@sideboard-ai/core 0.1.144 → 0.1.146

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 (31) hide show
  1. package/dist/{agents-OEEOIKUB.js → agents-N3KMRQUZ.js} +4 -4
  2. package/dist/{agents-E5AAMHDY.js → agents-YVETHB2R.js} +4 -4
  3. package/dist/{chunk-CG25RYQQ.js → chunk-4RYRNJPN.js} +3 -3
  4. package/dist/{chunk-OHWN4JEL.js → chunk-67K3FRKR.js} +1 -1
  5. package/dist/{chunk-R2W7A2UO.js → chunk-IHSR7EVK.js} +2 -2
  6. package/dist/{chunk-HC5N3BDL.js → chunk-JHZ6HGRI.js} +2 -2
  7. package/dist/{chunk-4Q45TLZ5.js → chunk-JTPDWTWJ.js} +194 -42
  8. package/dist/{chunk-4D4PEBGB.js → chunk-JW436RTA.js} +2 -2
  9. package/dist/{chunk-FADNFPZO.js → chunk-KNE3FZ46.js} +2 -2
  10. package/dist/{chunk-OLR4UPP7.js → chunk-KZG47SZP.js} +45 -14
  11. package/dist/{chunk-UG5N7ET3.js → chunk-SXPTL222.js} +1 -1
  12. package/dist/{chunk-VHTIHOHE.js → chunk-WWH4NNBH.js} +3 -3
  13. package/dist/{chunk-O3JEC2UJ.js → chunk-YP3CSOZ6.js} +194 -42
  14. package/dist/{chunk-FGT26PJE.js → chunk-ZZBN2MR7.js} +45 -14
  15. package/dist/{coordinator-prompt-FBX7Y4EM.js → coordinator-prompt-2EOR35TP.js} +2 -2
  16. package/dist/{coordinator-prompt-2LD3C74O.js → coordinator-prompt-6EPVHVGJ.js} +2 -2
  17. package/dist/{global-workspace-NG7SU3GV.js → global-workspace-EZVQPMWT.js} +3 -3
  18. package/dist/{global-workspace-OCV77UYF.js → global-workspace-PANZGRUS.js} +3 -3
  19. package/dist/index.cjs +232 -42
  20. package/dist/index.d.cts +42 -1
  21. package/dist/index.d.ts +42 -1
  22. package/dist/index.js +16 -6
  23. package/dist/mcp/run-stdio.cjs +222 -42
  24. package/dist/mcp/run-stdio.js +6 -6
  25. package/dist/{orchestrator-DB5ZSE6M.js → orchestrator-KWV2PPML.js} +6 -6
  26. package/dist/{orchestrator-IQGVBBSH.js → orchestrator-T35BJZWY.js} +6 -6
  27. package/dist/{workspaces-4FUQW5LD.js → workspaces-DWERPUQJ.js} +4 -4
  28. package/dist/{workspaces-PU5YHQ7Z.js → workspaces-ZJATBC4A.js} +4 -4
  29. package/dist/{worktree-GKLPPNWR.js → worktree-RZRJNHYL.js} +11 -1
  30. package/dist/{worktree-Z22HTSCU.js → worktree-UCWWTVLS.js} +11 -1
  31. package/package.json +1 -1
@@ -36,7 +36,7 @@ import {
36
36
  resolveQuotaFallbackAgent,
37
37
  turnCostUsdFromCursorUsage,
38
38
  whichOnPath
39
- } from "./chunk-CG25RYQQ.js";
39
+ } from "./chunk-4RYRNJPN.js";
40
40
  import "./chunk-ED4UPEJX.js";
41
41
  import "./chunk-S42XV45P.js";
42
42
  import "./chunk-6GN5WPYZ.js";
@@ -45,9 +45,9 @@ import {
45
45
  assertOrchestratorCapableAgent,
46
46
  coerceOrchestratorAgent,
47
47
  isOrchestratorCapableAgent
48
- } from "./chunk-FADNFPZO.js";
49
- import "./chunk-OHWN4JEL.js";
50
- import "./chunk-4Q45TLZ5.js";
48
+ } from "./chunk-KNE3FZ46.js";
49
+ import "./chunk-67K3FRKR.js";
50
+ import "./chunk-JTPDWTWJ.js";
51
51
  import "./chunk-B3SJXYIJ.js";
