opencode-swarm 7.5.1 → 7.5.2

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.
Files changed (53) hide show
  1. package/dist/agents/critic.d.ts +13 -0
  2. package/dist/background/event-bus.d.ts +8 -0
  3. package/dist/background/manager.d.ts +9 -0
  4. package/dist/build/discovery.d.ts +7 -0
  5. package/dist/cli/index.js +931 -430
  6. package/dist/commands/registry.d.ts +16 -0
  7. package/dist/config/index.d.ts +13 -0
  8. package/dist/config/schema.d.ts +10 -0
  9. package/dist/db/qa-gate-profile.d.ts +13 -0
  10. package/dist/evidence/manager.d.ts +14 -0
  11. package/dist/git/branch.d.ts +19 -0
  12. package/dist/hooks/curator-drift.d.ts +6 -0
  13. package/dist/hooks/curator.d.ts +13 -0
  14. package/dist/hooks/extractors.d.ts +11 -0
  15. package/dist/hooks/knowledge-curator.d.ts +6 -0
  16. package/dist/hooks/knowledge-migrator.d.ts +52 -1
  17. package/dist/hooks/knowledge-reader.d.ts +4 -0
  18. package/dist/hooks/knowledge-store.d.ts +21 -0
  19. package/dist/hooks/knowledge-validator.d.ts +6 -0
  20. package/dist/hooks/utils.d.ts +14 -0
  21. package/dist/index.js +958 -567
  22. package/dist/lang/detector.d.ts +4 -0
  23. package/dist/lang/index.d.ts +3 -2
  24. package/dist/lang/registry.d.ts +6 -0
  25. package/dist/mutation/engine.d.ts +5 -0
  26. package/dist/mutation/equivalence.d.ts +5 -0
  27. package/dist/mutation/gate.d.ts +8 -0
  28. package/dist/parallel/file-locks.d.ts +15 -0
  29. package/dist/plan/checkpoint.d.ts +4 -0
  30. package/dist/plan/ledger.d.ts +36 -0
  31. package/dist/plan/manager.d.ts +13 -0
  32. package/dist/sast/rules/index.d.ts +14 -0
  33. package/dist/sast/semgrep.d.ts +8 -0
  34. package/dist/services/evidence-summary-service.d.ts +51 -1
  35. package/dist/services/handoff-service.d.ts +68 -0
  36. package/dist/services/preflight-service.d.ts +67 -0
  37. package/dist/services/run-memory.d.ts +22 -0
  38. package/dist/session/snapshot-writer.d.ts +9 -0
  39. package/dist/state.d.ts +26 -0
  40. package/dist/telemetry.d.ts +12 -0
  41. package/dist/test-impact/analyzer.d.ts +20 -0
  42. package/dist/tools/co-change-analyzer.d.ts +12 -0
  43. package/dist/tools/knowledge-recall.d.ts +7 -0
  44. package/dist/tools/lint.d.ts +10 -0
  45. package/dist/tools/quality-budget.d.ts +7 -0
  46. package/dist/tools/sast-baseline.d.ts +10 -0
  47. package/dist/tools/sast-scan.d.ts +8 -0
  48. package/dist/tools/secretscan.d.ts +8 -0
  49. package/dist/tools/write-retro.d.ts +9 -0
  50. package/dist/utils/logger.d.ts +12 -0
  51. package/dist/utils/path-security.d.ts +10 -0
  52. package/dist/utils/spec-hash.d.ts +8 -0
  53. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var package_default;
