opencode-swarm 7.52.3 → 7.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.52.3",
72
+ version: "7.53.0",
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",
@@ -73213,7 +73213,7 @@ var init_plan = __esm(() => {
73213
73213
  init_plan_service();
73214
73214
  });
73215
73215
 
73216
- // src/commands/pr-review.ts
73216
+ // src/commands/pr-ref.ts
73217
73217
  import { execSync as execSync3 } from "node:child_process";
73218
73218
  function sanitizeUrl2(raw) {
73219
73219
  let urlStr = raw.trim();
@@ -73232,6 +73232,22 @@ function sanitizeUrl2(raw) {
73232
73232
  }
73233
73233
  return urlStr.trim();
73234
73234
  }
73235
+ function sanitizeInstructions(raw) {
73236
+ const collapsed = raw.replace(/\s+/g, " ").trim();
73237
+ const stripped = collapsed.replace(/\[\s*MODE\s*:[^\]]*\]/gi, "");
73238
+ const normalized = stripped.replace(/\s+/g, " ").trim();
73239
+ if (normalized.length <= MAX_INSTRUCTIONS_LEN)
73240
+ return normalized;
73241
+ return `${normalized.slice(0, MAX_INSTRUCTIONS_LEN)}…`;
73242
+ }
73243
+ function hasNonAsciiHostname(hostname5) {
73244
+ for (const ch of hostname5) {
73245
+ const cp = ch.codePointAt(0);
73246
+ if (cp !== undefined && cp > 127)
73247
+ return true;
73248
+ }
73249
+ return false;
73250
+ }
73235
73251
  function isPrivateHost2(url3) {
73236
73252
  const host = url3.hostname.toLowerCase();
73237
73253
  if (host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "0.0.0.0") {
@@ -73266,8 +73282,7 @@ function validateAndSanitizeUrl2(rawUrl) {
73266
73282
  }
73267
73283
  try {
73268
73284
  const url3 = new URL(sanitized);
73269
- const hostname5 = url3.hostname;
73270
- if (/[\u0080-\u{10FFFF}]/u.test(hostname5)) {
73285
+ if (hasNonAsciiHostname(url3.hostname)) {
73271
73286
  return { error: "Non-ASCII hostnames are not allowed" };
73272
73287
  }
73273
73288
  if (isPrivateHost2(url3)) {
@@ -73284,18 +73299,7 @@ function validateAndSanitizeUrl2(rawUrl) {
73284
73299
  return { error: "Invalid URL format" };
73285
73300
  }
73286
73301
  }
73287
- function parseArgs5(args2) {
73288
- const out2 = { council: false, rest: [] };
73289
- for (const token of args2) {
73290
- if (token === "--council") {
73291
- out2.council = true;
73292
- continue;
73293
- }
73294
- out2.rest.push(token);
73295
- }
73296
- return out2;
73297
- }
73298
- function parsePrRef(input) {
73302
+ function parsePrRef(input, cwd) {
73299
73303
  const urlMatch = input.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)\/?$/i);
73300
73304
  if (urlMatch) {
73301
73305
  return {
@@ -73315,7 +73319,7 @@ function parsePrRef(input) {
73315
73319
  const bareMatch = input.match(/^(\d+)$/);
73316
73320
  if (bareMatch) {
73317
73321
  const prNumber = parseInt(bareMatch[1], 10);
73318
- const remoteUrl = detectGitRemote2();
73322
+ const remoteUrl = detectGitRemote2(cwd);
73319
73323
  if (!remoteUrl) {
73320
73324
  return null;
73321
73325
  }
@@ -73331,12 +73335,13 @@ function parsePrRef(input) {
73331
73335
  }
73332
73336
  return null;
73333
73337
  }
73334
- function detectGitRemote2() {
73338
+ function detectGitRemote2(cwd) {
73335
73339
  try {
73336
- const remoteUrl = execSync3("git remote get-url origin", {
73340
+ const remoteUrl = _internals31.execSync("git remote get-url origin", {
73337
73341
  encoding: "utf-8",
73338
73342
  stdio: ["pipe", "pipe", "pipe"],
73339
- timeout: 5000
73343
+ timeout: 5000,
73344
+ ...cwd ? { cwd } : {}
73340
73345
  }).trim();
73341
73346
  return remoteUrl || null;
73342
73347
  } catch {
@@ -73367,41 +73372,115 @@ function parseGitRemoteUrl2(remoteUrl) {
73367
73372
  }
73368
73373
  return null;
73369
73374
  }
73370
- function handlePrReviewCommand(_directory, args2) {
73371
- const parsed = parseArgs5(args2);
73372
- const rawInput = parsed.rest.join(" ").trim();
73373
- if (!rawInput) {
73374
- return USAGE5;
73375
+ function looksLikePrRef(token) {
73376
+ return /^https?:\/\//i.test(token) || /^[^/]+\/[^#]+#\d+$/.test(token) || /^\d+$/.test(token);
73377
+ }
73378
+ function resolvePrCommandInput(rest, cwd) {
73379
+ if (rest.length === 0) {
73380
+ return null;
73375
73381
  }
73376
- const isFullUrl = /^https?:\/\//i.test(rawInput);
73377
- const prInfo = parsePrRef(isFullUrl ? sanitizeUrl2(rawInput) : rawInput);
73382
+ const refToken = rest[0];
73383
+ const instructions = sanitizeInstructions(rest.slice(1).join(" "));
73384
+ const isFullUrl = /^https?:\/\//i.test(refToken);
73385
+ const prInfo = parsePrRef(isFullUrl ? sanitizeUrl2(refToken) : refToken, cwd);
73378
73386
  if (!prInfo) {
73379
- return `Error: Could not parse PR reference from "${rawInput}"
73380
-
73381
- ${USAGE5}`;
73387
+ return { error: `Could not parse PR reference from "${refToken}"` };
73382
73388
  }
73383
73389
  const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
73384
73390
  const result = validateAndSanitizeUrl2(prUrl);
73385
73391
  if ("error" in result) {
73386
- return `Error: ${result.error}
73392
+ return { error: result.error };
73393
+ }
73394
+ return { prUrl: result.sanitized, instructions };
73395
+ }
73396
+ var _internals31, MAX_URL_LEN2 = 2048, MAX_INSTRUCTIONS_LEN = 1000;
73397
+ var init_pr_ref = __esm(() => {
73398
+ _internals31 = { execSync: execSync3 };
73399
+ });
73400
+
73401
+ // src/commands/pr-feedback.ts
73402
+ function handlePrFeedbackCommand(directory, args2) {
73403
+ const rest = args2.filter((t) => t.trim().length > 0);
73404
+ if (rest.length === 0) {
73405
+ return "[MODE: PR_FEEDBACK]";
73406
+ }
73407
+ const resolved = resolvePrCommandInput(rest, directory);
73408
+ if (resolved && "prUrl" in resolved) {
73409
+ const signal = `[MODE: PR_FEEDBACK pr="${resolved.prUrl}"]`;
73410
+ return resolved.instructions ? `${signal} ${resolved.instructions}` : signal;
73411
+ }
73412
+ if (resolved && "error" in resolved && looksLikePrRef(rest[0])) {
73413
+ return [
73414
+ `Error: ${resolved.error}`,
73415
+ "",
73416
+ "That looked like a PR reference but could not be resolved. Pass a full",
73417
+ "URL or `owner/repo#N`, or omit the reference to start a no-PR feedback",
73418
+ "session (e.g. `/swarm pr-feedback address the review notes`)."
73419
+ ].join(`
73420
+ `);
73421
+ }
73422
+ const instructions = sanitizeInstructions(rest.join(" "));
73423
+ return instructions ? `[MODE: PR_FEEDBACK] ${instructions}` : "[MODE: PR_FEEDBACK]";
73424
+ }
73425
+ var init_pr_feedback = __esm(() => {
73426
+ init_pr_ref();
73427
+ });
73428
+
73429
+ // src/commands/pr-review.ts
73430
+ function parseArgs5(args2) {
73431
+ const out2 = { council: false, rest: [] };
73432
+ for (const token of args2) {
73433
+ if (token === "--council") {
73434
+ out2.council = true;
73435
+ continue;
73436
+ }
73437
+ if (token.startsWith("--")) {
73438
+ if (out2.unknownFlag === undefined)
73439
+ out2.unknownFlag = token;
73440
+ continue;
73441
+ }
73442
+ if (token.trim().length === 0)
73443
+ continue;
73444
+ out2.rest.push(token);
73445
+ }
73446
+ return out2;
73447
+ }
73448
+ function handlePrReviewCommand(directory, args2) {
73449
+ const parsed = parseArgs5(args2);
73450
+ if (parsed.unknownFlag) {
73451
+ return `Error: Unknown flag "${parsed.unknownFlag}"
73452
+
73453
+ ${USAGE5}`;
73454
+ }
73455
+ const resolved = resolvePrCommandInput(parsed.rest, directory);
73456
+ if (resolved === null) {
73457
+ return USAGE5;
73458
+ }
73459
+ if ("error" in resolved) {
73460
+ return `Error: ${resolved.error}
73387
73461
 
73388
73462
  ${USAGE5}`;
73389
73463
  }
73390
73464
  const councilFlag = parsed.council ? "council=true" : "council=false";
73391
- return `[MODE: PR_REVIEW pr="${result.sanitized}" ${councilFlag}]`;
73465
+ const signal = `[MODE: PR_REVIEW pr="${resolved.prUrl}" ${councilFlag}]`;
73466
+ return resolved.instructions ? `${signal} ${resolved.instructions}` : signal;
73392
73467
  }
73393
- var MAX_URL_LEN2 = 2048, USAGE5;
73468
+ var USAGE5;
73394
73469
  var init_pr_review = __esm(() => {
73470
+ init_pr_ref();
73395
73471
  USAGE5 = [
73396
- "Usage: /swarm pr-review <url|owner/repo#N|N> [--council]",
73472
+ "Usage: /swarm pr-review <url|owner/repo#N|N> [--council] [instructions...]",
73397
73473
  "",
73398
73474
  "Run a full swarm PR review on a GitHub pull request.",
73399
73475
  " /swarm pr-review https://github.com/owner/repo/pull/42",
73400
73476
  " /swarm pr-review owner/repo#42",
73401
73477
  " /swarm pr-review 42 --council",
73478
+ " /swarm pr-review 42 focus on the auth refactor and the new retry logic",
73402
73479
  "",
73403
73480
  "Flags:",
73404
- " --council Run adversarial council variant (all lanes assume work is wrong)"
73481
+ " --council Run adversarial council variant (all lanes assume work is wrong)",
73482
+ "",
73483
+ "Any text after the PR reference is forwarded to the reviewer as extra instructions."
73405
73484
  ].join(`
73406
73485
  `);
73407
73486
  });
@@ -73843,7 +73922,7 @@ async function runAdditionalLint(linter, mode, cwd) {
73843
73922
  };
73844
73923
  }
73845
73924
  }
73846
- var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals31;
73925
+ var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals32;
73847
73926
  var init_lint = __esm(() => {
73848
73927
  init_zod();
73849
73928
  init_discovery();
@@ -73875,15 +73954,15 @@ var init_lint = __esm(() => {
73875
73954
  }
73876
73955
  const { mode } = args2;
73877
73956
  const cwd = directory;
73878
- const linter = await _internals31.detectAvailableLinter(directory);
73957
+ const linter = await _internals32.detectAvailableLinter(directory);
73879
73958
  if (linter) {
73880
- const result = await _internals31.runLint(linter, mode, directory);
73959
+ const result = await _internals32.runLint(linter, mode, directory);
73881
73960
  return JSON.stringify(result, null, 2);
73882
73961
  }
73883
- const additionalLinter = _internals31.detectAdditionalLinter(cwd);
73962
+ const additionalLinter = _internals32.detectAdditionalLinter(cwd);
73884
73963
  if (additionalLinter) {
73885
73964
  warn(`[lint] Using ${additionalLinter} linter for this project`);
73886
- const result = await _internals31.runAdditionalLint(additionalLinter, mode, cwd);
73965
+ const result = await _internals32.runAdditionalLint(additionalLinter, mode, cwd);
73887
73966
  return JSON.stringify(result, null, 2);
73888
73967
  }
73889
73968
  const errorResult = {
@@ -73897,7 +73976,7 @@ For Rust: rustup component add clippy`
73897
73976
  return JSON.stringify(errorResult, null, 2);
73898
73977
  }
73899
73978
  });
73900
- _internals31 = {
73979
+ _internals32 = {
73901
73980
  detectAvailableLinter,
73902
73981
  runLint,
73903
73982
  detectAdditionalLinter,
@@ -74211,7 +74290,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
74211
74290
  }
74212
74291
  async function runSecretscan(directory) {
74213
74292
  try {
74214
- const result = await _internals32.secretscan.execute({ directory }, {});
74293
+ const result = await _internals33.secretscan.execute({ directory }, {});
74215
74294
  const jsonStr = typeof result === "string" ? result : result.output;
74216
74295
  return JSON.parse(jsonStr);
74217
74296
  } catch (e) {
@@ -74226,7 +74305,7 @@ async function runSecretscan(directory) {
74226
74305
  return errorResult;
74227
74306
  }
74228
74307
  }
74229
- 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, _internals32;
74308
+ 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, _internals33;
74230
74309
  var init_secretscan = __esm(() => {
74231
74310
  init_zod();
74232
74311
  init_path_security();
@@ -74598,7 +74677,7 @@ var init_secretscan = __esm(() => {
74598
74677
  }
74599
74678
  }
74600
74679
  });
74601
- _internals32 = {
74680
+ _internals33 = {
74602
74681
  secretscan,
74603
74682
  runSecretscan
74604
74683
  };
@@ -75190,14 +75269,14 @@ function buildGoBackend() {
75190
75269
  selectEntryPoints
75191
75270
  };
75192
75271
  }
75193
- var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals33;
75272
+ var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals34;
75194
75273
  var init_go = __esm(() => {
75195
75274
  init_default_backend();
75196
75275
  init_profiles();
75197
75276
  IMPORT_REGEX_SINGLE = /^\s*import\s+(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/gm;
75198
75277
  IMPORT_REGEX_GROUP = /^\s*import\s*\(([\s\S]*?)\)/gm;
75199
75278
  IMPORT_REGEX_GROUP_LINE = /(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/g;
75200
- _internals33 = { extractImports };
75279
+ _internals34 = { extractImports };
75201
75280
  });
75202
75281
 
75203
75282
  // src/lang/backends/python.ts
@@ -75309,13 +75388,13 @@ function buildPythonBackend() {
75309
75388
  selectEntryPoints: selectEntryPoints2
75310
75389
  };
75311
75390
  }
75312
- var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals34;
75391
+ var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals35;
75313
75392
  var init_python = __esm(() => {
75314
75393
  init_default_backend();
75315
75394
  init_profiles();
75316
75395
  IMPORT_REGEX_FROM_WITH_TARGETS = /^\s*from\s+(\.*[\w.]*)\s+import\s+(\([^)]*\)|[^\n#]+)/gm;
75317
75396
  IMPORT_REGEX_IMPORT = /^\s*import\s+([^\n#]+)/gm;
75318
- _internals34 = { extractImports: extractImports2 };
75397
+ _internals35 = { extractImports: extractImports2 };
75319
75398
  });
75320
75399
 
75321
75400
  // src/test-impact/analyzer.ts
@@ -75539,7 +75618,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
75539
75618
  return;
75540
75619
  }
75541
75620
  if (PYTHON_EXTENSIONS.has(ext)) {
75542
- const modules = _internals34.extractImports(testFile, content);
75621
+ const modules = _internals35.extractImports(testFile, content);
75543
75622
  for (const mod of modules) {
75544
75623
  const resolved = resolvePythonImport(testDir, mod);
75545
75624
  if (resolved !== null)
@@ -75548,7 +75627,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
75548
75627
  return;
75549
75628
  }
75550
75629
  if (GO_EXTENSIONS.has(ext)) {
75551
- const imports = _internals33.extractImports(testFile, content);
75630
+ const imports = _internals34.extractImports(testFile, content);
75552
75631
  for (const importPath of imports) {
75553
75632
  const sourceFiles = resolveGoImport(testDir, importPath);
75554
75633
  for (const source of sourceFiles)
@@ -75575,8 +75654,8 @@ async function buildImpactMapInternal(cwd) {
75575
75654
  return impactMap;
75576
75655
  }
75577
75656
  async function buildImpactMap(cwd) {
75578
- const impactMap = await _internals35.buildImpactMapInternal(cwd);
75579
- await _internals35.saveImpactMap(cwd, impactMap);
75657
+ const impactMap = await _internals36.buildImpactMapInternal(cwd);
75658
+ await _internals36.saveImpactMap(cwd, impactMap);
75580
75659
  return impactMap;
75581
75660
  }
75582
75661
  async function loadImpactMap(cwd, options) {
@@ -75590,7 +75669,7 @@ async function loadImpactMap(cwd, options) {
75590
75669
  const hasValidValues = Object.values(map3).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
75591
75670
  if (hasValidValues) {
75592
75671
  const generatedAt = new Date(data.generatedAt).getTime();
75593
- if (!_internals35.isCacheStale(map3, generatedAt)) {
75672
+ if (!_internals36.isCacheStale(map3, generatedAt)) {
75594
75673
  return map3;
75595
75674
  }
75596
75675
  if (options?.skipRebuild) {
@@ -75610,13 +75689,13 @@ async function loadImpactMap(cwd, options) {
75610
75689
  if (options?.skipRebuild) {
75611
75690
  return {};
75612
75691
  }
75613
- return _internals35.buildImpactMap(cwd);
75692
+ return _internals36.buildImpactMap(cwd);
75614
75693
  }
75615
75694
  async function saveImpactMap(cwd, impactMap) {
75616
75695
  if (!path55.isAbsolute(cwd)) {
75617
75696
  throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
75618
75697
  }
75619
- _internals35.validateProjectRoot(cwd);
75698
+ _internals36.validateProjectRoot(cwd);
75620
75699
  const cacheDir2 = path55.join(cwd, ".swarm", "cache");
75621
75700
  const cachePath = path55.join(cacheDir2, "impact-map.json");
75622
75701
  if (!fs28.existsSync(cacheDir2)) {
@@ -75640,7 +75719,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
75640
75719
  };
75641
75720
  }
75642
75721
  const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
75643
- const impactMap = await _internals35.loadImpactMap(cwd);
75722
+ const impactMap = await _internals36.loadImpactMap(cwd);
75644
75723
  const impactedTestsSet = new Set;
75645
75724
  const untestedFiles = [];
75646
75725
  let visitedCount = 0;
@@ -75725,7 +75804,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
75725
75804
  budgetExceeded
75726
75805
  };
75727
75806
  }
75728
- var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals35;
75807
+ var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals36;
75729
75808
  var init_analyzer = __esm(() => {
75730
75809
  init_manager2();
75731
75810
  init_go();
@@ -75738,7 +75817,7 @@ var init_analyzer = __esm(() => {
75738
75817
  GO_EXTENSIONS = new Set([".go"]);
75739
75818
  EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
75740
75819
  goModuleCache = new Map;
75741
- _internals35 = {
75820
+ _internals36 = {
75742
75821
  validateProjectRoot,
75743
75822
  normalizePath,
75744
75823
  isCacheStale,
@@ -76074,7 +76153,7 @@ function batchAppendTestRuns(records, workingDir) {
76074
76153
  }
76075
76154
  const historyPath = getHistoryPath(workingDir);
76076
76155
  const historyDir = path56.dirname(historyPath);
76077
- _internals36.validateProjectRoot(workingDir);
76156
+ _internals37.validateProjectRoot(workingDir);
76078
76157
  if (!fs29.existsSync(historyDir)) {
76079
76158
  fs29.mkdirSync(historyDir, { recursive: true });
76080
76159
  }
@@ -76197,7 +76276,7 @@ function getAllHistory(workingDir) {
76197
76276
  records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
76198
76277
  return records;
76199
76278
  }
76200
- 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, _internals36;
76279
+ 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, _internals37;
76201
76280
  var init_history_store = __esm(() => {
76202
76281
  init_manager2();
76203
76282
  DANGEROUS_PROPERTY_NAMES = new Set([
@@ -76205,7 +76284,7 @@ var init_history_store = __esm(() => {
76205
76284
  "constructor",
76206
76285
  "prototype"
76207
76286
  ]);
76208
- _internals36 = {
76287
+ _internals37 = {
76209
76288
  validateProjectRoot
76210
76289
  };
76211
76290
  });
@@ -76331,7 +76410,7 @@ function readPackageJsonRaw(dir) {
76331
76410
  }
76332
76411
  }
76333
76412
  function readPackageJson(dir) {
76334
- return _internals37.readPackageJsonRaw(dir);
76413
+ return _internals38.readPackageJsonRaw(dir);
76335
76414
  }
76336
76415
  function readPackageJsonTestScript(dir) {
76337
76416
  return readPackageJson(dir)?.scripts?.test ?? null;
@@ -76501,7 +76580,7 @@ function buildTypescriptBackend() {
76501
76580
  selectEntryPoints: selectEntryPoints3
76502
76581
  };
76503
76582
  }
76504
- var PROFILE_ID3 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals37;
76583
+ var PROFILE_ID3 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals38;
76505
76584
  var init_typescript = __esm(() => {
76506
76585
  init_default_backend();
76507
76586
  init_profiles();
@@ -76510,7 +76589,7 @@ var init_typescript = __esm(() => {
76510
76589
  IMPORT_REGEX_REQUIRE2 = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
76511
76590
  IMPORT_REGEX_DYNAMIC = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
76512
76591
  IMPORT_REGEX_REEXPORT2 = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
76513
- _internals37 = {
76592
+ _internals38 = {
76514
76593
  readPackageJsonRaw,
76515
76594
  readPackageJsonTestScript,
76516
76595
  frameworkFromScriptsTest
@@ -76541,7 +76620,7 @@ __export(exports_dispatch, {
76541
76620
  pickedProfiles: () => pickedProfiles,
76542
76621
  pickBackend: () => pickBackend,
76543
76622
  clearDispatchCache: () => clearDispatchCache,
76544
- _internals: () => _internals38
76623
+ _internals: () => _internals39
76545
76624
  });
76546
76625
  import * as fs32 from "node:fs";
76547
76626
  import * as path59 from "node:path";
@@ -76596,7 +76675,7 @@ function findManifestRoot(start2) {
76596
76675
  return start2;
76597
76676
  }
76598
76677
  function evictIfNeeded() {
76599
- if (cache.size <= _internals38.cacheCapacity)
76678
+ if (cache.size <= _internals39.cacheCapacity)
76600
76679
  return;
76601
76680
  let oldestKey;
76602
76681
  let oldestOrder = Infinity;
@@ -76627,7 +76706,7 @@ async function pickBackend(dir) {
76627
76706
  evictIfNeeded();
76628
76707
  return null;
76629
76708
  }
76630
- const profiles = await _internals38.detectProjectLanguages(root);
76709
+ const profiles = await _internals39.detectProjectLanguages(root);
76631
76710
  if (profiles.length === 0) {
76632
76711
  cache.set(cacheKey, {
76633
76712
  hash: hash3,
@@ -76659,12 +76738,12 @@ function clearDispatchCache() {
76659
76738
  manifestRootCache.clear();
76660
76739
  insertCounter = 0;
76661
76740
  }
76662
- var _internals38, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
76741
+ var _internals39, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
76663
76742
  var init_dispatch = __esm(() => {
76664
76743
  init_backends();
76665
76744
  init_detector();
76666
76745
  init_registry_backend();
76667
- _internals38 = {
76746
+ _internals39 = {
76668
76747
  detectProjectLanguages,
76669
76748
  cacheCapacity: 64
76670
76749
  };
@@ -78521,9 +78600,9 @@ function getVersionFileVersion(dir) {
78521
78600
  async function runVersionCheck2(dir, _timeoutMs) {
78522
78601
  const startTime = Date.now();
78523
78602
  try {
78524
- const packageVersion = _internals39.getPackageVersion(dir);
78525
- const changelogVersion = _internals39.getChangelogVersion(dir);
78526
- const versionFileVersion = _internals39.getVersionFileVersion(dir);
78603
+ const packageVersion = _internals40.getPackageVersion(dir);
78604
+ const changelogVersion = _internals40.getChangelogVersion(dir);
78605
+ const versionFileVersion = _internals40.getVersionFileVersion(dir);
78527
78606
  const versions3 = [];
78528
78607
  if (packageVersion)
78529
78608
  versions3.push(`package.json: ${packageVersion}`);
@@ -78888,7 +78967,7 @@ async function runPreflight(dir, phase, config3) {
78888
78967
  const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
78889
78968
  let validatedDir;
78890
78969
  try {
78891
- validatedDir = _internals39.validateDirectoryPath(dir);
78970
+ validatedDir = _internals40.validateDirectoryPath(dir);
78892
78971
  } catch (error93) {
78893
78972
  return {
78894
78973
  id: reportId,
@@ -78908,7 +78987,7 @@ async function runPreflight(dir, phase, config3) {
78908
78987
  }
78909
78988
  let validatedTimeout;
78910
78989
  try {
78911
- validatedTimeout = _internals39.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
78990
+ validatedTimeout = _internals40.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
78912
78991
  } catch (error93) {
78913
78992
  return {
78914
78993
  id: reportId,
@@ -78949,12 +79028,12 @@ async function runPreflight(dir, phase, config3) {
78949
79028
  });
78950
79029
  const checks5 = [];
78951
79030
  log("[Preflight] Running lint check...");
78952
- const lintResult = await _internals39.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
79031
+ const lintResult = await _internals40.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
78953
79032
  checks5.push(lintResult);
78954
79033
  log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
78955
79034
  if (!cfg.skipTests) {
78956
79035
  log("[Preflight] Running tests check...");
78957
- const testsResult = await _internals39.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
79036
+ const testsResult = await _internals40.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
78958
79037
  checks5.push(testsResult);
78959
79038
  log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
78960
79039
  } else {
@@ -78966,7 +79045,7 @@ async function runPreflight(dir, phase, config3) {
78966
79045
  }
78967
79046
  if (!cfg.skipSecrets) {
78968
79047
  log("[Preflight] Running secrets check...");
78969
- const secretsResult = await _internals39.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
79048
+ const secretsResult = await _internals40.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
78970
79049
  checks5.push(secretsResult);
78971
79050
  log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
78972
79051
  } else {
@@ -78978,7 +79057,7 @@ async function runPreflight(dir, phase, config3) {
78978
79057
  }
78979
79058
  if (!cfg.skipEvidence) {
78980
79059
  log("[Preflight] Running evidence check...");
78981
- const evidenceResult = await _internals39.runEvidenceCheck(validatedDir);
79060
+ const evidenceResult = await _internals40.runEvidenceCheck(validatedDir);
78982
79061
  checks5.push(evidenceResult);
78983
79062
  log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
78984
79063
  } else {
@@ -78989,12 +79068,12 @@ async function runPreflight(dir, phase, config3) {
78989
79068
  });
78990
79069
  }
78991
79070
  log("[Preflight] Running requirement coverage check...");
78992
- const reqCoverageResult = await _internals39.runRequirementCoverageCheck(validatedDir, phase);
79071
+ const reqCoverageResult = await _internals40.runRequirementCoverageCheck(validatedDir, phase);
78993
79072
  checks5.push(reqCoverageResult);
78994
79073
  log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
78995
79074
  if (!cfg.skipVersion) {
78996
79075
  log("[Preflight] Running version check...");
78997
- const versionResult = await _internals39.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
79076
+ const versionResult = await _internals40.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
78998
79077
  checks5.push(versionResult);
78999
79078
  log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
79000
79079
  } else {
@@ -79057,10 +79136,10 @@ function formatPreflightMarkdown(report) {
79057
79136
  async function handlePreflightCommand(directory, _args) {
79058
79137
  const plan = await loadPlan(directory);
79059
79138
  const phase = plan?.current_phase ?? 1;
79060
- const report = await _internals39.runPreflight(directory, phase);
79061
- return _internals39.formatPreflightMarkdown(report);
79139
+ const report = await _internals40.runPreflight(directory, phase);
79140
+ return _internals40.formatPreflightMarkdown(report);
79062
79141
  }
79063
- var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals39;
79142
+ var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals40;
79064
79143
  var init_preflight_service = __esm(() => {
79065
79144
  init_gate_bridge();
79066
79145
  init_manager2();
@@ -79078,7 +79157,7 @@ var init_preflight_service = __esm(() => {
79078
79157
  testScope: "convention",
79079
79158
  linter: "biome"
79080
79159
  };
79081
- _internals39 = {
79160
+ _internals40 = {
79082
79161
  runPreflight,
79083
79162
  formatPreflightMarkdown,
79084
79163
  handlePreflightCommand,
@@ -80973,7 +81052,7 @@ async function getStatusData(directory, agents) {
80973
81052
  }
80974
81053
  function enrichWithLeanTurbo(status, directory) {
80975
81054
  const turboMode = hasActiveTurboMode();
80976
- const leanActive = _internals40.hasActiveLeanTurbo();
81055
+ const leanActive = _internals41.hasActiveLeanTurbo();
80977
81056
  let turboStrategy = "off";
80978
81057
  if (leanActive) {
80979
81058
  turboStrategy = "lean";
@@ -80992,7 +81071,7 @@ function enrichWithLeanTurbo(status, directory) {
80992
81071
  }
80993
81072
  }
80994
81073
  if (leanSessionID) {
80995
- const runState = _internals40.loadLeanTurboRunState(directory, leanSessionID);
81074
+ const runState = _internals41.loadLeanTurboRunState(directory, leanSessionID);
80996
81075
  if (runState) {
80997
81076
  status.leanTurboPhase = runState.phase;
80998
81077
  status.leanMaxParallelCoders = runState.maxParallelCoders;
@@ -81024,7 +81103,7 @@ function enrichWithLeanTurbo(status, directory) {
81024
81103
  }
81025
81104
  }
81026
81105
  }
81027
- status.fullAutoActive = _internals40.hasActiveFullAuto();
81106
+ status.fullAutoActive = _internals41.hasActiveFullAuto();
81028
81107
  return status;
81029
81108
  }
81030
81109
  function formatStatusMarkdown(status) {
@@ -81106,7 +81185,7 @@ async function handleStatusCommand(directory, agents) {
81106
81185
  }
81107
81186
  return formatStatusMarkdown(statusData);
81108
81187
  }
81109
- var _internals40;
81188
+ var _internals41;
81110
81189
  var init_status_service = __esm(() => {
81111
81190
  init_extractors();
81112
81191
  init_utils2();
@@ -81115,7 +81194,7 @@ var init_status_service = __esm(() => {
81115
81194
  init_state3();
81116
81195
  init_compaction_service();
81117
81196
  init_context_budget_service();
81118
- _internals40 = {
81197
+ _internals41 = {
81119
81198
  loadLeanTurboRunState,
81120
81199
  hasActiveLeanTurbo,
81121
81200
  hasActiveFullAuto
@@ -81206,7 +81285,7 @@ async function handleTurboCommand(directory, args2, sessionID) {
81206
81285
  if (arg0 === "on") {
81207
81286
  let strategy = "standard";
81208
81287
  try {
81209
- const { config: config3 } = _internals41.loadPluginConfigWithMeta(directory);
81288
+ const { config: config3 } = _internals42.loadPluginConfigWithMeta(directory);
81210
81289
  if (config3.turbo?.strategy === "lean") {
81211
81290
  strategy = "lean";
81212
81291
  }
@@ -81261,7 +81340,7 @@ function enableLeanTurbo(session, directory, sessionID) {
81261
81340
  let maxParallelCoders = 4;
81262
81341
  let conflictPolicy = "serialize";
81263
81342
  try {
81264
- const { config: config3 } = _internals41.loadPluginConfigWithMeta(directory);
81343
+ const { config: config3 } = _internals42.loadPluginConfigWithMeta(directory);
81265
81344
  const leanConfig = config3.turbo?.lean;
81266
81345
  if (leanConfig) {
81267
81346
  maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
@@ -81331,13 +81410,13 @@ function buildStatusMessage2(session, directory, sessionID) {
81331
81410
  ].join(`
81332
81411
  `);
81333
81412
  }
81334
- var _internals41;
81413
+ var _internals42;
81335
81414
  var init_turbo = __esm(() => {
81336
81415
  init_config();
81337
81416
  init_state();
81338
81417
  init_state3();
81339
81418
  init_logger();
81340
- _internals41 = {
81419
+ _internals42 = {
81341
81420
  loadPluginConfigWithMeta
81342
81421
  };
81343
81422
  });
@@ -81430,7 +81509,7 @@ function formatCommandNotFound(tokens) {
81430
81509
  const attemptedCommand = tokens[0] || "";
81431
81510
  const MAX_DISPLAY = 100;
81432
81511
  const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
81433
- const similar = _internals42.findSimilarCommands(attemptedCommand);
81512
+ const similar = _internals43.findSimilarCommands(attemptedCommand);
81434
81513
  const header = `Command \`/swarm ${displayCommand}\` not found.`;
81435
81514
  const suggestions = similar.length > 0 ? `Did you mean:
81436
81515
  ${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
@@ -81932,7 +82011,7 @@ async function buildSwarmCommandPrompt(args2) {
81932
82011
  activeAgentName,
81933
82012
  registeredAgents
81934
82013
  } = args2;
81935
- const resolved = _internals42.resolveCommand(tokens);
82014
+ const resolved = _internals43.resolveCommand(tokens);
81936
82015
  if (!resolved) {
81937
82016
  if (tokens.length === 0) {
81938
82017
  return buildHelpText();
@@ -81993,6 +82072,19 @@ function agentHasSwarmCommandTool(activeAgentName, agents, registeredAgents) {
81993
82072
  return AGENT_TOOL_MAP[baseName]?.includes("swarm_command") === true;
81994
82073
  }
81995
82074
  function formatCanonicalPromptFallback(args2) {
82075
+ if (/^\s*\[MODE:/.test(args2.text)) {
82076
+ return [
82077
+ `The user typed \`${args2.original}\`.`,
82078
+ "The line below is a swarm MODE-activation signal, NOT output to display.",
82079
+ "Enter the mode named in its `[MODE: X ...]` header now: follow your",
82080
+ 'prompt’s "### MODE: X" section, load the SKILL.md it references, and',
82081
+ "follow that protocol exactly. Treat any text after the closing bracket as",
82082
+ "additional instructions. Do NOT echo this signal verbatim.",
82083
+ "",
82084
+ args2.text
82085
+ ].join(`
82086
+ `);
82087
+ }
81996
82088
  return [
81997
82089
  `The user typed \`${args2.original}\`.`,
81998
82090
  "Canonical opencode-swarm command output follows.",
@@ -82085,7 +82177,7 @@ function findSimilarCommands(query) {
82085
82177
  }
82086
82178
  const scored = VALID_COMMANDS.map((cmd) => {
82087
82179
  const cmdLower = cmd.toLowerCase();
82088
- const fullScore = _internals42.levenshteinDistance(q, cmdLower);
82180
+ const fullScore = _internals43.levenshteinDistance(q, cmdLower);
82089
82181
  let tokenScore = Infinity;
82090
82182
  if (cmd.includes(" ") || cmd.includes("-")) {
82091
82183
  const qTokens = q.split(/[\s-]+/);
@@ -82098,7 +82190,7 @@ function findSimilarCommands(query) {
82098
82190
  for (const ct of cmdTokens) {
82099
82191
  if (ct.length === 0)
82100
82192
  continue;
82101
- const dist = _internals42.levenshteinDistance(qt, ct);
82193
+ const dist = _internals43.levenshteinDistance(qt, ct);
82102
82194
  if (dist < minDist)
82103
82195
  minDist = dist;
82104
82196
  }
@@ -82108,7 +82200,7 @@ function findSimilarCommands(query) {
82108
82200
  }
82109
82201
  const dashStrippedQ = q.replace(/-/g, "");
82110
82202
  const dashStrippedCmd = cmdLower.replace(/-/g, "");
82111
- const dashScore = _internals42.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
82203
+ const dashScore = _internals43.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
82112
82204
  const score = Math.min(fullScore, tokenScore, dashScore);
82113
82205
  return { cmd, score };
82114
82206
  });
@@ -82140,11 +82232,11 @@ async function handleHelpCommand(ctx) {
82140
82232
  return buildHelpText2();
82141
82233
  }
82142
82234
  const tokens = targetCommand.split(/\s+/);
82143
- const resolved = _internals42.resolveCommand(tokens);
82235
+ const resolved = _internals43.resolveCommand(tokens);
82144
82236
  if (resolved) {
82145
- return _internals42.buildDetailedHelp(resolved.key, resolved.entry);
82237
+ return _internals43.buildDetailedHelp(resolved.key, resolved.entry);
82146
82238
  }
82147
- const similar = _internals42.findSimilarCommands(targetCommand);
82239
+ const similar = _internals43.findSimilarCommands(targetCommand);
82148
82240
  const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
82149
82241
  if (similar.length > 0) {
82150
82242
  return `Command '/swarm ${targetCommand}' not found.
@@ -82238,7 +82330,7 @@ function resolveCommand(tokens) {
82238
82330
  }
82239
82331
  return null;
82240
82332
  }
82241
- var COMMAND_REGISTRY, VALID_COMMANDS, _internals42, validation;
82333
+ var COMMAND_REGISTRY, VALID_COMMANDS, _internals43, validation;
82242
82334
  var init_registry = __esm(() => {
82243
82335
  init_acknowledge_spec_drift();
82244
82336
  init_agents();
@@ -82264,6 +82356,7 @@ var init_registry = __esm(() => {
82264
82356
  init_knowledge();
82265
82357
  init_memory2();
82266
82358
  init_plan();
82359
+ init_pr_feedback();
82267
82360
  init_pr_review();
82268
82361
  init_preflight();
82269
82362
  init_promote();
@@ -82311,7 +82404,7 @@ var init_registry = __esm(() => {
82311
82404
  clashesWithNativeCcCommand: "/agents"
82312
82405
  },
82313
82406
  help: {
82314
- handler: (ctx) => _internals42.handleHelpCommand(ctx),
82407
+ handler: (ctx) => _internals43.handleHelpCommand(ctx),
82315
82408
  description: "Show help for swarm commands",
82316
82409
  category: "core",
82317
82410
  args: "[command]",
@@ -82554,6 +82647,13 @@ Subcommands:
82554
82647
  details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes (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).",
82555
82648
  category: "agent"
82556
82649
  },
82650
+ "pr-feedback": {
82651
+ handler: async (ctx) => handlePrFeedbackCommand(ctx.directory, ctx.args),
82652
+ description: "Ingest and close known PR feedback (review comments, CI failures, conflicts) [pr] [instructions]",
82653
+ args: "[url|owner/repo#N|N] [instructions...]",
82654
+ 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).",
82655
+ category: "agent"
82656
+ },
82557
82657
  "deep-dive": {
82558
82658
  handler: async (ctx) => handleDeepDiveCommand(ctx.directory, ctx.args),
82559
82659
  description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]",
@@ -82782,7 +82882,7 @@ Subcommands:
82782
82882
  }
82783
82883
  };
82784
82884
  VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
82785
- _internals42 = {
82885
+ _internals43 = {
82786
82886
  handleHelpCommand,
82787
82887
  validateAliases,
82788
82888
  resolveCommand,
@@ -82790,7 +82890,7 @@ Subcommands:
82790
82890
  findSimilarCommands,
82791
82891
  buildDetailedHelp
82792
82892
  };
82793
- validation = _internals42.validateAliases();
82893
+ validation = _internals43.validateAliases();
82794
82894
  if (!validation.valid) {
82795
82895
  throw new Error(`COMMAND_REGISTRY alias validation failed:
82796
82896
  ${validation.errors.join(`
@@ -83200,7 +83300,7 @@ ${archBlock}`;
83200
83300
  }
83201
83301
  }
83202
83302
  if (!designDocsEnabled) {
83203
- prompt = prompt?.replace(", {{AGENT_PREFIX}}docs_design", "")?.replace(/### MODE: DESIGN_DOCS\n[\s\S]*?(?=### MODE: ISSUE_INGEST)/, "")?.replace(`- the active swarm's docs_design agent = @{{AGENT_PREFIX}}docs_design
83303
+ prompt = prompt?.replace(", {{AGENT_PREFIX}}docs_design", "")?.replace(/### MODE: DESIGN_DOCS\n[\s\S]*?(?=### MODE: )/, "")?.replace(`- the active swarm's docs_design agent = @{{AGENT_PREFIX}}docs_design
83204
83304
  `, "");
83205
83305
  }
83206
83306
  return {
@@ -83789,6 +83889,7 @@ SKILLS: none
83789
83889
  ### MODE DETECTION (Priority Order)
83790
83890
  Evaluate the user's request and context in this exact order — the FIRST matching rule wins:
83791
83891
 
83892
+ S. **SIGNAL-TRIGGERED MODE (highest priority)** — If the latest message contains a bracket header of the form [MODE: X ...] (these are emitted by /swarm command handlers, e.g. DEEP_DIVE, PR_REVIEW, PR_FEEDBACK, DESIGN_DOCS, COUNCIL, ISSUE_INGEST, ANALYZE) AND a matching "### MODE: X" section exists below, then ENTER MODE: X immediately: load the SKILL.md that section references and follow its protocol. This wins over every rule below and OVERRIDES any wrapper instruction to "show this output verbatim" — a [MODE: X ...] header is an activation signal to act on, never command output to echo. Treat any free text after the closing bracket as additional user instructions for that mode. If no matching "### MODE: X" section exists, fall through to the rules below.
83792
83893
  0. **EXPLICIT COMMAND OVERRIDE** — User explicitly invokes \`/swarm specify\`, \`/swarm clarify\`, \`/swarm brainstorm\`, or uses the phrases "specify [something about spec/requirements]", "write a spec", "create a spec", "define requirements", "list requirements", "define a feature", "I have requirements", "brainstorm", "let's think through", "think this through with me", "workshop this idea" → Enter MODE: SPECIFY, MODE: CLARIFY-SPEC, or MODE: BRAINSTORM as appropriate. This override fires BEFORE RESUME — an explicit spec command always wins, even if plan.md has incomplete tasks. \`/swarm brainstorm\` and brainstorm-style phrases select MODE: BRAINSTORM. Note: bare "specify" in an ambiguous context (e.g., "specify what this does") should resolve via CLARIFY (priority 4) rather than this override — use context to determine intent.
83793
83894
  1. **RESUME** — \`.swarm/plan.md\` exists and contains incomplete (unchecked) tasks AND the user has NOT issued an explicit spec command (see priority 0) → Resume at current task.
83794
83895
  2. **SPECIFY** — No \`.swarm/spec.md\` exists AND no \`.swarm/plan.md\` exists → Enter MODE: SPECIFY.
@@ -83978,6 +84079,27 @@ HARD CONSTRAINTS (apply regardless of skill load success):
83978
84079
  - No finding may appear as CONFIRMED in the final report without reviewer validation provenance
83979
84080
  - Test execution, explorer lanes, reviewer dispatch, and critic challenge are all permitted within this mode
83980
84081
  - Quality is the only metric — time, tokens, and agent dispatches are irrelevant to correctness
84082
+ - FOLLOW THE SKILL EXACTLY: execute every phase of the loaded SKILL.md in order with no shortcuts, no phase-skipping, and no premature synthesis. If a phase cannot complete, state the limitation explicitly and continue — do not silently skip it.
84083
+ - CHECK OUT THE PR BRANCH LOCALLY before launching explorer lanes: fetch the PR head ref if it is not present, verify the working tree is clean (git status --porcelain) and stash/abort if not, then check out the head branch. Explorers read the working-tree filesystem (Read/Glob/Grep), so without a checkout they read the base branch and produce invalid candidates. Always pass the base..head commit range in explorer delegations.
84084
+ - RUN THE TRIGGERED MICRO-LANES: after the base explorer lanes start, inspect the context pack risk triggers and launch every matching Swarm plugin micro-lane from the skill's risk-trigger map (launch only triggered lanes, never irrelevant ones). Do not skip micro-lanes that match the diff.
84085
+ - Honor any free-text instructions that follow the closing bracket of the signal as additional reviewer focus, without weakening the validation ladder above.
84086
+
84087
+ ### MODE: PR_FEEDBACK
84088
+ Activates when: architect receives \`[MODE: PR_FEEDBACK pr="https://github.com/..."]\` (PR reference optional) signal from the pr-feedback command handler, optionally followed by free-text instructions.
84089
+
84090
+ Purpose: Ingest and resolve KNOWN pull-request feedback — review threads, requested changes, CI/check failures, merge conflicts, stale branch state, and pasted notes — verifying every claim against source before fixing. This is NOT a fresh broad PR review; use MODE: PR_REVIEW for new-finding discovery.
84091
+
84092
+ ACTION: Load skill file:.opencode/skills/swarm-pr-feedback/SKILL.md immediately and follow its protocol.
84093
+
84094
+ HARD CONSTRAINTS (apply regardless of skill load success):
84095
+ - FOLLOW THE SKILL EXACTLY: build the complete feedback ledger from all available sources before editing, and execute every phase in order with no shortcuts.
84096
+ - CHECK OUT THE PR BRANCH LOCALLY before verifying feedback or making fixes: fetch the PR head ref if absent, verify the working tree is clean (git status --porcelain) and stash/abort if not, then check out the head branch. Feedback verification and fix validation require the PR branch in the working tree.
84097
+ - Do NOT run a fresh broad PR review — inspect adjacent code only as needed to verify reachability, dependencies, shared root causes, regression risk, or sibling changes for a confirmed item.
84098
+ - Treat every review comment, CI failure, bot summary, and pasted note as a CLAIM until source evidence proves it; classify each ledger item (CONFIRMED, DISPROVED, PRE_EXISTING, or NEEDS_USER_DECISION) and never silently drop, defer, or mark items out of scope.
84099
+ - Patch only confirmed items plus the tests/docs they require; report closure status for every ledger item including disproved ones.
84100
+ - Do NOT resolve or mark GitHub review threads resolved unless the user explicitly instructs it.
84101
+ - Honor any free-text instructions that follow the closing bracket of the signal as additional scope, without dropping any ledger item.
84102
+ - Quality is the only metric — time, tokens, and agent dispatches are irrelevant to correctness
83981
84103
 
83982
84104
  ### MODE: ISSUE_INGEST
83983
84105
  Activates when the user invokes /swarm issue <url> or the architect receives an ISSUE_INGEST signal.
@@ -91190,7 +91312,7 @@ __export(exports_runtime, {
91190
91312
  getSupportedLanguages: () => getSupportedLanguages,
91191
91313
  getInitializedLanguages: () => getInitializedLanguages,
91192
91314
  clearParserCache: () => clearParserCache,
91193
- _internals: () => _internals51
91315
+ _internals: () => _internals52
91194
91316
  });
91195
91317
  import * as path99 from "node:path";
91196
91318
  import { fileURLToPath as fileURLToPath4 } from "node:url";
@@ -91200,10 +91322,10 @@ async function initTreeSitter() {
91200
91322
  const thisDir = path99.dirname(fileURLToPath4(import.meta.url));
91201
91323
  const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
91202
91324
  if (isSource) {
91203
- await _internals51.parserInit();
91325
+ await _internals52.parserInit();
91204
91326
  } else {
91205
91327
  const grammarsDir = getGrammarsDirAbsolute();
91206
- await _internals51.parserInit({
91328
+ await _internals52.parserInit({
91207
91329
  locateFile(scriptName) {
91208
91330
  return path99.join(grammarsDir, scriptName);
91209
91331
  }
@@ -91308,12 +91430,12 @@ function getInitializedLanguages() {
91308
91430
  function getSupportedLanguages() {
91309
91431
  return Object.keys(LANGUAGE_WASM_MAP);
91310
91432
  }
91311
- var parserCache, initializedLanguages, treeSitterInitPromise = null, _internals51, LANGUAGE_WASM_MAP;
91433
+ var parserCache, initializedLanguages, treeSitterInitPromise = null, _internals52, LANGUAGE_WASM_MAP;
91312
91434
  var init_runtime = __esm(() => {
91313
91435
  init_tree_sitter();
91314
91436
  parserCache = new Map;
91315
91437
  initializedLanguages = new Set;
91316
- _internals51 = {
91438
+ _internals52 = {
91317
91439
  parserInit: Parser.init
91318
91440
  };
91319
91441
  LANGUAGE_WASM_MAP = {
@@ -92216,9 +92338,9 @@ var init_search_knowledge = __esm(() => {
92216
92338
  var exports_knowledge_recall = {};
92217
92339
  __export(exports_knowledge_recall, {
92218
92340
  knowledge_recall: () => knowledge_recall,
92219
- _internals: () => _internals52
92341
+ _internals: () => _internals53
92220
92342
  });
92221
- var knowledge_recall, _internals52;
92343
+ var knowledge_recall, _internals53;
92222
92344
  var init_knowledge_recall = __esm(() => {
92223
92345
  init_zod();
92224
92346
  init_config();
@@ -92299,7 +92421,7 @@ var init_knowledge_recall = __esm(() => {
92299
92421
  return JSON.stringify(result);
92300
92422
  }
92301
92423
  });
92302
- _internals52 = {
92424
+ _internals53 = {
92303
92425
  knowledge_recall
92304
92426
  };
92305
92427
  });
@@ -92354,7 +92476,7 @@ __export(exports_curator_drift, {
92354
92476
  runDeterministicDriftCheck: () => runDeterministicDriftCheck,
92355
92477
  readPriorDriftReports: () => readPriorDriftReports,
92356
92478
  buildDriftInjectionText: () => buildDriftInjectionText,
92357
- _internals: () => _internals55
92479
+ _internals: () => _internals56
92358
92480
  });
92359
92481
  import * as fs71 from "node:fs";
92360
92482
  import * as path108 from "node:path";
@@ -92403,7 +92525,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
92403
92525
  try {
92404
92526
  const planMd = await readSwarmFileAsync(directory, "plan.md");
92405
92527
  const specMd = await readSwarmFileAsync(directory, "spec.md");
92406
- const priorReports = await _internals55.readPriorDriftReports(directory);
92528
+ const priorReports = await _internals56.readPriorDriftReports(directory);
92407
92529
  const complianceCount = curatorResult.compliance.length;
92408
92530
  const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
92409
92531
  let alignment = "ALIGNED";
@@ -92466,7 +92588,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
92466
92588
  scope_additions: [],
92467
92589
  injection_summary: injectionSummary
92468
92590
  };
92469
- const reportPath = await _internals55.writeDriftReport(directory, report);
92591
+ const reportPath = await _internals56.writeDriftReport(directory, report);
92470
92592
  getGlobalEventBus().publish("curator.drift.completed", {
92471
92593
  phase,
92472
92594
  alignment,
@@ -92529,12 +92651,12 @@ function buildDriftInjectionText(report, maxChars) {
92529
92651
  }
92530
92652
  return text.slice(0, maxChars);
92531
92653
  }
92532
- var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals55;
92654
+ var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals56;
92533
92655
  var init_curator_drift = __esm(() => {
92534
92656
  init_event_bus();
92535
92657
  init_logger();
92536
92658
  init_utils2();
92537
- _internals55 = {
92659
+ _internals56 = {
92538
92660
  readPriorDriftReports,
92539
92661
  writeDriftReport,
92540
92662
  runDeterministicDriftCheck,
@@ -92546,7 +92668,7 @@ var init_curator_drift = __esm(() => {
92546
92668
  var exports_design_doc_drift = {};
92547
92669
  __export(exports_design_doc_drift, {
92548
92670
  runDesignDocDriftCheck: () => runDesignDocDriftCheck,
92549
- _internals: () => _internals66
92671
+ _internals: () => _internals67
92550
92672
  });
92551
92673
  import * as fs106 from "node:fs";
92552
92674
  import * as path145 from "node:path";
@@ -92678,7 +92800,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
92678
92800
  return null;
92679
92801
  }
92680
92802
  }
92681
- var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL, _internals66;
92803
+ var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL, _internals67;
92682
92804
  var init_design_doc_drift = __esm(() => {
92683
92805
  init_event_bus();
92684
92806
  init_logger();
@@ -92692,7 +92814,7 @@ var init_design_doc_drift = __esm(() => {
92692
92814
  "idiom-notes": path145.join("reference", "idiom-notes.md")
92693
92815
  };
92694
92816
  TRACEABILITY_REL = path145.join("reference", "traceability.json");
92695
- _internals66 = {
92817
+ _internals67 = {
92696
92818
  mtimeMsOrNull,
92697
92819
  resolveAnchorWithin,
92698
92820
  DESIGN_DOC_FILES
@@ -92703,7 +92825,7 @@ var init_design_doc_drift = __esm(() => {
92703
92825
  var exports_project_context = {};
92704
92826
  __export(exports_project_context, {
92705
92827
  buildProjectContext: () => buildProjectContext,
92706
- _internals: () => _internals77,
92828
+ _internals: () => _internals78,
92707
92829
  LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
92708
92830
  });
92709
92831
  import * as fs130 from "node:fs";
@@ -92787,7 +92909,7 @@ function selectLintCommand(backend, directory) {
92787
92909
  return null;
92788
92910
  }
92789
92911
  async function buildProjectContext(directory) {
92790
- const backend = await _internals77.pickBackend(directory);
92912
+ const backend = await _internals78.pickBackend(directory);
92791
92913
  if (!backend)
92792
92914
  return null;
92793
92915
  const ctx = emptyProjectContext();
@@ -92818,16 +92940,16 @@ async function buildProjectContext(directory) {
92818
92940
  if (backend.prompts.reviewerChecklist.length > 0) {
92819
92941
  ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
92820
92942
  }
92821
- const profiles = _internals77.pickedProfiles(directory);
92943
+ const profiles = _internals78.pickedProfiles(directory);
92822
92944
  if (profiles.length > 1) {
92823
92945
  ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
92824
92946
  }
92825
92947
  return ctx;
92826
92948
  }
92827
- var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals77;
92949
+ var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals78;
92828
92950
  var init_project_context = __esm(() => {
92829
92951
  init_dispatch();
92830
- _internals77 = {
92952
+ _internals78 = {
92831
92953
  pickBackend,
92832
92954
  pickedProfiles
92833
92955
  };
@@ -93208,7 +93330,7 @@ import * as path76 from "node:path";
93208
93330
  import * as crypto7 from "node:crypto";
93209
93331
  import * as fs44 from "node:fs";
93210
93332
  import * as path75 from "node:path";
93211
- var _internals43 = {
93333
+ var _internals44 = {
93212
93334
  readFileSync: fs44.readFileSync,
93213
93335
  writeFileSync: fs44.writeFileSync,
93214
93336
  mkdirSync: fs44.mkdirSync,
@@ -93218,7 +93340,7 @@ var _internals43 = {
93218
93340
  createHash: crypto7.createHash.bind(crypto7)
93219
93341
  };
93220
93342
  function computeContentHash(content) {
93221
- return _internals43.createHash("sha256").update(content, "utf-8").digest("hex");
93343
+ return _internals44.createHash("sha256").update(content, "utf-8").digest("hex");
93222
93344
  }
93223
93345
  function createEmptyContextMap() {
93224
93346
  return {
@@ -93233,10 +93355,10 @@ function createEmptyContextMap() {
93233
93355
  function loadContextMap(directory) {
93234
93356
  const filePath = path75.join(directory, ".swarm", "context-map.json");
93235
93357
  try {
93236
- if (!_internals43.existsSync(filePath)) {
93358
+ if (!_internals44.existsSync(filePath)) {
93237
93359
  return null;
93238
93360
  }
93239
- const raw = _internals43.readFileSync(filePath, "utf-8");
93361
+ const raw = _internals44.readFileSync(filePath, "utf-8");
93240
93362
  const parsed = JSON.parse(raw);
93241
93363
  if (typeof parsed !== "object" || parsed === null || parsed.schema_version !== 1) {
93242
93364
  return null;
@@ -93250,14 +93372,14 @@ function saveContextMap(map3, directory) {
93250
93372
  const swarmDir = path75.join(directory, ".swarm");
93251
93373
  const tmpPath = path75.join(swarmDir, "context-map.tmp");
93252
93374
  const finalPath = path75.join(swarmDir, "context-map.json");
93253
- _internals43.mkdirSync(swarmDir, { recursive: true });
93375
+ _internals44.mkdirSync(swarmDir, { recursive: true });
93254
93376
  const updated = {
93255
93377
  ...map3,
93256
93378
  generated_at: new Date().toISOString()
93257
93379
  };
93258
93380
  const json3 = JSON.stringify(updated, null, 2);
93259
- _internals43.writeFileSync(tmpPath, json3, "utf-8");
93260
- _internals43.renameSync(tmpPath, finalPath);
93381
+ _internals44.writeFileSync(tmpPath, json3, "utf-8");
93382
+ _internals44.renameSync(tmpPath, finalPath);
93261
93383
  }
93262
93384
  function appendTaskHistory(map3, summary) {
93263
93385
  return {
@@ -93423,10 +93545,10 @@ function deriveFinalStatus(params) {
93423
93545
  }
93424
93546
  function readFileContent(absolutePath) {
93425
93547
  try {
93426
- if (!_internals44.existsSync(absolutePath)) {
93548
+ if (!_internals45.existsSync(absolutePath)) {
93427
93549
  return null;
93428
93550
  }
93429
- return _internals44.readFileSync(absolutePath, "utf-8");
93551
+ return _internals45.readFileSync(absolutePath, "utf-8");
93430
93552
  } catch {
93431
93553
  return null;
93432
93554
  }
@@ -93436,9 +93558,9 @@ function refreshFileEntry(relativePath, absolutePath, existingEntry) {
93436
93558
  if (content === null) {
93437
93559
  return null;
93438
93560
  }
93439
- return _internals44.extractFileSummary(relativePath, content, absolutePath, existingEntry);
93561
+ return _internals45.extractFileSummary(relativePath, content, absolutePath, existingEntry);
93440
93562
  }
93441
- var _internals44 = {
93563
+ var _internals45 = {
93442
93564
  loadContextMap,
93443
93565
  saveContextMap,
93444
93566
  createEmptyContextMap,
@@ -93457,10 +93579,10 @@ function extractEvidenceFindings(taskId, directory) {
93457
93579
  };
93458
93580
  try {
93459
93581
  const evidenceDir = path77.join(directory, ".swarm", "evidence", taskId);
93460
- if (!_internals44.existsSync(evidenceDir)) {
93582
+ if (!_internals45.existsSync(evidenceDir)) {
93461
93583
  return result;
93462
93584
  }
93463
- const evidenceFiles = _internals44.readdirSync(evidenceDir);
93585
+ const evidenceFiles = _internals45.readdirSync(evidenceDir);
93464
93586
  const targetFiles = [
93465
93587
  "evidence.json",
93466
93588
  "reviewer.json",
@@ -93552,20 +93674,20 @@ function extractEvidenceFindings(taskId, directory) {
93552
93674
  }
93553
93675
  function updateContextMapAfterAgent(params) {
93554
93676
  try {
93555
- let map3 = _internals44.loadContextMap(params.directory);
93677
+ let map3 = _internals45.loadContextMap(params.directory);
93556
93678
  if (map3 === null) {
93557
- map3 = _internals44.createEmptyContextMap();
93679
+ map3 = _internals45.createEmptyContextMap();
93558
93680
  }
93559
93681
  const root = path77.resolve(params.directory);
93560
93682
  const updatedFiles = {
93561
93683
  ...map3.files
93562
93684
  };
93563
93685
  const validFiles = [];
93564
- const realRoot = _internals44.realpathSync(root);
93686
+ const realRoot = _internals45.realpathSync(root);
93565
93687
  for (const filePath of params.files_touched) {
93566
93688
  try {
93567
93689
  const resolved = path77.resolve(root, filePath);
93568
- const realResolved = _internals44.realpathSync(resolved);
93690
+ const realResolved = _internals45.realpathSync(resolved);
93569
93691
  const relative12 = path77.relative(realRoot, realResolved);
93570
93692
  if (relative12.startsWith("..") || path77.isAbsolute(relative12)) {
93571
93693
  continue;
@@ -93603,7 +93725,7 @@ function updateContextMapAfterAgent(params) {
93603
93725
  reviewer_findings: reviewerFindings.length > 0 ? reviewerFindings : undefined,
93604
93726
  final_status: mergedRejectionReasons.length > 0 ? "rejected" : deriveFinalStatus(params)
93605
93727
  };
93606
- map3 = _internals44.appendTaskHistory(map3, taskSummary);
93728
+ map3 = _internals45.appendTaskHistory(map3, taskSummary);
93607
93729
  if (params.decisions) {
93608
93730
  for (const entry of params.decisions) {
93609
93731
  const decision = {
@@ -93613,17 +93735,17 @@ function updateContextMapAfterAgent(params) {
93613
93735
  timestamp: new Date().toISOString(),
93614
93736
  task_id: params.task_id
93615
93737
  };
93616
- map3 = _internals44.appendDecision(map3, decision);
93738
+ map3 = _internals45.appendDecision(map3, decision);
93617
93739
  }
93618
93740
  }
93619
- _internals44.saveContextMap(map3, params.directory);
93741
+ _internals45.saveContextMap(map3, params.directory);
93620
93742
  return map3;
93621
93743
  } catch {
93622
93744
  try {
93623
- const fallback = _internals44.loadContextMap(params.directory) ?? _internals44.createEmptyContextMap();
93745
+ const fallback = _internals45.loadContextMap(params.directory) ?? _internals45.createEmptyContextMap();
93624
93746
  return fallback;
93625
93747
  } catch {
93626
- return _internals44.createEmptyContextMap();
93748
+ return _internals45.createEmptyContextMap();
93627
93749
  }
93628
93750
  }
93629
93751
  }
@@ -94930,7 +95052,7 @@ import * as path79 from "node:path";
94930
95052
  function estimateTokens3(content) {
94931
95053
  return Math.max(1, estimateTokens2(content));
94932
95054
  }
94933
- var _internals45 = {
95055
+ var _internals46 = {
94934
95056
  loadContextMap,
94935
95057
  createEmptyContextMap,
94936
95058
  computeContentHash,
@@ -94998,14 +95120,14 @@ function buildReadPolicy(files, map3, directory, invalidateOnHashChange = true,
94998
95120
  const absolutePath = path79.join(directory, filePath);
94999
95121
  let currentContent;
95000
95122
  try {
95001
- if (_internals45.existsSync(absolutePath)) {
95002
- currentContent = _internals45.readFileSync(absolutePath, "utf-8");
95123
+ if (_internals46.existsSync(absolutePath)) {
95124
+ currentContent = _internals46.readFileSync(absolutePath, "utf-8");
95003
95125
  }
95004
95126
  } catch {}
95005
95127
  if (contentCache !== undefined) {
95006
95128
  contentCache.set(filePath, currentContent);
95007
95129
  }
95008
- if (currentContent === undefined || invalidateOnHashChange && _internals45.isFileStale(entry, currentContent)) {
95130
+ if (currentContent === undefined || invalidateOnHashChange && _internals46.isFileStale(entry, currentContent)) {
95009
95131
  policy.push({
95010
95132
  file_path: filePath,
95011
95133
  trust_summary: false,
@@ -95080,7 +95202,7 @@ function pruneCapsuleContent(sections, tokenEstimate, maxTokens, estimateFn) {
95080
95202
  function buildCapsule(params) {
95081
95203
  const { task_id, agent_role, delegation_reason, directory } = params;
95082
95204
  const generatedAt = new Date().toISOString();
95083
- const map3 = _internals45.loadContextMap(directory) ?? _internals45.createEmptyContextMap();
95205
+ const map3 = _internals46.loadContextMap(directory) ?? _internals46.createEmptyContextMap();
95084
95206
  let profile = DEFAULT_ROLE_PROFILES[agent_role];
95085
95207
  if (params.mode === "conservative") {
95086
95208
  profile = { ...profile, max_files: Math.ceil(profile.max_files * 1.5) };
@@ -95109,7 +95231,7 @@ function buildCapsule(params) {
95109
95231
  const shouldCheckStaleness = params.invalidate_on_hash_change !== false;
95110
95232
  if (shouldCheckStaleness) {
95111
95233
  const currentContent = contentCache.get(filePath);
95112
- if (currentContent === undefined || _internals45.isFileStale(entry, currentContent)) {
95234
+ if (currentContent === undefined || _internals46.isFileStale(entry, currentContent)) {
95113
95235
  staleEntries++;
95114
95236
  fileSummaries.push(`- ${filePath} — ${entry.purpose || "No summary available"} (stale)`);
95115
95237
  } else {
@@ -95151,11 +95273,11 @@ function buildCapsule(params) {
95151
95273
  }
95152
95274
  const content = sections.join(`
95153
95275
  `);
95154
- let tokenEstimate = _internals45.estimateTokens(content);
95276
+ let tokenEstimate = _internals46.estimateTokens(content);
95155
95277
  const maxCapsuleTokens = params.max_capsule_tokens ?? 2000;
95156
95278
  let prunedContent = content;
95157
95279
  if (tokenEstimate > maxCapsuleTokens) {
95158
- const { prunedSections, prunedTokenEstimate } = pruneCapsuleContent(sections, tokenEstimate, maxCapsuleTokens, _internals45.estimateTokens);
95280
+ const { prunedSections, prunedTokenEstimate } = pruneCapsuleContent(sections, tokenEstimate, maxCapsuleTokens, _internals46.estimateTokens);
95159
95281
  prunedContent = prunedSections.join(`
95160
95282
  `);
95161
95283
  tokenEstimate = prunedTokenEstimate;
@@ -95191,7 +95313,7 @@ function buildCapsule(params) {
95191
95313
  // src/context-map/capsule-persistence.ts
95192
95314
  import * as fs50 from "node:fs";
95193
95315
  import * as path80 from "node:path";
95194
- var _internals46 = {
95316
+ var _internals47 = {
95195
95317
  writeFileSync: fs50.writeFileSync,
95196
95318
  readFileSync: fs50.readFileSync,
95197
95319
  existsSync: fs50.existsSync,
@@ -95227,10 +95349,10 @@ function saveCapsule(capsule, directory) {
95227
95349
  const capsulesDir = path80.join(directory, ".swarm", "capsules");
95228
95350
  const finalPath = capsulePath(capsule.task_id, directory);
95229
95351
  const tmpPath = path80.join(capsulesDir, `capsule-${capsule.task_id}.tmp`);
95230
- _internals46.mkdirSync(capsulesDir, { recursive: true });
95352
+ _internals47.mkdirSync(capsulesDir, { recursive: true });
95231
95353
  const json3 = JSON.stringify(capsule, null, 2);
95232
- _internals46.writeFileSync(tmpPath, json3, "utf-8");
95233
- _internals46.renameSync(tmpPath, finalPath);
95354
+ _internals47.writeFileSync(tmpPath, json3, "utf-8");
95355
+ _internals47.renameSync(tmpPath, finalPath);
95234
95356
  return {
95235
95357
  success: true,
95236
95358
  capsule_path: finalPath,
@@ -95258,7 +95380,7 @@ function saveCapsule(capsule, directory) {
95258
95380
  // src/context-map/telemetry.ts
95259
95381
  import * as fs51 from "node:fs";
95260
95382
  import * as path81 from "node:path";
95261
- var _internals47 = {
95383
+ var _internals48 = {
95262
95384
  appendFileSync: fs51.appendFileSync,
95263
95385
  readFileSync: fs51.readFileSync,
95264
95386
  existsSync: fs51.existsSync,
@@ -95271,10 +95393,10 @@ function recordTelemetry(entry, directory) {
95271
95393
  const filePath = telemetryFilePath(directory);
95272
95394
  const swarmDir = path81.join(directory, ".swarm");
95273
95395
  try {
95274
- _internals47.mkdirSync(swarmDir, { recursive: true });
95396
+ _internals48.mkdirSync(swarmDir, { recursive: true });
95275
95397
  const line = `${JSON.stringify(entry)}
95276
95398
  `;
95277
- _internals47.appendFileSync(filePath, line, "utf-8");
95399
+ _internals48.appendFileSync(filePath, line, "utf-8");
95278
95400
  return true;
95279
95401
  } catch {
95280
95402
  return false;
@@ -95316,7 +95438,7 @@ function extractTaskGoal(taskId, directory) {
95316
95438
  return "";
95317
95439
  }
95318
95440
  }
95319
- var _internals48 = {
95441
+ var _internals49 = {
95320
95442
  buildCapsule,
95321
95443
  recordTelemetry,
95322
95444
  saveCapsule,
@@ -95384,21 +95506,21 @@ async function injectCapsule(input, output, config3, directory) {
95384
95506
  const sessionID = input.sessionID;
95385
95507
  if (!sessionID)
95386
95508
  return;
95387
- const agentName = _internals48.getActiveAgent(sessionID);
95509
+ const agentName = _internals49.getActiveAgent(sessionID);
95388
95510
  if (!agentName)
95389
95511
  return;
95390
95512
  const role = extractCapsuleRole(agentName);
95391
95513
  if (!role)
95392
95514
  return;
95393
- const taskId = _internals48.getCurrentTaskId(sessionID);
95515
+ const taskId = _internals49.getCurrentTaskId(sessionID);
95394
95516
  const effectiveTaskId = taskId ?? "unknown";
95395
- const files = _internals48.readScopeFile(effectiveTaskId, directory);
95517
+ const files = _internals49.readScopeFile(effectiveTaskId, directory);
95396
95518
  if (files.length === 0)
95397
95519
  return;
95398
95520
  const maxTokens = config3.context_map?.max_capsule_tokens;
95399
- const delegationReason = _internals48.resolveCapsuleDelegationReason(_internals48.getSession(sessionID), role, effectiveTaskId);
95400
- const taskGoal = _internals48.extractTaskGoal(effectiveTaskId, directory);
95401
- const { capsule, metadata: metadata2 } = _internals48.buildCapsule({
95521
+ const delegationReason = _internals49.resolveCapsuleDelegationReason(_internals49.getSession(sessionID), role, effectiveTaskId);
95522
+ const taskGoal = _internals49.extractTaskGoal(effectiveTaskId, directory);
95523
+ const { capsule, metadata: metadata2 } = _internals49.buildCapsule({
95402
95524
  task_id: effectiveTaskId,
95403
95525
  agent_role: role,
95404
95526
  delegation_reason: delegationReason,
@@ -95414,7 +95536,7 @@ async function injectCapsule(input, output, config3, directory) {
95414
95536
  return;
95415
95537
  output.system.push(capsule.content);
95416
95538
  try {
95417
- _internals48.saveCapsule(capsule, directory);
95539
+ _internals49.saveCapsule(capsule, directory);
95418
95540
  } catch {}
95419
95541
  const telemetryEntry = {
95420
95542
  timestamp: new Date().toISOString(),
@@ -95430,7 +95552,7 @@ async function injectCapsule(input, output, config3, directory) {
95430
95552
  success: metadata2.success
95431
95553
  };
95432
95554
  try {
95433
- _internals48.recordTelemetry(telemetryEntry, directory);
95555
+ _internals49.recordTelemetry(telemetryEntry, directory);
95434
95556
  } catch {}
95435
95557
  }
95436
95558
  // src/hooks/curator-llm-factory.ts
@@ -97140,7 +97262,7 @@ function validateGraphEdge(edge) {
97140
97262
  }
97141
97263
 
97142
97264
  // src/tools/repo-graph/builder.ts
97143
- var _internals49 = {
97265
+ var _internals50 = {
97144
97266
  safeRealpathSync,
97145
97267
  extractTSSymbols,
97146
97268
  extractPythonSymbols,
@@ -97227,12 +97349,12 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
97227
97349
  if (specifier.startsWith(".")) {
97228
97350
  const sourceDir = path88.dirname(sourceFile);
97229
97351
  let resolved = path88.resolve(sourceDir, specifier);
97230
- const initialRealResolved = _internals49.safeRealpathSync(resolved, resolved);
97352
+ const initialRealResolved = _internals50.safeRealpathSync(resolved, resolved);
97231
97353
  if (initialRealResolved === null) {
97232
97354
  return null;
97233
97355
  }
97234
97356
  let realResolved = initialRealResolved;
97235
- const realRoot = _internals49.safeRealpathSync(workspaceRoot, path88.normalize(workspaceRoot));
97357
+ const realRoot = _internals50.safeRealpathSync(workspaceRoot, path88.normalize(workspaceRoot));
97236
97358
  if (realRoot === null) {
97237
97359
  return null;
97238
97360
  }
@@ -97256,7 +97378,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
97256
97378
  }
97257
97379
  }
97258
97380
  if (found) {
97259
- const foundRealPath = _internals49.safeRealpathSync(found, found);
97381
+ const foundRealPath = _internals50.safeRealpathSync(found, found);
97260
97382
  if (foundRealPath === null) {
97261
97383
  return null;
97262
97384
  }
@@ -97456,14 +97578,14 @@ function scanFile(filePath, absoluteRoot, maxFileSize) {
97456
97578
  try {
97457
97579
  if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
97458
97580
  const relativePath = path88.relative(absoluteRoot, filePath);
97459
- const symbols2 = _internals49.extractTSSymbols(relativePath, absoluteRoot);
97581
+ const symbols2 = _internals50.extractTSSymbols(relativePath, absoluteRoot);
97460
97582
  exports = symbols2.filter((s) => s.exported).map((s) => s.name);
97461
97583
  } else if (ext === ".py") {
97462
97584
  const relativePath = path88.relative(absoluteRoot, filePath);
97463
- const symbols2 = _internals49.extractPythonSymbols(relativePath, absoluteRoot);
97585
+ const symbols2 = _internals50.extractPythonSymbols(relativePath, absoluteRoot);
97464
97586
  exports = symbols2.filter((s) => s.exported).map((s) => s.name);
97465
97587
  }
97466
- const parsedImports = _internals49.parseFileImports(content);
97588
+ const parsedImports = _internals50.parseFileImports(content);
97467
97589
  const node = {
97468
97590
  filePath,
97469
97591
  moduleName: toModuleName(filePath, absoluteRoot),
@@ -97593,7 +97715,7 @@ init_path_security();
97593
97715
  import { constants as constants4, existsSync as existsSync54 } from "node:fs";
97594
97716
  import * as fsPromises6 from "node:fs/promises";
97595
97717
  import * as path90 from "node:path";
97596
- var _internals50 = {
97718
+ var _internals51 = {
97597
97719
  safeRealpathSync
97598
97720
  };
97599
97721
  var WINDOWS_RENAME_MAX_RETRIES2 = 3;
@@ -97701,12 +97823,12 @@ async function saveGraph(workspace, graph, options) {
97701
97823
  throw new Error("Graph must have edges array");
97702
97824
  }
97703
97825
  const normalizedWorkspace = path90.normalize(workspace);
97704
- const realWorkspace = _internals50.safeRealpathSync(workspace, normalizedWorkspace);
97826
+ const realWorkspace = _internals51.safeRealpathSync(workspace, normalizedWorkspace);
97705
97827
  if (realWorkspace === null) {
97706
97828
  throw new Error(`Workspace realpath security check failed (non-ENOENT): ${workspace}`);
97707
97829
  }
97708
97830
  const normalizedGraphRoot = path90.normalize(graph.workspaceRoot);
97709
- const realGraphRoot = _internals50.safeRealpathSync(graph.workspaceRoot, normalizedGraphRoot);
97831
+ const realGraphRoot = _internals51.safeRealpathSync(graph.workspaceRoot, normalizedGraphRoot);
97710
97832
  if (realGraphRoot === null) {
97711
97833
  throw new Error(`Graph workspaceRoot realpath security check failed (non-ENOENT): ${graph.workspaceRoot}`);
97712
97834
  }
@@ -104181,7 +104303,7 @@ async function knowledgeApplicationGateBefore(directory, input, config3) {
104181
104303
  if (config3.mode === "enforce") {
104182
104304
  throw new Error("KNOWLEDGE_ENFORCE_GATE_DENY: missing sessionID on tool.execute.before; refusing to evaluate critical-directive ack state");
104183
104305
  }
104184
- _internals53.writeWarnEvent(directory, {
104306
+ _internals54.writeWarnEvent(directory, {
104185
104307
  timestamp: new Date().toISOString(),
104186
104308
  event: "knowledge_application_gate_warn",
104187
104309
  tool: toolName,
@@ -104264,7 +104386,7 @@ async function knowledgeApplicationTransformScan(directory, output, sessionID) {
104264
104386
  }
104265
104387
  }
104266
104388
  }
104267
- var _internals53 = {
104389
+ var _internals54 = {
104268
104390
  knowledgeApplicationGateBefore,
104269
104391
  knowledgeApplicationTransformScan,
104270
104392
  HIGH_RISK_TOOLS,
@@ -104400,10 +104522,10 @@ async function getRunMemorySummary(directory) {
104400
104522
  if (entries.length === 0) {
104401
104523
  return null;
104402
104524
  }
104403
- const groups = _internals54.groupByTaskId(entries);
104525
+ const groups = _internals55.groupByTaskId(entries);
104404
104526
  const summaries = [];
104405
104527
  for (const [taskId, taskEntries] of groups) {
104406
- const summary = _internals54.summarizeTask(taskId, taskEntries);
104528
+ const summary = _internals55.summarizeTask(taskId, taskEntries);
104407
104529
  if (summary) {
104408
104530
  summaries.push(summary);
104409
104531
  }
@@ -104436,7 +104558,7 @@ Use this data to avoid repeating known failure patterns.`;
104436
104558
  }
104437
104559
  return prefix + summaryText + suffix;
104438
104560
  }
104439
- var _internals54 = {
104561
+ var _internals55 = {
104440
104562
  generateTaskFingerprint,
104441
104563
  recordOutcome,
104442
104564
  getTaskHistory,
@@ -104629,7 +104751,7 @@ function createKnowledgeInjectorHook(directory, config3) {
104629
104751
  projectName,
104630
104752
  currentPhase: phaseDescription
104631
104753
  };
104632
- const searchFn = _internals56.searchKnowledge === defaultSearchKnowledge ? searchKnowledge : _internals56.searchKnowledge;
104754
+ const searchFn = _internals57.searchKnowledge === defaultSearchKnowledge ? searchKnowledge : _internals57.searchKnowledge;
104633
104755
  const search = await searchFn({
104634
104756
  directory,
104635
104757
  config: config3,
@@ -104738,7 +104860,7 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
104738
104860
  ranks[id] = idx + 1;
104739
104861
  scores[id] = scoreById.get(id) ?? 0;
104740
104862
  });
104741
- await _internals56.recordKnowledgeEvent(directory, {
104863
+ await _internals57.recordKnowledgeEvent(directory, {
104742
104864
  type: "retrieved",
104743
104865
  trace_id: search.trace_id,
104744
104866
  session_id: systemMsg?.info?.sessionID ?? "unknown",
@@ -104751,7 +104873,7 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
104751
104873
  ranks,
104752
104874
  scores
104753
104875
  });
104754
- _internals56.recordKnowledgeShown(directory, cachedShownIds, {
104876
+ _internals57.recordKnowledgeShown(directory, cachedShownIds, {
104755
104877
  phase: phaseLabel,
104756
104878
  tool: retrievalCtx.currentTool,
104757
104879
  action: retrievalCtx.currentAction,
@@ -104761,7 +104883,7 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
104761
104883
  }
104762
104884
  });
104763
104885
  }
104764
- var _internals56 = {
104886
+ var _internals57 = {
104765
104887
  searchKnowledge,
104766
104888
  recordKnowledgeEvent,
104767
104889
  recordKnowledgeShown
@@ -104946,7 +105068,7 @@ var TASK_DIVERSITY_WEIGHT = 0.05;
104946
105068
  var CONTEXT_WEIGHT = 0.2;
104947
105069
  var RECENCY_DECAY_MS = 30 * 24 * 60 * 60 * 1000;
104948
105070
  var SKILL_FRONTMATTER_READ_BYTES = 16 * 1024;
104949
- var _internals57 = {
105071
+ var _internals58 = {
104950
105072
  computeSkillRelevanceScore: null,
104951
105073
  rankSkillsForContext: null,
104952
105074
  getSkillStats: null,
@@ -105165,7 +105287,7 @@ function formatSkillIndexWithContext(skills, directory) {
105165
105287
  } catch {}
105166
105288
  if (!hasHistory) {
105167
105289
  return skills.map((sp) => {
105168
- const meta3 = _internals57.readSkillMetadata(sp, directory);
105290
+ const meta3 = _internals58.readSkillMetadata(sp, directory);
105169
105291
  return ` - file:${meta3.path} - ${meta3.name}: ${meta3.description}`;
105170
105292
  }).join(`
105171
105293
  `);
@@ -105173,7 +105295,7 @@ function formatSkillIndexWithContext(skills, directory) {
105173
105295
  const lines = [];
105174
105296
  for (const skillPath of skills) {
105175
105297
  const stats = getSkillStats(skillPath, directory);
105176
- const meta3 = _internals57.readSkillMetadata(skillPath, directory);
105298
+ const meta3 = _internals58.readSkillMetadata(skillPath, directory);
105177
105299
  const compliancePct = Math.round(stats.complianceRate * 100);
105178
105300
  const topAgentNames = stats.topAgents.slice(0, 3).map((a) => a.agent).join(", ");
105179
105301
  lines.push(` - file:${meta3.path} - ${meta3.name}: ${meta3.description} (used: ${stats.totalUsage}, compliance: ${compliancePct}%)` + (stats.topAgents.length > 0 ? ` → ${topAgentNames}` : ""));
@@ -105181,15 +105303,15 @@ function formatSkillIndexWithContext(skills, directory) {
105181
105303
  return lines.join(`
105182
105304
  `);
105183
105305
  }
105184
- _internals57.computeSkillRelevanceScore = computeSkillRelevanceScore;
105185
- _internals57.rankSkillsForContext = rankSkillsForContext;
105186
- _internals57.getSkillStats = getSkillStats;
105187
- _internals57.formatSkillIndexWithContext = formatSkillIndexWithContext;
105188
- _internals57.parseSkillFrontmatter = parseSkillFrontmatter;
105189
- _internals57.readSkillMetadata = readSkillMetadata;
105190
- _internals57.extractSkillName = extractSkillName;
105191
- _internals57.computeRecencyScore = computeRecencyScore;
105192
- _internals57.computeContextMatchScore = computeContextMatchScore;
105306
+ _internals58.computeSkillRelevanceScore = computeSkillRelevanceScore;
105307
+ _internals58.rankSkillsForContext = rankSkillsForContext;
105308
+ _internals58.getSkillStats = getSkillStats;
105309
+ _internals58.formatSkillIndexWithContext = formatSkillIndexWithContext;
105310
+ _internals58.parseSkillFrontmatter = parseSkillFrontmatter;
105311
+ _internals58.readSkillMetadata = readSkillMetadata;
105312
+ _internals58.extractSkillName = extractSkillName;
105313
+ _internals58.computeRecencyScore = computeRecencyScore;
105314
+ _internals58.computeContextMatchScore = computeContextMatchScore;
105193
105315
 
105194
105316
  // src/hooks/skill-propagation-gate.ts
105195
105317
  init_skill_usage_log();
@@ -105292,10 +105414,10 @@ function parseYamlValue(value) {
105292
105414
  }
105293
105415
  function loadRoutingSkills(directory, targetAgent) {
105294
105416
  const routingPath = path111.join(directory, ".opencode", "skill-routing.yaml");
105295
- if (!_internals58.existsSync(routingPath))
105417
+ if (!_internals59.existsSync(routingPath))
105296
105418
  return [];
105297
105419
  try {
105298
- const content = _internals58.readFileSync(routingPath, "utf-8");
105420
+ const content = _internals59.readFileSync(routingPath, "utf-8");
105299
105421
  const config3 = parseSimpleYaml(content);
105300
105422
  if (!config3?.routing)
105301
105423
  return [];
@@ -105322,7 +105444,7 @@ var SKILL_SEARCH_ROOTS = [
105322
105444
  ".claude/skills"
105323
105445
  ];
105324
105446
  var MAX_SCORING_SESSION_ENTRIES = 500;
105325
- var _internals58 = {
105447
+ var _internals59 = {
105326
105448
  readdirSync: fs73.readdirSync.bind(fs73),
105327
105449
  existsSync: fs73.existsSync.bind(fs73),
105328
105450
  statSync: fs73.statSync.bind(fs73),
@@ -105351,11 +105473,11 @@ function discoverAvailableSkills(directory) {
105351
105473
  const results = [];
105352
105474
  for (const root of SKILL_SEARCH_ROOTS) {
105353
105475
  const rootPath = path111.join(directory, root);
105354
- if (!_internals58.existsSync(rootPath))
105476
+ if (!_internals59.existsSync(rootPath))
105355
105477
  continue;
105356
105478
  let entries;
105357
105479
  try {
105358
- entries = _internals58.readdirSync(rootPath);
105480
+ entries = _internals59.readdirSync(rootPath);
105359
105481
  } catch {
105360
105482
  continue;
105361
105483
  }
@@ -105363,11 +105485,11 @@ function discoverAvailableSkills(directory) {
105363
105485
  if (entry.startsWith("."))
105364
105486
  continue;
105365
105487
  const skillDir = path111.join(rootPath, entry);
105366
- if (_internals58.existsSync(path111.join(skillDir, "retired.marker")))
105488
+ if (_internals59.existsSync(path111.join(skillDir, "retired.marker")))
105367
105489
  continue;
105368
105490
  const skillFile = path111.join(skillDir, "SKILL.md");
105369
105491
  try {
105370
- if (_internals58.statSync(skillDir).isDirectory() && _internals58.existsSync(skillFile)) {
105492
+ if (_internals59.statSync(skillDir).isDirectory() && _internals59.existsSync(skillFile)) {
105371
105493
  results.push(path111.join(root, entry, "SKILL.md").replace(/\\/g, "/"));
105372
105494
  }
105373
105495
  } catch (err2) {
@@ -105399,7 +105521,7 @@ function parseDelegationArgs(args2) {
105399
105521
  }
105400
105522
  if (!targetAgent)
105401
105523
  return null;
105402
- const skillsField = prompt ? _internals58.extractSkillsFieldFromPrompt(prompt) : "";
105524
+ const skillsField = prompt ? _internals59.extractSkillsFieldFromPrompt(prompt) : "";
105403
105525
  return { targetAgent, skillsField };
105404
105526
  }
105405
105527
  function extractSkillsFieldFromPrompt(prompt) {
@@ -105440,10 +105562,10 @@ function writeWarnEvent2(directory, record3) {
105440
105562
  const filePath = path111.join(directory, ".swarm", "events.jsonl");
105441
105563
  try {
105442
105564
  const dir = path111.dirname(filePath);
105443
- if (!_internals58.existsSync(dir)) {
105444
- _internals58.mkdirSync(dir, { recursive: true });
105565
+ if (!_internals59.existsSync(dir)) {
105566
+ _internals59.mkdirSync(dir, { recursive: true });
105445
105567
  }
105446
- _internals58.appendFileSync(filePath, `${JSON.stringify(record3)}
105568
+ _internals59.appendFileSync(filePath, `${JSON.stringify(record3)}
105447
105569
  `, "utf-8");
105448
105570
  } catch (err2) {
105449
105571
  warn(`[skill-propagation-gate] failed to write warning event: ${err2 instanceof Error ? err2.message : String(err2)}`);
@@ -105494,19 +105616,19 @@ async function skillPropagationGateBefore(directory, input, config3) {
105494
105616
  const baseAgent = stripKnownSwarmPrefix(agentRaw);
105495
105617
  if (baseAgent !== "architect")
105496
105618
  return { blocked: false, reason: null, recommendedSkills: undefined };
105497
- const parsed = _internals58.parseDelegationArgs(input.args);
105619
+ const parsed = _internals59.parseDelegationArgs(input.args);
105498
105620
  if (!parsed)
105499
105621
  return { blocked: false, reason: null, recommendedSkills: undefined };
105500
105622
  const targetBase = stripKnownSwarmPrefix(parsed.targetAgent);
105501
- if (!_internals58.SKILL_CAPABLE_AGENTS.has(targetBase))
105623
+ if (!_internals59.SKILL_CAPABLE_AGENTS.has(targetBase))
105502
105624
  return { blocked: false, reason: null, recommendedSkills: undefined };
105503
105625
  const sessionID = typeof input.sessionID === "string" ? input.sessionID : "unknown";
105504
- const availableSkills = _internals58.discoverAvailableSkills(directory);
105626
+ const availableSkills = _internals59.discoverAvailableSkills(directory);
105505
105627
  const skillsValue = parsed.skillsField.trim();
105506
105628
  if (skillsValue && skillsValue.toLowerCase() !== "none") {
105507
105629
  const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
105508
- const taskId = _internals58.extractTaskIdFromPrompt(prompt);
105509
- const skillPaths = _internals58.parseSkillPaths(skillsValue);
105630
+ const taskId = _internals59.extractTaskIdFromPrompt(prompt);
105631
+ const skillPaths = _internals59.parseSkillPaths(skillsValue);
105510
105632
  let coderSkillPaths = [];
105511
105633
  if (prompt) {
105512
105634
  for (const line of prompt.split(`
@@ -105514,7 +105636,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
105514
105636
  const trimmed = line.trim();
105515
105637
  if (trimmed.startsWith("SKILLS_USED_BY_CODER:")) {
105516
105638
  const fieldVal = trimmed.slice("SKILLS_USED_BY_CODER:".length).trim();
105517
- coderSkillPaths = _internals58.parseSkillPaths(fieldVal);
105639
+ coderSkillPaths = _internals59.parseSkillPaths(fieldVal);
105518
105640
  break;
105519
105641
  }
105520
105642
  }
@@ -105522,7 +105644,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
105522
105644
  const allPaths = [...new Set([...skillPaths, ...coderSkillPaths])];
105523
105645
  for (const skillPath of allPaths) {
105524
105646
  try {
105525
- _internals58.appendSkillUsageEntry(directory, {
105647
+ _internals59.appendSkillUsageEntry(directory, {
105526
105648
  skillPath,
105527
105649
  agentName: targetBase,
105528
105650
  taskID: taskId,
@@ -105539,17 +105661,17 @@ async function skillPropagationGateBefore(directory, input, config3) {
105539
105661
  let scored = [];
105540
105662
  if (skillsValue && skillsValue.toLowerCase() !== "none" && availableSkills.length > 0) {
105541
105663
  try {
105542
- const sessionEntries = _internals58.readSkillUsageEntriesTail(directory, {
105664
+ const sessionEntries = _internals59.readSkillUsageEntriesTail(directory, {
105543
105665
  sessionID
105544
105666
  });
105545
- if (sessionEntries.length > _internals58.MAX_SCORING_SESSION_ENTRIES) {
105667
+ if (sessionEntries.length > _internals59.MAX_SCORING_SESSION_ENTRIES) {
105546
105668
  scoringSkipped = true;
105547
- warn(`[skill-propagation-gate] skipping scoring — tail window has ${sessionEntries.length} session entries (limit: ${_internals58.MAX_SCORING_SESSION_ENTRIES})`);
105669
+ warn(`[skill-propagation-gate] skipping scoring — tail window has ${sessionEntries.length} session entries (limit: ${_internals59.MAX_SCORING_SESSION_ENTRIES})`);
105548
105670
  } else {
105549
105671
  const prompt = typeof input.args?.prompt === "string" ? String(input.args.prompt) : "";
105550
105672
  scored = availableSkills.map((skillPath) => {
105551
105673
  const skillEntries = sessionEntries.filter((e) => e.skillPath === skillPath);
105552
- const score = _internals58.computeSkillRelevanceScore(skillPath, prompt, skillEntries);
105674
+ const score = _internals59.computeSkillRelevanceScore(skillPath, prompt, skillEntries);
105553
105675
  return { skillPath, score, usageCount: skillEntries.length };
105554
105676
  }).sort((a, b) => b.score - a.score || b.usageCount - a.usageCount);
105555
105677
  if (scored.length > 0) {
@@ -105563,12 +105685,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
105563
105685
  }
105564
105686
  }
105565
105687
  try {
105566
- const routingPaths = _internals58.loadRoutingSkills(directory, targetBase);
105688
+ const routingPaths = _internals59.loadRoutingSkills(directory, targetBase);
105567
105689
  if (routingPaths.length > 0) {
105568
105690
  const existingPaths = new Set(scored.map((s) => s.skillPath));
105569
105691
  for (const routingPath of routingPaths) {
105570
105692
  const routedSkillDir = path111.dirname(path111.join(directory, routingPath));
105571
- if (_internals58.existsSync(path111.join(routedSkillDir, "retired.marker")))
105693
+ if (_internals59.existsSync(path111.join(routedSkillDir, "retired.marker")))
105572
105694
  continue;
105573
105695
  if (!existingPaths.has(routingPath)) {
105574
105696
  scored.push({
@@ -105594,12 +105716,12 @@ async function skillPropagationGateBefore(directory, input, config3) {
105594
105716
  } else if (typeof scored !== "undefined" && scored.length > 0) {
105595
105717
  skillsForIndex = scored.map((r) => r.skillPath);
105596
105718
  }
105597
- const formattedIndex = _internals58.formatSkillIndexWithContext(skillsForIndex, directory);
105719
+ const formattedIndex = _internals59.formatSkillIndexWithContext(skillsForIndex, directory);
105598
105720
  if (formattedIndex.length > 0) {
105599
105721
  const contextPath = path111.join(directory, ".swarm", "context.md");
105600
105722
  let existingContent = "";
105601
- if (_internals58.existsSync(contextPath)) {
105602
- existingContent = _internals58.readFileSync(contextPath, "utf-8");
105723
+ if (_internals59.existsSync(contextPath)) {
105724
+ existingContent = _internals59.readFileSync(contextPath, "utf-8");
105603
105725
  }
105604
105726
  const sectionHeader = "## Available Skills";
105605
105727
  const newSection = `${sectionHeader}
@@ -105619,10 +105741,10 @@ ${newSection}`;
105619
105741
  }
105620
105742
  }
105621
105743
  const swarmDir = path111.dirname(contextPath);
105622
- if (!_internals58.existsSync(swarmDir)) {
105623
- _internals58.mkdirSync(swarmDir, { recursive: true });
105744
+ if (!_internals59.existsSync(swarmDir)) {
105745
+ _internals59.mkdirSync(swarmDir, { recursive: true });
105624
105746
  }
105625
- _internals58.writeFileSync(contextPath, updatedContent, "utf-8");
105747
+ _internals59.writeFileSync(contextPath, updatedContent, "utf-8");
105626
105748
  }
105627
105749
  } catch (err2) {
105628
105750
  warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err2 instanceof Error ? err2.message : String(err2)}`);
@@ -105648,7 +105770,7 @@ ${newSection}`;
105648
105770
  });
105649
105771
  const warningMsg = `Skill propagation warning: Delegating to ${targetBase} without SKILLS field. ` + `Available skills: ${skillNames.join(", ")}`;
105650
105772
  try {
105651
- _internals58.writeWarnEvent(directory, {
105773
+ _internals59.writeWarnEvent(directory, {
105652
105774
  type: "skill_propagation_warn",
105653
105775
  timestamp: new Date().toISOString(),
105654
105776
  tool: toolName,
@@ -105677,7 +105799,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
105677
105799
  let dedupKeys = new Set;
105678
105800
  let existingEntries = [];
105679
105801
  try {
105680
- existingEntries = _internals58.readSkillUsageEntriesTail(directory, {
105802
+ existingEntries = _internals59.readSkillUsageEntriesTail(directory, {
105681
105803
  sessionID
105682
105804
  });
105683
105805
  dedupKeys = new Set(existingEntries.map((e, i2) => {
@@ -105709,7 +105831,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
105709
105831
  `)) {
105710
105832
  const coderMatch = line.trim().match(CODER_SKILLS_PATTERN);
105711
105833
  if (coderMatch) {
105712
- const parsed = _internals58.parseSkillPaths(coderMatch[1]);
105834
+ const parsed = _internals59.parseSkillPaths(coderMatch[1]);
105713
105835
  skillPaths.push(...parsed);
105714
105836
  }
105715
105837
  }
@@ -105740,7 +105862,7 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
105740
105862
  if (isDuplicate(skillPath, "reviewer", resolvedTaskID))
105741
105863
  continue;
105742
105864
  try {
105743
- _internals58.appendSkillUsageEntry(directory, {
105865
+ _internals59.appendSkillUsageEntry(directory, {
105744
105866
  skillPath,
105745
105867
  agentName: "reviewer",
105746
105868
  taskID: resolvedTaskID,
@@ -105784,15 +105906,15 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
105784
105906
  skillsField = trimmed.slice("SKILLS:".length).trim();
105785
105907
  }
105786
105908
  if (currentTargetAgent && skillsField && skillsField.toLowerCase() !== "none") {
105787
- const skillPaths = _internals58.parseSkillPaths(skillsField);
105788
- const taskId = _internals58.extractTaskIdFromPrompt(text);
105909
+ const skillPaths = _internals59.parseSkillPaths(skillsField);
105910
+ const taskId = _internals59.extractTaskIdFromPrompt(text);
105789
105911
  for (const skillPath of skillPaths) {
105790
105912
  if (hadRecordingError)
105791
105913
  break;
105792
105914
  if (isDuplicate(skillPath, currentTargetAgent, taskId))
105793
105915
  continue;
105794
105916
  try {
105795
- _internals58.appendSkillUsageEntry(directory, {
105917
+ _internals59.appendSkillUsageEntry(directory, {
105796
105918
  skillPath,
105797
105919
  agentName: currentTargetAgent,
105798
105920
  taskID: taskId,
@@ -105812,16 +105934,16 @@ async function skillPropagationTransformScan(directory, output, sessionID) {
105812
105934
  break;
105813
105935
  }
105814
105936
  }
105815
- _internals58.skillPropagationGateBefore = skillPropagationGateBefore;
105816
- _internals58.skillPropagationTransformScan = skillPropagationTransformScan;
105817
- _internals58.writeWarnEvent = writeWarnEvent2;
105818
- _internals58.discoverAvailableSkills = discoverAvailableSkills;
105819
- _internals58.parseDelegationArgs = parseDelegationArgs;
105820
- _internals58.parseSkillPaths = parseSkillPaths;
105821
- _internals58.extractTaskIdFromPrompt = extractTaskIdFromPrompt;
105822
- _internals58.extractSkillsFieldFromPrompt = extractSkillsFieldFromPrompt;
105823
- _internals58.formatSkillIndexWithContext = formatSkillIndexWithContext;
105824
- _internals58.loadRoutingSkills = loadRoutingSkills;
105937
+ _internals59.skillPropagationGateBefore = skillPropagationGateBefore;
105938
+ _internals59.skillPropagationTransformScan = skillPropagationTransformScan;
105939
+ _internals59.writeWarnEvent = writeWarnEvent2;
105940
+ _internals59.discoverAvailableSkills = discoverAvailableSkills;
105941
+ _internals59.parseDelegationArgs = parseDelegationArgs;
105942
+ _internals59.parseSkillPaths = parseSkillPaths;
105943
+ _internals59.extractTaskIdFromPrompt = extractTaskIdFromPrompt;
105944
+ _internals59.extractSkillsFieldFromPrompt = extractSkillsFieldFromPrompt;
105945
+ _internals59.formatSkillIndexWithContext = formatSkillIndexWithContext;
105946
+ _internals59.loadRoutingSkills = loadRoutingSkills;
105825
105947
 
105826
105948
  // src/index.ts
105827
105949
  init_skill_usage_log();
@@ -109936,7 +110058,7 @@ var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
109936
110058
  var COUNCIL_GATE_NAME = "council";
109937
110059
  var COUNCIL_AGENT_ID = "architect";
109938
110060
  var EvidenceFileSchema = exports_external.record(exports_external.string(), exports_external.unknown());
109939
- var _internals59 = {
110061
+ var _internals60 = {
109940
110062
  withTaskEvidenceLock
109941
110063
  };
109942
110064
  var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -109971,7 +110093,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
109971
110093
  const dir = join102(workingDir, EVIDENCE_DIR2);
109972
110094
  mkdirSync32(dir, { recursive: true });
109973
110095
  const filePath = taskEvidencePath(workingDir, synthesis.taskId);
109974
- await _internals59.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
110096
+ await _internals60.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
109975
110097
  const existingRoot = Object.create(null);
109976
110098
  if (existsSync69(filePath)) {
109977
110099
  try {
@@ -115092,7 +115214,7 @@ function resolveDefaultReviewerAgent(generatedAgentNames) {
115092
115214
  }
115093
115215
  async function compileReviewPackage(directory, phase, sessionID, requireDiffSummary) {
115094
115216
  const lanes = await listLaneEvidence(directory, phase);
115095
- const persisted = _internals60.readPersisted?.(directory) ?? null;
115217
+ const persisted = _internals61.readPersisted?.(directory) ?? null;
115096
115218
  if (persisted) {
115097
115219
  let matchingRunState = null;
115098
115220
  for (const sessionState of Object.values(persisted.sessions)) {
@@ -115284,7 +115406,7 @@ Be specific and evidence-based. Do not approve a phase with unresolved degraded
115284
115406
  client.session.delete({ path: { id: sessionId } }).catch(() => {});
115285
115407
  }
115286
115408
  }
115287
- var _internals60 = {
115409
+ var _internals61 = {
115288
115410
  compileReviewPackage,
115289
115411
  parseReviewerVerdict,
115290
115412
  writeReviewerEvidence,
@@ -115301,28 +115423,28 @@ async function dispatchPhaseReviewer(directory, phase, sessionID, config3) {
115301
115423
  };
115302
115424
  const generatedAgentNames = swarmState.generatedAgentNames;
115303
115425
  const agentName = mergedConfig.reviewerAgent || resolveDefaultReviewerAgent(generatedAgentNames);
115304
- const pkg = await _internals60.compileReviewPackage(directory, phase, sessionID, mergedConfig.requireDiffSummary);
115426
+ const pkg = await _internals61.compileReviewPackage(directory, phase, sessionID, mergedConfig.requireDiffSummary);
115305
115427
  let responseText;
115306
115428
  try {
115307
- responseText = await _internals60.dispatchReviewerAgent(directory, pkg, agentName, mergedConfig.timeoutMs);
115429
+ responseText = await _internals61.dispatchReviewerAgent(directory, pkg, agentName, mergedConfig.timeoutMs);
115308
115430
  } catch (error93) {
115309
- const evidencePath2 = await _internals60.writeReviewerEvidence(directory, phase, "REJECTED", error93 instanceof Error ? error93.message : String(error93));
115431
+ const evidencePath2 = await _internals61.writeReviewerEvidence(directory, phase, "REJECTED", error93 instanceof Error ? error93.message : String(error93));
115310
115432
  return {
115311
115433
  verdict: "REJECTED",
115312
115434
  reason: `Reviewer dispatch failed: ${error93 instanceof Error ? error93.message : String(error93)}`,
115313
115435
  evidencePath: evidencePath2
115314
115436
  };
115315
115437
  }
115316
- const parsed = _internals60.parseReviewerVerdict(responseText);
115438
+ const parsed = _internals61.parseReviewerVerdict(responseText);
115317
115439
  if (!parsed) {
115318
- const evidencePath2 = await _internals60.writeReviewerEvidence(directory, phase, "REJECTED", "Reviewer response could not be parsed");
115440
+ const evidencePath2 = await _internals61.writeReviewerEvidence(directory, phase, "REJECTED", "Reviewer response could not be parsed");
115319
115441
  return {
115320
115442
  verdict: "REJECTED",
115321
115443
  reason: "Reviewer response could not be parsed",
115322
115444
  evidencePath: evidencePath2
115323
115445
  };
115324
115446
  }
115325
- const evidencePath = await _internals60.writeReviewerEvidence(directory, phase, parsed.verdict, parsed.reason);
115447
+ const evidencePath = await _internals61.writeReviewerEvidence(directory, phase, parsed.verdict, parsed.reason);
115326
115448
  return {
115327
115449
  verdict: parsed.verdict,
115328
115450
  reason: parsed.reason,
@@ -115829,7 +115951,7 @@ ${fileList}
115829
115951
 
115830
115952
  // src/tools/lean-turbo-run-phase.ts
115831
115953
  init_create_tool();
115832
- var _internals61 = {
115954
+ var _internals62 = {
115833
115955
  LeanTurboRunner,
115834
115956
  loadPluginConfigWithMeta
115835
115957
  };
@@ -115839,9 +115961,9 @@ async function executeLeanTurboRunPhase(args2) {
115839
115961
  let runError = null;
115840
115962
  let runner = null;
115841
115963
  try {
115842
- const { config: config3 } = _internals61.loadPluginConfigWithMeta(directory);
115964
+ const { config: config3 } = _internals62.loadPluginConfigWithMeta(directory);
115843
115965
  const leanConfig = config3.turbo?.strategy === "lean" ? config3.turbo.lean : undefined;
115844
- runner = new _internals61.LeanTurboRunner({
115966
+ runner = new _internals62.LeanTurboRunner({
115845
115967
  directory,
115846
115968
  sessionID,
115847
115969
  opencodeClient: swarmState.opencodeClient ?? null,
@@ -116202,7 +116324,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
116202
116324
  const strippedMutated = stripCode(mutatedCode);
116203
116325
  return strippedOriginal === strippedMutated;
116204
116326
  }
116205
- var _internals62 = {
116327
+ var _internals63 = {
116206
116328
  isStaticallyEquivalent,
116207
116329
  checkEquivalence,
116208
116330
  batchCheckEquivalence
@@ -116242,7 +116364,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
116242
116364
  const results = [];
116243
116365
  for (const { patch, originalCode, mutatedCode } of patches) {
116244
116366
  try {
116245
- const result = await _internals62.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
116367
+ const result = await _internals63.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
116246
116368
  results.push(result);
116247
116369
  } catch (err2) {
116248
116370
  results.push({
@@ -116261,7 +116383,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
116261
116383
  var MUTATION_TIMEOUT_MS = 30000;
116262
116384
  var TOTAL_BUDGET_MS = 300000;
116263
116385
  var GIT_APPLY_TIMEOUT_MS = 5000;
116264
- var _internals63 = {
116386
+ var _internals64 = {
116265
116387
  executeMutation,
116266
116388
  computeReport,
116267
116389
  executeMutationSuite,
@@ -116293,7 +116415,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
116293
116415
  };
116294
116416
  }
116295
116417
  try {
116296
- const applyResult = _internals63.spawnSync("git", ["apply", "--", patchFile], {
116418
+ const applyResult = _internals64.spawnSync("git", ["apply", "--", patchFile], {
116297
116419
  cwd: workingDir,
116298
116420
  timeout: GIT_APPLY_TIMEOUT_MS,
116299
116421
  stdio: "pipe"
@@ -116322,7 +116444,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
116322
116444
  }
116323
116445
  let testPassed = false;
116324
116446
  try {
116325
- const spawnResult = _internals63.spawnSync(testCommand[0], testCommand.slice(1), {
116447
+ const spawnResult = _internals64.spawnSync(testCommand[0], testCommand.slice(1), {
116326
116448
  cwd: workingDir,
116327
116449
  timeout: MUTATION_TIMEOUT_MS,
116328
116450
  stdio: "pipe"
@@ -116355,7 +116477,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
116355
116477
  } finally {
116356
116478
  if (patchFile) {
116357
116479
  try {
116358
- const revertResult = _internals63.spawnSync("git", ["apply", "-R", "--", patchFile], {
116480
+ const revertResult = _internals64.spawnSync("git", ["apply", "-R", "--", patchFile], {
116359
116481
  cwd: workingDir,
116360
116482
  timeout: GIT_APPLY_TIMEOUT_MS,
116361
116483
  stdio: "pipe"
@@ -116548,7 +116670,7 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
116548
116670
  }
116549
116671
 
116550
116672
  // src/mutation/gate.ts
116551
- var _internals64 = {
116673
+ var _internals65 = {
116552
116674
  evaluateMutationGate,
116553
116675
  buildTestImprovementPrompt,
116554
116676
  buildMessage
@@ -116569,8 +116691,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
116569
116691
  } else {
116570
116692
  verdict = "fail";
116571
116693
  }
116572
- const testImprovementPrompt = _internals64.buildTestImprovementPrompt(report, passThreshold, verdict);
116573
- const message = _internals64.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
116694
+ const testImprovementPrompt = _internals65.buildTestImprovementPrompt(report, passThreshold, verdict);
116695
+ const message = _internals65.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
116574
116696
  return {
116575
116697
  verdict,
116576
116698
  killRate: report.killRate,
@@ -116965,7 +117087,7 @@ function listLaneEvidenceSync(directory, phase) {
116965
117087
  }
116966
117088
  return laneIds;
116967
117089
  }
116968
- var _internals65 = {
117090
+ var _internals66 = {
116969
117091
  listActiveLocks,
116970
117092
  readPersisted: readPersisted2,
116971
117093
  readPlanJson: defaultReadPlanJson,
@@ -117026,7 +117148,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117026
117148
  reason: "Lean Turbo state unreadable or missing"
117027
117149
  };
117028
117150
  }
117029
- const persisted = _internals65.readPersisted(directory);
117151
+ const persisted = _internals66.readPersisted(directory);
117030
117152
  if (!persisted) {
117031
117153
  return {
117032
117154
  ok: false,
@@ -117090,7 +117212,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117090
117212
  }
117091
117213
  }
117092
117214
  if (runState.lanes.length > 0) {
117093
- const evidenceLaneIds = new Set(_internals65.listLaneEvidenceSync(directory, phase));
117215
+ const evidenceLaneIds = new Set(_internals66.listLaneEvidenceSync(directory, phase));
117094
117216
  for (const lane of runState.lanes) {
117095
117217
  if ((lane.status === "completed" || lane.status === "failed") && !evidenceLaneIds.has(lane.laneId)) {
117096
117218
  return {
@@ -117100,7 +117222,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117100
117222
  }
117101
117223
  }
117102
117224
  }
117103
- const activeLocks = _internals65.listActiveLocks(directory);
117225
+ const activeLocks = _internals66.listActiveLocks(directory);
117104
117226
  const phaseLaneIds = new Set(laneIds);
117105
117227
  for (const lock of activeLocks) {
117106
117228
  if (lock.laneId && phaseLaneIds.has(lock.laneId)) {
@@ -117120,7 +117242,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117120
117242
  }
117121
117243
  const serialDegradedTasks = runState.degradedTasks.filter((dt) => !laneTaskIds.has(dt.taskId));
117122
117244
  if (serialDegradedTasks.length > 0) {
117123
- const plan = _internals65.readPlanJson(directory);
117245
+ const plan = _internals66.readPlanJson(directory);
117124
117246
  if (!plan) {
117125
117247
  return {
117126
117248
  ok: false,
@@ -117164,7 +117286,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117164
117286
  }
117165
117287
  const serializedTasks = runState.serializedTasks;
117166
117288
  if (Array.isArray(serializedTasks) && serializedTasks.length > 0) {
117167
- const plan = _internals65.readPlanJson(directory);
117289
+ const plan = _internals66.readPlanJson(directory);
117168
117290
  if (!plan) {
117169
117291
  return {
117170
117292
  ok: false,
@@ -117223,7 +117345,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117223
117345
  }
117224
117346
  let reviewerVerdict = runState.lastReviewerVerdict;
117225
117347
  if (!reviewerVerdict) {
117226
- const evidence = _internals65.readReviewerEvidence(directory, phase);
117348
+ const evidence = _internals66.readReviewerEvidence(directory, phase);
117227
117349
  reviewerVerdict = evidence?.verdict ?? undefined;
117228
117350
  }
117229
117351
  if (mergedConfig.phase_reviewer) {
@@ -117236,7 +117358,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
117236
117358
  }
117237
117359
  let criticVerdict = runState.lastCriticVerdict;
117238
117360
  if (!criticVerdict) {
117239
- const evidence = _internals65.readCriticEvidence(directory, phase);
117361
+ const evidence = _internals66.readCriticEvidence(directory, phase);
117240
117362
  criticVerdict = evidence?.verdict ?? undefined;
117241
117363
  }
117242
117364
  if (mergedConfig.phase_critic) {
@@ -118336,7 +118458,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
118336
118458
  phase_critic: leanConfig.phase_critic,
118337
118459
  integrated_diff_required: leanConfig.integrated_diff_required
118338
118460
  } : undefined;
118339
- const leanCheck = _internals65.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
118461
+ const leanCheck = _internals66.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
118340
118462
  if (!leanCheck.ok) {
118341
118463
  return JSON.stringify({
118342
118464
  success: false,
@@ -120599,11 +120721,11 @@ var quality_budget = createSwarmTool({
120599
120721
  }).optional().describe("Quality budget thresholds")
120600
120722
  },
120601
120723
  async execute(args2, directory) {
120602
- const result = await _internals67.qualityBudget(args2, directory);
120724
+ const result = await _internals68.qualityBudget(args2, directory);
120603
120725
  return JSON.stringify(result);
120604
120726
  }
120605
120727
  });
120606
- var _internals67 = {
120728
+ var _internals68 = {
120607
120729
  qualityBudget
120608
120730
  };
120609
120731
 
@@ -121332,7 +121454,7 @@ import * as path149 from "node:path";
121332
121454
  var semgrepAvailableCache = null;
121333
121455
  var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
121334
121456
  var DEFAULT_TIMEOUT_MS3 = 30000;
121335
- var _internals68 = {
121457
+ var _internals69 = {
121336
121458
  isSemgrepAvailable,
121337
121459
  checkSemgrepAvailable,
121338
121460
  resetSemgrepCache,
@@ -121357,7 +121479,7 @@ function isSemgrepAvailable() {
121357
121479
  }
121358
121480
  }
121359
121481
  async function checkSemgrepAvailable() {
121360
- return _internals68.isSemgrepAvailable();
121482
+ return _internals69.isSemgrepAvailable();
121361
121483
  }
121362
121484
  function resetSemgrepCache() {
121363
121485
  semgrepAvailableCache = null;
@@ -121454,12 +121576,12 @@ async function runSemgrep(options) {
121454
121576
  const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS3;
121455
121577
  if (files.length === 0) {
121456
121578
  return {
121457
- available: _internals68.isSemgrepAvailable(),
121579
+ available: _internals69.isSemgrepAvailable(),
121458
121580
  findings: [],
121459
121581
  engine: "tier_a"
121460
121582
  };
121461
121583
  }
121462
- if (!_internals68.isSemgrepAvailable()) {
121584
+ if (!_internals69.isSemgrepAvailable()) {
121463
121585
  return {
121464
121586
  available: false,
121465
121587
  findings: [],
@@ -121618,7 +121740,7 @@ function assignOccurrenceIndices(findings, directory) {
121618
121740
  }
121619
121741
  const occIdx = countMap.get(baseKey) ?? 0;
121620
121742
  countMap.set(baseKey, occIdx + 1);
121621
- const fp = _internals69.fingerprintFinding(finding, directory, occIdx);
121743
+ const fp = _internals70.fingerprintFinding(finding, directory, occIdx);
121622
121744
  return {
121623
121745
  finding,
121624
121746
  index: occIdx,
@@ -121687,7 +121809,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
121687
121809
  }
121688
121810
  } catch {}
121689
121811
  const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
121690
- const indexed = _internals69.assignOccurrenceIndices(findings, directory);
121812
+ const indexed = _internals70.assignOccurrenceIndices(findings, directory);
121691
121813
  if (existing && !opts?.force) {
121692
121814
  const prunedFingerprints = existing.fingerprints.filter((fp) => {
121693
121815
  const relFile = fp.slice(0, fp.indexOf("|"));
@@ -121827,7 +121949,7 @@ function loadBaseline(directory, phase) {
121827
121949
  };
121828
121950
  }
121829
121951
  }
121830
- var _internals69 = {
121952
+ var _internals70 = {
121831
121953
  fingerprintFinding,
121832
121954
  assignOccurrenceIndices,
121833
121955
  captureOrMergeBaseline,
@@ -122237,11 +122359,11 @@ var sast_scan = createSwarmTool({
122237
122359
  capture_baseline: safeArgs.capture_baseline,
122238
122360
  phase: safeArgs.phase
122239
122361
  };
122240
- const result = await _internals70.sastScan(input, directory);
122362
+ const result = await _internals71.sastScan(input, directory);
122241
122363
  return JSON.stringify(result, null, 2);
122242
122364
  }
122243
122365
  });
122244
- var _internals70 = {
122366
+ var _internals71 = {
122245
122367
  sastScan,
122246
122368
  sast_scan
122247
122369
  };
@@ -127187,7 +127309,7 @@ var swarm_memory_propose = createSwarmTool({
127187
127309
  evidenceRefs: exports_external.array(exports_external.string().min(1).max(500)).max(20).optional().describe("Evidence refs such as files, commits, test outputs, or URLs")
127188
127310
  },
127189
127311
  execute: async (args2, directory, ctx) => {
127190
- const { config: config3 } = _internals71.loadPluginConfigWithMeta(directory);
127312
+ const { config: config3 } = _internals72.loadPluginConfigWithMeta(directory);
127191
127313
  if (config3.memory?.enabled !== true) {
127192
127314
  return JSON.stringify({
127193
127315
  success: false,
@@ -127203,7 +127325,7 @@ var swarm_memory_propose = createSwarmTool({
127203
127325
  });
127204
127326
  }
127205
127327
  const agent = getContextAgent2(ctx);
127206
- const gateway = _internals71.createMemoryGateway({
127328
+ const gateway = _internals72.createMemoryGateway({
127207
127329
  directory,
127208
127330
  sessionID: ctx?.sessionID,
127209
127331
  agentRole: agent,
@@ -127228,7 +127350,7 @@ var swarm_memory_propose = createSwarmTool({
127228
127350
  }
127229
127351
  }
127230
127352
  });
127231
- var _internals71 = {
127353
+ var _internals72 = {
127232
127354
  loadPluginConfigWithMeta,
127233
127355
  createMemoryGateway
127234
127356
  };
@@ -127266,7 +127388,7 @@ var swarm_memory_recall = createSwarmTool({
127266
127388
  maxItems: exports_external.number().int().min(1).max(20).optional().describe("Maximum memories to return")
127267
127389
  },
127268
127390
  execute: async (args2, directory, ctx) => {
127269
- const { config: config3 } = _internals72.loadPluginConfigWithMeta(directory);
127391
+ const { config: config3 } = _internals73.loadPluginConfigWithMeta(directory);
127270
127392
  if (config3.memory?.enabled !== true) {
127271
127393
  return JSON.stringify({
127272
127394
  success: false,
@@ -127282,7 +127404,7 @@ var swarm_memory_recall = createSwarmTool({
127282
127404
  });
127283
127405
  }
127284
127406
  const agent = getContextAgent3(ctx);
127285
- const gateway = _internals72.createMemoryGateway({
127407
+ const gateway = _internals73.createMemoryGateway({
127286
127408
  directory,
127287
127409
  sessionID: ctx?.sessionID,
127288
127410
  agentRole: agent,
@@ -127315,7 +127437,7 @@ var RecallArgsSchema = exports_external.object({
127315
127437
  kinds: exports_external.array(exports_external.enum(MEMORY_KINDS2)).optional(),
127316
127438
  maxItems: exports_external.number().int().min(1).max(20).optional()
127317
127439
  });
127318
- var _internals72 = {
127440
+ var _internals73 = {
127319
127441
  loadPluginConfigWithMeta,
127320
127442
  createMemoryGateway
127321
127443
  };
@@ -127830,7 +127952,7 @@ import * as path165 from "node:path";
127830
127952
  init_bun_compat();
127831
127953
  import * as fs122 from "node:fs";
127832
127954
  import * as path164 from "node:path";
127833
- var _internals73 = { bunSpawn };
127955
+ var _internals74 = { bunSpawn };
127834
127956
  var _swarmGitExcludedChecked = false;
127835
127957
  function fileCoversSwarm(content) {
127836
127958
  for (const rawLine of content.split(`
@@ -127863,7 +127985,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
127863
127985
  checkIgnoreExitCode
127864
127986
  ] = await Promise.all([
127865
127987
  (async () => {
127866
- const proc = _internals73.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
127988
+ const proc = _internals74.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
127867
127989
  try {
127868
127990
  return await Promise.all([proc.exited, proc.stdout.text()]);
127869
127991
  } finally {
@@ -127873,7 +127995,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
127873
127995
  }
127874
127996
  })(),
127875
127997
  (async () => {
127876
- const proc = _internals73.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
127998
+ const proc = _internals74.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
127877
127999
  try {
127878
128000
  return await Promise.all([proc.exited, proc.stdout.text()]);
127879
128001
  } finally {
@@ -127883,7 +128005,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
127883
128005
  }
127884
128006
  })(),
127885
128007
  (async () => {
127886
- const proc = _internals73.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
128008
+ const proc = _internals74.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
127887
128009
  try {
127888
128010
  return await proc.exited;
127889
128011
  } finally {
@@ -127922,7 +128044,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
127922
128044
  }
127923
128045
  } catch {}
127924
128046
  }
127925
- const trackedProc = _internals73.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
128047
+ const trackedProc = _internals74.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
127926
128048
  let trackedExitCode;
127927
128049
  let trackedOutput;
127928
128050
  try {
@@ -127947,7 +128069,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
127947
128069
  }
127948
128070
 
127949
128071
  // src/hooks/diff-scope.ts
127950
- var _internals74 = { bunSpawn };
128072
+ var _internals75 = { bunSpawn };
127951
128073
  function getDeclaredScope(taskId, directory) {
127952
128074
  try {
127953
128075
  const planPath = path165.join(directory, ".swarm", "plan.json");
@@ -127982,7 +128104,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
127982
128104
  };
127983
128105
  async function getChangedFiles(directory) {
127984
128106
  try {
127985
- const proc = _internals74.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
128107
+ const proc = _internals75.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
127986
128108
  cwd: directory,
127987
128109
  ...GIT_DIFF_SPAWN_OPTIONS
127988
128110
  });
@@ -127999,7 +128121,7 @@ async function getChangedFiles(directory) {
127999
128121
  return stdout.trim().split(`
128000
128122
  `).map((f) => f.trim()).filter((f) => f.length > 0);
128001
128123
  }
128002
- const proc2 = _internals74.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
128124
+ const proc2 = _internals75.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
128003
128125
  cwd: directory,
128004
128126
  ...GIT_DIFF_SPAWN_OPTIONS
128005
128127
  });
@@ -128057,7 +128179,7 @@ init_telemetry();
128057
128179
  init_file_locks();
128058
128180
  import * as fs124 from "node:fs";
128059
128181
  import * as path166 from "node:path";
128060
- var _internals75 = {
128182
+ var _internals76 = {
128061
128183
  listActiveLocks,
128062
128184
  verifyLeanTurboTaskCompletion
128063
128185
  };
@@ -128199,7 +128321,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
128199
128321
  }
128200
128322
  };
128201
128323
  }
128202
- const activeLocks = _internals75.listActiveLocks(directory);
128324
+ const activeLocks = _internals76.listActiveLocks(directory);
128203
128325
  const laneLocks = activeLocks.filter((lock) => lock.laneId === lane.laneId);
128204
128326
  if (laneLocks.length > 0) {
128205
128327
  return {
@@ -129098,7 +129220,7 @@ var web_search = createSwarmTool({
129098
129220
  });
129099
129221
  async function captureSearchEvidence(directory, query, results) {
129100
129222
  try {
129101
- const written = await _internals76.writeEvidenceDocuments(directory, results.map((result) => ({
129223
+ const written = await _internals77.writeEvidenceDocuments(directory, results.map((result) => ({
129102
129224
  sourceType: "web_search",
129103
129225
  query,
129104
129226
  title: result.title,
@@ -129126,7 +129248,7 @@ async function captureSearchEvidence(directory, query, results) {
129126
129248
  };
129127
129249
  }
129128
129250
  }
129129
- var _internals76 = {
129251
+ var _internals77 = {
129130
129252
  writeEvidenceDocuments
129131
129253
  };
129132
129254
 
@@ -130376,7 +130498,7 @@ async function initializeOpenCodeSwarm(ctx) {
130376
130498
  ...opencodeConfig.command || {},
130377
130499
  swarm: {
130378
130500
  template: "/swarm $ARGUMENTS",
130379
- description: "Swarm management commands: /swarm [status|show-plan|plan|agents|history|config|help|evidence|handoff|archive|diagnose|diagnosis|preflight|sync-plan|benchmark|export|reset|rollback|retrieve|clarify|analyze|specify|brainstorm|council|pr-review|issue|qa-gates|dark-matter|knowledge|memory|curate|concurrency|turbo|full-auto|write-retro|reset-session|simulate|promote|checkpoint|acknowledge-spec-drift|doctor tools|finalize|close]"
130501
+ description: "Swarm management commands: /swarm [status|show-plan|plan|agents|history|config|help|evidence|handoff|archive|diagnose|diagnosis|preflight|sync-plan|benchmark|export|reset|rollback|retrieve|clarify|analyze|specify|brainstorm|council|pr-review|pr-feedback|deep-dive|design-docs|issue|qa-gates|dark-matter|knowledge|memory|curate|concurrency|turbo|full-auto|write-retro|reset-session|simulate|promote|checkpoint|acknowledge-spec-drift|doctor tools|finalize|close]"
130380
130502
  },
130381
130503
  "swarm-status": {
130382
130504
  template: "/swarm status",
@@ -130474,10 +130596,18 @@ async function initializeOpenCodeSwarm(ctx) {
130474
130596
  template: "/swarm pr-review $ARGUMENTS",
130475
130597
  description: "Use /swarm pr-review to launch deep PR review with multi-lane analysis"
130476
130598
  },
130599
+ "swarm-pr-feedback": {
130600
+ template: "/swarm pr-feedback $ARGUMENTS",
130601
+ description: "Use /swarm pr-feedback to ingest and close known PR feedback (review comments, CI failures, conflicts) without a fresh broad review"
130602
+ },
130477
130603
  "swarm-deep-dive": {
130478
130604
  template: "/swarm deep-dive $ARGUMENTS",
130479
130605
  description: "Use /swarm deep-dive to launch a read-only deep audit with parallel explorer waves, dual reviewers, and critic challenge"
130480
130606
  },
130607
+ "swarm-design-docs": {
130608
+ template: "/swarm design-docs $ARGUMENTS",
130609
+ description: "Use /swarm design-docs to generate or sync language-agnostic design docs for the project under build"
130610
+ },
130481
130611
  "swarm-issue": {
130482
130612
  template: "/swarm issue $ARGUMENTS",
130483
130613
  description: "Use /swarm issue to ingest a GitHub issue into the swarm workflow"