llm-wiki-kit 0.2.15 → 0.2.16

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
@@ -103,16 +103,16 @@ The installed hooks:
103
103
  - automatically choose Korean or English hook guidance from the current user prompt, then fall back to Claude Code `language`, local `CLAUDE.md`/`AGENTS.md`, and English.
104
104
  - remove Codex-facing legacy `oh-my-codex:wiki`/`omx_wiki` surfaces at session start so `llm-wiki/` remains the active wiki implementation
105
105
  - record small redacted raw event envelopes and per-turn state
106
- - capture meaningful work and structured decision points, including tool evidence, changed files, and verification notes
106
+ - capture meaningful work and structured decision points, including tool evidence, changed files, verification notes, and reusable durable-candidate signals
107
107
  - attach safe `evidence_refs` candidates to generated durable candidates when changed files or verification commands are available
108
- - before compaction, classify the current turn and save a redacted checkpoint only for meaningful work, structured decisions, or explicit durable requests; explicit durable candidates also get a maintenance queue item when no durable wiki update is detected
108
+ - before compaction, classify the current turn and save a redacted checkpoint only for meaningful work, structured decisions, explicit durable requests, or suggested durable candidates; durable candidates get a maintenance queue item when no durable wiki update is detected
109
109
  - after compaction, store the redacted compact summary only; if pre-compact preservation failed, prepare a recovery packet for the next legal model-visible context hook
110
110
  - allow tool calls to proceed without secret/PII-based hook blocking
111
- - update chunked `llm-wiki/outputs/questions/YYYY-MM-DD/live-qa-001.md` style archives only for meaningful work or structured decision turns
111
+ - update chunked `llm-wiki/outputs/questions/YYYY-MM-DD/live-qa-001.md` style archives only for meaningful work, structured decision turns, or hook-suggested durable candidates
112
112
  - avoid automatic `wiki/queries/` and `wiki/decisions/` promotion in the default answer-first mode
113
- - queue durable cleanup candidates only for explicit documentation requests that were not reflected in durable wiki files, or when stale turn state is recovered
113
+ - queue durable cleanup candidates for explicit documentation requests, hook-suggested durable candidates, or recovered stale turn state that were not reflected in durable wiki files
114
114
  - recover stale per-turn state into that queue on the next session start or prompt submit when the previous stop hook did not complete
115
- - nudge the active LLM to fold approved reusable facts into existing wiki pages instead of leaving everything as one-off Q&A
115
+ - nudge the active LLM to fold approved or hook-suggested reusable facts into existing wiki pages instead of leaving everything as one-off Q&A
116
116
  - automatically refresh managed rules/templates for older projects when the current runtime starts a session
117
117
 
118
118
  If you need to think about saving every answer manually, the setup has failed.
package/docs/concepts.md CHANGED
@@ -18,12 +18,12 @@ The important behavior is a loop:
18
18
  2. `memory.md`, `index.md`, and relevant wiki context are injected automatically with an answer-first instruction.
19
19
  3. The user works normally; no extra command loop is required.
20
20
  4. Hooks gather redacted prompt/tool/result summaries.
21
- 5. At stop/session end, hooks append redacted chunked live Q&A only for turns with work evidence or structured decision/debugging conclusions.
21
+ 5. At stop/session end, hooks append redacted chunked live Q&A only for turns with work evidence, structured decision/debugging conclusions, or hook-suggested durable candidates.
22
22
  6. When possible, generated candidates carry safe `evidence_refs` such as changed files, verification commands, raw source IDs, or external URLs.
23
23
  7. Simple answers, status checks, and keyword-only responses stay out of live Q&A and durable wiki by default.
24
- 8. Durable wiki promotion is selective: explicit record/document requests should be handled by the active agent in existing wiki pages; the hook queues review only when such a request was not reflected in durable files.
24
+ 8. Durable wiki promotion is selective: explicit record/document requests and hook-suggested durable candidates should be handled by the active agent in existing wiki pages; the hook queues review only when the turn was not reflected in durable files.
25
25
  9. At the next start/prompt after an abrupt shutdown, hooks can recover stale turn state into `outputs/maintenance/queue.md`.
26
- 10. When reusable knowledge appears, the active Claude Code/Codex agent folds approved facts into existing durable wiki pages instead of leaving everything as one-off Q&A.
26
+ 10. When reusable knowledge appears, the active Claude Code/Codex agent folds approved or hook-suggested facts into existing durable wiki pages instead of leaving everything as one-off Q&A.
27
27
  11. Export and eval reuse the same durable visibility policy so handoff manifests, retrieval fixtures, and context selection describe the same wiki surface.
28
28
  12. Future sessions start from the improved wiki instead of relying on long chat history.
29
29
 
@@ -44,9 +44,9 @@ The maintenance loop is intentionally layered:
44
44
  - `index.md`: broad navigation map.
45
45
  - MiniSearch + wikilinks: retrieval over durable `wiki/**/*.md`, with episodic `wiki/queries/`, `wiki/context/`, and `session-log` pages hidden by default unless promoted or `--include-episodic` is requested; archived/superseded pages stay preserved but hidden unless `--include-archived` is requested. Verbose context explains `why selected`; hook context stays compact.
46
46
  - `evidence_refs`: optional frontmatter that ties durable claims to `file:`, `cmd:`, `raw:`, or `url:` evidence without embedding secrets or raw transcripts.
47
- - `outputs/maintenance/queue.md`: selective reminders for explicit durable requests that need review, plus stale turn recovery. Queue state is `pending`, `approved`, `done`, or `skipped`.
47
+ - `outputs/maintenance/queue.md`: selective reminders for explicit durable requests, hook-suggested durable candidates, and stale turn recovery that need review. Queue state is `pending`, `approved`, `done`, or `skipped`.
48
48
  - `lint`: finds broken links, stale pages, duplicates, metadata gaps, invalid evidence refs, secret-like content, outdated managed rules, memory/page-count budget pressure, hidden episodic growth, and stale/archived discoverability gaps.
