@sideboard-ai/core 0.1.36 → 0.1.37

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.
@@ -21,7 +21,7 @@ import {
21
21
  opencodeAdapter,
22
22
  permissionMode,
23
23
  resolveCursorModelId
24
- } from "./chunk-EHUIPKBW.js";
24
+ } from "./chunk-5KZLWNBS.js";
25
25
  import "./chunk-ILQK4P5R.js";
26
26
  import {
27
27
  cursorSdkMessageToEvents,
@@ -772,7 +772,7 @@ var claudeAdapter = {
772
772
  );
773
773
  }
774
774
  const mode = permissionMode(thread);
775
- const { isOrchestratorThread } = await import("./global-workspace-LM4AA4RO.js");
775
+ const { isOrchestratorThread } = await import("./global-workspace-QSRP25HQ.js");
776
776
  const isOrchestrator = isOrchestratorThread(thread);
777
777
  const injectedServers = await buildInjectedMcpServers({
778
778
  includeSideboard: true,
@@ -3,7 +3,7 @@ import {
3
3
  ensureWorkspace,
4
4
  removeWorkspace,
5
5
  syncWorkspacesFromThreads
6
- } from "./chunk-PER4N6LS.js";
6
+ } from "./chunk-FVGRUZHI.js";
7
7
  import {
8
8
  GLOBAL_WORKSPACE_ID,
9
9
  createGlobalChat,
@@ -13,19 +13,19 @@ import {
13
13
  isGlobalThread,
14
14
  isOrchestratorThread,
15
15
  orchestratorSessionPoisonedByBuiltins
16
- } from "./chunk-Y2EWQ4TL.js";
16
+ } from "./chunk-IS3AGU33.js";
17
17
  import {
18
18
  coordinatorSystemPrompt,
19
19
  coordinatorTurnReminder,
20
20
  enrichWorkspacesWithGithub,
21
21
  ensureGlobalCoordinatorCwd
22
- } from "./chunk-BMB7WCGF.js";
22
+ } from "./chunk-PTASB7SJ.js";
23
23
  import {
24
24
  PLAN_MODE_INSTRUCTION,
25
25
  allAdapters,
26
26
  getAdapter,
27
27
  parseBrightsyCliLine
28
- } from "./chunk-EHUIPKBW.js";
28
+ } from "./chunk-5KZLWNBS.js";
29
29
  import {
30
30
  fallbackTurnFailDetail,
31
31
  formatTurnExitError,
@@ -71,7 +71,7 @@ import {
71
71
  takenSlugsFromThread,
72
72
  threadDisplayLabel,
73
73
  worktreeNameFromPath
74
- } from "./chunk-UFWEANLU.js";
74
+ } from "./chunk-XBEQI5H4.js";
75
75
  import {
76
76
  appendMessage,
77
77
  createEmptyThread,
@@ -451,9 +451,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
451
451
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
452
452
  );
453
453
  }
454
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-LM4AA4RO.js");
454
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-QSRP25HQ.js");
455
455
  if (isGlobalThread2(thread)) {
456
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-QH35ES7Y.js");
456
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-WIYQVMOG.js");
457
457
  ensureGlobalCoordinatorCwd2();
458
458
  }
459
459
  const adapter = getAdapter(thread.agent);
@@ -2606,7 +2606,7 @@ async function createThread(input, onSetupLine) {
2606
2606
  return readThread(thread.id) ?? thread;
2607
2607
  }
2608
2608
  async function listLinearIssues(agent, repoPath) {
2609
- const { getAdapter: getAdapter2 } = await import("./agents-JZK6TQG7.js");
2609
+ const { getAdapter: getAdapter2 } = await import("./agents-3CD7GH2V.js");
2610
2610
  await requireAgent(agent, { requireLinear: true });
2611
2611
  const adapter = getAdapter2(agent);
2612
2612
  if (!adapter.listLinearIssues) {
@@ -2826,7 +2826,7 @@ async function adoptThread(input) {
2826
2826
  messages: input.messages ?? []
2827
2827
  });
2828
2828
  writeThread(thread);
2829
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-23GHLR7I.js");
2829
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-DMYWHVJC.js");
2830
2830
  await ensureWorkspace2(repoPath);
2831
2831
  return thread;
2832
2832
  }
