opencode-swarm 7.52.2 → 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/cli/index.js CHANGED
@@ -52,7 +52,7 @@ var package_default;
52
52
  var init_package = __esm(() => {
53
53
  package_default = {
54
54
  name: "opencode-swarm",
55
- version: "7.52.2",
55
+ version: "7.53.0",
56
56
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
57
57
  main: "dist/index.js",
58
58
  types: "dist/index.d.ts",
@@ -49905,7 +49905,7 @@ var init_plan = __esm(() => {
49905
49905
  init_plan_service();
49906
49906
  });
49907
49907
 
49908
- // src/commands/pr-review.ts
49908
+ // src/commands/pr-ref.ts
49909
49909
  import { execSync as execSync3 } from "child_process";
49910
49910
  function sanitizeUrl2(raw) {
49911
49911
  let urlStr = raw.trim();
@@ -49924,6 +49924,22 @@ function sanitizeUrl2(raw) {
49924
49924
  }
49925
49925
  return urlStr.trim();
49926
49926
  }
49927
+ function sanitizeInstructions(raw) {
49928
+ const collapsed = raw.replace(/\s+/g, " ").trim();
49929
+ const stripped = collapsed.replace(/\[\s*MODE\s*:[^\]]*\]/gi, "");
49930
+ const normalized = stripped.replace(/\s+/g, " ").trim();
49931
+ if (normalized.length <= MAX_INSTRUCTIONS_LEN)
49932
+ return normalized;
49933
+ return `${normalized.slice(0, MAX_INSTRUCTIONS_LEN)}\u2026`;
49934
+ }
49935
+ function hasNonAsciiHostname(hostname5) {
49936
+ for (const ch of hostname5) {
49937
+ const cp = ch.codePointAt(0);
49938
+ if (cp !== undefined && cp > 127)
49939
+ return true;
49940
+ }
49941
+ return false;
49942
+ }
49927
49943
  function isPrivateHost2(url3) {
49928
49944
  const host = url3.hostname.toLowerCase();
49929
49945
  if (host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "0.0.0.0") {
@@ -49958,8 +49974,7 @@ function validateAndSanitizeUrl2(rawUrl) {
49958
49974
  }
49959
49975
  try {
49960
49976
  const url3 = new URL(sanitized);
49961
- const hostname5 = url3.hostname;
49962
- if (/[\u0080-\u{10FFFF}]/u.test(hostname5)) {
49977
+ if (hasNonAsciiHostname(url3.hostname)) {
49963
49978
  return { error: "Non-ASCII hostnames are not allowed" };
49964
49979
  }
49965
49980
  if (isPrivateHost2(url3)) {
@@ -49976,18 +49991,7 @@ function validateAndSanitizeUrl2(rawUrl) {
49976
49991
  return { error: "Invalid URL format" };
49977
49992
  }
49978
49993
  }
49979
- function parseArgs5(args) {
49980
- const out = { council: false, rest: [] };
49981
- for (const token of args) {
49982
- if (token === "--council") {
49983
- out.council = true;
49984
- continue;
49985
- }
49986
- out.rest.push(token);
49987
- }
49988
- return out;
49989
- }
49990
- function parsePrRef(input) {
49994
+ function parsePrRef(input, cwd) {
49991
49995
  const urlMatch = input.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)\/?$/i);
49992
49996
  if (urlMatch) {
49993
49997
  return {
@@ -50007,7 +50011,7 @@ function parsePrRef(input) {
50007
50011
  const bareMatch = input.match(/^(\d+)$/);
50008
50012
  if (bareMatch) {
50009
50013
  const prNumber = parseInt(bareMatch[1], 10);
50010
- const remoteUrl = detectGitRemote2();
50014
+ const remoteUrl = detectGitRemote2(cwd);
50011
50015
  if (!remoteUrl) {
50012
50016
  return null;
50013
50017
  }
@@ -50023,12 +50027,13 @@ function parsePrRef(input) {
50023
50027
  }
50024
50028
  return null;
50025
50029
  }
50026
- function detectGitRemote2() {
50030
+ function detectGitRemote2(cwd) {
50027
50031
  try {
50028
- const remoteUrl = execSync3("git remote get-url origin", {
50032
+ const remoteUrl = _internals21.execSync("git remote get-url origin", {
50029
50033
  encoding: "utf-8",
50030
50034
  stdio: ["pipe", "pipe", "pipe"],
50031
- timeout: 5000
50035
+ timeout: 5000,
50036
+ ...cwd ? { cwd } : {}
50032
50037
  }).trim();
50033
50038
  return remoteUrl || null;
50034
50039
  } catch {
@@ -50059,41 +50064,115 @@ function parseGitRemoteUrl2(remoteUrl) {
50059
50064
  }
50060
50065
  return null;
50061
50066
  }
50062
- function handlePrReviewCommand(_directory, args) {
50063
- const parsed = parseArgs5(args);
50064
- const rawInput = parsed.rest.join(" ").trim();
50065
- if (!rawInput) {
50066
- return USAGE5;
50067
+ function looksLikePrRef(token) {
50068
+ return /^https?:\/\//i.test(token) || /^[^/]+\/[^#]+#\d+$/.test(token) || /^\d+$/.test(token);
50069
+ }
50070
+ function resolvePrCommandInput(rest, cwd) {
50071
+ if (rest.length === 0) {
50072
+ return null;
50067
50073
  }
50068
- const isFullUrl = /^https?:\/\//i.test(rawInput);
50069
- const prInfo = parsePrRef(isFullUrl ? sanitizeUrl2(rawInput) : rawInput);
50074
+ const refToken = rest[0];
50075
+ const instructions = sanitizeInstructions(rest.slice(1).join(" "));
50076
+ const isFullUrl = /^https?:\/\//i.test(refToken);
50077
+ const prInfo = parsePrRef(isFullUrl ? sanitizeUrl2(refToken) : refToken, cwd);
50070
50078
  if (!prInfo) {
50071
- return `Error: Could not parse PR reference from "${rawInput}"
50072
-
50073
- ${USAGE5}`;
50079
+ return { error: `Could not parse PR reference from "${refToken}"` };
50074
50080
  }
50075
50081
  const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
50076
50082
  const result = validateAndSanitizeUrl2(prUrl);
50077
50083
  if ("error" in result) {
50078
- return `Error: ${result.error}
50084
+ return { error: result.error };
50085
+ }
50086
+ return { prUrl: result.sanitized, instructions };
50087
+ }
50088
+ var _internals21, MAX_URL_LEN2 = 2048, MAX_INSTRUCTIONS_LEN = 1000;
50089
+ var init_pr_ref = __esm(() => {
50090
+ _internals21 = { execSync: execSync3 };
50091
+ });
50092
+
50093
+ // src/commands/pr-feedback.ts
50094
+ function handlePrFeedbackCommand(directory, args) {
50095
+ const rest = args.filter((t) => t.trim().length > 0);
50096
+ if (rest.length === 0) {
50097
+ return "[MODE: PR_FEEDBACK]";
50098
+ }
50099
+ const resolved = resolvePrCommandInput(rest, directory);
50100
+ if (resolved && "prUrl" in resolved) {
50101
+ const signal = `[MODE: PR_FEEDBACK pr="${resolved.prUrl}"]`;
50102
+ return resolved.instructions ? `${signal} ${resolved.instructions}` : signal;
50103
+ }
50104
+ if (resolved && "error" in resolved && looksLikePrRef(rest[0])) {
50105
+ return [
50106
+ `Error: ${resolved.error}`,
50107
+ "",
50108
+ "That looked like a PR reference but could not be resolved. Pass a full",
50109
+ "URL or `owner/repo#N`, or omit the reference to start a no-PR feedback",
50110
+ "session (e.g. `/swarm pr-feedback address the review notes`)."
50111
+ ].join(`
50112
+ `);
50113
+ }
50114
+ const instructions = sanitizeInstructions(rest.join(" "));
50115
+ return instructions ? `[MODE: PR_FEEDBACK] ${instructions}` : "[MODE: PR_FEEDBACK]";
50116
+ }
50117
+ var init_pr_feedback = __esm(() => {
50118
+ init_pr_ref();
50119
+ });
50120
+
50121
+ // src/commands/pr-review.ts
50122
+ function parseArgs5(args) {
50123
+ const out = { council: false, rest: [] };
50124
+ for (const token of args) {
50125
+ if (token === "--council") {
50126
+ out.council = true;
50127
+ continue;
50128
+ }
50129
+ if (token.startsWith("--")) {
50130
+ if (out.unknownFlag === undefined)
50131
+ out.unknownFlag = token;
50132
+ continue;
50133
+ }
50134
+ if (token.trim().length === 0)
50135
+ continue;
50136
+ out.rest.push(token);
50137
+ }
50138
+ return out;
50139
+ }
50140
+ function handlePrReviewCommand(directory, args) {
50141
+ const parsed = parseArgs5(args);
50142
+ if (parsed.unknownFlag) {
50143
+ return `Error: Unknown flag "${parsed.unknownFlag}"
50144
+
50145
+ ${USAGE5}`;
50146
+ }
50147
+ const resolved = resolvePrCommandInput(parsed.rest, directory);
50148
+ if (resolved === null) {
50149
+ return USAGE5;
50150
+ }
50151
+ if ("error" in resolved) {
50152
+ return `Error: ${resolved.error}
50079
50153
 
50080
50154
  ${USAGE5}`;
50081
50155
  }
50082
50156
  const councilFlag = parsed.council ? "council=true" : "council=false";
50083
- return `[MODE: PR_REVIEW pr="${result.sanitized}" ${councilFlag}]`;
50157
+ const signal = `[MODE: PR_REVIEW pr="${resolved.prUrl}" ${councilFlag}]`;
50158
+ return resolved.instructions ? `${signal} ${resolved.instructions}` : signal;
50084
50159
  }
50085
- var MAX_URL_LEN2 = 2048, USAGE5;
50160
+ var USAGE5;
50086
50161
  var init_pr_review = __esm(() => {
50162
+ init_pr_ref();
50087
50163
  USAGE5 = [
50088
- "Usage: /swarm pr-review <url|owner/repo#N|N> [--council]",
50164
+ "Usage: /swarm pr-review <url|owner/repo#N|N> [--council] [instructions...]",
50089
50165
  "",
50090
50166
  "Run a full swarm PR review on a GitHub pull request.",
50091
50167
  " /swarm pr-review https://github.com/owner/repo/pull/42",
50092
50168
  " /swarm pr-review owner/repo#42",
50093
50169
  " /swarm pr-review 42 --council",
50170
+ " /swarm pr-review 42 focus on the auth refactor and the new retry logic",
50094
50171
  "",
50095
50172
  "Flags:",
50096
- " --council Run adversarial council variant (all lanes assume work is wrong)"
50173
+ " --council Run adversarial council variant (all lanes assume work is wrong)",
50174
+ "",
50175
+ "Any text after the PR reference is forwarded to the reviewer as extra instructions."
50097
50176
  ].join(`
50098
50177
  `);
50099
50178
  });
@@ -50483,7 +50562,7 @@ async function runAdditionalLint(linter, mode, cwd) {
50483
50562
  };
50484
50563
  }
50485
50564
  }
50486
- var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals21;
50565
+ var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals22;
50487
50566
  var init_lint = __esm(() => {
50488
50567
  init_zod();
50489
50568
  init_discovery();
@@ -50515,15 +50594,15 @@ var init_lint = __esm(() => {
50515
50594
  }
50516
50595
  const { mode } = args;
50517
50596
  const cwd = directory;
50518
- const linter = await _internals21.detectAvailableLinter(directory);
50597
+ const linter = await _internals22.detectAvailableLinter(directory);
50519
50598
  if (linter) {
50520
- const result = await _internals21.runLint(linter, mode, directory);
50599
+ const result = await _internals22.runLint(linter, mode, directory);
50521
50600
  return JSON.stringify(result, null, 2);
50522
50601
  }
50523
- const additionalLinter = _internals21.detectAdditionalLinter(cwd);
50602
+ const additionalLinter = _internals22.detectAdditionalLinter(cwd);
50524
50603
  if (additionalLinter) {
50525
50604
  warn(`[lint] Using ${additionalLinter} linter for this project`);
50526
- const result = await _internals21.runAdditionalLint(additionalLinter, mode, cwd);
50605
+ const result = await _internals22.runAdditionalLint(additionalLinter, mode, cwd);
50527
50606
  return JSON.stringify(result, null, 2);
50528
50607
  }
50529
50608
  const errorResult = {
@@ -50537,7 +50616,7 @@ For Rust: rustup component add clippy`
50537
50616
  return JSON.stringify(errorResult, null, 2);
50538
50617
  }
50539
50618
  });
50540
- _internals21 = {
50619
+ _internals22 = {
50541
50620
  detectAvailableLinter,
50542
50621
  runLint,
50543
50622
  detectAdditionalLinter,
@@ -50851,7 +50930,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
50851
50930
  }
50852
50931
  async function runSecretscan(directory) {
50853
50932
  try {
50854
- const result = await _internals22.secretscan.execute({ directory }, {});
50933
+ const result = await _internals23.secretscan.execute({ directory }, {});
50855
50934
  const jsonStr = typeof result === "string" ? result : result.output;
50856
50935
  return JSON.parse(jsonStr);
50857
50936
  } catch (e) {
@@ -50866,7 +50945,7 @@ async function runSecretscan(directory) {
50866
50945
  return errorResult;
50867
50946
  }
50868
50947
  }
50869
- 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, _internals22;
50948
+ 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, _internals23;
50870
50949
  var init_secretscan = __esm(() => {
50871
50950
  init_zod();
50872
50951
  init_path_security();
@@ -51238,7 +51317,7 @@ var init_secretscan = __esm(() => {
51238
51317
  }
51239
51318
  }
51240
51319
  });
51241
- _internals22 = {
51320
+ _internals23 = {
51242
51321
  secretscan,
51243
51322
  runSecretscan
51244
51323
  };
@@ -51830,14 +51909,14 @@ function buildGoBackend() {
51830
51909
  selectEntryPoints
51831
51910
  };
51832
51911
  }
51833
- var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals23;
51912
+ var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals24;
51834
51913
  var init_go = __esm(() => {
51835
51914
  init_default_backend();
51836
51915
  init_profiles();
51837
51916
  IMPORT_REGEX_SINGLE = /^\s*import\s+(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/gm;
51838
51917
  IMPORT_REGEX_GROUP = /^\s*import\s*\(([\s\S]*?)\)/gm;
51839
51918
  IMPORT_REGEX_GROUP_LINE = /(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/g;
51840
- _internals23 = { extractImports };
51919
+ _internals24 = { extractImports };
51841
51920
  });
51842
51921
 
51843
51922
  // src/lang/backends/python.ts
@@ -51949,13 +52028,13 @@ function buildPythonBackend() {
51949
52028
  selectEntryPoints: selectEntryPoints2
51950
52029
  };
51951
52030
  }
51952
- var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals24;
52031
+ var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals25;
51953
52032
  var init_python = __esm(() => {
51954
52033
  init_default_backend();
51955
52034
  init_profiles();
51956
52035
  IMPORT_REGEX_FROM_WITH_TARGETS = /^\s*from\s+(\.*[\w.]*)\s+import\s+(\([^)]*\)|[^\n#]+)/gm;
51957
52036
  IMPORT_REGEX_IMPORT = /^\s*import\s+([^\n#]+)/gm;
51958
- _internals24 = { extractImports: extractImports2 };
52037
+ _internals25 = { extractImports: extractImports2 };
51959
52038
  });
51960
52039
 
51961
52040
  // src/test-impact/analyzer.ts
@@ -52179,7 +52258,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
52179
52258
  return;
52180
52259
  }
52181
52260
  if (PYTHON_EXTENSIONS.has(ext)) {
52182
- const modules = _internals24.extractImports(testFile, content);
52261
+ const modules = _internals25.extractImports(testFile, content);
52183
52262
  for (const mod of modules) {
52184
52263
  const resolved = resolvePythonImport(testDir, mod);
52185
52264
  if (resolved !== null)
@@ -52188,7 +52267,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
52188
52267
  return;
52189
52268
  }
52190
52269
  if (GO_EXTENSIONS.has(ext)) {
52191
- const imports = _internals23.extractImports(testFile, content);
52270
+ const imports = _internals24.extractImports(testFile, content);
52192
52271
  for (const importPath of imports) {
52193
52272
  const sourceFiles = resolveGoImport(testDir, importPath);
52194
52273
  for (const source of sourceFiles)
@@ -52215,8 +52294,8 @@ async function buildImpactMapInternal(cwd) {
52215
52294
  return impactMap;
52216
52295
  }
52217
52296
  async function buildImpactMap(cwd) {
52218
- const impactMap = await _internals25.buildImpactMapInternal(cwd);
52219
- await _internals25.saveImpactMap(cwd, impactMap);
52297
+ const impactMap = await _internals26.buildImpactMapInternal(cwd);
52298
+ await _internals26.saveImpactMap(cwd, impactMap);
52220
52299
  return impactMap;
52221
52300
  }
52222
52301
  async function loadImpactMap(cwd, options) {
@@ -52230,7 +52309,7 @@ async function loadImpactMap(cwd, options) {
52230
52309
  const hasValidValues = Object.values(map3).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
52231
52310
  if (hasValidValues) {
52232
52311
  const generatedAt = new Date(data.generatedAt).getTime();
52233
- if (!_internals25.isCacheStale(map3, generatedAt)) {
52312
+ if (!_internals26.isCacheStale(map3, generatedAt)) {
52234
52313
  return map3;
52235
52314
  }
52236
52315
  if (options?.skipRebuild) {
@@ -52250,13 +52329,13 @@ async function loadImpactMap(cwd, options) {
52250
52329
  if (options?.skipRebuild) {
52251
52330
  return {};
52252
52331
  }
52253
- return _internals25.buildImpactMap(cwd);
52332
+ return _internals26.buildImpactMap(cwd);
52254
52333
  }
52255
52334
  async function saveImpactMap(cwd, impactMap) {
52256
52335
  if (!path40.isAbsolute(cwd)) {
52257
52336
  throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
52258
52337
  }
52259
- _internals25.validateProjectRoot(cwd);
52338
+ _internals26.validateProjectRoot(cwd);
52260
52339
  const cacheDir2 = path40.join(cwd, ".swarm", "cache");
52261
52340
  const cachePath = path40.join(cacheDir2, "impact-map.json");
52262
52341
  if (!fs18.existsSync(cacheDir2)) {
@@ -52280,7 +52359,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
52280
52359
  };
52281
52360
  }
52282
52361
  const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
52283
- const impactMap = await _internals25.loadImpactMap(cwd);
52362
+ const impactMap = await _internals26.loadImpactMap(cwd);
52284
52363
  const impactedTestsSet = new Set;
52285
52364
  const untestedFiles = [];
52286
52365
  let visitedCount = 0;
@@ -52365,7 +52444,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
52365
52444
  budgetExceeded
52366
52445
  };
52367
52446
  }
52368
- var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals25;
52447
+ var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals26;
52369
52448
  var init_analyzer = __esm(() => {
52370
52449
  init_manager2();
52371
52450
  init_go();
@@ -52378,7 +52457,7 @@ var init_analyzer = __esm(() => {
52378
52457
  GO_EXTENSIONS = new Set([".go"]);
52379
52458
  EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
52380
52459
  goModuleCache = new Map;
52381
- _internals25 = {
52460
+ _internals26 = {
52382
52461
  validateProjectRoot,
52383
52462
  normalizePath,
52384
52463
  isCacheStale,
@@ -52714,7 +52793,7 @@ function batchAppendTestRuns(records, workingDir) {
52714
52793
  }
52715
52794
  const historyPath = getHistoryPath(workingDir);
52716
52795
  const historyDir = path41.dirname(historyPath);
52717
- _internals26.validateProjectRoot(workingDir);
52796
+ _internals27.validateProjectRoot(workingDir);
52718
52797
  if (!fs19.existsSync(historyDir)) {
52719
52798
  fs19.mkdirSync(historyDir, { recursive: true });
52720
52799
  }
@@ -52837,7 +52916,7 @@ function getAllHistory(workingDir) {
52837
52916
  records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
52838
52917
  return records;
52839
52918
  }
52840
- 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, _internals26;
52919
+ 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, _internals27;
52841
52920
  var init_history_store = __esm(() => {
52842
52921
  init_manager2();
52843
52922
  DANGEROUS_PROPERTY_NAMES = new Set([
@@ -52845,7 +52924,7 @@ var init_history_store = __esm(() => {
52845
52924
  "constructor",
52846
52925
  "prototype"
52847
52926
  ]);
52848
- _internals26 = {
52927
+ _internals27 = {
52849
52928
  validateProjectRoot
52850
52929
  };
52851
52930
  });
@@ -52971,7 +53050,7 @@ function readPackageJsonRaw(dir) {
52971
53050
  }
52972
53051
  }
52973
53052
  function readPackageJson(dir) {
52974
- return _internals27.readPackageJsonRaw(dir);
53053
+ return _internals28.readPackageJsonRaw(dir);
52975
53054
  }
52976
53055
  function readPackageJsonTestScript(dir) {
52977
53056
  return readPackageJson(dir)?.scripts?.test ?? null;
@@ -53141,7 +53220,7 @@ function buildTypescriptBackend() {
53141
53220
  selectEntryPoints: selectEntryPoints3
53142
53221
  };
53143
53222
  }
53144
- var PROFILE_ID3 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals27;
53223
+ var PROFILE_ID3 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals28;
53145
53224
  var init_typescript = __esm(() => {
53146
53225
  init_default_backend();
53147
53226
  init_profiles();
@@ -53150,7 +53229,7 @@ var init_typescript = __esm(() => {
53150
53229
  IMPORT_REGEX_REQUIRE2 = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
53151
53230
  IMPORT_REGEX_DYNAMIC = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
53152
53231
  IMPORT_REGEX_REEXPORT2 = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
53153
- _internals27 = {
53232
+ _internals28 = {
53154
53233
  readPackageJsonRaw,
53155
53234
  readPackageJsonTestScript,
53156
53235
  frameworkFromScriptsTest
@@ -53181,7 +53260,7 @@ __export(exports_dispatch, {
53181
53260
  pickedProfiles: () => pickedProfiles,
53182
53261
  pickBackend: () => pickBackend,
53183
53262
  clearDispatchCache: () => clearDispatchCache,
53184
- _internals: () => _internals28
53263
+ _internals: () => _internals29
53185
53264
  });
53186
53265
  import * as fs22 from "fs";
53187
53266
  import * as path44 from "path";
@@ -53236,7 +53315,7 @@ function findManifestRoot(start) {
53236
53315
  return start;
53237
53316
  }
53238
53317
  function evictIfNeeded() {
53239
- if (cache.size <= _internals28.cacheCapacity)
53318
+ if (cache.size <= _internals29.cacheCapacity)
53240
53319
  return;
53241
53320
  let oldestKey;
53242
53321
  let oldestOrder = Infinity;
@@ -53267,7 +53346,7 @@ async function pickBackend(dir) {
53267
53346
  evictIfNeeded();
53268
53347
  return null;
53269
53348
  }
53270
- const profiles = await _internals28.detectProjectLanguages(root);
53349
+ const profiles = await _internals29.detectProjectLanguages(root);
53271
53350
  if (profiles.length === 0) {
53272
53351
  cache.set(cacheKey, {
53273
53352
  hash: hash3,
@@ -53299,12 +53378,12 @@ function clearDispatchCache() {
53299
53378
  manifestRootCache.clear();
53300
53379
  insertCounter = 0;
53301
53380
  }
53302
- var _internals28, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
53381
+ var _internals29, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
53303
53382
  var init_dispatch = __esm(() => {
53304
53383
  init_backends();
53305
53384
  init_detector();
53306
53385
  init_registry_backend();
53307
- _internals28 = {
53386
+ _internals29 = {
53308
53387
  detectProjectLanguages,
53309
53388
  cacheCapacity: 64
53310
53389
  };
@@ -55161,9 +55240,9 @@ function getVersionFileVersion(dir) {
55161
55240
  async function runVersionCheck(dir, _timeoutMs) {
55162
55241
  const startTime = Date.now();
55163
55242
  try {
55164
- const packageVersion = _internals29.getPackageVersion(dir);
55165
- const changelogVersion = _internals29.getChangelogVersion(dir);
55166
- const versionFileVersion = _internals29.getVersionFileVersion(dir);
55243
+ const packageVersion = _internals30.getPackageVersion(dir);
55244
+ const changelogVersion = _internals30.getChangelogVersion(dir);
55245
+ const versionFileVersion = _internals30.getVersionFileVersion(dir);
55167
55246
  const versions3 = [];
55168
55247
  if (packageVersion)
55169
55248
  versions3.push(`package.json: ${packageVersion}`);
@@ -55528,7 +55607,7 @@ async function runPreflight(dir, phase, config3) {
55528
55607
  const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
55529
55608
  let validatedDir;
55530
55609
  try {
55531
- validatedDir = _internals29.validateDirectoryPath(dir);
55610
+ validatedDir = _internals30.validateDirectoryPath(dir);
55532
55611
  } catch (error93) {
55533
55612
  return {
55534
55613
  id: reportId,
@@ -55548,7 +55627,7 @@ async function runPreflight(dir, phase, config3) {
55548
55627
  }
55549
55628
  let validatedTimeout;
55550
55629
  try {
55551
- validatedTimeout = _internals29.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
55630
+ validatedTimeout = _internals30.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
55552
55631
  } catch (error93) {
55553
55632
  return {
55554
55633
  id: reportId,
@@ -55589,12 +55668,12 @@ async function runPreflight(dir, phase, config3) {
55589
55668
  });
55590
55669
  const checks5 = [];
55591
55670
  log("[Preflight] Running lint check...");
55592
- const lintResult = await _internals29.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
55671
+ const lintResult = await _internals30.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
55593
55672
  checks5.push(lintResult);
55594
55673
  log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
55595
55674
  if (!cfg.skipTests) {
55596
55675
  log("[Preflight] Running tests check...");
55597
- const testsResult = await _internals29.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
55676
+ const testsResult = await _internals30.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
55598
55677
  checks5.push(testsResult);
55599
55678
  log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
55600
55679
  } else {
@@ -55606,7 +55685,7 @@ async function runPreflight(dir, phase, config3) {
55606
55685
  }
55607
55686
  if (!cfg.skipSecrets) {
55608
55687
  log("[Preflight] Running secrets check...");
55609
- const secretsResult = await _internals29.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
55688
+ const secretsResult = await _internals30.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
55610
55689
  checks5.push(secretsResult);
55611
55690
  log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
55612
55691
  } else {
@@ -55618,7 +55697,7 @@ async function runPreflight(dir, phase, config3) {
55618
55697
  }
55619
55698
  if (!cfg.skipEvidence) {
55620
55699
  log("[Preflight] Running evidence check...");
55621
- const evidenceResult = await _internals29.runEvidenceCheck(validatedDir);
55700
+ const evidenceResult = await _internals30.runEvidenceCheck(validatedDir);
55622
55701
  checks5.push(evidenceResult);
55623
55702
  log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
55624
55703
  } else {
@@ -55629,12 +55708,12 @@ async function runPreflight(dir, phase, config3) {
55629
55708
  });
55630
55709
  }
55631
55710
  log("[Preflight] Running requirement coverage check...");
55632
- const reqCoverageResult = await _internals29.runRequirementCoverageCheck(validatedDir, phase);
55711
+ const reqCoverageResult = await _internals30.runRequirementCoverageCheck(validatedDir, phase);
55633
55712
  checks5.push(reqCoverageResult);
55634
55713
  log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
55635
55714
  if (!cfg.skipVersion) {
55636
55715
  log("[Preflight] Running version check...");
55637
- const versionResult = await _internals29.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
55716
+ const versionResult = await _internals30.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
55638
55717
  checks5.push(versionResult);
55639
55718
  log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
55640
55719
  } else {
@@ -55697,10 +55776,10 @@ function formatPreflightMarkdown(report) {
55697
55776
  async function handlePreflightCommand(directory, _args) {
55698
55777
  const plan = await loadPlan(directory);
55699
55778
  const phase = plan?.current_phase ?? 1;
55700
- const report = await _internals29.runPreflight(directory, phase);
55701
- return _internals29.formatPreflightMarkdown(report);
55779
+ const report = await _internals30.runPreflight(directory, phase);
55780
+ return _internals30.formatPreflightMarkdown(report);
55702
55781
  }
55703
- var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals29;
55782
+ var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals30;
55704
55783
  var init_preflight_service = __esm(() => {
55705
55784
  init_gate_bridge();
55706
55785
  init_manager2();
@@ -55718,7 +55797,7 @@ var init_preflight_service = __esm(() => {
55718
55797
  testScope: "convention",
55719
55798
  linter: "biome"
55720
55799
  };
55721
- _internals29 = {
55800
+ _internals30 = {
55722
55801
  runPreflight,
55723
55802
  formatPreflightMarkdown,
55724
55803
  handlePreflightCommand,
@@ -57340,7 +57419,7 @@ async function getStatusData(directory, agents) {
57340
57419
  }
57341
57420
  function enrichWithLeanTurbo(status, directory) {
57342
57421
  const turboMode = hasActiveTurboMode();
57343
- const leanActive = _internals30.hasActiveLeanTurbo();
57422
+ const leanActive = _internals31.hasActiveLeanTurbo();
57344
57423
  let turboStrategy = "off";
57345
57424
  if (leanActive) {
57346
57425
  turboStrategy = "lean";
@@ -57359,7 +57438,7 @@ function enrichWithLeanTurbo(status, directory) {
57359
57438
  }
57360
57439
  }
57361
57440
  if (leanSessionID) {
57362
- const runState = _internals30.loadLeanTurboRunState(directory, leanSessionID);
57441
+ const runState = _internals31.loadLeanTurboRunState(directory, leanSessionID);
57363
57442
  if (runState) {
57364
57443
  status.leanTurboPhase = runState.phase;
57365
57444
  status.leanMaxParallelCoders = runState.maxParallelCoders;
@@ -57391,7 +57470,7 @@ function enrichWithLeanTurbo(status, directory) {
57391
57470
  }
57392
57471
  }
57393
57472
  }
57394
- status.fullAutoActive = _internals30.hasActiveFullAuto();
57473
+ status.fullAutoActive = _internals31.hasActiveFullAuto();
57395
57474
  return status;
57396
57475
  }
57397
57476
  function formatStatusMarkdown(status) {
@@ -57473,7 +57552,7 @@ async function handleStatusCommand(directory, agents) {
57473
57552
  }
57474
57553
  return formatStatusMarkdown(statusData);
57475
57554
  }
57476
- var _internals30;
57555
+ var _internals31;
57477
57556
  var init_status_service = __esm(() => {
57478
57557
  init_extractors();
57479
57558
  init_utils2();
@@ -57482,7 +57561,7 @@ var init_status_service = __esm(() => {
57482
57561
  init_state3();
57483
57562
  init_compaction_service();
57484
57563
  init_context_budget_service();
57485
- _internals30 = {
57564
+ _internals31 = {
57486
57565
  loadLeanTurboRunState,
57487
57566
  hasActiveLeanTurbo,
57488
57567
  hasActiveFullAuto
@@ -57573,7 +57652,7 @@ async function handleTurboCommand(directory, args, sessionID) {
57573
57652
  if (arg0 === "on") {
57574
57653
  let strategy = "standard";
57575
57654
  try {
57576
- const { config: config3 } = _internals31.loadPluginConfigWithMeta(directory);
57655
+ const { config: config3 } = _internals32.loadPluginConfigWithMeta(directory);
57577
57656
  if (config3.turbo?.strategy === "lean") {
57578
57657
  strategy = "lean";
57579
57658
  }
@@ -57628,7 +57707,7 @@ function enableLeanTurbo(session, directory, sessionID) {
57628
57707
  let maxParallelCoders = 4;
57629
57708
  let conflictPolicy = "serialize";
57630
57709
  try {
57631
- const { config: config3 } = _internals31.loadPluginConfigWithMeta(directory);
57710
+ const { config: config3 } = _internals32.loadPluginConfigWithMeta(directory);
57632
57711
  const leanConfig = config3.turbo?.lean;
57633
57712
  if (leanConfig) {
57634
57713
  maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
@@ -57698,13 +57777,13 @@ function buildStatusMessage2(session, directory, sessionID) {
57698
57777
  ].join(`
57699
57778
  `);
57700
57779
  }
57701
- var _internals31;
57780
+ var _internals32;
57702
57781
  var init_turbo = __esm(() => {
57703
57782
  init_config();
57704
57783
  init_state();
57705
57784
  init_state3();
57706
57785
  init_logger();
57707
- _internals31 = {
57786
+ _internals32 = {
57708
57787
  loadPluginConfigWithMeta
57709
57788
  };
57710
57789
  });
@@ -57797,7 +57876,7 @@ function formatCommandNotFound(tokens) {
57797
57876
  const attemptedCommand = tokens[0] || "";
57798
57877
  const MAX_DISPLAY = 100;
57799
57878
  const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
57800
- const similar = _internals32.findSimilarCommands(attemptedCommand);
57879
+ const similar = _internals33.findSimilarCommands(attemptedCommand);
57801
57880
  const header = `Command \`/swarm ${displayCommand}\` not found.`;
57802
57881
  const suggestions = similar.length > 0 ? `Did you mean:
57803
57882
  ${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
@@ -58299,7 +58378,7 @@ async function buildSwarmCommandPrompt(args) {
58299
58378
  activeAgentName,
58300
58379
  registeredAgents
58301
58380
  } = args;
58302
- const resolved = _internals32.resolveCommand(tokens);
58381
+ const resolved = _internals33.resolveCommand(tokens);
58303
58382
  if (!resolved) {
58304
58383
  if (tokens.length === 0) {
58305
58384
  return buildHelpText();
@@ -58360,6 +58439,19 @@ function agentHasSwarmCommandTool(activeAgentName, agents, registeredAgents) {
58360
58439
  return AGENT_TOOL_MAP[baseName]?.includes("swarm_command") === true;
58361
58440
  }
58362
58441
  function formatCanonicalPromptFallback(args) {
58442
+ if (/^\s*\[MODE:/.test(args.text)) {
58443
+ return [
58444
+ `The user typed \`${args.original}\`.`,
58445
+ "The line below is a swarm MODE-activation signal, NOT output to display.",
58446
+ "Enter the mode named in its `[MODE: X ...]` header now: follow your",
58447
+ 'prompt\u2019s "### MODE: X" section, load the SKILL.md it references, and',
58448
+ "follow that protocol exactly. Treat any text after the closing bracket as",
58449
+ "additional instructions. Do NOT echo this signal verbatim.",
58450
+ "",
58451
+ args.text
58452
+ ].join(`
58453
+ `);
58454
+ }
58363
58455
  return [
58364
58456
  `The user typed \`${args.original}\`.`,
58365
58457
  "Canonical opencode-swarm command output follows.",
@@ -58452,7 +58544,7 @@ function findSimilarCommands(query) {
58452
58544
  }
58453
58545
  const scored = VALID_COMMANDS.map((cmd) => {
58454
58546
  const cmdLower = cmd.toLowerCase();
58455
- const fullScore = _internals32.levenshteinDistance(q, cmdLower);
58547
+ const fullScore = _internals33.levenshteinDistance(q, cmdLower);
58456
58548
  let tokenScore = Infinity;
58457
58549
  if (cmd.includes(" ") || cmd.includes("-")) {
58458
58550
  const qTokens = q.split(/[\s-]+/);
@@ -58465,7 +58557,7 @@ function findSimilarCommands(query) {
58465
58557
  for (const ct of cmdTokens) {
58466
58558
  if (ct.length === 0)
58467
58559
  continue;
58468
- const dist = _internals32.levenshteinDistance(qt, ct);
58560
+ const dist = _internals33.levenshteinDistance(qt, ct);
58469
58561
  if (dist < minDist)
58470
58562
  minDist = dist;
58471
58563
  }
@@ -58475,7 +58567,7 @@ function findSimilarCommands(query) {
58475
58567
  }
58476
58568
  const dashStrippedQ = q.replace(/-/g, "");
58477
58569
  const dashStrippedCmd = cmdLower.replace(/-/g, "");
58478
- const dashScore = _internals32.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
58570
+ const dashScore = _internals33.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
58479
58571
  const score = Math.min(fullScore, tokenScore, dashScore);
58480
58572
  return { cmd, score };
58481
58573
  });
@@ -58507,11 +58599,11 @@ async function handleHelpCommand(ctx) {
58507
58599
  return buildHelpText2();
58508
58600
  }
58509
58601
  const tokens = targetCommand.split(/\s+/);
58510
- const resolved = _internals32.resolveCommand(tokens);
58602
+ const resolved = _internals33.resolveCommand(tokens);
58511
58603
  if (resolved) {
58512
- return _internals32.buildDetailedHelp(resolved.key, resolved.entry);
58604
+ return _internals33.buildDetailedHelp(resolved.key, resolved.entry);
58513
58605
  }
58514
- const similar = _internals32.findSimilarCommands(targetCommand);
58606
+ const similar = _internals33.findSimilarCommands(targetCommand);
58515
58607
  const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
58516
58608
  if (similar.length > 0) {
58517
58609
  return `Command '/swarm ${targetCommand}' not found.
@@ -58605,7 +58697,7 @@ function resolveCommand(tokens) {
58605
58697
  }
58606
58698
  return null;
58607
58699
  }
58608
- var COMMAND_REGISTRY, VALID_COMMANDS, _internals32, validation;
58700
+ var COMMAND_REGISTRY, VALID_COMMANDS, _internals33, validation;
58609
58701
  var init_registry = __esm(() => {
58610
58702
  init_acknowledge_spec_drift();
58611
58703
  init_agents();
@@ -58631,6 +58723,7 @@ var init_registry = __esm(() => {
58631
58723
  init_knowledge();
58632
58724
  init_memory2();
58633
58725
  init_plan();
58726
+ init_pr_feedback();
58634
58727
  init_pr_review();
58635
58728
  init_preflight();
58636
58729
  init_promote();
@@ -58678,7 +58771,7 @@ var init_registry = __esm(() => {
58678
58771
  clashesWithNativeCcCommand: "/agents"
58679
58772
  },
58680
58773
  help: {
58681
- handler: (ctx) => _internals32.handleHelpCommand(ctx),
58774
+ handler: (ctx) => _internals33.handleHelpCommand(ctx),
58682
58775
  description: "Show help for swarm commands",
58683
58776
  category: "core",
58684
58777
  args: "[command]",
@@ -58921,6 +59014,13 @@ Subcommands:
58921
59014
  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).",
58922
59015
  category: "agent"
58923
59016
  },
59017
+ "pr-feedback": {
59018
+ handler: async (ctx) => handlePrFeedbackCommand(ctx.directory, ctx.args),
59019
+ description: "Ingest and close known PR feedback (review comments, CI failures, conflicts) [pr] [instructions]",
59020
+ args: "[url|owner/repo#N|N] [instructions...]",
59021
+ details: "Triggers MODE: PR_FEEDBACK \u2014 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).",
59022
+ category: "agent"
59023
+ },
58924
59024
  "deep-dive": {
58925
59025
  handler: async (ctx) => handleDeepDiveCommand(ctx.directory, ctx.args),
58926
59026
  description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]",
@@ -59149,7 +59249,7 @@ Subcommands:
59149
59249
  }
59150
59250
  };
59151
59251
  VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
59152
- _internals32 = {
59252
+ _internals33 = {
59153
59253
  handleHelpCommand,
59154
59254
  validateAliases,
59155
59255
  resolveCommand,
@@ -59157,7 +59257,7 @@ Subcommands:
59157
59257
  findSimilarCommands,
59158
59258
  buildDetailedHelp
59159
59259
  };
59160
- validation = _internals32.validateAliases();
59260
+ validation = _internals33.validateAliases();
59161
59261
  if (!validation.valid) {
59162
59262
  throw new Error(`COMMAND_REGISTRY alias validation failed:
59163
59263
  ${validation.errors.join(`