spacecode 2.14.6 → 2.14.8
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 +39 -10
- package/package.json +1 -1
package/dist/repl.mjs
CHANGED
|
@@ -104826,6 +104826,17 @@ function codemindDigest(o) {
|
|
|
104826
104826
|
const checked = names.length === 0 ? "no repo checks configured for this task" : names.map((n) => `${n} exit ${o.checks[n]}`).join(", ");
|
|
104827
104827
|
return [`changed: created ${o.files.join(", ")} through Codemind build ${o.buildId}`, `checked: ${checked}`, "uncertain: none", `files: ${o.files.join(", ")}`].join("\n");
|
|
104828
104828
|
}
|
|
104829
|
+
function observedDigest(o) {
|
|
104830
|
+
const names = Object.keys(o.checks);
|
|
104831
|
+
const checked = names.length === 0 ? "no repo checks configured for this task" : names.map((n) => `${n} exit ${o.checks[n]}`).join(", ");
|
|
104832
|
+
const tail = redactSecrets((o.lastWords ?? "").trim().slice(-200).replace(/\s+/g, " "));
|
|
104833
|
+
return [
|
|
104834
|
+
`changed: ${o.changedFiles.length} file(s) changed in the task worktree`,
|
|
104835
|
+
`checked: ${checked}`,
|
|
104836
|
+
`uncertain: the agent ended without its own digest, so this summary is composed from the diff and the check results${tail ? `; its last words: ${tail}` : ""}`,
|
|
104837
|
+
`files: ${o.changedFiles.join(", ")}`
|
|
104838
|
+
].join("\n");
|
|
104839
|
+
}
|
|
104829
104840
|
function redactSecrets(text) {
|
|
104830
104841
|
return text.replace(/https?:\/\/\S+/g, "[url]").replace(/\b(?:gh[pousr]_[A-Za-z0-9]{20,255}|github_pat_[A-Za-z0-9_]{20,255})\b/g, "[token]");
|
|
104831
104842
|
}
|
|
@@ -104986,8 +104997,12 @@ ${r.stderr}`.trim().slice(-300).replace(/\s+/g, " ")) });
|
|
|
104986
104997
|
}
|
|
104987
104998
|
}
|
|
104988
104999
|
if (await deps.cancelled()) return "cancelled";
|
|
104989
|
-
|
|
105000
|
+
let digest = built ? codemindDigest({ buildId: built.buildId, files: built.files, checks }) : extractDigest(result?.text ?? "") ?? "";
|
|
104990
105001
|
const tooBig = new TextEncoder().encode(patch.stdout).length > MAX_PATCH_BYTES;
|
|
105002
|
+
if (digest === "" && run.exitCode === 0 && changedFiles.length > 0 && patch.stdout !== "" && !tooBig) {
|
|
105003
|
+
digest = observedDigest({ changedFiles, checks, ...result ? { lastWords: result.text } : {} });
|
|
105004
|
+
deps.log("worker ended without a digest; composed one from the diff and checks", { ...ids, files: changedFiles.length });
|
|
105005
|
+
}
|
|
104991
105006
|
if (result) {
|
|
104992
105007
|
await deps.report({ type: "usage", n: 0, tokens: result.inputTokens + result.outputTokens }).catch(
|
|
104993
105008
|
(e) => deps.log("worker usage report failed", { ...ids, error: e instanceof Error ? e.message.slice(0, 100) : "unknown" })
|
|
@@ -105054,7 +105069,7 @@ async function linkDependencyFolders(shell, top, dir) {
|
|
|
105054
105069
|
await must(shell, `mkdir -p ${q2(`${dir}/${parent}`)} && { [ -e ${q2(`${dir}/${rel}`)} ] || ln -s ${q2(`${top}/${rel}`)} ${q2(`${dir}/${rel}`)}; }`, `linking ${rel}`);
|
|
105055
105070
|
}
|
|
105056
105071
|
}
|
|
105057
|
-
async function
|
|
105072
|
+
async function createTaskWorktreeNow(shell, cwd2, base, runId, taskId, attempt, warn = () => {
|
|
105058
105073
|
}) {
|
|
105059
105074
|
const top = await must(shell, `cd ${q2(cwd2)} && git rev-parse --show-toplevel`, "finding the repository root");
|
|
105060
105075
|
const commit = await must(shell, `cd ${q2(top)} && git stash create`, "snapshotting the working tree") || "HEAD";
|
|
@@ -105074,7 +105089,12 @@ async function removeTaskWorktree(shell, top, dir) {
|
|
|
105074
105089
|
return err instanceof Error ? err.message : String(err);
|
|
105075
105090
|
}
|
|
105076
105091
|
}
|
|
105077
|
-
|
|
105092
|
+
function createTaskWorktree(...args) {
|
|
105093
|
+
const run = creating.then(() => createTaskWorktreeNow(...args));
|
|
105094
|
+
creating = run.catch(() => void 0);
|
|
105095
|
+
return run;
|
|
105096
|
+
}
|
|
105097
|
+
var q2, safe, hash, creating;
|
|
105078
105098
|
var init_worktree = __esm({
|
|
105079
105099
|
"src/core/worktree.ts"() {
|
|
105080
105100
|
"use strict";
|
|
@@ -105085,6 +105105,7 @@ var init_worktree = __esm({
|
|
|
105085
105105
|
for (let i = 0; i < s.length; i++) h = (h << 5) + h + s.charCodeAt(i) >>> 0;
|
|
105086
105106
|
return h.toString(16);
|
|
105087
105107
|
};
|
|
105108
|
+
creating = Promise.resolve();
|
|
105088
105109
|
}
|
|
105089
105110
|
});
|
|
105090
105111
|
|
|
@@ -105226,24 +105247,32 @@ async function runCoreTurn(d, prompt) {
|
|
|
105226
105247
|
if (changed.length > 0) say(changed.map((id) => `task ${id}: ${now[id]}`).join(", "));
|
|
105227
105248
|
cur.known = now;
|
|
105228
105249
|
if (d.runLocalTask) {
|
|
105229
|
-
|
|
105250
|
+
const runLocalTask = d.runLocalTask;
|
|
105251
|
+
const todo = [];
|
|
105230
105252
|
for (const id of state.order) {
|
|
105231
105253
|
const t = state.tasks[id];
|
|
105232
105254
|
const key = `${id}:${t.attempt ?? 1}`;
|
|
105233
105255
|
if (t.status !== "assigned" || cur.started.includes(key)) continue;
|
|
105234
105256
|
cur.started.push(key);
|
|
105235
105257
|
say(`task ${id}: running on this machine`);
|
|
105258
|
+
todo.push({ id, attempt: t.attempt ?? 1, t });
|
|
105259
|
+
}
|
|
105260
|
+
const fatal = [];
|
|
105261
|
+
await Promise.all(todo.map(async ({ id, attempt, t }) => {
|
|
105236
105262
|
try {
|
|
105237
|
-
await
|
|
105263
|
+
await runLocalTask({ taskId: id, attempt, task: { role: t.role ?? "code", goal: t.goal ?? "", files: t.files ?? [], acceptance: t.acceptance ?? { kind: "none" }, deadlineMs: t.deadlineMs ?? 6e5, budgetTokens: t.budgetTokens ?? 5e4 } });
|
|
105238
105264
|
} catch (err) {
|
|
105239
|
-
if (d.signal.aborted || err instanceof TypeError || err instanceof ReferenceError)
|
|
105265
|
+
if (d.signal.aborted || err instanceof TypeError || err instanceof ReferenceError) {
|
|
105266
|
+
fatal.push(err);
|
|
105267
|
+
return;
|
|
105268
|
+
}
|
|
105240
105269
|
const detail = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
|
|
105241
|
-
console.error("[core-turn] local task attempt could not run or report", JSON.stringify({ runId, taskId: id, attempt
|
|
105270
|
+
console.error("[core-turn] local task attempt could not run or report", JSON.stringify({ runId, taskId: id, attempt, error: detail.slice(0, 300) }));
|
|
105242
105271
|
say(`task ${id}: could not run or report locally (${err instanceof Error ? err.message : String(err)}); its deadline will fail it`);
|
|
105243
105272
|
}
|
|
105244
|
-
|
|
105245
|
-
|
|
105246
|
-
if (
|
|
105273
|
+
}));
|
|
105274
|
+
if (fatal.length > 0) throw fatal[0];
|
|
105275
|
+
if (todo.length > 0) {
|
|
105247
105276
|
delay = 1e3;
|
|
105248
105277
|
continue;
|
|
105249
105278
|
}
|