chore: capture live morning state before session merge
This commit is contained in:
@@ -1340,6 +1340,72 @@ def api_xmpp_keys():
|
||||
return jsonify({"error": "xmpp_logger not available"}), 500
|
||||
|
||||
|
||||
# ── 开发原则 Tab 端点(仿 AgentsMeeting: G规范/K测试/H需求)──
|
||||
|
||||
DOCS_DIR = Path(__file__).resolve().parent / "docs"
|
||||
HEALTH_REPORT = Path(__file__).resolve().parent / "gateway" / "temp" / "last_health_check.json"
|
||||
|
||||
|
||||
@app.route("/api/spec")
|
||||
def api_spec():
|
||||
"""G 规范:docs/dev-spec.md 内容"""
|
||||
f = DOCS_DIR / "dev-spec.md"
|
||||
if not f.exists():
|
||||
return jsonify({"ok": False, "error": "dev-spec.md not found"})
|
||||
return jsonify({"ok": True, "content": f.read_text(encoding="utf-8")})
|
||||
|
||||
|
||||
@app.route("/api/spec/history")
|
||||
def api_spec_history():
|
||||
"""dev-spec.md 的 git 历史"""
|
||||
import subprocess
|
||||
try:
|
||||
r = subprocess.run(
|
||||
["git", "log", "--oneline", "-20", "--", "docs/dev-spec.md"],
|
||||
capture_output=True, timeout=10, text=True,
|
||||
cwd=str(Path(__file__).resolve().parent))
|
||||
lines = [l for l in r.stdout.splitlines() if l.strip()]
|
||||
return jsonify({"ok": True, "log": lines, "count": len(lines)})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)[:100]})
|
||||
|
||||
|
||||
@app.route("/api/tests")
|
||||
def api_tests():
|
||||
"""K 测试:agents_health_check 服务检查结果,渲染为 pass/fail 测试报告"""
|
||||
if not HEALTH_REPORT.exists():
|
||||
return jsonify({"ok": False, "error": "health report not found (cron not run yet)"})
|
||||
try:
|
||||
rep = json.loads(HEALTH_REPORT.read_text(encoding="utf-8"))
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)[:100]})
|
||||
tests = []
|
||||
for svc in rep.get("services", []):
|
||||
ok = svc.get("health", {}).get("ok", False)
|
||||
tests.append({
|
||||
"name": f"{svc.get('label', svc.get('name'))} ({svc.get('name')})",
|
||||
"ok": ok,
|
||||
"expected": False,
|
||||
"detail": svc.get("detail", ""),
|
||||
})
|
||||
passed = sum(1 for t in tests if t["ok"])
|
||||
return jsonify({
|
||||
"ok": True,
|
||||
"tests": tests,
|
||||
"summary": {"total": len(tests), "passed": passed, "failed": len(tests) - passed},
|
||||
"time": rep.get("generated_at", ""),
|
||||
})
|
||||
|
||||
|
||||
@app.route("/api/prd")
|
||||
def api_prd():
|
||||
"""H 需求:docs/prd.md(不存在则返回未建立)"""
|
||||
f = DOCS_DIR / "prd.md"
|
||||
if not f.exists():
|
||||
return jsonify({"ok": False, "error": "prd.md 尚未建立"})
|
||||
return jsonify({"ok": True, "content": f.read_text(encoding="utf-8")})
|
||||
|
||||
|
||||
# 注册提示词管理路由
|
||||
register_routes(app)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user