opencode-swarm 7.8.0 → 7.8.1

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
@@ -34,7 +34,7 @@ var package_default;
34
34
  var init_package = __esm(() => {
35
35
  package_default = {
36
36
  name: "opencode-swarm",
37
- version: "7.8.0",
37
+ version: "7.8.1",
38
38
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
39
39
  main: "dist/index.js",
40
40
  types: "dist/index.d.ts",
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var package_default;
33
33
  var init_package = __esm(() => {
34
34
  package_default = {
35
35
  name: "opencode-swarm",
36
- version: "7.8.0",
36
+ version: "7.8.1",
37
37
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
38
38
  main: "dist/index.js",
39
39
  types: "dist/index.d.ts",
@@ -43835,8 +43835,10 @@ async function runCuratorInit(directory, config3, llmDelegate) {
43835
43835
  const timer = setTimeout(() => ac.abort(), timeoutMs);
43836
43836
  let llmOutput;
43837
43837
  try {
43838
+ const delegatePromise = llmDelegate(systemPrompt, userInput, ac.signal);
43839
+ delegatePromise.catch(() => {});
43838
43840
  llmOutput = await Promise.race([
43839
- llmDelegate(systemPrompt, userInput, ac.signal),
43841
+ delegatePromise,
43840
43842
  new Promise((_, reject) => {
43841
43843
  ac.signal.addEventListener("abort", () => reject(new Error("CURATOR_LLM_TIMEOUT")));
43842
43844
  })
@@ -43963,8 +43965,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43963
43965
  const timer = setTimeout(() => ac.abort(), timeoutMs);
43964
43966
  let llmOutput;
43965
43967
  try {
43968
+ const delegatePromise = llmDelegate(systemPrompt, userInput, ac.signal);
43969
+ delegatePromise.catch(() => {});
43966
43970
  llmOutput = await Promise.race([
43967
- llmDelegate(systemPrompt, userInput, ac.signal),
43971
+ delegatePromise,
43968
43972
  new Promise((_, reject) => {
43969
43973
  ac.signal.addEventListener("abort", () => reject(new Error("CURATOR_LLM_TIMEOUT")));
43970
43974
  })
@@ -65345,27 +65349,32 @@ __export(exports_runtime, {
65345
65349
  isGrammarAvailable: () => isGrammarAvailable,
65346
65350
  getSupportedLanguages: () => getSupportedLanguages,
65347
65351
  getInitializedLanguages: () => getInitializedLanguages,
65348
- clearParserCache: () => clearParserCache
65352
+ clearParserCache: () => clearParserCache,
65353
+ _internals: () => _internals25
65349
65354
  });
65350
65355
  import * as path67 from "node:path";
65351
65356
  import { fileURLToPath as fileURLToPath2 } from "node:url";
65352
65357
  async function initTreeSitter() {
65353
- if (treeSitterInitialized) {
65354
- return;
65355
- }
65356
- const thisDir = path67.dirname(fileURLToPath2(import.meta.url));
65357
- const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
65358
- if (isSource) {
65359
- await Parser.init();
65360
- } else {
65361
- const grammarsDir = getGrammarsDirAbsolute();
65362
- await Parser.init({
65363
- locateFile(scriptName) {
65364
- return path67.join(grammarsDir, scriptName);
65358
+ if (!treeSitterInitPromise) {
65359
+ treeSitterInitPromise = (async () => {
65360
+ const thisDir = path67.dirname(fileURLToPath2(import.meta.url));
65361
+ const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
65362
+ if (isSource) {
65363
+ await _internals25.parserInit();
65364
+ } else {
65365
+ const grammarsDir = getGrammarsDirAbsolute();
65366
+ await _internals25.parserInit({
65367
+ locateFile(scriptName) {
65368
+ return path67.join(grammarsDir, scriptName);
65369
+ }
65370
+ });
65365
65371
  }
65372
+ })().catch((err2) => {
65373
+ treeSitterInitPromise = null;
65374
+ throw err2;
65366
65375
  });
65367
65376
  }
65368
- treeSitterInitialized = true;
65377
+ return treeSitterInitPromise;
65369
65378
  }
65370
65379
  function sanitizeLanguageId(languageId) {
65371
65380
  const normalized = languageId.toLowerCase();
@@ -65448,7 +65457,7 @@ async function isGrammarAvailable(languageId) {
65448
65457
  function clearParserCache() {
65449
65458
  parserCache.clear();
65450
65459
  initializedLanguages.clear();
65451
- treeSitterInitialized = false;
65460
+ treeSitterInitPromise = null;
65452
65461
  }
65453
65462
  function getInitializedLanguages() {
65454
65463
  return Array.from(initializedLanguages);
@@ -65456,11 +65465,14 @@ function getInitializedLanguages() {
65456
65465
  function getSupportedLanguages() {
65457
65466
  return Object.keys(LANGUAGE_WASM_MAP);
65458
65467
  }
65459
- var parserCache, initializedLanguages, treeSitterInitialized = false, LANGUAGE_WASM_MAP;
65468
+ var parserCache, initializedLanguages, treeSitterInitPromise = null, _internals25, LANGUAGE_WASM_MAP;
65460
65469
  var init_runtime = __esm(() => {
65461
65470
  init_tree_sitter();
65462
65471
  parserCache = new Map;
65463
65472
  initializedLanguages = new Set;
65473
+ _internals25 = {
65474
+ parserInit: Parser.init
65475
+ };
65464
65476
  LANGUAGE_WASM_MAP = {
65465
65477
  javascript: "tree-sitter-javascript.wasm",
65466
65478
  typescript: "tree-sitter-typescript.wasm",
@@ -65878,9 +65890,9 @@ var init_doc_scan = __esm(() => {
65878
65890
  var exports_knowledge_recall = {};
65879
65891
  __export(exports_knowledge_recall, {
65880
65892
  knowledge_recall: () => knowledge_recall,
65881
- _internals: () => _internals25
65893
+ _internals: () => _internals26
65882
65894
  });
65883
- var knowledge_recall, _internals25;
65895
+ var knowledge_recall, _internals26;
65884
65896
  var init_knowledge_recall = __esm(() => {
65885
65897
  init_zod();
65886
65898
  init_knowledge_store();
@@ -65966,7 +65978,7 @@ var init_knowledge_recall = __esm(() => {
65966
65978
  return JSON.stringify(result);
65967
65979
  }
65968
65980
  });
65969
- _internals25 = {
65981
+ _internals26 = {
65970
65982
  knowledge_recall
65971
65983
  };
65972
65984
  });
@@ -66021,7 +66033,7 @@ __export(exports_curator_drift, {
66021
66033
  runDeterministicDriftCheck: () => runDeterministicDriftCheck,
66022
66034
  readPriorDriftReports: () => readPriorDriftReports,
66023
66035
  buildDriftInjectionText: () => buildDriftInjectionText,
66024
- _internals: () => _internals27
66036
+ _internals: () => _internals28
66025
66037
  });
66026
66038
  import * as fs54 from "node:fs";
66027
66039
  import * as path73 from "node:path";
@@ -66066,7 +66078,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
66066
66078
  try {
66067
66079
  const planMd = await readSwarmFileAsync(directory, "plan.md");
66068
66080
  const specMd = await readSwarmFileAsync(directory, "spec.md");
66069
- const priorReports = await _internals27.readPriorDriftReports(directory);
66081
+ const priorReports = await _internals28.readPriorDriftReports(directory);
66070
66082
  const complianceCount = curatorResult.compliance.length;
66071
66083
  const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
66072
66084
  let alignment = "ALIGNED";
@@ -66115,7 +66127,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
66115
66127
  scope_additions: [],
66116
66128
  injection_summary: injectionSummary
66117
66129
  };
66118
- const reportPath = await _internals27.writeDriftReport(directory, report);
66130
+ const reportPath = await _internals28.writeDriftReport(directory, report);
66119
66131
  getGlobalEventBus().publish("curator.drift.completed", {
66120
66132
  phase,
66121
66133
  alignment,
@@ -66178,12 +66190,12 @@ function buildDriftInjectionText(report, maxChars) {
66178
66190
  }
66179
66191
  return text.slice(0, maxChars);
66180
66192
  }
66181
- var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals27;
66193
+ var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals28;
66182
66194
  var init_curator_drift = __esm(() => {
66183
66195
  init_event_bus();
66184
66196
  init_logger();
66185
66197
  init_utils2();
66186
- _internals27 = {
66198
+ _internals28 = {
66187
66199
  readPriorDriftReports,
66188
66200
  writeDriftReport,
66189
66201
  runDeterministicDriftCheck,
@@ -67903,14 +67915,22 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
67903
67915
  throw new Error("CURATOR_LLM_TIMEOUT");
67904
67916
  }
67905
67917
  const agentName = resolveCuratorAgentName(mode, sessionId);
67906
- const promptResult = await client.session.prompt({
67907
- path: { id: ephemeralSessionId },
67908
- body: {
67909
- agent: agentName,
67910
- tools: { write: false, edit: false, patch: false },
67911
- parts: [{ type: "text", text: userInput }]
67918
+ let promptResult;
67919
+ try {
67920
+ promptResult = await client.session.prompt({
67921
+ path: { id: ephemeralSessionId },
67922
+ body: {
67923
+ agent: agentName,
67924
+ tools: { write: false, edit: false, patch: false },
67925
+ parts: [{ type: "text", text: userInput }]
67926
+ }
67927
+ });
67928
+ } catch (promptErr) {
67929
+ if (signal?.aborted) {
67930
+ throw new Error("CURATOR_LLM_TIMEOUT");
67912
67931
  }
67913
- });
67932
+ throw promptErr;
67933
+ }
67914
67934
  if (!promptResult.data) {
67915
67935
  throw new Error(`Curator LLM prompt failed: ${JSON.stringify(promptResult.error)}`);
67916
67936
  }
@@ -76307,10 +76327,10 @@ async function getRunMemorySummary(directory) {
76307
76327
  if (entries.length === 0) {
76308
76328
  return null;
76309
76329
  }
76310
- const groups = _internals26.groupByTaskId(entries);
76330
+ const groups = _internals27.groupByTaskId(entries);
76311
76331
  const summaries = [];
76312
76332
  for (const [taskId, taskEntries] of groups) {
76313
- const summary = _internals26.summarizeTask(taskId, taskEntries);
76333
+ const summary = _internals27.summarizeTask(taskId, taskEntries);
76314
76334
  if (summary) {
76315
76335
  summaries.push(summary);
76316
76336
  }
@@ -76343,7 +76363,7 @@ Use this data to avoid repeating known failure patterns.`;
76343
76363
  }
76344
76364
  return prefix + summaryText + suffix;
76345
76365
  }
76346
- var _internals26 = {
76366
+ var _internals27 = {
76347
76367
  generateTaskFingerprint,
76348
76368
  recordOutcome,
76349
76369
  getTaskHistory,
@@ -86442,11 +86462,11 @@ var quality_budget = createSwarmTool({
86442
86462
  }).optional().describe("Quality budget thresholds")
86443
86463
  },
86444
86464
  async execute(args2, directory) {
86445
- const result = await _internals28.qualityBudget(args2, directory);
86465
+ const result = await _internals29.qualityBudget(args2, directory);
86446
86466
  return JSON.stringify(result);
86447
86467
  }
86448
86468
  });
86449
- var _internals28 = {
86469
+ var _internals29 = {
86450
86470
  qualityBudget
86451
86471
  };
86452
86472
 
@@ -87175,7 +87195,7 @@ import * as path97 from "node:path";
87175
87195
  var semgrepAvailableCache = null;
87176
87196
  var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
87177
87197
  var DEFAULT_TIMEOUT_MS3 = 30000;
87178
- var _internals29 = {
87198
+ var _internals30 = {
87179
87199
  isSemgrepAvailable,
87180
87200
  checkSemgrepAvailable,
87181
87201
  resetSemgrepCache,
@@ -87200,7 +87220,7 @@ function isSemgrepAvailable() {
87200
87220
  }
87201
87221
  }
87202
87222
  async function checkSemgrepAvailable() {
87203
- return _internals29.isSemgrepAvailable();
87223
+ return _internals30.isSemgrepAvailable();
87204
87224
  }
87205
87225
  function resetSemgrepCache() {
87206
87226
  semgrepAvailableCache = null;
@@ -87297,12 +87317,12 @@ async function runSemgrep(options) {
87297
87317
  const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS3;
87298
87318
  if (files.length === 0) {
87299
87319
  return {
87300
- available: _internals29.isSemgrepAvailable(),
87320
+ available: _internals30.isSemgrepAvailable(),
87301
87321
  findings: [],
87302
87322
  engine: "tier_a"
87303
87323
  };
87304
87324
  }
87305
- if (!_internals29.isSemgrepAvailable()) {
87325
+ if (!_internals30.isSemgrepAvailable()) {
87306
87326
  return {
87307
87327
  available: false,
87308
87328
  findings: [],
@@ -87461,7 +87481,7 @@ function assignOccurrenceIndices(findings, directory) {
87461
87481
  }
87462
87482
  const occIdx = countMap.get(baseKey) ?? 0;
87463
87483
  countMap.set(baseKey, occIdx + 1);
87464
- const fp = _internals30.fingerprintFinding(finding, directory, occIdx);
87484
+ const fp = _internals31.fingerprintFinding(finding, directory, occIdx);
87465
87485
  return {
87466
87486
  finding,
87467
87487
  index: occIdx,
@@ -87530,7 +87550,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
87530
87550
  }
87531
87551
  } catch {}
87532
87552
  const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
87533
- const indexed = _internals30.assignOccurrenceIndices(findings, directory);
87553
+ const indexed = _internals31.assignOccurrenceIndices(findings, directory);
87534
87554
  if (existing && !opts?.force) {
87535
87555
  const prunedFingerprints = existing.fingerprints.filter((fp) => {
87536
87556
  const relFile = fp.slice(0, fp.indexOf("|"));
@@ -87670,7 +87690,7 @@ function loadBaseline(directory, phase) {
87670
87690
  };
87671
87691
  }
87672
87692
  }
87673
- var _internals30 = {
87693
+ var _internals31 = {
87674
87694
  fingerprintFinding,
87675
87695
  assignOccurrenceIndices,
87676
87696
  captureOrMergeBaseline,
@@ -88080,11 +88100,11 @@ var sast_scan = createSwarmTool({
88080
88100
  capture_baseline: safeArgs.capture_baseline,
88081
88101
  phase: safeArgs.phase
88082
88102
  };
88083
- const result = await _internals31.sastScan(input, directory);
88103
+ const result = await _internals32.sastScan(input, directory);
88084
88104
  return JSON.stringify(result, null, 2);
88085
88105
  }
88086
88106
  });
88087
- var _internals31 = {
88107
+ var _internals32 = {
88088
88108
  sastScan,
88089
88109
  sast_scan
88090
88110
  };
@@ -92511,7 +92531,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
92511
92531
  const strippedMutated = stripCode(mutatedCode);
92512
92532
  return strippedOriginal === strippedMutated;
92513
92533
  }
92514
- var _internals32 = {
92534
+ var _internals33 = {
92515
92535
  isStaticallyEquivalent,
92516
92536
  checkEquivalence,
92517
92537
  batchCheckEquivalence
@@ -92551,7 +92571,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
92551
92571
  const results = [];
92552
92572
  for (const { patch, originalCode, mutatedCode } of patches) {
92553
92573
  try {
92554
- const result = await _internals32.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
92574
+ const result = await _internals33.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
92555
92575
  results.push(result);
92556
92576
  } catch (err3) {
92557
92577
  results.push({
@@ -92851,7 +92871,7 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
92851
92871
  }
92852
92872
 
92853
92873
  // src/mutation/gate.ts
92854
- var _internals33 = {
92874
+ var _internals34 = {
92855
92875
  evaluateMutationGate,
92856
92876
  buildTestImprovementPrompt,
92857
92877
  buildMessage
@@ -92872,8 +92892,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
92872
92892
  } else {
92873
92893
  verdict = "fail";
92874
92894
  }
92875
- const testImprovementPrompt = _internals33.buildTestImprovementPrompt(report, passThreshold, verdict);
92876
- const message = _internals33.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
92895
+ const testImprovementPrompt = _internals34.buildTestImprovementPrompt(report, passThreshold, verdict);
92896
+ const message = _internals34.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
92877
92897
  return {
92878
92898
  verdict,
92879
92899
  killRate: report.killRate,
@@ -93490,7 +93510,7 @@ import * as path114 from "node:path";
93490
93510
  init_bun_compat();
93491
93511
  import * as fs92 from "node:fs";
93492
93512
  import * as path113 from "node:path";
93493
- var _internals34 = { bunSpawn };
93513
+ var _internals35 = { bunSpawn };
93494
93514
  var _swarmGitExcludedChecked = false;
93495
93515
  function fileCoversSwarm(content) {
93496
93516
  for (const rawLine of content.split(`
@@ -93523,7 +93543,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
93523
93543
  checkIgnoreExitCode
93524
93544
  ] = await Promise.all([
93525
93545
  (async () => {
93526
- const proc = _internals34.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
93546
+ const proc = _internals35.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
93527
93547
  try {
93528
93548
  return await Promise.all([proc.exited, proc.stdout.text()]);
93529
93549
  } finally {
@@ -93533,7 +93553,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
93533
93553
  }
93534
93554
  })(),
93535
93555
  (async () => {
93536
- const proc = _internals34.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
93556
+ const proc = _internals35.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
93537
93557
  try {
93538
93558
  return await Promise.all([proc.exited, proc.stdout.text()]);
93539
93559
  } finally {
@@ -93543,7 +93563,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
93543
93563
  }
93544
93564
  })(),
93545
93565
  (async () => {
93546
- const proc = _internals34.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
93566
+ const proc = _internals35.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
93547
93567
  try {
93548
93568
  return await proc.exited;
93549
93569
  } finally {
@@ -93582,7 +93602,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
93582
93602
  }
93583
93603
  } catch {}
93584
93604
  }
93585
- const trackedProc = _internals34.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
93605
+ const trackedProc = _internals35.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
93586
93606
  let trackedExitCode;
93587
93607
  let trackedOutput;
93588
93608
  try {
@@ -93607,7 +93627,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
93607
93627
  }
93608
93628
 
93609
93629
  // src/hooks/diff-scope.ts
93610
- var _internals35 = { bunSpawn };
93630
+ var _internals36 = { bunSpawn };
93611
93631
  function getDeclaredScope(taskId, directory) {
93612
93632
  try {
93613
93633
  const planPath = path114.join(directory, ".swarm", "plan.json");
@@ -93642,7 +93662,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
93642
93662
  };
93643
93663
  async function getChangedFiles(directory) {
93644
93664
  try {
93645
- const proc = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
93665
+ const proc = _internals36.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
93646
93666
  cwd: directory,
93647
93667
  ...GIT_DIFF_SPAWN_OPTIONS
93648
93668
  });
@@ -93659,7 +93679,7 @@ async function getChangedFiles(directory) {
93659
93679
  return stdout.trim().split(`
93660
93680
  `).map((f) => f.trim()).filter((f) => f.length > 0);
93661
93681
  }
93662
- const proc2 = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
93682
+ const proc2 = _internals36.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
93663
93683
  cwd: directory,
93664
93684
  ...GIT_DIFF_SPAWN_OPTIONS
93665
93685
  });
@@ -4,6 +4,16 @@ export type Parser = ParserType;
4
4
  * Parser cache to avoid reloading grammars multiple times per session
5
5
  */
6
6
  export declare const parserCache: Map<string, ParserType>;
7
+ /**
8
+ * DI seam for testing — overridable reference to TreeSitterParser.init.
9
+ * Tests can replace this with a spy/mock to observe init calls without
10
+ * mock.module leakage. Restore the original reference in afterEach.
11
+ */
12
+ export declare const _internals: {
13
+ parserInit: (opts?: {
14
+ locateFile: (scriptName: string) => string;
15
+ }) => Promise<void>;
16
+ };
7
17
  /**
8
18
  * Initialize a parser for the given language
9
19
  * Loads WASM from dist/lang/grammars/ (copied during build)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.8.0",
3
+ "version": "7.8.1",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",