llm-wiki-kit 0.1.4 → 0.1.6

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
@@ -47,6 +47,7 @@ llm-wiki/
47
47
  ├── raw/
48
48
  ├── wiki/
49
49
  │ ├── index.md
50
+ │ ├── memory.md
50
51
  │ ├── log.md
51
52
  │ ├── sources/
52
53
  │ ├── concepts/
@@ -60,7 +61,7 @@ llm-wiki/
60
61
  └── procedures/
61
62
  ```
62
63
 
63
- `raw/` is the immutable or redacted evidence layer. `wiki/` is the LLM-maintained knowledge layer. `outputs/` stores live Q&A and requested reports. `.kit-state.json` records which runtime version last applied managed templates to the project. Text written by the kit is normalized to NFC so Korean filenames and content stay composed.
64
+ `raw/` is the immutable or redacted evidence layer. `wiki/` is the LLM-maintained knowledge layer. `wiki/memory.md` is the short hot index injected into hook context before deeper search results. `outputs/` stores live Q&A and requested reports. `.kit-state.json` records which runtime version last applied managed templates to the project. Text written by the kit is normalized to NFC so Korean filenames and content stay composed.
64
65
 
65
66
  ## Normal Use
66
67
 
@@ -68,7 +69,7 @@ Use Claude Code or Codex normally.
68
69
 
69
70
  The installed hooks:
70
71
 
71
- - inject relevant wiki context at session start and prompt submit time
72
+ - inject `wiki/memory.md`, `wiki/index.md`, and relevant wiki context at session start and prompt submit time
72
73
  - record redacted turn summaries
73
74
  - capture decision points, debugging findings, changed files, and verification notes
74
75
  - allow tool calls to proceed without secret/PII-based hook blocking
@@ -83,12 +84,16 @@ If you need to think about saving every answer manually, the setup has failed.
83
84
  ```bash
84
85
  llm-wiki install --workspace /path/to/project --profile standard
85
86
  llm-wiki doctor
87
+ llm-wiki version
86
88
  llm-wiki status --workspace /path/to/project
87
89
  llm-wiki projects --workspace /path/to/search-root
88
90
  llm-wiki update --check --workspace /path/to/project
89
91
  llm-wiki update --all --workspace /path/to/search-root
90
92
  llm-wiki update --dry-run --workspace /path/to/project
91
93
  llm-wiki update --workspace /path/to/project
94
+ llm-wiki context "search phrase" --workspace /path/to/project
95
+ llm-wiki lint --workspace /path/to/project
96
+ llm-wiki consolidate --workspace /path/to/project
92
97
  llm-wiki uninstall