52
52
  import "./chunk-EUXOHTUK.js";
53
53
  import {
@@ -30,7 +30,7 @@ import {
30
30
  resolveLoginCommand,
31
31
  resolveQuotaFallbackAgent,
32
32
  whichOnPath
33
- } from "./chunk-VHTIHOHE.js";
33
+ } from "./chunk-WWH4NNBH.js";
34
34
  import "./chunk-KBWND62T.js";
35
35
  import "./chunk-M267JPEA.js";
36
36
  import {
@@ -38,8 +38,8 @@ import {
38
38
  assertOrchestratorCapableAgent,
39
39
  coerceOrchestratorAgent,
40
40
  isOrchestratorCapableAgent
41
- } from "./chunk-R2W7A2UO.js";
42
- import "./chunk-UG5N7ET3.js";
41
+ } from "./chunk-IHSR7EVK.js";
42
+ import "./chunk-SXPTL222.js";
43
43
  import "./chunk-ELBYOGVA.js";
44
44
  import {
45
45
  cursorSdkMessageToEvents,
@@ -47,7 +47,7 @@ import {
47
47
  preferredCursorCostCents,
48
48
  turnCostUsdFromCursorUsage
49
49
  } from "./chunk-WT5HSFOU.js";
50
- import "./chunk-O3JEC2UJ.js";
50
+ import "./chunk-YP3CSOZ6.js";
51
51
  import "./chunk-FKOIHGKV.js";
52
52
  import "./chunk-I77RYPOH.js";
53
53
  import "./chunk-4TR3HZFT.js";
@@ -11,13 +11,13 @@ import {
11
11
  } from "./chunk-S42XV45P.js";
12
12
  import {
13
13
  isOrchestratorThread
14
- } from "./chunk-FADNFPZO.js";
14
+ } from "./chunk-KNE3FZ46.js";
15
15
  import {
16
16
  codexUnattendedGitConfigArgs,
17
17
  mergeAgentGitAuthEnv,
18
18
  resolveAgentGitAuthEnv,
19
19
  resolveCodexGitWritableRoots
20
- } from "./chunk-4Q45TLZ5.js";
20
+ } from "./chunk-JTPDWTWJ.js";
21
21
  import {
22
22
  enrichPathWithNpmGlobalBin,
23
23
  isConductorBundledCli,
@@ -2085,7 +2085,7 @@ var claudeAdapter = {
2085
2085
  );
2086
2086
  }
2087
2087
  const mode = permissionMode(thread);
2088
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-OCV77UYF.js");
2088
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-PANZGRUS.js");
2089
2089
  const isOrchestrator = isOrchestratorThread2(thread);
2090
2090
  const injectedServers = await buildInjectedMcpServers({
2091
2091
  includeSideboard: true,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  resolveGithubRepoSlug
5
- } from "./chunk-4Q45TLZ5.js";
5
+ } from "./chunk-JTPDWTWJ.js";
6
6
  import {
7
7
  resolveThreadDefaults
8
8
  } from "./chunk-BGQBELGJ.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ensureGlobalCoordinatorCwd
3
- } from "./chunk-UG5N7ET3.js";
3
+ } from "./chunk-SXPTL222.js";
4
4
  import {
5
5
  allocateTeamName,
6
6
  takenSlugsFromThread,
7
7
  teamSlugFromName
8
- } from "./chunk-O3JEC2UJ.js";
8
+ } from "./chunk-YP3CSOZ6.js";
9
9
  import {
10
10
  ATTACHMENTS_DIR,
11
11
  attachmentsGitignoreBody
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  isGlobalRepoPath
3
- } from "./chunk-R2W7A2UO.js";
3
+ } from "./chunk-IHSR7EVK.js";
4
4
  import {
5
5
  ensureGhPreferOrigin,
6
6
  resolveRepoRoot
7
- } from "./chunk-O3JEC2UJ.js";
7
+ } from "./chunk-YP3CSOZ6.js";
8
8
  import {
9
9
  appDataDir
10
10
  } from "./chunk-QZQEXME2.js";
@@ -2215,45 +2215,128 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2215
2215
  function isLocalPrFetchBranch(ref) {
2216
2216
  return /^sideboard-pr-\d+$/.test(ref.trim());
2217
2217
  }
