caveat-cli 0.19.13 → 0.20.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/dist/index.js CHANGED
@@ -64,9 +64,12 @@ import {
64
64
  reviewJevObservation,
65
65
  runAutoSync,
66
66
  runWindowsAcl,
67
+ runtimeErrorReportDue,
68
+ runtimeErrorReportStatus,
67
69
  runtimeErrorsDiagnostics,
68
70
  runtimeErrorsSnapshot,
69
71
  search,
72
+ sendRuntimeErrorReport,
70
73
  setRuntimeErrorStatus,
71
74
  stderrLogger,
72
75
  stopReminderText,
@@ -79,7 +82,7 @@ import {
79
82
  writeDigestMarker,
80
83
  writeJevObservation,
81
84
  writeUserConfigPatch
82
- } from "./chunk-PFYFYJNS.js";
85
+ } from "./chunk-G52CLPRY.js";
83
86
 
84
87
  // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
85
88
  var require_code = __commonJS({
@@ -8399,7 +8402,7 @@ function runStats(ctx) {
8399
8402
 
8400
8403
  // src/commands/serve.ts
8401
8404
  async function runServe(opts) {
8402
- const { startServer } = await import("./server-JXBPTQNU.js");
8405
+ const { startServer } = await import("./server-2D6JIHWY.js");
8403
8406
  const { port, host } = startServer({ port: opts.port });
8404
8407
  process.stdout.write(`[caveat] web portal: http://${host}:${port}/
8405
8408
  `);
@@ -32797,7 +32800,7 @@ async function runMcpServer() {
32797
32800
  }
32798
32801
 
32799
32802
  // src/commands/hookCmd.ts
32800
- import { spawn as spawn2 } from "node:child_process";
32803
+ import { spawn as spawn3 } from "node:child_process";
32801
32804
  import {
32802
32805
  chmodSync,
32803
32806
  existsSync as existsSync15,
@@ -32846,6 +32849,20 @@ function maybeTriggerAutoSync(ctx, debounceMs = AUTO_SYNC_DEBOUNCE_MS) {
32846
32849
  });
32847
32850
  }
32848
32851
 
32852
+ // src/runtimeErrorReportTrigger.ts
32853
+ import { spawn as spawn2 } from "node:child_process";
32854
+ function maybeTriggerRuntimeErrorReport() {
32855
+ if (!runtimeErrorReportDue()) return;
32856
+ const cliScript = process.argv[1];
32857
+ if (!cliScript) throw new Error("current Caveat CLI script path is unavailable");
32858
+ const child = spawn2(
32859
+ process.execPath,
32860
+ [...process.execArgv, "--disable-warning=ExperimentalWarning", cliScript, "runtime-errors", "report", "--json", "--background"],
32861
+ { detached: true, stdio: "ignore", windowsHide: true }
32862
+ );
32863
+ child.unref();
32864
+ }
32865
+
32849
32866
  // src/jevStruggle.ts
32850
32867
  import { spawnSync as spawnSync3 } from "node:child_process";
32851
32868
  import { createHash as createHash3, randomBytes as randomBytes3 } from "node:crypto";
@@ -32934,6 +32951,10 @@ function reportHookError(host, phase, err) {
32934
32951
  observeRuntimeError(host.errorCode, { version: CAVEAT_VERSION });
32935
32952
  process.stderr.write(`[${host.stderrTag}] ${phase}: ${errorMessage4(err)}
32936
32953
  `);
32954
+ try {
32955
+ maybeTriggerRuntimeErrorReport();
32956
+ } catch {
32957
+ }
32937
32958
  }
32938
32959
  function parsePayload(host, raw) {
32939
32960
  if (!raw) return {};
@@ -33566,7 +33587,7 @@ function spawnWorker(job) {
33566
33587
  return;
33567
33588
  }
33568
33589
  try {
33569
- const child = spawn2(
33590
+ const child = spawn3(
33570
33591
  process.execPath,
33571
33592
  ["--disable-warning=ExperimentalWarning", cliScript, "hook", "worker", workFile],
33572
33593
  { detached: true, stdio: "ignore", windowsHide: true }
@@ -33892,6 +33913,12 @@ async function runHook(name, arg) {
33892
33913
  maybeTriggerAutoSync(ctx);
33893
33914
  } catch (err) {
33894
33915
  process.stderr.write(`[caveat:hook] auto sync trigger error: ${errorMessage4(err)}
33916
+ `);
33917
+ }
33918
+ try {
33919
+ maybeTriggerRuntimeErrorReport();
33920
+ } catch (err) {
33921
+ process.stderr.write(`[caveat:hook] runtime error report trigger error: ${errorMessage4(err)}
33895
33922
  `);
33896
33923
  }
33897
33924
  }
@@ -33914,7 +33941,7 @@ async function runHook(name, arg) {
33914
33941
  }
33915
33942
 
33916
33943
  // src/commands/codexHookCmd.ts
33917
- import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
33944
+ import { spawn as spawn4, spawnSync as spawnSync4 } from "node:child_process";
33918
33945
  import { existsSync as existsSync16, readFileSync as readFileSync11, unlinkSync, writeFileSync as writeFileSync8 } from "node:fs";
33919
33946
  import { homedir as homedir4, tmpdir as tmpdir2 } from "node:os";
33920
33947
  import { join as join16 } from "node:path";
@@ -34217,6 +34244,12 @@ async function runCodexHook(name, arg) {
34217
34244
  maybeTriggerAutoSync(ctx);
34218
34245
  } catch (err) {
34219
34246
  process.stderr.write(`[caveat:codex-hook] auto sync trigger error: ${errorMessage4(err)}
34247
+ `);
34248
+ }
34249
+ try {
34250
+ maybeTriggerRuntimeErrorReport();
34251
+ } catch (err) {
34252
+ process.stderr.write(`[caveat:codex-hook] runtime error report trigger error: ${errorMessage4(err)}
34220
34253
  `);
34221
34254
  }
34222
34255
  }
@@ -34372,6 +34405,12 @@ async function runCursorHook(name, arg) {
34372
34405
  maybeTriggerAutoSync(ctx);
34373
34406
  } catch (err) {
34374
34407
  process.stderr.write(`[caveat:cursor-hook] auto sync trigger error: ${errorMessage4(err)}
34408
+ `);
34409
+ }
34410
+ try {
34411
+ maybeTriggerRuntimeErrorReport();
34412
+ } catch (err) {
34413
+ process.stderr.write(`[caveat:cursor-hook] runtime error report trigger error: ${errorMessage4(err)}
34375
34414
  `);
34376
34415
  }
34377
34416
  }
@@ -34737,12 +34776,16 @@ function runRuntimeErrors(action, value, opts = {}) {
34737
34776
  const runtime = { version: CAVEAT_VERSION };
34738
34777
  if (action === "snapshot") return runtimeErrorsSnapshot(opts.afterCursor ?? 0, opts.limit ?? 256, runtime);
34739
34778
  if (action === "diagnostics") return runtimeErrorsDiagnostics(runtime);
34779
+ if (action === "report-status") return runtimeErrorReportStatus(runtime);
34740
34780
  if (action === "ack") return acknowledgeRuntimeErrors(parseCursor(value), runtime);
34741
34781
  if (action === "resolve") return setRuntimeErrorStatus(value ?? "", "resolved", runtime);
34742
34782
  if (action === "reopen") return setRuntimeErrorStatus(value ?? "", "open", runtime);
34743
34783
  if (action === "compact") return compactRuntimeErrors(runtime);
34744
34784
  throw new Error("unknown_runtime_errors_action");
34745
34785
  }
34786
+ function runRuntimeErrorReport(background) {
34787
+ return sendRuntimeErrorReport({ version: CAVEAT_VERSION, respectRetryWindow: background });
34788
+ }
34746
34789
  function parseCursor(value) {
34747
34790
  if (!value || !/^(?:0|[1-9][0-9]*)$/.test(value)) throw Error("invalid_cursor");
34748
34791
  const parsed = Number(value);
@@ -34828,10 +34871,16 @@ runtimeErrors.command("snapshot").requiredOption("--json", "emit JSON").option("
34828
34871
  process.stdout.write(`${JSON.stringify(runRuntimeErrors("snapshot", void 0, opts))}
34829
34872
  `);
34830
34873
  });
34831
- for (const action of ["diagnostics", "compact"]) runtimeErrors.command(action).requiredOption("--json", "emit JSON").action(() => {
34874
+ for (const action of ["diagnostics", "compact", "report-status"]) runtimeErrors.command(action).requiredOption("--json", "emit JSON").action(() => {
34832
34875
  process.stdout.write(`${JSON.stringify(runRuntimeErrors(action))}
34833
34876
  `);
34834
34877
  });
34878
+ runtimeErrors.command("report").description("Send unacknowledged runtime errors to the configured receiver").requiredOption("--json", "emit JSON").option("--background", "honour the retry window (used by the hook worker)").action(async (opts) => {
34879
+ const output = await runRuntimeErrorReport(opts.background === true);
34880
+ process.stdout.write(`${JSON.stringify(output)}
34881
+ `);
34882
+ if (output.status === "failed") process.exitCode = 1;
34883
+ });
34835
34884
  runtimeErrors.command("ack <cursor>").requiredOption("--json", "emit JSON").action((cursor) => {
34836
34885
  process.stdout.write(`${JSON.stringify(runRuntimeErrors("ack", cursor))}
34837
34886
  `);