@sideboard-ai/core 0.1.232 → 0.1.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/agents/cursor-runner.cjs +167 -62
  2. package/dist/agents/cursor-runner.js +16 -9
  3. package/dist/{agents-ENAQHQRZ.js → agents-J2CUJHPC.js} +16 -6
  4. package/dist/{agents-TCTEAK6M.js → agents-LDYMFW6N.js} +17 -7
  5. package/dist/{chunk-TQBUXKIB.js → chunk-26T43LBM.js} +97 -11
  6. package/dist/{chunk-PO4M4JAJ.js → chunk-2P4XKWV2.js} +1 -1
  7. package/dist/{chunk-ABOBTSO6.js → chunk-2UG25RMK.js} +18 -5
  8. package/dist/{chunk-4CZ25DO2.js → chunk-4VFOJZPS.js} +2 -2
  9. package/dist/{chunk-N5TX66CD.js → chunk-7H2CVVLF.js} +2 -2
  10. package/dist/{chunk-LLMG6OVS.js → chunk-BGHDWCAV.js} +19 -19
  11. package/dist/{chunk-SZJZEFTY.js → chunk-DD67JWTN.js} +1 -1
  12. package/dist/{chunk-7BZ7DSBN.js → chunk-NLETJP7Z.js} +17 -17
  13. package/dist/{chunk-FA4CPYCY.js → chunk-PZQNE5X4.js} +81 -41
  14. package/dist/{chunk-HVUVQXZ2.js → chunk-QVN2WOKJ.js} +18 -5
  15. package/dist/{chunk-HZFLKVGC.js → chunk-S2OEFXST.js} +1 -1
  16. package/dist/{chunk-SXFRXNBM.js → chunk-SPAMHHJH.js} +1 -1
  17. package/dist/{chunk-ZXJMAKEP.js → chunk-TNVJPFHM.js} +5 -5
  18. package/dist/{chunk-UNTOZA3C.js → chunk-TWXSZYR2.js} +1 -1
  19. package/dist/{chunk-6L25K7BE.js → chunk-TXMFBL3X.js} +195 -73
  20. package/dist/{connected-teams-PIBQTOJU.js → connected-teams-JUJAQZZE.js} +2 -2
  21. package/dist/{connected-teams-RVD3PFAG.js → connected-teams-KQUDU7LZ.js} +2 -2
  22. package/dist/{coordinator-prompt-YKLXQTWH.js → coordinator-prompt-CE7MN6QY.js} +4 -4
  23. package/dist/{coordinator-prompt-DFXYTM6D.js → coordinator-prompt-IGDMFKCD.js} +4 -4
  24. package/dist/{global-workspace-EYZKYHAO.js → global-workspace-7WH24UFO.js} +4 -4
  25. package/dist/{global-workspace-4SPANNJT.js → global-workspace-NCIC2Y2U.js} +4 -4
  26. package/dist/index.cjs +490 -326
  27. package/dist/index.d.cts +19 -3
  28. package/dist/index.d.ts +19 -3
  29. package/dist/index.js +27 -8
  30. package/dist/mcp/run-stdio.cjs +418 -302
  31. package/dist/mcp/run-stdio.js +7 -7
  32. package/dist/{orchestrator-FTHJKPIX.js → orchestrator-BXALNM4M.js} +8 -8
  33. package/dist/{orchestrator-RJX4OKYC.js → orchestrator-NLZMHTLX.js} +7 -7
  34. package/dist/{run-UEQM4JMZ.js → run-PCX5QWR4.js} +1 -1
  35. package/dist/{run-QDZCTP4Y.js → run-TB7RBII2.js} +1 -1
  36. package/dist/{workspaces-73Y7IJY2.js → workspaces-H2TRFDE2.js} +4 -4
  37. package/dist/{workspaces-FQCSCTNH.js → workspaces-NSQZSDQD.js} +4 -4
  38. package/dist/{worktree-DOPRKG7K.js → worktree-FMIX4BRV.js} +3 -3
  39. package/dist/{worktree-36VEFUJN.js → worktree-W7BSI4GU.js} +3 -3
  40. package/dist/{worktree-exclude-K7QK4RI5.js → worktree-exclude-5N2KTYIT.js} +2 -2
  41. package/dist/{worktree-exclude-L32WEBX6.js → worktree-exclude-RXZPTCNH.js} +2 -2
  42. package/package.json +2 -2
@@ -2034,6 +2034,14 @@ function ensureAgentPath(env = process.env) {
2034
2034
  }