49
- - `maintenance`: reports `reviewDue` only when periodic thresholds are met; hook reminders are soft and limited to session start/instructions loaded or maintenance-related prompts, with approved items shown before pending items.
49
+ - `maintenance`: reports `reviewDue` only when periodic thresholds are met; hook reminders are soft and limited to session start/instructions loaded or compact prompt-time reminders for maintenance prompts, approved items, durable candidates, stale/recovered items, or review-threshold pressure.
50
50
  - `consolidate`: agent helper that refreshes generated blocks in `memory.md` and `index.md` while preserving handwritten notes, keeping default query/context/session pages out of the durable generated maps, and skipping stale/archived/superseded pages.
51
51
  - `eval`: checks retrieval fixtures in `llm-wiki/evals/retrieval.json` and reports expected recall, missed expected paths, unexpected hits, and top hits.
52
52
  - `export`: writes redacted `llms.txt`, `llms-full.txt`, and `llm-wiki.json` manifests for agent onboarding, handoff, retrieval eval, and external consumption. `llms.txt` is not treated as a passive SEO artifact.
@@ -42,11 +42,11 @@ when no project `CLAUDE.md` exists. Existing `CLAUDE.md` files are not overwritt
42
42
 
43
43
  The hook records redacted turn summaries but does not deny tool calls only because an input looks sensitive. Hook payloads are stored as small redacted event envelopes rather than full transcripts, and context output is redacted field by field before it is returned to Claude Code.
44
44
 
45
- At `SessionStart`/`InstructionsLoaded`, the hook first attempts a safe managed-template refresh, recovers stale turn state into `outputs/maintenance/queue.md`, performs a cached npm update notice check for npm installs, then injects functional compact context. The context still uses `llm-wiki/wiki/memory.md`, `llm-wiki/wiki/index.md`, relevant wiki/search state, operating rules, maintenance signals, passive runtime update status, and managed-template cleanup notes; the hook formats those signals so they are usable if shown in the Claude Code UI. At `UserPromptSubmit`, it recovers stale turn state, searches wiki pages with MiniSearch or substring fallback, expands one-hop wikilinks, redacts context fields, performs the same cached update notice check, and injects the smallest useful functional compact context set. Verbose `llm-wiki context` can explain `why selected`, `rankReason`, `matchedFields`, and `evidenceRefs`, but hook context keeps those details compact. Update notice cache is scoped by npm command, and maintenance reminders are shown only when the prompt is wiki/maintenance related or matches a queue topic.
45
+ At `SessionStart`/`InstructionsLoaded`, the hook first attempts a safe managed-template refresh, recovers stale turn state into `outputs/maintenance/queue.md`, performs a cached npm update notice check for npm installs, then injects functional compact context. The context still uses `llm-wiki/wiki/memory.md`, `llm-wiki/wiki/index.md`, relevant wiki/search state, operating rules, maintenance signals, passive runtime update status, and managed-template cleanup notes; the hook formats those signals so they are usable if shown in the Claude Code UI. At `UserPromptSubmit`, it recovers stale turn state, searches wiki pages with MiniSearch or substring fallback, expands one-hop wikilinks, redacts context fields, performs the same cached update notice check, and injects the smallest useful functional compact context set. Verbose `llm-wiki context` can explain `why selected`, `rankReason`, `matchedFields`, and `evidenceRefs`, but hook context keeps those details compact. Update notice cache is scoped by npm command, and maintenance reminders are shown for wiki/maintenance prompts, queue topic matches, approved items, durable candidates, stale/recovered items, or review-threshold pressure.
46
46
 
47
47
  Hook-visible language is selected from the current user prompt first. Korean prompts get Korean guidance, English prompts get English guidance. If no prompt language is clear, the hook checks Claude Code `settings.json` `language` when it exists, then local `CLAUDE.md`/`AGENTS.md` language signals, then English. The kit does not require Claude Code to expose a language setting.
48
48
 
49
- `PostToolUse` and `PostToolBatch` record redacted tool summaries in the same turn buffer. `PreCompact` classifies the current turn before compaction: simple turns record only a context note, work-evidence or structured-decision turns write a chunked live Q&A checkpoint, and explicit durable candidates write a maintenance queue item only when no durable wiki update is detected. Queue items may carry safe `evidence_refs` candidates from changed files and verification commands. The checkpoint can include only a bounded redacted transcript tail, never the full raw transcript or raw `transcript_path`. Compaction is not blocked; if checkpoint storage fails, the hook records a compact recovery packet for the next legal context-injection event. `PostCompact` stores the redacted compact summary as a context note and prepares any pending recovery packet without returning model-visible context directly. In the default `answer-first` mode, `SubagentStop` does not create live Q&A, query, decision, or maintenance files. `Stop` and `SessionEnd` append chunked live Q&A only for work-evidence or structured-decision turns and do not auto-create `wiki/queries/` or `wiki/decisions/`. If the user explicitly asked to record or document durable knowledge and no durable wiki update is detected, `Stop`/`SessionEnd` queue a pending maintenance item for agent review. Approved maintenance items are shown before pending items in later reminders. `Stop` and `SessionEnd` then clear the per-session turn buffer; `SubagentStop` does not.
49
+ `PostToolUse` and `PostToolBatch` record redacted tool summaries in the same turn buffer. `PreCompact` classifies the current turn before compaction: simple turns record only a context note, work-evidence, structured-decision, explicit durable, or hook-suggested durable turns write a chunked live Q&A checkpoint, and durable candidates write a maintenance queue item only when no durable wiki update is detected. Queue items may carry safe `evidence_refs` candidates from changed files and verification commands. The checkpoint can include only a bounded redacted transcript tail, never the full raw transcript or raw `transcript_path`. Compaction is not blocked; if checkpoint storage fails, the hook records a compact recovery packet for the next legal context-injection event. `PostCompact` stores the redacted compact summary as a context note and prepares any pending recovery packet without returning model-visible context directly. In the default `answer-first` mode, `SubagentStop` does not create live Q&A, query, decision, or maintenance files. `Stop` and `SessionEnd` append chunked live Q&A only for work-evidence, structured-decision, or durable-candidate turns and do not auto-create `wiki/queries/` or `wiki/decisions/`. If the user explicitly asked to record durable knowledge, or the turn contains reusable architecture/debugging/policy/procedure/decision signals, and no durable wiki update is detected, `Stop`/`SessionEnd` queue a pending maintenance item for agent review. Approved and durable-candidate maintenance items are surfaced as compact soft reminders. `Stop` and `SessionEnd` then clear the per-session turn buffer; `SubagentStop` does not.
50
50
 
