opencode-swarm 7.144.3 → 7.144.5

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 (127) hide show
  1. package/.opencode/skills/swarm-pr-review/SKILL.md +3 -1
  2. package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +28 -0
  3. package/.opencode/skills/swarm-pr-review/references/prompt-templates.md +2 -0
  4. package/README.md +3 -1
  5. package/dist/background/pending-delegations.d.ts +14 -0
  6. package/dist/background/workspace-snapshot.d.ts +7 -0
  7. package/dist/cli/{capability-probe-f1paszww.js → capability-probe-976tt4ba.js} +6 -2
  8. package/dist/cli/{config-doctor-pkr9w2nv.js → config-doctor-m005xfdt.js} +3 -3
  9. package/dist/cli/{core-7pymdx0b.js → core-6vdtfb8s.js} +4 -3
  10. package/dist/cli/{curation-policy-y1pqpztb.js → curation-policy-a511r0qz.js} +6 -6
  11. package/dist/cli/{curator-wbzcjd0q.js → curator-0t87anp5.js} +35 -34
  12. package/dist/cli/{curator-drift-2jbjv03a.js → curator-drift-ckjm272w.js} +2 -2
  13. package/dist/cli/curator-llm-factory-j8tk9rxm.js +63 -0
  14. package/dist/cli/{dispatch-1y1rnv1h.js → dispatch-ndxbsk98.js} +2 -2
  15. package/dist/cli/{evidence-summary-service-rcgrdm52.js → evidence-summary-service-c22gahjc.js} +15 -14
  16. package/dist/cli/{gate-evidence-jmzctnhg.js → gate-evidence-hh8kc9wt.js} +9 -8
  17. package/dist/cli/guardrail-explain-9gjw2dsd.js +64 -0
  18. package/dist/cli/{guardrail-log-k1s9xf3h.js → guardrail-log-ejf5zjac.js} +5 -5
  19. package/dist/cli/{hive-promoter-vcj5h0e3.js → hive-promoter-gkbfpdtv.js} +35 -34
  20. package/dist/cli/{index-s2rcz51a.js → index-1jsmmx7y.js} +66 -34
  21. package/dist/cli/{index-qj22wyw2.js → index-1pxqkvvq.js} +3 -3
  22. package/dist/cli/{index-p863y7xx.js → index-3qdzpv91.js} +1 -1
  23. package/dist/cli/{index-8hkjk37c.js → index-58cvm3dw.js} +36 -1
  24. package/dist/cli/{index-ghzvxj3g.js → index-5wenr2vs.js} +40 -37
  25. package/dist/cli/{index-wck434f8.js → index-63tgh0cn.js} +15 -4
  26. package/dist/cli/{index-xwpmxpb7.js → index-641yjpk8.js} +6 -6
  27. package/dist/cli/{index-zwrqe065.js → index-6z5jtf7d.js} +2 -2
  28. package/dist/cli/{index-j6mfyy0a.js → index-7e4q41nb.js} +3 -3
  29. package/dist/cli/{index-6s2q144w.js → index-855hseq4.js} +43 -22
  30. package/dist/cli/index-9e6fdz2h.js +282 -0
  31. package/dist/cli/{index-zswmbm15.js → index-9s8drsf9.js} +2 -2
  32. package/dist/cli/{index-x68tw7v3.js → index-a1hxejxc.js} +168 -36
  33. package/dist/cli/{index-b6e016tv.js → index-abtrcs16.js} +1 -1
  34. package/dist/cli/{index-8fwhhayc.js → index-b44qqqt2.js} +27 -18
  35. package/dist/cli/{index-k3cxyk66.js → index-cwtpqm5f.js} +1 -1
  36. package/dist/cli/{index-2en8s72h.js → index-dc04v786.js} +30 -2
  37. package/dist/cli/{index-7554tecy.js → index-dtbzyr3s.js} +2 -2
  38. package/dist/cli/{index-eya357bk.js → index-ea09xax6.js} +5 -5
  39. package/dist/cli/{index-74hpm6sh.js → index-f36ybbsv.js} +12 -6
  40. package/dist/cli/{index-wd24zn2e.js → index-f9vvg5xb.js} +1 -1
  41. package/dist/cli/{index-rn0eq85g.js → index-fv0s19g9.js} +1 -1
  42. package/dist/cli/{index-ep14xc5z.js → index-fv2pzwnp.js} +6 -5
  43. package/dist/cli/{index-dpfphnmy.js → index-h1p08s3n.js} +1 -1
  44. package/dist/cli/{index-584grrwn.js → index-hkdgkkhb.js} +2 -2
  45. package/dist/cli/{index-1brb14xc.js → index-kdak6s63.js} +12 -6
  46. package/dist/cli/{index-satc0vs6.js → index-kh0jt9pg.js} +300 -1181
  47. package/dist/cli/{index-p7hbphaq.js → index-mkmcz6x8.js} +4 -4
  48. package/dist/cli/{index-krxcxkdq.js → index-n4hwcsbd.js} +20 -5
  49. package/dist/cli/{index-06cn7haa.js → index-rdgtfj74.js} +2 -2
  50. package/dist/cli/{index-b227mpnk.js → index-rnyt30tm.js} +4 -4
  51. package/dist/cli/{index-whezv7vc.js → index-v3y3qg48.js} +1 -1
  52. package/dist/cli/{index-0fgwdtvp.js → index-vdha477y.js} +1 -1
  53. package/dist/cli/{index-pr8vhj6j.js → index-wbrqvm2g.js} +8 -8
  54. package/dist/cli/{index-8214dd7j.js → index-wknz5c8q.js} +2 -2
  55. package/dist/cli/{index-pag8nsb1.js → index-wm6f7t7w.js} +3 -3
  56. package/dist/cli/{index-247wf23m.js → index-wmsehjq6.js} +2847 -1791
  57. package/dist/cli/{index-4nt52yr9.js → index-zj6t9zgx.js} +173 -25
  58. package/dist/cli/index-zy7f84cs.js +1210 -0
  59. package/dist/cli/index.d.ts +11 -1
  60. package/dist/cli/index.js +64 -42
  61. package/dist/cli/{knowledge-escalator-x6jrcrwj.js → knowledge-escalator-1d79m1tr.js} +14 -13
  62. package/dist/cli/{knowledge-events-aw22r72m.js → knowledge-events-ces29ncg.js} +12 -11
  63. package/dist/cli/{knowledge-link-bntppte4.js → knowledge-link-4cg4776a.js} +5 -5
  64. package/dist/cli/{knowledge-store-19xg1rw1.js → knowledge-store-pe8webc2.js} +6 -6
  65. package/dist/cli/{knowledge-validator-8wh82z0a.js → knowledge-validator-4yjf1f7k.js} +8 -8
  66. package/dist/cli/{pending-delegations-1y303j3k.js → pending-delegations-9h1jmtw1.js} +5 -5
  67. package/dist/cli/{pr-subscriptions-wvd041rp.js → pr-subscriptions-8pg34pev.js} +5 -5
  68. package/dist/cli/{runner-jn55k8xb.js → runner-cqecp1na.js} +6 -6
  69. package/dist/cli/{scan-cursor-429r5db9.js → scan-cursor-d6exjmqj.js} +9 -7
  70. package/dist/cli/{schema-jdwjcby0.js → schema-2esybebd.js} +4 -2
  71. package/dist/cli/{scope-persistence-s0s1bz15.js → scope-persistence-ej59x0yc.js} +9 -8
  72. package/dist/cli/{skill-generator-ffbj0ye5.js → skill-generator-yqta3yrg.js} +16 -15
  73. package/dist/cli/{telemetry-xyfb5vm8.js → telemetry-cybx6cfz.js} +1 -1
  74. package/dist/cli/{workspace-snapshot-w3tg4ne5.js → workspace-snapshot-d89zm6wm.js} +5 -2
  75. package/dist/cli/{worktree-collision-ownership-z5ftwjz3.js → worktree-collision-ownership-vy0kxa98.js} +28 -21
  76. package/dist/cli/{worktree-isolation-y2p93438.js → worktree-isolation-rwq0kke7.js} +35 -34
  77. package/dist/cli/{worktree-provisioning-owner-g24xd417.js → worktree-provisioning-owner-zzkjycp1.js} +3 -3
  78. package/dist/commands/ci-simulate.d.ts +2 -0
  79. package/dist/commands/index.d.ts +1 -0
  80. package/dist/commands/recover.d.ts +17 -0
  81. package/dist/commands/registry.d.ts +9 -1
  82. package/dist/commands/reset-session.d.ts +2 -0
  83. package/dist/config/cache-paths.d.ts +57 -0
  84. package/dist/config/evidence-schema.d.ts +3 -3
  85. package/dist/config/schema.d.ts +9 -0
  86. package/dist/git/branch.d.ts +2 -0
  87. package/dist/git/pr.d.ts +2 -0
  88. package/dist/hooks/context-budget.d.ts +4 -0
  89. package/dist/hooks/context-usage.d.ts +48 -0
  90. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +7 -0
  91. package/dist/hooks/diff-scope.d.ts +7 -0
  92. package/dist/hooks/pr-workflow-gate.d.ts +29 -2
  93. package/dist/hooks/review-receipt-scope.d.ts +7 -0
  94. package/dist/hooks/reviewer-scope-lifecycle.d.ts +9 -0
  95. package/dist/hooks/semantic-diff-injection.d.ts +8 -0
  96. package/dist/index.js +607 -591
  97. package/dist/mutation/engine.d.ts +11 -0
  98. package/dist/observability/catalog.d.ts +8 -6
  99. package/dist/review/diff-source.d.ts +2 -0
  100. package/dist/sandbox/capability-probe.d.ts +22 -0
  101. package/dist/sandbox/executor.d.ts +15 -0
  102. package/dist/sandbox/linux/bubblewrap-executor.d.ts +6 -0
  103. package/dist/sandbox/macos/sandbox-exec-executor.d.ts +41 -0
  104. package/dist/sast/semgrep.d.ts +3 -2
  105. package/dist/telemetry.d.ts +17 -1
  106. package/dist/tools/checkpoint.d.ts +11 -0
  107. package/dist/tools/complexity-hotspots.d.ts +15 -0
  108. package/dist/tools/context-status.d.ts +9 -3
  109. package/dist/tools/diff-summary.d.ts +12 -0
  110. package/dist/tools/dispatch-lanes.d.ts +35 -2
  111. package/dist/tools/gh-evidence.d.ts +17 -1
  112. package/dist/tools/knowledge-receipt.d.ts +1 -1
  113. package/dist/tools/pkg-audit.d.ts +13 -0
  114. package/dist/tools/pre-check-batch.d.ts +9 -0
  115. package/dist/tools/prepare-pr-workflow-checkout.d.ts +1 -0
  116. package/dist/tools/sast-scan.d.ts +3 -0
  117. package/dist/utils/bun-compat.d.ts +80 -3
  118. package/dist/utils/git-binary-missing-error.d.ts +80 -2
  119. package/dist/utils/git-executable.d.ts +179 -0
  120. package/dist/utils/gitignore-warning.d.ts +10 -0
  121. package/dist/workflow/coder-settlement.d.ts +92 -0
  122. package/dist/worktree/core.d.ts +8 -0
  123. package/dist/worktree/merge.d.ts +33 -0
  124. package/package.json +3 -2
  125. package/dist/cli/curator-llm-factory-7are9wjh.js +0 -62
  126. package/dist/cli/guardrail-explain-brgw4sve.js +0 -63
  127. package/dist/cli/index-q1exe2b3.js +0 -256
