@quikit/quikpilot-runner 9.3.0-rc.97 → 9.3.0-rc.99

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 CHANGED
@@ -194,6 +194,16 @@ wrong (a field that arrives from a database row or a request), so it only warns
194
194
 
195
195
  **9.3.0-rc.81 (also) - pytest and go test reports place their tests on files (QUIKTR-2465 item 3).** The Python and Go trial repositories' reports placed no test on a file, so the test-file list was empty and the AI Runtime's early check was off. pytest tests are placed by the longest dotted prefix that is a `.py` file of the listing; Go tests by go.mod's module and the one `_test.go` file of the package's folder that declares the function. Real reports: sqlparse 454 tests on 9 files, decimal 145 tests on 3 files, 0 unmapped each. A report that places none of its tests says so in the run's notes. JavaScript reports are unchanged.
196
196
 
197
+ **9.3.0-rc.99 - the running AI cost reaches QuikProjects while the job runs (QUIKTR-2834).** The run page's Spend stayed at $0.00 until the final report, because the job's AI cost was sent only then, and a job that died without that report kept $0.00 for good.
198
+ - **What is sent.** When the packet carries `progressUrl`, the job POSTs `{ aiCostUsd }` (its running total, `spendSoFar()`) to it every 10 s, only when the figure changed. QuikProjects writes the figure only (no status move, no event) and only upward, while the run is still working. The final report still sends the final total.
199
+ - **What it never does.** One short try per report (8 s); a failure is never thrown and the next tick tries again. 401/403/404/410 stop the reports for good (an older QuikProjects without the route, or a run it no longer accepts). The reports stop before the final report and before the last-resort one, and the timer never keeps the job alive. The run token is sent in the header only and never logged.
200
+ - **Older QuikProjects.** No `progressUrl` in the packet: nothing is reported, exactly as before.
201
+
202
+ **9.3.0-rc.98 - the tests the run wrote reach the pull request even when the repository ignores test files (QUIKTR-2851).** A repository that lists its test files in .gitignore (`*.test.ts`; QuikProjects' own repository does) got pull requests without the tests QuikPilot wrote and ran: the change was staged with `git add -A`, which skips ignored files, and nothing said so.
203
+ - **What is committed now.** The files the run itself created (through its one write of the change to disk) are staged with `git add -f`, inside the run's folder when it has one. A file created by an attempt that was undone is gone from disk, so it is not staged.
204
+ - **What is still left out.** Every other ignored file: a build output, a file a command wrote, and a file that was there before the run, even if the AI edited it. The denied paths are checked on everything staged, as before.
205
+ - **The final-change listing** (the parts check and the database-change check) counts the created files too, so both see what the pull request holds.
206
+
197
207
  **9.3.0-rc.97 - the early look can say the reported behaviour already works (QUIKTR-2821).** On UAT (17 Nov) the look read an already-fixed bug's fix and had no word for it: the model answered NOT_PRESENT, its searches had found code, and the runner turned that into CANNOT_TELL, so the run went through both gates and a build first.
198
208
  - **The new verdict.** The look now speaks the AI Runtime's `investigate-loop-2`, which adds a fifth verdict, **ALREADY_WORKS**: the code the report points at exists and already behaves as the report says it should. It stands only on a citation the runner checked (the rule PRESENT has), otherwise CANNOT_TELL, and a trimmed record keeps a citation for it.
199
209
  - **Older AI Runtimes.** An AI Runtime that predates loop-2 refuses it on the first turn: that turn is asked once more on `investigate-loop-1` (`investigate.version_fallback`) and the look carries on there. A switched-off look and any later refusal end the look as before. The fixed part of a loop-2 request is 7,000 tokens (the AI Runtime's value).
package/dist/index.js CHANGED
@@ -29091,14 +29091,19 @@ function checkoutTargetBranch(targetBranch) {
29091
29091
  }
29092
29092
  var LIST_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
29093
29093
  var RUNNER_OWN_FOLDER = ".quikpilot";
29094
- function addAll(scope) {
29094
+ var FORCE_ADD_CHUNK = 200;
29095
+ function addAll(scope, created = []) {
29095
29096
  if (!scope) {
29096
29097
  git(["add", "-A"]);
29097
- return;
29098
- }
29099
- for (const path of [scope, RUNNER_OWN_FOLDER]) {
29100
- if ((0, import_node_fs.existsSync)(path)) git(["add", "-A", "--", path]);
29098
+ } else {
29099
+ for (const path of [scope, RUNNER_OWN_FOLDER]) {
29100
+ if ((0, import_node_fs.existsSync)(path)) git(["add", "-A", "--", path]);
29101
+ }
29101
29102
  }
29103
+ const prefix = scope ? scope.endsWith("/") ? scope : `${scope}/` : "";
29104
+ const inScope = scope ? created.filter((p) => p === scope || p.startsWith(prefix)) : [...created];
29105
+ const forced = inScope.filter((p) => (0, import_node_fs.existsSync)(p));
29106
+ for (let i3 = 0; i3 < forced.length; i3 += FORCE_ADD_CHUNK) git(["add", "-f", "--", ...forced.slice(i3, i3 + FORCE_ADD_CHUNK)]);
29102
29107
  }
29103
29108
  function changedOutside(scope) {
29104
29109
  const out2 = (0, import_node_child_process.execFileSync)("git", [...NO_HOOKS_ARGS, "status", "--porcelain", "-z", "--untracked-files=all", "--no-renames"], {
@@ -42022,6 +42027,23 @@ function safeRepoTarget(rel, root = process.cwd()) {
42022
42027
  }
42023
42028
  }
42024
42029
  }
42030
+ var createdByRun = /* @__PURE__ */ new Map();
42031
+ function filesCreatedByRun(root = process.cwd()) {
42032
+ let rootReal;
42033
+ try {
42034
+ rootReal = (0, import_node_fs10.realpathSync)(root);
42035
+ } catch {
42036
+ return [];
42037
+ }
42038
+ const isFile = (path) => {
42039
+ try {
42040
+ return (0, import_node_fs10.statSync)((0, import_node_path13.join)(rootReal, path)).isFile();
42041
+ } catch {
42042
+ return false;
42043
+ }
42044
+ };
42045
+ return [...createdByRun.get(rootReal) ?? []].filter(isFile).sort();
42046
+ }
42025
42047
  function writeRepoFile(rel, content, root = process.cwd()) {
42026
42048
  const path = canonicalPath(rel);
42027
42049
  if (path === null) throw new DiskWriteRefused("bad_path");
@@ -42049,13 +42071,20 @@ function writeRepoFile(rel, content, root = process.cwd()) {
42049
42071
  (0, import_node_fs10.mkdirSync)(d);
42050
42072
  if ((0, import_node_fs10.lstatSync)(d).isSymbolicLink()) throw new DiskWriteRefused("outside_checkout");
42051
42073
  }
42074
+ let created = false;
42052
42075
  try {
42053
42076
  const stat = (0, import_node_fs10.lstatSync)(abs);
42054
42077
  if (stat.isSymbolicLink() || !stat.isFile()) throw new DiskWriteRefused("not_a_file");
42055
42078
  } catch (err2) {
42056
42079
  if (err2 instanceof DiskWriteRefused) throw err2;
42080
+ created = true;
42057
42081
  }
42058
42082
  (0, import_node_fs10.writeFileSync)(abs, content);
42083
+ if (created) {
42084
+ const set2 = createdByRun.get(rootReal) ?? /* @__PURE__ */ new Set();
42085
+ set2.add(path);
42086
+ createdByRun.set(rootReal, set2);
42087
+ }
42059
42088
  }
42060
42089
 
42061
42090
  // src/baselineCheck.ts
@@ -54459,7 +54488,7 @@ async function verifyChange(ctx, results, undoable) {
54459
54488
  // src/guardrail.ts
54460
54489
  var MAX_LEFT_OUT_NAMES2 = 10;
54461
54490
  function checkGuardrail(deniedPaths, writeRoot = "") {
54462
- addAll(writeRoot || void 0);
54491
+ addAll(writeRoot || void 0, filesCreatedByRun());
54463
54492
  const deleted = stagedDeletions();
54464
54493
  unstage(deleted);
54465
54494
  const deletionsLeftOut = { count: deleted.length, names: deleted.filter((p) => matchesDeniedPath(p, readDenied(deniedPaths)) === null).slice(0, MAX_LEFT_OUT_NAMES2) };
@@ -55058,6 +55087,56 @@ function packetShapeProblem(data2) {
55058
55087
  return null;
55059
55088
  }
55060
55089
 
55090
+ // src/progressReport.ts
55091
+ var PROGRESS_INTERVAL_MS = 1e4;
55092
+ var PROGRESS_TIMEOUT_MS = 8e3;
55093
+ var STOP_FOR_GOOD = /* @__PURE__ */ new Set([401, 403, 404, 410]);
55094
+ function startProgressReports(opts) {
55095
+ const fetchImpl = opts.fetchImpl ?? fetch;
55096
+ let lastSaved = null;
55097
+ let stopped = false;
55098
+ let inFlight = false;
55099
+ let warned = false;
55100
+ const warnOnce = (why) => {
55101
+ if (warned) return;
55102
+ warned = true;
55103
+ console.warn(`::warning::QuikPilot could not report its running AI cost (${why}); the final report still sends it.`);
55104
+ };
55105
+ const tick = async () => {
55106
+ if (stopped || inFlight) return;
55107
+ const raw = opts.read();
55108
+ const cost = Math.round((Number.isFinite(raw) ? raw : 0) * 1e4) / 1e4;
55109
+ if (!(cost > 0) || cost === lastSaved) return;
55110
+ inFlight = true;
55111
+ try {
55112
+ const res = await fetchImpl(opts.progressUrl, {
55113
+ method: "POST",
55114
+ headers: { authorization: `Bearer ${opts.runToken}`, "content-type": "application/json" },
55115
+ body: JSON.stringify({ aiCostUsd: cost }),
55116
+ signal: AbortSignal.timeout(PROGRESS_TIMEOUT_MS)
55117
+ });
55118
+ if (STOP_FOR_GOOD.has(res.status)) {
55119
+ stop2();
55120
+ console.log(JSON.stringify({ event: "runner.progress_stopped", status: res.status }));
55121
+ return;
55122
+ }
55123
+ if (res.ok) lastSaved = cost;
55124
+ else warnOnce(`HTTP ${res.status}`);
55125
+ } catch (err2) {
55126
+ warnOnce(err2 instanceof Error ? err2.name : "network error");
55127
+ } finally {
55128
+ inFlight = false;
55129
+ }
55130
+ };
55131
+ const timer = setInterval(() => void tick(), opts.intervalMs ?? PROGRESS_INTERVAL_MS);
55132
+ timer.unref?.();
55133
+ function stop2() {
55134
+ stopped = true;
55135
+ clearInterval(timer);
55136
+ }
55137
+ return { stop: stop2 };
55138
+ }
55139
+
55061
55140
  // src/runnerSwitches.ts
55062
55141
  var RUNNER_SWITCHES = {
55063
55142
  // Opt-ins (named in QUIKPILOT_FEATURES on QuikProjects).
@@ -55120,7 +55199,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
55120
55199
  var REPORT_COPY = "final-test-report.xml";
55121
55200
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
55122
55201
  var MAX_FILES = 200;
55123
- var RUNNER_VERSION = true ? "9.3.0-rc.97" : "dev";
55202
+ var RUNNER_VERSION = true ? "9.3.0-rc.99" : "dev";
55124
55203
  function safeDestination(base, repoPath) {
55125
55204
  if (!repoPath || (0, import_node_path27.isAbsolute)(repoPath)) return null;
55126
55205
  const destination = (0, import_node_path27.resolve)(base, repoPath);
@@ -55212,9 +55291,10 @@ function statusPaths(root) {
55212
55291
  encoding: "utf8",
55213
55292
  maxBuffer: 64 * 1024 * 1024
55214
55293
  });
55215
- return new Set(
55216
- status.split("\0").filter((entry) => entry.length > 3).map((entry) => entry.slice(3))
55217
- );
55294
+ return /* @__PURE__ */ new Set([
55295
+ ...status.split("\0").filter((entry) => entry.length > 3).map((entry) => entry.slice(3)),
55296
+ ...filesCreatedByRun(root)
55297
+ ]);
55218
55298
  }
55219
55299
  var isFileOnDisk = (root, path) => {
55220
55300
  try {
@@ -56082,6 +56162,8 @@ async function runUnderGuard(env2, guard) {
56082
56162
  let packet;
56083
56163
  let branch;
56084
56164
  let runToken;
56165
+ let stopProgress = () => {
56166
+ };
56085
56167
  const warnings = [];
56086
56168
  let scopeRoot = "";
56087
56169
  let installationToken;
@@ -56151,6 +56233,7 @@ async function runUnderGuard(env2, guard) {
56151
56233
  };
56152
56234
  };
56153
56235
  const lastResort = async (reason) => {
56236
+ stopProgress();
56154
56237
  if (!runToken) return;
56155
56238
  const message = reason === "time_limit" && packet ? jobTimeLimitMessage(packet.guardrails.maxWallClockMinutes) : jobStoppedMessage();
56156
56239
  let body2;
@@ -56170,6 +56253,10 @@ async function runUnderGuard(env2, guard) {
56170
56253
  }
56171
56254
  jobStopAtMs = runStopAtMs(runStartedAt, packet.guardrails.maxWallClockMinutes);
56172
56255
  guard.arm({ stopAtMs: jobStopAtMs, watchdogAtMs: watchdogAtMs(jobStopAtMs), send: lastResort });
56256
+ if (typeof packet.progressUrl === "string" && packet.progressUrl.length > 0) {
56257
+ const reports = startProgressReports({ progressUrl: packet.progressUrl, runToken, read: () => spendSoFar().costUsd });
56258
+ stopProgress = () => reports.stop();
56259
+ }
56173
56260
  for (const [label, name2] of [["branch", packet.branch], ["target branch", packet.targetBranch]]) {
56174
56261
  const why = typeof name2 === "string" ? checkBranchName(name2) : null;
56175
56262
  if (why) throw new Error(`QuikProjects sent a ${label} name git cannot use safely (${why}), so QuikPilot did not start. Nothing was changed.`);
@@ -56805,6 +56892,7 @@ async function runUnderGuard(env2, guard) {
56805
56892
  console.warn(`::warning::Could not keep the failed run's files: ${err2 instanceof Error ? err2.message : String(err2)}`);
56806
56893
  }
56807
56894
  }
56895
+ stopProgress();
56808
56896
  if (!guard.claim()) return { hardFailure: true };
56809
56897
  await reportBack({ callbackUrl: env2.callbackUrl, runToken, ...finalReportBody(), secrets: secrets() });
56810
56898
  return { hardFailure };