llm-wiki-compiler 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +211 -24
- package/dist/cli.js +2943 -941
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1010 -0
- package/dist/index.js +7257 -0
- package/dist/index.js.map +1 -0
- package/dist/viewer/assets/viewer-rail.js +71 -0
- package/dist/viewer/assets/viewer-sidebar.js +115 -4
- package/dist/viewer/assets/viewer.css +69 -0
- package/dist/viewer/assets/viewer.js +48 -0
- package/package.json +16 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.9.0] - 2026-06-08
|
|
9
|
+
|
|
10
|
+
Adds an end-to-end source-freshness loop — detect stale pages, surface them everywhere, and repair them with a targeted recompile — plus an in-process SDK with source-backed write APIs, a JSON export bridge contract for downstream importers, richer eval metrics, rule-candidate extraction, and a local-login Claude Agent provider.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Source freshness** — `llmwiki lint` flags pages whose sources changed (`stale`) or were all deleted (`orphaned`) since the last compile, computed on demand from `.llmwiki/state.json` and the current `sources/`. Freshness is surfaced across MCP (`wiki_status` stale/orphaned lists and a `stateStatus` field, plus `get_context_pack`), context packs (per-page `freshnessStatus`/`contradicted`/`archived` and a `stale-page` warning), the local viewer (STALE/ORPHANED/CONTRADICTED/ARCHIVED badges, a per-axis filter, health-pane counts, and a corrupt-state banner), the JSON export, and `llmwiki next`.
|
|
15
|
+
- **`llmwiki refresh --stale [--dry-run]`** — a targeted recompile that repairs stale/orphaned pages by recompiling their changed owning sources and cleaning up deleted owners, while deliberately skipping unrelated new sources. `--dry-run` previews the plan with no LLM calls and no writes; cleanup-only refreshes require no API key.
|
|
16
|
+
- **JSON export bridge contract** — `llmwiki export --target json --project-id <id>` adds per-page `path`, `kind`, advisory confidence/provenance, flattened citations, aliases, and freshness so downstream importers (e.g. [`@atomicmemory/llmwiki`](https://github.com/atomicstrata/atomicmemory/tree/main/packages/llmwiki)) can ingest pages as durable memory records.
|
|
17
|
+
- **Eval over MCP** — a `run_eval` MCP tool (the fast suite needs no API key; the full suite LLM-judges a sample of citations), plus read-only `llmwiki://eval/report` and `llmwiki://eval/history` resources.
|
|
18
|
+
- **Eval source-utilization metrics** — source-utilization and citation-depth dimensions, surfaced source warnings, a frame-safe report, and a `source_warnings_max` CI gate.
|
|
19
|
+
- **Rule-candidate extraction** — extract reusable rule candidates from sources with review/approve and a JSON export pipeline.
|
|
20
|
+
- **In-process SDK** — `createWiki()` exposes the compiler in-process, with source-backed write APIs (`writeStatus`, `listSources`/`getSource`/`deleteSource`) for programmatic callers.
|
|
21
|
+
- **Claude Agent SDK provider** — a provider that authenticates through a local Claude Code login and uses bundled plan tokens, so no separate API key is required.
|
|
22
|
+
- **Alias-aware wikilinks** — the viewer resolves a `[[term]]` link to any page that declares `term` in its `aliases` frontmatter, not just an exact slug match.
|
|
23
|
+
- **Append-only activity journal** — an append-only `log.md` records ingest, compile, review, and export activity.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Upgraded core dependencies — zod 3 → 4, openai 4 → 6, and `@anthropic-ai/sdk` 0.39 → 0.101 — and bumped the default model to `claude-sonnet-4-6` (the previous default was deprecated).
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Three read-only paths (`wiki_status`, the `llmwiki://state` MCP resource, and the viewer startup snapshot) no longer write a `.bak` file when `.llmwiki/state.json` is corrupt; corrupt and missing state are now surfaced explicitly instead of being swallowed.
|
|
32
|
+
- `wiki_status` derives pending source changes from the freshness snapshot instead of running a redundant second source-hash pass.
|
|
33
|
+
|
|
34
|
+
### Contributors
|
|
35
|
+
|
|
36
|
+
Thanks to **@alvins82** for the Claude Agent SDK provider (#81) and the append-only activity journal (#85), **@dohu012** for source-utilization and citation-depth eval metrics (#86), and **@joshuaknipe** for the `run_eval` MCP tool and eval resources (#74).
|
|
37
|
+
|
|
8
38
|
## [0.8.0] - 2026-05-26
|
|
9
39
|
|
|
10
40
|
Adds guided project next steps, one-command quickstart, agent-ready context graph packs, a viewer graph route, and the first eval harness for measuring wiki quality over time.
|
package/README.md
CHANGED
|
@@ -6,10 +6,24 @@ Inspired by Karpathy's [LLM Wiki](https://gist.github.com/karpathy/442a6bf555914
|
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
|
+
## What you get
|
|
10
|
+
|
|
11
|
+
- **Compiled wiki, not chunks.** A two-phase LLM pipeline turns raw sources into typed pages (`concept`, `entity`, `comparison`, `overview`) with paragraph- and claim-level citations back to source line ranges.
|
|
12
|
+
- **Hybrid retrieval.** Semantic chunk embeddings (incremental, content-hash-aware) narrow hundreds of pages to a small top-K; BM25 reranking and wikilink-graph expansion build the final evidence pack.
|
|
13
|
+
- **Local web viewer.** `llmwiki view` opens a read-only browser UI with sidebar navigation, search, a force-directed graph, and provenance/citation chips per page.
|
|
14
|
+
- **Eval harness.** `llmwiki eval` measures health score (0–100), citation coverage and precision, optional LLM-as-judge support scoring, regression deltas, and CI-gateable thresholds.
|
|
15
|
+
- **Source freshness.** `llmwiki lint` flags pages whose sources changed (`stale`) or were deleted (`orphaned`) since the last compile — surfaced across the viewer, MCP, context packs, the JSON export, and `llmwiki next` — and `llmwiki refresh --stale` repairs them with a targeted recompile.
|
|
16
|
+
- **MCP server.** `llmwiki serve` exposes the full pipeline to Claude Desktop, Cursor, Claude Code, and any MCP-compatible agent — including `get_context_pack` for budgeted, citation-aware evidence packs.
|
|
17
|
+
- **In-process SDK.** `createWiki({ root })` drives the whole pipeline programmatically — ingest, compile, query, status/freshness, context packs, export, eval — for embedding llmwiki in your own tooling without shelling out.
|
|
18
|
+
- **Activity journal.** Every ingest, compile, and query appends a timestamped, machine-parseable entry to `log.md` — a human- and agent-readable audit trail of how the wiki was built, carrying page wikilinks and counts.
|
|
19
|
+
- **Bridge to runtime memory.** `llmwiki export --target json --project-id <id>` produces a typed envelope that [`@atomicmemory/llmwiki`](https://github.com/atomicstrata/atomicmemory/tree/main/packages/llmwiki) imports as one verbatim Atomic Memory record per page, preserving all advisory metadata.
|
|
20
|
+
- **Provider-portable.** Anthropic, Claude Agent SDK (local Claude Code login, no API key), OpenAI-compatible (incl. local llama.cpp / vLLM), Ollama, GitHub Copilot.
|
|
21
|
+
|
|
9
22
|
## Who this is for
|
|
10
23
|
|
|
11
|
-
- **AI researchers and engineers** building
|
|
24
|
+
- **AI researchers and engineers** building durable knowledge from papers, docs, and notes
|
|
12
25
|
- **Technical writers** compiling scattered sources into a structured, interlinked reference
|
|
26
|
+
- **Open-source maintainers** turning READMEs, ADRs, and design docs into a navigable knowledge base
|
|
13
27
|
- **Anyone with too many bookmarks** who wants a wiki instead of a graveyard of tabs
|
|
14
28
|
|
|
15
29
|
## Quick start
|
|
@@ -78,6 +92,43 @@ Example with zero exports (Claude Code already configured):
|
|
|
78
92
|
llmwiki compile
|
|
79
93
|
```
|
|
80
94
|
|
|
95
|
+
### Claude Agent SDK (local Claude Code login)
|
|
96
|
+
|
|
97
|
+
The `claude-agent` provider routes calls through the
|
|
98
|
+
[Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk-typescript)
|
|
99
|
+
instead of the raw Messages API. It authenticates with your **local Claude Code
|
|
100
|
+
login** (OAuth/subscription), so **no `ANTHROPIC_API_KEY` is required** — if you
|
|
101
|
+
can run `claude` in your terminal, this provider works.
|
|
102
|
+
|
|
103
|
+
> **Terms of use.** This provider drives your Claude Code / Agent SDK session
|
|
104
|
+
> programmatically to compile wikis. That is not automatically appropriate for
|
|
105
|
+
> every account type, plan, or environment. Before using it, review Anthropic's
|
|
106
|
+
> current [Claude Code](https://www.anthropic.com/legal/consumer-terms) and
|
|
107
|
+
> [Agent SDK](https://docs.anthropic.com/en/api/agent-sdk/overview) terms and
|
|
108
|
+
> usage policies, and make sure your intended use complies with them.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
export LLMWIKI_PROVIDER=claude-agent
|
|
112
|
+
export LLMWIKI_MODEL=claude-sonnet-4-6 # optional; this is the default
|
|
113
|
+
llmwiki compile
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Notes:
|
|
117
|
+
|
|
118
|
+
- Generation (`compile`) and structured extraction work off the local login with
|
|
119
|
+
no extra credentials.
|
|
120
|
+
- Semantic search (`llmwiki query`) still needs embeddings, which Claude does not
|
|
121
|
+
provide. Set `VOYAGE_API_KEY` to enable them (same as the `anthropic`
|
|
122
|
+
provider); otherwise `query` falls back to lexical ranking.
|
|
123
|
+
- To see what the SDK is doing, set `LLMWIKI_DEBUG=1` for a concise one-line trace
|
|
124
|
+
per SDK message (`[claude-agent] system:init`, `… assistant`, `… result:success`)
|
|
125
|
+
plus any `claude` subprocess errors. Use `LLMWIKI_DEBUG=verbose` to additionally
|
|
126
|
+
enable the SDK's full verbose logging.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
LLMWIKI_DEBUG=1 LLMWIKI_PROVIDER=claude-agent llmwiki compile
|
|
130
|
+
```
|
|
131
|
+
|
|
81
132
|
### OpenAI-Compatible Local Servers
|
|
82
133
|
|
|
83
134
|
Use the OpenAI provider for local OpenAI-compatible servers such as
|
|
@@ -180,28 +231,46 @@ A truncation warning prints to stderr when the cap fires so you know which conce
|
|
|
180
231
|
<br>
|
|
181
232
|
|
|
182
233
|
|
|
183
|
-
## Why not just
|
|
234
|
+
## Why compile, not just retrieve?
|
|
235
|
+
|
|
236
|
+
llmwiki uses embeddings — chunk-level, incremental, with BM25 reranking. But the embedding layer sits **below** the compiled wiki, not in front of it.
|
|
184
237
|
|
|
185
|
-
RAG retrieves chunks at query time
|
|
238
|
+
**RAG retrieves chunks at query time.** Every question re-discovers the same relationships from scratch. The wiki structure, citation graph, and merged-concept disambiguation never accumulate; they get re-invented per query.
|
|
186
239
|
|
|
187
|
-
llmwiki
|
|
240
|
+
**llmwiki compiles your sources into a wiki first.** Concepts get their own typed pages. Concepts shared across multiple sources are merged into one page instead of competing as duplicate chunks. Pages link to each other via `[[wikilinks]]`. When you ask a question with `--save`, the answer becomes a new page, and future queries use it as context.
|
|
188
241
|
|
|
189
|
-
|
|
242
|
+
Then semantic retrieval, BM25 reranking, and graph expansion run over the compiled artifact — narrowing hundreds of pages to a tight, citation-traceable evidence pack.
|
|
190
243
|
|
|
191
244
|
```
|
|
192
245
|
RAG: query → search chunks → answer → forget
|
|
193
|
-
llmwiki: sources → compile → wiki → query → save → richer wiki → better answers
|
|
246
|
+
llmwiki: sources → compile → wiki → embed → query → save → richer wiki → better answers
|
|
194
247
|
```
|
|
195
248
|
|
|
249
|
+
llmwiki is complementary to traditional RAG: use RAG for ad-hoc retrieval over noisy or fast-changing corpora; use llmwiki when you want a persistent, structured, citation-traceable artifact that compounds.
|
|
250
|
+
|
|
196
251
|
## How it works
|
|
197
252
|
|
|
198
253
|
```
|
|
199
|
-
sources/ →
|
|
254
|
+
sources/ → hash check → LLM concept extraction → page generation → [[wikilink]] resolve
|
|
255
|
+
│ ↓
|
|
256
|
+
│ chunk embeddings ← wiki/ → index.md
|
|
257
|
+
│ ↓
|
|
258
|
+
│ semantic search + BM25 rerank + graph expansion
|
|
259
|
+
│ ↓
|
|
260
|
+
│ llmwiki query / context / MCP
|
|
261
|
+
↓
|
|
262
|
+
stale / orphaned pages → llmwiki refresh --stale → recompile changed owners, clean up orphans
|
|
200
263
|
```
|
|
201
264
|
|
|
202
|
-
**Two-phase
|
|
265
|
+
**Two-phase compile.** Phase 1 extracts all concepts from every source; Phase 2 generates pages. Splitting the phases eliminates order-dependence, catches extraction failures before anything is written, merges concepts shared across multiple sources into a single page, and marks pages whose sources were all deleted as `orphaned` rather than silently dropping them.
|
|
203
266
|
|
|
204
|
-
**Incremental.**
|
|
267
|
+
**Incremental everywhere.** Hash-based change detection on sources, content-hash-aware embedding updates, and cached citation judgements mean only changed work runs through the LLM. Recompiling after editing one source touches just the pages that source contributed to.
|
|
268
|
+
|
|
269
|
+
**Source freshness and repair.** Every page records the sources — and their content hashes — that produced it. On any later command, llmwiki compares those recorded hashes against `sources/` on disk: a page whose sources changed since the last compile is `stale`, and a page whose sources were all deleted is `orphaned`. `llmwiki lint`, `llmwiki status`, the viewer, the JSON export, and the MCP tools surface this without recompiling anything. `llmwiki refresh --stale` then repairs it — recompiling only the changed sources that own stale pages and cleaning up orphaned ones, while deliberately leaving unrelated new sources for a full `llmwiki compile`. `--dry-run` previews the plan with no LLM calls.
|
|
270
|
+
|
|
271
|
+
**Hybrid retrieval.** `.llmwiki/embeddings.json` v2 carries page- and chunk-level vectors. `llmwiki query` and `llmwiki context` narrow hundreds of pages down to a chunk-level top-K via cosine similarity, then rerank with BM25 and expand along the wikilink graph for the final evidence pack.
|
|
272
|
+
|
|
273
|
+
**Citation-traceable.** Paragraphs carry `^[source.md]` markers; specific claims pin to `^[source.md:42-58]` line ranges. `llmwiki lint` validates that every citation resolves to a real file and line range; `llmwiki eval` measures citation precision and (optionally) LLM-judged claim support.
|
|
205
274
|
|
|
206
275
|
**Compounding queries.** `llmwiki query --save` writes the answer as a wiki page and immediately rebuilds the index. Saved answers show up in future queries as context.
|
|
207
276
|
|
|
@@ -252,19 +321,24 @@ Pages include source attribution in frontmatter. Paragraphs are annotated with `
|
|
|
252
321
|
| `llmwiki compile` | Incremental compile: extract concepts, generate wiki pages |
|
|
253
322
|
| `llmwiki compile --review` | Write candidate pages to `.llmwiki/candidates/` instead of `wiki/` so you can review before they land |
|
|
254
323
|
| `llmwiki compile --lang <code>` | Generate wiki content in the given language (e.g. `Chinese`, `ja`, `zh-CN`); also works on `query` |
|
|
324
|
+
| `llmwiki refresh --stale [--dry-run]` | Repair stale/orphaned pages: recompile the sources that own stale pages and clean up deleted owners, skipping unrelated new sources. `--dry-run` previews the plan with no LLM calls or writes |
|
|
255
325
|
| `llmwiki review list` | List pending candidate pages |
|
|
256
326
|
| `llmwiki review show <id>` | Print a candidate's title, summary, and body |
|
|
257
327
|
| `llmwiki review approve <id>` | Promote a candidate into `wiki/` and refresh index/MOC/embeddings |
|
|
258
328
|
| `llmwiki review reject <id>` | Archive a candidate without touching `wiki/` |
|
|
329
|
+
| `llmwiki rules extract` | Extract machine-actionable rule candidates from changed sources into `.llmwiki/rule-candidates/` |
|
|
330
|
+
| `llmwiki rules list` | List pending rule candidates |
|
|
331
|
+
| `llmwiki rules approve <id>` / `reject <id>` | Approve or reject a rule candidate |
|
|
332
|
+
| `llmwiki rules export` | Emit approved rule candidates as a JSON array for a downstream rule importer |
|
|
259
333
|
| `llmwiki schema init` | Write a starter `.llmwiki/schema.json` file |
|
|
260
334
|
| `llmwiki schema show` | Print the resolved schema for the current project |
|
|
261
335
|
| `llmwiki query "question"` | Ask questions against your compiled wiki |
|
|
262
336
|
| `llmwiki query "question" --save` | Answer and save the result as a wiki page |
|
|
263
|
-
| `llmwiki export [--target <name>]` | Export the wiki to portable formats — `llms.txt`, `llms-full.txt`, JSON, JSON-LD, GraphML, Marp slides |
|
|
337
|
+
| `llmwiki export [--target <name>] [--project-id <id>]` | Export the wiki to portable formats — `llms.txt`, `llms-full.txt`, JSON, JSON-LD, GraphML, Marp slides. `--project-id` pins a stable identifier inside the JSON envelope so downstream importers (e.g. [`@atomicmemory/llmwiki`](https://github.com/atomicstrata/atomicmemory/tree/main/packages/llmwiki)) can derive deterministic external IDs |
|
|
264
338
|
| `llmwiki view [--open]` | Start a read-only local web viewer for browsing, searching, and inspecting the compiled wiki |
|
|
265
339
|
| `llmwiki next [--json]` | Show the recommended next action for this project (read-only); `--json` emits a stable envelope for agents |
|
|
266
340
|
| `llmwiki context "<prompt>" [--json]` | Build an agent-ready evidence pack (primary pages, citations, neighbors, suggested actions) — same v1 envelope as MCP `get_context_pack` |
|
|
267
|
-
| `llmwiki lint` | Check wiki quality (broken links, orphans, empty pages, low confidence, contradictions, etc.) |
|
|
341
|
+
| `llmwiki lint` | Check wiki quality (broken links, orphans, empty pages, low confidence, contradictions, stale pages whose sources changed, etc.) |
|
|
268
342
|
| `llmwiki eval [--suite fast\|full]` | Measure wiki quality: health score (0–100), citation coverage, corpus stats. `--suite full` adds LLM-as-judge citation support scoring |
|
|
269
343
|
| `llmwiki eval cache show` | Print score distribution and top-cited pages from the citation judgement cache |
|
|
270
344
|
| `llmwiki eval cache clear` | Remove the citation judgement cache |
|
|
@@ -279,6 +353,7 @@ Pages include source attribution in frontmatter. Paragraphs are annotated with `
|
|
|
279
353
|
## Output
|
|
280
354
|
|
|
281
355
|
```
|
|
356
|
+
log.md append-only activity journal (ingests, compiles, queries)
|
|
282
357
|
wiki/
|
|
283
358
|
concepts/ one .md file per concept, with YAML frontmatter
|
|
284
359
|
queries/ saved query answers, included in index and retrieval
|
|
@@ -289,7 +364,31 @@ wiki/
|
|
|
289
364
|
candidates/archive/ rejected candidates kept for audit
|
|
290
365
|
```
|
|
291
366
|
|
|
292
|
-
Obsidian-compatible. `[[wikilinks]]` resolve to concept titles.
|
|
367
|
+
Obsidian-compatible. `[[wikilinks]]` resolve to concept titles — or to any page that declares the term in its `aliases` frontmatter, so links survive renames and synonyms.
|
|
368
|
+
|
|
369
|
+
`log.md` records what happened and when. Each entry is a heading with a fixed
|
|
370
|
+
prefix — `## [YYYY-MM-DDThh:mm:ssZ] operation | description` (an ISO 8601 UTC
|
|
371
|
+
timestamp) — followed by a short bullet body carrying page wikilinks and counts:
|
|
372
|
+
|
|
373
|
+
```markdown
|
|
374
|
+
## [2026-06-05T09:14:02Z] ingest | Attention Is All You Need
|
|
375
|
+
- Source: https://arxiv.org/abs/1706.03762
|
|
376
|
+
- Saved: sources/attention-is-all-you-need.md
|
|
377
|
+
- Chars: 38,214
|
|
378
|
+
|
|
379
|
+
## [2026-06-05T09:15:30Z] compile | 1 source(s) → 6 page(s)
|
|
380
|
+
- Sources: attention-is-all-you-need.md
|
|
381
|
+
- Created: [[self-attention]], [[multi-head-attention]], [[transformer]]
|
|
382
|
+
- Updated: [[positional-encoding]]
|
|
383
|
+
|
|
384
|
+
## [2026-06-05T09:16:11Z] query | What is multi-head attention?
|
|
385
|
+
- Pages: [[multi-head-attention]], [[self-attention]]
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Only headings start with `## [`, so the gist's recipe still works even with the
|
|
389
|
+
bodies: `grep "^## \[" log.md | tail -5` shows the five most recent operations.
|
|
390
|
+
Where `index.md` organizes content for discovery, `log.md` tracks temporal
|
|
391
|
+
progression.
|
|
293
392
|
|
|
294
393
|
## Local web viewer
|
|
295
394
|
|
|
@@ -403,6 +502,7 @@ llmwiki eval cache clear # wipe the citation judgement cache
|
|
|
403
502
|
- **Health score (0–100)** aggregates all lint rules. Errors (broken citations, broken wikilinks, duplicate concepts) cost more than warnings.
|
|
404
503
|
- **Citation coverage** — fraction of prose paragraphs that carry a `^[...]` marker, plus citation precision (fraction of citations pointing to existing source files).
|
|
405
504
|
- **Citation support (full suite)** — samples up to N `(claim, source span)` pairs, asks a judge model to score each 0–2 (unsupported → fully supported), and caches results so subsequent runs only re-judge new pairs.
|
|
505
|
+
- **Source utilization & citation depth** — the fraction of a page's valid sources that are actually cited (`source_utilization_rate`), and the share of citations pinned to specific line ranges rather than whole files (`claim_level_citation_rate`). Source warnings flag sources excluded from compilation (e.g. out-of-tree symlinks), gateable via `source_warnings_max`.
|
|
406
506
|
- **Corpus stats** — page count, source count, total wiki characters, embedding counts, appended to `history.jsonl` for trend tracking.
|
|
407
507
|
- **Regression deltas** — current report is diffed against the previous entry in history.
|
|
408
508
|
|
|
@@ -413,6 +513,9 @@ health_score: 85
|
|
|
413
513
|
citation_coverage_percent: 70
|
|
414
514
|
citation_precision_percent: 90
|
|
415
515
|
citation_support_mean: 1.4 # only checked when --suite full
|
|
516
|
+
source_utilization_rate: 0.9 # min fraction of valid sources cited by a page
|
|
517
|
+
source_warnings_max: 0 # max excluded sources (out-of-tree symlinks, etc.)
|
|
518
|
+
claim_level_citation_rate: 0.5 # min fraction of citations with line ranges
|
|
416
519
|
```
|
|
417
520
|
|
|
418
521
|
Threshold violations are listed in the report. Exit code is non-zero when any threshold is breached, suitable for CI gating.
|
|
@@ -504,8 +607,9 @@ Tools that need an LLM (`compile_wiki`, `query_wiki`, `search_pages`) check for
|
|
|
504
607
|
| `search_pages` | Return full content of pages relevant to a question. |
|
|
505
608
|
| `read_page` | Read a single page by slug (concepts/ then queries/). |
|
|
506
609
|
| `lint_wiki` | Run quality checks; returns structured diagnostics. |
|
|
507
|
-
| `wiki_status` | Page
|
|
508
|
-
| `get_context_pack` | Build an agent-ready evidence pack (primary pages, semantic chunks, graph neighbors, citations, warnings, suggested actions) — same v1 JSON envelope as `llmwiki context --json`. `get_context_pack` **packages evidence**; `query_wiki` **generates answers**. |
|
|
610
|
+
| `wiki_status` | Page/source counts, stale and orphaned pages, a `stateStatus` field, and pending changes (read-only). |
|
|
611
|
+
| `get_context_pack` | Build an agent-ready evidence pack (primary pages, semantic chunks, graph neighbors, citations, per-page freshness, warnings, suggested actions) — same v1 JSON envelope as `llmwiki context --json`. `get_context_pack` **packages evidence**; `query_wiki` **generates answers**. |
|
|
612
|
+
| `run_eval` | Score wiki quality (the fast suite needs no API key; the full suite LLM-judges a sample of citations); read-only. |
|
|
509
613
|
|
|
510
614
|
### Resources
|
|
511
615
|
|
|
@@ -516,6 +620,56 @@ Tools that need an LLM (`compile_wiki`, `query_wiki`, `search_pages`) check for
|
|
|
516
620
|
| `llmwiki://query/{slug}` | A single saved query page. |
|
|
517
621
|
| `llmwiki://sources` | List of ingested source files with metadata. |
|
|
518
622
|
| `llmwiki://state` | Compilation state (per-source hashes, last compile times). |
|
|
623
|
+
| `llmwiki://eval/report` | The most recent eval report. |
|
|
624
|
+
| `llmwiki://eval/history` | Trend of past eval runs. |
|
|
625
|
+
|
|
626
|
+
</details>
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
<br>
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
<br>
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
<details>
|
|
637
|
+
<summary><span style="font-size: 1.4em;"><strong>SDK — programmatic API — click to expand</strong></span></summary>
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
## SDK — `createWiki()`
|
|
641
|
+
|
|
642
|
+
Drive llmwiki in-process instead of shelling out to the CLI. `createWiki({ root })` returns a `Wiki` facade bound to a project directory. Every method runs silently (no console output) and is concurrency-safe — quiet mode is scoped per async call, not via a global flag. `createWiki` is exported from the package entry, so `import { createWiki } from "llm-wiki-compiler"` works for any installed version.
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
import { createWiki } from "llm-wiki-compiler";
|
|
646
|
+
|
|
647
|
+
const wiki = createWiki({ root: "./my-wiki" });
|
|
648
|
+
|
|
649
|
+
await wiki.ingestText({ title: "Notes", text: "Raw text to compile…" });
|
|
650
|
+
await wiki.compile(); // needs LLM credentials
|
|
651
|
+
const { answer } = await wiki.query("What did I note about X?");
|
|
652
|
+
const status = await wiki.status(); // no credentials needed
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### Methods
|
|
656
|
+
|
|
657
|
+
| Method | What it does | LLM creds |
|
|
658
|
+
|--------|--------------|:---------:|
|
|
659
|
+
| `ingest({ source })` | Fetch a URL or read a local file into `sources/`. **Trusted input only** — a server-side fetch + local-file-read primitive (SSRF risk); use `ingestText` for untrusted content. | No |
|
|
660
|
+
| `ingestText({ title, text })` | Ingest raw text — the safe path for untrusted content (no fetch, no file read). | No |
|
|
661
|
+
| `compile(options?)` | Compile pending sources into wiki pages. `options.review` queues candidates instead of writing. **Sends source content to the provider.** | Yes |
|
|
662
|
+
| `search(question)` | Retrieve and hydrate the most relevant page records. | Yes |
|
|
663
|
+
| `query(question, options?)` | Grounded answer; `options.save` persists it as a page, `options.debug` returns retrieval detail. | Yes |
|
|
664
|
+
| `getPage(ref)` / `listPages(options?)` | Read one page / list pages with filters and cursor pagination. | No |
|
|
665
|
+
| `listSources(options?)` / `getSource(id)` / `deleteSource(id)` | List, read, or delete ingested sources. `id` is the `IngestResult.filename` (e.g. `"note.md"`); `deleteSource` reconciles the compiled page on the next `compile()`. | No |
|
|
666
|
+
| `status()` | Read-only status snapshot — counts, freshness, pending changes. | No |
|
|
667
|
+
| `lint()` | Run all lint rules; severity-counted summary. | No |
|
|
668
|
+
| `getContextPack({ prompt, budget?, depth?, topPages?, topChunks? })` | Build a v1 context pack — same envelope as MCP `get_context_pack`. Semantic retrieval when embeddings exist, lexical fallback otherwise. | No |
|
|
669
|
+
| `exportJson(options?)` | Structured JSON export document (same shape as `llmwiki export --target json`). | No |
|
|
670
|
+
| `runEval({ mode, record? })` | Eval harness. `mode: "fast"` is credential-free; `"full"` LLM-judges a sample of citations. | full only |
|
|
671
|
+
|
|
672
|
+
**Notes.** Methods that need a provider throw `ProviderUnavailableError` when no credentials are configured; the rest run credential-free. Output is suppressed and there is no progress callback in v1 (`compile`/`runEval` on a large corpus can run for minutes with no feedback). `status()`, `lint()`, and `exportJson()` each hash the full source corpus per call (no cross-call cache) — avoid calling them in a hot loop. All result types (`CompileResult`, `QueryResult`, `WikiStatus`, `ContextPack`, …) are exported from the package for typed consumption.
|
|
519
673
|
|
|
520
674
|
</details>
|
|
521
675
|
|
|
@@ -527,31 +681,60 @@ Tools that need an LLM (`compile_wiki`, `query_wiki`, `search_pages`) check for
|
|
|
527
681
|
<br>
|
|
528
682
|
|
|
529
683
|
|
|
530
|
-
##
|
|
684
|
+
## Companion: Atomic Memory
|
|
685
|
+
|
|
686
|
+
llmwiki and [Atomic Memory](https://github.com/atomicstrata/atomicmemory) are complementary layers of open context infrastructure, both maintained by [Atomic Strata](https://github.com/atomicstrata):
|
|
687
|
+
|
|
688
|
+
- **llmwiki** gives you a persistent **knowledge base** — durable markdown compiled from your sources, inspectable on disk.
|
|
689
|
+
- **Atomic Memory** gives your agents persistent **working memory** — runtime context that's searchable, correctable, scoped, and inspectable over time.
|
|
690
|
+
|
|
691
|
+
Use them independently or together. Each remains valuable on its own — llmwiki as a notebook, RAG index, CI-checked knowledge base, or domain pack source; Atomic Memory as a runtime memory layer for any agent or app.
|
|
692
|
+
|
|
693
|
+
The [`@atomicmemory/llmwiki`](https://github.com/atomicstrata/atomicmemory/tree/main/packages/llmwiki) bridge ingests `llmwiki export --target json --project-id <id>` envelopes as one verbatim Atomic Memory record per wiki page, preserving all advisory metadata (kind, citations, confidence, provenance state, contradictions, aliases, freshness) under `memory.metadata.llmwiki.*`. See the [bridge cookbook](https://github.com/atomicstrata/atomicmemory/blob/main/packages/llmwiki/docs/cookbook.md) for the full compile → export → import → package workflow.
|
|
694
|
+
|
|
695
|
+
## Scale and what works
|
|
531
696
|
|
|
532
|
-
|
|
697
|
+
Still early software, but the scale story has matured well past the "few dozen sources" era.
|
|
533
698
|
|
|
534
|
-
**
|
|
699
|
+
- **Semantic chunk retrieval** (`.llmwiki/embeddings.json` v2) narrows hundreds of pages down to a small top-K before LLM selection, with BM25 reranking and graph-neighborhood expansion layered on top.
|
|
700
|
+
- **Incremental everything.** Hash-based source-change detection, content-hash-aware embedding updates, cached citation judgements. Re-running on an unchanged corpus is a few seconds.
|
|
701
|
+
- **Lexical fallback.** Index-based routing kicks in automatically when no embedding store is present or the active provider has no embedding credentials, surfacing a stable warning code rather than hard-failing.
|
|
702
|
+
|
|
703
|
+
**Honest about truncation.** Sources that exceed the character limit are truncated on ingest with `truncated: true` and the original character count recorded in frontmatter, so downstream consumers know they're working with partial content. A per-concept prompt budget prevents popular shared concepts from crashing compile.
|
|
704
|
+
|
|
705
|
+
**Where it's still early.** No source-freshness watchdog yet (re-ingest detects content changes, but doesn't proactively re-check URLs). No team / multi-writer conflict resolution. The viewer is read-only by design — write operations go through the CLI or MCP.
|
|
535
706
|
|
|
536
707
|
## Karpathy's LLM Wiki pattern vs this compiler
|
|
537
708
|
|
|
538
|
-
Karpathy
|
|
709
|
+
Karpathy described an abstract pattern for turning raw data into compiled knowledge. Here's how llmwiki maps to it today:
|
|
539
710
|
|
|
540
711
|
| Karpathy's concept | llmwiki | Status |
|
|
541
712
|
|---|---|---|
|
|
542
|
-
| Data ingest | `llmwiki ingest` | Implemented |
|
|
543
|
-
| Compile wiki | `llmwiki compile` | Implemented |
|
|
544
|
-
| Q&A | `llmwiki query` | Implemented |
|
|
713
|
+
| Data ingest | `llmwiki ingest`, `ingest-session` (Claude/Codex/Cursor) | Implemented |
|
|
714
|
+
| Compile wiki | `llmwiki compile` (two-phase, incremental) | Implemented |
|
|
715
|
+
| Q&A | `llmwiki query` (semantic + BM25 + graph expansion) | Implemented |
|
|
545
716
|
| Output filing (save answers back) | `llmwiki query --save` | Implemented |
|
|
546
717
|
| Auto-recompile | `llmwiki watch` | Implemented |
|
|
547
|
-
| Linting / health-check pass | `llmwiki lint` | Implemented |
|
|
548
|
-
| Agent integration | `llmwiki serve`
|
|
549
|
-
|
|
|
718
|
+
| Linting / health-check pass | `llmwiki lint` + `llmwiki eval` (CI-gateable) | Implemented |
|
|
719
|
+
| Agent integration | `llmwiki serve` MCP server with `get_context_pack` | Implemented |
|
|
720
|
+
| Multimodal ingest | Images, PDFs, transcripts via `llmwiki ingest` | Implemented |
|
|
550
721
|
| Marp slides | `llmwiki export --target marp` | Implemented |
|
|
722
|
+
| Bridge to runtime memory | `llmwiki export --target json --project-id` → [`@atomicmemory/llmwiki`](https://github.com/atomicstrata/atomicmemory/tree/main/packages/llmwiki) | Implemented |
|
|
551
723
|
| Fine-tuning | — | Not yet implemented |
|
|
552
724
|
|
|
553
725
|
## Roadmap
|
|
554
726
|
|
|
727
|
+
Shipped in 0.9.0:
|
|
728
|
+
|
|
729
|
+
- ✅ Source freshness — `llmwiki lint` flags pages whose sources changed (`stale`) or were all deleted (`orphaned`) since compile, surfaced across MCP (`wiki_status`, `get_context_pack`), context packs, the viewer (badges, a per-axis filter, health counts, a corrupt-state banner), the JSON export, and `llmwiki next`
|
|
730
|
+
- ✅ `llmwiki refresh --stale` — repairs stale/orphaned pages with a targeted recompile of their changed owning sources (and deleted-owner cleanup), skipping unrelated new sources; `--dry-run` previews with no LLM calls or writes
|
|
731
|
+
- ✅ JSON export bridge contract — `llmwiki export --target json --project-id <id>` adds per-page `path`, `kind`, advisory confidence/provenance, flattened citations, aliases, and freshness so downstream importers (e.g. [`@atomicmemory/llmwiki`](https://github.com/atomicstrata/atomicmemory/tree/main/packages/llmwiki)) can ingest pages as durable memory records
|
|
732
|
+
- ✅ In-process SDK — `createWiki()` exposes the compiler in-process, with source-backed write APIs for programmatic callers
|
|
733
|
+
- ✅ Eval over MCP + richer metrics — `run_eval` tool and read-only `llmwiki://eval/report`/`llmwiki://eval/history` resources, plus source-utilization and citation-depth metrics with a `source_warnings_max` CI gate
|
|
734
|
+
- ✅ Rule-candidate extraction — extract reusable rule candidates from sources with review/approve and a JSON export pipeline
|
|
735
|
+
- ✅ Claude Agent provider — authenticates through a local Claude Code login (bundled plan tokens, no separate API key)
|
|
736
|
+
- ✅ Alias-aware wikilinks — the viewer resolves a `[[term]]` link to any page that declares `term` in its `aliases` frontmatter, not just an exact slug match
|
|
737
|
+
|
|
555
738
|
Shipped in 0.8.0:
|
|
556
739
|
|
|
557
740
|
- ✅ Guided project flow — `llmwiki next` recommends the next useful command, and `llmwiki quickstart <source>` ingests, compiles, and opens the viewer in one step
|
|
@@ -619,6 +802,10 @@ Explicitly not planned (good ideas, just not for this repo): full static-site ge
|
|
|
619
802
|
|
|
620
803
|
Node.js >= 24, plus provider credentials (for Anthropic: `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN`).
|
|
621
804
|
|
|
805
|
+
## About
|
|
806
|
+
|
|
807
|
+
llmwiki is maintained by [Atomic Strata](https://github.com/atomicstrata), the team behind [Atomic Memory](https://github.com/atomicstrata/atomicmemory). Atomic Strata builds open context infrastructure: durable compiled knowledge with llmwiki, runtime memory with Atomic Memory.
|
|
808
|
+
|
|
622
809
|
## License
|
|
623
810
|
|
|
624
811
|
MIT
|