@@ -4331,7 +4331,7 @@ var Orchestrator = class {
4331
4331
  return setStatus(thread.id, "idle");
4332
4332
  }
4333
4333
  if (!existsSync11(thread.worktreePath)) {
4334
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-RYTBDHHP.js");
4334
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-37FBII5A.js");
4335
4335
  const { execa: execa6 } = await import("execa");
4336
4336
  const slug = thread.worktreePath.split("/").pop();
4337
4337
  const dest = thread.worktreePath;
@@ -4414,7 +4414,7 @@ async function startOrchestration(opts) {
4414
4414
  sourceRef: "default",
4415
4415
  ...createOpts
4416
4416
  }).catch(async () => {
4417
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-RYTBDHHP.js");
4417
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-37FBII5A.js");
4418
4418
  const repo = await resolveRepoRoot2(repoPath);
4419
4419
  const def = await resolveDefaultBranch2(repo);
4420
4420
  return createThread({
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  isGlobalRepoPath
3
- } from "./chunk-Y2EWQ4TL.js";
3
+ } from "./chunk-IS3AGU33.js";
4
4
  import {
5
5
  ensureGhPreferOrigin,
6
6
  resolveRepoRoot
7
- } from "./chunk-UFWEANLU.js";
7
+ } from "./chunk-XBEQI5H4.js";
8
8
  import {
9
9
  appDataDir
10
10
  } from "./chunk-M37RITA6.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ensureGlobalCoordinatorCwd
3
- } from "./chunk-BMB7WCGF.js";
3
+ } from "./chunk-PTASB7SJ.js";
4
4
  import {
5
5
  allocateTeamName,
6
6
  takenSlugsFromThread,
7
7
  teamSlugFromName
8
- } from "./chunk-UFWEANLU.js";
8
+ } from "./chunk-XBEQI5H4.js";
9
9
  import {
10
10
  createEmptyThread,
11
11
  listThreads,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveGithubRepoSlug
3
- } from "./chunk-UFWEANLU.js";
3
+ } from "./chunk-XBEQI5H4.js";
4
4
  import {
5
5
  globalAgentCwd,
6
6
  sideboardReposDir
@@ -1473,11 +1473,83 @@ async function getPrDetails(cwd, selector) {
1473
1473
  };
1474
1474
  }
