opencode-swarm 7.144.4 → 7.144.6

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 (106) hide show
  1. package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +2 -2
  2. package/dist/background/workspace-snapshot.d.ts +7 -0
  3. package/dist/cli/{capability-probe-f1paszww.js → capability-probe-976tt4ba.js} +6 -2
  4. package/dist/cli/{config-doctor-rw9zrjk6.js → config-doctor-4chz0b95.js} +2 -2
  5. package/dist/cli/{core-zjx9aqaf.js → core-p04nvknr.js} +4 -3
  6. package/dist/cli/{curation-policy-0wbrh11c.js → curation-policy-a511r0qz.js} +4 -4
  7. package/dist/cli/{curator-drift-2jbjv03a.js → curator-drift-ckjm272w.js} +2 -2
  8. package/dist/cli/curator-llm-factory-vc1mrc3r.js +63 -0
  9. package/dist/cli/{curator-g54a7wv0.js → curator-sxeh36gw.js} +33 -32
  10. package/dist/cli/{dispatch-1y1rnv1h.js → dispatch-ndxbsk98.js} +2 -2
  11. package/dist/cli/{evidence-summary-service-fnr5y54e.js → evidence-summary-service-spyxcgsx.js} +13 -12
  12. package/dist/cli/{gate-evidence-2xt1x07r.js → gate-evidence-nz0bwa15.js} +7 -6
  13. package/dist/cli/guardrail-explain-ass47kn8.js +64 -0
  14. package/dist/cli/{guardrail-log-5w4b9zrw.js → guardrail-log-fyzd55fp.js} +4 -4
  15. package/dist/cli/{hive-promoter-x63ehffd.js → hive-promoter-k8gtah3n.js} +33 -32
  16. package/dist/cli/{index-h98t1m88.js → index-01nhedm7.js} +29 -1
  17. package/dist/cli/{index-q4ed1jk7.js → index-42ezdzam.js} +1994 -1333
  18. package/dist/cli/{index-y8j8ehc8.js → index-68mqwvf5.js} +11 -5
  19. package/dist/cli/{index-1csyxv0f.js → index-6z5jtf7d.js} +2 -2
  20. package/dist/cli/{index-2m7mavaz.js → index-7zehmnv1.js} +2 -2
  21. package/dist/cli/index-9e6fdz2h.js +282 -0
  22. package/dist/cli/{index-mazgg5s2.js → index-9s8drsf9.js} +1 -1
  23. package/dist/cli/{index-b6e016tv.js → index-abtrcs16.js} +1 -1
  24. package/dist/cli/{index-8fwhhayc.js → index-b44qqqt2.js} +27 -18
  25. package/dist/cli/{index-yts89pqg.js → index-bac12jpv.js} +4 -4
  26. package/dist/cli/{index-psvxq93b.js → index-ckq719fr.js} +2 -2
  27. package/dist/cli/{index-k3cxyk66.js → index-cwtpqm5f.js} +1 -1
  28. package/dist/cli/{index-d12jd5mn.js → index-dj8cah6s.js} +1 -1
  29. package/dist/cli/{index-pw83zgny.js → index-dvybg11w.js} +3 -3
  30. package/dist/cli/{index-03pv47h2.js → index-ec1kywxg.js} +6 -6
  31. package/dist/cli/{index-74hpm6sh.js → index-f36ybbsv.js} +12 -6
  32. package/dist/cli/{index-az8etqpp.js → index-fgdhf6a5.js} +298 -1179
  33. package/dist/cli/{index-rn0eq85g.js → index-fv0s19g9.js} +1 -1
  34. package/dist/cli/{index-ywn7vtxp.js → index-h1p08s3n.js} +1 -1
  35. package/dist/cli/{index-nckg4gxb.js → index-h5krb653.js} +15 -4
  36. package/dist/cli/{index-bt9aa01f.js → index-hkdgkkhb.js} +1 -1
  37. package/dist/cli/{index-p7cm3gtj.js → index-jqvsh0g3.js} +35 -34
  38. package/dist/cli/{index-x6tp0hfr.js → index-n06653nr.js} +5 -5
  39. package/dist/cli/{index-jabkn643.js → index-n4hwcsbd.js} +2 -2
  40. package/dist/cli/{index-z6v7kwpa.js → index-q6bhmyxb.js} +1 -1
  41. package/dist/cli/{index-cz25e8xp.js → index-sqe3nqh5.js} +166 -34
  42. package/dist/cli/{index-q67jb94n.js → index-sswzhcqb.js} +1 -1
  43. package/dist/cli/{index-8j0va7jp.js → index-tq89td7b.js} +43 -22
  44. package/dist/cli/{index-dty5qgk2.js → index-vdha477y.js} +1 -1
  45. package/dist/cli/{index-zb0xcz9t.js → index-vngs0meh.js} +3 -3
  46. package/dist/cli/{index-fqcjragy.js → index-wknz5c8q.js} +1 -1
  47. package/dist/cli/{index-9qq7c18c.js → index-ytzz6pq1.js} +36 -1
  48. package/dist/cli/{index-4w5qdbk7.js → index-zde2mkmg.js} +6 -6
  49. package/dist/cli/{index-4nt52yr9.js → index-zj6t9zgx.js} +173 -25
  50. package/dist/cli/{index-btmsqv7p.js → index-zxr5r9b7.js} +5 -4
  51. package/dist/cli/index-zy7f84cs.js +1210 -0
  52. package/dist/cli/index.d.ts +11 -1
  53. package/dist/cli/index.js +61 -39
  54. package/dist/cli/{knowledge-escalator-ypg14d5r.js → knowledge-escalator-yaxzz0k5.js} +12 -11
  55. package/dist/cli/{knowledge-events-nkrym4wb.js → knowledge-events-rgcwewpn.js} +10 -9
  56. package/dist/cli/{knowledge-link-e4qgqmpx.js → knowledge-link-4cg4776a.js} +3 -3
  57. package/dist/cli/{knowledge-store-vh3nhtg2.js → knowledge-store-qf8t25sw.js} +4 -4
  58. package/dist/cli/{knowledge-validator-jrxvexv6.js → knowledge-validator-dx6zzcdf.js} +6 -6
  59. package/dist/cli/{pending-delegations-pw79c8ds.js → pending-delegations-9h1jmtw1.js} +3 -3
  60. package/dist/cli/{pr-subscriptions-fk628bhc.js → pr-subscriptions-8pg34pev.js} +3 -3
  61. package/dist/cli/{runner-b02sz2vx.js → runner-cqecp1na.js} +4 -4
  62. package/dist/cli/{scan-cursor-fp7w5jmc.js → scan-cursor-pbcaj8hj.js} +7 -5
  63. package/dist/cli/{schema-rptwqbm4.js → schema-tzcjwe8j.js} +3 -1
  64. package/dist/cli/{scope-persistence-0bkaxawa.js → scope-persistence-mjg4we75.js} +7 -6
  65. package/dist/cli/{skill-generator-nh8b4gjv.js → skill-generator-7jrzbaej.js} +14 -13
  66. package/dist/cli/{workspace-snapshot-w3tg4ne5.js → workspace-snapshot-d89zm6wm.js} +5 -2
  67. package/dist/cli/{worktree-collision-ownership-hqd9ypsz.js → worktree-collision-ownership-vy0kxa98.js} +26 -19
  68. package/dist/cli/{worktree-isolation-canf3rj8.js → worktree-isolation-awpkp0yh.js} +33 -32
  69. package/dist/cli/{worktree-provisioning-owner-g24xd417.js → worktree-provisioning-owner-zzkjycp1.js} +3 -3
  70. package/dist/commands/ci-simulate.d.ts +2 -0
  71. package/dist/config/cache-paths.d.ts +57 -0
  72. package/dist/config/evidence-schema.d.ts +3 -3
  73. package/dist/config/schema.d.ts +9 -0
  74. package/dist/git/branch.d.ts +2 -0
  75. package/dist/git/pr.d.ts +2 -0
  76. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +7 -0
  77. package/dist/hooks/diff-scope.d.ts +7 -0
  78. package/dist/hooks/review-receipt-scope.d.ts +7 -0
  79. package/dist/hooks/reviewer-scope-lifecycle.d.ts +9 -0
  80. package/dist/hooks/semantic-diff-injection.d.ts +8 -0
  81. package/dist/index.js +599 -589
  82. package/dist/mutation/engine.d.ts +11 -0
  83. package/dist/review/diff-source.d.ts +2 -0
  84. package/dist/sandbox/capability-probe.d.ts +22 -0
  85. package/dist/sandbox/executor.d.ts +15 -0
  86. package/dist/sandbox/linux/bubblewrap-executor.d.ts +6 -0
  87. package/dist/sandbox/macos/sandbox-exec-executor.d.ts +41 -0
  88. package/dist/tools/checkpoint.d.ts +11 -0
  89. package/dist/tools/complexity-hotspots.d.ts +15 -0
  90. package/dist/tools/diff-summary.d.ts +12 -0
  91. package/dist/tools/dispatch-lanes.d.ts +8 -0
  92. package/dist/tools/gh-evidence.d.ts +17 -1
  93. package/dist/tools/knowledge-receipt.d.ts +1 -1
  94. package/dist/tools/pkg-audit.d.ts +13 -0
  95. package/dist/tools/prepare-pr-workflow-checkout.d.ts +1 -0
  96. package/dist/utils/bun-compat.d.ts +80 -3
  97. package/dist/utils/git-binary-missing-error.d.ts +80 -2
  98. package/dist/utils/git-executable.d.ts +179 -0
  99. package/dist/utils/gitignore-warning.d.ts +10 -0
  100. package/dist/workflow/coder-settlement.d.ts +18 -0
  101. package/dist/worktree/core.d.ts +8 -0
  102. package/dist/worktree/merge.d.ts +33 -0
  103. package/package.json +3 -2
  104. package/dist/cli/curator-llm-factory-xgb4pxmm.js +0 -62
  105. package/dist/cli/guardrail-explain-6wcgr9tz.js +0 -63
  106. package/dist/cli/index-q1exe2b3.js +0 -256
