@quikit/quikpilot-runner 9.3.0-rc.75 → 9.3.0-rc.76
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/README.md +319 -313
- package/dist/index.js +2085 -376
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3112,11 +3112,11 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
3112
3112
|
/**
|
|
3113
3113
|
* Get the node type id for a node type name.
|
|
3114
3114
|
*/
|
|
3115
|
-
idForNodeType(type,
|
|
3115
|
+
idForNodeType(type, named2) {
|
|
3116
3116
|
const typeLength = C.lengthBytesUTF8(type);
|
|
3117
3117
|
const typeAddress = C._malloc(typeLength + 1);
|
|
3118
3118
|
C.stringToUTF8(type, typeAddress, typeLength + 1);
|
|
3119
|
-
const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength,
|
|
3119
|
+
const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named2 ? 1 : 0);
|
|
3120
3120
|
C._free(typeAddress);
|
|
3121
3121
|
return result || null;
|
|
3122
3122
|
}
|
|
@@ -3552,9 +3552,9 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
3552
3552
|
});
|
|
3553
3553
|
} else {
|
|
3554
3554
|
const captureName = steps[1].name;
|
|
3555
|
-
const
|
|
3556
|
-
const matches = /* @__PURE__ */ __name((n) => n.text ===
|
|
3557
|
-
const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !==
|
|
3555
|
+
const stringValue2 = steps[2].value;
|
|
3556
|
+
const matches = /* @__PURE__ */ __name((n) => n.text === stringValue2, "matches");
|
|
3557
|
+
const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !== stringValue2, "doesNotMatch");
|
|
3558
3558
|
textPredicates[index].push((captures) => {
|
|
3559
3559
|
const nodes = [];
|
|
3560
3560
|
for (const c of captures) {
|
|
@@ -17613,12 +17613,12 @@ var require_trace_mapping_umd = __commonJS2({
|
|
|
17613
17613
|
function binarySearch(haystack, needle, low, high) {
|
|
17614
17614
|
while (low <= high) {
|
|
17615
17615
|
const mid = low + (high - low >> 1);
|
|
17616
|
-
const
|
|
17617
|
-
if (
|
|
17616
|
+
const cmp2 = haystack[mid][COLUMN] - needle;
|
|
17617
|
+
if (cmp2 === 0) {
|
|
17618
17618
|
found = true;
|
|
17619
17619
|
return mid;
|
|
17620
17620
|
}
|
|
17621
|
-
if (
|
|
17621
|
+
if (cmp2 < 0) {
|
|
17622
17622
|
low = mid + 1;
|
|
17623
17623
|
} else {
|
|
17624
17624
|
high = mid - 1;
|
|
@@ -28530,7 +28530,7 @@ function readRunnerEnv(env2 = process.env) {
|
|
|
28530
28530
|
var import_node_child_process4 = require("node:child_process");
|
|
28531
28531
|
var import_node_fs5 = require("node:fs");
|
|
28532
28532
|
var import_node_os2 = require("node:os");
|
|
28533
|
-
var
|
|
28533
|
+
var import_node_path7 = require("node:path");
|
|
28534
28534
|
|
|
28535
28535
|
// src/editsApply.ts
|
|
28536
28536
|
function detectLineEnding(text3) {
|
|
@@ -28628,7 +28628,7 @@ function applyEdits(originalLf, edits) {
|
|
|
28628
28628
|
var import_node_child_process3 = require("node:child_process");
|
|
28629
28629
|
var import_node_fs4 = require("node:fs");
|
|
28630
28630
|
var import_node_os = require("node:os");
|
|
28631
|
-
var
|
|
28631
|
+
var import_node_path6 = require("node:path");
|
|
28632
28632
|
|
|
28633
28633
|
// src/git.ts
|
|
28634
28634
|
var import_node_child_process = require("node:child_process");
|
|
@@ -29336,16 +29336,16 @@ function firstErrorRow(lang, text3) {
|
|
|
29336
29336
|
const root = tree.rootNode;
|
|
29337
29337
|
if (!root.hasError) return "ok";
|
|
29338
29338
|
let first = null;
|
|
29339
|
-
const
|
|
29339
|
+
const walk3 = (n) => {
|
|
29340
29340
|
if (first !== null) return;
|
|
29341
29341
|
if (n.type === "ERROR" || n.isMissing) {
|
|
29342
29342
|
first = n;
|
|
29343
29343
|
return;
|
|
29344
29344
|
}
|
|
29345
29345
|
if (!n.hasError) return;
|
|
29346
|
-
for (const c of n.children)
|
|
29346
|
+
for (const c of n.children) walk3(c);
|
|
29347
29347
|
};
|
|
29348
|
-
|
|
29348
|
+
walk3(root);
|
|
29349
29349
|
const at2 = first;
|
|
29350
29350
|
return { line: (at2?.startPosition.row ?? 0) + 1 };
|
|
29351
29351
|
} catch {
|
|
@@ -35195,15 +35195,15 @@ function isOtherCheck(lang, n) {
|
|
|
35195
35195
|
}
|
|
35196
35196
|
function countChecks(lang, spec, node) {
|
|
35197
35197
|
let count3 = 0;
|
|
35198
|
-
const
|
|
35198
|
+
const walk3 = (n) => {
|
|
35199
35199
|
if (spec.assertion(n)) {
|
|
35200
35200
|
count3 += 1;
|
|
35201
35201
|
return;
|
|
35202
35202
|
}
|
|
35203
35203
|
if (isOtherCheck(lang, n)) count3 += 1;
|
|
35204
|
-
for (const c of n.children)
|
|
35204
|
+
for (const c of n.children) walk3(c);
|
|
35205
35205
|
};
|
|
35206
|
-
|
|
35206
|
+
walk3(node);
|
|
35207
35207
|
return count3;
|
|
35208
35208
|
}
|
|
35209
35209
|
var SPECS = {
|
|
@@ -35277,7 +35277,7 @@ function shapeOf(spec, root, titleStart) {
|
|
|
35277
35277
|
if (token === LIT && out2[out2.length - 1] === LIT) return;
|
|
35278
35278
|
out2.push(token);
|
|
35279
35279
|
};
|
|
35280
|
-
const
|
|
35280
|
+
const walk3 = (n) => {
|
|
35281
35281
|
if (spec.comments.has(n.type) || spec.assertion(n)) return;
|
|
35282
35282
|
if (spec.literal(n) || spec.literalParts.has(n.type)) {
|
|
35283
35283
|
push2(LIT);
|
|
@@ -35295,12 +35295,12 @@ function shapeOf(spec, root, titleStart) {
|
|
|
35295
35295
|
if (block) push2("{");
|
|
35296
35296
|
for (const child of n.children) {
|
|
35297
35297
|
const before = out2.length;
|
|
35298
|
-
|
|
35298
|
+
walk3(child);
|
|
35299
35299
|
if (block && child.isNamed && out2.length > before) push2(";");
|
|
35300
35300
|
}
|
|
35301
35301
|
if (block) push2("}");
|
|
35302
35302
|
};
|
|
35303
|
-
|
|
35303
|
+
walk3(root);
|
|
35304
35304
|
return out2.join(SEP);
|
|
35305
35305
|
}
|
|
35306
35306
|
function locatePython(root, add2) {
|
|
@@ -35636,9 +35636,1023 @@ function testEditOverreach(input) {
|
|
|
35636
35636
|
return null;
|
|
35637
35637
|
}
|
|
35638
35638
|
|
|
35639
|
+
// src/setupAdded.ts
|
|
35640
|
+
var no = (why) => ({ ok: false, why });
|
|
35641
|
+
var JS_SKIP_KEYS = /* @__PURE__ */ new Set(["type", "start", "end", "range", "loc", "raw"]);
|
|
35642
|
+
function fromEstree(node, field2) {
|
|
35643
|
+
const prims = [];
|
|
35644
|
+
const kids = [];
|
|
35645
|
+
const start3 = node.start;
|
|
35646
|
+
const end = node.end;
|
|
35647
|
+
for (const key of Object.keys(node)) {
|
|
35648
|
+
if (JS_SKIP_KEYS.has(key)) continue;
|
|
35649
|
+
const v = node[key];
|
|
35650
|
+
if (v === null || v === void 0) {
|
|
35651
|
+
prims.push(`${key}=-`);
|
|
35652
|
+
} else if (Array.isArray(v)) {
|
|
35653
|
+
const items = v.map(
|
|
35654
|
+
(item) => item === null ? { t: "Hole", p: "", s: start3, e: start3, c: [], named: true } : fromEstree(item)
|
|
35655
|
+
);
|
|
35656
|
+
kids.push({ t: `${node.type}.${key}`, p: "", s: start3, e: end, c: items, f: key, named: true });
|
|
35657
|
+
} else if (typeof v === "object" && typeof v.type === "string") {
|
|
35658
|
+
kids.push(fromEstree(v, key));
|
|
35659
|
+
} else if (typeof v === "bigint") {
|
|
35660
|
+
prims.push(`${key}=${v.toString()}n`);
|
|
35661
|
+
} else {
|
|
35662
|
+
prims.push(`${key}=${JSON.stringify(v)}`);
|
|
35663
|
+
}
|
|
35664
|
+
}
|
|
35665
|
+
const type = node.type;
|
|
35666
|
+
const x = type === "Identifier" ? String(node.name) : type === "Literal" ? String(node.value) : void 0;
|
|
35667
|
+
return { t: type, p: prims.join(","), ...x !== void 0 ? { x } : {}, s: start3, e: end, c: kids, ...field2 ? { f: field2 } : {}, named: true };
|
|
35668
|
+
}
|
|
35669
|
+
var TS_FIELDS = [
|
|
35670
|
+
"name",
|
|
35671
|
+
"body",
|
|
35672
|
+
"function",
|
|
35673
|
+
"arguments",
|
|
35674
|
+
"left",
|
|
35675
|
+
"right",
|
|
35676
|
+
"object",
|
|
35677
|
+
"field",
|
|
35678
|
+
"operand",
|
|
35679
|
+
"parameters",
|
|
35680
|
+
"type",
|
|
35681
|
+
"value",
|
|
35682
|
+
"key",
|
|
35683
|
+
"declarator",
|
|
35684
|
+
"attribute",
|
|
35685
|
+
"definition",
|
|
35686
|
+
"result",
|
|
35687
|
+
"alias",
|
|
35688
|
+
"return_type"
|
|
35689
|
+
];
|
|
35690
|
+
var TS_COMMENTS = /* @__PURE__ */ new Set(["comment", "line_comment", "block_comment"]);
|
|
35691
|
+
function fromTs(n, field2) {
|
|
35692
|
+
const kids = n.children.filter((c) => !TS_COMMENTS.has(c.type));
|
|
35693
|
+
const fields = /* @__PURE__ */ new Map();
|
|
35694
|
+
if (n.childCount > 0) {
|
|
35695
|
+
for (const name2 of TS_FIELDS) {
|
|
35696
|
+
const fc = n.childForFieldName(name2);
|
|
35697
|
+
if (!fc) continue;
|
|
35698
|
+
const i3 = kids.findIndex((k) => k.startIndex === fc.startIndex && k.endIndex === fc.endIndex && k.type === fc.type);
|
|
35699
|
+
if (i3 >= 0 && !fields.has(i3)) fields.set(i3, name2);
|
|
35700
|
+
}
|
|
35701
|
+
}
|
|
35702
|
+
const leaf = n.childCount === 0;
|
|
35703
|
+
return {
|
|
35704
|
+
t: n.type,
|
|
35705
|
+
p: leaf ? n.text : "",
|
|
35706
|
+
...leaf ? { x: n.text } : {},
|
|
35707
|
+
s: n.startIndex,
|
|
35708
|
+
e: n.endIndex,
|
|
35709
|
+
c: kids.map((k, i3) => fromTs(k, fields.get(i3))),
|
|
35710
|
+
...field2 ? { f: field2 } : {},
|
|
35711
|
+
named: n.isNamed
|
|
35712
|
+
};
|
|
35713
|
+
}
|
|
35714
|
+
function langOf(path) {
|
|
35715
|
+
const ts = langOfPath(path);
|
|
35716
|
+
if (ts === "python" || ts === "go" || ts === "java") return ts;
|
|
35717
|
+
if (ts !== null) return null;
|
|
35718
|
+
return /\.(?:[cm]?js|jsx|[cm]?ts|tsx)$/i.test(path) ? "js" : null;
|
|
35719
|
+
}
|
|
35720
|
+
function treeOf(path, text3, lang) {
|
|
35721
|
+
if (lang === "js") {
|
|
35722
|
+
const parsed = parseProgram(path, text3);
|
|
35723
|
+
return parsed ? fromEstree(parsed.ast) : null;
|
|
35724
|
+
}
|
|
35725
|
+
return parseWith(lang, text3, (root) => fromTs(root));
|
|
35726
|
+
}
|
|
35727
|
+
var canonMemo = /* @__PURE__ */ new WeakMap();
|
|
35728
|
+
function canon(n) {
|
|
35729
|
+
let s = canonMemo.get(n);
|
|
35730
|
+
if (s === void 0) {
|
|
35731
|
+
s = `${n.t}(${n.p})${n.c.length > 0 ? `[${n.c.map(canon).join(",")}]` : ""}`;
|
|
35732
|
+
canonMemo.set(n, s);
|
|
35733
|
+
}
|
|
35734
|
+
return s;
|
|
35735
|
+
}
|
|
35736
|
+
var kid = (n, field2) => n.c.find((c) => c.f === field2);
|
|
35737
|
+
var named = (n) => n.c.filter((c) => c.named);
|
|
35738
|
+
function walk(n, visit, parent = null) {
|
|
35739
|
+
if (visit(n, parent) === false) return;
|
|
35740
|
+
for (const c of n.c) walk(c, visit, n);
|
|
35741
|
+
}
|
|
35742
|
+
var CONTROL = "an added line is control flow (if, try, return, a loop or similar), which could skip or wrap what is there";
|
|
35743
|
+
var NOT_ADDABLE = "an added line is not a call, a declaration of a new name or a check";
|
|
35744
|
+
var SHADOWS = "an added name hides or reuses a name the file already uses";
|
|
35745
|
+
var ASSIGNS = "an added line assigns to something that already exists";
|
|
35746
|
+
var SKIPS = "an added line skips or narrows tests";
|
|
35747
|
+
var RESETS = "an added line resets mocks or mocks a module again";
|
|
35748
|
+
var REARRANGES = "an added line arranges again a mock the code already arranges";
|
|
35749
|
+
function jsPath(n) {
|
|
35750
|
+
if (!n) return "?";
|
|
35751
|
+
if (n.t === "Identifier") return n.x ?? "?";
|
|
35752
|
+
if (n.t === "ThisExpression") return "this";
|
|
35753
|
+
if (n.t === "ChainExpression") return jsPath(kid(n, "expression"));
|
|
35754
|
+
if (n.t === "MemberExpression") {
|
|
35755
|
+
const prop = kid(n, "property");
|
|
35756
|
+
const computed = n.p.includes("computed=true");
|
|
35757
|
+
const name2 = !computed && prop?.t === "Identifier" ? prop.x : prop?.t === "Literal" ? prop.x : "?";
|
|
35758
|
+
return `${jsPath(kid(n, "object"))}.${name2}`;
|
|
35759
|
+
}
|
|
35760
|
+
if (n.t === "CallExpression") return `${jsPath(kid(n, "callee"))}()`;
|
|
35761
|
+
return "?";
|
|
35762
|
+
}
|
|
35763
|
+
var jsArgs2 = (call) => kid(call, "arguments")?.c ?? [];
|
|
35764
|
+
var JS_MOCK_ARRANGE = /* @__PURE__ */ new Set([
|
|
35765
|
+
"mockResolvedValue",
|
|
35766
|
+
"mockResolvedValueOnce",
|
|
35767
|
+
"mockReturnValue",
|
|
35768
|
+
"mockReturnValueOnce",
|
|
35769
|
+
"mockImplementation",
|
|
35770
|
+
"mockImplementationOnce",
|
|
35771
|
+
"mockRejectedValue",
|
|
35772
|
+
"mockRejectedValueOnce",
|
|
35773
|
+
"mockReturnThis",
|
|
35774
|
+
"calledWith"
|
|
35775
|
+
]);
|
|
35776
|
+
var JS_MOCKED = /* @__PURE__ */ new Set(["vi.mocked", "jest.mocked", "mocked"]);
|
|
35777
|
+
function jsTarget(obj) {
|
|
35778
|
+
if (!obj) return "?";
|
|
35779
|
+
if (obj.t === "ChainExpression") return jsTarget(kid(obj, "expression"));
|
|
35780
|
+
if (obj.t === "CallExpression") {
|
|
35781
|
+
const callee = kid(obj, "callee");
|
|
35782
|
+
if (JS_MOCKED.has(jsPath(callee))) return jsTarget(jsArgs2(obj)[0]);
|
|
35783
|
+
if (callee?.t === "MemberExpression" && JS_MOCK_ARRANGE.has(kid(callee, "property")?.x ?? "")) return jsTarget(kid(callee, "object"));
|
|
35784
|
+
}
|
|
35785
|
+
return jsPath(obj);
|
|
35786
|
+
}
|
|
35787
|
+
var JS_SKIP_WORDS = /* @__PURE__ */ new Set(["skip", "only", "todo", "skipIf", "runIf", "fails"]);
|
|
35788
|
+
var JS_SKIP_ROOTS = /* @__PURE__ */ new Set(["xit", "xtest", "xdescribe", "fit", "fdescribe", "ftest"]);
|
|
35789
|
+
var JS_TEST_ROOTS = /* @__PURE__ */ new Set(["it", "test", "describe", "suite", "context", "bench"]);
|
|
35790
|
+
var JS_RESETS = /* @__PURE__ */ new Set([
|
|
35791
|
+
"mock",
|
|
35792
|
+
"doMock",
|
|
35793
|
+
"unmock",
|
|
35794
|
+
"doUnmock",
|
|
35795
|
+
"dontMock",
|
|
35796
|
+
"resetModules",
|
|
35797
|
+
"isolateModules",
|
|
35798
|
+
"isolateModulesAsync",
|
|
35799
|
+
"restoreAllMocks",
|
|
35800
|
+
"resetAllMocks",
|
|
35801
|
+
"clearAllMocks",
|
|
35802
|
+
"unstubAllGlobals",
|
|
35803
|
+
"unstubAllEnvs",
|
|
35804
|
+
"resetConfig"
|
|
35805
|
+
]);
|
|
35806
|
+
var JS_RESET_METHODS = /* @__PURE__ */ new Set(["mockReset", "mockClear", "mockRestore"]);
|
|
35807
|
+
var JS_RESET_CALLS = /* @__PURE__ */ new Set(["mockReset", "mockClear", "resetAllWhenMocks"]);
|
|
35808
|
+
var JS_CONTROL = /* @__PURE__ */ new Set([
|
|
35809
|
+
"IfStatement",
|
|
35810
|
+
"TryStatement",
|
|
35811
|
+
"ReturnStatement",
|
|
35812
|
+
"ForStatement",
|
|
35813
|
+
"ForInStatement",
|
|
35814
|
+
"ForOfStatement",
|
|
35815
|
+
"WhileStatement",
|
|
35816
|
+
"DoWhileStatement",
|
|
35817
|
+
"SwitchStatement",
|
|
35818
|
+
"ThrowStatement",
|
|
35819
|
+
"BreakStatement",
|
|
35820
|
+
"ContinueStatement",
|
|
35821
|
+
"LabeledStatement",
|
|
35822
|
+
"WithStatement",
|
|
35823
|
+
"BlockStatement",
|
|
35824
|
+
"StaticBlock"
|
|
35825
|
+
]);
|
|
35826
|
+
var JS_EXPECT_ROOTS = /* @__PURE__ */ new Set(["expect", "assert", "expectTypeOf", "assertType"]);
|
|
35827
|
+
function jsBoundNames(pattern, out2 = []) {
|
|
35828
|
+
if (!pattern) return out2;
|
|
35829
|
+
if (pattern.t === "Identifier") out2.push(pattern.x ?? "");
|
|
35830
|
+
else if (pattern.t === "ObjectPattern") for (const p of kid(pattern, "properties")?.c ?? []) jsBoundNames(p.t === "RestElement" ? kid(p, "argument") : kid(p, "value"), out2);
|
|
35831
|
+
else if (pattern.t === "ArrayPattern") for (const e of kid(pattern, "elements")?.c ?? []) jsBoundNames(e, out2);
|
|
35832
|
+
else if (pattern.t === "RestElement") jsBoundNames(kid(pattern, "argument"), out2);
|
|
35833
|
+
else if (pattern.t === "AssignmentPattern") jsBoundNames(kid(pattern, "left"), out2);
|
|
35834
|
+
return out2;
|
|
35835
|
+
}
|
|
35836
|
+
function jsChainRoot(n) {
|
|
35837
|
+
let e = n;
|
|
35838
|
+
while (e) {
|
|
35839
|
+
if (e.t === "AwaitExpression") e = kid(e, "argument");
|
|
35840
|
+
else if (e.t === "ChainExpression") e = kid(e, "expression");
|
|
35841
|
+
else if (e.t === "CallExpression") e = kid(e, "callee");
|
|
35842
|
+
else if (e.t === "MemberExpression") e = kid(e, "object");
|
|
35843
|
+
else break;
|
|
35844
|
+
}
|
|
35845
|
+
return e?.t === "Identifier" ? e.x ?? null : null;
|
|
35846
|
+
}
|
|
35847
|
+
var JS = {
|
|
35848
|
+
isBlock: (n) => n.t === "BlockStatement.body" || n.t === "Program.body" || n.t === "StaticBlock.body" || n.t === "ClassBody.body",
|
|
35849
|
+
statements: (n) => n.c,
|
|
35850
|
+
isObject: (n) => n.t === "ObjectExpression.properties",
|
|
35851
|
+
entryKey: (n) => {
|
|
35852
|
+
if (n.t !== "Property" || n.p.includes("computed=true")) return null;
|
|
35853
|
+
const key = kid(n, "key");
|
|
35854
|
+
return key?.t === "Identifier" || key?.t === "Literal" ? key.x ?? null : null;
|
|
35855
|
+
},
|
|
35856
|
+
isExpectation: (stmt) => stmt.t === "ExpressionStatement" && JS_EXPECT_ROOTS.has(jsChainRoot(kid(stmt, "expression")) ?? ""),
|
|
35857
|
+
insertion: (stmt) => {
|
|
35858
|
+
switch (stmt.t) {
|
|
35859
|
+
case "EmptyStatement":
|
|
35860
|
+
return { names: [] };
|
|
35861
|
+
case "ExpressionStatement": {
|
|
35862
|
+
let e = kid(stmt, "expression");
|
|
35863
|
+
if (e?.t === "AwaitExpression") e = kid(e, "argument");
|
|
35864
|
+
if (e?.t === "ChainExpression") e = kid(e, "expression");
|
|
35865
|
+
return e?.t === "CallExpression" ? { names: [] } : e?.t === "AssignmentExpression" || e?.t === "UpdateExpression" ? { refused: ASSIGNS } : { refused: NOT_ADDABLE };
|
|
35866
|
+
}
|
|
35867
|
+
case "VariableDeclaration":
|
|
35868
|
+
return { names: (kid(stmt, "declarations")?.c ?? []).flatMap((d) => jsBoundNames(kid(d, "id"))) };
|
|
35869
|
+
case "FunctionDeclaration":
|
|
35870
|
+
case "ClassDeclaration":
|
|
35871
|
+
return { names: [kid(stmt, "id")?.x ?? ""] };
|
|
35872
|
+
case "ImportDeclaration": {
|
|
35873
|
+
const specs = kid(stmt, "specifiers")?.c ?? [];
|
|
35874
|
+
return specs.length === 0 ? { refused: NOT_ADDABLE } : { names: specs.map((s) => kid(s, "local")?.x ?? "") };
|
|
35875
|
+
}
|
|
35876
|
+
case "ExportNamedDeclaration": {
|
|
35877
|
+
const decl = kid(stmt, "declaration");
|
|
35878
|
+
return decl ? JS.insertion(decl) : { refused: NOT_ADDABLE };
|
|
35879
|
+
}
|
|
35880
|
+
case "MethodDefinition":
|
|
35881
|
+
case "PropertyDefinition": {
|
|
35882
|
+
const key = kid(stmt, "key");
|
|
35883
|
+
return key?.t === "Identifier" && !stmt.p.includes("computed=true") ? { names: [key.x ?? ""] } : { refused: NOT_ADDABLE };
|
|
35884
|
+
}
|
|
35885
|
+
default:
|
|
35886
|
+
return { refused: JS_CONTROL.has(stmt.t) ? CONTROL : NOT_ADDABLE };
|
|
35887
|
+
}
|
|
35888
|
+
},
|
|
35889
|
+
isFunction: (n) => n.t === "ArrowFunctionExpression" || n.t === "FunctionExpression" || n.t === "FunctionDeclaration",
|
|
35890
|
+
isAssignment: (n) => n.t === "AssignmentExpression" || n.t === "UpdateExpression" || n.t === "UnaryExpression" && n.p.includes('operator="delete"'),
|
|
35891
|
+
callPath: (n) => n.t === "CallExpression" ? jsPath(kid(n, "callee")).split(".") : null,
|
|
35892
|
+
arranges: (n) => {
|
|
35893
|
+
if (n.t !== "CallExpression") return [];
|
|
35894
|
+
let callee = kid(n, "callee");
|
|
35895
|
+
if (callee?.t === "ChainExpression") callee = kid(callee, "expression");
|
|
35896
|
+
const path = jsPath(callee);
|
|
35897
|
+
const args2 = jsArgs2(n);
|
|
35898
|
+
if (path === "vi.spyOn" || path === "jest.spyOn") return [`${jsPath(args2[0])}.${args2[1]?.x ?? "?"}`];
|
|
35899
|
+
if (path === "vi.stubGlobal") return [`global:${args2[0]?.x ?? "?"}`];
|
|
35900
|
+
if (path === "vi.stubEnv") return [`env:${args2[0]?.x ?? "?"}`];
|
|
35901
|
+
if (path === "when") return [jsTarget(args2[0])];
|
|
35902
|
+
if (callee?.t === "MemberExpression" && JS_MOCK_ARRANGE.has(kid(callee, "property")?.x ?? "")) return [jsTarget(kid(callee, "object"))];
|
|
35903
|
+
return [];
|
|
35904
|
+
},
|
|
35905
|
+
// `it.skip`, `describe.only`, `test.todo`, `xit`, and a test's own context skipping it (`ctx.skip()`); a model called `todo` is not a test API.
|
|
35906
|
+
skipName: (path) => JS_SKIP_ROOTS.has(path[0] ?? "") || JS_TEST_ROOTS.has(path[0] ?? "") && path.slice(1).some((s) => JS_SKIP_WORDS.has(s)) || path.length === 2 && path[1] === "skip",
|
|
35907
|
+
resetName: (path) => (path[0] === "vi" || path[0] === "jest" || path[0] === "vitest") && path.length === 2 && JS_RESETS.has(path[1] ?? "") || path.length > 1 && JS_RESET_METHODS.has(path[path.length - 1] ?? "") || path.length === 1 && JS_RESET_CALLS.has(path[0] ?? ""),
|
|
35908
|
+
usedNames: (root) => {
|
|
35909
|
+
const names = /* @__PURE__ */ new Set();
|
|
35910
|
+
walk(root, (n, parent) => {
|
|
35911
|
+
if (n.t !== "Identifier") return;
|
|
35912
|
+
if (parent?.t === "MemberExpression" && n.f === "property" && !parent.p.includes("computed=true")) return;
|
|
35913
|
+
if (parent?.t === "Property" && n.f === "key" && !parent.p.includes("computed=true") && !parent.p.includes("shorthand=true")) return;
|
|
35914
|
+
names.add(n.x ?? "");
|
|
35915
|
+
});
|
|
35916
|
+
return names;
|
|
35917
|
+
}
|
|
35918
|
+
};
|
|
35919
|
+
function pyPath(n) {
|
|
35920
|
+
if (!n) return "?";
|
|
35921
|
+
if (n.t === "identifier") return n.x ?? "?";
|
|
35922
|
+
if (n.t === "attribute") return `${pyPath(kid(n, "object"))}.${kid(n, "attribute")?.x ?? "?"}`;
|
|
35923
|
+
if (n.t === "call") return `${pyPath(kid(n, "function"))}()`;
|
|
35924
|
+
return "?";
|
|
35925
|
+
}
|
|
35926
|
+
function stringValue(n) {
|
|
35927
|
+
if (!n) return "?";
|
|
35928
|
+
if (n.t === "string" || n.t === "interpreted_string_literal" || n.t === "raw_string_literal" || n.t === "string_literal") {
|
|
35929
|
+
return n.c.filter((c) => c.t === "string_content" || c.t === "interpreted_string_literal_content" || c.t === "string_fragment").map((c) => c.x ?? "").join("");
|
|
35930
|
+
}
|
|
35931
|
+
return textOf(n);
|
|
35932
|
+
}
|
|
35933
|
+
function textOf(n) {
|
|
35934
|
+
if (n.c.length === 0) return n.x ?? "";
|
|
35935
|
+
return n.c.map(textOf).join("");
|
|
35936
|
+
}
|
|
35937
|
+
var PY_CONTROL = /* @__PURE__ */ new Set([
|
|
35938
|
+
"if_statement",
|
|
35939
|
+
"for_statement",
|
|
35940
|
+
"while_statement",
|
|
35941
|
+
"try_statement",
|
|
35942
|
+
"with_statement",
|
|
35943
|
+
"return_statement",
|
|
35944
|
+
"raise_statement",
|
|
35945
|
+
"break_statement",
|
|
35946
|
+
"continue_statement",
|
|
35947
|
+
"match_statement"
|
|
35948
|
+
]);
|
|
35949
|
+
var PY_CHANGES = /* @__PURE__ */ new Set(["delete_statement", "global_statement", "nonlocal_statement", "augmented_assignment"]);
|
|
35950
|
+
var PY_SKIP_WORDS = /* @__PURE__ */ new Set(["skip", "skipif", "xfail", "skipTest", "importorskip", "skipIf", "skipUnless", "expectedFailure"]);
|
|
35951
|
+
var PY_RESET_WORDS = /* @__PURE__ */ new Set(["reset_mock", "stopall", "resetall", "undo", "reload", "stop"]);
|
|
35952
|
+
var PY_MOCK_ATTRS = /* @__PURE__ */ new Set(["return_value", "side_effect"]);
|
|
35953
|
+
function pyBound(n, out2 = []) {
|
|
35954
|
+
if (!n) return out2;
|
|
35955
|
+
if (n.t === "identifier") {
|
|
35956
|
+
out2.push(n.x ?? "");
|
|
35957
|
+
return out2;
|
|
35958
|
+
}
|
|
35959
|
+
if (n.t === "pattern_list" || n.t === "tuple_pattern" || n.t === "list_pattern") {
|
|
35960
|
+
for (const c of named(n)) if (pyBound(c, out2) === null) return null;
|
|
35961
|
+
return out2;
|
|
35962
|
+
}
|
|
35963
|
+
return null;
|
|
35964
|
+
}
|
|
35965
|
+
function pyCallArgs(call) {
|
|
35966
|
+
return named(kid(call, "arguments") ?? { t: "", p: "", s: 0, e: 0, c: [], named: true });
|
|
35967
|
+
}
|
|
35968
|
+
var PY = {
|
|
35969
|
+
isBlock: (n) => n.t === "block" || n.t === "module",
|
|
35970
|
+
statements: (n) => named(n),
|
|
35971
|
+
isObject: (n) => n.t === "dictionary",
|
|
35972
|
+
entryKey: (n) => n.t === "pair" ? canon(kid(n, "key") ?? n) : null,
|
|
35973
|
+
isExpectation: (stmt) => {
|
|
35974
|
+
if (stmt.t === "assert_statement") return true;
|
|
35975
|
+
if (stmt.t !== "expression_statement") return false;
|
|
35976
|
+
const call = named(stmt)[0];
|
|
35977
|
+
if (call?.t !== "call") return false;
|
|
35978
|
+
const path = pyPath(kid(call, "function")).split(".");
|
|
35979
|
+
return /^assert/i.test(path[path.length - 1] ?? "");
|
|
35980
|
+
},
|
|
35981
|
+
insertion: (stmt) => {
|
|
35982
|
+
if (stmt.t === "pass_statement") return { names: [] };
|
|
35983
|
+
if (stmt.t === "assert_statement") return { names: [] };
|
|
35984
|
+
if (stmt.t === "expression_statement") {
|
|
35985
|
+
let e = named(stmt)[0];
|
|
35986
|
+
if (e?.t === "await") e = named(e)[0];
|
|
35987
|
+
if (e?.t === "call" || e?.t === "string") return { names: [] };
|
|
35988
|
+
if (e?.t === "assignment") {
|
|
35989
|
+
const left = kid(e, "left");
|
|
35990
|
+
const bound = pyBound(left);
|
|
35991
|
+
if (bound) return { names: bound };
|
|
35992
|
+
if (left?.t === "attribute" && PY_MOCK_ATTRS.has(kid(left, "attribute")?.x ?? "")) return { names: [] };
|
|
35993
|
+
return { refused: ASSIGNS };
|
|
35994
|
+
}
|
|
35995
|
+
return { refused: e?.t === "augmented_assignment" ? ASSIGNS : NOT_ADDABLE };
|
|
35996
|
+
}
|
|
35997
|
+
if (stmt.t === "import_statement" || stmt.t === "import_from_statement") {
|
|
35998
|
+
const names = [];
|
|
35999
|
+
for (const c of stmt.c) {
|
|
36000
|
+
if (c.f !== "name") continue;
|
|
36001
|
+
if (c.t === "aliased_import") names.push(kid(c, "alias")?.x ?? "");
|
|
36002
|
+
else {
|
|
36003
|
+
const ids = c.c.filter((x) => x.t === "identifier");
|
|
36004
|
+
names.push((stmt.t === "import_statement" ? ids[0] : ids[ids.length - 1])?.x ?? "");
|
|
36005
|
+
}
|
|
36006
|
+
}
|
|
36007
|
+
return names.length > 0 ? { names } : { refused: NOT_ADDABLE };
|
|
36008
|
+
}
|
|
36009
|
+
if (stmt.t === "function_definition" || stmt.t === "class_definition") return { names: [kid(stmt, "name")?.x ?? ""] };
|
|
36010
|
+
if (stmt.t === "decorated_definition") {
|
|
36011
|
+
const def = kid(stmt, "definition");
|
|
36012
|
+
return def ? { names: [kid(def, "name")?.x ?? ""] } : { refused: NOT_ADDABLE };
|
|
36013
|
+
}
|
|
36014
|
+
if (PY_CHANGES.has(stmt.t)) return { refused: ASSIGNS };
|
|
36015
|
+
return { refused: PY_CONTROL.has(stmt.t) ? CONTROL : NOT_ADDABLE };
|
|
36016
|
+
},
|
|
36017
|
+
isFunction: (n) => n.t === "function_definition" || n.t === "lambda",
|
|
36018
|
+
isAssignment: (n) => n.t === "named_expression" || n.t === "augmented_assignment",
|
|
36019
|
+
callPath: (n) => n.t === "call" ? pyPath(kid(n, "function")).split(".") : n.t === "decorator" ? textOf(n).replace(/^@/, "").split("(")[0].split(".") : null,
|
|
36020
|
+
arranges: (n) => {
|
|
36021
|
+
if (n.t === "assignment") {
|
|
36022
|
+
const left = kid(n, "left");
|
|
36023
|
+
if (left?.t === "attribute" && PY_MOCK_ATTRS.has(kid(left, "attribute")?.x ?? "")) return [textOf(kid(left, "object")).replace(/\s+/g, "")];
|
|
36024
|
+
return [];
|
|
36025
|
+
}
|
|
36026
|
+
if (n.t !== "call") return [];
|
|
36027
|
+
const path = pyPath(kid(n, "function")).split(".");
|
|
36028
|
+
const last = path[path.length - 1] ?? "";
|
|
36029
|
+
const args2 = pyCallArgs(n).filter((a) => a.t !== "keyword_argument");
|
|
36030
|
+
const str = (a) => a?.t === "string";
|
|
36031
|
+
if (last === "setattr" || last === "object" && path[path.length - 2] === "patch") {
|
|
36032
|
+
if (str(args2[0])) return [stringValue(args2[0])];
|
|
36033
|
+
return [`${textOf(args2[0] ?? n).replace(/\s+/g, "")}.${stringValue(args2[1])}`];
|
|
36034
|
+
}
|
|
36035
|
+
if (last === "setitem") return [`${textOf(args2[0] ?? n).replace(/\s+/g, "")}[${stringValue(args2[1])}]`];
|
|
36036
|
+
if (last === "setenv" || last === "delenv") return [`env:${stringValue(args2[0])}`];
|
|
36037
|
+
if (last === "patch" && str(args2[0])) return [stringValue(args2[0])];
|
|
36038
|
+
if (last === "dict" && path[path.length - 2] === "patch") return [str(args2[0]) ? stringValue(args2[0]) : textOf(args2[0] ?? n).replace(/\s+/g, "")];
|
|
36039
|
+
if (last === "configure_mock") return [pyPath(kid(kid(n, "function") ?? n, "object"))];
|
|
36040
|
+
return [];
|
|
36041
|
+
},
|
|
36042
|
+
skipName: (path) => path.some((s) => PY_SKIP_WORDS.has(s)),
|
|
36043
|
+
resetName: (path) => {
|
|
36044
|
+
const last = path[path.length - 1] ?? "";
|
|
36045
|
+
return PY_RESET_WORDS.has(last) && (last !== "stop" || path.length > 1);
|
|
36046
|
+
},
|
|
36047
|
+
usedNames: (root) => {
|
|
36048
|
+
const names = /* @__PURE__ */ new Set();
|
|
36049
|
+
walk(root, (n, parent) => {
|
|
36050
|
+
if (n.t !== "identifier") return;
|
|
36051
|
+
if (parent?.t === "attribute" && n.f === "attribute") return;
|
|
36052
|
+
if (parent?.t === "keyword_argument" && n.f === "name") return;
|
|
36053
|
+
names.add(n.x ?? "");
|
|
36054
|
+
});
|
|
36055
|
+
return names;
|
|
36056
|
+
}
|
|
36057
|
+
};
|
|
36058
|
+
function goPath(n) {
|
|
36059
|
+
if (!n) return "?";
|
|
36060
|
+
if (n.t === "identifier" || n.t === "field_identifier" || n.t === "package_identifier") return n.x ?? "?";
|
|
36061
|
+
if (n.t === "selector_expression") return `${goPath(kid(n, "operand"))}.${kid(n, "field")?.x ?? "?"}`;
|
|
36062
|
+
if (n.t === "call_expression") return `${goPath(kid(n, "function"))}()`;
|
|
36063
|
+
return "?";
|
|
36064
|
+
}
|
|
36065
|
+
var GO_CONTROL = /* @__PURE__ */ new Set([
|
|
36066
|
+
"if_statement",
|
|
36067
|
+
"for_statement",
|
|
36068
|
+
"expression_switch_statement",
|
|
36069
|
+
"type_switch_statement",
|
|
36070
|
+
"select_statement",
|
|
36071
|
+
"return_statement",
|
|
36072
|
+
"go_statement",
|
|
36073
|
+
"defer_statement",
|
|
36074
|
+
"goto_statement",
|
|
36075
|
+
"labeled_statement",
|
|
36076
|
+
"break_statement",
|
|
36077
|
+
"continue_statement",
|
|
36078
|
+
"fallthrough_statement",
|
|
36079
|
+
"block"
|
|
36080
|
+
]);
|
|
36081
|
+
var GO_CHANGES = /* @__PURE__ */ new Set(["assignment_statement", "inc_statement", "dec_statement", "send_statement"]);
|
|
36082
|
+
var GO_SKIP = /^(Skip|Skipf|SkipNow)$/;
|
|
36083
|
+
var GO_CHECK = /^(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$/;
|
|
36084
|
+
function goSpecNames(spec) {
|
|
36085
|
+
return spec.c.filter((c) => c.f === "name").map((c) => c.x ?? "");
|
|
36086
|
+
}
|
|
36087
|
+
var GO = {
|
|
36088
|
+
isBlock: (n) => n.t === "statement_list" || n.t === "source_file" || n.t === "import_spec_list",
|
|
36089
|
+
statements: (n) => named(n),
|
|
36090
|
+
isObject: (n) => n.t === "literal_value",
|
|
36091
|
+
entryKey: (n) => n.t === "keyed_element" ? canon(named(n)[0] ?? n) : null,
|
|
36092
|
+
isExpectation: (stmt) => {
|
|
36093
|
+
if (stmt.t !== "expression_statement") return false;
|
|
36094
|
+
const call = named(stmt)[0];
|
|
36095
|
+
if (call?.t !== "call_expression") return false;
|
|
36096
|
+
const fn = kid(call, "function");
|
|
36097
|
+
if (fn?.t !== "selector_expression") return false;
|
|
36098
|
+
const operand = kid(fn, "operand");
|
|
36099
|
+
return operand?.t === "identifier" && (operand.x === "assert" || operand.x === "require") || GO_CHECK.test(kid(fn, "field")?.x ?? "");
|
|
36100
|
+
},
|
|
36101
|
+
insertion: (stmt) => {
|
|
36102
|
+
if (stmt.t === "empty_statement") return { names: [] };
|
|
36103
|
+
if (stmt.t === "expression_statement") return named(stmt)[0]?.t === "call_expression" ? { names: [] } : { refused: NOT_ADDABLE };
|
|
36104
|
+
if (stmt.t === "short_var_declaration") {
|
|
36105
|
+
const left = kid(stmt, "left");
|
|
36106
|
+
const ids = left ? named(left) : [];
|
|
36107
|
+
return ids.every((i3) => i3.t === "identifier") && ids.length > 0 ? { names: ids.map((i3) => i3.x ?? "") } : { refused: NOT_ADDABLE };
|
|
36108
|
+
}
|
|
36109
|
+
if (stmt.t === "var_declaration" || stmt.t === "const_declaration") {
|
|
36110
|
+
return { names: named(stmt).flatMap((spec) => spec.t === "var_spec" || spec.t === "const_spec" ? goSpecNames(spec) : spec.t === "var_spec_list" ? named(spec).flatMap(goSpecNames) : []) };
|
|
36111
|
+
}
|
|
36112
|
+
if (stmt.t === "type_declaration") return { names: named(stmt).flatMap((spec) => [kid(spec, "name")?.x ?? ""]) };
|
|
36113
|
+
if (stmt.t === "function_declaration" || stmt.t === "method_declaration") return { names: [kid(stmt, "name")?.x ?? ""] };
|
|
36114
|
+
if (stmt.t === "import_declaration" || stmt.t === "import_spec") {
|
|
36115
|
+
const specs = stmt.t === "import_spec" ? [stmt] : named(stmt).flatMap((c) => c.t === "import_spec_list" ? named(c) : c.t === "import_spec" ? [c] : []);
|
|
36116
|
+
const names = specs.map((s) => {
|
|
36117
|
+
const alias = kid(s, "name");
|
|
36118
|
+
if (alias) return alias.x ?? "";
|
|
36119
|
+
const path = stringValue(named(s).find((c) => c.t === "interpreted_string_literal" || c.t === "raw_string_literal"));
|
|
36120
|
+
return path.split("/").pop() ?? "";
|
|
36121
|
+
});
|
|
36122
|
+
return names.length > 0 && !names.includes(".") && !names.includes("_") ? { names } : { refused: NOT_ADDABLE };
|
|
36123
|
+
}
|
|
36124
|
+
if (GO_CHANGES.has(stmt.t)) return { refused: ASSIGNS };
|
|
36125
|
+
return { refused: GO_CONTROL.has(stmt.t) ? CONTROL : NOT_ADDABLE };
|
|
36126
|
+
},
|
|
36127
|
+
isFunction: (n) => n.t === "func_literal" || n.t === "function_declaration" || n.t === "method_declaration",
|
|
36128
|
+
isAssignment: () => false,
|
|
36129
|
+
callPath: (n) => n.t === "call_expression" ? goPath(kid(n, "function")).split(".") : null,
|
|
36130
|
+
arranges: (n) => {
|
|
36131
|
+
if (n.t !== "call_expression") return [];
|
|
36132
|
+
const fn = kid(n, "function");
|
|
36133
|
+
if (fn?.t !== "selector_expression") return [];
|
|
36134
|
+
const field2 = kid(fn, "field")?.x ?? "";
|
|
36135
|
+
const operand = kid(fn, "operand");
|
|
36136
|
+
const args2 = named(kid(n, "arguments") ?? n);
|
|
36137
|
+
if (field2 === "On") return [`${goPath(operand)}.On:${stringValue(args2[0])}`];
|
|
36138
|
+
if (operand?.t === "call_expression" && goPath(kid(operand, "function")).endsWith(".EXPECT")) return [`${goPath(kid(kid(operand, "function"), "operand"))}.EXPECT.${field2}`];
|
|
36139
|
+
return [];
|
|
36140
|
+
},
|
|
36141
|
+
skipName: (path) => GO_SKIP.test(path[path.length - 1] ?? ""),
|
|
36142
|
+
resetName: () => false,
|
|
36143
|
+
usedNames: (root) => {
|
|
36144
|
+
const names = /* @__PURE__ */ new Set();
|
|
36145
|
+
walk(root, (n) => {
|
|
36146
|
+
if (n.t === "identifier") names.add(n.x ?? "");
|
|
36147
|
+
});
|
|
36148
|
+
return names;
|
|
36149
|
+
}
|
|
36150
|
+
};
|
|
36151
|
+
function javaPath(n) {
|
|
36152
|
+
if (!n) return "?";
|
|
36153
|
+
if (n.t === "identifier" || n.t === "this") return n.x ?? n.t;
|
|
36154
|
+
if (n.t === "field_access") return `${javaPath(kid(n, "object"))}.${kid(n, "field")?.x ?? "?"}`;
|
|
36155
|
+
if (n.t === "method_invocation") {
|
|
36156
|
+
const obj = kid(n, "object");
|
|
36157
|
+
return `${obj ? `${javaPath(obj)}.` : ""}${kid(n, "name")?.x ?? "?"}()`;
|
|
36158
|
+
}
|
|
36159
|
+
return "?";
|
|
36160
|
+
}
|
|
36161
|
+
function javaCallPath(n) {
|
|
36162
|
+
const obj = kid(n, "object");
|
|
36163
|
+
return [...obj ? javaPath(obj).split(".") : [], kid(n, "name")?.x ?? "?"];
|
|
36164
|
+
}
|
|
36165
|
+
var JAVA_CONTROL = /* @__PURE__ */ new Set([
|
|
36166
|
+
"if_statement",
|
|
36167
|
+
"for_statement",
|
|
36168
|
+
"enhanced_for_statement",
|
|
36169
|
+
"while_statement",
|
|
36170
|
+
"do_statement",
|
|
36171
|
+
"try_statement",
|
|
36172
|
+
"try_with_resources_statement",
|
|
36173
|
+
"return_statement",
|
|
36174
|
+
"throw_statement",
|
|
36175
|
+
"switch_expression",
|
|
36176
|
+
"switch_statement",
|
|
36177
|
+
"synchronized_statement",
|
|
36178
|
+
"labeled_statement",
|
|
36179
|
+
"break_statement",
|
|
36180
|
+
"continue_statement",
|
|
36181
|
+
"yield_statement",
|
|
36182
|
+
"block"
|
|
36183
|
+
]);
|
|
36184
|
+
var JAVA_TEST_ANNOTATIONS = /* @__PURE__ */ new Set(["Test", "ParameterizedTest", "RepeatedTest", "TestFactory", "TestTemplate"]);
|
|
36185
|
+
var JAVA_SKIP = /* @__PURE__ */ new Set(["assumeTrue", "assumeFalse", "assumeThat", "assumingThat", "Disabled", "Ignore", "DisabledIf", "DisabledOnOs", "DisabledIfEnvironmentVariable", "DisabledIfSystemProperty", "EnabledIf"]);
|
|
36186
|
+
var JAVA_RESET = /* @__PURE__ */ new Set(["reset", "clearInvocations", "openMocks", "initMocks", "clearInlineMocks"]);
|
|
36187
|
+
function javaAnnotationNames(member) {
|
|
36188
|
+
const mods = member.c.find((c) => c.t === "modifiers");
|
|
36189
|
+
return (mods?.c ?? []).filter((c) => c.t === "marker_annotation" || c.t === "annotation").map((a) => kid(a, "name")?.x ?? "");
|
|
36190
|
+
}
|
|
36191
|
+
function javaReceiverTarget(call) {
|
|
36192
|
+
if (call?.t === "method_invocation") return `${javaPath(kid(call, "object"))}.${kid(call, "name")?.x ?? "?"}`;
|
|
36193
|
+
return javaPath(call);
|
|
36194
|
+
}
|
|
36195
|
+
var JAVA = {
|
|
36196
|
+
isBlock: (n) => n.t === "block" || n.t === "class_body" || n.t === "program" || n.t === "constructor_body",
|
|
36197
|
+
statements: (n) => named(n),
|
|
36198
|
+
isObject: () => false,
|
|
36199
|
+
entryKey: () => null,
|
|
36200
|
+
isExpectation: (stmt) => {
|
|
36201
|
+
if (stmt.t === "assert_statement") return true;
|
|
36202
|
+
if (stmt.t !== "expression_statement") return false;
|
|
36203
|
+
let call = named(stmt)[0];
|
|
36204
|
+
if (call?.t !== "method_invocation") return false;
|
|
36205
|
+
for (; ; ) {
|
|
36206
|
+
const obj = kid(call, "object");
|
|
36207
|
+
if (obj?.t === "method_invocation") call = obj;
|
|
36208
|
+
else break;
|
|
36209
|
+
}
|
|
36210
|
+
const name2 = kid(call, "name")?.x ?? "";
|
|
36211
|
+
return /^assert/i.test(name2) || name2 === "fail";
|
|
36212
|
+
},
|
|
36213
|
+
insertion: (stmt) => {
|
|
36214
|
+
if (stmt.t === ";" || stmt.t === "empty_statement") return { names: [] };
|
|
36215
|
+
if (stmt.t === "assert_statement") return { names: [] };
|
|
36216
|
+
if (stmt.t === "expression_statement") {
|
|
36217
|
+
const e = named(stmt)[0];
|
|
36218
|
+
if (e?.t === "method_invocation") return { names: [] };
|
|
36219
|
+
return { refused: e?.t === "assignment_expression" || e?.t === "update_expression" ? ASSIGNS : NOT_ADDABLE };
|
|
36220
|
+
}
|
|
36221
|
+
if (stmt.t === "local_variable_declaration" || stmt.t === "field_declaration") {
|
|
36222
|
+
return { names: stmt.c.filter((c) => c.t === "variable_declarator").map((d) => kid(d, "name")?.x ?? "") };
|
|
36223
|
+
}
|
|
36224
|
+
if (stmt.t === "method_declaration") {
|
|
36225
|
+
if (javaAnnotationNames(stmt).some((a) => JAVA_TEST_ANNOTATIONS.has(a))) return { refused: NOT_ADDABLE };
|
|
36226
|
+
return { names: [kid(stmt, "name")?.x ?? ""] };
|
|
36227
|
+
}
|
|
36228
|
+
if (stmt.t === "class_declaration") return { names: [kid(stmt, "name")?.x ?? ""] };
|
|
36229
|
+
if (stmt.t === "import_declaration") {
|
|
36230
|
+
if (stmt.c.some((c) => c.t === "asterisk")) return { refused: NOT_ADDABLE };
|
|
36231
|
+
const id = named(stmt).find((c) => c.t === "scoped_identifier" || c.t === "identifier");
|
|
36232
|
+
const last = id?.t === "scoped_identifier" ? kid(id, "name")?.x : id?.x;
|
|
36233
|
+
return { names: [last ?? ""] };
|
|
36234
|
+
}
|
|
36235
|
+
return { refused: JAVA_CONTROL.has(stmt.t) ? CONTROL : NOT_ADDABLE };
|
|
36236
|
+
},
|
|
36237
|
+
isFunction: (n) => n.t === "lambda_expression" || n.t === "method_declaration" || n.t === "class_body",
|
|
36238
|
+
isAssignment: (n) => n.t === "assignment_expression" || n.t === "update_expression",
|
|
36239
|
+
callPath: (n) => n.t === "method_invocation" ? javaCallPath(n) : n.t === "marker_annotation" || n.t === "annotation" ? [kid(n, "name")?.x ?? "?"] : null,
|
|
36240
|
+
arranges: (n) => {
|
|
36241
|
+
if (n.t !== "method_invocation") return [];
|
|
36242
|
+
const name2 = kid(n, "name")?.x ?? "";
|
|
36243
|
+
const obj = kid(n, "object");
|
|
36244
|
+
const args2 = named(kid(n, "arguments") ?? n);
|
|
36245
|
+
if ((name2 === "when" || name2 === "given") && (!obj || /^(Mockito|BDDMockito)$/.test(obj.x ?? ""))) return [javaReceiverTarget(args2[0])];
|
|
36246
|
+
if (obj?.t === "method_invocation" && kid(obj, "name")?.x === "when" && kid(obj, "object") !== void 0) {
|
|
36247
|
+
const target = named(kid(obj, "arguments") ?? obj)[0];
|
|
36248
|
+
return [`${javaPath(target)}.${name2}`];
|
|
36249
|
+
}
|
|
36250
|
+
return [];
|
|
36251
|
+
},
|
|
36252
|
+
skipName: (path) => JAVA_SKIP.has(path[path.length - 1] ?? ""),
|
|
36253
|
+
resetName: (path) => JAVA_RESET.has(path[path.length - 1] ?? ""),
|
|
36254
|
+
usedNames: (root) => {
|
|
36255
|
+
const names = /* @__PURE__ */ new Set();
|
|
36256
|
+
walk(root, (n, parent) => {
|
|
36257
|
+
if (n.t !== "identifier") return;
|
|
36258
|
+
if (parent?.t === "method_invocation" && n.f === "name") return;
|
|
36259
|
+
names.add(n.x ?? "");
|
|
36260
|
+
});
|
|
36261
|
+
return names;
|
|
36262
|
+
}
|
|
36263
|
+
};
|
|
36264
|
+
var ADAPTERS = { js: JS, python: PY, go: GO, java: JAVA };
|
|
36265
|
+
var OK0 = { ok: true, changed: 0 };
|
|
36266
|
+
var CHANGED = "a line that was there was changed, moved or removed";
|
|
36267
|
+
var spanKey = (n) => `${n.s}:${n.e}`;
|
|
36268
|
+
function overlaps(a, b) {
|
|
36269
|
+
return a === b || a.startsWith(`${b}.`) || b.startsWith(`${a}.`) || a.startsWith(`${b}[`) || b.startsWith(`${a}[`);
|
|
36270
|
+
}
|
|
36271
|
+
function arrangedIn(a, root) {
|
|
36272
|
+
const out2 = [];
|
|
36273
|
+
walk(root, (n) => {
|
|
36274
|
+
out2.push(...a.arranges(n));
|
|
36275
|
+
});
|
|
36276
|
+
return out2.filter((t) => t !== "?" && !t.startsWith("?"));
|
|
36277
|
+
}
|
|
36278
|
+
function insertable(stmt, ctx) {
|
|
36279
|
+
const own = ctx.a.insertion(stmt);
|
|
36280
|
+
if ("refused" in own) return own.refused;
|
|
36281
|
+
if (own.names.some((n) => n === "" || ctx.names.has(n))) return SHADOWS;
|
|
36282
|
+
let why = null;
|
|
36283
|
+
const shallow = (n) => {
|
|
36284
|
+
if (why !== null) return;
|
|
36285
|
+
if (n !== stmt && ctx.a.isFunction(n)) return;
|
|
36286
|
+
if (ctx.a.isAssignment(n)) {
|
|
36287
|
+
why = ASSIGNS;
|
|
36288
|
+
return;
|
|
36289
|
+
}
|
|
36290
|
+
for (const c of n.c) shallow(c);
|
|
36291
|
+
};
|
|
36292
|
+
shallow(stmt);
|
|
36293
|
+
if (why !== null) return why;
|
|
36294
|
+
walk(stmt, (n) => {
|
|
36295
|
+
if (why !== null) return false;
|
|
36296
|
+
const path = ctx.a.callPath(n);
|
|
36297
|
+
if (path) {
|
|
36298
|
+
if (ctx.a.skipName(path, n)) why = SKIPS;
|
|
36299
|
+
else if (ctx.a.resetName(path, n)) why = RESETS;
|
|
36300
|
+
}
|
|
36301
|
+
if (why === null && ctx.a.arranges(n).some((t) => ctx.arranged.some((o) => overlaps(t, o)))) why = REARRANGES;
|
|
36302
|
+
return why === null;
|
|
36303
|
+
});
|
|
36304
|
+
return why;
|
|
36305
|
+
}
|
|
36306
|
+
function blockCmp(orig, next, ctx) {
|
|
36307
|
+
const n = orig.length;
|
|
36308
|
+
const m = next.length;
|
|
36309
|
+
const ins = next.map((s) => insertable(s, ctx));
|
|
36310
|
+
const INF = Number.MAX_SAFE_INTEGER;
|
|
36311
|
+
const memo = /* @__PURE__ */ new Map();
|
|
36312
|
+
const nested = [];
|
|
36313
|
+
const matchCost = (i3, j) => {
|
|
36314
|
+
const key = i3 * (m + 1) + j;
|
|
36315
|
+
if (memo.has(key)) return memo.get(key);
|
|
36316
|
+
const a = orig[i3];
|
|
36317
|
+
const b = next[j];
|
|
36318
|
+
let cost;
|
|
36319
|
+
if (canon(a) === canon(b)) cost = 0;
|
|
36320
|
+
else if (ctx.a.isExpectation(a) && ctx.a.isExpectation(b)) cost = 1;
|
|
36321
|
+
else {
|
|
36322
|
+
const r = cmp(a, b, ctx);
|
|
36323
|
+
cost = r.ok ? r.changed : null;
|
|
36324
|
+
if (!r.ok && r.why !== CHANGED && a.t === b.t) nested.push(r.why);
|
|
36325
|
+
}
|
|
36326
|
+
memo.set(key, cost);
|
|
36327
|
+
return cost;
|
|
36328
|
+
};
|
|
36329
|
+
const f = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(INF));
|
|
36330
|
+
f[n][m] = 0;
|
|
36331
|
+
for (let j = m - 1; j >= 0; j--) f[n][j] = ins[j] === null ? f[n][j + 1] : INF;
|
|
36332
|
+
for (let i3 = n - 1; i3 >= 0; i3--) {
|
|
36333
|
+
for (let j = m - 1; j >= 0; j--) {
|
|
36334
|
+
let best = ins[j] === null ? f[i3][j + 1] : INF;
|
|
36335
|
+
if (f[i3 + 1][j + 1] < INF) {
|
|
36336
|
+
const c = matchCost(i3, j);
|
|
36337
|
+
if (c !== null) best = Math.min(best, c + f[i3 + 1][j + 1]);
|
|
36338
|
+
}
|
|
36339
|
+
f[i3][j] = best;
|
|
36340
|
+
}
|
|
36341
|
+
}
|
|
36342
|
+
if (f[0][0] < INF) return { ok: true, changed: f[0][0] };
|
|
36343
|
+
if (nested.length > 0) return { ok: false, why: nested[0] };
|
|
36344
|
+
for (let j = 0; j < m; j++) {
|
|
36345
|
+
if (ins[j] !== null && !orig.some((_, i3) => matchCost(i3, j) !== null)) return { ok: false, why: ins[j] };
|
|
36346
|
+
}
|
|
36347
|
+
return { ok: false, why: CHANGED };
|
|
36348
|
+
}
|
|
36349
|
+
function objectCmp(origAll, nextAll, ctx, keyed) {
|
|
36350
|
+
const orig = origAll.filter(keyed);
|
|
36351
|
+
const next = nextAll.filter(keyed);
|
|
36352
|
+
const keys = new Set(orig.map((e) => ctx.a.entryKey(e)).filter((k) => k !== null));
|
|
36353
|
+
const added = /* @__PURE__ */ new Set();
|
|
36354
|
+
let i3 = 0;
|
|
36355
|
+
let changed = 0;
|
|
36356
|
+
for (const e of next) {
|
|
36357
|
+
const key = ctx.a.entryKey(e);
|
|
36358
|
+
const o = orig[i3];
|
|
36359
|
+
if (o && ctx.a.entryKey(o) === key) {
|
|
36360
|
+
const r = canon(o) === canon(e) ? OK0 : cmp(o, e, ctx);
|
|
36361
|
+
if (!r.ok) return r;
|
|
36362
|
+
changed += r.changed;
|
|
36363
|
+
i3 += 1;
|
|
36364
|
+
continue;
|
|
36365
|
+
}
|
|
36366
|
+
if (key === null || keys.has(key) || added.has(key)) return { ok: false, why: "a literal changed other than by gaining a new key" };
|
|
36367
|
+
added.add(key);
|
|
36368
|
+
const why = insertableValue(e, ctx);
|
|
36369
|
+
if (why !== null) return { ok: false, why };
|
|
36370
|
+
}
|
|
36371
|
+
return i3 === orig.length ? { ok: true, changed } : { ok: false, why: "a literal lost a key" };
|
|
36372
|
+
}
|
|
36373
|
+
function insertableValue(entry, ctx) {
|
|
36374
|
+
let why = null;
|
|
36375
|
+
walk(entry, (n) => {
|
|
36376
|
+
if (why !== null) return false;
|
|
36377
|
+
const path = ctx.a.callPath(n);
|
|
36378
|
+
if (path && ctx.a.skipName(path, n)) why = SKIPS;
|
|
36379
|
+
else if (path && ctx.a.resetName(path, n)) why = RESETS;
|
|
36380
|
+
else if (ctx.a.arranges(n).some((t) => ctx.arranged.some((o) => overlaps(t, o)))) why = REARRANGES;
|
|
36381
|
+
return why === null;
|
|
36382
|
+
});
|
|
36383
|
+
return why;
|
|
36384
|
+
}
|
|
36385
|
+
function blockStatements(n, ctx) {
|
|
36386
|
+
if (n.t === "block" && ctx.a === GO) return named(named(n).find((c) => c.t === "statement_list") ?? { t: "", p: "", s: 0, e: 0, c: [], named: true });
|
|
36387
|
+
return ctx.a.statements(n);
|
|
36388
|
+
}
|
|
36389
|
+
function cmp(a, b, ctx) {
|
|
36390
|
+
const ta = ctx.testType(a.t) ? ctx.testsBefore.get(spanKey(a)) : void 0;
|
|
36391
|
+
const tb = ctx.testType(b.t) ? ctx.testsAfter.get(spanKey(b)) : void 0;
|
|
36392
|
+
if (ta !== void 0 || tb !== void 0) {
|
|
36393
|
+
return ta !== void 0 && ta === tb && a.t === b.t ? OK0 : { ok: false, why: "a test moved" };
|
|
36394
|
+
}
|
|
36395
|
+
if (canon(a) === canon(b)) return OK0;
|
|
36396
|
+
if (a.t !== b.t || a.p !== b.p) return { ok: false, why: CHANGED };
|
|
36397
|
+
if (a.t === "block" && ctx.a === GO) return blockCmp(blockStatements(a, ctx), blockStatements(b, ctx), ctx);
|
|
36398
|
+
if (ctx.a.isBlock(a)) {
|
|
36399
|
+
const anonA = a.c.filter((c) => !c.named).map(canon).join();
|
|
36400
|
+
const anonB = b.c.filter((c) => !c.named).map(canon).join();
|
|
36401
|
+
if (anonA !== anonB && ctx.a !== JS) return { ok: false, why: CHANGED };
|
|
36402
|
+
return blockCmp(ctx.a.statements(a), ctx.a.statements(b), ctx);
|
|
36403
|
+
}
|
|
36404
|
+
if (ctx.a.isObject(a)) return objectCmp(a.c, b.c, ctx, (c) => c.named);
|
|
36405
|
+
if (a.c.length !== b.c.length) return { ok: false, why: CHANGED };
|
|
36406
|
+
let changed = 0;
|
|
36407
|
+
for (let i3 = 0; i3 < a.c.length; i3++) {
|
|
36408
|
+
const r = cmp(a.c[i3], b.c[i3], ctx);
|
|
36409
|
+
if (!r.ok) return r;
|
|
36410
|
+
changed += r.changed;
|
|
36411
|
+
}
|
|
36412
|
+
return { ok: true, changed };
|
|
36413
|
+
}
|
|
36414
|
+
var TEST_TYPES = {
|
|
36415
|
+
js: /* @__PURE__ */ new Set(["CallExpression"]),
|
|
36416
|
+
python: /* @__PURE__ */ new Set(["decorated_definition", "function_definition"]),
|
|
36417
|
+
go: /* @__PURE__ */ new Set(["function_declaration"]),
|
|
36418
|
+
java: /* @__PURE__ */ new Set(["method_declaration"])
|
|
36419
|
+
};
|
|
36420
|
+
function nodeOfTest(root, test, lang) {
|
|
36421
|
+
let found = null;
|
|
36422
|
+
walk(root, (n) => {
|
|
36423
|
+
if (found) return false;
|
|
36424
|
+
if (n.s === test.start && n.e === test.end && TEST_TYPES[lang].has(n.t)) {
|
|
36425
|
+
found = n;
|
|
36426
|
+
return false;
|
|
36427
|
+
}
|
|
36428
|
+
return n.s <= test.start && n.e >= test.end;
|
|
36429
|
+
});
|
|
36430
|
+
return found;
|
|
36431
|
+
}
|
|
36432
|
+
var FRAME_CHANGED = "the test's frame changed (how it is declared, its parameters, decorators or annotations), not only its title";
|
|
36433
|
+
function testCmp(a, b, titleStart, ctx, lang) {
|
|
36434
|
+
if (lang === "js") {
|
|
36435
|
+
if (a.t !== b.t || a.p !== b.p) return { ok: false, why: FRAME_CHANGED };
|
|
36436
|
+
const calleeA = kid(a, "callee");
|
|
36437
|
+
const calleeB = kid(b, "callee");
|
|
36438
|
+
if (!calleeA || !calleeB || canon(calleeA) !== canon(calleeB)) return { ok: false, why: FRAME_CHANGED };
|
|
36439
|
+
const argsA = jsArgs2(a);
|
|
36440
|
+
const argsB = jsArgs2(b);
|
|
36441
|
+
if (argsA.length !== argsB.length) return { ok: false, why: FRAME_CHANGED };
|
|
36442
|
+
let changed = 0;
|
|
36443
|
+
for (let i3 = 0; i3 < argsA.length; i3++) {
|
|
36444
|
+
const x = argsA[i3];
|
|
36445
|
+
const y = argsB[i3];
|
|
36446
|
+
if (x.s === titleStart.before && y.s === titleStart.after) continue;
|
|
36447
|
+
if ((x.t === "ArrowFunctionExpression" || x.t === "FunctionExpression") && x.t === y.t) {
|
|
36448
|
+
const paramsA = kid(x, "params");
|
|
36449
|
+
const paramsB = kid(y, "params");
|
|
36450
|
+
if (x.p !== y.p || !paramsA || !paramsB || canon(paramsA) !== canon(paramsB)) return { ok: false, why: FRAME_CHANGED };
|
|
36451
|
+
const r = cmp(x, y, ctx);
|
|
36452
|
+
if (!r.ok) return r;
|
|
36453
|
+
changed += r.changed;
|
|
36454
|
+
continue;
|
|
36455
|
+
}
|
|
36456
|
+
if (canon(x) !== canon(y)) return { ok: false, why: FRAME_CHANGED };
|
|
36457
|
+
}
|
|
36458
|
+
return { ok: true, changed };
|
|
36459
|
+
}
|
|
36460
|
+
return frameCmp(a, b, titleStart, ctx);
|
|
36461
|
+
}
|
|
36462
|
+
function frameCmp(a, b, titleStart, ctx) {
|
|
36463
|
+
if (a.t !== b.t || a.c.length !== b.c.length) return { ok: false, why: FRAME_CHANGED };
|
|
36464
|
+
let changed = 0;
|
|
36465
|
+
for (let i3 = 0; i3 < a.c.length; i3++) {
|
|
36466
|
+
const x = a.c[i3];
|
|
36467
|
+
const y = b.c[i3];
|
|
36468
|
+
if (x.s === titleStart.before && y.s === titleStart.after) continue;
|
|
36469
|
+
if (x.f === "name" && y.f === "name" && x.t === y.t) continue;
|
|
36470
|
+
if (x.f === "definition") {
|
|
36471
|
+
const r = frameCmp(x, y, titleStart, ctx);
|
|
36472
|
+
if (!r.ok) return r;
|
|
36473
|
+
changed += r.changed;
|
|
36474
|
+
continue;
|
|
36475
|
+
}
|
|
36476
|
+
if (x.f === "body" && y.f === "body") {
|
|
36477
|
+
const r = cmp(x, y, ctx);
|
|
36478
|
+
if (!r.ok) return r;
|
|
36479
|
+
changed += r.changed;
|
|
36480
|
+
continue;
|
|
36481
|
+
}
|
|
36482
|
+
if (x.t === "modifiers" && y.t === "modifiers" && displayNameOnly(x, y)) continue;
|
|
36483
|
+
if (canon(x) !== canon(y)) return { ok: false, why: FRAME_CHANGED };
|
|
36484
|
+
}
|
|
36485
|
+
return { ok: true, changed };
|
|
36486
|
+
}
|
|
36487
|
+
function displayNameOnly(a, b) {
|
|
36488
|
+
if (a.c.length !== b.c.length) return false;
|
|
36489
|
+
return a.c.every((x, i3) => {
|
|
36490
|
+
const y = b.c[i3];
|
|
36491
|
+
if (canon(x) === canon(y)) return true;
|
|
36492
|
+
return x.t === "annotation" && y.t === "annotation" && kid(x, "name")?.x === "DisplayName" && kid(y, "name")?.x === "DisplayName";
|
|
36493
|
+
});
|
|
36494
|
+
}
|
|
36495
|
+
function outsideSpans2(code, spans) {
|
|
36496
|
+
let out2 = "";
|
|
36497
|
+
let at2 = 0;
|
|
36498
|
+
for (const s of [...spans].sort((x, y) => x.start - y.start)) {
|
|
36499
|
+
out2 += `${code.slice(at2, s.start)}\0`;
|
|
36500
|
+
at2 = s.end;
|
|
36501
|
+
}
|
|
36502
|
+
return out2 + code.slice(at2);
|
|
36503
|
+
}
|
|
36504
|
+
function bareTest(code, t, js) {
|
|
36505
|
+
const text3 = `${code.slice(t.start, t.titleStart)}${code.slice(t.titleEnd, t.end)}`;
|
|
36506
|
+
return (js ? stripComments(text3) : text3).replace(/\s+/g, "");
|
|
36507
|
+
}
|
|
36508
|
+
function setupAdded(input) {
|
|
36509
|
+
const lang = langOf(input.path);
|
|
36510
|
+
if (!lang) return no("the file is not in a language this reads");
|
|
36511
|
+
const before = locateTests(input.path, input.before);
|
|
36512
|
+
const after = locateTests(input.path, input.after);
|
|
36513
|
+
if (!before) return no("the file could not be read before the edit");
|
|
36514
|
+
if (!after) return no("the file can no longer be read after the edit");
|
|
36515
|
+
if (after.tests.length !== before.tests.length || after.generated.length !== before.generated.length) return no("a test was added or removed");
|
|
36516
|
+
const treeBefore = treeOf(input.path, input.before, lang);
|
|
36517
|
+
const treeAfter = treeOf(input.path, input.after, lang);
|
|
36518
|
+
if (!treeBefore || !treeAfter) return no("the file could not be read");
|
|
36519
|
+
const a = ADAPTERS[lang];
|
|
36520
|
+
const beforeAll = allTests(before);
|
|
36521
|
+
const afterAll = allTests(after);
|
|
36522
|
+
const editable = new Set(input.editable ?? []);
|
|
36523
|
+
for (const i3 of editable) if (!beforeAll[i3] || !afterAll[i3]) return no("the test could not be found again after the edit");
|
|
36524
|
+
const arranged = arrangedIn(a, treeBefore);
|
|
36525
|
+
for (const extra of input.arranged ?? []) {
|
|
36526
|
+
const l = langOf(extra.path);
|
|
36527
|
+
const t = l ? treeOf(extra.path, extra.text, l) : null;
|
|
36528
|
+
if (l && t) arranged.push(...arrangedIn(ADAPTERS[l], t));
|
|
36529
|
+
}
|
|
36530
|
+
const nodesBefore = beforeAll.map((t) => nodeOfTest(treeBefore, t, lang));
|
|
36531
|
+
const nodesAfter = afterAll.map((t) => nodeOfTest(treeAfter, t, lang));
|
|
36532
|
+
const ctx = {
|
|
36533
|
+
a,
|
|
36534
|
+
testType: (t) => TEST_TYPES[lang].has(t),
|
|
36535
|
+
names: a.usedNames(treeBefore),
|
|
36536
|
+
arranged,
|
|
36537
|
+
testsBefore: new Map(nodesBefore.flatMap((n, i3) => n ? [[spanKey(n), i3]] : [])),
|
|
36538
|
+
testsAfter: new Map(nodesAfter.flatMap((n, i3) => n ? [[spanKey(n), i3]] : []))
|
|
36539
|
+
};
|
|
36540
|
+
let strictlyAdditive = true;
|
|
36541
|
+
if (input.outside === true) {
|
|
36542
|
+
const r = cmp(treeBefore, treeAfter, ctx);
|
|
36543
|
+
if (!r.ok) return no(r.why);
|
|
36544
|
+
if (r.changed > 0) strictlyAdditive = false;
|
|
36545
|
+
} else {
|
|
36546
|
+
const was = [...editable].map((i3) => beforeAll[i3]);
|
|
36547
|
+
const now = [...editable].map((i3) => afterAll[i3]);
|
|
36548
|
+
if (outsideSpans2(before.code, was) !== outsideSpans2(after.code, now)) return no("something outside the tests changed");
|
|
36549
|
+
}
|
|
36550
|
+
for (let i3 = 0; i3 < beforeAll.length; i3++) {
|
|
36551
|
+
const was = beforeAll[i3];
|
|
36552
|
+
const now = afterAll[i3];
|
|
36553
|
+
if (!editable.has(i3)) {
|
|
36554
|
+
if (input.outside === true && before.code.slice(was.start, was.end) !== after.code.slice(now.start, now.end)) {
|
|
36555
|
+
const x2 = nodesBefore[i3];
|
|
36556
|
+
const y2 = nodesAfter[i3];
|
|
36557
|
+
if (!x2 || !y2 || canon(x2) !== canon(y2)) return no("a test that may not change was changed");
|
|
36558
|
+
}
|
|
36559
|
+
continue;
|
|
36560
|
+
}
|
|
36561
|
+
if (input.legacy === true && (was.shape ?? testShape(before.code, was)) === (now.shape ?? testShape(after.code, now))) {
|
|
36562
|
+
if (bareTest(before.code, was, lang === "js") !== bareTest(after.code, now, lang === "js")) strictlyAdditive = false;
|
|
36563
|
+
continue;
|
|
36564
|
+
}
|
|
36565
|
+
const x = nodesBefore[i3];
|
|
36566
|
+
const y = nodesAfter[i3];
|
|
36567
|
+
if (!x || !y) return no("the test could not be found again after the edit");
|
|
36568
|
+
const ctxTest = { ...ctx, testsBefore: /* @__PURE__ */ new Map(), testsAfter: /* @__PURE__ */ new Map() };
|
|
36569
|
+
const r = testCmp(x, y, { before: was.titleStart, after: now.titleStart }, ctxTest, lang);
|
|
36570
|
+
if (!r.ok) return no(r.why);
|
|
36571
|
+
if (r.changed > 0) strictlyAdditive = false;
|
|
36572
|
+
}
|
|
36573
|
+
return { ok: true, strictlyAdditive };
|
|
36574
|
+
}
|
|
36575
|
+
|
|
36576
|
+
// src/featureTestUpdates.ts
|
|
36577
|
+
var import_node_path2 = require("node:path");
|
|
36578
|
+
var FEATURE_TEST_UPDATES_KEY = "featureTestUpdates";
|
|
36579
|
+
function featureTestUpdatesOn(env2 = process.env) {
|
|
36580
|
+
return env2.QUIKPILOT_FEATURE_TEST_UPDATES?.trim().toLowerCase() === "on";
|
|
36581
|
+
}
|
|
36582
|
+
function isFeatureKind(kind) {
|
|
36583
|
+
return typeof kind === "string" && ["TASK", "STORY", "EPIC"].includes(kind.trim().toUpperCase());
|
|
36584
|
+
}
|
|
36585
|
+
var FEATURE_GIVE_UP_MESSAGE = "Your answer was sent back once: existing tests your change broke are neither reported nor explained. Keep your change. Report each test the approved feature cannot be built without changing, naming that case; otherwise change your code.";
|
|
36586
|
+
var FEATURE_RECORDED_MESSAGE = "Recorded. Keep your change as it is, never revert it: QuikPilot runs the project's tests with your change and every proposed update before a person decides about this test. Finish your answer; there is nothing more to do for this test.";
|
|
36587
|
+
var FEATURE_RECORDED_MESSAGE_FIX_FIRST = "Recorded as a proposal; nothing was changed. Keep your change as it is, never revert it. Carry on: finish the change, run the project's tests, and report every other existing test it breaks. When it is complete answer DONE; a person then decides about the proposals together.";
|
|
36588
|
+
var FEATURE_BEYOND_EXPECTATIONS = "replace changes more than may change. Change only the test's expected values and title, or only ADD what the new code needs (a mock, a missing field in test data, a new check). Never change, remove, reorder, skip or wrap what is there, nor arrange again a mock it arranges.";
|
|
36589
|
+
var FEATURE_FIND_OUTSIDE_TEST = `find is neither inside that test nor in set-up outside every test. Put it in that test, in shared set-up of the same file outside any test (testPath ""), or in a test helper file as path with testPath the broken test's file.`;
|
|
36590
|
+
var FEATURE_NOT_TEST_SUPPORT = "That is not a test file or a test helper of this project. Set-up may be added only to existing test files and to test helpers (a file in a test folder, or conftest.py), never to a file of the product.";
|
|
36591
|
+
var STRONG_TEST_FOLDER = /(^|\/)(__tests__|__mocks__|src\/test)\//;
|
|
36592
|
+
var WEAK_TEST_FOLDER = /(^|\/)(tests?|spec|testutil|testing)\//;
|
|
36593
|
+
function isTestSupportPath(path, listing, discovered) {
|
|
36594
|
+
if (!listing.includes(path)) return false;
|
|
36595
|
+
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;
|
|
36597
|
+
const weak = WEAK_TEST_FOLDER.exec(path);
|
|
36598
|
+
if (!weak) return false;
|
|
36599
|
+
if (!discovered) return true;
|
|
36600
|
+
const folder = path.slice(0, weak.index + weak[0].length);
|
|
36601
|
+
return discovered.some((t) => t.startsWith(folder));
|
|
36602
|
+
}
|
|
36603
|
+
var MAX_USED_BY = 20;
|
|
36604
|
+
var MAX_FILES_READ = 2e3;
|
|
36605
|
+
var stripExt = (p) => p.replace(/\.[cm]?[jt]sx?$/i, "");
|
|
36606
|
+
var escapeRegExp3 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
36607
|
+
function jsNames(spec, from, helper) {
|
|
36608
|
+
const target = stripExt(helper);
|
|
36609
|
+
const targets = [target, ...import_node_path2.posix.basename(target) === "index" ? [import_node_path2.posix.dirname(target)] : []];
|
|
36610
|
+
if (spec.startsWith(".")) {
|
|
36611
|
+
const resolved = stripExt(import_node_path2.posix.normalize(import_node_path2.posix.join(import_node_path2.posix.dirname(from), spec)));
|
|
36612
|
+
return targets.includes(resolved);
|
|
36613
|
+
}
|
|
36614
|
+
const rest = stripExt(spec.replace(/^[@~#]\//, ""));
|
|
36615
|
+
return targets.some((t) => t === rest || t.endsWith(`/${rest}`));
|
|
36616
|
+
}
|
|
36617
|
+
var JS_SPECIFIER = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bmock\s*\(\s*|^\s*import\s+)["']([^"']+)["']/gm;
|
|
36618
|
+
var PY_IMPORT = /^\s*(?:from\s+(\.*[\w.]*)\s+import\b|import\s+([\w.]+))/gm;
|
|
36619
|
+
function usesHelper(from, text3, helper) {
|
|
36620
|
+
if (from === helper) return false;
|
|
36621
|
+
if (/\.[cm]?[jt]sx?$/i.test(helper)) return [...text3.matchAll(JS_SPECIFIER)].some((m) => jsNames(m[1], from, helper));
|
|
36622
|
+
if (helper.endsWith(".py")) {
|
|
36623
|
+
if (import_node_path2.posix.basename(helper) === "conftest.py") {
|
|
36624
|
+
const dir = import_node_path2.posix.dirname(helper);
|
|
36625
|
+
return dir === "." || from.startsWith(`${dir}/`);
|
|
36626
|
+
}
|
|
36627
|
+
const dotted = helper.slice(0, -3).split("/").join(".");
|
|
36628
|
+
return [...text3.matchAll(PY_IMPORT)].some((m) => {
|
|
36629
|
+
const mod = (m[1] ?? m[2] ?? "").replace(/^\.+/, "");
|
|
36630
|
+
return mod !== "" && (dotted === mod || dotted.endsWith(`.${mod}`));
|
|
36631
|
+
});
|
|
36632
|
+
}
|
|
36633
|
+
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);
|
|
36636
|
+
}
|
|
36637
|
+
if (helper.endsWith(".java") || helper.endsWith(".kt")) {
|
|
36638
|
+
const name2 = import_node_path2.posix.basename(helper).replace(/\.(java|kt)$/, "");
|
|
36639
|
+
return new RegExp(`\\b${escapeRegExp3(name2)}\\b`).test(text3);
|
|
36640
|
+
}
|
|
36641
|
+
return false;
|
|
36642
|
+
}
|
|
36643
|
+
function usedByOf(helper, testFiles, read) {
|
|
36644
|
+
const using = [];
|
|
36645
|
+
for (const path of testFiles.slice(0, MAX_FILES_READ)) {
|
|
36646
|
+
const text3 = read(path);
|
|
36647
|
+
if (text3 !== null && usesHelper(path, text3, helper)) using.push(path);
|
|
36648
|
+
}
|
|
36649
|
+
using.sort();
|
|
36650
|
+
return { files: using.slice(0, MAX_USED_BY), count: using.length };
|
|
36651
|
+
}
|
|
36652
|
+
|
|
35639
36653
|
// src/targetingTools.ts
|
|
35640
36654
|
var import_node_fs2 = require("node:fs");
|
|
35641
|
-
var
|
|
36655
|
+
var import_node_path4 = require("node:path");
|
|
35642
36656
|
|
|
35643
36657
|
// src/genericDenies.ts
|
|
35644
36658
|
var OTHER_LOCK_FILES = [
|
|
@@ -36054,7 +37068,7 @@ function definitionsOfFile(path, text3) {
|
|
|
36054
37068
|
}
|
|
36055
37069
|
|
|
36056
37070
|
// src/importContext.ts
|
|
36057
|
-
var
|
|
37071
|
+
var import_node_path3 = require("node:path");
|
|
36058
37072
|
var REGEX_PRECEDING_KEYWORDS = /* @__PURE__ */ new Set([
|
|
36059
37073
|
"return",
|
|
36060
37074
|
"typeof",
|
|
@@ -36308,12 +37322,12 @@ function resolveImport(fromPath, specifier, listing, mapSpecifier) {
|
|
|
36308
37322
|
const clean = specifier.replace(/[?#].*$/, "");
|
|
36309
37323
|
const relative11 = clean === "." || clean === ".." || clean.startsWith("./") || clean.startsWith("../");
|
|
36310
37324
|
if (!relative11) return { kind: "external" };
|
|
36311
|
-
const base =
|
|
36312
|
-
if (base === ".." || base.startsWith("../") ||
|
|
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" };
|
|
36313
37327
|
return probeBase(base, listing);
|
|
36314
37328
|
}
|
|
36315
37329
|
function probeBase(base, listing) {
|
|
36316
|
-
const ext =
|
|
37330
|
+
const ext = import_node_path3.posix.extname(base);
|
|
36317
37331
|
if (ASSET_EXTS.has(ext.toLowerCase())) return { kind: "unresolved", reason: "asset" };
|
|
36318
37332
|
const candidates = [];
|
|
36319
37333
|
if (CODE_EXTS.includes(ext)) {
|
|
@@ -36957,7 +37971,7 @@ function prepareGrepV2(args2, env2) {
|
|
|
36957
37971
|
}
|
|
36958
37972
|
var NOT_A_NAME = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "catch", "return", "else", "do"]);
|
|
36959
37973
|
var IDENT = /^[\p{L}_$][\p{L}\p{N}_$]*[?!]?$/u;
|
|
36960
|
-
var
|
|
37974
|
+
var escapeRegExp4 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
36961
37975
|
var MAX_TREE_FILES = 80;
|
|
36962
37976
|
var MAX_NAME_LENGTH = 80;
|
|
36963
37977
|
function definitionsIn(text3, name2, path, parsed) {
|
|
@@ -36966,7 +37980,7 @@ function definitionsIn(text3, name2, path, parsed) {
|
|
|
36966
37980
|
if (parsed && tree !== null) parsed.count += 1;
|
|
36967
37981
|
if (tree !== null) return tree.filter((d) => d.name === name2).map((d) => ({ line: d.startLine, kind: d.kind }));
|
|
36968
37982
|
}
|
|
36969
|
-
const id =
|
|
37983
|
+
const id = escapeRegExp4(name2);
|
|
36970
37984
|
const rules = [
|
|
36971
37985
|
[new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:async\\s+)?function\\*?\\s+${id}(?![\\w$])`), "function"],
|
|
36972
37986
|
[new RegExp(`^\\s*(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+${id}(?![\\w$])`), "class"],
|
|
@@ -37010,8 +38024,8 @@ function importedFrom(fromText, name2) {
|
|
|
37010
38024
|
const id = name2.replace(/\$/g, "\\$");
|
|
37011
38025
|
let m = new RegExp(`import\\s+(?:type\\s+)?${id}\\s*(?:,\\s*\\{[^}]*\\}\\s*)?from\\s*['"]([^'"]+)['"]`).exec(fromText);
|
|
37012
38026
|
if (m) return { spec: m[1], original: "default" };
|
|
37013
|
-
const
|
|
37014
|
-
while (m =
|
|
38027
|
+
const named2 = /import\s+(?:type\s+)?(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g;
|
|
38028
|
+
while (m = named2.exec(fromText)) {
|
|
37015
38029
|
for (const part of m[1].split(",")) {
|
|
37016
38030
|
const p = /^\s*(?:type\s+)?([\w$]+)(?:\s+as\s+([\w$]+))?\s*$/.exec(part);
|
|
37017
38031
|
if (p && (p[2] ?? p[1]) === name2) return { spec: m[2], original: p[1] };
|
|
@@ -37061,10 +38075,10 @@ function defineThrough(path, original, env2, visible, hops) {
|
|
|
37061
38075
|
}
|
|
37062
38076
|
if (hops <= 0 || !supportsImportScan(path)) return null;
|
|
37063
38077
|
const next = [];
|
|
37064
|
-
const
|
|
38078
|
+
const named2 = /export\s*\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g;
|
|
37065
38079
|
let m;
|
|
37066
38080
|
const renames = [];
|
|
37067
|
-
while (m =
|
|
38081
|
+
while (m = named2.exec(text3)) {
|
|
37068
38082
|
for (const part of m[1].split(",")) {
|
|
37069
38083
|
const p = /^\s*([\w$]+)(?:\s+as\s+([\w$]+))?\s*$/.exec(part);
|
|
37070
38084
|
if (p && (p[2] ?? p[1]) === original) renames.push({ spec: m[2], source: p[1] });
|
|
@@ -37189,16 +38203,16 @@ function createNodeToolFs(rootDir = process.cwd()) {
|
|
|
37189
38203
|
return {
|
|
37190
38204
|
rootReal,
|
|
37191
38205
|
lstat(rel) {
|
|
37192
|
-
const s = (0, import_node_fs2.lstatSync)((0,
|
|
38206
|
+
const s = (0, import_node_fs2.lstatSync)((0, import_node_path4.join)(rootDir, rel));
|
|
37193
38207
|
return { isSymlink: s.isSymbolicLink(), isFile: s.isFile(), size: s.size };
|
|
37194
38208
|
},
|
|
37195
38209
|
realpathInside(rel) {
|
|
37196
|
-
const real = (0, import_node_fs2.realpathSync)((0,
|
|
37197
|
-
const r = (0,
|
|
37198
|
-
return r !== "" && !r.startsWith("..") && !(0,
|
|
38210
|
+
const real = (0, import_node_fs2.realpathSync)((0, import_node_path4.join)(rootDir, rel));
|
|
38211
|
+
const r = (0, import_node_path4.relative)(rootReal, real);
|
|
38212
|
+
return r !== "" && !r.startsWith("..") && !(0, import_node_path4.isAbsolute)(r);
|
|
37199
38213
|
},
|
|
37200
38214
|
readBytes(rel) {
|
|
37201
|
-
return (0, import_node_fs2.readFileSync)((0,
|
|
38215
|
+
return (0, import_node_fs2.readFileSync)((0, import_node_path4.join)(rootDir, rel));
|
|
37202
38216
|
}
|
|
37203
38217
|
};
|
|
37204
38218
|
}
|
|
@@ -37585,22 +38599,22 @@ function outsideRootMessage(root) {
|
|
|
37585
38599
|
|
|
37586
38600
|
// src/workspaceOverlay.ts
|
|
37587
38601
|
var import_node_fs3 = require("node:fs");
|
|
37588
|
-
var
|
|
38602
|
+
var import_node_path5 = require("node:path");
|
|
37589
38603
|
function createNodeWriteFs(rootDir = process.cwd()) {
|
|
37590
38604
|
const base = createNodeToolFs(rootDir);
|
|
37591
38605
|
const inside3 = (real) => {
|
|
37592
|
-
const r = (0,
|
|
37593
|
-
return !r.startsWith("..") && !(0,
|
|
38606
|
+
const r = (0, import_node_path5.relative)(base.rootReal, real);
|
|
38607
|
+
return !r.startsWith("..") && !(0, import_node_path5.isAbsolute)(r);
|
|
37594
38608
|
};
|
|
37595
38609
|
return {
|
|
37596
38610
|
...base,
|
|
37597
38611
|
parentInside(rel) {
|
|
37598
|
-
let dir = (0,
|
|
38612
|
+
let dir = (0, import_node_path5.dirname)((0, import_node_path5.join)(rootDir, rel));
|
|
37599
38613
|
for (; ; ) {
|
|
37600
38614
|
try {
|
|
37601
38615
|
return inside3((0, import_node_fs3.realpathSync)(dir));
|
|
37602
38616
|
} catch {
|
|
37603
|
-
const up = (0,
|
|
38617
|
+
const up = (0, import_node_path5.dirname)(dir);
|
|
37604
38618
|
if (up === dir) return false;
|
|
37605
38619
|
dir = up;
|
|
37606
38620
|
}
|
|
@@ -37608,7 +38622,7 @@ function createNodeWriteFs(rootDir = process.cwd()) {
|
|
|
37608
38622
|
},
|
|
37609
38623
|
exists(rel) {
|
|
37610
38624
|
try {
|
|
37611
|
-
(0, import_node_fs3.lstatSync)((0,
|
|
38625
|
+
(0, import_node_fs3.lstatSync)((0, import_node_path5.join)(rootDir, rel));
|
|
37612
38626
|
return true;
|
|
37613
38627
|
} catch {
|
|
37614
38628
|
return false;
|
|
@@ -37784,10 +38798,21 @@ function matchRows(results, path, test) {
|
|
|
37784
38798
|
function text(v, min, max) {
|
|
37785
38799
|
return typeof v === "string" && v.length >= min && v.length <= max ? v : null;
|
|
37786
38800
|
}
|
|
37787
|
-
|
|
38801
|
+
var FEATURE_KEYS = /* @__PURE__ */ new Set([...ALLOWED_KEYS, "testPath"]);
|
|
38802
|
+
var TEST_PATH_MAX = 300;
|
|
38803
|
+
function parseConflictReport(args2, caseIds, feature = false) {
|
|
37788
38804
|
if (typeof args2 !== "object" || args2 === null || Array.isArray(args2)) return { ok: false, field: "arguments" };
|
|
37789
38805
|
const a = args2;
|
|
37790
|
-
|
|
38806
|
+
const allowed = feature ? FEATURE_KEYS : ALLOWED_KEYS;
|
|
38807
|
+
for (const key of Object.keys(a)) if (!allowed.has(key)) return { ok: false, field: "arguments" };
|
|
38808
|
+
let testPath;
|
|
38809
|
+
if (feature && a.testPath !== void 0) {
|
|
38810
|
+
if (typeof a.testPath !== "string" || a.testPath.length > TEST_PATH_MAX) return { ok: false, field: "testPath" };
|
|
38811
|
+
if (a.testPath !== "") {
|
|
38812
|
+
if (normaliseToolPath(a.testPath).ok !== true) return { ok: false, field: "testPath" };
|
|
38813
|
+
testPath = a.testPath;
|
|
38814
|
+
}
|
|
38815
|
+
}
|
|
37791
38816
|
if (typeof a.path !== "string" || normaliseToolPath(a.path).ok !== true) return { ok: false, field: "path" };
|
|
37792
38817
|
const find = text(a.find, 1, BOUNDS.find);
|
|
37793
38818
|
if (find === null) return { ok: false, field: "find" };
|
|
@@ -37820,7 +38845,8 @@ function parseConflictReport(args2, caseIds) {
|
|
|
37820
38845
|
caseId: a.caseId,
|
|
37821
38846
|
reading: a.reading,
|
|
37822
38847
|
reason,
|
|
37823
|
-
correction: { field: a.caseField, text: caseText, ...valueFrom !== void 0 && valueTo !== void 0 ? { valueFrom, valueTo } : {}, why }
|
|
38848
|
+
correction: { field: a.caseField, text: caseText, ...valueFrom !== void 0 && valueTo !== void 0 ? { valueFrom, valueTo } : {}, why },
|
|
38849
|
+
...testPath !== void 0 ? { testPath } : {}
|
|
37824
38850
|
}
|
|
37825
38851
|
};
|
|
37826
38852
|
}
|
|
@@ -37896,10 +38922,10 @@ var TestConflictTool = class {
|
|
|
37896
38922
|
return { ...this.counts, rejectedBy: { ...this.rejectedBy } };
|
|
37897
38923
|
}
|
|
37898
38924
|
/** QUIKTR-1855: `hint` is added for a test file of another language than JavaScript, where the generic sentence names JavaScript things. */
|
|
37899
|
-
reject(reason, hint) {
|
|
38925
|
+
reject(reason, hint, instead) {
|
|
37900
38926
|
this.counts.rejected += 1;
|
|
37901
38927
|
this.rejectedBy[reason] = (this.rejectedBy[reason] ?? 0) + 1;
|
|
37902
|
-
return { status: "conflict_rejected", reason, message: hint ? `${REJECT_MESSAGES[reason]} ${hint}` : REJECT_MESSAGES[reason] };
|
|
38928
|
+
return { status: "conflict_rejected", reason, message: instead ?? (hint ? `${REJECT_MESSAGES[reason]} ${hint}` : REJECT_MESSAGES[reason]) };
|
|
37903
38929
|
}
|
|
37904
38930
|
async execute(call, ledger, limits) {
|
|
37905
38931
|
const finish = (r) => {
|
|
@@ -37910,10 +38936,11 @@ var TestConflictTool = class {
|
|
|
37910
38936
|
if (ledger.toolCalls >= limits.maxToolCalls) return finish(budgetResult("tool_calls"));
|
|
37911
38937
|
ledger.toolCalls += 1;
|
|
37912
38938
|
this.counts.calls += 1;
|
|
37913
|
-
const parsed = parseConflictReport(call.args, this.deps.caseIds);
|
|
38939
|
+
const parsed = parseConflictReport(call.args, this.deps.caseIds, this.deps.feature !== void 0);
|
|
37914
38940
|
if (!parsed.ok) return finish({ status: "bad_args", message: `${parsed.field} is not valid for report_test_conflict.` });
|
|
37915
38941
|
const report = parsed.report;
|
|
37916
|
-
|
|
38942
|
+
const about = report.testPath ?? report.path;
|
|
38943
|
+
if (!this.reported.some((r) => r.path === about && r.title === report.testTitle)) this.reported.push({ path: about, title: report.testTitle });
|
|
37917
38944
|
const dupKey = `${call.name}:${JSON.stringify(report)}`;
|
|
37918
38945
|
const earlier = ledger.seen.get(dupKey);
|
|
37919
38946
|
if (earlier !== void 0) {
|
|
@@ -37934,25 +38961,41 @@ var TestConflictTool = class {
|
|
|
37934
38961
|
}
|
|
37935
38962
|
async check(r) {
|
|
37936
38963
|
const d = this.deps;
|
|
38964
|
+
const feature = d.feature;
|
|
37937
38965
|
const key = `${r.path}\0${r.testTitle}`;
|
|
37938
|
-
const
|
|
37939
|
-
|
|
37940
|
-
|
|
38966
|
+
const helper = feature !== void 0 && r.testPath !== void 0 && !sameFile2(r.testPath, r.path);
|
|
38967
|
+
const servedRaw = helper ? r.testPath : r.path;
|
|
38968
|
+
const revision = helper ? void 0 : d.revisable?.find((x) => sameFile2(x.path, r.path) && x.title === r.testTitle);
|
|
38969
|
+
if (!revision && d.decided.some((x) => sameFile2(x.path, servedRaw) && x.title === r.testTitle)) {
|
|
38970
|
+
const approved = d.approvedChanges?.some((a) => sameFile2(a.path, servedRaw) && (a.title === r.testTitle || a.diskTitle === r.testTitle)) === true;
|
|
37941
38971
|
if (approved) d.log?.({ event: "codegen.conflict_refused_approved", phase: d.phase ?? null });
|
|
37942
38972
|
return this.reject("already_decided", approved ? APPROVED_AGAIN_HINT : void 0);
|
|
37943
38973
|
}
|
|
37944
38974
|
if (!this.byTest.has(key) && this.byTest.size >= this.max) return this.reject("too_many_conflicts");
|
|
37945
38975
|
const path = normaliseToolPath(r.path);
|
|
37946
|
-
if (
|
|
38976
|
+
if (helper) {
|
|
38977
|
+
if (!path.ok || !insideWriteRoot(path.path, d.writeRoot) || matchesDeniedPath(path.path, d.deniedPaths) !== null || !feature.isTestSupport(path.path)) {
|
|
38978
|
+
return this.reject("not_existing_test", void 0, FEATURE_NOT_TEST_SUPPORT);
|
|
38979
|
+
}
|
|
38980
|
+
} else if (!path.ok || !d.existingTests.has(path.path) || !insideWriteRoot(path.path, d.writeRoot) || matchesDeniedPath(path.path, d.deniedPaths) !== null) {
|
|
38981
|
+
return this.reject("not_existing_test");
|
|
38982
|
+
}
|
|
38983
|
+
const served = helper ? normaliseToolPath(servedRaw) : path;
|
|
38984
|
+
if (!served.ok || !d.existingTests.has(served.path) || !insideWriteRoot(served.path, d.writeRoot) || matchesDeniedPath(served.path, d.deniedPaths) !== null) {
|
|
37947
38985
|
return this.reject("not_existing_test");
|
|
37948
38986
|
}
|
|
37949
38987
|
const loaded = loadTextForEdit(d.fs, path.path, d.fileBytesMax);
|
|
37950
|
-
if (!loaded.ok) return this.reject("not_existing_test");
|
|
38988
|
+
if (!loaded.ok) return this.reject("not_existing_test", void 0, helper ? FEATURE_NOT_TEST_SUPPORT : void 0);
|
|
38989
|
+
const servedLoaded = helper ? loadTextForEdit(d.fs, served.path, d.fileBytesMax) : loaded;
|
|
38990
|
+
if (!servedLoaded.ok) return this.reject("not_existing_test");
|
|
37951
38991
|
const lf = revision ? revision.text : loaded.lf;
|
|
37952
|
-
|
|
37953
|
-
|
|
38992
|
+
const servedLf = helper ? servedLoaded.lf : lf;
|
|
38993
|
+
await preloadLanguages(helper ? [path.path, served.path] : [path.path]);
|
|
38994
|
+
const located = locateTests(served.path, servedLf);
|
|
37954
38995
|
if (!located) return this.reject("unsupported_language");
|
|
37955
|
-
const
|
|
38996
|
+
const edited = helper ? locateTests(path.path, lf) : located;
|
|
38997
|
+
if (!edited) return this.reject("unsupported_language");
|
|
38998
|
+
const other = langOfPath(served.path) !== null;
|
|
37956
38999
|
const matches = allTests(located).map((t, index2) => ({ t, index: index2 })).filter(({ t }) => t.title === r.testTitle);
|
|
37957
39000
|
if (matches.length === 0) {
|
|
37958
39001
|
return this.reject("title_not_found", other ? `The tests in that file are: ${titlesHint(allTests(located))}. The title is the name of the test function.` : void 0);
|
|
@@ -37965,46 +39008,88 @@ var TestConflictTool = class {
|
|
|
37965
39008
|
const at2 = lf.indexOf(r.find);
|
|
37966
39009
|
const changeLine = lineAt(lf, at2);
|
|
37967
39010
|
const lastLine = lineAt(lf, at2 + r.find.length - 1);
|
|
37968
|
-
|
|
37969
|
-
|
|
37970
|
-
|
|
37971
|
-
|
|
37972
|
-
|
|
39011
|
+
const inTest = !helper && changeLine >= (test.bodyStartLine ?? test.startLine) && lastLine <= test.endLine;
|
|
39012
|
+
let place = "test";
|
|
39013
|
+
if (!inTest) {
|
|
39014
|
+
if (!feature) return this.reject("find_outside_test");
|
|
39015
|
+
if (revision || allTests(edited).some((t) => changeLine <= t.endLine && lastLine >= t.startLine)) return this.reject("find_outside_test", void 0, FEATURE_FIND_OUTSIDE_TEST);
|
|
39016
|
+
place = helper ? "support" : "shared";
|
|
39017
|
+
}
|
|
39018
|
+
let edit = "expectations";
|
|
39019
|
+
let strictlyAdditive = false;
|
|
39020
|
+
if (place === "test" && testEditOverreach({ path: path.path, before: lf, after: applied.content, indexes: [index] }) !== null) {
|
|
39021
|
+
if (!feature) return this.reject("beyond_expectations", other ? OTHER_LANGUAGE_EXPECTATIONS : void 0);
|
|
39022
|
+
const verdict = setupAdded({ path: path.path, before: lf, after: applied.content, editable: [index] });
|
|
39023
|
+
if (!verdict.ok) return this.reject("beyond_expectations", void 0, FEATURE_BEYOND_EXPECTATIONS);
|
|
39024
|
+
edit = "add_only";
|
|
39025
|
+
strictlyAdditive = verdict.strictlyAdditive;
|
|
39026
|
+
} else if (place !== "test") {
|
|
39027
|
+
const verdict = setupAdded({ path: path.path, before: lf, after: applied.content, outside: true, ...helper ? { arranged: [{ path: served.path, text: servedLf }] } : {} });
|
|
39028
|
+
if (!verdict.ok) return this.reject("beyond_expectations", void 0, FEATURE_BEYOND_EXPECTATIONS);
|
|
39029
|
+
edit = "add_only";
|
|
39030
|
+
strictlyAdditive = verdict.strictlyAdditive;
|
|
39031
|
+
}
|
|
39032
|
+
const servedTest = { path: served.path, title: r.testTitle, describes: test.describes, line: test.startLine, index, ...isTable ? { table: true } : {} };
|
|
39033
|
+
const featureFields = feature ? {
|
|
39034
|
+
edit,
|
|
39035
|
+
strictlyAdditive,
|
|
39036
|
+
place,
|
|
39037
|
+
served: servedTest,
|
|
39038
|
+
...helper ? { testPath: served.path, servedText: servedLf } : {},
|
|
39039
|
+
...place === "shared" ? { usedBy: { files: [path.path], count: 1 } } : place === "support" ? { usedBy: feature.usedBy(path.path) } : {}
|
|
39040
|
+
} : {};
|
|
39041
|
+
if (revision) return this.recordRevision(r, revision, { path: path.path, test, index, isTable, changeLine, lf, ending: loaded.ending, bom: loaded.bom, featureFields }, key);
|
|
37973
39042
|
const base = await d.baseline().catch(() => null);
|
|
37974
39043
|
const results = base?.snapshot.results ?? null;
|
|
37975
39044
|
if (!base || base.snapshot.timedOut === true || !results) return this.reject("baseline_unknown");
|
|
37976
|
-
const mine = isTable ? matchRows(results,
|
|
39045
|
+
const mine = isTable ? matchRows(results, served.path, test) : [...results.entries()].filter(([id]) => {
|
|
37977
39046
|
const { file, name: name2 } = splitTestId(id);
|
|
37978
|
-
return (file === null || idPlaceMatches(file,
|
|
39047
|
+
return (file === null || idPlaceMatches(file, served.path)) && nameIsTitle(name2, r.testTitle, test.describes);
|
|
37979
39048
|
});
|
|
37980
39049
|
if (mine.length === 0) {
|
|
37981
39050
|
if (!isTable) return this.reject("baseline_unknown");
|
|
37982
|
-
const rowsKey = `${
|
|
37983
|
-
if (!this.generated.has(rowsKey)) this.generated.set(rowsKey, { path:
|
|
39051
|
+
const rowsKey = `${served.path}\0${test.startLine}`;
|
|
39052
|
+
if (!this.generated.has(rowsKey)) this.generated.set(rowsKey, { path: served.path, line: test.startLine, caseId: r.caseId });
|
|
37984
39053
|
return this.reject("generated_test");
|
|
37985
39054
|
}
|
|
37986
39055
|
if (mine.some(([, passed]) => !passed)) return this.reject("not_passing_before");
|
|
37987
39056
|
const scrub = d.scrub ?? ((s) => s);
|
|
37988
|
-
const history = mapHistory((d.history ?? ((p, title) => readTestHistory({ path: p, title })))(
|
|
39057
|
+
const history = mapHistory((d.history ?? ((p, title) => readTestHistory({ path: p, title })))(served.path, r.testTitle), scrub);
|
|
37989
39058
|
const conflict = {
|
|
37990
39059
|
...r,
|
|
37991
39060
|
path: path.path,
|
|
37992
39061
|
describes: test.describes,
|
|
37993
|
-
|
|
37994
|
-
|
|
39062
|
+
// QUIKTR-2442: an update outside the test is placed by the lines it changes (in the helper, for a helper).
|
|
39063
|
+
startLine: place === "test" ? test.startLine : changeLine,
|
|
39064
|
+
endLine: place === "test" ? test.endLine : lastLine,
|
|
37995
39065
|
changeLine,
|
|
37996
|
-
index,
|
|
39066
|
+
index: place === "test" ? index : -1,
|
|
37997
39067
|
...isTable ? { rows: mine.length } : {},
|
|
37998
39068
|
history,
|
|
37999
39069
|
originalLf: loaded.lf,
|
|
38000
39070
|
ending: loaded.ending,
|
|
38001
39071
|
bom: loaded.bom,
|
|
38002
|
-
...d.phase ? { phase: d.phase } : {}
|
|
39072
|
+
...d.phase ? { phase: d.phase } : {},
|
|
39073
|
+
...featureFields
|
|
38003
39074
|
};
|
|
39075
|
+
if (!helper) delete conflict.testPath;
|
|
38004
39076
|
this.byTest.set(key, conflict);
|
|
38005
39077
|
this.counts.recorded += 1;
|
|
38006
|
-
d.log?.({
|
|
38007
|
-
|
|
39078
|
+
d.log?.({
|
|
39079
|
+
event: "codegen.conflict_recorded",
|
|
39080
|
+
reading: r.reading,
|
|
39081
|
+
phase: d.phase ?? null,
|
|
39082
|
+
historyAvailable: history.available,
|
|
39083
|
+
...isTable ? { rows: mine.length } : {},
|
|
39084
|
+
...feature ? { edit, place, strictlyAdditive } : {}
|
|
39085
|
+
});
|
|
39086
|
+
return { status: "conflict_recorded", message: this.recordedMessage(), output: { history } };
|
|
39087
|
+
}
|
|
39088
|
+
/** What a recorded report answers: a stop (loop-7) or a proposal (fix first); in feature mode, also: keep the change. */
|
|
39089
|
+
recordedMessage() {
|
|
39090
|
+
const d = this.deps;
|
|
39091
|
+
if (d.feature) return d.fixFirst ? FEATURE_RECORDED_MESSAGE_FIX_FIRST : FEATURE_RECORDED_MESSAGE;
|
|
39092
|
+
return d.fixFirst ? RECORDED_MESSAGE_FIX_FIRST : RECORDED_MESSAGE;
|
|
38008
39093
|
}
|
|
38009
39094
|
/** QUIKTR-1844: record a revision of an approved test change that does not fit. */
|
|
38010
39095
|
recordRevision(r, revision, at2, key) {
|
|
@@ -38027,12 +39112,14 @@ var TestConflictTool = class {
|
|
|
38027
39112
|
originalLf: at2.lf,
|
|
38028
39113
|
ending: at2.ending,
|
|
38029
39114
|
bom: at2.bom,
|
|
38030
|
-
...d.phase ? { phase: d.phase } : {}
|
|
39115
|
+
...d.phase ? { phase: d.phase } : {},
|
|
39116
|
+
...at2.featureFields
|
|
38031
39117
|
};
|
|
39118
|
+
delete conflict.testPath;
|
|
38032
39119
|
this.byTest.set(key, conflict);
|
|
38033
39120
|
this.counts.recorded += 1;
|
|
38034
39121
|
d.log?.({ event: "codegen.conflict_recorded", reading: r.reading, phase: d.phase ?? null, historyAvailable: history.available, revision: true, ...at2.isTable ? { rows: revision.rows } : {} });
|
|
38035
|
-
return { status: "conflict_recorded", message:
|
|
39122
|
+
return { status: "conflict_recorded", message: this.recordedMessage(), output: { history } };
|
|
38036
39123
|
}
|
|
38037
39124
|
};
|
|
38038
39125
|
function fileText(lf, ending, bom) {
|
|
@@ -38058,14 +39145,15 @@ function buildProposalFiles(conflicts) {
|
|
|
38058
39145
|
}
|
|
38059
39146
|
if (kept.length === 0) continue;
|
|
38060
39147
|
const located = locateTests(path, content);
|
|
38061
|
-
const indexes = kept.map((c) => c.index);
|
|
38062
|
-
if (!located ||
|
|
39148
|
+
const indexes = kept.filter((c) => c.index >= 0).map((c) => c.index);
|
|
39149
|
+
if (!located || editOverreach(path, first.originalLf, content, kept, indexes) !== null) {
|
|
38063
39150
|
dropped.push(...kept);
|
|
38064
39151
|
continue;
|
|
38065
39152
|
}
|
|
38066
39153
|
const after = allTests(located);
|
|
38067
39154
|
const stale = /* @__PURE__ */ new Map();
|
|
38068
39155
|
for (const c of kept) {
|
|
39156
|
+
if (c.index < 0) continue;
|
|
38069
39157
|
const t = after[c.index];
|
|
38070
39158
|
if (!t) continue;
|
|
38071
39159
|
const found = staleExpectations({ find: c.find, replace: c.replace, newTitle: t.title, newTestText: located.code.slice(t.start, t.end), firstLine: t.startLine });
|
|
@@ -38078,12 +39166,18 @@ function buildProposalFiles(conflicts) {
|
|
|
38078
39166
|
ending: first.ending,
|
|
38079
39167
|
bom: first.bom,
|
|
38080
39168
|
conflicts: kept,
|
|
38081
|
-
newTitles: new Map(kept.map((c) => [c.index, after[c.index]?.title ?? c.testTitle])),
|
|
39169
|
+
newTitles: new Map(kept.filter((c) => c.index >= 0).map((c) => [c.index, after[c.index]?.title ?? c.testTitle])),
|
|
38082
39170
|
stale
|
|
38083
39171
|
});
|
|
38084
39172
|
}
|
|
38085
39173
|
return { files, dropped };
|
|
38086
39174
|
}
|
|
39175
|
+
function editOverreach(path, before, after, kept, indexes) {
|
|
39176
|
+
if (kept.every((c) => (c.edit === void 0 || c.edit === "expectations") && c.index >= 0)) return testEditOverreach({ path, before, after, indexes });
|
|
39177
|
+
const arranged = kept.flatMap((c) => c.servedText !== void 0 && c.served ? [{ path: c.served.path, text: c.servedText }] : []);
|
|
39178
|
+
const verdict = setupAdded({ path, before, after, editable: indexes, outside: kept.some((c) => c.index < 0), legacy: true, arranged });
|
|
39179
|
+
return verdict.ok ? null : verdict.why;
|
|
39180
|
+
}
|
|
38087
39181
|
|
|
38088
39182
|
// src/proposal.ts
|
|
38089
39183
|
var GIT_MAX_BUFFER2 = 64 * 1024 * 1024;
|
|
@@ -38107,6 +39201,9 @@ function proposalBranchName(issueKey, githubRunId) {
|
|
|
38107
39201
|
const id = githubRunId.replace(/[^A-Za-z0-9]/g, "").slice(0, 20) || "0";
|
|
38108
39202
|
return `quikpilot/${key}-test-change-${id}`;
|
|
38109
39203
|
}
|
|
39204
|
+
var MAX_FIXES = 20;
|
|
39205
|
+
var MAX_USED_BY2 = 20;
|
|
39206
|
+
var MAX_SETUP_FOR = 8;
|
|
38110
39207
|
function lineOf2(c, file) {
|
|
38111
39208
|
const newTitle = file.newTitles.get(c.index);
|
|
38112
39209
|
const title = c.diskTitle ?? c.testTitle;
|
|
@@ -38129,7 +39226,11 @@ function lineOf2(c, file) {
|
|
|
38129
39226
|
...c.rows !== void 0 ? { rows: c.rows } : {},
|
|
38130
39227
|
...file.stale.get(c.index) ? { stale: file.stale.get(c.index) } : {},
|
|
38131
39228
|
...c.revises !== void 0 ? { revises: c.revises } : {},
|
|
38132
|
-
...c.misfit !== void 0 ? { misfit: c.misfit } : {}
|
|
39229
|
+
...c.misfit !== void 0 ? { misfit: c.misfit } : {},
|
|
39230
|
+
...c.proof !== void 0 ? { proof: c.proof } : {},
|
|
39231
|
+
...c.testPath !== void 0 ? { testPath: c.testPath } : {},
|
|
39232
|
+
...c.fixes && c.fixes.length > 0 ? { fixes: c.fixes.slice(0, MAX_FIXES).map((f) => ({ path: f.path, title: f.title })) } : {},
|
|
39233
|
+
...c.usedBy ? { usedBy: { files: c.usedBy.files.slice(0, MAX_USED_BY2), count: Math.max(c.usedBy.count, Math.min(c.usedBy.files.length, MAX_USED_BY2)) } } : {}
|
|
38133
39234
|
};
|
|
38134
39235
|
}
|
|
38135
39236
|
function revisionNote(sha2, m) {
|
|
@@ -38144,22 +39245,46 @@ function staleNote(s) {
|
|
|
38144
39245
|
function oneLine(s) {
|
|
38145
39246
|
return s.replace(/\s+/g, " ").trim();
|
|
38146
39247
|
}
|
|
39248
|
+
function featureNotes(l) {
|
|
39249
|
+
const out2 = [];
|
|
39250
|
+
if (l.proof === "broken_by_change") {
|
|
39251
|
+
out2.push(" The change for the approved case breaks this test only because it lacks set-up for the new code. With this update every broken test passes again and no other test fails; it only adds, and keeps every check.");
|
|
39252
|
+
}
|
|
39253
|
+
if (l.proof === "old_code") out2.push(" With this change the test fails on the code as it is today, so it pins what the approved case changes.");
|
|
39254
|
+
if (l.fixes && l.fixes.length > 0) {
|
|
39255
|
+
const shown = l.fixes.slice(0, MAX_SETUP_FOR).map((f) => `${f.path}: "${oneLine(f.title)}"`);
|
|
39256
|
+
out2.push(` Passes again with this update: ${shown.join("; ")}${l.fixes.length > MAX_SETUP_FOR ? `; and ${l.fixes.length - MAX_SETUP_FOR} more` : ""}.`);
|
|
39257
|
+
}
|
|
39258
|
+
if (l.usedBy && l.usedBy.files.length > 0) {
|
|
39259
|
+
out2.push(` This set-up is used by ${l.usedBy.count} test file${l.usedBy.count === 1 ? "" : "s"}: ${l.usedBy.files.join(", ")}${l.usedBy.count > l.usedBy.files.length ? ", ..." : ""}.`);
|
|
39260
|
+
}
|
|
39261
|
+
return out2;
|
|
39262
|
+
}
|
|
38147
39263
|
function buildProposalMessage(input) {
|
|
38148
39264
|
const n = input.lines.length;
|
|
38149
39265
|
const head = `QuikPilot proposal${input.issueKey ? ` for ${input.issueKey}` : ""}: change ${n} existing test${n === 1 ? "" : "s"}`;
|
|
39266
|
+
const feature = input.lines.some((l) => l.proof !== void 0);
|
|
39267
|
+
const intro = feature ? [
|
|
39268
|
+
"While building the approved feature, QuikPilot found existing tests its change breaks: some only lack set-up for the new code, others",
|
|
39269
|
+
"check what the approved feature changes. It never changes an existing test on its own, so it stopped and asked a person to decide in",
|
|
39270
|
+
"QuikProjects: approve this change, keep the tests as they are (the approved case is then narrowed instead), or stop."
|
|
39271
|
+
] : [
|
|
39272
|
+
"While preparing a fix, QuikPilot found existing tests that expect exactly what an approved test case calls wrong. It never changes an",
|
|
39273
|
+
"existing test on its own, so it stopped before writing any code and asked a person to decide in QuikProjects: approve this change,",
|
|
39274
|
+
"say the test is right (the approved case is then corrected instead), or stop."
|
|
39275
|
+
];
|
|
38150
39276
|
const body2 = [
|
|
38151
39277
|
"This commit is a PROPOSAL. Nothing in it is merged, and no pull request has been opened for it.",
|
|
38152
39278
|
"",
|
|
38153
|
-
|
|
38154
|
-
"existing test on its own, so it stopped before writing any code and asked a person to decide in QuikProjects: approve this change,",
|
|
38155
|
-
"say the test is right (the approved case is then corrected instead), or stop.",
|
|
39279
|
+
...intro,
|
|
38156
39280
|
"",
|
|
38157
39281
|
...input.lines.flatMap((l, i3) => [
|
|
38158
|
-
`${i3 + 1}. ${l.path}, line ${l.changeLine}: "${oneLine(l.title)}"`,
|
|
39282
|
+
l.testPath !== void 0 ? `${i3 + 1}. ${l.path}, line ${l.changeLine}: set-up for "${oneLine(l.title)}" in ${l.testPath}` : `${i3 + 1}. ${l.path}, line ${l.changeLine}: "${oneLine(l.title)}"`,
|
|
38159
39283
|
` Approved case ${l.caseId}: QuikPilot read this test as ${l.reading}. ${oneLine(l.reason)}`,
|
|
38160
39284
|
...l.history.available ? [` Added ${l.history.addedAt ?? ""} in ${l.history.addedBySha?.slice(0, 10) ?? "a commit"}${l.history.subject ? `: ${oneLine(l.history.subject)}` : ""}`] : [],
|
|
38161
39285
|
...l.history.sameCommitPaths && l.history.sameCommitPaths.length > 0 ? [` The same change also touched: ${l.history.sameCommitPaths.slice(0, 5).join(", ")}${l.history.sameCommitPaths.length > 5 || l.history.sameCommitMore ? ", ..." : ""}`] : [],
|
|
38162
|
-
...l.oldCodeChecked ? [" With this change the test fails on the code as it is today, so it shows the bug."] : [],
|
|
39286
|
+
...l.oldCodeChecked && l.proof === void 0 ? [" With this change the test fails on the code as it is today, so it shows the bug."] : [],
|
|
39287
|
+
...featureNotes(l),
|
|
38163
39288
|
...l.newCode === "passes" ? [" With this change the test passes on the fix QuikPilot wrote."] : [],
|
|
38164
39289
|
...l.newCode === "fails" ? [" With this change the test still fails on the fix QuikPilot wrote."] : [],
|
|
38165
39290
|
...l.newCode === "not_checked" ? [" It was not checked whether this change passes on the fix QuikPilot wrote."] : [],
|
|
@@ -38188,6 +39313,14 @@ function isStale(v) {
|
|
|
38188
39313
|
const s = v;
|
|
38189
39314
|
return Array.isArray(s.tokens) && s.tokens.length >= 1 && s.tokens.length <= 4 && s.tokens.every((t) => isStr(t, 60)) && typeof s.inTitle === "boolean" && Array.isArray(s.commentLines) && s.commentLines.length <= 6 && s.commentLines.every(isLine) && (s.inTitle === true || s.commentLines.length > 0);
|
|
38190
39315
|
}
|
|
39316
|
+
function isFixes(v) {
|
|
39317
|
+
return Array.isArray(v) && v.length >= 1 && v.length <= MAX_FIXES && v.every((f) => typeof f === "object" && f !== null && isStr(f.path, 300) && isStr(f.title, 300));
|
|
39318
|
+
}
|
|
39319
|
+
function isUsedBy(v) {
|
|
39320
|
+
if (typeof v !== "object" || v === null) return false;
|
|
39321
|
+
const u = v;
|
|
39322
|
+
return Array.isArray(u.files) && u.files.length <= MAX_USED_BY2 && u.files.every((f) => isStr(f, 300)) && typeof u.count === "number" && Number.isInteger(u.count) && u.count >= u.files.length && u.count <= 1e6;
|
|
39323
|
+
}
|
|
38191
39324
|
function parseProposalMessage(message) {
|
|
38192
39325
|
const out2 = [];
|
|
38193
39326
|
for (const raw of message.split("\n")) {
|
|
@@ -38202,7 +39335,7 @@ function parseProposalMessage(message) {
|
|
|
38202
39335
|
const o = j;
|
|
38203
39336
|
const c = o.correction;
|
|
38204
39337
|
const h = o.history;
|
|
38205
|
-
if (o.v !== 1 || !isStr(o.path, 300) || !isStr(o.title, 300) || o.newTitle !== void 0 && !isStr(o.newTitle, 300) || !isStr(o.caseId, 64) || !CONFLICT_READINGS.includes(o.reading) || !isLine(o.startLine) || !isLine(o.endLine) || !isLine(o.changeLine) || !isStr(o.reason, 300) || typeof c !== "object" || c === null || !CONFLICT_CASE_FIELDS.includes(c.field) || !isStr(c.text, 1e3) || !isStr(c.why, 300) || typeof h !== "object" || h === null || typeof h.available !== "boolean" || typeof o.oldCodeChecked !== "boolean" || o.newCode !== void 0 && !["passes", "fails", "not_checked"].includes(o.newCode) || o.newEndLine !== void 0 && !isLine(o.newEndLine) || o.rows !== void 0 && !(typeof o.rows === "number" && Number.isInteger(o.rows) && o.rows >= 1 && o.rows <= 1e4) || o.stale !== void 0 && !isStale(o.stale) || o.revises !== void 0 && !(typeof o.revises === "string" && /^[0-9a-f]{40}$/.test(o.revises)) || o.misfit !== void 0 && (o.revises === void 0 || !isMisfit(o.misfit))) {
|
|
39338
|
+
if (o.v !== 1 || !isStr(o.path, 300) || !isStr(o.title, 300) || o.newTitle !== void 0 && !isStr(o.newTitle, 300) || !isStr(o.caseId, 64) || !CONFLICT_READINGS.includes(o.reading) || !isLine(o.startLine) || !isLine(o.endLine) || !isLine(o.changeLine) || !isStr(o.reason, 300) || typeof c !== "object" || c === null || !CONFLICT_CASE_FIELDS.includes(c.field) || !isStr(c.text, 1e3) || !isStr(c.why, 300) || typeof h !== "object" || h === null || typeof h.available !== "boolean" || typeof o.oldCodeChecked !== "boolean" || o.newCode !== void 0 && !["passes", "fails", "not_checked"].includes(o.newCode) || o.newEndLine !== void 0 && !isLine(o.newEndLine) || o.rows !== void 0 && !(typeof o.rows === "number" && Number.isInteger(o.rows) && o.rows >= 1 && o.rows <= 1e4) || o.stale !== void 0 && !isStale(o.stale) || o.revises !== void 0 && !(typeof o.revises === "string" && /^[0-9a-f]{40}$/.test(o.revises)) || o.misfit !== void 0 && (o.revises === void 0 || !isMisfit(o.misfit)) || o.proof !== void 0 && o.proof !== "old_code" && o.proof !== "broken_by_change" || o.testPath !== void 0 && !isStr(o.testPath, 300) || o.fixes !== void 0 && !isFixes(o.fixes) || o.usedBy !== void 0 && !isUsedBy(o.usedBy)) {
|
|
38206
39339
|
continue;
|
|
38207
39340
|
}
|
|
38208
39341
|
out2.push(o);
|
|
@@ -38215,9 +39348,10 @@ function createProposalCommit(input) {
|
|
|
38215
39348
|
const { files, dropped } = buildProposalFiles(input.conflicts);
|
|
38216
39349
|
if (files.length === 0) return null;
|
|
38217
39350
|
const lines = files.flatMap((f) => f.conflicts.map((c) => lineOf2(c, f)));
|
|
38218
|
-
const
|
|
39351
|
+
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));
|
|
39352
|
+
const dir = (0, import_node_fs4.mkdtempSync)((0, import_node_path6.join)((0, import_node_os.tmpdir)(), "qp-proposal-"));
|
|
38219
39353
|
try {
|
|
38220
|
-
const env2 = { GIT_INDEX_FILE: (0,
|
|
39354
|
+
const env2 = { GIT_INDEX_FILE: (0, import_node_path6.join)(dir, "index"), ...BOT_ENV };
|
|
38221
39355
|
const head = git3(["rev-parse", "HEAD"], { cwd }).trim();
|
|
38222
39356
|
git3(["read-tree", head], { env: env2, cwd });
|
|
38223
39357
|
for (const f of files) {
|
|
@@ -38230,7 +39364,7 @@ function createProposalCommit(input) {
|
|
|
38230
39364
|
const treeSha = git3(["write-tree"], { env: env2, cwd }).trim();
|
|
38231
39365
|
const sha2 = git3(["commit-tree", treeSha, "-p", head, "-F", "-"], { input: buildProposalMessage({ issueKey: input.issueKey, lines }), env: env2, cwd }).trim();
|
|
38232
39366
|
git3(["update-ref", `refs/heads/${input.branch}`, sha2], { cwd });
|
|
38233
|
-
return { sha: sha2, branch: input.branch, files, lines, dropped };
|
|
39367
|
+
return { sha: sha2, branch: input.branch, files, lines, dropped, ...setupFor.some((s) => s !== void 0) ? { setupFor } : {} };
|
|
38234
39368
|
} finally {
|
|
38235
39369
|
(0, import_node_fs4.rmSync)(dir, { recursive: true, force: true });
|
|
38236
39370
|
}
|
|
@@ -38241,7 +39375,7 @@ function pushProposal(branch, installationToken, push2 = push) {
|
|
|
38241
39375
|
function conflictsReport(p) {
|
|
38242
39376
|
return {
|
|
38243
39377
|
proposal: { branch: p.branch, sha: p.sha },
|
|
38244
|
-
conflicts: p.lines.map((l) => ({
|
|
39378
|
+
conflicts: p.lines.map((l, i3) => ({
|
|
38245
39379
|
path: l.path,
|
|
38246
39380
|
startLine: l.startLine,
|
|
38247
39381
|
endLine: l.endLine,
|
|
@@ -38261,7 +39395,10 @@ function conflictsReport(p) {
|
|
|
38261
39395
|
...l.history.sameCommitMore ? { sameCommitMore: true } : {}
|
|
38262
39396
|
}
|
|
38263
39397
|
} : {},
|
|
38264
|
-
correction: l.correction
|
|
39398
|
+
correction: l.correction,
|
|
39399
|
+
...l.proof !== void 0 ? { proof: l.proof } : {},
|
|
39400
|
+
...p.setupFor?.[i3] && p.setupFor[i3].length > 0 ? { setupFor: p.setupFor[i3].slice(0, MAX_SETUP_FOR) } : {},
|
|
39401
|
+
...l.usedBy && l.usedBy.files.length > 0 ? { usedBy: { files: l.usedBy.files.slice(0, MAX_USED_BY2), total: Math.max(1, l.usedBy.count, l.usedBy.files.length) } } : {}
|
|
38265
39402
|
}))
|
|
38266
39403
|
};
|
|
38267
39404
|
}
|
|
@@ -38303,14 +39440,14 @@ function loadApprovedTests(input) {
|
|
|
38303
39440
|
return drop("the proposal could not be read", "read_failed");
|
|
38304
39441
|
}
|
|
38305
39442
|
if (changed.length === 0 || changed.some((f) => !paths.includes(f))) return drop("it changes files its message does not name", "foreign_files");
|
|
38306
|
-
const decided = (use) => use.map((l) => ({ path: l.path, testTitle: l.newTitle ?? l.title, caseId: l.caseId, decision }));
|
|
38307
|
-
const titlesOf = (use) => use.flatMap((l) => [{ path: l.path, title: l.title }, ...l.newTitle !== void 0 ? [{ path: l.path, title: l.newTitle }] : []]);
|
|
39443
|
+
const decided = (use) => use.map((l) => ({ path: l.testPath ?? l.path, testTitle: l.newTitle ?? l.title, caseId: l.caseId, decision }));
|
|
39444
|
+
const titlesOf = (use) => use.flatMap((l) => [{ path: l.testPath ?? l.path, title: l.title }, ...l.newTitle !== void 0 ? [{ path: l.testPath ?? l.path, title: l.newTitle }] : []]);
|
|
38308
39445
|
if (decision === "TEST_RIGHT") {
|
|
38309
39446
|
return { approved: { decision, files: [], decided: decided(lines), titles: titlesOf(lines), proposals: [], approvedTests: [], revises: [] }, warnings };
|
|
38310
39447
|
}
|
|
38311
39448
|
const readCurrent = input.readCurrent ?? ((path) => {
|
|
38312
39449
|
try {
|
|
38313
|
-
return (0, import_node_fs5.readFileSync)((0,
|
|
39450
|
+
return (0, import_node_fs5.readFileSync)((0, import_node_path7.join)(cwd ?? process.cwd(), path), "utf8");
|
|
38314
39451
|
} catch {
|
|
38315
39452
|
return null;
|
|
38316
39453
|
}
|
|
@@ -38334,12 +39471,14 @@ function loadApprovedTests(input) {
|
|
|
38334
39471
|
continue;
|
|
38335
39472
|
}
|
|
38336
39473
|
const before = locateTests(path, toLf(stripBom(current2)));
|
|
38337
|
-
const
|
|
38338
|
-
|
|
39474
|
+
const featureLines = mine.some((l) => l.proof !== void 0);
|
|
39475
|
+
const plan = featureLines ? featurePlan(path, before, mine, readCurrent) : null;
|
|
39476
|
+
const indexes = plan ? plan.indexes : mine.map((l) => (before ? allTests(before) : []).findIndex((t) => t.title === l.title));
|
|
39477
|
+
if (!before || (plan ? plan.missing : indexes.some((i3) => i3 < 0))) {
|
|
38339
39478
|
warnings.push(`The tests proposed for change in ${path} were not found in it, so that change was not applied.`);
|
|
38340
39479
|
continue;
|
|
38341
39480
|
}
|
|
38342
|
-
const overreach = testEditOverreach({ path, before: toLf(stripBom(current2)), after: toLf(stripBom(proposed)), indexes });
|
|
39481
|
+
const overreach = plan ? setupOverreach({ path, before: toLf(stripBom(current2)), after: toLf(stripBom(proposed)), editable: indexes, outside: plan.outside, legacy: true, arranged: plan.arranged }) : testEditOverreach({ path, before: toLf(stripBom(current2)), after: toLf(stripBom(proposed)), indexes });
|
|
38343
39482
|
if (overreach !== null) {
|
|
38344
39483
|
warnings.push(`The proposed change to ${path} was not applied: ${overreach}.`);
|
|
38345
39484
|
continue;
|
|
@@ -38353,17 +39492,48 @@ function loadApprovedTests(input) {
|
|
|
38353
39492
|
}
|
|
38354
39493
|
log({ event: "codegen.approval_loaded", decision, files: files.length, tests: kept.length, dropped: lines.length - kept.length });
|
|
38355
39494
|
const tests = kept.map((l) => ({ path: l.path, line: l.changeLine, caseId: l.caseId }));
|
|
38356
|
-
const approvedTests = kept.map((l) => ({ path: l.path, diskTitle: l.title, title: l.newTitle ?? l.title, caseId: l.caseId, sha: sha2 }));
|
|
39495
|
+
const approvedTests = kept.map((l) => ({ path: l.testPath ?? l.path, diskTitle: l.title, title: l.newTitle ?? l.title, caseId: l.caseId, sha: sha2 }));
|
|
38357
39496
|
const revises = [...new Set(kept.filter((l) => l.revises !== void 0).map((l) => l.path))];
|
|
38358
39497
|
return { approved: { decision, files, decided: decided(kept), titles: titlesOf(kept), proposals: [{ branch, sha: sha2, tests }], approvedTests, revises }, warnings };
|
|
38359
39498
|
}
|
|
39499
|
+
function featurePlan(path, before, lines, readCurrent) {
|
|
39500
|
+
const tests = before ? allTests(before) : [];
|
|
39501
|
+
const indexes = [];
|
|
39502
|
+
const arranged = [];
|
|
39503
|
+
let outside = false;
|
|
39504
|
+
let missing = false;
|
|
39505
|
+
for (const l of lines) {
|
|
39506
|
+
if (l.testPath !== void 0) {
|
|
39507
|
+
const raw = readCurrent(l.testPath);
|
|
39508
|
+
const text3 = raw === null ? null : toLf(stripBom(raw));
|
|
39509
|
+
const located = text3 === null ? null : locateTests(l.testPath, text3);
|
|
39510
|
+
if (!located || !allTests(located).some((t2) => t2.title === l.title)) missing = true;
|
|
39511
|
+
else arranged.push({ path: l.testPath, text: text3 });
|
|
39512
|
+
outside = true;
|
|
39513
|
+
continue;
|
|
39514
|
+
}
|
|
39515
|
+
const i3 = tests.findIndex((t2) => t2.title === l.title);
|
|
39516
|
+
if (i3 < 0) {
|
|
39517
|
+
missing = true;
|
|
39518
|
+
continue;
|
|
39519
|
+
}
|
|
39520
|
+
const t = tests[i3];
|
|
39521
|
+
if (l.proof !== void 0 && (l.changeLine < (t.bodyStartLine ?? t.startLine) || l.changeLine > t.endLine)) outside = true;
|
|
39522
|
+
else indexes.push(i3);
|
|
39523
|
+
}
|
|
39524
|
+
return { indexes, outside, arranged, missing };
|
|
39525
|
+
}
|
|
39526
|
+
function setupOverreach(input) {
|
|
39527
|
+
const verdict = setupAdded(input);
|
|
39528
|
+
return verdict.ok ? null : verdict.why;
|
|
39529
|
+
}
|
|
38360
39530
|
var gitMergeText = ({ ours, base, theirs }) => {
|
|
38361
|
-
const dir = (0, import_node_fs5.mkdtempSync)((0,
|
|
39531
|
+
const dir = (0, import_node_fs5.mkdtempSync)((0, import_node_path7.join)((0, import_node_os2.tmpdir)(), "qp-merge-"));
|
|
38362
39532
|
try {
|
|
38363
|
-
(0, import_node_fs5.writeFileSync)((0,
|
|
38364
|
-
(0, import_node_fs5.writeFileSync)((0,
|
|
38365
|
-
(0, import_node_fs5.writeFileSync)((0,
|
|
38366
|
-
return (0, import_node_child_process4.execFileSync)("git", ["merge-file", "-p", (0,
|
|
39533
|
+
(0, import_node_fs5.writeFileSync)((0, import_node_path7.join)(dir, "ours"), ours);
|
|
39534
|
+
(0, import_node_fs5.writeFileSync)((0, import_node_path7.join)(dir, "base"), base);
|
|
39535
|
+
(0, import_node_fs5.writeFileSync)((0, import_node_path7.join)(dir, "theirs"), theirs);
|
|
39536
|
+
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")], {
|
|
38367
39537
|
encoding: "utf8",
|
|
38368
39538
|
maxBuffer: 64 * 1024 * 1024,
|
|
38369
39539
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -38378,7 +39548,7 @@ function loadApprovals(input) {
|
|
|
38378
39548
|
const warnings = [];
|
|
38379
39549
|
const readCurrent = input.readCurrent ?? ((path) => {
|
|
38380
39550
|
try {
|
|
38381
|
-
return (0, import_node_fs5.readFileSync)((0,
|
|
39551
|
+
return (0, import_node_fs5.readFileSync)((0, import_node_path7.join)(input.cwd ?? process.cwd(), path), "utf8");
|
|
38382
39552
|
} catch {
|
|
38383
39553
|
return null;
|
|
38384
39554
|
}
|
|
@@ -38526,7 +39696,7 @@ async function fetchWithRetry(url, init2, { retries = 2, backoffMs = 250 } = {})
|
|
|
38526
39696
|
var REPORT_RETRY_STATUSES = /* @__PURE__ */ new Set([500, 502, 503, 504]);
|
|
38527
39697
|
var REPORT_RETRY_WAITS_MS = [2e3, 5e3, 1e4];
|
|
38528
39698
|
async function reportBack(params) {
|
|
38529
|
-
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, testsCorrected, codegenLoop, unresolved, aiCostUsd, testConflicts, approvedTestsApplied } = params;
|
|
39699
|
+
const { callbackUrl, runToken, status, branch, warnings, targeting, baselineFindings, vanishedTests, unsuppliedInputs, changesNoTestDependsOn, testsCorrected, codegenLoop, unresolved, aiCostUsd, testConflicts, approvedTestsApplied, databaseChange } = params;
|
|
38530
39700
|
const sleep = params.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
|
|
38531
39701
|
const body2 = { status };
|
|
38532
39702
|
if (branch) body2.branch = branch;
|
|
@@ -38542,6 +39712,7 @@ async function reportBack(params) {
|
|
|
38542
39712
|
if (typeof aiCostUsd === "number" && Number.isFinite(aiCostUsd) && aiCostUsd > 0) body2.aiCostUsd = Math.round(aiCostUsd * 1e6) / 1e6;
|
|
38543
39713
|
if (testConflicts) body2.testConflicts = testConflicts;
|
|
38544
39714
|
if (approvedTestsApplied && approvedTestsApplied.length > 0) body2.approvedTestsApplied = approvedTestsApplied;
|
|
39715
|
+
if (databaseChange && status === "completed") body2.databaseChange = databaseChange;
|
|
38545
39716
|
const payload = JSON.stringify(body2);
|
|
38546
39717
|
const tries = REPORT_RETRY_WAITS_MS.length + 1;
|
|
38547
39718
|
for (let attempt2 = 1; ; attempt2++) {
|
|
@@ -38981,10 +40152,10 @@ function gateNoTimeMessage(baselineMs) {
|
|
|
38981
40152
|
var import_node_crypto = require("node:crypto");
|
|
38982
40153
|
var import_node_fs10 = require("node:fs");
|
|
38983
40154
|
var import_node_os3 = require("node:os");
|
|
38984
|
-
var
|
|
40155
|
+
var import_node_path13 = require("node:path");
|
|
38985
40156
|
|
|
38986
40157
|
// src/pairedTests.ts
|
|
38987
|
-
var
|
|
40158
|
+
var import_node_path8 = require("node:path");
|
|
38988
40159
|
var MAX_TESTS_PER_TARGET = 3;
|
|
38989
40160
|
var MAX_REVERSE_TEST_CHARS = 24e3;
|
|
38990
40161
|
var MAX_TEST_FILE_CHARS = 2e5;
|
|
@@ -39026,28 +40197,28 @@ var TestCorpus = class {
|
|
|
39026
40197
|
}
|
|
39027
40198
|
};
|
|
39028
40199
|
function stemOf(path) {
|
|
39029
|
-
const base =
|
|
39030
|
-
return base === "index" ?
|
|
40200
|
+
const base = import_node_path8.posix.basename(path).replace(/\.[cm]?[jt]sx?$/i, "");
|
|
40201
|
+
return base === "index" ? import_node_path8.posix.basename(import_node_path8.posix.dirname(path)) : base;
|
|
39031
40202
|
}
|
|
39032
40203
|
function sharedPrefix(a, b) {
|
|
39033
|
-
const x =
|
|
39034
|
-
const y =
|
|
40204
|
+
const x = import_node_path8.posix.dirname(a).split("/");
|
|
40205
|
+
const y = import_node_path8.posix.dirname(b).split("/");
|
|
39035
40206
|
let n = 0;
|
|
39036
40207
|
while (n < x.length && n < y.length && x[n] === y[n]) n++;
|
|
39037
40208
|
return n;
|
|
39038
40209
|
}
|
|
39039
40210
|
function namesOf(path) {
|
|
39040
|
-
const base =
|
|
40211
|
+
const base = import_node_path8.posix.basename(path).replace(/\.[cm]?[jt]sx?$/i, "").toLowerCase();
|
|
39041
40212
|
const names = base.length >= 2 ? [base] : [];
|
|
39042
40213
|
if (ROUTE_FILE_NAMES.has(base)) {
|
|
39043
|
-
const parts2 =
|
|
40214
|
+
const parts2 = import_node_path8.posix.dirname(path).split("/").filter(Boolean);
|
|
39044
40215
|
while (parts2.length > 0 && /^[[(]/.test(parts2[parts2.length - 1])) parts2.pop();
|
|
39045
40216
|
const folder = parts2[parts2.length - 1];
|
|
39046
40217
|
if (folder && folder.length >= 3) names.push(folder.toLowerCase());
|
|
39047
40218
|
}
|
|
39048
40219
|
return names;
|
|
39049
40220
|
}
|
|
39050
|
-
var namedAfter = (test, path) => namesOf(path).some((n) =>
|
|
40221
|
+
var namedAfter = (test, path) => namesOf(path).some((n) => import_node_path8.posix.basename(test).toLowerCase().startsWith(n));
|
|
39051
40222
|
function testsImporting(p) {
|
|
39052
40223
|
if (p.limit <= 0 || (p.isTest ?? isTestTarget)(p.target) || !supportsImportScan(p.target)) return [];
|
|
39053
40224
|
const stem = stemOf(p.target);
|
|
@@ -39061,7 +40232,7 @@ function testsImporting(p) {
|
|
|
39061
40232
|
return r.kind === "repo" && r.path === p.target;
|
|
39062
40233
|
});
|
|
39063
40234
|
if (!imported) continue;
|
|
39064
|
-
hits.push({ path: file.path, named:
|
|
40235
|
+
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 });
|
|
39065
40236
|
}
|
|
39066
40237
|
hits.sort((a, b) => Number(b.named) - Number(a.named) || b.near - a.near || a.size - b.size || (a.path < b.path ? -1 : 1));
|
|
39067
40238
|
return hits.slice(0, p.limit).map((h) => h.path);
|
|
@@ -39105,16 +40276,16 @@ function testsThroughOneFile(p) {
|
|
|
39105
40276
|
if (p.exclude?.has(test) || test === p.target || imports.has(p.target)) continue;
|
|
39106
40277
|
for (const q of imports) if (via.has(q)) importers.set(q, [...importers.get(q) ?? [], test]);
|
|
39107
40278
|
}
|
|
39108
|
-
const
|
|
40279
|
+
const textOf2 = new Map(p.corpus.files().map((f) => [f.path, f.text]));
|
|
39109
40280
|
const hits = /* @__PURE__ */ new Map();
|
|
39110
40281
|
for (const [q, tests] of importers) {
|
|
39111
40282
|
const common = tests.length > COMMON_IMPORTER_LIMIT;
|
|
39112
40283
|
for (const test of tests) {
|
|
39113
|
-
const
|
|
39114
|
-
if (common && !
|
|
40284
|
+
const named2 = namedAfter(test, q) || namedAfter(test, p.target);
|
|
40285
|
+
if (common && !named2) continue;
|
|
39115
40286
|
const prev = hits.get(test);
|
|
39116
40287
|
const near = sharedPrefix(test, q);
|
|
39117
|
-
hits.set(test, { path: test, named:
|
|
40288
|
+
hits.set(test, { path: test, named: named2 || (prev?.named ?? false), near: Math.max(near, prev?.near ?? 0), size: textOf2.get(test)?.length ?? 0 });
|
|
39118
40289
|
}
|
|
39119
40290
|
}
|
|
39120
40291
|
return [...hits.values()].sort((a, b) => Number(b.named) - Number(a.named) || b.near - a.near || a.size - b.size || (a.path < b.path ? -1 : 1)).slice(0, p.limit).map((h) => h.path);
|
|
@@ -39123,16 +40294,16 @@ function testsThroughOneFile(p) {
|
|
|
39123
40294
|
// src/testAdapters.ts
|
|
39124
40295
|
var import_node_fs9 = require("node:fs");
|
|
39125
40296
|
var import_node_module = require("node:module");
|
|
39126
|
-
var
|
|
40297
|
+
var import_node_path11 = require("node:path");
|
|
39127
40298
|
|
|
39128
40299
|
// src/baselineCheck.ts
|
|
39129
40300
|
var import_node_child_process6 = require("node:child_process");
|
|
39130
40301
|
var import_node_fs8 = require("node:fs");
|
|
39131
|
-
var
|
|
40302
|
+
var import_node_path10 = require("node:path");
|
|
39132
40303
|
|
|
39133
40304
|
// src/quiktest.ts
|
|
39134
40305
|
var import_node_fs6 = require("node:fs");
|
|
39135
|
-
var
|
|
40306
|
+
var import_node_path9 = require("node:path");
|
|
39136
40307
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
39137
40308
|
var DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
|
|
39138
40309
|
"node_modules",
|
|
@@ -39168,7 +40339,7 @@ function isJUnitXml(path) {
|
|
|
39168
40339
|
}
|
|
39169
40340
|
function findJUnitReports(cwd = process.cwd(), opts = {}) {
|
|
39170
40341
|
const found = [];
|
|
39171
|
-
const
|
|
40342
|
+
const walk3 = (dir) => {
|
|
39172
40343
|
if (found.length >= MAX_REPORTS) return;
|
|
39173
40344
|
let entries;
|
|
39174
40345
|
try {
|
|
@@ -39178,23 +40349,23 @@ function findJUnitReports(cwd = process.cwd(), opts = {}) {
|
|
|
39178
40349
|
}
|
|
39179
40350
|
for (const entry of entries) {
|
|
39180
40351
|
if (DEPENDENCY_DIRS.has(entry)) continue;
|
|
39181
|
-
const full = (0,
|
|
40352
|
+
const full = (0, import_node_path9.join)(dir, entry);
|
|
39182
40353
|
let stat;
|
|
39183
40354
|
try {
|
|
39184
40355
|
stat = (0, import_node_fs6.statSync)(full);
|
|
39185
40356
|
} catch {
|
|
39186
40357
|
continue;
|
|
39187
40358
|
}
|
|
39188
|
-
if (stat.isDirectory())
|
|
40359
|
+
if (stat.isDirectory()) walk3(full);
|
|
39189
40360
|
else if (/\.xml$/i.test(entry) && (opts.freshSinceMs === void 0 || stat.mtimeMs >= opts.freshSinceMs) && isJUnitXml(full)) {
|
|
39190
40361
|
found.push(full);
|
|
39191
40362
|
if (found.length >= MAX_REPORTS) return;
|
|
39192
40363
|
}
|
|
39193
40364
|
}
|
|
39194
40365
|
};
|
|
39195
|
-
|
|
39196
|
-
const
|
|
39197
|
-
return found.sort((a, b) =>
|
|
40366
|
+
walk3(cwd);
|
|
40367
|
+
const named2 = (p) => /^junit.*\.xml$/i.test(p.split(/[\\/]/).pop() ?? "") ? 0 : 1;
|
|
40368
|
+
return found.sort((a, b) => named2(a) - named2(b) || a.localeCompare(b));
|
|
39198
40369
|
}
|
|
39199
40370
|
function mergeJUnitReports(texts) {
|
|
39200
40371
|
if (texts.length === 1) return texts[0];
|
|
@@ -39219,7 +40390,7 @@ function walkForJUnitByName(dir) {
|
|
|
39219
40390
|
}
|
|
39220
40391
|
for (const entry of entries) {
|
|
39221
40392
|
if (SKIP_DIRS.has(entry)) continue;
|
|
39222
|
-
const full = (0,
|
|
40393
|
+
const full = (0, import_node_path9.join)(dir, entry);
|
|
39223
40394
|
let stat;
|
|
39224
40395
|
try {
|
|
39225
40396
|
stat = (0, import_node_fs6.statSync)(full);
|
|
@@ -39243,7 +40414,7 @@ function firstXmlIn(dir, namePattern) {
|
|
|
39243
40414
|
return null;
|
|
39244
40415
|
}
|
|
39245
40416
|
const match = entries.find((e) => namePattern.test(e));
|
|
39246
|
-
return match ? (0,
|
|
40417
|
+
return match ? (0, import_node_path9.join)(dir, match) : null;
|
|
39247
40418
|
}
|
|
39248
40419
|
function readTestReportBytes(cwd = process.cwd()) {
|
|
39249
40420
|
try {
|
|
@@ -39256,15 +40427,15 @@ function readTestReportBytes(cwd = process.cwd()) {
|
|
|
39256
40427
|
}
|
|
39257
40428
|
}
|
|
39258
40429
|
function findJUnitReport(cwd = process.cwd()) {
|
|
39259
|
-
return walkForJUnitByName(cwd) ?? findJUnitReports(cwd)[0] ?? firstXmlIn((0,
|
|
40430
|
+
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$/);
|
|
39260
40431
|
}
|
|
39261
40432
|
function buildCiUrl(serverUrl, repository, githubRunId) {
|
|
39262
40433
|
return `${serverUrl}/${repository}/actions/runs/${githubRunId}`;
|
|
39263
40434
|
}
|
|
39264
40435
|
function describeUnmatchedAutomationIds(unmatched) {
|
|
39265
40436
|
if (unmatched.length === 0) return null;
|
|
39266
|
-
const
|
|
39267
|
-
return `${unmatched.length} generated test result(s) did not match any test case: ${
|
|
40437
|
+
const named2 = unmatched.map((u) => `${u.automationId} (\xD7${u.count})`).join(", ");
|
|
40438
|
+
return `${unmatched.length} generated test result(s) did not match any test case: ${named2} \u2014 check the automationId format.`;
|
|
39268
40439
|
}
|
|
39269
40440
|
async function reportToQuikTest(params) {
|
|
39270
40441
|
const { resultsUrl, runToken, githubServerUrl, githubRepository, githubRunId, generatedFiles, cwd } = params;
|
|
@@ -39722,16 +40893,16 @@ function checkableIds(ids, types2) {
|
|
|
39722
40893
|
});
|
|
39723
40894
|
}
|
|
39724
40895
|
function insideCheckout(cwd, path) {
|
|
39725
|
-
const abs = (0,
|
|
39726
|
-
const rel = (0,
|
|
39727
|
-
return rel === "" || rel.startsWith("..") || (0,
|
|
40896
|
+
const abs = (0, import_node_path10.resolve)(cwd, path);
|
|
40897
|
+
const rel = (0, import_node_path10.relative)(cwd, abs);
|
|
40898
|
+
return rel === "" || rel.startsWith("..") || (0, import_node_path10.isAbsolute)(rel) ? null : abs;
|
|
39728
40899
|
}
|
|
39729
40900
|
function writeForCheck(abs, content) {
|
|
39730
40901
|
const original = (0, import_node_fs8.existsSync)(abs) ? (0, import_node_fs8.readFileSync)(abs) : null;
|
|
39731
40902
|
const createdDirs = [];
|
|
39732
40903
|
if (original === null) {
|
|
39733
40904
|
const missing = [];
|
|
39734
|
-
for (let d = (0,
|
|
40905
|
+
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);
|
|
39735
40906
|
for (const d of missing.reverse()) {
|
|
39736
40907
|
(0, import_node_fs8.mkdirSync)(d);
|
|
39737
40908
|
createdDirs.push(d);
|
|
@@ -39894,11 +41065,11 @@ var CONFIG_FILES = ["vitest.config.ts", "vitest.config.mts", "vitest.config.cts"
|
|
|
39894
41065
|
var WORKSPACE_IN_CONFIG = /\b(?:workspace|projects)\s*:/;
|
|
39895
41066
|
function defaultResolveVitest(cwd) {
|
|
39896
41067
|
try {
|
|
39897
|
-
const pkgPath = (0, import_node_module.createRequire)((0,
|
|
41068
|
+
const pkgPath = (0, import_node_module.createRequire)((0, import_node_path11.join)(cwd, "package.json")).resolve("vitest/package.json");
|
|
39898
41069
|
const pkg = JSON.parse((0, import_node_fs9.readFileSync)(pkgPath, "utf8"));
|
|
39899
41070
|
const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.vitest;
|
|
39900
41071
|
if (typeof rel !== "string" || typeof pkg.version !== "string") return null;
|
|
39901
|
-
return { bin: forward((0,
|
|
41072
|
+
return { bin: forward((0, import_node_path11.join)((0, import_node_path11.dirname)(pkgPath), rel)), version: pkg.version };
|
|
39902
41073
|
} catch {
|
|
39903
41074
|
return null;
|
|
39904
41075
|
}
|
|
@@ -39943,9 +41114,9 @@ function detectAdapter(i3) {
|
|
|
39943
41114
|
const parsed = parseTestInvocation(rest);
|
|
39944
41115
|
if ("off" in parsed) return parsed;
|
|
39945
41116
|
if (parsed.flags.some((f) => !ALLOWED_FLAG.test(f))) return { off: "extra_flags" };
|
|
39946
|
-
const cwd = folder ?
|
|
41117
|
+
const cwd = folder ? import_node_path11.posix.join(forward(i3.root), folder) : forward(i3.root);
|
|
39947
41118
|
if (parsed.viaScript) {
|
|
39948
|
-
const pkgText = i3.readText(
|
|
41119
|
+
const pkgText = i3.readText(import_node_path11.posix.join(cwd, "package.json"));
|
|
39949
41120
|
let script = "";
|
|
39950
41121
|
try {
|
|
39951
41122
|
const scripts = JSON.parse(pkgText ?? "{}").scripts;
|
|
@@ -39956,9 +41127,9 @@ function detectAdapter(i3) {
|
|
|
39956
41127
|
if (!/\bvitest\b/.test(script)) return { off: "not_vitest" };
|
|
39957
41128
|
if (!PLAIN_VITEST_SCRIPT.test(script)) return { off: "script_not_plain" };
|
|
39958
41129
|
}
|
|
39959
|
-
if (WORKSPACE_FILES.some((f) => i3.exists(
|
|
41130
|
+
if (WORKSPACE_FILES.some((f) => i3.exists(import_node_path11.posix.join(cwd, f)))) return { off: "workspace_config" };
|
|
39960
41131
|
for (const f of CONFIG_FILES) {
|
|
39961
|
-
const text3 = i3.exists(
|
|
41132
|
+
const text3 = i3.exists(import_node_path11.posix.join(cwd, f)) ? i3.readText(import_node_path11.posix.join(cwd, f)) : null;
|
|
39962
41133
|
if (text3 !== null && WORKSPACE_IN_CONFIG.test(text3)) return { off: "workspace_config" };
|
|
39963
41134
|
}
|
|
39964
41135
|
const found = (i3.resolveVitest ?? defaultResolveVitest)(cwd);
|
|
@@ -39981,7 +41152,7 @@ var TEST_FILE_NAME = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
|
|
39981
41152
|
function forceFullReason(paths, setupFiles = []) {
|
|
39982
41153
|
for (const raw of paths) {
|
|
39983
41154
|
const p = forward(raw);
|
|
39984
|
-
const base =
|
|
41155
|
+
const base = import_node_path11.posix.basename(p);
|
|
39985
41156
|
if (base === "package.json" || base === "npm-shrinkwrap.json") return "package_manifest";
|
|
39986
41157
|
if (/^(?:package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?)$/.test(base)) return "lock_file";
|
|
39987
41158
|
if (/^[jt]sconfig(?:\.[\w.-]+)?\.json$/.test(base)) return "ts_config";
|
|
@@ -39999,7 +41170,7 @@ function setupFilesOf(configText, folderRel) {
|
|
|
39999
41170
|
for (const m of configText.matchAll(list2)) {
|
|
40000
41171
|
for (const s of (m[1] ?? "").matchAll(/["']([^"']+)["']/g)) {
|
|
40001
41172
|
const rel = forward(s[1] ?? "").replace(/^\.\//, "");
|
|
40002
|
-
if (rel) out2.push(
|
|
41173
|
+
if (rel) out2.push(import_node_path11.posix.join(folderRel, rel));
|
|
40003
41174
|
}
|
|
40004
41175
|
}
|
|
40005
41176
|
return out2;
|
|
@@ -40034,7 +41205,7 @@ function fsReadingTests(i3) {
|
|
|
40034
41205
|
}
|
|
40035
41206
|
|
|
40036
41207
|
// src/tsconfigPaths.ts
|
|
40037
|
-
var
|
|
41208
|
+
var import_node_path12 = require("node:path");
|
|
40038
41209
|
var MAX_EXTENDS_DEPTH = 5;
|
|
40039
41210
|
function parseJsonc(text3) {
|
|
40040
41211
|
let out2 = "";
|
|
@@ -40080,12 +41251,12 @@ function resolveConfig(readText, file, depth, seen) {
|
|
|
40080
41251
|
if (typeof text3 !== "string") return null;
|
|
40081
41252
|
const json = parseJsonc(text3);
|
|
40082
41253
|
if (!isObject(json)) return null;
|
|
40083
|
-
const dir =
|
|
41254
|
+
const dir = import_node_path12.posix.dirname(file) === "." ? "" : import_node_path12.posix.dirname(file);
|
|
40084
41255
|
let inherited = { paths: null, pathsDir: dir, baseUrl: null };
|
|
40085
41256
|
const ext = typeof json.extends === "string" ? [json.extends] : stringList(json.extends);
|
|
40086
41257
|
for (const e of ext) {
|
|
40087
41258
|
if (!e.startsWith(".")) continue;
|
|
40088
|
-
const parent = resolveConfig(readText,
|
|
41259
|
+
const parent = resolveConfig(readText, import_node_path12.posix.normalize(import_node_path12.posix.join(dir, e.endsWith(".json") ? e : `${e}.json`)), depth + 1, seen);
|
|
40089
41260
|
if (parent) {
|
|
40090
41261
|
inherited = {
|
|
40091
41262
|
paths: parent.paths ?? inherited.paths,
|
|
@@ -40095,7 +41266,7 @@ function resolveConfig(readText, file, depth, seen) {
|
|
|
40095
41266
|
}
|
|
40096
41267
|
}
|
|
40097
41268
|
const co = isObject(json.compilerOptions) ? json.compilerOptions : {};
|
|
40098
|
-
const baseUrl = typeof co.baseUrl === "string" ?
|
|
41269
|
+
const baseUrl = typeof co.baseUrl === "string" ? import_node_path12.posix.normalize(import_node_path12.posix.join(dir, co.baseUrl)) : inherited.baseUrl;
|
|
40099
41270
|
let paths = inherited.paths;
|
|
40100
41271
|
let pathsDir = inherited.pathsDir;
|
|
40101
41272
|
if (isObject(co.paths)) {
|
|
@@ -40125,7 +41296,7 @@ function aliasTable(opts) {
|
|
|
40125
41296
|
if (!config?.paths) return [];
|
|
40126
41297
|
const lines = [];
|
|
40127
41298
|
for (const [key, targets] of Object.entries(config.paths)) {
|
|
40128
|
-
const resolved = targets.map((t) =>
|
|
41299
|
+
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));
|
|
40129
41300
|
if (resolved.length > 0) lines.push(`${key} -> ${resolved.join(", ")}`);
|
|
40130
41301
|
}
|
|
40131
41302
|
return lines.sort().slice(0, opts.max ?? 20);
|
|
@@ -40152,7 +41323,7 @@ function createAliasMapper(opts) {
|
|
|
40152
41323
|
};
|
|
40153
41324
|
return (fromPath, specifier) => {
|
|
40154
41325
|
if (specifier.startsWith(".") || specifier.startsWith("/")) return null;
|
|
40155
|
-
const dir =
|
|
41326
|
+
const dir = import_node_path12.posix.dirname(fromPath) === "." ? "" : import_node_path12.posix.dirname(fromPath);
|
|
40156
41327
|
const config = configFor(dir);
|
|
40157
41328
|
if (!config?.paths) return null;
|
|
40158
41329
|
let best = null;
|
|
@@ -40163,8 +41334,8 @@ function createAliasMapper(opts) {
|
|
|
40163
41334
|
if (!best) return null;
|
|
40164
41335
|
const bases = [];
|
|
40165
41336
|
for (const target of config.paths[best.key]) {
|
|
40166
|
-
const joined =
|
|
40167
|
-
if (joined === ".." || joined.startsWith("../") ||
|
|
41337
|
+
const joined = import_node_path12.posix.normalize(import_node_path12.posix.join(config.baseUrl ?? config.pathsDir, target.replace("*", best.captured)));
|
|
41338
|
+
if (joined === ".." || joined.startsWith("../") || import_node_path12.posix.isAbsolute(joined)) continue;
|
|
40168
41339
|
if (opts.writeRoot !== "" && !matchesPrefix(joined, opts.writeRoot)) continue;
|
|
40169
41340
|
bases.push(joined === "." ? "" : joined);
|
|
40170
41341
|
}
|
|
@@ -40218,7 +41389,7 @@ function createRelatedPlanner(d) {
|
|
|
40218
41389
|
const exists = d.exists ?? import_node_fs10.existsSync;
|
|
40219
41390
|
const mode = (env2.QUIKPILOT_RELATED_TESTS ?? "").trim().toLowerCase();
|
|
40220
41391
|
const minMs = minBaselineMs(env2);
|
|
40221
|
-
const abs = (rel) => forward2((0,
|
|
41392
|
+
const abs = (rel) => forward2((0, import_node_path13.join)(d.root, rel));
|
|
40222
41393
|
const isTest = testRule(d.discoveredTests ?? null);
|
|
40223
41394
|
let detected = null;
|
|
40224
41395
|
let setupFiles = [];
|
|
@@ -40230,9 +41401,9 @@ function createRelatedPlanner(d) {
|
|
|
40230
41401
|
function detect() {
|
|
40231
41402
|
const found = detectAdapter({ command: d.command, root: forward2(d.root), readText, exists, resolveVitest: d.resolveVitest });
|
|
40232
41403
|
if ("adapter" in found) {
|
|
40233
|
-
const folder = forward2((0,
|
|
41404
|
+
const folder = forward2((0, import_node_path13.relative)(d.root, found.adapter.cwd));
|
|
40234
41405
|
for (const name2 of CONFIG_FILES) {
|
|
40235
|
-
const text3 = exists(
|
|
41406
|
+
const text3 = exists(import_node_path13.posix.join(found.adapter.cwd, name2)) ? readText(import_node_path13.posix.join(found.adapter.cwd, name2)) : null;
|
|
40236
41407
|
if (text3 !== null) setupFiles.push(...setupFilesOf(text3, folder));
|
|
40237
41408
|
}
|
|
40238
41409
|
log({ event: "related.adapter", adapter: found.adapter.kind, version: found.adapter.version });
|
|
@@ -40474,7 +41645,7 @@ function spendSoFar() {
|
|
|
40474
41645
|
|
|
40475
41646
|
// src/codegen.ts
|
|
40476
41647
|
var import_node_fs11 = require("node:fs");
|
|
40477
|
-
var
|
|
41648
|
+
var import_node_path14 = require("node:path");
|
|
40478
41649
|
|
|
40479
41650
|
// src/envelope.ts
|
|
40480
41651
|
var HARD_FAILURE_CODES = /* @__PURE__ */ new Set(["SEMANTIC_MISMATCH", "CONTRACT_REJECTED"]);
|
|
@@ -40916,7 +42087,7 @@ async function runCodegen(gateway, targets, workspaceListing, requiredTests, den
|
|
|
40916
42087
|
}
|
|
40917
42088
|
function flushCodegenResults(results) {
|
|
40918
42089
|
for (const { targetPath, newContent } of results) {
|
|
40919
|
-
(0, import_node_fs11.mkdirSync)((0,
|
|
42090
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path14.dirname)(targetPath), { recursive: true });
|
|
40920
42091
|
(0, import_node_fs11.writeFileSync)(targetPath, newContent);
|
|
40921
42092
|
}
|
|
40922
42093
|
}
|
|
@@ -40962,18 +42133,18 @@ function callFunctionEnabled(githubRepository, mode, env2 = process.env) {
|
|
|
40962
42133
|
|
|
40963
42134
|
// src/callFunctionTool.ts
|
|
40964
42135
|
var import_node_crypto4 = require("node:crypto");
|
|
40965
|
-
var
|
|
42136
|
+
var import_node_path18 = require("node:path");
|
|
40966
42137
|
|
|
40967
42138
|
// src/overlayOnDisk.ts
|
|
40968
42139
|
var import_node_child_process8 = require("node:child_process");
|
|
40969
42140
|
var import_node_fs13 = require("node:fs");
|
|
40970
|
-
var
|
|
42141
|
+
var import_node_path16 = require("node:path");
|
|
40971
42142
|
|
|
40972
42143
|
// src/treeFingerprint.ts
|
|
40973
42144
|
var import_node_crypto2 = require("node:crypto");
|
|
40974
42145
|
var import_node_child_process7 = require("node:child_process");
|
|
40975
42146
|
var import_node_fs12 = require("node:fs");
|
|
40976
|
-
var
|
|
42147
|
+
var import_node_path15 = require("node:path");
|
|
40977
42148
|
var MAX_HASHED_BYTES = 8 * 1024 * 1024;
|
|
40978
42149
|
function defaultGitStatus(root) {
|
|
40979
42150
|
try {
|
|
@@ -41001,7 +42172,7 @@ function parseStatus(raw) {
|
|
|
41001
42172
|
return raw.split("\0").filter((t) => t.length > 0).sort();
|
|
41002
42173
|
}
|
|
41003
42174
|
function hashOf(root, rel) {
|
|
41004
|
-
const abs = (0,
|
|
42175
|
+
const abs = (0, import_node_path15.join)(root, rel);
|
|
41005
42176
|
let st;
|
|
41006
42177
|
try {
|
|
41007
42178
|
st = (0, import_node_fs12.lstatSync)(abs);
|
|
@@ -41066,24 +42237,24 @@ var DiskWriteRefused = class extends Error {
|
|
|
41066
42237
|
};
|
|
41067
42238
|
function safeRelativePath(rel) {
|
|
41068
42239
|
if (typeof rel !== "string" || rel.length === 0 || rel.length > 400 || rel.includes("\0") || rel.includes("\\")) return null;
|
|
41069
|
-
if ((0,
|
|
42240
|
+
if ((0, import_node_path16.isAbsolute)(rel) || /^[A-Za-z]:/.test(rel)) return null;
|
|
41070
42241
|
const parts2 = rel.split("/");
|
|
41071
42242
|
if (parts2.some((p) => p === "" || p === "." || p === "..")) return null;
|
|
41072
42243
|
return rel;
|
|
41073
42244
|
}
|
|
41074
42245
|
function isInside(root, abs) {
|
|
41075
|
-
const r = (0,
|
|
41076
|
-
return r !== "" && !r.startsWith("..") && !(0,
|
|
42246
|
+
const r = (0, import_node_path16.relative)(root, abs);
|
|
42247
|
+
return r !== "" && !r.startsWith("..") && !(0, import_node_path16.isAbsolute)(r);
|
|
41077
42248
|
}
|
|
41078
42249
|
function ancestorInside(realRoot, abs) {
|
|
41079
|
-
let dir = (0,
|
|
42250
|
+
let dir = (0, import_node_path16.dirname)(abs);
|
|
41080
42251
|
for (; ; ) {
|
|
41081
42252
|
try {
|
|
41082
42253
|
const real = (0, import_node_fs13.realpathSync)(dir);
|
|
41083
|
-
const r = (0,
|
|
41084
|
-
return r === "" || !r.startsWith("..") && !(0,
|
|
42254
|
+
const r = (0, import_node_path16.relative)(realRoot, real);
|
|
42255
|
+
return r === "" || !r.startsWith("..") && !(0, import_node_path16.isAbsolute)(r);
|
|
41085
42256
|
} catch {
|
|
41086
|
-
const up = (0,
|
|
42257
|
+
const up = (0, import_node_path16.dirname)(dir);
|
|
41087
42258
|
if (up === dir) return false;
|
|
41088
42259
|
dir = up;
|
|
41089
42260
|
}
|
|
@@ -41096,7 +42267,7 @@ function applyOverlay(root, files) {
|
|
|
41096
42267
|
const restore2 = () => {
|
|
41097
42268
|
const failed = [];
|
|
41098
42269
|
for (const w of [...written].reverse()) {
|
|
41099
|
-
const rel = (0,
|
|
42270
|
+
const rel = (0, import_node_path16.relative)(root, w.abs).split("\\").join("/");
|
|
41100
42271
|
try {
|
|
41101
42272
|
if (w.original !== null) (0, import_node_fs13.writeFileSync)(w.abs, w.original);
|
|
41102
42273
|
else (0, import_node_fs13.rmSync)(w.abs, { force: true });
|
|
@@ -41119,7 +42290,7 @@ function applyOverlay(root, files) {
|
|
|
41119
42290
|
if (rel === null) throw new DiskWriteRefused("bad_path");
|
|
41120
42291
|
if (seen.has(rel)) throw new DiskWriteRefused("duplicate");
|
|
41121
42292
|
seen.add(rel);
|
|
41122
|
-
const abs = (0,
|
|
42293
|
+
const abs = (0, import_node_path16.resolve)(root, rel);
|
|
41123
42294
|
if (!isInside(root, abs) || !ancestorInside(realRoot, abs)) throw new DiskWriteRefused("outside_checkout");
|
|
41124
42295
|
let original = null;
|
|
41125
42296
|
try {
|
|
@@ -41133,7 +42304,7 @@ function applyOverlay(root, files) {
|
|
|
41133
42304
|
const createdDirs = [];
|
|
41134
42305
|
if (original === null) {
|
|
41135
42306
|
const missing = [];
|
|
41136
|
-
for (let d = (0,
|
|
42307
|
+
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);
|
|
41137
42308
|
for (const d of missing.reverse()) {
|
|
41138
42309
|
(0, import_node_fs13.mkdirSync)(d);
|
|
41139
42310
|
createdDirs.push(d);
|
|
@@ -41160,8 +42331,8 @@ function cleanUpAfterRun(root, beforePaths, afterStatus) {
|
|
|
41160
42331
|
const code = entryCode(token);
|
|
41161
42332
|
try {
|
|
41162
42333
|
if (code === "??") {
|
|
41163
|
-
(0, import_node_fs13.rmSync)((0,
|
|
41164
|
-
for (let d = (0,
|
|
42334
|
+
(0, import_node_fs13.rmSync)((0, import_node_path16.join)(root, p), { recursive: true, force: true });
|
|
42335
|
+
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)) {
|
|
41165
42336
|
try {
|
|
41166
42337
|
(0, import_node_fs13.rmdirSync)(d);
|
|
41167
42338
|
} catch {
|
|
@@ -41181,7 +42352,7 @@ function snapshotPreserved(root, paths) {
|
|
|
41181
42352
|
const out2 = [];
|
|
41182
42353
|
for (const rel of paths ?? []) {
|
|
41183
42354
|
if (safeRelativePath(rel) === null) continue;
|
|
41184
|
-
const abs = (0,
|
|
42355
|
+
const abs = (0, import_node_path16.resolve)(root, rel);
|
|
41185
42356
|
try {
|
|
41186
42357
|
const st = (0, import_node_fs13.lstatSync)(abs);
|
|
41187
42358
|
if (st.isSymbolicLink() || !st.isFile()) continue;
|
|
@@ -41249,7 +42420,7 @@ function undoableFlush(root, results, flush, options = {}) {
|
|
|
41249
42420
|
const beforePaths = new Set((before?.status ?? []).filter(isStatusEntry).map(entryPath));
|
|
41250
42421
|
for (const p of ignore) beforePaths.add(p);
|
|
41251
42422
|
const originals = rels.map((rel) => {
|
|
41252
|
-
const abs = (0,
|
|
42423
|
+
const abs = (0, import_node_path16.resolve)(root, rel);
|
|
41253
42424
|
let original = null;
|
|
41254
42425
|
try {
|
|
41255
42426
|
const st = (0, import_node_fs13.lstatSync)(abs);
|
|
@@ -41260,7 +42431,7 @@ function undoableFlush(root, results, flush, options = {}) {
|
|
|
41260
42431
|
const createdDirs = [];
|
|
41261
42432
|
if (original === null) {
|
|
41262
42433
|
const missing = [];
|
|
41263
|
-
for (let d = (0,
|
|
42434
|
+
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);
|
|
41264
42435
|
createdDirs.push(...missing.reverse());
|
|
41265
42436
|
}
|
|
41266
42437
|
return { rel, abs, original, createdDirs };
|
|
@@ -41316,7 +42487,7 @@ function undoableFlush(root, results, flush, options = {}) {
|
|
|
41316
42487
|
// src/runTestsTool.ts
|
|
41317
42488
|
var import_node_crypto3 = require("node:crypto");
|
|
41318
42489
|
var import_node_fs14 = require("node:fs");
|
|
41319
|
-
var
|
|
42490
|
+
var import_node_path17 = require("node:path");
|
|
41320
42491
|
var scrubSecrets2 = (text3) => scrubForModel(text3, [], "code").text;
|
|
41321
42492
|
var RUN_TESTS_TOOL = "run_tests";
|
|
41322
42493
|
var MAX_TEST_RUNS = 3;
|
|
@@ -41628,7 +42799,7 @@ var RunTestsTool = class {
|
|
|
41628
42799
|
const runCommand2 = d.runCommand ?? runTestCommandWithLimit;
|
|
41629
42800
|
const readSnapshot = d.readSnapshot ?? readTestSnapshot;
|
|
41630
42801
|
const reportBefore = findReport(d.root);
|
|
41631
|
-
const preserve = reportBefore ? [(0,
|
|
42802
|
+
const preserve = reportBefore ? [(0, import_node_path17.relative)(d.root, reportBefore).split("\\").join("/")] : [];
|
|
41632
42803
|
const spend = (n) => {
|
|
41633
42804
|
if (file === void 0) this.runs += n;
|
|
41634
42805
|
else this.fileRuns += n;
|
|
@@ -41979,7 +43150,7 @@ var CallFunctionTool = class {
|
|
|
41979
43150
|
const now = d.now ?? Date.now;
|
|
41980
43151
|
const helper = {
|
|
41981
43152
|
path: `.quikpilot-call-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.mjs`,
|
|
41982
|
-
content: helperSource({ target: (0,
|
|
43153
|
+
content: helperSource({ target: (0, import_node_path18.join)(d.root, parsed.path), exportName: parsed.exportName, args: parsed.callArgs })
|
|
41983
43154
|
};
|
|
41984
43155
|
const run3 = d.run ?? runCapturedCommand;
|
|
41985
43156
|
this.calls += 1;
|
|
@@ -41989,7 +43160,7 @@ var CallFunctionTool = class {
|
|
|
41989
43160
|
captured = await withOverlayOnDisk(
|
|
41990
43161
|
d.root,
|
|
41991
43162
|
[...files, helper],
|
|
41992
|
-
() => run3([d.nodePath ?? process.execPath, (0,
|
|
43163
|
+
() => 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 }),
|
|
41993
43164
|
{ ...d.tree }
|
|
41994
43165
|
);
|
|
41995
43166
|
} catch (err2) {
|
|
@@ -42302,10 +43473,10 @@ function quoted(line, width) {
|
|
|
42302
43473
|
return line.replace(/`/g, "").trim().slice(0, width).trimEnd();
|
|
42303
43474
|
}
|
|
42304
43475
|
function ambiguousPlacesMessage(lf, starts, total) {
|
|
42305
|
-
const
|
|
42306
|
-
if (
|
|
43476
|
+
const named2 = starts.slice(0, MAX_NAMED);
|
|
43477
|
+
if (named2.length === 0) return `That text matches ${total} places. ${TAIL}`;
|
|
42307
43478
|
const header = total <= MAX_NAMED ? `That text matches ${total} places: ` : `That text matches ${total} places; the first four are `;
|
|
42308
|
-
const places =
|
|
43479
|
+
const places = named2.map((start3) => ({ line: lineNumberAt(lf, start3), before: previousTextLine(lf, start3) }));
|
|
42309
43480
|
const parts2 = places.map((p) => {
|
|
42310
43481
|
const q = p.before !== null ? quoted(p.before, QUOTE_WIDTH) : "";
|
|
42311
43482
|
return q === "" ? `line ${p.line}` : `line ${p.line} (after \`${q}\`)`;
|
|
@@ -44032,14 +45203,14 @@ function identifiersOf(n) {
|
|
|
44032
45203
|
return n.namedChildren.flatMap((c) => identifiersOf(c));
|
|
44033
45204
|
}
|
|
44034
45205
|
function declaredBy(lang, node) {
|
|
44035
|
-
const
|
|
45206
|
+
const named2 = (n) => n ? [n.text] : null;
|
|
44036
45207
|
switch (lang) {
|
|
44037
45208
|
case "python": {
|
|
44038
45209
|
if (node.type === "decorated_definition") {
|
|
44039
45210
|
const inner = node.childForFieldName("definition");
|
|
44040
45211
|
return inner ? declaredBy(lang, inner) : null;
|
|
44041
45212
|
}
|
|
44042
|
-
if (node.type === "function_definition" || node.type === "class_definition") return
|
|
45213
|
+
if (node.type === "function_definition" || node.type === "class_definition") return named2(node.childForFieldName("name"));
|
|
44043
45214
|
if (node.type === "expression_statement") {
|
|
44044
45215
|
const a = node.namedChildren[0];
|
|
44045
45216
|
if (a && (a.type === "assignment" || a.type === "augmented_assignment")) return identifiersOf(a.childForFieldName("left"));
|
|
@@ -44047,7 +45218,7 @@ function declaredBy(lang, node) {
|
|
|
44047
45218
|
return null;
|
|
44048
45219
|
}
|
|
44049
45220
|
case "go": {
|
|
44050
|
-
if (node.type === "function_declaration") return
|
|
45221
|
+
if (node.type === "function_declaration") return named2(node.childForFieldName("name"));
|
|
44051
45222
|
if (node.type === "method_declaration") {
|
|
44052
45223
|
const receiver = node.childForFieldName("receiver")?.text.replace(/\s+/g, " ") ?? "";
|
|
44053
45224
|
return [`${receiver}.${text2(node.childForFieldName("name"))}`];
|
|
@@ -44060,13 +45231,13 @@ function declaredBy(lang, node) {
|
|
|
44060
45231
|
return null;
|
|
44061
45232
|
}
|
|
44062
45233
|
case "java": {
|
|
44063
|
-
if (node.type === "method_declaration" || node.type === "class_declaration" || node.type === "interface_declaration" || node.type === "enum_declaration" || node.type === "record_declaration") return
|
|
45234
|
+
if (node.type === "method_declaration" || node.type === "class_declaration" || node.type === "interface_declaration" || node.type === "enum_declaration" || node.type === "record_declaration") return named2(node.childForFieldName("name"));
|
|
44064
45235
|
if (node.type === "field_declaration") return node.namedChildren.filter((c) => c.type === "variable_declarator").map((c) => text2(c.childForFieldName("name")));
|
|
44065
45236
|
return null;
|
|
44066
45237
|
}
|
|
44067
45238
|
case "kotlin": {
|
|
44068
45239
|
if (node.type === "function_declaration" || node.type === "class_declaration" || node.type === "object_declaration" || node.type === "type_alias") {
|
|
44069
|
-
return
|
|
45240
|
+
return named2(node.childForFieldName("name") ?? node.namedChildren.find((c) => c.type === "identifier") ?? null);
|
|
44070
45241
|
}
|
|
44071
45242
|
if (node.type === "property_declaration") {
|
|
44072
45243
|
const v = node.namedChildren.find((c) => c.type === "variable_declaration" || c.type === "multi_variable_declaration");
|
|
@@ -44075,7 +45246,7 @@ function declaredBy(lang, node) {
|
|
|
44075
45246
|
return null;
|
|
44076
45247
|
}
|
|
44077
45248
|
case "csharp": {
|
|
44078
|
-
if (["method_declaration", "class_declaration", "struct_declaration", "interface_declaration", "enum_declaration", "record_declaration", "property_declaration", "delegate_declaration"].includes(node.type)) return
|
|
45249
|
+
if (["method_declaration", "class_declaration", "struct_declaration", "interface_declaration", "enum_declaration", "record_declaration", "property_declaration", "delegate_declaration"].includes(node.type)) return named2(node.childForFieldName("name"));
|
|
44079
45250
|
if (node.type === "field_declaration") {
|
|
44080
45251
|
const v = node.namedChildren.find((c) => c.type === "variable_declaration");
|
|
44081
45252
|
return (v?.namedChildren ?? []).filter((c) => c.type === "variable_declarator").map((c) => text2(c.childForFieldName("name") ?? c.namedChildren[0]));
|
|
@@ -44083,17 +45254,17 @@ function declaredBy(lang, node) {
|
|
|
44083
45254
|
return null;
|
|
44084
45255
|
}
|
|
44085
45256
|
case "rust": {
|
|
44086
|
-
if (["function_item", "struct_item", "enum_item", "const_item", "static_item", "type_item", "trait_item", "mod_item", "union_item", "macro_definition"].includes(node.type)) return
|
|
45257
|
+
if (["function_item", "struct_item", "enum_item", "const_item", "static_item", "type_item", "trait_item", "mod_item", "union_item", "macro_definition"].includes(node.type)) return named2(node.childForFieldName("name"));
|
|
44087
45258
|
if (node.type === "impl_item") return [`impl ${text2(node.childForFieldName("type"))}`];
|
|
44088
45259
|
return null;
|
|
44089
45260
|
}
|
|
44090
45261
|
case "ruby": {
|
|
44091
|
-
if (node.type === "method" || node.type === "singleton_method" || node.type === "class" || node.type === "module") return
|
|
45262
|
+
if (node.type === "method" || node.type === "singleton_method" || node.type === "class" || node.type === "module") return named2(node.childForFieldName("name"));
|
|
44092
45263
|
if (node.type === "assignment") return identifiersOf(node.childForFieldName("left")).concat(node.childForFieldName("left")?.type === "constant" ? [text2(node.childForFieldName("left"))] : []);
|
|
44093
45264
|
return null;
|
|
44094
45265
|
}
|
|
44095
45266
|
case "php": {
|
|
44096
|
-
if (node.type === "function_definition" || node.type === "class_declaration" || node.type === "trait_declaration" || node.type === "interface_declaration" || node.type === "method_declaration") return
|
|
45267
|
+
if (node.type === "function_definition" || node.type === "class_declaration" || node.type === "trait_declaration" || node.type === "interface_declaration" || node.type === "method_declaration") return named2(node.childForFieldName("name"));
|
|
44097
45268
|
if (node.type === "property_declaration") return node.namedChildren.filter((c) => c.type === "property_element").map((c) => c.text.split("=")[0].trim());
|
|
44098
45269
|
if (node.type === "const_declaration") return node.namedChildren.filter((c) => c.type === "const_element").map((c) => c.namedChildren[0]?.text ?? "");
|
|
44099
45270
|
return null;
|
|
@@ -44109,11 +45280,11 @@ function importOf(lang, node) {
|
|
|
44109
45280
|
}
|
|
44110
45281
|
if (lang === "go") {
|
|
44111
45282
|
const specs = [];
|
|
44112
|
-
const
|
|
45283
|
+
const walk3 = (n) => {
|
|
44113
45284
|
if (n.type === "import_spec") specs.push(n.text);
|
|
44114
|
-
else n.namedChildren.forEach(
|
|
45285
|
+
else n.namedChildren.forEach(walk3);
|
|
44115
45286
|
};
|
|
44116
|
-
|
|
45287
|
+
walk3(node);
|
|
44117
45288
|
return { head: "go import", names: specs, declared: [] };
|
|
44118
45289
|
}
|
|
44119
45290
|
return { head: "", names: [node.text], declared: lang === "python" ? [node.text] : [] };
|
|
@@ -44663,14 +45834,14 @@ var TOKEN = /\[(QP-[^\]\s]+)\]/;
|
|
|
44663
45834
|
var TEST_ROOTS3 = /* @__PURE__ */ new Set(["it", "test"]);
|
|
44664
45835
|
var X_ROOTS2 = /* @__PURE__ */ new Set(["xit", "xtest"]);
|
|
44665
45836
|
var SKIP_PROPS2 = /* @__PURE__ */ new Set(["skip", "todo"]);
|
|
44666
|
-
function
|
|
45837
|
+
function walk2(node, visit) {
|
|
44667
45838
|
visit(node);
|
|
44668
45839
|
for (const key of Object.keys(node)) {
|
|
44669
45840
|
const value = node[key];
|
|
44670
45841
|
if (Array.isArray(value)) {
|
|
44671
|
-
for (const child of value) if (child && typeof child.type === "string")
|
|
45842
|
+
for (const child of value) if (child && typeof child.type === "string") walk2(child, visit);
|
|
44672
45843
|
} else if (value && typeof value.type === "string") {
|
|
44673
|
-
|
|
45844
|
+
walk2(value, visit);
|
|
44674
45845
|
}
|
|
44675
45846
|
}
|
|
44676
45847
|
}
|
|
@@ -44711,7 +45882,7 @@ function findTests(path, text3) {
|
|
|
44711
45882
|
const parsed = parseProgram(path, text3);
|
|
44712
45883
|
if (!parsed) return findOtherLanguageTests(path, text3);
|
|
44713
45884
|
const out2 = [];
|
|
44714
|
-
|
|
45885
|
+
walk2(parsed.ast, (n) => {
|
|
44715
45886
|
if (n.type !== "CallExpression") return;
|
|
44716
45887
|
const call = n;
|
|
44717
45888
|
const chain = testChain(call.callee);
|
|
@@ -44722,7 +45893,7 @@ function findTests(path, text3) {
|
|
|
44722
45893
|
let checks = 0;
|
|
44723
45894
|
for (const arg of call.arguments) {
|
|
44724
45895
|
if (arg.type !== "ArrowFunctionExpression" && arg.type !== "FunctionExpression") continue;
|
|
44725
|
-
|
|
45896
|
+
walk2(arg.body, (m) => {
|
|
44726
45897
|
if (m.type === "CallExpression" && isCheck(m)) checks++;
|
|
44727
45898
|
});
|
|
44728
45899
|
}
|
|
@@ -46389,7 +47560,7 @@ function createCodegenWorkspace(args2) {
|
|
|
46389
47560
|
|
|
46390
47561
|
// src/scratchRunTool.ts
|
|
46391
47562
|
var import_node_fs15 = require("node:fs");
|
|
46392
|
-
var
|
|
47563
|
+
var import_node_path19 = require("node:path");
|
|
46393
47564
|
var RUN_SCRATCH_TOOL = "run_scratch";
|
|
46394
47565
|
var MAX_SCRATCH_TEXT_CHARS = 2e3;
|
|
46395
47566
|
var MAX_SCRATCH_CONTENT_CHARS = 8e3;
|
|
@@ -46475,10 +47646,10 @@ var ScratchRunTool = class {
|
|
|
46475
47646
|
if (matchesDeniedPath(path, d.deniedPaths) !== null) return false;
|
|
46476
47647
|
if (!testRule(d.discoveredTests)(path)) return false;
|
|
46477
47648
|
if (d.protectedTestPaths.includes(path) || d.listing.includes(path) || files.some((f) => f.path === path)) return false;
|
|
46478
|
-
const abs = (0,
|
|
47649
|
+
const abs = (0, import_node_path19.join)(d.root, path);
|
|
46479
47650
|
if ((0, import_node_fs15.existsSync)(abs)) return false;
|
|
46480
47651
|
try {
|
|
46481
|
-
return (0, import_node_fs15.statSync)((0,
|
|
47652
|
+
return (0, import_node_fs15.statSync)((0, import_node_path19.dirname)(abs)).isDirectory();
|
|
46482
47653
|
} catch {
|
|
46483
47654
|
return false;
|
|
46484
47655
|
}
|
|
@@ -46517,7 +47688,7 @@ var ScratchRunTool = class {
|
|
|
46517
47688
|
const run3 = d.run ?? runShellCaptured;
|
|
46518
47689
|
const command = buildSingleFileCommand(fileCommand, parsed.path);
|
|
46519
47690
|
const reportBefore = (d.findReport ?? findJUnitReport)(d.root);
|
|
46520
|
-
const preserve = reportBefore ? [(0,
|
|
47691
|
+
const preserve = reportBefore ? [(0, import_node_path19.relative)(d.root, reportBefore).split("\\").join("/")] : [];
|
|
46521
47692
|
this.calls += 1;
|
|
46522
47693
|
const startedAt = now();
|
|
46523
47694
|
let ran;
|
|
@@ -46568,9 +47739,9 @@ var count2 = (n) => typeof n === "number" && Number.isInteger(n) ? Math.min(1e5,
|
|
|
46568
47739
|
function callOf(call, result) {
|
|
46569
47740
|
if (!result) return null;
|
|
46570
47741
|
const args2 = isRecord2(call.args) ? call.args : {};
|
|
46571
|
-
const
|
|
47742
|
+
const named2 = typeof args2.path === "string" ? args2.path : call.name === "run_tests" && typeof args2.file === "string" ? args2.file : void 0;
|
|
46572
47743
|
const out2 = { tool: call.name, status: result.status };
|
|
46573
|
-
if (
|
|
47744
|
+
if (named2 && named2.length > 0 && named2.length <= MAX_PATH_CHARS3) out2.path = named2;
|
|
46574
47745
|
if (typeof result.reason === "string" && result.reason.length > 0) out2.reason = result.reason.slice(0, MAX_REASON_CHARS);
|
|
46575
47746
|
const o = result.output;
|
|
46576
47747
|
if (call.name === "run_tests" && isRecord2(o) && typeof o.passed === "number" && typeof o.failed === "number") {
|
|
@@ -46777,16 +47948,35 @@ function repeatedLossDetail(kind, first) {
|
|
|
46777
47948
|
|
|
46778
47949
|
// src/conflictVerify.ts
|
|
46779
47950
|
var CUT_AT = 190;
|
|
46780
|
-
function
|
|
47951
|
+
function testNameMatches(id, place, test) {
|
|
46781
47952
|
const { file: where, name: name2 } = splitTestId(id);
|
|
46782
|
-
if (where !== null && !idPlaceMatches(where,
|
|
46783
|
-
|
|
46784
|
-
|
|
46785
|
-
const
|
|
46786
|
-
const candidates = [title, full.join(" > "), full.join(" "), full.join(" \u203A ")];
|
|
47953
|
+
if (where !== null && !idPlaceMatches(where, place)) return false;
|
|
47954
|
+
if (test.table === true) return rowPattern({ describes: [...test.describes], title: test.title }, place).test(name2);
|
|
47955
|
+
const full = [...test.describes, test.title];
|
|
47956
|
+
const candidates = [test.title, full.join(" > "), full.join(" "), full.join(" \u203A ")];
|
|
46787
47957
|
return candidates.includes(name2) || name2.length >= CUT_AT && candidates.some((c) => c.startsWith(name2));
|
|
46788
47958
|
}
|
|
46789
|
-
|
|
47959
|
+
function failingNameIs(id, file, conflict) {
|
|
47960
|
+
const title = file.newTitles.get(conflict.index) ?? conflict.testTitle;
|
|
47961
|
+
return testNameMatches(id, file.path, { title, describes: conflict.describes, table: conflict.rows !== void 0 });
|
|
47962
|
+
}
|
|
47963
|
+
function proposalNameIs(id, file, conflict) {
|
|
47964
|
+
if (conflict.index < 0 && conflict.served) {
|
|
47965
|
+
return testNameMatches(id, conflict.served.path, { title: conflict.served.title, describes: conflict.served.describes, ...conflict.served.table ? { table: true } : {} });
|
|
47966
|
+
}
|
|
47967
|
+
return failingNameIs(id, file, conflict);
|
|
47968
|
+
}
|
|
47969
|
+
function failsIn(answer, place, test, among) {
|
|
47970
|
+
if (answer === null || answer.timedOut) return null;
|
|
47971
|
+
const names = among === void 0 ? answer.failingTests : answer.failingTests.slice(0, among);
|
|
47972
|
+
if (names.some((id) => testNameMatches(id, place, test))) return true;
|
|
47973
|
+
return answer.truncated ? null : false;
|
|
47974
|
+
}
|
|
47975
|
+
function brokenByChange(c) {
|
|
47976
|
+
return c.edit === "add_only" && c.strictlyAdditive === true && c.regressed === true && c.suite === "passes";
|
|
47977
|
+
}
|
|
47978
|
+
async function verifyOnOldCode(conflicts, run3, log = () => void 0, feature) {
|
|
47979
|
+
if (feature === true) return classify2(conflicts, run3, log);
|
|
46790
47980
|
const { files, dropped: unmergeable } = buildProposalFiles(conflicts);
|
|
46791
47981
|
if (files.length === 0 || run3 === null) return { kept: conflicts.filter((c) => !unmergeable.includes(c)), dropped: [] };
|
|
46792
47982
|
let answer = null;
|
|
@@ -46820,6 +48010,61 @@ async function verifyOnOldCode(conflicts, run3, log = () => void 0) {
|
|
|
46820
48010
|
log({ event: "codegen.conflict_old_code", ...outcomes, files: files.length, ran: answer !== null, timedOut: answer?.timedOut ?? false });
|
|
46821
48011
|
return { kept, dropped };
|
|
46822
48012
|
}
|
|
48013
|
+
var neededAddOnly = (c) => c.edit === "add_only";
|
|
48014
|
+
async function classify2(conflicts, run3, log) {
|
|
48015
|
+
const { files, dropped: unmergeable } = buildProposalFiles(conflicts);
|
|
48016
|
+
const kept = [];
|
|
48017
|
+
const dropped = [];
|
|
48018
|
+
const proven = /* @__PURE__ */ new Set();
|
|
48019
|
+
for (const f of files) for (const c of f.conflicts) if (brokenByChange(c)) proven.add(c);
|
|
48020
|
+
const needOld = files.filter((f) => f.conflicts.some((c) => !proven.has(c)));
|
|
48021
|
+
let answer = null;
|
|
48022
|
+
if (needOld.length > 0 && run3 !== null) {
|
|
48023
|
+
try {
|
|
48024
|
+
answer = await run3(needOld.map((f) => ({ targetPath: f.path, newContent: fileText(f.newLf, f.ending, f.bom) })));
|
|
48025
|
+
} catch (err2) {
|
|
48026
|
+
if (err2 instanceof TreeNotRestoredError) throw err2;
|
|
48027
|
+
answer = null;
|
|
48028
|
+
}
|
|
48029
|
+
}
|
|
48030
|
+
const usable = answer !== null && !answer.timedOut;
|
|
48031
|
+
const counts = { brokenByChange: 0, oldCode: 0, unchecked: 0, dropped: 0, unproven: 0 };
|
|
48032
|
+
for (const f of files) {
|
|
48033
|
+
for (const c of f.conflicts) {
|
|
48034
|
+
if (proven.has(c)) {
|
|
48035
|
+
kept.push({ ...c, proof: "broken_by_change" });
|
|
48036
|
+
counts.brokenByChange += 1;
|
|
48037
|
+
} else if (usable && answer.failingTests.some((id) => proposalNameIs(id, f, c))) {
|
|
48038
|
+
kept.push({ ...c, oldCodeChecked: true, proof: "old_code" });
|
|
48039
|
+
counts.oldCode += 1;
|
|
48040
|
+
} else if (usable && !answer.truncated) {
|
|
48041
|
+
dropped.push(c);
|
|
48042
|
+
counts.dropped += 1;
|
|
48043
|
+
} else if (!neededAddOnly(c)) {
|
|
48044
|
+
kept.push(run3 === null || needOld.length === 0 ? c : { ...c, oldCodeChecked: false });
|
|
48045
|
+
counts.unchecked += 1;
|
|
48046
|
+
} else {
|
|
48047
|
+
dropped.push(c);
|
|
48048
|
+
counts.dropped += 1;
|
|
48049
|
+
counts.unproven += 1;
|
|
48050
|
+
}
|
|
48051
|
+
}
|
|
48052
|
+
}
|
|
48053
|
+
const order = new Map(conflicts.map((c, i3) => [`${c.path}\0${c.testTitle}`, i3]));
|
|
48054
|
+
kept.sort((a, b) => (order.get(`${a.path}\0${a.testTitle}`) ?? 0) - (order.get(`${b.path}\0${b.testTitle}`) ?? 0));
|
|
48055
|
+
log({
|
|
48056
|
+
event: "codegen.broken_by_change",
|
|
48057
|
+
kept: counts.brokenByChange,
|
|
48058
|
+
oldCode: counts.oldCode,
|
|
48059
|
+
unchecked: counts.unchecked,
|
|
48060
|
+
dropped: counts.dropped + unmergeable.length,
|
|
48061
|
+
unproven: counts.unproven,
|
|
48062
|
+
files: files.length,
|
|
48063
|
+
ran: answer !== null,
|
|
48064
|
+
timedOut: answer?.timedOut ?? false
|
|
48065
|
+
});
|
|
48066
|
+
return { kept, dropped };
|
|
48067
|
+
}
|
|
46823
48068
|
|
|
46824
48069
|
// src/proofCheck.ts
|
|
46825
48070
|
var keyOf2 = (c) => `${c.path}\0${c.testTitle}`;
|
|
@@ -46853,7 +48098,7 @@ async function proveProposals(input) {
|
|
|
46853
48098
|
const covered = /* @__PURE__ */ new Set();
|
|
46854
48099
|
for (const f of files) {
|
|
46855
48100
|
for (const c of f.conflicts) {
|
|
46856
|
-
const failing = answer.failingTests.filter((id) =>
|
|
48101
|
+
const failing = answer.failingTests.filter((id) => proposalNameIs(id, f, c));
|
|
46857
48102
|
for (const id of failing) covered.add(id);
|
|
46858
48103
|
const newCode = failing.length > 0 ? "fails" : answer.truncated ? "not_checked" : "passes";
|
|
46859
48104
|
evidence.set(keyOf2(c), { newCode, ...endOf(f, c) });
|
|
@@ -46861,15 +48106,15 @@ async function proveProposals(input) {
|
|
|
46861
48106
|
}
|
|
46862
48107
|
}
|
|
46863
48108
|
const broken = answer.failingTests.slice(0, answer.regressions).filter((id) => !covered.has(id));
|
|
46864
|
-
return { ran: true, evidence, stillFailing, unexplained: groupRegressions(broken) };
|
|
48109
|
+
return { ran: true, evidence, stillFailing, unexplained: groupRegressions(broken), answer };
|
|
46865
48110
|
}
|
|
46866
48111
|
var MAX_NAMED2 = 8;
|
|
46867
48112
|
function proofSentences(proof) {
|
|
46868
48113
|
const out2 = [];
|
|
46869
48114
|
if (proof.stillFailing.length > 0) {
|
|
46870
|
-
const
|
|
48115
|
+
const named2 = proof.stillFailing.slice(0, MAX_NAMED2).map((c) => `${c.path}: "${c.testTitle.replace(/\s+/g, " ").slice(0, 120)}"`);
|
|
46871
48116
|
out2.push(
|
|
46872
|
-
`Your proposed change to ${
|
|
48117
|
+
`Your proposed change to ${named2.join("; ")}${proof.stillFailing.length > MAX_NAMED2 ? `; and ${proof.stillFailing.length - MAX_NAMED2} more` : ""} still fails on your fix. Another line of that test still expects the old behaviour: change EVERY expectation of it (status, body, message) and report the test again.`
|
|
46873
48118
|
);
|
|
46874
48119
|
}
|
|
46875
48120
|
if (proof.unexplained.length > 0) out2.push(...giveUpSentences(proof.unexplained).slice(0, MAX_NAMED2));
|
|
@@ -47367,6 +48612,227 @@ function reviewAnswer(lines) {
|
|
|
47367
48612
|
return { rules: ["done_rule"], violations: [...lines.slice(0, MAX_REVIEW_CASES), REVIEW_CLOSING], message: REVIEW_MESSAGE };
|
|
47368
48613
|
}
|
|
47369
48614
|
|
|
48615
|
+
// src/databaseChange.ts
|
|
48616
|
+
var DATABASE_CHANGE_KEY = "databaseChange";
|
|
48617
|
+
var DATABASE_CHANGE_PATH = ".quikpilot/database-change.json";
|
|
48618
|
+
var STORED_PROPOSALS_KEY = "storedProposals";
|
|
48619
|
+
var NOTE_REASON = "database_change_note";
|
|
48620
|
+
var MAX_NOTE_CHARS2 = 2e4;
|
|
48621
|
+
var MAX_WHY_CHARS = 300;
|
|
48622
|
+
var MAX_PATH_CHARS4 = 300;
|
|
48623
|
+
var MAX_SCHEMA_CHANGE_CHARS = 4e3;
|
|
48624
|
+
var MAX_MIGRATION_CHARS = 8e3;
|
|
48625
|
+
var MAX_UNDO_CHARS = 4e3;
|
|
48626
|
+
var MAX_APPLY_CHARS = 300;
|
|
48627
|
+
var MAX_FLAGGED = 10;
|
|
48628
|
+
var MAX_FLAG_CHARS = 40;
|
|
48629
|
+
function databaseParts(design, code) {
|
|
48630
|
+
return code.flatMap((c) => {
|
|
48631
|
+
const d = design.find((p) => p.id === c.id);
|
|
48632
|
+
return c.database && d ? [{ id: c.id, name: c.name, what: d.what, paths: [...c.paths], database: c.database }] : [];
|
|
48633
|
+
});
|
|
48634
|
+
}
|
|
48635
|
+
function databaseChangeWire(parts2) {
|
|
48636
|
+
return { path: DATABASE_CHANGE_PATH, parts: parts2.map((p) => ({ id: p.id, name: p.name, what: p.what })) };
|
|
48637
|
+
}
|
|
48638
|
+
var KEYS = ["parts", "additive", "why", "schemaFile", "schemaChange", "migrationFile", "migration", "undo", "apply"];
|
|
48639
|
+
var NOT_RECORDED = "The database change was not recorded:";
|
|
48640
|
+
var PROPOSAL_SENTENCES = {
|
|
48641
|
+
tooLong: `${NOT_RECORDED} it is longer than 20,000 characters. Write it whole again, shorter.`,
|
|
48642
|
+
notJson: `${NOT_RECORDED} it is not one JSON object. Write it whole again with write_file.`,
|
|
48643
|
+
keys: `${NOT_RECORDED} its keys must be parts, additive, schemaFile, migrationFile and migration, with why, schemaChange, undo and apply where they apply, and no other.`,
|
|
48644
|
+
parts: (ids) => `${NOT_RECORDED} "parts" must list, each once, the ids of the stored parts it adds (${ids.join(", ")}), and no other id.`,
|
|
48645
|
+
additive: `${NOT_RECORDED} "additive" must be true or false.`,
|
|
48646
|
+
why: `${NOT_RECORDED} "why" must say, in at most 300 characters, why the change is not additive.`,
|
|
48647
|
+
schemaFile: `${NOT_RECORDED} "schemaFile" must be the schema file's path from the repository root (at most 300 characters), or "" when the schema lives only in migrations.`,
|
|
48648
|
+
schemaChange: `${NOT_RECORDED} "schemaChange" must hold the change to the schema file, at most 4,000 characters, whenever "schemaFile" names one.`,
|
|
48649
|
+
migrationFile: `${NOT_RECORDED} "migrationFile" must be the migration file's path from the repository root (at most 300 characters), or "" when the migration tool names it.`,
|
|
48650
|
+
migration: `${NOT_RECORDED} "migration" must hold the forward change only, 1 to 8,000 characters.`,
|
|
48651
|
+
undo: `${NOT_RECORDED} "undo" must be text of at most 4,000 characters.`,
|
|
48652
|
+
apply: `${NOT_RECORDED} "apply" must be text of at most 300 characters.`
|
|
48653
|
+
};
|
|
48654
|
+
function isRecord3(x) {
|
|
48655
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
48656
|
+
}
|
|
48657
|
+
function cleanPath(value) {
|
|
48658
|
+
if (value.length > MAX_PATH_CHARS4) return false;
|
|
48659
|
+
const n = normaliseToolPath(value);
|
|
48660
|
+
return n.ok && n.path === value;
|
|
48661
|
+
}
|
|
48662
|
+
function readProposal(text3, partIds) {
|
|
48663
|
+
const fail = (sentence) => ({ ok: false, sentence });
|
|
48664
|
+
if (text3.length > MAX_NOTE_CHARS2) return fail(PROPOSAL_SENTENCES.tooLong);
|
|
48665
|
+
let raw;
|
|
48666
|
+
try {
|
|
48667
|
+
raw = JSON.parse(text3);
|
|
48668
|
+
} catch {
|
|
48669
|
+
return fail(PROPOSAL_SENTENCES.notJson);
|
|
48670
|
+
}
|
|
48671
|
+
if (!isRecord3(raw)) return fail(PROPOSAL_SENTENCES.notJson);
|
|
48672
|
+
const keys = Object.keys(raw);
|
|
48673
|
+
if (keys.some((k) => !KEYS.includes(k))) return fail(PROPOSAL_SENTENCES.keys);
|
|
48674
|
+
for (const k of ["parts", "additive", "schemaFile", "migrationFile", "migration"]) if (!keys.includes(k)) return fail(PROPOSAL_SENTENCES.keys);
|
|
48675
|
+
const parts2 = raw.parts;
|
|
48676
|
+
if (!Array.isArray(parts2) || parts2.length === 0 || parts2.some((id) => typeof id !== "string" || !partIds.includes(id)) || new Set(parts2).size !== parts2.length) {
|
|
48677
|
+
return fail(PROPOSAL_SENTENCES.parts(partIds));
|
|
48678
|
+
}
|
|
48679
|
+
if (typeof raw.additive !== "boolean") return fail(PROPOSAL_SENTENCES.additive);
|
|
48680
|
+
const why = raw.why;
|
|
48681
|
+
if (why !== void 0 && (typeof why !== "string" || why.length > MAX_WHY_CHARS)) return fail(PROPOSAL_SENTENCES.why);
|
|
48682
|
+
if (raw.additive === false && (typeof why !== "string" || why.trim() === "")) return fail(PROPOSAL_SENTENCES.why);
|
|
48683
|
+
const schemaFile = raw.schemaFile;
|
|
48684
|
+
if (typeof schemaFile !== "string" || schemaFile !== "" && !cleanPath(schemaFile)) return fail(PROPOSAL_SENTENCES.schemaFile);
|
|
48685
|
+
const schemaChange = raw.schemaChange;
|
|
48686
|
+
if (schemaChange !== void 0 && (typeof schemaChange !== "string" || schemaChange.length > MAX_SCHEMA_CHANGE_CHARS)) return fail(PROPOSAL_SENTENCES.schemaChange);
|
|
48687
|
+
if (schemaFile !== "" && (typeof schemaChange !== "string" || schemaChange.trim() === "")) return fail(PROPOSAL_SENTENCES.schemaChange);
|
|
48688
|
+
const migrationFile = raw.migrationFile;
|
|
48689
|
+
if (typeof migrationFile !== "string" || migrationFile !== "" && !cleanPath(migrationFile)) return fail(PROPOSAL_SENTENCES.migrationFile);
|
|
48690
|
+
const migration = raw.migration;
|
|
48691
|
+
if (typeof migration !== "string" || migration.trim() === "" || migration.length > MAX_MIGRATION_CHARS) return fail(PROPOSAL_SENTENCES.migration);
|
|
48692
|
+
const undo = raw.undo;
|
|
48693
|
+
if (undo !== void 0 && (typeof undo !== "string" || undo.length > MAX_UNDO_CHARS)) return fail(PROPOSAL_SENTENCES.undo);
|
|
48694
|
+
const apply = raw.apply;
|
|
48695
|
+
if (apply !== void 0 && (typeof apply !== "string" || apply.length > MAX_APPLY_CHARS)) return fail(PROPOSAL_SENTENCES.apply);
|
|
48696
|
+
return {
|
|
48697
|
+
ok: true,
|
|
48698
|
+
proposal: {
|
|
48699
|
+
parts: [...parts2],
|
|
48700
|
+
additive: raw.additive,
|
|
48701
|
+
...typeof why === "string" && why.trim() !== "" ? { why } : {},
|
|
48702
|
+
schemaFile,
|
|
48703
|
+
schemaChange: typeof schemaChange === "string" ? schemaChange : "",
|
|
48704
|
+
migrationFile,
|
|
48705
|
+
migration,
|
|
48706
|
+
...typeof undo === "string" && undo.trim() !== "" ? { undo } : {},
|
|
48707
|
+
...typeof apply === "string" && apply.trim() !== "" ? { apply } : {}
|
|
48708
|
+
}
|
|
48709
|
+
};
|
|
48710
|
+
}
|
|
48711
|
+
var fixed = (word) => () => word;
|
|
48712
|
+
var IDENT3 = String.raw`(?:"[^"]+"|\x60[^\x60]+\x60|\[[^\]]+\]|[\w$.]+)`;
|
|
48713
|
+
var WORD_RULES = [
|
|
48714
|
+
// SQL (Prisma, Django's and Rails' SQL, TypeORM's and Knex's raw queries, Go's migration files, any SQL migration).
|
|
48715
|
+
// `DROP TABLE(` is Ecto's call, reported as Ecto's word below.
|
|
48716
|
+
{ re: /\bDROP\s+(TABLE|COLUMN|SCHEMA|VIEW|TYPE|CONSTRAINT)\b(?!\s*\()/gi, label: (m) => `DROP ${m[1].toUpperCase()}` },
|
|
48717
|
+
{ re: new RegExp(String.raw`\bALTER\s+COLUMN\s+${IDENT3}\s+TYPE\b`, "gi"), label: fixed("ALTER COLUMN TYPE") },
|
|
48718
|
+
{ re: /\bSET\s+DATA\s+TYPE\b/gi, label: fixed("SET DATA TYPE") },
|
|
48719
|
+
{ re: /\bRENAME\b/gi, label: fixed("RENAME") },
|
|
48720
|
+
{ re: /\bTRUNCATE\b/gi, label: fixed("TRUNCATE") },
|
|
48721
|
+
{ re: /\bDELETE\s+FROM\b/gi, label: fixed("DELETE FROM") },
|
|
48722
|
+
{ re: new RegExp(String.raw`\bUPDATE\s+${IDENT3}\s+SET\b`, "gi"), label: fixed("UPDATE SET") },
|
|
48723
|
+
// MySQL. `modify :x` is Ecto's, reported below.
|
|
48724
|
+
{ re: /\bMODIFY\s+(?:COLUMN\b|[\x60"\w])/gi, label: fixed("MODIFY") },
|
|
48725
|
+
{ re: /\bCHANGE\s+COLUMN\b/gi, label: fixed("CHANGE COLUMN") },
|
|
48726
|
+
{ re: /\bSET\s+NOT\s+NULL\b/gi, label: fixed("SET NOT NULL") },
|
|
48727
|
+
// Django.
|
|
48728
|
+
{ re: /\b(RemoveField|DeleteModel|AlterField|RunPython)\b/g, label: (m) => m[1] },
|
|
48729
|
+
{ re: /\bRename(Field|Model|Index)\b/g, label: (m) => `Rename${m[1]}` },
|
|
48730
|
+
// Rails (bare calls: Alembic's `op.drop_table` is Alembic's word).
|
|
48731
|
+
{ re: /(?<![.\w])(remove_columns?|drop_table|change_column_null|change_column|remove_references?)\b/g, label: (m) => m[1] },
|
|
48732
|
+
{ re: /(?<![.\w])rename_(column|table|index)\b/g, label: (m) => `rename_${m[1]}` },
|
|
48733
|
+
// Alembic.
|
|
48734
|
+
{ re: /\b(op|batch_op)\.(drop_(?:column|table|index|constraint)|alter_column|rename_table)\b/g, label: (m) => `${m[1]}.${m[2]}` },
|
|
48735
|
+
// Knex, TypeORM, Sequelize, Laravel.
|
|
48736
|
+
{ re: /\b(drop|rename|change|remove)(Columns?|Table|Index|ForeignKey|Constraint)\b/g, label: (m) => `${m[1]}${m[2]}` },
|
|
48737
|
+
{ re: /\.alter\(\s*\)/g, label: fixed(".alter()") },
|
|
48738
|
+
{ re: /->change\(\s*\)/g, label: fixed("->change()") },
|
|
48739
|
+
// Ecto.
|
|
48740
|
+
{ re: /\bremove\s+:\w+/g, label: fixed("remove") },
|
|
48741
|
+
{ re: /\bmodify\s+:\w+/g, label: fixed("modify") },
|
|
48742
|
+
{ re: /\bdrop\s+table\(/g, label: fixed("drop table(") }
|
|
48743
|
+
];
|
|
48744
|
+
var ADD_NOT_NULL = "ADD COLUMN NOT NULL WITHOUT DEFAULT";
|
|
48745
|
+
function destructiveWords(text3) {
|
|
48746
|
+
const found = [];
|
|
48747
|
+
const add2 = (word) => {
|
|
48748
|
+
const w = word.slice(0, MAX_FLAG_CHARS);
|
|
48749
|
+
if (w !== "" && !found.includes(w)) found.push(w);
|
|
48750
|
+
};
|
|
48751
|
+
for (const rule of WORD_RULES) for (const m of text3.matchAll(rule.re)) add2(rule.label(m));
|
|
48752
|
+
for (const statement of text3.split(";")) {
|
|
48753
|
+
if (/\bADD\s+COLUMN\b/i.test(statement) && /\bNOT\s+NULL\b/i.test(statement) && !/\bDEFAULT\b/i.test(statement)) add2(ADD_NOT_NULL);
|
|
48754
|
+
}
|
|
48755
|
+
return found.slice(0, MAX_FLAGGED);
|
|
48756
|
+
}
|
|
48757
|
+
var NOTE_TOOLS = /* @__PURE__ */ new Set(["write_file", "edit_file", "read_file", "revert_file", "show_changes"]);
|
|
48758
|
+
var NOTE_MESSAGES = {
|
|
48759
|
+
recorded: "The database change is recorded. To change it, write it whole again with write_file.",
|
|
48760
|
+
same: "That is the database change already recorded; nothing changed.",
|
|
48761
|
+
wholeOnly: "This file is QuikPilot's own note of the database change: it cannot be read or edited. Write it whole again with write_file.",
|
|
48762
|
+
closed: "This file is QuikPilot's own note of the database change, and it is not written in this step.",
|
|
48763
|
+
content: "content must be a string."
|
|
48764
|
+
};
|
|
48765
|
+
function namesNote(args2) {
|
|
48766
|
+
if (!isRecord3(args2) || typeof args2.path !== "string") return false;
|
|
48767
|
+
const n = normaliseToolPath(args2.path);
|
|
48768
|
+
return n.ok && n.path === DATABASE_CHANGE_PATH;
|
|
48769
|
+
}
|
|
48770
|
+
var DatabaseChangeNote = class {
|
|
48771
|
+
constructor(partIds, inEffect) {
|
|
48772
|
+
this.partIds = partIds;
|
|
48773
|
+
this.inEffect = inEffect;
|
|
48774
|
+
}
|
|
48775
|
+
partIds;
|
|
48776
|
+
inEffect;
|
|
48777
|
+
text;
|
|
48778
|
+
proposal;
|
|
48779
|
+
/** The proposal recorded in this loop, if any. */
|
|
48780
|
+
recorded() {
|
|
48781
|
+
return this.proposal;
|
|
48782
|
+
}
|
|
48783
|
+
/** The result for a call on the note's path; `null` for any other call (it runs as it always did). */
|
|
48784
|
+
handle(call, ledger, limits) {
|
|
48785
|
+
if (!NOTE_TOOLS.has(call.name) || !namesNote(call.args)) return null;
|
|
48786
|
+
const finish = (r) => {
|
|
48787
|
+
const result = { id: call.id, name: call.name, ...r };
|
|
48788
|
+
ledger.resultChars += JSON.stringify(result).length;
|
|
48789
|
+
if (result.status === "refused") ledger.refused += 1;
|
|
48790
|
+
return result;
|
|
48791
|
+
};
|
|
48792
|
+
if (ledger.toolCalls >= limits.maxToolCalls) return finish({ status: "budget_exhausted", reason: "tool_calls", message: "That limit has been reached; give your answer from what you have." });
|
|
48793
|
+
if (ledger.resultChars >= limits.resultCharsTotal) return finish({ status: "budget_exhausted", reason: "result_chars", message: "That limit has been reached; give your answer from what you have." });
|
|
48794
|
+
ledger.toolCalls += 1;
|
|
48795
|
+
if (!this.inEffect) return finish({ status: "refused", reason: NOTE_REASON, message: NOTE_MESSAGES.closed });
|
|
48796
|
+
if (call.name !== "write_file") return finish({ status: "refused", reason: NOTE_REASON, message: NOTE_MESSAGES.wholeOnly });
|
|
48797
|
+
const content = call.args.content;
|
|
48798
|
+
if (typeof content !== "string") return finish({ status: "bad_args", message: NOTE_MESSAGES.content });
|
|
48799
|
+
if (limits.writeCharsTotal !== void 0 && (ledger.writeChars ?? 0) + content.length > limits.writeCharsTotal) {
|
|
48800
|
+
return finish({ status: "budget_exhausted", reason: "write_chars", message: "The limit on text written has been reached; finish with what you have." });
|
|
48801
|
+
}
|
|
48802
|
+
const read = readProposal(content, this.partIds);
|
|
48803
|
+
if (!read.ok) return finish({ status: "bad_args", message: read.sentence });
|
|
48804
|
+
if (this.text === content) return finish({ status: "no_effect", message: NOTE_MESSAGES.same });
|
|
48805
|
+
this.text = content;
|
|
48806
|
+
this.proposal = read.proposal;
|
|
48807
|
+
if (ledger.writeChars !== void 0) ledger.writeChars += content.length;
|
|
48808
|
+
return finish({ status: "ok", message: NOTE_MESSAGES.recorded, output: { path: DATABASE_CHANGE_PATH, parts: [...read.proposal.parts] } });
|
|
48809
|
+
}
|
|
48810
|
+
};
|
|
48811
|
+
function finalDatabaseChange(proposal, tree) {
|
|
48812
|
+
const flagged = [.../* @__PURE__ */ new Set([...destructiveWords(proposal.migration), ...destructiveWords(proposal.schemaChange)])].slice(0, MAX_FLAGGED);
|
|
48813
|
+
const changed = new Set(tree.changedFiles);
|
|
48814
|
+
const included = (path) => path !== "" && changed.has(path) && insideWriteRoot(path, tree.writeRoot) && matchesDeniedPath(path, writeDenied(tree.deniedPaths)) === null;
|
|
48815
|
+
const schemaFileIncluded = included(proposal.schemaFile);
|
|
48816
|
+
const schemaFileSeen = proposal.schemaFile === "" || schemaFileIncluded || tree.readPaths.includes(proposal.schemaFile) && matchesDeniedPath(proposal.schemaFile, readDenied(tree.deniedPaths)) === null;
|
|
48817
|
+
const text3 = (value, max) => tree.scrub(value).slice(0, max);
|
|
48818
|
+
return {
|
|
48819
|
+
parts: proposal.parts.map((id) => ({ id, name: tree.parts.find((p) => p.id === id)?.name ?? id })),
|
|
48820
|
+
additive: proposal.additive && flagged.length === 0,
|
|
48821
|
+
declaredAdditive: proposal.additive,
|
|
48822
|
+
flagged,
|
|
48823
|
+
...proposal.why !== void 0 ? { why: text3(proposal.why, MAX_WHY_CHARS) } : {},
|
|
48824
|
+
schemaFile: text3(proposal.schemaFile, MAX_PATH_CHARS4),
|
|
48825
|
+
schemaChange: text3(proposal.schemaChange, MAX_SCHEMA_CHANGE_CHARS),
|
|
48826
|
+
migrationFile: text3(proposal.migrationFile, MAX_PATH_CHARS4),
|
|
48827
|
+
migration: text3(proposal.migration, MAX_MIGRATION_CHARS),
|
|
48828
|
+
...proposal.undo !== void 0 ? { undo: text3(proposal.undo, MAX_UNDO_CHARS) } : {},
|
|
48829
|
+
...proposal.apply !== void 0 ? { apply: text3(proposal.apply, MAX_APPLY_CHARS) } : {},
|
|
48830
|
+
schemaFileIncluded,
|
|
48831
|
+
migrationFileIncluded: included(proposal.migrationFile),
|
|
48832
|
+
schemaFileSeen
|
|
48833
|
+
};
|
|
48834
|
+
}
|
|
48835
|
+
|
|
47370
48836
|
// src/partsCheck.ts
|
|
47371
48837
|
var PARTS_CHECK_ENV = "QUIKPILOT_PARTS_CHECK";
|
|
47372
48838
|
function partsCheckOn(env2 = process.env) {
|
|
@@ -47377,18 +48843,18 @@ var MAX_PARTS = 8;
|
|
|
47377
48843
|
var MAX_NAME_CHARS3 = 150;
|
|
47378
48844
|
var MAX_WHAT_CHARS = 300;
|
|
47379
48845
|
var PART_ID_RE = /^P\d+$/;
|
|
47380
|
-
var MARKER_RE = /\[(P\d+)(?:=(exists))?\]/g;
|
|
47381
|
-
function
|
|
48846
|
+
var MARKER_RE = /\[(P\d+)(?:=(exists|proposed))?\]/g;
|
|
48847
|
+
function isRecord4(x) {
|
|
47382
48848
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
47383
48849
|
}
|
|
47384
48850
|
function partsFromDesign(design) {
|
|
47385
|
-
if (!
|
|
48851
|
+
if (!isRecord4(design) || !Array.isArray(design.parts)) return [];
|
|
47386
48852
|
const raw = design.parts;
|
|
47387
48853
|
if (raw.length === 0 || raw.length > MAX_PARTS) return [];
|
|
47388
48854
|
const out2 = [];
|
|
47389
48855
|
const ids = /* @__PURE__ */ new Set();
|
|
47390
48856
|
for (const p of raw) {
|
|
47391
|
-
if (!
|
|
48857
|
+
if (!isRecord4(p)) return [];
|
|
47392
48858
|
const { id, kind, name: name2, what } = p;
|
|
47393
48859
|
if (typeof id !== "string" || !PART_ID_RE.test(id) || ids.has(id)) return [];
|
|
47394
48860
|
if (typeof kind !== "string" || !PART_KINDS.includes(kind)) return [];
|
|
@@ -47409,6 +48875,7 @@ function designForTargeting(design, on) {
|
|
|
47409
48875
|
function readMarks(targets) {
|
|
47410
48876
|
const placed = /* @__PURE__ */ new Map();
|
|
47411
48877
|
const exists = /* @__PURE__ */ new Set();
|
|
48878
|
+
const proposed = /* @__PURE__ */ new Set();
|
|
47412
48879
|
for (const t of targets) {
|
|
47413
48880
|
for (const step of t.planStepsImplemented ?? []) {
|
|
47414
48881
|
if (typeof step !== "string") continue;
|
|
@@ -47417,23 +48884,31 @@ function readMarks(targets) {
|
|
|
47417
48884
|
exists.add(m[1]);
|
|
47418
48885
|
continue;
|
|
47419
48886
|
}
|
|
48887
|
+
if (m[2] === "proposed") {
|
|
48888
|
+
proposed.add(m[1]);
|
|
48889
|
+
continue;
|
|
48890
|
+
}
|
|
47420
48891
|
const paths = placed.get(m[1]) ?? [];
|
|
47421
48892
|
if (!paths.includes(t.path)) paths.push(t.path);
|
|
47422
48893
|
placed.set(m[1], paths);
|
|
47423
48894
|
}
|
|
47424
48895
|
}
|
|
47425
48896
|
}
|
|
47426
|
-
return { placed, exists };
|
|
48897
|
+
return { placed, exists, proposed };
|
|
47427
48898
|
}
|
|
47428
48899
|
function takenAsExisting(part, marks) {
|
|
47429
|
-
return part.kind === "stored" && marks.exists.has(part.id) && !marks.placed.has(part.id);
|
|
48900
|
+
return part.kind === "stored" && marks.exists.has(part.id) && !marks.placed.has(part.id) && !marks.proposed.has(part.id);
|
|
48901
|
+
}
|
|
48902
|
+
function takenAsProposed(part, marks) {
|
|
48903
|
+
return part.kind === "stored" && marks.proposed.has(part.id) && !marks.placed.has(part.id);
|
|
47430
48904
|
}
|
|
47431
48905
|
function existsMarked(parts2, targets) {
|
|
47432
48906
|
const marks = readMarks(targets);
|
|
47433
|
-
const
|
|
48907
|
+
const onlyOther = parts2.filter((p) => (marks.exists.has(p.id) || marks.proposed.has(p.id)) && !marks.placed.has(p.id));
|
|
47434
48908
|
return {
|
|
47435
|
-
existing:
|
|
47436
|
-
ignored:
|
|
48909
|
+
existing: onlyOther.filter((p) => takenAsExisting(p, marks)).map((p) => p.id),
|
|
48910
|
+
ignored: onlyOther.filter((p) => !takenAsExisting(p, marks) && !takenAsProposed(p, marks)).map((p) => p.id),
|
|
48911
|
+
proposed: onlyOther.filter((p) => takenAsProposed(p, marks)).map((p) => p.id)
|
|
47437
48912
|
};
|
|
47438
48913
|
}
|
|
47439
48914
|
function words(text3) {
|
|
@@ -47450,13 +48925,16 @@ function notPlacedSentence(parts2) {
|
|
|
47450
48925
|
const listed = parts2.map((p) => `${p.id} ${words(p.name)} (${p.kind})`).join("; ");
|
|
47451
48926
|
return `${NOT_PLACED_START} ${listed}. Nothing was written. Run it again, or narrow the feature.`;
|
|
47452
48927
|
}
|
|
47453
|
-
function
|
|
48928
|
+
function storedStop(stored) {
|
|
48929
|
+
return { reason: "needs_database_change", ids: stored.map((p) => p.id), sentence: storedSentence(stored) };
|
|
48930
|
+
}
|
|
48931
|
+
function afterTargeting(parts2, targets, opts = {}) {
|
|
47454
48932
|
if (parts2.length === 0) return null;
|
|
47455
48933
|
const marks = readMarks(targets);
|
|
47456
|
-
const unplaced = parts2.filter((p) => !marks.placed.has(p.id) && !takenAsExisting(p, marks));
|
|
48934
|
+
const unplaced = parts2.filter((p) => !marks.placed.has(p.id) && !takenAsExisting(p, marks) && !(opts.proposals === true && takenAsProposed(p, marks)));
|
|
47457
48935
|
if (unplaced.length === 0) return null;
|
|
47458
48936
|
const stored = unplaced.filter((p) => p.kind === "stored");
|
|
47459
|
-
if (stored.length > 0) return
|
|
48937
|
+
if (stored.length > 0) return storedStop(stored);
|
|
47460
48938
|
return { reason: "part_not_placed", ids: unplaced.map((p) => p.id), sentence: notPlacedSentence(unplaced) };
|
|
47461
48939
|
}
|
|
47462
48940
|
var PartsStopError = class extends Error {
|
|
@@ -47469,17 +48947,31 @@ var PartsStopError = class extends Error {
|
|
|
47469
48947
|
this.ids = [...stop2.ids];
|
|
47470
48948
|
}
|
|
47471
48949
|
};
|
|
47472
|
-
function partsForCode(parts2, targets) {
|
|
48950
|
+
function partsForCode(parts2, targets, opts = {}) {
|
|
47473
48951
|
const marks = readMarks(targets);
|
|
47474
|
-
return parts2.filter((p) => !takenAsExisting(p, marks)).map((p) => ({
|
|
48952
|
+
return parts2.filter((p) => !takenAsExisting(p, marks)).map((p) => ({
|
|
48953
|
+
id: p.id,
|
|
48954
|
+
kind: p.kind,
|
|
48955
|
+
name: p.name,
|
|
48956
|
+
paths: marks.placed.get(p.id) ?? [],
|
|
48957
|
+
...opts.proposals === true && p.kind === "stored" ? { database: marks.placed.has(p.id) ? "placed" : "proposed" } : {}
|
|
48958
|
+
}));
|
|
47475
48959
|
}
|
|
47476
|
-
function missingAtDone(parts2, changed, isTest) {
|
|
48960
|
+
function missingAtDone(parts2, changed, isTest, proposalIds) {
|
|
47477
48961
|
const changedSet = new Set(changed);
|
|
47478
48962
|
const built = (part) => {
|
|
47479
48963
|
const onlyTests = part.paths.length > 0 && part.paths.every(isTest);
|
|
47480
48964
|
return part.paths.some((p) => changedSet.has(p) && (onlyTests || !isTest(p)));
|
|
47481
48965
|
};
|
|
47482
|
-
return parts2.
|
|
48966
|
+
return parts2.flatMap((part) => {
|
|
48967
|
+
if (proposalIds !== void 0 && part.database !== void 0) {
|
|
48968
|
+
const named2 = proposalIds.includes(part.id);
|
|
48969
|
+
if (part.database === "proposed") return named2 ? [] : [{ part, why: "not_proposed" }];
|
|
48970
|
+
if (!built(part)) return [{ part, why: "unchanged", ...named2 ? {} : { notProposed: true } }];
|
|
48971
|
+
return named2 ? [] : [{ part, why: "not_proposed" }];
|
|
48972
|
+
}
|
|
48973
|
+
return built(part) ? [] : [{ part, why: "unchanged" }];
|
|
48974
|
+
});
|
|
47483
48975
|
}
|
|
47484
48976
|
var PARTS_MESSAGE = "Your answer was sent back: the approved design lists parts this feature needs, and your change does not build each one yet. Each sentence names a part and the files the plan chose for it. This check is made once.";
|
|
47485
48977
|
function withFiles(build, paths) {
|
|
@@ -47490,29 +48982,38 @@ function withFiles(build, paths) {
|
|
|
47490
48982
|
}
|
|
47491
48983
|
return build(paths.length > 0 ? paths[0] : "no file").slice(0, MAX_REFUSED_SENTENCE_CHARS);
|
|
47492
48984
|
}
|
|
48985
|
+
function notProposedSentence(part) {
|
|
48986
|
+
const sentence = `Part ${part.id} (${part.kind}) "${words(part.name)}" is not in the database change: write it with write_file to ${DATABASE_CHANGE_PATH}, with ${part.id} in "parts".`;
|
|
48987
|
+
return sentence.slice(0, MAX_REFUSED_SENTENCE_CHARS);
|
|
48988
|
+
}
|
|
47493
48989
|
function partSentence(m) {
|
|
48990
|
+
if (m.why === "not_proposed") return notProposedSentence(m.part);
|
|
47494
48991
|
const head = `Part ${m.part.id} (${m.part.kind}) "${words(m.part.name)}" is not built: `;
|
|
47495
48992
|
return withFiles((files) => `${head}none of its planned files was changed (${files}). Build it there.`, m.part.paths);
|
|
47496
48993
|
}
|
|
47497
48994
|
function partsAnswer(missing) {
|
|
47498
|
-
|
|
48995
|
+
const violations = missing.flatMap((m) => m.notProposed ? [partSentence(m), notProposedSentence(m.part)] : [partSentence(m)]);
|
|
48996
|
+
return { rules: ["done_rule"], violations: violations.slice(0, MAX_REFUSED_SENTENCES), message: PARTS_MESSAGE };
|
|
47499
48997
|
}
|
|
47500
|
-
|
|
48998
|
+
var LAST_GATE_MISSING_START = "The last check before the commit found a part of the feature not built:";
|
|
48999
|
+
function partMissingSentence(missing, opts = {}) {
|
|
49000
|
+
const start3 = opts.lastGate === true ? LAST_GATE_MISSING_START : PART_MISSING_START;
|
|
47501
49001
|
const item = (m, short) => {
|
|
49002
|
+
if (m.why === "not_proposed") return `${m.part.id} ${words(m.part.name)} (${m.part.kind}, the database change was not proposed)`;
|
|
47502
49003
|
const paths = m.part.paths;
|
|
47503
49004
|
const files = paths.length === 0 ? "no file" : short && paths.length > 1 ? `${paths[0]} and ${paths.length - 1} more` : paths.join(", ");
|
|
47504
49005
|
return `${m.part.id} ${words(m.part.name)} (${m.part.kind}, planned in ${files})`;
|
|
47505
49006
|
};
|
|
47506
49007
|
const fits = (s) => s.length <= MAX_REFUSED_SENTENCE_CHARS;
|
|
47507
49008
|
for (const short of [false, true]) {
|
|
47508
|
-
const all = `${
|
|
49009
|
+
const all = `${start3} ${missing.map((m) => item(m, short)).join("; ")}.`;
|
|
47509
49010
|
if (fits(all)) return all;
|
|
47510
49011
|
}
|
|
47511
49012
|
for (let k = missing.length - 1; k >= 1; k--) {
|
|
47512
|
-
const some = `${
|
|
49013
|
+
const some = `${start3} ${missing.slice(0, k).map((m) => item(m, true)).join("; ")}; and ${missing.length - k} more.`;
|
|
47513
49014
|
if (fits(some)) return some;
|
|
47514
49015
|
}
|
|
47515
|
-
return `${
|
|
49016
|
+
return `${start3} ${missing[0] ? item(missing[0], true) : ""}`.slice(0, MAX_REFUSED_SENTENCE_CHARS);
|
|
47516
49017
|
}
|
|
47517
49018
|
|
|
47518
49019
|
// src/codegenLoop.ts
|
|
@@ -47558,6 +49059,10 @@ var CodegenLoopFailure = class extends Error {
|
|
|
47558
49059
|
unreportable;
|
|
47559
49060
|
/** QUIKTR-1853: a turn was lost straight after one that had been recovered (see `turnRecovery.ts`). */
|
|
47560
49061
|
afterRecovery;
|
|
49062
|
+
/** QUIKTR-2442: the AI Runtime refused a request that carried `featureTestUpdates` (the step then asks again without it). Wire only. */
|
|
49063
|
+
featureKey;
|
|
49064
|
+
/** QUIKTR-2445: the AI Runtime refused a request that carried `databaseChange` (the step then stops `needs_database_change`). */
|
|
49065
|
+
databaseKey;
|
|
47561
49066
|
constructor(reason, runtimeCode, cause, detail, told) {
|
|
47562
49067
|
super(`pilot.codegen loop failed: ${reason}${runtimeCode ? ` (${runtimeCode})` : ""}`);
|
|
47563
49068
|
this.name = "CodegenLoopFailure";
|
|
@@ -47683,6 +49188,19 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47683
49188
|
}) : null;
|
|
47684
49189
|
const notesOn = harness && args2.tools2?.notes === true;
|
|
47685
49190
|
const keepOn = notesOn && keepWorkingFilesOn();
|
|
49191
|
+
const featureOn = notesOn && args2.conflicts !== void 0 && args2.tests !== void 0 && args2.featureTestUpdates === true && args2.phase !== "tests" && !(args2.lane?.kind === "code" && args2.lane.amend !== void 0 && args2.lane.amend.length > 0);
|
|
49192
|
+
const databaseOn = harness && args2.databaseChange !== void 0 && args2.databaseChange.closed !== true && args2.databaseChange.parts.length > 0 && args2.phase !== "tests" && !(args2.lane?.kind === "code" && args2.lane.amend !== void 0 && args2.lane.amend.length > 0);
|
|
49193
|
+
const note = args2.databaseChange !== void 0 ? new DatabaseChangeNote(args2.databaseChange.parts.map((p) => p.id), databaseOn) : null;
|
|
49194
|
+
const handedChange = () => {
|
|
49195
|
+
const recorded = note?.recorded();
|
|
49196
|
+
return recorded ? { databaseChange: recorded } : {};
|
|
49197
|
+
};
|
|
49198
|
+
let diskFsMade;
|
|
49199
|
+
const diskFs = () => diskFsMade ??= deps.fs ?? createNodeWriteFs();
|
|
49200
|
+
const readDisk = (path) => {
|
|
49201
|
+
const loaded = loadTextForEdit(diskFs(), path, limits.fileBytesMax);
|
|
49202
|
+
return loaded.ok ? loaded.lf : null;
|
|
49203
|
+
};
|
|
47686
49204
|
const conflictTool = notesOn && args2.conflicts !== void 0 && args2.tests !== void 0 ? new TestConflictTool({
|
|
47687
49205
|
existingTests: new Set(args2.protectedTestPaths),
|
|
47688
49206
|
deniedPaths: args2.deniedPaths,
|
|
@@ -47694,13 +49212,20 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47694
49212
|
// QUIKTR-1844: a test whose approved change does not fit may be reported once more, against its approved text.
|
|
47695
49213
|
...args2.conflicts.revisable && args2.conflicts.revisable.length > 0 ? { revisable: withApprovedText(args2.conflicts.revisable, args2.approved ?? []) } : {},
|
|
47696
49214
|
// The checkout as it is on disk: a report is made against the file as it was before the run, never against this attempt's overlay.
|
|
47697
|
-
fs:
|
|
49215
|
+
fs: diskFs(),
|
|
47698
49216
|
fileBytesMax: limits.fileBytesMax,
|
|
47699
49217
|
baseline: args2.tests.baseline,
|
|
47700
49218
|
scrub,
|
|
47701
49219
|
...args2.phase ? { phase: args2.phase } : {},
|
|
47702
49220
|
...args2.fixFirst === true ? { fixFirst: true } : {},
|
|
47703
|
-
log
|
|
49221
|
+
log,
|
|
49222
|
+
// QUIKTR-2442: a report may also be an add-only update of set-up, in the test, its file, or a test helper.
|
|
49223
|
+
...featureOn ? {
|
|
49224
|
+
feature: {
|
|
49225
|
+
isTestSupport: (path) => isTestSupportPath(path, args2.listing, args2.discoveredTests ?? null),
|
|
49226
|
+
usedBy: (helper) => usedByOf(helper, args2.protectedTestPaths, readDisk)
|
|
49227
|
+
}
|
|
49228
|
+
} : {}
|
|
47704
49229
|
}) : null;
|
|
47705
49230
|
if (conflictTool && args2.seedProposals && args2.seedProposals.length > 0) conflictTool.seed(args2.seedProposals);
|
|
47706
49231
|
const markNotChecked = () => {
|
|
@@ -47744,6 +49269,8 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47744
49269
|
if (tests && args2.seed && args2.seed.length > 0) tests.markSeen(versionOfFiles(filesOnDisk()));
|
|
47745
49270
|
let testMs = 0;
|
|
47746
49271
|
let lastTestAnswer;
|
|
49272
|
+
let lastTestVersion;
|
|
49273
|
+
const freshTestAnswer = () => lastTestAnswer !== void 0 && lastTestVersion === versionOfFiles(filesOnDisk()) ? lastTestAnswer : void 0;
|
|
47747
49274
|
const pastHardStop = () => deps.hardStopAtMs !== void 0 && now() >= deps.hardStopAtMs;
|
|
47748
49275
|
const turnTimeoutMs = deps.turnTimeoutMs ?? 3e5;
|
|
47749
49276
|
const deadlineMs = deps.deadlineMs ?? 15e5;
|
|
@@ -47788,13 +49315,13 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47788
49315
|
}
|
|
47789
49316
|
if (passing.length > 0) {
|
|
47790
49317
|
const one = passing.length === 1;
|
|
47791
|
-
const
|
|
47792
|
-
const sentence = passing.length + unrun.length === ids.length && !anyOwnTestFails() ? `None of your tests fails on the code before any change (${
|
|
49318
|
+
const named2 = passing.slice(0, 4).map((id) => `[${id}]`).join(", ");
|
|
49319
|
+
const sentence = passing.length + unrun.length === ids.length && !anyOwnTestFails() ? `None of your tests fails on the code before any change (${named2} ${one ? "passes" : "pass"}), so none shows the bug. At least one case describes the bug: make its test fail for the reason the case gives.` : `${named2} ${one ? "passes" : "pass"} on the code before any change. A case that shows the bug: make its test fail for the reason the case gives. A case that must keep working: leave its test as it is and answer DONE again.`;
|
|
47793
49320
|
return { ids: passing, sentence: sentence.slice(0, 300), kind: "passing" };
|
|
47794
49321
|
}
|
|
47795
49322
|
if (unrun.length > 0) {
|
|
47796
|
-
const
|
|
47797
|
-
const sentence = `Run the tests with run_tests (the whole suite, or the file that holds them) before finishing phase 1: ${
|
|
49323
|
+
const named2 = unrun.slice(0, 6).map((id) => `[${id}]`).join(", ");
|
|
49324
|
+
const sentence = `Run the tests with run_tests (the whole suite, or the file that holds them) before finishing phase 1: ${named2} ${unrun.length === 1 ? "has" : "have"} not been run on the code as it is now.`;
|
|
47798
49325
|
return { ids: unrun, sentence: sentence.slice(0, 300), kind: "unrun" };
|
|
47799
49326
|
}
|
|
47800
49327
|
return null;
|
|
@@ -47851,6 +49378,10 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47851
49378
|
...conflictTool && args2.conflicts && args2.conflicts.decided.length > 0 ? { decidedTests: args2.conflicts.decided } : {},
|
|
47852
49379
|
// QUIKTR-1827 (§38.8): the existing test files to read first. The tests phase of loop-7 only.
|
|
47853
49380
|
...conflictTool && args2.phase === "tests" && toCheck().length > 0 ? { testsToCheck: toCheck() } : {},
|
|
49381
|
+
// QUIKTR-2442 (§38.15): a feature run may propose add-only set-up for an existing test the change breaks. Only `true` is ever sent.
|
|
49382
|
+
...conflictTool && featureOn ? { [FEATURE_TEST_UPDATES_KEY]: true } : {},
|
|
49383
|
+
// QUIKTR-2445: the database parts and the note's path, where the key is in effect. Data; the AI Runtime's clause explains it.
|
|
49384
|
+
...databaseOn ? { [DATABASE_CHANGE_KEY]: databaseChangeWire(args2.databaseChange.parts) } : {},
|
|
47854
49385
|
loop: {
|
|
47855
49386
|
turn,
|
|
47856
49387
|
maxTurns: limits.maxTurns,
|
|
@@ -47984,6 +49515,79 @@ async function runCodegenLoop(args2, deps) {
|
|
|
47984
49515
|
}
|
|
47985
49516
|
return null;
|
|
47986
49517
|
};
|
|
49518
|
+
const featureEvidence = async (reuse) => {
|
|
49519
|
+
if (!featureOn || !conflictTool) return;
|
|
49520
|
+
const all = conflictTool.recorded();
|
|
49521
|
+
const candidates = all.filter((c) => c.edit === "add_only" && c.strictlyAdditive === true && c.served !== void 0);
|
|
49522
|
+
if (candidates.length === 0) {
|
|
49523
|
+
log({ event: "codegen.feature_evidence", candidates: 0, reports: all.length });
|
|
49524
|
+
return;
|
|
49525
|
+
}
|
|
49526
|
+
const wholeSuite = async (files2) => {
|
|
49527
|
+
if (pastHardStop() || !deps.wholeSuite) return null;
|
|
49528
|
+
try {
|
|
49529
|
+
return await deps.wholeSuite(files2);
|
|
49530
|
+
} catch (err2) {
|
|
49531
|
+
if (err2 instanceof TreeNotRestoredError) throw err2;
|
|
49532
|
+
return null;
|
|
49533
|
+
}
|
|
49534
|
+
};
|
|
49535
|
+
const servedOf = (c) => ({ title: c.served.title, describes: c.served.describes, ...c.served.table ? { table: true } : {} });
|
|
49536
|
+
const regressedIn = (answer, c) => failsIn(answer, c.served.path, servedOf(c), answer?.regressions ?? 0);
|
|
49537
|
+
const fresh = freshTestAnswer() ?? null;
|
|
49538
|
+
let changeAnswer = fresh;
|
|
49539
|
+
let ranChange = false;
|
|
49540
|
+
if (changeAnswer === null || candidates.some((c) => regressedIn(changeAnswer, c) !== true)) {
|
|
49541
|
+
ranChange = true;
|
|
49542
|
+
const ran = await wholeSuite(overlay.results().map((r) => ({ targetPath: r.targetPath, newContent: r.newContent })));
|
|
49543
|
+
if (ran !== null) changeAnswer = ran;
|
|
49544
|
+
}
|
|
49545
|
+
const { files } = buildProposalFiles(all);
|
|
49546
|
+
const proposed = files.map((f) => ({ targetPath: f.path, newContent: fileText(f.newLf, f.ending, f.bom) }));
|
|
49547
|
+
const merged = [...overlay.results().filter((r) => !proposed.some((p) => p.targetPath === r.targetPath)).map((r) => ({ targetPath: r.targetPath, newContent: r.newContent })), ...proposed];
|
|
49548
|
+
const anyRegressed = candidates.some((c) => regressedIn(changeAnswer, c) === true);
|
|
49549
|
+
const suiteAnswer = reuse ?? (anyRegressed ? await wholeSuite(merged) : null);
|
|
49550
|
+
const whole4 = suiteAnswer !== null && !suiteAnswer.timedOut && !suiteAnswer.truncated;
|
|
49551
|
+
const counts = { regressed: 0, passes: 0, fails: 0, notChecked: 0, fixes: 0 };
|
|
49552
|
+
for (const c of candidates) {
|
|
49553
|
+
const regressed = regressedIn(changeAnswer, c) === true;
|
|
49554
|
+
const file = files.find((f) => f.path === c.path);
|
|
49555
|
+
const title = (c.index >= 0 ? file?.newTitles.get(c.index) : void 0) ?? c.served.title;
|
|
49556
|
+
const suite = !whole4 ? "not_checked" : suiteAnswer.regressions === 0 && failsIn(suiteAnswer, c.served.path, { ...servedOf(c), title }) === false ? "passes" : "fails";
|
|
49557
|
+
const fixes = regressed && suite === "passes" && changeAnswer ? fixesOf(c, changeAnswer) : [];
|
|
49558
|
+
if (regressed) counts.regressed += 1;
|
|
49559
|
+
counts[suite === "passes" ? "passes" : suite === "fails" ? "fails" : "notChecked"] += 1;
|
|
49560
|
+
counts.fixes += fixes.length;
|
|
49561
|
+
conflictTool.setEvidence(c.path, c.testTitle, { regressed, suite, ...fixes.length > 0 ? { fixes } : {} });
|
|
49562
|
+
}
|
|
49563
|
+
log({
|
|
49564
|
+
event: "codegen.feature_evidence",
|
|
49565
|
+
candidates: candidates.length,
|
|
49566
|
+
reports: all.length,
|
|
49567
|
+
fresh: fresh !== null,
|
|
49568
|
+
ranChange,
|
|
49569
|
+
reused: reuse !== void 0,
|
|
49570
|
+
suiteRan: suiteAnswer !== null,
|
|
49571
|
+
...counts
|
|
49572
|
+
});
|
|
49573
|
+
};
|
|
49574
|
+
const fixesOf = (c, answer) => {
|
|
49575
|
+
const served = c.served;
|
|
49576
|
+
if (c.place === "test") return [{ path: served.path, title: served.title, line: served.line }];
|
|
49577
|
+
const regressions = answer.failingTests.slice(0, answer.regressions);
|
|
49578
|
+
const scope = [.../* @__PURE__ */ new Set([served.path, ...c.place === "support" ? c.usedBy?.files ?? [] : []])];
|
|
49579
|
+
const out2 = [];
|
|
49580
|
+
for (const path of scope) {
|
|
49581
|
+
const text3 = readDisk(path);
|
|
49582
|
+
const located = text3 === null ? null : locateTests(path, text3);
|
|
49583
|
+
if (!located) continue;
|
|
49584
|
+
allTests(located).forEach((t, i3) => {
|
|
49585
|
+
const test = { title: t.title, describes: t.describes, ...i3 >= located.tests.length ? { table: true } : {} };
|
|
49586
|
+
if (out2.length < 20 && regressions.some((id) => testNameMatches(id, path, test))) out2.push({ path, title: t.title, line: t.startLine });
|
|
49587
|
+
});
|
|
49588
|
+
}
|
|
49589
|
+
return out2.length > 0 ? out2 : [{ path: served.path, title: served.title, line: served.line }];
|
|
49590
|
+
};
|
|
47987
49591
|
log({ event: "codegen.loop_start", maxTurns: limits.maxTurns, maxToolCalls: limits.maxToolCalls, listingFiles: args2.listing.length });
|
|
47988
49592
|
const loseTurn = (turn, kind, isFinalTurn, runtimeCode, elapsedMs) => {
|
|
47989
49593
|
const reason = kind === "cut_off" ? "output_too_large" : kind === "slow" ? "turn_timeout" : "runtime_failed";
|
|
@@ -48042,7 +49646,10 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48042
49646
|
const version2 = contextData.contractVersion;
|
|
48043
49647
|
log({ event: "codegen.contract_rejected", turn, ...typeof version2 === "string" ? { version: version2 } : {}, ...reason ? { reason } : {} });
|
|
48044
49648
|
}
|
|
48045
|
-
|
|
49649
|
+
const failure = new CodegenLoopFailure(code === "CONTRACT_REJECTED" ? "contract_rejected" : "semantic_mismatch", String(code), err2);
|
|
49650
|
+
if (code === "CONTRACT_REJECTED" && contextData[FEATURE_TEST_UPDATES_KEY] === true) failure.featureKey = true;
|
|
49651
|
+
if (code === "CONTRACT_REJECTED" && contextData[DATABASE_CHANGE_KEY] !== void 0) failure.databaseKey = true;
|
|
49652
|
+
throw failure;
|
|
48046
49653
|
}
|
|
48047
49654
|
if (envelope?.success === false) {
|
|
48048
49655
|
const runtimeCode = typeof code === "string" ? code : void 0;
|
|
@@ -48094,15 +49701,17 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48094
49701
|
const said = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
|
|
48095
49702
|
if (conflictTool && conflictTool.recorded().length > 0) {
|
|
48096
49703
|
markNotChecked();
|
|
49704
|
+
await featureEvidence();
|
|
48097
49705
|
throw new TestConflictStop(conflictTool.recorded(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
|
|
48098
49706
|
}
|
|
48099
49707
|
if (conflictTool && conflictTool.unreportable().length > 0) {
|
|
48100
49708
|
throw unreportableFailure(conflictTool.unreportable(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
|
|
48101
49709
|
}
|
|
48102
|
-
const
|
|
49710
|
+
const giveUpAnswer = featureOn ? freshTestAnswer() : lastTestAnswer;
|
|
49711
|
+
const unexplained = conflictTool && giveUpAnswer ? unexplainedRegressions(giveUpAnswer, conflictTool.reportedTests()) : [];
|
|
48103
49712
|
if (unexplained.length > 0 && giveUpRefusals < 1 && !isFinal) {
|
|
48104
49713
|
giveUpRefusals += 1;
|
|
48105
|
-
const answer = { rules: [GIVE_UP_RULE], violations: giveUpSentences(unexplained), message: GIVE_UP_MESSAGE };
|
|
49714
|
+
const answer = { rules: [GIVE_UP_RULE], violations: giveUpSentences(unexplained), message: featureOn ? FEATURE_GIVE_UP_MESSAGE : GIVE_UP_MESSAGE };
|
|
48106
49715
|
refusedStreak += 1;
|
|
48107
49716
|
refusedTurns.push({ turn, rules: answer.rules });
|
|
48108
49717
|
log({ event: "codegen.give_up_check", turn, outcome: "sent_back", tests: unexplained.length });
|
|
@@ -48119,11 +49728,19 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48119
49728
|
log({ event: "codegen.red_check", turn, outcome: "gave_up_but_red", files: overlay.changedPaths().length, ...redLeft ? { unproven: redLeft.ids.length } : {} });
|
|
48120
49729
|
const red = currentRedRuns().filter((r) => r.answer !== void 0).at(-1)?.answer;
|
|
48121
49730
|
const kept = last ?? red;
|
|
48122
|
-
return {
|
|
49731
|
+
return {
|
|
49732
|
+
results: overlay.results(),
|
|
49733
|
+
summary: snapshot("gave_up_kept"),
|
|
49734
|
+
doneSummary: said ?? "",
|
|
49735
|
+
steps: sentSteps(),
|
|
49736
|
+
...redLeft ? { redUnproven: redLeft.ids } : {},
|
|
49737
|
+
...kept ? { lastTestAnswer: kept } : {},
|
|
49738
|
+
...handedChange()
|
|
49739
|
+
};
|
|
48123
49740
|
}
|
|
48124
49741
|
if (args2.keepOnGiveUp === true && last !== void 0 && last.regressions + last.newFailures > 0 && handOverRefusal(turn, true) === null) {
|
|
48125
49742
|
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
|
|
48126
|
-
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", gaveUp: true, steps: sentSteps(), ...lastTestAnswer ? { lastTestAnswer } : {} };
|
|
49743
|
+
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", gaveUp: true, steps: sentSteps(), ...lastTestAnswer ? { lastTestAnswer } : {}, ...handedChange() };
|
|
48127
49744
|
}
|
|
48128
49745
|
if ((conflictTool?.record().rejectedBy["unsupported_language"] ?? 0) > 0) {
|
|
48129
49746
|
throw new CodegenLoopFailure("test_unsupported_language", void 0, void 0, UNSUPPORTED_TEST_LANGUAGE_SENTENCE, said);
|
|
@@ -48140,7 +49757,10 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48140
49757
|
if (reviewOn) noteReviewAnswer(turn, "done");
|
|
48141
49758
|
if (conflictTool && conflictTool.recorded().length > 0) {
|
|
48142
49759
|
const said = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
|
|
48143
|
-
if (args2.fixFirst !== true)
|
|
49760
|
+
if (args2.fixFirst !== true) {
|
|
49761
|
+
await featureEvidence();
|
|
49762
|
+
throw new TestConflictStop(conflictTool.recorded(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
|
|
49763
|
+
}
|
|
48144
49764
|
if (args2.phase !== "tests") {
|
|
48145
49765
|
const proof = await proveProposals({ conflicts: conflictTool.recorded(), fix: overlay.results(), run: pastHardStop() ? null : deps.wholeSuite ?? null });
|
|
48146
49766
|
for (const c of conflictTool.recorded()) {
|
|
@@ -48167,6 +49787,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48167
49787
|
}
|
|
48168
49788
|
for (const c of proof.stillFailing) conflictTool.drop(c.path, c.testTitle);
|
|
48169
49789
|
const detail = proof.unexplained.length > 0 ? oldBehaviourSentence(proof.unexplained, MAX_PREVIOUS_DETAIL_CHARS) : proof.stillFailing.length > 0 ? "a proposed change to an existing test could not be made to pass on the fix" : said;
|
|
49790
|
+
await featureEvidence(proof.stillFailing.length === 0 ? proof.answer : void 0);
|
|
48170
49791
|
throw new TestConflictStop(conflictTool.recorded(), new CodegenLoopFailure("cannot_complete", void 0, void 0, detail, said));
|
|
48171
49792
|
}
|
|
48172
49793
|
}
|
|
@@ -48263,8 +49884,14 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48263
49884
|
throw new CodegenLoopFailure("syntax_error", void 0, void 0, sentence, sentence.slice(0, MAX_PREVIOUS_DETAIL_CHARS));
|
|
48264
49885
|
}
|
|
48265
49886
|
}
|
|
48266
|
-
|
|
48267
|
-
|
|
49887
|
+
const heldParts = args2.phase === "code" && args2.parts ? [...args2.parts] : [];
|
|
49888
|
+
if (databaseOn) {
|
|
49889
|
+
for (const p of args2.databaseChange.parts) if (!heldParts.some((h) => h.id === p.id)) heldParts.push({ id: p.id, kind: "stored", name: p.name, paths: [...p.paths], database: p.database });
|
|
49890
|
+
}
|
|
49891
|
+
if (heldParts.length > 0) {
|
|
49892
|
+
const proposalIds = databaseOn ? note?.recorded()?.parts ?? [] : void 0;
|
|
49893
|
+
const dbLog = databaseOn ? { database: args2.databaseChange.parts.length, proposed: proposalIds.length > 0 } : {};
|
|
49894
|
+
const missingParts = missingAtDone(heldParts, overlay.changedPaths(), looksLikeTest, proposalIds);
|
|
48268
49895
|
if (missingParts.length > 0) {
|
|
48269
49896
|
const ids = missingParts.map((m) => m.part.id);
|
|
48270
49897
|
if (partRefusals < 1 && !isFinal) {
|
|
@@ -48272,17 +49899,17 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48272
49899
|
const answer = partsAnswer(missingParts);
|
|
48273
49900
|
refusedStreak += 1;
|
|
48274
49901
|
refusedTurns.push({ turn, rules: answer.rules });
|
|
48275
|
-
log({ event: "codegen.parts_check", turn, outcome: "sent", parts:
|
|
49902
|
+
log({ event: "codegen.parts_check", turn, outcome: "sent", parts: heldParts.length, missing: missingParts.length, ids, ...dbLog });
|
|
48276
49903
|
transcript.push({ turn, toolCalls: [], refused: answer });
|
|
48277
49904
|
if (refusedStreak >= REFUSED_STREAK_LIMIT) forced = "refused_repeatedly";
|
|
48278
49905
|
forced = settleNextTurn(turn, forced);
|
|
48279
49906
|
continue;
|
|
48280
49907
|
}
|
|
48281
|
-
log({ event: "codegen.parts_check", turn, outcome: "missing", parts:
|
|
49908
|
+
log({ event: "codegen.parts_check", turn, outcome: "missing", parts: heldParts.length, missing: missingParts.length, ids, ...dbLog });
|
|
48282
49909
|
const sentence = partMissingSentence(missingParts);
|
|
48283
49910
|
throw new CodegenLoopFailure("part_missing", void 0, void 0, sentence, sentence.slice(0, MAX_PREVIOUS_DETAIL_CHARS));
|
|
48284
49911
|
}
|
|
48285
|
-
log({ event: "codegen.parts_check", turn, outcome: "ok", parts:
|
|
49912
|
+
log({ event: "codegen.parts_check", turn, outcome: "ok", parts: heldParts.length, ...dbLog });
|
|
48286
49913
|
}
|
|
48287
49914
|
const doneSummary = typeof body2.summary === "string" ? body2.summary.slice(0, MAX_SUMMARY_CHARS) : "";
|
|
48288
49915
|
const lane = args2.lane;
|
|
@@ -48290,7 +49917,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48290
49917
|
const red2 = currentRedRuns().filter((r) => r.failing.some((name2) => lane.frozen.some((p) => idPlaceMatches(name2.split("::")[0] ?? "", p)))).at(-1);
|
|
48291
49918
|
if (red2?.answer) {
|
|
48292
49919
|
log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: red2.answer.regressions, newFailures: red2.answer.newFailures, after: "done" });
|
|
48293
|
-
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary, gaveUp: true, steps: sentSteps(), lastTestAnswer: red2.answer };
|
|
49920
|
+
return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary, gaveUp: true, steps: sentSteps(), lastTestAnswer: red2.answer, ...handedChange() };
|
|
48294
49921
|
}
|
|
48295
49922
|
}
|
|
48296
49923
|
const stopReason = isFinal ? `forced_${finalReason}` : "model_done";
|
|
@@ -48305,7 +49932,8 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48305
49932
|
steps: sentSteps(),
|
|
48306
49933
|
...redUnproven ? { redUnproven } : {},
|
|
48307
49934
|
...told ? { lastTestAnswer: told } : {},
|
|
48308
|
-
...proposals.length > 0 ? { proposals } : {}
|
|
49935
|
+
...proposals.length > 0 ? { proposals } : {},
|
|
49936
|
+
...handedChange()
|
|
48309
49937
|
};
|
|
48310
49938
|
}
|
|
48311
49939
|
if (body2.outcome !== "TOOL_CALLS") throw new CodegenLoopFailure("bad_reply");
|
|
@@ -48326,8 +49954,11 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48326
49954
|
for (const [index, call] of calls.entries()) {
|
|
48327
49955
|
let result;
|
|
48328
49956
|
let read;
|
|
49957
|
+
const noted = index < limits.maxCallsPerTurn && note ? note.handle(call, ledger, limits) : null;
|
|
48329
49958
|
if (index >= limits.maxCallsPerTurn) {
|
|
48330
49959
|
result = { id: call.id, name: call.name, status: "budget_exhausted", reason: "too_many_calls", message: "Too many calls in one turn; this one was not run." };
|
|
49960
|
+
} else if (noted) {
|
|
49961
|
+
result = noted;
|
|
48331
49962
|
} else if (call.name === RUN_TESTS_TOOL && tests) {
|
|
48332
49963
|
if (pastHardStop()) throw new CodegenLoopFailure("out_of_time");
|
|
48333
49964
|
const testsStarted = now();
|
|
@@ -48388,10 +50019,13 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48388
50019
|
}
|
|
48389
50020
|
tracker.noteRead(entry);
|
|
48390
50021
|
}
|
|
48391
|
-
if ((WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" && isPlainObject3(call.args) && typeof call.args.path === "string") {
|
|
50022
|
+
if (!noted && (WRITE_TOOLS.has(call.name) || call.name === "revert_file") && result.status === "ok" && isPlainObject3(call.args) && typeof call.args.path === "string") {
|
|
48392
50023
|
tracker.noteWrite(call.args.path, turn);
|
|
48393
50024
|
}
|
|
48394
|
-
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0)
|
|
50025
|
+
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.output.scope === void 0) {
|
|
50026
|
+
lastTestAnswer = result.output;
|
|
50027
|
+
lastTestVersion = versionOfFiles(filesOnDisk());
|
|
50028
|
+
}
|
|
48395
50029
|
if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
|
|
48396
50030
|
const file = result.output.scope === "file" && isPlainObject3(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
|
|
48397
50031
|
redRuns.push({ version: versionOfFiles(filesOnDisk()), ...file ? { file } : {}, failing: result.output.failingTests, truncated: result.output.truncated, answer: result.output });
|
|
@@ -48450,6 +50084,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48450
50084
|
let failure = err2 instanceof CodegenLoopFailure ? err2 : new CodegenLoopFailure("internal_error", void 0, err2);
|
|
48451
50085
|
if (conflictTool && conflictTool.recorded().length > 0) {
|
|
48452
50086
|
markNotChecked();
|
|
50087
|
+
await featureEvidence();
|
|
48453
50088
|
const stop2 = new TestConflictStop(conflictTool.recorded(), failure);
|
|
48454
50089
|
stop2.summary = failure.summary ?? snapshot("test_conflict");
|
|
48455
50090
|
throw withUnreportable(stop2, unreportable);
|
|
@@ -48464,7 +50099,7 @@ async function runCodegenLoop(args2, deps) {
|
|
|
48464
50099
|
|
|
48465
50100
|
// src/codegenPhases.ts
|
|
48466
50101
|
var QP_TOKEN = /\[QP-[^\]\s]+\]/;
|
|
48467
|
-
function frozenFailingTarget(failingTests, frozen,
|
|
50102
|
+
function frozenFailingTarget(failingTests, frozen, textOf2) {
|
|
48468
50103
|
const fileOf = (name3) => name3.split("::")[0] ?? "";
|
|
48469
50104
|
const failing = failingTests.filter((name3) => {
|
|
48470
50105
|
const file2 = fileOf(name3);
|
|
@@ -48477,7 +50112,7 @@ function frozenFailingTarget(failingTests, frozen, textOf) {
|
|
|
48477
50112
|
if (candidates.length === 1) return { failing, amend: candidates[0] };
|
|
48478
50113
|
const sep = name2.indexOf("::");
|
|
48479
50114
|
const testName = (sep >= 0 ? name2.slice(sep + 2) : name2).replace(QP_TOKEN, "").trim();
|
|
48480
|
-
const owners = candidates.filter((path) => definesTest(
|
|
50115
|
+
const owners = candidates.filter((path) => definesTest(textOf2(path) ?? "", testName));
|
|
48481
50116
|
return { failing, amend: owners.length === 1 ? owners[0] : null };
|
|
48482
50117
|
}
|
|
48483
50118
|
function testBlock(text3, token) {
|
|
@@ -48644,8 +50279,8 @@ async function runPhases(i3) {
|
|
|
48644
50279
|
return { failure: recorded(disagree, "amend"), tests, phases, final: true };
|
|
48645
50280
|
}
|
|
48646
50281
|
const path = amend[0];
|
|
48647
|
-
const
|
|
48648
|
-
const overreach = amendmentOverreach(
|
|
50282
|
+
const textOf2 = (results) => results.find((r) => r.targetPath === path)?.newContent ?? "";
|
|
50283
|
+
const overreach = amendmentOverreach(textOf2(d2.results), textOf2(d3.results), token);
|
|
48649
50284
|
if (overreach) {
|
|
48650
50285
|
phases.push(record("amend", "failed", d3.summary));
|
|
48651
50286
|
i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "overreached", why: overreach });
|
|
@@ -48653,7 +50288,7 @@ async function runPhases(i3) {
|
|
|
48653
50288
|
disagree.summary = d3.summary;
|
|
48654
50289
|
return { failure: recorded(disagree, "amend"), tests, phases, final: true };
|
|
48655
50290
|
}
|
|
48656
|
-
const stillShowsBug = await oldCodeVerdict(i3, tests.results, path,
|
|
50291
|
+
const stillShowsBug = await oldCodeVerdict(i3, tests.results, path, textOf2(d3.results), token);
|
|
48657
50292
|
if (stillShowsBug === false) {
|
|
48658
50293
|
phases.push(record("amend", "failed", d3.summary));
|
|
48659
50294
|
i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "failed", why: "passes_on_old_code" });
|
|
@@ -48664,7 +50299,8 @@ async function runPhases(i3) {
|
|
|
48664
50299
|
phases.push(record("amend", "finished", d3.summary));
|
|
48665
50300
|
summaries.push({ phase: "amend", summary: d3.summary });
|
|
48666
50301
|
i3.log({ event: "codegen.phase_end", attempt: i3.attempt, phase: "amend", outcome: "finished" });
|
|
48667
|
-
|
|
50302
|
+
const databaseChange = d3.databaseChange ?? d2.databaseChange;
|
|
50303
|
+
return { done: databaseChange ? { ...d3, databaseChange } : d3, tests, phases, summaries, amended: amend };
|
|
48668
50304
|
}
|
|
48669
50305
|
async function oldCodeVerdict(i3, frozenTests, path, corrected, token) {
|
|
48670
50306
|
if (!i3.onOldCode) return null;
|
|
@@ -48924,7 +50560,7 @@ function buildCodegenLoopRecord(loop) {
|
|
|
48924
50560
|
var import_node_fs16 = require("node:fs");
|
|
48925
50561
|
|
|
48926
50562
|
// src/langReach.ts
|
|
48927
|
-
var
|
|
50563
|
+
var import_node_path20 = require("node:path");
|
|
48928
50564
|
var LANGUAGE_BY_EXT = {
|
|
48929
50565
|
".go": "go",
|
|
48930
50566
|
".py": "python",
|
|
@@ -48940,7 +50576,7 @@ var LANGUAGE_BY_EXT = {
|
|
|
48940
50576
|
".swift": "swift"
|
|
48941
50577
|
};
|
|
48942
50578
|
function languageOf(path) {
|
|
48943
|
-
return LANGUAGE_BY_EXT[
|
|
50579
|
+
return LANGUAGE_BY_EXT[import_node_path20.posix.extname(path).toLowerCase()] ?? null;
|
|
48944
50580
|
}
|
|
48945
50581
|
var MAX_REACH_TESTS = 10;
|
|
48946
50582
|
var MAX_IMPORT_STEPS = 3;
|
|
@@ -48948,7 +50584,7 @@ var MAX_WALK_ROUNDS = 10;
|
|
|
48948
50584
|
var MAX_WALK_FILES = 5e3;
|
|
48949
50585
|
var HUB_LIMIT = 25;
|
|
48950
50586
|
var COMMON_MENTION_LIMIT = 12;
|
|
48951
|
-
var
|
|
50587
|
+
var MAX_FILES_READ2 = 4e3;
|
|
48952
50588
|
var MAX_FILE_CHARS2 = 2e5;
|
|
48953
50589
|
var MIN_NAME_CHARS = 4;
|
|
48954
50590
|
var MIN_CLASS_NAME_CHARS = 3;
|
|
@@ -48964,14 +50600,14 @@ function lookSymbolsOf(findings) {
|
|
|
48964
50600
|
for (const c of findings.callPath) add2(c.path, c.symbol);
|
|
48965
50601
|
return out2;
|
|
48966
50602
|
}
|
|
48967
|
-
var baseNoExt = (p) =>
|
|
48968
|
-
var dirOf = (p) =>
|
|
50603
|
+
var baseNoExt = (p) => import_node_path20.posix.basename(p).replace(/\.[^.]+$/, "");
|
|
50604
|
+
var dirOf = (p) => import_node_path20.posix.dirname(p) === "." ? "" : import_node_path20.posix.dirname(p);
|
|
48969
50605
|
function testStem(path) {
|
|
48970
50606
|
return baseNoExt(path).replace(/^test_/i, "").replace(/(_test|_spec)$/i, "").replace(/Tests?$/, "").toLowerCase();
|
|
48971
50607
|
}
|
|
48972
50608
|
function codeStem(path) {
|
|
48973
50609
|
const b = baseNoExt(path);
|
|
48974
|
-
if (b === "__init__" || b === "mod" || b === "index") return
|
|
50610
|
+
if (b === "__init__" || b === "mod" || b === "index") return import_node_path20.posix.basename(dirOf(path)).toLowerCase();
|
|
48975
50611
|
return b.toLowerCase();
|
|
48976
50612
|
}
|
|
48977
50613
|
function sharedPrefix2(a, b) {
|
|
@@ -49054,7 +50690,7 @@ function buildIndex(files, readText) {
|
|
|
49054
50690
|
}
|
|
49055
50691
|
}
|
|
49056
50692
|
let goModule = null;
|
|
49057
|
-
const gomod = files.filter((f) =>
|
|
50693
|
+
const gomod = files.filter((f) => import_node_path20.posix.basename(f) === "go.mod").sort((a, b) => a.length - b.length)[0];
|
|
49058
50694
|
if (gomod) {
|
|
49059
50695
|
const m = /^module[ \t]+(\S+)/m.exec(readText(gomod) ?? "");
|
|
49060
50696
|
if (m) goModule = { root: dirOf(gomod), module: m[1].replace(/^"|"$/g, "") };
|
|
@@ -49069,7 +50705,7 @@ function pythonImports(file, text3, ix) {
|
|
|
49069
50705
|
const relative11 = (dots, rest) => {
|
|
49070
50706
|
let base = dirOf(file);
|
|
49071
50707
|
for (let i3 = 1; i3 < dots; i3++) base = dirOf(base);
|
|
49072
|
-
const joined = rest ?
|
|
50708
|
+
const joined = rest ? import_node_path20.posix.join(base, rest.replace(/\./g, "/")) : base;
|
|
49073
50709
|
return [`${joined}.py`, `${joined}/__init__.py`].filter((p) => ix.set.has(p) && p !== file);
|
|
49074
50710
|
};
|
|
49075
50711
|
for (const line of text3.split("\n")) {
|
|
@@ -49109,7 +50745,7 @@ function goImports(file, text3, ix) {
|
|
|
49109
50745
|
let dir = null;
|
|
49110
50746
|
if (ix.goModule && (p === ix.goModule.module || p.startsWith(`${ix.goModule.module}/`))) {
|
|
49111
50747
|
const rest = p.slice(ix.goModule.module.length).replace(/^\//, "");
|
|
49112
|
-
dir = ix.goModule.root ?
|
|
50748
|
+
dir = ix.goModule.root ? import_node_path20.posix.join(ix.goModule.root, rest) : rest;
|
|
49113
50749
|
} else {
|
|
49114
50750
|
const tail = p.split("/").slice(-2).join("/");
|
|
49115
50751
|
for (const d of ix.byDir.keys()) if (d === tail || d.endsWith(`/${tail}`)) {
|
|
@@ -49160,7 +50796,7 @@ function importsOf(language, file, text3, ix) {
|
|
|
49160
50796
|
if (language === "jvm") return jvmImports(file, text3, ix);
|
|
49161
50797
|
return [];
|
|
49162
50798
|
}
|
|
49163
|
-
var isPackageInit = (p) =>
|
|
50799
|
+
var isPackageInit = (p) => import_node_path20.posix.basename(p) === "__init__.py";
|
|
49164
50800
|
function testsReaching(input) {
|
|
49165
50801
|
const limit = Math.min(MAX_REACH_TESTS, Math.max(0, input.limit ?? MAX_REACH_TESTS));
|
|
49166
50802
|
const listing = input.isDenied ? input.listing.filter((p) => !input.isDenied(p)) : [...input.listing];
|
|
@@ -49172,7 +50808,7 @@ function testsReaching(input) {
|
|
|
49172
50808
|
const text3 = (p) => {
|
|
49173
50809
|
if (cache2.has(p)) return cache2.get(p);
|
|
49174
50810
|
let t = null;
|
|
49175
|
-
if (reads <
|
|
50811
|
+
if (reads < MAX_FILES_READ2) {
|
|
49176
50812
|
reads += 1;
|
|
49177
50813
|
try {
|
|
49178
50814
|
t = input.readText(p);
|
|
@@ -49338,10 +50974,10 @@ function collectLoopContext(p) {
|
|
|
49338
50974
|
const records = [];
|
|
49339
50975
|
let total = 0;
|
|
49340
50976
|
for (const target of p.targets) {
|
|
49341
|
-
const
|
|
50977
|
+
const named2 = target.contextPaths ?? [];
|
|
49342
50978
|
const added = [];
|
|
49343
50979
|
const skipped = [];
|
|
49344
|
-
for (const path of
|
|
50980
|
+
for (const path of named2) {
|
|
49345
50981
|
if (seen.has(path)) continue;
|
|
49346
50982
|
seen.add(path);
|
|
49347
50983
|
if (matchesDeniedPath(path, denied)) {
|
|
@@ -49447,7 +51083,7 @@ function collectLoopContext(p) {
|
|
|
49447
51083
|
}
|
|
49448
51084
|
records.push({
|
|
49449
51085
|
targetPath: target.path,
|
|
49450
|
-
contextPaths:
|
|
51086
|
+
contextPaths: named2,
|
|
49451
51087
|
addedPaths: added,
|
|
49452
51088
|
skipped,
|
|
49453
51089
|
...importedPaths.length > 0 ? { importedPaths } : {},
|
|
@@ -49485,7 +51121,7 @@ function mapModeMessage(phase, reason) {
|
|
|
49485
51121
|
|
|
49486
51122
|
// src/testsToCheck.ts
|
|
49487
51123
|
var import_node_fs17 = require("node:fs");
|
|
49488
|
-
var
|
|
51124
|
+
var import_node_path21 = require("node:path");
|
|
49489
51125
|
var MAX_TESTS_TO_CHECK = 10;
|
|
49490
51126
|
var SECOND_HOP_BELOW = 3;
|
|
49491
51127
|
function testsToCheck(i3) {
|
|
@@ -49536,7 +51172,7 @@ function testsToCheck(i3) {
|
|
|
49536
51172
|
}
|
|
49537
51173
|
var readFromRoot = (root) => (rel) => {
|
|
49538
51174
|
try {
|
|
49539
|
-
return (0, import_node_fs17.readFileSync)((0,
|
|
51175
|
+
return (0, import_node_fs17.readFileSync)((0, import_node_path21.join)(root, rel), "utf8");
|
|
49540
51176
|
} catch {
|
|
49541
51177
|
return null;
|
|
49542
51178
|
}
|
|
@@ -49682,6 +51318,9 @@ function buildCodegenLoopArgs(p, context = collectLoopContext({
|
|
|
49682
51318
|
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2?.notes === true && p.conflicts ? { conflicts: p.conflicts, ...testsToCheckOf(p) } : {},
|
|
49683
51319
|
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2?.notes === true && p.conflicts && p.fixFirst === true ? { fixFirst: true } : {},
|
|
49684
51320
|
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2?.notes === true && p.conflicts && p.fixFirst === true && p.runScratch ? { runScratch: p.runScratch } : {},
|
|
51321
|
+
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.tools2?.notes === true && p.conflicts && p.featureTestUpdates === true ? { featureTestUpdates: true } : {},
|
|
51322
|
+
// QUIKTR-2445: the harness only (the loop decides where the key is in effect).
|
|
51323
|
+
...p.mode === "loop-tests" && p.tests && p.harness !== false && p.databaseChange && p.databaseChange.length > 0 ? { databaseChange: { parts: p.databaseChange } } : {},
|
|
49685
51324
|
// An approved test change stands whatever version the AI Runtime speaks: a person decided it.
|
|
49686
51325
|
...p.approved && p.approved.length > 0 ? { approved: p.approved.map((r) => ({ targetPath: r.targetPath, newContent: r.newContent })) } : {}
|
|
49687
51326
|
};
|
|
@@ -49750,7 +51389,7 @@ function oldCodeRunner(args2, log, now, wholeSuite = false) {
|
|
|
49750
51389
|
}
|
|
49751
51390
|
async function settleConflictStop(p, args2, stop2, clock) {
|
|
49752
51391
|
const run3 = args2?.tests && clock.now() < clock.hardStopAtMs ? oldCodeRunner(args2, clock.log, clock.now) : null;
|
|
49753
|
-
const verified = await verifyOnOldCode(stop2.conflicts, run3, clock.log);
|
|
51392
|
+
const verified = p.featureTestUpdates === true ? await verifyOnOldCode(stop2.conflicts, run3, clock.log, true) : await verifyOnOldCode(stop2.conflicts, run3, clock.log);
|
|
49754
51393
|
clock.log({ event: "codegen.conflict_stop", reported: stop2.conflicts.length, standing: verified.kept.length, dropped: verified.dropped.length });
|
|
49755
51394
|
if (verified.kept.length === 0) return null;
|
|
49756
51395
|
const settled = new TestConflictStop(verified.kept, stop2.fallback);
|
|
@@ -49858,6 +51497,7 @@ async function runCodegenStep(p) {
|
|
|
49858
51497
|
};
|
|
49859
51498
|
const finish = (done, attempts) => {
|
|
49860
51499
|
if (done.steps && done.steps.steps.length > 0) p.out.steps = done.steps;
|
|
51500
|
+
if (done.databaseChange) p.out.databaseChange = done.databaseChange;
|
|
49861
51501
|
p.out.loop = buildCodegenLoopRecord(attempts ? { ...done.summary, attempts } : done.summary);
|
|
49862
51502
|
const planned = new Set(p.targets.map((t) => t.path));
|
|
49863
51503
|
for (const r of done.results) {
|
|
@@ -49868,6 +51508,22 @@ async function runCodegenStep(p) {
|
|
|
49868
51508
|
log({ event: "codegen.attempt_start", attempt: 1 });
|
|
49869
51509
|
const firstStarted = now();
|
|
49870
51510
|
let first = await attempt2();
|
|
51511
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.featureKey === true && p.featureTestUpdates === true) {
|
|
51512
|
+
log({ event: "codegen.version_fallback", from: "feature_test_updates" });
|
|
51513
|
+
p.featureTestUpdates = false;
|
|
51514
|
+
const kept = "tests" in first ? first.tests : void 0;
|
|
51515
|
+
args2 = buildCodegenLoopArgs(p, context);
|
|
51516
|
+
first = await attempt2(void 0, 1, kept);
|
|
51517
|
+
}
|
|
51518
|
+
const databaseStop = (failure, why) => {
|
|
51519
|
+
const stop2 = storedStop(p.databaseChange ?? []);
|
|
51520
|
+
log({ event: "codegen.database_change_refused", ids: stop2.ids, ...why === "no_harness" ? { why } : {} });
|
|
51521
|
+
p.out.loop = buildCodegenLoopRecord({ ...failure.summary ?? NO_SUMMARY, stopReason: "failed" });
|
|
51522
|
+
return new PartsStopError(stop2);
|
|
51523
|
+
};
|
|
51524
|
+
if ("failure" in first && first.failure.reason === "contract_rejected" && first.failure.databaseKey === true && p.databaseChange && p.databaseChange.length > 0) {
|
|
51525
|
+
throw databaseStop(first.failure, "key_refused");
|
|
51526
|
+
}
|
|
49871
51527
|
if ("failure" in first && first.failure.reason === "contract_rejected" && p.runScratch && args2?.runScratch) {
|
|
49872
51528
|
log({ event: "codegen.version_fallback", from: "codegen-loop-9", to: "codegen-loop-8" });
|
|
49873
51529
|
p.runScratch = void 0;
|
|
@@ -49909,6 +51565,7 @@ async function runCodegenStep(p) {
|
|
|
49909
51565
|
throw new MapModeError("codegen", "contract_rejected");
|
|
49910
51566
|
}
|
|
49911
51567
|
if ("failure" in first && first.failure.reason === "contract_rejected" && args2?.harness === true) {
|
|
51568
|
+
if (p.databaseChange && p.databaseChange.length > 0) throw databaseStop(first.failure, "no_harness");
|
|
49912
51569
|
log({ event: "codegen.version_fallback", from: "codegen-loop-3", to: "codegen-loop-2" });
|
|
49913
51570
|
p.harness = false;
|
|
49914
51571
|
args2 = buildCodegenLoopArgs(p, context);
|
|
@@ -50063,10 +51720,12 @@ async function runHealAttempt(i3) {
|
|
|
50063
51720
|
const args2 = buildCodegenLoopArgs({ ...p, targets, workspaceListing, fixFirst: false }, context);
|
|
50064
51721
|
if (i3.review !== void 0 || i3.answer.regressions <= 0) delete args2.conflicts;
|
|
50065
51722
|
if (args2.conflicts && i3.misfits && i3.misfits.length > 0) args2.conflicts = withMisfits(args2.conflicts, i3.misfits);
|
|
51723
|
+
if (args2.databaseChange && p.out.databaseChange) args2.databaseChange = { ...args2.databaseChange, closed: true };
|
|
50066
51724
|
args2.protectedTestPaths = original.protectedTestPaths;
|
|
50067
51725
|
if (original.baseContext.protectedTestPaths !== void 0) args2.baseContext.protectedTestPaths = original.baseContext.protectedTestPaths;
|
|
50068
51726
|
else delete args2.baseContext.protectedTestPaths;
|
|
50069
51727
|
const now = p.deps?.now ?? Date.now;
|
|
51728
|
+
const log = p.deps?.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
50070
51729
|
try {
|
|
50071
51730
|
const done = await runCodegenLoop(
|
|
50072
51731
|
// `keepOnGiveUp` is off on purpose, whatever the step says: only a first attempt keeps a give-up. A fix that gives up ends as `heal_failed`
|
|
@@ -50086,6 +51745,8 @@ async function runHealAttempt(i3) {
|
|
|
50086
51745
|
{
|
|
50087
51746
|
post: (contextData, signal) => postCodegenTurn(p.gateway, contextData, signal),
|
|
50088
51747
|
secrets: [p.gateway.token],
|
|
51748
|
+
// QUIKTR-2442: the whole suite for the proof of an add-only update of set-up, on the fix's own clock (none past it).
|
|
51749
|
+
wholeSuite: async (files) => args2.tests && now() < i3.hardStopAtMs ? oldCodeRunner(args2, log, now, true)(files) : null,
|
|
50089
51750
|
...p.deps,
|
|
50090
51751
|
now,
|
|
50091
51752
|
hardStopAtMs: i3.hardStopAtMs
|
|
@@ -50093,11 +51754,11 @@ async function runHealAttempt(i3) {
|
|
|
50093
51754
|
);
|
|
50094
51755
|
i3.out.summary = done.summary;
|
|
50095
51756
|
if (done.steps && done.steps.steps.length > 0) p.out.steps = done.steps;
|
|
51757
|
+
if (done.databaseChange) p.out.databaseChange = done.databaseChange;
|
|
50096
51758
|
return done.results;
|
|
50097
51759
|
} catch (err2) {
|
|
50098
51760
|
if (err2 instanceof TestConflictStop) {
|
|
50099
51761
|
i3.out.summary = err2.summary;
|
|
50100
|
-
const log = p.deps?.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
50101
51762
|
const settled = await settleConflictStop(p, args2, err2, { log, now, hardStopAtMs: i3.hardStopAtMs });
|
|
50102
51763
|
if (settled) {
|
|
50103
51764
|
warnUnreportable(p, err2);
|
|
@@ -50161,10 +51822,10 @@ async function runVerifyAndFix(p) {
|
|
|
50161
51822
|
const first = healsRun === 1 ? { trigger: "unneeded_changes" } : {};
|
|
50162
51823
|
p.log({ event: "heal.start", attempt: attemptsRun, healsRun, trigger: "unneeded_changes", blocks: verdict.blocks.length });
|
|
50163
51824
|
const startedAt = p.now();
|
|
50164
|
-
let
|
|
51825
|
+
let fixed2 = null;
|
|
50165
51826
|
let failureReason;
|
|
50166
51827
|
try {
|
|
50167
|
-
|
|
51828
|
+
fixed2 = await p.heal({
|
|
50168
51829
|
results: before,
|
|
50169
51830
|
answer: greenAnswer(verdict.testCount),
|
|
50170
51831
|
attempt: attemptsRun - 1,
|
|
@@ -50193,15 +51854,15 @@ async function runVerifyAndFix(p) {
|
|
|
50193
51854
|
}
|
|
50194
51855
|
lastAttemptMs = p.now() - startedAt;
|
|
50195
51856
|
const review = lastReview ? { review: lastReview } : {};
|
|
50196
|
-
if (
|
|
50197
|
-
const v2 = await p.verify(
|
|
51857
|
+
if (fixed2) {
|
|
51858
|
+
const v2 = await p.verify(fixed2, true);
|
|
50198
51859
|
attempts.push({
|
|
50199
51860
|
n: attemptsRun,
|
|
50200
51861
|
startedBy: "heal",
|
|
50201
51862
|
checks: v2.ok ? "passed" : v2.stage === "gate" ? "tests_failed" : "failed_check",
|
|
50202
51863
|
...!v2.ok && v2.answer ? { gate: countsOf(v2.answer) } : {}
|
|
50203
51864
|
});
|
|
50204
|
-
if (v2.ok) return { outcome: v2, results:
|
|
51865
|
+
if (v2.ok) return { outcome: v2, results: fixed2, heal: record2("passed", first), ...review };
|
|
50205
51866
|
try {
|
|
50206
51867
|
v2.undo();
|
|
50207
51868
|
} catch (err2) {
|
|
@@ -50214,7 +51875,7 @@ async function runVerifyAndFix(p) {
|
|
|
50214
51875
|
return {
|
|
50215
51876
|
outcome: back,
|
|
50216
51877
|
results: before,
|
|
50217
|
-
heal:
|
|
51878
|
+
heal: fixed2 ? record2("review_reverted", first) : record2("heal_failed", { ...first, ...failureReason ? { failureReason } : {} }),
|
|
50218
51879
|
...review
|
|
50219
51880
|
};
|
|
50220
51881
|
};
|
|
@@ -50315,7 +51976,7 @@ async function runVerifyAndFix(p) {
|
|
|
50315
51976
|
// src/hunkCheck.ts
|
|
50316
51977
|
var import_node_child_process9 = require("node:child_process");
|
|
50317
51978
|
var import_node_fs20 = require("node:fs");
|
|
50318
|
-
var
|
|
51979
|
+
var import_node_path22 = require("node:path");
|
|
50319
51980
|
|
|
50320
51981
|
// src/scopeCheck.ts
|
|
50321
51982
|
var import_node_fs19 = require("node:fs");
|
|
@@ -50462,7 +52123,7 @@ async function runHunkCheck(input) {
|
|
|
50462
52123
|
let slowestRunMs = input.baselineMs ?? 3e4;
|
|
50463
52124
|
const runOnce = async (c) => {
|
|
50464
52125
|
const reportBefore = findReport(input.root);
|
|
50465
|
-
const preserve = reportBefore ? [(0,
|
|
52126
|
+
const preserve = reportBefore ? [(0, import_node_path22.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
50466
52127
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
50467
52128
|
const startedWall = Date.now();
|
|
50468
52129
|
const startedAt = now();
|
|
@@ -50498,7 +52159,7 @@ async function runHunkCheck(input) {
|
|
|
50498
52159
|
};
|
|
50499
52160
|
const runRelated = async (c, plan, limitMs) => {
|
|
50500
52161
|
const reportBefore = findReport(input.root);
|
|
50501
|
-
const preserve = reportBefore ? [(0,
|
|
52162
|
+
const preserve = reportBefore ? [(0, import_node_path22.relative)(input.root, reportBefore).split("\\").join("/")] : [];
|
|
50502
52163
|
const content = `${c.bom ? "\uFEFF" : ""}${fromLf(revertHunk(c.originalLf, c.currentLf, c.hunk), c.ending)}`;
|
|
50503
52164
|
const startedAt = now();
|
|
50504
52165
|
result.relatedRuns += 1;
|
|
@@ -50643,7 +52304,7 @@ function healFailureSuffix(heal) {
|
|
|
50643
52304
|
|
|
50644
52305
|
// src/dependencyCheck.ts
|
|
50645
52306
|
var import_node_fs21 = require("node:fs");
|
|
50646
|
-
var
|
|
52307
|
+
var import_node_path23 = require("node:path");
|
|
50647
52308
|
var SCANNABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
50648
52309
|
var IMPORT_RE = /(?:\bimport\b[^'"]*?\bfrom\s*|\bimport\s*\(\s*|\bexport\b[^'"]*?\bfrom\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"]+)\1/g;
|
|
50649
52310
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -50731,8 +52392,8 @@ function dependencyNames(pkg) {
|
|
|
50731
52392
|
]);
|
|
50732
52393
|
}
|
|
50733
52394
|
function readDeclaredDependencies(results, workspaceRoot) {
|
|
50734
|
-
const packageJsonPath = (0,
|
|
50735
|
-
const generated = results.find((r) => (0,
|
|
52395
|
+
const packageJsonPath = (0, import_node_path23.join)((0, import_node_path23.resolve)(workspaceRoot ?? "."), "package.json");
|
|
52396
|
+
const generated = results.find((r) => (0, import_node_path23.resolve)(r.targetPath) === packageJsonPath);
|
|
50736
52397
|
let raw;
|
|
50737
52398
|
if (generated) {
|
|
50738
52399
|
raw = generated.newContent;
|
|
@@ -50802,10 +52463,10 @@ function stripJsonComments(text3) {
|
|
|
50802
52463
|
return out2.replace(/,(\s*[}\]])/g, "$1");
|
|
50803
52464
|
}
|
|
50804
52465
|
function resolveAliasPrefixes(results, workspaceRoot) {
|
|
50805
|
-
const root = (0,
|
|
52466
|
+
const root = (0, import_node_path23.resolve)(workspaceRoot ?? ".");
|
|
50806
52467
|
for (const filename of ["tsconfig.json", "jsconfig.json"]) {
|
|
50807
|
-
const configPath = (0,
|
|
50808
|
-
const generated = results.find((r) => (0,
|
|
52468
|
+
const configPath = (0, import_node_path23.join)(root, filename);
|
|
52469
|
+
const generated = results.find((r) => (0, import_node_path23.resolve)(r.targetPath) === configPath);
|
|
50809
52470
|
let raw;
|
|
50810
52471
|
if (generated) {
|
|
50811
52472
|
raw = generated.newContent;
|
|
@@ -51163,7 +52824,7 @@ function describeVanishedTests(vanished) {
|
|
|
51163
52824
|
}
|
|
51164
52825
|
|
|
51165
52826
|
// src/verifyChange.ts
|
|
51166
|
-
var
|
|
52827
|
+
var import_node_path24 = require("node:path");
|
|
51167
52828
|
|
|
51168
52829
|
// src/packageUse.ts
|
|
51169
52830
|
var import_node_child_process10 = require("node:child_process");
|
|
@@ -51225,7 +52886,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
51225
52886
|
const depCheck = checkImportDependencies(results, readDeclaredDependencies(results, packet.workspaceRoot), resolveAliasPrefixes(results, packet.workspaceRoot), {
|
|
51226
52887
|
originalOf: (path) => {
|
|
51227
52888
|
try {
|
|
51228
|
-
return (0, import_node_fs23.readFileSync)((0,
|
|
52889
|
+
return (0, import_node_fs23.readFileSync)((0, import_node_path24.join)(cwd, path), "utf8");
|
|
51229
52890
|
} catch (err2) {
|
|
51230
52891
|
return err2.code === "ENOENT" ? "" : null;
|
|
51231
52892
|
}
|
|
@@ -51275,7 +52936,7 @@ async function verifyChange(ctx, results, undoable) {
|
|
|
51275
52936
|
flushedAt = now();
|
|
51276
52937
|
if (undoable) {
|
|
51277
52938
|
const report = findJUnitReport(cwd);
|
|
51278
|
-
const ignore = report ? [(0,
|
|
52939
|
+
const ignore = report ? [(0, import_node_path24.relative)(cwd, report).split("\\").join("/")] : [];
|
|
51279
52940
|
const flush = undoableFlush(cwd, results, flushCodegenResults, { ignore });
|
|
51280
52941
|
undo = () => flush.undo();
|
|
51281
52942
|
} else {
|
|
@@ -51441,7 +53102,7 @@ function buildToolsV2Env(i3) {
|
|
|
51441
53102
|
}
|
|
51442
53103
|
|
|
51443
53104
|
// src/repoMap.ts
|
|
51444
|
-
var
|
|
53105
|
+
var import_node_path25 = require("node:path");
|
|
51445
53106
|
var MAP_BUDGET_TOKENS = 4e3;
|
|
51446
53107
|
var MAX_FOLDERS = 200;
|
|
51447
53108
|
var MAX_LANGUAGES = 12;
|
|
@@ -51483,7 +53144,7 @@ function guidanceFiles(i3, perFile2, total) {
|
|
|
51483
53144
|
function languages2(listing) {
|
|
51484
53145
|
const counts = /* @__PURE__ */ new Map();
|
|
51485
53146
|
for (const p of listing) {
|
|
51486
|
-
const ext =
|
|
53147
|
+
const ext = import_node_path25.posix.extname(p).toLowerCase();
|
|
51487
53148
|
if (ext && ext.length <= 12) counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
51488
53149
|
}
|
|
51489
53150
|
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}`);
|
|
@@ -51499,7 +53160,7 @@ function testFacts(i3) {
|
|
|
51499
53160
|
const depth = i3.writeRoot === "" ? 0 : i3.writeRoot.split("/").length;
|
|
51500
53161
|
for (const t of tests) {
|
|
51501
53162
|
const parts2 = t.split("/");
|
|
51502
|
-
const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") :
|
|
53163
|
+
const folder = parts2.length > depth + 1 ? parts2.slice(0, depth + 1).join("/") : import_node_path25.posix.dirname(t);
|
|
51503
53164
|
byFolder.set(folder, (byFolder.get(folder) ?? 0) + 1);
|
|
51504
53165
|
}
|
|
51505
53166
|
for (const [folder, n] of [...byFolder.entries()].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 3)) {
|
|
@@ -51609,7 +53270,7 @@ function buildRepoMap(i3) {
|
|
|
51609
53270
|
}
|
|
51610
53271
|
|
|
51611
53272
|
// src/workspacePackages.ts
|
|
51612
|
-
var
|
|
53273
|
+
var import_node_path26 = require("node:path");
|
|
51613
53274
|
var MAX_READ_ROOTS = 8;
|
|
51614
53275
|
function isObject2(x) {
|
|
51615
53276
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -51671,8 +53332,8 @@ function workspacePackages(readText, packageJsonPaths) {
|
|
|
51671
53332
|
const exclude = patterns.filter((p) => p.startsWith("!")).map((p) => globMatcher(p.slice(1)));
|
|
51672
53333
|
const out2 = [];
|
|
51673
53334
|
for (const file of packageJsonPaths) {
|
|
51674
|
-
if (
|
|
51675
|
-
const folder =
|
|
53335
|
+
if (import_node_path26.posix.basename(file) !== "package.json" || file === "package.json" || file.split("/").includes("node_modules")) continue;
|
|
53336
|
+
const folder = import_node_path26.posix.dirname(file);
|
|
51676
53337
|
if (!include.some((re) => re.test(folder)) || exclude.some((re) => re.test(folder))) continue;
|
|
51677
53338
|
const text3 = readText(file);
|
|
51678
53339
|
const json = text3 === null ? null : parseJsonc(text3);
|
|
@@ -51952,17 +53613,17 @@ function writePhase0Marker(runId) {
|
|
|
51952
53613
|
// src/failureArtifact.ts
|
|
51953
53614
|
var import_node_child_process11 = require("node:child_process");
|
|
51954
53615
|
var import_node_fs25 = require("node:fs");
|
|
51955
|
-
var
|
|
53616
|
+
var import_node_path27 = require("node:path");
|
|
51956
53617
|
var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
|
|
51957
53618
|
var REPORT_COPY = "final-test-report.xml";
|
|
51958
53619
|
var MAX_REPORT_BYTES = 5 * 1024 * 1024;
|
|
51959
53620
|
var MAX_FILES = 200;
|
|
51960
|
-
var RUNNER_VERSION = true ? "9.3.0-rc.
|
|
53621
|
+
var RUNNER_VERSION = true ? "9.3.0-rc.76" : "dev";
|
|
51961
53622
|
function safeDestination(base, repoPath) {
|
|
51962
|
-
if (!repoPath || (0,
|
|
51963
|
-
const destination = (0,
|
|
51964
|
-
const rel = (0,
|
|
51965
|
-
if (!rel || rel.startsWith("..") || (0,
|
|
53623
|
+
if (!repoPath || (0, import_node_path27.isAbsolute)(repoPath)) return null;
|
|
53624
|
+
const destination = (0, import_node_path27.resolve)(base, repoPath);
|
|
53625
|
+
const rel = (0, import_node_path27.relative)(base, destination);
|
|
53626
|
+
if (!rel || rel.startsWith("..") || (0, import_node_path27.isAbsolute)(rel)) return null;
|
|
51966
53627
|
return destination;
|
|
51967
53628
|
}
|
|
51968
53629
|
var BUNDLE_FILE = "quikpilot-change.bundle";
|
|
@@ -51972,7 +53633,7 @@ function keepCommitBundle(repo, folder, branch) {
|
|
|
51972
53633
|
if (git3(["rev-parse", "--abbrev-ref", "HEAD"]) !== branch) return null;
|
|
51973
53634
|
if (git3(["diff", "--name-only", "HEAD~1", "HEAD"]) === "") return null;
|
|
51974
53635
|
const commit2 = git3(["rev-parse", "HEAD"]);
|
|
51975
|
-
const file = (0,
|
|
53636
|
+
const file = (0, import_node_path27.join)(folder, BUNDLE_FILE);
|
|
51976
53637
|
git3(["bundle", "create", file, "HEAD", "^HEAD~1"]);
|
|
51977
53638
|
let verified = true;
|
|
51978
53639
|
try {
|
|
@@ -51988,7 +53649,7 @@ function keepCommitBundle(repo, folder, branch) {
|
|
|
51988
53649
|
function writeFailureArtifact(input) {
|
|
51989
53650
|
if (input.results.length === 0) return { written: false };
|
|
51990
53651
|
try {
|
|
51991
|
-
const base = (0,
|
|
53652
|
+
const base = (0, import_node_path27.resolve)(input.cwd, FAILURE_ARTIFACT_DIR);
|
|
51992
53653
|
(0, import_node_fs25.rmSync)(base, { recursive: true, force: true });
|
|
51993
53654
|
(0, import_node_fs25.mkdirSync)(base, { recursive: true });
|
|
51994
53655
|
const files = [];
|
|
@@ -51999,7 +53660,7 @@ function writeFailureArtifact(input) {
|
|
|
51999
53660
|
skipped.push(result.targetPath);
|
|
52000
53661
|
continue;
|
|
52001
53662
|
}
|
|
52002
|
-
(0, import_node_fs25.mkdirSync)((0,
|
|
53663
|
+
(0, import_node_fs25.mkdirSync)((0, import_node_path27.dirname)(destination), { recursive: true });
|
|
52003
53664
|
(0, import_node_fs25.writeFileSync)(destination, result.newContent);
|
|
52004
53665
|
files.push({ path: result.targetPath, bytes: Buffer.byteLength(result.newContent) });
|
|
52005
53666
|
}
|
|
@@ -52008,7 +53669,7 @@ function writeFailureArtifact(input) {
|
|
|
52008
53669
|
if (input.testReport.byteLength > MAX_REPORT_BYTES) {
|
|
52009
53670
|
testReport = "too-large";
|
|
52010
53671
|
} else {
|
|
52011
|
-
(0, import_node_fs25.writeFileSync)((0,
|
|
53672
|
+
(0, import_node_fs25.writeFileSync)((0, import_node_path27.join)(base, REPORT_COPY), input.testReport);
|
|
52012
53673
|
testReport = "included";
|
|
52013
53674
|
}
|
|
52014
53675
|
}
|
|
@@ -52030,8 +53691,8 @@ function writeFailureArtifact(input) {
|
|
|
52030
53691
|
bundle
|
|
52031
53692
|
};
|
|
52032
53693
|
const text3 = JSON.stringify(manifest, (_key, value) => typeof value === "string" ? scrubSecrets(value, input.secrets) : value, 2);
|
|
52033
|
-
(0, import_node_fs25.writeFileSync)((0,
|
|
52034
|
-
return { written: (0, import_node_fs25.existsSync)((0,
|
|
53694
|
+
(0, import_node_fs25.writeFileSync)((0, import_node_path27.join)(base, "manifest.json"), text3);
|
|
53695
|
+
return { written: (0, import_node_fs25.existsSync)((0, import_node_path27.join)(base, "manifest.json")) };
|
|
52035
53696
|
} catch (err2) {
|
|
52036
53697
|
console.warn(`::warning::Could not keep the failed run's files: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
52037
53698
|
return { written: false };
|
|
@@ -52041,7 +53702,7 @@ function writeFailureArtifact(input) {
|
|
|
52041
53702
|
// src/finalChange.ts
|
|
52042
53703
|
var import_node_child_process12 = require("node:child_process");
|
|
52043
53704
|
var import_node_fs26 = require("node:fs");
|
|
52044
|
-
var
|
|
53705
|
+
var import_node_path28 = require("node:path");
|
|
52045
53706
|
function changesAgainstBase(root, wanted) {
|
|
52046
53707
|
if (wanted.size === 0) return [];
|
|
52047
53708
|
const status = (0, import_node_child_process12.execFileSync)("git", ["status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
|
|
@@ -52055,7 +53716,7 @@ function changesAgainstBase(root, wanted) {
|
|
|
52055
53716
|
return [...wanted].sort().filter((path) => {
|
|
52056
53717
|
if (!changed.has(path)) return false;
|
|
52057
53718
|
try {
|
|
52058
|
-
return (0, import_node_fs26.statSync)((0,
|
|
53719
|
+
return (0, import_node_fs26.statSync)((0, import_node_path28.join)(root, path)).isFile();
|
|
52059
53720
|
} catch {
|
|
52060
53721
|
return false;
|
|
52061
53722
|
}
|
|
@@ -52148,9 +53809,9 @@ async function resolveTestDiscovery(i3) {
|
|
|
52148
53809
|
const base = { command: i3.command, listing: i3.listing, workspaceRoot: i3.workspaceRoot, cwd: i3.cwd };
|
|
52149
53810
|
const done = (result, warning) => {
|
|
52150
53811
|
const waitedMs = now() - started;
|
|
52151
|
-
const
|
|
52152
|
-
const method = result.source === "live" ? "report" :
|
|
52153
|
-
i3.log?.({ event: "test_discovery", source: result.source, reason: result.reason, files: result.files, unmapped: result.unmapped, waitedMs, method, named });
|
|
53812
|
+
const named2 = i3.namedTestFiles ?? 0;
|
|
53813
|
+
const method = result.source === "live" ? "report" : named2 > 0 ? "names" : "none";
|
|
53814
|
+
i3.log?.({ event: "test_discovery", source: result.source, reason: result.reason, files: result.files, unmapped: result.unmapped, waitedMs, method, named: named2 });
|
|
52154
53815
|
return { result, waitedMs, ...warning ? { warning } : {} };
|
|
52155
53816
|
};
|
|
52156
53817
|
if (!i3.command || i3.command.trim().length === 0) return done(buildTestDiscovery({ ...base, snapshot: null }));
|
|
@@ -52165,8 +53826,8 @@ async function resolveTestDiscovery(i3) {
|
|
|
52165
53826
|
try {
|
|
52166
53827
|
const first = await Promise.race([settled, timeout]);
|
|
52167
53828
|
if (first === "timeout") {
|
|
52168
|
-
const
|
|
52169
|
-
return done(absent("timeout"),
|
|
53829
|
+
const named2 = i3.namedTestFiles ?? 0;
|
|
53830
|
+
return done(absent("timeout"), named2 > 0 ? lateReportWarning(Math.round(i3.waitMs / 1e3), named2) : TIMEOUT_WARNING);
|
|
52170
53831
|
}
|
|
52171
53832
|
return done(buildTestDiscovery({ ...base, snapshot: first }));
|
|
52172
53833
|
} finally {
|
|
@@ -52175,12 +53836,12 @@ async function resolveTestDiscovery(i3) {
|
|
|
52175
53836
|
}
|
|
52176
53837
|
|
|
52177
53838
|
// src/targetingFindings.ts
|
|
52178
|
-
var
|
|
53839
|
+
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
52179
53840
|
function prepareTargetingFindings(raw, listing, deniedPaths) {
|
|
52180
|
-
if (!
|
|
53841
|
+
if (!isRecord5(raw)) return void 0;
|
|
52181
53842
|
const { verdict, files, callPath, evidence, searches } = raw;
|
|
52182
53843
|
if (typeof verdict !== "string" || !Array.isArray(files) || !Array.isArray(callPath) || !Array.isArray(evidence)) return void 0;
|
|
52183
|
-
const keep = (entry) =>
|
|
53844
|
+
const keep = (entry) => isRecord5(entry) && typeof entry.path === "string" && listing.has(entry.path) && matchesDeniedPath(entry.path, deniedPaths) === null;
|
|
52184
53845
|
const kept = {
|
|
52185
53846
|
files: files.filter(keep),
|
|
52186
53847
|
callPath: callPath.filter(keep),
|
|
@@ -52234,7 +53895,7 @@ function validateTarget(target, workspaceRoot, workspaceListing, deniedPaths) {
|
|
|
52234
53895
|
);
|
|
52235
53896
|
}
|
|
52236
53897
|
}
|
|
52237
|
-
function buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false) {
|
|
53898
|
+
function buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false, storedProposals = false) {
|
|
52238
53899
|
const contextData = {
|
|
52239
53900
|
// NESTED, NOT FLATTENED — a second vocabulary for the design shape is exactly what
|
|
52240
53901
|
// QUIKTR-1034 cost.
|
|
@@ -52260,6 +53921,9 @@ function buildContextData(design, workspaceListing, requiredTests, deniedPaths,
|
|
|
52260
53921
|
if (partsCheck) {
|
|
52261
53922
|
contextData.partsCheck = true;
|
|
52262
53923
|
}
|
|
53924
|
+
if (partsCheck && storedProposals) {
|
|
53925
|
+
contextData[STORED_PROPOSALS_KEY] = true;
|
|
53926
|
+
}
|
|
52263
53927
|
return contextData;
|
|
52264
53928
|
}
|
|
52265
53929
|
async function postTargeting(gateway, contextData, signal) {
|
|
@@ -52309,14 +53973,14 @@ function finalizeTargeting(body2, workspaceRoot, workspaceListing, deniedPaths)
|
|
|
52309
53973
|
...correctedKinds.length > 0 ? { correctedKinds } : {}
|
|
52310
53974
|
};
|
|
52311
53975
|
}
|
|
52312
|
-
async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false) {
|
|
52313
|
-
const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
53976
|
+
async function runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope = [], findings, partsCheck = false, storedProposals = false) {
|
|
53977
|
+
const contextData = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
|
|
52314
53978
|
let envelope = await postTargeting(gateway, contextData);
|
|
52315
53979
|
let warnings;
|
|
52316
53980
|
if (findings && envelope?.errorCode === "CONTRACT_REJECTED") {
|
|
52317
53981
|
envelope = await postTargeting(
|
|
52318
53982
|
gateway,
|
|
52319
|
-
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck)
|
|
53983
|
+
buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, void 0, partsCheck, storedProposals)
|
|
52320
53984
|
);
|
|
52321
53985
|
warnings = ["QuikPilot's targeting ran without the early look's findings (the AI service did not accept them)."];
|
|
52322
53986
|
}
|
|
@@ -52355,15 +54019,16 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
|
|
|
52355
54019
|
const wired = designForTargeting(design, options.partsCheck === true);
|
|
52356
54020
|
design = wired.design;
|
|
52357
54021
|
const partsCheck = wired.partsCheck;
|
|
54022
|
+
const storedProposals = partsCheck && options.storedProposals === true;
|
|
52358
54023
|
if (options.scope?.view === "map") {
|
|
52359
|
-
return runMapTargeting(gateway, design, workspaceRoot, options.scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck);
|
|
54024
|
+
return runMapTargeting(gateway, design, workspaceRoot, options.scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck, storedProposals);
|
|
52360
54025
|
}
|
|
52361
54026
|
const mode = options.mode ?? resolveTargetingMode();
|
|
52362
54027
|
const findings = prepareTargetingFindings(options.findings, new Set(workspaceListing), deniedPaths);
|
|
52363
54028
|
if (mode !== "loop") {
|
|
52364
|
-
return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
54029
|
+
return runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
|
|
52365
54030
|
}
|
|
52366
|
-
const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
54031
|
+
const baseContext = buildContextData(design, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
|
|
52367
54032
|
const listingView = repoViewOf(options.scope);
|
|
52368
54033
|
let summary;
|
|
52369
54034
|
let runtimeCode;
|
|
@@ -52410,7 +54075,7 @@ async function runTargeting(gateway, design, workspaceRoot, workspaceListing, re
|
|
|
52410
54075
|
toolCalls: fellBack.toolCalls,
|
|
52411
54076
|
...runtimeCode && CODE_LIKE.test(runtimeCode) ? { runtimeCode } : {}
|
|
52412
54077
|
});
|
|
52413
|
-
const single = await runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
54078
|
+
const single = await runSingleShot(gateway, design, workspaceRoot, workspaceListing, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
|
|
52414
54079
|
return {
|
|
52415
54080
|
...single,
|
|
52416
54081
|
loop: fellBack,
|
|
@@ -52423,7 +54088,7 @@ function mapTestDiscovery(testDiscovery) {
|
|
|
52423
54088
|
if (estimateTokens(JSON.stringify(testDiscovery.discoveredTestFiles, null, 2)) <= MAP_DISCOVERY_MAX_TOKENS) return testDiscovery;
|
|
52424
54089
|
return { report: "PRESENT", discoveredTestFiles: [], unmappedEntries: Math.max(1, testDiscovery.unmappedEntries + testDiscovery.discoveredTestFiles.length) };
|
|
52425
54090
|
}
|
|
52426
|
-
function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false) {
|
|
54091
|
+
function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck = false, storedProposals = false) {
|
|
52427
54092
|
return {
|
|
52428
54093
|
repoMap,
|
|
52429
54094
|
design,
|
|
@@ -52433,12 +54098,13 @@ function buildMapContextData(repoMap, design, requiredTests, deniedPaths, testDi
|
|
|
52433
54098
|
...outOfScope.length > 0 ? { outOfScope } : {},
|
|
52434
54099
|
testDiscovery: mapTestDiscovery(testDiscovery),
|
|
52435
54100
|
...findings ? { findings } : {},
|
|
52436
|
-
...partsCheck ? { partsCheck: true } : {}
|
|
54101
|
+
...partsCheck ? { partsCheck: true } : {},
|
|
54102
|
+
...partsCheck && storedProposals ? { [STORED_PROPOSALS_KEY]: true } : {}
|
|
52437
54103
|
};
|
|
52438
54104
|
}
|
|
52439
|
-
async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck) {
|
|
54105
|
+
async function runMapTargeting(gateway, design, workspaceRoot, scope, requiredTests, deniedPaths, testDiscovery, outOfScope, options, partsCheck, storedProposals = false) {
|
|
52440
54106
|
const findings = prepareTargetingFindings(options.findings, new Set(scope.readListing), deniedPaths);
|
|
52441
|
-
const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck);
|
|
54107
|
+
const baseContext = buildMapContextData(scope.repoMap, design, requiredTests, deniedPaths, testDiscovery, outOfScope, findings, partsCheck, storedProposals);
|
|
52442
54108
|
const repoView = repoViewOf(scope);
|
|
52443
54109
|
const log = options.loopDeps?.log ?? ((e) => console.log(JSON.stringify(e)));
|
|
52444
54110
|
let reason;
|
|
@@ -52466,7 +54132,7 @@ var MAX_ADDED_PATHS = 20;
|
|
|
52466
54132
|
var MAX_SKIPPED_CONTEXT = 20;
|
|
52467
54133
|
var MAX_SKIPPED_CASES = 200;
|
|
52468
54134
|
var MAX_CONTEXT_RECORDS = 25;
|
|
52469
|
-
var
|
|
54135
|
+
var MAX_PATH_CHARS5 = 300;
|
|
52470
54136
|
var MAX_ID_CHARS3 = 100;
|
|
52471
54137
|
var MAX_REASON_CHARS3 = 300;
|
|
52472
54138
|
var MAX_LOOP_READS = 50;
|
|
@@ -52497,7 +54163,7 @@ function clampLoop(loop) {
|
|
|
52497
54163
|
break;
|
|
52498
54164
|
}
|
|
52499
54165
|
const path = typeof r.path === "string" ? r.path.trim() : "";
|
|
52500
|
-
if (path.length === 0 || path.length >
|
|
54166
|
+
if (path.length === 0 || path.length > MAX_PATH_CHARS5) {
|
|
52501
54167
|
cut = true;
|
|
52502
54168
|
continue;
|
|
52503
54169
|
}
|
|
@@ -52551,11 +54217,11 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
52551
54217
|
break;
|
|
52552
54218
|
}
|
|
52553
54219
|
const path = typeof t.path === "string" ? t.path.trim() : "";
|
|
52554
|
-
if (path.length === 0 || path.length >
|
|
54220
|
+
if (path.length === 0 || path.length > MAX_PATH_CHARS5) {
|
|
52555
54221
|
truncated = true;
|
|
52556
54222
|
continue;
|
|
52557
54223
|
}
|
|
52558
|
-
const contextPaths = clampList(t.contextPaths, MAX_CONTEXT_PATHS,
|
|
54224
|
+
const contextPaths = clampList(t.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS5);
|
|
52559
54225
|
const automationIds = clampList(t.automationIds, MAX_IDS_PER_TARGET, MAX_ID_CHARS3);
|
|
52560
54226
|
note(contextPaths.cut);
|
|
52561
54227
|
note(automationIds.cut);
|
|
@@ -52574,16 +54240,16 @@ function buildTargetingRecord(targeting, contextLog) {
|
|
|
52574
54240
|
break;
|
|
52575
54241
|
}
|
|
52576
54242
|
const targetPath = typeof entry.targetPath === "string" ? entry.targetPath.trim() : "";
|
|
52577
|
-
if (targetPath.length === 0 || targetPath.length >
|
|
54243
|
+
if (targetPath.length === 0 || targetPath.length > MAX_PATH_CHARS5) {
|
|
52578
54244
|
truncated = true;
|
|
52579
54245
|
continue;
|
|
52580
54246
|
}
|
|
52581
|
-
const contextPaths = clampList(entry.contextPaths, MAX_CONTEXT_PATHS,
|
|
52582
|
-
const addedPaths = clampList(entry.addedPaths, MAX_ADDED_PATHS,
|
|
54247
|
+
const contextPaths = clampList(entry.contextPaths, MAX_CONTEXT_PATHS, MAX_PATH_CHARS5);
|
|
54248
|
+
const addedPaths = clampList(entry.addedPaths, MAX_ADDED_PATHS, MAX_PATH_CHARS5);
|
|
52583
54249
|
const skippedPaths = clampList(
|
|
52584
54250
|
(entry.skipped ?? []).map((s) => s.path),
|
|
52585
54251
|
MAX_SKIPPED_CONTEXT,
|
|
52586
|
-
|
|
54252
|
+
MAX_PATH_CHARS5
|
|
52587
54253
|
);
|
|
52588
54254
|
note(contextPaths.cut);
|
|
52589
54255
|
note(addedPaths.cut);
|
|
@@ -52666,6 +54332,7 @@ async function run2(env2) {
|
|
|
52666
54332
|
let conflictStop;
|
|
52667
54333
|
let testConflicts;
|
|
52668
54334
|
let approvedApplied;
|
|
54335
|
+
let databaseChange;
|
|
52669
54336
|
const contextLog = [];
|
|
52670
54337
|
const codegenOut = {};
|
|
52671
54338
|
let pendingBaseline;
|
|
@@ -52719,6 +54386,7 @@ async function run2(env2) {
|
|
|
52719
54386
|
const partsOn = partsCheckOn();
|
|
52720
54387
|
const designParts = partsOn ? partsFromDesign(packet.design) : [];
|
|
52721
54388
|
if (partsOn) console.log(JSON.stringify({ event: "parts_check.on", parts: designParts.length }));
|
|
54389
|
+
const featureSwitch = featureTestUpdatesOn();
|
|
52722
54390
|
const setupStartedAt = Date.now();
|
|
52723
54391
|
runCommand(packet.commands.setup, "Setup");
|
|
52724
54392
|
if (packet.commands.setup) console.log(JSON.stringify({ event: "timing", phase: "setup", seconds: Math.round((Date.now() - setupStartedAt) / 1e3) }));
|
|
@@ -52768,7 +54436,9 @@ async function run2(env2) {
|
|
|
52768
54436
|
scope,
|
|
52769
54437
|
...tools2 ? { tools2 } : {},
|
|
52770
54438
|
mode: resolveTargetingMode(process.env, packet.targetingMode),
|
|
52771
|
-
...designParts.length > 0 ? { partsCheck: true } : {}
|
|
54439
|
+
...designParts.length > 0 ? { partsCheck: true } : {},
|
|
54440
|
+
// QUIKTR-2445 - and `storedProposals` only when one of those parts is a stored value.
|
|
54441
|
+
...designParts.some((p) => p.kind === "stored") ? { storedProposals: true } : {}
|
|
52772
54442
|
}
|
|
52773
54443
|
);
|
|
52774
54444
|
targetingResult = targeting;
|
|
@@ -52801,9 +54471,9 @@ async function run2(env2) {
|
|
|
52801
54471
|
console.warn(`QuikPilot targeting warning (not blocking): ${w}`);
|
|
52802
54472
|
}
|
|
52803
54473
|
}
|
|
52804
|
-
const
|
|
52805
|
-
const blockingOverlaps =
|
|
52806
|
-
const softOverlaps =
|
|
54474
|
+
const overlaps2 = findOverlappingSteps(targeting.targets);
|
|
54475
|
+
const blockingOverlaps = overlaps2.filter((o) => o.severity === "identical");
|
|
54476
|
+
const softOverlaps = overlaps2.filter((o) => o.severity === "similar");
|
|
52807
54477
|
if (softOverlaps.length > 0) {
|
|
52808
54478
|
const overlapWarnings = describeOverlapWarnings(softOverlaps);
|
|
52809
54479
|
warnings.push(...overlapWarnings);
|
|
@@ -52816,20 +54486,25 @@ async function run2(env2) {
|
|
|
52816
54486
|
`QuikPilot's generated plan gives two files identical instructions \u2014 ${describeOverlapWarnings(blockingOverlaps).join("; ")}`
|
|
52817
54487
|
);
|
|
52818
54488
|
}
|
|
54489
|
+
const codegenMode = mapMode ? "loop-tests" : resolveCodegenMode(process.env, packet.codegenMode);
|
|
54490
|
+
const noteTaken = workspaceListing.includes(DATABASE_CHANGE_PATH) || scope.readListing.includes(DATABASE_CHANGE_PATH) || (0, import_node_fs27.existsSync)(DATABASE_CHANGE_PATH);
|
|
54491
|
+
const proposals = designParts.length > 0 && codegenMode === "loop-tests" && !noteTaken;
|
|
54492
|
+
if (designParts.some((p) => p.kind === "stored") && codegenMode === "loop-tests" && noteTaken) console.log(JSON.stringify({ event: "database_change.off", reason: "note_path_taken" }));
|
|
52819
54493
|
if (designParts.length > 0) {
|
|
52820
54494
|
const exists = existsMarked(designParts, targeting.targets);
|
|
52821
|
-
if (exists.existing.length > 0 || exists.ignored.length > 0) {
|
|
54495
|
+
if (exists.existing.length > 0 || exists.ignored.length > 0 || exists.proposed.length > 0) {
|
|
52822
54496
|
console.log(
|
|
52823
54497
|
JSON.stringify({
|
|
52824
54498
|
event: "parts_check.after_targeting",
|
|
52825
54499
|
existing: exists.existing.length,
|
|
52826
54500
|
ids: exists.existing,
|
|
52827
|
-
...exists.ignored.length > 0 ? { ignored: exists.ignored } : {}
|
|
54501
|
+
...exists.ignored.length > 0 ? { ignored: exists.ignored } : {},
|
|
54502
|
+
...exists.proposed.length > 0 ? { proposed: exists.proposed, proposals } : {}
|
|
52828
54503
|
})
|
|
52829
54504
|
);
|
|
52830
54505
|
}
|
|
52831
54506
|
}
|
|
52832
|
-
const partsStop = afterTargeting(designParts, targeting.targets);
|
|
54507
|
+
const partsStop = afterTargeting(designParts, targeting.targets, proposals ? { proposals: true } : {});
|
|
52833
54508
|
if (partsStop) {
|
|
52834
54509
|
console.log(JSON.stringify({ event: "parts_check.stop", reason: partsStop.reason, ids: partsStop.ids }));
|
|
52835
54510
|
throw new PartsStopError(partsStop);
|
|
@@ -52839,7 +54514,6 @@ async function run2(env2) {
|
|
|
52839
54514
|
targeting.targets,
|
|
52840
54515
|
targeting.skippedCases ?? []
|
|
52841
54516
|
);
|
|
52842
|
-
const codegenMode = mapMode ? "loop-tests" : resolveCodegenMode(process.env, packet.codegenMode);
|
|
52843
54517
|
const keepOnGiveUp = codegenMode === "loop-tests" && packet.guardrails.maxHealIterations > 0 && process.env.QUIKPILOT_KEEP_ON_GIVE_UP?.trim().toLowerCase() !== "off";
|
|
52844
54518
|
const callFunctionAllowed = callFunctionEnabled(env2.githubRepository, codegenMode);
|
|
52845
54519
|
const callFunctionFits = callFunctionFitsTargets(targeting.targets, discoveredTestsOf(codegenDiscovery));
|
|
@@ -52854,7 +54528,9 @@ async function run2(env2) {
|
|
|
52854
54528
|
const twoPhase = twoPhaseWanted && twoPhaseSkip === null;
|
|
52855
54529
|
const redReview = twoPhase && redReviewOn();
|
|
52856
54530
|
if (redReview) console.log(JSON.stringify({ event: "red_review.on" }));
|
|
52857
|
-
const codeParts = twoPhase && designParts.length > 0 ? partsForCode(designParts, targeting.targets) : [];
|
|
54531
|
+
const codeParts = twoPhase && designParts.length > 0 ? partsForCode(designParts, targeting.targets, proposals ? { proposals: true } : {}) : [];
|
|
54532
|
+
const dbParts = proposals ? databaseParts(designParts, partsForCode(designParts, targeting.targets, { proposals: true })) : [];
|
|
54533
|
+
if (dbParts.length > 0) console.log(JSON.stringify({ event: "database_change.on", parts: dbParts.length, ids: dbParts.map((p) => p.id), proposed: dbParts.filter((p) => p.database === "proposed").length }));
|
|
52858
54534
|
if (designParts.length > 0 && !twoPhase) console.log(JSON.stringify({ event: "parts_check.done_check_off", reason: "one_phase" }));
|
|
52859
54535
|
if (twoPhaseWanted && twoPhaseSkip !== null) {
|
|
52860
54536
|
warnings.push(TWO_PHASE_SKIPPED_NOTE);
|
|
@@ -52863,6 +54539,9 @@ async function run2(env2) {
|
|
|
52863
54539
|
const flow = packet.testConflicts ?? null;
|
|
52864
54540
|
const conflictsOn = flow !== null && flow.reporting !== false && codegenMode === "loop-tests" && notesEnabled();
|
|
52865
54541
|
if (flow !== null && flow.reporting !== false && !conflictsOn) console.log(JSON.stringify({ event: "conflicts.off", reason: codegenMode === "loop-tests" ? "notes_off" : "no_tests" }));
|
|
54542
|
+
const featureKind = isFeatureKind(packet.requestKind);
|
|
54543
|
+
const featureUpdates = featureSwitch && conflictsOn && featureKind;
|
|
54544
|
+
if (featureSwitch) console.log(JSON.stringify({ event: "feature_test_updates.on", inEffect: featureUpdates, feature: featureKind, conflicts: conflictsOn }));
|
|
52866
54545
|
const codegenTools2 = tools2 ?? (conflictsOn ? buildToolsV2Env({ scope, readText: readCheckoutText2, notes: true }) : void 0);
|
|
52867
54546
|
let approved = null;
|
|
52868
54547
|
if (flow !== null && (flow.changes?.length ?? 0) > 0) {
|
|
@@ -52882,12 +54561,15 @@ async function run2(env2) {
|
|
|
52882
54561
|
...conflictsOn ? { conflicts: { decided, titles: approved?.titles ?? [], approvedTests: approved?.approvedTests ?? [] } } : {},
|
|
52883
54562
|
// QUIKTR-1851: write the fix first, then ask once; the project switched it on, and `QUIKPILOT_FIX_FIRST=off` turns it off without a rebuild.
|
|
52884
54563
|
...conflictsOn && packet.fixFirst === true && process.env.QUIKPILOT_FIX_FIRST?.trim().toLowerCase() !== "off" ? { fixFirst: true } : {},
|
|
54564
|
+
// QUIKTR-2442: a feature run may propose add-only set-up for an existing test its change breaks.
|
|
54565
|
+
...featureUpdates ? { featureTestUpdates: true } : {},
|
|
52885
54566
|
...approved && approved.files.length > 0 ? { approved: approved.files } : {},
|
|
52886
54567
|
...callFunction ? { callFunction } : {},
|
|
52887
54568
|
...runScratch ? { runScratch } : {},
|
|
52888
54569
|
...twoPhase ? { twoPhase: true, ...packet.requiredTestTypes ? { requiredTestTypes: packet.requiredTestTypes } : {} } : {},
|
|
52889
54570
|
...redReview ? { redReview: true } : {},
|
|
52890
54571
|
...codeParts.length > 0 ? { parts: codeParts } : {},
|
|
54572
|
+
...dbParts.length > 0 ? { databaseChange: dbParts } : {},
|
|
52891
54573
|
tests: {
|
|
52892
54574
|
root: process.cwd(),
|
|
52893
54575
|
command: packet.commands.test,
|
|
@@ -52990,9 +54672,9 @@ async function run2(env2) {
|
|
|
52990
54672
|
});
|
|
52991
54673
|
};
|
|
52992
54674
|
const reviewOn = process.env.QUIKPILOT_REVIEW_FIX?.trim().toLowerCase() !== "off";
|
|
52993
|
-
let
|
|
54675
|
+
let fixed2;
|
|
52994
54676
|
try {
|
|
52995
|
-
|
|
54677
|
+
fixed2 = await runVerifyAndFix({
|
|
52996
54678
|
firstResults: results,
|
|
52997
54679
|
attemptsRun: codegenOut.loop?.attempts?.length ?? 1,
|
|
52998
54680
|
mode: codegenMode,
|
|
@@ -53036,30 +54718,55 @@ async function run2(env2) {
|
|
|
53036
54718
|
if (healStop && codegenOut.loop) codegenOut.loop = mergeHealRecord(codegenOut.loop, { stop: healStop, allowed: 0, made: healCalls.length, attempts: [] }, healCalls);
|
|
53037
54719
|
throw err2;
|
|
53038
54720
|
}
|
|
53039
|
-
generatedResults =
|
|
53040
|
-
const final =
|
|
54721
|
+
generatedResults = fixed2.results;
|
|
54722
|
+
const final = fixed2.outcome;
|
|
53041
54723
|
warnings.push(...final.warnings);
|
|
53042
54724
|
baselineFindings = final.outputs.baselineFindings;
|
|
53043
54725
|
unsuppliedInputs = final.outputs.unsuppliedInputs;
|
|
53044
54726
|
generatedFilePaths = final.outputs.generatedFilePaths;
|
|
53045
54727
|
finalTestReport = final.outputs.finalTestReport;
|
|
53046
54728
|
vanishedTests = final.outputs.vanishedTests;
|
|
53047
|
-
if (
|
|
54729
|
+
if (fixed2.heal && codegenMode === "loop-tests") codegenOut.loop = mergeHealRecord(codegenOut.loop, fixed2.heal, healCalls);
|
|
53048
54730
|
if (!final.ok) {
|
|
53049
|
-
const suffix = healFailureSuffix(
|
|
54731
|
+
const suffix = healFailureSuffix(fixed2.heal);
|
|
53050
54732
|
throw suffix ? new Error(`${final.error.message}${suffix}`) : final.error;
|
|
53051
54733
|
}
|
|
53052
54734
|
if (designParts.length > 0) {
|
|
53053
|
-
const finalParts = partsForCode(designParts, targeting.targets);
|
|
54735
|
+
const finalParts = partsForCode(designParts, targeting.targets, proposals ? { proposals: true } : {});
|
|
53054
54736
|
const changed = changesAgainstBase(process.cwd(), new Set(finalParts.flatMap((p) => p.paths)));
|
|
53055
|
-
const
|
|
54737
|
+
const proposalIds = dbParts.length > 0 ? codegenOut.databaseChange?.parts ?? [] : void 0;
|
|
54738
|
+
const missing = missingAtDone(finalParts, changed, testRule(discoveredTestsOf(codegenDiscovery)), proposalIds);
|
|
53056
54739
|
const ids = missing.map((m) => m.part.id);
|
|
53057
54740
|
console.log(JSON.stringify({ event: "parts_check.final", outcome: missing.length > 0 ? "missing" : "ok", missing: missing.length, ids }));
|
|
53058
|
-
if (missing.length > 0) throw new PartsStopError({ reason: "part_missing", ids, sentence: partMissingSentence(missing) });
|
|
54741
|
+
if (missing.length > 0) throw new PartsStopError({ reason: "part_missing", ids, sentence: partMissingSentence(missing, { lastGate: true }) });
|
|
54742
|
+
}
|
|
54743
|
+
if (dbParts.length > 0 && codegenOut.databaseChange) {
|
|
54744
|
+
const proposal = codegenOut.databaseChange;
|
|
54745
|
+
const files = new Set([proposal.schemaFile, proposal.migrationFile].filter((f) => f !== ""));
|
|
54746
|
+
databaseChange = finalDatabaseChange(proposal, {
|
|
54747
|
+
changedFiles: changesAgainstBase(process.cwd(), files),
|
|
54748
|
+
writeRoot,
|
|
54749
|
+
deniedPaths: packet.guardrails.deniedPaths,
|
|
54750
|
+
readPaths: scope.readListing,
|
|
54751
|
+
scrub: makeCodeScrubber([runToken, packet.gateway.token].filter((s) => typeof s === "string" && s.length > 0)),
|
|
54752
|
+
parts: designParts
|
|
54753
|
+
});
|
|
54754
|
+
console.log(
|
|
54755
|
+
JSON.stringify({
|
|
54756
|
+
event: "database_change.final",
|
|
54757
|
+
parts: databaseChange.parts.length,
|
|
54758
|
+
additive: databaseChange.additive,
|
|
54759
|
+
declaredAdditive: databaseChange.declaredAdditive,
|
|
54760
|
+
flagged: databaseChange.flagged,
|
|
54761
|
+
schemaFileIncluded: databaseChange.schemaFileIncluded,
|
|
54762
|
+
migrationFileIncluded: databaseChange.migrationFileIncluded,
|
|
54763
|
+
schemaFileSeen: databaseChange.schemaFileSeen
|
|
54764
|
+
})
|
|
54765
|
+
);
|
|
53059
54766
|
}
|
|
53060
|
-
if (codegenMode === "loop-tests" &&
|
|
54767
|
+
if (codegenMode === "loop-tests" && fixed2.heal && fixed2.heal.made > 0 && process.env.QUIKPILOT_TESTS_CORRECTED?.trim().toLowerCase() !== "off") {
|
|
53061
54768
|
try {
|
|
53062
|
-
const files = correctedOwnTests({ kept: results, final:
|
|
54769
|
+
const files = correctedOwnTests({ kept: results, final: fixed2.results, baselineOf: (path) => readCommittedText(process.cwd(), path) });
|
|
53063
54770
|
console.log(JSON.stringify({ event: "tests_corrected", files: files.length, tests: files.reduce((n, f) => n + f.lines.length, 0) }));
|
|
53064
54771
|
if (files.length > 0) testsCorrected = { files };
|
|
53065
54772
|
} catch {
|
|
@@ -53067,8 +54774,8 @@ async function run2(env2) {
|
|
|
53067
54774
|
}
|
|
53068
54775
|
if (codegenMode === "loop-tests" && process.env.QUIKPILOT_HUNK_CHECK?.trim().toLowerCase() !== "off") {
|
|
53069
54776
|
try {
|
|
53070
|
-
const reused =
|
|
53071
|
-
const checked = reused ?? await hunkCheckOver(
|
|
54777
|
+
const reused = fixed2.review && fixed2.review.results === fixed2.results ? fixed2.review.raw : void 0;
|
|
54778
|
+
const checked = reused ?? await hunkCheckOver(fixed2.results, final.outputs.testCount ?? 0);
|
|
53072
54779
|
if (checked) {
|
|
53073
54780
|
if (!reused) console.log(JSON.stringify({ event: "hunk_check", checked: checked.checked, total: checked.total, flagged: checked.unnecessary.length, skipped: checked.skipped, stopped: checked.stopped ?? null, relatedRuns: checked.relatedRuns, wholeRuns: checked.wholeRuns }));
|
|
53074
54781
|
changesNoTestDependsOn = toFinding(checked);
|
|
@@ -53192,7 +54899,9 @@ async function run2(env2) {
|
|
|
53192
54899
|
aiCostUsd: spendSoFar().costUsd,
|
|
53193
54900
|
...testConflicts && !hardFailure ? { testConflicts } : {},
|
|
53194
54901
|
// Only for a run that is going to a pull request: a stop or a failure delivers none, so nothing is claimed as applied.
|
|
53195
|
-
...approvedApplied && !hardFailure && !conflictStop ? { approvedTestsApplied: approvedApplied } : {}
|
|
54902
|
+
...approvedApplied && !hardFailure && !conflictStop ? { approvedTestsApplied: approvedApplied } : {},
|
|
54903
|
+
// QUIKTR-2445: only for a completed run that pushed its branch: QuikProjects opens that pull request as a draft with the change at its top.
|
|
54904
|
+
...databaseChange && !hardFailure && !conflictStop && branch ? { databaseChange } : {}
|
|
53196
54905
|
});
|
|
53197
54906
|
return { hardFailure };
|
|
53198
54907
|
}
|
|
@@ -53290,7 +54999,7 @@ var EvidenceLedger = class {
|
|
|
53290
54999
|
return seen;
|
|
53291
55000
|
}
|
|
53292
55001
|
};
|
|
53293
|
-
function
|
|
55002
|
+
function isRecord6(x) {
|
|
53294
55003
|
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
53295
55004
|
}
|
|
53296
55005
|
function arrayOf(x) {
|
|
@@ -53328,7 +55037,7 @@ function capFindingsSize(findings, max = MAX_FINDINGS_CHARS) {
|
|
|
53328
55037
|
function verifyFindings(raw, ledger, ctx) {
|
|
53329
55038
|
const dropped = emptyDropped();
|
|
53330
55039
|
const redactions = emptyRedactionCounts();
|
|
53331
|
-
if (!
|
|
55040
|
+
if (!isRecord6(raw)) return { findings: emptyFindings(), downgraded: false, dropped, redactions };
|
|
53332
55041
|
const pathOk2 = (p) => typeof p === "string" && ctx.listing.has(p) && matchesDeniedPath(p, ctx.deniedPaths) === null;
|
|
53333
55042
|
const symbolsOf = (path, list2) => {
|
|
53334
55043
|
const out2 = [];
|
|
@@ -53343,7 +55052,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
53343
55052
|
};
|
|
53344
55053
|
const files = [];
|
|
53345
55054
|
for (const f of arrayOf(raw.files)) {
|
|
53346
|
-
if (!
|
|
55055
|
+
if (!isRecord6(f) || !pathOk2(f.path)) {
|
|
53347
55056
|
dropped.files += 1;
|
|
53348
55057
|
continue;
|
|
53349
55058
|
}
|
|
@@ -53353,7 +55062,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
53353
55062
|
}
|
|
53354
55063
|
const callPath = [];
|
|
53355
55064
|
for (const s of arrayOf(raw.callPath)) {
|
|
53356
|
-
const ok =
|
|
55065
|
+
const ok = isRecord6(s) && pathOk2(s.path) && typeof s.symbol === "string" && s.symbol.length > 0 && s.symbol.length <= MAX_SYMBOL_CHARS && isLine2(s.line) && ledger.hasLines(s.path, s.line, s.line) && ledger.textContains(s.path, s.symbol);
|
|
53357
55066
|
if (!ok) {
|
|
53358
55067
|
dropped.callPath += 1;
|
|
53359
55068
|
continue;
|
|
@@ -53362,7 +55071,7 @@ function verifyFindings(raw, ledger, ctx) {
|
|
|
53362
55071
|
}
|
|
53363
55072
|
const evidence = [];
|
|
53364
55073
|
for (const e of arrayOf(raw.evidence)) {
|
|
53365
|
-
const ok =
|
|
55074
|
+
const ok = isRecord6(e) && pathOk2(e.path) && isLine2(e.startLine) && isLine2(e.endLine) && e.startLine <= e.endLine && e.endLine - e.startLine + 1 <= MAX_EVIDENCE_LINES && ledger.hasLines(e.path, e.startLine, e.endLine);
|
|
53366
55075
|
if (!ok) {
|
|
53367
55076
|
dropped.evidence += 1;
|
|
53368
55077
|
continue;
|