llm-wiki-compiler 0.5.1 → 0.7.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/README.md CHANGED
@@ -25,9 +25,20 @@ export ANTHROPIC_API_KEY=sk-...
25
25
  llmwiki ingest https://some-article.com
26
26
  llmwiki compile
27
27
  llmwiki query "what is X?"
28
+ llmwiki view --open
28
29
  ```
29
30
 
30
- ## Configuration
31
+
32
+ <br>
33
+
34
+ ---
35
+
36
+ <br>
37
+
38
+
39
+ <details>
40
+ <summary><span style="font-size: 1.4em;"><strong>Configuration — click to expand</strong></span></summary>
41
+
31
42
 
32
43
  llmwiki configures providers via environment variables. The default provider is Anthropic.
33
44
 
@@ -103,6 +114,35 @@ export OLLAMA_HOST=http://ollama_host:11434/v1
103
114
  export OLLAMA_EMBEDDINGS_HOST=http://ollama_host:11435/v1
104
115
  ```
105
116
 
117
+ ### GitHub Copilot
118
+
119
+ Uses the GitHub Copilot API (`https://api.githubcopilot.com`), an
120
+ OpenAI-compatible endpoint available to Copilot subscribers. Requires a GitHub
121
+ OAuth token with the `copilot` scope — **classic PATs are not supported**.
122
+
123
+ First, ensure your `gh` CLI token has the required scope:
124
+
125
+ ```bash
126
+ gh auth refresh --scopes copilot
127
+ ```
128
+
129
+ Then run:
130
+
131
+ ```bash
132
+ export LLMWIKI_PROVIDER=copilot
133
+ export GITHUB_TOKEN=$(gh auth token) # OAuth token required; PATs will not work
134
+ export LLMWIKI_MODEL=gpt-4o # optional; gpt-4o is the default
135
+ ```
136
+
137
+ Available models (names use dots, not dashes): `gpt-4o`, `gpt-4o-mini`,
138
+ `claude-sonnet-4.5`, `claude-sonnet-4.6`, `claude-opus-4.5`, `gemini-2.5-pro`,
139
+ and others — availability depends on your Copilot plan.
140
+
141
+ **Embeddings:** The GitHub Copilot API does not expose an embeddings endpoint.
142
+ Semantic search (used by `llmwiki query` with chunked retrieval) will fall back
143
+ to full-index selection without embeddings. For embedding-dependent workflows,
144
+ switch to the `openai` provider and provide `OPENAI_API_KEY`.
145
+
106
146
  ### Request timeouts
107
147
 
108
148
  The OpenAI SDK defaults to a 10-minute per-request timeout, which can cut off long compile-time completions on slower local models. Override per provider:
@@ -112,6 +152,33 @@ The OpenAI SDK defaults to a 10-minute per-request timeout, which can cut off lo
112
152
 
113
153
  Defaults: 10 minutes for `openai`, 30 minutes for `ollama` (local models commonly need more).
114
154
 
155
+ ### Output language
156
+
157
+ Generated wiki content defaults to whatever language the model produces from the source material — typically English. Override with either:
158
+
159
+ - `LLMWIKI_OUTPUT_LANG` — e.g. `zh-CN`, `Chinese`, `ja`, `Japanese`. Applies to every prompt the compile and query pipelines make.
160
+ - `--lang <code>` on `llmwiki compile` and `llmwiki query` — same effect, scoped to one invocation. Wins over the env var.
161
+
162
+ Unset preserves prior behaviour byte-for-byte.
163
+
164
+ ### Per-concept prompt budget
165
+
166
+ When many sources contribute to the same compiled concept, `compile` enforces a per-concept character cap on the combined source content sent to the LLM so popular shared concepts don't blow past the model's context window. Each contributing source gets a fair share when truncation kicks in.
167
+
168
+ - `LLMWIKI_PROMPT_BUDGET_CHARS` — character ceiling for the combined per-concept prompt. Defaults to `200000` (~50k tokens), which fits modern context windows with headroom. Raise it for larger-context models, lower it for local small-context models.
169
+
170
+ A truncation warning prints to stderr when the cap fires so you know which concept hit the budget.
171
+
172
+ </details>
173
+
174
+
175
+ <br>
176
+
177
+ ---
178
+
179
+ <br>
180
+
181
+
115
182
  ## Why not just RAG?
