opencode-swarm 7.96.0 → 7.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.opencode/skills/codebase-review-swarm/references/review-protocol-v8.2.md +1 -1
  2. package/.opencode/skills/deep-dive/SKILL.md +3 -1
  3. package/.opencode/skills/deep-research/SKILL.md +8 -8
  4. package/.opencode/skills/pre-phase-briefing/SKILL.md +21 -5
  5. package/.opencode/skills/swarm-pr-feedback/SKILL.md +19 -7
  6. package/.opencode/skills/swarm-pr-review/SKILL.md +2 -0
  7. package/README.md +7 -1
  8. package/dist/agents/architect.d.ts +1 -1
  9. package/dist/cli/{config-doctor-h1xrvq83.js → config-doctor-7yrxfa6b.js} +2 -2
  10. package/dist/cli/{guardrail-explain-0hw3kyab.js → guardrail-explain-xdv74tfk.js} +5 -5
  11. package/dist/cli/{guardrail-log-9yyeccv5.js → guardrail-log-53z1cf46.js} +3 -3
  12. package/dist/cli/{index-tqbb2jx6.js → index-471qxz9g.js} +33 -9
  13. package/dist/cli/{index-b223mczb.js → index-5z2e78tv.js} +1 -1
  14. package/dist/cli/{index-rdc6nvmw.js → index-gnd1280x.js} +1 -1
  15. package/dist/cli/{index-r0zbs7ny.js → index-h6h8qfsh.js} +6 -6
  16. package/dist/cli/{index-q0t7gpf2.js → index-pc10e4d7.js} +9 -9
  17. package/dist/cli/{index-d3ds25vx.js → index-wmm21nsk.js} +2 -2
  18. package/dist/cli/{index-xx3sv77e.js → index-zy22fg5h.js} +1 -1
  19. package/dist/cli/index.js +4 -4
  20. package/dist/cli/{schema-a8fneygm.js → schema-mygkbbe9.js} +5 -1
  21. package/dist/config/constants.d.ts +4 -0
  22. package/dist/config/schema.d.ts +11 -0
  23. package/dist/evidence/normalize-verdict.d.ts +67 -0
  24. package/dist/hooks/knowledge-injector.d.ts +1 -1
  25. package/dist/index.js +576 -285
  26. package/dist/services/injection-budget.d.ts +98 -0
  27. package/dist/summaries/summarizer.d.ts +36 -0
  28. package/dist/tools/context-status.d.ts +102 -0
  29. package/dist/tools/index.d.ts +1 -0
  30. package/dist/tools/manifest.d.ts +1 -0
  31. package/dist/tools/tool-metadata.d.ts +11 -7
  32. package/dist/tools/write-drift-evidence.d.ts +11 -0
  33. package/dist/tools/write-hallucination-evidence.d.ts +11 -0
  34. package/dist/tools/write-mutation-evidence.d.ts +11 -0
  35. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ var package_default;
