clawvault 2.5.3 → 2.6.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 (95) hide show
  1. package/README.md +159 -159
  2. package/bin/clawvault.js +111 -111
  3. package/bin/command-registration.test.js +166 -166
  4. package/bin/command-runtime.js +93 -93
  5. package/bin/command-runtime.test.js +154 -154
  6. package/bin/help-contract.test.js +39 -39
  7. package/bin/register-config-commands.js +153 -153
  8. package/bin/register-config-route-commands.test.js +121 -121
  9. package/bin/register-core-commands.js +237 -237
  10. package/bin/register-kanban-commands.js +56 -56
  11. package/bin/register-kanban-commands.test.js +83 -83
  12. package/bin/register-maintenance-commands.js +282 -282
  13. package/bin/register-project-commands.js +209 -209
  14. package/bin/register-project-commands.test.js +206 -206
  15. package/bin/register-query-commands.js +317 -317
  16. package/bin/register-query-commands.test.js +65 -65
  17. package/bin/register-resilience-commands.js +182 -182
  18. package/bin/register-resilience-commands.test.js +81 -81
  19. package/bin/register-route-commands.js +114 -114
  20. package/bin/register-session-lifecycle-commands.js +206 -206
  21. package/bin/register-tailscale-commands.js +106 -106
  22. package/bin/register-task-commands.js +348 -348
  23. package/bin/register-task-commands.test.js +69 -69
  24. package/bin/register-template-commands.js +75 -72
  25. package/bin/register-template-commands.test.js +87 -0
  26. package/bin/register-vault-operations-commands.js +300 -300
  27. package/bin/test-helpers/cli-command-fixtures.js +119 -119
  28. package/dashboard/lib/graph-diff.js +104 -104
  29. package/dashboard/lib/graph-diff.test.js +75 -75
  30. package/dashboard/lib/vault-parser.js +556 -556
  31. package/dashboard/lib/vault-parser.test.js +254 -254
  32. package/dashboard/public/app.js +796 -796
  33. package/dashboard/public/index.html +52 -52
  34. package/dashboard/public/styles.css +221 -221
  35. package/dashboard/server.js +374 -374
  36. package/dist/{chunk-J5EMBUPK.js → chunk-4OXMU5S2.js} +1 -1
  37. package/dist/{chunk-3FP5BJ42.js → chunk-4QYGFWRM.js} +1 -1
  38. package/dist/{chunk-4IV3R2F5.js → chunk-4TE4JMLA.js} +1 -1
  39. package/dist/{chunk-5GZFTAL7.js → chunk-AZYOKJYC.js} +128 -42
  40. package/dist/{chunk-FG6RJMCN.js → chunk-HA5M6KJB.js} +4 -4
  41. package/dist/{chunk-IZEY5S74.js → chunk-IEVLHNLU.js} +1 -1
  42. package/dist/{chunk-CLE2HHNT.js → chunk-IVRIKYFE.js} +18 -11
  43. package/dist/{chunk-AY4PGUVL.js → chunk-KL4NAOMO.js} +1 -1
  44. package/dist/{chunk-O7XHXF7F.js → chunk-MAKNAHAW.js} +4 -4
  45. package/dist/{chunk-OSMS7QIG.js → chunk-ME37YNW3.js} +2 -2
  46. package/dist/chunk-MFAWT5O5.js +301 -0
  47. package/dist/{chunk-TPDH3JPP.js → chunk-PBEE567J.js} +1 -1
  48. package/dist/{chunk-S2IG7VNM.js → chunk-Q2J5YTUF.js} +2 -2
  49. package/dist/{chunk-IOALNTAN.js → chunk-QWQ3TIKS.js} +103 -29
  50. package/dist/{chunk-YCVDVI5B.js → chunk-R2MIW5G7.js} +1 -1
  51. package/dist/{chunk-M25QVSJM.js → chunk-RVYA52PY.js} +1 -1
  52. package/dist/{chunk-NZ4ZZNSR.js → chunk-THRJVD4L.js} +1 -1
  53. package/dist/{chunk-4GBPTBFJ.js → chunk-TIGW564L.js} +1 -1
  54. package/dist/{chunk-LMEMZGUV.js → chunk-UEOUADMO.js} +3 -3
  55. package/dist/{chunk-GFJ3LIIB.js → chunk-XAVB4GB4.js} +1 -1
  56. package/dist/cli/index.js +15 -13
  57. package/dist/commands/backlog.js +3 -1
  58. package/dist/commands/blocked.js +3 -1
  59. package/dist/commands/canvas.js +3 -1
  60. package/dist/commands/context.js +3 -3
  61. package/dist/commands/doctor.js +9 -7
  62. package/dist/commands/embed.js +2 -2
  63. package/dist/commands/kanban.js +4 -2
  64. package/dist/commands/observe.js +7 -5
  65. package/dist/commands/project.js +5 -3
  66. package/dist/commands/rebuild.js +6 -4
  67. package/dist/commands/replay.js +6 -4
  68. package/dist/commands/setup.js +2 -2
  69. package/dist/commands/sleep.js +7 -5
  70. package/dist/commands/status.js +8 -6
  71. package/dist/commands/tailscale.js +3 -3
  72. package/dist/commands/task.js +4 -2
  73. package/dist/commands/template.d.ts +10 -1
  74. package/dist/commands/template.js +47 -55
  75. package/dist/commands/wake.js +2 -2
  76. package/dist/index.js +23 -22
  77. package/dist/lib/project-utils.js +4 -2
  78. package/dist/lib/tailscale.js +2 -2
  79. package/dist/lib/task-utils.d.ts +14 -13
  80. package/dist/lib/task-utils.js +3 -1
  81. package/dist/lib/template-engine.d.ts +1 -0
  82. package/dist/lib/webdav.js +1 -1
  83. package/hooks/clawvault/HOOK.md +83 -83
  84. package/hooks/clawvault/handler.js +816 -816
  85. package/hooks/clawvault/handler.test.js +263 -263
  86. package/package.json +94 -94
  87. package/templates/checkpoint.md +34 -19
  88. package/templates/daily-note.md +34 -19
  89. package/templates/daily.md +34 -19
  90. package/templates/decision.md +39 -17
  91. package/templates/handoff.md +34 -19
  92. package/templates/lesson.md +31 -16
  93. package/templates/person.md +37 -19
  94. package/templates/project.md +84 -23
  95. package/templates/task.md +81 -0
