vericify 1.2.0 → 1.3.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.
package/src/index.js CHANGED
@@ -8,6 +8,8 @@ import {
8
8
  loadWorkspaceState,
9
9
  } from "./adapters/index.js";
10
10
  import { buildRunComparison, findRunById } from "./compare/engine.js";
11
+ import { buildCompactDelta } from "./context/delta.js";
12
+ import { buildCompactPacket } from "./context/packet.js";
11
13
  import { appendProcessPost } from "./post/process-posts.js";
12
14
  import { publishRunArtifact } from "./publish/artifact.js";
13
15
  import { projectWorkspaceState } from "./projection/runs.js";
@@ -27,10 +29,13 @@ function parseArgs(argv) {
27
29
  adapter: undefined,
28
30
  sessionId: undefined,
29
31
  captureMode: undefined,
32
+ pretty: false,
33
+ format: undefined,
30
34
  label: undefined,
31
35
  notes: undefined,
32
36
  runId: undefined,
33
37
  compareRunId: undefined,
38
+ since: undefined,
34
39
  agentId: undefined,
35
40
  kind: undefined,
36
41
  summary: undefined,
@@ -76,6 +81,10 @@ function parseArgs(argv) {
76
81
  options.feedFile = resolve(args[++i]);
77
82
  } else if (arg === "--adapter" && args[i + 1]) {
78
83
  options.adapter = args[++i];
84
+ } else if (arg === "--pretty") {
85
+ options.pretty = true;
86
+ } else if (arg === "--format" && args[i + 1]) {
87
+ options.format = args[++i];
79
88
  } else if (arg === "--session-id" && args[i + 1]) {
80
89
  options.sessionId = args[++i];
81
90
  } else if (arg === "--capture-mode" && args[i + 1]) {
@@ -88,6 +97,8 @@ function parseArgs(argv) {
88
97
  options.runId = args[++i];
89
98
  } else if (arg === "--compare-run-id" && args[i + 1]) {
90
99
  options.compareRunId = args[++i];
100
+ } else if (arg === "--since" && args[i + 1]) {
101
+ options.since = args[++i];
91
102
  } else if (arg === "--agent-id" && args[i + 1]) {
92
103
  options.agentId = args[++i];
93
104
  } else if (arg === "--kind" && args[i + 1]) {
@@ -178,6 +189,10 @@ function buildProjectedState(workspaceRoot) {
178
189
  return projectWorkspaceState(loadWorkspaceState(workspaceRoot));
179
190
  }
180
191
 
192
+ function writeJson(value, { pretty = true } = {}) {
193
+ process.stdout.write(`${JSON.stringify(value, null, pretty ? 2 : 0)}\n`);
194
+ }
195
+
181
196
  function printHelp() {
182
197
  process.stdout.write(
183
198
  [
@@ -189,6 +204,8 @@ function printHelp() {
189
204
  " hub Launch the terminal hub (default)",
190
205
  " adapters List available adapter contracts and current workspace status",
191
206
  " attach Attach an adapter profile to this workspace",
207
+ " context Print the compact bootstrap packet as JSON",
208
+ " delta Print the compact resume packet since a prior id",
192
209
  " compare Print a structured comparison between two runs",
193
210
  " publish Materialize a shareable run artifact under .vericify/published/",
194
211
  " sync Queue a published run artifact into .vericify/sync-outbox/",
@@ -197,17 +214,20 @@ function printHelp() {
197
214
  " ledger Append a native run-ledger entry into .vericify/run-ledger.json",
198
215
  " event Append a native status event into .vericify/status-events.ndjson",
199
216
  " post Append a structured process post into .vericify/process-posts.json",
200
- " snapshot Print the current projected run state as JSON",
217
+ " snapshot Print the current projected run state as JSON, or compact JSON with --format compact",
201
218
  " help Show this help",
202
219
  "",
203
220
  "Options:",
204
221
  " --workspace-root <path> Read workspace input artifacts from the given root",
205
222
  " --feed <path> Execute startup commands from a text file before returning control to keyboard",
206
223
  " --adapter <id> Adapter id for adapters/attach commands",
224
+ " --pretty Pretty-print compact JSON output for humans",
225
+ " --format <name> Snapshot format override, including compact",
207
226
  " --session-id <id> Optional adapter session identifier",
208
227
  " --capture-mode <mode> Adapter capture mode override",
209
228
  " --label <text> Human label for attached adapter or publish title",
210
229
  " --notes <text> Freeform note for attached adapter",
230
+ " --since <id> Prior compact context id for delta queries",
211
231
  " --id <id> Handoff/todo record id",
212
232
  " --title <text> Handoff/todo title",
213
233
  " --status <value> Handoff/todo/event status",
@@ -258,14 +278,36 @@ function printHelp() {
258
278
  );
259
279
  }
260
280
 
261
- async function printSnapshot(workspaceRoot) {
262
- const projected = buildProjectedState(workspaceRoot);
263
- process.stdout.write(`${JSON.stringify(projected, null, 2)}\n`);
281
+ async function printSnapshot(options) {
282
+ if (options.format === "compact") {
283
+ const packet = buildCompactPacket(buildProjectedState(options.workspaceRoot), {
284
+ runId: options.runId,
285
+ });
286
+ writeJson(packet, { pretty: options.pretty });
287
+ return;
288
+ }
289
+ const projected = buildProjectedState(options.workspaceRoot);
290
+ writeJson(projected, { pretty: true });
291
+ }
292
+
293
+ async function printContext(options) {
294
+ const packet = buildCompactPacket(buildProjectedState(options.workspaceRoot), {
295
+ runId: options.runId,
296
+ });
297
+ writeJson(packet, { pretty: options.pretty });
298
+ }
299
+
300
+ async function printDelta(options) {
301
+ const delta = buildCompactDelta(buildProjectedState(options.workspaceRoot), {
302
+ runId: options.runId,
303
+ since: options.since,
304
+ });
305
+ writeJson(delta, { pretty: options.pretty });
264
306
  }
265
307
 
266
308
  async function printAdapters(workspaceRoot) {
267
309
  const adapters = detectAdapters(workspaceRoot);
268
- process.stdout.write(`${JSON.stringify({ workspace_root: workspaceRoot, adapters }, null, 2)}\n`);
310
+ writeJson({ workspace_root: workspaceRoot, adapters }, { pretty: true });
269
311
  }
270
312
 
271
313
  async function writeAdapterAttachment(options) {
@@ -276,7 +318,7 @@ async function writeAdapterAttachment(options) {
276
318
  label: options.label,
277
319
  notes: options.notes,
278
320
  });
279
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
321
+ writeJson(result, { pretty: true });
280
322
  }
281
323
 
282
324
  async function printComparison(options) {
@@ -286,7 +328,7 @@ async function printComparison(options) {
286
328
  if (!left) throw new Error(`Unknown run id: ${options.runId}`);
287
329
  if (!right) throw new Error(`Unknown compare run id: ${options.compareRunId}`);
288
330
  const compare_report = buildRunComparison(left, right);
289
- process.stdout.write(`${JSON.stringify({ generated_at: projected.generated_at, workspace: projected.workspace, compare_report }, null, 2)}\n`);
331
+ writeJson({ generated_at: projected.generated_at, workspace: projected.workspace, compare_report }, { pretty: true });
290
332
  }
291
333
 
292
334
  async function writePublishedArtifact(options) {
@@ -298,7 +340,7 @@ async function writePublishedArtifact(options) {
298
340
  compareRunId: options.compareRunId,
299
341
  title: options.title ?? options.label,
300
342
  });
301
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
343
+ writeJson(result, { pretty: true });
302
344
  }
303
345
 
304
346
  async function queueSyncArtifact(options) {
@@ -317,7 +359,7 @@ async function queueSyncArtifact(options) {
317
359
  endpoint: options.endpoint,
318
360
  target: options.target,
319
361
  });
320
- process.stdout.write(`${JSON.stringify({ published, sync }, null, 2)}\n`);
362
+ writeJson({ published, sync }, { pretty: true });
321
363
  }
322
364
 
323
365
  async function writeProcessPost(options) {
@@ -332,7 +374,7 @@ async function writeProcessPost(options) {
332
374
  evidence_refs: options.evidenceRefs,
333
375
  checkpoint_ref: options.checkpointRef,
334
376
  });
335
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
377
+ writeJson(result, { pretty: true });
336
378
  }
337
379
 
338
380
  async function writeHandoff(options) {
@@ -350,7 +392,7 @@ async function writeHandoff(options) {
350
392
  agent_id: options.agentId,
351
393
  timestamp: options.timestamp,
352
394
  });
353
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
395
+ writeJson(result, { pretty: true });
354
396
  }
355
397
 
356
398
  async function writeTodo(options) {
@@ -364,7 +406,7 @@ async function writeTodo(options) {
364
406
  priority: options.priority,
365
407
  source_todo_path: options.sourceTodoPath,
366
408
  });
367
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
409
+ writeJson(result, { pretty: true });
368
410
  }
369
411
 
370
412
  async function writeLedgerEntry(options) {
@@ -377,7 +419,7 @@ async function writeLedgerEntry(options) {
377
419
  artifacts: options.artifacts,
378
420
  metadata: parseOptionalJson(options.metadataJson, "metadata-json"),
379
421
  });
380
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
422
+ writeJson(result, { pretty: true });
381
423
  }
382
424
 
383
425
  async function writeStatusEvent(options) {
@@ -392,7 +434,7 @@ async function writeStatusEvent(options) {
392
434
  decision_id: options.decisionId,
393
435
  payload: parseOptionalJson(options.payloadJson, "payload-json"),
394
436
  });
395
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
437
+ writeJson(result, { pretty: true });
396
438
  }
397
439
 
398
440
  async function main() {
@@ -409,8 +451,16 @@ async function main() {
409
451
  await writeAdapterAttachment(options);
410
452
  return;
411
453
  }
454
+ if (command === "context") {
455
+ await printContext(options);
456
+ return;
457
+ }
458
+ if (command === "delta") {
459
+ await printDelta(options);
460
+ return;
461
+ }
412
462
  if (command === "snapshot") {
413
- await printSnapshot(options.workspaceRoot);
463
+ await printSnapshot(options);
414
464
  return;
415
465
  }
416
466
  if (command === "compare") {
@@ -70,6 +70,7 @@ const OBSERVER_STATUS_EVENT_TYPES = new Set([
70
70
  "HUB_SESSION_STARTED",
71
71
  "HUB_SESSION_STOPPED",
72
72
  "HUB_SESSION_RESUMED",
73
+ "TOOL_COMPLETED",
73
74
  ]);
74
75
 
75
76
  const OBSERVER_LEDGER_CATEGORIES = new Set([
@@ -89,8 +90,7 @@ const PRIMARY_PROCESS_POST_KINDS = new Set([
89
90
  ]);
90
91
 
91
92
  function isObserverStatusEvent(event) {
92
- return event?.payload?.observer_telemetry === true ||
93
- (event?.source_module === "vericify-hub" && OBSERVER_STATUS_EVENT_TYPES.has(event?.event_type));
93
+ return event?.payload?.observer_telemetry === true || OBSERVER_STATUS_EVENT_TYPES.has(event?.event_type);
94
94
  }
95
95
 
96
96
  function isObserverLedgerEntry(entry) {