@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
@@ -2252,45 +2252,128 @@ async function resolveWorktreeStartPoint(repoPath, sourceRef) {
2252
2252
  function isLocalPrFetchBranch(ref) {
2253
2253
  return /^sideboard-pr-\d+$/.test(ref.trim());
2254
2254
  }
2255
- async function createThreadWorktree(opts) {
2256
- let branchName = `thread/${opts.slug}`;
2257
- const worktreePath = join2(worktreesRoot(opts.repoPath), opts.slug);
2258
- if (existsSync2(worktreePath)) {
2259
- throw new Error(`Worktree already exists at ${worktreePath}`);
2255
+ function originFetchBranch(sourceRef) {
2256
+ const ref = sourceRef.trim();
2257
+ if (!ref || isLocalPrFetchBranch(ref)) return null;
2258
+ if (ref.startsWith("refs/remotes/origin/")) {
2259
+ return ref.slice("refs/remotes/origin/".length) || null;
2260
2260
  }
2261
- await ensureGhPreferOrigin(opts.repoPath);
2262
- let startPoint = null;
2261
+ if (ref.startsWith("refs/heads/")) {
2262
+ return ref.slice("refs/heads/".length) || null;
2263
+ }
2264
+ if (ref.startsWith("refs/")) return null;
2265
+ if (ref.startsWith("origin/")) return ref.slice("origin/".length) || null;
2266
+ return ref;
2267
+ }
2268
+ async function fetchOriginWithAuth(repoPath, args, timeoutMs) {
2269
+ const first = await git(args, repoPath, { reject: false, timeoutMs });
2270
+ if (first.exitCode === 0) return true;
2271
+ let mode;
2263
2272
  try {
2264
- startPoint = await resolveWorktreeStartPoint(opts.repoPath, opts.sourceRef);
2273
+ mode = getGithubGitAuthMode();
2265
2274
  } catch {
2266
- startPoint = null;
2275
+ return false;
2267
2276
  }
2268
- if (!isLocalPrFetchBranch(opts.sourceRef)) {
2269
- const fetchTimeoutMs = startPoint ? 12e3 : 45e3;
2270
- await git(["fetch", "origin", "--prune"], opts.repoPath, {
2271
- reject: false,
2272
- timeoutMs: fetchTimeoutMs
2277
+ if (mode === "ssh") return false;
2278
+ const token = await resolveGithubAgentToken(mode, repoPath);
2279
+ if (!token) return false;
2280
+ const tryHttps = async (header) => git(args, repoPath, {
2281
+ reject: false,
2282
+ timeoutMs,
2283
+ env: { GIT_TERMINAL_PROMPT: "0" },
2284
+ config: {
2285
+ "url.https://github.com/.insteadOf": "git@github.com:",
2286
+ "http.extraHeader": header
2287
+ }
2288
+ });
2289
+ const bearer = await tryHttps(`AUTHORIZATION: bearer ${token}`);
2290
+ if (bearer.exitCode === 0) return true;
2291
+ const basic = Buffer.from(`x-access-token:${token}`, "utf8").toString("base64");
2292
+ const basicFetch = await tryHttps(`Authorization: Basic ${basic}`);
2293
+ return basicFetch.exitCode === 0;
2294
+ }
2295
+ async function fetchOriginForWorktree(repoPath, sourceRef, opts) {
2296
+ const timeoutMs = opts?.timeoutMs ?? 2e4;
2297
+ const branch = originFetchBranch(sourceRef);
2298
+ if (!branch) return false;
2299
+ const tipOk = await fetchOriginWithAuth(
2300
+ repoPath,
2301
+ ["fetch", "origin", branch],
2302
+ timeoutMs
2303
+ );
2304
+ await fetchOriginWithAuth(repoPath, ["fetch", "origin", "--prune"], timeoutMs);
2305
+ return tipOk;
2306
+ }
2307
+ async function fastForwardMainCheckoutIfSafe(repoPath, opts) {
2308
+ try {
2309
+ const branch = opts?.branch?.trim() || await resolveDefaultBranch(repoPath, { network: false });
2310
+ const head = await git(["rev-parse", "--abbrev-ref", "HEAD"], repoPath, {
2311
+ reject: false
2273
2312
  });
2274
- if (!opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2275
- await git(["fetch", "origin", opts.sourceRef], opts.repoPath, {
2276
- reject: false,
2277
- timeoutMs: fetchTimeoutMs
2278
- });
2313
+ const current = head.stdout.trim();
2314
+ if (head.exitCode !== 0 || !current || current === "HEAD" || current !== branch) {
2315
+ return { updated: false, reason: "not-on-default" };
2279
2316
  }
2280
- try {
2281
- startPoint = await resolveWorktreeStartPoint(
2282
- opts.repoPath,
2283
- opts.sourceRef
2284
- );
2285
- } catch (err) {
2286
- if (!startPoint) throw err;
2317
+ if (await isDirty(repoPath)) {
2318
+ return { updated: false, reason: "dirty" };
2287
2319
  }
2288
- }
2289
- if (!startPoint) {
2290
- throw new Error(
2291
- `Invalid git reference: ${opts.sourceRef} (and fetch did not resolve it)`
2320
+ const remote = `origin/${branch}`;
2321
+ const remoteOk = await git(["rev-parse", "--verify", remote], repoPath, {
2322
+ reject: false
2323
+ });
2324
+ if (remoteOk.exitCode !== 0) {
2325
+ return { updated: false, reason: "no-origin-tip" };
2326
+ }
2327
+ const ancestor = await git(
2328
+ ["merge-base", "--is-ancestor", "HEAD", remote],
2329
+ repoPath,
2330
+ { reject: false }
2331
+ );
2332
+ if (ancestor.exitCode !== 0) {
2333
+ return { updated: false, reason: "diverged" };
2334
+ }
2335
+ const behind = await git(
2336
+ ["rev-list", "--count", `HEAD..${remote}`],
2337
+ repoPath,
2338
+ { reject: false }
2292
2339
  );
2340
+ const n = Number(behind.stdout.trim());
2341
+ if (behind.exitCode !== 0 || !Number.isFinite(n) || n <= 0) {
2342
+ return { updated: false, reason: "already-current" };
2343
+ }
2344
+ const ff = await git(["merge", "--ff-only", remote], repoPath, {
2345
+ reject: false
2346
+ });
2347
+ if (ff.exitCode !== 0) {
2348
+ return { updated: false, reason: "ff-failed" };
2349
+ }
2350
+ return { updated: true, reason: "updated" };
2351
+ } catch {
2352
+ return { updated: false, reason: "ff-failed" };
2353
+ }
2354
+ }
2355
+ async function refreshOriginAndMaybeFastForwardMain(repoPath, sourceRef) {
2356
+ if (!isLocalPrFetchBranch(sourceRef)) {
2357
+ await fetchOriginForWorktree(repoPath, sourceRef);
2358
+ }
2359
+ const def = await resolveDefaultBranch(repoPath, { network: false });
2360
+ if (originFetchBranch(sourceRef) !== def) {
2361
+ await fetchOriginForWorktree(repoPath, def);
2293
2362
  }
2363
+ await fastForwardMainCheckoutIfSafe(repoPath, { branch: def });
2364
+ }
2365
+ async function createThreadWorktree(opts) {
2366
+ let branchName = `thread/${opts.slug}`;
2367
+ const worktreePath = join2(worktreesRoot(opts.repoPath), opts.slug);
2368
+ if (existsSync2(worktreePath)) {
2369
+ throw new Error(`Worktree already exists at ${worktreePath}`);
2370
+ }
2371
+ await ensureGhPreferOrigin(opts.repoPath);
2372
+ await refreshOriginAndMaybeFastForwardMain(opts.repoPath, opts.sourceRef);
2373
+ const startPoint = await resolveWorktreeStartPoint(
2374
+ opts.repoPath,
2375
+ opts.sourceRef
2376
+ );
2294
2377
  const added = await withRepoGitLock(opts.repoPath, async () => {
2295
2378
  const add = await git(
2296
2379
  ["worktree", "add", "-b", branchName, worktreePath, startPoint],
@@ -2327,10 +2410,7 @@ async function createExistingBranchWorktree(opts) {
2327
2410
  throw new Error(`Worktree already exists at ${worktreePath}`);
2328
2411
  }
2329
2412
  await ensureGhPreferOrigin(opts.repoPath);
2330
- await git(["fetch", "origin", "--prune"], opts.repoPath, { reject: false });
2331
- if (!branchName.startsWith("origin/") && !branchName.startsWith("refs/")) {
2332
- await git(["fetch", "origin", branchName], opts.repoPath, { reject: false });
2333
- }
2413
+ await refreshOriginAndMaybeFastForwardMain(opts.repoPath, branchName);
2334
2414
  const existing = await listWorktrees(opts.repoPath);
2335
2415
  const already = existing.find((w) => w.branch === branchName);
2336
2416
  if (already?.path) {
@@ -2396,6 +2476,32 @@ async function listWorktrees(repoPath) {
2396
2476
  if (current) entries.push(current);
2397
2477
  return entries;
2398
2478
  }
2479
+ async function countUnpushedVsOrigin(worktreePath) {
2480
+ const head = await git(["rev-parse", "--abbrev-ref", "HEAD"], worktreePath, {
2481
+ reject: false
2482
+ });
2483
+ const branch = head.stdout.trim();
2484
+ if (branch && branch !== "HEAD") {
2485
+ const remote = await git(
2486
+ ["rev-list", "--count", `origin/${branch}..HEAD`],
2487
+ worktreePath,
2488
+ { reject: false }
2489
+ );
2490
+ if (remote.exitCode === 0) {
2491
+ const n = Number(remote.stdout.trim());
2492
+ return Number.isFinite(n) ? n : 1;
2493
+ }
2494
+ const all = await git(["rev-list", "--count", "HEAD"], worktreePath, {
2495
+ reject: false
2496
+ });
2497
+ if (all.exitCode === 0) {
2498
+ const n = Number(all.stdout.trim());
2499
+ if (Number.isFinite(n) && n > 0) return n;
2500
+ }
2501
+ return 1;
2502
+ }
2503
+ return 1;
2504
+ }
2399
2505
  async function isDirty(worktreePath) {
2400
2506
  const { stdout } = await git(["status", "--porcelain"], worktreePath);
2401
2507
  for (const line of stdout.split("\n")) {
@@ -2459,6 +2565,54 @@ async function pushBranch(worktreePath, branchName) {
2459
2565
  const httpsErr = (basicPush.stderr || bearer.stderr || bearer.stdout).trim();
2460
2566
  throw new Error(httpsErr || sshErr || `git push origin ${branchName} failed`);
2461
2567
  }
2568
+ async function runPrReady(cwd, selector, slug) {
2569
+ const readyArgs = ["pr", "ready", selector];
2570
+ if (slug) readyArgs.push("--repo", slug);
2571
+ const ready = await gh(readyArgs, cwd, { reject: false });
2572
+ if (ready.exitCode !== 0) {
2573
+ throw new Error(
2574
+ ready.stderr.trim() || ready.stdout.trim() || "Could not mark draft pull request as ready"
2575
+ );
2576
+ }
2577
+ }
2578
+ async function markPrReady(cwd, selector) {
2579
+ const slug = await resolveGithubRepoSlug(cwd);
2580
+ const viewArgs = ["pr", "view", selector, "--json", "url,state,isDraft"];
2581
+ if (slug) viewArgs.push("--repo", slug);
2582
+ const before = await gh(viewArgs, cwd, { reject: false });
2583
+ if (before.exitCode !== 0 || !before.stdout.trim()) {
2584
+ throw new Error(before.stderr.trim() || "Could not load pull request");
2585
+ }
2586
+ let url = "";
2587
+ let state = "";
2588
+ let isDraft = false;
2589
+ try {
2590
+ const parsed = JSON.parse(before.stdout);
2591
+ url = String(parsed.url ?? "");
2592
+ state = String(parsed.state ?? "").toUpperCase();
2593
+ isDraft = Boolean(parsed.isDraft);
2594
+ } catch {
2595
+ throw new Error("Could not parse pull request details");
2596
+ }
2597
+ if (state === "MERGED" || state === "CLOSED") {
2598
+ return { url, state, isDraft: false };
2599
+ }
2600
+ if (isDraft) {
2601
+ if (await isDirty(cwd)) {
2602
+ throw new Error(
2603
+ "Commit and push local work before marking the pull request ready for review."
2604
+ );
2605
+ }
2606
+ const unpushed = await countUnpushedVsOrigin(cwd);
2607
+ if (unpushed > 0) {
2608
+ throw new Error(
2609
+ "Push this branch to origin before marking the pull request ready for review."
2610
+ );
2611
+ }
2612
+ await runPrReady(cwd, selector, slug);
2613
+ }
2614
+ return { url, state: state || "OPEN", isDraft: false };
2615
+ }
2462
2616
  async function mergePr(cwd, selector, opts) {
2463
2617
  const slug = await resolveGithubRepoSlug(cwd);
2464
2618
  const viewArgs = ["pr", "view", selector, "--json", "url,state,isDraft,number"];
@@ -2493,14 +2647,7 @@ async function mergePr(cwd, selector, opts) {
2493
2647
  return { url, state: "MERGED" };
2494
2648
  }
2495
2649
  if (isDraft) {
2496
- const readyArgs = ["pr", "ready", selector];
2497
- if (slug) readyArgs.push("--repo", slug);
2498
- const ready = await gh(readyArgs, cwd, { reject: false });
2499
- if (ready.exitCode !== 0) {
2500
- throw new Error(
2501
- ready.stderr.trim() || ready.stdout.trim() || "Could not mark draft pull request as ready"
2502
- );
2503
- }
2650
+ await runPrReady(cwd, selector, slug);
2504
2651
  }
2505
2652
  const method = opts?.method ?? "squash";
2506
2653
  const mergeFlag = method === "rebase" ? "--rebase" : method === "merge" ? "--merge" : "--squash";
@@ -2725,15 +2872,20 @@ export {
2725
2872
  getPrDetails,
2726
2873
  fetchPrHead,
2727
2874
  resolveWorktreeStartPoint,
2875
+ originFetchBranch,
2876
+ fetchOriginForWorktree,
2877
+ fastForwardMainCheckoutIfSafe,
2728
2878
  createThreadWorktree,
2729
2879
  createExistingBranchWorktree,
2730
2880
  removeWorktree,
2731
2881
  listWorktrees,
2882
+ countUnpushedVsOrigin,
2732
2883
  isDirty,
2733
2884
  isSideboardScratchPath,
2734
2885
  currentBranch,
2735
2886
  commitAll,
2736
2887
  pushBranch,
2888
+ markPrReady,
2737
2889
  mergePr,
2738
2890
  createOrUpdatePr,
2739
2891
  suggestSlug,
@@ -18,13 +18,13 @@ import {
18
18
  stripBrightsyNdjsonNoise,
19
19
  sumUsageList,
20
20
  toolDescription
21
- } from "./chunk-VHTIHOHE.js";
21
+ } from "./chunk-WWH4NNBH.js";
22
22
  import {
23
23
  addWorkspace,
24
24
  ensureWorkspace,
25
25
  removeWorkspace,
26
26
  syncWorkspacesFromThreads
27
- } from "./chunk-HC5N3BDL.js";
27
+ } from "./chunk-JHZ6HGRI.js";
28
28
  import {
29
29
  assertOrchestratorCapableAgent,
30
30
  attachmentsFromWorktreePaths,
@@ -41,14 +41,14 @@ import {
41
41
  persistPendingFileAttachments,
42
42
  stageAbsolutePathsAsAttachments,
43
43
  stageBuffersAsAttachments
44
- } from "./chunk-R2W7A2UO.js";
44
+ } from "./chunk-IHSR7EVK.js";
45
45
  import {
46
46
  SLACK_REPLY_FORMATTING,
47
47
  coordinatorSystemPrompt,
48
48
  coordinatorTurnReminder,
49
49
  enrichWorkspacesWithGithub,
50
50
  ensureGlobalCoordinatorCwd
51
- } from "./chunk-UG5N7ET3.js";
51
+ } from "./chunk-SXPTL222.js";
52
52
  import {
53
53
  httpFetch
54
54
  } from "./chunk-ELBYOGVA.js";
@@ -90,6 +90,8 @@ import {
90
90
  currentBranch,
91
91
  detectGhStack,
92
92
  enqueueByKey,
93
+ fastForwardMainCheckoutIfSafe,
94
+ fetchOriginForWorktree,
93
95
  fetchPrHead,
94
96
  formatGhLandError,
95
97
  formatGitAuthModeDirective,
@@ -104,6 +106,7 @@ import {
104
106
  isPlaceholderBranch,
105
107
  isSideboardScratchPath,
106
108
  listWorktrees,
109
+ markPrReady,
107
110
  mergeAgentGitAuthEnv,
108
111
  mergePr,
109
112
  normalizeWorktreePath,
@@ -122,7 +125,7 @@ import {
122
125
  withRepoGitLock,
123
126
  worktreeDisplayLabelForGroup,
124
127
  worktreeNameFromPath
125
- } from "./chunk-O3JEC2UJ.js";
128
+ } from "./chunk-YP3CSOZ6.js";
126
129
  import {
127
130
  ATTACHMENTS_DIR,
128
131
  LEGACY_ATTACHMENTS_DIR
@@ -453,7 +456,7 @@ async function continueSourceThread(threadId, prompt) {
453
456
  await continueOnReply(threadId, prompt);
454
457
  return;
455
458
  }
456
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-DB5ZSE6M.js");
459
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KWV2PPML.js");
457
460
  await getOrchestrator2().send(threadId, prompt);
458
461
  } catch {
459
462
  }
@@ -733,9 +736,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
733
736
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
734
737
  );
735
738
  }
736
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-NG7SU3GV.js");
739
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-EZVQPMWT.js");
737
740
  if (isGlobalThread2(thread)) {
738
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-2LD3C74O.js");
741
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-6EPVHVGJ.js");
739
742
  ensureGlobalCoordinatorCwd2(
740
743
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
741
744
  );
@@ -2962,6 +2965,8 @@ async function createThread(input, _onSetupLine) {
2962
2965
  `Cowboy mode uses ${defaultBranch} in the project folder. Switch that checkout to ${defaultBranch} first (currently ${head}).`
2963
2966
  );
2964
2967
  }
2968
+ await fetchOriginForWorktree(repoPath, defaultBranch);
2969
+ await fastForwardMainCheckoutIfSafe(repoPath, { branch: defaultBranch });
2965
2970
  const explicitTitle2 = input.title?.trim();
2966
2971
  const thread2 = createEmptyThread({
2967
2972
  title: explicitTitle2 || `Cowboy \xB7 ${head}`,
@@ -3068,7 +3073,7 @@ async function createThread(input, _onSetupLine) {
3068
3073
  return readThread(thread.id) ?? thread;
3069
3074
  }
3070
3075
  async function listLinearIssues(agent, repoPath) {
3071
- const { getAdapter: getAdapter2 } = await import("./agents-E5AAMHDY.js");
3076
+ const { getAdapter: getAdapter2 } = await import("./agents-YVETHB2R.js");
3072
3077
  await requireAgent(agent, { requireLinear: true });
3073
3078
  const adapter = getAdapter2(agent);
3074
3079
  if (!adapter.listLinearIssues) {
@@ -3475,7 +3480,7 @@ async function adoptThread(input) {
3475
3480
  messages: input.messages ?? []
3476
3481
  });
3477
3482
  writeThread(thread);
3478
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-PU5YHQ7Z.js");
3483
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-ZJATBC4A.js");
3479
3484
  await ensureWorkspace2(repoPath);
3480
3485
  return thread;
3481
3486
  }
@@ -5923,7 +5928,7 @@ function formatScheduledPrompt(name, prompt) {
5923
5928
  ${prompt}`;
5924
5929
  }
5925
5930
  async function defaultDeps() {
5926
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-DB5ZSE6M.js");
5931
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-KWV2PPML.js");
5927
5932
  const orch = getOrchestrator2();
5928
5933
  return {
5929
5934
  findThread: (id) => findThreadByRef(id),
@@ -7448,6 +7453,32 @@ var Orchestrator = class {
7448
7453
  }
7449
7454
  return result;
7450
7455
  }
7456
+ async markPrReady(threadRef) {
7457
+ const { thread, selectors, cwd } = await this.withPrSelector(threadRef);
7458
+ this.assertNotGlobal(thread, "Ready for review");
7459
+ const selector = selectors[0];
7460
+ if (!selector) throw new Error("No pull request linked to this thread");
7461
+ const result = await markPrReady(cwd, selector);
7462
+ const meta = await getPrMeta(cwd, selector);
7463
+ if (meta) {
7464
+ await this.persistPrMetaAndMaybeArchive(thread, { ...meta, isDraft: false });
7465
+ return { url: meta.url || result.url, state: meta.state || result.state, isDraft: false };
7466
+ }
7467
+ await this.persistPrMetaAndMaybeArchive(thread, {
7468
+ number: 0,
7469
+ title: thread.prTitle ?? thread.title,
7470
+ url: result.url || thread.prUrl || "",
7471
+ state: result.state || "OPEN",
7472
+ isDraft: false,
7473
+ reviewDecision: null,
7474
+ baseRefName: "",
7475
+ headRefName: "",
7476
+ isInMergeQueue: false,
7477
+ mergeable: null,
7478
+ mergeStateStatus: null
7479
+ });
7480
+ return { ...result, isDraft: false };
7481
+ }
7451
7482
  async mergePr(threadRef) {
7452
7483
  const { thread, selectors, cwd } = await this.withPrSelector(threadRef);
7453
7484
  this.assertNotGlobal(thread, "Merge PR");
@@ -7833,7 +7864,7 @@ var Orchestrator = class {
7833
7864
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
7834
7865
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
7835
7866
  try {
7836
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-PU5YHQ7Z.js");
7867
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-ZJATBC4A.js");
7837
7868
  await ensureWorkspace2(thread.repoPath);
7838
7869
  } catch {
7839
7870
  }
@@ -7887,7 +7918,7 @@ var Orchestrator = class {
7887
7918
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
7888
7919
  );
7889
7920
  }
7890
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-GKLPPNWR.js");
7921
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-RZRJNHYL.js");
7891
7922
  const slug = thread.worktreePath.split("/").pop();
7892
7923
  const dest = thread.worktreePath;
7893
7924
  await withRepoGitLock(thread.repoPath, async () => {
@@ -7995,7 +8026,7 @@ async function startOrchestration(opts) {
7995
8026
  sourceRef: "default",
7996
8027
  ...createOpts
7997
8028
  }).catch(async () => {
7998
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-GKLPPNWR.js");
8029
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-RZRJNHYL.js");
7999
8030
  const repo = await resolveRepoRoot2(repoPath);
8000
8031
  const def = await resolveDefaultBranch2(repo);
8001
8032
  return orch.createThread({
@@ -9,8 +9,8 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-OHWN4JEL.js";
13
- import "./chunk-4Q45TLZ5.js";
12
+ } from "./chunk-67K3FRKR.js";
13
+ import "./chunk-JTPDWTWJ.js";
14
14
  import "./chunk-B3SJXYIJ.js";
15
15
  import "./chunk-EUXOHTUK.js";
16
16
  import "./chunk-KPIYENTF.js";
@@ -7,8 +7,8 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-UG5N7ET3.js";
11
- import "./chunk-O3JEC2UJ.js";
10
+ } from "./chunk-SXPTL222.js";
11
+ import "./chunk-YP3CSOZ6.js";
12
12
  import "./chunk-FKOIHGKV.js";
13
13
  import "./chunk-I77RYPOH.js";
14
14
  import "./chunk-4TR3HZFT.js";
@@ -15,9 +15,9 @@ import {
15
15
  orchestratorSessionPoisonedByBuiltins,
16
16
  slackCoordinatorSourceRef,
17
17
  takenTeamSlugsForOrchestration
18
- } from "./chunk-R2W7A2UO.js";
19
- import "./chunk-UG5N7ET3.js";
20
- import "./chunk-O3JEC2UJ.js";
18
+ } from "./chunk-IHSR7EVK.js";
19
+ import "./chunk-SXPTL222.js";
20
+ import "./chunk-YP3CSOZ6.js";
21
21
  import "./chunk-FKOIHGKV.js";
22
22
  import "./chunk-I77RYPOH.js";
23
23
  import "./chunk-4TR3HZFT.js";
@@ -17,9 +17,9 @@ import {
17
17
  orchestratorSessionPoisonedByBuiltins,
18
18
  slackCoordinatorSourceRef,
19
19
  takenTeamSlugsForOrchestration
20
- } from "./chunk-FADNFPZO.js";
21
- import "./chunk-OHWN4JEL.js";
22
- import "./chunk-4Q45TLZ5.js";
20
+ } from "./chunk-KNE3FZ46.js";
21
+ import "./chunk-67K3FRKR.js";
22
+ import "./chunk-JTPDWTWJ.js";
23
23
  import "./chunk-B3SJXYIJ.js";
24
24
  import "./chunk-EUXOHTUK.js";
25
25
  import "./chunk-KPIYENTF.js";