116
183
 
117
184
  RAG retrieves chunks at query time. Every question re-discovers the same relationships from scratch. Nothing accumulates.
@@ -162,13 +229,27 @@ Related concepts: [[Propositional Logic]], [[Model Counting]]
162
229
 
163
230
  Pages include source attribution in frontmatter. Paragraphs are annotated with `^[filename.md]` markers pointing back to the source file that contributed the content; specific claims can use line ranges like `^[filename.md:42-58]` or `^[filename.md#L42-L58]`.
164
231
 
232
+
233
+ <br>
234
+
235
+ ---
236
+
237
+ <br>
238
+
239
+
240
+ <details>
241
+ <summary><span style="font-size: 1.4em;"><strong>CLI and wiki model — click to expand</strong></span></summary>
242
+
243
+
165
244
  ## Commands
166
245
 
167
246
  | Command | What it does |
168
247
  |---------|-------------|
169
248
  | `llmwiki ingest <url\|file>` | Fetch a URL or copy a local file into `sources/` |
249
+ | `llmwiki ingest-session <path>` | Import a Claude/Codex/Cursor session export (single file or whole directory) into `sources/` |
170
250
  | `llmwiki compile` | Incremental compile: extract concepts, generate wiki pages |
171
251
  | `llmwiki compile --review` | Write candidate pages to `.llmwiki/candidates/` instead of `wiki/` so you can review before they land |
252
+ | `llmwiki compile --lang <code>` | Generate wiki content in the given language (e.g. `Chinese`, `ja`, `zh-CN`); also works on `query` |
172
253
  | `llmwiki review list` | List pending candidate pages |
173
254
  | `llmwiki review show <id>` | Print a candidate's title, summary, and body |
174
255
  | `llmwiki review approve <id>` | Promote a candidate into `wiki/` and refresh index/MOC/embeddings |
@@ -177,6 +258,8 @@ Pages include source attribution in frontmatter. Paragraphs are annotated with `
177
258
  | `llmwiki schema show` | Print the resolved schema for the current project |
178
259
  | `llmwiki query "question"` | Ask questions against your compiled wiki |
179
260
  | `llmwiki query "question" --save` | Answer and save the result as a wiki page |
261
+ | `llmwiki export [--target <name>]` | Export the wiki to portable formats — `llms.txt`, `llms-full.txt`, JSON, JSON-LD, GraphML, Marp slides |
262
+ | `llmwiki view [--open]` | Start a read-only local web viewer for browsing, searching, and inspecting the compiled wiki |
180
263
  | `llmwiki lint` | Check wiki quality (broken links, orphans, empty pages, low confidence, contradictions, etc.) |
181
264
  | `llmwiki watch` | Auto-recompile when `sources/` changes |
182
265
  | `llmwiki serve [--root <dir>]` | Start an MCP server exposing wiki tools to AI agents |
@@ -196,6 +279,17 @@ wiki/
196
279
 
197
280
  Obsidian-compatible. `[[wikilinks]]` resolve to concept titles.
198
281
 
282
+ ## Local web viewer
283
+
284
+ Run `llmwiki view` from a project root to browse the compiled wiki in a local browser without Obsidian. The viewer is read-only: it renders `wiki/`, exposes sidebar navigation, search, page metadata, health counts, and provenance/citation chips, but does not mutate sources or generated pages.
285
+
286
+ ```bash
287
+ llmwiki view # prints Viewer ready at http://127.0.0.1:<port>
288
+ llmwiki view --open # also opens the URL in your default browser
289
+ ```
290
+
291
+ The server is private by default. It binds to `127.0.0.1` unless you explicitly provide both `--host <host>` and `--allow-lan`; wildcard hosts are rejected. Viewer responses use a strict local-asset CSP and path-confinement checks so the UI can safely render local markdown content.
292
+
199
293
  ## Review queue
200
294
 
201
295
  By default, `compile` writes pages directly to `wiki/`. Add `--review` to write candidate JSON records to `.llmwiki/candidates/` instead, so you can inspect each generated page before it lands.
@@ -229,17 +323,16 @@ confidence: 0.82 # 0–1, LLM-reported confidence in the synthesized p
229
323
  provenanceState: merged # extracted | merged | inferred | ambiguous
230
324
  contradictedBy:
231
325
  - slug: probabilistic-reasoning
232
- inferredParagraphs: 1 # paragraphs the LLM marked as inferred (vs cited)
233
326
  ---
234
327
  ```