1475
1475
  async function fetchPrHead(repoPath, number, localBranch) {
1476
- await git(
1477
- ["fetch", "origin", `pull/${number}/head:${localBranch}`],
1478
- repoPath,
1479
- { reject: false }
1480
- );
1476
+ const slug = await resolveGithubRepoSlug(repoPath);
1477
+ const refspec = `+pull/${number}/head:${localBranch}`;
1478
+ const errors = [];
1479
+ const tryFetch = async (remote) => {
1480
+ const result = await git(["fetch", remote, refspec], repoPath, {
1481
+ reject: false
1482
+ });
1483
+ if (result.exitCode === 0) return true;
1484
+ const detail = (result.stderr || result.stdout).trim();
1485
+ if (detail) errors.push(`${remote}: ${detail}`);
1486
+ return false;
1487
+ };
1488
+ let fetched = await tryFetch("origin");
1489
+ if (!fetched && slug) {
1490
+ fetched = await tryFetch(`https://github.com/${slug}.git`);
1491
+ }
1492
+ const localOk = async () => {
1493
+ const verify = await git(["rev-parse", "--verify", localBranch], repoPath, {
1494
+ reject: false
1495
+ });
1496
+ return verify.exitCode === 0;
1497
+ };
1498
+ if (!await localOk()) {
1499
+ const viewArgs = [
1500
+ "pr",
1501
+ "view",
1502
+ String(number),
1503
+ "--json",
1504
+ "headRefOid"
1505
+ ];
1506
+ if (slug) viewArgs.push("--repo", slug);
1507
+ const view = await gh(viewArgs, repoPath, { reject: false });
1508
+ let oid = "";
1509
+ if (view.exitCode === 0 && view.stdout.trim()) {
1510
+ try {
1511
+ oid = String(
1512
+ JSON.parse(view.stdout).headRefOid ?? ""
1513
+ ).trim();
1514
+ } catch {
1515
+ oid = "";
1516
+ }
1517
+ }
1518
+ if (oid) {
1519
+ const ensureOid = async (remote) => {
1520
+ const got = await git(["fetch", remote, oid], repoPath, {
1521
+ reject: false
1522
+ });
1523
+ return got.exitCode === 0;
1524
+ };
1525
+ let haveObject = (await git(["cat-file", "-e", `${oid}^{commit}`], repoPath, {
1526
+ reject: false
1527
+ })).exitCode === 0;
1528
+ if (!haveObject) haveObject = await ensureOid("origin");
1529
+ if (!haveObject && slug) {
1530
+ haveObject = await ensureOid(`https://github.com/${slug}.git`);
1531
+ }
1532
+ if (haveObject) {
1533
+ const branched = await git(["branch", "-f", localBranch, oid], repoPath, {
1534
+ reject: false
1535
+ });
1536
+ if (branched.exitCode !== 0) {
1537
+ const detail = (branched.stderr || branched.stdout).trim();
1538
+ if (detail) errors.push(`branch -f: ${detail}`);
1539
+ }
1540
+ } else {
1541
+ errors.push(`could not fetch commit ${oid.slice(0, 12)}`);
1542
+ }
1543
+ } else if (view.stderr.trim()) {
1544
+ errors.push(view.stderr.trim());
1545
+ }
1546
+ }
1547
+ if (!await localOk()) {
1548
+ const hint = errors.length ? ` (${errors.join(" | ")})` : "";
1549
+ throw new Error(
1550
+ `Failed to fetch PR #${number} head into ${localBranch}${hint}`
1551
+ );
1552
+ }
1481
1553
  }
1482
1554
  async function resolveWorktreeStartPoint(repoPath, sourceRef) {
1483
1555
  const ref = sourceRef.trim();
@@ -1487,6 +1559,7 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
1487
1559
  reject: false
1488
1560
  });
1489
1561
  if (ok.exitCode === 0) return ref;
1562
+ throw new Error(`Invalid git reference: ${ref}`);
1490
1563
  }
1491
1564
  const remote = `origin/${ref}`;
1492
1565
  const remoteOk = await git(["rev-parse", "--verify", remote], repoPath, {
@@ -1497,7 +1570,10 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
1497
1570
  reject: false
1498
1571
  });
1499
1572
  if (localOk.exitCode === 0) return ref;
1500
- return ref;
1573
+ throw new Error(`Invalid git reference: ${ref}`);
1574
+ }
1575
+ function isLocalPrFetchBranch(ref) {
1576
+ return /^sideboard-pr-\d+$/.test(ref.trim());
1501
1577
  }