93
98
  ```
94
99
 
@@ -98,10 +103,34 @@ llm-wiki uninstall
98
103
 
99
104
  `llm-wiki update` upgrades the global npm package, reinstalls the hook entries, and patches only managed project files such as the marked `AGENTS.md` policy block and generated `llm-wiki/AGENTS.md`/procedure files. Existing wiki content is not overwritten.
100
105
 
106
+ `llm-wiki context "<query>"` prints the same layered context used by hooks: the short `memory.md` excerpt, the `index.md` excerpt, and MiniSearch + wikilink-expanded page hits. Use `--limit 1..50` to bound hits and `--no-expand` to disable one-hop link expansion. Context output is redacted before printing; if MiniSearch is unavailable in a source checkout, the command falls back to substring search.
107
+
108
+ `llm-wiki lint` checks wiki health: missing core files, invalid frontmatter, broken wikilinks, broken relative Markdown links, unsafe `source_ids`, secret-like content, missing source files, duplicate aliases/titles, stale pages, and orphan candidates. Broken links, unsafe source IDs, and secret-like content are errors; metadata and discoverability gaps are warnings.
109
+
110
+ `llm-wiki consolidate` refreshes only generated marker blocks in `wiki/memory.md` and `wiki/index.md`. Handwritten notes outside those blocks are preserved. Runtime update creates `wiki/memory.md` if missing, but does not overwrite an existing memory page. Default `query`/`context`/`session-log` pages are not promoted into generated maps unless they are explicitly marked `memory_type: semantic` or `procedural` with `importance >= 4`.
111
+
101
112
  `llm-wiki projects --workspace /apps` lists project roots that already have `llm-wiki-kit` state and shows the update commands to run. `llm-wiki update --all --workspace /apps` updates the global runtime once, then reapplies managed templates across every discovered project root under `/apps`.
102
113
 
103
114
  After a plain `npm install -g llm-wiki-kit@latest`, installed hooks point at the same global binary path. The next `SessionStart`/`InstructionsLoaded` hook automatically reapplies safe managed template updates for the active project root. This only patches generated/managed files and does not overwrite wiki content.
104
115
 
116
+ On PCs that use nvm or user-local npm, prefer the non-sudo global install and make sure the `llm-wiki` command resolves to that npm package:
117
+
118
+ ```bash
119
+ npm install -g llm-wiki-kit@latest --registry=https://registry.npmjs.org/ --prefer-online
120
+ which -a llm-wiki
121
+ readlink -f "$(command -v llm-wiki)"
122
+ llm-wiki version
123
+ llm-wiki status
124
+ ```
125
+
126
+ If `which -a llm-wiki` shows a stale `~/.local/bin/llm-wiki` before the nvm/npm global binary, remove only that file, not the whole `~/.local/bin` directory:
127
+
128
+ ```bash
129
+ rm -f "$HOME/.local/bin/llm-wiki"
130
+ hash -r
131
+ llm-wiki version
132
+ ```
133
+
105
134
  Real `update --check` and `update` require the package to exist in the npm registry. Before publication, use local tarball installs for smoke testing and fake npm in automated tests.
106
135
 
107
136
  The hook subcommands are internal runtime targets:
@@ -126,6 +155,7 @@ Source checkout installs are supported for development:
126
155
  ```bash
127
156
  git clone <your-git-url>/llm-wiki-kit.git /apps/llm-wiki-kit
128
157
  cd /apps/llm-wiki-kit
158
+ npm install
129
159
  ./install.sh --workspace /apps --profile standard
130
160
  node --test
131
161
  ```
package/docs/concepts.md CHANGED
@@ -8,17 +8,18 @@ raw sources -> wiki -> schema/rules
8
8
 
9
9
  - `raw/` is evidence. It is immutable unless a hook appends a redacted event envelope.
10
10
  - `wiki/` is the living Markdown knowledge layer maintained by the agent.
11
+ - `wiki/memory.md` is the compact hot index that keeps the most reusable current facts close to the context window.
11
12
  - `AGENTS.md`, `CLAUDE.md`, and `procedures/` are the schema/rules layer.
12
13
  - `.kit-state.json` records which managed rules/templates were applied by which runtime version.
13
14
 
14
15
  The important behavior is a loop:
15
16
 
16
17
  1. A Claude Code or Codex session starts.
17
- 2. Relevant wiki context is injected automatically.
18
+ 2. `memory.md`, `index.md`, and relevant wiki context are injected automatically.
18
19
  3. The user works normally.
19
20
  4. Hooks gather redacted prompt/tool/result summaries.
20
21
  5. At stop/session end, useful knowledge is written back to Markdown.
21
- 6. Future sessions start from the improved wiki.
22
+ 6. Future sessions start from the improved wiki instead of relying on long chat history.
22
23
 
23
24
  The kit is a template/runtime repository. It must not centralize project wiki contents.
24
25
 
@@ -26,4 +27,13 @@ Runtime updates and project knowledge are separate:
26
27
 
27
28
  - npm updates replace the runtime package and hook targets.
28
29
  - project patching updates only managed policy blocks and generated procedure files.
30
+ - `memory.md` is created when missing, then treated as project-owned content.
29
31
  - curated wiki pages remain project-owned content and are not overwritten by runtime updates.
32
+
33
+ The maintenance loop is intentionally layered:
34
+
35
+ - `memory.md`: short hot index for current durable facts.
36
+ - `index.md`: broad navigation map.
37
+ - MiniSearch + wikilinks: retrieval over the rest of `wiki/**/*.md`, with substring fallback when MiniSearch is not installed in a source checkout.
38
+ - `lint`: finds broken links, stale pages, duplicates, and metadata gaps.
39
+ - `consolidate`: refreshes generated blocks in `memory.md` and `index.md` while preserving handwritten notes and keeping default query/context/session pages out of the durable generated maps.
@@ -40,6 +40,8 @@ when no project `CLAUDE.md` exists. Existing `CLAUDE.md` files are not overwritt
40
40
 
41
41
  The hook records redacted turn summaries but does not deny tool calls only because an input looks sensitive.
42
42
 
43
+ At `SessionStart`/`InstructionsLoaded`, the hook injects `llm-wiki/wiki/memory.md`, `llm-wiki/wiki/index.md`, recent log context, and operating rules. At `UserPromptSubmit`, it searches wiki pages with MiniSearch or substring fallback, expands one-hop wikilinks, redacts context fields, and injects the smallest useful context set.
44
+
43
45
  After installation or update, run:
44
46
 
45
47
  ```bash