235
328
 
236
- When multiple sources merge into one slug, metadata is reconciled: `min` confidence, `provenanceState = 'merged'`, union of `contradictedBy` (deduped by slug), `max` `inferredParagraphs`.
329
+ When multiple sources merge into one slug, metadata is reconciled: `min` confidence, `provenanceState = 'merged'`, union of `contradictedBy` (deduped by slug).
237
330
 
238
331
  `llmwiki lint` adds three rules that surface this metadata:
239
332
 
240
333
  - `low-confidence` — flags pages with `confidence` below a threshold
241
334
  - `contradicted-page` — flags pages with non-empty `contradictedBy`
242
- - `excess-inferred-paragraphs` — flags pages with too many inferred paragraphs without citations
335
+ - `excess-inferred-paragraphs` — flags pages whose body has too many uncited prose paragraphs (counted directly from the rendered text — the body is the single source of truth, no frontmatter field involved)
243
336
 
244
337
  ## Claim-level provenance
245
338
 
@@ -276,6 +369,16 @@ The schema supports four page kinds:
276
369
 
277
370
  Schema rules can set per-kind `minWikilinks` and optional `seedPages`. Compile can materialize seed pages such as overviews, lint enforces page-kind-specific cross-link minimums, and review candidates surface schema violations before approval.
278
371
 
372
+ </details>
373
+
374
+
375
+ <br>
376
+
377
+ ---
378
+
379
+ <br>
380
+
381
+
279
382
  ## Demo
280
383
 
281
384
  Try it on any article or document:
@@ -285,10 +388,23 @@ mkdir my-wiki && cd my-wiki
285
388
  llmwiki ingest https://en.wikipedia.org/wiki/Andrej_Karpathy
286
389
  llmwiki compile
287
390
  llmwiki query "What terms did Andrej coin?"
391
+ llmwiki view --open
288
392
  ```
289
393
 
290
394
  See `examples/basic/` in the repo for pre-generated output you can browse without an API key.
291
395
 
396
+
397
+ <br>
398
+
399
+ ---
400
+
401
+ <br>
402
+
403
+
404
+ <details>
405
+ <summary><span style="font-size: 1.4em;"><strong>MCP Server — click to expand</strong></span></summary>
406
+
407
+
292
408
  ## MCP Server
293
409
 
294
410
  llmwiki ships an MCP (Model Context Protocol) server so AI agents (Claude Desktop, Cursor, Claude Code, etc.) can drive the full pipeline directly: ingest sources, compile, query, search, lint, and read pages — without scraping CLI output.
@@ -345,6 +461,16 @@ Tools that need an LLM (`compile_wiki`, `query_wiki`, `search_pages`) check for
345
461
  | `llmwiki://sources` | List of ingested source files with metadata. |
346
462
  | `llmwiki://state` | Compilation state (per-source hashes, last compile times). |
347
463
 
464
+ </details>
465
+
466
+
467
+ <br>
468
+
469
+ ---
470
+
471
+ <br>
472
+
473
+
348
474
  ## Limitations
349
475
 
350
476
  Early software. Best for small, high-signal corpora (a few dozen sources). Query routing is index-based.
@@ -364,12 +490,25 @@ Karpathy describes an abstract pattern for turning raw data into compiled knowle
364
490
  | Auto-recompile | `llmwiki watch` | Implemented |
365
491
  | Linting / health-check pass | `llmwiki lint` | Implemented |
366
492
  | Agent integration | `llmwiki serve` (MCP server) | Implemented |
367
- | Image support | | Not yet implemented |
368
- | Marp slides | | Not yet implemented |
493
+ | Image support | `llmwiki ingest <image>` | Implemented |
494
+ | Marp slides | `llmwiki export --target marp` | Implemented |
369
495
  | Fine-tuning | — | Not yet implemented |
