完整测试通过
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user