Technical design for the LLM Wiki system.
┌──────────────────────────────────────────────────────────────────┐
│ Human Interface │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────────┐ │
│ │ VS Code │ │ Obsidian │ │ GitHub Web │ │
│ │ Extension │ │ (read-only) │ │ (browse) │ │
│ └──────┬───────┘ └──────────────┘ └────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ @llmwiki/ │◄────────│ MCP Server │◄── External LLM │
│ │ shared │ │ (in-proc / │ Agents │
│ │ │ │ stdio) │ (Claude, GPT, …) │
│ └──────┬───────┘ └──────────────┘ │
└─────────┼────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ Git Repository │
│ │
│ ┌────────────┐ ┌────────────┐ ┌───────────────────┐ │
│ │ raw/ │ │ wiki/ │ │ AGENTS.md │ │
│ │ (sources) │──▶│ (generated)│◀─│ (schema) │ │
│ │ immutable │ │ LLM-owned │ │ conventions │ │
│ └────────────┘ └────────────┘ └───────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────┘
The human-curated collection of source documents. Articles, papers, images, data files, notes clipped from the web.
- Immutable. The LLM reads from this layer but never modifies it.
- Source of truth. All wiki content traces back to raw sources.
- Format-agnostic. Markdown, PDF, plain text, images — anything the LLM can read.
- Organized by the human. Subdirectories are optional and user-defined (e.g.,
raw/papers/,raw/articles/).
LLM-generated markdown files — the compiled knowledge base.
- LLM-owned. The LLM creates, updates, and deletes wiki pages. Humans read but don't edit.
- Interlinked. Pages cross-reference each other with standard markdown links.
- Typed pages. Summaries, entity pages, concept pages — defined via YAML frontmatter (
typefield). - Two special files:
wiki/index.md— Content catalog. Every page listed with a link, one-line summary, and metadata. Organized by H2 category headings (## Entities,## Concepts,## Sources). The extension reads this for query matching and lint checking.wiki/log.md— Chronological append-only record of operations (ingests, queries, lint passes). Each entry has the format## [YYYY-MM-DD] verb | subjectfollowed by detail text.
The conventions document that tells the LLM how the wiki is structured and what workflows to follow.
- Co-evolved. Human and LLM refine this together as patterns emerge.
- Prescriptive. Defines page types, frontmatter schema, naming conventions, cross-referencing rules.
- Auto-generated. The LLM Wiki: Initialize Wiki command creates a starter template with seven sections: page types, directory structure, frontmatter schema, naming conventions, ingest workflow, lint rules, and cross-referencing guidelines.
- Starts minimal. Grows with use as the team discovers what works.
- Runtime: Node.js ≥ 20
- Language: TypeScript (ES2022 target, NodeNext modules, strict mode)
- Build tools: esbuild for the VS Code extension,
tscfor the shared library - Test framework: Vitest (single config at the repo root)
- Frontmatter parsing: gray-matter (in
@llmwiki/core) - MCP SDK: @modelcontextprotocol/sdk (in
@llmwiki/core) - Monorepo: npm workspaces with build order
shared → vscode - Distribution:
npm run package --workspace=packages/vscodeproduces a.vsix
The project is an npm workspaces monorepo with two packages:
llmwiki/
├── packages/
│ ├── core/ # @llmwiki/core — core wiki operations + MCP server
│ │ ├── src/
│ │ │ ├── index.ts # Barrel export
│ │ │ ├── constants.ts # API_VERSION
│ │ │ ├── errors.ts # isNotFoundError, isPermissionError
│ │ │ ├── lock.ts # withWikiLock (cross-process wiki write lock)
│ │ │ ├── wiki.ts # readPage, writePage, listPages, getPageLinks,
│ │ │ │ # directoryExists, createEntityPage,
│ │ │ │ # createConceptPage, addCrosslinks
│ │ │ ├── index-ops.ts # readIndex, writeIndex, addEntry, removeEntry,
│ │ │ │ # findEntries, updateIndexEntry
│ │ │ ├── log.ts # appendEntry, readLog, getRecentEntries
│ │ │ ├── sources.ts # listSources (raw/ directory metadata)
│ │ │ ├── backlinks.ts # getBacklinks (reverse link resolution)
│ │ │ ├── lint.ts # lintWiki (6 check categories)
│ │ │ ├── utils.ts # slugify, excerpt
│ │ │ ├── search.ts # countOccurrences (case-insensitive matching)
│ │ │ ├── init.ts # initWiki (directory scaffolding, AGENTS.md template)
│ │ │ ├── ingest.ts # ingestSource (single-file ingest)
│ │ │ ├── ingest-context.ts # ingestWithContext (enriched response)
│ │ │ ├── bulk-ingest.ts # bulkIngest (batch ingest helper)
│ │ │ ├── fix.ts # fixWiki (orphaned derived pages + lintFix in one pass)
│ │ │ ├── query.ts # queryWiki, slugifyQuery (weighted search)
│ │ │ ├── status.ts # getWikiStatus (aggregate statistics)
│ │ │ └── mcp/
│ │ │ ├── index.ts # Barrel export
│ │ │ ├── server.ts # createMcpServer — registers tools, dispatches
│ │ │ ├── read-tools.ts # 7 read-only tools (+ ToolDefinition/annotations types)
│ │ │ ├── write-tools.ts # 9 write tools (incl. wiki_fix, wiki_delete_page)
│ │ │ ├── workspace-tools.ts # wiki_open, wiki_init (discovery mode only)
│ │ │ ├── wiki-root.ts # WikiRootState — fixed root or discovery (roots, cwd, open)
│ │ │ ├── instructions.ts # Server instructions (+ the wiki's AGENTS.md)
│ │ │ ├── schemas.ts # Output schemas for structured tool results
│ │ │ ├── completions.ts # Argument completions for templates and prompts
│ │ │ ├── resources.ts # resource://wiki/* resources and templates
│ │ │ ├── prompts.ts # Prompt templates (ingest, lint, research)
│ │ │ └── bin.ts # llmwiki-mcp stdio launcher (shebang + StdioServerTransport)
│ │ ├── package.json # @llmwiki/core (bin: llmwiki-mcp)
│ │ └── tsconfig.json
│ │
│ └── vscode/ # llmwiki — VS Code extension
│ ├── src/
│ │ ├── extension.ts # activate/deactivate — wires providers & watchers
│ │ ├── commands.ts # Command handlers (init, ingest, query, status, lint, fix, …)
│ │ ├── llmIngest.ts # LM API enrichment pipeline for single-file ingest
│ │ ├── statusBar.ts # StatusBarManager — debounced live page count
│ │ ├── wikiPagesTree.ts # WikiPagesTreeDataProvider (Entities/Concepts/Sources)
│ │ ├── rawSourcesTree.ts # RawSourcesTreeDataProvider (raw/ browser)
│ │ ├── backlinksTree.ts # BacklinksTreeDataProvider (reverse links)
│ │ ├── lintFindingsTree.ts # LintFindingsTreeDataProvider (severity-grouped)
│ │ └── mcpProvider.ts # vscode.lm.registerMcpServerDefinitionProvider → llmwiki-mcp
│ ├── package.json # VS Code extension manifest (incl. chatSkills/chatAgents/chatInstructions)
│ └── esbuild.config.mjs # CJS bundles + plugin server bundle + copies chat customizations
│
├── plugin/ # Agent plugin (Agent Plugins 1.0)
│ ├── plugin.json # Manifest
│ ├── mcp.json # Starts server/llmwiki-mcp.cjs with node
│ ├── server/llmwiki-mcp.cjs # Generated, committed MCP server bundle
│ ├── skills/ # wiki-ask, wiki-research, wiki-ingest, wiki-save, wiki-fix
│ └── com.github.copilot/
│ ├── agents/ # wiki-librarian.agent.md
│ └── rules/ # llmwiki.instructions.md (applyTo .wiki/**)
│
├── tests/
│ ├── shared/ # Shared library tests (incl. mcp/)
│ ├── vscode/ # Extension tests (mocked vscode module)
│ │ └── integration/ # Real VS Code tests (npm run test:integration)
│ ├── plugin/ # Plugin validation + stdio e2e of the bundle
│ └── fixtures/ # Test fixture data
├── .github/
│ ├── plugin/marketplace.json # Marketplace index for the agent plugin
│ └── workflows/
│ └── ci.yml # CI — lint, build, test on push/PR to main
├── package.json # Workspace root — workspaces:
│ # [packages/core, packages/vscode]
├── tsconfig.base.json # Shared TypeScript config
├── tsconfig.json # Root references
├── vitest.config.ts # Single test config
├── AGENTS.md # Schema conventions (generated by init)
├── README.md
├── ARCHITECTURE.md
├── SECURITY.md
└── LICENSE # MIT
A wiki instance (created by the LLM Wiki: Initialize Wiki command) has this layout:
<workspace>/.wiki/
├── raw/ # Human-curated sources (immutable)
├── wiki/ # LLM-generated knowledge base
│ ├── index.md # Content catalog (categorized markdown list)
│ ├── log.md # Operation log (append-only)
│ ├── entities/ # Entity pages (people, orgs, tools)
│ ├── concepts/ # Concept pages (ideas, patterns)
│ ├── sources/ # Source summary pages
│ └── queries/ # Saved query results
└── AGENTS.md # Schema — wiki conventions
The .wiki/ directory is the wiki root. The extension activates whenever a workspace contains .wiki/wiki/.
# Wiki Index
## Entities
- [Ada Lovelace](entities/ada-lovelace.md) — Mathematician and writer #history
## Concepts
## Sources
- [notes.txt](sources/notes-summary.md) — Source file (.txt) #research## [2025-01-15] initialized | wiki
Wiki knowledge base initialized.
## [2025-01-15] ingested | notes.txt
Ingested source "notes.txt" → sources/notes-summary.mdtype: source # entity | concept | source | summary | query
title: notes.txt
source_path: raw/notes.txt
ingested: 2025-01-15
tags: []The extension (packages/vscode) is the primary UI. It never duplicates wiki logic — every operation delegates to @llmwiki/core.
The extension activates when the workspace contains a wiki at .wiki/wiki/ (the activation key llmwiki.isWikiWorkspace is set). The LLM Wiki: Initialize Wiki command is always available so a fresh workspace can be bootstrapped.
Activity Bar: "LLM Wiki" ($(book) icon)
├── Wiki Pages (wikiPagesTree.ts)
│ └── WikiPagesTreeDataProvider
│ ├── Reads wiki/index.md via readIndex()
│ ├── Root: category nodes (Entities, Concepts, Sources)
│ └── Children: page items with click-to-open
│
├── Raw Sources (rawSourcesTree.ts)
│ └── RawSourcesTreeDataProvider
│ ├── Reads raw/ via listSources()
│ ├── Groups files by subdirectory (flat if no subdirs)
│ └── Shows size + date in description
│
├── Backlinks (backlinksTree.ts)
│ └── BacklinksTreeDataProvider
│ ├── Calls getBacklinks() for the active editor's wiki page
│ ├── Updates on editor change (200ms debounce)
│ └── Shows "Open a wiki page" message when no wiki page is active
│
└── Lint Findings (lintFindingsTree.ts)
└── LintFindingsTreeDataProvider
├── Populated by llmwiki.lint, llmwiki.fix and llmwiki.refresh via setFindings()
├── Groups by severity (Errors → Warnings → Info)
└── Click to open the affected file
| Command ID | Trigger | Behaviour |
|---|---|---|
llmwiki.init |
Command palette | Creates wiki scaffold (dirs, index, log, AGENTS.md) |
llmwiki.ingest |
Palette / Explorer context menu / welcome view | Bulk-ingests selected files and/or folders (see Bulk Ingest below) |
llmwiki.query |
Command palette | Input box → weighted search → quick pick results |
llmwiki.status |
Palette / status bar click | Shows page count, sources, coverage, last ingest in a notification |
llmwiki.openPage |
Command palette | Quick pick from index entries → opens selected page |
llmwiki.search |
Command palette | Filter entities/concepts by title, summary, or tag |
llmwiki.searchRaw |
Command palette | Find a raw source file by name |
llmwiki.refresh |
Command palette | Runs fixWiki (prunes orphaned pages, lint-fix), refreshes trees |
llmwiki.lint |
Palette / Lint Findings view | Runs lintWiki and shows the findings in the Lint Findings view |
llmwiki.fix |
Raw Sources / Lint Findings views | Runs fixWiki with progress; remaining findings go to the Lint Findings view with a Fix with Copilot action |
llmwiki.fixWithCopilot |
Lint Findings view / notifications | Opens Copilot Chat with the /wiki-fix skill |
llmwiki.removeSource |
Raw Sources context menu | Deletes a raw source, its summary page, and pages derived only from it (removeSourcePages) |
The llmwiki.ingest handler accepts three invocation shapes:
- No arguments (Command Palette) — opens a native
showOpenDialogwithcanSelectFiles=true,canSelectFolders=true,canSelectMany=true. - Single Uri — fired by single-file Explorer context-menu clicks.
(focusedUri, selectedUris[])— fired by Explorer context-menu invocations with multi-selection (Ctrl/Shift-click); the second argument is honoured when present.
The flow:
raw URIs (files + folders)
│
▼
expandSelectionToFiles()
├─ stat each URI
├─ files → keep
└─ folders → walkFolder() BFS
├─ skip names starting with "."
└─ skip SKIP_DIRS = { node_modules, out, dist, build, .wiki }
│
▼
deduplicate by resolved fsPath
│
▼
if (count === 0) → "No files found in the selection." (info)
if (count > 20) → modal confirmation "You are about to ingest N files. Continue?"
│
▼
withProgress (Notification) → for each file:
├─ ensureInRaw() — copy external files into <workspace>/.wiki/raw/
└─ llmIngest() — LM API enrichment + ingestSource()
StatusBarManager (left-aligned, priority 100) displays: $(book) Wiki: N pages
- Tooltip: source count, last ingest date, coverage %
- Click action: runs
llmwiki.status - Auto-refresh: file system watchers on
wiki/**/*.mdandraw/**with 300ms debounce - Uninitialized state: shows "Wiki: Not initialized"
The extension has no chat participant (VS Code deprecated the Chat Participant API and the Copilot harness doesn't run participants). It integrates with Copilot Chat through:
- The MCP server — registered by
mcpProvider.ts; answers questions and edits the wiki through annotated tools, with server instructions that include the wiki'sAGENTS.md. - Skills, a custom agent and instructions — contributed through
chatSkills,chatAgentsandchatInstructions(gated onllmwiki.isWikiWorkspace). They are authored once inplugin/and copied toout/chat/byesbuild.config.mjs, so the extension and the agent plugin always ship the same content. - Commands —
llmwiki.fixWithCopilotopens chat with/wiki-fixafter Fix Issues has applied the deterministic fixes.
The Language Model API is still used directly for ingestion enrichment (llmIngest.ts), which runs outside chat.
The extension uses esbuild (CJS format) with vscode as an external. Packaging via vsce package --no-dependencies produces a .vsix file with @llmwiki/core bundled inline.
The MCP server lives in @llmwiki/core and exposes wiki operations via the Model Context Protocol, enabling external LLM agents (Claude Desktop, Cursor, VS Code Copilot, etc.) to read and write wiki content programmatically. The shared library exports createMcpServer plus per-tool handlers, and ships a stdio launcher binary (llmwiki-mcp) so any MCP-compatible client can spawn a server pointed at a .wiki/ directory.
packages/core/src/mcp/bin.ts is the executable entry point declared in the package bin field. It takes the wiki root from its single argument or the LLMWIKI_ROOT environment variable, validates the directory exists, builds a server via createMcpServer({ wikiRoot }), and connects it to a StdioServerTransport. With neither, it starts in discovery mode (createMcpServer({ cwd })). The output is dist/mcp/bin.js with a Node shebang preserved by tsc.
Once @llmwiki/core is installed, the launcher is invoked as:
npx llmwiki-mcp ./.wikiThis is what mcp.json entries (Claude Desktop, Cursor, .vscode/mcp.json, .mcp.json) point at. The same launcher is bundled into out/mcp-server.cjs (VSIX) and plugin/server/llmwiki-mcp.cjs (agent plugin).
WikiRootState (mcp/wiki-root.ts) decides which wiki the server works on:
- Bound — a root from the argument or
LLMWIKI_ROOT. Only that wiki is used;wiki_open/wiki_initare not offered. - Discovery — no root given. If
<cwd>/.wikiexists when the server starts, it is used (and itsAGENTS.mdgoes into the instructions). Otherwise, on the first tool call the server checks the client's workspace roots (MCProots/list; a wiki found this way is re-discovered afterroots/list_changed). Agents can also select a wiki withwiki_openor create one withwiki_init. Agent plugin clients start servers in the plugin folder and may report no roots, so the plugin's skills callwiki_openwith the workspace folder when needed.
A folder counts as a wiki when .wiki/wiki/ exists. initWiki and the extension use the same test, so a wiki whose index.md is missing still opens, and wiki_fix can rebuild the index.
Tool calls made before a wiki is found return an error that tells the agent how to open one.
- Tool annotations and titles — read tools set
readOnlyHint(VS Code skips the confirmation prompt); tools that overwrite or delete content setdestructiveHint; all tools setopenWorldHint: false. - Structured output —
wiki_status,wiki_query,wiki_lintandwiki_fixdeclare anoutputSchema(mcp/schemas.ts) and return matchingstructuredContentalongside the JSON text. - Instructions —
mcp/instructions.tsexplains the wiki layout and workflows; when the root is known at startup, the wiki'sAGENTS.mdis appended (capped at 12,000 characters). - Completions — page paths for
resource://wiki/pages/{path}, source paths forresource://wiki/sources/{path},raw/paths for theingest-and-integrateprompt, and index titles forresearch-topic. - Server info — name, title, version (
CORE_VERSION, kept in sync withpackage.jsonby a test), website and icon.
packages/vscode/src/mcpProvider.ts calls vscode.lm.registerMcpServerDefinitionProvider (stable API since VS Code 1.101) to advertise the launcher to Copilot automatically when a .wiki workspace is detected. The provider uses the bundled out/mcp-server.cjs (falling back to @llmwiki/core/mcp-bin in a dev checkout), builds a vscode.McpStdioServerDefinition pointing at process.execPath <launcher> <wikiRoot> with ELECTRON_RUN_AS_NODE=1 (so the editor binary runs as Node even when the spawning process, such as the Agent Host, doesn't set it), and exposes it under the id llmwiki. No mcp.json is required for the VS Code path.
| Tool | Type | Description |
|---|---|---|
wiki_status |
Read | Wiki statistics (source/page counts, coverage) |
wiki_query |
Read | Free-text search with relevance scores |
wiki_lint |
Read | Health checks by severity with category filter |
wiki_list_pages |
Read | All pages with frontmatter metadata |
wiki_list_sources |
Read | Raw source files with metadata |
wiki_read_page |
Read | Single page content by path |
wiki_read_index |
Read | All index entries |
wiki_write_page |
Write | Create/overwrite page with auto-index |
wiki_create_entity |
Write | Create entity page at entities/{slug}.md (optional sources provenance) |
wiki_create_concept |
Write | Create concept page at concepts/{slug}.md (optional sources provenance) |
wiki_update_page |
Write | Merge partial updates into existing page |
wiki_add_crosslinks |
Write | Add "See also" section with validated links |
wiki_update_index |
Write | Update index entry metadata |
wiki_ingest_with_context |
Write | Ingest source (path relative to the wiki root) with context-rich response |
wiki_fix |
Write | Deterministic fixes via fixWiki, with dryRun preview |
wiki_delete_page |
Write | Delete a page and its index entry; reports remaining backlinks |
wiki_open |
Workspace | Select the wiki by path (discovery mode only) |
wiki_init |
Workspace | Create a wiki in a project folder (discovery mode only) |
External LLM Agent
│
MCP JSON-RPC
│
▼
┌─────────────────────┐
│ MCP Server │
│ (createMcpServer) │
├─────────┬───────────┤
│ Read │ Write │
│ Tools │ Tools │
│ (7) │ (9) │
└────┬────┴────┬──────┘
│ │
▼ ▼
┌─────────────────────┐
│ @llmwiki/core │
│ (core operations) │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ Git Repository │
│ raw/ + wiki/ │
└─────────────────────┘
- Path traversal protection: All path arguments are validated via
assertWithinDir()— resolved paths must stay within the wiki directory. - Frontmatter validation:
wiki_write_pagerequirestitleandtypefields in frontmatter. - Input validation: All required fields are checked for non-empty strings; arrays are validated for correct element types.
- Empty slug/title rejection: Tools reject empty or whitespace-only slug and title arguments.
- Index injection prevention: Index updates use an upsert (find-or-replace) pattern to prevent duplicate entries.
- Protected files:
wiki_delete_pagerefusesindex.md,log.md(in any letter case) and non-markdown files.deletePagechecks the path again after resolving symlinked folders, so a link such aswiki/linked -> ../rawcan't be used to delete files outside the wiki. - Concurrent writes: every read-modify-write of a page or
index.md(ingest,upsertDerivedPage, crosslinks,wiki_update_page, index updates, fixes and source cleanup) runs under the wiki write lock (withWikiLockinlock.ts). The lock is awiki/.llmwiki.lockfile, so the extension and every MCP server process share it. It is re-entrant within one call chain, and a lock left by a crashed process is broken after 10 seconds. - Provenance:
sources/addSourcesmust name existing summary pages undersources/. Only such entries take part in cleanup: a page is deleted as orphaned when every one of them is definitely missing (ENOENT), and other entries (raw paths, URLs) count as present. Pages withoutsourcesare never deleted automatically, and the extension's LLM ingest extends existing pages instead of overwriting them. - Error isolation: Each tool call is wrapped in try/catch, returning
isError: trueon failure without crashing the server.
Human drops file(s) into raw/, picks them via the palette,
or right-clicks a folder in the Explorer
│
▼
┌──────────────────────┐
│ llmwiki.ingest │
│ (extension command) │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ expandSelectionToFiles│ ── walks folders, skips
│ (files + folders) │ hidden / build dirs
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ ensureInRaw() │ ── copies external
│ + llmIngest() per │ files into .wiki/raw/
│ file (LM enrichment) │
└──────────┬───────────┘
│
┌───────────┼────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Create │ │ Add to │ │ Append │
│ summary │ │ index.md │ │ log.md │
│ page │ │ │ │ │
└──────────┘ └──────────┘ └──────────┘
Human runs llmwiki.query and supplies search terms
│
▼
┌─────────────────┐ ┌─────────────────┐
│ Read │────▶│ Score entries │
│ wiki/index.md │ │ by title (3×) │
└─────────────────┘ │ + summary (2×) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Read matched │
│ page bodies │
│ + body score 1× │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Sort by score │
│ Show quick pick │
└─────────────────┘
llmwiki.lint, llmwiki.fix, or the wiki_lint / wiki_fix MCP tools
│
▼
┌─────────────────┐
│ Scan all wiki │
│ pages + index │
└────────┬────────┘
│
├──▶ broken-links (error) — Links to non-existent .md files
├──▶ orphan-pages (warning) — No inbound links, not indexed
├──▶ index-completeness (warning) — Pages missing from index
├──▶ stale-entries (error) — Index entries → deleted files
├──▶ missing-pages (info) — Referenced but non-existent pages
└──▶ frontmatter-validation — Type/title/tags/created checks
│
▼
┌──────────────────┐
│ Populate Lint │
│ Findings tree │
└──────────────────┘
Runs on every push and pull request to main. Executes lint (tsc --noEmit), build, and test (vitest run with coverage) for @llmwiki/core and the VS Code extension on Node.js 20, and fails if the committed plugin/server/llmwiki-mcp.cjs differs from a fresh build.
┌─────────────────────┐ ┌─────────────────────┐
│ llmwiki-vscode │ │ External Agents │
│ (VS Code ext) │ │ (via MCP) │
└──────────┬──────────┘ └──────────┬──────────┘
│ │
└────────────┬──────────────┘
│
▼
┌─────────────────────┐
│ @llmwiki/core │
│ (core + MCP) │
└─────────────────────┘
extension.ts
└─► commands.ts ──► @llmwiki/core (readIndex, directoryExists, lintWiki, fixWiki,
│ appendEntry, ingestSource, queryWiki, getWikiStatus)
│ └─► llmIngest.ts (LM API enrichment)
└─► wikiPagesTree.ts ──► @llmwiki/core (readIndex)
└─► rawSourcesTree.ts ──► @llmwiki/core (listSources)
└─► backlinksTree.ts ──► @llmwiki/core (getBacklinks)
└─► lintFindingsTree.ts ──► @llmwiki/core (LintFinding type)
└─► statusBar.ts ──► @llmwiki/core (directoryExists, getWikiStatus)
└─► mcpProvider.ts ──► vscode.lm.registerMcpServerDefinitionProvider
(spawns out/mcp-server.cjs over stdio)
| Module | Exports | Purpose |
|---|---|---|
constants.ts |
API_VERSION, WIKI_DIR_NAME, CORE_VERSION |
API version string ('1') included in MCP JSON output, the .wiki directory name, and the package version reported by the MCP server. |
errors.ts |
isNotFoundError, isPermissionError |
Error classification guards for ENOENT and EACCES. |
lock.ts |
withWikiLock |
Runs a read-modify-write of pages or index.md under the wiki write lock: a wiki/.llmwiki.lock file shared by the extension and MCP server processes, re-entrant within one call chain, and broken when stale. |
wiki.ts |
readPage, writePage, listPages, getPageLinks, directoryExists, createEntityPage, createConceptPage, addCrosslinks |
Read/write wiki pages with gray-matter frontmatter. List .md files recursively. Extract internal markdown links. Create typed pages with auto-index registration. Append cross-reference links. |
index-ops.ts |
readIndex, writeIndex, addEntry, removeEntry, findEntries, updateIndexEntry |
Parse and serialize the categorized index.md format. CRUD operations on index entries including partial metadata updates. |
log.ts |
appendEntry, readLog, getRecentEntries |
Append timestamped entries to log.md. Parse log entries. Retrieve recent entries. |
sources.ts |
listSources |
List all files in raw/ with metadata (name, path, size, modified, extension). |
backlinks.ts |
getBacklinks |
Find all pages containing links to a target page via link resolution. |
lint.ts |
lintWiki, lintFix |
Run 6 health-check categories (including frontmatter-validation) and return structured LintResult; lintFix applies the deterministic fixes (with an optional dryRun). |
fix.ts |
fixWiki, findOrphanedDerivedPages, removeSourcePages |
One pass of every deterministic fix: delete entity/concept pages whose sources were all removed, then lintFix with orphan indexing. Used by the extension's Fix Issues/Refresh commands and the wiki_fix tool. removeSourcePages deletes a removed source's summary and the pages left with no existing source (Remove Source and the raw/ deletion watcher). |
utils.ts |
slugify, excerpt |
Slugify filenames for wiki paths. Extract text excerpts with configurable max length. |
search.ts |
countOccurrences |
Case-insensitive substring occurrence counting for query scoring. |
init.ts |
initWiki, isWikiInitialized |
Initialize a wiki: create directory structure, index, log, and AGENTS.md template. isWikiInitialized (a wiki/ folder exists) is also what MCP discovery checks. |
ingest.ts |
ingestSource |
Ingest a single source file with duplicate detection. |
ingest-context.ts |
ingestWithContext |
Ingest a source with enriched context: word count, content type detection, related pages, follow-up actions. Used by wiki_ingest_with_context. |
bulk-ingest.ts |
bulkIngest |
Batch ingest all files from raw/, with progress callbacks and per-file status tracking. |
query.ts |
queryWiki, slugifyQuery |
Weighted keyword search across titles (3×), summaries (2×), and bodies (1×). |
status.ts |
getWikiStatus |
Aggregate wiki statistics: source count, page count, last ingest/lint dates, orphan count, index coverage. |
mcp/ |
createMcpServer |
MCP server with 14 tools (7 read, 7 write). |
mcp/bin.ts |
llmwiki-mcp binary |
Stdio launcher: validates wiki root arg, builds the server, connects StdioServerTransport. |
- Zero infrastructure. No database, no server, no hosting beyond GitHub.
- Version history for free. Every wiki change is a git commit. You can diff, revert, branch.
- Universal readability. Markdown renders in GitHub, VS Code, Obsidian, any text editor.
- Agent-friendly. LLMs read and write markdown natively. No serialization layer needed.
- Primary editor. Most wiki users already work in VS Code. A native extension removes context-switching between terminal and editor.
- Rich interaction. Tree views, quick picks, the status bar, and Copilot Chat skills backed by the wiki's MCP server provide discovery and navigation that a CLI cannot match.
- LM API built in. The extension uses VS Code's Language Model API for ingestion enrichment, with no extra credentials or HTTP wiring.
- Single surface. Concentrating on one client keeps the shared library focused and the test surface small.
- Single source of behaviour.
@llmwiki/coreimplements every wiki operation. The extension and the MCP server both consume it — there is no behaviour duplication. - Agent interop via MCP. External LLM agents (Claude Desktop, Cursor, …) can read and write the same wiki the extension uses, with strict path-traversal and frontmatter safety checks built in.
- Testable. The library is plain TypeScript with no UI dependencies, so the vast majority of behaviour is unit-tested against fixture wikis.
- Pre-compiled knowledge. The wiki is the synthesis — cross-references are already built, contradictions already flagged. RAG re-derives these on every query.
- Scale-appropriate. At personal scale (~100s of sources),
index.md+ keyword search is sufficient. Embedding infrastructure is overhead without proportional value. - Inspectable. You can read the wiki directly. RAG chunks and embeddings are opaque.
- Simplicity. A single markdown file that both humans and LLMs can read.
- Sufficient at personal scale. Hundreds of pages are navigable via a well-organized index.
- Upgrade path. When scale demands it, add a local search tool. The index remains useful as a human-readable catalog.
- Ecosystem. Rich npm ecosystem for VS Code extension development and markdown tooling (gray-matter, MCP SDK).
- LLM familiarity. LLMs are fluent in TypeScript, making the codebase easy to maintain via LLM agents.
- Modern toolchain. esbuild for the extension,
tscfor the shared library, Vitest for testing.
- Shared logic, multiple consumers. The core wiki operations live in
@llmwiki/coreand are consumed by both the extension and the MCP server without duplication. - Atomic changes. A single PR can update the shared library and the extension together, avoiding version drift.
- Simple tooling. npm workspaces require no additional monorepo tools —
npm ciat the root resolves all cross-package dependencies via symlinks.