Selectively port source hashing, locked manifest/memory writes, path-aware link lint and graph analysis, and revision-checked staging from upstream 4f457e154653756b04802d5aeb25c20f42b4770c. Record source hashes and exclusions. Preserve local archive/catalog citations, curated manifest metadata, config location, file-index and MCP behavior. Wire maintenance guidance into four skills without migrating vault contents or changing running services. Validation: 609 tests passed, including existing MCP/file-asset regressions and imported upstream maintenance tests. Read-only vault status left shared metadata hashes unchanged. Wiki MCP remains inactive; orders MCP is active.
93 lines
2.4 KiB
Python
Executable File
93 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Single user-facing operations entrypoint for this repository."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import Sequence
|
|
|
|
|
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
REPO_ROOT = SCRIPT_DIR.parent
|
|
|
|
for path in (REPO_ROOT, SCRIPT_DIR):
|
|
if str(path) not in sys.path:
|
|
sys.path.insert(0, str(path))
|
|
|
|
from obsidian_wiki.cli import main as obsidian_cli_main
|
|
|
|
import manage_mcp_service
|
|
|
|
|
|
HELP_TEXT = """obsidian-wiki user operations
|
|
|
|
Usage:
|
|
scripts/obsidian-wiki-ops.py help
|
|
|
|
scripts/obsidian-wiki-ops.py setup [args...]
|
|
scripts/obsidian-wiki-ops.py info
|
|
scripts/obsidian-wiki-ops.py file-index rebuild [args...]
|
|
scripts/obsidian-wiki-ops.py lint [vault] --json
|
|
scripts/obsidian-wiki-ops.py memory status --vault /path/to/vault
|
|
scripts/obsidian-wiki-ops.py staging list --vault /path/to/vault --json
|
|
|
|
|
|
scripts/obsidian-wiki-ops.py mcp start [args...]
|
|
scripts/obsidian-wiki-ops.py mcp tools list
|
|
scripts/obsidian-wiki-ops.py mcp status
|
|
scripts/obsidian-wiki-ops.py mcp stop
|
|
scripts/obsidian-wiki-ops.py mcp uninstall
|
|
|
|
scripts/obsidian-wiki-ops.py daily-update [args...]
|
|
|
|
Notes:
|
|
Use --help after any forwarded command to see that command's detailed options.
|
|
"""
|
|
|
|
|
|
CLI_COMMANDS = {
|
|
"setup",
|
|
"list",
|
|
"info",
|
|
"file-index",
|
|
"mcp-server",
|
|
"bot-view",
|
|
"graph-analyse", "cache-check", "projects-check", "cache-update",
|
|
"cache-hash", "staging", "lint", "memory",
|
|
}
|
|
|
|
|
|
def print_help() -> int:
|
|
print(HELP_TEXT, end="")
|
|
return 0
|
|
|
|
|
|
def run_script(script_name: str, args: Sequence[str]) -> int:
|
|
script = SCRIPT_DIR / script_name
|
|
completed = subprocess.run([str(script), *args], check=False)
|
|
return int(completed.returncode)
|
|
|
|
|
|
def main(argv: Sequence[str] | None = None) -> int:
|
|
args = list(sys.argv[1:] if argv is None else argv)
|
|
if not args or args[0] in {"help", "-h", "--help"}:
|
|
return print_help()
|
|
|
|
command, *rest = args
|
|
if command in CLI_COMMANDS:
|
|
return obsidian_cli_main([command, *rest])
|
|
if command == "mcp":
|
|
return manage_mcp_service.main(rest)
|
|
if command == "daily-update":
|
|
return run_script("daily-update.sh", rest)
|
|
|
|
print(f"Unknown command: {command}", file=sys.stderr)
|
|
print("Run `scripts/obsidian-wiki-ops.py help` for available operations.", file=sys.stderr)
|
|
return 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|