@@ -2,10 +2,14 @@
2
2
  import {
3
3
  readKnowledge,
4
4
  transactKnowledge
5
- } from "./index-xwpmxpb7.js";
5
+ } from "./index-641yjpk8.js";
6
+ import {
7
+ init_git_executable,
8
+ resolveGitExecutableAsync
9
+ } from "./index-9e6fdz2h.js";
6
10
  import {
7
11
  resolveKnowledgeStoreDir
8
- } from "./index-dpfphnmy.js";
12
+ } from "./index-h1p08s3n.js";
9
13
  import {
10
14
  init_knowledge_types,
11
15
  isActiveStatus
@@ -27,6 +31,7 @@ init_knowledge_types();
27
31
  init_logger();
28
32
 
29
33
  // src/knowledge/cohort-identity.ts
34
+ init_git_executable();
30
35
  import { execFile } from "child_process";
31
36
  import { createHash } from "crypto";
32
37
  import { realpathSync } from "fs";
@@ -111,10 +116,16 @@ function normalizeGitRemote(rawUrl) {
111
116
  return null;
112
117
  return `${host}/${pathPart}`;
113
118
  }
114
- function runGit(directory, args) {
119
+ async function runGit(directory, args) {
120
+ let gitExecutable;
121
+ try {
122
+ gitExecutable = await resolveGitExecutableAsync();
123
+ } catch {
124
+ return null;
125
+ }
115
126
  return new Promise((resolve2) => {
116
127
  try {
117
- const child = execFile("git", ["-C", directory, ...args], {
128
+ const child = execFile(gitExecutable, ["-C", directory, ...args], {
118
129
  timeout: GIT_TIMEOUT_MS,
119
130
  windowsHide: true,
120
131
  encoding: "utf-8",
@@ -6,10 +6,10 @@ import {
6
6
  } from "./index-ae75rja9.js";
7
7
  import {
8
8
  resolveKnowledgeStoreDir
9
- } from "./index-dpfphnmy.js";
9
+ } from "./index-h1p08s3n.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-zswmbm15.js";
12
+ } from "./index-9s8drsf9.js";
13
13
  import {
14
14
  readCachedParsedFile
15
15
  } from "./index-ed5ykebp.js";
@@ -709,7 +709,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
709
709
  const {
710
710
  readAuthoritativeKnowledgeCounterRollups,
711
711
  effectiveRetrievalOutcomes
712
- } = await import("./knowledge-events-aw22r72m.js");
712
+ } = await import("./knowledge-events-ces29ncg.js");
713
713
  const rollups = await readAuthoritativeKnowledgeCounterRollups(directory);
714
714
  const flagIds = new Set;
715
715
  for (const e of atFloor) {
@@ -776,11 +776,11 @@ async function applyConfidenceFloorAction(directory, touched, options) {
776
776
  });
777
777
  }
778
778
  if (action === "quarantine" && toQuarantine.length > 0) {
779
- const { quarantineEntry } = await import("./knowledge-validator-8wh82z0a.js");
780
- const { KnowledgeConfigSchema } = await import("./schema-jdwjcby0.js");
779
+ const { quarantineEntry } = await import("./knowledge-validator-4yjf1f7k.js");
780
+ const { KnowledgeConfigSchema } = await import("./schema-2esybebd.js");
781
781
  let config;
782
782
  try {
783
- const { loadPluginConfigWithMeta } = await import("./index-ep14xc5z.js");
783
+ const { loadPluginConfigWithMeta } = await import("./index-fv2pzwnp.js");
784
784
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
785
785
  config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
786
786
  } catch {
@@ -9,7 +9,7 @@ import {
9
9
  readEvaluationRun,
10
10
  saveEvaluationRun,
11
11
  saveTaskSetSnapshot
12
- } from "./index-8214dd7j.js";
12
+ } from "./index-wknz5c8q.js";
13
13
  import {
14
14
  canonicalHash,
15
15
  computeCandidateInputContentHash,
@@ -24,7 +24,7 @@ import {
24
24
  } from "./index-bpmtbmy9.js";
25
25
  import {
26
26
  bunSpawn
27
- } from "./index-4nt52yr9.js";
27
+ } from "./index-zj6t9zgx.js";
28
28
 
29
29
  // src/evaluation/runner.ts
30
30
  import * as fs3 from "fs";
@@ -4,14 +4,14 @@ import {
4
4
  PlanSchema,
5
5
  TaskStatusSchema,
6
6
  init_loader
7
- } from "./index-8hkjk37c.js";
7
+ } from "./index-58cvm3dw.js";
8
8
  import {
9
9
  assertProjectRoot,
10
10
  withEvidenceLock
11
- } from "./index-wd24zn2e.js";
11
+ } from "./index-f9vvg5xb.js";
12
12
  import {
13
13
  emit
14
- } from "./index-s2rcz51a.js";
14
+ } from "./index-1jsmmx7y.js";
15
15
  import {
16
16
  criticalWarn,
17
17
  init_logger,
@@ -1,15 +1,19 @@
1
1
  // @bun
2
+ import {
3
+ SWARM_WORKTREE_DIR_NAME,
4
+ init_constants
5
+ } from "./index-v3y3qg48.js";
6
+ import {
7
+ init_git_executable,
8
+ resolveGitExecutable
9
+ } from "./index-9e6fdz2h.js";
2
10
  import {
3
11
  advisoryWarn,
4
12
  init_warning_buffer
5
13
  } from "./index-4rhhvd1a.js";
6
- import {
7
- SWARM_WORKTREE_DIR_NAME,
8
- init_constants
9
- } from "./index-whezv7vc.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-s0s1bz15.js");
95
+ const { writeScopeToDisk: realWrite } = await import("./scope-persistence-ej59x0yc.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();
@@ -0,0 +1,282 @@
1
+ // @bun
2
+ import {
3
+ advisoryWarn,
4
+ init_warning_buffer
5
+ } from "./index-4rhhvd1a.js";
6
+ import {
7
+ __esm
8
+ } from "./index-a76rekgs.js";
9
+
10
+ // src/utils/git-executable.ts
11
+ import { spawnSync } from "child_process";
12
+ import * as fs from "fs";
13
+ import * as os from "os";
14
+ import * as path from "path";
15
+ function excerptProbeOutput(raw) {
16
+ return raw.slice(0, PROBE_OUTPUT_EXCERPT_CHARS).replace(/[^\x20-\x7E]/g, " ").trim();
17
+ }
18
+ function unique(values) {
19
+ return [...new Set(values.filter(Boolean))];
20
+ }
21
+ function envOverride() {
22
+ const raw = _internals.env()[GIT_BINARY_ENV_VAR];
23
+ return raw && raw.trim() !== "" ? raw : undefined;
24
+ }
25
+ function effectiveOverride() {
26
+ return envOverride() ?? configuredOverride;
27
+ }
28
+ function overrideSource() {
29
+ if (envOverride() !== undefined)
30
+ return "env";
31
+ if (configuredOverride !== undefined)
32
+ return "config";
33
+ return;
34
+ }
35
+ function isAbsoluteForPlatform(candidate, platform) {
36
+ return platform === "win32" ? path.win32.isAbsolute(candidate) : path.posix.isAbsolute(candidate);
37
+ }
38
+ function windowsPlatformCandidates() {
39
+ const env = _internals.env();
40
+ const roots = unique([
41
+ env.ProgramFiles ?? "",
42
+ env["ProgramFiles(x86)"] ?? "",
43
+ env.LOCALAPPDATA ? `${env.LOCALAPPDATA}\\Programs` : ""
44
+ ]);
45
+ const installed = roots.flatMap((root) => [
46
+ `${root}\\Git\\cmd\\git.exe`,
47
+ `${root}\\Git\\bin\\git.exe`
48
+ ]);
49
+ return unique(installed);
50
+ }
51
+ function platformCandidates(platform) {
52
+ if (platform === "darwin") {
53
+ return ["/opt/homebrew/bin/git", "/usr/local/bin/git", "/usr/bin/git"];
54
+ }
55
+ if (platform === "win32") {
56
+ return windowsPlatformCandidates();
57
+ }
58
+ return ["/usr/bin/git", "/usr/local/bin/git", "/bin/git"];
59
+ }
60
+ function pathDelimiterFor(platform) {
61
+ return platform === "win32" ? ";" : ":";
62
+ }
63
+ function joinDirAndName(dir, name, platform) {
64
+ const sep = platform === "win32" ? "\\" : "/";
65
+ const trimmed = dir.replace(/[\\/]+$/, "");
66
+ return trimmed ? `${trimmed}${sep}${name}` : `${sep}${name}`;
67
+ }
68
+ function pathCandidates(platform) {
69
+ const pathValue = _internals.env().PATH ?? "";
70
+ if (!pathValue)
71
+ return [];
72
+ const dirs = pathValue.split(pathDelimiterFor(platform)).filter(Boolean);
73
+ const names = platform === "win32" ? [...WINDOWS_PATH_EXTENSIONS.map((ext) => `git${ext}`), "git"] : ["git"];
74
+ const out = [];
75
+ for (const dir of dirs) {
76
+ for (const name of names) {
77
+ out.push(joinDirAndName(dir, name, platform));
78
+ }
79
+ }
80
+ return unique(out);
81
+ }
82
+ function buildCandidates(platform) {
83
+ const override = effectiveOverride();
84
+ const overrideCandidate = override ? [{ source: "override", path: override }] : [];
85
+ const seen = new Set(overrideCandidate.map((c) => c.path));
86
+ const rest = [];
87
+ for (const p of platformCandidates(platform)) {
88
+ if (seen.has(p))
89
+ continue;
90
+ seen.add(p);
91
+ rest.push({ source: "platform", path: p });
92
+ }
93
+ for (const p of pathCandidates(platform)) {
94
+ if (seen.has(p))
95
+ continue;
96
+ seen.add(p);
97
+ rest.push({ source: "path", path: p });
98
+ }
99
+ return [...overrideCandidate, ...rest];
100
+ }
101
+ function probeCandidate(candidatePath, platform) {
102
+ if (!isAbsoluteForPlatform(candidatePath, platform)) {
103
+ return { accepted: false, reason: "not an absolute path" };
104
+ }
105
+ let stat;
106
+ try {
107
+ stat = fs.statSync(candidatePath);
108
+ } catch (err) {
109
+ const code = err?.code;
110
+ if (code === "ENOENT")
111
+ return { accepted: false, reason: "no such file" };
112
+ return {
113
+ accepted: false,
114
+ reason: `cannot stat (${code ?? "unknown error"})`
115
+ };
116
+ }
117
+ if (stat.isDirectory()) {
118
+ return { accepted: false, reason: "is a directory" };
119
+ }
120
+ if (!stat.isFile()) {
121
+ return { accepted: false, reason: "not a regular file" };
122
+ }
123
+ let result;
124
+ try {
125
+ result = _internals.spawnSync(candidatePath, ["--version"], {
126
+ cwd: os.tmpdir(),
127
+ stdio: ["ignore", "pipe", "ignore"],
128
+ windowsHide: true,
129
+ timeout: PER_PROBE_TIMEOUT_MS,
130
+ maxBuffer: PROBE_MAX_BUFFER_BYTES
131
+ });
132
+ } catch (err) {
133
+ return {
134
+ accepted: false,
135
+ reason: `spawn threw: ${err instanceof Error ? err.message : String(err)}`
136
+ };
137
+ }
138
+ if (result.error) {
139
+ return { accepted: false, reason: `spawn failed: ${result.error.message}` };
140
+ }
141
+ if (result.status !== 0) {
142
+ const statusDescription = result.status !== null ? `exit ${result.status}` : `signal ${result.signal ?? "unknown"}`;
143
+ return {
144
+ accepted: false,
145
+ reason: `git --version returned ${statusDescription}`
146
+ };
147
+ }
148
+ const versionOutput = (result.stdout ?? "").toString().trim();
149
+ if (!GIT_VERSION_PATTERN.test(versionOutput)) {
150
+ const excerpt = excerptProbeOutput(versionOutput);
151
+ return {
152
+ accepted: false,
153
+ reason: excerpt ? `not git: --version printed "${excerpt}"` : "not git: --version printed nothing"
154
+ };
155
+ }
156
+ return { accepted: true };
157
+ }
158
+ function* probeCycle(candidates, platform, attempts) {
159
+ const start = _internals.now();
160
+ let budgetExceeded = false;
161
+ for (const candidate of candidates) {
162
+ if (_internals.now() - start > TOTAL_BUDGET_MS) {
163
+ budgetExceeded = true;
164
+ break;
165
+ }
166
+ const result = probeCandidate(candidate.path, platform);
167
+ attempts.push({
168
+ source: candidate.source,
169
+ candidate: candidate.path,
170
+ accepted: result.accepted,
171
+ reason: result.reason
172
+ });
173
+ if (candidate.source === "override" && !result.accepted) {
174
+ advisoryWarn(`[opencode-swarm] git.binary override "${candidate.path}" is unusable (${result.reason}); falling back to automatic git resolution.`);
175
+ }
176
+ if (result.accepted) {
177
+ return { outcome: "accepted", path: candidate.path };
178
+ }
179
+ yield;
180
+ }
181
+ return budgetExceeded ? { outcome: "exhausted-budget" } : { outcome: "all-rejected" };
182
+ }
183
+ function driveSync(gen) {
184
+ let step = gen.next();
185
+ while (!step.done) {
186
+ step = gen.next();
187
+ }
188
+ return step.value;
189
+ }
190
+ async function driveAsync(gen) {
191
+ let step = gen.next();
192
+ while (!step.done) {
193
+ await _internals.yieldToEventLoop();
194
+ step = gen.next();
195
+ }
196
+ return step.value;
197
+ }
198
+ function readCache() {
199
+ if (cache === null)
200
+ return null;
201
+ if (cache.kind === "success")
202
+ return cache;
203
+ if (_internals.now() < cache.expiresAt)
204
+ return cache;
205
+ cache = null;
206
+ return null;
207
+ }
208
+ function applyProbeResult(result, attempts, generation) {
209
+ if (generation !== cacheGeneration) {
210
+ return result.outcome === "accepted" ? result.path : BARE_GIT;
211
+ }
212
+ lastAttempts = attempts;
213
+ if (result.outcome === "accepted") {
214
+ cache = { kind: "success", path: result.path };
215
+ return result.path;
216
+ }
217
+ cache = {
218
+ kind: "fallback",
219
+ expiresAt: _internals.now() + NEGATIVE_CACHE_TTL_MS
220
+ };
221
+ return BARE_GIT;
222
+ }
223
+ function resolveGitExecutable() {
224
+ const cached = readCache();
225
+ if (cached)
226
+ return cached.kind === "success" ? cached.path : BARE_GIT;
227
+ const platform = _internals.platform();
228
+ const attempts = [];
229
+ const generation = cacheGeneration;
230
+ const candidates = buildCandidates(platform);
231
+ const result = driveSync(probeCycle(candidates, platform, attempts));
232
+ return applyProbeResult(result, attempts, generation);
233
+ }
234
+ async function resolveGitExecutableAsync() {
235
+ const cached = readCache();
236
+ if (cached)
237
+ return cached.kind === "success" ? cached.path : BARE_GIT;
238
+ if (inFlightAsync)
239
+ return inFlightAsync;
240
+ const platform = _internals.platform();
241
+ const attempts = [];
242
+ const generation = cacheGeneration;
243
+ const candidates = buildCandidates(platform);
244
+ const run = (async () => {
245
+ const result = await driveAsync(probeCycle(candidates, platform, attempts));
246
+ return applyProbeResult(result, attempts, generation);
247
+ })();
248
+ inFlightAsync = run;
249
+ try {
250
+ return await run;
251
+ } finally {
252
+ if (inFlightAsync === run)
253
+ inFlightAsync = null;
254
+ }
255
+ }
256
+ function describeGitResolution() {
257
+ const cached = cache;
258
+ return {
259
+ resolved: cached?.kind === "success",
260
+ resolvedPath: cached?.kind === "success" ? cached.path : undefined,
261
+ attempts: [...lastAttempts],
262
+ overrideValue: effectiveOverride(),
263
+ overrideSource: overrideSource()
264
+ };
265
+ }
266
+ var GIT_BINARY_ENV_VAR = "OPENCODE_SWARM_GIT_BINARY", PER_PROBE_TIMEOUT_MS = 250, TOTAL_BUDGET_MS = 1000, NEGATIVE_CACHE_TTL_MS = 60000, BARE_GIT = "git", PROBE_MAX_BUFFER_BYTES, WINDOWS_PATH_EXTENSIONS, GIT_VERSION_PATTERN, PROBE_OUTPUT_EXCERPT_CHARS = 60, cache = null, lastAttempts, configuredOverride, inFlightAsync = null, cacheGeneration = 0, _internals;
267
+ var init_git_executable = __esm(() => {
268
+ init_warning_buffer();
269
+ PROBE_MAX_BUFFER_BYTES = 64 * 1024;
270
+ WINDOWS_PATH_EXTENSIONS = [".exe", ".cmd", ".bat"];
271
+ GIT_VERSION_PATTERN = /^git version \d+\.\d+/;
272
+ lastAttempts = [];
273
+ _internals = {
274
+ spawnSync,
275
+ platform: () => process.platform,
276
+ env: () => process.env,
277
+ now: () => Date.now(),
278
+ yieldToEventLoop: () => new Promise((resolve) => setTimeout(resolve, 0))
279
+ };
280
+ });
281
+
282
+ export { GIT_BINARY_ENV_VAR, resolveGitExecutable, resolveGitExecutableAsync, describeGitResolution, init_git_executable };
@@ -4,10 +4,10 @@ import {
4
4
  } from "./index-ed5ykebp.js";
5
5
  import {
6
6
  withEvidenceLock
7
- } from "./index-wd24zn2e.js";
7
+ } from "./index-f9vvg5xb.js";
8
8
  import {
9
9
  bunWrite
10
- } from "./index-4nt52yr9.js";
10
+ } from "./index-zj6t9zgx.js";
11
11
 
12
12
  // src/evidence/task-file.ts
13
13
  import { renameSync, unlinkSync } from "fs";