51
51
  For handoff or retrieval verification, use `llm-wiki export --workspace <project> --format all` and `llm-wiki eval --workspace <project>`. The generated `llms.txt`/`llms-full.txt`/`llm-wiki.json` files are redacted durable manifests, not raw transcripts.
52
52
 
@@ -30,14 +30,14 @@ Handled events:
30
30
  Expected behavior:
31
31
 
32
32
  - `SessionStart` first attempts a safe managed-template refresh, removes Codex-facing legacy `oh-my-codex:wiki`/`omx_wiki` surfaces when they reappear, recovers stale turn state into `outputs/maintenance/queue.md`, performs a cached npm update notice check for npm installs, then injects functional compact context. The context still uses `llm-wiki/wiki/memory.md`, `llm-wiki/wiki/index.md`, relevant wiki/search state, operating rules, maintenance signals, passive runtime update status, and managed-template cleanup notes; the hook formats those signals so they are usable if shown in the Codex UI.
33
- - `UserPromptSubmit` recovers stale turn state, searches project wiki pages with MiniSearch or substring fallback, expands one-hop wikilinks, redacts context fields, performs the same cached update notice check, and injects the smallest useful functional compact context set. Verbose `llm-wiki context` can explain `why selected`, `rankReason`, `matchedFields`, and `evidenceRefs`, but hook context keeps those details compact. Update notice cache is scoped by npm command, and maintenance reminders are shown only when the prompt is wiki/maintenance related or matches a queue topic.
33
+ - `UserPromptSubmit` recovers stale turn state, searches project wiki pages with MiniSearch or substring fallback, expands one-hop wikilinks, redacts context fields, performs the same cached update notice check, and injects the smallest useful functional compact context set. Verbose `llm-wiki context` can explain `why selected`, `rankReason`, `matchedFields`, and `evidenceRefs`, but hook context keeps those details compact. Update notice cache is scoped by npm command, and maintenance reminders are shown for wiki/maintenance prompts, queue topic matches, approved items, durable candidates, stale/recovered items, or review-threshold pressure.
34
34
  - Hook-visible language is selected from the current user prompt first. Korean prompts get Korean guidance, English prompts get English guidance. If no prompt language is clear, Codex falls back to local `CLAUDE.md`/`AGENTS.md` language signals, then English.
35
35
  - `PreToolUse` records redacted tool summaries without blocking tool calls.
36
36
  - `PostToolUse` records redacted tool summaries in a turn buffer.
37
- - `PreCompact` classifies the current turn before compaction. Simple turns record only a context note; work-evidence or structured-decision turns write a chunked live Q&A checkpoint; explicit durable candidates write a maintenance queue item only when no durable wiki update is detected. The checkpoint can include only a bounded redacted transcript tail, never the full raw transcript or raw `transcript_path`. Compaction is not blocked; if checkpoint storage fails, the hook records a compact recovery packet for the next legal context-injection event.
37
+ - `PreCompact` classifies the current turn before compaction. Simple turns record only a context note; work-evidence, structured-decision, explicit durable, or hook-suggested durable turns write a chunked live Q&A checkpoint; durable candidates write a maintenance queue item only when no durable wiki update is detected. The checkpoint can include only a bounded redacted transcript tail, never the full raw transcript or raw `transcript_path`. Compaction is not blocked; if checkpoint storage fails, the hook records a compact recovery packet for the next legal context-injection event.
38
38
  - `PostCompact` stores the redacted compact summary as a context note and prepares any pending compact recovery packet. It does not return `hookSpecificOutput.additionalContext`, because Codex `PostCompact` only supports common output fields.
39
- - In the default `answer-first` mode, `SubagentStop` does not create live Q&A, query, decision, or maintenance files. `Stop` appends chunked live Q&A only for work-evidence or structured-decision turns and does not auto-create `wiki/queries/` or `wiki/decisions/`.
40
- - If the user explicitly asked to record or document durable knowledge and no durable wiki update is detected, `Stop` queues a pending maintenance item for agent review. Queue items may carry safe `evidence_refs` candidates from changed files and verification commands. Approved maintenance items are shown before pending items in later reminders.
39
+ - In the default `answer-first` mode, `SubagentStop` does not create live Q&A, query, decision, or maintenance files. `Stop` appends chunked live Q&A only for work-evidence, structured-decision, or durable-candidate turns and does not auto-create `wiki/queries/` or `wiki/decisions/`.
40
+ - If the user explicitly asked to record durable knowledge, or the turn contains reusable architecture/debugging/policy/procedure/decision signals, and no durable wiki update is detected, `Stop` queues a pending maintenance item for agent review. Queue items may carry safe `evidence_refs` candidates from changed files and verification commands. Approved and durable-candidate maintenance items are surfaced as compact soft reminders.
41
41
  - `Stop` clears the per-session turn buffer after recording. `SubagentStop` leaves the parent turn buffer available for the final stop event.
