spacecode 2.14.5 → 2.14.7
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 +25 -11
- package/package.json +1 -1
package/dist/repl.mjs
CHANGED
|
@@ -4088,7 +4088,7 @@ var init_defaults_core_loop = __esm({
|
|
|
4088
4088
|
body: `You are the core of a coding run. You direct; you never read files, search, run commands or write code. Workers do that.
|
|
4089
4089
|
|
|
4090
4090
|
## Tools (the only ones that exist)
|
|
4091
|
-
- edit_plan {tasks}: add tasks. Each task has id, role, goal (what the worker must do, concrete and self-contained: the worker sees only this, the files and the acceptance), files (a file belongs to one open task at a time), acceptance {kind: checks|rubric|none, detail} (a code task that the repo can check, with tests or a typecheck, uses kind checks so the repo's own typecheck and tests must pass; rubric and none skip them), budgetTokens, deadlineMs (milliseconds; a worker needs minutes to clone, work and check, so use 600000 for a code task; values are clamped to 600000-840000).
|
|
4091
|
+
- edit_plan {tasks}: add tasks. Each task has id, role, goal (what the worker must do, concrete and self-contained: the worker sees only this, the files and the acceptance), files (a file belongs to one open task at a time), dependsOn (optional list of task ids that must be accepted first; set it for any task that builds on another's work), acceptance {kind: checks|rubric|none, detail} (a code task that the repo can check, with tests or a typecheck, uses kind checks so the repo's own typecheck and tests must pass; rubric and none skip them), budgetTokens, deadlineMs (milliseconds; a worker needs minutes to clone, work and check, so use 600000 for a code task; values are clamped to 600000-840000).
|
|
4092
4092
|
- dispatch_task {taskId}: start a pending task (at most 2 attempts per task).
|
|
4093
4093
|
- accept_task {taskId}: accept a task in review. A checks task needs a passing verifier first.
|
|
4094
4094
|
- drop_task {taskId, reason}: drop a task you no longer need.
|
|
@@ -4101,7 +4101,7 @@ var init_defaults_core_loop = __esm({
|
|
|
4101
4101
|
- When the token budget is exhausted, package what is accepted and send the result.
|
|
4102
4102
|
- Prefer small tasks with one owner per file. Stay inside the budget.
|
|
4103
4103
|
- You are only woken by worker results and user messages, never by your own actions. So in the same answer as edit_plan, dispatch_task every task that can start now; a task left pending with nothing running stalls the run.
|
|
4104
|
-
- Tasks that must follow another (a test after its implementation) are dispatched after the earlier one is accepted; the later worker starts from the accepted work, so give it only its own files and do not repeat the earlier task's work.
|
|
4104
|
+
- Tasks that must follow another (a test after its implementation) name it in dependsOn and are dispatched only after the earlier one is accepted (a dispatch before that is refused, including while the earlier one is being retried); the later worker starts from the accepted work, so give it only its own files and do not repeat the earlier task's work. If a task it depends on is dropped or failed, the dependent can never start: drop it or replan it without that dependency.
|
|
4105
4105
|
- Worker digests are already included in what you are shown; there is nothing more to read. Decide from them (accept_task, drop_task, or dispatch a retry).
|
|
4106
4106
|
- Make every tool call of your answer at once; you do not see results between calls. Reply with tool calls only.`
|
|
4107
4107
|
},
|
|
@@ -105054,7 +105054,7 @@ async function linkDependencyFolders(shell, top, dir) {
|
|
|
105054
105054
|
await must(shell, `mkdir -p ${q2(`${dir}/${parent}`)} && { [ -e ${q2(`${dir}/${rel}`)} ] || ln -s ${q2(`${top}/${rel}`)} ${q2(`${dir}/${rel}`)}; }`, `linking ${rel}`);
|
|
105055
105055
|
}
|
|
105056
105056
|
}
|
|
105057
|
-
async function
|
|
105057
|
+
async function createTaskWorktreeNow(shell, cwd2, base, runId, taskId, attempt, warn = () => {
|
|
105058
105058
|
}) {
|
|
105059
105059
|
const top = await must(shell, `cd ${q2(cwd2)} && git rev-parse --show-toplevel`, "finding the repository root");
|
|
105060
105060
|
const commit = await must(shell, `cd ${q2(top)} && git stash create`, "snapshotting the working tree") || "HEAD";
|
|
@@ -105074,7 +105074,12 @@ async function removeTaskWorktree(shell, top, dir) {
|
|
|
105074
105074
|
return err instanceof Error ? err.message : String(err);
|
|
105075
105075
|
}
|
|
105076
105076
|
}
|
|
105077
|
-
|
|
105077
|
+
function createTaskWorktree(...args) {
|
|
105078
|
+
const run = creating.then(() => createTaskWorktreeNow(...args));
|
|
105079
|
+
creating = run.catch(() => void 0);
|
|
105080
|
+
return run;
|
|
105081
|
+
}
|
|
105082
|
+
var q2, safe, hash, creating;
|
|
105078
105083
|
var init_worktree = __esm({
|
|
105079
105084
|
"src/core/worktree.ts"() {
|
|
105080
105085
|
"use strict";
|
|
@@ -105085,6 +105090,7 @@ var init_worktree = __esm({
|
|
|
105085
105090
|
for (let i = 0; i < s.length; i++) h = (h << 5) + h + s.charCodeAt(i) >>> 0;
|
|
105086
105091
|
return h.toString(16);
|
|
105087
105092
|
};
|
|
105093
|
+
creating = Promise.resolve();
|
|
105088
105094
|
}
|
|
105089
105095
|
});
|
|
105090
105096
|
|
|
@@ -105226,24 +105232,32 @@ async function runCoreTurn(d, prompt) {
|
|
|
105226
105232
|
if (changed.length > 0) say(changed.map((id) => `task ${id}: ${now[id]}`).join(", "));
|
|
105227
105233
|
cur.known = now;
|
|
105228
105234
|
if (d.runLocalTask) {
|
|
105229
|
-
|
|
105235
|
+
const runLocalTask = d.runLocalTask;
|
|
105236
|
+
const todo = [];
|
|
105230
105237
|
for (const id of state.order) {
|
|
105231
105238
|
const t = state.tasks[id];
|
|
105232
105239
|
const key = `${id}:${t.attempt ?? 1}`;
|
|
105233
105240
|
if (t.status !== "assigned" || cur.started.includes(key)) continue;
|
|
105234
105241
|
cur.started.push(key);
|
|
105235
105242
|
say(`task ${id}: running on this machine`);
|
|
105243
|
+
todo.push({ id, attempt: t.attempt ?? 1, t });
|
|
105244
|
+
}
|
|
105245
|
+
const fatal = [];
|
|
105246
|
+
await Promise.all(todo.map(async ({ id, attempt, t }) => {
|
|
105236
105247
|
try {
|
|
105237
|
-
await
|
|
105248
|
+
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
105249
|
} catch (err) {
|
|
105239
|
-
if (d.signal.aborted || err instanceof TypeError || err instanceof ReferenceError)
|
|
105250
|
+
if (d.signal.aborted || err instanceof TypeError || err instanceof ReferenceError) {
|
|
105251
|
+
fatal.push(err);
|
|
105252
|
+
return;
|
|
105253
|
+
}
|
|
105240
105254
|
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
|
|
105255
|
+
console.error("[core-turn] local task attempt could not run or report", JSON.stringify({ runId, taskId: id, attempt, error: detail.slice(0, 300) }));
|
|
105242
105256
|
say(`task ${id}: could not run or report locally (${err instanceof Error ? err.message : String(err)}); its deadline will fail it`);
|
|
105243
105257
|
}
|
|
105244
|
-
|
|
105245
|
-
|
|
105246
|
-
if (
|
|
105258
|
+
}));
|
|
105259
|
+
if (fatal.length > 0) throw fatal[0];
|
|
105260
|
+
if (todo.length > 0) {
|
|
105247
105261
|
delay = 1e3;
|
|
105248
105262
|
continue;
|
|
105249
105263
|
}
|