opencode-swarm 6.25.0 → 6.25.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/index.js CHANGED
@@ -65,6 +65,7 @@ var init_tool_names = __esm(() => {
65
65
  "schema_drift",
66
66
  "todo_extract",
67
67
  "evidence_check",
68
+ "check_gate_status",
68
69
  "sbom_generate",
69
70
  "checkpoint",
70
71
  "pkg_audit",
@@ -141,6 +142,7 @@ var init_constants = __esm(() => {
141
142
  AGENT_TOOL_MAP = {
142
143
  architect: [
143
144
  "checkpoint",
145
+ "check_gate_status",
144
146
  "complexity_hotspots",
145
147
  "detect_domains",
146
148
  "evidence_check",
@@ -37457,8 +37459,8 @@ var init_tree_sitter = __esm(() => {
37457
37459
  bytes = Promise.resolve(input);
37458
37460
  } else {
37459
37461
  if (globalThis.process?.versions.node) {
37460
- const fs27 = await import("fs/promises");
37461
- bytes = fs27.readFile(input);
37462
+ const fs28 = await import("fs/promises");
37463
+ bytes = fs28.readFile(input);
37462
37464
  } else {
37463
37465
  bytes = fetch(input).then((response) => response.arrayBuffer().then((buffer) => {
37464
37466
  if (response.ok) {
@@ -37490,8 +37492,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
37490
37492
  var moduleRtn;
37491
37493
  var Module = moduleArg;
37492
37494
  var readyPromiseResolve, readyPromiseReject;
37493
- var readyPromise = new Promise((resolve13, reject) => {
37494
- readyPromiseResolve = resolve13;
37495
+ var readyPromise = new Promise((resolve14, reject) => {
37496
+ readyPromiseResolve = resolve14;
37495
37497
  readyPromiseReject = reject;
37496
37498
  });
37497
37499
  var ENVIRONMENT_IS_WEB = typeof window == "object";
@@ -37513,11 +37515,11 @@ ${JSON.stringify(symbolNames, null, 2)}`);
37513
37515
  throw toThrow;
37514
37516
  }, "quit_");
37515
37517
  var scriptDirectory = "";
37516
- function locateFile(path40) {
37518
+ function locateFile(path41) {
37517
37519
  if (Module["locateFile"]) {
37518
- return Module["locateFile"](path40, scriptDirectory);
37520
+ return Module["locateFile"](path41, scriptDirectory);
37519
37521
  }
37520
- return scriptDirectory + path40;
37522
+ return scriptDirectory + path41;
37521
37523
  }
37522
37524
  __name(locateFile, "locateFile");
37523
37525
  var readAsync, readBinary;
@@ -37571,13 +37573,13 @@ ${JSON.stringify(symbolNames, null, 2)}`);
37571
37573
  }
37572
37574
  readAsync = /* @__PURE__ */ __name(async (url3) => {
37573
37575
  if (isFileURI(url3)) {
37574
- return new Promise((resolve13, reject) => {
37576
+ return new Promise((resolve14, reject) => {
37575
37577
  var xhr = new XMLHttpRequest;
37576
37578
  xhr.open("GET", url3, true);
37577
37579
  xhr.responseType = "arraybuffer";
37578
37580
  xhr.onload = () => {
37579
37581
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
37580
- resolve13(xhr.response);
37582
+ resolve14(xhr.response);
37581
37583
  return;
37582
37584
  }
37583
37585
  reject(xhr.status);
@@ -37797,10 +37799,10 @@ ${JSON.stringify(symbolNames, null, 2)}`);
37797
37799
  __name(receiveInstantiationResult, "receiveInstantiationResult");
37798
37800
  var info2 = getWasmImports();
37799
37801
  if (Module["instantiateWasm"]) {
37800
- return new Promise((resolve13, reject) => {
37802
+ return new Promise((resolve14, reject) => {
37801
37803
  Module["instantiateWasm"](info2, (mod, inst) => {
37802
37804
  receiveInstance(mod, inst);
37803
- resolve13(mod.exports);
37805
+ resolve14(mod.exports);
37804
37806
  });
37805
37807
  });
37806
37808
  }
@@ -39265,7 +39267,7 @@ var init_runtime = __esm(() => {
39265
39267
  });
39266
39268
 
39267
39269
  // src/index.ts
39268
- import * as path49 from "path";
39270
+ import * as path50 from "path";
39269
39271
 
39270
39272
  // src/agents/index.ts
39271
39273
  init_config();
@@ -41515,6 +41517,7 @@ function getAgentConfigs(config2) {
41515
41517
  };
41516
41518
  if (agent.name === "architect" || agent.name.endsWith("_architect")) {
41517
41519
  sdkConfig.mode = "primary";
41520
+ sdkConfig.permission = { task: "allow" };
41518
41521
  } else {
41519
41522
  sdkConfig.mode = "subagent";
41520
41523
  }
@@ -52980,12 +52983,139 @@ var build_check = createSwarmTool({
52980
52983
  return JSON.stringify(result, null, 2);
52981
52984
  }
52982
52985
  });
52986
+ // src/tools/check-gate-status.ts
52987
+ init_dist();
52988
+ init_create_tool();
52989
+ import * as fs19 from "fs";
52990
+ import * as path32 from "path";
52991
+ var EVIDENCE_DIR = ".swarm/evidence";
52992
+ function isPathWithinSwarm(filePath, workspaceRoot) {
52993
+ const normalizedWorkspace = path32.resolve(workspaceRoot);
52994
+ const swarmPath = path32.join(normalizedWorkspace, ".swarm", "evidence");
52995
+ const normalizedPath = path32.resolve(filePath);
52996
+ return normalizedPath.startsWith(swarmPath);
52997
+ }
52998
+ function readEvidenceFile(evidencePath) {
52999
+ if (!fs19.existsSync(evidencePath)) {
53000
+ return null;
53001
+ }
53002
+ let content;
53003
+ try {
53004
+ content = fs19.readFileSync(evidencePath, "utf-8");
53005
+ } catch {
53006
+ return null;
53007
+ }
53008
+ let parsed;
53009
+ try {
53010
+ parsed = JSON.parse(content);
53011
+ } catch {
53012
+ return null;
53013
+ }
53014
+ if (parsed && typeof parsed === "object" && Array.isArray(parsed.required_gates) && typeof parsed.gates === "object" && parsed.gates !== null) {
53015
+ return parsed;
53016
+ }
53017
+ return null;
53018
+ }
53019
+ var check_gate_status = createSwarmTool({
53020
+ description: "Read-only tool to check the gate status of a specific task. Reads .swarm/evidence/{taskId}.json and returns structured JSON describing required, passed, and missing gates.",
53021
+ args: {
53022
+ task_id: tool.schema.string().min(1).regex(/^\d+\.\d+(\.\d+)?$/, "Task ID must be in N.M or N.M.P format").describe('The task ID to check gate status for (e.g., "1.1", "2.3.1")')
53023
+ },
53024
+ async execute(args2, directory) {
53025
+ let taskIdInput;
53026
+ try {
53027
+ if (args2 && typeof args2 === "object") {
53028
+ const obj = args2;
53029
+ taskIdInput = typeof obj.task_id === "string" ? obj.task_id : undefined;
53030
+ }
53031
+ } catch {}
53032
+ if (!taskIdInput) {
53033
+ const errorResult = {
53034
+ taskId: "",
53035
+ status: "no_evidence",
53036
+ required_gates: [],
53037
+ passed_gates: [],
53038
+ missing_gates: [],
53039
+ gates: {},
53040
+ message: "Invalid task_id: task_id is required"
53041
+ };
53042
+ return JSON.stringify(errorResult, null, 2);
53043
+ }
53044
+ const taskIdPattern = /^\d+\.\d+(\.\d+)?$/;
53045
+ if (!taskIdPattern.test(taskIdInput)) {
53046
+ const errorResult = {
53047
+ taskId: taskIdInput,
53048
+ status: "no_evidence",
53049
+ required_gates: [],
53050
+ passed_gates: [],
53051
+ missing_gates: [],
53052
+ gates: {},
53053
+ message: `Invalid task_id format: "${taskIdInput}". Must match pattern N.M or N.M.P (e.g., "1.1", "1.2.3")`
53054
+ };
53055
+ return JSON.stringify(errorResult, null, 2);
53056
+ }
53057
+ const evidencePath = path32.join(directory, EVIDENCE_DIR, `${taskIdInput}.json`);
53058
+ if (!isPathWithinSwarm(evidencePath, directory)) {
53059
+ const errorResult = {
53060
+ taskId: taskIdInput,
53061
+ status: "no_evidence",
53062
+ required_gates: [],
53063
+ passed_gates: [],
53064
+ missing_gates: [],
53065
+ gates: {},
53066
+ message: "Invalid path: evidence path validation failed"
53067
+ };
53068
+ return JSON.stringify(errorResult, null, 2);
53069
+ }
53070
+ const evidenceData = readEvidenceFile(evidencePath);
53071
+ if (!evidenceData) {
53072
+ const errorResult = {
53073
+ taskId: taskIdInput,
53074
+ status: "no_evidence",
53075
+ required_gates: [],
53076
+ passed_gates: [],
53077
+ missing_gates: [],
53078
+ gates: {},
53079
+ message: `No evidence file found for task "${taskIdInput}" at ${evidencePath}. Evidence file may be missing or invalid.`
53080
+ };
53081
+ return JSON.stringify(errorResult, null, 2);
53082
+ }
53083
+ const requiredGates = evidenceData.required_gates || [];
53084
+ const gatesMap = evidenceData.gates || {};
53085
+ const passedGates = [];
53086
+ const missingGates = [];
53087
+ for (const requiredGate of requiredGates) {
53088
+ if (gatesMap[requiredGate]) {
53089
+ passedGates.push(requiredGate);
53090
+ } else {
53091
+ missingGates.push(requiredGate);
53092
+ }
53093
+ }
53094
+ const status = missingGates.length === 0 ? "all_passed" : "incomplete";
53095
+ let message;
53096
+ if (status === "all_passed") {
53097
+ message = `All required gates have passed for task "${taskIdInput}".`;
53098
+ } else {
53099
+ message = `Task "${taskIdInput}" is incomplete. Missing gates: ${missingGates.join(", ")}.`;
53100
+ }
53101
+ const result = {
53102
+ taskId: taskIdInput,
53103
+ status,
53104
+ required_gates: requiredGates,
53105
+ passed_gates: passedGates,
53106
+ missing_gates: missingGates,
53107
+ gates: gatesMap,
53108
+ message
53109
+ };
53110
+ return JSON.stringify(result, null, 2);
53111
+ }
53112
+ });
52983
53113
  // src/tools/checkpoint.ts
52984
53114
  init_tool();
52985
53115
  init_create_tool();
52986
53116
  import { spawnSync } from "child_process";
52987
- import * as fs19 from "fs";
52988
- import * as path32 from "path";
53117
+ import * as fs20 from "fs";
53118
+ import * as path33 from "path";
52989
53119
  var CHECKPOINT_LOG_PATH = ".swarm/checkpoints.json";
52990
53120
  var MAX_LABEL_LENGTH = 100;
52991
53121
  var GIT_TIMEOUT_MS = 30000;
@@ -53036,13 +53166,13 @@ function validateLabel(label) {
53036
53166
  return null;
53037
53167
  }
53038
53168
  function getCheckpointLogPath(directory) {
53039
- return path32.join(directory, CHECKPOINT_LOG_PATH);
53169
+ return path33.join(directory, CHECKPOINT_LOG_PATH);
53040
53170
  }
53041
53171
  function readCheckpointLog(directory) {
53042
53172
  const logPath = getCheckpointLogPath(directory);
53043
53173
  try {
53044
- if (fs19.existsSync(logPath)) {
53045
- const content = fs19.readFileSync(logPath, "utf-8");
53174
+ if (fs20.existsSync(logPath)) {
53175
+ const content = fs20.readFileSync(logPath, "utf-8");
53046
53176
  const parsed = JSON.parse(content);
53047
53177
  if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
53048
53178
  return { version: 1, checkpoints: [] };
@@ -53054,13 +53184,13 @@ function readCheckpointLog(directory) {
53054
53184
  }
53055
53185
  function writeCheckpointLog(log2, directory) {
53056
53186
  const logPath = getCheckpointLogPath(directory);
53057
- const dir = path32.dirname(logPath);
53058
- if (!fs19.existsSync(dir)) {
53059
- fs19.mkdirSync(dir, { recursive: true });
53187
+ const dir = path33.dirname(logPath);
53188
+ if (!fs20.existsSync(dir)) {
53189
+ fs20.mkdirSync(dir, { recursive: true });
53060
53190
  }
53061
53191
  const tempPath = `${logPath}.tmp`;
53062
- fs19.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
53063
- fs19.renameSync(tempPath, logPath);
53192
+ fs20.writeFileSync(tempPath, JSON.stringify(log2, null, 2), "utf-8");
53193
+ fs20.renameSync(tempPath, logPath);
53064
53194
  }
53065
53195
  function gitExec(args2) {
53066
53196
  const result = spawnSync("git", args2, {
@@ -53261,8 +53391,8 @@ var checkpoint = createSwarmTool({
53261
53391
  // src/tools/complexity-hotspots.ts
53262
53392
  init_dist();
53263
53393
  init_create_tool();
53264
- import * as fs20 from "fs";
53265
- import * as path33 from "path";
53394
+ import * as fs21 from "fs";
53395
+ import * as path34 from "path";
53266
53396
  var MAX_FILE_SIZE_BYTES2 = 256 * 1024;
53267
53397
  var DEFAULT_DAYS = 90;
53268
53398
  var DEFAULT_TOP_N = 20;
@@ -53391,11 +53521,11 @@ function estimateComplexity(content) {
53391
53521
  }
53392
53522
  function getComplexityForFile(filePath) {
53393
53523
  try {
53394
- const stat2 = fs20.statSync(filePath);
53524
+ const stat2 = fs21.statSync(filePath);
53395
53525
  if (stat2.size > MAX_FILE_SIZE_BYTES2) {
53396
53526
  return null;
53397
53527
  }
53398
- const content = fs20.readFileSync(filePath, "utf-8");
53528
+ const content = fs21.readFileSync(filePath, "utf-8");
53399
53529
  return estimateComplexity(content);
53400
53530
  } catch {
53401
53531
  return null;
@@ -53406,7 +53536,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
53406
53536
  const extSet = new Set(extensions.map((e) => e.startsWith(".") ? e : `.${e}`));
53407
53537
  const filteredChurn = new Map;
53408
53538
  for (const [file3, count] of churnMap) {
53409
- const ext = path33.extname(file3).toLowerCase();
53539
+ const ext = path34.extname(file3).toLowerCase();
53410
53540
  if (extSet.has(ext)) {
53411
53541
  filteredChurn.set(file3, count);
53412
53542
  }
@@ -53416,8 +53546,8 @@ async function analyzeHotspots(days, topN, extensions, directory) {
53416
53546
  let analyzedFiles = 0;
53417
53547
  for (const [file3, churnCount] of filteredChurn) {
53418
53548
  let fullPath = file3;
53419
- if (!fs20.existsSync(fullPath)) {
53420
- fullPath = path33.join(cwd, file3);
53549
+ if (!fs21.existsSync(fullPath)) {
53550
+ fullPath = path34.join(cwd, file3);
53421
53551
  }
53422
53552
  const complexity = getComplexityForFile(fullPath);
53423
53553
  if (complexity !== null) {
@@ -53564,8 +53694,8 @@ var complexity_hotspots = createSwarmTool({
53564
53694
  });
53565
53695
  // src/tools/declare-scope.ts
53566
53696
  init_tool();
53567
- import * as fs21 from "fs";
53568
- import * as path34 from "path";
53697
+ import * as fs22 from "fs";
53698
+ import * as path35 from "path";
53569
53699
  init_create_tool();
53570
53700
  function validateTaskIdFormat(taskId) {
53571
53701
  const taskIdPattern = /^\d+\.\d+(\.\d+)*$/;
@@ -53644,8 +53774,8 @@ async function executeDeclareScope(args2, fallbackDir) {
53644
53774
  };
53645
53775
  }
53646
53776
  }
53647
- normalizedDir = path34.normalize(args2.working_directory);
53648
- const pathParts = normalizedDir.split(path34.sep);
53777
+ normalizedDir = path35.normalize(args2.working_directory);
53778
+ const pathParts = normalizedDir.split(path35.sep);
53649
53779
  if (pathParts.includes("..")) {
53650
53780
  return {
53651
53781
  success: false,
@@ -53655,11 +53785,11 @@ async function executeDeclareScope(args2, fallbackDir) {
53655
53785
  ]
53656
53786
  };
53657
53787
  }
53658
- const resolvedDir = path34.resolve(normalizedDir);
53788
+ const resolvedDir = path35.resolve(normalizedDir);
53659
53789
  try {
53660
- const realPath = fs21.realpathSync(resolvedDir);
53661
- const planPath2 = path34.join(realPath, ".swarm", "plan.json");
53662
- if (!fs21.existsSync(planPath2)) {
53790
+ const realPath = fs22.realpathSync(resolvedDir);
53791
+ const planPath2 = path35.join(realPath, ".swarm", "plan.json");
53792
+ if (!fs22.existsSync(planPath2)) {
53663
53793
  return {
53664
53794
  success: false,
53665
53795
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -53679,8 +53809,8 @@ async function executeDeclareScope(args2, fallbackDir) {
53679
53809
  }
53680
53810
  }
53681
53811
  const directory = normalizedDir ?? fallbackDir ?? process.cwd();
53682
- const planPath = path34.resolve(directory, ".swarm", "plan.json");
53683
- if (!fs21.existsSync(planPath)) {
53812
+ const planPath = path35.resolve(directory, ".swarm", "plan.json");
53813
+ if (!fs22.existsSync(planPath)) {
53684
53814
  return {
53685
53815
  success: false,
53686
53816
  message: "No plan found",
@@ -53689,7 +53819,7 @@ async function executeDeclareScope(args2, fallbackDir) {
53689
53819
  }
53690
53820
  let planContent;
53691
53821
  try {
53692
- planContent = JSON.parse(fs21.readFileSync(planPath, "utf-8"));
53822
+ planContent = JSON.parse(fs22.readFileSync(planPath, "utf-8"));
53693
53823
  } catch {
53694
53824
  return {
53695
53825
  success: false,
@@ -53769,20 +53899,20 @@ function validateBase(base) {
53769
53899
  function validatePaths(paths) {
53770
53900
  if (!paths)
53771
53901
  return null;
53772
- for (const path35 of paths) {
53773
- if (!path35 || path35.length === 0) {
53902
+ for (const path36 of paths) {
53903
+ if (!path36 || path36.length === 0) {
53774
53904
  return "empty path not allowed";
53775
53905
  }
53776
- if (path35.length > MAX_PATH_LENGTH) {
53906
+ if (path36.length > MAX_PATH_LENGTH) {
53777
53907
  return `path exceeds maximum length of ${MAX_PATH_LENGTH}`;
53778
53908
  }
53779
- if (SHELL_METACHARACTERS2.test(path35)) {
53909
+ if (SHELL_METACHARACTERS2.test(path36)) {
53780
53910
  return "path contains shell metacharacters";
53781
53911
  }
53782
- if (path35.startsWith("-")) {
53912
+ if (path36.startsWith("-")) {
53783
53913
  return 'path cannot start with "-" (option-like arguments not allowed)';
53784
53914
  }
53785
- if (CONTROL_CHAR_PATTERN2.test(path35)) {
53915
+ if (CONTROL_CHAR_PATTERN2.test(path36)) {
53786
53916
  return "path contains control characters";
53787
53917
  }
53788
53918
  }
@@ -53862,8 +53992,8 @@ var diff = tool({
53862
53992
  if (parts2.length >= 3) {
53863
53993
  const additions = parseInt(parts2[0], 10) || 0;
53864
53994
  const deletions = parseInt(parts2[1], 10) || 0;
53865
- const path35 = parts2[2];
53866
- files.push({ path: path35, additions, deletions });
53995
+ const path36 = parts2[2];
53996
+ files.push({ path: path36, additions, deletions });
53867
53997
  }
53868
53998
  }
53869
53999
  const contractChanges = [];
@@ -54092,11 +54222,11 @@ Use these as DOMAIN values when delegating to @sme.`;
54092
54222
  // src/tools/evidence-check.ts
54093
54223
  init_dist();
54094
54224
  init_create_tool();
54095
- import * as fs22 from "fs";
54096
- import * as path35 from "path";
54225
+ import * as fs23 from "fs";
54226
+ import * as path36 from "path";
54097
54227
  var MAX_FILE_SIZE_BYTES3 = 1024 * 1024;
54098
54228
  var MAX_EVIDENCE_FILES = 1000;
54099
- var EVIDENCE_DIR = ".swarm/evidence";
54229
+ var EVIDENCE_DIR2 = ".swarm/evidence";
54100
54230
  var PLAN_FILE = ".swarm/plan.md";
54101
54231
  var SHELL_METACHAR_REGEX2 = /[;&|%$`\\]/;
54102
54232
  var VALID_EVIDENCE_FILENAME_REGEX = /^[a-zA-Z0-9_-]+\.json$/;
@@ -54115,10 +54245,10 @@ function validateRequiredTypes(input) {
54115
54245
  }
54116
54246
  return null;
54117
54247
  }
54118
- function isPathWithinSwarm(filePath, cwd) {
54119
- const normalizedCwd = path35.resolve(cwd);
54120
- const swarmPath = path35.join(normalizedCwd, ".swarm");
54121
- const normalizedPath = path35.resolve(filePath);
54248
+ function isPathWithinSwarm2(filePath, cwd) {
54249
+ const normalizedCwd = path36.resolve(cwd);
54250
+ const swarmPath = path36.join(normalizedCwd, ".swarm");
54251
+ const normalizedPath = path36.resolve(filePath);
54122
54252
  return normalizedPath.startsWith(swarmPath);
54123
54253
  }
54124
54254
  function parseCompletedTasks(planContent) {
@@ -54134,12 +54264,12 @@ function parseCompletedTasks(planContent) {
54134
54264
  }
54135
54265
  function readEvidenceFiles(evidenceDir, _cwd) {
54136
54266
  const evidence = [];
54137
- if (!fs22.existsSync(evidenceDir) || !fs22.statSync(evidenceDir).isDirectory()) {
54267
+ if (!fs23.existsSync(evidenceDir) || !fs23.statSync(evidenceDir).isDirectory()) {
54138
54268
  return evidence;
54139
54269
  }
54140
54270
  let files;
54141
54271
  try {
54142
- files = fs22.readdirSync(evidenceDir);
54272
+ files = fs23.readdirSync(evidenceDir);
54143
54273
  } catch {
54144
54274
  return evidence;
54145
54275
  }
@@ -54148,14 +54278,14 @@ function readEvidenceFiles(evidenceDir, _cwd) {
54148
54278
  if (!VALID_EVIDENCE_FILENAME_REGEX.test(filename)) {
54149
54279
  continue;
54150
54280
  }
54151
- const filePath = path35.join(evidenceDir, filename);
54281
+ const filePath = path36.join(evidenceDir, filename);
54152
54282
  try {
54153
- const resolvedPath = path35.resolve(filePath);
54154
- const evidenceDirResolved = path35.resolve(evidenceDir);
54283
+ const resolvedPath = path36.resolve(filePath);
54284
+ const evidenceDirResolved = path36.resolve(evidenceDir);
54155
54285
  if (!resolvedPath.startsWith(evidenceDirResolved)) {
54156
54286
  continue;
54157
54287
  }
54158
- const stat2 = fs22.lstatSync(filePath);
54288
+ const stat2 = fs23.lstatSync(filePath);
54159
54289
  if (!stat2.isFile()) {
54160
54290
  continue;
54161
54291
  }
@@ -54164,7 +54294,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
54164
54294
  }
54165
54295
  let fileStat;
54166
54296
  try {
54167
- fileStat = fs22.statSync(filePath);
54297
+ fileStat = fs23.statSync(filePath);
54168
54298
  if (fileStat.size > MAX_FILE_SIZE_BYTES3) {
54169
54299
  continue;
54170
54300
  }
@@ -54173,7 +54303,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
54173
54303
  }
54174
54304
  let content;
54175
54305
  try {
54176
- content = fs22.readFileSync(filePath, "utf-8");
54306
+ content = fs23.readFileSync(filePath, "utf-8");
54177
54307
  } catch {
54178
54308
  continue;
54179
54309
  }
@@ -54258,8 +54388,8 @@ var evidence_check = createSwarmTool({
54258
54388
  return JSON.stringify(errorResult, null, 2);
54259
54389
  }
54260
54390
  const requiredTypes = requiredTypesValue.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
54261
- const planPath = path35.join(cwd, PLAN_FILE);
54262
- if (!isPathWithinSwarm(planPath, cwd)) {
54391
+ const planPath = path36.join(cwd, PLAN_FILE);
54392
+ if (!isPathWithinSwarm2(planPath, cwd)) {
54263
54393
  const errorResult = {
54264
54394
  error: "plan file path validation failed",
54265
54395
  completedTasks: [],
@@ -54272,7 +54402,7 @@ var evidence_check = createSwarmTool({
54272
54402
  }
54273
54403
  let planContent;
54274
54404
  try {
54275
- planContent = fs22.readFileSync(planPath, "utf-8");
54405
+ planContent = fs23.readFileSync(planPath, "utf-8");
54276
54406
  } catch {
54277
54407
  const result2 = {
54278
54408
  message: "No completed tasks found in plan.",
@@ -54290,7 +54420,7 @@ var evidence_check = createSwarmTool({
54290
54420
  };
54291
54421
  return JSON.stringify(result2, null, 2);
54292
54422
  }
54293
- const evidenceDir = path35.join(cwd, EVIDENCE_DIR);
54423
+ const evidenceDir = path36.join(cwd, EVIDENCE_DIR2);
54294
54424
  const evidence = readEvidenceFiles(evidenceDir, cwd);
54295
54425
  const { tasksWithFullEvidence, gaps } = analyzeGaps(completedTasks, evidence, requiredTypes);
54296
54426
  const completeness = completedTasks.length > 0 ? Math.round(tasksWithFullEvidence.length / completedTasks.length * 100) / 100 : 1;
@@ -54307,8 +54437,8 @@ var evidence_check = createSwarmTool({
54307
54437
  // src/tools/file-extractor.ts
54308
54438
  init_tool();
54309
54439
  init_create_tool();
54310
- import * as fs23 from "fs";
54311
- import * as path36 from "path";
54440
+ import * as fs24 from "fs";
54441
+ import * as path37 from "path";
54312
54442
  var EXT_MAP = {
54313
54443
  python: ".py",
54314
54444
  py: ".py",
@@ -54370,8 +54500,8 @@ var extract_code_blocks = createSwarmTool({
54370
54500
  execute: async (args2, directory) => {
54371
54501
  const { content, output_dir, prefix } = args2;
54372
54502
  const targetDir = output_dir || directory;
54373
- if (!fs23.existsSync(targetDir)) {
54374
- fs23.mkdirSync(targetDir, { recursive: true });
54503
+ if (!fs24.existsSync(targetDir)) {
54504
+ fs24.mkdirSync(targetDir, { recursive: true });
54375
54505
  }
54376
54506
  if (!content) {
54377
54507
  return "Error: content is required";
@@ -54389,16 +54519,16 @@ var extract_code_blocks = createSwarmTool({
54389
54519
  if (prefix) {
54390
54520
  filename = `${prefix}_${filename}`;
54391
54521
  }
54392
- let filepath = path36.join(targetDir, filename);
54393
- const base = path36.basename(filepath, path36.extname(filepath));
54394
- const ext = path36.extname(filepath);
54522
+ let filepath = path37.join(targetDir, filename);
54523
+ const base = path37.basename(filepath, path37.extname(filepath));
54524
+ const ext = path37.extname(filepath);
54395
54525
  let counter = 1;
54396
- while (fs23.existsSync(filepath)) {
54397
- filepath = path36.join(targetDir, `${base}_${counter}${ext}`);
54526
+ while (fs24.existsSync(filepath)) {
54527
+ filepath = path37.join(targetDir, `${base}_${counter}${ext}`);
54398
54528
  counter++;
54399
54529
  }
54400
54530
  try {
54401
- fs23.writeFileSync(filepath, code.trim(), "utf-8");
54531
+ fs24.writeFileSync(filepath, code.trim(), "utf-8");
54402
54532
  savedFiles.push(filepath);
54403
54533
  } catch (error93) {
54404
54534
  errors5.push(`Failed to save ${filename}: ${error93 instanceof Error ? error93.message : String(error93)}`);
@@ -54427,7 +54557,7 @@ init_dist();
54427
54557
  var GITINGEST_TIMEOUT_MS = 1e4;
54428
54558
  var GITINGEST_MAX_RESPONSE_BYTES = 5242880;
54429
54559
  var GITINGEST_MAX_RETRIES = 2;
54430
- var delay = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
54560
+ var delay = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
54431
54561
  async function fetchGitingest(args2) {
54432
54562
  for (let attempt = 0;attempt <= GITINGEST_MAX_RETRIES; attempt++) {
54433
54563
  try {
@@ -54511,8 +54641,8 @@ var gitingest = tool({
54511
54641
  });
54512
54642
  // src/tools/imports.ts
54513
54643
  init_dist();
54514
- import * as fs24 from "fs";
54515
- import * as path37 from "path";
54644
+ import * as fs25 from "fs";
54645
+ import * as path38 from "path";
54516
54646
  var MAX_FILE_PATH_LENGTH2 = 500;
54517
54647
  var MAX_SYMBOL_LENGTH = 256;
54518
54648
  var MAX_FILE_SIZE_BYTES4 = 1024 * 1024;
@@ -54566,7 +54696,7 @@ function validateSymbolInput(symbol3) {
54566
54696
  return null;
54567
54697
  }
54568
54698
  function isBinaryFile2(filePath, buffer) {
54569
- const ext = path37.extname(filePath).toLowerCase();
54699
+ const ext = path38.extname(filePath).toLowerCase();
54570
54700
  if (ext === ".json" || ext === ".md" || ext === ".txt") {
54571
54701
  return false;
54572
54702
  }
@@ -54590,15 +54720,15 @@ function parseImports(content, targetFile, targetSymbol) {
54590
54720
  const imports = [];
54591
54721
  let _resolvedTarget;
54592
54722
  try {
54593
- _resolvedTarget = path37.resolve(targetFile);
54723
+ _resolvedTarget = path38.resolve(targetFile);
54594
54724
  } catch {
54595
54725
  _resolvedTarget = targetFile;
54596
54726
  }
54597
- const targetBasename = path37.basename(targetFile, path37.extname(targetFile));
54727
+ const targetBasename = path38.basename(targetFile, path38.extname(targetFile));
54598
54728
  const targetWithExt = targetFile;
54599
54729
  const targetWithoutExt = targetFile.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
54600
- const normalizedTargetWithExt = path37.normalize(targetWithExt).replace(/\\/g, "/");
54601
- const normalizedTargetWithoutExt = path37.normalize(targetWithoutExt).replace(/\\/g, "/");
54730
+ const normalizedTargetWithExt = path38.normalize(targetWithExt).replace(/\\/g, "/");
54731
+ const normalizedTargetWithoutExt = path38.normalize(targetWithoutExt).replace(/\\/g, "/");
54602
54732
  const importRegex = /import\s+(?:\{[\s\S]*?\}|(?:\*\s+as\s+\w+)|\w+)\s+from\s+['"`]([^'"`]+)['"`]|import\s+['"`]([^'"`]+)['"`]|require\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
54603
54733
  for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
54604
54734
  const modulePath = match[1] || match[2] || match[3];
@@ -54621,9 +54751,9 @@ function parseImports(content, targetFile, targetSymbol) {
54621
54751
  }
54622
54752
  const _normalizedModule = modulePath.replace(/^\.\//, "").replace(/^\.\.\\/, "../");
54623
54753
  let isMatch = false;
54624
- const _targetDir = path37.dirname(targetFile);
54625
- const targetExt = path37.extname(targetFile);
54626
- const targetBasenameNoExt = path37.basename(targetFile, targetExt);
54754
+ const _targetDir = path38.dirname(targetFile);
54755
+ const targetExt = path38.extname(targetFile);
54756
+ const targetBasenameNoExt = path38.basename(targetFile, targetExt);
54627
54757
  const moduleNormalized = modulePath.replace(/\\/g, "/").replace(/^\.\//, "");
54628
54758
  const moduleName = modulePath.split(/[/\\]/).pop() || "";
54629
54759
  const moduleNameNoExt = moduleName.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/i, "");
@@ -54680,7 +54810,7 @@ var SKIP_DIRECTORIES2 = new Set([
54680
54810
  function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFiles: 0, fileErrors: [] }) {
54681
54811
  let entries;
54682
54812
  try {
54683
- entries = fs24.readdirSync(dir);
54813
+ entries = fs25.readdirSync(dir);
54684
54814
  } catch (e) {
54685
54815
  stats.fileErrors.push({
54686
54816
  path: dir,
@@ -54691,13 +54821,13 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
54691
54821
  entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
54692
54822
  for (const entry of entries) {
54693
54823
  if (SKIP_DIRECTORIES2.has(entry)) {
54694
- stats.skippedDirs.push(path37.join(dir, entry));
54824
+ stats.skippedDirs.push(path38.join(dir, entry));
54695
54825
  continue;
54696
54826
  }
54697
- const fullPath = path37.join(dir, entry);
54827
+ const fullPath = path38.join(dir, entry);
54698
54828
  let stat2;
54699
54829
  try {
54700
- stat2 = fs24.statSync(fullPath);
54830
+ stat2 = fs25.statSync(fullPath);
54701
54831
  } catch (e) {
54702
54832
  stats.fileErrors.push({
54703
54833
  path: fullPath,
@@ -54708,7 +54838,7 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
54708
54838
  if (stat2.isDirectory()) {
54709
54839
  findSourceFiles2(fullPath, files, stats);
54710
54840
  } else if (stat2.isFile()) {
54711
- const ext = path37.extname(fullPath).toLowerCase();
54841
+ const ext = path38.extname(fullPath).toLowerCase();
54712
54842
  if (SUPPORTED_EXTENSIONS.includes(ext)) {
54713
54843
  files.push(fullPath);
54714
54844
  }
@@ -54764,8 +54894,8 @@ var imports = tool({
54764
54894
  return JSON.stringify(errorResult, null, 2);
54765
54895
  }
54766
54896
  try {
54767
- const targetFile = path37.resolve(file3);
54768
- if (!fs24.existsSync(targetFile)) {
54897
+ const targetFile = path38.resolve(file3);
54898
+ if (!fs25.existsSync(targetFile)) {
54769
54899
  const errorResult = {
54770
54900
  error: `target file not found: ${file3}`,
54771
54901
  target: file3,
@@ -54775,7 +54905,7 @@ var imports = tool({
54775
54905
  };
54776
54906
  return JSON.stringify(errorResult, null, 2);
54777
54907
  }
54778
- const targetStat = fs24.statSync(targetFile);
54908
+ const targetStat = fs25.statSync(targetFile);
54779
54909
  if (!targetStat.isFile()) {
54780
54910
  const errorResult = {
54781
54911
  error: "target must be a file, not a directory",
@@ -54786,7 +54916,7 @@ var imports = tool({
54786
54916
  };
54787
54917
  return JSON.stringify(errorResult, null, 2);
54788
54918
  }
54789
- const baseDir = path37.dirname(targetFile);
54919
+ const baseDir = path38.dirname(targetFile);
54790
54920
  const scanStats = {
54791
54921
  skippedDirs: [],
54792
54922
  skippedFiles: 0,
@@ -54801,12 +54931,12 @@ var imports = tool({
54801
54931
  if (consumers.length >= MAX_CONSUMERS)
54802
54932
  break;
54803
54933
  try {
54804
- const stat2 = fs24.statSync(filePath);
54934
+ const stat2 = fs25.statSync(filePath);
54805
54935
  if (stat2.size > MAX_FILE_SIZE_BYTES4) {
54806
54936
  skippedFileCount++;
54807
54937
  continue;
54808
54938
  }
54809
- const buffer = fs24.readFileSync(filePath);
54939
+ const buffer = fs25.readFileSync(filePath);
54810
54940
  if (isBinaryFile2(filePath, buffer)) {
54811
54941
  skippedFileCount++;
54812
54942
  continue;
@@ -54871,7 +55001,7 @@ var imports = tool({
54871
55001
  });
54872
55002
  // src/tools/knowledge-query.ts
54873
55003
  init_dist();
54874
- import { existsSync as existsSync25 } from "fs";
55004
+ import { existsSync as existsSync26 } from "fs";
54875
55005
  init_create_tool();
54876
55006
  var DEFAULT_LIMIT = 10;
54877
55007
  var MAX_LESSON_LENGTH = 200;
@@ -54941,14 +55071,14 @@ function validateLimit(limit) {
54941
55071
  }
54942
55072
  async function readSwarmKnowledge(directory) {
54943
55073
  const swarmPath = resolveSwarmKnowledgePath(directory);
54944
- if (!existsSync25(swarmPath)) {
55074
+ if (!existsSync26(swarmPath)) {
54945
55075
  return [];
54946
55076
  }
54947
55077
  return readKnowledge(swarmPath);
54948
55078
  }
54949
55079
  async function readHiveKnowledge() {
54950
55080
  const hivePath = resolveHiveKnowledgePath();
54951
- if (!existsSync25(hivePath)) {
55081
+ if (!existsSync26(hivePath)) {
54952
55082
  return [];
54953
55083
  }
54954
55084
  return readKnowledge(hivePath);
@@ -55107,8 +55237,8 @@ init_dist();
55107
55237
  init_config();
55108
55238
  init_schema();
55109
55239
  init_manager();
55110
- import * as fs25 from "fs";
55111
- import * as path38 from "path";
55240
+ import * as fs26 from "fs";
55241
+ import * as path39 from "path";
55112
55242
  init_utils2();
55113
55243
  init_create_tool();
55114
55244
  function safeWarn(message, error93) {
@@ -55303,7 +55433,7 @@ async function executePhaseComplete(args2, workingDirectory) {
55303
55433
  }
55304
55434
  if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
55305
55435
  try {
55306
- const projectName = path38.basename(dir);
55436
+ const projectName = path39.basename(dir);
55307
55437
  const knowledgeConfig = {
55308
55438
  enabled: true,
55309
55439
  swarm_max_entries: 100,
@@ -55351,7 +55481,7 @@ async function executePhaseComplete(args2, workingDirectory) {
55351
55481
  if (agentsMissing.length > 0) {
55352
55482
  try {
55353
55483
  const planPath = validateSwarmPath(dir, "plan.json");
55354
- const planRaw = fs25.readFileSync(planPath, "utf-8");
55484
+ const planRaw = fs26.readFileSync(planPath, "utf-8");
55355
55485
  const plan = JSON.parse(planRaw);
55356
55486
  const targetPhase = plan.phases.find((p) => p.id === phase);
55357
55487
  if (targetPhase && targetPhase.tasks.length > 0 && targetPhase.tasks.every((t) => t.status === "completed")) {
@@ -55392,7 +55522,7 @@ async function executePhaseComplete(args2, workingDirectory) {
55392
55522
  };
55393
55523
  try {
55394
55524
  const eventsPath = validateSwarmPath(dir, "events.jsonl");
55395
- fs25.appendFileSync(eventsPath, `${JSON.stringify(event)}
55525
+ fs26.appendFileSync(eventsPath, `${JSON.stringify(event)}
55396
55526
  `, "utf-8");
55397
55527
  } catch (writeError) {
55398
55528
  warnings.push(`Warning: failed to write phase complete event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
@@ -55411,12 +55541,12 @@ async function executePhaseComplete(args2, workingDirectory) {
55411
55541
  }
55412
55542
  try {
55413
55543
  const planPath = validateSwarmPath(dir, "plan.json");
55414
- const planJson = fs25.readFileSync(planPath, "utf-8");
55544
+ const planJson = fs26.readFileSync(planPath, "utf-8");
55415
55545
  const plan = JSON.parse(planJson);
55416
55546
  const phaseObj = plan.phases.find((p) => p.id === phase);
55417
55547
  if (phaseObj) {
55418
55548
  phaseObj.status = "completed";
55419
- fs25.writeFileSync(planPath, `${JSON.stringify(plan, null, 2)}
55549
+ fs26.writeFileSync(planPath, `${JSON.stringify(plan, null, 2)}
55420
55550
  `, "utf-8");
55421
55551
  }
55422
55552
  } catch (error93) {
@@ -55466,8 +55596,8 @@ init_dist();
55466
55596
  init_discovery();
55467
55597
  init_utils();
55468
55598
  init_create_tool();
55469
- import * as fs26 from "fs";
55470
- import * as path39 from "path";
55599
+ import * as fs27 from "fs";
55600
+ import * as path40 from "path";
55471
55601
  var MAX_OUTPUT_BYTES5 = 52428800;
55472
55602
  var AUDIT_TIMEOUT_MS = 120000;
55473
55603
  function isValidEcosystem(value) {
@@ -55485,28 +55615,28 @@ function validateArgs3(args2) {
55485
55615
  function detectEcosystems(directory) {
55486
55616
  const ecosystems = [];
55487
55617
  const cwd = directory;
55488
- if (fs26.existsSync(path39.join(cwd, "package.json"))) {
55618
+ if (fs27.existsSync(path40.join(cwd, "package.json"))) {
55489
55619
  ecosystems.push("npm");
55490
55620
  }
55491
- if (fs26.existsSync(path39.join(cwd, "pyproject.toml")) || fs26.existsSync(path39.join(cwd, "requirements.txt"))) {
55621
+ if (fs27.existsSync(path40.join(cwd, "pyproject.toml")) || fs27.existsSync(path40.join(cwd, "requirements.txt"))) {
55492
55622
  ecosystems.push("pip");
55493
55623
  }
55494
- if (fs26.existsSync(path39.join(cwd, "Cargo.toml"))) {
55624
+ if (fs27.existsSync(path40.join(cwd, "Cargo.toml"))) {
55495
55625
  ecosystems.push("cargo");
55496
55626
  }
55497
- if (fs26.existsSync(path39.join(cwd, "go.mod"))) {
55627
+ if (fs27.existsSync(path40.join(cwd, "go.mod"))) {
55498
55628
  ecosystems.push("go");
55499
55629
  }
55500
55630
  try {
55501
- const files = fs26.readdirSync(cwd);
55631
+ const files = fs27.readdirSync(cwd);
55502
55632
  if (files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
55503
55633
  ecosystems.push("dotnet");
55504
55634
  }
55505
55635
  } catch {}
55506
- if (fs26.existsSync(path39.join(cwd, "Gemfile")) || fs26.existsSync(path39.join(cwd, "Gemfile.lock"))) {
55636
+ if (fs27.existsSync(path40.join(cwd, "Gemfile")) || fs27.existsSync(path40.join(cwd, "Gemfile.lock"))) {
55507
55637
  ecosystems.push("ruby");
55508
55638
  }
55509
- if (fs26.existsSync(path39.join(cwd, "pubspec.yaml"))) {
55639
+ if (fs27.existsSync(path40.join(cwd, "pubspec.yaml"))) {
55510
55640
  ecosystems.push("dart");
55511
55641
  }
55512
55642
  return ecosystems;
@@ -55519,7 +55649,7 @@ async function runNpmAudit(directory) {
55519
55649
  stderr: "pipe",
55520
55650
  cwd: directory
55521
55651
  });
55522
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
55652
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
55523
55653
  const result = await Promise.race([
55524
55654
  Promise.all([
55525
55655
  new Response(proc.stdout).text(),
@@ -55642,7 +55772,7 @@ async function runPipAudit(directory) {
55642
55772
  stderr: "pipe",
55643
55773
  cwd: directory
55644
55774
  });
55645
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
55775
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
55646
55776
  const result = await Promise.race([
55647
55777
  Promise.all([
55648
55778
  new Response(proc.stdout).text(),
@@ -55773,7 +55903,7 @@ async function runCargoAudit(directory) {
55773
55903
  stderr: "pipe",
55774
55904
  cwd: directory
55775
55905
  });
55776
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
55906
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
55777
55907
  const result = await Promise.race([
55778
55908
  Promise.all([
55779
55909
  new Response(proc.stdout).text(),
@@ -55900,7 +56030,7 @@ async function runGoAudit(directory) {
55900
56030
  stderr: "pipe",
55901
56031
  cwd: directory
55902
56032
  });
55903
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
56033
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
55904
56034
  const result = await Promise.race([
55905
56035
  Promise.all([
55906
56036
  new Response(proc.stdout).text(),
@@ -56036,7 +56166,7 @@ async function runDotnetAudit(directory) {
56036
56166
  stderr: "pipe",
56037
56167
  cwd: directory
56038
56168
  });
56039
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
56169
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
56040
56170
  const result = await Promise.race([
56041
56171
  Promise.all([
56042
56172
  new Response(proc.stdout).text(),
@@ -56155,7 +56285,7 @@ async function runBundleAudit(directory) {
56155
56285
  stderr: "pipe",
56156
56286
  cwd: directory
56157
56287
  });
56158
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
56288
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
56159
56289
  const result = await Promise.race([
56160
56290
  Promise.all([
56161
56291
  new Response(proc.stdout).text(),
@@ -56302,7 +56432,7 @@ async function runDartAudit(directory) {
56302
56432
  stderr: "pipe",
56303
56433
  cwd: directory
56304
56434
  });
56305
- const timeoutPromise = new Promise((resolve13) => setTimeout(() => resolve13("timeout"), AUDIT_TIMEOUT_MS));
56435
+ const timeoutPromise = new Promise((resolve14) => setTimeout(() => resolve14("timeout"), AUDIT_TIMEOUT_MS));
56306
56436
  const result = await Promise.race([
56307
56437
  Promise.all([
56308
56438
  new Response(proc.stdout).text(),
@@ -56568,8 +56698,8 @@ var SUPPORTED_PARSER_EXTENSIONS = new Set([
56568
56698
  ]);
56569
56699
  // src/tools/pre-check-batch.ts
56570
56700
  init_dist();
56571
- import * as fs29 from "fs";
56572
- import * as path42 from "path";
56701
+ import * as fs30 from "fs";
56702
+ import * as path43 from "path";
56573
56703
 
56574
56704
  // node_modules/yocto-queue/index.js
56575
56705
  class Node2 {
@@ -56660,26 +56790,26 @@ function pLimit(concurrency) {
56660
56790
  activeCount--;
56661
56791
  resumeNext();
56662
56792
  };
56663
- const run2 = async (function_, resolve13, arguments_2) => {
56793
+ const run2 = async (function_, resolve14, arguments_2) => {
56664
56794
  const result = (async () => function_(...arguments_2))();
56665
- resolve13(result);
56795
+ resolve14(result);
56666
56796
  try {
56667
56797
  await result;
56668
56798
  } catch {}
56669
56799
  next();
56670
56800
  };
56671
- const enqueue = (function_, resolve13, reject, arguments_2) => {
56801
+ const enqueue = (function_, resolve14, reject, arguments_2) => {
56672
56802
  const queueItem = { reject };
56673
56803
  new Promise((internalResolve) => {
56674
56804
  queueItem.run = internalResolve;
56675
56805
  queue.enqueue(queueItem);
56676
- }).then(run2.bind(undefined, function_, resolve13, arguments_2));
56806
+ }).then(run2.bind(undefined, function_, resolve14, arguments_2));
56677
56807
  if (activeCount < concurrency) {
56678
56808
  resumeNext();
56679
56809
  }
56680
56810
  };
56681
- const generator = (function_, ...arguments_2) => new Promise((resolve13, reject) => {
56682
- enqueue(function_, resolve13, reject, arguments_2);
56811
+ const generator = (function_, ...arguments_2) => new Promise((resolve14, reject) => {
56812
+ enqueue(function_, resolve14, reject, arguments_2);
56683
56813
  });
56684
56814
  Object.defineProperties(generator, {
56685
56815
  activeCount: {
@@ -56736,8 +56866,8 @@ init_lint();
56736
56866
  init_manager();
56737
56867
 
56738
56868
  // src/quality/metrics.ts
56739
- import * as fs27 from "fs";
56740
- import * as path40 from "path";
56869
+ import * as fs28 from "fs";
56870
+ import * as path41 from "path";
56741
56871
  var MAX_FILE_SIZE_BYTES5 = 256 * 1024;
56742
56872
  var MIN_DUPLICATION_LINES = 10;
56743
56873
  function estimateCyclomaticComplexity(content) {
@@ -56775,11 +56905,11 @@ function estimateCyclomaticComplexity(content) {
56775
56905
  }
56776
56906
  function getComplexityForFile2(filePath) {
56777
56907
  try {
56778
- const stat2 = fs27.statSync(filePath);
56908
+ const stat2 = fs28.statSync(filePath);
56779
56909
  if (stat2.size > MAX_FILE_SIZE_BYTES5) {
56780
56910
  return null;
56781
56911
  }
56782
- const content = fs27.readFileSync(filePath, "utf-8");
56912
+ const content = fs28.readFileSync(filePath, "utf-8");
56783
56913
  return estimateCyclomaticComplexity(content);
56784
56914
  } catch {
56785
56915
  return null;
@@ -56789,8 +56919,8 @@ async function computeComplexityDelta(files, workingDir) {
56789
56919
  let totalComplexity = 0;
56790
56920
  const analyzedFiles = [];
56791
56921
  for (const file3 of files) {
56792
- const fullPath = path40.isAbsolute(file3) ? file3 : path40.join(workingDir, file3);
56793
- if (!fs27.existsSync(fullPath)) {
56922
+ const fullPath = path41.isAbsolute(file3) ? file3 : path41.join(workingDir, file3);
56923
+ if (!fs28.existsSync(fullPath)) {
56794
56924
  continue;
56795
56925
  }
56796
56926
  const complexity = getComplexityForFile2(fullPath);
@@ -56911,8 +57041,8 @@ function countGoExports(content) {
56911
57041
  }
56912
57042
  function getExportCountForFile(filePath) {
56913
57043
  try {
56914
- const content = fs27.readFileSync(filePath, "utf-8");
56915
- const ext = path40.extname(filePath).toLowerCase();
57044
+ const content = fs28.readFileSync(filePath, "utf-8");
57045
+ const ext = path41.extname(filePath).toLowerCase();
56916
57046
  switch (ext) {
56917
57047
  case ".ts":
56918
57048
  case ".tsx":
@@ -56938,8 +57068,8 @@ async function computePublicApiDelta(files, workingDir) {
56938
57068
  let totalExports = 0;
56939
57069
  const analyzedFiles = [];
56940
57070
  for (const file3 of files) {
56941
- const fullPath = path40.isAbsolute(file3) ? file3 : path40.join(workingDir, file3);
56942
- if (!fs27.existsSync(fullPath)) {
57071
+ const fullPath = path41.isAbsolute(file3) ? file3 : path41.join(workingDir, file3);
57072
+ if (!fs28.existsSync(fullPath)) {
56943
57073
  continue;
56944
57074
  }
56945
57075
  const exports = getExportCountForFile(fullPath);
@@ -56972,16 +57102,16 @@ async function computeDuplicationRatio(files, workingDir) {
56972
57102
  let duplicateLines = 0;
56973
57103
  const analyzedFiles = [];
56974
57104
  for (const file3 of files) {
56975
- const fullPath = path40.isAbsolute(file3) ? file3 : path40.join(workingDir, file3);
56976
- if (!fs27.existsSync(fullPath)) {
57105
+ const fullPath = path41.isAbsolute(file3) ? file3 : path41.join(workingDir, file3);
57106
+ if (!fs28.existsSync(fullPath)) {
56977
57107
  continue;
56978
57108
  }
56979
57109
  try {
56980
- const stat2 = fs27.statSync(fullPath);
57110
+ const stat2 = fs28.statSync(fullPath);
56981
57111
  if (stat2.size > MAX_FILE_SIZE_BYTES5) {
56982
57112
  continue;
56983
57113
  }
56984
- const content = fs27.readFileSync(fullPath, "utf-8");
57114
+ const content = fs28.readFileSync(fullPath, "utf-8");
56985
57115
  const lines = content.split(`
56986
57116
  `).filter((line) => line.trim().length > 0);
56987
57117
  if (lines.length < MIN_DUPLICATION_LINES) {
@@ -57005,8 +57135,8 @@ function countCodeLines(content) {
57005
57135
  return lines.length;
57006
57136
  }
57007
57137
  function isTestFile(filePath) {
57008
- const basename8 = path40.basename(filePath);
57009
- const _ext = path40.extname(filePath).toLowerCase();
57138
+ const basename8 = path41.basename(filePath);
57139
+ const _ext = path41.extname(filePath).toLowerCase();
57010
57140
  const testPatterns = [
57011
57141
  ".test.",
57012
57142
  ".spec.",
@@ -57087,8 +57217,8 @@ function matchGlobSegment(globSegments, pathSegments) {
57087
57217
  }
57088
57218
  return gIndex === globSegments.length && pIndex === pathSegments.length;
57089
57219
  }
57090
- function matchesGlobSegment(path41, glob) {
57091
- const normalizedPath = path41.replace(/\\/g, "/");
57220
+ function matchesGlobSegment(path42, glob) {
57221
+ const normalizedPath = path42.replace(/\\/g, "/");
57092
57222
  const normalizedGlob = glob.replace(/\\/g, "/");
57093
57223
  if (normalizedPath.includes("//")) {
57094
57224
  return false;
@@ -57119,8 +57249,8 @@ function simpleGlobToRegex2(glob) {
57119
57249
  function hasGlobstar(glob) {
57120
57250
  return glob.includes("**");
57121
57251
  }
57122
- function globMatches(path41, glob) {
57123
- const normalizedPath = path41.replace(/\\/g, "/");
57252
+ function globMatches(path42, glob) {
57253
+ const normalizedPath = path42.replace(/\\/g, "/");
57124
57254
  if (!glob || glob === "") {
57125
57255
  if (normalizedPath.includes("//")) {
57126
57256
  return false;
@@ -57156,31 +57286,31 @@ function shouldExcludeFile(filePath, excludeGlobs) {
57156
57286
  async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
57157
57287
  let testLines = 0;
57158
57288
  let codeLines = 0;
57159
- const srcDir = path40.join(workingDir, "src");
57160
- if (fs27.existsSync(srcDir)) {
57289
+ const srcDir = path41.join(workingDir, "src");
57290
+ if (fs28.existsSync(srcDir)) {
57161
57291
  await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
57162
57292
  codeLines += lines;
57163
57293
  });
57164
57294
  }
57165
57295
  const possibleSrcDirs = ["lib", "app", "source", "core"];
57166
57296
  for (const dir of possibleSrcDirs) {
57167
- const dirPath = path40.join(workingDir, dir);
57168
- if (fs27.existsSync(dirPath)) {
57297
+ const dirPath = path41.join(workingDir, dir);
57298
+ if (fs28.existsSync(dirPath)) {
57169
57299
  await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
57170
57300
  codeLines += lines;
57171
57301
  });
57172
57302
  }
57173
57303
  }
57174
- const testsDir = path40.join(workingDir, "tests");
57175
- if (fs27.existsSync(testsDir)) {
57304
+ const testsDir = path41.join(workingDir, "tests");
57305
+ if (fs28.existsSync(testsDir)) {
57176
57306
  await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
57177
57307
  testLines += lines;
57178
57308
  });
57179
57309
  }
57180
57310
  const possibleTestDirs = ["test", "__tests__", "specs"];
57181
57311
  for (const dir of possibleTestDirs) {
57182
- const dirPath = path40.join(workingDir, dir);
57183
- if (fs27.existsSync(dirPath) && dirPath !== testsDir) {
57312
+ const dirPath = path41.join(workingDir, dir);
57313
+ if (fs28.existsSync(dirPath) && dirPath !== testsDir) {
57184
57314
  await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
57185
57315
  testLines += lines;
57186
57316
  });
@@ -57192,9 +57322,9 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
57192
57322
  }
57193
57323
  async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTestScan, callback) {
57194
57324
  try {
57195
- const entries = fs27.readdirSync(dirPath, { withFileTypes: true });
57325
+ const entries = fs28.readdirSync(dirPath, { withFileTypes: true });
57196
57326
  for (const entry of entries) {
57197
- const fullPath = path40.join(dirPath, entry.name);
57327
+ const fullPath = path41.join(dirPath, entry.name);
57198
57328
  if (entry.isDirectory()) {
57199
57329
  if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === ".git") {
57200
57330
  continue;
@@ -57202,7 +57332,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
57202
57332
  await scanDirectoryForLines(fullPath, includeGlobs, excludeGlobs, isTestScan, callback);
57203
57333
  } else if (entry.isFile()) {
57204
57334
  const relativePath = fullPath.replace(`${process.cwd()}/`, "");
57205
- const ext = path40.extname(entry.name).toLowerCase();
57335
+ const ext = path41.extname(entry.name).toLowerCase();
57206
57336
  const validExts = [
57207
57337
  ".ts",
57208
57338
  ".tsx",
@@ -57238,7 +57368,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
57238
57368
  continue;
57239
57369
  }
57240
57370
  try {
57241
- const content = fs27.readFileSync(fullPath, "utf-8");
57371
+ const content = fs28.readFileSync(fullPath, "utf-8");
57242
57372
  const lines = countCodeLines(content);
57243
57373
  callback(lines);
57244
57374
  } catch {}
@@ -57452,8 +57582,8 @@ async function qualityBudget(input, directory) {
57452
57582
  init_dist();
57453
57583
  init_manager();
57454
57584
  init_detector();
57455
- import * as fs28 from "fs";
57456
- import * as path41 from "path";
57585
+ import * as fs29 from "fs";
57586
+ import * as path42 from "path";
57457
57587
  import { extname as extname9 } from "path";
57458
57588
 
57459
57589
  // src/sast/rules/c.ts
@@ -58201,7 +58331,7 @@ function mapSemgrepSeverity(severity) {
58201
58331
  }
58202
58332
  }
58203
58333
  async function executeWithTimeout(command, args2, options) {
58204
- return new Promise((resolve13) => {
58334
+ return new Promise((resolve14) => {
58205
58335
  const child = spawn(command, args2, {
58206
58336
  shell: false,
58207
58337
  cwd: options.cwd
@@ -58210,7 +58340,7 @@ async function executeWithTimeout(command, args2, options) {
58210
58340
  let stderr = "";
58211
58341
  const timeout = setTimeout(() => {
58212
58342
  child.kill("SIGTERM");
58213
- resolve13({
58343
+ resolve14({
58214
58344
  stdout,
58215
58345
  stderr: "Process timed out",
58216
58346
  exitCode: 124
@@ -58224,7 +58354,7 @@ async function executeWithTimeout(command, args2, options) {
58224
58354
  });
58225
58355
  child.on("close", (code) => {
58226
58356
  clearTimeout(timeout);
58227
- resolve13({
58357
+ resolve14({
58228
58358
  stdout,
58229
58359
  stderr,
58230
58360
  exitCode: code ?? 0
@@ -58232,7 +58362,7 @@ async function executeWithTimeout(command, args2, options) {
58232
58362
  });
58233
58363
  child.on("error", (err2) => {
58234
58364
  clearTimeout(timeout);
58235
- resolve13({
58365
+ resolve14({
58236
58366
  stdout,
58237
58367
  stderr: err2.message,
58238
58368
  exitCode: 1
@@ -58320,17 +58450,17 @@ var SEVERITY_ORDER = {
58320
58450
  };
58321
58451
  function shouldSkipFile(filePath) {
58322
58452
  try {
58323
- const stats = fs28.statSync(filePath);
58453
+ const stats = fs29.statSync(filePath);
58324
58454
  if (stats.size > MAX_FILE_SIZE_BYTES6) {
58325
58455
  return { skip: true, reason: "file too large" };
58326
58456
  }
58327
58457
  if (stats.size === 0) {
58328
58458
  return { skip: true, reason: "empty file" };
58329
58459
  }
58330
- const fd = fs28.openSync(filePath, "r");
58460
+ const fd = fs29.openSync(filePath, "r");
58331
58461
  const buffer = Buffer.alloc(8192);
58332
- const bytesRead = fs28.readSync(fd, buffer, 0, 8192, 0);
58333
- fs28.closeSync(fd);
58462
+ const bytesRead = fs29.readSync(fd, buffer, 0, 8192, 0);
58463
+ fs29.closeSync(fd);
58334
58464
  if (bytesRead > 0) {
58335
58465
  let nullCount = 0;
58336
58466
  for (let i2 = 0;i2 < bytesRead; i2++) {
@@ -58369,7 +58499,7 @@ function countBySeverity(findings) {
58369
58499
  }
58370
58500
  function scanFileWithTierA(filePath, language) {
58371
58501
  try {
58372
- const content = fs28.readFileSync(filePath, "utf-8");
58502
+ const content = fs29.readFileSync(filePath, "utf-8");
58373
58503
  const findings = executeRulesSync(filePath, content, language);
58374
58504
  return findings.map((f) => ({
58375
58505
  rule_id: f.rule_id,
@@ -58416,8 +58546,8 @@ async function sastScan(input, directory, config3) {
58416
58546
  _filesSkipped++;
58417
58547
  continue;
58418
58548
  }
58419
- const resolvedPath = path41.isAbsolute(filePath) ? filePath : path41.resolve(directory, filePath);
58420
- if (!fs28.existsSync(resolvedPath)) {
58549
+ const resolvedPath = path42.isAbsolute(filePath) ? filePath : path42.resolve(directory, filePath);
58550
+ if (!fs29.existsSync(resolvedPath)) {
58421
58551
  _filesSkipped++;
58422
58552
  continue;
58423
58553
  }
@@ -58615,18 +58745,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
58615
58745
  let resolved;
58616
58746
  const isWinAbs = isWindowsAbsolutePath(inputPath);
58617
58747
  if (isWinAbs) {
58618
- resolved = path42.win32.resolve(inputPath);
58619
- } else if (path42.isAbsolute(inputPath)) {
58620
- resolved = path42.resolve(inputPath);
58748
+ resolved = path43.win32.resolve(inputPath);
58749
+ } else if (path43.isAbsolute(inputPath)) {
58750
+ resolved = path43.resolve(inputPath);
58621
58751
  } else {
58622
- resolved = path42.resolve(baseDir, inputPath);
58752
+ resolved = path43.resolve(baseDir, inputPath);
58623
58753
  }
58624
- const workspaceResolved = path42.resolve(workspaceDir);
58754
+ const workspaceResolved = path43.resolve(workspaceDir);
58625
58755
  let relative5;
58626
58756
  if (isWinAbs) {
58627
- relative5 = path42.win32.relative(workspaceResolved, resolved);
58757
+ relative5 = path43.win32.relative(workspaceResolved, resolved);
58628
58758
  } else {
58629
- relative5 = path42.relative(workspaceResolved, resolved);
58759
+ relative5 = path43.relative(workspaceResolved, resolved);
58630
58760
  }
58631
58761
  if (relative5.startsWith("..")) {
58632
58762
  return "path traversal detected";
@@ -58687,13 +58817,13 @@ async function runLintWrapped(files, directory, _config) {
58687
58817
  }
58688
58818
  async function runLintOnFiles(linter, files, workspaceDir) {
58689
58819
  const isWindows = process.platform === "win32";
58690
- const binDir = path42.join(workspaceDir, "node_modules", ".bin");
58820
+ const binDir = path43.join(workspaceDir, "node_modules", ".bin");
58691
58821
  const validatedFiles = [];
58692
58822
  for (const file3 of files) {
58693
58823
  if (typeof file3 !== "string") {
58694
58824
  continue;
58695
58825
  }
58696
- const resolvedPath = path42.resolve(file3);
58826
+ const resolvedPath = path43.resolve(file3);
58697
58827
  const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
58698
58828
  if (validationError) {
58699
58829
  continue;
@@ -58711,10 +58841,10 @@ async function runLintOnFiles(linter, files, workspaceDir) {
58711
58841
  }
58712
58842
  let command;
58713
58843
  if (linter === "biome") {
58714
- const biomeBin = isWindows ? path42.join(binDir, "biome.EXE") : path42.join(binDir, "biome");
58844
+ const biomeBin = isWindows ? path43.join(binDir, "biome.EXE") : path43.join(binDir, "biome");
58715
58845
  command = [biomeBin, "check", ...validatedFiles];
58716
58846
  } else {
58717
- const eslintBin = isWindows ? path42.join(binDir, "eslint.cmd") : path42.join(binDir, "eslint");
58847
+ const eslintBin = isWindows ? path43.join(binDir, "eslint.cmd") : path43.join(binDir, "eslint");
58718
58848
  command = [eslintBin, ...validatedFiles];
58719
58849
  }
58720
58850
  try {
@@ -58851,7 +58981,7 @@ async function runSecretscanWithFiles(files, directory) {
58851
58981
  skippedFiles++;
58852
58982
  continue;
58853
58983
  }
58854
- const resolvedPath = path42.resolve(file3);
58984
+ const resolvedPath = path43.resolve(file3);
58855
58985
  const validationError = validatePath(resolvedPath, directory, directory);
58856
58986
  if (validationError) {
58857
58987
  skippedFiles++;
@@ -58869,14 +58999,14 @@ async function runSecretscanWithFiles(files, directory) {
58869
58999
  };
58870
59000
  }
58871
59001
  for (const file3 of validatedFiles) {
58872
- const ext = path42.extname(file3).toLowerCase();
59002
+ const ext = path43.extname(file3).toLowerCase();
58873
59003
  if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
58874
59004
  skippedFiles++;
58875
59005
  continue;
58876
59006
  }
58877
59007
  let stat2;
58878
59008
  try {
58879
- stat2 = fs29.statSync(file3);
59009
+ stat2 = fs30.statSync(file3);
58880
59010
  } catch {
58881
59011
  skippedFiles++;
58882
59012
  continue;
@@ -58887,7 +59017,7 @@ async function runSecretscanWithFiles(files, directory) {
58887
59017
  }
58888
59018
  let content;
58889
59019
  try {
58890
- const buffer = fs29.readFileSync(file3);
59020
+ const buffer = fs30.readFileSync(file3);
58891
59021
  if (buffer.includes(0)) {
58892
59022
  skippedFiles++;
58893
59023
  continue;
@@ -59028,7 +59158,7 @@ async function runPreCheckBatch(input, workspaceDir) {
59028
59158
  warn(`pre_check_batch: Invalid file path: ${file3}`);
59029
59159
  continue;
59030
59160
  }
59031
- changedFiles.push(path42.resolve(directory, file3));
59161
+ changedFiles.push(path43.resolve(directory, file3));
59032
59162
  }
59033
59163
  if (changedFiles.length === 0) {
59034
59164
  warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
@@ -59179,7 +59309,7 @@ var pre_check_batch = createSwarmTool({
59179
59309
  };
59180
59310
  return JSON.stringify(errorResult, null, 2);
59181
59311
  }
59182
- const resolvedDirectory = path42.resolve(typedArgs.directory);
59312
+ const resolvedDirectory = path43.resolve(typedArgs.directory);
59183
59313
  const workspaceAnchor = resolvedDirectory;
59184
59314
  const dirError = validateDirectory3(resolvedDirectory, workspaceAnchor);
59185
59315
  if (dirError) {
@@ -59286,8 +59416,8 @@ ${paginatedContent}`;
59286
59416
  init_tool();
59287
59417
  init_manager2();
59288
59418
  init_create_tool();
59289
- import * as fs30 from "fs";
59290
- import * as path43 from "path";
59419
+ import * as fs31 from "fs";
59420
+ import * as path44 from "path";
59291
59421
  function detectPlaceholderContent(args2) {
59292
59422
  const issues = [];
59293
59423
  const placeholderPattern = /^\[\w[\w\s]*\]$/;
@@ -59391,19 +59521,19 @@ async function executeSavePlan(args2, fallbackDir) {
59391
59521
  try {
59392
59522
  await savePlan(dir, plan);
59393
59523
  try {
59394
- const markerPath = path43.join(dir, ".swarm", ".plan-write-marker");
59524
+ const markerPath = path44.join(dir, ".swarm", ".plan-write-marker");
59395
59525
  const marker = JSON.stringify({
59396
59526
  source: "save_plan",
59397
59527
  timestamp: new Date().toISOString(),
59398
59528
  phases_count: plan.phases.length,
59399
59529
  tasks_count: tasksCount
59400
59530
  });
59401
- await fs30.promises.writeFile(markerPath, marker, "utf8");
59531
+ await fs31.promises.writeFile(markerPath, marker, "utf8");
59402
59532
  } catch {}
59403
59533
  return {
59404
59534
  success: true,
59405
59535
  message: "Plan saved successfully",
59406
- plan_path: path43.join(dir, ".swarm", "plan.json"),
59536
+ plan_path: path44.join(dir, ".swarm", "plan.json"),
59407
59537
  phases_count: plan.phases.length,
59408
59538
  tasks_count: tasksCount
59409
59539
  };
@@ -59441,8 +59571,8 @@ var save_plan = createSwarmTool({
59441
59571
  // src/tools/sbom-generate.ts
59442
59572
  init_dist();
59443
59573
  init_manager();
59444
- import * as fs31 from "fs";
59445
- import * as path44 from "path";
59574
+ import * as fs32 from "fs";
59575
+ import * as path45 from "path";
59446
59576
 
59447
59577
  // src/sbom/detectors/index.ts
59448
59578
  init_utils();
@@ -60288,9 +60418,9 @@ function findManifestFiles(rootDir) {
60288
60418
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
60289
60419
  function searchDir(dir) {
60290
60420
  try {
60291
- const entries = fs31.readdirSync(dir, { withFileTypes: true });
60421
+ const entries = fs32.readdirSync(dir, { withFileTypes: true });
60292
60422
  for (const entry of entries) {
60293
- const fullPath = path44.join(dir, entry.name);
60423
+ const fullPath = path45.join(dir, entry.name);
60294
60424
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
60295
60425
  continue;
60296
60426
  }
@@ -60299,7 +60429,7 @@ function findManifestFiles(rootDir) {
60299
60429
  } else if (entry.isFile()) {
60300
60430
  for (const pattern of patterns) {
60301
60431
  if (simpleGlobToRegex(pattern).test(entry.name)) {
60302
- manifestFiles.push(path44.relative(rootDir, fullPath));
60432
+ manifestFiles.push(path45.relative(rootDir, fullPath));
60303
60433
  break;
60304
60434
  }
60305
60435
  }
@@ -60315,13 +60445,13 @@ function findManifestFilesInDirs(directories, workingDir) {
60315
60445
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
60316
60446
  for (const dir of directories) {
60317
60447
  try {
60318
- const entries = fs31.readdirSync(dir, { withFileTypes: true });
60448
+ const entries = fs32.readdirSync(dir, { withFileTypes: true });
60319
60449
  for (const entry of entries) {
60320
- const fullPath = path44.join(dir, entry.name);
60450
+ const fullPath = path45.join(dir, entry.name);
60321
60451
  if (entry.isFile()) {
60322
60452
  for (const pattern of patterns) {
60323
60453
  if (simpleGlobToRegex(pattern).test(entry.name)) {
60324
- found.push(path44.relative(workingDir, fullPath));
60454
+ found.push(path45.relative(workingDir, fullPath));
60325
60455
  break;
60326
60456
  }
60327
60457
  }
@@ -60334,11 +60464,11 @@ function findManifestFilesInDirs(directories, workingDir) {
60334
60464
  function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
60335
60465
  const dirs = new Set;
60336
60466
  for (const file3 of changedFiles) {
60337
- let currentDir = path44.dirname(file3);
60467
+ let currentDir = path45.dirname(file3);
60338
60468
  while (true) {
60339
- if (currentDir && currentDir !== "." && currentDir !== path44.sep) {
60340
- dirs.add(path44.join(workingDir, currentDir));
60341
- const parent = path44.dirname(currentDir);
60469
+ if (currentDir && currentDir !== "." && currentDir !== path45.sep) {
60470
+ dirs.add(path45.join(workingDir, currentDir));
60471
+ const parent = path45.dirname(currentDir);
60342
60472
  if (parent === currentDir)
60343
60473
  break;
60344
60474
  currentDir = parent;
@@ -60352,7 +60482,7 @@ function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
60352
60482
  }
60353
60483
  function ensureOutputDir(outputDir) {
60354
60484
  try {
60355
- fs31.mkdirSync(outputDir, { recursive: true });
60485
+ fs32.mkdirSync(outputDir, { recursive: true });
60356
60486
  } catch (error93) {
60357
60487
  if (!error93 || error93.code !== "EEXIST") {
60358
60488
  throw error93;
@@ -60422,7 +60552,7 @@ var sbom_generate = createSwarmTool({
60422
60552
  const changedFiles = obj.changed_files;
60423
60553
  const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
60424
60554
  const workingDir = directory;
60425
- const outputDir = path44.isAbsolute(relativeOutputDir) ? relativeOutputDir : path44.join(workingDir, relativeOutputDir);
60555
+ const outputDir = path45.isAbsolute(relativeOutputDir) ? relativeOutputDir : path45.join(workingDir, relativeOutputDir);
60426
60556
  let manifestFiles = [];
60427
60557
  if (scope === "all") {
60428
60558
  manifestFiles = findManifestFiles(workingDir);
@@ -60445,11 +60575,11 @@ var sbom_generate = createSwarmTool({
60445
60575
  const processedFiles = [];
60446
60576
  for (const manifestFile of manifestFiles) {
60447
60577
  try {
60448
- const fullPath = path44.isAbsolute(manifestFile) ? manifestFile : path44.join(workingDir, manifestFile);
60449
- if (!fs31.existsSync(fullPath)) {
60578
+ const fullPath = path45.isAbsolute(manifestFile) ? manifestFile : path45.join(workingDir, manifestFile);
60579
+ if (!fs32.existsSync(fullPath)) {
60450
60580
  continue;
60451
60581
  }
60452
- const content = fs31.readFileSync(fullPath, "utf-8");
60582
+ const content = fs32.readFileSync(fullPath, "utf-8");
60453
60583
  const components = detectComponents(manifestFile, content);
60454
60584
  processedFiles.push(manifestFile);
60455
60585
  if (components.length > 0) {
@@ -60462,8 +60592,8 @@ var sbom_generate = createSwarmTool({
60462
60592
  const bom = generateCycloneDX(allComponents);
60463
60593
  const bomJson = serializeCycloneDX(bom);
60464
60594
  const filename = generateSbomFilename();
60465
- const outputPath = path44.join(outputDir, filename);
60466
- fs31.writeFileSync(outputPath, bomJson, "utf-8");
60595
+ const outputPath = path45.join(outputDir, filename);
60596
+ fs32.writeFileSync(outputPath, bomJson, "utf-8");
60467
60597
  const verdict = processedFiles.length > 0 ? "pass" : "pass";
60468
60598
  try {
60469
60599
  const timestamp = new Date().toISOString();
@@ -60505,8 +60635,8 @@ var sbom_generate = createSwarmTool({
60505
60635
  // src/tools/schema-drift.ts
60506
60636
  init_dist();
60507
60637
  init_create_tool();
60508
- import * as fs32 from "fs";
60509
- import * as path45 from "path";
60638
+ import * as fs33 from "fs";
60639
+ import * as path46 from "path";
60510
60640
  var SPEC_CANDIDATES = [
60511
60641
  "openapi.json",
60512
60642
  "openapi.yaml",
@@ -60538,28 +60668,28 @@ function normalizePath2(p) {
60538
60668
  }
60539
60669
  function discoverSpecFile(cwd, specFileArg) {
60540
60670
  if (specFileArg) {
60541
- const resolvedPath = path45.resolve(cwd, specFileArg);
60542
- const normalizedCwd = cwd.endsWith(path45.sep) ? cwd : cwd + path45.sep;
60671
+ const resolvedPath = path46.resolve(cwd, specFileArg);
60672
+ const normalizedCwd = cwd.endsWith(path46.sep) ? cwd : cwd + path46.sep;
60543
60673
  if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
60544
60674
  throw new Error("Invalid spec_file: path traversal detected");
60545
60675
  }
60546
- const ext = path45.extname(resolvedPath).toLowerCase();
60676
+ const ext = path46.extname(resolvedPath).toLowerCase();
60547
60677
  if (!ALLOWED_EXTENSIONS.includes(ext)) {
60548
60678
  throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
60549
60679
  }
60550
- const stats = fs32.statSync(resolvedPath);
60680
+ const stats = fs33.statSync(resolvedPath);
60551
60681
  if (stats.size > MAX_SPEC_SIZE) {
60552
60682
  throw new Error(`Invalid spec_file: file exceeds ${MAX_SPEC_SIZE / 1024 / 1024}MB limit`);
60553
60683
  }
60554
- if (!fs32.existsSync(resolvedPath)) {
60684
+ if (!fs33.existsSync(resolvedPath)) {
60555
60685
  throw new Error(`Spec file not found: ${resolvedPath}`);
60556
60686
  }
60557
60687
  return resolvedPath;
60558
60688
  }
60559
60689
  for (const candidate of SPEC_CANDIDATES) {
60560
- const candidatePath = path45.resolve(cwd, candidate);
60561
- if (fs32.existsSync(candidatePath)) {
60562
- const stats = fs32.statSync(candidatePath);
60690
+ const candidatePath = path46.resolve(cwd, candidate);
60691
+ if (fs33.existsSync(candidatePath)) {
60692
+ const stats = fs33.statSync(candidatePath);
60563
60693
  if (stats.size <= MAX_SPEC_SIZE) {
60564
60694
  return candidatePath;
60565
60695
  }
@@ -60568,8 +60698,8 @@ function discoverSpecFile(cwd, specFileArg) {
60568
60698
  return null;
60569
60699
  }
60570
60700
  function parseSpec(specFile) {
60571
- const content = fs32.readFileSync(specFile, "utf-8");
60572
- const ext = path45.extname(specFile).toLowerCase();
60701
+ const content = fs33.readFileSync(specFile, "utf-8");
60702
+ const ext = path46.extname(specFile).toLowerCase();
60573
60703
  if (ext === ".json") {
60574
60704
  return parseJsonSpec(content);
60575
60705
  }
@@ -60640,12 +60770,12 @@ function extractRoutes(cwd) {
60640
60770
  function walkDir(dir) {
60641
60771
  let entries;
60642
60772
  try {
60643
- entries = fs32.readdirSync(dir, { withFileTypes: true });
60773
+ entries = fs33.readdirSync(dir, { withFileTypes: true });
60644
60774
  } catch {
60645
60775
  return;
60646
60776
  }
60647
60777
  for (const entry of entries) {
60648
- const fullPath = path45.join(dir, entry.name);
60778
+ const fullPath = path46.join(dir, entry.name);
60649
60779
  if (entry.isSymbolicLink()) {
60650
60780
  continue;
60651
60781
  }
@@ -60655,7 +60785,7 @@ function extractRoutes(cwd) {
60655
60785
  }
60656
60786
  walkDir(fullPath);
60657
60787
  } else if (entry.isFile()) {
60658
- const ext = path45.extname(entry.name).toLowerCase();
60788
+ const ext = path46.extname(entry.name).toLowerCase();
60659
60789
  const baseName = entry.name.toLowerCase();
60660
60790
  if (![".ts", ".js", ".mjs"].includes(ext)) {
60661
60791
  continue;
@@ -60673,7 +60803,7 @@ function extractRoutes(cwd) {
60673
60803
  }
60674
60804
  function extractRoutesFromFile(filePath) {
60675
60805
  const routes = [];
60676
- const content = fs32.readFileSync(filePath, "utf-8");
60806
+ const content = fs33.readFileSync(filePath, "utf-8");
60677
60807
  const lines = content.split(/\r?\n/);
60678
60808
  const expressRegex = /(?:app|router|server|express)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/g;
60679
60809
  const flaskRegex = /@(?:app|blueprint|bp)\.route\s*\(\s*['"]([^'"]+)['"]/g;
@@ -60824,8 +60954,8 @@ init_secretscan();
60824
60954
  // src/tools/symbols.ts
60825
60955
  init_tool();
60826
60956
  init_create_tool();
60827
- import * as fs33 from "fs";
60828
- import * as path46 from "path";
60957
+ import * as fs34 from "fs";
60958
+ import * as path47 from "path";
60829
60959
  var MAX_FILE_SIZE_BYTES7 = 1024 * 1024;
60830
60960
  var WINDOWS_RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
60831
60961
  function containsControlCharacters(str) {
@@ -60854,11 +60984,11 @@ function containsWindowsAttacks(str) {
60854
60984
  }
60855
60985
  function isPathInWorkspace(filePath, workspace) {
60856
60986
  try {
60857
- const resolvedPath = path46.resolve(workspace, filePath);
60858
- const realWorkspace = fs33.realpathSync(workspace);
60859
- const realResolvedPath = fs33.realpathSync(resolvedPath);
60860
- const relativePath = path46.relative(realWorkspace, realResolvedPath);
60861
- if (relativePath.startsWith("..") || path46.isAbsolute(relativePath)) {
60987
+ const resolvedPath = path47.resolve(workspace, filePath);
60988
+ const realWorkspace = fs34.realpathSync(workspace);
60989
+ const realResolvedPath = fs34.realpathSync(resolvedPath);
60990
+ const relativePath = path47.relative(realWorkspace, realResolvedPath);
60991
+ if (relativePath.startsWith("..") || path47.isAbsolute(relativePath)) {
60862
60992
  return false;
60863
60993
  }
60864
60994
  return true;
@@ -60870,17 +61000,17 @@ function validatePathForRead(filePath, workspace) {
60870
61000
  return isPathInWorkspace(filePath, workspace);
60871
61001
  }
60872
61002
  function extractTSSymbols(filePath, cwd) {
60873
- const fullPath = path46.join(cwd, filePath);
61003
+ const fullPath = path47.join(cwd, filePath);
60874
61004
  if (!validatePathForRead(fullPath, cwd)) {
60875
61005
  return [];
60876
61006
  }
60877
61007
  let content;
60878
61008
  try {
60879
- const stats = fs33.statSync(fullPath);
61009
+ const stats = fs34.statSync(fullPath);
60880
61010
  if (stats.size > MAX_FILE_SIZE_BYTES7) {
60881
61011
  throw new Error(`File too large: ${stats.size} bytes (max: ${MAX_FILE_SIZE_BYTES7})`);
60882
61012
  }
60883
- content = fs33.readFileSync(fullPath, "utf-8");
61013
+ content = fs34.readFileSync(fullPath, "utf-8");
60884
61014
  } catch {
60885
61015
  return [];
60886
61016
  }
@@ -61022,17 +61152,17 @@ function extractTSSymbols(filePath, cwd) {
61022
61152
  });
61023
61153
  }
61024
61154
  function extractPythonSymbols(filePath, cwd) {
61025
- const fullPath = path46.join(cwd, filePath);
61155
+ const fullPath = path47.join(cwd, filePath);
61026
61156
  if (!validatePathForRead(fullPath, cwd)) {
61027
61157
  return [];
61028
61158
  }
61029
61159
  let content;
61030
61160
  try {
61031
- const stats = fs33.statSync(fullPath);
61161
+ const stats = fs34.statSync(fullPath);
61032
61162
  if (stats.size > MAX_FILE_SIZE_BYTES7) {
61033
61163
  throw new Error(`File too large: ${stats.size} bytes (max: ${MAX_FILE_SIZE_BYTES7})`);
61034
61164
  }
61035
- content = fs33.readFileSync(fullPath, "utf-8");
61165
+ content = fs34.readFileSync(fullPath, "utf-8");
61036
61166
  } catch {
61037
61167
  return [];
61038
61168
  }
@@ -61105,7 +61235,7 @@ var symbols = createSwarmTool({
61105
61235
  }, null, 2);
61106
61236
  }
61107
61237
  const cwd = directory;
61108
- const ext = path46.extname(file3);
61238
+ const ext = path47.extname(file3);
61109
61239
  if (containsControlCharacters(file3)) {
61110
61240
  return JSON.stringify({
61111
61241
  file: file3,
@@ -61176,8 +61306,8 @@ init_test_runner();
61176
61306
  init_dist();
61177
61307
  init_utils();
61178
61308
  init_create_tool();
61179
- import * as fs34 from "fs";
61180
- import * as path47 from "path";
61309
+ import * as fs35 from "fs";
61310
+ import * as path48 from "path";
61181
61311
  var MAX_TEXT_LENGTH = 200;
61182
61312
  var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
61183
61313
  var SUPPORTED_EXTENSIONS2 = new Set([
@@ -61248,9 +61378,9 @@ function validatePathsInput(paths, cwd) {
61248
61378
  return { error: "paths contains path traversal", resolvedPath: null };
61249
61379
  }
61250
61380
  try {
61251
- const resolvedPath = path47.resolve(paths);
61252
- const normalizedCwd = path47.resolve(cwd);
61253
- const normalizedResolved = path47.resolve(resolvedPath);
61381
+ const resolvedPath = path48.resolve(paths);
61382
+ const normalizedCwd = path48.resolve(cwd);
61383
+ const normalizedResolved = path48.resolve(resolvedPath);
61254
61384
  if (!normalizedResolved.startsWith(normalizedCwd)) {
61255
61385
  return {
61256
61386
  error: "paths must be within the current working directory",
@@ -61266,13 +61396,13 @@ function validatePathsInput(paths, cwd) {
61266
61396
  }
61267
61397
  }
61268
61398
  function isSupportedExtension(filePath) {
61269
- const ext = path47.extname(filePath).toLowerCase();
61399
+ const ext = path48.extname(filePath).toLowerCase();
61270
61400
  return SUPPORTED_EXTENSIONS2.has(ext);
61271
61401
  }
61272
61402
  function findSourceFiles3(dir, files = []) {
61273
61403
  let entries;
61274
61404
  try {
61275
- entries = fs34.readdirSync(dir);
61405
+ entries = fs35.readdirSync(dir);
61276
61406
  } catch {
61277
61407
  return files;
61278
61408
  }
@@ -61281,10 +61411,10 @@ function findSourceFiles3(dir, files = []) {
61281
61411
  if (SKIP_DIRECTORIES3.has(entry)) {
61282
61412
  continue;
61283
61413
  }
61284
- const fullPath = path47.join(dir, entry);
61414
+ const fullPath = path48.join(dir, entry);
61285
61415
  let stat2;
61286
61416
  try {
61287
- stat2 = fs34.statSync(fullPath);
61417
+ stat2 = fs35.statSync(fullPath);
61288
61418
  } catch {
61289
61419
  continue;
61290
61420
  }
@@ -61377,7 +61507,7 @@ var todo_extract = createSwarmTool({
61377
61507
  return JSON.stringify(errorResult, null, 2);
61378
61508
  }
61379
61509
  const scanPath = resolvedPath;
61380
- if (!fs34.existsSync(scanPath)) {
61510
+ if (!fs35.existsSync(scanPath)) {
61381
61511
  const errorResult = {
61382
61512
  error: `path not found: ${pathsInput}`,
61383
61513
  total: 0,
@@ -61387,13 +61517,13 @@ var todo_extract = createSwarmTool({
61387
61517
  return JSON.stringify(errorResult, null, 2);
61388
61518
  }
61389
61519
  const filesToScan = [];
61390
- const stat2 = fs34.statSync(scanPath);
61520
+ const stat2 = fs35.statSync(scanPath);
61391
61521
  if (stat2.isFile()) {
61392
61522
  if (isSupportedExtension(scanPath)) {
61393
61523
  filesToScan.push(scanPath);
61394
61524
  } else {
61395
61525
  const errorResult = {
61396
- error: `unsupported file extension: ${path47.extname(scanPath)}`,
61526
+ error: `unsupported file extension: ${path48.extname(scanPath)}`,
61397
61527
  total: 0,
61398
61528
  byPriority: { high: 0, medium: 0, low: 0 },
61399
61529
  entries: []
@@ -61406,11 +61536,11 @@ var todo_extract = createSwarmTool({
61406
61536
  const allEntries = [];
61407
61537
  for (const filePath of filesToScan) {
61408
61538
  try {
61409
- const fileStat = fs34.statSync(filePath);
61539
+ const fileStat = fs35.statSync(filePath);
61410
61540
  if (fileStat.size > MAX_FILE_SIZE_BYTES8) {
61411
61541
  continue;
61412
61542
  }
61413
- const content = fs34.readFileSync(filePath, "utf-8");
61543
+ const content = fs35.readFileSync(filePath, "utf-8");
61414
61544
  const entries = parseTodoComments(content, filePath, tagsSet);
61415
61545
  allEntries.push(...entries);
61416
61546
  } catch {}
@@ -61439,8 +61569,8 @@ var todo_extract = createSwarmTool({
61439
61569
  init_tool();
61440
61570
  init_schema();
61441
61571
  init_manager2();
61442
- import * as fs35 from "fs";
61443
- import * as path48 from "path";
61572
+ import * as fs36 from "fs";
61573
+ import * as path49 from "path";
61444
61574
  init_create_tool();
61445
61575
  var VALID_STATUSES2 = [
61446
61576
  "pending",
@@ -61465,8 +61595,8 @@ function checkReviewerGate(taskId, workingDirectory) {
61465
61595
  try {
61466
61596
  const resolvedDir = workingDirectory ?? process.cwd();
61467
61597
  try {
61468
- const evidencePath = path48.join(resolvedDir, ".swarm", "evidence", `${taskId}.json`);
61469
- const raw = fs35.readFileSync(evidencePath, "utf-8");
61598
+ const evidencePath = path49.join(resolvedDir, ".swarm", "evidence", `${taskId}.json`);
61599
+ const raw = fs36.readFileSync(evidencePath, "utf-8");
61470
61600
  const evidence = JSON.parse(raw);
61471
61601
  if (evidence?.required_gates && Array.isArray(evidence.required_gates) && evidence?.gates) {
61472
61602
  const allGatesMet = evidence.required_gates.every((gate) => evidence.gates[gate] != null);
@@ -61506,8 +61636,8 @@ function checkReviewerGate(taskId, workingDirectory) {
61506
61636
  }
61507
61637
  try {
61508
61638
  const resolvedDir2 = workingDirectory ?? process.cwd();
61509
- const planPath = path48.join(resolvedDir2, ".swarm", "plan.json");
61510
- const planRaw = fs35.readFileSync(planPath, "utf-8");
61639
+ const planPath = path49.join(resolvedDir2, ".swarm", "plan.json");
61640
+ const planRaw = fs36.readFileSync(planPath, "utf-8");
61511
61641
  const plan = JSON.parse(planRaw);
61512
61642
  for (const planPhase of plan.phases ?? []) {
61513
61643
  for (const task of planPhase.tasks ?? []) {
@@ -61617,8 +61747,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
61617
61747
  };
61618
61748
  }
61619
61749
  }
61620
- normalizedDir = path48.normalize(args2.working_directory);
61621
- const pathParts = normalizedDir.split(path48.sep);
61750
+ normalizedDir = path49.normalize(args2.working_directory);
61751
+ const pathParts = normalizedDir.split(path49.sep);
61622
61752
  if (pathParts.includes("..")) {
61623
61753
  return {
61624
61754
  success: false,
@@ -61628,11 +61758,11 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
61628
61758
  ]
61629
61759
  };
61630
61760
  }
61631
- const resolvedDir = path48.resolve(normalizedDir);
61761
+ const resolvedDir = path49.resolve(normalizedDir);
61632
61762
  try {
61633
- const realPath = fs35.realpathSync(resolvedDir);
61634
- const planPath = path48.join(realPath, ".swarm", "plan.json");
61635
- if (!fs35.existsSync(planPath)) {
61763
+ const realPath = fs36.realpathSync(resolvedDir);
61764
+ const planPath = path49.join(realPath, ".swarm", "plan.json");
61765
+ if (!fs36.existsSync(planPath)) {
61636
61766
  return {
61637
61767
  success: false,
61638
61768
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -61789,7 +61919,7 @@ var OpenCodeSwarm = async (ctx) => {
61789
61919
  const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
61790
61920
  preflightTriggerManager = new PTM(automationConfig);
61791
61921
  const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
61792
- const swarmDir = path49.resolve(ctx.directory, ".swarm");
61922
+ const swarmDir = path50.resolve(ctx.directory, ".swarm");
61793
61923
  statusArtifact = new ASA(swarmDir);
61794
61924
  statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
61795
61925
  if (automationConfig.capabilities?.evidence_auto_summaries === true) {
@@ -61883,6 +62013,7 @@ var OpenCodeSwarm = async (ctx) => {
61883
62013
  name: "opencode-swarm",
61884
62014
  agent: agents,
61885
62015
  tool: {
62016
+ check_gate_status,
61886
62017
  checkpoint,
61887
62018
  complexity_hotspots,
61888
62019
  detect_domains,