1502
1578
  async function createThreadWorktree(opts) {
1503
1579
  let branchName = `thread/${opts.slug}`;
@@ -1507,7 +1583,7 @@ async function createThreadWorktree(opts) {
1507
1583
  }
1508
1584
  await ensureGhPreferOrigin(opts.repoPath);
1509
1585
  await git(["fetch", "origin", "--prune"], opts.repoPath, { reject: false });
1510
- if (!opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
1586
+ if (!isLocalPrFetchBranch(opts.sourceRef) && !opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
1511
1587
  await git(["fetch", "origin", opts.sourceRef], opts.repoPath, {
1512
1588
  reject: false
1513
1589
  });
@@ -6,8 +6,8 @@ import {
6
6
  enrichWorkspacesWithGithub,
7
7
  ensureGlobalCoordinatorCwd,
8
8
  formatWorkspaceInventory
9
- } from "./chunk-BMB7WCGF.js";
10
- import "./chunk-UFWEANLU.js";
9
+ } from "./chunk-PTASB7SJ.js";
10
+ import "./chunk-XBEQI5H4.js";
11
11
  import "./chunk-HYRHI3QU.js";
12
12
  import "./chunk-M37RITA6.js";
13
13
  import "./chunk-AJ6ROGD7.js";
@@ -11,9 +11,9 @@ import {
11
11
  orchestrationTitleNeedsSoccerNickname,
12
12
  orchestratorSessionPoisonedByBuiltins,
13
13
  takenTeamSlugsForOrchestration
14
- } from "./chunk-Y2EWQ4TL.js";
15
- import "./chunk-BMB7WCGF.js";
16
- import "./chunk-UFWEANLU.js";
14
+ } from "./chunk-IS3AGU33.js";
15
+ import "./chunk-PTASB7SJ.js";
16
+ import "./chunk-XBEQI5H4.js";
17
17
  import "./chunk-HYRHI3QU.js";
18
18
  import {
19
19
  globalAgentCwd
package/dist/index.cjs CHANGED
@@ -2579,11 +2579,83 @@ async function getPrDetails(cwd, selector) {
2579
2579
  };
2580
2580
  }
2581
2581
  async function fetchPrHead(repoPath, number, localBranch) {
2582
- await git(
2583
- ["fetch", "origin", `pull/${number}/head:${localBranch}`],
2584
- repoPath,
2585
- { reject: false }
2586
- );
2582
+ const slug = await resolveGithubRepoSlug(repoPath);
2583
+ const refspec = `+pull/${number}/head:${localBranch}`;
2584
+ const errors = [];
2585
+ const tryFetch = async (remote) => {
2586
+ const result = await git(["fetch", remote, refspec], repoPath, {
2587
+ reject: false
2588
+ });
2589
+ if (result.exitCode === 0) return true;
2590
+ const detail = (result.stderr || result.stdout).trim();
2591
+ if (detail) errors.push(`${remote}: ${detail}`);
2592
+ return false;
2593
+ };
2594
+ let fetched = await tryFetch("origin");
2595
+ if (!fetched && slug) {
2596
+ fetched = await tryFetch(`https://github.com/${slug}.git`);
2597
+ }
2598
+ const localOk = async () => {
2599
+ const verify = await git(["rev-parse", "--verify", localBranch], repoPath, {
2600
+ reject: false
2601
+ });
2602
+ return verify.exitCode === 0;
2603
+ };
2604
+ if (!await localOk()) {
2605
+ const viewArgs = [
2606
+ "pr",
2607
+ "view",
2608
+ String(number),
2609
+ "--json",
2610
+ "headRefOid"
2611
+ ];
2612
+ if (slug) viewArgs.push("--repo", slug);
2613
+ const view = await gh(viewArgs, repoPath, { reject: false });
2614
+ let oid = "";
2615
+ if (view.exitCode === 0 && view.stdout.trim()) {
2616
+ try {
2617
+ oid = String(
2618
+ JSON.parse(view.stdout).headRefOid ?? ""
2619
+ ).trim();
2620
+ } catch {
2621
+ oid = "";
2622
+ }
2623
+ }
2624
+ if (oid) {
2625
+ const ensureOid = async (remote) => {
2626
+ const got = await git(["fetch", remote, oid], repoPath, {
2627
+ reject: false
2628
+ });
2629
+ return got.exitCode === 0;
2630
+ };
2631
+ let haveObject = (await git(["cat-file", "-e", `${oid}^{commit}`], repoPath, {
2632
+ reject: false
2633
+ })).exitCode === 0;
2634
+ if (!haveObject) haveObject = await ensureOid("origin");
2635
+ if (!haveObject && slug) {
2636
+ haveObject = await ensureOid(`https://github.com/${slug}.git`);
2637
+ }
2638
+ if (haveObject) {
2639
+ const branched = await git(["branch", "-f", localBranch, oid], repoPath, {
2640
+ reject: false
2641
+ });
2642
+ if (branched.exitCode !== 0) {
2643
+ const detail = (branched.stderr || branched.stdout).trim();
2644
+ if (detail) errors.push(`branch -f: ${detail}`);
2645
+ }
2646
+ } else {
2647
+ errors.push(`could not fetch commit ${oid.slice(0, 12)}`);
2648
+ }
2649
+ } else if (view.stderr.trim()) {
2650
+ errors.push(view.stderr.trim());
2651
+ }
2652
+ }
2653
+ if (!await localOk()) {
2654
+ const hint = errors.length ? ` (${errors.join(" | ")})` : "";
2655
+ throw new Error(
2656
+ `Failed to fetch PR #${number} head into ${localBranch}${hint}`
2657
+ );
2658
+ }
2587
2659
  }
2588
2660
  async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2589
2661
  const ref = sourceRef.trim();
@@ -2593,6 +2665,7 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2593
2665
  reject: false
2594
2666
  });
