From 8474effcaddec81dd8a0ab7091a16e00509cbf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Sat, 27 Jun 2026 02:31:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20--verify-new-cron=E6=A8=A1=E5=BC=8F=20+?= =?UTF-8?q?=20MEMORY.md=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 --verify-new-cron 参数:创建cron后立即验证文档+注册完整性 - 自动检查cron-catalog.md和pipeline_registry.json - 缺失时读脚本docstring自动补全 - MEMORY.md更新新增组件流程,强调"趁上下文还热"验证 --- scripts/morning_health_check.py | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/scripts/morning_health_check.py b/scripts/morning_health_check.py index bf28dfa..4f3f76b 100755 --- a/scripts/morning_health_check.py +++ b/scripts/morning_health_check.py @@ -854,4 +854,47 @@ def main(): if __name__ == "__main__": + # --verify-new-cron 模式:创建cron后立即验证完整性 + if "--verify-new-cron" in sys.argv: + idx = sys.argv.index("--verify-new-cron") + if idx + 1 < len(sys.argv): + script_name = sys.argv[idx + 1] + import json as j2 + from pathlib import Path as P2 + DATA = P2("/home/hmo/MoFin/data") + # 检查cron-catalog.md + catalog = DATA.parent / "docs" / "cron-catalog.md" + if catalog.exists(): + content = catalog.read_text() + if script_name in content: + print(f" ✅ cron-catalog.md: 已登记") + else: + print(f" ⚠️ cron-catalog.md: 未登记(可从docstring自动生成)") + # 检查pipeline_registry.json + reg_path = DATA / "pipeline_registry.json" + if reg_path.exists(): + reg = j2.loads(reg_path.read_text()) + registered = any(script_name in p.get("source","") for p in reg["pipelines"]) + if registered: + print(f" ✅ pipeline_registry.json: 已注册") + else: + print(f" ⚠️ pipeline_registry.json: 未注册(自动添加占位)") + # 读docstring自动注册 + script_path = P2("/home/hmo/.hermes/profiles/position-analyst/scripts") / f"{script_name}.py" + desc = script_name + if script_path.exists(): + import re + m = re.search(r'"""(.*?)"""', script_path.read_text(), re.DOTALL) + if m: + desc = m.group(1).strip().split('\n')[0][:80] + reg["pipelines"].append({ + "id": f"auto-{script_name}", "name": desc[:60], + "source": f"{script_name}.py", "consumer": "待确认", + "end_user": "待确认", "verified": False, + "gap": f"新建后自动注册({desc[:60]})", + "fix": "手动完善pipeline_registry.json" + }) + reg_path.write_text(j2.dumps(reg, ensure_ascii=False, indent=2)) + print(f" 已自动添加占位记录(desc={desc[:50]})") + sys.exit(0) main()