@@ -29,8 +29,8 @@ Handled events:
29
29
 
30
30
  Expected behavior:
31
31
 
32
- - `SessionStart` injects `llm-wiki/wiki/index.md`, recent log context, and operating rules.
33
- - `UserPromptSubmit` searches project wiki pages and injects the smallest useful context set.
32
+ - `SessionStart` injects `llm-wiki/wiki/memory.md`, `llm-wiki/wiki/index.md`, recent log context, and operating rules.
33
+ - `UserPromptSubmit` searches project wiki pages with MiniSearch or substring fallback, expands one-hop wikilinks, redacts context fields, and injects the smallest useful context set.
34
34
  - `PreToolUse` records redacted tool summaries without blocking tool calls.
35
35
  - `PostToolUse` records redacted tool summaries in a turn buffer.
36
36
  - `Stop` writes live Q&A and durable wiki pages.
@@ -47,9 +47,12 @@ The installer:
47
47
  - bootstraps the workspace `llm-wiki/`
48
48
  - records managed template state in `llm-wiki/.kit-state.json`
49
49
 
50
+ Use `llm-wiki install --no-project` only when you want hook/bin installation without bootstrapping the current workspace as a project.
51
+
50
52
  Source checkout installs are still useful for development:
51
53
 
52
54
  ```bash
55
+ npm install
53
56
  ./install.sh --workspace /apps --profile standard
54
57
  ```
55
58
 
@@ -66,12 +69,16 @@ Do not delete a project `llm-wiki/` tree to reinstall the runtime. `llm-wiki uni
66
69
  ## Status And Updates
67
70
 
68
71
  ```bash
72
+ llm-wiki version
69
73
  llm-wiki status --workspace /path/to/project
70
74
  llm-wiki projects --workspace /path/to/search-root
71
75
  llm-wiki update --check --workspace /path/to/project
72
76
  llm-wiki update --all --workspace /path/to/search-root
73
77
  llm-wiki update --dry-run --workspace /path/to/project
74
78
  llm-wiki update --workspace /path/to/project