2218
- async function createThreadWorktree(opts) {
2219
- let branchName = `thread/${opts.slug}`;
2220
- const worktreePath = join2(worktreesRoot(opts.repoPath), opts.slug);
2221
- if (existsSync2(worktreePath)) {
2222
- throw new Error(`Worktree already exists at ${worktreePath}`);
2218
+ function originFetchBranch(sourceRef) {
2219
+ const ref = sourceRef.trim();
2220
+ if (!ref || isLocalPrFetchBranch(ref)) return null;
2221
+ if (ref.startsWith("refs/remotes/origin/")) {
2222
+ return ref.slice("refs/remotes/origin/".length) || null;
2223
2223
  }
2224
- await ensureGhPreferOrigin(opts.repoPath);
2225
- let startPoint = null;
2224
+ if (ref.startsWith("refs/heads/")) {
2225
+ return ref.slice("refs/heads/".length) || null;
2226
+ }
2227
+ if (ref.startsWith("refs/")) return null;
2228
+ if (ref.startsWith("origin/")) return ref.slice("origin/".length) || null;
2229
+ return ref;
2230
+ }
2231
+ async function fetchOriginWithAuth(repoPath, args, timeoutMs) {
2232
+ const first = await git(args, repoPath, { reject: false, timeoutMs });
2233
+ if (first.exitCode === 0) return true;
2234
+ let mode;
2226
2235
  try {
2227
- startPoint = await resolveWorktreeStartPoint(opts.repoPath, opts.sourceRef);
2236
+ mode = getGithubGitAuthMode();
2228
2237
  } catch {
2229
- startPoint = null;
2238
+ return false;
2230
2239
  }
2231
- if (!isLocalPrFetchBranch(opts.sourceRef)) {
2232
- const fetchTimeoutMs = startPoint ? 12e3 : 45e3;
2233
- await git(["fetch", "origin", "--prune"], opts.repoPath, {
2234
- reject: false,
2235
- timeoutMs: fetchTimeoutMs
2240
+ if (mode === "ssh") return false;
2241
+ const token = await resolveGithubAgentToken(mode, repoPath);
2242
+ if (!token) return false;
2243
+ const tryHttps = async (header) => git(args, repoPath, {
2244
+ reject: false,
2245
+ timeoutMs,
2246
+ env: { GIT_TERMINAL_PROMPT: "0" },
2247
+ config: {
2248
+ "url.https://github.com/.insteadOf": "git@github.com:",
2249
+ "http.extraHeader": header
2250
+ }
2251
+ });
2252
+ const bearer = await tryHttps(`AUTHORIZATION: bearer ${token}`);
2253
+ if (bearer.exitCode === 0) return true;
2254
+ const basic = Buffer.from(`x-access-token:${token}`, "utf8").toString("base64");
2255
+ const basicFetch = await tryHttps(`Authorization: Basic ${basic}`);
2256
+ return basicFetch.exitCode === 0;
2257
+ }
2258
+ async function fetchOriginForWorktree(repoPath, sourceRef, opts) {
2259
+ const timeoutMs = opts?.timeoutMs ?? 2e4;
2260
+ const branch = originFetchBranch(sourceRef);
2261
+ if (!branch) return false;
2262
+ const tipOk = await fetchOriginWithAuth(
2263
+ repoPath,
2264
+ ["fetch", "origin", branch],
2265
+ timeoutMs
2266
+ );
2267
+ await fetchOriginWithAuth(repoPath, ["fetch", "origin", "--prune"], timeoutMs);
2268
+ return tipOk;
2269
+ }
2270
+ async function fastForwardMainCheckoutIfSafe(repoPath, opts) {
2271
+ try {
2272
+ const branch = opts?.branch?.trim() || await resolveDefaultBranch(repoPath, { network: false });
2273
+ const head = await git(["rev-parse", "--abbrev-ref", "HEAD"], repoPath, {
2274
+ reject: false
2236
2275
  });
2237
- if (!opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2238
- await git(["fetch", "origin", opts.sourceRef], opts.repoPath, {
2239
- reject: false,
2240
- timeoutMs: fetchTimeoutMs
2241
- });
2276
+ const current = head.stdout.trim();
2277
+ if (head.exitCode !== 0 || !current || current === "HEAD" || current !== branch) {
2278
+ return { updated: false, reason: "not-on-default" };
2242
2279
  }
2243
- try {
2244
- startPoint = await resolveWorktreeStartPoint(
2245
- opts.repoPath,
2246
- opts.sourceRef
2247
- );
2248
- } catch (err) {
2249
- if (!startPoint) throw err;
2280
+ if (await isDirty(repoPath)) {
2281
+ return { updated: false, reason: "dirty" };
2250
2282
  }
2251
- }
2252
- if (!startPoint) {
2253
- throw new Error(
2254
- `Invalid git reference: ${opts.sourceRef} (and fetch did not resolve it)`
2283
+ const remote = `origin/${branch}`;
2284
+ const remoteOk = await git(["rev-parse", "--verify", remote], repoPath, {
2285
+ reject: false
2286
+ });
2287
+ if (remoteOk.exitCode !== 0) {
2288
+ return { updated: false, reason: "no-origin-tip" };
2289
+ }
2290
+ const ancestor = await git(
2291
+ ["merge-base", "--is-ancestor", "HEAD", remote],
2292
+ repoPath,
2293
+ { reject: false }
2294
+ );
2295
+ if (ancestor.exitCode !== 0) {
2296
+ return { updated: false, reason: "diverged" };
2297
+ }
2298
+ const behind = await git(
2299
+ ["rev-list", "--count", `HEAD..${remote}`],
2300
+ repoPath,
2301
+ { reject: false }
2255
2302
  );
2303
+ const n = Number(behind.stdout.trim());
2304
+ if (behind.exitCode !== 0 || !Number.isFinite(n) || n <= 0) {
2305
+ return { updated: false, reason: "already-current" };
2306
+ }
2307
+ const ff = await git(["merge", "--ff-only", remote], repoPath, {
2308
+ reject: false
2309
+ });
2310
+ if (ff.exitCode !== 0) {
2311
+ return { updated: false, reason: "ff-failed" };
2312
+ }
2313
+ return { updated: true, reason: "updated" };
2314
+ } catch {
2315
+ return { updated: false, reason: "ff-failed" };
2316
+ }
2317
+ }
2318
+ async function refreshOriginAndMaybeFastForwardMain(repoPath, sourceRef) {
2319
+ if (!isLocalPrFetchBranch(sourceRef)) {
2320
+ await fetchOriginForWorktree(repoPath, sourceRef);
2321
+ }
2322
+ const def = await resolveDefaultBranch(repoPath, { network: false });
2323
+ if (originFetchBranch(sourceRef) !== def) {
2324
+ await fetchOriginForWorktree(repoPath, def);
2256
2325
  }
2326
+ await fastForwardMainCheckoutIfSafe(repoPath, { branch: def });
2327
+ }
2328
+ async function createThreadWorktree(opts) {
2329
+ let branchName = `thread/${opts.slug}`;
2330
+ const worktreePath = join2(worktreesRoot(opts.repoPath), opts.slug);
2331
+ if (existsSync2(worktreePath)) {
2332
+ throw new Error(`Worktree already exists at ${worktreePath}`);
2333
+ }
2334
+ await ensureGhPreferOrigin(opts.repoPath);
2335
+ await refreshOriginAndMaybeFastForwardMain(opts.repoPath, opts.sourceRef);
2336
+ const startPoint = await resolveWorktreeStartPoint(
2337
+ opts.repoPath,
2338
+ opts.sourceRef
2339
+ );
2257
2340
  const added = await withRepoGitLock(opts.repoPath, async () => {
2258
2341
  const add = await git(
2259
2342
  ["worktree", "add", "-b", branchName, worktreePath, startPoint],
@@ -2290,10 +2373,7 @@ async function createExistingBranchWorktree(opts) {
2290
2373
  throw new Error(`Worktree already exists at ${worktreePath}`);
2291
2374
  }
2292
2375
  await ensureGhPreferOrigin(opts.repoPath);
2293
- await git(["fetch", "origin", "--prune"], opts.repoPath, { reject: false });
2294
- if (!branchName.startsWith("origin/") && !branchName.startsWith("refs/")) {
2295
- await git(["fetch", "origin", branchName], opts.repoPath, { reject: false });
2296
- }
2376
+ await refreshOriginAndMaybeFastForwardMain(opts.repoPath, branchName);
2297
2377
  const existing = await listWorktrees(opts.repoPath);
2298
2378
  const already = existing.find((w) => w.branch === branchName);
2299
2379
  if (already?.path) {
@@ -2359,6 +2439,32 @@ async function listWorktrees(repoPath) {
2359
2439
  if (current) entries.push(current);
2360
2440
  return entries;
2361
2441
  }
2442
+ async function countUnpushedVsOrigin(worktreePath) {
2443
+ const head = await git(["rev-parse", "--abbrev-ref", "HEAD"], worktreePath, {
2444
+ reject: false
2445
+ });
2446
+ const branch = head.stdout.trim();
2447
+ if (branch && branch !== "HEAD") {
2448
+ const remote = await git(
2449
+ ["rev-list", "--count", `origin/${branch}..HEAD`],
2450
+ worktreePath,
2451
+ { reject: false }
2452
+ );
2453
+ if (remote.exitCode === 0) {
2454
+ const n = Number(remote.stdout.trim());
2455
+ return Number.isFinite(n) ? n : 1;
2456
+ }
2457
+ const all = await git(["rev-list", "--count", "HEAD"], worktreePath, {
2458
+ reject: false
2459
+ });
2460
+ if (all.exitCode === 0) {
2461
+ const n = Number(all.stdout.trim());
2462
+ if (Number.isFinite(n) && n > 0) return n;
2463
+ }
2464
+ return 1;
2465
+ }
2466
+ return 1;
2467
+ }
2362
2468
  async function isDirty(worktreePath) {
2363
2469
  const { stdout } = await git(["status", "--porcelain"], worktreePath);
2364
2470
  for (const line of stdout.split("\n")) {
@@ -2422,6 +2528,54 @@ async function pushBranch(worktreePath, branchName) {
2422
2528
  const httpsErr = (basicPush.stderr || bearer.stderr || bearer.stdout).trim();
2423
2529
  throw new Error(httpsErr || sshErr || `git push origin ${branchName} failed`);
2424
2530
  }
2531
+ async function runPrReady(cwd, selector, slug) {
2532
+ const readyArgs = ["pr", "ready", selector];
2533
+ if (slug) readyArgs.push("--repo", slug);
2534
+ const ready = await gh(readyArgs, cwd, { reject: false });
2535
+ if (ready.exitCode !== 0) {
2536
+ throw new Error(
2537
+ ready.stderr.trim() || ready.stdout.trim() || "Could not mark draft pull request as ready"
2538
+ );
2539
+ }
2540
+ }
2541
+ async function markPrReady(cwd, selector) {
2542
+ const slug = await resolveGithubRepoSlug(cwd);
2543
+ const viewArgs = ["pr", "view", selector, "--json", "url,state,isDraft"];
2544
+ if (slug) viewArgs.push("--repo", slug);
2545
+ const before = await gh(viewArgs, cwd, { reject: false });
2546
+ if (before.exitCode !== 0 || !before.stdout.trim()) {
2547
+ throw new Error(before.stderr.trim() || "Could not load pull request");
2548
+ }
2549
+ let url = "";
2550
+ let state = "";
2551
+ let isDraft = false;
2552
+ try {
2553
+ const parsed = JSON.parse(before.stdout);
2554
+ url = String(parsed.url ?? "");
2555
+ state = String(parsed.state ?? "").toUpperCase();
2556
+ isDraft = Boolean(parsed.isDraft);
2557
+ } catch {
2558
+ throw new Error("Could not parse pull request details");
2559
+ }
2560
+ if (state === "MERGED" || state === "CLOSED") {
2561
+ return { url, state, isDraft: false };
2562
+ }
2563
+ if (isDraft) {
2564
+ if (await isDirty(cwd)) {
2565
+ throw new Error(
2566
+ "Commit and push local work before marking the pull request ready for review."
2567
+ );
2568
+ }
2569
+ const unpushed = await countUnpushedVsOrigin(cwd);
2570
+ if (unpushed > 0) {
2571
+ throw new Error(
2572
+ "Push this branch to origin before marking the pull request ready for review."
2573
+ );
2574
+ }
2575
+ await runPrReady(cwd, selector, slug);
2576
+ }
2577
+ return { url, state: state || "OPEN", isDraft: false };
2578
+ }
2425
2579
  async function mergePr(cwd, selector, opts) {
2426
2580
  const slug = await resolveGithubRepoSlug(cwd);
2427
2581
  const viewArgs = ["pr", "view", selector, "--json", "url,state,isDraft,number"];
@@ -2456,14 +2610,7 @@ async function mergePr(cwd, selector, opts) {
2456
2610
  return { url, state: "MERGED" };
2457
2611
  }
2458
2612
  if (isDraft) {
2459
- const readyArgs = ["pr", "ready", selector];
2460
- if (slug) readyArgs.push("--repo", slug);
2461
- const ready = await gh(readyArgs, cwd, { reject: false });
2462
- if (ready.exitCode !== 0) {
2463
- throw new Error(
2464
- ready.stderr.trim() || ready.stdout.trim() || "Could not mark draft pull request as ready"
2465
- );
2466
- }
2613
+ await runPrReady(cwd, selector, slug);
2467
2614
  }
2468
2615
  const method = opts?.method ?? "squash";
2469
2616
  const mergeFlag = method === "rebase" ? "--rebase" : method === "merge" ? "--merge" : "--squash";
@@ -2668,15 +2815,20 @@ export {
2668
2815
  getPrDetails,
2669
2816
  fetchPrHead,
2670
2817
  resolveWorktreeStartPoint,
2818
+ originFetchBranch,
2819
+ fetchOriginForWorktree,
2820
+ fastForwardMainCheckoutIfSafe,
2671
2821
  createThreadWorktree,
2672
2822
  createExistingBranchWorktree,
2673
2823
  removeWorktree,
2674
2824
  listWorktrees,
2825
+ countUnpushedVsOrigin,
2675
2826
  isDirty,
2676
2827
  isSideboardScratchPath,
2677
2828
  currentBranch,
2678
2829
  commitAll,
2679
2830
  pushBranch,
2831
+ markPrReady,
2680
2832
  mergePr,
2681
2833
  createOrUpdatePr,
2682
2834
  suggestSlug,
@@ -2,11 +2,11 @@
2
2
 
3
3
  import {
4
4
  isGlobalRepoPath
5
- } from "./chunk-FADNFPZO.js";
5
+ } from "./chunk-KNE3FZ46.js";
6
6
  import {
7
7
  ensureGhPreferOrigin,
8
8
  resolveRepoRoot
9
- } from "./chunk-4Q45TLZ5.js";
9
+ } from "./chunk-JTPDWTWJ.js";
10
10
  import {
11
11
  appDataDir
12
12
  } from "./chunk-BD2ICC4D.js";
@@ -2,12 +2,12 @@
2
2
 
3
3
  import {
4
4
  ensureGlobalCoordinatorCwd
5
- } from "./chunk-OHWN4JEL.js";
5
+ } from "./chunk-67K3FRKR.js";
6
6
  import {
7
7
  allocateTeamName,
8
8
  takenSlugsFromThread,
9
9
  teamSlugFromName
10
- } from "./chunk-4Q45TLZ5.js";
10
+ } from "./chunk-JTPDWTWJ.js";
11
11
  import {
12
12
  ATTACHMENTS_DIR,
13
13
  attachmentsGitignoreBody
@@ -32,13 +32,13 @@ import {
32
32
  summarizeTurnStderr,
33
33
  toolDescription,
34
34
  turnFailChatText
35
- } from "./chunk-CG25RYQQ.js";
35
+ } from "./chunk-4RYRNJPN.js";
36
36
  import {
37
37
  addWorkspace,
38
38
  ensureWorkspace,
39
39
  removeWorkspace,
40
40
  syncWorkspacesFromThreads
41
- } from "./chunk-4D4PEBGB.js";
41
+ } from "./chunk-JW436RTA.js";
42
42
  import {
43
43
  extractPresentedPlan,
44
44
  readPlanFile,
@@ -63,14 +63,14 @@ import {
63
63
  persistPendingFileAttachments,
64
64
  stageAbsolutePathsAsAttachments,
65
65
  stageBuffersAsAttachments
66
- } from "./chunk-FADNFPZO.js";
66
+ } from "./chunk-KNE3FZ46.js";
67
67
  import {
68
68
  SLACK_REPLY_FORMATTING,
69
69
  coordinatorSystemPrompt,
70
70
  coordinatorTurnReminder,
71
71
  enrichWorkspacesWithGithub,
72
72
  ensureGlobalCoordinatorCwd
73
- } from "./chunk-OHWN4JEL.js";
73
+ } from "./chunk-67K3FRKR.js";
74
74
  import {
75
75
  addPrStackLayer,
76
76
  allocateTeamName,
@@ -83,6 +83,8 @@ import {
83
83
  currentBranch,
84
84
  detectGhStack,
85
85
  enqueueByKey,
86
+ fastForwardMainCheckoutIfSafe,
87
+ fetchOriginForWorktree,
86
88
  fetchPrHead,
87
89
  formatGhLandError,
88
90
  formatGitAuthModeDirective,
@@ -97,6 +99,7 @@ import {
97
99
  isPlaceholderBranch,
98
100
  isSideboardScratchPath,
99
101
  listWorktrees,
102
+ markPrReady,
100
103
  mergeAgentGitAuthEnv,
101
104
  mergePr,
102
105
  normalizeWorktreePath,
@@ -115,7 +118,7 @@ import {
115
118
  withRepoGitLock,
116
119
  worktreeDisplayLabelForGroup,
117
120
  worktreeNameFromPath
118
- } from "./chunk-4Q45TLZ5.js";
121
+ } from "./chunk-JTPDWTWJ.js";
119
122
  import {
120
123
  ATTACHMENTS_DIR,
121
124
  LEGACY_ATTACHMENTS_DIR
@@ -388,7 +391,7 @@ async function continueSourceThread(threadId, prompt) {
388
391
  await continueOnReply(threadId, prompt);
389
392
  return;
390
393
  }
391
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-IQGVBBSH.js");
394
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-T35BJZWY.js");
392
395
  await getOrchestrator2().send(threadId, prompt);
393
396
  } catch {
394
397
  }
@@ -729,9 +732,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
729
732
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
730
733
  );
731
734
  }
732
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-OCV77UYF.js");
735
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-PANZGRUS.js");
733
736
  if (isGlobalThread2(thread)) {
734
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-FBX7Y4EM.js");
737
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-2EOR35TP.js");
735
738
  ensureGlobalCoordinatorCwd2(
736
739
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
737
740
  );
@@ -2894,6 +2897,8 @@ async function createThread(input, _onSetupLine) {
2894
2897
  `Cowboy mode uses ${defaultBranch} in the project folder. Switch that checkout to ${defaultBranch} first (currently ${head}).`
2895
2898
  );
2896
2899
  }
2900
+ await fetchOriginForWorktree(repoPath, defaultBranch);
2901
+ await fastForwardMainCheckoutIfSafe(repoPath, { branch: defaultBranch });
2897
2902
  const explicitTitle2 = input.title?.trim();
2898
2903
  const thread2 = createEmptyThread({
2899
2904
  title: explicitTitle2 || `Cowboy \xB7 ${head}`,
@@ -3000,7 +3005,7 @@ async function createThread(input, _onSetupLine) {
3000
3005
  return readThread(thread.id) ?? thread;
3001
3006
  }
3002
3007
  async function listLinearIssues(agent, repoPath) {
3003
- const { getAdapter: getAdapter2 } = await import("./agents-OEEOIKUB.js");
3008
+ const { getAdapter: getAdapter2 } = await import("./agents-N3KMRQUZ.js");
3004
3009
  await requireAgent(agent, { requireLinear: true });
3005
3010
  const adapter = getAdapter2(agent);
3006
3011
  if (!adapter.listLinearIssues) {
@@ -3407,7 +3412,7 @@ async function adoptThread(input) {
3407
3412
  messages: input.messages ?? []
3408
3413
  });
3409
3414
  writeThread(thread);
3410
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4FUQW5LD.js");
3415
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-DWERPUQJ.js");
3411
3416
  await ensureWorkspace2(repoPath);
3412
3417
  return thread;
3413
3418
  }
@@ -5606,7 +5611,7 @@ function formatScheduledPrompt(name, prompt) {
5606
5611
  ${prompt}`;
5607
5612
  }
5608
5613
  async function defaultDeps() {
5609
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-IQGVBBSH.js");
5614
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-T35BJZWY.js");
5610
5615
  const orch = getOrchestrator2();
5611
5616
  return {
5612
5617
  findThread: (id) => findThreadByRef(id),
@@ -7131,6 +7136,32 @@ var Orchestrator = class {
7131
7136
  }
7132
7137
  return result;
7133
7138
  }
7139
+ async markPrReady(threadRef) {
7140
+ const { thread, selectors, cwd } = await this.withPrSelector(threadRef);
7141
+ this.assertNotGlobal(thread, "Ready for review");
7142
+ const selector = selectors[0];
7143
+ if (!selector) throw new Error("No pull request linked to this thread");
7144
+ const result = await markPrReady(cwd, selector);
7145
+ const meta = await getPrMeta(cwd, selector);
7146
+ if (meta) {
7147
+ await this.persistPrMetaAndMaybeArchive(thread, { ...meta, isDraft: false });
7148
+ return { url: meta.url || result.url, state: meta.state || result.state, isDraft: false };
7149
+ }
7150
+ await this.persistPrMetaAndMaybeArchive(thread, {
7151
+ number: 0,
7152
+ title: thread.prTitle ?? thread.title,
7153
+ url: result.url || thread.prUrl || "",
7154
+ state: result.state || "OPEN",
7155
+ isDraft: false,
7156
+ reviewDecision: null,
7157
+ baseRefName: "",
7158
+ headRefName: "",
7159
+ isInMergeQueue: false,
7160
+ mergeable: null,
7161
+ mergeStateStatus: null
7162
+ });
7163
+ return { ...result, isDraft: false };
7164
+ }
7134
7165
  async mergePr(threadRef) {
7135
7166
  const { thread, selectors, cwd } = await this.withPrSelector(threadRef);
7136
7167
  this.assertNotGlobal(thread, "Merge PR");
@@ -7516,7 +7547,7 @@ var Orchestrator = class {
7516
7547
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
7517
7548
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
7518
7549
  try {
7519
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4FUQW5LD.js");
7550
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-DWERPUQJ.js");
7520
7551
  await ensureWorkspace2(thread.repoPath);
7521
7552
  } catch {
7522
7553
  }
@@ -7570,7 +7601,7 @@ var Orchestrator = class {
7570
7601
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
7571
7602
  );
7572
7603
  }
7573
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-Z22HTSCU.js");
7604
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-UCWWTVLS.js");
7574
7605
  const slug = thread.worktreePath.split("/").pop();
7575
7606
  const dest = thread.worktreePath;
7576
7607
  await withRepoGitLock(thread.repoPath, async () => {
@@ -7678,7 +7709,7 @@ async function startOrchestration(opts) {
7678
7709
  sourceRef: "default",
7679
7710
  ...createOpts
7680
7711
  }).catch(async () => {
7681
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-Z22HTSCU.js");
7712
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-UCWWTVLS.js");
7682
7713
  const repo = await resolveRepoRoot2(repoPath);
7683
7714
  const def = await resolveDefaultBranch2(repo);
7684
7715
  return orch.createThread({
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveGithubRepoSlug
3
- } from "./chunk-O3JEC2UJ.js";
3
+ } from "./chunk-YP3CSOZ6.js";
4
4
  import {
5
5
  resolveThreadDefaults
6
6
  } from "./chunk-I77RYPOH.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-M267JPEA.js";
10
10
  import {
11
11
  isOrchestratorThread
12
- } from "./chunk-R2W7A2UO.js";
12
+ } from "./chunk-IHSR7EVK.js";
13
13
  import {
14
14
  applyAgentRunnerHeapEnv,
15
15
  applyNodeLaunch,
@@ -28,7 +28,7 @@ import {
28
28
  mergeAgentGitAuthEnv,
29
29
  resolveAgentGitAuthEnv,
30
30
  resolveCodexGitWritableRoots
31
- } from "./chunk-O3JEC2UJ.js";
31
+ } from "./chunk-YP3CSOZ6.js";
32
32
  import {
33
33
  claudeChromeEnabled,
34
34
  loadAppSettings,
@@ -1767,7 +1767,7 @@ var claudeAdapter = {
1767
1767
  );
1768
1768
  }
1769
1769
  const mode = permissionMode(thread);
1770
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-NG7SU3GV.js");
1770
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-EZVQPMWT.js");
1771
1771
  const isOrchestrator = isOrchestratorThread2(thread);
1772
1772
  const injectedServers = await buildInjectedMcpServers({
1773
1773
  includeSideboard: true,