Metadata-Version: 2.4
Name: tianlong-toolkit
Version: 0.2.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)

> Agent 健康监控、安全约束与进化评估。从架构蓝图到可安装的 Python 工具箱。
>
> 版本: **v0.2.0** | 54 tests passing

## 安装

```bash
pip install tianlong-toolkit
```

## 模块

### monitor — Agent 健康监控

内置5项检查，可扩展，支持 text/json 输出。

```bash
# 检查当前目录下的 Agent 项目
tianlong-monitor

# 指定项目目录
tianlong-monitor -d /path/to/agent-project

# JSON 输出
tianlong-monitor -d /path/to/agent-project -o json
```

```python
from tianlong.monitor import run_all_checks
from pathlib import Path

report = run_all_checks(Path("/path/to/agent"))
print(report.to_json())
print(f"状态: {report.overall}, 退出码: {report.exit_code}")
```

### safety — SafetyGuard 安全约束引擎

基于 Misevolution 论文 (arXiv:2509.26354) 设计的双重门控安全系统。

- **5条红线规则**: R1删除确认 / R2不泄露 / R3不破坏 / R4不修改自身 / R5不自主授权
- **进化门控**: 按变更类型分配风险等级 (create/update/config/delete)
- **退化检测**: 3次退化自动暂停，防止对齐降级
- **审计日志**: 所有安全检查记录可导出

```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}")

# 退化检测
guard.record_degradation("错误重复率", "同类错误出现3次")

# 审计日志
guard.save_audit_log("audit-log.json")
```

### judge — (规划中) Agent-as-a-Judge 进化方向评估

## 开发

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