@sideboard-ai/core 0.1.352 → 0.1.353

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.
@@ -15246,7 +15246,84 @@ var init_rpc_env = __esm({
15246
15246
  }
15247
15247
  });
15248
15248
 
15249
+ // src/computer-use/bridge.ts
15250
+ function computerUseBridgePath() {
15251
+ return (0, import_node_path40.join)(appDataDir(), "computer-use-bridge.json");
15252
+ }
15253
+ function readComputerUseBridge(file = computerUseBridgePath()) {
15254
+ try {
15255
+ const raw = JSON.parse((0, import_node_fs38.readFileSync)(file, "utf8"));
15256
+ if (typeof raw.port !== "number" || !Number.isInteger(raw.port)) return null;
15257
+ if (raw.port < 1 || raw.port > 65535) return null;
15258
+ if (typeof raw.token !== "string" || raw.token.length < 16) return null;
15259
+ return { port: raw.port, token: raw.token };
15260
+ } catch {
15261
+ return null;
15262
+ }
15263
+ }
15264
+ function cgScrollWheels(dx, dy) {
15265
+ return { wheel1: -dy, wheel2: -dx };
15266
+ }
15267
+ async function bridgeError(res) {
15268
+ try {
15269
+ const body = await res.json();
15270
+ if (typeof body.error === "string" && body.error) return body.error;
15271
+ } catch {
15272
+ }
15273
+ return `computer use bridge returned ${res.status}`;
15274
+ }
15275
+ async function bridgeFetch(info, path, init) {
15276
+ try {
15277
+ return await fetch(`http://127.0.0.1:${info.port}${path}`, {
15278
+ ...init,
15279
+ headers: {
15280
+ authorization: `Bearer ${info.token}`,
15281
+ ...init.headers
15282
+ },
15283
+ signal: AbortSignal.timeout(15e3)
15284
+ });
15285
+ } catch {
15286
+ return null;
15287
+ }
15288
+ }
15289
+ async function postComputerUseBridge(event, file = computerUseBridgePath()) {
15290
+ const info = readComputerUseBridge(file);
15291
+ if (!info) return false;
15292
+ const res = await bridgeFetch(info, "/v1/event", {
15293
+ method: "POST",
15294
+ headers: { "content-type": "application/json" },
15295
+ body: JSON.stringify(event)
15296
+ });
15297
+ if (!res) return false;
15298
+ if (!res.ok) throw new Error(await bridgeError(res));
15299
+ return true;
15300
+ }
15301
+ async function fetchComputerUseScreenshot(file = computerUseBridgePath()) {
15302
+ const info = readComputerUseBridge(file);
15303
+ if (!info) return null;
15304
+ const res = await bridgeFetch(info, "/v1/screenshot", { method: "POST" });
15305
+ if (!res) return null;
15306
+ if (!res.ok) throw new Error(await bridgeError(res));
15307
+ const png = Buffer.from(await res.arrayBuffer());
15308
+ if (png.length < 24) throw new Error("screen capture was empty");
15309
+ const header = Number(res.headers.get("x-sideboard-scale"));
15310
+ return { png, scale: Number.isFinite(header) && header > 0 ? header : 1 };
15311
+ }
15312
+ var import_node_fs38, import_node_path40;
15313
+ var init_bridge = __esm({
15314
+ "src/computer-use/bridge.ts"() {
15315
+ "use strict";
15316
+ import_node_fs38 = require("fs");
15317
+ import_node_path40 = require("path");
15318
+ init_paths();
15319
+ }
15320
+ });
15321
+
15249
15322
  // src/computer-use/computer-use.ts