@@ -1,15 +1,19 @@
1
1
  // @bun
2
- import {
3
- advisoryWarn,
4
- init_warning_buffer
5
- } from "./index-4rhhvd1a.js";
6
2
  import {
7
3
  SWARM_WORKTREE_DIR_NAME,
8
4
  init_constants
9
5
  } from "./index-v3y3qg48.js";
6
+ import {
7
+ init_git_executable,
8
+ resolveGitExecutable
9
+ } from "./index-9e6fdz2h.js";
10
+ import {
11
+ advisoryWarn,
12
+ init_warning_buffer
13
+ } from "./index-4rhhvd1a.js";
10
14
  import {
11
15
  bunSpawn
12
- } from "./index-4nt52yr9.js";
16
+ } from "./index-zj6t9zgx.js";
13
17
  import {
14
18
  log
15
19
  } from "./index-zgwm4ryv.js";
@@ -66,8 +70,10 @@ function matchSwarmLaneBranch(branch) {
66
70
 
67
71
  // src/worktree/core.ts
68
72
  init_warning_buffer();
73
+ init_git_executable();
69
74
  var _internals = {
70
75
  bunSpawn,
76
+ resolveGitExecutable,
71
77
  platform: process.platform,
72
78
  sleep: (ms) => new Promise((resolve2) => setTimeout(resolve2, ms)),
73
79
  osTmpdir: () => os.tmpdir(),
@@ -86,7 +92,7 @@ var _internals = {
86
92
  symlinkSync: fs.symlinkSync
87
93
  },
88
94
  writeScopeToDisk: async (directory, taskId, files) => {
89
- const { writeScopeToDisk: realWrite } = await import("./scope-persistence-0bkaxawa.js");
95
+ const { writeScopeToDisk: realWrite } = await import("./scope-persistence-mjg4we75.js");
90
96
  return realWrite(directory, taskId, files);
91
97
  },
92
98
  writeLaneProfileToDisk: async (_worktreePath, _laneIndex, _envOverrides) => {
@@ -134,15 +140,25 @@ async function removeLaneProfileFromDiskReal(worktreePath, laneIndex) {
134
140
  }
135
141
  var WORKTREE_TIMEOUT_MS = 30000;
136
142
  var WIN_PATH_BUDGET = 250;
143
+ var GIT_SPAWN_FAILURE_EXIT_CODE = 1;
137
144
  async function runGit(args, cwd, timeoutMs = WORKTREE_TIMEOUT_MS) {
138
- const proc = _internals.bunSpawn(["git", ...args], {
139
- cwd,
140
- timeout: timeoutMs,
141
- stdin: "ignore",
142
- stdout: "pipe",
143
- stderr: "pipe",
144
- env: { ...process.env, LC_ALL: "C" }
145
- });
145
+ let proc;
146
+ try {
147
+ proc = _internals.bunSpawn([_internals.resolveGitExecutable(), ...args], {
148
+ cwd,
149
+ timeout: timeoutMs,
150
+ stdin: "ignore",
151
+ stdout: "pipe",
152
+ stderr: "pipe",
153
+ env: { ...process.env, LC_ALL: "C" }
154
+ });
155
+ } catch (error) {
156
+ return {
157
+ exitCode: GIT_SPAWN_FAILURE_EXIT_CODE,
158
+ stdout: "",
159
+ stderr: `git ${args[0] ?? "command"} could not start in ${cwd}: ${error instanceof Error ? error.message : String(error)}`
160
+ };
161
+ }
146
162
  try {
147
163
  const exitCode = await proc.exited;
148
164
  const stdout = await proc.stdout.text();
@@ -165,14 +181,19 @@ async function checkPathBudget(worktreeRoot, directory) {
165
181
  if (longPaths === "true") {
166
182
  return { ok: true };
167
183
  }
168
- const proc = _internals.bunSpawn(["git", "ls-files"], {
169
- cwd: directory,
170
- timeout: WORKTREE_TIMEOUT_MS,
171
- stdin: "ignore",
172
- stdout: "pipe",
173
- stderr: "ignore",
174
- env: { ...process.env, LC_ALL: "C" }
175
- });
184
+ let proc;
185
+ try {
186
+ proc = _internals.bunSpawn([_internals.resolveGitExecutable(), "ls-files"], {
187
+ cwd: directory,
188
+ timeout: WORKTREE_TIMEOUT_MS,
189
+ stdin: "ignore",
190
+ stdout: "pipe",
191
+ stderr: "ignore",
192
+ env: { ...process.env, LC_ALL: "C" }
193
+ });
194
+ } catch {
195
+ return { ok: true };
196
+ }
176
197
  try {
177
198
  const exitCode = await proc.exited;
178
199
  const stdout = await proc.stdout.text();
@@ -7,7 +7,7 @@ import {
7
7
  readLinkPointer,
8
8
  resolveKnowledgeStoreDir,
9
9
  resolveLinkDir
10
- } from "./index-ywn7vtxp.js";
10
+ } from "./index-h1p08s3n.js";
11
11
 
12
12
  // src/knowledge/curation-policy.ts
13
13
  import { appendFile, mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
@@ -2,18 +2,18 @@
2
2
  import {
3
3
  ALLOWED_SKILL_PATH_PREFIXES,
4
4
  validateSkillPath
5
- } from "./index-yts89pqg.js";
5
+ } from "./index-bac12jpv.js";
6
6
  import {
7
7
  computeOutcomeSignal,
8
8
  readKnowledge,
9
9
  resolveHiveKnowledgePath,
10
10
  resolveSwarmKnowledgePath,
11
11
  transactKnowledge
12
- } from "./index-03pv47h2.js";
12
+ } from "./index-ec1kywxg.js";
13
13
  import {
14
14
  effectiveRetrievalOutcomes,
15
15
  readAuthoritativeKnowledgeCounterRollups
16
- } from "./index-4w5qdbk7.js";
16
+ } from "./index-zde2mkmg.js";
17
17
  import {
18
18
  advisoryWarn,
19
19
  init_warning_buffer
@@ -9,7 +9,7 @@ import {
9
9
  } from "./index-y8552snf.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-mazgg5s2.js";
12
+ } from "./index-9s8drsf9.js";
13
13
  import {
14
14
  assertProjectRoot,
15
15
  withEvidenceLock
@@ -6,7 +6,11 @@ import {
6
6
  PluginConfigSchema,
7
7
  init_schema,
8
8
  resolveExternalSkillsConfig
9
- } from "./index-y8j8ehc8.js";
9
+ } from "./index-68mqwvf5.js";
10
+ import {
11
+ GIT_BINARY_ENV_VAR,
12
+ init_git_executable
13
+ } from "./index-9e6fdz2h.js";
10
14
  import {
11
15
  advisoryWarn,
12
16
  init_warning_buffer
@@ -437,11 +441,41 @@ function rawFullAutoLocked(raw) {
437
441
  }
438
442
  return fullAuto.locked === true;
439
443
  }
444
+ function exposedGitBinary(raw) {
445
+ if (!raw || typeof raw !== "object")
446
+ return;
447
+ const git = raw.git;
448
+ if (!git || typeof git !== "object" || Array.isArray(git))
449
+ return;
450
+ return git.binary;
451
+ }
452
+ function enforceGitBinaryProvenance(mergedRaw, rawUserConfig) {
453
+ const userBinary = exposedGitBinary(rawUserConfig);
454
+ const exposedBinary = exposedGitBinary(mergedRaw);
455
+ if (Object.is(exposedBinary, userBinary))
456
+ return mergedRaw;
457
+ advisoryWarn(`[opencode-swarm] \u26A0\uFE0F SECURITY: Ignoring "git.binary" supplied by the project config (.opencode/${CONFIG_FILENAME}). ` + 'That file lives inside the repository, so it is untrusted content, and "git.binary" selects the executable this plugin spawns for every git command. ' + `Set it in your user config (<config dir>/opencode/${CONFIG_FILENAME}) or the ${GIT_BINARY_ENV_VAR} environment variable instead.`);
458
+ const exposedGit = mergedRaw.git;
459
+ const nextGit = exposedGit && typeof exposedGit === "object" && !Array.isArray(exposedGit) ? { ...exposedGit } : {};
460
+ const rebuilt = { ...mergedRaw };
461
+ if (userBinary === undefined) {
462
+ delete nextGit.binary;
463
+ if (Object.keys(nextGit).length === 0) {
464
+ delete rebuilt.git;
465
+ return rebuilt;
466
+ }
467
+ } else {
468
+ nextGit.binary = userBinary;
469
+ }
470
+ rebuilt.git = nextGit;
471
+ return rebuilt;
472
+ }
440
473
  function buildConfigWithMeta(rawUserConfig, rawProjectConfig, loadedFromFile, configHadErrors) {
441
474
  let mergedRaw = rawUserConfig ?? {};
442
475
  if (rawProjectConfig) {
443
476
  mergedRaw = deepMerge(mergedRaw, rawProjectConfig);
444
477
  }
478
+ mergedRaw = enforceGitBinaryProvenance(mergedRaw, rawUserConfig);
445
479
  if (rawFullAutoLocked(rawUserConfig) || rawFullAutoLocked(rawProjectConfig)) {
446
480
  const fa = mergedRaw.full_auto && typeof mergedRaw.full_auto === "object" && !Array.isArray(mergedRaw.full_auto) ? mergedRaw.full_auto : {};
447
481
  mergedRaw = { ...mergedRaw, full_auto: { ...fa, locked: true } };
@@ -682,6 +716,7 @@ function loadAgentPrompt(agentName) {
682
716
  var CONFIG_FILENAME = "opencode-swarm.json", PROMPTS_DIR_NAME = "opencode-swarm", MAX_CONFIG_FILE_BYTES = 102400;
683
717
  var init_loader = __esm(() => {
684
718
  init_warning_buffer();
719
+ init_git_executable();
685
720
  init_sanitize_malformed_values();
686
721
  init_schema();
687
722
  init_merge();
@@ -1,23 +1,23 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-rn0eq85g.js";
4
+ } from "./index-fv0s19g9.js";
5
5
  import {
6
6
  loadPluginConfigWithMeta
7
- } from "./index-9qq7c18c.js";
7
+ } from "./index-ytzz6pq1.js";
8
8
  import {
9
9
  KnowledgeConfigSchema,
10
10
  init_schema
11
- } from "./index-y8j8ehc8.js";
11
+ } from "./index-68mqwvf5.js";
12
12
  import {
13
13
  resolveHiveEventsPath
14
14
  } from "./index-ae75rja9.js";
15
15
  import {
16
16
  resolveKnowledgeStoreDir
17
- } from "./index-ywn7vtxp.js";
17
+ } from "./index-h1p08s3n.js";
18
18
  import {
19
19
  atomicWriteFile
20
- } from "./index-mazgg5s2.js";
20
+ } from "./index-9s8drsf9.js";
21
21
  import {
22
22
  assertProjectRoot
23
23
  } from "./index-f9vvg5xb.js";
@@ -2545,7 +2545,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
2545
2545
  }
2546
2546
  let bumps = 0;
2547
2547
  if (deltas.length > 0) {
2548
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-vh3nhtg2.js");
2548
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-qf8t25sw.js");
2549
2549
  bumps = await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
2550
2550
  }
2551
2551
  return {
@@ -175,8 +175,85 @@ var _internals = {
175
175
  platform: () => process.platform,
176
176
  cwd: () => process.cwd(),
177
177
  spawnTaskkill: (args, options) => nodeSpawn("taskkill", args, options),
178
- createProcessTreeKiller
178
+ createProcessTreeKiller,
179
+ statSync: (target) => fsSync.statSync(target)
179
180
  };
181
+
182
+ class SpawnCwdMissingError extends Error {
183
+ name = "SpawnCwdMissingError";
184
+ code = "ENOENT";
185
+ cwd;
186
+ reason;
187
+ executable;
188
+ constructor(cwd, reason, executable, options) {
189
+ super(reason === "missing" ? `cannot start "${executable}": working directory no longer exists: ${cwd}` : `cannot start "${executable}": working directory is not a directory: ${cwd}`, options);
190
+ this.cwd = cwd;
191
+ this.reason = reason;
192
+ this.executable = executable;
193
+ }
194
+ }
195
+ function inspectSpawnCwd(cwd) {
196
+ try {
197
+ return _internals.statSync(cwd).isDirectory() ? "directory" : "not-directory";
198
+ } catch (err) {
199
+ const code = typeof err === "object" && err !== null && "code" in err ? err.code : undefined;
200
+ if (code === "ENOENT" || code === "ENOTDIR")
201
+ return "missing";
202
+ if (code === "EACCES" || code === "EPERM")
203
+ return "unreadable";
204
+ return "unknown";
205
+ }
206
+ }
207
+ function describeSpawnCwdFailure(cwd, executable, cause) {
208
+ const state = inspectSpawnCwd(cwd);
209
+ if (state === "missing") {
210
+ return new SpawnCwdMissingError(cwd, "missing", executable, { cause });
211
+ }
212
+ if (state === "not-directory") {
213
+ return new SpawnCwdMissingError(cwd, "not-directory", executable, {
214
+ cause
215
+ });
216
+ }
217
+ return null;
218
+ }
219
+ var AMBIGUOUS_SPAWN_CODES = new Set(["ENOENT", "ENOTDIR", "EACCES", "EPERM"]);
220
+ function spawnErrorCode(err) {
221
+ if (typeof err !== "object" || err === null || !("code" in err)) {
222
+ return;
223
+ }
224
+ const code = err.code;
225
+ return typeof code === "string" ? code : undefined;
226
+ }
227
+ function classifySpawnFailure(err, cwd) {
228
+ if (err instanceof SpawnCwdMissingError)
229
+ return "cwd-missing";
230
+ const code = spawnErrorCode(err);
231
+ if (code === undefined || !AMBIGUOUS_SPAWN_CODES.has(code))
232
+ return "other";
233
+ if (cwd === undefined || cwd === "") {
234
+ return code === "ENOENT" ? "binary-missing" : "other";
235
+ }
236
+ switch (inspectSpawnCwd(cwd)) {
237
+ case "missing":
238
+ case "not-directory":
239
+ return "cwd-missing";
240
+ case "unreadable":
241
+ case "unknown":
242
+ return "cwd-unreadable";
243
+ default:
244
+ return code === "ENOENT" ? "binary-missing" : "other";
245
+ }
246
+ }
247
+ function wrapSpawnFailure(error, cwd, executable) {
248
+ const err = asError(error);
249
+ if (err instanceof SpawnCwdMissingError)
250
+ return err;
251
+ if (cwd === undefined || cwd === "")
252
+ return err;
253
+ if (classifySpawnFailure(err, cwd) !== "cwd-missing")
254
+ return err;
255
+ return describeSpawnCwdFailure(cwd, executable, err) ?? err;
256
+ }
180
257
  function streamFromNode(pipe) {
181
258
  let collected;
182
259
  let readerClaimed = false;
@@ -321,6 +398,42 @@ function mergeEnvForChild(baseEnv, envOverrides) {
321
398
  }
322
399
  return merged;
323
400
  }
401
+ var SPAWN_CREATION_FAILURE_EXIT_CODE = 1;
402
+ function asError(value) {
403
+ return value instanceof Error ? value : new Error(String(value));
404
+ }
405
+ function staticStream(text) {
406
+ const bytes = new TextEncoder().encode(text);
407
+ return {
408
+ async text() {
409
+ return text;
410
+ },
411
+ async bytes() {
412
+ return bytes;
413
+ },
414
+ getReader() {
415
+ return new ReadableStream({
416
+ start(controller) {
417
+ if (bytes.byteLength > 0)
418
+ controller.enqueue(bytes);
419
+ controller.close();
420
+ }
421
+ }).getReader();
422
+ }
423
+ };
424
+ }
425
+ function spawnCreationFailure(error) {
426
+ return {
427
+ stdout: streamFromBun(undefined),
428
+ stderr: staticStream(error.message),
429
+ exited: Promise.resolve(SPAWN_CREATION_FAILURE_EXIT_CODE),
430
+ exitCode: null,
431
+ signalCode: null,
432
+ spawnError: error,
433
+ kill() {},
434
+ killTree: () => Promise.resolve()
435
+ };
436
+ }
324
437
  function bunSpawn(cmd, options) {
325
438
  const bun = getBun();
326
439
  if (bun?.spawn) {
@@ -337,7 +450,13 @@ function bunSpawn(cmd, options) {
337
450
  delete spawnOpts.killSignal;
338
451
  spawnOpts.detached = true;
339
452
  }
340
- const proc2 = bun.spawn(cmd, spawnOpts);
453
+ let spawned;
454
+ try {
455
+ spawned = bun.spawn(cmd, spawnOpts);
456
+ } catch (error) {
457
+ return spawnCreationFailure(wrapSpawnFailure(error, options?.cwd, cmd[0] ?? ""));
458
+ }
459
+ const proc2 = spawned;
341
460
  const killBunTree = createProcessTreeKiller(proc2.pid, (sig) => proc2.kill(sig), true);
342
461
  const killBunProcess = (sig) => options?.killProcessTree ? killBunTree(sig) : Promise.resolve(proc2.kill(sig));
343
462
  let timeoutHandle2;
@@ -377,18 +496,23 @@ function bunSpawn(cmd, options) {
377
496
  const [file, ...args] = cmd;
378
497
  const detached = options?.killProcessTree === true;
379
498
  const mergedEnv = mergeEnvForChild(options?.env, options?.envOverrides);
380
- const proc = nodeSpawn(file, args, {
381
- cwd: options?.cwd,
382
- env: mergedEnv,
383
- detached,
384
- windowsHide: true,
385
- windowsVerbatimArguments: options?.windowsVerbatimArguments,
386
- stdio: [
387
- mapStdio(options?.stdin),
388
- mapStdio(options?.stdout),
389
- mapStdio(options?.stderr)
390
- ]
391
- });
499
+ let proc;
500
+ try {
501
+ proc = nodeSpawn(file, args, {
502
+ cwd: options?.cwd,
503
+ env: mergedEnv,
504
+ detached,
505
+ windowsHide: true,
506
+ windowsVerbatimArguments: options?.windowsVerbatimArguments,
507
+ stdio: [
508
+ mapStdio(options?.stdin),
509
+ mapStdio(options?.stdout),
510
+ mapStdio(options?.stderr)
511
+ ]
512
+ });
513
+ } catch (error) {
514
+ return spawnCreationFailure(wrapSpawnFailure(error, options?.cwd, file));
515
+ }
392
516
  const killChildTree = createProcessTreeKiller(proc.pid, (signal) => proc.kill(signal), true);
393
517
  const killChild = (signal) => {
394
518
  if (detached)
@@ -405,7 +529,7 @@ function bunSpawn(cmd, options) {
405
529
  resolve(code ?? -1);
406
530
  });
407
531
  proc.on("error", (error) => {
408
- observedSpawnError = error;
532
+ observedSpawnError = wrapSpawnFailure(error, options?.cwd, file);
409
533
  resolve(1);
410
534
  });
411
535
  if (options?.timeout && options.timeout > 0) {
@@ -445,13 +569,26 @@ function bunSpawn(cmd, options) {
445
569
  killTree: killChild
446
570
  };
447
571
  }
572
+ function syncSpawnCreationFailure(error) {
573
+ return {
574
+ stdout: new Uint8Array(0),
575
+ stderr: new TextEncoder().encode(error.message),
576
+ exitCode: SPAWN_CREATION_FAILURE_EXIT_CODE,
577
+ success: false
578
+ };
579
+ }
448
580
  function bunSpawnSync(cmd, options) {
581
+ const requestedCwd = Array.isArray(cmd) ? options?.cwd : options?.cwd ?? cmd.cwd;
582
+ const executable = (Array.isArray(cmd) ? cmd[0] : cmd.cmd[0]) ?? "";
449
583
  const bun = getBun();
450
584
  if (bun?.spawnSync) {
451
585
  const mergedEnv2 = mergeEnvForChild(options?.env, options?.envOverrides);
452
586
  const spawnOpts = mergedEnv2 !== undefined ? { ...options, env: mergedEnv2 } : options;
453
- const result2 = bun.spawnSync(cmd, spawnOpts);
454
- return result2;
587
+ try {
588
+ return bun.spawnSync(cmd, spawnOpts);
589
+ } catch (error) {
590
+ return syncSpawnCreationFailure(wrapSpawnFailure(error, requestedCwd, executable));
591
+ }
455
592
  }
456
593
  let argv;
457
594
  let mergedOptions;
@@ -473,13 +610,24 @@ function bunSpawnSync(cmd, options) {
473
610
  }
474
611
  const [file, ...args] = argv;
475
612
  const mergedEnv = mergeEnvForChild(mergedOptions.env, options?.envOverrides);
476
- const result = nodeSpawnSync(file, args, {
477
- cwd: mergedOptions.cwd,
478
- env: mergedEnv,
479
- input: mergedOptions.stdin instanceof Uint8Array || typeof mergedOptions.stdin === "string" ? mergedOptions.stdin : undefined,
480
- timeout: mergedOptions.timeout,
481
- windowsHide: true
482
- });
613
+ let result;
614
+ try {
615
+ result = nodeSpawnSync(file, args, {
616
+ cwd: mergedOptions.cwd,
617
+ env: mergedEnv,
618
+ input: mergedOptions.stdin instanceof Uint8Array || typeof mergedOptions.stdin === "string" ? mergedOptions.stdin : undefined,
619
+ timeout: mergedOptions.timeout,
620
+ windowsHide: true
621
+ });
622
+ } catch (error) {
623
+ return syncSpawnCreationFailure(wrapSpawnFailure(error, mergedOptions.cwd, file));
624
+ }
625
+ if (result.error) {
626
+ const wrapped = wrapSpawnFailure(result.error, mergedOptions.cwd, file);
627
+ if (wrapped instanceof SpawnCwdMissingError) {
628
+ return syncSpawnCreationFailure(wrapped);
629
+ }
630
+ }
483
631
  const stdout = result.stdout instanceof Buffer ? new Uint8Array(result.stdout.buffer, result.stdout.byteOffset, result.stdout.byteLength) : typeof result.stdout === "string" ? new TextEncoder().encode(result.stdout) : new Uint8Array(0);
484
632
  const stderr = result.stderr instanceof Buffer ? new Uint8Array(result.stderr.buffer, result.stderr.byteOffset, result.stderr.byteLength) : typeof result.stderr === "string" ? new TextEncoder().encode(result.stderr) : new Uint8Array(0);
485
633
  const exitCode = result.status ?? (result.signal ? 128 : 1);
@@ -491,4 +639,4 @@ function bunSpawnSync(cmd, options) {
491
639
  };
492
640
  }
493
641
 
494
- export { bunFile, bunWrite, bunHash, mergeEnvForChild, bunSpawn, bunSpawnSync };
642
+ export { bunFile, bunWrite, bunHash, classifySpawnFailure, mergeEnvForChild, bunSpawn, bunSpawnSync };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  _internals,
4
4
  resolveWorktreeIsolationConfig
5
- } from "./index-psvxq93b.js";
5
+ } from "./index-ckq719fr.js";
6
6
  import {
7
7
  ApprovalEvidenceSchema,
8
8
  BaseEvidenceSchema,
@@ -42,7 +42,7 @@ import {
42
42
  loadPluginConfig,
43
43
  loadPluginConfigWithMeta,
44
44
  loadPluginConfigWithMetaAsync
45
- } from "./index-9qq7c18c.js";
45
+ } from "./index-ytzz6pq1.js";
46
46
  import {
47
47
  AUTO_REVIEW_V8_BURN_IN_DECISION,
48
48
  AgentOverrideConfigSchema,
@@ -64,8 +64,7 @@ import {
64
64
  TurboConfigSchema,
65
65
  WorktreeIsolationConfigSchema,
66
66
  resolveAutoReviewConfig
67
- } from "./index-y8j8ehc8.js";
68
- import"./index-4rhhvd1a.js";
67
+ } from "./index-68mqwvf5.js";
69
68
  import {
70
69
  ALL_AGENT_NAMES,
71
70
  ALL_SUBAGENT_NAMES,
@@ -76,6 +75,8 @@ import {
76
75
  isQAAgent,
77
76
  isSubagent
78
77
  } from "./index-v3y3qg48.js";
78
+ import"./index-9e6fdz2h.js";
79
+ import"./index-4rhhvd1a.js";
79
80
  import"./index-zjygnfay.js";
80
81
  import"./index-bk5tah7q.js";
81
82
  import"./index-bpmtbmy9.js";