@quikit/quikpilot-runner 9.3.0-rc.55 → 9.3.0-rc.56

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
@@ -28812,6 +28812,15 @@ var TEST_NAME_RULES = [
28812
28812
  /_(?:spec|test)\.rb$/,
28813
28813
  // PHP (PHPUnit): `FooTest.php`.
28814
28814
  /Test\.php$/,
28815
+ // QUIKTR-1701: JVM tooling's other defaults (Surefire `Test*.java` and `*TestCase.java`, Failsafe `*IT.java`), Kotest and ScalaTest `FooSpec`, Spock.
28816
+ // `Testing.java` (a lower-case letter after `Test`) and `Exit.java` (no capital before `IT`) are not tests.
28817
+ /(^|\/)Test[A-Z][^/]*\.(?:java|kt|kts|scala)$/,
28818
+ /TestCase\.(?:java|kt|kts|scala)$/,
28819
+ /[a-z0-9]IT\.(?:java|kt|kts|scala)$/,
28820
+ /[a-z0-9]Spec\.(?:kt|kts|scala|groovy)$/,
28821
+ // Django's `tests.py`, and every C# file of a test project (`Acme.Tests/`, `Acme.Test/`).
28822
+ /(^|\/)tests\.py$/,
28823
+ /(^|\/)[^/]+\.Tests?\/.+\.cs$/,
28815
28824
  // Rust and Dart: `foo_test.rs`, `foo_test.dart`.
28816
28825
  /_test\.(?:rs|dart)$/
28817
28826
  ];
@@ -30833,21 +30842,21 @@ pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper
30833
30842
  }
30834
30843
  return this.finishNode(method, "MethodDefinition");
30835
30844
  };
