clawvault 2.1.1 → 2.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 (54) hide show
  1. package/bin/command-registration.test.js +6 -1
  2. package/bin/help-contract.test.js +2 -0
  3. package/bin/register-maintenance-commands.js +111 -0
  4. package/bin/register-query-commands.js +32 -1
  5. package/bin/register-session-lifecycle-commands.js +2 -0
  6. package/dist/{chunk-USAY3OIO.js → chunk-2HM7ZI4X.js} +273 -435
  7. package/dist/{chunk-TBVI4N53.js → chunk-6RIHODNR.js} +120 -95
  8. package/dist/chunk-73P7XCQM.js +104 -0
  9. package/dist/{chunk-MIIXBNO3.js → chunk-DHBDH4DN.js} +4 -0
  10. package/dist/chunk-GJEGPO7U.js +49 -0
  11. package/dist/chunk-GQVYQCY5.js +396 -0
  12. package/dist/{chunk-TXO34J3O.js → chunk-H7JW4L7H.js} +1 -1
  13. package/dist/{chunk-QFBKWDYR.js → chunk-IFGDPIFI.js} +3 -3
  14. package/dist/chunk-K6XHCUFL.js +123 -0
  15. package/dist/{chunk-PIJGYMQZ.js → chunk-KNDVXXKC.js} +1 -1
  16. package/dist/chunk-L6NB43WV.js +472 -0
  17. package/dist/{chunk-UPHUI5PD.js → chunk-LB6P4CD5.js} +20 -7
  18. package/dist/chunk-MGDEINGP.js +99 -0
  19. package/dist/chunk-MQUJNOHK.js +58 -0
  20. package/dist/chunk-P5EPF6MB.js +182 -0
  21. package/dist/chunk-VR5NE7PZ.js +45 -0
  22. package/dist/chunk-WZI3OAE5.js +111 -0
  23. package/dist/chunk-Z2XBWN7A.js +247 -0
  24. package/dist/{chunk-O5V7SD5C.js → chunk-ZZA73MFY.js} +1 -1
  25. package/dist/commands/archive.d.ts +11 -0
  26. package/dist/commands/archive.js +11 -0
  27. package/dist/commands/context.d.ts +1 -1
  28. package/dist/commands/context.js +6 -4
  29. package/dist/commands/doctor.js +6 -6
  30. package/dist/commands/graph.js +2 -2
  31. package/dist/commands/link.js +1 -1
  32. package/dist/commands/migrate-observations.d.ts +19 -0
  33. package/dist/commands/migrate-observations.js +13 -0
  34. package/dist/commands/observe.js +5 -2
  35. package/dist/commands/rebuild.d.ts +11 -0
  36. package/dist/commands/rebuild.js +12 -0
  37. package/dist/commands/reflect.d.ts +11 -0
  38. package/dist/commands/reflect.js +13 -0
  39. package/dist/commands/replay.d.ts +16 -0
  40. package/dist/commands/replay.js +14 -0
  41. package/dist/commands/setup.js +2 -2
  42. package/dist/commands/sleep.d.ts +1 -0
  43. package/dist/commands/sleep.js +29 -6
  44. package/dist/commands/status.js +6 -6
  45. package/dist/commands/sync-bd.d.ts +10 -0
  46. package/dist/commands/sync-bd.js +9 -0
  47. package/dist/commands/wake.js +53 -35
  48. package/dist/{context-COo8oq1k.d.ts → context-BUGaWpyL.d.ts} +1 -0
  49. package/dist/index.d.ts +55 -20
  50. package/dist/index.js +67 -16
  51. package/hooks/clawvault/HOOK.md +3 -2
  52. package/hooks/clawvault/handler.js +51 -0
  53. package/hooks/clawvault/handler.test.js +20 -0
  54. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,27 +1,60 @@
1
+ import {
2
+ buildSessionRecap,
3
+ formatSessionRecapMarkdown,
4
+ sessionRecapCommand
5
+ } from "./chunk-ZKGY7WTT.js";
6
+ import {
7
+ setupCommand
8
+ } from "./chunk-KNDVXXKC.js";
9
+ import {
10
+ registerSyncBdCommand,
11
+ syncBdCommand
12
+ } from "./chunk-MGDEINGP.js";
1
13
  import {
2
14
  buildTemplateVariables,
3
15
  renderTemplate
4
16
  } from "./chunk-7766SIJP.js";