370
496
 
371
497
  ## Roadmap
372
498
 
499
+ Shipped in 0.7.0:
500
+
501
+ - ✅ Read-only local web viewer — `llmwiki view` with sidebar navigation, markdown rendering, search, metadata, health counts, and provenance/citation chips
502
+ - ✅ GitHub Copilot provider — `LLMWIKI_PROVIDER=copilot` with `GITHUB_TOKEN=$(gh auth token)` for Copilot chat/tool calls
503
+ - ✅ Cached lint health summary — `llmwiki lint` writes `.llmwiki/last-lint.json` so viewer health can show the latest lint counts without re-running lint
504
+
505
+ Shipped in 0.6.0:
506
+
507
+ - ✅ Export bundle (`llms.txt`, JSON, JSON-LD, GraphML, Marp slides)
508
+ - ✅ Session-history adapters — `llmwiki ingest-session` for Claude, Codex, and Cursor exports
509
+ - ✅ Configurable output language — `--lang <code>` and `LLMWIKI_OUTPUT_LANG`
510
+ - ✅ Defensive per-concept prompt budget so popular shared concepts don't crash compile
511
+
373
512
  Shipped in 0.5.0:
374
513
 
375
514
  - ✅ Multimodal ingest (images, PDFs, transcripts)
@@ -397,20 +536,22 @@ Shipped in 0.2.0:
397
536
 
398
537
  Next up:
399
538
 
400
- - Export bundle (`llms.txt`, JSON, JSON-LD, GraphML, Marp)
401
- - Session-history adapters (Claude, Codex, Cursor exports)
539
+ - **Graph/context layer** page-neighborhood tools, graph paths, gap detection, and token-budgeted context packs for agents.
540
+ - **Evaluation harness** — benchmark answer quality, citation accuracy, update drift, retrieval recall, and scale curves against serious retrieval baselines.
541
+ - **Task and decision ledger** — turn session ingest into durable agent memory: goals, decisions, open questions, outcomes, and next-agent handoffs.
542
+ - **Rollback, audit, and source lifecycle** — undo/reverse ingest, compile diff reports, stale-claim checks, freshness reports, and a durable operation log.
543
+ - **Domain templates** — schema/prompt packs for research, codebase docs, team handbooks, decision logs, and standards/regulations.
402
544
 
403
- Future ideas (open to discussion):
545
+ Later / open to discussion:
404
546
 
405
547
  - Recurring source refresh jobs — re-ingest URLs on a schedule, diff against the prior snapshot, re-compile only what changed
406
- - Graph export and a lightweight read-only graph browser for the concept network
407
- - A local read-only web UI for browsing the compiled wiki without Obsidian
408
- - MCP prompt resources curated agent prompts (review the wiki, propose new sources, draft a comparison page) shipped as MCP resources
409
- - Maintenance log + log rotation so long-running watch sessions don't grow unbounded
548
+ - MCP prompt resources curated agent prompts such as "review the wiki", "propose new sources", and "draft a comparison page"
549
+ - Codex OAuth provider ChatGPT subscription auth as a dedicated provider, with clear token refresh and embedding-limit behavior
550
+ - Team-chat connectors for Slack/Discord/Teams-style institutional memory
410
551
 
411
- If you like ambitious problems: **graph export with a browser**, **recurring source refresh**, and **MCP prompt resources** are the meatiest of the futures. Open an issue to claim one or kick off a design discussion.
552
+ If you like ambitious problems: **local web UI**, **graph/context packs**, and **eval harness** are the meatiest next contributions. Open an issue to claim one or kick off a design discussion.
412
553
 
413
- Explicitly not planned (good ideas, just not for this repo): full static-site generator, desktop or mobile apps, fine-tuning, a formal ontology engine, heavy graph reasoning.
554
+ Explicitly not planned (good ideas, just not for this repo): full static-site generator, desktop or mobile apps, fine-tuning, a formal ontology engine, heavy graph database infrastructure.
414
555
 
415
556
  ## Requirements
416
557