spacecode 2.14.0 → 2.14.2
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/repl.mjs +16 -4
- package/package.json +1 -1
package/dist/repl.mjs
CHANGED
|
@@ -104845,6 +104845,10 @@ function agentFailure(run) {
|
|
|
104845
104845
|
const tail = (run.stderr.trim() || run.stdout.trim()).slice(-300).replace(/\s+/g, " ");
|
|
104846
104846
|
return clip(`agent exited ${run.exitCode}${tail ? `; last output: ${redactSecrets(tail)}` : "; no output"}`, 400);
|
|
104847
104847
|
}
|
|
104848
|
+
function noDigestReason(text) {
|
|
104849
|
+
const tail = (text ?? "").trim().slice(-300).replace(/\s+/g, " ");
|
|
104850
|
+
return clip(`agent finished without the digest${tail ? `; its last words: ${redactSecrets(tail)}` : " and said nothing"}`, 400);
|
|
104851
|
+
}
|
|
104848
104852
|
async function runWorkerJob(deps, job) {
|
|
104849
104853
|
const ids = { runId: job.runId, taskId: job.taskId, attempt: job.attempt };
|
|
104850
104854
|
try {
|
|
@@ -104897,7 +104901,7 @@ async function runWorkerJob(deps, job) {
|
|
|
104897
104901
|
const run = built ? { exitCode: 0, stdout: "", stderr: "" } : deps.runAgent ? await deps.runAgent(dir, prompt, agentSecs) : await deps.sandbox.exec(`timeout ${agentSecs} ${deps.agentCommand(dir, prompt)}`);
|
|
104898
104902
|
const result = parseWorkerResult(run.stdout);
|
|
104899
104903
|
if (await deps.cancelled()) return "cancelled";
|
|
104900
|
-
const rawPatch = await deps.sandbox.exec(`cd ${shq(dir)} && git add -N . && git diff ${base}`);
|
|
104904
|
+
const rawPatch = await deps.sandbox.exec(`cd ${shq(dir)} && git add -N . ${(deps.excludeFromDiff ?? []).map((g2) => shq(`:(exclude,glob)${g2}`)).join(" ")} && git diff ${base}`);
|
|
104901
104905
|
if (rawPatch.exitCode !== 0) throw new Error("git diff failed");
|
|
104902
104906
|
const patch = { ...rawPatch, stdout: rawPatch.stdout === "" || rawPatch.stdout.endsWith("\n") ? rawPatch.stdout : `${rawPatch.stdout}
|
|
104903
104907
|
` };
|
|
@@ -104921,7 +104925,12 @@ async function runWorkerJob(deps, job) {
|
|
|
104921
104925
|
const install = await deps.sandbox.exec(`cd ${shq(dir)} && [ -d node_modules ] || timeout ${slice()} npm install --no-audit --no-fund --silent`);
|
|
104922
104926
|
if (install.exitCode !== 0) deps.log("worker dependency install failed", { ...ids, exitCode: install.exitCode });
|
|
104923
104927
|
}
|
|
104924
|
-
for (const c of wanted)
|
|
104928
|
+
for (const c of wanted) {
|
|
104929
|
+
const r = await deps.sandbox.exec(`cd ${shq(dir)} && timeout ${slice()} ${c.cmd}`);
|
|
104930
|
+
checks[c.name] = r.exitCode;
|
|
104931
|
+
if (r.exitCode !== 0) deps.log("worker check failed", { ...ids, check: c.name, exitCode: r.exitCode, tail: redactSecrets(`${r.stdout}
|
|
104932
|
+
${r.stderr}`.trim().slice(-300).replace(/\s+/g, " ")) });
|
|
104933
|
+
}
|
|
104925
104934
|
}
|
|
104926
104935
|
}
|
|
104927
104936
|
if (await deps.cancelled()) return "cancelled";
|
|
@@ -104937,7 +104946,7 @@ async function runWorkerJob(deps, job) {
|
|
|
104937
104946
|
digest,
|
|
104938
104947
|
...patch.stdout !== "" && !tooBig ? { patch: patch.stdout } : {},
|
|
104939
104948
|
...tooBig ? { reason: "patch exceeds the size limit" } : {},
|
|
104940
|
-
...
|
|
104949
|
+
...digest === "" ? { reason: run.exitCode !== 0 ? agentFailure(run) : noDigestReason(result?.text) } : {},
|
|
104941
104950
|
verify: { checks, changedFiles, diffLines }
|
|
104942
104951
|
});
|
|
104943
104952
|
deps.log("worker reported", { ...ids, files: changedFiles.length, diffLines });
|
|
@@ -104986,7 +104995,9 @@ async function createTaskWorktree(shell, cwd2, runId, taskId, attempt) {
|
|
|
104986
104995
|
const top = await must(shell, `cd ${q2(cwd2)} && git rev-parse --show-toplevel`, "finding the repository root");
|
|
104987
104996
|
const gitDir = await must(shell, `cd ${q2(cwd2)} && git rev-parse --absolute-git-dir`, "finding the git directory");
|
|
104988
104997
|
const base = await must(shell, `cd ${q2(top)} && git stash create`, "snapshotting the working tree") || "HEAD";
|
|
104989
|
-
const
|
|
104998
|
+
const root = `${gitDir}/spacecode-core`;
|
|
104999
|
+
await shell(`find ${q2(root)} -mindepth 2 -maxdepth 2 -type d -name 'wt-*' -mmin +1440 2>/dev/null | while read -r w; do git -C ${q2(top)} worktree remove --force "$w" >/dev/null 2>&1; done; git -C ${q2(top)} worktree prune`);
|
|
105000
|
+
const dir = `${root}/${safe(runId)}/wt-${safe(taskId)}-${attempt}`;
|
|
104990
105001
|
await must(shell, `git -C ${q2(top)} worktree add --detach ${q2(dir)} ${q2(base)}`, "creating the task worktree");
|
|
104991
105002
|
const found = await must(shell, `cd ${q2(top)} && find . -maxdepth 4 -name node_modules -type d -prune -not -path './.git/*'`, "listing dependency folders");
|
|
104992
105003
|
for (const line of found.split("\n")) {
|
|
@@ -105039,6 +105050,7 @@ function localPipelineDeps(d, job) {
|
|
|
105039
105050
|
},
|
|
105040
105051
|
chown: () => "true",
|
|
105041
105052
|
installDependencies: false,
|
|
105053
|
+
excludeFromDiff: ["**/node_modules"],
|
|
105042
105054
|
basePatches: async () => {
|
|
105043
105055
|
const res = await d.fetch(`${base}/base-patches`, { headers: auth, signal: d.signal });
|
|
105044
105056
|
if (!res.ok) throw new Error(`base patches request failed (${res.status})`);
|