@sideboard-ai/core 0.1.292 → 0.1.294

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.
Files changed (57) hide show
  1. package/dist/{abletime-VFKYNSJT.js → abletime-APP3DZ4P.js} +4 -4
  2. package/dist/{abletime-4WJUVE64.js → abletime-RYDAQ3FE.js} +4 -4
  3. package/dist/{abletime-oauth-ICMB2XV2.js → abletime-oauth-KTERKARA.js} +3 -3
  4. package/dist/{abletime-oauth-FW24YHYX.js → abletime-oauth-ZURGXSY6.js} +3 -3
  5. package/dist/{abletime-rest-OGWC7BC6.js → abletime-rest-4TVIWLZK.js} +3 -3
  6. package/dist/{abletime-rest-HFMRTUDT.js → abletime-rest-EUB6RW7K.js} +3 -3
  7. package/dist/agents/cursor-runner.cjs +329 -36
  8. package/dist/agents/cursor-runner.js +318 -17
  9. package/dist/{agents-XAKSP653.js → agents-2PDBDZPS.js} +5 -5
  10. package/dist/{agents-4BBCKITL.js → agents-73JXQXF2.js} +5 -5
  11. package/dist/{app-settings-EHMXHNG5.js → app-settings-2IH42VA5.js} +3 -1
  12. package/dist/{app-settings-MR2U6AXN.js → app-settings-3OQWRKOK.js} +3 -1
  13. package/dist/{chunk-3E4NOIXN.js → chunk-3D3GGL6X.js} +3 -3
  14. package/dist/{chunk-5HPMKLJ7.js → chunk-6SGYGYH7.js} +38 -14
  15. package/dist/{chunk-NXXQFLNQ.js → chunk-B42H6GJR.js} +2 -2
  16. package/dist/{chunk-G74TSBJ3.js → chunk-BJUHZSZQ.js} +4 -4
  17. package/dist/{chunk-MVZO7QZ2.js → chunk-BU6HH5VA.js} +4 -0
  18. package/dist/{chunk-QOUTSISS.js → chunk-BYAFYLLZ.js} +19 -19
  19. package/dist/{chunk-4VXWLY3L.js → chunk-CECZUHA5.js} +18 -18
  20. package/dist/{chunk-O4324MXE.js → chunk-E7G7RY6T.js} +3 -3
  21. package/dist/{chunk-NFPWLDCH.js → chunk-FAXOEKQR.js} +5 -5
  22. package/dist/{chunk-GU6DT6NO.js → chunk-HSF2RQSQ.js} +5 -5
  23. package/dist/{chunk-OH4EN323.js → chunk-ISEYRGMP.js} +2 -2
  24. package/dist/{chunk-VNCPRMIK.js → chunk-JEYJGQ33.js} +17 -11
  25. package/dist/{chunk-MYJYINTS.js → chunk-LZVWKJXY.js} +3 -3
  26. package/dist/{chunk-Y67TBJD5.js → chunk-MOP5L5QZ.js} +3 -3
  27. package/dist/{chunk-AF2DMY3K.js → chunk-QDDTVIWE.js} +13 -4
  28. package/dist/{chunk-B3BPLPKQ.js → chunk-R3R3ZDFC.js} +2 -2
  29. package/dist/{chunk-36J3IZBS.js → chunk-RSATPXU4.js} +4 -0
  30. package/dist/{chunk-AHH5USEA.js → chunk-SSETL5EX.js} +2 -2
  31. package/dist/{chunk-LUQ7MIVD.js → chunk-SVQTKVXH.js} +16 -11
  32. package/dist/{chunk-W2KZTDET.js → chunk-WZCPZVUC.js} +2 -2
  33. package/dist/{chunk-4BXRRHDC.js → chunk-XCXUVX7I.js} +12 -3
  34. package/dist/{chunk-V3BSO2O6.js → chunk-YEIPPZ5W.js} +3 -3
  35. package/dist/{chunk-GBAACE3C.js → chunk-YKO6HG74.js} +4 -4
  36. package/dist/{chunk-2IXKTAIT.js → chunk-ZEP6JIRF.js} +38 -14
  37. package/dist/{conductor-5MNGC25D.js → conductor-7DEMFEIO.js} +4 -4
  38. package/dist/{conductor-UFJXJPTF.js → conductor-ZQZTYXSX.js} +4 -4
  39. package/dist/{coordinator-prompt-5Q66Y5KW.js → coordinator-prompt-AROMFCP2.js} +3 -3
  40. package/dist/{coordinator-prompt-BYPEW6DE.js → coordinator-prompt-K6XHUG3N.js} +3 -3
  41. package/dist/{global-workspace-YKOYXSB2.js → global-workspace-4WAU4PAL.js} +3 -3
  42. package/dist/{global-workspace-BTH2YGDZ.js → global-workspace-PX4GUVLW.js} +3 -3
  43. package/dist/index.cjs +80 -24
  44. package/dist/index.d.cts +19 -5
  45. package/dist/index.d.ts +19 -5
  46. package/dist/index.js +32 -17
  47. package/dist/mcp/run-stdio.cjs +66 -24
  48. package/dist/mcp/run-stdio.js +15 -13
  49. package/dist/{optional-cli-FRUZSZ3U.js → optional-cli-JQVNSMSU.js} +3 -3
  50. package/dist/{optional-cli-6SW4OOX3.js → optional-cli-PZXDOVJJ.js} +4 -4
  51. package/dist/{orchestrator-EQSK2RMI.js → orchestrator-LIEGSQ6M.js} +8 -8
  52. package/dist/{orchestrator-GSOW3RPA.js → orchestrator-YNEEEP6O.js} +8 -8
  53. package/dist/{workspaces-ELO2YVTU.js → workspaces-MFU3IGAP.js} +3 -3
  54. package/dist/{workspaces-RFD6I4FM.js → workspaces-U7SSD27C.js} +3 -3
  55. package/dist/{worktree-ADVQ6X6C.js → worktree-2VSHRI72.js} +2 -2
  56. package/dist/{worktree-TN7DZDJZ.js → worktree-TQKASYPZ.js} +2 -2
  57. package/package.json +1 -1