30836
- pp$8.parseClassField = function(field) {
30837
- if (checkKeyName(field, "constructor")) {
30838
- this.raise(field.key.start, "Classes can't have a field named 'constructor'");
30839
- } else if (field.static && checkKeyName(field, "prototype")) {
30840
- this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
30845
+ pp$8.parseClassField = function(field2) {
30846
+ if (checkKeyName(field2, "constructor")) {
30847
+ this.raise(field2.key.start, "Classes can't have a field named 'constructor'");
30848
+ } else if (field2.static && checkKeyName(field2, "prototype")) {
30849
+ this.raise(field2.key.start, "Classes can't have a static field named 'prototype'");
30841
30850
  }
30842
30851
  if (this.eat(types$1.eq)) {
30843
30852
  this.enterScope(SCOPE_CLASS_FIELD_INIT | SCOPE_SUPER);
30844
- field.value = this.parseMaybeAssign();
30853
+ field2.value = this.parseMaybeAssign();
30845
30854
  this.exitScope();
30846
30855
  } else {
30847
- field.value = null;
30856
+ field2.value = null;
30848
30857
  }
30849
30858
  this.semicolon();
30850
- return this.finishNode(field, "PropertyDefinition");
30859
+ return this.finishNode(field2, "PropertyDefinition");
30851
30860
  };
30852
30861
  pp$8.parseClassStaticBlock = function(node) {
30853
30862
  node.body = [];
@@ -35152,6 +35161,29 @@ function contains(node, test) {
35152
35161
  if (test(node)) return true;
35153
35162
  return node.children.some((c) => contains(c, test));
35154
35163
  }
35164
+ function isOtherCheck(lang, n) {
35165
+ if (lang === "go") {
35166
+ if (n.type !== "call_expression") return false;
35167
+ const fn = n.childForFieldName("function");
35168
+ return fn?.type === "selector_expression" && /^(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$/.test(fn.childForFieldName("field")?.text ?? "");
35169
+ }
35170
+ if (lang === "python") return n.type === "with_item" && /\b(raises|warns|assertRaises|assertWarns)\b/.test(n.text.slice(0, 200));
35171
+ if (lang === "java") return n.type === "method_invocation" && n.childForFieldName("object") === null && /^(fail|assert\w*)$/.test(n.childForFieldName("name")?.text ?? "") && n.parent?.type === "expression_statement";
35172
+ return false;
35173
+ }
35174
+ function countChecks(lang, spec, node) {
35175
+ let count3 = 0;
35176
+ const walk2 = (n) => {
35177
+ if (spec.assertion(n)) {
35178
+ count3 += 1;
35179
+ return;
35180
+ }
35181
+ if (isOtherCheck(lang, n)) count3 += 1;
35182
+ for (const c of n.children) walk2(c);
35183
+ };
35184
+ walk2(node);
35185
+ return count3;
35186
+ }
35155
35187
  var SPECS = {
35156
35188
  python: {
35157
35189
  literal: (n) => n.type === "string" ? !n.children.some((c) => c.type === "interpolation") : ["integer", "float", "true", "false", "none"].includes(n.type),
@@ -35249,7 +35281,7 @@ function shapeOf(spec, root, titleStart) {
35249
35281
  walk2(root);
35250
35282
  return out2.join(SEP);
35251
35283
  }
35252
- function locatePython(root, add) {
35284
+ function locatePython(root, add2) {
35253
35285
  const visit = (body2, describes) => {
35254
35286
  for (const child of body2.namedChildren) {
35255
35287
  const decorated = child.type === "decorated_definition";
@@ -35262,30 +35294,30 @@ function locatePython(root, add) {
35262
35294
  const name2 = def.childForFieldName("name");
35263
35295
  if (!name2 || !/^test/.test(name2.text)) continue;
35264
35296
  const decorators = decorated ? child.namedChildren.filter((c) => c.type === "decorator").map((c) => c.text).join("\n") : "";
35265
- add({ span: child, name: name2, title: name2.text, describes, skipped: /\bskip/i.test(decorators), table: /parametri[sz]e|\bddt\b/i.test(decorators) });
35297
+ add2({ span: child, name: name2, title: name2.text, describes, skipped: /\bskip/i.test(decorators), table: /parametri[sz]e|\bddt\b/i.test(decorators) });
35266
35298
  }
35267
35299
  }
35268
35300
  };
35269
35301
  visit(root, []);
35270
35302
  }
35271
- function locateGo(root, add) {
35303
+ function locateGo(root, add2) {
35272
35304
  for (const fn of root.namedChildren) {
35273
35305
  if (fn.type !== "function_declaration") continue;
35274
35306
  const name2 = fn.childForFieldName("name");
35275
35307
  if (!name2 || !/^Test(?![a-z])/.test(name2.text) || name2.text === "TestMain") continue;
35276
35308
  if (!(fn.childForFieldName("parameters")?.text ?? "").includes("testing.")) continue;
35277
- const callsOn = (field) => (n) => {
35309
+ const callsOn = (field2) => (n) => {
35278
35310
  if (n.type !== "call_expression") return false;
35279
35311
  const callee = n.childForFieldName("function");
35280
- return callee?.type === "selector_expression" && field.test(callee.childForFieldName("field")?.text ?? "");
35312
+ return callee?.type === "selector_expression" && field2.test(callee.childForFieldName("field")?.text ?? "");
35281
35313
  };
35282
- add({ span: fn, name: name2, title: name2.text, describes: [], skipped: contains(fn, callsOn(/^Skip/)), table: contains(fn, callsOn(/^Run$/)) });
35314
+ add2({ span: fn, name: name2, title: name2.text, describes: [], skipped: contains(fn, callsOn(/^Skip/)), table: contains(fn, callsOn(/^Run$/)) });
35283
35315
  }
35284
35316
  }
35285
35317
  var JAVA_TESTS = /* @__PURE__ */ new Set(["Test", "ParameterizedTest", "RepeatedTest", "TestFactory", "TestTemplate"]);
35286
35318
  var JAVA_TABLES = /* @__PURE__ */ new Set(["ParameterizedTest", "RepeatedTest", "TestFactory", "TestTemplate"]);
35287
35319
  var JAVA_TYPES = /* @__PURE__ */ new Set(["class_declaration", "interface_declaration", "enum_declaration", "record_declaration"]);
35288
- function locateJava(root, add) {
35320
+ function locateJava(root, add2) {
35289
35321
  const visit = (node) => {
35290
35322
  for (const child of node.namedChildren) {
35291
35323
  if (JAVA_TYPES.has(child.type)) {
@@ -35301,7 +35333,7 @@ function locateJava(root, add) {
35301
35333
  if (!kind || !name2) continue;
35302
35334
  const shown = names.get("DisplayName")?.childForFieldName("arguments")?.namedChildren.find((c) => c.type === "string_literal")?.text;
35303
35335
  const display = shown && shown.length >= 2 ? shown.slice(1, -1) : null;
35304
- add({ span: child, name: name2, title: display && display.length > 0 ? display : name2.text, describes: [], skipped: names.has("Disabled") || names.has("Ignore"), table: [...names.keys()].some((n) => JAVA_TABLES.has(n)) });
35336
+ add2({ span: child, name: name2, title: display && display.length > 0 ? display : name2.text, describes: [], skipped: names.has("Disabled") || names.has("Ignore"), table: [...names.keys()].some((n) => JAVA_TABLES.has(n)) });
35305
35337
  }
35306
35338
  };
35307
35339
  visit(root);
@@ -35314,7 +35346,7 @@ function locateOtherLanguage(path, text3) {
35314
35346
  return parseWith(lang, text3, (root) => {
35315
35347
  const tests = [];
35316
35348
  const generated = [];
35317
- const add = (f) => {
35349
+ const add2 = (f) => {
35318
35350
  const test = {
35319
35351
  title: f.title,
35320
35352
  describes: f.describes,
@@ -35325,13 +35357,14 @@ function locateOtherLanguage(path, text3) {
35325
35357
  titleStart: f.name.startIndex,
35326
35358
  titleEnd: f.name.endIndex,
35327
35359
  skipped: f.skipped,
35328
- shape: shapeOf(spec, f.span, f.name.startIndex)
35360
+ shape: shapeOf(spec, f.span, f.name.startIndex),
35361
+ checks: countChecks(lang, spec, f.span)
35329
35362
  };
35330
35363
  (f.table ? generated : tests).push(test);
35331
35364
  };
35332
- if (lang === "python") locatePython(root, add);
35333
- else if (lang === "go") locateGo(root, add);
35334
- else locateJava(root, add);
35365
+ if (lang === "python") locatePython(root, add2);
35366
+ else if (lang === "go") locateGo(root, add2);
35367
+ else locateJava(root, add2);
35335
35368
  return { code: text3, tests, generated };
35336
35369
  });
35337
35370
  }
@@ -35632,6 +35665,173 @@ function isGeneratedText(lf) {
35632
35665
  }
35633
35666
  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.";
35634
35667
 
35668
+ // src/definitions.ts
35669
+ var MAX_NAME_CHARS = 80;
35670
+ var MAX_DEFINITIONS = 2e3;
35671
+ var clip = (s) => s.length > MAX_NAME_CHARS ? s.slice(0, MAX_NAME_CHARS) : s;
35672
+ var field = (n, f) => n.childForFieldName(f)?.text ?? "";
35673
+ function add(ctx, span, kind, name2, depth) {
35674
+ if (name2 === "" || ctx.out.length >= MAX_DEFINITIONS) {
35675
+ if (ctx.out.length >= MAX_DEFINITIONS) ctx.full = true;
35676
+ return;
35677
+ }
35678
+ ctx.out.push({ kind, name: clip(name2), startLine: span.startPosition.row + 1, endLine: span.endPosition.row + 1, depth });
35679
+ }
35680
+ var childOfType = (n, type) => n.namedChildren.find((c) => c.type === type) ?? null;
35681
+ function python(ctx) {
35682
+ const visit = (nodes, depth, inside3) => {
35683
+ for (const n of nodes) {
35684
+ const decorated = n.type === "decorated_definition";
35685
+ const def = decorated ? n.childForFieldName("definition") : n;
35686
+ if (!def) continue;
35687
+ if (def.type === "function_definition") add(ctx, n, inside3 ? "method" : "function", field(def, "name"), depth);
35688
+ else if (def.type === "class_definition") {
35689
+ add(ctx, n, "class", field(def, "name"), depth);
35690
+ const body2 = def.childForFieldName("body");
35691
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35692
+ }
35693
+ }
35694
+ };
35695
+ return visit;
35696
+ }
35697
+ function go(ctx) {
35698
+ return (nodes, depth) => {
35699
+ for (const n of nodes) {
35700
+ if (n.type === "function_declaration") add(ctx, n, "function", field(n, "name"), depth);
35701
+ else if (n.type === "method_declaration") add(ctx, n, "method", field(n, "name"), depth);
35702
+ else if (n.type === "type_declaration") {
35703
+ for (const spec of n.namedChildren) {
35704
+ if (spec.type !== "type_spec" && spec.type !== "type_alias") continue;
35705
+ const t = spec.childForFieldName("type")?.type;
35706
+ add(ctx, spec, t === "struct_type" ? "struct" : t === "interface_type" ? "interface" : "type", field(spec, "name"), depth);
35707
+ }
35708
+ }
35709
+ }
35710
+ };
35711
+ }
35712
+ function java(ctx) {
35713
+ const visit = (nodes, depth) => {
35714
+ for (const n of nodes) {
35715
+ const body2 = n.childForFieldName("body");
35716
+ if (n.type === "class_declaration" || n.type === "record_declaration") add(ctx, n, "class", field(n, "name"), depth);
35717
+ else if (n.type === "interface_declaration") add(ctx, n, "interface", field(n, "name"), depth);
35718
+ else if (n.type === "enum_declaration") add(ctx, n, "enum", field(n, "name"), depth);
35719
+ else if (n.type === "method_declaration" || n.type === "constructor_declaration") {
35720
+ add(ctx, n, "method", field(n, "name"), depth);
35721
+ continue;
35722
+ } else continue;
35723
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35724
+ }
35725
+ };
35726
+ return visit;
35727
+ }
35728
+ function kotlin(ctx) {
35729
+ const visit = (nodes, depth, inside3) => {
35730
+ for (const n of nodes) {
35731
+ if (n.type === "class_declaration" || n.type === "object_declaration") {
35732
+ const isInterface = n.children.some((c) => !c.isNamed && c.type === "interface");
35733
+ const name2 = n.childForFieldName("name")?.text ?? childOfType(n, "identifier")?.text ?? "";
35734
+ add(ctx, n, isInterface ? "interface" : "class", name2, depth);
35735
+ const body2 = childOfType(n, "class_body") ?? childOfType(n, "enum_class_body");
35736
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35737
+ } else if (n.type === "function_declaration") {
35738
+ add(ctx, n, inside3 ? "method" : "function", n.childForFieldName("name")?.text ?? childOfType(n, "identifier")?.text ?? "", depth);
35739
+ }
35740
+ }
35741
+ };
35742
+ return visit;
35743
+ }
35744
+ function csharp(ctx) {
35745
+ const visit = (nodes, depth) => {
35746
+ for (const n of nodes) {
35747
+ let kind = null;
35748
+ if (n.type === "namespace_declaration" || n.type === "file_scoped_namespace_declaration") kind = "module";
35749
+ else if (n.type === "class_declaration" || n.type === "record_declaration") kind = "class";
35750
+ else if (n.type === "struct_declaration") kind = "struct";
35751
+ else if (n.type === "interface_declaration") kind = "interface";
35752
+ else if (n.type === "enum_declaration") kind = "enum";
35753
+ else if (n.type === "method_declaration" || n.type === "constructor_declaration") {
35754
+ add(ctx, n, "method", field(n, "name"), depth);
35755
+ continue;
35756
+ }
35757
+ if (kind === null) continue;
35758
+ add(ctx, n, kind, field(n, "name"), depth);
35759
+ const body2 = n.childForFieldName("body");
35760
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35761
+ }
35762
+ };
35763
+ return visit;
35764
+ }
35765
+ function rust(ctx) {
35766
+ const visit = (nodes, depth, inside3) => {
35767
+ for (const n of nodes) {
35768
+ const body2 = n.childForFieldName("body");
35769
+ if (n.type === "function_item") add(ctx, n, inside3 ? "method" : "function", field(n, "name"), depth);
35770
+ else if (n.type === "struct_item" || n.type === "union_item") add(ctx, n, "struct", field(n, "name"), depth);
35771
+ else if (n.type === "enum_item") add(ctx, n, "enum", field(n, "name"), depth);
35772
+ else if (n.type === "type_item") add(ctx, n, "type", field(n, "name"), depth);
35773
+ else if (n.type === "trait_item") {
35774
+ add(ctx, n, "interface", field(n, "name"), depth);
35775
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35776
+ } else if (n.type === "impl_item") {
35777
+ const trait = field(n, "trait");
35778
+ add(ctx, n, "class", trait ? `${trait} for ${field(n, "type")}` : field(n, "type"), depth);
35779
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35780
+ } else if (n.type === "mod_item") {
35781
+ add(ctx, n, "module", field(n, "name"), depth);
35782
+ if (body2) visit(body2.namedChildren, depth + 1, false);
35783
+ }
35784
+ }
35785
+ };
35786
+ return visit;
35787
+ }
35788
+ function ruby(ctx) {
35789
+ const visit = (nodes, depth, inside3) => {
35790
+ for (const n of nodes) {
35791
+ if (n.type === "method" || n.type === "singleton_method") add(ctx, n, inside3 ? "method" : "function", field(n, "name"), depth);
35792
+ else if (n.type === "class" || n.type === "module") {
35793
+ add(ctx, n, n.type === "class" ? "class" : "module", field(n, "name"), depth);
35794
+ const body2 = n.childForFieldName("body");
35795
+ if (body2) visit(body2.namedChildren, depth + 1, true);
35796
+ }
35797
+ }
35798
+ };
35799
+ return visit;
35800
+ }
35801
+ function php(ctx) {
35802
+ const visit = (nodes, depth, inside3) => {
35803
+ for (const n of nodes) {
35804
+ let kind = null;
35805
+ if (n.type === "namespace_definition") kind = "module";
35806
+ else if (n.type === "class_declaration" || n.type === "trait_declaration") kind = "class";
35807
+ else if (n.type === "interface_declaration") kind = "interface";
35808
+ else if (n.type === "enum_declaration") kind = "enum";
35809
+ else if (n.type === "function_definition") {
35810
+ add(ctx, n, "function", field(n, "name"), depth);
35811
+ continue;
35812
+ } else if (n.type === "method_declaration") {
35813
+ add(ctx, n, inside3 ? "method" : "function", field(n, "name"), depth);
35814
+ continue;
35815
+ }
35816
+ if (kind === null) continue;
35817
+ add(ctx, n, kind, field(n, "name"), depth);
35818
+ const body2 = n.childForFieldName("body");
35819
+ if (body2) visit(body2.namedChildren, depth + 1, kind !== "module");
35820
+ }
35821
+ };
35822
+ return visit;
35823
+ }
35824
+ var WALKERS = { python, go, java, kotlin, csharp, rust, ruby, php };
35825
+ function definitionsOfFile(path, text3) {
35826
+ const lang = langOfPath(path);
35827
+ if (lang === null) return null;
35828
+ return parseWith(lang, text3, (root) => {
35829
+ const ctx = { out: [], full: false };
35830
+ WALKERS[lang](ctx)(root.namedChildren, 0, false);
35831
+ return ctx.out;
35832
+ });
35833
+ }
35834
+
35635
35835
  // src/importContext.ts
35636
35836
  var import_node_path2 = require("node:path");
35637
35837
  var REGEX_PRECEDING_KEYWORDS = /* @__PURE__ */ new Set([
@@ -35796,7 +35996,7 @@ function extractImportSpecifiers(source) {
35796
35996
  const t = tokenize(source);
35797
35997
  const found = [];
35798
35998
  const seen = /* @__PURE__ */ new Set();
35799
- const add = (s) => {
35999
+ const add2 = (s) => {
35800
36000
  if (!seen.has(s)) {
35801
36001
  seen.add(s);
35802
36002
  found.push(s);
@@ -35808,18 +36008,18 @@ function extractImportSpecifiers(source) {
35808
36008
  if (tok.k !== "id") continue;
35809
36009
  if (isP(t[i3 - 1], ".")) continue;
35810
36010
  if (tok.v === "require") {
35811
- if (isP(t[i3 + 1], "(") && t[i3 + 2]?.k === "str" && isP(t[i3 + 3], ")")) add(t[i3 + 2].v);
36011
+ if (isP(t[i3 + 1], "(") && t[i3 + 2]?.k === "str" && isP(t[i3 + 3], ")")) add2(t[i3 + 2].v);
35812
36012
  continue;
35813
36013
  }
35814
36014
  if (tok.v !== "import" && tok.v !== "export") continue;
35815
36015
  const next = t[i3 + 1];
35816
36016
  if (tok.v === "import") {
35817
36017
  if (next?.k === "str") {
35818
- add(next.v);
36018
+ add2(next.v);
35819
36019
  continue;
35820
36020
  }
35821
36021
  if (isP(next, "(")) {
35822
- if (t[i3 + 2]?.k === "str" && (isP(t[i3 + 3], ")") || isP(t[i3 + 3], ","))) add(t[i3 + 2].v);
36022
+ if (t[i3 + 2]?.k === "str" && (isP(t[i3 + 3], ")") || isP(t[i3 + 3], ","))) add2(t[i3 + 2].v);
35823
36023
  continue;
35824
36024
  }
35825
36025
  }
@@ -35828,7 +36028,7 @@ function extractImportSpecifiers(source) {
35828
36028
  if (c.k === "id") {
35829
36029
  if (c.v === "import" || c.v === "export") break;
35830
36030
  if (c.v === "from" && t[j + 1]?.k === "str") {
35831
- add(t[j + 1].v);
36031
+ add2(t[j + 1].v);
35832
36032
  break;
35833
36033
  }
35834
36034
  continue;
@@ -35960,7 +36160,7 @@ function collectImportContext(p) {
35960
36160
 
35961
36161
  // src/outline.ts
35962
36162
  var MAX_OUTLINE_ENTRIES = 200;
35963
- var MAX_NAME_CHARS = 80;
36163
+ var MAX_NAME_CHARS2 = 80;
35964
36164
  function lineStarts(code) {
35965
36165
  const starts = [0];
35966
36166
  for (let i3 = 0; i3 < code.length; i3++) if (code.charCodeAt(i3) === 10) starts.push(i3 + 1);
@@ -35984,8 +36184,8 @@ function keyName(key) {
35984
36184
  if (key.type === "Literal" && (typeof key.value === "string" || typeof key.value === "number")) return String(key.value);
35985
36185
  return null;
35986
36186
  }
35987
- function clip(name2) {
35988
- return name2.length > MAX_NAME_CHARS ? `${name2.slice(0, MAX_NAME_CHARS)}\u2026` : name2;
36187
+ function clip2(name2) {
36188
+ return name2.length > MAX_NAME_CHARS2 ? `${name2.slice(0, MAX_NAME_CHARS2)}\u2026` : name2;
35989
36189
  }
35990
36190
  function jsEntries(path, text3) {
35991
36191
  const parsed = parseProgram(path, text3);
@@ -35993,40 +36193,40 @@ function jsEntries(path, text3) {
35993
36193
  const { ast, code } = parsed;
35994
36194
  const starts = lineStarts(code);
35995
36195
  const out2 = [];
35996
- const add = (kind, name2, node, depth) => {
36196
+ const add2 = (kind, name2, node, depth) => {
35997
36197
  if (!name2) return;
35998
- out2.push({ kind, name: clip(name2), startLine: lineOf(starts, node.start), endLine: lineOf(starts, Math.max(node.start, node.end - 1)), depth });
36198
+ out2.push({ kind, name: clip2(name2), startLine: lineOf(starts, node.start), endLine: lineOf(starts, Math.max(node.start, node.end - 1)), depth });
35999
36199
  };
36000
36200
  const members = (cls, depth) => {
36001
36201
  for (const m of cls.body?.body ?? []) {
36002
- if (m.type === "MethodDefinition") add("method", keyName(m.key), m, depth);
36003
- else if (m.type === "PropertyDefinition" && isFn(m.value)) add("method", keyName(m.key), m, depth);
36202
+ if (m.type === "MethodDefinition") add2("method", keyName(m.key), m, depth);
36203
+ else if (m.type === "PropertyDefinition" && isFn(m.value)) add2("method", keyName(m.key), m, depth);
36004
36204
  }
36005
36205
  };
36006
36206
  const objectMethods = (obj, depth) => {
36007
36207
  for (const p of obj.properties ?? []) {
36008
- if (p.type === "Property" && (p.method || isFn(p.value))) add("method", keyName(p.key), p, depth);
36208
+ if (p.type === "Property" && (p.method || isFn(p.value))) add2("method", keyName(p.key), p, depth);
36009
36209
  }
36010
36210
  };
36011
36211
  const declaration = (node, exported) => {
36012
36212
  switch (node.type) {
36013
36213
  case "FunctionDeclaration":
36014
- add("function", node.id?.name ?? null, node, 0);
36214
+ add2("function", node.id?.name ?? null, node, 0);
36015
36215
  return;
36016
36216
  case "ClassDeclaration":
36017
- add("class", node.id?.name ?? null, node, 0);
36217
+ add2("class", node.id?.name ?? null, node, 0);
36018
36218
  members(node, 1);
36019
36219
  return;
36020
36220
  case "VariableDeclaration":
36021
36221
  for (const d of node.declarations) {
36022
36222
  if (d.id?.type !== "Identifier") continue;
36023
36223
  const init2 = d.init;
36024
- if (isFn(init2)) add("function", d.id.name, node, 0);
36224
+ if (isFn(init2)) add2("function", d.id.name, node, 0);
36025
36225
  else if (init2?.type === "ClassExpression") {
36026
- add("class", d.id.name, node, 0);
36226
+ add2("class", d.id.name, node, 0);
36027
36227
  members(init2, 1);
36028
36228
  } else if (exported) {
36029
- add("const", d.id.name, node, 0);
36229
+ add2("const", d.id.name, node, 0);
36030
36230
  if (init2?.type === "ObjectExpression") objectMethods(init2, 1);
36031
36231
  }
36032
36232
  }
@@ -36038,9 +36238,9 @@ function jsEntries(path, text3) {
36038
36238
  if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") {
36039
36239
  const inner = node.declaration;
36040
36240
  if (!inner) continue;
36041
- if (inner.type === "FunctionExpression" || inner.type === "ArrowFunctionExpression") add("function", "default", node, 0);
36241
+ if (inner.type === "FunctionExpression" || inner.type === "ArrowFunctionExpression") add2("function", "default", node, 0);
36042
36242
  else if (inner.type === "ClassExpression") {
36043
- add("class", inner.id?.name ?? "default", node, 0);
36243
+ add2("class", inner.id?.name ?? "default", node, 0);
36044
36244
  members(inner, 1);
36045
36245
  } else declaration(inner, true);
36046
36246
  continue;
@@ -36052,12 +36252,12 @@ function jsEntries(path, text3) {
36052
36252
  const m = /^(?:module\.)?exports(?:\.([A-Za-z_$][\w$]*))?$/.exec(text4);
36053
36253
  if (m) {
36054
36254
  const name2 = m[1] ?? "module.exports";
36055
- if (isFn(right)) add("function", name2, node, 0);
36255
+ if (isFn(right)) add2("function", name2, node, 0);
36056
36256
  else if (right.type === "ClassExpression") {
36057
- add("class", name2, node, 0);
36257
+ add2("class", name2, node, 0);
36058
36258
  members(right, 1);
36059
36259
  } else if (right.type === "ObjectExpression") {
36060
- add("const", name2, node, 0);
36260
+ add2("const", name2, node, 0);
36061
36261
  objectMethods(right, 1);
36062
36262
  }
36063
36263
  }
@@ -36103,7 +36303,7 @@ function keywordEntries(text3, only) {
36103
36303
  if (indentOf(line) > MAX_INDENT) continue;
36104
36304
  const kind = kindOfKeyword(m[2]);
36105
36305
  if (only && !only.has(m[2])) continue;
36106
- found.push({ indent: indentOf(m[1]), kind, name: clip(m[3]), line: i3 + 1 });
36306
+ found.push({ indent: indentOf(m[1]), kind, name: clip2(m[3]), line: i3 + 1 });
36107
36307
  }
36108
36308
  const out2 = [];
36109
36309
  const stack = [];
@@ -36150,6 +36350,13 @@ function outlineOf(path, text3) {
36150
36350
  } catch {
36151
36351
  entries = null;
36152
36352
  }
36353
+ if (entries === null) {
36354
+ const tree = definitionsOfFile(path, text3);
36355
+ if (tree) {
36356
+ engine = "treesitter";
36357
+ entries = tree.map((d) => ({ kind: d.kind, name: d.name, startLine: d.startLine, endLine: d.endLine, depth: d.depth }));
36358
+ }
36359
+ }
36153
36360
  if (entries === null) {
36154
36361
  engine = "keyword";
36155
36362
  entries = keywordEntries(text3);
@@ -36527,11 +36734,18 @@ function prepareGrepV2(args2, env2) {
36527
36734
  }
36528
36735
  };
36529
36736
  }
36530
- var NOT_A_NAME = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "catch", "return", "else", "do", "function", "new", "typeof", "await", "super", "this"]);
36531
- var IDENT = /^[A-Za-z_$][\w$]*$/;
36737
+ var NOT_A_NAME = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "catch", "return", "else", "do"]);
36738
+ var IDENT = /^[\p{L}_$][\p{L}\p{N}_$]*[?!]?$/u;
36739
+ var escapeRegExp3 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
36740
+ var MAX_TREE_FILES = 80;
36532
36741
  var MAX_NAME_LENGTH = 80;
36533
- function definitionsIn(text3, name2) {
36534
- const id = name2.replace(/\$/g, "\\$");
36742
+ function definitionsIn(text3, name2, path, parsed) {
36743
+ if (path !== void 0 && text3.includes(name2) && (parsed === void 0 || parsed.count < MAX_TREE_FILES)) {
36744
+ const tree = definitionsOfFile(path, text3);
36745
+ if (parsed && tree !== null) parsed.count += 1;
36746
+ if (tree !== null) return tree.filter((d) => d.name === name2).map((d) => ({ line: d.startLine, kind: d.kind }));
36747
+ }
36748
+ const id = escapeRegExp3(name2);
36535
36749
  const rules = [
36536
36750
  [new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?function\\*?\\s+${id}(?![\\w$])`), "function"],
36537
36751
  [new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+${id}(?![\\w$])`), "class"],
@@ -36665,7 +36879,7 @@ function visibleSet(env2) {
36665
36879
  function prepareFindDefinition(args2, env2) {
36666
36880
  const name2 = args2.name;
36667
36881
  if (typeof name2 !== "string" || name2.length === 0 || name2.length > MAX_NAME_LENGTH || !IDENT.test(name2)) {
36668
- return bad("name must be one identifier (letters, digits, _ or $).");
36882
+ return bad("name must be one name (letters, digits, _ or $, and a Ruby-style ? or ! at the end).");
36669
36883
  }
36670
36884
  if (NOT_A_NAME.has(name2)) return bad("name must be the name of something defined, not a language keyword.");
36671
36885
  let fromPath;
@@ -36696,6 +36910,7 @@ function prepareFindDefinition(args2, env2) {
36696
36910
  let filesScanned = 0;
36697
36911
  let bytesScanned = 0;
36698
36912
  let scanCapped = false;
36913
+ const parsedFiles = { count: 0 };
36699
36914
  for (const path of env2.visible) {
36700
36915
  if (filesScanned >= env2.limits.grepMaxFiles || bytesScanned >= env2.limits.grepMaxBytes) {
36701
36916
  scanCapped = true;
@@ -36706,7 +36921,7 @@ function prepareFindDefinition(args2, env2) {
36706
36921
  const text3 = scanText(path, env2);
36707
36922
  if (text3 === null) continue;
36708
36923
  bytesScanned += text3.length;
36709
- for (const d of definitionsIn(text3, name2)) {
36924
+ for (const d of definitionsIn(text3, name2, path, parsedFiles)) {
36710
36925
  if (!seen.has(`${path}:${d.line}`)) candidates.push({ path, ...d });
36711
36926
  }
36712
36927
  }
@@ -38769,10 +38984,10 @@ function unexplainedRegressions(answer, reported) {
38769
38984
  (g) => !reported.some((r) => (g.file === "" || idPlaceMatches(g.file, r.path)) && nameEndsWithTitle(g.title, r.title, r.path))
38770
38985
  );
38771
38986
  }
38772
- var clip2 = (s, max) => s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
38987
+ var clip3 = (s, max) => s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
38773
38988
  function sentenceOf(g) {
38774
38989
  const rows = g.rows > 1 ? ` (${g.rows} rows)` : "";
38775
- return clip2(`${g.file ? `${clip2(g.file, MAX_FILE_CHARS)}: ` : ""}"${clip2(g.title, MAX_TITLE_CHARS)}"${rows} passed before this run and fails now.`, MAX_SENTENCE_CHARS);
38990
+ return clip3(`${g.file ? `${clip3(g.file, MAX_FILE_CHARS)}: ` : ""}"${clip3(g.title, MAX_TITLE_CHARS)}"${rows} passed before this run and fails now.`, MAX_SENTENCE_CHARS);
38776
38991
  }
38777
38992
  function giveUpSentences(groups) {
38778
38993
  if (groups.length <= MAX_SENTENCES) return groups.map(sentenceOf);
@@ -38781,7 +38996,7 @@ function giveUpSentences(groups) {
38781
38996
  }
38782
38997
  function oldBehaviourSentence(groups, max = 600) {
38783
38998
  const parts2 = groups.map((g) => `${g.file ? `${g.file}: ` : ""}"${g.title}"${g.rows > 1 ? ` (${g.rows} rows)` : ""}`);
38784
- return clip2(`existing tests that may expect the old behaviour: ${parts2.join("; ")}`, max);
38999
+ return clip3(`existing tests that may expect the old behaviour: ${parts2.join("; ")}`, max);
38785
39000
  }
38786
39001
  function withoutLoop7Words(previous) {
38787
39002
  if (!previous.steps?.some((s) => s.refused?.includes(GIVE_UP_RULE))) return previous;
@@ -41678,13 +41893,12 @@ function failedAttemptRecord(n, failure) {
41678
41893
  outcome: "failed",
41679
41894
  reason: failure.reason,
41680
41895
  ...failure.runtimeCode ? { runtimeCode: runtimeCodeWord(failure.runtimeCode) } : {},
41681
- ...failure.afterRecovery ? { afterRecovery: true } : {},
41682
41896
  turns: failure.summary?.turns ?? 0,
41683
41897
  toolCalls: failure.summary?.toolCalls ?? 0
41684
41898
  };
41685
41899
  }
41686
41900
  function attemptInWords(a, fallback) {
41687
- const words = a?.afterRecovery ? `${reasonInWords(a?.reason ?? fallback)}, a second time in a row, even after the AI was asked to take a smaller step` : reasonInWords(a?.reason ?? fallback);
41901
+ const words = reasonInWords(a?.reason ?? fallback);
41688
41902
  return a?.runtimeCode && a.runtimeCode !== "other" ? `${words} (error code ${a.runtimeCode})` : words;
41689
41903
  }
41690
41904
  function exhaustedMessage(attempts, stop2, unreportable) {
@@ -44204,7 +44418,7 @@ function lineAt3(text3, offset2) {
44204
44418
  }
44205
44419
  function findTests(path, text3) {
44206
44420
  const parsed = parseProgram(path, text3);
44207
- if (!parsed) return null;
44421
+ if (!parsed) return findOtherLanguageTests(path, text3);
44208
44422
  const out2 = [];
44209
44423
  walk(parsed.ast, (n) => {
44210
44424
  if (n.type !== "CallExpression") return;
@@ -44234,6 +44448,17 @@ function findTests(path, text3) {
44234
44448
  });
44235
44449
  return out2;
44236
44450
  }
44451
+ function findOtherLanguageTests(path, text3) {
44452
+ const located = locateTests(path, text3);
44453
+ if (!located) return null;
44454
+ return allTests(located).sort((a, b) => a.start - b.start).map((t) => ({
44455
+ id: `title:${t.title}`,
44456
+ line: t.startLine,
44457
+ text: located.code.slice(t.start, t.end).replace(/\s+/g, " ").replace(/ ?([^\w$ ]) ?/g, "$1"),
44458
+ checks: t.checks ?? 0,
44459
+ skipped: t.skipped
44460
+ }));
44461
+ }
44237
44462
  function groupById(tests) {
44238
44463
  const map = /* @__PURE__ */ new Map();
44239
44464
  for (const t of tests) map.set(t.id, [...map.get(t.id) ?? [], t]);
@@ -46056,35 +46281,6 @@ function missingImportSentence(m) {
46056
46281
  return `${first.path} imports ${first.name} from ${first.from}, which does not export it${more}: export it there, or change the import.`.slice(0, 300);
46057
46282
  }
46058
46283
 
46059
- // src/turnRecovery.ts
46060
- var RECOVERY_RULE = "length";
46061
- var COMMON = "Take a smaller step: fewer files and fewer edits in one turn, and make each edit a small find-and-replace change.";
46062
- var SENTENCES = {
46063
- cut_off: {
46064
- violation: "Your last answer was cut off because it was too long, so none of it was run.",
46065
- message: `Your last answer was too long and was cut off, so none of it was run. ${COMMON}`
46066
- },
46067
- slow: {
46068
- violation: "Your last step took too long, so none of it was run.",
46069
- message: `Your last step took too long, so none of it was run. ${COMMON}`
46070
- }
46071
- };
46072
- function turnRecoveryOff(env2 = process.env) {
46073
- return env2.QUIKPILOT_TURN_RECOVERY === "off";
46074
- }
46075
- function shouldRecover(input) {
46076
- return !(input.off ?? turnRecoveryOff()) && !input.isFinal && input.consecutive < 1;
46077
- }
46078
- function recoveryAnswer(kind) {
46079
- const s = SENTENCES[kind];
46080
- return { rules: [RECOVERY_RULE], violations: [s.violation], message: s.message };
46081
- }
46082
- function repeatedLossDetail(kind, first) {
46083
- const now = kind === "cut_off" ? "cut off" : "too slow";
46084
- const before = first === "cut_off" ? "cut off" : "too slow";
46085
- return `a turn was ${before}, and the next one, after the AI was asked for a smaller step, was ${now} too`;
46086
- }
46087
-
46088
46284
  // src/targetingErrors.ts
46089
46285
  var DeniedPathError = class extends Error {
46090
46286
  constructor(message) {
@@ -46454,8 +46650,6 @@ var CodegenLoopFailure = class extends Error {
46454
46650
  summary;
46455
46651
  /** QUIKTR-1823 (`test_conflict_unreportable` only): where each such test is and which case it contradicts. Never a title. */
46456
46652
  unreportable;
46457
- /** QUIKTR-1853: a turn was lost straight after one that had been recovered (see `turnRecovery.ts`). */
46458
- afterRecovery;
46459
46653
  constructor(reason, runtimeCode, cause, detail, told) {
46460
46654
  super(`pilot.codegen loop failed: ${reason}${runtimeCode ? ` (${runtimeCode})` : ""}`);
46461
46655
  this.name = "CodegenLoopFailure";
@@ -46672,8 +46866,6 @@ async function runCodegenLoop(args2, deps) {
46672
46866
  let turns = 0;
46673
46867
  let noProgressStreak = 0;
46674
46868
  let forced = null;
46675
- let lostLast = null;
46676
- let lostStreak = 0;
46677
46869
  const started = now();
46678
46870
  let toCheckList = null;
46679
46871
  const toCheck = () => toCheckList ??= (args2.testsToCheck?.() ?? []).slice(0, 10);
@@ -46816,22 +47008,6 @@ async function runCodegenLoop(args2, deps) {
46816
47008
  return null;
46817
47009
  };
46818
47010
  log({ event: "codegen.loop_start", maxTurns: limits.maxTurns, maxToolCalls: limits.maxToolCalls, listingFiles: args2.listing.length });
46819
- const loseTurn = (turn, kind, isFinalTurn, runtimeCode, elapsedMs) => {
46820
- const reason = kind === "cut_off" ? "output_too_large" : "turn_timeout";
46821
- if (!shouldRecover({ isFinal: isFinalTurn, consecutive: lostStreak })) {
46822
- const again = lostLast !== null && lostStreak > 0;
46823
- const failure = new CodegenLoopFailure(reason, runtimeCode, void 0, again ? repeatedLossDetail(kind, lostLast) : void 0);
46824
- if (again) failure.afterRecovery = true;
46825
- return failure;
46826
- }
46827
- lostStreak += 1;
46828
- lostLast = kind;
46829
- refusedTurns.push({ turn, rules: [RECOVERY_RULE] });
46830
- transcript.push({ turn, toolCalls: [], refused: recoveryAnswer(kind) });
46831
- log({ event: "codegen.loop_recovered", turn, reason, ...runtimeCode ? { runtimeCode } : {}, elapsedMs });
46832
- forced = settleNextTurn(turn, forced);
46833
- return true;
46834
- };
46835
47011
  try {
46836
47012
  for (let turn = 1; turn <= limits.maxTurns; turn++) {
46837
47013
  turns = turn;
@@ -46853,13 +47029,7 @@ async function runCodegenLoop(args2, deps) {
46853
47029
  try {
46854
47030
  envelope = await deps.post(contextData, AbortSignal.timeout(turnTimeoutFor(turn, turnTimeoutMs, deps.turnTimeoutMs !== void 0)));
46855
47031
  } catch (err2) {
46856
- const lost = classifyTransport2(err2);
46857
- if (lost.reason === "turn_timeout") {
46858
- const handled = loseTurn(turn, "slow", isFinal, void 0, now() - turnStarted);
46859
- if (handled === true) continue;
46860
- throw handled;
46861
- }
46862
- throw lost;
47032
+ throw classifyTransport2(err2);
46863
47033
  }
46864
47034
  usage.record(turn, contextData, requestTokens, envelope, now() - turnStarted);
46865
47035
  const code = envelope?.errorCode;
@@ -46880,12 +47050,7 @@ async function runCodegenLoop(args2, deps) {
46880
47050
  const fallbackText = `pilot.codegen failed: ${runtimeCode}`;
46881
47051
  throw new SafetyRefusalError(inner?.message ?? fallbackText, inner?.summary ?? fallbackText);
46882
47052
  }
46883
- if (runtimeCode && OUTPUT_TOO_LARGE_CODES.has(runtimeCode)) {
46884
- const handled = loseTurn(turn, "cut_off", isFinal, runtimeCode, now() - turnStarted);
46885
- if (handled === true) continue;
46886
- throw handled;
46887
- }
46888
- throw new CodegenLoopFailure("runtime_failed", runtimeCode);
47053
+ throw new CodegenLoopFailure(runtimeCode && OUTPUT_TOO_LARGE_CODES.has(runtimeCode) ? "output_too_large" : "runtime_failed", runtimeCode);
46889
47054
  }
46890
47055
  let body2;
46891
47056
  try {
@@ -46893,7 +47058,6 @@ async function runCodegenLoop(args2, deps) {
46893
47058
  } catch (err2) {
46894
47059
  throw new CodegenLoopFailure("bad_reply", void 0, err2);
46895
47060
  }
46896
- lostStreak = 0;
46897
47061
  const reasonText = typeof body2.reasoning === "string" ? body2.reasoning.slice(0, limits.maxReasoningChars) : void 0;
46898
47062
  if (body2.outcome === REFUSED_OUTCOME) {
46899
47063
  const answer = readRefusedAnswer(body2);
@@ -47626,12 +47790,12 @@ var GENERIC_NAMES = /* @__PURE__ */ new Set(["main", "init", "test", "tests", "s
47626
47790
  function lookSymbolsOf(findings) {
47627
47791
  const out2 = /* @__PURE__ */ new Map();
47628
47792
  if (!findings) return out2;
47629
- const add = (path, name2) => {
47793
+ const add2 = (path, name2) => {
47630
47794
  const list2 = out2.get(path) ?? out2.set(path, []).get(path);
47631
47795
  if (!list2.includes(name2)) list2.push(name2);
47632
47796
  };
47633
- for (const f of findings.files) for (const s of f.symbols) add(f.path, s);
47634
- for (const c of findings.callPath) add(c.path, c.symbol);
47797
+ for (const f of findings.files) for (const s of f.symbols) add2(f.path, s);
47798
+ for (const c of findings.callPath) add2(c.path, c.symbol);
47635
47799
  return out2;
47636
47800
  }
47637
47801
  var baseNoExt = (p) => import_node_path18.posix.basename(p).replace(/\.[^.]+$/, "");
@@ -47656,7 +47820,7 @@ var squash = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, "");
47656
47820
  function mentionsOf(names) {
47657
47821
  const out2 = [];
47658
47822
  const seen = /* @__PURE__ */ new Set();
47659
- const add = (m) => {
47823
+ const add2 = (m) => {
47660
47824
  const key = `${m.word ?? ""}|${m.squashed ?? ""}`;
47661
47825
  if (!seen.has(key)) {
47662
47826
  seen.add(key);
@@ -47668,11 +47832,11 @@ function mentionsOf(names) {
47668
47832
  const tokens = splitName(name2);
47669
47833
  if (tokens.length >= 2) {
47670
47834
  const two = squash(tokens.slice(0, 2).join(""));
47671
- if (two.length >= 9) add({ squashed: two });
47835
+ if (two.length >= 9) add2({ squashed: two });
47672
47836
  const all = squash(name2);
47673
- if (all.length >= 9) add({ squashed: all });
47837
+ if (all.length >= 9) add2({ squashed: all });
47674
47838
  } else {
47675
- add({ word: name2 });
47839
+ add2({ word: name2 });
47676
47840
  }
47677
47841
  }
47678
47842
  return out2;
@@ -48211,12 +48375,12 @@ function testsToCheck(i3) {
48211
48375
  if (code.length === 0 || limit === 0) return [];
48212
48376
  const taken = new Set(i3.targets.map((t) => t.path));
48213
48377
  const out2 = [];
48214
- const add = (path) => {
48378
+ const add2 = (path) => {
48215
48379
  if (out2.length < limit && !taken.has(path) && !out2.includes(path)) out2.push(path);
48216
48380
  };
48217
- for (const t of code) for (const path of pairedTestPaths(t.path, world.listing, world.isTest)) add(path);
48381
+ for (const t of code) for (const path of pairedTestPaths(t.path, world.listing, world.isTest)) add2(path);
48218
48382
  for (const t of code) {
48219
- for (const path of testsImporting({ target: t.path, listing: world.listing, corpus: world.corpus, mapSpecifier: world.mapSpecifier, limit, isTest: world.isTest })) add(path);
48383
+ for (const path of testsImporting({ target: t.path, listing: world.listing, corpus: world.corpus, mapSpecifier: world.mapSpecifier, limit, isTest: world.isTest })) add2(path);
48220
48384
  }
48221
48385
  if (out2.length < SECOND_HOP_BELOW) {
48222
48386
  for (const t of code) {
@@ -48232,7 +48396,7 @@ function testsToCheck(i3) {
48232
48396
  readRel: i3.readRel,
48233
48397
  deniedPaths: i3.deniedPaths
48234
48398
  }))
48235
- add(path);
48399
+ add2(path);
48236
48400
  }
48237
48401
  }
48238
48402
  const other = code.map((t) => t.path).filter((path) => languageOf(path) !== null);
@@ -48246,7 +48410,7 @@ function testsToCheck(i3) {
48246
48410
  limit,
48247
48411
  ...i3.lookSymbols ? { lookSymbols: i3.lookSymbols } : {}
48248
48412
  });
48249
- for (const hit of reached) add(hit.path);
48413
+ for (const hit of reached) add2(hit.path);
48250
48414
  }
48251
48415
  return out2;
48252
48416
  }
@@ -48619,7 +48783,7 @@ async function runCodegenStep(p) {
48619
48783
  return finish(first.done);
48620
48784
  }
48621
48785
  const f1 = first.failure;
48622
- 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 });
48786
+ log({ event: "codegen.attempt_end", attempt: 1, outcome: "failed", reason: f1.reason, turns: f1.summary?.turns ?? 0, toolCalls: f1.summary?.toolCalls ?? 0, durationMs: firstMs });
48623
48787
  const said = f1.detail ? `: ${f1.detail}` : "";
48624
48788
  if (f1.reason === "contract_rejected") {
48625
48789
  p.out.loop = buildCodegenLoopRecord({ ...f1.summary ?? NO_SUMMARY, stopReason: "fallback", fellBack: true, fallbackReason: f1.reason });
@@ -48661,7 +48825,7 @@ async function runCodegenStep(p) {
48661
48825
  return finish(second.done, [firstRecord, { n: 2, outcome: "finished", turns: second.done.summary.turns, toolCalls: second.done.summary.toolCalls }]);
48662
48826
  }
48663
48827
  const f2 = second.failure;
48664
- 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 });
48828
+ log({ event: "codegen.attempt_end", attempt: 2, outcome: "failed", reason: f2.reason, turns: f2.summary?.turns ?? 0, toolCalls: f2.summary?.toolCalls ?? 0, durationMs: secondMs });
48665
48829
  throw lose(p, f2.summary, [firstRecord, failedAttempt(2, f2)], f2.reason === "out_of_time" ? "out_of_time" : "failed", f2.unreportable);
48666
48830
  }
48667
48831
 
@@ -49556,14 +49720,14 @@ function approvedTestsFailing(input) {
49556
49720
  }
49557
49721
  return out2;
49558
49722
  }
49559
- var clip3 = (s, max) => s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
49723
+ var clip4 = (s, max) => s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
49560
49724
  function misfitSentence(misfits, max = 600) {
49561
49725
  const parts2 = misfits.map((m) => {
49562
49726
  const rows = m.totalRows > 1 ? ` does not fit ${m.failingRows} of its ${m.totalRows} rows` : " does not fit: the test still fails";
49563
49727
  const now = m.examples[0] ? ` (now: "${m.examples[0]}")` : "";
49564
- return `the test change approved for ${m.path}: "${clip3(m.testTitle, 120)}"${rows}${now}`;
49728
+ return `the test change approved for ${m.path}: "${clip4(m.testTitle, 120)}"${rows}${now}`;
49565
49729
  });
49566
- return clip3(parts2.join("; "), max);
49730
+ return clip4(parts2.join("; "), max);
49567
49731
  }
49568
49732
 
49569
49733
  // src/testVerification.ts
@@ -49636,7 +49800,7 @@ function describeAutomationCoverageViolations(check) {
49636
49800
  var estraverse5 = __toESM2(require_estraverse());
49637
49801
  var MAX_UNSUPPLIED_ENTRIES = 10;
49638
49802
  var MAX_UNSUPPLIED_NAMES = 5;
49639
- var MAX_NAME_CHARS2 = 80;
49803
+ var MAX_NAME_CHARS3 = 80;
49640
49804
  var MAX_FUNCTION_CHARS = 120;
49641
49805
  var FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
49642
49806
  var IDENTIFIER_NAME = /^[A-Za-z_$][\w$]*$/;
@@ -49777,7 +49941,7 @@ function findUnsuppliedInputs(input) {
49777
49941
  if (isCallback(site)) continue;
49778
49942
  const names = [];
49779
49943
  for (const { name: name2 } of readsOf(site)) {
49780
- if (!IDENTIFIER_NAME.test(name2) || name2.length > MAX_NAME_CHARS2) continue;
49944
+ if (!IDENTIFIER_NAME.test(name2) || name2.length > MAX_NAME_CHARS3) continue;
49781
49945
  if (known.has(name2) || supplied.has(name2) || names.includes(name2)) continue;
49782
49946
  names.push(name2);
49783
49947
  }
@@ -50141,7 +50305,7 @@ var MAX_ENTRY_CHARS = 200;
50141
50305
  var inside = (path, root) => root === "" || path === root || path.startsWith(`${root}/`);
50142
50306
  var cap = (s) => s.length <= MAX_ENTRY_CHARS ? s : `${s.slice(0, MAX_ENTRY_CHARS - 1)}\u2026`;
50143
50307
  var parentOf2 = (d) => d.includes("/") ? d.slice(0, d.lastIndexOf("/")) : "";
50144
- function clip4(text3, max) {
50308
+ function clip5(text3, max) {
50145
50309
  if (text3.length <= max) return { text: text3, truncated: false };
50146
50310
  const cut = text3.slice(0, max);
50147
50311
  const nl = cut.lastIndexOf("\n");
@@ -50159,7 +50323,7 @@ function guidanceFiles(i3, perFile2, total) {
50159
50323
  if (!tracked.has(path) || matchesDeniedPath(path, denied)) continue;
50160
50324
  const raw = i3.readText(path);
50161
50325
  if (raw === null || raw.trim() === "") continue;
50162
- const clipped = clip4(i3.scrub(raw.replace(/\r\n/g, "\n")).trim(), Math.min(perFile2, left));
50326
+ const clipped = clip5(i3.scrub(raw.replace(/\r\n/g, "\n")).trim(), Math.min(perFile2, left));
50163
50327
  out2.push({ path, ...clipped });
50164
50328
  left -= clipped.text.length;
50165
50329
  }
@@ -50643,7 +50807,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
50643
50807
  var REPORT_COPY = "final-test-report.xml";
50644
50808
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
50645
50809
  var MAX_FILES = 200;
50646
- var RUNNER_VERSION = true ? "9.3.0-rc.55" : "dev";
50810
+ var RUNNER_VERSION = true ? "9.3.0-rc.56" : "dev";
50647
50811
  function safeDestination(base, repoPath) {
50648
50812
  if (!repoPath || (0, import_node_path25.isAbsolute)(repoPath)) return null;
50649
50813
  const destination = (0, import_node_path25.resolve)(base, repoPath);
@@ -51305,6 +51469,7 @@ async function run2(env2) {
51305
51469
  const writeRoot = normaliseWorkspaceRoot(packet.workspaceRoot);
51306
51470
  scopeRoot = writeRoot;
51307
51471
  const workspaceListing = listWorkspaceFiles(writeRoot === "" ? null : writeRoot);
51472
+ await preloadLanguages(workspaceListing);
51308
51473
  const readCheckoutText2 = (path) => {
51309
51474
  try {
51310
51475
  return (0, import_node_fs25.readFileSync)(path, "utf8");