42
42
 
43
43
  Hook payloads are stored as small redacted event envelopes rather than full transcripts. Context output is also redacted field by field before it is returned to Codex. Functional compact context is a presentation policy, not a feature reduction: Codex still receives the wiki memory, search, maintenance, and passive update signals needed for the hook workflow.
package/docs/manual.md CHANGED
@@ -72,9 +72,9 @@ Use Codex or Claude Code normally. Installed hooks:
72
72
  - use `wiki/memory.md`, `wiki/index.md`, relevant wiki search, maintenance signals, update notices, and compact recovery packets;
73
73
  - record redacted prompt/tool/result summaries in per-turn state;
74
74
  - preserve safe evidence pointers as `evidence_refs` when changed files or verification commands are available;
75
- - archive only meaningful work turns or structured decision/debugging turns into chunked `outputs/questions/YYYY-MM-DD/live-qa-001.md` files;
75
+ - archive only meaningful work turns, structured decision/debugging turns, or hook-suggested durable candidates into chunked `outputs/questions/YYYY-MM-DD/live-qa-001.md` files;
76
76
  - avoid automatic `wiki/queries/` and `wiki/decisions/` promotion in the default answer-first mode;
77
- - queue durable cleanup candidates only for explicit documentation requests that were not reflected in durable wiki files, or when stale turn state is recovered;
77
+ - queue durable cleanup candidates for explicit documentation requests, hook-suggested durable candidates, or recovered stale turn state that were not reflected in durable wiki files;
78
78
  - refresh clearly managed rules/templates for older projects at session start;
79
79
  - remove legacy Codex-facing `oh-my-codex:wiki`/`omx_wiki` surfaces when they reappear.
80
80
 
@@ -88,7 +88,7 @@ Default:
88
88
  LLM_WIKI_KIT_CAPTURE_MODE=answer-first
89
89
  ```
90
90
 
91
- `answer-first` keeps simple Q&A, status checks, and keyword-only replies out of durable wiki and live Q&A by default. It archives work turns with tool evidence, changed-file evidence, verification, or structured `Decision:`/`Root cause:` style conclusions. Explicit durable requests create maintenance queue candidates only when no durable wiki update is detected.
91
+ `answer-first` keeps simple Q&A, status checks, and keyword-only replies out of durable wiki and live Q&A by default. It archives work turns with tool evidence, changed-file evidence, verification, structured `Decision:`/`Root cause:` style conclusions, or reusable durable-candidate signals. Explicit durable requests and hook-suggested durable candidates create maintenance queue candidates only when no durable wiki update is detected.
92
92
 
93
93
  Deprecated compatibility mode:
94
94
 
@@ -241,7 +241,7 @@ llm-wiki maintenance --workspace <project> --skip <id> --note "duplicate"
241
241
  Hook reminders are soft:
242
242
 
243
243
  - session start and instructions loaded may show a one-item summary;
244
- - prompt submit shows a reminder only when the prompt is wiki/maintenance-related or matches a queue topic.
244
+ - prompt submit shows one compact reminder for wiki/maintenance prompts, queue topic matches, approved items, durable candidates, stale/recovered items, or review-threshold pressure.
245
245
 
246
246
  ## PreCompact
247
247
 
@@ -146,7 +146,7 @@ After a plain `npm install -g llm-wiki-kit@latest`, existing hooks keep working
146
146
 
147
147
  Daily use should be Claude Code/Codex first. The user should not need to run a chain of `llm-wiki` commands while working. Hooks inject context automatically, but the current user answer takes priority over wiki cleanup. The active agent updates durable wiki pages when reusable project knowledge appears and the turn's importance or user consent justifies persistence. Hook context policy is function-first: memory, search, maintenance, and update signals remain available, while user-visible context is formatted as functional compact context instead of a raw dump.
148
148
 
149
- In the default `LLM_WIKI_KIT_CAPTURE_MODE=answer-first` mode, `Stop` and `SessionEnd` append live Q&A only for meaningful work evidence or structured decision turns. Simple answers, status checks, and keyword-only responses are not archived. Live Q&A uses chunked files under `llm-wiki/outputs/questions/YYYY-MM-DD/` and rolls over by line/byte budget. Hooks do not auto-create `wiki/queries/` or `wiki/decisions/`. If the user explicitly asked for recording/documentation and no durable wiki update is detected, a pending cleanup candidate is written to `llm-wiki/outputs/maintenance/queue.md`. `PreCompact` performs the same answer-first classification before context compaction: simple turns get only a context note, archive-worthy turns get a live Q&A checkpoint, and explicit durable candidates get a checkpoint plus queue item only when needed. If checkpoint storage fails, compaction still proceeds and the hook prepares an important-only compact recovery packet for the next legal context-injection event. `SessionStart` and `UserPromptSubmit` also recover stale per-turn state into the same queue when the previous stop hook did not complete. `SessionStart` injects a one-item queue summary; `UserPromptSubmit` injects a soft reminder only when the prompt is wiki/maintenance related or matches a queue topic. This is a recovery and reminder layer, not a full transcript capture path.
149
+ In the default `LLM_WIKI_KIT_CAPTURE_MODE=answer-first` mode, `Stop` and `SessionEnd` append live Q&A only for meaningful work evidence, structured decision turns, or reusable durable-candidate signals. Simple answers, status checks, and keyword-only responses are not archived. Live Q&A uses chunked files under `llm-wiki/outputs/questions/YYYY-MM-DD/` and rolls over by line/byte budget. Hooks do not auto-create `wiki/queries/` or `wiki/decisions/`. If the user explicitly asked for recording/documentation, or the turn contains reusable architecture/debugging/policy/procedure/decision signals, and no durable wiki update is detected, a pending cleanup candidate is written to `llm-wiki/outputs/maintenance/queue.md`. `PreCompact` performs the same answer-first classification before context compaction: simple turns get only a context note, archive-worthy turns get a live Q&A checkpoint, and durable candidates get a checkpoint plus queue item only when needed. If checkpoint storage fails, compaction still proceeds and the hook prepares an important-only compact recovery packet for the next legal context-injection event. `SessionStart` and `UserPromptSubmit` also recover stale per-turn state into the same queue when the previous stop hook did not complete. `SessionStart` injects a one-item queue summary; `UserPromptSubmit` injects a compact soft reminder when the prompt is wiki/maintenance related, matches a queue topic, has approved or durable-candidate items, or the queue crosses the review threshold. This is a recovery and reminder layer, not a full transcript capture path.
150
150
 
151
151
  Use `llm-wiki archive-questions --workspace <project> --dry-run` to review splitting legacy `outputs/questions/YYYY-MM-DD-live-qa.md` files into the chunked layout. Running it without `--dry-run` preserves the original under `outputs/questions/archive/originals/` with a checksum sidecar and replaces the legacy file with a pointer stub.
152
152
 
@@ -211,7 +211,7 @@ Agents may run `consolidate` after meaningful wiki growth. Users should not need
211
211
 
212
212
  `llm-wiki maintenance --workspace <project>` prints queue counts, review due status, and the first pending items. It does not merge wiki pages by itself; the active agent should review pending items, update the closest existing durable wiki document, then mark the queue item `done` or `skipped`. Periodic maintenance is an agent-side task, not something users need to run after every turn.
213
213
 
214
- `llm-wiki maintenance --workspace <project> --json` includes `reviewDue`, `reviewReasons`, `pendingCount`, `stalePendingCount`, `health`, and `recommendedCommands`. Review is due when the last review is older than 14 days, pending queue size reaches 5, stale or result-missing pending items exist, lint has warnings/errors, `memory.md` is near budget, or wiki page count reaches 80% of the search cap. Hook reminders are soft: `SessionStart`/`InstructionsLoaded` may show a short due note, while `UserPromptSubmit` shows it only for wiki/maintenance/cleanup-related prompts. The reminder never blocks the current answer.
214
+ `llm-wiki maintenance --workspace <project> --json` includes `reviewDue`, `reviewReasons`, `pendingCount`, `stalePendingCount`, `health`, and `recommendedCommands`. Review is due when the last review is older than 14 days, pending queue size reaches 5, stale or result-missing pending items exist, lint has warnings/errors, `memory.md` is near budget, or wiki page count reaches 80% of the search cap. Hook reminders are soft: `SessionStart`/`InstructionsLoaded` may show a short due note, while `UserPromptSubmit` shows one compact item for wiki/maintenance prompts, approved items, durable candidates, stale/recovered items, or review-threshold pressure. The reminder never blocks the current answer.
215
215
 
216
216
  Recommended agent checklist:
217
217
 
@@ -229,7 +229,7 @@ Check:
229
229
 
230
230
  ## Maintenance Queue Is Empty Or Stale
231
231
 
232
- In the default answer-first mode, `llm-wiki/outputs/maintenance/queue.md` is created only when a user explicitly asked for durable recording/documentation but no durable wiki update was detected, or when `SessionStart`/`UserPromptSubmit` recovers stale per-turn state from a session that did not stop cleanly. It is not expected to grow after every normal `Stop`.
232
+ In the default answer-first mode, `llm-wiki/outputs/maintenance/queue.md` is created when a user explicitly asked for durable recording/documentation, a turn was classified as a hook-suggested durable candidate, or stale per-turn state is recovered, and no durable wiki update was detected. It is not expected to grow after every normal `Stop`.
233
233
 
234
234
  Check the queue and health warnings:
235
235
 
@@ -238,7 +238,7 @@ llm-wiki maintenance --workspace /path/to/project
238
238
  llm-wiki lint --workspace /path/to/project
239
239
  ```
240
240
 
241
- If the queue is always empty during ordinary Q&A, that is normal. If you expected an explicit documentation request to queue, confirm hooks run and that the turn had a captured `UserPromptSubmit`. If pending items stay around, the active agent should merge reusable content into existing durable wiki pages and mark each item `done` or `skipped` without delaying unrelated answers.
241
+ If the queue is always empty during ordinary Q&A, that is normal. If you expected an explicit documentation request or durable candidate to queue, confirm hooks run and that the turn had a captured `UserPromptSubmit`. If pending items stay around, the active agent should merge reusable content into existing durable wiki pages and mark each item `done` or `skipped` without delaying unrelated answers.
242
242
 
243
243
  ## Authentication Values Were Redacted
244
244
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-wiki-kit",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Hook-first living Markdown wiki runtime for Codex and Claude Code with Korean/English prompt-aware guidance.",
5
5
  "type": "module",
