opencode-swarm 7.13.2 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cli/index.js +950 -269
- package/dist/commands/deep-dive.d.ts +5 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/registry.d.ts +14 -0
- package/dist/commands/turbo.d.ts +4 -4
- package/dist/config/constants.d.ts +12 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/schema.d.ts +116 -0
- package/dist/index.js +4504 -1266
- package/dist/parallel/file-locks.d.ts +50 -2
- package/dist/services/status-service.d.ts +29 -0
- package/dist/state.d.ts +17 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/lean-turbo-acquire-locks.d.ts +36 -0
- package/dist/tools/lean-turbo-plan-lanes.d.ts +35 -0
- package/dist/tools/lean-turbo-review.d.ts +34 -0
- package/dist/tools/lean-turbo-run-phase.d.ts +44 -0
- package/dist/tools/lean-turbo-runner-status.d.ts +36 -0
- package/dist/tools/lean-turbo-status.d.ts +44 -0
- package/dist/tools/tool-names.d.ts +1 -1
- package/dist/tools/update-task-status.d.ts +7 -4
- package/dist/turbo/lean/conflicts.d.ts +100 -0
- package/dist/turbo/lean/evidence.d.ts +91 -0
- package/dist/turbo/lean/index.d.ts +27 -0
- package/dist/turbo/lean/integration.d.ts +137 -0
- package/dist/turbo/lean/phase-ready.d.ts +105 -0
- package/dist/turbo/lean/planner.d.ts +115 -0
- package/dist/turbo/lean/reviewer.d.ts +124 -0
- package/dist/turbo/lean/risk.d.ts +47 -0
- package/dist/turbo/lean/runner.d.ts +322 -0
- package/dist/turbo/lean/state.d.ts +61 -0
- package/dist/turbo/lean/task-completion.d.ts +53 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var package_default;
|
|
|
34
34
|
var init_package = __esm(() => {
|
|
35
35
|
package_default = {
|
|
36
36
|
name: "opencode-swarm",
|
|
37
|
-
version: "7.
|
|
37
|
+
version: "7.15.0",
|
|
38
38
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
39
39
|
main: "dist/index.js",
|
|
40
40
|
types: "dist/index.d.ts",
|
|
@@ -16061,7 +16061,13 @@ var init_tool_names = __esm(() => {
|
|
|
16061
16061
|
"skill_inspect",
|
|
16062
16062
|
"skill_improve",
|
|
16063
16063
|
"spec_write",
|
|
16064
|
-
"knowledge_ack"
|
|
16064
|
+
"knowledge_ack",
|
|
16065
|
+
"lean_turbo_plan_lanes",
|
|
16066
|
+
"lean_turbo_acquire_locks",
|
|
16067
|
+
"lean_turbo_runner_status",
|
|
16068
|
+
"lean_turbo_review",
|
|
16069
|
+
"lean_turbo_run_phase",
|
|
16070
|
+
"lean_turbo_status"
|
|
16065
16071
|
];
|
|
16066
16072
|
TOOL_NAME_SET = new Set(TOOL_NAMES);
|
|
16067
16073
|
});
|
|
@@ -16100,7 +16106,7 @@ function freezeSet(items) {
|
|
|
16100
16106
|
});
|
|
16101
16107
|
return proxy;
|
|
16102
16108
|
}
|
|
16103
|
-
var QA_AGENTS, PIPELINE_AGENTS, ORCHESTRATOR_NAME = "architect", ALL_SUBAGENT_NAMES, ALL_AGENT_NAMES, OPENCODE_NATIVE_AGENTS, CLAUDE_CODE_NATIVE_COMMANDS, AGENT_TOOL_MAP, DEFAULT_AGENT_CONFIGS;
|
|
16109
|
+
var QA_AGENTS, PIPELINE_AGENTS, ORCHESTRATOR_NAME = "architect", ALL_SUBAGENT_NAMES, ALL_AGENT_NAMES, OPENCODE_NATIVE_AGENTS, CLAUDE_CODE_NATIVE_COMMANDS, AGENT_TOOL_MAP, TOOL_DESCRIPTIONS, DEFAULT_AGENT_CONFIGS;
|
|
16104
16110
|
var init_constants = __esm(() => {
|
|
16105
16111
|
init_tool_names();
|
|
16106
16112
|
QA_AGENTS = ["reviewer", "critic", "critic_oversight"];
|
|
@@ -16307,7 +16313,13 @@ var init_constants = __esm(() => {
|
|
|
16307
16313
|
"skill_apply",
|
|
16308
16314
|
"skill_inspect",
|
|
16309
16315
|
"skill_improve",
|
|
16310
|
-
"knowledge_ack"
|
|
16316
|
+
"knowledge_ack",
|
|
16317
|
+
"lean_turbo_plan_lanes",
|
|
16318
|
+
"lean_turbo_acquire_locks",
|
|
16319
|
+
"lean_turbo_runner_status",
|
|
16320
|
+
"lean_turbo_review",
|
|
16321
|
+
"lean_turbo_run_phase",
|
|
16322
|
+
"lean_turbo_status"
|
|
16311
16323
|
],
|
|
16312
16324
|
explorer: [
|
|
16313
16325
|
"complexity_hotspots",
|
|
@@ -16504,6 +16516,81 @@ var init_constants = __esm(() => {
|
|
|
16504
16516
|
"spec_write"
|
|
16505
16517
|
]
|
|
16506
16518
|
};
|
|
16519
|
+
TOOL_DESCRIPTIONS = {
|
|
16520
|
+
symbols: "code symbol search",
|
|
16521
|
+
checkpoint: "state snapshots",
|
|
16522
|
+
diff: "structured git diff with contract change detection",
|
|
16523
|
+
diff_summary: "filter classified AST changes by category, risk level, or file for reviewer drill-down",
|
|
16524
|
+
imports: "dependency audit",
|
|
16525
|
+
lint: "code quality",
|
|
16526
|
+
placeholder_scan: "todo and FIXME comment detection",
|
|
16527
|
+
secretscan: "secret detection",
|
|
16528
|
+
sast_scan: "static analysis security scan",
|
|
16529
|
+
syntax_check: "syntax validation",
|
|
16530
|
+
test_runner: "auto-detect and run tests",
|
|
16531
|
+
test_impact: "identify test files impacted by changed source files via import analysis",
|
|
16532
|
+
mutation_test: "executes pre-generated mutation patches against tests, evaluates kill rate against quality gate thresholds",
|
|
16533
|
+
generate_mutants: "generate LLM-based mutation testing patches for source files; returns MutationPatch[] for direct consumption by the mutation_test tool",
|
|
16534
|
+
write_mutation_evidence: "write mutation gate evidence for a completed phase; normalizes PASS/WARN/FAIL/SKIP verdicts and writes .swarm/evidence/{phase}/mutation-gate.json",
|
|
16535
|
+
pkg_audit: "dependency vulnerability scan \u2014 npm/pip/cargo",
|
|
16536
|
+
complexity_hotspots: "git churn \xD7 complexity risk map",
|
|
16537
|
+
schema_drift: "OpenAPI spec vs route drift",
|
|
16538
|
+
todo_extract: "structured TODO/FIXME extraction",
|
|
16539
|
+
evidence_check: "verify task evidence completeness",
|
|
16540
|
+
sbom_generate: "SBOM generation for dependency inventory",
|
|
16541
|
+
build_check: "build verification",
|
|
16542
|
+
quality_budget: "code quality budget check",
|
|
16543
|
+
pre_check_batch: "parallel verification: lint:check + secretscan + sast_scan + quality_budget",
|
|
16544
|
+
update_task_status: "mark tasks complete, track phase progress",
|
|
16545
|
+
write_retro: "document phase retrospectives via phase_complete workflow, capture lessons learned",
|
|
16546
|
+
write_drift_evidence: "write drift verification evidence for a completed phase",
|
|
16547
|
+
write_hallucination_evidence: "write hallucination verification evidence for a completed phase",
|
|
16548
|
+
write_final_council_evidence: "write final council evidence for project completion",
|
|
16549
|
+
declare_scope: "declare file scope for next coder delegation",
|
|
16550
|
+
phase_complete: "mark a phase as complete and track dispatched agents",
|
|
16551
|
+
save_plan: "save a structured implementation plan",
|
|
16552
|
+
doc_scan: "scan project documentation files and build an index manifest",
|
|
16553
|
+
doc_extract: "extract actionable constraints from project documentation",
|
|
16554
|
+
curator_analyze: "run curator phase analysis and optionally apply knowledge recommendations",
|
|
16555
|
+
knowledge_add: "store a new lesson in the knowledge base",
|
|
16556
|
+
knowledge_recall: "search the knowledge base for relevant past decisions",
|
|
16557
|
+
knowledge_remove: "delete an outdated swarm knowledge entry by ID (swarm tier only)",
|
|
16558
|
+
knowledge_query: "query swarm or hive knowledge with optional filters",
|
|
16559
|
+
co_change_analyzer: "detect hidden couplings by analyzing git history",
|
|
16560
|
+
check_gate_status: "check the gate status of a specific task",
|
|
16561
|
+
completion_verify: "verify completed tasks have required evidence",
|
|
16562
|
+
submit_council_verdicts: "submit pre-collected council member verdicts for synthesis (architect MUST dispatch critic/reviewer/sme/test_engineer/explorer as Agent tasks first; this tool synthesizes only, it does not contact members)",
|
|
16563
|
+
submit_phase_council_verdicts: "submit pre-collected phase-level council member verdicts for holistic phase synthesis (architect MUST dispatch all 5 council members with phase-scoped context first; this tool synthesizes only, it does not contact members)",
|
|
16564
|
+
declare_council_criteria: "pre-declare acceptance criteria for a task before the coder starts work; criteria are read back during council evaluation",
|
|
16565
|
+
detect_domains: "detect which SME domains are relevant for a given text",
|
|
16566
|
+
extract_code_blocks: "extract code blocks from text content and save them to files",
|
|
16567
|
+
gitingest: "fetch a GitHub repository full content via gitingest.com",
|
|
16568
|
+
retrieve_summary: "retrieve the full content of a stored tool output summary",
|
|
16569
|
+
search: "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 \u2014 use symbols and imports tools for structural queries.",
|
|
16570
|
+
web_search: "External web search (Tavily or Brave) for architect-driven council research. Returns titled results with snippets and URLs. Config-gated on council.general.enabled; requires a search API key. Used by the architect in MODE: COUNCIL to gather a RESEARCH CONTEXT before dispatching council agents.",
|
|
16571
|
+
convene_general_council: "Synthesize responses from a multi-model General Council. Accepts parallel member responses (Round 1, optionally Round 2), detects disagreements, and returns consensus points, persisting disagreements, and a structured synthesis. Architect-only. Config-gated on council.general.enabled.",
|
|
16572
|
+
batch_symbols: "Batched symbol extraction across multiple files. Returns per-file symbol summaries with isolated error handling.",
|
|
16573
|
+
suggest_patch: "Reviewer-safe structured patch suggestion tool. Produces context-anchored patch artifacts without file modification. Returns structured diagnostics on context mismatch.",
|
|
16574
|
+
lint_spec: "validate .swarm/spec.md format and required fields",
|
|
16575
|
+
get_approved_plan: "retrieve the last critic-approved immutable plan snapshot for baseline drift comparison",
|
|
16576
|
+
repo_map: "query the repo code graph: importers, dependencies, blast radius, and localization context for structural awareness before refactoring",
|
|
16577
|
+
get_qa_gate_profile: "retrieve the QA gate profile for the current plan: gates (reviewer, test_engineer, sme_enabled, critic_pre_plan, sast_enabled, council_mode, hallucination_guard, mutation_test, council_general_review, drift_check, final_council), lock state, and profile hash. Read-only.",
|
|
16578
|
+
set_qa_gates: "configure the QA gate profile for the current plan. Architect-only. Ratchet-tighter only \u2014 rejected once the profile is locked after critic approval. Supports: reviewer, test_engineer, sme_enabled, critic_pre_plan, sast_enabled, council_mode, hallucination_guard, mutation_test, council_general_review, drift_check, final_council.",
|
|
16579
|
+
req_coverage: "query requirement coverage status for tracked functional requirements",
|
|
16580
|
+
skill_generate: "compile knowledge entries into a structured SKILL.md draft",
|
|
16581
|
+
skill_list: "list generated skill files and their status",
|
|
16582
|
+
skill_apply: "activate a draft skill proposal",
|
|
16583
|
+
skill_inspect: "inspect the content and source entries of a skill file",
|
|
16584
|
+
skill_improve: "run the skill_improver agent to review and refine skills",
|
|
16585
|
+
spec_write: "author or update .swarm/spec.md for the current project",
|
|
16586
|
+
knowledge_ack: "record an explicit KNOWLEDGE_APPLIED/IGNORED/VIOLATED acknowledgment",
|
|
16587
|
+
lean_turbo_plan_lanes: "partition phase tasks into parallel lanes based on file-scope conflicts for Lean Turbo execution",
|
|
16588
|
+
lean_turbo_acquire_locks: "acquire file locks for all files in a lane (all-or-nothing) before lane execution",
|
|
16589
|
+
lean_turbo_runner_status: "read Lean Turbo run state from .swarm/turbo-state.json",
|
|
16590
|
+
lean_turbo_review: "dispatch a read-only reviewer agent to evaluate a completed Lean Turbo phase",
|
|
16591
|
+
lean_turbo_run_phase: "Execute a phase using Lean Turbo parallel lane execution. " + "Plans lanes, acquires file locks, and dispatches coder agents concurrently. " + "Use when Lean Turbo is active and you want to execute all tasks in a phase in parallel lanes.",
|
|
16592
|
+
lean_turbo_status: "returns Lean Turbo configuration and active status for the current session"
|
|
16593
|
+
};
|
|
16507
16594
|
for (const [agentName, tools] of Object.entries(AGENT_TOOL_MAP)) {
|
|
16508
16595
|
const invalidTools = tools.filter((tool) => !TOOL_NAME_SET.has(tool));
|
|
16509
16596
|
if (invalidTools.length > 0) {
|
|
@@ -16607,7 +16694,7 @@ function getCanonicalAgentRole(agentName, generatedAgentNames) {
|
|
|
16607
16694
|
function stripKnownSwarmPrefix(agentName) {
|
|
16608
16695
|
return getCanonicalAgentRole(agentName);
|
|
16609
16696
|
}
|
|
16610
|
-
var SEPARATORS, CANONICAL_ROLES_LONGEST_FIRST, CANONICAL_ROLES_SET, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, CuratorConfigSchema, KnowledgeApplicationConfigSchema, SkillImproverConfigSchema, SpecWriterConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, ParallelizationConfigSchema, PluginConfigSchema;
|
|
16697
|
+
var SEPARATORS, CANONICAL_ROLES_LONGEST_FIRST, CANONICAL_ROLES_SET, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, CuratorConfigSchema, KnowledgeApplicationConfigSchema, SkillImproverConfigSchema, SpecWriterConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, ParallelizationConfigSchema, LeanTurboConfigSchema, StandardTurboConfigSchema, LeanTurboStrategyConfigSchema, TurboConfigSchema, PluginConfigSchema;
|
|
16611
16698
|
var init_schema = __esm(() => {
|
|
16612
16699
|
init_zod();
|
|
16613
16700
|
init_constants();
|
|
@@ -17194,6 +17281,31 @@ var init_schema = __esm(() => {
|
|
|
17194
17281
|
max_coders: exports_external.number().int().min(1).max(16).default(3),
|
|
17195
17282
|
max_reviewers: exports_external.number().int().min(1).max(16).default(2)
|
|
17196
17283
|
});
|
|
17284
|
+
LeanTurboConfigSchema = exports_external.object({
|
|
17285
|
+
max_parallel_coders: exports_external.number().int().min(1).max(6).default(4),
|
|
17286
|
+
require_declared_scope: exports_external.boolean().default(true),
|
|
17287
|
+
conflict_policy: exports_external.enum(["serialize", "degrade"]).default("serialize"),
|
|
17288
|
+
degrade_on_risk: exports_external.boolean().default(true),
|
|
17289
|
+
phase_reviewer: exports_external.boolean().default(true),
|
|
17290
|
+
phase_critic: exports_external.boolean().default(true),
|
|
17291
|
+
integrated_diff_required: exports_external.boolean().default(true),
|
|
17292
|
+
allow_docs_only_without_reviewer: exports_external.boolean().default(false),
|
|
17293
|
+
worktree_isolation: exports_external.boolean().default(false).refine((val) => val === false, {
|
|
17294
|
+
message: "worktree_isolation: true is not yet implemented. Use false (the default) for in-repo parallel execution. Full worktree isolation will be available in a future release."
|
|
17295
|
+
})
|
|
17296
|
+
});
|
|
17297
|
+
StandardTurboConfigSchema = exports_external.object({
|
|
17298
|
+
strategy: exports_external.literal("standard"),
|
|
17299
|
+
lean: LeanTurboConfigSchema.optional()
|
|
17300
|
+
});
|
|
17301
|
+
LeanTurboStrategyConfigSchema = exports_external.object({
|
|
17302
|
+
strategy: exports_external.literal("lean"),
|
|
17303
|
+
lean: LeanTurboConfigSchema
|
|
17304
|
+
});
|
|
17305
|
+
TurboConfigSchema = exports_external.discriminatedUnion("strategy", [
|
|
17306
|
+
StandardTurboConfigSchema,
|
|
17307
|
+
LeanTurboStrategyConfigSchema
|
|
17308
|
+
]);
|
|
17197
17309
|
PluginConfigSchema = exports_external.object({
|
|
17198
17310
|
agents: exports_external.record(exports_external.string(), AgentOverrideConfigSchema).optional(),
|
|
17199
17311
|
default_agent: exports_external.string().optional().transform((v) => {
|
|
@@ -17253,6 +17365,7 @@ var init_schema = __esm(() => {
|
|
|
17253
17365
|
prm: PrmConfigSchema.optional(),
|
|
17254
17366
|
council: CouncilConfigSchema.optional(),
|
|
17255
17367
|
parallelization: ParallelizationConfigSchema.optional(),
|
|
17368
|
+
turbo: TurboConfigSchema.optional(),
|
|
17256
17369
|
turbo_mode: exports_external.boolean().default(false).optional(),
|
|
17257
17370
|
quiet: exports_external.boolean().default(true).optional(),
|
|
17258
17371
|
version_check: exports_external.boolean().default(true).optional(),
|
|
@@ -19372,8 +19485,17 @@ function getLockFilePath(directory, filePath) {
|
|
|
19372
19485
|
if (!pathOk) {
|
|
19373
19486
|
throw new Error("Invalid file path: path traversal not allowed");
|
|
19374
19487
|
}
|
|
19375
|
-
const
|
|
19376
|
-
|
|
19488
|
+
const pathForHash = process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
19489
|
+
const hash2 = Buffer.from(pathForHash).toString("base64").replace(/[/+=]/g, "_");
|
|
19490
|
+
const lockPath = path6.join(directory, LOCKS_DIR, `${hash2}.lock`);
|
|
19491
|
+
if (process.platform === "win32") {
|
|
19492
|
+
const oldHash = Buffer.from(normalized).toString("base64").replace(/[/+=]/g, "_");
|
|
19493
|
+
const oldLockPath = path6.join(directory, LOCKS_DIR, `${oldHash}.lock`);
|
|
19494
|
+
if (fs3.existsSync(oldLockPath)) {
|
|
19495
|
+
return oldLockPath;
|
|
19496
|
+
}
|
|
19497
|
+
}
|
|
19498
|
+
return lockPath;
|
|
19377
19499
|
}
|
|
19378
19500
|
async function tryAcquireLock(directory, filePath, agent, taskId) {
|
|
19379
19501
|
const lockPath = getLockFilePath(directory, filePath);
|
|
@@ -19408,10 +19530,14 @@ async function tryAcquireLock(directory, filePath, agent, taskId) {
|
|
|
19408
19530
|
};
|
|
19409
19531
|
return { acquired: true, lock };
|
|
19410
19532
|
}
|
|
19411
|
-
var import_proper_lockfile, LOCKS_DIR = ".swarm/locks", LOCK_TIMEOUT_MS;
|
|
19533
|
+
var import_proper_lockfile, LOCKS_DIR = ".swarm/locks", LOCK_TIMEOUT_MS, _internals4;
|
|
19412
19534
|
var init_file_locks = __esm(() => {
|
|
19413
19535
|
import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
19414
19536
|
LOCK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
19537
|
+
_internals4 = {
|
|
19538
|
+
tryAcquireLock,
|
|
19539
|
+
writeFile: fs3.promises.writeFile
|
|
19540
|
+
};
|
|
19415
19541
|
});
|
|
19416
19542
|
|
|
19417
19543
|
// src/evidence/lock.ts
|
|
@@ -19634,7 +19760,7 @@ async function loadEvidence(directory, taskId) {
|
|
|
19634
19760
|
return { status: "invalid_schema", errors: ["Invalid JSON"] };
|
|
19635
19761
|
}
|
|
19636
19762
|
if (isFlatRetrospective(parsed)) {
|
|
19637
|
-
const wrappedBundle =
|
|
19763
|
+
const wrappedBundle = _internals5.wrapFlatRetrospective(parsed, sanitizedTaskId);
|
|
19638
19764
|
try {
|
|
19639
19765
|
const validated = EvidenceBundleSchema.parse(wrappedBundle);
|
|
19640
19766
|
try {
|
|
@@ -19730,14 +19856,14 @@ async function checkRequirementCoverage(phase, directory) {
|
|
|
19730
19856
|
}
|
|
19731
19857
|
}
|
|
19732
19858
|
async function archiveEvidence(directory, maxAgeDays, maxBundles) {
|
|
19733
|
-
const taskIds = await
|
|
19859
|
+
const taskIds = await _internals5.listEvidenceTaskIds(directory);
|
|
19734
19860
|
const cutoffDate = new Date;
|
|
19735
19861
|
cutoffDate.setDate(cutoffDate.getDate() - maxAgeDays);
|
|
19736
19862
|
const cutoffIso = cutoffDate.toISOString();
|
|
19737
19863
|
const archived = [];
|
|
19738
19864
|
const remainingBundles = [];
|
|
19739
19865
|
for (const taskId of taskIds) {
|
|
19740
|
-
const result = await
|
|
19866
|
+
const result = await _internals5.loadEvidence(directory, taskId);
|
|
19741
19867
|
if (result.status !== "found") {
|
|
19742
19868
|
continue;
|
|
19743
19869
|
}
|
|
@@ -19765,7 +19891,7 @@ async function archiveEvidence(directory, maxAgeDays, maxBundles) {
|
|
|
19765
19891
|
}
|
|
19766
19892
|
return archived;
|
|
19767
19893
|
}
|
|
19768
|
-
var VALID_EVIDENCE_TYPES, sanitizeTaskId2, LEGACY_TASK_COMPLEXITY_MAP,
|
|
19894
|
+
var VALID_EVIDENCE_TYPES, sanitizeTaskId2, LEGACY_TASK_COMPLEXITY_MAP, _internals5;
|
|
19769
19895
|
var init_manager2 = __esm(() => {
|
|
19770
19896
|
init_zod();
|
|
19771
19897
|
init_evidence_schema();
|
|
@@ -19795,7 +19921,7 @@ var init_manager2 = __esm(() => {
|
|
|
19795
19921
|
medium: "moderate",
|
|
19796
19922
|
high: "complex"
|
|
19797
19923
|
};
|
|
19798
|
-
|
|
19924
|
+
_internals5 = {
|
|
19799
19925
|
wrapFlatRetrospective,
|
|
19800
19926
|
loadEvidence,
|
|
19801
19927
|
listEvidenceTaskIds
|
|
@@ -20006,7 +20132,7 @@ function getProfile(directory, planId) {
|
|
|
20006
20132
|
return row ? rowToProfile(row) : null;
|
|
20007
20133
|
}
|
|
20008
20134
|
function getOrCreateProfile(directory, planId, projectType) {
|
|
20009
|
-
const existing =
|
|
20135
|
+
const existing = _internals6.getProfile(directory, planId);
|
|
20010
20136
|
if (existing)
|
|
20011
20137
|
return existing;
|
|
20012
20138
|
const db = getProjectDb(directory);
|
|
@@ -20022,14 +20148,14 @@ function getOrCreateProfile(directory, planId, projectType) {
|
|
|
20022
20148
|
throw err;
|
|
20023
20149
|
}
|
|
20024
20150
|
}
|
|
20025
|
-
const after =
|
|
20151
|
+
const after = _internals6.getProfile(directory, planId);
|
|
20026
20152
|
if (!after) {
|
|
20027
20153
|
throw new Error(`Failed to create or load QA gate profile for plan_id=${planId}`);
|
|
20028
20154
|
}
|
|
20029
20155
|
return after;
|
|
20030
20156
|
}
|
|
20031
20157
|
function setGates(directory, planId, gates) {
|
|
20032
|
-
const current =
|
|
20158
|
+
const current = _internals6.getProfile(directory, planId);
|
|
20033
20159
|
if (!current) {
|
|
20034
20160
|
throw new Error(`No QA gate profile found for plan_id=${planId} \u2014 call getOrCreateProfile first`);
|
|
20035
20161
|
}
|
|
@@ -20053,7 +20179,7 @@ function setGates(directory, planId, gates) {
|
|
|
20053
20179
|
JSON.stringify(merged),
|
|
20054
20180
|
planId
|
|
20055
20181
|
]);
|
|
20056
|
-
const updated =
|
|
20182
|
+
const updated = _internals6.getProfile(directory, planId);
|
|
20057
20183
|
if (!updated) {
|
|
20058
20184
|
throw new Error(`Failed to re-read QA gate profile after update for plan_id=${planId}`);
|
|
20059
20185
|
}
|
|
@@ -20075,10 +20201,10 @@ function getEffectiveGates(profile, sessionOverrides) {
|
|
|
20075
20201
|
}
|
|
20076
20202
|
return merged;
|
|
20077
20203
|
}
|
|
20078
|
-
var
|
|
20204
|
+
var _internals6, DEFAULT_QA_GATES;
|
|
20079
20205
|
var init_qa_gate_profile = __esm(() => {
|
|
20080
20206
|
init_project_db();
|
|
20081
|
-
|
|
20207
|
+
_internals6 = {
|
|
20082
20208
|
getProfile,
|
|
20083
20209
|
getOrCreateProfile,
|
|
20084
20210
|
setGates,
|
|
@@ -20813,6 +20939,30 @@ function hasActiveTurboMode(sessionID) {
|
|
|
20813
20939
|
}
|
|
20814
20940
|
return false;
|
|
20815
20941
|
}
|
|
20942
|
+
function hasActiveFullAuto(sessionID) {
|
|
20943
|
+
if (sessionID) {
|
|
20944
|
+
const session = swarmState.agentSessions.get(sessionID);
|
|
20945
|
+
return session?.fullAutoMode === true;
|
|
20946
|
+
}
|
|
20947
|
+
for (const [_sessionId, session] of swarmState.agentSessions) {
|
|
20948
|
+
if (session.fullAutoMode === true) {
|
|
20949
|
+
return true;
|
|
20950
|
+
}
|
|
20951
|
+
}
|
|
20952
|
+
return false;
|
|
20953
|
+
}
|
|
20954
|
+
function hasActiveLeanTurbo(sessionID) {
|
|
20955
|
+
if (sessionID) {
|
|
20956
|
+
const session = swarmState.agentSessions.get(sessionID);
|
|
20957
|
+
return session?.turboMode === true && session?.turboStrategy === "lean" && session?.leanTurboActive === true;
|
|
20958
|
+
}
|
|
20959
|
+
for (const [_sessionId, session] of swarmState.agentSessions) {
|
|
20960
|
+
if (session.turboMode === true && session.turboStrategy === "lean" && session.leanTurboActive === true) {
|
|
20961
|
+
return true;
|
|
20962
|
+
}
|
|
20963
|
+
}
|
|
20964
|
+
return false;
|
|
20965
|
+
}
|
|
20816
20966
|
var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState;
|
|
20817
20967
|
var init_state = __esm(() => {
|
|
20818
20968
|
init_constants();
|
|
@@ -21440,8 +21590,8 @@ function getElementAtPath2(obj, path9) {
|
|
|
21440
21590
|
}
|
|
21441
21591
|
function promiseAllObject2(promisesObj) {
|
|
21442
21592
|
const keys = Object.keys(promisesObj);
|
|
21443
|
-
const
|
|
21444
|
-
return Promise.all(
|
|
21593
|
+
const promises2 = keys.map((key) => promisesObj[key]);
|
|
21594
|
+
return Promise.all(promises2).then((results) => {
|
|
21445
21595
|
const resolvedObj = {};
|
|
21446
21596
|
for (let i = 0;i < keys.length; i++) {
|
|
21447
21597
|
resolvedObj[keys[i]] = results[i];
|
|
@@ -34401,7 +34551,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
34401
34551
|
const prunedBranches = [];
|
|
34402
34552
|
try {
|
|
34403
34553
|
const currentBranch = getCurrentBranch(cwd);
|
|
34404
|
-
const defaultRemoteBranch =
|
|
34554
|
+
const defaultRemoteBranch = _internals7.detectDefaultRemoteBranch(cwd);
|
|
34405
34555
|
if (!defaultRemoteBranch) {
|
|
34406
34556
|
return {
|
|
34407
34557
|
success: false,
|
|
@@ -34583,7 +34733,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
34583
34733
|
function resetToMainAfterMerge(cwd, options) {
|
|
34584
34734
|
const warnings = [];
|
|
34585
34735
|
try {
|
|
34586
|
-
const defaultBranch =
|
|
34736
|
+
const defaultBranch = _internals7.detectDefaultRemoteBranch(cwd);
|
|
34587
34737
|
if (!defaultBranch) {
|
|
34588
34738
|
return {
|
|
34589
34739
|
success: false,
|
|
@@ -34610,7 +34760,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34610
34760
|
}
|
|
34611
34761
|
if (currentBranch === defaultBranch) {
|
|
34612
34762
|
try {
|
|
34613
|
-
const logOutput =
|
|
34763
|
+
const logOutput = _internals7.gitExec(["log", `${targetBranch}..HEAD`, "--oneline"], cwd);
|
|
34614
34764
|
if (logOutput.trim().length > 0) {
|
|
34615
34765
|
return {
|
|
34616
34766
|
success: false,
|
|
@@ -34625,11 +34775,11 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34625
34775
|
} catch {}
|
|
34626
34776
|
} else {
|
|
34627
34777
|
try {
|
|
34628
|
-
|
|
34778
|
+
_internals7.gitExec(["rev-parse", "--abbrev-ref", `${currentBranch}@{upstream}`], cwd);
|
|
34629
34779
|
} catch {
|
|
34630
34780
|
try {
|
|
34631
|
-
const localSha =
|
|
34632
|
-
const remoteSha =
|
|
34781
|
+
const localSha = _internals7.gitExec(["rev-parse", "HEAD"], cwd).trim();
|
|
34782
|
+
const remoteSha = _internals7.gitExec(["rev-parse", targetBranch], cwd).trim();
|
|
34633
34783
|
if (localSha !== remoteSha) {
|
|
34634
34784
|
return {
|
|
34635
34785
|
success: false,
|
|
@@ -34655,7 +34805,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34655
34805
|
}
|
|
34656
34806
|
}
|
|
34657
34807
|
try {
|
|
34658
|
-
|
|
34808
|
+
_internals7.gitExec(["fetch", "--prune", "origin"], cwd);
|
|
34659
34809
|
} catch (err) {
|
|
34660
34810
|
return {
|
|
34661
34811
|
success: false,
|
|
@@ -34671,7 +34821,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34671
34821
|
let switchedBranch = false;
|
|
34672
34822
|
if (currentBranch !== defaultBranch) {
|
|
34673
34823
|
try {
|
|
34674
|
-
|
|
34824
|
+
_internals7.gitExec(["checkout", defaultBranch], cwd);
|
|
34675
34825
|
switchedBranch = true;
|
|
34676
34826
|
} catch (err) {
|
|
34677
34827
|
return {
|
|
@@ -34686,7 +34836,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34686
34836
|
}
|
|
34687
34837
|
}
|
|
34688
34838
|
try {
|
|
34689
|
-
|
|
34839
|
+
_internals7.gitExec(["reset", "--hard", targetBranch], cwd);
|
|
34690
34840
|
} catch (err) {
|
|
34691
34841
|
return {
|
|
34692
34842
|
success: false,
|
|
@@ -34707,7 +34857,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34707
34857
|
while (Date.now() < endTime) {}
|
|
34708
34858
|
}
|
|
34709
34859
|
try {
|
|
34710
|
-
|
|
34860
|
+
_internals7.gitExec(["checkout", "--", "."], cwd);
|
|
34711
34861
|
discardSucceeded = true;
|
|
34712
34862
|
break;
|
|
34713
34863
|
} catch {}
|
|
@@ -34718,18 +34868,18 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34718
34868
|
changesDiscarded = discardSucceeded;
|
|
34719
34869
|
}
|
|
34720
34870
|
try {
|
|
34721
|
-
|
|
34871
|
+
_internals7.gitExec(["clean", "-fd"], cwd);
|
|
34722
34872
|
} catch {
|
|
34723
34873
|
warnings.push("Could not clean untracked files");
|
|
34724
34874
|
}
|
|
34725
34875
|
let branchDeleted = false;
|
|
34726
34876
|
if (switchedBranch && previousBranch !== defaultBranch) {
|
|
34727
34877
|
try {
|
|
34728
|
-
const mergedOutput =
|
|
34878
|
+
const mergedOutput = _internals7.gitExec(["branch", "--merged", defaultBranch], cwd);
|
|
34729
34879
|
const isMerged = mergedOutput.split(`
|
|
34730
34880
|
`).some((line) => line.trim() === previousBranch || line.trim() === `* ${previousBranch}`);
|
|
34731
34881
|
if (isMerged) {
|
|
34732
|
-
|
|
34882
|
+
_internals7.gitExec(["branch", "-d", previousBranch], cwd);
|
|
34733
34883
|
branchDeleted = true;
|
|
34734
34884
|
} else {
|
|
34735
34885
|
warnings.push(`Branch ${previousBranch} is not merged into ${defaultBranch} \u2014 keeping it`);
|
|
@@ -34740,7 +34890,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34740
34890
|
}
|
|
34741
34891
|
if (options?.pruneBranches) {
|
|
34742
34892
|
try {
|
|
34743
|
-
const mergedOutput =
|
|
34893
|
+
const mergedOutput = _internals7.gitExec(["branch", "--merged", defaultBranch], cwd);
|
|
34744
34894
|
const mergedLines = mergedOutput.split(`
|
|
34745
34895
|
`);
|
|
34746
34896
|
for (const line of mergedLines) {
|
|
@@ -34749,7 +34899,7 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34749
34899
|
continue;
|
|
34750
34900
|
}
|
|
34751
34901
|
try {
|
|
34752
|
-
|
|
34902
|
+
_internals7.gitExec(["branch", "-d", trimmedLine], cwd);
|
|
34753
34903
|
} catch {
|
|
34754
34904
|
warnings.push(`Could not prune branch: ${trimmedLine}`);
|
|
34755
34905
|
}
|
|
@@ -34779,10 +34929,10 @@ function resetToMainAfterMerge(cwd, options) {
|
|
|
34779
34929
|
};
|
|
34780
34930
|
}
|
|
34781
34931
|
}
|
|
34782
|
-
var GIT_TIMEOUT_MS2 = 30000,
|
|
34932
|
+
var GIT_TIMEOUT_MS2 = 30000, _internals7;
|
|
34783
34933
|
var init_branch = __esm(() => {
|
|
34784
34934
|
init_logger();
|
|
34785
|
-
|
|
34935
|
+
_internals7 = {
|
|
34786
34936
|
gitExec: gitExec2,
|
|
34787
34937
|
detectDefaultRemoteBranch,
|
|
34788
34938
|
getDefaultBaseBranch,
|
|
@@ -35967,7 +36117,7 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
35967
36117
|
existingEntries.push(entry);
|
|
35968
36118
|
}
|
|
35969
36119
|
await enforceKnowledgeCap(knowledgePath, config3.swarm_max_entries);
|
|
35970
|
-
await
|
|
36120
|
+
await _internals8.runAutoPromotion(directory, config3);
|
|
35971
36121
|
return { stored, skipped, rejected };
|
|
35972
36122
|
}
|
|
35973
36123
|
async function runAutoPromotion(directory, config3) {
|
|
@@ -36048,7 +36198,7 @@ function createKnowledgeCuratorHook(directory, config3) {
|
|
|
36048
36198
|
});
|
|
36049
36199
|
const projectName2 = evidenceData.project_name ?? "unknown";
|
|
36050
36200
|
const phaseNumber2 = typeof evidenceData.phase_number === "number" ? evidenceData.phase_number : 1;
|
|
36051
|
-
await
|
|
36201
|
+
await _internals8.curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
|
|
36052
36202
|
await updateRetrievalOutcome(directory, `Phase ${phaseNumber2}`, true);
|
|
36053
36203
|
return;
|
|
36054
36204
|
}
|
|
@@ -36071,19 +36221,19 @@ function createKnowledgeCuratorHook(directory, config3) {
|
|
|
36071
36221
|
const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
|
|
36072
36222
|
const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
|
|
36073
36223
|
const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
|
|
36074
|
-
await
|
|
36224
|
+
await _internals8.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
|
|
36075
36225
|
await updateRetrievalOutcome(directory, `Phase ${phaseNumber}`, true);
|
|
36076
36226
|
};
|
|
36077
36227
|
return safeHook(handler);
|
|
36078
36228
|
}
|
|
36079
|
-
var seenRetroSections,
|
|
36229
|
+
var seenRetroSections, _internals8;
|
|
36080
36230
|
var init_knowledge_curator = __esm(() => {
|
|
36081
36231
|
init_knowledge_reader();
|
|
36082
36232
|
init_knowledge_store();
|
|
36083
36233
|
init_knowledge_validator();
|
|
36084
36234
|
init_utils2();
|
|
36085
36235
|
seenRetroSections = new Map;
|
|
36086
|
-
|
|
36236
|
+
_internals8 = {
|
|
36087
36237
|
isWriteToEvidenceFile,
|
|
36088
36238
|
curateAndStoreSwarm,
|
|
36089
36239
|
runAutoPromotion,
|
|
@@ -36392,7 +36542,7 @@ async function executeWriteRetro(args, directory) {
|
|
|
36392
36542
|
}, null, 2);
|
|
36393
36543
|
}
|
|
36394
36544
|
}
|
|
36395
|
-
var write_retro,
|
|
36545
|
+
var write_retro, _internals9;
|
|
36396
36546
|
var init_write_retro = __esm(() => {
|
|
36397
36547
|
init_zod();
|
|
36398
36548
|
init_evidence_schema();
|
|
@@ -36439,13 +36589,13 @@ var init_write_retro = __esm(() => {
|
|
|
36439
36589
|
task_id: args.task_id !== undefined ? String(args.task_id) : undefined,
|
|
36440
36590
|
metadata: args.metadata
|
|
36441
36591
|
};
|
|
36442
|
-
return await
|
|
36592
|
+
return await _internals9.executeWriteRetro(writeRetroArgs, directory);
|
|
36443
36593
|
} catch {
|
|
36444
36594
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
36445
36595
|
}
|
|
36446
36596
|
}
|
|
36447
36597
|
});
|
|
36448
|
-
|
|
36598
|
+
_internals9 = {
|
|
36449
36599
|
executeWriteRetro,
|
|
36450
36600
|
write_retro
|
|
36451
36601
|
};
|
|
@@ -37347,9 +37497,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
37347
37497
|
} catch {
|
|
37348
37498
|
return [];
|
|
37349
37499
|
}
|
|
37350
|
-
const commitMap = await
|
|
37351
|
-
const matrix =
|
|
37352
|
-
const staticEdges = await
|
|
37500
|
+
const commitMap = await _internals10.parseGitLog(directory, maxCommitsToAnalyze);
|
|
37501
|
+
const matrix = _internals10.buildCoChangeMatrix(commitMap);
|
|
37502
|
+
const staticEdges = await _internals10.getStaticEdges(directory);
|
|
37353
37503
|
const results = [];
|
|
37354
37504
|
for (const entry of matrix.values()) {
|
|
37355
37505
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -37429,7 +37579,7 @@ ${rows}
|
|
|
37429
37579
|
These pairs likely share an architectural concern invisible to static analysis.
|
|
37430
37580
|
Consider adding explicit documentation or extracting the shared concern.`;
|
|
37431
37581
|
}
|
|
37432
|
-
var co_change_analyzer,
|
|
37582
|
+
var co_change_analyzer, _internals10;
|
|
37433
37583
|
var init_co_change_analyzer = __esm(() => {
|
|
37434
37584
|
init_zod();
|
|
37435
37585
|
init_create_tool();
|
|
@@ -37461,11 +37611,11 @@ var init_co_change_analyzer = __esm(() => {
|
|
|
37461
37611
|
npmiThreshold,
|
|
37462
37612
|
maxCommitsToAnalyze
|
|
37463
37613
|
};
|
|
37464
|
-
const pairs = await
|
|
37465
|
-
return
|
|
37614
|
+
const pairs = await _internals10.detectDarkMatter(directory, options);
|
|
37615
|
+
return _internals10.formatDarkMatterOutput(pairs);
|
|
37466
37616
|
}
|
|
37467
37617
|
});
|
|
37468
|
-
|
|
37618
|
+
_internals10 = {
|
|
37469
37619
|
parseGitLog,
|
|
37470
37620
|
buildCoChangeMatrix,
|
|
37471
37621
|
getStaticEdges,
|
|
@@ -37496,7 +37646,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
37496
37646
|
}
|
|
37497
37647
|
let pairs;
|
|
37498
37648
|
try {
|
|
37499
|
-
pairs = await
|
|
37649
|
+
pairs = await _internals10.detectDarkMatter(directory, options);
|
|
37500
37650
|
} catch (err) {
|
|
37501
37651
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
37502
37652
|
return `## Dark Matter Analysis Failed
|
|
@@ -37531,6 +37681,118 @@ var init_dark_matter = __esm(() => {
|
|
|
37531
37681
|
init_co_change_analyzer();
|
|
37532
37682
|
});
|
|
37533
37683
|
|
|
37684
|
+
// src/commands/deep-dive.ts
|
|
37685
|
+
function sanitizeScope(raw) {
|
|
37686
|
+
const collapsed = raw.replace(/\s+/g, " ").trim();
|
|
37687
|
+
const stripped = collapsed.replace(/\[\s*MODE\s*:[^\]]*\]/gi, "");
|
|
37688
|
+
const normalized = stripped.replace(/\s+/g, " ").trim();
|
|
37689
|
+
if (normalized.length <= MAX_SCOPE_LEN)
|
|
37690
|
+
return normalized;
|
|
37691
|
+
return `${normalized.slice(0, MAX_SCOPE_LEN)}\u2026`;
|
|
37692
|
+
}
|
|
37693
|
+
function isValidPositiveInteger(raw) {
|
|
37694
|
+
if (!raw || !/^\d+$/.test(raw))
|
|
37695
|
+
return false;
|
|
37696
|
+
const n = Number(raw);
|
|
37697
|
+
if (!Number.isFinite(n) || !Number.isInteger(n) || n < 0)
|
|
37698
|
+
return false;
|
|
37699
|
+
return true;
|
|
37700
|
+
}
|
|
37701
|
+
function parseArgs2(args) {
|
|
37702
|
+
const result = {
|
|
37703
|
+
profile: DEFAULT_PROFILE,
|
|
37704
|
+
maxExplorers: DEFAULT_MAX_EXPLORERS,
|
|
37705
|
+
output: "markdown",
|
|
37706
|
+
updateMain: true,
|
|
37707
|
+
allowDirty: false,
|
|
37708
|
+
rest: []
|
|
37709
|
+
};
|
|
37710
|
+
let i = 0;
|
|
37711
|
+
while (i < args.length) {
|
|
37712
|
+
const token = args[i];
|
|
37713
|
+
if (token === "--profile") {
|
|
37714
|
+
if (i + 1 >= args.length) {
|
|
37715
|
+
return { ...result, error: `Flag "${token}" requires a value` };
|
|
37716
|
+
}
|
|
37717
|
+
const value = args[++i];
|
|
37718
|
+
if (!PROFILES.has(value)) {
|
|
37719
|
+
return {
|
|
37720
|
+
...result,
|
|
37721
|
+
error: `Invalid profile "${value}". Must be one of: standard, security, ux, architecture, full.`
|
|
37722
|
+
};
|
|
37723
|
+
}
|
|
37724
|
+
result.profile = value;
|
|
37725
|
+
} else if (token === "--max-explorers") {
|
|
37726
|
+
if (i + 1 >= args.length) {
|
|
37727
|
+
return { ...result, error: `Flag "${token}" requires a value` };
|
|
37728
|
+
}
|
|
37729
|
+
const value = args[++i];
|
|
37730
|
+
if (!isValidPositiveInteger(value) || value.includes(".") || value.startsWith("0x") || value.startsWith("0X") || Number(value) < 1 || Number(value) > 8) {
|
|
37731
|
+
return {
|
|
37732
|
+
...result,
|
|
37733
|
+
error: `Invalid --max-explorers value "${value}". Must be an integer between 1 and 8.`
|
|
37734
|
+
};
|
|
37735
|
+
}
|
|
37736
|
+
result.maxExplorers = Number(value);
|
|
37737
|
+
result.maxExplorersExplicit = true;
|
|
37738
|
+
} else if (token === "--json") {
|
|
37739
|
+
result.output = "json";
|
|
37740
|
+
} else if (token === "--skip-update") {
|
|
37741
|
+
result.updateMain = false;
|
|
37742
|
+
} else if (token === "--allow-dirty") {
|
|
37743
|
+
result.allowDirty = true;
|
|
37744
|
+
} else if (token.startsWith("--")) {
|
|
37745
|
+
return { ...result, error: `Unknown flag "${token}"` };
|
|
37746
|
+
} else {
|
|
37747
|
+
result.rest.push(token);
|
|
37748
|
+
}
|
|
37749
|
+
i++;
|
|
37750
|
+
}
|
|
37751
|
+
return result;
|
|
37752
|
+
}
|
|
37753
|
+
async function handleDeepDiveCommand(_directory, args) {
|
|
37754
|
+
const parsed = parseArgs2(args);
|
|
37755
|
+
if (parsed.error) {
|
|
37756
|
+
return `Error: ${parsed.error}
|
|
37757
|
+
|
|
37758
|
+
${USAGE2}`;
|
|
37759
|
+
}
|
|
37760
|
+
const scope = sanitizeScope(parsed.rest.join(" "));
|
|
37761
|
+
if (!scope) {
|
|
37762
|
+
return USAGE2;
|
|
37763
|
+
}
|
|
37764
|
+
if (parsed.profile === "full" && !parsed.maxExplorersExplicit) {
|
|
37765
|
+
parsed.maxExplorers = FULL_PROFILE_DEFAULT_MAX_EXPLORERS;
|
|
37766
|
+
}
|
|
37767
|
+
const header = `[MODE: DEEP_DIVE profile=${parsed.profile} max_explorers=${parsed.maxExplorers} output=${parsed.output} update_main=${parsed.updateMain} allow_dirty=${parsed.allowDirty}] ${scope}`;
|
|
37768
|
+
return header;
|
|
37769
|
+
}
|
|
37770
|
+
var MAX_SCOPE_LEN = 2000, PROFILES, DEFAULT_PROFILE = "standard", DEFAULT_MAX_EXPLORERS = 6, FULL_PROFILE_DEFAULT_MAX_EXPLORERS = 8, USAGE2 = `Usage: /swarm deep-dive <scope> [--profile standard|security|ux|architecture|full] [--max-explorers N] [--json] [--skip-update] [--allow-dirty]
|
|
37771
|
+
|
|
37772
|
+
Run a bounded, evidence-backed deep dive on an application section.
|
|
37773
|
+
|
|
37774
|
+
Examples:
|
|
37775
|
+
/swarm deep-dive auth
|
|
37776
|
+
/swarm deep dive src/commands --profile architecture
|
|
37777
|
+
/swarm deep-dive "settings page" --profile ux
|
|
37778
|
+
/swarm deep-dive src/security --profile security --max-explorers 5
|
|
37779
|
+
|
|
37780
|
+
Flags:
|
|
37781
|
+
--profile <name> standard, security, ux, architecture, or full
|
|
37782
|
+
--max-explorers <N> explorer runs per wave, 1..8
|
|
37783
|
+
--json include machine-readable JSON in the final report
|
|
37784
|
+
--skip-update skip the repo update-to-main preflight
|
|
37785
|
+
--allow-dirty allow audit to proceed with dirty worktree`;
|
|
37786
|
+
var init_deep_dive = __esm(() => {
|
|
37787
|
+
PROFILES = new Set([
|
|
37788
|
+
"standard",
|
|
37789
|
+
"security",
|
|
37790
|
+
"ux",
|
|
37791
|
+
"architecture",
|
|
37792
|
+
"full"
|
|
37793
|
+
]);
|
|
37794
|
+
});
|
|
37795
|
+
|
|
37534
37796
|
// src/config/cache-paths.ts
|
|
37535
37797
|
import * as os5 from "os";
|
|
37536
37798
|
import * as path18 from "path";
|
|
@@ -37577,7 +37839,7 @@ function getPluginLockFilePaths() {
|
|
|
37577
37839
|
var init_cache_paths = () => {};
|
|
37578
37840
|
|
|
37579
37841
|
// src/services/version-check.ts
|
|
37580
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as
|
|
37842
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
37581
37843
|
import { homedir as homedir5 } from "os";
|
|
37582
37844
|
import { join as join17 } from "path";
|
|
37583
37845
|
function cacheDir() {
|
|
@@ -37593,7 +37855,7 @@ function readVersionCache() {
|
|
|
37593
37855
|
const path19 = cacheFile();
|
|
37594
37856
|
if (!existsSync9(path19))
|
|
37595
37857
|
return null;
|
|
37596
|
-
const raw =
|
|
37858
|
+
const raw = readFileSync6(path19, "utf-8");
|
|
37597
37859
|
const parsed = JSON.parse(raw);
|
|
37598
37860
|
if (typeof parsed?.checkedAt !== "number")
|
|
37599
37861
|
return null;
|
|
@@ -37632,7 +37894,7 @@ var init_version_check = __esm(() => {
|
|
|
37632
37894
|
|
|
37633
37895
|
// src/services/diagnose-service.ts
|
|
37634
37896
|
import * as child_process4 from "child_process";
|
|
37635
|
-
import { existsSync as existsSync10, readdirSync as readdirSync4, readFileSync as
|
|
37897
|
+
import { existsSync as existsSync10, readdirSync as readdirSync4, readFileSync as readFileSync7, statSync as statSync6 } from "fs";
|
|
37636
37898
|
import path19 from "path";
|
|
37637
37899
|
import { fileURLToPath } from "url";
|
|
37638
37900
|
function validateTaskDag(plan) {
|
|
@@ -37939,7 +38201,7 @@ async function checkConfigParseability(directory) {
|
|
|
37939
38201
|
};
|
|
37940
38202
|
}
|
|
37941
38203
|
try {
|
|
37942
|
-
const content =
|
|
38204
|
+
const content = readFileSync7(configPath, "utf-8");
|
|
37943
38205
|
JSON.parse(content);
|
|
37944
38206
|
return {
|
|
37945
38207
|
name: "Config Parseability",
|
|
@@ -38017,7 +38279,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
38017
38279
|
};
|
|
38018
38280
|
}
|
|
38019
38281
|
try {
|
|
38020
|
-
const content =
|
|
38282
|
+
const content = readFileSync7(manifestPath, "utf-8");
|
|
38021
38283
|
const parsed = JSON.parse(content);
|
|
38022
38284
|
if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
|
|
38023
38285
|
return {
|
|
@@ -38069,7 +38331,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
38069
38331
|
};
|
|
38070
38332
|
}
|
|
38071
38333
|
try {
|
|
38072
|
-
const content =
|
|
38334
|
+
const content = readFileSync7(eventsPath, "utf-8");
|
|
38073
38335
|
const lines = content.split(`
|
|
38074
38336
|
`).filter((line) => line.trim() !== "");
|
|
38075
38337
|
let malformedCount = 0;
|
|
@@ -38110,7 +38372,7 @@ async function checkSteeringDirectives(directory) {
|
|
|
38110
38372
|
};
|
|
38111
38373
|
}
|
|
38112
38374
|
try {
|
|
38113
|
-
const content =
|
|
38375
|
+
const content = readFileSync7(eventsPath, "utf-8");
|
|
38114
38376
|
const lines = content.split(`
|
|
38115
38377
|
`).filter((line) => line.trim() !== "");
|
|
38116
38378
|
const directivesIssued = [];
|
|
@@ -38166,7 +38428,7 @@ async function checkCurator(directory) {
|
|
|
38166
38428
|
};
|
|
38167
38429
|
}
|
|
38168
38430
|
try {
|
|
38169
|
-
const content =
|
|
38431
|
+
const content = readFileSync7(summaryPath, "utf-8");
|
|
38170
38432
|
const parsed = JSON.parse(content);
|
|
38171
38433
|
if (typeof parsed.schema_version !== "number" || parsed.schema_version !== 1) {
|
|
38172
38434
|
return {
|
|
@@ -38363,7 +38625,7 @@ async function getDiagnoseData(directory) {
|
|
|
38363
38625
|
}
|
|
38364
38626
|
const pkgJsonPath = path19.join(cachePath, "package.json");
|
|
38365
38627
|
try {
|
|
38366
|
-
const raw =
|
|
38628
|
+
const raw = readFileSync7(pkgJsonPath, "utf-8");
|
|
38367
38629
|
const parsed = JSON.parse(raw);
|
|
38368
38630
|
const installedVersion = typeof parsed.version === "string" ? parsed.version : "?";
|
|
38369
38631
|
cacheRows.push(`\u2705 ${cachePath} \u2014 v${installedVersion}`);
|
|
@@ -40250,7 +40512,7 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
40250
40512
|
const scope = options?.scope ?? "all";
|
|
40251
40513
|
const changedFiles = options?.changedFiles ?? [];
|
|
40252
40514
|
const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
|
|
40253
|
-
const profileResult = await
|
|
40515
|
+
const profileResult = await _internals11.discoverBuildCommandsFromProfiles(workingDir);
|
|
40254
40516
|
const profileCommands = profileResult.commands;
|
|
40255
40517
|
const profileSkipped = profileResult.skipped;
|
|
40256
40518
|
const coveredEcosystems = new Set;
|
|
@@ -40313,7 +40575,7 @@ function clearToolchainCache() {
|
|
|
40313
40575
|
function getEcosystems() {
|
|
40314
40576
|
return ECOSYSTEMS.map((e) => e.ecosystem);
|
|
40315
40577
|
}
|
|
40316
|
-
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache,
|
|
40578
|
+
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, _internals11, build_discovery;
|
|
40317
40579
|
var init_discovery = __esm(() => {
|
|
40318
40580
|
init_dist();
|
|
40319
40581
|
init_detector();
|
|
@@ -40431,7 +40693,7 @@ var init_discovery = __esm(() => {
|
|
|
40431
40693
|
php: ["php-composer"]
|
|
40432
40694
|
};
|
|
40433
40695
|
toolchainCache = new Map;
|
|
40434
|
-
|
|
40696
|
+
_internals11 = {
|
|
40435
40697
|
isCommandAvailable,
|
|
40436
40698
|
discoverBuildCommandsFromProfiles,
|
|
40437
40699
|
discoverBuildCommands,
|
|
@@ -40683,7 +40945,7 @@ var exports_evidence_summary_service = {};
|
|
|
40683
40945
|
__export(exports_evidence_summary_service, {
|
|
40684
40946
|
isAutoSummaryEnabled: () => isAutoSummaryEnabled,
|
|
40685
40947
|
buildEvidenceSummary: () => buildEvidenceSummary,
|
|
40686
|
-
_internals: () =>
|
|
40948
|
+
_internals: () => _internals12,
|
|
40687
40949
|
REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
|
|
40688
40950
|
EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
|
|
40689
40951
|
});
|
|
@@ -40721,14 +40983,14 @@ function getTaskStatus(task, bundle) {
|
|
|
40721
40983
|
if (task?.status) {
|
|
40722
40984
|
return task.status;
|
|
40723
40985
|
}
|
|
40724
|
-
const entries =
|
|
40986
|
+
const entries = _internals12.normalizeBundleEntries(bundle);
|
|
40725
40987
|
if (entries.length > 0) {
|
|
40726
40988
|
return "completed";
|
|
40727
40989
|
}
|
|
40728
40990
|
return "pending";
|
|
40729
40991
|
}
|
|
40730
40992
|
function isEvidenceComplete(bundle) {
|
|
40731
|
-
const entries =
|
|
40993
|
+
const entries = _internals12.normalizeBundleEntries(bundle);
|
|
40732
40994
|
if (entries.length === 0) {
|
|
40733
40995
|
return {
|
|
40734
40996
|
isComplete: false,
|
|
@@ -40764,10 +41026,10 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
40764
41026
|
const result = await loadEvidence(directory, taskId);
|
|
40765
41027
|
const bundle = result.status === "found" ? result.bundle : null;
|
|
40766
41028
|
const phase = task?.phase ?? 0;
|
|
40767
|
-
const status =
|
|
40768
|
-
const evidenceCheck =
|
|
40769
|
-
const blockers =
|
|
40770
|
-
const entries =
|
|
41029
|
+
const status = _internals12.getTaskStatus(task, bundle);
|
|
41030
|
+
const evidenceCheck = _internals12.isEvidenceComplete(bundle);
|
|
41031
|
+
const blockers = _internals12.getTaskBlockers(task, evidenceCheck, status);
|
|
41032
|
+
const entries = _internals12.normalizeBundleEntries(bundle);
|
|
40771
41033
|
const hasReview = entries.some((e) => e.type === "review");
|
|
40772
41034
|
const hasTest = entries.some((e) => e.type === "test");
|
|
40773
41035
|
const hasApproval = entries.some((e) => e.type === "approval");
|
|
@@ -40796,12 +41058,12 @@ async function buildPhaseSummary(directory, phase) {
|
|
|
40796
41058
|
const taskSummaries = [];
|
|
40797
41059
|
const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
|
|
40798
41060
|
for (const task of phase.tasks) {
|
|
40799
|
-
const summary = await
|
|
41061
|
+
const summary = await _internals12.buildTaskSummary(directory, task, task.id);
|
|
40800
41062
|
taskSummaries.push(summary);
|
|
40801
41063
|
}
|
|
40802
41064
|
const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
|
|
40803
41065
|
for (const taskId of extraTaskIds) {
|
|
40804
|
-
const summary = await
|
|
41066
|
+
const summary = await _internals12.buildTaskSummary(directory, undefined, taskId);
|
|
40805
41067
|
if (summary.phase === phase.id) {
|
|
40806
41068
|
taskSummaries.push(summary);
|
|
40807
41069
|
}
|
|
@@ -40902,7 +41164,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
40902
41164
|
let totalTasks = 0;
|
|
40903
41165
|
let completedTasks = 0;
|
|
40904
41166
|
for (const phase of phasesToProcess) {
|
|
40905
|
-
const summary = await
|
|
41167
|
+
const summary = await _internals12.buildPhaseSummary(directory, phase);
|
|
40906
41168
|
phaseSummaries.push(summary);
|
|
40907
41169
|
totalTasks += summary.totalTasks;
|
|
40908
41170
|
completedTasks += summary.completedTasks;
|
|
@@ -40924,7 +41186,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
40924
41186
|
overallBlockers,
|
|
40925
41187
|
summaryText: ""
|
|
40926
41188
|
};
|
|
40927
|
-
artifact.summaryText =
|
|
41189
|
+
artifact.summaryText = _internals12.generateSummaryText(artifact);
|
|
40928
41190
|
log("[EvidenceSummary] Summary built", {
|
|
40929
41191
|
phases: phaseSummaries.length,
|
|
40930
41192
|
totalTasks,
|
|
@@ -40943,7 +41205,7 @@ function isAutoSummaryEnabled(automationConfig) {
|
|
|
40943
41205
|
}
|
|
40944
41206
|
return automationConfig.capabilities?.evidence_auto_summaries === true;
|
|
40945
41207
|
}
|
|
40946
|
-
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0",
|
|
41208
|
+
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0", _internals12;
|
|
40947
41209
|
var init_evidence_summary_service = __esm(() => {
|
|
40948
41210
|
init_manager2();
|
|
40949
41211
|
init_manager();
|
|
@@ -40957,7 +41219,7 @@ var init_evidence_summary_service = __esm(() => {
|
|
|
40957
41219
|
"retrospective"
|
|
40958
41220
|
]);
|
|
40959
41221
|
REQUIRED_EVIDENCE_TYPES = ["review", "test"];
|
|
40960
|
-
|
|
41222
|
+
_internals12 = {
|
|
40961
41223
|
buildEvidenceSummary,
|
|
40962
41224
|
isAutoSummaryEnabled,
|
|
40963
41225
|
normalizeBundleEntries,
|
|
@@ -41560,7 +41822,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
41560
41822
|
if (!plan) {
|
|
41561
41823
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
41562
41824
|
}
|
|
41563
|
-
if (!
|
|
41825
|
+
if (!_internals13.validatePlanPhases(plan)) {
|
|
41564
41826
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
41565
41827
|
}
|
|
41566
41828
|
let currentPhase = null;
|
|
@@ -41702,9 +41964,9 @@ function extractPhaseMetrics(content) {
|
|
|
41702
41964
|
async function getHandoffData(directory) {
|
|
41703
41965
|
const now = new Date().toISOString();
|
|
41704
41966
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
41705
|
-
const sessionState =
|
|
41967
|
+
const sessionState = _internals13.parseSessionState(sessionContent);
|
|
41706
41968
|
const plan = await loadPlanJsonOnly(directory);
|
|
41707
|
-
const planInfo =
|
|
41969
|
+
const planInfo = _internals13.extractCurrentPhaseFromPlan(plan);
|
|
41708
41970
|
if (!plan) {
|
|
41709
41971
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
41710
41972
|
if (planMdContent) {
|
|
@@ -41723,8 +41985,8 @@ async function getHandoffData(directory) {
|
|
|
41723
41985
|
}
|
|
41724
41986
|
}
|
|
41725
41987
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
41726
|
-
const recentDecisions =
|
|
41727
|
-
const rawPhaseMetrics =
|
|
41988
|
+
const recentDecisions = _internals13.extractDecisions(contextContent);
|
|
41989
|
+
const rawPhaseMetrics = _internals13.extractPhaseMetrics(contextContent);
|
|
41728
41990
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
41729
41991
|
let delegationState = null;
|
|
41730
41992
|
if (sessionState?.delegationState) {
|
|
@@ -41888,13 +42150,13 @@ ${lines.join(`
|
|
|
41888
42150
|
`)}
|
|
41889
42151
|
\`\`\``;
|
|
41890
42152
|
}
|
|
41891
|
-
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20,
|
|
42153
|
+
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20, _internals13;
|
|
41892
42154
|
var init_handoff_service = __esm(() => {
|
|
41893
42155
|
init_utils2();
|
|
41894
42156
|
init_manager();
|
|
41895
42157
|
init_utils();
|
|
41896
42158
|
RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
|
|
41897
|
-
|
|
42159
|
+
_internals13 = {
|
|
41898
42160
|
getHandoffData,
|
|
41899
42161
|
formatHandoffMarkdown,
|
|
41900
42162
|
formatContinuationPrompt,
|
|
@@ -42013,22 +42275,22 @@ async function writeSnapshot(directory, state) {
|
|
|
42013
42275
|
}
|
|
42014
42276
|
function createSnapshotWriterHook(directory) {
|
|
42015
42277
|
return (_input, _output) => {
|
|
42016
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
42278
|
+
_writeInFlight = _writeInFlight.then(() => _internals14.writeSnapshot(directory, swarmState), () => _internals14.writeSnapshot(directory, swarmState));
|
|
42017
42279
|
return _writeInFlight;
|
|
42018
42280
|
};
|
|
42019
42281
|
}
|
|
42020
42282
|
async function flushPendingSnapshot(directory) {
|
|
42021
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
42283
|
+
_writeInFlight = _writeInFlight.then(() => _internals14.writeSnapshot(directory, swarmState), () => _internals14.writeSnapshot(directory, swarmState));
|
|
42022
42284
|
await _writeInFlight;
|
|
42023
42285
|
}
|
|
42024
|
-
var _writeInFlight,
|
|
42286
|
+
var _writeInFlight, _internals14;
|
|
42025
42287
|
var init_snapshot_writer = __esm(() => {
|
|
42026
42288
|
init_utils2();
|
|
42027
42289
|
init_state();
|
|
42028
42290
|
init_utils();
|
|
42029
42291
|
init_bun_compat();
|
|
42030
42292
|
_writeInFlight = Promise.resolve();
|
|
42031
|
-
|
|
42293
|
+
_internals14 = {
|
|
42032
42294
|
writeSnapshot,
|
|
42033
42295
|
createSnapshotWriterHook,
|
|
42034
42296
|
flushPendingSnapshot
|
|
@@ -42308,7 +42570,7 @@ function validateAndSanitizeUrl(rawUrl) {
|
|
|
42308
42570
|
return { error: "Invalid URL format" };
|
|
42309
42571
|
}
|
|
42310
42572
|
}
|
|
42311
|
-
function
|
|
42573
|
+
function parseArgs3(args) {
|
|
42312
42574
|
const out = {
|
|
42313
42575
|
plan: false,
|
|
42314
42576
|
trace: false,
|
|
@@ -42399,24 +42661,24 @@ function parseGitRemoteUrl(remoteUrl) {
|
|
|
42399
42661
|
return null;
|
|
42400
42662
|
}
|
|
42401
42663
|
function handleIssueCommand(_directory, args) {
|
|
42402
|
-
const parsed =
|
|
42664
|
+
const parsed = parseArgs3(args);
|
|
42403
42665
|
const rawInput = parsed.rest.join(" ").trim();
|
|
42404
42666
|
if (!rawInput) {
|
|
42405
|
-
return
|
|
42667
|
+
return USAGE3;
|
|
42406
42668
|
}
|
|
42407
42669
|
const isFullUrl = /^https?:\/\//i.test(rawInput);
|
|
42408
42670
|
const issueInfo = parseIssueRef(isFullUrl ? sanitizeUrl(rawInput) : rawInput);
|
|
42409
42671
|
if (!issueInfo) {
|
|
42410
42672
|
return `Error: Could not parse issue reference from "${rawInput}"
|
|
42411
42673
|
|
|
42412
|
-
${
|
|
42674
|
+
${USAGE3}`;
|
|
42413
42675
|
}
|
|
42414
42676
|
const issueUrl = `https://github.com/${issueInfo.owner}/${issueInfo.repo}/issues/${issueInfo.number}`;
|
|
42415
42677
|
const result = validateAndSanitizeUrl(issueUrl);
|
|
42416
42678
|
if ("error" in result) {
|
|
42417
42679
|
return `Error: ${result.error}
|
|
42418
42680
|
|
|
42419
|
-
${
|
|
42681
|
+
${USAGE3}`;
|
|
42420
42682
|
}
|
|
42421
42683
|
const flags = [];
|
|
42422
42684
|
if (parsed.plan)
|
|
@@ -42428,9 +42690,9 @@ ${USAGE2}`;
|
|
|
42428
42690
|
const flagsStr = flags.length > 0 ? ` ${flags.join(" ")}` : "";
|
|
42429
42691
|
return `[MODE: ISSUE_INGEST issue="${result.sanitized}"${flagsStr}]`;
|
|
42430
42692
|
}
|
|
42431
|
-
var MAX_URL_LEN = 2048,
|
|
42693
|
+
var MAX_URL_LEN = 2048, USAGE3;
|
|
42432
42694
|
var init_issue = __esm(() => {
|
|
42433
|
-
|
|
42695
|
+
USAGE3 = [
|
|
42434
42696
|
"Usage: /swarm issue <url|owner/repo#N|N> [--plan] [--trace] [--no-repro]",
|
|
42435
42697
|
"",
|
|
42436
42698
|
"Ingest a GitHub issue into the swarm workflow.",
|
|
@@ -42449,7 +42711,7 @@ var init_issue = __esm(() => {
|
|
|
42449
42711
|
|
|
42450
42712
|
// src/hooks/knowledge-migrator.ts
|
|
42451
42713
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
42452
|
-
import { existsSync as existsSync15, readFileSync as
|
|
42714
|
+
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
42453
42715
|
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile6 } from "fs/promises";
|
|
42454
42716
|
import * as path25 from "path";
|
|
42455
42717
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
@@ -42493,9 +42755,9 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42493
42755
|
skippedReason: "empty-context"
|
|
42494
42756
|
};
|
|
42495
42757
|
}
|
|
42496
|
-
const rawEntries =
|
|
42758
|
+
const rawEntries = _internals15.parseContextMd(contextContent);
|
|
42497
42759
|
if (rawEntries.length === 0) {
|
|
42498
|
-
await
|
|
42760
|
+
await _internals15.writeSentinel(sentinelPath, 0, 0);
|
|
42499
42761
|
return {
|
|
42500
42762
|
migrated: true,
|
|
42501
42763
|
entriesMigrated: 0,
|
|
@@ -42506,10 +42768,10 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42506
42768
|
const existing = await readKnowledge(knowledgePath);
|
|
42507
42769
|
let migrated = 0;
|
|
42508
42770
|
let dropped = 0;
|
|
42509
|
-
const projectName =
|
|
42771
|
+
const projectName = _internals15.inferProjectName(directory);
|
|
42510
42772
|
for (const raw of rawEntries) {
|
|
42511
42773
|
if (config3.validation_enabled !== false) {
|
|
42512
|
-
const category = raw.categoryHint ??
|
|
42774
|
+
const category = raw.categoryHint ?? _internals15.inferCategoryFromText(raw.text);
|
|
42513
42775
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
42514
42776
|
category,
|
|
42515
42777
|
scope: "global",
|
|
@@ -42529,8 +42791,8 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42529
42791
|
const entry = {
|
|
42530
42792
|
id: randomUUID2(),
|
|
42531
42793
|
tier: "swarm",
|
|
42532
|
-
lesson:
|
|
42533
|
-
category: raw.categoryHint ??
|
|
42794
|
+
lesson: _internals15.truncateLesson(raw.text),
|
|
42795
|
+
category: raw.categoryHint ?? _internals15.inferCategoryFromText(raw.text),
|
|
42534
42796
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
42535
42797
|
scope: "global",
|
|
42536
42798
|
confidence: 0.3,
|
|
@@ -42553,7 +42815,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42553
42815
|
if (migrated > 0) {
|
|
42554
42816
|
await rewriteKnowledge(knowledgePath, existing);
|
|
42555
42817
|
}
|
|
42556
|
-
await
|
|
42818
|
+
await _internals15.writeSentinel(sentinelPath, migrated, dropped);
|
|
42557
42819
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
42558
42820
|
return {
|
|
42559
42821
|
migrated: true,
|
|
@@ -42563,7 +42825,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42563
42825
|
};
|
|
42564
42826
|
}
|
|
42565
42827
|
function parseContextMd(content) {
|
|
42566
|
-
const sections =
|
|
42828
|
+
const sections = _internals15.splitIntoSections(content);
|
|
42567
42829
|
const entries = [];
|
|
42568
42830
|
const seen = new Set;
|
|
42569
42831
|
const sectionPatterns = [
|
|
@@ -42579,7 +42841,7 @@ function parseContextMd(content) {
|
|
|
42579
42841
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
42580
42842
|
if (!match)
|
|
42581
42843
|
continue;
|
|
42582
|
-
const bullets =
|
|
42844
|
+
const bullets = _internals15.extractBullets(section.body);
|
|
42583
42845
|
for (const bullet of bullets) {
|
|
42584
42846
|
if (bullet.length < 15)
|
|
42585
42847
|
continue;
|
|
@@ -42588,9 +42850,9 @@ function parseContextMd(content) {
|
|
|
42588
42850
|
continue;
|
|
42589
42851
|
seen.add(normalized);
|
|
42590
42852
|
entries.push({
|
|
42591
|
-
text:
|
|
42853
|
+
text: _internals15.truncateLesson(bullet),
|
|
42592
42854
|
sourceSection: match.sourceSection,
|
|
42593
|
-
categoryHint:
|
|
42855
|
+
categoryHint: _internals15.inferCategoryFromText(bullet)
|
|
42594
42856
|
});
|
|
42595
42857
|
}
|
|
42596
42858
|
}
|
|
@@ -42662,7 +42924,7 @@ function inferProjectName(directory) {
|
|
|
42662
42924
|
const packageJsonPath = path25.join(directory, "package.json");
|
|
42663
42925
|
if (existsSync15(packageJsonPath)) {
|
|
42664
42926
|
try {
|
|
42665
|
-
const pkg = JSON.parse(
|
|
42927
|
+
const pkg = JSON.parse(readFileSync12(packageJsonPath, "utf-8"));
|
|
42666
42928
|
if (pkg.name && typeof pkg.name === "string") {
|
|
42667
42929
|
return pkg.name;
|
|
42668
42930
|
}
|
|
@@ -42683,12 +42945,12 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
42683
42945
|
await mkdir5(path25.dirname(sentinelPath), { recursive: true });
|
|
42684
42946
|
await writeFile6(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
42685
42947
|
}
|
|
42686
|
-
var
|
|
42948
|
+
var _internals15;
|
|
42687
42949
|
var init_knowledge_migrator = __esm(() => {
|
|
42688
42950
|
init_logger();
|
|
42689
42951
|
init_knowledge_store();
|
|
42690
42952
|
init_knowledge_validator();
|
|
42691
|
-
|
|
42953
|
+
_internals15 = {
|
|
42692
42954
|
migrateContextToKnowledge,
|
|
42693
42955
|
migrateKnowledgeToExternal,
|
|
42694
42956
|
parseContextMd,
|
|
@@ -43047,7 +43309,7 @@ function validateAndSanitizeUrl2(rawUrl) {
|
|
|
43047
43309
|
return { error: "Invalid URL format" };
|
|
43048
43310
|
}
|
|
43049
43311
|
}
|
|
43050
|
-
function
|
|
43312
|
+
function parseArgs4(args) {
|
|
43051
43313
|
const out = { council: false, rest: [] };
|
|
43052
43314
|
for (const token of args) {
|
|
43053
43315
|
if (token === "--council") {
|
|
@@ -43131,31 +43393,31 @@ function parseGitRemoteUrl2(remoteUrl) {
|
|
|
43131
43393
|
return null;
|
|
43132
43394
|
}
|
|
43133
43395
|
function handlePrReviewCommand(_directory, args) {
|
|
43134
|
-
const parsed =
|
|
43396
|
+
const parsed = parseArgs4(args);
|
|
43135
43397
|
const rawInput = parsed.rest.join(" ").trim();
|
|
43136
43398
|
if (!rawInput) {
|
|
43137
|
-
return
|
|
43399
|
+
return USAGE4;
|
|
43138
43400
|
}
|
|
43139
43401
|
const isFullUrl = /^https?:\/\//i.test(rawInput);
|
|
43140
43402
|
const prInfo = parsePrRef(isFullUrl ? sanitizeUrl2(rawInput) : rawInput);
|
|
43141
43403
|
if (!prInfo) {
|
|
43142
43404
|
return `Error: Could not parse PR reference from "${rawInput}"
|
|
43143
43405
|
|
|
43144
|
-
${
|
|
43406
|
+
${USAGE4}`;
|
|
43145
43407
|
}
|
|
43146
43408
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
43147
43409
|
const result = validateAndSanitizeUrl2(prUrl);
|
|
43148
43410
|
if ("error" in result) {
|
|
43149
43411
|
return `Error: ${result.error}
|
|
43150
43412
|
|
|
43151
|
-
${
|
|
43413
|
+
${USAGE4}`;
|
|
43152
43414
|
}
|
|
43153
43415
|
const councilFlag = parsed.council ? "council=true" : "council=false";
|
|
43154
43416
|
return `[MODE: PR_REVIEW pr="${result.sanitized}" ${councilFlag}]`;
|
|
43155
43417
|
}
|
|
43156
|
-
var MAX_URL_LEN2 = 2048,
|
|
43418
|
+
var MAX_URL_LEN2 = 2048, USAGE4;
|
|
43157
43419
|
var init_pr_review = __esm(() => {
|
|
43158
|
-
|
|
43420
|
+
USAGE4 = [
|
|
43159
43421
|
"Usage: /swarm pr-review <url|owner/repo#N|N> [--council]",
|
|
43160
43422
|
"",
|
|
43161
43423
|
"Run a full swarm PR review on a GitHub pull request.",
|
|
@@ -43554,7 +43816,7 @@ async function runAdditionalLint(linter, mode, cwd) {
|
|
|
43554
43816
|
};
|
|
43555
43817
|
}
|
|
43556
43818
|
}
|
|
43557
|
-
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint,
|
|
43819
|
+
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals16;
|
|
43558
43820
|
var init_lint = __esm(() => {
|
|
43559
43821
|
init_zod();
|
|
43560
43822
|
init_discovery();
|
|
@@ -43586,15 +43848,15 @@ var init_lint = __esm(() => {
|
|
|
43586
43848
|
}
|
|
43587
43849
|
const { mode } = args;
|
|
43588
43850
|
const cwd = directory;
|
|
43589
|
-
const linter = await
|
|
43851
|
+
const linter = await _internals16.detectAvailableLinter(directory);
|
|
43590
43852
|
if (linter) {
|
|
43591
|
-
const result = await
|
|
43853
|
+
const result = await _internals16.runLint(linter, mode, directory);
|
|
43592
43854
|
return JSON.stringify(result, null, 2);
|
|
43593
43855
|
}
|
|
43594
|
-
const additionalLinter =
|
|
43856
|
+
const additionalLinter = _internals16.detectAdditionalLinter(cwd);
|
|
43595
43857
|
if (additionalLinter) {
|
|
43596
43858
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
43597
|
-
const result = await
|
|
43859
|
+
const result = await _internals16.runAdditionalLint(additionalLinter, mode, cwd);
|
|
43598
43860
|
return JSON.stringify(result, null, 2);
|
|
43599
43861
|
}
|
|
43600
43862
|
const errorResult = {
|
|
@@ -43608,7 +43870,7 @@ For Rust: rustup component add clippy`
|
|
|
43608
43870
|
return JSON.stringify(errorResult, null, 2);
|
|
43609
43871
|
}
|
|
43610
43872
|
});
|
|
43611
|
-
|
|
43873
|
+
_internals16 = {
|
|
43612
43874
|
detectAvailableLinter,
|
|
43613
43875
|
runLint,
|
|
43614
43876
|
detectAdditionalLinter,
|
|
@@ -43922,7 +44184,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
43922
44184
|
}
|
|
43923
44185
|
async function runSecretscan(directory) {
|
|
43924
44186
|
try {
|
|
43925
|
-
const result = await
|
|
44187
|
+
const result = await _internals17.secretscan.execute({ directory }, {});
|
|
43926
44188
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
43927
44189
|
return JSON.parse(jsonStr);
|
|
43928
44190
|
} catch (e) {
|
|
@@ -43937,7 +44199,7 @@ async function runSecretscan(directory) {
|
|
|
43937
44199
|
return errorResult;
|
|
43938
44200
|
}
|
|
43939
44201
|
}
|
|
43940
|
-
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS, O_NOFOLLOW, secretscan,
|
|
44202
|
+
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS, O_NOFOLLOW, secretscan, _internals17;
|
|
43941
44203
|
var init_secretscan = __esm(() => {
|
|
43942
44204
|
init_zod();
|
|
43943
44205
|
init_path_security();
|
|
@@ -44309,7 +44571,7 @@ var init_secretscan = __esm(() => {
|
|
|
44309
44571
|
}
|
|
44310
44572
|
}
|
|
44311
44573
|
});
|
|
44312
|
-
|
|
44574
|
+
_internals17 = {
|
|
44313
44575
|
secretscan,
|
|
44314
44576
|
runSecretscan
|
|
44315
44577
|
};
|
|
@@ -44444,8 +44706,8 @@ async function buildImpactMapInternal(cwd) {
|
|
|
44444
44706
|
return impactMap;
|
|
44445
44707
|
}
|
|
44446
44708
|
async function buildImpactMap(cwd) {
|
|
44447
|
-
const impactMap = await
|
|
44448
|
-
await
|
|
44709
|
+
const impactMap = await _internals18.buildImpactMapInternal(cwd);
|
|
44710
|
+
await _internals18.saveImpactMap(cwd, impactMap);
|
|
44449
44711
|
return impactMap;
|
|
44450
44712
|
}
|
|
44451
44713
|
async function loadImpactMap(cwd) {
|
|
@@ -44456,12 +44718,12 @@ async function loadImpactMap(cwd) {
|
|
|
44456
44718
|
const data = JSON.parse(content);
|
|
44457
44719
|
const map3 = data.map;
|
|
44458
44720
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
44459
|
-
if (!
|
|
44721
|
+
if (!_internals18.isCacheStale(map3, generatedAt)) {
|
|
44460
44722
|
return map3;
|
|
44461
44723
|
}
|
|
44462
44724
|
} catch {}
|
|
44463
44725
|
}
|
|
44464
|
-
return
|
|
44726
|
+
return _internals18.buildImpactMap(cwd);
|
|
44465
44727
|
}
|
|
44466
44728
|
async function saveImpactMap(cwd, impactMap) {
|
|
44467
44729
|
const cacheDir2 = path28.join(cwd, ".swarm", "cache");
|
|
@@ -44487,7 +44749,7 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
44487
44749
|
};
|
|
44488
44750
|
}
|
|
44489
44751
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
44490
|
-
const impactMap = await
|
|
44752
|
+
const impactMap = await _internals18.loadImpactMap(cwd);
|
|
44491
44753
|
const impactedTestsSet = new Set;
|
|
44492
44754
|
const untestedFiles = [];
|
|
44493
44755
|
for (const changedFile of validFiles) {
|
|
@@ -44528,13 +44790,13 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
44528
44790
|
impactMap
|
|
44529
44791
|
};
|
|
44530
44792
|
}
|
|
44531
|
-
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, EXTENSIONS_TO_TRY,
|
|
44793
|
+
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, EXTENSIONS_TO_TRY, _internals18;
|
|
44532
44794
|
var init_analyzer = __esm(() => {
|
|
44533
44795
|
IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
44534
44796
|
IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
44535
44797
|
IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
44536
44798
|
EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
44537
|
-
|
|
44799
|
+
_internals18 = {
|
|
44538
44800
|
normalizePath,
|
|
44539
44801
|
isCacheStale,
|
|
44540
44802
|
resolveRelativeImport,
|
|
@@ -46381,9 +46643,9 @@ function getVersionFileVersion(dir) {
|
|
|
46381
46643
|
async function runVersionCheck(dir, _timeoutMs) {
|
|
46382
46644
|
const startTime = Date.now();
|
|
46383
46645
|
try {
|
|
46384
|
-
const packageVersion =
|
|
46385
|
-
const changelogVersion =
|
|
46386
|
-
const versionFileVersion =
|
|
46646
|
+
const packageVersion = _internals19.getPackageVersion(dir);
|
|
46647
|
+
const changelogVersion = _internals19.getChangelogVersion(dir);
|
|
46648
|
+
const versionFileVersion = _internals19.getVersionFileVersion(dir);
|
|
46387
46649
|
const versions3 = [];
|
|
46388
46650
|
if (packageVersion)
|
|
46389
46651
|
versions3.push(`package.json: ${packageVersion}`);
|
|
@@ -46733,7 +46995,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46733
46995
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
46734
46996
|
let validatedDir;
|
|
46735
46997
|
try {
|
|
46736
|
-
validatedDir =
|
|
46998
|
+
validatedDir = _internals19.validateDirectoryPath(dir);
|
|
46737
46999
|
} catch (error93) {
|
|
46738
47000
|
return {
|
|
46739
47001
|
id: reportId,
|
|
@@ -46753,7 +47015,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46753
47015
|
}
|
|
46754
47016
|
let validatedTimeout;
|
|
46755
47017
|
try {
|
|
46756
|
-
validatedTimeout =
|
|
47018
|
+
validatedTimeout = _internals19.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
46757
47019
|
} catch (error93) {
|
|
46758
47020
|
return {
|
|
46759
47021
|
id: reportId,
|
|
@@ -46794,12 +47056,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46794
47056
|
});
|
|
46795
47057
|
const checks5 = [];
|
|
46796
47058
|
log("[Preflight] Running lint check...");
|
|
46797
|
-
const lintResult = await
|
|
47059
|
+
const lintResult = await _internals19.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
46798
47060
|
checks5.push(lintResult);
|
|
46799
47061
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
46800
47062
|
if (!cfg.skipTests) {
|
|
46801
47063
|
log("[Preflight] Running tests check...");
|
|
46802
|
-
const testsResult = await
|
|
47064
|
+
const testsResult = await _internals19.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
46803
47065
|
checks5.push(testsResult);
|
|
46804
47066
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
46805
47067
|
} else {
|
|
@@ -46811,7 +47073,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46811
47073
|
}
|
|
46812
47074
|
if (!cfg.skipSecrets) {
|
|
46813
47075
|
log("[Preflight] Running secrets check...");
|
|
46814
|
-
const secretsResult = await
|
|
47076
|
+
const secretsResult = await _internals19.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
46815
47077
|
checks5.push(secretsResult);
|
|
46816
47078
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
46817
47079
|
} else {
|
|
@@ -46823,7 +47085,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46823
47085
|
}
|
|
46824
47086
|
if (!cfg.skipEvidence) {
|
|
46825
47087
|
log("[Preflight] Running evidence check...");
|
|
46826
|
-
const evidenceResult = await
|
|
47088
|
+
const evidenceResult = await _internals19.runEvidenceCheck(validatedDir);
|
|
46827
47089
|
checks5.push(evidenceResult);
|
|
46828
47090
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
46829
47091
|
} else {
|
|
@@ -46834,12 +47096,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46834
47096
|
});
|
|
46835
47097
|
}
|
|
46836
47098
|
log("[Preflight] Running requirement coverage check...");
|
|
46837
|
-
const reqCoverageResult = await
|
|
47099
|
+
const reqCoverageResult = await _internals19.runRequirementCoverageCheck(validatedDir, phase);
|
|
46838
47100
|
checks5.push(reqCoverageResult);
|
|
46839
47101
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
46840
47102
|
if (!cfg.skipVersion) {
|
|
46841
47103
|
log("[Preflight] Running version check...");
|
|
46842
|
-
const versionResult = await
|
|
47104
|
+
const versionResult = await _internals19.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
46843
47105
|
checks5.push(versionResult);
|
|
46844
47106
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
46845
47107
|
} else {
|
|
@@ -46902,10 +47164,10 @@ function formatPreflightMarkdown(report) {
|
|
|
46902
47164
|
async function handlePreflightCommand(directory, _args) {
|
|
46903
47165
|
const plan = await loadPlan(directory);
|
|
46904
47166
|
const phase = plan?.current_phase ?? 1;
|
|
46905
|
-
const report = await
|
|
46906
|
-
return
|
|
47167
|
+
const report = await _internals19.runPreflight(directory, phase);
|
|
47168
|
+
return _internals19.formatPreflightMarkdown(report);
|
|
46907
47169
|
}
|
|
46908
|
-
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG,
|
|
47170
|
+
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals19;
|
|
46909
47171
|
var init_preflight_service = __esm(() => {
|
|
46910
47172
|
init_manager2();
|
|
46911
47173
|
init_manager();
|
|
@@ -46922,7 +47184,7 @@ var init_preflight_service = __esm(() => {
|
|
|
46922
47184
|
testScope: "convention",
|
|
46923
47185
|
linter: "biome"
|
|
46924
47186
|
};
|
|
46925
|
-
|
|
47187
|
+
_internals19 = {
|
|
46926
47188
|
runPreflight,
|
|
46927
47189
|
formatPreflightMarkdown,
|
|
46928
47190
|
handlePreflightCommand,
|
|
@@ -48179,7 +48441,7 @@ async function handleSimulateCommand(directory, args) {
|
|
|
48179
48441
|
}
|
|
48180
48442
|
let darkMatterPairs;
|
|
48181
48443
|
try {
|
|
48182
|
-
darkMatterPairs = await
|
|
48444
|
+
darkMatterPairs = await _internals10.detectDarkMatter(directory, options);
|
|
48183
48445
|
} catch (err) {
|
|
48184
48446
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
48185
48447
|
return `## Simulate Report
|
|
@@ -48233,6 +48495,158 @@ async function handleSpecifyCommand(_directory, args) {
|
|
|
48233
48495
|
return "[MODE: SPECIFY] Please enter MODE: SPECIFY and generate a spec for this project.";
|
|
48234
48496
|
}
|
|
48235
48497
|
|
|
48498
|
+
// src/turbo/lean/state.ts
|
|
48499
|
+
import * as fs22 from "fs";
|
|
48500
|
+
import * as path37 from "path";
|
|
48501
|
+
function nowISO2() {
|
|
48502
|
+
return new Date().toISOString();
|
|
48503
|
+
}
|
|
48504
|
+
function ensureSwarmDir2(directory) {
|
|
48505
|
+
const swarmDir = path37.resolve(directory, ".swarm");
|
|
48506
|
+
if (!fs22.existsSync(swarmDir)) {
|
|
48507
|
+
fs22.mkdirSync(swarmDir, { recursive: true });
|
|
48508
|
+
}
|
|
48509
|
+
return swarmDir;
|
|
48510
|
+
}
|
|
48511
|
+
function emptyCounters2() {
|
|
48512
|
+
return {
|
|
48513
|
+
lanesPlanned: 0,
|
|
48514
|
+
lanesStarted: 0,
|
|
48515
|
+
lanesCompleted: 0,
|
|
48516
|
+
lanesFailed: 0,
|
|
48517
|
+
tasksSerialized: 0,
|
|
48518
|
+
tasksDegraded: 0
|
|
48519
|
+
};
|
|
48520
|
+
}
|
|
48521
|
+
function emptyRunState(sessionID, maxParallelCoders) {
|
|
48522
|
+
return {
|
|
48523
|
+
status: "idle",
|
|
48524
|
+
sessionID,
|
|
48525
|
+
strategy: "lean",
|
|
48526
|
+
maxParallelCoders,
|
|
48527
|
+
lanes: [],
|
|
48528
|
+
degradedTasks: [],
|
|
48529
|
+
serializedTasks: [],
|
|
48530
|
+
counters: emptyCounters2()
|
|
48531
|
+
};
|
|
48532
|
+
}
|
|
48533
|
+
function emptyPersisted2() {
|
|
48534
|
+
return {
|
|
48535
|
+
version: 1,
|
|
48536
|
+
updatedAt: nowISO2(),
|
|
48537
|
+
sessions: {}
|
|
48538
|
+
};
|
|
48539
|
+
}
|
|
48540
|
+
function isStateUnreadable(directory) {
|
|
48541
|
+
return stateUnreadableMap.get(directory) ?? false;
|
|
48542
|
+
}
|
|
48543
|
+
function markStateUnreadable2(directory, reason) {
|
|
48544
|
+
stateUnreadableMap.set(directory, true);
|
|
48545
|
+
error(`[turbo/lean/state] state file unreadable for ${directory}: ${reason} \u2014 failing closed`);
|
|
48546
|
+
}
|
|
48547
|
+
function readPersisted2(directory) {
|
|
48548
|
+
try {
|
|
48549
|
+
const filePath = path37.join(directory, ".swarm", STATE_FILE2);
|
|
48550
|
+
if (!fs22.existsSync(filePath)) {
|
|
48551
|
+
const seed = emptyPersisted2();
|
|
48552
|
+
try {
|
|
48553
|
+
ensureSwarmDir2(directory);
|
|
48554
|
+
fs22.writeFileSync(filePath, `${JSON.stringify(seed, null, 2)}
|
|
48555
|
+
`, "utf-8");
|
|
48556
|
+
} catch {}
|
|
48557
|
+
return seed;
|
|
48558
|
+
}
|
|
48559
|
+
const raw = fs22.readFileSync(filePath, "utf-8");
|
|
48560
|
+
const parsed = JSON.parse(raw);
|
|
48561
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || parsed.version !== 1 || !parsed.sessions || typeof parsed.sessions !== "object" || Array.isArray(parsed.sessions)) {
|
|
48562
|
+
markStateUnreadable2(directory, `malformed shape (version=${parsed?.version}, sessions type=${Array.isArray(parsed?.sessions) ? "array" : typeof parsed?.sessions})`);
|
|
48563
|
+
return null;
|
|
48564
|
+
}
|
|
48565
|
+
return {
|
|
48566
|
+
version: 1,
|
|
48567
|
+
updatedAt: parsed.updatedAt ?? nowISO2(),
|
|
48568
|
+
sessions: parsed.sessions
|
|
48569
|
+
};
|
|
48570
|
+
} catch (error93) {
|
|
48571
|
+
const reason = error93 instanceof Error ? error93.message : String(error93);
|
|
48572
|
+
markStateUnreadable2(directory, reason);
|
|
48573
|
+
return null;
|
|
48574
|
+
}
|
|
48575
|
+
}
|
|
48576
|
+
function writePersisted2(directory, persisted) {
|
|
48577
|
+
if (stateUnreadableMap.get(directory)) {
|
|
48578
|
+
throw new Error(`Lean Turbo state is unreadable. Please repair .swarm/${STATE_FILE2} before continuing.`);
|
|
48579
|
+
}
|
|
48580
|
+
let filePath;
|
|
48581
|
+
let tmpPath;
|
|
48582
|
+
let payload;
|
|
48583
|
+
try {
|
|
48584
|
+
ensureSwarmDir2(directory);
|
|
48585
|
+
filePath = path37.join(directory, ".swarm", STATE_FILE2);
|
|
48586
|
+
tmpPath = `${filePath}.tmp.${Date.now()}`;
|
|
48587
|
+
persisted.updatedAt = nowISO2();
|
|
48588
|
+
payload = `${JSON.stringify(persisted, null, 2)}
|
|
48589
|
+
`;
|
|
48590
|
+
} catch (error93) {
|
|
48591
|
+
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
48592
|
+
error(`[turbo/lean/state] Failed to prepare ${STATE_FILE2} write: ${msg}`);
|
|
48593
|
+
throw new Error(`Lean Turbo state persistence prepare failed: ${msg}`);
|
|
48594
|
+
}
|
|
48595
|
+
try {
|
|
48596
|
+
fs22.writeFileSync(tmpPath, payload, "utf-8");
|
|
48597
|
+
fs22.renameSync(tmpPath, filePath);
|
|
48598
|
+
} catch (error93) {
|
|
48599
|
+
const msg = error93 instanceof Error ? error93.message : String(error93);
|
|
48600
|
+
error(`[turbo/lean/state] Failed to persist ${STATE_FILE2} atomically: ${msg}`);
|
|
48601
|
+
try {
|
|
48602
|
+
if (fs22.existsSync(tmpPath)) {
|
|
48603
|
+
fs22.unlinkSync(tmpPath);
|
|
48604
|
+
}
|
|
48605
|
+
} catch {}
|
|
48606
|
+
throw new Error(`Lean Turbo state persistence failed: ${msg}`);
|
|
48607
|
+
}
|
|
48608
|
+
}
|
|
48609
|
+
function loadLeanTurboRunState(directory, sessionID) {
|
|
48610
|
+
if (stateUnreadableMap.get(directory))
|
|
48611
|
+
return null;
|
|
48612
|
+
const persisted = readPersisted2(directory);
|
|
48613
|
+
if (!persisted)
|
|
48614
|
+
return null;
|
|
48615
|
+
return persisted.sessions[sessionID] ?? null;
|
|
48616
|
+
}
|
|
48617
|
+
function saveLeanTurboRunState(directory, runState) {
|
|
48618
|
+
if (stateUnreadableMap.get(directory)) {
|
|
48619
|
+
throw new Error(`Lean Turbo state is unreadable for ${directory}. Please repair .swarm/${STATE_FILE2} before continuing.`);
|
|
48620
|
+
}
|
|
48621
|
+
const persisted = readPersisted2(directory);
|
|
48622
|
+
if (!persisted) {
|
|
48623
|
+
throw new Error(`Lean Turbo state is unreadable for ${directory}. Please repair .swarm/${STATE_FILE2} before continuing.`);
|
|
48624
|
+
}
|
|
48625
|
+
persisted.sessions[runState.sessionID] = runState;
|
|
48626
|
+
writePersisted2(directory, persisted);
|
|
48627
|
+
}
|
|
48628
|
+
function pauseLeanTurboRun(directory, sessionID, reason) {
|
|
48629
|
+
if (stateUnreadableMap.get(directory)) {
|
|
48630
|
+
throw new Error(`Lean Turbo state is unreadable for ${directory}. Please repair .swarm/${STATE_FILE2} before continuing.`);
|
|
48631
|
+
}
|
|
48632
|
+
const persisted = readPersisted2(directory);
|
|
48633
|
+
if (!persisted) {
|
|
48634
|
+
throw new Error(`Lean Turbo state is unreadable for ${directory}. Please repair .swarm/${STATE_FILE2} before continuing.`);
|
|
48635
|
+
}
|
|
48636
|
+
const state = persisted.sessions[sessionID];
|
|
48637
|
+
if (!state)
|
|
48638
|
+
return;
|
|
48639
|
+
state.status = "paused";
|
|
48640
|
+
state.pauseReason = reason;
|
|
48641
|
+
persisted.sessions[sessionID] = state;
|
|
48642
|
+
writePersisted2(directory, persisted);
|
|
48643
|
+
}
|
|
48644
|
+
var STATE_FILE2 = "turbo-state.json", stateUnreadableMap;
|
|
48645
|
+
var init_state3 = __esm(() => {
|
|
48646
|
+
init_logger();
|
|
48647
|
+
stateUnreadableMap = new Map;
|
|
48648
|
+
});
|
|
48649
|
+
|
|
48236
48650
|
// src/services/compaction-service.ts
|
|
48237
48651
|
function makeInitialState() {
|
|
48238
48652
|
return {
|
|
@@ -48296,66 +48710,126 @@ var init_context_budget_service = __esm(() => {
|
|
|
48296
48710
|
// src/services/status-service.ts
|
|
48297
48711
|
async function getStatusData(directory, agents) {
|
|
48298
48712
|
const plan = await loadPlan(directory);
|
|
48713
|
+
let status;
|
|
48299
48714
|
if (plan && plan.migration_status !== "migration_failed") {
|
|
48300
|
-
const
|
|
48301
|
-
let
|
|
48302
|
-
let
|
|
48715
|
+
const currentPhase = extractCurrentPhaseFromPlan(plan) || "Unknown";
|
|
48716
|
+
let completedTasks = 0;
|
|
48717
|
+
let totalTasks = 0;
|
|
48303
48718
|
for (const phase of plan.phases) {
|
|
48304
48719
|
for (const task of phase.tasks) {
|
|
48305
|
-
|
|
48720
|
+
totalTasks++;
|
|
48306
48721
|
if (task.status === "completed")
|
|
48307
|
-
|
|
48722
|
+
completedTasks++;
|
|
48308
48723
|
}
|
|
48309
48724
|
}
|
|
48310
|
-
const
|
|
48311
|
-
const
|
|
48312
|
-
|
|
48725
|
+
const agentCount = Object.keys(agents).length;
|
|
48726
|
+
const metrics = getCompactionMetrics();
|
|
48727
|
+
status = {
|
|
48313
48728
|
hasPlan: true,
|
|
48314
|
-
currentPhase
|
|
48315
|
-
completedTasks
|
|
48316
|
-
totalTasks
|
|
48317
|
-
agentCount
|
|
48729
|
+
currentPhase,
|
|
48730
|
+
completedTasks,
|
|
48731
|
+
totalTasks,
|
|
48732
|
+
agentCount,
|
|
48318
48733
|
isLegacy: false,
|
|
48319
48734
|
turboMode: hasActiveTurboMode(),
|
|
48320
48735
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
48321
|
-
compactionCount:
|
|
48322
|
-
lastSnapshotAt:
|
|
48736
|
+
compactionCount: metrics.compactionCount,
|
|
48737
|
+
lastSnapshotAt: metrics.lastSnapshotAt
|
|
48323
48738
|
};
|
|
48739
|
+
} else {
|
|
48740
|
+
const planContent = await readSwarmFileAsync(directory, "plan.md");
|
|
48741
|
+
if (!planContent) {
|
|
48742
|
+
const metrics = getCompactionMetrics();
|
|
48743
|
+
status = {
|
|
48744
|
+
hasPlan: false,
|
|
48745
|
+
currentPhase: "Unknown",
|
|
48746
|
+
completedTasks: 0,
|
|
48747
|
+
totalTasks: 0,
|
|
48748
|
+
agentCount: Object.keys(agents).length,
|
|
48749
|
+
isLegacy: true,
|
|
48750
|
+
turboMode: hasActiveTurboMode(),
|
|
48751
|
+
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
48752
|
+
compactionCount: metrics.compactionCount,
|
|
48753
|
+
lastSnapshotAt: metrics.lastSnapshotAt
|
|
48754
|
+
};
|
|
48755
|
+
} else {
|
|
48756
|
+
const currentPhase = extractCurrentPhase(planContent) || "Unknown";
|
|
48757
|
+
const completedTasks = (planContent.match(/^- \[x\]/gm) || []).length;
|
|
48758
|
+
const incompleteTasks = (planContent.match(/^- \[ \]/gm) || []).length;
|
|
48759
|
+
const totalTasks = completedTasks + incompleteTasks;
|
|
48760
|
+
const agentCount = Object.keys(agents).length;
|
|
48761
|
+
const metrics = getCompactionMetrics();
|
|
48762
|
+
status = {
|
|
48763
|
+
hasPlan: true,
|
|
48764
|
+
currentPhase,
|
|
48765
|
+
completedTasks,
|
|
48766
|
+
totalTasks,
|
|
48767
|
+
agentCount,
|
|
48768
|
+
isLegacy: true,
|
|
48769
|
+
turboMode: hasActiveTurboMode(),
|
|
48770
|
+
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
48771
|
+
compactionCount: metrics.compactionCount,
|
|
48772
|
+
lastSnapshotAt: metrics.lastSnapshotAt
|
|
48773
|
+
};
|
|
48774
|
+
}
|
|
48324
48775
|
}
|
|
48325
|
-
|
|
48326
|
-
|
|
48327
|
-
|
|
48328
|
-
|
|
48329
|
-
|
|
48330
|
-
|
|
48331
|
-
|
|
48332
|
-
|
|
48333
|
-
|
|
48334
|
-
|
|
48335
|
-
turboMode: hasActiveTurboMode(),
|
|
48336
|
-
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
48337
|
-
compactionCount: metrics2.compactionCount,
|
|
48338
|
-
lastSnapshotAt: metrics2.lastSnapshotAt
|
|
48339
|
-
};
|
|
48776
|
+
return enrichWithLeanTurbo(status, directory);
|
|
48777
|
+
}
|
|
48778
|
+
function enrichWithLeanTurbo(status, directory) {
|
|
48779
|
+
const turboMode = hasActiveTurboMode();
|
|
48780
|
+
const leanActive = _internals20.hasActiveLeanTurbo();
|
|
48781
|
+
let turboStrategy = "off";
|
|
48782
|
+
if (leanActive) {
|
|
48783
|
+
turboStrategy = "lean";
|
|
48784
|
+
} else if (turboMode) {
|
|
48785
|
+
turboStrategy = "standard";
|
|
48340
48786
|
}
|
|
48341
|
-
|
|
48342
|
-
|
|
48343
|
-
|
|
48344
|
-
|
|
48345
|
-
|
|
48346
|
-
const
|
|
48347
|
-
|
|
48348
|
-
|
|
48349
|
-
|
|
48350
|
-
|
|
48351
|
-
|
|
48352
|
-
|
|
48353
|
-
|
|
48354
|
-
|
|
48355
|
-
|
|
48356
|
-
|
|
48357
|
-
|
|
48358
|
-
|
|
48787
|
+
status.turboStrategy = turboStrategy;
|
|
48788
|
+
if (!leanActive) {
|
|
48789
|
+
return status;
|
|
48790
|
+
}
|
|
48791
|
+
let leanSessionID = null;
|
|
48792
|
+
for (const [sessionId, session] of swarmState.agentSessions) {
|
|
48793
|
+
if (session.turboStrategy === "lean" && session.leanTurboActive === true) {
|
|
48794
|
+
leanSessionID = sessionId;
|
|
48795
|
+
break;
|
|
48796
|
+
}
|
|
48797
|
+
}
|
|
48798
|
+
if (leanSessionID) {
|
|
48799
|
+
const runState = _internals20.loadLeanTurboRunState(directory, leanSessionID);
|
|
48800
|
+
if (runState) {
|
|
48801
|
+
status.leanTurboPhase = runState.phase;
|
|
48802
|
+
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
48803
|
+
status.leanPauseReason = runState.pauseReason;
|
|
48804
|
+
if (!Array.isArray(runState.lanes)) {
|
|
48805
|
+
runState.lanes = [];
|
|
48806
|
+
}
|
|
48807
|
+
let activeLanes = 0;
|
|
48808
|
+
let completedLanes = 0;
|
|
48809
|
+
for (const lane of runState.lanes) {
|
|
48810
|
+
if (lane.status === "running")
|
|
48811
|
+
activeLanes++;
|
|
48812
|
+
if (lane.status === "completed")
|
|
48813
|
+
completedLanes++;
|
|
48814
|
+
}
|
|
48815
|
+
status.leanActiveLaneCount = activeLanes;
|
|
48816
|
+
status.leanCompletedLanes = completedLanes;
|
|
48817
|
+
if (!Array.isArray(runState.degradedTasks)) {
|
|
48818
|
+
runState.degradedTasks = [];
|
|
48819
|
+
status.leanDegradedTasks = 0;
|
|
48820
|
+
}
|
|
48821
|
+
if (runState.degradedTasks.length > 0) {
|
|
48822
|
+
status.leanDegradedTasks = runState.degradedTasks.length;
|
|
48823
|
+
const summaryParts = [];
|
|
48824
|
+
for (const dt of runState.degradedTasks) {
|
|
48825
|
+
summaryParts.push(`${dt.taskId} (${dt.reason})`);
|
|
48826
|
+
}
|
|
48827
|
+
status.leanDegradationSummary = summaryParts.join("; ");
|
|
48828
|
+
}
|
|
48829
|
+
}
|
|
48830
|
+
}
|
|
48831
|
+
status.fullAutoActive = _internals20.hasActiveFullAuto();
|
|
48832
|
+
return status;
|
|
48359
48833
|
}
|
|
48360
48834
|
function formatStatusMarkdown(status) {
|
|
48361
48835
|
const lines = [
|
|
@@ -48365,8 +48839,36 @@ function formatStatusMarkdown(status) {
|
|
|
48365
48839
|
`**Tasks**: ${status.completedTasks}/${status.totalTasks} complete`,
|
|
48366
48840
|
`**Agents**: ${status.agentCount} registered`
|
|
48367
48841
|
];
|
|
48368
|
-
if (status.
|
|
48369
|
-
lines.push(""
|
|
48842
|
+
if (status.turboStrategy && status.turboStrategy !== "off") {
|
|
48843
|
+
lines.push("");
|
|
48844
|
+
if (status.turboStrategy === "lean") {
|
|
48845
|
+
const parts = ["lean"];
|
|
48846
|
+
if (status.leanTurboPhase !== undefined) {
|
|
48847
|
+
parts.push(`Phase ${status.leanTurboPhase}`);
|
|
48848
|
+
}
|
|
48849
|
+
if (status.leanActiveLaneCount !== undefined) {
|
|
48850
|
+
const totalLanes = (status.leanActiveLaneCount ?? 0) + (status.leanCompletedLanes ?? 0);
|
|
48851
|
+
parts.push(`${status.leanActiveLaneCount}/${totalLanes} lanes active`);
|
|
48852
|
+
}
|
|
48853
|
+
if (status.leanDegradedTasks !== undefined && status.leanDegradedTasks > 0) {
|
|
48854
|
+
parts.push(`${status.leanDegradedTasks} degraded`);
|
|
48855
|
+
}
|
|
48856
|
+
lines.push(`**Turbo**: ${parts.join(", ")}`);
|
|
48857
|
+
if (status.leanDegradationSummary) {
|
|
48858
|
+
lines.push(` - ${status.leanDegradationSummary}`);
|
|
48859
|
+
}
|
|
48860
|
+
if (status.leanPauseReason) {
|
|
48861
|
+
lines.push(`**Lean paused**: ${status.leanPauseReason}`);
|
|
48862
|
+
}
|
|
48863
|
+
} else {
|
|
48864
|
+
lines.push(`**Turbo**: standard`);
|
|
48865
|
+
}
|
|
48866
|
+
if (status.fullAutoActive) {
|
|
48867
|
+
lines.push(`**Full-Auto**: active`);
|
|
48868
|
+
}
|
|
48869
|
+
} else if (status.turboStrategy === undefined && status.turboMode === true) {
|
|
48870
|
+
lines.push("");
|
|
48871
|
+
lines.push("**TURBO MODE**: active");
|
|
48370
48872
|
}
|
|
48371
48873
|
if (status.contextBudgetPct !== null && status.contextBudgetPct > 0) {
|
|
48372
48874
|
const pct = status.contextBudgetPct.toFixed(1);
|
|
@@ -48390,13 +48892,20 @@ async function handleStatusCommand(directory, agents) {
|
|
|
48390
48892
|
}
|
|
48391
48893
|
return formatStatusMarkdown(statusData);
|
|
48392
48894
|
}
|
|
48895
|
+
var _internals20;
|
|
48393
48896
|
var init_status_service = __esm(() => {
|
|
48394
48897
|
init_extractors();
|
|
48395
48898
|
init_utils2();
|
|
48396
48899
|
init_manager();
|
|
48397
48900
|
init_state();
|
|
48901
|
+
init_state3();
|
|
48398
48902
|
init_compaction_service();
|
|
48399
48903
|
init_context_budget_service();
|
|
48904
|
+
_internals20 = {
|
|
48905
|
+
loadLeanTurboRunState,
|
|
48906
|
+
hasActiveLeanTurbo,
|
|
48907
|
+
hasActiveFullAuto
|
|
48908
|
+
};
|
|
48400
48909
|
});
|
|
48401
48910
|
|
|
48402
48911
|
// src/commands/status.ts
|
|
@@ -48432,7 +48941,7 @@ var init_sync_plan = __esm(() => {
|
|
|
48432
48941
|
});
|
|
48433
48942
|
|
|
48434
48943
|
// src/commands/turbo.ts
|
|
48435
|
-
async function handleTurboCommand(
|
|
48944
|
+
async function handleTurboCommand(directory, args, sessionID) {
|
|
48436
48945
|
if (!sessionID || sessionID.trim() === "") {
|
|
48437
48946
|
return "Error: No active session context. Turbo Mode requires an active session. Use /swarm turbo from within an OpenCode session, or start a session first.";
|
|
48438
48947
|
}
|
|
@@ -48440,24 +48949,179 @@ async function handleTurboCommand(_directory, args, sessionID) {
|
|
|
48440
48949
|
if (!session) {
|
|
48441
48950
|
return "Error: No active session. Turbo Mode requires an active session to operate.";
|
|
48442
48951
|
}
|
|
48443
|
-
const
|
|
48444
|
-
|
|
48445
|
-
|
|
48446
|
-
|
|
48447
|
-
|
|
48448
|
-
|
|
48449
|
-
|
|
48450
|
-
|
|
48451
|
-
|
|
48952
|
+
const arg0 = args[0]?.toLowerCase();
|
|
48953
|
+
const arg1 = args[1]?.toLowerCase();
|
|
48954
|
+
if (arg0 === "status") {
|
|
48955
|
+
return buildStatusMessage(session, directory, sessionID);
|
|
48956
|
+
}
|
|
48957
|
+
const isTurboOn = session.turboMode;
|
|
48958
|
+
const isLeanActive = session.leanTurboActive === true;
|
|
48959
|
+
const disableTurbo = (reason) => {
|
|
48960
|
+
if (isLeanActive) {
|
|
48961
|
+
try {
|
|
48962
|
+
pauseLeanTurboRun(directory, sessionID, reason);
|
|
48963
|
+
} catch (error93) {
|
|
48964
|
+
error(`[turbo] pauseLeanTurboRun failed: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
48965
|
+
}
|
|
48966
|
+
}
|
|
48967
|
+
session.turboMode = false;
|
|
48968
|
+
session.turboStrategy = undefined;
|
|
48969
|
+
session.leanTurboActive = false;
|
|
48970
|
+
session.leanTurboCurrentPhase = undefined;
|
|
48971
|
+
};
|
|
48972
|
+
if (arg0 === "off" || arg0 === "lean" && arg1 === "off") {
|
|
48973
|
+
disableTurbo("/swarm turbo off");
|
|
48974
|
+
return "Turbo Mode disabled";
|
|
48975
|
+
}
|
|
48976
|
+
if (arg0 === "standard" && arg1 === "off") {
|
|
48977
|
+
disableTurbo("/swarm turbo standard off");
|
|
48978
|
+
return "Turbo Mode disabled";
|
|
48979
|
+
}
|
|
48980
|
+
if (arg0 === undefined) {
|
|
48981
|
+
if (isTurboOn) {
|
|
48982
|
+
disableTurbo("/swarm turbo (toggle off)");
|
|
48983
|
+
return "Turbo Mode disabled";
|
|
48984
|
+
} else {
|
|
48985
|
+
session.turboMode = true;
|
|
48986
|
+
session.turboStrategy = "standard";
|
|
48987
|
+
session.leanTurboActive = false;
|
|
48988
|
+
session.leanTurboCurrentPhase = undefined;
|
|
48989
|
+
return "Turbo Mode enabled";
|
|
48990
|
+
}
|
|
48991
|
+
}
|
|
48992
|
+
if (arg0 === "on") {
|
|
48993
|
+
let strategy = "standard";
|
|
48994
|
+
try {
|
|
48995
|
+
const { config: config3 } = loadPluginConfigWithMeta(directory);
|
|
48996
|
+
if (config3.turbo?.strategy === "lean") {
|
|
48997
|
+
strategy = "lean";
|
|
48998
|
+
}
|
|
48999
|
+
} catch (error93) {
|
|
49000
|
+
warn(`[turbo] could not read config for strategy default: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
49001
|
+
}
|
|
49002
|
+
if (strategy === "lean") {
|
|
49003
|
+
return enableLeanTurbo(session, directory, sessionID);
|
|
49004
|
+
}
|
|
49005
|
+
if (isLeanActive) {
|
|
49006
|
+
disableTurbo("/swarm turbo on (switching from lean)");
|
|
49007
|
+
}
|
|
49008
|
+
session.turboMode = true;
|
|
49009
|
+
session.turboStrategy = "standard";
|
|
49010
|
+
session.leanTurboActive = false;
|
|
49011
|
+
session.leanTurboCurrentPhase = undefined;
|
|
49012
|
+
return "Turbo Mode enabled";
|
|
49013
|
+
}
|
|
49014
|
+
if (arg0 === "standard" && arg1 === "on") {
|
|
49015
|
+
if (isLeanActive) {
|
|
49016
|
+
disableTurbo("/swarm turbo standard on (switching from lean)");
|
|
49017
|
+
}
|
|
49018
|
+
session.turboMode = true;
|
|
49019
|
+
session.turboStrategy = "standard";
|
|
49020
|
+
session.leanTurboActive = false;
|
|
49021
|
+
session.leanTurboCurrentPhase = undefined;
|
|
49022
|
+
return "Turbo Mode enabled (standard)";
|
|
49023
|
+
}
|
|
49024
|
+
if (arg0 === "lean" && arg1 === "on") {
|
|
49025
|
+
return enableLeanTurbo(session, directory, sessionID);
|
|
49026
|
+
}
|
|
49027
|
+
if (arg0 === "lean" && arg1 === undefined) {
|
|
49028
|
+
if (isLeanActive) {
|
|
49029
|
+
disableTurbo("/swarm turbo lean (toggle off)");
|
|
49030
|
+
return "Turbo Mode disabled";
|
|
49031
|
+
} else {
|
|
49032
|
+
return enableLeanTurbo(session, directory, sessionID);
|
|
49033
|
+
}
|
|
49034
|
+
}
|
|
49035
|
+
if (isTurboOn) {
|
|
49036
|
+
disableTurbo("/swarm turbo (toggle off via unknown arg)");
|
|
49037
|
+
return "Turbo Mode disabled";
|
|
48452
49038
|
} else {
|
|
48453
|
-
|
|
48454
|
-
|
|
49039
|
+
session.turboMode = true;
|
|
49040
|
+
session.turboStrategy = "standard";
|
|
49041
|
+
session.leanTurboActive = false;
|
|
49042
|
+
session.leanTurboCurrentPhase = undefined;
|
|
49043
|
+
return "Turbo Mode enabled";
|
|
49044
|
+
}
|
|
49045
|
+
}
|
|
49046
|
+
function enableLeanTurbo(session, directory, sessionID) {
|
|
49047
|
+
let maxParallelCoders = 4;
|
|
49048
|
+
let conflictPolicy = "serialize";
|
|
49049
|
+
try {
|
|
49050
|
+
const { config: config3 } = loadPluginConfigWithMeta(directory);
|
|
49051
|
+
const leanConfig = config3.turbo?.lean;
|
|
49052
|
+
if (leanConfig) {
|
|
49053
|
+
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
49054
|
+
conflictPolicy = leanConfig.conflict_policy ?? "serialize";
|
|
49055
|
+
}
|
|
49056
|
+
} catch (error93) {
|
|
49057
|
+
warn(`[turbo] could not read lean config: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
49058
|
+
}
|
|
49059
|
+
let durableError;
|
|
49060
|
+
try {
|
|
49061
|
+
const state = emptyRunState(sessionID, maxParallelCoders);
|
|
49062
|
+
state.status = "running";
|
|
49063
|
+
saveLeanTurboRunState(directory, state);
|
|
49064
|
+
} catch (error93) {
|
|
49065
|
+
durableError = error93 instanceof Error ? error93.message : String(error93);
|
|
49066
|
+
error(`[turbo] durable run-state write failed: ${durableError}`);
|
|
48455
49067
|
}
|
|
48456
|
-
|
|
48457
|
-
|
|
49068
|
+
if (durableError) {
|
|
49069
|
+
return [
|
|
49070
|
+
"Error: Lean Turbo could NOT be enabled \u2014 durable run-state write failed.",
|
|
49071
|
+
`Reason: ${durableError}.`,
|
|
49072
|
+
"Inspect .swarm/ permissions and disk space, then retry."
|
|
49073
|
+
].join(" ");
|
|
49074
|
+
}
|
|
49075
|
+
const fullAutoActive = session.fullAutoMode;
|
|
49076
|
+
session.turboMode = true;
|
|
49077
|
+
session.turboStrategy = "lean";
|
|
49078
|
+
session.leanTurboActive = true;
|
|
49079
|
+
session.leanTurboCurrentPhase = undefined;
|
|
49080
|
+
return [
|
|
49081
|
+
"Lean Turbo enabled",
|
|
49082
|
+
`(maxParallelCoders=${maxParallelCoders}, conflict_policy=${conflictPolicy},`,
|
|
49083
|
+
`Full-Auto: ${fullAutoActive ? "active" : "inactive"})`
|
|
49084
|
+
].join(" ");
|
|
49085
|
+
}
|
|
49086
|
+
function buildStatusMessage(session, directory, sessionID) {
|
|
49087
|
+
if (!session.turboMode) {
|
|
49088
|
+
return "Turbo: off";
|
|
49089
|
+
}
|
|
49090
|
+
if (session.turboStrategy === "standard" || !session.leanTurboActive) {
|
|
49091
|
+
return "Turbo: standard (turboMode=true)";
|
|
49092
|
+
}
|
|
49093
|
+
if (isStateUnreadable(directory)) {
|
|
49094
|
+
return [
|
|
49095
|
+
"Turbo: lean (turboMode=true, leanTurboActive=true)",
|
|
49096
|
+
"WARNING: Durable state is unreadable \u2014 cannot report full status."
|
|
49097
|
+
].join(`
|
|
49098
|
+
`);
|
|
49099
|
+
}
|
|
49100
|
+
const state = loadLeanTurboRunState(directory, sessionID);
|
|
49101
|
+
if (!state) {
|
|
49102
|
+
return [
|
|
49103
|
+
"Turbo: lean (turboMode=true, leanTurboActive=true)",
|
|
49104
|
+
"WARNING: Durable state not found."
|
|
49105
|
+
].join(`
|
|
49106
|
+
`);
|
|
49107
|
+
}
|
|
49108
|
+
const phase = state.phase !== undefined ? `phase=${state.phase}` : "phase=unset";
|
|
49109
|
+
const laneCount = state.lanes.length;
|
|
49110
|
+
const degradedCount = state.degradedTasks.length;
|
|
49111
|
+
const maxParallel = state.maxParallelCoders;
|
|
49112
|
+
const fullAutoActive = session.fullAutoMode;
|
|
49113
|
+
return [
|
|
49114
|
+
`Turbo: lean (turboMode=true, leanTurboActive=true)`,
|
|
49115
|
+
`Status: ${state.status}, ${phase}, lanes=${laneCount}, degraded=${degradedCount}`,
|
|
49116
|
+
`maxParallelCoders=${maxParallel}, Full-Auto: ${fullAutoActive ? "active" : "inactive"}`
|
|
49117
|
+
].join(`
|
|
49118
|
+
`);
|
|
48458
49119
|
}
|
|
48459
49120
|
var init_turbo = __esm(() => {
|
|
49121
|
+
init_config();
|
|
48460
49122
|
init_state();
|
|
49123
|
+
init_state3();
|
|
49124
|
+
init_logger();
|
|
48461
49125
|
});
|
|
48462
49126
|
|
|
48463
49127
|
// src/commands/write-retro.ts
|
|
@@ -48560,6 +49224,7 @@ __export(exports_commands, {
|
|
|
48560
49224
|
handleEvidenceCommand: () => handleEvidenceCommand,
|
|
48561
49225
|
handleDoctorCommand: () => handleDoctorCommand,
|
|
48562
49226
|
handleDiagnoseCommand: () => handleDiagnoseCommand,
|
|
49227
|
+
handleDeepDiveCommand: () => handleDeepDiveCommand,
|
|
48563
49228
|
handleDarkMatterCommand: () => handleDarkMatterCommand,
|
|
48564
49229
|
handleCurateCommand: () => handleCurateCommand,
|
|
48565
49230
|
handleCouncilCommand: () => handleCouncilCommand,
|
|
@@ -48580,8 +49245,8 @@ __export(exports_commands, {
|
|
|
48580
49245
|
COMMAND_NAME_SET: () => COMMAND_NAME_SET,
|
|
48581
49246
|
COMMAND_NAMES: () => COMMAND_NAMES
|
|
48582
49247
|
});
|
|
48583
|
-
import
|
|
48584
|
-
import
|
|
49248
|
+
import fs23 from "fs";
|
|
49249
|
+
import path38 from "path";
|
|
48585
49250
|
function buildHelpText() {
|
|
48586
49251
|
const lines = ["## Swarm Commands", ""];
|
|
48587
49252
|
const CATEGORIES = [
|
|
@@ -48684,11 +49349,11 @@ function createSwarmCommandHandler(directory, agents) {
|
|
|
48684
49349
|
return;
|
|
48685
49350
|
}
|
|
48686
49351
|
let isFirstRun = false;
|
|
48687
|
-
const sentinelPath =
|
|
49352
|
+
const sentinelPath = path38.join(directory, ".swarm", ".first-run-complete");
|
|
48688
49353
|
try {
|
|
48689
|
-
const swarmDir =
|
|
48690
|
-
|
|
48691
|
-
|
|
49354
|
+
const swarmDir = path38.join(directory, ".swarm");
|
|
49355
|
+
fs23.mkdirSync(swarmDir, { recursive: true });
|
|
49356
|
+
fs23.writeFileSync(sentinelPath, `first-run-complete: ${new Date().toISOString()}
|
|
48692
49357
|
`, { flag: "wx" });
|
|
48693
49358
|
isFirstRun = true;
|
|
48694
49359
|
} catch (_err) {}
|
|
@@ -48709,7 +49374,7 @@ function createSwarmCommandHandler(directory, agents) {
|
|
|
48709
49374
|
const attemptedCommand = tokens[0] || "";
|
|
48710
49375
|
const MAX_DISPLAY = 100;
|
|
48711
49376
|
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
48712
|
-
const similar =
|
|
49377
|
+
const similar = _internals21.findSimilarCommands(attemptedCommand);
|
|
48713
49378
|
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
48714
49379
|
const suggestions = similar.length > 0 ? `Did you mean:
|
|
48715
49380
|
${similar.map((cmd) => ` \u2022 /swarm ${cmd}`).join(`
|
|
@@ -48763,6 +49428,7 @@ var init_commands = __esm(() => {
|
|
|
48763
49428
|
init_council();
|
|
48764
49429
|
init_curate();
|
|
48765
49430
|
init_dark_matter();
|
|
49431
|
+
init_deep_dive();
|
|
48766
49432
|
init_diagnose();
|
|
48767
49433
|
init_doctor();
|
|
48768
49434
|
init_evidence();
|
|
@@ -48815,7 +49481,7 @@ function findSimilarCommands(query) {
|
|
|
48815
49481
|
}
|
|
48816
49482
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
48817
49483
|
const cmdLower = cmd.toLowerCase();
|
|
48818
|
-
const fullScore =
|
|
49484
|
+
const fullScore = _internals21.levenshteinDistance(q, cmdLower);
|
|
48819
49485
|
let tokenScore = Infinity;
|
|
48820
49486
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
48821
49487
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -48828,7 +49494,7 @@ function findSimilarCommands(query) {
|
|
|
48828
49494
|
for (const ct of cmdTokens) {
|
|
48829
49495
|
if (ct.length === 0)
|
|
48830
49496
|
continue;
|
|
48831
|
-
const dist =
|
|
49497
|
+
const dist = _internals21.levenshteinDistance(qt, ct);
|
|
48832
49498
|
if (dist < minDist)
|
|
48833
49499
|
minDist = dist;
|
|
48834
49500
|
}
|
|
@@ -48838,7 +49504,7 @@ function findSimilarCommands(query) {
|
|
|
48838
49504
|
}
|
|
48839
49505
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
48840
49506
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
48841
|
-
const dashScore =
|
|
49507
|
+
const dashScore = _internals21.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
48842
49508
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
48843
49509
|
return { cmd, score };
|
|
48844
49510
|
});
|
|
@@ -48870,11 +49536,11 @@ async function handleHelpCommand(ctx) {
|
|
|
48870
49536
|
return buildHelpText2();
|
|
48871
49537
|
}
|
|
48872
49538
|
const tokens = targetCommand.split(/\s+/);
|
|
48873
|
-
const resolved =
|
|
49539
|
+
const resolved = _internals21.resolveCommand(tokens);
|
|
48874
49540
|
if (resolved) {
|
|
48875
|
-
return
|
|
49541
|
+
return _internals21.buildDetailedHelp(resolved.key, resolved.entry);
|
|
48876
49542
|
}
|
|
48877
|
-
const similar =
|
|
49543
|
+
const similar = _internals21.findSimilarCommands(targetCommand);
|
|
48878
49544
|
const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
|
|
48879
49545
|
if (similar.length > 0) {
|
|
48880
49546
|
return `Command '/swarm ${targetCommand}' not found.
|
|
@@ -48910,24 +49576,24 @@ function validateAliases() {
|
|
|
48910
49576
|
}
|
|
48911
49577
|
aliasTargets.get(target).push(name);
|
|
48912
49578
|
const visited = new Set;
|
|
48913
|
-
const
|
|
49579
|
+
const path39 = [];
|
|
48914
49580
|
let current = target;
|
|
48915
49581
|
while (current) {
|
|
48916
49582
|
const currentEntry = COMMAND_REGISTRY[current];
|
|
48917
49583
|
if (!currentEntry)
|
|
48918
49584
|
break;
|
|
48919
49585
|
if (visited.has(current)) {
|
|
48920
|
-
const cycleStart =
|
|
49586
|
+
const cycleStart = path39.indexOf(current);
|
|
48921
49587
|
const fullChain = [
|
|
48922
49588
|
name,
|
|
48923
|
-
...
|
|
49589
|
+
...path39.slice(0, cycleStart > 0 ? cycleStart : path39.length),
|
|
48924
49590
|
current
|
|
48925
49591
|
].join(" \u2192 ");
|
|
48926
49592
|
errors5.push(`Circular alias detected: ${fullChain}`);
|
|
48927
49593
|
break;
|
|
48928
49594
|
}
|
|
48929
49595
|
visited.add(current);
|
|
48930
|
-
|
|
49596
|
+
path39.push(current);
|
|
48931
49597
|
current = currentEntry.aliasOf || "";
|
|
48932
49598
|
}
|
|
48933
49599
|
}
|
|
@@ -48968,7 +49634,7 @@ function resolveCommand(tokens) {
|
|
|
48968
49634
|
}
|
|
48969
49635
|
return null;
|
|
48970
49636
|
}
|
|
48971
|
-
var COMMAND_REGISTRY, VALID_COMMANDS,
|
|
49637
|
+
var COMMAND_REGISTRY, VALID_COMMANDS, _internals21, validation;
|
|
48972
49638
|
var init_registry = __esm(() => {
|
|
48973
49639
|
init_acknowledge_spec_drift();
|
|
48974
49640
|
init_agents();
|
|
@@ -48980,6 +49646,7 @@ var init_registry = __esm(() => {
|
|
|
48980
49646
|
init_council();
|
|
48981
49647
|
init_curate();
|
|
48982
49648
|
init_dark_matter();
|
|
49649
|
+
init_deep_dive();
|
|
48983
49650
|
init_diagnose();
|
|
48984
49651
|
init_doctor();
|
|
48985
49652
|
init_evidence();
|
|
@@ -49037,7 +49704,7 @@ var init_registry = __esm(() => {
|
|
|
49037
49704
|
clashesWithNativeCcCommand: "/agents"
|
|
49038
49705
|
},
|
|
49039
49706
|
help: {
|
|
49040
|
-
handler: (ctx) =>
|
|
49707
|
+
handler: (ctx) => _internals21.handleHelpCommand(ctx),
|
|
49041
49708
|
description: "Show help for swarm commands",
|
|
49042
49709
|
category: "core",
|
|
49043
49710
|
args: "[command]",
|
|
@@ -49259,6 +49926,20 @@ var init_registry = __esm(() => {
|
|
|
49259
49926
|
details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes (correctness, security, dependencies, docs-intent-vs-actual, tests, performance-architecture), validates findings through independent reviewer confirmation, applies critic challenge to HIGH/CRITICAL findings, synthesizes structured report. --council variant fires adversarial multi-model review. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolves against origin remote).",
|
|
49260
49927
|
category: "agent"
|
|
49261
49928
|
},
|
|
49929
|
+
"deep-dive": {
|
|
49930
|
+
handler: async (ctx) => handleDeepDiveCommand(ctx.directory, ctx.args),
|
|
49931
|
+
description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]",
|
|
49932
|
+
args: "<scope> [--profile standard|security|ux|architecture|full] [--max-explorers 1..8] [--json] [--skip-update] [--allow-dirty]",
|
|
49933
|
+
details: "Runs a read-only deep audit of the specified scope using parallel explorer waves (8-file cap per mission, ~3500 line guardrail), always 2 parallel reviewers for verification, and sequential critic challenge on HIGH/CRITICAL findings. Profiles select explorer lanes: standard (5 lanes), security, ux, architecture, full (all 8 lanes). Emits a structured findings report without mutating source code.",
|
|
49934
|
+
category: "agent"
|
|
49935
|
+
},
|
|
49936
|
+
"deep dive": {
|
|
49937
|
+
handler: async (ctx) => handleDeepDiveCommand(ctx.directory, ctx.args),
|
|
49938
|
+
description: "Alias for /swarm deep-dive \u2014 launch deep codebase audit",
|
|
49939
|
+
args: "<scope> [--profile standard|security|ux|architecture|full] [--max-explorers 1..8] [--json] [--skip-update] [--allow-dirty]",
|
|
49940
|
+
category: "agent",
|
|
49941
|
+
aliasOf: "deep-dive"
|
|
49942
|
+
},
|
|
49262
49943
|
issue: {
|
|
49263
49944
|
handler: async (ctx) => handleIssueCommand(ctx.directory, ctx.args),
|
|
49264
49945
|
description: "Ingest a GitHub issue into the swarm workflow [url] [--plan] [--trace] [--no-repro]",
|
|
@@ -49376,7 +50057,7 @@ var init_registry = __esm(() => {
|
|
|
49376
50057
|
}
|
|
49377
50058
|
};
|
|
49378
50059
|
VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
|
|
49379
|
-
|
|
50060
|
+
_internals21 = {
|
|
49380
50061
|
handleHelpCommand,
|
|
49381
50062
|
validateAliases,
|
|
49382
50063
|
resolveCommand,
|
|
@@ -49384,7 +50065,7 @@ var init_registry = __esm(() => {
|
|
|
49384
50065
|
findSimilarCommands,
|
|
49385
50066
|
buildDetailedHelp
|
|
49386
50067
|
};
|
|
49387
|
-
validation =
|
|
50068
|
+
validation = _internals21.validateAliases();
|
|
49388
50069
|
if (!validation.valid) {
|
|
49389
50070
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
49390
50071
|
${validation.errors.join(`
|
|
@@ -49402,68 +50083,68 @@ init_package();
|
|
|
49402
50083
|
init_registry();
|
|
49403
50084
|
init_cache_paths();
|
|
49404
50085
|
init_constants();
|
|
49405
|
-
import * as
|
|
50086
|
+
import * as fs24 from "fs";
|
|
49406
50087
|
import * as os7 from "os";
|
|
49407
|
-
import * as
|
|
50088
|
+
import * as path39 from "path";
|
|
49408
50089
|
var { version: version4 } = package_default;
|
|
49409
50090
|
var CONFIG_DIR = getPluginConfigDir();
|
|
49410
|
-
var OPENCODE_CONFIG_PATH =
|
|
49411
|
-
var PLUGIN_CONFIG_PATH =
|
|
49412
|
-
var PROMPTS_DIR =
|
|
50091
|
+
var OPENCODE_CONFIG_PATH = path39.join(CONFIG_DIR, "opencode.json");
|
|
50092
|
+
var PLUGIN_CONFIG_PATH = path39.join(CONFIG_DIR, "opencode-swarm.json");
|
|
50093
|
+
var PROMPTS_DIR = path39.join(CONFIG_DIR, "opencode-swarm");
|
|
49413
50094
|
var OPENCODE_PLUGIN_CACHE_PATHS = getPluginCachePaths();
|
|
49414
50095
|
var OPENCODE_PLUGIN_LOCK_FILE_PATHS = getPluginLockFilePaths();
|
|
49415
50096
|
function isSafeCachePath(p) {
|
|
49416
|
-
const resolved =
|
|
49417
|
-
const home =
|
|
50097
|
+
const resolved = path39.resolve(p);
|
|
50098
|
+
const home = path39.resolve(os7.homedir());
|
|
49418
50099
|
if (resolved === "/" || resolved === home || resolved.length <= home.length) {
|
|
49419
50100
|
return false;
|
|
49420
50101
|
}
|
|
49421
|
-
const segments = resolved.split(
|
|
50102
|
+
const segments = resolved.split(path39.sep).filter((s) => s.length > 0);
|
|
49422
50103
|
if (segments.length < 4) {
|
|
49423
50104
|
return false;
|
|
49424
50105
|
}
|
|
49425
|
-
const leaf =
|
|
50106
|
+
const leaf = path39.basename(resolved);
|
|
49426
50107
|
if (leaf !== "opencode-swarm@latest" && leaf !== "opencode-swarm") {
|
|
49427
50108
|
return false;
|
|
49428
50109
|
}
|
|
49429
|
-
const parent =
|
|
50110
|
+
const parent = path39.basename(path39.dirname(resolved));
|
|
49430
50111
|
if (parent !== "packages" && parent !== "node_modules") {
|
|
49431
50112
|
return false;
|
|
49432
50113
|
}
|
|
49433
|
-
const grandparent =
|
|
50114
|
+
const grandparent = path39.basename(path39.dirname(path39.dirname(resolved)));
|
|
49434
50115
|
if (grandparent !== "opencode") {
|
|
49435
50116
|
return false;
|
|
49436
50117
|
}
|
|
49437
50118
|
return true;
|
|
49438
50119
|
}
|
|
49439
50120
|
function isSafeLockFilePath(p) {
|
|
49440
|
-
const resolved =
|
|
49441
|
-
const home =
|
|
50121
|
+
const resolved = path39.resolve(p);
|
|
50122
|
+
const home = path39.resolve(os7.homedir());
|
|
49442
50123
|
if (resolved === "/" || resolved === home || resolved.length <= home.length) {
|
|
49443
50124
|
return false;
|
|
49444
50125
|
}
|
|
49445
|
-
const segments = resolved.split(
|
|
50126
|
+
const segments = resolved.split(path39.sep).filter((s) => s.length > 0);
|
|
49446
50127
|
if (segments.length < 4) {
|
|
49447
50128
|
return false;
|
|
49448
50129
|
}
|
|
49449
|
-
const leaf =
|
|
50130
|
+
const leaf = path39.basename(resolved);
|
|
49450
50131
|
if (leaf !== "bun.lock" && leaf !== "bun.lockb" && leaf !== "package-lock.json") {
|
|
49451
50132
|
return false;
|
|
49452
50133
|
}
|
|
49453
|
-
const parent =
|
|
50134
|
+
const parent = path39.basename(path39.dirname(resolved));
|
|
49454
50135
|
if (parent !== "opencode") {
|
|
49455
50136
|
return false;
|
|
49456
50137
|
}
|
|
49457
50138
|
return true;
|
|
49458
50139
|
}
|
|
49459
50140
|
function ensureDir(dir) {
|
|
49460
|
-
if (!
|
|
49461
|
-
|
|
50141
|
+
if (!fs24.existsSync(dir)) {
|
|
50142
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
49462
50143
|
}
|
|
49463
50144
|
}
|
|
49464
50145
|
function loadJson(filepath) {
|
|
49465
50146
|
try {
|
|
49466
|
-
const content =
|
|
50147
|
+
const content = fs24.readFileSync(filepath, "utf-8");
|
|
49467
50148
|
const stripped = content.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (match, comment) => comment ? "" : match).replace(/,(\s*[}\]])/g, "$1");
|
|
49468
50149
|
return JSON.parse(stripped);
|
|
49469
50150
|
} catch {
|
|
@@ -49471,14 +50152,14 @@ function loadJson(filepath) {
|
|
|
49471
50152
|
}
|
|
49472
50153
|
}
|
|
49473
50154
|
function saveJson(filepath, data) {
|
|
49474
|
-
|
|
50155
|
+
fs24.writeFileSync(filepath, `${JSON.stringify(data, null, 2)}
|
|
49475
50156
|
`, "utf-8");
|
|
49476
50157
|
}
|
|
49477
50158
|
function writeProjectConfigIfMissing(cwd) {
|
|
49478
50159
|
try {
|
|
49479
|
-
const opencodeDir =
|
|
49480
|
-
const projectConfigPath =
|
|
49481
|
-
if (
|
|
50160
|
+
const opencodeDir = path39.join(cwd, ".opencode");
|
|
50161
|
+
const projectConfigPath = path39.join(opencodeDir, "opencode-swarm.json");
|
|
50162
|
+
if (fs24.existsSync(projectConfigPath)) {
|
|
49482
50163
|
return;
|
|
49483
50164
|
}
|
|
49484
50165
|
ensureDir(opencodeDir);
|
|
@@ -49494,7 +50175,7 @@ async function install() {
|
|
|
49494
50175
|
`);
|
|
49495
50176
|
ensureDir(CONFIG_DIR);
|
|
49496
50177
|
ensureDir(PROMPTS_DIR);
|
|
49497
|
-
const LEGACY_CONFIG_PATH =
|
|
50178
|
+
const LEGACY_CONFIG_PATH = path39.join(CONFIG_DIR, "config.json");
|
|
49498
50179
|
let opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
49499
50180
|
if (!opencodeConfig) {
|
|
49500
50181
|
const legacyConfig = loadJson(LEGACY_CONFIG_PATH);
|
|
@@ -49541,7 +50222,7 @@ async function install() {
|
|
|
49541
50222
|
console.warn(`\u26A0 Could not clear opencode lock file \u2014 you may need to delete it manually:
|
|
49542
50223
|
${failed}`);
|
|
49543
50224
|
}
|
|
49544
|
-
if (!
|
|
50225
|
+
if (!fs24.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
49545
50226
|
const defaultConfig = {
|
|
49546
50227
|
agents: { ...DEFAULT_AGENT_CONFIGS },
|
|
49547
50228
|
max_iterations: 5
|
|
@@ -49620,14 +50301,14 @@ function evictPluginCaches() {
|
|
|
49620
50301
|
const cleared = [];
|
|
49621
50302
|
const failed = [];
|
|
49622
50303
|
for (const cachePath of OPENCODE_PLUGIN_CACHE_PATHS) {
|
|
49623
|
-
if (!
|
|
50304
|
+
if (!fs24.existsSync(cachePath))
|
|
49624
50305
|
continue;
|
|
49625
50306
|
if (!isSafeCachePath(cachePath)) {
|
|
49626
50307
|
failed.push(`${cachePath} (refused: failed safety check)`);
|
|
49627
50308
|
continue;
|
|
49628
50309
|
}
|
|
49629
50310
|
try {
|
|
49630
|
-
|
|
50311
|
+
fs24.rmSync(cachePath, { recursive: true, force: true });
|
|
49631
50312
|
cleared.push(cachePath);
|
|
49632
50313
|
} catch (err) {
|
|
49633
50314
|
failed.push(`${cachePath} (${err instanceof Error ? err.message : String(err)})`);
|
|
@@ -49639,14 +50320,14 @@ function evictLockFiles() {
|
|
|
49639
50320
|
const cleared = [];
|
|
49640
50321
|
const failed = [];
|
|
49641
50322
|
for (const lockPath of OPENCODE_PLUGIN_LOCK_FILE_PATHS) {
|
|
49642
|
-
if (!
|
|
50323
|
+
if (!fs24.existsSync(lockPath))
|
|
49643
50324
|
continue;
|
|
49644
50325
|
if (!isSafeLockFilePath(lockPath)) {
|
|
49645
50326
|
failed.push(`${lockPath} (refused: failed safety check)`);
|
|
49646
50327
|
continue;
|
|
49647
50328
|
}
|
|
49648
50329
|
try {
|
|
49649
|
-
|
|
50330
|
+
fs24.unlinkSync(lockPath);
|
|
49650
50331
|
cleared.push(lockPath);
|
|
49651
50332
|
} catch (err) {
|
|
49652
50333
|
const code = err?.code;
|
|
@@ -49665,7 +50346,7 @@ async function uninstall() {
|
|
|
49665
50346
|
`);
|
|
49666
50347
|
const opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
49667
50348
|
if (!opencodeConfig) {
|
|
49668
|
-
if (
|
|
50349
|
+
if (fs24.existsSync(OPENCODE_CONFIG_PATH)) {
|
|
49669
50350
|
console.log(`\u2717 Could not parse opencode config at: ${OPENCODE_CONFIG_PATH}`);
|
|
49670
50351
|
return 1;
|
|
49671
50352
|
} else {
|
|
@@ -49697,13 +50378,13 @@ async function uninstall() {
|
|
|
49697
50378
|
console.log("\u2713 Re-enabled default OpenCode agents (explore, general)");
|
|
49698
50379
|
if (process.argv.includes("--clean")) {
|
|
49699
50380
|
let cleaned = false;
|
|
49700
|
-
if (
|
|
49701
|
-
|
|
50381
|
+
if (fs24.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
50382
|
+
fs24.unlinkSync(PLUGIN_CONFIG_PATH);
|
|
49702
50383
|
console.log(`\u2713 Removed plugin config: ${PLUGIN_CONFIG_PATH}`);
|
|
49703
50384
|
cleaned = true;
|
|
49704
50385
|
}
|
|
49705
|
-
if (
|
|
49706
|
-
|
|
50386
|
+
if (fs24.existsSync(PROMPTS_DIR)) {
|
|
50387
|
+
fs24.rmSync(PROMPTS_DIR, { recursive: true });
|
|
49707
50388
|
console.log(`\u2713 Removed custom prompts: ${PROMPTS_DIR}`);
|
|
49708
50389
|
cleaned = true;
|
|
49709
50390
|
}
|