agent-knowledge 1.9.4 → 1.9.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.5 (2026-04-20) — PreCompact nudge schema fix
4
+
5
+ ### Fixed
6
+
7
+ - **`scripts/hooks/precompact-flush.mjs` now emits the memory-flush nudge as top-level `systemMessage` instead of `hookSpecificOutput.additionalContext`.** Claude Code's PreCompact hook schema only accepts `additionalContext` under `hookSpecificOutput` for `UserPromptSubmit` and `PostToolUse` events — PreCompact has no `additionalContext` shape, so the host was rejecting every response with `Hook JSON output validation failed — (root): Invalid input` and dropping the nudge on the floor. The disk-dump side-effect still ran (that's why the companion `precompact-distill.mjs` reported success), but the pre-compaction "save your context" reminder never reached the transcript. Switched to `systemMessage`, which is accepted for all event types and lands in the transcript ahead of the compacted summary, so the reminder still survives compaction.
8
+
9
+ ### Tests
10
+
11
+ New assertions cover: (a) PreCompact nudge lands in `systemMessage` and nothing is emitted under `hookSpecificOutput`, (b) `AGENT_KNOWLEDGE_PRECOMPACT_NUDGE=0` suppresses the nudge entirely. Guards against regressing to the broken `hookSpecificOutput.additionalContext` shape.
12
+
3
13
  ## 1.9.4 (2026-04-19) — visible knowledge-hook feedback + L0-only SessionStart
4
14
 
5
15
  ### Changed
@@ -2,7 +2,7 @@
2
2
  "id": "agent-knowledge",
3
3
  "name": "Knowledge",
4
4
  "icon": "psychology",
5
- "version": "1.9.4",
5
+ "version": "1.9.5",
6
6
  "description": "Knowledge base — entries, sessions, search, graph relationships",
7
7
  "ui": "./dist/ui/app.js",
8
8
  "css": "./dist/ui/styles.css",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-knowledge",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "description": "Cross-session memory and recall for AI agents — git-synced knowledge base, knowledge graph, confidence scoring, hybrid semantic+TF-IDF search, auto-distillation with secrets scrubbing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,11 +9,14 @@
9
9
  // later distillation/promotion has a durable anchor even if the host
10
10
  // garbage-collects the transcript.
11
11
  //
12
- // 2. Inject a short "save-your-context" nudge into the host's PreCompact
13
- // response (`hookSpecificOutput.additionalContext`). The compaction pass
14
- // is about to summarize — anything important and unsaved should be
15
- // written to the knowledge base NOW via `knowledge(action="write", …)`.
16
- // Pre-compaction memory-flush primitive.
12
+ // 2. Emit a short "save-your-context" nudge as a top-level `systemMessage`.
13
+ // The compaction pass is about to summarize — anything important and
14
+ // unsaved should be written to the knowledge base NOW via
15
+ // `knowledge(action="write", …)`. Pre-compaction memory-flush primitive.
16
+ // (PreCompact rejects `hookSpecificOutput.additionalContext` — only
17
+ // UserPromptSubmit/PostToolUse accept that shape — so the nudge rides
18
+ // in `systemMessage`, which lands in the transcript and survives
19
+ // compaction.)
17
20
  //
18
21
  // Disable the nudge by exporting AGENT_KNOWLEDGE_PRECOMPACT_NUDGE=0 (the disk
19
22
  // dump still runs). Set AGENT_KNOWLEDGE_PRECOMPACT_NUDGE=off to suppress both.
@@ -38,28 +41,14 @@ const nudgeEnabled = NUDGE_MODE !== '0' && NUDGE_MODE !== 'false' && NUDGE_MODE
38
41
  const diskDumpEnabled = NUDGE_MODE !== 'off';
39
42
 
40
43
  const NUDGE_TEXT = [
41
- '## PreCompact — memory-flush nudge',
42
- '',
43
- 'The host is about to compact the conversation. Anything you learned this',
44
- 'turn that the next session will need MUST be written to the knowledge base',
45
- 'before the summary replaces the transcript. Use:',
46
- '',
47
- ' `knowledge(action="write", category="decisions"|"notes"|"workflows", filename=..., content=...)`',
48
- '',
49
- 'Candidates worth a write: architectural decisions, non-obvious gotchas,',
50
- 'hard-won commands, people/ownership facts, project state. Skip transient',
51
- 'things (file diffs, TODO lists, in-flight plans — plan/task systems own those).',
52
- ].join('\n');
53
-
54
- function emitResult(additionalContext) {
55
- const payload = additionalContext
56
- ? {
57
- hookSpecificOutput: {
58
- hookEventName: 'PreCompact',
59
- additionalContext,
60
- },
61
- }
62
- : {};
44
+ 'knowledge: PreCompact — flush durable facts to the KB before summary replaces the transcript.',
45
+ 'Write architectural decisions, non-obvious gotchas, hard-won commands, people/ownership facts, project state via',
46
+ '`knowledge(action="write", category="decisions"|"notes"|"workflows", filename=..., content=...)`.',
47
+ 'Skip transient things (file diffs, TODO lists, in-flight plans — plan/task systems own those).',
48
+ ].join(' ');
49
+
50
+ function emitResult(nudge) {
51
+ const payload = nudge ? { systemMessage: nudge } : {};
63
52
  process.stdout.write(JSON.stringify(payload) + '\n');
64
53
  process.exit(0);
65
54
  }