praneybehl/llm-wiki-plugin / skills/llm-wiki
llm-wiki
VerifiedBuild and maintain an LLM-curated knowledge base from papers, articles, transcripts, notes and project findings. Ingest sources into linked Markdown, answer questions with citations, lint or upgrade a wiki, and preserve useful synthesis across sessions and agents. Also capture verified task experience, consolidate success/failure patterns, and propose, evaluate, apply or roll back evidence-linked skill improvements. Trigger on "add this to my wiki", "what does the wiki say", "learn from this task", "improve this procedure", /wiki:learn or /wiki:evolve. Works on a local folder or a hosted wiki URL (MCP). Use index-first navigation, atomic pages and hybrid search.
scripts/init_wiki.py
View on GitHub#!/usr/bin/env python3
"""
init_wiki.py — Bootstrap or upgrade an LLM Wiki at a chosen filesystem location.
Plain init creates the directory layout and drops in templates for SCHEMA.md,
index.md, log.md, the page template, and the optional graph layer
(graph/ontology.yaml, graph/README.md, graph/.gitignore). It is idempotent:
re-running won't clobber existing files.
Both modes then install and verify the pinned local runtime, model cache,
parse cache, and vectors for every current wiki section through `uv`.
`--upgrade` mode is for wikis bootstrapped under an older plugin version. It
does the same idempotent file creation, then inspects the existing SCHEMA.md
for sections introduced in newer versions and prints clear instructions for
what to merge by hand. It never overwrites SCHEMA.md — the schema is
co-evolved with the user.
Usage:
python init_wiki.py <base-dir> [--wiki-dir wiki] [--raw-dir raw] [--upgrade]
Examples:
python init_wiki.py .
python init_wiki.py . --upgrade
python init_wiki.py ~/research --wiki-dir kb --raw-dir sources
"""
import argparse
import shutil
import subprocess
import sys
from pathlib import Path
from datetime import date
SKILL_ROOT = Path(__file__).resolve().parent.parent
TEMPLATES = SKILL_ROOT / "assets"
SUBDIRS = ["sources", "entities", "concepts", "synthesis", "graph"]
# Markers used by --upgrade to detect SCHEMA.md sections introduced in
# specific plugin versions. Each entry: (heading_marker, version_label,
# template_anchor, blurb).
SCHEMA_SECTION_MARKERS = [
{
"marker": "## Skill evolution",
"version": "3.2.0",
"anchor": "## Skill evolution",
"label": "Optional experience capture and tested skill evolution",
},
{
"marker": "## Optional graph metadata",
"version": "0.3.0",
"anchor": "## Optional graph metadata",
"label": "Optional graph metadata (Frontmatter section)",
},
{
"marker": "## Graph layer",
"version": "0.3.0",
"anchor": "## Graph layer",
"label": "Graph layer (canonical-vs-generated artifact policy)",
},
{
"marker": "Graph lint + extract",
"version": "0.3.0",
"anchor": "- Graph lint + extract: after every ingest that adds typed `graph.relationships`.",
"label": "Graph lint + extract cadence (Lint cadence section)",
},
{
"marker": "## Retrieval",
"version": "2.0.0",
"anchor": "## Retrieval",
"label": "Retrieval (section search and cache)",
},
{
"marker": "- Semantic backend: local FastEmbed + sqlite-vec",
"version": "3.0.0",
"anchor": "- Semantic backend: local FastEmbed + sqlite-vec",
"label": "Local semantic retrieval (FastEmbed + sqlite-vec)",
},
]
def copy_template(src: Path, dst: Path, substitutions: dict | None = None) -> bool:
"""Copy a template file to dst. Returns True if file was created, False if it already existed."""
if dst.exists():
return False
text = src.read_text()
if substitutions:
for key, value in substitutions.items():
text = text.replace(key, value)
dst.parent.mkdir(parents=True, exist_ok=True)
dst.write_text(text)
return True
def detect_schema_gaps(schema_path: Path) -> list[dict]:
"""Return the SCHEMA_SECTION_MARKERS entries missing from the user's SCHEMA.md."""
if not schema_path.exists():
return []
text = schema_path.read_text(encoding="utf-8")
def marker_present(marker: str) -> bool:
if marker.startswith("## "):
return any(line.strip() == marker for line in text.splitlines())
return marker in text
return [entry for entry in SCHEMA_SECTION_MARKERS if not marker_present(entry["marker"])]
def print_schema_upgrade_guidance(schema_path: Path, gaps: list[dict]) -> None:
template_path = TEMPLATES / "SCHEMA.md.template"
print()
print("=" * 64)
print(f"Upgrade required: {schema_path}")
print("=" * 64)
print(
"Your SCHEMA.md predates one or more sections or policy markers\n"
"introduced by newer plugin versions. Merge the items below by hand.\n"
"SCHEMA.md is co-evolved with you — this script never overwrites it."
)
print()
print("Missing sections:")
for m in gaps:
print(f" - [{m['version']}] {m['label']}")
print()
print(f"Reference template: {template_path}")
print(
"Diff your SCHEMA.md against the template and copy the missing\n"
"sections in. Or run /wiki:upgrade and Claude will propose the edits\n"
"interactively (one section at a time, never silent)."
)
def install_runtime(wiki: Path) -> None:
"""Install pinned dependencies, cache the model, and synchronize the wiki index."""
uv = shutil.which("uv")
if not uv:
print(
"Error: uv is required to install the pinned LLM Wiki runtime. "
"Install it from https://docs.astral.sh/uv/getting-started/installation/ "
"and rerun this command.",
file=sys.stderr,
)
raise SystemExit(1)
setup_script = Path(__file__).resolve().with_name("setup_wiki.py")
print()
print("Installing and verifying the local retrieval runtime...", flush=True)
try:
subprocess.run(
[uv, "run", "--script", str(setup_script), "--wiki", str(wiki), "--cache"],
check=True,
)
except subprocess.CalledProcessError as exc:
print(
f"Error: local retrieval setup failed with exit code {exc.returncode}.",
file=sys.stderr,
)
raise SystemExit(exc.returncode) from exc
def init_wiki(project_root: Path, wiki_dir: str, raw_dir: str, upgrade: bool = False) -> None:
project_root = project_root.resolve()
if not project_root.exists():
print(f"Error: base directory does not exist: {project_root}", file=sys.stderr)
sys.exit(1)
wiki = project_root / wiki_dir
raw = project_root / raw_dir
mode = "Upgrading" if upgrade else "Initializing"
print(f"{mode} LLM Wiki in: {project_root}")
print(f" Wiki directory: {wiki}")
print(f" Raw directory: {raw}")
print()
created = []
skipped = []
# Create wiki subdirs
for subdir in SUBDIRS:
d = wiki / subdir
if not d.exists():
d.mkdir(parents=True)
created.append(f"{wiki_dir}/{subdir}/")
else:
skipped.append(f"{wiki_dir}/{subdir}/")
# Create raw + raw/assets
for d, label in [(raw, raw_dir), (raw / "assets", f"{raw_dir}/assets")]:
if not d.exists():
d.mkdir(parents=True)
created.append(f"{label}/")
else:
skipped.append(f"{label}/")
# Copy templates
template_map = [
("SCHEMA.md.template", wiki / "SCHEMA.md"),
("index.md.template", wiki / "index.md"),
("log.md.template", wiki / "log.md"),
("page.md.template", wiki / ".page-template.md"),
("experience.json.template", wiki / ".experience-template.json"),
("pattern.md.template", wiki / ".pattern-template.md"),
("evolution_README.md.template", wiki / ".evolution" / "README.md"),
("ontology.yaml.template", wiki / "graph" / "ontology.yaml"),
("graph_README.md.template", wiki / "graph" / "README.md"),
("graph_gitignore.template", wiki / "graph" / ".gitignore"),
("wiki-cache_gitignore.template", wiki / ".wiki-cache" / ".gitignore"),
]
for src_name, dst in template_map:
src = TEMPLATES / src_name
if not src.exists():
print(f"Warning: template missing: {src}", file=sys.stderr)
continue
if copy_template(src, dst):
created.append(str(dst.relative_to(project_root)))
else:
skipped.append(str(dst.relative_to(project_root)))
# Report
if created:
print("Created:")
for path in created:
print(f" + {path}")
if skipped:
print("Already existed (skipped):")
for path in skipped:
print(f" = {path}")
install_runtime(wiki)
if upgrade:
gaps = detect_schema_gaps(wiki / "SCHEMA.md")
if gaps:
print_schema_upgrade_guidance(wiki / "SCHEMA.md", gaps)
else:
print()
print("SCHEMA.md is up to date with the current template — no manual merge needed.")
return
print()
print("Next steps:")
print(f" 1. Read {wiki_dir}/SCHEMA.md and customize it for your domain.")
print(f" 2. (Optional) Edit {wiki_dir}/graph/ontology.yaml to add domain-specific predicates.")
print(f" 3. Drop your first source into {raw_dir}/.")
print(f" 4. Ask Claude to ingest it.")
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("project_root", type=Path, metavar="BASE_DIR", help="Base directory containing the wiki and raw-source paths (for example a project root or home directory).")
parser.add_argument("--wiki-dir", default="wiki", help="Name of the wiki subdirectory (default: wiki).")
parser.add_argument("--raw-dir", default="raw", help="Name of the raw sources subdirectory (default: raw).")
parser.add_argument("--upgrade", action="store_true",
help="Upgrade an existing wiki: add missing files idempotently and surface SCHEMA.md sections to merge by hand.")
args = parser.parse_args()
init_wiki(args.project_root, args.wiki_dir, args.raw_dir, upgrade=args.upgrade)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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 available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |