hippo-memory 3.1.0 → 3.2.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 (78) hide show
  1. package/dist/api/context/context-plan.d.ts +2 -0
  2. package/dist/api/context/context-plan.js +10 -6
  3. package/dist/api/context/context-pools.d.ts +3 -0
  4. package/dist/api/context/context-pools.js +12 -0
  5. package/dist/api/context/context-render.d.ts +6 -0
  6. package/dist/api/context/context-render.js +24 -9
  7. package/dist/api/context/context-select.js +12 -7
  8. package/dist/api/context/context-types.d.ts +6 -3
  9. package/dist/api/context/context.js +5 -4
  10. package/dist/api/context/user-rule.d.ts +12 -0
  11. package/dist/api/context/user-rule.js +24 -0
  12. package/dist/api/context/user-rules-get.d.ts +10 -0
  13. package/dist/api/context/user-rules-get.js +25 -0
  14. package/dist/api/index.d.ts +1 -0
  15. package/dist/api/index.js +1 -0
  16. package/dist/api/memories/remember.js +2 -2
  17. package/dist/api/prompt-hook.d.ts +11 -0
  18. package/dist/api/prompt-hook.js +26 -10
  19. package/dist/api/recall/rank-stages.js +2 -2
  20. package/dist/api/session-end.d.ts +1 -1
  21. package/dist/api/session-end.js +5 -3
  22. package/dist/base/memory/entry.d.ts +5 -0
  23. package/dist/base/memory/entry.js +10 -3
  24. package/dist/base/memory/markdown-delimiters.d.ts +15 -0
  25. package/dist/base/memory/markdown-delimiters.js +94 -0
  26. package/dist/base/memory/memory-audit.js +4 -4
  27. package/dist/base/memory/memory-quality.d.ts +12 -0
  28. package/dist/base/memory/memory-quality.js +92 -3
  29. package/dist/base/ports/store/ledger.d.ts +2 -2
  30. package/dist/base/ports/store/types.d.ts +2 -1
  31. package/dist/base/rank/prompt-recall.d.ts +16 -3
  32. package/dist/base/rank/prompt-recall.js +47 -7
  33. package/dist/base/util/tokenize.d.ts +29 -0
  34. package/dist/base/util/tokenize.js +68 -5
  35. package/dist/base/util/version.d.ts +1 -1
  36. package/dist/base/util/version.js +1 -1
  37. package/dist/db/meta.d.ts +1 -0
  38. package/dist/db/meta.js +1 -0
  39. package/dist/domain/consolidate/conflicts.js +2 -2
  40. package/dist/domain/learn/forward-claim-detector.js +4 -2
  41. package/dist/domain/learn/invalidation.js +5 -2
  42. package/dist/domain/search/bm25.js +3 -3
  43. package/dist/store/rules/windows.d.ts +3 -0
  44. package/dist/store/rules/windows.js +3 -0
  45. package/dist/store/sqlite/audit/audit-maintenance.js +16 -13
  46. package/dist/store/sqlite/ledger/token-ledger.js +7 -1
  47. package/dist/store/sqlite/recall/candidates.js +1 -0
  48. package/dist/store/sqlite/recall/search-rows.d.ts +2 -2
  49. package/dist/store/sqlite/recall/search-rows.js +62 -26
  50. package/dist/store/sqlite/sharing/copy-rows.d.ts +1 -0
  51. package/dist/store/sqlite/sharing/copy-rows.js +2 -1
  52. package/dist/surface/capture/command.d.ts +11 -1
  53. package/dist/surface/capture/command.js +48 -17
  54. package/dist/surface/capture/extract.d.ts +13 -2
  55. package/dist/surface/capture/extract.js +251 -33
  56. package/dist/surface/capture/session-texts.js +8 -6
  57. package/dist/surface/capture/transcript.js +6 -1
  58. package/dist/surface/cli/context.d.ts +7 -0
  59. package/dist/surface/cli/context.js +17 -10
  60. package/dist/surface/cli/hook.js +3 -0
  61. package/dist/surface/cli/hooks/session-end-worker.js +5 -3
  62. package/dist/surface/cli/init.js +3 -0
  63. package/dist/surface/cli/memory-import.js +2 -1
  64. package/dist/surface/cli/session-rules.d.ts +3 -0
  65. package/dist/surface/cli/session-rules.js +45 -0
  66. package/dist/surface/cli/setup.js +2 -0
  67. package/dist/surface/cli/verbs/sessions.d.ts +1 -0
  68. package/dist/surface/cli/verbs/sessions.js +10 -2
  69. package/dist/surface/cli/verbs.d.ts +1 -0
  70. package/dist/surface/hooks-install/rules/claude-hooks.js +11 -3
  71. package/dist/surface/hooks-install/rules/install-plan.js +1 -0
  72. package/dist/surface/hooks-install/rules/json-hooks.d.ts +2 -0
  73. package/dist/surface/hooks-install/rules/shared.d.ts +2 -0
  74. package/dist/surface/hooks-install/rules/shared.js +2 -0
  75. package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
  76. package/extensions/openclaw-plugin/package.json +1 -1
  77. package/openclaw.plugin.json +1 -1
  78. package/package.json +1 -1
