spacecode 2.12.6 → 2.13.0
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 +36 -11
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
|
104673
|
-
const
|
|
104674
|
-
|
|
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
|
}
|
|
@@ -104871,13 +104894,15 @@ async function runCoreForRepl(o) {
|
|
|
104871
104894
|
const messages = [...o.history, { role: "user", content: o.prompt }, { role: "assistant", content: [{ type: "text", text: turn.text || "(no reply)" }] }];
|
|
104872
104895
|
return { success: turn.success, messages, totalInputTokens: turn.tokens, totalOutputTokens: 0 };
|
|
104873
104896
|
}
|
|
104874
|
-
var coreModeOn, sq;
|
|
104897
|
+
var coreSwitch, coreModeOn, shouldUseCore, sq;
|
|
104875
104898
|
var init_core_mode = __esm({
|
|
104876
104899
|
"src/core/core-mode.ts"() {
|
|
104877
104900
|
"use strict";
|
|
104878
104901
|
init_core_turn();
|
|
104879
104902
|
init_profile_runtime();
|
|
104880
|
-
|
|
104903
|
+
coreSwitch = (env3) => (env3.SPACECODE_CORE ?? "").trim().toLowerCase();
|
|
104904
|
+
coreModeOn = (env3) => !["off", "0", "false", "no"].includes(coreSwitch(env3));
|
|
104905
|
+
shouldUseCore = (env3, repo) => coreModeOn(env3) && (repo !== null || coreSwitch(env3) === "on");
|
|
104881
104906
|
sq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
104882
104907
|
}
|
|
104883
104908
|
});
|
|
@@ -105471,7 +105496,7 @@ ${list2.map((c) => ` /${c.name} (${c.scope})${c.description ? ` ${c.descripti
|
|
|
105471
105496
|
};
|
|
105472
105497
|
const attached = await mentions.attach(prompt);
|
|
105473
105498
|
if (attached.notices.length > 0) setNotices(attached.notices);
|
|
105474
|
-
const result = coreModeOn(process.env) ? await runCoreForRepl({
|
|
105499
|
+
const result = coreModeOn(process.env) && shouldUseCore(process.env, await detectRepo(projectRoot, process.env)) ? await runCoreForRepl({
|
|
105475
105500
|
env: process.env,
|
|
105476
105501
|
apiKey,
|
|
105477
105502
|
sessionId: sessionIdRef.current ??= sessions ? sessions.newId() : crypto.randomUUID(),
|