@@ -4,14 +4,14 @@ import {
4
4
  normalizeAbleTimeCredential,
5
5
  normalizeAbleTimeHost,
6
6
  rewriteAbleTimeError
7
- } from "./chunk-NFPWLDCH.js";
7
+ } from "./chunk-FAXOEKQR.js";
8
8
  import {
9
9
  httpFetch
10
10
  } from "./chunk-JAT3JFOS.js";
11
11
  import {
12
12
  getAbleTimeAccessToken,
13
13
  getAbleTimeHost
14
- } from "./chunk-36J3IZBS.js";
14
+ } from "./chunk-RSATPXU4.js";
15
15
 
16
16
  // src/integrations/abletime-rest.ts
17
17
  var ABLETIME_REST_PREFIX = "/api/public/v2";
@@ -1906,6 +1906,9 @@ function disconnectLinearConnection() {
1906
1906
  delete integrations.linearOrganizationName;
1907
1907
  return saveAppSettings({ ...current, integrations });
1908
1908
  }
1909
+ function isPosthogConnected(settings = loadAppSettings()) {
1910
+ return Boolean(settings.integrations.posthogPersonalApiKey?.trim());
1911
+ }
1909
1912
  function isAbleTimeConnected(settings = loadAppSettings()) {
1910
1913
  return Boolean(
1911
1914
  settings.integrations.abletimeAccessToken?.trim() || settings.integrations.abletimeRefreshToken?.trim()
@@ -2375,6 +2378,7 @@ export {
2375
2378
  isLinearConnected,
2376
2379
  saveLinearOAuth,
2377
2380
  disconnectLinearConnection,
2381
+ isPosthogConnected,
2378
2382
  isAbleTimeConnected,
2379
2383
  getAbleTimeAccessToken,
2380
2384
  getAbleTimeHost,
@@ -6,14 +6,14 @@ import {
6
6
  normalizeAbleTimeCredential,
7
7
  normalizeAbleTimeHost,
8
8
  rewriteAbleTimeError
9
- } from "./chunk-GU6DT6NO.js";
9
+ } from "./chunk-HSF2RQSQ.js";
10
10
  import {
11
11
  httpFetch
12
12
  } from "./chunk-2GPQZZLY.js";
13
13
  import {
14
14
  getAbleTimeAccessToken,
15
15
  getAbleTimeHost
16
- } from "./chunk-MVZO7QZ2.js";
16
+ } from "./chunk-BU6HH5VA.js";
17
17
 
18
18
  // src/integrations/abletime-rest.ts
19
19
  var ABLETIME_REST_PREFIX = "/api/public/v2";
@@ -24,13 +24,13 @@ import {
24
24
  } from "./chunk-AFLNFGGB.js";
25
25
  import {
26
26
  isOrchestratorThread
27
- } from "./chunk-O4324MXE.js";
27
+ } from "./chunk-E7G7RY6T.js";
28
28
  import {
29
29
  codexUnattendedGitConfigArgs,
30
30
  mergeAgentGitAuthEnv,
31
31
  resolveAgentGitAuthEnv,
32
32
  resolveCodexGitWritableRoots
33
- } from "./chunk-5HPMKLJ7.js";
33
+ } from "./chunk-6SGYGYH7.js";
34
34
  import {
35
35
  npmGlobalNodeModules,
36
36
  run
@@ -40,10 +40,11 @@ import {
40
40
  fromInclusiveInputUsage,
41
41
  isAbleTimeConnected,
42
42
  isLinearConnected,
43
+ isPosthogConnected,
43
44
  loadAppSettings,
44
45
  resolveAgentExecutable,
45
46
  resolveClaudeExecutable
46
- } from "./chunk-MVZO7QZ2.js";
47
+ } from "./chunk-BU6HH5VA.js";
47
48
  import {
48
49
  isElectronLikeCommand,
49
50
  unwrapStrippedElectronLaunch,
@@ -483,6 +484,10 @@ var CLAUDE_CHROME_ALLOWED_TOOLS = [
483
484
  "mcp__claude-in-chrome__*",
484
485
  "Skill(claude-in-chrome)"
485
486
  ];
487
+ var CLAUDE_POSTHOG_CONNECTOR_ALLOWED_TOOLS = [
488
+ "mcp__claude_ai_PostHog",
489
+ "mcp__claude_ai_PostHog__*"
490
+ ];
486
491
 
487
492
  // src/agents/orch-mcp-isolation.ts
488
493
  import { existsSync as existsSync7, readFileSync as readFileSync3 } from "fs";
@@ -976,11 +981,9 @@ var SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS = ["mcp__sideboard__github_*"];
976
981
  var SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS = ["mcp__sideboard__linear_*"];
977
982
  var SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS = ["mcp__sideboard__abletime_*"];
978
983
  function sideboardWorktreeAllowedTools(opts) {
979
- const out = [...SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS];
980
- if (!opts?.planMode) {
981
- const idx = out.indexOf("mcp__sideboard__present_plan");
982
- if (idx >= 0) out.splice(idx, 1);
983
- }
984
+ const out = SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS.filter(
985
+ (tool) => (opts?.planMode || tool !== "mcp__sideboard__present_plan") && (opts?.posthog || tool !== "mcp__sideboard__posthog_api")
986
+ );
984
987
  if (opts?.github !== false) out.push(...SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS);
985
988
  if (opts?.linear) out.push(...SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS);
986
989
  if (opts?.abletime) out.push(...SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS);
@@ -2015,7 +2018,7 @@ var claudeAdapter = {
2015
2018
  );
2016
2019
  }
2017
2020
  const mode = permissionMode(thread);
2018
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-BTH2YGDZ.js");
2021
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-PX4GUVLW.js");
2019
2022
  const isOrchestrator = isOrchestratorThread2(thread);
2020
2023
  const rpc = worktreeAgentRpc(isOrchestrator);
2021
2024
  const injectedServers = await buildInjectedMcpServers({
@@ -2045,9 +2048,11 @@ var claudeAdapter = {
2045
2048
  github: true,
2046
2049
  linear: isLinearConnected(),
2047
2050
  abletime: isAbleTimeConnected(),
2048
- planMode: thread.planMode
2051
+ planMode: thread.planMode,
2052
+ posthog: isPosthogConnected()
2049
2053
  }),
2050
- ...brightsyMcpAllowedTools(injectedBrightsyNames)
2054
+ ...brightsyMcpAllowedTools(injectedBrightsyNames),
2055
+ ...isPosthogConnected() ? [] : CLAUDE_POSTHOG_CONNECTOR_ALLOWED_TOOLS
2051
2056
  ];
2052
2057
  }