17
+ import {
18
+ migrateObservations,
19
+ migrateObservationsCommand,
20
+ registerMigrateObservationsCommand
21
+ } from "./chunk-WZI3OAE5.js";
5
22
  import {
6
23
  SessionWatcher,
7
24
  observeCommand,
8
25
  registerObserveCommand
9
- } from "./chunk-UPHUI5PD.js";
26
+ } from "./chunk-LB6P4CD5.js";
10
27
  import {
11
- buildSessionRecap,
12
- formatSessionRecapMarkdown,
13
- sessionRecapCommand
14
- } from "./chunk-ZKGY7WTT.js";
28
+ parseSessionFile
29
+ } from "./chunk-P5EPF6MB.js";
30
+ import {
31
+ rebuildCommand,
32
+ registerRebuildCommand
33
+ } from "./chunk-73P7XCQM.js";
34
+ import {
35
+ reflectCommand,
36
+ registerReflectCommand
37
+ } from "./chunk-GJEGPO7U.js";
15
38
  import "./chunk-HRLWZGMA.js";
16
39
  import {
17
- setupCommand
18
- } from "./chunk-PIJGYMQZ.js";
40
+ registerReplayCommand,
41
+ replayCommand
42
+ } from "./chunk-L6NB43WV.js";
19
43
  import {
20
44
  Compressor,
21
45
  Observer,
22
- Reflector,
23
- parseSessionFile
24
- } from "./chunk-USAY3OIO.js";
46
+ Reflector
47
+ } from "./chunk-2HM7ZI4X.js";
48
+ import {
49
+ runReflection
50
+ } from "./chunk-GQVYQCY5.js";
51
+ import {
52
+ archiveCommand,
53
+ registerArchiveCommand
54
+ } from "./chunk-VR5NE7PZ.js";
55
+ import {
56
+ archiveObservations
57
+ } from "./chunk-MQUJNOHK.js";
25
58
  import {
26
59
  buildContext,
27
60
  contextCommand,
@@ -30,7 +63,9 @@ import {
30
63
  normalizeContextProfileInput,
31
64
  registerContextCommand,
32
65
  resolveContextProfile
33
- } from "./chunk-TBVI4N53.js";
66
+ } from "./chunk-6RIHODNR.js";
67
+ import "./chunk-K6XHCUFL.js";
68
+ import "./chunk-Z2XBWN7A.js";
34
69
  import {
35
70
  checkOpenClawCompatibility,
36
71
  compatCommand,
@@ -40,7 +75,7 @@ import {
40
75
  ClawVault,
41
76
  createVault,
42
77
  findVault
43
- } from "./chunk-QFBKWDYR.js";
78
+ } from "./chunk-IFGDPIFI.js";
44
79
  import {
45
80
  DEFAULT_CATEGORIES,
46
81
  DEFAULT_CONFIG,
@@ -55,17 +90,17 @@ import {
55
90
  hasQmd,
56
91
  qmdEmbed,
57
92
  qmdUpdate
58
- } from "./chunk-MIIXBNO3.js";
93
+ } from "./chunk-DHBDH4DN.js";
59
94
  import {
60
95
  graphCommand,
61
96
  graphSummary
62
- } from "./chunk-TXO34J3O.js";
97
+ } from "./chunk-H7JW4L7H.js";
63
98
  import {
64
99
  MEMORY_GRAPH_SCHEMA_VERSION,
65
100
  buildOrUpdateMemoryGraphIndex,
66
101
  getMemoryGraph,
67
102
  loadMemoryGraphIndex
68
- } from "./chunk-O5V7SD5C.js";
103
+ } from "./chunk-ZZA73MFY.js";
69
104
  import {
70
105
  findNearestVaultPath,
71
106
  getVaultPath,
@@ -87,6 +122,7 @@ var VERSION = readPackageVersion();
87
122
  function registerCommanderCommands(program) {
88
123
  registerContextCommand(program);
89
124
  registerObserveCommand(program);
125
+ registerReflectCommand(program);
90
126
  return program;
91
127
  }
92
128
  export {
@@ -105,6 +141,8 @@ export {
105
141
  SessionWatcher,
106
142
  TYPE_TO_CATEGORY,
107
143
  VERSION,
144
+ archiveCommand,
145
+ archiveObservations,
108
146
  buildContext,
109
147
  buildOrUpdateMemoryGraphIndex,
110
148
  buildSessionRecap,
@@ -127,17 +165,30 @@ export {
127
165
  hasQmd,
128
166
  inferContextProfile,
129
167
  loadMemoryGraphIndex,
168
+ migrateObservations,
169
+ migrateObservationsCommand,
130
170
  normalizeContextProfileInput,
131
171
  observeCommand,
132
172
  parseSessionFile,
133
173
  qmdEmbed,
134
174
  qmdUpdate,
175
+ rebuildCommand,
176
+ reflectCommand,
177
+ registerArchiveCommand,
135
178
  registerCommanderCommands,
136
179
  registerContextCommand,
180
+ registerMigrateObservationsCommand,
137
181
  registerObserveCommand,
182
+ registerRebuildCommand,
183
+ registerReflectCommand,
184
+ registerReplayCommand,
185
+ registerSyncBdCommand,
138
186
  renderTemplate,
187
+ replayCommand,
139
188
  resolveContextProfile,
140
189
  resolveVaultPath,
190
+ runReflection,
141
191
  sessionRecapCommand,
142
- setupCommand
192
+ setupCommand,
193
+ syncBdCommand
143
194
  };
@@ -4,7 +4,7 @@ description: "Context resilience - recovery detection, auto-checkpoint, and sess
4
4
  metadata:
5
5
  openclaw:
6
6
  emoji: "🐘"
7
- events: ["gateway:startup", "gateway:heartbeat", "command:new", "session:start", "compaction:memoryFlush"]
7
+ events: ["gateway:startup", "gateway:heartbeat", "command:new", "session:start", "compaction:memoryFlush", "cron.weekly"]
8
8
  requires:
9
9
  bins: ["clawvault"]
10
10
  ---
@@ -18,6 +18,7 @@ Integrates ClawVault's context death resilience into OpenClaw:
18
18
  - **On /new command**: Auto-checkpoints before session reset
19
19
  - **On context compaction**: Forces incremental observation flush before context is lost
20
20
  - **On session start**: Injects relevant vault context for the initial prompt
21
+ - **On weekly cron**: Runs `clawvault reflect` every Sunday midnight (UTC)
21
22
 
22
23
  ## Installation
23
24
 
@@ -63,7 +64,7 @@ Injection format:
63
64
 
64
65
  ### Event Compatibility
65
66
 
66
- The hook accepts canonical OpenClaw events (`gateway:startup`, `gateway:heartbeat`, `command:new`, `session:start`, `compaction:memoryFlush`) and tolerates alias payload shapes (`event`, `eventName`, `name`, `hook`, `trigger`) to remain robust across runtime wrappers.
67
+ The hook accepts canonical OpenClaw events (`gateway:startup`, `gateway:heartbeat`, `command:new`, `session:start`, `compaction:memoryFlush`, `cron.weekly`) and tolerates alias payload shapes (`event`, `eventName`, `name`, `hook`, `trigger`) to remain robust across runtime wrappers.
67
68
 
68
69
  ## No Configuration Needed
69
70
 
@@ -544,6 +544,49 @@ function runActiveObservation(vaultPath, agentId, options = {}) {
544
544
  return true;
545
545
  }
546
546
 
547
+ function extractEventTimestamp(event) {
548
+ const candidates = [
549
+ event?.timestamp,
550
+ event?.scheduledAt,
551
+ event?.time,
552
+ event?.context?.timestamp,
553
+ event?.context?.scheduledAt
554
+ ];
555
+ for (const candidate of candidates) {
556
+ if (!candidate) continue;
557
+ const parsed = new Date(candidate);
558
+ if (!Number.isNaN(parsed.getTime())) {
559
+ return parsed;
560
+ }
561
+ }
562
+ return null;
563
+ }
564
+
565
+ function isSundayMidnightUtc(date) {
566
+ return date.getUTCDay() === 0 && date.getUTCHours() === 0 && date.getUTCMinutes() === 0;
567
+ }
568
+
569
+ async function handleWeeklyReflect(event) {
570
+ const vaultPath = findVaultPath();
571
+ if (!vaultPath) {
572
+ console.log('[clawvault] No vault found, skipping weekly reflection');
573
+ return;
574
+ }
575
+
576
+ const timestamp = extractEventTimestamp(event) || new Date();
577
+ if (!isSundayMidnightUtc(timestamp)) {
578
+ console.log('[clawvault] Weekly reflect skipped (not Sunday midnight UTC)');
579
+ return;
580
+ }
581
+
582
+ const result = runClawvault(['reflect', '-v', vaultPath], { timeoutMs: 120000 });
583
+ if (!result.success) {
584
+ console.warn('[clawvault] Weekly reflection failed');
585
+ return;
586
+ }
587
+ console.log('[clawvault] Weekly reflection complete');
588
+ }
589
+
547
590
  // Handle gateway startup - check for context death
548
591
  async function handleStartup(event) {
549
592
  const vaultPath = findVaultPath();
@@ -724,6 +767,14 @@ const handler = async (event) => {
724
767
  return;
725
768
  }
726
769
 
770
+ if (
771
+ eventMatches(event, 'cron', 'weekly')
772
+ || eventIncludesToken(event, 'cron:weekly')
773
+ ) {
774
+ await handleWeeklyReflect(event);
775
+ return;
776
+ }
777
+
727
778
  if (
728
779
  eventMatches(event, 'gateway', 'heartbeat')
729
780
  || eventMatches(event, 'session', 'heartbeat')
@@ -240,4 +240,24 @@ describe('clawvault hook handler', () => {
240
240
 
241
241
  fs.rmSync(vaultPath, { recursive: true, force: true });
242
242
  });
243
+
244
+ it('runs weekly reflection on cron.weekly at Sunday midnight', async () => {
245
+ const vaultPath = makeVaultFixture();
246
+ process.env.CLAWVAULT_PATH = vaultPath;
247
+ execFileSyncMock.mockReturnValue('');
248
+
249
+ const handler = await loadHandler();
250
+ await handler({
251
+ eventName: 'cron.weekly',
252
+ timestamp: '2026-02-15T00:00:00.000Z'
253
+ });
254
+
255
+ expect(execFileSyncMock).toHaveBeenCalledWith(
256
+ 'clawvault',
257
+ expect.arrayContaining(['reflect', '-v', vaultPath]),
258
+ expect.objectContaining({ shell: false })
259
+ );
260
+
261
+ fs.rmSync(vaultPath, { recursive: true, force: true });
262
+ });
243
263
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawvault",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "ClawVault™ - 🐘 An elephant never forgets. Structured memory for OpenClaw agents. Context death resilience, Obsidian-compatible markdown, local semantic search.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -29,7 +29,7 @@
29
29
  ]
30
30
  },
31
31
  "scripts": {
32
- "build": "tsup src/index.ts src/commands/entities.ts src/commands/link.ts src/commands/checkpoint.ts src/commands/recover.ts src/commands/status.ts src/commands/template.ts src/commands/setup.ts src/commands/context.ts src/commands/observe.ts src/commands/session-recap.ts src/commands/wake.ts src/commands/sleep.ts src/commands/doctor.ts src/commands/compat.ts src/commands/graph.ts src/commands/shell-init.ts src/commands/repair-session.ts src/lib/entity-index.ts src/lib/auto-linker.ts src/lib/config.ts src/lib/template-engine.ts src/lib/session-utils.ts src/lib/session-repair.ts --format esm --dts --clean",
32
+ "build": "tsup src/index.ts src/commands/entities.ts src/commands/link.ts src/commands/checkpoint.ts src/commands/recover.ts src/commands/status.ts src/commands/template.ts src/commands/setup.ts src/commands/context.ts src/commands/observe.ts src/commands/reflect.ts src/commands/archive.ts src/commands/rebuild.ts src/commands/replay.ts src/commands/migrate-observations.ts src/commands/sync-bd.ts src/commands/session-recap.ts src/commands/wake.ts src/commands/sleep.ts src/commands/doctor.ts src/commands/compat.ts src/commands/graph.ts src/commands/shell-init.ts src/commands/repair-session.ts src/lib/entity-index.ts src/lib/auto-linker.ts src/lib/config.ts src/lib/template-engine.ts src/lib/session-utils.ts src/lib/session-repair.ts --format esm --dts --clean",
33
33
  "dev": "tsup src/index.ts src/commands/*.ts src/lib/*.ts --format esm --dts --watch",
34
34
  "lint": "eslint src",
35
35
  "typecheck": "tsc --noEmit",