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/snapshot_wiki.py

View on GitHub
#!/usr/bin/env python3
"""Snapshot wiki-controlled files before an incremental maintenance run."""

from __future__ import annotations

import argparse
import hashlib
import json
import os
import shutil
import sys
from datetime import datetime, timezone
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)

import portable_io
from typing import Any, Iterable, Optional
from uuid import uuid4

from wiki_lock import require_lock


def sha256_file(path: Path) -> str:
    digest = hashlib.sha256()
    with path.open("rb") as handle:
        for block in iter(lambda: handle.read(1024 * 1024), b""):
            digest.update(block)
    return digest.hexdigest()


def portable_relative(value: str) -> bool:
    posix = PurePosixPath(value)
    windows = PureWindowsPath(value)
    return bool(value) and not posix.is_absolute() and not windows.is_absolute() and not windows.drive and ".." not in posix.parts and "\\" not in value and posix.as_posix() == value


def default_candidates(target: Path) -> list[Path]:
    return [
        target / "WIKI.md",
        target / "WIKI_VERSION",
        target / "SOUL.md",
        target / "schema",
        target / "wiki",
        target / "meta/sources.jsonl",
        target / "meta/changes.md",
        target / "meta/questions.md",
        target / "meta/lint-report.json",
        target / "meta/releases.jsonl",
        target / "meta/quality-reviews.jsonl",
        target / "meta/quality-status.json",
        target / "meta/manifest.json",
    ]


def selected_candidates(target: Path, selected_files: Iterable[str]) -> list[Path]:
    candidates: list[Path] = []
    for relative in selected_files:
        if not portable_relative(relative):
            raise ValueError(f"snapshot path is not portable: {relative!r}")
        candidate = target / relative
        try:
            candidate.resolve().relative_to(target)
        except ValueError as exc:
            raise ValueError(f"snapshot path escapes the wiki: {relative!r}") from exc
        if candidate.is_symlink():
            raise ValueError(f"snapshot refuses symbolic link: {relative!r}")
        candidates.append(candidate)
    return candidates


def create_snapshot(
    target: Path,
    lock_token: str,
    run_id: Optional[str] = None,
    operation: str = "maintenance",
    selected_files: Optional[Iterable[str]] = None,
) -> dict[str, Any]:
    target = target.expanduser().resolve()
    lock = require_lock(target, lock_token)
    if not (target / "WIKI.md").is_file():
        raise SystemExit("Target is not an initialized SkillSafeWerkstatt")

    run_id = run_id or datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S%fZ") + "-" + uuid4().hex[:8]
    if not run_id.replace("-", "").replace("_", "").isalnum():
        raise SystemExit("run-id may contain only letters, digits, hyphens, and underscores")

    destination = target / "meta/history" / run_id
    if destination.exists():
        raise SystemExit(f"Snapshot already exists: meta/history/{run_id}")

    temporary = destination.with_name(f".{run_id}.{uuid4().hex}.tmp")
    copied: list[str] = []
    missing: list[str] = []
    candidates = selected_candidates(target, selected_files) if selected_files is not None else default_candidates(target)
    try:
        for candidate in candidates:
            if not candidate.exists():
                if selected_files is not None:
                    missing.append(candidate.relative_to(target).as_posix())
                continue
            if candidate.is_symlink():
                raise ValueError(f"snapshot refuses symbolic link: {candidate.relative_to(target).as_posix()}")
            if candidate.is_dir():
                symbolic = [path.relative_to(target).as_posix() for path in candidate.rglob("*") if path.is_symlink()]
                if symbolic:
                    raise ValueError(f"snapshot refuses symbolic links: {symbolic}")
            relative = candidate.relative_to(target)
            output = temporary / relative
            if candidate.is_dir():
                shutil.copytree(candidate, output)
                copied.extend(path.relative_to(target).as_posix() for path in candidate.rglob("*") if path.is_file() and not path.is_symlink())
            elif candidate.is_file():
                output.parent.mkdir(parents=True, exist_ok=True)
                shutil.copy2(candidate, output)
                copied.append(relative.as_posix())
        copied = sorted(set(copied))
        entries = []
        for relative in copied:
            snapshot_file = temporary / relative
            entries.append({"path": relative, "bytes": snapshot_file.stat().st_size, "sha256": sha256_file(snapshot_file)})
        snapshot_record = {
            "format": "lmwiki-snapshot/1",
            "snapshot_id": run_id,
            "created_at": datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"),
            "operation": operation,
            "lock_id": str(lock.get("lock_id") or ""),
            "files": entries,
            "missing": sorted(set(missing)),
        }
        temporary.mkdir(parents=True, exist_ok=True)
        (temporary / "snapshot.json").write_text(json.dumps(snapshot_record, ensure_ascii=False, indent=2, sort_keys=True) + "\n", encoding="utf-8")
        destination.parent.mkdir(parents=True, exist_ok=True)
        portable_io.replace_with_retry(temporary, destination)
    finally:
        if temporary.exists():
            shutil.rmtree(temporary)
    return {"snapshot": f"meta/history/{run_id}", "snapshot_id": run_id, "operation": operation, "copied": copied, "missing": sorted(set(missing))}


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--target", required=True)
    parser.add_argument("--lock-token", required=True, help="Token returned by wiki_lock.py acquire")
    parser.add_argument("--run-id", help="Optional filesystem-safe run identifier")
    parser.add_argument("--operation", default="maintenance")
    args = parser.parse_args()

    target = Path(args.target).expanduser().resolve()
    report = create_snapshot(target, args.lock_token, args.run_id, args.operation)
    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 CodeCodexUnverifiedInstall
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