spacecode 2.6.0 → 2.6.1

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/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 in the cloud.
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 name = typeof input.name === "string" ? input.name.trim().toLowerCase() : "";
6777
- if (!SAFE2.test(name)) return { output: 'instructions_read needs a "name" from the on-demand list, e.g. "cloudflare-auth"', is_error: true };
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.`,
@@ -104610,6 +104652,7 @@ ${list2.map((c) => ` /${c.name} (${c.scope})${c.description ? ` ${c.descripti
104610
104652
  ...model ? { model } : {},
104611
104653
  systemPrompt: buildSystemPrompt({
104612
104654
  repoName: repoName2,
104655
+ localCwd: projectRoot,
104613
104656
  commitGuidance: true,
104614
104657
  hasGitHubTools: toolset.hasGitHubTools
104615
104658
  }) + (profileRef.current?.promptSection ?? ""),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spacecode",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "SpaceCode - launch cloud dev environments with AI coding agents",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",