Skip to content

GodModeAI2025/SkillSafeWerkstatt / maintain-llm-wiki

maintain-llm-wiki

Unverified

Create, maintain, inventory, migrate, recover, quality-review, optionally clean, release, or export an evidence-linked SkillSafeWerkstatt Markdown wiki. Use whenever the user wants to initialize or extend this wiki, ingest documents as Markdown, curate claims, clusters or concepts, clean metadata, restore files, record who reviewed which pages, resolve a OneDrive or SharePoint conflict copy, publish a release, or export a frozen read-only knowledge skill or an Open Knowledge Format bundle in Claude Code, Claude Cowork, or Codex.

FileKindSize
SKILL.mdskill md57.2 KB
assets/graph-template.htmlother27.8 KB
assets/knowledge-skill/SKILL.template.mdmarkdown35.6 KB
assets/knowledge-skill/assess_quality.pyscript1.5 KB
assets/knowledge-skill/identity_status.pyscript5.9 KB
assets/knowledge-skill/search_knowledge.pyscript4.5 KB
assets/knowledge-skill/verify_knowledge.pyscript4.8 KB
assets/page-template.htmlother7.4 KB
evals/evals.jsonconfig32.6 KB
references/adapted-vault-standards.mdmarkdown3.3 KB
references/frontmatter-operations.mdmarkdown9.8 KB
references/wiki-contract.mdmarkdown73.0 KB
scripts/adopt_directory.pyscript13.2 KB
scripts/apply_identity.pyscript3.1 KB
scripts/bm25.pyscript8.2 KB
scripts/build_graph.pyscript27.0 KB
scripts/claim_id.pyscript1.9 KB
scripts/describe_actions.pyscript13.2 KB
scripts/design_contract.pyscript217 B
scripts/export_okf_bundle.pyscript17.9 KB
scripts/export_wiki_skill.pyscript23.7 KB
scripts/findability_questions.pyscript17.6 KB
scripts/freshness.pyscript3.6 KB
scripts/frontmatter_actions.pyscript26.1 KB
scripts/frontmatter_contract.pyscript10.0 KB
scripts/identity_contract.pyscript15.2 KB
scripts/init_wiki.pyscript18.2 KB
scripts/initialize_wiki.pyscript12.2 KB
scripts/inventory_wiki.pyscript6.7 KB
scripts/lint_wiki.pyscript56.0 KB
scripts/move_wiki_page.pyscript6.7 KB
scripts/navigation.pyscript11.0 KB
scripts/okf_contract.pyscript14.3 KB
scripts/page_batch.pyscript11.4 KB
scripts/plan_identity.pyscript2.2 KB
scripts/plan_language_migration.pyscript4.9 KB
scripts/portable_io.pyscript3.3 KB
scripts/quality_core.pyscript15.9 KB
scripts/record_quality_review.pyscript3.4 KB
scripts/register_source.pyscript12.2 KB
scripts/release_wiki.pyscript15.9 KB
scripts/report_okf.pyscript3.8 KB
scripts/resolve_conflict_copy.pyscript11.0 KB
scripts/restore_wiki.pyscript16.1 KB
scripts/run_locked.pyscript2.2 KB
scripts/search_core.pyscript221.1 KB
scripts/secret_screen.pyscript4.1 KB
scripts/snapshot_wiki.pyscript6.7 KB
scripts/source_coverage.pyscript22.8 KB
scripts/sync_artifacts.pyscript14.2 KB
scripts/trust_contract.pyscript5.2 KB
scripts/validate_extraction.pyscript5.0 KB
scripts/verify_pages.pyscript9.1 KB
scripts/verify_release.pyscript12.1 KB
scripts/wiki_filters.pyscript6.6 KB
scripts/wiki_lock.pyscript59.2 KB
scripts/wordforms.pyscript56.0 KB

scripts/move_wiki_page.py

View on GitHub
#!/usr/bin/env python3
"""Preview or apply a safe wiki-page move and rewrite internal wikilinks."""

from __future__ import annotations

import argparse
import hashlib
import json
import re
import sys
from pathlib import Path, PurePosixPath, PureWindowsPath

# Siblings are imported from this folder even where the interpreter leaves it
# off sys.path: python -I, python -P, PYTHONSAFEPATH=1.
_SCRIPT_DIR = str(Path(__file__).resolve().parent)
if _SCRIPT_DIR not in sys.path:
    sys.path.insert(0, _SCRIPT_DIR)

from snapshot_wiki import create_snapshot
from wiki_lock import require_lock


WIKILINK = re.compile(r"\[\[([^\]]+)\]\]")
PROTECTED_PAGES = {"wiki/index.md", "wiki/overview.md"}


def portable_wiki_path(value: str) -> bool:
    normalized = value.replace("\\", "/").strip()
    path = PurePosixPath(normalized)
    if not normalized or PurePosixPath(normalized).is_absolute() or PureWindowsPath(normalized).is_absolute():
        return False
    return ".." not in path.parts and normalized.startswith("wiki/") and normalized.endswith(".md")


def link_target(raw: str) -> str:
    value = raw.split("|", 1)[0].split("#", 1)[0].strip()
    return value.removesuffix(".md").lstrip("./")


