diff --git a/gateway/scripts/dashboard.py b/gateway/scripts/dashboard.py index 4a23da5..5d4f966 100644 --- a/gateway/scripts/dashboard.py +++ b/gateway/scripts/dashboard.py @@ -661,6 +661,49 @@ def api_monitor(): return jsonify(result) +# ════════════════════════════════════════════════════════════ +# E — 元成长回路可视化 +# ════════════════════════════════════════════════════════════ +@app.route("/api/metagrowth") +def api_metagrowth(): + """元成长回路(Phase 3 规划中)""" + try: + # 统计已完成的修复次数 + todo_file = TEMP_DIR / "health_todos.jsonl" + total_fixes = 0 + completed_fixes = 0 + if todo_file.exists(): + with open(str(todo_file)) as f: + for line in f: + line = line.strip() + if line: + total_fixes += 1 + entry = json.loads(line) + if entry.get("status") == "completed": + completed_fixes += 1 + # 统计 git 提交次数(用作开发活动指标) + git_dir = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")) + commit_count = 0 + try: + r = subprocess.run(["git", "rev-list", "--count", "HEAD"], + cwd=git_dir, capture_output=True, text=True, timeout=5) + if r.returncode == 0: + commit_count = int(r.stdout.strip()) + except: + pass + return jsonify({ + "ok": True, + "status": "planned", # Phase 3 + "total_fixes": total_fixes, + "completed_fixes": completed_fixes, + "commit_count": commit_count, + "meta_growth_enabled": False, + "description": "E 元成长回路是 Phase 3 范围。启用后将自动分析修复模式并扩展检查规则。", + }) + except Exception as e: + return jsonify({"ok": False, "error": str(e)}) + + # ════════════════════════════════════════════════════════════ # D — 自修复流水线可视化 # ════════════════════════════════════════════════════════════ diff --git a/gateway/scripts/templates/dashboard.html b/gateway/scripts/templates/dashboard.html index 78ae981..3c5e169 100644 --- a/gateway/scripts/templates/dashboard.html +++ b/gateway/scripts/templates/dashboard.html @@ -3,21 +3,29 @@
-