@sideboard-ai/core 0.1.15 → 0.1.19

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.
package/dist/index.cjs CHANGED
@@ -1390,6 +1390,16 @@ function formatGhLandError(raw, opts) {
1390
1390
  return trimmed;
1391
1391
  }
1392
1392
  const detail = extractGhErrorDetail(raw);
1393
+ if (/Head ref must be a branch|No commits between|Head sha can't be blank/i.test(
1394
+ raw
1395
+ ) || /Head ref must be a branch|No commits between|Head sha can't be blank/i.test(
1396
+ detail
1397
+ )) {
1398
+ const target = opts?.targetedRepo ? ` Targeted ${opts.targetedRepo}` : "";
1399
+ const head = opts?.headRef ? ` with head ${opts.headRef}` : "";
1400
+ const hint = opts?.targetedRepo ? ` Branch was pushed to origin \u2014 confirm it exists on GitHub and differs from the base branch.${target}${head}.` : " Often `gh` targeted upstream instead of origin. Branch was pushed \u2014 retry in the latest Sideboard, or run: gh pr create -R <owner/name> --base main --head <branch>.";
1401
+ return `Could not create the pull request.${hint}`;
1402
+ }
1393
1403
  if (isGhRateLimitError(raw) || isGhRateLimitError(detail)) {
1394
1404
  const when = opts?.resetAt ? ` Try again ${formatRateLimitResetHint(opts.resetAt, opts.nowMs)}.` : " Wait a few minutes and try again.";
1395
1405
  const pushNote = opts?.pushed === false ? "" : " Your branch was already pushed.";
@@ -1600,11 +1610,14 @@ __export(worktree_exports, {
1600
1610
  createThreadWorktree: () => createThreadWorktree,
1601
1611
  currentBranch: () => currentBranch,
1602
1612
  detectLocalMergeConflicts: () => detectLocalMergeConflicts,
1613
+ ensureGhPreferOrigin: () => ensureGhPreferOrigin,
1603
1614
  fetchPrHead: () => fetchPrHead,
1604
1615
  getPr: () => getPr,
1605
1616
  getPrChecks: () => getPrChecks,
1606
1617
  getPrDetails: () => getPrDetails,
1607
1618
  getPrMeta: () => getPrMeta,
1619
+ ghHeadRef: () => ghHeadRef,
1620
+ ghRepoSelectArgs: () => ghRepoSelectArgs,
1608
1621
  isDirty: () => isDirty,
1609
1622
  isPlaceholderBranch: () => isPlaceholderBranch,
1610
1623
  listBranches: () => listBranches,
@@ -1612,6 +1625,7 @@ __export(worktree_exports, {
1612
1625
  listWorktrees: () => listWorktrees,
1613
1626
  mergePr: () => mergePr,
1614
1627
  normalizeWorktreePath: () => normalizeWorktreePath,
1628
+ originGhRepoEnv: () => originGhRepoEnv,
1615
1629
  parseGithubSlugFromRemoteUrl: () => parseGithubSlugFromRemoteUrl,
1616
1630
  pushBranch: () => pushBranch,
1617
1631
  removeWorktree: () => removeWorktree,
@@ -1639,12 +1653,19 @@ async function lookupGithubGraphqlReset(cwd) {
1639
1653
  return void 0;
1640
1654
  }
1641
1655
  }
1642
- async function formatPrCreateFailure(raw, cwd) {
1656
+ async function formatPrCreateFailure(raw, cwd, ctx) {
1643
1657
  if (!isGhRateLimitError(raw)) {
1644
- return formatGhLandError(raw);
1658
+ return formatGhLandError(raw, {
1659
+ targetedRepo: ctx?.slug,
1660
+ headRef: ctx?.head
1661
+ });
1645
1662
  }
1646
1663
  const resetAt = await lookupGithubGraphqlReset(cwd);
1647
- return formatGhLandError(raw, { resetAt });
1664
+ return formatGhLandError(raw, {
1665
+ resetAt,
1666
+ targetedRepo: ctx?.slug,
1667
+ headRef: ctx?.head
1668
+ });
1648
1669
  }
1649
1670
  function slugify(input) {
1650
1671
  return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
@@ -1654,10 +1675,13 @@ async function resolveRepoRoot(cwd) {
1654
1675
  return stdout.trim();
1655
1676
  }
1656
1677
  function parseGithubSlugFromRemoteUrl(url) {
1657
- const trimmed = url.trim();
1658
- const match = trimmed.match(/github\.com[:/]([^/]+)\/([^/.]+?)(?:\.git)?$/i) ?? trimmed.match(/github\.com[:/]([^/]+)\/([^/.]+)/i);
1659
- if (!match?.[1] || !match[2]) return null;
1660
- return `${match[1]}/${match[2]}`;
1678
+ const trimmed = url.trim().replace(/\.git$/i, "");
1679
+ if (!trimmed) return null;
1680
+ const github = trimmed.match(/github\.com[:/]([^/]+)\/([^/]+)$/i);
1681
+ if (github?.[1] && github[2]) return `${github[1]}/${github[2]}`;
1682
+ const sshAlias = trimmed.match(/^git@[^:]+:([^/]+)\/([^/]+)$/i);
1683
+ if (sshAlias?.[1] && sshAlias[2]) return `${sshAlias[1]}/${sshAlias[2]}`;
1684
+ return null;
1661
1685
  }
1662
1686
  async function slugFromGitRemote(repoPath, remote) {
1663
1687
  const result = await git(["remote", "get-url", remote], repoPath, {
@@ -1669,13 +1693,16 @@ async function slugFromGitRemote(repoPath, remote) {
1669
1693
  async function resolveGithubRepoSlug(repoPath) {
1670
1694
  const fromOrigin = await slugFromGitRemote(repoPath, "origin");
1671
1695
  if (fromOrigin) return fromOrigin;
1672
- const viaGh = await gh(
1673
- ["repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"],
1674
- repoPath,
1675
- { reject: false }
1676
- );
1677
- if (viaGh.exitCode === 0 && viaGh.stdout.trim()) {
1678
- return viaGh.stdout.trim();
1696
+ const hasAlt = Boolean(await slugFromGitRemote(repoPath, "upstream")) || Boolean(await slugFromGitRemote(repoPath, "github"));
1697
+ if (!hasAlt) {
1698
+ const viaGh = await gh(
1699
+ ["repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"],
1700
+ repoPath,
1701
+ { reject: false }
1702
+ );
1703
+ if (viaGh.exitCode === 0 && viaGh.stdout.trim()) {
1704
+ return viaGh.stdout.trim();
1705
+ }
1679
1706
  }
1680
1707
  for (const remote of ["upstream", "github"]) {
1681
1708
  const slug = await slugFromGitRemote(repoPath, remote);
@@ -1683,15 +1710,35 @@ async function resolveGithubRepoSlug(repoPath) {
1683
1710
  }
1684
1711
  return null;
1685
1712
  }
1713
+ function ghRepoSelectArgs(slug) {
1714
+ return ["-R", slug];
1715
+ }
1716
+ function ghHeadRef(slug, branch) {
1717
+ const owner = slug.split("/")[0];
1718
+ const head = branch.trim().replace(/^refs\/heads\//, "");
1719
+ if (!owner || !head) return head || branch;
1720
+ if (head.includes(":")) return head;
1721
+ return `${owner}:${head}`;
1722
+ }
1723
+ async function ensureGhPreferOrigin(cwd) {
1724
+ const originSlug = await slugFromGitRemote(cwd, "origin");
1725
+ if (!originSlug) return;
1726
+ const hasAlt = Boolean(await slugFromGitRemote(cwd, "upstream")) || Boolean(await slugFromGitRemote(cwd, "github"));
1727
+ if (!hasAlt) return;
1728
+ const view = await gh(["repo", "set-default", "--view"], cwd, {
1729
+ reject: false
1730
+ });
1731
+ const current = `${view.stdout}
1732
+ ${view.stderr}`;
1733
+ if (view.exitCode === 0 && current.includes(originSlug)) return;
1734
+ await gh(["repo", "set-default", "origin"], cwd, { reject: false });
1735
+ }
1736
+ async function originGhRepoEnv(cwd) {
1737
+ await ensureGhPreferOrigin(cwd);
1738
+ const slug = await resolveGithubRepoSlug(cwd);
1739
+ return slug ? { GH_REPO: slug } : {};
1740
+ }
1686
1741
  async function resolveDefaultBranch(repoPath) {
1687
- const viaGh = await gh(
1688
- ["repo", "view", "--json", "defaultBranchRef", "--jq", ".defaultBranchRef.name"],
1689
- repoPath,
1690
- { reject: false }
1691
- );
1692
- if (viaGh.exitCode === 0 && viaGh.stdout.trim()) {
1693
- return viaGh.stdout.trim();
1694
- }
1695
1742
  const viaOrigin = await git(
1696
1743
  ["symbolic-ref", "refs/remotes/origin/HEAD"],
1697
1744
  repoPath,
@@ -1700,6 +1747,31 @@ async function resolveDefaultBranch(repoPath) {
1700
1747
  if (viaOrigin.exitCode === 0 && viaOrigin.stdout.trim()) {
1701
1748
  return viaOrigin.stdout.trim().replace(/^refs\/remotes\/origin\//, "");
1702
1749
  }
1750
+ const slug = await resolveGithubRepoSlug(repoPath);
1751
+ const viaGh = await gh(
1752
+ [
1753
+ "repo",
1754
+ "view",
1755
+ ...slug ? ["--repo", slug] : [],
1756
+ "--json",
1757
+ "defaultBranchRef",
1758
+ "--jq",
1759
+ ".defaultBranchRef.name"
1760
+ ],
1761
+ repoPath,
1762
+ { reject: false }
1763
+ );
1764
+ if (viaGh.exitCode === 0 && viaGh.stdout.trim()) {
1765
+ return viaGh.stdout.trim();
1766
+ }
1767
+ for (const candidate of ["main", "master"]) {
1768
+ const check = await git(
1769
+ ["show-ref", "--verify", "--quiet", `refs/remotes/origin/${candidate}`],
1770
+ repoPath,
1771
+ { reject: false }
1772
+ );
1773
+ if (check.exitCode === 0) return candidate;
1774
+ }
1703
1775
  for (const candidate of ["main", "master"]) {
1704
1776
  const check = await git(
1705
1777
  ["show-ref", "--verify", "--quiet", `refs/heads/${candidate}`],
@@ -2105,6 +2177,7 @@ async function createThreadWorktree(opts) {
2105
2177
  if ((0, import_node_fs5.existsSync)(worktreePath)) {
2106
2178
  throw new Error(`Worktree already exists at ${worktreePath}`);
2107
2179
  }
2180
+ await ensureGhPreferOrigin(opts.repoPath);
2108
2181
  await git(["fetch", "origin", "--prune"], opts.repoPath, { reject: false });
2109
2182
  if (!opts.sourceRef.startsWith("origin/") && !opts.sourceRef.startsWith("refs/")) {
2110
2183
  await git(["fetch", "origin", opts.sourceRef], opts.repoPath, {
@@ -2133,6 +2206,7 @@ ${add.stdout}`;
2133
2206
  );
2134
2207
  if (retry.exitCode === 0) {
2135
2208
  branchName = alt;
2209
+ await ensureGhPreferOrigin(worktreePath);
2136
2210
  return { branchName, worktreePath };
2137
2211
  }
2138
2212
  }
@@ -2141,6 +2215,7 @@ ${add.stdout}`;
2141
2215
  `Failed to create worktree: ${add.stderr.trim() || add.stdout.trim() || `exit ${add.exitCode}`}`
2142
2216
  );
2143
2217
  }
2218
+ await ensureGhPreferOrigin(worktreePath);
2144
2219
  return { branchName, worktreePath };
2145
2220
  }
2146
2221
  async function removeWorktree(repoPath, worktreePath, opts) {
@@ -2241,8 +2316,18 @@ async function mergePr(cwd, selector, opts) {
2241
2316
  return { url, state: "MERGED" };
2242
2317
  }
2243
2318
  async function createOrUpdatePr(worktreePath, opts) {
2319
+ await ensureGhPreferOrigin(worktreePath);
2320
+ const slug = await resolveGithubRepoSlug(worktreePath);
2321
+ if (!slug) {
2322
+ throw new Error(
2323
+ "Could not resolve the origin GitHub repo (owner/name) for this worktree. Check that `git remote get-url origin` points at github.com."
2324
+ );
2325
+ }
2326
+ const repoArgs = ghRepoSelectArgs(slug);
2327
+ const headRef = ghHeadRef(slug, opts.head);
2328
+ const branchOnly = opts.head.trim().replace(/^refs\/heads\//, "");
2244
2329
  const existing = await gh(
2245
- ["pr", "view", opts.head, "--json", "url", "--jq", ".url"],
2330
+ [...repoArgs, "pr", "view", branchOnly, "--json", "url", "--jq", ".url"],
2246
2331
  worktreePath,
2247
2332
  { reject: false }
2248
2333
  );
@@ -2250,9 +2335,10 @@ async function createOrUpdatePr(worktreePath, opts) {
2250
2335
  const url2 = existing.stdout.trim();
2251
2336
  await gh(
2252
2337
  [
2338
+ ...repoArgs,
2253
2339
  "pr",
2254
2340
  "edit",
2255
- opts.head,
2341
+ branchOnly,
2256
2342
  "--title",
2257
2343
  opts.title,
2258
2344
  "--body",
@@ -2265,6 +2351,7 @@ async function createOrUpdatePr(worktreePath, opts) {
2265
2351
  }
2266
2352
  if (opts.web) {
2267
2353
  const args2 = [
2354
+ ...repoArgs,
2268
2355
  "pr",
2269
2356
  "create",
2270
2357
  "--web",
@@ -2275,18 +2362,19 @@ async function createOrUpdatePr(worktreePath, opts) {
2275
2362
  "--base",
2276
2363
  opts.base,
2277
2364
  "--head",
2278
- opts.head
2365
+ headRef
2279
2366
  ];
2280
2367
  if (opts.draft) args2.push("--draft");
2281
2368
  await gh(args2, worktreePath, { reject: false });
2282
2369
  const again = await gh(
2283
- ["pr", "view", opts.head, "--json", "url", "--jq", ".url"],
2370
+ [...repoArgs, "pr", "view", branchOnly, "--json", "url", "--jq", ".url"],
2284
2371
  worktreePath,
2285
2372
  { reject: false }
2286
2373
  );
2287
2374
  return again.stdout.trim() || "";
2288
2375
  }
2289
2376
  const args = [
2377
+ ...repoArgs,
2290
2378
  "pr",
2291
2379
  "create",
2292
2380
  "--title",
@@ -2296,13 +2384,13 @@ async function createOrUpdatePr(worktreePath, opts) {
2296
2384
  "--base",
2297
2385
  opts.base,
2298
2386
  "--head",
2299
- opts.head
2387
+ headRef
2300
2388
  ];
2301
2389
  if (opts.draft) args.push("--draft");
2302
2390
  const created = await gh(args, worktreePath, { reject: false });
2303
2391
  if (created.exitCode !== 0) {
2304
2392
  const raw = created.stderr.trim() || created.stdout.trim() || "gh pr create failed";
2305
- throw new Error(await formatPrCreateFailure(raw, worktreePath));
2393
+ throw new Error(await formatPrCreateFailure(raw, worktreePath, { slug, head: headRef }));
2306
2394
  }
2307
2395
  const url = created.stdout.trim().split("\n").find((l) => l.startsWith("http")) ?? created.stdout.trim();
2308
2396
  return url;
@@ -2406,7 +2494,8 @@ function coordinatorGreenfieldPlaybook(reposDir) {
2406
2494
  "- Examples:",
2407
2495
  ` - Clone: \`git clone <url> ${reposDir}/<name>\``,
2408
2496
  ` - New GitHub repo: \`gh repo create <owner>/<name> --private --clone -- ${reposDir}/<name>\` (or mkdir + git init + gh repo create + remote add + push)`,
2409
- "- Then: add_workspace with that absolute path \u2192 create_thread (repoPath + parentThreadId) \u2192 send_to_thread (build) \u2192 wait_for_turn \u2192 send_to_thread (`gh pr create --draft`) or create_draft_pr.",
2497
+ "- Then: add_workspace with that absolute path \u2192 create_thread (repoPath + parentThreadId) \u2192 send_to_thread (build) \u2192 wait_for_turn \u2192 send_to_thread (`gh pr create --draft -R <origin-owner/name>`) or create_draft_pr.",
2498
+ "- Always target the child worktree's **origin** (`github:` slug from list_workspaces / `git remote get-url origin` in that worktree). Never open PRs against `upstream`.",
2410
2499
  "- Do coding work in the child worktree thread, not by editing files in this home cwd."
2411
2500
  ].join("\n");
2412
2501
  }
@@ -2471,7 +2560,7 @@ function coordinatorSystemPrompt(opts) {
2471
2560
  COORDINATOR_TOOL_PLAYBOOK,
2472
2561
  coordinatorGreenfieldPlaybook(reposDir),
2473
2562
  "When creating threads, pass the correct repoPath for the target workspace and parentThreadId for children.",
2474
- "Typical flow (existing): list_workspaces \u2192 list_branches|list_prs|list_issues \u2192 create_thread \u2192 send_to_thread (implement) \u2192 wait_for_turn \u2192 send_to_thread (ask for `gh pr create --draft`) \u2192 wait_for_turn. Use create_draft_pr only if the child cannot open the PR.",
2563
+ "Typical flow (existing): list_workspaces \u2192 list_branches|list_prs|list_issues \u2192 create_thread \u2192 send_to_thread (implement) \u2192 wait_for_turn \u2192 send_to_thread (ask for `gh pr create --draft -R <origin-owner/name>` using the workspace github slug) \u2192 wait_for_turn. Use create_draft_pr only if the child cannot open the PR. Never target upstream.",
2475
2564
  "Typical flow (new app): Bash under repos dir (clone or gh repo create) \u2192 add_workspace \u2192 create_thread \u2192 send_to_thread \u2192 wait_for_turn \u2192 draft PR.",
2476
2565
  `Goal: ${opts.goal}`,
2477
2566
  `Parent thread id (pass as parentThreadId when creating children): ${opts.parentId}`,
@@ -2508,8 +2597,8 @@ var init_coordinator_prompt = __esm({
2508
2597
  "Inspect / PRs:",
2509
2598
  "- get_diff \u2014 compact diff summary",
2510
2599
  "- preview_land \u2014 preview push+PR (does not push)",
2511
- "- Prefer asking the worktree agent via send_to_thread to open a draft PR (`gh pr create --draft`) so it owns title/body from the diff.",
2512
- "- create_draft_pr \u2014 fallback: commit (if dirty), push, open/update a DRAFT PR from the orchestrator",
2600
+ "- Prefer asking the worktree agent via send_to_thread to open a draft PR with `gh pr create --draft -R <origin-owner/name>` (use the workspace `github:` slug / that worktree's origin \u2014 never upstream) so it owns title/body from the diff.",
2601
+ "- create_draft_pr \u2014 fallback: commit (if dirty), push to origin, open/update a DRAFT PR from the orchestrator (always against origin)",
2513
2602
  "Human-only (do not attempt): ready-for-review confirm_land, purge_thread.",
2514
2603
  "Thread links in replies: when mentioning a chat/thread for the user, include a markdown link `[Title](sideboard://thread/<id>)` using the full id (or the link field from create_thread / list_threads). Sideboard renders these as clickable opens.",
2515
2604
  "Bash / Read / etc: allowed for (1) inspecting target worktrees / registered repo paths from MCP, and (2) greenfield setup under ~/sideboard/repos (git clone, gh repo create, git init+remote). Never git init/clone *inside* this synthetic home cwd \u2014 emptiness here is expected, not a bug."
@@ -2729,7 +2818,9 @@ function forgetRemoved(repoPath) {
2729
2818
  }
2730
2819
  function listWorkspaces() {
2731
2820
  const all = readAll();
2732
- const valid = all.filter((w) => Boolean(w.path) && w.path !== "/" && w.path !== ".");
2821
+ const valid = all.filter(
2822
+ (w) => Boolean(w.path) && w.path !== "/" && w.path !== "." && !isGlobalRepoPath(w.path)
2823
+ );
2733
2824
  if (valid.length !== all.length) writeAll(valid);
2734
2825
  return valid.sort((a, b) => a.name.localeCompare(b.name));
2735
2826
  }
@@ -2738,6 +2829,7 @@ async function addWorkspace(repoPath) {
2738
2829
  if (!root || root === "/") throw new Error(`Invalid repo path: ${repoPath}`);
2739
2830
  if (!(0, import_node_fs7.existsSync)(root)) throw new Error(`Repo not found: ${root}`);
2740
2831
  forgetRemoved(root);
2832
+ await ensureGhPreferOrigin(root);
2741
2833
  const current = readAll();
2742
2834
  const existing = current.find((w) => w.path === root);
2743
2835
  if (existing) return existing;
@@ -4809,6 +4901,7 @@ __export(index_exports, {
4809
4901
  enrichWorkspacesWithGithub: () => enrichWorkspacesWithGithub,
4810
4902
  ensureAgentPath: () => ensureAgentPath,
4811
4903
  ensureCloudCoordinator: () => ensureCloudCoordinator,
4904
+ ensureGhPreferOrigin: () => ensureGhPreferOrigin,
4812
4905
  ensureGlobalCoordinatorCwd: () => ensureGlobalCoordinatorCwd,
4813
4906
  ensureWorkspace: () => ensureWorkspace,
4814
4907
  estimateMessageChars: () => estimateMessageChars,
@@ -4852,6 +4945,8 @@ __export(index_exports, {
4852
4945
  getRunMode: () => getRunMode,
4853
4946
  getRunScript: () => getRunScript,
4854
4947
  gh: () => gh,
4948
+ ghHeadRef: () => ghHeadRef,
4949
+ ghRepoSelectArgs: () => ghRepoSelectArgs,
4855
4950
  git: () => git,
4856
4951
  globalAgentCwd: () => globalAgentCwd,
4857
4952
  harnessEnvKey: () => harnessEnvKey,
@@ -4911,6 +5006,7 @@ __export(index_exports, {
4911
5006
  opencodeAdapter: () => opencodeAdapter,
4912
5007
  orchestrationTitleNeedsSoccerNickname: () => orchestrationTitleNeedsSoccerNickname,
4913
5008
  orchestratorSessionPoisonedByBuiltins: () => orchestratorSessionPoisonedByBuiltins,
5009
+ originGhRepoEnv: () => originGhRepoEnv,
4914
5010
  parseCursorRunnerLine: () => parseCursorRunnerLine,
4915
5011
  parseForceStopMessage: () => parseForceStopMessage,
4916
5012
  parseGithubSlugFromRemoteUrl: () => parseGithubSlugFromRemoteUrl,
@@ -5186,7 +5282,9 @@ init_agents();
5186
5282
  // src/agents/spawn.ts
5187
5283
  var import_node_readline = require("readline");
5188
5284
  var import_execa2 = require("execa");
5285
+ init_worktree();
5189
5286
  init_app_settings();
5287
+ init_global_workspace();
5190
5288
  init_brightsy();
5191
5289
  init_agents();
5192
5290
 
@@ -5420,9 +5518,14 @@ async function spawnAgentTurn(thread, input, onEvent) {
5420
5518
  `Agent cwd must be the thread worktree (got ${cmd.cwd}, expected ${thread.worktreePath})`
5421
5519
  );
5422
5520
  }
5521
+ const env = childEnvWithAppSettings(cmd.env);
5522
+ if (!isOrchestratorThread(thread)) {
5523
+ const originEnv = await originGhRepoEnv(thread.worktreePath).catch(() => ({}));
5524
+ Object.assign(env, originEnv);
5525
+ }
5423
5526
  const child = (0, import_execa2.execa)(cmd.file, cmd.args, {
5424
5527
  cwd: cmd.cwd,
5425
- env: childEnvWithAppSettings(cmd.env),
5528
+ env,
5426
5529
  reject: false,
5427
5530
  stdout: "pipe",
5428
5531
  stderr: "pipe",
@@ -5529,7 +5632,7 @@ function formatRenameBranchDirective(thread, opts) {
5529
5632
  }
5530
5633
  return lines.join("\n");
5531
5634
  }
5532
- function formatWorktreeDirective(thread) {
5635
+ function formatWorktreeDirective(thread, opts) {
5533
5636
  const worktree = normPath2(thread.worktreePath);
5534
5637
  const repo = normPath2(thread.repoPath);
5535
5638
  const dir = worktreeNameFromPath(thread.worktreePath);
@@ -5550,7 +5653,13 @@ function formatWorktreeDirective(thread) {
5550
5653
  );
5551
5654
  }
5552
5655
  lines.push("");
5553
- lines.push("Pull requests (when the work is ready to share):");
5656
+ lines.push("Git remotes + pull requests (when the work is ready to share):");
5657
+ lines.push(
5658
+ "- Always use this worktree's `origin` remote (`git remote get-url origin` from this cwd). Never push to or open PRs against `upstream` (template remotes)."
5659
+ );
5660
+ lines.push(
5661
+ "- Push with `git push -u origin HEAD` (or the current branch name). Do not `git push upstream`."
5662
+ );
5554
5663
  lines.push(
5555
5664
  "- Derive the PR title and body from what the changes actually do and why \u2014 inspect the diff/commits and the user request. Do not use the soccer-team worktree nickname or placeholder branch as the PR title."
5556
5665
  );
@@ -5564,9 +5673,13 @@ function formatWorktreeDirective(thread) {
5564
5673
  lines.push(
5565
5674
  `- A PR already exists (${thread.prUrl}). Update it (push + edit title/body if the purpose drifted) instead of opening a duplicate.`
5566
5675
  );
5676
+ } else if (opts?.githubSlug) {
5677
+ lines.push(
5678
+ `- Prefer a draft PR first: \`gh pr create --draft -R ${opts.githubSlug}\` (or update via \`gh pr edit -R ${opts.githubSlug}\`) once the change set is coherent. Always pass \`-R ${opts.githubSlug}\` (this worktree's origin). Bare \`gh pr create\` may target upstream instead of origin on dual-remote checkouts. Mark ready for review only when asked. Title/body must reflect the change purpose, not the worktree name.`
5679
+ );
5567
5680
  } else {
5568
5681
  lines.push(
5569
- "- Prefer a draft PR first: `gh pr create --draft` (or update via `gh pr edit`) once the change set is coherent. Mark ready for review only when asked. Title/body must reflect the change purpose, not the worktree name."
5682
+ "- Prefer a draft PR first: `gh pr create --draft -R <origin-owner/name>` (or update via `gh pr edit -R \u2026`) once the change set is coherent. Resolve `<origin-owner/name>` with `git remote get-url origin` in this worktree \u2014 never from `upstream`. Mark ready for review only when asked. Title/body must reflect the change purpose, not the worktree name."
5570
5683
  );
5571
5684
  }
5572
5685
  return lines.join("\n");
@@ -8212,7 +8325,11 @@ var Orchestrator = class {
8212
8325
  }
8213
8326
  const isBrightsy = fresh.agent === "brightsy";
8214
8327
  const isOrchestration = isOrchestratorThread(fresh);
8215
- const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh);
8328
+ const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
8329
+ githubSlug: await resolveGithubRepoSlug(fresh.worktreePath).catch(
8330
+ () => null
8331
+ )
8332
+ });
8216
8333
  const settings = loadWorkspaceSettings(fresh.worktreePath, fresh.repoPath);
8217
8334
  const { autoRenameBranchEnabled: autoRenameBranchEnabled2 } = await Promise.resolve().then(() => (init_app_settings(), app_settings_exports));
8218
8335
  const renameBranchDirective = !isBrightsy && !isOrchestration && autoRenameBranchEnabled2() ? formatRenameBranchDirective(fresh, {
@@ -9393,7 +9510,7 @@ async function startMcpServer() {
9393
9510
  );
9394
9511
  server.tool(
9395
9512
  "create_draft_pr",
9396
- "Commit dirty changes if needed, push the thread branch, and create/update a DRAFT GitHub PR. Ready-for-review / non-draft land stays human-only (CLI/app confirm_land). Prefer this when the orchestrator should open a PR itself; alternatively send_to_thread asking the worktree agent to run `gh pr create --draft`.",
9513
+ "Commit dirty changes if needed, push the thread branch to origin, and create/update a DRAFT GitHub PR against that worktree's origin (never upstream). Ready-for-review / non-draft land stays human-only (CLI/app confirm_land). Prefer this when the orchestrator should open a PR itself; alternatively send_to_thread asking the worktree agent to run `gh pr create --draft -R <origin-owner/name>`.",
9397
9514
  { ref: import_zod.z.string() },
9398
9515
  async ({ ref }) => {
9399
9516
  try {
@@ -9919,6 +10036,7 @@ init_injected_mcp();
9919
10036
  enrichWorkspacesWithGithub,
9920
10037
  ensureAgentPath,
9921
10038
  ensureCloudCoordinator,
10039
+ ensureGhPreferOrigin,
9922
10040
  ensureGlobalCoordinatorCwd,
9923
10041
  ensureWorkspace,
9924
10042
  estimateMessageChars,
@@ -9962,6 +10080,8 @@ init_injected_mcp();
9962
10080
  getRunMode,
9963
10081
  getRunScript,
9964
10082
  gh,
10083
+ ghHeadRef,
10084
+ ghRepoSelectArgs,
9965
10085
  git,
9966
10086
  globalAgentCwd,
9967
10087
  harnessEnvKey,
@@ -10021,6 +10141,7 @@ init_injected_mcp();
10021
10141
  opencodeAdapter,
10022
10142
  orchestrationTitleNeedsSoccerNickname,
10023
10143
  orchestratorSessionPoisonedByBuiltins,
10144
+ originGhRepoEnv,
10024
10145
  parseCursorRunnerLine,
10025
10146
  parseForceStopMessage,
10026
10147
  parseGithubSlugFromRemoteUrl,
package/dist/index.d.cts CHANGED
@@ -695,6 +695,10 @@ type FormatGhLandErrorOptions = {
695
695
  /** Land push already succeeded before PR create failed. Default true for PR-create path. */
696
696
  pushed?: boolean;
697
697
  nowMs?: number;
698
+ /** Repo Sideboard passed to `gh -R` (origin), when known. */
699
+ targetedRepo?: string;
700
+ /** Head ref passed to `gh pr create` (often `owner:branch`). */
701
+ headRef?: string;
698
702
  };
699
703
  /**
700
704
  * Turn noisy `gh pr create` / Execa failures into a short notice for UI/CLI.
@@ -757,7 +761,7 @@ declare function worktreeDisplayLabelForGroup(threads: {
757
761
  declare function slugify(input: string): string;
758
762
  declare function resolveRepoRoot(cwd: string): Promise<string>;
759
763
  /**
760
- * Parse `owner/name` from a git remote URL (SSH or HTTPS).
764
+ * Parse `owner/name` from a git remote URL (SSH, HTTPS, or SSH host aliases).
761
765
  */
762
766
  declare function parseGithubSlugFromRemoteUrl(url: string): string | null;
763
767
  /**
@@ -770,6 +774,21 @@ declare function parseGithubSlugFromRemoteUrl(url: string): string | null;
770
774
  * resolves to upstream — which lists the wrong open PRs in the create modal.
771
775
  */
772
776
  declare function resolveGithubRepoSlug(repoPath: string): Promise<string | null>;
777
+ /** Global `-R owner/repo` args so gh never targets upstream by accident. */
778
+ declare function ghRepoSelectArgs(slug: string): string[];
779
+ /** Same-repo head ref as `owner:branch` (required for reliable `-R` creates). */
780
+ declare function ghHeadRef(slug: string, branch: string): string;
781
+ /**
782
+ * On Makerkit-style checkouts (`origin` product + `upstream` template), `gh`
783
+ * prefers `upstream` → so bare `gh pr create` hits the wrong GitHub repo.
784
+ * Pin the CLI default to `origin` once per repo (shared by all worktrees).
785
+ */
786
+ declare function ensureGhPreferOrigin(cwd: string): Promise<void>;
787
+ /**
788
+ * Env pin so bare `gh` (and agents) target this checkout's **origin**, not
789
+ * Makerkit-style `upstream`. `GH_REPO` is the CLI's documented override.
790
+ */
791
+ declare function originGhRepoEnv(cwd: string): Promise<Record<string, string>>;
773
792
  declare function resolveDefaultBranch(repoPath: string): Promise<string>;
774
793
  /**
775
794
  * Prefer `origin/<branch>` for diff/merge-base so Changes / Land don't inflate
@@ -1189,7 +1208,9 @@ declare function formatRenameBranchDirective(thread: Pick<Thread, 'worktreePath'
1189
1208
  * Mandatory Sideboard isolation + landing guidance — agents must edit the thread
1190
1209
  * worktree and open PRs whose titles/bodies describe the *purpose of the changes*.
1191
1210
  */
1192
- declare function formatWorktreeDirective(thread: Pick<Thread, 'worktreePath' | 'repoPath' | 'branchName'> & Partial<Pick<Thread, 'title' | 'prUrl'>>): string;
1211
+ declare function formatWorktreeDirective(thread: Pick<Thread, 'worktreePath' | 'repoPath' | 'branchName'> & Partial<Pick<Thread, 'title' | 'prUrl'>>, opts?: {
1212
+ githubSlug?: string | null;
1213
+ }): string;
1193
1214
  interface AgentInstructionFile {
1194
1215
  relativePath: string;
1195
1216
  content: string;
@@ -2348,4 +2369,4 @@ declare function writeInjectedMcpConfig(opts: {
2348
2369
  includeBrightsy?: boolean;
2349
2370
  }): Promise<string | null>;
2350
2371
 
2351
- export { type ActiveRun, type AdoptInput, type AdvancedAppSettings, type AgentAdapter, type AgentEvent, type AgentInstructionFile, type AgentKind, type AgentStatus, type AgentTurnInput, type AnthropicCacheControl, type AppSettings, type ApplyIntoMainResult, type AttachCommand, type Autonomy, BRIGHTSY_MCP_ALLOWED_TOOLS, type BranchInfo, type BrightsyAccount, type BrightsyChatTarget, type BrightsyChatTargets, type BrightsyCloudConnectAgent, type BrightsyHarnessSettings, type BrightsySession, BrightsySideboardApi, type BrightsyTeamTargets, CLOUD_COORDINATOR_BUSY_REPLY, CLOUD_COORDINATOR_STOPPED_REPLY, CLOUD_COORDINATOR_TIMEOUT_REPLY, CLOUD_ORCHESTRATOR_GOAL, CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAGES, CONTEXT_MIN_MESSAGES, COORDINATOR_TOOL_PLAYBOOK, type ClaudeHarnessSettings, type CleanupOrphansResult, type CloudConnectAgent, type CloudConnectOptions, type CloudConnectStatus, type CompactResult, type CompactThresholds, type ConductorSettings, type ConductorWorkspace, type ConnectedBrightsyTeamInfo, type CreateChatTabInput, type CreateGlobalChatOpts, type CreateThreadInput, type CreateWorktreeResult, type CursorSdkStreamMessage, type CursorTurnRequest, type CursorWorktreesConfig, type DevServerHandle, type DiffCommit, type DiffFile, type DiffResult, type DiffScope, type DiffScopeStat, type ExpandResult, FAMOUS_SOCCER_TEAMS, type ForkChatTabInput, type ForkThreadWorktreeInput, type FormatGhLandErrorOptions, GLOBAL_WORKSPACE_ID, type GetDiffOptions, type GitHubStatus, type GitWorktreeStatus, HARNESS_ENV_KEYS, type HarnessId, type IntegrationsSettings, type IpcApi, type IssueInfo, type IssueSource, type LandPreview, type LandResult, type ListIssuesResult, MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS, type McpServerStatus, type MessagePart, Orchestrator, type OrchestratorEvent, type OrchestratorRuntime, type OrphanWorktree, PLAN_MODE_INSTRUCTION, type PrActor, type PrCheckRun, type PrCommentInfo, type PrCommitInfo, type PrDetails, type PrInfo, type PrMeta, type PrReviewInfo, type RepoSettings, type RepoSetupInfo, type RunMode, type RunScript, SIDEBOARD_FORCE_STOP, SIDEBOARD_MCP_ALLOWED_TOOLS, type ScriptHandle, type SkillInfo, type SourceType, type SpawnTurnHandle, type SummarizeResult, type TeamName, type Thread, type ThreadAttachment, type ThreadMessage, type ThreadOptionsPatch, type ThreadStatus, type TokenUsage, type TranscriptToolDetail, type TurnCommand, type Workspace, type WorkspaceInventoryEntry, type WorkspaceScriptEnvOpts, addWorkspace, adoptThread, allAdapters, allocatePort, allocatePortRange, allocateTeamName, allocateTeamSlug, appDataDir, appSettingsPath, appendMessage, applyAgentEvent, applyAppEnvironment, applyCompaction, applyThreadIntoMain, autoCleanupOrphansEnabled, autoRenameBranchEnabled, autoRunAfterSetupEnabled, branchDisplayLabel, brightsyAdapter, brightsyCloudConnectAgent, brightsyCloudConnectEnabled, brightsyConfigPath, brightsyMcpAllowedTools, brightsyMcpServerName, buildCachedUserContent, buildClaudeStreamJsonUserMessage, buildForkTranscriptAttachment, buildSessionSeed, buildWorkspaceScriptEnv, caffeinateWhileCloudConnectEnabled, caffeinateWhileRunningEnabled, captureLoginEnv, captureTurnBaseline, childEnvWithAppSettings, claudeAdapter, claudeChromeEnabled, claudeUserSettingsPath, cleanupOrphanWorktrees, cloneRepoIntoSideboard, codexAdapter, collectTakenTeamSlugs, commitAll, conductorDbPath, confirmLand, connectBrightsyTeam, coordinatorSystemPrompt, coordinatorTurnReminder, copyConfiguredFiles, countCacheControlBlocks, createChatTab, createEmptyThread, createGlobalChat, createOrUpdatePr, createThread, createThreadWorktree, currentBranch, cursorAdapter, cursorSdkMessageToEvents, decodeBrightsyTarget, deleteBranchOnPurgeEnabled, deleteThreadRecord, detectAgents, detectLocalMergeConflicts, disconnectBrightsyTeam, discoverSkills, encodeBrightsyTarget, enrichWorkspacesWithGithub, ensureAgentPath, ensureCloudCoordinator, ensureGlobalCoordinatorCwd, ensureWorkspace, estimateMessageChars, estimateThreadChars, expandComposerPrompt, extractGhErrorDetail, extractiveSummary, fetchPrHead, finalizeParts, findInvalidCacheControlTtlOrder, findOrphanWorktrees, findThreadByRef, flattenTurnInput, forkChatTab, forkMessageSlice, forkThreadWorktree, formatAgentInstructions, formatBrightsyFetchError, formatGhLandError, formatIpcInvokeError, formatMessagesAsTranscript, formatRateLimitResetHint, formatRenameBranchDirective, formatTranscriptMarkdown, formatWorkspaceInventory, formatWorktreeDirective, getAdapter, getBrightsySession, getDefaultRunScript, getDiff, getDiffSummary, getGitHubStatus, getIssueSource, getLinearApiKey, getOrchestrator, getPr, getPrChecks, getPrDetails, getPrMeta, getRepoSetupInfo, getRunMode, getRunScript, gh, git, globalAgentCwd, harnessEnvKey, hasConductorHook, hasCursorWorktreeSetup, hasRepoHook, hasWorkspaceHook, healOrchestrationSoccerTitles, importConductorWorkspace, importConductorWorkspaceAsync, initializeGitRepository, inspectGitWorktree, isBrightsyConnected, isBrightsyNdjsonLine, isCloudCoordinatorThread, isDirty, isGhRateLimitError, isGlobalRepoPath, isGlobalThread, isLinearConnected, isOrchestratorThread, isPlaceholderBranch, listBranchCommits, listBranches, listBrightsyAccounts, listBrightsyChatTargets, listConductorWorkspaces, listConnectedBrightsyTeams, listGitHubIssues, listGlobalThreads, listIssues, listLinearIssues, listLinearIssuesDirect, listPrs, listRunScripts, listThreads, listWorkspaces, listWorktreeFiles, listWorktrees, loadAgentInstructions, loadAppSettings, loadBrightsyConfig, loadConductorSettings, loadRepoSettings, loadWorkspaceSettings, locksDir, maxConcurrentAgents, maybeCompactContext, mcpAllowTools, mcpAuthWarnings, mergePr, mergeUsage, normalizeParseResult, normalizeThread, normalizeTurnInput, normalizeWorktreePath, opencodeAdapter, orchestrationTitleNeedsSoccerNickname, orchestratorSessionPoisonedByBuiltins, parseCursorRunnerLine, parseForceStopMessage, parseGithubSlugFromRemoteUrl, parseMcpList, partsToAssistantText, permissionMode, previewLand, pushBranch, readSkillBody, readThread, readWorktreeFile, readWorktreeInclude, refreshGitHubAuth, removeWorkspace, removeWorktree, repoSlug, requireAgent, resolveClaudeExecutable, resolveConductorCursorAgentId, resolveDefaultBranch, resolveDiffBaseRef, resolveEffectiveIssueSource, resolveFilesToCopy, resolveGithubRepoSlug, resolvePrSelector, resolveRepoRoot, resolveWorktreeStartPoint, run, runArchiveScript, runCloudConnect, runCursorWorktreeSetup, runSetupScript, sameWorktreePath, sanitizeMcpServerName, saveAppSettings, setStatus, settingsSourceLabel, shouldCompactContext, shouldRunWorktreeCleanup, sideboardHomeDir, sideboardReposDir, sideboardWorkspacesDir, slugify, spawnAgentTurn, splitForCompaction, startDevServer, startMcpServer, startOrchestration, stripBrightsyNdjsonNoise, suggestSlug, summarizeConversation, switchBrightsyAccount, syncWorkspacesFromThreads, takenTeamSlugsForChatTab, takenTeamSlugsForOrchestration, taskMessageText, threadDisplayLabel, threadFilePath, threadLockPath, threadsDir, threadsSharingWorktree, toolDescription, toolDetail, toolFilePath, totalTokens, updateAdvancedSettings, updateAppEnvironment, updateBrightsySettings, updateClaudeSettings, updateIntegrationsSettings, updateThread, validateLinearApiKey, withAgentInstructions, withThreadLock, workspaceSettingsSourceLabel, worktreeCleanupSettings, worktreeDisplayLabel, worktreeDisplayLabelForGroup, worktreeNameFromPath, worktreesRoot, writeInjectedMcpConfig, writeThread, writeWorktreeFile };
2372
+ export { type ActiveRun, type AdoptInput, type AdvancedAppSettings, type AgentAdapter, type AgentEvent, type AgentInstructionFile, type AgentKind, type AgentStatus, type AgentTurnInput, type AnthropicCacheControl, type AppSettings, type ApplyIntoMainResult, type AttachCommand, type Autonomy, BRIGHTSY_MCP_ALLOWED_TOOLS, type BranchInfo, type BrightsyAccount, type BrightsyChatTarget, type BrightsyChatTargets, type BrightsyCloudConnectAgent, type BrightsyHarnessSettings, type BrightsySession, BrightsySideboardApi, type BrightsyTeamTargets, CLOUD_COORDINATOR_BUSY_REPLY, CLOUD_COORDINATOR_STOPPED_REPLY, CLOUD_COORDINATOR_TIMEOUT_REPLY, CLOUD_ORCHESTRATOR_GOAL, CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAGES, CONTEXT_MIN_MESSAGES, COORDINATOR_TOOL_PLAYBOOK, type ClaudeHarnessSettings, type CleanupOrphansResult, type CloudConnectAgent, type CloudConnectOptions, type CloudConnectStatus, type CompactResult, type CompactThresholds, type ConductorSettings, type ConductorWorkspace, type ConnectedBrightsyTeamInfo, type CreateChatTabInput, type CreateGlobalChatOpts, type CreateThreadInput, type CreateWorktreeResult, type CursorSdkStreamMessage, type CursorTurnRequest, type CursorWorktreesConfig, type DevServerHandle, type DiffCommit, type DiffFile, type DiffResult, type DiffScope, type DiffScopeStat, type ExpandResult, FAMOUS_SOCCER_TEAMS, type ForkChatTabInput, type ForkThreadWorktreeInput, type FormatGhLandErrorOptions, GLOBAL_WORKSPACE_ID, type GetDiffOptions, type GitHubStatus, type GitWorktreeStatus, HARNESS_ENV_KEYS, type HarnessId, type IntegrationsSettings, type IpcApi, type IssueInfo, type IssueSource, type LandPreview, type LandResult, type ListIssuesResult, MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS, type McpServerStatus, type MessagePart, Orchestrator, type OrchestratorEvent, type OrchestratorRuntime, type OrphanWorktree, PLAN_MODE_INSTRUCTION, type PrActor, type PrCheckRun, type PrCommentInfo, type PrCommitInfo, type PrDetails, type PrInfo, type PrMeta, type PrReviewInfo, type RepoSettings, type RepoSetupInfo, type RunMode, type RunScript, SIDEBOARD_FORCE_STOP, SIDEBOARD_MCP_ALLOWED_TOOLS, type ScriptHandle, type SkillInfo, type SourceType, type SpawnTurnHandle, type SummarizeResult, type TeamName, type Thread, type ThreadAttachment, type ThreadMessage, type ThreadOptionsPatch, type ThreadStatus, type TokenUsage, type TranscriptToolDetail, type TurnCommand, type Workspace, type WorkspaceInventoryEntry, type WorkspaceScriptEnvOpts, addWorkspace, adoptThread, allAdapters, allocatePort, allocatePortRange, allocateTeamName, allocateTeamSlug, appDataDir, appSettingsPath, appendMessage, applyAgentEvent, applyAppEnvironment, applyCompaction, applyThreadIntoMain, autoCleanupOrphansEnabled, autoRenameBranchEnabled, autoRunAfterSetupEnabled, branchDisplayLabel, brightsyAdapter, brightsyCloudConnectAgent, brightsyCloudConnectEnabled, brightsyConfigPath, brightsyMcpAllowedTools, brightsyMcpServerName, buildCachedUserContent, buildClaudeStreamJsonUserMessage, buildForkTranscriptAttachment, buildSessionSeed, buildWorkspaceScriptEnv, caffeinateWhileCloudConnectEnabled, caffeinateWhileRunningEnabled, captureLoginEnv, captureTurnBaseline, childEnvWithAppSettings, claudeAdapter, claudeChromeEnabled, claudeUserSettingsPath, cleanupOrphanWorktrees, cloneRepoIntoSideboard, codexAdapter, collectTakenTeamSlugs, commitAll, conductorDbPath, confirmLand, connectBrightsyTeam, coordinatorSystemPrompt, coordinatorTurnReminder, copyConfiguredFiles, countCacheControlBlocks, createChatTab, createEmptyThread, createGlobalChat, createOrUpdatePr, createThread, createThreadWorktree, currentBranch, cursorAdapter, cursorSdkMessageToEvents, decodeBrightsyTarget, deleteBranchOnPurgeEnabled, deleteThreadRecord, detectAgents, detectLocalMergeConflicts, disconnectBrightsyTeam, discoverSkills, encodeBrightsyTarget, enrichWorkspacesWithGithub, ensureAgentPath, ensureCloudCoordinator, ensureGhPreferOrigin, ensureGlobalCoordinatorCwd, ensureWorkspace, estimateMessageChars, estimateThreadChars, expandComposerPrompt, extractGhErrorDetail, extractiveSummary, fetchPrHead, finalizeParts, findInvalidCacheControlTtlOrder, findOrphanWorktrees, findThreadByRef, flattenTurnInput, forkChatTab, forkMessageSlice, forkThreadWorktree, formatAgentInstructions, formatBrightsyFetchError, formatGhLandError, formatIpcInvokeError, formatMessagesAsTranscript, formatRateLimitResetHint, formatRenameBranchDirective, formatTranscriptMarkdown, formatWorkspaceInventory, formatWorktreeDirective, getAdapter, getBrightsySession, getDefaultRunScript, getDiff, getDiffSummary, getGitHubStatus, getIssueSource, getLinearApiKey, getOrchestrator, getPr, getPrChecks, getPrDetails, getPrMeta, getRepoSetupInfo, getRunMode, getRunScript, gh, ghHeadRef, ghRepoSelectArgs, git, globalAgentCwd, harnessEnvKey, hasConductorHook, hasCursorWorktreeSetup, hasRepoHook, hasWorkspaceHook, healOrchestrationSoccerTitles, importConductorWorkspace, importConductorWorkspaceAsync, initializeGitRepository, inspectGitWorktree, isBrightsyConnected, isBrightsyNdjsonLine, isCloudCoordinatorThread, isDirty, isGhRateLimitError, isGlobalRepoPath, isGlobalThread, isLinearConnected, isOrchestratorThread, isPlaceholderBranch, listBranchCommits, listBranches, listBrightsyAccounts, listBrightsyChatTargets, listConductorWorkspaces, listConnectedBrightsyTeams, listGitHubIssues, listGlobalThreads, listIssues, listLinearIssues, listLinearIssuesDirect, listPrs, listRunScripts, listThreads, listWorkspaces, listWorktreeFiles, listWorktrees, loadAgentInstructions, loadAppSettings, loadBrightsyConfig, loadConductorSettings, loadRepoSettings, loadWorkspaceSettings, locksDir, maxConcurrentAgents, maybeCompactContext, mcpAllowTools, mcpAuthWarnings, mergePr, mergeUsage, normalizeParseResult, normalizeThread, normalizeTurnInput, normalizeWorktreePath, opencodeAdapter, orchestrationTitleNeedsSoccerNickname, orchestratorSessionPoisonedByBuiltins, originGhRepoEnv, parseCursorRunnerLine, parseForceStopMessage, parseGithubSlugFromRemoteUrl, parseMcpList, partsToAssistantText, permissionMode, previewLand, pushBranch, readSkillBody, readThread, readWorktreeFile, readWorktreeInclude, refreshGitHubAuth, removeWorkspace, removeWorktree, repoSlug, requireAgent, resolveClaudeExecutable, resolveConductorCursorAgentId, resolveDefaultBranch, resolveDiffBaseRef, resolveEffectiveIssueSource, resolveFilesToCopy, resolveGithubRepoSlug, resolvePrSelector, resolveRepoRoot, resolveWorktreeStartPoint, run, runArchiveScript, runCloudConnect, runCursorWorktreeSetup, runSetupScript, sameWorktreePath, sanitizeMcpServerName, saveAppSettings, setStatus, settingsSourceLabel, shouldCompactContext, shouldRunWorktreeCleanup, sideboardHomeDir, sideboardReposDir, sideboardWorkspacesDir, slugify, spawnAgentTurn, splitForCompaction, startDevServer, startMcpServer, startOrchestration, stripBrightsyNdjsonNoise, suggestSlug, summarizeConversation, switchBrightsyAccount, syncWorkspacesFromThreads, takenTeamSlugsForChatTab, takenTeamSlugsForOrchestration, taskMessageText, threadDisplayLabel, threadFilePath, threadLockPath, threadsDir, threadsSharingWorktree, toolDescription, toolDetail, toolFilePath, totalTokens, updateAdvancedSettings, updateAppEnvironment, updateBrightsySettings, updateClaudeSettings, updateIntegrationsSettings, updateThread, validateLinearApiKey, withAgentInstructions, withThreadLock, workspaceSettingsSourceLabel, worktreeCleanupSettings, worktreeDisplayLabel, worktreeDisplayLabelForGroup, worktreeNameFromPath, worktreesRoot, writeInjectedMcpConfig, writeThread, writeWorktreeFile };
package/dist/index.d.ts CHANGED
@@ -695,6 +695,10 @@ type FormatGhLandErrorOptions = {
695
695
  /** Land push already succeeded before PR create failed. Default true for PR-create path. */
696
696
  pushed?: boolean;
697
697
  nowMs?: number;
698
+ /** Repo Sideboard passed to `gh -R` (origin), when known. */
699
+ targetedRepo?: string;
700
+ /** Head ref passed to `gh pr create` (often `owner:branch`). */
701
+ headRef?: string;
698
702
  };
699
703
  /**
700
704
  * Turn noisy `gh pr create` / Execa failures into a short notice for UI/CLI.
@@ -757,7 +761,7 @@ declare function worktreeDisplayLabelForGroup(threads: {
757
761
  declare function slugify(input: string): string;
758
762
  declare function resolveRepoRoot(cwd: string): Promise<string>;
759
763
  /**
760
- * Parse `owner/name` from a git remote URL (SSH or HTTPS).
764
+ * Parse `owner/name` from a git remote URL (SSH, HTTPS, or SSH host aliases).
761
765
  */
762
766
  declare function parseGithubSlugFromRemoteUrl(url: string): string | null;
763
767
  /**
@@ -770,6 +774,21 @@ declare function parseGithubSlugFromRemoteUrl(url: string): string | null;
770
774
  * resolves to upstream — which lists the wrong open PRs in the create modal.
771
775
  */
772
776
  declare function resolveGithubRepoSlug(repoPath: string): Promise<string | null>;
777
+ /** Global `-R owner/repo` args so gh never targets upstream by accident. */
778
+ declare function ghRepoSelectArgs(slug: string): string[];
779
+ /** Same-repo head ref as `owner:branch` (required for reliable `-R` creates). */
780
+ declare function ghHeadRef(slug: string, branch: string): string;
781
+ /**
782
+ * On Makerkit-style checkouts (`origin` product + `upstream` template), `gh`
783
+ * prefers `upstream` → so bare `gh pr create` hits the wrong GitHub repo.
784
+ * Pin the CLI default to `origin` once per repo (shared by all worktrees).
785
+ */
786
+ declare function ensureGhPreferOrigin(cwd: string): Promise<void>;
787
+ /**
788
+ * Env pin so bare `gh` (and agents) target this checkout's **origin**, not
789
+ * Makerkit-style `upstream`. `GH_REPO` is the CLI's documented override.
790
+ */
791
+ declare function originGhRepoEnv(cwd: string): Promise<Record<string, string>>;
773
792
  declare function resolveDefaultBranch(repoPath: string): Promise<string>;
774
793
  /**
775
794
  * Prefer `origin/<branch>` for diff/merge-base so Changes / Land don't inflate
@@ -1189,7 +1208,9 @@ declare function formatRenameBranchDirective(thread: Pick<Thread, 'worktreePath'
1189
1208
  * Mandatory Sideboard isolation + landing guidance — agents must edit the thread
1190
1209
  * worktree and open PRs whose titles/bodies describe the *purpose of the changes*.
1191
1210
  */
1192
- declare function formatWorktreeDirective(thread: Pick<Thread, 'worktreePath' | 'repoPath' | 'branchName'> & Partial<Pick<Thread, 'title' | 'prUrl'>>): string;
1211
+ declare function formatWorktreeDirective(thread: Pick<Thread, 'worktreePath' | 'repoPath' | 'branchName'> & Partial<Pick<Thread, 'title' | 'prUrl'>>, opts?: {
1212
+ githubSlug?: string | null;
1213
+ }): string;
1193
1214
  interface AgentInstructionFile {
1194
1215
  relativePath: string;
1195
1216
  content: string;
@@ -2348,4 +2369,4 @@ declare function writeInjectedMcpConfig(opts: {
2348
2369
  includeBrightsy?: boolean;
2349
2370
  }): Promise<string | null>;
2350
2371
 
2351
- export { type ActiveRun, type AdoptInput, type AdvancedAppSettings, type AgentAdapter, type AgentEvent, type AgentInstructionFile, type AgentKind, type AgentStatus, type AgentTurnInput, type AnthropicCacheControl, type AppSettings, type ApplyIntoMainResult, type AttachCommand, type Autonomy, BRIGHTSY_MCP_ALLOWED_TOOLS, type BranchInfo, type BrightsyAccount, type BrightsyChatTarget, type BrightsyChatTargets, type BrightsyCloudConnectAgent, type BrightsyHarnessSettings, type BrightsySession, BrightsySideboardApi, type BrightsyTeamTargets, CLOUD_COORDINATOR_BUSY_REPLY, CLOUD_COORDINATOR_STOPPED_REPLY, CLOUD_COORDINATOR_TIMEOUT_REPLY, CLOUD_ORCHESTRATOR_GOAL, CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAGES, CONTEXT_MIN_MESSAGES, COORDINATOR_TOOL_PLAYBOOK, type ClaudeHarnessSettings, type CleanupOrphansResult, type CloudConnectAgent, type CloudConnectOptions, type CloudConnectStatus, type CompactResult, type CompactThresholds, type ConductorSettings, type ConductorWorkspace, type ConnectedBrightsyTeamInfo, type CreateChatTabInput, type CreateGlobalChatOpts, type CreateThreadInput, type CreateWorktreeResult, type CursorSdkStreamMessage, type CursorTurnRequest, type CursorWorktreesConfig, type DevServerHandle, type DiffCommit, type DiffFile, type DiffResult, type DiffScope, type DiffScopeStat, type ExpandResult, FAMOUS_SOCCER_TEAMS, type ForkChatTabInput, type ForkThreadWorktreeInput, type FormatGhLandErrorOptions, GLOBAL_WORKSPACE_ID, type GetDiffOptions, type GitHubStatus, type GitWorktreeStatus, HARNESS_ENV_KEYS, type HarnessId, type IntegrationsSettings, type IpcApi, type IssueInfo, type IssueSource, type LandPreview, type LandResult, type ListIssuesResult, MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS, type McpServerStatus, type MessagePart, Orchestrator, type OrchestratorEvent, type OrchestratorRuntime, type OrphanWorktree, PLAN_MODE_INSTRUCTION, type PrActor, type PrCheckRun, type PrCommentInfo, type PrCommitInfo, type PrDetails, type PrInfo, type PrMeta, type PrReviewInfo, type RepoSettings, type RepoSetupInfo, type RunMode, type RunScript, SIDEBOARD_FORCE_STOP, SIDEBOARD_MCP_ALLOWED_TOOLS, type ScriptHandle, type SkillInfo, type SourceType, type SpawnTurnHandle, type SummarizeResult, type TeamName, type Thread, type ThreadAttachment, type ThreadMessage, type ThreadOptionsPatch, type ThreadStatus, type TokenUsage, type TranscriptToolDetail, type TurnCommand, type Workspace, type WorkspaceInventoryEntry, type WorkspaceScriptEnvOpts, addWorkspace, adoptThread, allAdapters, allocatePort, allocatePortRange, allocateTeamName, allocateTeamSlug, appDataDir, appSettingsPath, appendMessage, applyAgentEvent, applyAppEnvironment, applyCompaction, applyThreadIntoMain, autoCleanupOrphansEnabled, autoRenameBranchEnabled, autoRunAfterSetupEnabled, branchDisplayLabel, brightsyAdapter, brightsyCloudConnectAgent, brightsyCloudConnectEnabled, brightsyConfigPath, brightsyMcpAllowedTools, brightsyMcpServerName, buildCachedUserContent, buildClaudeStreamJsonUserMessage, buildForkTranscriptAttachment, buildSessionSeed, buildWorkspaceScriptEnv, caffeinateWhileCloudConnectEnabled, caffeinateWhileRunningEnabled, captureLoginEnv, captureTurnBaseline, childEnvWithAppSettings, claudeAdapter, claudeChromeEnabled, claudeUserSettingsPath, cleanupOrphanWorktrees, cloneRepoIntoSideboard, codexAdapter, collectTakenTeamSlugs, commitAll, conductorDbPath, confirmLand, connectBrightsyTeam, coordinatorSystemPrompt, coordinatorTurnReminder, copyConfiguredFiles, countCacheControlBlocks, createChatTab, createEmptyThread, createGlobalChat, createOrUpdatePr, createThread, createThreadWorktree, currentBranch, cursorAdapter, cursorSdkMessageToEvents, decodeBrightsyTarget, deleteBranchOnPurgeEnabled, deleteThreadRecord, detectAgents, detectLocalMergeConflicts, disconnectBrightsyTeam, discoverSkills, encodeBrightsyTarget, enrichWorkspacesWithGithub, ensureAgentPath, ensureCloudCoordinator, ensureGlobalCoordinatorCwd, ensureWorkspace, estimateMessageChars, estimateThreadChars, expandComposerPrompt, extractGhErrorDetail, extractiveSummary, fetchPrHead, finalizeParts, findInvalidCacheControlTtlOrder, findOrphanWorktrees, findThreadByRef, flattenTurnInput, forkChatTab, forkMessageSlice, forkThreadWorktree, formatAgentInstructions, formatBrightsyFetchError, formatGhLandError, formatIpcInvokeError, formatMessagesAsTranscript, formatRateLimitResetHint, formatRenameBranchDirective, formatTranscriptMarkdown, formatWorkspaceInventory, formatWorktreeDirective, getAdapter, getBrightsySession, getDefaultRunScript, getDiff, getDiffSummary, getGitHubStatus, getIssueSource, getLinearApiKey, getOrchestrator, getPr, getPrChecks, getPrDetails, getPrMeta, getRepoSetupInfo, getRunMode, getRunScript, gh, git, globalAgentCwd, harnessEnvKey, hasConductorHook, hasCursorWorktreeSetup, hasRepoHook, hasWorkspaceHook, healOrchestrationSoccerTitles, importConductorWorkspace, importConductorWorkspaceAsync, initializeGitRepository, inspectGitWorktree, isBrightsyConnected, isBrightsyNdjsonLine, isCloudCoordinatorThread, isDirty, isGhRateLimitError, isGlobalRepoPath, isGlobalThread, isLinearConnected, isOrchestratorThread, isPlaceholderBranch, listBranchCommits, listBranches, listBrightsyAccounts, listBrightsyChatTargets, listConductorWorkspaces, listConnectedBrightsyTeams, listGitHubIssues, listGlobalThreads, listIssues, listLinearIssues, listLinearIssuesDirect, listPrs, listRunScripts, listThreads, listWorkspaces, listWorktreeFiles, listWorktrees, loadAgentInstructions, loadAppSettings, loadBrightsyConfig, loadConductorSettings, loadRepoSettings, loadWorkspaceSettings, locksDir, maxConcurrentAgents, maybeCompactContext, mcpAllowTools, mcpAuthWarnings, mergePr, mergeUsage, normalizeParseResult, normalizeThread, normalizeTurnInput, normalizeWorktreePath, opencodeAdapter, orchestrationTitleNeedsSoccerNickname, orchestratorSessionPoisonedByBuiltins, parseCursorRunnerLine, parseForceStopMessage, parseGithubSlugFromRemoteUrl, parseMcpList, partsToAssistantText, permissionMode, previewLand, pushBranch, readSkillBody, readThread, readWorktreeFile, readWorktreeInclude, refreshGitHubAuth, removeWorkspace, removeWorktree, repoSlug, requireAgent, resolveClaudeExecutable, resolveConductorCursorAgentId, resolveDefaultBranch, resolveDiffBaseRef, resolveEffectiveIssueSource, resolveFilesToCopy, resolveGithubRepoSlug, resolvePrSelector, resolveRepoRoot, resolveWorktreeStartPoint, run, runArchiveScript, runCloudConnect, runCursorWorktreeSetup, runSetupScript, sameWorktreePath, sanitizeMcpServerName, saveAppSettings, setStatus, settingsSourceLabel, shouldCompactContext, shouldRunWorktreeCleanup, sideboardHomeDir, sideboardReposDir, sideboardWorkspacesDir, slugify, spawnAgentTurn, splitForCompaction, startDevServer, startMcpServer, startOrchestration, stripBrightsyNdjsonNoise, suggestSlug, summarizeConversation, switchBrightsyAccount, syncWorkspacesFromThreads, takenTeamSlugsForChatTab, takenTeamSlugsForOrchestration, taskMessageText, threadDisplayLabel, threadFilePath, threadLockPath, threadsDir, threadsSharingWorktree, toolDescription, toolDetail, toolFilePath, totalTokens, updateAdvancedSettings, updateAppEnvironment, updateBrightsySettings, updateClaudeSettings, updateIntegrationsSettings, updateThread, validateLinearApiKey, withAgentInstructions, withThreadLock, workspaceSettingsSourceLabel, worktreeCleanupSettings, worktreeDisplayLabel, worktreeDisplayLabelForGroup, worktreeNameFromPath, worktreesRoot, writeInjectedMcpConfig, writeThread, writeWorktreeFile };
2372
+ export { type ActiveRun, type AdoptInput, type AdvancedAppSettings, type AgentAdapter, type AgentEvent, type AgentInstructionFile, type AgentKind, type AgentStatus, type AgentTurnInput, type AnthropicCacheControl, type AppSettings, type ApplyIntoMainResult, type AttachCommand, type Autonomy, BRIGHTSY_MCP_ALLOWED_TOOLS, type BranchInfo, type BrightsyAccount, type BrightsyChatTarget, type BrightsyChatTargets, type BrightsyCloudConnectAgent, type BrightsyHarnessSettings, type BrightsySession, BrightsySideboardApi, type BrightsyTeamTargets, CLOUD_COORDINATOR_BUSY_REPLY, CLOUD_COORDINATOR_STOPPED_REPLY, CLOUD_COORDINATOR_TIMEOUT_REPLY, CLOUD_ORCHESTRATOR_GOAL, CONTEXT_COMPACT_CHARS, CONTEXT_KEEP_RECENT_CHARS, CONTEXT_KEEP_RECENT_MESSAGES, CONTEXT_MIN_MESSAGES, COORDINATOR_TOOL_PLAYBOOK, type ClaudeHarnessSettings, type CleanupOrphansResult, type CloudConnectAgent, type CloudConnectOptions, type CloudConnectStatus, type CompactResult, type CompactThresholds, type ConductorSettings, type ConductorWorkspace, type ConnectedBrightsyTeamInfo, type CreateChatTabInput, type CreateGlobalChatOpts, type CreateThreadInput, type CreateWorktreeResult, type CursorSdkStreamMessage, type CursorTurnRequest, type CursorWorktreesConfig, type DevServerHandle, type DiffCommit, type DiffFile, type DiffResult, type DiffScope, type DiffScopeStat, type ExpandResult, FAMOUS_SOCCER_TEAMS, type ForkChatTabInput, type ForkThreadWorktreeInput, type FormatGhLandErrorOptions, GLOBAL_WORKSPACE_ID, type GetDiffOptions, type GitHubStatus, type GitWorktreeStatus, HARNESS_ENV_KEYS, type HarnessId, type IntegrationsSettings, type IpcApi, type IssueInfo, type IssueSource, type LandPreview, type LandResult, type ListIssuesResult, MAX_ANTHROPIC_CACHE_CONTROL_BLOCKS, type McpServerStatus, type MessagePart, Orchestrator, type OrchestratorEvent, type OrchestratorRuntime, type OrphanWorktree, PLAN_MODE_INSTRUCTION, type PrActor, type PrCheckRun, type PrCommentInfo, type PrCommitInfo, type PrDetails, type PrInfo, type PrMeta, type PrReviewInfo, type RepoSettings, type RepoSetupInfo, type RunMode, type RunScript, SIDEBOARD_FORCE_STOP, SIDEBOARD_MCP_ALLOWED_TOOLS, type ScriptHandle, type SkillInfo, type SourceType, type SpawnTurnHandle, type SummarizeResult, type TeamName, type Thread, type ThreadAttachment, type ThreadMessage, type ThreadOptionsPatch, type ThreadStatus, type TokenUsage, type TranscriptToolDetail, type TurnCommand, type Workspace, type WorkspaceInventoryEntry, type WorkspaceScriptEnvOpts, addWorkspace, adoptThread, allAdapters, allocatePort, allocatePortRange, allocateTeamName, allocateTeamSlug, appDataDir, appSettingsPath, appendMessage, applyAgentEvent, applyAppEnvironment, applyCompaction, applyThreadIntoMain, autoCleanupOrphansEnabled, autoRenameBranchEnabled, autoRunAfterSetupEnabled, branchDisplayLabel, brightsyAdapter, brightsyCloudConnectAgent, brightsyCloudConnectEnabled, brightsyConfigPath, brightsyMcpAllowedTools, brightsyMcpServerName, buildCachedUserContent, buildClaudeStreamJsonUserMessage, buildForkTranscriptAttachment, buildSessionSeed, buildWorkspaceScriptEnv, caffeinateWhileCloudConnectEnabled, caffeinateWhileRunningEnabled, captureLoginEnv, captureTurnBaseline, childEnvWithAppSettings, claudeAdapter, claudeChromeEnabled, claudeUserSettingsPath, cleanupOrphanWorktrees, cloneRepoIntoSideboard, codexAdapter, collectTakenTeamSlugs, commitAll, conductorDbPath, confirmLand, connectBrightsyTeam, coordinatorSystemPrompt, coordinatorTurnReminder, copyConfiguredFiles, countCacheControlBlocks, createChatTab, createEmptyThread, createGlobalChat, createOrUpdatePr, createThread, createThreadWorktree, currentBranch, cursorAdapter, cursorSdkMessageToEvents, decodeBrightsyTarget, deleteBranchOnPurgeEnabled, deleteThreadRecord, detectAgents, detectLocalMergeConflicts, disconnectBrightsyTeam, discoverSkills, encodeBrightsyTarget, enrichWorkspacesWithGithub, ensureAgentPath, ensureCloudCoordinator, ensureGhPreferOrigin, ensureGlobalCoordinatorCwd, ensureWorkspace, estimateMessageChars, estimateThreadChars, expandComposerPrompt, extractGhErrorDetail, extractiveSummary, fetchPrHead, finalizeParts, findInvalidCacheControlTtlOrder, findOrphanWorktrees, findThreadByRef, flattenTurnInput, forkChatTab, forkMessageSlice, forkThreadWorktree, formatAgentInstructions, formatBrightsyFetchError, formatGhLandError, formatIpcInvokeError, formatMessagesAsTranscript, formatRateLimitResetHint, formatRenameBranchDirective, formatTranscriptMarkdown, formatWorkspaceInventory, formatWorktreeDirective, getAdapter, getBrightsySession, getDefaultRunScript, getDiff, getDiffSummary, getGitHubStatus, getIssueSource, getLinearApiKey, getOrchestrator, getPr, getPrChecks, getPrDetails, getPrMeta, getRepoSetupInfo, getRunMode, getRunScript, gh, ghHeadRef, ghRepoSelectArgs, git, globalAgentCwd, harnessEnvKey, hasConductorHook, hasCursorWorktreeSetup, hasRepoHook, hasWorkspaceHook, healOrchestrationSoccerTitles, importConductorWorkspace, importConductorWorkspaceAsync, initializeGitRepository, inspectGitWorktree, isBrightsyConnected, isBrightsyNdjsonLine, isCloudCoordinatorThread, isDirty, isGhRateLimitError, isGlobalRepoPath, isGlobalThread, isLinearConnected, isOrchestratorThread, isPlaceholderBranch, listBranchCommits, listBranches, listBrightsyAccounts, listBrightsyChatTargets, listConductorWorkspaces, listConnectedBrightsyTeams, listGitHubIssues, listGlobalThreads, listIssues, listLinearIssues, listLinearIssuesDirect, listPrs, listRunScripts, listThreads, listWorkspaces, listWorktreeFiles, listWorktrees, loadAgentInstructions, loadAppSettings, loadBrightsyConfig, loadConductorSettings, loadRepoSettings, loadWorkspaceSettings, locksDir, maxConcurrentAgents, maybeCompactContext, mcpAllowTools, mcpAuthWarnings, mergePr, mergeUsage, normalizeParseResult, normalizeThread, normalizeTurnInput, normalizeWorktreePath, opencodeAdapter, orchestrationTitleNeedsSoccerNickname, orchestratorSessionPoisonedByBuiltins, originGhRepoEnv, parseCursorRunnerLine, parseForceStopMessage, parseGithubSlugFromRemoteUrl, parseMcpList, partsToAssistantText, permissionMode, previewLand, pushBranch, readSkillBody, readThread, readWorktreeFile, readWorktreeInclude, refreshGitHubAuth, removeWorkspace, removeWorktree, repoSlug, requireAgent, resolveClaudeExecutable, resolveConductorCursorAgentId, resolveDefaultBranch, resolveDiffBaseRef, resolveEffectiveIssueSource, resolveFilesToCopy, resolveGithubRepoSlug, resolvePrSelector, resolveRepoRoot, resolveWorktreeStartPoint, run, runArchiveScript, runCloudConnect, runCursorWorktreeSetup, runSetupScript, sameWorktreePath, sanitizeMcpServerName, saveAppSettings, setStatus, settingsSourceLabel, shouldCompactContext, shouldRunWorktreeCleanup, sideboardHomeDir, sideboardReposDir, sideboardWorkspacesDir, slugify, spawnAgentTurn, splitForCompaction, startDevServer, startMcpServer, startOrchestration, stripBrightsyNdjsonNoise, suggestSlug, summarizeConversation, switchBrightsyAccount, syncWorkspacesFromThreads, takenTeamSlugsForChatTab, takenTeamSlugsForOrchestration, taskMessageText, threadDisplayLabel, threadFilePath, threadLockPath, threadsDir, threadsSharingWorktree, toolDescription, toolDetail, toolFilePath, totalTokens, updateAdvancedSettings, updateAppEnvironment, updateBrightsySettings, updateClaudeSettings, updateIntegrationsSettings, updateThread, validateLinearApiKey, withAgentInstructions, withThreadLock, workspaceSettingsSourceLabel, worktreeCleanupSettings, worktreeDisplayLabel, worktreeDisplayLabelForGroup, worktreeNameFromPath, worktreesRoot, writeInjectedMcpConfig, writeThread, writeWorktreeFile };