2595
2667
  if (ok.exitCode === 0) return ref;
2668
+ throw new Error(`Invalid git reference: ${ref}`);
2596
2669
  }
2597
2670
  const remote = `origin/${ref}`;
2598
2671
  const remoteOk = await git(["rev-parse", "--verify", remote], repoPath, {
@@ -2603,7 +2676,10 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2603
2676
  reject: false
2604
2677
  });
2605
2678
  if (localOk.exitCode === 0) return ref;
2606
- return ref;
2679
+ throw new Error(`Invalid git reference: ${ref}`);
2680
+ }
2681
+ function isLocalPrFetchBranch(ref) {
2682
+ return /^sideboard-pr-\d+$/.test(ref.trim());
2607
2683
  }
2608
2684
  async function createThreadWorktree(opts) {
2609
2685
  let branchName = `thread/${opts.slug}`;
@@ -2613,7 +2689,7 @@ async function createThreadWorktree(opts) {
2613
2689
  }
2614
2690
  await ensureGhPreferOrigin(opts.repoPath);
2615
2691
  await git(["fetch", "origin", "--prune"], opts.repoPath, { reject: false });
2616
- if (!opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2692
+ if (!isLocalPrFetchBranch(opts.sourceRef) && !opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2617
2693
  await git(["fetch", "origin", opts.sourceRef], opts.repoPath, {
2618
2694
  reject: false
2619
2695
  });
package/dist/index.js CHANGED
@@ -101,14 +101,14 @@ import {
101
101
  withAgentInstructions,
102
102
  worktreeCleanupSettings,
103
103
  writeWorktreeFile
104
- } from "./chunk-KSVPOIRV.js";
104
+ } from "./chunk-E4TRCRKH.js";
105
105
  import {
106
106
  addWorkspace,
107
107
  ensureWorkspace,
108
108
  listWorkspaces,
109
109
  removeWorkspace,
110
110
  syncWorkspacesFromThreads
111
- } from "./chunk-PER4N6LS.js";
111
+ } from "./chunk-FVGRUZHI.js";
112
112
  import {
113
113
  CLOUD_COORDINATOR_BUSY_REPLY,
114
114
  CLOUD_COORDINATOR_STOPPED_REPLY,
@@ -128,7 +128,7 @@ import {
128
128
  orchestratorSessionPoisonedByBuiltins,
129
129
  parseForceStopMessage,
130
130
  takenTeamSlugsForOrchestration
131
- } from "./chunk-Y2EWQ4TL.js";
131
+ } from "./chunk-IS3AGU33.js";
132
132
  import {
133
133
  COORDINATOR_TOOL_PLAYBOOK,
134
134
  coordinatorSystemPrompt,
@@ -136,7 +136,7 @@ import {
136
136
  enrichWorkspacesWithGithub,
137
137
  ensureGlobalCoordinatorCwd,
138
138
  formatWorkspaceInventory
139
- } from "./chunk-BMB7WCGF.js";
139
+ } from "./chunk-PTASB7SJ.js";
140
140
  import {
141
141
  BRIGHTSY_MCP_ALLOWED_TOOLS,
142
142
  MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS,
@@ -176,7 +176,7 @@ import {
176
176
  resolveCursorModelId,
177
177
  sanitizeMcpServerName,
178
178
  writeInjectedMcpConfig
179
- } from "./chunk-EHUIPKBW.js";
179
+ } from "./chunk-5KZLWNBS.js";
180
180
  import {
181
181
  brightsyConfigPath,
182
182
  brightsyMcpServerName,
@@ -275,7 +275,7 @@ import {
275
275
  worktreeDisplayLabel,
276
276
  worktreeDisplayLabelForGroup,
277
277
  worktreeNameFromPath
278
- } from "./chunk-UFWEANLU.js";
278
+ } from "./chunk-XBEQI5H4.js";
279
279
  import {
280
280
  appendMessage,
281
281
  createEmptyThread,
@@ -2174,11 +2174,83 @@ async function getPrDetails(cwd, selector) {
2174
2174
  };
2175
2175
  }
2176
2176
  async function fetchPrHead(repoPath, number, localBranch) {
2177
- await git(
2178
- ["fetch", "origin", `pull/${number}/head:${localBranch}`],
2179
- repoPath,
2180
- { reject: false }
2181
- );
2177
+ const slug = await resolveGithubRepoSlug(repoPath);
2178
+ const refspec = `+pull/${number}/head:${localBranch}`;
2179
+ const errors = [];
2180
+ const tryFetch = async (remote) => {
2181
+ const result = await git(["fetch", remote, refspec], repoPath, {
2182
+ reject: false
2183
+ });
2184
+ if (result.exitCode === 0) return true;
2185
+ const detail = (result.stderr || result.stdout).trim();
2186
+ if (detail) errors.push(`${remote}: ${detail}`);
2187
+ return false;
2188
+ };
2189
+ let fetched = await tryFetch("origin");
2190
+ if (!fetched && slug) {
2191
+ fetched = await tryFetch(`https://github.com/${slug}.git`);
2192
+ }
2193
+ const localOk = async () => {
2194
+ const verify = await git(["rev-parse", "--verify", localBranch], repoPath, {
2195
+ reject: false
2196
+ });
2197
+ return verify.exitCode === 0;
2198
+ };
2199
+ if (!await localOk()) {
2200
+ const viewArgs = [
2201
+ "pr",
2202
+ "view",
2203
+ String(number),
2204
+ "--json",
2205
+ "headRefOid"
2206
+ ];
2207
+ if (slug) viewArgs.push("--repo", slug);
2208
+ const view = await gh(viewArgs, repoPath, { reject: false });
2209
+ let oid = "";
2210
+ if (view.exitCode === 0 && view.stdout.trim()) {
2211
+ try {
2212
+ oid = String(
2213
+ JSON.parse(view.stdout).headRefOid ?? ""
2214
+ ).trim();
2215
+ } catch {
2216
+ oid = "";
2217
+ }
2218
+ }
2219
+ if (oid) {
2220
+ const ensureOid = async (remote) => {
2221
+ const got = await git(["fetch", remote, oid], repoPath, {
2222
+ reject: false
2223
+ });
2224
+ return got.exitCode === 0;
2225
+ };
2226
+ let haveObject = (await git(["cat-file", "-e", `${oid}^{commit}`], repoPath, {
2227
+ reject: false
2228
+ })).exitCode === 0;
2229
+ if (!haveObject) haveObject = await ensureOid("origin");
2230
+ if (!haveObject && slug) {
2231
+ haveObject = await ensureOid(`https://github.com/${slug}.git`);
2232
+ }
2233
+ if (haveObject) {
2234
+ const branched = await git(["branch", "-f", localBranch, oid], repoPath, {
2235
+ reject: false
2236
+ });
2237
+ if (branched.exitCode !== 0) {
2238
+ const detail = (branched.stderr || branched.stdout).trim();
2239
+ if (detail) errors.push(`branch -f: ${detail}`);
2240
+ }
2241
+ } else {
2242
+ errors.push(`could not fetch commit ${oid.slice(0, 12)}`);
2243
+ }
2244
+ } else if (view.stderr.trim()) {
2245
+ errors.push(view.stderr.trim());
2246
+ }
2247
+ }
2248
+ if (!await localOk()) {
2249
+ const hint = errors.length ? ` (${errors.join(" | ")})` : "";
2250
+ throw new Error(
2251
+ `Failed to fetch PR #${number} head into ${localBranch}${hint}`
2252
+ );
2253
+ }
2182
2254
  }
2183
2255
  async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2184
2256
  const ref = sourceRef.trim();
@@ -2188,6 +2260,7 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2188
2260
  reject: false
2189
2261
  });
