hippo-memory 3.8.0 → 3.9.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.
Files changed (58) hide show
  1. package/README.md +9 -8
  2. package/dist/api/agent-memories.d.ts +3 -2
  3. package/dist/api/agent-memories.js +21 -5
  4. package/dist/base/memory/agent-memory-report.js +1 -0
  5. package/dist/base/util/secret-detect.d.ts +8 -0
  6. package/dist/base/util/secret-detect.js +31 -11
  7. package/dist/base/util/version.d.ts +1 -1
  8. package/dist/base/util/version.js +1 -1
  9. package/dist/domain/agent-memories/apply.js +2 -1
  10. package/dist/domain/agent-memories/claude-code.d.ts +4 -0
  11. package/dist/domain/agent-memories/claude-code.js +24 -1
  12. package/dist/domain/agent-memories/container-steps.js +19 -3
  13. package/dist/domain/agent-memories/folder-store.d.ts +1 -0
  14. package/dist/domain/agent-memories/handover.js +2 -2
  15. package/dist/domain/agent-memories/keys.d.ts +4 -2
  16. package/dist/domain/agent-memories/keys.js +6 -3
  17. package/dist/domain/agent-memories/legacy.js +15 -8
  18. package/dist/domain/agent-memories/markdown.d.ts +5 -0
  19. package/dist/domain/agent-memories/markdown.js +7 -2
  20. package/dist/domain/agent-memories/note-parts.d.ts +4 -0
  21. package/dist/domain/agent-memories/note-parts.js +232 -0
  22. package/dist/domain/agent-memories/plan.d.ts +9 -4
  23. package/dist/domain/agent-memories/plan.js +35 -15
  24. package/dist/domain/agent-memories/source.d.ts +5 -0
  25. package/dist/domain/agent-memories/source.js +12 -0
  26. package/dist/domain/agent-memories/sync.js +5 -1
  27. package/dist/domain/agent-memories/types.d.ts +5 -1
  28. package/dist/store/sqlite/entries/set-aside.d.ts +2 -2
  29. package/dist/store/sqlite/entries/set-aside.js +5 -3
  30. package/dist/surface/capture/compact.d.ts +1 -1
  31. package/dist/surface/capture/compact.js +1 -1
  32. package/dist/surface/cli/doctor.js +1 -0
  33. package/dist/surface/cli/hook-runtime.d.ts +3 -0
  34. package/dist/surface/cli/hook-runtime.js +13 -0
  35. package/dist/surface/cli/hook.js +3 -0
  36. package/dist/surface/cli/hooks/note-import-worker.d.ts +15 -0
  37. package/dist/surface/cli/hooks/note-import-worker.js +44 -0
  38. package/dist/surface/cli/hooks/note-written.d.ts +4 -0
  39. package/dist/surface/cli/hooks/note-written.js +41 -0
  40. package/dist/surface/cli/hooks/post-compact.js +9 -18
  41. package/dist/surface/cli/hooks/session-end.js +2 -14
  42. package/dist/surface/cli/init.js +3 -0
  43. package/dist/surface/cli/setup.js +2 -0
  44. package/dist/surface/cli/verbs/sessions.d.ts +2 -0
  45. package/dist/surface/cli/verbs/sessions.js +16 -2
  46. package/dist/surface/cli/verbs.d.ts +2 -0
  47. package/dist/surface/hooks-install/json-hooks.js +2 -2
  48. package/dist/surface/hooks-install/rules/claude-hooks.d.ts +3 -2
  49. package/dist/surface/hooks-install/rules/claude-hooks.js +25 -2
  50. package/dist/surface/hooks-install/rules/install-plan.js +1 -0
  51. package/dist/surface/hooks-install/rules/json-hooks.d.ts +4 -2
  52. package/dist/surface/hooks-install/rules/json-hooks.js +3 -2
  53. package/dist/surface/hooks-install/rules/shared.d.ts +3 -0
  54. package/dist/surface/hooks-install/rules/shared.js +5 -0
  55. package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
  56. package/extensions/openclaw-plugin/package.json +1 -1
  57. package/openclaw.plugin.json +1 -1
  58. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ // The PostToolUse hook for Claude Code's memory notes: a write of one starts the import in a