79
+ llm-wiki context "search phrase" --workspace /path/to/project
80
+ llm-wiki lint --workspace /path/to/project
81
+ llm-wiki consolidate --workspace /path/to/project
75
82
  ```
76
83
 
77
84
  `status` is offline and answers whether the local installation is internally consistent:
@@ -97,12 +104,94 @@ llm-wiki update --workspace /path/to/project
97
104
 
98
105
  After a plain `npm install -g llm-wiki-kit@latest`, existing hooks keep pointing at the global package path. On the next `SessionStart` or `InstructionsLoaded`, the runtime automatically reapplies safe managed template updates for the active project root.
99
106
 
107
+ ## Context And Wiki Maintenance
108
+
109
+ `llm-wiki context "<query>"` is the manual form of hook context injection. It reads:
110
+
111
+ - `llm-wiki/wiki/memory.md` as the short hot index
112
+ - `llm-wiki/wiki/index.md` as the navigation map
113
+ - MiniSearch results from `llm-wiki/wiki/**/*.md`, with substring fallback when MiniSearch is unavailable
114
+ - one-hop wikilink neighbors for the strongest matches
115
+ - redacted output fields for query text, memory/index/log excerpts, hit paths, titles, snippets, matched terms, and link expansion metadata
116
+
117
+ Use it when you want to inspect what the next agent turn should see:
118
+
119
+ ```bash
120
+ llm-wiki context "auth architecture" --workspace /path/to/project
121
+ llm-wiki context "auth architecture" --workspace /path/to/project --json
122
+ llm-wiki context "auth architecture" --workspace /path/to/project --limit 8 --no-expand
123
+ ```
124
+
125
+ `llm-wiki lint` checks Markdown wiki health without modifying files:
126
+
127
+ - missing `index.md`, `log.md`, or `memory.md`
128
+ - missing or invalid frontmatter
129
+ - broken or ambiguous `[[wikilinks]]`
130
+ - broken relative Markdown links, including non-Markdown local files
131
+ - invalid path-escaping or protocol-style `source_ids`
132
+ - missing source files referenced by valid `source_ids`
133
+ - secret-like content patterns such as tokens, password assignments, bearer credentials, and private keys
134
+ - duplicate aliases or titles
135
+ - stale pages and orphan candidates
136
+
137
+ Broken links, invalid source IDs, and secret-like content are errors and return exit code 1. Metadata and discoverability gaps are warnings.
138
+
139
+ `llm-wiki consolidate` performs conservative generated-block maintenance:
140
+
141
+ - refreshes the generated block inside `wiki/memory.md`
142
+ - refreshes the generated block inside `wiki/index.md`
143
+ - excludes default `query`, `context`, and `session-log` pages from generated maps unless they are explicitly durable (`memory_type: semantic` or `procedural`, `importance >= 4`)
144
+ - skips malformed generated marker blocks instead of overwriting them
145
+ - preserves handwritten content outside marker blocks
146
+ - appends a log entry when files change
147
+ - supports `--dry-run`
148
+
149
+ Run `consolidate` after meaningful wiki growth, not after every small turn.
150
+
151
+ ## Updating User-Local Or nvm Installs
152
+
153
+ When Node is managed by nvm, update as the normal user instead of using `sudo`. `sudo npm install -g` writes to root's npm environment and may also fail behind a proxy/TLS-inspection network.
154
+
155
+ ```bash
156
+ npm install -g llm-wiki-kit@latest --registry=https://registry.npmjs.org/ --prefer-online
157
+ llm-wiki version
158
+ llm-wiki status --workspace /path/to/project
159
+ ```
160
+
161
+ If `npm install -g` reports success but `llm-wiki` still prints old help output, inspect the command resolution:
162
+
163
+ ```bash
164
+ which -a llm-wiki
165
+ readlink -f "$(command -v llm-wiki)"
166
+ npm root -g
167
+ node "$(npm root -g)/llm-wiki-kit/bin/llm-wiki.js" version
168
+ ```
169
+
170
+ When `which -a llm-wiki` shows `~/.local/bin/llm-wiki` before the nvm global binary, remove only that stale command file:
171
+
172
+ ```bash
173
+ rm -f "$HOME/.local/bin/llm-wiki"
174
+ hash -r
175
+ llm-wiki version
176
+ ```
177
+
178
+ Do not delete the whole `~/.local/bin` directory. It may contain unrelated user tools.
179
+
180
+ Use package-name-only uninstall syntax:
181
+
182
+ ```bash
183
+ npm uninstall -g llm-wiki-kit
184
+ ```
185
+
186
+ `npm uninstall -g llm-wiki-kit@latest` is not the right form and does not remove source checkouts or stale manually-created shims.
187
+
100
188
  Managed project files are conservative:
101
189
 
102
190
  - root `AGENTS.md` is patched only inside the `llm-wiki-kit` marker block
103
- - `llm-wiki/AGENTS.md` is replaced only when it is generated by the kit
104
- - generated procedures are replaced only when their recorded hash still matches or their content is a known generated template
105
- - `llm-wiki/wiki/index.md` and existing wiki pages are not overwritten
191
+ - `llm-wiki/AGENTS.md` is replaced only when its recorded hash still matches or the whole file exactly matches the current generated template
192
+ - generated procedures are replaced only when their recorded hash still matches or the whole file exactly matches the current generated template
193
+ - `llm-wiki/wiki/memory.md` is created if missing but never overwritten by template update once it exists
194
+ - `llm-wiki/wiki/index.md` and existing wiki pages are not overwritten by runtime update; `llm-wiki consolidate` updates only its generated marker block
106
195
 
107
196
  Real registry checks require `llm-wiki-kit` to be published to npm. Before publication, `llm-wiki update --check` returns npm 404. Use fake npm in tests or local tarball install for server smoke checks.
108
197
 
@@ -10,9 +10,11 @@ Important conclusions:
10
10
  - The durable pattern is `raw sources -> wiki -> schema`.
11
11
  - `raw/` and `wiki/` must not be mixed.
12
12
  - `index.md` should be a small navigation surface.
13
+ - `memory.md` should be an even smaller hot index for the facts most likely to matter in the next turn.
13
14
  - `log.md` should be append-only.
14
15
  - Good answers should be written back into the wiki instead of remaining in chat history.
15
16
  - Duplicate and stale pages are major failure modes.
16
17
  - Full automation without human review is risky for large imports or high-stakes decisions.
17
18
  - Obsidian, Graphify, MCP, and RAG can be useful extensions, but v1 must work with plain Markdown and hooks.
18
-
19
+ - Retrieval should combine lexical search with explicit Markdown links before adding heavier external infrastructure.
20
+ - Consolidation should be conservative: update generated blocks and navigation surfaces, but preserve human/agent-written page bodies.
package/docs/security.md CHANGED
@@ -11,4 +11,6 @@ Before writing durable summaries, the runtime redacts authentication values such
11
11
  - private key blocks
12
12
  - bearer credentials
13
13
 
14
+ Manual and hook context output also runs through redaction before returning excerpts or search hits. `llm-wiki lint` reports remaining secret-like wiki content as an error so it can be removed or rewritten before it becomes reusable project memory.
15
+
14
16
  Hook payloads are stored as small event envelopes, not full raw transcripts. Full transcript capture is intentionally not implemented as a default. If a project needs it, add a project-local policy and a redaction path first.
@@ -71,6 +71,54 @@ sudo npm install -g llm-wiki-kit@latest
71
71
 
72
72
  If the proxy performs TLS inspection, install the organization's CA and set `cafile` instead of disabling TLS verification. As a temporary diagnostic only, `sudo npm config set strict-ssl false` can confirm that the failure is CA-related, but do not keep that setting in production.
73
73
 
74
+ ## npm install -g Succeeds But llm-wiki Is Still Old
75
+
76
+ If `npm install -g llm-wiki-kit@latest` succeeds but `llm-wiki --help` does not show newer commands such as `projects`, `context`, `lint`, or `consolidate`, the shell is probably executing an older source checkout or stale shim before the npm global binary.
77
+
78
+ Confirm what is actually running:
79
+
80
+ ```bash
81
+ which -a llm-wiki
82
+ readlink -f "$(command -v llm-wiki)"
83
+ npm ls -g llm-wiki-kit --depth=0
84
+ npm root -g
85
+ node "$(npm root -g)/llm-wiki-kit/bin/llm-wiki.js" version
86
+ ```
87
+
88
+ If the direct `node "$(npm root -g)/llm-wiki-kit/bin/llm-wiki.js" version` command prints the latest version but plain `llm-wiki` is old, fix `PATH` or replace the stale shim:
89
+
90
+ ```bash
91
+ mkdir -p "$HOME/.local/bin"
92
+ ln -sfn "$(npm root -g)/llm-wiki-kit/bin/llm-wiki.js" "$HOME/.local/bin/llm-wiki"
93
+ export PATH="$HOME/.local/bin:$PATH"
94
+ hash -r
95
+ llm-wiki status
96
+ ```
97
+
98
+ If `readlink -f "$(command -v llm-wiki)"` points at a repository checkout such as `/mnt/d/dev_proj/llm-wiki-kit/bin/llm-wiki.js`, `npm install -g` is not updating that checkout. Either switch the shim to the npm package as above, or update the checkout itself with `git pull` and run it intentionally as source.
99
+
100
+ If `which -a llm-wiki` shows both `~/.local/bin/llm-wiki` and an nvm path such as `~/.nvm/versions/node/v20.20.2/bin/llm-wiki`, the `~/.local/bin` entry usually wins because it appears earlier on `PATH`. If the `~/.local/bin/llm-wiki` file is stale, remove only that file and let the nvm npm global command take over:
101
+
102
+ ```bash
103
+ rm -f "$HOME/.local/bin/llm-wiki"
104
+ hash -r
105
+ which -a llm-wiki
106
+ readlink -f "$(command -v llm-wiki)"
107
+ llm-wiki version
108
+ llm-wiki status
109
+ ```
110
+
111
+ Do not remove the entire `~/.local/bin` directory; it may contain unrelated commands. If the nvm command is missing after removing the stale file, reinstall the package in the active nvm Node version:
112
+
113
+ ```bash
114
+ npm uninstall -g llm-wiki-kit
115
+ npm install -g llm-wiki-kit@latest --registry=https://registry.npmjs.org/ --prefer-online
116
+ hash -r
117
+ llm-wiki version
118
+ ```
119
+
120
+ Use `npm uninstall -g llm-wiki-kit` with the package name only. `npm uninstall -g llm-wiki-kit@latest` is not the correct uninstall syntax and does not remove source checkouts or manually-created command shims.
121
+
74
122
  ## npm install -g Fails With EACCES
75
123
 
76
124
  If npm tries to write under `/usr` and fails with `EACCES`, use sudo when the server policy allows system-wide global packages:
@@ -127,7 +175,14 @@ The hook does not block tool calls only because inputs look sensitive. Durable s
127
175
  Run a manual review:
128
176
 
129
177
  ```bash