2035
2035
  function enrichPathWithNpmGlobalBin(env = process.env) {
2036
2036
  ensureAgentPath(env);
2037
+ const prefix = npmGlobalPrefix(env);
2038
+ if (prefix) {
2039
+ const binDir = process.platform === "win32" ? prefix : (0, import_node_path13.join)(prefix, "bin");
2040
+ prependPathDir(env, binDir);
2041
+ }
2042
+ return env.PATH ?? "";
2043
+ }
2044
+ function npmGlobalPrefix(env = process.env) {
2037
2045
  try {
2038
2046
  const prefix = (0, import_node_child_process3.execFileSync)("npm", ["prefix", "-g"], {
2039
2047
  encoding: "utf8",
@@ -2041,13 +2049,16 @@ function enrichPathWithNpmGlobalBin(env = process.env) {
2041
2049
  timeout: 8e3,
2042
2050
  stdio: ["ignore", "pipe", "ignore"]
2043
2051
  }).trim().split(/\r?\n/).find(Boolean);
2044
- if (prefix) {
2045
- const binDir = process.platform === "win32" ? prefix : (0, import_node_path13.join)(prefix, "bin");
2046
- prependPathDir(env, binDir);
2047
- }
2052
+ return prefix || null;
2048
2053
  } catch {
2054
+ return null;
2049
2055
  }
2050
- return env.PATH ?? "";
2056
+ }
2057
+ function npmGlobalNodeModules(env = process.env) {
2058
+ const prefix = npmGlobalPrefix(env);
2059
+ if (!prefix) return null;
2060
+ const dir = process.platform === "win32" ? (0, import_node_path13.join)(prefix, "node_modules") : (0, import_node_path13.join)(prefix, "lib", "node_modules");
2061
+ return (0, import_node_fs11.existsSync)(dir) ? dir : null;
2051
2062
  }
2052
2063
  var import_node_fs11, import_node_child_process3, import_node_os3, import_node_path13, EXTRA_BIN_DIRS;
2053
2064
  var init_path = __esm({
@@ -12005,6 +12016,95 @@ var init_codex = __esm({
12005
12016
  }
12006
12017
  });
12007
12018
 
12019
+ // src/agents/cursor-sdk-resolve.ts
12020
+ function thisModuleFile() {
12021
+ const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
12022
+ if (cjsDir) return (0, import_node_path33.join)(cjsDir, "cursor-sdk-resolve.js");
12023
+ try {
12024
+ return (0, import_node_url2.fileURLToPath)(import_meta2.url);
12025
+ } catch {
12026
+ return (0, import_node_path33.join)(process.cwd(), "package.json");
12027
+ }
12028
+ }
12029
+ function packageRootLooksLikeSdk(dir) {
12030
+ try {
12031
+ const raw = (0, import_node_fs31.readFileSync)((0, import_node_path33.join)(dir, "package.json"), "utf8");
12032
+ const pkg = JSON.parse(raw);
12033
+ return pkg.name === "@cursor/sdk" && (0, import_node_fs31.existsSync)(dir);
12034
+ } catch {
12035
+ return false;
12036
+ }
12037
+ }
12038
+ function resolvedPackageRoot(fromFile) {
12039
+ try {
12040
+ const req = (0, import_node_module2.createRequire)(fromFile);
12041
+ const pkgJson = req.resolve("@cursor/sdk/package.json");
12042
+ const root = (0, import_node_path33.dirname)(pkgJson);
12043
+ return packageRootLooksLikeSdk(root) ? root : null;
12044
+ } catch {
12045
+ return null;
12046
+ }
12047
+ }
12048
+ function resolveCursorSdkRoot(opts) {
12049
+ const env = opts?.env ?? process.env;
12050
+ const override = env.SIDEBOARD_CURSOR_SDK?.trim();
12051
+ if (override) {
12052
+ return packageRootLooksLikeSdk(override) ? override : null;
12053
+ }
12054
+ const globalNm = npmGlobalNodeModules(env);
12055
+ if (globalNm) {
12056
+ const globalRoot = (0, import_node_path33.join)(globalNm, "@cursor/sdk");
12057
+ if (packageRootLooksLikeSdk(globalRoot)) return globalRoot;
12058
+ }
12059
+ const cwdPkg = (0, import_node_path33.join)(process.cwd(), "package.json");
12060
+ return resolvedPackageRoot(thisModuleFile()) ?? resolvedPackageRoot(cwdPkg);
12061
+ }
12062
+ function isCursorSdkInstalled(opts) {
12063
+ return Boolean(resolveCursorSdkRoot(opts));
12064
+ }
12065
+ async function importCursorSdk(opts) {
12066
+ const root = resolveCursorSdkRoot(opts);
12067
+ if (!root) return null;
12068
+ try {
12069
+ const req = (0, import_node_module2.createRequire)((0, import_node_path33.join)(root, "package.json"));
12070
+ const entry = req.resolve("@cursor/sdk");
12071
+ return await import((0, import_node_url2.pathToFileURL)(entry).href);
12072
+ } catch {
12073
+ return null;
12074
+ }
12075
+ }
12076
+ function cursorSdkPlatformRipgrepPackage() {
12077
+ return `@cursor/sdk-${process.platform}-${process.arch}`;
12078
+ }
12079
+ function nodeModulesDirForPackageRoot(packageRoot) {
12080
+ const parent = (0, import_node_path33.dirname)(packageRoot);
12081
+ return (0, import_node_path33.basename)(parent).startsWith("@") ? (0, import_node_path33.dirname)(parent) : parent;
12082
+ }
12083
+ function cursorSdkRipgrepCandidate(opts) {
12084
+ const root = resolveCursorSdkRoot(opts);
12085
+ if (!root) return null;
12086
+ const nm = nodeModulesDirForPackageRoot(root);
12087
+ const pkg = cursorSdkPlatformRipgrepPackage();
12088
+ const bin = process.platform === "win32" ? "rg.exe" : "rg";
12089
+ const sibling = (0, import_node_path33.join)(nm, pkg, "bin", bin);
12090
+ if ((0, import_node_fs31.existsSync)(sibling)) return sibling;
12091
+ const nested = (0, import_node_path33.join)(root, "node_modules", pkg, "bin", bin);
12092
+ return (0, import_node_fs31.existsSync)(nested) ? nested : null;
12093
+ }
12094
+ var import_node_fs31, import_node_module2, import_node_path33, import_node_url2, import_meta2, CURSOR_SDK_INSTALL_HINT;
12095
+ var init_cursor_sdk_resolve = __esm({
12096
+ "src/agents/cursor-sdk-resolve.ts"() {
12097
+ "use strict";
12098
+ import_node_fs31 = require("fs");
12099
+ import_node_module2 = require("module");
12100
+ import_node_path33 = require("path");
12101
+ import_node_url2 = require("url");
12102
+ init_path();
12103
+ import_meta2 = {};
12104
+ CURSOR_SDK_INSTALL_HINT = "Cursor SDK is not installed. Settings \u2192 Agents \u2192 Cursor \u2192 Install (`npm i -g @cursor/sdk`). Sideboard does not ship the SDK \u2014 update it anytime without a new Sideboard build.";
12105
+ }
12106
+ });
12107
+
12008
12108
  // src/agents/cursor-events.ts
12009
12109
  function parseCursorRunnerLine(line) {
12010
12110
  const trimmed = line.trim();
@@ -12039,21 +12139,21 @@ function platformRipgrepPackage() {
12039
12139
  }
12040
12140
  function usableRipgrepPath(candidate) {
12041
12141
  const raw = candidate?.trim();
12042
- if (!raw || !(0, import_node_path33.isAbsolute)(raw)) return null;
12142
+ if (!raw || !(0, import_node_path34.isAbsolute)(raw)) return null;
12043
12143
  const readable = nodeReadableScriptPath(raw);
12044
- if (!(0, import_node_fs31.existsSync)(readable) || isAsarPath(readable)) return null;
12144
+ if (!(0, import_node_fs32.existsSync)(readable) || isAsarPath(readable)) return null;
12045
12145
  return readable;
12046
12146
  }
12047
12147
  function walkForBundledRipgrep(startFile) {
12048
12148
  if (!startFile) return null;
12049
12149
  const pkg = platformRipgrepPackage();
12050
12150
  const name = rgBinaryName();
12051
- let dir = (0, import_node_path33.dirname)((0, import_node_path33.resolve)(startFile));
12052
- const root = (0, import_node_path33.parse)(dir).root;
12151
+ let dir = (0, import_node_path34.dirname)((0, import_node_path34.resolve)(startFile));
12152
+ const root = (0, import_node_path34.parse)(dir).root;
12053
12153
  while (dir !== root) {
12054
- const hit = usableRipgrepPath((0, import_node_path33.join)(dir, "node_modules", pkg, "bin", name));
12154
+ const hit = usableRipgrepPath((0, import_node_path34.join)(dir, "node_modules", pkg, "bin", name));
12055
12155
  if (hit) return hit;
12056
- const next = (0, import_node_path33.dirname)(dir);
12156
+ const next = (0, import_node_path34.dirname)(dir);
12057
12157
  if (next === dir) break;
12058
12158
  dir = next;
12059
12159
  }
@@ -12061,9 +12161,9 @@ function walkForBundledRipgrep(startFile) {
12061
12161
  }
12062
12162
  function requireResolveBundledRipgrep(fromFile) {
12063
12163
  try {
12064
- const req = (0, import_node_module2.createRequire)(fromFile);
12164
+ const req = (0, import_node_module3.createRequire)(fromFile);
12065
12165
  const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
12066
- return usableRipgrepPath((0, import_node_path33.join)((0, import_node_path33.dirname)(pkgJson), "bin", rgBinaryName()));
12166
+ return usableRipgrepPath((0, import_node_path34.join)((0, import_node_path34.dirname)(pkgJson), "bin", rgBinaryName()));
12067
12167
  } catch {
12068
12168
  return null;
12069
12169
  }
@@ -12079,19 +12179,20 @@ function resolveCursorRipgrepPath(opts) {
12079
12179
  const start = opts?.startFile?.trim() || process.argv[1] || // CJS bundle only — ESM has no __filename; argv[1] is the running script.
12080
12180
  // eslint-disable-next-line camelcase
12081
12181
  (typeof __filename !== "undefined" ? __filename : "");
12082
- return walkForBundledRipgrep(start) ?? requireResolveBundledRipgrep(start);
12182
+ return walkForBundledRipgrep(start) ?? usableRipgrepPath(cursorSdkRipgrepCandidate({ env })) ?? requireResolveBundledRipgrep(start);
12083
12183
  }
12084
12184
  function cursorRipgrepEnv(opts) {
12085
12185
  const path = resolveCursorRipgrepPath(opts);
12086
12186
  return path ? { [RIPGREP_ENV]: path } : {};
12087
12187
  }
12088
- var import_node_fs31, import_node_module2, import_node_path33, RIPGREP_ENV;
12188
+ var import_node_fs32, import_node_module3, import_node_path34, RIPGREP_ENV;
12089
12189
  var init_cursor_ripgrep = __esm({
12090
12190
  "src/agents/cursor-ripgrep.ts"() {
12091
12191
  "use strict";
12092
- import_node_fs31 = require("fs");
12093
- import_node_module2 = require("module");
12094
- import_node_path33 = require("path");
12192
+ import_node_fs32 = require("fs");
12193
+ import_node_module3 = require("module");
12194
+ import_node_path34 = require("path");
12195
+ init_cursor_sdk_resolve();
12095
12196
  init_node_launch();
12096
12197
  init_packaged_runtime();
12097
12198
  RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
@@ -12114,8 +12215,10 @@ async function listCursorModels() {
12114
12215
  }
12115
12216
  const apiKey = resolveCursorApiKey();
12116
12217
  if (!apiKey) return FALLBACK_CURSOR_MODELS;
12218
+ const sdk = await importCursorSdk();
12219
+ if (!sdk) return FALLBACK_CURSOR_MODELS;
12117
12220
  try {
12118
- const listed = await import_sdk.Cursor.models.list({ apiKey });
12221
+ const listed = await sdk.Cursor.models.list({ apiKey });
12119
12222
  const models = listed.map((m) => ({
12120
12223
  id: m.id,
12121
12224
  displayName: m.displayName || m.id,
@@ -12132,11 +12235,11 @@ function entryDir() {
12132
12235
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
12133
12236
  if (cjsDir) return cjsDir;
12134
12237
  try {
12135
- return (0, import_node_path34.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
12238
+ return (0, import_node_path35.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
12136
12239
  } catch {
12137
12240
  try {
12138
- const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
12139
- return (0, import_node_path34.dirname)(req.resolve("@sideboard-ai/core"));
12241
+ const req = (0, import_node_module4.createRequire)(process.cwd() + "/");
12242
+ return (0, import_node_path35.dirname)(req.resolve("@sideboard-ai/core"));
12140
12243
  } catch {
12141
12244
  return process.cwd();
12142
12245
  }
@@ -12147,32 +12250,32 @@ function cursorRunnerPath() {
12147
12250
  if (packaged) return packaged;
12148
12251
  const root = entryDir();
12149
12252
  const candidates = [
12150
- (0, import_node_path34.join)(root, "agents", "cursor-runner.js"),
12151
- (0, import_node_path34.join)(root, "agents", "cursor-runner.cjs"),
12253
+ (0, import_node_path35.join)(root, "agents", "cursor-runner.js"),
12254
+ (0, import_node_path35.join)(root, "agents", "cursor-runner.cjs"),
12152
12255
  // If somehow resolved from package root instead of dist/
12153
- (0, import_node_path34.join)(root, "dist", "agents", "cursor-runner.js"),
12154
- (0, import_node_path34.join)(root, "dist", "agents", "cursor-runner.cjs"),
12256
+ (0, import_node_path35.join)(root, "dist", "agents", "cursor-runner.js"),
12257
+ (0, import_node_path35.join)(root, "dist", "agents", "cursor-runner.cjs"),
12155
12258
  // Source tree (dev): packages/core/src/agents/cursor-runner.ts
12156
- (0, import_node_path34.join)(root, "cursor-runner.ts"),
12157
- (0, import_node_path34.join)(root, "src", "agents", "cursor-runner.ts")
12259
+ (0, import_node_path35.join)(root, "cursor-runner.ts"),
12260
+ (0, import_node_path35.join)(root, "src", "agents", "cursor-runner.ts")
12158
12261
  ];
12159
12262
  for (const candidate of candidates) {
12160
- if ((0, import_node_fs32.existsSync)(candidate)) return candidate;
12263
+ if ((0, import_node_fs33.existsSync)(candidate)) return candidate;
12161
12264
  }
12162
12265
  return candidates[0];
12163
12266
  }
12164
- var import_node_fs32, import_node_module3, import_node_path34, import_node_url2, import_sdk, import_meta2, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
12267
+ var import_node_fs33, import_node_module4, import_node_path35, import_node_url3, import_meta3, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
12165
12268
  var init_cursor = __esm({
12166
12269
  "src/agents/cursor.ts"() {
12167
12270
  "use strict";
12168
- import_node_fs32 = require("fs");
12169
- import_node_module3 = require("module");
12170
- import_node_path34 = require("path");
12171
- import_node_url2 = require("url");
12172
- import_sdk = require("@cursor/sdk");
12271
+ import_node_fs33 = require("fs");
12272
+ import_node_module4 = require("module");
12273
+ import_node_path35 = require("path");
12274
+ import_node_url3 = require("url");
12173
12275
  init_run();
12174
12276
  init_app_settings();
12175
12277
  init_global_workspace();
12278
+ init_cursor_sdk_resolve();
12176
12279
  init_cursor_events();
12177
12280
  init_injected_mcp();
12178
12281
  init_cursor_ripgrep();
@@ -12180,7 +12283,7 @@ var init_cursor = __esm({
12180
12283
  init_packaged_runtime();
12181
12284
  init_turn_input();
12182
12285
  init_cursor_events();
12183
- import_meta2 = {};
12286
+ import_meta3 = {};
12184
12287
  FALLBACK_CURSOR_MODELS = [
12185
12288
  { id: "default", displayName: "Auto" },
12186
12289
  { id: "composer-2.5", displayName: "Composer 2.5" },
@@ -12191,6 +12294,16 @@ var init_cursor = __esm({
12191
12294
  cursorAdapter = {
12192
12295
  kind: "cursor",
12193
12296
  async detect() {
12297
+ if (!isCursorSdkInstalled()) {
12298
+ return {
12299
+ agent: "cursor",
12300
+ installed: false,
12301
+ authenticated: false,
12302
+ linearMcp: false,
12303
+ warnings: [],
12304
+ reason: CURSOR_SDK_INSTALL_HINT
12305
+ };
12306
+ }
12194
12307
  const apiKey = resolveCursorApiKey();
12195
12308
  if (!apiKey) {
12196
12309
  return {
@@ -12319,7 +12432,7 @@ async function listOpencodeModels() {
12319
12432
  if (opencode === "opencode") {
12320
12433
  const which = await run("which", ["opencode"], { reject: false });
12321
12434
  if (which.exitCode !== 0) return FALLBACK_OPENCODE_MODELS;
12322
- } else if (!(0, import_node_fs33.existsSync)(opencode)) {
12435
+ } else if (!(0, import_node_fs34.existsSync)(opencode)) {
12323
12436
  return FALLBACK_OPENCODE_MODELS;
12324
12437
  }
12325
12438
  const listed = await run(opencode, ["models"], { reject: false });
@@ -12349,11 +12462,11 @@ function usageFromOpencode(tokens) {
12349
12462
  cacheWriteTokens: tokens.cache?.write ? Number(tokens.cache.write) : void 0
12350
12463
  };
12351
12464
  }
12352
- var import_node_fs33, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
12465
+ var import_node_fs34, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
12353
12466
  var init_opencode = __esm({
12354
12467
  "src/agents/opencode.ts"() {
12355
12468
  "use strict";
12356
- import_node_fs33 = require("fs");
12469
+ import_node_fs34 = require("fs");
12357
12470
  init_run();
12358
12471
  init_app_settings();
12359
12472
  init_global_workspace();
@@ -12381,7 +12494,7 @@ var init_opencode = __esm({
12381
12494
  async detect() {
12382
12495
  const opencode = resolveAgentExecutable("opencode");
12383
12496
  if (opencode !== "opencode") {
12384
- if (!(0, import_node_fs33.existsSync)(opencode)) {
12497
+ if (!(0, import_node_fs34.existsSync)(opencode)) {
12385
12498
  return {
12386
12499
  agent: "opencode",
12387
12500
  installed: false,
@@ -12868,13 +12981,13 @@ var init_claude_usage = __esm({
12868
12981
  });
12869
12982
 
12870
12983
  // src/agents/claude-usage-client.ts
12871
- var import_node_fs34, import_node_os13, import_node_path35, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS;
12984
+ var import_node_fs35, import_node_os13, import_node_path36, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS;
12872
12985
  var init_claude_usage_client = __esm({
12873
12986
  "src/agents/claude-usage-client.ts"() {
12874
12987
  "use strict";
12875
- import_node_fs34 = require("fs");
12988
+ import_node_fs35 = require("fs");
12876
12989
  import_node_os13 = require("os");
12877
- import_node_path35 = require("path");
12990
+ import_node_path36 = require("path");
12878
12991
  init_run();
12879
12992
  init_fetch();
12880
12993
  init_app_settings();
@@ -12885,9 +12998,11 @@ var init_claude_usage_client = __esm({
12885
12998
  });
12886
12999
 
12887
13000
  // src/agents/install.ts
13001
+ var import_node_fs36;
12888
13002
  var init_install = __esm({
12889
13003
  "src/agents/install.ts"() {
12890
13004
  "use strict";
13005
+ import_node_fs36 = require("fs");
12891
13006
  init_run();
12892
13007
  init_app_settings();
12893
13008
  init_path();
@@ -12922,6 +13037,7 @@ var init_agents = __esm({
12922
13037
  init_claude_usage_client();
12923
13038
  init_orchestrator_capable();
12924
13039
  init_path();
13040
+ init_cursor_sdk_resolve();
12925
13041
  init_install();
12926
13042
  adapters = {
12927
13043
  claude: claudeAdapter,
@@ -12940,7 +13056,7 @@ function isAgentHostEnvKey(key) {
12940
13056
  }
12941
13057
  function stripHostToolingPath(pathValue) {
12942
13058
  if (!pathValue?.trim()) return "";
12943
- return pathValue.split(import_node_path36.delimiter).filter((part) => part && !HOST_PATH_NOISE.test(part.replace(/\\/g, "/"))).join(import_node_path36.delimiter);
13059
+ return pathValue.split(import_node_path37.delimiter).filter((part) => part && !HOST_PATH_NOISE.test(part.replace(/\\/g, "/"))).join(import_node_path37.delimiter);
12944
13060
  }
12945
13061
  function sanitizeAgentHostEnv(env, cwd) {
12946
13062
  for (const key of Object.keys(env)) {
@@ -12954,11 +13070,11 @@ function sanitizeAgentHostEnv(env, cwd) {
12954
13070
  }
12955
13071
  return env;
12956
13072
  }
12957
- var import_node_path36, DROP_EXACT, DROP_PREFIXES, HOST_PATH_NOISE;
13073
+ var import_node_path37, DROP_EXACT, DROP_PREFIXES, HOST_PATH_NOISE;
12958
13074
  var init_agent_host_env = __esm({
12959
13075
  "src/hook/agent-host-env.ts"() {
12960
13076
  "use strict";
12961
- import_node_path36 = require("path");
13077
+ import_node_path37 = require("path");
12962
13078
  DROP_EXACT = /* @__PURE__ */ new Set([
12963
13079
  "NODE_PATH",
12964
13080
  "NODE_ENV_ELECTRON_VITE",
@@ -12997,15 +13113,15 @@ var init_agent_host_env = __esm({
12997
13113
 
12998
13114
  // src/hook/worktree-pkg-cache.ts
12999
13115
  function worktreePkgCacheRoot(worktreePath) {
13000
- return (0, import_node_path37.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
13116
+ return (0, import_node_path38.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
13001
13117
  }
13002
13118
  function worktreePkgCacheEnv(worktreePath) {
13003
13119
  const root = worktreePkgCacheRoot(worktreePath);
13004
- const store = (0, import_node_path37.join)(root, "pnpm-store");
13005
- const pnpmCache = (0, import_node_path37.join)(root, "pnpm");
13006
- const npmCache = (0, import_node_path37.join)(root, "npm");
13007
- const nodeGyp = (0, import_node_path37.join)(root, "node-gyp");
13008
- const electron = (0, import_node_path37.join)(root, "electron");
13120
+ const store = (0, import_node_path38.join)(root, "pnpm-store");
13121
+ const pnpmCache = (0, import_node_path38.join)(root, "pnpm");
13122
+ const npmCache = (0, import_node_path38.join)(root, "npm");
13123
+ const nodeGyp = (0, import_node_path38.join)(root, "node-gyp");
13124
+ const electron = (0, import_node_path38.join)(root, "electron");
13009
13125
  return {
13010
13126
  npm_config_store_dir: store,
13011
13127
  PNPM_STORE_DIR: store,
@@ -13027,8 +13143,8 @@ function fillGroup(env, keys, values) {
13027
13143
  }
13028
13144
  }
13029
13145
  function ensureWorktreePkgCacheDirs(worktreePath) {
13030
- if (!(0, import_node_fs35.existsSync)(worktreePath)) return;
13031
- (0, import_node_fs35.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
13146
+ if (!(0, import_node_fs37.existsSync)(worktreePath)) return;
13147
+ (0, import_node_fs37.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
13032
13148
  }
13033
13149
  function applyWorktreePkgCacheEnv(env, worktreePath) {
13034
13150
  const cwd = worktreePath.trim();
@@ -13041,12 +13157,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
13041
13157
  fillGroup(env, ["electron_config_cache"], next);
13042
13158
  ensureWorktreePkgCacheDirs(cwd);
13043
13159
  }
13044
- var import_node_fs35, import_node_path37, WORKTREE_PKG_CACHE_REL;
13160
+ var import_node_fs37, import_node_path38, WORKTREE_PKG_CACHE_REL;
13045
13161
  var init_worktree_pkg_cache = __esm({
13046
13162
  "src/hook/worktree-pkg-cache.ts"() {
13047
13163
  "use strict";
13048
- import_node_fs35 = require("fs");
13049
- import_node_path37 = require("path");
13164
+ import_node_fs37 = require("fs");
13165
+ import_node_path38 = require("path");
13050
13166
  WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
13051
13167
  }
13052
13168
  });
@@ -14244,21 +14360,21 @@ function shouldRefreshReviewRequestTemplate(content) {
14244
14360
  return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
14245
14361
  }
14246
14362
  function readTextIfPresent(abs) {
14247
- if (!(0, import_node_fs36.existsSync)(abs)) return null;
14363
+ if (!(0, import_node_fs38.existsSync)(abs)) return null;
14248
14364
  try {
14249
- const content = (0, import_node_fs36.readFileSync)(abs, "utf8");
14365
+ const content = (0, import_node_fs38.readFileSync)(abs, "utf8");
14250
14366
  return content.trim() ? content : null;
14251
14367
  } catch {
14252
14368
  return null;
14253
14369
  }
14254
14370
  }
14255
14371
  function readLocalGuidelines(worktreePath) {
14256
- const localAbs = (0, import_node_path38.join)(worktreePath, REVIEW_REQUEST_PATH);
14372
+ const localAbs = (0, import_node_path39.join)(worktreePath, REVIEW_REQUEST_PATH);
14257
14373
  const localContent = readTextIfPresent(localAbs);
14258
14374
  if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
14259
14375
  return { path: REVIEW_REQUEST_PATH, content: localContent };
14260
14376
  }
14261
- const legacyAbs = (0, import_node_path38.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
14377
+ const legacyAbs = (0, import_node_path39.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
14262
14378
  const legacyContent = readTextIfPresent(legacyAbs);
14263
14379
  if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
14264
14380
  return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
@@ -14282,27 +14398,27 @@ function contextGuidelines(content, source) {
14282
14398
  };
14283
14399
  }
14284
14400
  function writeContextGuidelines(worktreePath, content) {
14285
- const abs = (0, import_node_path38.join)(worktreePath, CONTEXT_REVIEW_PATH);
14286
- (0, import_node_fs36.mkdirSync)((0, import_node_path38.dirname)(abs), { recursive: true });
14401
+ const abs = (0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH);
14402
+ (0, import_node_fs38.mkdirSync)((0, import_node_path39.dirname)(abs), { recursive: true });
14287
14403
  const body = content.endsWith("\n") ? content : `${content}
14288
14404
  `;
14289
- (0, import_node_fs36.writeFileSync)(abs, body, "utf8");
14405
+ (0, import_node_fs38.writeFileSync)(abs, body, "utf8");
14290
14406
  return body;
14291
14407
  }
14292
14408
  function readSideboardReview(worktreePath, repoPath) {
14293
- const fromWorktree = readTextIfPresent((0, import_node_path38.join)(worktreePath, REPO_REVIEW_PATH));
14409
+ const fromWorktree = readTextIfPresent((0, import_node_path39.join)(worktreePath, REPO_REVIEW_PATH));
14294
14410
  if (fromWorktree) return fromWorktree;
14295
14411
  const repo = repoPath?.replace(/\/+$/, "");
14296
14412
  const wt = worktreePath.replace(/\/+$/, "");
14297
14413
  if (!repo || repo === wt) return null;
14298
- return readTextIfPresent((0, import_node_path38.join)(repo, REPO_REVIEW_PATH));
14414
+ return readTextIfPresent((0, import_node_path39.join)(repo, REPO_REVIEW_PATH));
14299
14415
  }
14300
14416
  function ensureReviewGuidelinesFile(worktreePath, repoPath) {
14301
- const skillContent = readTextIfPresent((0, import_node_path38.join)(worktreePath, REVIEW_SKILL_PATH));
14417
+ const skillContent = readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_SKILL_PATH));
14302
14418
  if (skillContent) {
14303
14419
  return { ...skillGuidelines(skillContent, "skill"), wrote: false };
14304
14420
  }
14305
- const contextContent = readTextIfPresent((0, import_node_path38.join)(worktreePath, CONTEXT_REVIEW_PATH));
14421
+ const contextContent = readTextIfPresent((0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH));
14306
14422
  if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
14307
14423
  return { ...contextGuidelines(contextContent, "local"), wrote: false };
14308
14424
  }
@@ -14357,13 +14473,13 @@ async function requestReview(threadRef, send) {
14357
14473
  const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
14358
14474
  return { tab: started, from };
14359
14475
  }
14360
- var import_node_crypto7, import_node_fs36, import_node_path38, 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;
14476
+ var import_node_crypto7, import_node_fs38, import_node_path39, 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;
14361
14477
  var init_request_review = __esm({
14362
14478
  "src/review/request-review.ts"() {
14363
14479
  "use strict";
14364
14480
  import_node_crypto7 = require("crypto");
14365
- import_node_fs36 = require("fs");
14366
- import_node_path38 = require("path");
14481
+ import_node_fs38 = require("fs");
14482
+ import_node_path39 = require("path");
14367
14483
  init_global_workspace();
14368
14484
  init_chat_tabs();
14369
14485
  init_thread_store();
@@ -14389,9 +14505,9 @@ function matchSimpleGlob(pattern, name) {
14389
14505
  return new RegExp(`^${escaped}$`).test(name);
14390
14506
  }
14391
14507
  function readWorktreeInclude(repoPath) {
14392
- const path = (0, import_node_path39.join)(repoPath, ".worktreeinclude");
14393
- if (!(0, import_node_fs37.existsSync)(path)) return [];
14394
- return (0, import_node_fs37.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
14508
+ const path = (0, import_node_path40.join)(repoPath, ".worktreeinclude");
14509
+ if (!(0, import_node_fs39.existsSync)(path)) return [];
14510
+ return (0, import_node_fs39.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
14395
14511
  }
14396
14512
  function resolveFilesToCopy(repoPath) {
14397
14513
  const fromInclude = readWorktreeInclude(repoPath);
@@ -14401,10 +14517,10 @@ function resolveFilesToCopy(repoPath) {
14401
14517
  if (settings?.fileIncludeGlobs?.length) {
14402
14518
  const matched = [];
14403
14519
  try {
14404
- for (const entry of (0, import_node_fs37.readdirSync)(repoPath, { withFileTypes: true })) {
14520
+ for (const entry of (0, import_node_fs39.readdirSync)(repoPath, { withFileTypes: true })) {
14405
14521
  if (!entry.isFile()) continue;
14406
14522
  for (const glob of settings.fileIncludeGlobs) {
14407
- if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path39.basename)(glob), entry.name)) {
14523
+ if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path40.basename)(glob), entry.name)) {
14408
14524
  matched.push(entry.name);
14409
14525
  break;
14410
14526
  }
@@ -14416,7 +14532,7 @@ function resolveFilesToCopy(repoPath) {
14416
14532
  }
14417
14533
  const defaults = [];
14418
14534
  try {
14419
- for (const entry of (0, import_node_fs37.readdirSync)(repoPath, { withFileTypes: true })) {
14535
+ for (const entry of (0, import_node_fs39.readdirSync)(repoPath, { withFileTypes: true })) {
14420
14536
  if (entry.isFile() && entry.name.startsWith(".env")) {
14421
14537
  defaults.push(entry.name);
14422
14538
  }
@@ -14430,11 +14546,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
14430
14546
  const patterns = resolveFilesToCopy(repoPath);
14431
14547
  const copied = [];
14432
14548
  for (const rel of patterns) {
14433
- const src = (0, import_node_path39.join)(repoPath, rel);
14434
- if (!(0, import_node_fs37.existsSync)(src)) continue;
14435
- const dest = (0, import_node_path39.join)(worktreePath, rel);
14436
- (0, import_node_fs37.mkdirSync)((0, import_node_path39.dirname)(dest), { recursive: true });
14437
- (0, import_node_fs37.copyFileSync)(src, dest);
14549
+ const src = (0, import_node_path40.join)(repoPath, rel);
14550
+ if (!(0, import_node_fs39.existsSync)(src)) continue;
14551
+ const dest = (0, import_node_path40.join)(worktreePath, rel);
14552
+ (0, import_node_fs39.mkdirSync)((0, import_node_path40.dirname)(dest), { recursive: true });
14553
+ (0, import_node_fs39.copyFileSync)(src, dest);
14438
14554
  copied.push(rel);
14439
14555
  }
14440
14556
  return copied;
@@ -14469,7 +14585,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
14469
14585
  const env = stripNestedElectronEnv({
14470
14586
  ...baseEnv ?? process.env
14471
14587
  });
14472
- const name = opts.workspaceName ?? (0, import_node_path39.basename)(opts.worktreePath);
14588
+ const name = opts.workspaceName ?? (0, import_node_path40.basename)(opts.worktreePath);
14473
14589
  const ports = opts.ports ?? [];
14474
14590
  const primary = ports[0];
14475
14591
  env.SIDEBOARD_WORKSPACE_NAME = name;
@@ -14793,14 +14909,14 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
14793
14909
  throw err;
14794
14910
  }
14795
14911
  }
14796
- var import_node_fs37, import_node_child_process4, import_node_net, import_node_path39, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
14912
+ var import_node_fs39, import_node_child_process4, import_node_net, import_node_path40, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
14797
14913
  var init_conductor = __esm({
14798
14914
  "src/hook/conductor.ts"() {
14799
14915
  "use strict";
14800
- import_node_fs37 = require("fs");
14916
+ import_node_fs39 = require("fs");
14801
14917
  import_node_child_process4 = require("child_process");
14802
14918
  import_node_net = require("net");
14803
- import_node_path39 = require("path");
14919
+ import_node_path40 = require("path");
14804
14920
  import_execa4 = require("execa");
14805
14921
  import_node_readline3 = require("readline");
14806
14922
  init_settings();
@@ -14850,7 +14966,7 @@ function materialize(mem) {
14850
14966
  };
14851
14967
  }
14852
14968
  function setupLogPath(threadId) {
14853
- return (0, import_node_path40.join)(threadsDir(), `${threadId}.setup.log.json`);
14969
+ return (0, import_node_path41.join)(threadsDir(), `${threadId}.setup.log.json`);
14854
14970
  }
14855
14971
  function setupLogKeyForWorktree(worktreePath) {
14856
14972
  const norm = normalizeWorktreePath(worktreePath);
@@ -14868,7 +14984,7 @@ function persistNow(threadId) {
14868
14984
  const mem = memory.get(threadId);
14869
14985
  if (!mem) return;
14870
14986
  try {
14871
- (0, import_node_fs38.writeFileSync)(
14987
+ (0, import_node_fs40.writeFileSync)(
14872
14988
  setupLogPath(threadId),
14873
14989
  `${JSON.stringify(materialize(mem))}
14874
14990
  `,
@@ -14889,9 +15005,9 @@ function schedulePersist(threadId) {
14889
15005
  }
14890
15006
  function loadFromDisk(threadId) {
14891
15007
  const path = setupLogPath(threadId);
14892
- if (!(0, import_node_fs38.existsSync)(path)) return null;
15008
+ if (!(0, import_node_fs40.existsSync)(path)) return null;
14893
15009
  try {
14894
- const raw = JSON.parse((0, import_node_fs38.readFileSync)(path, "utf8"));
15010
+ const raw = JSON.parse((0, import_node_fs40.readFileSync)(path, "utf8"));
14895
15011
  return {
14896
15012
  output: typeof raw.output === "string" ? raw.output : "",
14897
15013
  running: Boolean(raw.running),
@@ -14947,13 +15063,13 @@ function finishSetupLog(threadId, exitCode, source) {
14947
15063
  persistNow(threadId);
14948
15064
  return materialize(mem);
14949
15065
  }
14950
- var import_node_crypto8, import_node_fs38, import_node_path40, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers, PERSIST_DEBOUNCE_MS;
15066
+ var import_node_crypto8, import_node_fs40, import_node_path41, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers, PERSIST_DEBOUNCE_MS;
14951
15067
  var init_setup_log = __esm({
14952
15068
  "src/store/setup-log.ts"() {
14953
15069
  "use strict";
14954
15070
  import_node_crypto8 = require("crypto");
14955
- import_node_fs38 = require("fs");
14956
- import_node_path40 = require("path");
15071
+ import_node_fs40 = require("fs");
15072
+ import_node_path41 = require("path");
14957
15073
  init_worktree_labels();
14958
15074
  init_paths();
14959
15075
  EMPTY = {
@@ -14980,9 +15096,9 @@ async function findOrphanWorktrees(repoPaths) {
14980
15096
  repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
14981
15097
  );
14982
15098
  const homeRoot = sideboardWorkspacesDir();
14983
- if ((0, import_node_fs39.existsSync)(homeRoot)) {
15099
+ if ((0, import_node_fs41.existsSync)(homeRoot)) {
14984
15100
  try {
14985
- for (const entry of (0, import_node_fs39.readdirSync)(homeRoot, { withFileTypes: true })) {
15101
+ for (const entry of (0, import_node_fs41.readdirSync)(homeRoot, { withFileTypes: true })) {
14986
15102
  if (!entry.isDirectory()) continue;
14987
15103
  void entry;
14988
15104
  }
@@ -14992,7 +15108,7 @@ async function findOrphanWorktrees(repoPaths) {
14992
15108
  const orphans = [];
14993
15109
  const seen = /* @__PURE__ */ new Set();
14994
15110
  for (const repoPath of repos) {
14995
- if (!repoPath || !(0, import_node_fs39.existsSync)(repoPath)) continue;
15111
+ if (!repoPath || !(0, import_node_fs41.existsSync)(repoPath)) continue;
14996
15112
  try {
14997
15113
  const wts = await listWorktrees(repoPath);
14998
15114
  for (const wt of wts) {
@@ -15003,7 +15119,7 @@ async function findOrphanWorktrees(repoPaths) {
15003
15119
  seen.add(path);
15004
15120
  let mtimeMs = 0;
15005
15121
  try {
15006
- mtimeMs = (0, import_node_fs39.statSync)(path).mtimeMs;
15122
+ mtimeMs = (0, import_node_fs41.statSync)(path).mtimeMs;
15007
15123
  } catch {
15008
15124
  mtimeMs = 0;
15009
15125
  }
@@ -15013,16 +15129,16 @@ async function findOrphanWorktrees(repoPaths) {
15013
15129
  }
15014
15130
  try {
15015
15131
  const root = worktreesRoot(repoPath);
15016
- if ((0, import_node_fs39.existsSync)(root)) {
15017
- for (const entry of (0, import_node_fs39.readdirSync)(root, { withFileTypes: true })) {
15132
+ if ((0, import_node_fs41.existsSync)(root)) {
15133
+ for (const entry of (0, import_node_fs41.readdirSync)(root, { withFileTypes: true })) {
15018
15134
  if (!entry.isDirectory()) continue;
15019
- const path = (0, import_node_path41.join)(root, entry.name).replace(/\/$/, "");
15135
+ const path = (0, import_node_path42.join)(root, entry.name).replace(/\/$/, "");
15020
15136
  if (known.has(path) || seen.has(path)) continue;
15021
- if (!(0, import_node_fs39.existsSync)((0, import_node_path41.join)(path, ".git"))) continue;
15137
+ if (!(0, import_node_fs41.existsSync)((0, import_node_path42.join)(path, ".git"))) continue;
15022
15138
  seen.add(path);
15023
15139
  let mtimeMs = 0;
15024
15140
  try {
15025
- mtimeMs = (0, import_node_fs39.statSync)(path).mtimeMs;
15141
+ mtimeMs = (0, import_node_fs41.statSync)(path).mtimeMs;
15026
15142
  } catch {
15027
15143
  mtimeMs = Date.now();
15028
15144
  }
@@ -15074,12 +15190,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
15074
15190
  const elapsed = Date.now() - Date.parse(last);
15075
15191
  return elapsed >= intervalHours * 36e5;
15076
15192
  }
15077
- var import_node_fs39, import_node_path41;
15193
+ var import_node_fs41, import_node_path42;
15078
15194
  var init_orphan_cleanup = __esm({
15079
15195
  "src/git/orphan-cleanup.ts"() {
15080
15196
  "use strict";
15081
- import_node_fs39 = require("fs");
15082
- import_node_path41 = require("path");
15197
+ import_node_fs41 = require("fs");
15198
+ import_node_path42 = require("path");
15083
15199
  init_worktree();
15084
15200
  init_thread_store();
15085
15201
  init_paths();
@@ -15254,12 +15370,12 @@ async function cloneRepoIntoSideboard(opts) {
15254
15370
  if (!url) throw new Error("Clone URL is required");
15255
15371
  let name = opts.name?.trim();
15256
15372
  if (!name) {
15257
- const leaf = (0, import_node_path42.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
15373
+ const leaf = (0, import_node_path43.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
15258
15374
  name = leaf || "repo";
15259
15375
  }
15260
15376
  name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
15261
- const dest = (0, import_node_path42.join)(sideboardReposDir(), name);
15262
- if ((0, import_node_fs40.existsSync)(dest)) {
15377
+ const dest = (0, import_node_path43.join)(sideboardReposDir(), name);
15378
+ if ((0, import_node_fs42.existsSync)(dest)) {
15263
15379
  const repoPath2 = await resolveRepoRoot(dest);
15264
15380
  const workspace2 = await ensureWorkspace(repoPath2);
15265
15381
  return { repoPath: repoPath2, workspace: workspace2 };
@@ -15274,12 +15390,12 @@ async function cloneRepoIntoSideboard(opts) {
15274
15390
  const workspace = await ensureWorkspace(repoPath);
15275
15391
  return { repoPath, workspace };
15276
15392
  }
15277
- var import_node_fs40, import_node_path42, import_execa6;
15393
+ var import_node_fs42, import_node_path43, import_execa6;
15278
15394
  var init_clone_repo = __esm({
15279
15395
  "src/git/clone-repo.ts"() {
15280
15396
  "use strict";
15281
- import_node_fs40 = require("fs");
15282
- import_node_path42 = require("path");
15397
+ import_node_fs42 = require("fs");
15398
+ import_node_path43 = require("path");
15283
15399
  import_execa6 = require("execa");
15284
15400
  init_paths();
15285
15401
  init_workspaces2();
@@ -15299,11 +15415,11 @@ var init_thread = __esm({
15299
15415
 
15300
15416
  // src/store/desktop-host.ts
15301
15417
  function desktopHostPidPath() {
15302
- return (0, import_node_path43.join)(appDataDir(), "desktop-host.pid");
15418
+ return (0, import_node_path44.join)(appDataDir(), "desktop-host.pid");
15303
15419
  }
15304
15420
  function readDesktopHostPid() {
15305
15421
  try {
15306
- const pid = Number.parseInt((0, import_node_fs41.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
15422
+ const pid = Number.parseInt((0, import_node_fs43.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
15307
15423
  if (!Number.isFinite(pid) || pid <= 0) return null;
15308
15424
  return pid;
15309
15425
  } catch {
@@ -15329,12 +15445,12 @@ function thisProcessShouldDrainAgentQueues() {
15329
15445
  if (isThisProcessDesktopHost()) return true;
15330
15446
  return !isDesktopHostAlive();
15331
15447
  }
15332
- var import_node_fs41, import_node_path43;
15448
+ var import_node_fs43, import_node_path44;
15333
15449
  var init_desktop_host = __esm({
15334
15450
  "src/store/desktop-host.ts"() {
15335
15451
  "use strict";
15336
- import_node_fs41 = require("fs");
15337
- import_node_path43 = require("path");
15452
+ import_node_fs43 = require("fs");
15453
+ import_node_path44 = require("path");
15338
15454
  init_paths();
15339
15455
  }
15340
15456
  });
@@ -15452,24 +15568,24 @@ function jobTreeAlive(pid) {
15452
15568
  return jobAlive(pid) || processGroupAlive(pid);
15453
15569
  }
15454
15570
  function readIntFile(file) {
15455
- if (!(0, import_node_fs42.existsSync)(file)) return null;
15456
- const n = Number.parseInt((0, import_node_fs42.readFileSync)(file, "utf8").trim(), 10);
15571
+ if (!(0, import_node_fs44.existsSync)(file)) return null;
15572
+ const n = Number.parseInt((0, import_node_fs44.readFileSync)(file, "utf8").trim(), 10);
15457
15573
  return Number.isInteger(n) ? n : null;
15458
15574
  }
15459
15575
  function jobDir(root, id, legacy = false) {
15460
- return (0, import_node_path44.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
15576
+ return (0, import_node_path45.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
15461
15577
  }
15462
15578
  function resolveJobDir(root, id) {
15463
15579
  const modern = jobDir(root, id, false);
15464
- if ((0, import_node_fs42.existsSync)(modern)) return modern;
15580
+ if ((0, import_node_fs44.existsSync)(modern)) return modern;
15465
15581
  const legacy = jobDir(root, id, true);
15466
- if ((0, import_node_fs42.existsSync)(legacy)) return legacy;
15582
+ if ((0, import_node_fs44.existsSync)(legacy)) return legacy;
15467
15583
  return modern;
15468
15584
  }
15469
15585
  function listJobIdsIn(root, rel) {
15470
- const dir = (0, import_node_path44.join)(root, rel);
15471
- if (!(0, import_node_fs42.existsSync)(dir)) return [];
15472
- return (0, import_node_fs42.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
15586
+ const dir = (0, import_node_path45.join)(root, rel);
15587
+ if (!(0, import_node_fs44.existsSync)(dir)) return [];
15588
+ return (0, import_node_fs44.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
15473
15589
  }
15474
15590
  function listRunningDetachedJobs(worktreePath) {
15475
15591
  const root = worktreePath.trim();
@@ -15481,7 +15597,7 @@ function listRunningDetachedJobs(worktreePath) {
15481
15597
  const running = [];
15482
15598
  for (const id of ids) {
15483
15599
  const dir = resolveJobDir(root, id);
15484
- const pid = readIntFile((0, import_node_path44.join)(dir, "pid"));
15600
+ const pid = readIntFile((0, import_node_path45.join)(dir, "pid"));
15485
15601
  if (jobTreeAlive(pid)) running.push(id);
15486
15602
  }
15487
15603
  return running.sort();
@@ -15564,8 +15680,8 @@ function planJobContinue(opts) {
15564
15680
  return { action: "none" };
15565
15681
  }
15566
15682
  function tailProgress(logFile, maxLines = 12) {
15567
- if (!(0, import_node_fs42.existsSync)(logFile)) return "(no log yet)";
15568
- const lines = (0, import_node_fs42.readFileSync)(logFile, "utf8").split("\n");
15683
+ if (!(0, import_node_fs44.existsSync)(logFile)) return "(no log yet)";
15684
+ const lines = (0, import_node_fs44.readFileSync)(logFile, "utf8").split("\n");
15569
15685
  return lines.slice(-maxLines).join("\n");
15570
15686
  }
15571
15687
  function lastProgressLine(progress) {
@@ -15573,8 +15689,8 @@ function lastProgressLine(progress) {
15573
15689
  return last ? last.slice(0, 72) : void 0;
15574
15690
  }
15575
15691
  function readLogLines(file) {
15576
- if (!(0, import_node_fs42.existsSync)(file)) return [];
15577
- const lines = (0, import_node_fs42.readFileSync)(file, "utf8").split("\n");
15692
+ if (!(0, import_node_fs44.existsSync)(file)) return [];
15693
+ const lines = (0, import_node_fs44.readFileSync)(file, "utf8").split("\n");
15578
15694
  if (lines.length && lines[lines.length - 1] === "") lines.pop();
15579
15695
  return lines;
15580
15696
  }
@@ -15585,15 +15701,15 @@ function takeDelta(logFile, cursorFile) {
15585
15701
  return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
15586
15702
  }
15587
15703
  function snapshotJob(dir) {
15588
- const pid = readIntFile((0, import_node_path44.join)(dir, "pid"));
15704
+ const pid = readIntFile((0, import_node_path45.join)(dir, "pid"));
15589
15705
  const running = jobTreeAlive(pid);
15590
15706
  return {
15591
15707
  pid,
15592
15708
  running,
15593
- exitCode: readIntFile((0, import_node_path44.join)(dir, "exit")),
15594
- log: (0, import_node_path44.join)(dir, "log"),
15595
- cursor: (0, import_node_path44.join)(dir, "present.cursor"),
15596
- progress: tailProgress((0, import_node_path44.join)(dir, "log"))
15709
+ exitCode: readIntFile((0, import_node_path45.join)(dir, "exit")),
15710
+ log: (0, import_node_path45.join)(dir, "log"),
15711
+ cursor: (0, import_node_path45.join)(dir, "present.cursor"),
15712
+ progress: tailProgress((0, import_node_path45.join)(dir, "log"))
15597
15713
  };
15598
15714
  }
15599
15715
  function toResult(id, snap, extra) {
@@ -15602,8 +15718,8 @@ function toResult(id, snap, extra) {
15602
15718
  const stillRunning = snap.running && !ok;
15603
15719
  const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
15604
15720
  try {
15605
- (0, import_node_fs42.mkdirSync)((0, import_node_path44.dirname)(snap.cursor), { recursive: true });
15606
- (0, import_node_fs42.writeFileSync)(snap.cursor, `${nextCursor}
15721
+ (0, import_node_fs44.mkdirSync)((0, import_node_path45.dirname)(snap.cursor), { recursive: true });
15722
+ (0, import_node_fs44.writeFileSync)(snap.cursor, `${nextCursor}
15607
15723
  `);
15608
15724
  } catch {
15609
15725
  }
@@ -15632,7 +15748,7 @@ async function waitForDetachedJob(cwd, id, opts) {
15632
15748
  const dir = resolveJobDir(root, jobId);
15633
15749
  const timeoutMs = mcpWaitForJobTimeoutMs(opts?.timeoutMs);
15634
15750
  const sleep = opts?.sleep ?? sleepMs;
15635
- if (!(0, import_node_fs42.existsSync)(dir)) {
15751
+ if (!(0, import_node_fs44.existsSync)(dir)) {
15636
15752
  return {
15637
15753
  stillRunning: false,
15638
15754
  ok: false,
@@ -15678,10 +15794,10 @@ function killProcessTree(pid, signal) {
15678
15794
  }
15679
15795
  function appendJobLog(logFile, line) {
15680
15796
  try {
15681
- (0, import_node_fs42.mkdirSync)((0, import_node_path44.dirname)(logFile), { recursive: true });
15797
+ (0, import_node_fs44.mkdirSync)((0, import_node_path45.dirname)(logFile), { recursive: true });
15682
15798
  const body = line.endsWith("\n") ? line : `${line}
15683
15799
  `;
15684
- (0, import_node_fs42.appendFileSync)(logFile, body);
15800
+ (0, import_node_fs44.appendFileSync)(logFile, body);
15685
15801
  } catch {
15686
15802
  }
15687
15803
  }
@@ -15691,7 +15807,7 @@ async function stopDetachedJob(cwd, id, opts) {
15691
15807
  const dir = resolveJobDir(root, jobId);
15692
15808
  const sleep = opts?.sleep ?? sleepMs;
15693
15809
  const why = opts?.reason?.trim() ?? "";
15694
- if (!(0, import_node_fs42.existsSync)(dir)) {
15810
+ if (!(0, import_node_fs44.existsSync)(dir)) {
15695
15811
  return {
15696
15812
  stillRunning: false,
15697
15813
  ok: false,
@@ -15727,10 +15843,10 @@ async function stopDetachedJob(cwd, id, opts) {
15727
15843
  killProcessTree(targetPid, "SIGKILL");
15728
15844
  await sleep(100);
15729
15845
  }
15730
- const exitFile = (0, import_node_path44.join)(dir, "exit");
15731
- if (!(0, import_node_fs42.existsSync)(exitFile)) {
15846
+ const exitFile = (0, import_node_path45.join)(dir, "exit");
15847
+ if (!(0, import_node_fs44.existsSync)(exitFile)) {
15732
15848
  try {
15733
- (0, import_node_fs42.writeFileSync)(exitFile, "1\n");
15849
+ (0, import_node_fs44.writeFileSync)(exitFile, "1\n");
15734
15850
  } catch {
15735
15851
  }
15736
15852
  }
@@ -15750,12 +15866,12 @@ async function stopDetachedJob(cwd, id, opts) {
15750
15866
  hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
15751
15867
  };
15752
15868
  }
15753
- var import_node_fs42, import_node_path44, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
15869
+ var import_node_fs44, import_node_path45, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
15754
15870
  var init_wait_for_job = __esm({
15755
15871
  "src/mcp/wait-for-job.ts"() {
15756
15872
  "use strict";
15757
- import_node_fs42 = require("fs");
15758
- import_node_path44 = require("path");
15873
+ import_node_fs44 = require("fs");
15874
+ import_node_path45 = require("path");
15759
15875
  init_workspace_scratch();
15760
15876
  init_wait_for_turn();
15761
15877
  MAX_JOB_CONTINUES = 8;
@@ -17790,7 +17906,7 @@ function reuseLiveThread(input, repoPath, match) {
17790
17906
  }
17791
17907
  async function createThread(input, _onSetupLine) {
17792
17908
  const repoPath = await resolveRepoRoot(input.repoPath);
17793
- if (!(0, import_node_fs43.existsSync)(repoPath)) {
17909
+ if (!(0, import_node_fs45.existsSync)(repoPath)) {
17794
17910
  throw new Error(`Repo not found: ${repoPath}`);
17795
17911
  }
17796
17912
  const reused = reuseLiveThread(input, repoPath, {
@@ -17966,11 +18082,11 @@ async function createThread(input, _onSetupLine) {
17966
18082
  await ensureWorkspace(repoPath);
17967
18083
  return readThread(thread.id) ?? thread;
17968
18084
  }
17969
- var import_node_fs43;
18085
+ var import_node_fs45;
17970
18086
  var init_create = __esm({
17971
18087
  "src/threads/create.ts"() {
17972
18088
  "use strict";
17973
- import_node_fs43 = require("fs");
18089
+ import_node_fs45 = require("fs");
17974
18090
  init_detect();
17975
18091
  init_worktree();
17976
18092
  init_home_board();
@@ -18122,20 +18238,20 @@ function writeTurnLive(threadId, progress) {
18122
18238
  const path = threadLivePath(threadId);
18123
18239
  const tmp = `${path}.${process.pid}.tmp`;
18124
18240
  try {
18125
- (0, import_node_fs44.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
18126
- (0, import_node_fs44.renameSync)(tmp, path);
18241
+ (0, import_node_fs46.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
18242
+ (0, import_node_fs46.renameSync)(tmp, path);
18127
18243
  } catch {
18128
18244
  try {
18129
- (0, import_node_fs44.unlinkSync)(tmp);
18245
+ (0, import_node_fs46.unlinkSync)(tmp);
18130
18246
  } catch {
18131
18247
  }
18132
18248
  }
18133
18249
  }
18134
18250
  function readTurnLive(threadId) {
18135
18251
  const path = threadLivePath(threadId);
18136
- if (!(0, import_node_fs44.existsSync)(path)) return null;
18252
+ if (!(0, import_node_fs46.existsSync)(path)) return null;
18137
18253
  try {
18138
- const raw = JSON.parse((0, import_node_fs44.readFileSync)(path, "utf8"));
18254
+ const raw = JSON.parse((0, import_node_fs46.readFileSync)(path, "utf8"));
18139
18255
  if (!raw || typeof raw.summary !== "string") return null;
18140
18256
  return raw;
18141
18257
  } catch {
@@ -18147,17 +18263,17 @@ function clearTurnLive(threadId) {
18147
18263
  if (buf?.timer) clearTimeout(buf.timer);
18148
18264
  buffers.delete(threadId);
18149
18265
  const path = threadLivePath(threadId);
18150
- if (!(0, import_node_fs44.existsSync)(path)) return;
18266
+ if (!(0, import_node_fs46.existsSync)(path)) return;
18151
18267
  try {
18152
- (0, import_node_fs44.unlinkSync)(path);
18268
+ (0, import_node_fs46.unlinkSync)(path);
18153
18269
  } catch {
18154
18270
  }
18155
18271
  }
18156
- var import_node_fs44, buffers, FLUSH_MS, MAX_PARTS;
18272
+ var import_node_fs46, buffers, FLUSH_MS, MAX_PARTS;
18157
18273
  var init_turn_live = __esm({
18158
18274
  "src/store/turn-live.ts"() {
18159
18275
  "use strict";
18160
- import_node_fs44 = require("fs");
18276
+ import_node_fs46 = require("fs");
18161
18277
  init_message_parts();
18162
18278
  init_paths();
18163
18279
  buffers = /* @__PURE__ */ new Map();
@@ -18396,12 +18512,12 @@ var init_quota_failover = __esm({
18396
18512
  });
18397
18513
 
18398
18514
  // src/threads/adopt.ts
18399
- function thisModuleFile() {
18515
+ function thisModuleFile2() {
18400
18516
  const cjsFile = typeof __filename !== "undefined" ? __filename : "";
18401
- return cjsFile || process.argv[1] || (0, import_node_path45.join)(process.cwd(), "package.json");
18517
+ return cjsFile || process.argv[1] || (0, import_node_path46.join)(process.cwd(), "package.json");
18402
18518
  }
18403
18519
  function openReadonlySqlite(file) {
18404
- const req = (0, import_node_module4.createRequire)(thisModuleFile());
18520
+ const req = (0, import_node_module5.createRequire)(thisModuleFile2());
18405
18521
  const Database = req("better-sqlite3");
18406
18522
  return new Database(file, { readonly: true, fileMustExist: true });
18407
18523
  }
@@ -18416,21 +18532,21 @@ function mapAgentType(raw) {
18416
18532
  return null;
18417
18533
  }
18418
18534
  function resolveConductorCursorAgentId(workspacePath) {
18419
- if (!workspacePath || !(0, import_node_fs45.existsSync)(CURSOR_SDK_STORE)) return null;
18535
+ if (!workspacePath || !(0, import_node_fs47.existsSync)(CURSOR_SDK_STORE)) return null;
18420
18536
  const normalized = workspacePath.replace(/\/$/, "");
18421
18537
  let best = null;
18422
18538
  let hashes;
18423
18539
  try {
18424
- hashes = (0, import_node_fs45.readdirSync)(CURSOR_SDK_STORE);
18540
+ hashes = (0, import_node_fs47.readdirSync)(CURSOR_SDK_STORE);
18425
18541
  } catch {
18426
18542
  return null;
18427
18543
  }
18428
18544
  for (const hash of hashes) {
18429
- const agentsFile = (0, import_node_path45.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
18430
- if (!(0, import_node_fs45.existsSync)(agentsFile)) continue;
18545
+ const agentsFile = (0, import_node_path46.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
18546
+ if (!(0, import_node_fs47.existsSync)(agentsFile)) continue;
18431
18547
  let text7;
18432
18548
  try {
18433
- text7 = (0, import_node_fs45.readFileSync)(agentsFile, "utf8");
18549
+ text7 = (0, import_node_fs47.readFileSync)(agentsFile, "utf8");
18434
18550
  } catch {
18435
18551
  continue;
18436
18552
  }
@@ -18454,7 +18570,7 @@ function resolveConductorCursorAgentId(workspacePath) {
18454
18570
  return best?.agentId ?? null;
18455
18571
  }
18456
18572
  async function adoptThread(input) {
18457
- if (!(0, import_node_fs45.existsSync)(input.worktreePath)) {
18573
+ if (!(0, import_node_fs47.existsSync)(input.worktreePath)) {
18458
18574
  throw new Error(`Worktree not found: ${input.worktreePath}`);
18459
18575
  }
18460
18576
  const repoPath = await resolveRepoRoot(input.worktreePath);
@@ -18480,18 +18596,18 @@ async function adoptThread(input) {
18480
18596
  return thread;
18481
18597
  }
18482
18598
  function listConductorWorkspaces() {
18483
- if (!(0, import_node_fs45.existsSync)(CONDUCTOR_DB)) {
18599
+ if (!(0, import_node_fs47.existsSync)(CONDUCTOR_DB)) {
18484
18600
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
18485
18601
  }
18486
- const tmp = (0, import_node_fs45.mkdtempSync)((0, import_node_path45.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
18487
- const snapshot = (0, import_node_path45.join)(tmp, "conductor.db");
18602
+ const tmp = (0, import_node_fs47.mkdtempSync)((0, import_node_path46.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
18603
+ const snapshot = (0, import_node_path46.join)(tmp, "conductor.db");
18488
18604
  try {
18489
- (0, import_node_fs45.copyFileSync)(CONDUCTOR_DB, snapshot);
18605
+ (0, import_node_fs47.copyFileSync)(CONDUCTOR_DB, snapshot);
18490
18606
  for (const suffix of ["-wal", "-shm"]) {
18491
18607
  const src = `${CONDUCTOR_DB}${suffix}`;
18492
- if ((0, import_node_fs45.existsSync)(src)) {
18608
+ if ((0, import_node_fs47.existsSync)(src)) {
18493
18609
  try {
18494
- (0, import_node_fs45.copyFileSync)(src, `${snapshot}${suffix}`);
18610
+ (0, import_node_fs47.copyFileSync)(src, `${snapshot}${suffix}`);
18495
18611
  } catch {
18496
18612
  }
18497
18613
  }
@@ -18567,22 +18683,22 @@ function listConductorWorkspaces() {
18567
18683
  db.close();
18568
18684
  }
18569
18685
  } finally {
18570
- (0, import_node_fs45.rmSync)(tmp, { recursive: true, force: true });
18686
+ (0, import_node_fs47.rmSync)(tmp, { recursive: true, force: true });
18571
18687
  }
18572
18688
  }
18573
18689
  function importConductorWorkspace(workspaceId) {
18574
- if (!(0, import_node_fs45.existsSync)(CONDUCTOR_DB)) {
18690
+ if (!(0, import_node_fs47.existsSync)(CONDUCTOR_DB)) {
18575
18691
  throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
18576
18692
  }
18577
- const tmp = (0, import_node_fs45.mkdtempSync)((0, import_node_path45.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
18578
- const snapshot = (0, import_node_path45.join)(tmp, "conductor.db");
18693
+ const tmp = (0, import_node_fs47.mkdtempSync)((0, import_node_path46.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
18694
+ const snapshot = (0, import_node_path46.join)(tmp, "conductor.db");
18579
18695
  try {
18580
- (0, import_node_fs45.copyFileSync)(CONDUCTOR_DB, snapshot);
18696
+ (0, import_node_fs47.copyFileSync)(CONDUCTOR_DB, snapshot);
18581
18697
  for (const suffix of ["-wal", "-shm"]) {
18582
18698
  const src = `${CONDUCTOR_DB}${suffix}`;
18583
- if ((0, import_node_fs45.existsSync)(src)) {
18699
+ if ((0, import_node_fs47.existsSync)(src)) {
18584
18700
  try {
18585
- (0, import_node_fs45.copyFileSync)(src, `${snapshot}${suffix}`);
18701
+ (0, import_node_fs47.copyFileSync)(src, `${snapshot}${suffix}`);
18586
18702
  } catch {
18587
18703
  }
18588
18704
  }
@@ -18600,7 +18716,7 @@ function importConductorWorkspace(workspaceId) {
18600
18716
  ).get(workspaceId);
18601
18717
  if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
18602
18718
  const worktreePath = String(row.workspacePath);
18603
- if (!(0, import_node_fs45.existsSync)(worktreePath)) {
18719
+ if (!(0, import_node_fs47.existsSync)(worktreePath)) {
18604
18720
  throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
18605
18721
  }
18606
18722
  let sessionId = null;
@@ -18663,31 +18779,31 @@ function importConductorWorkspace(workspaceId) {
18663
18779
  db.close();
18664
18780
  }
18665
18781
  } finally {
18666
- (0, import_node_fs45.rmSync)(tmp, { recursive: true, force: true });
18782
+ (0, import_node_fs47.rmSync)(tmp, { recursive: true, force: true });
18667
18783
  }
18668
18784
  }
18669
18785
  async function importConductorWorkspaceAsync(workspaceId) {
18670
18786
  return importConductorWorkspace(workspaceId);
18671
18787
  }
18672
- var import_node_child_process5, import_node_fs45, import_node_os14, import_node_path45, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
18788
+ var import_node_child_process5, import_node_fs47, import_node_os14, import_node_path46, import_node_module5, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
18673
18789
  var init_adopt = __esm({
18674
18790
  "src/threads/adopt.ts"() {
18675
18791
  "use strict";
18676
18792
  import_node_child_process5 = require("child_process");
18677
- import_node_fs45 = require("fs");
18793
+ import_node_fs47 = require("fs");
18678
18794
  import_node_os14 = require("os");
18679
- import_node_path45 = require("path");
18680
- import_node_module4 = require("module");
18795
+ import_node_path46 = require("path");
18796
+ import_node_module5 = require("module");
18681
18797
  init_worktree();
18682
18798
  init_thread_store();
18683
- CONDUCTOR_APP_SUPPORT = (0, import_node_path45.join)(
18799
+ CONDUCTOR_APP_SUPPORT = (0, import_node_path46.join)(
18684
18800
  process.env.HOME ?? "",
18685
18801
  "Library",
18686
18802
  "Application Support",
18687
18803
  "com.conductor.app"
18688
18804
  );
18689
- CONDUCTOR_DB = (0, import_node_path45.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
18690
- CURSOR_SDK_STORE = (0, import_node_path45.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
18805
+ CONDUCTOR_DB = (0, import_node_path46.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
18806
+ CURSOR_SDK_STORE = (0, import_node_path46.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
18691
18807
  }
18692
18808
  });
18693
18809
 
@@ -18754,7 +18870,7 @@ async function openStackLayer(input, _onSetupLine) {
18754
18870
  let createdWorktree = false;
18755
18871
  const trees = await listWorktrees(repoPath);
18756
18872
  const checkedOut = trees.find((w) => w.branch === branchName);
18757
- if (checkedOut?.path && (0, import_node_fs46.existsSync)(checkedOut.path)) {
18873
+ if (checkedOut?.path && (0, import_node_fs48.existsSync)(checkedOut.path)) {
18758
18874
  if (input.reuseExistingWorktree !== false) {
18759
18875
  worktreePath = checkedOut.path;
18760
18876
  } else {
@@ -18896,7 +19012,7 @@ async function initStackFromThread(input, onSetupLine) {
18896
19012
  async function createPrStack(input, onSetupLine) {
18897
19013
  await requireAgent(input.agent);
18898
19014
  const repoPath = await resolveRepoRoot(input.repoPath);
18899
- if (!(0, import_node_fs46.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
19015
+ if (!(0, import_node_fs48.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
18900
19016
  if (!input.branches.length) throw new Error("At least one branch name required");
18901
19017
  const status = await detectGhStack(repoPath);
18902
19018
  if (!status.available) throw new Error(status.reason);
@@ -18963,7 +19079,7 @@ async function createPrStack(input, onSetupLine) {
18963
19079
  }
18964
19080
  }
18965
19081
  const claimed = new Set(threads.map((t) => t.worktreePath));
18966
- if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs46.existsSync)(bootstrap.worktreePath)) {
19082
+ if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs48.existsSync)(bootstrap.worktreePath)) {
18967
19083
  try {
18968
19084
  await removeWorktree(repoPath, bootstrap.worktreePath, {
18969
19085
  deleteBranch: bootstrap.branchName
@@ -18973,11 +19089,11 @@ async function createPrStack(input, onSetupLine) {
18973
19089
  }
18974
19090
  return { stack, threads, createdThreadIds };
18975
19091
  }
18976
- var import_node_fs46;
19092
+ var import_node_fs48;
18977
19093
  var init_stack_layers = __esm({
18978
19094
  "src/threads/stack-layers.ts"() {
18979
19095
  "use strict";
18980
- import_node_fs46 = require("fs");
19096
+ import_node_fs48 = require("fs");
18981
19097
  init_detect();
18982
19098
  init_run();
18983
19099
  init_stack();
@@ -18990,7 +19106,7 @@ var init_stack_layers = __esm({
18990
19106
 
18991
19107
  // src/diff/diff.ts
18992
19108
  async function inspectGitWorktree(worktreePath) {
18993
- if (!worktreePath || !(0, import_node_fs47.existsSync)(worktreePath)) return "missing_worktree";
19109
+ if (!worktreePath || !(0, import_node_fs49.existsSync)(worktreePath)) return "missing_worktree";
18994
19110
  const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
18995
19111
  reject: false
18996
19112
  });
@@ -18998,7 +19114,7 @@ async function inspectGitWorktree(worktreePath) {
18998
19114
  return "ok";
18999
19115
  }
19000
19116
  async function initializeGitRepository(worktreePath) {
19001
- if (!worktreePath || !(0, import_node_fs47.existsSync)(worktreePath)) {
19117
+ if (!worktreePath || !(0, import_node_fs49.existsSync)(worktreePath)) {
19002
19118
  throw new Error("Worktree not found");
19003
19119
  }
19004
19120
  const status = await inspectGitWorktree(worktreePath);
@@ -19132,11 +19248,11 @@ new file mode 100644
19132
19248
  };
19133
19249
  }
19134
19250
  async function untrackedPatch(worktreePath, path, maxHunk) {
19135
- const abs = (0, import_node_path46.join)(worktreePath, path);
19251
+ const abs = (0, import_node_path47.join)(worktreePath, path);
19136
19252
  try {
19137
- const st = (0, import_node_fs47.statSync)(abs);
19253
+ const st = (0, import_node_fs49.statSync)(abs);
19138
19254
  if (st.isFile() && st.size > maxHunk) {
19139
- const buf = (0, import_node_fs47.readFileSync)(abs).subarray(0, maxHunk);
19255
+ const buf = (0, import_node_fs49.readFileSync)(abs).subarray(0, maxHunk);
19140
19256
  return syntheticAddPatch(path, buf.toString("utf8"), maxHunk);
19141
19257
  }
19142
19258
  } catch {
@@ -19603,9 +19719,9 @@ async function getDiff(worktreePath, repoPath, opts) {
19603
19719
  }
19604
19720
  function statWorktreePath(worktreePath, relativePath) {
19605
19721
  assertSafeRelativePath(relativePath);
19606
- const abs = (0, import_node_path46.join)(worktreePath, relativePath);
19607
- if (!(0, import_node_fs47.existsSync)(abs)) return "missing";
19608
- const st = (0, import_node_fs47.statSync)(abs);
19722
+ const abs = (0, import_node_path47.join)(worktreePath, relativePath);
19723
+ if (!(0, import_node_fs49.existsSync)(abs)) return "missing";
19724
+ const st = (0, import_node_fs49.statSync)(abs);
19609
19725
  if (st.isDirectory()) return "dir";
19610
19726
  if (st.isFile()) return "file";
19611
19727
  return "missing";
@@ -19634,8 +19750,8 @@ function isImageRelativePath(relativePath) {
19634
19750
  function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
19635
19751
  assertSafeRelativePath(relativePath);
19636
19752
  const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
19637
- const abs = (0, import_node_path46.join)(worktreePath, relativePath);
19638
- const st = (0, import_node_fs47.statSync)(abs);
19753
+ const abs = (0, import_node_path47.join)(worktreePath, relativePath);
19754
+ const st = (0, import_node_fs49.statSync)(abs);
19639
19755
  if (!st.isFile()) {
19640
19756
  throw new Error(`Not a file: ${relativePath}`);
19641
19757
  }
@@ -19644,7 +19760,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
19644
19760
  `File too large to upload (${st.size} bytes; max ${maxBytes})`
19645
19761
  );
19646
19762
  }
19647
- const buf = (0, import_node_fs47.readFileSync)(abs);
19763
+ const buf = (0, import_node_fs49.readFileSync)(abs);
19648
19764
  return {
19649
19765
  path: relativePath,
19650
19766
  contentBase64: buf.toString("base64"),
@@ -19654,12 +19770,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
19654
19770
  function readWorktreeFile(worktreePath, relativePath, opts) {
19655
19771
  assertSafeRelativePath(relativePath);
19656
19772
  const maxBytes = opts?.maxBytes ?? 2e5;
19657
- const abs = (0, import_node_path46.join)(worktreePath, relativePath);
19658
- const st = (0, import_node_fs47.statSync)(abs);
19773
+ const abs = (0, import_node_path47.join)(worktreePath, relativePath);
19774
+ const st = (0, import_node_fs49.statSync)(abs);
19659
19775
  if (!st.isFile()) {
19660
19776
  throw new Error(`Not a file: ${relativePath}`);
19661
19777
  }
19662
- const buf = (0, import_node_fs47.readFileSync)(abs);
19778
+ const buf = (0, import_node_fs49.readFileSync)(abs);
19663
19779
  if (isImageRelativePath(relativePath)) {
19664
19780
  const maxImageBytes = Math.max(maxBytes, 15e6);
19665
19781
  const truncated2 = buf.length > maxImageBytes;
@@ -19702,9 +19818,9 @@ function assertSafeRelativePath(relativePath) {
19702
19818
  }
19703
19819
  function writeWorktreeFile(worktreePath, relativePath, content) {
19704
19820
  assertSafeRelativePath(relativePath);
19705
- const abs = (0, import_node_path46.join)(worktreePath, relativePath);
19706
- (0, import_node_fs47.mkdirSync)((0, import_node_path46.dirname)(abs), { recursive: true });
19707
- (0, import_node_fs47.writeFileSync)(abs, content, "utf8");
19821
+ const abs = (0, import_node_path47.join)(worktreePath, relativePath);
19822
+ (0, import_node_fs49.mkdirSync)((0, import_node_path47.dirname)(abs), { recursive: true });
19823
+ (0, import_node_fs49.writeFileSync)(abs, content, "utf8");
19708
19824
  return { path: relativePath };
19709
19825
  }
19710
19826
  async function getWorktreeDirtyStat(worktreePath) {
@@ -19744,12 +19860,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
19744
19860
  truncated: full.files.length > maxFiles
19745
19861
  };
19746
19862
  }
19747
- var import_node_fs47, import_node_path46, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
19863
+ var import_node_fs49, import_node_path47, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
19748
19864
  var init_diff = __esm({
19749
19865
  "src/diff/diff.ts"() {
19750
19866
  "use strict";
19751
- import_node_fs47 = require("fs");
19752
- import_node_path46 = require("path");
19867
+ import_node_fs49 = require("fs");
19868
+ import_node_path47 = require("path");
19753
19869
  init_run();
19754
19870
  init_worktree();
19755
19871
  mergeBaseCache = /* @__PURE__ */ new Map();
@@ -20106,7 +20222,7 @@ function parseFrontmatter(content) {
20106
20222
  }
20107
20223
  function readSkill(skillMd, source) {
20108
20224
  try {
20109
- const content = (0, import_node_fs48.readFileSync)(skillMd, "utf8");
20225
+ const content = (0, import_node_fs50.readFileSync)(skillMd, "utf8");
20110
20226
  const { name: fmName, description } = parseFrontmatter(content);
20111
20227
  const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
20112
20228
  const name = fmName || dirName;
@@ -20125,19 +20241,19 @@ function readSkill(skillMd, source) {
20125
20241
  }
20126
20242
  }
20127
20243
  function scanSkillsDir(dir, source, out) {
20128
- if (!(0, import_node_fs48.existsSync)(dir)) return;
20244
+ if (!(0, import_node_fs50.existsSync)(dir)) return;
20129
20245
  let entries;
20130
20246
  try {
20131
- entries = (0, import_node_fs48.readdirSync)(dir);
20247
+ entries = (0, import_node_fs50.readdirSync)(dir);
20132
20248
  } catch {
20133
20249
  return;
20134
20250
  }
20135
20251
  for (const entry of entries) {
20136
20252
  if (entry.startsWith(".")) continue;
20137
- const skillMd = (0, import_node_path47.join)(dir, entry, "SKILL.md");
20138
- if (!(0, import_node_fs48.existsSync)(skillMd)) continue;
20253
+ const skillMd = (0, import_node_path48.join)(dir, entry, "SKILL.md");
20254
+ if (!(0, import_node_fs50.existsSync)(skillMd)) continue;
20139
20255
  try {
20140
- if (!(0, import_node_fs48.statSync)(skillMd).isFile()) continue;
20256
+ if (!(0, import_node_fs50.statSync)(skillMd).isFile()) continue;
20141
20257
  } catch {
20142
20258
  continue;
20143
20259
  }
@@ -20146,24 +20262,24 @@ function scanSkillsDir(dir, source, out) {
20146
20262
  }
20147
20263
  }
20148
20264
  function scanClaudePluginSkills(pluginsRoot, out) {
20149
- if (!(0, import_node_fs48.existsSync)(pluginsRoot)) return;
20265
+ if (!(0, import_node_fs50.existsSync)(pluginsRoot)) return;
20150
20266
  const walk = (dir, depth, lookingForSkillsDir) => {
20151
20267
  if (depth > 7) return;
20152
20268
  let entries;
20153
20269
  try {
20154
- entries = (0, import_node_fs48.readdirSync)(dir);
20270
+ entries = (0, import_node_fs50.readdirSync)(dir);
20155
20271
  } catch {
20156
20272
  return;
20157
20273
  }
20158
20274
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
20159
- const skill = readSkill((0, import_node_path47.join)(dir, "SKILL.md"), "cli");
20275
+ const skill = readSkill((0, import_node_path48.join)(dir, "SKILL.md"), "cli");
20160
20276
  if (skill) out.push(skill);
20161
20277
  }
20162
20278
  for (const entry of entries) {
20163
20279
  if (entry === "node_modules" || entry === ".git") continue;
20164
- const full = (0, import_node_path47.join)(dir, entry);
20280
+ const full = (0, import_node_path48.join)(dir, entry);
20165
20281
  try {
20166
- if (!(0, import_node_fs48.statSync)(full).isDirectory()) continue;
20282
+ if (!(0, import_node_fs50.statSync)(full).isDirectory()) continue;
20167
20283
  } catch {
20168
20284
  continue;
20169
20285
  }
@@ -20181,17 +20297,17 @@ function discoverSkills(worktreePath) {
20181
20297
  const home = (0, import_node_os15.homedir)();
20182
20298
  const collected = [];
20183
20299
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
20184
- scanSkillsDir((0, import_node_path47.join)(worktreePath, rel), "workspace", collected);
20300
+ scanSkillsDir((0, import_node_path48.join)(worktreePath, rel), "workspace", collected);
20185
20301
  }
20186
20302
  for (const abs of [
20187
- (0, import_node_path47.join)(home, ".claude/skills"),
20188
- (0, import_node_path47.join)(home, ".cursor/skills"),
20189
- (0, import_node_path47.join)(home, ".sideboard/skills"),
20190
- (0, import_node_path47.join)(home, ".brightsy/skills")
20303
+ (0, import_node_path48.join)(home, ".claude/skills"),
20304
+ (0, import_node_path48.join)(home, ".cursor/skills"),
20305
+ (0, import_node_path48.join)(home, ".sideboard/skills"),
20306
+ (0, import_node_path48.join)(home, ".brightsy/skills")
20191
20307
  ]) {
20192
20308
  scanSkillsDir(abs, "user", collected);
20193
20309
  }
20194
- scanClaudePluginSkills((0, import_node_path47.join)(home, ".claude/plugins"), collected);
20310
+ scanClaudePluginSkills((0, import_node_path48.join)(home, ".claude/plugins"), collected);
20195
20311
  collected.push(...bundledSkills());
20196
20312
  const rank = {
20197
20313
  workspace: 0,
@@ -20217,7 +20333,7 @@ function readSkillBody(skillPath, maxChars = 12e3) {
20217
20333
  \u2026(truncated)` : body;
20218
20334
  }
20219
20335
  }
20220
- const raw = (0, import_node_fs48.readFileSync)(skillPath, "utf8");
20336
+ const raw = (0, import_node_fs50.readFileSync)(skillPath, "utf8");
20221
20337
  if (raw.startsWith("---")) {
20222
20338
  const end = raw.indexOf("\n---", 3);
20223
20339
  if (end >= 0) {
@@ -20231,13 +20347,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
20231
20347
 
20232
20348
  \u2026(truncated)` : raw;
20233
20349
  }
20234
- var import_node_fs48, import_node_os15, import_node_path47, BUNDLED_SKILL_PREFIX;
20350
+ var import_node_fs50, import_node_os15, import_node_path48, BUNDLED_SKILL_PREFIX;
20235
20351
  var init_discover = __esm({
20236
20352
  "src/skills/discover.ts"() {
20237
20353
  "use strict";
20238
- import_node_fs48 = require("fs");
20354
+ import_node_fs50 = require("fs");
20239
20355
  import_node_os15 = require("os");
20240
- import_node_path47 = require("path");
20356
+ import_node_path48 = require("path");
20241
20357
  init_long_running();
20242
20358
  BUNDLED_SKILL_PREFIX = "bundled:";
20243
20359
  }
@@ -20390,9 +20506,9 @@ function compiledModuleDir() {
20390
20506
  const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
20391
20507
  if (cjsDir) return cjsDir;
20392
20508
  try {
20393
- const url = import_meta3.url;
20509
+ const url = import_meta4.url;
20394
20510
  if (typeof url === "string" && url.length > 0) {
20395
- return (0, import_node_path48.dirname)((0, import_node_url3.fileURLToPath)(url));
20511
+ return (0, import_node_path49.dirname)((0, import_node_url4.fileURLToPath)(url));
20396
20512
  }
20397
20513
  } catch {
20398
20514
  }
@@ -20400,8 +20516,8 @@ function compiledModuleDir() {
20400
20516
  }
20401
20517
  function detachedJobScriptIn(dir) {
20402
20518
  for (const name of DETACHED_JOB_FILENAMES) {
20403
- const script = (0, import_node_path48.join)(dir, "scripts", name);
20404
- if ((0, import_node_fs49.existsSync)(script)) return script;
20519
+ const script = (0, import_node_path49.join)(dir, "scripts", name);
20520
+ if ((0, import_node_fs51.existsSync)(script)) return script;
20405
20521
  }
20406
20522
  return null;
20407
20523
  }
@@ -20418,7 +20534,7 @@ function resolveDetachedJobScript() {
20418
20534
  for (let i = 0; i < 8; i++) {
20419
20535
  const candidate = detachedJobScriptIn(dir);
20420
20536
  if (candidate) return candidate;
20421
- const parent = (0, import_node_path48.dirname)(dir);
20537
+ const parent = (0, import_node_path49.dirname)(dir);
20422
20538
  if (parent === dir) break;
20423
20539
  dir = parent;
20424
20540
  }
@@ -20429,15 +20545,15 @@ function formatDetachedJobInvoke(scriptPath) {
20429
20545
  if (resolved) return `node ${JSON.stringify(resolved)}`;
20430
20546
  return "node scripts/detached-job.cjs";
20431
20547
  }
20432
- var import_node_fs49, import_node_path48, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
20548
+ var import_node_fs51, import_node_path49, import_node_url4, import_meta4, DETACHED_JOB_FILENAMES;
20433
20549
  var init_detached_job_path = __esm({
20434
20550
  "src/skills/detached-job-path.ts"() {
20435
20551
  "use strict";
20436
- import_node_fs49 = require("fs");
20437
- import_node_path48 = require("path");
20438
- import_node_url3 = require("url");
20552
+ import_node_fs51 = require("fs");
20553
+ import_node_path49 = require("path");
20554
+ import_node_url4 = require("url");
20439
20555
  init_packaged_runtime();
20440
- import_meta3 = {};
20556
+ import_meta4 = {};
20441
20557
  DETACHED_JOB_FILENAMES = ["detached-job.cjs", "detached-job.js"];
20442
20558
  }
20443
20559
  });
@@ -20594,9 +20710,9 @@ function formatPrGateDirective() {
20594
20710
  }
20595
20711
  function formatProcessGuideDirective(opts) {
20596
20712
  const worktree = opts?.worktreePath?.trim();
20597
- const hasGraphSkill = !!worktree && (0, import_node_fs50.existsSync)((0, import_node_path49.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
20598
- const hasReviewSkill = !!worktree && (0, import_node_fs50.existsSync)((0, import_node_path49.join)(worktree, ".claude/skills/review/SKILL.md"));
20599
- const hasInstallSkill = !!worktree && (0, import_node_fs50.existsSync)((0, import_node_path49.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
20713
+ const hasGraphSkill = !!worktree && (0, import_node_fs52.existsSync)((0, import_node_path50.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
20714
+ const hasReviewSkill = !!worktree && (0, import_node_fs52.existsSync)((0, import_node_path50.join)(worktree, ".claude/skills/review/SKILL.md"));
20715
+ const hasInstallSkill = !!worktree && (0, import_node_fs52.existsSync)((0, import_node_path50.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
20600
20716
  return [
20601
20717
  "Process guides (recurring work only):",
20602
20718
  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,
@@ -20635,12 +20751,12 @@ function formatArtifactDirective() {
20635
20751
  function formatUiReminder() {
20636
20752
  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). ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. Do not say artifacts/CMS UI are unavailable. Dev / preview: run_dev_script (same as the Dev button); stop_dev_script to stop.";
20637
20753
  }
20638
- var import_node_fs50, import_node_path49, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
20754
+ var import_node_fs52, import_node_path50, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
20639
20755
  var init_instructions = __esm({
20640
20756
  "src/agents/instructions.ts"() {
20641
20757
  "use strict";
20642
- import_node_fs50 = require("fs");
20643
- import_node_path49 = require("path");
20758
+ import_node_fs52 = require("fs");
20759
+ import_node_path50 = require("path");
20644
20760
  init_git_auth_mode();
20645
20761
  init_branch_prefix();
20646
20762
  init_worktree_labels();
@@ -20864,40 +20980,40 @@ __export(plan_file_exports, {
20864
20980
  writePlanFile: () => writePlanFile
20865
20981
  });
20866
20982
  function ensureAttachmentsGitignore(worktreePath) {
20867
- const gitignoreAbs = (0, import_node_path50.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
20868
- if ((0, import_node_fs51.existsSync)(gitignoreAbs)) return;
20869
- (0, import_node_fs51.mkdirSync)((0, import_node_path50.dirname)(gitignoreAbs), { recursive: true });
20870
- (0, import_node_fs51.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
20983
+ const gitignoreAbs = (0, import_node_path51.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
20984
+ if ((0, import_node_fs53.existsSync)(gitignoreAbs)) return;
20985
+ (0, import_node_fs53.mkdirSync)((0, import_node_path51.dirname)(gitignoreAbs), { recursive: true });
20986
+ (0, import_node_fs53.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
20871
20987
  }
20872
20988
  function planFileAbs(worktreePath) {
20873
- return (0, import_node_path50.join)(worktreePath, PLAN_FILE_REL);
20989
+ return (0, import_node_path51.join)(worktreePath, PLAN_FILE_REL);
20874
20990
  }
20875
20991
  function readTextIfPresent2(abs) {
20876
- if (!(0, import_node_fs51.existsSync)(abs)) return null;
20992
+ if (!(0, import_node_fs53.existsSync)(abs)) return null;
20877
20993
  try {
20878
- const content = (0, import_node_fs51.readFileSync)(abs, "utf8");
20994
+ const content = (0, import_node_fs53.readFileSync)(abs, "utf8");
20879
20995
  return content.trim() ? content : null;
20880
20996
  } catch {
20881
20997
  return null;
20882
20998
  }
20883
20999
  }
20884
21000
  function readPlanFile(worktreePath) {
20885
- return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path50.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path50.join)(worktreePath, LEGACY_PLAN_FILE_REL));
21001
+ return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path51.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path51.join)(worktreePath, LEGACY_PLAN_FILE_REL));
20886
21002
  }
20887
21003
  function writePlanFile(worktreePath, content) {
20888
21004
  ensureAttachmentsGitignore(worktreePath);
20889
21005
  const abs = planFileAbs(worktreePath);
20890
- (0, import_node_fs51.mkdirSync)((0, import_node_path50.dirname)(abs), { recursive: true });
21006
+ (0, import_node_fs53.mkdirSync)((0, import_node_path51.dirname)(abs), { recursive: true });
20891
21007
  const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
20892
- (0, import_node_fs51.writeFileSync)(abs, body, "utf8");
21008
+ (0, import_node_fs53.writeFileSync)(abs, body, "utf8");
20893
21009
  return PLAN_FILE_REL;
20894
21010
  }
20895
- var import_node_fs51, import_node_path50;
21011
+ var import_node_fs53, import_node_path51;
20896
21012
  var init_plan_file = __esm({
20897
21013
  "src/plan/plan-file.ts"() {
20898
21014
  "use strict";
20899
- import_node_fs51 = require("fs");
20900
- import_node_path50 = require("path");
21015
+ import_node_fs53 = require("fs");
21016
+ import_node_path51 = require("path");
20901
21017
  init_workspace_scratch();
20902
21018
  init_plan_present();
20903
21019
  init_plan_present();
@@ -20957,7 +21073,7 @@ function setCaffeinateHoldHooks(next) {
20957
21073
  hooks = next;
20958
21074
  }
20959
21075
  function caffeinateHoldPath() {
20960
- return (0, import_node_path51.join)(appDataDir(), "caffeinate-hold.json");
21076
+ return (0, import_node_path52.join)(appDataDir(), "caffeinate-hold.json");
20961
21077
  }
20962
21078
  function processAlive(pid) {
20963
21079
  if (hooks.processAlive) return hooks.processAlive(pid);
@@ -20991,9 +21107,9 @@ function uniqueIds(ids) {
20991
21107
  }
20992
21108
  function readHold() {
20993
21109
  const path = caffeinateHoldPath();
20994
- if (!(0, import_node_fs52.existsSync)(path)) return null;
21110
+ if (!(0, import_node_fs54.existsSync)(path)) return null;
20995
21111
  try {
20996
- const parsed = JSON.parse((0, import_node_fs52.readFileSync)(path, "utf8"));
21112
+ const parsed = JSON.parse((0, import_node_fs54.readFileSync)(path, "utf8"));
20997
21113
  if (typeof parsed?.pid === "number" && parsed.pid > 0) {
20998
21114
  return {
20999
21115
  pid: parsed.pid,
@@ -21015,7 +21131,7 @@ function writeHold(pid, threadIds) {
21015
21131
  }
21016
21132
  function clearHold() {
21017
21133
  try {
21018
- (0, import_node_fs52.unlinkSync)(caffeinateHoldPath());
21134
+ (0, import_node_fs54.unlinkSync)(caffeinateHoldPath());
21019
21135
  } catch {
21020
21136
  }
21021
21137
  }
@@ -21100,13 +21216,13 @@ function releaseCaffeinateHoldForThread(threadId) {
21100
21216
  }
21101
21217
  return setCaffeinateHold(false, { threadId: id });
21102
21218
  }
21103
- var import_node_child_process6, import_node_fs52, import_node_path51, hooks;
21219
+ var import_node_child_process6, import_node_fs54, import_node_path52, hooks;
21104
21220
  var init_caffeinate_hold = __esm({
21105
21221
  "src/store/caffeinate-hold.ts"() {
21106
21222
  "use strict";
21107
21223
  import_node_child_process6 = require("child_process");
21108
- import_node_fs52 = require("fs");
21109
- import_node_path51 = require("path");
21224
+ import_node_fs54 = require("fs");
21225
+ import_node_path52 = require("path");
21110
21226
  init_paths();
21111
21227
  init_private_file();
21112
21228
  hooks = {};
@@ -21115,7 +21231,7 @@ var init_caffeinate_hold = __esm({
21115
21231
 
21116
21232
  // src/store/schedules.ts
21117
21233
  function schedulesPath() {
21118
- return (0, import_node_path52.join)(appDataDir(), "schedules.json");
21234
+ return (0, import_node_path53.join)(appDataDir(), "schedules.json");
21119
21235
  }
21120
21236
  function parseDurationMs(every) {
21121
21237
  const m = every.trim().match(DURATION_RE);
@@ -21215,9 +21331,9 @@ function normalizeTask(raw) {
21215
21331
  }
21216
21332
  function readAll2() {
21217
21333
  const path = schedulesPath();
21218
- if (!(0, import_node_fs53.existsSync)(path)) return [];
21334
+ if (!(0, import_node_fs55.existsSync)(path)) return [];
21219
21335
  try {
21220
- const parsed = JSON.parse((0, import_node_fs53.readFileSync)(path, "utf8"));
21336
+ const parsed = JSON.parse((0, import_node_fs55.readFileSync)(path, "utf8"));
21221
21337
  if (!Array.isArray(parsed)) return [];
21222
21338
  return parsed.map((row) => {
21223
21339
  try {
@@ -21329,13 +21445,13 @@ function recordScheduleRun(id, result) {
21329
21445
  writeAll2(rows);
21330
21446
  return next;
21331
21447
  }
21332
- var import_node_crypto11, import_node_fs53, import_node_path52, import_croner, DURATION_RE, UNIT_MS;
21448
+ var import_node_crypto11, import_node_fs55, import_node_path53, import_croner, DURATION_RE, UNIT_MS;
21333
21449
  var init_schedules = __esm({
21334
21450
  "src/store/schedules.ts"() {
21335
21451
  "use strict";
21336
21452
  import_node_crypto11 = require("crypto");
21337
- import_node_fs53 = require("fs");
21338
- import_node_path52 = require("path");
21453
+ import_node_fs55 = require("fs");
21454
+ import_node_path53 = require("path");
21339
21455
  import_croner = require("croner");
21340
21456
  init_orchestrator_capable();
21341
21457
  init_paths();
@@ -21491,9 +21607,9 @@ function recoverFinishedCursorRun(opts) {
21491
21607
  return best;
21492
21608
  }
21493
21609
  function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
21494
- if (!(0, import_node_fs54.existsSync)(runsPath)) return null;
21610
+ if (!(0, import_node_fs56.existsSync)(runsPath)) return null;
21495
21611
  try {
21496
- const lines = (0, import_node_fs54.readFileSync)(runsPath, "utf8").split("\n");
21612
+ const lines = (0, import_node_fs56.readFileSync)(runsPath, "utf8").split("\n");
21497
21613
  let best = null;
21498
21614
  for (const line of lines) {
21499
21615
  const trimmed = line.trim();
@@ -21519,11 +21635,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
21519
21635
  return null;
21520
21636
  }
21521
21637
  }
21522
- var import_node_fs54;
21638
+ var import_node_fs56;
21523
21639
  var init_cursor_recover = __esm({
21524
21640
  "src/agents/cursor-recover.ts"() {
21525
21641
  "use strict";
21526
- import_node_fs54 = require("fs");
21642
+ import_node_fs56 = require("fs");
21527
21643
  init_cursor_store();
21528
21644
  }
21529
21645
  });
@@ -21677,14 +21793,14 @@ async function startOrchestration(opts) {
21677
21793
  }
21678
21794
  return updated;
21679
21795
  }
21680
- var import_node_events, import_node_crypto12, import_node_fs55, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton;
21796
+ var import_node_events, import_node_crypto12, import_node_fs57, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton;
21681
21797
  var init_orchestrator = __esm({
21682
21798
  "src/orchestrator/orchestrator.ts"() {
21683
21799
  "use strict";
21684
21800
  import_node_events = require("events");
21685
21801
  init_outbound_watch();
21686
21802
  import_node_crypto12 = require("crypto");
21687
- import_node_fs55 = require("fs");
21803
+ import_node_fs57 = require("fs");
21688
21804
  init_error_detail();
21689
21805
  init_run();
21690
21806
  init_stale_lock();
@@ -21861,7 +21977,7 @@ var init_orchestrator = __esm({
21861
21977
  this.lightReconcileAt.set(repoPath, Date.now());
21862
21978
  for (const thread of listThreads()) {
21863
21979
  if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
21864
- if (!(0, import_node_fs55.existsSync)(thread.worktreePath)) {
21980
+ if (!(0, import_node_fs57.existsSync)(thread.worktreePath)) {
21865
21981
  setStatus(thread.id, "broken", "Worktree missing on disk");
21866
21982
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
21867
21983
  }
@@ -21890,7 +22006,7 @@ var init_orchestrator = __esm({
21890
22006
  }
21891
22007
  continue;
21892
22008
  }
21893
- if (!(0, import_node_fs55.existsSync)(thread.worktreePath)) {
22009
+ if (!(0, import_node_fs57.existsSync)(thread.worktreePath)) {
21894
22010
  setStatus(thread.id, "broken", "Worktree missing on disk");
21895
22011
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
21896
22012
  continue;
@@ -24181,7 +24297,7 @@ var init_orchestrator = __esm({
24181
24297
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
24182
24298
  return restored2;
24183
24299
  }
24184
- if (!(0, import_node_fs55.existsSync)(thread.worktreePath)) {
24300
+ if (!(0, import_node_fs57.existsSync)(thread.worktreePath)) {
24185
24301
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
24186
24302
  throw new Error(
24187
24303
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
@@ -24265,7 +24381,7 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
24265
24381
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
24266
24382
  var import_zod9 = require("zod");
24267
24383
  var import_node_crypto15 = require("crypto");
24268
- var import_node_path55 = require("path");
24384
+ var import_node_path56 = require("path");
24269
24385
  init_orchestrator();
24270
24386
  init_worktree();
24271
24387
 
@@ -27685,27 +27801,27 @@ init_gh_errors();
27685
27801
  init_git_auth_mode();
27686
27802
 
27687
27803
  // src/board/load-home-board.ts
27688
- var import_node_fs57 = require("fs");
27689
- var import_node_path54 = require("path");
27804
+ var import_node_fs59 = require("fs");
27805
+ var import_node_path55 = require("path");
27690
27806
  init_worktree();
27691
27807
  init_paths();
27692
27808
 
27693
27809
  // src/board/board-pins.ts
27694
27810
  var import_node_crypto14 = require("crypto");
27695
- var import_node_fs56 = require("fs");
27696
- var import_node_path53 = require("path");
27811
+ var import_node_fs58 = require("fs");
27812
+ var import_node_path54 = require("path");
27697
27813
  init_paths();
27698
27814
  init_home_board();
27699
27815
  var FILE = "home-board-pins.json";
27700
27816
  var VERSION = 1;
27701
27817
  function pinsFile() {
27702
- return (0, import_node_path53.join)(appDataDir(), FILE);
27818
+ return (0, import_node_path54.join)(appDataDir(), FILE);
27703
27819
  }
27704
27820
  function readDisk() {
27705
27821
  const path = pinsFile();
27706
- if (!(0, import_node_fs56.existsSync)(path)) return [];
27822
+ if (!(0, import_node_fs58.existsSync)(path)) return [];
27707
27823
  try {
27708
- const raw = JSON.parse((0, import_node_fs56.readFileSync)(path, "utf8"));
27824
+ const raw = JSON.parse((0, import_node_fs58.readFileSync)(path, "utf8"));
27709
27825
  if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
27710
27826
  return raw.items.filter((item) => item?.id && item.kind && item.ref);
27711
27827
  } catch {
@@ -27713,8 +27829,8 @@ function readDisk() {
27713
27829
  }
27714
27830
  }
27715
27831
  function writeDisk(items) {
27716
- (0, import_node_fs56.mkdirSync)(appDataDir(), { recursive: true });
27717
- (0, import_node_fs56.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
27832
+ (0, import_node_fs58.mkdirSync)(appDataDir(), { recursive: true });
27833
+ (0, import_node_fs58.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
27718
27834
  }
27719
27835
  function listBoardPins() {
27720
27836
  return readDisk();
@@ -27735,7 +27851,7 @@ function homeBoardWorkspaceKey(workspaces) {
27735
27851
  return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
27736
27852
  }
27737
27853
  function cacheFile() {
27738
- return (0, import_node_path54.join)(appDataDir(), "home-board-cache.json");
27854
+ return (0, import_node_path55.join)(appDataDir(), "home-board-cache.json");
27739
27855
  }
27740
27856
  function emptyInputs() {
27741
27857
  return {
@@ -27761,9 +27877,9 @@ function shouldCacheHomeBoardInputs(inputs) {
27761
27877
  }
27762
27878
  function readDiskCache() {
27763
27879
  const path = cacheFile();
27764
- if (!(0, import_node_fs57.existsSync)(path)) return null;
27880
+ if (!(0, import_node_fs59.existsSync)(path)) return null;
27765
27881
  try {
27766
- const raw = JSON.parse((0, import_node_fs57.readFileSync)(path, "utf8"));
27882
+ const raw = JSON.parse((0, import_node_fs59.readFileSync)(path, "utf8"));
27767
27883
  if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
27768
27884
  return null;
27769
27885
  }
@@ -27777,8 +27893,8 @@ function readDiskCache() {
27777
27893
  }
27778
27894
  function writeDiskCache(entry) {
27779
27895
  try {
27780
- (0, import_node_fs57.mkdirSync)(appDataDir(), { recursive: true });
27781
- (0, import_node_fs57.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
27896
+ (0, import_node_fs59.mkdirSync)(appDataDir(), { recursive: true });
27897
+ (0, import_node_fs59.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
27782
27898
  } catch {
27783
27899
  }
27784
27900
  }
@@ -28165,7 +28281,7 @@ async function startMcpServer() {
28165
28281
  async () => {
28166
28282
  const threads = orch.getThreads(true);
28167
28283
  const lines = threads.map((t) => {
28168
- const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path55.basename)(t.repoPath) || t.repoPath;
28284
+ const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path56.basename)(t.repoPath) || t.repoPath;
28169
28285
  const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
28170
28286
  const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
28171
28287
  const preview = lastMessagePreview(t.messages, 80);