Metadata-Version: 2.4
Name: tianlong-toolkit
Version: 0.9.0
Summary: 天龙工具箱 — Agent健康监控、安全约束与进化评估
Author: 天龙1号
License: MIT
Project-URL: Homepage, https://github.com/
Keywords: agent,monitoring,safety,ai-agent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# Tianlong Toolkit (天龙工具箱)

> AI Agent 健康监控、安全约束与进化评估 — 从架构蓝图到可安装的 Python 工具箱。

**版本: v0.8.0** · 383 tests · 纯标准库 · MIT 开源

```bash
pip install tianlong-toolkit==0.8.0
```

---

## 快速开始

### 健康检查
```bash
# 检查当前 Agent 项目
tianlong-monitor

# HTML 报告
tianlong-monitor -o html > report.html

# 批量检查多个项目
tianlong-monitor -m /project/a /project/b
```

```python
from tianlong.monitor import run_all_checks
report = run_all_checks("/path/to/agent")
print(report.to_json())
```

### 安全约束
```bash
# 检查操作是否安全
tianlong-safety check -a delete -t config.yaml

# 加载项目配置
tianlong-safety check -a create -t note.md -c .uxurc.yaml

# 查看规则列表
tianlong-safety rules
```

```python
from tianlong.safety import SafetyGuard, ChangeType, DEFAULT_RULES
guard = SafetyGuard(rules=DEFAULT_RULES)
result = guard.check(action=ChangeType.DELETE, target="config.yaml")
if not result.allowed:
    print(f"⛔ 阻止: {result.reason}")
```

### 进化评估
```bash
# 评估一个变更提案
tianlong-judge evaluate --proposal "优化搜索流程"

# 查看评估历史
tianlong-judge history

# 查看进化指标仪表盘
tianlong-judge metrics
```

---

## CI/CD 集成

```yaml
# .github/workflows/tianlong-audit.yml
steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-python@v5
    with: { python-version: '3.12' }
  - run: pip install tianlong-toolkit==0.8.0
  - run: tianlong-monitor -d . -o html >> $GITHUB_STEP_SUMMARY
```

完整模板见 `examples/tianlong-audit.yml`。

---

## 项目配置

在项目根目录创建 `.uxurc.yaml`：

```yaml
version: "1"
project:
  name: "my-agent"
  agent_framework: "langchain"  # auto/langchain/openai/custom
rules:
  enabled: true
  severity_threshold: "medium"
paths:
  exclude:
    - "node_modules/**"
    - ".venv/**"
```

---

## 模块

| 模块 | 定位 | CLI |
|------|------|-----|
| **monitor** | Agent 健康监控（8项检查 + HTML报告） | `tianlong-monitor` |
| **safety** | SafetyGuard 安全约束引擎（5红线 + .uxurc.yaml配置） | `tianlong-safety` |
| **judge** | Agent-as-a-Judge 进化方向评估（规则引擎/LLM双模式 + 22指标仪表盘） | `tianlong-judge` |
| **evolution** | SelfLearning 进化闭环（LEARN→ANALYZE→JUDGE→EVOLVE→PROPAGATE + Ralph Loop） | — |
| **reporter** | 主动汇报系统（4模板 + 跨模块数据聚合） | `tianlong-reporter` |
| **brain** | BrainCore 决策引擎（任务路由 + 优先级调度 + 中断处理） | `tianlong-brain` |
| **executor** | 执行层（技能优先级 + 执行前检查） | — |
| **agents** | Sub-Agent SDK（Research/Code/Executor/Monitor 配置） | — |
| **metacog** | MetaCogTrigger 元认知触发器（5类信号监测） | — |
| **onlinestate** | 在线状态管理器 | — |

---

## 项目结构

```
tianlong/
├── monitor/        健康监控 CLI
├── safety/         安全约束 CLI + .uxurc.yaml 配置
├── judge/          进化评估 CLI + 历史 + 22指标仪表盘
├── evolution/      SelfLearning 闭环 + 增量记忆
├── reporter/       汇报模板 CLI
├── brain/          决策引擎 + 子Agent派发
├── executor/       执行层
├── agents/         Sub-Agent SDK
├── metacog/        元认知触发
└── onlinestate/    在线状态
```

---

## 开发

```bash
git clone ...
cd tianlong-toolkit
pip install -e .
pytest tests/ -v
```

## 许可

MIT License
