project-librarian 0.2.1 → 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.ko.md +245 -93
- package/README.md +174 -76
- package/SKILL.md +15 -10
- package/dist/args.js +11 -2
- package/dist/code-index-file-policy.js +105 -2
- package/dist/code-index.js +77 -59
- package/dist/hooks.js +78 -0
- package/dist/init-project-wiki.js +234 -166
- package/dist/install-skill.js +2 -9
- package/dist/mcp-server.js +449 -0
- package/dist/migration.js +875 -60
- package/dist/modes.js +205 -59
- package/dist/taxonomy.js +193 -0
- package/dist/templates.js +214 -36
- package/dist/wiki-files.js +15 -27
- package/dist/wiki-graph.js +141 -0
- package/package.json +3 -3
- package/README.ja.md +0 -215
- package/README.zh.md +0 -215
package/README.md
CHANGED
|
@@ -5,11 +5,42 @@
|
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://nodejs.org/api/sqlite.html)
|
|
7
7
|
|
|
8
|
-
|
|
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
|
-
|
|
10
|
+
Languages: [English](README.md) | [한국어](README.ko.md)
|
|
11
11
|
|
|
12
|
-
|
|
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,6 +52,7 @@ 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. |
|
|
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. |
|
|
24
56
|
| `.codex/`, `.claude/`, `.cursor/`, and `.gemini/` hooks | Automatic startup context for Codex, Claude Code, Cursor, and Gemini CLI without loading the full wiki. |
|
|
25
57
|
| `GEMINI.md` and `.cursor/rules/` | Gemini CLI and Cursor instruction files that route agents to the same compact wiki-first contract. |
|
|
26
58
|
| `.project-wiki/code-evidence.sqlite` | Regenerable code evidence for files, symbols, imports, routes, ownership, workspace graph, reports, and impact checks. |
|
|
@@ -28,23 +60,61 @@ Project Librarian gives agents two local sources of truth:
|
|
|
28
60
|
|
|
29
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."
|
|
30
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
|
+
|
|
31
65
|
## Benchmark Results
|
|
32
66
|
|
|
33
|
-
|
|
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:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
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
|
|
34
100
|
|
|
35
|
-
|
|
101
|
+
Repositories under test:
|
|
36
102
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| Small | 102,655 total tokens; 101,226 input; 37.15s; 9 command invocations | 176,104 total tokens; 173,733 input; 61.04s; 15 command invocations | +71.55% tokens; +64.33% time; +66.67% commands |
|
|
40
|
-
| Medium | 79,340 total tokens; 78,348 input; 44.28s; 5 command invocations | 165,840 total tokens; 163,856 input; 48.48s; 10 command invocations | +109.02% tokens; +9.5% time; +100% commands |
|
|
41
|
-
| Large | 197,097 total tokens; 195,278 input; 45.87s; 10 command invocations | 183,959 total tokens; 181,897 input; 49.42s; 13 command invocations | -6.67% tokens; +7.72% time; +30% commands |
|
|
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.
|
|
42
105
|
|
|
43
|
-
|
|
106
|
+
Question types (task families):
|
|
44
107
|
|
|
45
|
-
|
|
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.
|
|
46
114
|
|
|
47
|
-
|
|
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:
|
|
48
118
|
|
|
49
119
|
```bash
|
|
50
120
|
npx project-librarian install-skill --scope user --agents all
|
|
@@ -68,11 +138,11 @@ npx project-librarian install-skill --scope project --agents all
|
|
|
68
138
|
| Install only Gemini CLI | `npx project-librarian install-skill --agents gemini` |
|
|
69
139
|
| Preview install output | `npx project-librarian install-skill --scope project --agents all --dry-run` |
|
|
70
140
|
|
|
71
|
-
`--agents` also accepts comma-separated values such as `codex,claude,cursor,gemini`. `all` targets every supported agent
|
|
141
|
+
`--agents` also accepts comma-separated values such as `codex,claude,cursor,gemini`. `all` targets every supported agent. `--scope` accepts `user` or `project`.
|
|
72
142
|
|
|
73
|
-
##
|
|
143
|
+
## Runner Paths
|
|
74
144
|
|
|
75
|
-
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.
|
|
76
146
|
|
|
77
147
|
| Installation | Runner |
|
|
78
148
|
| --- | --- |
|
|
@@ -85,52 +155,41 @@ After installation, agents should run the installed local copy with `node`, not
|
|
|
85
155
|
| User-scoped Cursor skill | `node ~/.cursor/skills/project-librarian/dist/init-project-wiki.js` |
|
|
86
156
|
| User-scoped Gemini skill | `node ~/.gemini/skills/project-librarian/dist/init-project-wiki.js` |
|
|
87
157
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
| Build multiple scopes | `$PROJECT_LIBRARIAN --code-index --code-scope src --code-scope packages/api` |
|
|
124
|
-
| Require incremental update | `$PROJECT_LIBRARIAN --code-index --incremental` |
|
|
125
|
-
| Force a full rebuild | `$PROJECT_LIBRARIAN --code-index --code-index-full` |
|
|
126
|
-
| Use optional Tree-sitter backend | `$PROJECT_LIBRARIAN --code-index --code-parser tree-sitter` |
|
|
127
|
-
| Show cache status | `$PROJECT_LIBRARIAN --code-status` |
|
|
128
|
-
| List indexed files | `$PROJECT_LIBRARIAN --code-files` |
|
|
129
|
-
| Print architecture and ownership report | `$PROJECT_LIBRARIAN --code-report` |
|
|
130
|
-
| Print one report section | `$PROJECT_LIBRARIAN --code-report --code-report-section routes` |
|
|
131
|
-
| Inspect impact evidence | `$PROJECT_LIBRARIAN --code-impact healthHandler` |
|
|
132
|
-
| Search indexed symbols | `$PROJECT_LIBRARIAN --code-search-symbol Auth` |
|
|
133
|
-
| Run conservative read-only SQL | `$PROJECT_LIBRARIAN --code-query "select path from files order by path"` |
|
|
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"` |
|
|
134
193
|
|
|
135
194
|
Only one code evidence mode can run at a time. `--incremental`, `--code-index-full`, and `--code-parser` are valid only with `--code-index`.
|
|
136
195
|
|
|
@@ -169,21 +228,59 @@ Wiki directories:
|
|
|
169
228
|
- `wiki/sources/`
|
|
170
229
|
- `wiki/migration/`
|
|
171
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
|
+
|
|
172
245
|
Disposable code evidence cache:
|
|
173
246
|
|
|
174
247
|
- `.project-wiki/code-evidence.sqlite`
|
|
175
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
|
+
|
|
176
261
|
## How It Works
|
|
177
262
|
|
|
178
263
|
1. Bootstrap creates a preservation-first wiki structure and marker-bounded agent instruction sections.
|
|
179
264
|
2. Session-start hooks inject only `wiki/startup.md` and `wiki/index.md`, with character budgets.
|
|
180
|
-
3.
|
|
181
|
-
4.
|
|
182
|
-
5.
|
|
183
|
-
6. `--
|
|
184
|
-
7.
|
|
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.
|
|
185
282
|
|
|
186
|
-
|
|
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*`.
|
|
187
284
|
|
|
188
285
|
## Language Support Matrix
|
|
189
286
|
|
|
@@ -208,34 +305,35 @@ Recognized but inventory-only extensions include `.rb`, `.vue`, and `.css`. Conf
|
|
|
208
305
|
|
|
209
306
|
## CLI Reference
|
|
210
307
|
|
|
211
|
-
Use the local runner for
|
|
308
|
+
Use the resolved local runner for automation or direct CLI execution:
|
|
212
309
|
|
|
213
310
|
```bash
|
|
214
|
-
|
|
215
|
-
|
|
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]
|
|
216
313
|
```
|
|
217
314
|
|
|
218
315
|
Important options:
|
|
219
316
|
|
|
220
317
|
| Option | Purpose |
|
|
221
318
|
| --- | --- |
|
|
222
|
-
| `--migrate`, `--adopt-existing` | Preserve an existing wiki as `wiki_legacy
|
|
319
|
+
| `--migrate`, `--adopt-existing` | Preserve an existing wiki as `wiki_legacy*`, create migration inboxes, and generate unit-map/split-plan/coverage review files. |
|
|
223
320
|
| `--lint` | Validate generated setup without editing files. |
|
|
224
|
-
| `--link-check` | Report broken wiki links, duplicate routes, and
|
|
321
|
+
| `--link-check` | Report broken wiki links, duplicate routes, orphan pages, and pages the startup router cannot reach within the depth budget. |
|
|
225
322
|
| `--quality-check` | Report stale, conflicting, and low-quality wiki document signals. |
|
|
226
323
|
| `--doctor` | Run lint, link-check, and quality-check together. |
|
|
227
324
|
| `--doctor --fix` | Safely refresh generated index routing before diagnostics. |
|
|
228
|
-
| `--migration-lint` | Validate migration review scaffolding separately from normal lint. |
|
|
325
|
+
| `--migration-lint` | Validate migration coverage, unit-map, split-plan, and review scaffolding separately from normal lint. |
|
|
229
326
|
| `--migration-quality-check` | Report migration policy/structure signals separately from normal quality-check. |
|
|
230
327
|
| `--migration-doctor` | Run migration-lint and migration-quality-check together. |
|
|
231
|
-
| `--query <terms>` | Search wiki paths, metadata, titles, and bodies. |
|
|
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. |
|
|
232
330
|
| `--refresh-index` | Update generated auto-discovered wiki routing. |
|
|
233
331
|
| `--capture-inbox --title <title> --content <content>` | Append a candidate note to the wiki inbox. |
|
|
234
332
|
| `--issue-draft --issue-title <title>` | Print a read-only GitHub issue body draft for problems or side effects. |
|
|
235
333
|
| `--issue-create --issue-title <title>` | Create a GitHub issue through `gh` after explicit user approval. |
|
|
236
334
|
| `--glossary-init` | Create and route the optional glossary page. |
|
|
237
335
|
| `--prune-check` | Report active pages with stale or unresolved lifecycle signals. |
|
|
238
|
-
| `--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. |
|
|
239
337
|
| `--no-git-config` | Install hook files without changing `git core.hooksPath`. |
|
|
240
338
|
| `--code-index` | Build the disposable code evidence index. |
|
|
241
339
|
| `--code-report` | Print architecture and ownership summaries from the evidence index. |
|
package/SKILL.md
CHANGED
|
@@ -121,7 +121,7 @@ $PROJECT_LIBRARIAN --lint
|
|
|
121
121
|
|
|
122
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.
|
|
123
123
|
|
|
124
|
-
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`.
|
|
125
125
|
|
|
126
126
|
## Code-Informed Canonicalization
|
|
127
127
|
|
|
@@ -200,8 +200,8 @@ Execution contract:
|
|
|
200
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.
|
|
201
201
|
- Code-backed current project behavior, features, policies, constraints, terminology, domain rules, and operational facts belong under `wiki/canonical/`.
|
|
202
202
|
- Important design rationale or tradeoffs inferred from code may belong under `wiki/decisions/` when they meet the decision policy.
|
|
203
|
-
- Unclear, conflicting, or low-confidence interpretations belong in `wiki/inbox/` or
|
|
204
|
-
4. Do not use fixed canonical filenames
|
|
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.
|
|
205
205
|
5. Split large subjects into focused documents when a single file would force agents to read unrelated content.
|
|
206
206
|
6. Cite concrete evidence with repository-relative paths and distinguish code-proven facts from inference.
|
|
207
207
|
7. Update `wiki/startup.md` and `wiki/index.md` only with compact routing hints, not large code summaries.
|
|
@@ -226,11 +226,11 @@ It installs:
|
|
|
226
226
|
- `.gemini/hooks/wiki-session-start.js` compact startup context injector for Gemini CLI.
|
|
227
227
|
- `wiki/startup.md` compact session-start context.
|
|
228
228
|
- `wiki/index.md` router with read/update/token-budget hints.
|
|
229
|
-
- `wiki/canonical/` project-current-truth
|
|
229
|
+
- `wiki/canonical/` directory for project-current-truth documents, created only when real content exists.
|
|
230
230
|
- Optional `wiki/canonical/glossary.md` project terminology contract when `--glossary-init` is used.
|
|
231
|
-
- `wiki/decisions/` project-decision
|
|
231
|
+
- `wiki/decisions/` project-decision directory and lightweight decision ledgers.
|
|
232
232
|
- `wiki/meta/` wiki operating rules, project decision policy, and wiki-operations Decision Pack.
|
|
233
|
-
- `wiki/sources/` source summary
|
|
233
|
+
- `wiki/sources/` source summary documents.
|
|
234
234
|
|
|
235
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.
|
|
236
236
|
|
|
@@ -277,7 +277,7 @@ It appends these trailers when they are missing:
|
|
|
277
277
|
|
|
278
278
|
Do not hand-write wiki trailers unless the hook is unavailable or the generated value needs correction.
|
|
279
279
|
|
|
280
|
-
`--lint` verifies the
|
|
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.
|
|
281
281
|
|
|
282
282
|
## Glossary Mode
|
|
283
283
|
|
|
@@ -316,7 +316,8 @@ Migration mode is a reset-and-restructure flow:
|
|
|
316
316
|
- If `./wiki_legacy` already exists, preserves both by using a timestamped `wiki_legacy_...` directory for the current wiki.
|
|
317
317
|
- Creates a fresh `./wiki` using the current standard rules.
|
|
318
318
|
- Scans markdown files under the legacy wiki directory.
|
|
319
|
-
-
|
|
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`.
|
|
320
321
|
- Writes rewrite inboxes:
|
|
321
322
|
- `wiki/canonical/migration-inbox.md`
|
|
322
323
|
- `wiki/decisions/migration-inbox.md`
|
|
@@ -325,7 +326,11 @@ Migration mode is a reset-and-restructure flow:
|
|
|
325
326
|
|
|
326
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`.
|
|
327
328
|
|
|
328
|
-
`wiki/migration/coverage.md` is the unit-level coverage ledger. It accounts for legacy headings, paragraphs, list items, table rows, and code blocks with stable unit IDs. Every 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
|
|
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.
|
|
329
334
|
|
|
330
335
|
Inbox rows use these statuses:
|
|
331
336
|
|
|
@@ -341,7 +346,7 @@ Run semantic review sync after LLM or human processing:
|
|
|
341
346
|
$PROJECT_LIBRARIAN --review-migration
|
|
342
347
|
```
|
|
343
348
|
|
|
344
|
-
`wiki/migration/verification.md` verifies
|
|
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.
|
|
345
350
|
|
|
346
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`.
|
|
347
352
|
|
package/dist/args.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.captureContent = exports.captureTitle = exports.codeIndexScopes = exports.codeParser = exports.codeIndexOutput = exports.codeSearchSymbol = exports.codeReportSection = exports.codeQuerySql = exports.codeImpactTarget = exports.wikiImpactTarget = exports.wikiImpactMode = exports.queryTerm = exports.codeSearchSymbolMode = exports.codeQueryMode = exports.codeImpactMode = exports.codeParserMode = exports.codeFilesMode = exports.codeStatusMode = exports.codeReportMode = exports.codeIndexFullMode = exports.codeIndexIncrementalMode = exports.codeIndexMode = exports.acknowledgeSmallRepoMode = exports.noGitConfigMode = exports.reviewMigrationMode = exports.pruneCheckMode = exports.captureInboxMode = exports.refreshIndexMode = exports.issueDraftMode = exports.issueCreateMode = exports.glossaryMode = exports.fixMode = exports.doctorMode = exports.qualityCheckMode = exports.linkCheckMode = exports.migrationQualityCheckMode = exports.migrationLintMode = exports.migrationDoctorMode = exports.lintMode = exports.migrateMode = exports.missingValueOptions = exports.unexpectedValueOptions = exports.unknownOptions = exports.args = exports.commandArgs = exports.command = exports.unknownCommand = exports.helpMode = exports.parsedArgs = exports.rawArgs = void 0;
|
|
4
|
+
exports.issueDraftTitle = exports.issueBodyFile = exports.captureCategory = void 0;
|
|
4
5
|
exports.parseArgs = parseArgs;
|
|
5
6
|
exports.argValue = argValue;
|
|
6
7
|
exports.argValues = argValues;
|
|
7
8
|
exports.rawArgs = process.argv.slice(2);
|
|
8
|
-
const knownCommands = new Set(["init", "install-skill"]);
|
|
9
|
+
const knownCommands = new Set(["init", "install-skill", "mcp"]);
|
|
9
10
|
const flagsWithoutValues = new Set([
|
|
11
|
+
"--acknowledge-small-repo",
|
|
10
12
|
"--adopt-existing",
|
|
11
13
|
"--capture-inbox",
|
|
12
14
|
"--code-evidence-files",
|
|
@@ -65,6 +67,7 @@ const flagsWithValues = new Set([
|
|
|
65
67
|
"--query",
|
|
66
68
|
"--scope",
|
|
67
69
|
"--title",
|
|
70
|
+
"--wiki-impact",
|
|
68
71
|
]);
|
|
69
72
|
const knownFlags = new Set([...flagsWithoutValues, ...flagsWithValues, "--help", "-h"]);
|
|
70
73
|
function flagName(arg) {
|
|
@@ -130,6 +133,7 @@ function parseArgs(argv) {
|
|
|
130
133
|
const codeQuerySql = argValue("--code-query") || argValue("--code-evidence-query");
|
|
131
134
|
const codeSearchSymbol = argValue("--code-search-symbol") || argValue("--code-evidence-symbol");
|
|
132
135
|
return {
|
|
136
|
+
acknowledgeSmallRepoMode: args.has("--acknowledge-small-repo"),
|
|
133
137
|
args,
|
|
134
138
|
captureCategory: argValue("--category") || "project-candidate",
|
|
135
139
|
captureContent: argValue("--content"),
|
|
@@ -185,6 +189,8 @@ function parseArgs(argv) {
|
|
|
185
189
|
.filter((arg) => arg.startsWith("-"))
|
|
186
190
|
.map(flagName)
|
|
187
191
|
.filter((arg) => !knownFlags.has(arg)))),
|
|
192
|
+
wikiImpactMode: hasFlag("--wiki-impact"),
|
|
193
|
+
wikiImpactTarget: argValue("--wiki-impact"),
|
|
188
194
|
};
|
|
189
195
|
}
|
|
190
196
|
exports.parsedArgs = parseArgs(exports.rawArgs);
|
|
@@ -213,6 +219,7 @@ exports.captureInboxMode = exports.parsedArgs.captureInboxMode;
|
|
|
213
219
|
exports.pruneCheckMode = exports.parsedArgs.pruneCheckMode;
|
|
214
220
|
exports.reviewMigrationMode = exports.parsedArgs.reviewMigrationMode;
|
|
215
221
|
exports.noGitConfigMode = exports.parsedArgs.noGitConfigMode;
|
|
222
|
+
exports.acknowledgeSmallRepoMode = exports.parsedArgs.acknowledgeSmallRepoMode;
|
|
216
223
|
exports.codeIndexMode = exports.parsedArgs.codeIndexMode;
|
|
217
224
|
exports.codeIndexIncrementalMode = exports.parsedArgs.codeIndexIncrementalMode;
|
|
218
225
|
exports.codeIndexFullMode = exports.parsedArgs.codeIndexFullMode;
|
|
@@ -230,6 +237,8 @@ function argValues(name) {
|
|
|
230
237
|
return argValuesFrom(exports.commandArgs, name);
|
|
231
238
|
}
|
|
232
239
|
exports.queryTerm = exports.parsedArgs.queryTerm;
|
|
240
|
+
exports.wikiImpactMode = exports.parsedArgs.wikiImpactMode;
|
|
241
|
+
exports.wikiImpactTarget = exports.parsedArgs.wikiImpactTarget;
|
|
233
242
|
exports.codeImpactTarget = exports.parsedArgs.codeImpactTarget;
|
|
234
243
|
exports.codeQuerySql = exports.parsedArgs.codeQuerySql;
|
|
235
244
|
exports.codeReportSection = exports.parsedArgs.codeReportSection;
|