33
33
  var init_package = __esm(() => {
34
34
  package_default = {
35
35
  name: "opencode-swarm",
36
- version: "7.5.1",
36
+ version: "7.5.2",
37
37
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
38
38
  main: "dist/index.js",
39
39
  types: "dist/index.d.ts",
@@ -42,7 +42,7 @@ var init_package = __esm(() => {
42
42
  },
43
43
  type: "module",
44
44
  engines: {
45
- bun: ">=1.0.0"
45
+ bun: ">=1.3.13"
46
46
  },
47
47
  license: "MIT",
48
48
  repository: {
@@ -14902,7 +14902,7 @@ function resolveGuardrailsConfig(config2, agentName) {
14902
14902
  if (!agentName) {
14903
14903
  return config2;
14904
14904
  }
14905
- const canonicalName = stripKnownSwarmPrefix(agentName);
14905
+ const canonicalName = _internals.stripKnownSwarmPrefix(agentName);
14906
14906
  const hasBuiltInProfile = canonicalName in DEFAULT_AGENT_PROFILES;
14907
14907
  const userProfile = config2.profiles?.[agentName] ?? config2.profiles?.[canonicalName];
14908
14908
  if (!hasBuiltInProfile) {
@@ -14919,10 +14919,11 @@ function resolveGuardrailsConfig(config2, agentName) {
14919
14919
  };
14920
14920
  return resolved;
14921
14921
  }
14922
- var KNOWN_SWARM_PREFIXES, SEPARATORS, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, CuratorConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, ParallelizationConfigSchema, PluginConfigSchema;
14922
+ var _internals, KNOWN_SWARM_PREFIXES, SEPARATORS, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, CuratorConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, ParallelizationConfigSchema, PluginConfigSchema;
14923
14923
  var init_schema = __esm(() => {
14924
14924
  init_zod();
14925
14925
  init_constants();
14926
+ _internals = { stripKnownSwarmPrefix, resolveGuardrailsConfig };
14926
14927
  KNOWN_SWARM_PREFIXES = [
14927
14928
  "paid",
14928
14929
  "local",
@@ -15944,6 +15945,7 @@ __export(exports_config, {
15944
15945
  loadAgentPrompt: () => loadAgentPrompt,
15945
15946
  isSubagent: () => isSubagent,
15946
15947
  isQAAgent: () => isQAAgent,
15948
+ _internals: () => _internals2,
15947
15949
  TestEvidenceSchema: () => TestEvidenceSchema,
15948
15950
  TaskStatusSchema: () => TaskStatusSchema,
15949
15951
  TaskSizeSchema: () => TaskSizeSchema,
@@ -15986,13 +15988,16 @@ __export(exports_config, {
15986
15988
  ALL_SUBAGENT_NAMES: () => ALL_SUBAGENT_NAMES,
15987
15989
  ALL_AGENT_NAMES: () => ALL_AGENT_NAMES
15988
15990
  });
15991
+ var _internals2;
15989
15992
  var init_config = __esm(() => {
15990
15993
  init_constants();
15991
15994
  init_evidence_schema();
15992
15995
  init_loader();
15996
+ init_loader();
15993
15997
  init_plan_schema();
15994
15998
  init_schema();
15995
15999
  init_spec_schema();
16000
+ _internals2 = { loadPluginConfigWithMeta };
15996
16001
  });
15997
16002
 
15998
16003
  // src/services/warning-buffer.ts
@@ -16053,6 +16058,7 @@ function error48(message, data) {
16053
16058
  console.error(`[opencode-swarm ${timestamp}] ERROR: ${message}`);
16054
16059
  }
16055
16060
  }
16061
+ var init_logger = () => {};
16056
16062
 
16057
16063
  // src/utils/regex.ts
16058
16064
  function escapeRegex2(s) {
@@ -16066,6 +16072,7 @@ function simpleGlobToRegex(pattern, flags2 = "i") {
16066
16072
  // src/utils/index.ts
16067
16073
  var init_utils = __esm(() => {
16068
16074
  init_errors3();
16075
+ init_logger();
16069
16076
  });
16070
16077
 
16071
16078
  // src/utils/bun-compat.ts
@@ -16418,7 +16425,7 @@ function composeHandlers(...fns) {
16418
16425
  }
16419
16426
  return async (input, output) => {
16420
16427
  for (const fn of fns) {
16421
- const safeFn = safeHook(fn);
16428
+ const safeFn = _internals3.safeHook(fn);
16422
16429
  await safeFn(input, output);
16423
16430
  }
16424
16431
  };
@@ -16451,7 +16458,7 @@ function validateSwarmPath(directory, filename) {
16451
16458
  }
16452
16459
  async function readSwarmFileAsync(directory, filename) {
16453
16460
  try {
16454
- const resolvedPath = validateSwarmPath(directory, filename);
16461
+ const resolvedPath = _internals3.validateSwarmPath(directory, filename);
16455
16462
  const file2 = bunFile(resolvedPath);
16456
16463
  const content = await file2.text();
16457
16464
  return content;
@@ -16465,9 +16472,11 @@ function estimateTokens(text) {
16465
16472
  }
16466
16473
  return Math.ceil(text.length * 0.33);
16467
16474
  }
16475
+ var _internals3;
16468
16476
  var init_utils2 = __esm(() => {
16469
16477
  init_utils();
16470
16478
  init_bun_compat();
16479
+ _internals3 = { safeHook, composeHandlers, validateSwarmPath, readSwarmFileAsync };
16471
16480
  });
16472
16481
 
16473
16482
  // src/telemetry.ts
@@ -16478,7 +16487,8 @@ __export(exports_telemetry, {
16478
16487
  resetTelemetryForTesting: () => resetTelemetryForTesting,
16479
16488
  initTelemetry: () => initTelemetry,
16480
16489
  emit: () => emit,
16481
- addTelemetryListener: () => addTelemetryListener
16490
+ addTelemetryListener: () => addTelemetryListener,
16491
+ _internals: () => _internals4
16482
16492
  });
16483
16493
  import * as fs3 from "node:fs";
16484
16494
  import { createWriteStream } from "node:fs";
@@ -16565,42 +16575,47 @@ function rotateTelemetryIfNeeded(maxBytes = 10 * 1024 * 1024) {
16565
16575
  }
16566
16576
  } catch {}
16567
16577
  }
16568
- var _writeStream = null, _projectDirectory = null, _listeners, _disabled = false, telemetry;
16578
+ var _writeStream = null, _projectDirectory = null, _listeners, _disabled = false, telemetry, _internals4;
16569
16579
  var init_telemetry = __esm(() => {
16570
16580
  _listeners = [];
16571
16581
  telemetry = {
16572
16582
  sessionStarted(sessionId, agentName) {
16573
- emit("session_started", { sessionId, agentName });
16583
+ _internals4.emit("session_started", { sessionId, agentName });
16574
16584
  },
16575
16585
  sessionEnded(sessionId, reason) {
16576
- emit("session_ended", { sessionId, reason });
16586
+ _internals4.emit("session_ended", { sessionId, reason });
16577
16587
  },
16578
16588
  agentActivated(sessionId, agentName, oldName) {
16579
- emit("agent_activated", { sessionId, agentName, oldName });
16589
+ _internals4.emit("agent_activated", { sessionId, agentName, oldName });
16580
16590
  },
16581
16591
  delegationBegin(sessionId, agentName, taskId) {
16582
- emit("delegation_begin", { sessionId, agentName, taskId });
16592
+ _internals4.emit("delegation_begin", { sessionId, agentName, taskId });
16583
16593
  },
16584
16594
  delegationEnd(sessionId, agentName, taskId, result) {
16585
- emit("delegation_end", { sessionId, agentName, taskId, result });
16595
+ _internals4.emit("delegation_end", { sessionId, agentName, taskId, result });
16586
16596
  },
16587
16597
  taskStateChanged(sessionId, taskId, newState, oldState) {
16588
- emit("task_state_changed", { sessionId, taskId, newState, oldState });
16598
+ _internals4.emit("task_state_changed", {
16599
+ sessionId,
16600
+ taskId,
16601
+ newState,
16602
+ oldState
16603
+ });
16589
16604
  },
16590
16605
  gatePassed(sessionId, gate, taskId) {
16591
- emit("gate_passed", { sessionId, gate, taskId });
16606
+ _internals4.emit("gate_passed", { sessionId, gate, taskId });
16592
16607
  },
16593
16608
  gateFailed(sessionId, gate, taskId, reason) {
16594
- emit("gate_failed", { sessionId, gate, taskId, reason });
16609
+ _internals4.emit("gate_failed", { sessionId, gate, taskId, reason });
16595
16610
  },
16596
16611
  phaseChanged(sessionId, oldPhase, newPhase) {
16597
- emit("phase_changed", { sessionId, oldPhase, newPhase });
16612
+ _internals4.emit("phase_changed", { sessionId, oldPhase, newPhase });
16598
16613
  },
16599
16614
  budgetUpdated(sessionId, budgetPct, agentName) {
16600
- emit("budget_updated", { sessionId, budgetPct, agentName });
16615
+ _internals4.emit("budget_updated", { sessionId, budgetPct, agentName });
16601
16616
  },
16602
16617
  modelFallback(sessionId, agentName, fromModel, toModel, reason) {
16603
- emit("model_fallback", {
16618
+ _internals4.emit("model_fallback", {
16604
16619
  sessionId,
16605
16620
  agentName,
16606
16621
  fromModel,
@@ -16609,28 +16624,33 @@ var init_telemetry = __esm(() => {
16609
16624
  });
16610
16625
  },
16611
16626
  hardLimitHit(sessionId, agentName, limitType, value) {
16612
- emit("hard_limit_hit", { sessionId, agentName, limitType, value });
16627
+ _internals4.emit("hard_limit_hit", {
16628
+ sessionId,
16629
+ agentName,
16630
+ limitType,
16631
+ value
16632
+ });
16613
16633
  },
16614
16634
  revisionLimitHit(sessionId, agentName) {
16615
- emit("revision_limit_hit", { sessionId, agentName });
16635
+ _internals4.emit("revision_limit_hit", { sessionId, agentName });
16616
16636
  },
16617
16637
  loopDetected(sessionId, agentName, loopType) {
16618
- emit("loop_detected", { sessionId, agentName, loopType });
16638
+ _internals4.emit("loop_detected", { sessionId, agentName, loopType });
16619
16639
  },
16620
16640
  scopeViolation(sessionId, agentName, file2, reason) {
16621
- emit("scope_violation", { sessionId, agentName, file: file2, reason });
16641
+ _internals4.emit("scope_violation", { sessionId, agentName, file: file2, reason });
16622
16642
  },
16623
16643
  qaSkipViolation(sessionId, agentName, skipCount) {
16624
- emit("qa_skip_violation", { sessionId, agentName, skipCount });
16644
+ _internals4.emit("qa_skip_violation", { sessionId, agentName, skipCount });
16625
16645
  },
16626
16646
  heartbeat(sessionId) {
16627
- emit("heartbeat", { sessionId });
16647
+ _internals4.emit("heartbeat", { sessionId });
16628
16648
  },
16629
16649
  turboModeChanged(sessionId, enabled, agentName) {
16630
- emit("turbo_mode_changed", { sessionId, enabled, agentName });
16650
+ _internals4.emit("turbo_mode_changed", { sessionId, enabled, agentName });
16631
16651
  },
16632
16652
  autoOversightEscalation(sessionId, reason, interactionCount, deadlockCount, phase) {
16633
- emit("auto_oversight_escalation", {
16653
+ _internals4.emit("auto_oversight_escalation", {
16634
16654
  sessionId,
16635
16655
  reason,
16636
16656
  interactionCount,
@@ -16639,7 +16659,7 @@ var init_telemetry = __esm(() => {
16639
16659
  });
16640
16660
  },
16641
16661
  environmentDetected(sessionId, hostOS, shellFamily, executionMode) {
16642
- emit("environment_detected", {
16662
+ _internals4.emit("environment_detected", {
16643
16663
  sessionId,
16644
16664
  hostOS,
16645
16665
  shellFamily,
@@ -16647,7 +16667,7 @@ var init_telemetry = __esm(() => {
16647
16667
  });
16648
16668
  },
16649
16669
  prmPatternDetected(sessionId, pattern, severity, category, stepRange) {
16650
- emit("prm_pattern_detected", {
16670
+ _internals4.emit("prm_pattern_detected", {
16651
16671
  sessionId,
16652
16672
  pattern,
16653
16673
  severity,
@@ -16656,10 +16676,14 @@ var init_telemetry = __esm(() => {
16656
16676
  });
16657
16677
  },
16658
16678
  prmCourseCorrectionInjected(sessionId, pattern, level) {
16659
- emit("prm_course_correction_injected", { sessionId, pattern, level });
16679
+ _internals4.emit("prm_course_correction_injected", {
16680
+ sessionId,
16681
+ pattern,
16682
+ level
16683
+ });
16660
16684
  },
16661
16685
  prmEscalationTriggered(sessionId, pattern, level, occurrenceCount) {
16662
- emit("prm_escalation_triggered", {
16686
+ _internals4.emit("prm_escalation_triggered", {
16663
16687
  sessionId,
16664
16688
  pattern,
16665
16689
  level,
@@ -16667,9 +16691,15 @@ var init_telemetry = __esm(() => {
16667
16691
  });
16668
16692
  },
16669
16693
  prmHardStop(sessionId, pattern, level, occurrenceCount) {
16670
- emit("prm_hard_stop", { sessionId, pattern, level, occurrenceCount });
16694
+ _internals4.emit("prm_hard_stop", {
16695
+ sessionId,
16696
+ pattern,
16697
+ level,
16698
+ occurrenceCount
16699
+ });
16671
16700
  }
16672
16701
  };
16702
+ _internals4 = { telemetry, emit };
16673
16703
  });
16674
16704
 
16675
16705
  // src/utils/spec-hash.ts
@@ -16690,7 +16720,7 @@ async function computeSpecHash(directory) {
16690
16720
  return hash2;
16691
16721
  }
16692
16722
  async function isSpecStale(directory, plan) {
16693
- const currentHash = await computeSpecHash(directory);
16723
+ const currentHash = await _internals5.computeSpecHash(directory);
16694
16724
  if (!plan.specHash) {
16695
16725
  return { stale: false };
16696
16726
  }
@@ -16710,7 +16740,13 @@ async function isSpecStale(directory, plan) {
16710
16740
  }
16711
16741
  return { stale: false };
16712
16742
  }
16713
- var init_spec_hash = () => {};
16743
+ var _internals5;
16744
+ var init_spec_hash = __esm(() => {
16745
+ _internals5 = {
16746
+ computeSpecHash,
16747
+ isSpecStale
16748
+ };
16749
+ });
16714
16750
 
16715
16751
  // src/plan/ledger.ts
16716
16752
  import * as crypto2 from "node:crypto";
@@ -17284,7 +17320,7 @@ async function loadPlan(directory) {
17284
17320
  const inSync = await isPlanMdInSync(directory, validated);
17285
17321
  if (!inSync) {
17286
17322
  try {
17287
- await regeneratePlanMarkdown(directory, validated);
17323
+ await _internals6.regeneratePlanMarkdown(directory, validated);
17288
17324
  } catch (regenError) {
17289
17325
  warn(`Failed to regenerate plan.md: ${regenError instanceof Error ? regenError.message : String(regenError)}. Proceeding with plan.json only.`);
17290
17326
  }
@@ -17417,7 +17453,7 @@ async function loadPlan(directory) {
17417
17453
  const existingMutex = recoveryMutexes.get(resolvedDir);
17418
17454
  if (existingMutex) {
17419
17455
  await existingMutex;
17420
- const postRecoveryPlan = await loadPlanJsonOnly(directory);
17456
+ const postRecoveryPlan = await _internals6.loadPlanJsonOnly(directory);
17421
17457
  if (postRecoveryPlan)
17422
17458
  return postRecoveryPlan;
17423
17459
  }
@@ -17471,7 +17507,7 @@ async function savePlan(directory, plan, options) {
17471
17507
  const validated = PlanSchema.parse(plan);
17472
17508
  if (options?.preserveCompletedStatuses !== false) {
17473
17509
  try {
17474
- const currentPlan2 = await loadPlanJsonOnly(directory);
17510
+ const currentPlan2 = await _internals6.loadPlanJsonOnly(directory);
17475
17511
  if (currentPlan2) {
17476
17512
  const completedTaskIds = new Set;
17477
17513
  for (const phase of currentPlan2.phases) {
@@ -17504,7 +17540,7 @@ async function savePlan(directory, plan, options) {
17504
17540
  phase.status = "pending";
17505
17541
  }
17506
17542
  }
17507
- const currentPlan = await loadPlanJsonOnly(directory);
17543
+ const currentPlan = await _internals6.loadPlanJsonOnly(directory);
17508
17544
  const planId = `${validated.swarm}-${validated.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
17509
17545
  const planHashForInit = computePlanHash(validated);
17510
17546
  if (!await ledgerExists(directory)) {
@@ -17620,7 +17656,7 @@ async function savePlan(directory, plan, options) {
17620
17656
  expectedHash: currentHash,
17621
17657
  planHashAfter: hashAfter,
17622
17658
  verifyValid: async () => {
17623
- const onDisk = await loadPlanJsonOnly(directory);
17659
+ const onDisk = await _internals6.loadPlanJsonOnly(directory);
17624
17660
  if (!onDisk)
17625
17661
  return true;
17626
17662
  for (const p of onDisk.phases) {
@@ -17747,7 +17783,7 @@ async function updateTaskStatus(directory, taskId, status) {
17747
17783
  };
17748
17784
  const MAX_OUTER_RETRIES = 1;
17749
17785
  for (let attempt = 0;attempt <= MAX_OUTER_RETRIES; attempt++) {
17750
- const plan = await loadPlan(directory);
17786
+ const plan = await _internals6.loadPlan(directory);
17751
17787
  if (plan === null) {
17752
17788
  throw new Error(`Plan not found in directory: ${directory}`);
17753
17789
  }
@@ -18052,7 +18088,7 @@ function migrateLegacyPlan(planContent, swarmId) {
18052
18088
  };
18053
18089
  return plan;
18054
18090
  }
18055
- var PlanConcurrentModificationError, startupLedgerCheckedWorkspaces, recoveryMutexes, CAS_BACKOFF_START_MS = 5, CAS_BACKOFF_CAP_MS = 250, CAS_BACKOFF_JITTER = 0.25, CAS_MAX_RETRIES = 3;
18091
+ var PlanConcurrentModificationError, startupLedgerCheckedWorkspaces, recoveryMutexes, _internals6, CAS_BACKOFF_START_MS = 5, CAS_BACKOFF_CAP_MS = 250, CAS_BACKOFF_JITTER = 0.25, CAS_MAX_RETRIES = 3;
18056
18092
  var init_manager = __esm(() => {
18057
18093
  init_plan_schema();
18058
18094
  init_utils2();
@@ -18069,6 +18105,11 @@ var init_manager = __esm(() => {
18069
18105
  };
18070
18106
  startupLedgerCheckedWorkspaces = new Set;
18071
18107
  recoveryMutexes = new Map;
18108
+ _internals6 = {
18109
+ loadPlan,
18110
+ loadPlanJsonOnly,
18111
+ regeneratePlanMarkdown
18112
+ };
18072
18113
  });
18073
18114
 
18074
18115
  // src/commands/acknowledge-spec-drift.ts
@@ -20034,7 +20075,7 @@ async function loadEvidence(directory, taskId) {
20034
20075
  return { status: "invalid_schema", errors: ["Invalid JSON"] };
20035
20076
  }
20036
20077
  if (isFlatRetrospective(parsed)) {
20037
- const wrappedBundle = wrapFlatRetrospective(parsed, sanitizedTaskId);
20078
+ const wrappedBundle = _internals7.wrapFlatRetrospective(parsed, sanitizedTaskId);
20038
20079
  try {
20039
20080
  const validated = EvidenceBundleSchema.parse(wrappedBundle);
20040
20081
  try {
@@ -20130,14 +20171,14 @@ async function checkRequirementCoverage(phase, directory) {
20130
20171
  }
20131
20172
  }
20132
20173
  async function archiveEvidence(directory, maxAgeDays, maxBundles) {
20133
- const taskIds = await listEvidenceTaskIds(directory);
20174
+ const taskIds = await _internals7.listEvidenceTaskIds(directory);
20134
20175
  const cutoffDate = new Date;
20135
20176
  cutoffDate.setDate(cutoffDate.getDate() - maxAgeDays);
20136
20177
  const cutoffIso = cutoffDate.toISOString();
20137
20178
  const archived = [];
20138
20179
  const remainingBundles = [];
20139
20180
  for (const taskId of taskIds) {
20140
- const result = await loadEvidence(directory, taskId);
20181
+ const result = await _internals7.loadEvidence(directory, taskId);
20141
20182
  if (result.status !== "found") {
20142
20183
  continue;
20143
20184
  }
@@ -20165,7 +20206,7 @@ async function archiveEvidence(directory, maxAgeDays, maxBundles) {
20165
20206
  }
20166
20207
  return archived;
20167
20208
  }
20168
- var VALID_EVIDENCE_TYPES, sanitizeTaskId2, LEGACY_TASK_COMPLEXITY_MAP;
20209
+ var VALID_EVIDENCE_TYPES, sanitizeTaskId2, LEGACY_TASK_COMPLEXITY_MAP, _internals7;
20169
20210
  var init_manager2 = __esm(() => {
20170
20211
  init_zod();
20171
20212
  init_evidence_schema();
@@ -20195,6 +20236,11 @@ var init_manager2 = __esm(() => {
20195
20236
  medium: "moderate",
20196
20237
  high: "complex"
20197
20238
  };
20239
+ _internals7 = {
20240
+ wrapFlatRetrospective,
20241
+ loadEvidence,
20242
+ listEvidenceTaskIds
20243
+ };
20198
20244
  });
20199
20245
 
20200
20246
  // src/commands/archive.ts
@@ -20394,7 +20440,7 @@ function getProfile(directory, planId) {
20394
20440
  return row ? rowToProfile(row) : null;
20395
20441
  }
20396
20442
  function getOrCreateProfile(directory, planId, projectType) {
20397
- const existing = getProfile(directory, planId);
20443
+ const existing = _internals8.getProfile(directory, planId);
20398
20444
  if (existing)
20399
20445
  return existing;
20400
20446
  const db = getProjectDb(directory);
@@ -20410,14 +20456,14 @@ function getOrCreateProfile(directory, planId, projectType) {
20410
20456
  throw err2;
20411
20457
  }
20412
20458
  }
20413
- const after = getProfile(directory, planId);
20459
+ const after = _internals8.getProfile(directory, planId);
20414
20460
  if (!after) {
20415
20461
  throw new Error(`Failed to create or load QA gate profile for plan_id=${planId}`);
20416
20462
  }
20417
20463
  return after;
20418
20464
  }
20419
20465
  function setGates(directory, planId, gates) {
20420
- const current = getProfile(directory, planId);
20466
+ const current = _internals8.getProfile(directory, planId);
20421
20467
  if (!current) {
20422
20468
  throw new Error(`No QA gate profile found for plan_id=${planId} — call getOrCreateProfile first`);
20423
20469
  }
@@ -20441,14 +20487,14 @@ function setGates(directory, planId, gates) {
20441
20487
  JSON.stringify(merged),
20442
20488
  planId
20443
20489
  ]);
20444
- const updated = getProfile(directory, planId);
20490
+ const updated = _internals8.getProfile(directory, planId);
20445
20491
  if (!updated) {
20446
20492
  throw new Error(`Failed to re-read QA gate profile after update for plan_id=${planId}`);
20447
20493
  }
20448
20494
  return updated;
20449
20495
  }
20450
20496
  function lockProfile(directory, planId, snapshotSeq) {
20451
- const current = getProfile(directory, planId);
20497
+ const current = _internals8.getProfile(directory, planId);
20452
20498
  if (!current) {
20453
20499
  throw new Error(`No QA gate profile found for plan_id=${planId} — cannot lock`);
20454
20500
  }
@@ -20457,7 +20503,7 @@ function lockProfile(directory, planId, snapshotSeq) {
20457
20503
  }
20458
20504
  const db = getProjectDb(directory);
20459
20505
  db.run("UPDATE qa_gate_profile SET locked_at = datetime('now'), locked_by_snapshot_seq = ? WHERE plan_id = ?", [snapshotSeq, planId]);
20460
- const locked = getProfile(directory, planId);
20506
+ const locked = _internals8.getProfile(directory, planId);
20461
20507
  if (!locked) {
20462
20508
  throw new Error(`Failed to re-read locked QA gate profile for plan_id=${planId}`);
20463
20509
  }
@@ -20479,9 +20525,16 @@ function getEffectiveGates(profile, sessionOverrides) {
20479
20525
  }
20480
20526
  return merged;
20481
20527
  }
20482
- var DEFAULT_QA_GATES;
20528
+ var _internals8, DEFAULT_QA_GATES;
20483
20529
  var init_qa_gate_profile = __esm(() => {
20484
20530
  init_project_db();
20531
+ _internals8 = {
20532
+ getProfile,
20533
+ getOrCreateProfile,
20534
+ setGates,
20535
+ getEffectiveGates,
20536
+ computeProfileHash
20537
+ };
20485
20538
  DEFAULT_QA_GATES = {
20486
20539
  reviewer: true,
20487
20540
  test_engineer: true,
@@ -23302,6 +23355,7 @@ No plan content available. Start by creating a .swarm/plan.md file.
23302
23355
  }
23303
23356
  return output;
23304
23357
  }
23358
+ var init_extractors = () => {};
23305
23359
 
23306
23360
  // src/hooks/loop-detector.ts
23307
23361
  function hashDelegation(toolName, args2) {
@@ -25286,8 +25340,10 @@ var init_guardrails = __esm(() => {
25286
25340
  init_telemetry();
25287
25341
  init_utils();
25288
25342
  init_bun_compat();
25343
+ init_logger();
25289
25344
  init_conflict_resolution();
25290
25345
  init_delegation_gate();
25346
+ init_extractors();
25291
25347
  init_loop_detector();
25292
25348
  init_model_limits();
25293
25349
  init_normalize_tool_name();
@@ -26262,6 +26318,7 @@ var init_delegation_gate = __esm(() => {
26262
26318
  init_schema();
26263
26319
  init_state();
26264
26320
  init_telemetry();
26321
+ init_logger();
26265
26322
  init_guardrails();
26266
26323
  init_normalize_tool_name();
26267
26324
  init_utils2();
@@ -26319,6 +26376,7 @@ __export(exports_state, {
26319
26376
  advanceTaskStateAndPersist: () => advanceTaskStateAndPersist,
26320
26377
  advanceTaskState: () => advanceTaskState,
26321
26378
  _resetCouncilDisagreementWarnings: () => _resetCouncilDisagreementWarnings,
26379
+ _internals: () => _internals9,
26322
26380
  AgentRunContext: () => AgentRunContext
26323
26381
  });
26324
26382
  import * as fs10 from "node:fs/promises";
@@ -26412,10 +26470,10 @@ function startAgentSession(sessionId, agentName, staleDurationMs = 7200000, dire
26412
26470
  swarmState.agentSessions.set(sessionId, sessionState);
26413
26471
  telemetry.sessionStarted(sessionId, agentName);
26414
26472
  swarmState.activeAgent.set(sessionId, agentName);
26415
- applyRehydrationCache(sessionState);
26473
+ _internals9.applyRehydrationCache(sessionState);
26416
26474
  if (directory) {
26417
26475
  let rehydrationPromise;
26418
- rehydrationPromise = rehydrateSessionFromDisk(directory, sessionState).catch((err2) => {
26476
+ rehydrationPromise = _internals9.rehydrateSessionFromDisk(directory, sessionState).catch((err2) => {
26419
26477
  console.warn("[state] Rehydration failed:", err2 instanceof Error ? err2.message : String(err2));
26420
26478
  }).finally(() => {
26421
26479
  swarmState.pendingRehydrations.delete(rehydrationPromise);
@@ -26570,7 +26628,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
26570
26628
  session.lastToolCallTime = now;
26571
26629
  return session;
26572
26630
  }
26573
- startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
26631
+ _internals9.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
26574
26632
  session = swarmState.agentSessions.get(sessionId);
26575
26633
  if (!session) {
26576
26634
  throw new Error(`Failed to create guardrail session for ${sessionId}`);
@@ -26927,8 +26985,8 @@ function applyRehydrationCache(session) {
26927
26985
  }
26928
26986
  }
26929
26987
  async function rehydrateSessionFromDisk(directory, session) {
26930
- await buildRehydrationCache(directory);
26931
- applyRehydrationCache(session);
26988
+ await _internals9.buildRehydrationCache(directory);
26989
+ _internals9.applyRehydrationCache(session);
26932
26990
  }
26933
26991
  function hasActiveTurboMode(sessionID) {
26934
26992
  if (sessionID) {
@@ -26971,7 +27029,7 @@ function ensureSessionEnvironment(sessionId) {
26971
27029
  }).catch(() => {});
26972
27030
  return profile;
26973
27031
  }
26974
- var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState;
27032
+ var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState, _internals9;
26975
27033
  var init_state = __esm(() => {
26976
27034
  init_constants();
26977
27035
  init_plan_schema();
@@ -26999,6 +27057,24 @@ var init_state = __esm(() => {
26999
27057
  fullAutoEnabledInConfig: false,
27000
27058
  environmentProfiles: defaultRunContext.environmentProfiles
27001
27059
  };
27060
+ _internals9 = {
27061
+ swarmState,
27062
+ resetSwarmState,
27063
+ ensureAgentSession,
27064
+ startAgentSession,
27065
+ getAgentSession,
27066
+ beginInvocation,
27067
+ getActiveWindow,
27068
+ advanceTaskState,
27069
+ getTaskState,
27070
+ hasActiveFullAuto,
27071
+ hasActiveTurboMode,
27072
+ buildRehydrationCache,
27073
+ applyRehydrationCache,
27074
+ rehydrateSessionFromDisk,
27075
+ isCouncilGateActive,
27076
+ defaultRunContext
27077
+ };
27002
27078
  });
27003
27079
 
27004
27080
  // src/commands/benchmark.ts
@@ -40536,6 +40612,19 @@ function getCurrentBranch(cwd) {
40536
40612
  const output = gitExec2(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
40537
40613
  return output.trim();
40538
40614
  }
40615
+ function getDefaultBaseBranch(cwd) {
40616
+ try {
40617
+ gitExec2(["rev-parse", "--verify", "origin/main"], cwd);
40618
+ return "origin/main";
40619
+ } catch {
40620
+ try {
40621
+ gitExec2(["rev-parse", "--verify", "origin/master"], cwd);
40622
+ return "origin/master";
40623
+ } catch {
40624
+ return "origin/main";
40625
+ }
40626
+ }
40627
+ }
40539
40628
  function hasUncommittedChanges(cwd) {
40540
40629
  const status = gitExec2(["status", "--porcelain"], cwd);
40541
40630
  return status.trim().length > 0;
@@ -40571,7 +40660,7 @@ function resetToRemoteBranch(cwd, options) {
40571
40660
  const prunedBranches = [];
40572
40661
  try {
40573
40662
  const currentBranch = getCurrentBranch(cwd);
40574
- const defaultRemoteBranch = detectDefaultRemoteBranch(cwd);
40663
+ const defaultRemoteBranch = _internals10.detectDefaultRemoteBranch(cwd);
40575
40664
  if (!defaultRemoteBranch) {
40576
40665
  return {
40577
40666
  success: false,
@@ -40750,8 +40839,16 @@ function resetToRemoteBranch(cwd, options) {
40750
40839
  };
40751
40840
  }
40752
40841
  }
40753
- var GIT_TIMEOUT_MS2 = 30000;
40754
- var init_branch = () => {};
40842
+ var GIT_TIMEOUT_MS2 = 30000, _internals10;
40843
+ var init_branch = __esm(() => {
40844
+ init_logger();
40845
+ _internals10 = {
40846
+ gitExec: gitExec2,
40847
+ detectDefaultRemoteBranch,
40848
+ getDefaultBaseBranch,
40849
+ resetToRemoteBranch
40850
+ };
40851
+ });
40755
40852
 
40756
40853
  // src/hooks/knowledge-store.ts
40757
40854
  import { existsSync as existsSync9 } from "node:fs";
@@ -41233,6 +41330,7 @@ async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
41233
41330
  }
41234
41331
  var JACCARD_THRESHOLD = 0.6, HIVE_TIER_BOOST = 0.05, SAME_PROJECT_PENALTY = -0.05;
41235
41332
  var init_knowledge_reader = __esm(() => {
41333
+ init_logger();
41236
41334
  init_knowledge_store();
41237
41335
  });
41238
41336
 
@@ -41489,6 +41587,7 @@ async function restoreEntry(directory, entryId) {
41489
41587
  }
41490
41588
  var import_proper_lockfile4, DANGEROUS_COMMAND_PATTERNS, SECURITY_DEGRADING_PATTERNS, INVISIBLE_FORMAT_CHARS, INJECTION_PATTERNS, VALID_CATEGORIES, TECH_REFERENCE_WORDS, ACTION_VERB_WORDS, NEGATION_PAIRS;
41491
41589
  var init_knowledge_validator = __esm(() => {
41590
+ init_logger();
41492
41591
  init_knowledge_store();
41493
41592
  import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
41494
41593
  DANGEROUS_COMMAND_PATTERNS = [
@@ -41805,7 +41904,7 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
41805
41904
  existingEntries.push(entry);
41806
41905
  }
41807
41906
  await enforceKnowledgeCap(knowledgePath, config3.swarm_max_entries);
41808
- await runAutoPromotion(directory, config3);
41907
+ await _internals11.runAutoPromotion(directory, config3);
41809
41908
  return { stored, skipped, rejected };
41810
41909
  }
41811
41910
  async function runAutoPromotion(directory, config3) {
@@ -41886,7 +41985,7 @@ function createKnowledgeCuratorHook(directory, config3) {
41886
41985
  });
41887
41986
  const projectName2 = evidenceData.project_name ?? "unknown";
41888
41987
  const phaseNumber2 = typeof evidenceData.phase_number === "number" ? evidenceData.phase_number : 1;
41889
- await curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
41988
+ await _internals11.curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
41890
41989
  await updateRetrievalOutcome(directory, `Phase ${phaseNumber2}`, true);
41891
41990
  return;
41892
41991
  }
@@ -41909,18 +42008,24 @@ function createKnowledgeCuratorHook(directory, config3) {
41909
42008
  const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
41910
42009
  const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
41911
42010
  const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
41912
- await curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
42011
+ await _internals11.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
41913
42012
  await updateRetrievalOutcome(directory, `Phase ${phaseNumber}`, true);
41914
42013
  };
41915
42014
  return safeHook(handler);
41916
42015
  }
41917
- var seenRetroSections;
42016
+ var seenRetroSections, _internals11;
41918
42017
  var init_knowledge_curator = __esm(() => {
41919
42018
  init_knowledge_reader();
41920
42019
  init_knowledge_store();
41921
42020
  init_knowledge_validator();
41922
42021
  init_utils2();
41923
42022
  seenRetroSections = new Map;
42023
+ _internals11 = {
42024
+ isWriteToEvidenceFile,
42025
+ curateAndStoreSwarm,
42026
+ runAutoPromotion,
42027
+ createKnowledgeCuratorHook
42028
+ };
41924
42029
  });
41925
42030
 
41926
42031
  // src/session/snapshot-writer.ts
@@ -42028,21 +42133,26 @@ async function writeSnapshot(directory, state) {
42028
42133
  }
42029
42134
  function createSnapshotWriterHook(directory) {
42030
42135
  return (_input, _output) => {
42031
- _writeInFlight = _writeInFlight.then(() => writeSnapshot(directory, swarmState), () => writeSnapshot(directory, swarmState));
42136
+ _writeInFlight = _writeInFlight.then(() => _internals12.writeSnapshot(directory, swarmState), () => _internals12.writeSnapshot(directory, swarmState));
42032
42137
  return _writeInFlight;
42033
42138
  };
42034
42139
  }
42035
42140
  async function flushPendingSnapshot(directory) {
42036
- _writeInFlight = _writeInFlight.then(() => writeSnapshot(directory, swarmState), () => writeSnapshot(directory, swarmState));
42141
+ _writeInFlight = _writeInFlight.then(() => _internals12.writeSnapshot(directory, swarmState), () => _internals12.writeSnapshot(directory, swarmState));
42037
42142
  await _writeInFlight;
42038
42143
  }
42039
- var _writeInFlight;
42144
+ var _writeInFlight, _internals12;
42040
42145
  var init_snapshot_writer = __esm(() => {
42041
42146
  init_utils2();
42042
42147
  init_state();
42043
42148
  init_utils();
42044
42149
  init_bun_compat();
42045
42150
  _writeInFlight = Promise.resolve();
42151
+ _internals12 = {
42152
+ writeSnapshot,
42153
+ createSnapshotWriterHook,
42154
+ flushPendingSnapshot
42155
+ };
42046
42156
  });
42047
42157
 
42048
42158
  // src/tools/write-retro.ts
@@ -42346,7 +42456,7 @@ async function executeWriteRetro(args2, directory) {
42346
42456
  }, null, 2);
42347
42457
  }
42348
42458
  }
42349
- var write_retro;
42459
+ var write_retro, _internals13;
42350
42460
  var init_write_retro = __esm(() => {
42351
42461
  init_zod();
42352
42462
  init_evidence_schema();
@@ -42393,12 +42503,16 @@ var init_write_retro = __esm(() => {
42393
42503
  task_id: args2.task_id !== undefined ? String(args2.task_id) : undefined,
42394
42504
  metadata: args2.metadata
42395
42505
  };
42396
- return await executeWriteRetro(writeRetroArgs, directory);
42506
+ return await _internals13.executeWriteRetro(writeRetroArgs, directory);
42397
42507
  } catch {
42398
42508
  return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
42399
42509
  }
42400
42510
  }
42401
42511
  });
42512
+ _internals13 = {
42513
+ executeWriteRetro,
42514
+ write_retro
42515
+ };
42402
42516
  });
42403
42517
 
42404
42518
  // src/commands/close.ts
@@ -43450,8 +43564,8 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43450
43564
  const observations = [];
43451
43565
  const timestamp = new Date().toISOString();
43452
43566
  for (const agent of requiredAgents) {
43453
- const normalizedAgent = normalizeAgentName(agent);
43454
- const isDispatched = agentsDispatched.some((a) => normalizeAgentName(a) === normalizedAgent);
43567
+ const normalizedAgent = _internals14.normalizeAgentName(agent);
43568
+ const isDispatched = agentsDispatched.some((a) => _internals14.normalizeAgentName(a) === normalizedAgent);
43455
43569
  if (!isDispatched) {
43456
43570
  observations.push({
43457
43571
  phase,
@@ -43470,7 +43584,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43470
43584
  if (e.type === "agent.delegation") {
43471
43585
  const agent = e.agent;
43472
43586
  if (agent && typeof agent === "string") {
43473
- const normalized = normalizeAgentName(agent);
43587
+ const normalized = _internals14.normalizeAgentName(agent);
43474
43588
  if (normalized === "coder") {
43475
43589
  coderDelegations.push({ event: e, index: i2 });
43476
43590
  } else if (normalized === "reviewer") {
@@ -43527,7 +43641,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43527
43641
  if (e.type === "agent.delegation" && e.agent) {
43528
43642
  const agent = e.agent;
43529
43643
  if (agent && typeof agent === "string") {
43530
- const normalized = normalizeAgentName(agent);
43644
+ const normalized = _internals14.normalizeAgentName(agent);
43531
43645
  if (normalized === "sme") {
43532
43646
  smeDelegations.push({ event: e, index: i2 });
43533
43647
  }
@@ -43551,7 +43665,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43551
43665
  }
43552
43666
  async function runCuratorInit(directory, config3, llmDelegate) {
43553
43667
  try {
43554
- const priorSummary = await readCuratorSummary(directory);
43668
+ const priorSummary = await _internals14.readCuratorSummary(directory);
43555
43669
  const knowledgePath = resolveSwarmKnowledgePath(directory);
43556
43670
  const allEntries = await readKnowledge(knowledgePath);
43557
43671
  const highConfidenceEntries = allEntries.filter((e) => typeof e.confidence === "number" && e.confidence >= config3.min_knowledge_confidence);
@@ -43670,7 +43784,7 @@ Could not load prior session context.`,
43670
43784
  }
43671
43785
  async function runCuratorPhase(directory, phase, agentsDispatched, config3, _knowledgeConfig, llmDelegate) {
43672
43786
  try {
43673
- const priorSummary = await readCuratorSummary(directory);
43787
+ const priorSummary = await _internals14.readCuratorSummary(directory);
43674
43788
  if (priorSummary?.phase_digests.some((d) => d.phase === phase)) {
43675
43789
  const existingDigest = priorSummary.phase_digests.find((d) => d.phase === phase);
43676
43790
  return {
@@ -43682,10 +43796,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43682
43796
  };
43683
43797
  }
43684
43798
  const eventsJsonlContent = await readSwarmFileAsync(directory, "events.jsonl");
43685
- const phaseEvents = eventsJsonlContent ? filterPhaseEvents(eventsJsonlContent, phase) : [];
43799
+ const phaseEvents = eventsJsonlContent ? _internals14.filterPhaseEvents(eventsJsonlContent, phase) : [];
43686
43800
  const contextMd = await readSwarmFileAsync(directory, "context.md");
43687
43801
  const requiredAgents = ["reviewer", "test_engineer"];
43688
- const complianceObservations = checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
43802
+ const complianceObservations = _internals14.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
43689
43803
  const plan = await loadPlanJsonOnly(directory);
43690
43804
  const phaseData = plan?.phases.find((p) => p.id === phase);
43691
43805
  const tasksCompleted = phaseData ? phaseData.tasks.filter((t) => t.status === "completed").length : 0;
@@ -43708,7 +43822,9 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43708
43822
  phase,
43709
43823
  timestamp: new Date().toISOString(),
43710
43824
  summary: `Phase ${phase} completed. ${tasksCompleted}/${tasksTotal} tasks completed. ${complianceObservations.length} compliance observations.`,
43711
- agents_used: [...new Set(agentsDispatched.map(normalizeAgentName))],
43825
+ agents_used: [
43826
+ ...new Set(agentsDispatched.map((a) => _internals14.normalizeAgentName(a)))
43827
+ ],
43712
43828
  tasks_completed: tasksCompleted,
43713
43829
  tasks_total: tasksTotal,
43714
43830
  key_decisions: keyDecisions.slice(0, 5),
@@ -43753,7 +43869,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43753
43869
  clearTimeout(timer);
43754
43870
  }
43755
43871
  if (llmOutput?.trim()) {
43756
- knowledgeRecommendations = parseKnowledgeRecommendations(llmOutput);
43872
+ knowledgeRecommendations = _internals14.parseKnowledgeRecommendations(llmOutput);
43757
43873
  }
43758
43874
  getGlobalEventBus().publish("curator.phase.llm_completed", {
43759
43875
  phase,
@@ -43799,7 +43915,7 @@ ${phaseDigest.summary}`,
43799
43915
  knowledge_recommendations: knowledgeRecommendations
43800
43916
  };
43801
43917
  }
43802
- await writeCuratorSummary(directory, updatedSummary);
43918
+ await _internals14.writeCuratorSummary(directory, updatedSummary);
43803
43919
  const eventsPath = path21.join(directory, ".swarm", "events.jsonl");
43804
43920
  for (const obs of complianceObservations) {
43805
43921
  await appendKnowledge(eventsPath, {
@@ -43985,14 +44101,23 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
43985
44101
  }
43986
44102
  return { applied, skipped };
43987
44103
  }
43988
- var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000;
44104
+ var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000, _internals14;
43989
44105
  var init_curator = __esm(() => {
43990
44106
  init_event_bus();
43991
44107
  init_manager();
43992
44108
  init_bun_compat();
44109
+ init_logger();
43993
44110
  init_knowledge_store();
43994
44111
  init_knowledge_validator();
43995
44112
  init_utils2();
44113
+ _internals14 = {
44114
+ parseKnowledgeRecommendations,
44115
+ readCuratorSummary,
44116
+ writeCuratorSummary,
44117
+ filterPhaseEvents,
44118
+ checkPhaseCompliance,
44119
+ normalizeAgentName
44120
+ };
43996
44121
  });
43997
44122
 
43998
44123
  // src/hooks/hive-promoter.ts
@@ -44300,7 +44425,8 @@ __export(exports_co_change_analyzer, {
44300
44425
  detectDarkMatter: () => detectDarkMatter,
44301
44426
  darkMatterToKnowledgeEntries: () => darkMatterToKnowledgeEntries,
44302
44427
  co_change_analyzer: () => co_change_analyzer,
44303
- buildCoChangeMatrix: () => buildCoChangeMatrix
44428
+ buildCoChangeMatrix: () => buildCoChangeMatrix,
44429
+ _internals: () => _internals15
44304
44430
  });
44305
44431
  import * as child_process3 from "node:child_process";
44306
44432
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -44523,9 +44649,9 @@ async function detectDarkMatter(directory, options) {
44523
44649
  } catch {
44524
44650
  return [];
44525
44651
  }
44526
- const commitMap = await parseGitLog(directory, maxCommitsToAnalyze);
44527
- const matrix = buildCoChangeMatrix(commitMap);
44528
- const staticEdges = await getStaticEdges(directory);
44652
+ const commitMap = await _internals15.parseGitLog(directory, maxCommitsToAnalyze);
44653
+ const matrix = _internals15.buildCoChangeMatrix(commitMap);
44654
+ const staticEdges = await _internals15.getStaticEdges(directory);
44529
44655
  const results = [];
44530
44656
  for (const entry of matrix.values()) {
44531
44657
  const key = `${entry.fileA}::${entry.fileB}`;
@@ -44605,7 +44731,7 @@ ${rows}
44605
44731
  These pairs likely share an architectural concern invisible to static analysis.
44606
44732
  Consider adding explicit documentation or extracting the shared concern.`;
44607
44733
  }
44608
- var co_change_analyzer;
44734
+ var co_change_analyzer, _internals15;
44609
44735
  var init_co_change_analyzer = __esm(() => {
44610
44736
  init_zod();
44611
44737
  init_create_tool();
@@ -44637,10 +44763,18 @@ var init_co_change_analyzer = __esm(() => {
44637
44763
  npmiThreshold,
44638
44764
  maxCommitsToAnalyze
44639
44765
  };
44640
- const pairs = await detectDarkMatter(directory, options);
44641
- return formatDarkMatterOutput(pairs);
44766
+ const pairs = await _internals15.detectDarkMatter(directory, options);
44767
+ return _internals15.formatDarkMatterOutput(pairs);
44642
44768
  }
44643
44769
  });
44770
+ _internals15 = {
44771
+ parseGitLog,
44772
+ buildCoChangeMatrix,
44773
+ getStaticEdges,
44774
+ detectDarkMatter,
44775
+ darkMatterToKnowledgeEntries,
44776
+ formatDarkMatterOutput
44777
+ };
44644
44778
  });
44645
44779
 
44646
44780
  // src/commands/dark-matter.ts
@@ -47454,7 +47588,7 @@ async function discoverBuildCommands(workingDir, options) {
47454
47588
  const scope = options?.scope ?? "all";
47455
47589
  const changedFiles = options?.changedFiles ?? [];
47456
47590
  const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
47457
- const profileResult = await discoverBuildCommandsFromProfiles(workingDir);
47591
+ const profileResult = await _internals16.discoverBuildCommandsFromProfiles(workingDir);
47458
47592
  const profileCommands = profileResult.commands;
47459
47593
  const profileSkipped = profileResult.skipped;
47460
47594
  const coveredEcosystems = new Set;
@@ -47511,7 +47645,13 @@ async function discoverBuildCommands(workingDir, options) {
47511
47645
  commands.sort((a, b) => a.priority - b.priority);
47512
47646
  return { commands, skipped };
47513
47647
  }
47514
- var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, build_discovery;
47648
+ function clearToolchainCache() {
47649
+ toolchainCache.clear();
47650
+ }
47651
+ function getEcosystems() {
47652
+ return ECOSYSTEMS.map((e) => e.ecosystem);
47653
+ }
47654
+ var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, _internals16, build_discovery;
47515
47655
  var init_discovery = __esm(() => {
47516
47656
  init_dist();
47517
47657
  init_detector();
@@ -47629,6 +47769,13 @@ var init_discovery = __esm(() => {
47629
47769
  php: ["php-composer"]
47630
47770
  };
47631
47771
  toolchainCache = new Map;
47772
+ _internals16 = {
47773
+ isCommandAvailable,
47774
+ discoverBuildCommandsFromProfiles,
47775
+ discoverBuildCommands,
47776
+ clearToolchainCache,
47777
+ getEcosystems
47778
+ };
47632
47779
  build_discovery = tool({
47633
47780
  description: "Discover build commands for various ecosystems in a project directory",
47634
47781
  args: {
@@ -47891,6 +48038,7 @@ var exports_evidence_summary_service = {};
47891
48038
  __export(exports_evidence_summary_service, {
47892
48039
  isAutoSummaryEnabled: () => isAutoSummaryEnabled,
47893
48040
  buildEvidenceSummary: () => buildEvidenceSummary,
48041
+ _internals: () => _internals17,
47894
48042
  REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
47895
48043
  EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
47896
48044
  });
@@ -47928,14 +48076,14 @@ function getTaskStatus(task, bundle) {
47928
48076
  if (task?.status) {
47929
48077
  return task.status;
47930
48078
  }
47931
- const entries = normalizeBundleEntries(bundle);
48079
+ const entries = _internals17.normalizeBundleEntries(bundle);
47932
48080
  if (entries.length > 0) {
47933
48081
  return "completed";
47934
48082
  }
47935
48083
  return "pending";
47936
48084
  }
47937
48085
  function isEvidenceComplete(bundle) {
47938
- const entries = normalizeBundleEntries(bundle);
48086
+ const entries = _internals17.normalizeBundleEntries(bundle);
47939
48087
  if (entries.length === 0) {
47940
48088
  return {
47941
48089
  isComplete: false,
@@ -47971,10 +48119,10 @@ async function buildTaskSummary(directory, task, taskId) {
47971
48119
  const result = await loadEvidence(directory, taskId);
47972
48120
  const bundle = result.status === "found" ? result.bundle : null;
47973
48121
  const phase = task?.phase ?? 0;
47974
- const status = getTaskStatus(task, bundle);
47975
- const evidenceCheck = isEvidenceComplete(bundle);
47976
- const blockers = getTaskBlockers(task, evidenceCheck, status);
47977
- const entries = normalizeBundleEntries(bundle);
48122
+ const status = _internals17.getTaskStatus(task, bundle);
48123
+ const evidenceCheck = _internals17.isEvidenceComplete(bundle);
48124
+ const blockers = _internals17.getTaskBlockers(task, evidenceCheck, status);
48125
+ const entries = _internals17.normalizeBundleEntries(bundle);
47978
48126
  const hasReview = entries.some((e) => e.type === "review");
47979
48127
  const hasTest = entries.some((e) => e.type === "test");
47980
48128
  const hasApproval = entries.some((e) => e.type === "approval");
@@ -48003,12 +48151,12 @@ async function buildPhaseSummary(directory, phase) {
48003
48151
  const taskSummaries = [];
48004
48152
  const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
48005
48153
  for (const task of phase.tasks) {
48006
- const summary = await buildTaskSummary(directory, task, task.id);
48154
+ const summary = await _internals17.buildTaskSummary(directory, task, task.id);
48007
48155
  taskSummaries.push(summary);
48008
48156
  }
48009
48157
  const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
48010
48158
  for (const taskId of extraTaskIds) {
48011
- const summary = await buildTaskSummary(directory, undefined, taskId);
48159
+ const summary = await _internals17.buildTaskSummary(directory, undefined, taskId);
48012
48160
  if (summary.phase === phase.id) {
48013
48161
  taskSummaries.push(summary);
48014
48162
  }
@@ -48109,7 +48257,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
48109
48257
  let totalTasks = 0;
48110
48258
  let completedTasks = 0;
48111
48259
  for (const phase of phasesToProcess) {
48112
- const summary = await buildPhaseSummary(directory, phase);
48260
+ const summary = await _internals17.buildPhaseSummary(directory, phase);
48113
48261
  phaseSummaries.push(summary);
48114
48262
  totalTasks += summary.totalTasks;
48115
48263
  completedTasks += summary.completedTasks;
@@ -48131,7 +48279,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
48131
48279
  overallBlockers,
48132
48280
  summaryText: ""
48133
48281
  };
48134
- artifact.summaryText = generateSummaryText(artifact);
48282
+ artifact.summaryText = _internals17.generateSummaryText(artifact);
48135
48283
  log("[EvidenceSummary] Summary built", {
48136
48284
  phases: phaseSummaries.length,
48137
48285
  totalTasks,
@@ -48150,7 +48298,7 @@ function isAutoSummaryEnabled(automationConfig) {
48150
48298
  }
48151
48299
  return automationConfig.capabilities?.evidence_auto_summaries === true;
48152
48300
  }
48153
- var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0";
48301
+ var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0", _internals17;
48154
48302
  var init_evidence_summary_service = __esm(() => {
48155
48303
  init_manager2();
48156
48304
  init_manager();
@@ -48164,6 +48312,17 @@ var init_evidence_summary_service = __esm(() => {
48164
48312
  "retrospective"
48165
48313
  ]);
48166
48314
  REQUIRED_EVIDENCE_TYPES = ["review", "test"];
48315
+ _internals17 = {
48316
+ buildEvidenceSummary,
48317
+ isAutoSummaryEnabled,
48318
+ normalizeBundleEntries,
48319
+ getTaskStatus,
48320
+ isEvidenceComplete,
48321
+ getTaskBlockers,
48322
+ buildTaskSummary,
48323
+ buildPhaseSummary,
48324
+ generateSummaryText
48325
+ };
48167
48326
  });
48168
48327
 
48169
48328
  // src/services/evidence-service.ts
@@ -48463,7 +48622,7 @@ function extractCurrentPhaseFromPlan2(plan) {
48463
48622
  if (!plan) {
48464
48623
  return { currentPhase: null, currentTask: null, incompleteTasks: [] };
48465
48624
  }
48466
- if (!validatePlanPhases(plan)) {
48625
+ if (!_internals18.validatePlanPhases(plan)) {
48467
48626
  return { currentPhase: null, currentTask: null, incompleteTasks: [] };
48468
48627
  }
48469
48628
  let currentPhase = null;
@@ -48605,9 +48764,9 @@ function extractPhaseMetrics(content) {
48605
48764
  async function getHandoffData(directory) {
48606
48765
  const now = new Date().toISOString();
48607
48766
  const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
48608
- const sessionState = parseSessionState(sessionContent);
48767
+ const sessionState = _internals18.parseSessionState(sessionContent);
48609
48768
  const plan = await loadPlanJsonOnly(directory);
48610
- const planInfo = extractCurrentPhaseFromPlan2(plan);
48769
+ const planInfo = _internals18.extractCurrentPhaseFromPlan(plan);
48611
48770
  if (!plan) {
48612
48771
  const planMdContent = await readSwarmFileAsync(directory, "plan.md");
48613
48772
  if (planMdContent) {
@@ -48626,8 +48785,8 @@ async function getHandoffData(directory) {
48626
48785
  }
48627
48786
  }
48628
48787
  const contextContent = await readSwarmFileAsync(directory, "context.md");
48629
- const recentDecisions = extractDecisions2(contextContent);
48630
- const rawPhaseMetrics = extractPhaseMetrics(contextContent);
48788
+ const recentDecisions = _internals18.extractDecisions(contextContent);
48789
+ const rawPhaseMetrics = _internals18.extractPhaseMetrics(contextContent);
48631
48790
  const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
48632
48791
  let delegationState = null;
48633
48792
  if (sessionState?.delegationState) {
@@ -48791,12 +48950,24 @@ ${lines.join(`
48791
48950
  `)}
48792
48951
  \`\`\``;
48793
48952
  }
48794
- var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20;
48953
+ var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20, _internals18;
48795
48954
  var init_handoff_service = __esm(() => {
48796
48955
  init_utils2();
48797
48956
  init_manager();
48798
48957
  init_utils();
48799
48958
  RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
48959
+ _internals18 = {
48960
+ getHandoffData,
48961
+ formatHandoffMarkdown,
48962
+ formatContinuationPrompt,
48963
+ escapeHtml,
48964
+ sanitizeString,
48965
+ validatePlanPhases,
48966
+ extractCurrentPhaseFromPlan: extractCurrentPhaseFromPlan2,
48967
+ parseSessionState,
48968
+ extractDecisions: extractDecisions2,
48969
+ extractPhaseMetrics
48970
+ };
48800
48971
  });
48801
48972
 
48802
48973
  // src/commands/handoff.ts
@@ -49191,6 +49362,15 @@ import { randomUUID as randomUUID3 } from "node:crypto";
49191
49362
  import { existsSync as existsSync16, readFileSync as readFileSync11 } from "node:fs";
49192
49363
  import { mkdir as mkdir6, readFile as readFile8, writeFile as writeFile6 } from "node:fs/promises";
49193
49364
  import * as path30 from "node:path";
49365
+ async function migrateKnowledgeToExternal(_directory, _config) {
49366
+ return {
49367
+ migrated: false,
49368
+ entriesMigrated: 0,
49369
+ entriesDropped: 0,
49370
+ entriesTotal: 0,
49371
+ skippedReason: "no-context-file"
49372
+ };
49373
+ }
49194
49374
  async function migrateContextToKnowledge(directory, config3) {
49195
49375
  const sentinelPath = path30.join(directory, ".swarm", ".knowledge-migrated");
49196
49376
  const contextPath = path30.join(directory, ".swarm", "context.md");
@@ -49223,9 +49403,9 @@ async function migrateContextToKnowledge(directory, config3) {
49223
49403
  skippedReason: "empty-context"
49224
49404
  };
49225
49405
  }
49226
- const rawEntries = parseContextMd(contextContent);
49406
+ const rawEntries = _internals19.parseContextMd(contextContent);
49227
49407
  if (rawEntries.length === 0) {
49228
- await writeSentinel(sentinelPath, 0, 0);
49408
+ await _internals19.writeSentinel(sentinelPath, 0, 0);
49229
49409
  return {
49230
49410
  migrated: true,
49231
49411
  entriesMigrated: 0,
@@ -49236,10 +49416,10 @@ async function migrateContextToKnowledge(directory, config3) {
49236
49416
  const existing = await readKnowledge(knowledgePath);
49237
49417
  let migrated = 0;
49238
49418
  let dropped = 0;
49239
- const projectName = inferProjectName(directory);
49419
+ const projectName = _internals19.inferProjectName(directory);
49240
49420
  for (const raw of rawEntries) {
49241
49421
  if (config3.validation_enabled !== false) {
49242
- const category = raw.categoryHint ?? inferCategoryFromText(raw.text);
49422
+ const category = raw.categoryHint ?? _internals19.inferCategoryFromText(raw.text);
49243
49423
  const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
49244
49424
  category,
49245
49425
  scope: "global",
@@ -49259,8 +49439,8 @@ async function migrateContextToKnowledge(directory, config3) {
49259
49439
  const entry = {
49260
49440
  id: randomUUID3(),
49261
49441
  tier: "swarm",
49262
- lesson: truncateLesson(raw.text),
49263
- category: raw.categoryHint ?? inferCategoryFromText(raw.text),
49442
+ lesson: _internals19.truncateLesson(raw.text),
49443
+ category: raw.categoryHint ?? _internals19.inferCategoryFromText(raw.text),
49264
49444
  tags: [...inferredTags, `migration:${raw.sourceSection}`],
49265
49445
  scope: "global",
49266
49446
  confidence: 0.3,
@@ -49283,7 +49463,7 @@ async function migrateContextToKnowledge(directory, config3) {
49283
49463
  if (migrated > 0) {
49284
49464
  await rewriteKnowledge(knowledgePath, existing);
49285
49465
  }
49286
- await writeSentinel(sentinelPath, migrated, dropped);
49466
+ await _internals19.writeSentinel(sentinelPath, migrated, dropped);
49287
49467
  log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
49288
49468
  return {
49289
49469
  migrated: true,
@@ -49293,7 +49473,7 @@ async function migrateContextToKnowledge(directory, config3) {
49293
49473
  };
49294
49474
  }
49295
49475
  function parseContextMd(content) {
49296
- const sections = splitIntoSections(content);
49476
+ const sections = _internals19.splitIntoSections(content);
49297
49477
  const entries = [];
49298
49478
  const seen = new Set;
49299
49479
  const sectionPatterns = [
@@ -49309,7 +49489,7 @@ function parseContextMd(content) {
49309
49489
  const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
49310
49490
  if (!match)
49311
49491
  continue;
49312
- const bullets = extractBullets(section.body);
49492
+ const bullets = _internals19.extractBullets(section.body);
49313
49493
  for (const bullet of bullets) {
49314
49494
  if (bullet.length < 15)
49315
49495
  continue;
@@ -49318,9 +49498,9 @@ function parseContextMd(content) {
49318
49498
  continue;
49319
49499
  seen.add(normalized);
49320
49500
  entries.push({
49321
- text: truncateLesson(bullet),
49501
+ text: _internals19.truncateLesson(bullet),
49322
49502
  sourceSection: match.sourceSection,
49323
- categoryHint: inferCategoryFromText(bullet)
49503
+ categoryHint: _internals19.inferCategoryFromText(bullet)
49324
49504
  });
49325
49505
  }
49326
49506
  }
@@ -49413,9 +49593,22 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
49413
49593
  await mkdir6(path30.dirname(sentinelPath), { recursive: true });
49414
49594
  await writeFile6(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
49415
49595
  }
49596
+ var _internals19;
49416
49597
  var init_knowledge_migrator = __esm(() => {
49598
+ init_logger();
49417
49599
  init_knowledge_store();
49418
49600
  init_knowledge_validator();
49601
+ _internals19 = {
49602
+ migrateContextToKnowledge,
49603
+ migrateKnowledgeToExternal,
49604
+ parseContextMd,
49605
+ splitIntoSections,
49606
+ extractBullets,
49607
+ inferCategoryFromText,
49608
+ truncateLesson,
49609
+ inferProjectName,
49610
+ writeSentinel
49611
+ };
49419
49612
  });
49420
49613
 
49421
49614
  // src/commands/knowledge.ts
@@ -50323,7 +50516,7 @@ async function runAdditionalLint(linter, mode, cwd) {
50323
50516
  };
50324
50517
  }
50325
50518
  }
50326
- var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint;
50519
+ var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals20;
50327
50520
  var init_lint = __esm(() => {
50328
50521
  init_zod();
50329
50522
  init_discovery();
@@ -50355,15 +50548,15 @@ var init_lint = __esm(() => {
50355
50548
  }
50356
50549
  const { mode } = args2;
50357
50550
  const cwd = directory;
50358
- const linter = await detectAvailableLinter(directory);
50551
+ const linter = await _internals20.detectAvailableLinter(directory);
50359
50552
  if (linter) {
50360
- const result = await runLint(linter, mode, directory);
50553
+ const result = await _internals20.runLint(linter, mode, directory);
50361
50554
  return JSON.stringify(result, null, 2);
50362
50555
  }
50363
- const additionalLinter = detectAdditionalLinter(cwd);
50556
+ const additionalLinter = _internals20.detectAdditionalLinter(cwd);
50364
50557
  if (additionalLinter) {
50365
50558
  warn(`[lint] Using ${additionalLinter} linter for this project`);
50366
- const result = await runAdditionalLint(additionalLinter, mode, cwd);
50559
+ const result = await _internals20.runAdditionalLint(additionalLinter, mode, cwd);
50367
50560
  return JSON.stringify(result, null, 2);
50368
50561
  }
50369
50562
  const errorResult = {
@@ -50377,6 +50570,12 @@ For Rust: rustup component add clippy`
50377
50570
  return JSON.stringify(errorResult, null, 2);
50378
50571
  }
50379
50572
  });
50573
+ _internals20 = {
50574
+ detectAvailableLinter,
50575
+ runLint,
50576
+ detectAdditionalLinter,
50577
+ runAdditionalLint
50578
+ };
50380
50579
  });
50381
50580
 
50382
50581
  // src/tools/secretscan.ts
@@ -50685,7 +50884,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
50685
50884
  }
50686
50885
  async function runSecretscan(directory) {
50687
50886
  try {
50688
- const result = await secretscan.execute({ directory }, {});
50887
+ const result = await _internals21.secretscan.execute({ directory }, {});
50689
50888
  const jsonStr = typeof result === "string" ? result : result.output;
50690
50889
  return JSON.parse(jsonStr);
50691
50890
  } catch (e) {
@@ -50700,7 +50899,7 @@ async function runSecretscan(directory) {
50700
50899
  return errorResult;
50701
50900
  }
50702
50901
  }
50703
- var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS, O_NOFOLLOW, secretscan;
50902
+ var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS, O_NOFOLLOW, secretscan, _internals21;
50704
50903
  var init_secretscan = __esm(() => {
50705
50904
  init_zod();
50706
50905
  init_path_security();
@@ -51072,6 +51271,10 @@ var init_secretscan = __esm(() => {
51072
51271
  }
51073
51272
  }
51074
51273
  });
51274
+ _internals21 = {
51275
+ secretscan,
51276
+ runSecretscan
51277
+ };
51075
51278
  });
51076
51279
 
51077
51280
  // src/test-impact/analyzer.ts
@@ -51203,8 +51406,8 @@ async function buildImpactMapInternal(cwd) {
51203
51406
  return impactMap;
51204
51407
  }
51205
51408
  async function buildImpactMap(cwd) {
51206
- const impactMap = await buildImpactMapInternal(cwd);
51207
- await saveImpactMap(cwd, impactMap);
51409
+ const impactMap = await _internals22.buildImpactMapInternal(cwd);
51410
+ await _internals22.saveImpactMap(cwd, impactMap);
51208
51411
  return impactMap;
51209
51412
  }
51210
51413
  async function loadImpactMap(cwd) {
@@ -51215,12 +51418,12 @@ async function loadImpactMap(cwd) {
51215
51418
  const data = JSON.parse(content);
51216
51419
  const map3 = data.map;
51217
51420
  const generatedAt = new Date(data.generatedAt).getTime();
51218
- if (!isCacheStale(map3, generatedAt)) {
51421
+ if (!_internals22.isCacheStale(map3, generatedAt)) {
51219
51422
  return map3;
51220
51423
  }
51221
51424
  } catch {}
51222
51425
  }
51223
- return buildImpactMap(cwd);
51426
+ return _internals22.buildImpactMap(cwd);
51224
51427
  }
51225
51428
  async function saveImpactMap(cwd, impactMap) {
51226
51429
  const cacheDir2 = path34.join(cwd, ".swarm", "cache");
@@ -51246,7 +51449,7 @@ async function analyzeImpact(changedFiles, cwd) {
51246
51449
  };
51247
51450
  }
51248
51451
  const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
51249
- const impactMap = await loadImpactMap(cwd);
51452
+ const impactMap = await _internals22.loadImpactMap(cwd);
51250
51453
  const impactedTestsSet = new Set;
51251
51454
  const untestedFiles = [];
51252
51455
  for (const changedFile of validFiles) {
@@ -51287,12 +51490,24 @@ async function analyzeImpact(changedFiles, cwd) {
51287
51490
  impactMap
51288
51491
  };
51289
51492
  }
51290
- var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, EXTENSIONS_TO_TRY;
51493
+ var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, EXTENSIONS_TO_TRY, _internals22;
51291
51494
  var init_analyzer = __esm(() => {
51292
51495
  IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
51293
51496
  IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
51294
51497
  IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
51295
51498
  EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
51499
+ _internals22 = {
51500
+ normalizePath,
51501
+ isCacheStale,
51502
+ resolveRelativeImport,
51503
+ findTestFilesSync,
51504
+ extractImports,
51505
+ buildImpactMapInternal,
51506
+ buildImpactMap,
51507
+ loadImpactMap,
51508
+ saveImpactMap,
51509
+ analyzeImpact
51510
+ };
51296
51511
  });
51297
51512
 
51298
51513
  // src/test-impact/failure-classifier.ts
@@ -53128,9 +53343,9 @@ function getVersionFileVersion(dir) {
53128
53343
  async function runVersionCheck2(dir, _timeoutMs) {
53129
53344
  const startTime = Date.now();
53130
53345
  try {
53131
- const packageVersion = getPackageVersion(dir);
53132
- const changelogVersion = getChangelogVersion(dir);
53133
- const versionFileVersion = getVersionFileVersion(dir);
53346
+ const packageVersion = _internals23.getPackageVersion(dir);
53347
+ const changelogVersion = _internals23.getChangelogVersion(dir);
53348
+ const versionFileVersion = _internals23.getVersionFileVersion(dir);
53134
53349
  const versions3 = [];
53135
53350
  if (packageVersion)
53136
53351
  versions3.push(`package.json: ${packageVersion}`);
@@ -53480,7 +53695,7 @@ async function runPreflight(dir, phase, config3) {
53480
53695
  const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
53481
53696
  let validatedDir;
53482
53697
  try {
53483
- validatedDir = validateDirectoryPath(dir);
53698
+ validatedDir = _internals23.validateDirectoryPath(dir);
53484
53699
  } catch (error93) {
53485
53700
  return {
53486
53701
  id: reportId,
@@ -53500,7 +53715,7 @@ async function runPreflight(dir, phase, config3) {
53500
53715
  }
53501
53716
  let validatedTimeout;
53502
53717
  try {
53503
- validatedTimeout = validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
53718
+ validatedTimeout = _internals23.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
53504
53719
  } catch (error93) {
53505
53720
  return {
53506
53721
  id: reportId,
@@ -53541,12 +53756,12 @@ async function runPreflight(dir, phase, config3) {
53541
53756
  });
53542
53757
  const checks5 = [];
53543
53758
  log("[Preflight] Running lint check...");
53544
- const lintResult = await runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
53759
+ const lintResult = await _internals23.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
53545
53760
  checks5.push(lintResult);
53546
53761
  log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
53547
53762
  if (!cfg.skipTests) {
53548
53763
  log("[Preflight] Running tests check...");
53549
- const testsResult = await runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
53764
+ const testsResult = await _internals23.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
53550
53765
  checks5.push(testsResult);
53551
53766
  log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
53552
53767
  } else {
@@ -53558,7 +53773,7 @@ async function runPreflight(dir, phase, config3) {
53558
53773
  }
53559
53774
  if (!cfg.skipSecrets) {
53560
53775
  log("[Preflight] Running secrets check...");
53561
- const secretsResult = await runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
53776
+ const secretsResult = await _internals23.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
53562
53777
  checks5.push(secretsResult);
53563
53778
  log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
53564
53779
  } else {
@@ -53570,7 +53785,7 @@ async function runPreflight(dir, phase, config3) {
53570
53785
  }
53571
53786
  if (!cfg.skipEvidence) {
53572
53787
  log("[Preflight] Running evidence check...");
53573
- const evidenceResult = await runEvidenceCheck(validatedDir);
53788
+ const evidenceResult = await _internals23.runEvidenceCheck(validatedDir);
53574
53789
  checks5.push(evidenceResult);
53575
53790
  log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
53576
53791
  } else {
@@ -53581,12 +53796,12 @@ async function runPreflight(dir, phase, config3) {
53581
53796
  });
53582
53797
  }
53583
53798
  log("[Preflight] Running requirement coverage check...");
53584
- const reqCoverageResult = await runRequirementCoverageCheck(validatedDir, phase);
53799
+ const reqCoverageResult = await _internals23.runRequirementCoverageCheck(validatedDir, phase);
53585
53800
  checks5.push(reqCoverageResult);
53586
53801
  log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
53587
53802
  if (!cfg.skipVersion) {
53588
53803
  log("[Preflight] Running version check...");
53589
- const versionResult = await runVersionCheck2(validatedDir, cfg.checkTimeoutMs);
53804
+ const versionResult = await _internals23.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
53590
53805
  checks5.push(versionResult);
53591
53806
  log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
53592
53807
  } else {
@@ -53649,10 +53864,10 @@ function formatPreflightMarkdown(report) {
53649
53864
  async function handlePreflightCommand(directory, _args) {
53650
53865
  const plan = await loadPlan(directory);
53651
53866
  const phase = plan?.current_phase ?? 1;
53652
- const report = await runPreflight(directory, phase);
53653
- return formatPreflightMarkdown(report);
53867
+ const report = await _internals23.runPreflight(directory, phase);
53868
+ return _internals23.formatPreflightMarkdown(report);
53654
53869
  }
53655
- var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG;
53870
+ var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals23;
53656
53871
  var init_preflight_service = __esm(() => {
53657
53872
  init_manager2();
53658
53873
  init_manager();
@@ -53669,6 +53884,22 @@ var init_preflight_service = __esm(() => {
53669
53884
  testScope: "convention",
53670
53885
  linter: "biome"
53671
53886
  };
53887
+ _internals23 = {
53888
+ runPreflight,
53889
+ formatPreflightMarkdown,
53890
+ handlePreflightCommand,
53891
+ validateDirectoryPath,
53892
+ validateTimeout,
53893
+ getPackageVersion,
53894
+ getChangelogVersion,
53895
+ getVersionFileVersion,
53896
+ runVersionCheck: runVersionCheck2,
53897
+ runLintCheck,
53898
+ runTestsCheck,
53899
+ runSecretsCheck,
53900
+ runEvidenceCheck,
53901
+ runRequirementCoverageCheck
53902
+ };
53672
53903
  });
53673
53904
 
53674
53905
  // src/commands/preflight.ts
@@ -55379,6 +55610,7 @@ async function handleStatusCommand(directory, agents) {
55379
55610
  return formatStatusMarkdown(statusData);
55380
55611
  }
55381
55612
  var init_status_service = __esm(() => {
55613
+ init_extractors();
55382
55614
  init_utils2();
55383
55615
  init_manager();
55384
55616
  init_state();
@@ -55784,7 +56016,7 @@ function findSimilarCommands(query) {
55784
56016
  return cmd.toLowerCase().includes(q) || q.includes(cmd.toLowerCase());
55785
56017
  }).map((cmd) => ({
55786
56018
  cmd,
55787
- score: cmd.length < q.length ? q.length - cmd.length : levenshteinDistance(q, cmd)
56019
+ score: cmd.length < q.length ? q.length - cmd.length : _internals24.levenshteinDistance(q, cmd)
55788
56020
  }));
55789
56021
  scored.sort((a, b) => a.score - b.score);
55790
56022
  return scored.slice(0, 3).map((s) => s.cmd);
@@ -55814,11 +56046,11 @@ async function handleHelpCommand(ctx) {
55814
56046
  return buildHelpText2();
55815
56047
  }
55816
56048
  const tokens = targetCommand.split(/\s+/);
55817
- const resolved = resolveCommand(tokens);
56049
+ const resolved = _internals24.resolveCommand(tokens);
55818
56050
  if (resolved) {
55819
- return buildDetailedHelp(resolved.key, resolved.entry);
56051
+ return _internals24.buildDetailedHelp(resolved.key, resolved.entry);
55820
56052
  }
55821
- const similar = findSimilarCommands(targetCommand);
56053
+ const similar = _internals24.findSimilarCommands(targetCommand);
55822
56054
  const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
55823
56055
  if (similar.length > 0) {
55824
56056
  return `Command '/swarm ${targetCommand}' not found.
@@ -55912,7 +56144,7 @@ function resolveCommand(tokens) {
55912
56144
  }
55913
56145
  return null;
55914
56146
  }
55915
- var COMMAND_REGISTRY, VALID_COMMANDS, validation;
56147
+ var COMMAND_REGISTRY, VALID_COMMANDS, _internals24, validation;
55916
56148
  var init_registry = __esm(() => {
55917
56149
  init_acknowledge_spec_drift();
55918
56150
  init_agents();
@@ -55973,7 +56205,7 @@ var init_registry = __esm(() => {
55973
56205
  clashesWithNativeCcCommand: "/agents"
55974
56206
  },
55975
56207
  help: {
55976
- handler: (ctx) => handleHelpCommand(ctx),
56208
+ handler: (ctx) => _internals24.handleHelpCommand(ctx),
55977
56209
  description: "Show help for swarm commands",
55978
56210
  category: "core",
55979
56211
  args: "[command]",
@@ -56303,7 +56535,15 @@ var init_registry = __esm(() => {
56303
56535
  }
56304
56536
  };
56305
56537
  VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
56306
- validation = validateAliases();
56538
+ _internals24 = {
56539
+ handleHelpCommand,
56540
+ validateAliases,
56541
+ resolveCommand,
56542
+ levenshteinDistance,
56543
+ findSimilarCommands,
56544
+ buildDetailedHelp
56545
+ };
56546
+ validation = _internals24.validateAliases();
56307
56547
  if (!validation.valid) {
56308
56548
  throw new Error(`COMMAND_REGISTRY alias validation failed:
56309
56549
  ${validation.errors.join(`
@@ -59029,6 +59269,7 @@ REASONING: [2-4 sentences — what you verified and why]
59029
59269
  EVIDENCE_CHECKED: [list of files/artifacts you read]
59030
59270
  ANTI_PATTERNS_DETECTED: [list or "none"]
59031
59271
  ESCALATION_NEEDED: YES | NO`;
59272
+ var init_critic = () => {};
59032
59273
 
59033
59274
  // src/agents/curator-agent.ts
59034
59275
  function createCuratorAgent(model, customPrompt, customAppendPrompt, role = "curator_init") {
@@ -60385,10 +60626,12 @@ var init_agents2 = __esm(() => {
60385
60626
  init_warning_buffer();
60386
60627
  init_architect();
60387
60628
  init_council_prompts();
60629
+ init_critic();
60388
60630
  init_curator_agent();
60389
60631
  init_reviewer();
60390
60632
  init_architect();
60391
60633
  init_council_prompts();
60634
+ init_critic();
60392
60635
  init_curator_agent();
60393
60636
  init_reviewer();
60394
60637
  warnedAgents = new Set;
@@ -61224,6 +61467,7 @@ var init_preflight_integration = __esm(() => {
61224
61467
  init_status_artifact();
61225
61468
  init_trigger();
61226
61469
  init_preflight_service();
61470
+ init_logger();
61227
61471
  });
61228
61472
 
61229
61473
  // node_modules/web-tree-sitter/tree-sitter.js
@@ -64971,9 +65215,10 @@ var init_doc_scan = __esm(() => {
64971
65215
  // src/tools/knowledge-recall.ts
64972
65216
  var exports_knowledge_recall = {};
64973
65217
  __export(exports_knowledge_recall, {
64974
- knowledge_recall: () => knowledge_recall
65218
+ knowledge_recall: () => knowledge_recall,
65219
+ _internals: () => _internals25
64975
65220
  });
64976
- var knowledge_recall;
65221
+ var knowledge_recall, _internals25;
64977
65222
  var init_knowledge_recall = __esm(() => {
64978
65223
  init_zod();
64979
65224
  init_knowledge_store();
@@ -65059,6 +65304,9 @@ var init_knowledge_recall = __esm(() => {
65059
65304
  return JSON.stringify(result);
65060
65305
  }
65061
65306
  });
65307
+ _internals25 = {
65308
+ knowledge_recall
65309
+ };
65062
65310
  });
65063
65311
 
65064
65312
  // src/environment/prompt-renderer.ts
@@ -65110,13 +65358,14 @@ __export(exports_curator_drift, {
65110
65358
  writeDriftReport: () => writeDriftReport,
65111
65359
  runDeterministicDriftCheck: () => runDeterministicDriftCheck,
65112
65360
  readPriorDriftReports: () => readPriorDriftReports,
65113
- buildDriftInjectionText: () => buildDriftInjectionText
65361
+ buildDriftInjectionText: () => buildDriftInjectionText,
65362
+ _internals: () => _internals27
65114
65363
  });
65115
- import * as fs48 from "node:fs";
65364
+ import * as fs49 from "node:fs";
65116
65365
  import * as path70 from "node:path";
65117
65366
  async function readPriorDriftReports(directory) {
65118
65367
  const swarmDir = path70.join(directory, ".swarm");
65119
- const entries = await fs48.promises.readdir(swarmDir).catch(() => null);
65368
+ const entries = await fs49.promises.readdir(swarmDir).catch(() => null);
65120
65369
  if (entries === null)
65121
65370
  return [];
65122
65371
  const reportFiles = entries.filter((name2) => name2.startsWith(DRIFT_REPORT_PREFIX) && name2.endsWith(".json")).sort();
@@ -65143,9 +65392,9 @@ async function writeDriftReport(directory, report) {
65143
65392
  const filename = `${DRIFT_REPORT_PREFIX}${report.phase}.json`;
65144
65393
  const filePath = validateSwarmPath(directory, filename);
65145
65394
  const swarmDir = path70.dirname(filePath);
65146
- await fs48.promises.mkdir(swarmDir, { recursive: true });
65395
+ await fs49.promises.mkdir(swarmDir, { recursive: true });
65147
65396
  try {
65148
- await fs48.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
65397
+ await fs49.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
65149
65398
  } catch (err2) {
65150
65399
  throw new Error(`[curator-drift] Failed to write drift report to ${filePath}: ${String(err2)}`);
65151
65400
  }
@@ -65155,7 +65404,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
65155
65404
  try {
65156
65405
  const planMd = await readSwarmFileAsync(directory, "plan.md");
65157
65406
  const specMd = await readSwarmFileAsync(directory, "spec.md");
65158
- const priorReports = await readPriorDriftReports(directory);
65407
+ const priorReports = await _internals27.readPriorDriftReports(directory);
65159
65408
  const complianceCount = curatorResult.compliance.length;
65160
65409
  const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
65161
65410
  let alignment = "ALIGNED";
@@ -65204,7 +65453,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
65204
65453
  scope_additions: [],
65205
65454
  injection_summary: injectionSummary
65206
65455
  };
65207
- const reportPath = await writeDriftReport(directory, report);
65456
+ const reportPath = await _internals27.writeDriftReport(directory, report);
65208
65457
  getGlobalEventBus().publish("curator.drift.completed", {
65209
65458
  phase,
65210
65459
  alignment,
@@ -65267,16 +65516,24 @@ function buildDriftInjectionText(report, maxChars) {
65267
65516
  }
65268
65517
  return text.slice(0, maxChars);
65269
65518
  }
65270
- var DRIFT_REPORT_PREFIX = "drift-report-phase-";
65519
+ var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals27;
65271
65520
  var init_curator_drift = __esm(() => {
65272
65521
  init_event_bus();
65522
+ init_logger();
65273
65523
  init_utils2();
65524
+ _internals27 = {
65525
+ readPriorDriftReports,
65526
+ writeDriftReport,
65527
+ runDeterministicDriftCheck,
65528
+ buildDriftInjectionText
65529
+ };
65274
65530
  });
65275
65531
 
65276
65532
  // src/index.ts
65277
65533
  init_package();
65278
65534
  init_agents2();
65279
- import * as path114 from "node:path";
65535
+ init_critic();
65536
+ import * as path115 from "node:path";
65280
65537
 
65281
65538
  // src/background/index.ts
65282
65539
  init_event_bus();
@@ -65839,6 +66096,7 @@ var CONFLICT_MAP = new Map(CLAUDE_CODE_CONFLICTS.map((c) => [c.swarmCommand, c])
65839
66096
 
65840
66097
  // src/hooks/cc-command-intercept.ts
65841
66098
  init_constants();
66099
+ init_logger();
65842
66100
  function createCcCommandInterceptHook(config3 = {}) {
65843
66101
  const {
65844
66102
  intercept = ["CRITICAL", "HIGH"],
@@ -65950,6 +66208,7 @@ function createCcCommandInterceptHook(config3 = {}) {
65950
66208
  // src/hooks/compaction-customizer.ts
65951
66209
  init_manager();
65952
66210
  init_state();
66211
+ init_extractors();
65953
66212
  init_utils2();
65954
66213
  import * as fs33 from "node:fs";
65955
66214
  import { join as join45 } from "node:path";
@@ -66617,11 +66876,17 @@ function createDelegationTrackerHook(config3, guardrailsEnabled = true) {
66617
66876
  }
66618
66877
  };
66619
66878
  }
66879
+
66880
+ // src/hooks/index.ts
66881
+ init_extractors();
66882
+
66620
66883
  // src/hooks/full-auto-intercept.ts
66884
+ init_critic();
66621
66885
  init_schema();
66622
66886
  init_file_locks();
66623
66887
  init_state();
66624
66888
  init_telemetry();
66889
+ init_logger();
66625
66890
  init_utils2();
66626
66891
  import * as fs35 from "node:fs";
66627
66892
  var END_OF_SENTENCE_QUESTION_PATTERN = /\?\s*$/;
@@ -66930,7 +67195,7 @@ Critic reasoning: ${criticResult.reasoning}`
66930
67195
  }
66931
67196
  }
66932
67197
  async function dispatchCriticAndWriteEvent(directory, architectOutput, criticContext, criticModel, escalationType, interactionCount, deadlockCount, oversightAgentName) {
66933
- const client = swarmState.opencodeClient;
67198
+ const client = _internals9.swarmState.opencodeClient;
66934
67199
  if (!client) {
66935
67200
  warn("[full-auto-intercept] No opencodeClient — critic dispatch skipped (fallback to PENDING)");
66936
67201
  const result = {
@@ -67050,12 +67315,11 @@ function createFullAutoInterceptHook(config3, directory) {
67050
67315
  if (!architectText)
67051
67316
  return;
67052
67317
  const sessionID = architectMessage.info?.sessionID;
67053
- if (!hasActiveFullAuto(sessionID))
67318
+ if (!_internals9.hasActiveFullAuto(sessionID))
67054
67319
  return;
67055
67320
  let session = null;
67056
67321
  if (sessionID) {
67057
- const { ensureAgentSession: ensureAgentSession2 } = await Promise.resolve().then(() => (init_state(), exports_state));
67058
- session = ensureAgentSession2(sessionID);
67322
+ session = _internals9.ensureAgentSession(sessionID);
67059
67323
  }
67060
67324
  if (session) {
67061
67325
  const interactionCount = session.fullAutoInteractionCount ?? 0;
@@ -67323,6 +67587,7 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
67323
67587
  }
67324
67588
  // src/hooks/pipeline-tracker.ts
67325
67589
  init_manager();
67590
+ init_extractors();
67326
67591
  init_utils2();
67327
67592
  function parsePhaseNumber(phaseString) {
67328
67593
  if (!phaseString)
@@ -67413,6 +67678,7 @@ import { realpathSync as realpathSync8 } from "node:fs";
67413
67678
  import * as path58 from "node:path";
67414
67679
 
67415
67680
  // src/tools/repo-graph/builder.ts
67681
+ init_logger();
67416
67682
  init_path_security();
67417
67683
  import * as fsSync3 from "node:fs";
67418
67684
  import { existsSync as existsSync29, realpathSync as realpathSync6 } from "node:fs";
@@ -68321,12 +68587,14 @@ function getCachedMtime(workspace) {
68321
68587
  return mtimeCache.get(path55.normalize(workspace));
68322
68588
  }
68323
68589
  // src/tools/repo-graph/incremental.ts
68590
+ init_logger();
68324
68591
  import { existsSync as existsSync31 } from "node:fs";
68325
68592
  import * as fsPromises7 from "node:fs/promises";
68326
68593
  import * as path57 from "node:path";
68327
68594
 
68328
68595
  // src/tools/repo-graph/storage.ts
68329
68596
  init_utils2();
68597
+ init_logger();
68330
68598
  init_path_security();
68331
68599
  import { constants as constants4, existsSync as existsSync30, realpathSync as realpathSync7 } from "node:fs";
68332
68600
  import * as fsPromises6 from "node:fs/promises";
@@ -68585,6 +68853,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
68585
68853
  return graph;
68586
68854
  }
68587
68855
  // src/hooks/repo-graph-builder.ts
68856
+ init_logger();
68588
68857
  var SUPPORTED_EXTENSIONS2 = [
68589
68858
  ".ts",
68590
68859
  ".tsx",
@@ -69373,6 +69642,7 @@ function rankCandidates(candidates, config3) {
69373
69642
  }
69374
69643
 
69375
69644
  // src/hooks/system-enhancer.ts
69645
+ init_extractors();
69376
69646
  init_knowledge_store();
69377
69647
 
69378
69648
  // src/hooks/repo-graph-injection.ts
@@ -73272,8 +73542,64 @@ init_manager();
73272
73542
  // src/services/run-memory.ts
73273
73543
  init_utils2();
73274
73544
  init_path_security();
73545
+ import * as crypto8 from "node:crypto";
73546
+ import * as fs48 from "node:fs/promises";
73275
73547
  var RUN_MEMORY_FILENAME = "run-memory.jsonl";
73276
73548
  var MAX_SUMMARY_TOKENS = 500;
73549
+ function generateTaskFingerprint(taskId, fileTargets) {
73550
+ const sortedFiles = [...fileTargets].sort().join(",");
73551
+ const hash3 = crypto8.createHash("sha256").update(taskId + sortedFiles).digest("hex");
73552
+ return hash3.slice(0, 8);
73553
+ }
73554
+ async function recordOutcome(directory, entry) {
73555
+ validateDirectory(directory);
73556
+ const resolvedPath = validateSwarmPath(directory, RUN_MEMORY_FILENAME);
73557
+ const line = `${JSON.stringify(entry)}
73558
+ `;
73559
+ await fs48.appendFile(resolvedPath, line, { encoding: "utf-8" });
73560
+ }
73561
+ async function getTaskHistory(directory, taskId) {
73562
+ validateDirectory(directory);
73563
+ const content = await readSwarmFileAsync(directory, RUN_MEMORY_FILENAME);
73564
+ if (!content) {
73565
+ return [];
73566
+ }
73567
+ const entries = [];
73568
+ const lines = content.split(`
73569
+ `);
73570
+ for (const line of lines) {
73571
+ if (!line.trim())
73572
+ continue;
73573
+ try {
73574
+ const entry = JSON.parse(line);
73575
+ if (entry.taskId === taskId) {
73576
+ entries.push(entry);
73577
+ }
73578
+ } catch {}
73579
+ }
73580
+ return entries;
73581
+ }
73582
+ async function getFailures(directory) {
73583
+ validateDirectory(directory);
73584
+ const content = await readSwarmFileAsync(directory, RUN_MEMORY_FILENAME);
73585
+ if (!content) {
73586
+ return [];
73587
+ }
73588
+ const entries = [];
73589
+ const lines = content.split(`
73590
+ `);
73591
+ for (const line of lines) {
73592
+ if (!line.trim())
73593
+ continue;
73594
+ try {
73595
+ const entry = JSON.parse(line);
73596
+ if (entry.outcome === "fail" || entry.outcome === "retry") {
73597
+ entries.push(entry);
73598
+ }
73599
+ } catch {}
73600
+ }
73601
+ return entries;
73602
+ }
73277
73603
  function groupByTaskId(entries) {
73278
73604
  const groups = new Map;
73279
73605
  for (const entry of entries) {
@@ -73322,10 +73648,10 @@ async function getRunMemorySummary(directory) {
73322
73648
  if (entries.length === 0) {
73323
73649
  return null;
73324
73650
  }
73325
- const groups = groupByTaskId(entries);
73651
+ const groups = _internals26.groupByTaskId(entries);
73326
73652
  const summaries = [];
73327
73653
  for (const [taskId, taskEntries] of groups) {
73328
- const summary = summarizeTask(taskId, taskEntries);
73654
+ const summary = _internals26.summarizeTask(taskId, taskEntries);
73329
73655
  if (summary) {
73330
73656
  summaries.push(summary);
73331
73657
  }
@@ -73358,9 +73684,20 @@ Use this data to avoid repeating known failure patterns.`;
73358
73684
  }
73359
73685
  return prefix + summaryText + suffix;
73360
73686
  }
73687
+ var _internals26 = {
73688
+ generateTaskFingerprint,
73689
+ recordOutcome,
73690
+ getTaskHistory,
73691
+ getFailures,
73692
+ getRunMemorySummary,
73693
+ groupByTaskId,
73694
+ summarizeTask
73695
+ };
73361
73696
 
73362
73697
  // src/hooks/knowledge-injector.ts
73698
+ init_logger();
73363
73699
  init_curator_drift();
73700
+ init_extractors();
73364
73701
  init_knowledge_reader();
73365
73702
  init_knowledge_store();
73366
73703
  init_utils2();
@@ -73655,7 +73992,7 @@ function createSelfReviewHook(config3, injectAdvisory) {
73655
73992
  }
73656
73993
 
73657
73994
  // src/hooks/slop-detector.ts
73658
- import * as fs49 from "node:fs";
73995
+ import * as fs50 from "node:fs";
73659
73996
  import * as path72 from "node:path";
73660
73997
  var WRITE_EDIT_TOOLS = new Set([
73661
73998
  "write",
@@ -73701,7 +74038,7 @@ function checkBoilerplateExplosion(content, taskDescription, threshold) {
73701
74038
  function walkFiles(dir, exts, deadline) {
73702
74039
  const results = [];
73703
74040
  try {
73704
- for (const entry of fs49.readdirSync(dir, { withFileTypes: true })) {
74041
+ for (const entry of fs50.readdirSync(dir, { withFileTypes: true })) {
73705
74042
  if (deadline !== undefined && Date.now() > deadline)
73706
74043
  break;
73707
74044
  if (entry.isSymbolicLink())
@@ -73721,7 +74058,7 @@ function walkFiles(dir, exts, deadline) {
73721
74058
  return results;
73722
74059
  }
73723
74060
  function checkDeadExports(content, projectDir, startTime) {
73724
- const hasPackageJson = fs49.existsSync(path72.join(projectDir, "package.json"));
74061
+ const hasPackageJson = fs50.existsSync(path72.join(projectDir, "package.json"));
73725
74062
  if (!hasPackageJson)
73726
74063
  return null;
73727
74064
  const exportMatches = content.matchAll(/^\+(?:export)\s+(?:function|class|const|type|interface)\s+(\w{3,})/gm);
@@ -73744,7 +74081,7 @@ function checkDeadExports(content, projectDir, startTime) {
73744
74081
  if (found || Date.now() - startTime > 480)
73745
74082
  break;
73746
74083
  try {
73747
- const text = fs49.readFileSync(file3, "utf-8");
74084
+ const text = fs50.readFileSync(file3, "utf-8");
73748
74085
  if (importPattern.test(text))
73749
74086
  found = true;
73750
74087
  importPattern.lastIndex = 0;
@@ -73836,7 +74173,7 @@ function checkDuplicateUtility(content, projectDir, startTime, targetFile) {
73836
74173
  if (Date.now() > deadline)
73837
74174
  break;
73838
74175
  const utilPath = path72.join(projectDir, utilDir);
73839
- if (!fs49.existsSync(utilPath))
74176
+ if (!fs50.existsSync(utilPath))
73840
74177
  continue;
73841
74178
  const files = walkFiles(utilPath, [".ts", ".tsx", ".js", ".jsx"], deadline);
73842
74179
  for (const file3 of files) {
@@ -73845,7 +74182,7 @@ function checkDuplicateUtility(content, projectDir, startTime, targetFile) {
73845
74182
  if (targetFile && path72.resolve(file3) === path72.resolve(targetFile))
73846
74183
  continue;
73847
74184
  try {
73848
- const text = fs49.readFileSync(file3, "utf-8");
74185
+ const text = fs50.readFileSync(file3, "utf-8");
73849
74186
  for (const name2 of newExports) {
73850
74187
  const exportPattern = new RegExp(`\\bexport\\s+(?:function|class|const|type|interface)\\s+${name2}\\b`);
73851
74188
  if (exportPattern.test(text)) {
@@ -73928,7 +74265,7 @@ Review before proceeding.`;
73928
74265
  // src/hooks/steering-consumed.ts
73929
74266
  init_bun_compat();
73930
74267
  init_utils2();
73931
- import * as fs50 from "node:fs";
74268
+ import * as fs51 from "node:fs";
73932
74269
  function recordSteeringConsumed(directory, directiveId) {
73933
74270
  try {
73934
74271
  const eventsPath = validateSwarmPath(directory, "events.jsonl");
@@ -73937,7 +74274,7 @@ function recordSteeringConsumed(directory, directiveId) {
73937
74274
  directiveId,
73938
74275
  timestamp: new Date().toISOString()
73939
74276
  };
73940
- fs50.appendFileSync(eventsPath, `${JSON.stringify(event)}
74277
+ fs51.appendFileSync(eventsPath, `${JSON.stringify(event)}
73941
74278
  `, "utf-8");
73942
74279
  } catch {}
73943
74280
  }
@@ -73979,12 +74316,12 @@ function createSteeringConsumedHook(directory) {
73979
74316
 
73980
74317
  // src/hooks/trajectory-logger.ts
73981
74318
  init_manager2();
73982
- import * as fs52 from "node:fs/promises";
74319
+ import * as fs53 from "node:fs/promises";
73983
74320
  import * as path74 from "node:path";
73984
74321
 
73985
74322
  // src/prm/trajectory-store.ts
73986
74323
  init_utils2();
73987
- import * as fs51 from "node:fs/promises";
74324
+ import * as fs52 from "node:fs/promises";
73988
74325
  import * as path73 from "node:path";
73989
74326
  function getTrajectoryPath(sessionId, directory) {
73990
74327
  const relativePath = path73.join("trajectories", `${sessionId}.jsonl`);
@@ -74006,10 +74343,10 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
74006
74343
  _inMemoryTrajectoryCache.set(sessionId, cached3);
74007
74344
  }
74008
74345
  const trajectoryPath = getTrajectoryPath(sessionId, directory);
74009
- await fs51.mkdir(path73.dirname(trajectoryPath), { recursive: true });
74346
+ await fs52.mkdir(path73.dirname(trajectoryPath), { recursive: true });
74010
74347
  const line = `${JSON.stringify(entry)}
74011
74348
  `;
74012
- await fs51.appendFile(trajectoryPath, line, "utf-8");
74349
+ await fs52.appendFile(trajectoryPath, line, "utf-8");
74013
74350
  } catch (err2) {
74014
74351
  console.warn(`[trajectory-store] Failed to append trajectory entry: ${err2}`);
74015
74352
  }
@@ -74017,7 +74354,7 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
74017
74354
  async function readTrajectory(sessionId, directory) {
74018
74355
  try {
74019
74356
  const trajectoryPath = getTrajectoryPath(sessionId, directory);
74020
- const content = await fs51.readFile(trajectoryPath, "utf-8");
74357
+ const content = await fs52.readFile(trajectoryPath, "utf-8");
74021
74358
  const lines = content.split(`
74022
74359
  `).filter((line) => line.trim().length > 0);
74023
74360
  const entries = [];
@@ -74041,15 +74378,15 @@ async function cleanupOldTrajectoryFiles(directory, maxAgeDays = 7) {
74041
74378
  for (const subdir of ["trajectories", "replays"]) {
74042
74379
  try {
74043
74380
  const dirPath = validateSwarmPath(directory, subdir);
74044
- const entries = await fs51.readdir(dirPath, { withFileTypes: true });
74381
+ const entries = await fs52.readdir(dirPath, { withFileTypes: true });
74045
74382
  for (const entry of entries) {
74046
74383
  if (!entry.isFile())
74047
74384
  continue;
74048
74385
  const filePath = path73.join(dirPath, entry.name);
74049
74386
  try {
74050
- const stat7 = await fs51.stat(filePath);
74387
+ const stat7 = await fs52.stat(filePath);
74051
74388
  if (now - stat7.mtimeMs > cutoffMs) {
74052
- await fs51.unlink(filePath);
74389
+ await fs52.unlink(filePath);
74053
74390
  }
74054
74391
  } catch {}
74055
74392
  }
@@ -74099,7 +74436,7 @@ function isSensitiveKey(key) {
74099
74436
  }
74100
74437
  async function truncateTrajectoryFile(filePath, maxLines) {
74101
74438
  try {
74102
- const content = await fs52.readFile(filePath, "utf-8");
74439
+ const content = await fs53.readFile(filePath, "utf-8");
74103
74440
  const lines = content.split(`
74104
74441
  `).filter((line) => line.trim().length > 0);
74105
74442
  if (lines.length <= maxLines) {
@@ -74107,7 +74444,7 @@ async function truncateTrajectoryFile(filePath, maxLines) {
74107
74444
  }
74108
74445
  const keepCount = Math.floor(maxLines / 2);
74109
74446
  const keptLines = lines.slice(-keepCount);
74110
- await fs52.writeFile(filePath, `${keptLines.join(`
74447
+ await fs53.writeFile(filePath, `${keptLines.join(`
74111
74448
  `)}
74112
74449
  `, "utf-8");
74113
74450
  } catch {}
@@ -74240,10 +74577,10 @@ function createTrajectoryLoggerHook(config3, _directory) {
74240
74577
  const relativePath = path74.join("evidence", sanitized, "trajectory.jsonl");
74241
74578
  const trajectoryPath = validateSwarmPath(_directory, relativePath);
74242
74579
  try {
74243
- await fs52.mkdir(path74.dirname(trajectoryPath), { recursive: true });
74580
+ await fs53.mkdir(path74.dirname(trajectoryPath), { recursive: true });
74244
74581
  const line = `${JSON.stringify(entry)}
74245
74582
  `;
74246
- await fs52.appendFile(trajectoryPath, line, "utf-8");
74583
+ await fs53.appendFile(trajectoryPath, line, "utf-8");
74247
74584
  await truncateTrajectoryFile(trajectoryPath, maxLines);
74248
74585
  } catch {}
74249
74586
  try {
@@ -74790,7 +75127,7 @@ init_state();
74790
75127
  init_telemetry();
74791
75128
 
74792
75129
  // src/prm/replay.ts
74793
- import { promises as fs53 } from "node:fs";
75130
+ import { promises as fs54 } from "node:fs";
74794
75131
  import path75 from "node:path";
74795
75132
  function isPathSafe2(targetPath, basePath) {
74796
75133
  const resolvedTarget = path75.resolve(targetPath);
@@ -74821,7 +75158,7 @@ async function startReplayRecording(sessionID, directory) {
74821
75158
  console.warn(`[replay] Invalid path detected - path traversal attempt blocked for session ${sessionID}`);
74822
75159
  return null;
74823
75160
  }
74824
- await fs53.mkdir(replayDir, { recursive: true });
75161
+ await fs54.mkdir(replayDir, { recursive: true });
74825
75162
  return filepath;
74826
75163
  } catch (err2) {
74827
75164
  console.warn(`[replay] Failed to start recording for session ${sessionID}: ${err2}`);
@@ -74841,7 +75178,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
74841
75178
  };
74842
75179
  const line = `${JSON.stringify(fullEntry)}
74843
75180
  `;
74844
- await fs53.appendFile(artifactPath, line, "utf-8");
75181
+ await fs54.appendFile(artifactPath, line, "utf-8");
74845
75182
  } catch (err2) {
74846
75183
  console.warn(`[replay] Failed to record entry: ${err2}`);
74847
75184
  }
@@ -75189,7 +75526,7 @@ init_telemetry();
75189
75526
  // src/tools/batch-symbols.ts
75190
75527
  init_dist();
75191
75528
  init_create_tool();
75192
- import * as fs54 from "node:fs";
75529
+ import * as fs55 from "node:fs";
75193
75530
  import * as path76 from "node:path";
75194
75531
  init_path_security();
75195
75532
  var WINDOWS_RESERVED_NAMES2 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
@@ -75208,11 +75545,11 @@ function containsWindowsAttacks2(str) {
75208
75545
  function isPathInWorkspace2(filePath, workspace) {
75209
75546
  try {
75210
75547
  const resolvedPath = path76.resolve(workspace, filePath);
75211
- if (!fs54.existsSync(resolvedPath)) {
75548
+ if (!fs55.existsSync(resolvedPath)) {
75212
75549
  return true;
75213
75550
  }
75214
- const realWorkspace = fs54.realpathSync(workspace);
75215
- const realResolvedPath = fs54.realpathSync(resolvedPath);
75551
+ const realWorkspace = fs55.realpathSync(workspace);
75552
+ const realResolvedPath = fs55.realpathSync(resolvedPath);
75216
75553
  const relativePath = path76.relative(realWorkspace, realResolvedPath);
75217
75554
  if (relativePath.startsWith("..") || path76.isAbsolute(relativePath)) {
75218
75555
  return false;
@@ -75257,7 +75594,7 @@ function processFile2(file3, cwd, exportedOnly) {
75257
75594
  };
75258
75595
  }
75259
75596
  const fullPath = path76.join(cwd, file3);
75260
- if (!fs54.existsSync(fullPath)) {
75597
+ if (!fs55.existsSync(fullPath)) {
75261
75598
  return {
75262
75599
  file: file3,
75263
75600
  success: false,
@@ -75288,14 +75625,14 @@ function processFile2(file3, cwd, exportedOnly) {
75288
75625
  }
75289
75626
  let isEmptyFile = false;
75290
75627
  try {
75291
- const stats = fs54.statSync(fullPath);
75628
+ const stats = fs55.statSync(fullPath);
75292
75629
  if (stats.size === 0) {
75293
75630
  isEmptyFile = true;
75294
75631
  }
75295
75632
  } catch {}
75296
75633
  if (syms.length === 0) {
75297
75634
  try {
75298
- const content = fs54.readFileSync(fullPath, "utf-8");
75635
+ const content = fs55.readFileSync(fullPath, "utf-8");
75299
75636
  if (content.trim().length === 0) {
75300
75637
  isEmptyFile = true;
75301
75638
  }
@@ -75547,7 +75884,7 @@ init_manager2();
75547
75884
  init_task_id();
75548
75885
  init_create_tool();
75549
75886
  init_resolve_working_directory();
75550
- import * as fs55 from "node:fs";
75887
+ import * as fs56 from "node:fs";
75551
75888
  import * as path77 from "node:path";
75552
75889
  var EVIDENCE_DIR = ".swarm/evidence";
75553
75890
  function isValidTaskId3(taskId) {
@@ -75560,12 +75897,12 @@ function isPathWithinSwarm(filePath, workspaceRoot) {
75560
75897
  return normalizedPath.startsWith(swarmPath);
75561
75898
  }
75562
75899
  function readEvidenceFile(evidencePath) {
75563
- if (!fs55.existsSync(evidencePath)) {
75900
+ if (!fs56.existsSync(evidencePath)) {
75564
75901
  return null;
75565
75902
  }
75566
75903
  let content;
75567
75904
  try {
75568
- content = fs55.readFileSync(evidencePath, "utf-8");
75905
+ content = fs56.readFileSync(evidencePath, "utf-8");
75569
75906
  } catch {
75570
75907
  return null;
75571
75908
  }
@@ -75733,7 +76070,7 @@ init_utils2();
75733
76070
  init_state();
75734
76071
  init_create_tool();
75735
76072
  init_resolve_working_directory();
75736
- import * as fs56 from "node:fs";
76073
+ import * as fs57 from "node:fs";
75737
76074
  import * as path78 from "node:path";
75738
76075
  function extractMatches(regex, text) {
75739
76076
  return Array.from(text.matchAll(regex));
@@ -75828,7 +76165,7 @@ async function executeCompletionVerify(args2, directory) {
75828
76165
  let plan;
75829
76166
  try {
75830
76167
  const planPath = validateSwarmPath(directory, "plan.json");
75831
- const planRaw = fs56.readFileSync(planPath, "utf-8");
76168
+ const planRaw = fs57.readFileSync(planPath, "utf-8");
75832
76169
  plan = JSON.parse(planRaw);
75833
76170
  } catch {
75834
76171
  const result2 = {
@@ -75902,7 +76239,7 @@ async function executeCompletionVerify(args2, directory) {
75902
76239
  }
75903
76240
  let fileContent;
75904
76241
  try {
75905
- fileContent = fs56.readFileSync(resolvedPath, "utf-8");
76242
+ fileContent = fs57.readFileSync(resolvedPath, "utf-8");
75906
76243
  } catch {
75907
76244
  blockedTasks.push({
75908
76245
  task_id: task.id,
@@ -75946,7 +76283,7 @@ async function executeCompletionVerify(args2, directory) {
75946
76283
  try {
75947
76284
  const evidenceDir = path78.join(directory, ".swarm", "evidence", `${phase}`);
75948
76285
  const evidencePath = path78.join(evidenceDir, "completion-verify.json");
75949
- fs56.mkdirSync(evidenceDir, { recursive: true });
76286
+ fs57.mkdirSync(evidenceDir, { recursive: true });
75950
76287
  const evidenceBundle = {
75951
76288
  schema_version: "1.0.0",
75952
76289
  task_id: "completion-verify",
@@ -75967,7 +76304,7 @@ async function executeCompletionVerify(args2, directory) {
75967
76304
  }
75968
76305
  ]
75969
76306
  };
75970
- fs56.writeFileSync(evidencePath, JSON.stringify(evidenceBundle, null, 2), "utf-8");
76307
+ fs57.writeFileSync(evidencePath, JSON.stringify(evidenceBundle, null, 2), "utf-8");
75971
76308
  } catch {}
75972
76309
  return JSON.stringify(result, null, 2);
75973
76310
  }
@@ -76021,11 +76358,11 @@ var completion_verify = createSwarmTool({
76021
76358
  });
76022
76359
  // src/tools/complexity-hotspots.ts
76023
76360
  init_zod();
76024
- import * as fs58 from "node:fs";
76361
+ import * as fs59 from "node:fs";
76025
76362
  import * as path80 from "node:path";
76026
76363
 
76027
76364
  // src/quality/metrics.ts
76028
- import * as fs57 from "node:fs";
76365
+ import * as fs58 from "node:fs";
76029
76366
  import * as path79 from "node:path";
76030
76367
  var MAX_FILE_SIZE_BYTES4 = 256 * 1024;
76031
76368
  var MIN_DUPLICATION_LINES = 10;
@@ -76064,11 +76401,11 @@ function estimateCyclomaticComplexity(content) {
76064
76401
  }
76065
76402
  function getComplexityForFile(filePath) {
76066
76403
  try {
76067
- const stat7 = fs57.statSync(filePath);
76404
+ const stat7 = fs58.statSync(filePath);
76068
76405
  if (stat7.size > MAX_FILE_SIZE_BYTES4) {
76069
76406
  return null;
76070
76407
  }
76071
- const content = fs57.readFileSync(filePath, "utf-8");
76408
+ const content = fs58.readFileSync(filePath, "utf-8");
76072
76409
  return estimateCyclomaticComplexity(content);
76073
76410
  } catch {
76074
76411
  return null;
@@ -76079,7 +76416,7 @@ async function computeComplexityDelta(files, workingDir) {
76079
76416
  const analyzedFiles = [];
76080
76417
  for (const file3 of files) {
76081
76418
  const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
76082
- if (!fs57.existsSync(fullPath)) {
76419
+ if (!fs58.existsSync(fullPath)) {
76083
76420
  continue;
76084
76421
  }
76085
76422
  const complexity = getComplexityForFile(fullPath);
@@ -76200,7 +76537,7 @@ function countGoExports(content) {
76200
76537
  }
76201
76538
  function getExportCountForFile(filePath) {
76202
76539
  try {
76203
- const content = fs57.readFileSync(filePath, "utf-8");
76540
+ const content = fs58.readFileSync(filePath, "utf-8");
76204
76541
  const ext = path79.extname(filePath).toLowerCase();
76205
76542
  switch (ext) {
76206
76543
  case ".ts":
@@ -76228,7 +76565,7 @@ async function computePublicApiDelta(files, workingDir) {
76228
76565
  const analyzedFiles = [];
76229
76566
  for (const file3 of files) {
76230
76567
  const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
76231
- if (!fs57.existsSync(fullPath)) {
76568
+ if (!fs58.existsSync(fullPath)) {
76232
76569
  continue;
76233
76570
  }
76234
76571
  const exports = getExportCountForFile(fullPath);
@@ -76262,15 +76599,15 @@ async function computeDuplicationRatio(files, workingDir) {
76262
76599
  const analyzedFiles = [];
76263
76600
  for (const file3 of files) {
76264
76601
  const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
76265
- if (!fs57.existsSync(fullPath)) {
76602
+ if (!fs58.existsSync(fullPath)) {
76266
76603
  continue;
76267
76604
  }
76268
76605
  try {
76269
- const stat7 = fs57.statSync(fullPath);
76606
+ const stat7 = fs58.statSync(fullPath);
76270
76607
  if (stat7.size > MAX_FILE_SIZE_BYTES4) {
76271
76608
  continue;
76272
76609
  }
76273
- const content = fs57.readFileSync(fullPath, "utf-8");
76610
+ const content = fs58.readFileSync(fullPath, "utf-8");
76274
76611
  const lines = content.split(`
76275
76612
  `).filter((line) => line.trim().length > 0);
76276
76613
  if (lines.length < MIN_DUPLICATION_LINES) {
@@ -76446,7 +76783,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76446
76783
  let testLines = 0;
76447
76784
  let codeLines = 0;
76448
76785
  const srcDir = path79.join(workingDir, "src");
76449
- if (fs57.existsSync(srcDir)) {
76786
+ if (fs58.existsSync(srcDir)) {
76450
76787
  await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
76451
76788
  codeLines += lines;
76452
76789
  });
@@ -76454,14 +76791,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76454
76791
  const possibleSrcDirs = ["lib", "app", "source", "core"];
76455
76792
  for (const dir of possibleSrcDirs) {
76456
76793
  const dirPath = path79.join(workingDir, dir);
76457
- if (fs57.existsSync(dirPath)) {
76794
+ if (fs58.existsSync(dirPath)) {
76458
76795
  await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
76459
76796
  codeLines += lines;
76460
76797
  });
76461
76798
  }
76462
76799
  }
76463
76800
  const testsDir = path79.join(workingDir, "tests");
76464
- if (fs57.existsSync(testsDir)) {
76801
+ if (fs58.existsSync(testsDir)) {
76465
76802
  await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
76466
76803
  testLines += lines;
76467
76804
  });
@@ -76469,7 +76806,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76469
76806
  const possibleTestDirs = ["test", "__tests__", "specs"];
76470
76807
  for (const dir of possibleTestDirs) {
76471
76808
  const dirPath = path79.join(workingDir, dir);
76472
- if (fs57.existsSync(dirPath) && dirPath !== testsDir) {
76809
+ if (fs58.existsSync(dirPath) && dirPath !== testsDir) {
76473
76810
  await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
76474
76811
  testLines += lines;
76475
76812
  });
@@ -76481,7 +76818,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76481
76818
  }
76482
76819
  async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTestScan, callback) {
76483
76820
  try {
76484
- const entries = fs57.readdirSync(dirPath, { withFileTypes: true });
76821
+ const entries = fs58.readdirSync(dirPath, { withFileTypes: true });
76485
76822
  for (const entry of entries) {
76486
76823
  const fullPath = path79.join(dirPath, entry.name);
76487
76824
  if (entry.isDirectory()) {
@@ -76527,7 +76864,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
76527
76864
  continue;
76528
76865
  }
76529
76866
  try {
76530
- const content = fs57.readFileSync(fullPath, "utf-8");
76867
+ const content = fs58.readFileSync(fullPath, "utf-8");
76531
76868
  const lines = countCodeLines(content);
76532
76869
  callback(lines);
76533
76870
  } catch {}
@@ -76727,11 +77064,11 @@ async function getGitChurn(days, directory) {
76727
77064
  }
76728
77065
  function getComplexityForFile2(filePath) {
76729
77066
  try {
76730
- const stat7 = fs58.statSync(filePath);
77067
+ const stat7 = fs59.statSync(filePath);
76731
77068
  if (stat7.size > MAX_FILE_SIZE_BYTES5) {
76732
77069
  return null;
76733
77070
  }
76734
- const content = fs58.readFileSync(filePath, "utf-8");
77071
+ const content = fs59.readFileSync(filePath, "utf-8");
76735
77072
  return estimateCyclomaticComplexity(content);
76736
77073
  } catch {
76737
77074
  return null;
@@ -76752,7 +77089,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
76752
77089
  let analyzedFiles = 0;
76753
77090
  for (const [file3, churnCount] of filteredChurn) {
76754
77091
  let fullPath = file3;
76755
- if (!fs58.existsSync(fullPath)) {
77092
+ if (!fs59.existsSync(fullPath)) {
76756
77093
  fullPath = path80.join(cwd, file3);
76757
77094
  }
76758
77095
  const complexity = getComplexityForFile2(fullPath);
@@ -77013,7 +77350,7 @@ function writeCouncilEvidence(workingDir, synthesis) {
77013
77350
  }
77014
77351
 
77015
77352
  // src/council/council-service.ts
77016
- import fs59 from "node:fs";
77353
+ import fs60 from "node:fs";
77017
77354
  import path81 from "node:path";
77018
77355
 
77019
77356
  // src/council/types.ts
@@ -77175,7 +77512,7 @@ function synthesizePhaseCouncilAdvisory(phaseNumber, phaseSummary, verdicts, rou
77175
77512
  const evidencePath = `.swarm/evidence/${phaseNumber}/phase-council.json`;
77176
77513
  const baseDir = workingDir ?? process.cwd();
77177
77514
  const evidenceDir = path81.join(baseDir, ".swarm", "evidence", String(phaseNumber));
77178
- fs59.mkdirSync(evidenceDir, { recursive: true });
77515
+ fs60.mkdirSync(evidenceDir, { recursive: true });
77179
77516
  const evidenceFile = path81.join(evidenceDir, "phase-council.json");
77180
77517
  const evidenceBundle = {
77181
77518
  entries: [
@@ -77209,8 +77546,8 @@ function synthesizePhaseCouncilAdvisory(phaseNumber, phaseSummary, verdicts, rou
77209
77546
  };
77210
77547
  try {
77211
77548
  const tempFile = `${evidenceFile}.tmp-${Date.now()}`;
77212
- fs59.writeFileSync(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
77213
- fs59.renameSync(tempFile, evidenceFile);
77549
+ fs60.writeFileSync(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
77550
+ fs60.renameSync(tempFile, evidenceFile);
77214
77551
  } catch (writeErr) {
77215
77552
  console.warn(`[phase-council] Failed to write phase-council evidence to ${evidenceFile}: ${writeErr instanceof Error ? writeErr.message : String(writeErr)}`);
77216
77553
  }
@@ -77445,7 +77782,7 @@ var submit_council_verdicts = createSwarmTool({
77445
77782
  // src/tools/convene-general-council.ts
77446
77783
  init_zod();
77447
77784
  init_loader();
77448
- import * as fs60 from "node:fs";
77785
+ import * as fs61 from "node:fs";
77449
77786
  import * as path82 from "node:path";
77450
77787
 
77451
77788
  // src/council/general-council-advisory.ts
@@ -77879,8 +78216,8 @@ var convene_general_council = createSwarmTool({
77879
78216
  const evidenceFile = `${safeTimestamp}-${input.mode}.json`;
77880
78217
  const evidencePath = path82.join(evidenceDir, evidenceFile);
77881
78218
  try {
77882
- await fs60.promises.mkdir(evidenceDir, { recursive: true });
77883
- await fs60.promises.writeFile(evidencePath, JSON.stringify(result, null, 2));
78219
+ await fs61.promises.mkdir(evidenceDir, { recursive: true });
78220
+ await fs61.promises.writeFile(evidencePath, JSON.stringify(result, null, 2));
77884
78221
  } catch (err2) {
77885
78222
  const message = err2 instanceof Error ? err2.message : String(err2);
77886
78223
  console.warn(`[convene_general_council] Failed to write evidence to ${evidencePath}: ${message}`);
@@ -78111,7 +78448,7 @@ init_scope_persistence();
78111
78448
  init_state();
78112
78449
  init_task_id();
78113
78450
  init_create_tool();
78114
- import * as fs61 from "node:fs";
78451
+ import * as fs62 from "node:fs";
78115
78452
  import * as path83 from "node:path";
78116
78453
  function validateTaskIdFormat2(taskId) {
78117
78454
  return validateTaskIdFormat(taskId);
@@ -78199,9 +78536,9 @@ async function executeDeclareScope(args2, fallbackDir) {
78199
78536
  }
78200
78537
  const resolvedDir = path83.resolve(normalizedDir);
78201
78538
  try {
78202
- const realPath = fs61.realpathSync(resolvedDir);
78539
+ const realPath = fs62.realpathSync(resolvedDir);
78203
78540
  const planPath2 = path83.join(realPath, ".swarm", "plan.json");
78204
- if (!fs61.existsSync(planPath2)) {
78541
+ if (!fs62.existsSync(planPath2)) {
78205
78542
  return {
78206
78543
  success: false,
78207
78544
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -78225,7 +78562,7 @@ async function executeDeclareScope(args2, fallbackDir) {
78225
78562
  }
78226
78563
  const directory = normalizedDir || fallbackDir;
78227
78564
  const planPath = path83.resolve(directory, ".swarm", "plan.json");
78228
- if (!fs61.existsSync(planPath)) {
78565
+ if (!fs62.existsSync(planPath)) {
78229
78566
  return {
78230
78567
  success: false,
78231
78568
  message: "No plan found",
@@ -78234,7 +78571,7 @@ async function executeDeclareScope(args2, fallbackDir) {
78234
78571
  }
78235
78572
  let planContent;
78236
78573
  try {
78237
- planContent = JSON.parse(fs61.readFileSync(planPath, "utf-8"));
78574
+ planContent = JSON.parse(fs62.readFileSync(planPath, "utf-8"));
78238
78575
  } catch {
78239
78576
  return {
78240
78577
  success: false,
@@ -78325,7 +78662,7 @@ var declare_scope = createSwarmTool({
78325
78662
  // src/tools/diff.ts
78326
78663
  init_zod();
78327
78664
  import * as child_process7 from "node:child_process";
78328
- import * as fs62 from "node:fs";
78665
+ import * as fs63 from "node:fs";
78329
78666
  import * as path84 from "node:path";
78330
78667
  init_create_tool();
78331
78668
  var MAX_DIFF_LINES = 500;
@@ -78515,7 +78852,7 @@ var diff = createSwarmTool({
78515
78852
  } else if (base === "unstaged") {
78516
78853
  const oldRef = `:${file3.path}`;
78517
78854
  oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
78518
- newContent = fs62.readFileSync(path84.join(directory, file3.path), "utf-8");
78855
+ newContent = fs63.readFileSync(path84.join(directory, file3.path), "utf-8");
78519
78856
  } else {
78520
78857
  const oldRef = `${base}:${file3.path}`;
78521
78858
  oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
@@ -78589,7 +78926,7 @@ var diff = createSwarmTool({
78589
78926
  // src/tools/diff-summary.ts
78590
78927
  init_zod();
78591
78928
  import * as child_process8 from "node:child_process";
78592
- import * as fs63 from "node:fs";
78929
+ import * as fs64 from "node:fs";
78593
78930
  import * as path85 from "node:path";
78594
78931
  init_create_tool();
78595
78932
  var diff_summary = createSwarmTool({
@@ -78638,7 +78975,7 @@ var diff_summary = createSwarmTool({
78638
78975
  }
78639
78976
  try {
78640
78977
  let oldContent;
78641
- const newContent = fs63.readFileSync(path85.join(workingDir, filePath), "utf-8");
78978
+ const newContent = fs64.readFileSync(path85.join(workingDir, filePath), "utf-8");
78642
78979
  if (fileExistsInHead) {
78643
78980
  oldContent = child_process8.execFileSync("git", ["show", `HEAD:${filePath}`], {
78644
78981
  encoding: "utf-8",
@@ -78866,7 +79203,7 @@ Use these as DOMAIN values when delegating to @sme.`;
78866
79203
  init_zod();
78867
79204
  init_create_tool();
78868
79205
  init_path_security();
78869
- import * as fs64 from "node:fs";
79206
+ import * as fs65 from "node:fs";
78870
79207
  import * as path86 from "node:path";
78871
79208
  var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
78872
79209
  var MAX_EVIDENCE_FILES = 1000;
@@ -78912,12 +79249,12 @@ function parseCompletedTasks(planContent) {
78912
79249
  }
78913
79250
  function readEvidenceFiles(evidenceDir, _cwd) {
78914
79251
  const evidence = [];
78915
- if (!fs64.existsSync(evidenceDir) || !fs64.statSync(evidenceDir).isDirectory()) {
79252
+ if (!fs65.existsSync(evidenceDir) || !fs65.statSync(evidenceDir).isDirectory()) {
78916
79253
  return evidence;
78917
79254
  }
78918
79255
  let files;
78919
79256
  try {
78920
- files = fs64.readdirSync(evidenceDir);
79257
+ files = fs65.readdirSync(evidenceDir);
78921
79258
  } catch {
78922
79259
  return evidence;
78923
79260
  }
@@ -78933,7 +79270,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
78933
79270
  if (!resolvedPath.startsWith(evidenceDirResolved)) {
78934
79271
  continue;
78935
79272
  }
78936
- const stat7 = fs64.lstatSync(filePath);
79273
+ const stat7 = fs65.lstatSync(filePath);
78937
79274
  if (!stat7.isFile()) {
78938
79275
  continue;
78939
79276
  }
@@ -78942,7 +79279,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
78942
79279
  }
78943
79280
  let fileStat;
78944
79281
  try {
78945
- fileStat = fs64.statSync(filePath);
79282
+ fileStat = fs65.statSync(filePath);
78946
79283
  if (fileStat.size > MAX_FILE_SIZE_BYTES6) {
78947
79284
  continue;
78948
79285
  }
@@ -78951,7 +79288,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
78951
79288
  }
78952
79289
  let content;
78953
79290
  try {
78954
- content = fs64.readFileSync(filePath, "utf-8");
79291
+ content = fs65.readFileSync(filePath, "utf-8");
78955
79292
  } catch {
78956
79293
  continue;
78957
79294
  }
@@ -79061,7 +79398,7 @@ var evidence_check = createSwarmTool({
79061
79398
  }
79062
79399
  let planContent;
79063
79400
  try {
79064
- planContent = fs64.readFileSync(planPath, "utf-8");
79401
+ planContent = fs65.readFileSync(planPath, "utf-8");
79065
79402
  } catch {
79066
79403
  const result2 = {
79067
79404
  message: "No completed tasks found in plan.",
@@ -79096,7 +79433,7 @@ var evidence_check = createSwarmTool({
79096
79433
  // src/tools/file-extractor.ts
79097
79434
  init_zod();
79098
79435
  init_create_tool();
79099
- import * as fs65 from "node:fs";
79436
+ import * as fs66 from "node:fs";
79100
79437
  import * as path87 from "node:path";
79101
79438
  var EXT_MAP = {
79102
79439
  python: ".py",
@@ -79159,8 +79496,8 @@ var extract_code_blocks = createSwarmTool({
79159
79496
  execute: async (args2, directory) => {
79160
79497
  const { content, output_dir, prefix } = args2;
79161
79498
  const targetDir = output_dir || directory;
79162
- if (!fs65.existsSync(targetDir)) {
79163
- fs65.mkdirSync(targetDir, { recursive: true });
79499
+ if (!fs66.existsSync(targetDir)) {
79500
+ fs66.mkdirSync(targetDir, { recursive: true });
79164
79501
  }
79165
79502
  if (!content) {
79166
79503
  return "Error: content is required";
@@ -79182,12 +79519,12 @@ var extract_code_blocks = createSwarmTool({
79182
79519
  const base = path87.basename(filepath, path87.extname(filepath));
79183
79520
  const ext = path87.extname(filepath);
79184
79521
  let counter = 1;
79185
- while (fs65.existsSync(filepath)) {
79522
+ while (fs66.existsSync(filepath)) {
79186
79523
  filepath = path87.join(targetDir, `${base}_${counter}${ext}`);
79187
79524
  counter++;
79188
79525
  }
79189
79526
  try {
79190
- fs65.writeFileSync(filepath, code.trim(), "utf-8");
79527
+ fs66.writeFileSync(filepath, code.trim(), "utf-8");
79191
79528
  savedFiles.push(filepath);
79192
79529
  } catch (error93) {
79193
79530
  errors5.push(`Failed to save ${filename}: ${error93 instanceof Error ? error93.message : String(error93)}`);
@@ -79446,7 +79783,7 @@ var gitingest = createSwarmTool({
79446
79783
  init_zod();
79447
79784
  init_create_tool();
79448
79785
  init_path_security();
79449
- import * as fs66 from "node:fs";
79786
+ import * as fs67 from "node:fs";
79450
79787
  import * as path88 from "node:path";
79451
79788
  var MAX_FILE_PATH_LENGTH2 = 500;
79452
79789
  var MAX_SYMBOL_LENGTH = 256;
@@ -79609,7 +79946,7 @@ var SKIP_DIRECTORIES4 = new Set([
79609
79946
  function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFiles: 0, fileErrors: [] }) {
79610
79947
  let entries;
79611
79948
  try {
79612
- entries = fs66.readdirSync(dir);
79949
+ entries = fs67.readdirSync(dir);
79613
79950
  } catch (e) {
79614
79951
  stats.fileErrors.push({
79615
79952
  path: dir,
@@ -79626,7 +79963,7 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
79626
79963
  const fullPath = path88.join(dir, entry);
79627
79964
  let stat7;
79628
79965
  try {
79629
- stat7 = fs66.statSync(fullPath);
79966
+ stat7 = fs67.statSync(fullPath);
79630
79967
  } catch (e) {
79631
79968
  stats.fileErrors.push({
79632
79969
  path: fullPath,
@@ -79695,7 +80032,7 @@ var imports = createSwarmTool({
79695
80032
  }
79696
80033
  try {
79697
80034
  const targetFile = path88.resolve(file3);
79698
- if (!fs66.existsSync(targetFile)) {
80035
+ if (!fs67.existsSync(targetFile)) {
79699
80036
  const errorResult = {
79700
80037
  error: `target file not found: ${file3}`,
79701
80038
  target: file3,
@@ -79705,7 +80042,7 @@ var imports = createSwarmTool({
79705
80042
  };
79706
80043
  return JSON.stringify(errorResult, null, 2);
79707
80044
  }
79708
- const targetStat = fs66.statSync(targetFile);
80045
+ const targetStat = fs67.statSync(targetFile);
79709
80046
  if (!targetStat.isFile()) {
79710
80047
  const errorResult = {
79711
80048
  error: "target must be a file, not a directory",
@@ -79731,12 +80068,12 @@ var imports = createSwarmTool({
79731
80068
  if (consumers.length >= MAX_CONSUMERS)
79732
80069
  break;
79733
80070
  try {
79734
- const stat7 = fs66.statSync(filePath);
80071
+ const stat7 = fs67.statSync(filePath);
79735
80072
  if (stat7.size > MAX_FILE_SIZE_BYTES7) {
79736
80073
  skippedFileCount++;
79737
80074
  continue;
79738
80075
  }
79739
- const buffer = fs66.readFileSync(filePath);
80076
+ const buffer = fs67.readFileSync(filePath);
79740
80077
  if (isBinaryFile2(filePath, buffer)) {
79741
80078
  skippedFileCount++;
79742
80079
  continue;
@@ -80261,7 +80598,7 @@ init_schema();
80261
80598
  init_qa_gate_profile();
80262
80599
  init_manager2();
80263
80600
  init_curator();
80264
- import * as fs68 from "node:fs";
80601
+ import * as fs69 from "node:fs";
80265
80602
  import * as path90 from "node:path";
80266
80603
  init_knowledge_curator();
80267
80604
  init_knowledge_reader();
@@ -80274,7 +80611,7 @@ init_file_locks();
80274
80611
  init_plan_schema();
80275
80612
  init_ledger();
80276
80613
  init_manager();
80277
- import * as fs67 from "node:fs";
80614
+ import * as fs68 from "node:fs";
80278
80615
  import * as path89 from "node:path";
80279
80616
  async function writeCheckpoint(directory) {
80280
80617
  try {
@@ -80282,12 +80619,12 @@ async function writeCheckpoint(directory) {
80282
80619
  if (!plan)
80283
80620
  return;
80284
80621
  const swarmDir = path89.join(directory, ".swarm");
80285
- fs67.mkdirSync(swarmDir, { recursive: true });
80622
+ fs68.mkdirSync(swarmDir, { recursive: true });
80286
80623
  const jsonPath = path89.join(swarmDir, "SWARM_PLAN.json");
80287
80624
  const mdPath = path89.join(swarmDir, "SWARM_PLAN.md");
80288
- fs67.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
80625
+ fs68.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
80289
80626
  const md = derivePlanMarkdown(plan);
80290
- fs67.writeFileSync(mdPath, md, "utf8");
80627
+ fs68.writeFileSync(mdPath, md, "utf8");
80291
80628
  } catch (error93) {
80292
80629
  console.warn(`[checkpoint] Failed to write SWARM_PLAN checkpoint: ${error93 instanceof Error ? error93.message : String(error93)}`);
80293
80630
  }
@@ -80520,7 +80857,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80520
80857
  let driftHasSpecMd = false;
80521
80858
  try {
80522
80859
  const specMdPath = path90.join(dir, ".swarm", "spec.md");
80523
- driftHasSpecMd = fs68.existsSync(specMdPath);
80860
+ driftHasSpecMd = fs69.existsSync(specMdPath);
80524
80861
  const gatePlan = await loadPlan(dir);
80525
80862
  if (gatePlan) {
80526
80863
  const gatePlanId = `${gatePlan.swarm}-${gatePlan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
@@ -80542,8 +80879,8 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80542
80879
  let phaseType;
80543
80880
  try {
80544
80881
  const planPath = path90.join(dir, ".swarm", "plan.json");
80545
- if (fs68.existsSync(planPath)) {
80546
- const planRaw = fs68.readFileSync(planPath, "utf-8");
80882
+ if (fs69.existsSync(planPath)) {
80883
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
80547
80884
  const plan = JSON.parse(planRaw);
80548
80885
  const targetPhase = plan.phases?.find((p) => p.id === phase);
80549
80886
  phaseType = targetPhase?.type;
@@ -80558,7 +80895,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80558
80895
  let driftVerdictFound = false;
80559
80896
  let driftVerdictApproved = false;
80560
80897
  try {
80561
- const driftEvidenceContent = fs68.readFileSync(driftEvidencePath, "utf-8");
80898
+ const driftEvidenceContent = fs69.readFileSync(driftEvidencePath, "utf-8");
80562
80899
  const driftEvidence = JSON.parse(driftEvidenceContent);
80563
80900
  const entries = driftEvidence.entries ?? [];
80564
80901
  for (const entry of entries) {
@@ -80593,8 +80930,8 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80593
80930
  let planParseable = false;
80594
80931
  try {
80595
80932
  const planPath = path90.join(dir, ".swarm", "plan.json");
80596
- if (fs68.existsSync(planPath)) {
80597
- const planRaw = fs68.readFileSync(planPath, "utf-8");
80933
+ if (fs69.existsSync(planPath)) {
80934
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
80598
80935
  const plan = JSON.parse(planRaw);
80599
80936
  planParseable = true;
80600
80937
  const planPhase = plan.phases?.find((p) => p.id === phase);
@@ -80663,7 +81000,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80663
81000
  let hgVerdictFound = false;
80664
81001
  let hgVerdictApproved = false;
80665
81002
  try {
80666
- const hgContent = fs68.readFileSync(hgPath, "utf-8");
81003
+ const hgContent = fs69.readFileSync(hgPath, "utf-8");
80667
81004
  const hgBundle = JSON.parse(hgContent);
80668
81005
  for (const entry of hgBundle.entries ?? []) {
80669
81006
  if (typeof entry.type === "string" && entry.type.includes("hallucination") && typeof entry.verdict === "string") {
@@ -80735,7 +81072,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80735
81072
  let mgVerdictFound = false;
80736
81073
  let mgVerdict;
80737
81074
  try {
80738
- const mgContent = fs68.readFileSync(mgPath, "utf-8");
81075
+ const mgContent = fs69.readFileSync(mgPath, "utf-8");
80739
81076
  const mgBundle = JSON.parse(mgContent);
80740
81077
  for (const entry of mgBundle.entries ?? []) {
80741
81078
  if (typeof entry.type === "string" && entry.type === "mutation-gate" && typeof entry.verdict === "string") {
@@ -80812,7 +81149,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80812
81149
  let pcTimestamp;
80813
81150
  let pcPhaseNumber;
80814
81151
  try {
80815
- const pcContent = fs68.readFileSync(pcPath, "utf-8");
81152
+ const pcContent = fs69.readFileSync(pcPath, "utf-8");
80816
81153
  const pcBundle = JSON.parse(pcContent);
80817
81154
  for (const entry of pcBundle.entries ?? []) {
80818
81155
  if (typeof entry.type === "string" && entry.type === "phase-council" && typeof entry.verdict === "string") {
@@ -81087,7 +81424,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81087
81424
  let phaseRequiredAgents;
81088
81425
  try {
81089
81426
  const planPath = validateSwarmPath(dir, "plan.json");
81090
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81427
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81091
81428
  const plan = JSON.parse(planRaw);
81092
81429
  const phaseObj = plan.phases.find((p) => p.id === phase);
81093
81430
  phaseRequiredAgents = phaseObj?.required_agents;
@@ -81102,7 +81439,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81102
81439
  if (agentsMissing.length > 0) {
81103
81440
  try {
81104
81441
  const planPath = validateSwarmPath(dir, "plan.json");
81105
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81442
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81106
81443
  const plan = JSON.parse(planRaw);
81107
81444
  const targetPhase = plan.phases.find((p) => p.id === phase);
81108
81445
  if (targetPhase && targetPhase.tasks.length > 0 && targetPhase.tasks.every((t) => t.status === "completed")) {
@@ -81142,7 +81479,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81142
81479
  if (phaseCompleteConfig.regression_sweep?.enforce) {
81143
81480
  try {
81144
81481
  const planPath = validateSwarmPath(dir, "plan.json");
81145
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81482
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81146
81483
  const plan = JSON.parse(planRaw);
81147
81484
  const targetPhase = plan.phases.find((p) => p.id === phase);
81148
81485
  if (targetPhase) {
@@ -81196,7 +81533,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81196
81533
  }
81197
81534
  try {
81198
81535
  const eventsPath = validateSwarmPath(dir, "events.jsonl");
81199
- fs68.appendFileSync(eventsPath, `${JSON.stringify(event)}
81536
+ fs69.appendFileSync(eventsPath, `${JSON.stringify(event)}
81200
81537
  `, "utf-8");
81201
81538
  } catch (writeError) {
81202
81539
  warnings.push(`Warning: failed to write phase complete event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
@@ -81271,12 +81608,12 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81271
81608
  warnings.push(`Warning: failed to update plan.json phase status`);
81272
81609
  try {
81273
81610
  const planPath = validateSwarmPath(dir, "plan.json");
81274
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81611
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81275
81612
  const plan2 = JSON.parse(planRaw);
81276
81613
  const phaseObj = plan2.phases.find((p) => p.id === phase);
81277
81614
  if (phaseObj) {
81278
81615
  phaseObj.status = "complete";
81279
- fs68.writeFileSync(planPath, JSON.stringify(plan2, null, 2), "utf-8");
81616
+ fs69.writeFileSync(planPath, JSON.stringify(plan2, null, 2), "utf-8");
81280
81617
  }
81281
81618
  } catch {}
81282
81619
  } else if (plan) {
@@ -81313,12 +81650,12 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81313
81650
  warnings.push(`Warning: failed to update plan.json phase status`);
81314
81651
  try {
81315
81652
  const planPath = validateSwarmPath(dir, "plan.json");
81316
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81653
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81317
81654
  const plan = JSON.parse(planRaw);
81318
81655
  const phaseObj = plan.phases.find((p) => p.id === phase);
81319
81656
  if (phaseObj) {
81320
81657
  phaseObj.status = "complete";
81321
- fs68.writeFileSync(planPath, JSON.stringify(plan, null, 2), "utf-8");
81658
+ fs69.writeFileSync(planPath, JSON.stringify(plan, null, 2), "utf-8");
81322
81659
  }
81323
81660
  } catch {}
81324
81661
  }
@@ -81376,7 +81713,7 @@ init_discovery();
81376
81713
  init_utils();
81377
81714
  init_bun_compat();
81378
81715
  init_create_tool();
81379
- import * as fs69 from "node:fs";
81716
+ import * as fs70 from "node:fs";
81380
81717
  import * as path91 from "node:path";
81381
81718
  var MAX_OUTPUT_BYTES5 = 52428800;
81382
81719
  var AUDIT_TIMEOUT_MS = 120000;
@@ -81405,31 +81742,31 @@ function validateArgs3(args2) {
81405
81742
  function detectEcosystems(directory) {
81406
81743
  const ecosystems = [];
81407
81744
  const cwd = directory;
81408
- if (fs69.existsSync(path91.join(cwd, "package.json"))) {
81745
+ if (fs70.existsSync(path91.join(cwd, "package.json"))) {
81409
81746
  ecosystems.push("npm");
81410
81747
  }
81411
- if (fs69.existsSync(path91.join(cwd, "pyproject.toml")) || fs69.existsSync(path91.join(cwd, "requirements.txt"))) {
81748
+ if (fs70.existsSync(path91.join(cwd, "pyproject.toml")) || fs70.existsSync(path91.join(cwd, "requirements.txt"))) {
81412
81749
  ecosystems.push("pip");
81413
81750
  }
81414
- if (fs69.existsSync(path91.join(cwd, "Cargo.toml"))) {
81751
+ if (fs70.existsSync(path91.join(cwd, "Cargo.toml"))) {
81415
81752
  ecosystems.push("cargo");
81416
81753
  }
81417
- if (fs69.existsSync(path91.join(cwd, "go.mod"))) {
81754
+ if (fs70.existsSync(path91.join(cwd, "go.mod"))) {
81418
81755
  ecosystems.push("go");
81419
81756
  }
81420
81757
  try {
81421
- const files = fs69.readdirSync(cwd);
81758
+ const files = fs70.readdirSync(cwd);
81422
81759
  if (files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
81423
81760
  ecosystems.push("dotnet");
81424
81761
  }
81425
81762
  } catch {}
81426
- if (fs69.existsSync(path91.join(cwd, "Gemfile")) || fs69.existsSync(path91.join(cwd, "Gemfile.lock"))) {
81763
+ if (fs70.existsSync(path91.join(cwd, "Gemfile")) || fs70.existsSync(path91.join(cwd, "Gemfile.lock"))) {
81427
81764
  ecosystems.push("ruby");
81428
81765
  }
81429
- if (fs69.existsSync(path91.join(cwd, "pubspec.yaml"))) {
81766
+ if (fs70.existsSync(path91.join(cwd, "pubspec.yaml"))) {
81430
81767
  ecosystems.push("dart");
81431
81768
  }
81432
- if (fs69.existsSync(path91.join(cwd, "composer.lock"))) {
81769
+ if (fs70.existsSync(path91.join(cwd, "composer.lock"))) {
81433
81770
  ecosystems.push("composer");
81434
81771
  }
81435
81772
  return ecosystems;
@@ -82564,7 +82901,7 @@ var pkg_audit = createSwarmTool({
82564
82901
  // src/tools/placeholder-scan.ts
82565
82902
  init_zod();
82566
82903
  init_manager2();
82567
- import * as fs70 from "node:fs";
82904
+ import * as fs71 from "node:fs";
82568
82905
  import * as path92 from "node:path";
82569
82906
  init_utils();
82570
82907
  init_create_tool();
@@ -82966,7 +83303,7 @@ async function placeholderScan(input, directory) {
82966
83303
  if (!fullPath.startsWith(resolvedDirectory + path92.sep) && fullPath !== resolvedDirectory) {
82967
83304
  continue;
82968
83305
  }
82969
- if (!fs70.existsSync(fullPath)) {
83306
+ if (!fs71.existsSync(fullPath)) {
82970
83307
  continue;
82971
83308
  }
82972
83309
  if (isAllowedByGlobs(filePath, allow_globs)) {
@@ -82978,11 +83315,11 @@ async function placeholderScan(input, directory) {
82978
83315
  }
82979
83316
  let content;
82980
83317
  try {
82981
- const stat7 = fs70.statSync(fullPath);
83318
+ const stat7 = fs71.statSync(fullPath);
82982
83319
  if (stat7.size > MAX_FILE_SIZE) {
82983
83320
  continue;
82984
83321
  }
82985
- content = fs70.readFileSync(fullPath, "utf-8");
83322
+ content = fs71.readFileSync(fullPath, "utf-8");
82986
83323
  } catch {
82987
83324
  continue;
82988
83325
  }
@@ -83043,8 +83380,8 @@ var placeholder_scan = createSwarmTool({
83043
83380
  }
83044
83381
  });
83045
83382
  // src/tools/pre-check-batch.ts
83046
- import * as fs73 from "node:fs";
83047
- import * as path95 from "node:path";
83383
+ import * as fs75 from "node:fs";
83384
+ import * as path96 from "node:path";
83048
83385
  init_zod();
83049
83386
  init_manager2();
83050
83387
  init_utils();
@@ -83172,17 +83509,20 @@ var quality_budget = createSwarmTool({
83172
83509
  }).optional().describe("Quality budget thresholds")
83173
83510
  },
83174
83511
  async execute(args2, directory) {
83175
- const result = await qualityBudget(args2, directory);
83512
+ const result = await _internals28.qualityBudget(args2, directory);
83176
83513
  return JSON.stringify(result);
83177
83514
  }
83178
83515
  });
83516
+ var _internals28 = {
83517
+ qualityBudget
83518
+ };
83179
83519
 
83180
83520
  // src/tools/sast-scan.ts
83181
83521
  init_zod();
83182
83522
  init_manager2();
83183
83523
  init_detector();
83184
- import * as fs72 from "node:fs";
83185
- import * as path94 from "node:path";
83524
+ import * as fs74 from "node:fs";
83525
+ import * as path95 from "node:path";
83186
83526
  import { extname as extname18 } from "node:path";
83187
83527
 
83188
83528
  // src/sast/rules/c.ts
@@ -83897,9 +84237,19 @@ function executeRulesSync(filePath, content, language) {
83897
84237
 
83898
84238
  // src/sast/semgrep.ts
83899
84239
  import * as child_process9 from "node:child_process";
84240
+ import * as fs72 from "node:fs";
84241
+ import * as path93 from "node:path";
83900
84242
  var semgrepAvailableCache = null;
83901
84243
  var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
83902
84244
  var DEFAULT_TIMEOUT_MS3 = 30000;
84245
+ var _internals29 = {
84246
+ isSemgrepAvailable,
84247
+ checkSemgrepAvailable,
84248
+ resetSemgrepCache,
84249
+ runSemgrep,
84250
+ getRulesDirectory,
84251
+ hasBundledRules
84252
+ };
83903
84253
  function isSemgrepAvailable() {
83904
84254
  if (semgrepAvailableCache !== null) {
83905
84255
  return semgrepAvailableCache;
@@ -83916,6 +84266,12 @@ function isSemgrepAvailable() {
83916
84266
  return false;
83917
84267
  }
83918
84268
  }
84269
+ async function checkSemgrepAvailable() {
84270
+ return _internals29.isSemgrepAvailable();
84271
+ }
84272
+ function resetSemgrepCache() {
84273
+ semgrepAvailableCache = null;
84274
+ }
83919
84275
  function parseSemgrepResults(semgrepOutput) {
83920
84276
  const findings = [];
83921
84277
  try {
@@ -83963,7 +84319,7 @@ function mapSemgrepSeverity(severity) {
83963
84319
  }
83964
84320
  }
83965
84321
  async function executeWithTimeout(command, args2, options) {
83966
- return new Promise((resolve33) => {
84322
+ return new Promise((resolve34) => {
83967
84323
  const child = child_process9.spawn(command, args2, {
83968
84324
  shell: false,
83969
84325
  cwd: options.cwd
@@ -83972,7 +84328,7 @@ async function executeWithTimeout(command, args2, options) {
83972
84328
  let stderr = "";
83973
84329
  const timeout = setTimeout(() => {
83974
84330
  child.kill("SIGTERM");
83975
- resolve33({
84331
+ resolve34({
83976
84332
  stdout,
83977
84333
  stderr: "Process timed out",
83978
84334
  exitCode: 124
@@ -83986,7 +84342,7 @@ async function executeWithTimeout(command, args2, options) {
83986
84342
  });
83987
84343
  child.on("close", (code) => {
83988
84344
  clearTimeout(timeout);
83989
- resolve33({
84345
+ resolve34({
83990
84346
  stdout,
83991
84347
  stderr,
83992
84348
  exitCode: code ?? 0
@@ -83994,7 +84350,7 @@ async function executeWithTimeout(command, args2, options) {
83994
84350
  });
83995
84351
  child.on("error", (err2) => {
83996
84352
  clearTimeout(timeout);
83997
- resolve33({
84353
+ resolve34({
83998
84354
  stdout,
83999
84355
  stderr: err2.message,
84000
84356
  exitCode: 1
@@ -84008,12 +84364,12 @@ async function runSemgrep(options) {
84008
84364
  const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS3;
84009
84365
  if (files.length === 0) {
84010
84366
  return {
84011
- available: isSemgrepAvailable(),
84367
+ available: _internals29.isSemgrepAvailable(),
84012
84368
  findings: [],
84013
84369
  engine: "tier_a"
84014
84370
  };
84015
84371
  }
84016
- if (!isSemgrepAvailable()) {
84372
+ if (!_internals29.isSemgrepAvailable()) {
84017
84373
  return {
84018
84374
  available: false,
84019
84375
  findings: [],
@@ -84067,6 +84423,20 @@ async function runSemgrep(options) {
84067
84423
  };
84068
84424
  }
84069
84425
  }
84426
+ function getRulesDirectory(projectRoot) {
84427
+ if (projectRoot) {
84428
+ return path93.resolve(projectRoot, DEFAULT_RULES_DIR);
84429
+ }
84430
+ return DEFAULT_RULES_DIR;
84431
+ }
84432
+ function hasBundledRules(projectRoot) {
84433
+ const rulesDir = getRulesDirectory(projectRoot);
84434
+ try {
84435
+ return fs72.existsSync(rulesDir);
84436
+ } catch {
84437
+ return false;
84438
+ }
84439
+ }
84070
84440
 
84071
84441
  // src/tools/sast-scan.ts
84072
84442
  init_utils();
@@ -84074,26 +84444,26 @@ init_create_tool();
84074
84444
 
84075
84445
  // src/tools/sast-baseline.ts
84076
84446
  init_utils2();
84077
- import * as crypto8 from "node:crypto";
84078
- import * as fs71 from "node:fs";
84079
- import * as path93 from "node:path";
84447
+ import * as crypto9 from "node:crypto";
84448
+ import * as fs73 from "node:fs";
84449
+ import * as path94 from "node:path";
84080
84450
  var BASELINE_SCHEMA_VERSION = "1.0.0";
84081
84451
  var MAX_BASELINE_FINDINGS = 2000;
84082
84452
  var MAX_BASELINE_BYTES = 2 * 1048576;
84083
84453
  var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
84084
84454
  function normalizeFindingPath(directory, file3) {
84085
- const resolved = path93.isAbsolute(file3) ? file3 : path93.resolve(directory, file3);
84086
- const rel = path93.relative(path93.resolve(directory), resolved);
84455
+ const resolved = path94.isAbsolute(file3) ? file3 : path94.resolve(directory, file3);
84456
+ const rel = path94.relative(path94.resolve(directory), resolved);
84087
84457
  return rel.replace(/\\/g, "/");
84088
84458
  }
84089
84459
  function baselineRelPath(phase) {
84090
- return path93.join("evidence", String(phase), "sast-baseline.json");
84460
+ return path94.join("evidence", String(phase), "sast-baseline.json");
84091
84461
  }
84092
84462
  function tempRelPath(phase) {
84093
- return path93.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
84463
+ return path94.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
84094
84464
  }
84095
84465
  function lockRelPath(phase) {
84096
- return path93.join("evidence", String(phase), "sast-baseline.json.lock");
84466
+ return path94.join("evidence", String(phase), "sast-baseline.json.lock");
84097
84467
  }
84098
84468
  function getLine(lines, idx) {
84099
84469
  if (idx < 0 || idx >= lines.length)
@@ -84110,7 +84480,7 @@ function fingerprintFinding(finding, directory, occurrenceIndex) {
84110
84480
  }
84111
84481
  const lineNum = finding.location.line;
84112
84482
  try {
84113
- const content = fs71.readFileSync(finding.location.file, "utf-8");
84483
+ const content = fs73.readFileSync(finding.location.file, "utf-8");
84114
84484
  const lines = content.split(`
84115
84485
  `);
84116
84486
  const idx = lineNum - 1;
@@ -84120,7 +84490,7 @@ function fingerprintFinding(finding, directory, occurrenceIndex) {
84120
84490
  getLine(lines, idx + 1)
84121
84491
  ].join(`
84122
84492
  `);
84123
- const hash3 = crypto8.createHash("sha256").update(window2).digest("hex").slice(0, 16);
84493
+ const hash3 = crypto9.createHash("sha256").update(window2).digest("hex").slice(0, 16);
84124
84494
  return {
84125
84495
  fingerprint: `${relFile}|${finding.rule_id}|${hash3}|#${occurrenceIndex}`,
84126
84496
  stable: true
@@ -84141,7 +84511,7 @@ function assignOccurrenceIndices(findings, directory) {
84141
84511
  try {
84142
84512
  if (relFile.startsWith(".."))
84143
84513
  throw new Error("escapes workspace");
84144
- const content = fs71.readFileSync(finding.location.file, "utf-8");
84514
+ const content = fs73.readFileSync(finding.location.file, "utf-8");
84145
84515
  const lines = content.split(`
84146
84516
  `);
84147
84517
  const idx = lineNum - 1;
@@ -84151,14 +84521,14 @@ function assignOccurrenceIndices(findings, directory) {
84151
84521
  getLine(lines, idx + 1)
84152
84522
  ].join(`
84153
84523
  `);
84154
- const hash3 = crypto8.createHash("sha256").update(window2).digest("hex").slice(0, 16);
84524
+ const hash3 = crypto9.createHash("sha256").update(window2).digest("hex").slice(0, 16);
84155
84525
  baseKey = `${relFile}|${finding.rule_id}|${hash3}`;
84156
84526
  } catch {
84157
84527
  baseKey = `${relFile}|${finding.rule_id}|L${lineNum}|UNSTABLE`;
84158
84528
  }
84159
84529
  const occIdx = countMap.get(baseKey) ?? 0;
84160
84530
  countMap.set(baseKey, occIdx + 1);
84161
- const fp = fingerprintFinding(finding, directory, occIdx);
84531
+ const fp = _internals30.fingerprintFinding(finding, directory, occIdx);
84162
84532
  return {
84163
84533
  finding,
84164
84534
  index: occIdx,
@@ -84170,16 +84540,16 @@ function assignOccurrenceIndices(findings, directory) {
84170
84540
  async function acquireLock(lockPath) {
84171
84541
  for (let attempt = 0;attempt <= LOCK_RETRY_DELAYS_MS.length; attempt++) {
84172
84542
  try {
84173
- const fd = fs71.openSync(lockPath, "wx");
84174
- fs71.closeSync(fd);
84543
+ const fd = fs73.openSync(lockPath, "wx");
84544
+ fs73.closeSync(fd);
84175
84545
  return () => {
84176
84546
  try {
84177
- fs71.unlinkSync(lockPath);
84547
+ fs73.unlinkSync(lockPath);
84178
84548
  } catch {}
84179
84549
  };
84180
84550
  } catch {
84181
84551
  if (attempt < LOCK_RETRY_DELAYS_MS.length) {
84182
- await new Promise((resolve34) => setTimeout(resolve34, LOCK_RETRY_DELAYS_MS[attempt]));
84552
+ await new Promise((resolve35) => setTimeout(resolve35, LOCK_RETRY_DELAYS_MS[attempt]));
84183
84553
  }
84184
84554
  }
84185
84555
  }
@@ -84214,20 +84584,20 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
84214
84584
  message: e instanceof Error ? e.message : "Path validation failed"
84215
84585
  };
84216
84586
  }
84217
- fs71.mkdirSync(path93.dirname(baselinePath), { recursive: true });
84218
- fs71.mkdirSync(path93.dirname(tempPath), { recursive: true });
84587
+ fs73.mkdirSync(path94.dirname(baselinePath), { recursive: true });
84588
+ fs73.mkdirSync(path94.dirname(tempPath), { recursive: true });
84219
84589
  const releaseLock = await acquireLock(lockPath);
84220
84590
  try {
84221
84591
  let existing = null;
84222
84592
  try {
84223
- const raw = fs71.readFileSync(baselinePath, "utf-8");
84593
+ const raw = fs73.readFileSync(baselinePath, "utf-8");
84224
84594
  const parsed = JSON.parse(raw);
84225
84595
  if (parsed.schema_version === BASELINE_SCHEMA_VERSION) {
84226
84596
  existing = parsed;
84227
84597
  }
84228
84598
  } catch {}
84229
84599
  const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
84230
- const indexed = assignOccurrenceIndices(findings, directory);
84600
+ const indexed = _internals30.assignOccurrenceIndices(findings, directory);
84231
84601
  if (existing && !opts?.force) {
84232
84602
  const prunedFingerprints = existing.fingerprints.filter((fp) => {
84233
84603
  const relFile = fp.slice(0, fp.indexOf("|"));
@@ -84280,8 +84650,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
84280
84650
  message: `Baseline would exceed size cap (${json4.length} bytes > ${MAX_BASELINE_BYTES})`
84281
84651
  };
84282
84652
  }
84283
- fs71.writeFileSync(tempPath, json4, "utf-8");
84284
- fs71.renameSync(tempPath, baselinePath);
84653
+ fs73.writeFileSync(tempPath, json4, "utf-8");
84654
+ fs73.renameSync(tempPath, baselinePath);
84285
84655
  return {
84286
84656
  status: "merged",
84287
84657
  path: baselinePath,
@@ -84312,8 +84682,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
84312
84682
  message: `Baseline would exceed size cap (${json3.length} bytes > ${MAX_BASELINE_BYTES})`
84313
84683
  };
84314
84684
  }
84315
- fs71.writeFileSync(tempPath, json3, "utf-8");
84316
- fs71.renameSync(tempPath, baselinePath);
84685
+ fs73.writeFileSync(tempPath, json3, "utf-8");
84686
+ fs73.renameSync(tempPath, baselinePath);
84317
84687
  return {
84318
84688
  status: "written",
84319
84689
  path: baselinePath,
@@ -84338,7 +84708,7 @@ function loadBaseline(directory, phase) {
84338
84708
  };
84339
84709
  }
84340
84710
  try {
84341
- const raw = fs71.readFileSync(baselinePath, "utf-8");
84711
+ const raw = fs73.readFileSync(baselinePath, "utf-8");
84342
84712
  const parsed = JSON.parse(raw);
84343
84713
  if (parsed.schema_version !== BASELINE_SCHEMA_VERSION) {
84344
84714
  return {
@@ -84367,6 +84737,12 @@ function loadBaseline(directory, phase) {
84367
84737
  };
84368
84738
  }
84369
84739
  }
84740
+ var _internals30 = {
84741
+ fingerprintFinding,
84742
+ assignOccurrenceIndices,
84743
+ captureOrMergeBaseline,
84744
+ loadBaseline
84745
+ };
84370
84746
 
84371
84747
  // src/tools/sast-scan.ts
84372
84748
  var MAX_FILE_SIZE_BYTES8 = 512 * 1024;
@@ -84380,17 +84756,17 @@ var SEVERITY_ORDER = {
84380
84756
  };
84381
84757
  function shouldSkipFile(filePath) {
84382
84758
  try {
84383
- const stats = fs72.statSync(filePath);
84759
+ const stats = fs74.statSync(filePath);
84384
84760
  if (stats.size > MAX_FILE_SIZE_BYTES8) {
84385
84761
  return { skip: true, reason: "file too large" };
84386
84762
  }
84387
84763
  if (stats.size === 0) {
84388
84764
  return { skip: true, reason: "empty file" };
84389
84765
  }
84390
- const fd = fs72.openSync(filePath, "r");
84766
+ const fd = fs74.openSync(filePath, "r");
84391
84767
  const buffer = Buffer.alloc(8192);
84392
- const bytesRead = fs72.readSync(fd, buffer, 0, 8192, 0);
84393
- fs72.closeSync(fd);
84768
+ const bytesRead = fs74.readSync(fd, buffer, 0, 8192, 0);
84769
+ fs74.closeSync(fd);
84394
84770
  if (bytesRead > 0) {
84395
84771
  let nullCount = 0;
84396
84772
  for (let i2 = 0;i2 < bytesRead; i2++) {
@@ -84429,7 +84805,7 @@ function countBySeverity(findings) {
84429
84805
  }
84430
84806
  function scanFileWithTierA(filePath, language) {
84431
84807
  try {
84432
- const content = fs72.readFileSync(filePath, "utf-8");
84808
+ const content = fs74.readFileSync(filePath, "utf-8");
84433
84809
  const findings = executeRulesSync(filePath, content, language);
84434
84810
  return findings.map((f) => ({
84435
84811
  rule_id: f.rule_id,
@@ -84482,13 +84858,13 @@ async function sastScan(input, directory, config3) {
84482
84858
  _filesSkipped++;
84483
84859
  continue;
84484
84860
  }
84485
- const resolvedPath = path94.isAbsolute(filePath) ? filePath : path94.resolve(directory, filePath);
84486
- const resolvedDirectory = path94.resolve(directory);
84487
- if (!resolvedPath.startsWith(resolvedDirectory + path94.sep) && resolvedPath !== resolvedDirectory) {
84861
+ const resolvedPath = path95.isAbsolute(filePath) ? filePath : path95.resolve(directory, filePath);
84862
+ const resolvedDirectory = path95.resolve(directory);
84863
+ if (!resolvedPath.startsWith(resolvedDirectory + path95.sep) && resolvedPath !== resolvedDirectory) {
84488
84864
  _filesSkipped++;
84489
84865
  continue;
84490
84866
  }
84491
- if (!fs72.existsSync(resolvedPath)) {
84867
+ if (!fs74.existsSync(resolvedPath)) {
84492
84868
  _filesSkipped++;
84493
84869
  continue;
84494
84870
  }
@@ -84771,10 +85147,14 @@ var sast_scan = createSwarmTool({
84771
85147
  capture_baseline: safeArgs.capture_baseline,
84772
85148
  phase: safeArgs.phase
84773
85149
  };
84774
- const result = await sastScan(input, directory);
85150
+ const result = await _internals31.sastScan(input, directory);
84775
85151
  return JSON.stringify(result, null, 2);
84776
85152
  }
84777
85153
  });
85154
+ var _internals31 = {
85155
+ sastScan,
85156
+ sast_scan
85157
+ };
84778
85158
 
84779
85159
  // src/tools/pre-check-batch.ts
84780
85160
  init_secretscan();
@@ -84795,18 +85175,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
84795
85175
  let resolved;
84796
85176
  const isWinAbs = isWindowsAbsolutePath(inputPath);
84797
85177
  if (isWinAbs) {
84798
- resolved = path95.win32.resolve(inputPath);
84799
- } else if (path95.isAbsolute(inputPath)) {
84800
- resolved = path95.resolve(inputPath);
85178
+ resolved = path96.win32.resolve(inputPath);
85179
+ } else if (path96.isAbsolute(inputPath)) {
85180
+ resolved = path96.resolve(inputPath);
84801
85181
  } else {
84802
- resolved = path95.resolve(baseDir, inputPath);
85182
+ resolved = path96.resolve(baseDir, inputPath);
84803
85183
  }
84804
- const workspaceResolved = path95.resolve(workspaceDir);
85184
+ const workspaceResolved = path96.resolve(workspaceDir);
84805
85185
  let relative20;
84806
85186
  if (isWinAbs) {
84807
- relative20 = path95.win32.relative(workspaceResolved, resolved);
85187
+ relative20 = path96.win32.relative(workspaceResolved, resolved);
84808
85188
  } else {
84809
- relative20 = path95.relative(workspaceResolved, resolved);
85189
+ relative20 = path96.relative(workspaceResolved, resolved);
84810
85190
  }
84811
85191
  if (relative20.startsWith("..")) {
84812
85192
  return "path traversal detected";
@@ -84871,7 +85251,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
84871
85251
  if (typeof file3 !== "string") {
84872
85252
  continue;
84873
85253
  }
84874
- const resolvedPath = path95.resolve(file3);
85254
+ const resolvedPath = path96.resolve(file3);
84875
85255
  const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
84876
85256
  if (validationError) {
84877
85257
  continue;
@@ -85028,7 +85408,7 @@ async function runSecretscanWithFiles(files, directory) {
85028
85408
  skippedFiles++;
85029
85409
  continue;
85030
85410
  }
85031
- const resolvedPath = path95.resolve(file3);
85411
+ const resolvedPath = path96.resolve(file3);
85032
85412
  const validationError = validatePath(resolvedPath, directory, directory);
85033
85413
  if (validationError) {
85034
85414
  skippedFiles++;
@@ -85046,14 +85426,14 @@ async function runSecretscanWithFiles(files, directory) {
85046
85426
  };
85047
85427
  }
85048
85428
  for (const file3 of validatedFiles) {
85049
- const ext = path95.extname(file3).toLowerCase();
85429
+ const ext = path96.extname(file3).toLowerCase();
85050
85430
  if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
85051
85431
  skippedFiles++;
85052
85432
  continue;
85053
85433
  }
85054
85434
  let stat7;
85055
85435
  try {
85056
- stat7 = fs73.statSync(file3);
85436
+ stat7 = fs75.statSync(file3);
85057
85437
  } catch {
85058
85438
  skippedFiles++;
85059
85439
  continue;
@@ -85064,7 +85444,7 @@ async function runSecretscanWithFiles(files, directory) {
85064
85444
  }
85065
85445
  let content;
85066
85446
  try {
85067
- const buffer = fs73.readFileSync(file3);
85447
+ const buffer = fs75.readFileSync(file3);
85068
85448
  if (buffer.includes(0)) {
85069
85449
  skippedFiles++;
85070
85450
  continue;
@@ -85265,7 +85645,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
85265
85645
  const preexistingFindings = [];
85266
85646
  for (const finding of findings) {
85267
85647
  const filePath = finding.location.file;
85268
- const normalised = path95.relative(directory, filePath).replace(/\\/g, "/");
85648
+ const normalised = path96.relative(directory, filePath).replace(/\\/g, "/");
85269
85649
  const changedLines = changedLineRanges.get(normalised);
85270
85650
  if (changedLines?.has(finding.location.line)) {
85271
85651
  newFindings.push(finding);
@@ -85316,7 +85696,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
85316
85696
  warn(`pre_check_batch: Invalid file path: ${file3}`);
85317
85697
  continue;
85318
85698
  }
85319
- changedFiles.push(path95.resolve(directory, file3));
85699
+ changedFiles.push(path96.resolve(directory, file3));
85320
85700
  }
85321
85701
  if (changedFiles.length === 0) {
85322
85702
  warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
@@ -85517,7 +85897,7 @@ var pre_check_batch = createSwarmTool({
85517
85897
  };
85518
85898
  return JSON.stringify(errorResult, null, 2);
85519
85899
  }
85520
- const resolvedDirectory = path95.resolve(typedArgs.directory);
85900
+ const resolvedDirectory = path96.resolve(typedArgs.directory);
85521
85901
  const workspaceAnchor = resolvedDirectory;
85522
85902
  const dirError = validateDirectory2(resolvedDirectory, workspaceAnchor);
85523
85903
  if (dirError) {
@@ -85558,7 +85938,7 @@ var pre_check_batch = createSwarmTool({
85558
85938
  });
85559
85939
  // src/tools/repo-map.ts
85560
85940
  init_zod();
85561
- import * as path96 from "node:path";
85941
+ import * as path97 from "node:path";
85562
85942
  init_path_security();
85563
85943
  init_create_tool();
85564
85944
  var VALID_ACTIONS = [
@@ -85583,7 +85963,7 @@ function validateFile(p) {
85583
85963
  return "file contains control characters";
85584
85964
  if (containsPathTraversal(p))
85585
85965
  return "file contains path traversal";
85586
- if (path96.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
85966
+ if (path97.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
85587
85967
  return "file must be a workspace-relative path, not absolute";
85588
85968
  }
85589
85969
  return null;
@@ -85606,8 +85986,8 @@ function ok(action, payload) {
85606
85986
  }
85607
85987
  function toRelativeGraphPath(input, workspaceRoot) {
85608
85988
  const normalized = input.replace(/\\/g, "/");
85609
- if (path96.isAbsolute(normalized)) {
85610
- const rel = path96.relative(workspaceRoot, normalized).replace(/\\/g, "/");
85989
+ if (path97.isAbsolute(normalized)) {
85990
+ const rel = path97.relative(workspaceRoot, normalized).replace(/\\/g, "/");
85611
85991
  return normalizeGraphPath2(rel);
85612
85992
  }
85613
85993
  return normalizeGraphPath2(normalized);
@@ -85751,8 +86131,8 @@ var repo_map = createSwarmTool({
85751
86131
  // src/tools/req-coverage.ts
85752
86132
  init_zod();
85753
86133
  init_create_tool();
85754
- import * as fs74 from "node:fs";
85755
- import * as path97 from "node:path";
86134
+ import * as fs76 from "node:fs";
86135
+ import * as path98 from "node:path";
85756
86136
  var SPEC_FILE = ".swarm/spec.md";
85757
86137
  var EVIDENCE_DIR4 = ".swarm/evidence";
85758
86138
  var OBLIGATION_KEYWORDS = ["MUST", "SHOULD", "SHALL"];
@@ -85811,19 +86191,19 @@ function extractObligationAndText(id, lineText) {
85811
86191
  var PHASE_TASK_ID_REGEX = /^\d+\.\d+(\.\d+)*$/;
85812
86192
  function readTouchedFiles(evidenceDir, phase, cwd) {
85813
86193
  const touchedFiles = new Set;
85814
- if (!fs74.existsSync(evidenceDir) || !fs74.statSync(evidenceDir).isDirectory()) {
86194
+ if (!fs76.existsSync(evidenceDir) || !fs76.statSync(evidenceDir).isDirectory()) {
85815
86195
  return [];
85816
86196
  }
85817
86197
  let entries;
85818
86198
  try {
85819
- entries = fs74.readdirSync(evidenceDir);
86199
+ entries = fs76.readdirSync(evidenceDir);
85820
86200
  } catch {
85821
86201
  return [];
85822
86202
  }
85823
86203
  for (const entry of entries) {
85824
- const entryPath = path97.join(evidenceDir, entry);
86204
+ const entryPath = path98.join(evidenceDir, entry);
85825
86205
  try {
85826
- const stat7 = fs74.statSync(entryPath);
86206
+ const stat7 = fs76.statSync(entryPath);
85827
86207
  if (!stat7.isDirectory()) {
85828
86208
  continue;
85829
86209
  }
@@ -85837,14 +86217,14 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85837
86217
  if (entryPhase !== String(phase)) {
85838
86218
  continue;
85839
86219
  }
85840
- const evidenceFilePath = path97.join(entryPath, "evidence.json");
86220
+ const evidenceFilePath = path98.join(entryPath, "evidence.json");
85841
86221
  try {
85842
- const resolvedPath = path97.resolve(evidenceFilePath);
85843
- const evidenceDirResolved = path97.resolve(evidenceDir);
85844
- if (!resolvedPath.startsWith(evidenceDirResolved + path97.sep)) {
86222
+ const resolvedPath = path98.resolve(evidenceFilePath);
86223
+ const evidenceDirResolved = path98.resolve(evidenceDir);
86224
+ if (!resolvedPath.startsWith(evidenceDirResolved + path98.sep)) {
85845
86225
  continue;
85846
86226
  }
85847
- const stat7 = fs74.lstatSync(evidenceFilePath);
86227
+ const stat7 = fs76.lstatSync(evidenceFilePath);
85848
86228
  if (!stat7.isFile()) {
85849
86229
  continue;
85850
86230
  }
@@ -85856,7 +86236,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85856
86236
  }
85857
86237
  let content;
85858
86238
  try {
85859
- content = fs74.readFileSync(evidenceFilePath, "utf-8");
86239
+ content = fs76.readFileSync(evidenceFilePath, "utf-8");
85860
86240
  } catch {
85861
86241
  continue;
85862
86242
  }
@@ -85875,7 +86255,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85875
86255
  if (Array.isArray(diffEntry.files_changed)) {
85876
86256
  for (const file3 of diffEntry.files_changed) {
85877
86257
  if (typeof file3 === "string") {
85878
- touchedFiles.add(path97.resolve(cwd, file3));
86258
+ touchedFiles.add(path98.resolve(cwd, file3));
85879
86259
  }
85880
86260
  }
85881
86261
  }
@@ -85888,12 +86268,12 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85888
86268
  }
85889
86269
  function searchFileForKeywords(filePath, keywords, cwd) {
85890
86270
  try {
85891
- const resolvedPath = path97.resolve(filePath);
85892
- const cwdResolved = path97.resolve(cwd);
86271
+ const resolvedPath = path98.resolve(filePath);
86272
+ const cwdResolved = path98.resolve(cwd);
85893
86273
  if (!resolvedPath.startsWith(cwdResolved)) {
85894
86274
  return false;
85895
86275
  }
85896
- const content = fs74.readFileSync(resolvedPath, "utf-8");
86276
+ const content = fs76.readFileSync(resolvedPath, "utf-8");
85897
86277
  for (const keyword of keywords) {
85898
86278
  const regex = new RegExp(`\\b${keyword}\\b`, "i");
85899
86279
  if (regex.test(content)) {
@@ -86023,10 +86403,10 @@ var req_coverage = createSwarmTool({
86023
86403
  }, null, 2);
86024
86404
  }
86025
86405
  const cwd = inputDirectory || directory;
86026
- const specPath = path97.join(cwd, SPEC_FILE);
86406
+ const specPath = path98.join(cwd, SPEC_FILE);
86027
86407
  let specContent;
86028
86408
  try {
86029
- specContent = fs74.readFileSync(specPath, "utf-8");
86409
+ specContent = fs76.readFileSync(specPath, "utf-8");
86030
86410
  } catch (readError) {
86031
86411
  return JSON.stringify({
86032
86412
  success: false,
@@ -86050,7 +86430,7 @@ var req_coverage = createSwarmTool({
86050
86430
  message: "No FR requirements found in spec.md"
86051
86431
  }, null, 2);
86052
86432
  }
86053
- const evidenceDir = path97.join(cwd, EVIDENCE_DIR4);
86433
+ const evidenceDir = path98.join(cwd, EVIDENCE_DIR4);
86054
86434
  const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
86055
86435
  const analyzedRequirements = [];
86056
86436
  let coveredCount = 0;
@@ -86076,12 +86456,12 @@ var req_coverage = createSwarmTool({
86076
86456
  requirements: analyzedRequirements
86077
86457
  };
86078
86458
  const reportFilename = `req-coverage-phase-${phase}.json`;
86079
- const reportPath = path97.join(evidenceDir, reportFilename);
86459
+ const reportPath = path98.join(evidenceDir, reportFilename);
86080
86460
  try {
86081
- if (!fs74.existsSync(evidenceDir)) {
86082
- fs74.mkdirSync(evidenceDir, { recursive: true });
86461
+ if (!fs76.existsSync(evidenceDir)) {
86462
+ fs76.mkdirSync(evidenceDir, { recursive: true });
86083
86463
  }
86084
- fs74.writeFileSync(reportPath, JSON.stringify(result, null, 2), "utf-8");
86464
+ fs76.writeFileSync(reportPath, JSON.stringify(result, null, 2), "utf-8");
86085
86465
  } catch (writeError) {
86086
86466
  console.warn(`Failed to write coverage report: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
86087
86467
  }
@@ -86162,9 +86542,9 @@ init_zod();
86162
86542
  init_plan_schema();
86163
86543
  init_qa_gate_profile();
86164
86544
  init_file_locks();
86165
- import * as crypto9 from "node:crypto";
86166
- import * as fs75 from "node:fs";
86167
- import * as path98 from "node:path";
86545
+ import * as crypto10 from "node:crypto";
86546
+ import * as fs77 from "node:fs";
86547
+ import * as path99 from "node:path";
86168
86548
  init_ledger();
86169
86549
  init_manager();
86170
86550
  init_state();
@@ -86242,17 +86622,17 @@ async function executeSavePlan(args2, fallbackDir) {
86242
86622
  };
86243
86623
  }
86244
86624
  if (args2.working_directory && fallbackDir) {
86245
- const resolvedTarget = path98.resolve(args2.working_directory);
86246
- const resolvedRoot = path98.resolve(fallbackDir);
86625
+ const resolvedTarget = path99.resolve(args2.working_directory);
86626
+ const resolvedRoot = path99.resolve(fallbackDir);
86247
86627
  let fallbackExists = false;
86248
86628
  try {
86249
- fs75.accessSync(resolvedRoot, fs75.constants.F_OK);
86629
+ fs77.accessSync(resolvedRoot, fs77.constants.F_OK);
86250
86630
  fallbackExists = true;
86251
86631
  } catch {
86252
86632
  fallbackExists = false;
86253
86633
  }
86254
86634
  if (fallbackExists) {
86255
- const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path98.sep);
86635
+ const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path99.sep);
86256
86636
  if (isSubdirectory) {
86257
86637
  return {
86258
86638
  success: false,
@@ -86268,12 +86648,12 @@ async function executeSavePlan(args2, fallbackDir) {
86268
86648
  let specMtime;
86269
86649
  let specHash;
86270
86650
  if (process.env.SWARM_SKIP_SPEC_GATE !== "1") {
86271
- const specPath = path98.join(targetWorkspace, ".swarm", "spec.md");
86651
+ const specPath = path99.join(targetWorkspace, ".swarm", "spec.md");
86272
86652
  try {
86273
- const stat7 = await fs75.promises.stat(specPath);
86653
+ const stat7 = await fs77.promises.stat(specPath);
86274
86654
  specMtime = stat7.mtime.toISOString();
86275
- const content = await fs75.promises.readFile(specPath, "utf8");
86276
- specHash = crypto9.createHash("sha256").update(content).digest("hex");
86655
+ const content = await fs77.promises.readFile(specPath, "utf8");
86656
+ specHash = crypto10.createHash("sha256").update(content).digest("hex");
86277
86657
  } catch {
86278
86658
  return {
86279
86659
  success: false,
@@ -86284,10 +86664,10 @@ async function executeSavePlan(args2, fallbackDir) {
86284
86664
  }
86285
86665
  }
86286
86666
  if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
86287
- const contextPath = path98.join(targetWorkspace, ".swarm", "context.md");
86667
+ const contextPath = path99.join(targetWorkspace, ".swarm", "context.md");
86288
86668
  let contextContent = "";
86289
86669
  try {
86290
- contextContent = await fs75.promises.readFile(contextPath, "utf8");
86670
+ contextContent = await fs77.promises.readFile(contextPath, "utf8");
86291
86671
  } catch {}
86292
86672
  const hasPendingSection = contextContent.includes("## Pending QA Gate Selection");
86293
86673
  if (!hasPendingSection) {
@@ -86434,14 +86814,14 @@ async function executeSavePlan(args2, fallbackDir) {
86434
86814
  }
86435
86815
  await writeCheckpoint(dir).catch(() => {});
86436
86816
  try {
86437
- const markerPath = path98.join(dir, ".swarm", ".plan-write-marker");
86817
+ const markerPath = path99.join(dir, ".swarm", ".plan-write-marker");
86438
86818
  const marker = JSON.stringify({
86439
86819
  source: "save_plan",
86440
86820
  timestamp: new Date().toISOString(),
86441
86821
  phases_count: plan.phases.length,
86442
86822
  tasks_count: tasksCount
86443
86823
  });
86444
- await fs75.promises.writeFile(markerPath, marker, "utf8");
86824
+ await fs77.promises.writeFile(markerPath, marker, "utf8");
86445
86825
  } catch {}
86446
86826
  const warnings = [];
86447
86827
  let criticReviewFound = false;
@@ -86457,7 +86837,7 @@ async function executeSavePlan(args2, fallbackDir) {
86457
86837
  return {
86458
86838
  success: true,
86459
86839
  message: "Plan saved successfully",
86460
- plan_path: path98.join(dir, ".swarm", "plan.json"),
86840
+ plan_path: path99.join(dir, ".swarm", "plan.json"),
86461
86841
  phases_count: plan.phases.length,
86462
86842
  tasks_count: tasksCount,
86463
86843
  ...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
@@ -86509,8 +86889,8 @@ var save_plan = createSwarmTool({
86509
86889
  // src/tools/sbom-generate.ts
86510
86890
  init_zod();
86511
86891
  init_manager2();
86512
- import * as fs76 from "node:fs";
86513
- import * as path99 from "node:path";
86892
+ import * as fs78 from "node:fs";
86893
+ import * as path100 from "node:path";
86514
86894
 
86515
86895
  // src/sbom/detectors/index.ts
86516
86896
  init_utils();
@@ -87358,9 +87738,9 @@ function findManifestFiles(rootDir) {
87358
87738
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
87359
87739
  function searchDir(dir) {
87360
87740
  try {
87361
- const entries = fs76.readdirSync(dir, { withFileTypes: true });
87741
+ const entries = fs78.readdirSync(dir, { withFileTypes: true });
87362
87742
  for (const entry of entries) {
87363
- const fullPath = path99.join(dir, entry.name);
87743
+ const fullPath = path100.join(dir, entry.name);
87364
87744
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
87365
87745
  continue;
87366
87746
  }
@@ -87369,7 +87749,7 @@ function findManifestFiles(rootDir) {
87369
87749
  } else if (entry.isFile()) {
87370
87750
  for (const pattern of patterns) {
87371
87751
  if (simpleGlobToRegex(pattern).test(entry.name)) {
87372
- manifestFiles.push(path99.relative(rootDir, fullPath));
87752
+ manifestFiles.push(path100.relative(rootDir, fullPath));
87373
87753
  break;
87374
87754
  }
87375
87755
  }
@@ -87385,13 +87765,13 @@ function findManifestFilesInDirs(directories, workingDir) {
87385
87765
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
87386
87766
  for (const dir of directories) {
87387
87767
  try {
87388
- const entries = fs76.readdirSync(dir, { withFileTypes: true });
87768
+ const entries = fs78.readdirSync(dir, { withFileTypes: true });
87389
87769
  for (const entry of entries) {
87390
- const fullPath = path99.join(dir, entry.name);
87770
+ const fullPath = path100.join(dir, entry.name);
87391
87771
  if (entry.isFile()) {
87392
87772
  for (const pattern of patterns) {
87393
87773
  if (simpleGlobToRegex(pattern).test(entry.name)) {
87394
- found.push(path99.relative(workingDir, fullPath));
87774
+ found.push(path100.relative(workingDir, fullPath));
87395
87775
  break;
87396
87776
  }
87397
87777
  }
@@ -87404,11 +87784,11 @@ function findManifestFilesInDirs(directories, workingDir) {
87404
87784
  function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
87405
87785
  const dirs = new Set;
87406
87786
  for (const file3 of changedFiles) {
87407
- let currentDir = path99.dirname(file3);
87787
+ let currentDir = path100.dirname(file3);
87408
87788
  while (true) {
87409
- if (currentDir && currentDir !== "." && currentDir !== path99.sep) {
87410
- dirs.add(path99.join(workingDir, currentDir));
87411
- const parent = path99.dirname(currentDir);
87789
+ if (currentDir && currentDir !== "." && currentDir !== path100.sep) {
87790
+ dirs.add(path100.join(workingDir, currentDir));
87791
+ const parent = path100.dirname(currentDir);
87412
87792
  if (parent === currentDir)
87413
87793
  break;
87414
87794
  currentDir = parent;
@@ -87422,7 +87802,7 @@ function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
87422
87802
  }
87423
87803
  function ensureOutputDir(outputDir) {
87424
87804
  try {
87425
- fs76.mkdirSync(outputDir, { recursive: true });
87805
+ fs78.mkdirSync(outputDir, { recursive: true });
87426
87806
  } catch (error93) {
87427
87807
  if (!error93 || error93.code !== "EEXIST") {
87428
87808
  throw error93;
@@ -87492,7 +87872,7 @@ var sbom_generate = createSwarmTool({
87492
87872
  const changedFiles = obj.changed_files;
87493
87873
  const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
87494
87874
  const workingDir = directory;
87495
- const outputDir = path99.isAbsolute(relativeOutputDir) ? relativeOutputDir : path99.join(workingDir, relativeOutputDir);
87875
+ const outputDir = path100.isAbsolute(relativeOutputDir) ? relativeOutputDir : path100.join(workingDir, relativeOutputDir);
87496
87876
  let manifestFiles = [];
87497
87877
  if (scope === "all") {
87498
87878
  manifestFiles = findManifestFiles(workingDir);
@@ -87515,11 +87895,11 @@ var sbom_generate = createSwarmTool({
87515
87895
  const processedFiles = [];
87516
87896
  for (const manifestFile of manifestFiles) {
87517
87897
  try {
87518
- const fullPath = path99.isAbsolute(manifestFile) ? manifestFile : path99.join(workingDir, manifestFile);
87519
- if (!fs76.existsSync(fullPath)) {
87898
+ const fullPath = path100.isAbsolute(manifestFile) ? manifestFile : path100.join(workingDir, manifestFile);
87899
+ if (!fs78.existsSync(fullPath)) {
87520
87900
  continue;
87521
87901
  }
87522
- const content = fs76.readFileSync(fullPath, "utf-8");
87902
+ const content = fs78.readFileSync(fullPath, "utf-8");
87523
87903
  const components = detectComponents(manifestFile, content);
87524
87904
  processedFiles.push(manifestFile);
87525
87905
  if (components.length > 0) {
@@ -87532,8 +87912,8 @@ var sbom_generate = createSwarmTool({
87532
87912
  const bom = generateCycloneDX(allComponents);
87533
87913
  const bomJson = serializeCycloneDX(bom);
87534
87914
  const filename = generateSbomFilename();
87535
- const outputPath = path99.join(outputDir, filename);
87536
- fs76.writeFileSync(outputPath, bomJson, "utf-8");
87915
+ const outputPath = path100.join(outputDir, filename);
87916
+ fs78.writeFileSync(outputPath, bomJson, "utf-8");
87537
87917
  const verdict = processedFiles.length > 0 ? "pass" : "pass";
87538
87918
  try {
87539
87919
  const timestamp = new Date().toISOString();
@@ -87575,8 +87955,8 @@ var sbom_generate = createSwarmTool({
87575
87955
  // src/tools/schema-drift.ts
87576
87956
  init_zod();
87577
87957
  init_create_tool();
87578
- import * as fs77 from "node:fs";
87579
- import * as path100 from "node:path";
87958
+ import * as fs79 from "node:fs";
87959
+ import * as path101 from "node:path";
87580
87960
  var SPEC_CANDIDATES = [
87581
87961
  "openapi.json",
87582
87962
  "openapi.yaml",
@@ -87608,28 +87988,28 @@ function normalizePath3(p) {
87608
87988
  }
87609
87989
  function discoverSpecFile(cwd, specFileArg) {
87610
87990
  if (specFileArg) {
87611
- const resolvedPath = path100.resolve(cwd, specFileArg);
87612
- const normalizedCwd = cwd.endsWith(path100.sep) ? cwd : cwd + path100.sep;
87991
+ const resolvedPath = path101.resolve(cwd, specFileArg);
87992
+ const normalizedCwd = cwd.endsWith(path101.sep) ? cwd : cwd + path101.sep;
87613
87993
  if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
87614
87994
  throw new Error("Invalid spec_file: path traversal detected");
87615
87995
  }
87616
- const ext = path100.extname(resolvedPath).toLowerCase();
87996
+ const ext = path101.extname(resolvedPath).toLowerCase();
87617
87997
  if (!ALLOWED_EXTENSIONS.includes(ext)) {
87618
87998
  throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
87619
87999
  }
87620
- const stats = fs77.statSync(resolvedPath);
88000
+ const stats = fs79.statSync(resolvedPath);
87621
88001
  if (stats.size > MAX_SPEC_SIZE) {
87622
88002
  throw new Error(`Invalid spec_file: file exceeds ${MAX_SPEC_SIZE / 1024 / 1024}MB limit`);
87623
88003
  }
87624
- if (!fs77.existsSync(resolvedPath)) {
88004
+ if (!fs79.existsSync(resolvedPath)) {
87625
88005
  throw new Error(`Spec file not found: ${resolvedPath}`);
87626
88006
  }
87627
88007
  return resolvedPath;
87628
88008
  }
87629
88009
  for (const candidate of SPEC_CANDIDATES) {
87630
- const candidatePath = path100.resolve(cwd, candidate);
87631
- if (fs77.existsSync(candidatePath)) {
87632
- const stats = fs77.statSync(candidatePath);
88010
+ const candidatePath = path101.resolve(cwd, candidate);
88011
+ if (fs79.existsSync(candidatePath)) {
88012
+ const stats = fs79.statSync(candidatePath);
87633
88013
  if (stats.size <= MAX_SPEC_SIZE) {
87634
88014
  return candidatePath;
87635
88015
  }
@@ -87638,8 +88018,8 @@ function discoverSpecFile(cwd, specFileArg) {
87638
88018
  return null;
87639
88019
  }
87640
88020
  function parseSpec(specFile) {
87641
- const content = fs77.readFileSync(specFile, "utf-8");
87642
- const ext = path100.extname(specFile).toLowerCase();
88021
+ const content = fs79.readFileSync(specFile, "utf-8");
88022
+ const ext = path101.extname(specFile).toLowerCase();
87643
88023
  if (ext === ".json") {
87644
88024
  return parseJsonSpec(content);
87645
88025
  }
@@ -87710,12 +88090,12 @@ function extractRoutes(cwd) {
87710
88090
  function walkDir(dir) {
87711
88091
  let entries;
87712
88092
  try {
87713
- entries = fs77.readdirSync(dir, { withFileTypes: true });
88093
+ entries = fs79.readdirSync(dir, { withFileTypes: true });
87714
88094
  } catch {
87715
88095
  return;
87716
88096
  }
87717
88097
  for (const entry of entries) {
87718
- const fullPath = path100.join(dir, entry.name);
88098
+ const fullPath = path101.join(dir, entry.name);
87719
88099
  if (entry.isSymbolicLink()) {
87720
88100
  continue;
87721
88101
  }
@@ -87725,7 +88105,7 @@ function extractRoutes(cwd) {
87725
88105
  }
87726
88106
  walkDir(fullPath);
87727
88107
  } else if (entry.isFile()) {
87728
- const ext = path100.extname(entry.name).toLowerCase();
88108
+ const ext = path101.extname(entry.name).toLowerCase();
87729
88109
  const baseName = entry.name.toLowerCase();
87730
88110
  if (![".ts", ".js", ".mjs"].includes(ext)) {
87731
88111
  continue;
@@ -87743,7 +88123,7 @@ function extractRoutes(cwd) {
87743
88123
  }
87744
88124
  function extractRoutesFromFile(filePath) {
87745
88125
  const routes = [];
87746
- const content = fs77.readFileSync(filePath, "utf-8");
88126
+ const content = fs79.readFileSync(filePath, "utf-8");
87747
88127
  const lines = content.split(/\r?\n/);
87748
88128
  const expressRegex = /(?:app|router|server|express)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/g;
87749
88129
  const flaskRegex = /@(?:app|blueprint|bp)\.route\s*\(\s*['"]([^'"]+)['"]/g;
@@ -87892,8 +88272,8 @@ init_zod();
87892
88272
  init_bun_compat();
87893
88273
  init_path_security();
87894
88274
  init_create_tool();
87895
- import * as fs78 from "node:fs";
87896
- import * as path101 from "node:path";
88275
+ import * as fs80 from "node:fs";
88276
+ import * as path102 from "node:path";
87897
88277
  var DEFAULT_MAX_RESULTS = 100;
87898
88278
  var DEFAULT_MAX_LINES = 200;
87899
88279
  var REGEX_TIMEOUT_MS = 5000;
@@ -87929,11 +88309,11 @@ function containsWindowsAttacks3(str) {
87929
88309
  }
87930
88310
  function isPathInWorkspace3(filePath, workspace) {
87931
88311
  try {
87932
- const resolvedPath = path101.resolve(workspace, filePath);
87933
- const realWorkspace = fs78.realpathSync(workspace);
87934
- const realResolvedPath = fs78.realpathSync(resolvedPath);
87935
- const relativePath = path101.relative(realWorkspace, realResolvedPath);
87936
- if (relativePath.startsWith("..") || path101.isAbsolute(relativePath)) {
88312
+ const resolvedPath = path102.resolve(workspace, filePath);
88313
+ const realWorkspace = fs80.realpathSync(workspace);
88314
+ const realResolvedPath = fs80.realpathSync(resolvedPath);
88315
+ const relativePath = path102.relative(realWorkspace, realResolvedPath);
88316
+ if (relativePath.startsWith("..") || path102.isAbsolute(relativePath)) {
87937
88317
  return false;
87938
88318
  }
87939
88319
  return true;
@@ -87946,12 +88326,12 @@ function validatePathForRead2(filePath, workspace) {
87946
88326
  }
87947
88327
  function findRgInEnvPath() {
87948
88328
  const searchPath = process.env.PATH ?? "";
87949
- for (const dir of searchPath.split(path101.delimiter)) {
88329
+ for (const dir of searchPath.split(path102.delimiter)) {
87950
88330
  if (!dir)
87951
88331
  continue;
87952
88332
  const isWindows = process.platform === "win32";
87953
- const candidate = path101.join(dir, isWindows ? "rg.exe" : "rg");
87954
- if (fs78.existsSync(candidate))
88333
+ const candidate = path102.join(dir, isWindows ? "rg.exe" : "rg");
88334
+ if (fs80.existsSync(candidate))
87955
88335
  return candidate;
87956
88336
  }
87957
88337
  return null;
@@ -88005,7 +88385,7 @@ async function ripgrepSearch(opts) {
88005
88385
  stderr: "pipe",
88006
88386
  cwd: opts.workspace
88007
88387
  });
88008
- const timeout = new Promise((resolve40) => setTimeout(() => resolve40("timeout"), REGEX_TIMEOUT_MS));
88388
+ const timeout = new Promise((resolve41) => setTimeout(() => resolve41("timeout"), REGEX_TIMEOUT_MS));
88009
88389
  const exitPromise = proc.exited;
88010
88390
  const result = await Promise.race([exitPromise, timeout]);
88011
88391
  if (result === "timeout") {
@@ -88078,10 +88458,10 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
88078
88458
  return files;
88079
88459
  }
88080
88460
  try {
88081
- const entries = fs78.readdirSync(dir, { withFileTypes: true });
88461
+ const entries = fs80.readdirSync(dir, { withFileTypes: true });
88082
88462
  for (const entry of entries) {
88083
- const fullPath = path101.join(dir, entry.name);
88084
- const relativePath = path101.relative(workspace, fullPath);
88463
+ const fullPath = path102.join(dir, entry.name);
88464
+ const relativePath = path102.relative(workspace, fullPath);
88085
88465
  if (!validatePathForRead2(fullPath, workspace)) {
88086
88466
  continue;
88087
88467
  }
@@ -88122,13 +88502,13 @@ async function fallbackSearch(opts) {
88122
88502
  const matches = [];
88123
88503
  let total = 0;
88124
88504
  for (const file3 of files) {
88125
- const fullPath = path101.join(opts.workspace, file3);
88505
+ const fullPath = path102.join(opts.workspace, file3);
88126
88506
  if (!validatePathForRead2(fullPath, opts.workspace)) {
88127
88507
  continue;
88128
88508
  }
88129
88509
  let stats;
88130
88510
  try {
88131
- stats = fs78.statSync(fullPath);
88511
+ stats = fs80.statSync(fullPath);
88132
88512
  if (stats.size > MAX_FILE_SIZE_BYTES10) {
88133
88513
  continue;
88134
88514
  }
@@ -88137,7 +88517,7 @@ async function fallbackSearch(opts) {
88137
88517
  }
88138
88518
  let content;
88139
88519
  try {
88140
- content = fs78.readFileSync(fullPath, "utf-8");
88520
+ content = fs80.readFileSync(fullPath, "utf-8");
88141
88521
  } catch {
88142
88522
  continue;
88143
88523
  }
@@ -88249,7 +88629,7 @@ var search = createSwarmTool({
88249
88629
  message: "Exclude pattern contains invalid Windows-specific sequence"
88250
88630
  }, null, 2);
88251
88631
  }
88252
- if (!fs78.existsSync(directory)) {
88632
+ if (!fs80.existsSync(directory)) {
88253
88633
  return JSON.stringify({
88254
88634
  error: true,
88255
88635
  type: "unknown",
@@ -88502,8 +88882,8 @@ var submit_phase_council_verdicts = createSwarmTool({
88502
88882
  init_zod();
88503
88883
  init_path_security();
88504
88884
  init_create_tool();
88505
- import * as fs79 from "node:fs";
88506
- import * as path102 from "node:path";
88885
+ import * as fs81 from "node:fs";
88886
+ import * as path103 from "node:path";
88507
88887
  var WINDOWS_RESERVED_NAMES4 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
88508
88888
  function containsWindowsAttacks4(str) {
88509
88889
  if (/:[^\\/]/.test(str))
@@ -88517,14 +88897,14 @@ function containsWindowsAttacks4(str) {
88517
88897
  }
88518
88898
  function isPathInWorkspace4(filePath, workspace) {
88519
88899
  try {
88520
- const resolvedPath = path102.resolve(workspace, filePath);
88521
- if (!fs79.existsSync(resolvedPath)) {
88900
+ const resolvedPath = path103.resolve(workspace, filePath);
88901
+ if (!fs81.existsSync(resolvedPath)) {
88522
88902
  return true;
88523
88903
  }
88524
- const realWorkspace = fs79.realpathSync(workspace);
88525
- const realResolvedPath = fs79.realpathSync(resolvedPath);
88526
- const relativePath = path102.relative(realWorkspace, realResolvedPath);
88527
- if (relativePath.startsWith("..") || path102.isAbsolute(relativePath)) {
88904
+ const realWorkspace = fs81.realpathSync(workspace);
88905
+ const realResolvedPath = fs81.realpathSync(resolvedPath);
88906
+ const relativePath = path103.relative(realWorkspace, realResolvedPath);
88907
+ if (relativePath.startsWith("..") || path103.isAbsolute(relativePath)) {
88528
88908
  return false;
88529
88909
  }
88530
88910
  return true;
@@ -88696,7 +89076,7 @@ var suggestPatch = createSwarmTool({
88696
89076
  message: "changes cannot be empty"
88697
89077
  }, null, 2);
88698
89078
  }
88699
- if (!fs79.existsSync(directory)) {
89079
+ if (!fs81.existsSync(directory)) {
88700
89080
  return JSON.stringify({
88701
89081
  success: false,
88702
89082
  error: true,
@@ -88732,8 +89112,8 @@ var suggestPatch = createSwarmTool({
88732
89112
  });
88733
89113
  continue;
88734
89114
  }
88735
- const fullPath = path102.resolve(directory, change.file);
88736
- if (!fs79.existsSync(fullPath)) {
89115
+ const fullPath = path103.resolve(directory, change.file);
89116
+ if (!fs81.existsSync(fullPath)) {
88737
89117
  errors5.push({
88738
89118
  success: false,
88739
89119
  error: true,
@@ -88747,7 +89127,7 @@ var suggestPatch = createSwarmTool({
88747
89127
  }
88748
89128
  let content;
88749
89129
  try {
88750
- content = fs79.readFileSync(fullPath, "utf-8");
89130
+ content = fs81.readFileSync(fullPath, "utf-8");
88751
89131
  } catch (err3) {
88752
89132
  errors5.push({
88753
89133
  success: false,
@@ -88994,8 +89374,8 @@ var generate_mutants = createSwarmTool({
88994
89374
  // src/tools/lint-spec.ts
88995
89375
  init_spec_schema();
88996
89376
  init_create_tool();
88997
- import * as fs80 from "node:fs";
88998
- import * as path103 from "node:path";
89377
+ import * as fs82 from "node:fs";
89378
+ import * as path104 from "node:path";
88999
89379
  var SPEC_FILE_NAME = "spec.md";
89000
89380
  var SWARM_DIR2 = ".swarm";
89001
89381
  var OBLIGATION_KEYWORDS2 = ["MUST", "SHALL", "SHOULD", "MAY"];
@@ -89048,8 +89428,8 @@ var lint_spec = createSwarmTool({
89048
89428
  async execute(_args, directory) {
89049
89429
  const errors5 = [];
89050
89430
  const warnings = [];
89051
- const specPath = path103.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
89052
- if (!fs80.existsSync(specPath)) {
89431
+ const specPath = path104.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
89432
+ if (!fs82.existsSync(specPath)) {
89053
89433
  const result2 = {
89054
89434
  valid: false,
89055
89435
  specMtime: null,
@@ -89068,12 +89448,12 @@ var lint_spec = createSwarmTool({
89068
89448
  }
89069
89449
  let specMtime = null;
89070
89450
  try {
89071
- const stats = fs80.statSync(specPath);
89451
+ const stats = fs82.statSync(specPath);
89072
89452
  specMtime = stats.mtime.toISOString();
89073
89453
  } catch {}
89074
89454
  let content;
89075
89455
  try {
89076
- content = fs80.readFileSync(specPath, "utf-8");
89456
+ content = fs82.readFileSync(specPath, "utf-8");
89077
89457
  } catch (e) {
89078
89458
  const result2 = {
89079
89459
  valid: false,
@@ -89118,13 +89498,13 @@ var lint_spec = createSwarmTool({
89118
89498
  });
89119
89499
  // src/tools/mutation-test.ts
89120
89500
  init_zod();
89121
- import * as fs81 from "node:fs";
89122
- import * as path105 from "node:path";
89501
+ import * as fs83 from "node:fs";
89502
+ import * as path106 from "node:path";
89123
89503
 
89124
89504
  // src/mutation/engine.ts
89125
89505
  import { spawnSync as spawnSync3 } from "node:child_process";
89126
89506
  import { unlinkSync as unlinkSync13, writeFileSync as writeFileSync20 } from "node:fs";
89127
- import * as path104 from "node:path";
89507
+ import * as path105 from "node:path";
89128
89508
 
89129
89509
  // src/mutation/equivalence.ts
89130
89510
  function isStaticallyEquivalent(originalCode, mutatedCode) {
@@ -89196,6 +89576,11 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
89196
89576
  const strippedMutated = stripCode(mutatedCode);
89197
89577
  return strippedOriginal === strippedMutated;
89198
89578
  }
89579
+ var _internals32 = {
89580
+ isStaticallyEquivalent,
89581
+ checkEquivalence,
89582
+ batchCheckEquivalence
89583
+ };
89199
89584
  async function checkEquivalence(patch, originalCode, mutatedCode, llmJudge) {
89200
89585
  if (isStaticallyEquivalent(originalCode, mutatedCode)) {
89201
89586
  return {
@@ -89231,7 +89616,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
89231
89616
  const results = [];
89232
89617
  for (const { patch, originalCode, mutatedCode } of patches) {
89233
89618
  try {
89234
- const result = await checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
89619
+ const result = await _internals32.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
89235
89620
  results.push(result);
89236
89621
  } catch (err3) {
89237
89622
  results.push({
@@ -89259,7 +89644,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
89259
89644
  let patchFile;
89260
89645
  try {
89261
89646
  const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
89262
- patchFile = path104.join(workingDir, `.mutation_patch_${safeId2}.diff`);
89647
+ patchFile = path105.join(workingDir, `.mutation_patch_${safeId2}.diff`);
89263
89648
  try {
89264
89649
  writeFileSync20(patchFile, patch.patch);
89265
89650
  } catch (writeErr) {
@@ -89531,6 +89916,11 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
89531
89916
  }
89532
89917
 
89533
89918
  // src/mutation/gate.ts
89919
+ var _internals33 = {
89920
+ evaluateMutationGate,
89921
+ buildTestImprovementPrompt,
89922
+ buildMessage
89923
+ };
89534
89924
  var PASS_THRESHOLD = 0.8;
89535
89925
  var WARN_THRESHOLD = 0.6;
89536
89926
  function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThreshold = WARN_THRESHOLD) {
@@ -89547,8 +89937,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
89547
89937
  } else {
89548
89938
  verdict = "fail";
89549
89939
  }
89550
- const testImprovementPrompt = buildTestImprovementPrompt(report, passThreshold, verdict);
89551
- const message = buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
89940
+ const testImprovementPrompt = _internals33.buildTestImprovementPrompt(report, passThreshold, verdict);
89941
+ const message = _internals33.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
89552
89942
  return {
89553
89943
  verdict,
89554
89944
  killRate: report.killRate,
@@ -89653,8 +90043,8 @@ var mutation_test = createSwarmTool({
89653
90043
  ];
89654
90044
  for (const filePath of uniquePaths) {
89655
90045
  try {
89656
- const resolvedPath = path105.resolve(cwd, filePath);
89657
- sourceFiles.set(filePath, fs81.readFileSync(resolvedPath, "utf-8"));
90046
+ const resolvedPath = path106.resolve(cwd, filePath);
90047
+ sourceFiles.set(filePath, fs83.readFileSync(resolvedPath, "utf-8"));
89658
90048
  } catch {}
89659
90049
  }
89660
90050
  const report = await executeMutationSuite(typedArgs.patches, typedArgs.test_command, typedArgs.files, cwd, undefined, undefined, sourceFiles.size > 0 ? sourceFiles : undefined);
@@ -89672,8 +90062,8 @@ var mutation_test = createSwarmTool({
89672
90062
  init_zod();
89673
90063
  init_manager2();
89674
90064
  init_detector();
89675
- import * as fs82 from "node:fs";
89676
- import * as path106 from "node:path";
90065
+ import * as fs84 from "node:fs";
90066
+ import * as path107 from "node:path";
89677
90067
  init_create_tool();
89678
90068
  var MAX_FILE_SIZE2 = 2 * 1024 * 1024;
89679
90069
  var BINARY_CHECK_BYTES = 8192;
@@ -89739,7 +90129,7 @@ async function syntaxCheck(input, directory, config3) {
89739
90129
  if (languages?.length) {
89740
90130
  const lowerLangs = languages.map((l) => l.toLowerCase());
89741
90131
  filesToCheck = filesToCheck.filter((file3) => {
89742
- const ext = path106.extname(file3.path).toLowerCase();
90132
+ const ext = path107.extname(file3.path).toLowerCase();
89743
90133
  const langDef = getLanguageForExtension(ext);
89744
90134
  const fileProfile = getProfileForFile(file3.path);
89745
90135
  const langId = fileProfile?.id || langDef?.id;
@@ -89752,7 +90142,7 @@ async function syntaxCheck(input, directory, config3) {
89752
90142
  let skippedCount = 0;
89753
90143
  for (const fileInfo of filesToCheck) {
89754
90144
  const { path: filePath } = fileInfo;
89755
- const fullPath = path106.isAbsolute(filePath) ? filePath : path106.join(directory, filePath);
90145
+ const fullPath = path107.isAbsolute(filePath) ? filePath : path107.join(directory, filePath);
89756
90146
  const result = {
89757
90147
  path: filePath,
89758
90148
  language: "",
@@ -89782,7 +90172,7 @@ async function syntaxCheck(input, directory, config3) {
89782
90172
  }
89783
90173
  let content;
89784
90174
  try {
89785
- content = fs82.readFileSync(fullPath, "utf8");
90175
+ content = fs84.readFileSync(fullPath, "utf8");
89786
90176
  } catch {
89787
90177
  result.skipped_reason = "file_read_error";
89788
90178
  skippedCount++;
@@ -89801,7 +90191,7 @@ async function syntaxCheck(input, directory, config3) {
89801
90191
  results.push(result);
89802
90192
  continue;
89803
90193
  }
89804
- const ext = path106.extname(filePath).toLowerCase();
90194
+ const ext = path107.extname(filePath).toLowerCase();
89805
90195
  const langDef = getLanguageForExtension(ext);
89806
90196
  result.language = profile?.id || langDef?.id || "unknown";
89807
90197
  const errors5 = extractSyntaxErrors(parser, content);
@@ -89893,8 +90283,8 @@ init_zod();
89893
90283
  init_utils();
89894
90284
  init_create_tool();
89895
90285
  init_path_security();
89896
- import * as fs83 from "node:fs";
89897
- import * as path107 from "node:path";
90286
+ import * as fs85 from "node:fs";
90287
+ import * as path108 from "node:path";
89898
90288
  var MAX_TEXT_LENGTH = 200;
89899
90289
  var MAX_FILE_SIZE_BYTES11 = 1024 * 1024;
89900
90290
  var SUPPORTED_EXTENSIONS4 = new Set([
@@ -89960,9 +90350,9 @@ function validatePathsInput(paths, cwd) {
89960
90350
  return { error: "paths contains path traversal", resolvedPath: null };
89961
90351
  }
89962
90352
  try {
89963
- const resolvedPath = path107.resolve(paths);
89964
- const normalizedCwd = path107.resolve(cwd);
89965
- const normalizedResolved = path107.resolve(resolvedPath);
90353
+ const resolvedPath = path108.resolve(paths);
90354
+ const normalizedCwd = path108.resolve(cwd);
90355
+ const normalizedResolved = path108.resolve(resolvedPath);
89966
90356
  if (!normalizedResolved.startsWith(normalizedCwd)) {
89967
90357
  return {
89968
90358
  error: "paths must be within the current working directory",
@@ -89978,13 +90368,13 @@ function validatePathsInput(paths, cwd) {
89978
90368
  }
89979
90369
  }
89980
90370
  function isSupportedExtension(filePath) {
89981
- const ext = path107.extname(filePath).toLowerCase();
90371
+ const ext = path108.extname(filePath).toLowerCase();
89982
90372
  return SUPPORTED_EXTENSIONS4.has(ext);
89983
90373
  }
89984
90374
  function findSourceFiles3(dir, files = []) {
89985
90375
  let entries;
89986
90376
  try {
89987
- entries = fs83.readdirSync(dir);
90377
+ entries = fs85.readdirSync(dir);
89988
90378
  } catch {
89989
90379
  return files;
89990
90380
  }
@@ -89993,10 +90383,10 @@ function findSourceFiles3(dir, files = []) {
89993
90383
  if (SKIP_DIRECTORIES5.has(entry)) {
89994
90384
  continue;
89995
90385
  }
89996
- const fullPath = path107.join(dir, entry);
90386
+ const fullPath = path108.join(dir, entry);
89997
90387
  let stat7;
89998
90388
  try {
89999
- stat7 = fs83.statSync(fullPath);
90389
+ stat7 = fs85.statSync(fullPath);
90000
90390
  } catch {
90001
90391
  continue;
90002
90392
  }
@@ -90089,7 +90479,7 @@ var todo_extract = createSwarmTool({
90089
90479
  return JSON.stringify(errorResult, null, 2);
90090
90480
  }
90091
90481
  const scanPath = resolvedPath;
90092
- if (!fs83.existsSync(scanPath)) {
90482
+ if (!fs85.existsSync(scanPath)) {
90093
90483
  const errorResult = {
90094
90484
  error: `path not found: ${pathsInput}`,
90095
90485
  total: 0,
@@ -90099,13 +90489,13 @@ var todo_extract = createSwarmTool({
90099
90489
  return JSON.stringify(errorResult, null, 2);
90100
90490
  }
90101
90491
  const filesToScan = [];
90102
- const stat7 = fs83.statSync(scanPath);
90492
+ const stat7 = fs85.statSync(scanPath);
90103
90493
  if (stat7.isFile()) {
90104
90494
  if (isSupportedExtension(scanPath)) {
90105
90495
  filesToScan.push(scanPath);
90106
90496
  } else {
90107
90497
  const errorResult = {
90108
- error: `unsupported file extension: ${path107.extname(scanPath)}`,
90498
+ error: `unsupported file extension: ${path108.extname(scanPath)}`,
90109
90499
  total: 0,
90110
90500
  byPriority: { high: 0, medium: 0, low: 0 },
90111
90501
  entries: []
@@ -90118,11 +90508,11 @@ var todo_extract = createSwarmTool({
90118
90508
  const allEntries = [];
90119
90509
  for (const filePath of filesToScan) {
90120
90510
  try {
90121
- const fileStat = fs83.statSync(filePath);
90511
+ const fileStat = fs85.statSync(filePath);
90122
90512
  if (fileStat.size > MAX_FILE_SIZE_BYTES11) {
90123
90513
  continue;
90124
90514
  }
90125
- const content = fs83.readFileSync(filePath, "utf-8");
90515
+ const content = fs85.readFileSync(filePath, "utf-8");
90126
90516
  const entries = parseTodoComments(content, filePath, tagsSet);
90127
90517
  allEntries.push(...entries);
90128
90518
  } catch {}
@@ -90153,19 +90543,19 @@ init_loader();
90153
90543
  init_schema();
90154
90544
  init_qa_gate_profile();
90155
90545
  init_gate_evidence();
90156
- import * as fs86 from "node:fs";
90157
- import * as path110 from "node:path";
90546
+ import * as fs88 from "node:fs";
90547
+ import * as path111 from "node:path";
90158
90548
 
90159
90549
  // src/hooks/diff-scope.ts
90160
90550
  init_bun_compat();
90161
- import * as fs85 from "node:fs";
90162
- import * as path109 from "node:path";
90551
+ import * as fs87 from "node:fs";
90552
+ import * as path110 from "node:path";
90163
90553
 
90164
90554
  // src/utils/gitignore-warning.ts
90165
90555
  init_bun_compat();
90166
- import * as fs84 from "node:fs";
90167
- import * as path108 from "node:path";
90168
- var _internals = { bunSpawn };
90556
+ import * as fs86 from "node:fs";
90557
+ import * as path109 from "node:path";
90558
+ var _internals34 = { bunSpawn };
90169
90559
  var _swarmGitExcludedChecked = false;
90170
90560
  function fileCoversSwarm(content) {
90171
90561
  for (const rawLine of content.split(`
@@ -90198,7 +90588,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90198
90588
  checkIgnoreExitCode
90199
90589
  ] = await Promise.all([
90200
90590
  (async () => {
90201
- const proc = _internals.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
90591
+ const proc = _internals34.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
90202
90592
  try {
90203
90593
  return await Promise.all([proc.exited, proc.stdout.text()]);
90204
90594
  } finally {
@@ -90208,7 +90598,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90208
90598
  }
90209
90599
  })(),
90210
90600
  (async () => {
90211
- const proc = _internals.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
90601
+ const proc = _internals34.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
90212
90602
  try {
90213
90603
  return await Promise.all([proc.exited, proc.stdout.text()]);
90214
90604
  } finally {
@@ -90218,7 +90608,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90218
90608
  }
90219
90609
  })(),
90220
90610
  (async () => {
90221
- const proc = _internals.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
90611
+ const proc = _internals34.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
90222
90612
  try {
90223
90613
  return await proc.exited;
90224
90614
  } finally {
@@ -90238,16 +90628,16 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90238
90628
  const excludeRelPath = excludePathRaw.trim();
90239
90629
  if (!excludeRelPath)
90240
90630
  return;
90241
- const excludePath = path108.isAbsolute(excludeRelPath) ? excludeRelPath : path108.join(directory, excludeRelPath);
90631
+ const excludePath = path109.isAbsolute(excludeRelPath) ? excludeRelPath : path109.join(directory, excludeRelPath);
90242
90632
  if (checkIgnoreExitCode !== 0) {
90243
90633
  try {
90244
- fs84.mkdirSync(path108.dirname(excludePath), { recursive: true });
90634
+ fs86.mkdirSync(path109.dirname(excludePath), { recursive: true });
90245
90635
  let existing = "";
90246
90636
  try {
90247
- existing = fs84.readFileSync(excludePath, "utf8");
90637
+ existing = fs86.readFileSync(excludePath, "utf8");
90248
90638
  } catch {}
90249
90639
  if (!fileCoversSwarm(existing)) {
90250
- fs84.appendFileSync(excludePath, `
90640
+ fs86.appendFileSync(excludePath, `
90251
90641
  # opencode-swarm local runtime state
90252
90642
  .swarm/
90253
90643
  `, "utf8");
@@ -90257,7 +90647,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90257
90647
  }
90258
90648
  } catch {}
90259
90649
  }
90260
- const trackedProc = _internals.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
90650
+ const trackedProc = _internals34.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
90261
90651
  let trackedExitCode;
90262
90652
  let trackedOutput;
90263
90653
  try {
@@ -90282,13 +90672,13 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90282
90672
  }
90283
90673
 
90284
90674
  // src/hooks/diff-scope.ts
90285
- var _internals2 = { bunSpawn };
90675
+ var _internals35 = { bunSpawn };
90286
90676
  function getDeclaredScope(taskId, directory) {
90287
90677
  try {
90288
- const planPath = path109.join(directory, ".swarm", "plan.json");
90289
- if (!fs85.existsSync(planPath))
90678
+ const planPath = path110.join(directory, ".swarm", "plan.json");
90679
+ if (!fs87.existsSync(planPath))
90290
90680
  return null;
90291
- const raw = fs85.readFileSync(planPath, "utf-8");
90681
+ const raw = fs87.readFileSync(planPath, "utf-8");
90292
90682
  const plan = JSON.parse(raw);
90293
90683
  for (const phase of plan.phases ?? []) {
90294
90684
  for (const task of phase.tasks ?? []) {
@@ -90317,7 +90707,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
90317
90707
  };
90318
90708
  async function getChangedFiles(directory) {
90319
90709
  try {
90320
- const proc = _internals2.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
90710
+ const proc = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
90321
90711
  cwd: directory,
90322
90712
  ...GIT_DIFF_SPAWN_OPTIONS
90323
90713
  });
@@ -90334,7 +90724,7 @@ async function getChangedFiles(directory) {
90334
90724
  return stdout.trim().split(`
90335
90725
  `).map((f) => f.trim()).filter((f) => f.length > 0);
90336
90726
  }
90337
- const proc2 = _internals2.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
90727
+ const proc2 = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
90338
90728
  cwd: directory,
90339
90729
  ...GIT_DIFF_SPAWN_OPTIONS
90340
90730
  });
@@ -90422,7 +90812,7 @@ var TIER_3_PATTERNS = [
90422
90812
  ];
90423
90813
  function matchesTier3Pattern(files) {
90424
90814
  for (const file3 of files) {
90425
- const fileName = path110.basename(file3);
90815
+ const fileName = path111.basename(file3);
90426
90816
  for (const pattern of TIER_3_PATTERNS) {
90427
90817
  if (pattern.test(fileName)) {
90428
90818
  return true;
@@ -90436,8 +90826,8 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
90436
90826
  if (hasActiveTurboMode()) {
90437
90827
  const resolvedDir2 = workingDirectory;
90438
90828
  try {
90439
- const planPath = path110.join(resolvedDir2, ".swarm", "plan.json");
90440
- const planRaw = fs86.readFileSync(planPath, "utf-8");
90829
+ const planPath = path111.join(resolvedDir2, ".swarm", "plan.json");
90830
+ const planRaw = fs88.readFileSync(planPath, "utf-8");
90441
90831
  const plan = JSON.parse(planRaw);
90442
90832
  for (const planPhase of plan.phases ?? []) {
90443
90833
  for (const task of planPhase.tasks ?? []) {
@@ -90506,8 +90896,8 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
90506
90896
  }
90507
90897
  try {
90508
90898
  const resolvedDir2 = workingDirectory;
90509
- const planPath = path110.join(resolvedDir2, ".swarm", "plan.json");
90510
- const planRaw = fs86.readFileSync(planPath, "utf-8");
90899
+ const planPath = path111.join(resolvedDir2, ".swarm", "plan.json");
90900
+ const planRaw = fs88.readFileSync(planPath, "utf-8");
90511
90901
  const plan = JSON.parse(planRaw);
90512
90902
  for (const planPhase of plan.phases ?? []) {
90513
90903
  for (const task of planPhase.tasks ?? []) {
@@ -90696,8 +91086,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90696
91086
  };
90697
91087
  }
90698
91088
  }
90699
- normalizedDir = path110.normalize(args2.working_directory);
90700
- const pathParts = normalizedDir.split(path110.sep);
91089
+ normalizedDir = path111.normalize(args2.working_directory);
91090
+ const pathParts = normalizedDir.split(path111.sep);
90701
91091
  if (pathParts.includes("..")) {
90702
91092
  return {
90703
91093
  success: false,
@@ -90707,11 +91097,11 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90707
91097
  ]
90708
91098
  };
90709
91099
  }
90710
- const resolvedDir = path110.resolve(normalizedDir);
91100
+ const resolvedDir = path111.resolve(normalizedDir);
90711
91101
  try {
90712
- const realPath = fs86.realpathSync(resolvedDir);
90713
- const planPath = path110.join(realPath, ".swarm", "plan.json");
90714
- if (!fs86.existsSync(planPath)) {
91102
+ const realPath = fs88.realpathSync(resolvedDir);
91103
+ const planPath = path111.join(realPath, ".swarm", "plan.json");
91104
+ if (!fs88.existsSync(planPath)) {
90715
91105
  return {
90716
91106
  success: false,
90717
91107
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -90742,22 +91132,22 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90742
91132
  }
90743
91133
  if (args2.status === "in_progress") {
90744
91134
  try {
90745
- const evidencePath = path110.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
90746
- fs86.mkdirSync(path110.dirname(evidencePath), { recursive: true });
90747
- const fd = fs86.openSync(evidencePath, "wx");
91135
+ const evidencePath = path111.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
91136
+ fs88.mkdirSync(path111.dirname(evidencePath), { recursive: true });
91137
+ const fd = fs88.openSync(evidencePath, "wx");
90748
91138
  let writeOk = false;
90749
91139
  try {
90750
- fs86.writeSync(fd, JSON.stringify({
91140
+ fs88.writeSync(fd, JSON.stringify({
90751
91141
  taskId: args2.task_id,
90752
91142
  required_gates: ["reviewer", "test_engineer"],
90753
91143
  gates: {}
90754
91144
  }, null, 2));
90755
91145
  writeOk = true;
90756
91146
  } finally {
90757
- fs86.closeSync(fd);
91147
+ fs88.closeSync(fd);
90758
91148
  if (!writeOk) {
90759
91149
  try {
90760
- fs86.unlinkSync(evidencePath);
91150
+ fs88.unlinkSync(evidencePath);
90761
91151
  } catch {}
90762
91152
  }
90763
91153
  }
@@ -90767,8 +91157,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90767
91157
  recoverTaskStateFromDelegations(args2.task_id);
90768
91158
  let phaseRequiresReviewer = true;
90769
91159
  try {
90770
- const planPath = path110.join(directory, ".swarm", "plan.json");
90771
- const planRaw = fs86.readFileSync(planPath, "utf-8");
91160
+ const planPath = path111.join(directory, ".swarm", "plan.json");
91161
+ const planRaw = fs88.readFileSync(planPath, "utf-8");
90772
91162
  const plan = JSON.parse(planRaw);
90773
91163
  const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
90774
91164
  if (taskPhase?.required_agents && !taskPhase.required_agents.includes("reviewer")) {
@@ -91078,8 +91468,8 @@ init_utils2();
91078
91468
  init_ledger();
91079
91469
  init_manager();
91080
91470
  init_create_tool();
91081
- import fs87 from "node:fs";
91082
- import path111 from "node:path";
91471
+ import fs89 from "node:fs";
91472
+ import path112 from "node:path";
91083
91473
  function derivePlanId5(plan) {
91084
91474
  return `${plan.swarm}-${plan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
91085
91475
  }
@@ -91130,7 +91520,7 @@ async function executeWriteDriftEvidence(args2, directory) {
91130
91520
  entries: [evidenceEntry]
91131
91521
  };
91132
91522
  const filename = "drift-verifier.json";
91133
- const relativePath = path111.join("evidence", String(phase), filename);
91523
+ const relativePath = path112.join("evidence", String(phase), filename);
91134
91524
  let validatedPath;
91135
91525
  try {
91136
91526
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -91141,12 +91531,12 @@ async function executeWriteDriftEvidence(args2, directory) {
91141
91531
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
91142
91532
  }, null, 2);
91143
91533
  }
91144
- const evidenceDir = path111.dirname(validatedPath);
91534
+ const evidenceDir = path112.dirname(validatedPath);
91145
91535
  try {
91146
- await fs87.promises.mkdir(evidenceDir, { recursive: true });
91147
- const tempPath = path111.join(evidenceDir, `.${filename}.tmp`);
91148
- await fs87.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91149
- await fs87.promises.rename(tempPath, validatedPath);
91536
+ await fs89.promises.mkdir(evidenceDir, { recursive: true });
91537
+ const tempPath = path112.join(evidenceDir, `.${filename}.tmp`);
91538
+ await fs89.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91539
+ await fs89.promises.rename(tempPath, validatedPath);
91150
91540
  let snapshotInfo;
91151
91541
  let snapshotError;
91152
91542
  let qaProfileLocked;
@@ -91240,8 +91630,8 @@ var write_drift_evidence = createSwarmTool({
91240
91630
  init_zod();
91241
91631
  init_utils2();
91242
91632
  init_create_tool();
91243
- import fs88 from "node:fs";
91244
- import path112 from "node:path";
91633
+ import fs90 from "node:fs";
91634
+ import path113 from "node:path";
91245
91635
  function normalizeVerdict2(verdict) {
91246
91636
  switch (verdict) {
91247
91637
  case "APPROVED":
@@ -91289,7 +91679,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
91289
91679
  entries: [evidenceEntry]
91290
91680
  };
91291
91681
  const filename = "hallucination-guard.json";
91292
- const relativePath = path112.join("evidence", String(phase), filename);
91682
+ const relativePath = path113.join("evidence", String(phase), filename);
91293
91683
  let validatedPath;
91294
91684
  try {
91295
91685
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -91300,12 +91690,12 @@ async function executeWriteHallucinationEvidence(args2, directory) {
91300
91690
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
91301
91691
  }, null, 2);
91302
91692
  }
91303
- const evidenceDir = path112.dirname(validatedPath);
91693
+ const evidenceDir = path113.dirname(validatedPath);
91304
91694
  try {
91305
- await fs88.promises.mkdir(evidenceDir, { recursive: true });
91306
- const tempPath = path112.join(evidenceDir, `.${filename}.tmp`);
91307
- await fs88.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91308
- await fs88.promises.rename(tempPath, validatedPath);
91695
+ await fs90.promises.mkdir(evidenceDir, { recursive: true });
91696
+ const tempPath = path113.join(evidenceDir, `.${filename}.tmp`);
91697
+ await fs90.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91698
+ await fs90.promises.rename(tempPath, validatedPath);
91309
91699
  return JSON.stringify({
91310
91700
  success: true,
91311
91701
  phase,
@@ -91351,8 +91741,8 @@ var write_hallucination_evidence = createSwarmTool({
91351
91741
  init_zod();
91352
91742
  init_utils2();
91353
91743
  init_create_tool();
91354
- import fs89 from "node:fs";
91355
- import path113 from "node:path";
91744
+ import fs91 from "node:fs";
91745
+ import path114 from "node:path";
91356
91746
  function normalizeVerdict3(verdict) {
91357
91747
  switch (verdict) {
91358
91748
  case "PASS":
@@ -91426,7 +91816,7 @@ async function executeWriteMutationEvidence(args2, directory) {
91426
91816
  entries: [evidenceEntry]
91427
91817
  };
91428
91818
  const filename = "mutation-gate.json";
91429
- const relativePath = path113.join("evidence", String(phase), filename);
91819
+ const relativePath = path114.join("evidence", String(phase), filename);
91430
91820
  let validatedPath;
91431
91821
  try {
91432
91822
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -91437,12 +91827,12 @@ async function executeWriteMutationEvidence(args2, directory) {
91437
91827
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
91438
91828
  }, null, 2);
91439
91829
  }
91440
- const evidenceDir = path113.dirname(validatedPath);
91830
+ const evidenceDir = path114.dirname(validatedPath);
91441
91831
  try {
91442
- await fs89.promises.mkdir(evidenceDir, { recursive: true });
91443
- const tempPath = path113.join(evidenceDir, `.${filename}.tmp`);
91444
- await fs89.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91445
- await fs89.promises.rename(tempPath, validatedPath);
91832
+ await fs91.promises.mkdir(evidenceDir, { recursive: true });
91833
+ const tempPath = path114.join(evidenceDir, `.${filename}.tmp`);
91834
+ await fs91.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91835
+ await fs91.promises.rename(tempPath, validatedPath);
91446
91836
  return JSON.stringify({
91447
91837
  success: true,
91448
91838
  phase,
@@ -91734,7 +92124,7 @@ async function initializeOpenCodeSwarm(ctx) {
91734
92124
  const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
91735
92125
  preflightTriggerManager = new PTM(automationConfig);
91736
92126
  const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
91737
- const swarmDir = path114.resolve(ctx.directory, ".swarm");
92127
+ const swarmDir = path115.resolve(ctx.directory, ".swarm");
91738
92128
  statusArtifact = new ASA(swarmDir);
91739
92129
  statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
91740
92130
  if (automationConfig.capabilities?.evidence_auto_summaries === true) {
@@ -91840,6 +92230,7 @@ async function initializeOpenCodeSwarm(ctx) {
91840
92230
  completion_verify,
91841
92231
  complexity_hotspots,
91842
92232
  submit_council_verdicts,
92233
+ submit_phase_council_verdicts,
91843
92234
  convene_general_council,
91844
92235
  curator_analyze,
91845
92236
  declare_council_criteria,