project-librarian 0.2.0 → 0.3.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
@@ -5,11 +5,42 @@
5
5
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22.13-brightgreen.svg)](https://nodejs.org/)
6
6
  [![Code evidence index](https://img.shields.io/badge/code%20evidence-node%3Asqlite-blue.svg)](https://nodejs.org/api/sqlite.html)
7
7
 
8
- Compact project memory and code evidence for Codex and Claude Code.
8
+ **Give every AI coding agent the same durable memory of your project.** Project Librarian keeps a compact, repo-local planning wiki — plus an optional code-evidence index — that Codex, Claude Code, Cursor, and Gemini CLI read at session start, so they stop rediscovering your codebase from scratch every time.
9
9
 
10
- Project Librarian creates a repo-local planning wiki, compact startup hooks, and an optional SQLite code evidence index so agents can start with the project plan, route to the right document, and inspect code-backed evidence without repeatedly scanning the whole repository.
10
+ Languages: [English](README.md) | [한국어](README.ko.md)
11
11
 
12
- Languages: [English](README.md) | [한국어](README.ko.md) | [日本語](README.ja.md) | [简体中文](README.zh.md)
12
+ ## Quick Start
13
+
14
+ Most users should ask their coding agent to run Project Librarian rather than run lifecycle commands by hand.
15
+
16
+ Install the reusable skill files once, or ask an agent with shell access to do it:
17
+
18
+ ```bash
19
+ npx project-librarian install-skill --scope user --agents all
20
+ ```
21
+
22
+ Then ask Codex, Claude Code, Cursor, or Gemini CLI from the target repository:
23
+
24
+ - "Use Project Librarian to set up this repository's planning wiki and run diagnostics."
25
+ - "Use Project Librarian to migrate the existing docs/wiki content."
26
+ - "Search the Project Librarian wiki for authentication decisions."
27
+
28
+ The installed skill tells the agent to resolve the local runner and execute the right command from the project root. Prefer a project-local install only when you want that runner stored inside the target repository's agent setup:
29
+
30
+ ```bash
31
+ npx project-librarian install-skill --scope project --agents all
32
+ ```
33
+
34
+ `install-skill` only copies the reusable runner and skill files. The agent-run lifecycle command is what creates or updates `AGENTS.md`, agent hooks, `wiki/`, git hook files, diagnostics, and optional code-evidence support.
35
+
36
+ ## Highlights
37
+
38
+ - **Small first read.** Session-start hooks inject only `wiki/startup.md` and `wiki/index.md`; agents route to deeper pages on demand instead of grepping the whole repo cold.
39
+ - **One setup, four agents.** Codex, Claude Code, Cursor, and Gemini CLI share the same wiki-first contract, hooks, and rules.
40
+ - **Structured wiki writing.** New project content is classified through `wiki/meta/document-taxonomy.md` before it is written or consolidated, so PRDs, policies, UX, data, APIs, QA, release, and operations notes do not collapse into one catch-all page.
41
+ - **Measured, not hand-wavy.** Every performance claim comes from hermetic Codex benchmarks — and the cases where it costs *more* are shown right next to the wins.
42
+ - **Optional code evidence.** A regenerable SQLite index plus answer-shaped MCP tools answer impact, ownership, and workspace-graph questions, with zero extra runtime dependencies.
43
+ - **Safe to re-run.** Bootstrap is idempotent and preservation-first; diagnostics flag broken routes, unreachable pages, and stale truth before they mislead an agent.
13
44
 
14
45
  ## Why It Exists
15
46
 
@@ -21,134 +52,144 @@ Project Librarian gives agents two local sources of truth:
21
52
  | --- | --- |
22
53
  | `wiki/startup.md` + `wiki/index.md` | A compact session-start summary and router, so only the relevant planning pages are read. |
23
54
  | `wiki/canonical/` and `wiki/decisions/` | Current project facts, constraints, risks, package contracts, CLI behavior, and durable decisions. |
24
- | `.codex/` and `.claude/` hooks | Automatic startup context for Codex and Claude Code without loading the full wiki. |
55
+ | `wiki/meta/document-taxonomy.md` | A service-lifecycle classification map that tells agents where PRD, policy, UX, data, engineering, QA, release, and operations truth should live. |
56
+ | `.codex/`, `.claude/`, `.cursor/`, and `.gemini/` hooks | Automatic startup context for Codex, Claude Code, Cursor, and Gemini CLI without loading the full wiki. |
57
+ | `GEMINI.md` and `.cursor/rules/` | Gemini CLI and Cursor instruction files that route agents to the same compact wiki-first contract. |
25
58
  | `.project-wiki/code-evidence.sqlite` | Regenerable code evidence for files, symbols, imports, routes, ownership, workspace graph, reports, and impact checks. |
26
59
  | Diagnostics and migration modes | Link checks, quality checks, migration inboxes, stale-signal reports, and issue drafts when the workflow exposes a problem. |
27
60
 
28
61
  The core idea is not "write more docs." It is "keep the first agent read small, then give it reliable routes to deeper project truth and code evidence."
29
62
 
63
+ The taxonomy is a routing aid, not a mandate to create every possible document. It is strongest for service and product development. Library, infrastructure, research, or other non-service projects can use only the relevant slices and leave the rest as intentionally unused categories instead of forcing artificial pages.
64
+
30
65
  ## Benchmark Results
31
66
 
32
- Benchmarks are maintainer release evidence, not a public user workflow. They exist so README and release notes can make bounded claims with numbers instead of vague performance language.
33
-
34
- Latest clean large report: `benchmarks/reports/current-large.json`, generated 2026-06-09T08:08:07.238Z on Node v22.19.0, darwin arm64, Apple M4 Pro, commit `18e730882c4f`, 5 measured runs with 1 discarded warmup run. Timing status was `stable`; unstable metrics were `none`; the report source-control fingerprint was clean.
35
-
36
- | Metric | Result |
37
- | --- | ---: |
38
- | Median estimated Markdown context avoidance | 99.61% |
39
- | Minimum estimated Markdown context avoidance | 99.43% |
40
- | Median read-time reduction | 99.47% |
41
- | Minimum read-time reduction | 99.26% |
42
- | Wiki pages measured | 1,601 |
43
- | Code-index files | 1,608 |
44
- | Code-index time | 336.312ms |
45
- | Code-index throughput | 4,781.27 files/sec |
46
- | Incremental index time | 186.776ms |
47
- | Full-to-incremental time reduction | 45.52% |
48
- | Architecture report time | 251.175ms |
49
- | Architecture report evidence tables | 6 |
50
- | Architecture report routes | 24 |
51
- | Sample repos | 3 |
52
- | Benchmark runs | 5 |
53
- | Warmup runs | 1 |
54
- | Timing status | stable |
55
- | Unstable metrics | none |
56
-
57
- Scenario summary:
58
-
59
- | Scenario | Scale | Result |
60
- | --- | ---: | --- |
61
- | Docs-heavy wiki | 500 pages | 99.74% estimated Markdown context avoidance, 99.47% read reduction, 43.83ms query |
62
- | Monorepo wiki | 320 pages | 99.43% estimated Markdown context avoidance, 99.26% read reduction, 81.12ms doctor |
63
- | Scoped router wiki | 720 pages | 99.61% estimated Markdown context avoidance, 99.55% read reduction, 67.684ms refresh |
64
- | Code-heavy mixed index | 1,608 files | 336.312ms full index, 186.776ms incremental, 251.175ms report, 626.969ms Tree-sitter index |
65
- | Sample repo validation | 3 repos, 16 files | 132.363ms median code index, 135.694ms median architecture report |
66
-
67
- Claim boundary: token estimates use `ceil(characters / 4)` as a Markdown context-size estimate. They are not model tokenizer output, API billing counters, or measured real LLM token consumption. The benchmark compares the wiki context read by targeted retrieval against a naive full-wiki scan that reads every wiki Markdown file in the fixture. Code-index metrics are local CLI subprocess timings over generated and sample repositories; sample repo values are observational evidence for those explicit fixtures.
68
-
69
- ## Install
70
-
71
- Use `npx` only for initial skill installation:
67
+ These numbers are maintainer release evidence, not a blanket promise. Every value is real Codex JSONL usage and local wall-clock time (ChatGPT/Codex auth, `gpt-5.5`), measured hermetically — isolated Codex home, allowlist-only environment, clean tree, post-run fixture validation — with 3 measured runs plus 1 warmup per scenario against an `organic` control that has no Project Librarian.
68
+
69
+ In the tables below, **"less" / "more"** compares cost-weighted tokens against that control, and **"faster" / "slower"** compares wall-clock time. (Cost-weighted = uncached input + 0.1 × cached input + output + reasoning output; cached resends are discounted, and raw merged totals would unfairly penalize any tool that adds a turn.) The wiki-routing track and the code-graph track are measured and reported separately a win on one never backs a claim about the other. Generated benchmark reports under `benchmarks/reports/llm/` are ignored by default; maintainers should commit deliberate release baselines only when they are meant to support a public claim. Reproduce a release candidate with:
72
70
 
73
71
  ```bash
74
- npx project-librarian install-skill --scope user --agents both
72
+ npm run benchmark:release
73
+ ```
74
+
75
+ ### Wiki track (planning-doc routing)
76
+
77
+ Cost-weighted tokens, Project Librarian vs control:
78
+
79
+ | Scale | decision_lookup | aggregation | multi_session (2nd session) |
80
+ | --- | --- | --- | --- |
81
+ | Small | 7.9% less | 7.0% more | 30.4% less |
82
+ | Medium | 69.5% less | 8.8% more | 56.6% less |
83
+ | Large (gate-passed retry) | 62.6% less | 45.0% less* | 70.7% less |
84
+
85
+ The claim-grade cells (claim gate passed, every run correct) are the two large wins: `decision_lookup` (62.6% fewer cost-weighted tokens, 41.5% faster) and `multi_session` (70.7% fewer tokens, 33.9% faster). Published boundaries, not hidden: `aggregation` costs 7–9% *more* tokens at small/medium, aggregation is *slower* with the wiki at every scale even when tokens drop, and *the large aggregation figure (45.0% less) comes from a Stage 1 run whose gate failed on control-side correctness flakes, so it stays investigation evidence rather than a claim.
86
+
87
+ ### Code-graph track (code evidence index, real repositories)
88
+
89
+ Measured on two SHA-pinned open-source repositories with hand-authored answer keys and the answer-shaped MCP tools injected into the hermetic Codex home. The claim gate passed with 30/30 runs correct after two evaluator false positives were fixed and the report was re-scored from raw JSONL; recompute-from-raw is the standing audit policy. Cost-weighted tokens, Project Librarian vs control:
90
+
91
+ | Question | excalidraw (~1.2k files) | backstage (~11.8k files) |
92
+ | --- | --- | --- |
93
+ | impact_trace | 117% more | **27.7% less** |
94
+ | workspace_graph | 106% more | 2.6% less |
95
+ | ownership_lookup | — | 99% more |
96
+
97
+ The claim is a scale crossover, and the losses are published next to the win: on the 11.8k-file repository the tool wins the expensive traversal question (impact_trace 27.7% fewer cost-weighted tokens, 24.5% fewer scan bytes) and breaks even on the workspace graph, but everything loses on the small repository and cheap lookups (CODEOWNERS ownership) lose at every measured scale. In short, the code-evidence index pays off only on genuinely large repositories for expensive-traversal questions — exactly what the CLI's scale-aware gates encode: below ~5k indexable files, `--code-index` asks for explicit acknowledgement and bootstrap skips MCP auto-registration, citing these measurements.
98
+
99
+ ### What the benchmark names mean
100
+
101
+ Repositories under test:
102
+
103
+ - **excalidraw** — a real open-source whiteboard/diagramming app (~1.2k files); the small-repo data point.
104
+ - **backstage** — Spotify's open-source developer-portal platform (~11.8k files); the large-repo data point.
105
+
106
+ Question types (task families):
107
+
108
+ - **decision_lookup** — find the latest project decision and its date from the wiki.
109
+ - **aggregation** — answer a question whose facts are scattered across several pages and must be synthesized.
110
+ - **multi_session** — a second session on the same project, measuring whether the durable wiki helps the next session, not just the first.
111
+ - **impact_trace** — "if this module changes, what else is affected?": trace the full set of direct and indirect importers.
112
+ - **ownership_lookup** — "who owns this file?": resolve the owner by CODEOWNERS last-match precedence.
113
+ - **workspace_graph** — "what does this package depend on across the monorepo?": the workspace/package dependency graph.
114
+
115
+ ## Install Details
116
+
117
+ Use this section when you need to choose an install scope or target agent. Use `npx` only for initial skill installation:
118
+
119
+ ```bash
120
+ npx project-librarian install-skill --scope user --agents all
75
121
  ```
76
122
 
77
123
  Install into the current repository instead:
78
124
 
79
125
  ```bash
80
- npx project-librarian install-skill --scope project --agents both
126
+ npx project-librarian install-skill --scope project --agents all
81
127
  ```
82
128
 
83
- `install-skill` copies reusable skill files only. It does not create or update `AGENTS.md`, `CLAUDE.md`, `wiki/`, `.codex/hooks.json`, or `.claude/settings.json`.
129
+ `install-skill` copies reusable skill files only. It does not create or update `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `wiki/`, `.cursor/rules/`, `.cursor/hooks.json`, `.gemini/settings.json`, `.codex/hooks.json`, or `.claude/settings.json`.
84
130
 
85
131
  | Situation | Command |
86
132
  | --- | --- |
87
- | Install globally for Codex and Claude Code | `npx project-librarian install-skill --scope user --agents both` |
88
- | Install in the current repository | `npx project-librarian install-skill --scope project --agents both` |
133
+ | Install globally for all supported agents | `npx project-librarian install-skill --scope user --agents all` |
134
+ | Install in the current repository | `npx project-librarian install-skill --scope project --agents all` |
89
135
  | Install only Codex | `npx project-librarian install-skill --agents codex` |
90
136
  | Install only Claude Code | `npx project-librarian install-skill --agents claude` |
91
- | Preview install output | `npx project-librarian install-skill --scope project --agents both --dry-run` |
137
+ | Install only Cursor | `npx project-librarian install-skill --agents cursor` |
138
+ | Install only Gemini CLI | `npx project-librarian install-skill --agents gemini` |
139
+ | Preview install output | `npx project-librarian install-skill --scope project --agents all --dry-run` |
92
140
 
93
- `--agents` also accepts comma-separated values such as `codex,claude`. `--scope` accepts `user` or `project`.
141
+ `--agents` also accepts comma-separated values such as `codex,claude,cursor,gemini`. `all` targets every supported agent. `--scope` accepts `user` or `project`.
94
142
 
95
- ## Agent Runner
143
+ ## Runner Paths
96
144
 
97
- After installation, agents should run the installed local copy with `node`, not `npx`. This avoids network access and unpinned package execution in restricted agent environments.
145
+ These paths are mainly for agents and automation. After installation, agents should run the installed local copy with `node`, not `npx`. This avoids network access and unpinned package execution in restricted agent environments.
98
146
 
99
147
  | Installation | Runner |
100
148
  | --- | --- |
101
149
  | Project-scoped Codex skill | `node .codex/skills/project-librarian/dist/init-project-wiki.js` |
102
150
  | Project-scoped Claude skill | `node .claude/skills/project-librarian/dist/init-project-wiki.js` |
151
+ | Project-scoped Cursor skill | `node .cursor/skills/project-librarian/dist/init-project-wiki.js` |
152
+ | Project-scoped Gemini skill | `node .gemini/skills/project-librarian/dist/init-project-wiki.js` |
103
153
  | User-scoped Codex skill | `node ~/.codex/skills/project-librarian/dist/init-project-wiki.js` |
104
154
  | User-scoped Claude skill | `node ~/.claude/skills/project-librarian/dist/init-project-wiki.js` |
105
-
106
- The examples below use:
107
-
108
- ```bash
109
- PROJECT_LIBRARIAN="node .codex/skills/project-librarian/dist/init-project-wiki.js"
110
- ```
111
-
112
- Use the matching local runner for your install location.
113
-
114
- ## Common Agent Workflows
115
-
116
- Bootstrap or update the wiki from the project root:
117
-
118
- ```bash
119
- $PROJECT_LIBRARIAN
120
- ```
121
-
122
- Validate and maintain the wiki:
123
-
124
- | Goal | Agent Command |
125
- | --- | --- |
126
- | Create or update the wiki | `$PROJECT_LIBRARIAN` |
127
- | Migrate existing docs/wiki content | `$PROJECT_LIBRARIAN --migrate` |
128
- | Validate generated setup | `$PROJECT_LIBRARIAN --lint` |
129
- | Check links and document quality | `$PROJECT_LIBRARIAN --doctor` |
130
- | Refresh generated routing before diagnostics | `$PROJECT_LIBRARIAN --doctor --fix` |
131
- | Search project wiki content | `$PROJECT_LIBRARIAN --query "authentication decisions"` |
132
- | Capture a candidate note | `$PROJECT_LIBRARIAN --capture-inbox --title "Candidate" --content "Details"` |
133
- | Report stale or unresolved wiki pages | `$PROJECT_LIBRARIAN --prune-check` |
134
- | Install hook files without changing git config | `$PROJECT_LIBRARIAN --no-git-config` |
135
-
136
- Build and inspect code evidence:
137
-
138
- | Goal | Agent Command |
139
- | --- | --- |
140
- | Build the default evidence cache | `$PROJECT_LIBRARIAN --code-index --code-scope src` |
141
- | Build multiple scopes | `$PROJECT_LIBRARIAN --code-index --code-scope src --code-scope packages/api` |
142
- | Require incremental update | `$PROJECT_LIBRARIAN --code-index --incremental` |
143
- | Force a full rebuild | `$PROJECT_LIBRARIAN --code-index --code-index-full` |
144
- | Use optional Tree-sitter backend | `$PROJECT_LIBRARIAN --code-index --code-parser tree-sitter` |
145
- | Show cache status | `$PROJECT_LIBRARIAN --code-status` |
146
- | List indexed files | `$PROJECT_LIBRARIAN --code-files` |
147
- | Print architecture and ownership report | `$PROJECT_LIBRARIAN --code-report` |
148
- | Print one report section | `$PROJECT_LIBRARIAN --code-report --code-report-section routes` |
149
- | Inspect impact evidence | `$PROJECT_LIBRARIAN --code-impact healthHandler` |
150
- | Search indexed symbols | `$PROJECT_LIBRARIAN --code-search-symbol Auth` |
151
- | Run conservative read-only SQL | `$PROJECT_LIBRARIAN --code-query "select path from files order by path"` |
155
+ | User-scoped Cursor skill | `node ~/.cursor/skills/project-librarian/dist/init-project-wiki.js` |
156
+ | User-scoped Gemini skill | `node ~/.gemini/skills/project-librarian/dist/init-project-wiki.js` |
157
+
158
+ ## Common Agent Requests
159
+
160
+ Ask your agent for the outcome you want; the skill maps the request to the local runner internally.
161
+
162
+ Wiki setup and maintenance:
163
+
164
+ | Goal | Ask The Agent | Internal Action |
165
+ | --- | --- | --- |
166
+ | Create or update the wiki | "Use Project Librarian to set up or update this repository's planning wiki." | `[init]` |
167
+ | Migrate existing docs/wiki content | "Use Project Librarian to migrate the existing docs/wiki content." | `--migrate` |
168
+ | Validate generated setup | "Run Project Librarian validation." | `--lint` |
169
+ | Check links and document quality | "Run Project Librarian diagnostics." | `--doctor` |
170
+ | Refresh generated routing before diagnostics | "Refresh Project Librarian routing and then run diagnostics." | `--doctor --fix` |
171
+ | Search project wiki content | "Search the Project Librarian wiki for authentication decisions." | `--query "authentication decisions"` |
172
+ | Show backlinks and decision citations for a page | "Show Project Librarian wiki impact for decisions/release-policy." | `--wiki-impact "decisions/release-policy"` |
173
+ | Capture a candidate note | "Capture this as a Project Librarian candidate note: <details>." | `--capture-inbox --title "Candidate" --content "Details"` |
174
+ | Report stale or unresolved wiki pages | "Check Project Librarian for stale or unresolved pages." | `--prune-check` |
175
+ | Install hook files without changing git config | "Set up Project Librarian hook files without changing git config." | `--no-git-config` |
176
+
177
+ Code evidence:
178
+
179
+ | Goal | Ask The Agent | Internal Action |
180
+ | --- | --- | --- |
181
+ | Build the default evidence cache | "Build Project Librarian code evidence for `src`." | `--code-index --code-scope src` |
182
+ | Build multiple scopes | "Build Project Librarian code evidence for `src` and `packages/api`." | `--code-index --code-scope src --code-scope packages/api` |
183
+ | Require incremental update | "Update the Project Librarian code evidence index incrementally." | `--code-index --incremental` |
184
+ | Force a full rebuild | "Fully rebuild the Project Librarian code evidence index." | `--code-index --code-index-full` |
185
+ | Use optional Tree-sitter backend | "Build Project Librarian code evidence with the Tree-sitter parser." | `--code-index --code-parser tree-sitter` |
186
+ | Show cache status | "Show Project Librarian code evidence status." | `--code-status` |
187
+ | List indexed files | "List files in the Project Librarian code evidence index." | `--code-files` |
188
+ | Print architecture and ownership report | "Show the Project Librarian code report." | `--code-report` |
189
+ | Print one report section | "Show the routes section of the Project Librarian code report." | `--code-report --code-report-section routes` |
190
+ | Inspect impact evidence | "Show Project Librarian impact evidence for `healthHandler`." | `--code-impact healthHandler` |
191
+ | Search indexed symbols | "Search Project Librarian code evidence for symbol `Auth`." | `--code-search-symbol Auth` |
192
+ | Run conservative read-only SQL | "Run a read-only Project Librarian code evidence query for file paths." | `--code-query "select path from files order by path"` |
152
193
 
153
194
  Only one code evidence mode can run at a time. `--incremental`, `--code-index-full`, and `--code-parser` are valid only with `--code-index`.
154
195
 
@@ -158,7 +199,9 @@ Project instruction files:
158
199
 
159
200
  - `AGENTS.md`
160
201
  - `CLAUDE.md`
202
+ - `GEMINI.md`
161
203
  - `wiki/AGENTS.md`
204
+ - `.cursor/rules/project-librarian.mdc`
162
205
 
163
206
  Startup hooks:
164
207
 
@@ -166,6 +209,10 @@ Startup hooks:
166
209
  - `.codex/hooks/wiki-session-start.js`
167
210
  - `.claude/settings.json`
168
211
  - `.claude/hooks/wiki-session-start.js`
212
+ - `.cursor/hooks.json`
213
+ - `.cursor/hooks/wiki-session-start.js`
214
+ - `.gemini/settings.json`
215
+ - `.gemini/hooks/wiki-session-start.js`
169
216
 
170
217
  Git hook files:
171
218
 
@@ -181,21 +228,59 @@ Wiki directories:
181
228
  - `wiki/sources/`
182
229
  - `wiki/migration/`
183
230
 
231
+ Seed wiki pages and routers:
232
+
233
+ - `wiki/startup.md`
234
+ - `wiki/index.md`
235
+ - `wiki/meta/document-taxonomy.md`
236
+
237
+ Empty project pages such as `canonical/project-brief.md`, `canonical/open-questions.md`, `canonical/assumptions.md`, `canonical/risks.md`, and ADR templates are not created until there is real content to store. The router can discover them later with `--refresh-index`. During migration, form-only legacy templates are recorded as skipped in `wiki/migration/inventory.md` instead of becoming review rows or new wiki pages.
238
+
239
+ MCP server registration (preservation-first merge into `mcpServers`):
240
+
241
+ - `.mcp.json` (Claude Code)
242
+ - `.cursor/mcp.json` (Cursor)
243
+ - `.gemini/settings.json` `mcpServers` (Gemini CLI)
244
+
184
245
  Disposable code evidence cache:
185
246
 
186
247
  - `.project-wiki/code-evidence.sqlite`
187
248
 
249
+ ## Code Evidence MCP Server
250
+
251
+ `project-librarian mcp` runs a hand-rolled stdio MCP server (JSON-RPC 2.0 over newline-delimited JSON, no extra runtime dependencies) that serves the existing `.project-wiki` code-evidence index read-only. It exposes answer-shaped tools — `code_impact`, `code_ownership` (CODEOWNERS last-match precedence), `code_workspace_graph`, `code_search`, and `code_status` — whose responses lead with a one-line answer, follow with compact path/symbol/signature evidence, cap each reply, and prepend a warning when `code_status` reports the index is stale.
252
+
253
+ Bootstrap registers the server for Claude Code (`.mcp.json`), Cursor (`.cursor/mcp.json`), and Gemini CLI (`mcpServers` in `.gemini/settings.json`), preserving any existing servers and keys and reporting `exists` on a re-run. When the repository contains a local runner the registration uses `node <runner> mcp`; otherwise it uses the installed `project-librarian mcp` binary.
254
+
255
+ Codex registers MCP servers at the user level only (`codex mcp add`), so bootstrap does not write a project-level Codex MCP config. To use the server with Codex, run it once per machine:
256
+
257
+ ```bash
258
+ codex mcp add project-librarian -- node .codex/skills/project-librarian/dist/init-project-wiki.js mcp
259
+ ```
260
+
188
261
  ## How It Works
189
262
 
190
263
  1. Bootstrap creates a preservation-first wiki structure and marker-bounded agent instruction sections.
191
264
  2. Session-start hooks inject only `wiki/startup.md` and `wiki/index.md`, with character budgets.
192
- 3. Detailed planning truth stays in canonical, decision, source, and meta pages that agents read on demand.
193
- 4. `--refresh-index` routes newly discovered wiki pages; large route sets are split into `wiki/indexes/auto-*.md` scoped routers.
194
- 5. `--code-index` creates a disposable SQLite evidence cache under `.project-wiki/`.
195
- 6. `--code-report`, `--code-impact`, `--code-search-symbol`, and `--code-query` expose code-backed evidence for planning updates.
196
- 7. Diagnostics report broken links, duplicate routes, orphan pages, stale pages, missing TL;DRs, evidence gaps, and migration copy risks.
265
+ 3. Bootstrap avoids empty form-only project pages; focused canonical, decision, source, and meta pages are created when content actually exists.
266
+ 4. Detailed planning truth stays in canonical, decision, source, and meta pages that agents read on demand.
267
+ 5. New project-planning content is classified through `wiki/meta/document-taxonomy.md` before it is written or consolidated, keeping upstream/downstream document relationships visible.
268
+ 6. `--refresh-index` routes newly discovered wiki pages; large route sets are split into `wiki/indexes/auto-*.md` scoped routers.
269
+ 7. `--code-index` creates a disposable SQLite evidence cache under `.project-wiki/`.
270
+ 8. `--code-report`, `--code-impact`, `--code-search-symbol`, and `--code-query` expose code-backed evidence for planning updates.
271
+ 9. Diagnostics report broken links, duplicate routes, orphan pages, stale pages, missing TL;DRs, evidence gaps, and migration policy violations.
272
+
273
+ Migration is intentionally review-first. `--migrate` preserves an existing `wiki/` as `wiki_legacy*`, skips form-only/template legacy files, splits mixed legacy pages into meaning units, classifies each unit through the document taxonomy, and writes review files under `wiki/migration/`:
274
+
275
+ - `inventory.md` records migratable legacy markdown files, file-level classification, and form-only/template files skipped from semantic migration.
276
+ - `unit-map.md` records each heading, paragraph, list item, table row, and code block with its suggested taxonomy area and target page.
277
+ - `split-plan.md` groups those units by suggested new wiki target, so one legacy page that mixes API specs, features, UX, QA, policy, or operations can be rewritten into separate files.
278
+ - `coverage.md` is the editable status ledger for each unit: pending, adopted, merged, superseded, rejected, resolved, or needs-human-review.
279
+ - `verification.md` and `review.md` summarize coverage and semantic completion after `--review-migration`.
280
+
281
+ `--migration-lint` validates that `coverage.md`, `unit-map.md`, and `split-plan.md` still account for the current migration batch, including duplicate/stale unit IDs, invalid storage/confidence/status values, split count drift, target drift, and old coverage-table schemas. When a legacy page has units that point to multiple targets, `--review-migration` will not let a file-level inbox status complete every unit; unit-level coverage must be resolved instead.
197
282
 
198
- Migration is intentionally review-first. `--migrate` preserves an existing `wiki/` as `wiki_legacy*`, writes migration inboxes, and avoids copying legacy markdown directly into new canonical truth.
283
+ Retained or copied legacy content is acceptable when it fits the new wiki policy and structure; the new wiki must not depend on citing `wiki_legacy*`.
199
284
 
200
285
  ## Language Support Matrix
201
286
 
@@ -220,31 +305,35 @@ Recognized but inventory-only extensions include `.rb`, `.vue`, and `.css`. Conf
220
305
 
221
306
  ## CLI Reference
222
307
 
223
- Use the local runner for agent execution:
308
+ Use the resolved local runner for automation or direct CLI execution:
224
309
 
225
310
  ```bash
226
- $PROJECT_LIBRARIAN [init] [options]
227
- $PROJECT_LIBRARIAN install-skill [--scope user|project] [--agents codex|claude|both]
311
+ node .codex/skills/project-librarian/dist/init-project-wiki.js [init] [options]
312
+ node .codex/skills/project-librarian/dist/init-project-wiki.js install-skill [--scope user|project] [--agents codex|claude|cursor|gemini|all]
228
313
  ```
229
314
 
230
315
  Important options:
231
316
 
232
317
  | Option | Purpose |
233
318
  | --- | --- |
234
- | `--migrate`, `--adopt-existing` | Preserve an existing wiki as `wiki_legacy*` and create migration inboxes. |
319
+ | `--migrate`, `--adopt-existing` | Preserve an existing wiki as `wiki_legacy*`, create migration inboxes, and generate unit-map/split-plan/coverage review files. |
235
320
  | `--lint` | Validate generated setup without editing files. |
236
- | `--link-check` | Report broken wiki links, duplicate routes, and orphan pages. |
321
+ | `--link-check` | Report broken wiki links, duplicate routes, orphan pages, and pages the startup router cannot reach within the depth budget. |
237
322
  | `--quality-check` | Report stale, conflicting, and low-quality wiki document signals. |
238
323
  | `--doctor` | Run lint, link-check, and quality-check together. |
239
324
  | `--doctor --fix` | Safely refresh generated index routing before diagnostics. |
240
- | `--query <terms>` | Search wiki paths, metadata, titles, and bodies. |
325
+ | `--migration-lint` | Validate migration coverage, unit-map, split-plan, and review scaffolding separately from normal lint. |
326
+ | `--migration-quality-check` | Report migration policy/structure signals separately from normal quality-check. |
327
+ | `--migration-doctor` | Run migration-lint and migration-quality-check together. |
328
+ | `--query <terms>` | Search wiki paths, metadata, titles, and bodies; answer-first output with per-page TL;DR lines under a hard size cap. |
329
+ | `--wiki-impact <page-or-term>` | Show wiki backlinks, `decision_ref` citations, outgoing links, and router depth for matching pages. |
241
330
  | `--refresh-index` | Update generated auto-discovered wiki routing. |
242
331
  | `--capture-inbox --title <title> --content <content>` | Append a candidate note to the wiki inbox. |
243
332
  | `--issue-draft --issue-title <title>` | Print a read-only GitHub issue body draft for problems or side effects. |
244
333
  | `--issue-create --issue-title <title>` | Create a GitHub issue through `gh` after explicit user approval. |
245
334
  | `--glossary-init` | Create and route the optional glossary page. |
246
335
  | `--prune-check` | Report active pages with stale or unresolved lifecycle signals. |
247
- | `--review-migration`, `--semantic-migrate` | Sync migration inbox statuses into migration review files. |
336
+ | `--review-migration`, `--semantic-migrate` | Sync migration coverage and inbox statuses into migration review files. |
248
337
  | `--no-git-config` | Install hook files without changing `git core.hooksPath`. |
249
338
  | `--code-index` | Build the disposable code evidence index. |
250
339
  | `--code-report` | Print architecture and ownership summaries from the evidence index. |
@@ -273,7 +362,7 @@ Maintainer benchmark commands live in [benchmarks/README.md](benchmarks/README.m
273
362
 
274
363
  This project is inspired by Andrej Karpathy's [LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) pattern: keep persistent markdown context close to the work instead of reconstructing project state from long chat history.
275
364
 
276
- Project Librarian adapts that idea into an installable CLI and skill for Codex and Claude Code, with repo-local instructions, compact startup hooks, migration helpers, diagnostics, and optional code evidence.
365
+ Project Librarian adapts that idea into an installable CLI and skill for Codex, Claude Code, Cursor, and Gemini CLI, with repo-local instructions, compact startup hooks, migration helpers, diagnostics, and optional code evidence.
277
366
 
278
367
  ## License
279
368
 
package/SKILL.md CHANGED
@@ -37,8 +37,12 @@ Prefer an already installed local runner over network package execution:
37
37
  - In the project-librarian source repository, use `node dist/init-project-wiki.js` when `dist/init-project-wiki.js` exists.
38
38
  - In a target repository with a project-scoped Codex skill install, use `node .codex/skills/project-librarian/dist/init-project-wiki.js`.
39
39
  - In a target repository with a project-scoped Claude skill install, use `node .claude/skills/project-librarian/dist/init-project-wiki.js`.
40
+ - In a target repository with a project-scoped Cursor skill install, use `node .cursor/skills/project-librarian/dist/init-project-wiki.js`.
41
+ - In a target repository with a project-scoped Gemini skill install, use `node .gemini/skills/project-librarian/dist/init-project-wiki.js`.
40
42
  - In a user-scoped Codex skill install, use `node ~/.codex/skills/project-librarian/dist/init-project-wiki.js`.
41
43
  - In a user-scoped Claude skill install, use `node ~/.claude/skills/project-librarian/dist/init-project-wiki.js`.
44
+ - In a user-scoped Cursor skill install, use `node ~/.cursor/skills/project-librarian/dist/init-project-wiki.js`.
45
+ - In a user-scoped Gemini skill install, use `node ~/.gemini/skills/project-librarian/dist/init-project-wiki.js`.
42
46
 
43
47
  Use `npx` or `npm exec` only when no local runner exists and registry access is explicitly acceptable for the environment. When using npm package execution, pin the package version instead of running an unpinned public package.
44
48
 
@@ -68,6 +72,7 @@ Map lifecycle requests to these internal operations:
68
72
  - Check wiki links and routing: `$PROJECT_LIBRARIAN --link-check`.
69
73
  - Check document quality signals: `$PROJECT_LIBRARIAN --quality-check`.
70
74
  - Run all wiki diagnostics: `$PROJECT_LIBRARIAN --doctor`.
75
+ - Check migration-specific review signals: `$PROJECT_LIBRARIAN --migration-doctor`.
71
76
  - Safely refresh generated routing before diagnostics: `$PROJECT_LIBRARIAN --doctor --fix`.
72
77
  - Search the wiki: `$PROJECT_LIBRARIAN --query "search terms"`.
73
78
  - Refresh wiki routing/index: `$PROJECT_LIBRARIAN --refresh-index`.
@@ -89,9 +94,11 @@ Skill problem reporting contract:
89
94
  ```bash
90
95
  node .codex/hooks/wiki-session-start.js
91
96
  node .claude/hooks/wiki-session-start.js
97
+ node .cursor/hooks/wiki-session-start.js
98
+ GEMINI_PROJECT_DIR="$PWD" node .gemini/hooks/wiki-session-start.js
92
99
  $PROJECT_LIBRARIAN --lint
93
100
  $PROJECT_LIBRARIAN --doctor
94
- node -e 'JSON.parse(require("fs").readFileSync(".codex/hooks.json","utf8")); JSON.parse(require("fs").readFileSync(".claude/settings.json","utf8")); console.log("project librarian ok")'
101
+ node -e 'const fs=require("fs"); JSON.parse(fs.readFileSync(".codex/hooks.json","utf8")); JSON.parse(fs.readFileSync(".claude/settings.json","utf8")); JSON.parse(fs.readFileSync(".cursor/hooks.json","utf8")); JSON.parse(fs.readFileSync(".gemini/settings.json","utf8")); if (!fs.readFileSync("GEMINI.md","utf8").includes("@AGENTS.md")) process.exit(1); if (!fs.readFileSync(".cursor/rules/project-librarian.mdc","utf8").includes("@AGENTS.md")) process.exit(1); console.log("project librarian ok")'
95
102
  ```
96
103
 
97
104
  4. Report the files created or updated.
@@ -102,7 +109,7 @@ The script is idempotent. It creates missing files, updates the managed startup/
102
109
 
103
110
  Existing root instruction files are preservation-first:
104
111
 
105
- - Existing `AGENTS.md`, `CLAUDE.md`, and `wiki/AGENTS.md` files are not overwritten wholesale.
112
+ - Existing `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, and `wiki/AGENTS.md` files are not overwritten wholesale.
106
113
  - If no managed project-wiki section exists, bootstrap appends its marker-bounded section to the existing file.
107
114
  - On rerun, bootstrap replaces only content between its own `PROJECT-WIKI-*` markers and preserves surrounding project-specific content.
108
115
 
@@ -112,9 +119,9 @@ Use `--lint` for read-only validation:
112
119
  $PROJECT_LIBRARIAN --lint
113
120
  ```
114
121
 
115
- Use `--query`, `--prune-check`, `--issue-draft`, `--link-check`, `--quality-check`, and `--doctor` for read-only inspection/output through the resolved runner. Use `--doctor --fix` when safe generated routing refresh is intended. Use `--refresh-index`, `--capture-inbox`, `--glossary-init`, and `--migrate` only when updating wiki files is intended.
122
+ Use `--query`, `--prune-check`, `--issue-draft`, `--link-check`, `--quality-check`, `--doctor`, `--migration-lint`, `--migration-quality-check`, and `--migration-doctor` for read-only inspection/output through the resolved runner. Use `--doctor --fix` when safe generated routing refresh is intended. Use `--refresh-index`, `--capture-inbox`, `--glossary-init`, and `--migrate` only when updating wiki files is intended.
116
123
 
117
- Use `--review-migration` or `--semantic-migrate` after migration inbox rows are processed. It syncs inbox statuses into `wiki/migration/review.md` and `wiki/migration/verification.md`.
124
+ Use `--review-migration` or `--semantic-migrate` after migration coverage or compatible inbox rows are processed. It syncs unit coverage and safe file-level inbox statuses into `wiki/migration/review.md` and `wiki/migration/verification.md`.
118
125
 
119
126
  ## Code-Informed Canonicalization
120
127
 
@@ -193,8 +200,8 @@ Execution contract:
193
200
  - Code structure, entrypoints, module relationships, execution flows, read-on-demand routes, and evidence paths belong under `wiki/meta/` with descriptive project-specific filenames chosen by the LLM.
194
201
  - Code-backed current project behavior, features, policies, constraints, terminology, domain rules, and operational facts belong under `wiki/canonical/`.
195
202
  - Important design rationale or tradeoffs inferred from code may belong under `wiki/decisions/` when they meet the decision policy.
196
- - Unclear, conflicting, or low-confidence interpretations belong in `wiki/inbox/` or `wiki/canonical/open-questions.md`, not directly in canonical truth.
197
- 4. Do not use fixed canonical filenames beyond existing starter docs. Choose or create files from topic boundaries, expected read frequency, and token budget.
203
+ - Unclear, conflicting, or low-confidence interpretations belong in `wiki/inbox/` or a focused canonical questions page created for the topic, not directly in canonical truth.
204
+ 4. Do not use fixed canonical filenames. Choose or create files from topic boundaries, expected read frequency, and token budget.
198
205
  5. Split large subjects into focused documents when a single file would force agents to read unrelated content.
199
206
  6. Cite concrete evidence with repository-relative paths and distinguish code-proven facts from inference.
200
207
  7. Update `wiki/startup.md` and `wiki/index.md` only with compact routing hints, not large code summaries.
@@ -204,22 +211,28 @@ It installs:
204
211
 
205
212
  - `AGENTS.md` compact project-wide wiki-first planning instructions.
206
213
  - `CLAUDE.md` compact Claude Code compatibility file that imports `AGENTS.md`.
214
+ - `GEMINI.md` compact Gemini CLI compatibility file that imports `AGENTS.md`.
207
215
  - `wiki/AGENTS.md` detailed wiki-internal editing and boundary rules.
216
+ - `.cursor/rules/project-librarian.mdc` compact always-applied Cursor rule that references `AGENTS.md`.
208
217
  - `.githooks/prepare-commit-msg` wiki commit trailer hook.
209
218
  - `.githooks/wiki-commit-trailers.js` staged-file based trailer generator.
210
219
  - `.codex/hooks.json` `SessionStart` hook.
211
220
  - `.codex/hooks/wiki-session-start.js` compact startup context injector.
212
221
  - `.claude/settings.json` Claude Code `SessionStart` hook.
213
222
  - `.claude/hooks/wiki-session-start.js` compact startup context injector for Claude Code.
223
+ - `.cursor/hooks.json` Cursor `sessionStart` hook.
224
+ - `.cursor/hooks/wiki-session-start.js` compact startup context injector for Cursor.
225
+ - `.gemini/settings.json` Gemini CLI `SessionStart` hook.
226
+ - `.gemini/hooks/wiki-session-start.js` compact startup context injector for Gemini CLI.
214
227
  - `wiki/startup.md` compact session-start context.
215
228
  - `wiki/index.md` router with read/update/token-budget hints.
216
- - `wiki/canonical/` project-current-truth starter documents.
229
+ - `wiki/canonical/` directory for project-current-truth documents, created only when real content exists.
217
230
  - Optional `wiki/canonical/glossary.md` project terminology contract when `--glossary-init` is used.
218
- - `wiki/decisions/` project-decision starter documents and ADR templates.
231
+ - `wiki/decisions/` project-decision directory and lightweight decision ledgers.
219
232
  - `wiki/meta/` wiki operating rules, project decision policy, and wiki-operations Decision Pack.
220
- - `wiki/sources/` source summary starter documents.
233
+ - `wiki/sources/` source summary documents.
221
234
 
222
- The Codex and Claude Code startup hooks inject only `wiki/startup.md` and `wiki/index.md`. Codex uses `.codex/hooks.json` plus `.codex/hooks/wiki-session-start.js`; Claude Code uses `.claude/settings.json` plus `.claude/hooks/wiki-session-start.js`. `CLAUDE.md` still imports `AGENTS.md` so Claude Code shares the same compact wiki-first instruction contract without duplicating the rules. `AGENTS.md` should stay compact and project-wide; `wiki/AGENTS.md` should carry detailed wiki editing rules. `wiki/startup.md` should route detailed canonical and decision files as Read On Demand, not Always Read First, so detailed files are read only when the current question needs them.
235
+ The Codex, Claude Code, Cursor, and Gemini CLI startup hooks inject only `wiki/startup.md` and `wiki/index.md`. Codex uses `.codex/hooks.json` plus `.codex/hooks/wiki-session-start.js`; Claude Code uses `.claude/settings.json` plus `.claude/hooks/wiki-session-start.js`; Cursor uses `.cursor/hooks.json` plus `.cursor/hooks/wiki-session-start.js`; Gemini CLI uses `.gemini/settings.json` plus `.gemini/hooks/wiki-session-start.js`. `CLAUDE.md` and `GEMINI.md` import `AGENTS.md`, and `.cursor/rules/project-librarian.mdc` references `AGENTS.md`, so Claude Code, Gemini CLI, and Cursor share the same compact wiki-first instruction contract without duplicating the rules. `AGENTS.md` should stay compact and project-wide; `wiki/AGENTS.md` should carry detailed wiki editing rules. `wiki/startup.md` should route detailed canonical and decision files as Read On Demand, not Always Read First, so detailed files are read only when the current question needs them.
223
236
 
224
237
  When the project is a git repository, the script configures `git config core.hooksPath .githooks` by default only when `core.hooksPath` is unset, so wiki commit trailers are generated automatically without replacing an existing hook chain. Use `--no-git-config` to install hook files without changing git config. If the project is not a git repository yet, the hook files are still installed and will work after `core.hooksPath` is set.
225
238
 
@@ -249,7 +262,7 @@ Every wiki markdown file should include a compact metadata header with `status`,
249
262
 
250
263
  Wiki-specific commit trailers are automated through `.githooks/prepare-commit-msg`.
251
264
 
252
- The hook runs when staged files include `wiki/`, `AGENTS.md`, `CLAUDE.md`, `.codex/hooks.json`, `.codex/hooks/`, `.claude/settings.json`, `.claude/hooks/`, `.githooks/`, or `tools/project-librarian/`.
265
+ The hook runs when staged files include `wiki/`, `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursor/rules/`, `.cursor/hooks.json`, `.cursor/hooks/`, `.gemini/settings.json`, `.gemini/hooks/`, `.codex/hooks.json`, `.codex/hooks/`, `.claude/settings.json`, `.claude/hooks/`, `.githooks/`, or `tools/project-librarian/`.
253
266
 
254
267
  It appends these trailers when they are missing:
255
268
 
@@ -264,7 +277,7 @@ It appends these trailers when they are missing:
264
277
 
265
278
  Do not hand-write wiki trailers unless the hook is unavailable or the generated value needs correction.
266
279
 
267
- `--lint` verifies the Codex and Claude hook files/settings, git hook files, executable bits, trailer phrases, and `core.hooksPath` when the project is a git repository. If `--no-git-config` was used, an unset or different `core.hooksPath` is expected until the project owner configures it manually.
280
+ `--lint` verifies common wiki files plus the agent surfaces that are present in the project. If any file for a surface exists, lint requires the rest of that surface's files and settings; uninstalled Cursor or Gemini surfaces are not hard requirements. It also checks git hook files, executable bits, trailer phrases, and `core.hooksPath` when the project is a git repository. If `--no-git-config` was used, an unset or different `core.hooksPath` is expected until the project owner configures it manually.
268
281
 
269
282
  ## Glossary Mode
270
283
 
@@ -297,20 +310,27 @@ Captured inbox entries are not canonical. Fold them into `wiki/canonical/`, `wik
297
310
 
298
311
  `--migrate` and `--adopt-existing` are aliases.
299
312
 
300
- Migration mode is a reset-and-rewrite flow:
313
+ Migration mode is a reset-and-restructure flow:
301
314
 
302
315
  - If `./wiki` exists, renames it to `./wiki_legacy`.
303
316
  - If `./wiki_legacy` already exists, preserves both by using a timestamped `wiki_legacy_...` directory for the current wiki.
304
317
  - Creates a fresh `./wiki` using the current standard rules.
305
318
  - Scans markdown files under the legacy wiki directory.
306
- - Writes `wiki/migration/inventory.md`, `wiki/migration/plan.md`, and `wiki/migration/verification.md`.
319
+ - Skips form-only/template legacy files as non-semantic input; `inventory.md` records the skipped source and reason instead of creating review rows or new wiki pages.
320
+ - Writes `wiki/migration/inventory.md`, `wiki/migration/unit-map.md`, `wiki/migration/split-plan.md`, `wiki/migration/coverage.md`, `wiki/migration/plan.md`, `wiki/migration/review.md`, and `wiki/migration/verification.md`.
307
321
  - Writes rewrite inboxes:
308
322
  - `wiki/canonical/migration-inbox.md`
309
323
  - `wiki/decisions/migration-inbox.md`
310
324
  - `wiki/sources/migration-inbox.md`
311
325
  - Adds migration routing to `wiki/startup.md` and `wiki/index.md`.
312
326
 
313
- After migration mode, inspect inboxes and fold legacy content into canonical docs, Decision Packs, ADRs, source summaries, or meta docs. Do not copy legacy markdown files directly into `wiki/canonical/`, `wiki/decisions/`, or `wiki/sources/`; rewrite only the useful project meaning, cite current-project evidence when possible, and keep ambiguous material in the migration inbox or mark it `needs-human-review`.
327
+ After migration mode, inspect inboxes and fold legacy content into canonical docs, Decision Packs, ADRs, source summaries, or meta docs. Minimize information loss while converting useful legacy meaning to the current wiki structure and rules. Legacy files, sections, blocks, and wording may be retained when review confirms each retained unit belongs in the new topic shape and remains current project truth. Do not link to or cite `wiki_legacy*` from the new wiki; cite current-project evidence when possible, and keep ambiguous material in the migration inbox or mark it `needs-human-review`.
328
+
329
+ `wiki/migration/coverage.md` is the unit-level coverage ledger. It accounts for extracted legacy headings, paragraphs, list items, table rows, and code blocks with stable unit IDs. Form-only/template files are excluded before unit extraction and are listed in `inventory.md` instead. Every extracted unit should end as `adopted`, `merged`, `superseded`, `rejected`, `resolved`, or `needs-human-review`; `pending` means the unit is still open. `adopted` and `merged` rows require a new-wiki target under `wiki/canonical/`, `wiki/decisions/`, `wiki/sources/`, or `wiki/meta/`. Deleting an extracted unit row is treated as possible information loss and `--migration-lint` reports it as `migration-unaccounted-unit`.
330
+
331
+ `wiki/migration/unit-map.md` is the generated per-unit classification ledger. `wiki/migration/split-plan.md` groups units by suggested new target file. `--migration-lint` validates these files alongside `coverage.md`: stale or duplicate units, invalid storage/confidence/status values, split count drift, target drift, and old coverage schemas are reported separately from normal lint.
332
+
333
+ When one legacy file maps to multiple target pages, file-level migration inbox status is not enough to close every unit. In that case, update `wiki/migration/coverage.md` unit rows directly; `--review-migration` records that the file-level inbox row was ignored for the mixed-target source. File-level inbox fallback remains available only when all units from the legacy source point to the same target, preserving older migration workflows without masking mixed-page splits.
314
334
 
315
335
  Inbox rows use these statuses:
316
336
 
@@ -326,10 +346,10 @@ Run semantic review sync after LLM or human processing:
326
346
  $PROJECT_LIBRARIAN --review-migration
327
347
  ```
328
348
 
329
- `wiki/migration/verification.md` verifies file coverage: every legacy markdown file should be mapped to a new-wiki migration target. This is not a semantic-completeness proof. Semantic migration is complete only after inbox rows are marked adopted/rejected/resolved and `needs-human-review` is 0.
349
+ `wiki/migration/verification.md` verifies current-batch unit coverage: every extracted legacy meaning unit should be mapped to a new-wiki target and remain accounted for. Semantic migration is complete only after unit coverage or safe inbox rows are marked adopted/rejected/resolved and `needs-human-review` is 0.
330
350
 
331
351
  Human review is not required for every inbox item. LLM may process ordinary rows and close them as adopted/rejected/resolved. Human review is reserved for `needs-human-review`.
332
352
 
333
- Run `$PROJECT_LIBRARIAN --doctor` after migration review. `--quality-check` and `--doctor` report `migration-copy-risk` when a new project wiki document appears to be copied from `wiki_legacy*`, and report `migration-filename-reuse` when a legacy filename is reused and needs rewrite verification.
353
+ Run `$PROJECT_LIBRARIAN --migration-doctor` after migration review. Normal `--quality-check` and `--doctor` intentionally omit migration-only policy/structure signals so accepted migration decisions do not pollute later non-migration document checks. `--migration-quality-check` and `--migration-doctor` report `migration-legacy-reference` as an error when active project truth links to or cites `wiki_legacy*`. They do not warn merely because a new wiki document copies legacy wording, blocks, whole documents, or filenames; those are acceptable when the result follows the current wiki policy and structure. Use `--migration-lint` and `wiki/migration/coverage.md` to prevent information loss.
334
354
 
335
- Do not delete `wiki_legacy` until migration verification passes, semantic review is complete, and migration copy diagnostics are clear.
355
+ Do not delete `wiki_legacy` until migration verification passes, semantic review is complete, and migration policy/structure diagnostics are clear.