opencode-swarm 7.144.4 → 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 (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-m005xfdt.js} +2 -2
  5. package/dist/cli/{core-zjx9aqaf.js → core-6vdtfb8s.js} +4 -3
  6. package/dist/cli/{curation-policy-0wbrh11c.js → curation-policy-a511r0qz.js} +4 -4
  7. package/dist/cli/{curator-g54a7wv0.js → curator-0t87anp5.js} +33 -32
  8. package/dist/cli/{curator-drift-2jbjv03a.js → curator-drift-ckjm272w.js} +2 -2
  9. package/dist/cli/curator-llm-factory-j8tk9rxm.js +63 -0
  10. package/dist/cli/{dispatch-1y1rnv1h.js → dispatch-ndxbsk98.js} +2 -2
  11. package/dist/cli/{evidence-summary-service-fnr5y54e.js → evidence-summary-service-c22gahjc.js} +13 -12
  12. package/dist/cli/{gate-evidence-2xt1x07r.js → gate-evidence-hh8kc9wt.js} +7 -6
  13. package/dist/cli/guardrail-explain-9gjw2dsd.js +64 -0
  14. package/dist/cli/{guardrail-log-5w4b9zrw.js → guardrail-log-ejf5zjac.js} +4 -4
  15. package/dist/cli/{hive-promoter-x63ehffd.js → hive-promoter-gkbfpdtv.js} +33 -32
  16. package/dist/cli/{index-psvxq93b.js → index-1pxqkvvq.js} +2 -2
  17. package/dist/cli/{index-q67jb94n.js → index-3qdzpv91.js} +1 -1
  18. package/dist/cli/{index-9qq7c18c.js → index-58cvm3dw.js} +36 -1
  19. package/dist/cli/{index-p7cm3gtj.js → index-5wenr2vs.js} +35 -34
  20. package/dist/cli/{index-nckg4gxb.js → index-63tgh0cn.js} +15 -4
  21. package/dist/cli/{index-03pv47h2.js → index-641yjpk8.js} +6 -6
  22. package/dist/cli/{index-1csyxv0f.js → index-6z5jtf7d.js} +2 -2
  23. package/dist/cli/{index-z6v7kwpa.js → index-7e4q41nb.js} +1 -1
  24. package/dist/cli/{index-8j0va7jp.js → index-855hseq4.js} +43 -22
  25. package/dist/cli/index-9e6fdz2h.js +282 -0
  26. package/dist/cli/{index-mazgg5s2.js → index-9s8drsf9.js} +1 -1
  27. package/dist/cli/{index-cz25e8xp.js → index-a1hxejxc.js} +166 -34
  28. package/dist/cli/{index-b6e016tv.js → index-abtrcs16.js} +1 -1
  29. package/dist/cli/{index-8fwhhayc.js → index-b44qqqt2.js} +27 -18
  30. package/dist/cli/{index-k3cxyk66.js → index-cwtpqm5f.js} +1 -1
  31. package/dist/cli/{index-h98t1m88.js → index-dc04v786.js} +29 -1
  32. package/dist/cli/{index-d12jd5mn.js → index-dtbzyr3s.js} +1 -1
  33. package/dist/cli/{index-x6tp0hfr.js → index-ea09xax6.js} +5 -5
  34. package/dist/cli/{index-74hpm6sh.js → index-f36ybbsv.js} +12 -6
  35. package/dist/cli/{index-rn0eq85g.js → index-fv0s19g9.js} +1 -1
  36. package/dist/cli/{index-btmsqv7p.js → index-fv2pzwnp.js} +5 -4
  37. package/dist/cli/{index-ywn7vtxp.js → index-h1p08s3n.js} +1 -1
  38. package/dist/cli/{index-bt9aa01f.js → index-hkdgkkhb.js} +1 -1
  39. package/dist/cli/{index-y8j8ehc8.js → index-kdak6s63.js} +11 -5
  40. package/dist/cli/{index-az8etqpp.js → index-kh0jt9pg.js} +298 -1179
  41. package/dist/cli/{index-pw83zgny.js → index-mkmcz6x8.js} +3 -3
  42. package/dist/cli/{index-jabkn643.js → index-n4hwcsbd.js} +2 -2
  43. package/dist/cli/{index-2m7mavaz.js → index-rdgtfj74.js} +2 -2
  44. package/dist/cli/{index-yts89pqg.js → index-rnyt30tm.js} +4 -4
  45. package/dist/cli/{index-dty5qgk2.js → index-vdha477y.js} +1 -1
  46. package/dist/cli/{index-4w5qdbk7.js → index-wbrqvm2g.js} +6 -6
  47. package/dist/cli/{index-fqcjragy.js → index-wknz5c8q.js} +1 -1
  48. package/dist/cli/{index-zb0xcz9t.js → index-wm6f7t7w.js} +3 -3
  49. package/dist/cli/{index-q4ed1jk7.js → index-wmsehjq6.js} +1994 -1333
  50. package/dist/cli/{index-4nt52yr9.js → index-zj6t9zgx.js} +173 -25
  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-1d79m1tr.js} +12 -11
  55. package/dist/cli/{knowledge-events-nkrym4wb.js → knowledge-events-ces29ncg.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-pe8webc2.js} +4 -4
  58. package/dist/cli/{knowledge-validator-jrxvexv6.js → knowledge-validator-4yjf1f7k.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-d6exjmqj.js} +7 -5
  63. package/dist/cli/{schema-rptwqbm4.js → schema-2esybebd.js} +3 -1
  64. package/dist/cli/{scope-persistence-0bkaxawa.js → scope-persistence-ej59x0yc.js} +7 -6
  65. package/dist/cli/{skill-generator-nh8b4gjv.js → skill-generator-yqta3yrg.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-rwq0kke7.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,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  handleGuardrailExplain
4
- } from "./index-2m7mavaz.js";
4
+ } from "./index-rdgtfj74.js";
5
5
  import {
6
6
  handleGuardrailLog
7
- } from "./index-q67jb94n.js";
7
+ } from "./index-3qdzpv91.js";
8
8
  import {
9
9
  COMMAND_REGISTRY,
10
10
  SWARM_COMMAND_TOOL_ALLOWLIST,
@@ -85,67 +85,68 @@ import {
85
85
  handleWriteRetroCommand,
86
86
  normalizeSwarmCommandInput,
87
87
  resolveCommand
88
- } from "./index-q4ed1jk7.js";
89
- import"./index-d12jd5mn.js";
90
- import"./index-h98t1m88.js";
91
- import"./index-az8etqpp.js";
88
+ } from "./index-wmsehjq6.js";
89
+ import"./index-dtbzyr3s.js";
90
+ import"./index-dc04v786.js";
91
+ import"./index-kh0jt9pg.js";
92
92
  import"./index-134d35c1.js";