69
69
  var init_package = __esm(() => {
70
70
  package_default = {
71
71
  name: "opencode-swarm",
72
- version: "7.96.0",
72
+ version: "7.98.0",
73
73
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
74
74
  main: "dist/index.js",
75
75
  types: "dist/index.d.ts",
@@ -542,6 +542,10 @@ var init_tool_metadata = __esm(() => {
542
542
  description: "detect hidden couplings by analyzing git history",
543
543
  agents: ["architect"]
544
544
  },
545
+ context_status: {
546
+ description: "report current context-window headroom for the active session — returns tokens-used, model-limit, usage-percent, threshold-state (none/warn/critical), model name, and provider. Pure read-only: no state mutation, no warning injection. Works whether context_budget.enabled is true or false.",
547
+ agents: ["architect"]
548
+ },
545
549
  search: {
546
550
  description: "Workspace-scoped ripgrep-style text search with structured JSON output. Supports literal and regex modes, glob filtering, and result limits. NOTE: This is text search, not structural AST search — use symbols and imports tools for structural queries.",
547
551
  agents: [
@@ -658,19 +662,19 @@ var init_tool_metadata = __esm(() => {
658
662
  },
659
663
  skill_generate: {
660
664
  description: "compile knowledge entries into a structured SKILL.md draft",
661
- agents: ["architect", "skill_improver"]
665
+ agents: ["skill_improver"]
662
666
  },
663
667
  skill_list: {
664
668
  description: "list generated skill files and their status",
665
- agents: ["architect", "skill_improver"]
669
+ agents: ["skill_improver"]
666
670
  },
667
671
  skill_apply: {
668
672
  description: "activate a draft skill proposal",
669
- agents: ["architect"]
673
+ agents: []
670
674
  },
671
675
  skill_inspect: {
672
676
  description: "inspect the content and source entries of a skill file",
673
- agents: ["architect", "skill_improver"]
677
+ agents: ["skill_improver"]
674
678
  },
675
679
  run_stale_reconciliation: {
676
680
  description: "reconcile skills against the knowledge store: mark skills stale when source knowledge is archived or deleted, or clear stale markers",
@@ -678,15 +682,15 @@ var init_tool_metadata = __esm(() => {
678
682
  },
679
683
  skill_regenerate: {
680
684
  description: "regenerate an active skill by re-clustering its source knowledge entries and updating the SKILL.md in place",
681
- agents: ["architect"]
685
+ agents: []
682
686
  },
683
687
  skill_retire: {
684
688
  description: "retire a generated skill by adding a retired.marker file; retired skills are excluded from scoring and injection",
685
- agents: ["architect"]
689
+ agents: []
686
690
  },
687
691
  skill_improve: {
688
692
  description: "run the skill_improver agent to review and refine skills",
689
- agents: ["architect", "skill_improver"]
693
+ agents: ["skill_improver"]
690
694
  },
691
695
  spec_write: {
692
696
  description: "author or update .swarm/spec.md for the current project",
@@ -910,7 +914,7 @@ function isLowCapabilityModel(modelId) {
910
914
  const lower = (modelId || "").toLowerCase();
911
915
  return LOW_CAPABILITY_MODELS.some((substr) => lower.includes(substr));
912
916
  }
913
- var OPENCODE_NATIVE_AGENTS, CLAUDE_CODE_NATIVE_COMMANDS, MEMORY_AGENT_TOOL_MAP, EXTERNAL_SKILL_TOOL_NAMES, EXTERNAL_SKILL_AGENT_TOOL_MAP, COUNCIL_TOOL_NAMES, COUNCIL_AGENT_TOOL_MAP, GENERAL_COUNCIL_TOOL_NAMES, GENERAL_COUNCIL_AGENT_TOOL_MAP, TURBO_TOOL_NAMES, TURBO_AGENT_TOOL_MAP, WRITE_TOOL_NAMES, DEFAULT_MODELS, DEFAULT_SCORING_CONFIG, LOW_CAPABILITY_MODELS, TURBO_MODE_BANNER = `## \uD83D\uDE80 TURBO MODE ACTIVE
917
+ var OPENCODE_NATIVE_AGENTS, CLAUDE_CODE_NATIVE_COMMANDS, MEMORY_AGENT_TOOL_MAP, EXTERNAL_SKILL_TOOL_NAMES, EXTERNAL_SKILL_AGENT_TOOL_MAP, COUNCIL_TOOL_NAMES, COUNCIL_AGENT_TOOL_MAP, GENERAL_COUNCIL_TOOL_NAMES, GENERAL_COUNCIL_AGENT_TOOL_MAP, TURBO_TOOL_NAMES, TURBO_AGENT_TOOL_MAP, SKILL_TOOL_NAMES, SKILL_AGENT_TOOL_MAP, WRITE_TOOL_NAMES, DEFAULT_MODELS, DEFAULT_SCORING_CONFIG, LOW_CAPABILITY_MODELS, TURBO_MODE_BANNER = `## \uD83D\uDE80 TURBO MODE ACTIVE
914
918
 
915
919
  **Speed optimization enabled for this session.**
916
920
 
@@ -1211,6 +1215,18 @@ var init_constants = __esm(() => {
1211
1215
  TURBO_AGENT_TOOL_MAP = {
1212
1216
  architect: [...TURBO_TOOL_NAMES]
1213
1217
  };
1218
+ SKILL_TOOL_NAMES = [
1219
+ "skill_generate",
1220
+ "skill_list",
1221
+ "skill_apply",
1222
+ "skill_inspect",
1223
+ "skill_regenerate",
1224
+ "skill_retire",
1225
+ "skill_improve"
1226
+ ];
1227
+ SKILL_AGENT_TOOL_MAP = {
1228
+ architect: [...SKILL_TOOL_NAMES]
1229
+ };
1214
1230
  WRITE_TOOL_NAMES = [
1215
1231
  "write",
1216
1232
  "edit",
@@ -15466,6 +15482,7 @@ __export(exports_schema, {
15466
15482
  StandardTurboConfigSchema: () => StandardTurboConfigSchema,
15467
15483
  SpecWriterConfigSchema: () => SpecWriterConfigSchema,
15468
15484
  SlopDetectorConfigSchema: () => SlopDetectorConfigSchema,
15485
+ SkillsConfigSchema: () => SkillsConfigSchema,
15469
15486
  SkillPropagationConfigSchema: () => SkillPropagationConfigSchema,
15470
15487
  SkillImproverConfigSchema: () => SkillImproverConfigSchema,
15471
15488
  SelfReviewConfigSchema: () => SelfReviewConfigSchema,
@@ -15507,6 +15524,7 @@ __export(exports_schema, {
15507
15524
  DiscoverySourceSchema: () => DiscoverySourceSchema,
15508
15525
  DesignDocsConfigSchema: () => DesignDocsConfigSchema,
15509
15526
  DecisionDecaySchema: () => DecisionDecaySchema,
15527
+ DEFAULT_SKILLS_CONFIG: () => DEFAULT_SKILLS_CONFIG,
15510
15528
  DEFAULT_EXTERNAL_SKILLS_CONFIG: () => DEFAULT_EXTERNAL_SKILLS_CONFIG,
15511
15529
  DEFAULT_ARCHITECT_PROFILE: () => DEFAULT_ARCHITECT_PROFILE,
15512
15530
  DEFAULT_AGENT_PROFILES: () => DEFAULT_AGENT_PROFILES,
@@ -15606,7 +15624,7 @@ function resolveExternalSkillsConfig(input) {
15606
15624
  };
15607
15625
  return merged;
15608
15626
  }
15609
- var _internals, SEPARATORS, CANONICAL_ROLES_LONGEST_FIRST, CANONICAL_ROLES_SET, AgentReasoningConfigSchema, AgentThinkingConfigSchema, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AutoReviewConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, DesignDocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, ContextMapConfigSchema, RepoGraphConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, MemoryConfigSchema, CuratorConfigSchema, ArchitecturalSupervisionConfigSchema, KnowledgeApplicationConfigSchema, SkillPropagationConfigSchema, SkillImproverConfigSchema, SpecWriterConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, PrMonitorConfigSchema, ParallelizationConfigSchema, WorktreeIsolationConfigSchema, LeanTurboConfigSchema, EpicConfigSchema, StandardTurboConfigSchema, LeanTurboStrategyConfigSchema, TurboConfigSchema, ExternalSkillCandidateSourceTypeSchema, ExternalSkillCandidateEvaluationVerdictSchema, DiscoverySourceSchema, ExternalSkillCandidateSchema, ExternalSkillsConfigSchema, DEFAULT_EXTERNAL_SKILLS_CONFIG, PluginConfigSchema;
15627
+ var _internals, SEPARATORS, CANONICAL_ROLES_LONGEST_FIRST, CANONICAL_ROLES_SET, AgentReasoningConfigSchema, AgentThinkingConfigSchema, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AutoReviewConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, DesignDocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, ContextMapConfigSchema, RepoGraphConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, MemoryConfigSchema, CuratorConfigSchema, ArchitecturalSupervisionConfigSchema, KnowledgeApplicationConfigSchema, SkillPropagationConfigSchema, SkillImproverConfigSchema, SkillsConfigSchema, SpecWriterConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, PrMonitorConfigSchema, ParallelizationConfigSchema, WorktreeIsolationConfigSchema, LeanTurboConfigSchema, EpicConfigSchema, StandardTurboConfigSchema, LeanTurboStrategyConfigSchema, TurboConfigSchema, ExternalSkillCandidateSourceTypeSchema, ExternalSkillCandidateEvaluationVerdictSchema, DiscoverySourceSchema, ExternalSkillCandidateSchema, ExternalSkillsConfigSchema, DEFAULT_EXTERNAL_SKILLS_CONFIG, DEFAULT_SKILLS_CONFIG, PluginConfigSchema;
15610
15628
  var init_schema = __esm(() => {
15611
15629
  init_zod();
15612
15630
  init_constants();
@@ -15684,6 +15702,7 @@ var init_schema = __esm(() => {
15684
15702
  critical_threshold: exports_external.number().min(0).max(1).default(0.9),
15685
15703
  model_limits: exports_external.record(exports_external.string(), exports_external.number().min(1000)).default({ default: 128000 }),
15686
15704
  max_injection_tokens: exports_external.number().min(100).max(50000).default(4000),
15705
+ unified_injection_tokens: exports_external.number().min(100).max(50000).optional(),
15687
15706
  tracked_agents: exports_external.array(exports_external.string()).default(["architect"]),
15688
15707
  scoring: ScoringConfigSchema.optional(),
15689
15708
  enforce: exports_external.boolean().default(true),
@@ -16302,6 +16321,9 @@ var init_schema = __esm(() => {
16302
16321
  quota_window: exports_external.enum(["utc", "local"]).default("utc"),
16303
16322
  allow_deterministic_fallback: exports_external.boolean().default(true)
16304
16323
  });
16324
+ SkillsConfigSchema = exports_external.object({
16325
+ enabled: exports_external.boolean().default(false)
16326
+ });
16305
16327
  SpecWriterConfigSchema = exports_external.object({
16306
16328
  enabled: exports_external.boolean().default(true),
16307
16329
  model: exports_external.string().nullable().default(null),
@@ -16562,6 +16584,9 @@ var init_schema = __esm(() => {
16562
16584
  max_concurrent_fetches: 5,
16563
16585
  fetch_timeout_ms: 30000
16564
16586
  };
16587
+ DEFAULT_SKILLS_CONFIG = {
16588
+ enabled: false
16589
+ };
16565
16590
  PluginConfigSchema = exports_external.object({
16566
16591
  agents: exports_external.record(exports_external.string(), AgentOverrideConfigSchema).optional(),
16567
16592
  default_agent: exports_external.string().optional().transform((v) => {
@@ -16789,7 +16814,8 @@ var init_schema = __esm(() => {
16789
16814
  }
16790
16815
  })),
16791
16816
  pr_monitor: PrMonitorConfigSchema.optional(),
16792
- external_skills: ExternalSkillsConfigSchema.optional()
16817
+ external_skills: ExternalSkillsConfigSchema.optional(),
16818
+ skills: SkillsConfigSchema.optional()
16793
16819
  });
16794
16820
  });
16795
16821
 
@@ -101547,7 +101573,7 @@ Members verify prior findings are resolved without re-reviewing unchanged code.
101547
101573
  The architect resolves any \`unresolvedConflicts\` in \`unifiedFeedbackMd\` BEFORE
101548
101574
  sending it to the coder — the coder never sees contradictory instructions.`;
101549
101575
  }
101550
- function buildYourToolsList(council, memoryEnabled = false, externalSkillsEnabled = false, turboEnabled = false) {
101576
+ function buildYourToolsList(council, memoryEnabled = false, externalSkillsEnabled = false, turboEnabled = false, skillsEnabled = false) {
101551
101577
  const qaCouncilEnabled = council?.enabled === true;
101552
101578
  const generalCouncilEnabled = council?.general?.enabled === true;
101553
101579
  const tools = [
@@ -101556,7 +101582,8 @@ function buildYourToolsList(council, memoryEnabled = false, externalSkillsEnable
101556
101582
  ...externalSkillsEnabled ? EXTERNAL_SKILL_AGENT_TOOL_MAP.architect ?? [] : [],
101557
101583
  ...qaCouncilEnabled ? COUNCIL_AGENT_TOOL_MAP.architect ?? [] : [],
101558
101584
  ...generalCouncilEnabled ? GENERAL_COUNCIL_AGENT_TOOL_MAP.architect ?? [] : [],
101559
- ...turboEnabled ? TURBO_AGENT_TOOL_MAP.architect ?? [] : []
101585
+ ...turboEnabled ? TURBO_AGENT_TOOL_MAP.architect ?? [] : [],
101586
+ ...skillsEnabled ? SKILL_AGENT_TOOL_MAP.architect ?? [] : []
101560
101587
  ];
101561
101588
  const sorted = [...tools].sort();
101562
101589
  return `Task (delegation), ${sorted.join(", ")}.`;
@@ -101608,7 +101635,7 @@ If the user accepts the default (1), skip writing this section entirely — seri
101608
101635
  \`\`\`
101609
101636
  If the user keeps the default phase-level behavior, do not write this section.`;
101610
101637
  }
101611
- function buildAvailableToolsList(council, memoryEnabled = false, externalSkillsEnabled = false, turboEnabled = false) {
101638
+ function buildAvailableToolsList(council, memoryEnabled = false, externalSkillsEnabled = false, turboEnabled = false, skillsEnabled = false) {
101612
101639
  const qaCouncilEnabled = council?.enabled === true;
101613
101640
  const generalCouncilEnabled = council?.general?.enabled === true;
101614
101641
  const tools = [
@@ -101617,7 +101644,8 @@ function buildAvailableToolsList(council, memoryEnabled = false, externalSkillsE
101617
101644
  ...externalSkillsEnabled ? EXTERNAL_SKILL_AGENT_TOOL_MAP.architect ?? [] : [],
101618
101645
  ...qaCouncilEnabled ? COUNCIL_AGENT_TOOL_MAP.architect ?? [] : [],
101619
101646
  ...generalCouncilEnabled ? GENERAL_COUNCIL_AGENT_TOOL_MAP.architect ?? [] : [],
101620
- ...turboEnabled ? TURBO_AGENT_TOOL_MAP.architect ?? [] : []
101647
+ ...turboEnabled ? TURBO_AGENT_TOOL_MAP.architect ?? [] : [],
101648
+ ...skillsEnabled ? SKILL_AGENT_TOOL_MAP.architect ?? [] : []
101621
101649
  ];
101622
101650
  const sorted = [...tools].sort();
101623
101651
  return sorted.map((t) => {
@@ -101753,7 +101781,7 @@ function buildSlashCommandsList() {
101753
101781
  return lines.join(`
101754
101782
  `);
101755
101783
  }
101756
- function createArchitectAgent(model, customPrompt, customAppendPrompt, adversarialTesting, council, uiReview, memoryEnabled = false, architecturalSupervision, designDocsEnabled = false, externalSkillsEnabled = false, turboEnabled = false) {
101784
+ function createArchitectAgent(model, customPrompt, customAppendPrompt, adversarialTesting, council, uiReview, memoryEnabled = false, architecturalSupervision, designDocsEnabled = false, externalSkillsEnabled = false, turboEnabled = false, skillsEnabled = false) {
101757
101785
  let prompt = ARCHITECT_PROMPT;
101758
101786
  if (customPrompt) {
101759
101787
  prompt = customPrompt;
@@ -101762,7 +101790,7 @@ function createArchitectAgent(model, customPrompt, customAppendPrompt, adversari
101762
101790
 
101763
101791
  ${customAppendPrompt}`;
101764
101792
  }
101765
- prompt = prompt?.replace("{{YOUR_TOOLS}}", buildYourToolsList(council, memoryEnabled, externalSkillsEnabled, turboEnabled))?.replace("{{AVAILABLE_TOOLS}}", buildAvailableToolsList(council, memoryEnabled, externalSkillsEnabled, turboEnabled))?.replace("{{SLASH_COMMANDS}}", buildSlashCommandsList());
101793
+ prompt = prompt?.replace("{{YOUR_TOOLS}}", buildYourToolsList(council, memoryEnabled, externalSkillsEnabled, turboEnabled, skillsEnabled))?.replace("{{AVAILABLE_TOOLS}}", buildAvailableToolsList(council, memoryEnabled, externalSkillsEnabled, turboEnabled, skillsEnabled))?.replace("{{SLASH_COMMANDS}}", buildSlashCommandsList());
101766
101794
  prompt = prompt?.replace(/\{\{QA_GATE_DIALOGUE_SPECIFY\}\}/g, buildQaGateSelectionDialogue("SPECIFY"))?.replace(/\{\{QA_GATE_DIALOGUE_BRAINSTORM\}\}/g, buildQaGateSelectionDialogue("BRAINSTORM"))?.replace(/\{\{QA_GATE_DIALOGUE_PLAN\}\}/g, buildQaGateSelectionDialogue("PLAN"));
101767
101795
  const councilBlock = buildCouncilWorkflow(council);
101768
101796
  const hasPlaceholder = prompt?.includes("{{COUNCIL_WORKFLOW}}") === true;
@@ -102537,7 +102565,7 @@ Purpose: Read the previous retrospective and produce a codebase reality report b
102537
102565
  ACTION: Load skill file:.opencode/skills/pre-phase-briefing/SKILL.md immediately. Follow the protocol defined there.
102538
102566
 
102539
102567
  HARD CONSTRAINTS:
102540
- - Complete the codebase reality report before starting or resuming phase implementation.
102568
+ - Complete the codebase reality report before spec finalization, plan generation, plan ingestion, declare_scope, or starting/resuming phase implementation. Dispatching the reality-check lanes asynchronously is allowed and preferred; settling all lanes before any of that downstream work is not optional.
102541
102569
 
102542
102570
  ### MODE: COUNCIL
102543
102571
  Activates when the user invokes /swarm council or requests a council-style decision review.
@@ -105437,7 +105465,7 @@ function createSwarmAgents(swarmId, swarmConfig, isDefault, pluginConfig, projec
105437
105465
  const prefixName = (name) => `${prefix}${name}`;
105438
105466
  if (!isAgentDisabled("architect", swarmAgents, swarmPrefix)) {
105439
105467
  const architectPrompts = getPrompts("architect");
105440
- const architect = createArchitectAgent(getModel("architect"), architectPrompts.prompt, architectPrompts.appendPrompt, pluginConfig?.adversarial_testing, pluginConfig?.council, pluginConfig?.ui_review, pluginConfig?.memory?.enabled === true, pluginConfig?.architectural_supervision, pluginConfig?.design_docs?.enabled === true, pluginConfig?.external_skills?.curation_enabled === true, pluginConfig?.turbo !== undefined);
105468
+ const architect = createArchitectAgent(getModel("architect"), architectPrompts.prompt, architectPrompts.appendPrompt, pluginConfig?.adversarial_testing, pluginConfig?.council, pluginConfig?.ui_review, pluginConfig?.memory?.enabled === true, pluginConfig?.architectural_supervision, pluginConfig?.design_docs?.enabled === true, pluginConfig?.external_skills?.curation_enabled === true, pluginConfig?.turbo !== undefined, pluginConfig?.skills?.enabled === true);
105441
105469
  architect.name = prefixName("architect");
105442
105470
  const swarmName = swarmConfig.name || swarmId;
105443
105471
  const swarmIdentity = isDefault ? "default" : swarmId;
@@ -105778,6 +105806,17 @@ function getAgentConfigs(config3, directory, sessionId, projectContext) {
105778
105806
  allowedTools = Array.from(new Set([...allowedTools ?? [], ...turboTools]));
105779
105807
  }
105780
105808
  }
105809
+ {
105810
+ const skillTools = SKILL_AGENT_TOOL_MAP[baseAgentName] ?? [];
105811
+ if (skillTools.length > 0 && allowedTools) {
105812
+ if (config3?.skills?.enabled === true) {
105813
+ allowedTools = Array.from(new Set([...allowedTools, ...skillTools]));
105814
+ } else {
105815
+ const skillToolsSet = new Set(skillTools);
105816
+ allowedTools = allowedTools.filter((t) => !skillToolsSet.has(t));
105817
+ }
105818
+ }
105819
+ }
105781
105820
  if (baseAgentName === "architect" && config3?.council?.enabled !== true && override !== undefined) {
105782
105821
  const councilTools = [
105783
105822
  "declare_council_criteria",
@@ -108330,7 +108369,7 @@ var init_knowledge_recall = __esm(() => {
108330
108369
  init_knowledge_diagnostics();
108331
108370
  init_create_tool();
108332
108371
  knowledge_recall = createSwarmTool({
108333
- description: "Search the knowledge base for relevant past decisions, patterns, and lessons learned. Returns ranked results via the unified hybrid retrieval service and a trace_id for knowledge_receipt.",
108372
+ description: "Performs semantic natural-language search across the knowledge base for relevant past decisions, patterns, and lessons learned. Returns ranked results via the unified hybrid retrieval service and a trace_id for knowledge_receipt. This is the tool to use when the user has a QUESTION about what the knowledge base contains. For structured filter-based retrieval (by category, status, or score), use `knowledge_query` instead.",
108334
108373
  args: {
108335
108374
  query: exports_external.string().min(3).describe("Natural language search query"),
108336
108375
  top_n: exports_external.number().int().min(1).max(20).optional().describe("Maximum results to return (default: 5)"),
@@ -108650,7 +108689,7 @@ var init_curator_drift = __esm(() => {
108650
108689
  var exports_design_doc_drift = {};
108651
108690
  __export(exports_design_doc_drift, {
108652
108691
  runDesignDocDriftCheck: () => runDesignDocDriftCheck,
108653
- _internals: () => _internals116
108692
+ _internals: () => _internals117
108654
108693
  });
108655
108694
  import * as fs122 from "node:fs";
108656
108695
  import * as path194 from "node:path";
@@ -108783,7 +108822,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
108783
108822
  return null;
108784
108823
  }
108785
108824
  }
108786
- var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL, _internals116;
108825
+ var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL, _internals117;
108787
108826
  var init_design_doc_drift = __esm(() => {
108788
108827
  init_event_bus();
108789
108828
  init_effective_spec();
@@ -108798,7 +108837,7 @@ var init_design_doc_drift = __esm(() => {
108798
108837
  "idiom-notes": path194.join("reference", "idiom-notes.md")
108799
108838
  };
108800
108839
  TRACEABILITY_REL = path194.join("reference", "traceability.json");
108801
- _internals116 = {
108840
+ _internals117 = {
108802
108841
  mtimeMsOrNull,
108803
108842
  resolveAnchorWithin,
108804
108843
  DESIGN_DOC_FILES
@@ -108809,7 +108848,7 @@ var init_design_doc_drift = __esm(() => {
108809
108848
  var exports_project_context = {};
108810
108849
  __export(exports_project_context, {
108811
108850
  buildProjectContext: () => buildProjectContext,
108812
- _internals: () => _internals131,
108851
+ _internals: () => _internals135,
108813
108852
  LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
108814
108853
  });
108815
108854
  import * as fs146 from "node:fs";
@@ -108893,7 +108932,7 @@ function selectLintCommand(backend, directory) {
108893
108932
  return null;
108894
108933
  }
108895
108934
  async function buildProjectContext(directory) {
108896
- const backend = await _internals131.pickBackend(directory);
108935
+ const backend = await _internals135.pickBackend(directory);
108897
108936
  if (!backend)
108898
108937
  return null;
108899
108938
  const ctx = emptyProjectContext();
@@ -108932,17 +108971,17 @@ async function buildProjectContext(directory) {
108932
108971
  if (backend.prompts.reviewerChecklist.length > 0) {
108933
108972
  ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
108934
108973
  }
108935
- const profiles = _internals131.pickedProfiles(directory);
108974
+ const profiles = _internals135.pickedProfiles(directory);
108936
108975
  if (profiles.length > 1) {
108937
108976
  ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
108938
108977
  }
108939
108978
  return ctx;
108940
108979
  }
108941
- var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals131;
108980
+ var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals135;
108942
108981
  var init_project_context = __esm(() => {
108943
108982
  init_dispatch();
108944
108983
  init_framework_detector();
108945
- _internals131 = {
108984
+ _internals135 = {
108946
108985
  pickBackend,
108947
108986
  pickedProfiles
108948
108987
  };
@@ -117975,6 +118014,73 @@ init_preflight_integration();
117975
118014
  init_preflight_service();
117976
118015
  init_status_service();
117977
118016
 
118017
+ // src/services/injection-budget.ts
118018
+ function charsToTokens(chars) {
118019
+ if (chars <= 0)
118020
+ return 0;
118021
+ return Math.ceil(chars * 0.33);
118022
+ }
118023
+ function allocateInjectionBudget(systemEnhancerDemandTokens, knowledgeInjectorDemandChars, config3) {
118024
+ const budget = config3.totalBudgetTokens;
118025
+ const seDemand = Math.max(0, systemEnhancerDemandTokens);
118026
+ const kiChars = Math.max(0, knowledgeInjectorDemandChars);
118027
+ const ceiling = Math.max(0, budget);
118028
+ const kiDemand = charsToTokens(kiChars);
118029
+ if (seDemand + kiDemand <= ceiling) {
118030
+ return {
118031
+ systemEnhancerTokens: seDemand,
118032
+ knowledgeInjectorTokens: kiDemand,
118033
+ totalTokens: seDemand + kiDemand
118034
+ };
118035
+ }
118036
+ if (seDemand >= ceiling) {
118037
+ return {
118038
+ systemEnhancerTokens: ceiling,
118039
+ knowledgeInjectorTokens: 0,
118040
+ totalTokens: ceiling
118041
+ };
118042
+ }
118043
+ if (kiDemand >= ceiling) {
118044
+ return {
118045
+ systemEnhancerTokens: 0,
118046
+ knowledgeInjectorTokens: ceiling,
118047
+ totalTokens: ceiling
118048
+ };
118049
+ }
118050
+ const totalDemand = seDemand + kiDemand;
118051
+ const seShare = Math.floor(seDemand / totalDemand * ceiling);
118052
+ const kiShare = ceiling - seShare;
118053
+ return {
118054
+ systemEnhancerTokens: seShare,
118055
+ knowledgeInjectorTokens: kiShare,
118056
+ totalTokens: ceiling
118057
+ };
118058
+ }
118059
+ var sessionBudgets = new Map;
118060
+ var MAX_TRACKED_SESSIONS = 256;
118061
+ function evictSessionBudgets() {
118062
+ while (sessionBudgets.size > MAX_TRACKED_SESSIONS) {
118063
+ const firstKey = sessionBudgets.keys().next().value;
118064
+ if (firstKey === undefined)
118065
+ break;
118066
+ sessionBudgets.delete(firstKey);
118067
+ }
118068
+ }
118069
+ function resetUnifiedBudget(sessionID, totalBudget) {
118070
+ sessionBudgets.set(sessionID, { total: totalBudget, used: 0, seDemand: 0 });
118071
+ evictSessionBudgets();
118072
+ }
118073
+ function setSystemEnhancerDemand(sessionID, demand) {
118074
+ const budget = sessionBudgets.get(sessionID);
118075
+ if (!budget)
118076
+ return;
118077
+ budget.seDemand = demand;
118078
+ }
118079
+ function getSystemEnhancerDemand(sessionID) {
118080
+ const budget = sessionBudgets.get(sessionID);
118081
+ return budget?.seDemand ?? 0;
118082
+ }
118083
+
117978
118084
  // src/hooks/system-enhancer.ts
117979
118085
  init_telemetry();
117980
118086
  init_co_change_analyzer();
@@ -118246,7 +118352,7 @@ var MAX_RECENT_CALLS = 20;
118246
118352
  var SPIRAL_THRESHOLD = 5;
118247
118353
  var SPIRAL_WINDOW_MS = 300000;
118248
118354
  var SPIRAL_COOLDOWN_MS = 60000;
118249
- var MAX_TRACKED_SESSIONS = 500;
118355
+ var MAX_TRACKED_SESSIONS2 = 500;
118250
118356
  function recordToolCall(tool3, args2, sessionId) {
118251
118357
  const argsHash = typeof args2 === "string" ? args2.slice(0, 100) : JSON.stringify(args2 ?? "").slice(0, 100);
118252
118358
  let calls = recentToolCallsBySession.get(sessionId);
@@ -118276,7 +118382,7 @@ async function detectDebuggingSpiral(_directory, sessionId) {
118276
118382
  if (allSameTool && allSimilarArgs) {
118277
118383
  lastSpiralTimestampBySession.set(sessionId, now);
118278
118384
  recentToolCallsBySession.delete(sessionId);
118279
- if (lastSpiralTimestampBySession.size > MAX_TRACKED_SESSIONS) {
118385
+ if (lastSpiralTimestampBySession.size > MAX_TRACKED_SESSIONS2) {
118280
118386
  for (const oldest of lastSpiralTimestampBySession.keys()) {
118281
118387
  if (oldest !== sessionId) {
118282
118388
  lastSpiralTimestampBySession.delete(oldest);
@@ -119605,8 +119711,10 @@ function createSystemEnhancerHook(config3, directory) {
119605
119711
  try {
119606
119712
  let tryInject = function(text) {
119607
119713
  const tokens = estimateTokens(text);
119608
- if (injectedTokens + tokens > maxInjectionTokens) {
119609
- warn(`system-enhancer: injection budget exceeded (${injectedTokens + tokens} > ${maxInjectionTokens} tokens) — truncating system prompt content`);
119714
+ actualDemand += tokens;
119715
+ const effectiveMax = seAllocation;
119716
+ if (injectedTokens + tokens > effectiveMax) {
119717
+ warn(`system-enhancer: injection budget exceeded (${injectedTokens + tokens} > ${effectiveMax} tokens) — truncating system prompt content`);
119610
119718
  return;
119611
119719
  }
119612
119720
  output.system.push(text);
@@ -119620,6 +119728,18 @@ function createSystemEnhancerHook(config3, directory) {
119620
119728
  }
119621
119729
  const maxInjectionTokens = config3.context_budget?.max_injection_tokens ?? 4000;
119622
119730
  let injectedTokens = 0;
119731
+ let actualDemand = 0;
119732
+ let seAllocation;
119733
+ let unifiedBudget;
119734
+ if (config3.context_budget?.unified_injection_tokens !== undefined && _input.sessionID) {
119735
+ unifiedBudget = config3.context_budget.unified_injection_tokens;
119736
+ const allocation = allocateInjectionBudget(maxInjectionTokens, 0, {
119737
+ totalBudgetTokens: unifiedBudget
119738
+ });
119739
+ seAllocation = allocation.systemEnhancerTokens;
119740
+ } else {
119741
+ seAllocation = maxInjectionTokens;
119742
+ }
119623
119743
  const contextContent = await readSwarmFileAsync(directory, "context.md");
119624
119744
  try {
119625
119745
  const { scanDocIndex: scanDocIndex2 } = await Promise.resolve().then(() => (init_doc_scan(), exports_doc_scan));
@@ -120057,6 +120177,15 @@ ${budgetWarning}`);
120057
120177
  tryInject(envPrompt);
120058
120178
  }
120059
120179
  } catch {}
120180
+ if (unifiedBudget !== undefined && _input.sessionID) {
120181
+ const totalDemand = actualDemand;
120182
+ const allocation = allocateInjectionBudget(totalDemand, 0, {
120183
+ totalBudgetTokens: unifiedBudget
120184
+ });
120185
+ seAllocation = allocation.systemEnhancerTokens;
120186
+ resetUnifiedBudget(_input.sessionID, unifiedBudget);
120187
+ setSystemEnhancerDemand(_input.sessionID, totalDemand);
120188
+ } else {}
120060
120189
  return;
120061
120190
  }
120062
120191
  const mode_b = await detectArchitectMode(directory);
@@ -120538,7 +120667,8 @@ ${handoffBlock}`;
120538
120667
  } catch {}
120539
120668
  const ranked = rankCandidates(candidates, effectiveConfig);
120540
120669
  for (const candidate of ranked) {
120541
- if (injectedTokens + candidate.tokens > maxInjectionTokens) {
120670
+ actualDemand += candidate.tokens;
120671
+ if (injectedTokens + candidate.tokens > seAllocation) {
120542
120672
  continue;
120543
120673
  }
120544
120674
  output.system.push(candidate.text);
@@ -120577,6 +120707,15 @@ ${budgetWarning_b}`);
120577
120707
  }
120578
120708
  }
120579
120709
  }
120710
+ if (unifiedBudget !== undefined && _input.sessionID) {
120711
+ const totalDemand = actualDemand;
120712
+ const allocation = allocateInjectionBudget(totalDemand, 0, {
120713
+ totalBudgetTokens: unifiedBudget
120714
+ });
120715
+ seAllocation = allocation.systemEnhancerTokens;
120716
+ resetUnifiedBudget(_input.sessionID, unifiedBudget);
120717
+ setSystemEnhancerDemand(_input.sessionID, totalDemand);
120718
+ }
120580
120719
  } catch (error93) {
120581
120720
  warn("System enhancer failed:", error93);
120582
120721
  }
@@ -120696,6 +120835,71 @@ function formatBytes(bytes) {
120696
120835
  const formatted = unitIndex === 0 ? size.toString() : size.toFixed(1);
120697
120836
  return `${formatted} ${units[unitIndex]}`;
120698
120837
  }
120838
+ function jsonTypeSignature(value) {
120839
+ if (value === null)
120840
+ return "null";
120841
+ if (Array.isArray(value)) {
120842
+ const len = value.length;
120843
+ if (len === 0)
120844
+ return "array<>";
120845
+ const first = value[0];
120846
+ return `array<${len}, ${jsonTypeSignature(first)}>`;
120847
+ }
120848
+ switch (typeof value) {
120849
+ case "string":
120850
+ return "string";
120851
+ case "number":
120852
+ return Number.isInteger(value) ? "number" : "number(float)";
120853
+ case "boolean":
120854
+ return "boolean";
120855
+ case "object":
120856
+ return "object";
120857
+ default:
120858
+ return typeof value;
120859
+ }
120860
+ }
120861
+ function summarizeJsonObject(parsed) {
120862
+ const keys = Object.keys(parsed);
120863
+ const parts = keys.map((key) => `${key}: ${jsonTypeSignature(parsed[key])}`);
120864
+ return `{ ${parts.join(", ")} }`;
120865
+ }
120866
+ function summarizeJsonArray(parsed) {
120867
+ const len = parsed.length;
120868
+ if (len === 0)
120869
+ return "[ 0 items ]";
120870
+ const firstSig = jsonTypeSignature(parsed[0]);
120871
+ return `[ ${len} items, first: ${firstSig} ]`;
120872
+ }
120873
+ var DECLARATION_PATTERN = /(?:export\s+)?(?:async\s+)?(?:function|class|interface|type|const|let|var)\s+(\w+)/g;
120874
+ function extractCodeSignatures(code) {
120875
+ const signatures = [];
120876
+ for (const match of code.matchAll(DECLARATION_PATTERN)) {
120877
+ const name = match[1];
120878
+ if (name && !signatures.includes(name)) {
120879
+ signatures.push(name);
120880
+ }
120881
+ }
120882
+ return signatures;
120883
+ }
120884
+ function summarizeCode(output) {
120885
+ const signatures = extractCodeSignatures(output);
120886
+ const lines = output.split(`
120887
+ `).filter((line) => line.trim().length > 0).slice(0, 5);
120888
+ if (signatures.length === 0) {
120889
+ return lines.join(`
120890
+ `);
120891
+ }
120892
+ const sigLine = `// declarations: ${signatures.join(", ")}`;
120893
+ const previewLines = [sigLine, ...lines];
120894
+ return previewLines.join(`
120895
+ `);
120896
+ }
120897
+ function summarizeText(output, maxLines) {
120898
+ const lines = output.split(`
120899
+ `).filter((line) => line.trim().length > 0).slice(0, maxLines);
120900
+ return lines.join(`
120901
+ `);
120902
+ }
120699
120903
  function createSummary(output, toolName, summaryId, maxSummaryChars) {
120700
120904
  const contentType = detectContentType(output, toolName);
120701
120905
  const lineCount = output.split(`
@@ -120712,36 +120916,23 @@ function createSummary(output, toolName, summaryId, maxSummaryChars) {
120712
120916
  try {
120713
120917
  const parsed = JSON.parse(output.trim());
120714
120918
  if (Array.isArray(parsed)) {
120715
- preview = `[ ${parsed.length} items ]`;
120919
+ preview = summarizeJsonArray(parsed);
120716
120920
  } else if (typeof parsed === "object" && parsed !== null) {
120717
- const keys = Object.keys(parsed).slice(0, 3);
120718
- preview = `{ ${keys.join(", ")}${Object.keys(parsed).length > 3 ? ", ..." : ""} }`;
120921
+ preview = summarizeJsonObject(parsed);
120719
120922
  } else {
120720
- const lines = output.split(`
120721
- `).filter((line) => line.trim().length > 0).slice(0, 3);
120722
- preview = lines.join(`
120723
- `);
120923
+ preview = summarizeText(output, 3);
120724
120924
  }
120725
120925
  } catch {
120726
- const lines = output.split(`
120727
- `).filter((line) => line.trim().length > 0).slice(0, 3);
120728
- preview = lines.join(`
120729
- `);
120926
+ preview = summarizeText(output, 3);
120730
120927
  }
120731
120928
  break;
120732
120929
  }
120733
120930
  case "code": {
120734
- const lines = output.split(`
120735
- `).filter((line) => line.trim().length > 0).slice(0, 5);
120736
- preview = lines.join(`
120737
- `);
120931
+ preview = summarizeCode(output);
120738
120932
  break;
120739
120933
  }
120740
120934
  case "text": {
120741
- const lines = output.split(`
120742
- `).filter((line) => line.trim().length > 0).slice(0, 5);
120743
- preview = lines.join(`
120744
- `);
120935
+ preview = summarizeText(output, 5);
120745
120936
  break;
120746
120937
  }
120747
120938
  case "binary": {
@@ -120749,10 +120940,7 @@ function createSummary(output, toolName, summaryId, maxSummaryChars) {
120749
120940
  break;
120750
120941
  }
120751
120942
  default: {
120752
- const lines = output.split(`
120753
- `).filter((line) => line.trim().length > 0).slice(0, 5);
120754
- preview = lines.join(`
120755
- `);
120943
+ preview = summarizeText(output, 5);
120756
120944
  }
120757
120945
  }
120758
120946
  if (preview.length > maxPreviewChars) {
@@ -121205,12 +121393,12 @@ init_logger();
121205
121393
  init_normalize_tool_name();
121206
121394
  init_review_receipt();
121207
121395
  init_utils2();
121208
- var MAX_TRACKED_SESSIONS2 = 256;
121396
+ var MAX_TRACKED_SESSIONS3 = 256;
121209
121397
  var COOLDOWN_MS = 60000;
121210
121398
  var inFlightSessions = new Set;
121211
121399
  var lastDispatchBySession = new Map;
121212
121400
  function evictCooldownMap() {
121213
- while (lastDispatchBySession.size > MAX_TRACKED_SESSIONS2) {
121401
+ while (lastDispatchBySession.size > MAX_TRACKED_SESSIONS3) {
121214
121402
  const firstKey = lastDispatchBySession.keys().next().value;
121215
121403
  if (firstKey === undefined)
121216
121404
  break;
@@ -122333,7 +122521,7 @@ function injectKnowledgeMessage(output, text) {
122333
122521
  };
122334
122522
  output.messages.splice(insertIdx, 0, knowledgeMessage);
122335
122523
  }
122336
- function createKnowledgeInjectorHook(directory, config3, modelLimitOverrides = {}) {
122524
+ function createKnowledgeInjectorHook(directory, config3, modelLimitOverrides = {}, unifiedInjectionTokens = undefined) {
122337
122525
  function buildContextCacheKey(phase, ctx) {
122338
122526
  const parts = [
122339
122527
  String(phase),
@@ -122367,11 +122555,19 @@ function createKnowledgeInjectorHook(directory, config3, modelLimitOverrides = {
122367
122555
  return;
122368
122556
  }
122369
122557
  const maxInjectChars = config3.inject_char_budget ?? 2000;
122370
- const effectiveBudget = headroomChars >= MODEL_LIMIT_CHARS * 0.6 ? maxInjectChars : headroomChars >= MODEL_LIMIT_CHARS * 0.2 ? Math.floor(maxInjectChars * 0.5) : Math.floor(maxInjectChars * 0.25);
122558
+ let effectiveBudget = headroomChars >= MODEL_LIMIT_CHARS * 0.6 ? maxInjectChars : headroomChars >= MODEL_LIMIT_CHARS * 0.2 ? Math.floor(maxInjectChars * 0.5) : Math.floor(maxInjectChars * 0.25);
122371
122559
  const systemMsg = output.messages.find((m) => m.info?.role === "system");
122372
122560
  const agentName = systemMsg?.info?.agent;
122373
122561
  if (!agentName)
122374
122562
  return;
122563
+ if (unifiedInjectionTokens !== undefined) {
122564
+ const sessionID2 = systemMsg?.info?.sessionID;
122565
+ const seDemand = sessionID2 ? getSystemEnhancerDemand(sessionID2) : 0;
122566
+ const allocation = allocateInjectionBudget(seDemand, effectiveBudget, {
122567
+ totalBudgetTokens: unifiedInjectionTokens
122568
+ });
122569
+ effectiveBudget = Math.floor(allocation.knowledgeInjectorTokens / 0.33);
122570
+ }
122375
122571
  if (isDelegatedAgent(agentName)) {
122376
122572
  await injectForDelegateIntoMessages(directory, config3, output, agentName, systemMsg?.info?.sessionID);
122377
122573
  return;
@@ -124005,7 +124201,7 @@ function extractText2(out) {
124005
124201
  }
124006
124202
  return "";
124007
124203
  }
124008
- var MAX_TRACKED_SESSIONS3 = 256;
124204
+ var MAX_TRACKED_SESSIONS4 = 256;
124009
124205
  var WARNING_TTL_MS = 5 * 60 * 1000;
124010
124206
  var fullAutoInputWarningStash = new Map;
124011
124207
  function isExpired2(w, nowMs = Date.now()) {
@@ -124020,7 +124216,7 @@ function evictExpired() {
124020
124216
  if (isExpired2(w, now))
124021
124217
  fullAutoInputWarningStash.delete(sid);
124022
124218
  }
124023
- while (fullAutoInputWarningStash.size > MAX_TRACKED_SESSIONS3) {
124219
+ while (fullAutoInputWarningStash.size > MAX_TRACKED_SESSIONS4) {
124024
124220
  const firstKey = fullAutoInputWarningStash.keys().next().value;
124025
124221
  if (firstKey === undefined)
124026
124222
  break;
@@ -128939,6 +129135,77 @@ var complexity_hotspots = createSwarmTool({
128939
129135
  }
128940
129136
  });
128941
129137
 
129138
+ // src/tools/context-status.ts
129139
+ init_config();
129140
+ init_model_limits();
129141
+ init_utils2();
129142
+ init_state2();
129143
+ init_create_tool();
129144
+ var _internals93 = {
129145
+ loadPluginConfig,
129146
+ fetchSessionMessages: async (sessionID, directory, limit = 100) => {
129147
+ if (!swarmState.opencodeClient?.session)
129148
+ return null;
129149
+ try {
129150
+ const result = await swarmState.opencodeClient.session.messages({
129151
+ path: { id: sessionID },
129152
+ query: { directory, limit }
129153
+ });
129154
+ return result.data ?? null;
129155
+ } catch {
129156
+ return null;
129157
+ }
129158
+ }
129159
+ };
129160
+ function computeContextHeadroom(messages, warnThreshold = 0.7, criticalThreshold = 0.9, modelLimitsConfig = {}) {
129161
+ const { modelID, providerID } = extractModelInfo(messages);
129162
+ const modelLimit = resolveModelLimit(modelID, providerID, modelLimitsConfig);
129163
+ let totalTokens = 0;
129164
+ for (const message of messages) {
129165
+ if (!message?.parts)
129166
+ continue;
129167
+ for (const part of message.parts) {
129168
+ if (part?.type === "text" && part.text) {
129169
+ totalTokens += estimateTokens(part.text);
129170
+ }
129171
+ }
129172
+ }
129173
+ const usagePercent = totalTokens / modelLimit;
129174
+ let thresholdCrossed = "none";
129175
+ if (usagePercent > criticalThreshold) {
129176
+ thresholdCrossed = "critical";
129177
+ } else if (usagePercent > warnThreshold) {
129178
+ thresholdCrossed = "warn";
129179
+ }
129180
+ return {
129181
+ tokensUsed: totalTokens,
129182
+ modelLimit,
129183
+ usagePercent,
129184
+ thresholdCrossed,
129185
+ modelId: modelID ?? null,
129186
+ provider: providerID ?? null
129187
+ };
129188
+ }
129189
+ var context_status = createSwarmTool({
129190
+ description: "Report current context-window headroom for the active session. Returns tokens-used, model-limit, usage-percent, threshold-state (none/warn/critical), model name, and provider. Pure read-only — no state mutation, no warning injection. Works whether context_budget.enabled is true or false.",
129191
+ args: {},
129192
+ async execute(_args, directory, ctx) {
129193
+ const config3 = _internals93.loadPluginConfig(directory);
129194
+ const warnThreshold = config3.context_budget?.warn_threshold ?? 0.7;
129195
+ const criticalThreshold = config3.context_budget?.critical_threshold ?? 0.9;
129196
+ const modelLimitsConfig = config3.context_budget?.model_limits ?? {};
129197
+ let messages = [];
129198
+ if (ctx?.sessionID) {
129199
+ const sessionMessages = await _internals93.fetchSessionMessages(ctx.sessionID, directory);
129200
+ if (sessionMessages) {
129201
+ messages = sessionMessages;
129202
+ }
129203
+ }
129204
+ const headroom = computeContextHeadroom(messages, warnThreshold, criticalThreshold, modelLimitsConfig);
129205
+ return JSON.stringify(headroom, null, 2);
129206
+ }
129207
+ });
129208
+
128942
129209
  // src/tools/convene-council.ts
128943
129210
  init_zod();
128944
129211
  init_loader();
@@ -128970,7 +129237,7 @@ var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
128970
129237
  var COUNCIL_GATE_NAME = "council";
128971
129238
  var COUNCIL_AGENT_ID = "architect";
128972
129239
  var EvidenceFileSchema = exports_external.record(exports_external.string(), exports_external.unknown());
128973
- var _internals93 = {
129240
+ var _internals94 = {
128974
129241
  withTaskEvidenceLock
128975
129242
  };
128976
129243
  var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -129005,7 +129272,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
129005
129272
  const dir = join130(workingDir, EVIDENCE_DIR2);
129006
129273
  mkdirSync42(dir, { recursive: true });
129007
129274
  const filePath = taskEvidencePath(workingDir, synthesis.taskId);
129008
- await _internals93.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
129275
+ await _internals94.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
129009
129276
  const existingRoot = Object.create(null);
129010
129277
  if (existsSync93(filePath)) {
129011
129278
  try {
@@ -131525,7 +131792,7 @@ var CollectLaneResultsArgsSchema = exports_external.object({
131525
131792
  include_pending: exports_external.boolean().optional().describe("Include pending/running lanes in lane_results. Defaults to true for non-blocking polls and false for wait=true joins."),
131526
131793
  cancel_pending: exports_external.boolean().optional().describe("Abort and mark pending/running lanes cancelled")
131527
131794
  });
131528
- var _internals94 = {
131795
+ var _internals95 = {
131529
131796
  getSessionOps: () => swarmState.opencodeClient?.session ?? null,
131530
131797
  getGeneratedAgentNames: () => swarmState.generatedAgentNames,
131531
131798
  createParallelDispatcher,
@@ -131549,7 +131816,7 @@ async function executeDispatchLanes(args2, directory, context = {}) {
131549
131816
  errors: duplicateLaneIds.map((id) => `Duplicate lane id: ${id}`)
131550
131817
  });
131551
131818
  }
131552
- const session = _internals94.getSessionOps();
131819
+ const session = _internals95.getSessionOps();
131553
131820
  if (!session) {
131554
131821
  return failureResult({
131555
131822
  failure_class: "no_client",
@@ -131567,7 +131834,7 @@ async function executeDispatchLanes(args2, directory, context = {}) {
131567
131834
  const lanes = applyExplorerFormatSuffix(common.lanes);
131568
131835
  const maxConcurrent = Math.min(parsed.data.max_concurrent ?? lanes.length, lanes.length, MAX_LANES);
131569
131836
  const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS3;
131570
- const dispatcher = _internals94.createParallelDispatcher({
131837
+ const dispatcher = _internals95.createParallelDispatcher({
131571
131838
  enabled: true,
131572
131839
  maxConcurrentTasks: maxConcurrent,
131573
131840
  evidenceLockTimeoutMs: 0
@@ -131597,7 +131864,7 @@ async function executeDispatchLanesAsync(args2, directory, context = {}) {
131597
131864
  errors: duplicateLaneIds.map((id) => `Duplicate lane id: ${id}`)
131598
131865
  });
131599
131866
  }
131600
- const session = _internals94.getSessionOps();
131867
+ const session = _internals95.getSessionOps();
131601
131868
  if (!session || typeof session.promptAsync !== "function") {
131602
131869
  return asyncFailureResult({
131603
131870
  failure_class: "no_client",
@@ -131623,7 +131890,7 @@ async function executeDispatchLanesAsync(args2, directory, context = {}) {
131623
131890
  }
131624
131891
  const maxConcurrent = Math.min(parsed.data.max_concurrent ?? lanes.length, lanes.length, MAX_LANES);
131625
131892
  const launchTimeoutMs = parsed.data.launch_timeout_ms ?? parsed.data.timeout_ms ?? DEFAULT_ASYNC_LAUNCH_TIMEOUT_MS;
131626
- const dispatcher = _internals94.createParallelDispatcher({
131893
+ const dispatcher = _internals95.createParallelDispatcher({
131627
131894
  enabled: true,
131628
131895
  maxConcurrentTasks: maxConcurrent,
131629
131896
  evidenceLockTimeoutMs: 0
@@ -131671,7 +131938,7 @@ async function executeCollectLaneResults(args2, directory, context = {}) {
131671
131938
  errors: parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`)
131672
131939
  });
131673
131940
  }
131674
- const session = _internals94.getSessionOps();
131941
+ const session = _internals95.getSessionOps();
131675
131942
  if (!session || typeof session.messages !== "function") {
131676
131943
  return collectFailureResult({
131677
131944
  failure_class: "no_client",
@@ -131680,7 +131947,7 @@ async function executeCollectLaneResults(args2, directory, context = {}) {
131680
131947
  });
131681
131948
  }
131682
131949
  const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_COLLECT_TIMEOUT_MS;
131683
- const deadline = _internals94.now() + timeoutMs;
131950
+ const deadline = _internals95.now() + timeoutMs;
131684
131951
  const batchFilter = context.sessionID !== undefined ? { parentSessionId: context.sessionID } : undefined;
131685
131952
  let records = findByBatchId(directory, parsed.data.batch_id, batchFilter);
131686
131953
  if (records.length === 0) {
@@ -131700,11 +131967,11 @@ async function executeCollectLaneResults(args2, directory, context = {}) {
131700
131967
  keepPolling = false;
131701
131968
  continue;
131702
131969
  }
131703
- if (_internals94.now() >= deadline) {
131970
+ if (_internals95.now() >= deadline) {
131704
131971
  keepPolling = false;
131705
131972
  continue;
131706
131973
  }
131707
- await _internals94.sleep(Math.min(pollIntervalMs, Math.max(0, deadline - _internals94.now())));
131974
+ await _internals95.sleep(Math.min(pollIntervalMs, Math.max(0, deadline - _internals95.now())));
131708
131975
  pollIntervalMs = nextCollectPollInterval(pollIntervalMs);
131709
131976
  }
131710
131977
  return buildCollectResult(parsed.data.batch_id, records, parsed.data.include_pending ?? parsed.data.wait !== true);
@@ -131935,7 +132202,7 @@ async function isLaneReadyForCollection(session, directory, sessionId) {
131935
132202
  async function sweepStaleAsyncLaneRecords(session, directory, records, staleTimeoutMs) {
131936
132203
  if (staleTimeoutMs <= 0)
131937
132204
  return;
131938
- const now = _internals94.now();
132205
+ const now = _internals95.now();
131939
132206
  for (const record3 of records) {
131940
132207
  if (record3.status !== "pending" && record3.status !== "running" && record3.status !== "ingestion_error")
131941
132208
  continue;
@@ -132146,7 +132413,7 @@ function failedLane(lane, role, startedAt, error93, slotId, runId, sessionId) {
132146
132413
  };
132147
132414
  }
132148
132415
  function validateLaneAgent(agent, context) {
132149
- const generatedAgentNames = _internals94.getGeneratedAgentNames();
132416
+ const generatedAgentNames = _internals95.getGeneratedAgentNames();
132150
132417
  const role = resolveGeneratedAgentRole(agent, generatedAgentNames);
132151
132418
  if (!isKnownCanonicalRole(role)) {
132152
132419
  return {
@@ -132297,7 +132564,7 @@ function applyCommonPrompt(lanes, commonPrompt) {
132297
132564
  return { ok: true, lanes: merged };
132298
132565
  }
132299
132566
  function applyExplorerFormatSuffix(lanes) {
132300
- const generatedAgentNames = _internals94.getGeneratedAgentNames();
132567
+ const generatedAgentNames = _internals95.getGeneratedAgentNames();
132301
132568
  return lanes.map((lane) => {
132302
132569
  const role = resolveGeneratedAgentRole(lane.agent, generatedAgentNames);
132303
132570
  if (role !== "explorer")
@@ -132370,10 +132637,10 @@ function boundErrorString(text) {
132370
132637
  return `${text.slice(0, MAX_ERROR_CHARS)}${ERROR_TRUNCATION_SUFFIX}`;
132371
132638
  }
132372
132639
  function isoNow() {
132373
- return new Date(_internals94.now()).toISOString();
132640
+ return new Date(_internals95.now()).toISOString();
132374
132641
  }
132375
132642
  function makeBatchId() {
132376
- return `lanes-${_internals94.now().toString(36)}`;
132643
+ return `lanes-${_internals95.now().toString(36)}`;
132377
132644
  }
132378
132645
  function promptHash(lane, directory, batchId) {
132379
132646
  return digestText2(JSON.stringify({
@@ -132665,7 +132932,7 @@ function buildIsUpstreamCommittedWithStatus(directory, options) {
132665
132932
  const max = options?.maxCommits ?? MAX_LOG_COMMITS;
132666
132933
  let subjects;
132667
132934
  try {
132668
- subjects = _internals95.readGitLogSubjects(directory, max);
132935
+ subjects = _internals96.readGitLogSubjects(directory, max);
132669
132936
  } catch (err) {
132670
132937
  const msg = err instanceof Error ? err.message : String(err);
132671
132938
  criticalWarn(`[epic:upstream-commits] git log scan failed (degrading to permissive predicate, the activation gate may flip fail-closed): ${msg}`);
@@ -132687,7 +132954,7 @@ function buildIsUpstreamCommittedWithStatus(directory, options) {
132687
132954
  gitFailed: false
132688
132955
  };
132689
132956
  }
132690
- var _internals95 = {
132957
+ var _internals96 = {
132691
132958
  readGitLogSubjects: (cwd, max) => {
132692
132959
  return _internals4.gitExec(["log", "--no-merges", `--max-count=${max}`, "--pretty=%s"], cwd);
132693
132960
  }
@@ -133092,7 +133359,7 @@ function readPlanJson(directory) {
133092
133359
  }
133093
133360
  async function executeEpicPlanWaves(args2) {
133094
133361
  const { directory, phase, scopes } = args2;
133095
- const plan = _internals96.readPlanJson(directory);
133362
+ const plan = _internals97.readPlanJson(directory);
133096
133363
  if (!plan) {
133097
133364
  return {
133098
133365
  success: false,
@@ -133145,7 +133412,7 @@ async function executeEpicPlanWaves(args2) {
133145
133412
  try {
133146
133413
  const tasksMissingScope = [];
133147
133414
  for (const task of pendingTasks) {
133148
- const declaredScope = _internals96.readTaskScopes(directory, task.id);
133415
+ const declaredScope = _internals97.readTaskScopes(directory, task.id);
133149
133416
  const filesTouched = task.files_touched ?? [];
133150
133417
  const providedScope = scopes && task.id in scopes ? scopes[task.id] : null;
133151
133418
  if ((declaredScope === null || declaredScope.length === 0) && filesTouched.length === 0 && (providedScope === null || providedScope.length === 0)) {
@@ -133168,8 +133435,8 @@ async function executeEpicPlanWaves(args2) {
133168
133435
  };
133169
133436
  }
133170
133437
  let isUpstreamCommitted;
133171
- if (_internals96.isGitRepo(directory)) {
133172
- const evidence = _internals96.buildIsUpstreamCommittedWithStatus(directory);
133438
+ if (_internals97.isGitRepo(directory)) {
133439
+ const evidence = _internals97.buildIsUpstreamCommittedWithStatus(directory);
133173
133440
  if (evidence.gitFailed) {
133174
133441
  criticalWarn(`[epic_plan_waves] wave-planning blocked for directory=${directory} phase=${phase}: git log scan failed. Any prior promote verdict in .swarm/evidence/epic-promotions.jsonl for this phase is not backed by actual parallel execution.`);
133175
133442
  return {
@@ -133184,7 +133451,7 @@ async function executeEpicPlanWaves(args2) {
133184
133451
  }
133185
133452
  let leanConfig = { ...DEFAULT_LEAN_TURBO_CONFIG };
133186
133453
  try {
133187
- const loaded = await _internals96.loadPluginConfigWithMeta(directory);
133454
+ const loaded = await _internals97.loadPluginConfigWithMeta(directory);
133188
133455
  const userLean = loaded?.config?.turbo?.lean;
133189
133456
  if (userLean) {
133190
133457
  leanConfig = { ...leanConfig, ...userLean };
@@ -133208,7 +133475,7 @@ async function executeEpicPlanWaves(args2) {
133208
133475
  };
133209
133476
  }
133210
133477
  }
133211
- var _internals96 = {
133478
+ var _internals97 = {
133212
133479
  readPlanJson,
133213
133480
  readTaskScopes,
133214
133481
  isGitRepo: (cwd) => isGitRepo(cwd),
@@ -133240,7 +133507,7 @@ init_state2();
133240
133507
  init_divergence_recorder();
133241
133508
  init_logger();
133242
133509
  init_create_tool();
133243
- var _internals97 = {
133510
+ var _internals98 = {
133244
133511
  hasActiveEpicMode,
133245
133512
  getAgentSession,
133246
133513
  readScopeFromDisk,
@@ -133249,7 +133516,7 @@ var _internals97 = {
133249
133516
  };
133250
133517
  async function findPhaseForTask(directory, taskId) {
133251
133518
  try {
133252
- const plan = await _internals97.loadPlanJsonOnly(directory);
133519
+ const plan = await _internals98.loadPlanJsonOnly(directory);
133253
133520
  if (!plan)
133254
133521
  return;
133255
133522
  for (const phase of plan.phases) {
@@ -133262,20 +133529,20 @@ async function findPhaseForTask(directory, taskId) {
133262
133529
  }
133263
133530
  async function executeEpicRecordDivergence(args2) {
133264
133531
  const { directory, taskId, sessionID } = args2;
133265
- if (!_internals97.hasActiveEpicMode(sessionID)) {
133532
+ if (!_internals98.hasActiveEpicMode(sessionID)) {
133266
133533
  return { success: true, reason: "epic-mode-not-active" };
133267
133534
  }
133268
- const session = _internals97.getAgentSession(sessionID);
133535
+ const session = _internals98.getAgentSession(sessionID);
133269
133536
  if (!session) {
133270
133537
  return { success: true, reason: "no-session" };
133271
133538
  }
133272
- const declaredScope = _internals97.readScopeFromDisk(directory, taskId);
133539
+ const declaredScope = _internals98.readScopeFromDisk(directory, taskId);
133273
133540
  if (declaredScope === null) {
133274
133541
  return { success: true, reason: "no-scope" };
133275
133542
  }
133276
133543
  const actualFiles = session.modifiedFilesThisCoderTask ?? [];
133277
133544
  const phaseNumber = await findPhaseForTask(directory, taskId);
133278
- const result = _internals97.recordTaskDivergence({
133545
+ const result = _internals98.recordTaskDivergence({
133279
133546
  directory,
133280
133547
  sessionID,
133281
133548
  taskId,
@@ -133657,7 +133924,7 @@ init_state4();
133657
133924
 
133658
133925
  // src/turbo/lean/state-lock.ts
133659
133926
  init_file_locks();
133660
- var _internals98 = { tryAcquireLock };
133927
+ var _internals99 = { tryAcquireLock };
133661
133928
 
133662
133929
  class TurboStateLockTimeoutError extends Error {
133663
133930
  directory;
@@ -133685,7 +133952,7 @@ async function withTurboStateLock(directory, sessionID, fn2, timeoutMs = 30000)
133685
133952
  while (true) {
133686
133953
  let result;
133687
133954
  try {
133688
- result = await _internals98.tryAcquireLock(directory, lockPath, agent, sessionID);
133955
+ result = await _internals99.tryAcquireLock(directory, lockPath, agent, sessionID);
133689
133956
  } catch (acquireErr) {
133690
133957
  console.warn(`[lean-turbo] state lock acquisition error for ${sessionID} (${lockPath}), will retry: ${acquireErr instanceof Error ? acquireErr.message : String(acquireErr)}`);
133691
133958
  }
@@ -134432,7 +134699,7 @@ ${fileList}
134432
134699
  // src/tools/epic-run-phase.ts
134433
134700
  init_logger();
134434
134701
  init_create_tool();
134435
- var _internals99 = {
134702
+ var _internals100 = {
134436
134703
  loadPluginConfigWithMeta,
134437
134704
  loadPlanJsonOnly,
134438
134705
  getCoChangeData,
@@ -134454,13 +134721,13 @@ var _internals99 = {
134454
134721
  };
134455
134722
  async function executeEpicDecidePhase(args2) {
134456
134723
  const { directory, phase, sessionID } = args2;
134457
- if (!_internals99.isEpicModeActive(directory, sessionID)) {
134724
+ if (!_internals100.isEpicModeActive(directory, sessionID)) {
134458
134725
  return {
134459
134726
  success: false,
134460
134727
  reason: "epic-mode-not-active"
134461
134728
  };
134462
134729
  }
134463
- const plan = await _internals99.loadPlanJsonOnly(directory);
134730
+ const plan = await _internals100.loadPlanJsonOnly(directory);
134464
134731
  if (plan === null) {
134465
134732
  return { success: false, reason: "no-plan" };
134466
134733
  }
@@ -134490,7 +134757,7 @@ async function executeEpicDecidePhase(args2) {
134490
134757
  }
134491
134758
  const tasksMissingScope = [];
134492
134759
  for (const task of pendingTasks) {
134493
- const declaredScope = _internals99.readTaskScopes(directory, task.id);
134760
+ const declaredScope = _internals100.readTaskScopes(directory, task.id);
134494
134761
  const filesTouched = task.files_touched ?? [];
134495
134762
  if ((declaredScope === null || declaredScope.length === 0) && filesTouched.length === 0) {
134496
134763
  tasksMissingScope.push(task.id);
@@ -134510,7 +134777,7 @@ async function executeEpicDecidePhase(args2) {
134510
134777
  };
134511
134778
  }
134512
134779
  }
134513
- const { config: config3 } = _internals99.loadPluginConfigWithMeta(directory);
134780
+ const { config: config3 } = _internals100.loadPluginConfigWithMeta(directory);
134514
134781
  const modeCfg = config3.turbo?.epic?.mode;
134515
134782
  const cochangeCfg = config3.turbo?.epic?.cochange;
134516
134783
  const calibrationCfg = config3.turbo?.epic?.calibration;
@@ -134523,14 +134790,14 @@ async function executeEpicDecidePhase(args2) {
134523
134790
  let extraHotModules = [];
134524
134791
  if (calibrationEnabled) {
134525
134792
  try {
134526
- const currentCalibration = _internals99.loadCalibrationState(directory);
134793
+ const currentCalibration = _internals100.loadCalibrationState(directory);
134527
134794
  if (currentCalibration !== null) {
134528
- const history = _internals99.readDivergenceHistory(directory, {
134795
+ const history = _internals100.readDivergenceHistory(directory, {
134529
134796
  maxBytes: Number.POSITIVE_INFINITY
134530
134797
  });
134531
134798
  const newRecords = history.slice(currentCalibration.processedRecords);
134532
134799
  if (newRecords.length > 0) {
134533
- const updated = _internals99.applyCalibration(currentCalibration, newRecords, {
134800
+ const updated = _internals100.applyCalibration(currentCalibration, newRecords, {
134534
134801
  staticThreshold: staticActivationThreshold,
134535
134802
  floorThreshold: calibrationCfg?.floor_threshold,
134536
134803
  tightenStep: calibrationCfg?.tighten_step,
@@ -134539,17 +134806,17 @@ async function executeEpicDecidePhase(args2) {
134539
134806
  });
134540
134807
  let savedSuccessfully = false;
134541
134808
  try {
134542
- _internals99.saveCalibrationState(directory, updated);
134809
+ _internals100.saveCalibrationState(directory, updated);
134543
134810
  savedSuccessfully = true;
134544
134811
  } catch (err) {
134545
134812
  criticalWarn(`[epic_run_phase] calibration persist failed; ignoring this run's calibration delta to avoid drift on next run: ${err instanceof Error ? err.message : String(err)}`);
134546
134813
  }
134547
134814
  const sourceForThisRun = savedSuccessfully ? updated : currentCalibration;
134548
- effectiveThreshold = _internals99.effectiveActivationThreshold(staticActivationThreshold, sourceForThisRun);
134549
- extraHotModules = _internals99.effectiveHotModules([], sourceForThisRun);
134815
+ effectiveThreshold = _internals100.effectiveActivationThreshold(staticActivationThreshold, sourceForThisRun);
134816
+ extraHotModules = _internals100.effectiveHotModules([], sourceForThisRun);
134550
134817
  } else {
134551
- effectiveThreshold = _internals99.effectiveActivationThreshold(staticActivationThreshold, currentCalibration);
134552
- extraHotModules = _internals99.effectiveHotModules([], currentCalibration);
134818
+ effectiveThreshold = _internals100.effectiveActivationThreshold(staticActivationThreshold, currentCalibration);
134819
+ extraHotModules = _internals100.effectiveHotModules([], currentCalibration);
134553
134820
  }
134554
134821
  }
134555
134822
  } catch (err) {
@@ -134565,14 +134832,14 @@ async function executeEpicDecidePhase(args2) {
134565
134832
  }
134566
134833
  }
134567
134834
  const tasks = rawTasks.map((task) => {
134568
- const scopeFiles = _internals99.readTaskScopes(directory, task.id);
134835
+ const scopeFiles = _internals100.readTaskScopes(directory, task.id);
134569
134836
  const scope = scopeFiles ?? task.files_touched ?? [];
134570
134837
  return { id: task.id, scope };
134571
134838
  });
134572
- const { pairs, commitsObserved } = await _internals99.getCoChangeData(directory);
134839
+ const { pairs, commitsObserved } = await _internals100.getCoChangeData(directory);
134573
134840
  const isGitProject = (() => {
134574
134841
  try {
134575
- return _internals99.isGitRepo(directory);
134842
+ return _internals100.isGitRepo(directory);
134576
134843
  } catch {
134577
134844
  return false;
134578
134845
  }
@@ -134605,10 +134872,10 @@ async function executeEpicDecidePhase(args2) {
134605
134872
  const phantomDeps = [...phantomDepsSet];
134606
134873
  let isUpstreamCommitted;
134607
134874
  if (isGitProject) {
134608
- const evidence = _internals99.buildIsUpstreamCommittedWithStatus(directory);
134875
+ const evidence = _internals100.buildIsUpstreamCommittedWithStatus(directory);
134609
134876
  isUpstreamCommitted = evidence.gitFailed ? () => false : evidence.predicate;
134610
134877
  }
134611
- const verdict = _internals99.decideEpicActivation(tasks, pairs, commitsObserved, {
134878
+ const verdict = _internals100.decideEpicActivation(tasks, pairs, commitsObserved, {
134612
134879
  activationThreshold: effectiveThreshold,
134613
134880
  minCommitsForSignal,
134614
134881
  cochangeNpmiThreshold,
@@ -134620,7 +134887,7 @@ async function executeEpicDecidePhase(args2) {
134620
134887
  isUpstreamCommitted
134621
134888
  });
134622
134889
  try {
134623
- _internals99.appendPromotionEvidence(directory, {
134890
+ _internals100.appendPromotionEvidence(directory, {
134624
134891
  timestamp: new Date().toISOString(),
134625
134892
  sessionID,
134626
134893
  phase,
@@ -134630,7 +134897,7 @@ async function executeEpicDecidePhase(args2) {
134630
134897
  warn(`[epic_run_phase] promotion-evidence append failed: ${err instanceof Error ? err.message : String(err)}`);
134631
134898
  }
134632
134899
  try {
134633
- _internals99.recordEpicDecision(directory, sessionID, {
134900
+ _internals100.recordEpicDecision(directory, sessionID, {
134634
134901
  decidedAt: new Date().toISOString(),
134635
134902
  phase,
134636
134903
  decision: verdict.decision,
@@ -134927,7 +135194,7 @@ function candidateFilePath(storePath3, id) {
134927
135194
  }
134928
135195
  return path172.join(storePath3, `${id}.json`);
134929
135196
  }
134930
- var _internals100 = {
135197
+ var _internals101 = {
134931
135198
  randomUUID: crypto12.randomUUID.bind(crypto12),
134932
135199
  fs: {
134933
135200
  mkdir: fs106.mkdir,
@@ -134940,11 +135207,11 @@ var _internals100 = {
134940
135207
  function createExternalSkillStore(directory, config3) {
134941
135208
  const storePath3 = path172.join(directory, ".swarm", "skills", "candidates");
134942
135209
  async function add2(candidate) {
134943
- const id = _internals100.randomUUID();
135210
+ const id = _internals101.randomUUID();
134944
135211
  const full = { ...candidate, id };
134945
135212
  const filePath = path172.join(storePath3, `${id}.json`);
134946
- await _internals100.fs.mkdir(storePath3, { recursive: true });
134947
- await _internals100.atomicWriteFile(filePath, JSON.stringify(full, null, "\t"));
135213
+ await _internals101.fs.mkdir(storePath3, { recursive: true });
135214
+ await _internals101.atomicWriteFile(filePath, JSON.stringify(full, null, "\t"));
134948
135215
  return full;
134949
135216
  }
134950
135217
  async function get2(id) {
@@ -134954,7 +135221,7 @@ function createExternalSkillStore(directory, config3) {
134954
135221
  }
134955
135222
  let raw;
134956
135223
  try {
134957
- raw = await _internals100.fs.readFile(filePath, "utf-8");
135224
+ raw = await _internals101.fs.readFile(filePath, "utf-8");
134958
135225
  } catch (err) {
134959
135226
  if (err.code === "ENOENT") {
134960
135227
  return null;
@@ -134970,7 +135237,7 @@ function createExternalSkillStore(directory, config3) {
134970
135237
  async function list(filter) {
134971
135238
  let entries;
134972
135239
  try {
134973
- entries = await _internals100.fs.readdir(storePath3);
135240
+ entries = await _internals101.fs.readdir(storePath3);
134974
135241
  } catch (err) {
134975
135242
  if (err.code === "ENOENT") {
134976
135243
  return [];
@@ -134985,7 +135252,7 @@ function createExternalSkillStore(directory, config3) {
134985
135252
  const filePath = path172.join(storePath3, entry);
134986
135253
  let raw;
134987
135254
  try {
134988
- raw = await _internals100.fs.readFile(filePath, "utf-8");
135255
+ raw = await _internals101.fs.readFile(filePath, "utf-8");
134989
135256
  } catch {
134990
135257
  continue;
134991
135258
  }
@@ -135052,7 +135319,7 @@ function createExternalSkillStore(directory, config3) {
135052
135319
  ...patch.evaluation_history
135053
135320
  ];
135054
135321
  }
135055
- await _internals100.atomicWriteFile(filePath, JSON.stringify(updated, null, "\t"));
135322
+ await _internals101.atomicWriteFile(filePath, JSON.stringify(updated, null, "\t"));
135056
135323
  return updated;
135057
135324
  }
135058
135325
  async function deleteCandidate(id) {
@@ -135061,7 +135328,7 @@ function createExternalSkillStore(directory, config3) {
135061
135328
  return false;
135062
135329
  }
135063
135330
  try {
135064
- await _internals100.fs.unlink(filePath);
135331
+ await _internals101.fs.unlink(filePath);
135065
135332
  return true;
135066
135333
  } catch (err) {
135067
135334
  if (err.code === "ENOENT") {
@@ -135099,7 +135366,7 @@ function createExternalSkillStore(directory, config3) {
135099
135366
 
135100
135367
  // src/tools/external-skill-delete.ts
135101
135368
  init_create_tool();
135102
- var _internals101 = {
135369
+ var _internals102 = {
135103
135370
  loadConfig: (directory) => {
135104
135371
  const pluginConfig = loadPluginConfig(directory);
135105
135372
  return pluginConfig.external_skills;
@@ -135121,7 +135388,7 @@ var external_skill_delete = createSwarmTool({
135121
135388
  } catch {}
135122
135389
  let config3;
135123
135390
  try {
135124
- config3 = _internals101.loadConfig(directory);
135391
+ config3 = _internals102.loadConfig(directory);
135125
135392
  } catch {
135126
135393
  return JSON.stringify({
135127
135394
  success: false,
@@ -135589,7 +135856,7 @@ function scanProvenanceIntegrity(candidate, trustLevel = "low", ttlDays) {
135589
135856
  });
135590
135857
  }
135591
135858
  fieldsScanned.push("fetched_at");
135592
- const now = new Date(_internals102.getTimestamp()).getTime();
135859
+ const now = new Date(_internals103.getTimestamp()).getTime();
135593
135860
  const fetchedAtMs = new Date(candidate.fetched_at).getTime();
135594
135861
  if (Number.isNaN(fetchedAtMs)) {
135595
135862
  findings.push({
@@ -135653,7 +135920,7 @@ function scanProvenanceIntegrity(candidate, trustLevel = "low", ttlDays) {
135653
135920
  });
135654
135921
  }
135655
135922
  fieldsScanned.push("skill_body");
135656
- const computedHash = _internals102.computeSha256(candidate.skill_body);
135923
+ const computedHash = _internals103.computeSha256(candidate.skill_body);
135657
135924
  if (computedHash !== candidate.sha256) {
135658
135925
  findings.push({
135659
135926
  pattern: "content_hash_mismatch",
@@ -135703,7 +135970,7 @@ function evaluateCandidate(candidate, options) {
135703
135970
  risk_flags: riskFlags
135704
135971
  };
135705
135972
  }
135706
- var _internals102 = {
135973
+ var _internals103 = {
135707
135974
  getTimestamp: () => new Date().toISOString(),
135708
135975
  computeSha256: (content) => createHash21("sha256").update(content).digest("hex"),
135709
135976
  stripMarkdownCodeForUnsafeScan
@@ -135711,7 +135978,7 @@ var _internals102 = {
135711
135978
 
135712
135979
  // src/tools/external-skill-discover.ts
135713
135980
  init_create_tool();
135714
- var _internals103 = {
135981
+ var _internals104 = {
135715
135982
  fetchContent: async (_url3, _timeoutMs) => {
135716
135983
  const parsed = new URL(_url3);
135717
135984
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
@@ -135872,7 +136139,7 @@ var external_skill_discover = createSwarmTool({
135872
136139
  resolvedContent = content;
135873
136140
  } else {
135874
136141
  try {
135875
- const fetched = await _internals103.fetchContent(resolvedUrl, config3.fetch_timeout_ms);
136142
+ const fetched = await _internals104.fetchContent(resolvedUrl, config3.fetch_timeout_ms);
135876
136143
  if (fetched.finalUrl !== resolvedUrl && matchedSource && !isSubpathUrl(fetched.finalUrl, matchedSource.location)) {
135877
136144
  return JSON.stringify({
135878
136145
  success: false,
@@ -135894,14 +136161,14 @@ var external_skill_discover = createSwarmTool({
135894
136161
  error: `Content too large: ${resolvedContent.length} bytes exceeds max_bytes_per_candidate (${config3.max_bytes_per_candidate})`
135895
136162
  });
135896
136163
  }
135897
- const sha256 = _internals103.computeSha256(resolvedContent);
136164
+ const sha256 = _internals104.computeSha256(resolvedContent);
135898
136165
  const candidate = {
135899
- id: _internals103.uuid(),
136166
+ id: _internals104.uuid(),
135900
136167
  source_url: resolvedUrl,
135901
136168
  source_type: sourceType,
135902
136169
  publisher,
135903
136170
  sha256,
135904
- fetched_at: _internals103.getTimestamp(),
136171
+ fetched_at: _internals104.getTimestamp(),
135905
136172
  skill_name: typeof skillName === "string" ? skillName : undefined,
135906
136173
  skill_description: typeof skillDescription === "string" ? skillDescription : undefined,
135907
136174
  skill_body: resolvedContent,
@@ -135919,7 +136186,7 @@ var external_skill_discover = createSwarmTool({
135919
136186
  candidate.evaluation_history = [
135920
136187
  {
135921
136188
  verdict: result.overall_verdict,
135922
- timestamp: _internals103.getTimestamp(),
136189
+ timestamp: _internals104.getTimestamp(),
135923
136190
  actor: "system",
135924
136191
  reason: `Validation: ${result.gate_results.length} gates, ${result.all_findings.length} findings`,
135925
136192
  gate_results: result.gate_results.map((gr) => ({
@@ -135964,7 +136231,7 @@ var external_skill_discover = createSwarmTool({
135964
136231
  init_zod();
135965
136232
  init_loader();
135966
136233
  init_create_tool();
135967
- var _internals104 = {
136234
+ var _internals105 = {
135968
136235
  loadConfig: (directory) => {
135969
136236
  const pluginConfig = loadPluginConfig(directory);
135970
136237
  return pluginConfig.external_skills;
@@ -135986,7 +136253,7 @@ var external_skill_inspect = createSwarmTool({
135986
136253
  } catch {}
135987
136254
  let config3;
135988
136255
  try {
135989
- config3 = _internals104.loadConfig(directory);
136256
+ config3 = _internals105.loadConfig(directory);
135990
136257
  } catch {
135991
136258
  return JSON.stringify({
135992
136259
  success: false,
@@ -136028,7 +136295,7 @@ var external_skill_inspect = createSwarmTool({
136028
136295
  init_zod();
136029
136296
  init_loader();
136030
136297
  init_create_tool();
136031
- var _internals105 = {
136298
+ var _internals106 = {
136032
136299
  loadConfig: (directory) => {
136033
136300
  const pluginConfig = loadPluginConfig(directory);
136034
136301
  return pluginConfig.external_skills;
@@ -136064,7 +136331,7 @@ var external_skill_list = createSwarmTool({
136064
136331
  } catch {}
136065
136332
  let config3;
136066
136333
  try {
136067
- config3 = _internals105.loadConfig(directory);
136334
+ config3 = _internals106.loadConfig(directory);
136068
136335
  } catch {
136069
136336
  return JSON.stringify({
136070
136337
  success: false,
@@ -136117,7 +136384,7 @@ import { createHash as createHash23 } from "node:crypto";
136117
136384
  import * as fs107 from "node:fs/promises";
136118
136385
  import * as path173 from "node:path";
136119
136386
  init_create_tool();
136120
- var _internals106 = {
136387
+ var _internals107 = {
136121
136388
  loadConfig: (directory) => {
136122
136389
  const pluginConfig = loadPluginConfig(directory);
136123
136390
  return pluginConfig.external_skills;
@@ -136187,7 +136454,7 @@ var external_skill_promote = createSwarmTool({
136187
136454
  } catch {}
136188
136455
  let config3;
136189
136456
  try {
136190
- config3 = _internals106.loadConfig(directory);
136457
+ config3 = _internals107.loadConfig(directory);
136191
136458
  } catch {
136192
136459
  return JSON.stringify({
136193
136460
  success: false,
@@ -136257,8 +136524,8 @@ var external_skill_promote = createSwarmTool({
136257
136524
  }
136258
136525
  const targetDir = path173.join(directory, ".opencode", "skills", "generated", sanitizedSlug);
136259
136526
  const targetPath = path173.join(targetDir, "SKILL.md");
136260
- const timestamp = _internals106.getTimestamp();
136261
- const alreadyExists = await _internals106.fileExists(targetPath);
136527
+ const timestamp = _internals107.getTimestamp();
136528
+ const alreadyExists = await _internals107.fileExists(targetPath);
136262
136529
  if (alreadyExists) {
136263
136530
  return JSON.stringify({
136264
136531
  success: false,
@@ -136267,7 +136534,7 @@ var external_skill_promote = createSwarmTool({
136267
136534
  }
136268
136535
  const skillMarkdown = buildSkillMarkdown(candidate, sanitizedSlug, timestamp);
136269
136536
  try {
136270
- await _internals106.writeSkillFile(targetPath, skillMarkdown);
136537
+ await _internals107.writeSkillFile(targetPath, skillMarkdown);
136271
136538
  } catch (writeErr) {
136272
136539
  const writeError = writeErr;
136273
136540
  if (writeError?.code === "EEXIST") {
@@ -136344,7 +136611,7 @@ var external_skill_promote = createSwarmTool({
136344
136611
  init_zod();
136345
136612
  init_loader();
136346
136613
  init_create_tool();
136347
- var _internals107 = {
136614
+ var _internals108 = {
136348
136615
  loadConfig: (directory) => {
136349
136616
  const pluginConfig = loadPluginConfig(directory);
136350
136617
  return pluginConfig.external_skills;
@@ -136369,7 +136636,7 @@ var external_skill_reject = createSwarmTool({
136369
136636
  } catch {}
136370
136637
  let config3;
136371
136638
  try {
136372
- config3 = _internals107.loadConfig(directory);
136639
+ config3 = _internals108.loadConfig(directory);
136373
136640
  } catch {
136374
136641
  return JSON.stringify({
136375
136642
  success: false,
@@ -136432,7 +136699,7 @@ init_zod();
136432
136699
  init_loader();
136433
136700
  import * as path174 from "node:path";
136434
136701
  init_create_tool();
136435
- var _internals108 = {
136702
+ var _internals109 = {
136436
136703
  loadConfig: (directory) => {
136437
136704
  const pluginConfig = loadPluginConfig(directory);
136438
136705
  return pluginConfig.external_skills;
@@ -136483,7 +136750,7 @@ var external_skill_revoke = createSwarmTool({
136483
136750
  } catch {}
136484
136751
  let config3;
136485
136752
  try {
136486
- config3 = _internals108.loadConfig(directory);
136753
+ config3 = _internals109.loadConfig(directory);
136487
136754
  } catch {
136488
136755
  return JSON.stringify({
136489
136756
  success: false,
@@ -136530,8 +136797,8 @@ var external_skill_revoke = createSwarmTool({
136530
136797
  });
136531
136798
  }
136532
136799
  const skillPath = path174.join(directory, ".opencode", "skills", "generated", slug, "SKILL.md");
136533
- const skillFileRemoved = await _internals108.retireSkillFile(skillPath);
136534
- const timestamp = _internals108.getTimestamp();
136800
+ const skillFileRemoved = await _internals109.retireSkillFile(skillPath);
136801
+ const timestamp = _internals109.getTimestamp();
136535
136802
  const historyEntry = {
136536
136803
  verdict: "revoked",
136537
136804
  timestamp,
@@ -137050,7 +137317,7 @@ var ISSUE_FIELD_ALLOWLIST = new Set([
137050
137317
  "updatedAt"
137051
137318
  ]);
137052
137319
  function resolveGhBinary() {
137053
- return _internals109.resolveExecutableFromPath(["gh"]);
137320
+ return _internals110.resolveExecutableFromPath(["gh"]);
137054
137321
  }
137055
137322
  function normalizeRepo(value) {
137056
137323
  if (value === undefined || value === null || value === "")
@@ -137138,7 +137405,7 @@ var gh_evidence = createSwarmTool({
137138
137405
  if (!Array.isArray(fields)) {
137139
137406
  return JSON.stringify(fields, null, 2);
137140
137407
  }
137141
- const executable = _internals109.resolveGhBinary();
137408
+ const executable = _internals110.resolveGhBinary();
137142
137409
  if (!executable) {
137143
137410
  return JSON.stringify({
137144
137411
  error: true,
@@ -137150,7 +137417,7 @@ var gh_evidence = createSwarmTool({
137150
137417
  if (repo) {
137151
137418
  ghArgs.push("--repo", repo);
137152
137419
  }
137153
- const run = await _internals109.runExternalTool({
137420
+ const run = await _internals110.runExternalTool({
137154
137421
  executable,
137155
137422
  args: ghArgs,
137156
137423
  cwd: directory,
@@ -137201,7 +137468,7 @@ var gh_evidence = createSwarmTool({
137201
137468
  }, null, 2);
137202
137469
  }
137203
137470
  });
137204
- var _internals109 = {
137471
+ var _internals110 = {
137205
137472
  resolveExecutableFromPath,
137206
137473
  resolveGhBinary,
137207
137474
  runExternalTool
@@ -138704,7 +138971,7 @@ function formatHiveEntry(entry) {
138704
138971
  `);
138705
138972
  }
138706
138973
  var knowledge_query = createSwarmTool({
138707
- description: 'Query swarm knowledge (project-level) or hive knowledge (cross-project) with optional filters. Returns human-readable formatted text output. Use tier "all" to query both swarm and hive knowledge.',
138974
+ description: "Performs structured filter-based retrieval of swarm knowledge (project-level) or hive knowledge (cross-project). Returns formatted text for human inspection. This is the tool to use when the user knows the CATEGORY, STATUS, or SCORE they want to filter by. For semantic natural-language search, use `knowledge_recall` instead.",
138708
138975
  args: {
138709
138976
  tier: exports_external.string().optional().describe("Knowledge tier to query: 'swarm', 'hive', or 'all' (default: 'all')"),
138710
138977
  status: exports_external.string().optional().describe("Filter by status: 'candidate', 'established', 'promoted', or 'archived'"),
@@ -139211,7 +139478,7 @@ init_zod();
139211
139478
  init_config();
139212
139479
  init_state2();
139213
139480
  init_create_tool();
139214
- var _internals110 = {
139481
+ var _internals111 = {
139215
139482
  LeanTurboRunner,
139216
139483
  loadPluginConfigWithMeta
139217
139484
  };
@@ -139221,9 +139488,9 @@ async function executeLeanTurboRunPhase(args2) {
139221
139488
  let runError = null;
139222
139489
  let runner = null;
139223
139490
  try {
139224
- const { config: config3 } = _internals110.loadPluginConfigWithMeta(directory);
139491
+ const { config: config3 } = _internals111.loadPluginConfigWithMeta(directory);
139225
139492
  const leanConfig = config3.turbo?.strategy === "lean" ? config3.turbo.lean : undefined;
139226
- runner = new _internals110.LeanTurboRunner({
139493
+ runner = new _internals111.LeanTurboRunner({
139227
139494
  directory,
139228
139495
  sessionID,
139229
139496
  opencodeClient: swarmState.opencodeClient ?? null,
@@ -139559,7 +139826,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
139559
139826
  const strippedMutated = stripCode(mutatedCode);
139560
139827
  return strippedOriginal === strippedMutated;
139561
139828
  }
139562
- var _internals111 = {
139829
+ var _internals112 = {
139563
139830
  isStaticallyEquivalent,
139564
139831
  checkEquivalence,
139565
139832
  batchCheckEquivalence
@@ -139599,7 +139866,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
139599
139866
  const results = [];
139600
139867
  for (const { patch, originalCode, mutatedCode } of patches) {
139601
139868
  try {
139602
- const result = await _internals111.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
139869
+ const result = await _internals112.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
139603
139870
  results.push(result);
139604
139871
  } catch (err) {
139605
139872
  results.push({
@@ -139659,7 +139926,7 @@ function validateTestCommand(testCommand) {
139659
139926
  var MUTATION_TIMEOUT_MS = 30000;
139660
139927
  var TOTAL_BUDGET_MS = 300000;
139661
139928
  var GIT_APPLY_TIMEOUT_MS = 5000;
139662
- var _internals112 = {
139929
+ var _internals113 = {
139663
139930
  executeMutation,
139664
139931
  computeReport,
139665
139932
  executeMutationSuite,
@@ -139691,7 +139958,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
139691
139958
  };
139692
139959
  }
139693
139960
  try {
139694
- const applyResult = _internals112.spawnSync("git", ["apply", "--", patchFile], {
139961
+ const applyResult = _internals113.spawnSync("git", ["apply", "--", patchFile], {
139695
139962
  cwd: workingDir,
139696
139963
  timeout: GIT_APPLY_TIMEOUT_MS,
139697
139964
  stdio: "pipe"
@@ -139722,7 +139989,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
139722
139989
  try {
139723
139990
  const safeTestFiles = testFiles.filter((f) => !f.startsWith("-"));
139724
139991
  const testArgs = safeTestFiles.length > 0 ? [...testCommand.slice(1), ...safeTestFiles] : testCommand.slice(1);
139725
- const spawnResult = _internals112.spawnSync(testCommand[0], testArgs, {
139992
+ const spawnResult = _internals113.spawnSync(testCommand[0], testArgs, {
139726
139993
  cwd: workingDir,
139727
139994
  timeout: MUTATION_TIMEOUT_MS,
139728
139995
  stdio: "pipe"
@@ -139755,7 +140022,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
139755
140022
  } finally {
139756
140023
  if (patchFile) {
139757
140024
  try {
139758
- const revertResult = _internals112.spawnSync("git", ["apply", "-R", "--", patchFile], {
140025
+ const revertResult = _internals113.spawnSync("git", ["apply", "-R", "--", patchFile], {
139759
140026
  cwd: workingDir,
139760
140027
  timeout: GIT_APPLY_TIMEOUT_MS,
139761
140028
  stdio: "pipe"
@@ -139952,7 +140219,7 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
139952
140219
  }
139953
140220
 
139954
140221
  // src/mutation/gate.ts
139955
- var _internals113 = {
140222
+ var _internals114 = {
139956
140223
  evaluateMutationGate,
139957
140224
  buildTestImprovementPrompt,
139958
140225
  buildMessage
@@ -139973,8 +140240,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
139973
140240
  } else {
139974
140241
  verdict = "fail";
139975
140242
  }
139976
- const testImprovementPrompt = _internals113.buildTestImprovementPrompt(report, passThreshold, verdict);
139977
- const message = _internals113.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
140243
+ const testImprovementPrompt = _internals114.buildTestImprovementPrompt(report, passThreshold, verdict);
140244
+ const message = _internals114.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
139978
140245
  return {
139979
140246
  verdict,
139980
140247
  killRate: report.killRate,
@@ -140119,7 +140386,7 @@ var OSV_MAX_STDERR_BYTES = 256 * 1024;
140119
140386
  var DEFAULT_MAX_RESULTS3 = 200;
140120
140387
  var HARD_CAP_RESULTS3 = 2000;
140121
140388
  function resolveOsvScannerBinary() {
140122
- return _internals114.resolveExecutableFromPath(["osv-scanner"]);
140389
+ return _internals115.resolveExecutableFromPath(["osv-scanner"]);
140123
140390
  }
140124
140391
  function normalizeScanPath(value, workspace) {
140125
140392
  const raw = typeof value === "string" && value.trim() ? value.trim() : ".";
@@ -140207,7 +140474,7 @@ var osv_scan = createSwarmTool({
140207
140474
  }, null, 2);
140208
140475
  }
140209
140476
  const maxResults = sanitizeMaxResults2(obj.max_results);
140210
- const executable = _internals114.resolveOsvScannerBinary();
140477
+ const executable = _internals115.resolveOsvScannerBinary();
140211
140478
  if (!executable) {
140212
140479
  return JSON.stringify({
140213
140480
  error: true,
@@ -140217,7 +140484,7 @@ var osv_scan = createSwarmTool({
140217
140484
  }
140218
140485
  const target = scanPath === "." ? "." : `./${scanPath}`;
140219
140486
  const osvArgs = ["scan", "--format", "json", target];
140220
- const run = await _internals114.runExternalTool({
140487
+ const run = await _internals115.runExternalTool({
140221
140488
  executable,
140222
140489
  args: osvArgs,
140223
140490
  cwd: directory,
@@ -140267,7 +140534,7 @@ var osv_scan = createSwarmTool({
140267
140534
  }, null, 2);
140268
140535
  }
140269
140536
  });
140270
- var _internals114 = {
140537
+ var _internals115 = {
140271
140538
  resolveExecutableFromPath,
140272
140539
  resolveOsvScannerBinary,
140273
140540
  runExternalTool,
@@ -141964,7 +142231,7 @@ function listLaneEvidenceSync(directory, phase) {
141964
142231
  }
141965
142232
  return laneIds;
141966
142233
  }
141967
- var _internals115 = {
142234
+ var _internals116 = {
141968
142235
  listActiveLocks,
141969
142236
  readPersisted: readPersisted3,
141970
142237
  readPlanJson: defaultReadPlanJson,
@@ -142025,7 +142292,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142025
142292
  reason: "Lean Turbo state unreadable or missing"
142026
142293
  };
142027
142294
  }
142028
- const persisted = _internals115.readPersisted(directory);
142295
+ const persisted = _internals116.readPersisted(directory);
142029
142296
  if (!persisted) {
142030
142297
  return {
142031
142298
  ok: false,
@@ -142089,7 +142356,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142089
142356
  }
142090
142357
  }
142091
142358
  if (runState.lanes.length > 0) {
142092
- const evidenceLaneIds = new Set(_internals115.listLaneEvidenceSync(directory, phase));
142359
+ const evidenceLaneIds = new Set(_internals116.listLaneEvidenceSync(directory, phase));
142093
142360
  for (const lane of runState.lanes) {
142094
142361
  if ((lane.status === "completed" || lane.status === "failed") && !evidenceLaneIds.has(lane.laneId)) {
142095
142362
  return {
@@ -142099,7 +142366,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142099
142366
  }
142100
142367
  }
142101
142368
  }
142102
- const activeLocks = _internals115.listActiveLocks(directory);
142369
+ const activeLocks = _internals116.listActiveLocks(directory);
142103
142370
  const phaseLaneIds = new Set(laneIds);
142104
142371
  for (const lock of activeLocks) {
142105
142372
  if (lock.laneId && phaseLaneIds.has(lock.laneId)) {
@@ -142119,7 +142386,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142119
142386
  }
142120
142387
  const serialDegradedTasks = runState.degradedTasks.filter((dt) => !laneTaskIds.has(dt.taskId));
142121
142388
  if (serialDegradedTasks.length > 0) {
142122
- const plan = _internals115.readPlanJson(directory);
142389
+ const plan = _internals116.readPlanJson(directory);
142123
142390
  if (!plan) {
142124
142391
  return {
142125
142392
  ok: false,
@@ -142163,7 +142430,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142163
142430
  }
142164
142431
  const serializedTasks = runState.serializedTasks;
142165
142432
  if (Array.isArray(serializedTasks) && serializedTasks.length > 0) {
142166
- const plan = _internals115.readPlanJson(directory);
142433
+ const plan = _internals116.readPlanJson(directory);
142167
142434
  if (!plan) {
142168
142435
  return {
142169
142436
  ok: false,
@@ -142222,7 +142489,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142222
142489
  }
142223
142490
  let reviewerVerdict = runState.lastReviewerVerdict;
142224
142491
  if (!reviewerVerdict) {
142225
- const evidence = _internals115.readReviewerEvidence(directory, phase);
142492
+ const evidence = _internals116.readReviewerEvidence(directory, phase);
142226
142493
  reviewerVerdict = evidence?.verdict ?? undefined;
142227
142494
  }
142228
142495
  if (mergedConfig.phase_reviewer) {
@@ -142235,7 +142502,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
142235
142502
  }
142236
142503
  let criticVerdict = runState.lastCriticVerdict;
142237
142504
  if (!criticVerdict) {
142238
- const evidence = _internals115.readCriticEvidence(directory, phase);
142505
+ const evidence = _internals116.readCriticEvidence(directory, phase);
142239
142506
  criticVerdict = evidence?.verdict ?? undefined;
142240
142507
  }
142241
142508
  if (mergedConfig.phase_critic) {
@@ -143419,7 +143686,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
143419
143686
  phase_critic: leanConfig.phase_critic,
143420
143687
  integrated_diff_required: leanConfig.integrated_diff_required
143421
143688
  } : undefined;
143422
- const leanCheck = _internals115.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
143689
+ const leanCheck = _internals116.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
143423
143690
  if (!leanCheck.ok) {
143424
143691
  return JSON.stringify({
143425
143692
  success: false,
@@ -145816,11 +146083,11 @@ var quality_budget = createSwarmTool({
145816
146083
  }).optional().describe("Quality budget thresholds")
145817
146084
  },
145818
146085
  async execute(args2, directory) {
145819
- const result = await _internals117.qualityBudget(args2, directory);
146086
+ const result = await _internals118.qualityBudget(args2, directory);
145820
146087
  return JSON.stringify(result);
145821
146088
  }
145822
146089
  });
145823
- var _internals117 = {
146090
+ var _internals118 = {
145824
146091
  qualityBudget
145825
146092
  };
145826
146093
 
@@ -146545,7 +146812,7 @@ var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
146545
146812
  var DEFAULT_TIMEOUT_MS4 = 30000;
146546
146813
  var MAX_OUTPUT_BYTES8 = 10 * 1024 * 1024;
146547
146814
  var KILL_GRACE_MS = 2000;
146548
- var _internals118 = {
146815
+ var _internals119 = {
146549
146816
  isSemgrepAvailable,
146550
146817
  checkSemgrepAvailable,
146551
146818
  resetSemgrepCache,
@@ -146571,7 +146838,7 @@ function isSemgrepAvailable() {
146571
146838
  }
146572
146839
  }
146573
146840
  async function checkSemgrepAvailable() {
146574
- return _internals118.isSemgrepAvailable();
146841
+ return _internals119.isSemgrepAvailable();
146575
146842
  }
146576
146843
  function resetSemgrepCache() {
146577
146844
  semgrepAvailableCache = null;
@@ -146757,12 +147024,12 @@ async function runSemgrep(options) {
146757
147024
  const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS4;
146758
147025
  if (files.length === 0) {
146759
147026
  return {
146760
- available: _internals118.isSemgrepAvailable(),
147027
+ available: _internals119.isSemgrepAvailable(),
146761
147028
  findings: [],
146762
147029
  engine: "tier_a"
146763
147030
  };
146764
147031
  }
146765
- if (!_internals118.isSemgrepAvailable()) {
147032
+ if (!_internals119.isSemgrepAvailable()) {
146766
147033
  return {
146767
147034
  available: false,
146768
147035
  findings: [],
@@ -146929,7 +147196,7 @@ function assignOccurrenceIndices(findings, directory) {
146929
147196
  }
146930
147197
  const occIdx = countMap.get(baseKey) ?? 0;
146931
147198
  countMap.set(baseKey, occIdx + 1);
146932
- const fp = _internals119.fingerprintFinding(finding, directory, occIdx);
147199
+ const fp = _internals120.fingerprintFinding(finding, directory, occIdx);
146933
147200
  return {
146934
147201
  finding,
146935
147202
  index: occIdx,
@@ -146998,7 +147265,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
146998
147265
  }
146999
147266
  } catch {}
147000
147267
  const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
147001
- const indexed = _internals119.assignOccurrenceIndices(findings, directory);
147268
+ const indexed = _internals120.assignOccurrenceIndices(findings, directory);
147002
147269
  if (existing && !opts?.force) {
147003
147270
  const prunedFingerprints = existing.fingerprints.filter((fp) => {
147004
147271
  const relFile = fp.slice(0, fp.indexOf("|"));
@@ -147138,7 +147405,7 @@ function loadBaseline(directory, phase) {
147138
147405
  };
147139
147406
  }
147140
147407
  }
147141
- var _internals119 = {
147408
+ var _internals120 = {
147142
147409
  fingerprintFinding,
147143
147410
  assignOccurrenceIndices,
147144
147411
  captureOrMergeBaseline,
@@ -147548,11 +147815,11 @@ var sast_scan = createSwarmTool({
147548
147815
  capture_baseline: safeArgs.capture_baseline,
147549
147816
  phase: safeArgs.phase
147550
147817
  };
147551
- const result = await _internals120.sastScan(input, directory);
147818
+ const result = await _internals121.sastScan(input, directory);
147552
147819
  return JSON.stringify(result, null, 2);
147553
147820
  }
147554
147821
  });
147555
- var _internals120 = {
147822
+ var _internals121 = {
147556
147823
  sastScan,
147557
147824
  sast_scan
147558
147825
  };
@@ -151125,10 +151392,10 @@ function resolvePackagedRipgrep() {
151125
151392
  }
151126
151393
  }
151127
151394
  function resolveRipgrepBinary() {
151128
- return _internals121.resolvePackagedRipgrep() ?? _internals121.resolveExecutableFromPath(["rg"]);
151395
+ return _internals122.resolvePackagedRipgrep() ?? _internals122.resolveExecutableFromPath(["rg"]);
151129
151396
  }
151130
151397
  async function ripgrepSearch(opts) {
151131
- const rgPath = _internals121.resolveRipgrepBinary();
151398
+ const rgPath = _internals122.resolveRipgrepBinary();
151132
151399
  if (!rgPath) {
151133
151400
  return {
151134
151401
  error: true,
@@ -151151,7 +151418,7 @@ async function ripgrepSearch(opts) {
151151
151418
  args2.push("--fixed-strings");
151152
151419
  }
151153
151420
  args2.push("--", opts.query, ".");
151154
- const run = await _internals121.runExternalTool({
151421
+ const run = await _internals122.runExternalTool({
151155
151422
  executable: rgPath,
151156
151423
  args: args2,
151157
151424
  cwd: opts.workspace,
@@ -151455,7 +151722,7 @@ var search = createSwarmTool({
151455
151722
  }, null, 2);
151456
151723
  }
151457
151724
  let result;
151458
- if (_internals121.resolveRipgrepBinary()) {
151725
+ if (_internals122.resolveRipgrepBinary()) {
151459
151726
  result = await ripgrepSearch({
151460
151727
  query,
151461
151728
  mode,
@@ -151482,7 +151749,7 @@ var search = createSwarmTool({
151482
151749
  return JSON.stringify(result, null, 2);
151483
151750
  }
151484
151751
  });
151485
- var _internals121 = {
151752
+ var _internals122 = {
151486
151753
  resolvePackagedRipgrep,
151487
151754
  resolveExecutableFromPath,
151488
151755
  resolveRipgrepBinary,
@@ -151842,18 +152109,18 @@ var run_stale_reconciliation = createSwarmTool({
151842
152109
  if (typeof directory !== "string" || !directory) {
151843
152110
  return JSON.stringify({ found: 0, skills: [] }, null, 2);
151844
152111
  }
151845
- const archivedIds = await _internals122.getArchivedKnowledgeIds(directory);
152112
+ const archivedIds = await _internals123.getArchivedKnowledgeIds(directory);
151846
152113
  const archivedSet = new Set(archivedIds);
151847
152114
  const allKnownIds = new Set;
151848
- const swarmPath = _internals122.resolveSwarmKnowledgePath(directory);
151849
- const hivePath = _internals122.resolveHiveKnowledgePath();
152115
+ const swarmPath = _internals123.resolveSwarmKnowledgePath(directory);
152116
+ const hivePath = _internals123.resolveHiveKnowledgePath();
151850
152117
  try {
151851
- const swarmEntries = await _internals122.readKnowledge(swarmPath);
152118
+ const swarmEntries = await _internals123.readKnowledge(swarmPath);
151852
152119
  for (const e of swarmEntries)
151853
152120
  allKnownIds.add(e.id);
151854
152121
  } catch {}
151855
152122
  try {
151856
- const hiveEntries = await _internals122.readKnowledge(hivePath);
152123
+ const hiveEntries = await _internals123.readKnowledge(hivePath);
151857
152124
  for (const e of hiveEntries)
151858
152125
  allKnownIds.add(e.id);
151859
152126
  } catch {}
@@ -151862,9 +152129,9 @@ var run_stale_reconciliation = createSwarmTool({
151862
152129
  join165(directory, ".opencode", "skills", "generated"),
151863
152130
  join165(directory, ".swarm", "skills", "proposals")
151864
152131
  ]) {
151865
- if (!_internals122.existsSync(dir))
152132
+ if (!_internals123.existsSync(dir))
151866
152133
  continue;
151867
- const entries = await _internals122.readdir(dir, { withFileTypes: true });
152134
+ const entries = await _internals123.readdir(dir, { withFileTypes: true });
151868
152135
  for (const entry of entries) {
151869
152136
  if (entry.isDirectory()) {
151870
152137
  skillEntries.push({
@@ -151885,10 +152152,10 @@ var run_stale_reconciliation = createSwarmTool({
151885
152152
  const results = [];
151886
152153
  for (const { slug, path: path209, isProposal } of skillEntries) {
151887
152154
  const skillMdPath = isProposal ? path209 : join165(path209, "SKILL.md");
151888
- if (!_internals122.existsSync(skillMdPath))
152155
+ if (!_internals123.existsSync(skillMdPath))
151889
152156
  continue;
151890
- const content = await _internals122.readFile(skillMdPath, "utf-8");
151891
- const fm = _internals122.parseDraftFrontmatter(content);
152157
+ const content = await _internals123.readFile(skillMdPath, "utf-8");
152158
+ const fm = _internals123.parseDraftFrontmatter(content);
151892
152159
  const sourceIds = fm?.sourceKnowledgeIds ?? [];
151893
152160
  if (sourceIds.length === 0)
151894
152161
  continue;
@@ -151898,9 +152165,9 @@ var run_stale_reconciliation = createSwarmTool({
151898
152165
  if (args2.clear) {
151899
152166
  if (!isProposal) {
151900
152167
  const markerPath = join165(path209, "stale.marker");
151901
- if (_internals122.existsSync(markerPath)) {
152168
+ if (_internals123.existsSync(markerPath)) {
151902
152169
  try {
151903
- await _internals122.clearSkillStale(path209);
152170
+ await _internals123.clearSkillStale(path209);
151904
152171
  results.push({
151905
152172
  slug,
151906
152173
  reason: affected.join(", "),
@@ -151912,7 +152179,7 @@ var run_stale_reconciliation = createSwarmTool({
151912
152179
  } else {
151913
152180
  if (!isProposal) {
151914
152181
  try {
151915
- await _internals122.retireOrMarkStale(directory, path209, archivedSet);
152182
+ await _internals123.retireOrMarkStale(directory, path209, archivedSet);
151916
152183
  results.push({
151917
152184
  slug,
151918
152185
  reason: affected.join(", "),
@@ -151925,7 +152192,7 @@ var run_stale_reconciliation = createSwarmTool({
151925
152192
  return JSON.stringify({ found: results.length, skills: results }, null, 2);
151926
152193
  }
151927
152194
  });
151928
- var _internals122 = {
152195
+ var _internals123 = {
151929
152196
  run_stale_reconciliation,
151930
152197
  clearSkillStale,
151931
152198
  retireOrMarkStale,
@@ -152903,7 +153170,7 @@ var swarm_memory_propose = createSwarmTool({
152903
153170
  evidenceRefs: exports_external.array(exports_external.string().min(1).max(500)).max(20).optional().describe("Evidence refs such as files, commits, test outputs, or URLs")
152904
153171
  },
152905
153172
  execute: async (args2, directory, ctx) => {
152906
- const { config: config3 } = _internals123.loadPluginConfigWithMeta(directory);
153173
+ const { config: config3 } = _internals124.loadPluginConfigWithMeta(directory);
152907
153174
  if (config3.memory?.enabled !== true) {
152908
153175
  return JSON.stringify({
152909
153176
  success: false,
@@ -152919,7 +153186,7 @@ var swarm_memory_propose = createSwarmTool({
152919
153186
  });
152920
153187
  }
152921
153188
  const agent = getContextAgent3(ctx);
152922
- const gateway = _internals123.createMemoryGateway({
153189
+ const gateway = _internals124.createMemoryGateway({
152923
153190
  directory,
152924
153191
  sessionID: ctx?.sessionID,
152925
153192
  agentRole: agent,
@@ -152944,7 +153211,7 @@ var swarm_memory_propose = createSwarmTool({
152944
153211
  }
152945
153212
  }
152946
153213
  });
152947
- var _internals123 = {
153214
+ var _internals124 = {
152948
153215
  loadPluginConfigWithMeta,
152949
153216
  createMemoryGateway
152950
153217
  };
@@ -152982,7 +153249,7 @@ var swarm_memory_recall = createSwarmTool({
152982
153249
  maxItems: exports_external.number().int().min(1).max(20).optional().describe("Maximum memories to return")
152983
153250
  },
152984
153251
  execute: async (args2, directory, ctx) => {
152985
- const { config: config3 } = _internals124.loadPluginConfigWithMeta(directory);
153252
+ const { config: config3 } = _internals125.loadPluginConfigWithMeta(directory);
152986
153253
  if (config3.memory?.enabled !== true) {
152987
153254
  return JSON.stringify({
152988
153255
  success: false,
@@ -152998,7 +153265,7 @@ var swarm_memory_recall = createSwarmTool({
152998
153265
  });
152999
153266
  }
153000
153267
  const agent = getContextAgent4(ctx);
153001
- const gateway = _internals124.createMemoryGateway({
153268
+ const gateway = _internals125.createMemoryGateway({
153002
153269
  directory,
153003
153270
  sessionID: ctx?.sessionID,
153004
153271
  agentRole: agent,
@@ -153031,7 +153298,7 @@ var RecallArgsSchema = exports_external.object({
153031
153298
  kinds: exports_external.array(exports_external.enum(MEMORY_KINDS2)).optional(),
153032
153299
  maxItems: exports_external.number().int().min(1).max(20).optional()
153033
153300
  });
153034
- var _internals124 = {
153301
+ var _internals125 = {
153035
153302
  loadPluginConfigWithMeta,
153036
153303
  createMemoryGateway
153037
153304
  };
@@ -153557,7 +153824,7 @@ import * as path214 from "node:path";
153557
153824
  init_bun_compat();
153558
153825
  import * as fs138 from "node:fs";
153559
153826
  import * as path213 from "node:path";
153560
- var _internals125 = { bunSpawn };
153827
+ var _internals126 = { bunSpawn };
153561
153828
  var _swarmGitExcludedChecked = false;
153562
153829
  function fileCoversSwarm(content) {
153563
153830
  for (const rawLine of content.split(`
@@ -153590,7 +153857,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
153590
153857
  checkIgnoreExitCode
153591
153858
  ] = await Promise.all([
153592
153859
  (async () => {
153593
- const proc = _internals125.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
153860
+ const proc = _internals126.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
153594
153861
  try {
153595
153862
  return await Promise.all([proc.exited, proc.stdout.text()]);
153596
153863
  } finally {
@@ -153600,7 +153867,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
153600
153867
  }
153601
153868
  })(),
153602
153869
  (async () => {
153603
- const proc = _internals125.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
153870
+ const proc = _internals126.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
153604
153871
  try {
153605
153872
  return await Promise.all([proc.exited, proc.stdout.text()]);
153606
153873
  } finally {
@@ -153610,7 +153877,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
153610
153877
  }
153611
153878
  })(),
153612
153879
  (async () => {
153613
- const proc = _internals125.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
153880
+ const proc = _internals126.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
153614
153881
  try {
153615
153882
  return await proc.exited;
153616
153883
  } finally {
@@ -153649,7 +153916,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
153649
153916
  }
153650
153917
  } catch {}
153651
153918
  }
153652
- const trackedProc = _internals125.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
153919
+ const trackedProc = _internals126.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
153653
153920
  let trackedExitCode;
153654
153921
  let trackedOutput;
153655
153922
  try {
@@ -153674,7 +153941,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
153674
153941
  }
153675
153942
 
153676
153943
  // src/hooks/diff-scope.ts
153677
- var _internals126 = { bunSpawn };
153944
+ var _internals127 = { bunSpawn };
153678
153945
  function getDeclaredScope(taskId, directory) {
153679
153946
  try {
153680
153947
  const planPath = path214.join(directory, ".swarm", "plan.json");
@@ -153709,7 +153976,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
153709
153976
  };
153710
153977
  async function getChangedFiles2(directory) {
153711
153978
  try {
153712
- const proc = _internals126.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
153979
+ const proc = _internals127.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
153713
153980
  cwd: directory,
153714
153981
  ...GIT_DIFF_SPAWN_OPTIONS
153715
153982
  });
@@ -153726,7 +153993,7 @@ async function getChangedFiles2(directory) {
153726
153993
  return stdout.trim().split(`
153727
153994
  `).map((f) => f.trim()).filter((f) => f.length > 0);
153728
153995
  }
153729
- const proc2 = _internals126.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
153996
+ const proc2 = _internals127.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
153730
153997
  cwd: directory,
153731
153998
  ...GIT_DIFF_SPAWN_OPTIONS
153732
153999
  });
@@ -153784,7 +154051,7 @@ init_telemetry();
153784
154051
  init_file_locks();
153785
154052
  import * as fs140 from "node:fs";
153786
154053
  import * as path215 from "node:path";
153787
- var _internals127 = {
154054
+ var _internals128 = {
153788
154055
  listActiveLocks,
153789
154056
  verifyLeanTurboTaskCompletion
153790
154057
  };
@@ -153926,7 +154193,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
153926
154193
  }
153927
154194
  };
153928
154195
  }
153929
- const activeLocks = _internals127.listActiveLocks(directory);
154196
+ const activeLocks = _internals128.listActiveLocks(directory);
153930
154197
  const laneLocks = activeLocks.filter((lock) => lock.laneId === lane.laneId);
153931
154198
  if (laneLocks.length > 0) {
153932
154199
  return {
@@ -153993,7 +154260,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
153993
154260
  init_task_id();
153994
154261
  init_create_tool();
153995
154262
  init_resolve_working_directory();
153996
- var _internals128 = {
154263
+ var _internals129 = {
153997
154264
  tryAcquireLock,
153998
154265
  updateTaskStatus,
153999
154266
  resolveWorkingDirectory
@@ -154090,7 +154357,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
154090
154357
  }
154091
154358
  let resolvedDir;
154092
154359
  if (fallbackDir) {
154093
- const resolveResult = _internals128.resolveWorkingDirectory(workingDirectory, fallbackDir);
154360
+ const resolveResult = _internals129.resolveWorkingDirectory(workingDirectory, fallbackDir);
154094
154361
  if (resolveResult.success) {
154095
154362
  resolvedDir = resolveResult.directory;
154096
154363
  } else {
@@ -154437,7 +154704,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
154437
154704
  }
154438
154705
  }
154439
154706
  let directory;
154440
- const resolveResult = _internals128.resolveWorkingDirectory(args2.working_directory, fallbackDir);
154707
+ const resolveResult = _internals129.resolveWorkingDirectory(args2.working_directory, fallbackDir);
154441
154708
  if (!resolveResult.success) {
154442
154709
  return {
154443
154710
  success: false,
@@ -154530,7 +154797,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
154530
154797
  }
154531
154798
  let lockResult;
154532
154799
  try {
154533
- lockResult = await _internals128.tryAcquireLock(directory, planFilePath, agentName, lockTaskId);
154800
+ lockResult = await _internals129.tryAcquireLock(directory, planFilePath, agentName, lockTaskId);
154534
154801
  } catch (error93) {
154535
154802
  return {
154536
154803
  success: false,
@@ -154549,7 +154816,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
154549
154816
  };
154550
154817
  }
154551
154818
  try {
154552
- const updatedPlan = await _internals128.updateTaskStatus(directory, args2.task_id, args2.status);
154819
+ const updatedPlan = await _internals129.updateTaskStatus(directory, args2.task_id, args2.status);
154553
154820
  if (args2.status === "completed") {
154554
154821
  for (const [_sessionId, session] of swarmState.agentSessions) {
154555
154822
  if (!(session.taskWorkflowStates instanceof Map)) {
@@ -155204,7 +155471,7 @@ var web_fetch = createSwarmTool({
155204
155471
  };
155205
155472
  return JSON.stringify(fail, null, 2);
155206
155473
  }
155207
- const config3 = _internals129.loadPluginConfig(dirResult.directory);
155474
+ const config3 = _internals130.loadPluginConfig(dirResult.directory);
155208
155475
  const generalConfig = config3.council?.general;
155209
155476
  if (!generalConfig || generalConfig.enabled !== true) {
155210
155477
  const fail = {
@@ -155214,7 +155481,7 @@ var web_fetch = createSwarmTool({
155214
155481
  };
155215
155482
  return JSON.stringify(fail, null, 2);
155216
155483
  }
155217
- const validated = await validateFetchUrl(parsed.data.url, _internals129.dnsLookup);
155484
+ const validated = await validateFetchUrl(parsed.data.url, _internals130.dnsLookup);
155218
155485
  if (!validated.ok) {
155219
155486
  const fail = {
155220
155487
  success: false,
@@ -155225,7 +155492,7 @@ var web_fetch = createSwarmTool({
155225
155492
  }
155226
155493
  const maxBytes = parsed.data.max_bytes ?? DEFAULT_MAX_BYTES;
155227
155494
  const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS5;
155228
- const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs, _internals129);
155495
+ const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs, _internals130);
155229
155496
  if (!result.ok) {
155230
155497
  const fail = {
155231
155498
  success: false,
@@ -155260,7 +155527,7 @@ var web_fetch = createSwarmTool({
155260
155527
  });
155261
155528
  async function captureFetchEvidence(directory, url3, title, text) {
155262
155529
  try {
155263
- const written = await _internals129.writeEvidenceDocuments(directory, [
155530
+ const written = await _internals130.writeEvidenceDocuments(directory, [
155264
155531
  {
155265
155532
  sourceType: "crawl",
155266
155533
  url: url3,
@@ -155281,7 +155548,7 @@ async function captureFetchEvidence(directory, url3, title, text) {
155281
155548
  };
155282
155549
  }
155283
155550
  }
155284
- var _internals129 = {
155551
+ var _internals130 = {
155285
155552
  httpRequest: performHttpRequest,
155286
155553
  dnsLookup: lookup,
155287
155554
  loadPluginConfig,
@@ -155595,7 +155862,7 @@ var web_search = createSwarmTool({
155595
155862
  });
155596
155863
  async function captureSearchEvidence(directory, query, results) {
155597
155864
  try {
155598
- const written = await _internals130.writeEvidenceDocuments(directory, results.map((result) => ({
155865
+ const written = await _internals131.writeEvidenceDocuments(directory, results.map((result) => ({
155599
155866
  sourceType: "web_search",
155600
155867
  query,
155601
155868
  title: result.title,
@@ -155623,7 +155890,7 @@ async function captureSearchEvidence(directory, query, results) {
155623
155890
  };
155624
155891
  }
155625
155892
  }
155626
- var _internals130 = {
155893
+ var _internals131 = {
155627
155894
  writeEvidenceDocuments
155628
155895
  };
155629
155896
 
@@ -155756,22 +156023,56 @@ var write_architecture_supervisor_evidence = createSwarmTool({
155756
156023
  // src/tools/write-drift-evidence.ts
155757
156024
  init_zod();
155758
156025
  init_qa_gate_profile();
155759
- init_utils2();
155760
- init_ledger();
155761
- init_manager();
155762
- init_create_tool();
155763
156026
  import fs142 from "node:fs";
155764
156027
  import path219 from "node:path";
155765
- function normalizeVerdict(verdict) {
156028
+
156029
+ // src/evidence/normalize-verdict.ts
156030
+ function normalizeVerdict2(verdict) {
156031
+ if (!LIVE_VERDICT_SET_2.includes(verdict)) {
156032
+ throw new Error(`Invalid verdict: must be 'APPROVED' or 'NEEDS_REVISION', got '${verdict}'`);
156033
+ }
155766
156034
  switch (verdict) {
155767
156035
  case "APPROVED":
155768
156036
  return "approved";
155769
156037
  case "NEEDS_REVISION":
155770
156038
  return "rejected";
155771
156039
  default:
155772
- throw new Error(`Invalid verdict: must be 'APPROVED' or 'NEEDS_REVISION', got '${verdict}'`);
156040
+ return verdict.toLowerCase();
156041
+ }
156042
+ }
156043
+ function normalizeVerdict4(verdict) {
156044
+ if (!LIVE_VERDICT_SET_4.includes(verdict)) {
156045
+ throw new Error(`Invalid verdict: must be 'PASS', 'WARN', 'FAIL', or 'SKIP', got '${verdict}'`);
156046
+ }
156047
+ switch (verdict) {
156048
+ case "PASS":
156049
+ return "pass";
156050
+ case "WARN":
156051
+ return "warn";
156052
+ case "FAIL":
156053
+ return "fail";
156054
+ case "SKIP":
156055
+ return "skip";
156056
+ default:
156057
+ return verdict.toLowerCase();
155773
156058
  }
155774
156059
  }
156060
+ var LIVE_VERDICT_SET_2 = ["APPROVED", "NEEDS_REVISION"];
156061
+ var LIVE_VERDICT_SET_4 = ["PASS", "WARN", "FAIL", "SKIP"];
156062
+ var VERDICT_SET_2 = LIVE_VERDICT_SET_2;
156063
+ var VERDICT_SET_4 = LIVE_VERDICT_SET_4;
156064
+ function isAcceptedVerdict2(v) {
156065
+ return LIVE_VERDICT_SET_2.includes(v);
156066
+ }
156067
+ function isAcceptedVerdict4(v) {
156068
+ return LIVE_VERDICT_SET_4.includes(v);
156069
+ }
156070
+
156071
+ // src/tools/write-drift-evidence.ts
156072
+ init_utils2();
156073
+ init_ledger();
156074
+ init_manager();
156075
+ init_create_tool();
155775
156076
  async function executeWriteDriftEvidence(args2, directory) {
155776
156077
  const phase = args2.phase;
155777
156078
  if (!Number.isInteger(phase) || phase < 1) {
@@ -155781,8 +156082,7 @@ async function executeWriteDriftEvidence(args2, directory) {
155781
156082
  message: "Invalid phase: must be a positive integer"
155782
156083
  }, null, 2);
155783
156084
  }
155784
- const validVerdicts = ["APPROVED", "NEEDS_REVISION"];
155785
- if (!validVerdicts.includes(args2.verdict)) {
156085
+ if (!isAcceptedVerdict2(args2.verdict)) {
155786
156086
  return JSON.stringify({
155787
156087
  success: false,
155788
156088
  phase,
@@ -155797,7 +156097,7 @@ async function executeWriteDriftEvidence(args2, directory) {
155797
156097
  message: "Invalid summary: must be a non-empty string"
155798
156098
  }, null, 2);
155799
156099
  }
155800
- const normalizedVerdict = normalizeVerdict(args2.verdict);
156100
+ const normalizedVerdict = _internals132.normalizeVerdict2(args2.verdict);
155801
156101
  const provenance = args2.provenanceAgentName || args2.provenanceSessionId ? {
155802
156102
  agent_name: args2.provenanceAgentName,
155803
156103
  session_id: args2.provenanceSessionId,
@@ -155894,11 +156194,16 @@ async function executeWriteDriftEvidence(args2, directory) {
155894
156194
  }, null, 2);
155895
156195
  }
155896
156196
  }
156197
+ var _internals132 = {
156198
+ normalizeVerdict2,
156199
+ VERDICT_SET_2,
156200
+ isAcceptedVerdict2
156201
+ };
155897
156202
  var write_drift_evidence = createSwarmTool({
155898
156203
  description: "Write drift verification evidence for a completed phase. " + "Normalizes verdict (APPROVED->approved, NEEDS_REVISION->rejected) and writes " + "a gate-contract formatted EvidenceBundle to .swarm/evidence/{phase}/drift-verifier.json. " + "Use this after critic_drift_verifier delegation to persist the verification result.",
155899
156204
  args: {
155900
156205
  phase: exports_external.number().int().min(1).describe("The phase number for the drift verification (e.g., 1, 2, 3)"),
155901
- verdict: exports_external.enum(["APPROVED", "NEEDS_REVISION"]).describe("Verdict of the drift verification: 'APPROVED' or 'NEEDS_REVISION'"),
156206
+ verdict: exports_external.enum(VERDICT_SET_2).describe("Verdict of the drift verification: 'APPROVED' or 'NEEDS_REVISION'"),
155902
156207
  summary: exports_external.string().describe("Human-readable summary of the drift verification"),
155903
156208
  requirementCoverage: exports_external.string().optional().describe("Requirement coverage report from req_coverage tool (JSON string)"),
155904
156209
  provenanceAgentName: exports_external.string().min(1).optional().describe("Agent name that produced this evidence (optional provenance)"),
@@ -156118,20 +156423,10 @@ var write_final_council_evidence = createSwarmTool({
156118
156423
 
156119
156424
  // src/tools/write-hallucination-evidence.ts
156120
156425
  init_zod();
156121
- init_utils2();
156122
- init_create_tool();
156123
156426
  import fs144 from "node:fs";
156124
156427
  import path221 from "node:path";
156125
- function normalizeVerdict2(verdict) {
156126
- switch (verdict) {
156127
- case "APPROVED":
156128
- return "approved";
156129
- case "NEEDS_REVISION":
156130
- return "rejected";
156131
- default:
156132
- throw new Error(`Invalid verdict: must be 'APPROVED' or 'NEEDS_REVISION', got '${verdict}'`);
156133
- }
156134
- }
156428
+ init_utils2();
156429
+ init_create_tool();
156135
156430
  async function executeWriteHallucinationEvidence(args2, directory) {
156136
156431
  const phase = args2.phase;
156137
156432
  if (!Number.isInteger(phase) || phase < 1) {
@@ -156141,8 +156436,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
156141
156436
  message: "Invalid phase: must be a positive integer"
156142
156437
  }, null, 2);
156143
156438
  }
156144
- const validVerdicts = ["APPROVED", "NEEDS_REVISION"];
156145
- if (!validVerdicts.includes(args2.verdict)) {
156439
+ if (!isAcceptedVerdict2(args2.verdict)) {
156146
156440
  return JSON.stringify({
156147
156441
  success: false,
156148
156442
  phase,
@@ -156157,7 +156451,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
156157
156451
  message: "Invalid summary: must be a non-empty string"
156158
156452
  }, null, 2);
156159
156453
  }
156160
- const normalizedVerdict = normalizeVerdict2(args2.verdict);
156454
+ const normalizedVerdict = _internals133.normalizeVerdict2(args2.verdict);
156161
156455
  const evidenceEntry = {
156162
156456
  type: "hallucination-verification",
156163
156457
  verdict: normalizedVerdict,
@@ -156200,11 +156494,16 @@ async function executeWriteHallucinationEvidence(args2, directory) {
156200
156494
  }, null, 2);
156201
156495
  }
156202
156496
  }
156497
+ var _internals133 = {
156498
+ normalizeVerdict2,
156499
+ VERDICT_SET_2,
156500
+ isAcceptedVerdict2
156501
+ };
156203
156502
  var write_hallucination_evidence = createSwarmTool({
156204
156503
  description: "Write hallucination verification evidence for a completed phase. " + "Normalizes verdict (APPROVED->approved, NEEDS_REVISION->rejected) and writes " + "a gate-contract formatted EvidenceBundle to .swarm/evidence/{phase}/hallucination-guard.json. " + "Use this after critic_hallucination_verifier delegation to persist the verification result. " + "Unlike write_drift_evidence, this tool does NOT lock the QA gate profile.",
156205
156504
  args: {
156206
156505
  phase: exports_external.number().int().min(1).describe("The phase number for the hallucination verification (e.g., 1, 2, 3)"),
156207
- verdict: exports_external.enum(["APPROVED", "NEEDS_REVISION"]).describe("Verdict of the hallucination verification: 'APPROVED' or 'NEEDS_REVISION'"),
156506
+ verdict: exports_external.enum(VERDICT_SET_2).describe("Verdict of the hallucination verification: 'APPROVED' or 'NEEDS_REVISION'"),
156208
156507
  summary: exports_external.string().describe("Human-readable summary of the hallucination verification"),
156209
156508
  findings: exports_external.string().optional().describe("Optional bullet list of FABRICATED/DRIFTED/UNSUPPORTED/BROKEN findings (for NEEDS_REVISION)")
156210
156509
  },
@@ -156230,24 +156529,10 @@ var write_hallucination_evidence = createSwarmTool({
156230
156529
 
156231
156530
  // src/tools/write-mutation-evidence.ts
156232
156531
  init_zod();
156233
- init_utils2();
156234
- init_create_tool();
156235
156532
  import fs145 from "node:fs";
156236
156533
  import path222 from "node:path";
156237
- function normalizeVerdict3(verdict) {
156238
- switch (verdict) {
156239
- case "PASS":
156240
- return "pass";
156241
- case "WARN":
156242
- return "warn";
156243
- case "FAIL":
156244
- return "fail";
156245
- case "SKIP":
156246
- return "skip";
156247
- default:
156248
- throw new Error(`Invalid verdict: must be 'PASS', 'WARN', 'FAIL', or 'SKIP', got '${verdict}'`);
156249
- }
156250
- }
156534
+ init_utils2();
156535
+ init_create_tool();
156251
156536
  async function executeWriteMutationEvidence(args2, directory) {
156252
156537
  const phase = args2.phase;
156253
156538
  if (!Number.isInteger(phase) || phase < 1) {
@@ -156257,8 +156542,7 @@ async function executeWriteMutationEvidence(args2, directory) {
156257
156542
  message: "Invalid phase: must be a positive integer"
156258
156543
  }, null, 2);
156259
156544
  }
156260
- const validVerdicts = ["PASS", "WARN", "FAIL", "SKIP"];
156261
- if (!validVerdicts.includes(args2.verdict)) {
156545
+ if (!isAcceptedVerdict4(args2.verdict)) {
156262
156546
  return JSON.stringify({
156263
156547
  success: false,
156264
156548
  phase,
@@ -156291,7 +156575,7 @@ async function executeWriteMutationEvidence(args2, directory) {
156291
156575
  message: "Invalid summary: must be a non-empty string"
156292
156576
  }, null, 2);
156293
156577
  }
156294
- const normalizedVerdict = normalizeVerdict3(args2.verdict);
156578
+ const normalizedVerdict = _internals134.normalizeVerdict4(args2.verdict);
156295
156579
  const evidenceEntry = {
156296
156580
  type: "mutation-gate",
156297
156581
  verdict: normalizedVerdict,
@@ -156338,11 +156622,16 @@ async function executeWriteMutationEvidence(args2, directory) {
156338
156622
  }, null, 2);
156339
156623
  }
156340
156624
  }
156625
+ var _internals134 = {
156626
+ normalizeVerdict4,
156627
+ VERDICT_SET_4,
156628
+ isAcceptedVerdict4
156629
+ };
156341
156630
  var write_mutation_evidence = createSwarmTool({
156342
156631
  description: 'Write mutation gate evidence for a completed phase. Accepts phase, verdict (PASS/WARN/FAIL/SKIP), killRate, adjustedKillRate, summary, and optional survivedMutants. Normalizes uppercase verdicts to lowercase (PASS→pass, WARN→warn, FAIL→fail, SKIP→skip) and writes entries[0].type="mutation-gate" to .swarm/evidence/{phase}/mutation-gate.json using atomic temp+rename write. Use this after mutation_test tool returns to persist the gate verdict.',
156343
156632
  args: {
156344
156633
  phase: exports_external.number().int().min(1).describe("The phase number for the mutation gate (e.g., 1, 2, 3)"),
156345
- verdict: exports_external.enum(["PASS", "WARN", "FAIL", "SKIP"]).describe("Verdict of the mutation gate: 'PASS', 'WARN', 'FAIL', or 'SKIP'"),
156634
+ verdict: exports_external.enum(VERDICT_SET_4).describe("Verdict of the mutation gate: 'PASS', 'WARN', 'FAIL', or 'SKIP'"),
156346
156635
  killRate: exports_external.number().optional().describe("The raw kill rate (e.g., 0.85)"),
156347
156636
  adjustedKillRate: exports_external.number().optional().describe("The adjusted kill rate accounting for timeout survived mutants (e.g., 0.87)"),
156348
156637
  summary: exports_external.string().describe("Human-readable summary of the mutation gate result"),
@@ -156428,6 +156717,7 @@ var TOOL_MANIFEST = defineHandlers({
156428
156717
  knowledge_recall: () => knowledge_recall,
156429
156718
  knowledge_remove: () => knowledge_remove,
156430
156719
  co_change_analyzer: () => co_change_analyzer,
156720
+ context_status: () => context_status,
156431
156721
  search: () => search,
156432
156722
  ast_grep: () => ast_grep,
156433
156723
  actionlint_scan: () => actionlint_scan,
@@ -156772,7 +157062,8 @@ async function initializeOpenCodeSwarm(ctx) {
156772
157062
  });
156773
157063
  const summaryConfig = SummaryConfigSchema.parse(config3.summaries ?? {});
156774
157064
  const toolSummarizerHook = createToolSummarizerHook(summaryConfig, ctx.directory);
156775
- const knowledgeConfig = KnowledgeConfigSchema.parse(config3.knowledge ?? {});
157065
+ const knowledgeConfigBase = config3.knowledge ?? {};
157066
+ const knowledgeConfig = KnowledgeConfigSchema.parse(knowledgeConfigBase);
156776
157067
  const skillImproverConfig = SkillImproverConfigSchema.parse(config3.skill_improver ?? {});
156777
157068
  const skillPropagationConfig = SkillPropagationConfigSchema.parse(config3.skillPropagation ?? {});
156778
157069
  if (skillImproverConfig.enabled && skillImproverConfig.trigger === "scheduled") {
@@ -156809,7 +157100,7 @@ async function initializeOpenCodeSwarm(ctx) {
156809
157100
  }
156810
157101
  }) : undefined;
156811
157102
  const hivePromoterHook = knowledgeConfig.enabled && knowledgeConfig.hive_enabled ? createHivePromoterHook(ctx.directory, knowledgeConfig) : undefined;
156812
- const knowledgeInjectorHook = knowledgeConfig.enabled ? createKnowledgeInjectorHook(ctx.directory, knowledgeConfig, config3.context_budget?.model_limits ?? {}) : undefined;
157103
+ const knowledgeInjectorHook = knowledgeConfig.enabled ? createKnowledgeInjectorHook(ctx.directory, knowledgeConfig, config3.context_budget?.model_limits ?? {}, config3.context_budget?.unified_injection_tokens) : undefined;
156813
157104
  const steeringConsumedHook = createSteeringConsumedHook(ctx.directory);
156814
157105
  const coChangeSuggesterHook = createCoChangeSuggesterHook(ctx.directory);
156815
157106
  const darkMatterDetectorHook = createDarkMatterDetectorHook(ctx.directory);