opencode-swarm 7.25.2 → 7.26.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
@@ -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.25.2",
37
+ version: "7.26.0",
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",
@@ -72,7 +72,7 @@ var init_package = __esm(() => {
72
72
  ],
73
73
  scripts: {
74
74
  clean: `bun -e "require('fs').rmSync('dist',{recursive:true,force:true})"`,
75
- build: "bun run clean && bun run scripts/copy-grammars.ts && bun build src/index.ts --outdir dist --target node --format esm && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm && bun run scripts/copy-grammars.ts --to-dist && tsc --emitDeclarationOnly",
75
+ build: "bun run clean && bun run scripts/copy-grammars.ts && bun build src/index.ts --outdir dist --target node --format esm --external bash-parser && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external bash-parser && bun run scripts/copy-grammars.ts --to-dist && tsc --emitDeclarationOnly",
76
76
  typecheck: "tsc --noEmit",
77
77
  test: "bun test",
78
78
  lint: "biome lint .",
@@ -86,6 +86,7 @@ var init_package = __esm(() => {
86
86
  "@opencode-ai/plugin": "^1.1.53",
87
87
  "@opencode-ai/sdk": "^1.1.53",
88
88
  "@vscode/tree-sitter-wasm": "^0.3.0",
89
+ "bash-parser": "^0.5.0",
89
90
  "p-limit": "^7.3.0",
90
91
  picomatch: "^4.0.4",
91
92
  "proper-lockfile": "^4.1.2",
@@ -19802,47 +19803,13 @@ var init_task_id = __esm(() => {
19802
19803
  });
19803
19804
 
19804
19805
  // src/evidence/manager.ts
19805
- import {
19806
- mkdirSync as mkdirSync3,
19807
- readdirSync as readdirSync3,
19808
- realpathSync,
19809
- rmSync,
19810
- statSync as statSync4
19811
- } from "fs";
19806
+ import { mkdirSync as mkdirSync3, readdirSync as readdirSync3, rmSync, statSync as statSync4 } from "fs";
19812
19807
  import * as fs4 from "fs/promises";
19813
19808
  import * as path7 from "path";
19814
19809
  function isValidEvidenceType(type) {
19815
19810
  return VALID_EVIDENCE_TYPES.includes(type);
19816
19811
  }
19817
- function validateProjectRoot(directory) {
19818
- let resolved;
19819
- try {
19820
- resolved = realpathSync(directory);
19821
- } catch {
19822
- warn(`[evidence] Cannot canonicalize directory "${directory}" \u2014 failing closed`);
19823
- throw new Error(`Cannot verify project root for "${directory}" \u2014 directory may not exist or is inaccessible`);
19824
- }
19825
- let current = resolved;
19826
- while (true) {
19827
- const parent = path7.dirname(current);
19828
- if (parent === current)
19829
- break;
19830
- const parentSwarm = path7.join(parent, ".swarm");
19831
- try {
19832
- if (statSync4(parentSwarm).isDirectory()) {
19833
- warn(`[evidence] Rejecting write to subdirectory "${resolved}" \u2014 parent "${parent}" already contains .swarm/`);
19834
- throw new Error(`Cannot write evidence in "${resolved}" \u2014 parent directory "${parent}" already contains a .swarm/ folder. Evidence must be written to the project root.`);
19835
- }
19836
- } catch (error49) {
19837
- if (error49 instanceof Error && error49.message.startsWith("Cannot write evidence")) {
19838
- throw error49;
19839
- }
19840
- }
19841
- current = parent;
19842
- }
19843
- }
19844
19812
  async function saveEvidence(directory, taskId, evidence) {
19845
- _internals5.validateProjectRoot(directory);
19846
19813
  const sanitizedTaskId = sanitizeTaskId2(taskId);
19847
19814
  const relativePath = path7.join("evidence", sanitizedTaskId, "evidence.json");
19848
19815
  validateSwarmPath(directory, relativePath);
@@ -20107,8 +20074,7 @@ var init_manager2 = __esm(() => {
20107
20074
  _internals5 = {
20108
20075
  wrapFlatRetrospective,
20109
20076
  loadEvidence,
20110
- listEvidenceTaskIds,
20111
- validateProjectRoot
20077
+ listEvidenceTaskIds
20112
20078
  };
20113
20079
  });
20114
20080
 
@@ -20929,6 +20895,73 @@ var init_scope_persistence = __esm(() => {
20929
20895
  ]);
20930
20896
  });
20931
20897
 
20898
+ // src/hooks/shell-write-detect.ts
20899
+ import parse5 from "bash-parser";
20900
+ var REDIRECT_WRITE_TOKENS, REDIRECT_HERE_TOKENS, REDIRECT_ALL_WRITE_TOKENS, BUILTIN_WRITE_COMMANDS, INPLACE_EDIT_COMMANDS, INTERPRETER_EVAL_COMMANDS, NETWORK_DOWNLOAD_COMMANDS, ARCHIVE_EXTRACT_COMMANDS, PS_WRITE_CMDLETS, PS_WRITE_ALIASES, CMD_WRITE_BUILTINS;
20901
+ var init_shell_write_detect = __esm(() => {
20902
+ REDIRECT_WRITE_TOKENS = new Set([
20903
+ "GREAT",
20904
+ "DGREAT",
20905
+ "CLOBBER",
20906
+ "LESSGREAT"
20907
+ ]);
20908
+ REDIRECT_HERE_TOKENS = new Set(["DLESS", "DLESSDASH"]);
20909
+ REDIRECT_ALL_WRITE_TOKENS = new Set([
20910
+ ...REDIRECT_WRITE_TOKENS,
20911
+ ...REDIRECT_HERE_TOKENS
20912
+ ]);
20913
+ BUILTIN_WRITE_COMMANDS = new Set([
20914
+ "cp",
20915
+ "mv",
20916
+ "install",
20917
+ "ln",
20918
+ "truncate"
20919
+ ]);
20920
+ INPLACE_EDIT_COMMANDS = new Set(["sed", "perl", "awk"]);
20921
+ INTERPRETER_EVAL_COMMANDS = new Set([
20922
+ "python",
20923
+ "python3",
20924
+ "python2",
20925
+ "node",
20926
+ "bun",
20927
+ "ruby",
20928
+ "perl",
20929
+ "php"
20930
+ ]);
20931
+ NETWORK_DOWNLOAD_COMMANDS = new Set(["curl", "wget", "scp"]);
20932
+ ARCHIVE_EXTRACT_COMMANDS = new Set([
20933
+ "tar",
20934
+ "unzip",
20935
+ "gunzip",
20936
+ "gzip",
20937
+ "bzip2",
20938
+ "xz",
20939
+ "7z",
20940
+ "rar"
20941
+ ]);
20942
+ PS_WRITE_CMDLETS = new Set([
20943
+ "Out-File",
20944
+ "Set-Content",
20945
+ "Add-Content",
20946
+ "Clear-Content",
20947
+ "Copy-Item",
20948
+ "Move-Item",
20949
+ "Remove-Item",
20950
+ "Invoke-WebRequest",
20951
+ "Start-Process"
20952
+ ]);
20953
+ PS_WRITE_ALIASES = new Set(["echo", "write"]);
20954
+ CMD_WRITE_BUILTINS = new Set([
20955
+ "copy",
20956
+ "move",
20957
+ "type",
20958
+ "del",
20959
+ "rd",
20960
+ "md",
20961
+ "ren"
20962
+ ]);
20963
+ });
20964
+
20932
20965
  // src/hooks/conflict-resolution.ts
20933
20966
  var init_conflict_resolution = __esm(() => {
20934
20967
  init_state();
@@ -21003,6 +21036,7 @@ var init_guardrails = __esm(() => {
21003
21036
  init_state();
21004
21037
  init_telemetry();
21005
21038
  init_utils();
21039
+ init_shell_write_detect();
21006
21040
  init_bun_compat();
21007
21041
  init_logger();
21008
21042
  init_conflict_resolution();
@@ -22405,7 +22439,7 @@ var _parse2 = (_Err) => (schema, value, _ctx, _params) => {
22405
22439
  throw e;
22406
22440
  }
22407
22441
  return result.value;
22408
- }, parse5, _parseAsync2 = (_Err) => async (schema, value, _ctx, params) => {
22442
+ }, parse6, _parseAsync2 = (_Err) => async (schema, value, _ctx, params) => {
22409
22443
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
22410
22444
  let result = schema._zod.run({ value, issues: [] }, ctx);
22411
22445
  if (result instanceof Promise)
@@ -22460,7 +22494,7 @@ var init_parse3 = __esm(() => {
22460
22494
  init_core3();
22461
22495
  init_errors4();
22462
22496
  init_util2();
22463
- parse5 = /* @__PURE__ */ _parse2($ZodRealError2);
22497
+ parse6 = /* @__PURE__ */ _parse2($ZodRealError2);
22464
22498
  parseAsync3 = /* @__PURE__ */ _parseAsync2($ZodRealError2);
22465
22499
  safeParse3 = /* @__PURE__ */ _safeParse2($ZodRealError2);
22466
22500
  safeParseAsync3 = /* @__PURE__ */ _safeParseAsync2($ZodRealError2);
@@ -24950,10 +24984,10 @@ var init_schemas3 = __esm(() => {
24950
24984
  throw new Error("implement() must be called with a function");
24951
24985
  }
24952
24986
  return function(...args) {
24953
- const parsedArgs = inst._def.input ? parse5(inst._def.input, args) : args;
24987
+ const parsedArgs = inst._def.input ? parse6(inst._def.input, args) : args;
24954
24988
  const result = Reflect.apply(func, this, parsedArgs);
24955
24989
  if (inst._def.output) {
24956
- return parse5(inst._def.output, result);
24990
+ return parse6(inst._def.output, result);
24957
24991
  }
24958
24992
  return result;
24959
24993
  };
@@ -32529,7 +32563,7 @@ __export(exports_core4, {
32529
32563
  regexes: () => exports_regexes2,
32530
32564
  prettifyError: () => prettifyError2,
32531
32565
  parseAsync: () => parseAsync3,
32532
- parse: () => parse5,
32566
+ parse: () => parse6,
32533
32567
  locales: () => exports_locales2,
32534
32568
  isValidJWT: () => isValidJWT2,
32535
32569
  isValidBase64URL: () => isValidBase64URL2,
@@ -32882,11 +32916,11 @@ var init_errors5 = __esm(() => {
32882
32916
  });
32883
32917
 
32884
32918
  // node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/parse.js
32885
- var parse7, parseAsync4, safeParse4, safeParseAsync4, encode4, decode4, encodeAsync4, decodeAsync4, safeEncode4, safeDecode4, safeEncodeAsync4, safeDecodeAsync4;
32919
+ var parse8, parseAsync4, safeParse4, safeParseAsync4, encode4, decode4, encodeAsync4, decodeAsync4, safeEncode4, safeDecode4, safeEncodeAsync4, safeDecodeAsync4;
32886
32920
  var init_parse4 = __esm(() => {
32887
32921
  init_core4();
32888
32922
  init_errors5();
32889
- parse7 = /* @__PURE__ */ _parse2(ZodRealError2);
32923
+ parse8 = /* @__PURE__ */ _parse2(ZodRealError2);
32890
32924
  parseAsync4 = /* @__PURE__ */ _parseAsync2(ZodRealError2);
32891
32925
  safeParse4 = /* @__PURE__ */ _safeParse2(ZodRealError2);
32892
32926
  safeParseAsync4 = /* @__PURE__ */ _safeParseAsync2(ZodRealError2);
@@ -33358,7 +33392,7 @@ var init_schemas4 = __esm(() => {
33358
33392
  reg.add(inst, meta3);
33359
33393
  return inst;
33360
33394
  };
33361
- inst.parse = (data, params) => parse7(inst, data, params, { callee: inst.parse });
33395
+ inst.parse = (data, params) => parse8(inst, data, params, { callee: inst.parse });
33362
33396
  inst.safeParse = (data, params) => safeParse4(inst, data, params);
33363
33397
  inst.parseAsync = async (data, params) => parseAsync4(inst, data, params, { callee: inst.parseAsync });
33364
33398
  inst.safeParseAsync = async (data, params) => safeParseAsync4(inst, data, params);
@@ -33998,7 +34032,7 @@ __export(exports_external2, {
33998
34032
  pipe: () => pipe2,
33999
34033
  partialRecord: () => partialRecord2,
34000
34034
  parseAsync: () => parseAsync4,
34001
- parse: () => parse7,
34035
+ parse: () => parse8,
34002
34036
  overwrite: () => _overwrite2,
34003
34037
  optional: () => optional2,
34004
34038
  object: () => object2,
@@ -39968,9 +40002,7 @@ __export(exports_config_doctor, {
39968
40002
  runConfigDoctorWithFixes: () => runConfigDoctorWithFixes,
39969
40003
  runConfigDoctor: () => runConfigDoctor,
39970
40004
  restoreFromBackup: () => restoreFromBackup,
39971
- removeStraySwarmDir: () => removeStraySwarmDir,
39972
40005
  getConfigPaths: () => getConfigPaths,
39973
- detectStraySwarmDirs: () => detectStraySwarmDirs,
39974
40006
  createConfigBackup: () => createConfigBackup,
39975
40007
  applySafeAutoFixes: () => applySafeAutoFixes
39976
40008
  });
@@ -40586,114 +40618,6 @@ async function runConfigDoctorWithFixes(directory, config3, autoFix = false) {
40586
40618
  artifactPath
40587
40619
  };
40588
40620
  }
40589
- function detectStraySwarmDirs(projectRoot) {
40590
- const findings = [];
40591
- const SKIP_DIRS = new Set([
40592
- "node_modules",
40593
- ".git",
40594
- "dist",
40595
- ".cache",
40596
- ".next",
40597
- "coverage",
40598
- ".turbo",
40599
- ".vercel",
40600
- ".terraform",
40601
- "__pycache__",
40602
- ".tox"
40603
- ]);
40604
- const MAX_DEPTH = 10;
40605
- const MAX_CONTENTS_ENTRIES = 20;
40606
- function walk(dir, depth) {
40607
- if (depth > MAX_DEPTH)
40608
- return;
40609
- let entries;
40610
- try {
40611
- entries = fs8.readdirSync(dir, { withFileTypes: true });
40612
- } catch {
40613
- return;
40614
- }
40615
- for (const entry of entries) {
40616
- if (!entry.isDirectory())
40617
- continue;
40618
- const name = entry.name;
40619
- const fullPath = path23.join(dir, name);
40620
- if (SKIP_DIRS.has(name))
40621
- continue;
40622
- const gitPath = path23.join(fullPath, ".git");
40623
- try {
40624
- const gitStat = fs8.statSync(gitPath);
40625
- if (gitStat.isFile() || gitStat.isDirectory())
40626
- continue;
40627
- } catch {}
40628
- if (name === ".swarm") {
40629
- const parentDir = path23.dirname(fullPath);
40630
- if (parentDir === projectRoot)
40631
- continue;
40632
- let contents = [];
40633
- try {
40634
- contents = fs8.readdirSync(fullPath);
40635
- } catch {
40636
- contents = ["<unreadable>"];
40637
- }
40638
- findings.push({
40639
- path: path23.relative(projectRoot, fullPath).replace(/\\/g, "/"),
40640
- absolutePath: fullPath,
40641
- contents: contents.slice(0, MAX_CONTENTS_ENTRIES),
40642
- totalEntries: contents.length
40643
- });
40644
- continue;
40645
- }
40646
- walk(fullPath, depth + 1);
40647
- }
40648
- }
40649
- walk(projectRoot, 0);
40650
- return findings;
40651
- }
40652
- function removeStraySwarmDir(projectRoot, strayPath) {
40653
- let canonicalRoot;
40654
- let canonicalStray;
40655
- try {
40656
- canonicalRoot = fs8.realpathSync(projectRoot);
40657
- canonicalStray = fs8.realpathSync(path23.isAbsolute(strayPath) ? strayPath : path23.resolve(projectRoot, strayPath));
40658
- } catch (err) {
40659
- return {
40660
- success: false,
40661
- message: `Failed to resolve paths: ${err instanceof Error ? err.message : String(err)}`
40662
- };
40663
- }
40664
- const rootSwarm = path23.join(canonicalRoot, ".swarm");
40665
- if (canonicalStray === rootSwarm || canonicalStray === canonicalRoot) {
40666
- return {
40667
- success: false,
40668
- message: "Refusing to remove root .swarm/ directory"
40669
- };
40670
- }
40671
- if (!canonicalStray.startsWith(canonicalRoot + path23.sep)) {
40672
- return {
40673
- success: false,
40674
- message: "Path is outside project root \u2014 refusing to remove"
40675
- };
40676
- }
40677
- const normalizedStray = canonicalStray.replace(/\\/g, "/");
40678
- if (!normalizedStray.endsWith("/.swarm")) {
40679
- return {
40680
- success: false,
40681
- message: "Path is not a .swarm directory \u2014 refusing to remove"
40682
- };
40683
- }
40684
- try {
40685
- fs8.rmSync(canonicalStray, { recursive: true, force: true });
40686
- return {
40687
- success: true,
40688
- message: `Removed stray .swarm directory: ${canonicalStray}`
40689
- };
40690
- } catch (err) {
40691
- return {
40692
- success: false,
40693
- message: `Failed to remove: ${err instanceof Error ? err.message : String(err)}`
40694
- };
40695
- }
40696
- }
40697
40621
  var VALID_CONFIG_PATTERNS, DANGEROUS_PATH_SEGMENTS;
40698
40622
  var init_config_doctor = __esm(() => {
40699
40623
  init_utils();
@@ -42381,62 +42305,12 @@ async function handleDoctorCommand(directory, args) {
42381
42305
  const enableAutoFix = args.includes("--fix") || args.includes("-f");
42382
42306
  const config3 = loadPluginConfig(directory);
42383
42307
  const result = runConfigDoctor(config3, directory);
42384
- let output;
42385
42308
  if (enableAutoFix && result.hasAutoFixableIssues) {
42386
42309
  const { runConfigDoctorWithFixes: runConfigDoctorWithFixes2 } = await Promise.resolve().then(() => (init_config_doctor(), exports_config_doctor));
42387
42310
  const fixResult = await runConfigDoctorWithFixes2(directory, config3, true);
42388
- output = formatDoctorMarkdown(fixResult.result);
42389
- } else {
42390
- output = formatDoctorMarkdown(result);
42391
- }
42392
- const strayDirs = detectStraySwarmDirs(directory);
42393
- if (strayDirs.length > 0) {
42394
- if (enableAutoFix) {
42395
- let fixOutput = `
42396
- ---
42397
-
42398
- ## Stray .swarm Directories
42399
-
42400
- `;
42401
- let removed = 0;
42402
- let failed = 0;
42403
- for (const finding of strayDirs) {
42404
- const cleanupResult = removeStraySwarmDir(directory, finding.path);
42405
- if (cleanupResult.success) {
42406
- removed++;
42407
- } else {
42408
- failed++;
42409
- fixOutput += `- \`${finding.path}\`: ${cleanupResult.message}
42410
- `;
42411
- }
42412
- }
42413
- fixOutput += `
42414
- Cleaned up ${removed} stray director${removed === 1 ? "y" : "ies"}.`;
42415
- if (failed > 0) {
42416
- fixOutput += ` ${failed} could not be removed.`;
42417
- }
42418
- output += fixOutput;
42419
- } else {
42420
- output += `
42421
- ---
42422
-
42423
- ## Stray .swarm Directories
42424
-
42425
- `;
42426
- output += `Found ${strayDirs.length} stray .swarm director${strayDirs.length === 1 ? "y" : "ies"} in subdirectories:
42427
-
42428
- `;
42429
- for (const finding of strayDirs) {
42430
- const contentsPreview = finding.contents.length > 5 ? `${finding.contents.slice(0, 5).join(", ")}, ...` : finding.contents.join(", ");
42431
- output += `- \`${finding.path}\` (${finding.totalEntries} entries: ${contentsPreview})
42432
- `;
42433
- }
42434
- output += `
42435
- These are likely from a prior bug (Issue #922). `;
42436
- output += "Re-run with `--fix` to auto-clean.\n";
42437
- }
42311
+ return formatDoctorMarkdown(fixResult.result);
42438
42312
  }
42439
- return output;
42313
+ return formatDoctorMarkdown(result);
42440
42314
  }
42441
42315
  async function handleDoctorToolsCommand(directory, _args) {
42442
42316
  const result = runToolDoctor(directory);
@@ -46194,14 +46068,7 @@ function defaultBuildTestCommand(profile, framework, files, dir = ".", opts = {}
46194
46068
  return args;
46195
46069
  }
46196
46070
  case "vitest": {
46197
- const args = [
46198
- "npx",
46199
- "vitest",
46200
- "run",
46201
- "--reporter=json",
46202
- "--outputFile",
46203
- ".swarm/cache/test-runner-vitest.json"
46204
- ];
46071
+ const args = ["npx", "vitest", "run"];
46205
46072
  if (coverage)
46206
46073
  args.push("--coverage");
46207
46074
  if (scope !== "all" && files.length > 0)
@@ -46209,7 +46076,7 @@ function defaultBuildTestCommand(profile, framework, files, dir = ".", opts = {}
46209
46076
  return args;
46210
46077
  }
46211
46078
  case "jest": {
46212
- const args = ["npx", "jest", "--json"];
46079
+ const args = ["npx", "jest"];
46213
46080
  if (coverage)
46214
46081
  args.push("--coverage");
46215
46082
  if (scope !== "all" && files.length > 0)
@@ -47094,10 +46961,6 @@ async function loadImpactMap(cwd, options) {
47094
46961
  return _internals22.buildImpactMap(cwd);
47095
46962
  }
47096
46963
  async function saveImpactMap(cwd, impactMap) {
47097
- if (!path34.isAbsolute(cwd)) {
47098
- throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
47099
- }
47100
- _internals22.validateProjectRoot(cwd);
47101
46964
  const cacheDir2 = path34.join(cwd, ".swarm", "cache");
47102
46965
  const cachePath = path34.join(cacheDir2, "impact-map.json");
47103
46966
  if (!fs17.existsSync(cacheDir2)) {
@@ -47190,7 +47053,6 @@ async function analyzeImpact(changedFiles, cwd, budget) {
47190
47053
  }
47191
47054
  var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals22;
47192
47055
  var init_analyzer = __esm(() => {
47193
- init_manager2();
47194
47056
  init_go();
47195
47057
  init_python();
47196
47058
  IMPORT_REGEX_ES = /import\s+[\s\S]*?\s+from\s+['"]([^'"]+)['"]/g;
@@ -47202,7 +47064,6 @@ var init_analyzer = __esm(() => {
47202
47064
  EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
47203
47065
  goModuleCache = new Map;
47204
47066
  _internals22 = {
47205
- validateProjectRoot,
47206
47067
  normalizePath,
47207
47068
  isCacheStale,
47208
47069
  resolveRelativeImport,
@@ -47426,13 +47287,7 @@ var FLAKY_THRESHOLD = 0.3, MIN_RUNS_FOR_QUARANTINE = 5, MAX_HISTORY_RUNS = 20;
47426
47287
  import fs18 from "fs";
47427
47288
  import path35 from "path";
47428
47289
  function getHistoryPath(workingDir) {
47429
- if (!workingDir) {
47430
- throw new Error("getHistoryPath requires a working directory \u2014 project root must be provided by the caller");
47431
- }
47432
- if (!path35.isAbsolute(workingDir)) {
47433
- throw new Error(`getHistoryPath requires an absolute project root path, got: "${workingDir}"`);
47434
- }
47435
- return path35.join(workingDir, ".swarm", "cache", "test-history.jsonl");
47290
+ return path35.join(workingDir || process.cwd(), ".swarm", "cache", "test-history.jsonl");
47436
47291
  }
47437
47292
  function sanitizeErrorMessage(errorMessage) {
47438
47293
  if (errorMessage === undefined) {
@@ -47456,42 +47311,6 @@ function sanitizeChangedFiles(changedFiles) {
47456
47311
  const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !DANGEROUS_PROPERTY_NAMES.has(f));
47457
47312
  return validFiles.slice(0, MAX_CHANGED_FILES);
47458
47313
  }
47459
- function isTestRunResult(value) {
47460
- return value === "pass" || value === "fail" || value === "skip";
47461
- }
47462
- function parseStoredRecord(value) {
47463
- if (typeof value !== "object" || value === null)
47464
- return null;
47465
- const record3 = value;
47466
- if (typeof record3.testFile !== "string" || record3.testFile.length === 0) {
47467
- return null;
47468
- }
47469
- if (typeof record3.testName !== "string" || record3.testName.length === 0) {
47470
- return null;
47471
- }
47472
- if (typeof record3.taskId !== "string" || record3.taskId.length === 0) {
47473
- return null;
47474
- }
47475
- if (!isTestRunResult(record3.result))
47476
- return null;
47477
- if (typeof record3.durationMs !== "number" || !Number.isFinite(record3.durationMs)) {
47478
- return null;
47479
- }
47480
- if (typeof record3.timestamp !== "string" || Number.isNaN(Date.parse(record3.timestamp))) {
47481
- return null;
47482
- }
47483
- return {
47484
- timestamp: record3.timestamp,
47485
- taskId: record3.taskId,
47486
- testFile: record3.testFile,
47487
- testName: record3.testName,
47488
- result: record3.result,
47489
- durationMs: Math.max(0, record3.durationMs),
47490
- errorMessage: typeof record3.errorMessage === "string" ? sanitizeErrorMessage(record3.errorMessage) : undefined,
47491
- stackPrefix: typeof record3.stackPrefix === "string" ? sanitizeStackPrefix(record3.stackPrefix) : undefined,
47492
- changedFiles: sanitizeChangedFiles(Array.isArray(record3.changedFiles) ? record3.changedFiles : [])
47493
- };
47494
- }
47495
47314
  function appendTestRun(record3, workingDir) {
47496
47315
  if (typeof record3.testFile !== "string" || record3.testFile.length === 0) {
47497
47316
  throw new TypeError("testFile must be a non-empty string");
@@ -47524,22 +47343,21 @@ function appendTestRun(record3, workingDir) {
47524
47343
  };
47525
47344
  const historyPath = getHistoryPath(workingDir);
47526
47345
  const historyDir = path35.dirname(historyPath);
47527
- _internals23.validateProjectRoot(workingDir);
47528
47346
  if (!fs18.existsSync(historyDir)) {
47529
47347
  fs18.mkdirSync(historyDir, { recursive: true });
47530
47348
  }
47531
47349
  const existingRecords = readAllRecords(historyPath);
47532
47350
  existingRecords.push(sanitizedRecord);
47533
- const recordsByTest = new Map;
47351
+ const recordsByFile = new Map;
47534
47352
  for (const rec of existingRecords) {
47535
- const normalizedKey = `${rec.testFile.toLowerCase()}|${rec.testName.toLowerCase()}`;
47536
- if (!recordsByTest.has(normalizedKey)) {
47537
- recordsByTest.set(normalizedKey, []);
47353
+ const normalizedFile = rec.testFile.toLowerCase();
47354
+ if (!recordsByFile.has(normalizedFile)) {
47355
+ recordsByFile.set(normalizedFile, []);
47538
47356
  }
47539
- recordsByTest.get(normalizedKey).push(rec);
47357
+ recordsByFile.get(normalizedFile).push(rec);
47540
47358
  }
47541
47359
  const prunedRecords = [];
47542
- for (const [, records] of recordsByTest) {
47360
+ for (const [, records] of recordsByFile) {
47543
47361
  records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
47544
47362
  const toKeep = records.slice(-MAX_HISTORY_PER_TEST);
47545
47363
  prunedRecords.push(...toKeep);
@@ -47579,9 +47397,8 @@ function readAllRecords(historyPath) {
47579
47397
  }
47580
47398
  try {
47581
47399
  const parsed = JSON.parse(trimmed);
47582
- const record3 = parseStoredRecord(parsed);
47583
- if (record3) {
47584
- records.push(record3);
47400
+ if (typeof parsed === "object" && parsed !== null && "testFile" in parsed && "testName" in parsed && "result" in parsed) {
47401
+ records.push(parsed);
47585
47402
  }
47586
47403
  } catch {}
47587
47404
  }
@@ -47596,17 +47413,13 @@ function getAllHistory(workingDir) {
47596
47413
  records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
47597
47414
  return records;
47598
47415
  }
47599
- var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, DANGEROUS_PROPERTY_NAMES, _internals23;
47416
+ var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, DANGEROUS_PROPERTY_NAMES;
47600
47417
  var init_history_store = __esm(() => {
47601
- init_manager2();
47602
47418
  DANGEROUS_PROPERTY_NAMES = new Set([
47603
47419
  "__proto__",
47604
47420
  "constructor",
47605
47421
  "prototype"
47606
47422
  ]);
47607
- _internals23 = {
47608
- validateProjectRoot
47609
- };
47610
47423
  });
47611
47424
 
47612
47425
  // src/tools/resolve-working-directory.ts
@@ -47730,7 +47543,7 @@ function readPackageJsonRaw(dir) {
47730
47543
  }
47731
47544
  }
47732
47545
  function readPackageJson(dir) {
47733
- return _internals24.readPackageJsonRaw(dir);
47546
+ return _internals23.readPackageJsonRaw(dir);
47734
47547
  }
47735
47548
  function readPackageJsonTestScript(dir) {
47736
47549
  return readPackageJson(dir)?.scripts?.test ?? null;
@@ -47900,7 +47713,7 @@ function buildTypescriptBackend() {
47900
47713
  selectEntryPoints: selectEntryPoints3
47901
47714
  };
47902
47715
  }
47903
- var PROFILE_ID3 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals24;
47716
+ var PROFILE_ID3 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals23;
47904
47717
  var init_typescript = __esm(() => {
47905
47718
  init_default_backend();
47906
47719
  init_profiles();
@@ -47909,7 +47722,7 @@ var init_typescript = __esm(() => {
47909
47722
  IMPORT_REGEX_REQUIRE2 = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
47910
47723
  IMPORT_REGEX_DYNAMIC = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
47911
47724
  IMPORT_REGEX_REEXPORT2 = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
47912
- _internals24 = {
47725
+ _internals23 = {
47913
47726
  readPackageJsonRaw,
47914
47727
  readPackageJsonTestScript,
47915
47728
  frameworkFromScriptsTest
@@ -47940,7 +47753,7 @@ __export(exports_dispatch, {
47940
47753
  pickedProfiles: () => pickedProfiles,
47941
47754
  pickBackend: () => pickBackend,
47942
47755
  clearDispatchCache: () => clearDispatchCache,
47943
- _internals: () => _internals25
47756
+ _internals: () => _internals24
47944
47757
  });
47945
47758
  import * as fs21 from "fs";
47946
47759
  import * as path38 from "path";
@@ -47995,7 +47808,7 @@ function findManifestRoot(start) {
47995
47808
  return start;
47996
47809
  }
47997
47810
  function evictIfNeeded() {
47998
- if (cache.size <= _internals25.cacheCapacity)
47811
+ if (cache.size <= _internals24.cacheCapacity)
47999
47812
  return;
48000
47813
  let oldestKey;
48001
47814
  let oldestOrder = Infinity;
@@ -48026,7 +47839,7 @@ async function pickBackend(dir) {
48026
47839
  evictIfNeeded();
48027
47840
  return null;
48028
47841
  }
48029
- const profiles = await _internals25.detectProjectLanguages(root);
47842
+ const profiles = await _internals24.detectProjectLanguages(root);
48030
47843
  if (profiles.length === 0) {
48031
47844
  cache.set(cacheKey, {
48032
47845
  hash: hash3,
@@ -48058,12 +47871,12 @@ function clearDispatchCache() {
48058
47871
  manifestRootCache.clear();
48059
47872
  insertCounter = 0;
48060
47873
  }
48061
- var _internals25, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
47874
+ var _internals24, cache, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
48062
47875
  var init_dispatch = __esm(() => {
48063
47876
  init_backends();
48064
47877
  init_detector();
48065
47878
  init_registry_backend();
48066
- _internals25 = {
47879
+ _internals24 = {
48067
47880
  detectProjectLanguages,
48068
47881
  cacheCapacity: 64
48069
47882
  };
@@ -48624,14 +48437,7 @@ function buildTestCommand2(framework, scope, files, coverage, baseDir) {
48624
48437
  return args;
48625
48438
  }
48626
48439
  case "vitest": {
48627
- const args = [
48628
- "npx",
48629
- "vitest",
48630
- "run",
48631
- "--reporter=json",
48632
- "--outputFile",
48633
- VITEST_JSON_OUTPUT_RELATIVE_PATH
48634
- ];
48440
+ const args = ["npx", "vitest", "run"];
48635
48441
  if (coverage)
48636
48442
  args.push("--coverage");
48637
48443
  if (scope !== "all" && files.length > 0) {
@@ -48640,7 +48446,7 @@ function buildTestCommand2(framework, scope, files, coverage, baseDir) {
48640
48446
  return args;
48641
48447
  }
48642
48448
  case "jest": {
48643
- const args = ["npx", "jest", "--json"];
48449
+ const args = ["npx", "jest"];
48644
48450
  if (coverage)
48645
48451
  args.push("--coverage");
48646
48452
  if (scope !== "all" && files.length > 0) {
@@ -48736,122 +48542,6 @@ function buildTestCommand2(framework, scope, files, coverage, baseDir) {
48736
48542
  return null;
48737
48543
  }
48738
48544
  }
48739
- function mapFrameworkStatusToResult(status) {
48740
- if (typeof status !== "string")
48741
- return null;
48742
- const normalized = status.toLowerCase();
48743
- if (normalized === "pass" || normalized === "passed")
48744
- return "pass";
48745
- if (normalized === "fail" || normalized === "failed")
48746
- return "fail";
48747
- if (normalized === "skip" || normalized === "skipped" || normalized === "pending" || normalized === "todo") {
48748
- return "skip";
48749
- }
48750
- return null;
48751
- }
48752
- function firstLine(value) {
48753
- if (typeof value !== "string")
48754
- return;
48755
- const line = value.split(`
48756
- `).find((part) => part.trim().length > 0)?.trim();
48757
- return line && line.length > 0 ? line : undefined;
48758
- }
48759
- function parseJestLikeJsonTestResults(payload) {
48760
- if (typeof payload !== "object" || payload === null)
48761
- return [];
48762
- const rawSuites = payload.testResults;
48763
- if (!Array.isArray(rawSuites))
48764
- return [];
48765
- const parsed = [];
48766
- for (const suite of rawSuites) {
48767
- if (typeof suite !== "object" || suite === null)
48768
- continue;
48769
- const suiteObj = suite;
48770
- const rawFile = typeof suiteObj.name === "string" ? suiteObj.name : typeof suiteObj.testFilePath === "string" ? suiteObj.testFilePath : undefined;
48771
- if (!rawFile)
48772
- continue;
48773
- const testFile = rawFile.replace(/\\/g, "/");
48774
- const assertionResults = suiteObj.assertionResults;
48775
- if (!Array.isArray(assertionResults))
48776
- continue;
48777
- for (const assertion of assertionResults) {
48778
- if (typeof assertion !== "object" || assertion === null)
48779
- continue;
48780
- const assertionObj = assertion;
48781
- const result = mapFrameworkStatusToResult(assertionObj.status);
48782
- const testName = typeof assertionObj.fullName === "string" ? assertionObj.fullName : typeof assertionObj.title === "string" ? assertionObj.title : undefined;
48783
- if (!result || !testName || testName.length === 0)
48784
- continue;
48785
- const failureMessages = Array.isArray(assertionObj.failureMessages) ? assertionObj.failureMessages : [];
48786
- const firstFailure = failureMessages.find((entry) => typeof entry === "string" && entry.length > 0);
48787
- const durationMs = typeof assertionObj.duration === "number" && Number.isFinite(assertionObj.duration) ? Math.max(assertionObj.duration, 0) : 0;
48788
- parsed.push({
48789
- testFile,
48790
- testName,
48791
- result,
48792
- durationMs,
48793
- errorMessage: firstLine(firstFailure),
48794
- stackPrefix: firstLine(firstFailure)
48795
- });
48796
- }
48797
- }
48798
- return parsed;
48799
- }
48800
- function parseBunJsonLines(output) {
48801
- const parsed = [];
48802
- for (const line of output.split(`
48803
- `)) {
48804
- const trimmed = line.trim();
48805
- if (!trimmed.startsWith("{") || !trimmed.endsWith("}"))
48806
- continue;
48807
- try {
48808
- const obj = JSON.parse(trimmed);
48809
- const rawFile = typeof obj.file === "string" ? obj.file : typeof obj.testFile === "string" ? obj.testFile : typeof obj.path === "string" ? obj.path : undefined;
48810
- const rawName = typeof obj.testName === "string" ? obj.testName : typeof obj.fullName === "string" ? obj.fullName : typeof obj.name === "string" ? obj.name : undefined;
48811
- const result = mapFrameworkStatusToResult(typeof obj.status === "string" ? obj.status : obj.result);
48812
- if (!rawFile || !rawName || !result)
48813
- continue;
48814
- const errorObj = typeof obj.error === "object" && obj.error !== null ? obj.error : undefined;
48815
- const durationMs = typeof obj.durationMs === "number" && Number.isFinite(obj.durationMs) ? Math.max(obj.durationMs, 0) : typeof obj.duration === "number" && Number.isFinite(obj.duration) ? Math.max(obj.duration, 0) : 0;
48816
- parsed.push({
48817
- testFile: rawFile.replace(/\\/g, "/"),
48818
- testName: rawName,
48819
- result,
48820
- durationMs,
48821
- errorMessage: firstLine(errorObj?.message ?? obj.errorMessage),
48822
- stackPrefix: firstLine(errorObj?.stack)
48823
- });
48824
- } catch {}
48825
- }
48826
- return parsed;
48827
- }
48828
- function parseFrameworkJsonTestResults(framework, output) {
48829
- const jsonMatch = output.match(/\{[\s\S]*"testResults"[\s\S]*\}/);
48830
- if (jsonMatch) {
48831
- try {
48832
- const parsed = JSON.parse(jsonMatch[0]);
48833
- const testResults = parseJestLikeJsonTestResults(parsed);
48834
- if (testResults.length > 0)
48835
- return testResults;
48836
- } catch {}
48837
- }
48838
- for (const line of output.split(`
48839
- `)) {
48840
- const trimmed = line.trim();
48841
- if (!trimmed.startsWith("{") || !trimmed.endsWith("}"))
48842
- continue;
48843
- try {
48844
- const parsed = JSON.parse(trimmed);
48845
- const testResults = parseJestLikeJsonTestResults(parsed);
48846
- if (testResults.length > 0)
48847
- return testResults;
48848
- } catch {}
48849
- }
48850
- if (framework === "bun") {
48851
- return parseBunJsonLines(output);
48852
- }
48853
- return [];
48854
- }
48855
48545
  function parseTestOutput2(framework, output) {
48856
48546
  const totals = {
48857
48547
  passed: 0,
@@ -49139,16 +48829,7 @@ async function runTests(framework, scope, files, coverage, timeout_ms, cwd) {
49139
48829
  };
49140
48830
  }
49141
48831
  const startTime = Date.now();
49142
- const vitestJsonOutputPath = framework === "vitest" ? path39.join(cwd, ".swarm", "cache", "test-runner-vitest.json") : undefined;
49143
48832
  try {
49144
- if (vitestJsonOutputPath) {
49145
- try {
49146
- fs22.mkdirSync(path39.dirname(vitestJsonOutputPath), { recursive: true });
49147
- if (fs22.existsSync(vitestJsonOutputPath)) {
49148
- fs22.unlinkSync(vitestJsonOutputPath);
49149
- }
49150
- } catch {}
49151
- }
49152
48833
  const proc = bunSpawn(command, {
49153
48834
  stdout: "pipe",
49154
48835
  stderr: "pipe",
@@ -49169,37 +48850,13 @@ async function runTests(framework, scope, files, coverage, timeout_ms, cwd) {
49169
48850
  output += (output ? `
49170
48851
  ` : "") + stderrResult.text;
49171
48852
  }
49172
- if (vitestJsonOutputPath) {
49173
- try {
49174
- if (fs22.existsSync(vitestJsonOutputPath)) {
49175
- const vitestJsonOutput = fs22.readFileSync(vitestJsonOutputPath, "utf-8");
49176
- if (vitestJsonOutput.trim().length > 0) {
49177
- output += (output ? `
49178
- ` : "") + vitestJsonOutput;
49179
- }
49180
- }
49181
- } catch {}
49182
- }
49183
48853
  if (stdoutResult.truncated || stderrResult.truncated) {
49184
48854
  output += `
49185
48855
  ... (output truncated at stream read limit)`;
49186
48856
  }
49187
48857
  const useDispatchParse = process.env.SWARM_LANG_BACKEND !== "legacy";
49188
48858
  const parsed = useDispatchParse ? await parseTestOutputViaDispatch(framework, output, cwd) ?? parseTestOutput2(framework, output) : parseTestOutput2(framework, output);
49189
- const parsedTestCases = parseFrameworkJsonTestResults(framework, output);
49190
- const totals = { ...parsed.totals };
49191
- const { coveragePercent } = parsed;
49192
- if (totals.total === 0 && parsedTestCases.length > 0) {
49193
- for (const entry of parsedTestCases) {
49194
- if (entry.result === "pass")
49195
- totals.passed++;
49196
- else if (entry.result === "fail")
49197
- totals.failed++;
49198
- else
49199
- totals.skipped++;
49200
- }
49201
- totals.total = parsedTestCases.length;
49202
- }
48859
+ const { totals, coveragePercent } = parsed;
49203
48860
  const isTimeout = exitCode === -1;
49204
48861
  const testPassed = exitCode === 0 && totals.failed === 0;
49205
48862
  if (testPassed) {
@@ -49212,8 +48869,7 @@ async function runTests(framework, scope, files, coverage, timeout_ms, cwd) {
49212
48869
  duration_ms,
49213
48870
  totals,
49214
48871
  rawOutput: output,
49215
- outcome: "pass",
49216
- testCases: parsedTestCases
48872
+ outcome: "pass"
49217
48873
  };
49218
48874
  if (coveragePercent !== undefined) {
49219
48875
  result.coveragePercent = coveragePercent;
@@ -49235,8 +48891,7 @@ async function runTests(framework, scope, files, coverage, timeout_ms, cwd) {
49235
48891
  rawOutput: output,
49236
48892
  error: isTimeout ? `Tests timed out after ${timeout_ms}ms` : `Tests failed with ${totals.failed} failures`,
49237
48893
  message: isTimeout ? `${framework} tests timed out after ${timeout_ms}ms` : `${framework} tests failed (${totals.failed}/${totals.total} failed)`,
49238
- outcome: isTimeout ? "error" : "regression",
49239
- testCases: parsedTestCases
48894
+ outcome: isTimeout ? "error" : "regression"
49240
48895
  };
49241
48896
  if (coveragePercent !== undefined) {
49242
48897
  result.coveragePercent = coveragePercent;
@@ -49257,78 +48912,25 @@ async function runTests(framework, scope, files, coverage, timeout_ms, cwd) {
49257
48912
  };
49258
48913
  }
49259
48914
  }
49260
- function normalizeHistoryTestFile(testFile, workingDir) {
49261
- const normalized = testFile.replace(/\\/g, "/");
49262
- if (!path39.isAbsolute(testFile))
49263
- return normalized;
49264
- const relative9 = path39.relative(workingDir, testFile);
49265
- if (relative9.startsWith("..") || path39.isAbsolute(relative9)) {
49266
- return normalized;
49267
- }
49268
- return relative9.replace(/\\/g, "/");
49269
- }
49270
- function combineAggregateResult(current, next) {
49271
- if (current === "fail" || next === "fail")
49272
- return "fail";
49273
- if (current === "pass" || next === "pass")
49274
- return "pass";
49275
- return "skip";
49276
- }
49277
- function recordAndAnalyzeResults(result, testFiles, workingDir, sourceFiles, parsedTestCases) {
48915
+ function recordAndAnalyzeResults(result, testFiles, workingDir, sourceFiles) {
49278
48916
  if (!result.totals || result.totals.total === 0)
49279
48917
  return;
49280
48918
  const now = new Date().toISOString();
49281
48919
  const changedFiles = (sourceFiles && sourceFiles.length > 0 ? sourceFiles : testFiles).map((f) => f.replace(/\\/g, "/"));
49282
- const aggregateResultsByFile = new Map;
49283
- const validParsedCases = parsedTestCases?.filter((parsedCase) => parsedCase.testFile.length > 0 && parsedCase.testName.length > 0) ?? [];
49284
- for (const parsedCase of validParsedCases) {
49285
- const normalizedTestFile = normalizeHistoryTestFile(parsedCase.testFile, workingDir);
49286
- try {
49287
- appendTestRun({
49288
- timestamp: now,
49289
- taskId: "auto",
49290
- testFile: normalizedTestFile,
49291
- testName: parsedCase.testName,
49292
- result: parsedCase.result,
49293
- durationMs: parsedCase.durationMs,
49294
- errorMessage: parsedCase.errorMessage,
49295
- stackPrefix: parsedCase.stackPrefix,
49296
- changedFiles
49297
- }, workingDir);
49298
- } catch {}
49299
- aggregateResultsByFile.set(normalizedTestFile, combineAggregateResult(aggregateResultsByFile.get(normalizedTestFile), parsedCase.result));
49300
- }
49301
- if (aggregateResultsByFile.size === 0) {
49302
- const aggregateResult = result.success ? "pass" : "fail";
49303
- for (const testFile of testFiles) {
49304
- aggregateResultsByFile.set(testFile.replace(/\\/g, "/"), aggregateResult);
49305
- }
49306
- }
49307
- for (const [testFile, aggregateResult] of aggregateResultsByFile) {
48920
+ for (const testFile of testFiles) {
49308
48921
  try {
49309
48922
  appendTestRun({
49310
48923
  timestamp: now,
49311
48924
  taskId: "auto",
49312
- testFile,
49313
- testName: AGGREGATE_TEST_NAME,
49314
- result: aggregateResult,
48925
+ testFile: testFile.replace(/\\/g, "/"),
48926
+ testName: "(aggregate)",
48927
+ result: result.success ? "pass" : "fail",
49315
48928
  durationMs: result.duration_ms || 0,
49316
48929
  changedFiles
49317
48930
  }, workingDir);
49318
48931
  } catch {}
49319
48932
  }
49320
48933
  }
49321
- function selectHistoryForAnalysis(history) {
49322
- const filesWithIndividualRecords = new Set;
49323
- for (const record3 of history) {
49324
- if (record3.testName !== AGGREGATE_TEST_NAME) {
49325
- filesWithIndividualRecords.add(record3.testFile.toLowerCase());
49326
- }
49327
- }
49328
- if (filesWithIndividualRecords.size === 0)
49329
- return history;
49330
- return history.filter((record3) => record3.testName !== AGGREGATE_TEST_NAME || !filesWithIndividualRecords.has(record3.testFile.toLowerCase()));
49331
- }
49332
48934
  function analyzeFailures(workingDir) {
49333
48935
  const report = {
49334
48936
  flakyTests: [],
@@ -49336,7 +48938,7 @@ function analyzeFailures(workingDir) {
49336
48938
  quarantinedFailures: []
49337
48939
  };
49338
48940
  try {
49339
- const history = selectHistoryForAnalysis(getAllHistory(workingDir));
48941
+ const history = getAllHistory(workingDir);
49340
48942
  if (history.length === 0)
49341
48943
  return report;
49342
48944
  report.flakyTests = detectFlakyTests(history);
@@ -49357,7 +48959,7 @@ function analyzeFailures(workingDir) {
49357
48959
  } catch {}
49358
48960
  return report;
49359
48961
  }
49360
- var MAX_OUTPUT_BYTES3 = 512000, MAX_COMMAND_LENGTH2 = 500, DEFAULT_TIMEOUT_MS = 60000, MAX_TIMEOUT_MS = 300000, MAX_SAFE_TEST_FILES = 50, MAX_SAFE_SOURCE_FILES = 1, AGGREGATE_TEST_NAME = "(aggregate)", VITEST_JSON_OUTPUT_RELATIVE_PATH = ".swarm/cache/test-runner-vitest.json", POWERSHELL_METACHARACTERS, DISPATCH_FRAMEWORK_MAP, COMPOUND_TEST_EXTENSIONS, TEST_DIRECTORY_NAMES, SOURCE_EXTENSIONS, SKIP_DIRECTORIES, test_runner;
48962
+ var MAX_OUTPUT_BYTES3 = 512000, MAX_COMMAND_LENGTH2 = 500, DEFAULT_TIMEOUT_MS = 60000, MAX_TIMEOUT_MS = 300000, MAX_SAFE_TEST_FILES = 50, MAX_SAFE_SOURCE_FILES = 1, POWERSHELL_METACHARACTERS, DISPATCH_FRAMEWORK_MAP, COMPOUND_TEST_EXTENSIONS, TEST_DIRECTORY_NAMES, SOURCE_EXTENSIONS, SKIP_DIRECTORIES, test_runner;
49361
48963
  var init_test_runner = __esm(() => {
49362
48964
  init_zod();
49363
48965
  init_discovery();
@@ -49803,7 +49405,7 @@ var init_test_runner = __esm(() => {
49803
49405
  return JSON.stringify(errorResult, null, 2);
49804
49406
  }
49805
49407
  const result = await runTests(framework, effectiveScope, testFiles, coverage, timeout_ms, workingDir);
49806
- recordAndAnalyzeResults(result, testFiles, workingDir, _files.length > 0 ? _files : undefined, result.testCases);
49408
+ recordAndAnalyzeResults(result, testFiles, workingDir, _files.length > 0 ? _files : undefined);
49807
49409
  let historyReport;
49808
49410
  if (!result.success && result.totals && result.totals.failed > 0) {
49809
49411
  historyReport = analyzeFailures(workingDir);
@@ -49898,9 +49500,9 @@ function getVersionFileVersion(dir) {
49898
49500
  async function runVersionCheck(dir, _timeoutMs) {
49899
49501
  const startTime = Date.now();
49900
49502
  try {
49901
- const packageVersion = _internals26.getPackageVersion(dir);
49902
- const changelogVersion = _internals26.getChangelogVersion(dir);
49903
- const versionFileVersion = _internals26.getVersionFileVersion(dir);
49503
+ const packageVersion = _internals25.getPackageVersion(dir);
49504
+ const changelogVersion = _internals25.getChangelogVersion(dir);
49505
+ const versionFileVersion = _internals25.getVersionFileVersion(dir);
49904
49506
  const versions3 = [];
49905
49507
  if (packageVersion)
49906
49508
  versions3.push(`package.json: ${packageVersion}`);
@@ -50250,7 +49852,7 @@ async function runPreflight(dir, phase, config3) {
50250
49852
  const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
50251
49853
  let validatedDir;
50252
49854
  try {
50253
- validatedDir = _internals26.validateDirectoryPath(dir);
49855
+ validatedDir = _internals25.validateDirectoryPath(dir);
50254
49856
  } catch (error93) {
50255
49857
  return {
50256
49858
  id: reportId,
@@ -50270,7 +49872,7 @@ async function runPreflight(dir, phase, config3) {
50270
49872
  }
50271
49873
  let validatedTimeout;
50272
49874
  try {
50273
- validatedTimeout = _internals26.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
49875
+ validatedTimeout = _internals25.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
50274
49876
  } catch (error93) {
50275
49877
  return {
50276
49878
  id: reportId,
@@ -50311,12 +49913,12 @@ async function runPreflight(dir, phase, config3) {
50311
49913
  });
50312
49914
  const checks5 = [];
50313
49915
  log("[Preflight] Running lint check...");
50314
- const lintResult = await _internals26.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
49916
+ const lintResult = await _internals25.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
50315
49917
  checks5.push(lintResult);
50316
49918
  log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
50317
49919
  if (!cfg.skipTests) {
50318
49920
  log("[Preflight] Running tests check...");
50319
- const testsResult = await _internals26.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
49921
+ const testsResult = await _internals25.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
50320
49922
  checks5.push(testsResult);
50321
49923
  log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
50322
49924
  } else {
@@ -50328,7 +49930,7 @@ async function runPreflight(dir, phase, config3) {
50328
49930
  }
50329
49931
  if (!cfg.skipSecrets) {
50330
49932
  log("[Preflight] Running secrets check...");
50331
- const secretsResult = await _internals26.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
49933
+ const secretsResult = await _internals25.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
50332
49934
  checks5.push(secretsResult);
50333
49935
  log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
50334
49936
  } else {
@@ -50340,7 +49942,7 @@ async function runPreflight(dir, phase, config3) {
50340
49942
  }
50341
49943
  if (!cfg.skipEvidence) {
50342
49944
  log("[Preflight] Running evidence check...");
50343
- const evidenceResult = await _internals26.runEvidenceCheck(validatedDir);
49945
+ const evidenceResult = await _internals25.runEvidenceCheck(validatedDir);
50344
49946
  checks5.push(evidenceResult);
50345
49947
  log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
50346
49948
  } else {
@@ -50351,12 +49953,12 @@ async function runPreflight(dir, phase, config3) {
50351
49953
  });
50352
49954
  }
50353
49955
  log("[Preflight] Running requirement coverage check...");
50354
- const reqCoverageResult = await _internals26.runRequirementCoverageCheck(validatedDir, phase);
49956
+ const reqCoverageResult = await _internals25.runRequirementCoverageCheck(validatedDir, phase);
50355
49957
  checks5.push(reqCoverageResult);
50356
49958
  log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
50357
49959
  if (!cfg.skipVersion) {
50358
49960
  log("[Preflight] Running version check...");
50359
- const versionResult = await _internals26.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
49961
+ const versionResult = await _internals25.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
50360
49962
  checks5.push(versionResult);
50361
49963
  log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
50362
49964
  } else {
@@ -50419,10 +50021,10 @@ function formatPreflightMarkdown(report) {
50419
50021
  async function handlePreflightCommand(directory, _args) {
50420
50022
  const plan = await loadPlan(directory);
50421
50023
  const phase = plan?.current_phase ?? 1;
50422
- const report = await _internals26.runPreflight(directory, phase);
50423
- return _internals26.formatPreflightMarkdown(report);
50024
+ const report = await _internals25.runPreflight(directory, phase);
50025
+ return _internals25.formatPreflightMarkdown(report);
50424
50026
  }
50425
- var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals26;
50027
+ var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals25;
50426
50028
  var init_preflight_service = __esm(() => {
50427
50029
  init_manager2();
50428
50030
  init_manager();
@@ -50439,7 +50041,7 @@ var init_preflight_service = __esm(() => {
50439
50041
  testScope: "convention",
50440
50042
  linter: "biome"
50441
50043
  };
50442
- _internals26 = {
50044
+ _internals25 = {
50443
50045
  runPreflight,
50444
50046
  formatPreflightMarkdown,
50445
50047
  handlePreflightCommand,
@@ -52061,7 +51663,7 @@ async function getStatusData(directory, agents) {
52061
51663
  }
52062
51664
  function enrichWithLeanTurbo(status, directory) {
52063
51665
  const turboMode = hasActiveTurboMode();
52064
- const leanActive = _internals27.hasActiveLeanTurbo();
51666
+ const leanActive = _internals26.hasActiveLeanTurbo();
52065
51667
  let turboStrategy = "off";
52066
51668
  if (leanActive) {
52067
51669
  turboStrategy = "lean";
@@ -52080,7 +51682,7 @@ function enrichWithLeanTurbo(status, directory) {
52080
51682
  }
52081
51683
  }
52082
51684
  if (leanSessionID) {
52083
- const runState = _internals27.loadLeanTurboRunState(directory, leanSessionID);
51685
+ const runState = _internals26.loadLeanTurboRunState(directory, leanSessionID);
52084
51686
  if (runState) {
52085
51687
  status.leanTurboPhase = runState.phase;
52086
51688
  status.leanMaxParallelCoders = runState.maxParallelCoders;
@@ -52112,7 +51714,7 @@ function enrichWithLeanTurbo(status, directory) {
52112
51714
  }
52113
51715
  }
52114
51716
  }
52115
- status.fullAutoActive = _internals27.hasActiveFullAuto();
51717
+ status.fullAutoActive = _internals26.hasActiveFullAuto();
52116
51718
  return status;
52117
51719
  }
52118
51720
  function formatStatusMarkdown(status) {
@@ -52194,7 +51796,7 @@ async function handleStatusCommand(directory, agents) {
52194
51796
  }
52195
51797
  return formatStatusMarkdown(statusData);
52196
51798
  }
52197
- var _internals27;
51799
+ var _internals26;
52198
51800
  var init_status_service = __esm(() => {
52199
51801
  init_extractors();
52200
51802
  init_utils2();
@@ -52203,7 +51805,7 @@ var init_status_service = __esm(() => {
52203
51805
  init_state3();
52204
51806
  init_compaction_service();
52205
51807
  init_context_budget_service();
52206
- _internals27 = {
51808
+ _internals26 = {
52207
51809
  loadLeanTurboRunState,
52208
51810
  hasActiveLeanTurbo,
52209
51811
  hasActiveFullAuto
@@ -52294,7 +51896,7 @@ async function handleTurboCommand(directory, args, sessionID) {
52294
51896
  if (arg0 === "on") {
52295
51897
  let strategy = "standard";
52296
51898
  try {
52297
- const { config: config3 } = _internals28.loadPluginConfigWithMeta(directory);
51899
+ const { config: config3 } = _internals27.loadPluginConfigWithMeta(directory);
52298
51900
  if (config3.turbo?.strategy === "lean") {
52299
51901
  strategy = "lean";
52300
51902
  }
@@ -52349,7 +51951,7 @@ function enableLeanTurbo(session, directory, sessionID) {
52349
51951
  let maxParallelCoders = 4;
52350
51952
  let conflictPolicy = "serialize";
52351
51953
  try {
52352
- const { config: config3 } = _internals28.loadPluginConfigWithMeta(directory);
51954
+ const { config: config3 } = _internals27.loadPluginConfigWithMeta(directory);
52353
51955
  const leanConfig = config3.turbo?.lean;
52354
51956
  if (leanConfig) {
52355
51957
  maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
@@ -52419,13 +52021,13 @@ function buildStatusMessage(session, directory, sessionID) {
52419
52021
  ].join(`
52420
52022
  `);
52421
52023
  }
52422
- var _internals28;
52024
+ var _internals27;
52423
52025
  var init_turbo = __esm(() => {
52424
52026
  init_config();
52425
52027
  init_state();
52426
52028
  init_state3();
52427
52029
  init_logger();
52428
- _internals28 = {
52030
+ _internals27 = {
52429
52031
  loadPluginConfigWithMeta
52430
52032
  };
52431
52033
  });
@@ -52518,7 +52120,7 @@ function formatCommandNotFound(tokens) {
52518
52120
  const attemptedCommand = tokens[0] || "";
52519
52121
  const MAX_DISPLAY = 100;
52520
52122
  const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
52521
- const similar = _internals29.findSimilarCommands(attemptedCommand);
52123
+ const similar = _internals28.findSimilarCommands(attemptedCommand);
52522
52124
  const header = `Command \`/swarm ${displayCommand}\` not found.`;
52523
52125
  const suggestions = similar.length > 0 ? `Did you mean:
52524
52126
  ${similar.map((cmd) => ` - /swarm ${cmd}`).join(`
@@ -52967,7 +52569,7 @@ async function buildSwarmCommandPrompt(args) {
52967
52569
  activeAgentName,
52968
52570
  registeredAgents
52969
52571
  } = args;
52970
- const resolved = _internals29.resolveCommand(tokens);
52572
+ const resolved = _internals28.resolveCommand(tokens);
52971
52573
  if (!resolved) {
52972
52574
  if (tokens.length === 0) {
52973
52575
  return buildHelpText();
@@ -53118,7 +52720,7 @@ function findSimilarCommands(query) {
53118
52720
  }
53119
52721
  const scored = VALID_COMMANDS.map((cmd) => {
53120
52722
  const cmdLower = cmd.toLowerCase();
53121
- const fullScore = _internals29.levenshteinDistance(q, cmdLower);
52723
+ const fullScore = _internals28.levenshteinDistance(q, cmdLower);
53122
52724
  let tokenScore = Infinity;
53123
52725
  if (cmd.includes(" ") || cmd.includes("-")) {
53124
52726
  const qTokens = q.split(/[\s-]+/);
@@ -53131,7 +52733,7 @@ function findSimilarCommands(query) {
53131
52733
  for (const ct of cmdTokens) {
53132
52734
  if (ct.length === 0)
53133
52735
  continue;
53134
- const dist = _internals29.levenshteinDistance(qt, ct);
52736
+ const dist = _internals28.levenshteinDistance(qt, ct);
53135
52737
  if (dist < minDist)
53136
52738
  minDist = dist;
53137
52739
  }
@@ -53141,7 +52743,7 @@ function findSimilarCommands(query) {
53141
52743
  }
53142
52744
  const dashStrippedQ = q.replace(/-/g, "");
53143
52745
  const dashStrippedCmd = cmdLower.replace(/-/g, "");
53144
- const dashScore = _internals29.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
52746
+ const dashScore = _internals28.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
53145
52747
  const score = Math.min(fullScore, tokenScore, dashScore);
53146
52748
  return { cmd, score };
53147
52749
  });
@@ -53173,11 +52775,11 @@ async function handleHelpCommand(ctx) {
53173
52775
  return buildHelpText2();
53174
52776
  }
53175
52777
  const tokens = targetCommand.split(/\s+/);
53176
- const resolved = _internals29.resolveCommand(tokens);
52778
+ const resolved = _internals28.resolveCommand(tokens);
53177
52779
  if (resolved) {
53178
- return _internals29.buildDetailedHelp(resolved.key, resolved.entry);
52780
+ return _internals28.buildDetailedHelp(resolved.key, resolved.entry);
53179
52781
  }
53180
- const similar = _internals29.findSimilarCommands(targetCommand);
52782
+ const similar = _internals28.findSimilarCommands(targetCommand);
53181
52783
  const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
53182
52784
  if (similar.length > 0) {
53183
52785
  return `Command '/swarm ${targetCommand}' not found.
@@ -53271,7 +52873,7 @@ function resolveCommand(tokens) {
53271
52873
  }
53272
52874
  return null;
53273
52875
  }
53274
- var COMMAND_REGISTRY, VALID_COMMANDS, _internals29, validation;
52876
+ var COMMAND_REGISTRY, VALID_COMMANDS, _internals28, validation;
53275
52877
  var init_registry = __esm(() => {
53276
52878
  init_acknowledge_spec_drift();
53277
52879
  init_agents();
@@ -53341,7 +52943,7 @@ var init_registry = __esm(() => {
53341
52943
  clashesWithNativeCcCommand: "/agents"
53342
52944
  },
53343
52945
  help: {
53344
- handler: (ctx) => _internals29.handleHelpCommand(ctx),
52946
+ handler: (ctx) => _internals28.handleHelpCommand(ctx),
53345
52947
  description: "Show help for swarm commands",
53346
52948
  category: "core",
53347
52949
  args: "[command]",
@@ -53713,7 +53315,7 @@ Subcommands:
53713
53315
  }
53714
53316
  };
53715
53317
  VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
53716
- _internals29 = {
53318
+ _internals28 = {
53717
53319
  handleHelpCommand,
53718
53320
  validateAliases,
53719
53321
  resolveCommand,
@@ -53721,7 +53323,7 @@ Subcommands:
53721
53323
  findSimilarCommands,
53722
53324
  buildDetailedHelp
53723
53325
  };
53724
- validation = _internals29.validateAliases();
53326
+ validation = _internals28.validateAliases();
53725
53327
  if (!validation.valid) {
53726
53328
  throw new Error(`COMMAND_REGISTRY alias validation failed:
53727
53329
  ${validation.errors.join(`