def rewrite_links(text: str, old_target: str, new_target: str) -> tuple[str, int]:
    replacements = 0

    def replace(match: re.Match[str]) -> str:
        nonlocal replacements
        raw = match.group(1)
        if link_target(raw) != old_target:
            return match.group(0)
        target_and_anchor, separator, alias = raw.partition("|")
        _, anchor_separator, anchor = target_and_anchor.partition("#")
        updated = new_target
        if anchor_separator:
            updated += "#" + anchor
        if separator:
            updated += "|" + alias
        replacements += 1
        return "[[" + updated + "]]"

    return WIKILINK.sub(replace, text), replacements


def sha256_file(path: Path) -> str:
    return hashlib.sha256(path.read_bytes()).hexdigest()


def plan_hash(value: dict[str, object]) -> str:
    encoded = json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8")
    return hashlib.sha256(encoded).hexdigest()


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--target", required=True, help="Target wiki directory")
    parser.add_argument("--lock-token", required=True, help="Token returned by wiki_lock.py acquire")
    parser.add_argument("--from-path", required=True, help="Existing vault-relative Markdown path")
    parser.add_argument("--to-path", required=True, help="New vault-relative Markdown path")
    parser.add_argument("--apply", action="store_true", help="Apply the move after the user approves the preview")
    parser.add_argument("--expect-preview-sha256", help="Required with --apply; binds the write to the approved preview")
    args = parser.parse_args()

    target = Path(args.target).expanduser().resolve()
    require_lock(target, args.lock_token)
    old_relative = args.from_path.replace("\\", "/").strip()
    new_relative = args.to_path.replace("\\", "/").strip()
    for label, value in (("from-path", old_relative), ("to-path", new_relative)):
        if not portable_wiki_path(value):
            raise SystemExit(f"{label} must be a portable .md path below wiki/")
    if old_relative in PROTECTED_PAGES:
        raise SystemExit("wiki/index.md and wiki/overview.md cannot be moved by category migration")
    if old_relative == new_relative:
        raise SystemExit("from-path and to-path must differ")

    source = target / old_relative
    destination = target / new_relative
    if not (target / "WIKI.md").is_file() or not source.is_file():
        raise SystemExit("Target or source page does not exist")
    if source.is_symlink():
        raise SystemExit("Source page may not be a symbolic link")
    if destination.exists():
        raise SystemExit("Destination already exists; refusing to overwrite")

    old_target = old_relative.removesuffix(".md")
    new_target = new_relative.removesuffix(".md")
    affected: list[dict[str, object]] = []
    for path in sorted(target.rglob("*.md")):
        relative = path.relative_to(target).as_posix()
        if relative.startswith("meta/history/"):
            continue
        if path.is_symlink():
            raise SystemExit(f"Move planning refuses symbolic link: {relative}")
        _, count = rewrite_links(path.read_text(encoding="utf-8"), old_target, new_target)
        if count:
            affected.append({"path": relative, "links": count})

    precondition_paths = sorted({old_relative, *(str(item["path"]) for item in affected)})
    plan: dict[str, object] = {
        "from": old_relative,
        "to": new_relative,
        "affected_files": affected,
        "preconditions": [
            {"path": relative, "sha256": sha256_file(target / relative)}
            for relative in precondition_paths
        ],
        "destination_must_not_exist": True,
        "external_link_warning": "Links stored outside this wiki cannot be rewritten automatically.",
    }
    preview_sha256 = plan_hash(plan)
    report: dict[str, object] = {"mode": "apply" if args.apply else "preview", **plan, "preview_sha256": preview_sha256}
    if not args.apply:
        print(json.dumps(report, ensure_ascii=False, indent=2))
        return 0

    if not args.expect_preview_sha256:
        raise SystemExit("--expect-preview-sha256 is required with --apply")
    if args.expect_preview_sha256 != preview_sha256:
        raise SystemExit("Move preview is stale or differs from the approved preview; no files were changed")

    snapshot = create_snapshot(
        target,
        args.lock_token,
        operation=f"move:{old_relative}->{new_relative}",
        selected_files=[*precondition_paths, new_relative],
    )
    report["snapshot"] = snapshot["snapshot"]

    destination.parent.mkdir(parents=True, exist_ok=True)
    source.replace(destination)
    rewritten: list[dict[str, object]] = []
    for path in sorted(target.rglob("*.md")):
        relative = path.relative_to(target).as_posix()
        if relative.startswith("meta/history/"):
            continue
        original = path.read_text(encoding="utf-8")
        updated, count = rewrite_links(original, old_target, new_target)
        if count:
            path.write_text(updated, encoding="utf-8")
            rewritten.append({"path": relative, "links": count})
    report["rewritten_files"] = rewritten
    print(json.dumps(report, ensure_ascii=False, indent=2))
    return 0


if __name__ == "__main__":
    # Windows pipes default to the ANSI code page; output is UTF-8 everywhere.
    for _stream in (sys.stdout, sys.stderr):
        if hasattr(_stream, "reconfigure"):
            _stream.reconfigure(encoding="utf-8", errors=_stream.errors)
    raise SystemExit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall