feat: --verify-new-cron模式 + MEMORY.md流程

- 新增 --verify-new-cron 参数:创建cron后立即验证文档+注册完整性
- 自动检查cron-catalog.md和pipeline_registry.json
- 缺失时读脚本docstring自动补全
- MEMORY.md更新新增组件流程,强调"趁上下文还热"验证
This commit is contained in:
知微
2026-06-27 02:31:18 +08:00
parent 2912b127e3
commit 8474effcad
+43
View File
@@ -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()