@@ -301,7 +301,7 @@ export const SESSION_VERBS = {
301
301
  usage: [
302
302
  `
303
303
  setup One-shot: detect installed AI tools and install their hooks:
304
- claude-code gets 7 hooks in $CLAUDE_CONFIG_DIR/settings.json
304
+ claude-code gets 8 hooks in $CLAUDE_CONFIG_DIR/settings.json
305
305
  (~/.claude by default), opencode a plugin, codex 2 hooks in
306
306
  its hooks.json plus a launcher wrapper, copilot 4 hooks, the
307
307
  MCP server and an instructions block under $COPILOT_HOME
@@ -323,6 +323,14 @@ export const SESSION_VERBS = {
323
323
  --keep Print without clearing`,
324
324
  ],
325
325
  }),
326
+ 'session-rules': verb(() => import('../session-rules.js'), 'handleSessionRules', {
327
+ flags: {},
328
+ usage: [
329
+ `
330
+ session-rules SessionStart hook: send every rule you stated to this project as Claude Code
331
+ session context, from the project store and the global one`,
332
+ ],
333
+ }),
326
334
  'session-end': verb(() => import('../hooks/session-end.js'), 'handleSessionEnd', {
327
335
  // Its sleep step reads --dry-run, but the capture after it writes for real.
328
336
  dryRun: false,
@@ -399,7 +407,7 @@ export const SESSION_VERBS = {
399
407
  hook <sub> [target] Manage framework integrations
400
408
  hook list Show available hooks
401
409
  hook install <target> Install hook (claude-code|codex|copilot|cursor|openclaw|opencode|pi)
402
- claude-code adds 7 hooks to $CLAUDE_CONFIG_DIR/settings.json
410
+ claude-code adds 8 hooks to $CLAUDE_CONFIG_DIR/settings.json
403
411
  (~/.claude by default); opencode installs a plugin; codex
404
412
  adds 2 hooks to $CODEX_HOME/hooks.json (trust them once in /hooks) and
405
413
  wraps the detected launcher in place; copilot writes
@@ -36,6 +36,7 @@ export declare const COMMANDS: {
36
36
  capture: import("./verb-row.js").VerbSpec;
37
37
  setup: import("./verb-row.js").VerbSpec;
38
38
  'last-sleep': import("./verb-row.js").VerbSpec;
39
+ 'session-rules': import("./verb-row.js").VerbSpec;
39
40
  'session-end': import("./verb-row.js").VerbSpec;
40
41
  '__session-end-worker': import("./verb-row.js").VerbSpec;
41
42
  'pre-compact': import("./verb-row.js").VerbSpec;
@@ -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_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, } 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';
@@ -74,7 +74,10 @@ function appendHookIfMissing(hooks, event, marker, group) {
74
74
  * included; uninstall removes only handlers that run one. */
75
75
  const CLAUDE_HOOK_MARKERS = [
76
76
  ['SessionEnd', [HIPPO_SESSION_END_MARKER, HIPPO_SLEEP_MARKER, HIPPO_CAPTURE_MARKER]],
77
- ['SessionStart', [HIPPO_LAST_SLEEP_MARKER, HIPPO_COMPACT_RESUME_MARKER]],
77
+ [
78
+ 'SessionStart',
79
+ [HIPPO_LAST_SLEEP_MARKER, HIPPO_SESSION_RULES_MARKER, HIPPO_COMPACT_RESUME_MARKER],
80
+ ],
78
81
  ['UserPromptSubmit', [HIPPO_PINNED_INJECT_MARKER]],
79
82
  ['PreCompact', [HIPPO_PRE_COMPACT_MARKER]],
80
83
  ['PostCompact', [HIPPO_POST_COMPACT_MARKER]],
@@ -87,6 +90,9 @@ const CLAUDE_APPENDED_EVENTS = CLAUDE_HOOK_MARKERS.map(([event]) => event).filte
87
90
  function appendSessionHooks(hooks, logFile) {
88
91
  const installedSessionEnd = appendHookIfMissing(hooks, 'SessionEnd', HIPPO_SESSION_END_MARKER, claudeCommandGroup(`hippo session-end --log-file "${logFile}"`, HOOK_SHORT_TIMEOUT_SECONDS));
89
92
  const installedSessionStart = appendHookIfMissing(hooks, 'SessionStart', HIPPO_LAST_SLEEP_MARKER, claudeCommandGroup(`hippo last-sleep --path "${logFile}"`, HOOK_SHORT_TIMEOUT_SECONDS));
93
+ // No matcher: a resumed or cleared session and a compaction lose the rules too, so every source
94
+ // sends them again.
95
+ const installedSessionRules = appendHookIfMissing(hooks, 'SessionStart', HIPPO_SESSION_RULES_MARKER, claudeCommandGroup(HIPPO_SESSION_RULES_COMMAND, HOOK_SHORT_TIMEOUT_SECONDS));
90
96
  // Mid-session pinned-rule re-injection: UserPromptSubmit runs every turn, so pinned memories stay
91
97
  // in context; the fresh write tail makes lessons saved earlier in the session visible on the next
92
98
  // prompt even before they are pinned.
@@ -95,6 +101,7 @@ function appendSessionHooks(hooks, logFile) {
95
101
  return {
96
102
  installedSessionEnd,
97
103
  installedSessionStart,
104
+ installedSessionRules,
98
105
  migratedPinnedInjectRecent,
99
106
  installedUserPromptSubmit,
100
107
  };
@@ -121,7 +128,7 @@ export function planClaudeCodeHooks(settings, { settingsPath, logFile, compactLo
121
128
  // SAFETY: ensureHooksObject left every event hippo appends to absent or an array.
122
129
  const hooks = merge;
123
130
  const migration = migrateLegacyClaudeHooks(hooks);
124
- const { installedSessionEnd, installedSessionStart, migratedPinnedInjectRecent, installedUserPromptSubmit, } = appendSessionHooks(hooks, logFile);
131
+ const { installedSessionEnd, installedSessionStart, installedSessionRules, migratedPinnedInjectRecent, installedUserPromptSubmit, } = appendSessionHooks(hooks, logFile);
125
132
  const { installedPreCompact, installedCompactResume, installedPostCompact } = appendCompactionHooks(hooks, compactLog);
126
133
  const installedCaptureError = appendCaptureErrorHook(hooks);
127
134
  const result = {
@@ -129,6 +136,7 @@ export function planClaudeCodeHooks(settings, { settingsPath, logFile, compactLo
129
136
  settingsPath,
130
137
  installedSessionEnd,
131
138
  installedSessionStart,
139
+ installedSessionRules,
132
140
  installedUserPromptSubmit,
133
141
  installedPreCompact,
134
142
  installedCompactResume,
@@ -10,6 +10,7 @@ export function nothingInstalled(target, settingsPath) {
10
10
  settingsPath,
11
11
  installedSessionEnd: false,
12
12
  installedSessionStart: false,
13
+ installedSessionRules: false,
13
14
  installedUserPromptSubmit: false,
14
15
  installedPreCompact: false,
15
16
  installedCompactResume: false,
@@ -18,6 +18,8 @@ export interface InstallResult {
18
18
  settingsPath: string;
19
19
  installedSessionEnd: boolean;
20
20
  installedSessionStart: boolean;
21
+ /** SessionStart -> `hippo session-rules` (sends the rules you stated). */
22
+ installedSessionRules: boolean;
21
23
  installedUserPromptSubmit: boolean;
22
24
  installedPreCompact: boolean;
23
25
  installedCompactResume: boolean;
@@ -9,6 +9,8 @@ export interface ToolDetection {
9
9
  }
10
10
  export declare const HIPPO_SLEEP_MARKER = "hippo sleep";
11
11
  export declare const HIPPO_LAST_SLEEP_MARKER = "hippo last-sleep";
12
+ export declare const HIPPO_SESSION_RULES_MARKER = "hippo session-rules";
13
+ export declare const HIPPO_SESSION_RULES_COMMAND = "hippo session-rules";
12
14
  export declare const HIPPO_CAPTURE_MARKER = "hippo capture --last-session";
13
15
  export declare const HIPPO_SESSION_END_MARKER = "hippo session-end";
14
16
  export declare const HIPPO_PINNED_INJECT_MARKER = "hippo context --pinned-only";
@@ -2,6 +2,8 @@ import * as path from 'node:path';
2
2
  import { HIPPO_DIR, userHome } from '../../../base/util/agent-homes.js';
3
3
  export const HIPPO_SLEEP_MARKER = 'hippo sleep';
4
4
  export const HIPPO_LAST_SLEEP_MARKER = 'hippo last-sleep';
5
+ export const HIPPO_SESSION_RULES_MARKER = 'hippo session-rules';
6
+ export const HIPPO_SESSION_RULES_COMMAND = 'hippo session-rules';
5
7
  export const HIPPO_CAPTURE_MARKER = 'hippo capture --last-session';
6
8
  export const HIPPO_SESSION_END_MARKER = 'hippo session-end';
7
9
  export const HIPPO_PINNED_INJECT_MARKER = 'hippo context --pinned-only';
@@ -2,7 +2,7 @@
2
2
  "id": "hippo-memory",
3
3
  "name": "Hippo Memory",
4
4
  "description": "Make your agent's memory work like a brain. Hippo is long-term memory for coding agents.",
5
- "version": "3.1.0",
5
+ "version": "3.2.0",
6
6
 
7
7
  "configSchema": {
8
8
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hippo-memory",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "type": "module",
5
5
  "description": "Make your agent's memory work like a brain. Hippo is long-term memory for coding agents.",
6
6
  "main": "index.ts",
@@ -2,7 +2,7 @@
2
2
  "id": "hippo-memory",
3
3
  "name": "Hippo Memory",
4
4
  "description": "Make your agent's memory work like a brain. Hippo is long-term memory for coding agents.",
5
- "version": "3.1.0",
5
+ "version": "3.2.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.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Make your agent's memory work like a brain. Hippo is long-term memory for coding agents.",
5
5
  "mcpName": "io.github.kitfunso/hippo-memory",
6
6
  "type": "module",