spacecode 2.12.6 → 2.12.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/repl.mjs CHANGED
@@ -104601,12 +104601,18 @@ var init_import_reload = __esm({
104601
104601
 
104602
104602
  // src/command-loader.ts
104603
104603
  import { join as join14 } from "node:path";
104604
- async function userCommands(deps, lines2) {
104604
+ function skillCommandBody(name) {
104605
+ return `Run the imported skill "${name}": call the skill tool with name "${name}" and follow its instructions.
104606
+
104607
+ Arguments (may be empty): $ARGUMENTS`;
104608
+ }
104609
+ async function userCommands(deps, lines2, includeSkills) {
104610
+ const skillNames = /* @__PURE__ */ new Set();
104605
104611
  try {
104606
104612
  const apiKey = await resolveApiKey({ env: deps.env, readFile: deps.readFile, homedir: deps.homedir });
104607
104613
  if (!apiKey) {
104608
104614
  lines2.push("commands: user commands NOT loaded (not signed in)");
104609
- return [];
104615
+ return { defs: [], skillNames };
104610
104616
  }
104611
104617
  const client = createProfileClient({ baseUrl: backendUrl(deps.env), apiKey, fetch: deps.fetch, timeoutMs: 3e3 });
104612
104618
  const index = await client.index();
@@ -104622,10 +104628,24 @@ async function userCommands(deps, lines2) {
104622
104628
  }
104623
104629
  })
104624
104630
  );
104625
- return defs;
104631
+ if (includeSkills) {
104632
+ const taken = /* @__PURE__ */ new Set([...defs.map((d) => d.name.toLowerCase()), ...deps.builtins.map((b2) => b2.toLowerCase())]);
104633
+ let hidden = 0;
104634
+ for (const a of index?.assets ?? []) {
104635
+ if (a.kind !== "skill" || (a.description ?? "").startsWith("file:")) continue;
104636
+ if (taken.has(a.name.toLowerCase())) {
104637
+ hidden++;
104638
+ continue;
104639
+ }
104640
+ skillNames.add(a.name.toLowerCase());
104641
+ defs.push({ name: a.name, description: a.description ?? "", body: skillCommandBody(a.name) });
104642
+ }
104643
+ if (hidden > 0) lines2.push(`commands: ${hidden} skill(s) not offered as /name (a command or built-in has that name)`);
104644
+ }
104645
+ return { defs, skillNames };
104626
104646
  } catch (err) {
104627
104647
  lines2.push(`commands: user commands NOT loaded (${err instanceof Error ? err.message : String(err)})`);
104628
- return [];
104648
+ return { defs: [], skillNames };
104629
104649
  }
104630
104650
  }
104631
104651
  async function repoCommands(deps, lines2) {
@@ -104656,6 +104676,7 @@ async function repoCommands(deps, lines2) {
104656
104676
  }
104657
104677
  async function loadCommands(deps) {
104658
104678
  const configPath = join14(deps.configDir, "imports.json");
104679
+ let skillsOn = false;
104659
104680
  try {
104660
104681
  const loaded = parseImportsConfig(await deps.readFile(configPath).catch((err) => {
104661
104682
  if (err.code === "ENOENT") return null;
@@ -104663,15 +104684,17 @@ async function loadCommands(deps) {
104663
104684
  }), configPath);
104664
104685
  if (loaded.error) return off("commands: off (imports.json unreadable)");
104665
104686
  if (!loaded.config.categories.commands) return off("commands: off (imports.json has commands off)");
104687
+ skillsOn = loaded.config.categories.skills;
104666
104688
  } catch (err) {
104667
104689
  return off(`commands: off (imports.json not read: ${err instanceof Error ? err.message : String(err)})`);
104668
104690
  }
104669
104691
  const lines2 = [];
104670
- const [user, repo] = await Promise.all([userCommands(deps, lines2), repoCommands(deps, lines2)]);
104692
+ const [{ defs: user, skillNames }, repo] = await Promise.all([userCommands(deps, lines2, skillsOn), repoCommands(deps, lines2)]);
104671
104693
  const reg = buildCommandRegistry({ builtins: deps.builtins, user, repo });
104672
- const nUser = reg.commands.filter((c) => c.scope === "user").length;
104673
- const nRepo = reg.commands.length - nUser;
104674
- lines2.unshift(`commands: ${nUser} user, ${nRepo} repo${reg.shadowed.length ? `; repo shadows user: ${reg.shadowed.map((n) => "/" + n).join(", ")}` : ""}`);
104694
+ const nSkill = reg.commands.filter((c) => c.scope === "user" && skillNames.has(c.name)).length;
104695
+ const nUser = reg.commands.filter((c) => c.scope === "user").length - nSkill;
104696
+ const nRepo = reg.commands.length - nUser - nSkill;
104697
+ lines2.unshift(`commands: ${nUser} user, ${nRepo} repo${nSkill ? `, ${nSkill} from skills` : ""}${reg.shadowed.length ? `; repo shadows user: ${reg.shadowed.map((n) => "/" + n).join(", ")}` : ""}`);
104675
104698
  for (const s of reg.skipped) lines2.push(`commands: skipped [${s.scope}] /${s.name} (${s.reason})`);
104676
104699
  return { commands: reg.commands, statusLines: lines2 };
104677
104700
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spacecode",
3
- "version": "2.12.6",
3
+ "version": "2.12.7",
4
4
  "description": "SpaceCode - launch cloud dev environments with AI coding agents",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",