178
+ llm-wiki lint --workspace /path/to/project
130
179
  rg -n "title:|aliases:|source_ids:" llm-wiki/wiki
131
180
  ```
132
181
 
133
182
  Prefer merging duplicates into existing pages and preserving contradictions in an `Open Questions` section.
183
+
184
+ After merging or adding durable pages, refresh generated navigation blocks:
185
+
186
+ ```bash
187
+ llm-wiki consolidate --workspace /path/to/project
188
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-wiki-kit",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Hook-first living LLM Wiki runtime for Codex and Claude Code.",
5
5
  "type": "module",
6
6
  "files": [
@@ -20,6 +20,9 @@
20
20
  "doctor": "node bin/llm-wiki.js doctor",
21
21
  "status": "node bin/llm-wiki.js status"
22
22
  },
23
+ "dependencies": {
24
+ "minisearch": "^7.2.0"
25
+ },
23
26
  "engines": {
24
27
  "node": ">=20"
25
28
  },
package/src/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { resolve } from 'path';
2
+ import { formatConsolidateResult, runConsolidate } from './consolidate.js';
2
3
  import { handleHook } from './hook.js';
3
4
  import { install, status, uninstall } from './install.js';
4
5
  import { bootstrapProject } from './project.js';
@@ -7,18 +8,28 @@ import { commandForProject, knownProjectRoots } from './projects.js';
7
8
  import { formatDoctor, runDoctor } from './doctor.js';
