@quikit/quikpilot-runner 9.3.0-rc.2 → 9.3.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1201,6 +1201,7 @@ function toLf(text) {
1201
1201
  function fromLf(text, ending) {
1202
1202
  return ending === "CRLF" ? text.replace(/\n/g, "\r\n") : text;
1203
1203
  }
1204
+ var MAX_MATCH_STARTS = 5;
1204
1205
  function occurrences(haystack, needle) {
1205
1206
  const found = [];
1206
1207
  let index = haystack.indexOf(needle);
@@ -1246,6 +1247,7 @@ function applyEdits(originalLf, edits) {
1246
1247
  kind: "ambiguous",
1247
1248
  edits: [number],
1248
1249
  matchCount: starts.length,
1250
+ matchStarts: starts.slice(0, MAX_MATCH_STARTS),
1249
1251
  message: `edit ${number}: the anchor matched ${starts.length} times`
1250
1252
  });
1251
1253
  } else {
@@ -2421,6 +2423,40 @@ function collectLoopContext(p) {
2421
2423
  return { entries, testPaths, records };
2422
2424
  }
2423
2425
 
2426
+ // src/anchorPlaces.ts
2427
+ var MAX_NAMED = 4;
2428
+ var QUOTE_WIDTH = 50;
2429
+ var TAIL = "Make `find` longer by adding the line before or after the place you mean, so it matches exactly once.";
2430
+ function lineNumberAt(text, index) {
2431
+ let line = 1;
2432
+ for (let at2 = text.indexOf("\n"); at2 !== -1 && at2 < index; at2 = text.indexOf("\n", at2 + 1)) line += 1;
2433
+ return line;
2434
+ }
2435
+ function previousTextLine(text, index) {
2436
+ let end = (index === 0 ? 0 : text.lastIndexOf("\n", index - 1) + 1) - 1;
2437
+ while (end >= 0) {
2438
+ const start = end === 0 ? 0 : text.lastIndexOf("\n", end - 1) + 1;
2439
+ const line = text.slice(start, end);
2440
+ if (line.trim() !== "") return line;
2441
+ end = start - 1;
2442
+ }
2443
+ return null;
2444
+ }
2445
+ function quoted(line, width) {
2446
+ return line.replace(/`/g, "").trim().slice(0, width).trimEnd();
2447
+ }
2448
+ function ambiguousPlacesMessage(lf, starts, total) {
2449
+ const named = starts.slice(0, MAX_NAMED);
2450
+ if (named.length === 0) return `That text matches ${total} places. ${TAIL}`;
2451
+ const header = total <= MAX_NAMED ? `That text matches ${total} places: ` : `That text matches ${total} places; the first four are `;
2452
+ const places = named.map((start) => ({ line: lineNumberAt(lf, start), before: previousTextLine(lf, start) }));
2453
+ const parts = places.map((p) => {
2454
+ const q = p.before !== null ? quoted(p.before, QUOTE_WIDTH) : "";
2455
+ return q === "" ? `line ${p.line}` : `line ${p.line} (after \`${q}\`)`;
2456
+ });
2457
+ return `${header}${parts.join(", ")}. ${TAIL}`;
2458
+ }
2459
+
2424
2460
  // src/addOnly.ts
2425
2461
  var JS_FAMILY = /\.(?:[cm]?[jt]sx?)$/i;
2426
2462
  var DECLARES_TEST = /^[ \t]*(?:it|test|describe)\b/m;
@@ -11289,8 +11325,7 @@ function createCodegenWorkspace(args) {
11289
11325
  return { result: { status: "no_match", message: "That text was not found in the file. Read it again and copy it exactly." } };
11290
11326
  }
11291
11327
  if (refusal?.kind === "ambiguous") {
11292
- const n = refusal.matchCount ?? 0;
11293
- return { result: { status: "ambiguous", message: `That text matches ${n} places. Include more surrounding text so it matches exactly once.` } };
11328
+ return { result: { status: "ambiguous", message: ambiguousPlacesMessage(lf, refusal.matchStarts ?? [], refusal.matchCount ?? 0) } };
11294
11329
  }
11295
11330
  return { result: { status: "bad_args", message: "That edit could not be applied." } };
11296
11331
  }
@@ -13149,8 +13184,8 @@ function shellQuote(value) {
13149
13184
  return `'${value.split("'").join("'\\''")}'`;
13150
13185
  }
13151
13186
  function buildSingleFileCommand(command, path) {
13152
- const quoted = shellQuote(path);
13153
- return command.includes("{file}") ? command.split("{file}").join(quoted) : `${command} ${quoted}`;
13187
+ const quoted2 = shellQuote(path);
13188
+ return command.includes("{file}") ? command.split("{file}").join(quoted2) : `${command} ${quoted2}`;
13154
13189
  }
13155
13190
  var isTestTarget2 = (t) => (t.automationIds?.length ?? 0) > 0;
13156
13191
  function checkableIds(ids, types2) {
@@ -13328,7 +13363,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
13328
13363
  var REPORT_COPY = "final-test-report.xml";
13329
13364
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
13330
13365
  var MAX_FILES = 200;
13331
- var RUNNER_VERSION = true ? "9.3.0-rc.2" : "dev";
13366
+ var RUNNER_VERSION = true ? "9.3.0-rc.3" : "dev";
13332
13367
  function safeDestination(base, repoPath) {
13333
13368
  if (!repoPath || (0, import_node_path12.isAbsolute)(repoPath)) return null;
13334
13369
  const destination = (0, import_node_path12.resolve)(base, repoPath);