opencode-swarm 7.14.0 → 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 +807 -255
- 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 +4233 -1251
- 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
|
|
@@ -37689,7 +37839,7 @@ function getPluginLockFilePaths() {
|
|
|
37689
37839
|
var init_cache_paths = () => {};
|
|
37690
37840
|
|
|
37691
37841
|
// src/services/version-check.ts
|
|
37692
|
-
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";
|
|
37693
37843
|
import { homedir as homedir5 } from "os";
|
|
37694
37844
|
import { join as join17 } from "path";
|
|
37695
37845
|
function cacheDir() {
|
|
@@ -37705,7 +37855,7 @@ function readVersionCache() {
|
|
|
37705
37855
|
const path19 = cacheFile();
|
|
37706
37856
|
if (!existsSync9(path19))
|
|
37707
37857
|
return null;
|
|
37708
|
-
const raw =
|
|
37858
|
+
const raw = readFileSync6(path19, "utf-8");
|
|
37709
37859
|
const parsed = JSON.parse(raw);
|
|
37710
37860
|
if (typeof parsed?.checkedAt !== "number")
|
|
37711
37861
|
return null;
|
|
@@ -37744,7 +37894,7 @@ var init_version_check = __esm(() => {
|
|
|
37744
37894
|
|
|
37745
37895
|
// src/services/diagnose-service.ts
|
|
37746
37896
|
import * as child_process4 from "child_process";
|
|
37747
|
-
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";
|
|
37748
37898
|
import path19 from "path";
|
|
37749
37899
|
import { fileURLToPath } from "url";
|
|
37750
37900
|
function validateTaskDag(plan) {
|
|
@@ -38051,7 +38201,7 @@ async function checkConfigParseability(directory) {
|
|
|
38051
38201
|
};
|
|
38052
38202
|
}
|
|
38053
38203
|
try {
|
|
38054
|
-
const content =
|
|
38204
|
+
const content = readFileSync7(configPath, "utf-8");
|
|
38055
38205
|
JSON.parse(content);
|
|
38056
38206
|
return {
|
|
38057
38207
|
name: "Config Parseability",
|
|
@@ -38129,7 +38279,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
38129
38279
|
};
|
|
38130
38280
|
}
|
|
38131
38281
|
try {
|
|
38132
|
-
const content =
|
|
38282
|
+
const content = readFileSync7(manifestPath, "utf-8");
|
|
38133
38283
|
const parsed = JSON.parse(content);
|
|
38134
38284
|
if (!parsed.checkpoints || !Array.isArray(parsed.checkpoints)) {
|
|
38135
38285
|
return {
|
|
@@ -38181,7 +38331,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
38181
38331
|
};
|
|
38182
38332
|
}
|
|
38183
38333
|
try {
|
|
38184
|
-
const content =
|
|
38334
|
+
const content = readFileSync7(eventsPath, "utf-8");
|
|
38185
38335
|
const lines = content.split(`
|
|
38186
38336
|
`).filter((line) => line.trim() !== "");
|
|
38187
38337
|
let malformedCount = 0;
|
|
@@ -38222,7 +38372,7 @@ async function checkSteeringDirectives(directory) {
|
|
|
38222
38372
|
};
|
|
38223
38373
|
}
|
|
38224
38374
|
try {
|
|
38225
|
-
const content =
|
|
38375
|
+
const content = readFileSync7(eventsPath, "utf-8");
|
|
38226
38376
|
const lines = content.split(`
|
|
38227
38377
|
`).filter((line) => line.trim() !== "");
|
|
38228
38378
|
const directivesIssued = [];
|
|
@@ -38278,7 +38428,7 @@ async function checkCurator(directory) {
|
|
|
38278
38428
|
};
|
|
38279
38429
|
}
|
|
38280
38430
|
try {
|
|
38281
|
-
const content =
|
|
38431
|
+
const content = readFileSync7(summaryPath, "utf-8");
|
|
38282
38432
|
const parsed = JSON.parse(content);
|
|
38283
38433
|
if (typeof parsed.schema_version !== "number" || parsed.schema_version !== 1) {
|
|
38284
38434
|
return {
|
|
@@ -38475,7 +38625,7 @@ async function getDiagnoseData(directory) {
|
|
|
38475
38625
|
}
|
|
38476
38626
|
const pkgJsonPath = path19.join(cachePath, "package.json");
|
|
38477
38627
|
try {
|
|
38478
|
-
const raw =
|
|
38628
|
+
const raw = readFileSync7(pkgJsonPath, "utf-8");
|
|
38479
38629
|
const parsed = JSON.parse(raw);
|
|
38480
38630
|
const installedVersion = typeof parsed.version === "string" ? parsed.version : "?";
|
|
38481
38631
|
cacheRows.push(`\u2705 ${cachePath} \u2014 v${installedVersion}`);
|
|
@@ -40362,7 +40512,7 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
40362
40512
|
const scope = options?.scope ?? "all";
|
|
40363
40513
|
const changedFiles = options?.changedFiles ?? [];
|
|
40364
40514
|
const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
|
|
40365
|
-
const profileResult = await
|
|
40515
|
+
const profileResult = await _internals11.discoverBuildCommandsFromProfiles(workingDir);
|
|
40366
40516
|
const profileCommands = profileResult.commands;
|
|
40367
40517
|
const profileSkipped = profileResult.skipped;
|
|
40368
40518
|
const coveredEcosystems = new Set;
|
|
@@ -40425,7 +40575,7 @@ function clearToolchainCache() {
|
|
|
40425
40575
|
function getEcosystems() {
|
|
40426
40576
|
return ECOSYSTEMS.map((e) => e.ecosystem);
|
|
40427
40577
|
}
|
|
40428
|
-
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache,
|
|
40578
|
+
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, _internals11, build_discovery;
|
|
40429
40579
|
var init_discovery = __esm(() => {
|
|
40430
40580
|
init_dist();
|
|
40431
40581
|
init_detector();
|
|
@@ -40543,7 +40693,7 @@ var init_discovery = __esm(() => {
|
|
|
40543
40693
|
php: ["php-composer"]
|
|
40544
40694
|
};
|
|
40545
40695
|
toolchainCache = new Map;
|
|
40546
|
-
|
|
40696
|
+
_internals11 = {
|
|
40547
40697
|
isCommandAvailable,
|
|
40548
40698
|
discoverBuildCommandsFromProfiles,
|
|
40549
40699
|
discoverBuildCommands,
|
|
@@ -40795,7 +40945,7 @@ var exports_evidence_summary_service = {};
|
|
|
40795
40945
|
__export(exports_evidence_summary_service, {
|
|
40796
40946
|
isAutoSummaryEnabled: () => isAutoSummaryEnabled,
|
|
40797
40947
|
buildEvidenceSummary: () => buildEvidenceSummary,
|
|
40798
|
-
_internals: () =>
|
|
40948
|
+
_internals: () => _internals12,
|
|
40799
40949
|
REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
|
|
40800
40950
|
EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
|
|
40801
40951
|
});
|
|
@@ -40833,14 +40983,14 @@ function getTaskStatus(task, bundle) {
|
|
|
40833
40983
|
if (task?.status) {
|
|
40834
40984
|
return task.status;
|
|
40835
40985
|
}
|
|
40836
|
-
const entries =
|
|
40986
|
+
const entries = _internals12.normalizeBundleEntries(bundle);
|
|
40837
40987
|
if (entries.length > 0) {
|
|
40838
40988
|
return "completed";
|
|
40839
40989
|
}
|
|
40840
40990
|
return "pending";
|
|
40841
40991
|
}
|
|
40842
40992
|
function isEvidenceComplete(bundle) {
|
|
40843
|
-
const entries =
|
|
40993
|
+
const entries = _internals12.normalizeBundleEntries(bundle);
|
|
40844
40994
|
if (entries.length === 0) {
|
|
40845
40995
|
return {
|
|
40846
40996
|
isComplete: false,
|
|
@@ -40876,10 +41026,10 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
40876
41026
|
const result = await loadEvidence(directory, taskId);
|
|
40877
41027
|
const bundle = result.status === "found" ? result.bundle : null;
|
|
40878
41028
|
const phase = task?.phase ?? 0;
|
|
40879
|
-
const status =
|
|
40880
|
-
const evidenceCheck =
|
|
40881
|
-
const blockers =
|
|
40882
|
-
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);
|
|
40883
41033
|
const hasReview = entries.some((e) => e.type === "review");
|
|
40884
41034
|
const hasTest = entries.some((e) => e.type === "test");
|
|
40885
41035
|
const hasApproval = entries.some((e) => e.type === "approval");
|
|
@@ -40908,12 +41058,12 @@ async function buildPhaseSummary(directory, phase) {
|
|
|
40908
41058
|
const taskSummaries = [];
|
|
40909
41059
|
const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
|
|
40910
41060
|
for (const task of phase.tasks) {
|
|
40911
|
-
const summary = await
|
|
41061
|
+
const summary = await _internals12.buildTaskSummary(directory, task, task.id);
|
|
40912
41062
|
taskSummaries.push(summary);
|
|
40913
41063
|
}
|
|
40914
41064
|
const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
|
|
40915
41065
|
for (const taskId of extraTaskIds) {
|
|
40916
|
-
const summary = await
|
|
41066
|
+
const summary = await _internals12.buildTaskSummary(directory, undefined, taskId);
|
|
40917
41067
|
if (summary.phase === phase.id) {
|
|
40918
41068
|
taskSummaries.push(summary);
|
|
40919
41069
|
}
|
|
@@ -41014,7 +41164,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
41014
41164
|
let totalTasks = 0;
|
|
41015
41165
|
let completedTasks = 0;
|
|
41016
41166
|
for (const phase of phasesToProcess) {
|
|
41017
|
-
const summary = await
|
|
41167
|
+
const summary = await _internals12.buildPhaseSummary(directory, phase);
|
|
41018
41168
|
phaseSummaries.push(summary);
|
|
41019
41169
|
totalTasks += summary.totalTasks;
|
|
41020
41170
|
completedTasks += summary.completedTasks;
|
|
@@ -41036,7 +41186,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
41036
41186
|
overallBlockers,
|
|
41037
41187
|
summaryText: ""
|
|
41038
41188
|
};
|
|
41039
|
-
artifact.summaryText =
|
|
41189
|
+
artifact.summaryText = _internals12.generateSummaryText(artifact);
|
|
41040
41190
|
log("[EvidenceSummary] Summary built", {
|
|
41041
41191
|
phases: phaseSummaries.length,
|
|
41042
41192
|
totalTasks,
|
|
@@ -41055,7 +41205,7 @@ function isAutoSummaryEnabled(automationConfig) {
|
|
|
41055
41205
|
}
|
|
41056
41206
|
return automationConfig.capabilities?.evidence_auto_summaries === true;
|
|
41057
41207
|
}
|
|
41058
|
-
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;
|
|
41059
41209
|
var init_evidence_summary_service = __esm(() => {
|
|
41060
41210
|
init_manager2();
|
|
41061
41211
|
init_manager();
|
|
@@ -41069,7 +41219,7 @@ var init_evidence_summary_service = __esm(() => {
|
|
|
41069
41219
|
"retrospective"
|
|
41070
41220
|
]);
|
|
41071
41221
|
REQUIRED_EVIDENCE_TYPES = ["review", "test"];
|
|
41072
|
-
|
|
41222
|
+
_internals12 = {
|
|
41073
41223
|
buildEvidenceSummary,
|
|
41074
41224
|
isAutoSummaryEnabled,
|
|
41075
41225
|
normalizeBundleEntries,
|
|
@@ -41672,7 +41822,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
41672
41822
|
if (!plan) {
|
|
41673
41823
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
41674
41824
|
}
|
|
41675
|
-
if (!
|
|
41825
|
+
if (!_internals13.validatePlanPhases(plan)) {
|
|
41676
41826
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
41677
41827
|
}
|
|
41678
41828
|
let currentPhase = null;
|
|
@@ -41814,9 +41964,9 @@ function extractPhaseMetrics(content) {
|
|
|
41814
41964
|
async function getHandoffData(directory) {
|
|
41815
41965
|
const now = new Date().toISOString();
|
|
41816
41966
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
41817
|
-
const sessionState =
|
|
41967
|
+
const sessionState = _internals13.parseSessionState(sessionContent);
|
|
41818
41968
|
const plan = await loadPlanJsonOnly(directory);
|
|
41819
|
-
const planInfo =
|
|
41969
|
+
const planInfo = _internals13.extractCurrentPhaseFromPlan(plan);
|
|
41820
41970
|
if (!plan) {
|
|
41821
41971
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
41822
41972
|
if (planMdContent) {
|
|
@@ -41835,8 +41985,8 @@ async function getHandoffData(directory) {
|
|
|
41835
41985
|
}
|
|
41836
41986
|
}
|
|
41837
41987
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
41838
|
-
const recentDecisions =
|
|
41839
|
-
const rawPhaseMetrics =
|
|
41988
|
+
const recentDecisions = _internals13.extractDecisions(contextContent);
|
|
41989
|
+
const rawPhaseMetrics = _internals13.extractPhaseMetrics(contextContent);
|
|
41840
41990
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
41841
41991
|
let delegationState = null;
|
|
41842
41992
|
if (sessionState?.delegationState) {
|
|
@@ -42000,13 +42150,13 @@ ${lines.join(`
|
|
|
42000
42150
|
`)}
|
|
42001
42151
|
\`\`\``;
|
|
42002
42152
|
}
|
|
42003
|
-
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;
|
|
42004
42154
|
var init_handoff_service = __esm(() => {
|
|
42005
42155
|
init_utils2();
|
|
42006
42156
|
init_manager();
|
|
42007
42157
|
init_utils();
|
|
42008
42158
|
RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
|
|
42009
|
-
|
|
42159
|
+
_internals13 = {
|
|
42010
42160
|
getHandoffData,
|
|
42011
42161
|
formatHandoffMarkdown,
|
|
42012
42162
|
formatContinuationPrompt,
|
|
@@ -42125,22 +42275,22 @@ async function writeSnapshot(directory, state) {
|
|
|
42125
42275
|
}
|
|
42126
42276
|
function createSnapshotWriterHook(directory) {
|
|
42127
42277
|
return (_input, _output) => {
|
|
42128
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
42278
|
+
_writeInFlight = _writeInFlight.then(() => _internals14.writeSnapshot(directory, swarmState), () => _internals14.writeSnapshot(directory, swarmState));
|
|
42129
42279
|
return _writeInFlight;
|
|
42130
42280
|
};
|
|
42131
42281
|
}
|
|
42132
42282
|
async function flushPendingSnapshot(directory) {
|
|
42133
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
42283
|
+
_writeInFlight = _writeInFlight.then(() => _internals14.writeSnapshot(directory, swarmState), () => _internals14.writeSnapshot(directory, swarmState));
|
|
42134
42284
|
await _writeInFlight;
|
|
42135
42285
|
}
|
|
42136
|
-
var _writeInFlight,
|
|
42286
|
+
var _writeInFlight, _internals14;
|
|
42137
42287
|
var init_snapshot_writer = __esm(() => {
|
|
42138
42288
|
init_utils2();
|
|
42139
42289
|
init_state();
|
|
42140
42290
|
init_utils();
|
|
42141
42291
|
init_bun_compat();
|
|
42142
42292
|
_writeInFlight = Promise.resolve();
|
|
42143
|
-
|
|
42293
|
+
_internals14 = {
|
|
42144
42294
|
writeSnapshot,
|
|
42145
42295
|
createSnapshotWriterHook,
|
|
42146
42296
|
flushPendingSnapshot
|
|
@@ -42561,7 +42711,7 @@ var init_issue = __esm(() => {
|
|
|
42561
42711
|
|
|
42562
42712
|
// src/hooks/knowledge-migrator.ts
|
|
42563
42713
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
42564
|
-
import { existsSync as existsSync15, readFileSync as
|
|
42714
|
+
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
42565
42715
|
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile6 } from "fs/promises";
|
|
42566
42716
|
import * as path25 from "path";
|
|
42567
42717
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
@@ -42605,9 +42755,9 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42605
42755
|
skippedReason: "empty-context"
|
|
42606
42756
|
};
|
|
42607
42757
|
}
|
|
42608
|
-
const rawEntries =
|
|
42758
|
+
const rawEntries = _internals15.parseContextMd(contextContent);
|
|
42609
42759
|
if (rawEntries.length === 0) {
|
|
42610
|
-
await
|
|
42760
|
+
await _internals15.writeSentinel(sentinelPath, 0, 0);
|
|
42611
42761
|
return {
|
|
42612
42762
|
migrated: true,
|
|
42613
42763
|
entriesMigrated: 0,
|
|
@@ -42618,10 +42768,10 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42618
42768
|
const existing = await readKnowledge(knowledgePath);
|
|
42619
42769
|
let migrated = 0;
|
|
42620
42770
|
let dropped = 0;
|
|
42621
|
-
const projectName =
|
|
42771
|
+
const projectName = _internals15.inferProjectName(directory);
|
|
42622
42772
|
for (const raw of rawEntries) {
|
|
42623
42773
|
if (config3.validation_enabled !== false) {
|
|
42624
|
-
const category = raw.categoryHint ??
|
|
42774
|
+
const category = raw.categoryHint ?? _internals15.inferCategoryFromText(raw.text);
|
|
42625
42775
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
42626
42776
|
category,
|
|
42627
42777
|
scope: "global",
|
|
@@ -42641,8 +42791,8 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42641
42791
|
const entry = {
|
|
42642
42792
|
id: randomUUID2(),
|
|
42643
42793
|
tier: "swarm",
|
|
42644
|
-
lesson:
|
|
42645
|
-
category: raw.categoryHint ??
|
|
42794
|
+
lesson: _internals15.truncateLesson(raw.text),
|
|
42795
|
+
category: raw.categoryHint ?? _internals15.inferCategoryFromText(raw.text),
|
|
42646
42796
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
42647
42797
|
scope: "global",
|
|
42648
42798
|
confidence: 0.3,
|
|
@@ -42665,7 +42815,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42665
42815
|
if (migrated > 0) {
|
|
42666
42816
|
await rewriteKnowledge(knowledgePath, existing);
|
|
42667
42817
|
}
|
|
42668
|
-
await
|
|
42818
|
+
await _internals15.writeSentinel(sentinelPath, migrated, dropped);
|
|
42669
42819
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
42670
42820
|
return {
|
|
42671
42821
|
migrated: true,
|
|
@@ -42675,7 +42825,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
42675
42825
|
};
|
|
42676
42826
|
}
|
|
42677
42827
|
function parseContextMd(content) {
|
|
42678
|
-
const sections =
|
|
42828
|
+
const sections = _internals15.splitIntoSections(content);
|
|
42679
42829
|
const entries = [];
|
|
42680
42830
|
const seen = new Set;
|
|
42681
42831
|
const sectionPatterns = [
|
|
@@ -42691,7 +42841,7 @@ function parseContextMd(content) {
|
|
|
42691
42841
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
42692
42842
|
if (!match)
|
|
42693
42843
|
continue;
|
|
42694
|
-
const bullets =
|
|
42844
|
+
const bullets = _internals15.extractBullets(section.body);
|
|
42695
42845
|
for (const bullet of bullets) {
|
|
42696
42846
|
if (bullet.length < 15)
|
|
42697
42847
|
continue;
|
|
@@ -42700,9 +42850,9 @@ function parseContextMd(content) {
|
|
|
42700
42850
|
continue;
|
|
42701
42851
|
seen.add(normalized);
|
|
42702
42852
|
entries.push({
|
|
42703
|
-
text:
|
|
42853
|
+
text: _internals15.truncateLesson(bullet),
|
|
42704
42854
|
sourceSection: match.sourceSection,
|
|
42705
|
-
categoryHint:
|
|
42855
|
+
categoryHint: _internals15.inferCategoryFromText(bullet)
|
|
42706
42856
|
});
|
|
42707
42857
|
}
|
|
42708
42858
|
}
|
|
@@ -42774,7 +42924,7 @@ function inferProjectName(directory) {
|
|
|
42774
42924
|
const packageJsonPath = path25.join(directory, "package.json");
|
|
42775
42925
|
if (existsSync15(packageJsonPath)) {
|
|
42776
42926
|
try {
|
|
42777
|
-
const pkg = JSON.parse(
|
|
42927
|
+
const pkg = JSON.parse(readFileSync12(packageJsonPath, "utf-8"));
|
|
42778
42928
|
if (pkg.name && typeof pkg.name === "string") {
|
|
42779
42929
|
return pkg.name;
|
|
42780
42930
|
}
|
|
@@ -42795,12 +42945,12 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
42795
42945
|
await mkdir5(path25.dirname(sentinelPath), { recursive: true });
|
|
42796
42946
|
await writeFile6(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
42797
42947
|
}
|
|
42798
|
-
var
|
|
42948
|
+
var _internals15;
|
|
42799
42949
|
var init_knowledge_migrator = __esm(() => {
|
|
42800
42950
|
init_logger();
|
|
42801
42951
|
init_knowledge_store();
|
|
42802
42952
|
init_knowledge_validator();
|
|
42803
|
-
|
|
42953
|
+
_internals15 = {
|
|
42804
42954
|
migrateContextToKnowledge,
|
|
42805
42955
|
migrateKnowledgeToExternal,
|
|
42806
42956
|
parseContextMd,
|
|
@@ -43666,7 +43816,7 @@ async function runAdditionalLint(linter, mode, cwd) {
|
|
|
43666
43816
|
};
|
|
43667
43817
|
}
|
|
43668
43818
|
}
|
|
43669
|
-
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint,
|
|
43819
|
+
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals16;
|
|
43670
43820
|
var init_lint = __esm(() => {
|
|
43671
43821
|
init_zod();
|
|
43672
43822
|
init_discovery();
|
|
@@ -43698,15 +43848,15 @@ var init_lint = __esm(() => {
|
|
|
43698
43848
|
}
|
|
43699
43849
|
const { mode } = args;
|
|
43700
43850
|
const cwd = directory;
|
|
43701
|
-
const linter = await
|
|
43851
|
+
const linter = await _internals16.detectAvailableLinter(directory);
|
|
43702
43852
|
if (linter) {
|
|
43703
|
-
const result = await
|
|
43853
|
+
const result = await _internals16.runLint(linter, mode, directory);
|
|
43704
43854
|
return JSON.stringify(result, null, 2);
|
|
43705
43855
|
}
|
|
43706
|
-
const additionalLinter =
|
|
43856
|
+
const additionalLinter = _internals16.detectAdditionalLinter(cwd);
|
|
43707
43857
|
if (additionalLinter) {
|
|
43708
43858
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
43709
|
-
const result = await
|
|
43859
|
+
const result = await _internals16.runAdditionalLint(additionalLinter, mode, cwd);
|
|
43710
43860
|
return JSON.stringify(result, null, 2);
|
|
43711
43861
|
}
|
|
43712
43862
|
const errorResult = {
|
|
@@ -43720,7 +43870,7 @@ For Rust: rustup component add clippy`
|
|
|
43720
43870
|
return JSON.stringify(errorResult, null, 2);
|
|
43721
43871
|
}
|
|
43722
43872
|
});
|
|
43723
|
-
|
|
43873
|
+
_internals16 = {
|
|
43724
43874
|
detectAvailableLinter,
|
|
43725
43875
|
runLint,
|
|
43726
43876
|
detectAdditionalLinter,
|
|
@@ -44034,7 +44184,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
44034
44184
|
}
|
|
44035
44185
|
async function runSecretscan(directory) {
|
|
44036
44186
|
try {
|
|
44037
|
-
const result = await
|
|
44187
|
+
const result = await _internals17.secretscan.execute({ directory }, {});
|
|
44038
44188
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
44039
44189
|
return JSON.parse(jsonStr);
|
|
44040
44190
|
} catch (e) {
|
|
@@ -44049,7 +44199,7 @@ async function runSecretscan(directory) {
|
|
|
44049
44199
|
return errorResult;
|
|
44050
44200
|
}
|
|
44051
44201
|
}
|
|
44052
|
-
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;
|
|
44053
44203
|
var init_secretscan = __esm(() => {
|
|
44054
44204
|
init_zod();
|
|
44055
44205
|
init_path_security();
|
|
@@ -44421,7 +44571,7 @@ var init_secretscan = __esm(() => {
|
|
|
44421
44571
|
}
|
|
44422
44572
|
}
|
|
44423
44573
|
});
|
|
44424
|
-
|
|
44574
|
+
_internals17 = {
|
|
44425
44575
|
secretscan,
|
|
44426
44576
|
runSecretscan
|
|
44427
44577
|
};
|
|
@@ -44556,8 +44706,8 @@ async function buildImpactMapInternal(cwd) {
|
|
|
44556
44706
|
return impactMap;
|
|
44557
44707
|
}
|
|
44558
44708
|
async function buildImpactMap(cwd) {
|
|
44559
|
-
const impactMap = await
|
|
44560
|
-
await
|
|
44709
|
+
const impactMap = await _internals18.buildImpactMapInternal(cwd);
|
|
44710
|
+
await _internals18.saveImpactMap(cwd, impactMap);
|
|
44561
44711
|
return impactMap;
|
|
44562
44712
|
}
|
|
44563
44713
|
async function loadImpactMap(cwd) {
|
|
@@ -44568,12 +44718,12 @@ async function loadImpactMap(cwd) {
|
|
|
44568
44718
|
const data = JSON.parse(content);
|
|
44569
44719
|
const map3 = data.map;
|
|
44570
44720
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
44571
|
-
if (!
|
|
44721
|
+
if (!_internals18.isCacheStale(map3, generatedAt)) {
|
|
44572
44722
|
return map3;
|
|
44573
44723
|
}
|
|
44574
44724
|
} catch {}
|
|
44575
44725
|
}
|
|
44576
|
-
return
|
|
44726
|
+
return _internals18.buildImpactMap(cwd);
|
|
44577
44727
|
}
|
|
44578
44728
|
async function saveImpactMap(cwd, impactMap) {
|
|
44579
44729
|
const cacheDir2 = path28.join(cwd, ".swarm", "cache");
|
|
@@ -44599,7 +44749,7 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
44599
44749
|
};
|
|
44600
44750
|
}
|
|
44601
44751
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
44602
|
-
const impactMap = await
|
|
44752
|
+
const impactMap = await _internals18.loadImpactMap(cwd);
|
|
44603
44753
|
const impactedTestsSet = new Set;
|
|
44604
44754
|
const untestedFiles = [];
|
|
44605
44755
|
for (const changedFile of validFiles) {
|
|
@@ -44640,13 +44790,13 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
44640
44790
|
impactMap
|
|
44641
44791
|
};
|
|
44642
44792
|
}
|
|
44643
|
-
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;
|
|
44644
44794
|
var init_analyzer = __esm(() => {
|
|
44645
44795
|
IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
44646
44796
|
IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
44647
44797
|
IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
44648
44798
|
EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
44649
|
-
|
|
44799
|
+
_internals18 = {
|
|
44650
44800
|
normalizePath,
|
|
44651
44801
|
isCacheStale,
|
|
44652
44802
|
resolveRelativeImport,
|
|
@@ -46493,9 +46643,9 @@ function getVersionFileVersion(dir) {
|
|
|
46493
46643
|
async function runVersionCheck(dir, _timeoutMs) {
|
|
46494
46644
|
const startTime = Date.now();
|
|
46495
46645
|
try {
|
|
46496
|
-
const packageVersion =
|
|
46497
|
-
const changelogVersion =
|
|
46498
|
-
const versionFileVersion =
|
|
46646
|
+
const packageVersion = _internals19.getPackageVersion(dir);
|
|
46647
|
+
const changelogVersion = _internals19.getChangelogVersion(dir);
|
|
46648
|
+
const versionFileVersion = _internals19.getVersionFileVersion(dir);
|
|
46499
46649
|
const versions3 = [];
|
|
46500
46650
|
if (packageVersion)
|
|
46501
46651
|
versions3.push(`package.json: ${packageVersion}`);
|
|
@@ -46845,7 +46995,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46845
46995
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
46846
46996
|
let validatedDir;
|
|
46847
46997
|
try {
|
|
46848
|
-
validatedDir =
|
|
46998
|
+
validatedDir = _internals19.validateDirectoryPath(dir);
|
|
46849
46999
|
} catch (error93) {
|
|
46850
47000
|
return {
|
|
46851
47001
|
id: reportId,
|
|
@@ -46865,7 +47015,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46865
47015
|
}
|
|
46866
47016
|
let validatedTimeout;
|
|
46867
47017
|
try {
|
|
46868
|
-
validatedTimeout =
|
|
47018
|
+
validatedTimeout = _internals19.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
46869
47019
|
} catch (error93) {
|
|
46870
47020
|
return {
|
|
46871
47021
|
id: reportId,
|
|
@@ -46906,12 +47056,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46906
47056
|
});
|
|
46907
47057
|
const checks5 = [];
|
|
46908
47058
|
log("[Preflight] Running lint check...");
|
|
46909
|
-
const lintResult = await
|
|
47059
|
+
const lintResult = await _internals19.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
46910
47060
|
checks5.push(lintResult);
|
|
46911
47061
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
46912
47062
|
if (!cfg.skipTests) {
|
|
46913
47063
|
log("[Preflight] Running tests check...");
|
|
46914
|
-
const testsResult = await
|
|
47064
|
+
const testsResult = await _internals19.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
46915
47065
|
checks5.push(testsResult);
|
|
46916
47066
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
46917
47067
|
} else {
|
|
@@ -46923,7 +47073,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46923
47073
|
}
|
|
46924
47074
|
if (!cfg.skipSecrets) {
|
|
46925
47075
|
log("[Preflight] Running secrets check...");
|
|
46926
|
-
const secretsResult = await
|
|
47076
|
+
const secretsResult = await _internals19.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
46927
47077
|
checks5.push(secretsResult);
|
|
46928
47078
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
46929
47079
|
} else {
|
|
@@ -46935,7 +47085,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46935
47085
|
}
|
|
46936
47086
|
if (!cfg.skipEvidence) {
|
|
46937
47087
|
log("[Preflight] Running evidence check...");
|
|
46938
|
-
const evidenceResult = await
|
|
47088
|
+
const evidenceResult = await _internals19.runEvidenceCheck(validatedDir);
|
|
46939
47089
|
checks5.push(evidenceResult);
|
|
46940
47090
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
46941
47091
|
} else {
|
|
@@ -46946,12 +47096,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
46946
47096
|
});
|
|
46947
47097
|
}
|
|
46948
47098
|
log("[Preflight] Running requirement coverage check...");
|
|
46949
|
-
const reqCoverageResult = await
|
|
47099
|
+
const reqCoverageResult = await _internals19.runRequirementCoverageCheck(validatedDir, phase);
|
|
46950
47100
|
checks5.push(reqCoverageResult);
|
|
46951
47101
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
46952
47102
|
if (!cfg.skipVersion) {
|
|
46953
47103
|
log("[Preflight] Running version check...");
|
|
46954
|
-
const versionResult = await
|
|
47104
|
+
const versionResult = await _internals19.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
46955
47105
|
checks5.push(versionResult);
|
|
46956
47106
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
46957
47107
|
} else {
|
|
@@ -47014,10 +47164,10 @@ function formatPreflightMarkdown(report) {
|
|
|
47014
47164
|
async function handlePreflightCommand(directory, _args) {
|
|
47015
47165
|
const plan = await loadPlan(directory);
|
|
47016
47166
|
const phase = plan?.current_phase ?? 1;
|
|
47017
|
-
const report = await
|
|
47018
|
-
return
|
|
47167
|
+
const report = await _internals19.runPreflight(directory, phase);
|
|
47168
|
+
return _internals19.formatPreflightMarkdown(report);
|
|
47019
47169
|
}
|
|
47020
|
-
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;
|
|
47021
47171
|
var init_preflight_service = __esm(() => {
|
|
47022
47172
|
init_manager2();
|
|
47023
47173
|
init_manager();
|
|
@@ -47034,7 +47184,7 @@ var init_preflight_service = __esm(() => {
|
|
|
47034
47184
|
testScope: "convention",
|
|
47035
47185
|
linter: "biome"
|
|
47036
47186
|
};
|
|
47037
|
-
|
|
47187
|
+
_internals19 = {
|
|
47038
47188
|
runPreflight,
|
|
47039
47189
|
formatPreflightMarkdown,
|
|
47040
47190
|
handlePreflightCommand,
|
|
@@ -48291,7 +48441,7 @@ async function handleSimulateCommand(directory, args) {
|
|
|
48291
48441
|
}
|
|
48292
48442
|
let darkMatterPairs;
|
|
48293
48443
|
try {
|
|
48294
|
-
darkMatterPairs = await
|
|
48444
|
+
darkMatterPairs = await _internals10.detectDarkMatter(directory, options);
|
|
48295
48445
|
} catch (err) {
|
|
48296
48446
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
48297
48447
|
return `## Simulate Report
|
|
@@ -48345,6 +48495,158 @@ async function handleSpecifyCommand(_directory, args) {
|
|
|
48345
48495
|
return "[MODE: SPECIFY] Please enter MODE: SPECIFY and generate a spec for this project.";
|
|
48346
48496
|
}
|
|
48347
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
|
+
|
|
48348
48650
|
// src/services/compaction-service.ts
|
|
48349
48651
|
function makeInitialState() {
|
|
48350
48652
|
return {
|
|
@@ -48408,66 +48710,126 @@ var init_context_budget_service = __esm(() => {
|
|
|
48408
48710
|
// src/services/status-service.ts
|
|
48409
48711
|
async function getStatusData(directory, agents) {
|
|
48410
48712
|
const plan = await loadPlan(directory);
|
|
48713
|
+
let status;
|
|
48411
48714
|
if (plan && plan.migration_status !== "migration_failed") {
|
|
48412
|
-
const
|
|
48413
|
-
let
|
|
48414
|
-
let
|
|
48715
|
+
const currentPhase = extractCurrentPhaseFromPlan(plan) || "Unknown";
|
|
48716
|
+
let completedTasks = 0;
|
|
48717
|
+
let totalTasks = 0;
|
|
48415
48718
|
for (const phase of plan.phases) {
|
|
48416
48719
|
for (const task of phase.tasks) {
|
|
48417
|
-
|
|
48720
|
+
totalTasks++;
|
|
48418
48721
|
if (task.status === "completed")
|
|
48419
|
-
|
|
48722
|
+
completedTasks++;
|
|
48420
48723
|
}
|
|
48421
48724
|
}
|
|
48422
|
-
const
|
|
48423
|
-
const
|
|
48424
|
-
|
|
48725
|
+
const agentCount = Object.keys(agents).length;
|
|
48726
|
+
const metrics = getCompactionMetrics();
|
|
48727
|
+
status = {
|
|
48425
48728
|
hasPlan: true,
|
|
48426
|
-
currentPhase
|
|
48427
|
-
completedTasks
|
|
48428
|
-
totalTasks
|
|
48429
|
-
agentCount
|
|
48729
|
+
currentPhase,
|
|
48730
|
+
completedTasks,
|
|
48731
|
+
totalTasks,
|
|
48732
|
+
agentCount,
|
|
48430
48733
|
isLegacy: false,
|
|
48431
48734
|
turboMode: hasActiveTurboMode(),
|
|
48432
48735
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
48433
|
-
compactionCount:
|
|
48434
|
-
lastSnapshotAt:
|
|
48736
|
+
compactionCount: metrics.compactionCount,
|
|
48737
|
+
lastSnapshotAt: metrics.lastSnapshotAt
|
|
48435
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
|
+
}
|
|
48436
48775
|
}
|
|
48437
|
-
|
|
48438
|
-
|
|
48439
|
-
|
|
48440
|
-
|
|
48441
|
-
|
|
48442
|
-
|
|
48443
|
-
|
|
48444
|
-
|
|
48445
|
-
|
|
48446
|
-
|
|
48447
|
-
turboMode: hasActiveTurboMode(),
|
|
48448
|
-
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
48449
|
-
compactionCount: metrics2.compactionCount,
|
|
48450
|
-
lastSnapshotAt: metrics2.lastSnapshotAt
|
|
48451
|
-
};
|
|
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";
|
|
48452
48786
|
}
|
|
48453
|
-
|
|
48454
|
-
|
|
48455
|
-
|
|
48456
|
-
|
|
48457
|
-
|
|
48458
|
-
const
|
|
48459
|
-
|
|
48460
|
-
|
|
48461
|
-
|
|
48462
|
-
|
|
48463
|
-
|
|
48464
|
-
|
|
48465
|
-
|
|
48466
|
-
|
|
48467
|
-
|
|
48468
|
-
|
|
48469
|
-
|
|
48470
|
-
|
|
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;
|
|
48471
48833
|
}
|
|
48472
48834
|
function formatStatusMarkdown(status) {
|
|
48473
48835
|
const lines = [
|
|
@@ -48477,8 +48839,36 @@ function formatStatusMarkdown(status) {
|
|
|
48477
48839
|
`**Tasks**: ${status.completedTasks}/${status.totalTasks} complete`,
|
|
48478
48840
|
`**Agents**: ${status.agentCount} registered`
|
|
48479
48841
|
];
|
|
48480
|
-
if (status.
|
|
48481
|
-
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");
|
|
48482
48872
|
}
|
|
48483
48873
|
if (status.contextBudgetPct !== null && status.contextBudgetPct > 0) {
|
|
48484
48874
|
const pct = status.contextBudgetPct.toFixed(1);
|
|
@@ -48502,13 +48892,20 @@ async function handleStatusCommand(directory, agents) {
|
|
|
48502
48892
|
}
|
|
48503
48893
|
return formatStatusMarkdown(statusData);
|
|
48504
48894
|
}
|
|
48895
|
+
var _internals20;
|
|
48505
48896
|
var init_status_service = __esm(() => {
|
|
48506
48897
|
init_extractors();
|
|
48507
48898
|
init_utils2();
|
|
48508
48899
|
init_manager();
|
|
48509
48900
|
init_state();
|
|
48901
|
+
init_state3();
|
|
48510
48902
|
init_compaction_service();
|
|
48511
48903
|
init_context_budget_service();
|
|
48904
|
+
_internals20 = {
|
|
48905
|
+
loadLeanTurboRunState,
|
|
48906
|
+
hasActiveLeanTurbo,
|
|
48907
|
+
hasActiveFullAuto
|
|
48908
|
+
};
|
|
48512
48909
|
});
|
|
48513
48910
|
|
|
48514
48911
|
// src/commands/status.ts
|
|
@@ -48544,7 +48941,7 @@ var init_sync_plan = __esm(() => {
|
|
|
48544
48941
|
});
|
|
48545
48942
|
|
|
48546
48943
|
// src/commands/turbo.ts
|
|
48547
|
-
async function handleTurboCommand(
|
|
48944
|
+
async function handleTurboCommand(directory, args, sessionID) {
|
|
48548
48945
|
if (!sessionID || sessionID.trim() === "") {
|
|
48549
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.";
|
|
48550
48947
|
}
|
|
@@ -48552,24 +48949,179 @@ async function handleTurboCommand(_directory, args, sessionID) {
|
|
|
48552
48949
|
if (!session) {
|
|
48553
48950
|
return "Error: No active session. Turbo Mode requires an active session to operate.";
|
|
48554
48951
|
}
|
|
48555
|
-
const
|
|
48556
|
-
|
|
48557
|
-
|
|
48558
|
-
|
|
48559
|
-
|
|
48560
|
-
|
|
48561
|
-
|
|
48562
|
-
|
|
48563
|
-
|
|
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";
|
|
48564
49038
|
} else {
|
|
48565
|
-
|
|
48566
|
-
|
|
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}`);
|
|
48567
49067
|
}
|
|
48568
|
-
|
|
48569
|
-
|
|
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
|
+
`);
|
|
48570
49119
|
}
|
|
48571
49120
|
var init_turbo = __esm(() => {
|
|
49121
|
+
init_config();
|
|
48572
49122
|
init_state();
|
|
49123
|
+
init_state3();
|
|
49124
|
+
init_logger();
|
|
48573
49125
|
});
|
|
48574
49126
|
|
|
48575
49127
|
// src/commands/write-retro.ts
|
|
@@ -48693,8 +49245,8 @@ __export(exports_commands, {
|
|
|
48693
49245
|
COMMAND_NAME_SET: () => COMMAND_NAME_SET,
|
|
48694
49246
|
COMMAND_NAMES: () => COMMAND_NAMES
|
|
48695
49247
|
});
|
|
48696
|
-
import
|
|
48697
|
-
import
|
|
49248
|
+
import fs23 from "fs";
|
|
49249
|
+
import path38 from "path";
|
|
48698
49250
|
function buildHelpText() {
|
|
48699
49251
|
const lines = ["## Swarm Commands", ""];
|
|
48700
49252
|
const CATEGORIES = [
|
|
@@ -48797,11 +49349,11 @@ function createSwarmCommandHandler(directory, agents) {
|
|
|
48797
49349
|
return;
|
|
48798
49350
|
}
|
|
48799
49351
|
let isFirstRun = false;
|
|
48800
|
-
const sentinelPath =
|
|
49352
|
+
const sentinelPath = path38.join(directory, ".swarm", ".first-run-complete");
|
|
48801
49353
|
try {
|
|
48802
|
-
const swarmDir =
|
|
48803
|
-
|
|
48804
|
-
|
|
49354
|
+
const swarmDir = path38.join(directory, ".swarm");
|
|
49355
|
+
fs23.mkdirSync(swarmDir, { recursive: true });
|
|
49356
|
+
fs23.writeFileSync(sentinelPath, `first-run-complete: ${new Date().toISOString()}
|
|
48805
49357
|
`, { flag: "wx" });
|
|
48806
49358
|
isFirstRun = true;
|
|
48807
49359
|
} catch (_err) {}
|
|
@@ -48822,7 +49374,7 @@ function createSwarmCommandHandler(directory, agents) {
|
|
|
48822
49374
|
const attemptedCommand = tokens[0] || "";
|
|
48823
49375
|
const MAX_DISPLAY = 100;
|
|
48824
49376
|
const displayCommand = attemptedCommand.length > MAX_DISPLAY ? `${attemptedCommand.slice(0, MAX_DISPLAY)}...` : attemptedCommand;
|
|
48825
|
-
const similar =
|
|
49377
|
+
const similar = _internals21.findSimilarCommands(attemptedCommand);
|
|
48826
49378
|
const header = `Command \`/swarm ${displayCommand}\` not found.`;
|
|
48827
49379
|
const suggestions = similar.length > 0 ? `Did you mean:
|
|
48828
49380
|
${similar.map((cmd) => ` \u2022 /swarm ${cmd}`).join(`
|
|
@@ -48929,7 +49481,7 @@ function findSimilarCommands(query) {
|
|
|
48929
49481
|
}
|
|
48930
49482
|
const scored = VALID_COMMANDS.map((cmd) => {
|
|
48931
49483
|
const cmdLower = cmd.toLowerCase();
|
|
48932
|
-
const fullScore =
|
|
49484
|
+
const fullScore = _internals21.levenshteinDistance(q, cmdLower);
|
|
48933
49485
|
let tokenScore = Infinity;
|
|
48934
49486
|
if (cmd.includes(" ") || cmd.includes("-")) {
|
|
48935
49487
|
const qTokens = q.split(/[\s-]+/);
|
|
@@ -48942,7 +49494,7 @@ function findSimilarCommands(query) {
|
|
|
48942
49494
|
for (const ct of cmdTokens) {
|
|
48943
49495
|
if (ct.length === 0)
|
|
48944
49496
|
continue;
|
|
48945
|
-
const dist =
|
|
49497
|
+
const dist = _internals21.levenshteinDistance(qt, ct);
|
|
48946
49498
|
if (dist < minDist)
|
|
48947
49499
|
minDist = dist;
|
|
48948
49500
|
}
|
|
@@ -48952,7 +49504,7 @@ function findSimilarCommands(query) {
|
|
|
48952
49504
|
}
|
|
48953
49505
|
const dashStrippedQ = q.replace(/-/g, "");
|
|
48954
49506
|
const dashStrippedCmd = cmdLower.replace(/-/g, "");
|
|
48955
|
-
const dashScore =
|
|
49507
|
+
const dashScore = _internals21.levenshteinDistance(dashStrippedQ, dashStrippedCmd);
|
|
48956
49508
|
const score = Math.min(fullScore, tokenScore, dashScore);
|
|
48957
49509
|
return { cmd, score };
|
|
48958
49510
|
});
|
|
@@ -48984,11 +49536,11 @@ async function handleHelpCommand(ctx) {
|
|
|
48984
49536
|
return buildHelpText2();
|
|
48985
49537
|
}
|
|
48986
49538
|
const tokens = targetCommand.split(/\s+/);
|
|
48987
|
-
const resolved =
|
|
49539
|
+
const resolved = _internals21.resolveCommand(tokens);
|
|
48988
49540
|
if (resolved) {
|
|
48989
|
-
return
|
|
49541
|
+
return _internals21.buildDetailedHelp(resolved.key, resolved.entry);
|
|
48990
49542
|
}
|
|
48991
|
-
const similar =
|
|
49543
|
+
const similar = _internals21.findSimilarCommands(targetCommand);
|
|
48992
49544
|
const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
|
|
48993
49545
|
if (similar.length > 0) {
|
|
48994
49546
|
return `Command '/swarm ${targetCommand}' not found.
|
|
@@ -49024,24 +49576,24 @@ function validateAliases() {
|
|
|
49024
49576
|
}
|
|
49025
49577
|
aliasTargets.get(target).push(name);
|
|
49026
49578
|
const visited = new Set;
|
|
49027
|
-
const
|
|
49579
|
+
const path39 = [];
|
|
49028
49580
|
let current = target;
|
|
49029
49581
|
while (current) {
|
|
49030
49582
|
const currentEntry = COMMAND_REGISTRY[current];
|
|
49031
49583
|
if (!currentEntry)
|
|
49032
49584
|
break;
|
|
49033
49585
|
if (visited.has(current)) {
|
|
49034
|
-
const cycleStart =
|
|
49586
|
+
const cycleStart = path39.indexOf(current);
|
|
49035
49587
|
const fullChain = [
|
|
49036
49588
|
name,
|
|
49037
|
-
...
|
|
49589
|
+
...path39.slice(0, cycleStart > 0 ? cycleStart : path39.length),
|
|
49038
49590
|
current
|
|
49039
49591
|
].join(" \u2192 ");
|
|
49040
49592
|
errors5.push(`Circular alias detected: ${fullChain}`);
|
|
49041
49593
|
break;
|
|
49042
49594
|
}
|
|
49043
49595
|
visited.add(current);
|
|
49044
|
-
|
|
49596
|
+
path39.push(current);
|
|
49045
49597
|
current = currentEntry.aliasOf || "";
|
|
49046
49598
|
}
|
|
49047
49599
|
}
|
|
@@ -49082,7 +49634,7 @@ function resolveCommand(tokens) {
|
|
|
49082
49634
|
}
|
|
49083
49635
|
return null;
|
|
49084
49636
|
}
|
|
49085
|
-
var COMMAND_REGISTRY, VALID_COMMANDS,
|
|
49637
|
+
var COMMAND_REGISTRY, VALID_COMMANDS, _internals21, validation;
|
|
49086
49638
|
var init_registry = __esm(() => {
|
|
49087
49639
|
init_acknowledge_spec_drift();
|
|
49088
49640
|
init_agents();
|
|
@@ -49152,7 +49704,7 @@ var init_registry = __esm(() => {
|
|
|
49152
49704
|
clashesWithNativeCcCommand: "/agents"
|
|
49153
49705
|
},
|
|
49154
49706
|
help: {
|
|
49155
|
-
handler: (ctx) =>
|
|
49707
|
+
handler: (ctx) => _internals21.handleHelpCommand(ctx),
|
|
49156
49708
|
description: "Show help for swarm commands",
|
|
49157
49709
|
category: "core",
|
|
49158
49710
|
args: "[command]",
|
|
@@ -49505,7 +50057,7 @@ var init_registry = __esm(() => {
|
|
|
49505
50057
|
}
|
|
49506
50058
|
};
|
|
49507
50059
|
VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
|
|
49508
|
-
|
|
50060
|
+
_internals21 = {
|
|
49509
50061
|
handleHelpCommand,
|
|
49510
50062
|
validateAliases,
|
|
49511
50063
|
resolveCommand,
|
|
@@ -49513,7 +50065,7 @@ var init_registry = __esm(() => {
|
|
|
49513
50065
|
findSimilarCommands,
|
|
49514
50066
|
buildDetailedHelp
|
|
49515
50067
|
};
|
|
49516
|
-
validation =
|
|
50068
|
+
validation = _internals21.validateAliases();
|
|
49517
50069
|
if (!validation.valid) {
|
|
49518
50070
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
49519
50071
|
${validation.errors.join(`
|
|
@@ -49531,68 +50083,68 @@ init_package();
|
|
|
49531
50083
|
init_registry();
|
|
49532
50084
|
init_cache_paths();
|
|
49533
50085
|
init_constants();
|
|
49534
|
-
import * as
|
|
50086
|
+
import * as fs24 from "fs";
|
|
49535
50087
|
import * as os7 from "os";
|
|
49536
|
-
import * as
|
|
50088
|
+
import * as path39 from "path";
|
|
49537
50089
|
var { version: version4 } = package_default;
|
|
49538
50090
|
var CONFIG_DIR = getPluginConfigDir();
|
|
49539
|
-
var OPENCODE_CONFIG_PATH =
|
|
49540
|
-
var PLUGIN_CONFIG_PATH =
|
|
49541
|
-
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");
|
|
49542
50094
|
var OPENCODE_PLUGIN_CACHE_PATHS = getPluginCachePaths();
|
|
49543
50095
|
var OPENCODE_PLUGIN_LOCK_FILE_PATHS = getPluginLockFilePaths();
|
|
49544
50096
|
function isSafeCachePath(p) {
|
|
49545
|
-
const resolved =
|
|
49546
|
-
const home =
|
|
50097
|
+
const resolved = path39.resolve(p);
|
|
50098
|
+
const home = path39.resolve(os7.homedir());
|
|
49547
50099
|
if (resolved === "/" || resolved === home || resolved.length <= home.length) {
|
|
49548
50100
|
return false;
|
|
49549
50101
|
}
|
|
49550
|
-
const segments = resolved.split(
|
|
50102
|
+
const segments = resolved.split(path39.sep).filter((s) => s.length > 0);
|
|
49551
50103
|
if (segments.length < 4) {
|
|
49552
50104
|
return false;
|
|
49553
50105
|
}
|
|
49554
|
-
const leaf =
|
|
50106
|
+
const leaf = path39.basename(resolved);
|
|
49555
50107
|
if (leaf !== "opencode-swarm@latest" && leaf !== "opencode-swarm") {
|
|
49556
50108
|
return false;
|
|
49557
50109
|
}
|
|
49558
|
-
const parent =
|
|
50110
|
+
const parent = path39.basename(path39.dirname(resolved));
|
|
49559
50111
|
if (parent !== "packages" && parent !== "node_modules") {
|
|
49560
50112
|
return false;
|
|
49561
50113
|
}
|
|
49562
|
-
const grandparent =
|
|
50114
|
+
const grandparent = path39.basename(path39.dirname(path39.dirname(resolved)));
|
|
49563
50115
|
if (grandparent !== "opencode") {
|
|
49564
50116
|
return false;
|
|
49565
50117
|
}
|
|
49566
50118
|
return true;
|
|
49567
50119
|
}
|
|
49568
50120
|
function isSafeLockFilePath(p) {
|
|
49569
|
-
const resolved =
|
|
49570
|
-
const home =
|
|
50121
|
+
const resolved = path39.resolve(p);
|
|
50122
|
+
const home = path39.resolve(os7.homedir());
|
|
49571
50123
|
if (resolved === "/" || resolved === home || resolved.length <= home.length) {
|
|
49572
50124
|
return false;
|
|
49573
50125
|
}
|
|
49574
|
-
const segments = resolved.split(
|
|
50126
|
+
const segments = resolved.split(path39.sep).filter((s) => s.length > 0);
|
|
49575
50127
|
if (segments.length < 4) {
|
|
49576
50128
|
return false;
|
|
49577
50129
|
}
|
|
49578
|
-
const leaf =
|
|
50130
|
+
const leaf = path39.basename(resolved);
|
|
49579
50131
|
if (leaf !== "bun.lock" && leaf !== "bun.lockb" && leaf !== "package-lock.json") {
|
|
49580
50132
|
return false;
|
|
49581
50133
|
}
|
|
49582
|
-
const parent =
|
|
50134
|
+
const parent = path39.basename(path39.dirname(resolved));
|
|
49583
50135
|
if (parent !== "opencode") {
|
|
49584
50136
|
return false;
|
|
49585
50137
|
}
|
|
49586
50138
|
return true;
|
|
49587
50139
|
}
|
|
49588
50140
|
function ensureDir(dir) {
|
|
49589
|
-
if (!
|
|
49590
|
-
|
|
50141
|
+
if (!fs24.existsSync(dir)) {
|
|
50142
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
49591
50143
|
}
|
|
49592
50144
|
}
|
|
49593
50145
|
function loadJson(filepath) {
|
|
49594
50146
|
try {
|
|
49595
|
-
const content =
|
|
50147
|
+
const content = fs24.readFileSync(filepath, "utf-8");
|
|
49596
50148
|
const stripped = content.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (match, comment) => comment ? "" : match).replace(/,(\s*[}\]])/g, "$1");
|
|
49597
50149
|
return JSON.parse(stripped);
|
|
49598
50150
|
} catch {
|
|
@@ -49600,14 +50152,14 @@ function loadJson(filepath) {
|
|
|
49600
50152
|
}
|
|
49601
50153
|
}
|
|
49602
50154
|
function saveJson(filepath, data) {
|
|
49603
|
-
|
|
50155
|
+
fs24.writeFileSync(filepath, `${JSON.stringify(data, null, 2)}
|
|
49604
50156
|
`, "utf-8");
|
|
49605
50157
|
}
|
|
49606
50158
|
function writeProjectConfigIfMissing(cwd) {
|
|
49607
50159
|
try {
|
|
49608
|
-
const opencodeDir =
|
|
49609
|
-
const projectConfigPath =
|
|
49610
|
-
if (
|
|
50160
|
+
const opencodeDir = path39.join(cwd, ".opencode");
|
|
50161
|
+
const projectConfigPath = path39.join(opencodeDir, "opencode-swarm.json");
|
|
50162
|
+
if (fs24.existsSync(projectConfigPath)) {
|
|
49611
50163
|
return;
|
|
49612
50164
|
}
|
|
49613
50165
|
ensureDir(opencodeDir);
|
|
@@ -49623,7 +50175,7 @@ async function install() {
|
|
|
49623
50175
|
`);
|
|
49624
50176
|
ensureDir(CONFIG_DIR);
|
|
49625
50177
|
ensureDir(PROMPTS_DIR);
|
|
49626
|
-
const LEGACY_CONFIG_PATH =
|
|
50178
|
+
const LEGACY_CONFIG_PATH = path39.join(CONFIG_DIR, "config.json");
|
|
49627
50179
|
let opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
49628
50180
|
if (!opencodeConfig) {
|
|
49629
50181
|
const legacyConfig = loadJson(LEGACY_CONFIG_PATH);
|
|
@@ -49670,7 +50222,7 @@ async function install() {
|
|
|
49670
50222
|
console.warn(`\u26A0 Could not clear opencode lock file \u2014 you may need to delete it manually:
|
|
49671
50223
|
${failed}`);
|
|
49672
50224
|
}
|
|
49673
|
-
if (!
|
|
50225
|
+
if (!fs24.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
49674
50226
|
const defaultConfig = {
|
|
49675
50227
|
agents: { ...DEFAULT_AGENT_CONFIGS },
|
|
49676
50228
|
max_iterations: 5
|
|
@@ -49749,14 +50301,14 @@ function evictPluginCaches() {
|
|
|
49749
50301
|
const cleared = [];
|
|
49750
50302
|
const failed = [];
|
|
49751
50303
|
for (const cachePath of OPENCODE_PLUGIN_CACHE_PATHS) {
|
|
49752
|
-
if (!
|
|
50304
|
+
if (!fs24.existsSync(cachePath))
|
|
49753
50305
|
continue;
|
|
49754
50306
|
if (!isSafeCachePath(cachePath)) {
|
|
49755
50307
|
failed.push(`${cachePath} (refused: failed safety check)`);
|
|
49756
50308
|
continue;
|
|
49757
50309
|
}
|
|
49758
50310
|
try {
|
|
49759
|
-
|
|
50311
|
+
fs24.rmSync(cachePath, { recursive: true, force: true });
|
|
49760
50312
|
cleared.push(cachePath);
|
|
49761
50313
|
} catch (err) {
|
|
49762
50314
|
failed.push(`${cachePath} (${err instanceof Error ? err.message : String(err)})`);
|
|
@@ -49768,14 +50320,14 @@ function evictLockFiles() {
|
|
|
49768
50320
|
const cleared = [];
|
|
49769
50321
|
const failed = [];
|
|
49770
50322
|
for (const lockPath of OPENCODE_PLUGIN_LOCK_FILE_PATHS) {
|
|
49771
|
-
if (!
|
|
50323
|
+
if (!fs24.existsSync(lockPath))
|
|
49772
50324
|
continue;
|
|
49773
50325
|
if (!isSafeLockFilePath(lockPath)) {
|
|
49774
50326
|
failed.push(`${lockPath} (refused: failed safety check)`);
|
|
49775
50327
|
continue;
|
|
49776
50328
|
}
|
|
49777
50329
|
try {
|
|
49778
|
-
|
|
50330
|
+
fs24.unlinkSync(lockPath);
|
|
49779
50331
|
cleared.push(lockPath);
|
|
49780
50332
|
} catch (err) {
|
|
49781
50333
|
const code = err?.code;
|
|
@@ -49794,7 +50346,7 @@ async function uninstall() {
|
|
|
49794
50346
|
`);
|
|
49795
50347
|
const opencodeConfig = loadJson(OPENCODE_CONFIG_PATH);
|
|
49796
50348
|
if (!opencodeConfig) {
|
|
49797
|
-
if (
|
|
50349
|
+
if (fs24.existsSync(OPENCODE_CONFIG_PATH)) {
|
|
49798
50350
|
console.log(`\u2717 Could not parse opencode config at: ${OPENCODE_CONFIG_PATH}`);
|
|
49799
50351
|
return 1;
|
|
49800
50352
|
} else {
|
|
@@ -49826,13 +50378,13 @@ async function uninstall() {
|
|
|
49826
50378
|
console.log("\u2713 Re-enabled default OpenCode agents (explore, general)");
|
|
49827
50379
|
if (process.argv.includes("--clean")) {
|
|
49828
50380
|
let cleaned = false;
|
|
49829
|
-
if (
|
|
49830
|
-
|
|
50381
|
+
if (fs24.existsSync(PLUGIN_CONFIG_PATH)) {
|
|
50382
|
+
fs24.unlinkSync(PLUGIN_CONFIG_PATH);
|
|
49831
50383
|
console.log(`\u2713 Removed plugin config: ${PLUGIN_CONFIG_PATH}`);
|
|
49832
50384
|
cleaned = true;
|
|
49833
50385
|
}
|
|
49834
|
-
if (
|
|
49835
|
-
|
|
50386
|
+
if (fs24.existsSync(PROMPTS_DIR)) {
|
|
50387
|
+
fs24.rmSync(PROMPTS_DIR, { recursive: true });
|
|
49836
50388
|
console.log(`\u2713 Removed custom prompts: ${PROMPTS_DIR}`);
|
|
49837
50389
|
cleaned = true;
|
|
49838
50390
|
}
|