spacecode 2.13.0 → 2.13.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
@@ -104831,6 +104831,25 @@ var init_core_turn = __esm({
104831
104831
  import { execFile as execFile4 } from "node:child_process";
104832
104832
  import { mkdir as mkdir6, writeFile as writeFile6 } from "node:fs/promises";
104833
104833
  import { join as join15 } from "node:path";
104834
+ async function repoIsPublic(url, fetchFn = fetch) {
104835
+ const hit = visibility.get(url);
104836
+ if (hit !== void 0) return hit;
104837
+ let ok = false;
104838
+ try {
104839
+ const res = await fetchFn(url.replace("https://github.com/", "https://api.github.com/repos/"), { headers: { Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(3e3) });
104840
+ ok = res.ok;
104841
+ } catch {
104842
+ ok = false;
104843
+ }
104844
+ visibility.set(url, ok);
104845
+ return ok;
104846
+ }
104847
+ async function chooseCore(env3, repo, fetchFn) {
104848
+ if (!shouldUseCore(env3, repo)) return { useCore: false };
104849
+ if (coreSwitch(env3) === "on" || repo === null || shareableGithubToken(env3)) return { useCore: true };
104850
+ if (await repoIsPublic(repo.url, fetchFn)) return { useCore: true };
104851
+ return { useCore: false, reason: "Core runs are off for this repo: it is private (or unreachable) and task agents cannot clone it. Using the local agent. Set SPACECODE_CORE_SHARE_GITHUB_TOKEN=on with GH_TOKEN to allow it, or SPACECODE_CORE=on to force it." };
104852
+ }
104834
104853
  function githubHttpsUrl(remote) {
104835
104854
  const t = remote.trim();
104836
104855
  const m2 = t.match(/^(?:git@github\.com:|ssh:\/\/git@github\.com\/|https:\/\/(?:[^@/]+@)?github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/);
@@ -104894,7 +104913,7 @@ async function runCoreForRepl(o) {
104894
104913
  const messages = [...o.history, { role: "user", content: o.prompt }, { role: "assistant", content: [{ type: "text", text: turn.text || "(no reply)" }] }];
104895
104914
  return { success: turn.success, messages, totalInputTokens: turn.tokens, totalOutputTokens: 0 };
104896
104915
  }
104897
- var coreSwitch, coreModeOn, shouldUseCore, sq;
104916
+ var coreSwitch, coreModeOn, shouldUseCore, visibility, sq;
104898
104917
  var init_core_mode = __esm({
104899
104918
  "src/core/core-mode.ts"() {
104900
104919
  "use strict";
@@ -104903,6 +104922,7 @@ var init_core_mode = __esm({
104903
104922
  coreSwitch = (env3) => (env3.SPACECODE_CORE ?? "").trim().toLowerCase();
104904
104923
  coreModeOn = (env3) => !["off", "0", "false", "no"].includes(coreSwitch(env3));
104905
104924
  shouldUseCore = (env3, repo) => coreModeOn(env3) && (repo !== null || coreSwitch(env3) === "on");
104925
+ visibility = /* @__PURE__ */ new Map();
104906
104926
  sq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
104907
104927
  }
104908
104928
  });
@@ -104968,6 +104988,7 @@ function useReplController({ repoName: repoName2, yolo: yolo2, mentions: mention
104968
104988
  }, []);
104969
104989
  const [replayed, setReplayed] = (0, import_react30.useState)([]);
104970
104990
  const [notices, setNotices] = (0, import_react30.useState)([]);
104991
+ const corePrivateNoticeShown = (0, import_react30.useRef)(false);
104971
104992
  const retryRef = (0, import_react30.useRef)(null);
104972
104993
  const [pending, setPending] = (0, import_react30.useState)(null);
104973
104994
  const abortRef = (0, import_react30.useRef)(null);
@@ -105496,7 +105517,12 @@ ${list2.map((c) => ` /${c.name} (${c.scope})${c.description ? ` ${c.descripti
105496
105517
  };
105497
105518
  const attached = await mentions.attach(prompt);
105498
105519
  if (attached.notices.length > 0) setNotices(attached.notices);
105499
- const result = coreModeOn(process.env) && shouldUseCore(process.env, await detectRepo(projectRoot, process.env)) ? await runCoreForRepl({
105520
+ const coreChoice = coreModeOn(process.env) ? await chooseCore(process.env, await detectRepo(projectRoot, process.env)) : { useCore: false };
105521
+ if (coreChoice.reason && !corePrivateNoticeShown.current) {
105522
+ corePrivateNoticeShown.current = true;
105523
+ notice(coreChoice.reason);
105524
+ }
105525
+ const result = coreChoice.useCore ? await runCoreForRepl({
105500
105526
  env: process.env,
105501
105527
  apiKey,
105502
105528
  sessionId: sessionIdRef.current ??= sessions ? sessions.newId() : crypto.randomUUID(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spacecode",
3
- "version": "2.13.0",
3
+ "version": "2.13.1",
4
4
  "description": "SpaceCode - launch cloud dev environments with AI coding agents",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",