spacecode 2.6.0 → 2.6.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 +59 -8
- package/package.json +1 -1
package/dist/repl.mjs
CHANGED
|
@@ -3765,6 +3765,21 @@ var init_loop = __esm({
|
|
|
3765
3765
|
}
|
|
3766
3766
|
});
|
|
3767
3767
|
|
|
3768
|
+
// ../agent/src/tools/exit-status.ts
|
|
3769
|
+
function isNeutralExit(command, exitCode, combinedOutput) {
|
|
3770
|
+
const segments2 = command.split("&&").map((s) => s.trim()).filter((s) => s && !s.toLowerCase().startsWith("cd "));
|
|
3771
|
+
if (segments2.length !== 1 || /[;|]/.test(segments2[0])) return false;
|
|
3772
|
+
const segment = segments2[0];
|
|
3773
|
+
const cmd = segment.split(/\s+/)[0].toLowerCase();
|
|
3774
|
+
if ((cmd === "grep" || cmd === "rg" || cmd === "diff" || cmd === "test") && exitCode === 1) return true;
|
|
3775
|
+
return (cmd === "ls" || cmd === "find") && (exitCode === 1 || exitCode === 2) && combinedOutput.trim().length > 0;
|
|
3776
|
+
}
|
|
3777
|
+
var init_exit_status = __esm({
|
|
3778
|
+
"../agent/src/tools/exit-status.ts"() {
|
|
3779
|
+
"use strict";
|
|
3780
|
+
}
|
|
3781
|
+
});
|
|
3782
|
+
|
|
3768
3783
|
// ../agent/src/tools/bash.ts
|
|
3769
3784
|
function createBashTool(exec2) {
|
|
3770
3785
|
return async (input, onOutput) => {
|
|
@@ -3783,7 +3798,7 @@ function createBashTool(exec2) {
|
|
|
3783
3798
|
if (exitCode !== 0) {
|
|
3784
3799
|
const output = combined ? `${combined}
|
|
3785
3800
|
[exit code ${exitCode}]` : `[exit code ${exitCode}]`;
|
|
3786
|
-
return { output, is_error: true };
|
|
3801
|
+
return isNeutralExit(command, exitCode, combined) ? { output } : { output, is_error: true };
|
|
3787
3802
|
}
|
|
3788
3803
|
return { output: combined || "(no output)" };
|
|
3789
3804
|
};
|
|
@@ -3792,6 +3807,7 @@ var BASH_TOOL_DEFINITION;
|
|
|
3792
3807
|
var init_bash = __esm({
|
|
3793
3808
|
"../agent/src/tools/bash.ts"() {
|
|
3794
3809
|
"use strict";
|
|
3810
|
+
init_exit_status();
|
|
3795
3811
|
BASH_TOOL_DEFINITION = {
|
|
3796
3812
|
name: "bash",
|
|
3797
3813
|
description: "Run a shell command in the sandbox. Use for: running tests, installing dependencies, building, linting, git operations, or any command-line task.",
|
|
@@ -3811,7 +3827,8 @@ var init_bash = __esm({
|
|
|
3811
3827
|
|
|
3812
3828
|
// ../agent/src/prompt.ts
|
|
3813
3829
|
function buildSystemPrompt(options) {
|
|
3814
|
-
const workingDir = options.repoName ? `Working directory: /home/user/${options.repoName}` : "Working directory: empty workspace";
|
|
3830
|
+
const workingDir = options.localCwd ? `Working directory: ${options.localCwd}` : options.repoName ? `Working directory: /home/user/${options.repoName}` : "Working directory: empty workspace";
|
|
3831
|
+
const where = options.localCwd ? "on the user's machine" : "in the cloud";
|
|
3815
3832
|
const toolLines = [
|
|
3816
3833
|
"- read_file / write_file / edit_file / list_directory \u2014 instant file operations",
|
|
3817
3834
|
"- search \u2014 semantic code search by concept or keyword",
|
|
@@ -3829,7 +3846,7 @@ function buildSystemPrompt(options) {
|
|
|
3829
3846
|
if (options.hasCodegenTools) {
|
|
3830
3847
|
toolLines.push("- build_feature \u2014 generate a complete feature with tests using the platform codegen service. Use for multi-file features or new modules. Files are written to workspace; run tests afterwards.");
|
|
3831
3848
|
}
|
|
3832
|
-
return `You are SpaceCode Agent, a coding assistant running
|
|
3849
|
+
return `You are SpaceCode Agent, a coding assistant running ${where}.
|
|
3833
3850
|
|
|
3834
3851
|
## Tools
|
|
3835
3852
|
${toolLines.join("\n")}
|
|
@@ -6770,14 +6787,38 @@ var init_adapt_plan = __esm({
|
|
|
6770
6787
|
}
|
|
6771
6788
|
});
|
|
6772
6789
|
|
|
6790
|
+
// ../agent/src/import/section-name.ts
|
|
6791
|
+
function resolveSectionName(raw, known) {
|
|
6792
|
+
let n = raw.trim().toLowerCase();
|
|
6793
|
+
if (n.length > 40) n = n.slice(0, 40);
|
|
6794
|
+
n = n.replace(/-+$/g, "");
|
|
6795
|
+
if (n.length === 0 || !/^[a-z0-9-]+$/.test(n)) {
|
|
6796
|
+
return { error: `"${raw}" is not a valid section name` };
|
|
6797
|
+
}
|
|
6798
|
+
if (known.length === 0 || known.includes(n)) return { name: n };
|
|
6799
|
+
const candidates = known.filter((k2) => k2.startsWith(n) || n.startsWith(k2));
|
|
6800
|
+
if (candidates.length === 1) return { name: candidates[0] };
|
|
6801
|
+
if (candidates.length === 0) return { error: `"${raw}" is not a valid section name` };
|
|
6802
|
+
return { error: `"${raw}" is not a valid section name (candidates: ${candidates.join(", ")})` };
|
|
6803
|
+
}
|
|
6804
|
+
var init_section_name = __esm({
|
|
6805
|
+
"../agent/src/import/section-name.ts"() {
|
|
6806
|
+
"use strict";
|
|
6807
|
+
}
|
|
6808
|
+
});
|
|
6809
|
+
|
|
6773
6810
|
// ../agent/src/import/instructions-tool.ts
|
|
6774
6811
|
function createInstructionsReadTool(client) {
|
|
6775
6812
|
return async (input) => {
|
|
6776
|
-
const
|
|
6777
|
-
|
|
6813
|
+
const raw = typeof input.name === "string" ? input.name : "";
|
|
6814
|
+
const resolved = resolveSectionName(raw, []);
|
|
6815
|
+
if ("error" in resolved || !SAFE2.test(resolved.name)) {
|
|
6816
|
+
return { output: `instructions_read needs a "name" from the on-demand list, e.g. "cloudflare-auth"; received "${raw}"`, is_error: true };
|
|
6817
|
+
}
|
|
6818
|
+
const name = resolved.name;
|
|
6778
6819
|
try {
|
|
6779
6820
|
const asset = await client.get("instructions", `global.sec.${name}`);
|
|
6780
|
-
if (!asset) return { output: `No instructions section "${name}". Use a name from the on-demand list.`, is_error: true };
|
|
6821
|
+
if (!asset) return { output: `No instructions section "${name}"${name !== raw ? ` (from "${raw}")` : ""}. Use a name from the on-demand list.`, is_error: true };
|
|
6781
6822
|
return { output: asset.content };
|
|
6782
6823
|
} catch (err) {
|
|
6783
6824
|
return { output: `instructions_read failed: ${err instanceof Error ? err.message : String(err)}`, is_error: true };
|
|
@@ -6788,6 +6829,7 @@ var INSTRUCTIONS_READ_TOOL, INSTRUCTIONS_TOOL_DEFINITIONS, SAFE2;
|
|
|
6788
6829
|
var init_instructions_tool = __esm({
|
|
6789
6830
|
"../agent/src/import/instructions-tool.ts"() {
|
|
6790
6831
|
"use strict";
|
|
6832
|
+
init_section_name();
|
|
6791
6833
|
INSTRUCTIONS_READ_TOOL = {
|
|
6792
6834
|
name: "instructions_read",
|
|
6793
6835
|
description: `Read one on-demand section of the user's imported instructions by its name (listed under "More instructions (on demand)" in your instructions). Read the relevant section before working in that area; these are the user's standing rules.`,
|
|
@@ -102144,6 +102186,7 @@ function classifyError(message) {
|
|
|
102144
102186
|
}
|
|
102145
102187
|
if (/^No API key found/.test(message)) return { kind: "missing-key" };
|
|
102146
102188
|
if (/^Not approved\b/.test(message)) return { kind: "policy" };
|
|
102189
|
+
if (TIMEOUT.test(message)) return { kind: "timeout" };
|
|
102147
102190
|
if (NETWORK.test(message)) return { kind: "network" };
|
|
102148
102191
|
return { kind: "unknown" };
|
|
102149
102192
|
}
|
|
@@ -102205,6 +102248,12 @@ function describeError(kind, cause, ctx = {}) {
|
|
|
102205
102248
|
cause: `${shown}${retained ? " Your prompt is saved." : ""}`,
|
|
102206
102249
|
action: retained ? "Check your connection, then press enter to retry." : "Check your connection, then send your prompt again."
|
|
102207
102250
|
};
|
|
102251
|
+
case "timeout":
|
|
102252
|
+
return {
|
|
102253
|
+
title: "The model stopped responding",
|
|
102254
|
+
cause: `${shown}${retained ? " Your prompt is saved." : ""}`,
|
|
102255
|
+
action: retained ? "Press enter to retry." : "Send your prompt again."
|
|
102256
|
+
};
|
|
102208
102257
|
case "session-save":
|
|
102209
102258
|
return {
|
|
102210
102259
|
title: "Session not saved",
|
|
@@ -102227,9 +102276,9 @@ function describeEventError(message, ctx = {}) {
|
|
|
102227
102276
|
}
|
|
102228
102277
|
function isRetryable(message) {
|
|
102229
102278
|
const { kind } = classifyError(message);
|
|
102230
|
-
return kind === "gateway" || kind === "rate-limit" || kind === "network" || kind === "missing-key" || kind === "auth";
|
|
102279
|
+
return kind === "gateway" || kind === "rate-limit" || kind === "network" || kind === "timeout" || kind === "missing-key" || kind === "auth";
|
|
102231
102280
|
}
|
|
102232
|
-
var BILLING_URL, MAX_CAUSE_LINES, MAX_CAUSE_CHARS, NETWORK;
|
|
102281
|
+
var BILLING_URL, MAX_CAUSE_LINES, MAX_CAUSE_CHARS, TIMEOUT, NETWORK;
|
|
102233
102282
|
var init_describe_error = __esm({
|
|
102234
102283
|
"src/render/describe-error.ts"() {
|
|
102235
102284
|
"use strict";
|
|
@@ -102237,6 +102286,7 @@ var init_describe_error = __esm({
|
|
|
102237
102286
|
BILLING_URL = "https://spacecode.g-a-l-a-c-t-i-c.com";
|
|
102238
102287
|
MAX_CAUSE_LINES = 3;
|
|
102239
102288
|
MAX_CAUSE_CHARS = 300;
|
|
102289
|
+
TIMEOUT = /Stream stalled|Stream exceeded|No event within/i;
|
|
102240
102290
|
NETWORK = /fetch failed|ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|network (error|request failed|is unreachable)|socket hang up/i;
|
|
102241
102291
|
}
|
|
102242
102292
|
});
|
|
@@ -104610,6 +104660,7 @@ ${list2.map((c) => ` /${c.name} (${c.scope})${c.description ? ` ${c.descripti
|
|
|
104610
104660
|
...model ? { model } : {},
|
|
104611
104661
|
systemPrompt: buildSystemPrompt({
|
|
104612
104662
|
repoName: repoName2,
|
|
104663
|
+
localCwd: projectRoot,
|
|
104613
104664
|
commitGuidance: true,
|
|
104614
104665
|
hasGitHubTools: toolset.hasGitHubTools
|
|
104615
104666
|
}) + (profileRef.current?.promptSection ?? ""),
|