@@ -1,282 +1,282 @@
1
- /**
2
- * Maintenance and graph-oriented command registrations.
3
- * Split from the main CLI entrypoint to keep bin/clawvault.js maintainable.
4
- */
5
-
6
- export function registerMaintenanceCommands(program, { chalk }) {
7
- // === DOCTOR (health check) ===
8
- program
9
- .command('doctor')
10
- .description('Diagnose vault health and optionally apply fixes')
11
- .option('-v, --vault <path>', 'Vault path')
12
- .option('--fix', 'Apply safe auto-fixes for qmd index, embeddings, and dead collections')
13
- .option('--json', 'Output machine-readable JSON')
14
- .action(async (options) => {
15
- try {
16
- const { doctor } = await import('../dist/commands/doctor.js');
17
- const report = await doctor({
18
- vaultPath: options.vault,
19
- fix: options.fix
20
- });
21
-
22
- if (options.json) {
23
- console.log(JSON.stringify(report, null, 2));
24
- return;
25
- }
26
-
27
- console.log(chalk.cyan('\n🩺 ClawVault Health Check\n'));
28
- console.log(chalk.dim(`Vault: ${report.vaultPath}`));
29
- console.log(chalk.dim(`qmd collection: ${report.qmdCollection}`));
30
- console.log(chalk.dim(`qmd root: ${report.qmdRoot}`));
31
- console.log();
32
-
33
- for (const check of report.checks) {
34
- const prefix = check.status === 'ok'
35
- ? chalk.green('✓')
36
- : check.status === 'warn'
37
- ? chalk.yellow('⚠')
38
- : chalk.red('✗');
39
- const line = `${check.label}: ${check.detail}`;
40
- const renderedLine = check.status === 'ok'
41
- ? chalk.green(line)
42
- : check.status === 'warn'
43
- ? chalk.yellow(line)
44
- : chalk.red(line);
45
- console.log(`${prefix} ${renderedLine}`);
46
- if (check.hint) {
47
- console.log(chalk.dim(` ${check.hint}`));
48
- }
49
- }
50
-
51
- const issues = report.warnings + report.errors;
52
- console.log();
53
- if (issues === 0) {
54
- console.log(chalk.green('✅ ClawVault is healthy!\n'));
55
- } else {
56
- const summary = `${report.errors} error(s), ${report.warnings} warning(s)`;
57
- const colorized = report.errors > 0 ? chalk.red(summary) : chalk.yellow(summary);
58
- console.log(`${report.errors > 0 ? '✗' : '⚠'} ${colorized}\n`);
59
- }
60
- } catch (err) {
61
- console.error(chalk.red(`Error: ${err.message}`));
62
- process.exit(1);
63
- }
64
- });
65
-
66
- // === EMBED ===
67
- program
68
- .command('embed')
69
- .description('Run qmd embedding for pending vault documents')
70
- .option('-v, --vault <path>', 'Vault path')
71
- .action(async (options) => {
72
- try {
73
- const { embedCommand } = await import('../dist/commands/embed.js');
74
- await embedCommand({
75
- vaultPath: options.vault
76
- });
77
- } catch (err) {
78
- console.error(chalk.red(`Error: ${err.message}`));
79
- process.exit(1);
80
- }
81
- });
82
-
83
- // === COMPAT (OpenClaw compatibility) ===
84
- program
85
- .command('compat')
86
- .description('Check OpenClaw compatibility status')
87
- .option('--strict', 'Exit non-zero when warnings are present')
88
- .option('--base-dir <path>', 'Validate compatibility against alternate project root')
89
- .option('--json', 'Output as JSON')
90
- .action(async (options) => {
91
- try {
92
- const { compatCommand, compatibilityExitCode } = await import('../dist/commands/compat.js');
93
- const report = await compatCommand({
94
- json: options.json,
95
- strict: options.strict,
96
- baseDir: options.baseDir
97
- });
98
- const exitCode = compatibilityExitCode(report, { strict: options.strict });
99
- if (exitCode !== 0) {
100
- process.exitCode = exitCode;
101
- }
102
- } catch (err) {
103
- console.error(chalk.red(`Error: ${err.message}`));
104
- process.exit(1);
105
- }
106
- });
107
-
108
- // === GRAPH ===
109
- program
110
- .command('graph')
111
- .description('Show typed memory graph summary')
112
- .option('-v, --vault <path>', 'Vault path')
113
- .option('--refresh', 'Rebuild graph index before showing summary')
114
- .option('--json', 'Output as JSON')
115
- .action(async (options) => {
116
- try {
117
- const { graphCommand } = await import('../dist/commands/graph.js');
118
- await graphCommand({
119
- vaultPath: options.vault,
120
- refresh: options.refresh,
121
- json: options.json
122
- });
123
- } catch (err) {
124
- console.error(chalk.red(`Error: ${err.message}`));
125
- process.exit(1);
126
- }
127
- });
128
-
129
- // === ENTITIES ===
130
- program
131
- .command('entities')
132
- .description('List all linkable entities in the vault')
133
- .option('-v, --vault <path>', 'Vault path')
134
- .option('--json', 'Output as JSON')
135
- .action(async (options) => {
136
- try {
137
- const { entitiesCommand } = await import('../dist/commands/entities.js');
138
- await entitiesCommand({ json: options.json, vaultPath: options.vault });
139
- } catch (err) {
140
- console.error(chalk.red(`Error: ${err.message}`));
141
- process.exit(1);
142
- }
143
- });
144
-
145
- // === LINK ===
146
- program
147
- .command('link [file]')
148
- .description('Auto-link entity mentions in markdown files')
149
- .option('--all', 'Link all files in vault')
150
- .option('--backlinks <file>', 'Show backlinks to a file')
151
- .option('--dry-run', 'Show what would be linked without changing files')
152
- .option('--orphans', 'List broken wiki-links')
153
- .option('--rebuild', 'Rebuild backlinks index')
154
- .option('-v, --vault <path>', 'Vault path')
155
- .action(async (file, options) => {
156
- try {
157
- const { linkCommand } = await import('../dist/commands/link.js');
158
- await linkCommand(file, {
159
- all: options.all,
160
- dryRun: options.dryRun,
161
- backlinks: options.backlinks,
162
- orphans: options.orphans,
163
- rebuild: options.rebuild,
164
- vaultPath: options.vault
165
- });
166
- } catch (err) {
167
- console.error(chalk.red(`Error: ${err.message}`));
168
- process.exit(1);
169
- }
170
- });
171
-
172
- // === REBUILD ===
173
- program
174
- .command('rebuild')
175
- .description('Rebuild observations from ledger/raw transcripts')
176
- .option('--from <date>', 'Start date (YYYY-MM-DD)')
177
- .option('--to <date>', 'End date (YYYY-MM-DD)')
178
- .option('-v, --vault <path>', 'Vault path')
179
- .action(async (options) => {
180
- try {
181
- const { rebuildCommand } = await import('../dist/commands/rebuild.js');
182
- await rebuildCommand({
183
- vaultPath: options.vault,
184
- from: options.from,
185
- to: options.to
186
- });
187
- } catch (err) {
188
- console.error(chalk.red(`Error: ${err.message}`));
189
- process.exit(1);
190
- }
191
- });
192
-
193
- // === ARCHIVE ===
194
- program
195
- .command('archive')
196
- .description('Archive old observations into ledger/archive')
197
- .option('--older-than <days>', 'Archive observations older than this many days (default: 14)', '14')
198
- .option('--dry-run', 'Show archive candidates without writing')
199
- .option('-v, --vault <path>', 'Vault path')
200
- .action(async (options) => {
201
- try {
202
- const { archiveCommand } = await import('../dist/commands/archive.js');
203
- const olderThan = Number.parseInt(options.olderThan, 10);
204
- if (!Number.isFinite(olderThan) || olderThan <= 0) {
205
- throw new Error(`Invalid --older-than value: ${options.olderThan}`);
206
- }
207
- await archiveCommand({
208
- vaultPath: options.vault,
209
- olderThan,
210
- dryRun: options.dryRun
211
- });
212
- } catch (err) {
213
- console.error(chalk.red(`Error: ${err.message}`));
214
- process.exit(1);
215
- }
216
- });
217
-
218
- // === MIGRATE-OBSERVATIONS ===
219
- program
220
- .command('migrate-observations')
221
- .description('Convert legacy emoji observations to scored format')
222
- .option('--dry-run', 'Show migration candidates without writing')
223
- .option('-v, --vault <path>', 'Vault path')
224
- .action(async (options) => {
225
- try {
226
- const { migrateObservationsCommand } = await import('../dist/commands/migrate-observations.js');
227
- await migrateObservationsCommand({
228
- vaultPath: options.vault,
229
- dryRun: options.dryRun
230
- });
231
- } catch (err) {
232
- console.error(chalk.red(`Error: ${err.message}`));
233
- process.exit(1);
234
- }
235
- });
236
-
237
- // === REPLAY ===
238
- program
239
- .command('replay')
240
- .description('Replay historical conversation exports through observe pipeline')
241
- .requiredOption('--source <platform>', 'Source platform (chatgpt|claude|opencode|openclaw)')
242
- .requiredOption('--input <path>', 'Input export file or directory')
243
- .option('--from <date>', 'Start date (YYYY-MM-DD)')
244
- .option('--to <date>', 'End date (YYYY-MM-DD)')
245
- .option('--dry-run', 'Preview replay candidates without writing')
246
- .option('-v, --vault <path>', 'Vault path')
247
- .action(async (options) => {
248
- try {
249
- const { replayCommand } = await import('../dist/commands/replay.js');
250
- await replayCommand({
251
- source: options.source,
252
- inputPath: options.input,
253
- from: options.from,
254
- to: options.to,
255
- dryRun: options.dryRun,
256
- vaultPath: options.vault
257
- });
258
- } catch (err) {
259
- console.error(chalk.red(`Error: ${err.message}`));
260
- process.exit(1);
261
- }
262
- });
263
-
264
- // === SYNC-BD ===
265
- program
266
- .command('sync-bd')
267
- .description('Sync active Beads tasks into views/now.md (optional)')
268
- .option('--dry-run', 'Show sync output without writing')
269
- .option('-v, --vault <path>', 'Vault path')
270
- .action(async (options) => {
271
- try {
272
- const { syncBdCommand } = await import('../dist/commands/sync-bd.js');
273
- await syncBdCommand({
274
- vaultPath: options.vault,
275
- dryRun: options.dryRun
276
- });
277
- } catch (err) {
278
- console.error(chalk.red(`Error: ${err.message}`));
279
- process.exit(1);
280
- }
281
- });
282
- }
1
+ /**
2
+ * Maintenance and graph-oriented command registrations.
3
+ * Split from the main CLI entrypoint to keep bin/clawvault.js maintainable.
4
+ */
5
+
6
+ export function registerMaintenanceCommands(program, { chalk }) {
7
+ // === DOCTOR (health check) ===
8
+ program
9
+ .command('doctor')
10
+ .description('Diagnose vault health and optionally apply fixes')
11
+ .option('-v, --vault <path>', 'Vault path')
12
+ .option('--fix', 'Apply safe auto-fixes for qmd index, embeddings, and dead collections')
13
+ .option('--json', 'Output machine-readable JSON')
14
+ .action(async (options) => {
15
+ try {
16
+ const { doctor } = await import('../dist/commands/doctor.js');
17
+ const report = await doctor({
18
+ vaultPath: options.vault,
19
+ fix: options.fix
20
+ });
21
+
22
+ if (options.json) {
23
+ console.log(JSON.stringify(report, null, 2));
24
+ return;
25
+ }
26
+
27
+ console.log(chalk.cyan('\n🩺 ClawVault Health Check\n'));
28
+ console.log(chalk.dim(`Vault: ${report.vaultPath}`));
29
+ console.log(chalk.dim(`qmd collection: ${report.qmdCollection}`));
30
+ console.log(chalk.dim(`qmd root: ${report.qmdRoot}`));
31
+ console.log();
32
+
33
+ for (const check of report.checks) {
34
+ const prefix = check.status === 'ok'
35
+ ? chalk.green('✓')
36
+ : check.status === 'warn'
37
+ ? chalk.yellow('⚠')
38
+ : chalk.red('✗');
39
+ const line = `${check.label}: ${check.detail}`;
40
+ const renderedLine = check.status === 'ok'
41
+ ? chalk.green(line)
42
+ : check.status === 'warn'
43
+ ? chalk.yellow(line)
44
+ : chalk.red(line);
45
+ console.log(`${prefix} ${renderedLine}`);
46
+ if (check.hint) {
47
+ console.log(chalk.dim(` ${check.hint}`));
48
+ }
49
+ }
50
+
51
+ const issues = report.warnings + report.errors;
52
+ console.log();
53
+ if (issues === 0) {
54
+ console.log(chalk.green('✅ ClawVault is healthy!\n'));
55
+ } else {
56
+ const summary = `${report.errors} error(s), ${report.warnings} warning(s)`;
57
+ const colorized = report.errors > 0 ? chalk.red(summary) : chalk.yellow(summary);
58
+ console.log(`${report.errors > 0 ? '✗' : '⚠'} ${colorized}\n`);
59
+ }
60
+ } catch (err) {
61
+ console.error(chalk.red(`Error: ${err.message}`));
62
+ process.exit(1);
63
+ }
64
+ });
65
+
66
+ // === EMBED ===
67
+ program
68
+ .command('embed')
69
+ .description('Run qmd embedding for pending vault documents')
70
+ .option('-v, --vault <path>', 'Vault path')
71
+ .action(async (options) => {
72
+ try {
73
+ const { embedCommand } = await import('../dist/commands/embed.js');
74
+ await embedCommand({
75
+ vaultPath: options.vault
76
+ });
77
+ } catch (err) {
78
+ console.error(chalk.red(`Error: ${err.message}`));
79
+ process.exit(1);
80
+ }
81
+ });
82
+
83
+ // === COMPAT (OpenClaw compatibility) ===
84
+ program
85
+ .command('compat')
86
+ .description('Check OpenClaw compatibility status')
87
+ .option('--strict', 'Exit non-zero when warnings are present')
88
+ .option('--base-dir <path>', 'Validate compatibility against alternate project root')
89
+ .option('--json', 'Output as JSON')
90
+ .action(async (options) => {
91
+ try {
92
+ const { compatCommand, compatibilityExitCode } = await import('../dist/commands/compat.js');
93
+ const report = await compatCommand({
94
+ json: options.json,
95
+ strict: options.strict,
96
+ baseDir: options.baseDir
97
+ });
98
+ const exitCode = compatibilityExitCode(report, { strict: options.strict });
99
+ if (exitCode !== 0) {
100
+ process.exitCode = exitCode;
101
+ }
102
+ } catch (err) {
103
+ console.error(chalk.red(`Error: ${err.message}`));
104
+ process.exit(1);
105
+ }
106
+ });
107
+
108
+ // === GRAPH ===
109
+ program
110
+ .command('graph')
111
+ .description('Show typed memory graph summary')
112
+ .option('-v, --vault <path>', 'Vault path')
113
+ .option('--refresh', 'Rebuild graph index before showing summary')
114
+ .option('--json', 'Output as JSON')
115
+ .action(async (options) => {
116
+ try {
117
+ const { graphCommand } = await import('../dist/commands/graph.js');
118
+ await graphCommand({
119
+ vaultPath: options.vault,
120
+ refresh: options.refresh,
121
+ json: options.json
122
+ });
123
+ } catch (err) {
124
+ console.error(chalk.red(`Error: ${err.message}`));
125
+ process.exit(1);
126
+ }
127
+ });
128
+
129
+ // === ENTITIES ===
130
+ program
131
+ .command('entities')
132
+ .description('List all linkable entities in the vault')
133
+ .option('-v, --vault <path>', 'Vault path')
134
+ .option('--json', 'Output as JSON')
135
+ .action(async (options) => {
136
+ try {
137
+ const { entitiesCommand } = await import('../dist/commands/entities.js');
138
+ await entitiesCommand({ json: options.json, vaultPath: options.vault });
139
+ } catch (err) {
140
+ console.error(chalk.red(`Error: ${err.message}`));
141
+ process.exit(1);
142
+ }
143
+ });
144
+
145
+ // === LINK ===
146
+ program
147
+ .command('link [file]')
148
+ .description('Auto-link entity mentions in markdown files')
149
+ .option('--all', 'Link all files in vault')
150
+ .option('--backlinks <file>', 'Show backlinks to a file')
151
+ .option('--dry-run', 'Show what would be linked without changing files')
152
+ .option('--orphans', 'List broken wiki-links')
153
+ .option('--rebuild', 'Rebuild backlinks index')
154
+ .option('-v, --vault <path>', 'Vault path')
155
+ .action(async (file, options) => {
156
+ try {
157
+ const { linkCommand } = await import('../dist/commands/link.js');
158
+ await linkCommand(file, {
159
+ all: options.all,
160
+ dryRun: options.dryRun,
161
+ backlinks: options.backlinks,
162
+ orphans: options.orphans,
163
+ rebuild: options.rebuild,
164
+ vaultPath: options.vault
165
+ });
166
+ } catch (err) {
167
+ console.error(chalk.red(`Error: ${err.message}`));
168
+ process.exit(1);
169
+ }
170
+ });
171
+
172
+ // === REBUILD ===
173
+ program
174
+ .command('rebuild')
175
+ .description('Rebuild observations from ledger/raw transcripts')
176
+ .option('--from <date>', 'Start date (YYYY-MM-DD)')
177
+ .option('--to <date>', 'End date (YYYY-MM-DD)')
178
+ .option('-v, --vault <path>', 'Vault path')
179
+ .action(async (options) => {
180
+ try {
181
+ const { rebuildCommand } = await import('../dist/commands/rebuild.js');
182
+ await rebuildCommand({
183
+ vaultPath: options.vault,
184
+ from: options.from,
185
+ to: options.to
186
+ });
187
+ } catch (err) {
188
+ console.error(chalk.red(`Error: ${err.message}`));
189
+ process.exit(1);
190
+ }
191
+ });
192
+
193
+ // === ARCHIVE ===
194
+ program
195
+ .command('archive')
196
+ .description('Archive old observations into ledger/archive')
197
+ .option('--older-than <days>', 'Archive observations older than this many days (default: 14)', '14')
198
+ .option('--dry-run', 'Show archive candidates without writing')
199
+ .option('-v, --vault <path>', 'Vault path')
200
+ .action(async (options) => {
201
+ try {
202
+ const { archiveCommand } = await import('../dist/commands/archive.js');
203
+ const olderThan = Number.parseInt(options.olderThan, 10);
204
+ if (!Number.isFinite(olderThan) || olderThan <= 0) {
205
+ throw new Error(`Invalid --older-than value: ${options.olderThan}`);
206
+ }
207
+ await archiveCommand({
208
+ vaultPath: options.vault,
209
+ olderThan,
210
+ dryRun: options.dryRun
211
+ });
212
+ } catch (err) {
213
+ console.error(chalk.red(`Error: ${err.message}`));
214
+ process.exit(1);
215
+ }
216
+ });
217
+
218
+ // === MIGRATE-OBSERVATIONS ===
219
+ program
220
+ .command('migrate-observations')
221
+ .description('Convert legacy emoji observations to scored format')
222
+ .option('--dry-run', 'Show migration candidates without writing')
223
+ .option('-v, --vault <path>', 'Vault path')
224
+ .action(async (options) => {
225
+ try {
226
+ const { migrateObservationsCommand } = await import('../dist/commands/migrate-observations.js');
227
+ await migrateObservationsCommand({
228
+ vaultPath: options.vault,
229
+ dryRun: options.dryRun
230
+ });
231
+ } catch (err) {
232
+ console.error(chalk.red(`Error: ${err.message}`));
233
+ process.exit(1);
234
+ }
235
+ });
236
+
237
+ // === REPLAY ===
238
+ program
239
+ .command('replay')
240
+ .description('Replay historical conversation exports through observe pipeline')
241
+ .requiredOption('--source <platform>', 'Source platform (chatgpt|claude|opencode|openclaw)')
242
+ .requiredOption('--input <path>', 'Input export file or directory')
243
+ .option('--from <date>', 'Start date (YYYY-MM-DD)')
244
+ .option('--to <date>', 'End date (YYYY-MM-DD)')
245
+ .option('--dry-run', 'Preview replay candidates without writing')
246
+ .option('-v, --vault <path>', 'Vault path')
247
+ .action(async (options) => {
248
+ try {
249
+ const { replayCommand } = await import('../dist/commands/replay.js');
250
+ await replayCommand({
251
+ source: options.source,
252
+ inputPath: options.input,
253
+ from: options.from,
254
+ to: options.to,
255
+ dryRun: options.dryRun,
256
+ vaultPath: options.vault
257
+ });
258
+ } catch (err) {
259
+ console.error(chalk.red(`Error: ${err.message}`));
260
+ process.exit(1);
261
+ }
262
+ });
263
+
264
+ // === SYNC-BD ===
265
+ program
266
+ .command('sync-bd')
267
+ .description('Sync active Beads tasks into views/now.md (optional)')
268
+ .option('--dry-run', 'Show sync output without writing')
269
+ .option('-v, --vault <path>', 'Vault path')
270
+ .action(async (options) => {
271
+ try {
272
+ const { syncBdCommand } = await import('../dist/commands/sync-bd.js');
273
+ await syncBdCommand({
274
+ vaultPath: options.vault,
275
+ dryRun: options.dryRun
276
+ });
277
+ } catch (err) {
278
+ console.error(chalk.red(`Error: ${err.message}`));
279
+ process.exit(1);
280
+ }
281
+ });
282
+ }