15323
+ function macKeyCode(key) {
15324
+ const code = KEY_CODES[key];
15325
+ return code === void 0 ? null : code;
15326
+ }
15250
15327
  function appleScriptString(text8) {
15251
15328
  return `"${text8.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
15252
15329
  }
@@ -15313,8 +15390,7 @@ function scrollWheelSwift(x, y, dx, dy) {
15313
15390
  for (const n of [x, y, dx, dy]) {
15314
15391
  if (!Number.isInteger(n)) throw new Error("scroll coordinates must be integers");
15315
15392
  }
15316
- const wheel1 = -dy;
15317
- const wheel2 = -dx;
15393
+ const { wheel1, wheel2 } = cgScrollWheels(dx, dy);
15318
15394
  return `import CoreGraphics
15319
15395
  let src = CGEventSource(stateID: .hidSystemState)
15320
15396
  let p = CGPoint(x: ${x}, y: ${y})
@@ -15345,10 +15421,14 @@ function scrollDelta(value) {
15345
15421
  return n;
15346
15422
  }
15347
15423
  function screenshotFile(cwd, now) {
15348
- const root = (0, import_node_path40.isAbsolute)(cwd) ? cwd : (0, import_node_os19.tmpdir)();
15349
- const dir = (0, import_node_path40.join)(root, ".context", "cli");
15350
- (0, import_node_fs38.mkdirSync)(dir, { recursive: true });
15351
- return (0, import_node_path40.join)(dir, `computer-use-${now}.png`);
15424
+ const root = (0, import_node_path41.isAbsolute)(cwd) ? cwd : (0, import_node_os19.tmpdir)();
15425
+ const dir = (0, import_node_path41.join)(root, ".context", "cli");
15426
+ (0, import_node_fs39.mkdirSync)(dir, { recursive: true });
15427
+ return (0, import_node_path41.join)(dir, `computer-use-${now}.png`);
15428
+ }
15429
+ async function posted(runner, event) {
15430
+ if (!runner.postInput) return false;
15431
+ return runner.postInput(event);
15352
15432
  }
15353
15433
  function screenshotMessage(width, height, scale) {
15354
15434
  return `Screenshot saved (main display). Read that PNG. x and y are screen points from the top-left of this image, not PNG pixels. Divide a pixel by scale ${scale}. Point size is ${width}\xD7${height}. Judge behavior and visual design: hierarchy, alignment, spacing, type, contrast, and fit with the surrounding surface.`;
@@ -15379,17 +15459,21 @@ async function performComputerUse(opts) {
15379
15459
  const px = point(x);
15380
15460
  const py = point(y);
15381
15461
  if (px === null || py === null) return { ok: false, error: "click point is out of range" };
15382
- await opts.runner.runAppleScript(
15383
- `tell application "System Events" to click at {${px}, ${py}}`
15384
- );
15462
+ if (!await posted(opts.runner, { type: "click", x: px, y: py })) {
15463
+ await opts.runner.runAppleScript(
15464
+ `tell application "System Events" to click at {${px}, ${py}}`
15465
+ );
15466
+ }
15385
15467
  return { ok: true, action, message: `Clicked ${px}, ${py}.` };
15386
15468
  }
15387
15469
  if (action === "type") {
15388
15470
  const text8 = typeof rec.text === "string" ? rec.text : "";
15389
15471
  if (!text8) return { ok: false, error: "type requires text" };
15390
15472
  if (text8.length > 2e3) return { ok: false, error: "type text is longer than 2000 characters" };
15391
- for (const script of typeScripts(text8)) {
15392
- await opts.runner.runAppleScript(script);
15473
+ if (!await posted(opts.runner, { type: "type", text: text8 })) {
15474
+ for (const script of typeScripts(text8)) {
15475
+ await opts.runner.runAppleScript(script);
15476
+ }
15393
15477
  }
15394
15478
  return { ok: true, action, message: `Typed ${text8.length} characters.` };
15395
15479
  }
@@ -15400,11 +15484,14 @@ async function performComputerUse(opts) {
15400
15484
  if (modifiers.some((name) => !MODIFIERS.has(name.toLowerCase()))) {
15401
15485
  return { ok: false, error: "key modifiers are command, shift, option, and control" };
15402
15486
  }
15403
- const using = modifierClause(modifiers.map((name) => name.toLowerCase()));
15404
- const code = KEY_CODES[key];
15405
- const script = code !== void 0 ? `tell application "System Events" to key code ${code}${using}` : key.length === 1 ? `tell application "System Events" to keystroke ${appleScriptString(key)}${using}` : "";
15487
+ const mods = modifiers.map((name) => name.toLowerCase());
15488
+ const using = modifierClause(mods);
15489
+ const code = macKeyCode(key);
15490
+ const script = code !== null ? `tell application "System Events" to key code ${code}${using}` : key.length === 1 ? `tell application "System Events" to keystroke ${appleScriptString(key)}${using}` : "";
15406
15491
  if (!script) return { ok: false, error: `unsupported key ${key}` };
15407
- await opts.runner.runAppleScript(script);
15492
+ if (!await posted(opts.runner, { type: "key", key, modifiers: mods })) {
15493
+ await opts.runner.runAppleScript(script);
15494
+ }
15408
15495
  return { ok: true, action, message: `Pressed ${key}.` };
15409
15496
  }
15410
15497
  if (action === "scroll") {
@@ -15420,7 +15507,9 @@ async function performComputerUse(opts) {
15420
15507
  const sdy = scrollDelta(dy);
15421
15508
  if (sdx === null || sdy === null) return { ok: false, error: "scroll delta is out of range" };
15422
15509
  if (sdx === 0 && sdy === 0) return { ok: false, error: "scroll requires dx or dy" };
15423
- await opts.runner.scroll(px, py, sdx, sdy);
15510
+ if (!await posted(opts.runner, { type: "scroll", x: px, y: py, dx: sdx, dy: sdy })) {
15511
+ await opts.runner.scroll(px, py, sdx, sdy);
15512
+ }
15424
15513
  return {
15425
15514
  ok: true,
15426
15515
  action,
@@ -15439,18 +15528,19 @@ function formatComputerUseHint(enabled) {
15439
15528
  }
15440
15529
  return "Computer use is on. Screenshot returns scale; x and y are screen points (divide a PNG pixel by scale). Scroll is a wheel event at that point.";
15441
15530
  }
15442
- var import_node_child_process5, import_node_fs38, import_node_os19, import_node_path40, import_node_util, execFileAsync, COMPUTER_USE_OFF, COMPUTER_USE_DESCRIPTION, KEY_CODES, MODIFIERS, PNG_SIG, macosComputerUseRunner;
15531
+ var import_node_child_process5, import_node_fs39, import_node_os19, import_node_path41, import_node_util, execFileAsync, COMPUTER_USE_OFF, COMPUTER_USE_DESCRIPTION, KEY_CODES, MODIFIERS, PNG_SIG, macosComputerUseRunner;
15443
15532
  var init_computer_use = __esm({
15444
15533
  "src/computer-use/computer-use.ts"() {
15445
15534
  "use strict";
15446
15535
  import_node_child_process5 = require("child_process");
15447
- import_node_fs38 = require("fs");
15536
+ import_node_fs39 = require("fs");
15448
15537
  import_node_os19 = require("os");
15449
- import_node_path40 = require("path");
15538
+ import_node_path41 = require("path");
15450
15539
  import_node_util = require("util");
15540
+ init_bridge();
15451
15541
  execFileAsync = (0, import_node_util.promisify)(import_node_child_process5.execFile);
15452
15542
  COMPUTER_USE_OFF = "Computer use is off. Turn it on in Settings \u2192 Advanced.";
15453
- COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Sideboard needs Accessibility and Screen Recording permission. Do not drive an app you did not start for this test.";
15543
+ COMPUTER_USE_DESCRIPTION = "Drive this Mac to test an app you started. Off unless Settings \u2192 Advanced \u2192 Computer use is on. action is screenshot, click, type, key, or scroll. screenshot writes a PNG of the main display under the worktree .context/cli/ and returns that path plus point width, height, and scale. Read the image. x and y are screen points from the top-left of that image, not PNG pixels: divide a pixel by scale. click and scroll use those points. scroll posts a wheel event at the point (positive dx is right, positive dy is down). type sends text. key is one key (return, tab, escape, arrows, delete, or one character) with optional modifiers command, shift, option, control. Use it to check behavior and visual design (hierarchy, alignment, spacing, type, contrast, fit with the surrounding surface). preview=window means the Electron window, not a browser tab. Clicks, typing, scrolling, and screenshots are posted by Sideboard after macOS allows Sideboard to control this Mac and record the screen. Do not drive an app you did not start for this test.";
15454
15544
  KEY_CODES = {
15455
15545
  return: 36,
15456
15546
  enter: 36,
@@ -15469,14 +15559,23 @@ var init_computer_use = __esm({
15469
15559
  PNG_SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
15470
15560
  macosComputerUseRunner = {
15471
15561
  async screenshot(file) {
15562
+ const via = await fetchComputerUseScreenshot();
15563
+ if (via) {
15564
+ (0, import_node_fs39.writeFileSync)(file, via.png);
15565
+ const info = pngPointSize(via.png);
15566
+ return { ...info, scale: via.scale > 0 ? via.scale : info.scale };
15567
+ }
15472
15568
  await execFileAsync("screencapture", ["-x", "-m", file]);
15473
- return pngPointSize((0, import_node_fs38.readFileSync)(file));
15569
+ return pngPointSize((0, import_node_fs39.readFileSync)(file));
15474
15570
  },
15475
15571
  async runAppleScript(script) {
15476
15572
  await execFileAsync("osascript", ["-e", script]);
15477
15573
  },
15478
15574
  async scroll(x, y, dx, dy) {
15479
15575
  await execFileAsync("swift", ["-e", scrollWheelSwift(x, y, dx, dy)]);
15576
+ },
15577
+ postInput(event) {
15578
+ return postComputerUseBridge(event);
15480
15579
  }
15481
15580
  };
15482
15581
  }
@@ -15529,11 +15628,11 @@ function entryDir2() {
15529
15628
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
15530
15629
  if (cjsDir) return cjsDir;
15531
15630
  try {
15532
- return (0, import_node_path41.dirname)((0, import_node_url3.fileURLToPath)(import_meta6.url));
15631
+ return (0, import_node_path42.dirname)((0, import_node_url3.fileURLToPath)(import_meta6.url));
15533
15632
  } catch {
15534
15633
  try {
15535
15634
  const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
15536
- return (0, import_node_path41.dirname)(req.resolve("@sideboard-ai/core"));
15635
+ return (0, import_node_path42.dirname)(req.resolve("@sideboard-ai/core"));
15537
15636
  } catch {
15538
15637
  return process.cwd();
15539
15638
  }
@@ -15542,20 +15641,20 @@ function entryDir2() {
15542
15641
  function claudeRunnerPath() {
15543
15642
  const packagedDir = packagedCursorRuntimeDir();
15544
15643
  if (packagedDir) {
15545
- const packaged = (0, import_node_path41.join)(packagedDir, "core-dist", "agents", "claude-runner.js");
15546
- if ((0, import_node_fs39.existsSync)(packaged)) return packaged;
15644
+ const packaged = (0, import_node_path42.join)(packagedDir, "core-dist", "agents", "claude-runner.js");
15645
+ if ((0, import_node_fs40.existsSync)(packaged)) return packaged;
15547
15646
  }
15548
15647
  const root = entryDir2();
15549
15648
  const candidates = [
15550
- (0, import_node_path41.join)(root, "agents", "claude-runner.js"),
15551
- (0, import_node_path41.join)(root, "agents", "claude-runner.cjs"),
15552
- (0, import_node_path41.join)(root, "dist", "agents", "claude-runner.js"),
15553
- (0, import_node_path41.join)(root, "dist", "agents", "claude-runner.cjs"),
15554
- (0, import_node_path41.join)(root, "claude-runner.ts"),
15555
- (0, import_node_path41.join)(root, "src", "agents", "claude-runner.ts")
15649
+ (0, import_node_path42.join)(root, "agents", "claude-runner.js"),
15650
+ (0, import_node_path42.join)(root, "agents", "claude-runner.cjs"),
15651
+ (0, import_node_path42.join)(root, "dist", "agents", "claude-runner.js"),
15652
+ (0, import_node_path42.join)(root, "dist", "agents", "claude-runner.cjs"),
15653
+ (0, import_node_path42.join)(root, "claude-runner.ts"),
15654
+ (0, import_node_path42.join)(root, "src", "agents", "claude-runner.ts")
15556
15655
  ];
15557
15656
  for (const candidate of candidates) {
15558
- if ((0, import_node_fs39.existsSync)(candidate)) return candidate;
15657
+ if ((0, import_node_fs40.existsSync)(candidate)) return candidate;
15559
15658
  }
15560
15659
  return candidates[0];
15561
15660
  }
@@ -15579,13 +15678,13 @@ async function buildClaudeRpcTurnCommand(req) {
15579
15678
  }
15580
15679
  };
15581
15680
  }
15582
- var import_node_fs39, import_node_module3, import_node_path41, import_node_url3, import_meta6;
15681
+ var import_node_fs40, import_node_module3, import_node_path42, import_node_url3, import_meta6;
15583
15682
  var init_claude_host = __esm({
15584
15683
  "src/agents/claude-host.ts"() {
15585
15684
  "use strict";
15586
- import_node_fs39 = require("fs");
15685
+ import_node_fs40 = require("fs");
15587
15686
  import_node_module3 = require("module");
15588
- import_node_path41 = require("path");
15687
+ import_node_path42 = require("path");
15589
15688
  import_node_url3 = require("url");
15590
15689
  init_protocol2();
15591
15690
  init_pilot_tools();
@@ -15677,11 +15776,11 @@ function issueAttachmentWorktreePath(repoPath) {
15677
15776
  return raw || process.cwd();
15678
15777
  }
15679
15778
  function ensureIssueAttachmentsDir(worktreePath) {
15680
- const dir = (0, import_node_path42.join)(worktreePath, ATTACHMENTS_DIR);
15681
- (0, import_node_fs40.mkdirSync)(dir, { recursive: true });
15682
- const gi = (0, import_node_path42.join)(dir, ".gitignore");
15683
- if (!(0, import_node_fs40.existsSync)(gi)) {
15684
- (0, import_node_fs40.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
15779
+ const dir = (0, import_node_path43.join)(worktreePath, ATTACHMENTS_DIR);
15780
+ (0, import_node_fs41.mkdirSync)(dir, { recursive: true });
15781
+ const gi = (0, import_node_path43.join)(dir, ".gitignore");
15782
+ if (!(0, import_node_fs41.existsSync)(gi)) {
15783
+ (0, import_node_fs41.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
15685
15784
  }
15686
15785
  return dir;
15687
15786
  }
@@ -15711,7 +15810,7 @@ function looksLikeFileUrl(url) {
15711
15810
  function filenameFromUrl(url, fallback = "attachment") {
15712
15811
  try {
15713
15812
  const parsed = new URL(url);
15714
- const last = decodeURIComponent((0, import_node_path42.basename)(parsed.pathname)).replace(/[/\\]/g, "_");
15813
+ const last = decodeURIComponent((0, import_node_path43.basename)(parsed.pathname)).replace(/[/\\]/g, "_");
15715
15814
  if (last && last !== "/" && last !== ".") return last;
15716
15815
  } catch {
15717
15816
  }
@@ -15733,12 +15832,12 @@ function filenameFromContentDisposition(header) {
15733
15832
  }
15734
15833
  function uniqueAttachmentFileName(dir, originalName) {
15735
15834
  const safe = originalName.replace(/[/\\]/g, "_").replace(/^\.+/, "") || "file";
15736
- if (!(0, import_node_fs40.existsSync)((0, import_node_path42.join)(dir, safe))) return safe;
15737
- const ext = (0, import_node_path42.extname)(safe);
15835
+ if (!(0, import_node_fs41.existsSync)((0, import_node_path43.join)(dir, safe))) return safe;
15836
+ const ext = (0, import_node_path43.extname)(safe);
15738
15837
  const stem = ext ? safe.slice(0, -ext.length) : safe;
15739
15838
  for (let i = 1; i < 1e4; i++) {
15740
15839
  const candidate = `${stem}-${i}${ext}`;
15741
- if (!(0, import_node_fs40.existsSync)((0, import_node_path42.join)(dir, candidate))) return candidate;
15840
+ if (!(0, import_node_fs41.existsSync)((0, import_node_path43.join)(dir, candidate))) return candidate;
15742
15841
  }
15743
15842
  return `${stem}-${(0, import_node_crypto10.randomUUID)()}${ext}`;
15744
15843
  }
@@ -15786,7 +15885,7 @@ function mergeIssueAttachments(items) {
15786
15885
  return out;
15787
15886
  }
15788
15887
  function extensionForContentType(contentType, name) {
15789
- if ((0, import_node_path42.extname)(name)) return name;
15888
+ if ((0, import_node_path43.extname)(name)) return name;
15790
15889
  const mime = (contentType ?? "").split(";")[0]?.trim().toLowerCase() ?? "";
15791
15890
  const ext = EXT_BY_MIME[mime];
15792
15891
  return ext ? `${name}${ext}` : name;
@@ -15838,7 +15937,7 @@ async function downloadAuthenticatedFile(opts) {
15838
15937
  const dir = ensureIssueAttachmentsDir(opts.worktreePath);
15839
15938
  const hinted = opts.name?.trim() || filenameFromContentDisposition(res.headers.get("content-disposition")) || filenameFromUrl(url);
15840
15939
  const name = uniqueAttachmentFileName(dir, extensionForContentType(contentType, hinted));
15841
- (0, import_node_fs40.writeFileSync)((0, import_node_path42.join)(dir, name), buf);
15940
+ (0, import_node_fs41.writeFileSync)((0, import_node_path43.join)(dir, name), buf);
15842
15941
  return {
15843
15942
  name,
15844
15943
  path: `${ATTACHMENTS_DIR}/${name}`,
@@ -15846,12 +15945,12 @@ async function downloadAuthenticatedFile(opts) {
15846
15945
  ...contentType ? { contentType } : {}
15847
15946
  };
15848
15947
  }
15849
- var import_node_fs40, import_node_path42, import_node_crypto10, ISSUE_ATTACHMENT_MAX_BYTES, MARKDOWN_IMAGE_RE, MARKDOWN_LINK_RE, HTML_SRC_RE, BARE_URL_RE, EXT_BY_MIME;
15948
+ var import_node_fs41, import_node_path43, import_node_crypto10, ISSUE_ATTACHMENT_MAX_BYTES, MARKDOWN_IMAGE_RE, MARKDOWN_LINK_RE, HTML_SRC_RE, BARE_URL_RE, EXT_BY_MIME;
15850
15949
  var init_issue_attachments = __esm({
15851
15950
  "src/integrations/issue-attachments.ts"() {
15852
15951
  "use strict";
15853
- import_node_fs40 = require("fs");
15854
- import_node_path42 = require("path");
15952
+ import_node_fs41 = require("fs");
15953
+ import_node_path43 = require("path");
15855
15954
  import_node_crypto10 = require("crypto");
15856
15955
  init_fetch();
15857
15956
  init_workspace_scratch();
@@ -17504,12 +17603,12 @@ function compactMetadataFromClaude(obj) {
17504
17603
  const postTokens = typeof post === "number" && Number.isFinite(post) && post > 0 ? Math.round(post) : void 0;
17505
17604
  return { trigger, postTokens };
17506
17605
  }
17507
- var import_node_fs41, import_node_path43, CLAUDE_PROMPT_ARG_MAX, claudeAdapter;
17606
+ var import_node_fs42, import_node_path44, CLAUDE_PROMPT_ARG_MAX, claudeAdapter;
17508
17607
  var init_claude = __esm({
17509
17608
  "src/agents/claude.ts"() {
17510
17609
  "use strict";
17511
- import_node_fs41 = require("fs");
17512
- import_node_path43 = require("path");
17610
+ import_node_fs42 = require("fs");
17611
+ import_node_path44 = require("path");
17513
17612
  init_run();
17514
17613
  init_app_settings();
17515
17614
  init_claude_mcp_status();
@@ -17529,7 +17628,7 @@ var init_claude = __esm({
17529
17628
  async detect() {
17530
17629
  const claude = resolveClaudeExecutable();
17531
17630
  if (claude !== "claude") {
17532
- if (!(0, import_node_fs41.existsSync)(claude)) {
17631
+ if (!(0, import_node_fs42.existsSync)(claude)) {
17533
17632
  return {
17534
17633
  agent: "claude",
17535
17634
  installed: false,
@@ -17687,7 +17786,7 @@ ${hint}` : hint;
17687
17786
  cwd: thread.worktreePath,
17688
17787
  stdin: useStdin ? `${promptText}
17689
17788
  ` : void 0,
17690
- ...mcpConfigPath ? { cleanupDirs: [(0, import_node_path43.dirname)(mcpConfigPath)] } : {},
17789
+ ...mcpConfigPath ? { cleanupDirs: [(0, import_node_path44.dirname)(mcpConfigPath)] } : {},
17691
17790
  // Nested Task/Agent thinking+text in stream-json (Claude Code 2.1.211+).
17692
17791
  // Raise the -p background-agent wait so long TaskOutput polls are not
17693
17792
  // abandoned at Claude Code’s 10-minute default.
@@ -17867,7 +17966,7 @@ async function listCodexModels() {
17867
17966
  if (codex === "codex") {
17868
17967
  const which = await run("which", ["codex"], { reject: false });
17869
17968
  if (which.exitCode !== 0) return FALLBACK_CODEX_MODELS;
17870
- } else if (!(0, import_node_fs42.existsSync)(codex)) {
17969
+ } else if (!(0, import_node_fs43.existsSync)(codex)) {
17871
17970
  return FALLBACK_CODEX_MODELS;
17872
17971
  }
17873
17972
  const listed = await run(codex, ["debug", "models"], { reject: false });
@@ -17904,7 +18003,7 @@ function usageFromCodex(usage, asContext = false) {
17904
18003
  return occ > 0 ? { ...mapped, lastRequestTokens: occ } : mapped;
17905
18004
  }
17906
18005
  function codexHomeDir() {
17907
- return process.env.CODEX_HOME?.trim() || (0, import_node_path44.join)((0, import_node_os20.homedir)(), ".codex");
18006
+ return process.env.CODEX_HOME?.trim() || (0, import_node_path45.join)((0, import_node_os20.homedir)(), ".codex");
17908
18007
  }
17909
18008
  function unwrapCodexMcpResult(result) {
17910
18009
  if (result == null) return void 0;
@@ -17933,21 +18032,21 @@ function asRecord7(value) {
17933
18032
  return void 0;
17934
18033
  }
17935
18034
  function codexLooksAuthenticated() {
17936
- const authPath = (0, import_node_path44.join)(codexHomeDir(), "auth.json");
17937
- if (!(0, import_node_fs42.existsSync)(authPath)) return false;
18035
+ const authPath = (0, import_node_path45.join)(codexHomeDir(), "auth.json");
18036
+ if (!(0, import_node_fs43.existsSync)(authPath)) return false;
17938
18037
  try {
17939
- return (0, import_node_fs42.statSync)(authPath).size > 2;
18038
+ return (0, import_node_fs43.statSync)(authPath).size > 2;
17940
18039
  } catch {
17941
18040
  return false;
17942
18041
  }
17943
18042
  }
17944
- var import_node_fs42, import_node_os20, import_node_path44, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
18043
+ var import_node_fs43, import_node_os20, import_node_path45, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
17945
18044
  var init_codex = __esm({
17946
18045
  "src/agents/codex.ts"() {
17947
18046
  "use strict";
17948
- import_node_fs42 = require("fs");
18047
+ import_node_fs43 = require("fs");
17949
18048
  import_node_os20 = require("os");
17950
- import_node_path44 = require("path");
18049
+ import_node_path45 = require("path");
17951
18050
  init_run();
17952
18051
  init_app_settings();
17953
18052
  init_global_workspace();
@@ -17976,7 +18075,7 @@ var init_codex = __esm({
17976
18075
  async detect() {
17977
18076
  const codex = resolveAgentExecutable("codex");
17978
18077
  if (codex !== "codex") {
17979
- if (!(0, import_node_fs42.existsSync)(codex)) {
18078
+ if (!(0, import_node_fs43.existsSync)(codex)) {
17980
18079
  return {
17981
18080
  agent: "codex",
17982
18081
  installed: false,
@@ -18008,7 +18107,7 @@ var init_codex = __esm({
18008
18107
  authenticated,
18009
18108
  linearMcp,
18010
18109
  warnings,
18011
- reason: authenticated ? void 0 : `Codex auth not found \u2014 run \`codex login\` (expected ${(0, import_node_path44.join)(codexHomeDir(), "auth.json")})`
18110
+ reason: authenticated ? void 0 : `Codex auth not found \u2014 run \`codex login\` (expected ${(0, import_node_path45.join)(codexHomeDir(), "auth.json")})`
18012
18111
  };
18013
18112
  },
18014
18113
  async buildTurn(thread, input) {
@@ -18240,18 +18339,18 @@ var init_codex = __esm({
18240
18339
  // src/agents/cursor-sdk-resolve.ts
18241
18340
  function thisModuleFile() {
18242
18341
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
18243
- if (cjsDir) return (0, import_node_path45.join)(cjsDir, "cursor-sdk-resolve.js");
18342
+ if (cjsDir) return (0, import_node_path46.join)(cjsDir, "cursor-sdk-resolve.js");
18244
18343
  try {
18245
18344
  return (0, import_node_url4.fileURLToPath)(import_meta7.url);
18246
18345
  } catch {
18247
- return (0, import_node_path45.join)(process.cwd(), "package.json");
18346
+ return (0, import_node_path46.join)(process.cwd(), "package.json");
18248
18347
  }
18249
18348
  }
18250
18349
  function packageRootLooksLikeSdk(dir) {
18251
18350
  try {
18252
- const raw = (0, import_node_fs43.readFileSync)((0, import_node_path45.join)(dir, "package.json"), "utf8");
18351
+ const raw = (0, import_node_fs44.readFileSync)((0, import_node_path46.join)(dir, "package.json"), "utf8");
18253
18352
  const pkg = JSON.parse(raw);
18254
- return pkg.name === "@cursor/sdk" && (0, import_node_fs43.existsSync)(dir);
18353
+ return pkg.name === "@cursor/sdk" && (0, import_node_fs44.existsSync)(dir);
18255
18354
  } catch {
18256
18355
  return false;
18257
18356
  }
@@ -18260,7 +18359,7 @@ function resolvedPackageRoot(fromFile) {
18260
18359
  try {
18261
18360
  const req = (0, import_node_module4.createRequire)(fromFile);
18262
18361
  const pkgJson = req.resolve("@cursor/sdk/package.json");
18263
- const root = (0, import_node_path45.dirname)(pkgJson);
18362
+ const root = (0, import_node_path46.dirname)(pkgJson);
18264
18363
  return packageRootLooksLikeSdk(root) ? root : null;
18265
18364
  } catch {
18266
18365
  return null;
@@ -18274,10 +18373,10 @@ function resolveCursorSdkRoot(opts) {
18274
18373
  }
18275
18374
  const globalNm = npmGlobalNodeModules(env);
18276
18375
  if (globalNm) {
18277
- const globalRoot = (0, import_node_path45.join)(globalNm, "@cursor/sdk");
18376
+ const globalRoot = (0, import_node_path46.join)(globalNm, "@cursor/sdk");
18278
18377
  if (packageRootLooksLikeSdk(globalRoot)) return globalRoot;
18279
18378
  }
18280
- const cwdPkg = (0, import_node_path45.join)(process.cwd(), "package.json");
18379
+ const cwdPkg = (0, import_node_path46.join)(process.cwd(), "package.json");
18281
18380
  return resolvedPackageRoot(thisModuleFile()) ?? resolvedPackageRoot(cwdPkg);
18282
18381
  }
18283
18382
  function isCursorSdkInstalled(opts) {
@@ -18293,13 +18392,13 @@ function exportTarget(value) {
18293
18392
  }
18294
18393
  function cursorSdkEsmEntry(root) {
18295
18394
  try {
18296
- const pkg = JSON.parse((0, import_node_fs43.readFileSync)((0, import_node_path45.join)(root, "package.json"), "utf8"));
18395
+ const pkg = JSON.parse((0, import_node_fs44.readFileSync)((0, import_node_path46.join)(root, "package.json"), "utf8"));
18297
18396
  const exp = pkg.exports;
18298
18397
  const dot = exp && typeof exp === "object" && !Array.isArray(exp) && "." in exp ? exp["."] : exp;
18299
18398
  const rel = exportTarget(dot) ?? (typeof pkg.module === "string" ? pkg.module : null);
18300
18399
  if (!rel) return null;
18301
- const entry = (0, import_node_path45.join)(root, rel);
18302
- return (0, import_node_fs43.existsSync)(entry) ? entry : null;
18400
+ const entry = (0, import_node_path46.join)(root, rel);
18401
+ return (0, import_node_fs44.existsSync)(entry) ? entry : null;
18303
18402
  } catch {
18304
18403
  return null;
18305
18404
  }
@@ -18315,7 +18414,7 @@ async function importCursorSdk(opts) {
18315
18414
  try {
18316
18415
  let entry = cursorSdkEsmEntry(root);
18317
18416
  if (!entry) {
18318
- const req = (0, import_node_module4.createRequire)((0, import_node_path45.join)(root, "package.json"));
18417
+ const req = (0, import_node_module4.createRequire)((0, import_node_path46.join)(root, "package.json"));
18319
18418
  entry = req.resolve("@cursor/sdk");
18320
18419
  }
18321
18420
  return unwrapCursorSdkModule(await import((0, import_node_url4.pathToFileURL)(entry).href));
@@ -18327,8 +18426,8 @@ function cursorSdkPlatformRipgrepPackage() {
18327
18426
  return `@cursor/sdk-${process.platform}-${process.arch}`;
18328
18427
  }
18329
18428
  function nodeModulesDirForPackageRoot(packageRoot) {
18330
- const parent = (0, import_node_path45.dirname)(packageRoot);
18331
- return (0, import_node_path45.basename)(parent).startsWith("@") ? (0, import_node_path45.dirname)(parent) : parent;
18429
+ const parent = (0, import_node_path46.dirname)(packageRoot);
18430
+ return (0, import_node_path46.basename)(parent).startsWith("@") ? (0, import_node_path46.dirname)(parent) : parent;
18332
18431
  }
18333
18432
  function cursorSdkRipgrepCandidate(opts) {
18334
18433
  const root = resolveCursorSdkRoot(opts);
@@ -18336,18 +18435,18 @@ function cursorSdkRipgrepCandidate(opts) {
18336
18435
  const nm = nodeModulesDirForPackageRoot(root);
18337
18436
  const pkg = cursorSdkPlatformRipgrepPackage();
18338
18437
  const bin = process.platform === "win32" ? "rg.exe" : "rg";
18339
- const sibling = (0, import_node_path45.join)(nm, pkg, "bin", bin);
18340
- if ((0, import_node_fs43.existsSync)(sibling)) return sibling;
18341
- const nested = (0, import_node_path45.join)(root, "node_modules", pkg, "bin", bin);
18342
- return (0, import_node_fs43.existsSync)(nested) ? nested : null;
18438
+ const sibling = (0, import_node_path46.join)(nm, pkg, "bin", bin);
18439
+ if ((0, import_node_fs44.existsSync)(sibling)) return sibling;
18440
+ const nested = (0, import_node_path46.join)(root, "node_modules", pkg, "bin", bin);
18441
+ return (0, import_node_fs44.existsSync)(nested) ? nested : null;
18343
18442
  }
18344
- var import_node_fs43, import_node_module4, import_node_path45, import_node_url4, import_meta7, CURSOR_SDK_INSTALL_HINT;
18443
+ var import_node_fs44, import_node_module4, import_node_path46, import_node_url4, import_meta7, CURSOR_SDK_INSTALL_HINT;
18345
18444
  var init_cursor_sdk_resolve = __esm({
18346
18445
  "src/agents/cursor-sdk-resolve.ts"() {
18347
18446
  "use strict";
18348
- import_node_fs43 = require("fs");
18447
+ import_node_fs44 = require("fs");
18349
18448
  import_node_module4 = require("module");
18350
- import_node_path45 = require("path");
18449
+ import_node_path46 = require("path");
18351
18450
  import_node_url4 = require("url");
18352
18451
  init_path();
18353
18452
  import_meta7 = {};
@@ -18389,21 +18488,21 @@ function platformRipgrepPackage() {
18389
18488
  }
18390
18489
  function usableRipgrepPath(candidate) {
18391
18490
  const raw = candidate?.trim();
18392
- if (!raw || !(0, import_node_path46.isAbsolute)(raw)) return null;
18491
+ if (!raw || !(0, import_node_path47.isAbsolute)(raw)) return null;
18393
18492
  const readable = nodeReadableScriptPath(raw);
18394
- if (!(0, import_node_fs44.existsSync)(readable) || isAsarPath(readable)) return null;
18493
+ if (!(0, import_node_fs45.existsSync)(readable) || isAsarPath(readable)) return null;
18395
18494
  return readable;
18396
18495
  }
18397
18496
  function walkForBundledRipgrep(startFile) {
18398
18497
  if (!startFile) return null;
18399
18498
  const pkg = platformRipgrepPackage();
18400
18499
  const name = rgBinaryName();
18401
- let dir = (0, import_node_path46.dirname)((0, import_node_path46.resolve)(startFile));
18402
- const root = (0, import_node_path46.parse)(dir).root;
18500
+ let dir = (0, import_node_path47.dirname)((0, import_node_path47.resolve)(startFile));
18501
+ const root = (0, import_node_path47.parse)(dir).root;
18403
18502
  while (dir !== root) {
18404
- const hit = usableRipgrepPath((0, import_node_path46.join)(dir, "node_modules", pkg, "bin", name));
18503
+ const hit = usableRipgrepPath((0, import_node_path47.join)(dir, "node_modules", pkg, "bin", name));
18405
18504
  if (hit) return hit;
18406
- const next = (0, import_node_path46.dirname)(dir);
18505
+ const next = (0, import_node_path47.dirname)(dir);
18407
18506
  if (next === dir) break;
18408
18507
  dir = next;
18409
18508
  }
@@ -18413,7 +18512,7 @@ function requireResolveBundledRipgrep(fromFile) {
18413
18512
  try {
18414
18513
  const req = (0, import_node_module5.createRequire)(fromFile);
18415
18514
  const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
18416
- return usableRipgrepPath((0, import_node_path46.join)((0, import_node_path46.dirname)(pkgJson), "bin", rgBinaryName()));
18515
+ return usableRipgrepPath((0, import_node_path47.join)((0, import_node_path47.dirname)(pkgJson), "bin", rgBinaryName()));
18417
18516
  } catch {
18418
18517
  return null;
18419
18518
  }
@@ -18435,13 +18534,13 @@ function cursorRipgrepEnv(opts) {
18435
18534
  const path = resolveCursorRipgrepPath(opts);
18436
18535
  return path ? { [RIPGREP_ENV]: path } : {};
18437
18536
  }
18438
- var import_node_fs44, import_node_module5, import_node_path46, RIPGREP_ENV;
18537
+ var import_node_fs45, import_node_module5, import_node_path47, RIPGREP_ENV;
18439
18538
  var init_cursor_ripgrep = __esm({
18440
18539
  "src/agents/cursor-ripgrep.ts"() {
18441
18540
  "use strict";
18442
- import_node_fs44 = require("fs");
18541
+ import_node_fs45 = require("fs");
18443
18542
  import_node_module5 = require("module");
18444
- import_node_path46 = require("path");
18543
+ import_node_path47 = require("path");
18445
18544
  init_cursor_sdk_resolve();
18446
18545
  init_node_launch();
18447
18546
  init_packaged_runtime();
@@ -18485,11 +18584,11 @@ function entryDir3() {
18485
18584
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
18486
18585
  if (cjsDir) return cjsDir;
18487
18586
  try {
18488
- return (0, import_node_path47.dirname)((0, import_node_url5.fileURLToPath)(import_meta8.url));
18587
+ return (0, import_node_path48.dirname)((0, import_node_url5.fileURLToPath)(import_meta8.url));
18489
18588
  } catch {
18490
18589
  try {
18491
18590
  const req = (0, import_node_module6.createRequire)(process.cwd() + "/");
18492
- return (0, import_node_path47.dirname)(req.resolve("@sideboard-ai/core"));
18591
+ return (0, import_node_path48.dirname)(req.resolve("@sideboard-ai/core"));
18493
18592
  } catch {
18494
18593
  return process.cwd();
18495
18594
  }
@@ -18500,27 +18599,27 @@ function cursorRunnerPath() {
18500
18599
  if (packaged) return packaged;
18501
18600
  const root = entryDir3();
18502
18601
  const candidates = [
18503
- (0, import_node_path47.join)(root, "agents", "cursor-runner.js"),
18504
- (0, import_node_path47.join)(root, "agents", "cursor-runner.cjs"),
18602
+ (0, import_node_path48.join)(root, "agents", "cursor-runner.js"),
18603
+ (0, import_node_path48.join)(root, "agents", "cursor-runner.cjs"),
18505
18604
  // If somehow resolved from package root instead of dist/
18506
- (0, import_node_path47.join)(root, "dist", "agents", "cursor-runner.js"),
18507
- (0, import_node_path47.join)(root, "dist", "agents", "cursor-runner.cjs"),
18605
+ (0, import_node_path48.join)(root, "dist", "agents", "cursor-runner.js"),
18606
+ (0, import_node_path48.join)(root, "dist", "agents", "cursor-runner.cjs"),
18508
18607
  // Source tree (dev): packages/core/src/agents/cursor-runner.ts
18509
- (0, import_node_path47.join)(root, "cursor-runner.ts"),
18510
- (0, import_node_path47.join)(root, "src", "agents", "cursor-runner.ts")
18608
+ (0, import_node_path48.join)(root, "cursor-runner.ts"),
18609
+ (0, import_node_path48.join)(root, "src", "agents", "cursor-runner.ts")
18511
18610
  ];
18512
18611
  for (const candidate of candidates) {
18513
- if ((0, import_node_fs45.existsSync)(candidate)) return candidate;
18612
+ if ((0, import_node_fs46.existsSync)(candidate)) return candidate;
18514
18613
  }
18515
18614
  return candidates[0];
18516
18615
  }
18517
- var import_node_fs45, import_node_module6, import_node_path47, import_node_url5, import_meta8, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
18616
+ var import_node_fs46, import_node_module6, import_node_path48, import_node_url5, import_meta8, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
18518
18617
  var init_cursor = __esm({
18519
18618
  "src/agents/cursor.ts"() {
18520
18619
  "use strict";
18521
- import_node_fs45 = require("fs");
18620
+ import_node_fs46 = require("fs");
18522
18621
  import_node_module6 = require("module");
18523
- import_node_path47 = require("path");
18622
+ import_node_path48 = require("path");
18524
18623
  import_node_url5 = require("url");
18525
18624
  init_run();
18526
18625
  init_app_settings();
@@ -18647,26 +18746,26 @@ var init_cursor = __esm({
18647
18746
 
18648
18747
  // src/agent-rpc/opencode-hook.ts
18649
18748
  function writeOpencodeRpcPlugin() {
18650
- const pluginDir = (0, import_node_path48.join)(appDataDir(), "agent-rpc", "opencode");
18651
- (0, import_node_fs46.mkdirSync)(pluginDir, { recursive: true });
18652
- const pluginFile = (0, import_node_path48.join)(pluginDir, "sideboard-rpc.js");
18653
- if ((0, import_node_fs46.existsSync)(pluginFile)) {
18749
+ const pluginDir = (0, import_node_path49.join)(appDataDir(), "agent-rpc", "opencode");
18750
+ (0, import_node_fs47.mkdirSync)(pluginDir, { recursive: true });
18751
+ const pluginFile = (0, import_node_path49.join)(pluginDir, "sideboard-rpc.js");
18752
+ if ((0, import_node_fs47.existsSync)(pluginFile)) {
18654
18753
  try {
18655
- if ((0, import_node_fs46.readFileSync)(pluginFile, "utf8") === OPENCODE_PLUGIN_SOURCE) return pluginFile;
18754
+ if ((0, import_node_fs47.readFileSync)(pluginFile, "utf8") === OPENCODE_PLUGIN_SOURCE) return pluginFile;
18656
18755
  } catch {
18657
18756
  }
18658
18757
  }
18659
18758
  const tmp = `${pluginFile}.${process.pid}.tmp`;
18660
- (0, import_node_fs46.writeFileSync)(tmp, OPENCODE_PLUGIN_SOURCE);
18661
- (0, import_node_fs46.renameSync)(tmp, pluginFile);
18759
+ (0, import_node_fs47.writeFileSync)(tmp, OPENCODE_PLUGIN_SOURCE);
18760
+ (0, import_node_fs47.renameSync)(tmp, pluginFile);
18662
18761
  return pluginFile;
18663
18762
  }
18664
- var import_node_fs46, import_node_path48, OPENCODE_PLUGIN_SOURCE;
18763
+ var import_node_fs47, import_node_path49, OPENCODE_PLUGIN_SOURCE;
18665
18764
  var init_opencode_hook = __esm({
18666
18765
  "src/agent-rpc/opencode-hook.ts"() {
18667
18766
  "use strict";
18668
- import_node_fs46 = require("fs");
18669
- import_node_path48 = require("path");
18767
+ import_node_fs47 = require("fs");
18768
+ import_node_path49 = require("path");
18670
18769
  init_paths();
18671
18770
  init_pilot_tools();
18672
18771
  init_protocol2();
@@ -18885,7 +18984,7 @@ async function listOpencodeModels() {
18885
18984
  if (opencode === "opencode") {
18886
18985
  const which = await run("which", ["opencode"], { reject: false });
18887
18986
  if (which.exitCode !== 0) return FALLBACK_OPENCODE_MODELS;
18888
- } else if (!(0, import_node_fs47.existsSync)(opencode)) {
18987
+ } else if (!(0, import_node_fs48.existsSync)(opencode)) {
18889
18988
  return FALLBACK_OPENCODE_MODELS;
18890
18989
  }
18891
18990
  const listed = await run(opencode, ["models"], { reject: false });
@@ -18915,11 +19014,11 @@ function usageFromOpencode(tokens) {
18915
19014
  cacheWriteTokens: tokens.cache?.write ? Number(tokens.cache.write) : void 0
18916
19015
  };
18917
19016
  }
18918
- var import_node_fs47, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
19017
+ var import_node_fs48, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
18919
19018
  var init_opencode = __esm({
18920
19019
  "src/agents/opencode.ts"() {
18921
19020
  "use strict";
18922
- import_node_fs47 = require("fs");
19021
+ import_node_fs48 = require("fs");
18923
19022
  init_run();
18924
19023
  init_app_settings();
18925
19024
  init_error_detail();
@@ -18945,7 +19044,7 @@ var init_opencode = __esm({
18945
19044
  async detect() {
18946
19045
  const opencode = resolveAgentExecutable("opencode");
18947
19046
  if (opencode !== "opencode") {
18948
- if (!(0, import_node_fs47.existsSync)(opencode)) {
19047
+ if (!(0, import_node_fs48.existsSync)(opencode)) {
18949
19048
  return {
18950
19049
  agent: "opencode",
18951
19050
  installed: false,
@@ -19535,21 +19634,21 @@ async function resolveCliAfterNpmInstall(cliBin) {
19535
19634
  if (prefix.exitCode !== 0) return null;
19536
19635
  const root = prefix.stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.startsWith("/")).pop();
19537
19636
  if (!root) return null;
19538
- const candidate = (0, import_node_path49.join)(root, "bin", cliBin);
19539
- if (!(0, import_node_fs48.existsSync)(candidate)) return null;
19637
+ const candidate = (0, import_node_path50.join)(root, "bin", cliBin);
19638
+ if (!(0, import_node_fs49.existsSync)(candidate)) return null;
19540
19639
  try {
19541
- (0, import_node_fs48.chmodSync)(candidate, 493);
19640
+ (0, import_node_fs49.chmodSync)(candidate, 493);
19542
19641
  } catch {
19543
19642
  }
19544
19643
  enrichPathWithNpmGlobalBin();
19545
19644
  return whichOnPath(cliBin);
19546
19645
  }
19547
- var import_node_fs48, import_node_path49;
19646
+ var import_node_fs49, import_node_path50;
19548
19647
  var init_install = __esm({
19549
19648
  "src/agents/install.ts"() {
19550
19649
  "use strict";
19551
- import_node_fs48 = require("fs");
19552
- import_node_path49 = require("path");
19650
+ import_node_fs49 = require("fs");
19651
+ import_node_path50 = require("path");
19553
19652
  init_run();
19554
19653
  init_app_settings();
19555
19654
  init_acp_harness();
@@ -19659,7 +19758,7 @@ function isAgentHostEnvKey(key) {
19659
19758
  }
19660
19759
  function stripHostToolingPath(pathValue) {
19661
19760
  if (!pathValue?.trim()) return "";
19662
- return pathValue.split(import_node_path50.delimiter).filter((part) => part && !HOST_PATH_NOISE.test(part.replace(/\\/g, "/"))).join(import_node_path50.delimiter);
19761
+ return pathValue.split(import_node_path51.delimiter).filter((part) => part && !HOST_PATH_NOISE.test(part.replace(/\\/g, "/"))).join(import_node_path51.delimiter);
19663
19762
  }
19664
19763
  function sanitizeAgentHostEnv(env, cwd) {
19665
19764
  for (const key of Object.keys(env)) {
@@ -19673,11 +19772,11 @@ function sanitizeAgentHostEnv(env, cwd) {
19673
19772
  }
19674
19773
  return env;
19675
19774
  }
19676
- var import_node_path50, DROP_EXACT, DROP_PREFIXES, HOST_PATH_NOISE;
19775
+ var import_node_path51, DROP_EXACT, DROP_PREFIXES, HOST_PATH_NOISE;
19677
19776
  var init_agent_host_env = __esm({
19678
19777
  "src/hook/agent-host-env.ts"() {
19679
19778
  "use strict";
19680
- import_node_path50 = require("path");
19779
+ import_node_path51 = require("path");
19681
19780
  DROP_EXACT = /* @__PURE__ */ new Set([
19682
19781
  "NODE_PATH",
19683
19782
  "NODE_ENV_ELECTRON_VITE",
@@ -19716,15 +19815,15 @@ var init_agent_host_env = __esm({
19716
19815
 
19717
19816
  // src/hook/worktree-pkg-cache.ts
19718
19817
  function worktreePkgCacheRoot(worktreePath) {
19719
- return (0, import_node_path51.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
19818
+ return (0, import_node_path52.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
19720
19819
  }
19721
19820
  function worktreePkgCacheEnv(worktreePath) {
19722
19821
  const root = worktreePkgCacheRoot(worktreePath);
19723
- const store = (0, import_node_path51.join)(root, "pnpm-store");
19724
- const pnpmCache = (0, import_node_path51.join)(root, "pnpm");
19725
- const npmCache = (0, import_node_path51.join)(root, "npm");
19726
- const nodeGyp = (0, import_node_path51.join)(root, "node-gyp");
19727
- const electron = (0, import_node_path51.join)(root, "electron");
19822
+ const store = (0, import_node_path52.join)(root, "pnpm-store");
19823
+ const pnpmCache = (0, import_node_path52.join)(root, "pnpm");
19824
+ const npmCache = (0, import_node_path52.join)(root, "npm");
19825
+ const nodeGyp = (0, import_node_path52.join)(root, "node-gyp");
19826
+ const electron = (0, import_node_path52.join)(root, "electron");
19728
19827
  return {
19729
19828
  npm_config_store_dir: store,
19730
19829
  PNPM_STORE_DIR: store,
@@ -19746,8 +19845,8 @@ function fillGroup(env, keys, values) {
19746
19845
  }
19747
19846
  }
19748
19847
  function ensureWorktreePkgCacheDirs(worktreePath) {
19749
- if (!(0, import_node_fs49.existsSync)(worktreePath)) return;
19750
- (0, import_node_fs49.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
19848
+ if (!(0, import_node_fs50.existsSync)(worktreePath)) return;
19849
+ (0, import_node_fs50.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
19751
19850
  }
19752
19851
  function applyWorktreePkgCacheEnv(env, worktreePath) {
19753
19852
  const cwd = worktreePath.trim();
@@ -19760,12 +19859,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
19760
19859
  fillGroup(env, ["electron_config_cache"], next);
19761
19860
  ensureWorktreePkgCacheDirs(cwd);
19762
19861
  }
19763
- var import_node_fs49, import_node_path51, WORKTREE_PKG_CACHE_REL;
19862
+ var import_node_fs50, import_node_path52, WORKTREE_PKG_CACHE_REL;
19764
19863
  var init_worktree_pkg_cache = __esm({
19765
19864
  "src/hook/worktree-pkg-cache.ts"() {
19766
19865
  "use strict";
19767
- import_node_fs49 = require("fs");
19768
- import_node_path51 = require("path");
19866
+ import_node_fs50 = require("fs");
19867
+ import_node_path52 = require("path");
19769
19868
  WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
19770
19869
  }
19771
19870
  });
@@ -20025,7 +20124,7 @@ async function spawnAgentTurn(thread, input, onEvent) {
20025
20124
  }).finally(() => {
20026
20125
  for (const dir of cmd.cleanupDirs ?? []) {
20027
20126
  try {
20028
- (0, import_node_fs50.rmSync)(dir, { recursive: true, force: true });
20127
+ (0, import_node_fs51.rmSync)(dir, { recursive: true, force: true });
20029
20128
  } catch {
20030
20129
  }
20031
20130
  }
@@ -20059,11 +20158,11 @@ async function spawnAgentTurn(thread, input, onEvent) {
20059
20158
  done
20060
20159
  };
20061
20160
  }
20062
- var import_node_fs50, import_node_readline2, import_execa3;
20161
+ var import_node_fs51, import_node_readline2, import_execa3;
20063
20162
  var init_spawn = __esm({
20064
20163
  "src/agents/spawn.ts"() {
20065
20164
  "use strict";
20066
- import_node_fs50 = require("fs");
20165
+ import_node_fs51 = require("fs");
20067
20166
  import_node_readline2 = require("readline");
20068
20167
  import_execa3 = require("execa");
20069
20168
  init_worktree();
@@ -20305,10 +20404,6 @@ function entireGitActionExpansion(action, base) {
20305
20404
  return "This phrase is the explicit ask to merge this thread's Trail change with `entire trail merge`. Do not force-push main/master or merge locally into the main checkout. Do not use `gh`.";
20306
20405
  }
20307
20406
  }
20308
- function worktreeHasAnnounceSkill(worktreePath) {
20309
- const root = worktreePath?.trim();
20310
- return !!root && (0, import_node_fs51.existsSync)((0, import_node_path52.join)(root, ".claude/skills/announce-on-x/SKILL.md"));
20311
- }
20312
20407
  function expandCanonicalGitRequest(prompt, opts) {
20313
20408
  const trimmed = prompt.trim();
20314
20409
  let action = null;
@@ -20342,7 +20437,7 @@ function expandCanonicalGitRequest(prompt, opts) {
20342
20437
  expansion = forge === "cursor" ? "Investigate that failing check (`origin pr checks`, `origin pr watch`), fix it, commit, and push. Loop only if a goal to keep going until it passes was given. Do not use `gh run`." : forge === "entire" ? "Investigate the blocking gate (`entire trail merge --dry-run`, `entire trail finding list`, `entire trail watch`), fix it, commit, and push. Loop only if a goal to keep going until it passes was given. Do not use `gh run`." : "Investigate that failing check (`gh pr checks`, `gh run view --log-failed`), fix it, commit, and push. Loop only if a goal to keep going until it passes was given.";
20343
20438
  }
20344
20439
  if (!expansion) return prompt;
20345
- if (action === "merge" && (!base || isMainishPrBase(base)) && worktreeHasAnnounceSkill(opts?.worktreePath)) {
20440
+ if (action === "merge" && (!base || isMainishPrBase(base)) && opts?.hasAnnounceSkill) {
20346
20441
  expansion = `${expansion} ${ANNOUNCE_AFTER_MERGE}`;
20347
20442
  }
20348
20443
  if (expansionPushes(action, trimmed)) expansion = withPushReview(expansion);
@@ -20360,12 +20455,10 @@ function expansionPushes(action, prompt) {
20360
20455
  if (action) return true;
20361
20456
  return prompt === "Address review comments." || FIX_CI_RE.test(prompt);
20362
20457
  }
20363
- var import_node_fs51, import_node_path52, ANNOUNCE_AFTER_MERGE, AGENT_GIT_ACTIONS, RESOLVE_CONFLICTS_RE, MERGE_INTO_RE, FIX_CI_RE, PUSH_WAKES_REVIEW, CHECKS_LOOP_UNLESS_GOAL;
20458
+ var ANNOUNCE_AFTER_MERGE, AGENT_GIT_ACTIONS, RESOLVE_CONFLICTS_RE, MERGE_INTO_RE, FIX_CI_RE, PUSH_WAKES_REVIEW, CHECKS_LOOP_UNLESS_GOAL;
20364
20459
  var init_agent_git_actions = __esm({
20365
20460
  "src/git/agent-git-actions.ts"() {
20366
20461
  "use strict";
20367
- import_node_fs51 = require("fs");
20368
- import_node_path52 = require("path");
20369
20462
  ANNOUNCE_AFTER_MERGE = "After that merge to the default branch succeeds, follow `.claude/skills/announce-on-x/SKILL.md` (`/announce-on-x`) before the turn ends. Post or skip each pull request that merge landed on the default branch. Do not schedule a catch-up.";
20370
20463
  AGENT_GIT_ACTIONS = [
20371
20464
  "commit-push",
@@ -20383,6 +20476,20 @@ var init_agent_git_actions = __esm({
20383
20476
  }
20384
20477
  });
20385
20478
 
20479
+ // src/git/announce-skill.ts
20480
+ function announceSkillPresent(worktreePath) {
20481
+ const root = worktreePath?.trim();
20482
+ return !!root && (0, import_node_fs52.existsSync)((0, import_node_path53.join)(root, ".claude/skills/announce-on-x/SKILL.md"));
20483
+ }
20484
+ var import_node_fs52, import_node_path53;
20485
+ var init_announce_skill = __esm({
20486
+ "src/git/announce-skill.ts"() {
20487
+ "use strict";
20488
+ import_node_fs52 = require("fs");
20489
+ import_node_path53 = require("path");
20490
+ }
20491
+ });
20492
+
20386
20493
  // src/git/pr-merge-archive.ts
20387
20494
  function normalizePrState(state) {
20388
20495
  return (state ?? "").trim().toUpperCase();
@@ -21322,21 +21429,21 @@ function shouldRefreshReviewRequestTemplate(content) {
21322
21429
  return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
21323
21430
  }
21324
21431
  function readTextIfPresent(abs) {
21325
- if (!(0, import_node_fs52.existsSync)(abs)) return null;
21432
+ if (!(0, import_node_fs53.existsSync)(abs)) return null;
21326
21433
  try {
21327
- const content = (0, import_node_fs52.readFileSync)(abs, "utf8");
21434
+ const content = (0, import_node_fs53.readFileSync)(abs, "utf8");
21328
21435
  return content.trim() ? content : null;
21329
21436
  } catch {
21330
21437
  return null;
21331
21438
  }
21332
21439
  }
21333
21440
  function readLocalGuidelines(worktreePath) {
21334
- const localAbs = (0, import_node_path53.join)(worktreePath, REVIEW_REQUEST_PATH);
21441
+ const localAbs = (0, import_node_path54.join)(worktreePath, REVIEW_REQUEST_PATH);
21335
21442
  const localContent = readTextIfPresent(localAbs);
21336
21443
  if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
21337
21444
  return { path: REVIEW_REQUEST_PATH, content: localContent };
21338
21445
  }
21339
- const legacyAbs = (0, import_node_path53.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
21446
+ const legacyAbs = (0, import_node_path54.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
21340
21447
  const legacyContent = readTextIfPresent(legacyAbs);
21341
21448
  if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
21342
21449
  return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
@@ -21360,27 +21467,27 @@ function contextGuidelines(content, source) {
21360
21467
  };
21361
21468
  }
21362
21469
  function writeContextGuidelines(worktreePath, content) {
21363
- const abs = (0, import_node_path53.join)(worktreePath, CONTEXT_REVIEW_PATH);
21364
- (0, import_node_fs52.mkdirSync)((0, import_node_path53.dirname)(abs), { recursive: true });
21470
+ const abs = (0, import_node_path54.join)(worktreePath, CONTEXT_REVIEW_PATH);
21471
+ (0, import_node_fs53.mkdirSync)((0, import_node_path54.dirname)(abs), { recursive: true });
21365
21472
  const body = content.endsWith("\n") ? content : `${content}
21366
21473
  `;
21367
- (0, import_node_fs52.writeFileSync)(abs, body, "utf8");
21474
+ (0, import_node_fs53.writeFileSync)(abs, body, "utf8");
21368
21475
  return body;
21369
21476
  }
21370
21477
  function readSideboardReview(worktreePath, repoPath) {
21371
- const fromWorktree = readTextIfPresent((0, import_node_path53.join)(worktreePath, REPO_REVIEW_PATH));
21478
+ const fromWorktree = readTextIfPresent((0, import_node_path54.join)(worktreePath, REPO_REVIEW_PATH));
21372
21479
  if (fromWorktree) return fromWorktree;
21373
21480
  const repo = repoPath?.replace(/\/+$/, "");
21374
21481
  const wt = worktreePath.replace(/\/+$/, "");
21375
21482
  if (!repo || repo === wt) return null;
21376
- return readTextIfPresent((0, import_node_path53.join)(repo, REPO_REVIEW_PATH));
21483
+ return readTextIfPresent((0, import_node_path54.join)(repo, REPO_REVIEW_PATH));
21377
21484
  }
21378
21485
  function ensureReviewGuidelinesFile(worktreePath, repoPath) {
21379
- const skillContent = readTextIfPresent((0, import_node_path53.join)(worktreePath, REVIEW_SKILL_PATH));
21486
+ const skillContent = readTextIfPresent((0, import_node_path54.join)(worktreePath, REVIEW_SKILL_PATH));
21380
21487
  if (skillContent) {
21381
21488
  return { ...skillGuidelines(skillContent, "skill"), wrote: false };
21382
21489
  }
21383
- const contextContent = readTextIfPresent((0, import_node_path53.join)(worktreePath, CONTEXT_REVIEW_PATH));
21490
+ const contextContent = readTextIfPresent((0, import_node_path54.join)(worktreePath, CONTEXT_REVIEW_PATH));
21384
21491
  if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
21385
21492
  return { ...contextGuidelines(contextContent, "local"), wrote: false };
21386
21493
  }
@@ -21456,13 +21563,13 @@ async function requestReview(threadRef, send) {
21456
21563
  const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
21457
21564
  return { tab: started, from };
21458
21565
  }
21459
- var import_node_crypto13, import_node_fs52, import_node_path53, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
21566
+ var import_node_crypto13, import_node_fs53, import_node_path54, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
21460
21567
  var init_request_review = __esm({
21461
21568
  "src/review/request-review.ts"() {
21462
21569
  "use strict";
21463
21570
  import_node_crypto13 = require("crypto");
21464
- import_node_fs52 = require("fs");
21465
- import_node_path53 = require("path");
21571
+ import_node_fs53 = require("fs");
21572
+ import_node_path54 = require("path");
21466
21573
  init_global_workspace();
21467
21574
  init_chat_tabs();
21468
21575
  init_thread_store();
@@ -21485,7 +21592,7 @@ var init_request_review = __esm({
21485
21592
 
21486
21593
  // src/hook/worktree-run-ports.ts
21487
21594
  function worktreeRunPortsPath(worktreePath) {
21488
- return (0, import_node_path54.join)(worktreePath, RUN_PORTS_REL);
21595
+ return (0, import_node_path55.join)(worktreePath, RUN_PORTS_REL);
21489
21596
  }
21490
21597
  function isPort(value) {
21491
21598
  return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= 65535;
@@ -21510,7 +21617,7 @@ function parseFile(raw) {
21510
21617
  function readScripts(worktreePath) {
21511
21618
  if (!worktreePath.trim()) return {};
21512
21619
  try {
21513
- const raw = (0, import_node_fs53.readFileSync)(worktreeRunPortsPath(worktreePath), "utf8");
21620
+ const raw = (0, import_node_fs54.readFileSync)(worktreeRunPortsPath(worktreePath), "utf8");
21514
21621
  return parseFile(raw).scripts ?? {};
21515
21622
  } catch {
21516
21623
  return {};
@@ -21537,22 +21644,22 @@ function saveWorktreeRunPorts(worktreePath, scriptName, ports) {
21537
21644
  const path = worktreeRunPortsPath(worktreePath);
21538
21645
  let current = {};
21539
21646
  try {
21540
- current = parseFile((0, import_node_fs53.readFileSync)(path, "utf8"));
21647
+ current = parseFile((0, import_node_fs54.readFileSync)(path, "utf8"));
21541
21648
  } catch {
21542
21649
  current = {};
21543
21650
  }
21544
21651
  const scripts = { ...current.scripts ?? {} };
21545
21652
  scripts[scriptName] = cleaned;
21546
- (0, import_node_fs53.mkdirSync)((0, import_node_path54.dirname)(path), { recursive: true });
21547
- (0, import_node_fs53.writeFileSync)(path, `${JSON.stringify({ scripts }, null, 2)}
21653
+ (0, import_node_fs54.mkdirSync)((0, import_node_path55.dirname)(path), { recursive: true });
21654
+ (0, import_node_fs54.writeFileSync)(path, `${JSON.stringify({ scripts }, null, 2)}
21548
21655
  `, "utf8");
21549
21656
  }
21550
- var import_node_fs53, import_node_path54, RUN_PORTS_REL;
21657
+ var import_node_fs54, import_node_path55, RUN_PORTS_REL;
21551
21658
  var init_worktree_run_ports = __esm({
21552
21659
  "src/hook/worktree-run-ports.ts"() {
21553
21660
  "use strict";
21554
- import_node_fs53 = require("fs");
21555
- import_node_path54 = require("path");
21661
+ import_node_fs54 = require("fs");
21662
+ import_node_path55 = require("path");
21556
21663
  RUN_PORTS_REL = ".context/.sideboard/run-ports.json";
21557
21664
  }
21558
21665
  });
@@ -21650,24 +21757,24 @@ function sanitizeDetachedJobId(id) {
21650
21757
  return s;
21651
21758
  }
21652
21759
  function readIntFile(file) {
21653
- if (!(0, import_node_fs54.existsSync)(file)) return null;
21654
- const n = Number.parseInt((0, import_node_fs54.readFileSync)(file, "utf8").trim(), 10);
21760
+ if (!(0, import_node_fs55.existsSync)(file)) return null;
21761
+ const n = Number.parseInt((0, import_node_fs55.readFileSync)(file, "utf8").trim(), 10);
21655
21762
  return Number.isInteger(n) ? n : null;
21656
21763
  }
21657
21764
  function jobDir(root, id, legacy = false) {
21658
- return (0, import_node_path55.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
21765
+ return (0, import_node_path56.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
21659
21766
  }
21660
21767
  function resolveJobDir(root, id) {
21661
21768
  const modern = jobDir(root, id, false);
21662
- if ((0, import_node_fs54.existsSync)(modern)) return modern;
21769
+ if ((0, import_node_fs55.existsSync)(modern)) return modern;
21663
21770
  const legacy = jobDir(root, id, true);
21664
- if ((0, import_node_fs54.existsSync)(legacy)) return legacy;
21771
+ if ((0, import_node_fs55.existsSync)(legacy)) return legacy;
21665
21772
  return modern;
21666
21773
  }
21667
21774
  function listJobIdsIn(root, rel) {
21668
- const dir = (0, import_node_path55.join)(root, rel);
21669
- if (!(0, import_node_fs54.existsSync)(dir)) return [];
21670
- return (0, import_node_fs54.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
21775
+ const dir = (0, import_node_path56.join)(root, rel);
21776
+ if (!(0, import_node_fs55.existsSync)(dir)) return [];
21777
+ return (0, import_node_fs55.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
21671
21778
  }
21672
21779
  function listRunningDetachedJobs(worktreePath) {
21673
21780
  const root = worktreePath.trim();
@@ -21679,7 +21786,7 @@ function listRunningDetachedJobs(worktreePath) {
21679
21786
  const running = [];
21680
21787
  for (const id of ids) {
21681
21788
  const dir = resolveJobDir(root, id);
21682
- const pid = readIntFile((0, import_node_path55.join)(dir, "pid"));
21789
+ const pid = readIntFile((0, import_node_path56.join)(dir, "pid"));
21683
21790
  if (jobTreeAlive(pid)) running.push(id);
21684
21791
  }
21685
21792
  return running.sort();
@@ -21761,8 +21868,8 @@ function planJobContinue(opts) {
21761
21868
  return { action: "none" };
21762
21869
  }
21763
21870
  function tailProgress(logFile, maxLines = 12) {
21764
- if (!(0, import_node_fs54.existsSync)(logFile)) return "(no log yet)";
21765
- const lines = (0, import_node_fs54.readFileSync)(logFile, "utf8").split("\n");
21871
+ if (!(0, import_node_fs55.existsSync)(logFile)) return "(no log yet)";
21872
+ const lines = (0, import_node_fs55.readFileSync)(logFile, "utf8").split("\n");
21766
21873
  return lines.slice(-maxLines).join("\n");
21767
21874
  }
21768
21875
  function lastProgressLine(progress) {
@@ -21770,8 +21877,8 @@ function lastProgressLine(progress) {
21770
21877
  return last ? last.slice(0, 72) : void 0;
21771
21878
  }
21772
21879
  function readLogLines(file) {
21773
- if (!(0, import_node_fs54.existsSync)(file)) return [];
21774
- const lines = (0, import_node_fs54.readFileSync)(file, "utf8").split("\n");
21880
+ if (!(0, import_node_fs55.existsSync)(file)) return [];
21881
+ const lines = (0, import_node_fs55.readFileSync)(file, "utf8").split("\n");
21775
21882
  if (lines.length && lines[lines.length - 1] === "") lines.pop();
21776
21883
  return lines;
21777
21884
  }
@@ -21782,15 +21889,15 @@ function takeDelta(logFile, cursorFile) {
21782
21889
  return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
21783
21890
  }
21784
21891
  function snapshotJob(dir) {
21785
- const pid = readIntFile((0, import_node_path55.join)(dir, "pid"));
21892
+ const pid = readIntFile((0, import_node_path56.join)(dir, "pid"));
21786
21893
  const running = jobTreeAlive(pid);
21787
21894
  return {
21788
21895
  pid,
21789
21896
  running,
21790
- exitCode: readIntFile((0, import_node_path55.join)(dir, "exit")),
21791
- log: (0, import_node_path55.join)(dir, "log"),
21792
- cursor: (0, import_node_path55.join)(dir, "present.cursor"),
21793
- progress: tailProgress((0, import_node_path55.join)(dir, "log"))
21897
+ exitCode: readIntFile((0, import_node_path56.join)(dir, "exit")),
21898
+ log: (0, import_node_path56.join)(dir, "log"),
21899
+ cursor: (0, import_node_path56.join)(dir, "present.cursor"),
21900
+ progress: tailProgress((0, import_node_path56.join)(dir, "log"))
21794
21901
  };
21795
21902
  }
21796
21903
  function toResult(id, snap, extra) {
@@ -21799,8 +21906,8 @@ function toResult(id, snap, extra) {
21799
21906
  const stillRunning = snap.running && !ok;
21800
21907
  const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
21801
21908
  try {
21802
- (0, import_node_fs54.mkdirSync)((0, import_node_path55.dirname)(snap.cursor), { recursive: true });
21803
- (0, import_node_fs54.writeFileSync)(snap.cursor, `${nextCursor}
21909
+ (0, import_node_fs55.mkdirSync)((0, import_node_path56.dirname)(snap.cursor), { recursive: true });
21910
+ (0, import_node_fs55.writeFileSync)(snap.cursor, `${nextCursor}
21804
21911
  `);
21805
21912
  } catch {
21806
21913
  }
@@ -21829,7 +21936,7 @@ async function waitForDetachedJob(cwd, id, opts) {
21829
21936
  const dir = resolveJobDir(root, jobId);
21830
21937
  const timeoutMs = mcpWaitForJobTimeoutMs(opts?.timeoutMs);
21831
21938
  const sleep = opts?.sleep ?? sleepMs;
21832
- if (!(0, import_node_fs54.existsSync)(dir)) {
21939
+ if (!(0, import_node_fs55.existsSync)(dir)) {
21833
21940
  return {
21834
21941
  stillRunning: false,
21835
21942
  ok: false,
@@ -21875,10 +21982,10 @@ function killProcessTree(pid, signal) {
21875
21982
  }
21876
21983
  function appendJobLog(logFile, line) {
21877
21984
  try {
21878
- (0, import_node_fs54.mkdirSync)((0, import_node_path55.dirname)(logFile), { recursive: true });
21985
+ (0, import_node_fs55.mkdirSync)((0, import_node_path56.dirname)(logFile), { recursive: true });
21879
21986
  const body = line.endsWith("\n") ? line : `${line}
21880
21987
  `;
21881
- (0, import_node_fs54.appendFileSync)(logFile, body);
21988
+ (0, import_node_fs55.appendFileSync)(logFile, body);
21882
21989
  } catch {
21883
21990
  }
21884
21991
  }
@@ -21888,7 +21995,7 @@ async function stopDetachedJob(cwd, id, opts) {
21888
21995
  const dir = resolveJobDir(root, jobId);
21889
21996
  const sleep = opts?.sleep ?? sleepMs;
21890
21997
  const why = opts?.reason?.trim() ?? "";
21891
- if (!(0, import_node_fs54.existsSync)(dir)) {
21998
+ if (!(0, import_node_fs55.existsSync)(dir)) {
21892
21999
  return {
21893
22000
  stillRunning: false,
21894
22001
  ok: false,
@@ -21924,10 +22031,10 @@ async function stopDetachedJob(cwd, id, opts) {
21924
22031
  killProcessTree(targetPid, "SIGKILL");
21925
22032
  await sleep(100);
21926
22033
  }
21927
- const exitFile = (0, import_node_path55.join)(dir, "exit");
21928
- if (!(0, import_node_fs54.existsSync)(exitFile)) {
22034
+ const exitFile = (0, import_node_path56.join)(dir, "exit");
22035
+ if (!(0, import_node_fs55.existsSync)(exitFile)) {
21929
22036
  try {
21930
- (0, import_node_fs54.writeFileSync)(exitFile, "1\n");
22037
+ (0, import_node_fs55.writeFileSync)(exitFile, "1\n");
21931
22038
  } catch {
21932
22039
  }
21933
22040
  }
@@ -21947,12 +22054,12 @@ async function stopDetachedJob(cwd, id, opts) {
21947
22054
  hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
21948
22055
  };
21949
22056
  }
21950
- var import_node_fs54, import_node_path55, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
22057
+ var import_node_fs55, import_node_path56, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
21951
22058
  var init_wait_for_job = __esm({
21952
22059
  "src/mcp/wait-for-job.ts"() {
21953
22060
  "use strict";
21954
- import_node_fs54 = require("fs");
21955
- import_node_path55 = require("path");
22061
+ import_node_fs55 = require("fs");
22062
+ import_node_path56 = require("path");
21956
22063
  init_workspace_scratch();
21957
22064
  init_job_process();
21958
22065
  init_wait_for_turn();
@@ -22229,9 +22336,9 @@ function matchSimpleGlob(pattern, name) {
22229
22336
  return new RegExp(`^${escaped}$`).test(name);
22230
22337
  }
22231
22338
  function readWorktreeInclude(repoPath) {
22232
- const path = (0, import_node_path56.join)(repoPath, ".worktreeinclude");
22233
- if (!(0, import_node_fs55.existsSync)(path)) return [];
22234
- return (0, import_node_fs55.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
22339
+ const path = (0, import_node_path57.join)(repoPath, ".worktreeinclude");
22340
+ if (!(0, import_node_fs56.existsSync)(path)) return [];
22341
+ return (0, import_node_fs56.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
22235
22342
  }
22236
22343
  function resolveFilesToCopy(repoPath) {
22237
22344
  const fromInclude = readWorktreeInclude(repoPath);
@@ -22241,10 +22348,10 @@ function resolveFilesToCopy(repoPath) {
22241
22348
  if (settings?.fileIncludeGlobs?.length) {
22242
22349
  const matched = [];
22243
22350
  try {
22244
- for (const entry of (0, import_node_fs55.readdirSync)(repoPath, { withFileTypes: true })) {
22351
+ for (const entry of (0, import_node_fs56.readdirSync)(repoPath, { withFileTypes: true })) {
22245
22352
  if (!entry.isFile()) continue;
22246
22353
  for (const glob of settings.fileIncludeGlobs) {
22247
- if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path56.basename)(glob), entry.name)) {
22354
+ if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path57.basename)(glob), entry.name)) {
22248
22355
  matched.push(entry.name);
22249
22356
  break;
22250
22357
  }
@@ -22256,7 +22363,7 @@ function resolveFilesToCopy(repoPath) {
22256
22363
  }
22257
22364
  const defaults = [];
22258
22365
  try {
22259
- for (const entry of (0, import_node_fs55.readdirSync)(repoPath, { withFileTypes: true })) {
22366
+ for (const entry of (0, import_node_fs56.readdirSync)(repoPath, { withFileTypes: true })) {
22260
22367
  if (entry.isFile() && entry.name.startsWith(".env")) {
22261
22368
  defaults.push(entry.name);
22262
22369
  }
@@ -22270,11 +22377,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
22270
22377
  const patterns = resolveFilesToCopy(repoPath);
22271
22378
  const copied = [];
22272
22379
  for (const rel of patterns) {
22273
- const src = (0, import_node_path56.join)(repoPath, rel);
22274
- if (!(0, import_node_fs55.existsSync)(src)) continue;
22275
- const dest = (0, import_node_path56.join)(worktreePath, rel);
22276
- (0, import_node_fs55.mkdirSync)((0, import_node_path56.dirname)(dest), { recursive: true });
22277
- (0, import_node_fs55.copyFileSync)(src, dest);
22380
+ const src = (0, import_node_path57.join)(repoPath, rel);
22381
+ if (!(0, import_node_fs56.existsSync)(src)) continue;
22382
+ const dest = (0, import_node_path57.join)(worktreePath, rel);
22383
+ (0, import_node_fs56.mkdirSync)((0, import_node_path57.dirname)(dest), { recursive: true });
22384
+ (0, import_node_fs56.copyFileSync)(src, dest);
22278
22385
  copied.push(rel);
22279
22386
  }
22280
22387
  linkSharedDirectories(repoPath, worktreePath);
@@ -22287,19 +22394,19 @@ function linkSharedDirectories(repoPath, worktreePath) {
22287
22394
  for (const rel of dirs) {
22288
22395
  if (!isSafeRelativeDir(rel)) continue;
22289
22396
  if (!isGitignored(repoPath, rel)) continue;
22290
- const src = (0, import_node_path56.join)(repoPath, rel);
22397
+ const src = (0, import_node_path57.join)(repoPath, rel);
22291
22398
  let srcStat;
22292
22399
  try {
22293
- srcStat = (0, import_node_fs55.lstatSync)(src);
22400
+ srcStat = (0, import_node_fs56.lstatSync)(src);
22294
22401
  } catch {
22295
22402
  continue;
22296
22403
  }
22297
22404
  if (!srcStat.isDirectory()) continue;
22298
- const dest = (0, import_node_path56.join)(worktreePath, rel);
22299
- if ((0, import_node_fs55.existsSync)(dest)) continue;
22300
- (0, import_node_fs55.mkdirSync)((0, import_node_path56.dirname)(dest), { recursive: true });
22405
+ const dest = (0, import_node_path57.join)(worktreePath, rel);
22406
+ if ((0, import_node_fs56.existsSync)(dest)) continue;
22407
+ (0, import_node_fs56.mkdirSync)((0, import_node_path57.dirname)(dest), { recursive: true });
22301
22408
  try {
22302
- (0, import_node_fs55.symlinkSync)(src, dest);
22409
+ (0, import_node_fs56.symlinkSync)(src, dest);
22303
22410
  } catch {
22304
22411
  continue;
22305
22412
  }
@@ -22309,13 +22416,13 @@ function linkSharedDirectories(repoPath, worktreePath) {
22309
22416
  }
22310
22417
  function samePath(a, b) {
22311
22418
  try {
22312
- return (0, import_node_fs55.realpathSync)(a) === (0, import_node_fs55.realpathSync)(b);
22419
+ return (0, import_node_fs56.realpathSync)(a) === (0, import_node_fs56.realpathSync)(b);
22313
22420
  } catch {
22314
- return (0, import_node_path56.resolve)(a) === (0, import_node_path56.resolve)(b);
22421
+ return (0, import_node_path57.resolve)(a) === (0, import_node_path57.resolve)(b);
22315
22422
  }
22316
22423
  }
22317
22424
  function isSafeRelativeDir(rel) {
22318
- if (!rel || (0, import_node_path56.isAbsolute)(rel)) return false;
22425
+ if (!rel || (0, import_node_path57.isAbsolute)(rel)) return false;
22319
22426
  const parts = rel.split(/[\\/]/).filter(Boolean);
22320
22427
  return parts.length > 0 && parts.every((part) => part !== "." && part !== "..");
22321
22428
  }
@@ -22357,7 +22464,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
22357
22464
  const env = stripNestedElectronEnv({
22358
22465
  ...baseEnv ?? process.env
22359
22466
  });
22360
- const name = opts.workspaceName ?? (0, import_node_path56.basename)(opts.worktreePath);
22467
+ const name = opts.workspaceName ?? (0, import_node_path57.basename)(opts.worktreePath);
22361
22468
  const ports = opts.ports ?? [];
22362
22469
  const primary = ports[0];
22363
22470
  env.SIDEBOARD_WORKSPACE_NAME = name;
@@ -22426,20 +22533,20 @@ function listenerCwd(pid) {
22426
22533
  }
22427
22534
  function realpathOrResolve(path) {
22428
22535
  try {
22429
- return (0, import_node_fs55.realpathSync)(path);
22536
+ return (0, import_node_fs56.realpathSync)(path);
22430
22537
  } catch {
22431
- return (0, import_node_path56.resolve)(path);
22538
+ return (0, import_node_path57.resolve)(path);
22432
22539
  }
22433
22540
  }
22434
22541
  function isOtherWorktreeListenerCwd(cwd, worktreePath) {
22435
22542
  const wt = realpathOrResolve(worktreePath);
22436
22543
  const c = realpathOrResolve(cwd);
22437
- if (c === wt || c.startsWith(wt + import_node_path56.sep)) return false;
22438
- const parent = (0, import_node_path56.dirname)(wt);
22439
- const thisName = (0, import_node_path56.basename)(wt);
22544
+ if (c === wt || c.startsWith(wt + import_node_path57.sep)) return false;
22545
+ const parent = (0, import_node_path57.dirname)(wt);
22546
+ const thisName = (0, import_node_path57.basename)(wt);
22440
22547
  if (!thisName || c === parent) return false;
22441
- if (!c.startsWith(parent + import_node_path56.sep)) return false;
22442
- const first = c.slice(parent.length + 1).split(import_node_path56.sep)[0];
22548
+ if (!c.startsWith(parent + import_node_path57.sep)) return false;
22549
+ const first = c.slice(parent.length + 1).split(import_node_path57.sep)[0];
22443
22550
  return Boolean(first) && first !== thisName;
22444
22551
  }
22445
22552
  function signalPid(pid, signal) {
@@ -22451,7 +22558,7 @@ function signalPid(pid, signal) {
22451
22558
  function isThisWorktreeListenerCwd(cwd, worktreePath) {
22452
22559
  const wt = realpathOrResolve(worktreePath);
22453
22560
  const c = realpathOrResolve(cwd);
22454
- return c === wt || c.startsWith(wt + import_node_path56.sep);
22561
+ return c === wt || c.startsWith(wt + import_node_path57.sep);
22455
22562
  }
22456
22563
  function killDetachedRunTree(pid, worktreePath) {
22457
22564
  if (!Number.isFinite(pid) || pid <= 1 || pid === process.pid) return;
@@ -22703,13 +22810,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
22703
22810
  throw err;
22704
22811
  }
22705
22812
  }
22706
- var import_node_fs55, import_node_child_process6, import_node_path56, import_execa4, import_node_readline3, cachedLoginEnv;
22813
+ var import_node_fs56, import_node_child_process6, import_node_path57, import_execa4, import_node_readline3, cachedLoginEnv;
22707
22814
  var init_conductor = __esm({
22708
22815
  "src/hook/conductor.ts"() {
22709
22816
  "use strict";
22710
- import_node_fs55 = require("fs");
22817
+ import_node_fs56 = require("fs");
22711
22818
  import_node_child_process6 = require("child_process");
22712
- import_node_path56 = require("path");
22819
+ import_node_path57 = require("path");
22713
22820
  import_execa4 = require("execa");
22714
22821
  import_node_readline3 = require("readline");
22715
22822
  init_settings();
@@ -22762,7 +22869,7 @@ function materialize(mem) {
22762
22869
  };
22763
22870
  }
22764
22871
  function setupLogPath(threadId) {
22765
- return (0, import_node_path57.join)(threadsDir(), `${threadId}.setup.log.json`);
22872
+ return (0, import_node_path58.join)(threadsDir(), `${threadId}.setup.log.json`);
22766
22873
  }
22767
22874
  function setupLogKeyForWorktree(worktreePath) {
22768
22875
  const norm = normalizeWorktreePath(worktreePath);
@@ -22780,7 +22887,7 @@ function persistNow(threadId) {
22780
22887
  const mem = memory.get(threadId);
22781
22888
  if (!mem) return;
22782
22889
  try {
22783
- (0, import_node_fs56.writeFileSync)(
22890
+ (0, import_node_fs57.writeFileSync)(
22784
22891
  setupLogPath(threadId),
22785
22892
  `${JSON.stringify(materialize(mem))}
22786
22893
  `,
@@ -22801,9 +22908,9 @@ function schedulePersist(threadId) {
22801
22908
  }
22802
22909
  function loadFromDisk(threadId) {
22803
22910
  const path = setupLogPath(threadId);
22804
- if (!(0, import_node_fs56.existsSync)(path)) return null;
22911
+ if (!(0, import_node_fs57.existsSync)(path)) return null;
22805
22912
  try {
22806
- const raw = JSON.parse((0, import_node_fs56.readFileSync)(path, "utf8"));
22913
+ const raw = JSON.parse((0, import_node_fs57.readFileSync)(path, "utf8"));
22807
22914
  return {
22808
22915
  output: typeof raw.output === "string" ? raw.output : "",
22809
22916
  running: Boolean(raw.running),
@@ -22859,13 +22966,13 @@ function finishSetupLog(threadId, exitCode, source) {
22859
22966
  persistNow(threadId);
22860
22967
  return materialize(mem);
22861
22968
  }
22862
- var import_node_crypto14, import_node_fs56, import_node_path57, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers, PERSIST_DEBOUNCE_MS;
22969
+ var import_node_crypto14, import_node_fs57, import_node_path58, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers, PERSIST_DEBOUNCE_MS;
22863
22970
  var init_setup_log = __esm({
22864
22971
  "src/store/setup-log.ts"() {
22865
22972
  "use strict";
22866
22973
  import_node_crypto14 = require("crypto");
22867
- import_node_fs56 = require("fs");
22868
- import_node_path57 = require("path");
22974
+ import_node_fs57 = require("fs");
22975
+ import_node_path58 = require("path");
22869
22976
  init_worktree_labels();
22870
22977
  init_paths();
22871
22978
  EMPTY = {
@@ -22910,7 +23017,7 @@ function safeScriptToken(scriptName) {
22910
23017
  return token || "dev";
22911
23018
  }
22912
23019
  function runLogPath(key) {
22913
- return (0, import_node_path58.join)(threadsDir(), `${key}.run.log.json`);
23020
+ return (0, import_node_path59.join)(threadsDir(), `${key}.run.log.json`);
22914
23021
  }
22915
23022
  function runLogKeyForWorktree(worktreePath, scriptName) {
22916
23023
  const norm = normalizeWorktreePath(worktreePath);
@@ -22938,7 +23045,7 @@ function persistNow2(key) {
22938
23045
  const mem = memory2.get(key);
22939
23046
  if (!mem) return;
22940
23047
  try {
22941
- (0, import_node_fs57.writeFileSync)(runLogPath(key), `${JSON.stringify(materialize2(mem))}
23048
+ (0, import_node_fs58.writeFileSync)(runLogPath(key), `${JSON.stringify(materialize2(mem))}
22942
23049
  `, "utf8");
22943
23050
  } catch {
22944
23051
  }
@@ -22955,9 +23062,9 @@ function schedulePersist2(key) {
22955
23062
  }
22956
23063
  function loadFromDisk2(key) {
22957
23064
  const path = runLogPath(key);
22958
- if (!(0, import_node_fs57.existsSync)(path)) return null;
23065
+ if (!(0, import_node_fs58.existsSync)(path)) return null;
22959
23066
  try {
22960
- const raw = JSON.parse((0, import_node_fs57.readFileSync)(path, "utf8"));
23067
+ const raw = JSON.parse((0, import_node_fs58.readFileSync)(path, "utf8"));
22961
23068
  return {
22962
23069
  output: typeof raw.output === "string" ? raw.output : "",
22963
23070
  running: Boolean(raw.running),
@@ -23015,13 +23122,13 @@ function finishRunLog(key, exitCode) {
23015
23122
  function flushRunLog(key) {
23016
23123
  persistNow2(key);
23017
23124
  }
23018
- var import_node_crypto15, import_node_fs57, import_node_path58, EMPTY2, MAX_RUN_LOG_CHARS, DEFAULT_RUN_LOG_TAIL_CHARS, memory2, persistTimers2, PERSIST_DEBOUNCE_MS2;
23125
+ var import_node_crypto15, import_node_fs58, import_node_path59, EMPTY2, MAX_RUN_LOG_CHARS, DEFAULT_RUN_LOG_TAIL_CHARS, memory2, persistTimers2, PERSIST_DEBOUNCE_MS2;
23019
23126
  var init_run_log = __esm({
23020
23127
  "src/store/run-log.ts"() {
23021
23128
  "use strict";
23022
23129
  import_node_crypto15 = require("crypto");
23023
- import_node_fs57 = require("fs");
23024
- import_node_path58 = require("path");
23130
+ import_node_fs58 = require("fs");
23131
+ import_node_path59 = require("path");
23025
23132
  init_worktree_labels();
23026
23133
  init_setup_log();
23027
23134
  init_paths();
@@ -23050,9 +23157,9 @@ async function findOrphanWorktrees(repoPaths) {
23050
23157
  repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
23051
23158
  );
23052
23159
  const homeRoot = sideboardWorkspacesDir();
23053
- if ((0, import_node_fs58.existsSync)(homeRoot)) {
23160
+ if ((0, import_node_fs59.existsSync)(homeRoot)) {
23054
23161
  try {
23055
- for (const entry of (0, import_node_fs58.readdirSync)(homeRoot, { withFileTypes: true })) {
23162
+ for (const entry of (0, import_node_fs59.readdirSync)(homeRoot, { withFileTypes: true })) {
23056
23163
  if (!entry.isDirectory()) continue;
23057
23164
  void entry;
23058
23165
  }
@@ -23062,7 +23169,7 @@ async function findOrphanWorktrees(repoPaths) {
23062
23169
  const orphans = [];
23063
23170
  const seen = /* @__PURE__ */ new Set();
23064
23171
  for (const repoPath of repos) {
23065
- if (!repoPath || !(0, import_node_fs58.existsSync)(repoPath)) continue;
23172
+ if (!repoPath || !(0, import_node_fs59.existsSync)(repoPath)) continue;
23066
23173
  try {
23067
23174
  const wts = await listWorktrees(repoPath);
23068
23175
  for (const wt of wts) {
@@ -23073,7 +23180,7 @@ async function findOrphanWorktrees(repoPaths) {
23073
23180
  seen.add(path);
23074
23181
  let mtimeMs = 0;
23075
23182
  try {
23076
- mtimeMs = (0, import_node_fs58.statSync)(path).mtimeMs;
23183
+ mtimeMs = (0, import_node_fs59.statSync)(path).mtimeMs;
23077
23184
  } catch {
23078
23185
  mtimeMs = 0;
23079
23186
  }
@@ -23083,16 +23190,16 @@ async function findOrphanWorktrees(repoPaths) {
23083
23190
  }
23084
23191
  try {
23085
23192
  const root = worktreesRoot(repoPath);
23086
- if ((0, import_node_fs58.existsSync)(root)) {
23087
- for (const entry of (0, import_node_fs58.readdirSync)(root, { withFileTypes: true })) {
23193
+ if ((0, import_node_fs59.existsSync)(root)) {
23194
+ for (const entry of (0, import_node_fs59.readdirSync)(root, { withFileTypes: true })) {
23088
23195
  if (!entry.isDirectory()) continue;
23089
- const path = (0, import_node_path59.join)(root, entry.name).replace(/\/$/, "");
23196
+ const path = (0, import_node_path60.join)(root, entry.name).replace(/\/$/, "");
23090
23197
  if (known.has(path) || seen.has(path)) continue;
23091
- if (!(0, import_node_fs58.existsSync)((0, import_node_path59.join)(path, ".git"))) continue;
23198
+ if (!(0, import_node_fs59.existsSync)((0, import_node_path60.join)(path, ".git"))) continue;
23092
23199
  seen.add(path);
23093
23200
  let mtimeMs = 0;
23094
23201
  try {
23095
- mtimeMs = (0, import_node_fs58.statSync)(path).mtimeMs;
23202
+ mtimeMs = (0, import_node_fs59.statSync)(path).mtimeMs;
23096
23203
  } catch {
23097
23204
  mtimeMs = Date.now();
23098
23205
  }
@@ -23144,12 +23251,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
23144
23251
  const elapsed = Date.now() - Date.parse(last);
23145
23252
  return elapsed >= intervalHours * 36e5;
23146
23253
  }
23147
- var import_node_fs58, import_node_path59;
23254
+ var import_node_fs59, import_node_path60;
23148
23255
  var init_orphan_cleanup = __esm({
23149
23256
  "src/git/orphan-cleanup.ts"() {
23150
23257
  "use strict";
23151
- import_node_fs58 = require("fs");
23152
- import_node_path59 = require("path");
23258
+ import_node_fs59 = require("fs");
23259
+ import_node_path60 = require("path");
23153
23260
  init_worktree();
23154
23261
  init_thread_store();
23155
23262
  init_paths();
@@ -23325,12 +23432,12 @@ async function cloneRepoIntoSideboard(opts) {
23325
23432
  if (!url) throw new Error("Clone URL is required");
23326
23433
  let name = opts.name?.trim();
23327
23434
  if (!name) {
23328
- const leaf = (0, import_node_path60.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
23435
+ const leaf = (0, import_node_path61.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
23329
23436
  name = leaf || "repo";
23330
23437
  }
23331
23438
  name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
23332
- const dest = (0, import_node_path60.join)(sideboardReposDir(), name);
23333
- if ((0, import_node_fs59.existsSync)(dest)) {
23439
+ const dest = (0, import_node_path61.join)(sideboardReposDir(), name);
23440
+ if ((0, import_node_fs60.existsSync)(dest)) {
23334
23441
  const repoPath2 = await resolveRepoRoot(dest);
23335
23442
  const workspace2 = await addWorkspace(repoPath2);
23336
23443
  return { repoPath: repoPath2, workspace: workspace2 };
@@ -23345,12 +23452,12 @@ async function cloneRepoIntoSideboard(opts) {
23345
23452
  const workspace = await addWorkspace(repoPath);
23346
23453
  return { repoPath, workspace };
23347
23454
  }
23348
- var import_node_fs59, import_node_path60, import_execa6;
23455
+ var import_node_fs60, import_node_path61, import_execa6;
23349
23456
  var init_clone_repo = __esm({
23350
23457
  "src/git/clone-repo.ts"() {
23351
23458
  "use strict";
23352
- import_node_fs59 = require("fs");
23353
- import_node_path60 = require("path");
23459
+ import_node_fs60 = require("fs");
23460
+ import_node_path61 = require("path");
23354
23461
  import_execa6 = require("execa");
23355
23462
  init_paths();
23356
23463
  init_workspaces();
@@ -23370,11 +23477,11 @@ var init_thread = __esm({
23370
23477
 
23371
23478
  // src/store/desktop-host.ts
23372
23479
  function desktopHostPidPath() {
23373
- return (0, import_node_path61.join)(appDataDir(), "desktop-host.pid");
23480
+ return (0, import_node_path62.join)(appDataDir(), "desktop-host.pid");
23374
23481
  }
23375
23482
  function readDesktopHostPid() {
23376
23483
  try {
23377
- const pid = Number.parseInt((0, import_node_fs60.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
23484
+ const pid = Number.parseInt((0, import_node_fs61.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
23378
23485
  if (!Number.isFinite(pid) || pid <= 0) return null;
23379
23486
  return pid;
23380
23487
  } catch {
@@ -23400,12 +23507,12 @@ function thisProcessShouldDrainAgentQueues() {
23400
23507
  if (isThisProcessDesktopHost()) return true;
23401
23508
  return !isDesktopHostAlive();
23402
23509
  }
23403
- var import_node_fs60, import_node_path61;
23510
+ var import_node_fs61, import_node_path62;
23404
23511
  var init_desktop_host = __esm({
23405
23512
  "src/store/desktop-host.ts"() {
23406
23513
  "use strict";
23407
- import_node_fs60 = require("fs");
23408
- import_node_path61 = require("path");
23514
+ import_node_fs61 = require("fs");
23515
+ import_node_path62 = require("path");
23409
23516
  init_paths();
23410
23517
  }
23411
23518
  });
@@ -23445,12 +23552,12 @@ function denyPendingToolPermissions(threadId) {
23445
23552
  const last = pending[pending.length - 1];
23446
23553
  if (last) clearPrompt(threadId, last.id);
23447
23554
  }
23448
- var import_node_crypto16, import_node_path62, queues, publisher;
23555
+ var import_node_crypto16, import_node_path63, queues, publisher;
23449
23556
  var init_tool_permission = __esm({
23450
23557
  "src/agents/tool-permission.ts"() {
23451
23558
  "use strict";
23452
23559
  import_node_crypto16 = require("crypto");
23453
- import_node_path62 = require("path");
23560
+ import_node_path63 = require("path");
23454
23561
  init_claude_mcp();
23455
23562
  queues = /* @__PURE__ */ new Map();
23456
23563
  publisher = null;
@@ -26622,7 +26729,7 @@ function reuseLiveThread(input, repoPath, match) {
26622
26729
  }
26623
26730
  async function createThread(input, _onSetupLine) {
26624
26731
  const repoPath = await resolveRepoRoot(input.repoPath);
26625
- if (!(0, import_node_fs61.existsSync)(repoPath)) {
26732
+ if (!(0, import_node_fs62.existsSync)(repoPath)) {
26626
26733
  throw new Error(`Repo not found: ${repoPath}`);
26627
26734
  }
26628
26735
  if (isRemovedWorkspace(repoPath)) throw new Error(`Project was removed: ${repoPath}`);
@@ -26813,11 +26920,11 @@ async function createThread(input, _onSetupLine) {
26813
26920
  await ensureWorkspace(repoPath);
26814
26921
  return readThread(thread.id) ?? thread;
26815
26922
  }
26816
- var import_node_fs61;
26923
+ var import_node_fs62;
26817
26924
  var init_create = __esm({
26818
26925
  "src/threads/create.ts"() {
26819
26926
  "use strict";
26820
- import_node_fs61 = require("fs");
26927
+ import_node_fs62 = require("fs");
26821
26928
  init_acp_harness();
26822
26929
  init_detect();
26823
26930
  init_worktree();
@@ -26907,7 +27014,7 @@ function stampOf(thread) {
26907
27014
  function repoLabel(thread) {
26908
27015
  if (isOrchestratorThread(thread)) return "Orchestration";
26909
27016
  const path = thread.repoPath?.trim() ?? "";
26910
- return path && (0, import_node_path63.basename)(path) || path || "project";
27017
+ return path && (0, import_node_path64.basename)(path) || path || "project";
26911
27018
  }
26912
27019
  function toAgent(thread, flags) {
26913
27020
  const prUrl = thread.prUrl?.trim();
@@ -27106,11 +27213,11 @@ function formatFleetArchive(view) {
27106
27213
  }
27107
27214
  return lines.join("\n");
27108
27215
  }
27109
- var import_node_path63, DEFAULT_LIMIT, MAX_LIMIT;
27216
+ var import_node_path64, DEFAULT_LIMIT, MAX_LIMIT;
27110
27217
  var init_fleet_archive = __esm({
27111
27218
  "src/archive/fleet-archive.ts"() {
27112
27219
  "use strict";
27113
- import_node_path63 = require("path");
27220
+ import_node_path64 = require("path");
27114
27221
  init_global_workspace();
27115
27222
  init_worktree_labels();
27116
27223
  DEFAULT_LIMIT = 40;
@@ -27285,11 +27392,11 @@ function writeTurnLive(threadId, progress) {
27285
27392
  const path = threadLivePath(threadId);
27286
27393
  const tmp = `${path}.${process.pid}.tmp`;
27287
27394
  try {
27288
- (0, import_node_fs62.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
27289
- (0, import_node_fs62.renameSync)(tmp, path);
27395
+ (0, import_node_fs63.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
27396
+ (0, import_node_fs63.renameSync)(tmp, path);
27290
27397
  } catch {
27291
27398
  try {
27292
- (0, import_node_fs62.unlinkSync)(tmp);
27399
+ (0, import_node_fs63.unlinkSync)(tmp);
27293
27400
  } catch {
27294
27401
  }
27295
27402
  }
@@ -27299,9 +27406,9 @@ function readTurnLiveParts(threadId) {
27299
27406
  }
27300
27407
  function readTurnLive(threadId) {
27301
27408
  const path = threadLivePath(threadId);
27302
- if (!(0, import_node_fs62.existsSync)(path)) return null;
27409
+ if (!(0, import_node_fs63.existsSync)(path)) return null;
27303
27410
  try {
27304
- const raw = JSON.parse((0, import_node_fs62.readFileSync)(path, "utf8"));
27411
+ const raw = JSON.parse((0, import_node_fs63.readFileSync)(path, "utf8"));
27305
27412
  if (!raw || typeof raw.summary !== "string") return null;
27306
27413
  return raw;
27307
27414
  } catch {
@@ -27313,17 +27420,17 @@ function clearTurnLive(threadId) {
27313
27420
  if (buf?.timer) clearTimeout(buf.timer);
27314
27421
  buffers.delete(threadId);
27315
27422
  const path = threadLivePath(threadId);
27316
- if (!(0, import_node_fs62.existsSync)(path)) return;
27423
+ if (!(0, import_node_fs63.existsSync)(path)) return;
27317
27424
  try {
27318
- (0, import_node_fs62.unlinkSync)(path);
27425
+ (0, import_node_fs63.unlinkSync)(path);
27319
27426
  } catch {
27320
27427
  }
27321
27428
  }
27322
- var import_node_fs62, buffers, FLUSH_MS, MAX_PARTS;
27429
+ var import_node_fs63, buffers, FLUSH_MS, MAX_PARTS;
27323
27430
  var init_turn_live = __esm({
27324
27431
  "src/store/turn-live.ts"() {
27325
27432
  "use strict";
27326
- import_node_fs62 = require("fs");
27433
+ import_node_fs63 = require("fs");
27327
27434
  init_message_parts();
27328
27435
  init_paths();
27329
27436
  init_agent_block();
@@ -27608,7 +27715,7 @@ var init_quota_failover = __esm({
27608
27715
  // src/threads/adopt.ts
27609
27716
  function thisModuleFile2() {
27610
27717
  const cjsFile = typeof __filename !== "undefined" ? __filename : "";
27611
- return cjsFile || process.argv[1] || (0, import_node_path64.join)(process.cwd(), "package.json");
27718
+ return cjsFile || process.argv[1] || (0, import_node_path65.join)(process.cwd(), "package.json");
27612
27719
  }
27613
27720
  function openReadonlySqlite(file) {
27614
27721
  const req = (0, import_node_module7.createRequire)(thisModuleFile2());
@@ -27626,21 +27733,21 @@ function mapAgentType(raw) {
27626
27733
  return null;
27627
27734
  }
27628
27735
  function resolveConductorCursorAgentId(workspacePath) {
27629
- if (!workspacePath || !(0, import_node_fs63.existsSync)(CURSOR_SDK_STORE)) return null;
27736
+ if (!workspacePath || !(0, import_node_fs64.existsSync)(CURSOR_SDK_STORE)) return null;
27630
27737
  const normalized = workspacePath.replace(/\/$/, "");
27631
27738
  let best = null;
27632
27739
  let hashes;
27633
27740
  try {
27634
- hashes = (0, import_node_fs63.readdirSync)(CURSOR_SDK_STORE);
27741
+ hashes = (0, import_node_fs64.readdirSync)(CURSOR_SDK_STORE);
27635
27742
  } catch {
27636
27743
  return null;
27637
27744
  }
27638
27745
  for (const hash of hashes) {
27639
- const agentsFile = (0, import_node_path64.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
27640
- if (!(0, import_node_fs63.existsSync)(agentsFile)) continue;
27746
+ const agentsFile = (0, import_node_path65.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
27747
+ if (!(0, import_node_fs64.existsSync)(agentsFile)) continue;
27641
27748
  let text8;
27642
27749
  try {
27643
- text8 = (0, import_node_fs63.readFileSync)(agentsFile, "utf8");
27750
+ text8 = (0, import_node_fs64.readFileSync)(agentsFile, "utf8");
27644
27751
  } catch {
27645
27752
  continue;
27646
27753
  }
@@ -27664,7 +27771,7 @@ function resolveConductorCursorAgentId(workspacePath) {
27664
27771
  return best?.agentId ?? null;
27665
27772
  }
27666
27773
  async function adoptThread(input) {
27667
- if (!(0, import_node_fs63.existsSync)(input.worktreePath)) {
27774
+ if (!(0, import_node_fs64.existsSync)(input.worktreePath)) {
27668
27775
  throw new Error(`Worktree not found: ${input.worktreePath}`);
27669
27776
  }
27670
27777
  const repoPath = await resolveRepoRoot(input.worktreePath);
@@ -27693,18 +27800,18 @@ async function adoptThread(input) {
27693
27800
  return thread;
27694
27801
  }
27695
27802
  function listConductorWorkspaces() {
27696
- if (!(0, import_node_fs63.existsSync)(CONDUCTOR_DB)) {
27803
+ if (!(0, import_node_fs64.existsSync)(CONDUCTOR_DB)) {
27697
27804
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
27698
27805
  }
27699
- const tmp = (0, import_node_fs63.mkdtempSync)((0, import_node_path64.join)((0, import_node_os21.tmpdir)(), "sideboard-conductor-"));
27700
- const snapshot = (0, import_node_path64.join)(tmp, "conductor.db");
27806
+ const tmp = (0, import_node_fs64.mkdtempSync)((0, import_node_path65.join)((0, import_node_os21.tmpdir)(), "sideboard-conductor-"));
27807
+ const snapshot = (0, import_node_path65.join)(tmp, "conductor.db");
27701
27808
  try {
27702
- (0, import_node_fs63.copyFileSync)(CONDUCTOR_DB, snapshot);
27809
+ (0, import_node_fs64.copyFileSync)(CONDUCTOR_DB, snapshot);
27703
27810
  for (const suffix of ["-wal", "-shm"]) {
27704
27811
  const src = `${CONDUCTOR_DB}${suffix}`;
27705
- if ((0, import_node_fs63.existsSync)(src)) {
27812
+ if ((0, import_node_fs64.existsSync)(src)) {
27706
27813
  try {
27707
- (0, import_node_fs63.copyFileSync)(src, `${snapshot}${suffix}`);
27814
+ (0, import_node_fs64.copyFileSync)(src, `${snapshot}${suffix}`);
27708
27815
  } catch {
27709
27816
  }
27710
27817
  }
@@ -27780,22 +27887,22 @@ function listConductorWorkspaces() {
27780
27887
  db.close();
27781
27888
  }
27782
27889
  } finally {
27783
- (0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
27890
+ (0, import_node_fs64.rmSync)(tmp, { recursive: true, force: true });
27784
27891
  }
27785
27892
  }
27786
27893
  function importConductorWorkspace(workspaceId) {
27787
- if (!(0, import_node_fs63.existsSync)(CONDUCTOR_DB)) {
27894
+ if (!(0, import_node_fs64.existsSync)(CONDUCTOR_DB)) {
27788
27895
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
27789
27896
  }
27790
- const tmp = (0, import_node_fs63.mkdtempSync)((0, import_node_path64.join)((0, import_node_os21.tmpdir)(), "sideboard-conductor-"));
27791
- const snapshot = (0, import_node_path64.join)(tmp, "conductor.db");
27897
+ const tmp = (0, import_node_fs64.mkdtempSync)((0, import_node_path65.join)((0, import_node_os21.tmpdir)(), "sideboard-conductor-"));
27898
+ const snapshot = (0, import_node_path65.join)(tmp, "conductor.db");
27792
27899
  try {
27793
- (0, import_node_fs63.copyFileSync)(CONDUCTOR_DB, snapshot);
27900
+ (0, import_node_fs64.copyFileSync)(CONDUCTOR_DB, snapshot);
27794
27901
  for (const suffix of ["-wal", "-shm"]) {
27795
27902
  const src = `${CONDUCTOR_DB}${suffix}`;
27796
- if ((0, import_node_fs63.existsSync)(src)) {
27903
+ if ((0, import_node_fs64.existsSync)(src)) {
27797
27904
  try {
27798
- (0, import_node_fs63.copyFileSync)(src, `${snapshot}${suffix}`);
27905
+ (0, import_node_fs64.copyFileSync)(src, `${snapshot}${suffix}`);
27799
27906
  } catch {
27800
27907
  }
27801
27908
  }
@@ -27813,7 +27920,7 @@ function importConductorWorkspace(workspaceId) {
27813
27920
  ).get(workspaceId);
27814
27921
  if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
27815
27922
  const worktreePath = String(row.workspacePath);
27816
- if (!(0, import_node_fs63.existsSync)(worktreePath)) {
27923
+ if (!(0, import_node_fs64.existsSync)(worktreePath)) {
27817
27924
  throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
27818
27925
  }
27819
27926
  let sessionId = null;
@@ -27876,31 +27983,31 @@ function importConductorWorkspace(workspaceId) {
27876
27983
  db.close();
27877
27984
  }
27878
27985
  } finally {
27879
- (0, import_node_fs63.rmSync)(tmp, { recursive: true, force: true });
27986
+ (0, import_node_fs64.rmSync)(tmp, { recursive: true, force: true });
27880
27987
  }
27881
27988
  }
27882
27989
  async function importConductorWorkspaceAsync(workspaceId) {
27883
27990
  return importConductorWorkspace(workspaceId);
27884
27991
  }
27885
- var import_node_child_process7, import_node_fs63, import_node_os21, import_node_path64, import_node_module7, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
27992
+ var import_node_child_process7, import_node_fs64, import_node_os21, import_node_path65, import_node_module7, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
27886
27993
  var init_adopt = __esm({
27887
27994
  "src/threads/adopt.ts"() {
27888
27995
  "use strict";
27889
27996
  import_node_child_process7 = require("child_process");
27890
- import_node_fs63 = require("fs");
27997
+ import_node_fs64 = require("fs");
27891
27998
  import_node_os21 = require("os");
27892
- import_node_path64 = require("path");
27999
+ import_node_path65 = require("path");
27893
28000
  import_node_module7 = require("module");
27894
28001
  init_worktree();
27895
28002
  init_thread_store();
27896
- CONDUCTOR_APP_SUPPORT = (0, import_node_path64.join)(
28003
+ CONDUCTOR_APP_SUPPORT = (0, import_node_path65.join)(
27897
28004
  process.env.HOME ?? "",
27898
28005
  "Library",
27899
28006
  "Application Support",
27900
28007
  "com.conductor.app"
27901
28008
  );
27902
- CONDUCTOR_DB = (0, import_node_path64.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
27903
- CURSOR_SDK_STORE = (0, import_node_path64.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
28009
+ CONDUCTOR_DB = (0, import_node_path65.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
28010
+ CURSOR_SDK_STORE = (0, import_node_path65.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
27904
28011
  }
27905
28012
  });
27906
28013
 
@@ -27967,7 +28074,7 @@ async function openStackLayer(input, _onSetupLine) {
27967
28074
  let createdWorktree = false;
27968
28075
  const trees = await listWorktrees(repoPath);
27969
28076
  const checkedOut = trees.find((w) => w.branch === branchName);
27970
- if (checkedOut?.path && (0, import_node_fs64.existsSync)(checkedOut.path)) {
28077
+ if (checkedOut?.path && (0, import_node_fs65.existsSync)(checkedOut.path)) {
27971
28078
  if (input.reuseExistingWorktree !== false) {
27972
28079
  worktreePath = checkedOut.path;
27973
28080
  } else {
@@ -28109,7 +28216,7 @@ async function initStackFromThread(input, onSetupLine) {
28109
28216
  async function createPrStack(input, onSetupLine) {
28110
28217
  await requireAgent(input.agent);
28111
28218
  const repoPath = await resolveRepoRoot(input.repoPath);
28112
- if (!(0, import_node_fs64.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
28219
+ if (!(0, import_node_fs65.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
28113
28220
  if (!input.branches.length) throw new Error("At least one branch name required");
28114
28221
  const status = await detectGhStack(repoPath);
28115
28222
  if (!status.available) throw new Error(status.reason);
@@ -28176,7 +28283,7 @@ async function createPrStack(input, onSetupLine) {
28176
28283
  }
28177
28284
  }
28178
28285
  const claimed = new Set(threads.map((t) => t.worktreePath));
28179
- if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs64.existsSync)(bootstrap.worktreePath)) {
28286
+ if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs65.existsSync)(bootstrap.worktreePath)) {
28180
28287
  try {
28181
28288
  await removeWorktree(repoPath, bootstrap.worktreePath, {
28182
28289
  deleteBranch: bootstrap.branchName
@@ -28186,11 +28293,11 @@ async function createPrStack(input, onSetupLine) {
28186
28293
  }
28187
28294
  return { stack, threads, createdThreadIds };
28188
28295
  }
28189
- var import_node_fs64;
28296
+ var import_node_fs65;
28190
28297
  var init_stack_layers = __esm({
28191
28298
  "src/threads/stack-layers.ts"() {
28192
28299
  "use strict";
28193
- import_node_fs64 = require("fs");
28300
+ import_node_fs65 = require("fs");
28194
28301
  init_detect();
28195
28302
  init_run();
28196
28303
  init_stack();
@@ -28230,11 +28337,11 @@ async function formatPrCreateFailure(raw, cwd, ctx) {
28230
28337
  }
28231
28338
  async function createCursorPullRequest(worktreePath, slug, opts) {
28232
28339
  const bodyText = (opts.body ?? opts.title).trim() || opts.title;
28233
- const bodyFile = (0, import_node_path65.join)(
28340
+ const bodyFile = (0, import_node_path66.join)(
28234
28341
  (0, import_node_os22.tmpdir)(),
28235
28342
  `sideboard-pr-body-${process.pid}-${(0, import_node_crypto20.randomBytes)(6).toString("hex")}.md`
28236
28343
  );
28237
- (0, import_node_fs65.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
28344
+ (0, import_node_fs66.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
28238
28345
  `, "utf8");
28239
28346
  try {
28240
28347
  return await createOrUpdateCursorPr(worktreePath, slug, {
@@ -28246,7 +28353,7 @@ async function createCursorPullRequest(worktreePath, slug, opts) {
28246
28353
  });
28247
28354
  } finally {
28248
28355
  try {
28249
- (0, import_node_fs65.unlinkSync)(bodyFile);
28356
+ (0, import_node_fs66.unlinkSync)(bodyFile);
28250
28357
  } catch {
28251
28358
  }
28252
28359
  }
@@ -28272,11 +28379,11 @@ async function createOrUpdatePr(worktreePath, opts) {
28272
28379
  const headRef = ghHeadRef(slug, opts.head);
28273
28380
  const branchOnly = opts.head.trim().replace(/^refs\/heads\//, "");
28274
28381
  const bodyText = clampGithubPrBody(opts.body ?? opts.title);
28275
- const bodyFile = (0, import_node_path65.join)(
28382
+ const bodyFile = (0, import_node_path66.join)(
28276
28383
  (0, import_node_os22.tmpdir)(),
28277
28384
  `sideboard-pr-body-${process.pid}-${(0, import_node_crypto20.randomBytes)(6).toString("hex")}.md`
28278
28385
  );
28279
- (0, import_node_fs65.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
28386
+ (0, import_node_fs66.writeFileSync)(bodyFile, bodyText.endsWith("\n") ? bodyText : `${bodyText}
28280
28387
  `, "utf8");
28281
28388
  const bodyArgs = ["--body-file", bodyFile];
28282
28389
  try {
@@ -28290,7 +28397,7 @@ async function createOrUpdatePr(worktreePath, opts) {
28290
28397
  });
28291
28398
  } finally {
28292
28399
  try {
28293
- (0, import_node_fs65.unlinkSync)(bodyFile);
28400
+ (0, import_node_fs66.unlinkSync)(bodyFile);
28294
28401
  } catch {
28295
28402
  }
28296
28403
  }
@@ -28365,14 +28472,14 @@ async function createOrUpdatePrWithBodyFile(worktreePath, opts) {
28365
28472
  const url = created.stdout.trim().split("\n").find((l) => l.startsWith("http")) ?? created.stdout.trim();
28366
28473
  return url;
28367
28474
  }
28368
- var import_node_crypto20, import_node_fs65, import_node_os22, import_node_path65;
28475
+ var import_node_crypto20, import_node_fs66, import_node_os22, import_node_path66;
28369
28476
  var init_pr_write = __esm({
28370
28477
  "src/git/pr-write.ts"() {
28371
28478
  "use strict";
28372
28479
  import_node_crypto20 = require("crypto");
28373
- import_node_fs65 = require("fs");
28480
+ import_node_fs66 = require("fs");
28374
28481
  import_node_os22 = require("os");
28375
- import_node_path65 = require("path");
28482
+ import_node_path66 = require("path");
28376
28483
  init_gh_errors();
28377
28484
  init_run();
28378
28485
  init_cursor_pr();
@@ -28382,7 +28489,7 @@ var init_pr_write = __esm({
28382
28489
 
28383
28490
  // src/diff/diff.ts
28384
28491
  async function inspectGitWorktree(worktreePath) {
28385
- if (!worktreePath || !(0, import_node_fs66.existsSync)(worktreePath)) return "missing_worktree";
28492
+ if (!worktreePath || !(0, import_node_fs67.existsSync)(worktreePath)) return "missing_worktree";
28386
28493
  const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
28387
28494
  reject: false
28388
28495
  });
@@ -28390,7 +28497,7 @@ async function inspectGitWorktree(worktreePath) {
28390
28497
  return "ok";
28391
28498
  }
28392
28499
  async function initializeGitRepository(worktreePath) {
28393
- if (!worktreePath || !(0, import_node_fs66.existsSync)(worktreePath)) {
28500
+ if (!worktreePath || !(0, import_node_fs67.existsSync)(worktreePath)) {
28394
28501
  throw new Error("Worktree not found");
28395
28502
  }
28396
28503
  const status = await inspectGitWorktree(worktreePath);
@@ -28524,11 +28631,11 @@ new file mode 100644
28524
28631
  };
28525
28632
  }
28526
28633
  async function untrackedPatch(worktreePath, path, maxHunk) {
28527
- const abs = (0, import_node_path66.join)(worktreePath, path);
28634
+ const abs = (0, import_node_path67.join)(worktreePath, path);
28528
28635
  try {
28529
- const st = (0, import_node_fs66.statSync)(abs);
28636
+ const st = (0, import_node_fs67.statSync)(abs);
28530
28637
  if (st.isFile() && st.size > maxHunk) {
28531
- const buf = (0, import_node_fs66.readFileSync)(abs).subarray(0, maxHunk);
28638
+ const buf = (0, import_node_fs67.readFileSync)(abs).subarray(0, maxHunk);
28532
28639
  return syntheticAddPatch(path, buf.toString("utf8"), maxHunk);
28533
28640
  }
28534
28641
  } catch {
@@ -28995,9 +29102,9 @@ async function getDiff(worktreePath, repoPath, opts) {
28995
29102
  }
28996
29103
  function statWorktreePath(worktreePath, relativePath) {
28997
29104
  assertSafeRelativePath(relativePath);
28998
- const abs = (0, import_node_path66.join)(worktreePath, relativePath);
28999
- if (!(0, import_node_fs66.existsSync)(abs)) return "missing";
29000
- const st = (0, import_node_fs66.statSync)(abs);
29105
+ const abs = (0, import_node_path67.join)(worktreePath, relativePath);
29106
+ if (!(0, import_node_fs67.existsSync)(abs)) return "missing";
29107
+ const st = (0, import_node_fs67.statSync)(abs);
29001
29108
  if (st.isDirectory()) return "dir";
29002
29109
  if (st.isFile()) return "file";
29003
29110
  return "missing";
@@ -29026,8 +29133,8 @@ function isImageRelativePath(relativePath) {
29026
29133
  function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
29027
29134
  assertSafeRelativePath(relativePath);
29028
29135
  const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
29029
- const abs = (0, import_node_path66.join)(worktreePath, relativePath);
29030
- const st = (0, import_node_fs66.statSync)(abs);
29136
+ const abs = (0, import_node_path67.join)(worktreePath, relativePath);
29137
+ const st = (0, import_node_fs67.statSync)(abs);
29031
29138
  if (!st.isFile()) {
29032
29139
  throw new Error(`Not a file: ${relativePath}`);
29033
29140
  }
@@ -29036,7 +29143,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
29036
29143
  `File too large to upload (${st.size} bytes; max ${maxBytes})`
29037
29144
  );
29038
29145
  }
29039
- const buf = (0, import_node_fs66.readFileSync)(abs);
29146
+ const buf = (0, import_node_fs67.readFileSync)(abs);
29040
29147
  return {
29041
29148
  path: relativePath,
29042
29149
  contentBase64: buf.toString("base64"),
@@ -29046,12 +29153,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
29046
29153
  function readWorktreeFile(worktreePath, relativePath, opts) {
29047
29154
  assertSafeRelativePath(relativePath);
29048
29155
  const maxBytes = opts?.maxBytes ?? 2e5;
29049
- const abs = (0, import_node_path66.join)(worktreePath, relativePath);
29050
- const st = (0, import_node_fs66.statSync)(abs);
29156
+ const abs = (0, import_node_path67.join)(worktreePath, relativePath);
29157
+ const st = (0, import_node_fs67.statSync)(abs);
29051
29158
  if (!st.isFile()) {
29052
29159
  throw new Error(`Not a file: ${relativePath}`);
29053
29160
  }
29054
- const buf = (0, import_node_fs66.readFileSync)(abs);
29161
+ const buf = (0, import_node_fs67.readFileSync)(abs);
29055
29162
  if (isImageRelativePath(relativePath)) {
29056
29163
  const maxImageBytes = Math.max(maxBytes, 15e6);
29057
29164
  const truncated2 = buf.length > maxImageBytes;
@@ -29094,9 +29201,9 @@ function assertSafeRelativePath(relativePath) {
29094
29201
  }
29095
29202
  function writeWorktreeFile(worktreePath, relativePath, content) {
29096
29203
  assertSafeRelativePath(relativePath);
29097
- const abs = (0, import_node_path66.join)(worktreePath, relativePath);
29098
- (0, import_node_fs66.mkdirSync)((0, import_node_path66.dirname)(abs), { recursive: true });
29099
- (0, import_node_fs66.writeFileSync)(abs, content, "utf8");
29204
+ const abs = (0, import_node_path67.join)(worktreePath, relativePath);
29205
+ (0, import_node_fs67.mkdirSync)((0, import_node_path67.dirname)(abs), { recursive: true });
29206
+ (0, import_node_fs67.writeFileSync)(abs, content, "utf8");
29100
29207
  return { path: relativePath };
29101
29208
  }
29102
29209
  async function getWorktreeDirtyStat(worktreePath) {
@@ -29136,12 +29243,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
29136
29243
  truncated: full.files.length > maxFiles
29137
29244
  };
29138
29245
  }
29139
- var import_node_fs66, import_node_path66, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
29246
+ var import_node_fs67, import_node_path67, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
29140
29247
  var init_diff = __esm({
29141
29248
  "src/diff/diff.ts"() {
29142
29249
  "use strict";
29143
- import_node_fs66 = require("fs");
29144
- import_node_path66 = require("path");
29250
+ import_node_fs67 = require("fs");
29251
+ import_node_path67 = require("path");
29145
29252
  init_run();
29146
29253
  init_worktree();
29147
29254
  mergeBaseCache = /* @__PURE__ */ new Map();
@@ -29364,16 +29471,16 @@ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TA
29364
29471
  if (!relativePath || relativePath.includes("..") || relativePath.startsWith("/")) {
29365
29472
  throw new Error("Invalid path");
29366
29473
  }
29367
- const abs = (0, import_node_path67.join)(worktreePath, relativePath);
29368
- const fd = (0, import_node_fs67.openSync)(abs, "r");
29474
+ const abs = (0, import_node_path68.join)(worktreePath, relativePath);
29475
+ const fd = (0, import_node_fs68.openSync)(abs, "r");
29369
29476
  try {
29370
- const st = (0, import_node_fs67.fstatSync)(fd);
29477
+ const st = (0, import_node_fs68.fstatSync)(fd);
29371
29478
  if (!st.isFile()) throw new Error(`Not a file: ${relativePath}`);
29372
29479
  const size = st.size;
29373
29480
  const start = Math.max(0, size - maxBytes);
29374
29481
  const length = size - start;
29375
29482
  const buf = Buffer.alloc(length);
29376
- if (length > 0) (0, import_node_fs67.readSync)(fd, buf, 0, length, start);
29483
+ if (length > 0) (0, import_node_fs68.readSync)(fd, buf, 0, length, start);
29377
29484
  if (buf.subarray(0, Math.min(buf.length, 8e3)).includes(0)) {
29378
29485
  return {
29379
29486
  path: relativePath,
@@ -29391,15 +29498,15 @@ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TA
29391
29498
  }
29392
29499
  return { path: relativePath, content, truncated, binary: false, encoding: "utf8" };
29393
29500
  } finally {
29394
- (0, import_node_fs67.closeSync)(fd);
29501
+ (0, import_node_fs68.closeSync)(fd);
29395
29502
  }
29396
29503
  }
29397
- var import_node_fs67, import_node_path67, WORKTREE_TAIL_BYTES;
29504
+ var import_node_fs68, import_node_path68, WORKTREE_TAIL_BYTES;
29398
29505
  var init_read_worktree_tail = __esm({
29399
29506
  "src/diff/read-worktree-tail.ts"() {
29400
29507
  "use strict";
29401
- import_node_fs67 = require("fs");
29402
- import_node_path67 = require("path");
29508
+ import_node_fs68 = require("fs");
29509
+ import_node_path68 = require("path");
29403
29510
  WORKTREE_TAIL_BYTES = 2e5;
29404
29511
  }
29405
29512
  });
@@ -29548,7 +29655,7 @@ function parseFrontmatter(content) {
29548
29655
  }
29549
29656
  function readSkill(skillMd, source) {
29550
29657
  try {
29551
- const content = (0, import_node_fs68.readFileSync)(skillMd, "utf8");
29658
+ const content = (0, import_node_fs69.readFileSync)(skillMd, "utf8");
29552
29659
  const { name: fmName, description } = parseFrontmatter(content);
29553
29660
  const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
29554
29661
  const name = fmName || dirName;
@@ -29567,19 +29674,19 @@ function readSkill(skillMd, source) {
29567
29674
  }
29568
29675
  }
29569
29676
  function scanSkillsDir(dir, source, out) {
29570
- if (!(0, import_node_fs68.existsSync)(dir)) return;
29677
+ if (!(0, import_node_fs69.existsSync)(dir)) return;
29571
29678
  let entries;
29572
29679
  try {
29573
- entries = (0, import_node_fs68.readdirSync)(dir);
29680
+ entries = (0, import_node_fs69.readdirSync)(dir);
29574
29681
  } catch {
29575
29682
  return;
29576
29683
  }
29577
29684
  for (const entry of entries) {
29578
29685
  if (entry.startsWith(".")) continue;
29579
- const skillMd = (0, import_node_path68.join)(dir, entry, "SKILL.md");
29580
- if (!(0, import_node_fs68.existsSync)(skillMd)) continue;
29686
+ const skillMd = (0, import_node_path69.join)(dir, entry, "SKILL.md");
29687
+ if (!(0, import_node_fs69.existsSync)(skillMd)) continue;
29581
29688
  try {
29582
- if (!(0, import_node_fs68.statSync)(skillMd).isFile()) continue;
29689
+ if (!(0, import_node_fs69.statSync)(skillMd).isFile()) continue;
29583
29690
  } catch {
29584
29691
  continue;
29585
29692
  }
@@ -29588,24 +29695,24 @@ function scanSkillsDir(dir, source, out) {
29588
29695
  }
29589
29696
  }
29590
29697
  function scanClaudePluginSkills(pluginsRoot, out) {
29591
- if (!(0, import_node_fs68.existsSync)(pluginsRoot)) return;
29698
+ if (!(0, import_node_fs69.existsSync)(pluginsRoot)) return;
29592
29699
  const walk = (dir, depth, lookingForSkillsDir) => {
29593
29700
  if (depth > 7) return;
29594
29701
  let entries;
29595
29702
  try {
29596
- entries = (0, import_node_fs68.readdirSync)(dir);
29703
+ entries = (0, import_node_fs69.readdirSync)(dir);
29597
29704
  } catch {
29598
29705
  return;
29599
29706
  }
29600
29707
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
29601
- const skill = readSkill((0, import_node_path68.join)(dir, "SKILL.md"), "cli");
29708
+ const skill = readSkill((0, import_node_path69.join)(dir, "SKILL.md"), "cli");
29602
29709
  if (skill) out.push(skill);
29603
29710
  }
29604
29711
  for (const entry of entries) {
29605
29712
  if (entry === "node_modules" || entry === ".git") continue;
29606
- const full = (0, import_node_path68.join)(dir, entry);
29713
+ const full = (0, import_node_path69.join)(dir, entry);
29607
29714
  try {
29608
- if (!(0, import_node_fs68.statSync)(full).isDirectory()) continue;
29715
+ if (!(0, import_node_fs69.statSync)(full).isDirectory()) continue;
29609
29716
  } catch {
29610
29717
  continue;
29611
29718
  }
@@ -29623,17 +29730,17 @@ function discoverSkills(worktreePath) {
29623
29730
  const home = (0, import_node_os23.homedir)();
29624
29731
  const collected = [];
29625
29732
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
29626
- scanSkillsDir((0, import_node_path68.join)(worktreePath, rel), "workspace", collected);
29733
+ scanSkillsDir((0, import_node_path69.join)(worktreePath, rel), "workspace", collected);
29627
29734
  }
29628
29735
  for (const abs of [
29629
- (0, import_node_path68.join)(home, ".claude/skills"),
29630
- (0, import_node_path68.join)(home, ".cursor/skills"),
29631
- (0, import_node_path68.join)(home, ".sideboard/skills"),
29632
- (0, import_node_path68.join)(home, ".brightsy/skills")
29736
+ (0, import_node_path69.join)(home, ".claude/skills"),
29737
+ (0, import_node_path69.join)(home, ".cursor/skills"),
29738
+ (0, import_node_path69.join)(home, ".sideboard/skills"),
29739
+ (0, import_node_path69.join)(home, ".brightsy/skills")
29633
29740
  ]) {
29634
29741
  scanSkillsDir(abs, "user", collected);
29635
29742
  }
29636
- scanClaudePluginSkills((0, import_node_path68.join)(home, ".claude/plugins"), collected);
29743
+ scanClaudePluginSkills((0, import_node_path69.join)(home, ".claude/plugins"), collected);
29637
29744
  collected.push(...bundledSkills());
29638
29745
  const rank = {
29639
29746
  workspace: 0,
@@ -29659,7 +29766,7 @@ function readSkillBody(skillPath, maxChars = 12e3) {
29659
29766
  \u2026(truncated)` : body;
29660
29767
  }
29661
29768
  }
29662
- const raw = (0, import_node_fs68.readFileSync)(skillPath, "utf8");
29769
+ const raw = (0, import_node_fs69.readFileSync)(skillPath, "utf8");
29663
29770
  if (raw.startsWith("---")) {
29664
29771
  const end = raw.indexOf("\n---", 3);
29665
29772
  if (end >= 0) {
@@ -29673,13 +29780,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
29673
29780
 
29674
29781
  \u2026(truncated)` : raw;
29675
29782
  }
29676
- var import_node_fs68, import_node_os23, import_node_path68, BUNDLED_SKILL_PREFIX;
29783
+ var import_node_fs69, import_node_os23, import_node_path69, BUNDLED_SKILL_PREFIX;
29677
29784
  var init_discover = __esm({
29678
29785
  "src/skills/discover.ts"() {
29679
29786
  "use strict";
29680
- import_node_fs68 = require("fs");
29787
+ import_node_fs69 = require("fs");
29681
29788
  import_node_os23 = require("os");
29682
- import_node_path68 = require("path");
29789
+ import_node_path69 = require("path");
29683
29790
  init_long_running();
29684
29791
  BUNDLED_SKILL_PREFIX = "bundled:";
29685
29792
  }
@@ -29967,7 +30074,8 @@ function promptForJoinedSteer(input) {
29967
30074
  input.worktreePath,
29968
30075
  expandCanonicalGitRequest(input.latestPrompt, {
29969
30076
  forge: input.gitForge,
29970
- worktreePath: input.worktreePath
30077
+ worktreePath: input.worktreePath,
30078
+ hasAnnounceSkill: announceSkillPresent(input.worktreePath)
29971
30079
  }),
29972
30080
  { attachments: latestAttachments }
29973
30081
  );
@@ -29993,10 +30101,10 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
29993
30101
  throw new Error(`Thread is archived: ${thread.id}`);
29994
30102
  }
29995
30103
  const requested = opts?.followUp;
29996
- const join69 = requested === "join";
30104
+ const join70 = requested === "join";
29997
30105
  const followUp = resolveSendFollowUp(
29998
30106
  current,
29999
- join69 ? "steer" : requested
30107
+ join70 ? "steer" : requested
30000
30108
  );
30001
30109
  const explicit = opts?.attachments;
30002
30110
  const consumed = explicit !== void 0 ? { attachments: current.attachments, consumed: explicit } : consumeComposerAttachments(current);
@@ -30005,7 +30113,7 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
30005
30113
  const draft = host.openSteerPrompt.get(current.id);
30006
30114
  const queuedHead = !inFlightEarly && current.status === "queued" && current.queue.length > 0 ? current.queue[0] : null;
30007
30115
  const joinCanMerge = draft != null && !draft.spawned || !inFlightEarly && queuedHead != null;
30008
- const unanswered = followUp === "steer" && !agentHasRepliedEarly && (!join69 || joinCanMerge) ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
30116
+ const unanswered = followUp === "steer" && !agentHasRepliedEarly && (!join70 || joinCanMerge) ? draft?.text ?? (inFlightEarly ? trailingUnansweredUserText(current.messages) : queuedHead) : null;
30009
30117
  if (unanswered != null && (draft ? !draft.spawned : queuedHead != null)) {
30010
30118
  clearSendBookkeeping(host, thread.id);
30011
30119
  const combined = joinSteerPrompt(unanswered, prompt);
@@ -30057,7 +30165,7 @@ async function enqueueThreadSend(host, threadRef, prompt, opts) {
30057
30165
  clearSendBookkeeping(host, thread.id);
30058
30166
  const inFlight = host.activeTurns.has(thread.id) || host.startingTurns.has(thread.id) || current.status === "running";
30059
30167
  shouldSteer = sendFollowUpInterrupts(
30060
- join69 ? "join" : followUp,
30168
+ join70 ? "join" : followUp,
30061
30169
  inFlight || current.queue.length > 0
30062
30170
  );
30063
30171
  const patch = queued;
@@ -30085,6 +30193,7 @@ var init_enqueue_thread_send = __esm({
30085
30193
  "src/orchestrator/enqueue-thread-send.ts"() {
30086
30194
  "use strict";
30087
30195
  init_agent_git_actions();
30196
+ init_announce_skill();
30088
30197
  init_agent_has_replied();
30089
30198
  init_expand();
30090
30199
  init_consume_attachments();
@@ -30130,7 +30239,7 @@ function compiledModuleDir() {
30130
30239
  try {
30131
30240
  const url = import_meta9.url;
30132
30241
  if (typeof url === "string" && url.length > 0) {
30133
- return (0, import_node_path69.dirname)((0, import_node_url7.fileURLToPath)(url));
30242
+ return (0, import_node_path70.dirname)((0, import_node_url7.fileURLToPath)(url));
30134
30243
  }
30135
30244
  } catch {
30136
30245
  }
@@ -30138,8 +30247,8 @@ function compiledModuleDir() {
30138
30247
  }
30139
30248
  function detachedJobScriptIn(dir) {
30140
30249
  for (const name of DETACHED_JOB_FILENAMES) {
30141
- const script = (0, import_node_path69.join)(dir, "scripts", name);
30142
- if ((0, import_node_fs69.existsSync)(script)) return script;
30250
+ const script = (0, import_node_path70.join)(dir, "scripts", name);
30251
+ if ((0, import_node_fs70.existsSync)(script)) return script;
30143
30252
  }
30144
30253
  return null;
30145
30254
  }
@@ -30156,7 +30265,7 @@ function resolveDetachedJobScript() {
30156
30265
  for (let i = 0; i < 8; i++) {
30157
30266
  const candidate = detachedJobScriptIn(dir);
30158
30267
  if (candidate) return candidate;
30159
- const parent = (0, import_node_path69.dirname)(dir);
30268
+ const parent = (0, import_node_path70.dirname)(dir);
30160
30269
  if (parent === dir) break;
30161
30270
  dir = parent;
30162
30271
  }
@@ -30167,12 +30276,12 @@ function formatDetachedJobInvoke(scriptPath) {
30167
30276
  if (resolved) return `node ${JSON.stringify(resolved)}`;
30168
30277
  return "node scripts/detached-job.cjs";
30169
30278
  }
30170
- var import_node_fs69, import_node_path69, import_node_url7, import_meta9, DETACHED_JOB_FILENAMES;
30279
+ var import_node_fs70, import_node_path70, import_node_url7, import_meta9, DETACHED_JOB_FILENAMES;
30171
30280
  var init_detached_job_path = __esm({
30172
30281
  "src/skills/detached-job-path.ts"() {
30173
30282
  "use strict";
30174
- import_node_fs69 = require("fs");
30175
- import_node_path69 = require("path");
30283
+ import_node_fs70 = require("fs");
30284
+ import_node_path70 = require("path");
30176
30285
  import_node_url7 = require("url");
30177
30286
  init_packaged_runtime();
30178
30287
  import_meta9 = {};
@@ -30275,7 +30384,7 @@ function formatWorktreeDirective(thread, opts) {
30275
30384
  lines.push(
30276
30385
  cursorRepo ? "- Stay on this workspace branch. Never push to main/master or merge locally into the main checkout. Merge the PR only when this turn is a Merge PR request or the user explicitly asked \u2014 via Origin from this worktree (`origin pr merge` / `origin stack merge`)." : entireRepo ? "- Stay on this workspace branch. Never push to main/master or merge locally into the main checkout. Merge only when this turn is a Merge PR request or the user explicitly asked \u2014 via Entire from this worktree (`entire trail merge`)." : "- Stay on this workspace branch. Never push to main/master or merge locally into the main checkout. Merge the PR only when this turn is a Merge PR request or the user explicitly asked \u2014 via GitHub from this worktree (`gh pr merge` / `gh stack merge`)."
30277
30386
  );
30278
- if ((0, import_node_fs70.existsSync)((0, import_node_path70.join)(worktree, ".claude/skills/announce-on-x/SKILL.md"))) lines.push("- After that merge to the default branch succeeds, follow `.claude/skills/announce-on-x/SKILL.md` (`/announce-on-x`) before the turn ends. Post or skip each pull request that merge landed on the default branch. Do not schedule a catch-up.");
30387
+ if ((0, import_node_fs71.existsSync)((0, import_node_path71.join)(worktree, ".claude/skills/announce-on-x/SKILL.md"))) lines.push("- After that merge to the default branch succeeds, follow `.claude/skills/announce-on-x/SKILL.md` (`/announce-on-x`) before the turn ends. Post or skip each pull request that merge landed on the default branch. Do not schedule a catch-up.");
30279
30388
  if (thread.prUrl) {
30280
30389
  lines.push(
30281
30390
  `- A PR already exists (${thread.prUrl}). Update it (push + edit title/body if the purpose drifted) instead of opening a duplicate.`
@@ -30411,16 +30520,16 @@ function formatPrGateDirective() {
30411
30520
  }
30412
30521
  function formatProcessGuideDirective(opts) {
30413
30522
  const worktree = opts?.worktreePath?.trim();
30414
- const hasGraphSkill = !!worktree && (0, import_node_fs70.existsSync)((0, import_node_path70.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
30415
- const hasReviewSkill = !!worktree && (0, import_node_fs70.existsSync)((0, import_node_path70.join)(worktree, ".claude/skills/review/SKILL.md"));
30416
- const hasInstallSkill = !!worktree && (0, import_node_fs70.existsSync)((0, import_node_path70.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
30523
+ const hasGraphSkill = !!worktree && (0, import_node_fs71.existsSync)((0, import_node_path71.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
30524
+ const hasReviewSkill = !!worktree && (0, import_node_fs71.existsSync)((0, import_node_path71.join)(worktree, ".claude/skills/review/SKILL.md"));
30525
+ const hasInstallSkill = !!worktree && (0, import_node_fs71.existsSync)((0, import_node_path71.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
30417
30526
  return [
30418
30527
  "Process guides (recurring work only):",
30419
30528
  hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
30420
30529
  hasInstallSkill ? "- After merge-from-main / lockfile change, or a hung `pnpm install`: follow `.claude/skills/worktree-install/SKILL.md` (`/worktree-install`). Use the worktree-local store Sideboard already set; do not share `~/.pnpm-store` across concurrent worktrees." : null,
30421
30530
  "- If this same shape of work will happen again, write `.claude/skills/<kebab-name>/SKILL.md` in this worktree (Claude Code project skill; Sideboard `/name`, Claude Code, and `attach` all load it). Not under `.sideboard/skills/`. Point Codex/OpenCode at it from `AGENTS.md`.",
30422
30531
  hasReviewSkill ? "- Merge-readiness notes go in `.claude/skills/review/SKILL.md` (edit it; do not create another review skill)." : "- Merge-readiness notes go in `.context/review.md` (copied from `.sideboard/review.md` when that file exists). Do not create a review skill.",
30423
- !!worktree && (0, import_node_fs70.existsSync)((0, import_node_path70.join)(worktree, ".claude/skills/skill-improver/SKILL.md")) ? "- Skip a guide for a one-off. If a matching skill exists, follow it. A miss that will recur (you made it twice, or a person told you the rule) \u2192 follow `.claude/skills/skill-improver/SKILL.md` (`/skill-improver`): one sentence in the skill that owns it, in this change. Do not patch around it." : "- Skip a guide for a one-off. If a matching skill exists, follow it. Same miss twice \u2192 edit the skill, do not patch around it."
30532
+ !!worktree && (0, import_node_fs71.existsSync)((0, import_node_path71.join)(worktree, ".claude/skills/skill-improver/SKILL.md")) ? "- Skip a guide for a one-off. If a matching skill exists, follow it. A miss that will recur (you made it twice, or a person told you the rule) \u2192 follow `.claude/skills/skill-improver/SKILL.md` (`/skill-improver`): one sentence in the skill that owns it, in this change. Do not patch around it." : "- Skip a guide for a one-off. If a matching skill exists, follow it. Same miss twice \u2192 edit the skill, do not patch around it."
30424
30533
  ].filter(Boolean).join("\n");
30425
30534
  }
30426
30535
  function formatLongRunningDirective(opts) {
@@ -30453,12 +30562,12 @@ function formatArtifactDirective() {
30453
30562
  function formatUiReminder() {
30454
30563
  return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). Chat links: `[name](sideboard://artifact/<id-or-title>)` opens that pane; `[name](sideboard://file/path#L12-L40)` opens a file. ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. ask_user wakes the parent orchestrator; notify_orchestrator if blocked without a picker. Do not say artifacts/CMS UI are unavailable. Dev / preview: run_dev_script (same as the Dev button; pass name \u2014 several scripts can run at once) returns {url, port, preview} (SIDEBOARD_PORT \u2014 never guess :3000). preview=url \u2192 open url; preview=window \u2192 Electron window is the app, url is renderer/HMR only. list_run_scripts active[].url if already running; get_run_log for that script\u2019s Run-tab terminal; stop_dev_script to stop one.";
30455
30564
  }
30456
- var import_node_fs70, import_node_path70, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
30565
+ var import_node_fs71, import_node_path71, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
30457
30566
  var init_instructions = __esm({
30458
30567
  "src/agents/instructions.ts"() {
30459
30568
  "use strict";
30460
- import_node_fs70 = require("fs");
30461
- import_node_path70 = require("path");
30569
+ import_node_fs71 = require("fs");
30570
+ import_node_path71 = require("path");
30462
30571
  init_git_auth_mode();
30463
30572
  init_forge_git_directives();
30464
30573
  init_branch_prefix();
@@ -31130,40 +31239,40 @@ __export(plan_file_exports, {
31130
31239
  writePlanFile: () => writePlanFile
31131
31240
  });
31132
31241
  function ensureAttachmentsGitignore(worktreePath) {
31133
- const gitignoreAbs = (0, import_node_path71.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
31134
- if ((0, import_node_fs71.existsSync)(gitignoreAbs)) return;
31135
- (0, import_node_fs71.mkdirSync)((0, import_node_path71.dirname)(gitignoreAbs), { recursive: true });
31136
- (0, import_node_fs71.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
31242
+ const gitignoreAbs = (0, import_node_path72.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
31243
+ if ((0, import_node_fs72.existsSync)(gitignoreAbs)) return;
31244
+ (0, import_node_fs72.mkdirSync)((0, import_node_path72.dirname)(gitignoreAbs), { recursive: true });
31245
+ (0, import_node_fs72.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
31137
31246
  }
31138
31247
  function planFileAbs(worktreePath) {
31139
- return (0, import_node_path71.join)(worktreePath, PLAN_FILE_REL);
31248
+ return (0, import_node_path72.join)(worktreePath, PLAN_FILE_REL);
31140
31249
  }
31141
31250
  function readTextIfPresent2(abs) {
31142
- if (!(0, import_node_fs71.existsSync)(abs)) return null;
31251
+ if (!(0, import_node_fs72.existsSync)(abs)) return null;
31143
31252
  try {
31144
- const content = (0, import_node_fs71.readFileSync)(abs, "utf8");
31253
+ const content = (0, import_node_fs72.readFileSync)(abs, "utf8");
31145
31254
  return content.trim() ? content : null;
31146
31255
  } catch {
31147
31256
  return null;
31148
31257
  }
31149
31258
  }
31150
31259
  function readPlanFile(worktreePath) {
31151
- return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path71.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path71.join)(worktreePath, LEGACY_PLAN_FILE_REL));
31260
+ return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path72.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path72.join)(worktreePath, LEGACY_PLAN_FILE_REL));
31152
31261
  }
31153
31262
  function writePlanFile(worktreePath, content) {
31154
31263
  ensureAttachmentsGitignore(worktreePath);
31155
31264
  const abs = planFileAbs(worktreePath);
31156
- (0, import_node_fs71.mkdirSync)((0, import_node_path71.dirname)(abs), { recursive: true });
31265
+ (0, import_node_fs72.mkdirSync)((0, import_node_path72.dirname)(abs), { recursive: true });
31157
31266
  const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
31158
- (0, import_node_fs71.writeFileSync)(abs, body, "utf8");
31267
+ (0, import_node_fs72.writeFileSync)(abs, body, "utf8");
31159
31268
  return PLAN_FILE_REL;
31160
31269
  }
31161
- var import_node_fs71, import_node_path71;
31270
+ var import_node_fs72, import_node_path72;
31162
31271
  var init_plan_file = __esm({
31163
31272
  "src/plan/plan-file.ts"() {
31164
31273
  "use strict";
31165
- import_node_fs71 = require("fs");
31166
- import_node_path71 = require("path");
31274
+ import_node_fs72 = require("fs");
31275
+ import_node_path72 = require("path");
31167
31276
  init_workspace_scratch();
31168
31277
  init_plan_present();
31169
31278
  init_plan_present();
@@ -31212,7 +31321,7 @@ function setCaffeinateHoldHooks(next) {
31212
31321
  hooks = next;
31213
31322
  }
31214
31323
  function caffeinateHoldPath() {
31215
- return (0, import_node_path72.join)(appDataDir(), "caffeinate-hold.json");
31324
+ return (0, import_node_path73.join)(appDataDir(), "caffeinate-hold.json");
31216
31325
  }
31217
31326
  function processAlive(pid) {
31218
31327
  if (hooks.processAlive) return hooks.processAlive(pid);
@@ -31246,9 +31355,9 @@ function uniqueIds(ids) {
31246
31355
  }
31247
31356
  function readHold() {
31248
31357
  const path = caffeinateHoldPath();
31249
- if (!(0, import_node_fs72.existsSync)(path)) return null;
31358
+ if (!(0, import_node_fs73.existsSync)(path)) return null;
31250
31359
  try {
31251
- const parsed = JSON.parse((0, import_node_fs72.readFileSync)(path, "utf8"));
31360
+ const parsed = JSON.parse((0, import_node_fs73.readFileSync)(path, "utf8"));
31252
31361
  if (typeof parsed?.pid === "number" && parsed.pid > 0) {
31253
31362
  return {
31254
31363
  pid: parsed.pid,
@@ -31270,7 +31379,7 @@ function writeHold(pid, threadIds) {
31270
31379
  }
31271
31380
  function clearHold() {
31272
31381
  try {
31273
- (0, import_node_fs72.unlinkSync)(caffeinateHoldPath());
31382
+ (0, import_node_fs73.unlinkSync)(caffeinateHoldPath());
31274
31383
  } catch {
31275
31384
  }
31276
31385
  }
@@ -31355,13 +31464,13 @@ function releaseCaffeinateHoldForThread(threadId) {
31355
31464
  }
31356
31465
  return setCaffeinateHold(false, { threadId: id });
31357
31466
  }
31358
- var import_node_child_process8, import_node_fs72, import_node_path72, hooks;
31467
+ var import_node_child_process8, import_node_fs73, import_node_path73, hooks;
31359
31468
  var init_caffeinate_hold = __esm({
31360
31469
  "src/store/caffeinate-hold.ts"() {
31361
31470
  "use strict";
31362
31471
  import_node_child_process8 = require("child_process");
31363
- import_node_fs72 = require("fs");
31364
- import_node_path72 = require("path");
31472
+ import_node_fs73 = require("fs");
31473
+ import_node_path73 = require("path");
31365
31474
  init_paths();
31366
31475
  init_private_file();
31367
31476
  hooks = {};
@@ -31639,13 +31748,13 @@ var init_github_edge = __esm({
31639
31748
 
31640
31749
  // src/orchestrator/github-edge-watch.ts
31641
31750
  function githubEdgeSnapshotPath() {
31642
- return (0, import_node_path73.join)(appDataDir(), "github-edge-watch.json");
31751
+ return (0, import_node_path74.join)(appDataDir(), "github-edge-watch.json");
31643
31752
  }
31644
31753
  function loadGithubEdgeSnapshot() {
31645
31754
  try {
31646
31755
  const path = githubEdgeSnapshotPath();
31647
- if (!(0, import_node_fs73.existsSync)(path)) return emptyGithubEdgeSnapshot();
31648
- return coerceGithubEdgeSnapshot(JSON.parse((0, import_node_fs73.readFileSync)(path, "utf8")));
31756
+ if (!(0, import_node_fs74.existsSync)(path)) return emptyGithubEdgeSnapshot();
31757
+ return coerceGithubEdgeSnapshot(JSON.parse((0, import_node_fs74.readFileSync)(path, "utf8")));
31649
31758
  } catch {
31650
31759
  return emptyGithubEdgeSnapshot();
31651
31760
  }
@@ -31960,12 +32069,12 @@ function realDeps() {
31960
32069
  now: () => Date.now()
31961
32070
  };
31962
32071
  }
31963
- var import_node_fs73, import_node_path73, timer, polling, needsBaseline;
32072
+ var import_node_fs74, import_node_path74, timer, polling, needsBaseline;
31964
32073
  var init_github_edge_watch = __esm({
31965
32074
  "src/orchestrator/github-edge-watch.ts"() {
31966
32075
  "use strict";
31967
- import_node_fs73 = require("fs");
31968
- import_node_path73 = require("path");
32076
+ import_node_fs74 = require("fs");
32077
+ import_node_path74 = require("path");
31969
32078
  init_pr_gates();
31970
32079
  init_pr_merge_archive();
31971
32080
  init_worktree();
@@ -32248,9 +32357,9 @@ function recoverFinishedCursorRun(opts) {
32248
32357
  return best;
32249
32358
  }
32250
32359
  function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
32251
- if (!(0, import_node_fs74.existsSync)(runsPath)) return null;
32360
+ if (!(0, import_node_fs75.existsSync)(runsPath)) return null;
32252
32361
  try {
32253
- const lines = (0, import_node_fs74.readFileSync)(runsPath, "utf8").split("\n");
32362
+ const lines = (0, import_node_fs75.readFileSync)(runsPath, "utf8").split("\n");
32254
32363
  let best = null;
32255
32364
  for (const line of lines) {
32256
32365
  const trimmed = line.trim();
@@ -32276,11 +32385,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
32276
32385
  return null;
32277
32386
  }
32278
32387
  }
32279
- var import_node_fs74;
32388
+ var import_node_fs75;
32280
32389
  var init_cursor_recover = __esm({
32281
32390
  "src/agents/cursor-recover.ts"() {
32282
32391
  "use strict";
32283
- import_node_fs74 = require("fs");
32392
+ import_node_fs75 = require("fs");
32284
32393
  init_cursor_store();
32285
32394
  }
32286
32395
  });
@@ -32384,7 +32493,7 @@ async function startOrchestration(opts) {
32384
32493
  }
32385
32494
  return ready;
32386
32495
  }
32387
- var import_node_events, import_node_crypto21, import_node_fs75, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton2;
32496
+ var import_node_events, import_node_crypto21, import_node_fs76, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton2;
32388
32497
  var init_orchestrator = __esm({
32389
32498
  "src/orchestrator/orchestrator.ts"() {
32390
32499
  "use strict";
@@ -32393,7 +32502,7 @@ var init_orchestrator = __esm({
32393
32502
  init_task_state();
32394
32503
  init_wait_for_turn();
32395
32504
  import_node_crypto21 = require("crypto");
32396
- import_node_fs75 = require("fs");
32505
+ import_node_fs76 = require("fs");
32397
32506
  init_error_detail();
32398
32507
  init_run();
32399
32508
  init_stale_lock();
@@ -32405,6 +32514,7 @@ var init_orchestrator = __esm({
32405
32514
  init_worktree_leftovers();
32406
32515
  init_stack();
32407
32516
  init_agent_git_actions();
32517
+ init_announce_skill();
32408
32518
  init_pr_merge_archive();
32409
32519
  init_pr_gates();
32410
32520
  init_conductor();
@@ -32597,7 +32707,7 @@ var init_orchestrator = __esm({
32597
32707
  this.lightReconcileAt.set(repoPath, Date.now());
32598
32708
  for (const thread of listThreads()) {
32599
32709
  if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
32600
- if (!(0, import_node_fs75.existsSync)(thread.worktreePath)) {
32710
+ if (!(0, import_node_fs76.existsSync)(thread.worktreePath)) {
32601
32711
  setStatus(thread.id, "broken", "Worktree missing on disk");
32602
32712
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
32603
32713
  }
@@ -32626,7 +32736,7 @@ var init_orchestrator = __esm({
32626
32736
  }
32627
32737
  continue;
32628
32738
  }
32629
- if (!(0, import_node_fs75.existsSync)(thread.worktreePath)) {
32739
+ if (!(0, import_node_fs76.existsSync)(thread.worktreePath)) {
32630
32740
  setStatus(thread.id, "broken", "Worktree missing on disk");
32631
32741
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
32632
32742
  continue;
@@ -33356,7 +33466,8 @@ var init_orchestrator = __esm({
33356
33466
  const turnOrigin = thread.worktreePath?.trim() ? await resolveOriginRemote(thread.worktreePath).catch(() => null) : null;
33357
33467
  const gitPrompt = expandCanonicalGitRequest(promptText, {
33358
33468
  forge: turnOrigin?.forge,
33359
- worktreePath: thread.worktreePath
33469
+ worktreePath: thread.worktreePath,
33470
+ hasAnnounceSkill: announceSkillPresent(thread.worktreePath)
33360
33471
  });
33361
33472
  const expandedAttachments = openSteerTurnAttachments(this.openSteerPrompt.get(threadId), turnAttachments, autoContinue);
33362
33473
  const { agentPrompt: expandedPrompt } = expandComposerPrompt(
@@ -35115,7 +35226,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
35115
35226
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
35116
35227
  return restored2;
35117
35228
  }
35118
- if (!(0, import_node_fs75.existsSync)(thread.worktreePath)) {
35229
+ if (!(0, import_node_fs76.existsSync)(thread.worktreePath)) {
35119
35230
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
35120
35231
  throw new Error(
35121
35232
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
@@ -35307,7 +35418,7 @@ function createClippedMcpServer() {
35307
35418
  // src/mcp/server.ts
35308
35419
  var import_zod14 = require("zod");
35309
35420
  var import_node_crypto26 = require("crypto");
35310
- var import_node_path78 = require("path");
35421
+ var import_node_path79 = require("path");
35311
35422
  init_orchestrator();
35312
35423
  init_task_state();
35313
35424
  init_worktree();
@@ -37980,8 +38091,8 @@ var import_zod13 = require("zod");
37980
38091
 
37981
38092
  // src/order/order.ts
37982
38093
  var import_node_crypto23 = require("crypto");
37983
- var import_node_fs76 = require("fs");
37984
- var import_node_path74 = require("path");
38094
+ var import_node_fs77 = require("fs");
38095
+ var import_node_path75 = require("path");
37985
38096
  init_paths();
37986
38097
  init_private_file();
37987
38098
  init_thread_store();
@@ -38690,7 +38801,7 @@ function showPlanMessage(docs, worktree) {
38690
38801
 
38691
38802
  // src/order/order.ts
38692
38803
  function orderPath() {
38693
- return (0, import_node_path74.join)(appDataDir(), "order.json");
38804
+ return (0, import_node_path75.join)(appDataDir(), "order.json");
38694
38805
  }
38695
38806
  function emptyFile() {
38696
38807
  return { plans: [], edges: [], marks: [] };
@@ -38753,9 +38864,9 @@ function asMark(value) {
38753
38864
  }
38754
38865
  function readFile() {
38755
38866
  const path = orderPath();
38756
- if (!(0, import_node_fs76.existsSync)(path)) return emptyFile();
38867
+ if (!(0, import_node_fs77.existsSync)(path)) return emptyFile();
38757
38868
  try {
38758
- const parsed = JSON.parse((0, import_node_fs76.readFileSync)(path, "utf8"));
38869
+ const parsed = JSON.parse((0, import_node_fs77.readFileSync)(path, "utf8"));
38759
38870
  if (!parsed || typeof parsed !== "object") return emptyFile();
38760
38871
  const raw = parsed;
38761
38872
  const edges = Array.isArray(raw.edges) ? raw.edges.map(asEdge).filter((row) => Boolean(row)) : [];
@@ -39251,7 +39362,7 @@ function registerOrderTools(server) {
39251
39362
 
39252
39363
  // src/agent-rpc/handlers.ts
39253
39364
  var import_node_crypto24 = require("crypto");
39254
- var import_node_path75 = require("path");
39365
+ var import_node_path76 = require("path");
39255
39366
  init_wait_for_job();
39256
39367
  init_wait_for_turn();
39257
39368
  init_computer_use();
@@ -39318,27 +39429,27 @@ init_gh_errors();
39318
39429
  init_git_auth_mode();
39319
39430
 
39320
39431
  // src/board/load-home-board.ts
39321
- var import_node_fs78 = require("fs");
39322
- var import_node_path77 = require("path");
39432
+ var import_node_fs79 = require("fs");
39433
+ var import_node_path78 = require("path");
39323
39434
  init_worktree();
39324
39435
  init_paths();
39325
39436
 
39326
39437
  // src/board/board-pins.ts
39327
39438
  var import_node_crypto25 = require("crypto");
39328
- var import_node_fs77 = require("fs");
39329
- var import_node_path76 = require("path");
39439
+ var import_node_fs78 = require("fs");
39440
+ var import_node_path77 = require("path");
39330
39441
  init_paths();
39331
39442
  init_home_board();
39332
39443
  var FILE = "home-board-pins.json";
39333
39444
  var VERSION = 1;
39334
39445
  function pinsFile() {
39335
- return (0, import_node_path76.join)(appDataDir(), FILE);
39446
+ return (0, import_node_path77.join)(appDataDir(), FILE);
39336
39447
  }
39337
39448
  function readDisk() {
39338
39449
  const path = pinsFile();
39339
- if (!(0, import_node_fs77.existsSync)(path)) return [];
39450
+ if (!(0, import_node_fs78.existsSync)(path)) return [];
39340
39451
  try {
39341
- const raw = JSON.parse((0, import_node_fs77.readFileSync)(path, "utf8"));
39452
+ const raw = JSON.parse((0, import_node_fs78.readFileSync)(path, "utf8"));
39342
39453
  if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
39343
39454
  return raw.items.filter((item) => item?.id && item.kind && item.ref);
39344
39455
  } catch {
@@ -39346,8 +39457,8 @@ function readDisk() {
39346
39457
  }
39347
39458
  }
39348
39459
  function writeDisk(items) {
39349
- (0, import_node_fs77.mkdirSync)(appDataDir(), { recursive: true });
39350
- (0, import_node_fs77.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
39460
+ (0, import_node_fs78.mkdirSync)(appDataDir(), { recursive: true });
39461
+ (0, import_node_fs78.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
39351
39462
  }
39352
39463
  function listBoardPins() {
39353
39464
  return readDisk();
@@ -39368,7 +39479,7 @@ function homeBoardWorkspaceKey(workspaces) {
39368
39479
  return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
39369
39480
  }
39370
39481
  function cacheFile() {
39371
- return (0, import_node_path77.join)(appDataDir(), "home-board-cache.json");
39482
+ return (0, import_node_path78.join)(appDataDir(), "home-board-cache.json");
39372
39483
  }
39373
39484
  function emptyInputs() {
39374
39485
  return {
@@ -39394,9 +39505,9 @@ function shouldCacheHomeBoardInputs(inputs) {
39394
39505
  }
39395
39506
  function readDiskCache() {
39396
39507
  const path = cacheFile();
39397
- if (!(0, import_node_fs78.existsSync)(path)) return null;
39508
+ if (!(0, import_node_fs79.existsSync)(path)) return null;
39398
39509
  try {
39399
- const raw = JSON.parse((0, import_node_fs78.readFileSync)(path, "utf8"));
39510
+ const raw = JSON.parse((0, import_node_fs79.readFileSync)(path, "utf8"));
39400
39511
  if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
39401
39512
  return null;
39402
39513
  }
@@ -39410,8 +39521,8 @@ function readDiskCache() {
39410
39521
  }
39411
39522
  function writeDiskCache(entry) {
39412
39523
  try {
39413
- (0, import_node_fs78.mkdirSync)(appDataDir(), { recursive: true });
39414
- (0, import_node_fs78.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
39524
+ (0, import_node_fs79.mkdirSync)(appDataDir(), { recursive: true });
39525
+ (0, import_node_fs79.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
39415
39526
  } catch {
39416
39527
  }
39417
39528
  }
@@ -39666,7 +39777,7 @@ async function startMcpServer() {
39666
39777
  async () => {
39667
39778
  const threads = orch.getThreads();
39668
39779
  const lines = threads.map((t) => {
39669
- const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path78.basename)(t.repoPath) || t.repoPath;
39780
+ const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path79.basename)(t.repoPath) || t.repoPath;
39670
39781
  const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
39671
39782
  const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
39672
39783
  const preview = lastMessagePreview(t.messages, 80);