opencode-swarm 7.5.0 → 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 +979 -579
  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.0",
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,
@@ -22637,7 +22690,7 @@ var init_quick_lru = __esm(() => {
22637
22690
  // src/context/zone-classifier.ts
22638
22691
  function classifyFile(filePath) {
22639
22692
  const normalized = filePath.toLowerCase().replace(/\\/g, "/");
22640
- if (normalized.endsWith(".wasm") || normalized.includes("/dist/") || normalized.includes("/build/") || normalized.includes(".swarm/checkpoints/")) {
22693
+ if (normalized.endsWith(".wasm") || normalized.startsWith("dist/") || normalized.includes("/dist/") || normalized.startsWith("build/") || normalized.includes("/build/") || normalized.includes(".swarm/checkpoints/")) {
22641
22694
  return {
22642
22695
  filePath,
22643
22696
  zone: "generated",
@@ -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) {
@@ -25225,6 +25279,16 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules, o
25225
25279
  return { allowed: true };
25226
25280
  }
25227
25281
  }
25282
+ if (rules.blockedZones && rules.blockedZones.length > 0) {
25283
+ const { zone } = classifyFile(normalizedPath);
25284
+ if (rules.blockedZones.includes(zone)) {
25285
+ return {
25286
+ allowed: false,
25287
+ reason: `Path blocked: ${normalizedPath} is in ${zone} zone`,
25288
+ zone
25289
+ };
25290
+ }
25291
+ }
25228
25292
  if (rules.allowedGlobs && rules.allowedGlobs.length > 0) {
25229
25293
  const isGlobAllowed = rules.allowedGlobs.some((glob) => {
25230
25294
  const matcher = getGlobMatcher(glob);
@@ -25262,16 +25326,6 @@ function checkFileAuthorityWithRules(agentName, filePath, cwd, effectiveRules, o
25262
25326
  };
25263
25327
  }
25264
25328
  }
25265
- if (rules.blockedZones && rules.blockedZones.length > 0) {
25266
- const { zone } = classifyFile(normalizedPath);
25267
- if (rules.blockedZones.includes(zone)) {
25268
- return {
25269
- allowed: false,
25270
- reason: `Path blocked: ${normalizedPath} is in ${zone} zone`,
25271
- zone
25272
- };
25273
- }
25274
- }
25275
25329
  return { allowed: true };
25276
25330
  }
25277
25331
  var import_picomatch, storedInputArgs, TRANSIENT_MODEL_ERROR_PATTERN, toolCallsSinceLastWrite, noOpWarningIssued, consecutiveNoToolTurns, DC_MAX_UNWRAP_DEPTH = 5, DC_SAFE_TARGETS, DC_BLOCKED_ABSOLUTE_PREFIXES, DC_FS_ROOTS, DC_REMOTE_PREFIXES, pathNormalizationCache, globMatcherCache, DEFAULT_AGENT_AUTHORITY_RULES;
@@ -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();
@@ -25390,15 +25446,24 @@ var init_guardrails = __esm(() => {
25390
25446
  test_engineer: {
25391
25447
  blockedExact: [".swarm/plan.md", ".swarm/plan.json"],
25392
25448
  blockedPrefix: ["src/"],
25393
- allowedPrefix: ["tests/", ".swarm/evidence/"],
25449
+ allowedPrefix: ["tests/", "test/", ".swarm/evidence/"],
25450
+ allowedGlobs: [
25451
+ "**/tests/**",
25452
+ "**/test/**",
25453
+ "**/__tests__/**",
25454
+ "**/*.test.*",
25455
+ "**/*.spec.*"
25456
+ ],
25394
25457
  blockedZones: ["generated"]
25395
25458
  },
25396
25459
  docs: {
25397
25460
  allowedPrefix: ["docs/", ".swarm/outputs/"],
25461
+ allowedGlobs: ["**/docs/**", "**/*.md", "**/*.mdx", "**/*.rst"],
25398
25462
  blockedZones: ["generated"]
25399
25463
  },
25400
25464
  designer: {
25401
25465
  allowedPrefix: ["docs/", ".swarm/outputs/"],
25466
+ allowedGlobs: ["**/docs/**", "**/*.md", "**/*.mdx", "**/*.rst"],
25402
25467
  blockedZones: ["generated"]
25403
25468
  },
25404
25469
  critic: {
@@ -26253,6 +26318,7 @@ var init_delegation_gate = __esm(() => {
26253
26318
  init_schema();
26254
26319
  init_state();
26255
26320
  init_telemetry();
26321
+ init_logger();
26256
26322
  init_guardrails();
26257
26323
  init_normalize_tool_name();
26258
26324
  init_utils2();
@@ -26310,6 +26376,7 @@ __export(exports_state, {
26310
26376
  advanceTaskStateAndPersist: () => advanceTaskStateAndPersist,
26311
26377
  advanceTaskState: () => advanceTaskState,
26312
26378
  _resetCouncilDisagreementWarnings: () => _resetCouncilDisagreementWarnings,
26379
+ _internals: () => _internals9,
26313
26380
  AgentRunContext: () => AgentRunContext
26314
26381
  });
26315
26382
  import * as fs10 from "node:fs/promises";
@@ -26403,10 +26470,10 @@ function startAgentSession(sessionId, agentName, staleDurationMs = 7200000, dire
26403
26470
  swarmState.agentSessions.set(sessionId, sessionState);
26404
26471
  telemetry.sessionStarted(sessionId, agentName);
26405
26472
  swarmState.activeAgent.set(sessionId, agentName);
26406
- applyRehydrationCache(sessionState);
26473
+ _internals9.applyRehydrationCache(sessionState);
26407
26474
  if (directory) {
26408
26475
  let rehydrationPromise;
26409
- rehydrationPromise = rehydrateSessionFromDisk(directory, sessionState).catch((err2) => {
26476
+ rehydrationPromise = _internals9.rehydrateSessionFromDisk(directory, sessionState).catch((err2) => {
26410
26477
  console.warn("[state] Rehydration failed:", err2 instanceof Error ? err2.message : String(err2));
26411
26478
  }).finally(() => {
26412
26479
  swarmState.pendingRehydrations.delete(rehydrationPromise);
@@ -26561,7 +26628,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
26561
26628
  session.lastToolCallTime = now;
26562
26629
  return session;
26563
26630
  }
26564
- startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
26631
+ _internals9.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
26565
26632
  session = swarmState.agentSessions.get(sessionId);
26566
26633
  if (!session) {
26567
26634
  throw new Error(`Failed to create guardrail session for ${sessionId}`);
@@ -26918,8 +26985,8 @@ function applyRehydrationCache(session) {
26918
26985
  }
26919
26986
  }
26920
26987
  async function rehydrateSessionFromDisk(directory, session) {
26921
- await buildRehydrationCache(directory);
26922
- applyRehydrationCache(session);
26988
+ await _internals9.buildRehydrationCache(directory);
26989
+ _internals9.applyRehydrationCache(session);
26923
26990
  }
26924
26991
  function hasActiveTurboMode(sessionID) {
26925
26992
  if (sessionID) {
@@ -26962,7 +27029,7 @@ function ensureSessionEnvironment(sessionId) {
26962
27029
  }).catch(() => {});
26963
27030
  return profile;
26964
27031
  }
26965
- var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState;
27032
+ var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState, _internals9;
26966
27033
  var init_state = __esm(() => {
26967
27034
  init_constants();
26968
27035
  init_plan_schema();
@@ -26990,6 +27057,24 @@ var init_state = __esm(() => {
26990
27057
  fullAutoEnabledInConfig: false,
26991
27058
  environmentProfiles: defaultRunContext.environmentProfiles
26992
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
+ };
26993
27078
  });
26994
27079
 
26995
27080
  // src/commands/benchmark.ts
@@ -40527,6 +40612,19 @@ function getCurrentBranch(cwd) {
40527
40612
  const output = gitExec2(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
40528
40613
  return output.trim();
40529
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
+ }
40530
40628
  function hasUncommittedChanges(cwd) {
40531
40629
  const status = gitExec2(["status", "--porcelain"], cwd);
40532
40630
  return status.trim().length > 0;
@@ -40562,7 +40660,7 @@ function resetToRemoteBranch(cwd, options) {
40562
40660
  const prunedBranches = [];
40563
40661
  try {
40564
40662
  const currentBranch = getCurrentBranch(cwd);
40565
- const defaultRemoteBranch = detectDefaultRemoteBranch(cwd);
40663
+ const defaultRemoteBranch = _internals10.detectDefaultRemoteBranch(cwd);
40566
40664
  if (!defaultRemoteBranch) {
40567
40665
  return {
40568
40666
  success: false,
@@ -40741,8 +40839,16 @@ function resetToRemoteBranch(cwd, options) {
40741
40839
  };
40742
40840
  }
40743
40841
  }
40744
- var GIT_TIMEOUT_MS2 = 30000;
40745
- 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
+ });
40746
40852
 
40747
40853
  // src/hooks/knowledge-store.ts
40748
40854
  import { existsSync as existsSync9 } from "node:fs";
@@ -41224,6 +41330,7 @@ async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
41224
41330
  }
41225
41331
  var JACCARD_THRESHOLD = 0.6, HIVE_TIER_BOOST = 0.05, SAME_PROJECT_PENALTY = -0.05;
41226
41332
  var init_knowledge_reader = __esm(() => {
41333
+ init_logger();
41227
41334
  init_knowledge_store();
41228
41335
  });
41229
41336
 
@@ -41480,6 +41587,7 @@ async function restoreEntry(directory, entryId) {
41480
41587
  }
41481
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;
41482
41589
  var init_knowledge_validator = __esm(() => {
41590
+ init_logger();
41483
41591
  init_knowledge_store();
41484
41592
  import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
41485
41593
  DANGEROUS_COMMAND_PATTERNS = [
@@ -41796,7 +41904,7 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
41796
41904
  existingEntries.push(entry);
41797
41905
  }
41798
41906
  await enforceKnowledgeCap(knowledgePath, config3.swarm_max_entries);
41799
- await runAutoPromotion(directory, config3);
41907
+ await _internals11.runAutoPromotion(directory, config3);
41800
41908
  return { stored, skipped, rejected };
41801
41909
  }
41802
41910
  async function runAutoPromotion(directory, config3) {
@@ -41877,7 +41985,7 @@ function createKnowledgeCuratorHook(directory, config3) {
41877
41985
  });
41878
41986
  const projectName2 = evidenceData.project_name ?? "unknown";
41879
41987
  const phaseNumber2 = typeof evidenceData.phase_number === "number" ? evidenceData.phase_number : 1;
41880
- await curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
41988
+ await _internals11.curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
41881
41989
  await updateRetrievalOutcome(directory, `Phase ${phaseNumber2}`, true);
41882
41990
  return;
41883
41991
  }
@@ -41900,18 +42008,24 @@ function createKnowledgeCuratorHook(directory, config3) {
41900
42008
  const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
41901
42009
  const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
41902
42010
  const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
41903
- await curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
42011
+ await _internals11.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
41904
42012
  await updateRetrievalOutcome(directory, `Phase ${phaseNumber}`, true);
41905
42013
  };
41906
42014
  return safeHook(handler);
41907
42015
  }
41908
- var seenRetroSections;
42016
+ var seenRetroSections, _internals11;
41909
42017
  var init_knowledge_curator = __esm(() => {
41910
42018
  init_knowledge_reader();
41911
42019
  init_knowledge_store();
41912
42020
  init_knowledge_validator();
41913
42021
  init_utils2();
41914
42022
  seenRetroSections = new Map;
42023
+ _internals11 = {
42024
+ isWriteToEvidenceFile,
42025
+ curateAndStoreSwarm,
42026
+ runAutoPromotion,
42027
+ createKnowledgeCuratorHook
42028
+ };
41915
42029
  });
41916
42030
 
41917
42031
  // src/session/snapshot-writer.ts
@@ -42019,21 +42133,26 @@ async function writeSnapshot(directory, state) {
42019
42133
  }
42020
42134
  function createSnapshotWriterHook(directory) {
42021
42135
  return (_input, _output) => {
42022
- _writeInFlight = _writeInFlight.then(() => writeSnapshot(directory, swarmState), () => writeSnapshot(directory, swarmState));
42136
+ _writeInFlight = _writeInFlight.then(() => _internals12.writeSnapshot(directory, swarmState), () => _internals12.writeSnapshot(directory, swarmState));
42023
42137
  return _writeInFlight;
42024
42138
  };
42025
42139
  }
42026
42140
  async function flushPendingSnapshot(directory) {
42027
- _writeInFlight = _writeInFlight.then(() => writeSnapshot(directory, swarmState), () => writeSnapshot(directory, swarmState));
42141
+ _writeInFlight = _writeInFlight.then(() => _internals12.writeSnapshot(directory, swarmState), () => _internals12.writeSnapshot(directory, swarmState));
42028
42142
  await _writeInFlight;
42029
42143
  }
42030
- var _writeInFlight;
42144
+ var _writeInFlight, _internals12;
42031
42145
  var init_snapshot_writer = __esm(() => {
42032
42146
  init_utils2();
42033
42147
  init_state();
42034
42148
  init_utils();
42035
42149
  init_bun_compat();
42036
42150
  _writeInFlight = Promise.resolve();
42151
+ _internals12 = {
42152
+ writeSnapshot,
42153
+ createSnapshotWriterHook,
42154
+ flushPendingSnapshot
42155
+ };
42037
42156
  });
42038
42157
 
42039
42158
  // src/tools/write-retro.ts
@@ -42337,7 +42456,7 @@ async function executeWriteRetro(args2, directory) {
42337
42456
  }, null, 2);
42338
42457
  }
42339
42458
  }
42340
- var write_retro;
42459
+ var write_retro, _internals13;
42341
42460
  var init_write_retro = __esm(() => {
42342
42461
  init_zod();
42343
42462
  init_evidence_schema();
@@ -42384,12 +42503,16 @@ var init_write_retro = __esm(() => {
42384
42503
  task_id: args2.task_id !== undefined ? String(args2.task_id) : undefined,
42385
42504
  metadata: args2.metadata
42386
42505
  };
42387
- return await executeWriteRetro(writeRetroArgs, directory);
42506
+ return await _internals13.executeWriteRetro(writeRetroArgs, directory);
42388
42507
  } catch {
42389
42508
  return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
42390
42509
  }
42391
42510
  }
42392
42511
  });
42512
+ _internals13 = {
42513
+ executeWriteRetro,
42514
+ write_retro
42515
+ };
42393
42516
  });
42394
42517
 
42395
42518
  // src/commands/close.ts
@@ -43441,8 +43564,8 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43441
43564
  const observations = [];
43442
43565
  const timestamp = new Date().toISOString();
43443
43566
  for (const agent of requiredAgents) {
43444
- const normalizedAgent = normalizeAgentName(agent);
43445
- const isDispatched = agentsDispatched.some((a) => normalizeAgentName(a) === normalizedAgent);
43567
+ const normalizedAgent = _internals14.normalizeAgentName(agent);
43568
+ const isDispatched = agentsDispatched.some((a) => _internals14.normalizeAgentName(a) === normalizedAgent);
43446
43569
  if (!isDispatched) {
43447
43570
  observations.push({
43448
43571
  phase,
@@ -43461,7 +43584,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43461
43584
  if (e.type === "agent.delegation") {
43462
43585
  const agent = e.agent;
43463
43586
  if (agent && typeof agent === "string") {
43464
- const normalized = normalizeAgentName(agent);
43587
+ const normalized = _internals14.normalizeAgentName(agent);
43465
43588
  if (normalized === "coder") {
43466
43589
  coderDelegations.push({ event: e, index: i2 });
43467
43590
  } else if (normalized === "reviewer") {
@@ -43518,7 +43641,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43518
43641
  if (e.type === "agent.delegation" && e.agent) {
43519
43642
  const agent = e.agent;
43520
43643
  if (agent && typeof agent === "string") {
43521
- const normalized = normalizeAgentName(agent);
43644
+ const normalized = _internals14.normalizeAgentName(agent);
43522
43645
  if (normalized === "sme") {
43523
43646
  smeDelegations.push({ event: e, index: i2 });
43524
43647
  }
@@ -43542,7 +43665,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
43542
43665
  }
43543
43666
  async function runCuratorInit(directory, config3, llmDelegate) {
43544
43667
  try {
43545
- const priorSummary = await readCuratorSummary(directory);
43668
+ const priorSummary = await _internals14.readCuratorSummary(directory);
43546
43669
  const knowledgePath = resolveSwarmKnowledgePath(directory);
43547
43670
  const allEntries = await readKnowledge(knowledgePath);
43548
43671
  const highConfidenceEntries = allEntries.filter((e) => typeof e.confidence === "number" && e.confidence >= config3.min_knowledge_confidence);
@@ -43661,7 +43784,7 @@ Could not load prior session context.`,
43661
43784
  }
43662
43785
  async function runCuratorPhase(directory, phase, agentsDispatched, config3, _knowledgeConfig, llmDelegate) {
43663
43786
  try {
43664
- const priorSummary = await readCuratorSummary(directory);
43787
+ const priorSummary = await _internals14.readCuratorSummary(directory);
43665
43788
  if (priorSummary?.phase_digests.some((d) => d.phase === phase)) {
43666
43789
  const existingDigest = priorSummary.phase_digests.find((d) => d.phase === phase);
43667
43790
  return {
@@ -43673,10 +43796,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43673
43796
  };
43674
43797
  }
43675
43798
  const eventsJsonlContent = await readSwarmFileAsync(directory, "events.jsonl");
43676
- const phaseEvents = eventsJsonlContent ? filterPhaseEvents(eventsJsonlContent, phase) : [];
43799
+ const phaseEvents = eventsJsonlContent ? _internals14.filterPhaseEvents(eventsJsonlContent, phase) : [];
43677
43800
  const contextMd = await readSwarmFileAsync(directory, "context.md");
43678
43801
  const requiredAgents = ["reviewer", "test_engineer"];
43679
- const complianceObservations = checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
43802
+ const complianceObservations = _internals14.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
43680
43803
  const plan = await loadPlanJsonOnly(directory);
43681
43804
  const phaseData = plan?.phases.find((p) => p.id === phase);
43682
43805
  const tasksCompleted = phaseData ? phaseData.tasks.filter((t) => t.status === "completed").length : 0;
@@ -43699,7 +43822,9 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43699
43822
  phase,
43700
43823
  timestamp: new Date().toISOString(),
43701
43824
  summary: `Phase ${phase} completed. ${tasksCompleted}/${tasksTotal} tasks completed. ${complianceObservations.length} compliance observations.`,
43702
- agents_used: [...new Set(agentsDispatched.map(normalizeAgentName))],
43825
+ agents_used: [
43826
+ ...new Set(agentsDispatched.map((a) => _internals14.normalizeAgentName(a)))
43827
+ ],
43703
43828
  tasks_completed: tasksCompleted,
43704
43829
  tasks_total: tasksTotal,
43705
43830
  key_decisions: keyDecisions.slice(0, 5),
@@ -43744,7 +43869,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
43744
43869
  clearTimeout(timer);
43745
43870
  }
43746
43871
  if (llmOutput?.trim()) {
43747
- knowledgeRecommendations = parseKnowledgeRecommendations(llmOutput);
43872
+ knowledgeRecommendations = _internals14.parseKnowledgeRecommendations(llmOutput);
43748
43873
  }
43749
43874
  getGlobalEventBus().publish("curator.phase.llm_completed", {
43750
43875
  phase,
@@ -43790,7 +43915,7 @@ ${phaseDigest.summary}`,
43790
43915
  knowledge_recommendations: knowledgeRecommendations
43791
43916
  };
43792
43917
  }
43793
- await writeCuratorSummary(directory, updatedSummary);
43918
+ await _internals14.writeCuratorSummary(directory, updatedSummary);
43794
43919
  const eventsPath = path21.join(directory, ".swarm", "events.jsonl");
43795
43920
  for (const obs of complianceObservations) {
43796
43921
  await appendKnowledge(eventsPath, {
@@ -43976,14 +44101,23 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
43976
44101
  }
43977
44102
  return { applied, skipped };
43978
44103
  }
43979
- var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000;
44104
+ var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000, _internals14;
43980
44105
  var init_curator = __esm(() => {
43981
44106
  init_event_bus();
43982
44107
  init_manager();
43983
44108
  init_bun_compat();
44109
+ init_logger();
43984
44110
  init_knowledge_store();
43985
44111
  init_knowledge_validator();
43986
44112
  init_utils2();
44113
+ _internals14 = {
44114
+ parseKnowledgeRecommendations,
44115
+ readCuratorSummary,
44116
+ writeCuratorSummary,
44117
+ filterPhaseEvents,
44118
+ checkPhaseCompliance,
44119
+ normalizeAgentName
44120
+ };
43987
44121
  });
43988
44122
 
43989
44123
  // src/hooks/hive-promoter.ts
@@ -44291,7 +44425,8 @@ __export(exports_co_change_analyzer, {
44291
44425
  detectDarkMatter: () => detectDarkMatter,
44292
44426
  darkMatterToKnowledgeEntries: () => darkMatterToKnowledgeEntries,
44293
44427
  co_change_analyzer: () => co_change_analyzer,
44294
- buildCoChangeMatrix: () => buildCoChangeMatrix
44428
+ buildCoChangeMatrix: () => buildCoChangeMatrix,
44429
+ _internals: () => _internals15
44295
44430
  });
44296
44431
  import * as child_process3 from "node:child_process";
44297
44432
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -44514,9 +44649,9 @@ async function detectDarkMatter(directory, options) {
44514
44649
  } catch {
44515
44650
  return [];
44516
44651
  }
44517
- const commitMap = await parseGitLog(directory, maxCommitsToAnalyze);
44518
- const matrix = buildCoChangeMatrix(commitMap);
44519
- 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);
44520
44655
  const results = [];
44521
44656
  for (const entry of matrix.values()) {
44522
44657
  const key = `${entry.fileA}::${entry.fileB}`;
@@ -44596,7 +44731,7 @@ ${rows}
44596
44731
  These pairs likely share an architectural concern invisible to static analysis.
44597
44732
  Consider adding explicit documentation or extracting the shared concern.`;
44598
44733
  }
44599
- var co_change_analyzer;
44734
+ var co_change_analyzer, _internals15;
44600
44735
  var init_co_change_analyzer = __esm(() => {
44601
44736
  init_zod();
44602
44737
  init_create_tool();
@@ -44628,10 +44763,18 @@ var init_co_change_analyzer = __esm(() => {
44628
44763
  npmiThreshold,
44629
44764
  maxCommitsToAnalyze
44630
44765
  };
44631
- const pairs = await detectDarkMatter(directory, options);
44632
- return formatDarkMatterOutput(pairs);
44766
+ const pairs = await _internals15.detectDarkMatter(directory, options);
44767
+ return _internals15.formatDarkMatterOutput(pairs);
44633
44768
  }
44634
44769
  });
44770
+ _internals15 = {
44771
+ parseGitLog,
44772
+ buildCoChangeMatrix,
44773
+ getStaticEdges,
44774
+ detectDarkMatter,
44775
+ darkMatterToKnowledgeEntries,
44776
+ formatDarkMatterOutput
44777
+ };
44635
44778
  });
44636
44779
 
44637
44780
  // src/commands/dark-matter.ts
@@ -47445,7 +47588,7 @@ async function discoverBuildCommands(workingDir, options) {
47445
47588
  const scope = options?.scope ?? "all";
47446
47589
  const changedFiles = options?.changedFiles ?? [];
47447
47590
  const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
47448
- const profileResult = await discoverBuildCommandsFromProfiles(workingDir);
47591
+ const profileResult = await _internals16.discoverBuildCommandsFromProfiles(workingDir);
47449
47592
  const profileCommands = profileResult.commands;
47450
47593
  const profileSkipped = profileResult.skipped;
47451
47594
  const coveredEcosystems = new Set;
@@ -47502,7 +47645,13 @@ async function discoverBuildCommands(workingDir, options) {
47502
47645
  commands.sort((a, b) => a.priority - b.priority);
47503
47646
  return { commands, skipped };
47504
47647
  }
47505
- 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;
47506
47655
  var init_discovery = __esm(() => {
47507
47656
  init_dist();
47508
47657
  init_detector();
@@ -47620,6 +47769,13 @@ var init_discovery = __esm(() => {
47620
47769
  php: ["php-composer"]
47621
47770
  };
47622
47771
  toolchainCache = new Map;
47772
+ _internals16 = {
47773
+ isCommandAvailable,
47774
+ discoverBuildCommandsFromProfiles,
47775
+ discoverBuildCommands,
47776
+ clearToolchainCache,
47777
+ getEcosystems
47778
+ };
47623
47779
  build_discovery = tool({
47624
47780
  description: "Discover build commands for various ecosystems in a project directory",
47625
47781
  args: {
@@ -47882,6 +48038,7 @@ var exports_evidence_summary_service = {};
47882
48038
  __export(exports_evidence_summary_service, {
47883
48039
  isAutoSummaryEnabled: () => isAutoSummaryEnabled,
47884
48040
  buildEvidenceSummary: () => buildEvidenceSummary,
48041
+ _internals: () => _internals17,
47885
48042
  REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
47886
48043
  EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
47887
48044
  });
@@ -47919,14 +48076,14 @@ function getTaskStatus(task, bundle) {
47919
48076
  if (task?.status) {
47920
48077
  return task.status;
47921
48078
  }
47922
- const entries = normalizeBundleEntries(bundle);
48079
+ const entries = _internals17.normalizeBundleEntries(bundle);
47923
48080
  if (entries.length > 0) {
47924
48081
  return "completed";
47925
48082
  }
47926
48083
  return "pending";
47927
48084
  }
47928
48085
  function isEvidenceComplete(bundle) {
47929
- const entries = normalizeBundleEntries(bundle);
48086
+ const entries = _internals17.normalizeBundleEntries(bundle);
47930
48087
  if (entries.length === 0) {
47931
48088
  return {
47932
48089
  isComplete: false,
@@ -47962,10 +48119,10 @@ async function buildTaskSummary(directory, task, taskId) {
47962
48119
  const result = await loadEvidence(directory, taskId);
47963
48120
  const bundle = result.status === "found" ? result.bundle : null;
47964
48121
  const phase = task?.phase ?? 0;
47965
- const status = getTaskStatus(task, bundle);
47966
- const evidenceCheck = isEvidenceComplete(bundle);
47967
- const blockers = getTaskBlockers(task, evidenceCheck, status);
47968
- 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);
47969
48126
  const hasReview = entries.some((e) => e.type === "review");
47970
48127
  const hasTest = entries.some((e) => e.type === "test");
47971
48128
  const hasApproval = entries.some((e) => e.type === "approval");
@@ -47994,12 +48151,12 @@ async function buildPhaseSummary(directory, phase) {
47994
48151
  const taskSummaries = [];
47995
48152
  const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
47996
48153
  for (const task of phase.tasks) {
47997
- const summary = await buildTaskSummary(directory, task, task.id);
48154
+ const summary = await _internals17.buildTaskSummary(directory, task, task.id);
47998
48155
  taskSummaries.push(summary);
47999
48156
  }
48000
48157
  const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
48001
48158
  for (const taskId of extraTaskIds) {
48002
- const summary = await buildTaskSummary(directory, undefined, taskId);
48159
+ const summary = await _internals17.buildTaskSummary(directory, undefined, taskId);
48003
48160
  if (summary.phase === phase.id) {
48004
48161
  taskSummaries.push(summary);
48005
48162
  }
@@ -48100,7 +48257,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
48100
48257
  let totalTasks = 0;
48101
48258
  let completedTasks = 0;
48102
48259
  for (const phase of phasesToProcess) {
48103
- const summary = await buildPhaseSummary(directory, phase);
48260
+ const summary = await _internals17.buildPhaseSummary(directory, phase);
48104
48261
  phaseSummaries.push(summary);
48105
48262
  totalTasks += summary.totalTasks;
48106
48263
  completedTasks += summary.completedTasks;
@@ -48122,7 +48279,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
48122
48279
  overallBlockers,
48123
48280
  summaryText: ""
48124
48281
  };
48125
- artifact.summaryText = generateSummaryText(artifact);
48282
+ artifact.summaryText = _internals17.generateSummaryText(artifact);
48126
48283
  log("[EvidenceSummary] Summary built", {
48127
48284
  phases: phaseSummaries.length,
48128
48285
  totalTasks,
@@ -48141,7 +48298,7 @@ function isAutoSummaryEnabled(automationConfig) {
48141
48298
  }
48142
48299
  return automationConfig.capabilities?.evidence_auto_summaries === true;
48143
48300
  }
48144
- 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;
48145
48302
  var init_evidence_summary_service = __esm(() => {
48146
48303
  init_manager2();
48147
48304
  init_manager();
@@ -48155,6 +48312,17 @@ var init_evidence_summary_service = __esm(() => {
48155
48312
  "retrospective"
48156
48313
  ]);
48157
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
+ };
48158
48326
  });
48159
48327
 
48160
48328
  // src/services/evidence-service.ts
@@ -48454,7 +48622,7 @@ function extractCurrentPhaseFromPlan2(plan) {
48454
48622
  if (!plan) {
48455
48623
  return { currentPhase: null, currentTask: null, incompleteTasks: [] };
48456
48624
  }
48457
- if (!validatePlanPhases(plan)) {
48625
+ if (!_internals18.validatePlanPhases(plan)) {
48458
48626
  return { currentPhase: null, currentTask: null, incompleteTasks: [] };
48459
48627
  }
48460
48628
  let currentPhase = null;
@@ -48596,9 +48764,9 @@ function extractPhaseMetrics(content) {
48596
48764
  async function getHandoffData(directory) {
48597
48765
  const now = new Date().toISOString();
48598
48766
  const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
48599
- const sessionState = parseSessionState(sessionContent);
48767
+ const sessionState = _internals18.parseSessionState(sessionContent);
48600
48768
  const plan = await loadPlanJsonOnly(directory);
48601
- const planInfo = extractCurrentPhaseFromPlan2(plan);
48769
+ const planInfo = _internals18.extractCurrentPhaseFromPlan(plan);
48602
48770
  if (!plan) {
48603
48771
  const planMdContent = await readSwarmFileAsync(directory, "plan.md");
48604
48772
  if (planMdContent) {
@@ -48617,8 +48785,8 @@ async function getHandoffData(directory) {
48617
48785
  }
48618
48786
  }
48619
48787
  const contextContent = await readSwarmFileAsync(directory, "context.md");
48620
- const recentDecisions = extractDecisions2(contextContent);
48621
- const rawPhaseMetrics = extractPhaseMetrics(contextContent);
48788
+ const recentDecisions = _internals18.extractDecisions(contextContent);
48789
+ const rawPhaseMetrics = _internals18.extractPhaseMetrics(contextContent);
48622
48790
  const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
48623
48791
  let delegationState = null;
48624
48792
  if (sessionState?.delegationState) {
@@ -48782,12 +48950,24 @@ ${lines.join(`
48782
48950
  `)}
48783
48951
  \`\`\``;
48784
48952
  }
48785
- 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;
48786
48954
  var init_handoff_service = __esm(() => {
48787
48955
  init_utils2();
48788
48956
  init_manager();
48789
48957
  init_utils();
48790
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
+ };
48791
48971
  });
48792
48972
 
48793
48973
  // src/commands/handoff.ts
@@ -49182,6 +49362,15 @@ import { randomUUID as randomUUID3 } from "node:crypto";
49182
49362
  import { existsSync as existsSync16, readFileSync as readFileSync11 } from "node:fs";
49183
49363
  import { mkdir as mkdir6, readFile as readFile8, writeFile as writeFile6 } from "node:fs/promises";
49184
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
+ }
49185
49374
  async function migrateContextToKnowledge(directory, config3) {
49186
49375
  const sentinelPath = path30.join(directory, ".swarm", ".knowledge-migrated");
49187
49376
  const contextPath = path30.join(directory, ".swarm", "context.md");
@@ -49214,9 +49403,9 @@ async function migrateContextToKnowledge(directory, config3) {
49214
49403
  skippedReason: "empty-context"
49215
49404
  };
49216
49405
  }
49217
- const rawEntries = parseContextMd(contextContent);
49406
+ const rawEntries = _internals19.parseContextMd(contextContent);
49218
49407
  if (rawEntries.length === 0) {
49219
- await writeSentinel(sentinelPath, 0, 0);
49408
+ await _internals19.writeSentinel(sentinelPath, 0, 0);
49220
49409
  return {
49221
49410
  migrated: true,
49222
49411
  entriesMigrated: 0,
@@ -49227,10 +49416,10 @@ async function migrateContextToKnowledge(directory, config3) {
49227
49416
  const existing = await readKnowledge(knowledgePath);
49228
49417
  let migrated = 0;
49229
49418
  let dropped = 0;
49230
- const projectName = inferProjectName(directory);
49419
+ const projectName = _internals19.inferProjectName(directory);
49231
49420
  for (const raw of rawEntries) {
49232
49421
  if (config3.validation_enabled !== false) {
49233
- const category = raw.categoryHint ?? inferCategoryFromText(raw.text);
49422
+ const category = raw.categoryHint ?? _internals19.inferCategoryFromText(raw.text);
49234
49423
  const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
49235
49424
  category,
49236
49425
  scope: "global",
@@ -49250,8 +49439,8 @@ async function migrateContextToKnowledge(directory, config3) {
49250
49439
  const entry = {
49251
49440
  id: randomUUID3(),
49252
49441
  tier: "swarm",
49253
- lesson: truncateLesson(raw.text),
49254
- category: raw.categoryHint ?? inferCategoryFromText(raw.text),
49442
+ lesson: _internals19.truncateLesson(raw.text),
49443
+ category: raw.categoryHint ?? _internals19.inferCategoryFromText(raw.text),
49255
49444
  tags: [...inferredTags, `migration:${raw.sourceSection}`],
49256
49445
  scope: "global",
49257
49446
  confidence: 0.3,
@@ -49274,7 +49463,7 @@ async function migrateContextToKnowledge(directory, config3) {
49274
49463
  if (migrated > 0) {
49275
49464
  await rewriteKnowledge(knowledgePath, existing);
49276
49465
  }
49277
- await writeSentinel(sentinelPath, migrated, dropped);
49466
+ await _internals19.writeSentinel(sentinelPath, migrated, dropped);
49278
49467
  log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
49279
49468
  return {
49280
49469
  migrated: true,
@@ -49284,7 +49473,7 @@ async function migrateContextToKnowledge(directory, config3) {
49284
49473
  };
49285
49474
  }
49286
49475
  function parseContextMd(content) {
49287
- const sections = splitIntoSections(content);
49476
+ const sections = _internals19.splitIntoSections(content);
49288
49477
  const entries = [];
49289
49478
  const seen = new Set;
49290
49479
  const sectionPatterns = [
@@ -49300,7 +49489,7 @@ function parseContextMd(content) {
49300
49489
  const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
49301
49490
  if (!match)
49302
49491
  continue;
49303
- const bullets = extractBullets(section.body);
49492
+ const bullets = _internals19.extractBullets(section.body);
49304
49493
  for (const bullet of bullets) {
49305
49494
  if (bullet.length < 15)
49306
49495
  continue;
@@ -49309,9 +49498,9 @@ function parseContextMd(content) {
49309
49498
  continue;
49310
49499
  seen.add(normalized);
49311
49500
  entries.push({
49312
- text: truncateLesson(bullet),
49501
+ text: _internals19.truncateLesson(bullet),
49313
49502
  sourceSection: match.sourceSection,
49314
- categoryHint: inferCategoryFromText(bullet)
49503
+ categoryHint: _internals19.inferCategoryFromText(bullet)
49315
49504
  });
49316
49505
  }
49317
49506
  }
@@ -49404,9 +49593,22 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
49404
49593
  await mkdir6(path30.dirname(sentinelPath), { recursive: true });
49405
49594
  await writeFile6(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
49406
49595
  }
49596
+ var _internals19;
49407
49597
  var init_knowledge_migrator = __esm(() => {
49598
+ init_logger();
49408
49599
  init_knowledge_store();
49409
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
+ };
49410
49612
  });
49411
49613
 
49412
49614
  // src/commands/knowledge.ts
@@ -50314,7 +50516,7 @@ async function runAdditionalLint(linter, mode, cwd) {
50314
50516
  };
50315
50517
  }
50316
50518
  }
50317
- var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint;
50519
+ var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals20;
50318
50520
  var init_lint = __esm(() => {
50319
50521
  init_zod();
50320
50522
  init_discovery();
@@ -50346,15 +50548,15 @@ var init_lint = __esm(() => {
50346
50548
  }
50347
50549
  const { mode } = args2;
50348
50550
  const cwd = directory;
50349
- const linter = await detectAvailableLinter(directory);
50551
+ const linter = await _internals20.detectAvailableLinter(directory);
50350
50552
  if (linter) {
50351
- const result = await runLint(linter, mode, directory);
50553
+ const result = await _internals20.runLint(linter, mode, directory);
50352
50554
  return JSON.stringify(result, null, 2);
50353
50555
  }
50354
- const additionalLinter = detectAdditionalLinter(cwd);
50556
+ const additionalLinter = _internals20.detectAdditionalLinter(cwd);
50355
50557
  if (additionalLinter) {
50356
50558
  warn(`[lint] Using ${additionalLinter} linter for this project`);
50357
- const result = await runAdditionalLint(additionalLinter, mode, cwd);
50559
+ const result = await _internals20.runAdditionalLint(additionalLinter, mode, cwd);
50358
50560
  return JSON.stringify(result, null, 2);
50359
50561
  }
50360
50562
  const errorResult = {
@@ -50368,6 +50570,12 @@ For Rust: rustup component add clippy`
50368
50570
  return JSON.stringify(errorResult, null, 2);
50369
50571
  }
50370
50572
  });
50573
+ _internals20 = {
50574
+ detectAvailableLinter,
50575
+ runLint,
50576
+ detectAdditionalLinter,
50577
+ runAdditionalLint
50578
+ };
50371
50579
  });
50372
50580
 
50373
50581
  // src/tools/secretscan.ts
@@ -50676,7 +50884,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
50676
50884
  }
50677
50885
  async function runSecretscan(directory) {
50678
50886
  try {
50679
- const result = await secretscan.execute({ directory }, {});
50887
+ const result = await _internals21.secretscan.execute({ directory }, {});
50680
50888
  const jsonStr = typeof result === "string" ? result : result.output;
50681
50889
  return JSON.parse(jsonStr);
50682
50890
  } catch (e) {
@@ -50691,7 +50899,7 @@ async function runSecretscan(directory) {
50691
50899
  return errorResult;
50692
50900
  }
50693
50901
  }
50694
- 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;
50695
50903
  var init_secretscan = __esm(() => {
50696
50904
  init_zod();
50697
50905
  init_path_security();
@@ -51063,6 +51271,10 @@ var init_secretscan = __esm(() => {
51063
51271
  }
51064
51272
  }
51065
51273
  });
51274
+ _internals21 = {
51275
+ secretscan,
51276
+ runSecretscan
51277
+ };
51066
51278
  });
51067
51279
 
51068
51280
  // src/test-impact/analyzer.ts
@@ -51194,8 +51406,8 @@ async function buildImpactMapInternal(cwd) {
51194
51406
  return impactMap;
51195
51407
  }
51196
51408
  async function buildImpactMap(cwd) {
51197
- const impactMap = await buildImpactMapInternal(cwd);
51198
- await saveImpactMap(cwd, impactMap);
51409
+ const impactMap = await _internals22.buildImpactMapInternal(cwd);
51410
+ await _internals22.saveImpactMap(cwd, impactMap);
51199
51411
  return impactMap;
51200
51412
  }
51201
51413
  async function loadImpactMap(cwd) {
@@ -51206,12 +51418,12 @@ async function loadImpactMap(cwd) {
51206
51418
  const data = JSON.parse(content);
51207
51419
  const map3 = data.map;
51208
51420
  const generatedAt = new Date(data.generatedAt).getTime();
51209
- if (!isCacheStale(map3, generatedAt)) {
51421
+ if (!_internals22.isCacheStale(map3, generatedAt)) {
51210
51422
  return map3;
51211
51423
  }
51212
51424
  } catch {}
51213
51425
  }
51214
- return buildImpactMap(cwd);
51426
+ return _internals22.buildImpactMap(cwd);
51215
51427
  }
51216
51428
  async function saveImpactMap(cwd, impactMap) {
51217
51429
  const cacheDir2 = path34.join(cwd, ".swarm", "cache");
@@ -51237,7 +51449,7 @@ async function analyzeImpact(changedFiles, cwd) {
51237
51449
  };
51238
51450
  }
51239
51451
  const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
51240
- const impactMap = await loadImpactMap(cwd);
51452
+ const impactMap = await _internals22.loadImpactMap(cwd);
51241
51453
  const impactedTestsSet = new Set;
51242
51454
  const untestedFiles = [];
51243
51455
  for (const changedFile of validFiles) {
@@ -51278,12 +51490,24 @@ async function analyzeImpact(changedFiles, cwd) {
51278
51490
  impactMap
51279
51491
  };
51280
51492
  }
51281
- 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;
51282
51494
  var init_analyzer = __esm(() => {
51283
51495
  IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
51284
51496
  IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
51285
51497
  IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
51286
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
+ };
51287
51511
  });
51288
51512
 
51289
51513
  // src/test-impact/failure-classifier.ts
@@ -53119,9 +53343,9 @@ function getVersionFileVersion(dir) {
53119
53343
  async function runVersionCheck2(dir, _timeoutMs) {
53120
53344
  const startTime = Date.now();
53121
53345
  try {
53122
- const packageVersion = getPackageVersion(dir);
53123
- const changelogVersion = getChangelogVersion(dir);
53124
- const versionFileVersion = getVersionFileVersion(dir);
53346
+ const packageVersion = _internals23.getPackageVersion(dir);
53347
+ const changelogVersion = _internals23.getChangelogVersion(dir);
53348
+ const versionFileVersion = _internals23.getVersionFileVersion(dir);
53125
53349
  const versions3 = [];
53126
53350
  if (packageVersion)
53127
53351
  versions3.push(`package.json: ${packageVersion}`);
@@ -53471,7 +53695,7 @@ async function runPreflight(dir, phase, config3) {
53471
53695
  const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
53472
53696
  let validatedDir;
53473
53697
  try {
53474
- validatedDir = validateDirectoryPath(dir);
53698
+ validatedDir = _internals23.validateDirectoryPath(dir);
53475
53699
  } catch (error93) {
53476
53700
  return {
53477
53701
  id: reportId,
@@ -53491,7 +53715,7 @@ async function runPreflight(dir, phase, config3) {
53491
53715
  }
53492
53716
  let validatedTimeout;
53493
53717
  try {
53494
- validatedTimeout = validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
53718
+ validatedTimeout = _internals23.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
53495
53719
  } catch (error93) {
53496
53720
  return {
53497
53721
  id: reportId,
@@ -53532,12 +53756,12 @@ async function runPreflight(dir, phase, config3) {
53532
53756
  });
53533
53757
  const checks5 = [];
53534
53758
  log("[Preflight] Running lint check...");
53535
- const lintResult = await runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
53759
+ const lintResult = await _internals23.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
53536
53760
  checks5.push(lintResult);
53537
53761
  log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
53538
53762
  if (!cfg.skipTests) {
53539
53763
  log("[Preflight] Running tests check...");
53540
- const testsResult = await runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
53764
+ const testsResult = await _internals23.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
53541
53765
  checks5.push(testsResult);
53542
53766
  log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
53543
53767
  } else {
@@ -53549,7 +53773,7 @@ async function runPreflight(dir, phase, config3) {
53549
53773
  }
53550
53774
  if (!cfg.skipSecrets) {
53551
53775
  log("[Preflight] Running secrets check...");
53552
- const secretsResult = await runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
53776
+ const secretsResult = await _internals23.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
53553
53777
  checks5.push(secretsResult);
53554
53778
  log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
53555
53779
  } else {
@@ -53561,7 +53785,7 @@ async function runPreflight(dir, phase, config3) {
53561
53785
  }
53562
53786
  if (!cfg.skipEvidence) {
53563
53787
  log("[Preflight] Running evidence check...");
53564
- const evidenceResult = await runEvidenceCheck(validatedDir);
53788
+ const evidenceResult = await _internals23.runEvidenceCheck(validatedDir);
53565
53789
  checks5.push(evidenceResult);
53566
53790
  log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
53567
53791
  } else {
@@ -53572,12 +53796,12 @@ async function runPreflight(dir, phase, config3) {
53572
53796
  });
53573
53797
  }
53574
53798
  log("[Preflight] Running requirement coverage check...");
53575
- const reqCoverageResult = await runRequirementCoverageCheck(validatedDir, phase);
53799
+ const reqCoverageResult = await _internals23.runRequirementCoverageCheck(validatedDir, phase);
53576
53800
  checks5.push(reqCoverageResult);
53577
53801
  log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
53578
53802
  if (!cfg.skipVersion) {
53579
53803
  log("[Preflight] Running version check...");
53580
- const versionResult = await runVersionCheck2(validatedDir, cfg.checkTimeoutMs);
53804
+ const versionResult = await _internals23.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
53581
53805
  checks5.push(versionResult);
53582
53806
  log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
53583
53807
  } else {
@@ -53640,10 +53864,10 @@ function formatPreflightMarkdown(report) {
53640
53864
  async function handlePreflightCommand(directory, _args) {
53641
53865
  const plan = await loadPlan(directory);
53642
53866
  const phase = plan?.current_phase ?? 1;
53643
- const report = await runPreflight(directory, phase);
53644
- return formatPreflightMarkdown(report);
53867
+ const report = await _internals23.runPreflight(directory, phase);
53868
+ return _internals23.formatPreflightMarkdown(report);
53645
53869
  }
53646
- 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;
53647
53871
  var init_preflight_service = __esm(() => {
53648
53872
  init_manager2();
53649
53873
  init_manager();
@@ -53660,6 +53884,22 @@ var init_preflight_service = __esm(() => {
53660
53884
  testScope: "convention",
53661
53885
  linter: "biome"
53662
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
+ };
53663
53903
  });
53664
53904
 
53665
53905
  // src/commands/preflight.ts
@@ -55370,6 +55610,7 @@ async function handleStatusCommand(directory, agents) {
55370
55610
  return formatStatusMarkdown(statusData);
55371
55611
  }
55372
55612
  var init_status_service = __esm(() => {
55613
+ init_extractors();
55373
55614
  init_utils2();
55374
55615
  init_manager();
55375
55616
  init_state();
@@ -55775,7 +56016,7 @@ function findSimilarCommands(query) {
55775
56016
  return cmd.toLowerCase().includes(q) || q.includes(cmd.toLowerCase());
55776
56017
  }).map((cmd) => ({
55777
56018
  cmd,
55778
- 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)
55779
56020
  }));
55780
56021
  scored.sort((a, b) => a.score - b.score);
55781
56022
  return scored.slice(0, 3).map((s) => s.cmd);
@@ -55805,11 +56046,11 @@ async function handleHelpCommand(ctx) {
55805
56046
  return buildHelpText2();
55806
56047
  }
55807
56048
  const tokens = targetCommand.split(/\s+/);
55808
- const resolved = resolveCommand(tokens);
56049
+ const resolved = _internals24.resolveCommand(tokens);
55809
56050
  if (resolved) {
55810
- return buildDetailedHelp(resolved.key, resolved.entry);
56051
+ return _internals24.buildDetailedHelp(resolved.key, resolved.entry);
55811
56052
  }
55812
- const similar = findSimilarCommands(targetCommand);
56053
+ const similar = _internals24.findSimilarCommands(targetCommand);
55813
56054
  const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
55814
56055
  if (similar.length > 0) {
55815
56056
  return `Command '/swarm ${targetCommand}' not found.
@@ -55903,7 +56144,7 @@ function resolveCommand(tokens) {
55903
56144
  }
55904
56145
  return null;
55905
56146
  }
55906
- var COMMAND_REGISTRY, VALID_COMMANDS, validation;
56147
+ var COMMAND_REGISTRY, VALID_COMMANDS, _internals24, validation;
55907
56148
  var init_registry = __esm(() => {
55908
56149
  init_acknowledge_spec_drift();
55909
56150
  init_agents();
@@ -55964,7 +56205,7 @@ var init_registry = __esm(() => {
55964
56205
  clashesWithNativeCcCommand: "/agents"
55965
56206
  },
55966
56207
  help: {
55967
- handler: (ctx) => handleHelpCommand(ctx),
56208
+ handler: (ctx) => _internals24.handleHelpCommand(ctx),
55968
56209
  description: "Show help for swarm commands",
55969
56210
  category: "core",
55970
56211
  args: "[command]",
@@ -56294,7 +56535,15 @@ var init_registry = __esm(() => {
56294
56535
  }
56295
56536
  };
56296
56537
  VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
56297
- validation = validateAliases();
56538
+ _internals24 = {
56539
+ handleHelpCommand,
56540
+ validateAliases,
56541
+ resolveCommand,
56542
+ levenshteinDistance,
56543
+ findSimilarCommands,
56544
+ buildDetailedHelp
56545
+ };
56546
+ validation = _internals24.validateAliases();
56298
56547
  if (!validation.valid) {
56299
56548
  throw new Error(`COMMAND_REGISTRY alias validation failed:
56300
56549
  ${validation.errors.join(`
@@ -59020,6 +59269,7 @@ REASONING: [2-4 sentences — what you verified and why]
59020
59269
  EVIDENCE_CHECKED: [list of files/artifacts you read]
59021
59270
  ANTI_PATTERNS_DETECTED: [list or "none"]
59022
59271
  ESCALATION_NEEDED: YES | NO`;
59272
+ var init_critic = () => {};
59023
59273
 
59024
59274
  // src/agents/curator-agent.ts
59025
59275
  function createCuratorAgent(model, customPrompt, customAppendPrompt, role = "curator_init") {
@@ -60376,10 +60626,12 @@ var init_agents2 = __esm(() => {
60376
60626
  init_warning_buffer();
60377
60627
  init_architect();
60378
60628
  init_council_prompts();
60629
+ init_critic();
60379
60630
  init_curator_agent();
60380
60631
  init_reviewer();
60381
60632
  init_architect();
60382
60633
  init_council_prompts();
60634
+ init_critic();
60383
60635
  init_curator_agent();
60384
60636
  init_reviewer();
60385
60637
  warnedAgents = new Set;
@@ -61215,6 +61467,7 @@ var init_preflight_integration = __esm(() => {
61215
61467
  init_status_artifact();
61216
61468
  init_trigger();
61217
61469
  init_preflight_service();
61470
+ init_logger();
61218
61471
  });
61219
61472
 
61220
61473
  // node_modules/web-tree-sitter/tree-sitter.js
@@ -64962,9 +65215,10 @@ var init_doc_scan = __esm(() => {
64962
65215
  // src/tools/knowledge-recall.ts
64963
65216
  var exports_knowledge_recall = {};
64964
65217
  __export(exports_knowledge_recall, {
64965
- knowledge_recall: () => knowledge_recall
65218
+ knowledge_recall: () => knowledge_recall,
65219
+ _internals: () => _internals25
64966
65220
  });
64967
- var knowledge_recall;
65221
+ var knowledge_recall, _internals25;
64968
65222
  var init_knowledge_recall = __esm(() => {
64969
65223
  init_zod();
64970
65224
  init_knowledge_store();
@@ -65050,6 +65304,9 @@ var init_knowledge_recall = __esm(() => {
65050
65304
  return JSON.stringify(result);
65051
65305
  }
65052
65306
  });
65307
+ _internals25 = {
65308
+ knowledge_recall
65309
+ };
65053
65310
  });
65054
65311
 
65055
65312
  // src/environment/prompt-renderer.ts
@@ -65101,13 +65358,14 @@ __export(exports_curator_drift, {
65101
65358
  writeDriftReport: () => writeDriftReport,
65102
65359
  runDeterministicDriftCheck: () => runDeterministicDriftCheck,
65103
65360
  readPriorDriftReports: () => readPriorDriftReports,
65104
- buildDriftInjectionText: () => buildDriftInjectionText
65361
+ buildDriftInjectionText: () => buildDriftInjectionText,
65362
+ _internals: () => _internals27
65105
65363
  });
65106
- import * as fs48 from "node:fs";
65364
+ import * as fs49 from "node:fs";
65107
65365
  import * as path70 from "node:path";
65108
65366
  async function readPriorDriftReports(directory) {
65109
65367
  const swarmDir = path70.join(directory, ".swarm");
65110
- const entries = await fs48.promises.readdir(swarmDir).catch(() => null);
65368
+ const entries = await fs49.promises.readdir(swarmDir).catch(() => null);
65111
65369
  if (entries === null)
65112
65370
  return [];
65113
65371
  const reportFiles = entries.filter((name2) => name2.startsWith(DRIFT_REPORT_PREFIX) && name2.endsWith(".json")).sort();
@@ -65134,9 +65392,9 @@ async function writeDriftReport(directory, report) {
65134
65392
  const filename = `${DRIFT_REPORT_PREFIX}${report.phase}.json`;
65135
65393
  const filePath = validateSwarmPath(directory, filename);
65136
65394
  const swarmDir = path70.dirname(filePath);
65137
- await fs48.promises.mkdir(swarmDir, { recursive: true });
65395
+ await fs49.promises.mkdir(swarmDir, { recursive: true });
65138
65396
  try {
65139
- 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");
65140
65398
  } catch (err2) {
65141
65399
  throw new Error(`[curator-drift] Failed to write drift report to ${filePath}: ${String(err2)}`);
65142
65400
  }
@@ -65146,7 +65404,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
65146
65404
  try {
65147
65405
  const planMd = await readSwarmFileAsync(directory, "plan.md");
65148
65406
  const specMd = await readSwarmFileAsync(directory, "spec.md");
65149
- const priorReports = await readPriorDriftReports(directory);
65407
+ const priorReports = await _internals27.readPriorDriftReports(directory);
65150
65408
  const complianceCount = curatorResult.compliance.length;
65151
65409
  const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
65152
65410
  let alignment = "ALIGNED";
@@ -65195,7 +65453,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
65195
65453
  scope_additions: [],
65196
65454
  injection_summary: injectionSummary
65197
65455
  };
65198
- const reportPath = await writeDriftReport(directory, report);
65456
+ const reportPath = await _internals27.writeDriftReport(directory, report);
65199
65457
  getGlobalEventBus().publish("curator.drift.completed", {
65200
65458
  phase,
65201
65459
  alignment,
@@ -65258,16 +65516,24 @@ function buildDriftInjectionText(report, maxChars) {
65258
65516
  }
65259
65517
  return text.slice(0, maxChars);
65260
65518
  }
65261
- var DRIFT_REPORT_PREFIX = "drift-report-phase-";
65519
+ var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals27;
65262
65520
  var init_curator_drift = __esm(() => {
65263
65521
  init_event_bus();
65522
+ init_logger();
65264
65523
  init_utils2();
65524
+ _internals27 = {
65525
+ readPriorDriftReports,
65526
+ writeDriftReport,
65527
+ runDeterministicDriftCheck,
65528
+ buildDriftInjectionText
65529
+ };
65265
65530
  });
65266
65531
 
65267
65532
  // src/index.ts
65268
65533
  init_package();
65269
65534
  init_agents2();
65270
- import * as path114 from "node:path";
65535
+ init_critic();
65536
+ import * as path115 from "node:path";
65271
65537
 
65272
65538
  // src/background/index.ts
65273
65539
  init_event_bus();
@@ -65830,6 +66096,7 @@ var CONFLICT_MAP = new Map(CLAUDE_CODE_CONFLICTS.map((c) => [c.swarmCommand, c])
65830
66096
 
65831
66097
  // src/hooks/cc-command-intercept.ts
65832
66098
  init_constants();
66099
+ init_logger();
65833
66100
  function createCcCommandInterceptHook(config3 = {}) {
65834
66101
  const {
65835
66102
  intercept = ["CRITICAL", "HIGH"],
@@ -65941,6 +66208,7 @@ function createCcCommandInterceptHook(config3 = {}) {
65941
66208
  // src/hooks/compaction-customizer.ts
65942
66209
  init_manager();
65943
66210
  init_state();
66211
+ init_extractors();
65944
66212
  init_utils2();
65945
66213
  import * as fs33 from "node:fs";
65946
66214
  import { join as join45 } from "node:path";
@@ -66608,11 +66876,17 @@ function createDelegationTrackerHook(config3, guardrailsEnabled = true) {
66608
66876
  }
66609
66877
  };
66610
66878
  }
66879
+
66880
+ // src/hooks/index.ts
66881
+ init_extractors();
66882
+
66611
66883
  // src/hooks/full-auto-intercept.ts
66884
+ init_critic();
66612
66885
  init_schema();
66613
66886
  init_file_locks();
66614
66887
  init_state();
66615
66888
  init_telemetry();
66889
+ init_logger();
66616
66890
  init_utils2();
66617
66891
  import * as fs35 from "node:fs";
66618
66892
  var END_OF_SENTENCE_QUESTION_PATTERN = /\?\s*$/;
@@ -66921,7 +67195,7 @@ Critic reasoning: ${criticResult.reasoning}`
66921
67195
  }
66922
67196
  }
66923
67197
  async function dispatchCriticAndWriteEvent(directory, architectOutput, criticContext, criticModel, escalationType, interactionCount, deadlockCount, oversightAgentName) {
66924
- const client = swarmState.opencodeClient;
67198
+ const client = _internals9.swarmState.opencodeClient;
66925
67199
  if (!client) {
66926
67200
  warn("[full-auto-intercept] No opencodeClient — critic dispatch skipped (fallback to PENDING)");
66927
67201
  const result = {
@@ -67041,12 +67315,11 @@ function createFullAutoInterceptHook(config3, directory) {
67041
67315
  if (!architectText)
67042
67316
  return;
67043
67317
  const sessionID = architectMessage.info?.sessionID;
67044
- if (!hasActiveFullAuto(sessionID))
67318
+ if (!_internals9.hasActiveFullAuto(sessionID))
67045
67319
  return;
67046
67320
  let session = null;
67047
67321
  if (sessionID) {
67048
- const { ensureAgentSession: ensureAgentSession2 } = await Promise.resolve().then(() => (init_state(), exports_state));
67049
- session = ensureAgentSession2(sessionID);
67322
+ session = _internals9.ensureAgentSession(sessionID);
67050
67323
  }
67051
67324
  if (session) {
67052
67325
  const interactionCount = session.fullAutoInteractionCount ?? 0;
@@ -67314,6 +67587,7 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
67314
67587
  }
67315
67588
  // src/hooks/pipeline-tracker.ts
67316
67589
  init_manager();
67590
+ init_extractors();
67317
67591
  init_utils2();
67318
67592
  function parsePhaseNumber(phaseString) {
67319
67593
  if (!phaseString)
@@ -67404,6 +67678,7 @@ import { realpathSync as realpathSync8 } from "node:fs";
67404
67678
  import * as path58 from "node:path";
67405
67679
 
67406
67680
  // src/tools/repo-graph/builder.ts
67681
+ init_logger();
67407
67682
  init_path_security();
67408
67683
  import * as fsSync3 from "node:fs";
67409
67684
  import { existsSync as existsSync29, realpathSync as realpathSync6 } from "node:fs";
@@ -68312,12 +68587,14 @@ function getCachedMtime(workspace) {
68312
68587
  return mtimeCache.get(path55.normalize(workspace));
68313
68588
  }
68314
68589
  // src/tools/repo-graph/incremental.ts
68590
+ init_logger();
68315
68591
  import { existsSync as existsSync31 } from "node:fs";
68316
68592
  import * as fsPromises7 from "node:fs/promises";
68317
68593
  import * as path57 from "node:path";
68318
68594
 
68319
68595
  // src/tools/repo-graph/storage.ts
68320
68596
  init_utils2();
68597
+ init_logger();
68321
68598
  init_path_security();
68322
68599
  import { constants as constants4, existsSync as existsSync30, realpathSync as realpathSync7 } from "node:fs";
68323
68600
  import * as fsPromises6 from "node:fs/promises";
@@ -68576,6 +68853,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
68576
68853
  return graph;
68577
68854
  }
68578
68855
  // src/hooks/repo-graph-builder.ts
68856
+ init_logger();
68579
68857
  var SUPPORTED_EXTENSIONS2 = [
68580
68858
  ".ts",
68581
68859
  ".tsx",
@@ -69364,6 +69642,7 @@ function rankCandidates(candidates, config3) {
69364
69642
  }
69365
69643
 
69366
69644
  // src/hooks/system-enhancer.ts
69645
+ init_extractors();
69367
69646
  init_knowledge_store();
69368
69647
 
69369
69648
  // src/hooks/repo-graph-injection.ts
@@ -73263,8 +73542,64 @@ init_manager();
73263
73542
  // src/services/run-memory.ts
73264
73543
  init_utils2();
73265
73544
  init_path_security();
73545
+ import * as crypto8 from "node:crypto";
73546
+ import * as fs48 from "node:fs/promises";
73266
73547
  var RUN_MEMORY_FILENAME = "run-memory.jsonl";
73267
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
+ }
73268
73603
  function groupByTaskId(entries) {
73269
73604
  const groups = new Map;
73270
73605
  for (const entry of entries) {
@@ -73313,10 +73648,10 @@ async function getRunMemorySummary(directory) {
73313
73648
  if (entries.length === 0) {
73314
73649
  return null;
73315
73650
  }
73316
- const groups = groupByTaskId(entries);
73651
+ const groups = _internals26.groupByTaskId(entries);
73317
73652
  const summaries = [];
73318
73653
  for (const [taskId, taskEntries] of groups) {
73319
- const summary = summarizeTask(taskId, taskEntries);
73654
+ const summary = _internals26.summarizeTask(taskId, taskEntries);
73320
73655
  if (summary) {
73321
73656
  summaries.push(summary);
73322
73657
  }
@@ -73349,9 +73684,20 @@ Use this data to avoid repeating known failure patterns.`;
73349
73684
  }
73350
73685
  return prefix + summaryText + suffix;
73351
73686
  }
73687
+ var _internals26 = {
73688
+ generateTaskFingerprint,
73689
+ recordOutcome,
73690
+ getTaskHistory,
73691
+ getFailures,
73692
+ getRunMemorySummary,
73693
+ groupByTaskId,
73694
+ summarizeTask
73695
+ };
73352
73696
 
73353
73697
  // src/hooks/knowledge-injector.ts
73698
+ init_logger();
73354
73699
  init_curator_drift();
73700
+ init_extractors();
73355
73701
  init_knowledge_reader();
73356
73702
  init_knowledge_store();
73357
73703
  init_utils2();
@@ -73646,7 +73992,7 @@ function createSelfReviewHook(config3, injectAdvisory) {
73646
73992
  }
73647
73993
 
73648
73994
  // src/hooks/slop-detector.ts
73649
- import * as fs49 from "node:fs";
73995
+ import * as fs50 from "node:fs";
73650
73996
  import * as path72 from "node:path";
73651
73997
  var WRITE_EDIT_TOOLS = new Set([
73652
73998
  "write",
@@ -73692,7 +74038,7 @@ function checkBoilerplateExplosion(content, taskDescription, threshold) {
73692
74038
  function walkFiles(dir, exts, deadline) {
73693
74039
  const results = [];
73694
74040
  try {
73695
- for (const entry of fs49.readdirSync(dir, { withFileTypes: true })) {
74041
+ for (const entry of fs50.readdirSync(dir, { withFileTypes: true })) {
73696
74042
  if (deadline !== undefined && Date.now() > deadline)
73697
74043
  break;
73698
74044
  if (entry.isSymbolicLink())
@@ -73712,7 +74058,7 @@ function walkFiles(dir, exts, deadline) {
73712
74058
  return results;
73713
74059
  }
73714
74060
  function checkDeadExports(content, projectDir, startTime) {
73715
- const hasPackageJson = fs49.existsSync(path72.join(projectDir, "package.json"));
74061
+ const hasPackageJson = fs50.existsSync(path72.join(projectDir, "package.json"));
73716
74062
  if (!hasPackageJson)
73717
74063
  return null;
73718
74064
  const exportMatches = content.matchAll(/^\+(?:export)\s+(?:function|class|const|type|interface)\s+(\w{3,})/gm);
@@ -73735,7 +74081,7 @@ function checkDeadExports(content, projectDir, startTime) {
73735
74081
  if (found || Date.now() - startTime > 480)
73736
74082
  break;
73737
74083
  try {
73738
- const text = fs49.readFileSync(file3, "utf-8");
74084
+ const text = fs50.readFileSync(file3, "utf-8");
73739
74085
  if (importPattern.test(text))
73740
74086
  found = true;
73741
74087
  importPattern.lastIndex = 0;
@@ -73827,7 +74173,7 @@ function checkDuplicateUtility(content, projectDir, startTime, targetFile) {
73827
74173
  if (Date.now() > deadline)
73828
74174
  break;
73829
74175
  const utilPath = path72.join(projectDir, utilDir);
73830
- if (!fs49.existsSync(utilPath))
74176
+ if (!fs50.existsSync(utilPath))
73831
74177
  continue;
73832
74178
  const files = walkFiles(utilPath, [".ts", ".tsx", ".js", ".jsx"], deadline);
73833
74179
  for (const file3 of files) {
@@ -73836,7 +74182,7 @@ function checkDuplicateUtility(content, projectDir, startTime, targetFile) {
73836
74182
  if (targetFile && path72.resolve(file3) === path72.resolve(targetFile))
73837
74183
  continue;
73838
74184
  try {
73839
- const text = fs49.readFileSync(file3, "utf-8");
74185
+ const text = fs50.readFileSync(file3, "utf-8");
73840
74186
  for (const name2 of newExports) {
73841
74187
  const exportPattern = new RegExp(`\\bexport\\s+(?:function|class|const|type|interface)\\s+${name2}\\b`);
73842
74188
  if (exportPattern.test(text)) {
@@ -73919,7 +74265,7 @@ Review before proceeding.`;
73919
74265
  // src/hooks/steering-consumed.ts
73920
74266
  init_bun_compat();
73921
74267
  init_utils2();
73922
- import * as fs50 from "node:fs";
74268
+ import * as fs51 from "node:fs";
73923
74269
  function recordSteeringConsumed(directory, directiveId) {
73924
74270
  try {
73925
74271
  const eventsPath = validateSwarmPath(directory, "events.jsonl");
@@ -73928,7 +74274,7 @@ function recordSteeringConsumed(directory, directiveId) {
73928
74274
  directiveId,
73929
74275
  timestamp: new Date().toISOString()
73930
74276
  };
73931
- fs50.appendFileSync(eventsPath, `${JSON.stringify(event)}
74277
+ fs51.appendFileSync(eventsPath, `${JSON.stringify(event)}
73932
74278
  `, "utf-8");
73933
74279
  } catch {}
73934
74280
  }
@@ -73970,12 +74316,12 @@ function createSteeringConsumedHook(directory) {
73970
74316
 
73971
74317
  // src/hooks/trajectory-logger.ts
73972
74318
  init_manager2();
73973
- import * as fs52 from "node:fs/promises";
74319
+ import * as fs53 from "node:fs/promises";
73974
74320
  import * as path74 from "node:path";
73975
74321
 
73976
74322
  // src/prm/trajectory-store.ts
73977
74323
  init_utils2();
73978
- import * as fs51 from "node:fs/promises";
74324
+ import * as fs52 from "node:fs/promises";
73979
74325
  import * as path73 from "node:path";
73980
74326
  function getTrajectoryPath(sessionId, directory) {
73981
74327
  const relativePath = path73.join("trajectories", `${sessionId}.jsonl`);
@@ -73997,10 +74343,10 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
73997
74343
  _inMemoryTrajectoryCache.set(sessionId, cached3);
73998
74344
  }
73999
74345
  const trajectoryPath = getTrajectoryPath(sessionId, directory);
74000
- await fs51.mkdir(path73.dirname(trajectoryPath), { recursive: true });
74346
+ await fs52.mkdir(path73.dirname(trajectoryPath), { recursive: true });
74001
74347
  const line = `${JSON.stringify(entry)}
74002
74348
  `;
74003
- await fs51.appendFile(trajectoryPath, line, "utf-8");
74349
+ await fs52.appendFile(trajectoryPath, line, "utf-8");
74004
74350
  } catch (err2) {
74005
74351
  console.warn(`[trajectory-store] Failed to append trajectory entry: ${err2}`);
74006
74352
  }
@@ -74008,7 +74354,7 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
74008
74354
  async function readTrajectory(sessionId, directory) {
74009
74355
  try {
74010
74356
  const trajectoryPath = getTrajectoryPath(sessionId, directory);
74011
- const content = await fs51.readFile(trajectoryPath, "utf-8");
74357
+ const content = await fs52.readFile(trajectoryPath, "utf-8");
74012
74358
  const lines = content.split(`
74013
74359
  `).filter((line) => line.trim().length > 0);
74014
74360
  const entries = [];
@@ -74032,15 +74378,15 @@ async function cleanupOldTrajectoryFiles(directory, maxAgeDays = 7) {
74032
74378
  for (const subdir of ["trajectories", "replays"]) {
74033
74379
  try {
74034
74380
  const dirPath = validateSwarmPath(directory, subdir);
74035
- const entries = await fs51.readdir(dirPath, { withFileTypes: true });
74381
+ const entries = await fs52.readdir(dirPath, { withFileTypes: true });
74036
74382
  for (const entry of entries) {
74037
74383
  if (!entry.isFile())
74038
74384
  continue;
74039
74385
  const filePath = path73.join(dirPath, entry.name);
74040
74386
  try {
74041
- const stat7 = await fs51.stat(filePath);
74387
+ const stat7 = await fs52.stat(filePath);
74042
74388
  if (now - stat7.mtimeMs > cutoffMs) {
74043
- await fs51.unlink(filePath);
74389
+ await fs52.unlink(filePath);
74044
74390
  }
74045
74391
  } catch {}
74046
74392
  }
@@ -74090,7 +74436,7 @@ function isSensitiveKey(key) {
74090
74436
  }
74091
74437
  async function truncateTrajectoryFile(filePath, maxLines) {
74092
74438
  try {
74093
- const content = await fs52.readFile(filePath, "utf-8");
74439
+ const content = await fs53.readFile(filePath, "utf-8");
74094
74440
  const lines = content.split(`
74095
74441
  `).filter((line) => line.trim().length > 0);
74096
74442
  if (lines.length <= maxLines) {
@@ -74098,7 +74444,7 @@ async function truncateTrajectoryFile(filePath, maxLines) {
74098
74444
  }
74099
74445
  const keepCount = Math.floor(maxLines / 2);
74100
74446
  const keptLines = lines.slice(-keepCount);
74101
- await fs52.writeFile(filePath, `${keptLines.join(`
74447
+ await fs53.writeFile(filePath, `${keptLines.join(`
74102
74448
  `)}
74103
74449
  `, "utf-8");
74104
74450
  } catch {}
@@ -74231,10 +74577,10 @@ function createTrajectoryLoggerHook(config3, _directory) {
74231
74577
  const relativePath = path74.join("evidence", sanitized, "trajectory.jsonl");
74232
74578
  const trajectoryPath = validateSwarmPath(_directory, relativePath);
74233
74579
  try {
74234
- await fs52.mkdir(path74.dirname(trajectoryPath), { recursive: true });
74580
+ await fs53.mkdir(path74.dirname(trajectoryPath), { recursive: true });
74235
74581
  const line = `${JSON.stringify(entry)}
74236
74582
  `;
74237
- await fs52.appendFile(trajectoryPath, line, "utf-8");
74583
+ await fs53.appendFile(trajectoryPath, line, "utf-8");
74238
74584
  await truncateTrajectoryFile(trajectoryPath, maxLines);
74239
74585
  } catch {}
74240
74586
  try {
@@ -74781,7 +75127,7 @@ init_state();
74781
75127
  init_telemetry();
74782
75128
 
74783
75129
  // src/prm/replay.ts
74784
- import { promises as fs53 } from "node:fs";
75130
+ import { promises as fs54 } from "node:fs";
74785
75131
  import path75 from "node:path";
74786
75132
  function isPathSafe2(targetPath, basePath) {
74787
75133
  const resolvedTarget = path75.resolve(targetPath);
@@ -74812,7 +75158,7 @@ async function startReplayRecording(sessionID, directory) {
74812
75158
  console.warn(`[replay] Invalid path detected - path traversal attempt blocked for session ${sessionID}`);
74813
75159
  return null;
74814
75160
  }
74815
- await fs53.mkdir(replayDir, { recursive: true });
75161
+ await fs54.mkdir(replayDir, { recursive: true });
74816
75162
  return filepath;
74817
75163
  } catch (err2) {
74818
75164
  console.warn(`[replay] Failed to start recording for session ${sessionID}: ${err2}`);
@@ -74832,7 +75178,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
74832
75178
  };
74833
75179
  const line = `${JSON.stringify(fullEntry)}
74834
75180
  `;
74835
- await fs53.appendFile(artifactPath, line, "utf-8");
75181
+ await fs54.appendFile(artifactPath, line, "utf-8");
74836
75182
  } catch (err2) {
74837
75183
  console.warn(`[replay] Failed to record entry: ${err2}`);
74838
75184
  }
@@ -75180,7 +75526,7 @@ init_telemetry();
75180
75526
  // src/tools/batch-symbols.ts
75181
75527
  init_dist();
75182
75528
  init_create_tool();
75183
- import * as fs54 from "node:fs";
75529
+ import * as fs55 from "node:fs";
75184
75530
  import * as path76 from "node:path";
75185
75531
  init_path_security();
75186
75532
  var WINDOWS_RESERVED_NAMES2 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
@@ -75199,11 +75545,11 @@ function containsWindowsAttacks2(str) {
75199
75545
  function isPathInWorkspace2(filePath, workspace) {
75200
75546
  try {
75201
75547
  const resolvedPath = path76.resolve(workspace, filePath);
75202
- if (!fs54.existsSync(resolvedPath)) {
75548
+ if (!fs55.existsSync(resolvedPath)) {
75203
75549
  return true;
75204
75550
  }
75205
- const realWorkspace = fs54.realpathSync(workspace);
75206
- const realResolvedPath = fs54.realpathSync(resolvedPath);
75551
+ const realWorkspace = fs55.realpathSync(workspace);
75552
+ const realResolvedPath = fs55.realpathSync(resolvedPath);
75207
75553
  const relativePath = path76.relative(realWorkspace, realResolvedPath);
75208
75554
  if (relativePath.startsWith("..") || path76.isAbsolute(relativePath)) {
75209
75555
  return false;
@@ -75248,7 +75594,7 @@ function processFile2(file3, cwd, exportedOnly) {
75248
75594
  };
75249
75595
  }
75250
75596
  const fullPath = path76.join(cwd, file3);
75251
- if (!fs54.existsSync(fullPath)) {
75597
+ if (!fs55.existsSync(fullPath)) {
75252
75598
  return {
75253
75599
  file: file3,
75254
75600
  success: false,
@@ -75279,14 +75625,14 @@ function processFile2(file3, cwd, exportedOnly) {
75279
75625
  }
75280
75626
  let isEmptyFile = false;
75281
75627
  try {
75282
- const stats = fs54.statSync(fullPath);
75628
+ const stats = fs55.statSync(fullPath);
75283
75629
  if (stats.size === 0) {
75284
75630
  isEmptyFile = true;
75285
75631
  }
75286
75632
  } catch {}
75287
75633
  if (syms.length === 0) {
75288
75634
  try {
75289
- const content = fs54.readFileSync(fullPath, "utf-8");
75635
+ const content = fs55.readFileSync(fullPath, "utf-8");
75290
75636
  if (content.trim().length === 0) {
75291
75637
  isEmptyFile = true;
75292
75638
  }
@@ -75538,7 +75884,7 @@ init_manager2();
75538
75884
  init_task_id();
75539
75885
  init_create_tool();
75540
75886
  init_resolve_working_directory();
75541
- import * as fs55 from "node:fs";
75887
+ import * as fs56 from "node:fs";
75542
75888
  import * as path77 from "node:path";
75543
75889
  var EVIDENCE_DIR = ".swarm/evidence";
75544
75890
  function isValidTaskId3(taskId) {
@@ -75551,12 +75897,12 @@ function isPathWithinSwarm(filePath, workspaceRoot) {
75551
75897
  return normalizedPath.startsWith(swarmPath);
75552
75898
  }
75553
75899
  function readEvidenceFile(evidencePath) {
75554
- if (!fs55.existsSync(evidencePath)) {
75900
+ if (!fs56.existsSync(evidencePath)) {
75555
75901
  return null;
75556
75902
  }
75557
75903
  let content;
75558
75904
  try {
75559
- content = fs55.readFileSync(evidencePath, "utf-8");
75905
+ content = fs56.readFileSync(evidencePath, "utf-8");
75560
75906
  } catch {
75561
75907
  return null;
75562
75908
  }
@@ -75724,7 +76070,7 @@ init_utils2();
75724
76070
  init_state();
75725
76071
  init_create_tool();
75726
76072
  init_resolve_working_directory();
75727
- import * as fs56 from "node:fs";
76073
+ import * as fs57 from "node:fs";
75728
76074
  import * as path78 from "node:path";
75729
76075
  function extractMatches(regex, text) {
75730
76076
  return Array.from(text.matchAll(regex));
@@ -75819,7 +76165,7 @@ async function executeCompletionVerify(args2, directory) {
75819
76165
  let plan;
75820
76166
  try {
75821
76167
  const planPath = validateSwarmPath(directory, "plan.json");
75822
- const planRaw = fs56.readFileSync(planPath, "utf-8");
76168
+ const planRaw = fs57.readFileSync(planPath, "utf-8");
75823
76169
  plan = JSON.parse(planRaw);
75824
76170
  } catch {
75825
76171
  const result2 = {
@@ -75893,7 +76239,7 @@ async function executeCompletionVerify(args2, directory) {
75893
76239
  }
75894
76240
  let fileContent;
75895
76241
  try {
75896
- fileContent = fs56.readFileSync(resolvedPath, "utf-8");
76242
+ fileContent = fs57.readFileSync(resolvedPath, "utf-8");
75897
76243
  } catch {
75898
76244
  blockedTasks.push({
75899
76245
  task_id: task.id,
@@ -75937,7 +76283,7 @@ async function executeCompletionVerify(args2, directory) {
75937
76283
  try {
75938
76284
  const evidenceDir = path78.join(directory, ".swarm", "evidence", `${phase}`);
75939
76285
  const evidencePath = path78.join(evidenceDir, "completion-verify.json");
75940
- fs56.mkdirSync(evidenceDir, { recursive: true });
76286
+ fs57.mkdirSync(evidenceDir, { recursive: true });
75941
76287
  const evidenceBundle = {
75942
76288
  schema_version: "1.0.0",
75943
76289
  task_id: "completion-verify",
@@ -75958,7 +76304,7 @@ async function executeCompletionVerify(args2, directory) {
75958
76304
  }
75959
76305
  ]
75960
76306
  };
75961
- fs56.writeFileSync(evidencePath, JSON.stringify(evidenceBundle, null, 2), "utf-8");
76307
+ fs57.writeFileSync(evidencePath, JSON.stringify(evidenceBundle, null, 2), "utf-8");
75962
76308
  } catch {}
75963
76309
  return JSON.stringify(result, null, 2);
75964
76310
  }
@@ -76012,11 +76358,11 @@ var completion_verify = createSwarmTool({
76012
76358
  });
76013
76359
  // src/tools/complexity-hotspots.ts
76014
76360
  init_zod();
76015
- import * as fs58 from "node:fs";
76361
+ import * as fs59 from "node:fs";
76016
76362
  import * as path80 from "node:path";
76017
76363
 
76018
76364
  // src/quality/metrics.ts
76019
- import * as fs57 from "node:fs";
76365
+ import * as fs58 from "node:fs";
76020
76366
  import * as path79 from "node:path";
76021
76367
  var MAX_FILE_SIZE_BYTES4 = 256 * 1024;
76022
76368
  var MIN_DUPLICATION_LINES = 10;
@@ -76055,11 +76401,11 @@ function estimateCyclomaticComplexity(content) {
76055
76401
  }
76056
76402
  function getComplexityForFile(filePath) {
76057
76403
  try {
76058
- const stat7 = fs57.statSync(filePath);
76404
+ const stat7 = fs58.statSync(filePath);
76059
76405
  if (stat7.size > MAX_FILE_SIZE_BYTES4) {
76060
76406
  return null;
76061
76407
  }
76062
- const content = fs57.readFileSync(filePath, "utf-8");
76408
+ const content = fs58.readFileSync(filePath, "utf-8");
76063
76409
  return estimateCyclomaticComplexity(content);
76064
76410
  } catch {
76065
76411
  return null;
@@ -76070,7 +76416,7 @@ async function computeComplexityDelta(files, workingDir) {
76070
76416
  const analyzedFiles = [];
76071
76417
  for (const file3 of files) {
76072
76418
  const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
76073
- if (!fs57.existsSync(fullPath)) {
76419
+ if (!fs58.existsSync(fullPath)) {
76074
76420
  continue;
76075
76421
  }
76076
76422
  const complexity = getComplexityForFile(fullPath);
@@ -76191,7 +76537,7 @@ function countGoExports(content) {
76191
76537
  }
76192
76538
  function getExportCountForFile(filePath) {
76193
76539
  try {
76194
- const content = fs57.readFileSync(filePath, "utf-8");
76540
+ const content = fs58.readFileSync(filePath, "utf-8");
76195
76541
  const ext = path79.extname(filePath).toLowerCase();
76196
76542
  switch (ext) {
76197
76543
  case ".ts":
@@ -76219,7 +76565,7 @@ async function computePublicApiDelta(files, workingDir) {
76219
76565
  const analyzedFiles = [];
76220
76566
  for (const file3 of files) {
76221
76567
  const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
76222
- if (!fs57.existsSync(fullPath)) {
76568
+ if (!fs58.existsSync(fullPath)) {
76223
76569
  continue;
76224
76570
  }
76225
76571
  const exports = getExportCountForFile(fullPath);
@@ -76253,15 +76599,15 @@ async function computeDuplicationRatio(files, workingDir) {
76253
76599
  const analyzedFiles = [];
76254
76600
  for (const file3 of files) {
76255
76601
  const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
76256
- if (!fs57.existsSync(fullPath)) {
76602
+ if (!fs58.existsSync(fullPath)) {
76257
76603
  continue;
76258
76604
  }
76259
76605
  try {
76260
- const stat7 = fs57.statSync(fullPath);
76606
+ const stat7 = fs58.statSync(fullPath);
76261
76607
  if (stat7.size > MAX_FILE_SIZE_BYTES4) {
76262
76608
  continue;
76263
76609
  }
76264
- const content = fs57.readFileSync(fullPath, "utf-8");
76610
+ const content = fs58.readFileSync(fullPath, "utf-8");
76265
76611
  const lines = content.split(`
76266
76612
  `).filter((line) => line.trim().length > 0);
76267
76613
  if (lines.length < MIN_DUPLICATION_LINES) {
@@ -76437,7 +76783,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76437
76783
  let testLines = 0;
76438
76784
  let codeLines = 0;
76439
76785
  const srcDir = path79.join(workingDir, "src");
76440
- if (fs57.existsSync(srcDir)) {
76786
+ if (fs58.existsSync(srcDir)) {
76441
76787
  await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
76442
76788
  codeLines += lines;
76443
76789
  });
@@ -76445,14 +76791,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76445
76791
  const possibleSrcDirs = ["lib", "app", "source", "core"];
76446
76792
  for (const dir of possibleSrcDirs) {
76447
76793
  const dirPath = path79.join(workingDir, dir);
76448
- if (fs57.existsSync(dirPath)) {
76794
+ if (fs58.existsSync(dirPath)) {
76449
76795
  await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
76450
76796
  codeLines += lines;
76451
76797
  });
76452
76798
  }
76453
76799
  }
76454
76800
  const testsDir = path79.join(workingDir, "tests");
76455
- if (fs57.existsSync(testsDir)) {
76801
+ if (fs58.existsSync(testsDir)) {
76456
76802
  await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
76457
76803
  testLines += lines;
76458
76804
  });
@@ -76460,7 +76806,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76460
76806
  const possibleTestDirs = ["test", "__tests__", "specs"];
76461
76807
  for (const dir of possibleTestDirs) {
76462
76808
  const dirPath = path79.join(workingDir, dir);
76463
- if (fs57.existsSync(dirPath) && dirPath !== testsDir) {
76809
+ if (fs58.existsSync(dirPath) && dirPath !== testsDir) {
76464
76810
  await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
76465
76811
  testLines += lines;
76466
76812
  });
@@ -76472,7 +76818,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
76472
76818
  }
76473
76819
  async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTestScan, callback) {
76474
76820
  try {
76475
- const entries = fs57.readdirSync(dirPath, { withFileTypes: true });
76821
+ const entries = fs58.readdirSync(dirPath, { withFileTypes: true });
76476
76822
  for (const entry of entries) {
76477
76823
  const fullPath = path79.join(dirPath, entry.name);
76478
76824
  if (entry.isDirectory()) {
@@ -76518,7 +76864,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
76518
76864
  continue;
76519
76865
  }
76520
76866
  try {
76521
- const content = fs57.readFileSync(fullPath, "utf-8");
76867
+ const content = fs58.readFileSync(fullPath, "utf-8");
76522
76868
  const lines = countCodeLines(content);
76523
76869
  callback(lines);
76524
76870
  } catch {}
@@ -76718,11 +77064,11 @@ async function getGitChurn(days, directory) {
76718
77064
  }
76719
77065
  function getComplexityForFile2(filePath) {
76720
77066
  try {
76721
- const stat7 = fs58.statSync(filePath);
77067
+ const stat7 = fs59.statSync(filePath);
76722
77068
  if (stat7.size > MAX_FILE_SIZE_BYTES5) {
76723
77069
  return null;
76724
77070
  }
76725
- const content = fs58.readFileSync(filePath, "utf-8");
77071
+ const content = fs59.readFileSync(filePath, "utf-8");
76726
77072
  return estimateCyclomaticComplexity(content);
76727
77073
  } catch {
76728
77074
  return null;
@@ -76743,7 +77089,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
76743
77089
  let analyzedFiles = 0;
76744
77090
  for (const [file3, churnCount] of filteredChurn) {
76745
77091
  let fullPath = file3;
76746
- if (!fs58.existsSync(fullPath)) {
77092
+ if (!fs59.existsSync(fullPath)) {
76747
77093
  fullPath = path80.join(cwd, file3);
76748
77094
  }
76749
77095
  const complexity = getComplexityForFile2(fullPath);
@@ -77004,7 +77350,7 @@ function writeCouncilEvidence(workingDir, synthesis) {
77004
77350
  }
77005
77351
 
77006
77352
  // src/council/council-service.ts
77007
- import fs59 from "node:fs";
77353
+ import fs60 from "node:fs";
77008
77354
  import path81 from "node:path";
77009
77355
 
77010
77356
  // src/council/types.ts
@@ -77166,7 +77512,7 @@ function synthesizePhaseCouncilAdvisory(phaseNumber, phaseSummary, verdicts, rou
77166
77512
  const evidencePath = `.swarm/evidence/${phaseNumber}/phase-council.json`;
77167
77513
  const baseDir = workingDir ?? process.cwd();
77168
77514
  const evidenceDir = path81.join(baseDir, ".swarm", "evidence", String(phaseNumber));
77169
- fs59.mkdirSync(evidenceDir, { recursive: true });
77515
+ fs60.mkdirSync(evidenceDir, { recursive: true });
77170
77516
  const evidenceFile = path81.join(evidenceDir, "phase-council.json");
77171
77517
  const evidenceBundle = {
77172
77518
  entries: [
@@ -77200,8 +77546,8 @@ function synthesizePhaseCouncilAdvisory(phaseNumber, phaseSummary, verdicts, rou
77200
77546
  };
77201
77547
  try {
77202
77548
  const tempFile = `${evidenceFile}.tmp-${Date.now()}`;
77203
- fs59.writeFileSync(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
77204
- fs59.renameSync(tempFile, evidenceFile);
77549
+ fs60.writeFileSync(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
77550
+ fs60.renameSync(tempFile, evidenceFile);
77205
77551
  } catch (writeErr) {
77206
77552
  console.warn(`[phase-council] Failed to write phase-council evidence to ${evidenceFile}: ${writeErr instanceof Error ? writeErr.message : String(writeErr)}`);
77207
77553
  }
@@ -77436,7 +77782,7 @@ var submit_council_verdicts = createSwarmTool({
77436
77782
  // src/tools/convene-general-council.ts
77437
77783
  init_zod();
77438
77784
  init_loader();
77439
- import * as fs60 from "node:fs";
77785
+ import * as fs61 from "node:fs";
77440
77786
  import * as path82 from "node:path";
77441
77787
 
77442
77788
  // src/council/general-council-advisory.ts
@@ -77870,8 +78216,8 @@ var convene_general_council = createSwarmTool({
77870
78216
  const evidenceFile = `${safeTimestamp}-${input.mode}.json`;
77871
78217
  const evidencePath = path82.join(evidenceDir, evidenceFile);
77872
78218
  try {
77873
- await fs60.promises.mkdir(evidenceDir, { recursive: true });
77874
- 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));
77875
78221
  } catch (err2) {
77876
78222
  const message = err2 instanceof Error ? err2.message : String(err2);
77877
78223
  console.warn(`[convene_general_council] Failed to write evidence to ${evidencePath}: ${message}`);
@@ -78102,7 +78448,7 @@ init_scope_persistence();
78102
78448
  init_state();
78103
78449
  init_task_id();
78104
78450
  init_create_tool();
78105
- import * as fs61 from "node:fs";
78451
+ import * as fs62 from "node:fs";
78106
78452
  import * as path83 from "node:path";
78107
78453
  function validateTaskIdFormat2(taskId) {
78108
78454
  return validateTaskIdFormat(taskId);
@@ -78190,9 +78536,9 @@ async function executeDeclareScope(args2, fallbackDir) {
78190
78536
  }
78191
78537
  const resolvedDir = path83.resolve(normalizedDir);
78192
78538
  try {
78193
- const realPath = fs61.realpathSync(resolvedDir);
78539
+ const realPath = fs62.realpathSync(resolvedDir);
78194
78540
  const planPath2 = path83.join(realPath, ".swarm", "plan.json");
78195
- if (!fs61.existsSync(planPath2)) {
78541
+ if (!fs62.existsSync(planPath2)) {
78196
78542
  return {
78197
78543
  success: false,
78198
78544
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -78216,7 +78562,7 @@ async function executeDeclareScope(args2, fallbackDir) {
78216
78562
  }
78217
78563
  const directory = normalizedDir || fallbackDir;
78218
78564
  const planPath = path83.resolve(directory, ".swarm", "plan.json");
78219
- if (!fs61.existsSync(planPath)) {
78565
+ if (!fs62.existsSync(planPath)) {
78220
78566
  return {
78221
78567
  success: false,
78222
78568
  message: "No plan found",
@@ -78225,7 +78571,7 @@ async function executeDeclareScope(args2, fallbackDir) {
78225
78571
  }
78226
78572
  let planContent;
78227
78573
  try {
78228
- planContent = JSON.parse(fs61.readFileSync(planPath, "utf-8"));
78574
+ planContent = JSON.parse(fs62.readFileSync(planPath, "utf-8"));
78229
78575
  } catch {
78230
78576
  return {
78231
78577
  success: false,
@@ -78316,7 +78662,7 @@ var declare_scope = createSwarmTool({
78316
78662
  // src/tools/diff.ts
78317
78663
  init_zod();
78318
78664
  import * as child_process7 from "node:child_process";
78319
- import * as fs62 from "node:fs";
78665
+ import * as fs63 from "node:fs";
78320
78666
  import * as path84 from "node:path";
78321
78667
  init_create_tool();
78322
78668
  var MAX_DIFF_LINES = 500;
@@ -78506,7 +78852,7 @@ var diff = createSwarmTool({
78506
78852
  } else if (base === "unstaged") {
78507
78853
  const oldRef = `:${file3.path}`;
78508
78854
  oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
78509
- newContent = fs62.readFileSync(path84.join(directory, file3.path), "utf-8");
78855
+ newContent = fs63.readFileSync(path84.join(directory, file3.path), "utf-8");
78510
78856
  } else {
78511
78857
  const oldRef = `${base}:${file3.path}`;
78512
78858
  oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
@@ -78580,7 +78926,7 @@ var diff = createSwarmTool({
78580
78926
  // src/tools/diff-summary.ts
78581
78927
  init_zod();
78582
78928
  import * as child_process8 from "node:child_process";
78583
- import * as fs63 from "node:fs";
78929
+ import * as fs64 from "node:fs";
78584
78930
  import * as path85 from "node:path";
78585
78931
  init_create_tool();
78586
78932
  var diff_summary = createSwarmTool({
@@ -78629,7 +78975,7 @@ var diff_summary = createSwarmTool({
78629
78975
  }
78630
78976
  try {
78631
78977
  let oldContent;
78632
- const newContent = fs63.readFileSync(path85.join(workingDir, filePath), "utf-8");
78978
+ const newContent = fs64.readFileSync(path85.join(workingDir, filePath), "utf-8");
78633
78979
  if (fileExistsInHead) {
78634
78980
  oldContent = child_process8.execFileSync("git", ["show", `HEAD:${filePath}`], {
78635
78981
  encoding: "utf-8",
@@ -78857,7 +79203,7 @@ Use these as DOMAIN values when delegating to @sme.`;
78857
79203
  init_zod();
78858
79204
  init_create_tool();
78859
79205
  init_path_security();
78860
- import * as fs64 from "node:fs";
79206
+ import * as fs65 from "node:fs";
78861
79207
  import * as path86 from "node:path";
78862
79208
  var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
78863
79209
  var MAX_EVIDENCE_FILES = 1000;
@@ -78903,12 +79249,12 @@ function parseCompletedTasks(planContent) {
78903
79249
  }
78904
79250
  function readEvidenceFiles(evidenceDir, _cwd) {
78905
79251
  const evidence = [];
78906
- if (!fs64.existsSync(evidenceDir) || !fs64.statSync(evidenceDir).isDirectory()) {
79252
+ if (!fs65.existsSync(evidenceDir) || !fs65.statSync(evidenceDir).isDirectory()) {
78907
79253
  return evidence;
78908
79254
  }
78909
79255
  let files;
78910
79256
  try {
78911
- files = fs64.readdirSync(evidenceDir);
79257
+ files = fs65.readdirSync(evidenceDir);
78912
79258
  } catch {
78913
79259
  return evidence;
78914
79260
  }
@@ -78924,7 +79270,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
78924
79270
  if (!resolvedPath.startsWith(evidenceDirResolved)) {
78925
79271
  continue;
78926
79272
  }
78927
- const stat7 = fs64.lstatSync(filePath);
79273
+ const stat7 = fs65.lstatSync(filePath);
78928
79274
  if (!stat7.isFile()) {
78929
79275
  continue;
78930
79276
  }
@@ -78933,7 +79279,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
78933
79279
  }
78934
79280
  let fileStat;
78935
79281
  try {
78936
- fileStat = fs64.statSync(filePath);
79282
+ fileStat = fs65.statSync(filePath);
78937
79283
  if (fileStat.size > MAX_FILE_SIZE_BYTES6) {
78938
79284
  continue;
78939
79285
  }
@@ -78942,7 +79288,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
78942
79288
  }
78943
79289
  let content;
78944
79290
  try {
78945
- content = fs64.readFileSync(filePath, "utf-8");
79291
+ content = fs65.readFileSync(filePath, "utf-8");
78946
79292
  } catch {
78947
79293
  continue;
78948
79294
  }
@@ -79052,7 +79398,7 @@ var evidence_check = createSwarmTool({
79052
79398
  }
79053
79399
  let planContent;
79054
79400
  try {
79055
- planContent = fs64.readFileSync(planPath, "utf-8");
79401
+ planContent = fs65.readFileSync(planPath, "utf-8");
79056
79402
  } catch {
79057
79403
  const result2 = {
79058
79404
  message: "No completed tasks found in plan.",
@@ -79087,7 +79433,7 @@ var evidence_check = createSwarmTool({
79087
79433
  // src/tools/file-extractor.ts
79088
79434
  init_zod();
79089
79435
  init_create_tool();
79090
- import * as fs65 from "node:fs";
79436
+ import * as fs66 from "node:fs";
79091
79437
  import * as path87 from "node:path";
79092
79438
  var EXT_MAP = {
79093
79439
  python: ".py",
@@ -79150,8 +79496,8 @@ var extract_code_blocks = createSwarmTool({
79150
79496
  execute: async (args2, directory) => {
79151
79497
  const { content, output_dir, prefix } = args2;
79152
79498
  const targetDir = output_dir || directory;
79153
- if (!fs65.existsSync(targetDir)) {
79154
- fs65.mkdirSync(targetDir, { recursive: true });
79499
+ if (!fs66.existsSync(targetDir)) {
79500
+ fs66.mkdirSync(targetDir, { recursive: true });
79155
79501
  }
79156
79502
  if (!content) {
79157
79503
  return "Error: content is required";
@@ -79173,12 +79519,12 @@ var extract_code_blocks = createSwarmTool({
79173
79519
  const base = path87.basename(filepath, path87.extname(filepath));
79174
79520
  const ext = path87.extname(filepath);
79175
79521
  let counter = 1;
79176
- while (fs65.existsSync(filepath)) {
79522
+ while (fs66.existsSync(filepath)) {
79177
79523
  filepath = path87.join(targetDir, `${base}_${counter}${ext}`);
79178
79524
  counter++;
79179
79525
  }
79180
79526
  try {
79181
- fs65.writeFileSync(filepath, code.trim(), "utf-8");
79527
+ fs66.writeFileSync(filepath, code.trim(), "utf-8");
79182
79528
  savedFiles.push(filepath);
79183
79529
  } catch (error93) {
79184
79530
  errors5.push(`Failed to save ${filename}: ${error93 instanceof Error ? error93.message : String(error93)}`);
@@ -79437,7 +79783,7 @@ var gitingest = createSwarmTool({
79437
79783
  init_zod();
79438
79784
  init_create_tool();
79439
79785
  init_path_security();
79440
- import * as fs66 from "node:fs";
79786
+ import * as fs67 from "node:fs";
79441
79787
  import * as path88 from "node:path";
79442
79788
  var MAX_FILE_PATH_LENGTH2 = 500;
79443
79789
  var MAX_SYMBOL_LENGTH = 256;
@@ -79600,7 +79946,7 @@ var SKIP_DIRECTORIES4 = new Set([
79600
79946
  function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFiles: 0, fileErrors: [] }) {
79601
79947
  let entries;
79602
79948
  try {
79603
- entries = fs66.readdirSync(dir);
79949
+ entries = fs67.readdirSync(dir);
79604
79950
  } catch (e) {
79605
79951
  stats.fileErrors.push({
79606
79952
  path: dir,
@@ -79617,7 +79963,7 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
79617
79963
  const fullPath = path88.join(dir, entry);
79618
79964
  let stat7;
79619
79965
  try {
79620
- stat7 = fs66.statSync(fullPath);
79966
+ stat7 = fs67.statSync(fullPath);
79621
79967
  } catch (e) {
79622
79968
  stats.fileErrors.push({
79623
79969
  path: fullPath,
@@ -79686,7 +80032,7 @@ var imports = createSwarmTool({
79686
80032
  }
79687
80033
  try {
79688
80034
  const targetFile = path88.resolve(file3);
79689
- if (!fs66.existsSync(targetFile)) {
80035
+ if (!fs67.existsSync(targetFile)) {
79690
80036
  const errorResult = {
79691
80037
  error: `target file not found: ${file3}`,
79692
80038
  target: file3,
@@ -79696,7 +80042,7 @@ var imports = createSwarmTool({
79696
80042
  };
79697
80043
  return JSON.stringify(errorResult, null, 2);
79698
80044
  }
79699
- const targetStat = fs66.statSync(targetFile);
80045
+ const targetStat = fs67.statSync(targetFile);
79700
80046
  if (!targetStat.isFile()) {
79701
80047
  const errorResult = {
79702
80048
  error: "target must be a file, not a directory",
@@ -79722,12 +80068,12 @@ var imports = createSwarmTool({
79722
80068
  if (consumers.length >= MAX_CONSUMERS)
79723
80069
  break;
79724
80070
  try {
79725
- const stat7 = fs66.statSync(filePath);
80071
+ const stat7 = fs67.statSync(filePath);
79726
80072
  if (stat7.size > MAX_FILE_SIZE_BYTES7) {
79727
80073
  skippedFileCount++;
79728
80074
  continue;
79729
80075
  }
79730
- const buffer = fs66.readFileSync(filePath);
80076
+ const buffer = fs67.readFileSync(filePath);
79731
80077
  if (isBinaryFile2(filePath, buffer)) {
79732
80078
  skippedFileCount++;
79733
80079
  continue;
@@ -80252,7 +80598,7 @@ init_schema();
80252
80598
  init_qa_gate_profile();
80253
80599
  init_manager2();
80254
80600
  init_curator();
80255
- import * as fs68 from "node:fs";
80601
+ import * as fs69 from "node:fs";
80256
80602
  import * as path90 from "node:path";
80257
80603
  init_knowledge_curator();
80258
80604
  init_knowledge_reader();
@@ -80265,7 +80611,7 @@ init_file_locks();
80265
80611
  init_plan_schema();
80266
80612
  init_ledger();
80267
80613
  init_manager();
80268
- import * as fs67 from "node:fs";
80614
+ import * as fs68 from "node:fs";
80269
80615
  import * as path89 from "node:path";
80270
80616
  async function writeCheckpoint(directory) {
80271
80617
  try {
@@ -80273,12 +80619,12 @@ async function writeCheckpoint(directory) {
80273
80619
  if (!plan)
80274
80620
  return;
80275
80621
  const swarmDir = path89.join(directory, ".swarm");
80276
- fs67.mkdirSync(swarmDir, { recursive: true });
80622
+ fs68.mkdirSync(swarmDir, { recursive: true });
80277
80623
  const jsonPath = path89.join(swarmDir, "SWARM_PLAN.json");
80278
80624
  const mdPath = path89.join(swarmDir, "SWARM_PLAN.md");
80279
- fs67.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
80625
+ fs68.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
80280
80626
  const md = derivePlanMarkdown(plan);
80281
- fs67.writeFileSync(mdPath, md, "utf8");
80627
+ fs68.writeFileSync(mdPath, md, "utf8");
80282
80628
  } catch (error93) {
80283
80629
  console.warn(`[checkpoint] Failed to write SWARM_PLAN checkpoint: ${error93 instanceof Error ? error93.message : String(error93)}`);
80284
80630
  }
@@ -80511,7 +80857,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80511
80857
  let driftHasSpecMd = false;
80512
80858
  try {
80513
80859
  const specMdPath = path90.join(dir, ".swarm", "spec.md");
80514
- driftHasSpecMd = fs68.existsSync(specMdPath);
80860
+ driftHasSpecMd = fs69.existsSync(specMdPath);
80515
80861
  const gatePlan = await loadPlan(dir);
80516
80862
  if (gatePlan) {
80517
80863
  const gatePlanId = `${gatePlan.swarm}-${gatePlan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
@@ -80533,8 +80879,8 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80533
80879
  let phaseType;
80534
80880
  try {
80535
80881
  const planPath = path90.join(dir, ".swarm", "plan.json");
80536
- if (fs68.existsSync(planPath)) {
80537
- const planRaw = fs68.readFileSync(planPath, "utf-8");
80882
+ if (fs69.existsSync(planPath)) {
80883
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
80538
80884
  const plan = JSON.parse(planRaw);
80539
80885
  const targetPhase = plan.phases?.find((p) => p.id === phase);
80540
80886
  phaseType = targetPhase?.type;
@@ -80549,7 +80895,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80549
80895
  let driftVerdictFound = false;
80550
80896
  let driftVerdictApproved = false;
80551
80897
  try {
80552
- const driftEvidenceContent = fs68.readFileSync(driftEvidencePath, "utf-8");
80898
+ const driftEvidenceContent = fs69.readFileSync(driftEvidencePath, "utf-8");
80553
80899
  const driftEvidence = JSON.parse(driftEvidenceContent);
80554
80900
  const entries = driftEvidence.entries ?? [];
80555
80901
  for (const entry of entries) {
@@ -80584,8 +80930,8 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80584
80930
  let planParseable = false;
80585
80931
  try {
80586
80932
  const planPath = path90.join(dir, ".swarm", "plan.json");
80587
- if (fs68.existsSync(planPath)) {
80588
- const planRaw = fs68.readFileSync(planPath, "utf-8");
80933
+ if (fs69.existsSync(planPath)) {
80934
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
80589
80935
  const plan = JSON.parse(planRaw);
80590
80936
  planParseable = true;
80591
80937
  const planPhase = plan.phases?.find((p) => p.id === phase);
@@ -80654,7 +81000,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80654
81000
  let hgVerdictFound = false;
80655
81001
  let hgVerdictApproved = false;
80656
81002
  try {
80657
- const hgContent = fs68.readFileSync(hgPath, "utf-8");
81003
+ const hgContent = fs69.readFileSync(hgPath, "utf-8");
80658
81004
  const hgBundle = JSON.parse(hgContent);
80659
81005
  for (const entry of hgBundle.entries ?? []) {
80660
81006
  if (typeof entry.type === "string" && entry.type.includes("hallucination") && typeof entry.verdict === "string") {
@@ -80726,7 +81072,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80726
81072
  let mgVerdictFound = false;
80727
81073
  let mgVerdict;
80728
81074
  try {
80729
- const mgContent = fs68.readFileSync(mgPath, "utf-8");
81075
+ const mgContent = fs69.readFileSync(mgPath, "utf-8");
80730
81076
  const mgBundle = JSON.parse(mgContent);
80731
81077
  for (const entry of mgBundle.entries ?? []) {
80732
81078
  if (typeof entry.type === "string" && entry.type === "mutation-gate" && typeof entry.verdict === "string") {
@@ -80803,7 +81149,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
80803
81149
  let pcTimestamp;
80804
81150
  let pcPhaseNumber;
80805
81151
  try {
80806
- const pcContent = fs68.readFileSync(pcPath, "utf-8");
81152
+ const pcContent = fs69.readFileSync(pcPath, "utf-8");
80807
81153
  const pcBundle = JSON.parse(pcContent);
80808
81154
  for (const entry of pcBundle.entries ?? []) {
80809
81155
  if (typeof entry.type === "string" && entry.type === "phase-council" && typeof entry.verdict === "string") {
@@ -81078,7 +81424,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81078
81424
  let phaseRequiredAgents;
81079
81425
  try {
81080
81426
  const planPath = validateSwarmPath(dir, "plan.json");
81081
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81427
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81082
81428
  const plan = JSON.parse(planRaw);
81083
81429
  const phaseObj = plan.phases.find((p) => p.id === phase);
81084
81430
  phaseRequiredAgents = phaseObj?.required_agents;
@@ -81093,7 +81439,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81093
81439
  if (agentsMissing.length > 0) {
81094
81440
  try {
81095
81441
  const planPath = validateSwarmPath(dir, "plan.json");
81096
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81442
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81097
81443
  const plan = JSON.parse(planRaw);
81098
81444
  const targetPhase = plan.phases.find((p) => p.id === phase);
81099
81445
  if (targetPhase && targetPhase.tasks.length > 0 && targetPhase.tasks.every((t) => t.status === "completed")) {
@@ -81133,7 +81479,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81133
81479
  if (phaseCompleteConfig.regression_sweep?.enforce) {
81134
81480
  try {
81135
81481
  const planPath = validateSwarmPath(dir, "plan.json");
81136
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81482
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81137
81483
  const plan = JSON.parse(planRaw);
81138
81484
  const targetPhase = plan.phases.find((p) => p.id === phase);
81139
81485
  if (targetPhase) {
@@ -81187,7 +81533,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81187
81533
  }
81188
81534
  try {
81189
81535
  const eventsPath = validateSwarmPath(dir, "events.jsonl");
81190
- fs68.appendFileSync(eventsPath, `${JSON.stringify(event)}
81536
+ fs69.appendFileSync(eventsPath, `${JSON.stringify(event)}
81191
81537
  `, "utf-8");
81192
81538
  } catch (writeError) {
81193
81539
  warnings.push(`Warning: failed to write phase complete event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
@@ -81262,12 +81608,12 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81262
81608
  warnings.push(`Warning: failed to update plan.json phase status`);
81263
81609
  try {
81264
81610
  const planPath = validateSwarmPath(dir, "plan.json");
81265
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81611
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81266
81612
  const plan2 = JSON.parse(planRaw);
81267
81613
  const phaseObj = plan2.phases.find((p) => p.id === phase);
81268
81614
  if (phaseObj) {
81269
81615
  phaseObj.status = "complete";
81270
- fs68.writeFileSync(planPath, JSON.stringify(plan2, null, 2), "utf-8");
81616
+ fs69.writeFileSync(planPath, JSON.stringify(plan2, null, 2), "utf-8");
81271
81617
  }
81272
81618
  } catch {}
81273
81619
  } else if (plan) {
@@ -81304,12 +81650,12 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
81304
81650
  warnings.push(`Warning: failed to update plan.json phase status`);
81305
81651
  try {
81306
81652
  const planPath = validateSwarmPath(dir, "plan.json");
81307
- const planRaw = fs68.readFileSync(planPath, "utf-8");
81653
+ const planRaw = fs69.readFileSync(planPath, "utf-8");
81308
81654
  const plan = JSON.parse(planRaw);
81309
81655
  const phaseObj = plan.phases.find((p) => p.id === phase);
81310
81656
  if (phaseObj) {
81311
81657
  phaseObj.status = "complete";
81312
- fs68.writeFileSync(planPath, JSON.stringify(plan, null, 2), "utf-8");
81658
+ fs69.writeFileSync(planPath, JSON.stringify(plan, null, 2), "utf-8");
81313
81659
  }
81314
81660
  } catch {}
81315
81661
  }
@@ -81367,7 +81713,7 @@ init_discovery();
81367
81713
  init_utils();
81368
81714
  init_bun_compat();
81369
81715
  init_create_tool();
81370
- import * as fs69 from "node:fs";
81716
+ import * as fs70 from "node:fs";
81371
81717
  import * as path91 from "node:path";
81372
81718
  var MAX_OUTPUT_BYTES5 = 52428800;
81373
81719
  var AUDIT_TIMEOUT_MS = 120000;
@@ -81396,31 +81742,31 @@ function validateArgs3(args2) {
81396
81742
  function detectEcosystems(directory) {
81397
81743
  const ecosystems = [];
81398
81744
  const cwd = directory;
81399
- if (fs69.existsSync(path91.join(cwd, "package.json"))) {
81745
+ if (fs70.existsSync(path91.join(cwd, "package.json"))) {
81400
81746
  ecosystems.push("npm");
81401
81747
  }
81402
- 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"))) {
81403
81749
  ecosystems.push("pip");
81404
81750
  }
81405
- if (fs69.existsSync(path91.join(cwd, "Cargo.toml"))) {
81751
+ if (fs70.existsSync(path91.join(cwd, "Cargo.toml"))) {
81406
81752
  ecosystems.push("cargo");
81407
81753
  }
81408
- if (fs69.existsSync(path91.join(cwd, "go.mod"))) {
81754
+ if (fs70.existsSync(path91.join(cwd, "go.mod"))) {
81409
81755
  ecosystems.push("go");
81410
81756
  }
81411
81757
  try {
81412
- const files = fs69.readdirSync(cwd);
81758
+ const files = fs70.readdirSync(cwd);
81413
81759
  if (files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
81414
81760
  ecosystems.push("dotnet");
81415
81761
  }
81416
81762
  } catch {}
81417
- 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"))) {
81418
81764
  ecosystems.push("ruby");
81419
81765
  }
81420
- if (fs69.existsSync(path91.join(cwd, "pubspec.yaml"))) {
81766
+ if (fs70.existsSync(path91.join(cwd, "pubspec.yaml"))) {
81421
81767
  ecosystems.push("dart");
81422
81768
  }
81423
- if (fs69.existsSync(path91.join(cwd, "composer.lock"))) {
81769
+ if (fs70.existsSync(path91.join(cwd, "composer.lock"))) {
81424
81770
  ecosystems.push("composer");
81425
81771
  }
81426
81772
  return ecosystems;
@@ -82555,7 +82901,7 @@ var pkg_audit = createSwarmTool({
82555
82901
  // src/tools/placeholder-scan.ts
82556
82902
  init_zod();
82557
82903
  init_manager2();
82558
- import * as fs70 from "node:fs";
82904
+ import * as fs71 from "node:fs";
82559
82905
  import * as path92 from "node:path";
82560
82906
  init_utils();
82561
82907
  init_create_tool();
@@ -82957,7 +83303,7 @@ async function placeholderScan(input, directory) {
82957
83303
  if (!fullPath.startsWith(resolvedDirectory + path92.sep) && fullPath !== resolvedDirectory) {
82958
83304
  continue;
82959
83305
  }
82960
- if (!fs70.existsSync(fullPath)) {
83306
+ if (!fs71.existsSync(fullPath)) {
82961
83307
  continue;
82962
83308
  }
82963
83309
  if (isAllowedByGlobs(filePath, allow_globs)) {
@@ -82969,11 +83315,11 @@ async function placeholderScan(input, directory) {
82969
83315
  }
82970
83316
  let content;
82971
83317
  try {
82972
- const stat7 = fs70.statSync(fullPath);
83318
+ const stat7 = fs71.statSync(fullPath);
82973
83319
  if (stat7.size > MAX_FILE_SIZE) {
82974
83320
  continue;
82975
83321
  }
82976
- content = fs70.readFileSync(fullPath, "utf-8");
83322
+ content = fs71.readFileSync(fullPath, "utf-8");
82977
83323
  } catch {
82978
83324
  continue;
82979
83325
  }
@@ -83034,8 +83380,8 @@ var placeholder_scan = createSwarmTool({
83034
83380
  }
83035
83381
  });
83036
83382
  // src/tools/pre-check-batch.ts
83037
- import * as fs73 from "node:fs";
83038
- import * as path95 from "node:path";
83383
+ import * as fs75 from "node:fs";
83384
+ import * as path96 from "node:path";
83039
83385
  init_zod();
83040
83386
  init_manager2();
83041
83387
  init_utils();
@@ -83163,17 +83509,20 @@ var quality_budget = createSwarmTool({
83163
83509
  }).optional().describe("Quality budget thresholds")
83164
83510
  },
83165
83511
  async execute(args2, directory) {
83166
- const result = await qualityBudget(args2, directory);
83512
+ const result = await _internals28.qualityBudget(args2, directory);
83167
83513
  return JSON.stringify(result);
83168
83514
  }
83169
83515
  });
83516
+ var _internals28 = {
83517
+ qualityBudget
83518
+ };
83170
83519
 
83171
83520
  // src/tools/sast-scan.ts
83172
83521
  init_zod();
83173
83522
  init_manager2();
83174
83523
  init_detector();
83175
- import * as fs72 from "node:fs";
83176
- import * as path94 from "node:path";
83524
+ import * as fs74 from "node:fs";
83525
+ import * as path95 from "node:path";
83177
83526
  import { extname as extname18 } from "node:path";
83178
83527
 
83179
83528
  // src/sast/rules/c.ts
@@ -83888,9 +84237,19 @@ function executeRulesSync(filePath, content, language) {
83888
84237
 
83889
84238
  // src/sast/semgrep.ts
83890
84239
  import * as child_process9 from "node:child_process";
84240
+ import * as fs72 from "node:fs";
84241
+ import * as path93 from "node:path";
83891
84242
  var semgrepAvailableCache = null;
83892
84243
  var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
83893
84244
  var DEFAULT_TIMEOUT_MS3 = 30000;
84245
+ var _internals29 = {
84246
+ isSemgrepAvailable,
84247
+ checkSemgrepAvailable,
84248
+ resetSemgrepCache,
84249
+ runSemgrep,
84250
+ getRulesDirectory,
84251
+ hasBundledRules
84252
+ };
83894
84253
  function isSemgrepAvailable() {
83895
84254
  if (semgrepAvailableCache !== null) {
83896
84255
  return semgrepAvailableCache;
@@ -83907,6 +84266,12 @@ function isSemgrepAvailable() {
83907
84266
  return false;
83908
84267
  }
83909
84268
  }
84269
+ async function checkSemgrepAvailable() {
84270
+ return _internals29.isSemgrepAvailable();
84271
+ }
84272
+ function resetSemgrepCache() {
84273
+ semgrepAvailableCache = null;
84274
+ }
83910
84275
  function parseSemgrepResults(semgrepOutput) {
83911
84276
  const findings = [];
83912
84277
  try {
@@ -83954,7 +84319,7 @@ function mapSemgrepSeverity(severity) {
83954
84319
  }
83955
84320
  }
83956
84321
  async function executeWithTimeout(command, args2, options) {
83957
- return new Promise((resolve33) => {
84322
+ return new Promise((resolve34) => {
83958
84323
  const child = child_process9.spawn(command, args2, {
83959
84324
  shell: false,
83960
84325
  cwd: options.cwd
@@ -83963,7 +84328,7 @@ async function executeWithTimeout(command, args2, options) {
83963
84328
  let stderr = "";
83964
84329
  const timeout = setTimeout(() => {
83965
84330
  child.kill("SIGTERM");
83966
- resolve33({
84331
+ resolve34({
83967
84332
  stdout,
83968
84333
  stderr: "Process timed out",
83969
84334
  exitCode: 124
@@ -83977,7 +84342,7 @@ async function executeWithTimeout(command, args2, options) {
83977
84342
  });
83978
84343
  child.on("close", (code) => {
83979
84344
  clearTimeout(timeout);
83980
- resolve33({
84345
+ resolve34({
83981
84346
  stdout,
83982
84347
  stderr,
83983
84348
  exitCode: code ?? 0
@@ -83985,7 +84350,7 @@ async function executeWithTimeout(command, args2, options) {
83985
84350
  });
83986
84351
  child.on("error", (err2) => {
83987
84352
  clearTimeout(timeout);
83988
- resolve33({
84353
+ resolve34({
83989
84354
  stdout,
83990
84355
  stderr: err2.message,
83991
84356
  exitCode: 1
@@ -83999,12 +84364,12 @@ async function runSemgrep(options) {
83999
84364
  const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS3;
84000
84365
  if (files.length === 0) {
84001
84366
  return {
84002
- available: isSemgrepAvailable(),
84367
+ available: _internals29.isSemgrepAvailable(),
84003
84368
  findings: [],
84004
84369
  engine: "tier_a"
84005
84370
  };
84006
84371
  }
84007
- if (!isSemgrepAvailable()) {
84372
+ if (!_internals29.isSemgrepAvailable()) {
84008
84373
  return {
84009
84374
  available: false,
84010
84375
  findings: [],
@@ -84058,6 +84423,20 @@ async function runSemgrep(options) {
84058
84423
  };
84059
84424
  }
84060
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
+ }
84061
84440
 
84062
84441
  // src/tools/sast-scan.ts
84063
84442
  init_utils();
@@ -84065,26 +84444,26 @@ init_create_tool();
84065
84444
 
84066
84445
  // src/tools/sast-baseline.ts
84067
84446
  init_utils2();
84068
- import * as crypto8 from "node:crypto";
84069
- import * as fs71 from "node:fs";
84070
- 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";
84071
84450
  var BASELINE_SCHEMA_VERSION = "1.0.0";
84072
84451
  var MAX_BASELINE_FINDINGS = 2000;
84073
84452
  var MAX_BASELINE_BYTES = 2 * 1048576;
84074
84453
  var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
84075
84454
  function normalizeFindingPath(directory, file3) {
84076
- const resolved = path93.isAbsolute(file3) ? file3 : path93.resolve(directory, file3);
84077
- 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);
84078
84457
  return rel.replace(/\\/g, "/");
84079
84458
  }
84080
84459
  function baselineRelPath(phase) {
84081
- return path93.join("evidence", String(phase), "sast-baseline.json");
84460
+ return path94.join("evidence", String(phase), "sast-baseline.json");
84082
84461
  }
84083
84462
  function tempRelPath(phase) {
84084
- 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}`);
84085
84464
  }
84086
84465
  function lockRelPath(phase) {
84087
- return path93.join("evidence", String(phase), "sast-baseline.json.lock");
84466
+ return path94.join("evidence", String(phase), "sast-baseline.json.lock");
84088
84467
  }
84089
84468
  function getLine(lines, idx) {
84090
84469
  if (idx < 0 || idx >= lines.length)
@@ -84101,7 +84480,7 @@ function fingerprintFinding(finding, directory, occurrenceIndex) {
84101
84480
  }
84102
84481
  const lineNum = finding.location.line;
84103
84482
  try {
84104
- const content = fs71.readFileSync(finding.location.file, "utf-8");
84483
+ const content = fs73.readFileSync(finding.location.file, "utf-8");
84105
84484
  const lines = content.split(`
84106
84485
  `);
84107
84486
  const idx = lineNum - 1;
@@ -84111,7 +84490,7 @@ function fingerprintFinding(finding, directory, occurrenceIndex) {
84111
84490
  getLine(lines, idx + 1)
84112
84491
  ].join(`
84113
84492
  `);
84114
- 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);
84115
84494
  return {
84116
84495
  fingerprint: `${relFile}|${finding.rule_id}|${hash3}|#${occurrenceIndex}`,
84117
84496
  stable: true
@@ -84132,7 +84511,7 @@ function assignOccurrenceIndices(findings, directory) {
84132
84511
  try {
84133
84512
  if (relFile.startsWith(".."))
84134
84513
  throw new Error("escapes workspace");
84135
- const content = fs71.readFileSync(finding.location.file, "utf-8");
84514
+ const content = fs73.readFileSync(finding.location.file, "utf-8");
84136
84515
  const lines = content.split(`
84137
84516
  `);
84138
84517
  const idx = lineNum - 1;
@@ -84142,14 +84521,14 @@ function assignOccurrenceIndices(findings, directory) {
84142
84521
  getLine(lines, idx + 1)
84143
84522
  ].join(`
84144
84523
  `);
84145
- 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);
84146
84525
  baseKey = `${relFile}|${finding.rule_id}|${hash3}`;
84147
84526
  } catch {
84148
84527
  baseKey = `${relFile}|${finding.rule_id}|L${lineNum}|UNSTABLE`;
84149
84528
  }
84150
84529
  const occIdx = countMap.get(baseKey) ?? 0;
84151
84530
  countMap.set(baseKey, occIdx + 1);
84152
- const fp = fingerprintFinding(finding, directory, occIdx);
84531
+ const fp = _internals30.fingerprintFinding(finding, directory, occIdx);
84153
84532
  return {
84154
84533
  finding,
84155
84534
  index: occIdx,
@@ -84161,16 +84540,16 @@ function assignOccurrenceIndices(findings, directory) {
84161
84540
  async function acquireLock(lockPath) {
84162
84541
  for (let attempt = 0;attempt <= LOCK_RETRY_DELAYS_MS.length; attempt++) {
84163
84542
  try {
84164
- const fd = fs71.openSync(lockPath, "wx");
84165
- fs71.closeSync(fd);
84543
+ const fd = fs73.openSync(lockPath, "wx");
84544
+ fs73.closeSync(fd);
84166
84545
  return () => {
84167
84546
  try {
84168
- fs71.unlinkSync(lockPath);
84547
+ fs73.unlinkSync(lockPath);
84169
84548
  } catch {}
84170
84549
  };
84171
84550
  } catch {
84172
84551
  if (attempt < LOCK_RETRY_DELAYS_MS.length) {
84173
- await new Promise((resolve34) => setTimeout(resolve34, LOCK_RETRY_DELAYS_MS[attempt]));
84552
+ await new Promise((resolve35) => setTimeout(resolve35, LOCK_RETRY_DELAYS_MS[attempt]));
84174
84553
  }
84175
84554
  }
84176
84555
  }
@@ -84205,20 +84584,20 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
84205
84584
  message: e instanceof Error ? e.message : "Path validation failed"
84206
84585
  };
84207
84586
  }
84208
- fs71.mkdirSync(path93.dirname(baselinePath), { recursive: true });
84209
- fs71.mkdirSync(path93.dirname(tempPath), { recursive: true });
84587
+ fs73.mkdirSync(path94.dirname(baselinePath), { recursive: true });
84588
+ fs73.mkdirSync(path94.dirname(tempPath), { recursive: true });
84210
84589
  const releaseLock = await acquireLock(lockPath);
84211
84590
  try {
84212
84591
  let existing = null;
84213
84592
  try {
84214
- const raw = fs71.readFileSync(baselinePath, "utf-8");
84593
+ const raw = fs73.readFileSync(baselinePath, "utf-8");
84215
84594
  const parsed = JSON.parse(raw);
84216
84595
  if (parsed.schema_version === BASELINE_SCHEMA_VERSION) {
84217
84596
  existing = parsed;
84218
84597
  }
84219
84598
  } catch {}
84220
84599
  const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
84221
- const indexed = assignOccurrenceIndices(findings, directory);
84600
+ const indexed = _internals30.assignOccurrenceIndices(findings, directory);
84222
84601
  if (existing && !opts?.force) {
84223
84602
  const prunedFingerprints = existing.fingerprints.filter((fp) => {
84224
84603
  const relFile = fp.slice(0, fp.indexOf("|"));
@@ -84271,8 +84650,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
84271
84650
  message: `Baseline would exceed size cap (${json4.length} bytes > ${MAX_BASELINE_BYTES})`
84272
84651
  };
84273
84652
  }
84274
- fs71.writeFileSync(tempPath, json4, "utf-8");
84275
- fs71.renameSync(tempPath, baselinePath);
84653
+ fs73.writeFileSync(tempPath, json4, "utf-8");
84654
+ fs73.renameSync(tempPath, baselinePath);
84276
84655
  return {
84277
84656
  status: "merged",
84278
84657
  path: baselinePath,
@@ -84303,8 +84682,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
84303
84682
  message: `Baseline would exceed size cap (${json3.length} bytes > ${MAX_BASELINE_BYTES})`
84304
84683
  };
84305
84684
  }
84306
- fs71.writeFileSync(tempPath, json3, "utf-8");
84307
- fs71.renameSync(tempPath, baselinePath);
84685
+ fs73.writeFileSync(tempPath, json3, "utf-8");
84686
+ fs73.renameSync(tempPath, baselinePath);
84308
84687
  return {
84309
84688
  status: "written",
84310
84689
  path: baselinePath,
@@ -84329,7 +84708,7 @@ function loadBaseline(directory, phase) {
84329
84708
  };
84330
84709
  }
84331
84710
  try {
84332
- const raw = fs71.readFileSync(baselinePath, "utf-8");
84711
+ const raw = fs73.readFileSync(baselinePath, "utf-8");
84333
84712
  const parsed = JSON.parse(raw);
84334
84713
  if (parsed.schema_version !== BASELINE_SCHEMA_VERSION) {
84335
84714
  return {
@@ -84358,6 +84737,12 @@ function loadBaseline(directory, phase) {
84358
84737
  };
84359
84738
  }
84360
84739
  }
84740
+ var _internals30 = {
84741
+ fingerprintFinding,
84742
+ assignOccurrenceIndices,
84743
+ captureOrMergeBaseline,
84744
+ loadBaseline
84745
+ };
84361
84746
 
84362
84747
  // src/tools/sast-scan.ts
84363
84748
  var MAX_FILE_SIZE_BYTES8 = 512 * 1024;
@@ -84371,17 +84756,17 @@ var SEVERITY_ORDER = {
84371
84756
  };
84372
84757
  function shouldSkipFile(filePath) {
84373
84758
  try {
84374
- const stats = fs72.statSync(filePath);
84759
+ const stats = fs74.statSync(filePath);
84375
84760
  if (stats.size > MAX_FILE_SIZE_BYTES8) {
84376
84761
  return { skip: true, reason: "file too large" };
84377
84762
  }
84378
84763
  if (stats.size === 0) {
84379
84764
  return { skip: true, reason: "empty file" };
84380
84765
  }
84381
- const fd = fs72.openSync(filePath, "r");
84766
+ const fd = fs74.openSync(filePath, "r");
84382
84767
  const buffer = Buffer.alloc(8192);
84383
- const bytesRead = fs72.readSync(fd, buffer, 0, 8192, 0);
84384
- fs72.closeSync(fd);
84768
+ const bytesRead = fs74.readSync(fd, buffer, 0, 8192, 0);
84769
+ fs74.closeSync(fd);
84385
84770
  if (bytesRead > 0) {
84386
84771
  let nullCount = 0;
84387
84772
  for (let i2 = 0;i2 < bytesRead; i2++) {
@@ -84420,7 +84805,7 @@ function countBySeverity(findings) {
84420
84805
  }
84421
84806
  function scanFileWithTierA(filePath, language) {
84422
84807
  try {
84423
- const content = fs72.readFileSync(filePath, "utf-8");
84808
+ const content = fs74.readFileSync(filePath, "utf-8");
84424
84809
  const findings = executeRulesSync(filePath, content, language);
84425
84810
  return findings.map((f) => ({
84426
84811
  rule_id: f.rule_id,
@@ -84473,13 +84858,13 @@ async function sastScan(input, directory, config3) {
84473
84858
  _filesSkipped++;
84474
84859
  continue;
84475
84860
  }
84476
- const resolvedPath = path94.isAbsolute(filePath) ? filePath : path94.resolve(directory, filePath);
84477
- const resolvedDirectory = path94.resolve(directory);
84478
- 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) {
84479
84864
  _filesSkipped++;
84480
84865
  continue;
84481
84866
  }
84482
- if (!fs72.existsSync(resolvedPath)) {
84867
+ if (!fs74.existsSync(resolvedPath)) {
84483
84868
  _filesSkipped++;
84484
84869
  continue;
84485
84870
  }
@@ -84762,10 +85147,14 @@ var sast_scan = createSwarmTool({
84762
85147
  capture_baseline: safeArgs.capture_baseline,
84763
85148
  phase: safeArgs.phase
84764
85149
  };
84765
- const result = await sastScan(input, directory);
85150
+ const result = await _internals31.sastScan(input, directory);
84766
85151
  return JSON.stringify(result, null, 2);
84767
85152
  }
84768
85153
  });
85154
+ var _internals31 = {
85155
+ sastScan,
85156
+ sast_scan
85157
+ };
84769
85158
 
84770
85159
  // src/tools/pre-check-batch.ts
84771
85160
  init_secretscan();
@@ -84786,18 +85175,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
84786
85175
  let resolved;
84787
85176
  const isWinAbs = isWindowsAbsolutePath(inputPath);
84788
85177
  if (isWinAbs) {
84789
- resolved = path95.win32.resolve(inputPath);
84790
- } else if (path95.isAbsolute(inputPath)) {
84791
- resolved = path95.resolve(inputPath);
85178
+ resolved = path96.win32.resolve(inputPath);
85179
+ } else if (path96.isAbsolute(inputPath)) {
85180
+ resolved = path96.resolve(inputPath);
84792
85181
  } else {
84793
- resolved = path95.resolve(baseDir, inputPath);
85182
+ resolved = path96.resolve(baseDir, inputPath);
84794
85183
  }
84795
- const workspaceResolved = path95.resolve(workspaceDir);
85184
+ const workspaceResolved = path96.resolve(workspaceDir);
84796
85185
  let relative20;
84797
85186
  if (isWinAbs) {
84798
- relative20 = path95.win32.relative(workspaceResolved, resolved);
85187
+ relative20 = path96.win32.relative(workspaceResolved, resolved);
84799
85188
  } else {
84800
- relative20 = path95.relative(workspaceResolved, resolved);
85189
+ relative20 = path96.relative(workspaceResolved, resolved);
84801
85190
  }
84802
85191
  if (relative20.startsWith("..")) {
84803
85192
  return "path traversal detected";
@@ -84862,7 +85251,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
84862
85251
  if (typeof file3 !== "string") {
84863
85252
  continue;
84864
85253
  }
84865
- const resolvedPath = path95.resolve(file3);
85254
+ const resolvedPath = path96.resolve(file3);
84866
85255
  const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
84867
85256
  if (validationError) {
84868
85257
  continue;
@@ -85019,7 +85408,7 @@ async function runSecretscanWithFiles(files, directory) {
85019
85408
  skippedFiles++;
85020
85409
  continue;
85021
85410
  }
85022
- const resolvedPath = path95.resolve(file3);
85411
+ const resolvedPath = path96.resolve(file3);
85023
85412
  const validationError = validatePath(resolvedPath, directory, directory);
85024
85413
  if (validationError) {
85025
85414
  skippedFiles++;
@@ -85037,14 +85426,14 @@ async function runSecretscanWithFiles(files, directory) {
85037
85426
  };
85038
85427
  }
85039
85428
  for (const file3 of validatedFiles) {
85040
- const ext = path95.extname(file3).toLowerCase();
85429
+ const ext = path96.extname(file3).toLowerCase();
85041
85430
  if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
85042
85431
  skippedFiles++;
85043
85432
  continue;
85044
85433
  }
85045
85434
  let stat7;
85046
85435
  try {
85047
- stat7 = fs73.statSync(file3);
85436
+ stat7 = fs75.statSync(file3);
85048
85437
  } catch {
85049
85438
  skippedFiles++;
85050
85439
  continue;
@@ -85055,7 +85444,7 @@ async function runSecretscanWithFiles(files, directory) {
85055
85444
  }
85056
85445
  let content;
85057
85446
  try {
85058
- const buffer = fs73.readFileSync(file3);
85447
+ const buffer = fs75.readFileSync(file3);
85059
85448
  if (buffer.includes(0)) {
85060
85449
  skippedFiles++;
85061
85450
  continue;
@@ -85256,7 +85645,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
85256
85645
  const preexistingFindings = [];
85257
85646
  for (const finding of findings) {
85258
85647
  const filePath = finding.location.file;
85259
- const normalised = path95.relative(directory, filePath).replace(/\\/g, "/");
85648
+ const normalised = path96.relative(directory, filePath).replace(/\\/g, "/");
85260
85649
  const changedLines = changedLineRanges.get(normalised);
85261
85650
  if (changedLines?.has(finding.location.line)) {
85262
85651
  newFindings.push(finding);
@@ -85307,7 +85696,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
85307
85696
  warn(`pre_check_batch: Invalid file path: ${file3}`);
85308
85697
  continue;
85309
85698
  }
85310
- changedFiles.push(path95.resolve(directory, file3));
85699
+ changedFiles.push(path96.resolve(directory, file3));
85311
85700
  }
85312
85701
  if (changedFiles.length === 0) {
85313
85702
  warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
@@ -85508,7 +85897,7 @@ var pre_check_batch = createSwarmTool({
85508
85897
  };
85509
85898
  return JSON.stringify(errorResult, null, 2);
85510
85899
  }
85511
- const resolvedDirectory = path95.resolve(typedArgs.directory);
85900
+ const resolvedDirectory = path96.resolve(typedArgs.directory);
85512
85901
  const workspaceAnchor = resolvedDirectory;
85513
85902
  const dirError = validateDirectory2(resolvedDirectory, workspaceAnchor);
85514
85903
  if (dirError) {
@@ -85549,7 +85938,7 @@ var pre_check_batch = createSwarmTool({
85549
85938
  });
85550
85939
  // src/tools/repo-map.ts
85551
85940
  init_zod();
85552
- import * as path96 from "node:path";
85941
+ import * as path97 from "node:path";
85553
85942
  init_path_security();
85554
85943
  init_create_tool();
85555
85944
  var VALID_ACTIONS = [
@@ -85574,7 +85963,7 @@ function validateFile(p) {
85574
85963
  return "file contains control characters";
85575
85964
  if (containsPathTraversal(p))
85576
85965
  return "file contains path traversal";
85577
- if (path96.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
85966
+ if (path97.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
85578
85967
  return "file must be a workspace-relative path, not absolute";
85579
85968
  }
85580
85969
  return null;
@@ -85597,8 +85986,8 @@ function ok(action, payload) {
85597
85986
  }
85598
85987
  function toRelativeGraphPath(input, workspaceRoot) {
85599
85988
  const normalized = input.replace(/\\/g, "/");
85600
- if (path96.isAbsolute(normalized)) {
85601
- const rel = path96.relative(workspaceRoot, normalized).replace(/\\/g, "/");
85989
+ if (path97.isAbsolute(normalized)) {
85990
+ const rel = path97.relative(workspaceRoot, normalized).replace(/\\/g, "/");
85602
85991
  return normalizeGraphPath2(rel);
85603
85992
  }
85604
85993
  return normalizeGraphPath2(normalized);
@@ -85742,8 +86131,8 @@ var repo_map = createSwarmTool({
85742
86131
  // src/tools/req-coverage.ts
85743
86132
  init_zod();
85744
86133
  init_create_tool();
85745
- import * as fs74 from "node:fs";
85746
- import * as path97 from "node:path";
86134
+ import * as fs76 from "node:fs";
86135
+ import * as path98 from "node:path";
85747
86136
  var SPEC_FILE = ".swarm/spec.md";
85748
86137
  var EVIDENCE_DIR4 = ".swarm/evidence";
85749
86138
  var OBLIGATION_KEYWORDS = ["MUST", "SHOULD", "SHALL"];
@@ -85802,19 +86191,19 @@ function extractObligationAndText(id, lineText) {
85802
86191
  var PHASE_TASK_ID_REGEX = /^\d+\.\d+(\.\d+)*$/;
85803
86192
  function readTouchedFiles(evidenceDir, phase, cwd) {
85804
86193
  const touchedFiles = new Set;
85805
- if (!fs74.existsSync(evidenceDir) || !fs74.statSync(evidenceDir).isDirectory()) {
86194
+ if (!fs76.existsSync(evidenceDir) || !fs76.statSync(evidenceDir).isDirectory()) {
85806
86195
  return [];
85807
86196
  }
85808
86197
  let entries;
85809
86198
  try {
85810
- entries = fs74.readdirSync(evidenceDir);
86199
+ entries = fs76.readdirSync(evidenceDir);
85811
86200
  } catch {
85812
86201
  return [];
85813
86202
  }
85814
86203
  for (const entry of entries) {
85815
- const entryPath = path97.join(evidenceDir, entry);
86204
+ const entryPath = path98.join(evidenceDir, entry);
85816
86205
  try {
85817
- const stat7 = fs74.statSync(entryPath);
86206
+ const stat7 = fs76.statSync(entryPath);
85818
86207
  if (!stat7.isDirectory()) {
85819
86208
  continue;
85820
86209
  }
@@ -85828,14 +86217,14 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85828
86217
  if (entryPhase !== String(phase)) {
85829
86218
  continue;
85830
86219
  }
85831
- const evidenceFilePath = path97.join(entryPath, "evidence.json");
86220
+ const evidenceFilePath = path98.join(entryPath, "evidence.json");
85832
86221
  try {
85833
- const resolvedPath = path97.resolve(evidenceFilePath);
85834
- const evidenceDirResolved = path97.resolve(evidenceDir);
85835
- 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)) {
85836
86225
  continue;
85837
86226
  }
85838
- const stat7 = fs74.lstatSync(evidenceFilePath);
86227
+ const stat7 = fs76.lstatSync(evidenceFilePath);
85839
86228
  if (!stat7.isFile()) {
85840
86229
  continue;
85841
86230
  }
@@ -85847,7 +86236,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85847
86236
  }
85848
86237
  let content;
85849
86238
  try {
85850
- content = fs74.readFileSync(evidenceFilePath, "utf-8");
86239
+ content = fs76.readFileSync(evidenceFilePath, "utf-8");
85851
86240
  } catch {
85852
86241
  continue;
85853
86242
  }
@@ -85866,7 +86255,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85866
86255
  if (Array.isArray(diffEntry.files_changed)) {
85867
86256
  for (const file3 of diffEntry.files_changed) {
85868
86257
  if (typeof file3 === "string") {
85869
- touchedFiles.add(path97.resolve(cwd, file3));
86258
+ touchedFiles.add(path98.resolve(cwd, file3));
85870
86259
  }
85871
86260
  }
85872
86261
  }
@@ -85879,12 +86268,12 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
85879
86268
  }
85880
86269
  function searchFileForKeywords(filePath, keywords, cwd) {
85881
86270
  try {
85882
- const resolvedPath = path97.resolve(filePath);
85883
- const cwdResolved = path97.resolve(cwd);
86271
+ const resolvedPath = path98.resolve(filePath);
86272
+ const cwdResolved = path98.resolve(cwd);
85884
86273
  if (!resolvedPath.startsWith(cwdResolved)) {
85885
86274
  return false;
85886
86275
  }
85887
- const content = fs74.readFileSync(resolvedPath, "utf-8");
86276
+ const content = fs76.readFileSync(resolvedPath, "utf-8");
85888
86277
  for (const keyword of keywords) {
85889
86278
  const regex = new RegExp(`\\b${keyword}\\b`, "i");
85890
86279
  if (regex.test(content)) {
@@ -86014,10 +86403,10 @@ var req_coverage = createSwarmTool({
86014
86403
  }, null, 2);
86015
86404
  }
86016
86405
  const cwd = inputDirectory || directory;
86017
- const specPath = path97.join(cwd, SPEC_FILE);
86406
+ const specPath = path98.join(cwd, SPEC_FILE);
86018
86407
  let specContent;
86019
86408
  try {
86020
- specContent = fs74.readFileSync(specPath, "utf-8");
86409
+ specContent = fs76.readFileSync(specPath, "utf-8");
86021
86410
  } catch (readError) {
86022
86411
  return JSON.stringify({
86023
86412
  success: false,
@@ -86041,7 +86430,7 @@ var req_coverage = createSwarmTool({
86041
86430
  message: "No FR requirements found in spec.md"
86042
86431
  }, null, 2);
86043
86432
  }
86044
- const evidenceDir = path97.join(cwd, EVIDENCE_DIR4);
86433
+ const evidenceDir = path98.join(cwd, EVIDENCE_DIR4);
86045
86434
  const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
86046
86435
  const analyzedRequirements = [];
86047
86436
  let coveredCount = 0;
@@ -86067,12 +86456,12 @@ var req_coverage = createSwarmTool({
86067
86456
  requirements: analyzedRequirements
86068
86457
  };
86069
86458
  const reportFilename = `req-coverage-phase-${phase}.json`;
86070
- const reportPath = path97.join(evidenceDir, reportFilename);
86459
+ const reportPath = path98.join(evidenceDir, reportFilename);
86071
86460
  try {
86072
- if (!fs74.existsSync(evidenceDir)) {
86073
- fs74.mkdirSync(evidenceDir, { recursive: true });
86461
+ if (!fs76.existsSync(evidenceDir)) {
86462
+ fs76.mkdirSync(evidenceDir, { recursive: true });
86074
86463
  }
86075
- fs74.writeFileSync(reportPath, JSON.stringify(result, null, 2), "utf-8");
86464
+ fs76.writeFileSync(reportPath, JSON.stringify(result, null, 2), "utf-8");
86076
86465
  } catch (writeError) {
86077
86466
  console.warn(`Failed to write coverage report: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
86078
86467
  }
@@ -86153,9 +86542,9 @@ init_zod();
86153
86542
  init_plan_schema();
86154
86543
  init_qa_gate_profile();
86155
86544
  init_file_locks();
86156
- import * as crypto9 from "node:crypto";
86157
- import * as fs75 from "node:fs";
86158
- 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";
86159
86548
  init_ledger();
86160
86549
  init_manager();
86161
86550
  init_state();
@@ -86233,17 +86622,17 @@ async function executeSavePlan(args2, fallbackDir) {
86233
86622
  };
86234
86623
  }
86235
86624
  if (args2.working_directory && fallbackDir) {
86236
- const resolvedTarget = path98.resolve(args2.working_directory);
86237
- const resolvedRoot = path98.resolve(fallbackDir);
86625
+ const resolvedTarget = path99.resolve(args2.working_directory);
86626
+ const resolvedRoot = path99.resolve(fallbackDir);
86238
86627
  let fallbackExists = false;
86239
86628
  try {
86240
- fs75.accessSync(resolvedRoot, fs75.constants.F_OK);
86629
+ fs77.accessSync(resolvedRoot, fs77.constants.F_OK);
86241
86630
  fallbackExists = true;
86242
86631
  } catch {
86243
86632
  fallbackExists = false;
86244
86633
  }
86245
86634
  if (fallbackExists) {
86246
- const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path98.sep);
86635
+ const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path99.sep);
86247
86636
  if (isSubdirectory) {
86248
86637
  return {
86249
86638
  success: false,
@@ -86259,12 +86648,12 @@ async function executeSavePlan(args2, fallbackDir) {
86259
86648
  let specMtime;
86260
86649
  let specHash;
86261
86650
  if (process.env.SWARM_SKIP_SPEC_GATE !== "1") {
86262
- const specPath = path98.join(targetWorkspace, ".swarm", "spec.md");
86651
+ const specPath = path99.join(targetWorkspace, ".swarm", "spec.md");
86263
86652
  try {
86264
- const stat7 = await fs75.promises.stat(specPath);
86653
+ const stat7 = await fs77.promises.stat(specPath);
86265
86654
  specMtime = stat7.mtime.toISOString();
86266
- const content = await fs75.promises.readFile(specPath, "utf8");
86267
- 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");
86268
86657
  } catch {
86269
86658
  return {
86270
86659
  success: false,
@@ -86275,10 +86664,10 @@ async function executeSavePlan(args2, fallbackDir) {
86275
86664
  }
86276
86665
  }
86277
86666
  if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
86278
- const contextPath = path98.join(targetWorkspace, ".swarm", "context.md");
86667
+ const contextPath = path99.join(targetWorkspace, ".swarm", "context.md");
86279
86668
  let contextContent = "";
86280
86669
  try {
86281
- contextContent = await fs75.promises.readFile(contextPath, "utf8");
86670
+ contextContent = await fs77.promises.readFile(contextPath, "utf8");
86282
86671
  } catch {}
86283
86672
  const hasPendingSection = contextContent.includes("## Pending QA Gate Selection");
86284
86673
  if (!hasPendingSection) {
@@ -86425,14 +86814,14 @@ async function executeSavePlan(args2, fallbackDir) {
86425
86814
  }
86426
86815
  await writeCheckpoint(dir).catch(() => {});
86427
86816
  try {
86428
- const markerPath = path98.join(dir, ".swarm", ".plan-write-marker");
86817
+ const markerPath = path99.join(dir, ".swarm", ".plan-write-marker");
86429
86818
  const marker = JSON.stringify({
86430
86819
  source: "save_plan",
86431
86820
  timestamp: new Date().toISOString(),
86432
86821
  phases_count: plan.phases.length,
86433
86822
  tasks_count: tasksCount
86434
86823
  });
86435
- await fs75.promises.writeFile(markerPath, marker, "utf8");
86824
+ await fs77.promises.writeFile(markerPath, marker, "utf8");
86436
86825
  } catch {}
86437
86826
  const warnings = [];
86438
86827
  let criticReviewFound = false;
@@ -86448,7 +86837,7 @@ async function executeSavePlan(args2, fallbackDir) {
86448
86837
  return {
86449
86838
  success: true,
86450
86839
  message: "Plan saved successfully",
86451
- plan_path: path98.join(dir, ".swarm", "plan.json"),
86840
+ plan_path: path99.join(dir, ".swarm", "plan.json"),
86452
86841
  phases_count: plan.phases.length,
86453
86842
  tasks_count: tasksCount,
86454
86843
  ...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
@@ -86500,8 +86889,8 @@ var save_plan = createSwarmTool({
86500
86889
  // src/tools/sbom-generate.ts
86501
86890
  init_zod();
86502
86891
  init_manager2();
86503
- import * as fs76 from "node:fs";
86504
- import * as path99 from "node:path";
86892
+ import * as fs78 from "node:fs";
86893
+ import * as path100 from "node:path";
86505
86894
 
86506
86895
  // src/sbom/detectors/index.ts
86507
86896
  init_utils();
@@ -87349,9 +87738,9 @@ function findManifestFiles(rootDir) {
87349
87738
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
87350
87739
  function searchDir(dir) {
87351
87740
  try {
87352
- const entries = fs76.readdirSync(dir, { withFileTypes: true });
87741
+ const entries = fs78.readdirSync(dir, { withFileTypes: true });
87353
87742
  for (const entry of entries) {
87354
- const fullPath = path99.join(dir, entry.name);
87743
+ const fullPath = path100.join(dir, entry.name);
87355
87744
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
87356
87745
  continue;
87357
87746
  }
@@ -87360,7 +87749,7 @@ function findManifestFiles(rootDir) {
87360
87749
  } else if (entry.isFile()) {
87361
87750
  for (const pattern of patterns) {
87362
87751
  if (simpleGlobToRegex(pattern).test(entry.name)) {
87363
- manifestFiles.push(path99.relative(rootDir, fullPath));
87752
+ manifestFiles.push(path100.relative(rootDir, fullPath));
87364
87753
  break;
87365
87754
  }
87366
87755
  }
@@ -87376,13 +87765,13 @@ function findManifestFilesInDirs(directories, workingDir) {
87376
87765
  const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
87377
87766
  for (const dir of directories) {
87378
87767
  try {
87379
- const entries = fs76.readdirSync(dir, { withFileTypes: true });
87768
+ const entries = fs78.readdirSync(dir, { withFileTypes: true });
87380
87769
  for (const entry of entries) {
87381
- const fullPath = path99.join(dir, entry.name);
87770
+ const fullPath = path100.join(dir, entry.name);
87382
87771
  if (entry.isFile()) {
87383
87772
  for (const pattern of patterns) {
87384
87773
  if (simpleGlobToRegex(pattern).test(entry.name)) {
87385
- found.push(path99.relative(workingDir, fullPath));
87774
+ found.push(path100.relative(workingDir, fullPath));
87386
87775
  break;
87387
87776
  }
87388
87777
  }
@@ -87395,11 +87784,11 @@ function findManifestFilesInDirs(directories, workingDir) {
87395
87784
  function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
87396
87785
  const dirs = new Set;
87397
87786
  for (const file3 of changedFiles) {
87398
- let currentDir = path99.dirname(file3);
87787
+ let currentDir = path100.dirname(file3);
87399
87788
  while (true) {
87400
- if (currentDir && currentDir !== "." && currentDir !== path99.sep) {
87401
- dirs.add(path99.join(workingDir, currentDir));
87402
- 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);
87403
87792
  if (parent === currentDir)
87404
87793
  break;
87405
87794
  currentDir = parent;
@@ -87413,7 +87802,7 @@ function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
87413
87802
  }
87414
87803
  function ensureOutputDir(outputDir) {
87415
87804
  try {
87416
- fs76.mkdirSync(outputDir, { recursive: true });
87805
+ fs78.mkdirSync(outputDir, { recursive: true });
87417
87806
  } catch (error93) {
87418
87807
  if (!error93 || error93.code !== "EEXIST") {
87419
87808
  throw error93;
@@ -87483,7 +87872,7 @@ var sbom_generate = createSwarmTool({
87483
87872
  const changedFiles = obj.changed_files;
87484
87873
  const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
87485
87874
  const workingDir = directory;
87486
- const outputDir = path99.isAbsolute(relativeOutputDir) ? relativeOutputDir : path99.join(workingDir, relativeOutputDir);
87875
+ const outputDir = path100.isAbsolute(relativeOutputDir) ? relativeOutputDir : path100.join(workingDir, relativeOutputDir);
87487
87876
  let manifestFiles = [];
87488
87877
  if (scope === "all") {
87489
87878
  manifestFiles = findManifestFiles(workingDir);
@@ -87506,11 +87895,11 @@ var sbom_generate = createSwarmTool({
87506
87895
  const processedFiles = [];
87507
87896
  for (const manifestFile of manifestFiles) {
87508
87897
  try {
87509
- const fullPath = path99.isAbsolute(manifestFile) ? manifestFile : path99.join(workingDir, manifestFile);
87510
- if (!fs76.existsSync(fullPath)) {
87898
+ const fullPath = path100.isAbsolute(manifestFile) ? manifestFile : path100.join(workingDir, manifestFile);
87899
+ if (!fs78.existsSync(fullPath)) {
87511
87900
  continue;
87512
87901
  }
87513
- const content = fs76.readFileSync(fullPath, "utf-8");
87902
+ const content = fs78.readFileSync(fullPath, "utf-8");
87514
87903
  const components = detectComponents(manifestFile, content);
87515
87904
  processedFiles.push(manifestFile);
87516
87905
  if (components.length > 0) {
@@ -87523,8 +87912,8 @@ var sbom_generate = createSwarmTool({
87523
87912
  const bom = generateCycloneDX(allComponents);
87524
87913
  const bomJson = serializeCycloneDX(bom);
87525
87914
  const filename = generateSbomFilename();
87526
- const outputPath = path99.join(outputDir, filename);
87527
- fs76.writeFileSync(outputPath, bomJson, "utf-8");
87915
+ const outputPath = path100.join(outputDir, filename);
87916
+ fs78.writeFileSync(outputPath, bomJson, "utf-8");
87528
87917
  const verdict = processedFiles.length > 0 ? "pass" : "pass";
87529
87918
  try {
87530
87919
  const timestamp = new Date().toISOString();
@@ -87566,8 +87955,8 @@ var sbom_generate = createSwarmTool({
87566
87955
  // src/tools/schema-drift.ts
87567
87956
  init_zod();
87568
87957
  init_create_tool();
87569
- import * as fs77 from "node:fs";
87570
- import * as path100 from "node:path";
87958
+ import * as fs79 from "node:fs";
87959
+ import * as path101 from "node:path";
87571
87960
  var SPEC_CANDIDATES = [
87572
87961
  "openapi.json",
87573
87962
  "openapi.yaml",
@@ -87599,28 +87988,28 @@ function normalizePath3(p) {
87599
87988
  }
87600
87989
  function discoverSpecFile(cwd, specFileArg) {
87601
87990
  if (specFileArg) {
87602
- const resolvedPath = path100.resolve(cwd, specFileArg);
87603
- 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;
87604
87993
  if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
87605
87994
  throw new Error("Invalid spec_file: path traversal detected");
87606
87995
  }
87607
- const ext = path100.extname(resolvedPath).toLowerCase();
87996
+ const ext = path101.extname(resolvedPath).toLowerCase();
87608
87997
  if (!ALLOWED_EXTENSIONS.includes(ext)) {
87609
87998
  throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
87610
87999
  }
87611
- const stats = fs77.statSync(resolvedPath);
88000
+ const stats = fs79.statSync(resolvedPath);
87612
88001
  if (stats.size > MAX_SPEC_SIZE) {
87613
88002
  throw new Error(`Invalid spec_file: file exceeds ${MAX_SPEC_SIZE / 1024 / 1024}MB limit`);
87614
88003
  }
87615
- if (!fs77.existsSync(resolvedPath)) {
88004
+ if (!fs79.existsSync(resolvedPath)) {
87616
88005
  throw new Error(`Spec file not found: ${resolvedPath}`);
87617
88006
  }
87618
88007
  return resolvedPath;
87619
88008
  }
87620
88009
  for (const candidate of SPEC_CANDIDATES) {
87621
- const candidatePath = path100.resolve(cwd, candidate);
87622
- if (fs77.existsSync(candidatePath)) {
87623
- const stats = fs77.statSync(candidatePath);
88010
+ const candidatePath = path101.resolve(cwd, candidate);
88011
+ if (fs79.existsSync(candidatePath)) {
88012
+ const stats = fs79.statSync(candidatePath);
87624
88013
  if (stats.size <= MAX_SPEC_SIZE) {
87625
88014
  return candidatePath;
87626
88015
  }
@@ -87629,8 +88018,8 @@ function discoverSpecFile(cwd, specFileArg) {
87629
88018
  return null;
87630
88019
  }
87631
88020
  function parseSpec(specFile) {
87632
- const content = fs77.readFileSync(specFile, "utf-8");
87633
- const ext = path100.extname(specFile).toLowerCase();
88021
+ const content = fs79.readFileSync(specFile, "utf-8");
88022
+ const ext = path101.extname(specFile).toLowerCase();
87634
88023
  if (ext === ".json") {
87635
88024
  return parseJsonSpec(content);
87636
88025
  }
@@ -87701,12 +88090,12 @@ function extractRoutes(cwd) {
87701
88090
  function walkDir(dir) {
87702
88091
  let entries;
87703
88092
  try {
87704
- entries = fs77.readdirSync(dir, { withFileTypes: true });
88093
+ entries = fs79.readdirSync(dir, { withFileTypes: true });
87705
88094
  } catch {
87706
88095
  return;
87707
88096
  }
87708
88097
  for (const entry of entries) {
87709
- const fullPath = path100.join(dir, entry.name);
88098
+ const fullPath = path101.join(dir, entry.name);
87710
88099
  if (entry.isSymbolicLink()) {
87711
88100
  continue;
87712
88101
  }
@@ -87716,7 +88105,7 @@ function extractRoutes(cwd) {
87716
88105
  }
87717
88106
  walkDir(fullPath);
87718
88107
  } else if (entry.isFile()) {
87719
- const ext = path100.extname(entry.name).toLowerCase();
88108
+ const ext = path101.extname(entry.name).toLowerCase();
87720
88109
  const baseName = entry.name.toLowerCase();
87721
88110
  if (![".ts", ".js", ".mjs"].includes(ext)) {
87722
88111
  continue;
@@ -87734,7 +88123,7 @@ function extractRoutes(cwd) {
87734
88123
  }
87735
88124
  function extractRoutesFromFile(filePath) {
87736
88125
  const routes = [];
87737
- const content = fs77.readFileSync(filePath, "utf-8");
88126
+ const content = fs79.readFileSync(filePath, "utf-8");
87738
88127
  const lines = content.split(/\r?\n/);
87739
88128
  const expressRegex = /(?:app|router|server|express)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/g;
87740
88129
  const flaskRegex = /@(?:app|blueprint|bp)\.route\s*\(\s*['"]([^'"]+)['"]/g;
@@ -87883,8 +88272,8 @@ init_zod();
87883
88272
  init_bun_compat();
87884
88273
  init_path_security();
87885
88274
  init_create_tool();
87886
- import * as fs78 from "node:fs";
87887
- import * as path101 from "node:path";
88275
+ import * as fs80 from "node:fs";
88276
+ import * as path102 from "node:path";
87888
88277
  var DEFAULT_MAX_RESULTS = 100;
87889
88278
  var DEFAULT_MAX_LINES = 200;
87890
88279
  var REGEX_TIMEOUT_MS = 5000;
@@ -87920,11 +88309,11 @@ function containsWindowsAttacks3(str) {
87920
88309
  }
87921
88310
  function isPathInWorkspace3(filePath, workspace) {
87922
88311
  try {
87923
- const resolvedPath = path101.resolve(workspace, filePath);
87924
- const realWorkspace = fs78.realpathSync(workspace);
87925
- const realResolvedPath = fs78.realpathSync(resolvedPath);
87926
- const relativePath = path101.relative(realWorkspace, realResolvedPath);
87927
- 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)) {
87928
88317
  return false;
87929
88318
  }
87930
88319
  return true;
@@ -87937,12 +88326,12 @@ function validatePathForRead2(filePath, workspace) {
87937
88326
  }
87938
88327
  function findRgInEnvPath() {
87939
88328
  const searchPath = process.env.PATH ?? "";
87940
- for (const dir of searchPath.split(path101.delimiter)) {
88329
+ for (const dir of searchPath.split(path102.delimiter)) {
87941
88330
  if (!dir)
87942
88331
  continue;
87943
88332
  const isWindows = process.platform === "win32";
87944
- const candidate = path101.join(dir, isWindows ? "rg.exe" : "rg");
87945
- if (fs78.existsSync(candidate))
88333
+ const candidate = path102.join(dir, isWindows ? "rg.exe" : "rg");
88334
+ if (fs80.existsSync(candidate))
87946
88335
  return candidate;
87947
88336
  }
87948
88337
  return null;
@@ -87996,7 +88385,7 @@ async function ripgrepSearch(opts) {
87996
88385
  stderr: "pipe",
87997
88386
  cwd: opts.workspace
87998
88387
  });
87999
- const timeout = new Promise((resolve40) => setTimeout(() => resolve40("timeout"), REGEX_TIMEOUT_MS));
88388
+ const timeout = new Promise((resolve41) => setTimeout(() => resolve41("timeout"), REGEX_TIMEOUT_MS));
88000
88389
  const exitPromise = proc.exited;
88001
88390
  const result = await Promise.race([exitPromise, timeout]);
88002
88391
  if (result === "timeout") {
@@ -88069,10 +88458,10 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
88069
88458
  return files;
88070
88459
  }
88071
88460
  try {
88072
- const entries = fs78.readdirSync(dir, { withFileTypes: true });
88461
+ const entries = fs80.readdirSync(dir, { withFileTypes: true });
88073
88462
  for (const entry of entries) {
88074
- const fullPath = path101.join(dir, entry.name);
88075
- const relativePath = path101.relative(workspace, fullPath);
88463
+ const fullPath = path102.join(dir, entry.name);
88464
+ const relativePath = path102.relative(workspace, fullPath);
88076
88465
  if (!validatePathForRead2(fullPath, workspace)) {
88077
88466
  continue;
88078
88467
  }
@@ -88113,13 +88502,13 @@ async function fallbackSearch(opts) {
88113
88502
  const matches = [];
88114
88503
  let total = 0;
88115
88504
  for (const file3 of files) {
88116
- const fullPath = path101.join(opts.workspace, file3);
88505
+ const fullPath = path102.join(opts.workspace, file3);
88117
88506
  if (!validatePathForRead2(fullPath, opts.workspace)) {
88118
88507
  continue;
88119
88508
  }
88120
88509
  let stats;
88121
88510
  try {
88122
- stats = fs78.statSync(fullPath);
88511
+ stats = fs80.statSync(fullPath);
88123
88512
  if (stats.size > MAX_FILE_SIZE_BYTES10) {
88124
88513
  continue;
88125
88514
  }
@@ -88128,7 +88517,7 @@ async function fallbackSearch(opts) {
88128
88517
  }
88129
88518
  let content;
88130
88519
  try {
88131
- content = fs78.readFileSync(fullPath, "utf-8");
88520
+ content = fs80.readFileSync(fullPath, "utf-8");
88132
88521
  } catch {
88133
88522
  continue;
88134
88523
  }
@@ -88240,7 +88629,7 @@ var search = createSwarmTool({
88240
88629
  message: "Exclude pattern contains invalid Windows-specific sequence"
88241
88630
  }, null, 2);
88242
88631
  }
88243
- if (!fs78.existsSync(directory)) {
88632
+ if (!fs80.existsSync(directory)) {
88244
88633
  return JSON.stringify({
88245
88634
  error: true,
88246
88635
  type: "unknown",
@@ -88493,8 +88882,8 @@ var submit_phase_council_verdicts = createSwarmTool({
88493
88882
  init_zod();
88494
88883
  init_path_security();
88495
88884
  init_create_tool();
88496
- import * as fs79 from "node:fs";
88497
- import * as path102 from "node:path";
88885
+ import * as fs81 from "node:fs";
88886
+ import * as path103 from "node:path";
88498
88887
  var WINDOWS_RESERVED_NAMES4 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
88499
88888
  function containsWindowsAttacks4(str) {
88500
88889
  if (/:[^\\/]/.test(str))
@@ -88508,14 +88897,14 @@ function containsWindowsAttacks4(str) {
88508
88897
  }
88509
88898
  function isPathInWorkspace4(filePath, workspace) {
88510
88899
  try {
88511
- const resolvedPath = path102.resolve(workspace, filePath);
88512
- if (!fs79.existsSync(resolvedPath)) {
88900
+ const resolvedPath = path103.resolve(workspace, filePath);
88901
+ if (!fs81.existsSync(resolvedPath)) {
88513
88902
  return true;
88514
88903
  }
88515
- const realWorkspace = fs79.realpathSync(workspace);
88516
- const realResolvedPath = fs79.realpathSync(resolvedPath);
88517
- const relativePath = path102.relative(realWorkspace, realResolvedPath);
88518
- 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)) {
88519
88908
  return false;
88520
88909
  }
88521
88910
  return true;
@@ -88687,7 +89076,7 @@ var suggestPatch = createSwarmTool({
88687
89076
  message: "changes cannot be empty"
88688
89077
  }, null, 2);
88689
89078
  }
88690
- if (!fs79.existsSync(directory)) {
89079
+ if (!fs81.existsSync(directory)) {
88691
89080
  return JSON.stringify({
88692
89081
  success: false,
88693
89082
  error: true,
@@ -88723,8 +89112,8 @@ var suggestPatch = createSwarmTool({
88723
89112
  });
88724
89113
  continue;
88725
89114
  }
88726
- const fullPath = path102.resolve(directory, change.file);
88727
- if (!fs79.existsSync(fullPath)) {
89115
+ const fullPath = path103.resolve(directory, change.file);
89116
+ if (!fs81.existsSync(fullPath)) {
88728
89117
  errors5.push({
88729
89118
  success: false,
88730
89119
  error: true,
@@ -88738,7 +89127,7 @@ var suggestPatch = createSwarmTool({
88738
89127
  }
88739
89128
  let content;
88740
89129
  try {
88741
- content = fs79.readFileSync(fullPath, "utf-8");
89130
+ content = fs81.readFileSync(fullPath, "utf-8");
88742
89131
  } catch (err3) {
88743
89132
  errors5.push({
88744
89133
  success: false,
@@ -88985,8 +89374,8 @@ var generate_mutants = createSwarmTool({
88985
89374
  // src/tools/lint-spec.ts
88986
89375
  init_spec_schema();
88987
89376
  init_create_tool();
88988
- import * as fs80 from "node:fs";
88989
- import * as path103 from "node:path";
89377
+ import * as fs82 from "node:fs";
89378
+ import * as path104 from "node:path";
88990
89379
  var SPEC_FILE_NAME = "spec.md";
88991
89380
  var SWARM_DIR2 = ".swarm";
88992
89381
  var OBLIGATION_KEYWORDS2 = ["MUST", "SHALL", "SHOULD", "MAY"];
@@ -89039,8 +89428,8 @@ var lint_spec = createSwarmTool({
89039
89428
  async execute(_args, directory) {
89040
89429
  const errors5 = [];
89041
89430
  const warnings = [];
89042
- const specPath = path103.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
89043
- if (!fs80.existsSync(specPath)) {
89431
+ const specPath = path104.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
89432
+ if (!fs82.existsSync(specPath)) {
89044
89433
  const result2 = {
89045
89434
  valid: false,
89046
89435
  specMtime: null,
@@ -89059,12 +89448,12 @@ var lint_spec = createSwarmTool({
89059
89448
  }
89060
89449
  let specMtime = null;
89061
89450
  try {
89062
- const stats = fs80.statSync(specPath);
89451
+ const stats = fs82.statSync(specPath);
89063
89452
  specMtime = stats.mtime.toISOString();
89064
89453
  } catch {}
89065
89454
  let content;
89066
89455
  try {
89067
- content = fs80.readFileSync(specPath, "utf-8");
89456
+ content = fs82.readFileSync(specPath, "utf-8");
89068
89457
  } catch (e) {
89069
89458
  const result2 = {
89070
89459
  valid: false,
@@ -89109,13 +89498,13 @@ var lint_spec = createSwarmTool({
89109
89498
  });
89110
89499
  // src/tools/mutation-test.ts
89111
89500
  init_zod();
89112
- import * as fs81 from "node:fs";
89113
- import * as path105 from "node:path";
89501
+ import * as fs83 from "node:fs";
89502
+ import * as path106 from "node:path";
89114
89503
 
89115
89504
  // src/mutation/engine.ts
89116
89505
  import { spawnSync as spawnSync3 } from "node:child_process";
89117
89506
  import { unlinkSync as unlinkSync13, writeFileSync as writeFileSync20 } from "node:fs";
89118
- import * as path104 from "node:path";
89507
+ import * as path105 from "node:path";
89119
89508
 
89120
89509
  // src/mutation/equivalence.ts
89121
89510
  function isStaticallyEquivalent(originalCode, mutatedCode) {
@@ -89187,6 +89576,11 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
89187
89576
  const strippedMutated = stripCode(mutatedCode);
89188
89577
  return strippedOriginal === strippedMutated;
89189
89578
  }
89579
+ var _internals32 = {
89580
+ isStaticallyEquivalent,
89581
+ checkEquivalence,
89582
+ batchCheckEquivalence
89583
+ };
89190
89584
  async function checkEquivalence(patch, originalCode, mutatedCode, llmJudge) {
89191
89585
  if (isStaticallyEquivalent(originalCode, mutatedCode)) {
89192
89586
  return {
@@ -89222,7 +89616,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
89222
89616
  const results = [];
89223
89617
  for (const { patch, originalCode, mutatedCode } of patches) {
89224
89618
  try {
89225
- const result = await checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
89619
+ const result = await _internals32.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
89226
89620
  results.push(result);
89227
89621
  } catch (err3) {
89228
89622
  results.push({
@@ -89250,7 +89644,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
89250
89644
  let patchFile;
89251
89645
  try {
89252
89646
  const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
89253
- patchFile = path104.join(workingDir, `.mutation_patch_${safeId2}.diff`);
89647
+ patchFile = path105.join(workingDir, `.mutation_patch_${safeId2}.diff`);
89254
89648
  try {
89255
89649
  writeFileSync20(patchFile, patch.patch);
89256
89650
  } catch (writeErr) {
@@ -89522,6 +89916,11 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
89522
89916
  }
89523
89917
 
89524
89918
  // src/mutation/gate.ts
89919
+ var _internals33 = {
89920
+ evaluateMutationGate,
89921
+ buildTestImprovementPrompt,
89922
+ buildMessage
89923
+ };
89525
89924
  var PASS_THRESHOLD = 0.8;
89526
89925
  var WARN_THRESHOLD = 0.6;
89527
89926
  function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThreshold = WARN_THRESHOLD) {
@@ -89538,8 +89937,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
89538
89937
  } else {
89539
89938
  verdict = "fail";
89540
89939
  }
89541
- const testImprovementPrompt = buildTestImprovementPrompt(report, passThreshold, verdict);
89542
- 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);
89543
89942
  return {
89544
89943
  verdict,
89545
89944
  killRate: report.killRate,
@@ -89644,8 +90043,8 @@ var mutation_test = createSwarmTool({
89644
90043
  ];
89645
90044
  for (const filePath of uniquePaths) {
89646
90045
  try {
89647
- const resolvedPath = path105.resolve(cwd, filePath);
89648
- sourceFiles.set(filePath, fs81.readFileSync(resolvedPath, "utf-8"));
90046
+ const resolvedPath = path106.resolve(cwd, filePath);
90047
+ sourceFiles.set(filePath, fs83.readFileSync(resolvedPath, "utf-8"));
89649
90048
  } catch {}
89650
90049
  }
89651
90050
  const report = await executeMutationSuite(typedArgs.patches, typedArgs.test_command, typedArgs.files, cwd, undefined, undefined, sourceFiles.size > 0 ? sourceFiles : undefined);
@@ -89663,8 +90062,8 @@ var mutation_test = createSwarmTool({
89663
90062
  init_zod();
89664
90063
  init_manager2();
89665
90064
  init_detector();
89666
- import * as fs82 from "node:fs";
89667
- import * as path106 from "node:path";
90065
+ import * as fs84 from "node:fs";
90066
+ import * as path107 from "node:path";
89668
90067
  init_create_tool();
89669
90068
  var MAX_FILE_SIZE2 = 2 * 1024 * 1024;
89670
90069
  var BINARY_CHECK_BYTES = 8192;
@@ -89730,7 +90129,7 @@ async function syntaxCheck(input, directory, config3) {
89730
90129
  if (languages?.length) {
89731
90130
  const lowerLangs = languages.map((l) => l.toLowerCase());
89732
90131
  filesToCheck = filesToCheck.filter((file3) => {
89733
- const ext = path106.extname(file3.path).toLowerCase();
90132
+ const ext = path107.extname(file3.path).toLowerCase();
89734
90133
  const langDef = getLanguageForExtension(ext);
89735
90134
  const fileProfile = getProfileForFile(file3.path);
89736
90135
  const langId = fileProfile?.id || langDef?.id;
@@ -89743,7 +90142,7 @@ async function syntaxCheck(input, directory, config3) {
89743
90142
  let skippedCount = 0;
89744
90143
  for (const fileInfo of filesToCheck) {
89745
90144
  const { path: filePath } = fileInfo;
89746
- const fullPath = path106.isAbsolute(filePath) ? filePath : path106.join(directory, filePath);
90145
+ const fullPath = path107.isAbsolute(filePath) ? filePath : path107.join(directory, filePath);
89747
90146
  const result = {
89748
90147
  path: filePath,
89749
90148
  language: "",
@@ -89773,7 +90172,7 @@ async function syntaxCheck(input, directory, config3) {
89773
90172
  }
89774
90173
  let content;
89775
90174
  try {
89776
- content = fs82.readFileSync(fullPath, "utf8");
90175
+ content = fs84.readFileSync(fullPath, "utf8");
89777
90176
  } catch {
89778
90177
  result.skipped_reason = "file_read_error";
89779
90178
  skippedCount++;
@@ -89792,7 +90191,7 @@ async function syntaxCheck(input, directory, config3) {
89792
90191
  results.push(result);
89793
90192
  continue;
89794
90193
  }
89795
- const ext = path106.extname(filePath).toLowerCase();
90194
+ const ext = path107.extname(filePath).toLowerCase();
89796
90195
  const langDef = getLanguageForExtension(ext);
89797
90196
  result.language = profile?.id || langDef?.id || "unknown";
89798
90197
  const errors5 = extractSyntaxErrors(parser, content);
@@ -89884,8 +90283,8 @@ init_zod();
89884
90283
  init_utils();
89885
90284
  init_create_tool();
89886
90285
  init_path_security();
89887
- import * as fs83 from "node:fs";
89888
- import * as path107 from "node:path";
90286
+ import * as fs85 from "node:fs";
90287
+ import * as path108 from "node:path";
89889
90288
  var MAX_TEXT_LENGTH = 200;
89890
90289
  var MAX_FILE_SIZE_BYTES11 = 1024 * 1024;
89891
90290
  var SUPPORTED_EXTENSIONS4 = new Set([
@@ -89951,9 +90350,9 @@ function validatePathsInput(paths, cwd) {
89951
90350
  return { error: "paths contains path traversal", resolvedPath: null };
89952
90351
  }
89953
90352
  try {
89954
- const resolvedPath = path107.resolve(paths);
89955
- const normalizedCwd = path107.resolve(cwd);
89956
- const normalizedResolved = path107.resolve(resolvedPath);
90353
+ const resolvedPath = path108.resolve(paths);
90354
+ const normalizedCwd = path108.resolve(cwd);
90355
+ const normalizedResolved = path108.resolve(resolvedPath);
89957
90356
  if (!normalizedResolved.startsWith(normalizedCwd)) {
89958
90357
  return {
89959
90358
  error: "paths must be within the current working directory",
@@ -89969,13 +90368,13 @@ function validatePathsInput(paths, cwd) {
89969
90368
  }
89970
90369
  }
89971
90370
  function isSupportedExtension(filePath) {
89972
- const ext = path107.extname(filePath).toLowerCase();
90371
+ const ext = path108.extname(filePath).toLowerCase();
89973
90372
  return SUPPORTED_EXTENSIONS4.has(ext);
89974
90373
  }
89975
90374
  function findSourceFiles3(dir, files = []) {
89976
90375
  let entries;
89977
90376
  try {
89978
- entries = fs83.readdirSync(dir);
90377
+ entries = fs85.readdirSync(dir);
89979
90378
  } catch {
89980
90379
  return files;
89981
90380
  }
@@ -89984,10 +90383,10 @@ function findSourceFiles3(dir, files = []) {
89984
90383
  if (SKIP_DIRECTORIES5.has(entry)) {
89985
90384
  continue;
89986
90385
  }
89987
- const fullPath = path107.join(dir, entry);
90386
+ const fullPath = path108.join(dir, entry);
89988
90387
  let stat7;
89989
90388
  try {
89990
- stat7 = fs83.statSync(fullPath);
90389
+ stat7 = fs85.statSync(fullPath);
89991
90390
  } catch {
89992
90391
  continue;
89993
90392
  }
@@ -90080,7 +90479,7 @@ var todo_extract = createSwarmTool({
90080
90479
  return JSON.stringify(errorResult, null, 2);
90081
90480
  }
90082
90481
  const scanPath = resolvedPath;
90083
- if (!fs83.existsSync(scanPath)) {
90482
+ if (!fs85.existsSync(scanPath)) {
90084
90483
  const errorResult = {
90085
90484
  error: `path not found: ${pathsInput}`,
90086
90485
  total: 0,
@@ -90090,13 +90489,13 @@ var todo_extract = createSwarmTool({
90090
90489
  return JSON.stringify(errorResult, null, 2);
90091
90490
  }
90092
90491
  const filesToScan = [];
90093
- const stat7 = fs83.statSync(scanPath);
90492
+ const stat7 = fs85.statSync(scanPath);
90094
90493
  if (stat7.isFile()) {
90095
90494
  if (isSupportedExtension(scanPath)) {
90096
90495
  filesToScan.push(scanPath);
90097
90496
  } else {
90098
90497
  const errorResult = {
90099
- error: `unsupported file extension: ${path107.extname(scanPath)}`,
90498
+ error: `unsupported file extension: ${path108.extname(scanPath)}`,
90100
90499
  total: 0,
90101
90500
  byPriority: { high: 0, medium: 0, low: 0 },
90102
90501
  entries: []
@@ -90109,11 +90508,11 @@ var todo_extract = createSwarmTool({
90109
90508
  const allEntries = [];
90110
90509
  for (const filePath of filesToScan) {
90111
90510
  try {
90112
- const fileStat = fs83.statSync(filePath);
90511
+ const fileStat = fs85.statSync(filePath);
90113
90512
  if (fileStat.size > MAX_FILE_SIZE_BYTES11) {
90114
90513
  continue;
90115
90514
  }
90116
- const content = fs83.readFileSync(filePath, "utf-8");
90515
+ const content = fs85.readFileSync(filePath, "utf-8");
90117
90516
  const entries = parseTodoComments(content, filePath, tagsSet);
90118
90517
  allEntries.push(...entries);
90119
90518
  } catch {}
@@ -90144,19 +90543,19 @@ init_loader();
90144
90543
  init_schema();
90145
90544
  init_qa_gate_profile();
90146
90545
  init_gate_evidence();
90147
- import * as fs86 from "node:fs";
90148
- import * as path110 from "node:path";
90546
+ import * as fs88 from "node:fs";
90547
+ import * as path111 from "node:path";
90149
90548
 
90150
90549
  // src/hooks/diff-scope.ts
90151
90550
  init_bun_compat();
90152
- import * as fs85 from "node:fs";
90153
- import * as path109 from "node:path";
90551
+ import * as fs87 from "node:fs";
90552
+ import * as path110 from "node:path";
90154
90553
 
90155
90554
  // src/utils/gitignore-warning.ts
90156
90555
  init_bun_compat();
90157
- import * as fs84 from "node:fs";
90158
- import * as path108 from "node:path";
90159
- var _internals = { bunSpawn };
90556
+ import * as fs86 from "node:fs";
90557
+ import * as path109 from "node:path";
90558
+ var _internals34 = { bunSpawn };
90160
90559
  var _swarmGitExcludedChecked = false;
90161
90560
  function fileCoversSwarm(content) {
90162
90561
  for (const rawLine of content.split(`
@@ -90189,7 +90588,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90189
90588
  checkIgnoreExitCode
90190
90589
  ] = await Promise.all([
90191
90590
  (async () => {
90192
- 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);
90193
90592
  try {
90194
90593
  return await Promise.all([proc.exited, proc.stdout.text()]);
90195
90594
  } finally {
@@ -90199,7 +90598,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90199
90598
  }
90200
90599
  })(),
90201
90600
  (async () => {
90202
- 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);
90203
90602
  try {
90204
90603
  return await Promise.all([proc.exited, proc.stdout.text()]);
90205
90604
  } finally {
@@ -90209,7 +90608,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90209
90608
  }
90210
90609
  })(),
90211
90610
  (async () => {
90212
- 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);
90213
90612
  try {
90214
90613
  return await proc.exited;
90215
90614
  } finally {
@@ -90229,16 +90628,16 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90229
90628
  const excludeRelPath = excludePathRaw.trim();
90230
90629
  if (!excludeRelPath)
90231
90630
  return;
90232
- const excludePath = path108.isAbsolute(excludeRelPath) ? excludeRelPath : path108.join(directory, excludeRelPath);
90631
+ const excludePath = path109.isAbsolute(excludeRelPath) ? excludeRelPath : path109.join(directory, excludeRelPath);
90233
90632
  if (checkIgnoreExitCode !== 0) {
90234
90633
  try {
90235
- fs84.mkdirSync(path108.dirname(excludePath), { recursive: true });
90634
+ fs86.mkdirSync(path109.dirname(excludePath), { recursive: true });
90236
90635
  let existing = "";
90237
90636
  try {
90238
- existing = fs84.readFileSync(excludePath, "utf8");
90637
+ existing = fs86.readFileSync(excludePath, "utf8");
90239
90638
  } catch {}
90240
90639
  if (!fileCoversSwarm(existing)) {
90241
- fs84.appendFileSync(excludePath, `
90640
+ fs86.appendFileSync(excludePath, `
90242
90641
  # opencode-swarm local runtime state
90243
90642
  .swarm/
90244
90643
  `, "utf8");
@@ -90248,7 +90647,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90248
90647
  }
90249
90648
  } catch {}
90250
90649
  }
90251
- 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);
90252
90651
  let trackedExitCode;
90253
90652
  let trackedOutput;
90254
90653
  try {
@@ -90273,13 +90672,13 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
90273
90672
  }
90274
90673
 
90275
90674
  // src/hooks/diff-scope.ts
90276
- var _internals2 = { bunSpawn };
90675
+ var _internals35 = { bunSpawn };
90277
90676
  function getDeclaredScope(taskId, directory) {
90278
90677
  try {
90279
- const planPath = path109.join(directory, ".swarm", "plan.json");
90280
- if (!fs85.existsSync(planPath))
90678
+ const planPath = path110.join(directory, ".swarm", "plan.json");
90679
+ if (!fs87.existsSync(planPath))
90281
90680
  return null;
90282
- const raw = fs85.readFileSync(planPath, "utf-8");
90681
+ const raw = fs87.readFileSync(planPath, "utf-8");
90283
90682
  const plan = JSON.parse(raw);
90284
90683
  for (const phase of plan.phases ?? []) {
90285
90684
  for (const task of phase.tasks ?? []) {
@@ -90308,7 +90707,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
90308
90707
  };
90309
90708
  async function getChangedFiles(directory) {
90310
90709
  try {
90311
- const proc = _internals2.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
90710
+ const proc = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
90312
90711
  cwd: directory,
90313
90712
  ...GIT_DIFF_SPAWN_OPTIONS
90314
90713
  });
@@ -90325,7 +90724,7 @@ async function getChangedFiles(directory) {
90325
90724
  return stdout.trim().split(`
90326
90725
  `).map((f) => f.trim()).filter((f) => f.length > 0);
90327
90726
  }
90328
- const proc2 = _internals2.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
90727
+ const proc2 = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
90329
90728
  cwd: directory,
90330
90729
  ...GIT_DIFF_SPAWN_OPTIONS
90331
90730
  });
@@ -90413,7 +90812,7 @@ var TIER_3_PATTERNS = [
90413
90812
  ];
90414
90813
  function matchesTier3Pattern(files) {
90415
90814
  for (const file3 of files) {
90416
- const fileName = path110.basename(file3);
90815
+ const fileName = path111.basename(file3);
90417
90816
  for (const pattern of TIER_3_PATTERNS) {
90418
90817
  if (pattern.test(fileName)) {
90419
90818
  return true;
@@ -90427,8 +90826,8 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
90427
90826
  if (hasActiveTurboMode()) {
90428
90827
  const resolvedDir2 = workingDirectory;
90429
90828
  try {
90430
- const planPath = path110.join(resolvedDir2, ".swarm", "plan.json");
90431
- const planRaw = fs86.readFileSync(planPath, "utf-8");
90829
+ const planPath = path111.join(resolvedDir2, ".swarm", "plan.json");
90830
+ const planRaw = fs88.readFileSync(planPath, "utf-8");
90432
90831
  const plan = JSON.parse(planRaw);
90433
90832
  for (const planPhase of plan.phases ?? []) {
90434
90833
  for (const task of planPhase.tasks ?? []) {
@@ -90497,8 +90896,8 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
90497
90896
  }
90498
90897
  try {
90499
90898
  const resolvedDir2 = workingDirectory;
90500
- const planPath = path110.join(resolvedDir2, ".swarm", "plan.json");
90501
- const planRaw = fs86.readFileSync(planPath, "utf-8");
90899
+ const planPath = path111.join(resolvedDir2, ".swarm", "plan.json");
90900
+ const planRaw = fs88.readFileSync(planPath, "utf-8");
90502
90901
  const plan = JSON.parse(planRaw);
90503
90902
  for (const planPhase of plan.phases ?? []) {
90504
90903
  for (const task of planPhase.tasks ?? []) {
@@ -90687,8 +91086,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90687
91086
  };
90688
91087
  }
90689
91088
  }
90690
- normalizedDir = path110.normalize(args2.working_directory);
90691
- const pathParts = normalizedDir.split(path110.sep);
91089
+ normalizedDir = path111.normalize(args2.working_directory);
91090
+ const pathParts = normalizedDir.split(path111.sep);
90692
91091
  if (pathParts.includes("..")) {
90693
91092
  return {
90694
91093
  success: false,
@@ -90698,11 +91097,11 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90698
91097
  ]
90699
91098
  };
90700
91099
  }
90701
- const resolvedDir = path110.resolve(normalizedDir);
91100
+ const resolvedDir = path111.resolve(normalizedDir);
90702
91101
  try {
90703
- const realPath = fs86.realpathSync(resolvedDir);
90704
- const planPath = path110.join(realPath, ".swarm", "plan.json");
90705
- if (!fs86.existsSync(planPath)) {
91102
+ const realPath = fs88.realpathSync(resolvedDir);
91103
+ const planPath = path111.join(realPath, ".swarm", "plan.json");
91104
+ if (!fs88.existsSync(planPath)) {
90706
91105
  return {
90707
91106
  success: false,
90708
91107
  message: `Invalid working_directory: plan not found in "${realPath}"`,
@@ -90733,22 +91132,22 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90733
91132
  }
90734
91133
  if (args2.status === "in_progress") {
90735
91134
  try {
90736
- const evidencePath = path110.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
90737
- fs86.mkdirSync(path110.dirname(evidencePath), { recursive: true });
90738
- 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");
90739
91138
  let writeOk = false;
90740
91139
  try {
90741
- fs86.writeSync(fd, JSON.stringify({
91140
+ fs88.writeSync(fd, JSON.stringify({
90742
91141
  taskId: args2.task_id,
90743
91142
  required_gates: ["reviewer", "test_engineer"],
90744
91143
  gates: {}
90745
91144
  }, null, 2));
90746
91145
  writeOk = true;
90747
91146
  } finally {
90748
- fs86.closeSync(fd);
91147
+ fs88.closeSync(fd);
90749
91148
  if (!writeOk) {
90750
91149
  try {
90751
- fs86.unlinkSync(evidencePath);
91150
+ fs88.unlinkSync(evidencePath);
90752
91151
  } catch {}
90753
91152
  }
90754
91153
  }
@@ -90758,8 +91157,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
90758
91157
  recoverTaskStateFromDelegations(args2.task_id);
90759
91158
  let phaseRequiresReviewer = true;
90760
91159
  try {
90761
- const planPath = path110.join(directory, ".swarm", "plan.json");
90762
- const planRaw = fs86.readFileSync(planPath, "utf-8");
91160
+ const planPath = path111.join(directory, ".swarm", "plan.json");
91161
+ const planRaw = fs88.readFileSync(planPath, "utf-8");
90763
91162
  const plan = JSON.parse(planRaw);
90764
91163
  const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
90765
91164
  if (taskPhase?.required_agents && !taskPhase.required_agents.includes("reviewer")) {
@@ -91069,8 +91468,8 @@ init_utils2();
91069
91468
  init_ledger();
91070
91469
  init_manager();
91071
91470
  init_create_tool();
91072
- import fs87 from "node:fs";
91073
- import path111 from "node:path";
91471
+ import fs89 from "node:fs";
91472
+ import path112 from "node:path";
91074
91473
  function derivePlanId5(plan) {
91075
91474
  return `${plan.swarm}-${plan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
91076
91475
  }
@@ -91121,7 +91520,7 @@ async function executeWriteDriftEvidence(args2, directory) {
91121
91520
  entries: [evidenceEntry]
91122
91521
  };
91123
91522
  const filename = "drift-verifier.json";
91124
- const relativePath = path111.join("evidence", String(phase), filename);
91523
+ const relativePath = path112.join("evidence", String(phase), filename);
91125
91524
  let validatedPath;
91126
91525
  try {
91127
91526
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -91132,12 +91531,12 @@ async function executeWriteDriftEvidence(args2, directory) {
91132
91531
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
91133
91532
  }, null, 2);
91134
91533
  }
91135
- const evidenceDir = path111.dirname(validatedPath);
91534
+ const evidenceDir = path112.dirname(validatedPath);
91136
91535
  try {
91137
- await fs87.promises.mkdir(evidenceDir, { recursive: true });
91138
- const tempPath = path111.join(evidenceDir, `.${filename}.tmp`);
91139
- await fs87.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91140
- 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);
91141
91540
  let snapshotInfo;
91142
91541
  let snapshotError;
91143
91542
  let qaProfileLocked;
@@ -91231,8 +91630,8 @@ var write_drift_evidence = createSwarmTool({
91231
91630
  init_zod();
91232
91631
  init_utils2();
91233
91632
  init_create_tool();
91234
- import fs88 from "node:fs";
91235
- import path112 from "node:path";
91633
+ import fs90 from "node:fs";
91634
+ import path113 from "node:path";
91236
91635
  function normalizeVerdict2(verdict) {
91237
91636
  switch (verdict) {
91238
91637
  case "APPROVED":
@@ -91280,7 +91679,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
91280
91679
  entries: [evidenceEntry]
91281
91680
  };
91282
91681
  const filename = "hallucination-guard.json";
91283
- const relativePath = path112.join("evidence", String(phase), filename);
91682
+ const relativePath = path113.join("evidence", String(phase), filename);
91284
91683
  let validatedPath;
91285
91684
  try {
91286
91685
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -91291,12 +91690,12 @@ async function executeWriteHallucinationEvidence(args2, directory) {
91291
91690
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
91292
91691
  }, null, 2);
91293
91692
  }
91294
- const evidenceDir = path112.dirname(validatedPath);
91693
+ const evidenceDir = path113.dirname(validatedPath);
91295
91694
  try {
91296
- await fs88.promises.mkdir(evidenceDir, { recursive: true });
91297
- const tempPath = path112.join(evidenceDir, `.${filename}.tmp`);
91298
- await fs88.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91299
- 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);
91300
91699
  return JSON.stringify({
91301
91700
  success: true,
91302
91701
  phase,
@@ -91342,8 +91741,8 @@ var write_hallucination_evidence = createSwarmTool({
91342
91741
  init_zod();
91343
91742
  init_utils2();
91344
91743
  init_create_tool();
91345
- import fs89 from "node:fs";
91346
- import path113 from "node:path";
91744
+ import fs91 from "node:fs";
91745
+ import path114 from "node:path";
91347
91746
  function normalizeVerdict3(verdict) {
91348
91747
  switch (verdict) {
91349
91748
  case "PASS":
@@ -91417,7 +91816,7 @@ async function executeWriteMutationEvidence(args2, directory) {
91417
91816
  entries: [evidenceEntry]
91418
91817
  };
91419
91818
  const filename = "mutation-gate.json";
91420
- const relativePath = path113.join("evidence", String(phase), filename);
91819
+ const relativePath = path114.join("evidence", String(phase), filename);
91421
91820
  let validatedPath;
91422
91821
  try {
91423
91822
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -91428,12 +91827,12 @@ async function executeWriteMutationEvidence(args2, directory) {
91428
91827
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
91429
91828
  }, null, 2);
91430
91829
  }
91431
- const evidenceDir = path113.dirname(validatedPath);
91830
+ const evidenceDir = path114.dirname(validatedPath);
91432
91831
  try {
91433
- await fs89.promises.mkdir(evidenceDir, { recursive: true });
91434
- const tempPath = path113.join(evidenceDir, `.${filename}.tmp`);
91435
- await fs89.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
91436
- 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);
91437
91836
  return JSON.stringify({
91438
91837
  success: true,
91439
91838
  phase,
@@ -91725,7 +92124,7 @@ async function initializeOpenCodeSwarm(ctx) {
91725
92124
  const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
91726
92125
  preflightTriggerManager = new PTM(automationConfig);
91727
92126
  const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
91728
- const swarmDir = path114.resolve(ctx.directory, ".swarm");
92127
+ const swarmDir = path115.resolve(ctx.directory, ".swarm");
91729
92128
  statusArtifact = new ASA(swarmDir);
91730
92129
  statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
91731
92130
  if (automationConfig.capabilities?.evidence_auto_summaries === true) {
@@ -91831,6 +92230,7 @@ async function initializeOpenCodeSwarm(ctx) {
91831
92230
  completion_verify,
91832
92231
  complexity_hotspots,
91833
92232
  submit_council_verdicts,
92233
+ submit_phase_council_verdicts,
91834
92234
  convene_general_council,
91835
92235
  curator_analyze,
91836
92236
  declare_council_criteria,