8
9
  import { migrate } from './migrate.js';
9
10
  import { postUpdate, update } from './update.js';
11
+ import { buildContextPack, formatContextPack } from './wiki-search.js';
12
+ import { formatLintResult, runLint } from './wiki-lint.js';
10
13
 
11
14
  function parseOptions(args) {
12
15
  const options = {};
13
16
  const rest = [];
17
+ const optionValue = (name, index) => {
18
+ const value = args[index + 1];
19
+ if (!value || value.startsWith('--')) throw new Error(`${name} requires a value`);
20
+ return value;
21
+ };
14
22
  for (let i = 0; i < args.length; i += 1) {
15
23
  const arg = args[i];
16
24
  if (arg === '--workspace' || arg === '--cwd') {
17
- options.workspace = args[++i];
25
+ options.workspace = optionValue(arg, i);
26
+ i += 1;
18
27
  } else if (arg === '--profile') {
19
- options.profile = args[++i];
28
+ options.profile = optionValue(arg, i);
29
+ i += 1;
20
30
  } else if (arg === '--to') {
21
- options.to = args[++i];
31
+ options.to = optionValue(arg, i);
32
+ i += 1;
22
33
  } else if (arg === '--no-codex') {
23
34
  options.codex = false;
24
35
  } else if (arg === '--no-claude') {
@@ -29,6 +40,16 @@ function parseOptions(args) {
29
40
  options.check = true;
30
41
  } else if (arg === '--dry-run') {
31
42
  options.dryRun = true;
43
+ } else if (arg === '--limit') {
44
+ const value = optionValue(arg, i);
45
+ const limit = Number(value);
46
+ if (!Number.isInteger(limit) || limit < 1 || limit > 50) {
47
+ throw new Error('--limit must be an integer from 1 to 50');
48
+ }
49
+ options.limit = limit;
50
+ i += 1;
51
+ } else if (arg === '--no-expand') {
52
+ options.expand = false;
32
53
  } else if (arg === '--replace-hooks') {
33
54
  options.replaceHooks = true;
34
55
  } else if (arg === '--all') {
@@ -71,6 +92,9 @@ Usage:
71
92
  llm-wiki hook claude <EventName>
72
93
  llm-wiki bootstrap --workspace <project>
73
94
  llm-wiki migrate --workspace <project>
95
+ llm-wiki context "<query>" --workspace <project> [--limit 5] [--no-expand]
96
+ llm-wiki lint --workspace <project>
97
+ llm-wiki consolidate --workspace <project> [--dry-run]
74
98
  `);
75
99
  return;
76
100
  }
@@ -143,6 +167,27 @@ Usage:
143
167
  return;
144
168
  }
145
169
 
170
+ if (command === 'context') {
171
+ const projectRoot = resolve(options.workspace || process.cwd());
172
+ const query = rest.join(' ').trim();
173
+ printJsonOrText(await buildContextPack(projectRoot, query, options), options, formatContextPack);
174
+ return;
175
+ }
176
+
177
+ if (command === 'lint') {
178
+ const projectRoot = resolve(options.workspace || process.cwd());
179
+ const result = await runLint(projectRoot, options);
180
+ printJsonOrText(result, options, formatLintResult);
181
+ if (!result.ok) process.exitCode = 1;
182
+ return;
183
+ }
184
+
185
+ if (command === 'consolidate') {
186
+ const projectRoot = resolve(options.workspace || process.cwd());
187
+ printJsonOrText(await runConsolidate(projectRoot, options), options, formatConsolidateResult);
188
+ return;
189
+ }
190
+
146
191
  if (command === 'hook') {
147
192
  const provider = rest[0] || 'codex';
148
193
  const eventName = rest[1];
@@ -183,6 +228,8 @@ function formatStatus(value) {
183
228
  `- version: ${value.runtimeVersion}`,
184
229
  `- runtime: ${value.runtimeVersion} (${value.installSource})`,
185
230
  `- bin: ${value.binPath}`,
231
+ `- command: ${value.commandPath || 'not found'}`,
232
+ `- command matches runtime: ${value.commandMatchesRuntime ? 'yes' : 'no'}`,
186
233
  `- hooks current: ${value.hooksCurrent ? 'yes' : 'no'}`,
187
234
  `- codex hook: ${value.codexInstalled ? 'current' : 'missing/outdated'}`,
188
235
  `- claude hook: ${value.claudeInstalled ? 'current' : 'missing/outdated'}`,