93
- import"./index-b6e016tv.js";
94
- import"./index-1csyxv0f.js";
95
- import"./index-fqcjragy.js";
93
+ import"./index-abtrcs16.js";
94
+ import"./index-6z5jtf7d.js";
95
+ import"./index-wknz5c8q.js";
96
96
  import"./index-y8552snf.js";
97
- import"./index-nckg4gxb.js";
97
+ import"./index-63tgh0cn.js";
98
98
  import"./index-70ha9e09.js";
99
99
  import"./index-c8s9a3zh.js";
100
100
  import"./index-9ss2m4rs.js";
101
- import"./index-74hpm6sh.js";
102
- import"./index-bt9aa01f.js";
103
- import"./index-zb0xcz9t.js";
104
- import"./index-x6tp0hfr.js";
105
- import"./index-yts89pqg.js";
106
- import"./index-dty5qgk2.js";
101
+ import"./index-f36ybbsv.js";
102
+ import"./index-hkdgkkhb.js";
103
+ import"./index-wm6f7t7w.js";
104
+ import"./index-ea09xax6.js";
105
+ import"./index-rnyt30tm.js";
106
+ import"./index-vdha477y.js";
107
107
  import"./index-rtry5xyf.js";
108
108
  import"./index-zsrtt42s.js";
