@sideboard-ai/core 0.1.35 → 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,13 +21,13 @@ import {
21
21
  opencodeAdapter,
22
22
  permissionMode,
23
23
  resolveCursorModelId
24
- } from "./chunk-MULWZLDI.js";
24
+ } from "./chunk-5KZLWNBS.js";
25
25
  import "./chunk-ILQK4P5R.js";
26
26
  import {
27
27
  cursorSdkMessageToEvents,
28
28
  parseCursorRunnerLine
29
29
  } from "./chunk-BSZX63TV.js";
30
- import "./chunk-3WF3X46L.js";
30
+ import "./chunk-YZ23S32T.js";
31
31
  import "./chunk-M37RITA6.js";
32
32
  import {
33
33
  ensureAgentPath
@@ -13,6 +13,8 @@ import {
13
13
  claudeChromeEnabled,
14
14
  claudeUserSettingsPath,
15
15
  deleteBranchOnPurgeEnabled,
16
+ getDefaultAgent,
17
+ getDefaultModel,
16
18
  getIssueSource,
17
19
  getLinearApiKey,
18
20
  harnessEnvKey,
@@ -21,13 +23,15 @@ import {
21
23
  maxConcurrentAgents,
22
24
  resolveClaudeExecutable,
23
25
  resolveEffectiveIssueSource,
26
+ resolveThreadDefaults,
24
27
  saveAppSettings,
25
28
  updateAdvancedSettings,
26
29
  updateAppEnvironment,
27
30
  updateBrightsySettings,
28
31
  updateClaudeSettings,
32
+ updateDefaultsSettings,
29
33
  updateIntegrationsSettings
30
- } from "./chunk-3WF3X46L.js";
34
+ } from "./chunk-YZ23S32T.js";
31
35
  import "./chunk-M37RITA6.js";
32
36
  export {
33
37
  HARNESS_ENV_KEYS,
@@ -44,6 +48,8 @@ export {
44
48
  claudeChromeEnabled,
45
49
  claudeUserSettingsPath,
46
50
  deleteBranchOnPurgeEnabled,
51
+ getDefaultAgent,
52
+ getDefaultModel,
47
53
  getIssueSource,
48
54
  getLinearApiKey,
49
55
  harnessEnvKey,
@@ -52,10 +58,12 @@ export {
52
58
  maxConcurrentAgents,
53
59
  resolveClaudeExecutable,
54
60
  resolveEffectiveIssueSource,
61
+ resolveThreadDefaults,
55
62
  saveAppSettings,
56
63
  updateAdvancedSettings,
57
64
  updateAppEnvironment,
58
65
  updateBrightsySettings,
59
66
  updateClaudeSettings,
67
+ updateDefaultsSettings,
60
68
  updateIntegrationsSettings
61
69
  };
@@ -15,7 +15,7 @@ import {
15
15
  claudeChromeEnabled,
16
16
  loadAppSettings,
17
17
  resolveClaudeExecutable
18
- } from "./chunk-3WF3X46L.js";
18
+ } from "./chunk-YZ23S32T.js";
19
19
  import {
20
20
  ensureAgentPath,
21
21
  run
@@ -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-MULWZLDI.js";
28
+ } from "./chunk-5KZLWNBS.js";
29
29
  import {
30
30
  fallbackTurnFailDetail,
31
31
  formatTurnExitError,
@@ -40,7 +40,7 @@ import {
40
40
  loadAppSettings,
41
41
  resolveEffectiveIssueSource,
42
42
  updateAdvancedSettings
43
- } from "./chunk-3WF3X46L.js";
43
+ } from "./chunk-YZ23S32T.js";
44
44
  import {
45
45
  allocateTeamName,
46
46
  allocateTeamSlug,
@@ -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-2OX5XXYP.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
  }
@@ -3366,7 +3366,7 @@ var Orchestrator = class {
3366
3366
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
3367
3367
  });
3368
3368
  }
3369
- const { autoCleanupOrphansEnabled } = await import("./app-settings-BDMLWCWI.js");
3369
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-RSKDEMUI.js");
3370
3370
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
3371
3371
  await cleanupOrphanWorktrees({ repoPaths });
3372
3372
  }
@@ -3393,7 +3393,7 @@ var Orchestrator = class {
3393
3393
  });
3394
3394
  });
3395
3395
  this.emit({ type: "status_changed", threadId: thread.id, status: thread.status });
