From 9e9b5d402984d9d0e02695201cd957acebea5bb6 Mon Sep 17 00:00:00 2001 From: weishen Date: Thu, 16 Apr 2026 17:09:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=95=B4=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 13 +++++++++++-- tools/manifest.json | 24 ++++++++++++------------ tools/sync.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 4747487..8aecaa6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -129,7 +129,16 @@ last_updated: YYYY-MM-DD 6. 创建或更新 Entity 页面 7. 创建或更新 Concept 页面 8. 检测并记录冲突 -9. 追加 `wiki/log.md` +9. 追加 `wiki/log.md`,**输出格式必须包含实际使用的 slug**: + ```markdown + ## 2026-04-16 + - [[sources/实际使用的-slug.md]] (raw/xxx.md) — 简短描述 + ``` + > ⚠️ 输出 **done** 后必须附加一行显示实际 slug,例如: + > ``` + > done + > SLUG: modern-itsm-driving-efficiency-security-resilience + > ``` > ⚠️ 本项目所有 ingest 操作直接通过 Claude Code agent 执行,不使用 `tools/ingest.py`(该脚本依赖 litellm 但未安装)。 @@ -187,7 +196,7 @@ last_updated: YYYY-MM-DD 2. 然后执行 /wiki-ingest /absolute/path/to/xxx.md 3. 严格按 CLAUDE.md 中的 9 步执行,不可跳过任何步骤 4. 每篇必须完成:source page + index.md + overview.md(如有必要)+ entity + concept + log.md - 5. 完成后输出 done' Enter + 5. 完成后输出 done,并附加一行:SLUG: 实际生成的-slug(用于更新 manifest)' Enter # 监控任务完成状态(等待看到 "done" 或任务完成提示)**[Hermes]** tmux capture-pane -t claude-wiki -p diff --git a/tools/manifest.json b/tools/manifest.json index 4efc2d9..d301275 100644 --- a/tools/manifest.json +++ b/tools/manifest.json @@ -77,42 +77,42 @@ "raw/Cloud & DevOps/These 6 Linux apps let you monitor system resources in style.md": { "hash": "a31075218ca6624e", "modified": "2026-04-14T04:28:42.641312+00:00", - "slug": "These-6-Linux-apps-let-you-monitor-system-resources-in-style", - "source_path": "wiki/sources/These-6-Linux-apps-let-you-monitor-system-resources-in-style.md", + "slug": "these-6-linux-apps-let-you-monitor-system-resources-in-style", + "source_path": "wiki/sources/these-6-linux-apps-let-you-monitor-system-resources-in-style.md", "ingested": true, "ingested_at": "2026-04-16T06:20:57+00:00" }, "raw/Cloud & DevOps/RTO vs RPO Key Differences for Modern Disaster Recovery.md": { "hash": "54e2ec8ad0a3202d", "modified": "2026-04-14T04:28:42.627898+00:00", - "slug": "RTO-vs-RPO-Key-Differences-for-Modern-Disaster-Recovery", - "source_path": "wiki/sources/RTO-vs-RPO-Key-Differences-for-Modern-Disaster-Recovery.md", + "slug": "rto-vs-rpo-key-differences-for-modern-disaster-recovery", + "source_path": "wiki/sources/rto-vs-rpo-key-differences-for-modern-disaster-recovery.md", "ingested": true, "ingested_at": "2026-04-16T06:35:00+00:00" }, "raw/Cloud & DevOps/How to Simplify Multi-Account Deployments Monitoring Centralized Logs for AWS CloudFormation StackSets.md": { "hash": "6719289e55a83ef8", "modified": "2026-04-14T04:28:42.627379+00:00", - "slug": "How-to-Simplify-Multi-Account-Deployments-Monitoring-Centralized-Logs-for-AWS-CloudFormation-StackSets", - "source_path": "wiki/sources/How-to-Simplify-Multi-Account-Deployments-Monitoring-Centralized-Logs-for-AWS-CloudFormation-StackSets.md", + "slug": "how-to-simplify-multi-account-deployments-monitoring", + "source_path": "wiki/sources/how-to-simplify-multi-account-deployments-monitoring.md", "ingested": true, "ingested_at": "2026-04-16T08:46:30.130439+00:00" }, "raw/Cloud & DevOps/Understanding Complete ITSM.md": { "hash": "71ce0a0425bf6c22", "modified": "2026-04-14T04:28:42.630861+00:00", - "slug": "Understanding-Complete-ITSM", - "source_path": "wiki/sources/Understanding-Complete-ITSM.md", + "slug": "modern-itsm-driving-efficiency-security-resilience", + "source_path": "wiki/sources/modern-itsm-driving-efficiency-security-resilience.md", "ingested": true, "ingested_at": "2026-04-16T08:46:30.130604+00:00" }, "raw/Cloud & DevOps/What is DevSecOps Best Practices, Benefits, and Tools.md": { "hash": "f4257c49bc1ec641", "modified": "2026-04-14T04:28:42.631251+00:00", - "slug": "What-is-DevSecOps-Best-Practices--Benefits--and-Tools", - "source_path": "wiki/sources/What-is-DevSecOps-Best-Practices--Benefits--and-Tools.md", - "ingested": false, - "ingested_at": null + "slug": "what-is-devsecops-best-practices-benefits-and-tools", + "source_path": "wiki/sources/what-is-devsecops-best-practices-benefits-and-tools.md", + "ingested": true, + "ingested_at": "2026-04-16T09:07:53.809640+00:00" }, "raw/Cloud & DevOps/Cloud Operating Model Key Strategies and Best Practices.md": { "hash": "a58d5e980eeaf214", diff --git a/tools/sync.py b/tools/sync.py index 417cdec..602d4f1 100755 --- a/tools/sync.py +++ b/tools/sync.py @@ -141,6 +141,37 @@ def call_ingest(abs_path: str, slug: str, json_mode: bool = False) -> dict: } +def parse_slug_from_output(output: str) -> str | None: + """从 TMUX 输出中解析 SLUG: xxx 行""" + import re + match = re.search(r"SLUG:\s*([a-zA-Z0-9_-]+)", output) + return match.group(1) if match else None + + +def update_manifest_with_slug(rel_path: str, actual_slug: str) -> bool: + """更新 manifest 中的 slug 和 source_path""" + import json + from datetime import datetime, timezone + + manifest_file = Path(__file__).parent / "manifest.json" + if not manifest_file.exists(): + return False + + try: + manifest = json.loads(manifest_file.read_text(encoding="utf-8")) + if rel_path in manifest["files"]: + manifest["files"][rel_path]["slug"] = actual_slug + manifest["files"][rel_path]["source_path"] = f"wiki/sources/{actual_slug}.md" + manifest["files"][rel_path]["ingested"] = True + manifest["files"][rel_path]["ingested_at"] = datetime.now(timezone.utc).isoformat() + manifest["updated_at"] = datetime.now(timezone.utc).isoformat() + manifest_file.write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding="utf-8") + return True + except Exception as e: + print(f"Error updating manifest: {e}") + return False + + def start_tmux_session() -> bool: """启动 TMUX session 用于 wiki ingest""" TMUX_SESSION = "wiki-ingest"