2
+ // detached worker; any other write ends here, before a store opens.
3
+ import { isClaudeMemoryNote } from '../../../api/agent-memories.js';
4
+ import { isJsonObjectLiteral, isJsonString, tryParseJson } from '../../../base/util/json.js';
5
+ import { errorFields, errorMessage, log } from '../../../base/util/log.js';
6
+ import { processHomes } from '../../../host/agent-homes.js';
7
+ import { currentMachine } from '../../../infra/machine.js';
8
+ import { defaultNoteWrittenLogPath } from '../../hooks-install/rules/shared.js';
9
+ import { readHookStdin } from '../stdin.js';
10
+ import { stringFlag } from '../flag-values.js';
11
+ import { startNoteImport } from './note-import-worker.js';
12
+ function writtenFile(text) {
13
+ const payload = tryParseJson((text ?? '').trim());
14
+ if (!isJsonObjectLiteral(payload))
15
+ return null;
16
+ const input = payload.tool_input;
17
+ const file = isJsonObjectLiteral(input) ? input.file_path : undefined;
18
+ const { transcript_path: transcriptPath, cwd } = payload;
19
+ if (!isJsonString(file) || !isJsonString(transcriptPath))
20
+ return null;
21
+ return { file, transcriptPath, cwd: isJsonString(cwd) ? cwd : null };
22
+ }
23
+ /** Every path exits 0, so a failure never blocks the session. */
24
+ export async function handleNoteWritten({ flags }) {
25
+ try {
26
+ const { text } = await readHookStdin();
27
+ const written = writtenFile(text);
28
+ if (written === null || !isClaudeMemoryNote(written.file, currentMachine()))
29
+ return;
30
+ startNoteImport({
31
+ from: 'note-written',
32
+ transcriptPath: written.transcriptPath,
33
+ cwd: written.cwd,
34
+ logFile: stringFlag(flags, 'log-file') ?? defaultNoteWrittenLogPath(processHomes()),
35
+ });
36
+ }
37
+ catch (err) {
38
+ log.warn(`note-written skipped: ${errorMessage(err)}`, errorFields(err));
39
+ }
40
+ }
41
+ //# sourceMappingURL=note-written.js.map
@@ -1,35 +1,26 @@
1
1
  // The PostCompact hook: saves the compaction summary and its memories, then prints one plain line,
2
2
  // because Claude Code shows this hook's stdout as-is.
3
- import { importSessionFolder } from '../../../api/agent-memories.js';
4
- import { summaryLine } from '../../../base/memory/agent-memory-report.js';
5
- import { COMPACTION_DB_WAIT_MS } from '../../../base/session/compaction-timing.js';
6
- import { currentMachine } from '../../../infra/machine.js';
3
+ import { processHomes } from '../../../host/agent-homes.js';
7
4
  import { postCompactHook } from '../../capture/compact.js';
5
+ import { defaultPreCompactLogPath } from '../../hooks-install/rules/shared.js';
8
6
  import { readHookStdin } from '../stdin.js';
9
- import { cliHookRequest, cliStore, cliSyncOptions } from '../api-context.js';
7
+ import { cliHookRequest, cliStore } from '../api-context.js';
10
8
  import { stringFlag } from '../flag-values.js';
11
9
  import { hookStoreRoot } from '../hook-runtime.js';
10
+ import { startNoteImport } from './note-import-worker.js';
12
11
  /** Always exits 0. */