3396
- const { autoRunAfterSetupEnabled } = await import("./app-settings-BDMLWCWI.js");
3396
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-RSKDEMUI.js");
3397
3397
  if (autoRunAfterSetupEnabled()) {
3398
3398
  try {
3399
3399
  await this.startDev(thread.id);
@@ -3634,7 +3634,7 @@ var Orchestrator = class {
3634
3634
  });
3635
3635
  const artifactDirective = isBrightsy ? null : formatArtifactDirective();
3636
3636
  const settings = loadWorkspaceSettings(fresh.worktreePath, fresh.repoPath);
3637
- const { autoRenameBranchEnabled } = await import("./app-settings-BDMLWCWI.js");
3637
+ const { autoRenameBranchEnabled } = await import("./app-settings-RSKDEMUI.js");
3638
3638
  const renameBranchDirective = !isBrightsy && !isOrchestration && autoRenameBranchEnabled() ? formatRenameBranchDirective(fresh, {
3639
3639
  customPrompt: settings?.prompts?.renameBranch
3640
3640
  }) : null;
@@ -4312,7 +4312,7 @@ var Orchestrator = class {
4312
4312
  await runArchiveScript(thread.repoPath, thread.worktreePath);
4313
4313
  } catch {
4314
4314
  }
4315
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-BDMLWCWI.js");
4315
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-RSKDEMUI.js");
4316
4316
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
4317
4317
  await removeWorktree(thread.repoPath, thread.worktreePath, {
4318
4318
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -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
  });
@@ -13,6 +13,13 @@ var HARNESS_ENV_KEYS = {
13
13
  opencode: null,
14
14
  brightsy: null
15
15
  };
16
+ var DEFAULT_AGENTS = /* @__PURE__ */ new Set([
17
+ "claude",
18
+ "codex",
19
+ "opencode",
20
+ "brightsy",
21
+ "cursor"
22
+ ]);
16
23
  function appSettingsPath() {
17
24
  return join(appDataDir(), "settings.json");
18
25
  }
@@ -64,6 +71,19 @@ function normalizeIntegrations(raw) {
64
71
  }
65
72
  return out;
66
73
  }
74
+ function normalizeDefaults(raw) {
75
+ if (!raw || typeof raw !== "object") return {};
76
+ const source = raw;
77
+ const out = {};
78
+ if (typeof source.agent === "string" && DEFAULT_AGENTS.has(source.agent)) {
79
+ out.agent = source.agent;
80
+ }
81
+ if (typeof source.model === "string") {
82
+ const model = source.model.trim();
83
+ if (model) out.model = model;
84
+ }
85
+ return out;
86
+ }
67
87
  function normalizeAdvanced(raw) {
68
88
  if (!raw || typeof raw !== "object") return {};
69
89
  const source = raw;
@@ -108,6 +128,7 @@ function normalizeSettings(raw) {
108
128
  let claude = {};
109
129
  let brightsy = {};
110
130
  let integrations = {};
131
+ let defaults = {};
111
132
  let advanced = {};
112
133
  if (raw && typeof raw === "object") {
113
134
  if ("environment" in raw) {
@@ -131,17 +152,21 @@ function normalizeSettings(raw) {
131
152
  raw.integrations
132
153
  );
133
154
  }
155
+ if ("defaults" in raw) {
156
+ defaults = normalizeDefaults(raw.defaults);
157
+ }
134
158
  if ("advanced" in raw) {
135
159
  advanced = normalizeAdvanced(raw.advanced);
136
160
  }
137
161
  }
138
- return { environment: env, claude, brightsy, integrations, advanced };
162
+ return { environment: env, claude, brightsy, integrations, defaults, advanced };
139
163
  }
140
164
  var EMPTY_SETTINGS = {
141
165
  environment: {},
142
166
  claude: {},
143
167
  brightsy: {},
144
168
  integrations: {},
169
+ defaults: {},
145
170
  advanced: {}
146
171
  };
147
172
  function loadAppSettings() {
@@ -226,6 +251,38 @@ function updateIntegrationsSettings(patch) {
226
251
  }
227
252
  return saveAppSettings({ ...current, integrations });
228
253
  }
254
+ function updateDefaultsSettings(patch) {
255
+ const current = loadAppSettings();
256
+ const defaults = { ...current.defaults };
257
+ if ("agent" in patch) {
258
+ if (patch.agent == null) {
259
+ delete defaults.agent;
260
+ } else if (DEFAULT_AGENTS.has(patch.agent)) {
261
+ defaults.agent = patch.agent;
262
+ }
263
+ }
264
+ if ("model" in patch) {
265
+ if (patch.model == null || patch.model.trim() === "") {
266
+ delete defaults.model;
267
+ } else {
268
+ defaults.model = patch.model.trim();
269
+ }
270
+ }
271
+ return saveAppSettings({ ...current, defaults });
272
+ }
273
+ function getDefaultAgent(settings = loadAppSettings()) {
274
+ return settings.defaults.agent ?? "claude";
275
+ }
276
+ function getDefaultModel(settings = loadAppSettings()) {
277
+ const model = settings.defaults.model?.trim();
278
+ return model || null;
279
+ }
280
+ function resolveThreadDefaults(settings = loadAppSettings()) {
281
+ return {
282
+ agent: getDefaultAgent(settings),
283
+ model: getDefaultModel(settings)
284
+ };
285
+ }
229
286
  function isLinearConnected(settings = loadAppSettings()) {
230
287
  return Boolean(settings.integrations.linearApiKey?.trim());
231
288
  }
@@ -351,6 +408,10 @@ export {
351
408
  updateClaudeSettings,
352
409
  updateBrightsySettings,
353
410
  updateIntegrationsSettings,
411
+ updateDefaultsSettings,
412
+ getDefaultAgent,
413
+ getDefaultModel,
414
+ resolveThreadDefaults,
354
415
  isLinearConnected,
355
416
  getIssueSource,
356
417
  resolveEffectiveIssueSource,
@@ -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