opencode-swarm 7.107.6 → 7.109.0
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/clarify-spec/SKILL.md +15 -9
- package/.opencode/skills/critic-gate/SKILL.md +10 -4
- package/.opencode/skills/phase-wrap/SKILL.md +2 -2
- package/.opencode/skills/plan/SKILL.md +23 -11
- package/.opencode/skills/specify/SKILL.md +27 -9
- package/dist/cli/{capability-probe-wsjzcp48.js → capability-probe-sh9bwh39.js} +2 -1
- package/dist/cli/{config-doctor-kdq3vae4.js → config-doctor-q354tb2w.js} +2 -2
- package/dist/cli/core-vev13ej2.js +34 -0
- package/dist/cli/{curator-jpwvkpdv.js → curator-3efwdf9x.js} +25 -21
- package/dist/cli/{curator-drift-ed7p5mfy.js → curator-drift-169wgaxn.js} +4 -4
- package/dist/cli/curator-llm-factory-nttpcx4b.js +40 -0
- package/dist/cli/{dispatch-anmxxhen.js → dispatch-zr1xja4t.js} +2 -2
- package/dist/cli/{evidence-summary-service-6zsgw7x7.js → evidence-summary-service-j7jwf20f.js} +10 -8
- package/dist/cli/{gate-evidence-pgr7d942.js → gate-evidence-v6ds8rcp.js} +5 -4
- package/dist/cli/guardrail-explain-e85gbj0r.js +41 -0
- package/dist/cli/{guardrail-log-fjypsmek.js → guardrail-log-8mqqsssq.js} +4 -4
- package/dist/cli/hive-promoter-rc6z2x8f.js +48 -0
- package/dist/cli/{index-9b7qp18e.js → index-1cn967sa.js} +2 -2
- package/dist/cli/{index-h28wfp7n.js → index-1mjzvkzj.js} +29 -25
- package/dist/cli/{index-n1sptn1w.js → index-2nt4mq9n.js} +1 -1
- package/dist/cli/{index-57rthc1z.js → index-3e7jajwe.js} +2 -2
- package/dist/cli/{index-bq8kd9r9.js → index-5gnp8fyw.js} +3 -3
- package/dist/cli/index-5mkc2f9z.js +154 -0
- package/dist/cli/{index-0kxc7t16.js → index-6jng9c8t.js} +1 -1
- package/dist/cli/{index-b9v501fr.js → index-7xgqky26.js} +33 -5
- package/dist/cli/{index-4r5z8sgw.js → index-85bacexr.js} +2 -2
- package/dist/cli/{index-bpgqbwmf.js → index-9qxntjtx.js} +6 -6
- package/dist/cli/index-f1qyj61w.js +418 -0
- package/dist/cli/{index-wvxhynxq.js → index-fm7xz1ne.js} +1 -1
- package/dist/cli/{index-dfdg4ws5.js → index-fz1jgbvw.js} +6 -6
- package/dist/cli/{index-pchpahdf.js → index-h4c4rrwx.js} +20 -3
- package/dist/cli/{index-kxm3bdjh.js → index-mmny81g1.js} +6 -6
- package/dist/cli/{index-v4fcn4tr.js → index-q1exe2b3.js} +2 -198
- package/dist/cli/{index-57ymmh7h.js → index-r3j3458j.js} +4 -4
- package/dist/cli/{index-91j1sqzm.js → index-scww5b77.js} +47 -0
- package/dist/cli/{index-572t1qff.js → index-vb5t1kvs.js} +1477 -2045
- package/dist/cli/{index-3naa2ajc.js → index-vvk2g744.js} +10 -156
- package/dist/cli/{index-zej8cy0j.js → index-vx76tcxe.js} +1 -1
- package/dist/cli/{index-6h82c2h0.js → index-wfq4r95s.js} +1057 -193
- package/dist/cli/{index-xmarctsf.js → index-wg0665ft.js} +7 -7
- package/dist/cli/{index-4vsgp5a8.js → index-wj4jeavn.js} +1 -1
- package/dist/cli/index-wvrj16f0.js +206 -0
- package/dist/cli/index-x2q0gnt8.js +254 -0
- package/dist/cli/{index-xg18az81.js → index-yw8qpf51.js} +1 -1
- package/dist/cli/index.js +25 -21
- package/dist/cli/{knowledge-escalator-3sgwrgy9.js → knowledge-escalator-6v7sjprx.js} +8 -7
- package/dist/cli/{knowledge-events-kfc6xmkw.js → knowledge-events-6n3x3he2.js} +6 -5
- package/dist/cli/{knowledge-store-kyacem71.js → knowledge-store-exkw6yb1.js} +6 -5
- package/dist/cli/{knowledge-validator-ez3ws8ef.js → knowledge-validator-exymfcb9.js} +7 -6
- package/dist/cli/{pending-delegations-vfnpm8zt.js → pending-delegations-yyz3fcfn.js} +5 -4
- package/dist/cli/{pr-subscriptions-bpvazmsw.js → pr-subscriptions-vv8byxe6.js} +6 -5
- package/dist/cli/{schema-x0ekqzvs.js → schema-x17zmd03.js} +1 -1
- package/dist/cli/scope-persistence-6m5nsp1r.js +20 -0
- package/dist/cli/{skill-generator-x83re96d.js → skill-generator-mx9br4ty.js} +9 -8
- package/dist/commands/_shared/url-security.d.ts +13 -3
- package/dist/commands/close.d.ts +11 -0
- package/dist/commands/lanes.d.ts +35 -0
- package/dist/commands/registry.d.ts +9 -2
- package/dist/commands/sdd.d.ts +10 -0
- package/dist/config/schema.d.ts +102 -0
- package/dist/git/branch.d.ts +53 -7
- package/dist/git/index.d.ts +5 -1
- package/dist/git/pr.d.ts +35 -2
- package/dist/hooks/delegation-gate/worktree-isolation.d.ts +118 -2
- package/dist/hooks/delegation-gate/worktree-merge-status.d.ts +17 -0
- package/dist/hooks/init-orphan-recovery-advisory.d.ts +58 -0
- package/dist/hooks/init-orphan-recovery.d.ts +65 -0
- package/dist/index.js +452 -436
- package/dist/sandbox/executor.d.ts +11 -1
- package/dist/sandbox/linux/bubblewrap-executor.d.ts +3 -1
- package/dist/sandbox/macos/sandbox-exec-executor.d.ts +3 -1
- package/dist/sandbox/win32/native-sandbox-executor.d.ts +1 -1
- package/dist/sandbox/win32/restricted-environment-executor.d.ts +4 -1
- package/dist/sdd/effective-spec.d.ts +21 -0
- package/dist/turbo/lean/runner.d.ts +11 -20
- package/dist/turbo/lean/worktree.d.ts +9 -3
- package/dist/utils/bun-compat.d.ts +30 -0
- package/dist/worktree/core.d.ts +55 -0
- package/dist/worktree/merge.d.ts +5 -1
- package/dist/worktree/types.d.ts +38 -0
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-9y15npd5.js +0 -36
- package/dist/cli/guardrail-explain-jk0amzae.js +0 -37
- package/dist/cli/hive-promoter-j2krbdn9.js +0 -44
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
resolveKnowledgeStoreDir
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-2nt4mq9n.js";
|
|
5
5
|
import {
|
|
6
6
|
isActiveStatus
|
|
7
7
|
} from "./index-bfwt3abw.js";
|
|
8
|
-
import {
|
|
9
|
-
atomicWriteFile
|
|
10
|
-
} from "./index-9b7qp18e.js";
|
|
11
8
|
import {
|
|
12
9
|
readCachedParsedFile
|
|
13
10
|
} from "./index-jtqkh8jf.js";
|
|
11
|
+
import {
|
|
12
|
+
atomicWriteFile
|
|
13
|
+
} from "./index-1cn967sa.js";
|
|
14
14
|
import {
|
|
15
15
|
require_proper_lockfile
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-vvk2g744.js";
|
|
17
17
|
import {
|
|
18
18
|
__require,
|
|
19
19
|
__toESM
|
|
@@ -525,7 +525,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
|
|
|
525
525
|
const recovered = touched.filter((e) => e.confidence > CONFIDENCE_FLOOR + FLOOR_EPSILON && e.confidence_floor_demoted);
|
|
526
526
|
if (atFloor.length === 0 && recovered.length === 0)
|
|
527
527
|
return;
|
|
528
|
-
const { readKnowledgeCounterRollups, effectiveRetrievalOutcomes } = await import("./knowledge-events-
|
|
528
|
+
const { readKnowledgeCounterRollups, effectiveRetrievalOutcomes } = await import("./knowledge-events-6n3x3he2.js");
|
|
529
529
|
const rollups = await readKnowledgeCounterRollups(directory);
|
|
530
530
|
const flagIds = new Set;
|
|
531
531
|
for (const e of atFloor) {
|
|
@@ -592,7 +592,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
|
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
594
|
if (action === "quarantine" && toQuarantine.length > 0) {
|
|
595
|
-
const { quarantineEntry } = await import("./knowledge-validator-
|
|
595
|
+
const { quarantineEntry } = await import("./knowledge-validator-exymfcb9.js");
|
|
596
596
|
for (const { id } of toQuarantine) {
|
|
597
597
|
await quarantineEntry(directory, id, "confidence_floor_negative_outcome", "auto").catch((err) => {
|
|
598
598
|
console.warn("[knowledge-store] confidence-floor quarantine failed (best-effort):", err instanceof Error ? err.message : String(err));
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
exports_runner_client,
|
|
4
|
+
init_runner_client
|
|
5
|
+
} from "./index-q1exe2b3.js";
|
|
6
|
+
import {
|
|
7
|
+
__esm,
|
|
8
|
+
__toCommonJS
|
|
9
|
+
} from "./index-a76rekgs.js";
|
|
10
|
+
|
|
11
|
+
// src/sandbox/capability-probe.ts
|
|
12
|
+
import { execFile, spawnSync } from "child_process";
|
|
13
|
+
import * as os from "os";
|
|
14
|
+
function withProbeTimeout(cmd, args, ms) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const controller = new AbortController;
|
|
17
|
+
const timer = setTimeout(() => {
|
|
18
|
+
controller.abort();
|
|
19
|
+
proc?.kill();
|
|
20
|
+
}, ms);
|
|
21
|
+
const unref = timer.unref;
|
|
22
|
+
if (typeof unref === "function") {
|
|
23
|
+
unref.call(timer);
|
|
24
|
+
}
|
|
25
|
+
let proc;
|
|
26
|
+
try {
|
|
27
|
+
proc = execFile(cmd, args, {
|
|
28
|
+
signal: controller.signal,
|
|
29
|
+
timeout: ms,
|
|
30
|
+
windowsHide: true,
|
|
31
|
+
cwd: os.tmpdir()
|
|
32
|
+
}, (error, stdout, _stderr) => {
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
if (error) {
|
|
35
|
+
const exc = error;
|
|
36
|
+
if (exc.code === "ENOENT" || exc.code === "ENOTFOUND") {
|
|
37
|
+
reject(new Error("binary not found"));
|
|
38
|
+
} else {
|
|
39
|
+
reject(error);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
resolve(stdout?.trim() ?? "");
|
|
44
|
+
});
|
|
45
|
+
} catch (spawnError) {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
reject(spawnError);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async function probeLinux() {
|
|
52
|
+
try {
|
|
53
|
+
const output = await withProbeTimeout("bwrap", ["--version"], 2000);
|
|
54
|
+
if (output.length > 0) {
|
|
55
|
+
return {
|
|
56
|
+
status: "enabled",
|
|
57
|
+
mechanism: "Bubblewrap",
|
|
58
|
+
platform: "linux"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
status: "disabled",
|
|
63
|
+
mechanism: "Bubblewrap",
|
|
64
|
+
platform: "linux",
|
|
65
|
+
error: "binary returned empty version"
|
|
66
|
+
};
|
|
67
|
+
} catch (err) {
|
|
68
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
69
|
+
if (msg === "binary not found") {
|
|
70
|
+
return {
|
|
71
|
+
status: "unsupported",
|
|
72
|
+
mechanism: "Bubblewrap",
|
|
73
|
+
platform: "linux",
|
|
74
|
+
error: msg
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
status: "disabled",
|
|
79
|
+
mechanism: "Bubblewrap",
|
|
80
|
+
platform: "linux",
|
|
81
|
+
error: msg
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function probeMacOS() {
|
|
86
|
+
try {
|
|
87
|
+
const output = await withProbeTimeout("sandbox-exec", ["--version"], 2000);
|
|
88
|
+
if (output.length > 0) {
|
|
89
|
+
return {
|
|
90
|
+
status: "enabled",
|
|
91
|
+
mechanism: "sandbox-exec",
|
|
92
|
+
platform: "darwin"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
status: "disabled",
|
|
97
|
+
mechanism: "sandbox-exec",
|
|
98
|
+
platform: "darwin",
|
|
99
|
+
error: "binary returned empty version"
|
|
100
|
+
};
|
|
101
|
+
} catch (err) {
|
|
102
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
103
|
+
if (msg === "binary not found") {
|
|
104
|
+
return {
|
|
105
|
+
status: "unsupported",
|
|
106
|
+
mechanism: "sandbox-exec",
|
|
107
|
+
platform: "darwin",
|
|
108
|
+
error: msg
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
status: "disabled",
|
|
113
|
+
mechanism: "sandbox-exec",
|
|
114
|
+
platform: "darwin",
|
|
115
|
+
error: msg
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function probeWindows() {
|
|
120
|
+
try {
|
|
121
|
+
const { probe: runnerProbe } = (init_runner_client(), __toCommonJS(exports_runner_client));
|
|
122
|
+
const result = runnerProbe();
|
|
123
|
+
if (result.available) {
|
|
124
|
+
return {
|
|
125
|
+
status: "enabled",
|
|
126
|
+
platform: "win32",
|
|
127
|
+
mechanism: `native-runner/${result.mode}`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
} catch {}
|
|
131
|
+
try {
|
|
132
|
+
const result = spawnSync("cmd", ["/c", "echo", "ok"], {
|
|
133
|
+
windowsHide: true,
|
|
134
|
+
encoding: "utf-8",
|
|
135
|
+
timeout: 5000,
|
|
136
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
137
|
+
});
|
|
138
|
+
if (result.error) {
|
|
139
|
+
return {
|
|
140
|
+
status: "disabled",
|
|
141
|
+
platform: "win32",
|
|
142
|
+
mechanism: "PowerShell wrapper",
|
|
143
|
+
error: `cmd.exe probe failed: ${result.error.code}`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return result.status === 0 ? {
|
|
147
|
+
status: "enabled",
|
|
148
|
+
platform: "win32",
|
|
149
|
+
mechanism: "PowerShell wrapper"
|
|
150
|
+
} : {
|
|
151
|
+
status: "disabled",
|
|
152
|
+
platform: "win32",
|
|
153
|
+
mechanism: "PowerShell wrapper",
|
|
154
|
+
error: "cmd.exe probe returned non-zero"
|
|
155
|
+
};
|
|
156
|
+
} catch (err) {
|
|
157
|
+
return {
|
|
158
|
+
status: "disabled",
|
|
159
|
+
platform: "win32",
|
|
160
|
+
mechanism: "PowerShell wrapper",
|
|
161
|
+
error: String(err)
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function isBubblewrapAvailable() {
|
|
166
|
+
return _cached?.status === "enabled" && _cached?.platform === "linux";
|
|
167
|
+
}
|
|
168
|
+
function isSandboxExecAvailable() {
|
|
169
|
+
return _cached?.status === "enabled" && _cached?.platform === "darwin";
|
|
170
|
+
}
|
|
171
|
+
function isWindowsSandboxAvailable() {
|
|
172
|
+
return _cached?.status === "enabled" && _cached?.platform === "win32";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
class SandboxCapabilityProbe {
|
|
176
|
+
async detect() {
|
|
177
|
+
if (_cached !== undefined) {
|
|
178
|
+
return _cached;
|
|
179
|
+
}
|
|
180
|
+
const platform = process.platform;
|
|
181
|
+
switch (platform) {
|
|
182
|
+
case "linux":
|
|
183
|
+
_cached = await probeLinux();
|
|
184
|
+
break;
|
|
185
|
+
case "darwin":
|
|
186
|
+
_cached = await probeMacOS();
|
|
187
|
+
break;
|
|
188
|
+
case "win32":
|
|
189
|
+
_cached = probeWindows();
|
|
190
|
+
break;
|
|
191
|
+
default: {
|
|
192
|
+
_cached = {
|
|
193
|
+
status: "unsupported",
|
|
194
|
+
mechanism: "unknown",
|
|
195
|
+
platform,
|
|
196
|
+
error: `unsupported platform: ${platform}`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return _cached;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
var _cached;
|
|
204
|
+
var init_capability_probe = () => {};
|
|
205
|
+
|
|
206
|
+
export { isBubblewrapAvailable, isSandboxExecAvailable, isWindowsSandboxAvailable, SandboxCapabilityProbe, init_capability_probe };
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
require_proper_lockfile
|
|
4
|
+
} from "./index-vvk2g744.js";
|
|
5
|
+
import {
|
|
6
|
+
bunWrite
|
|
7
|
+
} from "./index-7xgqky26.js";
|
|
8
|
+
import {
|
|
9
|
+
__toESM
|
|
10
|
+
} from "./index-a76rekgs.js";
|
|
11
|
+
|
|
12
|
+
// src/scope/scope-persistence.ts
|
|
13
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
14
|
+
import * as fs from "fs";
|
|
15
|
+
import * as path from "path";
|
|
16
|
+
var SCOPE_SCHEMA_VERSION = 1;
|
|
17
|
+
var DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
18
|
+
var LOCK_STALE_MS = 30 * 1000;
|
|
19
|
+
var SCOPES_DIR = ".swarm/scopes";
|
|
20
|
+
var MAX_FILES_PER_SCOPE = 1e4;
|
|
21
|
+
var MAX_PLAN_BYTES = 10 * 1024 * 1024;
|
|
22
|
+
var MAX_SCOPE_BYTES = 2 * 1024 * 1024;
|
|
23
|
+
var WINDOWS_RESERVED = new Set([
|
|
24
|
+
"CON",
|
|
25
|
+
"PRN",
|
|
26
|
+
"AUX",
|
|
27
|
+
"NUL",
|
|
28
|
+
"COM1",
|
|
29
|
+
"COM2",
|
|
30
|
+
"COM3",
|
|
31
|
+
"COM4",
|
|
32
|
+
"COM5",
|
|
33
|
+
"COM6",
|
|
34
|
+
"COM7",
|
|
35
|
+
"COM8",
|
|
36
|
+
"COM9",
|
|
37
|
+
"LPT1",
|
|
38
|
+
"LPT2",
|
|
39
|
+
"LPT3",
|
|
40
|
+
"LPT4",
|
|
41
|
+
"LPT5",
|
|
42
|
+
"LPT6",
|
|
43
|
+
"LPT7",
|
|
44
|
+
"LPT8",
|
|
45
|
+
"LPT9"
|
|
46
|
+
]);
|
|
47
|
+
function getScopesDir(directory) {
|
|
48
|
+
return path.join(directory, SCOPES_DIR);
|
|
49
|
+
}
|
|
50
|
+
function isSafeTaskId(taskId) {
|
|
51
|
+
if (typeof taskId !== "string")
|
|
52
|
+
return false;
|
|
53
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(taskId))
|
|
54
|
+
return false;
|
|
55
|
+
const head = taskId.replace(/\.+$/, "").split(".")[0].toUpperCase();
|
|
56
|
+
if (WINDOWS_RESERVED.has(head))
|
|
57
|
+
return false;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
function isScopesDirSafe(directory, scopesDir) {
|
|
61
|
+
try {
|
|
62
|
+
const resolvedWorkspace = fs.realpathSync(directory);
|
|
63
|
+
const resolvedScopes = fs.realpathSync(scopesDir);
|
|
64
|
+
const rel = path.relative(resolvedWorkspace, resolvedScopes);
|
|
65
|
+
return rel.length > 0 && !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function getScopeFilePath(directory, taskId) {
|
|
71
|
+
if (!isSafeTaskId(taskId)) {
|
|
72
|
+
throw new Error(`Invalid taskId for scope persistence: ${taskId}`);
|
|
73
|
+
}
|
|
74
|
+
return path.join(getScopesDir(directory), `scope-${taskId}.json`);
|
|
75
|
+
}
|
|
76
|
+
async function writeScopeToDisk(directory, taskId, files, ttlMs = DEFAULT_TTL_MS) {
|
|
77
|
+
if (!isSafeTaskId(taskId))
|
|
78
|
+
return;
|
|
79
|
+
if (!Array.isArray(files) || files.length === 0)
|
|
80
|
+
return;
|
|
81
|
+
if (files.length > MAX_FILES_PER_SCOPE)
|
|
82
|
+
return;
|
|
83
|
+
const scopesDir = getScopesDir(directory);
|
|
84
|
+
const scopePath = getScopeFilePath(directory, taskId);
|
|
85
|
+
try {
|
|
86
|
+
fs.mkdirSync(scopesDir, { recursive: true });
|
|
87
|
+
} catch {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!isScopesDirSafe(directory, scopesDir))
|
|
91
|
+
return;
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
const payload = {
|
|
94
|
+
version: SCOPE_SCHEMA_VERSION,
|
|
95
|
+
taskId,
|
|
96
|
+
declaredAt: now,
|
|
97
|
+
expiresAt: now + ttlMs,
|
|
98
|
+
files: [...files]
|
|
99
|
+
};
|
|
100
|
+
const content = JSON.stringify(payload, null, 2);
|
|
101
|
+
try {
|
|
102
|
+
const flags = fs.constants.O_WRONLY | fs.constants.O_CREAT;
|
|
103
|
+
const nofollow = fs.constants.O_NOFOLLOW ?? 0;
|
|
104
|
+
const fd = fs.openSync(scopePath, flags | nofollow);
|
|
105
|
+
fs.closeSync(fd);
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
let release;
|
|
110
|
+
try {
|
|
111
|
+
release = await import_proper_lockfile.default.lock(scopePath, {
|
|
112
|
+
stale: LOCK_STALE_MS,
|
|
113
|
+
retries: { retries: 3, minTimeout: 50, maxTimeout: 200 },
|
|
114
|
+
realpath: false
|
|
115
|
+
});
|
|
116
|
+
await atomicWrite(scopePath, content);
|
|
117
|
+
} catch {} finally {
|
|
118
|
+
if (release) {
|
|
119
|
+
try {
|
|
120
|
+
await release();
|
|
121
|
+
} catch {}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function atomicWrite(targetPath, content) {
|
|
126
|
+
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
127
|
+
try {
|
|
128
|
+
await bunWrite(tempPath, content);
|
|
129
|
+
fs.renameSync(tempPath, targetPath);
|
|
130
|
+
} finally {
|
|
131
|
+
try {
|
|
132
|
+
fs.unlinkSync(tempPath);
|
|
133
|
+
} catch {}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function readScopeFromDisk(directory, taskId) {
|
|
137
|
+
if (!isSafeTaskId(taskId))
|
|
138
|
+
return null;
|
|
139
|
+
const scopesDir = getScopesDir(directory);
|
|
140
|
+
if (!isScopesDirSafe(directory, scopesDir))
|
|
141
|
+
return null;
|
|
142
|
+
const scopePath = getScopeFilePath(directory, taskId);
|
|
143
|
+
const nofollow = fs.constants.O_NOFOLLOW ?? 0;
|
|
144
|
+
let fd;
|
|
145
|
+
try {
|
|
146
|
+
fd = fs.openSync(scopePath, fs.constants.O_RDONLY | nofollow);
|
|
147
|
+
} catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
let raw;
|
|
151
|
+
try {
|
|
152
|
+
const stat = fs.fstatSync(fd);
|
|
153
|
+
if (!stat.isFile())
|
|
154
|
+
return null;
|
|
155
|
+
if (stat.size > MAX_SCOPE_BYTES)
|
|
156
|
+
return null;
|
|
157
|
+
const buf = Buffer.alloc(stat.size);
|
|
158
|
+
fs.readSync(fd, buf, 0, stat.size, 0);
|
|
159
|
+
raw = buf.toString("utf-8");
|
|
160
|
+
} catch {
|
|
161
|
+
return null;
|
|
162
|
+
} finally {
|
|
163
|
+
try {
|
|
164
|
+
fs.closeSync(fd);
|
|
165
|
+
} catch {}
|
|
166
|
+
}
|
|
167
|
+
if (!raw.trim())
|
|
168
|
+
return null;
|
|
169
|
+
let parsed;
|
|
170
|
+
try {
|
|
171
|
+
parsed = JSON.parse(raw);
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
if (parsed.version !== SCOPE_SCHEMA_VERSION)
|
|
176
|
+
return null;
|
|
177
|
+
if (parsed.taskId !== taskId)
|
|
178
|
+
return null;
|
|
179
|
+
const now = Date.now();
|
|
180
|
+
if (typeof parsed.declaredAt !== "number" || parsed.declaredAt > now) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (typeof parsed.expiresAt !== "number" || now > parsed.expiresAt) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (!Array.isArray(parsed.files))
|
|
187
|
+
return null;
|
|
188
|
+
if (parsed.files.length > MAX_FILES_PER_SCOPE)
|
|
189
|
+
return null;
|
|
190
|
+
const files = parsed.files.filter((f) => typeof f === "string");
|
|
191
|
+
return files.length > 0 ? files : null;
|
|
192
|
+
}
|
|
193
|
+
function readPlanScope(directory, taskId) {
|
|
194
|
+
if (!isSafeTaskId(taskId))
|
|
195
|
+
return null;
|
|
196
|
+
try {
|
|
197
|
+
const planPath = path.join(directory, ".swarm", "plan.json");
|
|
198
|
+
const stat = fs.statSync(planPath);
|
|
199
|
+
if (!stat.isFile())
|
|
200
|
+
return null;
|
|
201
|
+
if (stat.size > MAX_PLAN_BYTES)
|
|
202
|
+
return null;
|
|
203
|
+
const raw = fs.readFileSync(planPath, "utf-8");
|
|
204
|
+
const plan = JSON.parse(raw);
|
|
205
|
+
for (const phase of plan.phases ?? []) {
|
|
206
|
+
for (const task of phase.tasks ?? []) {
|
|
207
|
+
if (task.id !== taskId)
|
|
208
|
+
continue;
|
|
209
|
+
const ft = task.files_touched;
|
|
210
|
+
if (Array.isArray(ft) && ft.length > 0) {
|
|
211
|
+
if (ft.length > MAX_FILES_PER_SCOPE)
|
|
212
|
+
return null;
|
|
213
|
+
return ft.filter((f) => typeof f === "string");
|
|
214
|
+
}
|
|
215
|
+
if (typeof ft === "string" && ft.length > 0)
|
|
216
|
+
return [ft];
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
} catch {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function clearScopeForTask(directory, taskId) {
|
|
226
|
+
if (!isSafeTaskId(taskId))
|
|
227
|
+
return;
|
|
228
|
+
try {
|
|
229
|
+
fs.unlinkSync(getScopeFilePath(directory, taskId));
|
|
230
|
+
} catch {}
|
|
231
|
+
}
|
|
232
|
+
function clearAllScopes(directory) {
|
|
233
|
+
try {
|
|
234
|
+
fs.rmSync(getScopesDir(directory), { recursive: true, force: true });
|
|
235
|
+
} catch {}
|
|
236
|
+
}
|
|
237
|
+
function resolveScopeWithFallbacks(input) {
|
|
238
|
+
const { directory, taskId, inMemoryScope, pendingMapScope } = input;
|
|
239
|
+
if (inMemoryScope && inMemoryScope.length > 0)
|
|
240
|
+
return inMemoryScope;
|
|
241
|
+
if (taskId) {
|
|
242
|
+
const disk = readScopeFromDisk(directory, taskId);
|
|
243
|
+
if (disk && disk.length > 0)
|
|
244
|
+
return disk;
|
|
245
|
+
const plan = readPlanScope(directory, taskId);
|
|
246
|
+
if (plan && plan.length > 0)
|
|
247
|
+
return plan;
|
|
248
|
+
}
|
|
249
|
+
if (pendingMapScope && pendingMapScope.length > 0)
|
|
250
|
+
return pendingMapScope;
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export { writeScopeToDisk, readScopeFromDisk, readPlanScope, clearScopeForTask, clearAllScopes, resolveScopeWithFallbacks };
|
package/dist/cli/index.js
CHANGED
|
@@ -7,37 +7,41 @@ import {
|
|
|
7
7
|
getPluginLockFilePaths,
|
|
8
8
|
package_default,
|
|
9
9
|
resolveCommand
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
} from "./index-vb5t1kvs.js";
|
|
11
|
+
import"./index-wj4jeavn.js";
|
|
12
|
+
import"./index-5gnp8fyw.js";
|
|
12
13
|
import"./index-c8s9a3zh.js";
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
15
|
-
import"./index-
|
|
16
|
-
import"./index-
|
|
14
|
+
import"./index-fm7xz1ne.js";
|
|
15
|
+
import"./index-wfq4r95s.js";
|
|
16
|
+
import"./index-scww5b77.js";
|
|
17
|
+
import"./index-yw8qpf51.js";
|
|
18
|
+
import"./index-85bacexr.js";
|
|
17
19
|
import"./index-09xpycan.js";
|
|
18
20
|
import {
|
|
19
21
|
DEFAULT_AGENT_CONFIGS
|
|
20
|
-
} from "./index-
|
|
21
|
-
import"./index-
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-
|
|
24
|
-
import"./index-
|
|
25
|
-
import"./index-
|
|
26
|
-
import"./index-n1sptn1w.js";
|
|
22
|
+
} from "./index-h4c4rrwx.js";
|
|
23
|
+
import"./index-9qxntjtx.js";
|
|
24
|
+
import"./index-mmny81g1.js";
|
|
25
|
+
import"./index-fz1jgbvw.js";
|
|
26
|
+
import"./index-wg0665ft.js";
|
|
27
|
+
import"./index-2nt4mq9n.js";
|
|
27
28
|
import"./index-bfwt3abw.js";
|
|
28
|
-
import"./index-
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-
|
|
31
|
-
import"./index-
|
|
32
|
-
import"./index-
|
|
29
|
+
import"./index-wvrj16f0.js";
|
|
30
|
+
import"./index-q1exe2b3.js";
|
|
31
|
+
import"./index-x2q0gnt8.js";
|
|
32
|
+
import"./index-f1qyj61w.js";
|
|
33
|
+
import"./index-r3j3458j.js";
|
|
34
|
+
import"./index-jtqkh8jf.js";
|
|
33
35
|
import"./index-5e4e2hvv.js";
|
|
34
36
|
import"./index-p0arc26j.js";
|
|
35
|
-
import"./index-jtqkh8jf.js";
|
|
36
37
|
import"./index-zgwm4ryv.js";
|
|
38
|
+
import"./index-6jng9c8t.js";
|
|
39
|
+
import"./index-1cn967sa.js";
|
|
37
40
|
import"./index-293f68mj.js";
|
|
38
|
-
import"./index-
|
|
39
|
-
import"./index-b9v501fr.js";
|
|
41
|
+
import"./index-5mkc2f9z.js";
|
|
40
42
|
import"./index-vn263hqt.js";
|
|
43
|
+
import"./index-vvk2g744.js";
|
|
44
|
+
import"./index-7xgqky26.js";
|
|
41
45
|
import"./index-a76rekgs.js";
|
|
42
46
|
|
|
43
47
|
// src/cli/index.ts
|
|
@@ -8,17 +8,18 @@ import {
|
|
|
8
8
|
maybeEscalateOnViolation,
|
|
9
9
|
maybeQuarantineOnContradiction,
|
|
10
10
|
readRecentEscalations
|
|
11
|
-
} from "./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
11
|
+
} from "./index-5gnp8fyw.js";
|
|
12
|
+
import"./index-mmny81g1.js";
|
|
13
|
+
import"./index-wg0665ft.js";
|
|
14
|
+
import"./index-2nt4mq9n.js";
|
|
15
15
|
import"./index-bfwt3abw.js";
|
|
16
|
-
import"./index-9b7qp18e.js";
|
|
17
16
|
import"./index-jtqkh8jf.js";
|
|
18
17
|
import"./index-zgwm4ryv.js";
|
|
19
|
-
import"./index-
|
|
20
|
-
import"./index-
|
|
18
|
+
import"./index-1cn967sa.js";
|
|
19
|
+
import"./index-5mkc2f9z.js";
|
|
21
20
|
import"./index-vn263hqt.js";
|
|
21
|
+
import"./index-vvk2g744.js";
|
|
22
|
+
import"./index-7xgqky26.js";
|
|
22
23
|
import"./index-a76rekgs.js";
|
|
23
24
|
export {
|
|
24
25
|
readRecentEscalations,
|
|
@@ -25,13 +25,14 @@ import {
|
|
|
25
25
|
resolveKnowledgeCounterBaselinePath,
|
|
26
26
|
resolveKnowledgeEventsPath,
|
|
27
27
|
resolveLegacyApplicationLogPath
|
|
28
|
-
} from "./index-
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-9b7qp18e.js";
|
|
28
|
+
} from "./index-mmny81g1.js";
|
|
29
|
+
import"./index-2nt4mq9n.js";
|
|
31
30
|
import"./index-zgwm4ryv.js";
|
|
32
|
-
import"./index-
|
|
33
|
-
import"./index-
|
|
31
|
+
import"./index-1cn967sa.js";
|
|
32
|
+
import"./index-5mkc2f9z.js";
|
|
34
33
|
import"./index-vn263hqt.js";
|
|
34
|
+
import"./index-vvk2g744.js";
|
|
35
|
+
import"./index-7xgqky26.js";
|
|
35
36
|
import"./index-a76rekgs.js";
|
|
36
37
|
export {
|
|
37
38
|
resolveLegacyApplicationLogPath,
|
|
@@ -32,14 +32,15 @@ import {
|
|
|
32
32
|
transactFile,
|
|
33
33
|
transactKnowledge,
|
|
34
34
|
wordBigrams
|
|
35
|
-
} from "./index-
|
|
36
|
-
import"./index-
|
|
35
|
+
} from "./index-wg0665ft.js";
|
|
36
|
+
import"./index-2nt4mq9n.js";
|
|
37
37
|
import"./index-bfwt3abw.js";
|
|
38
|
-
import"./index-9b7qp18e.js";
|
|
39
38
|
import"./index-jtqkh8jf.js";
|
|
40
|
-
import"./index-
|
|
41
|
-
import"./index-
|
|
39
|
+
import"./index-1cn967sa.js";
|
|
40
|
+
import"./index-5mkc2f9z.js";
|
|
42
41
|
import"./index-vn263hqt.js";
|
|
42
|
+
import"./index-vvk2g744.js";
|
|
43
|
+
import"./index-7xgqky26.js";
|
|
43
44
|
import"./index-a76rekgs.js";
|
|
44
45
|
export {
|
|
45
46
|
wordBigrams,
|
|
@@ -21,16 +21,17 @@ import {
|
|
|
21
21
|
validateLesson,
|
|
22
22
|
validateSkillCandidatePath,
|
|
23
23
|
validateSkillPath
|
|
24
|
-
} from "./index-
|
|
25
|
-
import"./index-
|
|
26
|
-
import"./index-
|
|
24
|
+
} from "./index-fz1jgbvw.js";
|
|
25
|
+
import"./index-wg0665ft.js";
|
|
26
|
+
import"./index-2nt4mq9n.js";
|
|
27
27
|
import"./index-bfwt3abw.js";
|
|
28
|
-
import"./index-9b7qp18e.js";
|
|
29
28
|
import"./index-jtqkh8jf.js";
|
|
30
29
|
import"./index-zgwm4ryv.js";
|
|
31
|
-
import"./index-
|
|
32
|
-
import"./index-
|
|
30
|
+
import"./index-1cn967sa.js";
|
|
31
|
+
import"./index-5mkc2f9z.js";
|
|
33
32
|
import"./index-vn263hqt.js";
|
|
33
|
+
import"./index-vvk2g744.js";
|
|
34
|
+
import"./index-7xgqky26.js";
|
|
34
35
|
import"./index-a76rekgs.js";
|
|
35
36
|
export {
|
|
36
37
|
validateSkillPath,
|