13
12
  export async function handlePostCompact({ hippoRoot, tenantId, flags, }) {
14
13
  const { text, timedOut } = await readHookStdin();
15
14
  const store = hookStoreRoot(hippoRoot);
15
+ const logFile = stringFlag(flags, 'log-file') ?? defaultPreCompactLogPath(processHomes());
16
16
  const line = await cliHookRequest(() => postCompactHook(store, cliStore(store), {
17
17
  tenantId,
18
18
  stdinText: text,
19
19
  stdinTimedOut: timedOut,
20
- logFile: stringFlag(flags, 'log-file'),
21
- // Passed in, since src/surface/capture/ importing the sync would close an import cycle.
22
- afterSave: async (transcriptPath, cwd, log) => {
23
- const sync = cliSyncOptions(tenantId, currentMachine(), {
24
- busyWaitMs: COMPACTION_DB_WAIT_MS,
25
- });
26
- const report = await importSessionFolder(store, transcriptPath, cwd, sync);
27
- const summary = summaryLine(report);
28
- if (summary !== null)
29
- log(summary);
30
- for (const warning of report.warnings)
31
- log(`agent memories: ${warning}`);
32
- },
20
+ logFile,
21
+ // A first import is thousands of rows, more than the hook's time limit, so a detached worker runs
22
+ // it; passed in, since src/surface/capture/ importing the worker would close an import cycle.
23
+ afterSave: (transcriptPath, cwd) => startNoteImport({ from: 'post-compact', transcriptPath, cwd, logFile }),
33
24
  }));
34
25
  if (line !== null && line !== undefined)
35
26
  console.log(line);
@@ -1,7 +1,6 @@
1
1
  // The SessionEnd hook: reads the payload inline, then hands the slow work to a detached worker
2
2
  // before the host exits.
3
3
  import * as fs from 'node:fs';
4
- import { spawn } from 'node:child_process';
5
4
  import { defaultSleepLogPath, resolveJsonHookPaths } from '../../hooks-install/json-hooks.js';
6
5
  import { copilotTranscriptFor } from '../../capture/copilot-transcript.js';
7
6
  import { SESSION_ID_RE } from '../../../base/util/session-id.js';
@@ -11,7 +10,7 @@ import { flushDeliveryRecorder, startDeliveryRecorder } from '../../../api/ledge
11
10
  import { normalizeHookPayload, readStdinBounded } from '../stdin.js';
12
11
  import { cliApiContext, cliHookRequest } from '../api-context.js';
13
12
  import { boolFlag, stringFlag } from '../flag-values.js';
14
- import { hookRuntime, hookStoreRoot, hostSessionId, payloadCwdRoot } from '../hook-runtime.js';
13
+ import { hookRuntime, hookStoreRoot, hostSessionId, payloadCwdRoot, spawnDetachedWorker, } from '../hook-runtime.js';
15
14
  import { handleSessionEndWorker } from './session-end-worker.js';
16
15
  /** Copilot's hook command and OpenCode's plugin carry no path, since one quoted into them would
17
16
  * need escaping for each shell. Copilot's log goes where its hook table used to point,
@@ -61,7 +60,7 @@ function workerTranscriptPath(input, runtime) {
61
60
  }
62
61
  async function runSessionEndWorker(worker, { root, tenantId, flags, rec }) {
63
62
  try {
64
- spawnSessionEndWorker(sessionEndWorkerArgs(worker));
63
+ spawnDetachedWorker('session-end', sessionEndWorkerArgs(worker));
65
64
  }
66
65
  catch (err) {
67
66
  log.debug(`session-end: the worker did not spawn, running inline: ${errorMessage(err)}`, errorFields(err));
@@ -138,17 +137,6 @@ function inlineWorkerFlags(flags, w) {
138
137
  out['no-share'] = true;
139
138
  return out;
140
139
  }
141
- function spawnSessionEndWorker(workerArgs) {
142
- const child = spawn(process.execPath, workerArgs, {
143
- detached: true,
144
- stdio: 'ignore',
145
- windowsHide: true,
146
- });
147
- // An async spawn failure arrives as an 'error' event, which with no listener is an uncaught
148
- // exception.
149
- child.on('error', (err) => log.warn(`hippo session-end: the worker did not start: ${errorMessage(err)}`, errorFields(err)));
150
- child.unref();
151
- }
152
140
  /** The input of a VS Code Stop payload with a session id that can name the lock file; null makes
153
141
  * turn mode a silent no-op. */
154
142
  function vscodeStopInput(raw) {
@@ -380,6 +380,9 @@ function installClaudeCodeSettingsHooks(hook) {
380
380
  if (result.installedCaptureError) {
381
381
  console.log(` Auto-installed hippo capture-error PostToolUseFailure hook in ${hook} settings`);
382
382
  }
383
+ if (result.installedNoteWritten) {
384
+ console.log(` Auto-installed hippo note-written PostToolUse hook in ${hook} settings`);
385
+ }
383
386
  if (result.migratedFromStop) {
384
387
  console.log(` Migrated legacy Stop hook → SessionEnd (no longer runs every turn)`);
385
388
  }
@@ -116,6 +116,8 @@ function setupJsonTool(tool, dryRun) {
116
116
  bits.push('PostCompact (post-compact)');
117
117
  if (result.installedCaptureError)
118
118
  bits.push('PostToolUseFailure (capture-error)');
119
+ if (result.installedNoteWritten)
120
+ bits.push('PostToolUse (note-written)');
119
121
  if (result.migratedFromStop)
120
122
  bits.push('migrated legacy Stop');
121
123
  if (result.migratedSplitSessionEnd)
@@ -25,6 +25,8 @@ export declare const SESSION_VERBS: {
25
25
  'pre-compact': VerbSpec;
26
26
  'compact-resume': VerbSpec;
27
27
  'post-compact': VerbSpec;
28
+ 'note-written': VerbSpec;
29
+ '__note-import-worker': VerbSpec;
28
30
  'codex-run': VerbSpec;
29
31
  '__codex-session-end-worker': VerbSpec;
30
32
  hook: VerbSpec;
@@ -307,7 +307,7 @@ export const SESSION_VERBS = {
307
307
  usage: [
308
308
  `
309
309
  setup One-shot: detect installed AI tools and install their hooks:
310
- claude-code gets 8 hooks in $CLAUDE_CONFIG_DIR/settings.json
310
+ claude-code gets 9 hooks in $CLAUDE_CONFIG_DIR/settings.json
311
311
  (~/.claude by default), opencode a plugin, codex 2 hooks in
312
312
  its hooks.json plus a launcher wrapper, copilot 4 hooks, the
313
313
  MCP server and an instructions block under $COPILOT_HOME
@@ -400,6 +400,20 @@ export const SESSION_VERBS = {
400
400
  --log-file <p> Same log path as pre-compact (default: ~/.hippo/logs/pre-compact.log)`,
401
401
  ],
402
402
  }),
403
+ 'note-written': verb(() => import('../hooks/note-written.js'), 'handleNoteWritten', {
404
+ readOnly: 'skip',
405
+ flags: { values: ['log-file'] },
406
+ usage: [
407
+ `
408
+ note-written PostToolUse hook: when Claude Code writes a memory note, import it in a
409
+ detached worker (any other write exits at once)
410
+ --log-file <p> Where the worker logs (default: ~/.hippo/logs/note-written.log)`,
411
+ ],
412
+ }),
413
+ '__note-import-worker': verb(() => import('../hooks/note-import-worker.js'), 'handleNoteImportWorker', {
414
+ readOnly: 'skip',
415
+ flags: { values: ['cwd', 'from', 'log-file', 'transcript'] },
416
+ }),
403
417
  'codex-run': verb(() => import('../hooks/codex-run.js'), 'handleCodexRun', {
404
418
  flags: {},
405
419
  usage: [
@@ -418,7 +432,7 @@ export const SESSION_VERBS = {
418
432
  hook <sub> [target] Manage framework integrations
419
433
  hook list Show available hooks
420
434
  hook install <target> Install hook (claude-code|codex|copilot|cursor|openclaw|opencode|pi)
421
- claude-code adds 8 hooks to $CLAUDE_CONFIG_DIR/settings.json
435
+ claude-code adds 9 hooks to $CLAUDE_CONFIG_DIR/settings.json
422
436
  (~/.claude by default); opencode installs a plugin; codex
423
437
  adds 2 hooks to $CODEX_HOME/hooks.json (trust them once in /hooks) and
424
438
  wraps the detected launcher in place; copilot writes
@@ -42,6 +42,8 @@ export declare const COMMANDS: {
42
42
  'pre-compact': import("./verb-row.js").VerbSpec;
43
43
  'compact-resume': import("./verb-row.js").VerbSpec;
44
44
  'post-compact': import("./verb-row.js").VerbSpec;
45
+ 'note-written': import("./verb-row.js").VerbSpec;
46
+ '__note-import-worker': import("./verb-row.js").VerbSpec;
45
47
  'codex-run': import("./verb-row.js").VerbSpec;
46
48
  '__codex-session-end-worker': import("./verb-row.js").VerbSpec;
47
49
  hook: import("./verb-row.js").VerbSpec;
@@ -6,7 +6,7 @@ import { readJsonFile, tryReadJsonFile } from '../../host/json-file.js';
6
6
  import { errorFields, errorMessage, log } from '../../base/util/log.js';
7
7
  import { processHomes } from '../../host/agent-homes.js';
8
8
  import { canEditHooks, jsonHookPathsOn, planCopilotHooks, planHookRemoval, planJsonHooks, settingsText, } from './rules/json-hooks.js';
9
- import { defaultPreCompactLogPath, sleepLogPathOn } from './rules/shared.js';
9
+ import { defaultNoteWrittenLogPath, defaultPreCompactLogPath, sleepLogPathOn, } from './rules/shared.js';
10
10
  // What a caller of the installer names beside it: the reminder Codex needs before it runs a new hook.
11
11
  export { CODEX_TRUST_LINE } from './rules/shared.js';
12
12
  /** The paths for `target` under this process's home folder; reads and writes nothing. */
@@ -35,7 +35,7 @@ export function installJsonHooks(target) {
35
35
  fs.mkdirSync(dir, { recursive: true });
36
36
  const plan = target === 'copilot'
37
37
  ? planCopilotHooks(paths.settings, fs.existsSync(paths.settings) ? fs.readFileSync(paths.settings, 'utf8') : null)
38
- : planJsonHooks(target, paths, readSettings(paths.settings), defaultPreCompactLogPath(processHomes()));
38
+ : planJsonHooks(target, paths, readSettings(paths.settings), defaultPreCompactLogPath(processHomes()), defaultNoteWrittenLogPath(processHomes()));
39
39
  if (plan.write !== null)
40
40
  writeSettingsFile(paths.settings, plan.write);
41
41
  return plan.result;
@@ -1,12 +1,13 @@
1
1
  import { type JsonObject } from '../../../base/util/json.js';
2
2
  import { type HookInstallPlan } from './install-plan.js';
3
- /** Where Claude Code's settings live and where its session and compaction hooks log. */
3
+ /** Where Claude Code's settings live and where its session, compaction and note hooks log. */
4
4
  interface ClaudeHookPaths {
5
5
  readonly settingsPath: string;
6
6
  readonly logFile: string;
7
7
  readonly compactLog: string;
8
+ readonly noteLog: string;
8
9
  }
9
- export declare function planClaudeCodeHooks(settings: JsonObject, { settingsPath, logFile, compactLog }: ClaudeHookPaths): HookInstallPlan;
10
+ export declare function planClaudeCodeHooks(settings: JsonObject, { settingsPath, logFile, compactLog, noteLog }: ClaudeHookPaths): HookInstallPlan;
10
11
  /** The Claude Code handlers uninstall kept that still mention a hippo command (`nice hippo
11
12
  * sleep`, `pnpm exec hippo ...`), so the user can be told to remove them by hand. */
12
13
  export declare function keptHippoHandlers(hooks: JsonObject): string[];
@@ -1,5 +1,5 @@
1
1
  // Claude Code's hooks: install, migrate older forms, and remove hippo's handlers.
2
- import { HIPPO_SLEEP_MARKER, HIPPO_LAST_SLEEP_MARKER, HIPPO_SESSION_RULES_MARKER, HIPPO_SESSION_RULES_COMMAND, HIPPO_CAPTURE_MARKER, HIPPO_SESSION_END_MARKER, HIPPO_PINNED_INJECT_MARKER, HIPPO_PINNED_INJECT_COMMAND, HIPPO_PRE_COMPACT_MARKER, HIPPO_COMPACT_RESUME_MARKER, HIPPO_CAPTURE_ERROR_MARKER, HIPPO_POST_COMPACT_MARKER, } from './shared.js';
2
+ import { HIPPO_SLEEP_MARKER, HIPPO_LAST_SLEEP_MARKER, HIPPO_SESSION_RULES_MARKER, HIPPO_SESSION_RULES_COMMAND, HIPPO_CAPTURE_MARKER, HIPPO_SESSION_END_MARKER, HIPPO_PINNED_INJECT_MARKER, HIPPO_PINNED_INJECT_COMMAND, HIPPO_PRE_COMPACT_MARKER, HIPPO_COMPACT_RESUME_MARKER, HIPPO_CAPTURE_ERROR_MARKER, HIPPO_POST_COMPACT_MARKER, HIPPO_NOTE_WRITTEN_MARKER, } from './shared.js';
3
3
  import { isJsonString, isJsonObjectLiteral, } from '../../../base/util/json.js';
4
4
  import { handlerCommands, hookArrayContains, isHippoCommand, runsHippo, stripHandlers, withoutHandlers, } from './hook-handlers.js';
5
5
  import { HOOK_LONG_TIMEOUT_SECONDS, HOOK_MEDIUM_TIMEOUT_SECONDS, HOOK_SHORT_TIMEOUT_SECONDS, ensureHooksObject, nothingInstalled, } from './install-plan.js';
@@ -82,6 +82,7 @@ const CLAUDE_HOOK_MARKERS = [
82
82
  ['PreCompact', [HIPPO_PRE_COMPACT_MARKER]],
83
83
  ['PostCompact', [HIPPO_POST_COMPACT_MARKER]],
84
84
  ['PostToolUseFailure', [HIPPO_CAPTURE_ERROR_MARKER]],
85
+ ['PostToolUse', [HIPPO_NOTE_WRITTEN_MARKER]],
85
86
  ['Stop', [HIPPO_SLEEP_MARKER]],
86
87
  ];
87
88
  // Stop is only ever migrated away, so install never appends to it and a Stop that is not a list
@@ -121,7 +122,7 @@ function appendCompactionHooks(hooks, compactLog) {
121
122
  const installedPostCompact = appendHookIfMissing(hooks, 'PostCompact', HIPPO_POST_COMPACT_MARKER, claudeCommandGroup(`hippo post-compact --log-file "${compactLog}"`, HOOK_MEDIUM_TIMEOUT_SECONDS));
122
123
  return { installedPreCompact, installedCompactResume, installedPostCompact };
123
124
  }
124
- export function planClaudeCodeHooks(settings, { settingsPath, logFile, compactLog }) {
125
+ export function planClaudeCodeHooks(settings, { settingsPath, logFile, compactLog, noteLog }) {
125
126
  const merge = ensureHooksObject(settings, CLAUDE_APPENDED_EVENTS);
126
127
  if (merge === null)
127
128
  return invalidClaudeSettings(settingsPath);
@@ -131,6 +132,7 @@ export function planClaudeCodeHooks(settings, { settingsPath, logFile, compactLo
131
132
  const { installedSessionEnd, installedSessionStart, installedSessionRules, migratedPinnedInjectRecent, installedUserPromptSubmit, } = appendSessionHooks(hooks, logFile);
132
133
  const { installedPreCompact, installedCompactResume, installedPostCompact } = appendCompactionHooks(hooks, compactLog);
133
134
  const installedCaptureError = appendCaptureErrorHook(hooks);
135
+ const installedNoteWritten = appendNoteWrittenHook(hooks, noteLog);
134
136
  const result = {
135
137
  target: 'claude-code',
136
138
  settingsPath,
@@ -142,6 +144,7 @@ export function planClaudeCodeHooks(settings, { settingsPath, logFile, compactLo
142
144
  installedCompactResume,
143
145
  installedPostCompact,
144
146
  installedCaptureError,
147
+ installedNoteWritten,
145
148
  migratedPinnedInjectRecent,
146
149
  ...migration,
147
150
  invalidJson: false,
@@ -160,6 +163,26 @@ function appendCaptureErrorHook(hooks) {
160
163
  // hook the plugin ships.
161
164
  return appendHookIfMissing(hooks, 'PostToolUseFailure', HIPPO_CAPTURE_ERROR_MARKER, claudeCommandGroup('hippo capture-error', HOOK_MEDIUM_TIMEOUT_SECONDS, '.*'));
162
165
  }
166
+ // Measured on Claude Code 2.1.326: an `Edit(...)` rule does not fire for a Write call, so each tool
167
+ // gets its own rule; `//**` reaches any config folder.
168
+ const NOTE_WRITTEN_IFS = [
169
+ 'Write(//**/projects/*/memory/*.md)',
170
+ 'Edit(//**/projects/*/memory/*.md)',
171
+ ];
172
+ function appendNoteWrittenHook(hooks, noteLog) {
173
+ // PostToolUse: a memory note Claude Code just wrote reaches hippo at once, in a detached worker
174
+ // that `hippo note-written` starts. Versions that ignore `if` still get the hook's own path check.
175
+ const command = `hippo note-written --log-file "${noteLog}"`;
176
+ return appendHookIfMissing(hooks, 'PostToolUse', HIPPO_NOTE_WRITTEN_MARKER, {
177
+ matcher: 'Edit|Write|MultiEdit',
178
+ hooks: NOTE_WRITTEN_IFS.map((condition) => ({
179
+ type: 'command',
180
+ command,
181
+ timeout: HOOK_MEDIUM_TIMEOUT_SECONDS,
182
+ if: condition,
183
+ })),
184
+ });
185
+ }
163
186
  /** The Claude Code handlers uninstall kept that still mention a hippo command (`nice hippo
164
187
  * sleep`, `pnpm exec hippo ...`), so the user can be told to remove them by hand. */
165
188
  export function keptHippoHandlers(hooks) {
@@ -16,6 +16,7 @@ export function nothingInstalled(target, settingsPath) {
16
16
  installedCompactResume: false,
17
17
  installedPostCompact: false,
18
18
  installedCaptureError: false,
19
+ installedNoteWritten: false,
19
20
  migratedPinnedInjectRecent: false,
20
21
  migratedFromStop: false,
21
22
  migratedLegacySessionEnd: false,
@@ -28,6 +28,8 @@ export interface InstallResult {
28
28
  installedPostCompact: boolean;
29
29
  /** PostToolUseFailure -> `hippo capture-error` (failed tool calls become error memories). */
30
30
  installedCaptureError: boolean;
31
+ /** PostToolUse -> `hippo note-written` (a memory note Claude Code writes is imported at once). */
32
+ installedNoteWritten: boolean;
31
33
  migratedPinnedInjectRecent: boolean;
32
34
  migratedFromStop: boolean;
33
35
  migratedLegacySessionEnd: boolean;
@@ -45,8 +47,8 @@ export declare function settingsText(settings: JsonValue): string;
45
47
  export declare function planCopilotHooks(settingsPath: string, current: string | null): HookInstallPlan;
46
48
  /** Adds hippo's hooks to parsed settings, which it edits in place, and migrates older hippo
47
49
  * entries; `settings` is undefined for a file that is not JSON, which stays untouched.
48
- * `compactLog` is where the compaction hooks log. */
49
- export declare function planJsonHooks(target: 'claude-code' | 'codex', paths: Pick<JsonHookPaths, 'settings' | 'logFile'>, settings: JsonValue | undefined, compactLog: string): HookInstallPlan;
50
+ * `compactLog` is where the compaction hooks log, `noteLog` where the note hook does. */
51
+ export declare function planJsonHooks(target: 'claude-code' | 'codex', paths: Pick<JsonHookPaths, 'settings' | 'logFile'>, settings: JsonValue | undefined, compactLog: string, noteLog: string): HookInstallPlan;
50
52
  /** What uninstall does to parsed settings, edited in place: the settings to write (null when
51
53
  * nothing changed) and, for Claude Code, the kept handlers that still name a hippo command. */
52
54
  export interface HookRemovalPlan {
@@ -59,8 +59,8 @@ export function planCopilotHooks(settingsPath, current) {
59
59
  }
60
60
  /** Adds hippo's hooks to parsed settings, which it edits in place, and migrates older hippo
61
61
  * entries; `settings` is undefined for a file that is not JSON, which stays untouched.
62
- * `compactLog` is where the compaction hooks log. */
63
- export function planJsonHooks(target, paths, settings, compactLog) {
62
+ * `compactLog` is where the compaction hooks log, `noteLog` where the note hook does. */
63
+ export function planJsonHooks(target, paths, settings, compactLog, noteLog) {
64
64
  const invalid = {
65
65
  result: { ...nothingInstalled(target, paths.settings), invalidJson: true },
66
66
  write: null,
@@ -75,6 +75,7 @@ export function planJsonHooks(target, paths, settings, compactLog) {
75
75
  settingsPath: paths.settings,
76
76
  logFile: paths.logFile,
77
77
  compactLog,
78
+ noteLog,
78
79
  });
79
80
  }
80
81
  /** Removes hippo's own hook handlers and keeps every other handler. */
@@ -20,6 +20,7 @@ export declare const HIPPO_PRE_COMPACT_MARKER = "hippo pre-compact";
20
20
  export declare const HIPPO_COMPACT_RESUME_MARKER = "hippo compact-resume";
21
21
  export declare const HIPPO_CAPTURE_ERROR_MARKER = "hippo capture-error";
22
22
  export declare const HIPPO_POST_COMPACT_MARKER = "hippo post-compact";
23
+ export declare const HIPPO_NOTE_WRITTEN_MARKER = "hippo note-written";
23
24
  /** Copilot's config folder: $COPILOT_HOME, else ~/.copilot under the profile folder, as the
24
25
  * Copilot apps resolve it (a HOME that differs from the profile must not move it). */
25
26
  export declare function copilotHomeDir({ home, env }: Homes): string;
@@ -42,4 +43,6 @@ export declare function sleepLogPathOn(homes: Homes): string;
42
43
  * because `hippo last-sleep` truncates that one every SessionStart. Nothing reads it
43
44
  * programmatically; overridden by `--log-file`. */
44
45
  export declare function defaultPreCompactLogPath(homes: Homes): string;
46
+ /** Where `hippo note-written` logs each import; overridden by `--log-file`. */
47
+ export declare function defaultNoteWrittenLogPath(homes: Homes): string;
45
48
  //# sourceMappingURL=shared.d.ts.map
@@ -13,6 +13,7 @@ export const HIPPO_PRE_COMPACT_MARKER = 'hippo pre-compact';
13
13
  export const HIPPO_COMPACT_RESUME_MARKER = 'hippo compact-resume';
14
14
  export const HIPPO_CAPTURE_ERROR_MARKER = 'hippo capture-error';
15
15
  export const HIPPO_POST_COMPACT_MARKER = 'hippo post-compact';
16
+ export const HIPPO_NOTE_WRITTEN_MARKER = 'hippo note-written';
16
17
  /** Copilot's config folder: $COPILOT_HOME, else ~/.copilot under the profile folder, as the
17
18
  * Copilot apps resolve it (a HOME that differs from the profile must not move it). */
18
19
  export function copilotHomeDir({ home, env }) {
@@ -46,4 +47,8 @@ export function sleepLogPathOn(homes) {
46
47
  export function defaultPreCompactLogPath(homes) {
47
48
  return path.join(userHome(homes), HIPPO_DIR, 'logs', 'pre-compact.log');
48
49
  }
50
+ /** Where `hippo note-written` logs each import; overridden by `--log-file`. */
51
+ export function defaultNoteWrittenLogPath(homes) {
52
+ return path.join(userHome(homes), HIPPO_DIR, 'logs', 'note-written.log');
53
+ }
49
54
  //# sourceMappingURL=shared.js.map
@@ -2,7 +2,7 @@
2
2
  "id": "hippo-memory",
3
3
  "name": "Hippo Memory",
4
4
  "description": "One memory for every agent you'll ever use. Hippo writes what you teach a coding agent into a store in your repo, and your other agents read that same store.",
5
- "version": "3.8.0",
5
+ "version": "3.9.0",
6
6
 
7
7
  "configSchema": {
8
8
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hippo-memory",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "type": "module",
5
5
  "description": "One memory for every agent you'll ever use. Hippo writes what you teach a coding agent into a store in your repo, and your other agents read that same store.",
6
6
  "main": "index.ts",
@@ -2,7 +2,7 @@
2
2
  "id": "hippo-memory",
3
3
  "name": "Hippo Memory",
4
4
  "description": "One memory for every agent you'll ever use. Hippo writes what you teach a coding agent into a store in your repo, and your other agents read that same store.",
5
- "version": "3.8.0",
5
+ "version": "3.9.0",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hippo-memory",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "One memory for every agent you'll ever use. Hippo writes what you teach a coding agent into a store in your repo, and your other agents read that same store.",
5
5
  "mcpName": "io.github.kitfunso/hippo-memory",
6
6
  "type": "module",