109
- import"./index-jabkn643.js";
110
- import"./index-k3cxyk66.js";
111
- import"./index-cz25e8xp.js";
112
- import"./index-8j0va7jp.js";
113
- import"./index-pw83zgny.js";
114
- import"./index-z6v7kwpa.js";
109
+ import"./index-n4hwcsbd.js";
110
+ import"./index-cwtpqm5f.js";
111
+ import"./index-a1hxejxc.js";
112
+ import"./index-855hseq4.js";
113
+ import"./index-mkmcz6x8.js";
114
+ import"./index-7e4q41nb.js";
115
115
  import"./index-556ja8an.js";
116
116
  import"./index-7sy3aa9m.js";
117
117
  import"./index-wx8zdh4a.js";
118
- import"./index-8fwhhayc.js";
119
- import"./index-q1exe2b3.js";
120
- import"./index-03pv47h2.js";
121
- import"./index-4w5qdbk7.js";
122
- import"./index-psvxq93b.js";
118
+ import"./index-b44qqqt2.js";
119
+ import"./index-zy7f84cs.js";
120
+ import"./index-641yjpk8.js";
121
+ import"./index-wbrqvm2g.js";
122
+ import"./index-1pxqkvvq.js";
123
123
  import"./index-gprxjmm7.js";
124
124
  import"./index-n832052r.js";
125
- import"./index-rn0eq85g.js";
125
+ import"./index-fv0s19g9.js";
126
126
  import"./index-z6xqpmqg.js";
127
- import"./index-9qq7c18c.js";
127
+ import"./index-58cvm3dw.js";
128
128
  import {
129
129
  init_schema,
130
130
  stripKnownSwarmPrefix
131
- } from "./index-y8j8ehc8.js";
132
- import"./index-4rhhvd1a.js";
131
+ } from "./index-kdak6s63.js";
133
132
  import {
134
133
  AGENT_TOOL_MAP,
135
134
  ORCHESTRATOR_NAME,
136
135
  init_constants
137
136
  } from "./index-v3y3qg48.js";
137
+ import"./index-9e6fdz2h.js";
138
+ import"./index-4rhhvd1a.js";
138
139
  import"./index-zjygnfay.js";
139
140
  import"./index-ae75rja9.js";
140
- import"./index-ywn7vtxp.js";
141
- import"./index-mazgg5s2.js";
141
+ import"./index-h1p08s3n.js";
142
+ import"./index-9s8drsf9.js";
142
143
  import"./index-ed5ykebp.js";
143
144
  import"./index-bk5tah7q.js";
144
145
  import"./index-f9vvg5xb.js";
145
146
  import"./index-1jsmmx7y.js";
146
147
  import"./index-7g4c7s5r.js";
147
148
  import"./index-bpmtbmy9.js";
148
- import"./index-4nt52yr9.js";
149
+ import"./index-zj6t9zgx.js";
149
150
  import"./index-zgwm4ryv.js";
150
151
  import"./index-a76rekgs.js";
151
152
 
@@ -2,10 +2,14 @@
2
2
  import {
3
3
  readKnowledge,
4
4
  transactKnowledge
5
- } from "./index-03pv47h2.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-ywn7vtxp.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-ywn7vtxp.js";
9
+ } from "./index-h1p08s3n.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-mazgg5s2.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-nkrym4wb.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-jrxvexv6.js");
780
- const { KnowledgeConfigSchema } = await import("./schema-rptwqbm4.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-btmsqv7p.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-fqcjragy.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,7 +4,7 @@ import {
4
4
  PlanSchema,
5
5
  TaskStatusSchema,
6
6
  init_loader
7
- } from "./index-9qq7c18c.js";
7
+ } from "./index-58cvm3dw.js";
8
8
  import {
9
9
  assertProjectRoot,
10
10
  withEvidenceLock
@@ -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-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 };
@@ -7,7 +7,7 @@ import {
7
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";