opencode-swarm 7.77.4 → 7.77.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/skills/swarm-pr-feedback/SKILL.md +8 -0
- package/dist/cli/index.js +738 -683
- package/dist/commands/registry.d.ts +109 -0
- package/dist/commands/tool-policy.d.ts +2 -2
- package/dist/index.js +906 -795
- package/dist/tools/repo-graph/storage.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var package_default;
|
|
|
69
69
|
var init_package = __esm(() => {
|
|
70
70
|
package_default = {
|
|
71
71
|
name: "opencode-swarm",
|
|
72
|
-
version: "7.77.
|
|
72
|
+
version: "7.77.6",
|
|
73
73
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
74
74
|
main: "dist/index.js",
|
|
75
75
|
types: "dist/index.d.ts",
|
|
@@ -27167,6 +27167,291 @@ var init_stored_input_args = __esm(() => {
|
|
|
27167
27167
|
storedInputArgs = new Map;
|
|
27168
27168
|
});
|
|
27169
27169
|
|
|
27170
|
+
// src/commands/command-dispatch.ts
|
|
27171
|
+
function normalizeSwarmCommandInput(command, argumentText) {
|
|
27172
|
+
if (command !== "swarm" && !command.startsWith("swarm-")) {
|
|
27173
|
+
return { isSwarmCommand: false, tokens: [] };
|
|
27174
|
+
}
|
|
27175
|
+
if (command === "swarm") {
|
|
27176
|
+
return {
|
|
27177
|
+
isSwarmCommand: true,
|
|
27178
|
+
tokens: argumentText.trim().split(/\s+/).filter(Boolean)
|
|
27179
|
+
};
|
|
27180
|
+
}
|
|
27181
|
+
const subcommand = command.slice("swarm-".length);
|
|
27182
|
+
const extraArgs = argumentText.trim().split(/\s+/).filter(Boolean);
|
|
27183
|
+
return {
|
|
27184
|
+
isSwarmCommand: true,
|
|
27185
|
+
tokens: [subcommand, ...extraArgs].filter(Boolean)
|
|
27186
|
+
};
|
|
27187
|
+
}
|
|
27188
|
+
function canonicalCommandKey(resolved) {
|
|
27189
|
+
return resolved.entry.aliasOf ?? resolved.key;
|
|
27190
|
+
}
|
|
27191
|
+
function formatCommandNotFound(tokens) {
|
|
27192
|
+
const attemptedCommand = tokens[0] || "";
|
|
27193
|
+
const MAX_DISPLAY = 100;
|
|
27194
|
+
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
27195
|
+
const similar = _internals13.findSimilarCommands(attemptedCommand);
|
|
27196
|
+
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
27197
|
+
const suggestions = similar.length > 0 ? `Did you mean:
|
|
27198
|
+
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
27199
|
+
`)}` : "";
|
|
27200
|
+
const footer = "Run `/swarm help` for all commands.";
|
|
27201
|
+
return [header, suggestions, footer].filter(Boolean).join(`
|
|
27202
|
+
|
|
27203
|
+
`);
|
|
27204
|
+
}
|
|
27205
|
+
async function executeSwarmCommand(args2) {
|
|
27206
|
+
const {
|
|
27207
|
+
directory,
|
|
27208
|
+
agents,
|
|
27209
|
+
sessionID,
|
|
27210
|
+
tokens,
|
|
27211
|
+
packageRoot,
|
|
27212
|
+
buildHelpText,
|
|
27213
|
+
policy
|
|
27214
|
+
} = args2;
|
|
27215
|
+
let text;
|
|
27216
|
+
const resolved = resolveCommand(tokens);
|
|
27217
|
+
if (!resolved) {
|
|
27218
|
+
text = tokens.length === 0 && buildHelpText ? buildHelpText() : formatCommandNotFound(tokens);
|
|
27219
|
+
} else {
|
|
27220
|
+
const policyResult = policy?.(resolved) ?? { allowed: true };
|
|
27221
|
+
if (!policyResult.allowed) {
|
|
27222
|
+
text = policyResult.message;
|
|
27223
|
+
} else {
|
|
27224
|
+
try {
|
|
27225
|
+
text = await resolved.entry.handler({
|
|
27226
|
+
directory,
|
|
27227
|
+
args: resolved.remainingArgs,
|
|
27228
|
+
sessionID,
|
|
27229
|
+
agents,
|
|
27230
|
+
packageRoot,
|
|
27231
|
+
source: "chat"
|
|
27232
|
+
});
|
|
27233
|
+
} catch (_err) {
|
|
27234
|
+
const cmdName = tokens[0] || "unknown";
|
|
27235
|
+
const errMsg = _err instanceof Error ? _err.message : String(_err);
|
|
27236
|
+
text = `Error executing /swarm ${cmdName}: ${errMsg}`;
|
|
27237
|
+
}
|
|
27238
|
+
if (resolved.warning) {
|
|
27239
|
+
text = `${resolved.warning}
|
|
27240
|
+
|
|
27241
|
+
${text}`;
|
|
27242
|
+
}
|
|
27243
|
+
}
|
|
27244
|
+
}
|
|
27245
|
+
return {
|
|
27246
|
+
text,
|
|
27247
|
+
resolved: resolved ?? undefined,
|
|
27248
|
+
canonicalKey: resolved ? canonicalCommandKey(resolved) : undefined
|
|
27249
|
+
};
|
|
27250
|
+
}
|
|
27251
|
+
var init_command_dispatch = __esm(() => {
|
|
27252
|
+
init_registry();
|
|
27253
|
+
});
|
|
27254
|
+
|
|
27255
|
+
// src/commands/tool-policy.ts
|
|
27256
|
+
function lazySet(getValues) {
|
|
27257
|
+
let cached2 = null;
|
|
27258
|
+
const ensure = () => {
|
|
27259
|
+
if (cached2 === null)
|
|
27260
|
+
cached2 = new Set(getValues());
|
|
27261
|
+
return cached2;
|
|
27262
|
+
};
|
|
27263
|
+
return new Proxy({}, {
|
|
27264
|
+
get(_target, prop) {
|
|
27265
|
+
const set2 = ensure();
|
|
27266
|
+
const value = Reflect.get(set2, prop);
|
|
27267
|
+
return typeof value === "function" ? value.bind(set2) : value;
|
|
27268
|
+
}
|
|
27269
|
+
});
|
|
27270
|
+
}
|
|
27271
|
+
function lazyArray(getValues) {
|
|
27272
|
+
let cached2 = null;
|
|
27273
|
+
const ensure = () => {
|
|
27274
|
+
if (cached2 === null)
|
|
27275
|
+
cached2 = getValues();
|
|
27276
|
+
return cached2;
|
|
27277
|
+
};
|
|
27278
|
+
return new Proxy([], {
|
|
27279
|
+
get(_target, prop) {
|
|
27280
|
+
const arr = ensure();
|
|
27281
|
+
const value = Reflect.get(arr, prop);
|
|
27282
|
+
return typeof value === "function" ? value.bind(arr) : value;
|
|
27283
|
+
}
|
|
27284
|
+
});
|
|
27285
|
+
}
|
|
27286
|
+
function classifySwarmCommandToolUse(resolved) {
|
|
27287
|
+
const canonicalKey = canonicalCommandKey(resolved);
|
|
27288
|
+
const args2 = resolved.remainingArgs;
|
|
27289
|
+
if (!SWARM_COMMAND_TOOL_ALLOWLIST.has(canonicalKey)) {
|
|
27290
|
+
if (HUMAN_ONLY_SWARM_COMMANDS.has(canonicalKey)) {
|
|
27291
|
+
return {
|
|
27292
|
+
allowed: false,
|
|
27293
|
+
message: `/swarm ${canonicalKey} is a human-only command. ` + `Present the situation to the user and ask them to run \`/swarm ${canonicalKey}\` themselves ` + `(or \`bunx opencode-swarm run ${canonicalKey}\` from a terminal). ` + `You MUST NOT run it yourself via Bash, swarm_command, or any other tool — ` + `the runtime guardrail will block such attempts.`
|
|
27294
|
+
};
|
|
27295
|
+
}
|
|
27296
|
+
return {
|
|
27297
|
+
allowed: false,
|
|
27298
|
+
message: `/swarm ${canonicalKey} is not available through the chat tool yet.
|
|
27299
|
+
|
|
27300
|
+
` + `Use the canonical CLI path for now: \`bunx opencode-swarm run ${canonicalKey}\`.
|
|
27301
|
+
` + `Commands with state changes, auto-heal behavior, or subprocesses need confirmation gates before chat-tool support.`
|
|
27302
|
+
};
|
|
27303
|
+
}
|
|
27304
|
+
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
27305
|
+
return {
|
|
27306
|
+
allowed: false,
|
|
27307
|
+
message: "/swarm config doctor --fix is not available through swarm_command. Run the CLI command directly when you intend to modify config files."
|
|
27308
|
+
};
|
|
27309
|
+
}
|
|
27310
|
+
if (NO_ARGS.has(canonicalKey) && args2.length > 0) {
|
|
27311
|
+
return {
|
|
27312
|
+
allowed: false,
|
|
27313
|
+
message: `/swarm ${canonicalKey} does not accept arguments through swarm_command.`
|
|
27314
|
+
};
|
|
27315
|
+
}
|
|
27316
|
+
if (canonicalKey === "knowledge") {
|
|
27317
|
+
if (args2.length === 0)
|
|
27318
|
+
return { allowed: true };
|
|
27319
|
+
if (args2.length === 1 && (args2[0] === "list" || args2[0] === "unactionable"))
|
|
27320
|
+
return { allowed: true };
|
|
27321
|
+
return {
|
|
27322
|
+
allowed: false,
|
|
27323
|
+
message: "Only `/swarm knowledge`, `/swarm knowledge list`, and `/swarm knowledge unactionable` are available through swarm_command. Knowledge migrate/quarantine/restore/retry-hardening are intentionally excluded."
|
|
27324
|
+
};
|
|
27325
|
+
}
|
|
27326
|
+
if (canonicalKey === "memory") {
|
|
27327
|
+
if (args2.length === 0)
|
|
27328
|
+
return { allowed: true };
|
|
27329
|
+
return {
|
|
27330
|
+
allowed: false,
|
|
27331
|
+
message: "Use `/swarm memory status`, `/swarm memory pending`, `/swarm memory recall-log`, `/swarm memory stale`, `/swarm memory export`, or `/swarm memory evaluate --json` through swarm_command. Memory import, migrate, and compact are intentionally excluded from chat-tool execution."
|
|
27332
|
+
};
|
|
27333
|
+
}
|
|
27334
|
+
if (canonicalKey === "memory evaluate") {
|
|
27335
|
+
if (args2.length === 0)
|
|
27336
|
+
return { allowed: true };
|
|
27337
|
+
if (args2.length === 1 && args2[0] === "--json")
|
|
27338
|
+
return { allowed: true };
|
|
27339
|
+
return {
|
|
27340
|
+
allowed: false,
|
|
27341
|
+
message: "Usage through swarm_command: `/swarm memory evaluate --json`. Custom fixture directories are only available through direct user command execution."
|
|
27342
|
+
};
|
|
27343
|
+
}
|
|
27344
|
+
if (canonicalKey === "sdd status") {
|
|
27345
|
+
if (args2.length === 0)
|
|
27346
|
+
return { allowed: true };
|
|
27347
|
+
if (args2.length === 1 && args2[0] === "--json")
|
|
27348
|
+
return { allowed: true };
|
|
27349
|
+
return {
|
|
27350
|
+
allowed: false,
|
|
27351
|
+
message: "Usage through swarm_command: `/swarm sdd status` or `/swarm sdd status --json`."
|
|
27352
|
+
};
|
|
27353
|
+
}
|
|
27354
|
+
if (canonicalKey === "sdd validate") {
|
|
27355
|
+
if (args2.length === 0)
|
|
27356
|
+
return { allowed: true };
|
|
27357
|
+
if (args2.length === 1 && args2[0] === "--json")
|
|
27358
|
+
return { allowed: true };
|
|
27359
|
+
if (args2.length === 2 && args2[0] === "--change" && /^[A-Za-z0-9_.-]{1,128}$/.test(args2[1])) {
|
|
27360
|
+
return { allowed: true };
|
|
27361
|
+
}
|
|
27362
|
+
return {
|
|
27363
|
+
allowed: false,
|
|
27364
|
+
message: "Usage through swarm_command: `/swarm sdd validate`, `/swarm sdd validate --json`, or `/swarm sdd validate --change <id>`."
|
|
27365
|
+
};
|
|
27366
|
+
}
|
|
27367
|
+
if (canonicalKey === "memory pending" || canonicalKey === "memory recall-log" || canonicalKey === "memory stale") {
|
|
27368
|
+
if (args2.length === 0)
|
|
27369
|
+
return { allowed: true };
|
|
27370
|
+
if (args2.length === 2 && args2[0] === "--limit" && /^\d+$/.test(args2[1])) {
|
|
27371
|
+
return { allowed: true };
|
|
27372
|
+
}
|
|
27373
|
+
return {
|
|
27374
|
+
allowed: false,
|
|
27375
|
+
message: `Usage through swarm_command: \`/swarm ${canonicalKey}\` or ` + `\`/swarm ${canonicalKey} --limit <n>\`.`
|
|
27376
|
+
};
|
|
27377
|
+
}
|
|
27378
|
+
if (canonicalKey === "retrieve") {
|
|
27379
|
+
if (args2.length !== 1 || !SUMMARY_ID_PATTERN.test(args2[0])) {
|
|
27380
|
+
return {
|
|
27381
|
+
allowed: false,
|
|
27382
|
+
message: "Usage through swarm_command: `/swarm retrieve <summary-id>` with a single summary ID such as S1."
|
|
27383
|
+
};
|
|
27384
|
+
}
|
|
27385
|
+
}
|
|
27386
|
+
if (canonicalKey === "benchmark") {
|
|
27387
|
+
const allowedFlags = new Set(["--cumulative", "--ci-gate"]);
|
|
27388
|
+
const invalid = args2.filter((arg) => !allowedFlags.has(arg));
|
|
27389
|
+
if (invalid.length > 0) {
|
|
27390
|
+
return {
|
|
27391
|
+
allowed: false,
|
|
27392
|
+
message: "Only `--cumulative` and `--ci-gate` are supported for `/swarm benchmark` through swarm_command."
|
|
27393
|
+
};
|
|
27394
|
+
}
|
|
27395
|
+
}
|
|
27396
|
+
if (canonicalKey === "show-plan") {
|
|
27397
|
+
if (args2.length > 1 || args2[0] && !/^\d+$/.test(args2[0])) {
|
|
27398
|
+
return {
|
|
27399
|
+
allowed: false,
|
|
27400
|
+
message: "Usage through swarm_command: `/swarm show-plan` or `/swarm show-plan <phase-number>`."
|
|
27401
|
+
};
|
|
27402
|
+
}
|
|
27403
|
+
}
|
|
27404
|
+
if (canonicalKey === "evidence") {
|
|
27405
|
+
if (args2.length > 1 || args2[0] && !TASK_ID_PATTERN.test(args2[0])) {
|
|
27406
|
+
return {
|
|
27407
|
+
allowed: false,
|
|
27408
|
+
message: "Usage through swarm_command: `/swarm evidence` or `/swarm evidence <task-id>`."
|
|
27409
|
+
};
|
|
27410
|
+
}
|
|
27411
|
+
}
|
|
27412
|
+
if (canonicalKey === "help" && args2.length > 2) {
|
|
27413
|
+
return {
|
|
27414
|
+
allowed: false,
|
|
27415
|
+
message: "Usage through swarm_command: `/swarm help` or `/swarm help <command>`."
|
|
27416
|
+
};
|
|
27417
|
+
}
|
|
27418
|
+
return { allowed: true };
|
|
27419
|
+
}
|
|
27420
|
+
function classifySwarmCommandChatFallbackUse(resolved) {
|
|
27421
|
+
const canonicalKey = canonicalCommandKey(resolved);
|
|
27422
|
+
const args2 = resolved.remainingArgs;
|
|
27423
|
+
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
27424
|
+
return {
|
|
27425
|
+
allowed: false,
|
|
27426
|
+
message: "/swarm config doctor --fix is not available through chat fallback because it can modify configuration files. Run the CLI command directly when you intend to apply fixes."
|
|
27427
|
+
};
|
|
27428
|
+
}
|
|
27429
|
+
if (canonicalKey === "knowledge migrate" || canonicalKey === "knowledge quarantine" || canonicalKey === "knowledge restore" || canonicalKey === "memory import" || canonicalKey === "memory migrate" || canonicalKey === "memory compact" || canonicalKey === "sdd project") {
|
|
27430
|
+
return {
|
|
27431
|
+
allowed: false,
|
|
27432
|
+
message: `/swarm ${canonicalKey} is not available through chat fallback because it mutates .swarm state. ` + "Run the CLI command directly after confirming the intended state change."
|
|
27433
|
+
};
|
|
27434
|
+
}
|
|
27435
|
+
return { allowed: true };
|
|
27436
|
+
}
|
|
27437
|
+
var SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, NO_ARGS, SUMMARY_ID_PATTERN, TASK_ID_PATTERN;
|
|
27438
|
+
var init_tool_policy = __esm(() => {
|
|
27439
|
+
init_command_dispatch();
|
|
27440
|
+
init_registry();
|
|
27441
|
+
SWARM_COMMAND_TOOL_COMMANDS = lazyArray(() => VALID_COMMANDS.filter((cmd) => {
|
|
27442
|
+
const policy = COMMAND_REGISTRY[cmd]?.toolPolicy;
|
|
27443
|
+
return policy === "agent" || policy === "human-only";
|
|
27444
|
+
}).sort());
|
|
27445
|
+
SWARM_COMMAND_TOOL_ALLOWLIST = lazySet(() => VALID_COMMANDS.filter((cmd) => COMMAND_REGISTRY[cmd]?.toolPolicy === "agent"));
|
|
27446
|
+
HUMAN_ONLY_SWARM_COMMANDS = lazySet(() => VALID_COMMANDS.filter((cmd) => {
|
|
27447
|
+
const policy = COMMAND_REGISTRY[cmd]?.toolPolicy;
|
|
27448
|
+
return policy === "human-only" || policy === "restricted";
|
|
27449
|
+
}));
|
|
27450
|
+
NO_ARGS = lazySet(() => VALID_COMMANDS.filter((cmd) => COMMAND_REGISTRY[cmd]?.toolNoArgs === true));
|
|
27451
|
+
SUMMARY_ID_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
27452
|
+
TASK_ID_PATTERN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
27453
|
+
});
|
|
27454
|
+
|
|
27170
27455
|
// src/sandbox/win32/runner-client.ts
|
|
27171
27456
|
var exports_runner_client = {};
|
|
27172
27457
|
__export(exports_runner_client, {
|
|
@@ -27174,7 +27459,7 @@ __export(exports_runner_client, {
|
|
|
27174
27459
|
execute: () => execute,
|
|
27175
27460
|
buildDefaultPolicy: () => buildDefaultPolicy,
|
|
27176
27461
|
_resetProbeCache: () => _resetProbeCache,
|
|
27177
|
-
_internals: () =>
|
|
27462
|
+
_internals: () => _internals14,
|
|
27178
27463
|
RUNNER_EXIT_CODES: () => RUNNER_EXIT_CODES
|
|
27179
27464
|
});
|
|
27180
27465
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -27223,7 +27508,7 @@ function probe() {
|
|
|
27223
27508
|
};
|
|
27224
27509
|
return _cachedProbe;
|
|
27225
27510
|
}
|
|
27226
|
-
const binary2 =
|
|
27511
|
+
const binary2 = _internals14.findRunnerBinary();
|
|
27227
27512
|
if (!binary2) {
|
|
27228
27513
|
_cachedProbe = {
|
|
27229
27514
|
available: false,
|
|
@@ -27235,7 +27520,7 @@ function probe() {
|
|
|
27235
27520
|
return _cachedProbe;
|
|
27236
27521
|
}
|
|
27237
27522
|
try {
|
|
27238
|
-
const result =
|
|
27523
|
+
const result = _internals14.spawnRunner(binary2, ["--probe"], {
|
|
27239
27524
|
windowsHide: true,
|
|
27240
27525
|
encoding: "utf-8",
|
|
27241
27526
|
timeout: 2000,
|
|
@@ -27288,7 +27573,7 @@ function probe() {
|
|
|
27288
27573
|
}
|
|
27289
27574
|
}
|
|
27290
27575
|
async function execute(command, policy, mode = "auto") {
|
|
27291
|
-
const binary2 =
|
|
27576
|
+
const binary2 = _internals14.findRunnerBinary();
|
|
27292
27577
|
if (!binary2) {
|
|
27293
27578
|
throw new Error("runner binary not found");
|
|
27294
27579
|
}
|
|
@@ -27305,7 +27590,7 @@ async function execute(command, policy, mode = "auto") {
|
|
|
27305
27590
|
unref.call(timeout);
|
|
27306
27591
|
}
|
|
27307
27592
|
try {
|
|
27308
|
-
proc =
|
|
27593
|
+
proc = _internals14.spawnAsync(binary2, args2, {
|
|
27309
27594
|
windowsHide: true,
|
|
27310
27595
|
stdio: ["pipe", "pipe", "pipe"],
|
|
27311
27596
|
cwd: policy.workspace_roots[0] ?? os4.tmpdir()
|
|
@@ -27391,7 +27676,7 @@ function buildDefaultPolicy(workspaceRoot, runId) {
|
|
|
27391
27676
|
deny_symlink_egress: true
|
|
27392
27677
|
};
|
|
27393
27678
|
}
|
|
27394
|
-
var _runtimeDir, RUNNER_EXIT_CODES, _cachedProbe,
|
|
27679
|
+
var _runtimeDir, RUNNER_EXIT_CODES, _cachedProbe, _internals14;
|
|
27395
27680
|
var init_runner_client = __esm(() => {
|
|
27396
27681
|
init_logger();
|
|
27397
27682
|
_runtimeDir = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -27405,7 +27690,7 @@ var init_runner_client = __esm(() => {
|
|
|
27405
27690
|
OS_API_FAILURE: 68,
|
|
27406
27691
|
PROBE_FAILED: 69
|
|
27407
27692
|
};
|
|
27408
|
-
|
|
27693
|
+
_internals14 = {
|
|
27409
27694
|
findRunnerBinary,
|
|
27410
27695
|
spawnRunner: spawnSync,
|
|
27411
27696
|
spawnAsync: spawn
|
|
@@ -27656,7 +27941,7 @@ class BubblewrapSandboxExecutor {
|
|
|
27656
27941
|
this._available = false;
|
|
27657
27942
|
this._disabledReason = null;
|
|
27658
27943
|
try {
|
|
27659
|
-
if (!
|
|
27944
|
+
if (!_internals15.probeBwrap()) {
|
|
27660
27945
|
this._disabledReason = "bwrap not available or not functional";
|
|
27661
27946
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
27662
27947
|
} else {
|
|
@@ -27727,12 +28012,12 @@ class BubblewrapSandboxExecutor {
|
|
|
27727
28012
|
return {};
|
|
27728
28013
|
}
|
|
27729
28014
|
}
|
|
27730
|
-
var BWRAP_VERSION_EXIT = 0, BWRAP_UNAVAILABLE_CODES,
|
|
28015
|
+
var BWRAP_VERSION_EXIT = 0, BWRAP_UNAVAILABLE_CODES, _internals15;
|
|
27731
28016
|
var init_bubblewrap_executor = __esm(() => {
|
|
27732
28017
|
init_logger();
|
|
27733
28018
|
init_executor();
|
|
27734
28019
|
BWRAP_UNAVAILABLE_CODES = new Set(["ENOENT", "EACCES", "ENOSPC"]);
|
|
27735
|
-
|
|
28020
|
+
_internals15 = {
|
|
27736
28021
|
probeBwrap
|
|
27737
28022
|
};
|
|
27738
28023
|
});
|
|
@@ -27819,7 +28104,7 @@ class MacOSSandboxExecutor {
|
|
|
27819
28104
|
this._available = false;
|
|
27820
28105
|
this._disabledReason = null;
|
|
27821
28106
|
try {
|
|
27822
|
-
if (!
|
|
28107
|
+
if (!_internals16.probeSandboxExec()) {
|
|
27823
28108
|
this._disabledReason = "sandbox-exec not available or not functional";
|
|
27824
28109
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
27825
28110
|
} else {
|
|
@@ -27844,7 +28129,7 @@ class MacOSSandboxExecutor {
|
|
|
27844
28129
|
if (!this._available) {
|
|
27845
28130
|
throw new SandboxError("Sandbox not available", "SANDBOX_UNAVAILABLE");
|
|
27846
28131
|
}
|
|
27847
|
-
if (!
|
|
28132
|
+
if (!_internals16.probeSandboxExec()) {
|
|
27848
28133
|
this._available = false;
|
|
27849
28134
|
this._disabledReason = "sandbox-exec became unavailable between calls";
|
|
27850
28135
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
@@ -27877,12 +28162,12 @@ class MacOSSandboxExecutor {
|
|
|
27877
28162
|
};
|
|
27878
28163
|
}
|
|
27879
28164
|
}
|
|
27880
|
-
var SANDBOX_UNAVAILABLE_CODES,
|
|
28165
|
+
var SANDBOX_UNAVAILABLE_CODES, _internals16;
|
|
27881
28166
|
var init_sandbox_exec_executor = __esm(() => {
|
|
27882
28167
|
init_logger();
|
|
27883
28168
|
init_executor();
|
|
27884
28169
|
SANDBOX_UNAVAILABLE_CODES = new Set(["ENOENT", "EACCES", "ENOSPC"]);
|
|
27885
|
-
|
|
28170
|
+
_internals16 = {
|
|
27886
28171
|
probeSandboxExec
|
|
27887
28172
|
};
|
|
27888
28173
|
});
|
|
@@ -28019,7 +28304,7 @@ class WindowsSandboxExecutor {
|
|
|
28019
28304
|
this._disabled = false;
|
|
28020
28305
|
this._disabledReason = null;
|
|
28021
28306
|
try {
|
|
28022
|
-
if (!
|
|
28307
|
+
if (!_internals17.probeWindowsSandbox()) {
|
|
28023
28308
|
this._available = false;
|
|
28024
28309
|
this._disabledReason = "Windows sandbox not available or not functional";
|
|
28025
28310
|
warn(`Sandbox unavailable: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
@@ -28045,7 +28330,7 @@ class WindowsSandboxExecutor {
|
|
|
28045
28330
|
if (!this.isAvailable()) {
|
|
28046
28331
|
throw new SandboxError("Sandbox not available", "SANDBOX_UNAVAILABLE");
|
|
28047
28332
|
}
|
|
28048
|
-
if (!
|
|
28333
|
+
if (!_internals17.probeWindowsSandbox()) {
|
|
28049
28334
|
this._available = false;
|
|
28050
28335
|
this._disabledReason = "Windows sandbox became unavailable between calls";
|
|
28051
28336
|
warn(`Sandbox disabled: ${this._disabledReason}. Falling through to tool-layer enforcement.`);
|
|
@@ -28110,7 +28395,7 @@ try {
|
|
|
28110
28395
|
};
|
|
28111
28396
|
}
|
|
28112
28397
|
}
|
|
28113
|
-
var SANDBOX_UNAVAILABLE_CODES2,
|
|
28398
|
+
var SANDBOX_UNAVAILABLE_CODES2, _internals17;
|
|
28114
28399
|
var init_restricted_environment_executor = __esm(() => {
|
|
28115
28400
|
init_logger();
|
|
28116
28401
|
init_executor();
|
|
@@ -28120,7 +28405,7 @@ var init_restricted_environment_executor = __esm(() => {
|
|
|
28120
28405
|
"EPERM",
|
|
28121
28406
|
"ENOSPC"
|
|
28122
28407
|
]);
|
|
28123
|
-
|
|
28408
|
+
_internals17 = {
|
|
28124
28409
|
probeWindowsSandbox
|
|
28125
28410
|
};
|
|
28126
28411
|
});
|
|
@@ -28178,7 +28463,7 @@ class NativeWindowsSandboxExecutor {
|
|
|
28178
28463
|
return this._fallbackExecutor.wrapCommand(command, scopePaths, tempDir);
|
|
28179
28464
|
}
|
|
28180
28465
|
_wrapWithRunner(command, scopePaths, tempDir) {
|
|
28181
|
-
const binary2 =
|
|
28466
|
+
const binary2 = _internals14.findRunnerBinary();
|
|
28182
28467
|
if (!binary2) {
|
|
28183
28468
|
throw new SandboxError("Runner binary not found", "RUNNER_NOT_FOUND");
|
|
28184
28469
|
}
|
|
@@ -40979,14 +41264,7 @@ function createToolBeforeHandler(ctx) {
|
|
|
40979
41264
|
throw new Error(`BLOCKED: "7z" with delete-source flag targeting .swarm/ detected — archive with source deletion under .swarm/ is not allowed`);
|
|
40980
41265
|
}
|
|
40981
41266
|
{
|
|
40982
|
-
const HUMAN_ONLY_SWARM_SUBCOMMANDS =
|
|
40983
|
-
"acknowledge-spec-drift",
|
|
40984
|
-
"reset",
|
|
40985
|
-
"reset-session",
|
|
40986
|
-
"rollback",
|
|
40987
|
-
"checkpoint",
|
|
40988
|
-
"consolidate"
|
|
40989
|
-
]);
|
|
41267
|
+
const HUMAN_ONLY_SWARM_SUBCOMMANDS = HUMAN_ONLY_SWARM_COMMANDS;
|
|
40990
41268
|
let probe2 = seg.replace(/^(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+)+/, "").replace(/^eval(?:\s+--)?\s+["']?/, "").replace(/["']\s*$/, "").replace(/^\$\(\s*/, "").replace(/^\(\s*/, "").replace(/\s*\)$/, "").replace(/^`/, "").replace(/`$/, "").trim();
|
|
40991
41269
|
for (let i2 = 0;i2 < 4; i2++) {
|
|
40992
41270
|
const before = probe2;
|
|
@@ -40994,17 +41272,35 @@ function createToolBeforeHandler(ctx) {
|
|
|
40994
41272
|
if (probe2 === before)
|
|
40995
41273
|
break;
|
|
40996
41274
|
}
|
|
40997
|
-
const swarmCliBypassMatch = probe2.match(/^\\?(?:bunx|npx|pnpx|npm(?:\s+(?:exec|x)(?:\s+--)?)?|pnpm(?:\s+(?:dlx|exec))?|yarn(?:\s+(?:dlx|exec))?|bun(?:\s+x)?|node|deno\s+run|tsx|ts-node)\b[^|;&]*?\bopencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+)/i);
|
|
40998
|
-
if (swarmCliBypassMatch
|
|
40999
|
-
|
|
41275
|
+
const swarmCliBypassMatch = probe2.match(/^\\?(?:bunx|npx|pnpx|npm(?:\s+(?:exec|x)(?:\s+--)?)?|pnpm(?:\s+(?:dlx|exec))?|yarn(?:\s+(?:dlx|exec))?|bun(?:\s+x)?|node|deno\s+run|tsx|ts-node)\b[^|;&]*?\bopencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+(?:\s+(?!-)[A-Za-z0-9_-]+)?)/i);
|
|
41276
|
+
if (swarmCliBypassMatch) {
|
|
41277
|
+
const captured = swarmCliBypassMatch[1];
|
|
41278
|
+
const normalized = captured.trim().split(/\s+/).join(" ");
|
|
41279
|
+
const firstToken = normalized.includes(" ") ? normalized.split(" ")[0] : normalized;
|
|
41280
|
+
const cmdName = HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) ? normalized : firstToken;
|
|
41281
|
+
if (HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) || HUMAN_ONLY_SWARM_SUBCOMMANDS.has(firstToken)) {
|
|
41282
|
+
throw new Error(`BLOCKED: "${cmdName}" is a human-only swarm command and may not be invoked from shell by an agent. ` + `Present the situation to the user and ask them to run \`/swarm ${cmdName}\` themselves.`);
|
|
41283
|
+
}
|
|
41000
41284
|
}
|
|
41001
|
-
const swarmBareBinMatch = probe2.match(/^\\?opencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+)/i);
|
|
41002
|
-
if (swarmBareBinMatch
|
|
41003
|
-
|
|
41285
|
+
const swarmBareBinMatch = probe2.match(/^\\?opencode-swarm\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+(?:\s+(?!-)[A-Za-z0-9_-]+)?)/i);
|
|
41286
|
+
if (swarmBareBinMatch) {
|
|
41287
|
+
const captured = swarmBareBinMatch[1];
|
|
41288
|
+
const normalized = captured.trim().split(/\s+/).join(" ");
|
|
41289
|
+
const firstToken = normalized.includes(" ") ? normalized.split(" ")[0] : normalized;
|
|
41290
|
+
const cmdName = HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) ? normalized : firstToken;
|
|
41291
|
+
if (HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) || HUMAN_ONLY_SWARM_SUBCOMMANDS.has(firstToken)) {
|
|
41292
|
+
throw new Error(`BLOCKED: "${cmdName}" is a human-only swarm command and may not be invoked from shell by an agent. ` + `Present the situation to the user and ask them to run \`/swarm ${cmdName}\` themselves.`);
|
|
41293
|
+
}
|
|
41004
41294
|
}
|
|
41005
|
-
const swarmCliPathMatch = probe2.match(/\bcli[/\\]+index\.[mc]?(?:js|ts)\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+)/i);
|
|
41006
|
-
if (swarmCliPathMatch
|
|
41007
|
-
|
|
41295
|
+
const swarmCliPathMatch = probe2.match(/\bcli[/\\]+index\.[mc]?(?:js|ts)\b[^|;&]*?\brun\s+([A-Za-z0-9_-]+(?:\s+(?!-)[A-Za-z0-9_-]+)?)/i);
|
|
41296
|
+
if (swarmCliPathMatch) {
|
|
41297
|
+
const captured = swarmCliPathMatch[1];
|
|
41298
|
+
const normalized = captured.trim().split(/\s+/).join(" ");
|
|
41299
|
+
const firstToken = normalized.includes(" ") ? normalized.split(" ")[0] : normalized;
|
|
41300
|
+
const cmdName = HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) ? normalized : firstToken;
|
|
41301
|
+
if (HUMAN_ONLY_SWARM_SUBCOMMANDS.has(normalized) || HUMAN_ONLY_SWARM_SUBCOMMANDS.has(firstToken)) {
|
|
41302
|
+
throw new Error(`BLOCKED: "${cmdName}" is a human-only swarm command and may not be invoked from shell by an agent. ` + `Present the situation to the user and ask them to run \`/swarm ${cmdName}\` themselves.`);
|
|
41303
|
+
}
|
|
41008
41304
|
}
|
|
41009
41305
|
}
|
|
41010
41306
|
{
|
|
@@ -41358,11 +41654,15 @@ function createToolBeforeHandler(ctx) {
|
|
|
41358
41654
|
}
|
|
41359
41655
|
return out2;
|
|
41360
41656
|
}
|
|
41657
|
+
function getHumanOnlyAlternation() {
|
|
41658
|
+
return [...HUMAN_ONLY_SWARM_COMMANDS].map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).sort((a, b) => b.length - a.length).join("|");
|
|
41659
|
+
}
|
|
41361
41660
|
function patchPayloadHasHumanOnlyInvocation(args2) {
|
|
41362
41661
|
const payloads = extractAllPatchPayloads(args2);
|
|
41363
41662
|
if (payloads.length === 0)
|
|
41364
41663
|
return false;
|
|
41365
|
-
const
|
|
41664
|
+
const alternation = getHumanOnlyAlternation();
|
|
41665
|
+
const re = new RegExp(`\\bopencode-swarm\\b[\\s\\S]*?\\brun\\s+(${alternation})\\b`, "i");
|
|
41366
41666
|
return payloads.some((p) => re.test(p));
|
|
41367
41667
|
}
|
|
41368
41668
|
function extractPatchTargetPaths(tool, args2) {
|
|
@@ -41434,7 +41734,7 @@ function createToolBeforeHandler(ctx) {
|
|
|
41434
41734
|
throw new Error("SPEC_DRIFT_VIOLATION: Direct writes to .swarm/spec-staleness.json are blocked. " + "This file is system-managed and gates plan-mutating tools while spec drift is unresolved. " + "Present the drift to the user and ask them to run /swarm clarify or /swarm acknowledge-spec-drift.");
|
|
41435
41735
|
}
|
|
41436
41736
|
const content = toolArgs?.content ?? toolArgs?.text ?? toolArgs?.new_string ?? toolArgs?.newText;
|
|
41437
|
-
if (typeof content === "string" &&
|
|
41737
|
+
if (typeof content === "string" && new RegExp(`\\bopencode-swarm\\b[\\s\\S]*?\\brun\\s+(${getHumanOnlyAlternation()})\\b`, "i").test(content)) {
|
|
41438
41738
|
throw new Error("BLOCKED: write/edit tool would create a script invoking a human-only swarm CLI subcommand. " + "Present the situation to the user and ask them to run the command themselves.");
|
|
41439
41739
|
}
|
|
41440
41740
|
}
|
|
@@ -41673,6 +41973,7 @@ function createToolBeforeHandler(ctx) {
|
|
|
41673
41973
|
};
|
|
41674
41974
|
}
|
|
41675
41975
|
var init_tool_before = __esm(() => {
|
|
41976
|
+
init_tool_policy();
|
|
41676
41977
|
init_constants();
|
|
41677
41978
|
init_schema();
|
|
41678
41979
|
init_executor();
|
|
@@ -42079,9 +42380,9 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
42079
42380
|
const isContentFilter = CONTENT_FILTER_PATTERN.test(errorSignal);
|
|
42080
42381
|
if (session && !session.modelFallbackExhausted) {
|
|
42081
42382
|
session.model_fallback_index++;
|
|
42082
|
-
const swarmId =
|
|
42383
|
+
const swarmId = _internals18.extractSwarmIdFromAgentName(session.agentName);
|
|
42083
42384
|
const baseAgentName = session.agentName ? session.agentName.replace(/^[^_]+[_]/, "") : "";
|
|
42084
|
-
const swarmAgents =
|
|
42385
|
+
const swarmAgents = _internals18.getSwarmAgents(swarmId);
|
|
42085
42386
|
const fallbackModels = swarmAgents?.[baseAgentName]?.fallback_models;
|
|
42086
42387
|
session.modelFallbackExhausted = !fallbackModels || session.model_fallback_index > fallbackModels.length;
|
|
42087
42388
|
session.pendingAdvisoryMessages ??= [];
|
|
@@ -42104,12 +42405,12 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
42104
42405
|
let modelFallbackAdvisoryEmitted = false;
|
|
42105
42406
|
if (session && isTransientMatch && !session.modelFallbackExhausted && !isDegraded) {
|
|
42106
42407
|
session.model_fallback_index++;
|
|
42107
|
-
const swarmId =
|
|
42408
|
+
const swarmId = _internals18.extractSwarmIdFromAgentName(session.agentName);
|
|
42108
42409
|
const baseAgentName = session.agentName ? session.agentName.replace(/^[^_]+[_]/, "") : "";
|
|
42109
|
-
const swarmAgents =
|
|
42410
|
+
const swarmAgents = _internals18.getSwarmAgents(swarmId);
|
|
42110
42411
|
const fallbackModels = swarmAgents?.[baseAgentName]?.fallback_models;
|
|
42111
42412
|
session.modelFallbackExhausted = !fallbackModels || session.model_fallback_index > fallbackModels.length;
|
|
42112
|
-
const fallbackModel =
|
|
42413
|
+
const fallbackModel = _internals18.resolveFallbackModel(baseAgentName, session.model_fallback_index, swarmAgents);
|
|
42113
42414
|
const primaryModel = swarmAgents?.[baseAgentName]?.model ?? "default";
|
|
42114
42415
|
if (fallbackModel) {
|
|
42115
42416
|
if (swarmAgents?.[baseAgentName]) {
|
|
@@ -42147,7 +42448,7 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
|
|
|
42147
42448
|
messagesTransform
|
|
42148
42449
|
};
|
|
42149
42450
|
}
|
|
42150
|
-
var
|
|
42451
|
+
var _internals18, SPEC_DRIFT_BLOCKED_TOOLS, TRANSIENT_STATUS_CODES2, TRANSIENT_MODEL_ERROR_PATTERN2, DEGRADED_ERROR_PATTERN, CONTENT_FILTER_PATTERN, toolCallsSinceLastWrite, noOpWarningIssued;
|
|
42151
42452
|
var init_guardrails = __esm(() => {
|
|
42152
42453
|
init_agents2();
|
|
42153
42454
|
init_constants();
|
|
@@ -42165,7 +42466,7 @@ var init_guardrails = __esm(() => {
|
|
|
42165
42466
|
init_messages_transform();
|
|
42166
42467
|
init_stored_input_args();
|
|
42167
42468
|
init_tool_before();
|
|
42168
|
-
|
|
42469
|
+
_internals18 = {
|
|
42169
42470
|
extractSwarmIdFromAgentName,
|
|
42170
42471
|
getSwarmAgents,
|
|
42171
42472
|
getMostRecentAssistantText,
|
|
@@ -42400,21 +42701,21 @@ async function atomicWriteFile(targetPath, content) {
|
|
|
42400
42701
|
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
42401
42702
|
try {
|
|
42402
42703
|
await bunWrite(tempPath, content);
|
|
42403
|
-
|
|
42704
|
+
_internals19.renameSync(tempPath, targetPath);
|
|
42404
42705
|
} finally {
|
|
42405
42706
|
try {
|
|
42406
|
-
|
|
42707
|
+
_internals19.unlinkSync(tempPath);
|
|
42407
42708
|
} catch {}
|
|
42408
42709
|
}
|
|
42409
42710
|
}
|
|
42410
42711
|
function withTaskEvidenceLock(directory, taskId, agent, fn2) {
|
|
42411
42712
|
return withEvidenceLock(directory, taskEvidenceRelPath(taskId), agent, taskId, fn2);
|
|
42412
42713
|
}
|
|
42413
|
-
var
|
|
42714
|
+
var _internals19;
|
|
42414
42715
|
var init_task_file = __esm(() => {
|
|
42415
42716
|
init_bun_compat();
|
|
42416
42717
|
init_lock();
|
|
42417
|
-
|
|
42718
|
+
_internals19 = {
|
|
42418
42719
|
renameSync: renameSync6,
|
|
42419
42720
|
unlinkSync: unlinkSync4
|
|
42420
42721
|
};
|
|
@@ -42967,7 +43268,7 @@ function createDelegationGateHook(config2, directory) {
|
|
|
42967
43268
|
if (standardWorktreeSerializationSessions.has(input.sessionID)) {
|
|
42968
43269
|
throw new Error("STANDARD_WORKTREE_ISOLATION_SERIALIZED: prior standard worktree isolation setup failed in this session; wait for the active coder task to finish before dispatching another coder.");
|
|
42969
43270
|
}
|
|
42970
|
-
const plan = await
|
|
43271
|
+
const plan = await _internals20.loadPlanJsonOnly(directory);
|
|
42971
43272
|
if (!plan)
|
|
42972
43273
|
return;
|
|
42973
43274
|
const profile = plan.execution_profile;
|
|
@@ -43582,7 +43883,7 @@ ${warningLines.join(`
|
|
|
43582
43883
|
toolAfter
|
|
43583
43884
|
};
|
|
43584
43885
|
}
|
|
43585
|
-
var EvidenceTaskIdPlanSchema, pendingCoderScopeByTaskId, SWARM_BACKGROUND_TASK_BLOCKED_MESSAGE, ACTIVE_PARALLEL_TASK_STATES,
|
|
43886
|
+
var EvidenceTaskIdPlanSchema, pendingCoderScopeByTaskId, SWARM_BACKGROUND_TASK_BLOCKED_MESSAGE, ACTIVE_PARALLEL_TASK_STATES, _internals20;
|
|
43586
43887
|
var init_delegation_gate = __esm(() => {
|
|
43587
43888
|
init_zod();
|
|
43588
43889
|
init_schema();
|
|
@@ -43612,7 +43913,7 @@ var init_delegation_gate = __esm(() => {
|
|
|
43612
43913
|
"reviewer_run",
|
|
43613
43914
|
"tests_run"
|
|
43614
43915
|
]);
|
|
43615
|
-
|
|
43916
|
+
_internals20 = {
|
|
43616
43917
|
resolveEvidenceTaskId,
|
|
43617
43918
|
resolveDelegatedPlanTaskId,
|
|
43618
43919
|
buildParallelExecutionGuidance,
|
|
@@ -43946,7 +44247,7 @@ __export(exports_state, {
|
|
|
43946
44247
|
advanceTaskState: () => advanceTaskState,
|
|
43947
44248
|
addKnowledgeAckDedup: () => addKnowledgeAckDedup,
|
|
43948
44249
|
_resetCouncilDisagreementWarnings: () => _resetCouncilDisagreementWarnings,
|
|
43949
|
-
_internals: () =>
|
|
44250
|
+
_internals: () => _internals21,
|
|
43950
44251
|
MAX_TRACKED_KNOWLEDGE_ACKS: () => MAX_TRACKED_KNOWLEDGE_ACKS,
|
|
43951
44252
|
MAX_TRACKED_CRITICAL_SHOWN: () => MAX_TRACKED_CRITICAL_SHOWN,
|
|
43952
44253
|
AgentRunContext: () => AgentRunContext
|
|
@@ -44074,10 +44375,10 @@ function startAgentSession(sessionId, agentName, staleDurationMs = 7200000, dire
|
|
|
44074
44375
|
swarmState.agentSessions.set(sessionId, sessionState);
|
|
44075
44376
|
telemetry.sessionStarted(sessionId, agentName);
|
|
44076
44377
|
swarmState.activeAgent.set(sessionId, agentName);
|
|
44077
|
-
|
|
44378
|
+
_internals21.applyRehydrationCache(sessionState);
|
|
44078
44379
|
if (directory) {
|
|
44079
44380
|
let rehydrationPromise;
|
|
44080
|
-
rehydrationPromise =
|
|
44381
|
+
rehydrationPromise = _internals21.rehydrateSessionFromDisk(directory, sessionState).then(async () => {
|
|
44081
44382
|
try {
|
|
44082
44383
|
sessionState.prSubscriptions = await rehydratePrSubscriptions(sessionId, directory);
|
|
44083
44384
|
} catch (err2) {
|
|
@@ -44253,7 +44554,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
|
|
|
44253
44554
|
session.lastToolCallTime = now;
|
|
44254
44555
|
return session;
|
|
44255
44556
|
}
|
|
44256
|
-
|
|
44557
|
+
_internals21.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
|
|
44257
44558
|
session = swarmState.agentSessions.get(sessionId);
|
|
44258
44559
|
if (!session) {
|
|
44259
44560
|
throw new Error(`Failed to create guardrail session for ${sessionId}`);
|
|
@@ -44614,8 +44915,8 @@ function applyRehydrationCache(session) {
|
|
|
44614
44915
|
}
|
|
44615
44916
|
}
|
|
44616
44917
|
async function rehydrateSessionFromDisk(directory, session) {
|
|
44617
|
-
await
|
|
44618
|
-
|
|
44918
|
+
await _internals21.buildRehydrationCache(directory);
|
|
44919
|
+
_internals21.applyRehydrationCache(session);
|
|
44619
44920
|
}
|
|
44620
44921
|
function hasActiveTurboMode(sessionID) {
|
|
44621
44922
|
if (sessionID) {
|
|
@@ -44723,7 +45024,7 @@ async function rehydratePrSubscriptions(sessionID, directory) {
|
|
|
44723
45024
|
}
|
|
44724
45025
|
return map2;
|
|
44725
45026
|
}
|
|
44726
|
-
var _rehydrationCache = null, _councilDisagreementWarned, STATE_ORDER, _toolAggregates, defaultRunContext, _runContexts, swarmState, MAX_TRACKED_CRITICAL_SHOWN = 500, MAX_TRACKED_KNOWLEDGE_ACKS = 5000,
|
|
45027
|
+
var _rehydrationCache = null, _councilDisagreementWarned, STATE_ORDER, _toolAggregates, defaultRunContext, _runContexts, swarmState, MAX_TRACKED_CRITICAL_SHOWN = 500, MAX_TRACKED_KNOWLEDGE_ACKS = 5000, _internals21;
|
|
44727
45028
|
var init_state = __esm(() => {
|
|
44728
45029
|
init_constants();
|
|
44729
45030
|
init_plan_schema();
|
|
@@ -44766,7 +45067,7 @@ var init_state = __esm(() => {
|
|
|
44766
45067
|
fullAutoEnabledInConfig: false,
|
|
44767
45068
|
environmentProfiles: defaultRunContext.environmentProfiles
|
|
44768
45069
|
};
|
|
44769
|
-
|
|
45070
|
+
_internals21 = {
|
|
44770
45071
|
swarmState,
|
|
44771
45072
|
resetSwarmState,
|
|
44772
45073
|
ensureAgentSession,
|
|
@@ -58434,7 +58735,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
58434
58735
|
const prunedBranches = [];
|
|
58435
58736
|
try {
|
|
58436
58737
|
const currentBranch = getCurrentBranch(cwd);
|
|
58437
|
-
const defaultRemoteBranch =
|
|
58738
|
+
const defaultRemoteBranch = _internals22.detectDefaultRemoteBranch(cwd);
|
|
58438
58739
|
if (!defaultRemoteBranch) {
|
|
58439
58740
|
return {
|
|
58440
58741
|
success: false,
|
|
@@ -58616,7 +58917,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
58616
58917
|
function resetToMainAfterMerge(cwd, options) {
|
|
58617
58918
|
const warnings = [];
|
|
58618
58919
|
try {
|
|
58619
|
-
const defaultBranch =
|
|
58920
|
+
const defaultBranch = _internals22.detectDefaultRemoteBranch(cwd);
|
|
58620
58921
|
if (!defaultBranch) {
|
|
58621
58922
|
return {
|
|
58622
58923
|
success: false,
|
|
@@ -58643,7 +58944,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58643
58944
|
}
|
|
58644
58945
|
if (currentBranch === defaultBranch) {
|
|
58645
58946
|
try {
|
|
58646
|
-
const logOutput =
|
|
58947
|
+
const logOutput = _internals22.gitExec(["log", `${targetBranch}..HEAD`, "--oneline"], cwd);
|
|
58647
58948
|
if (logOutput.trim().length > 0) {
|
|
58648
58949
|
return {
|
|
58649
58950
|
success: false,
|
|
@@ -58658,11 +58959,11 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58658
58959
|
} catch {}
|
|
58659
58960
|
} else {
|
|
58660
58961
|
try {
|
|
58661
|
-
|
|
58962
|
+
_internals22.gitExec(["rev-parse", "--abbrev-ref", `${currentBranch}@{upstream}`], cwd);
|
|
58662
58963
|
} catch {
|
|
58663
58964
|
try {
|
|
58664
|
-
const localSha =
|
|
58665
|
-
const remoteSha =
|
|
58965
|
+
const localSha = _internals22.gitExec(["rev-parse", "HEAD"], cwd).trim();
|
|
58966
|
+
const remoteSha = _internals22.gitExec(["rev-parse", targetBranch], cwd).trim();
|
|
58666
58967
|
if (localSha !== remoteSha) {
|
|
58667
58968
|
return {
|
|
58668
58969
|
success: false,
|
|
@@ -58688,7 +58989,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58688
58989
|
}
|
|
58689
58990
|
}
|
|
58690
58991
|
try {
|
|
58691
|
-
|
|
58992
|
+
_internals22.gitExec(["fetch", "--prune", "origin"], cwd);
|
|
58692
58993
|
} catch (err2) {
|
|
58693
58994
|
return {
|
|
58694
58995
|
success: false,
|
|
@@ -58704,7 +59005,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58704
59005
|
let switchedBranch = false;
|
|
58705
59006
|
if (currentBranch !== defaultBranch) {
|
|
58706
59007
|
try {
|
|
58707
|
-
|
|
59008
|
+
_internals22.gitExec(["checkout", defaultBranch], cwd);
|
|
58708
59009
|
switchedBranch = true;
|
|
58709
59010
|
} catch (err2) {
|
|
58710
59011
|
return {
|
|
@@ -58719,7 +59020,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58719
59020
|
}
|
|
58720
59021
|
}
|
|
58721
59022
|
try {
|
|
58722
|
-
|
|
59023
|
+
_internals22.gitExec(["reset", "--hard", targetBranch], cwd);
|
|
58723
59024
|
} catch (err2) {
|
|
58724
59025
|
return {
|
|
58725
59026
|
success: false,
|
|
@@ -58740,7 +59041,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58740
59041
|
while (Date.now() < endTime) {}
|
|
58741
59042
|
}
|
|
58742
59043
|
try {
|
|
58743
|
-
|
|
59044
|
+
_internals22.gitExec(["checkout", "--", "."], cwd);
|
|
58744
59045
|
discardSucceeded = true;
|
|
58745
59046
|
break;
|
|
58746
59047
|
} catch {}
|
|
@@ -58751,18 +59052,18 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58751
59052
|
changesDiscarded = discardSucceeded;
|
|
58752
59053
|
}
|
|
58753
59054
|
try {
|
|
58754
|
-
|
|
59055
|
+
_internals22.gitExec(["clean", "-fd"], cwd);
|
|
58755
59056
|
} catch {
|
|
58756
59057
|
warnings.push("Could not clean untracked files");
|
|
58757
59058
|
}
|
|
58758
59059
|
let branchDeleted = false;
|
|
58759
59060
|
if (switchedBranch && previousBranch !== defaultBranch) {
|
|
58760
59061
|
try {
|
|
58761
|
-
const mergedOutput =
|
|
59062
|
+
const mergedOutput = _internals22.gitExec(["branch", "--merged", defaultBranch], cwd);
|
|
58762
59063
|
const isMerged = mergedOutput.split(`
|
|
58763
59064
|
`).some((line) => line.trim() === previousBranch || line.trim() === `* ${previousBranch}`);
|
|
58764
59065
|
if (isMerged) {
|
|
58765
|
-
|
|
59066
|
+
_internals22.gitExec(["branch", "-d", previousBranch], cwd);
|
|
58766
59067
|
branchDeleted = true;
|
|
58767
59068
|
} else {
|
|
58768
59069
|
warnings.push(`Branch ${previousBranch} is not merged into ${defaultBranch} — keeping it`);
|
|
@@ -58773,7 +59074,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58773
59074
|
}
|
|
58774
59075
|
if (options?.pruneBranches) {
|
|
58775
59076
|
try {
|
|
58776
|
-
const mergedOutput =
|
|
59077
|
+
const mergedOutput = _internals22.gitExec(["branch", "--merged", defaultBranch], cwd);
|
|
58777
59078
|
const mergedLines = mergedOutput.split(`
|
|
58778
59079
|
`);
|
|
58779
59080
|
for (const line of mergedLines) {
|
|
@@ -58782,7 +59083,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58782
59083
|
continue;
|
|
58783
59084
|
}
|
|
58784
59085
|
try {
|
|
58785
|
-
|
|
59086
|
+
_internals22.gitExec(["branch", "-d", trimmedLine], cwd);
|
|
58786
59087
|
} catch {
|
|
58787
59088
|
warnings.push(`Could not prune branch: ${trimmedLine}`);
|
|
58788
59089
|
}
|
|
@@ -58812,10 +59113,10 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
58812
59113
|
};
|
|
58813
59114
|
}
|
|
58814
59115
|
}
|
|
58815
|
-
var GIT_TIMEOUT_MS2 = 30000,
|
|
59116
|
+
var GIT_TIMEOUT_MS2 = 30000, _internals22;
|
|
58816
59117
|
var init_branch = __esm(() => {
|
|
58817
59118
|
init_logger();
|
|
58818
|
-
|
|
59119
|
+
_internals22 = {
|
|
58819
59120
|
gitExec: gitExec2,
|
|
58820
59121
|
detectDefaultRemoteBranch,
|
|
58821
59122
|
getDefaultBaseBranch,
|
|
@@ -59394,7 +59695,7 @@ __export(exports_knowledge_store, {
|
|
|
59394
59695
|
appendRejectedLesson: () => appendRejectedLesson,
|
|
59395
59696
|
appendKnowledgeWithCapEnforcement: () => appendKnowledgeWithCapEnforcement,
|
|
59396
59697
|
appendKnowledge: () => appendKnowledge,
|
|
59397
|
-
_internals: () =>
|
|
59698
|
+
_internals: () => _internals23,
|
|
59398
59699
|
OUTCOME_SIGNAL_SMOOTHING: () => OUTCOME_SIGNAL_SMOOTHING
|
|
59399
59700
|
});
|
|
59400
59701
|
import { existsSync as existsSync13 } from "node:fs";
|
|
@@ -59870,11 +60171,11 @@ async function applyConfidenceDeltas(filePath, deltas) {
|
|
|
59870
60171
|
}
|
|
59871
60172
|
}
|
|
59872
60173
|
}
|
|
59873
|
-
var import_proper_lockfile3, OUTCOME_SIGNAL_SMOOTHING = 4, CONFIDENCE_FLOOR = 0.1, CONFIDENCE_CEILING = 1,
|
|
60174
|
+
var import_proper_lockfile3, OUTCOME_SIGNAL_SMOOTHING = 4, CONFIDENCE_FLOOR = 0.1, CONFIDENCE_CEILING = 1, _internals23;
|
|
59874
60175
|
var init_knowledge_store = __esm(() => {
|
|
59875
60176
|
init_task_file();
|
|
59876
60177
|
import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
59877
|
-
|
|
60178
|
+
_internals23 = {
|
|
59878
60179
|
getPlatformConfigDir,
|
|
59879
60180
|
resolveSwarmKnowledgePath,
|
|
59880
60181
|
resolveSwarmRejectedPath,
|
|
@@ -59919,7 +60220,7 @@ __export(exports_knowledge_events, {
|
|
|
59919
60220
|
countEntryViolationsInWindow: () => countEntryViolationsInWindow,
|
|
59920
60221
|
applyKnowledgeVerdictFeedback: () => applyKnowledgeVerdictFeedback,
|
|
59921
60222
|
appendKnowledgeEvent: () => appendKnowledgeEvent,
|
|
59922
|
-
_internals: () =>
|
|
60223
|
+
_internals: () => _internals24,
|
|
59923
60224
|
RECEIPT_EVENT_TYPES: () => RECEIPT_EVENT_TYPES,
|
|
59924
60225
|
MAX_VIOLATION_TIMESTAMPS: () => MAX_VIOLATION_TIMESTAMPS,
|
|
59925
60226
|
MAX_EVENT_LOG_ENTRIES: () => MAX_EVENT_LOG_ENTRIES,
|
|
@@ -60375,7 +60676,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
|
|
|
60375
60676
|
return { processed: 0, bumps: 0 };
|
|
60376
60677
|
}
|
|
60377
60678
|
}
|
|
60378
|
-
var import_proper_lockfile4, KNOWLEDGE_EVENT_SCHEMA_VERSION = 1, MAX_EVENT_LOG_ENTRIES = 5000, counterRollupCache, MAX_COUNTER_ROLLUP_CACHE_DIRS = 32, RECEIPT_EVENT_TYPES, MAX_VIOLATION_TIMESTAMPS = 10, VERDICT_CONFIDENCE_BOOST = 0.03, VERDICT_CONFIDENCE_DECAY = 0.05,
|
|
60679
|
+
var import_proper_lockfile4, KNOWLEDGE_EVENT_SCHEMA_VERSION = 1, MAX_EVENT_LOG_ENTRIES = 5000, counterRollupCache, MAX_COUNTER_ROLLUP_CACHE_DIRS = 32, RECEIPT_EVENT_TYPES, MAX_VIOLATION_TIMESTAMPS = 10, VERDICT_CONFIDENCE_BOOST = 0.03, VERDICT_CONFIDENCE_DECAY = 0.05, _internals24;
|
|
60379
60680
|
var init_knowledge_events = __esm(() => {
|
|
60380
60681
|
init_task_file();
|
|
60381
60682
|
init_logger();
|
|
@@ -60390,7 +60691,7 @@ var init_knowledge_events = __esm(() => {
|
|
|
60390
60691
|
"n_a",
|
|
60391
60692
|
"override"
|
|
60392
60693
|
]);
|
|
60393
|
-
|
|
60694
|
+
_internals24 = {
|
|
60394
60695
|
resolveKnowledgeEventsPath,
|
|
60395
60696
|
resolveKnowledgeCounterBaselinePath,
|
|
60396
60697
|
appendKnowledgeEvent,
|
|
@@ -61931,7 +62232,7 @@ __export(exports_skill_generator, {
|
|
|
61931
62232
|
activeRepoRelativePath: () => activeRepoRelativePath,
|
|
61932
62233
|
activePath: () => activePath,
|
|
61933
62234
|
activateProposal: () => activateProposal,
|
|
61934
|
-
_internals: () =>
|
|
62235
|
+
_internals: () => _internals25,
|
|
61935
62236
|
STRONG_SKILL_OUTCOME_COUNT: () => STRONG_SKILL_OUTCOME_COUNT,
|
|
61936
62237
|
DEFAULT_SKILL_MIN_CONFIRMATIONS: () => DEFAULT_SKILL_MIN_CONFIRMATIONS,
|
|
61937
62238
|
DEFAULT_SKILL_MIN_CONFIDENCE: () => DEFAULT_SKILL_MIN_CONFIDENCE
|
|
@@ -62521,7 +62822,7 @@ async function activateProposal(directory, slug, force = false, options = {}) {
|
|
|
62521
62822
|
try {
|
|
62522
62823
|
await stampSourceEntries(directory, cleanSlug, fm.sourceKnowledgeIds);
|
|
62523
62824
|
try {
|
|
62524
|
-
|
|
62825
|
+
_internals25.unlinkSync(from);
|
|
62525
62826
|
} catch {}
|
|
62526
62827
|
return {
|
|
62527
62828
|
activated: true,
|
|
@@ -62626,7 +62927,7 @@ async function autoApplyProposals(directory, llmDelegate) {
|
|
|
62626
62927
|
}
|
|
62627
62928
|
} else if (verdict === "REJECT") {
|
|
62628
62929
|
try {
|
|
62629
|
-
|
|
62930
|
+
_internals25.unlinkSync(proposal.path);
|
|
62630
62931
|
warn(`[skill-generator] auto-apply rejected proposal "${proposal.slug}"; deleted ${proposal.path}`);
|
|
62631
62932
|
result.rejected.push(proposal.slug);
|
|
62632
62933
|
} catch (delErr) {
|
|
@@ -62736,7 +63037,7 @@ async function regenerateSkill(directory, slug, options = {}) {
|
|
|
62736
63037
|
matchedEntries = all.filter((e) => idSet.has(e.id));
|
|
62737
63038
|
if (matchedEntries.length === idSet.size && idSet.size > 0 && matchedEntries.every((e) => e.status === "archived")) {
|
|
62738
63039
|
try {
|
|
62739
|
-
await
|
|
63040
|
+
await _internals25.retireSkill(directory, cleanSlug, "auto-retire: all source knowledge entries archived at regeneration time");
|
|
62740
63041
|
} catch {}
|
|
62741
63042
|
return {
|
|
62742
63043
|
regenerated: false,
|
|
@@ -62759,7 +63060,7 @@ async function regenerateSkill(directory, slug, options = {}) {
|
|
|
62759
63060
|
const activeEntries = matchedEntries.filter((e) => e.status !== "archived");
|
|
62760
63061
|
if (activeEntries.length === 0) {
|
|
62761
63062
|
try {
|
|
62762
|
-
await
|
|
63063
|
+
await _internals25.retireSkill(directory, cleanSlug, "auto-retire: all matched source knowledge entries archived at regeneration time");
|
|
62763
63064
|
} catch {}
|
|
62764
63065
|
return {
|
|
62765
63066
|
regenerated: false,
|
|
@@ -62876,7 +63177,7 @@ async function regenerateSkill(directory, slug, options = {}) {
|
|
|
62876
63177
|
evaluation
|
|
62877
63178
|
};
|
|
62878
63179
|
}
|
|
62879
|
-
var SLUG_PATTERN2, DEFAULT_SKILL_MIN_CONFIDENCE = 0.7, DEFAULT_SKILL_MIN_CONFIRMATIONS = 2, STRONG_SKILL_OUTCOME_COUNT = 3, MIN_CLUSTER_SIZE = 2, JACCARD_THRESHOLD = 0.5, AUTO_APPLY_BATCH_LIMIT = 5,
|
|
63180
|
+
var SLUG_PATTERN2, DEFAULT_SKILL_MIN_CONFIDENCE = 0.7, DEFAULT_SKILL_MIN_CONFIRMATIONS = 2, STRONG_SKILL_OUTCOME_COUNT = 3, MIN_CLUSTER_SIZE = 2, JACCARD_THRESHOLD = 0.5, AUTO_APPLY_BATCH_LIMIT = 5, _internals25;
|
|
62880
63181
|
var init_skill_generator = __esm(() => {
|
|
62881
63182
|
init_knowledge_events();
|
|
62882
63183
|
init_knowledge_store();
|
|
@@ -62885,7 +63186,7 @@ var init_skill_generator = __esm(() => {
|
|
|
62885
63186
|
init_skill_changelog();
|
|
62886
63187
|
init_skill_evaluator();
|
|
62887
63188
|
SLUG_PATTERN2 = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
62888
|
-
|
|
63189
|
+
_internals25 = {
|
|
62889
63190
|
sanitizeSlug,
|
|
62890
63191
|
isValidSlug: isValidSlug2,
|
|
62891
63192
|
selectCandidateEntries,
|
|
@@ -63172,7 +63473,7 @@ async function reviseSkill(params) {
|
|
|
63172
63473
|
}
|
|
63173
63474
|
if (!params.delegate) {
|
|
63174
63475
|
try {
|
|
63175
|
-
const revised =
|
|
63476
|
+
const revised = _internals26.buildDeterministicRevision(params.currentContent, params.currentVersion, params.violationContexts);
|
|
63176
63477
|
const validation = await validateRevisionCandidate(params, revised, "skill_reviser:deterministic");
|
|
63177
63478
|
if (!validation.passed) {
|
|
63178
63479
|
return {
|
|
@@ -63299,13 +63600,13 @@ async function reviseSkill(params) {
|
|
|
63299
63600
|
};
|
|
63300
63601
|
}
|
|
63301
63602
|
}
|
|
63302
|
-
var REVISION_VIOLATION_THRESHOLD = 0.15, MAX_REVISION_CALLS_PER_PHASE = 3, DEFAULT_MAX_CALLS = 10,
|
|
63603
|
+
var REVISION_VIOLATION_THRESHOLD = 0.15, MAX_REVISION_CALLS_PER_PHASE = 3, DEFAULT_MAX_CALLS = 10, _internals26;
|
|
63303
63604
|
var init_skill_reviser = __esm(() => {
|
|
63304
63605
|
init_logger();
|
|
63305
63606
|
init_skill_changelog();
|
|
63306
63607
|
init_skill_evaluator();
|
|
63307
63608
|
init_skill_improver_quota();
|
|
63308
|
-
|
|
63609
|
+
_internals26 = {
|
|
63309
63610
|
reviseSkill,
|
|
63310
63611
|
getSkillVersion,
|
|
63311
63612
|
buildDeterministicRevision,
|
|
@@ -63376,9 +63677,9 @@ function parseFeedbackMarker(raw) {
|
|
|
63376
63677
|
function readFeedbackAppliedEntryIds(directory) {
|
|
63377
63678
|
const resolved = resolveLogPath(directory);
|
|
63378
63679
|
const processed = new Set;
|
|
63379
|
-
if (!
|
|
63680
|
+
if (!_internals27.existsSync(resolved))
|
|
63380
63681
|
return processed;
|
|
63381
|
-
const raw =
|
|
63682
|
+
const raw = _internals27.readFileSync(resolved, "utf-8");
|
|
63382
63683
|
for (const line of raw.split(`
|
|
63383
63684
|
`)) {
|
|
63384
63685
|
const trimmed = line.trim();
|
|
@@ -63399,15 +63700,15 @@ function appendFeedbackAppliedMarker(directory, processedEntryIds) {
|
|
|
63399
63700
|
return;
|
|
63400
63701
|
const resolved = resolveLogPath(directory);
|
|
63401
63702
|
const dir = path38.dirname(resolved);
|
|
63402
|
-
if (!
|
|
63403
|
-
|
|
63703
|
+
if (!_internals27.existsSync(dir)) {
|
|
63704
|
+
_internals27.mkdirSync(dir, { recursive: true });
|
|
63404
63705
|
}
|
|
63405
63706
|
const marker = {
|
|
63406
63707
|
type: "feedback_applied",
|
|
63407
63708
|
timestamp: new Date().toISOString(),
|
|
63408
63709
|
processedEntryIds: [...new Set(processedEntryIds)]
|
|
63409
63710
|
};
|
|
63410
|
-
|
|
63711
|
+
_internals27.appendFileSync(resolved, `${JSON.stringify(marker)}
|
|
63411
63712
|
`, "utf-8");
|
|
63412
63713
|
}
|
|
63413
63714
|
function appendSkillUsageEntry(directory, entry) {
|
|
@@ -63444,11 +63745,11 @@ function appendSkillUsageEntry(directory, entry) {
|
|
|
63444
63745
|
}
|
|
63445
63746
|
const resolved = validateSwarmPath(directory, "skill-usage.jsonl");
|
|
63446
63747
|
const dir = path38.dirname(resolved);
|
|
63447
|
-
if (!
|
|
63448
|
-
|
|
63748
|
+
if (!_internals27.existsSync(dir)) {
|
|
63749
|
+
_internals27.mkdirSync(dir, { recursive: true });
|
|
63449
63750
|
}
|
|
63450
63751
|
const fullEntry = {
|
|
63451
|
-
id:
|
|
63752
|
+
id: _internals27.generateId(),
|
|
63452
63753
|
skillPath,
|
|
63453
63754
|
agentName,
|
|
63454
63755
|
taskID,
|
|
@@ -63458,21 +63759,21 @@ function appendSkillUsageEntry(directory, entry) {
|
|
|
63458
63759
|
...reviewerNotes !== undefined && { reviewerNotes },
|
|
63459
63760
|
...skillVersion !== undefined && { skillVersion }
|
|
63460
63761
|
};
|
|
63461
|
-
|
|
63762
|
+
_internals27.appendFileSync(resolved, `${JSON.stringify(fullEntry)}
|
|
63462
63763
|
`, "utf-8");
|
|
63463
63764
|
try {
|
|
63464
|
-
const stat6 =
|
|
63765
|
+
const stat6 = _internals27.statSync(resolved);
|
|
63465
63766
|
if (stat6.size > SKILL_USAGE_LOG_ROTATE_BYTES) {
|
|
63466
|
-
|
|
63767
|
+
_internals27.pruneSkillUsageLog(directory, SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL);
|
|
63467
63768
|
}
|
|
63468
63769
|
} catch {}
|
|
63469
63770
|
}
|
|
63470
63771
|
function readSkillUsageEntries(directory, options) {
|
|
63471
63772
|
const resolved = resolveLogPath(directory);
|
|
63472
|
-
if (!
|
|
63773
|
+
if (!_internals27.existsSync(resolved)) {
|
|
63473
63774
|
return [];
|
|
63474
63775
|
}
|
|
63475
|
-
const raw =
|
|
63776
|
+
const raw = _internals27.readFileSync(resolved, "utf-8");
|
|
63476
63777
|
const entries = [];
|
|
63477
63778
|
for (const line of raw.split(`
|
|
63478
63779
|
`)) {
|
|
@@ -63511,20 +63812,20 @@ function readSkillUsageEntries(directory, options) {
|
|
|
63511
63812
|
}
|
|
63512
63813
|
function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEFAULT) {
|
|
63513
63814
|
const logPath = resolveLogPath(directory);
|
|
63514
|
-
if (!
|
|
63815
|
+
if (!_internals27.existsSync(logPath))
|
|
63515
63816
|
return [];
|
|
63516
63817
|
try {
|
|
63517
63818
|
const normalizedMaxBytes = Number.isFinite(maxBytes) ? maxBytes : TAIL_BYTES_DEFAULT;
|
|
63518
63819
|
const boundedMaxBytes = Math.min(Math.max(1, normalizedMaxBytes), MAX_TAIL_BYTES);
|
|
63519
|
-
const stat6 =
|
|
63820
|
+
const stat6 = _internals27.statSync(logPath);
|
|
63520
63821
|
const start2 = Math.max(0, stat6.size - boundedMaxBytes);
|
|
63521
|
-
const fd =
|
|
63822
|
+
const fd = _internals27.openSync(logPath, "r");
|
|
63522
63823
|
try {
|
|
63523
63824
|
const readLen = stat6.size - start2;
|
|
63524
63825
|
if (readLen === 0)
|
|
63525
63826
|
return [];
|
|
63526
63827
|
const buf = Buffer.alloc(readLen);
|
|
63527
|
-
|
|
63828
|
+
_internals27.readSync(fd, buf, 0, buf.length, start2);
|
|
63528
63829
|
const content = buf.toString("utf-8");
|
|
63529
63830
|
let usable;
|
|
63530
63831
|
if (start2 > 0) {
|
|
@@ -63551,7 +63852,7 @@ function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEF
|
|
|
63551
63852
|
}
|
|
63552
63853
|
return entries;
|
|
63553
63854
|
} finally {
|
|
63554
|
-
|
|
63855
|
+
_internals27.closeSync(fd);
|
|
63555
63856
|
}
|
|
63556
63857
|
} catch {
|
|
63557
63858
|
return [];
|
|
@@ -63588,7 +63889,7 @@ function computeComplianceByVersion(entries, skillPath) {
|
|
|
63588
63889
|
}
|
|
63589
63890
|
function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
63590
63891
|
const resolved = resolveLogPath(directory);
|
|
63591
|
-
if (!
|
|
63892
|
+
if (!_internals27.existsSync(resolved)) {
|
|
63592
63893
|
return { pruned: 0, remaining: 0 };
|
|
63593
63894
|
}
|
|
63594
63895
|
const allEntries = readSkillUsageEntries(directory);
|
|
@@ -63624,13 +63925,13 @@ function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
|
|
|
63624
63925
|
`).concat(`
|
|
63625
63926
|
`);
|
|
63626
63927
|
try {
|
|
63627
|
-
|
|
63628
|
-
|
|
63928
|
+
_internals27.writeFileSync(tmpPath, content, "utf-8");
|
|
63929
|
+
_internals27.renameSync(tmpPath, resolved);
|
|
63629
63930
|
} catch (writeErr) {
|
|
63630
63931
|
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
63631
63932
|
try {
|
|
63632
|
-
if (
|
|
63633
|
-
|
|
63933
|
+
if (_internals27.existsSync(tmpPath)) {
|
|
63934
|
+
_internals27.writeFileSync(tmpPath, "", "utf-8");
|
|
63634
63935
|
}
|
|
63635
63936
|
} catch {}
|
|
63636
63937
|
return { pruned: 0, remaining: allEntries.length, error: msg };
|
|
@@ -63652,10 +63953,10 @@ async function resolveSourceKnowledgeIds(directory, skillPath) {
|
|
|
63652
63953
|
if (!isContained) {
|
|
63653
63954
|
return [];
|
|
63654
63955
|
}
|
|
63655
|
-
if (!
|
|
63956
|
+
if (!_internals27.existsSync(absolute)) {
|
|
63656
63957
|
return [];
|
|
63657
63958
|
}
|
|
63658
|
-
const content =
|
|
63959
|
+
const content = _internals27.readFileSync(absolute, "utf-8");
|
|
63659
63960
|
return parseGeneratedFromKnowledge(content);
|
|
63660
63961
|
} catch (err2) {
|
|
63661
63962
|
console.warn("[skill-usage-log] resolveSourceKnowledgeIds failed (fail-open):", err2 instanceof Error ? err2.message : String(err2));
|
|
@@ -63755,11 +64056,11 @@ async function applySkillUsageFeedback(directory, options) {
|
|
|
63755
64056
|
}
|
|
63756
64057
|
return { processed, bumps };
|
|
63757
64058
|
}
|
|
63758
|
-
var
|
|
64059
|
+
var _internals27, TAIL_BYTES_DEFAULT, MAX_TAIL_BYTES, SKILL_USAGE_LOG_ROTATE_BYTES, SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL = 500, COMPLIANCE_BOOST = 0.05, VIOLATION_DECAY = 0.1;
|
|
63759
64060
|
var init_skill_usage_log = __esm(() => {
|
|
63760
64061
|
init_knowledge_store();
|
|
63761
64062
|
init_utils2();
|
|
63762
|
-
|
|
64063
|
+
_internals27 = {
|
|
63763
64064
|
generateId: () => crypto4.randomUUID(),
|
|
63764
64065
|
appendFileSync: fs19.appendFileSync.bind(fs19),
|
|
63765
64066
|
readFileSync: fs19.readFileSync.bind(fs19),
|
|
@@ -63792,8 +64093,8 @@ import * as path39 from "node:path";
|
|
|
63792
64093
|
async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
|
|
63793
64094
|
const observations = [];
|
|
63794
64095
|
try {
|
|
63795
|
-
const skillListResult = await
|
|
63796
|
-
const usageEntries =
|
|
64096
|
+
const skillListResult = await _internals28.listSkills(directory);
|
|
64097
|
+
const usageEntries = _internals28.readSkillUsageEntries(directory);
|
|
63797
64098
|
for (const active of skillListResult.active) {
|
|
63798
64099
|
if (excludeSlugs?.has(active.slug))
|
|
63799
64100
|
continue;
|
|
@@ -63815,15 +64116,15 @@ async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
|
|
|
63815
64116
|
const violationRate = skillUsage.length > 0 ? violations / skillUsage.length : 0;
|
|
63816
64117
|
let allArchived = false;
|
|
63817
64118
|
try {
|
|
63818
|
-
const content = await
|
|
63819
|
-
const fm =
|
|
64119
|
+
const content = await _internals28.readFileAsync(active.path, "utf-8");
|
|
64120
|
+
const fm = _internals28.parseDraftFrontmatter(content);
|
|
63820
64121
|
if (fm && fm.sourceKnowledgeIds.length > 0) {
|
|
63821
|
-
const swarmKnowledge = await
|
|
64122
|
+
const swarmKnowledge = await _internals28.readKnowledge(curatorKnowledgePath);
|
|
63822
64123
|
let hiveKnowledge = [];
|
|
63823
64124
|
try {
|
|
63824
64125
|
const hivePath = resolveHiveKnowledgePath();
|
|
63825
64126
|
if (fs20.existsSync(hivePath)) {
|
|
63826
|
-
hiveKnowledge = await
|
|
64127
|
+
hiveKnowledge = await _internals28.readKnowledge(hivePath);
|
|
63827
64128
|
}
|
|
63828
64129
|
} catch {}
|
|
63829
64130
|
const allKnowledge = [...swarmKnowledge, ...hiveKnowledge];
|
|
@@ -63834,7 +64135,7 @@ async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
|
|
|
63834
64135
|
} catch {}
|
|
63835
64136
|
if (violationRate > 0.3 || allArchived) {
|
|
63836
64137
|
const reason = violationRate > 0.3 ? `auto-retire: violation rate ${(violationRate * 100).toFixed(0)}% exceeds 30% threshold` : "auto-retire: all source knowledge entries archived";
|
|
63837
|
-
await
|
|
64138
|
+
await _internals28.retireSkill(directory, active.slug, reason);
|
|
63838
64139
|
observations.push(`Skill '${active.slug}' auto-retired: ${reason}`);
|
|
63839
64140
|
warn(`[curator] ${observations[observations.length - 1]}`);
|
|
63840
64141
|
}
|
|
@@ -64045,8 +64346,8 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64045
64346
|
const observations = [];
|
|
64046
64347
|
const timestamp = new Date().toISOString();
|
|
64047
64348
|
for (const agent of requiredAgents) {
|
|
64048
|
-
const normalizedAgent =
|
|
64049
|
-
const isDispatched = agentsDispatched.some((a) =>
|
|
64349
|
+
const normalizedAgent = _internals28.normalizeAgentName(agent);
|
|
64350
|
+
const isDispatched = agentsDispatched.some((a) => _internals28.normalizeAgentName(a) === normalizedAgent);
|
|
64050
64351
|
if (!isDispatched) {
|
|
64051
64352
|
observations.push({
|
|
64052
64353
|
phase,
|
|
@@ -64065,7 +64366,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64065
64366
|
if (e.type === "agent.delegation") {
|
|
64066
64367
|
const agent = e.agent;
|
|
64067
64368
|
if (agent && typeof agent === "string") {
|
|
64068
|
-
const normalized =
|
|
64369
|
+
const normalized = _internals28.normalizeAgentName(agent);
|
|
64069
64370
|
if (normalized === "coder") {
|
|
64070
64371
|
coderDelegations.push({ event: e, index: i2 });
|
|
64071
64372
|
} else if (normalized === "reviewer") {
|
|
@@ -64122,7 +64423,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64122
64423
|
if (e.type === "agent.delegation" && e.agent) {
|
|
64123
64424
|
const agent = e.agent;
|
|
64124
64425
|
if (agent && typeof agent === "string") {
|
|
64125
|
-
const normalized =
|
|
64426
|
+
const normalized = _internals28.normalizeAgentName(agent);
|
|
64126
64427
|
if (normalized === "sme") {
|
|
64127
64428
|
smeDelegations.push({ event: e, index: i2 });
|
|
64128
64429
|
}
|
|
@@ -64146,7 +64447,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
64146
64447
|
}
|
|
64147
64448
|
async function runCuratorInit(directory, config3, llmDelegate) {
|
|
64148
64449
|
try {
|
|
64149
|
-
const priorSummary = await
|
|
64450
|
+
const priorSummary = await _internals28.readCuratorSummary(directory);
|
|
64150
64451
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
64151
64452
|
const allEntries = await readKnowledge(knowledgePath);
|
|
64152
64453
|
const highConfidenceEntries = allEntries.filter((e) => typeof e.confidence === "number" && e.confidence >= config3.min_knowledge_confidence);
|
|
@@ -64267,7 +64568,7 @@ Could not load prior session context.`,
|
|
|
64267
64568
|
}
|
|
64268
64569
|
async function runCuratorPhase(directory, phase, agentsDispatched, config3, _knowledgeConfig, llmDelegate) {
|
|
64269
64570
|
try {
|
|
64270
|
-
const priorSummary = await
|
|
64571
|
+
const priorSummary = await _internals28.readCuratorSummary(directory);
|
|
64271
64572
|
if (priorSummary?.phase_digests.some((d) => d.phase === phase)) {
|
|
64272
64573
|
const existingDigest = priorSummary.phase_digests.find((d) => d.phase === phase);
|
|
64273
64574
|
return {
|
|
@@ -64280,10 +64581,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
64280
64581
|
};
|
|
64281
64582
|
}
|
|
64282
64583
|
const eventsJsonlContent = await readSwarmFileAsync(directory, "events.jsonl");
|
|
64283
|
-
const phaseEvents = eventsJsonlContent ?
|
|
64584
|
+
const phaseEvents = eventsJsonlContent ? _internals28.filterPhaseEvents(eventsJsonlContent, phase) : [];
|
|
64284
64585
|
const contextMd = await readSwarmFileAsync(directory, "context.md");
|
|
64285
64586
|
const requiredAgents = ["reviewer", "test_engineer"];
|
|
64286
|
-
const complianceObservations =
|
|
64587
|
+
const complianceObservations = _internals28.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
64287
64588
|
const plan = await loadPlanJsonOnly(directory);
|
|
64288
64589
|
const phaseData = plan?.phases.find((p) => p.id === phase);
|
|
64289
64590
|
const tasksCompleted = phaseData ? phaseData.tasks.filter((t) => t.status === "completed").length : 0;
|
|
@@ -64307,7 +64608,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
64307
64608
|
timestamp: new Date().toISOString(),
|
|
64308
64609
|
summary: `Phase ${phase} completed. ${tasksCompleted}/${tasksTotal} tasks completed. ${complianceObservations.length} compliance observations.`,
|
|
64309
64610
|
agents_used: [
|
|
64310
|
-
...new Set(agentsDispatched.map((a) =>
|
|
64611
|
+
...new Set(agentsDispatched.map((a) => _internals28.normalizeAgentName(a)))
|
|
64311
64612
|
],
|
|
64312
64613
|
tasks_completed: tasksCompleted,
|
|
64313
64614
|
tasks_total: tasksTotal,
|
|
@@ -64357,7 +64658,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
64357
64658
|
clearTimeout(timer);
|
|
64358
64659
|
}
|
|
64359
64660
|
if (llmOutput?.trim()) {
|
|
64360
|
-
knowledgeRecommendations =
|
|
64661
|
+
knowledgeRecommendations = _internals28.parseKnowledgeRecommendations(llmOutput);
|
|
64361
64662
|
const structured = parseStructuredCuratorBlocks(llmOutput);
|
|
64362
64663
|
knowledgeApplicationFindings = structured.findings;
|
|
64363
64664
|
skillCandidates = structured.candidates;
|
|
@@ -64408,7 +64709,7 @@ ${phaseDigest.summary}`,
|
|
|
64408
64709
|
knowledge_recommendations: knowledgeRecommendations
|
|
64409
64710
|
};
|
|
64410
64711
|
}
|
|
64411
|
-
await
|
|
64712
|
+
await _internals28.writeCuratorSummary(directory, updatedSummary);
|
|
64412
64713
|
if (knowledgeApplicationFindings.length > 0) {
|
|
64413
64714
|
try {
|
|
64414
64715
|
const evidenceDir = path39.join(directory, ".swarm", "evidence", String(phase));
|
|
@@ -64450,8 +64751,8 @@ ${phaseDigest.summary}`,
|
|
|
64450
64751
|
}
|
|
64451
64752
|
const revisedSlugs = new Set;
|
|
64452
64753
|
try {
|
|
64453
|
-
const skillListResult = await
|
|
64454
|
-
const usageEntries =
|
|
64754
|
+
const skillListResult = await _internals28.listSkills(directory);
|
|
64755
|
+
const usageEntries = _internals28.readSkillUsageEntries(directory);
|
|
64455
64756
|
let revisionCallsThisPhase = 0;
|
|
64456
64757
|
for (const active of skillListResult.active) {
|
|
64457
64758
|
if (revisionCallsThisPhase >= MAX_REVISION_CALLS_PER_PHASE)
|
|
@@ -64475,8 +64776,8 @@ ${phaseDigest.summary}`,
|
|
|
64475
64776
|
const violations = skillUsage.filter((e) => e.complianceVerdict === "violation").length;
|
|
64476
64777
|
const violationRate = violations / skillUsage.length;
|
|
64477
64778
|
if (violationRate > REVISION_VIOLATION_THRESHOLD && violationRate <= 0.3) {
|
|
64478
|
-
const content = await
|
|
64479
|
-
const fm =
|
|
64779
|
+
const content = await _internals28.readFileAsync(active.path, "utf-8");
|
|
64780
|
+
const fm = _internals28.parseDraftFrontmatter(content);
|
|
64480
64781
|
if (fm && fm.skillOrigin === "promoted_external")
|
|
64481
64782
|
continue;
|
|
64482
64783
|
const currentVersion = fm?.version ?? 1;
|
|
@@ -64487,7 +64788,7 @@ ${phaseDigest.summary}`,
|
|
|
64487
64788
|
reviewerNotes: e.reviewerNotes,
|
|
64488
64789
|
timestamp: e.timestamp
|
|
64489
64790
|
}));
|
|
64490
|
-
const result2 = await
|
|
64791
|
+
const result2 = await _internals28.reviseSkill({
|
|
64491
64792
|
directory,
|
|
64492
64793
|
slug: active.slug,
|
|
64493
64794
|
skillPath: active.path,
|
|
@@ -64506,7 +64807,7 @@ ${phaseDigest.summary}`,
|
|
|
64506
64807
|
} catch (revisionErr) {
|
|
64507
64808
|
warn(`[curator] skill revision check failed: ${revisionErr instanceof Error ? revisionErr.message : String(revisionErr)}`);
|
|
64508
64809
|
}
|
|
64509
|
-
const autoRetireObservations = await
|
|
64810
|
+
const autoRetireObservations = await _internals28.autoRetireSkills(directory, curatorKnowledgePath, revisedSlugs);
|
|
64510
64811
|
if (autoRetireObservations.length > 0) {
|
|
64511
64812
|
const retireNote = ` [${autoRetireObservations.length} skill(s) auto-retired]`;
|
|
64512
64813
|
phaseDigest.summary += retireNote;
|
|
@@ -64714,7 +65015,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
64714
65015
|
}
|
|
64715
65016
|
return { applied, skipped };
|
|
64716
65017
|
}
|
|
64717
|
-
var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000,
|
|
65018
|
+
var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000, _internals28;
|
|
64718
65019
|
var init_curator = __esm(() => {
|
|
64719
65020
|
init_event_bus();
|
|
64720
65021
|
init_schema();
|
|
@@ -64729,7 +65030,7 @@ var init_curator = __esm(() => {
|
|
|
64729
65030
|
init_knowledge_validator();
|
|
64730
65031
|
init_skill_usage_log();
|
|
64731
65032
|
init_utils2();
|
|
64732
|
-
|
|
65033
|
+
_internals28 = {
|
|
64733
65034
|
parseKnowledgeRecommendations,
|
|
64734
65035
|
readCuratorSummary,
|
|
64735
65036
|
writeCuratorSummary,
|
|
@@ -65575,7 +65876,7 @@ function rankSkillsForContext(skills, taskContext, directory) {
|
|
|
65575
65876
|
const results = [];
|
|
65576
65877
|
for (const skillPath of skills) {
|
|
65577
65878
|
const skillEntries = allEntries.filter((e) => e.skillPath === skillPath);
|
|
65578
|
-
const metadata2 =
|
|
65879
|
+
const metadata2 = _internals29.readSkillMetadata(skillPath, directory);
|
|
65579
65880
|
const score = computeSkillRelevanceScore(skillPath, taskContext, skillEntries, metadata2);
|
|
65580
65881
|
const entriesWithVerdict = skillEntries.filter((e) => e.complianceVerdict !== undefined && e.complianceVerdict !== "not_checked");
|
|
65581
65882
|
const compliantCount = entriesWithVerdict.filter((e) => e.complianceVerdict === "compliant").length;
|
|
@@ -65630,7 +65931,7 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
65630
65931
|
} catch {}
|
|
65631
65932
|
if (!hasHistory) {
|
|
65632
65933
|
return skills.map((sp) => {
|
|
65633
|
-
const meta3 =
|
|
65934
|
+
const meta3 = _internals29.readSkillMetadata(sp, directory);
|
|
65634
65935
|
return ` - file:${meta3.path} - ${meta3.name}: ${meta3.description}`;
|
|
65635
65936
|
}).join(`
|
|
65636
65937
|
`);
|
|
@@ -65638,7 +65939,7 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
65638
65939
|
const lines = [];
|
|
65639
65940
|
for (const skillPath of skills) {
|
|
65640
65941
|
const stats = getSkillStats(skillPath, directory);
|
|
65641
|
-
const meta3 =
|
|
65942
|
+
const meta3 = _internals29.readSkillMetadata(skillPath, directory);
|
|
65642
65943
|
const compliancePct = Math.round(stats.complianceRate * 100);
|
|
65643
65944
|
const topAgentNames = stats.topAgents.slice(0, 3).map((a) => a.agent).join(", ");
|
|
65644
65945
|
lines.push(` - file:${meta3.path} - ${meta3.name}: ${meta3.description} (used: ${stats.totalUsage}, compliance: ${compliancePct}%)` + (stats.topAgents.length > 0 ? ` → ${topAgentNames}` : ""));
|
|
@@ -65646,12 +65947,12 @@ function formatSkillIndexWithContext(skills, directory) {
|
|
|
65646
65947
|
return lines.join(`
|
|
65647
65948
|
`);
|
|
65648
65949
|
}
|
|
65649
|
-
var FREQUENCY_CAP = 10, FREQUENCY_WEIGHT = 0.3, COMPLIANCE_WEIGHT = 0.3, RECENCY_WEIGHT = 0.15, TASK_DIVERSITY_WEIGHT = 0.05, CONTEXT_WEIGHT = 0.2, WORKFLOW_BOOST = 0.1, SKILL_TRIGGER_BOOST = 0.3, SKILL_TRIGGER_MIN_LENGTH = 3, MAX_SKILL_TRIGGERS = 20, MAX_SKILL_TRIGGER_LENGTH = 120, WORKFLOW_BOOST_MIN_CONTEXT = 0.05, RECENCY_DECAY_MS, SKILL_FRONTMATTER_READ_BYTES,
|
|
65950
|
+
var FREQUENCY_CAP = 10, FREQUENCY_WEIGHT = 0.3, COMPLIANCE_WEIGHT = 0.3, RECENCY_WEIGHT = 0.15, TASK_DIVERSITY_WEIGHT = 0.05, CONTEXT_WEIGHT = 0.2, WORKFLOW_BOOST = 0.1, SKILL_TRIGGER_BOOST = 0.3, SKILL_TRIGGER_MIN_LENGTH = 3, MAX_SKILL_TRIGGERS = 20, MAX_SKILL_TRIGGER_LENGTH = 120, WORKFLOW_BOOST_MIN_CONTEXT = 0.05, RECENCY_DECAY_MS, SKILL_FRONTMATTER_READ_BYTES, _internals29, MIN_KEYWORD_LENGTH = 3;
|
|
65650
65951
|
var init_skill_scoring = __esm(() => {
|
|
65651
65952
|
init_skill_usage_log();
|
|
65652
65953
|
RECENCY_DECAY_MS = 30 * 24 * 60 * 60 * 1000;
|
|
65653
65954
|
SKILL_FRONTMATTER_READ_BYTES = 16 * 1024;
|
|
65654
|
-
|
|
65955
|
+
_internals29 = {
|
|
65655
65956
|
computeSkillRelevanceScore: null,
|
|
65656
65957
|
rankSkillsForContext: null,
|
|
65657
65958
|
getSkillStats: null,
|
|
@@ -65663,16 +65964,16 @@ var init_skill_scoring = __esm(() => {
|
|
|
65663
65964
|
computeContextMatchScore: null,
|
|
65664
65965
|
computeTriggerMatchBoost: null
|
|
65665
65966
|
};
|
|
65666
|
-
|
|
65667
|
-
|
|
65668
|
-
|
|
65669
|
-
|
|
65670
|
-
|
|
65671
|
-
|
|
65672
|
-
|
|
65673
|
-
|
|
65674
|
-
|
|
65675
|
-
|
|
65967
|
+
_internals29.computeSkillRelevanceScore = computeSkillRelevanceScore;
|
|
65968
|
+
_internals29.rankSkillsForContext = rankSkillsForContext;
|
|
65969
|
+
_internals29.getSkillStats = getSkillStats;
|
|
65970
|
+
_internals29.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
65971
|
+
_internals29.parseSkillFrontmatter = parseSkillFrontmatter;
|
|
65972
|
+
_internals29.readSkillMetadata = readSkillMetadata;
|
|
65973
|
+
_internals29.extractSkillName = extractSkillName;
|
|
65974
|
+
_internals29.computeRecencyScore = computeRecencyScore;
|
|
65975
|
+
_internals29.computeContextMatchScore = computeContextMatchScore;
|
|
65976
|
+
_internals29.computeTriggerMatchBoost = computeTriggerMatchBoost;
|
|
65676
65977
|
});
|
|
65677
65978
|
|
|
65678
65979
|
// src/hooks/skill-propagation-gate.ts
|
|
@@ -65777,10 +66078,10 @@ function parseYamlValue(value) {
|
|
|
65777
66078
|
}
|
|
65778
66079
|
function loadRoutingSkills(directory, targetAgent) {
|
|
65779
66080
|
const routingPath = path43.join(directory, ".opencode", "skill-routing.yaml");
|
|
65780
|
-
if (!
|
|
66081
|
+
if (!_internals30.existsSync(routingPath))
|
|
65781
66082
|
return [];
|
|
65782
66083
|
try {
|
|
65783
|
-
const content =
|
|
66084
|
+
const content = _internals30.readFileSync(routingPath, "utf-8");
|
|
65784
66085
|
const config3 = parseSimpleYaml(content);
|
|
65785
66086
|
if (!config3?.routing)
|
|
65786
66087
|
return [];
|
|
@@ -65797,11 +66098,11 @@ function discoverAvailableSkills(directory) {
|
|
|
65797
66098
|
const results = [];
|
|
65798
66099
|
for (const root of SKILL_SEARCH_ROOTS) {
|
|
65799
66100
|
const rootPath = path43.join(directory, root);
|
|
65800
|
-
if (!
|
|
66101
|
+
if (!_internals30.existsSync(rootPath))
|
|
65801
66102
|
continue;
|
|
65802
66103
|
let entries;
|
|
65803
66104
|
try {
|
|
65804
|
-
entries =
|
|
66105
|
+
entries = _internals30.readdirSync(rootPath);
|
|
65805
66106
|
} catch {
|
|
65806
66107
|
continue;
|
|
65807
66108
|
}
|
|
@@ -65809,11 +66110,11 @@ function discoverAvailableSkills(directory) {
|
|
|
65809
66110
|
if (entry.startsWith("."))
|
|
65810
66111
|
continue;
|
|
65811
66112
|
const skillDir = path43.join(rootPath, entry);
|
|
65812
|
-
if (
|
|
66113
|
+
if (_internals30.existsSync(path43.join(skillDir, "retired.marker")))
|
|
65813
66114
|
continue;
|
|
65814
66115
|
const skillFile = path43.join(skillDir, "SKILL.md");
|
|
65815
66116
|
try {
|
|
65816
|
-
if (
|
|
66117
|
+
if (_internals30.statSync(skillDir).isDirectory() && _internals30.existsSync(skillFile)) {
|
|
65817
66118
|
results.push(path43.join(root, entry, "SKILL.md").replace(/\\/g, "/"));
|
|
65818
66119
|
}
|
|
65819
66120
|
} catch (err2) {
|
|
@@ -65845,7 +66146,7 @@ function parseDelegationArgs(args2) {
|
|
|
65845
66146
|
}
|
|
65846
66147
|
if (!targetAgent)
|
|
65847
66148
|
return null;
|
|
65848
|
-
const skillsField = prompt ?
|
|
66149
|
+
const skillsField = prompt ? _internals30.extractSkillsFieldFromPrompt(prompt) : "";
|
|
65849
66150
|
return { targetAgent, skillsField };
|
|
65850
66151
|
}
|
|
65851
66152
|
function extractSkillsFieldFromPrompt(prompt) {
|
|
@@ -65886,10 +66187,10 @@ function writeWarnEvent(directory, record3) {
|
|
|
65886
66187
|
const filePath = path43.join(directory, ".swarm", "events.jsonl");
|
|
65887
66188
|
try {
|
|
65888
66189
|
const dir = path43.dirname(filePath);
|
|
65889
|
-
if (!
|
|
65890
|
-
|
|
66190
|
+
if (!_internals30.existsSync(dir)) {
|
|
66191
|
+
_internals30.mkdirSync(dir, { recursive: true });
|
|
65891
66192
|
}
|
|
65892
|
-
|
|
66193
|
+
_internals30.appendFileSync(filePath, `${JSON.stringify(record3)}
|
|
65893
66194
|
`, "utf-8");
|
|
65894
66195
|
} catch (err2) {
|
|
65895
66196
|
warn(`[skill-propagation-gate] failed to write warning event: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
@@ -65940,19 +66241,19 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65940
66241
|
const baseAgent = stripKnownSwarmPrefix(agentRaw);
|
|
65941
66242
|
if (baseAgent !== "architect")
|
|
65942
66243
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
65943
|
-
const parsed =
|
|
66244
|
+
const parsed = _internals30.parseDelegationArgs(input.args);
|
|
65944
66245
|
if (!parsed)
|
|
65945
66246
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
65946
66247
|
const targetBase = stripKnownSwarmPrefix(parsed.targetAgent);
|
|
65947
|
-
if (!
|
|
66248
|
+
if (!_internals30.SKILL_CAPABLE_AGENTS.has(targetBase))
|
|
65948
66249
|
return { blocked: false, reason: null, recommendedSkills: undefined };
|
|
65949
66250
|
const sessionID = typeof input.sessionID === "string" ? input.sessionID : "unknown";
|
|
65950
|
-
const availableSkills =
|
|
66251
|
+
const availableSkills = _internals30.discoverAvailableSkills(directory);
|
|
65951
66252
|
const skillsValue = parsed.skillsField.trim();
|
|
65952
66253
|
if (skillsValue && skillsValue.toLowerCase() !== "none") {
|
|
65953
66254
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
65954
|
-
const taskId =
|
|
65955
|
-
const skillPaths =
|
|
66255
|
+
const taskId = _internals30.extractTaskIdFromPrompt(prompt);
|
|
66256
|
+
const skillPaths = _internals30.parseSkillPaths(skillsValue);
|
|
65956
66257
|
let coderSkillPaths = [];
|
|
65957
66258
|
if (prompt) {
|
|
65958
66259
|
for (const line of prompt.split(`
|
|
@@ -65960,7 +66261,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65960
66261
|
const trimmed = line.trim();
|
|
65961
66262
|
if (trimmed.startsWith("SKILLS_USED_BY_CODER:")) {
|
|
65962
66263
|
const fieldVal = trimmed.slice("SKILLS_USED_BY_CODER:".length).trim();
|
|
65963
|
-
coderSkillPaths =
|
|
66264
|
+
coderSkillPaths = _internals30.parseSkillPaths(fieldVal);
|
|
65964
66265
|
break;
|
|
65965
66266
|
}
|
|
65966
66267
|
}
|
|
@@ -65968,7 +66269,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65968
66269
|
const allPaths = [...new Set([...skillPaths, ...coderSkillPaths])];
|
|
65969
66270
|
for (const skillPath of allPaths) {
|
|
65970
66271
|
try {
|
|
65971
|
-
|
|
66272
|
+
_internals30.appendSkillUsageEntry(directory, {
|
|
65972
66273
|
skillPath,
|
|
65973
66274
|
agentName: targetBase,
|
|
65974
66275
|
taskID: taskId,
|
|
@@ -65985,18 +66286,18 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
65985
66286
|
let scored = [];
|
|
65986
66287
|
if (skillsValue.toLowerCase() !== "none" && availableSkills.length > 0) {
|
|
65987
66288
|
try {
|
|
65988
|
-
const sessionEntries =
|
|
66289
|
+
const sessionEntries = _internals30.readSkillUsageEntriesTail(directory, {
|
|
65989
66290
|
sessionID
|
|
65990
66291
|
});
|
|
65991
|
-
if (sessionEntries.length >
|
|
66292
|
+
if (sessionEntries.length > _internals30.MAX_SCORING_SESSION_ENTRIES) {
|
|
65992
66293
|
scoringSkipped = true;
|
|
65993
|
-
warn(`[skill-propagation-gate] skipping scoring — tail window has ${sessionEntries.length} session entries (limit: ${
|
|
66294
|
+
warn(`[skill-propagation-gate] skipping scoring — tail window has ${sessionEntries.length} session entries (limit: ${_internals30.MAX_SCORING_SESSION_ENTRIES})`);
|
|
65994
66295
|
} else {
|
|
65995
66296
|
const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
|
|
65996
66297
|
scored = availableSkills.map((skillPath) => {
|
|
65997
66298
|
const skillEntries = sessionEntries.filter((e) => e.skillPath === skillPath);
|
|
65998
|
-
const metadata2 =
|
|
65999
|
-
const score =
|
|
66299
|
+
const metadata2 = _internals30.readSkillMetadata(skillPath, directory);
|
|
66300
|
+
const score = _internals30.computeSkillRelevanceScore(skillPath, prompt, skillEntries, metadata2);
|
|
66000
66301
|
return { skillPath, score, usageCount: skillEntries.length };
|
|
66001
66302
|
}).sort((a, b) => b.score - a.score || b.usageCount - a.usageCount);
|
|
66002
66303
|
if (scored.length > 0) {
|
|
@@ -66010,12 +66311,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
66010
66311
|
}
|
|
66011
66312
|
}
|
|
66012
66313
|
try {
|
|
66013
|
-
const routingPaths =
|
|
66314
|
+
const routingPaths = _internals30.loadRoutingSkills(directory, targetBase);
|
|
66014
66315
|
if (routingPaths.length > 0) {
|
|
66015
66316
|
const existingPaths = new Set(scored.map((s) => s.skillPath));
|
|
66016
66317
|
for (const routingPath of routingPaths) {
|
|
66017
66318
|
const routedSkillDir = path43.dirname(path43.join(directory, routingPath));
|
|
66018
|
-
if (
|
|
66319
|
+
if (_internals30.existsSync(path43.join(routedSkillDir, "retired.marker")))
|
|
66019
66320
|
continue;
|
|
66020
66321
|
if (!existingPaths.has(routingPath)) {
|
|
66021
66322
|
scored.push({
|
|
@@ -66041,12 +66342,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
|
|
|
66041
66342
|
} else if (typeof scored !== "undefined" && scored.length > 0) {
|
|
66042
66343
|
skillsForIndex = scored.map((r) => r.skillPath);
|
|
66043
66344
|
}
|
|
66044
|
-
const formattedIndex =
|
|
66345
|
+
const formattedIndex = _internals30.formatSkillIndexWithContext(skillsForIndex, directory);
|
|
66045
66346
|
if (formattedIndex.length > 0) {
|
|
66046
66347
|
const contextPath = path43.join(directory, ".swarm", "context.md");
|
|
66047
66348
|
let existingContent = "";
|
|
66048
|
-
if (
|
|
66049
|
-
existingContent =
|
|
66349
|
+
if (_internals30.existsSync(contextPath)) {
|
|
66350
|
+
existingContent = _internals30.readFileSync(contextPath, "utf-8");
|
|
66050
66351
|
}
|
|
66051
66352
|
const sectionHeader = "## Available Skills";
|
|
66052
66353
|
const newSection = `${sectionHeader}
|
|
@@ -66066,10 +66367,10 @@ ${newSection}`;
|
|
|
66066
66367
|
}
|
|
66067
66368
|
}
|
|
66068
66369
|
const swarmDir = path43.dirname(contextPath);
|
|
66069
|
-
if (!
|
|
66070
|
-
|
|
66370
|
+
if (!_internals30.existsSync(swarmDir)) {
|
|
66371
|
+
_internals30.mkdirSync(swarmDir, { recursive: true });
|
|
66071
66372
|
}
|
|
66072
|
-
|
|
66373
|
+
_internals30.writeFileSync(contextPath, updatedContent, "utf-8");
|
|
66073
66374
|
}
|
|
66074
66375
|
} catch (err2) {
|
|
66075
66376
|
warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
@@ -66095,7 +66396,7 @@ ${newSection}`;
|
|
|
66095
66396
|
});
|
|
66096
66397
|
const warningMsg = `Skill propagation warning: Delegating to ${targetBase} without SKILLS field. ` + `Available skills: ${skillNames.join(", ")}`;
|
|
66097
66398
|
try {
|
|
66098
|
-
|
|
66399
|
+
_internals30.writeWarnEvent(directory, {
|
|
66099
66400
|
type: "skill_propagation_warn",
|
|
66100
66401
|
timestamp: new Date().toISOString(),
|
|
66101
66402
|
tool: toolName,
|
|
@@ -66122,7 +66423,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66122
66423
|
let dedupKeys = new Set;
|
|
66123
66424
|
let existingEntries = [];
|
|
66124
66425
|
try {
|
|
66125
|
-
existingEntries =
|
|
66426
|
+
existingEntries = _internals30.readSkillUsageEntriesTail(directory, {
|
|
66126
66427
|
sessionID
|
|
66127
66428
|
});
|
|
66128
66429
|
dedupKeys = new Set(existingEntries.map((e, i2) => {
|
|
@@ -66160,7 +66461,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66160
66461
|
}
|
|
66161
66462
|
const coderMatch = trimmed.match(CODER_SKILLS_PATTERN);
|
|
66162
66463
|
if (coderMatch) {
|
|
66163
|
-
const parsed =
|
|
66464
|
+
const parsed = _internals30.parseSkillPaths(coderMatch[1]);
|
|
66164
66465
|
skillPaths.push(...parsed);
|
|
66165
66466
|
}
|
|
66166
66467
|
}
|
|
@@ -66193,7 +66494,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66193
66494
|
if (isDuplicate(skillPath, "reviewer", resolvedTaskID))
|
|
66194
66495
|
continue;
|
|
66195
66496
|
try {
|
|
66196
|
-
|
|
66497
|
+
_internals30.appendSkillUsageEntry(directory, {
|
|
66197
66498
|
skillPath,
|
|
66198
66499
|
agentName: "reviewer",
|
|
66199
66500
|
taskID: resolvedTaskID,
|
|
@@ -66237,15 +66538,15 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66237
66538
|
skillsField = trimmed.slice("SKILLS:".length).trim();
|
|
66238
66539
|
}
|
|
66239
66540
|
if (currentTargetAgent && skillsField && skillsField.toLowerCase() !== "none") {
|
|
66240
|
-
const skillPaths =
|
|
66241
|
-
const taskId =
|
|
66541
|
+
const skillPaths = _internals30.parseSkillPaths(skillsField);
|
|
66542
|
+
const taskId = _internals30.extractTaskIdFromPrompt(text);
|
|
66242
66543
|
for (const skillPath of skillPaths) {
|
|
66243
66544
|
if (hadRecordingError)
|
|
66244
66545
|
break;
|
|
66245
66546
|
if (isDuplicate(skillPath, currentTargetAgent, taskId))
|
|
66246
66547
|
continue;
|
|
66247
66548
|
try {
|
|
66248
|
-
|
|
66549
|
+
_internals30.appendSkillUsageEntry(directory, {
|
|
66249
66550
|
skillPath,
|
|
66250
66551
|
agentName: currentTargetAgent,
|
|
66251
66552
|
taskID: taskId,
|
|
@@ -66265,7 +66566,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
|
|
|
66265
66566
|
break;
|
|
66266
66567
|
}
|
|
66267
66568
|
}
|
|
66268
|
-
var SKILL_CAPABLE_AGENTS, SKILL_SEARCH_ROOTS, MAX_SCORING_SESSION_ENTRIES = 500,
|
|
66569
|
+
var SKILL_CAPABLE_AGENTS, SKILL_SEARCH_ROOTS, MAX_SCORING_SESSION_ENTRIES = 500, _internals30, COMPLIANCE_PATTERN, CODER_SKILLS_PATTERN, REVIEWER_TASK_PATTERN;
|
|
66269
66570
|
var init_skill_propagation_gate = __esm(() => {
|
|
66270
66571
|
init_schema();
|
|
66271
66572
|
init_logger();
|
|
@@ -66284,7 +66585,7 @@ var init_skill_propagation_gate = __esm(() => {
|
|
|
66284
66585
|
".opencode/skills/generated",
|
|
66285
66586
|
".claude/skills"
|
|
66286
66587
|
];
|
|
66287
|
-
|
|
66588
|
+
_internals30 = {
|
|
66288
66589
|
readdirSync: fs22.readdirSync.bind(fs22),
|
|
66289
66590
|
existsSync: fs22.existsSync.bind(fs22),
|
|
66290
66591
|
statSync: fs22.statSync.bind(fs22),
|
|
@@ -66313,16 +66614,16 @@ var init_skill_propagation_gate = __esm(() => {
|
|
|
66313
66614
|
COMPLIANCE_PATTERN = /SKILL_COMPLIANCE\s*:\s*(COMPLIANT|PARTIAL|VIOLATED)(?:\s*(?:—|-)\s*(.*))?\s*$/i;
|
|
66314
66615
|
CODER_SKILLS_PATTERN = /SKILLS_USED_BY_CODER\s*:\s*(.+)/i;
|
|
66315
66616
|
REVIEWER_TASK_PATTERN = /TASK\s*:\s*(\S+)/i;
|
|
66316
|
-
|
|
66317
|
-
|
|
66318
|
-
|
|
66319
|
-
|
|
66320
|
-
|
|
66321
|
-
|
|
66322
|
-
|
|
66323
|
-
|
|
66324
|
-
|
|
66325
|
-
|
|
66617
|
+
_internals30.skillPropagationGateBefore = skillPropagationGateBefore;
|
|
66618
|
+
_internals30.skillPropagationTransformScan = skillPropagationTransformScan;
|
|
66619
|
+
_internals30.writeWarnEvent = writeWarnEvent;
|
|
66620
|
+
_internals30.discoverAvailableSkills = discoverAvailableSkills;
|
|
66621
|
+
_internals30.parseDelegationArgs = parseDelegationArgs;
|
|
66622
|
+
_internals30.parseSkillPaths = parseSkillPaths;
|
|
66623
|
+
_internals30.extractTaskIdFromPrompt = extractTaskIdFromPrompt;
|
|
66624
|
+
_internals30.extractSkillsFieldFromPrompt = extractSkillsFieldFromPrompt;
|
|
66625
|
+
_internals30.formatSkillIndexWithContext = formatSkillIndexWithContext;
|
|
66626
|
+
_internals30.loadRoutingSkills = loadRoutingSkills;
|
|
66326
66627
|
});
|
|
66327
66628
|
|
|
66328
66629
|
// src/hooks/micro-reflector.ts
|
|
@@ -67154,7 +67455,7 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
67154
67455
|
} catch {}
|
|
67155
67456
|
}
|
|
67156
67457
|
if (!options?.skipAutoPromotion) {
|
|
67157
|
-
await
|
|
67458
|
+
await _internals31.runAutoPromotion(directory, config3);
|
|
67158
67459
|
}
|
|
67159
67460
|
return { stored, reinforced, skipped, rejected, quarantined };
|
|
67160
67461
|
}
|
|
@@ -67237,7 +67538,7 @@ function createKnowledgeCuratorHook(directory, config3, options = {}) {
|
|
|
67237
67538
|
recordSeenRetroSection(evidenceKey, evidenceHash, Date.now());
|
|
67238
67539
|
const projectName2 = evidenceData.project_name ?? "unknown";
|
|
67239
67540
|
const phaseNumber2 = typeof evidenceData.phase_number === "number" ? evidenceData.phase_number : 1;
|
|
67240
|
-
await
|
|
67541
|
+
await _internals31.curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3, {
|
|
67241
67542
|
llmDelegate: options.llmDelegateFactory?.(sessionID),
|
|
67242
67543
|
enrichmentQuota: options.enrichmentQuota
|
|
67243
67544
|
});
|
|
@@ -67262,14 +67563,14 @@ function createKnowledgeCuratorHook(directory, config3, options = {}) {
|
|
|
67262
67563
|
const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
|
|
67263
67564
|
const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
|
|
67264
67565
|
const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
|
|
67265
|
-
await
|
|
67566
|
+
await _internals31.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3, {
|
|
67266
67567
|
llmDelegate: options.llmDelegateFactory?.(sessionID),
|
|
67267
67568
|
enrichmentQuota: options.enrichmentQuota
|
|
67268
67569
|
});
|
|
67269
67570
|
};
|
|
67270
67571
|
return safeHook(handler);
|
|
67271
67572
|
}
|
|
67272
|
-
var seenRetroSections, MAX_TRACKED_RETRO_SECTIONS = 500, ENRICHMENT_ALLOWED_FIELDS, ENRICHMENT_LLM_TIMEOUT_MS = 60000, MESO_INSIGHT_BATCH_LIMIT = 20, KNOWLEDGE_CATEGORIES, OUTCOME_PROMOTION_BLOCK = -0.3,
|
|
67573
|
+
var seenRetroSections, MAX_TRACKED_RETRO_SECTIONS = 500, ENRICHMENT_ALLOWED_FIELDS, ENRICHMENT_LLM_TIMEOUT_MS = 60000, MESO_INSIGHT_BATCH_LIMIT = 20, KNOWLEDGE_CATEGORIES, OUTCOME_PROMOTION_BLOCK = -0.3, _internals31;
|
|
67273
67574
|
var init_knowledge_curator = __esm(() => {
|
|
67274
67575
|
init_skill_improver_quota();
|
|
67275
67576
|
init_synonym_map();
|
|
@@ -67302,7 +67603,7 @@ var init_knowledge_curator = __esm(() => {
|
|
|
67302
67603
|
"todo",
|
|
67303
67604
|
"other"
|
|
67304
67605
|
]);
|
|
67305
|
-
|
|
67606
|
+
_internals31 = {
|
|
67306
67607
|
isWriteToEvidenceFile,
|
|
67307
67608
|
curateAndStoreSwarm,
|
|
67308
67609
|
runAutoPromotion,
|
|
@@ -68550,7 +68851,7 @@ async function executeWriteRetro(args2, directory) {
|
|
|
68550
68851
|
}, null, 2);
|
|
68551
68852
|
}
|
|
68552
68853
|
}
|
|
68553
|
-
var write_retro,
|
|
68854
|
+
var write_retro, _internals32;
|
|
68554
68855
|
var init_write_retro = __esm(() => {
|
|
68555
68856
|
init_zod();
|
|
68556
68857
|
init_evidence_schema();
|
|
@@ -68597,13 +68898,13 @@ var init_write_retro = __esm(() => {
|
|
|
68597
68898
|
task_id: args2.task_id !== undefined ? String(args2.task_id) : undefined,
|
|
68598
68899
|
metadata: args2.metadata
|
|
68599
68900
|
};
|
|
68600
|
-
return await
|
|
68901
|
+
return await _internals32.executeWriteRetro(writeRetroArgs, directory);
|
|
68601
68902
|
} catch {
|
|
68602
68903
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
68603
68904
|
}
|
|
68604
68905
|
}
|
|
68605
68906
|
});
|
|
68606
|
-
|
|
68907
|
+
_internals32 = {
|
|
68607
68908
|
executeWriteRetro,
|
|
68608
68909
|
write_retro
|
|
68609
68910
|
};
|
|
@@ -68613,7 +68914,7 @@ var init_write_retro = __esm(() => {
|
|
|
68613
68914
|
var exports_curator_postmortem = {};
|
|
68614
68915
|
__export(exports_curator_postmortem, {
|
|
68615
68916
|
runCuratorPostMortem: () => runCuratorPostMortem,
|
|
68616
|
-
_internals: () =>
|
|
68917
|
+
_internals: () => _internals33
|
|
68617
68918
|
});
|
|
68618
68919
|
import { existsSync as existsSync26, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "node:fs";
|
|
68619
68920
|
import * as path48 from "node:path";
|
|
@@ -68967,13 +69268,13 @@ ${llmOutput}`;
|
|
|
68967
69268
|
warnings
|
|
68968
69269
|
};
|
|
68969
69270
|
}
|
|
68970
|
-
var
|
|
69271
|
+
var _internals33;
|
|
68971
69272
|
var init_curator_postmortem = __esm(() => {
|
|
68972
69273
|
init_manager();
|
|
68973
69274
|
init_knowledge_events();
|
|
68974
69275
|
init_knowledge_store();
|
|
68975
69276
|
init_utils2();
|
|
68976
|
-
|
|
69277
|
+
_internals33 = {
|
|
68977
69278
|
collectKnowledgeSummary,
|
|
68978
69279
|
collectRetrospectives,
|
|
68979
69280
|
collectDriftReports,
|
|
@@ -69978,7 +70279,7 @@ __export(exports_skill_consolidation, {
|
|
|
69978
70279
|
runSkillConsolidationFireAndForget: () => runSkillConsolidationFireAndForget,
|
|
69979
70280
|
runSkillConsolidation: () => runSkillConsolidation,
|
|
69980
70281
|
consolidationStatePath: () => consolidationStatePath,
|
|
69981
|
-
_internals: () =>
|
|
70282
|
+
_internals: () => _internals34
|
|
69982
70283
|
});
|
|
69983
70284
|
import { existsSync as existsSync27 } from "node:fs";
|
|
69984
70285
|
import { mkdir as mkdir15, readFile as readFile15, rename as rename9, writeFile as writeFile13 } from "node:fs/promises";
|
|
@@ -70102,12 +70403,12 @@ function runSkillConsolidationFireAndForget(req, onComplete, onError) {
|
|
|
70102
70403
|
runSkillConsolidation(req).then(onComplete).catch(onError);
|
|
70103
70404
|
});
|
|
70104
70405
|
}
|
|
70105
|
-
var DEFAULT_CONSOLIDATION_INTERVAL_HOURS = 24, DEFAULT_CONSOLIDATION_MAX_CALLS_PER_RUN = 1, CONSOLIDATION_RUN_TIMEOUT_MS, runningByDirectory,
|
|
70406
|
+
var DEFAULT_CONSOLIDATION_INTERVAL_HOURS = 24, DEFAULT_CONSOLIDATION_MAX_CALLS_PER_RUN = 1, CONSOLIDATION_RUN_TIMEOUT_MS, runningByDirectory, _internals34;
|
|
70106
70407
|
var init_skill_consolidation = __esm(() => {
|
|
70107
70408
|
init_skill_improver();
|
|
70108
70409
|
CONSOLIDATION_RUN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
70109
70410
|
runningByDirectory = new Map;
|
|
70110
|
-
|
|
70411
|
+
_internals34 = {
|
|
70111
70412
|
readState: readState2,
|
|
70112
70413
|
writeState: writeState2,
|
|
70113
70414
|
intervalElapsed,
|
|
@@ -70297,7 +70598,7 @@ __export(exports_co_change_analyzer, {
|
|
|
70297
70598
|
darkMatterToKnowledgeEntries: () => darkMatterToKnowledgeEntries,
|
|
70298
70599
|
co_change_analyzer: () => co_change_analyzer,
|
|
70299
70600
|
buildCoChangeMatrix: () => buildCoChangeMatrix,
|
|
70300
|
-
_internals: () =>
|
|
70601
|
+
_internals: () => _internals35
|
|
70301
70602
|
});
|
|
70302
70603
|
import * as child_process3 from "node:child_process";
|
|
70303
70604
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -70523,9 +70824,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
70523
70824
|
} catch {
|
|
70524
70825
|
return [];
|
|
70525
70826
|
}
|
|
70526
|
-
const commitMap = await
|
|
70527
|
-
const matrix =
|
|
70528
|
-
const staticEdges = await
|
|
70827
|
+
const commitMap = await _internals35.parseGitLog(directory, maxCommitsToAnalyze);
|
|
70828
|
+
const matrix = _internals35.buildCoChangeMatrix(commitMap, maxFilesPerCommit);
|
|
70829
|
+
const staticEdges = await _internals35.getStaticEdges(directory);
|
|
70529
70830
|
const results = [];
|
|
70530
70831
|
for (const entry of matrix.values()) {
|
|
70531
70832
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -70613,7 +70914,7 @@ ${rows}
|
|
|
70613
70914
|
These pairs likely share an architectural concern invisible to static analysis.
|
|
70614
70915
|
Consider adding explicit documentation or extracting the shared concern.`;
|
|
70615
70916
|
}
|
|
70616
|
-
var co_change_analyzer,
|
|
70917
|
+
var co_change_analyzer, _internals35;
|
|
70617
70918
|
var init_co_change_analyzer = __esm(() => {
|
|
70618
70919
|
init_zod();
|
|
70619
70920
|
init_create_tool();
|
|
@@ -70645,11 +70946,11 @@ var init_co_change_analyzer = __esm(() => {
|
|
|
70645
70946
|
npmiThreshold,
|
|
70646
70947
|
maxCommitsToAnalyze
|
|
70647
70948
|
};
|
|
70648
|
-
const pairs = await
|
|
70649
|
-
return
|
|
70949
|
+
const pairs = await _internals35.detectDarkMatter(directory, options);
|
|
70950
|
+
return _internals35.formatDarkMatterOutput(pairs);
|
|
70650
70951
|
}
|
|
70651
70952
|
});
|
|
70652
|
-
|
|
70953
|
+
_internals35 = {
|
|
70653
70954
|
parseGitLog,
|
|
70654
70955
|
buildCoChangeMatrix,
|
|
70655
70956
|
getStaticEdges,
|
|
@@ -70680,7 +70981,7 @@ async function handleDarkMatterCommand(directory, args2) {
|
|
|
70680
70981
|
}
|
|
70681
70982
|
let pairs;
|
|
70682
70983
|
try {
|
|
70683
|
-
pairs = await
|
|
70984
|
+
pairs = await _internals35.detectDarkMatter(directory, options);
|
|
70684
70985
|
} catch (err2) {
|
|
70685
70986
|
const errMsg = err2 instanceof Error ? err2.message : String(err2);
|
|
70686
70987
|
return `## Dark Matter Analysis Failed
|
|
@@ -74716,7 +75017,7 @@ function isCommandAvailable(command) {
|
|
|
74716
75017
|
const isWindows = process.platform === "win32";
|
|
74717
75018
|
const cmd = isWindows ? `${command}.exe` : command;
|
|
74718
75019
|
try {
|
|
74719
|
-
const result =
|
|
75020
|
+
const result = _internals36.spawnSyncImpl(isWindows ? ["where", cmd] : ["which", cmd], {
|
|
74720
75021
|
cwd: process.cwd(),
|
|
74721
75022
|
stdin: "ignore",
|
|
74722
75023
|
stdout: "ignore",
|
|
@@ -74866,7 +75167,7 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
74866
75167
|
const scope = options?.scope ?? "all";
|
|
74867
75168
|
const changedFiles = options?.changedFiles ?? [];
|
|
74868
75169
|
const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
|
|
74869
|
-
const profileResult = await
|
|
75170
|
+
const profileResult = await _internals36.discoverBuildCommandsFromProfiles(workingDir);
|
|
74870
75171
|
const profileCommands = profileResult.commands;
|
|
74871
75172
|
const profileSkipped = profileResult.skipped;
|
|
74872
75173
|
const coveredEcosystems = new Set;
|
|
@@ -74929,7 +75230,7 @@ function clearToolchainCache() {
|
|
|
74929
75230
|
function getEcosystems() {
|
|
74930
75231
|
return ECOSYSTEMS.map((e) => e.ecosystem);
|
|
74931
75232
|
}
|
|
74932
|
-
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, IS_COMMAND_AVAILABLE_TIMEOUT_MS = 3000,
|
|
75233
|
+
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, IS_COMMAND_AVAILABLE_TIMEOUT_MS = 3000, _internals36, build_discovery;
|
|
74933
75234
|
var init_discovery = __esm(() => {
|
|
74934
75235
|
init_dist();
|
|
74935
75236
|
init_detector();
|
|
@@ -75047,7 +75348,7 @@ var init_discovery = __esm(() => {
|
|
|
75047
75348
|
php: ["php-composer"]
|
|
75048
75349
|
};
|
|
75049
75350
|
toolchainCache = new Map;
|
|
75050
|
-
|
|
75351
|
+
_internals36 = {
|
|
75051
75352
|
isCommandAvailable,
|
|
75052
75353
|
discoverBuildCommandsFromProfiles,
|
|
75053
75354
|
discoverBuildCommands,
|
|
@@ -75344,7 +75645,7 @@ var exports_evidence_summary_service = {};
|
|
|
75344
75645
|
__export(exports_evidence_summary_service, {
|
|
75345
75646
|
isAutoSummaryEnabled: () => isAutoSummaryEnabled,
|
|
75346
75647
|
buildEvidenceSummary: () => buildEvidenceSummary,
|
|
75347
|
-
_internals: () =>
|
|
75648
|
+
_internals: () => _internals37,
|
|
75348
75649
|
REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
|
|
75349
75650
|
EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
|
|
75350
75651
|
});
|
|
@@ -75382,7 +75683,7 @@ function getTaskStatus(task, bundle) {
|
|
|
75382
75683
|
if (task?.status) {
|
|
75383
75684
|
return task.status;
|
|
75384
75685
|
}
|
|
75385
|
-
const entries =
|
|
75686
|
+
const entries = _internals37.normalizeBundleEntries(bundle);
|
|
75386
75687
|
if (entries.length > 0) {
|
|
75387
75688
|
return "completed";
|
|
75388
75689
|
}
|
|
@@ -75408,7 +75709,7 @@ function evidenceCompleteFromEntries(entries) {
|
|
|
75408
75709
|
};
|
|
75409
75710
|
}
|
|
75410
75711
|
function isEvidenceComplete(bundle) {
|
|
75411
|
-
return evidenceCompleteFromEntries(
|
|
75712
|
+
return evidenceCompleteFromEntries(_internals37.normalizeBundleEntries(bundle));
|
|
75412
75713
|
}
|
|
75413
75714
|
function getTaskBlockers(task, summary, status) {
|
|
75414
75715
|
const blockers = [];
|
|
@@ -75428,9 +75729,9 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
75428
75729
|
const bundle = result.status === "found" ? result.bundle : null;
|
|
75429
75730
|
const gateEvidence = await readDurableGateEvidence(directory, taskId);
|
|
75430
75731
|
const phase = task?.phase ?? 0;
|
|
75431
|
-
const status =
|
|
75432
|
-
const entries = mergeDurableGateEntriesFromEvidence(taskId,
|
|
75433
|
-
let evidenceCheck =
|
|
75732
|
+
const status = _internals37.getTaskStatus(task, bundle);
|
|
75733
|
+
const entries = mergeDurableGateEntriesFromEvidence(taskId, _internals37.normalizeBundleEntries(bundle), gateEvidence);
|
|
75734
|
+
let evidenceCheck = _internals37.evidenceCompleteFromEntries(entries);
|
|
75434
75735
|
if (gateEvidence) {
|
|
75435
75736
|
const gateStatus = getDurableGateEvidenceStatus(gateEvidence);
|
|
75436
75737
|
evidenceCheck = gateStatus.isComplete ? { isComplete: true, missingEvidence: [] } : {
|
|
@@ -75438,7 +75739,7 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
75438
75739
|
missingEvidence: gateStatus.missingGates.map((gate) => `gate:${gate}`)
|
|
75439
75740
|
};
|
|
75440
75741
|
}
|
|
75441
|
-
const blockers =
|
|
75742
|
+
const blockers = _internals37.getTaskBlockers(task, evidenceCheck, status);
|
|
75442
75743
|
const hasReview = entries.some((e) => e.type === "review");
|
|
75443
75744
|
const hasTest = entries.some((e) => e.type === "test");
|
|
75444
75745
|
const hasApproval = entries.some((e) => e.type === "approval");
|
|
@@ -75467,12 +75768,12 @@ async function buildPhaseSummary(directory, phase) {
|
|
|
75467
75768
|
const taskSummaries = [];
|
|
75468
75769
|
const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
|
|
75469
75770
|
for (const task of phase.tasks) {
|
|
75470
|
-
const summary = await
|
|
75771
|
+
const summary = await _internals37.buildTaskSummary(directory, task, task.id);
|
|
75471
75772
|
taskSummaries.push(summary);
|
|
75472
75773
|
}
|
|
75473
75774
|
const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
|
|
75474
75775
|
for (const taskId of extraTaskIds) {
|
|
75475
|
-
const summary = await
|
|
75776
|
+
const summary = await _internals37.buildTaskSummary(directory, undefined, taskId);
|
|
75476
75777
|
if (summary.phase === phase.id) {
|
|
75477
75778
|
taskSummaries.push(summary);
|
|
75478
75779
|
}
|
|
@@ -75573,7 +75874,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
75573
75874
|
let totalTasks = 0;
|
|
75574
75875
|
let completedTasks = 0;
|
|
75575
75876
|
for (const phase of phasesToProcess) {
|
|
75576
|
-
const summary = await
|
|
75877
|
+
const summary = await _internals37.buildPhaseSummary(directory, phase);
|
|
75577
75878
|
phaseSummaries.push(summary);
|
|
75578
75879
|
totalTasks += summary.totalTasks;
|
|
75579
75880
|
completedTasks += summary.completedTasks;
|
|
@@ -75595,7 +75896,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
75595
75896
|
overallBlockers,
|
|
75596
75897
|
summaryText: ""
|
|
75597
75898
|
};
|
|
75598
|
-
artifact.summaryText =
|
|
75899
|
+
artifact.summaryText = _internals37.generateSummaryText(artifact);
|
|
75599
75900
|
log("[EvidenceSummary] Summary built", {
|
|
75600
75901
|
phases: phaseSummaries.length,
|
|
75601
75902
|
totalTasks,
|
|
@@ -75614,7 +75915,7 @@ function isAutoSummaryEnabled(automationConfig) {
|
|
|
75614
75915
|
}
|
|
75615
75916
|
return automationConfig.capabilities?.evidence_auto_summaries === true;
|
|
75616
75917
|
}
|
|
75617
|
-
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0",
|
|
75918
|
+
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0", _internals37;
|
|
75618
75919
|
var init_evidence_summary_service = __esm(() => {
|
|
75619
75920
|
init_gate_bridge();
|
|
75620
75921
|
init_manager2();
|
|
@@ -75629,7 +75930,7 @@ var init_evidence_summary_service = __esm(() => {
|
|
|
75629
75930
|
"retrospective"
|
|
75630
75931
|
]);
|
|
75631
75932
|
REQUIRED_EVIDENCE_TYPES = ["review", "test"];
|
|
75632
|
-
|
|
75933
|
+
_internals37 = {
|
|
75633
75934
|
buildEvidenceSummary,
|
|
75634
75935
|
isAutoSummaryEnabled,
|
|
75635
75936
|
normalizeBundleEntries,
|
|
@@ -75685,7 +75986,7 @@ function getVerdictEmoji(verdict) {
|
|
|
75685
75986
|
return getVerdictIcon(verdict);
|
|
75686
75987
|
}
|
|
75687
75988
|
async function getTaskEvidenceData(directory, taskId) {
|
|
75688
|
-
const result = await
|
|
75989
|
+
const result = await _internals38.loadEvidence(directory, taskId);
|
|
75689
75990
|
if (result.status !== "found") {
|
|
75690
75991
|
return {
|
|
75691
75992
|
hasEvidence: false,
|
|
@@ -75708,13 +76009,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
75708
76009
|
};
|
|
75709
76010
|
}
|
|
75710
76011
|
async function getEvidenceListData(directory) {
|
|
75711
|
-
const taskIds = await
|
|
76012
|
+
const taskIds = await _internals38.listEvidenceTaskIds(directory);
|
|
75712
76013
|
if (taskIds.length === 0) {
|
|
75713
76014
|
return { hasEvidence: false, tasks: [] };
|
|
75714
76015
|
}
|
|
75715
76016
|
const tasks = [];
|
|
75716
76017
|
for (const taskId of taskIds) {
|
|
75717
|
-
const result = await
|
|
76018
|
+
const result = await _internals38.loadEvidence(directory, taskId);
|
|
75718
76019
|
if (result.status === "found") {
|
|
75719
76020
|
tasks.push({
|
|
75720
76021
|
taskId,
|
|
@@ -75828,10 +76129,10 @@ async function handleEvidenceSummaryCommand(directory) {
|
|
|
75828
76129
|
return lines.join(`
|
|
75829
76130
|
`);
|
|
75830
76131
|
}
|
|
75831
|
-
var
|
|
76132
|
+
var _internals38;
|
|
75832
76133
|
var init_evidence_service = __esm(() => {
|
|
75833
76134
|
init_manager2();
|
|
75834
|
-
|
|
76135
|
+
_internals38 = {
|
|
75835
76136
|
loadEvidence,
|
|
75836
76137
|
listEvidenceTaskIds
|
|
75837
76138
|
};
|
|
@@ -76480,7 +76781,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
76480
76781
|
if (!plan) {
|
|
76481
76782
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
76482
76783
|
}
|
|
76483
|
-
if (!
|
|
76784
|
+
if (!_internals39.validatePlanPhases(plan)) {
|
|
76484
76785
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
76485
76786
|
}
|
|
76486
76787
|
let currentPhase = null;
|
|
@@ -76622,9 +76923,9 @@ function extractPhaseMetrics(content) {
|
|
|
76622
76923
|
async function getHandoffData(directory) {
|
|
76623
76924
|
const now = new Date().toISOString();
|
|
76624
76925
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
76625
|
-
const sessionState =
|
|
76926
|
+
const sessionState = _internals39.parseSessionState(sessionContent);
|
|
76626
76927
|
const plan = await loadPlanJsonOnly(directory);
|
|
76627
|
-
const planInfo =
|
|
76928
|
+
const planInfo = _internals39.extractCurrentPhaseFromPlan(plan);
|
|
76628
76929
|
if (!plan) {
|
|
76629
76930
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
76630
76931
|
if (planMdContent) {
|
|
@@ -76643,8 +76944,8 @@ async function getHandoffData(directory) {
|
|
|
76643
76944
|
}
|
|
76644
76945
|
}
|
|
76645
76946
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
76646
|
-
const recentDecisions =
|
|
76647
|
-
const rawPhaseMetrics =
|
|
76947
|
+
const recentDecisions = _internals39.extractDecisions(contextContent);
|
|
76948
|
+
const rawPhaseMetrics = _internals39.extractPhaseMetrics(contextContent);
|
|
76648
76949
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
76649
76950
|
let delegationState = null;
|
|
76650
76951
|
if (sessionState?.delegationState) {
|
|
@@ -76808,13 +77109,13 @@ ${lines.join(`
|
|
|
76808
77109
|
`)}
|
|
76809
77110
|
\`\`\``;
|
|
76810
77111
|
}
|
|
76811
|
-
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20,
|
|
77112
|
+
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20, _internals39;
|
|
76812
77113
|
var init_handoff_service = __esm(() => {
|
|
76813
77114
|
init_utils2();
|
|
76814
77115
|
init_manager();
|
|
76815
77116
|
init_utils();
|
|
76816
77117
|
RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
|
|
76817
|
-
|
|
77118
|
+
_internals39 = {
|
|
76818
77119
|
getHandoffData,
|
|
76819
77120
|
formatHandoffMarkdown,
|
|
76820
77121
|
formatContinuationPrompt,
|
|
@@ -76957,22 +77258,22 @@ async function writeSnapshot(directory, state) {
|
|
|
76957
77258
|
}
|
|
76958
77259
|
function createSnapshotWriterHook(directory) {
|
|
76959
77260
|
return (_input, _output) => {
|
|
76960
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
77261
|
+
_writeInFlight = _writeInFlight.then(() => _internals40.writeSnapshot(directory, swarmState), () => _internals40.writeSnapshot(directory, swarmState));
|
|
76961
77262
|
return _writeInFlight;
|
|
76962
77263
|
};
|
|
76963
77264
|
}
|
|
76964
77265
|
async function flushPendingSnapshot(directory) {
|
|
76965
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
77266
|
+
_writeInFlight = _writeInFlight.then(() => _internals40.writeSnapshot(directory, swarmState), () => _internals40.writeSnapshot(directory, swarmState));
|
|
76966
77267
|
await _writeInFlight;
|
|
76967
77268
|
}
|
|
76968
|
-
var _writeInFlight,
|
|
77269
|
+
var _writeInFlight, _internals40;
|
|
76969
77270
|
var init_snapshot_writer = __esm(() => {
|
|
76970
77271
|
init_utils2();
|
|
76971
77272
|
init_state();
|
|
76972
77273
|
init_utils();
|
|
76973
77274
|
init_bun_compat();
|
|
76974
77275
|
_writeInFlight = Promise.resolve();
|
|
76975
|
-
|
|
77276
|
+
_internals40 = {
|
|
76976
77277
|
writeSnapshot,
|
|
76977
77278
|
createSnapshotWriterHook,
|
|
76978
77279
|
flushPendingSnapshot
|
|
@@ -77292,7 +77593,7 @@ function validateAndSanitizeGithubUrl(rawUrl, resource) {
|
|
|
77292
77593
|
}
|
|
77293
77594
|
function detectGitRemote(cwd) {
|
|
77294
77595
|
try {
|
|
77295
|
-
const result =
|
|
77596
|
+
const result = _internals41.spawnSync("git", ["remote", "get-url", "origin"], {
|
|
77296
77597
|
encoding: "utf-8",
|
|
77297
77598
|
stdio: ["ignore", "pipe", "pipe"],
|
|
77298
77599
|
timeout: 5000,
|
|
@@ -77337,7 +77638,7 @@ function parseGitRemoteUrl(remoteUrl) {
|
|
|
77337
77638
|
}
|
|
77338
77639
|
return null;
|
|
77339
77640
|
}
|
|
77340
|
-
var MAX_URL_LEN = 2048, IPV4_PRIVATE, IPV4_LOOPBACK, IPV4_LINK_LOCAL, IPV4_PRIVATE_172, IPV4_PRIVATE_192, IPV4_ZERO_NETWORK, IPV6_LINK_LOCAL, IPV6_UNIQUE_LOCAL,
|
|
77641
|
+
var MAX_URL_LEN = 2048, IPV4_PRIVATE, IPV4_LOOPBACK, IPV4_LINK_LOCAL, IPV4_PRIVATE_172, IPV4_PRIVATE_192, IPV4_ZERO_NETWORK, IPV6_LINK_LOCAL, IPV6_UNIQUE_LOCAL, _internals41;
|
|
77341
77642
|
var init_url_security = __esm(() => {
|
|
77342
77643
|
IPV4_PRIVATE = /^10\./;
|
|
77343
77644
|
IPV4_LOOPBACK = /^127\./;
|
|
@@ -77347,7 +77648,7 @@ var init_url_security = __esm(() => {
|
|
|
77347
77648
|
IPV4_ZERO_NETWORK = /^0\./;
|
|
77348
77649
|
IPV6_LINK_LOCAL = /^fe80:/i;
|
|
77349
77650
|
IPV6_UNIQUE_LOCAL = /^f[cd][0-9a-f]{2}:/i;
|
|
77350
|
-
|
|
77651
|
+
_internals41 = { spawnSync: spawnSync8 };
|
|
77351
77652
|
});
|
|
77352
77653
|
|
|
77353
77654
|
// src/commands/issue.ts
|
|
@@ -77521,9 +77822,9 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77521
77822
|
skippedReason: "empty-context"
|
|
77522
77823
|
};
|
|
77523
77824
|
}
|
|
77524
|
-
const rawEntries =
|
|
77825
|
+
const rawEntries = _internals42.parseContextMd(contextContent);
|
|
77525
77826
|
if (rawEntries.length === 0) {
|
|
77526
|
-
await
|
|
77827
|
+
await _internals42.writeSentinel(sentinelPath, 0, 0);
|
|
77527
77828
|
return {
|
|
77528
77829
|
migrated: true,
|
|
77529
77830
|
entriesMigrated: 0,
|
|
@@ -77534,10 +77835,10 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77534
77835
|
const existing = await readKnowledge(knowledgePath);
|
|
77535
77836
|
let migrated = 0;
|
|
77536
77837
|
let dropped = 0;
|
|
77537
|
-
const projectName =
|
|
77838
|
+
const projectName = _internals42.inferProjectName(directory);
|
|
77538
77839
|
for (const raw of rawEntries) {
|
|
77539
77840
|
if (config3.validation_enabled !== false) {
|
|
77540
|
-
const category = raw.categoryHint ??
|
|
77841
|
+
const category = raw.categoryHint ?? _internals42.inferCategoryFromText(raw.text);
|
|
77541
77842
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
77542
77843
|
category,
|
|
77543
77844
|
scope: "global",
|
|
@@ -77557,8 +77858,8 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77557
77858
|
const entry = {
|
|
77558
77859
|
id: randomUUID6(),
|
|
77559
77860
|
tier: "swarm",
|
|
77560
|
-
lesson:
|
|
77561
|
-
category: raw.categoryHint ??
|
|
77861
|
+
lesson: _internals42.truncateLesson(raw.text),
|
|
77862
|
+
category: raw.categoryHint ?? _internals42.inferCategoryFromText(raw.text),
|
|
77562
77863
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
77563
77864
|
scope: "global",
|
|
77564
77865
|
confidence: 0.3,
|
|
@@ -77581,7 +77882,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77581
77882
|
if (migrated > 0) {
|
|
77582
77883
|
await rewriteKnowledge(knowledgePath, existing);
|
|
77583
77884
|
}
|
|
77584
|
-
await
|
|
77885
|
+
await _internals42.writeSentinel(sentinelPath, migrated, dropped);
|
|
77585
77886
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
77586
77887
|
return {
|
|
77587
77888
|
migrated: true,
|
|
@@ -77591,7 +77892,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
77591
77892
|
};
|
|
77592
77893
|
}
|
|
77593
77894
|
async function migrateHiveKnowledgeLegacy(config3) {
|
|
77594
|
-
const legacyHivePath =
|
|
77895
|
+
const legacyHivePath = _internals42.resolveLegacyHiveKnowledgePath();
|
|
77595
77896
|
const canonicalHivePath = resolveHiveKnowledgePath();
|
|
77596
77897
|
const sentinelPath = path60.join(path60.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
77597
77898
|
if (existsSync34(sentinelPath)) {
|
|
@@ -77614,7 +77915,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77614
77915
|
}
|
|
77615
77916
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
77616
77917
|
if (legacyEntries.length === 0) {
|
|
77617
|
-
await
|
|
77918
|
+
await _internals42.writeSentinel(sentinelPath, 0, 0);
|
|
77618
77919
|
return {
|
|
77619
77920
|
migrated: true,
|
|
77620
77921
|
entriesMigrated: 0,
|
|
@@ -77662,7 +77963,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77662
77963
|
const newHiveEntry = {
|
|
77663
77964
|
id: resolvedId,
|
|
77664
77965
|
tier: "hive",
|
|
77665
|
-
lesson:
|
|
77966
|
+
lesson: _internals42.truncateLesson(lesson),
|
|
77666
77967
|
category,
|
|
77667
77968
|
tags: ["migration:legacy-hive"],
|
|
77668
77969
|
scope: scopeTag,
|
|
@@ -77681,7 +77982,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77681
77982
|
encounter_score: 1
|
|
77682
77983
|
};
|
|
77683
77984
|
try {
|
|
77684
|
-
await
|
|
77985
|
+
await _internals42.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
77685
77986
|
existingHiveEntries.push(newHiveEntry);
|
|
77686
77987
|
migrated++;
|
|
77687
77988
|
} catch (appendError) {
|
|
@@ -77697,7 +77998,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77697
77998
|
dropped++;
|
|
77698
77999
|
}
|
|
77699
78000
|
}
|
|
77700
|
-
await
|
|
78001
|
+
await _internals42.writeSentinel(sentinelPath, migrated, dropped);
|
|
77701
78002
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
77702
78003
|
return {
|
|
77703
78004
|
migrated: true,
|
|
@@ -77708,7 +78009,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
77708
78009
|
};
|
|
77709
78010
|
}
|
|
77710
78011
|
function parseContextMd(content) {
|
|
77711
|
-
const sections =
|
|
78012
|
+
const sections = _internals42.splitIntoSections(content);
|
|
77712
78013
|
const entries = [];
|
|
77713
78014
|
const seen = new Set;
|
|
77714
78015
|
const sectionPatterns = [
|
|
@@ -77724,7 +78025,7 @@ function parseContextMd(content) {
|
|
|
77724
78025
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
77725
78026
|
if (!match)
|
|
77726
78027
|
continue;
|
|
77727
|
-
const bullets =
|
|
78028
|
+
const bullets = _internals42.extractBullets(section.body);
|
|
77728
78029
|
for (const bullet of bullets) {
|
|
77729
78030
|
if (bullet.length < 15)
|
|
77730
78031
|
continue;
|
|
@@ -77733,9 +78034,9 @@ function parseContextMd(content) {
|
|
|
77733
78034
|
continue;
|
|
77734
78035
|
seen.add(normalized);
|
|
77735
78036
|
entries.push({
|
|
77736
|
-
text:
|
|
78037
|
+
text: _internals42.truncateLesson(bullet),
|
|
77737
78038
|
sourceSection: match.sourceSection,
|
|
77738
|
-
categoryHint:
|
|
78039
|
+
categoryHint: _internals42.inferCategoryFromText(bullet)
|
|
77739
78040
|
});
|
|
77740
78041
|
}
|
|
77741
78042
|
}
|
|
@@ -77841,12 +78142,12 @@ function resolveLegacyHiveKnowledgePath() {
|
|
|
77841
78142
|
}
|
|
77842
78143
|
return path60.join(dataDir, "hive-knowledge.jsonl");
|
|
77843
78144
|
}
|
|
77844
|
-
var
|
|
78145
|
+
var _internals42;
|
|
77845
78146
|
var init_knowledge_migrator = __esm(() => {
|
|
77846
78147
|
init_logger();
|
|
77847
78148
|
init_knowledge_store();
|
|
77848
78149
|
init_knowledge_validator();
|
|
77849
|
-
|
|
78150
|
+
_internals42 = {
|
|
77850
78151
|
appendKnowledge,
|
|
77851
78152
|
migrateContextToKnowledge,
|
|
77852
78153
|
migrateKnowledgeToExternal,
|
|
@@ -82431,9 +82732,9 @@ var init_memory2 = __esm(() => {
|
|
|
82431
82732
|
|
|
82432
82733
|
// src/services/plan-service.ts
|
|
82433
82734
|
async function getPlanData(directory, phaseArg) {
|
|
82434
|
-
const plan = await
|
|
82735
|
+
const plan = await _internals43.loadPlanJsonOnly(directory);
|
|
82435
82736
|
if (plan) {
|
|
82436
|
-
const fullMarkdown =
|
|
82737
|
+
const fullMarkdown = _internals43.derivePlanMarkdown(plan);
|
|
82437
82738
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
82438
82739
|
return {
|
|
82439
82740
|
hasPlan: true,
|
|
@@ -82476,7 +82777,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
82476
82777
|
isLegacy: false
|
|
82477
82778
|
};
|
|
82478
82779
|
}
|
|
82479
|
-
const planContent = await
|
|
82780
|
+
const planContent = await _internals43.readSwarmFileAsync(directory, "plan.md");
|
|
82480
82781
|
if (!planContent) {
|
|
82481
82782
|
return {
|
|
82482
82783
|
hasPlan: false,
|
|
@@ -82572,11 +82873,11 @@ async function handlePlanCommand(directory, args2) {
|
|
|
82572
82873
|
const planData = await getPlanData(directory, phaseArg);
|
|
82573
82874
|
return formatPlanMarkdown(planData);
|
|
82574
82875
|
}
|
|
82575
|
-
var
|
|
82876
|
+
var _internals43;
|
|
82576
82877
|
var init_plan_service = __esm(() => {
|
|
82577
82878
|
init_utils2();
|
|
82578
82879
|
init_manager();
|
|
82579
|
-
|
|
82880
|
+
_internals43 = {
|
|
82580
82881
|
loadPlanJsonOnly,
|
|
82581
82882
|
derivePlanMarkdown,
|
|
82582
82883
|
readSwarmFileAsync
|
|
@@ -82766,7 +83067,7 @@ function formatRelativeTime(epochMs) {
|
|
|
82766
83067
|
return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
|
|
82767
83068
|
}
|
|
82768
83069
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID) {
|
|
82769
|
-
const allActive = await
|
|
83070
|
+
const allActive = await _internals44.listActive(directory);
|
|
82770
83071
|
const sessionSubs = allActive.filter((record3) => record3.sessionID === sessionID);
|
|
82771
83072
|
if (sessionSubs.length === 0) {
|
|
82772
83073
|
return "No active PR subscriptions for this session.";
|
|
@@ -82795,10 +83096,10 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID) {
|
|
|
82795
83096
|
return lines.join(`
|
|
82796
83097
|
`);
|
|
82797
83098
|
}
|
|
82798
|
-
var
|
|
83099
|
+
var _internals44;
|
|
82799
83100
|
var init_pr_monitor_status = __esm(() => {
|
|
82800
83101
|
init_pr_subscriptions();
|
|
82801
|
-
|
|
83102
|
+
_internals44 = {
|
|
82802
83103
|
formatRelativeTime,
|
|
82803
83104
|
listActive
|
|
82804
83105
|
};
|
|
@@ -82903,7 +83204,7 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
82903
83204
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
82904
83205
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
82905
83206
|
try {
|
|
82906
|
-
const config3 =
|
|
83207
|
+
const config3 = _internals45.loadPluginConfig(directory);
|
|
82907
83208
|
const prMonitorConfig = config3.pr_monitor;
|
|
82908
83209
|
if (!prMonitorConfig?.enabled) {
|
|
82909
83210
|
return [
|
|
@@ -82913,7 +83214,7 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
82913
83214
|
].join(`
|
|
82914
83215
|
`);
|
|
82915
83216
|
}
|
|
82916
|
-
await
|
|
83217
|
+
await _internals45.subscribe(directory, {
|
|
82917
83218
|
sessionID,
|
|
82918
83219
|
prNumber: prInfo.number,
|
|
82919
83220
|
repoFullName,
|
|
@@ -82937,12 +83238,12 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
82937
83238
|
`);
|
|
82938
83239
|
}
|
|
82939
83240
|
}
|
|
82940
|
-
var
|
|
83241
|
+
var _internals45;
|
|
82941
83242
|
var init_pr_subscribe = __esm(() => {
|
|
82942
83243
|
init_pr_subscriptions();
|
|
82943
83244
|
init_loader();
|
|
82944
83245
|
init_pr_ref();
|
|
82945
|
-
|
|
83246
|
+
_internals45 = {
|
|
82946
83247
|
loadPluginConfig,
|
|
82947
83248
|
subscribe
|
|
82948
83249
|
};
|
|
@@ -82966,9 +83267,9 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
82966
83267
|
`);
|
|
82967
83268
|
}
|
|
82968
83269
|
const refToken = rest[0];
|
|
82969
|
-
const prInfo =
|
|
83270
|
+
const prInfo = _internals46.parsePrRef(refToken, directory);
|
|
82970
83271
|
if (!prInfo) {
|
|
82971
|
-
if (
|
|
83272
|
+
if (_internals46.looksLikePrRef(refToken)) {
|
|
82972
83273
|
return [
|
|
82973
83274
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
82974
83275
|
"",
|
|
@@ -82989,8 +83290,8 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
82989
83290
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
82990
83291
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
82991
83292
|
try {
|
|
82992
|
-
const correlationId =
|
|
82993
|
-
const result = await
|
|
83293
|
+
const correlationId = _internals46.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
83294
|
+
const result = await _internals46.unsubscribe(directory, correlationId);
|
|
82994
83295
|
if (!result) {
|
|
82995
83296
|
return [
|
|
82996
83297
|
`Not subscribed to ${prUrl}`,
|
|
@@ -83017,11 +83318,11 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
83017
83318
|
`);
|
|
83018
83319
|
}
|
|
83019
83320
|
}
|
|
83020
|
-
var
|
|
83321
|
+
var _internals46;
|
|
83021
83322
|
var init_pr_unsubscribe = __esm(() => {
|
|
83022
83323
|
init_pr_subscriptions();
|
|
83023
83324
|
init_pr_ref();
|
|
83024
|
-
|
|
83325
|
+
_internals46 = {
|
|
83025
83326
|
unsubscribe,
|
|
83026
83327
|
buildCorrelationId,
|
|
83027
83328
|
parsePrRef,
|
|
@@ -83477,7 +83778,7 @@ async function runAdditionalLint(linter, mode, cwd) {
|
|
|
83477
83778
|
};
|
|
83478
83779
|
}
|
|
83479
83780
|
}
|
|
83480
|
-
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint,
|
|
83781
|
+
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals47;
|
|
83481
83782
|
var init_lint = __esm(() => {
|
|
83482
83783
|
init_zod();
|
|
83483
83784
|
init_discovery();
|
|
@@ -83509,15 +83810,15 @@ var init_lint = __esm(() => {
|
|
|
83509
83810
|
}
|
|
83510
83811
|
const { mode } = args2;
|
|
83511
83812
|
const cwd = directory;
|
|
83512
|
-
const linter = await
|
|
83813
|
+
const linter = await _internals47.detectAvailableLinter(directory);
|
|
83513
83814
|
if (linter) {
|
|
83514
|
-
const result = await
|
|
83815
|
+
const result = await _internals47.runLint(linter, mode, directory);
|
|
83515
83816
|
return JSON.stringify(result, null, 2);
|
|
83516
83817
|
}
|
|
83517
|
-
const additionalLinter =
|
|
83818
|
+
const additionalLinter = _internals47.detectAdditionalLinter(cwd);
|
|
83518
83819
|
if (additionalLinter) {
|
|
83519
83820
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
83520
|
-
const result = await
|
|
83821
|
+
const result = await _internals47.runAdditionalLint(additionalLinter, mode, cwd);
|
|
83521
83822
|
return JSON.stringify(result, null, 2);
|
|
83522
83823
|
}
|
|
83523
83824
|
const errorResult = {
|
|
@@ -83531,7 +83832,7 @@ For Rust: rustup component add clippy`
|
|
|
83531
83832
|
return JSON.stringify(errorResult, null, 2);
|
|
83532
83833
|
}
|
|
83533
83834
|
});
|
|
83534
|
-
|
|
83835
|
+
_internals47 = {
|
|
83535
83836
|
detectAvailableLinter,
|
|
83536
83837
|
runLint,
|
|
83537
83838
|
detectAdditionalLinter,
|
|
@@ -83845,7 +84146,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
83845
84146
|
}
|
|
83846
84147
|
async function runSecretscan(directory) {
|
|
83847
84148
|
try {
|
|
83848
|
-
const result = await
|
|
84149
|
+
const result = await _internals48.secretscan.execute({ directory }, {});
|
|
83849
84150
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
83850
84151
|
return JSON.parse(jsonStr);
|
|
83851
84152
|
} catch (e) {
|
|
@@ -83860,7 +84161,7 @@ async function runSecretscan(directory) {
|
|
|
83860
84161
|
return errorResult;
|
|
83861
84162
|
}
|
|
83862
84163
|
}
|
|
83863
|
-
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS2, O_NOFOLLOW, secretscan,
|
|
84164
|
+
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS2, O_NOFOLLOW, secretscan, _internals48;
|
|
83864
84165
|
var init_secretscan = __esm(() => {
|
|
83865
84166
|
init_zod();
|
|
83866
84167
|
init_path_security();
|
|
@@ -84232,7 +84533,7 @@ var init_secretscan = __esm(() => {
|
|
|
84232
84533
|
}
|
|
84233
84534
|
}
|
|
84234
84535
|
});
|
|
84235
|
-
|
|
84536
|
+
_internals48 = {
|
|
84236
84537
|
secretscan,
|
|
84237
84538
|
runSecretscan
|
|
84238
84539
|
};
|
|
@@ -84824,14 +85125,14 @@ function buildGoBackend() {
|
|
|
84824
85125
|
selectEntryPoints
|
|
84825
85126
|
};
|
|
84826
85127
|
}
|
|
84827
|
-
var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE,
|
|
85128
|
+
var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals49;
|
|
84828
85129
|
var init_go = __esm(() => {
|
|
84829
85130
|
init_default_backend();
|
|
84830
85131
|
init_profiles();
|
|
84831
85132
|
IMPORT_REGEX_SINGLE = /^\s*import\s+(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/gm;
|
|
84832
85133
|
IMPORT_REGEX_GROUP = /^\s*import\s*\(([\s\S]*?)\)/gm;
|
|
84833
85134
|
IMPORT_REGEX_GROUP_LINE = /(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/g;
|
|
84834
|
-
|
|
85135
|
+
_internals49 = { extractImports };
|
|
84835
85136
|
});
|
|
84836
85137
|
|
|
84837
85138
|
// src/lang/backends/python.ts
|
|
@@ -84943,13 +85244,13 @@ function buildPythonBackend() {
|
|
|
84943
85244
|
selectEntryPoints: selectEntryPoints2
|
|
84944
85245
|
};
|
|
84945
85246
|
}
|
|
84946
|
-
var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT,
|
|
85247
|
+
var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals50;
|
|
84947
85248
|
var init_python = __esm(() => {
|
|
84948
85249
|
init_default_backend();
|
|
84949
85250
|
init_profiles();
|
|
84950
85251
|
IMPORT_REGEX_FROM_WITH_TARGETS = /^\s*from\s+(\.*[\w.]*)\s+import\s+(\([^)]*\)|[^\n#]+)/gm;
|
|
84951
85252
|
IMPORT_REGEX_IMPORT = /^\s*import\s+([^\n#]+)/gm;
|
|
84952
|
-
|
|
85253
|
+
_internals50 = { extractImports: extractImports2 };
|
|
84953
85254
|
});
|
|
84954
85255
|
|
|
84955
85256
|
// src/test-impact/analyzer.ts
|
|
@@ -85173,7 +85474,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
|
|
|
85173
85474
|
return;
|
|
85174
85475
|
}
|
|
85175
85476
|
if (PYTHON_EXTENSIONS.has(ext)) {
|
|
85176
|
-
const modules =
|
|
85477
|
+
const modules = _internals50.extractImports(testFile, content);
|
|
85177
85478
|
for (const mod of modules) {
|
|
85178
85479
|
const resolved = resolvePythonImport(testDir, mod);
|
|
85179
85480
|
if (resolved !== null)
|
|
@@ -85182,7 +85483,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
|
|
|
85182
85483
|
return;
|
|
85183
85484
|
}
|
|
85184
85485
|
if (GO_EXTENSIONS.has(ext)) {
|
|
85185
|
-
const imports =
|
|
85486
|
+
const imports = _internals49.extractImports(testFile, content);
|
|
85186
85487
|
for (const importPath of imports) {
|
|
85187
85488
|
const sourceFiles = resolveGoImport(testDir, importPath);
|
|
85188
85489
|
for (const source of sourceFiles)
|
|
@@ -85209,8 +85510,8 @@ async function buildImpactMapInternal(cwd) {
|
|
|
85209
85510
|
return impactMap;
|
|
85210
85511
|
}
|
|
85211
85512
|
async function buildImpactMap(cwd) {
|
|
85212
|
-
const impactMap = await
|
|
85213
|
-
await
|
|
85513
|
+
const impactMap = await _internals51.buildImpactMapInternal(cwd);
|
|
85514
|
+
await _internals51.saveImpactMap(cwd, impactMap);
|
|
85214
85515
|
return impactMap;
|
|
85215
85516
|
}
|
|
85216
85517
|
async function loadImpactMap(cwd, options) {
|
|
@@ -85224,7 +85525,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
85224
85525
|
const hasValidValues = Object.values(map3).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
85225
85526
|
if (hasValidValues) {
|
|
85226
85527
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
85227
|
-
if (!
|
|
85528
|
+
if (!_internals51.isCacheStale(map3, generatedAt)) {
|
|
85228
85529
|
return map3;
|
|
85229
85530
|
}
|
|
85230
85531
|
if (options?.skipRebuild) {
|
|
@@ -85244,13 +85545,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
85244
85545
|
if (options?.skipRebuild) {
|
|
85245
85546
|
return {};
|
|
85246
85547
|
}
|
|
85247
|
-
return
|
|
85548
|
+
return _internals51.buildImpactMap(cwd);
|
|
85248
85549
|
}
|
|
85249
85550
|
async function saveImpactMap(cwd, impactMap) {
|
|
85250
85551
|
if (!path74.isAbsolute(cwd)) {
|
|
85251
85552
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
85252
85553
|
}
|
|
85253
|
-
|
|
85554
|
+
_internals51.validateProjectRoot(cwd);
|
|
85254
85555
|
const cacheDir2 = path74.join(cwd, ".swarm", "cache");
|
|
85255
85556
|
const cachePath = path74.join(cacheDir2, "impact-map.json");
|
|
85256
85557
|
if (!fs34.existsSync(cacheDir2)) {
|
|
@@ -85274,7 +85575,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
85274
85575
|
};
|
|
85275
85576
|
}
|
|
85276
85577
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
85277
|
-
const impactMap = await
|
|
85578
|
+
const impactMap = await _internals51.loadImpactMap(cwd);
|
|
85278
85579
|
const impactedTestsSet = new Set;
|
|
85279
85580
|
const untestedFiles = [];
|
|
85280
85581
|
let visitedCount = 0;
|
|
@@ -85359,7 +85660,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
85359
85660
|
budgetExceeded
|
|
85360
85661
|
};
|
|
85361
85662
|
}
|
|
85362
|
-
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache,
|
|
85663
|
+
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals51;
|
|
85363
85664
|
var init_analyzer = __esm(() => {
|
|
85364
85665
|
init_manager2();
|
|
85365
85666
|
init_go();
|
|
@@ -85372,7 +85673,7 @@ var init_analyzer = __esm(() => {
|
|
|
85372
85673
|
GO_EXTENSIONS = new Set([".go"]);
|
|
85373
85674
|
EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
85374
85675
|
goModuleCache = new Map;
|
|
85375
|
-
|
|
85676
|
+
_internals51 = {
|
|
85376
85677
|
validateProjectRoot,
|
|
85377
85678
|
normalizePath,
|
|
85378
85679
|
isCacheStale,
|
|
@@ -85755,7 +86056,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
85755
86056
|
}
|
|
85756
86057
|
const historyPath = getHistoryPath(workingDir);
|
|
85757
86058
|
const historyDir = path75.dirname(historyPath);
|
|
85758
|
-
|
|
86059
|
+
_internals52.validateProjectRoot(workingDir);
|
|
85759
86060
|
if (!fs35.existsSync(historyDir)) {
|
|
85760
86061
|
fs35.mkdirSync(historyDir, { recursive: true });
|
|
85761
86062
|
}
|
|
@@ -85878,7 +86179,7 @@ function getAllHistory(workingDir) {
|
|
|
85878
86179
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
85879
86180
|
return records;
|
|
85880
86181
|
}
|
|
85881
|
-
var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, HISTORY_WRITE_LOCK_TIMEOUT_MS = 5000, HISTORY_WRITE_LOCK_STALE_MS = 60000, HISTORY_WRITE_LOCK_BACKOFF_MS = 10, DANGEROUS_PROPERTY_NAMES,
|
|
86182
|
+
var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, HISTORY_WRITE_LOCK_TIMEOUT_MS = 5000, HISTORY_WRITE_LOCK_STALE_MS = 60000, HISTORY_WRITE_LOCK_BACKOFF_MS = 10, DANGEROUS_PROPERTY_NAMES, _internals52;
|
|
85882
86183
|
var init_history_store = __esm(() => {
|
|
85883
86184
|
init_manager2();
|
|
85884
86185
|
DANGEROUS_PROPERTY_NAMES = new Set([
|
|
@@ -85886,7 +86187,7 @@ var init_history_store = __esm(() => {
|
|
|
85886
86187
|
"constructor",
|
|
85887
86188
|
"prototype"
|
|
85888
86189
|
]);
|
|
85889
|
-
|
|
86190
|
+
_internals52 = {
|
|
85890
86191
|
validateProjectRoot
|
|
85891
86192
|
};
|
|
85892
86193
|
});
|
|
@@ -86136,7 +86437,7 @@ function readPackageJsonRaw(dir) {
|
|
|
86136
86437
|
}
|
|
86137
86438
|
}
|
|
86138
86439
|
function readPackageJson(dir) {
|
|
86139
|
-
return
|
|
86440
|
+
return _internals53.readPackageJsonRaw(dir);
|
|
86140
86441
|
}
|
|
86141
86442
|
function readPackageJsonTestScript(dir) {
|
|
86142
86443
|
return readPackageJson(dir)?.scripts?.test ?? null;
|
|
@@ -86306,7 +86607,7 @@ function buildTypescriptBackend() {
|
|
|
86306
86607
|
selectEntryPoints: selectEntryPoints3
|
|
86307
86608
|
};
|
|
86308
86609
|
}
|
|
86309
|
-
var PROFILE_ID4 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2,
|
|
86610
|
+
var PROFILE_ID4 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals53;
|
|
86310
86611
|
var init_typescript = __esm(() => {
|
|
86311
86612
|
init_default_backend();
|
|
86312
86613
|
init_profiles();
|
|
@@ -86315,7 +86616,7 @@ var init_typescript = __esm(() => {
|
|
|
86315
86616
|
IMPORT_REGEX_REQUIRE2 = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
86316
86617
|
IMPORT_REGEX_DYNAMIC = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
86317
86618
|
IMPORT_REGEX_REEXPORT2 = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
86318
|
-
|
|
86619
|
+
_internals53 = {
|
|
86319
86620
|
readPackageJsonRaw,
|
|
86320
86621
|
readPackageJsonTestScript,
|
|
86321
86622
|
frameworkFromScriptsTest
|
|
@@ -86348,7 +86649,7 @@ __export(exports_dispatch, {
|
|
|
86348
86649
|
pickedProfiles: () => pickedProfiles,
|
|
86349
86650
|
pickBackend: () => pickBackend,
|
|
86350
86651
|
clearDispatchCache: () => clearDispatchCache,
|
|
86351
|
-
_internals: () =>
|
|
86652
|
+
_internals: () => _internals54
|
|
86352
86653
|
});
|
|
86353
86654
|
import * as fs39 from "node:fs";
|
|
86354
86655
|
import * as path79 from "node:path";
|
|
@@ -86403,7 +86704,7 @@ function findManifestRoot(start2) {
|
|
|
86403
86704
|
return start2;
|
|
86404
86705
|
}
|
|
86405
86706
|
function evictIfNeeded() {
|
|
86406
|
-
if (cache.size <=
|
|
86707
|
+
if (cache.size <= _internals54.cacheCapacity)
|
|
86407
86708
|
return;
|
|
86408
86709
|
let oldestKey;
|
|
86409
86710
|
let oldestOrder = Infinity;
|
|
@@ -86434,7 +86735,7 @@ async function pickBackend(dir) {
|
|
|
86434
86735
|
evictIfNeeded();
|
|
86435
86736
|
return null;
|
|
86436
86737
|
}
|
|
86437
|
-
const profiles = await
|
|
86738
|
+
const profiles = await _internals54.detectProjectLanguages(root);
|
|
86438
86739
|
if (profiles.length === 0) {
|
|
86439
86740
|
cache.set(cacheKey, {
|
|
86440
86741
|
hash: hash4,
|
|
@@ -86466,12 +86767,12 @@ function clearDispatchCache() {
|
|
|
86466
86767
|
manifestRootCache.clear();
|
|
86467
86768
|
insertCounter = 0;
|
|
86468
86769
|
}
|
|
86469
|
-
var
|
|
86770
|
+
var _internals54, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
|
|
86470
86771
|
var init_dispatch = __esm(() => {
|
|
86471
86772
|
init_backends();
|
|
86472
86773
|
init_detector();
|
|
86473
86774
|
init_registry_backend();
|
|
86474
|
-
|
|
86775
|
+
_internals54 = {
|
|
86475
86776
|
detectProjectLanguages,
|
|
86476
86777
|
cacheCapacity: 64
|
|
86477
86778
|
};
|
|
@@ -88327,9 +88628,9 @@ function getVersionFileVersion(dir) {
|
|
|
88327
88628
|
async function runVersionCheck2(dir, _timeoutMs) {
|
|
88328
88629
|
const startTime = Date.now();
|
|
88329
88630
|
try {
|
|
88330
|
-
const packageVersion =
|
|
88331
|
-
const changelogVersion =
|
|
88332
|
-
const versionFileVersion =
|
|
88631
|
+
const packageVersion = _internals55.getPackageVersion(dir);
|
|
88632
|
+
const changelogVersion = _internals55.getChangelogVersion(dir);
|
|
88633
|
+
const versionFileVersion = _internals55.getVersionFileVersion(dir);
|
|
88333
88634
|
const versions3 = [];
|
|
88334
88635
|
if (packageVersion)
|
|
88335
88636
|
versions3.push(`package.json: ${packageVersion}`);
|
|
@@ -88693,7 +88994,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88693
88994
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
88694
88995
|
let validatedDir;
|
|
88695
88996
|
try {
|
|
88696
|
-
validatedDir =
|
|
88997
|
+
validatedDir = _internals55.validateDirectoryPath(dir);
|
|
88697
88998
|
} catch (error93) {
|
|
88698
88999
|
return {
|
|
88699
89000
|
id: reportId,
|
|
@@ -88713,7 +89014,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88713
89014
|
}
|
|
88714
89015
|
let validatedTimeout;
|
|
88715
89016
|
try {
|
|
88716
|
-
validatedTimeout =
|
|
89017
|
+
validatedTimeout = _internals55.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
88717
89018
|
} catch (error93) {
|
|
88718
89019
|
return {
|
|
88719
89020
|
id: reportId,
|
|
@@ -88754,12 +89055,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88754
89055
|
});
|
|
88755
89056
|
const checks5 = [];
|
|
88756
89057
|
log("[Preflight] Running lint check...");
|
|
88757
|
-
const lintResult = await
|
|
89058
|
+
const lintResult = await _internals55.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
88758
89059
|
checks5.push(lintResult);
|
|
88759
89060
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
88760
89061
|
if (!cfg.skipTests) {
|
|
88761
89062
|
log("[Preflight] Running tests check...");
|
|
88762
|
-
const testsResult = await
|
|
89063
|
+
const testsResult = await _internals55.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
88763
89064
|
checks5.push(testsResult);
|
|
88764
89065
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
88765
89066
|
} else {
|
|
@@ -88771,7 +89072,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88771
89072
|
}
|
|
88772
89073
|
if (!cfg.skipSecrets) {
|
|
88773
89074
|
log("[Preflight] Running secrets check...");
|
|
88774
|
-
const secretsResult = await
|
|
89075
|
+
const secretsResult = await _internals55.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
88775
89076
|
checks5.push(secretsResult);
|
|
88776
89077
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
88777
89078
|
} else {
|
|
@@ -88783,7 +89084,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88783
89084
|
}
|
|
88784
89085
|
if (!cfg.skipEvidence) {
|
|
88785
89086
|
log("[Preflight] Running evidence check...");
|
|
88786
|
-
const evidenceResult = await
|
|
89087
|
+
const evidenceResult = await _internals55.runEvidenceCheck(validatedDir);
|
|
88787
89088
|
checks5.push(evidenceResult);
|
|
88788
89089
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
88789
89090
|
} else {
|
|
@@ -88794,12 +89095,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
88794
89095
|
});
|
|
88795
89096
|
}
|
|
88796
89097
|
log("[Preflight] Running requirement coverage check...");
|
|
88797
|
-
const reqCoverageResult = await
|
|
89098
|
+
const reqCoverageResult = await _internals55.runRequirementCoverageCheck(validatedDir, phase);
|
|
88798
89099
|
checks5.push(reqCoverageResult);
|
|
88799
89100
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
88800
89101
|
if (!cfg.skipVersion) {
|
|
88801
89102
|
log("[Preflight] Running version check...");
|
|
88802
|
-
const versionResult = await
|
|
89103
|
+
const versionResult = await _internals55.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
88803
89104
|
checks5.push(versionResult);
|
|
88804
89105
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
88805
89106
|
} else {
|
|
@@ -88862,10 +89163,10 @@ function formatPreflightMarkdown(report) {
|
|
|
88862
89163
|
async function handlePreflightCommand(directory, _args) {
|
|
88863
89164
|
const plan = await loadPlan(directory);
|
|
88864
89165
|
const phase = plan?.current_phase ?? 1;
|
|
88865
|
-
const report = await
|
|
88866
|
-
return
|
|
89166
|
+
const report = await _internals55.runPreflight(directory, phase);
|
|
89167
|
+
return _internals55.formatPreflightMarkdown(report);
|
|
88867
89168
|
}
|
|
88868
|
-
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG,
|
|
89169
|
+
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals55;
|
|
88869
89170
|
var init_preflight_service = __esm(() => {
|
|
88870
89171
|
init_gate_bridge();
|
|
88871
89172
|
init_manager2();
|
|
@@ -88884,7 +89185,7 @@ var init_preflight_service = __esm(() => {
|
|
|
88884
89185
|
testScope: "convention",
|
|
88885
89186
|
linter: "biome"
|
|
88886
89187
|
};
|
|
88887
|
-
|
|
89188
|
+
_internals55 = {
|
|
88888
89189
|
runPreflight,
|
|
88889
89190
|
formatPreflightMarkdown,
|
|
88890
89191
|
handlePreflightCommand,
|
|
@@ -90367,7 +90668,7 @@ async function handleSimulateCommand(directory, args2) {
|
|
|
90367
90668
|
}
|
|
90368
90669
|
let darkMatterPairs;
|
|
90369
90670
|
try {
|
|
90370
|
-
darkMatterPairs = await
|
|
90671
|
+
darkMatterPairs = await _internals35.detectDarkMatter(directory, options);
|
|
90371
90672
|
} catch (err2) {
|
|
90372
90673
|
const errMsg = err2 instanceof Error ? err2.message : String(err2);
|
|
90373
90674
|
return `## Simulate Report
|
|
@@ -90952,7 +91253,7 @@ async function getStatusData(directory, agents) {
|
|
|
90952
91253
|
}
|
|
90953
91254
|
function enrichWithLeanTurbo(status, directory) {
|
|
90954
91255
|
const turboMode = hasActiveTurboMode();
|
|
90955
|
-
const leanActive =
|
|
91256
|
+
const leanActive = _internals56.hasActiveLeanTurbo();
|
|
90956
91257
|
let turboStrategy = "off";
|
|
90957
91258
|
if (leanActive) {
|
|
90958
91259
|
turboStrategy = "lean";
|
|
@@ -90971,7 +91272,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
90971
91272
|
}
|
|
90972
91273
|
}
|
|
90973
91274
|
if (leanSessionID) {
|
|
90974
|
-
const runState =
|
|
91275
|
+
const runState = _internals56.loadLeanTurboRunState(directory, leanSessionID);
|
|
90975
91276
|
if (runState) {
|
|
90976
91277
|
status.leanTurboPhase = runState.phase;
|
|
90977
91278
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -91003,7 +91304,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
91003
91304
|
}
|
|
91004
91305
|
}
|
|
91005
91306
|
}
|
|
91006
|
-
status.fullAutoActive =
|
|
91307
|
+
status.fullAutoActive = _internals56.hasActiveFullAuto();
|
|
91007
91308
|
return status;
|
|
91008
91309
|
}
|
|
91009
91310
|
function formatStatusMarkdown(status) {
|
|
@@ -91131,7 +91432,7 @@ async function countProposals(directory) {
|
|
|
91131
91432
|
return 0;
|
|
91132
91433
|
}
|
|
91133
91434
|
}
|
|
91134
|
-
var
|
|
91435
|
+
var _internals56;
|
|
91135
91436
|
var init_status_service = __esm(() => {
|
|
91136
91437
|
init_extractors();
|
|
91137
91438
|
init_knowledge_escalator();
|
|
@@ -91141,7 +91442,7 @@ var init_status_service = __esm(() => {
|
|
|
91141
91442
|
init_state3();
|
|
91142
91443
|
init_compaction_service();
|
|
91143
91444
|
init_context_budget_service();
|
|
91144
|
-
|
|
91445
|
+
_internals56 = {
|
|
91145
91446
|
loadLeanTurboRunState,
|
|
91146
91447
|
hasActiveLeanTurbo,
|
|
91147
91448
|
hasActiveFullAuto
|
|
@@ -91232,7 +91533,7 @@ async function handleTurboCommand(directory, args2, sessionID) {
|
|
|
91232
91533
|
if (arg0 === "on") {
|
|
91233
91534
|
let strategy = "standard";
|
|
91234
91535
|
try {
|
|
91235
|
-
const { config: config3 } =
|
|
91536
|
+
const { config: config3 } = _internals57.loadPluginConfigWithMeta(directory);
|
|
91236
91537
|
if (config3.turbo?.strategy === "lean") {
|
|
91237
91538
|
strategy = "lean";
|
|
91238
91539
|
}
|
|
@@ -91287,7 +91588,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
91287
91588
|
let maxParallelCoders = 4;
|
|
91288
91589
|
let conflictPolicy = "serialize";
|
|
91289
91590
|
try {
|
|
91290
|
-
const { config: config3 } =
|
|
91591
|
+
const { config: config3 } = _internals57.loadPluginConfigWithMeta(directory);
|
|
91291
91592
|
const leanConfig = config3.turbo?.lean;
|
|
91292
91593
|
if (leanConfig) {
|
|
91293
91594
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -91357,13 +91658,13 @@ function buildStatusMessage2(session, directory, sessionID) {
|
|
|
91357
91658
|
].join(`
|
|
91358
91659
|
`);
|
|
91359
91660
|
}
|
|
91360
|
-
var
|
|
91661
|
+
var _internals57;
|
|
91361
91662
|
var init_turbo = __esm(() => {
|
|
91362
91663
|
init_config();
|
|
91363
91664
|
init_state();
|
|
91364
91665
|
init_state3();
|
|
91365
91666
|
init_logger();
|
|
91366
|
-
|
|
91667
|
+
_internals57 = {
|
|
91367
91668
|
loadPluginConfigWithMeta
|
|
91368
91669
|
};
|
|
91369
91670
|
});
|
|
@@ -91429,342 +91730,6 @@ var init_write_retro2 = __esm(() => {
|
|
|
91429
91730
|
init_write_retro();
|
|
91430
91731
|
});
|
|
91431
91732
|
|
|
91432
|
-
// src/commands/command-dispatch.ts
|
|
91433
|
-
function normalizeSwarmCommandInput(command, argumentText) {
|
|
91434
|
-
if (command !== "swarm" && !command.startsWith("swarm-")) {
|
|
91435
|
-
return { isSwarmCommand: false, tokens: [] };
|
|
91436
|
-
}
|
|
91437
|
-
if (command === "swarm") {
|
|
91438
|
-
return {
|
|
91439
|
-
isSwarmCommand: true,
|
|
91440
|
-
tokens: argumentText.trim().split(/\s+/).filter(Boolean)
|
|
91441
|
-
};
|
|
91442
|
-
}
|
|
91443
|
-
const subcommand = command.slice("swarm-".length);
|
|
91444
|
-
const extraArgs = argumentText.trim().split(/\s+/).filter(Boolean);
|
|
91445
|
-
return {
|
|
91446
|
-
isSwarmCommand: true,
|
|
91447
|
-
tokens: [subcommand, ...extraArgs].filter(Boolean)
|
|
91448
|
-
};
|
|
91449
|
-
}
|
|
91450
|
-
function canonicalCommandKey(resolved) {
|
|
91451
|
-
return resolved.entry.aliasOf ?? resolved.key;
|
|
91452
|
-
}
|
|
91453
|
-
function formatCommandNotFound(tokens) {
|
|
91454
|
-
const attemptedCommand = tokens[0] || "";
|
|
91455
|
-
const MAX_DISPLAY = 100;
|
|
91456
|
-
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
91457
|
-
const similar = _internals57.findSimilarCommands(attemptedCommand);
|
|
91458
|
-
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
91459
|
-
const suggestions = similar.length > 0 ? `Did you mean:
|
|
91460
|
-
${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
|
|
91461
|
-
`)}` : "";
|
|
91462
|
-
const footer = "Run `/swarm help` for all commands.";
|
|
91463
|
-
return [header, suggestions, footer].filter(Boolean).join(`
|
|
91464
|
-
|
|
91465
|
-
`);
|
|
91466
|
-
}
|
|
91467
|
-
async function executeSwarmCommand(args2) {
|
|
91468
|
-
const {
|
|
91469
|
-
directory,
|
|
91470
|
-
agents,
|
|
91471
|
-
sessionID,
|
|
91472
|
-
tokens,
|
|
91473
|
-
packageRoot,
|
|
91474
|
-
buildHelpText,
|
|
91475
|
-
policy
|
|
91476
|
-
} = args2;
|
|
91477
|
-
let text;
|
|
91478
|
-
const resolved = resolveCommand(tokens);
|
|
91479
|
-
if (!resolved) {
|
|
91480
|
-
text = tokens.length === 0 && buildHelpText ? buildHelpText() : formatCommandNotFound(tokens);
|
|
91481
|
-
} else {
|
|
91482
|
-
const policyResult = policy?.(resolved) ?? { allowed: true };
|
|
91483
|
-
if (!policyResult.allowed) {
|
|
91484
|
-
text = policyResult.message;
|
|
91485
|
-
} else {
|
|
91486
|
-
try {
|
|
91487
|
-
text = await resolved.entry.handler({
|
|
91488
|
-
directory,
|
|
91489
|
-
args: resolved.remainingArgs,
|
|
91490
|
-
sessionID,
|
|
91491
|
-
agents,
|
|
91492
|
-
packageRoot,
|
|
91493
|
-
source: "chat"
|
|
91494
|
-
});
|
|
91495
|
-
} catch (_err) {
|
|
91496
|
-
const cmdName = tokens[0] || "unknown";
|
|
91497
|
-
const errMsg = _err instanceof Error ? _err.message : String(_err);
|
|
91498
|
-
text = `Error executing /swarm ${cmdName}: ${errMsg}`;
|
|
91499
|
-
}
|
|
91500
|
-
if (resolved.warning) {
|
|
91501
|
-
text = `${resolved.warning}
|
|
91502
|
-
|
|
91503
|
-
${text}`;
|
|
91504
|
-
}
|
|
91505
|
-
}
|
|
91506
|
-
}
|
|
91507
|
-
return {
|
|
91508
|
-
text,
|
|
91509
|
-
resolved: resolved ?? undefined,
|
|
91510
|
-
canonicalKey: resolved ? canonicalCommandKey(resolved) : undefined
|
|
91511
|
-
};
|
|
91512
|
-
}
|
|
91513
|
-
var init_command_dispatch = __esm(() => {
|
|
91514
|
-
init_registry();
|
|
91515
|
-
});
|
|
91516
|
-
|
|
91517
|
-
// src/commands/tool-policy.ts
|
|
91518
|
-
function classifySwarmCommandToolUse(resolved) {
|
|
91519
|
-
const canonicalKey = canonicalCommandKey(resolved);
|
|
91520
|
-
const args2 = resolved.remainingArgs;
|
|
91521
|
-
if (!SWARM_COMMAND_TOOL_ALLOWLIST.has(canonicalKey)) {
|
|
91522
|
-
if (HUMAN_ONLY_SWARM_COMMANDS.has(canonicalKey)) {
|
|
91523
|
-
return {
|
|
91524
|
-
allowed: false,
|
|
91525
|
-
message: `/swarm ${canonicalKey} is a human-only command. ` + `Present the situation to the user and ask them to run \`/swarm ${canonicalKey}\` themselves ` + `(or \`bunx opencode-swarm run ${canonicalKey}\` from a terminal). ` + `You MUST NOT run it yourself via Bash, swarm_command, or any other tool — ` + `the runtime guardrail will block such attempts.`
|
|
91526
|
-
};
|
|
91527
|
-
}
|
|
91528
|
-
return {
|
|
91529
|
-
allowed: false,
|
|
91530
|
-
message: `/swarm ${canonicalKey} is not available through the chat tool yet.
|
|
91531
|
-
|
|
91532
|
-
` + `Use the canonical CLI path for now: \`bunx opencode-swarm run ${canonicalKey}\`.
|
|
91533
|
-
` + `Commands with state changes, auto-heal behavior, or subprocesses need confirmation gates before chat-tool support.`
|
|
91534
|
-
};
|
|
91535
|
-
}
|
|
91536
|
-
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
91537
|
-
return {
|
|
91538
|
-
allowed: false,
|
|
91539
|
-
message: "/swarm config doctor --fix is not available through swarm_command. Run the CLI command directly when you intend to modify config files."
|
|
91540
|
-
};
|
|
91541
|
-
}
|
|
91542
|
-
if (NO_ARGS.has(canonicalKey) && args2.length > 0) {
|
|
91543
|
-
return {
|
|
91544
|
-
allowed: false,
|
|
91545
|
-
message: `/swarm ${canonicalKey} does not accept arguments through swarm_command.`
|
|
91546
|
-
};
|
|
91547
|
-
}
|
|
91548
|
-
if (canonicalKey === "knowledge") {
|
|
91549
|
-
if (args2.length === 0)
|
|
91550
|
-
return { allowed: true };
|
|
91551
|
-
if (args2.length === 1 && (args2[0] === "list" || args2[0] === "unactionable"))
|
|
91552
|
-
return { allowed: true };
|
|
91553
|
-
return {
|
|
91554
|
-
allowed: false,
|
|
91555
|
-
message: "Only `/swarm knowledge`, `/swarm knowledge list`, and `/swarm knowledge unactionable` are available through swarm_command. Knowledge migrate/quarantine/restore/retry-hardening are intentionally excluded."
|
|
91556
|
-
};
|
|
91557
|
-
}
|
|
91558
|
-
if (canonicalKey === "memory") {
|
|
91559
|
-
if (args2.length === 0)
|
|
91560
|
-
return { allowed: true };
|
|
91561
|
-
return {
|
|
91562
|
-
allowed: false,
|
|
91563
|
-
message: "Use `/swarm memory status`, `/swarm memory pending`, `/swarm memory recall-log`, `/swarm memory stale`, `/swarm memory export`, or `/swarm memory evaluate --json` through swarm_command. Memory import, migrate, and compact are intentionally excluded from chat-tool execution."
|
|
91564
|
-
};
|
|
91565
|
-
}
|
|
91566
|
-
if (canonicalKey === "memory evaluate") {
|
|
91567
|
-
if (args2.length === 0)
|
|
91568
|
-
return { allowed: true };
|
|
91569
|
-
if (args2.length === 1 && args2[0] === "--json")
|
|
91570
|
-
return { allowed: true };
|
|
91571
|
-
return {
|
|
91572
|
-
allowed: false,
|
|
91573
|
-
message: "Usage through swarm_command: `/swarm memory evaluate --json`. Custom fixture directories are only available through direct user command execution."
|
|
91574
|
-
};
|
|
91575
|
-
}
|
|
91576
|
-
if (canonicalKey === "sdd status") {
|
|
91577
|
-
if (args2.length === 0)
|
|
91578
|
-
return { allowed: true };
|
|
91579
|
-
if (args2.length === 1 && args2[0] === "--json")
|
|
91580
|
-
return { allowed: true };
|
|
91581
|
-
return {
|
|
91582
|
-
allowed: false,
|
|
91583
|
-
message: "Usage through swarm_command: `/swarm sdd status` or `/swarm sdd status --json`."
|
|
91584
|
-
};
|
|
91585
|
-
}
|
|
91586
|
-
if (canonicalKey === "sdd validate") {
|
|
91587
|
-
if (args2.length === 0)
|
|
91588
|
-
return { allowed: true };
|
|
91589
|
-
if (args2.length === 1 && args2[0] === "--json")
|
|
91590
|
-
return { allowed: true };
|
|
91591
|
-
if (args2.length === 2 && args2[0] === "--change" && /^[A-Za-z0-9_.-]{1,128}$/.test(args2[1])) {
|
|
91592
|
-
return { allowed: true };
|
|
91593
|
-
}
|
|
91594
|
-
return {
|
|
91595
|
-
allowed: false,
|
|
91596
|
-
message: "Usage through swarm_command: `/swarm sdd validate`, `/swarm sdd validate --json`, or `/swarm sdd validate --change <id>`."
|
|
91597
|
-
};
|
|
91598
|
-
}
|
|
91599
|
-
if (canonicalKey === "memory pending" || canonicalKey === "memory recall-log" || canonicalKey === "memory stale") {
|
|
91600
|
-
if (args2.length === 0)
|
|
91601
|
-
return { allowed: true };
|
|
91602
|
-
if (args2.length === 2 && args2[0] === "--limit" && /^\d+$/.test(args2[1])) {
|
|
91603
|
-
return { allowed: true };
|
|
91604
|
-
}
|
|
91605
|
-
return {
|
|
91606
|
-
allowed: false,
|
|
91607
|
-
message: `Usage through swarm_command: \`/swarm ${canonicalKey}\` or ` + `\`/swarm ${canonicalKey} --limit <n>\`.`
|
|
91608
|
-
};
|
|
91609
|
-
}
|
|
91610
|
-
if (canonicalKey === "retrieve") {
|
|
91611
|
-
if (args2.length !== 1 || !SUMMARY_ID_PATTERN.test(args2[0])) {
|
|
91612
|
-
return {
|
|
91613
|
-
allowed: false,
|
|
91614
|
-
message: "Usage through swarm_command: `/swarm retrieve <summary-id>` with a single summary ID such as S1."
|
|
91615
|
-
};
|
|
91616
|
-
}
|
|
91617
|
-
}
|
|
91618
|
-
if (canonicalKey === "benchmark") {
|
|
91619
|
-
const allowedFlags = new Set(["--cumulative", "--ci-gate"]);
|
|
91620
|
-
const invalid = args2.filter((arg) => !allowedFlags.has(arg));
|
|
91621
|
-
if (invalid.length > 0) {
|
|
91622
|
-
return {
|
|
91623
|
-
allowed: false,
|
|
91624
|
-
message: "Only `--cumulative` and `--ci-gate` are supported for `/swarm benchmark` through swarm_command."
|
|
91625
|
-
};
|
|
91626
|
-
}
|
|
91627
|
-
}
|
|
91628
|
-
if (canonicalKey === "show-plan") {
|
|
91629
|
-
if (args2.length > 1 || args2[0] && !/^\d+$/.test(args2[0])) {
|
|
91630
|
-
return {
|
|
91631
|
-
allowed: false,
|
|
91632
|
-
message: "Usage through swarm_command: `/swarm show-plan` or `/swarm show-plan <phase-number>`."
|
|
91633
|
-
};
|
|
91634
|
-
}
|
|
91635
|
-
}
|
|
91636
|
-
if (canonicalKey === "evidence") {
|
|
91637
|
-
if (args2.length > 1 || args2[0] && !TASK_ID_PATTERN.test(args2[0])) {
|
|
91638
|
-
return {
|
|
91639
|
-
allowed: false,
|
|
91640
|
-
message: "Usage through swarm_command: `/swarm evidence` or `/swarm evidence <task-id>`."
|
|
91641
|
-
};
|
|
91642
|
-
}
|
|
91643
|
-
}
|
|
91644
|
-
if (canonicalKey === "help" && args2.length > 2) {
|
|
91645
|
-
return {
|
|
91646
|
-
allowed: false,
|
|
91647
|
-
message: "Usage through swarm_command: `/swarm help` or `/swarm help <command>`."
|
|
91648
|
-
};
|
|
91649
|
-
}
|
|
91650
|
-
return { allowed: true };
|
|
91651
|
-
}
|
|
91652
|
-
function classifySwarmCommandChatFallbackUse(resolved) {
|
|
91653
|
-
const canonicalKey = canonicalCommandKey(resolved);
|
|
91654
|
-
const args2 = resolved.remainingArgs;
|
|
91655
|
-
if (canonicalKey === "config doctor" && args2.some((arg) => arg === "--fix" || arg === "-f")) {
|
|
91656
|
-
return {
|
|
91657
|
-
allowed: false,
|
|
91658
|
-
message: "/swarm config doctor --fix is not available through chat fallback because it can modify configuration files. Run the CLI command directly when you intend to apply fixes."
|
|
91659
|
-
};
|
|
91660
|
-
}
|
|
91661
|
-
if (canonicalKey === "knowledge migrate" || canonicalKey === "knowledge quarantine" || canonicalKey === "knowledge restore" || canonicalKey === "memory import" || canonicalKey === "memory migrate" || canonicalKey === "memory compact" || canonicalKey === "sdd project") {
|
|
91662
|
-
return {
|
|
91663
|
-
allowed: false,
|
|
91664
|
-
message: `/swarm ${canonicalKey} is not available through chat fallback because it mutates .swarm state. ` + "Run the CLI command directly after confirming the intended state change."
|
|
91665
|
-
};
|
|
91666
|
-
}
|
|
91667
|
-
return { allowed: true };
|
|
91668
|
-
}
|
|
91669
|
-
var SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, NO_ARGS, SUMMARY_ID_PATTERN, TASK_ID_PATTERN;
|
|
91670
|
-
var init_tool_policy = __esm(() => {
|
|
91671
|
-
init_command_dispatch();
|
|
91672
|
-
SWARM_COMMAND_TOOL_COMMANDS = [
|
|
91673
|
-
"agents",
|
|
91674
|
-
"config",
|
|
91675
|
-
"config doctor",
|
|
91676
|
-
"doctor tools",
|
|
91677
|
-
"status",
|
|
91678
|
-
"show-plan",
|
|
91679
|
-
"help",
|
|
91680
|
-
"history",
|
|
91681
|
-
"evidence",
|
|
91682
|
-
"evidence summary",
|
|
91683
|
-
"retrieve",
|
|
91684
|
-
"diagnose",
|
|
91685
|
-
"preflight",
|
|
91686
|
-
"benchmark",
|
|
91687
|
-
"knowledge",
|
|
91688
|
-
"memory",
|
|
91689
|
-
"memory status",
|
|
91690
|
-
"memory pending",
|
|
91691
|
-
"memory recall-log",
|
|
91692
|
-
"memory compact",
|
|
91693
|
-
"memory stale",
|
|
91694
|
-
"memory export",
|
|
91695
|
-
"memory evaluate",
|
|
91696
|
-
"memory import",
|
|
91697
|
-
"memory migrate",
|
|
91698
|
-
"sdd",
|
|
91699
|
-
"sdd status",
|
|
91700
|
-
"sdd validate",
|
|
91701
|
-
"sdd project",
|
|
91702
|
-
"sync-plan",
|
|
91703
|
-
"export",
|
|
91704
|
-
"auto-proceed"
|
|
91705
|
-
];
|
|
91706
|
-
SWARM_COMMAND_TOOL_ALLOWLIST = new Set([
|
|
91707
|
-
"agents",
|
|
91708
|
-
"config",
|
|
91709
|
-
"config doctor",
|
|
91710
|
-
"doctor tools",
|
|
91711
|
-
"status",
|
|
91712
|
-
"show-plan",
|
|
91713
|
-
"help",
|
|
91714
|
-
"history",
|
|
91715
|
-
"evidence",
|
|
91716
|
-
"evidence summary",
|
|
91717
|
-
"retrieve",
|
|
91718
|
-
"diagnose",
|
|
91719
|
-
"preflight",
|
|
91720
|
-
"benchmark",
|
|
91721
|
-
"knowledge",
|
|
91722
|
-
"memory",
|
|
91723
|
-
"memory status",
|
|
91724
|
-
"memory pending",
|
|
91725
|
-
"memory recall-log",
|
|
91726
|
-
"memory stale",
|
|
91727
|
-
"memory export",
|
|
91728
|
-
"memory evaluate",
|
|
91729
|
-
"sdd",
|
|
91730
|
-
"sdd status",
|
|
91731
|
-
"sdd validate",
|
|
91732
|
-
"sync-plan",
|
|
91733
|
-
"export",
|
|
91734
|
-
"auto-proceed"
|
|
91735
|
-
]);
|
|
91736
|
-
HUMAN_ONLY_SWARM_COMMANDS = new Set([
|
|
91737
|
-
"acknowledge-spec-drift",
|
|
91738
|
-
"reset",
|
|
91739
|
-
"reset-session",
|
|
91740
|
-
"rollback",
|
|
91741
|
-
"checkpoint",
|
|
91742
|
-
"consolidate",
|
|
91743
|
-
"memory import",
|
|
91744
|
-
"memory migrate",
|
|
91745
|
-
"memory compact",
|
|
91746
|
-
"sdd project"
|
|
91747
|
-
]);
|
|
91748
|
-
NO_ARGS = new Set([
|
|
91749
|
-
"agents",
|
|
91750
|
-
"config",
|
|
91751
|
-
"config doctor",
|
|
91752
|
-
"doctor tools",
|
|
91753
|
-
"status",
|
|
91754
|
-
"history",
|
|
91755
|
-
"evidence summary",
|
|
91756
|
-
"diagnose",
|
|
91757
|
-
"preflight",
|
|
91758
|
-
"sync-plan",
|
|
91759
|
-
"export",
|
|
91760
|
-
"memory",
|
|
91761
|
-
"memory status",
|
|
91762
|
-
"memory export"
|
|
91763
|
-
]);
|
|
91764
|
-
SUMMARY_ID_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
91765
|
-
TASK_ID_PATTERN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
91766
|
-
});
|
|
91767
|
-
|
|
91768
91733
|
// src/commands/command-names.ts
|
|
91769
91734
|
var COMMAND_NAMES, COMMAND_NAME_SET;
|
|
91770
91735
|
var init_command_names = __esm(() => {
|
|
@@ -91982,7 +91947,7 @@ async function buildSwarmCommandPrompt(args2) {
|
|
|
91982
91947
|
packageRoot,
|
|
91983
91948
|
registeredAgents
|
|
91984
91949
|
} = args2;
|
|
91985
|
-
const resolved =
|
|
91950
|
+
const resolved = _internals13.resolveCommand(tokens);
|
|
91986
91951
|
if (!resolved) {
|
|
91987
91952
|
if (tokens.length === 0) {
|
|
91988
91953
|
return buildHelpText();
|
|
@@ -92155,7 +92120,7 @@ function findSimilarCommands(query) {
|
|
|
92155
92120
|
}
|
|
92156
92121
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
92157
92122
|
const cmdLower = cmd.toLowerCase();
|
|
92158
|
-
const fullScore =
|
|
92123
|
+
const fullScore = _internals13.levenshteinDistance(q, cmdLower);
|
|
92159
92124
|
let tokenScore = Infinity;
|
|
92160
92125
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
92161
92126
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -92168,7 +92133,7 @@ function findSimilarCommands(query) {
|
|
|
92168
92133
|
for (const ct of cmdTokens) {
|
|
92169
92134
|
if (ct.length === 0)
|
|
92170
92135
|
continue;
|
|
92171
|
-
const dist =
|
|
92136
|
+
const dist = _internals13.levenshteinDistance(qt, ct);
|
|
92172
92137
|
if (dist < minDist)
|
|
92173
92138
|
minDist = dist;
|
|
92174
92139
|
}
|
|
@@ -92178,7 +92143,7 @@ function findSimilarCommands(query) {
|
|
|
92178
92143
|
}
|
|
92179
92144
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
92180
92145
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
92181
|
-
const dashScore =
|
|
92146
|
+
const dashScore = _internals13.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
92182
92147
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
92183
92148
|
return { cmd, score };
|
|
92184
92149
|
});
|
|
@@ -92210,11 +92175,11 @@ async function handleHelpCommand(ctx) {
|
|
|
92210
92175
|
return buildHelpText2();
|
|
92211
92176
|
}
|
|
92212
92177
|
const tokens = targetCommand.split(/\s+/);
|
|
92213
|
-
const resolved =
|
|
92178
|
+
const resolved = _internals13.resolveCommand(tokens);
|
|
92214
92179
|
if (resolved) {
|
|
92215
|
-
return
|
|
92180
|
+
return _internals13.buildDetailedHelp(resolved.key, resolved.entry);
|
|
92216
92181
|
}
|
|
92217
|
-
const similar =
|
|
92182
|
+
const similar = _internals13.findSimilarCommands(targetCommand);
|
|
92218
92183
|
const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
|
|
92219
92184
|
if (similar.length > 0) {
|
|
92220
92185
|
return `Command '/swarm ${targetCommand}' not found.
|
|
@@ -92285,6 +92250,18 @@ function validateAliases() {
|
|
|
92285
92250
|
}
|
|
92286
92251
|
return { valid: errors5.length === 0, errors: errors5, warnings };
|
|
92287
92252
|
}
|
|
92253
|
+
function validateToolPolicy() {
|
|
92254
|
+
const warnings = [];
|
|
92255
|
+
for (const [name2, entry] of Object.entries(COMMAND_REGISTRY)) {
|
|
92256
|
+
const cmdEntry = entry;
|
|
92257
|
+
if (cmdEntry.aliasOf || cmdEntry.subcommandOf)
|
|
92258
|
+
continue;
|
|
92259
|
+
if (cmdEntry.toolPolicy === undefined) {
|
|
92260
|
+
warnings.push(`Command '${name2}' has no toolPolicy field — it will not be available through the swarm_command tool. Add toolPolicy: 'agent' | 'human-only' | 'restricted' | 'none'.`);
|
|
92261
|
+
}
|
|
92262
|
+
}
|
|
92263
|
+
return { valid: warnings.length === 0, warnings };
|
|
92264
|
+
}
|
|
92288
92265
|
function resolveCommand(tokens) {
|
|
92289
92266
|
if (tokens.length === 0)
|
|
92290
92267
|
return null;
|
|
@@ -92314,7 +92291,7 @@ function resolveCommand(tokens) {
|
|
|
92314
92291
|
}
|
|
92315
92292
|
return null;
|
|
92316
92293
|
}
|
|
92317
|
-
var COMMAND_REGISTRY, VALID_COMMANDS,
|
|
92294
|
+
var COMMAND_REGISTRY, VALID_COMMANDS, _internals13, validation;
|
|
92318
92295
|
var init_registry = __esm(() => {
|
|
92319
92296
|
init_bundled_skills();
|
|
92320
92297
|
init_acknowledge_spec_drift();
|
|
@@ -92370,19 +92347,23 @@ var init_registry = __esm(() => {
|
|
|
92370
92347
|
handler: (ctx) => handleAcknowledgeSpecDriftCommand(ctx.directory, ctx.args, ctx.source === "cli" ? "cli" : ctx.source === "chat" ? "user" : "unknown"),
|
|
92371
92348
|
description: "Acknowledge that the spec has drifted from the plan and suppress further warnings",
|
|
92372
92349
|
args: "",
|
|
92373
|
-
category: "diagnostics"
|
|
92350
|
+
category: "diagnostics",
|
|
92351
|
+
toolPolicy: "restricted"
|
|
92374
92352
|
},
|
|
92375
92353
|
status: {
|
|
92376
92354
|
handler: (ctx) => handleStatusCommand(ctx.directory, ctx.agents),
|
|
92377
92355
|
description: "Show current swarm state",
|
|
92378
92356
|
category: "core",
|
|
92379
|
-
clashesWithNativeCcCommand: "/status"
|
|
92357
|
+
clashesWithNativeCcCommand: "/status",
|
|
92358
|
+
toolPolicy: "agent",
|
|
92359
|
+
toolNoArgs: true
|
|
92380
92360
|
},
|
|
92381
92361
|
"show-plan": {
|
|
92382
92362
|
handler: (ctx) => handlePlanCommand(ctx.directory, ctx.args),
|
|
92383
92363
|
description: "Show current plan (optionally filter by phase number)",
|
|
92384
92364
|
category: "core",
|
|
92385
|
-
args: "[phase-number]"
|
|
92365
|
+
args: "[phase-number]",
|
|
92366
|
+
toolPolicy: "agent"
|
|
92386
92367
|
},
|
|
92387
92368
|
plan: {
|
|
92388
92369
|
handler: (ctx) => handlePlanCommand(ctx.directory, ctx.args),
|
|
@@ -92396,32 +92377,41 @@ var init_registry = __esm(() => {
|
|
|
92396
92377
|
handler: (ctx) => Promise.resolve(handleAgentsCommand(ctx.agents, undefined)),
|
|
92397
92378
|
description: "List registered agents",
|
|
92398
92379
|
category: "core",
|
|
92399
|
-
clashesWithNativeCcCommand: "/agents"
|
|
92380
|
+
clashesWithNativeCcCommand: "/agents",
|
|
92381
|
+
toolPolicy: "agent",
|
|
92382
|
+
toolNoArgs: true
|
|
92400
92383
|
},
|
|
92401
92384
|
help: {
|
|
92402
|
-
handler: (ctx) =>
|
|
92385
|
+
handler: (ctx) => _internals13.handleHelpCommand(ctx),
|
|
92403
92386
|
description: "Show help for swarm commands",
|
|
92404
92387
|
category: "core",
|
|
92405
92388
|
args: "[command]",
|
|
92406
|
-
details: "Without argument, shows full command listing. With argument, shows detailed help for a specific command."
|
|
92389
|
+
details: "Without argument, shows full command listing. With argument, shows detailed help for a specific command.",
|
|
92390
|
+
toolPolicy: "agent"
|
|
92407
92391
|
},
|
|
92408
92392
|
history: {
|
|
92409
92393
|
handler: (ctx) => handleHistoryCommand(ctx.directory, ctx.args),
|
|
92410
92394
|
description: "Show completed phases summary",
|
|
92411
92395
|
category: "utility",
|
|
92412
|
-
clashesWithNativeCcCommand: "/history"
|
|
92396
|
+
clashesWithNativeCcCommand: "/history",
|
|
92397
|
+
toolPolicy: "agent",
|
|
92398
|
+
toolNoArgs: true
|
|
92413
92399
|
},
|
|
92414
92400
|
config: {
|
|
92415
92401
|
handler: (ctx) => handleConfigCommand(ctx.directory, ctx.args),
|
|
92416
92402
|
description: "Show current resolved configuration",
|
|
92417
92403
|
category: "config",
|
|
92418
|
-
clashesWithNativeCcCommand: "/config"
|
|
92404
|
+
clashesWithNativeCcCommand: "/config",
|
|
92405
|
+
toolPolicy: "agent",
|
|
92406
|
+
toolNoArgs: true
|
|
92419
92407
|
},
|
|
92420
92408
|
"config doctor": {
|
|
92421
92409
|
handler: (ctx) => handleDoctorCommand(ctx.directory, ctx.args),
|
|
92422
92410
|
description: "Run config doctor checks",
|
|
92423
92411
|
subcommandOf: "config",
|
|
92424
|
-
category: "diagnostics"
|
|
92412
|
+
category: "diagnostics",
|
|
92413
|
+
toolPolicy: "agent",
|
|
92414
|
+
toolNoArgs: true
|
|
92425
92415
|
},
|
|
92426
92416
|
"config-doctor": {
|
|
92427
92417
|
handler: (ctx) => handleDoctorCommand(ctx.directory, ctx.args),
|
|
@@ -92434,7 +92424,9 @@ var init_registry = __esm(() => {
|
|
|
92434
92424
|
"doctor tools": {
|
|
92435
92425
|
handler: (ctx) => handleDoctorToolsCommand(ctx.directory, ctx.args),
|
|
92436
92426
|
description: "Run tool registration coherence check",
|
|
92437
|
-
category: "diagnostics"
|
|
92427
|
+
category: "diagnostics",
|
|
92428
|
+
toolPolicy: "agent",
|
|
92429
|
+
toolNoArgs: true
|
|
92438
92430
|
},
|
|
92439
92431
|
"doctor-tools": {
|
|
92440
92432
|
handler: (ctx) => handleDoctorToolsCommand(ctx.directory, ctx.args),
|
|
@@ -92446,7 +92438,9 @@ var init_registry = __esm(() => {
|
|
|
92446
92438
|
diagnose: {
|
|
92447
92439
|
handler: (ctx) => handleDiagnoseCommand(ctx.directory, ctx.args),
|
|
92448
92440
|
description: "Run health check on swarm state",
|
|
92449
|
-
category: "diagnostics"
|
|
92441
|
+
category: "diagnostics",
|
|
92442
|
+
toolPolicy: "agent",
|
|
92443
|
+
toolNoArgs: true
|
|
92450
92444
|
},
|
|
92451
92445
|
diagnosis: {
|
|
92452
92446
|
handler: (ctx) => handleDiagnoseCommand(ctx.directory, ctx.args),
|
|
@@ -92458,26 +92452,32 @@ var init_registry = __esm(() => {
|
|
|
92458
92452
|
preflight: {
|
|
92459
92453
|
handler: (ctx) => handlePreflightCommand(ctx.directory, ctx.args),
|
|
92460
92454
|
description: "Run preflight automation checks",
|
|
92461
|
-
category: "diagnostics"
|
|
92455
|
+
category: "diagnostics",
|
|
92456
|
+
toolPolicy: "agent",
|
|
92457
|
+
toolNoArgs: true
|
|
92462
92458
|
},
|
|
92463
92459
|
"sync-plan": {
|
|
92464
92460
|
handler: (ctx) => handleSyncPlanCommand(ctx.directory, ctx.args),
|
|
92465
92461
|
description: "Ensure plan.json and plan.md are synced",
|
|
92466
92462
|
args: "",
|
|
92467
|
-
category: "config"
|
|
92463
|
+
category: "config",
|
|
92464
|
+
toolPolicy: "agent",
|
|
92465
|
+
toolNoArgs: true
|
|
92468
92466
|
},
|
|
92469
92467
|
benchmark: {
|
|
92470
92468
|
handler: (ctx) => handleBenchmarkCommand(ctx.directory, ctx.args),
|
|
92471
92469
|
description: "Show performance metrics [--cumulative] [--ci-gate]",
|
|
92472
92470
|
args: "--cumulative, --ci-gate",
|
|
92473
|
-
category: "diagnostics"
|
|
92471
|
+
category: "diagnostics",
|
|
92472
|
+
toolPolicy: "agent"
|
|
92474
92473
|
},
|
|
92475
92474
|
learning: {
|
|
92476
92475
|
handler: (ctx) => handleLearningCommand(ctx.directory, ctx.args),
|
|
92477
92476
|
description: "Show learning metrics and violation trends",
|
|
92478
92477
|
args: "--json, --phase <N>",
|
|
92479
92478
|
details: "Computes aggregate learning metrics from knowledge events: violation-rate trends, directive application rates, escalation frequency, per-entry ROI, and never-applied entries. Surfaces a learning summary for the curator digest.",
|
|
92480
|
-
category: "diagnostics"
|
|
92479
|
+
category: "diagnostics",
|
|
92480
|
+
toolPolicy: "agent"
|
|
92481
92481
|
},
|
|
92482
92482
|
export: {
|
|
92483
92483
|
handler: (ctx) => handleExportCommand(ctx.directory, ctx.args),
|
|
@@ -92485,14 +92485,17 @@ var init_registry = __esm(() => {
|
|
|
92485
92485
|
args: "",
|
|
92486
92486
|
details: "Exports the current plan and context as JSON to stdout. Useful for piping to external tools or debugging swarm state.",
|
|
92487
92487
|
category: "utility",
|
|
92488
|
-
clashesWithNativeCcCommand: "/export"
|
|
92488
|
+
clashesWithNativeCcCommand: "/export",
|
|
92489
|
+
toolPolicy: "agent",
|
|
92490
|
+
toolNoArgs: true
|
|
92489
92491
|
},
|
|
92490
92492
|
evidence: {
|
|
92491
92493
|
handler: (ctx) => handleEvidenceCommand(ctx.directory, ctx.args),
|
|
92492
92494
|
description: "Show evidence bundles [taskId]",
|
|
92493
92495
|
args: "<taskId>",
|
|
92494
92496
|
details: 'Displays review results, test verdicts, and other evidence bundles for the given task ID (e.g., "2.1").',
|
|
92495
|
-
category: "utility"
|
|
92497
|
+
category: "utility",
|
|
92498
|
+
toolPolicy: "agent"
|
|
92496
92499
|
},
|
|
92497
92500
|
"evidence summary": {
|
|
92498
92501
|
handler: (ctx) => handleEvidenceSummaryCommand(ctx.directory),
|
|
@@ -92500,7 +92503,9 @@ var init_registry = __esm(() => {
|
|
|
92500
92503
|
subcommandOf: "evidence",
|
|
92501
92504
|
args: "",
|
|
92502
92505
|
details: "Generates a summary showing completion ratio across all tasks, lists blockers, and identifies missing evidence.",
|
|
92503
|
-
category: "utility"
|
|
92506
|
+
category: "utility",
|
|
92507
|
+
toolPolicy: "agent",
|
|
92508
|
+
toolNoArgs: true
|
|
92504
92509
|
},
|
|
92505
92510
|
"evidence-summary": {
|
|
92506
92511
|
handler: (ctx) => handleEvidenceSummaryCommand(ctx.directory),
|
|
@@ -92560,13 +92565,15 @@ var init_registry = __esm(() => {
|
|
|
92560
92565
|
description: "Archive old evidence bundles [--dry-run]",
|
|
92561
92566
|
details: "Archives evidence bundles older than max_age_days (config, default 90) or beyond max_bundles cap (config, default 1000). --dry-run previews which bundles would be archived without deleting them. Applies two-tier retention: age-based first, then count-based on oldest remaining.",
|
|
92562
92567
|
args: "--dry-run",
|
|
92563
|
-
category: "utility"
|
|
92568
|
+
category: "utility",
|
|
92569
|
+
toolPolicy: "none"
|
|
92564
92570
|
},
|
|
92565
92571
|
curate: {
|
|
92566
92572
|
handler: (ctx) => handleCurateCommand(ctx.directory, ctx.args),
|
|
92567
92573
|
description: "Run knowledge curation and hive promotion review",
|
|
92568
92574
|
args: "",
|
|
92569
|
-
category: "utility"
|
|
92575
|
+
category: "utility",
|
|
92576
|
+
toolPolicy: "none"
|
|
92570
92577
|
},
|
|
92571
92578
|
consolidate: {
|
|
92572
92579
|
handler: (ctx) => handleConsolidateCommand(ctx.directory, ctx.args, {
|
|
@@ -92575,13 +92582,15 @@ var init_registry = __esm(() => {
|
|
|
92575
92582
|
description: "Run quota-bounded skill-improver consolidation and stage skill proposals",
|
|
92576
92583
|
details: "Runs the same consolidation pass used by scheduled skill_improver trigger points: queue hardening, skill-improver proposal writing, and optional draft-skill generation. It never auto-activates skills. Use --respect-interval to obey the configured cadence instead of forcing a run.",
|
|
92577
92584
|
args: "--force, --respect-interval, --evaluate",
|
|
92578
|
-
category: "utility"
|
|
92585
|
+
category: "utility",
|
|
92586
|
+
toolPolicy: "restricted"
|
|
92579
92587
|
},
|
|
92580
92588
|
"dark-matter": {
|
|
92581
92589
|
handler: (ctx) => handleDarkMatterCommand(ctx.directory, ctx.args),
|
|
92582
92590
|
description: "Detect hidden file couplings via co-change NPMI analysis",
|
|
92583
92591
|
args: "--threshold <number>, --min-commits <number>",
|
|
92584
|
-
category: "diagnostics"
|
|
92592
|
+
category: "diagnostics",
|
|
92593
|
+
toolPolicy: "none"
|
|
92585
92594
|
},
|
|
92586
92595
|
finalize: {
|
|
92587
92596
|
handler: (ctx) => handleCloseCommand(ctx.directory, ctx.args, {
|
|
@@ -92590,7 +92599,8 @@ var init_registry = __esm(() => {
|
|
|
92590
92599
|
description: "Use /swarm finalize to finalize the swarm project and archive evidence",
|
|
92591
92600
|
details: "Idempotent 4-stage terminal finalization: (1) finalize writes retrospectives for in-progress phases, (2) archive creates timestamped bundle of swarm artifacts and evidence, (3) clean removes active-state files for a clean slate, (4) align performs safe git ff-only to main. Resets agent sessions and delegation chains. Reads .swarm/close-lessons.md for explicit lessons and runs curation. Use --skill-review to run the quota-bounded skill_improver in proposal mode.",
|
|
92592
92601
|
args: "--prune-branches, --skill-review",
|
|
92593
|
-
category: "core"
|
|
92602
|
+
category: "core",
|
|
92603
|
+
toolPolicy: "none"
|
|
92594
92604
|
},
|
|
92595
92605
|
close: {
|
|
92596
92606
|
handler: (ctx) => handleCloseCommand(ctx.directory, ctx.args, {
|
|
@@ -92610,7 +92620,8 @@ var init_registry = __esm(() => {
|
|
|
92610
92620
|
description: "Run the post-mortem agent: project-end synthesis, queue triage, and final curation pass",
|
|
92611
92621
|
details: "Reads .swarm/ evidence (knowledge entries, events, curator digests, proposals, retrospectives, drift reports) and produces a post-mortem report at .swarm/post-mortem-{planId}.md. Idempotent: re-runs skip if report exists unless --force is passed.",
|
|
92612
92622
|
args: "--force",
|
|
92613
|
-
category: "core"
|
|
92623
|
+
category: "core",
|
|
92624
|
+
toolPolicy: "agent"
|
|
92614
92625
|
},
|
|
92615
92626
|
concurrency: {
|
|
92616
92627
|
handler: (ctx) => handleConcurrencyCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
@@ -92627,115 +92638,133 @@ Subcommands:
|
|
|
92627
92638
|
` + ` concurrency reset — Clear the session concurrency override
|
|
92628
92639
|
` + `
|
|
92629
92640
|
` + "Session-scoped — resets on new session.",
|
|
92630
|
-
category: "utility"
|
|
92641
|
+
category: "utility",
|
|
92642
|
+
toolPolicy: "none"
|
|
92631
92643
|
},
|
|
92632
92644
|
simulate: {
|
|
92633
92645
|
handler: (ctx) => handleSimulateCommand(ctx.directory, ctx.args),
|
|
92634
92646
|
description: "Dry-run hidden coupling analysis with configurable thresholds",
|
|
92635
92647
|
args: "--threshold <number>, --min-commits <number>",
|
|
92636
|
-
category: "diagnostics"
|
|
92648
|
+
category: "diagnostics",
|
|
92649
|
+
toolPolicy: "none"
|
|
92637
92650
|
},
|
|
92638
92651
|
sdd: {
|
|
92639
92652
|
handler: (ctx) => handleSddCommand(ctx.directory, ctx.args),
|
|
92640
92653
|
description: "Manage OpenSpec-compatible SDD artifacts and effective spec projection",
|
|
92641
92654
|
args: "status|validate|project [--json] [--change <id>] [--dry-run]",
|
|
92642
92655
|
details: "Parent command for spec-driven development artifacts. Use sdd status to inspect .swarm/spec.md plus openspec/ artifacts, sdd validate to validate OpenSpec-compatible deltas, and sdd project to materialize the effective spec into .swarm/spec.md for planning.",
|
|
92643
|
-
category: "utility"
|
|
92656
|
+
category: "utility",
|
|
92657
|
+
toolPolicy: "agent"
|
|
92644
92658
|
},
|
|
92645
92659
|
"sdd status": {
|
|
92646
92660
|
handler: (ctx) => handleSddStatusCommand(ctx.directory, ctx.args),
|
|
92647
92661
|
description: "Show OpenSpec-compatible SDD status and effective spec source",
|
|
92648
92662
|
subcommandOf: "sdd",
|
|
92649
92663
|
args: "[--json]",
|
|
92650
|
-
category: "utility"
|
|
92664
|
+
category: "utility",
|
|
92665
|
+
toolPolicy: "agent"
|
|
92651
92666
|
},
|
|
92652
92667
|
"sdd validate": {
|
|
92653
92668
|
handler: (ctx) => handleSddValidateCommand(ctx.directory, ctx.args),
|
|
92654
92669
|
description: "Validate OpenSpec-compatible artifacts and effective spec projection",
|
|
92655
92670
|
subcommandOf: "sdd",
|
|
92656
92671
|
args: "[--json] [--change <id>]",
|
|
92657
|
-
category: "utility"
|
|
92672
|
+
category: "utility",
|
|
92673
|
+
toolPolicy: "agent"
|
|
92658
92674
|
},
|
|
92659
92675
|
"sdd project": {
|
|
92660
92676
|
handler: (ctx) => handleSddProjectCommand(ctx.directory, ctx.args),
|
|
92661
92677
|
description: "Materialize the OpenSpec-compatible effective spec into .swarm/spec.md",
|
|
92662
92678
|
subcommandOf: "sdd",
|
|
92663
92679
|
args: "[--dry-run] [--json] [--change <id>]",
|
|
92664
|
-
category: "utility"
|
|
92680
|
+
category: "utility",
|
|
92681
|
+
toolPolicy: "human-only"
|
|
92665
92682
|
},
|
|
92666
92683
|
analyze: {
|
|
92667
92684
|
handler: (ctx) => handleAnalyzeCommand(ctx.directory, ctx.args),
|
|
92668
92685
|
description: "Analyze spec.md vs plan.md for requirement coverage gaps",
|
|
92669
92686
|
args: "",
|
|
92670
|
-
category: "agent"
|
|
92687
|
+
category: "agent",
|
|
92688
|
+
toolPolicy: "none"
|
|
92671
92689
|
},
|
|
92672
92690
|
clarify: {
|
|
92673
92691
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleClarifyCommand),
|
|
92674
92692
|
description: "Clarify and refine an existing feature specification",
|
|
92675
92693
|
args: "[description-text]",
|
|
92676
|
-
category: "agent"
|
|
92694
|
+
category: "agent",
|
|
92695
|
+
toolPolicy: "none"
|
|
92677
92696
|
},
|
|
92678
92697
|
specify: {
|
|
92679
92698
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleSpecifyCommand),
|
|
92680
92699
|
description: "Generate or import a feature specification [description]",
|
|
92681
92700
|
args: "[description-text]",
|
|
92682
|
-
category: "agent"
|
|
92701
|
+
category: "agent",
|
|
92702
|
+
toolPolicy: "none"
|
|
92683
92703
|
},
|
|
92684
92704
|
brainstorm: {
|
|
92685
92705
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleBrainstormCommand),
|
|
92686
92706
|
description: "Enter architect MODE: BRAINSTORM — structured seven-phase planning workflow [topic]",
|
|
92687
92707
|
args: "[topic-text]",
|
|
92688
92708
|
details: "Triggers the architect to run the brainstorm workflow: CONTEXT SCAN, single-question DIALOGUE, APPROACHES, DESIGN SECTIONS, SPEC WRITE + SELF-REVIEW, QA GATE SELECTION, TRANSITION. Use for new plans where requirements need to be drawn out before writing spec.md / plan.md.",
|
|
92689
|
-
category: "agent"
|
|
92709
|
+
category: "agent",
|
|
92710
|
+
toolPolicy: "none"
|
|
92690
92711
|
},
|
|
92691
92712
|
council: {
|
|
92692
92713
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleCouncilCommand),
|
|
92693
92714
|
description: "Enter architect MODE: COUNCIL — multi-model deliberation [question] [--preset <name>] [--spec-review]",
|
|
92694
92715
|
args: "<question> [--preset <name>] [--spec-review]",
|
|
92695
92716
|
details: "Triggers the architect to convene a three-agent General Council: Generalist (reviewer model), Skeptic (critic model), and Domain Expert (SME model). Use --preset <name> to choose a named member preset from council.general.presets. " + "The architect first runs 1–3 targeted web searches and passes a compiled RESEARCH CONTEXT " + "to all three agents before dispatching them in parallel. Agents deliberate using the NSED peer-review protocol (Round 1 independent analysis, Round 2 MAINTAIN/CONCEDE/NUANCE for disagreements). The architect synthesizes the final answer directly from convene_general_council output. --spec-review switches to single-pass advisory mode for spec review. Requires council.general.enabled: true and a search API key in the resolved config: global ~/.config/opencode/opencode-swarm.json, then project .opencode/opencode-swarm.json overrides.",
|
|
92696
|
-
category: "agent"
|
|
92717
|
+
category: "agent",
|
|
92718
|
+
toolPolicy: "none"
|
|
92697
92719
|
},
|
|
92698
92720
|
"pr-review": {
|
|
92699
92721
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handlePrReviewCommand),
|
|
92700
92722
|
description: "Launch deep PR review with multi-lane analysis [url] [--council]",
|
|
92701
92723
|
args: "<pr-url|owner/repo#N|N> [--council]",
|
|
92702
92724
|
details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes through the deterministic dispatch_lanes join barrier (correctness, security, dependencies, docs-intent-vs-actual, tests, performance-architecture), validates findings through independent reviewer confirmation, applies critic challenge to HIGH/CRITICAL findings, synthesizes structured report. --council variant fires adversarial multi-model review. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolves against origin remote).",
|
|
92703
|
-
category: "agent"
|
|
92725
|
+
category: "agent",
|
|
92726
|
+
toolPolicy: "none"
|
|
92704
92727
|
},
|
|
92705
92728
|
"pr-feedback": {
|
|
92706
92729
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handlePrFeedbackCommand),
|
|
92707
92730
|
description: "Ingest and close known PR feedback (review comments, CI failures, conflicts) [pr] [instructions]",
|
|
92708
92731
|
args: "[url|owner/repo#N|N] [instructions...]",
|
|
92709
92732
|
details: "Triggers MODE: PR_FEEDBACK — ingests existing pull-request feedback (review threads, requested changes, CI/check failures, merge conflicts, stale branch state, pasted notes), verifies every claim against source, clusters related problems, fixes confirmed items, validates the branch, and reports closure status for every ledger item. Distinct from /swarm pr-review, which discovers new findings. The PR reference is optional: with none, the architect builds the ledger from the current PR/branch; text after the reference is forwarded as extra instructions. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin).",
|
|
92710
|
-
category: "agent"
|
|
92733
|
+
category: "agent",
|
|
92734
|
+
toolPolicy: "none"
|
|
92711
92735
|
},
|
|
92712
92736
|
"pr subscribe": {
|
|
92713
92737
|
handler: (ctx) => handlePrSubscribeCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92714
92738
|
description: "Subscribe the current session to PR state-change notifications",
|
|
92715
92739
|
args: "<pr-url|owner/repo#N|N>",
|
|
92716
92740
|
details: "Subscribes the current session to receive advisory notifications for the specified PR. When pr_monitor.enabled is true, the background polling worker will detect CI failures, new comments, merge conflicts, review state changes, and merge/close events. Notifications are delivered as session-scoped advisories with dedup tokens. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin). Requires pr_monitor.enabled: true in config.",
|
|
92717
|
-
category: "agent"
|
|
92741
|
+
category: "agent",
|
|
92742
|
+
toolPolicy: "human-only"
|
|
92718
92743
|
},
|
|
92719
92744
|
"pr unsubscribe": {
|
|
92720
92745
|
handler: (ctx) => handlePrUnsubscribeCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92721
92746
|
description: "Unsubscribe the current session from PR state-change notifications",
|
|
92722
92747
|
args: "<pr-url|owner/repo#N|N>",
|
|
92723
92748
|
details: "Unsubscribes the current session from receiving advisory notifications for the specified PR. Removes the active subscription record. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin).",
|
|
92724
|
-
category: "agent"
|
|
92749
|
+
category: "agent",
|
|
92750
|
+
toolPolicy: "human-only"
|
|
92725
92751
|
},
|
|
92726
92752
|
"pr status": {
|
|
92727
92753
|
handler: (ctx) => handlePrMonitorStatusCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92728
92754
|
description: "Show PR monitor subscription status for the current session",
|
|
92729
92755
|
args: "",
|
|
92730
92756
|
details: "Displays all active PR subscriptions for the current session. Shows PR URL, last checked time, watching status, and error count per subscription. Also shows total active subscriptions across all sessions.",
|
|
92731
|
-
category: "agent"
|
|
92757
|
+
category: "agent",
|
|
92758
|
+
toolPolicy: "agent",
|
|
92759
|
+
toolNoArgs: true
|
|
92732
92760
|
},
|
|
92733
92761
|
"deep-dive": {
|
|
92734
92762
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDeepDiveCommand),
|
|
92735
92763
|
description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]",
|
|
92736
92764
|
args: "<scope> [--profile standard|security|ux|architecture|full] [--max-explorers 1..8] [--json] [--skip-update] [--allow-dirty]",
|
|
92737
92765
|
details: "Runs a read-only deep audit of the specified scope using parallel explorer waves (8-file cap per mission, ~3500 line guardrail), always 2 parallel reviewers for verification, and sequential critic challenge on HIGH/CRITICAL findings. Profiles select explorer lanes: standard (5 lanes), security, ux, architecture, full (all 8 lanes). Emits a structured findings report without mutating source code.",
|
|
92738
|
-
category: "agent"
|
|
92766
|
+
category: "agent",
|
|
92767
|
+
toolPolicy: "none"
|
|
92739
92768
|
},
|
|
92740
92769
|
"deep dive": {
|
|
92741
92770
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDeepDiveCommand),
|
|
@@ -92749,7 +92778,8 @@ Subcommands:
|
|
|
92749
92778
|
description: "Launch a multi-source, fact-checked deep research pass and synthesize a cited report [question]",
|
|
92750
92779
|
args: "<question> [--depth standard|exhaustive] [--max-researchers 1..6] [--rounds 1..4] [--brief]",
|
|
92751
92780
|
details: "Runs the orchestrator-worker deep-research protocol: the architect decomposes the question into subtopics, gathers evidence with web_search and web_fetch across up to N iterative rounds, dispatches parallel sme synthesis workers, verifies every claim against cited sources with dual reviewers, challenges high-stakes claims with the critic, and presents a cited report in chat. Read-only — does not mutate source code, delegate to coder, or call declare_scope. Requires council.general.enabled and a search API key.",
|
|
92752
|
-
category: "agent"
|
|
92781
|
+
category: "agent",
|
|
92782
|
+
toolPolicy: "none"
|
|
92753
92783
|
},
|
|
92754
92784
|
"deep research": {
|
|
92755
92785
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDeepResearchCommand),
|
|
@@ -92763,7 +92793,8 @@ Subcommands:
|
|
|
92763
92793
|
description: "Launch codebase-review-swarm for a quote-grounded full-repo or large-subsystem audit",
|
|
92764
92794
|
args: "[scope] [--mode phase0|complete|defect|security|correctness|testing|ui|performance|ai-slop|enhancements|custom] [--tracks <list>] [--continue <run-id>] [--json] [--skip-update] [--allow-dirty]",
|
|
92765
92795
|
details: "Runs the codebase-review-swarm workflow: Phase 0 inventory, selected-track depth planning, non-diluting review passes, coverage closure, reviewer validation, critic challenge, and .swarm/review-v8 artifacts. Materializes the bundled skill package if missing, then emits a MODE signal; the architect workflow must not mutate source files.",
|
|
92766
|
-
category: "agent"
|
|
92796
|
+
category: "agent",
|
|
92797
|
+
toolPolicy: "none"
|
|
92767
92798
|
},
|
|
92768
92799
|
"codebase review": {
|
|
92769
92800
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleCodebaseReviewCommand),
|
|
@@ -92777,7 +92808,8 @@ Subcommands:
|
|
|
92777
92808
|
description: "Generate or sync language-agnostic design docs (domain, technical-spec, behavior-spec, reference/) for the project under build [description]",
|
|
92778
92809
|
args: "<description> [--out <dir>] [--lang <name>] [--update]",
|
|
92779
92810
|
details: "Triggers the architect to enter MODE: DESIGN_DOCS — delegates to the docs_design agent to author/sync docs/domain.md, docs/technical-spec.md, docs/behavior-spec.md, and docs/reference/* (plus reference/traceability.json and design-changelog.md). Normative docs are 100% language-agnostic; all framework-specific material is quarantined under reference/. --update syncs existing docs to current code/spec instead of generating fresh. Requires design_docs.enabled: true.",
|
|
92780
|
-
category: "agent"
|
|
92811
|
+
category: "agent",
|
|
92812
|
+
toolPolicy: "none"
|
|
92781
92813
|
},
|
|
92782
92814
|
"design docs": {
|
|
92783
92815
|
handler: (ctx) => handleModeCommandWithBundledSkills(ctx, handleDesignDocsCommand),
|
|
@@ -92791,21 +92823,24 @@ Subcommands:
|
|
|
92791
92823
|
description: "Ingest a GitHub issue into the swarm workflow [url] [--plan] [--trace] [--no-repro]",
|
|
92792
92824
|
args: "<issue-url|owner/repo#N|N> [--plan] [--trace] [--no-repro]",
|
|
92793
92825
|
details: "Triggers the architect to enter MODE: ISSUE_INGEST — ingests a GitHub issue, restructures it into a normalized intake note, localizes root cause through hypothesis-driven tracing, and outputs a resolution spec. --plan transitions to plan creation after spec generation. --trace runs the full fix-and-PR workflow (implies --plan). --no-repro skips the reproduction step. Supports full GitHub URL, owner/repo#N shorthand, or bare issue number (resolves against origin remote).",
|
|
92794
|
-
category: "agent"
|
|
92826
|
+
category: "agent",
|
|
92827
|
+
toolPolicy: "none"
|
|
92795
92828
|
},
|
|
92796
92829
|
"qa-gates": {
|
|
92797
92830
|
handler: (ctx) => handleQaGatesCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92798
92831
|
description: "View or modify QA gate profile for the current plan [enable|override <gate>...]",
|
|
92799
92832
|
args: "[show|enable|override] <gate>...",
|
|
92800
92833
|
details: "show: display spec-level, session-override, and effective QA gates for the current plan. enable: persist gate(s) into the locked-once profile (architect; rejected after critic approval lock). override: session-only ratchet-tighter enable. Valid gates: reviewer, test_engineer, council_mode, sme_enabled, critic_pre_plan, hallucination_guard, sast_enabled, mutation_test, phase_council, drift_check, final_council.",
|
|
92801
|
-
category: "config"
|
|
92834
|
+
category: "config",
|
|
92835
|
+
toolPolicy: "none"
|
|
92802
92836
|
},
|
|
92803
92837
|
promote: {
|
|
92804
92838
|
handler: (ctx) => handlePromoteCommand(ctx.directory, ctx.args),
|
|
92805
92839
|
description: "Manually promote lesson to hive knowledge",
|
|
92806
92840
|
details: "Promotes a lesson directly to hive knowledge (--category flag sets category) or references an existing swarm lesson by ID (--from-swarm). Validates lesson text before promotion. Either direct text or --from-swarm ID is required.",
|
|
92807
92841
|
args: "--category <category>, --from-swarm <lesson-id>, <lesson-text>",
|
|
92808
|
-
category: "utility"
|
|
92842
|
+
category: "utility",
|
|
92843
|
+
toolPolicy: "none"
|
|
92809
92844
|
},
|
|
92810
92845
|
reset: {
|
|
92811
92846
|
handler: (ctx) => handleResetCommand(ctx.directory, ctx.args),
|
|
@@ -92813,35 +92848,40 @@ Subcommands:
|
|
|
92813
92848
|
details: "DELETES plan.md, context.md, and summaries/ directory from .swarm/. Stops background automation and clears in-memory queues. SAFETY: requires --confirm flag — without it, displays a warning and tips to export first.",
|
|
92814
92849
|
args: "--confirm (required)",
|
|
92815
92850
|
category: "utility",
|
|
92816
|
-
clashesWithNativeCcCommand: "/reset"
|
|
92851
|
+
clashesWithNativeCcCommand: "/reset",
|
|
92852
|
+
toolPolicy: "restricted"
|
|
92817
92853
|
},
|
|
92818
92854
|
"reset-session": {
|
|
92819
92855
|
handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args),
|
|
92820
92856
|
description: "Clear session state while preserving plan, evidence, and knowledge",
|
|
92821
92857
|
details: "Deletes only .swarm/session/state.json and any other session files. Clears in-memory agent sessions and delegation chains. Preserves plan, evidence, and knowledge for cross-session continuity.",
|
|
92822
92858
|
args: "",
|
|
92823
|
-
category: "utility"
|
|
92859
|
+
category: "utility",
|
|
92860
|
+
toolPolicy: "restricted"
|
|
92824
92861
|
},
|
|
92825
92862
|
rollback: {
|
|
92826
92863
|
handler: (ctx) => handleRollbackCommand(ctx.directory, ctx.args),
|
|
92827
92864
|
description: "Restore swarm state to a checkpoint <phase>",
|
|
92828
92865
|
details: "Restores .swarm/ state by directly overwriting files from a checkpoint directory (checkpoints/phase-<N>). Writes rollback event to events.jsonl. Without phase argument, lists available checkpoints. Partial failures are reported but processing continues.",
|
|
92829
92866
|
args: "<phase-number>",
|
|
92830
|
-
category: "utility"
|
|
92867
|
+
category: "utility",
|
|
92868
|
+
toolPolicy: "restricted"
|
|
92831
92869
|
},
|
|
92832
92870
|
retrieve: {
|
|
92833
92871
|
handler: (ctx) => handleRetrieveCommand(ctx.directory, ctx.args),
|
|
92834
92872
|
description: "Retrieve full output from a summary <id>",
|
|
92835
92873
|
args: "<summary-id>",
|
|
92836
92874
|
details: "Loads the full tool output that was previously summarized (referenced by IDs like S1, S2). Use when you need the complete output instead of the truncated summary.",
|
|
92837
|
-
category: "utility"
|
|
92875
|
+
category: "utility",
|
|
92876
|
+
toolPolicy: "agent"
|
|
92838
92877
|
},
|
|
92839
92878
|
handoff: {
|
|
92840
92879
|
handler: (ctx) => handleHandoffCommand(ctx.directory, ctx.args),
|
|
92841
92880
|
description: "Prepare state for clean model switch (new session)",
|
|
92842
92881
|
args: "",
|
|
92843
92882
|
details: "Generates handoff.md with full session state snapshot, including plan progress, recent decisions, and agent delegation history. Prepended to the next session prompt for seamless model switches.",
|
|
92844
|
-
category: "core"
|
|
92883
|
+
category: "core",
|
|
92884
|
+
toolPolicy: "none"
|
|
92845
92885
|
},
|
|
92846
92886
|
turbo: {
|
|
92847
92887
|
handler: (ctx) => handleTurboCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
@@ -92863,28 +92903,32 @@ Subcommands:
|
|
|
92863
92903
|
` + ` turbo status — show detailed status including active strategy and lanes
|
|
92864
92904
|
` + `
|
|
92865
92905
|
` + "Session-scoped — resets on new session.",
|
|
92866
|
-
category: "utility"
|
|
92906
|
+
category: "utility",
|
|
92907
|
+
toolPolicy: "none"
|
|
92867
92908
|
},
|
|
92868
92909
|
"full-auto": {
|
|
92869
92910
|
handler: (ctx) => handleFullAutoCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92870
92911
|
description: "Toggle Full-Auto Mode for the active session [on [mode]|off|status]",
|
|
92871
92912
|
args: "on [assisted|supervised|strict], off, status",
|
|
92872
92913
|
details: 'First-class toggle for Full-Auto Mode — autonomous execution with the critic reviewing escalations on your behalf. No config-level enablement is required: "on" activates immediately (unless full_auto.locked is true in config), "off" disarms the run and returns the session to normal interactive operation, "status" reports the durable run state. ' + 'An optional mode after "on" overrides full_auto.mode for this run: assisted (critic consulted only on policy escalations), supervised (default — risky/high-impact actions reviewed by the critic), strict (ALL plan mutations reviewed by the critic). ' + "While active, the critic answers architect questions and reviews phase boundaries, delegations, and risky actions on your behalf; only ESCALATE_TO_HUMAN verdicts halt the run for your input. The run state is durable (.swarm/full-auto-state.json) and survives restarts; toggle with no argument flips the current state.",
|
|
92873
|
-
category: "utility"
|
|
92914
|
+
category: "utility",
|
|
92915
|
+
toolPolicy: "none"
|
|
92874
92916
|
},
|
|
92875
92917
|
"auto-proceed": {
|
|
92876
92918
|
handler: (ctx) => handleAutoProceedCommand(ctx.directory, ctx.args, ctx.sessionID),
|
|
92877
92919
|
description: "Toggle or set auto-proceed override for the active session",
|
|
92878
92920
|
args: "[on|off]",
|
|
92879
92921
|
category: "config",
|
|
92880
|
-
details: 'Without argument, toggles auto-proceed mode. With "on" or "off", sets the state explicitly.'
|
|
92922
|
+
details: 'Without argument, toggles auto-proceed mode. With "on" or "off", sets the state explicitly.',
|
|
92923
|
+
toolPolicy: "agent"
|
|
92881
92924
|
},
|
|
92882
92925
|
"write-retro": {
|
|
92883
92926
|
handler: (ctx) => handleWriteRetroCommand(ctx.directory, ctx.args),
|
|
92884
92927
|
description: "Write a retrospective evidence bundle for a completed phase <json>",
|
|
92885
92928
|
details: "Writes retrospective evidence bundle to .swarm/evidence/retro-{phase}/evidence.json. Required JSON: phase, summary, task_count, task_complexity, total_tool_calls, coder_revisions, reviewer_rejections, test_failures, security_findings, integration_issues. Optional: lessons_learned (max 5), top_rejection_reasons, task_id, metadata.",
|
|
92886
92929
|
args: "<json: {phase, summary, task_count, task_complexity, ...}>",
|
|
92887
|
-
category: "utility"
|
|
92930
|
+
category: "utility",
|
|
92931
|
+
toolPolicy: "none"
|
|
92888
92932
|
},
|
|
92889
92933
|
"knowledge migrate": {
|
|
92890
92934
|
handler: (ctx) => handleKnowledgeMigrateCommand(ctx.directory, ctx.args),
|
|
@@ -92928,75 +92972,89 @@ Subcommands:
|
|
|
92928
92972
|
knowledge: {
|
|
92929
92973
|
handler: (ctx) => handleKnowledgeListCommand(ctx.directory, ctx.args),
|
|
92930
92974
|
description: "List knowledge entries",
|
|
92931
|
-
category: "utility"
|
|
92975
|
+
category: "utility",
|
|
92976
|
+
toolPolicy: "agent"
|
|
92932
92977
|
},
|
|
92933
92978
|
memory: {
|
|
92934
92979
|
handler: (ctx) => handleMemoryCommand(ctx.directory, ctx.args),
|
|
92935
92980
|
description: "Show Swarm memory commands",
|
|
92936
|
-
category: "utility"
|
|
92981
|
+
category: "utility",
|
|
92982
|
+
toolPolicy: "agent",
|
|
92983
|
+
toolNoArgs: true
|
|
92937
92984
|
},
|
|
92938
92985
|
"memory status": {
|
|
92939
92986
|
handler: (ctx) => handleMemoryStatusCommand(ctx.directory, ctx.args),
|
|
92940
92987
|
description: "Show Swarm memory provider, JSONL, and migration status",
|
|
92941
92988
|
subcommandOf: "memory",
|
|
92942
92989
|
args: "",
|
|
92943
|
-
category: "diagnostics"
|
|
92990
|
+
category: "diagnostics",
|
|
92991
|
+
toolPolicy: "agent",
|
|
92992
|
+
toolNoArgs: true
|
|
92944
92993
|
},
|
|
92945
92994
|
"memory pending": {
|
|
92946
92995
|
handler: (ctx) => handleMemoryPendingCommand(ctx.directory, ctx.args),
|
|
92947
92996
|
description: "Show pending Swarm memory proposals and rejection reasons",
|
|
92948
92997
|
subcommandOf: "memory",
|
|
92949
92998
|
args: "--limit <n>",
|
|
92950
|
-
category: "diagnostics"
|
|
92999
|
+
category: "diagnostics",
|
|
93000
|
+
toolPolicy: "agent"
|
|
92951
93001
|
},
|
|
92952
93002
|
"memory recall-log": {
|
|
92953
93003
|
handler: (ctx) => handleMemoryRecallLogCommand(ctx.directory, ctx.args),
|
|
92954
93004
|
description: "Summarize Swarm memory recall usage",
|
|
92955
93005
|
subcommandOf: "memory",
|
|
92956
93006
|
args: "--limit <n>",
|
|
92957
|
-
category: "diagnostics"
|
|
93007
|
+
category: "diagnostics",
|
|
93008
|
+
toolPolicy: "agent"
|
|
92958
93009
|
},
|
|
92959
93010
|
"memory compact": {
|
|
92960
93011
|
handler: (ctx) => handleMemoryCompactCommand(ctx.directory, ctx.args),
|
|
92961
93012
|
description: "Compact deleted, superseded, and expired scratch memories",
|
|
92962
93013
|
subcommandOf: "memory",
|
|
92963
93014
|
args: "--confirm",
|
|
92964
|
-
category: "utility"
|
|
93015
|
+
category: "utility",
|
|
93016
|
+
toolPolicy: "human-only"
|
|
92965
93017
|
},
|
|
92966
93018
|
"memory stale": {
|
|
92967
93019
|
handler: (ctx) => handleMemoryStaleCommand(ctx.directory, ctx.args),
|
|
92968
93020
|
description: "List stale and low-utility Swarm memories",
|
|
92969
93021
|
subcommandOf: "memory",
|
|
92970
93022
|
args: "--limit <n>",
|
|
92971
|
-
category: "diagnostics"
|
|
93023
|
+
category: "diagnostics",
|
|
93024
|
+
toolPolicy: "agent"
|
|
92972
93025
|
},
|
|
92973
93026
|
"memory export": {
|
|
92974
93027
|
handler: (ctx) => handleMemoryExportCommand(ctx.directory, ctx.args),
|
|
92975
93028
|
description: "Export current Swarm memory to JSONL files",
|
|
92976
93029
|
subcommandOf: "memory",
|
|
92977
93030
|
args: "",
|
|
92978
|
-
category: "utility"
|
|
93031
|
+
category: "utility",
|
|
93032
|
+
toolPolicy: "agent",
|
|
93033
|
+
toolNoArgs: true
|
|
92979
93034
|
},
|
|
92980
93035
|
"memory evaluate": {
|
|
92981
93036
|
handler: (ctx) => handleMemoryEvaluateCommand(ctx.directory, ctx.args),
|
|
92982
93037
|
description: "Run golden Swarm memory recall evaluation fixtures",
|
|
92983
93038
|
subcommandOf: "memory",
|
|
92984
93039
|
args: "--json, --fixtures <directory>",
|
|
92985
|
-
category: "diagnostics"
|
|
93040
|
+
category: "diagnostics",
|
|
93041
|
+
toolPolicy: "agent"
|
|
92986
93042
|
},
|
|
92987
93043
|
"memory import": {
|
|
92988
93044
|
handler: (ctx) => handleMemoryImportCommand(ctx.directory, ctx.args),
|
|
92989
93045
|
description: "Import legacy JSONL memory into SQLite",
|
|
92990
93046
|
subcommandOf: "memory",
|
|
92991
93047
|
args: "",
|
|
92992
|
-
category: "utility"
|
|
93048
|
+
category: "utility",
|
|
93049
|
+
toolPolicy: "human-only"
|
|
92993
93050
|
},
|
|
92994
93051
|
"memory migrate": {
|
|
92995
93052
|
handler: (ctx) => handleMemoryMigrateCommand(ctx.directory, ctx.args),
|
|
92996
93053
|
description: "Run the one-time legacy JSONL to SQLite migration",
|
|
92997
93054
|
subcommandOf: "memory",
|
|
92998
93055
|
args: "",
|
|
92999
|
-
category: "utility"
|
|
93056
|
+
category: "utility",
|
|
93057
|
+
toolPolicy: "human-only"
|
|
93000
93058
|
},
|
|
93001
93059
|
checkpoint: {
|
|
93002
93060
|
handler: (ctx) => handleCheckpointCommand(ctx.directory, ctx.args),
|
|
@@ -93004,19 +93062,21 @@ Subcommands:
|
|
|
93004
93062
|
details: "save: creates named snapshot of current .swarm/ state. restore: soft-resets to checkpoint by overwriting current .swarm/ files. delete: removes named checkpoint. list: shows all checkpoints with timestamps. All subcommands require a label except list.",
|
|
93005
93063
|
args: "<save|restore|delete|list> <label>",
|
|
93006
93064
|
category: "utility",
|
|
93007
|
-
clashesWithNativeCcCommand: "/checkpoint"
|
|
93065
|
+
clashesWithNativeCcCommand: "/checkpoint",
|
|
93066
|
+
toolPolicy: "restricted"
|
|
93008
93067
|
}
|
|
93009
93068
|
};
|
|
93010
93069
|
VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
|
|
93011
|
-
|
|
93070
|
+
_internals13 = {
|
|
93012
93071
|
handleHelpCommand,
|
|
93013
93072
|
validateAliases,
|
|
93073
|
+
validateToolPolicy,
|
|
93014
93074
|
resolveCommand,
|
|
93015
93075
|
levenshteinDistance: levenshteinDistance2,
|
|
93016
93076
|
findSimilarCommands,
|
|
93017
93077
|
buildDetailedHelp
|
|
93018
93078
|
};
|
|
93019
|
-
validation =
|
|
93079
|
+
validation = _internals13.validateAliases();
|
|
93020
93080
|
if (!validation.valid) {
|
|
93021
93081
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
93022
93082
|
${validation.errors.join(`
|
|
@@ -93027,6 +93087,16 @@ ${validation.errors.join(`
|
|
|
93027
93087
|
${validation.warnings.join(`
|
|
93028
93088
|
`)}`);
|
|
93029
93089
|
}
|
|
93090
|
+
try {
|
|
93091
|
+
const toolPolicyValidation = _internals13.validateToolPolicy();
|
|
93092
|
+
if (toolPolicyValidation.warnings.length > 0) {
|
|
93093
|
+
console.warn(`COMMAND_REGISTRY toolPolicy warnings:
|
|
93094
|
+
${toolPolicyValidation.warnings.join(`
|
|
93095
|
+
`)}`);
|
|
93096
|
+
}
|
|
93097
|
+
} catch (e) {
|
|
93098
|
+
console.warn(`COMMAND_REGISTRY toolPolicy validation failed (non-fatal): ${e.message}`);
|
|
93099
|
+
}
|
|
93030
93100
|
});
|
|
93031
93101
|
|
|
93032
93102
|
// src/agents/architect.ts
|
|
@@ -104798,6 +104868,7 @@ function createBackgroundCompletionObserver(opts) {
|
|
|
104798
104868
|
// src/index.ts
|
|
104799
104869
|
init_pr_subscriptions();
|
|
104800
104870
|
init_commands();
|
|
104871
|
+
init_registry();
|
|
104801
104872
|
init_config();
|
|
104802
104873
|
init_bundled_skills();
|
|
104803
104874
|
init_constants();
|
|
@@ -105513,7 +105584,7 @@ async function writeFullAutoOversightEvidence(directory, phase, event) {
|
|
|
105513
105584
|
}
|
|
105514
105585
|
}
|
|
105515
105586
|
async function dispatchFullAutoOversight(input) {
|
|
105516
|
-
const client =
|
|
105587
|
+
const client = _internals21.swarmState.opencodeClient;
|
|
105517
105588
|
const sequence = nextFullAutoOversightSequence(input.directory);
|
|
105518
105589
|
oversightSequenceCounter = sequence;
|
|
105519
105590
|
const beforeStatus = loadFullAutoRunState(input.directory, input.sessionID)?.status;
|
|
@@ -107494,7 +107565,7 @@ Critic reasoning: ${criticResult.reasoning}`
|
|
|
107494
107565
|
}
|
|
107495
107566
|
}
|
|
107496
107567
|
async function dispatchCriticAndWriteEvent(directory, architectOutput, criticContext, criticModel, escalationType, interactionCount, deadlockCount, oversightAgentName, sessionID) {
|
|
107497
|
-
const client =
|
|
107568
|
+
const client = _internals21.swarmState.opencodeClient;
|
|
107498
107569
|
if (!client) {
|
|
107499
107570
|
warn("[full-auto-intercept] No opencodeClient — critic dispatch skipped (fallback to PENDING)");
|
|
107500
107571
|
const result = {
|
|
@@ -107621,11 +107692,11 @@ function createFullAutoInterceptHook(config3, directory) {
|
|
|
107621
107692
|
if (!architectText)
|
|
107622
107693
|
return;
|
|
107623
107694
|
const sessionID = architectMessage.info?.sessionID;
|
|
107624
|
-
if (!
|
|
107695
|
+
if (!_internals21.hasActiveFullAuto(sessionID))
|
|
107625
107696
|
return;
|
|
107626
107697
|
let session = null;
|
|
107627
107698
|
if (sessionID) {
|
|
107628
|
-
session =
|
|
107699
|
+
session = _internals21.ensureAgentSession(sessionID);
|
|
107629
107700
|
}
|
|
107630
107701
|
if (session) {
|
|
107631
107702
|
const interactionCount = session.fullAutoInteractionCount ?? 0;
|
|
@@ -110280,11 +110351,13 @@ init_path_security();
|
|
|
110280
110351
|
import { constants as constants5, existsSync as existsSync64, readFileSync as readFileSync44, statSync as statSync24 } from "node:fs";
|
|
110281
110352
|
import * as fsPromises6 from "node:fs/promises";
|
|
110282
110353
|
import * as path111 from "node:path";
|
|
110354
|
+
var WINDOWS_RENAME_MAX_RETRIES2 = 5;
|
|
110355
|
+
var WINDOWS_RENAME_RETRY_DELAY_MS2 = 100;
|
|
110283
110356
|
var _internals68 = {
|
|
110284
|
-
safeRealpathSync
|
|
110357
|
+
safeRealpathSync,
|
|
110358
|
+
fsRename: fsPromises6.rename.bind(fsPromises6),
|
|
110359
|
+
retryDelayMs: WINDOWS_RENAME_RETRY_DELAY_MS2
|
|
110285
110360
|
};
|
|
110286
|
-
var WINDOWS_RENAME_MAX_RETRIES2 = 3;
|
|
110287
|
-
var WINDOWS_RENAME_RETRY_DELAY_MS2 = 50;
|
|
110288
110361
|
function validateLoadedGraph(parsed) {
|
|
110289
110362
|
if (!parsed.schema_version) {
|
|
110290
110363
|
throw Object.assign(new Error("repo-graph.json missing schema_version"), {
|
|
@@ -110466,21 +110539,25 @@ async function saveGraph(workspace, graph, options) {
|
|
|
110466
110539
|
throw lastError;
|
|
110467
110540
|
}
|
|
110468
110541
|
} else {
|
|
110469
|
-
let
|
|
110470
|
-
while (retries < WINDOWS_RENAME_MAX_RETRIES2) {
|
|
110542
|
+
for (let attempt = 0;attempt < WINDOWS_RENAME_MAX_RETRIES2; attempt++) {
|
|
110471
110543
|
try {
|
|
110472
|
-
await
|
|
110544
|
+
await _internals68.fsRename(tempPath, graphPath);
|
|
110545
|
+
lastError = null;
|
|
110473
110546
|
break;
|
|
110474
110547
|
} catch (error93) {
|
|
110475
110548
|
lastError = error93 instanceof Error ? error93 : new Error(String(error93));
|
|
110476
|
-
|
|
110477
|
-
|
|
110478
|
-
|
|
110479
|
-
|
|
110549
|
+
const code = lastError.code;
|
|
110550
|
+
if (code !== "EEXIST" && code !== "EPERM" && code !== "EBUSY") {
|
|
110551
|
+
break;
|
|
110552
|
+
}
|
|
110553
|
+
if (attempt < WINDOWS_RENAME_MAX_RETRIES2 - 1) {
|
|
110554
|
+
await new Promise((resolve41) => setTimeout(resolve41, _internals68.retryDelayMs));
|
|
110480
110555
|
}
|
|
110481
|
-
throw lastError;
|
|
110482
110556
|
}
|
|
110483
110557
|
}
|
|
110558
|
+
if (lastError) {
|
|
110559
|
+
throw lastError;
|
|
110560
|
+
}
|
|
110484
110561
|
}
|
|
110485
110562
|
} finally {
|
|
110486
110563
|
try {
|
|
@@ -146756,11 +146833,25 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
146756
146833
|
addDeferredWarning("[swarm] auto_select_architect is enabled but no architect agents were found in the generated set. The option has no effect.");
|
|
146757
146834
|
}
|
|
146758
146835
|
}
|
|
146836
|
+
const shortcutDescription = (cmd) => {
|
|
146837
|
+
const entry = COMMAND_REGISTRY[cmd];
|
|
146838
|
+
if (!entry?.description) {
|
|
146839
|
+
return `Use /swarm ${cmd}`;
|
|
146840
|
+
}
|
|
146841
|
+
const desc = entry.description.charAt(0).toLowerCase() + entry.description.slice(1);
|
|
146842
|
+
return `Use /swarm ${cmd} to ${desc}`;
|
|
146843
|
+
};
|
|
146759
146844
|
opencodeConfig.command = {
|
|
146760
146845
|
...opencodeConfig.command || {},
|
|
146761
146846
|
swarm: {
|
|
146762
146847
|
template: "/swarm $ARGUMENTS",
|
|
146763
|
-
description:
|
|
146848
|
+
description: (() => {
|
|
146849
|
+
const standaloneCommands = VALID_COMMANDS.filter((cmd) => {
|
|
146850
|
+
const entry = COMMAND_REGISTRY[cmd];
|
|
146851
|
+
return !entry.aliasOf && !entry.deprecated && !entry.subcommandOf;
|
|
146852
|
+
});
|
|
146853
|
+
return `Swarm management commands: /swarm [${standaloneCommands.join("|")}]`;
|
|
146854
|
+
})()
|
|
146764
146855
|
},
|
|
146765
146856
|
"swarm-status": {
|
|
146766
146857
|
template: "/swarm status",
|
|
@@ -146862,6 +146953,26 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
146862
146953
|
template: "/swarm pr-feedback $ARGUMENTS",
|
|
146863
146954
|
description: "Use /swarm pr-feedback to ingest and close known PR feedback (review comments, CI failures, conflicts) without a fresh broad review"
|
|
146864
146955
|
},
|
|
146956
|
+
"swarm-pr-subscribe": {
|
|
146957
|
+
template: "/swarm pr subscribe $ARGUMENTS",
|
|
146958
|
+
description: shortcutDescription("pr subscribe")
|
|
146959
|
+
},
|
|
146960
|
+
"swarm-pr-unsubscribe": {
|
|
146961
|
+
template: "/swarm pr unsubscribe $ARGUMENTS",
|
|
146962
|
+
description: shortcutDescription("pr unsubscribe")
|
|
146963
|
+
},
|
|
146964
|
+
"swarm-pr-status": {
|
|
146965
|
+
template: "/swarm pr status",
|
|
146966
|
+
description: shortcutDescription("pr status")
|
|
146967
|
+
},
|
|
146968
|
+
"swarm-learning": {
|
|
146969
|
+
template: "/swarm learning",
|
|
146970
|
+
description: shortcutDescription("learning")
|
|
146971
|
+
},
|
|
146972
|
+
"swarm-post-mortem": {
|
|
146973
|
+
template: "/swarm post-mortem $ARGUMENTS",
|
|
146974
|
+
description: shortcutDescription("post-mortem")
|
|
146975
|
+
},
|
|
146865
146976
|
"swarm-deep-dive": {
|
|
146866
146977
|
template: "/swarm deep-dive $ARGUMENTS",
|
|
146867
146978
|
description: "Use /swarm deep-dive to launch a read-only deep audit with parallel explorer waves, dual reviewers, and critic challenge"
|