Generate or update a structured markdown wiki from the current codebase using local-rag semantic search. Produces architecture docs, module pages, entity pages, guides, and Mermaid diagrams in a wiki/ directory. Use when the user asks to generate documentation, create a wiki, or document the project.
Generate a structured, cross-linked markdown wiki from the current codebase using local-rag MCP tools. The wiki is built by querying the semantic index — not by bulk-reading source files.
wiki/
_manifest.json # Tracks pages, source files, git ref for incremental updates
index.md # Landing page with one-line summaries per entry
log.md # Append-only changelog of wiki operations
architecture.md # High-level overview
data-flow.md # How data moves through the system
api-surface.md # Public API / entry points / CLI commands
glossary.md # Domain terms and project-specific jargon
modules/
<module>/
index.md # Module overview
internals.md # Internal implementation details (optional, large modules)
entities/
<entity-name>.md # Key symbols (classes, widely-used functions, central types)
guides/
getting-started.md # What you need to know to start working in this codebase
conventions.md # Patterns, naming, error handling approaches found in the code
testing.md # How tests are structured, what's covered
[Name](../entities/foo.md)). Never use Obsidian [[wikilinks]].hybrid-search.md, not HybridSearch.md).graph TD for hierarchies, graph LR for pipelines, sequenceDiagram for flows, classDiagram for entity relationships.graph, subgraph, end, style, classDef, click, linkStyle, class, default, node, edge. Always suffix them (e.g., depGraph, graphTools, endNode).top values than defaults (see per-phase instructions). Missing context produces shallow pages.read_relevant, search_symbols, project_map, etc.) to gather information. Do not Read entire source files.read_relevant or search_symbols actually returned. If a chunk shows function foo(query: string, db: RagDB, topK: number), write exactly that. Never invent parameter names, reorder parameters, or assume units (e.g., "tokens" vs "characters") without seeing the source.search_symbols(symbol: "<module-prefix>", type: "export") results. Do not list functions that weren't in the results. Do not rename functions to what they "probably" are.Check if wiki/_manifest.json exists by trying to read it.
Gather the information needed to plan the wiki.
server_info(). If 0 files are indexed, call index_files() first.git_context() to get the current HEAD ref (store this for the manifest).project_map(zoom: "directory", maxNodes: 100) to identify top-level modules.project_map(maxNodes: 100) for the file-level dependency graph.search_analytics() to identify documentation gaps.From the results, build a list of:
Generate the three top-level architecture documents.
read_relevant("project architecture entry points main modules", top: 20).read_relevant("configuration setup initialization", top: 20).read_relevant("data flow request handling pipeline processing", top: 20).read_relevant("public API exports CLI commands endpoints", top: 20).Then write:
wiki/architecture.md# Architecture
## Overview
One-paragraph project summary.
## Module Map
How modules relate to each other.
(Mermaid dependency graph generated from project_map — use graph TD, one node
per module, edges showing import direction)
## Entry Points
Where execution starts, what the public API surface is.
## Configuration
How the project is configured, key config files and options.
## Design Decisions
Key architectural choices and their rationale.
wiki/data-flow.md# Data Flow
## Overview
How data enters, moves through, and exits the system.
## Primary Flows
Each major flow as a section with a Mermaid sequence diagram.
## Error Paths
How errors propagate through the system.
wiki/api-surface.md# API Surface
## Public API
Exported functions, classes, endpoints grouped by module.
## CLI Commands
If applicable — command names, arguments, behavior.
## Configuration Options
Public-facing config keys and what they control.
For each top-level module identified in Phase 1:
project_map(focus: "<module-entry-file>", maxNodes: 100) for internal structure.depends_on("<module-entry>") and depended_on_by("<module-entry>").read_relevant("<module-name> purpose responsibilities", top: 15).search_symbols(symbol: "<module-prefix>", exact: false, type: "export", top: 30) to discover exports.Then write wiki/modules/<module-name>/index.md:
# <Module Name>
## Purpose
What this module does and why it exists.
## Structure
(Mermaid graph of internal file dependencies — use graph LR, one node per file,
edges showing internal imports)
## Files
- `path/to/file.ts` — brief description of what it does
## Key Exports
- `functionName` — what it does
- `ClassName` — what it represents
## Dependencies
What this module imports from other modules (with links to their module pages).
## Dependents
What other modules depend on this one (with links to their module pages).
## See Also
- Links to related module pages and entity pages for key exports
If the module has 10+ files or 15+ exports, also write
wiki/modules/<module-name>/internals.md with a detailed breakdown of internal