@quikit/quikpilot-runner 9.3.0-rc.85 → 9.3.0-rc.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -520,8 +520,8 @@ var require_web_tree_sitter2 = __commonJS2({
520
520
  } else if (subsectionType === WASM_DYLINK_NEEDED) {
521
521
  customSection.neededDynlibs = getStringList();
522
522
  } else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
523
- var count3 = getLEB();
524
- while (count3--) {
523
+ var count4 = getLEB();
524
+ while (count4--) {
525
525
  var symname = getString();
526
526
  var flags2 = getLEB();
527
527
  if (flags2 & WASM_SYMBOL_TLS) {
@@ -529,8 +529,8 @@ var require_web_tree_sitter2 = __commonJS2({
529
529
  }
530
530
  }
531
531
  } else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
532
- var count3 = getLEB();
533
- while (count3--) {
532
+ var count4 = getLEB();
533
+ while (count4--) {
534
534
  var modname = getString();
535
535
  var symname = getString();
536
536
  var flags2 = getLEB();
@@ -689,9 +689,9 @@ var require_web_tree_sitter2 = __commonJS2({
689
689
  }
690
690
  return func2;
691
691
  }, "getWasmTableEntry");
692
- var updateTableMap = /* @__PURE__ */ __name((offset2, count3) => {
692
+ var updateTableMap = /* @__PURE__ */ __name((offset2, count4) => {
693
693
  if (functionsInTableMap) {
694
- for (var i22 = offset2; i22 < offset2 + count3; i22++) {
694
+ for (var i22 = offset2; i22 < offset2 + count4; i22++) {
695
695
  var item = getWasmTableEntry(i22);
696
696
  if (item) {
697
697
  functionsInTableMap.set(item, i22);
@@ -2029,12 +2029,12 @@ var require_web_tree_sitter2 = __commonJS2({
2029
2029
  throw new TypeError("Argument must be a Tree");
2030
2030
  }
2031
2031
  C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
2032
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2032
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2033
2033
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2034
- const result = new Array(count3);
2035
- if (count3 > 0) {
2034
+ const result = new Array(count4);
2035
+ if (count4 > 0) {
2036
2036
  let address = buffer;
2037
- for (let i22 = 0; i22 < count3; i22++) {
2037
+ for (let i22 = 0; i22 < count4; i22++) {
2038
2038
  result[i22] = unmarshalRange(address);
2039
2039
  address += SIZE_OF_RANGE;
2040
2040
  }
@@ -2045,12 +2045,12 @@ var require_web_tree_sitter2 = __commonJS2({
2045
2045
  /** Get the included ranges that were used to parse the syntax tree. */
2046
2046
  getIncludedRanges() {
2047
2047
  C._ts_tree_included_ranges_wasm(this[0]);
2048
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2048
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2049
2049
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2050
- const result = new Array(count3);
2051
- if (count3 > 0) {
2050
+ const result = new Array(count4);
2051
+ if (count4 > 0) {
2052
2052
  let address = buffer;
2053
- for (let i22 = 0; i22 < count3; i22++) {
2053
+ for (let i22 = 0; i22 < count4; i22++) {
2054
2054
  result[i22] = unmarshalRange(address);
2055
2055
  address += SIZE_OF_RANGE;
2056
2056
  }
@@ -2580,12 +2580,12 @@ var require_web_tree_sitter2 = __commonJS2({
2580
2580
  childrenForFieldId(fieldId) {
2581
2581
  marshalNode(this);
2582
2582
  C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
2583
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2583
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2584
2584
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2585
- const result = new Array(count3);
2586
- if (count3 > 0) {
2585
+ const result = new Array(count4);
2586
+ if (count4 > 0) {
2587
2587
  let address = buffer;
2588
- for (let i22 = 0; i22 < count3; i22++) {
2588
+ for (let i22 = 0; i22 < count4; i22++) {
2589
2589
  result[i22] = unmarshalNode(this.tree, address);
2590
2590
  address += SIZE_OF_NODE;
2591
2591
  }
@@ -2657,12 +2657,12 @@ var require_web_tree_sitter2 = __commonJS2({
2657
2657
  if (!this._children) {
2658
2658
  marshalNode(this);
2659
2659
  C._ts_node_children_wasm(this.tree[0]);
2660
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2660
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2661
2661
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2662
- this._children = new Array(count3);
2663
- if (count3 > 0) {
2662
+ this._children = new Array(count4);
2663
+ if (count4 > 0) {
2664
2664
  let address = buffer;
2665
- for (let i22 = 0; i22 < count3; i22++) {
2665
+ for (let i22 = 0; i22 < count4; i22++) {
2666
2666
  this._children[i22] = unmarshalNode(this.tree, address);
2667
2667
  address += SIZE_OF_NODE;
2668
2668
  }
@@ -2680,12 +2680,12 @@ var require_web_tree_sitter2 = __commonJS2({
2680
2680
  if (!this._namedChildren) {
2681
2681
  marshalNode(this);
2682
2682
  C._ts_node_named_children_wasm(this.tree[0]);
2683
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
2683
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
2684
2684
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
2685
- this._namedChildren = new Array(count3);
2686
- if (count3 > 0) {
2685
+ this._namedChildren = new Array(count4);
2686
+ if (count4 > 0) {
2687
2687
  let address = buffer;
2688
- for (let i22 = 0; i22 < count3; i22++) {
2688
+ for (let i22 = 0; i22 < count4; i22++) {
2689
2689
  this._namedChildren[i22] = unmarshalNode(this.tree, address);
2690
2690
  address += SIZE_OF_NODE;
2691
2691
  }
@@ -3154,12 +3154,12 @@ var require_web_tree_sitter2 = __commonJS2({
3154
3154
  */
3155
3155
  get supertypes() {
3156
3156
  C._ts_language_supertypes_wasm(this[0]);
3157
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
3157
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
3158
3158
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3159
- const result = new Array(count3);
3160
- if (count3 > 0) {
3159
+ const result = new Array(count4);
3160
+ if (count4 > 0) {
3161
3161
  let address = buffer;
3162
- for (let i22 = 0; i22 < count3; i22++) {
3162
+ for (let i22 = 0; i22 < count4; i22++) {
3163
3163
  result[i22] = C.getValue(address, "i16");
3164
3164
  address += SIZE_OF_SHORT;
3165
3165
  }
@@ -3171,12 +3171,12 @@ var require_web_tree_sitter2 = __commonJS2({
3171
3171
  */
3172
3172
  subtypes(supertype) {
3173
3173
  C._ts_language_subtypes_wasm(this[0], supertype);
3174
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
3174
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
3175
3175
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3176
- const result = new Array(count3);
3177
- if (count3 > 0) {
3176
+ const result = new Array(count4);
3177
+ if (count4 > 0) {
3178
3178
  let address = buffer;
3179
- for (let i22 = 0; i22 < count3; i22++) {
3179
+ for (let i22 = 0; i22 < count4; i22++) {
3180
3180
  result[i22] = C.getValue(address, "i16");
3181
3181
  address += SIZE_OF_SHORT;
3182
3182
  }
@@ -3442,12 +3442,12 @@ ${JSON.stringify(symbolNames, null, 2)}`);
3442
3442
  /** Get the ranges of text that the parser will include when parsing. */
3443
3443
  getIncludedRanges() {
3444
3444
  C._ts_parser_included_ranges_wasm(this[0]);
3445
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
3445
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
3446
3446
  const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3447
- const result = new Array(count3);
3448
- if (count3 > 0) {
3447
+ const result = new Array(count4);
3448
+ if (count4 > 0) {
3449
3449
  let address = buffer;
3450
- for (let i22 = 0; i22 < count3; i22++) {
3450
+ for (let i22 = 0; i22 < count4; i22++) {
3451
3451
  result[i22] = unmarshalRange(address);
3452
3452
  address += SIZE_OF_RANGE;
3453
3453
  }
@@ -4016,14 +4016,14 @@ ${JSON.stringify(symbolNames, null, 2)}`);
4016
4016
  matchLimit,
4017
4017
  maxStartDepth
4018
4018
  );
4019
- const count3 = C.getValue(TRANSFER_BUFFER, "i32");
4019
+ const count4 = C.getValue(TRANSFER_BUFFER, "i32");
4020
4020
  const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
4021
4021
  const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
4022
4022
  const result = new Array();
4023
4023
  this.exceededMatchLimit = Boolean(didExceedMatchLimit);
4024
4024
  const captures = new Array();
4025
4025
  let address = startAddress;
4026
- for (let i22 = 0; i22 < count3; i22++) {
4026
+ for (let i22 = 0; i22 < count4; i22++) {
4027
4027
  const patternIndex = C.getValue(address, "i32");
4028
4028
  address += SIZE_OF_INT;
4029
4029
  const captureCount = C.getValue(address, "i32");
@@ -16351,7 +16351,7 @@ var require_JSXTransformer = __commonJS2({
16351
16351
  }
16352
16352
  function processEntity(text3, indexAfterAmpersand) {
16353
16353
  let str = "";
16354
- let count3 = 0;
16354
+ let count4 = 0;
16355
16355
  let entity;
16356
16356
  let i3 = indexAfterAmpersand;
16357
16357
  if (text3[i3] === "#") {
@@ -16379,7 +16379,7 @@ var require_JSXTransformer = __commonJS2({
16379
16379
  }
16380
16380
  }
16381
16381
  } else {
16382
- while (i3 < text3.length && count3++ < 10) {
16382
+ while (i3 < text3.length && count4++ < 10) {
16383
16383
  const ch = text3[i3];
16384
16384
  i3++;
16385
16385
  if (ch === ";") {
@@ -28529,8 +28529,8 @@ function readRunnerEnv(env2 = process.env) {
28529
28529
  // src/approvedTests.ts
28530
28530
  var import_node_child_process4 = require("node:child_process");
28531
28531
  var import_node_fs5 = require("node:fs");
28532
- var import_node_os2 = require("node:os");
28533
- var import_node_path7 = require("node:path");
28532
+ var import_node_os3 = require("node:os");
28533
+ var import_node_path8 = require("node:path");
28534
28534
 
28535
28535
  // src/editsApply.ts
28536
28536
  function detectLineEnding(text3) {
@@ -28624,18 +28624,377 @@ function applyEdits(originalLf, edits) {
28624
28624
  return { ok: true, content: pieces.join(""), editCount: edits.length };
28625
28625
  }
28626
28626
 
28627
+ // src/gitSafety.ts
28628
+ var import_node_os = require("node:os");
28629
+ var import_node_path = require("node:path");
28630
+
28631
+ // src/runtimeReplyError.ts
28632
+ var RuntimeReplyError = class extends Error {
28633
+ summary;
28634
+ constructor(message, summary) {
28635
+ super(message);
28636
+ this.name = "RuntimeReplyError";
28637
+ this.summary = summary;
28638
+ }
28639
+ };
28640
+
28641
+ // src/failureReason.ts
28642
+ var MAX_FAILURE_REASON = 1e3;
28643
+ var MIN_SECRET_LENGTH = 8;
28644
+ var CREDENTIAL_PATTERNS = [
28645
+ /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,
28646
+ /\bgithub_pat_[A-Za-z0-9_]{20,}/g,
28647
+ /x-access-token:[^@\s'"]+/gi,
28648
+ // Only the header form ("Authorization: basic <token>"), or a bearer value that contains a digit: a bare
28649
+ // "basic authentication" or "bearer of the news" is prose, not a credential.
28650
+ /\bauthorization:\s*(?:basic|bearer|token)\s+[^\s'"]{8,}/gi,
28651
+ /\bbearer\s+(?=[A-Za-z0-9._~+/=-]*\d)[A-Za-z0-9._~+/=-]{12,}/gi,
28652
+ // A signed JWT is three dot-separated segments; QuikPilot's own run token is an encrypted JWT (alg dir) of five, the
28653
+ // second one empty. The run token is also matched by exact value, but one that has expired or rotated is not the
28654
+ // current value, so its shape has to catch it.
28655
+ /\beyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*){2,4}/g
28656
+ ];
28657
+ function failureSummary(err2) {
28658
+ if (err2 instanceof RuntimeReplyError) return err2.summary;
28659
+ return err2 instanceof Error ? err2.message : String(err2);
28660
+ }
28661
+ function scrubSecrets(message, secrets = []) {
28662
+ let text3 = message;
28663
+ for (const secret of secrets) {
28664
+ if (secret.length >= MIN_SECRET_LENGTH) text3 = text3.split(secret).join("***");
28665
+ }
28666
+ for (const pattern of CREDENTIAL_PATTERNS) text3 = text3.replace(pattern, "***");
28667
+ return text3;
28668
+ }
28669
+ function describeFailureReason(message, secrets = []) {
28670
+ let text3 = scrubSecrets(message, secrets);
28671
+ text3 = text3.replace(/\s*\n\s*/g, " | ").trim();
28672
+ return text3.length > MAX_FAILURE_REASON ? `${text3.slice(0, MAX_FAILURE_REASON)}\u2026` : text3;
28673
+ }
28674
+
28675
+ // src/scrubForModel.ts
28676
+ var REDACTION_WORDS = ["credential", "private_key", "cloud_key", "url_credentials", "assigned_secret"];
28677
+ function emptyRedactionCounts() {
28678
+ return { credential: 0, private_key: 0, cloud_key: 0, url_credentials: 0, assigned_secret: 0 };
28679
+ }
28680
+ function nonZero(counts) {
28681
+ const out2 = {};
28682
+ for (const w of REDACTION_WORDS) if (counts[w] > 0) out2[w] = counts[w];
28683
+ return out2;
28684
+ }
28685
+ function addRedactionCounts(into, more) {
28686
+ for (const word of REDACTION_WORDS) into[word] += more[word];
28687
+ }
28688
+ var NAMES = "password|passwd|pwd|secret|token|api[_-]?key|access_key|private_key|credential";
28689
+ var PRIVATE_KEY = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g;
28690
+ var CLOUD_KEYS = [
28691
+ /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
28692
+ /\bxox[abeprs]-[A-Za-z0-9-]{10,}/g,
28693
+ /\b[sr]k_(?:live|test)_[A-Za-z0-9]{16,}/g,
28694
+ /\bAIza[0-9A-Za-z_-]{35}/g,
28695
+ // QUIKTR-1703: package-registry and container-registry tokens, which have a shape of their own (npm automation tokens, PyPI API tokens,
28696
+ // GitLab personal access tokens, Docker Hub personal access tokens).
28697
+ /\bnpm_[A-Za-z0-9]{30,}\b/g,
28698
+ /\bpypi-[A-Za-z0-9_-]{30,}/g,
28699
+ /\bglpat-[A-Za-z0-9_-]{20,}/g,
28700
+ /\bdckr_pat_[A-Za-z0-9_-]{20,}/g
28701
+ ];
28702
+ var URL_CREDENTIALS = /\b([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+:[^/\s@]+@/gi;
28703
+ var ASSIGNED_QUOTED = new RegExp(`((?<![\\w.-])[\\w.-]{0,40}(?:${NAMES})[\\w.-]{0,40}["']?\\s*[:=]\\s*)(["'])[^"'\\s]{8,}\\2`, "gi");
28704
+ var ASSIGNED_ENV = new RegExp(
28705
+ `^((?:\\d+\\t)?\\s*(?:export\\s+)?[A-Z0-9_]*(?:${NAMES.toUpperCase().replace(/\[_-\]\?/g, "_?")})[A-Z0-9_]*[ \\t]*=[ \\t]*)(?!["'])\\S{8,}`,
28706
+ "gm"
28707
+ );
28708
+ var NAMES_CONFIG = `${NAMES}|passphrase|access[_-]?key|account[_-]?key|_auth(?![a-z])`;
28709
+ var CONFIG_REFERENCE = "(?!\\$\\{|\\$\\(|%\\(|%[A-Za-z_]+%|\\{\\{|\\*\\*\\*)";
28710
+ var CONFIG_PLAIN = "(?!(?:true|false|null|none|yes|no|on|off|\\d{1,3})[ \\t]*(?:[#;]|$))";
28711
+ var CONFIG_QUOTED = new RegExp(
28712
+ `((?<![\\w.-])[\\w.-]{0,60}(?:${NAMES_CONFIG})[\\w.-]{0,40}["']?[ \\t]*[:=][ \\t]*)(["'])${CONFIG_REFERENCE}[^"'\\r\\n]+\\2`,
28713
+ "gi"
28714
+ );
28715
+ var CONFIG_UNQUOTED = new RegExp(
28716
+ `((?<![\\w.-])[\\w.-]{0,60}(?:${NAMES_CONFIG})[\\w.-]{0,40}[ \\t]*[:=][ \\t]*)${CONFIG_REFERENCE}(?!["'])${CONFIG_PLAIN}[^\\s#;][^\\r\\n]*$`,
28717
+ "gim"
28718
+ );
28719
+ var CONFIG_INLINE = /(?<![\w.-])((?:password|passwd|pwd|passphrase|secret|accountkey|sharedaccesskey|access[_-]?key)[ \t]*=[ \t]*)(?!\$\{|["']|\*\*\*)[^;&"'\s<]+/gi;
28720
+ var CONFIG_XML_ELEMENT = /<([\w.:-]*(?:password|passwd|pwd|passphrase|secret|token|api-?key|access-?key|credential)[\w.:-]*)((?:\s[^>]*)?)>(?![ \t\r\n]*(?:\$\{|\*\*\*))([^<]*\S[^<]*)<\/\1>/gi;
28721
+ var CONFIG_XML_ATTRIBUTE = /(key[ \t]*=[ \t]*["'][^"']*(?:password|token|secret|api-?key)[^"']*["'][ \t]+value[ \t]*=[ \t]*["'])(?!\$\{|\*\*\*)[^"']+(["'])/gi;
28722
+ var CONFIG_FILE = /(^|\/)\.env(\.[^/]*)?$|\.env$|\.(?:properties|ini|cfg|conf|config|toml|ya?ml|xml)$|(^|\/)(?:appsettings|config|settings|secrets|credentials)[^/]*\.json$/i;
28723
+ var TRANSLATION_FILE = /(^|\/)(?:locales?|i18n|l10n|lang|languages|translations?|messages)\/|(^|\/)(?:messages|labels|strings|bundle)[\w-]*\.properties$|_[a-z]{2}(?:_[A-Z]{2})?\.properties$/;
28724
+ function isConfigPath(path) {
28725
+ return CONFIG_FILE.test(path) && !TRANSLATION_FILE.test(path);
28726
+ }
28727
+ function modeForPath(path, base) {
28728
+ return path !== void 0 && isConfigPath(path) ? "config" : base;
28729
+ }
28730
+ function configPathInDiff(text3) {
28731
+ for (const m of text3.matchAll(/^\+\+\+ b\/(.+)$/gm)) if (isConfigPath(m[1])) return m[1];
28732
+ return void 0;
28733
+ }
28734
+ function replaceCounting(text3, pattern, replacement, onHit) {
28735
+ return text3.replace(pattern, (...args2) => {
28736
+ onHit();
28737
+ return typeof replacement === "function" ? replacement(...args2) : replacement;
28738
+ });
28739
+ }
28740
+ function scrubForModel(input, secrets = [], mode = "look") {
28741
+ const counts = emptyRedactionCounts();
28742
+ let text3 = input;
28743
+ text3 = replaceCounting(text3, PRIVATE_KEY, "***", () => counts.private_key += 1);
28744
+ for (const secret of secrets) {
28745
+ if (secret.length < MIN_SECRET_LENGTH) continue;
28746
+ const parts2 = text3.split(secret);
28747
+ if (parts2.length > 1) {
28748
+ counts.credential += parts2.length - 1;
28749
+ text3 = parts2.join("***");
28750
+ }
28751
+ }
28752
+ for (const pattern of CREDENTIAL_PATTERNS) text3 = replaceCounting(text3, pattern, "***", () => counts.credential += 1);
28753
+ for (const pattern of CLOUD_KEYS) text3 = replaceCounting(text3, pattern, "***", () => counts.cloud_key += 1);
28754
+ text3 = replaceCounting(text3, URL_CREDENTIALS, (_all, scheme) => `${scheme}***@`, () => counts.url_credentials += 1);
28755
+ if (mode === "look" || mode === "config") {
28756
+ text3 = replaceCounting(text3, ASSIGNED_QUOTED, (_all, name2, quote) => `${name2}${quote}***${quote}`, () => counts.assigned_secret += 1);
28757
+ text3 = replaceCounting(text3, ASSIGNED_ENV, (_all, name2) => `${name2}***`, () => counts.assigned_secret += 1);
28758
+ }
28759
+ if (mode === "config") {
28760
+ const hit = () => counts.assigned_secret += 1;
28761
+ text3 = replaceCounting(text3, CONFIG_XML_ELEMENT, (_all, tag, attrs) => `<${tag}${attrs}>***</${tag}>`, hit);
28762
+ text3 = replaceCounting(text3, CONFIG_XML_ATTRIBUTE, (_all, head, quote) => `${head}***${quote}`, hit);
28763
+ text3 = replaceCounting(text3, CONFIG_QUOTED, (_all, name2, quote) => `${name2}${quote}***${quote}`, hit);
28764
+ text3 = replaceCounting(text3, CONFIG_INLINE, (_all, name2) => `${name2}***`, hit);
28765
+ text3 = replaceCounting(text3, CONFIG_UNQUOTED, (_all, name2) => `${name2}***`, hit);
28766
+ }
28767
+ return { text: text3, counts };
28768
+ }
28769
+ function makeCodeScrubber(secrets, onHits) {
28770
+ return (text3, path) => {
28771
+ const r = scrubForModel(text3, secrets, modeForPath(path, "code"));
28772
+ if (onHits && REDACTION_WORDS.some((w) => r.counts[w] > 0)) onHits(r.counts);
28773
+ return r.text;
28774
+ };
28775
+ }
28776
+ function scrubEntriesForModel(entries, secrets, keep) {
28777
+ return entries.map((e) => {
28778
+ if (keep && "path" in e && keep.has(e.path)) return e;
28779
+ const path = "path" in e && typeof e.path === "string" ? e.path : void 0;
28780
+ return { ...e, content: scrubForModel(e.content, secrets, modeForPath(path, "code")).text };
28781
+ });
28782
+ }
28783
+
28784
+ // src/commandEnv.ts
28785
+ var ALLOWED_NAMES = /* @__PURE__ */ new Set([
28786
+ // Identity, locale and scratch space.
28787
+ "PATH",
28788
+ "Path",
28789
+ "HOME",
28790
+ "USER",
28791
+ "USERNAME",
28792
+ "LOGNAME",
28793
+ "SHELL",
28794
+ "HOSTNAME",
28795
+ "TMPDIR",
28796
+ "TMP",
28797
+ "TEMP",
28798
+ "TZ",
28799
+ "LANG",
28800
+ "LANGUAGE",
28801
+ "TERM",
28802
+ "COLORTERM",
28803
+ "NO_COLOR",
28804
+ "FORCE_COLOR",
28805
+ "DISPLAY",
28806
+ "CI",
28807
+ // Windows system variables, for the developer machine.
28808
+ "SystemRoot",
28809
+ "SYSTEMROOT",
28810
+ "windir",
28811
+ "COMSPEC",
28812
+ "PATHEXT",
28813
+ "USERPROFILE",
28814
+ "APPDATA",
28815
+ "LOCALAPPDATA",
28816
+ // Network settings a hosted or self-hosted runner may rely on.
28817
+ "HTTP_PROXY",
28818
+ "HTTPS_PROXY",
28819
+ "NO_PROXY",
28820
+ "ALL_PROXY",
28821
+ "http_proxy",
28822
+ "https_proxy",
28823
+ "no_proxy",
28824
+ "all_proxy",
28825
+ "SSL_CERT_FILE",
28826
+ "SSL_CERT_DIR",
28827
+ "NODE_EXTRA_CA_CERTS",
28828
+ "REQUESTS_CA_BUNDLE",
28829
+ "CURL_CA_BUNDLE",
28830
+ // Toolchain locations the setup-* actions and the runner image export.
28831
+ "NODE_OPTIONS",
28832
+ "NODE_PATH",
28833
+ "NVM_DIR",
28834
+ "ImageOS",
28835
+ "ImageVersion",
28836
+ "AGENT_TOOLSDIRECTORY",
28837
+ "CONDA",
28838
+ "pythonLocation",
28839
+ "PKG_CONFIG_PATH",
28840
+ "LD_LIBRARY_PATH",
28841
+ "CARGO_HOME",
28842
+ "RUSTUP_HOME",
28843
+ "GOPATH",
28844
+ "GOMODCACHE",
28845
+ "GOCACHE",
28846
+ "GOFLAGS",
28847
+ "JAVA_HOME",
28848
+ "GRADLE_HOME",
28849
+ "GRADLE_USER_HOME",
28850
+ "MAVEN_HOME",
28851
+ "M2_HOME",
28852
+ "ANDROID_HOME",
28853
+ "ANDROID_SDK_ROOT",
28854
+ "GEM_HOME",
28855
+ "GEM_PATH",
28856
+ "BUNDLE_PATH",
28857
+ "PIPX_HOME",
28858
+ "PIPX_BIN_DIR",
28859
+ "POETRY_HOME",
28860
+ // QUIKTR-1699: PHP projects (Composer, set up by shivammathur/setup-php).
28861
+ "COMPOSER_HOME",
28862
+ "COMPOSER_CACHE_DIR",
28863
+ "COMPOSER_NO_INTERACTION",
28864
+ "PHP_INI_SCAN_DIR",
28865
+ "PNPM_HOME",
28866
+ "BUN_INSTALL",
28867
+ "DENO_INSTALL",
28868
+ "DENO_DIR",
28869
+ "VOLTA_HOME",
28870
+ "COREPACK_HOME",
28871
+ "PYENV_ROOT",
28872
+ "RBENV_ROOT",
28873
+ // QUIKTR-1703: settings a project's own steps export for its tests and that carry no secret: where Go, Python, .NET and Rust look for
28874
+ // things and how they behave. A path, a flag, a pattern list; never a login (those are withheld by name below).
28875
+ "GOPRIVATE",
28876
+ "GONOSUMDB",
28877
+ "GONOSUMCHECK",
28878
+ "GOSUMDB",
28879
+ "GOTOOLCHAIN",
28880
+ "GOOS",
28881
+ "GOARCH",
28882
+ "CGO_ENABLED",
28883
+ "VIRTUAL_ENV",
28884
+ "PYTHONPATH",
28885
+ "PYTHONDONTWRITEBYTECODE",
28886
+ "PYTHONUNBUFFERED",
28887
+ "PYTHONHASHSEED",
28888
+ "PIP_CACHE_DIR",
28889
+ "PIP_NO_INPUT",
28890
+ "PIP_DISABLE_PIP_VERSION_CHECK",
28891
+ "UV_CACHE_DIR",
28892
+ "UV_PYTHON",
28893
+ "NODE_ENV",
28894
+ "NUGET_PACKAGES",
28895
+ "NUGET_HTTP_CACHE_PATH",
28896
+ "CARGO_TARGET_DIR",
28897
+ "CARGO_INCREMENTAL",
28898
+ "RUST_BACKTRACE",
28899
+ "RUST_LOG",
28900
+ // ... and these, which CAN carry a login inside their value (a registry address with `user:pass@`, a Java option `-D...password=`):
28901
+ // kept only when the value is clean (`valueIsClean`).
28902
+ "GOPROXY",
28903
+ "PIP_INDEX_URL",
28904
+ "PIP_EXTRA_INDEX_URL",
28905
+ "UV_INDEX_URL",
28906
+ "UV_DEFAULT_INDEX",
28907
+ "MAVEN_OPTS",
28908
+ "JAVA_TOOL_OPTIONS",
28909
+ "JAVA_OPTS",
28910
+ "GRADLE_OPTS",
28911
+ "RUSTFLAGS"
28912
+ ]);
28913
+ var VALUE_CHECKED_NAMES = /* @__PURE__ */ new Set([
28914
+ "GOPROXY",
28915
+ "PIP_INDEX_URL",
28916
+ "PIP_EXTRA_INDEX_URL",
28917
+ "UV_INDEX_URL",
28918
+ "UV_DEFAULT_INDEX",
28919
+ "MAVEN_OPTS",
28920
+ "JAVA_TOOL_OPTIONS",
28921
+ "JAVA_OPTS",
28922
+ "GRADLE_OPTS",
28923
+ "RUSTFLAGS"
28924
+ ]);
28925
+ var OPTION_WITH_LOGIN = /(?:^|\s)(?:-D|--)[\w.-]*(?:password|passwd|pwd|token|secret|credential|api[_-]?key|passphrase)[\w.-]*[= ]/i;
28926
+ function valueIsClean(value) {
28927
+ if (OPTION_WITH_LOGIN.test(value)) return false;
28928
+ const counts = scrubForModel(value, [], "code").counts;
28929
+ return REDACTION_WORDS.every((word) => counts[word] === 0);
28930
+ }
28931
+ var ALLOWED_PREFIXES = [
28932
+ "LC_",
28933
+ "RUNNER_",
28934
+ "GITHUB_",
28935
+ "JAVA_HOME_",
28936
+ "GOROOT",
28937
+ "ANDROID_NDK",
28938
+ "Python",
28939
+ // Python_ROOT_DIR, Python2_ROOT_DIR, Python3_ROOT_DIR
28940
+ "XDG_",
28941
+ "DOTNET_",
28942
+ "VCPKG_",
28943
+ "npm_config_",
28944
+ "NPM_CONFIG_"
28945
+ ];
28946
+ var ALWAYS_WITHHELD = /* @__PURE__ */ new Set([
28947
+ "GITHUB_TOKEN",
28948
+ "GITHUB_ENV",
28949
+ "GITHUB_PATH",
28950
+ "GITHUB_OUTPUT",
28951
+ "GITHUB_STATE",
28952
+ "GITHUB_STEP_SUMMARY"
28953
+ ]);
28954
+ var CREDENTIAL_NAME = /(token|secret|password|passwd|credential|private_?key|api_?key|(?:^|_)auth(?:$|_))/i;
28955
+ function isAllowed(name2) {
28956
+ if (ALWAYS_WITHHELD.has(name2) || CREDENTIAL_NAME.test(name2)) return false;
28957
+ if (ALLOWED_NAMES.has(name2)) return true;
28958
+ return ALLOWED_PREFIXES.some((prefix) => name2.startsWith(prefix));
28959
+ }
28960
+ function keeps(name2, value) {
28961
+ return isAllowed(name2) && (!VALUE_CHECKED_NAMES.has(name2) || valueIsClean(value));
28962
+ }
28963
+ function commandEnv(source = process.env) {
28964
+ const out2 = {};
28965
+ for (const [name2, value] of Object.entries(source)) {
28966
+ if (value === void 0) continue;
28967
+ if (keeps(name2, value)) out2[name2] = value;
28968
+ }
28969
+ return out2;
28970
+ }
28971
+ function withheldNames(source = process.env) {
28972
+ return Object.entries(source).filter(([name2, value]) => value !== void 0 && !keeps(name2, value)).map(([name2]) => name2).sort();
28973
+ }
28974
+
28975
+ // src/gitSafety.ts
28976
+ var NO_HOOKS_DIR = (0, import_node_path.join)((0, import_node_os.tmpdir)(), "quikpilot-no-git-hooks-never-created");
28977
+ var NO_HOOKS_ARGS = ["-c", `core.hooksPath=${NO_HOOKS_DIR}`];
28978
+ function gitEnv(extra = {}, source = process.env) {
28979
+ const env2 = commandEnv(source);
28980
+ for (const [name2, value] of Object.entries(source)) {
28981
+ if (value !== void 0 && name2.startsWith("GIT_")) env2[name2] = value;
28982
+ }
28983
+ return { ...env2, ...extra };
28984
+ }
28985
+
28627
28986
  // src/proposal.ts
28628
28987
  var import_node_child_process3 = require("node:child_process");
28629
28988
  var import_node_fs4 = require("node:fs");
28630
- var import_node_os = require("node:os");
28631
- var import_node_path6 = require("node:path");
28989
+ var import_node_os2 = require("node:os");
28990
+ var import_node_path7 = require("node:path");
28632
28991
 
28633
28992
  // src/git.ts
28634
28993
  var import_node_child_process = require("node:child_process");
28635
28994
  var import_node_fs = require("node:fs");
28636
28995
 
28637
28996
  // src/targetingPaths.ts
28638
- var import_node_path = require("node:path");
28997
+ var import_node_path2 = require("node:path");
28639
28998
 
28640
28999
  // src/deniedPaths.ts
28641
29000
  function globToRegExp(pattern) {
@@ -28685,7 +29044,7 @@ function normaliseToolPath(raw, options = {}) {
28685
29044
  if (raw.includes("\\")) return { ok: false, reason: "path_invalid" };
28686
29045
  if (raw.startsWith("/") || /^[A-Za-z]:/.test(raw)) return { ok: false, reason: "path_invalid" };
28687
29046
  if (raw.split("/").includes("..")) return { ok: false, reason: "outside_workspace" };
28688
- const normalised = import_node_path.posix.normalize(raw).replace(/\/+$/, "");
29047
+ const normalised = import_node_path2.posix.normalize(raw).replace(/\/+$/, "");
28689
29048
  if (normalised === "" || normalised === ".") {
28690
29049
  return allowRoot ? { ok: true, path: "" } : { ok: false, reason: "path_invalid" };
28691
29050
  }
@@ -28701,9 +29060,9 @@ function buildVisibleListing(listing, deniedPaths) {
28701
29060
 
28702
29061
  // src/git.ts
28703
29062
  function git(args2, extraEnv = {}) {
28704
- return (0, import_node_child_process.execFileSync)("git", args2, {
29063
+ return (0, import_node_child_process.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], {
28705
29064
  encoding: "utf8",
28706
- env: { ...process.env, ...extraEnv }
29065
+ env: gitEnv(extraEnv)
28707
29066
  }).trim();
28708
29067
  }
28709
29068
  function headCommit() {
@@ -28729,8 +29088,9 @@ function addAll(scope) {
28729
29088
  }
28730
29089
  }
28731
29090
  function changedOutside(scope) {
28732
- const out2 = (0, import_node_child_process.execFileSync)("git", ["status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
29091
+ const out2 = (0, import_node_child_process.execFileSync)("git", [...NO_HOOKS_ARGS, "status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
28733
29092
  encoding: "utf8",
29093
+ env: gitEnv(),
28734
29094
  maxBuffer: 64 * 1024 * 1024
28735
29095
  });
28736
29096
  return out2.split("\0").filter((entry) => entry.length > 3).map((entry) => entry.slice(3)).filter((path) => !matchesPrefix(path, scope) && !matchesPrefix(path, RUNNER_OWN_FOLDER));
@@ -28740,12 +29100,12 @@ function diffCachedNamesMatching(pattern) {
28740
29100
  return out2 ? out2.split("\n").filter(Boolean) : [];
28741
29101
  }
28742
29102
  function listFiles(pathspec) {
28743
- const out2 = (0, import_node_child_process.execFileSync)("git", ["ls-files", "-z", "--", pathspec], { encoding: "utf8", maxBuffer: LIST_MAX_BUFFER_BYTES });
29103
+ const out2 = (0, import_node_child_process.execFileSync)("git", [...NO_HOOKS_ARGS, "ls-files", "-z", "--", pathspec], { encoding: "utf8", maxBuffer: LIST_MAX_BUFFER_BYTES, env: gitEnv() });
28744
29104
  return out2.split("\0").filter(Boolean);
28745
29105
  }
28746
29106
  function hasStagedChanges() {
28747
29107
  try {
28748
- (0, import_node_child_process.execFileSync)("git", ["diff", "--cached", "--quiet"]);
29108
+ (0, import_node_child_process.execFileSync)("git", [...NO_HOOKS_ARGS, "diff", "--cached", "--quiet"], { env: gitEnv() });
28749
29109
  return false;
28750
29110
  } catch {
28751
29111
  return true;
@@ -28884,7 +29244,7 @@ var GIT_MAX_BUFFER = 32 * 1024 * 1024;
28884
29244
  var MAX_COMMITS_LOOKED_AT = 400;
28885
29245
  var WALK_BUDGET_MS = 25e3;
28886
29246
  var SHA = /^[0-9a-f]{40}$/;
28887
- var readGit = (args2) => (0, import_node_child_process2.execFileSync)("git", args2, { encoding: "utf8", timeout: GIT_TIMEOUT_MS, maxBuffer: GIT_MAX_BUFFER, stdio: ["ignore", "pipe", "ignore"] });
29247
+ var readGit = (args2) => (0, import_node_child_process2.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], { env: gitEnv(), encoding: "utf8", timeout: GIT_TIMEOUT_MS, maxBuffer: GIT_MAX_BUFFER, stdio: ["ignore", "pipe", "ignore"] });
28888
29248
  function parseFileCommits(log) {
28889
29249
  const out2 = [];
28890
29250
  for (const block of log.split("")) {
@@ -34021,11 +34381,11 @@ pp$1.regexp_classStringDisjunctionContents = function(state) {
34021
34381
  return result;
34022
34382
  };
34023
34383
  pp$1.regexp_classString = function(state) {
34024
- var count3 = 0;
34384
+ var count4 = 0;
34025
34385
  while (this.regexp_eatClassSetCharacter(state)) {
34026
- count3++;
34386
+ count4++;
34027
34387
  }
34028
- return count3 === 1 ? CharSetOk : CharSetString;
34388
+ return count4 === 1 ? CharSetOk : CharSetString;
34029
34389
  };
34030
34390
  pp$1.regexp_eatClassSetCharacter = function(state) {
34031
34391
  var start3 = state.pos;
@@ -35194,17 +35554,17 @@ function isOtherCheck(lang, n) {
35194
35554
  return false;
35195
35555
  }
35196
35556
  function countChecks(lang, spec, node) {
35197
- let count3 = 0;
35557
+ let count4 = 0;
35198
35558
  const walk3 = (n) => {
35199
35559
  if (spec.assertion(n)) {
35200
- count3 += 1;
35560
+ count4 += 1;
35201
35561
  return;
35202
35562
  }
35203
- if (isOtherCheck(lang, n)) count3 += 1;
35563
+ if (isOtherCheck(lang, n)) count4 += 1;
35204
35564
  for (const c of n.children) walk3(c);
35205
35565
  };
35206
35566
  walk3(node);
35207
- return count3;
35567
+ return count4;
35208
35568
  }
35209
35569
  var SPECS = {
35210
35570
  python: {
@@ -36574,7 +36934,7 @@ function setupAdded(input) {
36574
36934
  }
36575
36935
 
36576
36936
  // src/featureTestUpdates.ts
36577
- var import_node_path2 = require("node:path");
36937
+ var import_node_path3 = require("node:path");
36578
36938
  var FEATURE_TEST_UPDATES_KEY = "featureTestUpdates";
36579
36939
  function featureTestUpdatesOn(env2 = process.env) {
36580
36940
  return env2.QUIKPILOT_FEATURE_TEST_UPDATES?.trim().toLowerCase() === "on";
@@ -36593,7 +36953,7 @@ var WEAK_TEST_FOLDER = /(^|\/)(tests?|spec|testutil|testing)\//;
36593
36953
  function isTestSupportPath(path, listing, discovered) {
36594
36954
  if (!listing.includes(path)) return false;
36595
36955
  if (isTestTarget(path, discovered ? new Set(discovered) : null)) return true;
36596
- if (STRONG_TEST_FOLDER.test(path) || import_node_path2.posix.basename(path) === "conftest.py") return true;
36956
+ if (STRONG_TEST_FOLDER.test(path) || import_node_path3.posix.basename(path) === "conftest.py") return true;
36597
36957
  const weak = WEAK_TEST_FOLDER.exec(path);
36598
36958
  if (!weak) return false;
36599
36959
  if (!discovered) return true;
@@ -36606,9 +36966,9 @@ var stripExt = (p) => p.replace(/\.[cm]?[jt]sx?$/i, "");
36606
36966
  var escapeRegExp3 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36607
36967
  function jsNames(spec, from, helper) {
36608
36968
  const target = stripExt(helper);
36609
- const targets = [target, ...import_node_path2.posix.basename(target) === "index" ? [import_node_path2.posix.dirname(target)] : []];
36969
+ const targets = [target, ...import_node_path3.posix.basename(target) === "index" ? [import_node_path3.posix.dirname(target)] : []];
36610
36970
  if (spec.startsWith(".")) {
36611
- const resolved = stripExt(import_node_path2.posix.normalize(import_node_path2.posix.join(import_node_path2.posix.dirname(from), spec)));
36971
+ const resolved = stripExt(import_node_path3.posix.normalize(import_node_path3.posix.join(import_node_path3.posix.dirname(from), spec)));
36612
36972
  return targets.includes(resolved);
36613
36973
  }
36614
36974
  const rest = stripExt(spec.replace(/^[@~#]\//, ""));
@@ -36620,8 +36980,8 @@ function usesHelper(from, text3, helper) {
36620
36980
  if (from === helper) return false;
36621
36981
  if (/\.[cm]?[jt]sx?$/i.test(helper)) return [...text3.matchAll(JS_SPECIFIER)].some((m) => jsNames(m[1], from, helper));
36622
36982
  if (helper.endsWith(".py")) {
36623
- if (import_node_path2.posix.basename(helper) === "conftest.py") {
36624
- const dir = import_node_path2.posix.dirname(helper);
36983
+ if (import_node_path3.posix.basename(helper) === "conftest.py") {
36984
+ const dir = import_node_path3.posix.dirname(helper);
36625
36985
  return dir === "." || from.startsWith(`${dir}/`);
36626
36986
  }
36627
36987
  const dotted = helper.slice(0, -3).split("/").join(".");
@@ -36631,11 +36991,11 @@ function usesHelper(from, text3, helper) {
36631
36991
  });
36632
36992
  }
36633
36993
  if (helper.endsWith(".go")) {
36634
- const dir = import_node_path2.posix.dirname(helper);
36635
- return import_node_path2.posix.dirname(from) === dir || dir !== "." && new RegExp(`"[^"]*(^|/)${escapeRegExp3(dir)}"`).test(text3);
36994
+ const dir = import_node_path3.posix.dirname(helper);
36995
+ return import_node_path3.posix.dirname(from) === dir || dir !== "." && new RegExp(`"[^"]*(^|/)${escapeRegExp3(dir)}"`).test(text3);
36636
36996
  }
36637
36997
  if (helper.endsWith(".java") || helper.endsWith(".kt")) {
36638
- const name2 = import_node_path2.posix.basename(helper).replace(/\.(java|kt)$/, "");
36998
+ const name2 = import_node_path3.posix.basename(helper).replace(/\.(java|kt)$/, "");
36639
36999
  return new RegExp(`\\b${escapeRegExp3(name2)}\\b`).test(text3);
36640
37000
  }
36641
37001
  return false;
@@ -36652,7 +37012,7 @@ function usedByOf(helper, testFiles, read) {
36652
37012
 
36653
37013
  // src/targetingTools.ts
36654
37014
  var import_node_fs2 = require("node:fs");
36655
- var import_node_path4 = require("node:path");
37015
+ var import_node_path5 = require("node:path");
36656
37016
 
36657
37017
  // src/genericDenies.ts
36658
37018
  var OTHER_LOCK_FILES = [
@@ -36719,12 +37079,13 @@ var CREDENTIAL_FILES = [
36719
37079
  "**/*.ppk"
36720
37080
  ];
36721
37081
  var GIT_INTERNALS = [".git/**"];
37082
+ var HOOK_FILES = ["**/.husky/**", "**/.githooks/**", "**/lefthook*.yml", "**/.lefthook*.yml"];
36722
37083
  function withExtra(denied, extra) {
36723
37084
  const have = new Set(denied);
36724
37085
  return [...denied, ...extra.filter((p) => !have.has(p))];
36725
37086
  }
36726
37087
  function writeDenied(denied) {
36727
- return withExtra(denied, [...OTHER_LOCK_FILES, ...CREDENTIAL_FILES, ...GIT_INTERNALS]);
37088
+ return withExtra(denied, [...OTHER_LOCK_FILES, ...CREDENTIAL_FILES, ...GIT_INTERNALS, ...HOOK_FILES]);
36728
37089
  }
36729
37090
  function readDenied(denied) {
36730
37091
  return withExtra(writeDenied(denied), SECRET_SHAPED_FILES);
@@ -36747,159 +37108,6 @@ function isGeneratedText(lf) {
36747
37108
  }
36748
37109
  var GENERATED_FILE_MESSAGE = "This file is generated (its first lines say so), so a change here would be overwritten. Change the file it is generated from instead.";
36749
37110
 
36750
- // src/runtimeReplyError.ts
36751
- var RuntimeReplyError = class extends Error {
36752
- summary;
36753
- constructor(message, summary) {
36754
- super(message);
36755
- this.name = "RuntimeReplyError";
36756
- this.summary = summary;
36757
- }
36758
- };
36759
-
36760
- // src/failureReason.ts
36761
- var MAX_FAILURE_REASON = 1e3;
36762
- var MIN_SECRET_LENGTH = 8;
36763
- var CREDENTIAL_PATTERNS = [
36764
- /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,
36765
- /\bgithub_pat_[A-Za-z0-9_]{20,}/g,
36766
- /x-access-token:[^@\s'"]+/gi,
36767
- // Only the header form ("Authorization: basic <token>"), or a bearer value that contains a digit: a bare
36768
- // "basic authentication" or "bearer of the news" is prose, not a credential.
36769
- /\bauthorization:\s*(?:basic|bearer|token)\s+[^\s'"]{8,}/gi,
36770
- /\bbearer\s+(?=[A-Za-z0-9._~+/=-]*\d)[A-Za-z0-9._~+/=-]{12,}/gi,
36771
- // A signed JWT is three dot-separated segments; QuikPilot's own run token is an encrypted JWT (alg dir) of five, the
36772
- // second one empty. The run token is also matched by exact value, but one that has expired or rotated is not the
36773
- // current value, so its shape has to catch it.
36774
- /\beyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*){2,4}/g
36775
- ];
36776
- function failureSummary(err2) {
36777
- if (err2 instanceof RuntimeReplyError) return err2.summary;
36778
- return err2 instanceof Error ? err2.message : String(err2);
36779
- }
36780
- function scrubSecrets(message, secrets = []) {
36781
- let text3 = message;
36782
- for (const secret of secrets) {
36783
- if (secret.length >= MIN_SECRET_LENGTH) text3 = text3.split(secret).join("***");
36784
- }
36785
- for (const pattern of CREDENTIAL_PATTERNS) text3 = text3.replace(pattern, "***");
36786
- return text3;
36787
- }
36788
- function describeFailureReason(message, secrets = []) {
36789
- let text3 = scrubSecrets(message, secrets);
36790
- text3 = text3.replace(/\s*\n\s*/g, " | ").trim();
36791
- return text3.length > MAX_FAILURE_REASON ? `${text3.slice(0, MAX_FAILURE_REASON)}\u2026` : text3;
36792
- }
36793
-
36794
- // src/scrubForModel.ts
36795
- var REDACTION_WORDS = ["credential", "private_key", "cloud_key", "url_credentials", "assigned_secret"];
36796
- function emptyRedactionCounts() {
36797
- return { credential: 0, private_key: 0, cloud_key: 0, url_credentials: 0, assigned_secret: 0 };
36798
- }
36799
- function nonZero(counts) {
36800
- const out2 = {};
36801
- for (const w of REDACTION_WORDS) if (counts[w] > 0) out2[w] = counts[w];
36802
- return out2;
36803
- }
36804
- function addRedactionCounts(into, more) {
36805
- for (const word of REDACTION_WORDS) into[word] += more[word];
36806
- }
36807
- var NAMES = "password|passwd|pwd|secret|token|api[_-]?key|access_key|private_key|credential";
36808
- var PRIVATE_KEY = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g;
36809
- var CLOUD_KEYS = [
36810
- /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
36811
- /\bxox[abeprs]-[A-Za-z0-9-]{10,}/g,
36812
- /\b[sr]k_(?:live|test)_[A-Za-z0-9]{16,}/g,
36813
- /\bAIza[0-9A-Za-z_-]{35}/g,
36814
- // QUIKTR-1703: package-registry and container-registry tokens, which have a shape of their own (npm automation tokens, PyPI API tokens,
36815
- // GitLab personal access tokens, Docker Hub personal access tokens).
36816
- /\bnpm_[A-Za-z0-9]{30,}\b/g,
36817
- /\bpypi-[A-Za-z0-9_-]{30,}/g,
36818
- /\bglpat-[A-Za-z0-9_-]{20,}/g,
36819
- /\bdckr_pat_[A-Za-z0-9_-]{20,}/g
36820
- ];
36821
- var URL_CREDENTIALS = /\b([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+:[^/\s@]+@/gi;
36822
- var ASSIGNED_QUOTED = new RegExp(`((?<![\\w.-])[\\w.-]{0,40}(?:${NAMES})[\\w.-]{0,40}["']?\\s*[:=]\\s*)(["'])[^"'\\s]{8,}\\2`, "gi");
36823
- var ASSIGNED_ENV = new RegExp(
36824
- `^((?:\\d+\\t)?\\s*(?:export\\s+)?[A-Z0-9_]*(?:${NAMES.toUpperCase().replace(/\[_-\]\?/g, "_?")})[A-Z0-9_]*[ \\t]*=[ \\t]*)(?!["'])\\S{8,}`,
36825
- "gm"
36826
- );
36827
- var NAMES_CONFIG = `${NAMES}|passphrase|access[_-]?key|account[_-]?key|_auth(?![a-z])`;
36828
- var CONFIG_REFERENCE = "(?!\\$\\{|\\$\\(|%\\(|%[A-Za-z_]+%|\\{\\{|\\*\\*\\*)";
36829
- var CONFIG_PLAIN = "(?!(?:true|false|null|none|yes|no|on|off|\\d{1,3})[ \\t]*(?:[#;]|$))";
36830
- var CONFIG_QUOTED = new RegExp(
36831
- `((?<![\\w.-])[\\w.-]{0,60}(?:${NAMES_CONFIG})[\\w.-]{0,40}["']?[ \\t]*[:=][ \\t]*)(["'])${CONFIG_REFERENCE}[^"'\\r\\n]+\\2`,
36832
- "gi"
36833
- );
36834
- var CONFIG_UNQUOTED = new RegExp(
36835
- `((?<![\\w.-])[\\w.-]{0,60}(?:${NAMES_CONFIG})[\\w.-]{0,40}[ \\t]*[:=][ \\t]*)${CONFIG_REFERENCE}(?!["'])${CONFIG_PLAIN}[^\\s#;][^\\r\\n]*$`,
36836
- "gim"
36837
- );
36838
- var CONFIG_INLINE = /(?<![\w.-])((?:password|passwd|pwd|passphrase|secret|accountkey|sharedaccesskey|access[_-]?key)[ \t]*=[ \t]*)(?!\$\{|["']|\*\*\*)[^;&"'\s<]+/gi;
36839
- var CONFIG_XML_ELEMENT = /<([\w.:-]*(?:password|passwd|pwd|passphrase|secret|token|api-?key|access-?key|credential)[\w.:-]*)((?:\s[^>]*)?)>(?![ \t\r\n]*(?:\$\{|\*\*\*))([^<]*\S[^<]*)<\/\1>/gi;
36840
- var CONFIG_XML_ATTRIBUTE = /(key[ \t]*=[ \t]*["'][^"']*(?:password|token|secret|api-?key)[^"']*["'][ \t]+value[ \t]*=[ \t]*["'])(?!\$\{|\*\*\*)[^"']+(["'])/gi;
36841
- var CONFIG_FILE = /(^|\/)\.env(\.[^/]*)?$|\.env$|\.(?:properties|ini|cfg|conf|config|toml|ya?ml|xml)$|(^|\/)(?:appsettings|config|settings|secrets|credentials)[^/]*\.json$/i;
36842
- var TRANSLATION_FILE = /(^|\/)(?:locales?|i18n|l10n|lang|languages|translations?|messages)\/|(^|\/)(?:messages|labels|strings|bundle)[\w-]*\.properties$|_[a-z]{2}(?:_[A-Z]{2})?\.properties$/;
36843
- function isConfigPath(path) {
36844
- return CONFIG_FILE.test(path) && !TRANSLATION_FILE.test(path);
36845
- }
36846
- function modeForPath(path, base) {
36847
- return path !== void 0 && isConfigPath(path) ? "config" : base;
36848
- }
36849
- function configPathInDiff(text3) {
36850
- for (const m of text3.matchAll(/^\+\+\+ b\/(.+)$/gm)) if (isConfigPath(m[1])) return m[1];
36851
- return void 0;
36852
- }
36853
- function replaceCounting(text3, pattern, replacement, onHit) {
36854
- return text3.replace(pattern, (...args2) => {
36855
- onHit();
36856
- return typeof replacement === "function" ? replacement(...args2) : replacement;
36857
- });
36858
- }
36859
- function scrubForModel(input, secrets = [], mode = "look") {
36860
- const counts = emptyRedactionCounts();
36861
- let text3 = input;
36862
- text3 = replaceCounting(text3, PRIVATE_KEY, "***", () => counts.private_key += 1);
36863
- for (const secret of secrets) {
36864
- if (secret.length < MIN_SECRET_LENGTH) continue;
36865
- const parts2 = text3.split(secret);
36866
- if (parts2.length > 1) {
36867
- counts.credential += parts2.length - 1;
36868
- text3 = parts2.join("***");
36869
- }
36870
- }
36871
- for (const pattern of CREDENTIAL_PATTERNS) text3 = replaceCounting(text3, pattern, "***", () => counts.credential += 1);
36872
- for (const pattern of CLOUD_KEYS) text3 = replaceCounting(text3, pattern, "***", () => counts.cloud_key += 1);
36873
- text3 = replaceCounting(text3, URL_CREDENTIALS, (_all, scheme) => `${scheme}***@`, () => counts.url_credentials += 1);
36874
- if (mode === "look" || mode === "config") {
36875
- text3 = replaceCounting(text3, ASSIGNED_QUOTED, (_all, name2, quote) => `${name2}${quote}***${quote}`, () => counts.assigned_secret += 1);
36876
- text3 = replaceCounting(text3, ASSIGNED_ENV, (_all, name2) => `${name2}***`, () => counts.assigned_secret += 1);
36877
- }
36878
- if (mode === "config") {
36879
- const hit = () => counts.assigned_secret += 1;
36880
- text3 = replaceCounting(text3, CONFIG_XML_ELEMENT, (_all, tag, attrs) => `<${tag}${attrs}>***</${tag}>`, hit);
36881
- text3 = replaceCounting(text3, CONFIG_XML_ATTRIBUTE, (_all, head, quote) => `${head}***${quote}`, hit);
36882
- text3 = replaceCounting(text3, CONFIG_QUOTED, (_all, name2, quote) => `${name2}${quote}***${quote}`, hit);
36883
- text3 = replaceCounting(text3, CONFIG_INLINE, (_all, name2) => `${name2}***`, hit);
36884
- text3 = replaceCounting(text3, CONFIG_UNQUOTED, (_all, name2) => `${name2}***`, hit);
36885
- }
36886
- return { text: text3, counts };
36887
- }
36888
- function makeCodeScrubber(secrets, onHits) {
36889
- return (text3, path) => {
36890
- const r = scrubForModel(text3, secrets, modeForPath(path, "code"));
36891
- if (onHits && REDACTION_WORDS.some((w) => r.counts[w] > 0)) onHits(r.counts);
36892
- return r.text;
36893
- };
36894
- }
36895
- function scrubEntriesForModel(entries, secrets, keep) {
36896
- return entries.map((e) => {
36897
- if (keep && "path" in e && keep.has(e.path)) return e;
36898
- const path = "path" in e && typeof e.path === "string" ? e.path : void 0;
36899
- return { ...e, content: scrubForModel(e.content, secrets, modeForPath(path, "code")).text };
36900
- });
36901
- }
36902
-
36903
37111
  // src/definitions.ts
36904
37112
  var MAX_NAME_CHARS = 80;
36905
37113
  var MAX_DEFINITIONS = 2e3;
@@ -37068,7 +37276,7 @@ function definitionsOfFile(path, text3) {
37068
37276
  }
37069
37277
 
37070
37278
  // src/importContext.ts
37071
- var import_node_path3 = require("node:path");
37279
+ var import_node_path4 = require("node:path");
37072
37280
  var REGEX_PRECEDING_KEYWORDS = /* @__PURE__ */ new Set([
37073
37281
  "return",
37074
37282
  "typeof",
@@ -37322,12 +37530,12 @@ function resolveImport(fromPath, specifier, listing, mapSpecifier) {
37322
37530
  const clean = specifier.replace(/[?#].*$/, "");
37323
37531
  const relative11 = clean === "." || clean === ".." || clean.startsWith("./") || clean.startsWith("../");
37324
37532
  if (!relative11) return { kind: "external" };
37325
- const base = import_node_path3.posix.normalize(import_node_path3.posix.join(import_node_path3.posix.dirname(fromPath), clean));
37326
- if (base === ".." || base.startsWith("../") || import_node_path3.posix.isAbsolute(base)) return { kind: "unresolved", reason: "not found" };
37533
+ const base = import_node_path4.posix.normalize(import_node_path4.posix.join(import_node_path4.posix.dirname(fromPath), clean));
37534
+ if (base === ".." || base.startsWith("../") || import_node_path4.posix.isAbsolute(base)) return { kind: "unresolved", reason: "not found" };
37327
37535
  return probeBase(base, listing);
37328
37536
  }
37329
37537
  function probeBase(base, listing) {
37330
- const ext = import_node_path3.posix.extname(base);
37538
+ const ext = import_node_path4.posix.extname(base);
37331
37539
  if (ASSET_EXTS.has(ext.toLowerCase())) return { kind: "unresolved", reason: "asset" };
37332
37540
  const candidates = [];
37333
37541
  if (CODE_EXTS.includes(ext)) {
@@ -38233,16 +38441,16 @@ function createNodeToolFs(rootDir = process.cwd()) {
38233
38441
  return {
38234
38442
  rootReal,
38235
38443
  lstat(rel) {
38236
- const s = (0, import_node_fs2.lstatSync)((0, import_node_path4.join)(rootDir, rel));
38444
+ const s = (0, import_node_fs2.lstatSync)((0, import_node_path5.join)(rootDir, rel));
38237
38445
  return { isSymlink: s.isSymbolicLink(), isFile: s.isFile(), size: s.size };
38238
38446
  },
38239
38447
  realpathInside(rel) {
38240
- const real = (0, import_node_fs2.realpathSync)((0, import_node_path4.join)(rootDir, rel));
38241
- const r = (0, import_node_path4.relative)(rootReal, real);
38242
- return r !== "" && !r.startsWith("..") && !(0, import_node_path4.isAbsolute)(r);
38448
+ const real = (0, import_node_fs2.realpathSync)((0, import_node_path5.join)(rootDir, rel));
38449
+ const r = (0, import_node_path5.relative)(rootReal, real);
38450
+ return r !== "" && !r.startsWith("..") && !(0, import_node_path5.isAbsolute)(r);
38243
38451
  },
38244
38452
  readBytes(rel) {
38245
- return (0, import_node_fs2.readFileSync)((0, import_node_path4.join)(rootDir, rel));
38453
+ return (0, import_node_fs2.readFileSync)((0, import_node_path5.join)(rootDir, rel));
38246
38454
  }
38247
38455
  };
38248
38456
  }
@@ -38413,7 +38621,7 @@ function prepareListFiles(args2, env2) {
38413
38621
  const slash = rest.indexOf("/");
38414
38622
  if (slash > 0) counts.set(rest.slice(0, slash), (counts.get(rest.slice(0, slash)) ?? 0) + 1);
38415
38623
  }
38416
- output.subdirs = [...counts.entries()].map(([name2, count3]) => ({ name: name2, count: count3 })).sort((a, b) => b.count - a.count || (a.name < b.name ? -1 : 1)).slice(0, 50);
38624
+ output.subdirs = [...counts.entries()].map(([name2, count4]) => ({ name: name2, count: count4 })).sort((a, b) => b.count - a.count || (a.name < b.name ? -1 : 1)).slice(0, 50);
38417
38625
  }
38418
38626
  return { result: { status: "ok", output } };
38419
38627
  }
@@ -38633,22 +38841,22 @@ function outsideRootMessage(root) {
38633
38841
 
38634
38842
  // src/workspaceOverlay.ts
38635
38843
  var import_node_fs3 = require("node:fs");
38636
- var import_node_path5 = require("node:path");
38844
+ var import_node_path6 = require("node:path");
38637
38845
  function createNodeWriteFs(rootDir = process.cwd()) {
38638
38846
  const base = createNodeToolFs(rootDir);
38639
38847
  const inside3 = (real) => {
38640
- const r = (0, import_node_path5.relative)(base.rootReal, real);
38641
- return !r.startsWith("..") && !(0, import_node_path5.isAbsolute)(r);
38848
+ const r = (0, import_node_path6.relative)(base.rootReal, real);
38849
+ return !r.startsWith("..") && !(0, import_node_path6.isAbsolute)(r);
38642
38850
  };
38643
38851
  return {
38644
38852
  ...base,
38645
38853
  parentInside(rel) {
38646
- let dir = (0, import_node_path5.dirname)((0, import_node_path5.join)(rootDir, rel));
38854
+ let dir = (0, import_node_path6.dirname)((0, import_node_path6.join)(rootDir, rel));
38647
38855
  for (; ; ) {
38648
38856
  try {
38649
38857
  return inside3((0, import_node_fs3.realpathSync)(dir));
38650
38858
  } catch {
38651
- const up = (0, import_node_path5.dirname)(dir);
38859
+ const up = (0, import_node_path6.dirname)(dir);
38652
38860
  if (up === dir) return false;
38653
38861
  dir = up;
38654
38862
  }
@@ -38656,7 +38864,7 @@ function createNodeWriteFs(rootDir = process.cwd()) {
38656
38864
  },
38657
38865
  exists(rel) {
38658
38866
  try {
38659
- (0, import_node_fs3.lstatSync)((0, import_node_path5.join)(rootDir, rel));
38867
+ (0, import_node_fs3.lstatSync)((0, import_node_path6.join)(rootDir, rel));
38660
38868
  return true;
38661
38869
  } catch {
38662
38870
  return false;
@@ -38762,6 +38970,27 @@ function loadTextForEdit(fs2, path, maxBytes) {
38762
38970
  return { ok: true, lf: toLf(text3), ending, bom };
38763
38971
  }
38764
38972
 
38973
+ // src/redactionMarkers.ts
38974
+ var REDACTION_MARKERS = [
38975
+ "[ACCOUNT_REDACTED]",
38976
+ "[AADHAAR_REDACTED]",
38977
+ "[CARD_REDACTED]",
38978
+ "[PAN_REDACTED]",
38979
+ "[PHONE_REDACTED]"
38980
+ ];
38981
+ var REDACTED_TEXT_MESSAGE = "Not written: your text holds a placeholder such as [ACCOUNT_REDACTED] that the AI service put in place of a long number on the way, so the value is not the one you meant. Send it again with the real value written out.";
38982
+ function count(text3, marker) {
38983
+ let n = 0;
38984
+ for (let at2 = text3.indexOf(marker); at2 !== -1; at2 = text3.indexOf(marker, at2 + marker.length)) n += 1;
38985
+ return n;
38986
+ }
38987
+ function addedMarkers(after, before = "") {
38988
+ if (!after.includes("_REDACTED]")) return 0;
38989
+ let added = 0;
38990
+ for (const marker of REDACTION_MARKERS) added += Math.max(0, count(after, marker) - count(before, marker));
38991
+ return added;
38992
+ }
38993
+
38765
38994
  // src/testConflict.ts
38766
38995
  var REPORT_TEST_CONFLICT_TOOL = "report_test_conflict";
38767
38996
  var MAX_CONFLICTS_PER_STOP = 8;
@@ -38781,7 +39010,8 @@ var REJECT_MESSAGES = {
38781
39010
  still_passes_old_code: "With your replacement that test still passes on the code before this run, so it would not show the bug.",
38782
39011
  already_decided: "A person has already decided about that test. Do not report it again.",
38783
39012
  too_many_conflicts: "Too many tests have been reported already. Finish with what you have.",
38784
- generated_test: "That test is written once and run for each row of a table (describe.each or it.each), and its rows were not found in the test run made before your change, so it cannot be checked. Do not report it again: answer CANNOT_COMPLETE, and in your summary name the test and the case it contradicts. A person will change it."
39013
+ generated_test: "That test is written once and run for each row of a table (describe.each or it.each), and its rows were not found in the test run made before your change, so it cannot be checked. Do not report it again: answer CANNOT_COMPLETE, and in your summary name the test and the case it contradicts. A person will change it.",
39014
+ redacted_text: "Not recorded: replace or caseValueTo holds a placeholder such as [ACCOUNT_REDACTED] that the AI service put in place of a long number on the way, so the value is not the one you meant. Report it again with the real value written out."
38785
39015
  };
38786
39016
  var OTHER_LANGUAGE_EXPECTATIONS = "In this language only literal values (text, numbers, true/false), assertion statements, comments and the test's name may differ from find; everything else the test does must stay as it is.";
38787
39017
  var AMBIGUOUS_LINES_SHOWN = 6;
@@ -39084,6 +39314,7 @@ var TestConflictTool = class {
39084
39314
  }
39085
39315
  async check(r) {
39086
39316
  const d = this.deps;
39317
+ if (addedMarkers(r.replace, r.find) + addedMarkers(r.correction.valueTo ?? "", r.correction.valueFrom ?? "") > 0) return this.reject("redacted_text");
39087
39318
  const feature = d.feature;
39088
39319
  const key = `${r.path}\0${r.testTitle}`;
39089
39320
  const helper = feature !== void 0 && r.testPath !== void 0 && !sameFile2(r.testPath, r.path);
@@ -39309,14 +39540,17 @@ function editOverreach(path, before, after, kept, indexes) {
39309
39540
 
39310
39541
  // src/proposal.ts
39311
39542
  var GIT_MAX_BUFFER2 = 64 * 1024 * 1024;
39312
- var runGit = (args2, opts = {}) => (0, import_node_child_process3.execFileSync)("git", args2, {
39313
- encoding: "utf8",
39314
- ...opts.input !== void 0 ? { input: opts.input } : {},
39315
- env: { ...process.env, ...opts.env },
39316
- ...opts.cwd ? { cwd: opts.cwd } : {},
39317
- maxBuffer: GIT_MAX_BUFFER2,
39318
- stdio: ["pipe", "pipe", "pipe"]
39319
- });
39543
+ var runGit = (args2, opts = {}) => (
39544
+ // QUIKTR-2704: no repository hook can run (update-ref fires reference-transaction), and git gets a minimal environment.
39545
+ (0, import_node_child_process3.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], {
39546
+ encoding: "utf8",
39547
+ ...opts.input !== void 0 ? { input: opts.input } : {},
39548
+ env: gitEnv(opts.env),
39549
+ ...opts.cwd ? { cwd: opts.cwd } : {},
39550
+ maxBuffer: GIT_MAX_BUFFER2,
39551
+ stdio: ["pipe", "pipe", "pipe"]
39552
+ })
39553
+ );
39320
39554
  var BOT_ENV = {
39321
39555
  GIT_AUTHOR_NAME: "quikpilot[bot]",
39322
39556
  GIT_AUTHOR_EMAIL: "quikpilot@users.noreply.github.com",
@@ -39433,8 +39667,8 @@ var isLine = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v
39433
39667
  function isMisfit(v) {
39434
39668
  if (typeof v !== "object" || v === null) return false;
39435
39669
  const m = v;
39436
- const count3 = (n) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= 1e4;
39437
- return count3(m.failingRows) && count3(m.totalRows) && m.failingRows <= m.totalRows && Array.isArray(m.examples) && m.examples.length <= 3 && m.examples.every((e) => isStr(e, 120));
39670
+ const count4 = (n) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= 1e4;
39671
+ return count4(m.failingRows) && count4(m.totalRows) && m.failingRows <= m.totalRows && Array.isArray(m.examples) && m.examples.length <= 3 && m.examples.every((e) => isStr(e, 120));
39438
39672
  }
39439
39673
  function isStale(v) {
39440
39674
  if (typeof v !== "object" || v === null) return false;
@@ -39477,9 +39711,9 @@ function createProposalCommit(input) {
39477
39711
  if (files.length === 0) return null;
39478
39712
  const lines = files.flatMap((f) => f.conflicts.map((c) => lineOf2(c, f)));
39479
39713
  const setupFor = files.flatMap((f) => f.conflicts.map((c) => c.fixes && c.fixes.length > 0 ? c.fixes.slice(0, MAX_SETUP_FOR).map((x) => ({ path: x.path, line: x.line })) : void 0));
39480
- const dir = (0, import_node_fs4.mkdtempSync)((0, import_node_path6.join)((0, import_node_os.tmpdir)(), "qp-proposal-"));
39714
+ const dir = (0, import_node_fs4.mkdtempSync)((0, import_node_path7.join)((0, import_node_os2.tmpdir)(), "qp-proposal-"));
39481
39715
  try {
39482
- const env2 = { GIT_INDEX_FILE: (0, import_node_path6.join)(dir, "index"), ...BOT_ENV };
39716
+ const env2 = { GIT_INDEX_FILE: (0, import_node_path7.join)(dir, "index"), ...BOT_ENV };
39483
39717
  const head = git4(["rev-parse", "HEAD"], { cwd }).trim();
39484
39718
  git4(["read-tree", head], { env: env2, cwd });
39485
39719
  for (const f of files) {
@@ -39575,7 +39809,7 @@ function loadApprovedTests(input) {
39575
39809
  }
39576
39810
  const readCurrent = input.readCurrent ?? ((path) => {
39577
39811
  try {
39578
- return (0, import_node_fs5.readFileSync)((0, import_node_path7.join)(cwd ?? process.cwd(), path), "utf8");
39812
+ return (0, import_node_fs5.readFileSync)((0, import_node_path8.join)(cwd ?? process.cwd(), path), "utf8");
39579
39813
  } catch {
39580
39814
  return null;
39581
39815
  }
@@ -39656,13 +39890,15 @@ function setupOverreach(input) {
39656
39890
  return verdict.ok ? null : verdict.why;
39657
39891
  }
39658
39892
  var gitMergeText = ({ ours, base, theirs }) => {
39659
- const dir = (0, import_node_fs5.mkdtempSync)((0, import_node_path7.join)((0, import_node_os2.tmpdir)(), "qp-merge-"));
39893
+ const dir = (0, import_node_fs5.mkdtempSync)((0, import_node_path8.join)((0, import_node_os3.tmpdir)(), "qp-merge-"));
39660
39894
  try {
39661
- (0, import_node_fs5.writeFileSync)((0, import_node_path7.join)(dir, "ours"), ours);
39662
- (0, import_node_fs5.writeFileSync)((0, import_node_path7.join)(dir, "base"), base);
39663
- (0, import_node_fs5.writeFileSync)((0, import_node_path7.join)(dir, "theirs"), theirs);
39664
- return (0, import_node_child_process4.execFileSync)("git", ["merge-file", "-p", (0, import_node_path7.join)(dir, "ours"), (0, import_node_path7.join)(dir, "base"), (0, import_node_path7.join)(dir, "theirs")], {
39895
+ (0, import_node_fs5.writeFileSync)((0, import_node_path8.join)(dir, "ours"), ours);
39896
+ (0, import_node_fs5.writeFileSync)((0, import_node_path8.join)(dir, "base"), base);
39897
+ (0, import_node_fs5.writeFileSync)((0, import_node_path8.join)(dir, "theirs"), theirs);
39898
+ return (0, import_node_child_process4.execFileSync)("git", [...NO_HOOKS_ARGS, "merge-file", "-p", (0, import_node_path8.join)(dir, "ours"), (0, import_node_path8.join)(dir, "base"), (0, import_node_path8.join)(dir, "theirs")], {
39665
39899
  encoding: "utf8",
39900
+ env: gitEnv(),
39901
+ // QUIKTR-2704: git never gets the runner's whole environment.
39666
39902
  maxBuffer: 64 * 1024 * 1024,
39667
39903
  stdio: ["ignore", "pipe", "ignore"]
39668
39904
  });
@@ -39676,7 +39912,7 @@ function loadApprovals(input) {
39676
39912
  const warnings = [];
39677
39913
  const readCurrent = input.readCurrent ?? ((path) => {
39678
39914
  try {
39679
- return (0, import_node_fs5.readFileSync)((0, import_node_path7.join)(input.cwd ?? process.cwd(), path), "utf8");
39915
+ return (0, import_node_fs5.readFileSync)((0, import_node_path8.join)(input.cwd ?? process.cwd(), path), "utf8");
39680
39916
  } catch {
39681
39917
  return null;
39682
39918
  }
@@ -39874,199 +40110,6 @@ async function reportBack(params) {
39874
40110
 
39875
40111
  // src/commands.ts
39876
40112
  var import_node_child_process5 = require("node:child_process");
39877
-
39878
- // src/commandEnv.ts
39879
- var ALLOWED_NAMES = /* @__PURE__ */ new Set([
39880
- // Identity, locale and scratch space.
39881
- "PATH",
39882
- "Path",
39883
- "HOME",
39884
- "USER",
39885
- "USERNAME",
39886
- "LOGNAME",
39887
- "SHELL",
39888
- "HOSTNAME",
39889
- "TMPDIR",
39890
- "TMP",
39891
- "TEMP",
39892
- "TZ",
39893
- "LANG",
39894
- "LANGUAGE",
39895
- "TERM",
39896
- "COLORTERM",
39897
- "NO_COLOR",
39898
- "FORCE_COLOR",
39899
- "DISPLAY",
39900
- "CI",
39901
- // Windows system variables, for the developer machine.
39902
- "SystemRoot",
39903
- "SYSTEMROOT",
39904
- "windir",
39905
- "COMSPEC",
39906
- "PATHEXT",
39907
- "USERPROFILE",
39908
- "APPDATA",
39909
- "LOCALAPPDATA",
39910
- // Network settings a hosted or self-hosted runner may rely on.
39911
- "HTTP_PROXY",
39912
- "HTTPS_PROXY",
39913
- "NO_PROXY",
39914
- "ALL_PROXY",
39915
- "http_proxy",
39916
- "https_proxy",
39917
- "no_proxy",
39918
- "all_proxy",
39919
- "SSL_CERT_FILE",
39920
- "SSL_CERT_DIR",
39921
- "NODE_EXTRA_CA_CERTS",
39922
- "REQUESTS_CA_BUNDLE",
39923
- "CURL_CA_BUNDLE",
39924
- // Toolchain locations the setup-* actions and the runner image export.
39925
- "NODE_OPTIONS",
39926
- "NODE_PATH",
39927
- "NVM_DIR",
39928
- "ImageOS",
39929
- "ImageVersion",
39930
- "AGENT_TOOLSDIRECTORY",
39931
- "CONDA",
39932
- "pythonLocation",
39933
- "PKG_CONFIG_PATH",
39934
- "LD_LIBRARY_PATH",
39935
- "CARGO_HOME",
39936
- "RUSTUP_HOME",
39937
- "GOPATH",
39938
- "GOMODCACHE",
39939
- "GOCACHE",
39940
- "GOFLAGS",
39941
- "JAVA_HOME",
39942
- "GRADLE_HOME",
39943
- "GRADLE_USER_HOME",
39944
- "MAVEN_HOME",
39945
- "M2_HOME",
39946
- "ANDROID_HOME",
39947
- "ANDROID_SDK_ROOT",
39948
- "GEM_HOME",
39949
- "GEM_PATH",
39950
- "BUNDLE_PATH",
39951
- "PIPX_HOME",
39952
- "PIPX_BIN_DIR",
39953
- "POETRY_HOME",
39954
- // QUIKTR-1699: PHP projects (Composer, set up by shivammathur/setup-php).
39955
- "COMPOSER_HOME",
39956
- "COMPOSER_CACHE_DIR",
39957
- "COMPOSER_NO_INTERACTION",
39958
- "PHP_INI_SCAN_DIR",
39959
- "PNPM_HOME",
39960
- "BUN_INSTALL",
39961
- "DENO_INSTALL",
39962
- "DENO_DIR",
39963
- "VOLTA_HOME",
39964
- "COREPACK_HOME",
39965
- "PYENV_ROOT",
39966
- "RBENV_ROOT",
39967
- // QUIKTR-1703: settings a project's own steps export for its tests and that carry no secret: where Go, Python, .NET and Rust look for
39968
- // things and how they behave. A path, a flag, a pattern list; never a login (those are withheld by name below).
39969
- "GOPRIVATE",
39970
- "GONOSUMDB",
39971
- "GONOSUMCHECK",
39972
- "GOSUMDB",
39973
- "GOTOOLCHAIN",
39974
- "GOOS",
39975
- "GOARCH",
39976
- "CGO_ENABLED",
39977
- "VIRTUAL_ENV",
39978
- "PYTHONPATH",
39979
- "PYTHONDONTWRITEBYTECODE",
39980
- "PYTHONUNBUFFERED",
39981
- "PYTHONHASHSEED",
39982
- "PIP_CACHE_DIR",
39983
- "PIP_NO_INPUT",
39984
- "PIP_DISABLE_PIP_VERSION_CHECK",
39985
- "UV_CACHE_DIR",
39986
- "UV_PYTHON",
39987
- "NODE_ENV",
39988
- "NUGET_PACKAGES",
39989
- "NUGET_HTTP_CACHE_PATH",
39990
- "CARGO_TARGET_DIR",
39991
- "CARGO_INCREMENTAL",
39992
- "RUST_BACKTRACE",
39993
- "RUST_LOG",
39994
- // ... and these, which CAN carry a login inside their value (a registry address with `user:pass@`, a Java option `-D...password=`):
39995
- // kept only when the value is clean (`valueIsClean`).
39996
- "GOPROXY",
39997
- "PIP_INDEX_URL",
39998
- "PIP_EXTRA_INDEX_URL",
39999
- "UV_INDEX_URL",
40000
- "UV_DEFAULT_INDEX",
40001
- "MAVEN_OPTS",
40002
- "JAVA_TOOL_OPTIONS",
40003
- "JAVA_OPTS",
40004
- "GRADLE_OPTS",
40005
- "RUSTFLAGS"
40006
- ]);
40007
- var VALUE_CHECKED_NAMES = /* @__PURE__ */ new Set([
40008
- "GOPROXY",
40009
- "PIP_INDEX_URL",
40010
- "PIP_EXTRA_INDEX_URL",
40011
- "UV_INDEX_URL",
40012
- "UV_DEFAULT_INDEX",
40013
- "MAVEN_OPTS",
40014
- "JAVA_TOOL_OPTIONS",
40015
- "JAVA_OPTS",
40016
- "GRADLE_OPTS",
40017
- "RUSTFLAGS"
40018
- ]);
40019
- var OPTION_WITH_LOGIN = /(?:^|\s)(?:-D|--)[\w.-]*(?:password|passwd|pwd|token|secret|credential|api[_-]?key|passphrase)[\w.-]*[= ]/i;
40020
- function valueIsClean(value) {
40021
- if (OPTION_WITH_LOGIN.test(value)) return false;
40022
- const counts = scrubForModel(value, [], "code").counts;
40023
- return REDACTION_WORDS.every((word) => counts[word] === 0);
40024
- }
40025
- var ALLOWED_PREFIXES = [
40026
- "LC_",
40027
- "RUNNER_",
40028
- "GITHUB_",
40029
- "JAVA_HOME_",
40030
- "GOROOT",
40031
- "ANDROID_NDK",
40032
- "Python",
40033
- // Python_ROOT_DIR, Python2_ROOT_DIR, Python3_ROOT_DIR
40034
- "XDG_",
40035
- "DOTNET_",
40036
- "VCPKG_",
40037
- "npm_config_",
40038
- "NPM_CONFIG_"
40039
- ];
40040
- var ALWAYS_WITHHELD = /* @__PURE__ */ new Set([
40041
- "GITHUB_TOKEN",
40042
- "GITHUB_ENV",
40043
- "GITHUB_PATH",
40044
- "GITHUB_OUTPUT",
40045
- "GITHUB_STATE",
40046
- "GITHUB_STEP_SUMMARY"
40047
- ]);
40048
- var CREDENTIAL_NAME = /(token|secret|password|passwd|credential|private_?key|api_?key|(?:^|_)auth(?:$|_))/i;
40049
- function isAllowed(name2) {
40050
- if (ALWAYS_WITHHELD.has(name2) || CREDENTIAL_NAME.test(name2)) return false;
40051
- if (ALLOWED_NAMES.has(name2)) return true;
40052
- return ALLOWED_PREFIXES.some((prefix) => name2.startsWith(prefix));
40053
- }
40054
- function keeps(name2, value) {
40055
- return isAllowed(name2) && (!VALUE_CHECKED_NAMES.has(name2) || valueIsClean(value));
40056
- }
40057
- function commandEnv(source = process.env) {
40058
- const out2 = {};
40059
- for (const [name2, value] of Object.entries(source)) {
40060
- if (value === void 0) continue;
40061
- if (keeps(name2, value)) out2[name2] = value;
40062
- }
40063
- return out2;
40064
- }
40065
- function withheldNames(source = process.env) {
40066
- return Object.entries(source).filter(([name2, value]) => value !== void 0 && !keeps(name2, value)).map(([name2]) => name2).sort();
40067
- }
40068
-
40069
- // src/commands.ts
40070
40113
  var withheldLogged = false;
40071
40114
  function repositoryCommandEnv() {
40072
40115
  if (!withheldLogged) {
@@ -40279,11 +40322,11 @@ function gateNoTimeMessage(baselineMs) {
40279
40322
  // src/testPlan.ts
40280
40323
  var import_node_crypto = require("node:crypto");
40281
40324
  var import_node_fs10 = require("node:fs");
40282
- var import_node_os3 = require("node:os");
40283
- var import_node_path13 = require("node:path");
40325
+ var import_node_os4 = require("node:os");
40326
+ var import_node_path14 = require("node:path");
40284
40327
 
40285
40328
  // src/pairedTests.ts
40286
- var import_node_path8 = require("node:path");
40329
+ var import_node_path9 = require("node:path");
40287
40330
  var MAX_TESTS_PER_TARGET = 3;
40288
40331
  var MAX_REVERSE_TEST_CHARS = 24e3;
40289
40332
  var MAX_TEST_FILE_CHARS = 2e5;
@@ -40325,28 +40368,28 @@ var TestCorpus = class {
40325
40368
  }
40326
40369
  };
40327
40370
  function stemOf(path) {
40328
- const base = import_node_path8.posix.basename(path).replace(/\.[cm]?[jt]sx?$/i, "");
40329
- return base === "index" ? import_node_path8.posix.basename(import_node_path8.posix.dirname(path)) : base;
40371
+ const base = import_node_path9.posix.basename(path).replace(/\.[cm]?[jt]sx?$/i, "");
40372
+ return base === "index" ? import_node_path9.posix.basename(import_node_path9.posix.dirname(path)) : base;
40330
40373
  }
40331
40374
  function sharedPrefix(a, b) {
40332
- const x = import_node_path8.posix.dirname(a).split("/");
40333
- const y = import_node_path8.posix.dirname(b).split("/");
40375
+ const x = import_node_path9.posix.dirname(a).split("/");
40376
+ const y = import_node_path9.posix.dirname(b).split("/");
40334
40377
  let n = 0;
40335
40378
  while (n < x.length && n < y.length && x[n] === y[n]) n++;
40336
40379
  return n;
40337
40380
  }
40338
40381
  function namesOf(path) {
40339
- const base = import_node_path8.posix.basename(path).replace(/\.[cm]?[jt]sx?$/i, "").toLowerCase();
40382
+ const base = import_node_path9.posix.basename(path).replace(/\.[cm]?[jt]sx?$/i, "").toLowerCase();
40340
40383
  const names = base.length >= 2 ? [base] : [];
40341
40384
  if (ROUTE_FILE_NAMES.has(base)) {
40342
- const parts2 = import_node_path8.posix.dirname(path).split("/").filter(Boolean);
40385
+ const parts2 = import_node_path9.posix.dirname(path).split("/").filter(Boolean);
40343
40386
  while (parts2.length > 0 && /^[[(]/.test(parts2[parts2.length - 1])) parts2.pop();
40344
40387
  const folder = parts2[parts2.length - 1];
40345
40388
  if (folder && folder.length >= 3) names.push(folder.toLowerCase());
40346
40389
  }
40347
40390
  return names;
40348
40391
  }
40349
- var namedAfter = (test, path) => namesOf(path).some((n) => import_node_path8.posix.basename(test).toLowerCase().startsWith(n));
40392
+ var namedAfter = (test, path) => namesOf(path).some((n) => import_node_path9.posix.basename(test).toLowerCase().startsWith(n));
40350
40393
  function testsImporting(p) {
40351
40394
  if (p.limit <= 0 || (p.isTest ?? isTestTarget)(p.target) || !supportsImportScan(p.target)) return [];
40352
40395
  const stem = stemOf(p.target);
@@ -40360,7 +40403,7 @@ function testsImporting(p) {
40360
40403
  return r.kind === "repo" && r.path === p.target;
40361
40404
  });
40362
40405
  if (!imported) continue;
40363
- hits.push({ path: file.path, named: import_node_path8.posix.basename(file.path).toLowerCase().startsWith(stem.toLowerCase()), near: sharedPrefix(file.path, p.target), size: file.text.length });
40406
+ hits.push({ path: file.path, named: import_node_path9.posix.basename(file.path).toLowerCase().startsWith(stem.toLowerCase()), near: sharedPrefix(file.path, p.target), size: file.text.length });
40364
40407
  }
40365
40408
  hits.sort((a, b) => Number(b.named) - Number(a.named) || b.near - a.near || a.size - b.size || (a.path < b.path ? -1 : 1));
40366
40409
  return hits.slice(0, p.limit).map((h) => h.path);
@@ -40422,16 +40465,16 @@ function testsThroughOneFile(p) {
40422
40465
  // src/testAdapters.ts
40423
40466
  var import_node_fs9 = require("node:fs");
40424
40467
  var import_node_module = require("node:module");
40425
- var import_node_path11 = require("node:path");
40468
+ var import_node_path12 = require("node:path");
40426
40469
 
40427
40470
  // src/baselineCheck.ts
40428
40471
  var import_node_child_process6 = require("node:child_process");
40429
40472
  var import_node_fs8 = require("node:fs");
40430
- var import_node_path10 = require("node:path");
40473
+ var import_node_path11 = require("node:path");
40431
40474
 
40432
40475
  // src/quiktest.ts
40433
40476
  var import_node_fs6 = require("node:fs");
40434
- var import_node_path9 = require("node:path");
40477
+ var import_node_path10 = require("node:path");
40435
40478
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
40436
40479
  var DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
40437
40480
  "node_modules",
@@ -40477,7 +40520,7 @@ function findJUnitReports(cwd = process.cwd(), opts = {}) {
40477
40520
  }
40478
40521
  for (const entry of entries) {
40479
40522
  if (DEPENDENCY_DIRS.has(entry)) continue;
40480
- const full = (0, import_node_path9.join)(dir, entry);
40523
+ const full = (0, import_node_path10.join)(dir, entry);
40481
40524
  let stat;
40482
40525
  try {
40483
40526
  stat = (0, import_node_fs6.statSync)(full);
@@ -40518,7 +40561,7 @@ function walkForJUnitByName(dir) {
40518
40561
  }
40519
40562
  for (const entry of entries) {
40520
40563
  if (SKIP_DIRS.has(entry)) continue;
40521
- const full = (0, import_node_path9.join)(dir, entry);
40564
+ const full = (0, import_node_path10.join)(dir, entry);
40522
40565
  let stat;
40523
40566
  try {
40524
40567
  stat = (0, import_node_fs6.statSync)(full);
@@ -40542,7 +40585,7 @@ function firstXmlIn(dir, namePattern) {
40542
40585
  return null;
40543
40586
  }
40544
40587
  const match = entries.find((e) => namePattern.test(e));
40545
- return match ? (0, import_node_path9.join)(dir, match) : null;
40588
+ return match ? (0, import_node_path10.join)(dir, match) : null;
40546
40589
  }
40547
40590
  function readTestReportBytes(cwd = process.cwd()) {
40548
40591
  try {
@@ -40555,7 +40598,7 @@ function readTestReportBytes(cwd = process.cwd()) {
40555
40598
  }
40556
40599
  }
40557
40600
  function findJUnitReport(cwd = process.cwd()) {
40558
- return walkForJUnitByName(cwd) ?? findJUnitReports(cwd)[0] ?? firstXmlIn((0, import_node_path9.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path9.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path9.join)(cwd, "target", "surefire-reports"), /\.xml$/);
40601
+ return walkForJUnitByName(cwd) ?? findJUnitReports(cwd)[0] ?? firstXmlIn((0, import_node_path10.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path10.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path10.join)(cwd, "target", "surefire-reports"), /\.xml$/);
40559
40602
  }
40560
40603
  function buildCiUrl(serverUrl, repository, githubRunId) {
40561
40604
  return `${serverUrl}/${repository}/actions/runs/${githubRunId}`;
@@ -41031,16 +41074,16 @@ function checkableIds(ids, types2) {
41031
41074
  });
41032
41075
  }
41033
41076
  function insideCheckout(cwd, path) {
41034
- const abs = (0, import_node_path10.resolve)(cwd, path);
41035
- const rel = (0, import_node_path10.relative)(cwd, abs);
41036
- return rel === "" || rel.startsWith("..") || (0, import_node_path10.isAbsolute)(rel) ? null : abs;
41077
+ const abs = (0, import_node_path11.resolve)(cwd, path);
41078
+ const rel = (0, import_node_path11.relative)(cwd, abs);
41079
+ return rel === "" || rel.startsWith("..") || (0, import_node_path11.isAbsolute)(rel) ? null : abs;
41037
41080
  }
41038
41081
  function writeForCheck(abs, content) {
41039
41082
  const original = (0, import_node_fs8.existsSync)(abs) ? (0, import_node_fs8.readFileSync)(abs) : null;
41040
41083
  const createdDirs = [];
41041
41084
  if (original === null) {
41042
41085
  const missing = [];
41043
- for (let d = (0, import_node_path10.dirname)(abs); !(0, import_node_fs8.existsSync)(d); d = (0, import_node_path10.dirname)(d)) missing.push(d);
41086
+ for (let d = (0, import_node_path11.dirname)(abs); !(0, import_node_fs8.existsSync)(d); d = (0, import_node_path11.dirname)(d)) missing.push(d);
41044
41087
  for (const d of missing.reverse()) {
41045
41088
  (0, import_node_fs8.mkdirSync)(d);
41046
41089
  createdDirs.push(d);
@@ -41067,7 +41110,8 @@ function restore(written) {
41067
41110
  }
41068
41111
  function untrackedFiles(cwd) {
41069
41112
  try {
41070
- const out2 = (0, import_node_child_process6.execFileSync)("git", ["ls-files", "--others", "--exclude-standard", "-z"], {
41113
+ const out2 = (0, import_node_child_process6.execFileSync)("git", [...NO_HOOKS_ARGS, "ls-files", "--others", "--exclude-standard", "-z"], {
41114
+ env: gitEnv(),
41071
41115
  cwd,
41072
41116
  encoding: "utf8",
41073
41117
  stdio: ["ignore", "pipe", "ignore"],
@@ -41203,11 +41247,11 @@ var CONFIG_FILES = ["vitest.config.ts", "vitest.config.mts", "vitest.config.cts"
41203
41247
  var WORKSPACE_IN_CONFIG = /\b(?:workspace|projects)\s*:/;
41204
41248
  function defaultResolveVitest(cwd) {
41205
41249
  try {
41206
- const pkgPath = (0, import_node_module.createRequire)((0, import_node_path11.join)(cwd, "package.json")).resolve("vitest/package.json");
41250
+ const pkgPath = (0, import_node_module.createRequire)((0, import_node_path12.join)(cwd, "package.json")).resolve("vitest/package.json");
41207
41251
  const pkg = JSON.parse((0, import_node_fs9.readFileSync)(pkgPath, "utf8"));
41208
41252
  const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.vitest;
41209
41253
  if (typeof rel !== "string" || typeof pkg.version !== "string") return null;
41210
- return { bin: forward((0, import_node_path11.join)((0, import_node_path11.dirname)(pkgPath), rel)), version: pkg.version };
41254
+ return { bin: forward((0, import_node_path12.join)((0, import_node_path12.dirname)(pkgPath), rel)), version: pkg.version };
41211
41255
  } catch {
41212
41256
  return null;
41213
41257
  }
@@ -41252,9 +41296,9 @@ function detectAdapter(i3) {
41252
41296
  const parsed = parseTestInvocation(rest);
41253
41297
  if ("off" in parsed) return parsed;
41254
41298
  if (parsed.flags.some((f) => !ALLOWED_FLAG.test(f))) return { off: "extra_flags" };
41255
- const cwd = folder ? import_node_path11.posix.join(forward(i3.root), folder) : forward(i3.root);
41299
+ const cwd = folder ? import_node_path12.posix.join(forward(i3.root), folder) : forward(i3.root);
41256
41300
  if (parsed.viaScript) {
41257
- const pkgText = i3.readText(import_node_path11.posix.join(cwd, "package.json"));
41301
+ const pkgText = i3.readText(import_node_path12.posix.join(cwd, "package.json"));
41258
41302
  let script = "";
41259
41303
  try {
41260
41304
  const scripts = JSON.parse(pkgText ?? "{}").scripts;
@@ -41265,9 +41309,9 @@ function detectAdapter(i3) {
41265
41309
  if (!/\bvitest\b/.test(script)) return { off: "not_vitest" };
41266
41310
  if (!PLAIN_VITEST_SCRIPT.test(script)) return { off: "script_not_plain" };
41267
41311
  }
41268
- if (WORKSPACE_FILES.some((f) => i3.exists(import_node_path11.posix.join(cwd, f)))) return { off: "workspace_config" };
41312
+ if (WORKSPACE_FILES.some((f) => i3.exists(import_node_path12.posix.join(cwd, f)))) return { off: "workspace_config" };
41269
41313
  for (const f of CONFIG_FILES) {
41270
- const text3 = i3.exists(import_node_path11.posix.join(cwd, f)) ? i3.readText(import_node_path11.posix.join(cwd, f)) : null;
41314
+ const text3 = i3.exists(import_node_path12.posix.join(cwd, f)) ? i3.readText(import_node_path12.posix.join(cwd, f)) : null;
41271
41315
  if (text3 !== null && WORKSPACE_IN_CONFIG.test(text3)) return { off: "workspace_config" };
41272
41316
  }
41273
41317
  const found = (i3.resolveVitest ?? defaultResolveVitest)(cwd);
@@ -41290,7 +41334,7 @@ var TEST_FILE_NAME = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
41290
41334
  function forceFullReason(paths, setupFiles = []) {
41291
41335
  for (const raw of paths) {
41292
41336
  const p = forward(raw);
41293
- const base = import_node_path11.posix.basename(p);
41337
+ const base = import_node_path12.posix.basename(p);
41294
41338
  if (base === "package.json" || base === "npm-shrinkwrap.json") return "package_manifest";
41295
41339
  if (/^(?:package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?)$/.test(base)) return "lock_file";
41296
41340
  if (/^[jt]sconfig(?:\.[\w.-]+)?\.json$/.test(base)) return "ts_config";
@@ -41308,7 +41352,7 @@ function setupFilesOf(configText, folderRel) {
41308
41352
  for (const m of configText.matchAll(list2)) {
41309
41353
  for (const s of (m[1] ?? "").matchAll(/["']([^"']+)["']/g)) {
41310
41354
  const rel = forward(s[1] ?? "").replace(/^\.\//, "");
41311
- if (rel) out2.push(import_node_path11.posix.join(folderRel, rel));
41355
+ if (rel) out2.push(import_node_path12.posix.join(folderRel, rel));
41312
41356
  }
41313
41357
  }
41314
41358
  return out2;
@@ -41343,7 +41387,7 @@ function fsReadingTests(i3) {
41343
41387
  }
41344
41388
 
41345
41389
  // src/tsconfigPaths.ts
41346
- var import_node_path12 = require("node:path");
41390
+ var import_node_path13 = require("node:path");
41347
41391
  var MAX_EXTENDS_DEPTH = 5;
41348
41392
  function parseJsonc(text3) {
41349
41393
  let out2 = "";
@@ -41389,12 +41433,12 @@ function resolveConfig(readText, file, depth, seen) {
41389
41433
  if (typeof text3 !== "string") return null;
41390
41434
  const json = parseJsonc(text3);
41391
41435
  if (!isObject(json)) return null;
41392
- const dir = import_node_path12.posix.dirname(file) === "." ? "" : import_node_path12.posix.dirname(file);
41436
+ const dir = import_node_path13.posix.dirname(file) === "." ? "" : import_node_path13.posix.dirname(file);
41393
41437
  let inherited = { paths: null, pathsDir: dir, baseUrl: null };
41394
41438
  const ext = typeof json.extends === "string" ? [json.extends] : stringList(json.extends);
41395
41439
  for (const e of ext) {
41396
41440
  if (!e.startsWith(".")) continue;
41397
- const parent = resolveConfig(readText, import_node_path12.posix.normalize(import_node_path12.posix.join(dir, e.endsWith(".json") ? e : `${e}.json`)), depth + 1, seen);
41441
+ const parent = resolveConfig(readText, import_node_path13.posix.normalize(import_node_path13.posix.join(dir, e.endsWith(".json") ? e : `${e}.json`)), depth + 1, seen);
41398
41442
  if (parent) {
41399
41443
  inherited = {
41400
41444
  paths: parent.paths ?? inherited.paths,
@@ -41404,7 +41448,7 @@ function resolveConfig(readText, file, depth, seen) {
41404
41448
  }
41405
41449
  }
41406
41450
  const co = isObject(json.compilerOptions) ? json.compilerOptions : {};
41407
- const baseUrl = typeof co.baseUrl === "string" ? import_node_path12.posix.normalize(import_node_path12.posix.join(dir, co.baseUrl)) : inherited.baseUrl;
41451
+ const baseUrl = typeof co.baseUrl === "string" ? import_node_path13.posix.normalize(import_node_path13.posix.join(dir, co.baseUrl)) : inherited.baseUrl;
41408
41452
  let paths = inherited.paths;
41409
41453
  let pathsDir = inherited.pathsDir;
41410
41454
  if (isObject(co.paths)) {
@@ -41434,7 +41478,7 @@ function aliasTable(opts) {
41434
41478
  if (!config?.paths) return [];
41435
41479
  const lines = [];
41436
41480
  for (const [key, targets] of Object.entries(config.paths)) {
41437
- const resolved = targets.map((t) => import_node_path12.posix.normalize(import_node_path12.posix.join(config.baseUrl ?? config.pathsDir, t))).filter((p) => p !== ".." && !p.startsWith("../") && !import_node_path12.posix.isAbsolute(p));
41481
+ const resolved = targets.map((t) => import_node_path13.posix.normalize(import_node_path13.posix.join(config.baseUrl ?? config.pathsDir, t))).filter((p) => p !== ".." && !p.startsWith("../") && !import_node_path13.posix.isAbsolute(p));
41438
41482
  if (resolved.length > 0) lines.push(`${key} -> ${resolved.join(", ")}`);
41439
41483
  }
41440
41484
  return lines.sort().slice(0, opts.max ?? 20);
@@ -41461,7 +41505,7 @@ function createAliasMapper(opts) {
41461
41505
  };
41462
41506
  return (fromPath, specifier) => {
41463
41507
  if (specifier.startsWith(".") || specifier.startsWith("/")) return null;
41464
- const dir = import_node_path12.posix.dirname(fromPath) === "." ? "" : import_node_path12.posix.dirname(fromPath);
41508
+ const dir = import_node_path13.posix.dirname(fromPath) === "." ? "" : import_node_path13.posix.dirname(fromPath);
41465
41509
  const config = configFor(dir);
41466
41510
  if (!config?.paths) return null;
41467
41511
  let best = null;
@@ -41472,8 +41516,8 @@ function createAliasMapper(opts) {
41472
41516
  if (!best) return null;
41473
41517
  const bases = [];
41474
41518
  for (const target of config.paths[best.key]) {
41475
- const joined = import_node_path12.posix.normalize(import_node_path12.posix.join(config.baseUrl ?? config.pathsDir, target.replace("*", best.captured)));
41476
- if (joined === ".." || joined.startsWith("../") || import_node_path12.posix.isAbsolute(joined)) continue;
41519
+ const joined = import_node_path13.posix.normalize(import_node_path13.posix.join(config.baseUrl ?? config.pathsDir, target.replace("*", best.captured)));
41520
+ if (joined === ".." || joined.startsWith("../") || import_node_path13.posix.isAbsolute(joined)) continue;
41477
41521
  if (opts.writeRoot !== "" && !matchesPrefix(joined, opts.writeRoot)) continue;
41478
41522
  bases.push(joined === "." ? "" : joined);
41479
41523
  }
@@ -41527,7 +41571,7 @@ function createRelatedPlanner(d) {
41527
41571
  const exists = d.exists ?? import_node_fs10.existsSync;
41528
41572
  const mode = (env2.QUIKPILOT_RELATED_TESTS ?? "").trim().toLowerCase();
41529
41573
  const minMs = minBaselineMs(env2);
41530
- const abs = (rel) => forward2((0, import_node_path13.join)(d.root, rel));
41574
+ const abs = (rel) => forward2((0, import_node_path14.join)(d.root, rel));
41531
41575
  const isTest = testRule(d.discoveredTests ?? null);
41532
41576
  let detected = null;
41533
41577
  let setupFiles = [];
@@ -41539,9 +41583,9 @@ function createRelatedPlanner(d) {
41539
41583
  function detect() {
41540
41584
  const found = detectAdapter({ command: d.command, root: forward2(d.root), readText, exists, resolveVitest: d.resolveVitest });
41541
41585
  if ("adapter" in found) {
41542
- const folder = forward2((0, import_node_path13.relative)(d.root, found.adapter.cwd));
41586
+ const folder = forward2((0, import_node_path14.relative)(d.root, found.adapter.cwd));
41543
41587
  for (const name2 of CONFIG_FILES) {
41544
- const text3 = exists(import_node_path13.posix.join(found.adapter.cwd, name2)) ? readText(import_node_path13.posix.join(found.adapter.cwd, name2)) : null;
41588
+ const text3 = exists(import_node_path14.posix.join(found.adapter.cwd, name2)) ? readText(import_node_path14.posix.join(found.adapter.cwd, name2)) : null;
41545
41589
  if (text3 !== null) setupFiles.push(...setupFilesOf(text3, folder));
41546
41590
  }
41547
41591
  log({ event: "related.adapter", adapter: found.adapter.kind, version: found.adapter.version });
@@ -41597,7 +41641,7 @@ function createRelatedPlanner(d) {
41597
41641
  const testFiles = unique([...changed.filter((p) => isTest(p)), ...importersOf(changed), ...alwaysRun]).slice(0, MAX_FALLBACK_TESTS).map(abs);
41598
41642
  runNumber += 1;
41599
41643
  const stamp = `${process.pid}-${runNumber}`;
41600
- const dir = forward2((d.tmp ?? (() => env2.RUNNER_TEMP?.trim() || (0, import_node_os3.tmpdir)()))());
41644
+ const dir = forward2((d.tmp ?? (() => env2.RUNNER_TEMP?.trim() || (0, import_node_os4.tmpdir)()))());
41601
41645
  const report = `${dir}/qp-related-${stamp}.xml`;
41602
41646
  const fallbackReport = `${dir}/qp-related-${stamp}-files.xml`;
41603
41647
  return {
@@ -41783,7 +41827,7 @@ function spendSoFar() {
41783
41827
 
41784
41828
  // src/codegen.ts
41785
41829
  var import_node_fs11 = require("node:fs");
41786
- var import_node_path14 = require("node:path");
41830
+ var import_node_path15 = require("node:path");
41787
41831
 
41788
41832
  // src/envelope.ts
41789
41833
  var HARD_FAILURE_CODES = /* @__PURE__ */ new Set(["SEMANTIC_MISMATCH", "CONTRACT_REJECTED"]);
@@ -41865,9 +41909,9 @@ function countRemovedLines(currentContent, newContent) {
41865
41909
  }
41866
41910
  let removed = 0;
41867
41911
  for (const line2 of currentContent.split("\n")) {
41868
- const count3 = remaining.get(line2) ?? 0;
41869
- if (count3 > 0) {
41870
- remaining.set(line2, count3 - 1);
41912
+ const count4 = remaining.get(line2) ?? 0;
41913
+ if (count4 > 0) {
41914
+ remaining.set(line2, count4 - 1);
41871
41915
  } else {
41872
41916
  removed++;
41873
41917
  }
@@ -42201,6 +42245,11 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
42201
42245
  })
42202
42246
  );
42203
42247
  }
42248
+ if (addedMarkers(newContent, currentContent) > 0) {
42249
+ throw new Error(
42250
+ `Codegen output for ${target.path} holds a placeholder the AI service put in place of a long number (such as [ACCOUNT_REDACTED]) \u2014 refusing to apply it.`
42251
+ );
42252
+ }
42204
42253
  if (!isNewFile) {
42205
42254
  const suspectReason = looksLikeTruncatedRewrite(target, currentContent, newContent);
42206
42255
  if (suspectReason) {
@@ -42225,7 +42274,7 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
42225
42274
  }
42226
42275
  function flushCodegenResults(results) {
42227
42276
  for (const { targetPath, newContent } of results) {
42228
- (0, import_node_fs11.mkdirSync)((0, import_node_path14.dirname)(targetPath), { recursive: true });
42277
+ (0, import_node_fs11.mkdirSync)((0, import_node_path15.dirname)(targetPath), { recursive: true });
42229
42278
  (0, import_node_fs11.writeFileSync)(targetPath, newContent);
42230
42279
  }
42231
42280
  }
@@ -42271,22 +42320,23 @@ function callFunctionEnabled(githubRepository, mode, env2 = process.env) {
42271
42320
 
42272
42321
  // src/callFunctionTool.ts
42273
42322
  var import_node_crypto4 = require("node:crypto");
42274
- var import_node_path18 = require("node:path");
42323
+ var import_node_path19 = require("node:path");
42275
42324
 
42276
42325
  // src/overlayOnDisk.ts
42277
42326
  var import_node_child_process8 = require("node:child_process");
42278
42327
  var import_node_fs13 = require("node:fs");
42279
- var import_node_path16 = require("node:path");
42328
+ var import_node_path17 = require("node:path");
42280
42329
 
42281
42330
  // src/treeFingerprint.ts
42282
42331
  var import_node_crypto2 = require("node:crypto");
42283
42332
  var import_node_child_process7 = require("node:child_process");
42284
42333
  var import_node_fs12 = require("node:fs");
42285
- var import_node_path15 = require("node:path");
42334
+ var import_node_path16 = require("node:path");
42286
42335
  var MAX_HASHED_BYTES = 8 * 1024 * 1024;
42287
42336
  function defaultGitStatus(root) {
42288
42337
  try {
42289
- return (0, import_node_child_process7.execFileSync)("git", ["status", "--porcelain=v1", "-z", "--untracked-files=all"], {
42338
+ return (0, import_node_child_process7.execFileSync)("git", [...NO_HOOKS_ARGS, "status", "--porcelain=v1", "-z", "--untracked-files=all"], {
42339
+ env: gitEnv(),
42290
42340
  cwd: root,
42291
42341
  encoding: "utf8",
42292
42342
  stdio: ["ignore", "pipe", "ignore"],
@@ -42310,7 +42360,7 @@ function parseStatus(raw) {
42310
42360
  return raw.split("\0").filter((t) => t.length > 0).sort();
42311
42361
  }
42312
42362
  function hashOf(root, rel) {
42313
- const abs = (0, import_node_path15.join)(root, rel);
42363
+ const abs = (0, import_node_path16.join)(root, rel);
42314
42364
  let st;
42315
42365
  try {
42316
42366
  st = (0, import_node_fs12.lstatSync)(abs);
@@ -42375,24 +42425,24 @@ var DiskWriteRefused = class extends Error {
42375
42425
  };
42376
42426
  function safeRelativePath(rel) {
42377
42427
  if (typeof rel !== "string" || rel.length === 0 || rel.length > 400 || rel.includes("\0") || rel.includes("\\")) return null;
42378
- if ((0, import_node_path16.isAbsolute)(rel) || /^[A-Za-z]:/.test(rel)) return null;
42428
+ if ((0, import_node_path17.isAbsolute)(rel) || /^[A-Za-z]:/.test(rel)) return null;
42379
42429
  const parts2 = rel.split("/");
42380
42430
  if (parts2.some((p) => p === "" || p === "." || p === "..")) return null;
42381
42431
  return rel;
42382
42432
  }
42383
42433
  function isInside(root, abs) {
42384
- const r = (0, import_node_path16.relative)(root, abs);
42385
- return r !== "" && !r.startsWith("..") && !(0, import_node_path16.isAbsolute)(r);
42434
+ const r = (0, import_node_path17.relative)(root, abs);
42435
+ return r !== "" && !r.startsWith("..") && !(0, import_node_path17.isAbsolute)(r);
42386
42436
  }
42387
42437
  function ancestorInside(realRoot, abs) {
42388
- let dir = (0, import_node_path16.dirname)(abs);
42438
+ let dir = (0, import_node_path17.dirname)(abs);
42389
42439
  for (; ; ) {
42390
42440
  try {
42391
42441
  const real = (0, import_node_fs13.realpathSync)(dir);
42392
- const r = (0, import_node_path16.relative)(realRoot, real);
42393
- return r === "" || !r.startsWith("..") && !(0, import_node_path16.isAbsolute)(r);
42442
+ const r = (0, import_node_path17.relative)(realRoot, real);
42443
+ return r === "" || !r.startsWith("..") && !(0, import_node_path17.isAbsolute)(r);
42394
42444
  } catch {
42395
- const up = (0, import_node_path16.dirname)(dir);
42445
+ const up = (0, import_node_path17.dirname)(dir);
42396
42446
  if (up === dir) return false;
42397
42447
  dir = up;
42398
42448
  }
@@ -42405,7 +42455,7 @@ function applyOverlay(root, files) {
42405
42455
  const restore2 = () => {
42406
42456
  const failed = [];
42407
42457
  for (const w of [...written].reverse()) {
42408
- const rel = (0, import_node_path16.relative)(root, w.abs).split("\\").join("/");
42458
+ const rel = (0, import_node_path17.relative)(root, w.abs).split("\\").join("/");
42409
42459
  try {
42410
42460
  if (w.original !== null) (0, import_node_fs13.writeFileSync)(w.abs, w.original);
42411
42461
  else (0, import_node_fs13.rmSync)(w.abs, { force: true });
@@ -42428,7 +42478,7 @@ function applyOverlay(root, files) {
42428
42478
  if (rel === null) throw new DiskWriteRefused("bad_path");
42429
42479
  if (seen.has(rel)) throw new DiskWriteRefused("duplicate");
42430
42480
  seen.add(rel);
42431
- const abs = (0, import_node_path16.resolve)(root, rel);
42481
+ const abs = (0, import_node_path17.resolve)(root, rel);
42432
42482
  if (!isInside(root, abs) || !ancestorInside(realRoot, abs)) throw new DiskWriteRefused("outside_checkout");
42433
42483
  let original = null;
42434
42484
  try {
@@ -42442,7 +42492,7 @@ function applyOverlay(root, files) {
42442
42492
  const createdDirs = [];
42443
42493
  if (original === null) {
42444
42494
  const missing = [];
42445
- for (let d = (0, import_node_path16.dirname)(abs); !(0, import_node_fs13.existsSync)(d); d = (0, import_node_path16.dirname)(d)) missing.push(d);
42495
+ for (let d = (0, import_node_path17.dirname)(abs); !(0, import_node_fs13.existsSync)(d); d = (0, import_node_path17.dirname)(d)) missing.push(d);
42446
42496
  for (const d of missing.reverse()) {
42447
42497
  (0, import_node_fs13.mkdirSync)(d);
42448
42498
  createdDirs.push(d);
@@ -42459,7 +42509,7 @@ function applyOverlay(root, files) {
42459
42509
  return { restore: restore2 };
42460
42510
  }
42461
42511
  function git2(root, args2) {
42462
- (0, import_node_child_process8.execFileSync)("git", args2, { cwd: root, stdio: ["ignore", "ignore", "ignore"] });
42512
+ (0, import_node_child_process8.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], { env: gitEnv(), cwd: root, stdio: ["ignore", "ignore", "ignore"] });
42463
42513
  }
42464
42514
  function cleanUpAfterRun(root, beforePaths, afterStatus) {
42465
42515
  for (const token of afterStatus) {
@@ -42469,8 +42519,8 @@ function cleanUpAfterRun(root, beforePaths, afterStatus) {
42469
42519
  const code = entryCode(token);
42470
42520
  try {
42471
42521
  if (code === "??") {
42472
- (0, import_node_fs13.rmSync)((0, import_node_path16.join)(root, p), { recursive: true, force: true });
42473
- for (let d = (0, import_node_path16.dirname)((0, import_node_path16.join)(root, p)); d !== root && isInside(root, d); d = (0, import_node_path16.dirname)(d)) {
42522
+ (0, import_node_fs13.rmSync)((0, import_node_path17.join)(root, p), { recursive: true, force: true });
42523
+ for (let d = (0, import_node_path17.dirname)((0, import_node_path17.join)(root, p)); d !== root && isInside(root, d); d = (0, import_node_path17.dirname)(d)) {
42474
42524
  try {
42475
42525
  (0, import_node_fs13.rmdirSync)(d);
42476
42526
  } catch {
@@ -42490,7 +42540,7 @@ function snapshotPreserved(root, paths) {
42490
42540
  const out2 = [];
42491
42541
  for (const rel of paths ?? []) {
42492
42542
  if (safeRelativePath(rel) === null) continue;
42493
- const abs = (0, import_node_path16.resolve)(root, rel);
42543
+ const abs = (0, import_node_path17.resolve)(root, rel);
42494
42544
  try {
42495
42545
  const st = (0, import_node_fs13.lstatSync)(abs);
42496
42546
  if (st.isSymbolicLink() || !st.isFile()) continue;
@@ -42558,7 +42608,7 @@ function undoableFlush(root, results, flush, options = {}) {
42558
42608
  const beforePaths = new Set((before?.status ?? []).filter(isStatusEntry).map(entryPath));
42559
42609
  for (const p of ignore) beforePaths.add(p);
42560
42610
  const originals = rels.map((rel) => {
42561
- const abs = (0, import_node_path16.resolve)(root, rel);
42611
+ const abs = (0, import_node_path17.resolve)(root, rel);
42562
42612
  let original = null;
42563
42613
  try {
42564
42614
  const st = (0, import_node_fs13.lstatSync)(abs);
@@ -42569,7 +42619,7 @@ function undoableFlush(root, results, flush, options = {}) {
42569
42619
  const createdDirs = [];
42570
42620
  if (original === null) {
42571
42621
  const missing = [];
42572
- for (let d = (0, import_node_path16.dirname)(abs); !(0, import_node_fs13.existsSync)(d) && isInside(root, d); d = (0, import_node_path16.dirname)(d)) missing.push(d);
42622
+ for (let d = (0, import_node_path17.dirname)(abs); !(0, import_node_fs13.existsSync)(d) && isInside(root, d); d = (0, import_node_path17.dirname)(d)) missing.push(d);
42573
42623
  createdDirs.push(...missing.reverse());
42574
42624
  }
42575
42625
  return { rel, abs, original, createdDirs };
@@ -42625,7 +42675,7 @@ function undoableFlush(root, results, flush, options = {}) {
42625
42675
  // src/runTestsTool.ts
42626
42676
  var import_node_crypto3 = require("node:crypto");
42627
42677
  var import_node_fs14 = require("node:fs");
42628
- var import_node_path17 = require("node:path");
42678
+ var import_node_path18 = require("node:path");
42629
42679
  var scrubSecrets2 = (text3) => scrubForModel(text3, [], "code").text;
42630
42680
  var RUN_TESTS_TOOL = "run_tests";
42631
42681
  var MAX_TEST_RUNS = 3;
@@ -42936,7 +42986,7 @@ var RunTestsTool = class {
42936
42986
  const runCommand2 = d.runCommand ?? runTestCommandWithLimit;
42937
42987
  const readSnapshot = d.readSnapshot ?? readTestSnapshot;
42938
42988
  const reportBefore = findReport(d.root);
42939
- const preserve = reportBefore ? [(0, import_node_path17.relative)(d.root, reportBefore).split("\\").join("/")] : [];
42989
+ const preserve = reportBefore ? [(0, import_node_path18.relative)(d.root, reportBefore).split("\\").join("/")] : [];
42940
42990
  const spend = (n) => {
42941
42991
  if (file === void 0) this.runs += n;
42942
42992
  else this.fileRuns += n;
@@ -43287,7 +43337,7 @@ var CallFunctionTool = class {
43287
43337
  const now = d.now ?? Date.now;
43288
43338
  const helper = {
43289
43339
  path: `.quikpilot-call-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.mjs`,
43290
- content: helperSource({ target: (0, import_node_path18.join)(d.root, parsed.path), exportName: parsed.exportName, args: parsed.callArgs })
43340
+ content: helperSource({ target: (0, import_node_path19.join)(d.root, parsed.path), exportName: parsed.exportName, args: parsed.callArgs })
43291
43341
  };
43292
43342
  const run3 = d.run ?? runCapturedCommand;
43293
43343
  this.calls += 1;
@@ -43297,7 +43347,7 @@ var CallFunctionTool = class {
43297
43347
  captured = await withOverlayOnDisk(
43298
43348
  d.root,
43299
43349
  [...files, helper],
43300
- () => run3([d.nodePath ?? process.execPath, (0, import_node_path18.join)(d.root, helper.path)], { cwd: d.root, timeoutMs: d.timeoutMs ?? CALL_TIMEOUT_MS, maxStdoutBytes: MAX_STDOUT_BYTES }),
43350
+ () => run3([d.nodePath ?? process.execPath, (0, import_node_path19.join)(d.root, helper.path)], { cwd: d.root, timeoutMs: d.timeoutMs ?? CALL_TIMEOUT_MS, maxStdoutBytes: MAX_STDOUT_BYTES }),
43301
43351
  { ...d.tree }
43302
43352
  );
43303
43353
  } catch (err2) {
@@ -43525,7 +43575,7 @@ var CodegenAttemptsExhausted = class extends Error {
43525
43575
  }
43526
43576
  };
43527
43577
  var RULE_SHAPE = /^[a-z][a-z0-9_]{0,39}$/;
43528
- function count(n) {
43578
+ function count2(n) {
43529
43579
  return typeof n === "number" && Number.isInteger(n) ? Math.min(MAX_PREVIOUS_COUNT, Math.max(0, n)) : 0;
43530
43580
  }
43531
43581
  function isRecord(x) {
@@ -43537,12 +43587,12 @@ function testRunFrom(answer) {
43537
43587
  if (!numbers.every((k) => typeof answer[k] === "number") || !Array.isArray(answer.failingTests)) return void 0;
43538
43588
  const failingTests = answer.failingTests.filter((n) => typeof n === "string").map((n) => n.slice(0, MAX_PREVIOUS_NAME_CHARS)).filter((n) => n.length > 0).slice(0, MAX_PREVIOUS_TESTS);
43539
43589
  const run3 = {
43540
- passed: count(answer.passed),
43541
- failed: count(answer.failed),
43542
- total: count(answer.total),
43543
- regressions: count(answer.regressions),
43544
- newFailures: count(answer.newFailures),
43545
- alreadyFailing: count(answer.alreadyFailing),
43590
+ passed: count2(answer.passed),
43591
+ failed: count2(answer.failed),
43592
+ total: count2(answer.total),
43593
+ regressions: count2(answer.regressions),
43594
+ newFailures: count2(answer.newFailures),
43595
+ alreadyFailing: count2(answer.alreadyFailing),
43546
43596
  failingTests
43547
43597
  };
43548
43598
  if (isRecord(answer.messages)) {
@@ -43737,11 +43787,11 @@ function foldersAbove(path) {
43737
43787
  function makeGuidanceFinder(i3) {
43738
43788
  const given = new Set(i3.alreadyShown ?? []);
43739
43789
  const done = new Set([...given].map((p) => p.slice(0, Math.max(0, p.lastIndexOf("/")))));
43740
- let count3 = 0;
43790
+ let count4 = 0;
43741
43791
  return {
43742
- shown: () => count3,
43792
+ shown: () => count4,
43743
43793
  forRead(path) {
43744
- if (count3 >= GUIDANCE_PER_RUN) return void 0;
43794
+ if (count4 >= GUIDANCE_PER_RUN) return void 0;
43745
43795
  for (const folder of foldersAbove(path)) {
43746
43796
  if (done.has(folder)) continue;
43747
43797
  for (const name2 of GUIDANCE_NAMES) {
@@ -43753,7 +43803,7 @@ function makeGuidanceFinder(i3) {
43753
43803
  const text3 = cutText2((i3.scrub ? i3.scrub(raw) : raw).trim(), GUIDANCE_TEXT_CHARS);
43754
43804
  if (text3.length === 0) continue;
43755
43805
  done.add(folder);
43756
- count3 += 1;
43806
+ count4 += 1;
43757
43807
  return { path: candidate, text: text3 };
43758
43808
  }
43759
43809
  }
@@ -47465,6 +47515,7 @@ function createCodegenWorkspace(args2) {
47465
47515
  }
47466
47516
  const find = a.find;
47467
47517
  const replace = a.replace;
47518
+ if (addedMarkers(replace, find) > 0) return refused("redacted_text", REDACTED_TEXT_MESSAGE);
47468
47519
  return {
47469
47520
  key: JSON.stringify({ path, find, replace }),
47470
47521
  exec: () => {
@@ -47544,6 +47595,7 @@ function createCodegenWorkspace(args2) {
47544
47595
  for (const p of env3.listing) if (p.startsWith(`${path}/`)) return refused("is_directory", "That path is not allowed.");
47545
47596
  if (!baseFs.parentInside(path)) return refused("outside_workspace", "That path is not allowed.");
47546
47597
  const content = a.content;
47598
+ if (addedMarkers(content, overlay.get(path)?.lf ?? "") > 0) return refused("redacted_text", REDACTED_TEXT_MESSAGE);
47547
47599
  return {
47548
47600
  key: JSON.stringify({ path, content }),
47549
47601
  exec: () => {
@@ -47707,7 +47759,7 @@ function createCodegenWorkspace(args2) {
47707
47759
 
47708
47760
  // src/scratchRunTool.ts
47709
47761
  var import_node_fs15 = require("node:fs");
47710
- var import_node_path19 = require("node:path");
47762
+ var import_node_path20 = require("node:path");
47711
47763
  var RUN_SCRATCH_TOOL = "run_scratch";
47712
47764
  var MAX_SCRATCH_TEXT_CHARS = 2e3;
47713
47765
  var MAX_SCRATCH_CONTENT_CHARS = 8e3;
@@ -47793,10 +47845,10 @@ var ScratchRunTool = class {
47793
47845
  if (matchesDeniedPath(path, d.deniedPaths) !== null) return false;
47794
47846
  if (!testRule(d.discoveredTests)(path)) return false;
47795
47847
  if (d.protectedTestPaths.includes(path) || d.listing.includes(path) || files.some((f) => f.path === path)) return false;
47796
- const abs = (0, import_node_path19.join)(d.root, path);
47848
+ const abs = (0, import_node_path20.join)(d.root, path);
47797
47849
  if ((0, import_node_fs15.existsSync)(abs)) return false;
47798
47850
  try {
47799
- return (0, import_node_fs15.statSync)((0, import_node_path19.dirname)(abs)).isDirectory();
47851
+ return (0, import_node_fs15.statSync)((0, import_node_path20.dirname)(abs)).isDirectory();
47800
47852
  } catch {
47801
47853
  return false;
47802
47854
  }
@@ -47835,7 +47887,7 @@ var ScratchRunTool = class {
47835
47887
  const run3 = d.run ?? runShellCaptured;
47836
47888
  const command = buildSingleFileCommand(fileCommand, parsed.path);
47837
47889
  const reportBefore = (d.findReport ?? findJUnitReport)(d.root);
47838
- const preserve = reportBefore ? [(0, import_node_path19.relative)(d.root, reportBefore).split("\\").join("/")] : [];
47890
+ const preserve = reportBefore ? [(0, import_node_path20.relative)(d.root, reportBefore).split("\\").join("/")] : [];
47839
47891
  this.calls += 1;
47840
47892
  const startedAt = now();
47841
47893
  let ran;
@@ -47882,7 +47934,7 @@ var MAX_NOTE_CHARS = 500;
47882
47934
  var MAX_PATH_CHARS3 = 300;
47883
47935
  var MAX_REASON_CHARS = 200;
47884
47936
  var isRecord2 = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
47885
- var count2 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5, Math.max(0, n)) : 0;
47937
+ var count3 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5, Math.max(0, n)) : 0;
47886
47938
  function callOf(call, result) {
47887
47939
  if (!result) return null;
47888
47940
  const args2 = isRecord2(call.args) ? call.args : {};
@@ -47892,7 +47944,7 @@ function callOf(call, result) {
47892
47944
  if (typeof result.reason === "string" && result.reason.length > 0) out2.reason = result.reason.slice(0, MAX_REASON_CHARS);
47893
47945
  const o = result.output;
47894
47946
  if (call.name === "run_tests" && isRecord2(o) && typeof o.passed === "number" && typeof o.failed === "number") {
47895
- out2.tests = { passed: count2(o.passed), failed: count2(o.failed), regressions: count2(o.regressions), newFailures: count2(o.newFailures) };
47947
+ out2.tests = { passed: count3(o.passed), failed: count3(o.failed), regressions: count3(o.regressions), newFailures: count3(o.newFailures) };
47896
47948
  if (o.scope === "file") out2.scope = "file";
47897
47949
  }
47898
47950
  return out2;
@@ -48287,7 +48339,7 @@ var TargetingHttpError = class extends Error {
48287
48339
  // src/dataPathCheck.ts
48288
48340
  var import_node_child_process9 = require("node:child_process");
48289
48341
  var import_node_fs17 = require("node:fs");
48290
- var import_node_path20 = require("node:path");
48342
+ var import_node_path21 = require("node:path");
48291
48343
 
48292
48344
  // src/scopeCheck.ts
48293
48345
  var import_node_fs16 = require("node:fs");
@@ -48432,7 +48484,7 @@ function addressMatches(route, call) {
48432
48484
  }
48433
48485
  var git3 = (cwd, args2) => {
48434
48486
  try {
48435
- return (0, import_node_child_process9.execFileSync)("git", args2, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: GIT_TIMEOUT_MS2, maxBuffer: GIT_MAX_BUFFER3 });
48487
+ return (0, import_node_child_process9.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], { env: gitEnv(), cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: GIT_TIMEOUT_MS2, maxBuffer: GIT_MAX_BUFFER3 });
48436
48488
  } catch {
48437
48489
  return "";
48438
48490
  }
@@ -48519,7 +48571,7 @@ function screenLoaders(cwd, screen, read, skip, expired) {
48519
48571
  function readFromCheckout(root) {
48520
48572
  return (path) => {
48521
48573
  try {
48522
- const abs = (0, import_node_path20.join)(root, path);
48574
+ const abs = (0, import_node_path21.join)(root, path);
48523
48575
  const st = (0, import_node_fs17.lstatSync)(abs);
48524
48576
  return st.isSymbolicLink() || !st.isFile() || st.size > MAX_FILE_CHARS2 ? null : (0, import_node_fs17.readFileSync)(abs, "utf8");
48525
48577
  } catch {
@@ -50170,7 +50222,7 @@ async function runCodegenLoop(args2, deps) {
50170
50222
  refused: ledger.refused,
50171
50223
  stopReason,
50172
50224
  reads: [...reads],
50173
- edits: [...ws.edits.entries()].map(([path, count3]) => ({ path, count: count3 })),
50225
+ edits: [...ws.edits.entries()].map(([path, count4]) => ({ path, count: count4 })),
50174
50226
  created: [...ws.created.entries()].map(([path, chars]) => ({ path, chars })),
50175
50227
  statusCounts: { ...statusCounts },
50176
50228
  syntaxWarnings: ws.syntaxWarnings,
@@ -50898,6 +50950,22 @@ async function runCodegenLoop(args2, deps) {
50898
50950
  }
50899
50951
  }
50900
50952
 
50953
+ // src/errorName.ts
50954
+ var NAME_SHAPE = /^[A-Z][A-Za-z0-9]{0,59}$/;
50955
+ var CODE_SHAPE = /^E[A-Z0-9_]{1,30}$/;
50956
+ function errorName(err2) {
50957
+ if (err2 === void 0) return "none";
50958
+ if (!(err2 instanceof Error)) return "other";
50959
+ const name2 = err2.name === "Error" ? err2.constructor?.name ?? err2.name : err2.name;
50960
+ return typeof name2 === "string" && NAME_SHAPE.test(name2) ? name2 : "other";
50961
+ }
50962
+ function internalCause(failure) {
50963
+ if (failure.reason !== "internal_error") return {};
50964
+ const cause = failure.cause;
50965
+ const code = cause instanceof Error ? cause.code : void 0;
50966
+ return { cause: errorName(cause), ...typeof code === "string" && CODE_SHAPE.test(code) ? { causeCode: code } : {} };
50967
+ }
50968
+
50901
50969
  // src/codegenPhases.ts
50902
50970
  var QP_TOKEN = /\[QP-[^\]\s]+\]/;
50903
50971
  function frozenFailingTarget(failingTests, frozen, textOf2) {
@@ -51011,7 +51079,7 @@ async function runPhases(i3) {
51011
51079
  } catch (err2) {
51012
51080
  const f = asFailure(err2);
51013
51081
  phases.push(record("tests", "failed", f.summary));
51014
- i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "tests", outcome: "failed", reason: f.reason });
51082
+ i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "tests", outcome: "failed", reason: f.reason, ...internalCause(f) });
51015
51083
  return { failure: recorded(f, "tests"), phases };
51016
51084
  }
51017
51085
  phases.push(record("tests", "finished", d1.summary, d1.redUnproven?.length));
@@ -51050,7 +51118,7 @@ async function runPhases(i3) {
51050
51118
  } catch (err2) {
51051
51119
  const f = asFailure(err2);
51052
51120
  phases.push(record("code", "failed", f.summary));
51053
- i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "failed", reason: f.reason });
51121
+ i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "code", outcome: "failed", reason: f.reason, ...internalCause(f) });
51054
51122
  return { failure: recorded(f, "code"), tests, phases };
51055
51123
  }
51056
51124
  summaries.push({ phase: "code", summary: d2.summary });
@@ -51081,7 +51149,7 @@ async function runPhases(i3) {
51081
51149
  } catch (err2) {
51082
51150
  const f = asFailure(err2);
51083
51151
  phases.push(record("amend", "failed", f.summary));
51084
- i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "failed", reason: f.reason });
51152
+ i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "failed", reason: f.reason, ...internalCause(f) });
51085
51153
  const disagree = new CodegenLoopFailure("test_case_disagree", void 0, f, `${amend.length} test file(s) and the approved cases still disagree`, f.told);
51086
51154
  disagree.summary = f.summary ?? d2.summary;
51087
51155
  return { failure: recorded(disagree, "amend"), tests, phases, final: true };
@@ -51144,7 +51212,7 @@ function mergePhaseSummaries(parts2, phases) {
51144
51212
  toolCalls: parts2.reduce((s, p) => s + p.summary.toolCalls, 0),
51145
51213
  refused: parts2.reduce((s, p) => s + p.summary.refused, 0),
51146
51214
  reads: parts2.flatMap((p) => p.summary.reads),
51147
- edits: [...edits.entries()].map(([path, count3]) => ({ path, count: count3 })),
51215
+ edits: [...edits.entries()].map(([path, count4]) => ({ path, count: count4 })),
51148
51216
  created: [...created.entries()].map(([path, chars]) => ({ path, chars })),
51149
51217
  statusCounts,
51150
51218
  syntaxWarnings: parts2.reduce((s, p) => s + (p.summary.syntaxWarnings ?? 0), 0),
@@ -51368,7 +51436,7 @@ function buildCodegenLoopRecord(loop) {
51368
51436
  var import_node_fs18 = require("node:fs");
51369
51437
 
51370
51438
  // src/langReach.ts
51371
- var import_node_path21 = require("node:path");
51439
+ var import_node_path22 = require("node:path");
51372
51440
  var LANGUAGE_BY_EXT = {
51373
51441
  ".go": "go",
51374
51442
  ".py": "python",
@@ -51384,7 +51452,7 @@ var LANGUAGE_BY_EXT = {
51384
51452
  ".swift": "swift"
51385
51453
  };
51386
51454
  function languageOf(path) {
51387
- return LANGUAGE_BY_EXT[import_node_path21.posix.extname(path).toLowerCase()] ?? null;
51455
+ return LANGUAGE_BY_EXT[import_node_path22.posix.extname(path).toLowerCase()] ?? null;
51388
51456
  }
51389
51457
  var MAX_REACH_TESTS = 10;
51390
51458
  var MAX_IMPORT_STEPS = 3;
@@ -51408,14 +51476,14 @@ function lookSymbolsOf(findings) {
51408
51476
  for (const c of findings.callPath) add2(c.path, c.symbol);
51409
51477
  return out2;
51410
51478
  }
51411
- var baseNoExt = (p) => import_node_path21.posix.basename(p).replace(/\.[^.]+$/, "");
51412
- var dirOf = (p) => import_node_path21.posix.dirname(p) === "." ? "" : import_node_path21.posix.dirname(p);
51479
+ var baseNoExt = (p) => import_node_path22.posix.basename(p).replace(/\.[^.]+$/, "");
51480
+ var dirOf = (p) => import_node_path22.posix.dirname(p) === "." ? "" : import_node_path22.posix.dirname(p);
51413
51481
  function testStem(path) {
51414
51482
  return baseNoExt(path).replace(/^test_/i, "").replace(/(_test|_spec)$/i, "").replace(/Tests?$/, "").toLowerCase();
51415
51483
  }
51416
51484
  function codeStem(path) {
51417
51485
  const b = baseNoExt(path);
51418
- if (b === "__init__" || b === "mod" || b === "index") return import_node_path21.posix.basename(dirOf(path)).toLowerCase();
51486
+ if (b === "__init__" || b === "mod" || b === "index") return import_node_path22.posix.basename(dirOf(path)).toLowerCase();
51419
51487
  return b.toLowerCase();
51420
51488
  }
51421
51489
  function sharedPrefix2(a, b) {
@@ -51498,7 +51566,7 @@ function buildIndex(files, readText) {
51498
51566
  }
51499
51567
  }
51500
51568
  let goModule = null;
51501
- const gomod = files.filter((f) => import_node_path21.posix.basename(f) === "go.mod").sort((a, b) => a.length - b.length)[0];
51569
+ const gomod = files.filter((f) => import_node_path22.posix.basename(f) === "go.mod").sort((a, b) => a.length - b.length)[0];
51502
51570
  if (gomod) {
51503
51571
  const m = /^module[ \t]+(\S+)/m.exec(readText(gomod) ?? "");
51504
51572
  if (m) goModule = { root: dirOf(gomod), module: m[1].replace(/^"|"$/g, "") };
@@ -51513,7 +51581,7 @@ function pythonImports(file, text3, ix) {
51513
51581
  const relative11 = (dots, rest) => {
51514
51582
  let base = dirOf(file);
51515
51583
  for (let i3 = 1; i3 < dots; i3++) base = dirOf(base);
51516
- const joined = rest ? import_node_path21.posix.join(base, rest.replace(/\./g, "/")) : base;
51584
+ const joined = rest ? import_node_path22.posix.join(base, rest.replace(/\./g, "/")) : base;
51517
51585
  return [`${joined}.py`, `${joined}/__init__.py`].filter((p) => ix.set.has(p) && p !== file);
51518
51586
  };
51519
51587
  for (const line2 of text3.split("\n")) {
@@ -51553,7 +51621,7 @@ function goImports(file, text3, ix) {
51553
51621
  let dir = null;
51554
51622
  if (ix.goModule && (p === ix.goModule.module || p.startsWith(`${ix.goModule.module}/`))) {
51555
51623
  const rest = p.slice(ix.goModule.module.length).replace(/^\//, "");
51556
- dir = ix.goModule.root ? import_node_path21.posix.join(ix.goModule.root, rest) : rest;
51624
+ dir = ix.goModule.root ? import_node_path22.posix.join(ix.goModule.root, rest) : rest;
51557
51625
  } else {
51558
51626
  const tail2 = p.split("/").slice(-2).join("/");
51559
51627
  for (const d of ix.byDir.keys()) if (d === tail2 || d.endsWith(`/${tail2}`)) {
@@ -51604,7 +51672,7 @@ function importsOf(language, file, text3, ix) {
51604
51672
  if (language === "jvm") return jvmImports(file, text3, ix);
51605
51673
  return [];
51606
51674
  }
51607
- var isPackageInit = (p) => import_node_path21.posix.basename(p) === "__init__.py";
51675
+ var isPackageInit = (p) => import_node_path22.posix.basename(p) === "__init__.py";
51608
51676
  function testsReaching(input) {
51609
51677
  const limit = Math.min(MAX_REACH_TESTS, Math.max(0, input.limit ?? MAX_REACH_TESTS));
51610
51678
  const listing = input.isDenied ? input.listing.filter((p) => !input.isDenied(p)) : [...input.listing];
@@ -51747,8 +51815,8 @@ function pairedTestPaths(codePath, listing, isTest = isTestTarget) {
51747
51815
  const stem = m[1].toLowerCase();
51748
51816
  const dir = dirOf2(codePath);
51749
51817
  const parent = parentOf(dir);
51750
- const join19 = (d, leaf) => d === "" ? leaf : `${d}/${leaf}`;
51751
- const homes = /* @__PURE__ */ new Set([dir, join19(dir, "__tests__"), join19(parent, "__tests__"), join19(parent, "tests"), join19(parent, "test")]);
51818
+ const join20 = (d, leaf) => d === "" ? leaf : `${d}/${leaf}`;
51819
+ const homes = /* @__PURE__ */ new Set([dir, join20(dir, "__tests__"), join20(parent, "__tests__"), join20(parent, "tests"), join20(parent, "test")]);
51752
51820
  const found = [];
51753
51821
  for (const path of listing) {
51754
51822
  if (!homes.has(dirOf2(path))) continue;
@@ -51929,7 +51997,7 @@ function mapModeMessage(phase, reason) {
51929
51997
 
51930
51998
  // src/testsToCheck.ts
51931
51999
  var import_node_fs19 = require("node:fs");
51932
- var import_node_path22 = require("node:path");
52000
+ var import_node_path23 = require("node:path");
51933
52001
  var MAX_TESTS_TO_CHECK = 10;
51934
52002
  var SECOND_HOP_BELOW = 3;
51935
52003
  function testsToCheck(i3) {
@@ -51980,7 +52048,7 @@ function testsToCheck(i3) {
51980
52048
  }
51981
52049
  var readFromRoot = (root) => (rel) => {
51982
52050
  try {
51983
- return (0, import_node_fs19.readFileSync)((0, import_node_path22.join)(root, rel), "utf8");
52051
+ return (0, import_node_fs19.readFileSync)((0, import_node_path23.join)(root, rel), "utf8");
51984
52052
  } catch {
51985
52053
  return null;
51986
52054
  }
@@ -52407,7 +52475,7 @@ async function runCodegenStep(p) {
52407
52475
  return finish(first.done);
52408
52476
  }
52409
52477
  const f1 = first.failure;
52410
- log({ event: "codegen.attempt_end", attempt: 1, outcome: "failed", reason: f1.reason, ...f1.afterRecovery ? { afterRecovery: true } : {}, turns: f1.summary?.turns ?? 0, toolCalls: f1.summary?.toolCalls ?? 0, durationMs: firstMs });
52478
+ log({ event: "codegen.attempt_end", attempt: 1, outcome: "failed", reason: f1.reason, ...internalCause(f1), ...f1.afterRecovery ? { afterRecovery: true } : {}, turns: f1.summary?.turns ?? 0, toolCalls: f1.summary?.toolCalls ?? 0, durationMs: firstMs });
52411
52479
  const said = f1.detail ? `: ${f1.detail}` : "";
52412
52480
  if (f1.reason === "contract_rejected" && f1.late !== true) {
52413
52481
  p.out.loop = buildCodegenLoopRecord({ ...f1.summary ?? NO_SUMMARY, stopReason: "fallback", fellBack: true, fallbackReason: f1.reason });
@@ -52449,7 +52517,7 @@ async function runCodegenStep(p) {
52449
52517
  return finish(second.done, [firstRecord, { n: 2, outcome: "finished", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls }]);
52450
52518
  }
52451
52519
  const f2 = second.failure;
52452
- log({ event: "codegen.attempt_end", attempt: 2, outcome: "failed", reason: f2.reason, ...f2.afterRecovery ? { afterRecovery: true } : {}, turns: f2.summary?.turns ?? 0, toolCalls: f2.summary?.toolCalls ?? 0, durationMs: secondMs });
52520
+ log({ event: "codegen.attempt_end", attempt: 2, outcome: "failed", reason: f2.reason, ...internalCause(f2), ...f2.afterRecovery ? { afterRecovery: true } : {}, turns: f2.summary?.turns ?? 0, toolCalls: f2.summary?.toolCalls ?? 0, durationMs: secondMs });
52453
52521
  throw lose(p, f2.summary, [firstRecord, failedAttempt(2, f2)], f2.reason === "out_of_time" ? "out_of_time" : "failed", f2.unreportable, [f1, f2]);
52454
52522
  }
52455
52523
 
@@ -52801,7 +52869,7 @@ async function runVerifyAndFix(p) {
52801
52869
  // src/hunkCheck.ts
52802
52870
  var import_node_child_process10 = require("node:child_process");
52803
52871
  var import_node_fs21 = require("node:fs");
52804
- var import_node_path23 = require("node:path");
52872
+ var import_node_path24 = require("node:path");
52805
52873
  var MAX_REPORTED_HUNKS = 20;
52806
52874
  function toFinding(r) {
52807
52875
  if (r.unnecessary.length === 0) return void 0;
@@ -52828,7 +52896,7 @@ function collectHunkCheckFiles(results, root, readHead = readCommittedText) {
52828
52896
  }
52829
52897
  function readCommittedText(root, path) {
52830
52898
  try {
52831
- return (0, import_node_child_process10.execFileSync)("git", ["show", `HEAD:${path}`], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 8 * 1024 * 1024 });
52899
+ return (0, import_node_child_process10.execFileSync)("git", [...NO_HOOKS_ARGS, "show", `HEAD:${path}`], { env: gitEnv(), cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 8 * 1024 * 1024 });
52832
52900
  } catch {
52833
52901
  return null;
52834
52902
  }
@@ -52879,7 +52947,7 @@ async function runHunkCheck(input) {
52879
52947
  let slowestRunMs = input.baselineMs ?? 3e4;
52880
52948
  const runOnce = async (c) => {
52881
52949
  const reportBefore = findReport(input.root);
52882
- const preserve = reportBefore ? [(0, import_node_path23.relative)(input.root, reportBefore).split("\\").join("/")] : [];
52950
+ const preserve = reportBefore ? [(0, import_node_path24.relative)(input.root, reportBefore).split("\\").join("/")] : [];
52883
52951
  const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
52884
52952
  const startedWall = Date.now();
52885
52953
  const startedAt = now();
@@ -52915,7 +52983,7 @@ async function runHunkCheck(input) {
52915
52983
  };
52916
52984
  const runRelated = async (c, plan, limitMs) => {
52917
52985
  const reportBefore = findReport(input.root);
52918
- const preserve = reportBefore ? [(0, import_node_path23.relative)(input.root, reportBefore).split("\\").join("/")] : [];
52986
+ const preserve = reportBefore ? [(0, import_node_path24.relative)(input.root, reportBefore).split("\\").join("/")] : [];
52919
52987
  const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
52920
52988
  const startedAt = now();
52921
52989
  result.relatedRuns += 1;
@@ -53060,7 +53128,7 @@ function healFailureSuffix(heal) {
53060
53128
 
53061
53129
  // src/dependencyCheck.ts
53062
53130
  var import_node_fs22 = require("node:fs");
53063
- var import_node_path24 = require("node:path");
53131
+ var import_node_path25 = require("node:path");
53064
53132
  var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
53065
53133
  var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
53066
53134
  var NODE_BUILTINS = /* @__PURE__ */ new Set([
@@ -53148,8 +53216,8 @@ function dependencyNames(pkg) {
53148
53216
  ]);
53149
53217
  }
53150
53218
  function readDeclaredDependencies(results, workspaceRoot) {
53151
- const packageJsonPath = (0, import_node_path24.join)((0, import_node_path24.resolve)(workspaceRoot ?? "."), "package.json");
53152
- const generated = results.find((r) => (0, import_node_path24.resolve)(r.targetPath) === packageJsonPath);
53219
+ const packageJsonPath = (0, import_node_path25.join)((0, import_node_path25.resolve)(workspaceRoot ?? "."), "package.json");
53220
+ const generated = results.find((r) => (0, import_node_path25.resolve)(r.targetPath) === packageJsonPath);
53153
53221
  let raw;
53154
53222
  if (generated) {
53155
53223
  raw = generated.newContent;
@@ -53219,10 +53287,10 @@ function stripJsonComments(text3) {
53219
53287
  return out2.replace(/,(\s*[}\]])/g, "$1");
53220
53288
  }
53221
53289
  function resolveAliasPrefixes(results, workspaceRoot) {
53222
- const root = (0, import_node_path24.resolve)(workspaceRoot ?? ".");
53290
+ const root = (0, import_node_path25.resolve)(workspaceRoot ?? ".");
53223
53291
  for (const filename of ["tsconfig.json", "jsconfig.json"]) {
53224
- const configPath = (0, import_node_path24.join)(root, filename);
53225
- const generated = results.find((r) => (0, import_node_path24.resolve)(r.targetPath) === configPath);
53292
+ const configPath = (0, import_node_path25.join)(root, filename);
53293
+ const generated = results.find((r) => (0, import_node_path25.resolve)(r.targetPath) === configPath);
53226
53294
  let raw;
53227
53295
  if (generated) {
53228
53296
  raw = generated.newContent;
@@ -53331,7 +53399,8 @@ function routeAlreadyNamed(cwd, mention) {
53331
53399
  const wanted = normalizePath(mention.path);
53332
53400
  let out2;
53333
53401
  try {
53334
- out2 = (0, import_node_child_process11.execFileSync)("git", ["grep", "-I", "-n", "-F", "-e", anchor], {
53402
+ out2 = (0, import_node_child_process11.execFileSync)("git", [...NO_HOOKS_ARGS, "grep", "-I", "-n", "-F", "-e", anchor], {
53403
+ env: gitEnv(),
53335
53404
  cwd,
53336
53405
  encoding: "utf8",
53337
53406
  stdio: ["ignore", "pipe", "ignore"],
@@ -53624,7 +53693,7 @@ function describeVanishedTests(vanished) {
53624
53693
  }
53625
53694
 
53626
53695
  // src/verifyChange.ts
53627
- var import_node_path25 = require("node:path");
53696
+ var import_node_path26 = require("node:path");
53628
53697
 
53629
53698
  // src/packageUse.ts
53630
53699
  var import_node_child_process12 = require("node:child_process");
@@ -53639,7 +53708,8 @@ function packageImportedInWorkspace(pkg, root, cwd = process.cwd()) {
53639
53708
  if (!PACKAGE_NAME.test(pkg)) return false;
53640
53709
  const pathspecs = FILE_TYPES.map((type) => root ? `:(glob)${root}/**/${type}` : `:(glob)**/${type}`);
53641
53710
  try {
53642
- (0, import_node_child_process12.execFileSync)("git", ["grep", "-q", "-E", "-e", importPattern(pkg), "--", ...pathspecs], {
53711
+ (0, import_node_child_process12.execFileSync)("git", [...NO_HOOKS_ARGS, "grep", "-q", "-E", "-e", importPattern(pkg), "--", ...pathspecs], {
53712
+ env: gitEnv(),
53643
53713
  cwd,
53644
53714
  stdio: "ignore",
53645
53715
  timeout: GREP_TIMEOUT_MS2
@@ -53686,7 +53756,7 @@ async function verifyChange(ctx, results, undoable) {
53686
53756
  const depCheck = checkImportDependencies(results, readDeclaredDependencies(results, packet.workspaceRoot), resolveAliasPrefixes(results, packet.workspaceRoot), {
53687
53757
  originalOf: (path) => {
53688
53758
  try {
53689
- return (0, import_node_fs24.readFileSync)((0, import_node_path25.join)(cwd, path), "utf8");
53759
+ return (0, import_node_fs24.readFileSync)((0, import_node_path26.join)(cwd, path), "utf8");
53690
53760
  } catch (err2) {
53691
53761
  return err2.code === "ENOENT" ? "" : null;
53692
53762
  }
@@ -53746,7 +53816,7 @@ async function verifyChange(ctx, results, undoable) {
53746
53816
  flushedAt = now();
53747
53817
  if (undoable) {
53748
53818
  const report = findJUnitReport(cwd);
53749
- const ignore = report ? [(0, import_node_path25.relative)(cwd, report).split("\\").join("/")] : [];
53819
+ const ignore = report ? [(0, import_node_path26.relative)(cwd, report).split("\\").join("/")] : [];
53750
53820
  const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
53751
53821
  undo = () => flush.undo();
53752
53822
  } else {
@@ -53912,7 +53982,7 @@ function buildToolsV2Env(i3) {
53912
53982
  }
53913
53983
 
53914
53984
  // src/repoMap.ts
53915
- var import_node_path26 = require("node:path");
53985
+ var import_node_path27 = require("node:path");
53916
53986
  var MAP_BUDGET_TOKENS = 4e3;
53917
53987
  var MAX_FOLDERS = 200;
53918
53988
  var MAX_LANGUAGES = 12;
@@ -53954,7 +54024,7 @@ function guidanceFiles(i3, perFile2, total) {
53954
54024
  function languages2(listing) {
53955
54025
  const counts = /* @__PURE__ */ new Map();
53956
54026
  for (const p of listing) {
53957
- const ext = import_node_path26.posix.extname(p).toLowerCase();
54027
+ const ext = import_node_path27.posix.extname(p).toLowerCase();
53958
54028
  if (ext && ext.length <= 12) counts.set(ext, (counts.get(ext) ?? 0) + 1);
53959
54029
  }
53960
54030
  return [...counts.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, MAX_LANGUAGES).map(([ext, n]) => `${ext} ${n}`);
@@ -53970,7 +54040,7 @@ function testFacts(i3) {
53970
54040
  const depth = i3.writeRoot === "" ? 0 : i3.writeRoot.split("/").length;
53971
54041
  for (const t of tests) {
53972
54042
  const parts2 = t.split("/");
53973
- const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") : import_node_path26.posix.dirname(t);
54043
+ const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") : import_node_path27.posix.dirname(t);
53974
54044
  byFolder.set(folder, (byFolder.get(folder) ?? 0) + 1);
53975
54045
  }
53976
54046
  for (const [folder, n] of [...byFolder.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 3)) {
@@ -54080,7 +54150,7 @@ function buildRepoMap(i3) {
54080
54150
  }
54081
54151
 
54082
54152
  // src/workspacePackages.ts
54083
- var import_node_path27 = require("node:path");
54153
+ var import_node_path28 = require("node:path");
54084
54154
  var MAX_READ_ROOTS = 8;
54085
54155
  function isObject2(x) {
54086
54156
  return typeof x === "object" && x !== null && !Array.isArray(x);
@@ -54142,8 +54212,8 @@ function workspacePackages(readText, packageJsonPaths) {
54142
54212
  const exclude = patterns.filter((p) => p.startsWith("!")).map((p) => globMatcher(p.slice(1)));
54143
54213
  const out2 = [];
54144
54214
  for (const file of packageJsonPaths) {
54145
- if (import_node_path27.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
54146
- const folder = import_node_path27.posix.dirname(file);
54215
+ if (import_node_path28.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
54216
+ const folder = import_node_path28.posix.dirname(file);
54147
54217
  if (!include.some((re) => re.test(folder)) || exclude.some((re) => re.test(folder))) continue;
54148
54218
  const text3 = readText(file);
54149
54219
  const json = text3 === null ? null : parseJsonc(text3);
@@ -54423,27 +54493,27 @@ function writePhase0Marker(runId) {
54423
54493
  // src/failureArtifact.ts
54424
54494
  var import_node_child_process13 = require("node:child_process");
54425
54495
  var import_node_fs26 = require("node:fs");
54426
- var import_node_path28 = require("node:path");
54496
+ var import_node_path29 = require("node:path");
54427
54497
  var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
54428
54498
  var REPORT_COPY = "final-test-report.xml";
54429
54499
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
54430
54500
  var MAX_FILES = 200;
54431
- var RUNNER_VERSION = true ? "9.3.0-rc.85" : "dev";
54501
+ var RUNNER_VERSION = true ? "9.3.0-rc.87" : "dev";
54432
54502
  function safeDestination(base, repoPath) {
54433
- if (!repoPath || (0, import_node_path28.isAbsolute)(repoPath)) return null;
54434
- const destination = (0, import_node_path28.resolve)(base, repoPath);
54435
- const rel = (0, import_node_path28.relative)(base, destination);
54436
- if (!rel || rel.startsWith("..") || (0, import_node_path28.isAbsolute)(rel)) return null;
54503
+ if (!repoPath || (0, import_node_path29.isAbsolute)(repoPath)) return null;
54504
+ const destination = (0, import_node_path29.resolve)(base, repoPath);
54505
+ const rel = (0, import_node_path29.relative)(base, destination);
54506
+ if (!rel || rel.startsWith("..") || (0, import_node_path29.isAbsolute)(rel)) return null;
54437
54507
  return destination;
54438
54508
  }
54439
54509
  var BUNDLE_FILE = "quikpilot-change.bundle";
54440
54510
  function keepCommitBundle(repo, folder, branch) {
54441
- const git4 = (args2) => (0, import_node_child_process13.execFileSync)("git", args2, { cwd: repo, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
54511
+ const git4 = (args2) => (0, import_node_child_process13.execFileSync)("git", [...NO_HOOKS_ARGS, ...args2], { env: gitEnv(), cwd: repo, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
54442
54512
  try {
54443
54513
  if (git4(["rev-parse", "--abbrev-ref", "HEAD"]) !== branch) return null;
54444
54514
  if (git4(["diff", "--name-only", "HEAD~1", "HEAD"]) === "") return null;
54445
54515
  const commit2 = git4(["rev-parse", "HEAD"]);
54446
- const file = (0, import_node_path28.join)(folder, BUNDLE_FILE);
54516
+ const file = (0, import_node_path29.join)(folder, BUNDLE_FILE);
54447
54517
  git4(["bundle", "create", file, "HEAD", "^HEAD~1"]);
54448
54518
  let verified = true;
54449
54519
  try {
@@ -54459,7 +54529,7 @@ function keepCommitBundle(repo, folder, branch) {
54459
54529
  function writeFailureArtifact(input) {
54460
54530
  if (input.results.length === 0) return { written: false };
54461
54531
  try {
54462
- const base = (0, import_node_path28.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
54532
+ const base = (0, import_node_path29.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
54463
54533
  (0, import_node_fs26.rmSync)(base, { recursive: true, force: true });
54464
54534
  (0, import_node_fs26.mkdirSync)(base, { recursive: true });
54465
54535
  const files = [];
@@ -54470,7 +54540,7 @@ function writeFailureArtifact(input) {
54470
54540
  skipped.push(result.targetPath);
54471
54541
  continue;
54472
54542
  }
54473
- (0, import_node_fs26.mkdirSync)((0, import_node_path28.dirname)(destination), { recursive: true });
54543
+ (0, import_node_fs26.mkdirSync)((0, import_node_path29.dirname)(destination), { recursive: true });
54474
54544
  (0, import_node_fs26.writeFileSync)(destination, result.newContent);
54475
54545
  files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
54476
54546
  }
@@ -54479,7 +54549,7 @@ function writeFailureArtifact(input) {
54479
54549
  if (input.testReport.byteLength > MAX_REPORT_BYTES) {
54480
54550
  testReport = "too-large";
54481
54551
  } else {
54482
- (0, import_node_fs26.writeFileSync)((0, import_node_path28.join)(base, REPORT_COPY), input.testReport);
54552
+ (0, import_node_fs26.writeFileSync)((0, import_node_path29.join)(base, REPORT_COPY), input.testReport);
54483
54553
  testReport = "included";
54484
54554
  }
54485
54555
  }
@@ -54501,8 +54571,8 @@ function writeFailureArtifact(input) {
54501
54571
  bundle
54502
54572
  };
54503
54573
  const text3 = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
54504
- (0, import_node_fs26.writeFileSync)((0, import_node_path28.join)(base, "manifest.json"), text3);
54505
- return { written: (0, import_node_fs26.existsSync)((0, import_node_path28.join)(base, "manifest.json")) };
54574
+ (0, import_node_fs26.writeFileSync)((0, import_node_path29.join)(base, "manifest.json"), text3);
54575
+ return { written: (0, import_node_fs26.existsSync)((0, import_node_path29.join)(base, "manifest.json")) };
54506
54576
  } catch (err2) {
54507
54577
  console.warn(`::warning::Could not keep the failed run's files: ${err2 instanceof Error ? err2.message : String(err2)}`);
54508
54578
  return { written: false };
@@ -54512,9 +54582,10 @@ function writeFailureArtifact(input) {
54512
54582
  // src/finalChange.ts
54513
54583
  var import_node_child_process14 = require("node:child_process");
54514
54584
  var import_node_fs27 = require("node:fs");
54515
- var import_node_path29 = require("node:path");
54585
+ var import_node_path30 = require("node:path");
54516
54586
  function statusPaths(root) {
54517
- const status = (0, import_node_child_process14.execFileSync)("git", ["status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
54587
+ const status = (0, import_node_child_process14.execFileSync)("git", [...NO_HOOKS_ARGS, "status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
54588
+ env: gitEnv(),
54518
54589
  cwd: root,
54519
54590
  encoding: "utf8",
54520
54591
  maxBuffer: 64 * 1024 * 1024
@@ -54525,7 +54596,7 @@ function statusPaths(root) {
54525
54596
  }
54526
54597
  var isFileOnDisk = (root, path) => {
54527
54598
  try {
54528
- return (0, import_node_fs27.statSync)((0, import_node_path29.join)(root, path)).isFile();
54599
+ return (0, import_node_fs27.statSync)((0, import_node_path30.join)(root, path)).isFile();
54529
54600
  } catch {
54530
54601
  return false;
54531
54602
  }
@@ -54547,7 +54618,7 @@ function allChangesAgainstBase(root) {
54547
54618
  // src/nameEvidence.ts
54548
54619
  var import_node_child_process15 = require("node:child_process");
54549
54620
  var import_node_fs28 = require("node:fs");
54550
- var import_node_path30 = require("node:path");
54621
+ var import_node_path31 = require("node:path");
54551
54622
 
54552
54623
  // src/migrationNames.ts
54553
54624
  var PART = String.raw`(?:"[^"]+"|\x60[^\x60]+\x60|\[[^\]]+\]|[\w$]+)`;
@@ -54612,7 +54683,8 @@ var escapeRegExp5 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
54612
54683
  function filesNaming(word, ev, readable, denied) {
54613
54684
  let out2;
54614
54685
  try {
54615
- out2 = (0, import_node_child_process15.execFileSync)("git", ["grep", "-l", "-I", "-w", "-F", "-e", word], {
54686
+ out2 = (0, import_node_child_process15.execFileSync)("git", [...NO_HOOKS_ARGS, "grep", "-l", "-I", "-w", "-F", "-e", word], {
54687
+ env: gitEnv(),
54616
54688
  cwd: ev.cwd,
54617
54689
  encoding: "utf8",
54618
54690
  stdio: ["ignore", "pipe", "ignore"],
@@ -54626,7 +54698,7 @@ function filesNaming(word, ev, readable, denied) {
54626
54698
  }
54627
54699
  function fileHasWord(cwd, file, word) {
54628
54700
  try {
54629
- const path = (0, import_node_path30.join)(cwd, file);
54701
+ const path = (0, import_node_path31.join)(cwd, file);
54630
54702
  if ((0, import_node_fs28.statSync)(path).size > MAX_FILE_BYTES2) return false;
54631
54703
  return new RegExp(`(?<![\\w$])${escapeRegExp5(word)}(?![\\w$])`).test((0, import_node_fs28.readFileSync)(path, "utf8"));
54632
54704
  } catch {
@@ -54708,8 +54780,8 @@ function buildTestDiscovery(i3) {
54708
54780
  }
54709
54781
  function placeUnmapped(cases, listing, workspaceRoot, readText) {
54710
54782
  const files = /* @__PURE__ */ new Set();
54711
- let count3 = 0;
54712
- if (cases.length === 0) return { files, count: count3 };
54783
+ let count4 = 0;
54784
+ if (cases.length === 0) return { files, count: count4 };
54713
54785
  const root = workspaceRoot ? withoutDotSlash(slashes(workspaceRoot)).replace(/\/+$/, "") : "";
54714
54786
  const inListing2 = (p) => listing.has(p) ? p : root && listing.has(`${root}/${p}`) ? `${root}/${p}` : null;
54715
54787
  const isTest = testRule(null);
@@ -54771,10 +54843,10 @@ function placeUnmapped(cases, listing, workspaceRoot, readText) {
54771
54843
  const hit = pythonFile(classname) ?? goFile(classname, c.name);
54772
54844
  if (hit) {
54773
54845
  files.add(hit);
54774
- count3 += 1;
54846
+ count4 += 1;
54775
54847
  }
54776
54848
  }
54777
- return { files, count: count3 };
54849
+ return { files, count: count4 };
54778
54850
  }
54779
54851
  var DEFAULT_DISCOVERY_WAIT_MS = 9e4;
54780
54852
  var MAX_DISCOVERY_WAIT_MS = 36e5;
@@ -55048,6 +55120,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
55048
55120
  let summary;
55049
55121
  let runtimeCode;
55050
55122
  let reason;
55123
+ let causeFields = {};
55051
55124
  try {
55052
55125
  const deps = { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) };
55053
55126
  const looped = await withoutHintsIfRefused(
@@ -55073,6 +55146,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
55073
55146
  reason = err2.reason;
55074
55147
  runtimeCode = err2.runtimeCode;
55075
55148
  summary = err2.summary ?? summary;
55149
+ causeFields = internalCause(err2);
55076
55150
  } else {
55077
55151
  reason = "final_invalid";
55078
55152
  }
@@ -55096,6 +55170,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
55096
55170
  log({
55097
55171
  event: "targeting.loop_fallback",
55098
55172
  reason,
55173
+ ...causeFields,
55099
55174
  turn: fellBack.turns,
55100
55175
  toolCalls: fellBack.toolCalls,
55101
55176
  ...runtimeCode && CODE_LIKE.test(runtimeCode) ? { runtimeCode } : {}
@@ -55135,6 +55210,7 @@ async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTe
55135
55210
  const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals, ticketHints);
55136
55211
  const repoView = repoViewOf(scope);
55137
55212
  let reason;
55213
+ let causeFields = {};
55138
55214
  let hintsWarning;
55139
55215
  try {
55140
55216
  const deps = { secrets: [gateway.token], ...options.loopDeps, post: (contextData, signal) => postTargeting(gateway, contextData, signal) };
@@ -55156,8 +55232,9 @@ async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTe
55156
55232
  } catch (err2) {
55157
55233
  if (err2 instanceof DeniedPathError || err2 instanceof SafetyRefusalError) throw err2;
55158
55234
  reason = err2 instanceof LoopFailure ? err2.reason : "final_invalid";
55235
+ if (err2 instanceof LoopFailure) causeFields = internalCause(err2);
55159
55236
  }
55160
- log({ event: "targeting.map_failed", reason });
55237
+ log({ event: "targeting.map_failed", reason, ...causeFields });
55161
55238
  throw new MapModeError("targeting", reason);
55162
55239
  }
55163
55240
  var TICKET_HINTS_REFUSED_WARNING = "QuikPilot's targeting ran without the files and routes the request names (the AI service did not accept them).";
@@ -56470,7 +56547,7 @@ async function runInvestigateLoop(args2, deps) {
56470
56547
  } catch (err2) {
56471
56548
  const failure = err2 instanceof InvestigateFailure ? err2 : new InvestigateFailure("internal_error", err2);
56472
56549
  failure.summary ??= snapshot("failed");
56473
- log({ event: "investigate.loop_failed", reason: failure.reason, turns, toolCalls: ledger.toolCalls });
56550
+ log({ event: "investigate.loop_failed", reason: failure.reason, ...internalCause(failure), turns, toolCalls: ledger.toolCalls });
56474
56551
  throw failure;
56475
56552
  }
56476
56553
  }