CLI 用于本地灌数据与脚本化回测; API 用于前端 / 别的 Agent 调用; 同一套 repository 层 支撑, 行为一致。--db 可被环境变量 SATAGENT_DB 覆盖, 默认在 agent/data/agent.db。
所有子命令支持 --db PATH 全局参数。错误从 stderr 输出, 非零 exit code。--text 必填项缺失时退出码 2。
启动: uvicorn satellite_agent.api:app --reload · Swagger UI: http://127.0.0.1:8000/docs
MVP 阶段 FastAPI 用默认 422 / 404 / 500, 无自定义错误码。
本地日常跟踪 · 前端对接 · CI 回归门。
# 把今天的几条新闻塞进 JSONL cat > today.jsonl <<EOF {"title":"...","content":"...","occurred_at":"2026-06-01T10:00:00"} {"title":"...","content":"...","occurred_at":"2026-06-01T15:30:00"} EOF satagent ingest-file today.jsonl satagent report --window 7 --format md > weekly.md
// 1. 灌入事件 const r = await fetch('/events/ingest', { method: 'POST', headers: {'content-type': 'application/json'}, body: JSON.stringify({title, text, occurred_at}), }); const { id, classification } = await r.json(); // 2. 拉本周报告 const w = await fetch('/report/weekly?window=7&format=json').then(r => r.json()); // w.thread_scores / w.risks / w.next_tracking ...
# .github/workflows/regression.yml - run: pip install -e ".[dev]" - run: pytest -q # 含 test_regression.py - run: satagent regress samples/labeled_regression.jsonl