6
6
  "files": [
@@ -116,10 +116,28 @@ export function classifyTurn(entry, eventName = '') {
116
116
  const hasVerification = Boolean(verification);
117
117
  const hasWorkEvidence = hasWork || hasFiles || hasVerification;
118
118
  const durableConclusion = hasDurableConclusion(text);
119
+ const durableSignal = durableConclusion || hasDurableKeyword(text);
120
+ const durableUpdated = hasDetectedDurableWikiChange(entry);
119
121
 
120
122
  if (hasWorkEvidence) {
123
+ if (durableUpdated) {
124
+ return {
125
+ kind: 'durable-updated',
126
+ archive: true,
127
+ suggestDurable: false,
128
+ queueIfMissingDurable: false,
129
+ };
130
+ }
131
+ if (durableSignal) {
132
+ return {
133
+ kind: 'suggest-durable',
134
+ archive: true,
135
+ suggestDurable: true,
136
+ queueIfMissingDurable: true,
137
+ };
138
+ }
121
139
  return {
122
- kind: hasDetectedDurableWikiChange(entry) ? 'durable-updated' : 'work',
140
+ kind: 'work',
123
141
  archive: true,
124
142
  suggestDurable: false,
125
143
  queueIfMissingDurable: false,
@@ -128,10 +146,10 @@ export function classifyTurn(entry, eventName = '') {
128
146
 
129
147
  if (durableConclusion) {
130
148
  return {
131
- kind: 'decision',
149
+ kind: 'suggest-durable',
132
150
  archive: true,
133
- suggestDurable: false,
134
- queueIfMissingDurable: false,
151
+ suggestDurable: true,
152
+ queueIfMissingDurable: true,
135
153
  };
136
154
  }
137
155
 
package/src/hook.js CHANGED
@@ -81,21 +81,35 @@ async function handleLegacyEagerStop(projectRoot, eventName, payload, entry) {
81
81
  }
82
82
  }
83
83
 
84
+ function durableQueueReason(classification) {
85
+ if (classification.kind === 'explicit-durable') {
86
+ return 'Explicit durable documentation request did not have a detected durable wiki update.';
87
+ }
88
+ return 'Suggested durable wiki candidate did not have a detected durable wiki update.';
89
+ }
90
+
91
+ function durableFollowUp(entry, classification) {
92
+ if (!classification.suggestDurable) return entry.followUp;
93
+ const message = 'This turn is a durable wiki candidate. After the current answer, merge reusable facts into an existing durable wiki page or mark the maintenance item skipped.';
94
+ const current = String(entry.followUp || '').trim();
95
+ if (!current || current === '(not captured)') return message;
96
+ if (current.includes(message)) return current;
97
+ return `${current}\n${message}`;
98
+ }
99
+
84
100
  async function handleAnswerFirstStop(projectRoot, eventName, payload, entry) {
85
101
  const classification = classifyTurn(entry, eventName);
86
102
  if (classification.archive) {
87
103
  const archiveEntry = {
88
104
  ...entry,
89
- followUp: classification.suggestDurable
90
- ? 'This turn may be worth preserving. If the user approves, merge it into an existing durable wiki page.'
91
- : entry.followUp,
105
+ followUp: durableFollowUp(entry, classification),
92
106
  };
93
107
  const liveQaPath = await appendLiveQa(projectRoot, archiveEntry);
94
108
  if (classification.queueIfMissingDurable && !hasDetectedDurableWikiChange(entry)) {
95
109
  await recordMaintenanceForEntry(projectRoot, entry, {
96
110
  source: liveQaPath,
97
111
  eventName,
98
- reason: 'Explicit durable documentation request did not have a detected durable wiki update.',
112
+ reason: durableQueueReason(classification),
99
113
  }).catch(() => {});
100
114
  }
101
115
  await appendWikiLog(projectRoot, `captured ${eventName}; archive=${relative(projectRoot, liveQaPath)}; classification=${classification.kind}`);
@@ -402,6 +402,21 @@ export async function recoverStaleTurnStates(projectRoot, options = {}) {
402
402
  return output;
403
403
  }
404
404
 
405
+ function isDurablePromotionCandidate(item) {
406
+ if (item?.status === 'approved') return true;
407
+ const text = `${item?.reason || ''} ${item?.fields?.reason || ''}`.toLowerCase();
408
+ return /suggested durable wiki candidate|precompact durable candidate|explicit durable documentation|durable wiki review/.test(text);
409
+ }
410
+
411
+ function shouldSurfacePromptMaintenance(summary, query, reviewCandidates) {
412
+ if (isMaintenanceRelatedQuery(query || '', reviewCandidates)) return true;
413
+ if ((summary.approvedCount || 0) > 0) return true;
414
+ if (reviewCandidates.some(isDurablePromotionCandidate)) return true;
415
+ if ((summary.pendingCount || 0) >= (summary.reviewPendingLimit || DEFAULT_REVIEW_PENDING_LIMIT)) return true;
416
+ if ((summary.stalePendingCount || 0) > 0) return true;
417
+ return reviewCandidates.some((item) => item.result_missing);
418
+ }
419
+
405
420
  export function formatMaintenanceContext(summary, options = {}) {
406
421
  if (!summary.reviewDue) return '';
407
422
  const language = options.language === 'ko' ? 'ko' : 'en';
@@ -412,7 +427,7 @@ export function formatMaintenanceContext(summary, options = {}) {
412
427
  let pending = reviewCandidates.slice(0, limit);
413
428
 
414
429
  if (eventName === 'UserPromptSubmit') {
415
- if (!isMaintenanceRelatedQuery(options.query || '', reviewCandidates)) return '';
430
+ if (!shouldSurfacePromptMaintenance(summary, options.query || '', reviewCandidates)) return '';
416
431
  pending = reviewCandidates.slice(0, 1);
417
432
  } else if (eventName !== 'SessionStart' && eventName !== 'InstructionsLoaded') {
418
433
  return '';
@@ -423,12 +438,12 @@ export function formatMaintenanceContext(summary, options = {}) {
423
438
  ? [
424
439
  'LLM Wiki maintenance status:',
425
440
  `- review due: yes (${(summary.reviewReasons || []).slice(0, 2).join('; ') || 'periodic review threshold met'}).`,
426
- `- approved/pending review items: ${reviewCount}. 현재 요청이 우선이며, 관련 있을 때만 durable wiki 정리에 사용한다.`,
441
+ `- approved/pending review items: ${reviewCount}. 현재 요청이 우선이며, 관련 있거나 세션 종료 전 여유가 있으면 durable wiki 병합하거나 skipped로 표시한다.`,
427
442
  ]
428
443
  : [
429
444
  'LLM Wiki maintenance status:',
430
445
  `- review due: yes (${(summary.reviewReasons || []).slice(0, 2).join('; ') || 'periodic review threshold met'}).`,
431
- `- approved/pending review items: ${reviewCount}. The current request comes first; use this only when it is relevant to durable wiki cleanup.`,
446
+ `- approved/pending review items: ${reviewCount}. The current request comes first; when relevant or before ending the session, merge candidates into durable wiki pages or mark them skipped.`,
432
447
  ];
433
448
  for (const item of pending) {
434
449
  const target = item.target || item.suggested_target;
@@ -254,7 +254,7 @@ function legacyProcedureSignals(name) {
254
254
  const common = [/^# .+ Procedure/m];
255
255
  const byName = {
256
256
  'ingest.md': [/^# Ingest Procedure/m, /wiki\/memory\.md/, /raw\/inbox|raw\/sources/],
257
- 'query.md': [/^# Query Procedure/m, /llm-wiki context/, /Save reusable answers|reusable answers/],
257
+ 'query.md': [/^# Query Procedure/m, /llm-wiki context/, /Save reusable answers|reusable answers|Merge reusable facts|reusable facts/],
258
258
  'lint.md': [/^# Lint Procedure/m, /llm-wiki lint/, /stale pages|orphan pages/],
259
259
  'security.md': [/^# Security Procedure/m, /Redact authentication values|token|private keys/, /raw transcript capture/],
260
260
  };
@@ -359,12 +359,19 @@ function hasKitManagedSignal(text, descriptor) {
359
359
  return false;
360
360
  }
361
361
 
362
+ function hasPatchableGeneratedSignal(text, descriptor) {
363
+ if (!hasLegacyGeneratedSignal(text, descriptor)) return false;
364
+ if (String(descriptor.id || '').startsWith('procedure-') && /^##\s+/m.test(text)) return false;
365
+ return true;
366
+ }
367
+
362
368
  function canPatchDescriptor(state, descriptor, currentText, fileExists = true) {
363
369
  if (descriptor.mode === 'create-only') return !fileExists;
364
370
  if (descriptor.mode === 'marker') return replaceMarkedBlock(currentText, descriptor.content) !== null;
365
371
  return isRecordedManaged(state, descriptor, currentText) ||
366
372
  isKnownGeneratedContent(currentText, descriptor) ||
367
- isLegacyGeneratedContent(currentText, descriptor);
373
+ isLegacyGeneratedContent(currentText, descriptor) ||
374
+ hasPatchableGeneratedSignal(currentText, descriptor);
368
375
  }
369
376
 
370
377
  function desiredTextForDescriptor(descriptor, currentText, fileExists = true) {
package/src/templates.js CHANGED
@@ -16,9 +16,9 @@ This repository uses llm-wiki-kit as a hook-first living Markdown wiki for Codex
16
16
  - Keep \`llm-wiki/wiki/memory.md\` short. Link to important documents instead of copying long explanations.
17
17
  - Use hook-injected context when helpful, but answer the current user request first. Use \`llm-wiki context\`, \`llm-wiki lint\`, and \`llm-wiki consolidate\` only as agent maintenance helpers.
18
18
  - Hooks safely store redacted raw envelopes and work/decision-focused live Q&A. Simple answers, status checks, and keyword-only turns should not be promoted to live Q&A or durable wiki by default.
19
- - Hooks may queue durable cleanup candidates in \`llm-wiki/outputs/maintenance/queue.md\` at stop/start boundaries. Treat maintenance as a soft agent-side reminder; merge pending items only when relevant and mark them \`done\` or \`skipped\`.
19
+ - Hooks may queue durable cleanup candidates in \`llm-wiki/outputs/maintenance/queue.md\` at stop/start boundaries. Treat maintenance as a soft agent-side reminder; merge surfaced candidates when relevant or before ending the session, then mark them \`done\` or \`skipped\`.
20
20
  - Before creating new wiki pages, search existing pages and update the right one when possible. Reusable facts should not stay only in chunked \`outputs/questions/\`.
21
- - Store one-off work or decision records in \`llm-wiki/outputs/questions/YYYY-MM-DD/live-qa-001.md\` when needed. Merge reusable knowledge into \`wiki/architecture/\`, \`wiki/debugging/\`, \`wiki/decisions/\`, \`wiki/concepts/\`, or \`procedures/\` when approved or clearly important.
21
+ - Store one-off work or decision records in \`llm-wiki/outputs/questions/YYYY-MM-DD/live-qa-001.md\` when needed. Merge reusable knowledge into \`wiki/architecture/\`, \`wiki/debugging/\`, \`wiki/decisions/\`, \`wiki/concepts/\`, or \`procedures/\` when approved, hook-suggested, or clearly important.
22
22
  - Record verification commands, evidence files, and uncertainty. Mark inference explicitly and preserve contradictions in Open Questions or Contradictions.
23
23
  - Never store credentials, tokens, passwords, private keys, or raw \`.env\` contents. Store only redacted summaries when needed.
24
24
 
@@ -64,9 +64,10 @@ These rules replace older OMX/OMC/\`omx_wiki/\` rules for this project.
64
64
  - Important claims should include at least one of: \`source_ids\`, file paths, or verification commands.
65
65
  - When durable knowledge appears, search existing \`wiki/\` pages before creating a new page.
66
66
  - Do not promote simple answers, status checks, keyword-only replies, or one-off chat into live Q&A, \`wiki/queries\`, or maintenance.
67
- - Merge reusable knowledge into \`wiki/architecture/\`, \`wiki/debugging/\`, \`wiki/decisions/\`, \`wiki/concepts/\`, or \`procedures/\` based on importance and user consent flow.
68
- - Review \`outputs/maintenance/queue.md\` pending items only when related to the current request or when review is due. Merge into existing durable wiki pages, then mark items \`done\` or \`skipped\`.
69
- - Periodic maintenance is agent review, not automatic editing. Show only short reminders at \`SessionStart\`/\`InstructionsLoaded\`, and only show prompt-time reminders for wiki/maintenance-related user prompts.
67
+ - Hooks may flag work/decision turns as durable wiki candidates when they contain reusable architecture, debugging, policy, procedure, or decision signals. Treat those as review prompts, not automatic page creation.
68
+ - Merge reusable knowledge into \`wiki/architecture/\`, \`wiki/debugging/\`, \`wiki/decisions/\`, \`wiki/concepts/\`, or \`procedures/\` based on importance, hook suggestions, and user consent flow.
69
+ - Review \`outputs/maintenance/queue.md\` pending items when surfaced by hook context, related to the current request, or review is due. Merge into existing durable wiki pages, then mark items \`done\` or \`skipped\`.
70
+ - Periodic maintenance is agent review, not automatic editing. Show only short reminders at \`SessionStart\`/\`InstructionsLoaded\`, and compact prompt-time reminders when durable candidates or review thresholds need agent attention.
70
71
  - Keep \`wiki/memory.md\` short. Use links to current state and important documents instead of long explanations.
71
72
  - Preserve contradictions in \`Contradictions\` or \`Open Questions\`; do not overwrite them silently.
72
73
  - Do not store credentials, tokens, passwords, private keys, or raw \`.env\` contents in wiki.
@@ -105,7 +106,7 @@ superseded_by: []
105
106
  - query: use hook-injected context when useful, but answer the current request first. Manual commands are diagnostics, not required daily workflow.
106
107
  - lint: agent helper for user-requested or wiki maintenance work. Do not run it every turn.
107
108
  - consolidate: safely refresh generated blocks in \`memory.md\`/\`index.md\`. Do not overwrite handwritten sections or curated document bodies.
108
- - maintenance: \`outputs/maintenance/queue.md\` stores stop/start cleanup candidates. Review and update it only when it does not delay the current user request.
109
+ - maintenance: \`outputs/maintenance/queue.md\` stores stop/start cleanup candidates. Review surfaced durable candidates without delaying the current user request, then mark them \`done\` or \`skipped\`.
109
110
  `;
110
111
  }
111
112
 
@@ -198,7 +199,7 @@ export function procedure(name) {
198
199
  3. Create or update \`wiki/sources/<slug>.md\` only when a source summary is useful.
199
200
  4. Before creating a new page, look for related concept/entity/decision/architecture/debugging/context pages and update those first.
200
201
  5. Do not create duplicates. Merge facts into existing pages when they already exist.
201
- 6. Do not promote simple answers or one-off chat into durable wiki.
202
+ 6. Do not promote simple answers or one-off chat into durable wiki, but do review hook-suggested durable candidates for reusable facts.
202
203
  7. Important claims should record source references, confidence, memory type, importance, and verification status.
203
204
  8. When durable entry points change, update \`wiki/memory.md\` briefly or use \`llm-wiki consolidate\`.
204
205
  9. Add a short entry to \`wiki/log.md\` for meaningful wiki changes.
@@ -211,8 +212,8 @@ export function procedure(name) {
211
212
  4. Inspect raw sources only when exact evidence matters.
212
213
  5. Separate verified facts from inference.
213
214
  6. Use \`llm-wiki context "<query>"\` only when manual inspection is useful. Add \`--include-episodic\` only for historical query/context pages, and \`--include-archived\` only for archived/superseded pages.
214
- 7. Do not promote one-off answers, status checks, or keyword-only replies to durable wiki or live Q&A. Archive only work turns with tool evidence, changed-file evidence, verification, or structured decision/debugging conclusions.
215
- 8. Merge reusable facts into \`wiki/architecture/\`, \`wiki/debugging/\`, \`wiki/decisions/\`, \`wiki/concepts/\`, or \`procedures/\` based on importance and user consent flow.
215
+ 7. Do not promote one-off answers, status checks, or keyword-only replies to durable wiki or live Q&A. Archive only work turns with tool evidence, changed-file evidence, verification, structured decision/debugging conclusions, or hook-suggested durable candidates.
216
+ 8. Merge reusable facts into \`wiki/architecture/\`, \`wiki/debugging/\`, \`wiki/decisions/\`, \`wiki/concepts/\`, or \`procedures/\` based on importance, hook suggestions, and user consent flow.
216
217
  `,
217
218
  'lint.md': `# Lint Procedure
218
219
 
@@ -224,7 +225,7 @@ Periodic maintenance is an agent-side task, not a per-turn user command. When ne
224
225
 
225
226
  1. \`llm-wiki lint --workspace <project>\`
226
227
  2. \`llm-wiki maintenance --workspace <project>\`
227
- 3. Merge pending items into existing durable pages, then mark them \`done\` or \`skipped\`.
228
+ 3. Merge pending or hook-suggested durable candidates into existing durable pages when appropriate, then mark them \`done\` or \`skipped\`.
228
229
  4. \`llm-wiki consolidate --workspace <project> --dry-run\`
229
230
  5. Run \`llm-wiki consolidate --workspace <project>\` when the dry run is acceptable.
230
231