2190
2262
  if (ok.exitCode === 0) return ref;
2263
+ throw new Error(`Invalid git reference: ${ref}`);
2191
2264
  }
2192
2265
  const remote = `origin/${ref}`;
2193
2266
  const remoteOk = await git(["rev-parse", "--verify", remote], repoPath, {
@@ -2198,7 +2271,10 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2198
2271
  reject: false
2199
2272
  });
2200
2273
  if (localOk.exitCode === 0) return ref;
2201
- return ref;
2274
+ throw new Error(`Invalid git reference: ${ref}`);
2275
+ }
2276
+ function isLocalPrFetchBranch(ref) {
2277
+ return /^sideboard-pr-\d+$/.test(ref.trim());
2202
2278
  }
2203
2279
  async function createThreadWorktree(opts) {
2204
2280
  let branchName = `thread/${opts.slug}`;
@@ -2208,7 +2284,7 @@ async function createThreadWorktree(opts) {
2208
2284
  }
2209
2285
  await ensureGhPreferOrigin(opts.repoPath);
2210
2286
  await git(["fetch", "origin", "--prune"], opts.repoPath, { reject: false });
2211
- if (!opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2287
+ if (!isLocalPrFetchBranch(opts.sourceRef) && !opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2212
2288
  await git(["fetch", "origin", opts.sourceRef], opts.repoPath, {
2213
2289
  reject: false
2214
2290
  });
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  startMcpServer
4
- } from "../chunk-KSVPOIRV.js";
5
- import "../chunk-PER4N6LS.js";
6
- import "../chunk-Y2EWQ4TL.js";
7
- import "../chunk-BMB7WCGF.js";
8
- import "../chunk-EHUIPKBW.js";
4
+ } from "../chunk-E4TRCRKH.js";
5
+ import "../chunk-FVGRUZHI.js";
6
+ import "../chunk-IS3AGU33.js";
7
+ import "../chunk-PTASB7SJ.js";
8
+ import "../chunk-5KZLWNBS.js";
9
9
  import "../chunk-ILQK4P5R.js";
10
10
  import "../chunk-BSZX63TV.js";
11
11
  import "../chunk-YZ23S32T.js";
12
- import "../chunk-UFWEANLU.js";
12
+ import "../chunk-XBEQI5H4.js";
13
13
  import "../chunk-HYRHI3QU.js";
14
14
  import "../chunk-M37RITA6.js";
15
15
  import "../chunk-AJ6ROGD7.js";
@@ -4,10 +4,10 @@ import {
4
4
  listWorkspaces,
5
5
  removeWorkspace,
6
6
  syncWorkspacesFromThreads
7
- } from "./chunk-PER4N6LS.js";
8
- import "./chunk-Y2EWQ4TL.js";
9
- import "./chunk-BMB7WCGF.js";
10
- import "./chunk-UFWEANLU.js";
7
+ } from "./chunk-FVGRUZHI.js";
8
+ import "./chunk-IS3AGU33.js";
9
+ import "./chunk-PTASB7SJ.js";
10
+ import "./chunk-XBEQI5H4.js";
11
11
  import "./chunk-HYRHI3QU.js";
12
12
  import "./chunk-M37RITA6.js";
13
13
  import "./chunk-AJ6ROGD7.js";
@@ -41,7 +41,7 @@ import {
41
41
  worktreeDisplayLabel,
42
42
  worktreeDisplayLabelForGroup,
43
43
  worktreeNameFromPath
44
- } from "./chunk-UFWEANLU.js";
44
+ } from "./chunk-XBEQI5H4.js";
45
45
  import "./chunk-HYRHI3QU.js";
46
46
  import "./chunk-M37RITA6.js";
47
47
  import "./chunk-AJ6ROGD7.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sideboard-ai/core",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Sideboard core — orchestration, agents, git worktrees, MCP server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",