@codacy/verity-cli 0.34.1-experimental.c910405 → 0.34.2-experimental.d59d8cb

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 (3) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/bin/verity.js +407 -270
  3. package/package.json +1 -1
package/bin/verity.js CHANGED
@@ -6975,10 +6975,10 @@ var require_resolve_block_map = __commonJS2({
6975
6975
  let offset = bm.offset;
6976
6976
  let commentEnd = null;
6977
6977
  for (const collItem of bm.items) {
6978
- const { start: start2, key, sep: sep6, value } = collItem;
6978
+ const { start: start2, key, sep: sep7, value } = collItem;
6979
6979
  const keyProps = resolveProps.resolveProps(start2, {
6980
6980
  indicator: "explicit-key-ind",
6981
- next: key ?? sep6?.[0],
6981
+ next: key ?? sep7?.[0],
6982
6982
  offset,
6983
6983
  onError,
6984
6984
  parentIndent: bm.indent,
@@ -6992,7 +6992,7 @@ var require_resolve_block_map = __commonJS2({
6992
6992
  else if ("indent" in key && key.indent !== bm.indent)
6993
6993
  onError(offset, "BAD_INDENT", startColMsg);
6994
6994
  }
6995
- if (!keyProps.anchor && !keyProps.tag && !sep6) {
6995
+ if (!keyProps.anchor && !keyProps.tag && !sep7) {
6996
6996
  commentEnd = keyProps.end;
6997
6997
  if (keyProps.comment) {
6998
6998
  if (map.comment)
@@ -7016,7 +7016,7 @@ var require_resolve_block_map = __commonJS2({
7016
7016
  ctx.atKey = false;
7017
7017
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
7018
7018
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
7019
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
7019
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
7020
7020
  indicator: "map-value-ind",
7021
7021
  next: value,
7022
7022
  offset: keyNode.range[2],
@@ -7032,7 +7032,7 @@ var require_resolve_block_map = __commonJS2({
7032
7032
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
7033
7033
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
7034
7034
  }
7035
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep6, null, valueProps, onError);
7035
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep7, null, valueProps, onError);
7036
7036
  if (ctx.schema.compat)
7037
7037
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
7038
7038
  offset = valueNode.range[2];
@@ -7123,7 +7123,7 @@ var require_resolve_end = __commonJS2({
7123
7123
  let comment = "";
7124
7124
  if (end) {
7125
7125
  let hasSpace = false;
7126
- let sep6 = "";
7126
+ let sep7 = "";
7127
7127
  for (const token of end) {
7128
7128
  const { source: source2, type } = token;
7129
7129
  switch (type) {
@@ -7137,13 +7137,13 @@ var require_resolve_end = __commonJS2({
7137
7137
  if (!comment)
7138
7138
  comment = cb;
7139
7139
  else
7140
- comment += sep6 + cb;
7141
- sep6 = "";
7140
+ comment += sep7 + cb;
7141
+ sep7 = "";
7142
7142
  break;
7143
7143
  }
7144
7144
  case "newline":
7145
7145
  if (comment)
7146
- sep6 += source2;
7146
+ sep7 += source2;
7147
7147
  hasSpace = true;
7148
7148
  break;
7149
7149
  default:
@@ -7186,18 +7186,18 @@ var require_resolve_flow_collection = __commonJS2({
7186
7186
  let offset = fc.offset + fc.start.source.length;
7187
7187
  for (let i2 = 0; i2 < fc.items.length; ++i2) {
7188
7188
  const collItem = fc.items[i2];
7189
- const { start: start2, key, sep: sep6, value } = collItem;
7189
+ const { start: start2, key, sep: sep7, value } = collItem;
7190
7190
  const props = resolveProps.resolveProps(start2, {
7191
7191
  flow: fcName,
7192
7192
  indicator: "explicit-key-ind",
7193
- next: key ?? sep6?.[0],
7193
+ next: key ?? sep7?.[0],
7194
7194
  offset,
7195
7195
  onError,
7196
7196
  parentIndent: fc.indent,
7197
7197
  startOnNewline: false
7198
7198
  });
7199
7199
  if (!props.found) {
7200
- if (!props.anchor && !props.tag && !sep6 && !value) {
7200
+ if (!props.anchor && !props.tag && !sep7 && !value) {
7201
7201
  if (i2 === 0 && props.comma)
7202
7202
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
7203
7203
  else if (i2 < fc.items.length - 1)
@@ -7251,8 +7251,8 @@ var require_resolve_flow_collection = __commonJS2({
7251
7251
  }
7252
7252
  }
7253
7253
  }
7254
- if (!isMap && !sep6 && !props.found) {
7255
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep6, null, props, onError);
7254
+ if (!isMap && !sep7 && !props.found) {
7255
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep7, null, props, onError);
7256
7256
  coll.items.push(valueNode);
7257
7257
  offset = valueNode.range[2];
7258
7258
  if (isBlock(value))
@@ -7264,7 +7264,7 @@ var require_resolve_flow_collection = __commonJS2({
7264
7264
  if (isBlock(key))
7265
7265
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
7266
7266
  ctx.atKey = false;
7267
- const valueProps = resolveProps.resolveProps(sep6 ?? [], {
7267
+ const valueProps = resolveProps.resolveProps(sep7 ?? [], {
7268
7268
  flow: fcName,
7269
7269
  indicator: "map-value-ind",
7270
7270
  next: value,
@@ -7275,8 +7275,8 @@ var require_resolve_flow_collection = __commonJS2({
7275
7275
  });
7276
7276
  if (valueProps.found) {
7277
7277
  if (!isMap && !props.found && ctx.options.strict) {
7278
- if (sep6)
7279
- for (const st of sep6) {
7278
+ if (sep7)
7279
+ for (const st of sep7) {
7280
7280
  if (st === valueProps.found)
7281
7281
  break;
7282
7282
  if (st.type === "newline") {
@@ -7293,7 +7293,7 @@ var require_resolve_flow_collection = __commonJS2({
7293
7293
  else
7294
7294
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
7295
7295
  }
7296
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep6, null, valueProps, onError) : null;
7296
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep7, null, valueProps, onError) : null;
7297
7297
  if (valueNode) {
7298
7298
  if (isBlock(value))
7299
7299
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -7473,7 +7473,7 @@ var require_resolve_block_scalar = __commonJS2({
7473
7473
  chompStart = i2 + 1;
7474
7474
  }
7475
7475
  let value = "";
7476
- let sep6 = "";
7476
+ let sep7 = "";
7477
7477
  let prevMoreIndented = false;
7478
7478
  for (let i2 = 0; i2 < contentStart; ++i2)
7479
7479
  value += lines[i2][0].slice(trimIndent) + "\n";
@@ -7490,24 +7490,24 @@ var require_resolve_block_scalar = __commonJS2({
7490
7490
  indent = "";
7491
7491
  }
7492
7492
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
7493
- value += sep6 + indent.slice(trimIndent) + content;
7494
- sep6 = "\n";
7493
+ value += sep7 + indent.slice(trimIndent) + content;
7494
+ sep7 = "\n";
7495
7495
  } else if (indent.length > trimIndent || content[0] === " ") {
7496
- if (sep6 === " ")
7497
- sep6 = "\n";
7498
- else if (!prevMoreIndented && sep6 === "\n")
7499
- sep6 = "\n\n";
7500
- value += sep6 + indent.slice(trimIndent) + content;
7501
- sep6 = "\n";
7496
+ if (sep7 === " ")
7497
+ sep7 = "\n";
7498
+ else if (!prevMoreIndented && sep7 === "\n")
7499
+ sep7 = "\n\n";
7500
+ value += sep7 + indent.slice(trimIndent) + content;
7501
+ sep7 = "\n";
7502
7502
  prevMoreIndented = true;
7503
7503
  } else if (content === "") {
7504
- if (sep6 === "\n")
7504
+ if (sep7 === "\n")
7505
7505
  value += "\n";
7506
7506
  else
7507
- sep6 = "\n";
7507
+ sep7 = "\n";
7508
7508
  } else {
7509
- value += sep6 + content;
7510
- sep6 = " ";
7509
+ value += sep7 + content;
7510
+ sep7 = " ";
7511
7511
  prevMoreIndented = false;
7512
7512
  }
7513
7513
  }
@@ -7689,25 +7689,25 @@ var require_resolve_flow_scalar = __commonJS2({
7689
7689
  if (!match)
7690
7690
  return source2;
7691
7691
  let res = match[1];
7692
- let sep6 = " ";
7692
+ let sep7 = " ";
7693
7693
  let pos = first.lastIndex;
7694
7694
  line2.lastIndex = pos;
7695
7695
  while (match = line2.exec(source2)) {
7696
7696
  if (match[1] === "") {
7697
- if (sep6 === "\n")
7698
- res += sep6;
7697
+ if (sep7 === "\n")
7698
+ res += sep7;
7699
7699
  else
7700
- sep6 = "\n";
7700
+ sep7 = "\n";
7701
7701
  } else {
7702
- res += sep6 + match[1];
7703
- sep6 = " ";
7702
+ res += sep7 + match[1];
7703
+ sep7 = " ";
7704
7704
  }
7705
7705
  pos = line2.lastIndex;
7706
7706
  }
7707
7707
  const last = /[ \t]*(.*)/sy;
7708
7708
  last.lastIndex = pos;
7709
7709
  match = last.exec(source2);
7710
- return res + sep6 + (match?.[1] ?? "");
7710
+ return res + sep7 + (match?.[1] ?? "");
7711
7711
  }
7712
7712
  function doubleQuotedValue(source2, onError) {
7713
7713
  let res = "";
@@ -8514,14 +8514,14 @@ var require_cst_stringify = __commonJS2({
8514
8514
  }
8515
8515
  }
8516
8516
  }
8517
- function stringifyItem({ start: start2, key, sep: sep6, value }) {
8517
+ function stringifyItem({ start: start2, key, sep: sep7, value }) {
8518
8518
  let res = "";
8519
8519
  for (const st of start2)
8520
8520
  res += st.source;
8521
8521
  if (key)
8522
8522
  res += stringifyToken(key);
8523
- if (sep6)
8524
- for (const st of sep6)
8523
+ if (sep7)
8524
+ for (const st of sep7)
8525
8525
  res += st.source;
8526
8526
  if (value)
8527
8527
  res += stringifyToken(value);
@@ -9671,18 +9671,18 @@ var require_parser = __commonJS2({
9671
9671
  if (this.type === "map-value-ind") {
9672
9672
  const prev = getPrevProps(this.peek(2));
9673
9673
  const start2 = getFirstKeyStartProps(prev);
9674
- let sep6;
9674
+ let sep7;
9675
9675
  if (scalar.end) {
9676
- sep6 = scalar.end;
9677
- sep6.push(this.sourceToken);
9676
+ sep7 = scalar.end;
9677
+ sep7.push(this.sourceToken);
9678
9678
  delete scalar.end;
9679
9679
  } else
9680
- sep6 = [this.sourceToken];
9680
+ sep7 = [this.sourceToken];
9681
9681
  const map = {
9682
9682
  type: "block-map",
9683
9683
  offset: scalar.offset,
9684
9684
  indent: scalar.indent,
9685
- items: [{ start: start2, key: scalar, sep: sep6 }]
9685
+ items: [{ start: start2, key: scalar, sep: sep7 }]
9686
9686
  };
9687
9687
  this.onKeyLine = true;
9688
9688
  this.stack[this.stack.length - 1] = map;
@@ -9835,15 +9835,15 @@ var require_parser = __commonJS2({
9835
9835
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
9836
9836
  const start3 = getFirstKeyStartProps(it.start);
9837
9837
  const key = it.key;
9838
- const sep6 = it.sep;
9839
- sep6.push(this.sourceToken);
9838
+ const sep7 = it.sep;
9839
+ sep7.push(this.sourceToken);
9840
9840
  delete it.key;
9841
9841
  delete it.sep;
9842
9842
  this.stack.push({
9843
9843
  type: "block-map",
9844
9844
  offset: this.offset,
9845
9845
  indent: this.indent,
9846
- items: [{ start: start3, key, sep: sep6 }]
9846
+ items: [{ start: start3, key, sep: sep7 }]
9847
9847
  });
9848
9848
  } else if (start2.length > 0) {
9849
9849
  it.sep = it.sep.concat(start2, this.sourceToken);
@@ -10037,13 +10037,13 @@ var require_parser = __commonJS2({
10037
10037
  const prev = getPrevProps(parent);
10038
10038
  const start2 = getFirstKeyStartProps(prev);
10039
10039
  fixFlowSeqItems(fc);
10040
- const sep6 = fc.end.splice(1, fc.end.length);
10041
- sep6.push(this.sourceToken);
10040
+ const sep7 = fc.end.splice(1, fc.end.length);
10041
+ sep7.push(this.sourceToken);
10042
10042
  const map = {
10043
10043
  type: "block-map",
10044
10044
  offset: fc.offset,
10045
10045
  indent: fc.indent,
10046
- items: [{ start: start2, key: fc, sep: sep6 }]
10046
+ items: [{ start: start2, key: fc, sep: sep7 }]
10047
10047
  };
10048
10048
  this.onKeyLine = true;
10049
10049
  this.stack[this.stack.length - 1] = map;
@@ -15172,8 +15172,8 @@ function filterReviewable(files) {
15172
15172
  const ext = (0, import_node_path4.extname)(f).slice(1);
15173
15173
  if (ANALYZABLE_EXTENSIONS.has(ext)) return false;
15174
15174
  if (REVIEWABLE_EXTENSIONS.has(ext)) return true;
15175
- const basename9 = f.split("/").pop() ?? "";
15176
- if (REVIEWABLE_FILENAMES.has(basename9)) return true;
15175
+ const basename11 = f.split("/").pop() ?? "";
15176
+ if (REVIEWABLE_FILENAMES.has(basename11)) return true;
15177
15177
  if (REVIEWABLE_PATH_PATTERNS.some((p) => p.test(f))) return true;
15178
15178
  return false;
15179
15179
  });
@@ -16287,6 +16287,15 @@ async function reportLoginOutcome(out2, opts = {}) {
16287
16287
  }
16288
16288
  }
16289
16289
 
16290
+ // src/lib/session-env.ts
16291
+ function envSessionId(env = process.env) {
16292
+ for (const name2 of ["CLAUDE_SESSION_ID", "CLAUDE_CODE_SESSION_ID"]) {
16293
+ const value = env[name2];
16294
+ if (value) return value;
16295
+ }
16296
+ return void 0;
16297
+ }
16298
+
16290
16299
  // src/commands/login.ts
16291
16300
  function registerLoginCommand(program2) {
16292
16301
  program2.command("login").description("Log in to Verity (one GitHub login grants access to all your repositories)").option("--force", "Re-authenticate even if already logged in").option("--start", "Show the GitHub code and return at once (finish with --finish); prints JSON").option("--finish", "Wait for approval of the code --start showed, then log in; prints JSON").option("--wait <seconds>", "With --finish: how long to wait for approval before returning", "100").option("--cancel", "Discard a code --start showed that will not be approved").action(async (opts) => {
@@ -16303,7 +16312,7 @@ function registerLoginCommand(program2) {
16303
16312
  return;
16304
16313
  }
16305
16314
  const split = !!(opts.start || opts.finish);
16306
- if (!split && !process.stdin.isTTY && (process.env.CLAUDECODE || process.env.CLAUDE_SESSION_ID)) {
16315
+ if (!split && !process.stdin.isTTY && (process.env.CLAUDECODE || envSessionId())) {
16307
16316
  printWarn("Inside a Claude Code session the code below may not be visible until this command ends.");
16308
16317
  printWarn(' Use "verity login --start", then "verity login --finish" once it is approved.');
16309
16318
  }
@@ -19477,8 +19486,8 @@ function ensureVerityGitignore() {
19477
19486
  }
19478
19487
  let text = next.join("\n");
19479
19488
  if (!hasMarker) {
19480
- const sep6 = text === "" ? "" : text.endsWith("\n") ? "\n" : "\n\n";
19481
- text = text + sep6 + VERITY_GITIGNORE_BLOCK;
19489
+ const sep7 = text === "" ? "" : text.endsWith("\n") ? "\n" : "\n\n";
19490
+ text = text + sep7 + VERITY_GITIGNORE_BLOCK;
19482
19491
  }
19483
19492
  if (text !== content) (0, import_node_fs19.writeFileSync)(".gitignore", text);
19484
19493
  return verified(
@@ -19508,8 +19517,8 @@ function writeFencedBlock() {
19508
19517
  lines = fenceMemoryLines(lines);
19509
19518
  let text = lines.join("\n");
19510
19519
  if (!hasMarker) {
19511
- const sep6 = text === "" ? "" : text.endsWith("\n") ? "\n" : "\n\n";
19512
- text = text + sep6 + VERITY_GITIGNORE_BLOCK;
19520
+ const sep7 = text === "" ? "" : text.endsWith("\n") ? "\n" : "\n\n";
19521
+ text = text + sep7 + VERITY_GITIGNORE_BLOCK;
19513
19522
  }
19514
19523
  try {
19515
19524
  (0, import_node_fs19.writeFileSync)(".gitignore", text);
@@ -19559,8 +19568,8 @@ function keepMemoryTracked() {
19559
19568
  }
19560
19569
  if (content.includes(MEMORY_OPT_OUT_MARKER)) return "already";
19561
19570
  try {
19562
- const sep6 = content === "" ? "" : content.endsWith("\n") ? "\n" : "\n\n";
19563
- (0, import_node_fs19.writeFileSync)(".gitignore", content + sep6 + MEMORY_OPT_OUT_STANZA);
19571
+ const sep7 = content === "" ? "" : content.endsWith("\n") ? "\n" : "\n\n";
19572
+ (0, import_node_fs19.writeFileSync)(".gitignore", content + sep7 + MEMORY_OPT_OUT_STANZA);
19564
19573
  } catch {
19565
19574
  return "failed";
19566
19575
  }
@@ -22150,13 +22159,13 @@ function registerIntentCommands(program2) {
22150
22159
  if (!prompt) {
22151
22160
  process.exit(0);
22152
22161
  }
22153
- if (deferredToPlugin("intent capture", event.session_id ?? process.env.CLAUDE_SESSION_ID ?? null)) {
22162
+ if (deferredToPlugin("intent capture", event.session_id ?? envSessionId() ?? null)) {
22154
22163
  process.exit(0);
22155
22164
  }
22156
22165
  const isPrimitive = isSlashCommand(prompt);
22157
22166
  const authForScope = await resolveToken(program2.opts().token);
22158
22167
  const scopeToken = authForScope.ok ? authForScope.data.token : void 0;
22159
- const scopeSession = event.session_id || process.env.CLAUDE_SESSION_ID || "";
22168
+ const scopeSession = event.session_id || envSessionId() || "";
22160
22169
  if (!isPrimitive) await appendToConversationBuffer(prompt, sessionScopeKey(scopeToken, scopeSession));
22161
22170
  if (!isPrimitive) {
22162
22171
  try {
@@ -22876,7 +22885,12 @@ function registerLifecycleCommands(program2) {
22876
22885
  }
22877
22886
  if (!verityConfigured()) process.exit(0);
22878
22887
  const event = await readHookStdin();
22879
- const sessionId = opts.sessionId ?? event.session_id ?? process.env.CLAUDE_SESSION_ID ?? null;
22888
+ const resolved = resolveHookSession(opts.sessionId, event, envSessionId());
22889
+ if (!resolved.ok) {
22890
+ logEvent("lifecycle_session_flag_refused", { command: "compact" });
22891
+ process.exit(0);
22892
+ }
22893
+ const sessionId = resolved.sessionId;
22880
22894
  if (deferredToPlugin("compact", sessionId)) process.exit(0);
22881
22895
  const globals = program2.opts();
22882
22896
  const tok = await resolveToken(globals.token);
@@ -22905,9 +22919,14 @@ function registerLifecycleCommands(program2) {
22905
22919
  }
22906
22920
  if (!verityConfigured()) process.exit(0);
22907
22921
  const event = await readHookStdin();
22908
- const sessionId = opts.sessionId ?? event.session_id ?? process.env.CLAUDE_SESSION_ID ?? null;
22922
+ const resolved = resolveHookSession(opts.sessionId, event, envSessionId());
22923
+ if (!resolved.ok) {
22924
+ logEvent("lifecycle_session_flag_refused", { command: "session end" });
22925
+ process.exit(0);
22926
+ }
22927
+ const sessionId = resolved.sessionId;
22909
22928
  if (deferredToPlugin("session end", sessionId)) process.exit(0);
22910
- const reason = opts.reason ?? event.session_end_reason ?? event.reason ?? "other";
22929
+ const reason = hookWord(opts.reason) ?? event.session_end_reason ?? event.reason ?? "other";
22911
22930
  if (reason === "clear") {
22912
22931
  writeCarry(sessionId ?? void 0, getCurrentCommit());
22913
22932
  }
@@ -22991,20 +23010,56 @@ function buildCompactionContext(session) {
22991
23010
  const trimmed = [...lines.slice(0, 5), ...lines.slice(5, 5 + 2)].join("\n");
22992
23011
  return trimmed.length <= MAX_CHARS ? trimmed : null;
22993
23012
  }
23013
+ var MAX_HOOK_EVENT_BYTES = 64 * 1024;
23014
+ var SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
23015
+ var HOOK_WORD = /^[a-z][a-z_]{0,63}$/;
23016
+ function isHookSessionId(value) {
23017
+ return typeof value === "string" && SESSION_ID.test(value);
23018
+ }
23019
+ function hookWord(value) {
23020
+ return typeof value === "string" && HOOK_WORD.test(value) ? value : void 0;
23021
+ }
23022
+ function resolveHookSession(flag, event, env) {
23023
+ if (flag !== void 0) return isHookSessionId(flag) ? { ok: true, sessionId: flag } : { ok: false };
23024
+ if (event.session_id) return { ok: true, sessionId: event.session_id };
23025
+ return { ok: true, sessionId: isHookSessionId(env) ? env : null };
23026
+ }
23027
+ function parseHookEvent(raw) {
23028
+ let data;
23029
+ try {
23030
+ data = JSON.parse(raw.trim() || "{}");
23031
+ } catch {
23032
+ return {};
23033
+ }
23034
+ if (!data || typeof data !== "object" || Array.isArray(data)) return {};
23035
+ const o = data;
23036
+ const event = {};
23037
+ if (isHookSessionId(o.session_id)) event.session_id = o.session_id;
23038
+ const compaction = hookWord(o.compaction_type);
23039
+ if (compaction) event.compaction_type = compaction;
23040
+ const endReason = hookWord(o.session_end_reason);
23041
+ if (endReason) event.session_end_reason = endReason;
23042
+ const reason = hookWord(o.reason);
23043
+ if (reason) event.reason = reason;
23044
+ return event;
23045
+ }
22994
23046
  async function readHookStdin() {
22995
23047
  try {
22996
23048
  if (process.stdin.isTTY) return {};
22997
23049
  const chunks = [];
23050
+ let size = 0;
22998
23051
  const timeout = new Promise((resolve9) => setTimeout(() => resolve9({}), 500));
22999
23052
  const read2 = new Promise((resolve9) => {
23000
- process.stdin.on("data", (c) => chunks.push(c));
23001
- process.stdin.on("end", () => {
23002
- try {
23003
- resolve9(JSON.parse(Buffer.concat(chunks).toString("utf-8").trim() || "{}"));
23004
- } catch {
23053
+ process.stdin.on("data", (c) => {
23054
+ size += c.length;
23055
+ if (size > MAX_HOOK_EVENT_BYTES) {
23056
+ process.stdin.destroy();
23005
23057
  resolve9({});
23058
+ return;
23006
23059
  }
23060
+ chunks.push(c);
23007
23061
  });
23062
+ process.stdin.on("end", () => resolve9(parseHookEvent(Buffer.concat(chunks).toString("utf-8"))));
23008
23063
  process.stdin.on("error", () => resolve9({}));
23009
23064
  process.stdin.resume();
23010
23065
  });
@@ -23828,8 +23883,8 @@ async function correctVerityMdVersion(opts) {
23828
23883
  origin: { kind: "synthesized", tools: opts.tools }
23829
23884
  }));
23830
23885
  }
23831
- async function writeFileTo(relative6, body2) {
23832
- const target = projectPath(relative6);
23886
+ async function writeFileTo(relative7, body2) {
23887
+ const target = projectPath(relative7);
23833
23888
  await (0, import_promises10.mkdir)((0, import_node_path29.dirname)(target), { recursive: true });
23834
23889
  await (0, import_promises10.writeFile)(target, body2);
23835
23890
  }
@@ -24908,7 +24963,7 @@ function registerStatusCommand(program2) {
24908
24963
  {
24909
24964
  const tokenForScope = tokenResult.data.token;
24910
24965
  const found = resolveIgnoreState(
24911
- ignoreStateKeys(tokenForScope, process.env.CLAUDE_SESSION_ID || void 0)
24966
+ ignoreStateKeys(tokenForScope, envSessionId())
24912
24967
  );
24913
24968
  const now = Math.floor(Date.now() / 1e3);
24914
24969
  const active = resolveActive(found?.state ?? null, now);
@@ -25101,7 +25156,7 @@ async function sendGeneralFeedback(message, opts, globals) {
25101
25156
  process.exit(1);
25102
25157
  }
25103
25158
  const body2 = { message };
25104
- const sessionId = opts.sessionId ?? process.env.CLAUDE_SESSION_ID;
25159
+ const sessionId = opts.sessionId ?? envSessionId();
25105
25160
  const model = opts.model ?? process.env.CLAUDE_MODEL ?? "unknown";
25106
25161
  if (sessionId) body2.session_id = sessionId;
25107
25162
  if (model) body2.agent_model = model;
@@ -26345,7 +26400,7 @@ function resolveFrame(input) {
26345
26400
  const hookDirUsable = !!input.hookCwd && (0, import_node_fs40.existsSync)(input.hookCwd);
26346
26401
  const baseDir = hookDirUsable ? input.hookCwd : process.cwd();
26347
26402
  let anchor = hookDirUsable ? "hook-cwd" : "process-cwd";
26348
- const refuse = (refusal) => ({
26403
+ const refuse2 = (refusal) => ({
26349
26404
  moment: found?.moment ?? null,
26350
26405
  frame: { worktreeRoot: null, gitDir: null, commonDir: null, isLinkedWorktree: false, branch: null, anchor, refusal }
26351
26406
  });
@@ -26359,19 +26414,19 @@ function resolveFrame(input) {
26359
26414
  if (!kindRes.some((re) => re.test(segments[i2]))) continue;
26360
26415
  const target = extractCommandTarget(input.command, i2, baseDir);
26361
26416
  if (target.named) anchor = "command-target";
26362
- if (target.unresolvable) return refuse(`target:${target.unresolvable}`);
26417
+ if (target.unresolvable) return refuse2(`target:${target.unresolvable}`);
26363
26418
  dirs.add(target.dir ?? baseDir);
26364
26419
  }
26365
- if (dirs.size > 1) return refuse(`target:multiple ${found.moment} targets in one command`);
26420
+ if (dirs.size > 1) return refuse2(`target:multiple ${found.moment} targets in one command`);
26366
26421
  const targetDir = dirs.size === 1 ? [...dirs][0] : baseDir;
26367
26422
  if (targetDir !== baseDir) {
26368
- if (!(0, import_node_fs40.existsSync)(targetDir)) return refuse(`target:directory does not exist: ${targetDir}`);
26423
+ if (!(0, import_node_fs40.existsSync)(targetDir)) return refuse2(`target:directory does not exist: ${targetDir}`);
26369
26424
  dir = targetDir;
26370
26425
  }
26371
26426
  }
26372
26427
  const toplevel = gitAt(dir, ["rev-parse", "--show-toplevel"]);
26373
26428
  if (!toplevel) {
26374
- return refuse(anchor === "command-target" ? `target:not a git repository: ${dir}` : `anchor:not a git repository: ${dir}`);
26429
+ return refuse2(anchor === "command-target" ? `target:not a git repository: ${dir}` : `anchor:not a git repository: ${dir}`);
26375
26430
  }
26376
26431
  const gitDirRaw = gitAt(dir, ["rev-parse", "--absolute-git-dir"]);
26377
26432
  const commonRaw = gitAt(dir, ["rev-parse", "--git-common-dir"]);
@@ -26967,7 +27022,7 @@ function sanitizeCommandWithLoss(rawCmd) {
26967
27022
  const lost = lines.slice(1).some((l) => l.trim().length > 0);
26968
27023
  const first = lines[0];
26969
27024
  const cmd = sanitizeCommand(first);
26970
- const hadSeparator = SEPARATORS.some((sep6) => first.indexOf(sep6) > 0);
27025
+ const hadSeparator = SEPARATORS.some((sep7) => first.indexOf(sep7) > 0);
26971
27026
  return { cmd, lost: lost || !hadSeparator && first.length > MAX_COMMAND_CHARS };
26972
27027
  }
26973
27028
  var SEPARATORS = [" | ", " > ", " >> ", " 2>", " && ", " ; "];
@@ -26976,11 +27031,11 @@ function sanitizeCommand(rawCmd) {
26976
27031
  let cmd = rawCmd.split("\n")[0];
26977
27032
  let cut = -1;
26978
27033
  let marker = "";
26979
- for (const sep6 of SEPARATORS) {
26980
- const idx = cmd.indexOf(sep6);
27034
+ for (const sep7 of SEPARATORS) {
27035
+ const idx = cmd.indexOf(sep7);
26981
27036
  if (idx > 0 && (cut === -1 || idx < cut)) {
26982
27037
  cut = idx;
26983
- marker = sep6.trim();
27038
+ marker = sep7.trim();
26984
27039
  }
26985
27040
  }
26986
27041
  if (cut > -1) cmd = cmd.slice(0, cut);
@@ -27047,13 +27102,13 @@ async function bootstrap(run4) {
27047
27102
  isTTY: process.stdout.isTTY === true
27048
27103
  });
27049
27104
  const { assistantMessage: assistantResponse, stopReason, transcriptPath, sessionId } = await readStopHookStdin();
27050
- if (deferredToPlugin("analyze", sessionId ?? process.env.CLAUDE_SESSION_ID ?? null)) {
27105
+ if (deferredToPlugin("analyze", sessionId ?? envSessionId() ?? null)) {
27051
27106
  process.exit(0);
27052
27107
  }
27053
27108
  const actionSummary = transcriptPath ? await extractActionSummary(transcriptPath) : null;
27054
27109
  const tokenResult = await resolveToken(globals.token);
27055
27110
  const scopeToken = tokenResult.ok ? tokenResult.data.token : void 0;
27056
- const rawSessionId = sessionId || process.env.CLAUDE_SESSION_ID || void 0;
27111
+ const rawSessionId = sessionId || envSessionId();
27057
27112
  const baselineSessionId = sessionScopeKey(scopeToken, rawSessionId);
27058
27113
  if (tokenResult.ok) {
27059
27114
  run4.beacon = {
@@ -27258,7 +27313,7 @@ function channelSilence(input) {
27258
27313
  // src/lib/cli-version.ts
27259
27314
  function cliVersion() {
27260
27315
  try {
27261
- return true ? "0.34.1-experimental.c910405" : "dev";
27316
+ return true ? "0.34.2-experimental.d59d8cb" : "dev";
27262
27317
  } catch {
27263
27318
  return "dev";
27264
27319
  }
@@ -28059,7 +28114,7 @@ async function connect(run4) {
28059
28114
  async function mode(run4) {
28060
28115
  const { opts, globals } = run4;
28061
28116
  const { actionSummary, allForReview, assistantResponse, baseline, conversation, memory: memory2, noFilesChanged, serviceUrl, sessionId, token, turnAuthoredCode } = run4;
28062
- const sessionIdForMemory = sessionId || process.env.CLAUDE_SESSION_ID || "";
28117
+ const sessionIdForMemory = sessionId || envSessionId() || "";
28063
28118
  let predictedMode;
28064
28119
  try {
28065
28120
  const memoryPath2 = sessionIdForMemory ? `/memory?session_id=${encodeURIComponent(sessionIdForMemory)}` : "/memory";
@@ -31952,7 +32007,7 @@ async function workingMemory(run4) {
31952
32007
  const { opts } = run4;
31953
32008
  const { allForReview, baseline, conversation, foldResult, sessionId, token, transcriptPath } = run4;
31954
32009
  let { reachability } = run4;
31955
- const memorySession = sessionDossier(token, sessionId ?? process.env.CLAUDE_SESSION_ID ?? null);
32010
+ const memorySession = sessionDossier(token, sessionId ?? envSessionId() ?? null);
31956
32011
  let memory2 = null;
31957
32012
  let incrementReport = null;
31958
32013
  if (memorySession) {
@@ -32225,7 +32280,7 @@ async function buildRequest(run4) {
32225
32280
  context: {
32226
32281
  agent_model: process.env.CLAUDE_MODEL ?? "unknown",
32227
32282
  agent_harness: "claude-code",
32228
- session_id: sessionId || process.env.CLAUDE_SESSION_ID || "unknown",
32283
+ session_id: sessionId || envSessionId() || "unknown",
32229
32284
  iteration,
32230
32285
  // Makes fleet composition falsifiable — without it, no adoption-gated
32231
32286
  // rollout decision can be checked against anything.
@@ -33522,12 +33577,12 @@ function registerBaselineCommands(program2) {
33522
33577
  if (!process.stdin.isTTY) {
33523
33578
  const input = (await readStdin()).trim();
33524
33579
  if (input) {
33525
- const event = parseHookEvent(input);
33580
+ const event = parseHookEvent2(input);
33526
33581
  if (opts.sessionId === void 0) sessionId = event.sessionId;
33527
33582
  if (opts.source === void 0) source2 = event.source;
33528
33583
  }
33529
33584
  }
33530
- const session = sessionId ?? validSessionId(process.env.CLAUDE_SESSION_ID);
33585
+ const session = sessionId ?? validSessionId(envSessionId());
33531
33586
  const cli = pluginCliInvocation();
33532
33587
  const skew = cliVersionSkew();
33533
33588
  const why = skew ? `the \`verity\` on PATH is ${skew.global} but the hooks run ${skew.hooks}, so it is not the CLI they use` : verityOnPath() ? "the `verity` on PATH is a separate install whose version could not be read" : "this machine has no `verity` on PATH \u2014 the plugin carries its own copy";
@@ -33647,7 +33702,7 @@ function registerBaselineCommands(program2) {
33647
33702
  process.exit(0);
33648
33703
  });
33649
33704
  }
33650
- var MAX_HOOK_EVENT_BYTES = 64 * 1024;
33705
+ var MAX_HOOK_EVENT_BYTES2 = 64 * 1024;
33651
33706
  var HOOK_SOURCES = /* @__PURE__ */ new Set(["startup", "resume", "clear", "compact"]);
33652
33707
  var SESSION_ID_RE2 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
33653
33708
  async function readStdin() {
@@ -33655,11 +33710,11 @@ async function readStdin() {
33655
33710
  let size = 0;
33656
33711
  for await (const chunk of process.stdin) {
33657
33712
  size += chunk.length;
33658
- if (size <= MAX_HOOK_EVENT_BYTES) chunks.push(chunk);
33713
+ if (size <= MAX_HOOK_EVENT_BYTES2) chunks.push(chunk);
33659
33714
  }
33660
- return size > MAX_HOOK_EVENT_BYTES ? "" : Buffer.concat(chunks).toString("utf-8");
33715
+ return size > MAX_HOOK_EVENT_BYTES2 ? "" : Buffer.concat(chunks).toString("utf-8");
33661
33716
  }
33662
- function parseHookEvent(input) {
33717
+ function parseHookEvent2(input) {
33663
33718
  let event;
33664
33719
  try {
33665
33720
  event = JSON.parse(input);
@@ -33680,6 +33735,34 @@ function hookSource(value) {
33680
33735
 
33681
33736
  // src/commands/review.ts
33682
33737
  var import_node_fs57 = require("node:fs");
33738
+ var import_node_path44 = require("node:path");
33739
+ function containReviewPaths(paths, base) {
33740
+ const kept = [];
33741
+ const refused2 = [];
33742
+ for (const raw of paths) {
33743
+ const candidate = (0, import_node_path44.isAbsolute)(raw) ? relativeForm(base, raw) : raw;
33744
+ if (candidate === "" || resolveInside(base, candidate) === null) refused2.push(raw);
33745
+ else kept.push(candidate);
33746
+ }
33747
+ return { kept, refused: refused2 };
33748
+ }
33749
+ function relativeForm(base, abs) {
33750
+ const lexical = (0, import_node_path44.relative)(base, abs);
33751
+ if (!(lexical === ".." || lexical.startsWith(`..${import_node_path44.sep}`) || (0, import_node_path44.isAbsolute)(lexical))) return lexical;
33752
+ try {
33753
+ let dir = (0, import_node_path44.dirname)(abs);
33754
+ let rest = (0, import_node_path44.basename)(abs);
33755
+ while (!(0, import_node_fs57.existsSync)(dir)) {
33756
+ const up = (0, import_node_path44.dirname)(dir);
33757
+ if (up === dir) return lexical;
33758
+ rest = (0, import_node_path44.join)((0, import_node_path44.basename)(dir), rest);
33759
+ dir = up;
33760
+ }
33761
+ return (0, import_node_path44.relative)((0, import_node_fs57.realpathSync)(base), (0, import_node_path44.join)((0, import_node_fs57.realpathSync)(dir), rest));
33762
+ } catch {
33763
+ return lexical;
33764
+ }
33765
+ }
33683
33766
  function registerReviewCommand(program2) {
33684
33767
  program2.command("review").description("Run on-demand Verity analysis (advisory, never blocks)").requiredOption("--files <paths>", "Comma-separated file list").option("--changed <paths>", "Subset of --files that were modified").option("--intent <text>", "User intent description (max 2000 chars); - reads it from stdin, so the words never pass through shell quoting").option("--specs <paths>", "Comma-separated spec file paths").option("--json", "Output raw JSON response").action(async (opts) => {
33685
33768
  const globals = program2.opts();
@@ -33698,8 +33781,20 @@ function registerReviewCommand(program2) {
33698
33781
  });
33699
33782
  }
33700
33783
  async function runReview(opts, globals) {
33701
- const allFiles = opts.files.split(",").map((f) => f.trim()).filter(Boolean);
33702
- const changedFiles = opts.changed ? opts.changed.split(",").map((f) => f.trim()).filter(Boolean) : allFiles;
33784
+ const base = process.cwd();
33785
+ const files = containReviewPaths(opts.files.split(",").map((f) => f.trim()).filter(Boolean), base);
33786
+ const changed = opts.changed ? containReviewPaths(opts.changed.split(",").map((f) => f.trim()).filter(Boolean), base) : files;
33787
+ const refused2 = Array.from(/* @__PURE__ */ new Set([...files.refused, ...changed.refused]));
33788
+ if (refused2.length > 0) {
33789
+ printJsonCompact({
33790
+ gate_decision: "WARN",
33791
+ systemMessage: `Verity: refused ${refused2.length} path(s) outside this repository \u2014 nothing was reviewed. Pass paths inside the repository you run \`verity review\` from.`,
33792
+ refused_paths: refused2
33793
+ });
33794
+ process.exit(0);
33795
+ }
33796
+ const allFiles = files.kept;
33797
+ const changedFiles = changed.kept;
33703
33798
  const analyzable = filterAnalyzable(allFiles);
33704
33799
  const securityFiles = filterSecurity(allFiles);
33705
33800
  const scannable = Array.from(/* @__PURE__ */ new Set([...analyzable, ...securityFiles])).filter((f) => (0, import_node_fs57.existsSync)(f) || resolveFile(f) !== null);
@@ -33727,7 +33822,7 @@ async function runReview(opts, globals) {
33727
33822
  context: {
33728
33823
  agent_model: process.env.CLAUDE_MODEL ?? "unknown",
33729
33824
  agent_harness: "claude-code",
33730
- session_id: process.env.CLAUDE_SESSION_ID ?? "unknown",
33825
+ session_id: envSessionId() ?? "unknown",
33731
33826
  trigger: "review",
33732
33827
  iteration: 1
33733
33828
  }
@@ -33769,11 +33864,11 @@ async function runReview(opts, globals) {
33769
33864
 
33770
33865
  // src/commands/guard.ts
33771
33866
  var import_node_fs62 = require("node:fs");
33772
- var import_node_path49 = require("node:path");
33867
+ var import_node_path50 = require("node:path");
33773
33868
 
33774
33869
  // src/lib/vendored.ts
33775
33870
  var import_node_fs58 = require("node:fs");
33776
- var import_node_path44 = require("node:path");
33871
+ var import_node_path45 = require("node:path");
33777
33872
  var INSTALLED_SKILL = /^\.claude\/skills\/(verity-[a-z0-9-]+)\/(.+)$/;
33778
33873
  function dataDirOrNull() {
33779
33874
  try {
@@ -33788,7 +33883,7 @@ function shippedSkillFile(path, dataDir = dataDirOrNull()) {
33788
33883
  const [, skill, rel] = m;
33789
33884
  if (rel.split("/").some((seg) => seg === ".." || seg === ".")) return null;
33790
33885
  try {
33791
- return (0, import_node_fs58.readFileSync)((0, import_node_path44.join)(dataDir, "skills", skill, rel), "utf8");
33886
+ return (0, import_node_fs58.readFileSync)((0, import_node_path45.join)(dataDir, "skills", skill, rel), "utf8");
33792
33887
  } catch {
33793
33888
  return null;
33794
33889
  }
@@ -33898,7 +33993,7 @@ async function runAgentReview(options) {
33898
33993
  }
33899
33994
 
33900
33995
  // src/lib/prove/auto.ts
33901
- var import_node_path48 = require("node:path");
33996
+ var import_node_path49 = require("node:path");
33902
33997
  var import_node_crypto19 = require("node:crypto");
33903
33998
 
33904
33999
  // src/lib/prove/signals.ts
@@ -35585,9 +35680,9 @@ async function runReplay(brief, opts) {
35585
35680
  if (opts.auth) return runReplayViaServer(brief, opts.auth, opts.timeoutMs);
35586
35681
  const env = opts.env ?? process.env;
35587
35682
  const none = { covered: 0, total: 0, ratio: 0, basis: "none" };
35588
- const refuse = (error) => ({ claimed: null, verdict: "unverified", reason: "", downgrade: error, executedCalls: 0, shellCalls: 0, verbatim: none, executedOutput: "", harnessFiles: [], usage: null, durationMs: 0, containerId: null, error });
35589
- if (env.VERITY_PROVE_DIRECT !== "1") return refuse("not logged in (run `verity login`); replays run on the Verity service");
35590
- if (!opts.apiKey) return refuse("OPENAI_API_KEY is not set");
35683
+ const refuse2 = (error) => ({ claimed: null, verdict: "unverified", reason: "", downgrade: error, executedCalls: 0, shellCalls: 0, verbatim: none, executedOutput: "", harnessFiles: [], usage: null, durationMs: 0, containerId: null, error });
35684
+ if (env.VERITY_PROVE_DIRECT !== "1") return refuse2("not logged in (run `verity login`); replays run on the Verity service");
35685
+ if (!opts.apiKey) return refuse2("OPENAI_API_KEY is not set");
35591
35686
  return runReplayInContainer(brief, { apiKey: opts.apiKey, model: opts.model, timeoutMs: opts.timeoutMs, maxRounds: opts.maxRounds, fetchImpl: opts.fetchImpl });
35592
35687
  }
35593
35688
  function renderReplay(model, property, r) {
@@ -35627,16 +35722,16 @@ var import_node_child_process15 = require("node:child_process");
35627
35722
  var import_node_os8 = require("node:os");
35628
35723
  var import_node_fs61 = require("node:fs");
35629
35724
  var import_node_os9 = require("node:os");
35630
- var import_node_path47 = require("node:path");
35725
+ var import_node_path48 = require("node:path");
35631
35726
 
35632
35727
  // src/lib/prove/scaffold.ts
35633
35728
  var import_node_fs60 = require("node:fs");
35634
- var import_node_path46 = require("node:path");
35729
+ var import_node_path47 = require("node:path");
35635
35730
 
35636
35731
  // src/lib/prove/safe-write.ts
35637
35732
  var import_node_fs59 = require("node:fs");
35638
35733
  var import_node_crypto15 = require("node:crypto");
35639
- var import_node_path45 = require("node:path");
35734
+ var import_node_path46 = require("node:path");
35640
35735
  var SafeWriteError = class extends Error {
35641
35736
  constructor(reason, path) {
35642
35737
  super(`refusing to write ${path}: ${reason}`);
@@ -35648,7 +35743,7 @@ var SafeWriteError = class extends Error {
35648
35743
  var FLAGS3 = import_node_fs59.constants;
35649
35744
  var NOFOLLOW2 = FLAGS3.O_NOFOLLOW ?? 0;
35650
35745
  function assertPlainRelative(rel) {
35651
- if (!rel || (0, import_node_path45.isAbsolute)(rel)) throw new SafeWriteError("bad-path", rel);
35746
+ if (!rel || (0, import_node_path46.isAbsolute)(rel)) throw new SafeWriteError("bad-path", rel);
35652
35747
  for (const part of rel.split(/[\\/]/)) {
35653
35748
  if (part === ".." || part === "" || part === ".") throw new SafeWriteError("bad-path", rel);
35654
35749
  }
@@ -35657,7 +35752,7 @@ function ensureDirsNoFollow(root, rel) {
35657
35752
  const parts2 = rel.split(/[\\/]/);
35658
35753
  let cur = root;
35659
35754
  for (const part of parts2.slice(0, -1)) {
35660
- cur = (0, import_node_path45.join)(cur, part);
35755
+ cur = (0, import_node_path46.join)(cur, part);
35661
35756
  let st;
35662
35757
  try {
35663
35758
  st = (0, import_node_fs59.lstatSync)(cur);
@@ -35668,10 +35763,10 @@ function ensureDirsNoFollow(root, rel) {
35668
35763
  if (st.isSymbolicLink()) throw new SafeWriteError("symlink", cur);
35669
35764
  if (!st.isDirectory()) throw new SafeWriteError("not-regular", cur);
35670
35765
  }
35671
- return (0, import_node_path45.join)(root, rel);
35766
+ return (0, import_node_path46.join)(root, rel);
35672
35767
  }
35673
35768
  function insideRoot(realRoot, realPath) {
35674
- return realPath === realRoot || realPath.startsWith(realRoot.endsWith(import_node_path45.sep) ? realRoot : realRoot + import_node_path45.sep);
35769
+ return realPath === realRoot || realPath.startsWith(realRoot.endsWith(import_node_path46.sep) ? realRoot : realRoot + import_node_path46.sep);
35675
35770
  }
35676
35771
  function removeQuietly(path) {
35677
35772
  try {
@@ -35682,7 +35777,7 @@ function removeQuietly(path) {
35682
35777
  function writeFileInRootNoFollow(root, rel, content) {
35683
35778
  assertPlainRelative(rel);
35684
35779
  const dest = ensureDirsNoFollow(root, rel);
35685
- const dir = (0, import_node_path45.dirname)(dest);
35780
+ const dir = (0, import_node_path46.dirname)(dest);
35686
35781
  try {
35687
35782
  const st = (0, import_node_fs59.lstatSync)(dest);
35688
35783
  if (st.isSymbolicLink()) throw new SafeWriteError("symlink", dest);
@@ -35696,7 +35791,7 @@ function writeFileInRootNoFollow(root, rel, content) {
35696
35791
  } catch {
35697
35792
  throw new SafeWriteError("unwritable", root);
35698
35793
  }
35699
- const tmp = (0, import_node_path45.join)(dir, `.${(0, import_node_path45.basename)(dest)}.${(0, import_node_crypto15.randomBytes)(6).toString("hex")}.tmp`);
35794
+ const tmp = (0, import_node_path46.join)(dir, `.${(0, import_node_path46.basename)(dest)}.${(0, import_node_crypto15.randomBytes)(6).toString("hex")}.tmp`);
35700
35795
  let fd;
35701
35796
  try {
35702
35797
  fd = (0, import_node_fs59.openSync)(tmp, import_node_fs59.constants.O_WRONLY | import_node_fs59.constants.O_CREAT | import_node_fs59.constants.O_EXCL | NOFOLLOW2, 420);
@@ -35740,7 +35835,7 @@ function pathHasNoLink(root, rel) {
35740
35835
  }
35741
35836
  let cur = root;
35742
35837
  for (const part of rel.split(/[\\/]/)) {
35743
- cur = cur + import_node_path45.sep + part;
35838
+ cur = cur + import_node_path46.sep + part;
35744
35839
  try {
35745
35840
  if ((0, import_node_fs59.lstatSync)(cur).isSymbolicLink()) return false;
35746
35841
  } catch {
@@ -36052,20 +36147,20 @@ This directory is machine-local and gitignored (see ../.gitignore). Models are
36052
36147
  never committed; what reaches the team is the bug report and the fix.
36053
36148
  `;
36054
36149
  function scaffoldProofs(root) {
36055
- const proofsDir = (0, import_node_path46.join)(root, PROOFS_DIR);
36150
+ const proofsDir = (0, import_node_path47.join)(root, PROOFS_DIR);
36056
36151
  const written = [];
36057
36152
  const kept = [];
36058
36153
  for (const stray of ["lakefile.lean"]) {
36059
36154
  const rel = `${PROOFS_DIR}/${stray}`;
36060
- if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path46.join)(root, rel));
36155
+ if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path47.join)(root, rel));
36061
36156
  try {
36062
- (0, import_node_fs60.rmSync)((0, import_node_path46.join)(root, rel), { force: true });
36157
+ (0, import_node_fs60.rmSync)((0, import_node_path47.join)(root, rel), { force: true });
36063
36158
  } catch {
36064
36159
  }
36065
36160
  }
36066
36161
  for (const f of PROOFS_TEMPLATE_FILES) {
36067
36162
  const rel = `${PROOFS_DIR}/${f.path}`;
36068
- if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path46.join)(root, rel));
36163
+ if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path47.join)(root, rel));
36069
36164
  const current = readRegularFileInRoot(root, rel, 4 * 1024 * 1024);
36070
36165
  if (current.ok && current.content === f.content) {
36071
36166
  kept.push(rel);
@@ -36078,8 +36173,8 @@ function scaffoldProofs(root) {
36078
36173
  [`${PROOFS_DIR}/.gitignore`, LOCAL_GITIGNORE],
36079
36174
  [`${MODELS_DIR}/README.md`, MODELS_README]
36080
36175
  ]) {
36081
- if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path46.join)(root, rel));
36082
- if (existsNoFollow((0, import_node_path46.join)(root, rel))) {
36176
+ if (!pathHasNoLink(root, rel)) throw new SafeWriteError("symlink", (0, import_node_path47.join)(root, rel));
36177
+ if (existsNoFollow((0, import_node_path47.join)(root, rel))) {
36083
36178
  kept.push(rel);
36084
36179
  continue;
36085
36180
  }
@@ -36348,17 +36443,17 @@ function renderReport(r) {
36348
36443
 
36349
36444
  // src/lib/prove/runner.ts
36350
36445
  function verityLeanHome(env = process.env) {
36351
- return env.VERITY_LEAN_HOME ?? (0, import_node_path47.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".verity", "lean");
36446
+ return env.VERITY_LEAN_HOME ?? (0, import_node_path48.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".verity", "lean");
36352
36447
  }
36353
36448
  function findToolchain(env = process.env) {
36354
- const managedBin = (0, import_node_path47.join)(verityLeanHome(env), LEAN_TOOLCHAIN.replace(/^leanprover\/lean4:/, ""), "bin");
36355
- const elanBin = (0, import_node_path47.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "bin");
36356
- const elanHas = (0, import_node_fs61.existsSync)((0, import_node_path47.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "toolchains", LEAN_TOOLCHAIN.replace("/", "--").replace(":", "---")));
36357
- const userPath = (env.PATH ?? "").split(import_node_path47.delimiter).filter((d) => d && (elanHas || (0, import_node_path47.resolve)(d) !== (0, import_node_path47.resolve)(elanBin)));
36358
- const path = [managedBin, ...elanHas ? [elanBin] : [], ...userPath].join(import_node_path47.delimiter);
36449
+ const managedBin = (0, import_node_path48.join)(verityLeanHome(env), LEAN_TOOLCHAIN.replace(/^leanprover\/lean4:/, ""), "bin");
36450
+ const elanBin = (0, import_node_path48.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "bin");
36451
+ const elanHas = (0, import_node_fs61.existsSync)((0, import_node_path48.join)(env.HOME ?? (0, import_node_os9.homedir)(), ".elan", "toolchains", LEAN_TOOLCHAIN.replace("/", "--").replace(":", "---")));
36452
+ const userPath = (env.PATH ?? "").split(import_node_path48.delimiter).filter((d) => d && (elanHas || (0, import_node_path48.resolve)(d) !== (0, import_node_path48.resolve)(elanBin)));
36453
+ const path = [managedBin, ...elanHas ? [elanBin] : [], ...userPath].join(import_node_path48.delimiter);
36359
36454
  const merged = { ...env, PATH: path, ELAN_TOOLCHAIN: env.ELAN_TOOLCHAIN ?? LEAN_TOOLCHAIN };
36360
36455
  const exe = process.platform === "win32" ? "lake.exe" : "lake";
36361
- const candidates2 = [(0, import_node_path47.join)(managedBin, exe), ...elanHas ? [(0, import_node_path47.join)(elanBin, exe)] : [], exe];
36456
+ const candidates2 = [(0, import_node_path48.join)(managedBin, exe), ...elanHas ? [(0, import_node_path48.join)(elanBin, exe)] : [], exe];
36362
36457
  for (const candidate of candidates2) {
36363
36458
  try {
36364
36459
  (0, import_node_child_process15.execFileSync)(candidate, ["--version"], { env: merged, stdio: ["ignore", "pipe", "pipe"], timeout: 1e4 });
@@ -36437,7 +36532,7 @@ function proofsWorkspaceProblem(root) {
36437
36532
  for (const rel of [".verity", PROOFS_DIR, `${PROOFS_DIR}/.lake`]) {
36438
36533
  let st;
36439
36534
  try {
36440
- st = (0, import_node_fs61.lstatSync)((0, import_node_path47.join)(root, rel));
36535
+ st = (0, import_node_fs61.lstatSync)((0, import_node_path48.join)(root, rel));
36441
36536
  } catch {
36442
36537
  break;
36443
36538
  }
@@ -36457,44 +36552,44 @@ function refused(problem) {
36457
36552
  function buildLibrary(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
36458
36553
  const problem = proofsWorkspaceProblem(root);
36459
36554
  if (problem) return refused(problem);
36460
- return run2(tc, (0, import_node_path47.join)(root, PROOFS_DIR), ["build"], timeoutMs);
36555
+ return run2(tc, (0, import_node_path48.join)(root, PROOFS_DIR), ["build"], timeoutMs);
36461
36556
  }
36462
36557
  async function buildLibraryAsync(tc, root, timeoutMs = DEFAULT_BUILD_TIMEOUT_MS) {
36463
36558
  const problem = proofsWorkspaceProblem(root);
36464
36559
  if (problem) return refused(problem);
36465
- return runAsync(tc, (0, import_node_path47.join)(root, PROOFS_DIR), ["build"], timeoutMs);
36560
+ return runAsync(tc, (0, import_node_path48.join)(root, PROOFS_DIR), ["build"], timeoutMs);
36466
36561
  }
36467
36562
  function isModelInRoot(modelsAbs, rel) {
36468
- if (!rel.endsWith(".lean") || (0, import_node_path47.isAbsolute)(rel) || rel.startsWith("..")) return false;
36563
+ if (!rel.endsWith(".lean") || (0, import_node_path48.isAbsolute)(rel) || rel.startsWith("..")) return false;
36469
36564
  return statRegularInRoot(modelsAbs, rel).ok;
36470
36565
  }
36471
36566
  function resolveModelFile(root, arg) {
36472
- const modelsAbs = (0, import_node_path47.join)(root, MODELS_DIR);
36473
- const asPath = (0, import_node_path47.relative)(modelsAbs, (0, import_node_path47.isAbsolute)(arg) ? arg : (0, import_node_path47.resolve)(root, arg));
36567
+ const modelsAbs = (0, import_node_path48.join)(root, MODELS_DIR);
36568
+ const asPath = (0, import_node_path48.relative)(modelsAbs, (0, import_node_path48.isAbsolute)(arg) ? arg : (0, import_node_path48.resolve)(root, arg));
36474
36569
  const candidates2 = arg.includes("/") || arg.includes("\\") ? [asPath] : [arg, `${arg}.lean`];
36475
36570
  for (const rel of candidates2) {
36476
- if (isModelInRoot(modelsAbs, rel)) return (0, import_node_path47.join)(modelsAbs, rel);
36571
+ if (isModelInRoot(modelsAbs, rel)) return (0, import_node_path48.join)(modelsAbs, rel);
36477
36572
  }
36478
36573
  return null;
36479
36574
  }
36480
36575
  function listModelFiles(root) {
36481
- const modelsAbs = (0, import_node_path47.join)(root, MODELS_DIR);
36576
+ const modelsAbs = (0, import_node_path48.join)(root, MODELS_DIR);
36482
36577
  if (!(0, import_node_fs61.existsSync)(modelsAbs)) return [];
36483
- return (0, import_node_fs61.readdirSync)(modelsAbs).filter((f) => isModelInRoot(modelsAbs, f)).sort().map((f) => (0, import_node_path47.join)(modelsAbs, f));
36578
+ return (0, import_node_fs61.readdirSync)(modelsAbs).filter((f) => isModelInRoot(modelsAbs, f)).sort().map((f) => (0, import_node_path48.join)(modelsAbs, f));
36484
36579
  }
36485
36580
  function trimDiagnostics(text) {
36486
36581
  return text.split("\n").filter((l) => !l.startsWith("trace:")).join("\n").trim().slice(0, 4e3);
36487
36582
  }
36488
36583
  function checkModel(tc, root, modelFile, opts = {}) {
36489
- const proofsAbs = (0, import_node_path47.join)(root, PROOFS_DIR);
36490
- const rel = (0, import_node_path47.relative)(proofsAbs, modelFile);
36584
+ const proofsAbs = (0, import_node_path48.join)(root, PROOFS_DIR);
36585
+ const rel = (0, import_node_path48.relative)(proofsAbs, modelFile);
36491
36586
  const problem = proofsWorkspaceProblem(root);
36492
36587
  const res = problem ? refused(problem) : run2(tc, proofsAbs, ["env", "lean", rel], opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
36493
36588
  return toReport(res, root, modelFile, opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
36494
36589
  }
36495
36590
  async function checkModelAsync(tc, root, modelFile, opts = {}) {
36496
- const proofsAbs = (0, import_node_path47.join)(root, PROOFS_DIR);
36497
- const rel = (0, import_node_path47.relative)(proofsAbs, modelFile);
36591
+ const proofsAbs = (0, import_node_path48.join)(root, PROOFS_DIR);
36592
+ const rel = (0, import_node_path48.relative)(proofsAbs, modelFile);
36498
36593
  const problem = proofsWorkspaceProblem(root);
36499
36594
  const res = problem ? refused(problem) : await runAsync(tc, proofsAbs, ["env", "lean", rel], opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
36500
36595
  return toReport(res, root, modelFile, opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS);
@@ -36503,10 +36598,10 @@ function toReport(res, root, modelFile, timeoutMs) {
36503
36598
  const parsed = parseVerityLines(res.stdout);
36504
36599
  const combined = `${res.stdout}
36505
36600
  ${res.stderr}`;
36506
- const name2 = parsed.header?.model ?? (0, import_node_path47.basename)(modelFile, ".lean");
36601
+ const name2 = parsed.header?.model ?? (0, import_node_path48.basename)(modelFile, ".lean");
36507
36602
  const report = {
36508
36603
  model: name2,
36509
- file: (0, import_node_path47.relative)(root, modelFile),
36604
+ file: (0, import_node_path48.relative)(root, modelFile),
36510
36605
  ok: res.ok,
36511
36606
  header: parsed.header,
36512
36607
  properties: parsed.properties,
@@ -37076,7 +37171,7 @@ async function runFormalPhase(input) {
37076
37171
  modelName = gen.name;
37077
37172
  const rel = `${AUTO_MODELS_DIR}/${gen.name}.lean`;
37078
37173
  writeFileInRootNoFollow(root, rel, gen.source);
37079
- const abs = resolveModelFile(root, rel) ?? (0, import_node_path48.join)(root, rel);
37174
+ const abs = resolveModelFile(root, rel) ?? (0, import_node_path49.join)(root, rel);
37080
37175
  progress.model = { name: gen.name, file: rel, rounds: round };
37081
37176
  progress.step = "check";
37082
37177
  report = await deps.check(root, abs);
@@ -37198,7 +37293,7 @@ async function runFormalPhase(input) {
37198
37293
  return done({
37199
37294
  status: "checked",
37200
37295
  target,
37201
- model: { name: modelName, file: (0, import_node_path48.relative)(root, (0, import_node_path48.join)(root, modelFile)), rounds },
37296
+ model: { name: modelName, file: (0, import_node_path49.relative)(root, (0, import_node_path49.join)(root, modelFile)), rounds },
37202
37297
  properties: report.properties,
37203
37298
  findings
37204
37299
  });
@@ -37275,7 +37370,7 @@ async function generateAndCheck(root, req, opts) {
37275
37370
  }
37276
37371
  const rel = `${dir}/${gen.name}.lean`;
37277
37372
  writeFileInRootNoFollow(root, rel, gen.source);
37278
- const abs = resolveModelFile(root, rel) ?? (0, import_node_path48.join)(root, rel);
37373
+ const abs = resolveModelFile(root, rel) ?? (0, import_node_path49.join)(root, rel);
37279
37374
  const report = await opts.deps.check(root, abs);
37280
37375
  const abstracts = report.header?.abstracts ?? [];
37281
37376
  const stray = abstracts.find((a) => !headerFiles.has(a.file)) ?? (abstracts[0] && abstracts[0].file !== req.file ? abstracts[0] : void 0);
@@ -37537,7 +37632,7 @@ var WRITERS_BUDGET_MS = 1500;
37537
37632
  var EXCERPT_MAX_LINES2 = 30;
37538
37633
  var VENDORED_READ_MAX_BYTES = 256 * 1024;
37539
37634
  var GUARD_BLOCK_CAP = 2;
37540
- var GUARD_ITER_FILE = (0, import_node_path49.join)(VERITY_DIR, ".guard-iteration");
37635
+ var GUARD_ITER_FILE = (0, import_node_path50.join)(VERITY_DIR, ".guard-iteration");
37541
37636
  function readPreToolUseStdin() {
37542
37637
  const empty = { command: "", cwd: null, sessionId: null };
37543
37638
  return new Promise((resolve9) => {
@@ -37701,7 +37796,7 @@ function buildGuardRequest(moment, files, codeDelta, iter, sessionId, statedInte
37701
37796
  agent_harness: "claude-code",
37702
37797
  // Prefer the session id Claude Code passes on the hook payload; fall back
37703
37798
  // to the env var, then 'unknown'.
37704
- session_id: sessionId ?? process.env.CLAUDE_SESSION_ID ?? "unknown",
37799
+ session_id: sessionId ?? envSessionId() ?? "unknown",
37705
37800
  trigger,
37706
37801
  iteration: iter + 1
37707
37802
  }
@@ -38229,7 +38324,7 @@ function writeBlockMessage(moment, response, covDetail) {
38229
38324
 
38230
38325
  // src/commands/ignore.ts
38231
38326
  function registerIgnoreCommand(program2) {
38232
- const ignore = program2.command("ignore").description("Declare the next turn (or a short window) as housekeeping \u2014 no review needed").option("--turn", "Cover the next turn only (the default)").option("--for <duration>", "Cover a window: 30m, 45s, 1h (max 60m)").option("--reason <reason>", "Why this window needs no review \u2014 required, and recorded").option("--agent", "Mark the declaration as agent-invoked (a ledger label, not a permission)").option("--session-id <id>", "Session id (defaults to $CLAUDE_SESSION_ID)").option("--json", "Output raw JSON").action(async (opts) => {
38327
+ const ignore = program2.command("ignore").description("Declare the next turn (or a short window) as housekeeping \u2014 no review needed").option("--turn", "Cover the next turn only (the default)").option("--for <duration>", "Cover a window: 30m, 45s, 1h (max 60m)").option("--reason <reason>", "Why this window needs no review \u2014 required, and recorded").option("--agent", "Mark the declaration as agent-invoked (a ledger label, not a permission)").option("--session-id <id>", "Session id (defaults to $CLAUDE_SESSION_ID, then $CLAUDE_CODE_SESSION_ID)").option("--json", "Output raw JSON").action(async (opts) => {
38233
38328
  const globals = program2.opts();
38234
38329
  const now = Math.floor(Date.now() / 1e3);
38235
38330
  const reason = opts.reason?.trim();
@@ -38256,7 +38351,7 @@ function registerIgnoreCommand(program2) {
38256
38351
  }
38257
38352
  const tokenResult = await resolveToken(globals.token);
38258
38353
  const token = tokenResult.ok ? tokenResult.data.token : void 0;
38259
- const sessionId = opts.sessionId || process.env.CLAUDE_SESSION_ID || void 0;
38354
+ const sessionId = opts.sessionId || envSessionId();
38260
38355
  const keys = ignoreStateKeys(token, sessionId);
38261
38356
  const existing = resolveIgnoreState(keys);
38262
38357
  const spent = existing?.state.spent ?? 0;
@@ -38302,11 +38397,11 @@ function registerIgnoreCommand(program2) {
38302
38397
  printInfo(`Verity will skip ${window2} \u2014 "${reason}" (${spent + 1}/${IGNORE_BUDGET} this session).`);
38303
38398
  printInfo("It covers turns that author nothing. If anything is written, the declaration voids and the review runs.");
38304
38399
  });
38305
- ignore.command("clear").description("Cancel the active declaration (the spent budget is not refunded)").option("--session-id <id>", "Session id (defaults to $CLAUDE_SESSION_ID)").action(async (opts) => {
38400
+ ignore.command("clear").description("Cancel the active declaration (the spent budget is not refunded)").option("--session-id <id>", "Session id (defaults to $CLAUDE_SESSION_ID, then $CLAUDE_CODE_SESSION_ID)").action(async (opts) => {
38306
38401
  const globals = program2.opts();
38307
38402
  const tokenResult = await resolveToken(globals.token);
38308
38403
  const token = tokenResult.ok ? tokenResult.data.token : void 0;
38309
- const sessionId = opts.sessionId || process.env.CLAUDE_SESSION_ID || void 0;
38404
+ const sessionId = opts.sessionId || envSessionId();
38310
38405
  const found = resolveIgnoreState(ignoreStateKeys(token, sessionId));
38311
38406
  const active = resolveActive(found?.state ?? null, Math.floor(Date.now() / 1e3));
38312
38407
  if (!found || !active) {
@@ -38378,7 +38473,7 @@ function registerWaiveCommand(program2) {
38378
38473
  var import_node_fs68 = require("node:fs");
38379
38474
  var import_promises20 = require("node:fs/promises");
38380
38475
  var import_yaml6 = __toESM2(require_dist());
38381
- var import_node_path53 = require("node:path");
38476
+ var import_node_path54 = require("node:path");
38382
38477
  var import_node_os11 = require("node:os");
38383
38478
  var import_node_child_process19 = require("node:child_process");
38384
38479
 
@@ -38830,7 +38925,7 @@ function registerDoctorCommand(program2) {
38830
38925
 
38831
38926
  // src/commands/migrate.ts
38832
38927
  var import_node_fs65 = require("node:fs");
38833
- var import_node_path50 = require("node:path");
38928
+ var import_node_path51 = require("node:path");
38834
38929
  var import_node_child_process17 = require("node:child_process");
38835
38930
  var LEGACY_NPM_PACKAGE = "@codacy/gate-cli";
38836
38931
  function defaultNpmRemover(pkg) {
@@ -38867,8 +38962,8 @@ async function runMigration(opts = {}) {
38867
38962
  return { actions, migrated: actions.length > 0 };
38868
38963
  }
38869
38964
  function migrateProjectDir(root, actions) {
38870
- const gateDir = (0, import_node_path50.join)(root, ".gate");
38871
- const verityDir = (0, import_node_path50.join)(root, ".verity");
38965
+ const gateDir = (0, import_node_path51.join)(root, ".gate");
38966
+ const verityDir = (0, import_node_path51.join)(root, ".verity");
38872
38967
  if ((0, import_node_fs65.existsSync)(gateDir) && !(0, import_node_fs65.existsSync)(verityDir)) {
38873
38968
  return migrateProjectDirRename(root, gateDir, verityDir, actions);
38874
38969
  }
@@ -38922,11 +39017,11 @@ function migrateProjectDirCarry(gateDir, verityDir, actions) {
38922
39017
  }
38923
39018
  function migrateGlobalCredentials(home, actions) {
38924
39019
  if (!home) return;
38925
- const gateCreds = (0, import_node_path50.join)(home, ".gate", "credentials");
38926
- const verityCreds = (0, import_node_path50.join)(home, ".verity", "credentials");
39020
+ const gateCreds = (0, import_node_path51.join)(home, ".gate", "credentials");
39021
+ const verityCreds = (0, import_node_path51.join)(home, ".verity", "credentials");
38927
39022
  if (!(0, import_node_fs65.existsSync)(gateCreds)) return;
38928
39023
  if (!(0, import_node_fs65.existsSync)(verityCreds)) {
38929
- (0, import_node_fs65.mkdirSync)((0, import_node_path50.join)(home, ".verity"), { recursive: true });
39024
+ (0, import_node_fs65.mkdirSync)((0, import_node_path51.join)(home, ".verity"), { recursive: true });
38930
39025
  moveFile(gateCreds, verityCreds);
38931
39026
  actions.push("Moved ~/.gate/credentials \u2192 ~/.verity/credentials");
38932
39027
  return;
@@ -38948,7 +39043,7 @@ async function migrateLegacyHooks(root, actions) {
38948
39043
  }
38949
39044
  }
38950
39045
  async function migrateClaudeMd(root, actions) {
38951
- const claudeMd = (0, import_node_path50.join)(root, "CLAUDE.md");
39046
+ const claudeMd = (0, import_node_path51.join)(root, "CLAUDE.md");
38952
39047
  const hadLegacyBlock = (0, import_node_fs65.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd));
38953
39048
  if (!hadLegacyBlock) return;
38954
39049
  try {
@@ -38959,8 +39054,8 @@ async function migrateClaudeMd(root, actions) {
38959
39054
  }
38960
39055
  }
38961
39056
  function migrateStandardFile(root, actions) {
38962
- const gateMd = (0, import_node_path50.join)(root, "GATE.md");
38963
- const verityMd = (0, import_node_path50.join)(root, "VERITY.md");
39057
+ const gateMd = (0, import_node_path51.join)(root, "GATE.md");
39058
+ const verityMd = (0, import_node_path51.join)(root, "VERITY.md");
38964
39059
  if (!(0, import_node_fs65.existsSync)(gateMd) || (0, import_node_fs65.existsSync)(verityMd)) return;
38965
39060
  let moved = false;
38966
39061
  if (isGitRepo(root) && isGitTracked(root, "GATE.md")) {
@@ -38977,7 +39072,7 @@ function migrateStandardFile(root, actions) {
38977
39072
  actions.push("Renamed GATE.md \u2192 VERITY.md");
38978
39073
  }
38979
39074
  async function migrateTelemetryHeaders(root, actions) {
38980
- const file = (0, import_node_path50.join)(root, ".claude", "settings.local.json");
39075
+ const file = (0, import_node_path51.join)(root, ".claude", "settings.local.json");
38981
39076
  if (!(0, import_node_fs65.existsSync)(file)) return;
38982
39077
  let settings;
38983
39078
  try {
@@ -39025,8 +39120,8 @@ function mergeGlobalCredentials(gateCreds, verityCreds) {
39025
39120
  toAppend.push(line2.replace(/\r$/, ""));
39026
39121
  }
39027
39122
  if (toAppend.length > 0) {
39028
- const sep6 = verityContent.endsWith("\n") || verityContent === "" ? "" : "\n";
39029
- (0, import_node_fs65.writeFileSync)(verityCreds, verityContent + sep6 + toAppend.join("\n") + "\n");
39123
+ const sep7 = verityContent.endsWith("\n") || verityContent === "" ? "" : "\n";
39124
+ (0, import_node_fs65.writeFileSync)(verityCreds, verityContent + sep7 + toAppend.join("\n") + "\n");
39030
39125
  }
39031
39126
  (0, import_node_fs65.rmSync)(gateCreds, { force: true });
39032
39127
  return toAppend.length;
@@ -39067,15 +39162,15 @@ function moveFile(from, to) {
39067
39162
  function carryLegacyContents(gateDir, verityDir) {
39068
39163
  let copied = 0;
39069
39164
  const walk2 = (relDir) => {
39070
- const srcDir = (0, import_node_path50.join)(gateDir, relDir);
39165
+ const srcDir = (0, import_node_path51.join)(gateDir, relDir);
39071
39166
  for (const entry of (0, import_node_fs65.readdirSync)(srcDir)) {
39072
- const rel = relDir ? (0, import_node_path50.join)(relDir, entry) : entry;
39073
- const src = (0, import_node_path50.join)(gateDir, rel);
39074
- const dest = (0, import_node_path50.join)(verityDir, rel);
39167
+ const rel = relDir ? (0, import_node_path51.join)(relDir, entry) : entry;
39168
+ const src = (0, import_node_path51.join)(gateDir, rel);
39169
+ const dest = (0, import_node_path51.join)(verityDir, rel);
39075
39170
  if ((0, import_node_fs65.statSync)(src).isDirectory()) {
39076
39171
  walk2(rel);
39077
39172
  } else if (!(0, import_node_fs65.existsSync)(dest)) {
39078
- (0, import_node_fs65.mkdirSync)((0, import_node_path50.dirname)(dest), { recursive: true });
39173
+ (0, import_node_fs65.mkdirSync)((0, import_node_path51.dirname)(dest), { recursive: true });
39079
39174
  (0, import_node_fs65.cpSync)(src, dest);
39080
39175
  copied++;
39081
39176
  }
@@ -39085,22 +39180,22 @@ function carryLegacyContents(gateDir, verityDir) {
39085
39180
  return copied;
39086
39181
  }
39087
39182
  async function needsMigration(root = repoRoot()) {
39088
- const gateDir = (0, import_node_path50.join)(root, ".gate");
39089
- const verityDir = (0, import_node_path50.join)(root, ".verity");
39183
+ const gateDir = (0, import_node_path51.join)(root, ".gate");
39184
+ const verityDir = (0, import_node_path51.join)(root, ".verity");
39090
39185
  if ((0, import_node_fs65.existsSync)(gateDir) && !(0, import_node_fs65.existsSync)(verityDir)) return true;
39091
39186
  if ((0, import_node_fs65.existsSync)(gateDir) && (0, import_node_fs65.existsSync)(verityDir)) {
39092
- if ((0, import_node_fs65.existsSync)((0, import_node_path50.join)(gateDir, "credentials")) && !(0, import_node_fs65.existsSync)((0, import_node_path50.join)(verityDir, "credentials"))) {
39187
+ if ((0, import_node_fs65.existsSync)((0, import_node_path51.join)(gateDir, "credentials")) && !(0, import_node_fs65.existsSync)((0, import_node_path51.join)(verityDir, "credentials"))) {
39093
39188
  return true;
39094
39189
  }
39095
- if ((0, import_node_fs65.existsSync)((0, import_node_path50.join)(gateDir, "memory")) && !(0, import_node_fs65.existsSync)((0, import_node_path50.join)(verityDir, "memory"))) {
39190
+ if ((0, import_node_fs65.existsSync)((0, import_node_path51.join)(gateDir, "memory")) && !(0, import_node_fs65.existsSync)((0, import_node_path51.join)(verityDir, "memory"))) {
39096
39191
  return true;
39097
39192
  }
39098
39193
  }
39099
- const claudeMd = (0, import_node_path50.join)(root, "CLAUDE.md");
39194
+ const claudeMd = (0, import_node_path51.join)(root, "CLAUDE.md");
39100
39195
  if ((0, import_node_fs65.existsSync)(claudeMd) && hasLegacyMemoryBlock(readFileSyncSafe(claudeMd))) {
39101
39196
  return true;
39102
39197
  }
39103
- if ((0, import_node_fs65.existsSync)((0, import_node_path50.join)(root, "GATE.md")) && !(0, import_node_fs65.existsSync)((0, import_node_path50.join)(root, "VERITY.md"))) {
39198
+ if ((0, import_node_fs65.existsSync)((0, import_node_path51.join)(root, "GATE.md")) && !(0, import_node_fs65.existsSync)((0, import_node_path51.join)(root, "VERITY.md"))) {
39104
39199
  return true;
39105
39200
  }
39106
39201
  if (await hasLegacyHooksAt(root)) return true;
@@ -39385,7 +39480,7 @@ var import_node_fs66 = require("node:fs");
39385
39480
  var import_node_crypto21 = require("node:crypto");
39386
39481
  var import_node_child_process18 = require("node:child_process");
39387
39482
  var import_node_os10 = require("node:os");
39388
- var import_node_path51 = require("node:path");
39483
+ var import_node_path52 = require("node:path");
39389
39484
  var import_promises18 = require("node:stream/promises");
39390
39485
  var import_node_stream = require("node:stream");
39391
39486
  var RELEASES = "https://releases.lean-lang.org/lean4";
@@ -39399,7 +39494,7 @@ function freeBytes(dir) {
39399
39494
  const st = (0, import_node_fs66.statfsSync)(d);
39400
39495
  return Number(st.bavail) * Number(st.bsize);
39401
39496
  } catch {
39402
- const up = (0, import_node_path51.join)(d, "..");
39497
+ const up = (0, import_node_path52.join)(d, "..");
39403
39498
  if (up === d) return null;
39404
39499
  d = up;
39405
39500
  }
@@ -39441,7 +39536,7 @@ function leanAssetName(version = pinnedVersion()) {
39441
39536
  return suffix ? `lean-${v}-${suffix}.zip` : null;
39442
39537
  }
39443
39538
  function pinnedVersionDir(env = process.env) {
39444
- return (0, import_node_path51.join)(verityLeanHome(env), pinnedVersion());
39539
+ return (0, import_node_path52.join)(verityLeanHome(env), pinnedVersion());
39445
39540
  }
39446
39541
  function lakeBinary() {
39447
39542
  return (0, import_node_os10.platform)() === "win32" ? "lake.exe" : "lake";
@@ -39457,7 +39552,7 @@ function unzip(zip, dest) {
39457
39552
  } catch (err2) {
39458
39553
  errors.push(`${cmd}: ${String(err2.message).split("\n")[0].slice(0, 120)}`);
39459
39554
  try {
39460
- for (const e of (0, import_node_fs66.readdirSync)(dest)) (0, import_node_fs66.rmSync)((0, import_node_path51.join)(dest, e), { recursive: true, force: true });
39555
+ for (const e of (0, import_node_fs66.readdirSync)(dest)) (0, import_node_fs66.rmSync)((0, import_node_path52.join)(dest, e), { recursive: true, force: true });
39461
39556
  } catch {
39462
39557
  }
39463
39558
  }
@@ -39533,10 +39628,10 @@ async function installLean(opts = {}) {
39533
39628
  const gb = (n) => (n / 1024 ** 3).toFixed(1);
39534
39629
  return { ok: false, error: `not enough disk space for Lean: ${gb(free)} GB free where ${home} lives, needs about ${gb(needed)} GB` };
39535
39630
  }
39536
- const tmp = (0, import_node_path51.join)(home, ".tmp");
39631
+ const tmp = (0, import_node_path52.join)(home, ".tmp");
39537
39632
  (0, import_node_fs66.rmSync)(tmp, { recursive: true, force: true });
39538
39633
  (0, import_node_fs66.mkdirSync)(tmp, { recursive: true });
39539
- const zip = (0, import_node_path51.join)(tmp, asset);
39634
+ const zip = (0, import_node_path52.join)(tmp, asset);
39540
39635
  say(`downloading ${url}`);
39541
39636
  let lastPct = -1;
39542
39637
  try {
@@ -39559,7 +39654,7 @@ async function installLean(opts = {}) {
39559
39654
  return { ok: false, error: verified.error };
39560
39655
  }
39561
39656
  say("unpacking (this takes a minute)");
39562
- const unpack = (0, import_node_path51.join)(tmp, "unpack");
39657
+ const unpack = (0, import_node_path52.join)(tmp, "unpack");
39563
39658
  (0, import_node_fs66.mkdirSync)(unpack);
39564
39659
  const unpacked = unzip(zip, unpack);
39565
39660
  if (!unpacked.ok) {
@@ -39567,8 +39662,8 @@ async function installLean(opts = {}) {
39567
39662
  return { ok: false, error: `unpack failed: ${unpacked.error}` };
39568
39663
  }
39569
39664
  const entries = (0, import_node_fs66.readdirSync)(unpack);
39570
- const top = entries.length === 1 && (0, import_node_fs66.statSync)((0, import_node_path51.join)(unpack, entries[0])).isDirectory() ? (0, import_node_path51.join)(unpack, entries[0]) : unpack;
39571
- if (!(0, import_node_fs66.existsSync)((0, import_node_path51.join)(top, "bin", lakeBinary()))) {
39665
+ const top = entries.length === 1 && (0, import_node_fs66.statSync)((0, import_node_path52.join)(unpack, entries[0])).isDirectory() ? (0, import_node_path52.join)(unpack, entries[0]) : unpack;
39666
+ if (!(0, import_node_fs66.existsSync)((0, import_node_path52.join)(top, "bin", lakeBinary()))) {
39572
39667
  (0, import_node_fs66.rmSync)(tmp, { recursive: true, force: true });
39573
39668
  return { ok: false, error: "the archive did not contain bin/lake" };
39574
39669
  }
@@ -39582,7 +39677,7 @@ async function installLean(opts = {}) {
39582
39677
  // src/lib/remote-config.ts
39583
39678
  var import_node_fs67 = require("node:fs");
39584
39679
  var import_promises19 = require("node:fs/promises");
39585
- var import_node_path52 = require("node:path");
39680
+ var import_node_path53 = require("node:path");
39586
39681
  var import_yaml5 = __toESM2(require_dist());
39587
39682
  var IGNORE_RIDER = "verityignore";
39588
39683
  async function fetchRemoteSetup(opts) {
@@ -39658,9 +39753,9 @@ async function adoptRemoteSetup(found, opts) {
39658
39753
  written.push(VERITY_MD_FILE);
39659
39754
  return { written, notes };
39660
39755
  }
39661
- async function writeOut(relative6, body2) {
39662
- const target = projectPath(relative6);
39663
- await (0, import_promises19.mkdir)((0, import_node_path52.dirname)(target), { recursive: true });
39756
+ async function writeOut(relative7, body2) {
39757
+ const target = projectPath(relative7);
39758
+ await (0, import_promises19.mkdir)((0, import_node_path53.dirname)(target), { recursive: true });
39664
39759
  await (0, import_promises19.writeFile)(target, body2);
39665
39760
  }
39666
39761
  function describeRemote(found) {
@@ -39777,15 +39872,15 @@ async function runOptionalAuth(resolution, opts = {}) {
39777
39872
  }
39778
39873
  function resolveDataDir2() {
39779
39874
  const candidates2 = [
39780
- (0, import_node_path53.join)(__dirname, "..", "data"),
39875
+ (0, import_node_path54.join)(__dirname, "..", "data"),
39781
39876
  // installed: node_modules/@codacy/verity-cli/data
39782
- (0, import_node_path53.join)(__dirname, "..", "..", "data"),
39877
+ (0, import_node_path54.join)(__dirname, "..", "..", "data"),
39783
39878
  // edge case: nested resolution
39784
- (0, import_node_path53.join)(process.cwd(), "cli", "data")
39879
+ (0, import_node_path54.join)(process.cwd(), "cli", "data")
39785
39880
  // local dev: running from repo root
39786
39881
  ];
39787
39882
  for (const candidate of candidates2) {
39788
- if ((0, import_node_fs68.existsSync)((0, import_node_path53.join)(candidate, "skills"))) {
39883
+ if ((0, import_node_fs68.existsSync)((0, import_node_path54.join)(candidate, "skills"))) {
39789
39884
  return candidate;
39790
39885
  }
39791
39886
  }
@@ -39803,7 +39898,7 @@ async function skillIsCurrent(src, dest) {
39803
39898
  const walk2 = (d, prefix) => {
39804
39899
  for (const e of (0, import_node_fs68.readdirSync)(d, { withFileTypes: true })) {
39805
39900
  const rel = prefix ? `${prefix}/${e.name}` : e.name;
39806
- if (e.isDirectory()) walk2((0, import_node_path53.join)(d, e.name), rel);
39901
+ if (e.isDirectory()) walk2((0, import_node_path54.join)(d, e.name), rel);
39807
39902
  else if (e.isFile()) out2.push(rel);
39808
39903
  }
39809
39904
  };
@@ -39814,8 +39909,8 @@ async function skillIsCurrent(src, dest) {
39814
39909
  const shipped = list2(src);
39815
39910
  if (JSON.stringify(shipped) !== JSON.stringify(list2(dest))) return false;
39816
39911
  for (const rel of shipped) {
39817
- const a = await (0, import_promises20.readFile)((0, import_node_path53.join)(src, rel), "utf-8");
39818
- const b = await (0, import_promises20.readFile)((0, import_node_path53.join)(dest, rel), "utf-8");
39912
+ const a = await (0, import_promises20.readFile)((0, import_node_path54.join)(src, rel), "utf-8");
39913
+ const b = await (0, import_promises20.readFile)((0, import_node_path54.join)(dest, rel), "utf-8");
39819
39914
  if (a !== b) return false;
39820
39915
  }
39821
39916
  return true;
@@ -39911,7 +40006,7 @@ function parseTelemetryAnswer(raw) {
39911
40006
  return null;
39912
40007
  }
39913
40008
  function insideClaudeCode() {
39914
- return !!process.env.CLAUDECODE || !!process.env.CLAUDE_SESSION_ID;
40009
+ return !!process.env.CLAUDECODE || !!envSessionId();
39915
40010
  }
39916
40011
  function resumeDeferredPending(previous) {
39917
40012
  return previous?.telemetry === "deferred";
@@ -40115,12 +40210,12 @@ async function handoffToSetup(enabled, claudeInstalled) {
40115
40210
  async function installSkills(force, step) {
40116
40211
  step("Installing skills");
40117
40212
  const dataDir = resolveDataDir2();
40118
- const skillsSource = (0, import_node_path53.join)(dataDir, "skills");
40213
+ const skillsSource = (0, import_node_path54.join)(dataDir, "skills");
40119
40214
  const skillsDest = ".claude/skills";
40120
40215
  let skillsInstalled = 0;
40121
40216
  for (const skill of SKILLS) {
40122
- const src = (0, import_node_path53.join)(skillsSource, skill);
40123
- const dest = (0, import_node_path53.join)(skillsDest, skill);
40217
+ const src = (0, import_node_path54.join)(skillsSource, skill);
40218
+ const dest = (0, import_node_path54.join)(skillsDest, skill);
40124
40219
  if (!(0, import_node_fs68.existsSync)(src)) {
40125
40220
  printWarn(` Skill data not found: ${skill}`);
40126
40221
  continue;
@@ -40274,7 +40369,7 @@ async function offerFormalVerification(defaultsOnly, pluginMode) {
40274
40369
  if (!toolchain) {
40275
40370
  const dir = pinnedVersionDir();
40276
40371
  const home = (0, import_node_os11.homedir)();
40277
- const shown = dir.startsWith(home + import_node_path53.sep) ? `~${dir.slice(home.length)}` : dir;
40372
+ const shown = dir.startsWith(home + import_node_path54.sep) ? `~${dir.slice(home.length)}` : dir;
40278
40373
  console.log("");
40279
40374
  console.log(` "yes" installs Lean 4 (${LEAN_DOWNLOAD_SIZE}) into ${shown}`);
40280
40375
  }
@@ -40436,7 +40531,7 @@ function registerInitCommand(program2) {
40436
40531
  untrackMemory: opts.untrackMemory === true,
40437
40532
  untrackState: opts.untrackState === true
40438
40533
  });
40439
- const globalVerityDir = (0, import_node_path53.join)(process.env.HOME ?? "", ".verity");
40534
+ const globalVerityDir = (0, import_node_path54.join)(process.env.HOME ?? "", ".verity");
40440
40535
  await (0, import_promises20.mkdir)(globalVerityDir, { recursive: true });
40441
40536
  console.log("");
40442
40537
  step("Wiring Claude Code hooks");
@@ -40541,7 +40636,7 @@ function registerInitCommand(program2) {
40541
40636
  ...telemetryChoice ? { telemetry: telemetryChoice } : {},
40542
40637
  init: {
40543
40638
  completed_at: (/* @__PURE__ */ new Date()).toISOString(),
40544
- cli_version: true ? "0.34.1-experimental.c910405" : "dev"
40639
+ cli_version: true ? "0.34.2-experimental.d59d8cb" : "dev"
40545
40640
  }
40546
40641
  });
40547
40642
  } catch (err2) {
@@ -40592,7 +40687,7 @@ function registerInitCommand(program2) {
40592
40687
 
40593
40688
  // src/commands/uninstall.ts
40594
40689
  var import_node_fs69 = require("node:fs");
40595
- var import_node_path54 = require("node:path");
40690
+ var import_node_path55 = require("node:path");
40596
40691
  function registerUninstallCommand(program2) {
40597
40692
  program2.command("uninstall").description("Remove Verity from this project (skills, hooks, .verity/, VERITY.md)").option("--dry-run", "Show what would be removed without doing it").option("--purge-global", "Also remove ~/.verity/ (deletes saved tokens \u2014 reconnect requires re-registration)").option("--keep-verity-md", "Keep the project root VERITY.md file").action(async (opts) => {
40598
40693
  const dryRun = opts.dryRun ?? false;
@@ -40601,7 +40696,7 @@ function registerUninstallCommand(program2) {
40601
40696
  const actions = [];
40602
40697
  const skillsRoot = projectPath(".claude/skills");
40603
40698
  for (const name2 of PROJECT_SKILL_NAMES) {
40604
- const dir = (0, import_node_path54.join)(skillsRoot, name2);
40699
+ const dir = (0, import_node_path55.join)(skillsRoot, name2);
40605
40700
  if ((0, import_node_fs69.existsSync)(dir)) {
40606
40701
  actions.push({
40607
40702
  label: `Remove .claude/skills/${name2}/`,
@@ -40647,7 +40742,7 @@ function registerUninstallCommand(program2) {
40647
40742
  }
40648
40743
  });
40649
40744
  const home = process.env.HOME ?? "";
40650
- const globalVerityDir = (0, import_node_path54.join)(home, ".verity");
40745
+ const globalVerityDir = (0, import_node_path55.join)(home, ".verity");
40651
40746
  if (purgeGlobal && (0, import_node_fs69.existsSync)(globalVerityDir)) {
40652
40747
  actions.push({
40653
40748
  label: `Remove ~/.verity/ (global credentials \u2014 reconnect requires re-registration)`,
@@ -40678,9 +40773,26 @@ function registerUninstallCommand(program2) {
40678
40773
 
40679
40774
  // src/commands/task.ts
40680
40775
  function memoryPath() {
40681
- const sid = process.env.CLAUDE_SESSION_ID;
40776
+ const sid = envSessionId();
40682
40777
  return sid ? `/memory?session_id=${encodeURIComponent(sid)}` : "/memory";
40683
40778
  }
40779
+ var TASK_STATUSES = ["active", "closed", "merged"];
40780
+ var TASK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
40781
+ function isTaskId(value) {
40782
+ return typeof value === "string" && TASK_ID.test(value);
40783
+ }
40784
+ function taskListPath(status) {
40785
+ if (status === void 0) return "/tasks";
40786
+ if (!TASK_STATUSES.includes(status)) return null;
40787
+ return `/tasks?status=${encodeURIComponent(status)}`;
40788
+ }
40789
+ function taskActionPath(taskId, action) {
40790
+ return isTaskId(taskId) ? `/tasks/${encodeURIComponent(taskId)}/${action}` : null;
40791
+ }
40792
+ function refuse(message) {
40793
+ printError(message);
40794
+ process.exit(1);
40795
+ }
40684
40796
  function timeAgo2(isoDate) {
40685
40797
  const ms = Date.now() - new Date(isoDate).getTime();
40686
40798
  const mins = Math.floor(ms / 6e4);
@@ -40708,10 +40820,11 @@ function registerTaskCommands(program2) {
40708
40820
  task.command("list").description("List tasks").option("--status <status>", "Filter by status (active, closed, merged)").action(async (opts) => {
40709
40821
  const globals = program2.opts();
40710
40822
  const { token, serviceUrl } = await getAuth(globals);
40711
- const statusParam = opts.status ? `?status=${opts.status}` : "";
40823
+ const listPath = taskListPath(opts.status);
40824
+ if (!listPath) refuse(`Unknown status ${JSON.stringify(String(opts.status).slice(0, 40))} \u2014 use one of: ${TASK_STATUSES.join(", ")}`);
40712
40825
  const result = await apiRequest({
40713
40826
  method: "GET",
40714
- path: `/tasks${statusParam}`,
40827
+ path: listPath,
40715
40828
  serviceUrl,
40716
40829
  token,
40717
40830
  verbose: globals.verbose,
@@ -40760,9 +40873,11 @@ function registerTaskCommands(program2) {
40760
40873
  }
40761
40874
  taskId = ct.id;
40762
40875
  }
40876
+ const closePath = taskActionPath(taskId, "close");
40877
+ if (!closePath) refuse(`Not a task id (expected a UUID): ${JSON.stringify(String(taskId).slice(0, 80))}`);
40763
40878
  const result = await apiRequest({
40764
40879
  method: "POST",
40765
- path: `/tasks/${taskId}/close`,
40880
+ path: closePath,
40766
40881
  serviceUrl,
40767
40882
  token,
40768
40883
  verbose: globals.verbose,
@@ -40809,9 +40924,11 @@ function registerTaskCommands(program2) {
40809
40924
  }
40810
40925
  taskId = ct.id;
40811
40926
  }
40927
+ const renamePath = taskActionPath(taskId, "rename");
40928
+ if (!renamePath) refuse(`Not a task id (expected a UUID): ${JSON.stringify(String(taskId).slice(0, 80))}`);
40812
40929
  const result = await apiRequest({
40813
40930
  method: "POST",
40814
- path: `/tasks/${taskId}/rename`,
40931
+ path: renamePath,
40815
40932
  serviceUrl,
40816
40933
  token,
40817
40934
  body: { label: label2.slice(0, 120) },
@@ -40826,6 +40943,9 @@ function registerTaskCommands(program2) {
40826
40943
  });
40827
40944
  task.command("merge <source> <target>").description("Merge source task into target task").action(async (source2, target) => {
40828
40945
  const globals = program2.opts();
40946
+ if (!isTaskId(source2) || !isTaskId(target)) {
40947
+ refuse("task merge takes two task ids (UUIDs): `verity task merge <source> <target>`");
40948
+ }
40829
40949
  const { token, serviceUrl } = await getAuth(globals);
40830
40950
  const result = await apiRequest({
40831
40951
  method: "POST",
@@ -40846,7 +40966,7 @@ function registerTaskCommands(program2) {
40846
40966
 
40847
40967
  // src/commands/reset.ts
40848
40968
  var import_node_fs70 = require("node:fs");
40849
- var import_node_path55 = require("node:path");
40969
+ var import_node_path56 = require("node:path");
40850
40970
  function registerResetCommand(program2) {
40851
40971
  program2.command("reset").description("Close the current task and clear transient state").option("--keep-task", "Only purge caches; leave the current task open").option("--all", "Also purge diagnostic logs (.verity/.logs/)").action(async (opts) => {
40852
40972
  const globals = program2.opts();
@@ -40855,75 +40975,92 @@ function registerResetCommand(program2) {
40855
40975
  const tokenResult = await resolveToken(globals.token);
40856
40976
  const urlResult = await resolveServiceUrl(globals.serviceUrl);
40857
40977
  if (tokenResult.ok && urlResult.ok) {
40978
+ const sessionId = envSessionId();
40858
40979
  const mem = await apiRequest({
40859
40980
  method: "GET",
40860
- path: process.env.CLAUDE_SESSION_ID ? `/memory?session_id=${encodeURIComponent(process.env.CLAUDE_SESSION_ID)}` : "/memory",
40981
+ path: sessionId ? `/memory?session_id=${encodeURIComponent(sessionId)}` : "/memory",
40861
40982
  serviceUrl: urlResult.data,
40862
40983
  token: tokenResult.data.token,
40863
40984
  timeout: 1e4,
40864
40985
  cmd: "reset_lookup"
40865
40986
  });
40866
40987
  const ct = mem.ok ? mem.data.current_task : null;
40867
- if (ct?.id) {
40988
+ const closePath = ct?.id ? taskActionPath(ct.id, "close") : null;
40989
+ if (ct?.id && !closePath) {
40990
+ printError("The current task in the service response has a malformed id \u2014 not closing it.");
40991
+ }
40992
+ if (closePath) {
40868
40993
  const closeResult = await apiRequest({
40869
40994
  method: "POST",
40870
- path: `/tasks/${ct.id}/close`,
40995
+ path: closePath,
40871
40996
  serviceUrl: urlResult.data,
40872
40997
  token: tokenResult.data.token,
40873
40998
  timeout: 1e4,
40874
40999
  cmd: "reset_close"
40875
41000
  });
40876
41001
  if (closeResult.ok) {
40877
- printInfo(`Closed task: "${ct.label}"`);
41002
+ printInfo(`Closed task: "${terminalText(ct?.label, 200) || "(unnamed)"}"`);
40878
41003
  }
40879
41004
  }
40880
41005
  }
40881
41006
  } catch {
40882
41007
  }
40883
41008
  }
40884
- const cacheDir = projectPath(CACHE_DIR);
40885
- let purged = 0;
40886
- if ((0, import_node_fs70.existsSync)(cacheDir)) {
40887
- for (const entry of (0, import_node_fs70.readdirSync)(cacheDir)) {
40888
- if (entry.startsWith("pending-")) {
40889
- try {
40890
- (0, import_node_fs70.unlinkSync)((0, import_node_path55.join)(cacheDir, entry));
40891
- purged++;
40892
- } catch {
40893
- }
40894
- }
40895
- }
40896
- }
41009
+ const purged = purgeVerityDir((0, import_node_path56.basename)(CACHE_DIR), (name2) => name2.startsWith("pending-"));
41010
+ if (purged === null) printError(`Did not purge ${CACHE_DIR}: it is not a directory inside ${VERITY_DIR}.`);
41011
+ const stateDir2 = projectPath(VERITY_DIR);
40897
41012
  const filesToClear = [
40898
- projectPath(INTENT_FILE),
40899
- projectPath(HASH_FILE),
40900
- projectPath(BASELINE_SHA_FILE),
40901
- projectPath(`${VERITY_DIR}/.iteration-count`),
40902
- projectPath(`${VERITY_DIR}/.last-analysis`)
41013
+ (0, import_node_path56.basename)(INTENT_FILE),
41014
+ (0, import_node_path56.basename)(HASH_FILE),
41015
+ (0, import_node_path56.basename)(BASELINE_SHA_FILE),
41016
+ ".iteration-count",
41017
+ ".last-analysis"
40903
41018
  ];
40904
- for (const file of filesToClear) {
40905
- if ((0, import_node_fs70.existsSync)(file)) {
40906
- try {
40907
- (0, import_node_fs70.writeFileSync)(file, "");
40908
- } catch {
40909
- }
41019
+ for (const name2 of filesToClear) {
41020
+ if (lstatOrNull((0, import_node_path56.join)(stateDir2, name2)) && !replaceInRoot(stateDir2, name2, "")) {
41021
+ printError(`Did not clear ${VERITY_DIR}/${name2}: it is not a regular file inside ${VERITY_DIR}.`);
40910
41022
  }
40911
41023
  }
40912
41024
  if (opts.all) {
40913
- const logsDir = projectPath(`${VERITY_DIR}/.logs`);
40914
- if ((0, import_node_fs70.existsSync)(logsDir)) {
40915
- for (const entry of (0, import_node_fs70.readdirSync)(logsDir)) {
40916
- try {
40917
- (0, import_node_fs70.unlinkSync)((0, import_node_path55.join)(logsDir, entry));
40918
- } catch {
40919
- }
40920
- }
40921
- }
40922
- printInfo("Cleared diagnostic logs.");
41025
+ const logs = purgeVerityDir(".logs", () => true);
41026
+ if (logs === null) printError(`Did not clear ${VERITY_DIR}/.logs: it is not a directory inside ${VERITY_DIR}.`);
41027
+ else printInfo("Cleared diagnostic logs.");
40923
41028
  }
40924
- printInfo(`Reset complete. Purged ${purged} cached request${purged !== 1 ? "s" : ""}.${opts.keepTask ? "" : " Next run starts a new task."}`);
41029
+ const count = purged ?? 0;
41030
+ printInfo(`Reset complete. Purged ${count} cached request${count !== 1 ? "s" : ""}.${opts.keepTask ? "" : " Next run starts a new task."}`);
40925
41031
  });
40926
41032
  }
41033
+ function lstatOrNull(path) {
41034
+ try {
41035
+ return (0, import_node_fs70.lstatSync)(path);
41036
+ } catch {
41037
+ return null;
41038
+ }
41039
+ }
41040
+ function purgeVerityDir(child, select) {
41041
+ const verityDir = projectPath(VERITY_DIR);
41042
+ const dir = (0, import_node_path56.join)(verityDir, child);
41043
+ const parent = lstatOrNull(verityDir);
41044
+ const st = lstatOrNull(dir);
41045
+ if (!st) return 0;
41046
+ if (!parent || parent.isSymbolicLink() || !parent.isDirectory()) return null;
41047
+ if (st.isSymbolicLink() || !st.isDirectory()) return null;
41048
+ try {
41049
+ if ((0, import_node_fs70.realpathSync)(dir) !== (0, import_node_path56.join)((0, import_node_fs70.realpathSync)(verityDir), child)) return null;
41050
+ } catch {
41051
+ return null;
41052
+ }
41053
+ let removed = 0;
41054
+ for (const entry of (0, import_node_fs70.readdirSync)(dir, { withFileTypes: true })) {
41055
+ if (entry.isDirectory() || !select(entry.name)) continue;
41056
+ try {
41057
+ (0, import_node_fs70.unlinkSync)((0, import_node_path56.join)(dir, entry.name));
41058
+ removed++;
41059
+ } catch {
41060
+ }
41061
+ }
41062
+ return removed;
41063
+ }
40927
41064
 
40928
41065
  // src/commands/reflect.ts
40929
41066
  var import_node_fs71 = require("node:fs");
@@ -40995,7 +41132,7 @@ function registerReflectCommand(program2) {
40995
41132
  let taskResolution = "flag";
40996
41133
  let inheritedGlobs = [];
40997
41134
  if (!taskId) {
40998
- const sessionId = process.env.CLAUDE_SESSION_ID ?? "";
41135
+ const sessionId = envSessionId() ?? "";
40999
41136
  const memPath = sessionId ? `/memory?session_id=${encodeURIComponent(sessionId)}` : "/memory";
41000
41137
  const mem = await apiRequest({
41001
41138
  method: "GET",
@@ -41481,7 +41618,7 @@ function registerTelemetryCommands(program2) {
41481
41618
 
41482
41619
  // src/commands/prove.ts
41483
41620
  var import_node_fs73 = require("node:fs");
41484
- var import_node_path56 = require("node:path");
41621
+ var import_node_path57 = require("node:path");
41485
41622
 
41486
41623
  // src/lib/prove/hint-pool.ts
41487
41624
  var STOP2 = /* @__PURE__ */ new Set([
@@ -41623,7 +41760,7 @@ function registerProveCommand(program2) {
41623
41760
  process.exit(2);
41624
41761
  }
41625
41762
  const limit = Math.max(1, Math.min(50, Number(opts.limit) || 10));
41626
- let signals = collectRiskSignals(root, { since: opts.since, limit, paths: paths.map((p) => (0, import_node_path56.relative)(root, (0, import_node_path56.resolve)(p)) || ".") });
41763
+ let signals = collectRiskSignals(root, { since: opts.since, limit, paths: paths.map((p) => (0, import_node_path57.relative)(root, (0, import_node_path57.resolve)(p)) || ".") });
41627
41764
  if (opts.hint && paths.length === 0) {
41628
41765
  const hit = hintMatches(root, opts.hint);
41629
41766
  if (hit.files.length > 0) {
@@ -41677,7 +41814,7 @@ function registerProveCommand(program2) {
41677
41814
  });
41678
41815
  prove.command("check [model]").description("Elaborate a model (or every model) with the local Lean toolchain and report each property").option("--timeout <ms>", "Per-model timeout in ms", "120000").option("--json", "Machine-readable output").action((model, opts) => {
41679
41816
  const root = repoRoot();
41680
- if (!(0, import_node_fs73.existsSync)((0, import_node_path56.join)(root, PROOFS_DIR, "lakefile.toml"))) {
41817
+ if (!(0, import_node_fs73.existsSync)((0, import_node_path57.join)(root, PROOFS_DIR, "lakefile.toml"))) {
41681
41818
  printError(`No ${PROOFS_DIR}/ project here. Run \`verity prove init\` first.`);
41682
41819
  process.exit(2);
41683
41820
  }
@@ -41701,7 +41838,7 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
41701
41838
  const reports = [];
41702
41839
  for (const f of files) {
41703
41840
  const report = checkModel(tc, root, f, { timeoutMs: Math.max(1e3, Number(opts.timeout) || 12e4) });
41704
- report.file = (0, import_node_path56.relative)(root, f);
41841
+ report.file = (0, import_node_path57.relative)(root, f);
41705
41842
  reports.push(report);
41706
41843
  try {
41707
41844
  writeResult(root, report);
@@ -41739,7 +41876,7 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
41739
41876
  printError("Not logged in \u2014 replays run on the Verity service. Run `verity login` first.");
41740
41877
  process.exit(2);
41741
41878
  }
41742
- if (!(0, import_node_fs73.existsSync)((0, import_node_path56.join)(root, PROOFS_DIR, "lakefile.toml"))) {
41879
+ if (!(0, import_node_fs73.existsSync)((0, import_node_path57.join)(root, PROOFS_DIR, "lakefile.toml"))) {
41743
41880
  printError(`No ${PROOFS_DIR}/ project here. Run \`verity prove init\` first.`);
41744
41881
  process.exit(2);
41745
41882
  }
@@ -41770,7 +41907,7 @@ ${report.error ?? ""}`);
41770
41907
  printInfo(opts.property ? `${model} ${opts.property} has no counterexample to replay` : `${model} has no counterexample to replay`);
41771
41908
  return;
41772
41909
  }
41773
- const modelSource = readRegularFileInRoot(root, (0, import_node_path56.relative)(root, file), 512 * 1024);
41910
+ const modelSource = readRegularFileInRoot(root, (0, import_node_path57.relative)(root, file), 512 * 1024);
41774
41911
  if (!opts.json) printInfo(`replaying ${targets.length} counterexample(s) of ${model} in network-less containers (${Math.min(targets.length, REPLAY_CONCURRENCY)} at a time)\u2026`);
41775
41912
  const outcomes = await mapPool(targets, REPLAY_CONCURRENCY, async (p) => {
41776
41913
  const brief = buildReplayBrief(root, report, p, modelSource.ok ? modelSource.content : "");
@@ -41790,7 +41927,7 @@ ${report.error ?? ""}`);
41790
41927
  });
41791
41928
  prove.command("auto [files...]").description("The formal phase the pre-push guard runs: select one risky symbol among changed files, generate a model, check it, replay counterexamples (default files: the commits ahead of upstream)").option("--deadline <ms>", "Budget for the whole phase", "170000").option("--json", "Machine-readable output").action(async (paths, opts) => {
41792
41929
  const root = repoRoot();
41793
- let files = paths.map((p) => (0, import_node_path56.relative)(root, (0, import_node_path56.resolve)(p)));
41930
+ let files = paths.map((p) => (0, import_node_path57.relative)(root, (0, import_node_path57.resolve)(p)));
41794
41931
  if (files.length === 0) {
41795
41932
  const ahead = runGitSync(root, ["diff", "--name-only", "@{upstream}...HEAD"]);
41796
41933
  const fallback = ahead.ok ? ahead : runGitSync(root, ["diff", "--name-only", "HEAD~1..HEAD"]);
@@ -41864,7 +42001,7 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
41864
42001
  let revise;
41865
42002
  if (opts.revise) {
41866
42003
  const existing = resolveModelFile(root, opts.revise);
41867
- const src = existing ? readRegularFileInRoot(root, (0, import_node_path56.relative)(root, existing), 64 * 1024) : null;
42004
+ const src = existing ? readRegularFileInRoot(root, (0, import_node_path57.relative)(root, existing), 64 * 1024) : null;
41868
42005
  if (!src || !src.ok || !opts.note) {
41869
42006
  printError("--revise needs an existing model under Models/ and --note - with what the replay showed on stdin");
41870
42007
  process.exit(2);
@@ -41904,8 +42041,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
41904
42041
  });
41905
42042
  prove.command("waive <file>").description("Dismiss the remembered formal finding(s) on a file for its current bytes \u2014 the accepted-risk path for a formal block").requiredOption("--reason <text>", "The human disposition this records (reviewer finding, ADR, \u2026)").action((file, opts) => {
41906
42043
  const root = repoRoot();
41907
- const rel0 = (0, import_node_path56.relative)(root, (0, import_node_path56.isAbsolute)(file) ? file : (0, import_node_path56.join)(root, file)).replace(/\\/g, "/");
41908
- const rel = rel0.startsWith("..") || (0, import_node_path56.isAbsolute)(rel0) ? null : rel0;
42044
+ const rel0 = (0, import_node_path57.relative)(root, (0, import_node_path57.isAbsolute)(file) ? file : (0, import_node_path57.join)(root, file)).replace(/\\/g, "/");
42045
+ const rel = rel0.startsWith("..") || (0, import_node_path57.isAbsolute)(rel0) ? null : rel0;
41909
42046
  if (!rel) {
41910
42047
  printError(`${file} is not inside this repository`);
41911
42048
  process.exit(2);
@@ -41921,8 +42058,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
41921
42058
  });
41922
42059
  prove.command("hash <file>").description("Print the sha256 of a file, for a model header (Verity.model \u2026 sha256). Path is REPO-relative, as in the header").action((file) => {
41923
42060
  const root = repoRoot();
41924
- const rel = (0, import_node_path56.relative)(root, (0, import_node_path56.isAbsolute)(file) ? file : (0, import_node_path56.join)(root, file));
41925
- const digest = rel.startsWith("..") || (0, import_node_path56.isAbsolute)(rel) ? null : sha256InRoot(root, rel);
42061
+ const rel = (0, import_node_path57.relative)(root, (0, import_node_path57.isAbsolute)(file) ? file : (0, import_node_path57.join)(root, file));
42062
+ const digest = rel.startsWith("..") || (0, import_node_path57.isAbsolute)(rel) ? null : sha256InRoot(root, rel);
41926
42063
  if (!digest) {
41927
42064
  printError(`Cannot hash ${file}: it must be a regular file inside this repository (not a symlink)`);
41928
42065
  process.exit(2);
@@ -41959,7 +42096,7 @@ function refreshScaffold(root) {
41959
42096
  var import_node_fs74 = require("node:fs");
41960
42097
  var import_node_child_process20 = require("node:child_process");
41961
42098
  var import_node_os12 = require("node:os");
41962
- var import_node_path57 = require("node:path");
42099
+ var import_node_path58 = require("node:path");
41963
42100
  function registerLeanCommand(program2) {
41964
42101
  const lean = program2.command("lean").description("The Lean 4 toolchain formal verification needs (managed download, pinned by this CLI)");
41965
42102
  lean.command("status").option("--json", "Machine-readable output").description("Which toolchain would run, and whether it matches the pinned version").action((opts) => {
@@ -41976,7 +42113,7 @@ function registerLeanCommand(program2) {
41976
42113
  const managed = pinnedVersionDir();
41977
42114
  const matches = version ? version.includes(pin) : false;
41978
42115
  if (opts.json) {
41979
- printJson({ pinned: LEAN_TOOLCHAIN, found: tc?.lake ?? null, version, matches_pin: matches, managed_dir: managed, managed_installed: (0, import_node_fs74.existsSync)((0, import_node_path57.join)(managed, "bin")), asset: leanAssetName() });
42116
+ printJson({ pinned: LEAN_TOOLCHAIN, found: tc?.lake ?? null, version, matches_pin: matches, managed_dir: managed, managed_installed: (0, import_node_fs74.existsSync)((0, import_node_path58.join)(managed, "bin")), asset: leanAssetName() });
41980
42117
  return;
41981
42118
  }
41982
42119
  printInfo(`pinned: ${LEAN_TOOLCHAIN}`);
@@ -41994,7 +42131,7 @@ function registerLeanCommand(program2) {
41994
42131
  process.exit(2);
41995
42132
  }
41996
42133
  const dir = pinnedVersionDir();
41997
- if ((0, import_node_fs74.existsSync)((0, import_node_path57.join)(dir, "bin", "lake")) && !opts.force) {
42134
+ if ((0, import_node_fs74.existsSync)((0, import_node_path58.join)(dir, "bin", "lake")) && !opts.force) {
41998
42135
  printInfo(`already installed at ${dir}`);
41999
42136
  return;
42000
42137
  }
@@ -42040,8 +42177,8 @@ function registerLeanCommand(program2) {
42040
42177
  }
42041
42178
 
42042
42179
  // src/cli.ts
42043
- program.name("verity").description("CLI for Verity quality gate service").version("0.34.1-experimental.c910405").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
42044
- installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.1-experimental.c910405");
42180
+ program.name("verity").description("CLI for Verity quality gate service").version("0.34.2-experimental.d59d8cb").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
42181
+ installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.2-experimental.d59d8cb");
42045
42182
  setUserNamedServiceUrl(program.opts().serviceUrl);
42046
42183
  try {
42047
42184
  await foldLegacyLocalCredential();