opencode-swarm 7.184.5 → 7.184.7
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.
- package/.opencode/skills/issue-tracer/SKILL.md +3 -3
- package/.opencode/skills/issue-tracer/assets/pr-template.md +7 -0
- package/.opencode/skills/issue-tracer/references/acceptance-checks.md +30 -6
- package/.opencode/skills/issue-tracer/references/critic-gate.md +5 -0
- package/.opencode/skills/issue-tracer/references/evidence-artifacts.md +18 -2
- package/.opencode/skills/issue-tracer/scripts/repro-check.sh +604 -77
- package/.opencode/skills/issue-tracer/scripts/trace-check.sh +486 -60
- package/.opencode/skills/issue-tracer/scripts/trace-init.sh +30 -0
- package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
- package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
- package/dist/cli/{coder-settlement-m3r1kmzx.js → coder-settlement-2759zt77.js} +11 -11
- package/dist/cli/{config-doctor-1qgq2s96.js → config-doctor-g48tz4kt.js} +3 -3
- package/dist/cli/{core-h7pp6xzs.js → core-1jfgxw72.js} +4 -4
- package/dist/cli/{curation-policy-49f8jx48.js → curation-policy-k43q6b91.js} +4 -4
- package/dist/cli/{curator-drift-epvr1y5j.js → curator-drift-5wc9jfmy.js} +9 -9
- package/dist/cli/curator-llm-factory-jjd0cxb2.js +75 -0
- package/dist/cli/{curator-48mky2w8.js → curator-m7sja3jp.js} +38 -38
- package/dist/cli/{evidence-summary-service-akzas6he.js → evidence-summary-service-sx8x12w0.js} +17 -17
- package/dist/cli/{gate-evidence-gmq1th1b.js → gate-evidence-znfffz94.js} +8 -6
- package/dist/cli/guardrail-explain-x81m4s8q.js +76 -0
- package/dist/cli/{guardrail-log-n2cgvbh1.js → guardrail-log-mcv4ad3t.js} +7 -7
- package/dist/cli/{guardrail-reset-3br6fs4n.js → guardrail-reset-ksrr2r0n.js} +38 -38
- package/dist/cli/{hive-promoter-a1yw6evd.js → hive-promoter-06dzq5ms.js} +38 -38
- package/dist/cli/{index-fnbcd9ve.js → index-0prgjynb.js} +5 -5
- package/dist/cli/{index-ar2gsn6b.js → index-14j1jkyy.js} +6 -6
- package/dist/cli/{index-2zzmthnv.js → index-16smfppa.js} +4 -4
- package/dist/cli/{index-k1cxzdbd.js → index-1kz2repk.js} +4 -4
- package/dist/cli/{index-7ge1gcd3.js → index-1npynszx.js} +12 -12
- package/dist/cli/{index-82hy3v8f.js → index-1nwkzj24.js} +2 -2
- package/dist/cli/{index-ya32wfkp.js → index-1t2ctwkd.js} +1 -1
- package/dist/cli/{index-8pfcj7tz.js → index-2s0gy81b.js} +3 -3
- package/dist/cli/{index-k53a69vb.js → index-2t4zv1ag.js} +7 -14
- package/dist/cli/{index-3ny2d85s.js → index-3h0f07e9.js} +2 -2
- package/dist/cli/{index-qf75z3xz.js → index-42pchr9f.js} +1 -1
- package/dist/cli/{index-6jqxstq4.js → index-4qmeshfa.js} +5 -5
- package/dist/cli/{index-3n5zsp31.js → index-7xv2hvr6.js} +2 -2
- package/dist/cli/{index-10rsjhfy.js → index-82j1een1.js} +46 -19
- package/dist/cli/{index-h9hvszf7.js → index-8bvpcbk8.js} +40 -40
- package/dist/cli/{index-wy3zpwjy.js → index-98a0rxby.js} +1 -1
- package/dist/cli/{index-vyjped9g.js → index-b1v0zxnh.js} +2 -2
- package/dist/cli/{index-cdvb33mn.js → index-bf055zyw.js} +2 -2
- package/dist/cli/{index-2adz24wr.js → index-c5c7hrz1.js} +3 -3
- package/dist/cli/{index-6bn74qs9.js → index-dyddcx8h.js} +168 -105
- package/dist/cli/{index-xf69xty9.js → index-e1zrgvqg.js} +1 -1
- package/dist/cli/{index-yqcaf6r3.js → index-eecz2kna.js} +7 -7
- package/dist/cli/{index-1511m10x.js → index-enjsn68b.js} +7 -7
- package/dist/cli/{index-wzec3c4g.js → index-ezagem2g.js} +4 -0
- package/dist/cli/{index-zzvxj02e.js → index-fr6x6vn2.js} +1 -1
- package/dist/cli/{index-475bkab8.js → index-g2r6t7by.js} +1 -1
- package/dist/cli/{index-tzejdtyx.js → index-kbd6apth.js} +38 -38
- package/dist/cli/{index-e602am4j.js → index-m8rt7a3g.js} +4 -4
- package/dist/cli/{index-xf6j4ypk.js → index-mp60wy1f.js} +4 -4
- package/dist/cli/{index-6g664sy8.js → index-q39ecyaq.js} +1 -1
- package/dist/cli/{index-tajh3egk.js → index-q4a0j3nh.js} +5 -5
- package/dist/cli/{index-earq3mda.js → index-qeqn241m.js} +1 -1
- package/dist/cli/{index-ae2jf510.js → index-raj6y6d3.js} +2 -2
- package/dist/cli/{index-f0nj3d8z.js → index-rmspt7xm.js} +1 -1
- package/dist/cli/{index-ezpzd88b.js → index-rwzrbcm9.js} +2 -2
- package/dist/cli/{index-jvk95e6y.js → index-s95ghsy1.js} +1 -1
- package/dist/cli/{index-f4z1ez09.js → index-sxxj47cy.js} +6 -6
- package/dist/cli/{index-w9hxzcz4.js → index-t0mb5a9p.js} +1 -1
- package/dist/cli/{index-wehwbv89.js → index-x16a0c6b.js} +7 -7
- package/dist/cli/{index-456awy1p.js → index-xqxqepsy.js} +2 -2
- package/dist/cli/{index-zeg8y1fw.js → index-ywmknn6m.js} +1 -1
- package/dist/cli/{index-d1bfyxj5.js → index-z1qs160n.js} +1 -1
- package/dist/cli/{index-gcdgtcg5.js → index-z7recmq5.js} +3 -3
- package/dist/cli/index.d.ts +36 -7
- package/dist/cli/index.js +352 -92
- package/dist/cli/{knowledge-escalator-rdgspj3v.js → knowledge-escalator-ghx76dcv.js} +12 -12
- package/dist/cli/{knowledge-events-zh16e78y.js → knowledge-events-kpw6fbmc.js} +10 -10
- package/dist/cli/{knowledge-link-ap2274vm.js → knowledge-link-xw6vsbx3.js} +3 -3
- package/dist/cli/{knowledge-store-jxke13cv.js → knowledge-store-fhdrpxdm.js} +4 -4
- package/dist/cli/{knowledge-validator-24myt9fp.js → knowledge-validator-7jr0aka1.js} +6 -6
- package/dist/cli/{mcp-a4q99fmb.js → mcp-v7cgf5tn.js} +1 -1
- package/dist/cli/{model-preflight-qy88p9fc.js → model-preflight-kn3xqvfk.js} +38 -38
- package/dist/cli/{pending-delegations-9vqyq3bj.js → pending-delegations-z7mcbecn.js} +10 -10
- package/dist/cli/{pr-subscriptions-hrefmtay.js → pr-subscriptions-1sb07tx3.js} +10 -10
- package/dist/cli/{pr-workflow-gate-1jcs4wnp.js → pr-workflow-gate-ph4fvf47.js} +38 -38
- package/dist/cli/{runner-yz3ysehf.js → runner-pvdhxh74.js} +4 -4
- package/dist/cli/{scan-cursor-krn56ew2.js → scan-cursor-7ny9bnmk.js} +5 -5
- package/dist/cli/{schema-zqankczb.js → schema-pjkzvcw8.js} +2 -2
- package/dist/cli/{scope-persistence-5qrjm5d2.js → scope-persistence-mkb8yc5s.js} +14 -14
- package/dist/cli/{server-7wydssat.js → server-4e853cwk.js} +38 -38
- package/dist/cli/{skill-generator-br4wctes.js → skill-generator-v6n0kwh0.js} +14 -14
- package/dist/cli/{snapshot-coordination-init-g4sg2fxv.js → snapshot-coordination-init-agx2sn6h.js} +38 -38
- package/dist/cli/{speckit-checkoff-82s1qy0c.js → speckit-checkoff-wfsbvt1b.js} +5 -5
- package/dist/cli/{workspace-snapshot-xwhhznt3.js → workspace-snapshot-553c6cd3.js} +3 -3
- package/dist/cli/{worktree-collision-ownership-19n9em8b.js → worktree-collision-ownership-4znww3nt.js} +11 -11
- package/dist/cli/{worktree-isolation-hkd7xtdp.js → worktree-isolation-w4k8q59z.js} +38 -38
- package/dist/commands/registry.d.ts +1 -1
- package/dist/gate-evidence.d.ts +51 -0
- package/dist/index.js +34 -34
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/record-branch-freshness.d.ts +6 -0
- package/dist/tools/record-trace-validation.d.ts +11 -0
- package/dist/tools/recover-stage-a-task.d.ts +5 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/dist/workflow/settlement-recovery.d.ts +52 -0
- package/dist/workflow/stage-a-repair.d.ts +13 -8
- package/dist/workflow/task-recovery-status.d.ts +11 -2
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-782jtn0a.js +0 -75
- package/dist/cli/guardrail-explain-xgahzbts.js +0 -76
package/dist/cli/index.js
CHANGED
|
@@ -14,74 +14,74 @@ import {
|
|
|
14
14
|
readCachePackageVersion,
|
|
15
15
|
resolveCommand,
|
|
16
16
|
safeRealpathSync
|
|
17
|
-
} from "./index-
|
|
18
|
-
import"./index-
|
|
17
|
+
} from "./index-dyddcx8h.js";
|
|
18
|
+
import"./index-c5c7hrz1.js";
|
|
19
19
|
import"./index-hamqvzqn.js";
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-
|
|
24
|
-
import"./index-
|
|
20
|
+
import"./index-q39ecyaq.js";
|
|
21
|
+
import"./index-z7recmq5.js";
|
|
22
|
+
import"./index-rwzrbcm9.js";
|
|
23
|
+
import"./index-1npynszx.js";
|
|
24
|
+
import"./index-1t2ctwkd.js";
|
|
25
25
|
import"./index-txdagbh7.js";
|
|
26
|
-
import"./index-
|
|
26
|
+
import"./index-z1qs160n.js";
|
|
27
27
|
import"./index-6b295cas.js";
|
|
28
|
-
import"./index-
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-
|
|
28
|
+
import"./index-mp60wy1f.js";
|
|
29
|
+
import"./index-4qmeshfa.js";
|
|
30
|
+
import"./index-raj6y6d3.js";
|
|
31
31
|
import"./index-rdec0y3z.js";
|
|
32
|
-
import"./index-
|
|
32
|
+
import"./index-14j1jkyy.js";
|
|
33
33
|
import"./index-cjapb4hy.js";
|
|
34
34
|
import"./index-zsrtt42s.js";
|
|
35
|
-
import"./index-
|
|
36
|
-
import"./index-
|
|
37
|
-
import"./index-
|
|
35
|
+
import"./index-x16a0c6b.js";
|
|
36
|
+
import"./index-b1v0zxnh.js";
|
|
37
|
+
import"./index-7xv2hvr6.js";
|
|
38
38
|
import"./index-pt7h91zc.js";
|
|
39
39
|
import"./index-q7sjgr1y.js";
|
|
40
|
-
import"./index-
|
|
41
|
-
import"./index-
|
|
42
|
-
import"./index-
|
|
43
|
-
import"./index-
|
|
44
|
-
import"./index-
|
|
45
|
-
import"./index-
|
|
40
|
+
import"./index-1nwkzj24.js";
|
|
41
|
+
import"./index-82j1een1.js";
|
|
42
|
+
import"./index-1kz2repk.js";
|
|
43
|
+
import"./index-sxxj47cy.js";
|
|
44
|
+
import"./index-eecz2kna.js";
|
|
45
|
+
import"./index-98a0rxby.js";
|
|
46
46
|
import"./index-2s7dvzff.js";
|
|
47
|
-
import"./index-
|
|
48
|
-
import"./index-
|
|
47
|
+
import"./index-m8rt7a3g.js";
|
|
48
|
+
import"./index-qeqn241m.js";
|
|
49
49
|
import"./index-rtry5xyf.js";
|
|
50
|
-
import"./index-
|
|
50
|
+
import"./index-2s0gy81b.js";
|
|
51
51
|
import"./index-frcemc0b.js";
|
|
52
52
|
import"./index-0725jpp7.js";
|
|
53
|
-
import"./index-
|
|
54
|
-
import"./index-
|
|
55
|
-
import"./index-
|
|
56
|
-
import"./index-
|
|
57
|
-
import"./index-
|
|
58
|
-
import"./index-
|
|
53
|
+
import"./index-0prgjynb.js";
|
|
54
|
+
import"./index-q4a0j3nh.js";
|
|
55
|
+
import"./index-s95ghsy1.js";
|
|
56
|
+
import"./index-xqxqepsy.js";
|
|
57
|
+
import"./index-rmspt7xm.js";
|
|
58
|
+
import"./index-t0mb5a9p.js";
|
|
59
59
|
import"./index-rdm3px0g.js";
|
|
60
60
|
import"./index-ry16d01s.js";
|
|
61
|
-
import"./index-
|
|
62
|
-
import"./index-
|
|
61
|
+
import"./index-fr6x6vn2.js";
|
|
62
|
+
import"./index-enjsn68b.js";
|
|
63
63
|
import"./index-vzm6zre7.js";
|
|
64
64
|
import"./index-ae75rja9.js";
|
|
65
|
-
import"./index-
|
|
66
|
-
import"./index-
|
|
65
|
+
import"./index-g2r6t7by.js";
|
|
66
|
+
import"./index-e1zrgvqg.js";
|
|
67
67
|
import"./index-t7hmqgjy.js";
|
|
68
68
|
import"./index-x1gyqgze.js";
|
|
69
69
|
import"./index-mc72pk74.js";
|
|
70
70
|
import"./index-c1ggtmpm.js";
|
|
71
71
|
import"./index-ejhxgyvm.js";
|
|
72
72
|
import"./index-7g4c7s5r.js";
|
|
73
|
-
import"./index-
|
|
73
|
+
import"./index-2t4zv1ag.js";
|
|
74
74
|
import"./index-gx2vp8gx.js";
|
|
75
|
-
import"./index-
|
|
75
|
+
import"./index-42pchr9f.js";
|
|
76
76
|
import"./index-zxdawwc7.js";
|
|
77
77
|
import {
|
|
78
78
|
init_package,
|
|
79
79
|
package_default
|
|
80
|
-
} from "./index-
|
|
80
|
+
} from "./index-3h0f07e9.js";
|
|
81
81
|
import {
|
|
82
82
|
DEFAULT_AGENT_CONFIGS,
|
|
83
83
|
init_constants
|
|
84
|
-
} from "./index-
|
|
84
|
+
} from "./index-ezagem2g.js";
|
|
85
85
|
import"./index-bk5tah7q.js";
|
|
86
86
|
import"./index-gknz3bv1.js";
|
|
87
87
|
import"./index-zpsr8rpc.js";
|
|
@@ -118,6 +118,24 @@ function segmentDepthBelowRoot(resolved) {
|
|
|
118
118
|
const { root } = path.parse(resolved);
|
|
119
119
|
return resolved.slice(root.length).split(path.sep).filter((s) => s.length > 0).length;
|
|
120
120
|
}
|
|
121
|
+
function normalizePathForComparison(value) {
|
|
122
|
+
const normalized = path.normalize(path.resolve(value));
|
|
123
|
+
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
124
|
+
}
|
|
125
|
+
function isExactConfiguredConfigChild(canonicalTarget, configuredDir) {
|
|
126
|
+
const canonicalConfigDir = safeRealpathSync(configuredDir, configuredDir);
|
|
127
|
+
const canonicalParent = safeRealpathSync(path.dirname(canonicalTarget), path.dirname(canonicalTarget));
|
|
128
|
+
if (canonicalConfigDir === null || canonicalParent === null) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return normalizePathForComparison(canonicalParent) === normalizePathForComparison(canonicalConfigDir);
|
|
132
|
+
}
|
|
133
|
+
function hasSafeConfigArtifactParent(resolved, configuredDir) {
|
|
134
|
+
if (configuredDir !== undefined) {
|
|
135
|
+
return isExactConfiguredConfigChild(resolved, configuredDir);
|
|
136
|
+
}
|
|
137
|
+
return path.basename(path.dirname(resolved)) === path.basename(CONFIG_DIR);
|
|
138
|
+
}
|
|
121
139
|
function isSafeCachePath(p) {
|
|
122
140
|
const resolved = path.resolve(p);
|
|
123
141
|
const home = path.resolve(os.homedir());
|
|
@@ -164,7 +182,7 @@ function isSafeLockFilePath(p) {
|
|
|
164
182
|
}
|
|
165
183
|
return true;
|
|
166
184
|
}
|
|
167
|
-
function isSafePromptsDir(p) {
|
|
185
|
+
function isSafePromptsDir(p, configuredDir) {
|
|
168
186
|
const canonical = safeRealpathSync(p, p);
|
|
169
187
|
if (canonical === null) {
|
|
170
188
|
return false;
|
|
@@ -180,12 +198,12 @@ function isSafePromptsDir(p) {
|
|
|
180
198
|
if (path.basename(resolved) !== "opencode-swarm") {
|
|
181
199
|
return false;
|
|
182
200
|
}
|
|
183
|
-
if (
|
|
201
|
+
if (!hasSafeConfigArtifactParent(resolved, configuredDir)) {
|
|
184
202
|
return false;
|
|
185
203
|
}
|
|
186
204
|
return true;
|
|
187
205
|
}
|
|
188
|
-
function isSafePluginConfigPath(p) {
|
|
206
|
+
function isSafePluginConfigPath(p, configuredDir) {
|
|
189
207
|
const canonical = safeRealpathSync(p, p);
|
|
190
208
|
if (canonical === null) {
|
|
191
209
|
return false;
|
|
@@ -201,25 +219,235 @@ function isSafePluginConfigPath(p) {
|
|
|
201
219
|
if (path.basename(resolved) !== "opencode-swarm.json") {
|
|
202
220
|
return false;
|
|
203
221
|
}
|
|
204
|
-
if (
|
|
222
|
+
if (!hasSafeConfigArtifactParent(resolved, configuredDir)) {
|
|
205
223
|
return false;
|
|
206
224
|
}
|
|
207
225
|
return true;
|
|
208
226
|
}
|
|
227
|
+
function isSafeInstallBackupPath(p, configuredDir) {
|
|
228
|
+
const canonical = safeRealpathSync(p, p);
|
|
229
|
+
if (canonical === null) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
const resolved = path.resolve(canonical);
|
|
233
|
+
const home = path.resolve(os.homedir());
|
|
234
|
+
if (resolved === "/" || resolved === home || resolved.length <= home.length) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (segmentDepthBelowRoot(resolved) < 3) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (path.basename(resolved) !== "opencode.swarm-install-backup.json") {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
return hasSafeConfigArtifactParent(resolved, configuredDir);
|
|
244
|
+
}
|
|
245
|
+
var cleanupFs = {
|
|
246
|
+
lstatSync: (target) => fs.lstatSync(target),
|
|
247
|
+
openSync: (target, flags) => fs.openSync(target, flags),
|
|
248
|
+
fstatSync: (descriptor) => fs.fstatSync(descriptor),
|
|
249
|
+
closeSync: (descriptor) => fs.closeSync(descriptor),
|
|
250
|
+
unlinkSync: (target) => fs.unlinkSync(target),
|
|
251
|
+
rmSync: (target) => fs.rmSync(target, { recursive: true }),
|
|
252
|
+
existsSync: (target) => fs.existsSync(target)
|
|
253
|
+
};
|
|
254
|
+
function sameFileIdentity(left, right) {
|
|
255
|
+
return left.dev === right.dev && left.ino === right.ino;
|
|
256
|
+
}
|
|
257
|
+
function snapshotCleanupTarget(canonicalTarget, configuredDir, kind) {
|
|
258
|
+
const canonicalConfigDir = safeRealpathSync(configuredDir, configuredDir);
|
|
259
|
+
const canonicalParent = safeRealpathSync(path.dirname(canonicalTarget), path.dirname(canonicalTarget));
|
|
260
|
+
if (canonicalConfigDir === null || canonicalParent === null || normalizePathForComparison(canonicalConfigDir) !== normalizePathForComparison(canonicalParent)) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
const parentStat = cleanupFs.lstatSync(path.dirname(canonicalTarget));
|
|
265
|
+
if (parentStat.isSymbolicLink() || !parentStat.isDirectory())
|
|
266
|
+
return null;
|
|
267
|
+
const stat = cleanupFs.lstatSync(canonicalTarget);
|
|
268
|
+
if (stat.isSymbolicLink())
|
|
269
|
+
return null;
|
|
270
|
+
if (kind === "file" ? !stat.isFile() : !stat.isDirectory())
|
|
271
|
+
return null;
|
|
272
|
+
return { parent: parentStat, target: stat };
|
|
273
|
+
} catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function removeBoundCleanupTarget(canonicalTarget, configuredDir, kind) {
|
|
278
|
+
const before = snapshotCleanupTarget(canonicalTarget, configuredDir, kind);
|
|
279
|
+
if (before === null) {
|
|
280
|
+
if (kind === "file") {
|
|
281
|
+
try {
|
|
282
|
+
const target = cleanupFs.lstatSync(canonicalTarget);
|
|
283
|
+
if (!target.isSymbolicLink() && target.isDirectory()) {
|
|
284
|
+
return { ok: false, error: "path is a directory, not a file" };
|
|
285
|
+
}
|
|
286
|
+
} catch {}
|
|
287
|
+
}
|
|
288
|
+
return { ok: false, error: "target or parent changed during validation" };
|
|
289
|
+
}
|
|
290
|
+
let descriptor;
|
|
291
|
+
try {
|
|
292
|
+
if (kind === "file") {
|
|
293
|
+
descriptor = cleanupFs.openSync(canonicalTarget, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0));
|
|
294
|
+
const opened = cleanupFs.fstatSync(descriptor);
|
|
295
|
+
if (!sameFileIdentity(before.target, opened)) {
|
|
296
|
+
return { ok: false, error: "target changed while being opened" };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const immediatelyBefore = snapshotCleanupTarget(canonicalTarget, configuredDir, kind);
|
|
300
|
+
if (immediatelyBefore === null || !sameFileIdentity(before.parent, immediatelyBefore.parent) || !sameFileIdentity(before.target, immediatelyBefore.target)) {
|
|
301
|
+
if (immediatelyBefore === null && kind === "file") {
|
|
302
|
+
try {
|
|
303
|
+
const target = cleanupFs.lstatSync(canonicalTarget);
|
|
304
|
+
if (!target.isSymbolicLink() && target.isDirectory()) {
|
|
305
|
+
return { ok: false, error: "path is a directory, not a file" };
|
|
306
|
+
}
|
|
307
|
+
} catch {}
|
|
308
|
+
}
|
|
309
|
+
return { ok: false, error: "target or parent changed before deletion" };
|
|
310
|
+
}
|
|
311
|
+
if (kind === "file") {
|
|
312
|
+
cleanupFs.unlinkSync(canonicalTarget);
|
|
313
|
+
} else {
|
|
314
|
+
cleanupFs.rmSync(canonicalTarget);
|
|
315
|
+
}
|
|
316
|
+
if (cleanupFs.existsSync(canonicalTarget)) {
|
|
317
|
+
return { ok: false, error: "delete returned but target still exists" };
|
|
318
|
+
}
|
|
319
|
+
return { ok: true };
|
|
320
|
+
} catch (error) {
|
|
321
|
+
return {
|
|
322
|
+
ok: false,
|
|
323
|
+
error: error instanceof Error ? error.message : String(error)
|
|
324
|
+
};
|
|
325
|
+
} finally {
|
|
326
|
+
if (descriptor !== undefined) {
|
|
327
|
+
try {
|
|
328
|
+
cleanupFs.closeSync(descriptor);
|
|
329
|
+
} catch {}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
var _test_exports = { cleanupFs, removeBoundCleanupTarget };
|
|
209
334
|
function ensureDir(dir) {
|
|
210
335
|
if (!fs.existsSync(dir)) {
|
|
211
336
|
fs.mkdirSync(dir, { recursive: true });
|
|
212
337
|
}
|
|
213
338
|
}
|
|
339
|
+
function normalizeJsonc(content) {
|
|
340
|
+
let normalized = "";
|
|
341
|
+
let inString = false;
|
|
342
|
+
let escaped = false;
|
|
343
|
+
const nextSignificantToken = (from) => {
|
|
344
|
+
let index = from;
|
|
345
|
+
while (index < content.length) {
|
|
346
|
+
const current = content[index];
|
|
347
|
+
if (/\s/.test(current)) {
|
|
348
|
+
index += 1;
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
if (current === "/" && content[index + 1] === "/") {
|
|
352
|
+
index += 2;
|
|
353
|
+
while (index < content.length && content[index] !== `
|
|
354
|
+
` && content[index] !== "\r") {
|
|
355
|
+
index += 1;
|
|
356
|
+
}
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (current === "/" && content[index + 1] === "*") {
|
|
360
|
+
const close = content.indexOf("*/", index + 2);
|
|
361
|
+
if (close < 0) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
index = close + 2;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
return index;
|
|
368
|
+
}
|
|
369
|
+
return content.length;
|
|
370
|
+
};
|
|
371
|
+
for (let index = 0;index < content.length; index += 1) {
|
|
372
|
+
const current = content[index];
|
|
373
|
+
if (inString) {
|
|
374
|
+
normalized += current;
|
|
375
|
+
if (escaped) {
|
|
376
|
+
escaped = false;
|
|
377
|
+
} else if (current === "\\") {
|
|
378
|
+
escaped = true;
|
|
379
|
+
} else if (current === '"') {
|
|
380
|
+
inString = false;
|
|
381
|
+
}
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (current === '"') {
|
|
385
|
+
inString = true;
|
|
386
|
+
normalized += current;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (current === "/" && content[index + 1] === "/") {
|
|
390
|
+
index += 2;
|
|
391
|
+
while (index < content.length && content[index] !== `
|
|
392
|
+
` && content[index] !== "\r") {
|
|
393
|
+
index += 1;
|
|
394
|
+
}
|
|
395
|
+
if (index < content.length) {
|
|
396
|
+
normalized += content[index];
|
|
397
|
+
}
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
if (current === "/" && content[index + 1] === "*") {
|
|
401
|
+
const close = content.indexOf("*/", index + 2);
|
|
402
|
+
if (close < 0) {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
index = close + 1;
|
|
406
|
+
normalized += " ";
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (current === ",") {
|
|
410
|
+
const next = nextSignificantToken(index + 1);
|
|
411
|
+
if (next === null) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
if (content[next] === "}" || content[next] === "]") {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
normalized += current;
|
|
419
|
+
}
|
|
420
|
+
return normalized;
|
|
421
|
+
}
|
|
214
422
|
function loadJson(filepath) {
|
|
215
423
|
try {
|
|
216
424
|
const content = fs.readFileSync(filepath, "utf-8");
|
|
217
|
-
const
|
|
218
|
-
|
|
425
|
+
const normalized = normalizeJsonc(content);
|
|
426
|
+
if (normalized === null) {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
return JSON.parse(normalized);
|
|
219
430
|
} catch {
|
|
220
431
|
return null;
|
|
221
432
|
}
|
|
222
433
|
}
|
|
434
|
+
function isOpenCodeConfig(value) {
|
|
435
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
436
|
+
}
|
|
437
|
+
function loadConfigObject(filepath) {
|
|
438
|
+
if (!fs.existsSync(filepath))
|
|
439
|
+
return { kind: "missing" };
|
|
440
|
+
try {
|
|
441
|
+
const content = fs.readFileSync(filepath, "utf-8");
|
|
442
|
+
const normalized = normalizeJsonc(content);
|
|
443
|
+
if (normalized === null)
|
|
444
|
+
return { kind: "invalid" };
|
|
445
|
+
const parsed = JSON.parse(normalized);
|
|
446
|
+
return isOpenCodeConfig(parsed) ? { kind: "object", value: parsed } : { kind: "non-object" };
|
|
447
|
+
} catch {
|
|
448
|
+
return { kind: "invalid" };
|
|
449
|
+
}
|
|
450
|
+
}
|
|
223
451
|
function saveJson(filepath, data) {
|
|
224
452
|
fs.writeFileSync(filepath, `${JSON.stringify(data, null, 2)}
|
|
225
453
|
`, "utf-8");
|
|
@@ -249,12 +477,22 @@ async function install() {
|
|
|
249
477
|
const LEGACY_CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
|
|
250
478
|
const configExisted = fs.existsSync(OPENCODE_CONFIG_PATH);
|
|
251
479
|
const originalConfigRaw = configExisted ? fs.readFileSync(OPENCODE_CONFIG_PATH, "utf-8") : null;
|
|
252
|
-
const
|
|
480
|
+
const originalConfigLoad = loadConfigObject(OPENCODE_CONFIG_PATH);
|
|
481
|
+
if (originalConfigLoad.kind === "non-object") {
|
|
482
|
+
console.error("\u2717 opencode.json must contain a JSON object at the root; refusing to overwrite it.");
|
|
483
|
+
return 1;
|
|
484
|
+
}
|
|
485
|
+
const originalConfig = originalConfigLoad.kind === "object" ? originalConfigLoad.value : null;
|
|
253
486
|
let opencodeConfig;
|
|
254
487
|
if (originalConfig) {
|
|
255
488
|
opencodeConfig = structuredClone(originalConfig);
|
|
256
489
|
} else {
|
|
257
|
-
const
|
|
490
|
+
const legacyConfigLoad = loadConfigObject(LEGACY_CONFIG_PATH);
|
|
491
|
+
if (legacyConfigLoad.kind === "non-object") {
|
|
492
|
+
console.error("\u2717 config.json must contain a JSON object at the root; refusing to overwrite it.");
|
|
493
|
+
return 1;
|
|
494
|
+
}
|
|
495
|
+
const legacyConfig = legacyConfigLoad.kind === "object" ? legacyConfigLoad.value : null;
|
|
258
496
|
if (legacyConfig) {
|
|
259
497
|
console.log("\u26A0 Migrating existing config from config.json to opencode.json...");
|
|
260
498
|
opencodeConfig = structuredClone(legacyConfig);
|
|
@@ -421,9 +659,9 @@ function evictPluginCaches(additionalPaths = []) {
|
|
|
421
659
|
}
|
|
422
660
|
const versionBeforeDelete = readCachePackageVersion(canonical);
|
|
423
661
|
try {
|
|
424
|
-
|
|
425
|
-
if (
|
|
426
|
-
failed.push(`${canonical} (
|
|
662
|
+
const removal = removeBoundCleanupTarget(canonical, path.dirname(canonical), "directory");
|
|
663
|
+
if (!removal.ok) {
|
|
664
|
+
failed.push(`${canonical} (${removal.error ?? "target changed before deletion"})`);
|
|
427
665
|
continue;
|
|
428
666
|
}
|
|
429
667
|
cleared.push(canonical);
|
|
@@ -448,9 +686,9 @@ function evictLockFiles() {
|
|
|
448
686
|
continue;
|
|
449
687
|
}
|
|
450
688
|
try {
|
|
451
|
-
|
|
452
|
-
if (
|
|
453
|
-
failed.push(`${canonical} (
|
|
689
|
+
const removal = removeBoundCleanupTarget(canonical, path.dirname(canonical), "file");
|
|
690
|
+
if (!removal.ok) {
|
|
691
|
+
failed.push(`${canonical} (${removal.error ?? "target changed before deletion"})`);
|
|
454
692
|
continue;
|
|
455
693
|
}
|
|
456
694
|
cleared.push(canonical);
|
|
@@ -465,10 +703,65 @@ function evictLockFiles() {
|
|
|
465
703
|
}
|
|
466
704
|
return { cleared, failed };
|
|
467
705
|
}
|
|
706
|
+
function cleanupPluginOwnedFiles() {
|
|
707
|
+
let cleaned = false;
|
|
708
|
+
let hadTargets = false;
|
|
709
|
+
if (fs.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
710
|
+
hadTargets = true;
|
|
711
|
+
const canonical = safeRealpathSync(PLUGIN_CONFIG_PATH, PLUGIN_CONFIG_PATH);
|
|
712
|
+
if (canonical === null || !isSafePluginConfigPath(canonical, CONFIG_DIR)) {
|
|
713
|
+
console.log(`\u2717 Refused to remove plugin config (failed safety check): ${canonical ?? PLUGIN_CONFIG_PATH}`);
|
|
714
|
+
} else {
|
|
715
|
+
const removal = removeBoundCleanupTarget(canonical, CONFIG_DIR, "file");
|
|
716
|
+
if (removal.ok) {
|
|
717
|
+
console.log(`\u2713 Removed plugin config: ${canonical}`);
|
|
718
|
+
cleaned = true;
|
|
719
|
+
} else {
|
|
720
|
+
console.log(`\u2717 Refused to remove plugin config (target changed): ${canonical} (${removal.error})`);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (fs.existsSync(PROMPTS_DIR)) {
|
|
725
|
+
hadTargets = true;
|
|
726
|
+
const canonical = safeRealpathSync(PROMPTS_DIR, PROMPTS_DIR);
|
|
727
|
+
if (canonical === null || !isSafePromptsDir(canonical, CONFIG_DIR)) {
|
|
728
|
+
console.log(`\u2717 Refused to remove custom prompts (failed safety check): ${canonical ?? PROMPTS_DIR}`);
|
|
729
|
+
} else {
|
|
730
|
+
const removal = removeBoundCleanupTarget(canonical, CONFIG_DIR, "directory");
|
|
731
|
+
if (removal.ok) {
|
|
732
|
+
console.log(`\u2713 Removed custom prompts: ${canonical}`);
|
|
733
|
+
cleaned = true;
|
|
734
|
+
} else {
|
|
735
|
+
console.log(`\u2717 Refused to remove custom prompts (target changed): ${canonical} (${removal.error})`);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const backupPath = path.join(CONFIG_DIR, "opencode.swarm-install-backup.json");
|
|
740
|
+
if (fs.existsSync(backupPath)) {
|
|
741
|
+
hadTargets = true;
|
|
742
|
+
const canonical = safeRealpathSync(backupPath, backupPath);
|
|
743
|
+
if (canonical === null || !isSafeInstallBackupPath(canonical, CONFIG_DIR)) {
|
|
744
|
+
console.log(`\u2717 Refused to remove install backup (failed safety check): ${canonical ?? backupPath}`);
|
|
745
|
+
} else {
|
|
746
|
+
const removal = removeBoundCleanupTarget(canonical, CONFIG_DIR, "file");
|
|
747
|
+
if (removal.ok) {
|
|
748
|
+
console.log(`\u2713 Removed install backup: ${canonical}`);
|
|
749
|
+
cleaned = true;
|
|
750
|
+
} else {
|
|
751
|
+
console.log(`\u2717 Refused to remove install backup (target changed): ${canonical} (${removal.error})`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (!cleaned && !hadTargets) {
|
|
756
|
+
console.log("\u2713 No config files to clean up");
|
|
757
|
+
}
|
|
758
|
+
return { cleaned, hadTargets };
|
|
759
|
+
}
|
|
468
760
|
async function uninstall() {
|
|
469
761
|
try {
|
|
470
762
|
console.log(`\uD83D\uDC1D Uninstalling OpenCode Swarm...
|
|
471
763
|
`);
|
|
764
|
+
const cleanupResult = process.argv.includes("--clean") ? cleanupPluginOwnedFiles() : { cleaned: false, hadTargets: false };
|
|
472
765
|
const opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
473
766
|
if (!opencodeConfig) {
|
|
474
767
|
if (fs.existsSync(OPENCODE_CONFIG_PATH)) {
|
|
@@ -476,7 +769,9 @@ async function uninstall() {
|
|
|
476
769
|
return 1;
|
|
477
770
|
} else {
|
|
478
771
|
console.log(`\u26A0 No opencode config found at: ${OPENCODE_CONFIG_PATH}`);
|
|
479
|
-
|
|
772
|
+
if (!cleanupResult.cleaned && !cleanupResult.hadTargets) {
|
|
773
|
+
console.log("Nothing to uninstall.");
|
|
774
|
+
}
|
|
480
775
|
return 0;
|
|
481
776
|
}
|
|
482
777
|
}
|
|
@@ -508,43 +803,6 @@ async function uninstall() {
|
|
|
508
803
|
saveJson(OPENCODE_CONFIG_PATH, opencodeConfig);
|
|
509
804
|
console.log("\u2713 Removed opencode-swarm from OpenCode plugins");
|
|
510
805
|
console.log("\u2713 Re-enabled default OpenCode agents (explore, general)");
|
|
511
|
-
if (process.argv.includes("--clean")) {
|
|
512
|
-
let cleaned = false;
|
|
513
|
-
if (fs.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
514
|
-
const canonical = safeRealpathSync(PLUGIN_CONFIG_PATH, PLUGIN_CONFIG_PATH);
|
|
515
|
-
if (canonical === null || !isSafePluginConfigPath(canonical)) {
|
|
516
|
-
console.log(`\u2717 Refused to remove plugin config (failed safety check): ${canonical ?? PLUGIN_CONFIG_PATH}`);
|
|
517
|
-
} else {
|
|
518
|
-
fs.unlinkSync(canonical);
|
|
519
|
-
console.log(`\u2713 Removed plugin config: ${canonical}`);
|
|
520
|
-
cleaned = true;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
if (fs.existsSync(PROMPTS_DIR)) {
|
|
524
|
-
const canonical = safeRealpathSync(PROMPTS_DIR, PROMPTS_DIR);
|
|
525
|
-
if (canonical === null || !isSafePromptsDir(canonical)) {
|
|
526
|
-
console.log(`\u2717 Refused to remove custom prompts (failed safety check): ${canonical ?? PROMPTS_DIR}`);
|
|
527
|
-
} else {
|
|
528
|
-
fs.rmSync(canonical, { recursive: true });
|
|
529
|
-
console.log(`\u2713 Removed custom prompts: ${canonical}`);
|
|
530
|
-
cleaned = true;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
const backupPath = path.join(CONFIG_DIR, "opencode.swarm-install-backup.json");
|
|
534
|
-
if (fs.existsSync(backupPath)) {
|
|
535
|
-
const canonical = safeRealpathSync(backupPath, backupPath);
|
|
536
|
-
if (canonical === null || path.basename(canonical) !== "opencode.swarm-install-backup.json" || path.basename(path.dirname(canonical)) !== path.basename(CONFIG_DIR)) {
|
|
537
|
-
console.log(`\u2717 Refused to remove install backup (failed safety check): ${canonical ?? backupPath}`);
|
|
538
|
-
} else {
|
|
539
|
-
fs.unlinkSync(canonical);
|
|
540
|
-
console.log(`\u2713 Removed install backup: ${canonical}`);
|
|
541
|
-
cleaned = true;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
if (!cleaned) {
|
|
545
|
-
console.log("\u2713 No config files to clean up");
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
806
|
console.log(`
|
|
549
807
|
\u2705 Uninstall complete!`);
|
|
550
808
|
return 0;
|
|
@@ -645,7 +903,7 @@ async function main() {
|
|
|
645
903
|
const exitCode = await run(["ci", ...args.slice(1)]);
|
|
646
904
|
process.exit(exitCode);
|
|
647
905
|
} else if (command === "mcp") {
|
|
648
|
-
const { handleMcpCommand } = await import("./mcp-
|
|
906
|
+
const { handleMcpCommand } = await import("./mcp-v7cgf5tn.js");
|
|
649
907
|
const exitCode = await handleMcpCommand(args.slice(1));
|
|
650
908
|
process.exit(exitCode);
|
|
651
909
|
} else {
|
|
@@ -713,7 +971,9 @@ export {
|
|
|
713
971
|
isSafePromptsDir,
|
|
714
972
|
isSafePluginConfigPath,
|
|
715
973
|
isSafeLockFilePath,
|
|
974
|
+
isSafeInstallBackupPath,
|
|
716
975
|
isSafeCachePath,
|
|
717
976
|
evictPluginCaches,
|
|
718
|
-
evictLockFiles
|
|
977
|
+
evictLockFiles,
|
|
978
|
+
_test_exports
|
|
719
979
|
};
|
|
@@ -9,31 +9,31 @@ import {
|
|
|
9
9
|
maybeEscalateOnViolation,
|
|
10
10
|
maybeQuarantineOnContradiction,
|
|
11
11
|
readRecentEscalations
|
|
12
|
-
} from "./index-
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
12
|
+
} from "./index-4qmeshfa.js";
|
|
13
|
+
import"./index-eecz2kna.js";
|
|
14
|
+
import"./index-98a0rxby.js";
|
|
15
15
|
import"./index-2s7dvzff.js";
|
|
16
|
-
import"./index-
|
|
16
|
+
import"./index-2s0gy81b.js";
|
|
17
17
|
import"./index-frcemc0b.js";
|
|
18
18
|
import"./index-0725jpp7.js";
|
|
19
|
-
import"./index-
|
|
20
|
-
import"./index-
|
|
19
|
+
import"./index-fr6x6vn2.js";
|
|
20
|
+
import"./index-enjsn68b.js";
|
|
21
21
|
import"./index-vzm6zre7.js";
|
|
22
22
|
import"./index-ae75rja9.js";
|
|
23
|
-
import"./index-
|
|
24
|
-
import"./index-
|
|
23
|
+
import"./index-g2r6t7by.js";
|
|
24
|
+
import"./index-e1zrgvqg.js";
|
|
25
25
|
import"./index-t7hmqgjy.js";
|
|
26
26
|
import"./index-x1gyqgze.js";
|
|
27
27
|
import"./index-mc72pk74.js";
|
|
28
28
|
import"./index-c1ggtmpm.js";
|
|
29
29
|
import"./index-ejhxgyvm.js";
|
|
30
30
|
import"./index-7g4c7s5r.js";
|
|
31
|
-
import"./index-
|
|
31
|
+
import"./index-2t4zv1ag.js";
|
|
32
32
|
import"./index-gx2vp8gx.js";
|
|
33
|
-
import"./index-
|
|
33
|
+
import"./index-42pchr9f.js";
|
|
34
34
|
import"./index-zxdawwc7.js";
|
|
35
|
-
import"./index-
|
|
36
|
-
import"./index-
|
|
35
|
+
import"./index-3h0f07e9.js";
|
|
36
|
+
import"./index-ezagem2g.js";
|
|
37
37
|
import"./index-bk5tah7q.js";
|
|
38
38
|
import"./index-gknz3bv1.js";
|
|
39
39
|
import"./index-zpsr8rpc.js";
|
|
@@ -29,28 +29,28 @@ import {
|
|
|
29
29
|
resolveKnowledgeCounterBaselinePath,
|
|
30
30
|
resolveKnowledgeEventsPath,
|
|
31
31
|
resolveLegacyApplicationLogPath
|
|
32
|
-
} from "./index-
|
|
33
|
-
import"./index-
|
|
32
|
+
} from "./index-eecz2kna.js";
|
|
33
|
+
import"./index-98a0rxby.js";
|
|
34
34
|
import"./index-2s7dvzff.js";
|
|
35
|
-
import"./index-
|
|
35
|
+
import"./index-2s0gy81b.js";
|
|
36
36
|
import"./index-frcemc0b.js";
|
|
37
37
|
import"./index-0725jpp7.js";
|
|
38
|
-
import"./index-
|
|
38
|
+
import"./index-fr6x6vn2.js";
|
|
39
39
|
import"./index-ae75rja9.js";
|
|
40
|
-
import"./index-
|
|
41
|
-
import"./index-
|
|
40
|
+
import"./index-g2r6t7by.js";
|
|
41
|
+
import"./index-e1zrgvqg.js";
|
|
42
42
|
import"./index-t7hmqgjy.js";
|
|
43
43
|
import"./index-x1gyqgze.js";
|
|
44
44
|
import"./index-mc72pk74.js";
|
|
45
45
|
import"./index-c1ggtmpm.js";
|
|
46
46
|
import"./index-ejhxgyvm.js";
|
|
47
47
|
import"./index-7g4c7s5r.js";
|
|
48
|
-
import"./index-
|
|
48
|
+
import"./index-2t4zv1ag.js";
|
|
49
49
|
import"./index-gx2vp8gx.js";
|
|
50
|
-
import"./index-
|
|
50
|
+
import"./index-42pchr9f.js";
|
|
51
51
|
import"./index-zxdawwc7.js";
|
|
52
|
-
import"./index-
|
|
53
|
-
import"./index-
|
|
52
|
+
import"./index-3h0f07e9.js";
|
|
53
|
+
import"./index-ezagem2g.js";
|
|
54
54
|
import"./index-bk5tah7q.js";
|
|
55
55
|
import"./index-gknz3bv1.js";
|
|
56
56
|
import"./index-zpsr8rpc.js";
|