2053
2058
  if (chromeOn) {
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-2UG25RMK.js";
10
10
  import {
11
11
  resolveAgentExecutable
12
- } from "./chunk-MVZO7QZ2.js";
12
+ } from "./chunk-BU6HH5VA.js";
13
13
 
14
14
  // src/agents/install.ts
15
15
  import { existsSync } from "fs";
@@ -267,7 +267,7 @@ async function loginAgent(agent) {
267
267
  };
268
268
  }
269
269
  async function loginManagedAccount(accountId) {
270
- const { loadAppSettings } = await import("./app-settings-EHMXHNG5.js");
270
+ const { loadAppSettings } = await import("./app-settings-2IH42VA5.js");
271
271
  const { loginEnvPrefix } = await import("./managed-accounts-46A4KRUE.js");
272
272
  const account = loadAppSettings().accounts.accounts.find((a) => a.id === accountId);
273
273
  if (!account) {
@@ -87,6 +87,12 @@ function connectorDirectiveLine(spec, cli) {
87
87
  }
88
88
  return `- ${spec.label}: call \`posthog_api\`. Path must start with \`/api/\`. GET is the default. POST \`/api/projects/:id/query/\` or \`/api/environments/:id/query/\` is a read and does not need \`write=true\`. Other POST and PATCH require \`write=true\` only when the user asked to change data. Do not read the API key from the environment. Do not add a ${spec.label} MCP.`;
89
89
  }
90
+ function connectorAuthCaution(posthog, cliConnected) {
91
+ const signIn = posthog ? "If a connector MCP is listed but needsAuth or returns unauthorized, do not sign in to that MCP." : "If a Vercel, Supabase, or Sentry MCP is listed but needsAuth or returns unauthorized, do not sign in to that MCP.";
92
+ const token = cliConnected ? " CLI tokens are already in this process." : "";
93
+ const key = posthog ? " Do not read a PostHog key from the environment." : "";
94
+ return `${signIn}${token}${key}`;
95
+ }
90
96
  function connectorReminderBit(spec, cli) {
91
97
  if (!spec.cli) return `${spec.label}: \`posthog_api\``;
92
98
  const presence = cliPresencePhrase(spec, cli);
@@ -96,10 +102,11 @@ function formatOptionalServicesDirective(integrations, cli) {
96
102
  const connected = connectedOptionalServices(integrations);
97
103
  if (connected.length === 0) return null;
98
104
  const cliConnected = connected.some((spec) => spec.cli);
105
+ const posthog = connected.some((spec) => spec.id === "posthog");
99
106
  const lines = [
100
107
  cliConnected ? "Optional connectors (connected \u2014 CLI tokens are already in this process env):" : "Optional connectors (connected):",
101
108
  ...connected.map((spec) => connectorDirectiveLine(spec, cli)),
102
- cliConnected ? "If a connector MCP is listed but needsAuth or returns unauthorized, do not sign in to that MCP. CLI tokens are already in this process. Do not read a PostHog key from the environment." : "If a connector MCP is listed but needsAuth or returns unauthorized, do not sign in to that MCP. Do not read a PostHog key from the environment.",
109
+ connectorAuthCaution(posthog, cliConnected),
103
110
  "Do not add a vendor MCP. When a binary is missing, ask the user to press Install CLI in Settings \u2192 Connectors.",
104
111
  "When you shell a connector CLI, write bulky output to `.context/cli/` and read a slice."
105
112
  ];
@@ -110,13 +117,15 @@ function formatOptionalServicesReminder(integrations, cli) {
110
117
  if (connected.length === 0) return null;
111
118
  const bits = connected.map((spec) => connectorReminderBit(spec, cli)).join(". ");
112
119
  const tokenBit = connected.some((spec) => spec.cli) ? "CLI tokens are already in this process. " : "";
113
- return `Settings \u2192 Connectors: ${tokenBit}${bits}. If a connector MCP needsAuth or is unauthorized, ignore it and use the CLI or \`posthog_api\`. Do not add vendor MCPs. Do not read a PostHog key from the environment. Shell dumps from those CLIs go in \`.context/cli/\` \u2014 read a slice.`;
120
+ const posthog = connected.some((spec) => spec.id === "posthog");
121
+ const auth = posthog ? "If a connector MCP needsAuth or is unauthorized, ignore it and use the CLI or `posthog_api`. Do not read a PostHog key from the environment." : "If a Vercel, Supabase, or Sentry MCP needsAuth or is unauthorized, ignore it and use the CLI.";
122
+ return `Settings \u2192 Connectors: ${tokenBit}${bits}. ${auth} Do not add vendor MCPs. Shell dumps from those CLIs go in \`.context/cli/\` \u2014 read a slice.`;
114
123
  }
115
124
  async function connectedCliPresence(integrations) {
116
125
  const ids = connectedOptionalServices(integrations).filter((spec) => spec.cli).map((spec) => spec.id);
117
126
  if (ids.length === 0) return void 0;
118
127
  try {
119
- const { optionalCliPresence } = await import("./optional-cli-FRUZSZ3U.js");
128
+ const { optionalCliPresence } = await import("./optional-cli-JQVNSMSU.js");
120
129
  return await optionalCliPresence(ids);
121
130
  } catch {
122
131
  return void 0;
@@ -3,7 +3,7 @@ import {
3
3
  ensureGhPreferOrigin,
4
4
  resolveGithubRepoSlug,
5
5
  resolveRepoRoot
6
- } from "./chunk-2IXKTAIT.js";
6
+ } from "./chunk-ZEP6JIRF.js";
7
7
  import {
8
8
  allocateTeamName,
9
9
  createEmptyThread,
@@ -29,7 +29,7 @@ import {
29
29
  resolveThreadDefaults,
30
30
  resolveViewerProfile,
31
31
  resolveViewerProfileForRepo
32
- } from "./chunk-36J3IZBS.js";
32
+ } from "./chunk-RSATPXU4.js";
33
33
  import {
34
34
  appDataDir,
35
35
  globalAgentCwd,
@@ -391,7 +391,7 @@ var COORDINATOR_TOOL_PLAYBOOK = [
391
391
  "- linear_* (when Linear is connected) \u2014 list_teams for team key/states; linear_list_projects for project names; get/search include the project a ticket is on; get/create/update/comment with ENG-123. Worktree agents have the same Account tools \u2014 prefer they comment, update status, and create spin-offs (parent=) on their own ticket when they were asked to do the work. When reviewing a PR or ticket, do not comment or update until the user types a next step \u2014 they should work through the feedback in chat first. Do not tell the child to ask_user after the review. Scope errors: reconnect Linear in Account settings. Prefer these over any Linear MCP the CLI may still list.",
392
392
  "- github_* \u2014 get/comment/update/create GitHub issues via Account `gh` (#123). github_list_projects and get/search include GitHub Projects. projectsError or a missing read:project scope \u2192 `gh auth refresh -s read:project`. Worktree agents have these too. Prefer over any vendor GitHub MCP. Pass parent= for spin-offs. When reviewing a PR or ticket, do not comment, submit `gh pr review`, or update the PR/ticket until the user types a next step.",
393
393
  "- abletime_* (when AbleTime is connected) \u2014 orientation first; abletime_list_projects lists projects; get/list include the project a task is on; get/comment/update/create (parent= for spin-offs); ensure_task when work has no ticket (or create_workspace from the default branch auto-creates one). Worktree agents have the same Account tools. Same review-write gate as Linear/GitHub.",
394
- "- Optional connectors (Vercel, Supabase, Sentry) in Settings \u2192 Connectors inject tokens into worktree agent env when connected. Prefer official CLIs (`vercel`, `supabase`, `sentry-cli`). PostHog is the Sideboard tool `posthog_api` (GET by default; POST `/api/projects/:id/query/` or `/api/environments/:id/query/` is a read and does not need write=true; other POST and PATCH need write=true only when the user asked to change data). The PostHog key stays in the vault \u2014 do not read it from the environment. If a connector MCP needsAuth or is unauthorized, do not sign in \u2014 use the native CLI or `posthog_api`. Tell any worktree agent (Claude / Cursor / Codex / OpenCode) to write CLI output to `.context/cli/` and read a slice. If a CLI is missing, the user presses Install CLI on that row. Do not add vendor MCPs. Git (`gh`) stays Settings \u2192 Git; issue tracking stays Settings \u2192 Issues. The phone remote is Settings \u2192 Remote \u2014 do not look up Slack users.",
394
+ "- Optional connectors (Vercel, Supabase, Sentry) in Settings \u2192 Connectors inject tokens into worktree agent env when connected. Prefer official CLIs (`vercel`, `supabase`, `sentry-cli`). When Settings \u2192 Connectors has a PostHog personal API key, PostHog is the Sideboard tool `posthog_api` (GET by default; POST `/api/projects/:id/query/` or `/api/environments/:id/query/` is a read and does not need write=true; other POST and PATCH need write=true only when the user asked to change data). The PostHog key stays in the vault \u2014 do not read it from the environment, and do not sign in to a PostHog MCP. When no PostHog API key is set, leave the Claude PostHog connector alone. If a Vercel, Supabase, or Sentry MCP needsAuth or is unauthorized, do not sign in \u2014 use the native CLI. Tell any worktree agent (Claude / Cursor / Codex / OpenCode) to write CLI output to `.context/cli/` and read a slice. If a CLI is missing, the user presses Install CLI on that row. Do not add vendor MCPs. Git (`gh`) stays Settings \u2192 Git; issue tracking stays Settings \u2192 Issues. The phone remote is Settings \u2192 Remote \u2014 do not look up Slack users.",
395
395
  "- get_pr_stack / open_pr_stack_layers / add_stack_layer / create_pr_stack \u2014 GitHub stacked PRs (`gh stack`); one worktree per layer",
396
396
  "- list_models \u2014 only when you need a specific model (rare); otherwise omit model so Account defaults apply",
397
397
  "- list_chats / get_chat \u2014 live thread list (parent id + last message preview). get_chat on this orchestration chat lists child worktree agents (status + lastText). blockedReason is why that agent is waiting on a person. Also includes usage / lastTurnUsage.",
@@ -8,11 +8,11 @@ import {
8
8
  isGlobalThread,
9
9
  isOrchestratorThread,
10
10
  isSlackCoordinatorThread
11
- } from "./chunk-V3BSO2O6.js";
11
+ } from "./chunk-YEIPPZ5W.js";
12
12
  import {
13
13
  mergeAgentGitAuthEnv,
14
14
  resolveAgentGitAuthEnv
15
- } from "./chunk-2IXKTAIT.js";
15
+ } from "./chunk-ZEP6JIRF.js";
16
16
  import {
17
17
  allocateTeamName,
18
18
  createEmptyThread,
@@ -43,7 +43,7 @@ import {
43
43
  import {
44
44
  assertOrchestratorCapableAgent,
45
45
  contextTokens
46
- } from "./chunk-36J3IZBS.js";
46
+ } from "./chunk-RSATPXU4.js";
47
47
  import {
48
48
  stripNestedElectronEnv
49
49
  } from "./chunk-4TR3HZFT.js";
@@ -1776,7 +1776,7 @@ var PORT_RANGE_SIZE = 10;
1776
1776
  var RECLAIM_RETRY_DELAY_MS = 40;
1777
1777
  var RECLAIM_TRIES = 8;
1778
1778
  async function killReclaimable(ports, worktreePath, signal) {
1779
- const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-UFJXJPTF.js");
1779
+ const { killListenersOnPorts: killListenersOnPorts2, killStaleWorktreeListeners: killStaleWorktreeListeners2 } = await import("./conductor-ZQZTYXSX.js");
1780
1780
  if (worktreePath) killStaleWorktreeListeners2(ports, worktreePath, signal);
1781
1781
  else killListenersOnPorts2(ports);
1782
1782
  }
@@ -24,7 +24,7 @@ import {
24
24
  import {
25
25
  getGithubGitAuthMode,
26
26
  getGithubPat
27
- } from "./chunk-36J3IZBS.js";
27
+ } from "./chunk-RSATPXU4.js";
28
28
  import {
29
29
  worktreesRoot
30
30
  } from "./chunk-EHT2DRT4.js";
@@ -2021,15 +2021,8 @@ async function fetchOriginForWorktree(repoPath, sourceRef, opts) {
2021
2021
  async function fastForwardMainCheckoutIfSafe(repoPath, opts) {
2022
2022
  try {
2023
2023
  const branch = opts?.branch?.trim() || await resolveDefaultBranch(repoPath, { network: false });
2024
- const head = await git(["rev-parse", "--abbrev-ref", "HEAD"], repoPath, {
2025
- reject: false
2026
- });
2027
- const current = head.stdout.trim();
2028
- if (head.exitCode !== 0 || !current || current === "HEAD" || current !== branch) {
2029
- return { updated: false, reason: "not-on-default" };
2030
- }
2031
- if (await isDirty(repoPath)) {
2032
- return { updated: false, reason: "dirty" };
2024
+ if (!branch || branch === "HEAD" || branch.includes("..")) {
2025
+ return { updated: false, reason: "ff-failed" };
2033
2026
  }
2034
2027
  const remote = `origin/${branch}`;
2035
2028
  const remoteOk = await git(["rev-parse", "--verify", remote], repoPath, {
@@ -2038,8 +2031,27 @@ async function fastForwardMainCheckoutIfSafe(repoPath, opts) {
2038
2031
  if (remoteOk.exitCode !== 0) {
2039
2032
  return { updated: false, reason: "no-origin-tip" };
2040
2033
  }
2034
+ const worktrees = await listWorktrees(repoPath);
2035
+ if (worktrees.length === 0) {
2036
+ return { updated: false, reason: "ff-failed" };
2037
+ }
2038
+ const checkout = worktrees.find((entry) => entry.branch === branch) ?? null;
2039
+ const localRef = `refs/heads/${branch}`;
2040
+ const localOk = await git(["rev-parse", "--verify", localRef], repoPath, {
2041
+ reject: false
2042
+ });
2043
+ if (localOk.exitCode !== 0) {
2044
+ if (checkout) return { updated: false, reason: "ff-failed" };
2045
+ const created = await git(["branch", "--track", branch, remote], repoPath, {
2046
+ reject: false
2047
+ });
2048
+ if (created.exitCode !== 0) {
2049
+ return { updated: false, reason: "ff-failed" };
2050
+ }
2051
+ return { updated: true, reason: "updated" };
2052
+ }
2041
2053
  const ancestor = await git(
2042
- ["merge-base", "--is-ancestor", "HEAD", remote],
2054
+ ["merge-base", "--is-ancestor", localRef, remote],
2043
2055
  repoPath,
2044
2056
  { reject: false }
2045
2057
  );
@@ -2047,7 +2059,7 @@ async function fastForwardMainCheckoutIfSafe(repoPath, opts) {
2047
2059
  return { updated: false, reason: "diverged" };
2048
2060
  }
2049
2061
  const behind = await git(
2050
- ["rev-list", "--count", `HEAD..${remote}`],
2062
+ ["rev-list", "--count", `${localRef}..${remote}`],
2051
2063
  repoPath,
2052
2064
  { reject: false }
2053
2065
  );
@@ -2055,10 +2067,22 @@ async function fastForwardMainCheckoutIfSafe(repoPath, opts) {
2055
2067
  if (behind.exitCode !== 0 || !Number.isFinite(n) || n <= 0) {
2056
2068
  return { updated: false, reason: "already-current" };
2057
2069
  }
2058
- const ff = await git(["merge", "--ff-only", remote], repoPath, {
2070
+ if (checkout) {
2071
+ if (await isDirty(checkout.path)) {
2072
+ return { updated: false, reason: "dirty" };
2073
+ }
2074
+ const ff = await git(["merge", "--ff-only", remote], checkout.path, {
2075
+ reject: false
2076
+ });
2077
+ if (ff.exitCode !== 0) {
2078
+ return { updated: false, reason: "ff-failed" };
2079
+ }
2080
+ return { updated: true, reason: "updated" };
2081
+ }
2082
+ const moved = await git(["branch", "-f", branch, remote], repoPath, {
2059
2083
  reject: false
2060
2084
  });
2061
- if (ff.exitCode !== 0) {
2085
+ if (moved.exitCode !== 0) {
2062
2086
  return { updated: false, reason: "ff-failed" };
2063
2087
  }
2064
2088
  return { updated: true, reason: "updated" };
@@ -33,14 +33,14 @@ import {
33
33
  tryReservePort,
34
34
  tryReservePorts,
35
35
  worktreeRunPortsPath
36
- } from "./chunk-G74TSBJ3.js";
36
+ } from "./chunk-BJUHZSZQ.js";
37
37
  import "./chunk-AFLNFGGB.js";
38
- import "./chunk-O4324MXE.js";
39
- import "./chunk-5HPMKLJ7.js";
38
+ import "./chunk-E7G7RY6T.js";
39
+ import "./chunk-6SGYGYH7.js";
40
40
  import "./chunk-N2WW62LF.js";
41
41
  import "./chunk-DD67JWTN.js";
42
42
  import "./chunk-2UG25RMK.js";
43
- import "./chunk-MVZO7QZ2.js";
43
+ import "./chunk-BU6HH5VA.js";
44
44
  import "./chunk-NSTQ6QKD.js";
45
45
  import {
46
46
  stripNestedElectronEnv
@@ -31,17 +31,17 @@ import {
31
31
  tryReservePort,
32
32
  tryReservePorts,
33
33
  worktreeRunPortsPath
34
- } from "./chunk-GBAACE3C.js";
34
+ } from "./chunk-YKO6HG74.js";
35
35
  import "./chunk-YSLCWCMJ.js";
36
- import "./chunk-V3BSO2O6.js";
37
- import "./chunk-2IXKTAIT.js";
36
+ import "./chunk-YEIPPZ5W.js";
37
+ import "./chunk-ZEP6JIRF.js";
38
38
  import "./chunk-QB5MDOHL.js";
39
39
  import "./chunk-2P4XKWV2.js";
40
40
  import "./chunk-MIVX7QKI.js";
41
41
  import "./chunk-6K64FJDD.js";
42
42
  import "./chunk-UWQ6UCIB.js";
43
43
  import "./chunk-QVN2WOKJ.js";
44
- import "./chunk-36J3IZBS.js";
44
+ import "./chunk-RSATPXU4.js";
45
45
  import "./chunk-77WWLBCI.js";
46
46
  import {
47
47
  stripNestedElectronEnv
@@ -7,14 +7,14 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-V3BSO2O6.js";
11
- import "./chunk-2IXKTAIT.js";
10
+ } from "./chunk-YEIPPZ5W.js";
11
+ import "./chunk-ZEP6JIRF.js";
12
12
  import "./chunk-QB5MDOHL.js";
13
13
  import "./chunk-2P4XKWV2.js";
14
14
  import "./chunk-6K64FJDD.js";
15
15
  import "./chunk-UWQ6UCIB.js";
16
16
  import "./chunk-QVN2WOKJ.js";
17
- import "./chunk-36J3IZBS.js";
17
+ import "./chunk-RSATPXU4.js";
18
18
  import "./chunk-77WWLBCI.js";
19
19
  import "./chunk-4TR3HZFT.js";
20
20
  import "./chunk-WDRMZKVB.js";
@@ -9,12 +9,12 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-O4324MXE.js";
13
- import "./chunk-5HPMKLJ7.js";
12
+ } from "./chunk-E7G7RY6T.js";
13
+ import "./chunk-6SGYGYH7.js";
14
14
  import "./chunk-N2WW62LF.js";
15
15
  import "./chunk-DD67JWTN.js";
16
16
  import "./chunk-2UG25RMK.js";
17
- import "./chunk-MVZO7QZ2.js";
17
+ import "./chunk-BU6HH5VA.js";
18
18
  import "./chunk-NSTQ6QKD.js";
19
19
  import "./chunk-WWUABK6B.js";
20
20
  import "./chunk-FJZWM2ON.js";
@@ -18,14 +18,14 @@ import {
18
18
  remoteCoordinatorSourceRef,
19
19
  slackCoordinatorSourceRef,
20
20
  takenTeamSlugsForOrchestration
21
- } from "./chunk-V3BSO2O6.js";
22
- import "./chunk-2IXKTAIT.js";
21
+ } from "./chunk-YEIPPZ5W.js";
22
+ import "./chunk-ZEP6JIRF.js";
23
23
  import "./chunk-QB5MDOHL.js";
24
24
  import "./chunk-2P4XKWV2.js";
25
25
  import "./chunk-6K64FJDD.js";
26
26
  import "./chunk-UWQ6UCIB.js";
27
27
  import "./chunk-QVN2WOKJ.js";
28
- import "./chunk-36J3IZBS.js";
28
+ import "./chunk-RSATPXU4.js";
29
29
  import "./chunk-77WWLBCI.js";
30
30
  import "./chunk-4TR3HZFT.js";
31
31
  import "./chunk-WDRMZKVB.js";
@@ -20,12 +20,12 @@ import {
20
20
  remoteCoordinatorSourceRef,
21
21
  slackCoordinatorSourceRef,
22
22
  takenTeamSlugsForOrchestration
23
- } from "./chunk-O4324MXE.js";
24
- import "./chunk-5HPMKLJ7.js";
23
+ } from "./chunk-E7G7RY6T.js";
24
+ import "./chunk-6SGYGYH7.js";
25
25
  import "./chunk-N2WW62LF.js";
26
26
  import "./chunk-DD67JWTN.js";
27
27
  import "./chunk-2UG25RMK.js";
28
- import "./chunk-MVZO7QZ2.js";
28
+ import "./chunk-BU6HH5VA.js";
29
29
  import "./chunk-NSTQ6QKD.js";
30
30
  import "./chunk-WWUABK6B.js";
31
31
  import "./chunk-FJZWM2ON.js";