opencode-swarm 7.5.1 → 7.5.3
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/dist/agents/critic.d.ts +13 -0
- package/dist/background/event-bus.d.ts +8 -0
- package/dist/background/manager.d.ts +9 -0
- package/dist/build/discovery.d.ts +7 -0
- package/dist/cli/index.js +940 -431
- package/dist/commands/registry.d.ts +16 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/schema.d.ts +10 -0
- package/dist/db/qa-gate-profile.d.ts +13 -0
- package/dist/evidence/manager.d.ts +14 -0
- package/dist/git/branch.d.ts +19 -0
- package/dist/hooks/curator-drift.d.ts +6 -0
- package/dist/hooks/curator.d.ts +13 -0
- package/dist/hooks/extractors.d.ts +11 -0
- package/dist/hooks/knowledge-curator.d.ts +6 -0
- package/dist/hooks/knowledge-migrator.d.ts +52 -1
- package/dist/hooks/knowledge-reader.d.ts +4 -0
- package/dist/hooks/knowledge-store.d.ts +21 -0
- package/dist/hooks/knowledge-validator.d.ts +6 -0
- package/dist/hooks/utils.d.ts +14 -0
- package/dist/index.js +971 -570
- package/dist/lang/detector.d.ts +4 -0
- package/dist/lang/index.d.ts +3 -2
- package/dist/lang/registry.d.ts +6 -0
- package/dist/mutation/engine.d.ts +5 -0
- package/dist/mutation/equivalence.d.ts +5 -0
- package/dist/mutation/gate.d.ts +8 -0
- package/dist/parallel/file-locks.d.ts +15 -0
- package/dist/plan/checkpoint.d.ts +4 -0
- package/dist/plan/ledger.d.ts +36 -0
- package/dist/plan/manager.d.ts +13 -0
- package/dist/sast/rules/index.d.ts +14 -0
- package/dist/sast/semgrep.d.ts +8 -0
- package/dist/services/evidence-summary-service.d.ts +51 -1
- package/dist/services/handoff-service.d.ts +68 -0
- package/dist/services/preflight-service.d.ts +67 -0
- package/dist/services/run-memory.d.ts +22 -0
- package/dist/session/snapshot-writer.d.ts +9 -0
- package/dist/state.d.ts +26 -0
- package/dist/telemetry.d.ts +12 -0
- package/dist/test-impact/analyzer.d.ts +20 -0
- package/dist/tools/co-change-analyzer.d.ts +12 -0
- package/dist/tools/knowledge-recall.d.ts +7 -0
- package/dist/tools/lint.d.ts +10 -0
- package/dist/tools/quality-budget.d.ts +7 -0
- package/dist/tools/sast-baseline.d.ts +10 -0
- package/dist/tools/sast-scan.d.ts +8 -0
- package/dist/tools/secretscan.d.ts +8 -0
- package/dist/tools/write-retro.d.ts +9 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/path-security.d.ts +10 -0
- package/dist/utils/spec-hash.d.ts +8 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var package_default;
|
|
|
33
33
|
var init_package = __esm(() => {
|
|
34
34
|
package_default = {
|
|
35
35
|
name: "opencode-swarm",
|
|
36
|
-
version: "7.5.
|
|
36
|
+
version: "7.5.3",
|
|
37
37
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
38
38
|
main: "dist/index.js",
|
|
39
39
|
types: "dist/index.d.ts",
|
|
@@ -42,7 +42,7 @@ var init_package = __esm(() => {
|
|
|
42
42
|
},
|
|
43
43
|
type: "module",
|
|
44
44
|
engines: {
|
|
45
|
-
bun: ">=1.
|
|
45
|
+
bun: ">=1.3.13"
|
|
46
46
|
},
|
|
47
47
|
license: "MIT",
|
|
48
48
|
repository: {
|
|
@@ -14902,7 +14902,7 @@ function resolveGuardrailsConfig(config2, agentName) {
|
|
|
14902
14902
|
if (!agentName) {
|
|
14903
14903
|
return config2;
|
|
14904
14904
|
}
|
|
14905
|
-
const canonicalName = stripKnownSwarmPrefix(agentName);
|
|
14905
|
+
const canonicalName = _internals.stripKnownSwarmPrefix(agentName);
|
|
14906
14906
|
const hasBuiltInProfile = canonicalName in DEFAULT_AGENT_PROFILES;
|
|
14907
14907
|
const userProfile = config2.profiles?.[agentName] ?? config2.profiles?.[canonicalName];
|
|
14908
14908
|
if (!hasBuiltInProfile) {
|
|
@@ -14919,10 +14919,11 @@ function resolveGuardrailsConfig(config2, agentName) {
|
|
|
14919
14919
|
};
|
|
14920
14920
|
return resolved;
|
|
14921
14921
|
}
|
|
14922
|
-
var KNOWN_SWARM_PREFIXES, SEPARATORS, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, CuratorConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, ParallelizationConfigSchema, PluginConfigSchema;
|
|
14922
|
+
var _internals, KNOWN_SWARM_PREFIXES, SEPARATORS, AgentOverrideConfigSchema, SwarmConfigSchema, HooksConfigSchema, ScoringWeightsSchema, DecisionDecaySchema, TokenRatiosSchema, ScoringConfigSchema, ContextBudgetConfigSchema, EvidenceConfigSchema, GateFeatureSchema, PlaceholderScanConfigSchema, QualityBudgetConfigSchema, GateConfigSchema, PipelineConfigSchema, PhaseCompleteConfigSchema, SummaryConfigSchema, ReviewPassesConfigSchema, AdversarialDetectionConfigSchema, AdversarialTestingConfigSchemaBase, AdversarialTestingConfigSchema, IntegrationAnalysisConfigSchema, DocsConfigSchema, UIReviewConfigSchema, CompactionAdvisoryConfigSchema, LintConfigSchema, SecretscanConfigSchema, GuardrailsProfileSchema, DEFAULT_AGENT_PROFILES, DEFAULT_ARCHITECT_PROFILE, GuardrailsConfigSchema, WatchdogConfigSchema, SelfReviewConfigSchema, ToolFilterConfigSchema, PlanCursorConfigSchema, CheckpointConfigSchema, AutomationModeSchema, AutomationCapabilitiesSchema, AutomationConfigSchemaBase, AutomationConfigSchema, KnowledgeConfigSchema, CuratorConfigSchema, SlopDetectorConfigSchema, IncrementalVerifyConfigSchema, CompactionConfigSchema, PrmConfigSchema, AgentAuthorityRuleSchema, AuthorityConfigSchema, GeneralCouncilMemberConfigSchema, GeneralCouncilConfigSchema, CouncilConfigSchema, ParallelizationConfigSchema, PluginConfigSchema;
|
|
14923
14923
|
var init_schema = __esm(() => {
|
|
14924
14924
|
init_zod();
|
|
14925
14925
|
init_constants();
|
|
14926
|
+
_internals = { stripKnownSwarmPrefix, resolveGuardrailsConfig };
|
|
14926
14927
|
KNOWN_SWARM_PREFIXES = [
|
|
14927
14928
|
"paid",
|
|
14928
14929
|
"local",
|
|
@@ -15944,6 +15945,7 @@ __export(exports_config, {
|
|
|
15944
15945
|
loadAgentPrompt: () => loadAgentPrompt,
|
|
15945
15946
|
isSubagent: () => isSubagent,
|
|
15946
15947
|
isQAAgent: () => isQAAgent,
|
|
15948
|
+
_internals: () => _internals2,
|
|
15947
15949
|
TestEvidenceSchema: () => TestEvidenceSchema,
|
|
15948
15950
|
TaskStatusSchema: () => TaskStatusSchema,
|
|
15949
15951
|
TaskSizeSchema: () => TaskSizeSchema,
|
|
@@ -15986,13 +15988,16 @@ __export(exports_config, {
|
|
|
15986
15988
|
ALL_SUBAGENT_NAMES: () => ALL_SUBAGENT_NAMES,
|
|
15987
15989
|
ALL_AGENT_NAMES: () => ALL_AGENT_NAMES
|
|
15988
15990
|
});
|
|
15991
|
+
var _internals2;
|
|
15989
15992
|
var init_config = __esm(() => {
|
|
15990
15993
|
init_constants();
|
|
15991
15994
|
init_evidence_schema();
|
|
15992
15995
|
init_loader();
|
|
15996
|
+
init_loader();
|
|
15993
15997
|
init_plan_schema();
|
|
15994
15998
|
init_schema();
|
|
15995
15999
|
init_spec_schema();
|
|
16000
|
+
_internals2 = { loadPluginConfigWithMeta };
|
|
15996
16001
|
});
|
|
15997
16002
|
|
|
15998
16003
|
// src/services/warning-buffer.ts
|
|
@@ -16053,6 +16058,7 @@ function error48(message, data) {
|
|
|
16053
16058
|
console.error(`[opencode-swarm ${timestamp}] ERROR: ${message}`);
|
|
16054
16059
|
}
|
|
16055
16060
|
}
|
|
16061
|
+
var init_logger = () => {};
|
|
16056
16062
|
|
|
16057
16063
|
// src/utils/regex.ts
|
|
16058
16064
|
function escapeRegex2(s) {
|
|
@@ -16066,6 +16072,7 @@ function simpleGlobToRegex(pattern, flags2 = "i") {
|
|
|
16066
16072
|
// src/utils/index.ts
|
|
16067
16073
|
var init_utils = __esm(() => {
|
|
16068
16074
|
init_errors3();
|
|
16075
|
+
init_logger();
|
|
16069
16076
|
});
|
|
16070
16077
|
|
|
16071
16078
|
// src/utils/bun-compat.ts
|
|
@@ -16418,7 +16425,7 @@ function composeHandlers(...fns) {
|
|
|
16418
16425
|
}
|
|
16419
16426
|
return async (input, output) => {
|
|
16420
16427
|
for (const fn of fns) {
|
|
16421
|
-
const safeFn = safeHook(fn);
|
|
16428
|
+
const safeFn = _internals3.safeHook(fn);
|
|
16422
16429
|
await safeFn(input, output);
|
|
16423
16430
|
}
|
|
16424
16431
|
};
|
|
@@ -16451,7 +16458,7 @@ function validateSwarmPath(directory, filename) {
|
|
|
16451
16458
|
}
|
|
16452
16459
|
async function readSwarmFileAsync(directory, filename) {
|
|
16453
16460
|
try {
|
|
16454
|
-
const resolvedPath = validateSwarmPath(directory, filename);
|
|
16461
|
+
const resolvedPath = _internals3.validateSwarmPath(directory, filename);
|
|
16455
16462
|
const file2 = bunFile(resolvedPath);
|
|
16456
16463
|
const content = await file2.text();
|
|
16457
16464
|
return content;
|
|
@@ -16465,9 +16472,11 @@ function estimateTokens(text) {
|
|
|
16465
16472
|
}
|
|
16466
16473
|
return Math.ceil(text.length * 0.33);
|
|
16467
16474
|
}
|
|
16475
|
+
var _internals3;
|
|
16468
16476
|
var init_utils2 = __esm(() => {
|
|
16469
16477
|
init_utils();
|
|
16470
16478
|
init_bun_compat();
|
|
16479
|
+
_internals3 = { safeHook, composeHandlers, validateSwarmPath, readSwarmFileAsync };
|
|
16471
16480
|
});
|
|
16472
16481
|
|
|
16473
16482
|
// src/telemetry.ts
|
|
@@ -16478,7 +16487,8 @@ __export(exports_telemetry, {
|
|
|
16478
16487
|
resetTelemetryForTesting: () => resetTelemetryForTesting,
|
|
16479
16488
|
initTelemetry: () => initTelemetry,
|
|
16480
16489
|
emit: () => emit,
|
|
16481
|
-
addTelemetryListener: () => addTelemetryListener
|
|
16490
|
+
addTelemetryListener: () => addTelemetryListener,
|
|
16491
|
+
_internals: () => _internals4
|
|
16482
16492
|
});
|
|
16483
16493
|
import * as fs3 from "node:fs";
|
|
16484
16494
|
import { createWriteStream } from "node:fs";
|
|
@@ -16565,42 +16575,47 @@ function rotateTelemetryIfNeeded(maxBytes = 10 * 1024 * 1024) {
|
|
|
16565
16575
|
}
|
|
16566
16576
|
} catch {}
|
|
16567
16577
|
}
|
|
16568
|
-
var _writeStream = null, _projectDirectory = null, _listeners, _disabled = false, telemetry;
|
|
16578
|
+
var _writeStream = null, _projectDirectory = null, _listeners, _disabled = false, telemetry, _internals4;
|
|
16569
16579
|
var init_telemetry = __esm(() => {
|
|
16570
16580
|
_listeners = [];
|
|
16571
16581
|
telemetry = {
|
|
16572
16582
|
sessionStarted(sessionId, agentName) {
|
|
16573
|
-
emit("session_started", { sessionId, agentName });
|
|
16583
|
+
_internals4.emit("session_started", { sessionId, agentName });
|
|
16574
16584
|
},
|
|
16575
16585
|
sessionEnded(sessionId, reason) {
|
|
16576
|
-
emit("session_ended", { sessionId, reason });
|
|
16586
|
+
_internals4.emit("session_ended", { sessionId, reason });
|
|
16577
16587
|
},
|
|
16578
16588
|
agentActivated(sessionId, agentName, oldName) {
|
|
16579
|
-
emit("agent_activated", { sessionId, agentName, oldName });
|
|
16589
|
+
_internals4.emit("agent_activated", { sessionId, agentName, oldName });
|
|
16580
16590
|
},
|
|
16581
16591
|
delegationBegin(sessionId, agentName, taskId) {
|
|
16582
|
-
emit("delegation_begin", { sessionId, agentName, taskId });
|
|
16592
|
+
_internals4.emit("delegation_begin", { sessionId, agentName, taskId });
|
|
16583
16593
|
},
|
|
16584
16594
|
delegationEnd(sessionId, agentName, taskId, result) {
|
|
16585
|
-
emit("delegation_end", { sessionId, agentName, taskId, result });
|
|
16595
|
+
_internals4.emit("delegation_end", { sessionId, agentName, taskId, result });
|
|
16586
16596
|
},
|
|
16587
16597
|
taskStateChanged(sessionId, taskId, newState, oldState) {
|
|
16588
|
-
emit("task_state_changed", {
|
|
16598
|
+
_internals4.emit("task_state_changed", {
|
|
16599
|
+
sessionId,
|
|
16600
|
+
taskId,
|
|
16601
|
+
newState,
|
|
16602
|
+
oldState
|
|
16603
|
+
});
|
|
16589
16604
|
},
|
|
16590
16605
|
gatePassed(sessionId, gate, taskId) {
|
|
16591
|
-
emit("gate_passed", { sessionId, gate, taskId });
|
|
16606
|
+
_internals4.emit("gate_passed", { sessionId, gate, taskId });
|
|
16592
16607
|
},
|
|
16593
16608
|
gateFailed(sessionId, gate, taskId, reason) {
|
|
16594
|
-
emit("gate_failed", { sessionId, gate, taskId, reason });
|
|
16609
|
+
_internals4.emit("gate_failed", { sessionId, gate, taskId, reason });
|
|
16595
16610
|
},
|
|
16596
16611
|
phaseChanged(sessionId, oldPhase, newPhase) {
|
|
16597
|
-
emit("phase_changed", { sessionId, oldPhase, newPhase });
|
|
16612
|
+
_internals4.emit("phase_changed", { sessionId, oldPhase, newPhase });
|
|
16598
16613
|
},
|
|
16599
16614
|
budgetUpdated(sessionId, budgetPct, agentName) {
|
|
16600
|
-
emit("budget_updated", { sessionId, budgetPct, agentName });
|
|
16615
|
+
_internals4.emit("budget_updated", { sessionId, budgetPct, agentName });
|
|
16601
16616
|
},
|
|
16602
16617
|
modelFallback(sessionId, agentName, fromModel, toModel, reason) {
|
|
16603
|
-
emit("model_fallback", {
|
|
16618
|
+
_internals4.emit("model_fallback", {
|
|
16604
16619
|
sessionId,
|
|
16605
16620
|
agentName,
|
|
16606
16621
|
fromModel,
|
|
@@ -16609,28 +16624,33 @@ var init_telemetry = __esm(() => {
|
|
|
16609
16624
|
});
|
|
16610
16625
|
},
|
|
16611
16626
|
hardLimitHit(sessionId, agentName, limitType, value) {
|
|
16612
|
-
emit("hard_limit_hit", {
|
|
16627
|
+
_internals4.emit("hard_limit_hit", {
|
|
16628
|
+
sessionId,
|
|
16629
|
+
agentName,
|
|
16630
|
+
limitType,
|
|
16631
|
+
value
|
|
16632
|
+
});
|
|
16613
16633
|
},
|
|
16614
16634
|
revisionLimitHit(sessionId, agentName) {
|
|
16615
|
-
emit("revision_limit_hit", { sessionId, agentName });
|
|
16635
|
+
_internals4.emit("revision_limit_hit", { sessionId, agentName });
|
|
16616
16636
|
},
|
|
16617
16637
|
loopDetected(sessionId, agentName, loopType) {
|
|
16618
|
-
emit("loop_detected", { sessionId, agentName, loopType });
|
|
16638
|
+
_internals4.emit("loop_detected", { sessionId, agentName, loopType });
|
|
16619
16639
|
},
|
|
16620
16640
|
scopeViolation(sessionId, agentName, file2, reason) {
|
|
16621
|
-
emit("scope_violation", { sessionId, agentName, file: file2, reason });
|
|
16641
|
+
_internals4.emit("scope_violation", { sessionId, agentName, file: file2, reason });
|
|
16622
16642
|
},
|
|
16623
16643
|
qaSkipViolation(sessionId, agentName, skipCount) {
|
|
16624
|
-
emit("qa_skip_violation", { sessionId, agentName, skipCount });
|
|
16644
|
+
_internals4.emit("qa_skip_violation", { sessionId, agentName, skipCount });
|
|
16625
16645
|
},
|
|
16626
16646
|
heartbeat(sessionId) {
|
|
16627
|
-
emit("heartbeat", { sessionId });
|
|
16647
|
+
_internals4.emit("heartbeat", { sessionId });
|
|
16628
16648
|
},
|
|
16629
16649
|
turboModeChanged(sessionId, enabled, agentName) {
|
|
16630
|
-
emit("turbo_mode_changed", { sessionId, enabled, agentName });
|
|
16650
|
+
_internals4.emit("turbo_mode_changed", { sessionId, enabled, agentName });
|
|
16631
16651
|
},
|
|
16632
16652
|
autoOversightEscalation(sessionId, reason, interactionCount, deadlockCount, phase) {
|
|
16633
|
-
emit("auto_oversight_escalation", {
|
|
16653
|
+
_internals4.emit("auto_oversight_escalation", {
|
|
16634
16654
|
sessionId,
|
|
16635
16655
|
reason,
|
|
16636
16656
|
interactionCount,
|
|
@@ -16639,7 +16659,7 @@ var init_telemetry = __esm(() => {
|
|
|
16639
16659
|
});
|
|
16640
16660
|
},
|
|
16641
16661
|
environmentDetected(sessionId, hostOS, shellFamily, executionMode) {
|
|
16642
|
-
emit("environment_detected", {
|
|
16662
|
+
_internals4.emit("environment_detected", {
|
|
16643
16663
|
sessionId,
|
|
16644
16664
|
hostOS,
|
|
16645
16665
|
shellFamily,
|
|
@@ -16647,7 +16667,7 @@ var init_telemetry = __esm(() => {
|
|
|
16647
16667
|
});
|
|
16648
16668
|
},
|
|
16649
16669
|
prmPatternDetected(sessionId, pattern, severity, category, stepRange) {
|
|
16650
|
-
emit("prm_pattern_detected", {
|
|
16670
|
+
_internals4.emit("prm_pattern_detected", {
|
|
16651
16671
|
sessionId,
|
|
16652
16672
|
pattern,
|
|
16653
16673
|
severity,
|
|
@@ -16656,10 +16676,14 @@ var init_telemetry = __esm(() => {
|
|
|
16656
16676
|
});
|
|
16657
16677
|
},
|
|
16658
16678
|
prmCourseCorrectionInjected(sessionId, pattern, level) {
|
|
16659
|
-
emit("prm_course_correction_injected", {
|
|
16679
|
+
_internals4.emit("prm_course_correction_injected", {
|
|
16680
|
+
sessionId,
|
|
16681
|
+
pattern,
|
|
16682
|
+
level
|
|
16683
|
+
});
|
|
16660
16684
|
},
|
|
16661
16685
|
prmEscalationTriggered(sessionId, pattern, level, occurrenceCount) {
|
|
16662
|
-
emit("prm_escalation_triggered", {
|
|
16686
|
+
_internals4.emit("prm_escalation_triggered", {
|
|
16663
16687
|
sessionId,
|
|
16664
16688
|
pattern,
|
|
16665
16689
|
level,
|
|
@@ -16667,9 +16691,15 @@ var init_telemetry = __esm(() => {
|
|
|
16667
16691
|
});
|
|
16668
16692
|
},
|
|
16669
16693
|
prmHardStop(sessionId, pattern, level, occurrenceCount) {
|
|
16670
|
-
emit("prm_hard_stop", {
|
|
16694
|
+
_internals4.emit("prm_hard_stop", {
|
|
16695
|
+
sessionId,
|
|
16696
|
+
pattern,
|
|
16697
|
+
level,
|
|
16698
|
+
occurrenceCount
|
|
16699
|
+
});
|
|
16671
16700
|
}
|
|
16672
16701
|
};
|
|
16702
|
+
_internals4 = { telemetry, emit };
|
|
16673
16703
|
});
|
|
16674
16704
|
|
|
16675
16705
|
// src/utils/spec-hash.ts
|
|
@@ -16690,7 +16720,7 @@ async function computeSpecHash(directory) {
|
|
|
16690
16720
|
return hash2;
|
|
16691
16721
|
}
|
|
16692
16722
|
async function isSpecStale(directory, plan) {
|
|
16693
|
-
const currentHash = await computeSpecHash(directory);
|
|
16723
|
+
const currentHash = await _internals5.computeSpecHash(directory);
|
|
16694
16724
|
if (!plan.specHash) {
|
|
16695
16725
|
return { stale: false };
|
|
16696
16726
|
}
|
|
@@ -16710,7 +16740,13 @@ async function isSpecStale(directory, plan) {
|
|
|
16710
16740
|
}
|
|
16711
16741
|
return { stale: false };
|
|
16712
16742
|
}
|
|
16713
|
-
var
|
|
16743
|
+
var _internals5;
|
|
16744
|
+
var init_spec_hash = __esm(() => {
|
|
16745
|
+
_internals5 = {
|
|
16746
|
+
computeSpecHash,
|
|
16747
|
+
isSpecStale
|
|
16748
|
+
};
|
|
16749
|
+
});
|
|
16714
16750
|
|
|
16715
16751
|
// src/plan/ledger.ts
|
|
16716
16752
|
import * as crypto2 from "node:crypto";
|
|
@@ -17284,7 +17320,7 @@ async function loadPlan(directory) {
|
|
|
17284
17320
|
const inSync = await isPlanMdInSync(directory, validated);
|
|
17285
17321
|
if (!inSync) {
|
|
17286
17322
|
try {
|
|
17287
|
-
await regeneratePlanMarkdown(directory, validated);
|
|
17323
|
+
await _internals6.regeneratePlanMarkdown(directory, validated);
|
|
17288
17324
|
} catch (regenError) {
|
|
17289
17325
|
warn(`Failed to regenerate plan.md: ${regenError instanceof Error ? regenError.message : String(regenError)}. Proceeding with plan.json only.`);
|
|
17290
17326
|
}
|
|
@@ -17417,7 +17453,7 @@ async function loadPlan(directory) {
|
|
|
17417
17453
|
const existingMutex = recoveryMutexes.get(resolvedDir);
|
|
17418
17454
|
if (existingMutex) {
|
|
17419
17455
|
await existingMutex;
|
|
17420
|
-
const postRecoveryPlan = await loadPlanJsonOnly(directory);
|
|
17456
|
+
const postRecoveryPlan = await _internals6.loadPlanJsonOnly(directory);
|
|
17421
17457
|
if (postRecoveryPlan)
|
|
17422
17458
|
return postRecoveryPlan;
|
|
17423
17459
|
}
|
|
@@ -17471,7 +17507,7 @@ async function savePlan(directory, plan, options) {
|
|
|
17471
17507
|
const validated = PlanSchema.parse(plan);
|
|
17472
17508
|
if (options?.preserveCompletedStatuses !== false) {
|
|
17473
17509
|
try {
|
|
17474
|
-
const currentPlan2 = await loadPlanJsonOnly(directory);
|
|
17510
|
+
const currentPlan2 = await _internals6.loadPlanJsonOnly(directory);
|
|
17475
17511
|
if (currentPlan2) {
|
|
17476
17512
|
const completedTaskIds = new Set;
|
|
17477
17513
|
for (const phase of currentPlan2.phases) {
|
|
@@ -17504,7 +17540,7 @@ async function savePlan(directory, plan, options) {
|
|
|
17504
17540
|
phase.status = "pending";
|
|
17505
17541
|
}
|
|
17506
17542
|
}
|
|
17507
|
-
const currentPlan = await loadPlanJsonOnly(directory);
|
|
17543
|
+
const currentPlan = await _internals6.loadPlanJsonOnly(directory);
|
|
17508
17544
|
const planId = `${validated.swarm}-${validated.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
17509
17545
|
const planHashForInit = computePlanHash(validated);
|
|
17510
17546
|
if (!await ledgerExists(directory)) {
|
|
@@ -17620,7 +17656,7 @@ async function savePlan(directory, plan, options) {
|
|
|
17620
17656
|
expectedHash: currentHash,
|
|
17621
17657
|
planHashAfter: hashAfter,
|
|
17622
17658
|
verifyValid: async () => {
|
|
17623
|
-
const onDisk = await loadPlanJsonOnly(directory);
|
|
17659
|
+
const onDisk = await _internals6.loadPlanJsonOnly(directory);
|
|
17624
17660
|
if (!onDisk)
|
|
17625
17661
|
return true;
|
|
17626
17662
|
for (const p of onDisk.phases) {
|
|
@@ -17747,7 +17783,7 @@ async function updateTaskStatus(directory, taskId, status) {
|
|
|
17747
17783
|
};
|
|
17748
17784
|
const MAX_OUTER_RETRIES = 1;
|
|
17749
17785
|
for (let attempt = 0;attempt <= MAX_OUTER_RETRIES; attempt++) {
|
|
17750
|
-
const plan = await loadPlan(directory);
|
|
17786
|
+
const plan = await _internals6.loadPlan(directory);
|
|
17751
17787
|
if (plan === null) {
|
|
17752
17788
|
throw new Error(`Plan not found in directory: ${directory}`);
|
|
17753
17789
|
}
|
|
@@ -18052,7 +18088,7 @@ function migrateLegacyPlan(planContent, swarmId) {
|
|
|
18052
18088
|
};
|
|
18053
18089
|
return plan;
|
|
18054
18090
|
}
|
|
18055
|
-
var PlanConcurrentModificationError, startupLedgerCheckedWorkspaces, recoveryMutexes, CAS_BACKOFF_START_MS = 5, CAS_BACKOFF_CAP_MS = 250, CAS_BACKOFF_JITTER = 0.25, CAS_MAX_RETRIES = 3;
|
|
18091
|
+
var PlanConcurrentModificationError, startupLedgerCheckedWorkspaces, recoveryMutexes, _internals6, CAS_BACKOFF_START_MS = 5, CAS_BACKOFF_CAP_MS = 250, CAS_BACKOFF_JITTER = 0.25, CAS_MAX_RETRIES = 3;
|
|
18056
18092
|
var init_manager = __esm(() => {
|
|
18057
18093
|
init_plan_schema();
|
|
18058
18094
|
init_utils2();
|
|
@@ -18069,6 +18105,11 @@ var init_manager = __esm(() => {
|
|
|
18069
18105
|
};
|
|
18070
18106
|
startupLedgerCheckedWorkspaces = new Set;
|
|
18071
18107
|
recoveryMutexes = new Map;
|
|
18108
|
+
_internals6 = {
|
|
18109
|
+
loadPlan,
|
|
18110
|
+
loadPlanJsonOnly,
|
|
18111
|
+
regeneratePlanMarkdown
|
|
18112
|
+
};
|
|
18072
18113
|
});
|
|
18073
18114
|
|
|
18074
18115
|
// src/commands/acknowledge-spec-drift.ts
|
|
@@ -20034,7 +20075,7 @@ async function loadEvidence(directory, taskId) {
|
|
|
20034
20075
|
return { status: "invalid_schema", errors: ["Invalid JSON"] };
|
|
20035
20076
|
}
|
|
20036
20077
|
if (isFlatRetrospective(parsed)) {
|
|
20037
|
-
const wrappedBundle = wrapFlatRetrospective(parsed, sanitizedTaskId);
|
|
20078
|
+
const wrappedBundle = _internals7.wrapFlatRetrospective(parsed, sanitizedTaskId);
|
|
20038
20079
|
try {
|
|
20039
20080
|
const validated = EvidenceBundleSchema.parse(wrappedBundle);
|
|
20040
20081
|
try {
|
|
@@ -20130,14 +20171,14 @@ async function checkRequirementCoverage(phase, directory) {
|
|
|
20130
20171
|
}
|
|
20131
20172
|
}
|
|
20132
20173
|
async function archiveEvidence(directory, maxAgeDays, maxBundles) {
|
|
20133
|
-
const taskIds = await listEvidenceTaskIds(directory);
|
|
20174
|
+
const taskIds = await _internals7.listEvidenceTaskIds(directory);
|
|
20134
20175
|
const cutoffDate = new Date;
|
|
20135
20176
|
cutoffDate.setDate(cutoffDate.getDate() - maxAgeDays);
|
|
20136
20177
|
const cutoffIso = cutoffDate.toISOString();
|
|
20137
20178
|
const archived = [];
|
|
20138
20179
|
const remainingBundles = [];
|
|
20139
20180
|
for (const taskId of taskIds) {
|
|
20140
|
-
const result = await loadEvidence(directory, taskId);
|
|
20181
|
+
const result = await _internals7.loadEvidence(directory, taskId);
|
|
20141
20182
|
if (result.status !== "found") {
|
|
20142
20183
|
continue;
|
|
20143
20184
|
}
|
|
@@ -20165,7 +20206,7 @@ async function archiveEvidence(directory, maxAgeDays, maxBundles) {
|
|
|
20165
20206
|
}
|
|
20166
20207
|
return archived;
|
|
20167
20208
|
}
|
|
20168
|
-
var VALID_EVIDENCE_TYPES, sanitizeTaskId2, LEGACY_TASK_COMPLEXITY_MAP;
|
|
20209
|
+
var VALID_EVIDENCE_TYPES, sanitizeTaskId2, LEGACY_TASK_COMPLEXITY_MAP, _internals7;
|
|
20169
20210
|
var init_manager2 = __esm(() => {
|
|
20170
20211
|
init_zod();
|
|
20171
20212
|
init_evidence_schema();
|
|
@@ -20195,6 +20236,11 @@ var init_manager2 = __esm(() => {
|
|
|
20195
20236
|
medium: "moderate",
|
|
20196
20237
|
high: "complex"
|
|
20197
20238
|
};
|
|
20239
|
+
_internals7 = {
|
|
20240
|
+
wrapFlatRetrospective,
|
|
20241
|
+
loadEvidence,
|
|
20242
|
+
listEvidenceTaskIds
|
|
20243
|
+
};
|
|
20198
20244
|
});
|
|
20199
20245
|
|
|
20200
20246
|
// src/commands/archive.ts
|
|
@@ -20394,7 +20440,7 @@ function getProfile(directory, planId) {
|
|
|
20394
20440
|
return row ? rowToProfile(row) : null;
|
|
20395
20441
|
}
|
|
20396
20442
|
function getOrCreateProfile(directory, planId, projectType) {
|
|
20397
|
-
const existing = getProfile(directory, planId);
|
|
20443
|
+
const existing = _internals8.getProfile(directory, planId);
|
|
20398
20444
|
if (existing)
|
|
20399
20445
|
return existing;
|
|
20400
20446
|
const db = getProjectDb(directory);
|
|
@@ -20410,14 +20456,14 @@ function getOrCreateProfile(directory, planId, projectType) {
|
|
|
20410
20456
|
throw err2;
|
|
20411
20457
|
}
|
|
20412
20458
|
}
|
|
20413
|
-
const after = getProfile(directory, planId);
|
|
20459
|
+
const after = _internals8.getProfile(directory, planId);
|
|
20414
20460
|
if (!after) {
|
|
20415
20461
|
throw new Error(`Failed to create or load QA gate profile for plan_id=${planId}`);
|
|
20416
20462
|
}
|
|
20417
20463
|
return after;
|
|
20418
20464
|
}
|
|
20419
20465
|
function setGates(directory, planId, gates) {
|
|
20420
|
-
const current = getProfile(directory, planId);
|
|
20466
|
+
const current = _internals8.getProfile(directory, planId);
|
|
20421
20467
|
if (!current) {
|
|
20422
20468
|
throw new Error(`No QA gate profile found for plan_id=${planId} — call getOrCreateProfile first`);
|
|
20423
20469
|
}
|
|
@@ -20441,14 +20487,14 @@ function setGates(directory, planId, gates) {
|
|
|
20441
20487
|
JSON.stringify(merged),
|
|
20442
20488
|
planId
|
|
20443
20489
|
]);
|
|
20444
|
-
const updated = getProfile(directory, planId);
|
|
20490
|
+
const updated = _internals8.getProfile(directory, planId);
|
|
20445
20491
|
if (!updated) {
|
|
20446
20492
|
throw new Error(`Failed to re-read QA gate profile after update for plan_id=${planId}`);
|
|
20447
20493
|
}
|
|
20448
20494
|
return updated;
|
|
20449
20495
|
}
|
|
20450
20496
|
function lockProfile(directory, planId, snapshotSeq) {
|
|
20451
|
-
const current = getProfile(directory, planId);
|
|
20497
|
+
const current = _internals8.getProfile(directory, planId);
|
|
20452
20498
|
if (!current) {
|
|
20453
20499
|
throw new Error(`No QA gate profile found for plan_id=${planId} — cannot lock`);
|
|
20454
20500
|
}
|
|
@@ -20457,7 +20503,7 @@ function lockProfile(directory, planId, snapshotSeq) {
|
|
|
20457
20503
|
}
|
|
20458
20504
|
const db = getProjectDb(directory);
|
|
20459
20505
|
db.run("UPDATE qa_gate_profile SET locked_at = datetime('now'), locked_by_snapshot_seq = ? WHERE plan_id = ?", [snapshotSeq, planId]);
|
|
20460
|
-
const locked = getProfile(directory, planId);
|
|
20506
|
+
const locked = _internals8.getProfile(directory, planId);
|
|
20461
20507
|
if (!locked) {
|
|
20462
20508
|
throw new Error(`Failed to re-read locked QA gate profile for plan_id=${planId}`);
|
|
20463
20509
|
}
|
|
@@ -20479,9 +20525,16 @@ function getEffectiveGates(profile, sessionOverrides) {
|
|
|
20479
20525
|
}
|
|
20480
20526
|
return merged;
|
|
20481
20527
|
}
|
|
20482
|
-
var DEFAULT_QA_GATES;
|
|
20528
|
+
var _internals8, DEFAULT_QA_GATES;
|
|
20483
20529
|
var init_qa_gate_profile = __esm(() => {
|
|
20484
20530
|
init_project_db();
|
|
20531
|
+
_internals8 = {
|
|
20532
|
+
getProfile,
|
|
20533
|
+
getOrCreateProfile,
|
|
20534
|
+
setGates,
|
|
20535
|
+
getEffectiveGates,
|
|
20536
|
+
computeProfileHash
|
|
20537
|
+
};
|
|
20485
20538
|
DEFAULT_QA_GATES = {
|
|
20486
20539
|
reviewer: true,
|
|
20487
20540
|
test_engineer: true,
|
|
@@ -23302,6 +23355,7 @@ No plan content available. Start by creating a .swarm/plan.md file.
|
|
|
23302
23355
|
}
|
|
23303
23356
|
return output;
|
|
23304
23357
|
}
|
|
23358
|
+
var init_extractors = () => {};
|
|
23305
23359
|
|
|
23306
23360
|
// src/hooks/loop-detector.ts
|
|
23307
23361
|
function hashDelegation(toolName, args2) {
|
|
@@ -25286,8 +25340,10 @@ var init_guardrails = __esm(() => {
|
|
|
25286
25340
|
init_telemetry();
|
|
25287
25341
|
init_utils();
|
|
25288
25342
|
init_bun_compat();
|
|
25343
|
+
init_logger();
|
|
25289
25344
|
init_conflict_resolution();
|
|
25290
25345
|
init_delegation_gate();
|
|
25346
|
+
init_extractors();
|
|
25291
25347
|
init_loop_detector();
|
|
25292
25348
|
init_model_limits();
|
|
25293
25349
|
init_normalize_tool_name();
|
|
@@ -26262,6 +26318,7 @@ var init_delegation_gate = __esm(() => {
|
|
|
26262
26318
|
init_schema();
|
|
26263
26319
|
init_state();
|
|
26264
26320
|
init_telemetry();
|
|
26321
|
+
init_logger();
|
|
26265
26322
|
init_guardrails();
|
|
26266
26323
|
init_normalize_tool_name();
|
|
26267
26324
|
init_utils2();
|
|
@@ -26319,6 +26376,7 @@ __export(exports_state, {
|
|
|
26319
26376
|
advanceTaskStateAndPersist: () => advanceTaskStateAndPersist,
|
|
26320
26377
|
advanceTaskState: () => advanceTaskState,
|
|
26321
26378
|
_resetCouncilDisagreementWarnings: () => _resetCouncilDisagreementWarnings,
|
|
26379
|
+
_internals: () => _internals9,
|
|
26322
26380
|
AgentRunContext: () => AgentRunContext
|
|
26323
26381
|
});
|
|
26324
26382
|
import * as fs10 from "node:fs/promises";
|
|
@@ -26412,10 +26470,10 @@ function startAgentSession(sessionId, agentName, staleDurationMs = 7200000, dire
|
|
|
26412
26470
|
swarmState.agentSessions.set(sessionId, sessionState);
|
|
26413
26471
|
telemetry.sessionStarted(sessionId, agentName);
|
|
26414
26472
|
swarmState.activeAgent.set(sessionId, agentName);
|
|
26415
|
-
applyRehydrationCache(sessionState);
|
|
26473
|
+
_internals9.applyRehydrationCache(sessionState);
|
|
26416
26474
|
if (directory) {
|
|
26417
26475
|
let rehydrationPromise;
|
|
26418
|
-
rehydrationPromise = rehydrateSessionFromDisk(directory, sessionState).catch((err2) => {
|
|
26476
|
+
rehydrationPromise = _internals9.rehydrateSessionFromDisk(directory, sessionState).catch((err2) => {
|
|
26419
26477
|
console.warn("[state] Rehydration failed:", err2 instanceof Error ? err2.message : String(err2));
|
|
26420
26478
|
}).finally(() => {
|
|
26421
26479
|
swarmState.pendingRehydrations.delete(rehydrationPromise);
|
|
@@ -26570,7 +26628,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
|
|
|
26570
26628
|
session.lastToolCallTime = now;
|
|
26571
26629
|
return session;
|
|
26572
26630
|
}
|
|
26573
|
-
startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
|
|
26631
|
+
_internals9.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
|
|
26574
26632
|
session = swarmState.agentSessions.get(sessionId);
|
|
26575
26633
|
if (!session) {
|
|
26576
26634
|
throw new Error(`Failed to create guardrail session for ${sessionId}`);
|
|
@@ -26927,8 +26985,8 @@ function applyRehydrationCache(session) {
|
|
|
26927
26985
|
}
|
|
26928
26986
|
}
|
|
26929
26987
|
async function rehydrateSessionFromDisk(directory, session) {
|
|
26930
|
-
await buildRehydrationCache(directory);
|
|
26931
|
-
applyRehydrationCache(session);
|
|
26988
|
+
await _internals9.buildRehydrationCache(directory);
|
|
26989
|
+
_internals9.applyRehydrationCache(session);
|
|
26932
26990
|
}
|
|
26933
26991
|
function hasActiveTurboMode(sessionID) {
|
|
26934
26992
|
if (sessionID) {
|
|
@@ -26971,7 +27029,7 @@ function ensureSessionEnvironment(sessionId) {
|
|
|
26971
27029
|
}).catch(() => {});
|
|
26972
27030
|
return profile;
|
|
26973
27031
|
}
|
|
26974
|
-
var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState;
|
|
27032
|
+
var _rehydrationCache = null, _councilDisagreementWarned, _toolAggregates, defaultRunContext, _runContexts, swarmState, _internals9;
|
|
26975
27033
|
var init_state = __esm(() => {
|
|
26976
27034
|
init_constants();
|
|
26977
27035
|
init_plan_schema();
|
|
@@ -26999,6 +27057,24 @@ var init_state = __esm(() => {
|
|
|
26999
27057
|
fullAutoEnabledInConfig: false,
|
|
27000
27058
|
environmentProfiles: defaultRunContext.environmentProfiles
|
|
27001
27059
|
};
|
|
27060
|
+
_internals9 = {
|
|
27061
|
+
swarmState,
|
|
27062
|
+
resetSwarmState,
|
|
27063
|
+
ensureAgentSession,
|
|
27064
|
+
startAgentSession,
|
|
27065
|
+
getAgentSession,
|
|
27066
|
+
beginInvocation,
|
|
27067
|
+
getActiveWindow,
|
|
27068
|
+
advanceTaskState,
|
|
27069
|
+
getTaskState,
|
|
27070
|
+
hasActiveFullAuto,
|
|
27071
|
+
hasActiveTurboMode,
|
|
27072
|
+
buildRehydrationCache,
|
|
27073
|
+
applyRehydrationCache,
|
|
27074
|
+
rehydrateSessionFromDisk,
|
|
27075
|
+
isCouncilGateActive,
|
|
27076
|
+
defaultRunContext
|
|
27077
|
+
};
|
|
27002
27078
|
});
|
|
27003
27079
|
|
|
27004
27080
|
// src/commands/benchmark.ts
|
|
@@ -40536,6 +40612,19 @@ function getCurrentBranch(cwd) {
|
|
|
40536
40612
|
const output = gitExec2(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
40537
40613
|
return output.trim();
|
|
40538
40614
|
}
|
|
40615
|
+
function getDefaultBaseBranch(cwd) {
|
|
40616
|
+
try {
|
|
40617
|
+
gitExec2(["rev-parse", "--verify", "origin/main"], cwd);
|
|
40618
|
+
return "origin/main";
|
|
40619
|
+
} catch {
|
|
40620
|
+
try {
|
|
40621
|
+
gitExec2(["rev-parse", "--verify", "origin/master"], cwd);
|
|
40622
|
+
return "origin/master";
|
|
40623
|
+
} catch {
|
|
40624
|
+
return "origin/main";
|
|
40625
|
+
}
|
|
40626
|
+
}
|
|
40627
|
+
}
|
|
40539
40628
|
function hasUncommittedChanges(cwd) {
|
|
40540
40629
|
const status = gitExec2(["status", "--porcelain"], cwd);
|
|
40541
40630
|
return status.trim().length > 0;
|
|
@@ -40571,7 +40660,7 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
40571
40660
|
const prunedBranches = [];
|
|
40572
40661
|
try {
|
|
40573
40662
|
const currentBranch = getCurrentBranch(cwd);
|
|
40574
|
-
const defaultRemoteBranch = detectDefaultRemoteBranch(cwd);
|
|
40663
|
+
const defaultRemoteBranch = _internals10.detectDefaultRemoteBranch(cwd);
|
|
40575
40664
|
if (!defaultRemoteBranch) {
|
|
40576
40665
|
return {
|
|
40577
40666
|
success: false,
|
|
@@ -40750,8 +40839,16 @@ function resetToRemoteBranch(cwd, options) {
|
|
|
40750
40839
|
};
|
|
40751
40840
|
}
|
|
40752
40841
|
}
|
|
40753
|
-
var GIT_TIMEOUT_MS2 = 30000;
|
|
40754
|
-
var init_branch = () => {
|
|
40842
|
+
var GIT_TIMEOUT_MS2 = 30000, _internals10;
|
|
40843
|
+
var init_branch = __esm(() => {
|
|
40844
|
+
init_logger();
|
|
40845
|
+
_internals10 = {
|
|
40846
|
+
gitExec: gitExec2,
|
|
40847
|
+
detectDefaultRemoteBranch,
|
|
40848
|
+
getDefaultBaseBranch,
|
|
40849
|
+
resetToRemoteBranch
|
|
40850
|
+
};
|
|
40851
|
+
});
|
|
40755
40852
|
|
|
40756
40853
|
// src/hooks/knowledge-store.ts
|
|
40757
40854
|
import { existsSync as existsSync9 } from "node:fs";
|
|
@@ -41233,6 +41330,7 @@ async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
|
|
|
41233
41330
|
}
|
|
41234
41331
|
var JACCARD_THRESHOLD = 0.6, HIVE_TIER_BOOST = 0.05, SAME_PROJECT_PENALTY = -0.05;
|
|
41235
41332
|
var init_knowledge_reader = __esm(() => {
|
|
41333
|
+
init_logger();
|
|
41236
41334
|
init_knowledge_store();
|
|
41237
41335
|
});
|
|
41238
41336
|
|
|
@@ -41489,6 +41587,7 @@ async function restoreEntry(directory, entryId) {
|
|
|
41489
41587
|
}
|
|
41490
41588
|
var import_proper_lockfile4, DANGEROUS_COMMAND_PATTERNS, SECURITY_DEGRADING_PATTERNS, INVISIBLE_FORMAT_CHARS, INJECTION_PATTERNS, VALID_CATEGORIES, TECH_REFERENCE_WORDS, ACTION_VERB_WORDS, NEGATION_PAIRS;
|
|
41491
41589
|
var init_knowledge_validator = __esm(() => {
|
|
41590
|
+
init_logger();
|
|
41492
41591
|
init_knowledge_store();
|
|
41493
41592
|
import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
|
|
41494
41593
|
DANGEROUS_COMMAND_PATTERNS = [
|
|
@@ -41805,7 +41904,7 @@ async function curateAndStoreSwarm(lessons, projectName, phaseInfo, directory, c
|
|
|
41805
41904
|
existingEntries.push(entry);
|
|
41806
41905
|
}
|
|
41807
41906
|
await enforceKnowledgeCap(knowledgePath, config3.swarm_max_entries);
|
|
41808
|
-
await runAutoPromotion(directory, config3);
|
|
41907
|
+
await _internals11.runAutoPromotion(directory, config3);
|
|
41809
41908
|
return { stored, skipped, rejected };
|
|
41810
41909
|
}
|
|
41811
41910
|
async function runAutoPromotion(directory, config3) {
|
|
@@ -41886,7 +41985,7 @@ function createKnowledgeCuratorHook(directory, config3) {
|
|
|
41886
41985
|
});
|
|
41887
41986
|
const projectName2 = evidenceData.project_name ?? "unknown";
|
|
41888
41987
|
const phaseNumber2 = typeof evidenceData.phase_number === "number" ? evidenceData.phase_number : 1;
|
|
41889
|
-
await curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
|
|
41988
|
+
await _internals11.curateAndStoreSwarm(lessons, projectName2, { phase_number: phaseNumber2 }, directory, config3);
|
|
41890
41989
|
await updateRetrievalOutcome(directory, `Phase ${phaseNumber2}`, true);
|
|
41891
41990
|
return;
|
|
41892
41991
|
}
|
|
@@ -41909,18 +42008,24 @@ function createKnowledgeCuratorHook(directory, config3) {
|
|
|
41909
42008
|
const projectName = projectNameMatch ? projectNameMatch[1].trim() : "unknown";
|
|
41910
42009
|
const phaseMatch = /^Phase:\s*(\d+)/m.exec(planContent);
|
|
41911
42010
|
const phaseNumber = phaseMatch ? parseInt(phaseMatch[1], 10) : 1;
|
|
41912
|
-
await curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
|
|
42011
|
+
await _internals11.curateAndStoreSwarm(normalLessons, projectName, { phase_number: phaseNumber }, directory, config3);
|
|
41913
42012
|
await updateRetrievalOutcome(directory, `Phase ${phaseNumber}`, true);
|
|
41914
42013
|
};
|
|
41915
42014
|
return safeHook(handler);
|
|
41916
42015
|
}
|
|
41917
|
-
var seenRetroSections;
|
|
42016
|
+
var seenRetroSections, _internals11;
|
|
41918
42017
|
var init_knowledge_curator = __esm(() => {
|
|
41919
42018
|
init_knowledge_reader();
|
|
41920
42019
|
init_knowledge_store();
|
|
41921
42020
|
init_knowledge_validator();
|
|
41922
42021
|
init_utils2();
|
|
41923
42022
|
seenRetroSections = new Map;
|
|
42023
|
+
_internals11 = {
|
|
42024
|
+
isWriteToEvidenceFile,
|
|
42025
|
+
curateAndStoreSwarm,
|
|
42026
|
+
runAutoPromotion,
|
|
42027
|
+
createKnowledgeCuratorHook
|
|
42028
|
+
};
|
|
41924
42029
|
});
|
|
41925
42030
|
|
|
41926
42031
|
// src/session/snapshot-writer.ts
|
|
@@ -42028,21 +42133,26 @@ async function writeSnapshot(directory, state) {
|
|
|
42028
42133
|
}
|
|
42029
42134
|
function createSnapshotWriterHook(directory) {
|
|
42030
42135
|
return (_input, _output) => {
|
|
42031
|
-
_writeInFlight = _writeInFlight.then(() => writeSnapshot(directory, swarmState), () => writeSnapshot(directory, swarmState));
|
|
42136
|
+
_writeInFlight = _writeInFlight.then(() => _internals12.writeSnapshot(directory, swarmState), () => _internals12.writeSnapshot(directory, swarmState));
|
|
42032
42137
|
return _writeInFlight;
|
|
42033
42138
|
};
|
|
42034
42139
|
}
|
|
42035
42140
|
async function flushPendingSnapshot(directory) {
|
|
42036
|
-
_writeInFlight = _writeInFlight.then(() => writeSnapshot(directory, swarmState), () => writeSnapshot(directory, swarmState));
|
|
42141
|
+
_writeInFlight = _writeInFlight.then(() => _internals12.writeSnapshot(directory, swarmState), () => _internals12.writeSnapshot(directory, swarmState));
|
|
42037
42142
|
await _writeInFlight;
|
|
42038
42143
|
}
|
|
42039
|
-
var _writeInFlight;
|
|
42144
|
+
var _writeInFlight, _internals12;
|
|
42040
42145
|
var init_snapshot_writer = __esm(() => {
|
|
42041
42146
|
init_utils2();
|
|
42042
42147
|
init_state();
|
|
42043
42148
|
init_utils();
|
|
42044
42149
|
init_bun_compat();
|
|
42045
42150
|
_writeInFlight = Promise.resolve();
|
|
42151
|
+
_internals12 = {
|
|
42152
|
+
writeSnapshot,
|
|
42153
|
+
createSnapshotWriterHook,
|
|
42154
|
+
flushPendingSnapshot
|
|
42155
|
+
};
|
|
42046
42156
|
});
|
|
42047
42157
|
|
|
42048
42158
|
// src/tools/write-retro.ts
|
|
@@ -42346,7 +42456,7 @@ async function executeWriteRetro(args2, directory) {
|
|
|
42346
42456
|
}, null, 2);
|
|
42347
42457
|
}
|
|
42348
42458
|
}
|
|
42349
|
-
var write_retro;
|
|
42459
|
+
var write_retro, _internals13;
|
|
42350
42460
|
var init_write_retro = __esm(() => {
|
|
42351
42461
|
init_zod();
|
|
42352
42462
|
init_evidence_schema();
|
|
@@ -42393,12 +42503,16 @@ var init_write_retro = __esm(() => {
|
|
|
42393
42503
|
task_id: args2.task_id !== undefined ? String(args2.task_id) : undefined,
|
|
42394
42504
|
metadata: args2.metadata
|
|
42395
42505
|
};
|
|
42396
|
-
return await executeWriteRetro(writeRetroArgs, directory);
|
|
42506
|
+
return await _internals13.executeWriteRetro(writeRetroArgs, directory);
|
|
42397
42507
|
} catch {
|
|
42398
42508
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
42399
42509
|
}
|
|
42400
42510
|
}
|
|
42401
42511
|
});
|
|
42512
|
+
_internals13 = {
|
|
42513
|
+
executeWriteRetro,
|
|
42514
|
+
write_retro
|
|
42515
|
+
};
|
|
42402
42516
|
});
|
|
42403
42517
|
|
|
42404
42518
|
// src/commands/close.ts
|
|
@@ -43450,8 +43564,8 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
43450
43564
|
const observations = [];
|
|
43451
43565
|
const timestamp = new Date().toISOString();
|
|
43452
43566
|
for (const agent of requiredAgents) {
|
|
43453
|
-
const normalizedAgent = normalizeAgentName(agent);
|
|
43454
|
-
const isDispatched = agentsDispatched.some((a) => normalizeAgentName(a) === normalizedAgent);
|
|
43567
|
+
const normalizedAgent = _internals14.normalizeAgentName(agent);
|
|
43568
|
+
const isDispatched = agentsDispatched.some((a) => _internals14.normalizeAgentName(a) === normalizedAgent);
|
|
43455
43569
|
if (!isDispatched) {
|
|
43456
43570
|
observations.push({
|
|
43457
43571
|
phase,
|
|
@@ -43470,7 +43584,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
43470
43584
|
if (e.type === "agent.delegation") {
|
|
43471
43585
|
const agent = e.agent;
|
|
43472
43586
|
if (agent && typeof agent === "string") {
|
|
43473
|
-
const normalized = normalizeAgentName(agent);
|
|
43587
|
+
const normalized = _internals14.normalizeAgentName(agent);
|
|
43474
43588
|
if (normalized === "coder") {
|
|
43475
43589
|
coderDelegations.push({ event: e, index: i2 });
|
|
43476
43590
|
} else if (normalized === "reviewer") {
|
|
@@ -43527,7 +43641,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
43527
43641
|
if (e.type === "agent.delegation" && e.agent) {
|
|
43528
43642
|
const agent = e.agent;
|
|
43529
43643
|
if (agent && typeof agent === "string") {
|
|
43530
|
-
const normalized = normalizeAgentName(agent);
|
|
43644
|
+
const normalized = _internals14.normalizeAgentName(agent);
|
|
43531
43645
|
if (normalized === "sme") {
|
|
43532
43646
|
smeDelegations.push({ event: e, index: i2 });
|
|
43533
43647
|
}
|
|
@@ -43551,7 +43665,7 @@ function checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, pha
|
|
|
43551
43665
|
}
|
|
43552
43666
|
async function runCuratorInit(directory, config3, llmDelegate) {
|
|
43553
43667
|
try {
|
|
43554
|
-
const priorSummary = await readCuratorSummary(directory);
|
|
43668
|
+
const priorSummary = await _internals14.readCuratorSummary(directory);
|
|
43555
43669
|
const knowledgePath = resolveSwarmKnowledgePath(directory);
|
|
43556
43670
|
const allEntries = await readKnowledge(knowledgePath);
|
|
43557
43671
|
const highConfidenceEntries = allEntries.filter((e) => typeof e.confidence === "number" && e.confidence >= config3.min_knowledge_confidence);
|
|
@@ -43670,7 +43784,7 @@ Could not load prior session context.`,
|
|
|
43670
43784
|
}
|
|
43671
43785
|
async function runCuratorPhase(directory, phase, agentsDispatched, config3, _knowledgeConfig, llmDelegate) {
|
|
43672
43786
|
try {
|
|
43673
|
-
const priorSummary = await readCuratorSummary(directory);
|
|
43787
|
+
const priorSummary = await _internals14.readCuratorSummary(directory);
|
|
43674
43788
|
if (priorSummary?.phase_digests.some((d) => d.phase === phase)) {
|
|
43675
43789
|
const existingDigest = priorSummary.phase_digests.find((d) => d.phase === phase);
|
|
43676
43790
|
return {
|
|
@@ -43682,10 +43796,10 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
43682
43796
|
};
|
|
43683
43797
|
}
|
|
43684
43798
|
const eventsJsonlContent = await readSwarmFileAsync(directory, "events.jsonl");
|
|
43685
|
-
const phaseEvents = eventsJsonlContent ? filterPhaseEvents(eventsJsonlContent, phase) : [];
|
|
43799
|
+
const phaseEvents = eventsJsonlContent ? _internals14.filterPhaseEvents(eventsJsonlContent, phase) : [];
|
|
43686
43800
|
const contextMd = await readSwarmFileAsync(directory, "context.md");
|
|
43687
43801
|
const requiredAgents = ["reviewer", "test_engineer"];
|
|
43688
|
-
const complianceObservations = checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
43802
|
+
const complianceObservations = _internals14.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
43689
43803
|
const plan = await loadPlanJsonOnly(directory);
|
|
43690
43804
|
const phaseData = plan?.phases.find((p) => p.id === phase);
|
|
43691
43805
|
const tasksCompleted = phaseData ? phaseData.tasks.filter((t) => t.status === "completed").length : 0;
|
|
@@ -43708,7 +43822,9 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
43708
43822
|
phase,
|
|
43709
43823
|
timestamp: new Date().toISOString(),
|
|
43710
43824
|
summary: `Phase ${phase} completed. ${tasksCompleted}/${tasksTotal} tasks completed. ${complianceObservations.length} compliance observations.`,
|
|
43711
|
-
agents_used: [
|
|
43825
|
+
agents_used: [
|
|
43826
|
+
...new Set(agentsDispatched.map((a) => _internals14.normalizeAgentName(a)))
|
|
43827
|
+
],
|
|
43712
43828
|
tasks_completed: tasksCompleted,
|
|
43713
43829
|
tasks_total: tasksTotal,
|
|
43714
43830
|
key_decisions: keyDecisions.slice(0, 5),
|
|
@@ -43753,7 +43869,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, _kno
|
|
|
43753
43869
|
clearTimeout(timer);
|
|
43754
43870
|
}
|
|
43755
43871
|
if (llmOutput?.trim()) {
|
|
43756
|
-
knowledgeRecommendations = parseKnowledgeRecommendations(llmOutput);
|
|
43872
|
+
knowledgeRecommendations = _internals14.parseKnowledgeRecommendations(llmOutput);
|
|
43757
43873
|
}
|
|
43758
43874
|
getGlobalEventBus().publish("curator.phase.llm_completed", {
|
|
43759
43875
|
phase,
|
|
@@ -43799,7 +43915,7 @@ ${phaseDigest.summary}`,
|
|
|
43799
43915
|
knowledge_recommendations: knowledgeRecommendations
|
|
43800
43916
|
};
|
|
43801
43917
|
}
|
|
43802
|
-
await writeCuratorSummary(directory, updatedSummary);
|
|
43918
|
+
await _internals14.writeCuratorSummary(directory, updatedSummary);
|
|
43803
43919
|
const eventsPath = path21.join(directory, ".swarm", "events.jsonl");
|
|
43804
43920
|
for (const obs of complianceObservations) {
|
|
43805
43921
|
await appendKnowledge(eventsPath, {
|
|
@@ -43985,14 +44101,23 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
43985
44101
|
}
|
|
43986
44102
|
return { applied, skipped };
|
|
43987
44103
|
}
|
|
43988
|
-
var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000;
|
|
44104
|
+
var DEFAULT_CURATOR_LLM_TIMEOUT_MS = 300000, _internals14;
|
|
43989
44105
|
var init_curator = __esm(() => {
|
|
43990
44106
|
init_event_bus();
|
|
43991
44107
|
init_manager();
|
|
43992
44108
|
init_bun_compat();
|
|
44109
|
+
init_logger();
|
|
43993
44110
|
init_knowledge_store();
|
|
43994
44111
|
init_knowledge_validator();
|
|
43995
44112
|
init_utils2();
|
|
44113
|
+
_internals14 = {
|
|
44114
|
+
parseKnowledgeRecommendations,
|
|
44115
|
+
readCuratorSummary,
|
|
44116
|
+
writeCuratorSummary,
|
|
44117
|
+
filterPhaseEvents,
|
|
44118
|
+
checkPhaseCompliance,
|
|
44119
|
+
normalizeAgentName
|
|
44120
|
+
};
|
|
43996
44121
|
});
|
|
43997
44122
|
|
|
43998
44123
|
// src/hooks/hive-promoter.ts
|
|
@@ -44300,7 +44425,8 @@ __export(exports_co_change_analyzer, {
|
|
|
44300
44425
|
detectDarkMatter: () => detectDarkMatter,
|
|
44301
44426
|
darkMatterToKnowledgeEntries: () => darkMatterToKnowledgeEntries,
|
|
44302
44427
|
co_change_analyzer: () => co_change_analyzer,
|
|
44303
|
-
buildCoChangeMatrix: () => buildCoChangeMatrix
|
|
44428
|
+
buildCoChangeMatrix: () => buildCoChangeMatrix,
|
|
44429
|
+
_internals: () => _internals15
|
|
44304
44430
|
});
|
|
44305
44431
|
import * as child_process3 from "node:child_process";
|
|
44306
44432
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
@@ -44523,9 +44649,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
44523
44649
|
} catch {
|
|
44524
44650
|
return [];
|
|
44525
44651
|
}
|
|
44526
|
-
const commitMap = await parseGitLog(directory, maxCommitsToAnalyze);
|
|
44527
|
-
const matrix = buildCoChangeMatrix(commitMap);
|
|
44528
|
-
const staticEdges = await getStaticEdges(directory);
|
|
44652
|
+
const commitMap = await _internals15.parseGitLog(directory, maxCommitsToAnalyze);
|
|
44653
|
+
const matrix = _internals15.buildCoChangeMatrix(commitMap);
|
|
44654
|
+
const staticEdges = await _internals15.getStaticEdges(directory);
|
|
44529
44655
|
const results = [];
|
|
44530
44656
|
for (const entry of matrix.values()) {
|
|
44531
44657
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -44605,7 +44731,7 @@ ${rows}
|
|
|
44605
44731
|
These pairs likely share an architectural concern invisible to static analysis.
|
|
44606
44732
|
Consider adding explicit documentation or extracting the shared concern.`;
|
|
44607
44733
|
}
|
|
44608
|
-
var co_change_analyzer;
|
|
44734
|
+
var co_change_analyzer, _internals15;
|
|
44609
44735
|
var init_co_change_analyzer = __esm(() => {
|
|
44610
44736
|
init_zod();
|
|
44611
44737
|
init_create_tool();
|
|
@@ -44637,10 +44763,18 @@ var init_co_change_analyzer = __esm(() => {
|
|
|
44637
44763
|
npmiThreshold,
|
|
44638
44764
|
maxCommitsToAnalyze
|
|
44639
44765
|
};
|
|
44640
|
-
const pairs = await detectDarkMatter(directory, options);
|
|
44641
|
-
return formatDarkMatterOutput(pairs);
|
|
44766
|
+
const pairs = await _internals15.detectDarkMatter(directory, options);
|
|
44767
|
+
return _internals15.formatDarkMatterOutput(pairs);
|
|
44642
44768
|
}
|
|
44643
44769
|
});
|
|
44770
|
+
_internals15 = {
|
|
44771
|
+
parseGitLog,
|
|
44772
|
+
buildCoChangeMatrix,
|
|
44773
|
+
getStaticEdges,
|
|
44774
|
+
detectDarkMatter,
|
|
44775
|
+
darkMatterToKnowledgeEntries,
|
|
44776
|
+
formatDarkMatterOutput
|
|
44777
|
+
};
|
|
44644
44778
|
});
|
|
44645
44779
|
|
|
44646
44780
|
// src/commands/dark-matter.ts
|
|
@@ -47454,7 +47588,7 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
47454
47588
|
const scope = options?.scope ?? "all";
|
|
47455
47589
|
const changedFiles = options?.changedFiles ?? [];
|
|
47456
47590
|
const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
|
|
47457
|
-
const profileResult = await discoverBuildCommandsFromProfiles(workingDir);
|
|
47591
|
+
const profileResult = await _internals16.discoverBuildCommandsFromProfiles(workingDir);
|
|
47458
47592
|
const profileCommands = profileResult.commands;
|
|
47459
47593
|
const profileSkipped = profileResult.skipped;
|
|
47460
47594
|
const coveredEcosystems = new Set;
|
|
@@ -47511,7 +47645,13 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
47511
47645
|
commands.sort((a, b) => a.priority - b.priority);
|
|
47512
47646
|
return { commands, skipped };
|
|
47513
47647
|
}
|
|
47514
|
-
|
|
47648
|
+
function clearToolchainCache() {
|
|
47649
|
+
toolchainCache.clear();
|
|
47650
|
+
}
|
|
47651
|
+
function getEcosystems() {
|
|
47652
|
+
return ECOSYSTEMS.map((e) => e.ecosystem);
|
|
47653
|
+
}
|
|
47654
|
+
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, _internals16, build_discovery;
|
|
47515
47655
|
var init_discovery = __esm(() => {
|
|
47516
47656
|
init_dist();
|
|
47517
47657
|
init_detector();
|
|
@@ -47629,6 +47769,13 @@ var init_discovery = __esm(() => {
|
|
|
47629
47769
|
php: ["php-composer"]
|
|
47630
47770
|
};
|
|
47631
47771
|
toolchainCache = new Map;
|
|
47772
|
+
_internals16 = {
|
|
47773
|
+
isCommandAvailable,
|
|
47774
|
+
discoverBuildCommandsFromProfiles,
|
|
47775
|
+
discoverBuildCommands,
|
|
47776
|
+
clearToolchainCache,
|
|
47777
|
+
getEcosystems
|
|
47778
|
+
};
|
|
47632
47779
|
build_discovery = tool({
|
|
47633
47780
|
description: "Discover build commands for various ecosystems in a project directory",
|
|
47634
47781
|
args: {
|
|
@@ -47891,6 +48038,7 @@ var exports_evidence_summary_service = {};
|
|
|
47891
48038
|
__export(exports_evidence_summary_service, {
|
|
47892
48039
|
isAutoSummaryEnabled: () => isAutoSummaryEnabled,
|
|
47893
48040
|
buildEvidenceSummary: () => buildEvidenceSummary,
|
|
48041
|
+
_internals: () => _internals17,
|
|
47894
48042
|
REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
|
|
47895
48043
|
EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
|
|
47896
48044
|
});
|
|
@@ -47928,14 +48076,14 @@ function getTaskStatus(task, bundle) {
|
|
|
47928
48076
|
if (task?.status) {
|
|
47929
48077
|
return task.status;
|
|
47930
48078
|
}
|
|
47931
|
-
const entries = normalizeBundleEntries(bundle);
|
|
48079
|
+
const entries = _internals17.normalizeBundleEntries(bundle);
|
|
47932
48080
|
if (entries.length > 0) {
|
|
47933
48081
|
return "completed";
|
|
47934
48082
|
}
|
|
47935
48083
|
return "pending";
|
|
47936
48084
|
}
|
|
47937
48085
|
function isEvidenceComplete(bundle) {
|
|
47938
|
-
const entries = normalizeBundleEntries(bundle);
|
|
48086
|
+
const entries = _internals17.normalizeBundleEntries(bundle);
|
|
47939
48087
|
if (entries.length === 0) {
|
|
47940
48088
|
return {
|
|
47941
48089
|
isComplete: false,
|
|
@@ -47971,10 +48119,10 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
47971
48119
|
const result = await loadEvidence(directory, taskId);
|
|
47972
48120
|
const bundle = result.status === "found" ? result.bundle : null;
|
|
47973
48121
|
const phase = task?.phase ?? 0;
|
|
47974
|
-
const status = getTaskStatus(task, bundle);
|
|
47975
|
-
const evidenceCheck = isEvidenceComplete(bundle);
|
|
47976
|
-
const blockers = getTaskBlockers(task, evidenceCheck, status);
|
|
47977
|
-
const entries = normalizeBundleEntries(bundle);
|
|
48122
|
+
const status = _internals17.getTaskStatus(task, bundle);
|
|
48123
|
+
const evidenceCheck = _internals17.isEvidenceComplete(bundle);
|
|
48124
|
+
const blockers = _internals17.getTaskBlockers(task, evidenceCheck, status);
|
|
48125
|
+
const entries = _internals17.normalizeBundleEntries(bundle);
|
|
47978
48126
|
const hasReview = entries.some((e) => e.type === "review");
|
|
47979
48127
|
const hasTest = entries.some((e) => e.type === "test");
|
|
47980
48128
|
const hasApproval = entries.some((e) => e.type === "approval");
|
|
@@ -48003,12 +48151,12 @@ async function buildPhaseSummary(directory, phase) {
|
|
|
48003
48151
|
const taskSummaries = [];
|
|
48004
48152
|
const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
|
|
48005
48153
|
for (const task of phase.tasks) {
|
|
48006
|
-
const summary = await buildTaskSummary(directory, task, task.id);
|
|
48154
|
+
const summary = await _internals17.buildTaskSummary(directory, task, task.id);
|
|
48007
48155
|
taskSummaries.push(summary);
|
|
48008
48156
|
}
|
|
48009
48157
|
const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
|
|
48010
48158
|
for (const taskId of extraTaskIds) {
|
|
48011
|
-
const summary = await buildTaskSummary(directory, undefined, taskId);
|
|
48159
|
+
const summary = await _internals17.buildTaskSummary(directory, undefined, taskId);
|
|
48012
48160
|
if (summary.phase === phase.id) {
|
|
48013
48161
|
taskSummaries.push(summary);
|
|
48014
48162
|
}
|
|
@@ -48109,7 +48257,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
48109
48257
|
let totalTasks = 0;
|
|
48110
48258
|
let completedTasks = 0;
|
|
48111
48259
|
for (const phase of phasesToProcess) {
|
|
48112
|
-
const summary = await buildPhaseSummary(directory, phase);
|
|
48260
|
+
const summary = await _internals17.buildPhaseSummary(directory, phase);
|
|
48113
48261
|
phaseSummaries.push(summary);
|
|
48114
48262
|
totalTasks += summary.totalTasks;
|
|
48115
48263
|
completedTasks += summary.completedTasks;
|
|
@@ -48131,7 +48279,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
48131
48279
|
overallBlockers,
|
|
48132
48280
|
summaryText: ""
|
|
48133
48281
|
};
|
|
48134
|
-
artifact.summaryText = generateSummaryText(artifact);
|
|
48282
|
+
artifact.summaryText = _internals17.generateSummaryText(artifact);
|
|
48135
48283
|
log("[EvidenceSummary] Summary built", {
|
|
48136
48284
|
phases: phaseSummaries.length,
|
|
48137
48285
|
totalTasks,
|
|
@@ -48150,7 +48298,7 @@ function isAutoSummaryEnabled(automationConfig) {
|
|
|
48150
48298
|
}
|
|
48151
48299
|
return automationConfig.capabilities?.evidence_auto_summaries === true;
|
|
48152
48300
|
}
|
|
48153
|
-
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0";
|
|
48301
|
+
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0", _internals17;
|
|
48154
48302
|
var init_evidence_summary_service = __esm(() => {
|
|
48155
48303
|
init_manager2();
|
|
48156
48304
|
init_manager();
|
|
@@ -48164,6 +48312,17 @@ var init_evidence_summary_service = __esm(() => {
|
|
|
48164
48312
|
"retrospective"
|
|
48165
48313
|
]);
|
|
48166
48314
|
REQUIRED_EVIDENCE_TYPES = ["review", "test"];
|
|
48315
|
+
_internals17 = {
|
|
48316
|
+
buildEvidenceSummary,
|
|
48317
|
+
isAutoSummaryEnabled,
|
|
48318
|
+
normalizeBundleEntries,
|
|
48319
|
+
getTaskStatus,
|
|
48320
|
+
isEvidenceComplete,
|
|
48321
|
+
getTaskBlockers,
|
|
48322
|
+
buildTaskSummary,
|
|
48323
|
+
buildPhaseSummary,
|
|
48324
|
+
generateSummaryText
|
|
48325
|
+
};
|
|
48167
48326
|
});
|
|
48168
48327
|
|
|
48169
48328
|
// src/services/evidence-service.ts
|
|
@@ -48463,7 +48622,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
48463
48622
|
if (!plan) {
|
|
48464
48623
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
48465
48624
|
}
|
|
48466
|
-
if (!validatePlanPhases(plan)) {
|
|
48625
|
+
if (!_internals18.validatePlanPhases(plan)) {
|
|
48467
48626
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
48468
48627
|
}
|
|
48469
48628
|
let currentPhase = null;
|
|
@@ -48605,9 +48764,9 @@ function extractPhaseMetrics(content) {
|
|
|
48605
48764
|
async function getHandoffData(directory) {
|
|
48606
48765
|
const now = new Date().toISOString();
|
|
48607
48766
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
48608
|
-
const sessionState = parseSessionState(sessionContent);
|
|
48767
|
+
const sessionState = _internals18.parseSessionState(sessionContent);
|
|
48609
48768
|
const plan = await loadPlanJsonOnly(directory);
|
|
48610
|
-
const planInfo =
|
|
48769
|
+
const planInfo = _internals18.extractCurrentPhaseFromPlan(plan);
|
|
48611
48770
|
if (!plan) {
|
|
48612
48771
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
48613
48772
|
if (planMdContent) {
|
|
@@ -48626,8 +48785,8 @@ async function getHandoffData(directory) {
|
|
|
48626
48785
|
}
|
|
48627
48786
|
}
|
|
48628
48787
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
48629
|
-
const recentDecisions =
|
|
48630
|
-
const rawPhaseMetrics = extractPhaseMetrics(contextContent);
|
|
48788
|
+
const recentDecisions = _internals18.extractDecisions(contextContent);
|
|
48789
|
+
const rawPhaseMetrics = _internals18.extractPhaseMetrics(contextContent);
|
|
48631
48790
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
48632
48791
|
let delegationState = null;
|
|
48633
48792
|
if (sessionState?.delegationState) {
|
|
@@ -48791,12 +48950,24 @@ ${lines.join(`
|
|
|
48791
48950
|
`)}
|
|
48792
48951
|
\`\`\``;
|
|
48793
48952
|
}
|
|
48794
|
-
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20;
|
|
48953
|
+
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20, _internals18;
|
|
48795
48954
|
var init_handoff_service = __esm(() => {
|
|
48796
48955
|
init_utils2();
|
|
48797
48956
|
init_manager();
|
|
48798
48957
|
init_utils();
|
|
48799
48958
|
RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
|
|
48959
|
+
_internals18 = {
|
|
48960
|
+
getHandoffData,
|
|
48961
|
+
formatHandoffMarkdown,
|
|
48962
|
+
formatContinuationPrompt,
|
|
48963
|
+
escapeHtml,
|
|
48964
|
+
sanitizeString,
|
|
48965
|
+
validatePlanPhases,
|
|
48966
|
+
extractCurrentPhaseFromPlan: extractCurrentPhaseFromPlan2,
|
|
48967
|
+
parseSessionState,
|
|
48968
|
+
extractDecisions: extractDecisions2,
|
|
48969
|
+
extractPhaseMetrics
|
|
48970
|
+
};
|
|
48800
48971
|
});
|
|
48801
48972
|
|
|
48802
48973
|
// src/commands/handoff.ts
|
|
@@ -49191,6 +49362,15 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
49191
49362
|
import { existsSync as existsSync16, readFileSync as readFileSync11 } from "node:fs";
|
|
49192
49363
|
import { mkdir as mkdir6, readFile as readFile8, writeFile as writeFile6 } from "node:fs/promises";
|
|
49193
49364
|
import * as path30 from "node:path";
|
|
49365
|
+
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
49366
|
+
return {
|
|
49367
|
+
migrated: false,
|
|
49368
|
+
entriesMigrated: 0,
|
|
49369
|
+
entriesDropped: 0,
|
|
49370
|
+
entriesTotal: 0,
|
|
49371
|
+
skippedReason: "no-context-file"
|
|
49372
|
+
};
|
|
49373
|
+
}
|
|
49194
49374
|
async function migrateContextToKnowledge(directory, config3) {
|
|
49195
49375
|
const sentinelPath = path30.join(directory, ".swarm", ".knowledge-migrated");
|
|
49196
49376
|
const contextPath = path30.join(directory, ".swarm", "context.md");
|
|
@@ -49223,9 +49403,9 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
49223
49403
|
skippedReason: "empty-context"
|
|
49224
49404
|
};
|
|
49225
49405
|
}
|
|
49226
|
-
const rawEntries = parseContextMd(contextContent);
|
|
49406
|
+
const rawEntries = _internals19.parseContextMd(contextContent);
|
|
49227
49407
|
if (rawEntries.length === 0) {
|
|
49228
|
-
await writeSentinel(sentinelPath, 0, 0);
|
|
49408
|
+
await _internals19.writeSentinel(sentinelPath, 0, 0);
|
|
49229
49409
|
return {
|
|
49230
49410
|
migrated: true,
|
|
49231
49411
|
entriesMigrated: 0,
|
|
@@ -49236,10 +49416,10 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
49236
49416
|
const existing = await readKnowledge(knowledgePath);
|
|
49237
49417
|
let migrated = 0;
|
|
49238
49418
|
let dropped = 0;
|
|
49239
|
-
const projectName = inferProjectName(directory);
|
|
49419
|
+
const projectName = _internals19.inferProjectName(directory);
|
|
49240
49420
|
for (const raw of rawEntries) {
|
|
49241
49421
|
if (config3.validation_enabled !== false) {
|
|
49242
|
-
const category = raw.categoryHint ?? inferCategoryFromText(raw.text);
|
|
49422
|
+
const category = raw.categoryHint ?? _internals19.inferCategoryFromText(raw.text);
|
|
49243
49423
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
49244
49424
|
category,
|
|
49245
49425
|
scope: "global",
|
|
@@ -49259,8 +49439,8 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
49259
49439
|
const entry = {
|
|
49260
49440
|
id: randomUUID3(),
|
|
49261
49441
|
tier: "swarm",
|
|
49262
|
-
lesson: truncateLesson(raw.text),
|
|
49263
|
-
category: raw.categoryHint ?? inferCategoryFromText(raw.text),
|
|
49442
|
+
lesson: _internals19.truncateLesson(raw.text),
|
|
49443
|
+
category: raw.categoryHint ?? _internals19.inferCategoryFromText(raw.text),
|
|
49264
49444
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
49265
49445
|
scope: "global",
|
|
49266
49446
|
confidence: 0.3,
|
|
@@ -49283,7 +49463,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
49283
49463
|
if (migrated > 0) {
|
|
49284
49464
|
await rewriteKnowledge(knowledgePath, existing);
|
|
49285
49465
|
}
|
|
49286
|
-
await writeSentinel(sentinelPath, migrated, dropped);
|
|
49466
|
+
await _internals19.writeSentinel(sentinelPath, migrated, dropped);
|
|
49287
49467
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
49288
49468
|
return {
|
|
49289
49469
|
migrated: true,
|
|
@@ -49293,7 +49473,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
49293
49473
|
};
|
|
49294
49474
|
}
|
|
49295
49475
|
function parseContextMd(content) {
|
|
49296
|
-
const sections = splitIntoSections(content);
|
|
49476
|
+
const sections = _internals19.splitIntoSections(content);
|
|
49297
49477
|
const entries = [];
|
|
49298
49478
|
const seen = new Set;
|
|
49299
49479
|
const sectionPatterns = [
|
|
@@ -49309,7 +49489,7 @@ function parseContextMd(content) {
|
|
|
49309
49489
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
49310
49490
|
if (!match)
|
|
49311
49491
|
continue;
|
|
49312
|
-
const bullets = extractBullets(section.body);
|
|
49492
|
+
const bullets = _internals19.extractBullets(section.body);
|
|
49313
49493
|
for (const bullet of bullets) {
|
|
49314
49494
|
if (bullet.length < 15)
|
|
49315
49495
|
continue;
|
|
@@ -49318,9 +49498,9 @@ function parseContextMd(content) {
|
|
|
49318
49498
|
continue;
|
|
49319
49499
|
seen.add(normalized);
|
|
49320
49500
|
entries.push({
|
|
49321
|
-
text: truncateLesson(bullet),
|
|
49501
|
+
text: _internals19.truncateLesson(bullet),
|
|
49322
49502
|
sourceSection: match.sourceSection,
|
|
49323
|
-
categoryHint: inferCategoryFromText(bullet)
|
|
49503
|
+
categoryHint: _internals19.inferCategoryFromText(bullet)
|
|
49324
49504
|
});
|
|
49325
49505
|
}
|
|
49326
49506
|
}
|
|
@@ -49413,9 +49593,22 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
49413
49593
|
await mkdir6(path30.dirname(sentinelPath), { recursive: true });
|
|
49414
49594
|
await writeFile6(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
49415
49595
|
}
|
|
49596
|
+
var _internals19;
|
|
49416
49597
|
var init_knowledge_migrator = __esm(() => {
|
|
49598
|
+
init_logger();
|
|
49417
49599
|
init_knowledge_store();
|
|
49418
49600
|
init_knowledge_validator();
|
|
49601
|
+
_internals19 = {
|
|
49602
|
+
migrateContextToKnowledge,
|
|
49603
|
+
migrateKnowledgeToExternal,
|
|
49604
|
+
parseContextMd,
|
|
49605
|
+
splitIntoSections,
|
|
49606
|
+
extractBullets,
|
|
49607
|
+
inferCategoryFromText,
|
|
49608
|
+
truncateLesson,
|
|
49609
|
+
inferProjectName,
|
|
49610
|
+
writeSentinel
|
|
49611
|
+
};
|
|
49419
49612
|
});
|
|
49420
49613
|
|
|
49421
49614
|
// src/commands/knowledge.ts
|
|
@@ -50323,7 +50516,7 @@ async function runAdditionalLint(linter, mode, cwd) {
|
|
|
50323
50516
|
};
|
|
50324
50517
|
}
|
|
50325
50518
|
}
|
|
50326
|
-
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint;
|
|
50519
|
+
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals20;
|
|
50327
50520
|
var init_lint = __esm(() => {
|
|
50328
50521
|
init_zod();
|
|
50329
50522
|
init_discovery();
|
|
@@ -50355,15 +50548,15 @@ var init_lint = __esm(() => {
|
|
|
50355
50548
|
}
|
|
50356
50549
|
const { mode } = args2;
|
|
50357
50550
|
const cwd = directory;
|
|
50358
|
-
const linter = await detectAvailableLinter(directory);
|
|
50551
|
+
const linter = await _internals20.detectAvailableLinter(directory);
|
|
50359
50552
|
if (linter) {
|
|
50360
|
-
const result = await runLint(linter, mode, directory);
|
|
50553
|
+
const result = await _internals20.runLint(linter, mode, directory);
|
|
50361
50554
|
return JSON.stringify(result, null, 2);
|
|
50362
50555
|
}
|
|
50363
|
-
const additionalLinter = detectAdditionalLinter(cwd);
|
|
50556
|
+
const additionalLinter = _internals20.detectAdditionalLinter(cwd);
|
|
50364
50557
|
if (additionalLinter) {
|
|
50365
50558
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
50366
|
-
const result = await runAdditionalLint(additionalLinter, mode, cwd);
|
|
50559
|
+
const result = await _internals20.runAdditionalLint(additionalLinter, mode, cwd);
|
|
50367
50560
|
return JSON.stringify(result, null, 2);
|
|
50368
50561
|
}
|
|
50369
50562
|
const errorResult = {
|
|
@@ -50377,6 +50570,12 @@ For Rust: rustup component add clippy`
|
|
|
50377
50570
|
return JSON.stringify(errorResult, null, 2);
|
|
50378
50571
|
}
|
|
50379
50572
|
});
|
|
50573
|
+
_internals20 = {
|
|
50574
|
+
detectAvailableLinter,
|
|
50575
|
+
runLint,
|
|
50576
|
+
detectAdditionalLinter,
|
|
50577
|
+
runAdditionalLint
|
|
50578
|
+
};
|
|
50380
50579
|
});
|
|
50381
50580
|
|
|
50382
50581
|
// src/tools/secretscan.ts
|
|
@@ -50685,7 +50884,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
50685
50884
|
}
|
|
50686
50885
|
async function runSecretscan(directory) {
|
|
50687
50886
|
try {
|
|
50688
|
-
const result = await secretscan.execute({ directory }, {});
|
|
50887
|
+
const result = await _internals21.secretscan.execute({ directory }, {});
|
|
50689
50888
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
50690
50889
|
return JSON.parse(jsonStr);
|
|
50691
50890
|
} catch (e) {
|
|
@@ -50700,7 +50899,7 @@ async function runSecretscan(directory) {
|
|
|
50700
50899
|
return errorResult;
|
|
50701
50900
|
}
|
|
50702
50901
|
}
|
|
50703
|
-
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS, O_NOFOLLOW, secretscan;
|
|
50902
|
+
var MAX_FILE_PATH_LENGTH = 500, MAX_FILE_SIZE_BYTES, MAX_FILES_SCANNED = 1000, MAX_FINDINGS = 100, MAX_OUTPUT_BYTES2 = 512000, MAX_LINE_LENGTH = 1e4, MAX_CONTENT_BYTES, BINARY_SIGNATURES, BINARY_PREFIX_BYTES = 4, BINARY_NULL_CHECK_BYTES = 8192, BINARY_NULL_THRESHOLD = 0.1, DEFAULT_EXCLUDE_DIRS, DEFAULT_EXCLUDE_EXTENSIONS, SECRET_PATTERNS, O_NOFOLLOW, secretscan, _internals21;
|
|
50704
50903
|
var init_secretscan = __esm(() => {
|
|
50705
50904
|
init_zod();
|
|
50706
50905
|
init_path_security();
|
|
@@ -51072,6 +51271,10 @@ var init_secretscan = __esm(() => {
|
|
|
51072
51271
|
}
|
|
51073
51272
|
}
|
|
51074
51273
|
});
|
|
51274
|
+
_internals21 = {
|
|
51275
|
+
secretscan,
|
|
51276
|
+
runSecretscan
|
|
51277
|
+
};
|
|
51075
51278
|
});
|
|
51076
51279
|
|
|
51077
51280
|
// src/test-impact/analyzer.ts
|
|
@@ -51203,8 +51406,8 @@ async function buildImpactMapInternal(cwd) {
|
|
|
51203
51406
|
return impactMap;
|
|
51204
51407
|
}
|
|
51205
51408
|
async function buildImpactMap(cwd) {
|
|
51206
|
-
const impactMap = await buildImpactMapInternal(cwd);
|
|
51207
|
-
await saveImpactMap(cwd, impactMap);
|
|
51409
|
+
const impactMap = await _internals22.buildImpactMapInternal(cwd);
|
|
51410
|
+
await _internals22.saveImpactMap(cwd, impactMap);
|
|
51208
51411
|
return impactMap;
|
|
51209
51412
|
}
|
|
51210
51413
|
async function loadImpactMap(cwd) {
|
|
@@ -51215,12 +51418,12 @@ async function loadImpactMap(cwd) {
|
|
|
51215
51418
|
const data = JSON.parse(content);
|
|
51216
51419
|
const map3 = data.map;
|
|
51217
51420
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
51218
|
-
if (!isCacheStale(map3, generatedAt)) {
|
|
51421
|
+
if (!_internals22.isCacheStale(map3, generatedAt)) {
|
|
51219
51422
|
return map3;
|
|
51220
51423
|
}
|
|
51221
51424
|
} catch {}
|
|
51222
51425
|
}
|
|
51223
|
-
return buildImpactMap(cwd);
|
|
51426
|
+
return _internals22.buildImpactMap(cwd);
|
|
51224
51427
|
}
|
|
51225
51428
|
async function saveImpactMap(cwd, impactMap) {
|
|
51226
51429
|
const cacheDir2 = path34.join(cwd, ".swarm", "cache");
|
|
@@ -51246,7 +51449,7 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
51246
51449
|
};
|
|
51247
51450
|
}
|
|
51248
51451
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
51249
|
-
const impactMap = await loadImpactMap(cwd);
|
|
51452
|
+
const impactMap = await _internals22.loadImpactMap(cwd);
|
|
51250
51453
|
const impactedTestsSet = new Set;
|
|
51251
51454
|
const untestedFiles = [];
|
|
51252
51455
|
for (const changedFile of validFiles) {
|
|
@@ -51287,12 +51490,24 @@ async function analyzeImpact(changedFiles, cwd) {
|
|
|
51287
51490
|
impactMap
|
|
51288
51491
|
};
|
|
51289
51492
|
}
|
|
51290
|
-
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, EXTENSIONS_TO_TRY;
|
|
51493
|
+
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, EXTENSIONS_TO_TRY, _internals22;
|
|
51291
51494
|
var init_analyzer = __esm(() => {
|
|
51292
51495
|
IMPORT_REGEX_ES = /import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
|
|
51293
51496
|
IMPORT_REGEX_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
51294
51497
|
IMPORT_REGEX_REEXPORT = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
51295
51498
|
EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
51499
|
+
_internals22 = {
|
|
51500
|
+
normalizePath,
|
|
51501
|
+
isCacheStale,
|
|
51502
|
+
resolveRelativeImport,
|
|
51503
|
+
findTestFilesSync,
|
|
51504
|
+
extractImports,
|
|
51505
|
+
buildImpactMapInternal,
|
|
51506
|
+
buildImpactMap,
|
|
51507
|
+
loadImpactMap,
|
|
51508
|
+
saveImpactMap,
|
|
51509
|
+
analyzeImpact
|
|
51510
|
+
};
|
|
51296
51511
|
});
|
|
51297
51512
|
|
|
51298
51513
|
// src/test-impact/failure-classifier.ts
|
|
@@ -53128,9 +53343,9 @@ function getVersionFileVersion(dir) {
|
|
|
53128
53343
|
async function runVersionCheck2(dir, _timeoutMs) {
|
|
53129
53344
|
const startTime = Date.now();
|
|
53130
53345
|
try {
|
|
53131
|
-
const packageVersion = getPackageVersion(dir);
|
|
53132
|
-
const changelogVersion = getChangelogVersion(dir);
|
|
53133
|
-
const versionFileVersion = getVersionFileVersion(dir);
|
|
53346
|
+
const packageVersion = _internals23.getPackageVersion(dir);
|
|
53347
|
+
const changelogVersion = _internals23.getChangelogVersion(dir);
|
|
53348
|
+
const versionFileVersion = _internals23.getVersionFileVersion(dir);
|
|
53134
53349
|
const versions3 = [];
|
|
53135
53350
|
if (packageVersion)
|
|
53136
53351
|
versions3.push(`package.json: ${packageVersion}`);
|
|
@@ -53480,7 +53695,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
53480
53695
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
53481
53696
|
let validatedDir;
|
|
53482
53697
|
try {
|
|
53483
|
-
validatedDir = validateDirectoryPath(dir);
|
|
53698
|
+
validatedDir = _internals23.validateDirectoryPath(dir);
|
|
53484
53699
|
} catch (error93) {
|
|
53485
53700
|
return {
|
|
53486
53701
|
id: reportId,
|
|
@@ -53500,7 +53715,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
53500
53715
|
}
|
|
53501
53716
|
let validatedTimeout;
|
|
53502
53717
|
try {
|
|
53503
|
-
validatedTimeout = validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
53718
|
+
validatedTimeout = _internals23.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
53504
53719
|
} catch (error93) {
|
|
53505
53720
|
return {
|
|
53506
53721
|
id: reportId,
|
|
@@ -53541,12 +53756,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
53541
53756
|
});
|
|
53542
53757
|
const checks5 = [];
|
|
53543
53758
|
log("[Preflight] Running lint check...");
|
|
53544
|
-
const lintResult = await runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
53759
|
+
const lintResult = await _internals23.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
53545
53760
|
checks5.push(lintResult);
|
|
53546
53761
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
53547
53762
|
if (!cfg.skipTests) {
|
|
53548
53763
|
log("[Preflight] Running tests check...");
|
|
53549
|
-
const testsResult = await runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
53764
|
+
const testsResult = await _internals23.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
53550
53765
|
checks5.push(testsResult);
|
|
53551
53766
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
53552
53767
|
} else {
|
|
@@ -53558,7 +53773,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
53558
53773
|
}
|
|
53559
53774
|
if (!cfg.skipSecrets) {
|
|
53560
53775
|
log("[Preflight] Running secrets check...");
|
|
53561
|
-
const secretsResult = await runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
53776
|
+
const secretsResult = await _internals23.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
53562
53777
|
checks5.push(secretsResult);
|
|
53563
53778
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
53564
53779
|
} else {
|
|
@@ -53570,7 +53785,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
53570
53785
|
}
|
|
53571
53786
|
if (!cfg.skipEvidence) {
|
|
53572
53787
|
log("[Preflight] Running evidence check...");
|
|
53573
|
-
const evidenceResult = await runEvidenceCheck(validatedDir);
|
|
53788
|
+
const evidenceResult = await _internals23.runEvidenceCheck(validatedDir);
|
|
53574
53789
|
checks5.push(evidenceResult);
|
|
53575
53790
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
53576
53791
|
} else {
|
|
@@ -53581,12 +53796,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
53581
53796
|
});
|
|
53582
53797
|
}
|
|
53583
53798
|
log("[Preflight] Running requirement coverage check...");
|
|
53584
|
-
const reqCoverageResult = await runRequirementCoverageCheck(validatedDir, phase);
|
|
53799
|
+
const reqCoverageResult = await _internals23.runRequirementCoverageCheck(validatedDir, phase);
|
|
53585
53800
|
checks5.push(reqCoverageResult);
|
|
53586
53801
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
53587
53802
|
if (!cfg.skipVersion) {
|
|
53588
53803
|
log("[Preflight] Running version check...");
|
|
53589
|
-
const versionResult = await
|
|
53804
|
+
const versionResult = await _internals23.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
53590
53805
|
checks5.push(versionResult);
|
|
53591
53806
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
53592
53807
|
} else {
|
|
@@ -53649,10 +53864,10 @@ function formatPreflightMarkdown(report) {
|
|
|
53649
53864
|
async function handlePreflightCommand(directory, _args) {
|
|
53650
53865
|
const plan = await loadPlan(directory);
|
|
53651
53866
|
const phase = plan?.current_phase ?? 1;
|
|
53652
|
-
const report = await runPreflight(directory, phase);
|
|
53653
|
-
return formatPreflightMarkdown(report);
|
|
53867
|
+
const report = await _internals23.runPreflight(directory, phase);
|
|
53868
|
+
return _internals23.formatPreflightMarkdown(report);
|
|
53654
53869
|
}
|
|
53655
|
-
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG;
|
|
53870
|
+
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals23;
|
|
53656
53871
|
var init_preflight_service = __esm(() => {
|
|
53657
53872
|
init_manager2();
|
|
53658
53873
|
init_manager();
|
|
@@ -53669,6 +53884,22 @@ var init_preflight_service = __esm(() => {
|
|
|
53669
53884
|
testScope: "convention",
|
|
53670
53885
|
linter: "biome"
|
|
53671
53886
|
};
|
|
53887
|
+
_internals23 = {
|
|
53888
|
+
runPreflight,
|
|
53889
|
+
formatPreflightMarkdown,
|
|
53890
|
+
handlePreflightCommand,
|
|
53891
|
+
validateDirectoryPath,
|
|
53892
|
+
validateTimeout,
|
|
53893
|
+
getPackageVersion,
|
|
53894
|
+
getChangelogVersion,
|
|
53895
|
+
getVersionFileVersion,
|
|
53896
|
+
runVersionCheck: runVersionCheck2,
|
|
53897
|
+
runLintCheck,
|
|
53898
|
+
runTestsCheck,
|
|
53899
|
+
runSecretsCheck,
|
|
53900
|
+
runEvidenceCheck,
|
|
53901
|
+
runRequirementCoverageCheck
|
|
53902
|
+
};
|
|
53672
53903
|
});
|
|
53673
53904
|
|
|
53674
53905
|
// src/commands/preflight.ts
|
|
@@ -55379,6 +55610,7 @@ async function handleStatusCommand(directory, agents) {
|
|
|
55379
55610
|
return formatStatusMarkdown(statusData);
|
|
55380
55611
|
}
|
|
55381
55612
|
var init_status_service = __esm(() => {
|
|
55613
|
+
init_extractors();
|
|
55382
55614
|
init_utils2();
|
|
55383
55615
|
init_manager();
|
|
55384
55616
|
init_state();
|
|
@@ -55784,7 +56016,7 @@ function findSimilarCommands(query) {
|
|
|
55784
56016
|
return cmd.toLowerCase().includes(q) || q.includes(cmd.toLowerCase());
|
|
55785
56017
|
}).map((cmd) => ({
|
|
55786
56018
|
cmd,
|
|
55787
|
-
score: cmd.length < q.length ? q.length - cmd.length : levenshteinDistance(q, cmd)
|
|
56019
|
+
score: cmd.length < q.length ? q.length - cmd.length : _internals24.levenshteinDistance(q, cmd)
|
|
55788
56020
|
}));
|
|
55789
56021
|
scored.sort((a, b) => a.score - b.score);
|
|
55790
56022
|
return scored.slice(0, 3).map((s) => s.cmd);
|
|
@@ -55814,11 +56046,11 @@ async function handleHelpCommand(ctx) {
|
|
|
55814
56046
|
return buildHelpText2();
|
|
55815
56047
|
}
|
|
55816
56048
|
const tokens = targetCommand.split(/\s+/);
|
|
55817
|
-
const resolved = resolveCommand(tokens);
|
|
56049
|
+
const resolved = _internals24.resolveCommand(tokens);
|
|
55818
56050
|
if (resolved) {
|
|
55819
|
-
return buildDetailedHelp(resolved.key, resolved.entry);
|
|
56051
|
+
return _internals24.buildDetailedHelp(resolved.key, resolved.entry);
|
|
55820
56052
|
}
|
|
55821
|
-
const similar = findSimilarCommands(targetCommand);
|
|
56053
|
+
const similar = _internals24.findSimilarCommands(targetCommand);
|
|
55822
56054
|
const { buildHelpText: fullHelp } = await Promise.resolve().then(() => (init_commands(), exports_commands));
|
|
55823
56055
|
if (similar.length > 0) {
|
|
55824
56056
|
return `Command '/swarm ${targetCommand}' not found.
|
|
@@ -55912,7 +56144,7 @@ function resolveCommand(tokens) {
|
|
|
55912
56144
|
}
|
|
55913
56145
|
return null;
|
|
55914
56146
|
}
|
|
55915
|
-
var COMMAND_REGISTRY, VALID_COMMANDS, validation;
|
|
56147
|
+
var COMMAND_REGISTRY, VALID_COMMANDS, _internals24, validation;
|
|
55916
56148
|
var init_registry = __esm(() => {
|
|
55917
56149
|
init_acknowledge_spec_drift();
|
|
55918
56150
|
init_agents();
|
|
@@ -55973,7 +56205,7 @@ var init_registry = __esm(() => {
|
|
|
55973
56205
|
clashesWithNativeCcCommand: "/agents"
|
|
55974
56206
|
},
|
|
55975
56207
|
help: {
|
|
55976
|
-
handler: (ctx) => handleHelpCommand(ctx),
|
|
56208
|
+
handler: (ctx) => _internals24.handleHelpCommand(ctx),
|
|
55977
56209
|
description: "Show help for swarm commands",
|
|
55978
56210
|
category: "core",
|
|
55979
56211
|
args: "[command]",
|
|
@@ -56303,7 +56535,15 @@ var init_registry = __esm(() => {
|
|
|
56303
56535
|
}
|
|
56304
56536
|
};
|
|
56305
56537
|
VALID_COMMANDS = Object.keys(COMMAND_REGISTRY);
|
|
56306
|
-
|
|
56538
|
+
_internals24 = {
|
|
56539
|
+
handleHelpCommand,
|
|
56540
|
+
validateAliases,
|
|
56541
|
+
resolveCommand,
|
|
56542
|
+
levenshteinDistance,
|
|
56543
|
+
findSimilarCommands,
|
|
56544
|
+
buildDetailedHelp
|
|
56545
|
+
};
|
|
56546
|
+
validation = _internals24.validateAliases();
|
|
56307
56547
|
if (!validation.valid) {
|
|
56308
56548
|
throw new Error(`COMMAND_REGISTRY alias validation failed:
|
|
56309
56549
|
${validation.errors.join(`
|
|
@@ -59029,6 +59269,7 @@ REASONING: [2-4 sentences — what you verified and why]
|
|
|
59029
59269
|
EVIDENCE_CHECKED: [list of files/artifacts you read]
|
|
59030
59270
|
ANTI_PATTERNS_DETECTED: [list or "none"]
|
|
59031
59271
|
ESCALATION_NEEDED: YES | NO`;
|
|
59272
|
+
var init_critic = () => {};
|
|
59032
59273
|
|
|
59033
59274
|
// src/agents/curator-agent.ts
|
|
59034
59275
|
function createCuratorAgent(model, customPrompt, customAppendPrompt, role = "curator_init") {
|
|
@@ -60044,8 +60285,10 @@ function applyOverrides(agent, swarmAgents, swarmPrefix, quiet) {
|
|
|
60044
60285
|
}
|
|
60045
60286
|
const variantOverride = getVariantOverride(agent.name, swarmAgents, swarmPrefix);
|
|
60046
60287
|
const modelSegments = agent.config.model?.split("/") ?? [];
|
|
60047
|
-
|
|
60048
|
-
|
|
60288
|
+
const lastSegment = modelSegments[modelSegments.length - 1] ?? "";
|
|
60289
|
+
const hasEmbeddedVariant = modelSegments.length >= 3 && KNOWN_VARIANT_VALUES.has(lastSegment);
|
|
60290
|
+
if (hasEmbeddedVariant) {
|
|
60291
|
+
const autoVariant = lastSegment;
|
|
60049
60292
|
const cleanedModel = modelSegments.slice(0, -1).join("/");
|
|
60050
60293
|
const effectiveVariant = variantOverride ?? autoVariant;
|
|
60051
60294
|
if (!quiet) {
|
|
@@ -60377,7 +60620,7 @@ function getAgentConfigs(config3, directory, sessionId) {
|
|
|
60377
60620
|
}
|
|
60378
60621
|
return result;
|
|
60379
60622
|
}
|
|
60380
|
-
var warnedAgents, _swarmAgents;
|
|
60623
|
+
var warnedAgents, _swarmAgents, KNOWN_VARIANT_VALUES;
|
|
60381
60624
|
var init_agents2 = __esm(() => {
|
|
60382
60625
|
init_config();
|
|
60383
60626
|
init_constants();
|
|
@@ -60385,13 +60628,23 @@ var init_agents2 = __esm(() => {
|
|
|
60385
60628
|
init_warning_buffer();
|
|
60386
60629
|
init_architect();
|
|
60387
60630
|
init_council_prompts();
|
|
60631
|
+
init_critic();
|
|
60388
60632
|
init_curator_agent();
|
|
60389
60633
|
init_reviewer();
|
|
60390
60634
|
init_architect();
|
|
60391
60635
|
init_council_prompts();
|
|
60636
|
+
init_critic();
|
|
60392
60637
|
init_curator_agent();
|
|
60393
60638
|
init_reviewer();
|
|
60394
60639
|
warnedAgents = new Set;
|
|
60640
|
+
KNOWN_VARIANT_VALUES = new Set([
|
|
60641
|
+
"low",
|
|
60642
|
+
"medium",
|
|
60643
|
+
"high",
|
|
60644
|
+
"max",
|
|
60645
|
+
"xhigh",
|
|
60646
|
+
"thinking"
|
|
60647
|
+
]);
|
|
60395
60648
|
});
|
|
60396
60649
|
|
|
60397
60650
|
// src/background/evidence-summary-integration.ts
|
|
@@ -61224,6 +61477,7 @@ var init_preflight_integration = __esm(() => {
|
|
|
61224
61477
|
init_status_artifact();
|
|
61225
61478
|
init_trigger();
|
|
61226
61479
|
init_preflight_service();
|
|
61480
|
+
init_logger();
|
|
61227
61481
|
});
|
|
61228
61482
|
|
|
61229
61483
|
// node_modules/web-tree-sitter/tree-sitter.js
|
|
@@ -64971,9 +65225,10 @@ var init_doc_scan = __esm(() => {
|
|
|
64971
65225
|
// src/tools/knowledge-recall.ts
|
|
64972
65226
|
var exports_knowledge_recall = {};
|
|
64973
65227
|
__export(exports_knowledge_recall, {
|
|
64974
|
-
knowledge_recall: () => knowledge_recall
|
|
65228
|
+
knowledge_recall: () => knowledge_recall,
|
|
65229
|
+
_internals: () => _internals25
|
|
64975
65230
|
});
|
|
64976
|
-
var knowledge_recall;
|
|
65231
|
+
var knowledge_recall, _internals25;
|
|
64977
65232
|
var init_knowledge_recall = __esm(() => {
|
|
64978
65233
|
init_zod();
|
|
64979
65234
|
init_knowledge_store();
|
|
@@ -65059,6 +65314,9 @@ var init_knowledge_recall = __esm(() => {
|
|
|
65059
65314
|
return JSON.stringify(result);
|
|
65060
65315
|
}
|
|
65061
65316
|
});
|
|
65317
|
+
_internals25 = {
|
|
65318
|
+
knowledge_recall
|
|
65319
|
+
};
|
|
65062
65320
|
});
|
|
65063
65321
|
|
|
65064
65322
|
// src/environment/prompt-renderer.ts
|
|
@@ -65110,13 +65368,14 @@ __export(exports_curator_drift, {
|
|
|
65110
65368
|
writeDriftReport: () => writeDriftReport,
|
|
65111
65369
|
runDeterministicDriftCheck: () => runDeterministicDriftCheck,
|
|
65112
65370
|
readPriorDriftReports: () => readPriorDriftReports,
|
|
65113
|
-
buildDriftInjectionText: () => buildDriftInjectionText
|
|
65371
|
+
buildDriftInjectionText: () => buildDriftInjectionText,
|
|
65372
|
+
_internals: () => _internals27
|
|
65114
65373
|
});
|
|
65115
|
-
import * as
|
|
65374
|
+
import * as fs49 from "node:fs";
|
|
65116
65375
|
import * as path70 from "node:path";
|
|
65117
65376
|
async function readPriorDriftReports(directory) {
|
|
65118
65377
|
const swarmDir = path70.join(directory, ".swarm");
|
|
65119
|
-
const entries = await
|
|
65378
|
+
const entries = await fs49.promises.readdir(swarmDir).catch(() => null);
|
|
65120
65379
|
if (entries === null)
|
|
65121
65380
|
return [];
|
|
65122
65381
|
const reportFiles = entries.filter((name2) => name2.startsWith(DRIFT_REPORT_PREFIX) && name2.endsWith(".json")).sort();
|
|
@@ -65143,9 +65402,9 @@ async function writeDriftReport(directory, report) {
|
|
|
65143
65402
|
const filename = `${DRIFT_REPORT_PREFIX}${report.phase}.json`;
|
|
65144
65403
|
const filePath = validateSwarmPath(directory, filename);
|
|
65145
65404
|
const swarmDir = path70.dirname(filePath);
|
|
65146
|
-
await
|
|
65405
|
+
await fs49.promises.mkdir(swarmDir, { recursive: true });
|
|
65147
65406
|
try {
|
|
65148
|
-
await
|
|
65407
|
+
await fs49.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
|
|
65149
65408
|
} catch (err2) {
|
|
65150
65409
|
throw new Error(`[curator-drift] Failed to write drift report to ${filePath}: ${String(err2)}`);
|
|
65151
65410
|
}
|
|
@@ -65155,7 +65414,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
|
|
|
65155
65414
|
try {
|
|
65156
65415
|
const planMd = await readSwarmFileAsync(directory, "plan.md");
|
|
65157
65416
|
const specMd = await readSwarmFileAsync(directory, "spec.md");
|
|
65158
|
-
const priorReports = await readPriorDriftReports(directory);
|
|
65417
|
+
const priorReports = await _internals27.readPriorDriftReports(directory);
|
|
65159
65418
|
const complianceCount = curatorResult.compliance.length;
|
|
65160
65419
|
const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
|
|
65161
65420
|
let alignment = "ALIGNED";
|
|
@@ -65204,7 +65463,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
|
|
|
65204
65463
|
scope_additions: [],
|
|
65205
65464
|
injection_summary: injectionSummary
|
|
65206
65465
|
};
|
|
65207
|
-
const reportPath = await writeDriftReport(directory, report);
|
|
65466
|
+
const reportPath = await _internals27.writeDriftReport(directory, report);
|
|
65208
65467
|
getGlobalEventBus().publish("curator.drift.completed", {
|
|
65209
65468
|
phase,
|
|
65210
65469
|
alignment,
|
|
@@ -65267,16 +65526,24 @@ function buildDriftInjectionText(report, maxChars) {
|
|
|
65267
65526
|
}
|
|
65268
65527
|
return text.slice(0, maxChars);
|
|
65269
65528
|
}
|
|
65270
|
-
var DRIFT_REPORT_PREFIX = "drift-report-phase-";
|
|
65529
|
+
var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals27;
|
|
65271
65530
|
var init_curator_drift = __esm(() => {
|
|
65272
65531
|
init_event_bus();
|
|
65532
|
+
init_logger();
|
|
65273
65533
|
init_utils2();
|
|
65534
|
+
_internals27 = {
|
|
65535
|
+
readPriorDriftReports,
|
|
65536
|
+
writeDriftReport,
|
|
65537
|
+
runDeterministicDriftCheck,
|
|
65538
|
+
buildDriftInjectionText
|
|
65539
|
+
};
|
|
65274
65540
|
});
|
|
65275
65541
|
|
|
65276
65542
|
// src/index.ts
|
|
65277
65543
|
init_package();
|
|
65278
65544
|
init_agents2();
|
|
65279
|
-
|
|
65545
|
+
init_critic();
|
|
65546
|
+
import * as path115 from "node:path";
|
|
65280
65547
|
|
|
65281
65548
|
// src/background/index.ts
|
|
65282
65549
|
init_event_bus();
|
|
@@ -65839,6 +66106,7 @@ var CONFLICT_MAP = new Map(CLAUDE_CODE_CONFLICTS.map((c) => [c.swarmCommand, c])
|
|
|
65839
66106
|
|
|
65840
66107
|
// src/hooks/cc-command-intercept.ts
|
|
65841
66108
|
init_constants();
|
|
66109
|
+
init_logger();
|
|
65842
66110
|
function createCcCommandInterceptHook(config3 = {}) {
|
|
65843
66111
|
const {
|
|
65844
66112
|
intercept = ["CRITICAL", "HIGH"],
|
|
@@ -65950,6 +66218,7 @@ function createCcCommandInterceptHook(config3 = {}) {
|
|
|
65950
66218
|
// src/hooks/compaction-customizer.ts
|
|
65951
66219
|
init_manager();
|
|
65952
66220
|
init_state();
|
|
66221
|
+
init_extractors();
|
|
65953
66222
|
init_utils2();
|
|
65954
66223
|
import * as fs33 from "node:fs";
|
|
65955
66224
|
import { join as join45 } from "node:path";
|
|
@@ -66617,11 +66886,17 @@ function createDelegationTrackerHook(config3, guardrailsEnabled = true) {
|
|
|
66617
66886
|
}
|
|
66618
66887
|
};
|
|
66619
66888
|
}
|
|
66889
|
+
|
|
66890
|
+
// src/hooks/index.ts
|
|
66891
|
+
init_extractors();
|
|
66892
|
+
|
|
66620
66893
|
// src/hooks/full-auto-intercept.ts
|
|
66894
|
+
init_critic();
|
|
66621
66895
|
init_schema();
|
|
66622
66896
|
init_file_locks();
|
|
66623
66897
|
init_state();
|
|
66624
66898
|
init_telemetry();
|
|
66899
|
+
init_logger();
|
|
66625
66900
|
init_utils2();
|
|
66626
66901
|
import * as fs35 from "node:fs";
|
|
66627
66902
|
var END_OF_SENTENCE_QUESTION_PATTERN = /\?\s*$/;
|
|
@@ -66930,7 +67205,7 @@ Critic reasoning: ${criticResult.reasoning}`
|
|
|
66930
67205
|
}
|
|
66931
67206
|
}
|
|
66932
67207
|
async function dispatchCriticAndWriteEvent(directory, architectOutput, criticContext, criticModel, escalationType, interactionCount, deadlockCount, oversightAgentName) {
|
|
66933
|
-
const client = swarmState.opencodeClient;
|
|
67208
|
+
const client = _internals9.swarmState.opencodeClient;
|
|
66934
67209
|
if (!client) {
|
|
66935
67210
|
warn("[full-auto-intercept] No opencodeClient — critic dispatch skipped (fallback to PENDING)");
|
|
66936
67211
|
const result = {
|
|
@@ -67050,12 +67325,11 @@ function createFullAutoInterceptHook(config3, directory) {
|
|
|
67050
67325
|
if (!architectText)
|
|
67051
67326
|
return;
|
|
67052
67327
|
const sessionID = architectMessage.info?.sessionID;
|
|
67053
|
-
if (!hasActiveFullAuto(sessionID))
|
|
67328
|
+
if (!_internals9.hasActiveFullAuto(sessionID))
|
|
67054
67329
|
return;
|
|
67055
67330
|
let session = null;
|
|
67056
67331
|
if (sessionID) {
|
|
67057
|
-
|
|
67058
|
-
session = ensureAgentSession2(sessionID);
|
|
67332
|
+
session = _internals9.ensureAgentSession(sessionID);
|
|
67059
67333
|
}
|
|
67060
67334
|
if (session) {
|
|
67061
67335
|
const interactionCount = session.fullAutoInteractionCount ?? 0;
|
|
@@ -67323,6 +67597,7 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
|
|
|
67323
67597
|
}
|
|
67324
67598
|
// src/hooks/pipeline-tracker.ts
|
|
67325
67599
|
init_manager();
|
|
67600
|
+
init_extractors();
|
|
67326
67601
|
init_utils2();
|
|
67327
67602
|
function parsePhaseNumber(phaseString) {
|
|
67328
67603
|
if (!phaseString)
|
|
@@ -67413,6 +67688,7 @@ import { realpathSync as realpathSync8 } from "node:fs";
|
|
|
67413
67688
|
import * as path58 from "node:path";
|
|
67414
67689
|
|
|
67415
67690
|
// src/tools/repo-graph/builder.ts
|
|
67691
|
+
init_logger();
|
|
67416
67692
|
init_path_security();
|
|
67417
67693
|
import * as fsSync3 from "node:fs";
|
|
67418
67694
|
import { existsSync as existsSync29, realpathSync as realpathSync6 } from "node:fs";
|
|
@@ -68321,12 +68597,14 @@ function getCachedMtime(workspace) {
|
|
|
68321
68597
|
return mtimeCache.get(path55.normalize(workspace));
|
|
68322
68598
|
}
|
|
68323
68599
|
// src/tools/repo-graph/incremental.ts
|
|
68600
|
+
init_logger();
|
|
68324
68601
|
import { existsSync as existsSync31 } from "node:fs";
|
|
68325
68602
|
import * as fsPromises7 from "node:fs/promises";
|
|
68326
68603
|
import * as path57 from "node:path";
|
|
68327
68604
|
|
|
68328
68605
|
// src/tools/repo-graph/storage.ts
|
|
68329
68606
|
init_utils2();
|
|
68607
|
+
init_logger();
|
|
68330
68608
|
init_path_security();
|
|
68331
68609
|
import { constants as constants4, existsSync as existsSync30, realpathSync as realpathSync7 } from "node:fs";
|
|
68332
68610
|
import * as fsPromises6 from "node:fs/promises";
|
|
@@ -68585,6 +68863,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
|
|
|
68585
68863
|
return graph;
|
|
68586
68864
|
}
|
|
68587
68865
|
// src/hooks/repo-graph-builder.ts
|
|
68866
|
+
init_logger();
|
|
68588
68867
|
var SUPPORTED_EXTENSIONS2 = [
|
|
68589
68868
|
".ts",
|
|
68590
68869
|
".tsx",
|
|
@@ -69373,6 +69652,7 @@ function rankCandidates(candidates, config3) {
|
|
|
69373
69652
|
}
|
|
69374
69653
|
|
|
69375
69654
|
// src/hooks/system-enhancer.ts
|
|
69655
|
+
init_extractors();
|
|
69376
69656
|
init_knowledge_store();
|
|
69377
69657
|
|
|
69378
69658
|
// src/hooks/repo-graph-injection.ts
|
|
@@ -73272,8 +73552,64 @@ init_manager();
|
|
|
73272
73552
|
// src/services/run-memory.ts
|
|
73273
73553
|
init_utils2();
|
|
73274
73554
|
init_path_security();
|
|
73555
|
+
import * as crypto8 from "node:crypto";
|
|
73556
|
+
import * as fs48 from "node:fs/promises";
|
|
73275
73557
|
var RUN_MEMORY_FILENAME = "run-memory.jsonl";
|
|
73276
73558
|
var MAX_SUMMARY_TOKENS = 500;
|
|
73559
|
+
function generateTaskFingerprint(taskId, fileTargets) {
|
|
73560
|
+
const sortedFiles = [...fileTargets].sort().join(",");
|
|
73561
|
+
const hash3 = crypto8.createHash("sha256").update(taskId + sortedFiles).digest("hex");
|
|
73562
|
+
return hash3.slice(0, 8);
|
|
73563
|
+
}
|
|
73564
|
+
async function recordOutcome(directory, entry) {
|
|
73565
|
+
validateDirectory(directory);
|
|
73566
|
+
const resolvedPath = validateSwarmPath(directory, RUN_MEMORY_FILENAME);
|
|
73567
|
+
const line = `${JSON.stringify(entry)}
|
|
73568
|
+
`;
|
|
73569
|
+
await fs48.appendFile(resolvedPath, line, { encoding: "utf-8" });
|
|
73570
|
+
}
|
|
73571
|
+
async function getTaskHistory(directory, taskId) {
|
|
73572
|
+
validateDirectory(directory);
|
|
73573
|
+
const content = await readSwarmFileAsync(directory, RUN_MEMORY_FILENAME);
|
|
73574
|
+
if (!content) {
|
|
73575
|
+
return [];
|
|
73576
|
+
}
|
|
73577
|
+
const entries = [];
|
|
73578
|
+
const lines = content.split(`
|
|
73579
|
+
`);
|
|
73580
|
+
for (const line of lines) {
|
|
73581
|
+
if (!line.trim())
|
|
73582
|
+
continue;
|
|
73583
|
+
try {
|
|
73584
|
+
const entry = JSON.parse(line);
|
|
73585
|
+
if (entry.taskId === taskId) {
|
|
73586
|
+
entries.push(entry);
|
|
73587
|
+
}
|
|
73588
|
+
} catch {}
|
|
73589
|
+
}
|
|
73590
|
+
return entries;
|
|
73591
|
+
}
|
|
73592
|
+
async function getFailures(directory) {
|
|
73593
|
+
validateDirectory(directory);
|
|
73594
|
+
const content = await readSwarmFileAsync(directory, RUN_MEMORY_FILENAME);
|
|
73595
|
+
if (!content) {
|
|
73596
|
+
return [];
|
|
73597
|
+
}
|
|
73598
|
+
const entries = [];
|
|
73599
|
+
const lines = content.split(`
|
|
73600
|
+
`);
|
|
73601
|
+
for (const line of lines) {
|
|
73602
|
+
if (!line.trim())
|
|
73603
|
+
continue;
|
|
73604
|
+
try {
|
|
73605
|
+
const entry = JSON.parse(line);
|
|
73606
|
+
if (entry.outcome === "fail" || entry.outcome === "retry") {
|
|
73607
|
+
entries.push(entry);
|
|
73608
|
+
}
|
|
73609
|
+
} catch {}
|
|
73610
|
+
}
|
|
73611
|
+
return entries;
|
|
73612
|
+
}
|
|
73277
73613
|
function groupByTaskId(entries) {
|
|
73278
73614
|
const groups = new Map;
|
|
73279
73615
|
for (const entry of entries) {
|
|
@@ -73322,10 +73658,10 @@ async function getRunMemorySummary(directory) {
|
|
|
73322
73658
|
if (entries.length === 0) {
|
|
73323
73659
|
return null;
|
|
73324
73660
|
}
|
|
73325
|
-
const groups = groupByTaskId(entries);
|
|
73661
|
+
const groups = _internals26.groupByTaskId(entries);
|
|
73326
73662
|
const summaries = [];
|
|
73327
73663
|
for (const [taskId, taskEntries] of groups) {
|
|
73328
|
-
const summary = summarizeTask(taskId, taskEntries);
|
|
73664
|
+
const summary = _internals26.summarizeTask(taskId, taskEntries);
|
|
73329
73665
|
if (summary) {
|
|
73330
73666
|
summaries.push(summary);
|
|
73331
73667
|
}
|
|
@@ -73358,9 +73694,20 @@ Use this data to avoid repeating known failure patterns.`;
|
|
|
73358
73694
|
}
|
|
73359
73695
|
return prefix + summaryText + suffix;
|
|
73360
73696
|
}
|
|
73697
|
+
var _internals26 = {
|
|
73698
|
+
generateTaskFingerprint,
|
|
73699
|
+
recordOutcome,
|
|
73700
|
+
getTaskHistory,
|
|
73701
|
+
getFailures,
|
|
73702
|
+
getRunMemorySummary,
|
|
73703
|
+
groupByTaskId,
|
|
73704
|
+
summarizeTask
|
|
73705
|
+
};
|
|
73361
73706
|
|
|
73362
73707
|
// src/hooks/knowledge-injector.ts
|
|
73708
|
+
init_logger();
|
|
73363
73709
|
init_curator_drift();
|
|
73710
|
+
init_extractors();
|
|
73364
73711
|
init_knowledge_reader();
|
|
73365
73712
|
init_knowledge_store();
|
|
73366
73713
|
init_utils2();
|
|
@@ -73655,7 +74002,7 @@ function createSelfReviewHook(config3, injectAdvisory) {
|
|
|
73655
74002
|
}
|
|
73656
74003
|
|
|
73657
74004
|
// src/hooks/slop-detector.ts
|
|
73658
|
-
import * as
|
|
74005
|
+
import * as fs50 from "node:fs";
|
|
73659
74006
|
import * as path72 from "node:path";
|
|
73660
74007
|
var WRITE_EDIT_TOOLS = new Set([
|
|
73661
74008
|
"write",
|
|
@@ -73701,7 +74048,7 @@ function checkBoilerplateExplosion(content, taskDescription, threshold) {
|
|
|
73701
74048
|
function walkFiles(dir, exts, deadline) {
|
|
73702
74049
|
const results = [];
|
|
73703
74050
|
try {
|
|
73704
|
-
for (const entry of
|
|
74051
|
+
for (const entry of fs50.readdirSync(dir, { withFileTypes: true })) {
|
|
73705
74052
|
if (deadline !== undefined && Date.now() > deadline)
|
|
73706
74053
|
break;
|
|
73707
74054
|
if (entry.isSymbolicLink())
|
|
@@ -73721,7 +74068,7 @@ function walkFiles(dir, exts, deadline) {
|
|
|
73721
74068
|
return results;
|
|
73722
74069
|
}
|
|
73723
74070
|
function checkDeadExports(content, projectDir, startTime) {
|
|
73724
|
-
const hasPackageJson =
|
|
74071
|
+
const hasPackageJson = fs50.existsSync(path72.join(projectDir, "package.json"));
|
|
73725
74072
|
if (!hasPackageJson)
|
|
73726
74073
|
return null;
|
|
73727
74074
|
const exportMatches = content.matchAll(/^\+(?:export)\s+(?:function|class|const|type|interface)\s+(\w{3,})/gm);
|
|
@@ -73744,7 +74091,7 @@ function checkDeadExports(content, projectDir, startTime) {
|
|
|
73744
74091
|
if (found || Date.now() - startTime > 480)
|
|
73745
74092
|
break;
|
|
73746
74093
|
try {
|
|
73747
|
-
const text =
|
|
74094
|
+
const text = fs50.readFileSync(file3, "utf-8");
|
|
73748
74095
|
if (importPattern.test(text))
|
|
73749
74096
|
found = true;
|
|
73750
74097
|
importPattern.lastIndex = 0;
|
|
@@ -73836,7 +74183,7 @@ function checkDuplicateUtility(content, projectDir, startTime, targetFile) {
|
|
|
73836
74183
|
if (Date.now() > deadline)
|
|
73837
74184
|
break;
|
|
73838
74185
|
const utilPath = path72.join(projectDir, utilDir);
|
|
73839
|
-
if (!
|
|
74186
|
+
if (!fs50.existsSync(utilPath))
|
|
73840
74187
|
continue;
|
|
73841
74188
|
const files = walkFiles(utilPath, [".ts", ".tsx", ".js", ".jsx"], deadline);
|
|
73842
74189
|
for (const file3 of files) {
|
|
@@ -73845,7 +74192,7 @@ function checkDuplicateUtility(content, projectDir, startTime, targetFile) {
|
|
|
73845
74192
|
if (targetFile && path72.resolve(file3) === path72.resolve(targetFile))
|
|
73846
74193
|
continue;
|
|
73847
74194
|
try {
|
|
73848
|
-
const text =
|
|
74195
|
+
const text = fs50.readFileSync(file3, "utf-8");
|
|
73849
74196
|
for (const name2 of newExports) {
|
|
73850
74197
|
const exportPattern = new RegExp(`\\bexport\\s+(?:function|class|const|type|interface)\\s+${name2}\\b`);
|
|
73851
74198
|
if (exportPattern.test(text)) {
|
|
@@ -73928,7 +74275,7 @@ Review before proceeding.`;
|
|
|
73928
74275
|
// src/hooks/steering-consumed.ts
|
|
73929
74276
|
init_bun_compat();
|
|
73930
74277
|
init_utils2();
|
|
73931
|
-
import * as
|
|
74278
|
+
import * as fs51 from "node:fs";
|
|
73932
74279
|
function recordSteeringConsumed(directory, directiveId) {
|
|
73933
74280
|
try {
|
|
73934
74281
|
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
@@ -73937,7 +74284,7 @@ function recordSteeringConsumed(directory, directiveId) {
|
|
|
73937
74284
|
directiveId,
|
|
73938
74285
|
timestamp: new Date().toISOString()
|
|
73939
74286
|
};
|
|
73940
|
-
|
|
74287
|
+
fs51.appendFileSync(eventsPath, `${JSON.stringify(event)}
|
|
73941
74288
|
`, "utf-8");
|
|
73942
74289
|
} catch {}
|
|
73943
74290
|
}
|
|
@@ -73979,12 +74326,12 @@ function createSteeringConsumedHook(directory) {
|
|
|
73979
74326
|
|
|
73980
74327
|
// src/hooks/trajectory-logger.ts
|
|
73981
74328
|
init_manager2();
|
|
73982
|
-
import * as
|
|
74329
|
+
import * as fs53 from "node:fs/promises";
|
|
73983
74330
|
import * as path74 from "node:path";
|
|
73984
74331
|
|
|
73985
74332
|
// src/prm/trajectory-store.ts
|
|
73986
74333
|
init_utils2();
|
|
73987
|
-
import * as
|
|
74334
|
+
import * as fs52 from "node:fs/promises";
|
|
73988
74335
|
import * as path73 from "node:path";
|
|
73989
74336
|
function getTrajectoryPath(sessionId, directory) {
|
|
73990
74337
|
const relativePath = path73.join("trajectories", `${sessionId}.jsonl`);
|
|
@@ -74006,10 +74353,10 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
|
|
|
74006
74353
|
_inMemoryTrajectoryCache.set(sessionId, cached3);
|
|
74007
74354
|
}
|
|
74008
74355
|
const trajectoryPath = getTrajectoryPath(sessionId, directory);
|
|
74009
|
-
await
|
|
74356
|
+
await fs52.mkdir(path73.dirname(trajectoryPath), { recursive: true });
|
|
74010
74357
|
const line = `${JSON.stringify(entry)}
|
|
74011
74358
|
`;
|
|
74012
|
-
await
|
|
74359
|
+
await fs52.appendFile(trajectoryPath, line, "utf-8");
|
|
74013
74360
|
} catch (err2) {
|
|
74014
74361
|
console.warn(`[trajectory-store] Failed to append trajectory entry: ${err2}`);
|
|
74015
74362
|
}
|
|
@@ -74017,7 +74364,7 @@ async function appendTrajectoryEntry(sessionId, entry, directory, maxLines = 100
|
|
|
74017
74364
|
async function readTrajectory(sessionId, directory) {
|
|
74018
74365
|
try {
|
|
74019
74366
|
const trajectoryPath = getTrajectoryPath(sessionId, directory);
|
|
74020
|
-
const content = await
|
|
74367
|
+
const content = await fs52.readFile(trajectoryPath, "utf-8");
|
|
74021
74368
|
const lines = content.split(`
|
|
74022
74369
|
`).filter((line) => line.trim().length > 0);
|
|
74023
74370
|
const entries = [];
|
|
@@ -74041,15 +74388,15 @@ async function cleanupOldTrajectoryFiles(directory, maxAgeDays = 7) {
|
|
|
74041
74388
|
for (const subdir of ["trajectories", "replays"]) {
|
|
74042
74389
|
try {
|
|
74043
74390
|
const dirPath = validateSwarmPath(directory, subdir);
|
|
74044
|
-
const entries = await
|
|
74391
|
+
const entries = await fs52.readdir(dirPath, { withFileTypes: true });
|
|
74045
74392
|
for (const entry of entries) {
|
|
74046
74393
|
if (!entry.isFile())
|
|
74047
74394
|
continue;
|
|
74048
74395
|
const filePath = path73.join(dirPath, entry.name);
|
|
74049
74396
|
try {
|
|
74050
|
-
const stat7 = await
|
|
74397
|
+
const stat7 = await fs52.stat(filePath);
|
|
74051
74398
|
if (now - stat7.mtimeMs > cutoffMs) {
|
|
74052
|
-
await
|
|
74399
|
+
await fs52.unlink(filePath);
|
|
74053
74400
|
}
|
|
74054
74401
|
} catch {}
|
|
74055
74402
|
}
|
|
@@ -74099,7 +74446,7 @@ function isSensitiveKey(key) {
|
|
|
74099
74446
|
}
|
|
74100
74447
|
async function truncateTrajectoryFile(filePath, maxLines) {
|
|
74101
74448
|
try {
|
|
74102
|
-
const content = await
|
|
74449
|
+
const content = await fs53.readFile(filePath, "utf-8");
|
|
74103
74450
|
const lines = content.split(`
|
|
74104
74451
|
`).filter((line) => line.trim().length > 0);
|
|
74105
74452
|
if (lines.length <= maxLines) {
|
|
@@ -74107,7 +74454,7 @@ async function truncateTrajectoryFile(filePath, maxLines) {
|
|
|
74107
74454
|
}
|
|
74108
74455
|
const keepCount = Math.floor(maxLines / 2);
|
|
74109
74456
|
const keptLines = lines.slice(-keepCount);
|
|
74110
|
-
await
|
|
74457
|
+
await fs53.writeFile(filePath, `${keptLines.join(`
|
|
74111
74458
|
`)}
|
|
74112
74459
|
`, "utf-8");
|
|
74113
74460
|
} catch {}
|
|
@@ -74240,10 +74587,10 @@ function createTrajectoryLoggerHook(config3, _directory) {
|
|
|
74240
74587
|
const relativePath = path74.join("evidence", sanitized, "trajectory.jsonl");
|
|
74241
74588
|
const trajectoryPath = validateSwarmPath(_directory, relativePath);
|
|
74242
74589
|
try {
|
|
74243
|
-
await
|
|
74590
|
+
await fs53.mkdir(path74.dirname(trajectoryPath), { recursive: true });
|
|
74244
74591
|
const line = `${JSON.stringify(entry)}
|
|
74245
74592
|
`;
|
|
74246
|
-
await
|
|
74593
|
+
await fs53.appendFile(trajectoryPath, line, "utf-8");
|
|
74247
74594
|
await truncateTrajectoryFile(trajectoryPath, maxLines);
|
|
74248
74595
|
} catch {}
|
|
74249
74596
|
try {
|
|
@@ -74790,7 +75137,7 @@ init_state();
|
|
|
74790
75137
|
init_telemetry();
|
|
74791
75138
|
|
|
74792
75139
|
// src/prm/replay.ts
|
|
74793
|
-
import { promises as
|
|
75140
|
+
import { promises as fs54 } from "node:fs";
|
|
74794
75141
|
import path75 from "node:path";
|
|
74795
75142
|
function isPathSafe2(targetPath, basePath) {
|
|
74796
75143
|
const resolvedTarget = path75.resolve(targetPath);
|
|
@@ -74821,7 +75168,7 @@ async function startReplayRecording(sessionID, directory) {
|
|
|
74821
75168
|
console.warn(`[replay] Invalid path detected - path traversal attempt blocked for session ${sessionID}`);
|
|
74822
75169
|
return null;
|
|
74823
75170
|
}
|
|
74824
|
-
await
|
|
75171
|
+
await fs54.mkdir(replayDir, { recursive: true });
|
|
74825
75172
|
return filepath;
|
|
74826
75173
|
} catch (err2) {
|
|
74827
75174
|
console.warn(`[replay] Failed to start recording for session ${sessionID}: ${err2}`);
|
|
@@ -74841,7 +75188,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
|
|
|
74841
75188
|
};
|
|
74842
75189
|
const line = `${JSON.stringify(fullEntry)}
|
|
74843
75190
|
`;
|
|
74844
|
-
await
|
|
75191
|
+
await fs54.appendFile(artifactPath, line, "utf-8");
|
|
74845
75192
|
} catch (err2) {
|
|
74846
75193
|
console.warn(`[replay] Failed to record entry: ${err2}`);
|
|
74847
75194
|
}
|
|
@@ -75189,7 +75536,7 @@ init_telemetry();
|
|
|
75189
75536
|
// src/tools/batch-symbols.ts
|
|
75190
75537
|
init_dist();
|
|
75191
75538
|
init_create_tool();
|
|
75192
|
-
import * as
|
|
75539
|
+
import * as fs55 from "node:fs";
|
|
75193
75540
|
import * as path76 from "node:path";
|
|
75194
75541
|
init_path_security();
|
|
75195
75542
|
var WINDOWS_RESERVED_NAMES2 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
@@ -75208,11 +75555,11 @@ function containsWindowsAttacks2(str) {
|
|
|
75208
75555
|
function isPathInWorkspace2(filePath, workspace) {
|
|
75209
75556
|
try {
|
|
75210
75557
|
const resolvedPath = path76.resolve(workspace, filePath);
|
|
75211
|
-
if (!
|
|
75558
|
+
if (!fs55.existsSync(resolvedPath)) {
|
|
75212
75559
|
return true;
|
|
75213
75560
|
}
|
|
75214
|
-
const realWorkspace =
|
|
75215
|
-
const realResolvedPath =
|
|
75561
|
+
const realWorkspace = fs55.realpathSync(workspace);
|
|
75562
|
+
const realResolvedPath = fs55.realpathSync(resolvedPath);
|
|
75216
75563
|
const relativePath = path76.relative(realWorkspace, realResolvedPath);
|
|
75217
75564
|
if (relativePath.startsWith("..") || path76.isAbsolute(relativePath)) {
|
|
75218
75565
|
return false;
|
|
@@ -75257,7 +75604,7 @@ function processFile2(file3, cwd, exportedOnly) {
|
|
|
75257
75604
|
};
|
|
75258
75605
|
}
|
|
75259
75606
|
const fullPath = path76.join(cwd, file3);
|
|
75260
|
-
if (!
|
|
75607
|
+
if (!fs55.existsSync(fullPath)) {
|
|
75261
75608
|
return {
|
|
75262
75609
|
file: file3,
|
|
75263
75610
|
success: false,
|
|
@@ -75288,14 +75635,14 @@ function processFile2(file3, cwd, exportedOnly) {
|
|
|
75288
75635
|
}
|
|
75289
75636
|
let isEmptyFile = false;
|
|
75290
75637
|
try {
|
|
75291
|
-
const stats =
|
|
75638
|
+
const stats = fs55.statSync(fullPath);
|
|
75292
75639
|
if (stats.size === 0) {
|
|
75293
75640
|
isEmptyFile = true;
|
|
75294
75641
|
}
|
|
75295
75642
|
} catch {}
|
|
75296
75643
|
if (syms.length === 0) {
|
|
75297
75644
|
try {
|
|
75298
|
-
const content =
|
|
75645
|
+
const content = fs55.readFileSync(fullPath, "utf-8");
|
|
75299
75646
|
if (content.trim().length === 0) {
|
|
75300
75647
|
isEmptyFile = true;
|
|
75301
75648
|
}
|
|
@@ -75547,7 +75894,7 @@ init_manager2();
|
|
|
75547
75894
|
init_task_id();
|
|
75548
75895
|
init_create_tool();
|
|
75549
75896
|
init_resolve_working_directory();
|
|
75550
|
-
import * as
|
|
75897
|
+
import * as fs56 from "node:fs";
|
|
75551
75898
|
import * as path77 from "node:path";
|
|
75552
75899
|
var EVIDENCE_DIR = ".swarm/evidence";
|
|
75553
75900
|
function isValidTaskId3(taskId) {
|
|
@@ -75560,12 +75907,12 @@ function isPathWithinSwarm(filePath, workspaceRoot) {
|
|
|
75560
75907
|
return normalizedPath.startsWith(swarmPath);
|
|
75561
75908
|
}
|
|
75562
75909
|
function readEvidenceFile(evidencePath) {
|
|
75563
|
-
if (!
|
|
75910
|
+
if (!fs56.existsSync(evidencePath)) {
|
|
75564
75911
|
return null;
|
|
75565
75912
|
}
|
|
75566
75913
|
let content;
|
|
75567
75914
|
try {
|
|
75568
|
-
content =
|
|
75915
|
+
content = fs56.readFileSync(evidencePath, "utf-8");
|
|
75569
75916
|
} catch {
|
|
75570
75917
|
return null;
|
|
75571
75918
|
}
|
|
@@ -75733,7 +76080,7 @@ init_utils2();
|
|
|
75733
76080
|
init_state();
|
|
75734
76081
|
init_create_tool();
|
|
75735
76082
|
init_resolve_working_directory();
|
|
75736
|
-
import * as
|
|
76083
|
+
import * as fs57 from "node:fs";
|
|
75737
76084
|
import * as path78 from "node:path";
|
|
75738
76085
|
function extractMatches(regex, text) {
|
|
75739
76086
|
return Array.from(text.matchAll(regex));
|
|
@@ -75828,7 +76175,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
75828
76175
|
let plan;
|
|
75829
76176
|
try {
|
|
75830
76177
|
const planPath = validateSwarmPath(directory, "plan.json");
|
|
75831
|
-
const planRaw =
|
|
76178
|
+
const planRaw = fs57.readFileSync(planPath, "utf-8");
|
|
75832
76179
|
plan = JSON.parse(planRaw);
|
|
75833
76180
|
} catch {
|
|
75834
76181
|
const result2 = {
|
|
@@ -75902,7 +76249,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
75902
76249
|
}
|
|
75903
76250
|
let fileContent;
|
|
75904
76251
|
try {
|
|
75905
|
-
fileContent =
|
|
76252
|
+
fileContent = fs57.readFileSync(resolvedPath, "utf-8");
|
|
75906
76253
|
} catch {
|
|
75907
76254
|
blockedTasks.push({
|
|
75908
76255
|
task_id: task.id,
|
|
@@ -75946,7 +76293,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
75946
76293
|
try {
|
|
75947
76294
|
const evidenceDir = path78.join(directory, ".swarm", "evidence", `${phase}`);
|
|
75948
76295
|
const evidencePath = path78.join(evidenceDir, "completion-verify.json");
|
|
75949
|
-
|
|
76296
|
+
fs57.mkdirSync(evidenceDir, { recursive: true });
|
|
75950
76297
|
const evidenceBundle = {
|
|
75951
76298
|
schema_version: "1.0.0",
|
|
75952
76299
|
task_id: "completion-verify",
|
|
@@ -75967,7 +76314,7 @@ async function executeCompletionVerify(args2, directory) {
|
|
|
75967
76314
|
}
|
|
75968
76315
|
]
|
|
75969
76316
|
};
|
|
75970
|
-
|
|
76317
|
+
fs57.writeFileSync(evidencePath, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
75971
76318
|
} catch {}
|
|
75972
76319
|
return JSON.stringify(result, null, 2);
|
|
75973
76320
|
}
|
|
@@ -76021,11 +76368,11 @@ var completion_verify = createSwarmTool({
|
|
|
76021
76368
|
});
|
|
76022
76369
|
// src/tools/complexity-hotspots.ts
|
|
76023
76370
|
init_zod();
|
|
76024
|
-
import * as
|
|
76371
|
+
import * as fs59 from "node:fs";
|
|
76025
76372
|
import * as path80 from "node:path";
|
|
76026
76373
|
|
|
76027
76374
|
// src/quality/metrics.ts
|
|
76028
|
-
import * as
|
|
76375
|
+
import * as fs58 from "node:fs";
|
|
76029
76376
|
import * as path79 from "node:path";
|
|
76030
76377
|
var MAX_FILE_SIZE_BYTES4 = 256 * 1024;
|
|
76031
76378
|
var MIN_DUPLICATION_LINES = 10;
|
|
@@ -76064,11 +76411,11 @@ function estimateCyclomaticComplexity(content) {
|
|
|
76064
76411
|
}
|
|
76065
76412
|
function getComplexityForFile(filePath) {
|
|
76066
76413
|
try {
|
|
76067
|
-
const stat7 =
|
|
76414
|
+
const stat7 = fs58.statSync(filePath);
|
|
76068
76415
|
if (stat7.size > MAX_FILE_SIZE_BYTES4) {
|
|
76069
76416
|
return null;
|
|
76070
76417
|
}
|
|
76071
|
-
const content =
|
|
76418
|
+
const content = fs58.readFileSync(filePath, "utf-8");
|
|
76072
76419
|
return estimateCyclomaticComplexity(content);
|
|
76073
76420
|
} catch {
|
|
76074
76421
|
return null;
|
|
@@ -76079,7 +76426,7 @@ async function computeComplexityDelta(files, workingDir) {
|
|
|
76079
76426
|
const analyzedFiles = [];
|
|
76080
76427
|
for (const file3 of files) {
|
|
76081
76428
|
const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
|
|
76082
|
-
if (!
|
|
76429
|
+
if (!fs58.existsSync(fullPath)) {
|
|
76083
76430
|
continue;
|
|
76084
76431
|
}
|
|
76085
76432
|
const complexity = getComplexityForFile(fullPath);
|
|
@@ -76200,7 +76547,7 @@ function countGoExports(content) {
|
|
|
76200
76547
|
}
|
|
76201
76548
|
function getExportCountForFile(filePath) {
|
|
76202
76549
|
try {
|
|
76203
|
-
const content =
|
|
76550
|
+
const content = fs58.readFileSync(filePath, "utf-8");
|
|
76204
76551
|
const ext = path79.extname(filePath).toLowerCase();
|
|
76205
76552
|
switch (ext) {
|
|
76206
76553
|
case ".ts":
|
|
@@ -76228,7 +76575,7 @@ async function computePublicApiDelta(files, workingDir) {
|
|
|
76228
76575
|
const analyzedFiles = [];
|
|
76229
76576
|
for (const file3 of files) {
|
|
76230
76577
|
const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
|
|
76231
|
-
if (!
|
|
76578
|
+
if (!fs58.existsSync(fullPath)) {
|
|
76232
76579
|
continue;
|
|
76233
76580
|
}
|
|
76234
76581
|
const exports = getExportCountForFile(fullPath);
|
|
@@ -76262,15 +76609,15 @@ async function computeDuplicationRatio(files, workingDir) {
|
|
|
76262
76609
|
const analyzedFiles = [];
|
|
76263
76610
|
for (const file3 of files) {
|
|
76264
76611
|
const fullPath = path79.isAbsolute(file3) ? file3 : path79.join(workingDir, file3);
|
|
76265
|
-
if (!
|
|
76612
|
+
if (!fs58.existsSync(fullPath)) {
|
|
76266
76613
|
continue;
|
|
76267
76614
|
}
|
|
76268
76615
|
try {
|
|
76269
|
-
const stat7 =
|
|
76616
|
+
const stat7 = fs58.statSync(fullPath);
|
|
76270
76617
|
if (stat7.size > MAX_FILE_SIZE_BYTES4) {
|
|
76271
76618
|
continue;
|
|
76272
76619
|
}
|
|
76273
|
-
const content =
|
|
76620
|
+
const content = fs58.readFileSync(fullPath, "utf-8");
|
|
76274
76621
|
const lines = content.split(`
|
|
76275
76622
|
`).filter((line) => line.trim().length > 0);
|
|
76276
76623
|
if (lines.length < MIN_DUPLICATION_LINES) {
|
|
@@ -76446,7 +76793,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
76446
76793
|
let testLines = 0;
|
|
76447
76794
|
let codeLines = 0;
|
|
76448
76795
|
const srcDir = path79.join(workingDir, "src");
|
|
76449
|
-
if (
|
|
76796
|
+
if (fs58.existsSync(srcDir)) {
|
|
76450
76797
|
await scanDirectoryForLines(srcDir, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
76451
76798
|
codeLines += lines;
|
|
76452
76799
|
});
|
|
@@ -76454,14 +76801,14 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
76454
76801
|
const possibleSrcDirs = ["lib", "app", "source", "core"];
|
|
76455
76802
|
for (const dir of possibleSrcDirs) {
|
|
76456
76803
|
const dirPath = path79.join(workingDir, dir);
|
|
76457
|
-
if (
|
|
76804
|
+
if (fs58.existsSync(dirPath)) {
|
|
76458
76805
|
await scanDirectoryForLines(dirPath, enforceGlobs, excludeGlobs, false, (lines) => {
|
|
76459
76806
|
codeLines += lines;
|
|
76460
76807
|
});
|
|
76461
76808
|
}
|
|
76462
76809
|
}
|
|
76463
76810
|
const testsDir = path79.join(workingDir, "tests");
|
|
76464
|
-
if (
|
|
76811
|
+
if (fs58.existsSync(testsDir)) {
|
|
76465
76812
|
await scanDirectoryForLines(testsDir, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
76466
76813
|
testLines += lines;
|
|
76467
76814
|
});
|
|
@@ -76469,7 +76816,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
76469
76816
|
const possibleTestDirs = ["test", "__tests__", "specs"];
|
|
76470
76817
|
for (const dir of possibleTestDirs) {
|
|
76471
76818
|
const dirPath = path79.join(workingDir, dir);
|
|
76472
|
-
if (
|
|
76819
|
+
if (fs58.existsSync(dirPath) && dirPath !== testsDir) {
|
|
76473
76820
|
await scanDirectoryForLines(dirPath, ["**"], ["node_modules", "dist"], true, (lines) => {
|
|
76474
76821
|
testLines += lines;
|
|
76475
76822
|
});
|
|
@@ -76481,7 +76828,7 @@ async function computeTestToCodeRatio(workingDir, enforceGlobs, excludeGlobs) {
|
|
|
76481
76828
|
}
|
|
76482
76829
|
async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTestScan, callback) {
|
|
76483
76830
|
try {
|
|
76484
|
-
const entries =
|
|
76831
|
+
const entries = fs58.readdirSync(dirPath, { withFileTypes: true });
|
|
76485
76832
|
for (const entry of entries) {
|
|
76486
76833
|
const fullPath = path79.join(dirPath, entry.name);
|
|
76487
76834
|
if (entry.isDirectory()) {
|
|
@@ -76527,7 +76874,7 @@ async function scanDirectoryForLines(dirPath, includeGlobs, excludeGlobs, isTest
|
|
|
76527
76874
|
continue;
|
|
76528
76875
|
}
|
|
76529
76876
|
try {
|
|
76530
|
-
const content =
|
|
76877
|
+
const content = fs58.readFileSync(fullPath, "utf-8");
|
|
76531
76878
|
const lines = countCodeLines(content);
|
|
76532
76879
|
callback(lines);
|
|
76533
76880
|
} catch {}
|
|
@@ -76727,11 +77074,11 @@ async function getGitChurn(days, directory) {
|
|
|
76727
77074
|
}
|
|
76728
77075
|
function getComplexityForFile2(filePath) {
|
|
76729
77076
|
try {
|
|
76730
|
-
const stat7 =
|
|
77077
|
+
const stat7 = fs59.statSync(filePath);
|
|
76731
77078
|
if (stat7.size > MAX_FILE_SIZE_BYTES5) {
|
|
76732
77079
|
return null;
|
|
76733
77080
|
}
|
|
76734
|
-
const content =
|
|
77081
|
+
const content = fs59.readFileSync(filePath, "utf-8");
|
|
76735
77082
|
return estimateCyclomaticComplexity(content);
|
|
76736
77083
|
} catch {
|
|
76737
77084
|
return null;
|
|
@@ -76752,7 +77099,7 @@ async function analyzeHotspots(days, topN, extensions, directory) {
|
|
|
76752
77099
|
let analyzedFiles = 0;
|
|
76753
77100
|
for (const [file3, churnCount] of filteredChurn) {
|
|
76754
77101
|
let fullPath = file3;
|
|
76755
|
-
if (!
|
|
77102
|
+
if (!fs59.existsSync(fullPath)) {
|
|
76756
77103
|
fullPath = path80.join(cwd, file3);
|
|
76757
77104
|
}
|
|
76758
77105
|
const complexity = getComplexityForFile2(fullPath);
|
|
@@ -77013,7 +77360,7 @@ function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
77013
77360
|
}
|
|
77014
77361
|
|
|
77015
77362
|
// src/council/council-service.ts
|
|
77016
|
-
import
|
|
77363
|
+
import fs60 from "node:fs";
|
|
77017
77364
|
import path81 from "node:path";
|
|
77018
77365
|
|
|
77019
77366
|
// src/council/types.ts
|
|
@@ -77175,7 +77522,7 @@ function synthesizePhaseCouncilAdvisory(phaseNumber, phaseSummary, verdicts, rou
|
|
|
77175
77522
|
const evidencePath = `.swarm/evidence/${phaseNumber}/phase-council.json`;
|
|
77176
77523
|
const baseDir = workingDir ?? process.cwd();
|
|
77177
77524
|
const evidenceDir = path81.join(baseDir, ".swarm", "evidence", String(phaseNumber));
|
|
77178
|
-
|
|
77525
|
+
fs60.mkdirSync(evidenceDir, { recursive: true });
|
|
77179
77526
|
const evidenceFile = path81.join(evidenceDir, "phase-council.json");
|
|
77180
77527
|
const evidenceBundle = {
|
|
77181
77528
|
entries: [
|
|
@@ -77209,8 +77556,8 @@ function synthesizePhaseCouncilAdvisory(phaseNumber, phaseSummary, verdicts, rou
|
|
|
77209
77556
|
};
|
|
77210
77557
|
try {
|
|
77211
77558
|
const tempFile = `${evidenceFile}.tmp-${Date.now()}`;
|
|
77212
|
-
|
|
77213
|
-
|
|
77559
|
+
fs60.writeFileSync(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
|
|
77560
|
+
fs60.renameSync(tempFile, evidenceFile);
|
|
77214
77561
|
} catch (writeErr) {
|
|
77215
77562
|
console.warn(`[phase-council] Failed to write phase-council evidence to ${evidenceFile}: ${writeErr instanceof Error ? writeErr.message : String(writeErr)}`);
|
|
77216
77563
|
}
|
|
@@ -77445,7 +77792,7 @@ var submit_council_verdicts = createSwarmTool({
|
|
|
77445
77792
|
// src/tools/convene-general-council.ts
|
|
77446
77793
|
init_zod();
|
|
77447
77794
|
init_loader();
|
|
77448
|
-
import * as
|
|
77795
|
+
import * as fs61 from "node:fs";
|
|
77449
77796
|
import * as path82 from "node:path";
|
|
77450
77797
|
|
|
77451
77798
|
// src/council/general-council-advisory.ts
|
|
@@ -77879,8 +78226,8 @@ var convene_general_council = createSwarmTool({
|
|
|
77879
78226
|
const evidenceFile = `${safeTimestamp}-${input.mode}.json`;
|
|
77880
78227
|
const evidencePath = path82.join(evidenceDir, evidenceFile);
|
|
77881
78228
|
try {
|
|
77882
|
-
await
|
|
77883
|
-
await
|
|
78229
|
+
await fs61.promises.mkdir(evidenceDir, { recursive: true });
|
|
78230
|
+
await fs61.promises.writeFile(evidencePath, JSON.stringify(result, null, 2));
|
|
77884
78231
|
} catch (err2) {
|
|
77885
78232
|
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
77886
78233
|
console.warn(`[convene_general_council] Failed to write evidence to ${evidencePath}: ${message}`);
|
|
@@ -78111,7 +78458,7 @@ init_scope_persistence();
|
|
|
78111
78458
|
init_state();
|
|
78112
78459
|
init_task_id();
|
|
78113
78460
|
init_create_tool();
|
|
78114
|
-
import * as
|
|
78461
|
+
import * as fs62 from "node:fs";
|
|
78115
78462
|
import * as path83 from "node:path";
|
|
78116
78463
|
function validateTaskIdFormat2(taskId) {
|
|
78117
78464
|
return validateTaskIdFormat(taskId);
|
|
@@ -78199,9 +78546,9 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
78199
78546
|
}
|
|
78200
78547
|
const resolvedDir = path83.resolve(normalizedDir);
|
|
78201
78548
|
try {
|
|
78202
|
-
const realPath =
|
|
78549
|
+
const realPath = fs62.realpathSync(resolvedDir);
|
|
78203
78550
|
const planPath2 = path83.join(realPath, ".swarm", "plan.json");
|
|
78204
|
-
if (!
|
|
78551
|
+
if (!fs62.existsSync(planPath2)) {
|
|
78205
78552
|
return {
|
|
78206
78553
|
success: false,
|
|
78207
78554
|
message: `Invalid working_directory: plan not found in "${realPath}"`,
|
|
@@ -78225,7 +78572,7 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
78225
78572
|
}
|
|
78226
78573
|
const directory = normalizedDir || fallbackDir;
|
|
78227
78574
|
const planPath = path83.resolve(directory, ".swarm", "plan.json");
|
|
78228
|
-
if (!
|
|
78575
|
+
if (!fs62.existsSync(planPath)) {
|
|
78229
78576
|
return {
|
|
78230
78577
|
success: false,
|
|
78231
78578
|
message: "No plan found",
|
|
@@ -78234,7 +78581,7 @@ async function executeDeclareScope(args2, fallbackDir) {
|
|
|
78234
78581
|
}
|
|
78235
78582
|
let planContent;
|
|
78236
78583
|
try {
|
|
78237
|
-
planContent = JSON.parse(
|
|
78584
|
+
planContent = JSON.parse(fs62.readFileSync(planPath, "utf-8"));
|
|
78238
78585
|
} catch {
|
|
78239
78586
|
return {
|
|
78240
78587
|
success: false,
|
|
@@ -78325,7 +78672,7 @@ var declare_scope = createSwarmTool({
|
|
|
78325
78672
|
// src/tools/diff.ts
|
|
78326
78673
|
init_zod();
|
|
78327
78674
|
import * as child_process7 from "node:child_process";
|
|
78328
|
-
import * as
|
|
78675
|
+
import * as fs63 from "node:fs";
|
|
78329
78676
|
import * as path84 from "node:path";
|
|
78330
78677
|
init_create_tool();
|
|
78331
78678
|
var MAX_DIFF_LINES = 500;
|
|
@@ -78515,7 +78862,7 @@ var diff = createSwarmTool({
|
|
|
78515
78862
|
} else if (base === "unstaged") {
|
|
78516
78863
|
const oldRef = `:${file3.path}`;
|
|
78517
78864
|
oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
|
|
78518
|
-
newContent =
|
|
78865
|
+
newContent = fs63.readFileSync(path84.join(directory, file3.path), "utf-8");
|
|
78519
78866
|
} else {
|
|
78520
78867
|
const oldRef = `${base}:${file3.path}`;
|
|
78521
78868
|
oldContent = fileExistsInRef(oldRef) ? getContentFromRef(oldRef) : "";
|
|
@@ -78589,7 +78936,7 @@ var diff = createSwarmTool({
|
|
|
78589
78936
|
// src/tools/diff-summary.ts
|
|
78590
78937
|
init_zod();
|
|
78591
78938
|
import * as child_process8 from "node:child_process";
|
|
78592
|
-
import * as
|
|
78939
|
+
import * as fs64 from "node:fs";
|
|
78593
78940
|
import * as path85 from "node:path";
|
|
78594
78941
|
init_create_tool();
|
|
78595
78942
|
var diff_summary = createSwarmTool({
|
|
@@ -78638,7 +78985,7 @@ var diff_summary = createSwarmTool({
|
|
|
78638
78985
|
}
|
|
78639
78986
|
try {
|
|
78640
78987
|
let oldContent;
|
|
78641
|
-
const newContent =
|
|
78988
|
+
const newContent = fs64.readFileSync(path85.join(workingDir, filePath), "utf-8");
|
|
78642
78989
|
if (fileExistsInHead) {
|
|
78643
78990
|
oldContent = child_process8.execFileSync("git", ["show", `HEAD:${filePath}`], {
|
|
78644
78991
|
encoding: "utf-8",
|
|
@@ -78866,7 +79213,7 @@ Use these as DOMAIN values when delegating to @sme.`;
|
|
|
78866
79213
|
init_zod();
|
|
78867
79214
|
init_create_tool();
|
|
78868
79215
|
init_path_security();
|
|
78869
|
-
import * as
|
|
79216
|
+
import * as fs65 from "node:fs";
|
|
78870
79217
|
import * as path86 from "node:path";
|
|
78871
79218
|
var MAX_FILE_SIZE_BYTES6 = 1024 * 1024;
|
|
78872
79219
|
var MAX_EVIDENCE_FILES = 1000;
|
|
@@ -78912,12 +79259,12 @@ function parseCompletedTasks(planContent) {
|
|
|
78912
79259
|
}
|
|
78913
79260
|
function readEvidenceFiles(evidenceDir, _cwd) {
|
|
78914
79261
|
const evidence = [];
|
|
78915
|
-
if (!
|
|
79262
|
+
if (!fs65.existsSync(evidenceDir) || !fs65.statSync(evidenceDir).isDirectory()) {
|
|
78916
79263
|
return evidence;
|
|
78917
79264
|
}
|
|
78918
79265
|
let files;
|
|
78919
79266
|
try {
|
|
78920
|
-
files =
|
|
79267
|
+
files = fs65.readdirSync(evidenceDir);
|
|
78921
79268
|
} catch {
|
|
78922
79269
|
return evidence;
|
|
78923
79270
|
}
|
|
@@ -78933,7 +79280,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
78933
79280
|
if (!resolvedPath.startsWith(evidenceDirResolved)) {
|
|
78934
79281
|
continue;
|
|
78935
79282
|
}
|
|
78936
|
-
const stat7 =
|
|
79283
|
+
const stat7 = fs65.lstatSync(filePath);
|
|
78937
79284
|
if (!stat7.isFile()) {
|
|
78938
79285
|
continue;
|
|
78939
79286
|
}
|
|
@@ -78942,7 +79289,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
78942
79289
|
}
|
|
78943
79290
|
let fileStat;
|
|
78944
79291
|
try {
|
|
78945
|
-
fileStat =
|
|
79292
|
+
fileStat = fs65.statSync(filePath);
|
|
78946
79293
|
if (fileStat.size > MAX_FILE_SIZE_BYTES6) {
|
|
78947
79294
|
continue;
|
|
78948
79295
|
}
|
|
@@ -78951,7 +79298,7 @@ function readEvidenceFiles(evidenceDir, _cwd) {
|
|
|
78951
79298
|
}
|
|
78952
79299
|
let content;
|
|
78953
79300
|
try {
|
|
78954
|
-
content =
|
|
79301
|
+
content = fs65.readFileSync(filePath, "utf-8");
|
|
78955
79302
|
} catch {
|
|
78956
79303
|
continue;
|
|
78957
79304
|
}
|
|
@@ -79061,7 +79408,7 @@ var evidence_check = createSwarmTool({
|
|
|
79061
79408
|
}
|
|
79062
79409
|
let planContent;
|
|
79063
79410
|
try {
|
|
79064
|
-
planContent =
|
|
79411
|
+
planContent = fs65.readFileSync(planPath, "utf-8");
|
|
79065
79412
|
} catch {
|
|
79066
79413
|
const result2 = {
|
|
79067
79414
|
message: "No completed tasks found in plan.",
|
|
@@ -79096,7 +79443,7 @@ var evidence_check = createSwarmTool({
|
|
|
79096
79443
|
// src/tools/file-extractor.ts
|
|
79097
79444
|
init_zod();
|
|
79098
79445
|
init_create_tool();
|
|
79099
|
-
import * as
|
|
79446
|
+
import * as fs66 from "node:fs";
|
|
79100
79447
|
import * as path87 from "node:path";
|
|
79101
79448
|
var EXT_MAP = {
|
|
79102
79449
|
python: ".py",
|
|
@@ -79159,8 +79506,8 @@ var extract_code_blocks = createSwarmTool({
|
|
|
79159
79506
|
execute: async (args2, directory) => {
|
|
79160
79507
|
const { content, output_dir, prefix } = args2;
|
|
79161
79508
|
const targetDir = output_dir || directory;
|
|
79162
|
-
if (!
|
|
79163
|
-
|
|
79509
|
+
if (!fs66.existsSync(targetDir)) {
|
|
79510
|
+
fs66.mkdirSync(targetDir, { recursive: true });
|
|
79164
79511
|
}
|
|
79165
79512
|
if (!content) {
|
|
79166
79513
|
return "Error: content is required";
|
|
@@ -79182,12 +79529,12 @@ var extract_code_blocks = createSwarmTool({
|
|
|
79182
79529
|
const base = path87.basename(filepath, path87.extname(filepath));
|
|
79183
79530
|
const ext = path87.extname(filepath);
|
|
79184
79531
|
let counter = 1;
|
|
79185
|
-
while (
|
|
79532
|
+
while (fs66.existsSync(filepath)) {
|
|
79186
79533
|
filepath = path87.join(targetDir, `${base}_${counter}${ext}`);
|
|
79187
79534
|
counter++;
|
|
79188
79535
|
}
|
|
79189
79536
|
try {
|
|
79190
|
-
|
|
79537
|
+
fs66.writeFileSync(filepath, code.trim(), "utf-8");
|
|
79191
79538
|
savedFiles.push(filepath);
|
|
79192
79539
|
} catch (error93) {
|
|
79193
79540
|
errors5.push(`Failed to save ${filename}: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
@@ -79446,7 +79793,7 @@ var gitingest = createSwarmTool({
|
|
|
79446
79793
|
init_zod();
|
|
79447
79794
|
init_create_tool();
|
|
79448
79795
|
init_path_security();
|
|
79449
|
-
import * as
|
|
79796
|
+
import * as fs67 from "node:fs";
|
|
79450
79797
|
import * as path88 from "node:path";
|
|
79451
79798
|
var MAX_FILE_PATH_LENGTH2 = 500;
|
|
79452
79799
|
var MAX_SYMBOL_LENGTH = 256;
|
|
@@ -79609,7 +79956,7 @@ var SKIP_DIRECTORIES4 = new Set([
|
|
|
79609
79956
|
function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFiles: 0, fileErrors: [] }) {
|
|
79610
79957
|
let entries;
|
|
79611
79958
|
try {
|
|
79612
|
-
entries =
|
|
79959
|
+
entries = fs67.readdirSync(dir);
|
|
79613
79960
|
} catch (e) {
|
|
79614
79961
|
stats.fileErrors.push({
|
|
79615
79962
|
path: dir,
|
|
@@ -79626,7 +79973,7 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
|
|
|
79626
79973
|
const fullPath = path88.join(dir, entry);
|
|
79627
79974
|
let stat7;
|
|
79628
79975
|
try {
|
|
79629
|
-
stat7 =
|
|
79976
|
+
stat7 = fs67.statSync(fullPath);
|
|
79630
79977
|
} catch (e) {
|
|
79631
79978
|
stats.fileErrors.push({
|
|
79632
79979
|
path: fullPath,
|
|
@@ -79695,7 +80042,7 @@ var imports = createSwarmTool({
|
|
|
79695
80042
|
}
|
|
79696
80043
|
try {
|
|
79697
80044
|
const targetFile = path88.resolve(file3);
|
|
79698
|
-
if (!
|
|
80045
|
+
if (!fs67.existsSync(targetFile)) {
|
|
79699
80046
|
const errorResult = {
|
|
79700
80047
|
error: `target file not found: ${file3}`,
|
|
79701
80048
|
target: file3,
|
|
@@ -79705,7 +80052,7 @@ var imports = createSwarmTool({
|
|
|
79705
80052
|
};
|
|
79706
80053
|
return JSON.stringify(errorResult, null, 2);
|
|
79707
80054
|
}
|
|
79708
|
-
const targetStat =
|
|
80055
|
+
const targetStat = fs67.statSync(targetFile);
|
|
79709
80056
|
if (!targetStat.isFile()) {
|
|
79710
80057
|
const errorResult = {
|
|
79711
80058
|
error: "target must be a file, not a directory",
|
|
@@ -79731,12 +80078,12 @@ var imports = createSwarmTool({
|
|
|
79731
80078
|
if (consumers.length >= MAX_CONSUMERS)
|
|
79732
80079
|
break;
|
|
79733
80080
|
try {
|
|
79734
|
-
const stat7 =
|
|
80081
|
+
const stat7 = fs67.statSync(filePath);
|
|
79735
80082
|
if (stat7.size > MAX_FILE_SIZE_BYTES7) {
|
|
79736
80083
|
skippedFileCount++;
|
|
79737
80084
|
continue;
|
|
79738
80085
|
}
|
|
79739
|
-
const buffer =
|
|
80086
|
+
const buffer = fs67.readFileSync(filePath);
|
|
79740
80087
|
if (isBinaryFile2(filePath, buffer)) {
|
|
79741
80088
|
skippedFileCount++;
|
|
79742
80089
|
continue;
|
|
@@ -80261,7 +80608,7 @@ init_schema();
|
|
|
80261
80608
|
init_qa_gate_profile();
|
|
80262
80609
|
init_manager2();
|
|
80263
80610
|
init_curator();
|
|
80264
|
-
import * as
|
|
80611
|
+
import * as fs69 from "node:fs";
|
|
80265
80612
|
import * as path90 from "node:path";
|
|
80266
80613
|
init_knowledge_curator();
|
|
80267
80614
|
init_knowledge_reader();
|
|
@@ -80274,7 +80621,7 @@ init_file_locks();
|
|
|
80274
80621
|
init_plan_schema();
|
|
80275
80622
|
init_ledger();
|
|
80276
80623
|
init_manager();
|
|
80277
|
-
import * as
|
|
80624
|
+
import * as fs68 from "node:fs";
|
|
80278
80625
|
import * as path89 from "node:path";
|
|
80279
80626
|
async function writeCheckpoint(directory) {
|
|
80280
80627
|
try {
|
|
@@ -80282,12 +80629,12 @@ async function writeCheckpoint(directory) {
|
|
|
80282
80629
|
if (!plan)
|
|
80283
80630
|
return;
|
|
80284
80631
|
const swarmDir = path89.join(directory, ".swarm");
|
|
80285
|
-
|
|
80632
|
+
fs68.mkdirSync(swarmDir, { recursive: true });
|
|
80286
80633
|
const jsonPath = path89.join(swarmDir, "SWARM_PLAN.json");
|
|
80287
80634
|
const mdPath = path89.join(swarmDir, "SWARM_PLAN.md");
|
|
80288
|
-
|
|
80635
|
+
fs68.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
|
|
80289
80636
|
const md = derivePlanMarkdown(plan);
|
|
80290
|
-
|
|
80637
|
+
fs68.writeFileSync(mdPath, md, "utf8");
|
|
80291
80638
|
} catch (error93) {
|
|
80292
80639
|
console.warn(`[checkpoint] Failed to write SWARM_PLAN checkpoint: ${error93 instanceof Error ? error93.message : String(error93)}`);
|
|
80293
80640
|
}
|
|
@@ -80520,7 +80867,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80520
80867
|
let driftHasSpecMd = false;
|
|
80521
80868
|
try {
|
|
80522
80869
|
const specMdPath = path90.join(dir, ".swarm", "spec.md");
|
|
80523
|
-
driftHasSpecMd =
|
|
80870
|
+
driftHasSpecMd = fs69.existsSync(specMdPath);
|
|
80524
80871
|
const gatePlan = await loadPlan(dir);
|
|
80525
80872
|
if (gatePlan) {
|
|
80526
80873
|
const gatePlanId = `${gatePlan.swarm}-${gatePlan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
@@ -80542,8 +80889,8 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80542
80889
|
let phaseType;
|
|
80543
80890
|
try {
|
|
80544
80891
|
const planPath = path90.join(dir, ".swarm", "plan.json");
|
|
80545
|
-
if (
|
|
80546
|
-
const planRaw =
|
|
80892
|
+
if (fs69.existsSync(planPath)) {
|
|
80893
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
80547
80894
|
const plan = JSON.parse(planRaw);
|
|
80548
80895
|
const targetPhase = plan.phases?.find((p) => p.id === phase);
|
|
80549
80896
|
phaseType = targetPhase?.type;
|
|
@@ -80558,7 +80905,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80558
80905
|
let driftVerdictFound = false;
|
|
80559
80906
|
let driftVerdictApproved = false;
|
|
80560
80907
|
try {
|
|
80561
|
-
const driftEvidenceContent =
|
|
80908
|
+
const driftEvidenceContent = fs69.readFileSync(driftEvidencePath, "utf-8");
|
|
80562
80909
|
const driftEvidence = JSON.parse(driftEvidenceContent);
|
|
80563
80910
|
const entries = driftEvidence.entries ?? [];
|
|
80564
80911
|
for (const entry of entries) {
|
|
@@ -80593,8 +80940,8 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80593
80940
|
let planParseable = false;
|
|
80594
80941
|
try {
|
|
80595
80942
|
const planPath = path90.join(dir, ".swarm", "plan.json");
|
|
80596
|
-
if (
|
|
80597
|
-
const planRaw =
|
|
80943
|
+
if (fs69.existsSync(planPath)) {
|
|
80944
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
80598
80945
|
const plan = JSON.parse(planRaw);
|
|
80599
80946
|
planParseable = true;
|
|
80600
80947
|
const planPhase = plan.phases?.find((p) => p.id === phase);
|
|
@@ -80663,7 +81010,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80663
81010
|
let hgVerdictFound = false;
|
|
80664
81011
|
let hgVerdictApproved = false;
|
|
80665
81012
|
try {
|
|
80666
|
-
const hgContent =
|
|
81013
|
+
const hgContent = fs69.readFileSync(hgPath, "utf-8");
|
|
80667
81014
|
const hgBundle = JSON.parse(hgContent);
|
|
80668
81015
|
for (const entry of hgBundle.entries ?? []) {
|
|
80669
81016
|
if (typeof entry.type === "string" && entry.type.includes("hallucination") && typeof entry.verdict === "string") {
|
|
@@ -80735,7 +81082,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80735
81082
|
let mgVerdictFound = false;
|
|
80736
81083
|
let mgVerdict;
|
|
80737
81084
|
try {
|
|
80738
|
-
const mgContent =
|
|
81085
|
+
const mgContent = fs69.readFileSync(mgPath, "utf-8");
|
|
80739
81086
|
const mgBundle = JSON.parse(mgContent);
|
|
80740
81087
|
for (const entry of mgBundle.entries ?? []) {
|
|
80741
81088
|
if (typeof entry.type === "string" && entry.type === "mutation-gate" && typeof entry.verdict === "string") {
|
|
@@ -80812,7 +81159,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
80812
81159
|
let pcTimestamp;
|
|
80813
81160
|
let pcPhaseNumber;
|
|
80814
81161
|
try {
|
|
80815
|
-
const pcContent =
|
|
81162
|
+
const pcContent = fs69.readFileSync(pcPath, "utf-8");
|
|
80816
81163
|
const pcBundle = JSON.parse(pcContent);
|
|
80817
81164
|
for (const entry of pcBundle.entries ?? []) {
|
|
80818
81165
|
if (typeof entry.type === "string" && entry.type === "phase-council" && typeof entry.verdict === "string") {
|
|
@@ -81087,7 +81434,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
|
|
|
81087
81434
|
let phaseRequiredAgents;
|
|
81088
81435
|
try {
|
|
81089
81436
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
81090
|
-
const planRaw =
|
|
81437
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
81091
81438
|
const plan = JSON.parse(planRaw);
|
|
81092
81439
|
const phaseObj = plan.phases.find((p) => p.id === phase);
|
|
81093
81440
|
phaseRequiredAgents = phaseObj?.required_agents;
|
|
@@ -81102,7 +81449,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
|
|
|
81102
81449
|
if (agentsMissing.length > 0) {
|
|
81103
81450
|
try {
|
|
81104
81451
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
81105
|
-
const planRaw =
|
|
81452
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
81106
81453
|
const plan = JSON.parse(planRaw);
|
|
81107
81454
|
const targetPhase = plan.phases.find((p) => p.id === phase);
|
|
81108
81455
|
if (targetPhase && targetPhase.tasks.length > 0 && targetPhase.tasks.every((t) => t.status === "completed")) {
|
|
@@ -81142,7 +81489,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
|
|
|
81142
81489
|
if (phaseCompleteConfig.regression_sweep?.enforce) {
|
|
81143
81490
|
try {
|
|
81144
81491
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
81145
|
-
const planRaw =
|
|
81492
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
81146
81493
|
const plan = JSON.parse(planRaw);
|
|
81147
81494
|
const targetPhase = plan.phases.find((p) => p.id === phase);
|
|
81148
81495
|
if (targetPhase) {
|
|
@@ -81196,7 +81543,7 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
|
|
|
81196
81543
|
}
|
|
81197
81544
|
try {
|
|
81198
81545
|
const eventsPath = validateSwarmPath(dir, "events.jsonl");
|
|
81199
|
-
|
|
81546
|
+
fs69.appendFileSync(eventsPath, `${JSON.stringify(event)}
|
|
81200
81547
|
`, "utf-8");
|
|
81201
81548
|
} catch (writeError) {
|
|
81202
81549
|
warnings.push(`Warning: failed to write phase complete event: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
|
|
@@ -81271,12 +81618,12 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
|
|
|
81271
81618
|
warnings.push(`Warning: failed to update plan.json phase status`);
|
|
81272
81619
|
try {
|
|
81273
81620
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
81274
|
-
const planRaw =
|
|
81621
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
81275
81622
|
const plan2 = JSON.parse(planRaw);
|
|
81276
81623
|
const phaseObj = plan2.phases.find((p) => p.id === phase);
|
|
81277
81624
|
if (phaseObj) {
|
|
81278
81625
|
phaseObj.status = "complete";
|
|
81279
|
-
|
|
81626
|
+
fs69.writeFileSync(planPath, JSON.stringify(plan2, null, 2), "utf-8");
|
|
81280
81627
|
}
|
|
81281
81628
|
} catch {}
|
|
81282
81629
|
} else if (plan) {
|
|
@@ -81313,12 +81660,12 @@ Advisory notes: ${advisoryNotes.join("; ")}` : "";
|
|
|
81313
81660
|
warnings.push(`Warning: failed to update plan.json phase status`);
|
|
81314
81661
|
try {
|
|
81315
81662
|
const planPath = validateSwarmPath(dir, "plan.json");
|
|
81316
|
-
const planRaw =
|
|
81663
|
+
const planRaw = fs69.readFileSync(planPath, "utf-8");
|
|
81317
81664
|
const plan = JSON.parse(planRaw);
|
|
81318
81665
|
const phaseObj = plan.phases.find((p) => p.id === phase);
|
|
81319
81666
|
if (phaseObj) {
|
|
81320
81667
|
phaseObj.status = "complete";
|
|
81321
|
-
|
|
81668
|
+
fs69.writeFileSync(planPath, JSON.stringify(plan, null, 2), "utf-8");
|
|
81322
81669
|
}
|
|
81323
81670
|
} catch {}
|
|
81324
81671
|
}
|
|
@@ -81376,7 +81723,7 @@ init_discovery();
|
|
|
81376
81723
|
init_utils();
|
|
81377
81724
|
init_bun_compat();
|
|
81378
81725
|
init_create_tool();
|
|
81379
|
-
import * as
|
|
81726
|
+
import * as fs70 from "node:fs";
|
|
81380
81727
|
import * as path91 from "node:path";
|
|
81381
81728
|
var MAX_OUTPUT_BYTES5 = 52428800;
|
|
81382
81729
|
var AUDIT_TIMEOUT_MS = 120000;
|
|
@@ -81405,31 +81752,31 @@ function validateArgs3(args2) {
|
|
|
81405
81752
|
function detectEcosystems(directory) {
|
|
81406
81753
|
const ecosystems = [];
|
|
81407
81754
|
const cwd = directory;
|
|
81408
|
-
if (
|
|
81755
|
+
if (fs70.existsSync(path91.join(cwd, "package.json"))) {
|
|
81409
81756
|
ecosystems.push("npm");
|
|
81410
81757
|
}
|
|
81411
|
-
if (
|
|
81758
|
+
if (fs70.existsSync(path91.join(cwd, "pyproject.toml")) || fs70.existsSync(path91.join(cwd, "requirements.txt"))) {
|
|
81412
81759
|
ecosystems.push("pip");
|
|
81413
81760
|
}
|
|
81414
|
-
if (
|
|
81761
|
+
if (fs70.existsSync(path91.join(cwd, "Cargo.toml"))) {
|
|
81415
81762
|
ecosystems.push("cargo");
|
|
81416
81763
|
}
|
|
81417
|
-
if (
|
|
81764
|
+
if (fs70.existsSync(path91.join(cwd, "go.mod"))) {
|
|
81418
81765
|
ecosystems.push("go");
|
|
81419
81766
|
}
|
|
81420
81767
|
try {
|
|
81421
|
-
const files =
|
|
81768
|
+
const files = fs70.readdirSync(cwd);
|
|
81422
81769
|
if (files.some((f) => f.endsWith(".csproj") || f.endsWith(".sln"))) {
|
|
81423
81770
|
ecosystems.push("dotnet");
|
|
81424
81771
|
}
|
|
81425
81772
|
} catch {}
|
|
81426
|
-
if (
|
|
81773
|
+
if (fs70.existsSync(path91.join(cwd, "Gemfile")) || fs70.existsSync(path91.join(cwd, "Gemfile.lock"))) {
|
|
81427
81774
|
ecosystems.push("ruby");
|
|
81428
81775
|
}
|
|
81429
|
-
if (
|
|
81776
|
+
if (fs70.existsSync(path91.join(cwd, "pubspec.yaml"))) {
|
|
81430
81777
|
ecosystems.push("dart");
|
|
81431
81778
|
}
|
|
81432
|
-
if (
|
|
81779
|
+
if (fs70.existsSync(path91.join(cwd, "composer.lock"))) {
|
|
81433
81780
|
ecosystems.push("composer");
|
|
81434
81781
|
}
|
|
81435
81782
|
return ecosystems;
|
|
@@ -82564,7 +82911,7 @@ var pkg_audit = createSwarmTool({
|
|
|
82564
82911
|
// src/tools/placeholder-scan.ts
|
|
82565
82912
|
init_zod();
|
|
82566
82913
|
init_manager2();
|
|
82567
|
-
import * as
|
|
82914
|
+
import * as fs71 from "node:fs";
|
|
82568
82915
|
import * as path92 from "node:path";
|
|
82569
82916
|
init_utils();
|
|
82570
82917
|
init_create_tool();
|
|
@@ -82966,7 +83313,7 @@ async function placeholderScan(input, directory) {
|
|
|
82966
83313
|
if (!fullPath.startsWith(resolvedDirectory + path92.sep) && fullPath !== resolvedDirectory) {
|
|
82967
83314
|
continue;
|
|
82968
83315
|
}
|
|
82969
|
-
if (!
|
|
83316
|
+
if (!fs71.existsSync(fullPath)) {
|
|
82970
83317
|
continue;
|
|
82971
83318
|
}
|
|
82972
83319
|
if (isAllowedByGlobs(filePath, allow_globs)) {
|
|
@@ -82978,11 +83325,11 @@ async function placeholderScan(input, directory) {
|
|
|
82978
83325
|
}
|
|
82979
83326
|
let content;
|
|
82980
83327
|
try {
|
|
82981
|
-
const stat7 =
|
|
83328
|
+
const stat7 = fs71.statSync(fullPath);
|
|
82982
83329
|
if (stat7.size > MAX_FILE_SIZE) {
|
|
82983
83330
|
continue;
|
|
82984
83331
|
}
|
|
82985
|
-
content =
|
|
83332
|
+
content = fs71.readFileSync(fullPath, "utf-8");
|
|
82986
83333
|
} catch {
|
|
82987
83334
|
continue;
|
|
82988
83335
|
}
|
|
@@ -83043,8 +83390,8 @@ var placeholder_scan = createSwarmTool({
|
|
|
83043
83390
|
}
|
|
83044
83391
|
});
|
|
83045
83392
|
// src/tools/pre-check-batch.ts
|
|
83046
|
-
import * as
|
|
83047
|
-
import * as
|
|
83393
|
+
import * as fs75 from "node:fs";
|
|
83394
|
+
import * as path96 from "node:path";
|
|
83048
83395
|
init_zod();
|
|
83049
83396
|
init_manager2();
|
|
83050
83397
|
init_utils();
|
|
@@ -83172,17 +83519,20 @@ var quality_budget = createSwarmTool({
|
|
|
83172
83519
|
}).optional().describe("Quality budget thresholds")
|
|
83173
83520
|
},
|
|
83174
83521
|
async execute(args2, directory) {
|
|
83175
|
-
const result = await qualityBudget(args2, directory);
|
|
83522
|
+
const result = await _internals28.qualityBudget(args2, directory);
|
|
83176
83523
|
return JSON.stringify(result);
|
|
83177
83524
|
}
|
|
83178
83525
|
});
|
|
83526
|
+
var _internals28 = {
|
|
83527
|
+
qualityBudget
|
|
83528
|
+
};
|
|
83179
83529
|
|
|
83180
83530
|
// src/tools/sast-scan.ts
|
|
83181
83531
|
init_zod();
|
|
83182
83532
|
init_manager2();
|
|
83183
83533
|
init_detector();
|
|
83184
|
-
import * as
|
|
83185
|
-
import * as
|
|
83534
|
+
import * as fs74 from "node:fs";
|
|
83535
|
+
import * as path95 from "node:path";
|
|
83186
83536
|
import { extname as extname18 } from "node:path";
|
|
83187
83537
|
|
|
83188
83538
|
// src/sast/rules/c.ts
|
|
@@ -83897,9 +84247,19 @@ function executeRulesSync(filePath, content, language) {
|
|
|
83897
84247
|
|
|
83898
84248
|
// src/sast/semgrep.ts
|
|
83899
84249
|
import * as child_process9 from "node:child_process";
|
|
84250
|
+
import * as fs72 from "node:fs";
|
|
84251
|
+
import * as path93 from "node:path";
|
|
83900
84252
|
var semgrepAvailableCache = null;
|
|
83901
84253
|
var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
83902
84254
|
var DEFAULT_TIMEOUT_MS3 = 30000;
|
|
84255
|
+
var _internals29 = {
|
|
84256
|
+
isSemgrepAvailable,
|
|
84257
|
+
checkSemgrepAvailable,
|
|
84258
|
+
resetSemgrepCache,
|
|
84259
|
+
runSemgrep,
|
|
84260
|
+
getRulesDirectory,
|
|
84261
|
+
hasBundledRules
|
|
84262
|
+
};
|
|
83903
84263
|
function isSemgrepAvailable() {
|
|
83904
84264
|
if (semgrepAvailableCache !== null) {
|
|
83905
84265
|
return semgrepAvailableCache;
|
|
@@ -83916,6 +84276,12 @@ function isSemgrepAvailable() {
|
|
|
83916
84276
|
return false;
|
|
83917
84277
|
}
|
|
83918
84278
|
}
|
|
84279
|
+
async function checkSemgrepAvailable() {
|
|
84280
|
+
return _internals29.isSemgrepAvailable();
|
|
84281
|
+
}
|
|
84282
|
+
function resetSemgrepCache() {
|
|
84283
|
+
semgrepAvailableCache = null;
|
|
84284
|
+
}
|
|
83919
84285
|
function parseSemgrepResults(semgrepOutput) {
|
|
83920
84286
|
const findings = [];
|
|
83921
84287
|
try {
|
|
@@ -83963,7 +84329,7 @@ function mapSemgrepSeverity(severity) {
|
|
|
83963
84329
|
}
|
|
83964
84330
|
}
|
|
83965
84331
|
async function executeWithTimeout(command, args2, options) {
|
|
83966
|
-
return new Promise((
|
|
84332
|
+
return new Promise((resolve34) => {
|
|
83967
84333
|
const child = child_process9.spawn(command, args2, {
|
|
83968
84334
|
shell: false,
|
|
83969
84335
|
cwd: options.cwd
|
|
@@ -83972,7 +84338,7 @@ async function executeWithTimeout(command, args2, options) {
|
|
|
83972
84338
|
let stderr = "";
|
|
83973
84339
|
const timeout = setTimeout(() => {
|
|
83974
84340
|
child.kill("SIGTERM");
|
|
83975
|
-
|
|
84341
|
+
resolve34({
|
|
83976
84342
|
stdout,
|
|
83977
84343
|
stderr: "Process timed out",
|
|
83978
84344
|
exitCode: 124
|
|
@@ -83986,7 +84352,7 @@ async function executeWithTimeout(command, args2, options) {
|
|
|
83986
84352
|
});
|
|
83987
84353
|
child.on("close", (code) => {
|
|
83988
84354
|
clearTimeout(timeout);
|
|
83989
|
-
|
|
84355
|
+
resolve34({
|
|
83990
84356
|
stdout,
|
|
83991
84357
|
stderr,
|
|
83992
84358
|
exitCode: code ?? 0
|
|
@@ -83994,7 +84360,7 @@ async function executeWithTimeout(command, args2, options) {
|
|
|
83994
84360
|
});
|
|
83995
84361
|
child.on("error", (err2) => {
|
|
83996
84362
|
clearTimeout(timeout);
|
|
83997
|
-
|
|
84363
|
+
resolve34({
|
|
83998
84364
|
stdout,
|
|
83999
84365
|
stderr: err2.message,
|
|
84000
84366
|
exitCode: 1
|
|
@@ -84008,12 +84374,12 @@ async function runSemgrep(options) {
|
|
|
84008
84374
|
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS3;
|
|
84009
84375
|
if (files.length === 0) {
|
|
84010
84376
|
return {
|
|
84011
|
-
available: isSemgrepAvailable(),
|
|
84377
|
+
available: _internals29.isSemgrepAvailable(),
|
|
84012
84378
|
findings: [],
|
|
84013
84379
|
engine: "tier_a"
|
|
84014
84380
|
};
|
|
84015
84381
|
}
|
|
84016
|
-
if (!isSemgrepAvailable()) {
|
|
84382
|
+
if (!_internals29.isSemgrepAvailable()) {
|
|
84017
84383
|
return {
|
|
84018
84384
|
available: false,
|
|
84019
84385
|
findings: [],
|
|
@@ -84067,6 +84433,20 @@ async function runSemgrep(options) {
|
|
|
84067
84433
|
};
|
|
84068
84434
|
}
|
|
84069
84435
|
}
|
|
84436
|
+
function getRulesDirectory(projectRoot) {
|
|
84437
|
+
if (projectRoot) {
|
|
84438
|
+
return path93.resolve(projectRoot, DEFAULT_RULES_DIR);
|
|
84439
|
+
}
|
|
84440
|
+
return DEFAULT_RULES_DIR;
|
|
84441
|
+
}
|
|
84442
|
+
function hasBundledRules(projectRoot) {
|
|
84443
|
+
const rulesDir = getRulesDirectory(projectRoot);
|
|
84444
|
+
try {
|
|
84445
|
+
return fs72.existsSync(rulesDir);
|
|
84446
|
+
} catch {
|
|
84447
|
+
return false;
|
|
84448
|
+
}
|
|
84449
|
+
}
|
|
84070
84450
|
|
|
84071
84451
|
// src/tools/sast-scan.ts
|
|
84072
84452
|
init_utils();
|
|
@@ -84074,26 +84454,26 @@ init_create_tool();
|
|
|
84074
84454
|
|
|
84075
84455
|
// src/tools/sast-baseline.ts
|
|
84076
84456
|
init_utils2();
|
|
84077
|
-
import * as
|
|
84078
|
-
import * as
|
|
84079
|
-
import * as
|
|
84457
|
+
import * as crypto9 from "node:crypto";
|
|
84458
|
+
import * as fs73 from "node:fs";
|
|
84459
|
+
import * as path94 from "node:path";
|
|
84080
84460
|
var BASELINE_SCHEMA_VERSION = "1.0.0";
|
|
84081
84461
|
var MAX_BASELINE_FINDINGS = 2000;
|
|
84082
84462
|
var MAX_BASELINE_BYTES = 2 * 1048576;
|
|
84083
84463
|
var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
|
|
84084
84464
|
function normalizeFindingPath(directory, file3) {
|
|
84085
|
-
const resolved =
|
|
84086
|
-
const rel =
|
|
84465
|
+
const resolved = path94.isAbsolute(file3) ? file3 : path94.resolve(directory, file3);
|
|
84466
|
+
const rel = path94.relative(path94.resolve(directory), resolved);
|
|
84087
84467
|
return rel.replace(/\\/g, "/");
|
|
84088
84468
|
}
|
|
84089
84469
|
function baselineRelPath(phase) {
|
|
84090
|
-
return
|
|
84470
|
+
return path94.join("evidence", String(phase), "sast-baseline.json");
|
|
84091
84471
|
}
|
|
84092
84472
|
function tempRelPath(phase) {
|
|
84093
|
-
return
|
|
84473
|
+
return path94.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
|
|
84094
84474
|
}
|
|
84095
84475
|
function lockRelPath(phase) {
|
|
84096
|
-
return
|
|
84476
|
+
return path94.join("evidence", String(phase), "sast-baseline.json.lock");
|
|
84097
84477
|
}
|
|
84098
84478
|
function getLine(lines, idx) {
|
|
84099
84479
|
if (idx < 0 || idx >= lines.length)
|
|
@@ -84110,7 +84490,7 @@ function fingerprintFinding(finding, directory, occurrenceIndex) {
|
|
|
84110
84490
|
}
|
|
84111
84491
|
const lineNum = finding.location.line;
|
|
84112
84492
|
try {
|
|
84113
|
-
const content =
|
|
84493
|
+
const content = fs73.readFileSync(finding.location.file, "utf-8");
|
|
84114
84494
|
const lines = content.split(`
|
|
84115
84495
|
`);
|
|
84116
84496
|
const idx = lineNum - 1;
|
|
@@ -84120,7 +84500,7 @@ function fingerprintFinding(finding, directory, occurrenceIndex) {
|
|
|
84120
84500
|
getLine(lines, idx + 1)
|
|
84121
84501
|
].join(`
|
|
84122
84502
|
`);
|
|
84123
|
-
const hash3 =
|
|
84503
|
+
const hash3 = crypto9.createHash("sha256").update(window2).digest("hex").slice(0, 16);
|
|
84124
84504
|
return {
|
|
84125
84505
|
fingerprint: `${relFile}|${finding.rule_id}|${hash3}|#${occurrenceIndex}`,
|
|
84126
84506
|
stable: true
|
|
@@ -84141,7 +84521,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
84141
84521
|
try {
|
|
84142
84522
|
if (relFile.startsWith(".."))
|
|
84143
84523
|
throw new Error("escapes workspace");
|
|
84144
|
-
const content =
|
|
84524
|
+
const content = fs73.readFileSync(finding.location.file, "utf-8");
|
|
84145
84525
|
const lines = content.split(`
|
|
84146
84526
|
`);
|
|
84147
84527
|
const idx = lineNum - 1;
|
|
@@ -84151,14 +84531,14 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
84151
84531
|
getLine(lines, idx + 1)
|
|
84152
84532
|
].join(`
|
|
84153
84533
|
`);
|
|
84154
|
-
const hash3 =
|
|
84534
|
+
const hash3 = crypto9.createHash("sha256").update(window2).digest("hex").slice(0, 16);
|
|
84155
84535
|
baseKey = `${relFile}|${finding.rule_id}|${hash3}`;
|
|
84156
84536
|
} catch {
|
|
84157
84537
|
baseKey = `${relFile}|${finding.rule_id}|L${lineNum}|UNSTABLE`;
|
|
84158
84538
|
}
|
|
84159
84539
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
84160
84540
|
countMap.set(baseKey, occIdx + 1);
|
|
84161
|
-
const fp = fingerprintFinding(finding, directory, occIdx);
|
|
84541
|
+
const fp = _internals30.fingerprintFinding(finding, directory, occIdx);
|
|
84162
84542
|
return {
|
|
84163
84543
|
finding,
|
|
84164
84544
|
index: occIdx,
|
|
@@ -84170,16 +84550,16 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
84170
84550
|
async function acquireLock(lockPath) {
|
|
84171
84551
|
for (let attempt = 0;attempt <= LOCK_RETRY_DELAYS_MS.length; attempt++) {
|
|
84172
84552
|
try {
|
|
84173
|
-
const fd =
|
|
84174
|
-
|
|
84553
|
+
const fd = fs73.openSync(lockPath, "wx");
|
|
84554
|
+
fs73.closeSync(fd);
|
|
84175
84555
|
return () => {
|
|
84176
84556
|
try {
|
|
84177
|
-
|
|
84557
|
+
fs73.unlinkSync(lockPath);
|
|
84178
84558
|
} catch {}
|
|
84179
84559
|
};
|
|
84180
84560
|
} catch {
|
|
84181
84561
|
if (attempt < LOCK_RETRY_DELAYS_MS.length) {
|
|
84182
|
-
await new Promise((
|
|
84562
|
+
await new Promise((resolve35) => setTimeout(resolve35, LOCK_RETRY_DELAYS_MS[attempt]));
|
|
84183
84563
|
}
|
|
84184
84564
|
}
|
|
84185
84565
|
}
|
|
@@ -84214,20 +84594,20 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
84214
84594
|
message: e instanceof Error ? e.message : "Path validation failed"
|
|
84215
84595
|
};
|
|
84216
84596
|
}
|
|
84217
|
-
|
|
84218
|
-
|
|
84597
|
+
fs73.mkdirSync(path94.dirname(baselinePath), { recursive: true });
|
|
84598
|
+
fs73.mkdirSync(path94.dirname(tempPath), { recursive: true });
|
|
84219
84599
|
const releaseLock = await acquireLock(lockPath);
|
|
84220
84600
|
try {
|
|
84221
84601
|
let existing = null;
|
|
84222
84602
|
try {
|
|
84223
|
-
const raw =
|
|
84603
|
+
const raw = fs73.readFileSync(baselinePath, "utf-8");
|
|
84224
84604
|
const parsed = JSON.parse(raw);
|
|
84225
84605
|
if (parsed.schema_version === BASELINE_SCHEMA_VERSION) {
|
|
84226
84606
|
existing = parsed;
|
|
84227
84607
|
}
|
|
84228
84608
|
} catch {}
|
|
84229
84609
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
84230
|
-
const indexed = assignOccurrenceIndices(findings, directory);
|
|
84610
|
+
const indexed = _internals30.assignOccurrenceIndices(findings, directory);
|
|
84231
84611
|
if (existing && !opts?.force) {
|
|
84232
84612
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
84233
84613
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -84280,8 +84660,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
84280
84660
|
message: `Baseline would exceed size cap (${json4.length} bytes > ${MAX_BASELINE_BYTES})`
|
|
84281
84661
|
};
|
|
84282
84662
|
}
|
|
84283
|
-
|
|
84284
|
-
|
|
84663
|
+
fs73.writeFileSync(tempPath, json4, "utf-8");
|
|
84664
|
+
fs73.renameSync(tempPath, baselinePath);
|
|
84285
84665
|
return {
|
|
84286
84666
|
status: "merged",
|
|
84287
84667
|
path: baselinePath,
|
|
@@ -84312,8 +84692,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
84312
84692
|
message: `Baseline would exceed size cap (${json3.length} bytes > ${MAX_BASELINE_BYTES})`
|
|
84313
84693
|
};
|
|
84314
84694
|
}
|
|
84315
|
-
|
|
84316
|
-
|
|
84695
|
+
fs73.writeFileSync(tempPath, json3, "utf-8");
|
|
84696
|
+
fs73.renameSync(tempPath, baselinePath);
|
|
84317
84697
|
return {
|
|
84318
84698
|
status: "written",
|
|
84319
84699
|
path: baselinePath,
|
|
@@ -84338,7 +84718,7 @@ function loadBaseline(directory, phase) {
|
|
|
84338
84718
|
};
|
|
84339
84719
|
}
|
|
84340
84720
|
try {
|
|
84341
|
-
const raw =
|
|
84721
|
+
const raw = fs73.readFileSync(baselinePath, "utf-8");
|
|
84342
84722
|
const parsed = JSON.parse(raw);
|
|
84343
84723
|
if (parsed.schema_version !== BASELINE_SCHEMA_VERSION) {
|
|
84344
84724
|
return {
|
|
@@ -84367,6 +84747,12 @@ function loadBaseline(directory, phase) {
|
|
|
84367
84747
|
};
|
|
84368
84748
|
}
|
|
84369
84749
|
}
|
|
84750
|
+
var _internals30 = {
|
|
84751
|
+
fingerprintFinding,
|
|
84752
|
+
assignOccurrenceIndices,
|
|
84753
|
+
captureOrMergeBaseline,
|
|
84754
|
+
loadBaseline
|
|
84755
|
+
};
|
|
84370
84756
|
|
|
84371
84757
|
// src/tools/sast-scan.ts
|
|
84372
84758
|
var MAX_FILE_SIZE_BYTES8 = 512 * 1024;
|
|
@@ -84380,17 +84766,17 @@ var SEVERITY_ORDER = {
|
|
|
84380
84766
|
};
|
|
84381
84767
|
function shouldSkipFile(filePath) {
|
|
84382
84768
|
try {
|
|
84383
|
-
const stats =
|
|
84769
|
+
const stats = fs74.statSync(filePath);
|
|
84384
84770
|
if (stats.size > MAX_FILE_SIZE_BYTES8) {
|
|
84385
84771
|
return { skip: true, reason: "file too large" };
|
|
84386
84772
|
}
|
|
84387
84773
|
if (stats.size === 0) {
|
|
84388
84774
|
return { skip: true, reason: "empty file" };
|
|
84389
84775
|
}
|
|
84390
|
-
const fd =
|
|
84776
|
+
const fd = fs74.openSync(filePath, "r");
|
|
84391
84777
|
const buffer = Buffer.alloc(8192);
|
|
84392
|
-
const bytesRead =
|
|
84393
|
-
|
|
84778
|
+
const bytesRead = fs74.readSync(fd, buffer, 0, 8192, 0);
|
|
84779
|
+
fs74.closeSync(fd);
|
|
84394
84780
|
if (bytesRead > 0) {
|
|
84395
84781
|
let nullCount = 0;
|
|
84396
84782
|
for (let i2 = 0;i2 < bytesRead; i2++) {
|
|
@@ -84429,7 +84815,7 @@ function countBySeverity(findings) {
|
|
|
84429
84815
|
}
|
|
84430
84816
|
function scanFileWithTierA(filePath, language) {
|
|
84431
84817
|
try {
|
|
84432
|
-
const content =
|
|
84818
|
+
const content = fs74.readFileSync(filePath, "utf-8");
|
|
84433
84819
|
const findings = executeRulesSync(filePath, content, language);
|
|
84434
84820
|
return findings.map((f) => ({
|
|
84435
84821
|
rule_id: f.rule_id,
|
|
@@ -84482,13 +84868,13 @@ async function sastScan(input, directory, config3) {
|
|
|
84482
84868
|
_filesSkipped++;
|
|
84483
84869
|
continue;
|
|
84484
84870
|
}
|
|
84485
|
-
const resolvedPath =
|
|
84486
|
-
const resolvedDirectory =
|
|
84487
|
-
if (!resolvedPath.startsWith(resolvedDirectory +
|
|
84871
|
+
const resolvedPath = path95.isAbsolute(filePath) ? filePath : path95.resolve(directory, filePath);
|
|
84872
|
+
const resolvedDirectory = path95.resolve(directory);
|
|
84873
|
+
if (!resolvedPath.startsWith(resolvedDirectory + path95.sep) && resolvedPath !== resolvedDirectory) {
|
|
84488
84874
|
_filesSkipped++;
|
|
84489
84875
|
continue;
|
|
84490
84876
|
}
|
|
84491
|
-
if (!
|
|
84877
|
+
if (!fs74.existsSync(resolvedPath)) {
|
|
84492
84878
|
_filesSkipped++;
|
|
84493
84879
|
continue;
|
|
84494
84880
|
}
|
|
@@ -84771,10 +85157,14 @@ var sast_scan = createSwarmTool({
|
|
|
84771
85157
|
capture_baseline: safeArgs.capture_baseline,
|
|
84772
85158
|
phase: safeArgs.phase
|
|
84773
85159
|
};
|
|
84774
|
-
const result = await sastScan(input, directory);
|
|
85160
|
+
const result = await _internals31.sastScan(input, directory);
|
|
84775
85161
|
return JSON.stringify(result, null, 2);
|
|
84776
85162
|
}
|
|
84777
85163
|
});
|
|
85164
|
+
var _internals31 = {
|
|
85165
|
+
sastScan,
|
|
85166
|
+
sast_scan
|
|
85167
|
+
};
|
|
84778
85168
|
|
|
84779
85169
|
// src/tools/pre-check-batch.ts
|
|
84780
85170
|
init_secretscan();
|
|
@@ -84795,18 +85185,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
|
|
|
84795
85185
|
let resolved;
|
|
84796
85186
|
const isWinAbs = isWindowsAbsolutePath(inputPath);
|
|
84797
85187
|
if (isWinAbs) {
|
|
84798
|
-
resolved =
|
|
84799
|
-
} else if (
|
|
84800
|
-
resolved =
|
|
85188
|
+
resolved = path96.win32.resolve(inputPath);
|
|
85189
|
+
} else if (path96.isAbsolute(inputPath)) {
|
|
85190
|
+
resolved = path96.resolve(inputPath);
|
|
84801
85191
|
} else {
|
|
84802
|
-
resolved =
|
|
85192
|
+
resolved = path96.resolve(baseDir, inputPath);
|
|
84803
85193
|
}
|
|
84804
|
-
const workspaceResolved =
|
|
85194
|
+
const workspaceResolved = path96.resolve(workspaceDir);
|
|
84805
85195
|
let relative20;
|
|
84806
85196
|
if (isWinAbs) {
|
|
84807
|
-
relative20 =
|
|
85197
|
+
relative20 = path96.win32.relative(workspaceResolved, resolved);
|
|
84808
85198
|
} else {
|
|
84809
|
-
relative20 =
|
|
85199
|
+
relative20 = path96.relative(workspaceResolved, resolved);
|
|
84810
85200
|
}
|
|
84811
85201
|
if (relative20.startsWith("..")) {
|
|
84812
85202
|
return "path traversal detected";
|
|
@@ -84871,7 +85261,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
|
|
|
84871
85261
|
if (typeof file3 !== "string") {
|
|
84872
85262
|
continue;
|
|
84873
85263
|
}
|
|
84874
|
-
const resolvedPath =
|
|
85264
|
+
const resolvedPath = path96.resolve(file3);
|
|
84875
85265
|
const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
|
|
84876
85266
|
if (validationError) {
|
|
84877
85267
|
continue;
|
|
@@ -85028,7 +85418,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
85028
85418
|
skippedFiles++;
|
|
85029
85419
|
continue;
|
|
85030
85420
|
}
|
|
85031
|
-
const resolvedPath =
|
|
85421
|
+
const resolvedPath = path96.resolve(file3);
|
|
85032
85422
|
const validationError = validatePath(resolvedPath, directory, directory);
|
|
85033
85423
|
if (validationError) {
|
|
85034
85424
|
skippedFiles++;
|
|
@@ -85046,14 +85436,14 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
85046
85436
|
};
|
|
85047
85437
|
}
|
|
85048
85438
|
for (const file3 of validatedFiles) {
|
|
85049
|
-
const ext =
|
|
85439
|
+
const ext = path96.extname(file3).toLowerCase();
|
|
85050
85440
|
if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
|
|
85051
85441
|
skippedFiles++;
|
|
85052
85442
|
continue;
|
|
85053
85443
|
}
|
|
85054
85444
|
let stat7;
|
|
85055
85445
|
try {
|
|
85056
|
-
stat7 =
|
|
85446
|
+
stat7 = fs75.statSync(file3);
|
|
85057
85447
|
} catch {
|
|
85058
85448
|
skippedFiles++;
|
|
85059
85449
|
continue;
|
|
@@ -85064,7 +85454,7 @@ async function runSecretscanWithFiles(files, directory) {
|
|
|
85064
85454
|
}
|
|
85065
85455
|
let content;
|
|
85066
85456
|
try {
|
|
85067
|
-
const buffer =
|
|
85457
|
+
const buffer = fs75.readFileSync(file3);
|
|
85068
85458
|
if (buffer.includes(0)) {
|
|
85069
85459
|
skippedFiles++;
|
|
85070
85460
|
continue;
|
|
@@ -85265,7 +85655,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
|
|
|
85265
85655
|
const preexistingFindings = [];
|
|
85266
85656
|
for (const finding of findings) {
|
|
85267
85657
|
const filePath = finding.location.file;
|
|
85268
|
-
const normalised =
|
|
85658
|
+
const normalised = path96.relative(directory, filePath).replace(/\\/g, "/");
|
|
85269
85659
|
const changedLines = changedLineRanges.get(normalised);
|
|
85270
85660
|
if (changedLines?.has(finding.location.line)) {
|
|
85271
85661
|
newFindings.push(finding);
|
|
@@ -85316,7 +85706,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
|
|
|
85316
85706
|
warn(`pre_check_batch: Invalid file path: ${file3}`);
|
|
85317
85707
|
continue;
|
|
85318
85708
|
}
|
|
85319
|
-
changedFiles.push(
|
|
85709
|
+
changedFiles.push(path96.resolve(directory, file3));
|
|
85320
85710
|
}
|
|
85321
85711
|
if (changedFiles.length === 0) {
|
|
85322
85712
|
warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
|
|
@@ -85517,7 +85907,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
85517
85907
|
};
|
|
85518
85908
|
return JSON.stringify(errorResult, null, 2);
|
|
85519
85909
|
}
|
|
85520
|
-
const resolvedDirectory =
|
|
85910
|
+
const resolvedDirectory = path96.resolve(typedArgs.directory);
|
|
85521
85911
|
const workspaceAnchor = resolvedDirectory;
|
|
85522
85912
|
const dirError = validateDirectory2(resolvedDirectory, workspaceAnchor);
|
|
85523
85913
|
if (dirError) {
|
|
@@ -85558,7 +85948,7 @@ var pre_check_batch = createSwarmTool({
|
|
|
85558
85948
|
});
|
|
85559
85949
|
// src/tools/repo-map.ts
|
|
85560
85950
|
init_zod();
|
|
85561
|
-
import * as
|
|
85951
|
+
import * as path97 from "node:path";
|
|
85562
85952
|
init_path_security();
|
|
85563
85953
|
init_create_tool();
|
|
85564
85954
|
var VALID_ACTIONS = [
|
|
@@ -85583,7 +85973,7 @@ function validateFile(p) {
|
|
|
85583
85973
|
return "file contains control characters";
|
|
85584
85974
|
if (containsPathTraversal(p))
|
|
85585
85975
|
return "file contains path traversal";
|
|
85586
|
-
if (
|
|
85976
|
+
if (path97.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
|
|
85587
85977
|
return "file must be a workspace-relative path, not absolute";
|
|
85588
85978
|
}
|
|
85589
85979
|
return null;
|
|
@@ -85606,8 +85996,8 @@ function ok(action, payload) {
|
|
|
85606
85996
|
}
|
|
85607
85997
|
function toRelativeGraphPath(input, workspaceRoot) {
|
|
85608
85998
|
const normalized = input.replace(/\\/g, "/");
|
|
85609
|
-
if (
|
|
85610
|
-
const rel =
|
|
85999
|
+
if (path97.isAbsolute(normalized)) {
|
|
86000
|
+
const rel = path97.relative(workspaceRoot, normalized).replace(/\\/g, "/");
|
|
85611
86001
|
return normalizeGraphPath2(rel);
|
|
85612
86002
|
}
|
|
85613
86003
|
return normalizeGraphPath2(normalized);
|
|
@@ -85751,8 +86141,8 @@ var repo_map = createSwarmTool({
|
|
|
85751
86141
|
// src/tools/req-coverage.ts
|
|
85752
86142
|
init_zod();
|
|
85753
86143
|
init_create_tool();
|
|
85754
|
-
import * as
|
|
85755
|
-
import * as
|
|
86144
|
+
import * as fs76 from "node:fs";
|
|
86145
|
+
import * as path98 from "node:path";
|
|
85756
86146
|
var SPEC_FILE = ".swarm/spec.md";
|
|
85757
86147
|
var EVIDENCE_DIR4 = ".swarm/evidence";
|
|
85758
86148
|
var OBLIGATION_KEYWORDS = ["MUST", "SHOULD", "SHALL"];
|
|
@@ -85811,19 +86201,19 @@ function extractObligationAndText(id, lineText) {
|
|
|
85811
86201
|
var PHASE_TASK_ID_REGEX = /^\d+\.\d+(\.\d+)*$/;
|
|
85812
86202
|
function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
85813
86203
|
const touchedFiles = new Set;
|
|
85814
|
-
if (!
|
|
86204
|
+
if (!fs76.existsSync(evidenceDir) || !fs76.statSync(evidenceDir).isDirectory()) {
|
|
85815
86205
|
return [];
|
|
85816
86206
|
}
|
|
85817
86207
|
let entries;
|
|
85818
86208
|
try {
|
|
85819
|
-
entries =
|
|
86209
|
+
entries = fs76.readdirSync(evidenceDir);
|
|
85820
86210
|
} catch {
|
|
85821
86211
|
return [];
|
|
85822
86212
|
}
|
|
85823
86213
|
for (const entry of entries) {
|
|
85824
|
-
const entryPath =
|
|
86214
|
+
const entryPath = path98.join(evidenceDir, entry);
|
|
85825
86215
|
try {
|
|
85826
|
-
const stat7 =
|
|
86216
|
+
const stat7 = fs76.statSync(entryPath);
|
|
85827
86217
|
if (!stat7.isDirectory()) {
|
|
85828
86218
|
continue;
|
|
85829
86219
|
}
|
|
@@ -85837,14 +86227,14 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
85837
86227
|
if (entryPhase !== String(phase)) {
|
|
85838
86228
|
continue;
|
|
85839
86229
|
}
|
|
85840
|
-
const evidenceFilePath =
|
|
86230
|
+
const evidenceFilePath = path98.join(entryPath, "evidence.json");
|
|
85841
86231
|
try {
|
|
85842
|
-
const resolvedPath =
|
|
85843
|
-
const evidenceDirResolved =
|
|
85844
|
-
if (!resolvedPath.startsWith(evidenceDirResolved +
|
|
86232
|
+
const resolvedPath = path98.resolve(evidenceFilePath);
|
|
86233
|
+
const evidenceDirResolved = path98.resolve(evidenceDir);
|
|
86234
|
+
if (!resolvedPath.startsWith(evidenceDirResolved + path98.sep)) {
|
|
85845
86235
|
continue;
|
|
85846
86236
|
}
|
|
85847
|
-
const stat7 =
|
|
86237
|
+
const stat7 = fs76.lstatSync(evidenceFilePath);
|
|
85848
86238
|
if (!stat7.isFile()) {
|
|
85849
86239
|
continue;
|
|
85850
86240
|
}
|
|
@@ -85856,7 +86246,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
85856
86246
|
}
|
|
85857
86247
|
let content;
|
|
85858
86248
|
try {
|
|
85859
|
-
content =
|
|
86249
|
+
content = fs76.readFileSync(evidenceFilePath, "utf-8");
|
|
85860
86250
|
} catch {
|
|
85861
86251
|
continue;
|
|
85862
86252
|
}
|
|
@@ -85875,7 +86265,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
85875
86265
|
if (Array.isArray(diffEntry.files_changed)) {
|
|
85876
86266
|
for (const file3 of diffEntry.files_changed) {
|
|
85877
86267
|
if (typeof file3 === "string") {
|
|
85878
|
-
touchedFiles.add(
|
|
86268
|
+
touchedFiles.add(path98.resolve(cwd, file3));
|
|
85879
86269
|
}
|
|
85880
86270
|
}
|
|
85881
86271
|
}
|
|
@@ -85888,12 +86278,12 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
|
|
|
85888
86278
|
}
|
|
85889
86279
|
function searchFileForKeywords(filePath, keywords, cwd) {
|
|
85890
86280
|
try {
|
|
85891
|
-
const resolvedPath =
|
|
85892
|
-
const cwdResolved =
|
|
86281
|
+
const resolvedPath = path98.resolve(filePath);
|
|
86282
|
+
const cwdResolved = path98.resolve(cwd);
|
|
85893
86283
|
if (!resolvedPath.startsWith(cwdResolved)) {
|
|
85894
86284
|
return false;
|
|
85895
86285
|
}
|
|
85896
|
-
const content =
|
|
86286
|
+
const content = fs76.readFileSync(resolvedPath, "utf-8");
|
|
85897
86287
|
for (const keyword of keywords) {
|
|
85898
86288
|
const regex = new RegExp(`\\b${keyword}\\b`, "i");
|
|
85899
86289
|
if (regex.test(content)) {
|
|
@@ -86023,10 +86413,10 @@ var req_coverage = createSwarmTool({
|
|
|
86023
86413
|
}, null, 2);
|
|
86024
86414
|
}
|
|
86025
86415
|
const cwd = inputDirectory || directory;
|
|
86026
|
-
const specPath =
|
|
86416
|
+
const specPath = path98.join(cwd, SPEC_FILE);
|
|
86027
86417
|
let specContent;
|
|
86028
86418
|
try {
|
|
86029
|
-
specContent =
|
|
86419
|
+
specContent = fs76.readFileSync(specPath, "utf-8");
|
|
86030
86420
|
} catch (readError) {
|
|
86031
86421
|
return JSON.stringify({
|
|
86032
86422
|
success: false,
|
|
@@ -86050,7 +86440,7 @@ var req_coverage = createSwarmTool({
|
|
|
86050
86440
|
message: "No FR requirements found in spec.md"
|
|
86051
86441
|
}, null, 2);
|
|
86052
86442
|
}
|
|
86053
|
-
const evidenceDir =
|
|
86443
|
+
const evidenceDir = path98.join(cwd, EVIDENCE_DIR4);
|
|
86054
86444
|
const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
|
|
86055
86445
|
const analyzedRequirements = [];
|
|
86056
86446
|
let coveredCount = 0;
|
|
@@ -86076,12 +86466,12 @@ var req_coverage = createSwarmTool({
|
|
|
86076
86466
|
requirements: analyzedRequirements
|
|
86077
86467
|
};
|
|
86078
86468
|
const reportFilename = `req-coverage-phase-${phase}.json`;
|
|
86079
|
-
const reportPath =
|
|
86469
|
+
const reportPath = path98.join(evidenceDir, reportFilename);
|
|
86080
86470
|
try {
|
|
86081
|
-
if (!
|
|
86082
|
-
|
|
86471
|
+
if (!fs76.existsSync(evidenceDir)) {
|
|
86472
|
+
fs76.mkdirSync(evidenceDir, { recursive: true });
|
|
86083
86473
|
}
|
|
86084
|
-
|
|
86474
|
+
fs76.writeFileSync(reportPath, JSON.stringify(result, null, 2), "utf-8");
|
|
86085
86475
|
} catch (writeError) {
|
|
86086
86476
|
console.warn(`Failed to write coverage report: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
|
|
86087
86477
|
}
|
|
@@ -86162,9 +86552,9 @@ init_zod();
|
|
|
86162
86552
|
init_plan_schema();
|
|
86163
86553
|
init_qa_gate_profile();
|
|
86164
86554
|
init_file_locks();
|
|
86165
|
-
import * as
|
|
86166
|
-
import * as
|
|
86167
|
-
import * as
|
|
86555
|
+
import * as crypto10 from "node:crypto";
|
|
86556
|
+
import * as fs77 from "node:fs";
|
|
86557
|
+
import * as path99 from "node:path";
|
|
86168
86558
|
init_ledger();
|
|
86169
86559
|
init_manager();
|
|
86170
86560
|
init_state();
|
|
@@ -86242,17 +86632,17 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
86242
86632
|
};
|
|
86243
86633
|
}
|
|
86244
86634
|
if (args2.working_directory && fallbackDir) {
|
|
86245
|
-
const resolvedTarget =
|
|
86246
|
-
const resolvedRoot =
|
|
86635
|
+
const resolvedTarget = path99.resolve(args2.working_directory);
|
|
86636
|
+
const resolvedRoot = path99.resolve(fallbackDir);
|
|
86247
86637
|
let fallbackExists = false;
|
|
86248
86638
|
try {
|
|
86249
|
-
|
|
86639
|
+
fs77.accessSync(resolvedRoot, fs77.constants.F_OK);
|
|
86250
86640
|
fallbackExists = true;
|
|
86251
86641
|
} catch {
|
|
86252
86642
|
fallbackExists = false;
|
|
86253
86643
|
}
|
|
86254
86644
|
if (fallbackExists) {
|
|
86255
|
-
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot +
|
|
86645
|
+
const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path99.sep);
|
|
86256
86646
|
if (isSubdirectory) {
|
|
86257
86647
|
return {
|
|
86258
86648
|
success: false,
|
|
@@ -86268,12 +86658,12 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
86268
86658
|
let specMtime;
|
|
86269
86659
|
let specHash;
|
|
86270
86660
|
if (process.env.SWARM_SKIP_SPEC_GATE !== "1") {
|
|
86271
|
-
const specPath =
|
|
86661
|
+
const specPath = path99.join(targetWorkspace, ".swarm", "spec.md");
|
|
86272
86662
|
try {
|
|
86273
|
-
const stat7 = await
|
|
86663
|
+
const stat7 = await fs77.promises.stat(specPath);
|
|
86274
86664
|
specMtime = stat7.mtime.toISOString();
|
|
86275
|
-
const content = await
|
|
86276
|
-
specHash =
|
|
86665
|
+
const content = await fs77.promises.readFile(specPath, "utf8");
|
|
86666
|
+
specHash = crypto10.createHash("sha256").update(content).digest("hex");
|
|
86277
86667
|
} catch {
|
|
86278
86668
|
return {
|
|
86279
86669
|
success: false,
|
|
@@ -86284,10 +86674,10 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
86284
86674
|
}
|
|
86285
86675
|
}
|
|
86286
86676
|
if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
|
|
86287
|
-
const contextPath =
|
|
86677
|
+
const contextPath = path99.join(targetWorkspace, ".swarm", "context.md");
|
|
86288
86678
|
let contextContent = "";
|
|
86289
86679
|
try {
|
|
86290
|
-
contextContent = await
|
|
86680
|
+
contextContent = await fs77.promises.readFile(contextPath, "utf8");
|
|
86291
86681
|
} catch {}
|
|
86292
86682
|
const hasPendingSection = contextContent.includes("## Pending QA Gate Selection");
|
|
86293
86683
|
if (!hasPendingSection) {
|
|
@@ -86434,14 +86824,14 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
86434
86824
|
}
|
|
86435
86825
|
await writeCheckpoint(dir).catch(() => {});
|
|
86436
86826
|
try {
|
|
86437
|
-
const markerPath =
|
|
86827
|
+
const markerPath = path99.join(dir, ".swarm", ".plan-write-marker");
|
|
86438
86828
|
const marker = JSON.stringify({
|
|
86439
86829
|
source: "save_plan",
|
|
86440
86830
|
timestamp: new Date().toISOString(),
|
|
86441
86831
|
phases_count: plan.phases.length,
|
|
86442
86832
|
tasks_count: tasksCount
|
|
86443
86833
|
});
|
|
86444
|
-
await
|
|
86834
|
+
await fs77.promises.writeFile(markerPath, marker, "utf8");
|
|
86445
86835
|
} catch {}
|
|
86446
86836
|
const warnings = [];
|
|
86447
86837
|
let criticReviewFound = false;
|
|
@@ -86457,7 +86847,7 @@ async function executeSavePlan(args2, fallbackDir) {
|
|
|
86457
86847
|
return {
|
|
86458
86848
|
success: true,
|
|
86459
86849
|
message: "Plan saved successfully",
|
|
86460
|
-
plan_path:
|
|
86850
|
+
plan_path: path99.join(dir, ".swarm", "plan.json"),
|
|
86461
86851
|
phases_count: plan.phases.length,
|
|
86462
86852
|
tasks_count: tasksCount,
|
|
86463
86853
|
...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
|
|
@@ -86509,8 +86899,8 @@ var save_plan = createSwarmTool({
|
|
|
86509
86899
|
// src/tools/sbom-generate.ts
|
|
86510
86900
|
init_zod();
|
|
86511
86901
|
init_manager2();
|
|
86512
|
-
import * as
|
|
86513
|
-
import * as
|
|
86902
|
+
import * as fs78 from "node:fs";
|
|
86903
|
+
import * as path100 from "node:path";
|
|
86514
86904
|
|
|
86515
86905
|
// src/sbom/detectors/index.ts
|
|
86516
86906
|
init_utils();
|
|
@@ -87358,9 +87748,9 @@ function findManifestFiles(rootDir) {
|
|
|
87358
87748
|
const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
|
|
87359
87749
|
function searchDir(dir) {
|
|
87360
87750
|
try {
|
|
87361
|
-
const entries =
|
|
87751
|
+
const entries = fs78.readdirSync(dir, { withFileTypes: true });
|
|
87362
87752
|
for (const entry of entries) {
|
|
87363
|
-
const fullPath =
|
|
87753
|
+
const fullPath = path100.join(dir, entry.name);
|
|
87364
87754
|
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
|
|
87365
87755
|
continue;
|
|
87366
87756
|
}
|
|
@@ -87369,7 +87759,7 @@ function findManifestFiles(rootDir) {
|
|
|
87369
87759
|
} else if (entry.isFile()) {
|
|
87370
87760
|
for (const pattern of patterns) {
|
|
87371
87761
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
87372
|
-
manifestFiles.push(
|
|
87762
|
+
manifestFiles.push(path100.relative(rootDir, fullPath));
|
|
87373
87763
|
break;
|
|
87374
87764
|
}
|
|
87375
87765
|
}
|
|
@@ -87385,13 +87775,13 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
87385
87775
|
const patterns = [...new Set(allDetectors.flatMap((d) => d.patterns))];
|
|
87386
87776
|
for (const dir of directories) {
|
|
87387
87777
|
try {
|
|
87388
|
-
const entries =
|
|
87778
|
+
const entries = fs78.readdirSync(dir, { withFileTypes: true });
|
|
87389
87779
|
for (const entry of entries) {
|
|
87390
|
-
const fullPath =
|
|
87780
|
+
const fullPath = path100.join(dir, entry.name);
|
|
87391
87781
|
if (entry.isFile()) {
|
|
87392
87782
|
for (const pattern of patterns) {
|
|
87393
87783
|
if (simpleGlobToRegex(pattern).test(entry.name)) {
|
|
87394
|
-
found.push(
|
|
87784
|
+
found.push(path100.relative(workingDir, fullPath));
|
|
87395
87785
|
break;
|
|
87396
87786
|
}
|
|
87397
87787
|
}
|
|
@@ -87404,11 +87794,11 @@ function findManifestFilesInDirs(directories, workingDir) {
|
|
|
87404
87794
|
function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
87405
87795
|
const dirs = new Set;
|
|
87406
87796
|
for (const file3 of changedFiles) {
|
|
87407
|
-
let currentDir =
|
|
87797
|
+
let currentDir = path100.dirname(file3);
|
|
87408
87798
|
while (true) {
|
|
87409
|
-
if (currentDir && currentDir !== "." && currentDir !==
|
|
87410
|
-
dirs.add(
|
|
87411
|
-
const parent =
|
|
87799
|
+
if (currentDir && currentDir !== "." && currentDir !== path100.sep) {
|
|
87800
|
+
dirs.add(path100.join(workingDir, currentDir));
|
|
87801
|
+
const parent = path100.dirname(currentDir);
|
|
87412
87802
|
if (parent === currentDir)
|
|
87413
87803
|
break;
|
|
87414
87804
|
currentDir = parent;
|
|
@@ -87422,7 +87812,7 @@ function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
|
|
|
87422
87812
|
}
|
|
87423
87813
|
function ensureOutputDir(outputDir) {
|
|
87424
87814
|
try {
|
|
87425
|
-
|
|
87815
|
+
fs78.mkdirSync(outputDir, { recursive: true });
|
|
87426
87816
|
} catch (error93) {
|
|
87427
87817
|
if (!error93 || error93.code !== "EEXIST") {
|
|
87428
87818
|
throw error93;
|
|
@@ -87492,7 +87882,7 @@ var sbom_generate = createSwarmTool({
|
|
|
87492
87882
|
const changedFiles = obj.changed_files;
|
|
87493
87883
|
const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
|
|
87494
87884
|
const workingDir = directory;
|
|
87495
|
-
const outputDir =
|
|
87885
|
+
const outputDir = path100.isAbsolute(relativeOutputDir) ? relativeOutputDir : path100.join(workingDir, relativeOutputDir);
|
|
87496
87886
|
let manifestFiles = [];
|
|
87497
87887
|
if (scope === "all") {
|
|
87498
87888
|
manifestFiles = findManifestFiles(workingDir);
|
|
@@ -87515,11 +87905,11 @@ var sbom_generate = createSwarmTool({
|
|
|
87515
87905
|
const processedFiles = [];
|
|
87516
87906
|
for (const manifestFile of manifestFiles) {
|
|
87517
87907
|
try {
|
|
87518
|
-
const fullPath =
|
|
87519
|
-
if (!
|
|
87908
|
+
const fullPath = path100.isAbsolute(manifestFile) ? manifestFile : path100.join(workingDir, manifestFile);
|
|
87909
|
+
if (!fs78.existsSync(fullPath)) {
|
|
87520
87910
|
continue;
|
|
87521
87911
|
}
|
|
87522
|
-
const content =
|
|
87912
|
+
const content = fs78.readFileSync(fullPath, "utf-8");
|
|
87523
87913
|
const components = detectComponents(manifestFile, content);
|
|
87524
87914
|
processedFiles.push(manifestFile);
|
|
87525
87915
|
if (components.length > 0) {
|
|
@@ -87532,8 +87922,8 @@ var sbom_generate = createSwarmTool({
|
|
|
87532
87922
|
const bom = generateCycloneDX(allComponents);
|
|
87533
87923
|
const bomJson = serializeCycloneDX(bom);
|
|
87534
87924
|
const filename = generateSbomFilename();
|
|
87535
|
-
const outputPath =
|
|
87536
|
-
|
|
87925
|
+
const outputPath = path100.join(outputDir, filename);
|
|
87926
|
+
fs78.writeFileSync(outputPath, bomJson, "utf-8");
|
|
87537
87927
|
const verdict = processedFiles.length > 0 ? "pass" : "pass";
|
|
87538
87928
|
try {
|
|
87539
87929
|
const timestamp = new Date().toISOString();
|
|
@@ -87575,8 +87965,8 @@ var sbom_generate = createSwarmTool({
|
|
|
87575
87965
|
// src/tools/schema-drift.ts
|
|
87576
87966
|
init_zod();
|
|
87577
87967
|
init_create_tool();
|
|
87578
|
-
import * as
|
|
87579
|
-
import * as
|
|
87968
|
+
import * as fs79 from "node:fs";
|
|
87969
|
+
import * as path101 from "node:path";
|
|
87580
87970
|
var SPEC_CANDIDATES = [
|
|
87581
87971
|
"openapi.json",
|
|
87582
87972
|
"openapi.yaml",
|
|
@@ -87608,28 +87998,28 @@ function normalizePath3(p) {
|
|
|
87608
87998
|
}
|
|
87609
87999
|
function discoverSpecFile(cwd, specFileArg) {
|
|
87610
88000
|
if (specFileArg) {
|
|
87611
|
-
const resolvedPath =
|
|
87612
|
-
const normalizedCwd = cwd.endsWith(
|
|
88001
|
+
const resolvedPath = path101.resolve(cwd, specFileArg);
|
|
88002
|
+
const normalizedCwd = cwd.endsWith(path101.sep) ? cwd : cwd + path101.sep;
|
|
87613
88003
|
if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
|
|
87614
88004
|
throw new Error("Invalid spec_file: path traversal detected");
|
|
87615
88005
|
}
|
|
87616
|
-
const ext =
|
|
88006
|
+
const ext = path101.extname(resolvedPath).toLowerCase();
|
|
87617
88007
|
if (!ALLOWED_EXTENSIONS.includes(ext)) {
|
|
87618
88008
|
throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
|
|
87619
88009
|
}
|
|
87620
|
-
const stats =
|
|
88010
|
+
const stats = fs79.statSync(resolvedPath);
|
|
87621
88011
|
if (stats.size > MAX_SPEC_SIZE) {
|
|
87622
88012
|
throw new Error(`Invalid spec_file: file exceeds ${MAX_SPEC_SIZE / 1024 / 1024}MB limit`);
|
|
87623
88013
|
}
|
|
87624
|
-
if (!
|
|
88014
|
+
if (!fs79.existsSync(resolvedPath)) {
|
|
87625
88015
|
throw new Error(`Spec file not found: ${resolvedPath}`);
|
|
87626
88016
|
}
|
|
87627
88017
|
return resolvedPath;
|
|
87628
88018
|
}
|
|
87629
88019
|
for (const candidate of SPEC_CANDIDATES) {
|
|
87630
|
-
const candidatePath =
|
|
87631
|
-
if (
|
|
87632
|
-
const stats =
|
|
88020
|
+
const candidatePath = path101.resolve(cwd, candidate);
|
|
88021
|
+
if (fs79.existsSync(candidatePath)) {
|
|
88022
|
+
const stats = fs79.statSync(candidatePath);
|
|
87633
88023
|
if (stats.size <= MAX_SPEC_SIZE) {
|
|
87634
88024
|
return candidatePath;
|
|
87635
88025
|
}
|
|
@@ -87638,8 +88028,8 @@ function discoverSpecFile(cwd, specFileArg) {
|
|
|
87638
88028
|
return null;
|
|
87639
88029
|
}
|
|
87640
88030
|
function parseSpec(specFile) {
|
|
87641
|
-
const content =
|
|
87642
|
-
const ext =
|
|
88031
|
+
const content = fs79.readFileSync(specFile, "utf-8");
|
|
88032
|
+
const ext = path101.extname(specFile).toLowerCase();
|
|
87643
88033
|
if (ext === ".json") {
|
|
87644
88034
|
return parseJsonSpec(content);
|
|
87645
88035
|
}
|
|
@@ -87710,12 +88100,12 @@ function extractRoutes(cwd) {
|
|
|
87710
88100
|
function walkDir(dir) {
|
|
87711
88101
|
let entries;
|
|
87712
88102
|
try {
|
|
87713
|
-
entries =
|
|
88103
|
+
entries = fs79.readdirSync(dir, { withFileTypes: true });
|
|
87714
88104
|
} catch {
|
|
87715
88105
|
return;
|
|
87716
88106
|
}
|
|
87717
88107
|
for (const entry of entries) {
|
|
87718
|
-
const fullPath =
|
|
88108
|
+
const fullPath = path101.join(dir, entry.name);
|
|
87719
88109
|
if (entry.isSymbolicLink()) {
|
|
87720
88110
|
continue;
|
|
87721
88111
|
}
|
|
@@ -87725,7 +88115,7 @@ function extractRoutes(cwd) {
|
|
|
87725
88115
|
}
|
|
87726
88116
|
walkDir(fullPath);
|
|
87727
88117
|
} else if (entry.isFile()) {
|
|
87728
|
-
const ext =
|
|
88118
|
+
const ext = path101.extname(entry.name).toLowerCase();
|
|
87729
88119
|
const baseName = entry.name.toLowerCase();
|
|
87730
88120
|
if (![".ts", ".js", ".mjs"].includes(ext)) {
|
|
87731
88121
|
continue;
|
|
@@ -87743,7 +88133,7 @@ function extractRoutes(cwd) {
|
|
|
87743
88133
|
}
|
|
87744
88134
|
function extractRoutesFromFile(filePath) {
|
|
87745
88135
|
const routes = [];
|
|
87746
|
-
const content =
|
|
88136
|
+
const content = fs79.readFileSync(filePath, "utf-8");
|
|
87747
88137
|
const lines = content.split(/\r?\n/);
|
|
87748
88138
|
const expressRegex = /(?:app|router|server|express)\.(get|post|put|patch|delete|options|head)\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
87749
88139
|
const flaskRegex = /@(?:app|blueprint|bp)\.route\s*\(\s*['"]([^'"]+)['"]/g;
|
|
@@ -87892,8 +88282,8 @@ init_zod();
|
|
|
87892
88282
|
init_bun_compat();
|
|
87893
88283
|
init_path_security();
|
|
87894
88284
|
init_create_tool();
|
|
87895
|
-
import * as
|
|
87896
|
-
import * as
|
|
88285
|
+
import * as fs80 from "node:fs";
|
|
88286
|
+
import * as path102 from "node:path";
|
|
87897
88287
|
var DEFAULT_MAX_RESULTS = 100;
|
|
87898
88288
|
var DEFAULT_MAX_LINES = 200;
|
|
87899
88289
|
var REGEX_TIMEOUT_MS = 5000;
|
|
@@ -87929,11 +88319,11 @@ function containsWindowsAttacks3(str) {
|
|
|
87929
88319
|
}
|
|
87930
88320
|
function isPathInWorkspace3(filePath, workspace) {
|
|
87931
88321
|
try {
|
|
87932
|
-
const resolvedPath =
|
|
87933
|
-
const realWorkspace =
|
|
87934
|
-
const realResolvedPath =
|
|
87935
|
-
const relativePath =
|
|
87936
|
-
if (relativePath.startsWith("..") ||
|
|
88322
|
+
const resolvedPath = path102.resolve(workspace, filePath);
|
|
88323
|
+
const realWorkspace = fs80.realpathSync(workspace);
|
|
88324
|
+
const realResolvedPath = fs80.realpathSync(resolvedPath);
|
|
88325
|
+
const relativePath = path102.relative(realWorkspace, realResolvedPath);
|
|
88326
|
+
if (relativePath.startsWith("..") || path102.isAbsolute(relativePath)) {
|
|
87937
88327
|
return false;
|
|
87938
88328
|
}
|
|
87939
88329
|
return true;
|
|
@@ -87946,12 +88336,12 @@ function validatePathForRead2(filePath, workspace) {
|
|
|
87946
88336
|
}
|
|
87947
88337
|
function findRgInEnvPath() {
|
|
87948
88338
|
const searchPath = process.env.PATH ?? "";
|
|
87949
|
-
for (const dir of searchPath.split(
|
|
88339
|
+
for (const dir of searchPath.split(path102.delimiter)) {
|
|
87950
88340
|
if (!dir)
|
|
87951
88341
|
continue;
|
|
87952
88342
|
const isWindows = process.platform === "win32";
|
|
87953
|
-
const candidate =
|
|
87954
|
-
if (
|
|
88343
|
+
const candidate = path102.join(dir, isWindows ? "rg.exe" : "rg");
|
|
88344
|
+
if (fs80.existsSync(candidate))
|
|
87955
88345
|
return candidate;
|
|
87956
88346
|
}
|
|
87957
88347
|
return null;
|
|
@@ -88005,7 +88395,7 @@ async function ripgrepSearch(opts) {
|
|
|
88005
88395
|
stderr: "pipe",
|
|
88006
88396
|
cwd: opts.workspace
|
|
88007
88397
|
});
|
|
88008
|
-
const timeout = new Promise((
|
|
88398
|
+
const timeout = new Promise((resolve41) => setTimeout(() => resolve41("timeout"), REGEX_TIMEOUT_MS));
|
|
88009
88399
|
const exitPromise = proc.exited;
|
|
88010
88400
|
const result = await Promise.race([exitPromise, timeout]);
|
|
88011
88401
|
if (result === "timeout") {
|
|
@@ -88078,10 +88468,10 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
|
|
|
88078
88468
|
return files;
|
|
88079
88469
|
}
|
|
88080
88470
|
try {
|
|
88081
|
-
const entries =
|
|
88471
|
+
const entries = fs80.readdirSync(dir, { withFileTypes: true });
|
|
88082
88472
|
for (const entry of entries) {
|
|
88083
|
-
const fullPath =
|
|
88084
|
-
const relativePath =
|
|
88473
|
+
const fullPath = path102.join(dir, entry.name);
|
|
88474
|
+
const relativePath = path102.relative(workspace, fullPath);
|
|
88085
88475
|
if (!validatePathForRead2(fullPath, workspace)) {
|
|
88086
88476
|
continue;
|
|
88087
88477
|
}
|
|
@@ -88122,13 +88512,13 @@ async function fallbackSearch(opts) {
|
|
|
88122
88512
|
const matches = [];
|
|
88123
88513
|
let total = 0;
|
|
88124
88514
|
for (const file3 of files) {
|
|
88125
|
-
const fullPath =
|
|
88515
|
+
const fullPath = path102.join(opts.workspace, file3);
|
|
88126
88516
|
if (!validatePathForRead2(fullPath, opts.workspace)) {
|
|
88127
88517
|
continue;
|
|
88128
88518
|
}
|
|
88129
88519
|
let stats;
|
|
88130
88520
|
try {
|
|
88131
|
-
stats =
|
|
88521
|
+
stats = fs80.statSync(fullPath);
|
|
88132
88522
|
if (stats.size > MAX_FILE_SIZE_BYTES10) {
|
|
88133
88523
|
continue;
|
|
88134
88524
|
}
|
|
@@ -88137,7 +88527,7 @@ async function fallbackSearch(opts) {
|
|
|
88137
88527
|
}
|
|
88138
88528
|
let content;
|
|
88139
88529
|
try {
|
|
88140
|
-
content =
|
|
88530
|
+
content = fs80.readFileSync(fullPath, "utf-8");
|
|
88141
88531
|
} catch {
|
|
88142
88532
|
continue;
|
|
88143
88533
|
}
|
|
@@ -88249,7 +88639,7 @@ var search = createSwarmTool({
|
|
|
88249
88639
|
message: "Exclude pattern contains invalid Windows-specific sequence"
|
|
88250
88640
|
}, null, 2);
|
|
88251
88641
|
}
|
|
88252
|
-
if (!
|
|
88642
|
+
if (!fs80.existsSync(directory)) {
|
|
88253
88643
|
return JSON.stringify({
|
|
88254
88644
|
error: true,
|
|
88255
88645
|
type: "unknown",
|
|
@@ -88502,8 +88892,8 @@ var submit_phase_council_verdicts = createSwarmTool({
|
|
|
88502
88892
|
init_zod();
|
|
88503
88893
|
init_path_security();
|
|
88504
88894
|
init_create_tool();
|
|
88505
|
-
import * as
|
|
88506
|
-
import * as
|
|
88895
|
+
import * as fs81 from "node:fs";
|
|
88896
|
+
import * as path103 from "node:path";
|
|
88507
88897
|
var WINDOWS_RESERVED_NAMES4 = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|:|$)/i;
|
|
88508
88898
|
function containsWindowsAttacks4(str) {
|
|
88509
88899
|
if (/:[^\\/]/.test(str))
|
|
@@ -88517,14 +88907,14 @@ function containsWindowsAttacks4(str) {
|
|
|
88517
88907
|
}
|
|
88518
88908
|
function isPathInWorkspace4(filePath, workspace) {
|
|
88519
88909
|
try {
|
|
88520
|
-
const resolvedPath =
|
|
88521
|
-
if (!
|
|
88910
|
+
const resolvedPath = path103.resolve(workspace, filePath);
|
|
88911
|
+
if (!fs81.existsSync(resolvedPath)) {
|
|
88522
88912
|
return true;
|
|
88523
88913
|
}
|
|
88524
|
-
const realWorkspace =
|
|
88525
|
-
const realResolvedPath =
|
|
88526
|
-
const relativePath =
|
|
88527
|
-
if (relativePath.startsWith("..") ||
|
|
88914
|
+
const realWorkspace = fs81.realpathSync(workspace);
|
|
88915
|
+
const realResolvedPath = fs81.realpathSync(resolvedPath);
|
|
88916
|
+
const relativePath = path103.relative(realWorkspace, realResolvedPath);
|
|
88917
|
+
if (relativePath.startsWith("..") || path103.isAbsolute(relativePath)) {
|
|
88528
88918
|
return false;
|
|
88529
88919
|
}
|
|
88530
88920
|
return true;
|
|
@@ -88696,7 +89086,7 @@ var suggestPatch = createSwarmTool({
|
|
|
88696
89086
|
message: "changes cannot be empty"
|
|
88697
89087
|
}, null, 2);
|
|
88698
89088
|
}
|
|
88699
|
-
if (!
|
|
89089
|
+
if (!fs81.existsSync(directory)) {
|
|
88700
89090
|
return JSON.stringify({
|
|
88701
89091
|
success: false,
|
|
88702
89092
|
error: true,
|
|
@@ -88732,8 +89122,8 @@ var suggestPatch = createSwarmTool({
|
|
|
88732
89122
|
});
|
|
88733
89123
|
continue;
|
|
88734
89124
|
}
|
|
88735
|
-
const fullPath =
|
|
88736
|
-
if (!
|
|
89125
|
+
const fullPath = path103.resolve(directory, change.file);
|
|
89126
|
+
if (!fs81.existsSync(fullPath)) {
|
|
88737
89127
|
errors5.push({
|
|
88738
89128
|
success: false,
|
|
88739
89129
|
error: true,
|
|
@@ -88747,7 +89137,7 @@ var suggestPatch = createSwarmTool({
|
|
|
88747
89137
|
}
|
|
88748
89138
|
let content;
|
|
88749
89139
|
try {
|
|
88750
|
-
content =
|
|
89140
|
+
content = fs81.readFileSync(fullPath, "utf-8");
|
|
88751
89141
|
} catch (err3) {
|
|
88752
89142
|
errors5.push({
|
|
88753
89143
|
success: false,
|
|
@@ -88994,8 +89384,8 @@ var generate_mutants = createSwarmTool({
|
|
|
88994
89384
|
// src/tools/lint-spec.ts
|
|
88995
89385
|
init_spec_schema();
|
|
88996
89386
|
init_create_tool();
|
|
88997
|
-
import * as
|
|
88998
|
-
import * as
|
|
89387
|
+
import * as fs82 from "node:fs";
|
|
89388
|
+
import * as path104 from "node:path";
|
|
88999
89389
|
var SPEC_FILE_NAME = "spec.md";
|
|
89000
89390
|
var SWARM_DIR2 = ".swarm";
|
|
89001
89391
|
var OBLIGATION_KEYWORDS2 = ["MUST", "SHALL", "SHOULD", "MAY"];
|
|
@@ -89048,8 +89438,8 @@ var lint_spec = createSwarmTool({
|
|
|
89048
89438
|
async execute(_args, directory) {
|
|
89049
89439
|
const errors5 = [];
|
|
89050
89440
|
const warnings = [];
|
|
89051
|
-
const specPath =
|
|
89052
|
-
if (!
|
|
89441
|
+
const specPath = path104.join(directory, SWARM_DIR2, SPEC_FILE_NAME);
|
|
89442
|
+
if (!fs82.existsSync(specPath)) {
|
|
89053
89443
|
const result2 = {
|
|
89054
89444
|
valid: false,
|
|
89055
89445
|
specMtime: null,
|
|
@@ -89068,12 +89458,12 @@ var lint_spec = createSwarmTool({
|
|
|
89068
89458
|
}
|
|
89069
89459
|
let specMtime = null;
|
|
89070
89460
|
try {
|
|
89071
|
-
const stats =
|
|
89461
|
+
const stats = fs82.statSync(specPath);
|
|
89072
89462
|
specMtime = stats.mtime.toISOString();
|
|
89073
89463
|
} catch {}
|
|
89074
89464
|
let content;
|
|
89075
89465
|
try {
|
|
89076
|
-
content =
|
|
89466
|
+
content = fs82.readFileSync(specPath, "utf-8");
|
|
89077
89467
|
} catch (e) {
|
|
89078
89468
|
const result2 = {
|
|
89079
89469
|
valid: false,
|
|
@@ -89118,13 +89508,13 @@ var lint_spec = createSwarmTool({
|
|
|
89118
89508
|
});
|
|
89119
89509
|
// src/tools/mutation-test.ts
|
|
89120
89510
|
init_zod();
|
|
89121
|
-
import * as
|
|
89122
|
-
import * as
|
|
89511
|
+
import * as fs83 from "node:fs";
|
|
89512
|
+
import * as path106 from "node:path";
|
|
89123
89513
|
|
|
89124
89514
|
// src/mutation/engine.ts
|
|
89125
89515
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
89126
89516
|
import { unlinkSync as unlinkSync13, writeFileSync as writeFileSync20 } from "node:fs";
|
|
89127
|
-
import * as
|
|
89517
|
+
import * as path105 from "node:path";
|
|
89128
89518
|
|
|
89129
89519
|
// src/mutation/equivalence.ts
|
|
89130
89520
|
function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
@@ -89196,6 +89586,11 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
89196
89586
|
const strippedMutated = stripCode(mutatedCode);
|
|
89197
89587
|
return strippedOriginal === strippedMutated;
|
|
89198
89588
|
}
|
|
89589
|
+
var _internals32 = {
|
|
89590
|
+
isStaticallyEquivalent,
|
|
89591
|
+
checkEquivalence,
|
|
89592
|
+
batchCheckEquivalence
|
|
89593
|
+
};
|
|
89199
89594
|
async function checkEquivalence(patch, originalCode, mutatedCode, llmJudge) {
|
|
89200
89595
|
if (isStaticallyEquivalent(originalCode, mutatedCode)) {
|
|
89201
89596
|
return {
|
|
@@ -89231,7 +89626,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
89231
89626
|
const results = [];
|
|
89232
89627
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
89233
89628
|
try {
|
|
89234
|
-
const result = await checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
89629
|
+
const result = await _internals32.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
89235
89630
|
results.push(result);
|
|
89236
89631
|
} catch (err3) {
|
|
89237
89632
|
results.push({
|
|
@@ -89259,7 +89654,7 @@ async function executeMutation(patch, testCommand, _testFiles, workingDir) {
|
|
|
89259
89654
|
let patchFile;
|
|
89260
89655
|
try {
|
|
89261
89656
|
const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
89262
|
-
patchFile =
|
|
89657
|
+
patchFile = path105.join(workingDir, `.mutation_patch_${safeId2}.diff`);
|
|
89263
89658
|
try {
|
|
89264
89659
|
writeFileSync20(patchFile, patch.patch);
|
|
89265
89660
|
} catch (writeErr) {
|
|
@@ -89531,6 +89926,11 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
|
|
|
89531
89926
|
}
|
|
89532
89927
|
|
|
89533
89928
|
// src/mutation/gate.ts
|
|
89929
|
+
var _internals33 = {
|
|
89930
|
+
evaluateMutationGate,
|
|
89931
|
+
buildTestImprovementPrompt,
|
|
89932
|
+
buildMessage
|
|
89933
|
+
};
|
|
89534
89934
|
var PASS_THRESHOLD = 0.8;
|
|
89535
89935
|
var WARN_THRESHOLD = 0.6;
|
|
89536
89936
|
function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThreshold = WARN_THRESHOLD) {
|
|
@@ -89547,8 +89947,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
|
|
|
89547
89947
|
} else {
|
|
89548
89948
|
verdict = "fail";
|
|
89549
89949
|
}
|
|
89550
|
-
const testImprovementPrompt = buildTestImprovementPrompt(report, passThreshold, verdict);
|
|
89551
|
-
const message = buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
|
|
89950
|
+
const testImprovementPrompt = _internals33.buildTestImprovementPrompt(report, passThreshold, verdict);
|
|
89951
|
+
const message = _internals33.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
|
|
89552
89952
|
return {
|
|
89553
89953
|
verdict,
|
|
89554
89954
|
killRate: report.killRate,
|
|
@@ -89653,8 +90053,8 @@ var mutation_test = createSwarmTool({
|
|
|
89653
90053
|
];
|
|
89654
90054
|
for (const filePath of uniquePaths) {
|
|
89655
90055
|
try {
|
|
89656
|
-
const resolvedPath =
|
|
89657
|
-
sourceFiles.set(filePath,
|
|
90056
|
+
const resolvedPath = path106.resolve(cwd, filePath);
|
|
90057
|
+
sourceFiles.set(filePath, fs83.readFileSync(resolvedPath, "utf-8"));
|
|
89658
90058
|
} catch {}
|
|
89659
90059
|
}
|
|
89660
90060
|
const report = await executeMutationSuite(typedArgs.patches, typedArgs.test_command, typedArgs.files, cwd, undefined, undefined, sourceFiles.size > 0 ? sourceFiles : undefined);
|
|
@@ -89672,8 +90072,8 @@ var mutation_test = createSwarmTool({
|
|
|
89672
90072
|
init_zod();
|
|
89673
90073
|
init_manager2();
|
|
89674
90074
|
init_detector();
|
|
89675
|
-
import * as
|
|
89676
|
-
import * as
|
|
90075
|
+
import * as fs84 from "node:fs";
|
|
90076
|
+
import * as path107 from "node:path";
|
|
89677
90077
|
init_create_tool();
|
|
89678
90078
|
var MAX_FILE_SIZE2 = 2 * 1024 * 1024;
|
|
89679
90079
|
var BINARY_CHECK_BYTES = 8192;
|
|
@@ -89739,7 +90139,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
89739
90139
|
if (languages?.length) {
|
|
89740
90140
|
const lowerLangs = languages.map((l) => l.toLowerCase());
|
|
89741
90141
|
filesToCheck = filesToCheck.filter((file3) => {
|
|
89742
|
-
const ext =
|
|
90142
|
+
const ext = path107.extname(file3.path).toLowerCase();
|
|
89743
90143
|
const langDef = getLanguageForExtension(ext);
|
|
89744
90144
|
const fileProfile = getProfileForFile(file3.path);
|
|
89745
90145
|
const langId = fileProfile?.id || langDef?.id;
|
|
@@ -89752,7 +90152,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
89752
90152
|
let skippedCount = 0;
|
|
89753
90153
|
for (const fileInfo of filesToCheck) {
|
|
89754
90154
|
const { path: filePath } = fileInfo;
|
|
89755
|
-
const fullPath =
|
|
90155
|
+
const fullPath = path107.isAbsolute(filePath) ? filePath : path107.join(directory, filePath);
|
|
89756
90156
|
const result = {
|
|
89757
90157
|
path: filePath,
|
|
89758
90158
|
language: "",
|
|
@@ -89782,7 +90182,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
89782
90182
|
}
|
|
89783
90183
|
let content;
|
|
89784
90184
|
try {
|
|
89785
|
-
content =
|
|
90185
|
+
content = fs84.readFileSync(fullPath, "utf8");
|
|
89786
90186
|
} catch {
|
|
89787
90187
|
result.skipped_reason = "file_read_error";
|
|
89788
90188
|
skippedCount++;
|
|
@@ -89801,7 +90201,7 @@ async function syntaxCheck(input, directory, config3) {
|
|
|
89801
90201
|
results.push(result);
|
|
89802
90202
|
continue;
|
|
89803
90203
|
}
|
|
89804
|
-
const ext =
|
|
90204
|
+
const ext = path107.extname(filePath).toLowerCase();
|
|
89805
90205
|
const langDef = getLanguageForExtension(ext);
|
|
89806
90206
|
result.language = profile?.id || langDef?.id || "unknown";
|
|
89807
90207
|
const errors5 = extractSyntaxErrors(parser, content);
|
|
@@ -89893,8 +90293,8 @@ init_zod();
|
|
|
89893
90293
|
init_utils();
|
|
89894
90294
|
init_create_tool();
|
|
89895
90295
|
init_path_security();
|
|
89896
|
-
import * as
|
|
89897
|
-
import * as
|
|
90296
|
+
import * as fs85 from "node:fs";
|
|
90297
|
+
import * as path108 from "node:path";
|
|
89898
90298
|
var MAX_TEXT_LENGTH = 200;
|
|
89899
90299
|
var MAX_FILE_SIZE_BYTES11 = 1024 * 1024;
|
|
89900
90300
|
var SUPPORTED_EXTENSIONS4 = new Set([
|
|
@@ -89960,9 +90360,9 @@ function validatePathsInput(paths, cwd) {
|
|
|
89960
90360
|
return { error: "paths contains path traversal", resolvedPath: null };
|
|
89961
90361
|
}
|
|
89962
90362
|
try {
|
|
89963
|
-
const resolvedPath =
|
|
89964
|
-
const normalizedCwd =
|
|
89965
|
-
const normalizedResolved =
|
|
90363
|
+
const resolvedPath = path108.resolve(paths);
|
|
90364
|
+
const normalizedCwd = path108.resolve(cwd);
|
|
90365
|
+
const normalizedResolved = path108.resolve(resolvedPath);
|
|
89966
90366
|
if (!normalizedResolved.startsWith(normalizedCwd)) {
|
|
89967
90367
|
return {
|
|
89968
90368
|
error: "paths must be within the current working directory",
|
|
@@ -89978,13 +90378,13 @@ function validatePathsInput(paths, cwd) {
|
|
|
89978
90378
|
}
|
|
89979
90379
|
}
|
|
89980
90380
|
function isSupportedExtension(filePath) {
|
|
89981
|
-
const ext =
|
|
90381
|
+
const ext = path108.extname(filePath).toLowerCase();
|
|
89982
90382
|
return SUPPORTED_EXTENSIONS4.has(ext);
|
|
89983
90383
|
}
|
|
89984
90384
|
function findSourceFiles3(dir, files = []) {
|
|
89985
90385
|
let entries;
|
|
89986
90386
|
try {
|
|
89987
|
-
entries =
|
|
90387
|
+
entries = fs85.readdirSync(dir);
|
|
89988
90388
|
} catch {
|
|
89989
90389
|
return files;
|
|
89990
90390
|
}
|
|
@@ -89993,10 +90393,10 @@ function findSourceFiles3(dir, files = []) {
|
|
|
89993
90393
|
if (SKIP_DIRECTORIES5.has(entry)) {
|
|
89994
90394
|
continue;
|
|
89995
90395
|
}
|
|
89996
|
-
const fullPath =
|
|
90396
|
+
const fullPath = path108.join(dir, entry);
|
|
89997
90397
|
let stat7;
|
|
89998
90398
|
try {
|
|
89999
|
-
stat7 =
|
|
90399
|
+
stat7 = fs85.statSync(fullPath);
|
|
90000
90400
|
} catch {
|
|
90001
90401
|
continue;
|
|
90002
90402
|
}
|
|
@@ -90089,7 +90489,7 @@ var todo_extract = createSwarmTool({
|
|
|
90089
90489
|
return JSON.stringify(errorResult, null, 2);
|
|
90090
90490
|
}
|
|
90091
90491
|
const scanPath = resolvedPath;
|
|
90092
|
-
if (!
|
|
90492
|
+
if (!fs85.existsSync(scanPath)) {
|
|
90093
90493
|
const errorResult = {
|
|
90094
90494
|
error: `path not found: ${pathsInput}`,
|
|
90095
90495
|
total: 0,
|
|
@@ -90099,13 +90499,13 @@ var todo_extract = createSwarmTool({
|
|
|
90099
90499
|
return JSON.stringify(errorResult, null, 2);
|
|
90100
90500
|
}
|
|
90101
90501
|
const filesToScan = [];
|
|
90102
|
-
const stat7 =
|
|
90502
|
+
const stat7 = fs85.statSync(scanPath);
|
|
90103
90503
|
if (stat7.isFile()) {
|
|
90104
90504
|
if (isSupportedExtension(scanPath)) {
|
|
90105
90505
|
filesToScan.push(scanPath);
|
|
90106
90506
|
} else {
|
|
90107
90507
|
const errorResult = {
|
|
90108
|
-
error: `unsupported file extension: ${
|
|
90508
|
+
error: `unsupported file extension: ${path108.extname(scanPath)}`,
|
|
90109
90509
|
total: 0,
|
|
90110
90510
|
byPriority: { high: 0, medium: 0, low: 0 },
|
|
90111
90511
|
entries: []
|
|
@@ -90118,11 +90518,11 @@ var todo_extract = createSwarmTool({
|
|
|
90118
90518
|
const allEntries = [];
|
|
90119
90519
|
for (const filePath of filesToScan) {
|
|
90120
90520
|
try {
|
|
90121
|
-
const fileStat =
|
|
90521
|
+
const fileStat = fs85.statSync(filePath);
|
|
90122
90522
|
if (fileStat.size > MAX_FILE_SIZE_BYTES11) {
|
|
90123
90523
|
continue;
|
|
90124
90524
|
}
|
|
90125
|
-
const content =
|
|
90525
|
+
const content = fs85.readFileSync(filePath, "utf-8");
|
|
90126
90526
|
const entries = parseTodoComments(content, filePath, tagsSet);
|
|
90127
90527
|
allEntries.push(...entries);
|
|
90128
90528
|
} catch {}
|
|
@@ -90153,19 +90553,19 @@ init_loader();
|
|
|
90153
90553
|
init_schema();
|
|
90154
90554
|
init_qa_gate_profile();
|
|
90155
90555
|
init_gate_evidence();
|
|
90156
|
-
import * as
|
|
90157
|
-
import * as
|
|
90556
|
+
import * as fs88 from "node:fs";
|
|
90557
|
+
import * as path111 from "node:path";
|
|
90158
90558
|
|
|
90159
90559
|
// src/hooks/diff-scope.ts
|
|
90160
90560
|
init_bun_compat();
|
|
90161
|
-
import * as
|
|
90162
|
-
import * as
|
|
90561
|
+
import * as fs87 from "node:fs";
|
|
90562
|
+
import * as path110 from "node:path";
|
|
90163
90563
|
|
|
90164
90564
|
// src/utils/gitignore-warning.ts
|
|
90165
90565
|
init_bun_compat();
|
|
90166
|
-
import * as
|
|
90167
|
-
import * as
|
|
90168
|
-
var
|
|
90566
|
+
import * as fs86 from "node:fs";
|
|
90567
|
+
import * as path109 from "node:path";
|
|
90568
|
+
var _internals34 = { bunSpawn };
|
|
90169
90569
|
var _swarmGitExcludedChecked = false;
|
|
90170
90570
|
function fileCoversSwarm(content) {
|
|
90171
90571
|
for (const rawLine of content.split(`
|
|
@@ -90198,7 +90598,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
90198
90598
|
checkIgnoreExitCode
|
|
90199
90599
|
] = await Promise.all([
|
|
90200
90600
|
(async () => {
|
|
90201
|
-
const proc =
|
|
90601
|
+
const proc = _internals34.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
|
|
90202
90602
|
try {
|
|
90203
90603
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
90204
90604
|
} finally {
|
|
@@ -90208,7 +90608,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
90208
90608
|
}
|
|
90209
90609
|
})(),
|
|
90210
90610
|
(async () => {
|
|
90211
|
-
const proc =
|
|
90611
|
+
const proc = _internals34.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
|
|
90212
90612
|
try {
|
|
90213
90613
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
90214
90614
|
} finally {
|
|
@@ -90218,7 +90618,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
90218
90618
|
}
|
|
90219
90619
|
})(),
|
|
90220
90620
|
(async () => {
|
|
90221
|
-
const proc =
|
|
90621
|
+
const proc = _internals34.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
|
|
90222
90622
|
try {
|
|
90223
90623
|
return await proc.exited;
|
|
90224
90624
|
} finally {
|
|
@@ -90238,16 +90638,16 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
90238
90638
|
const excludeRelPath = excludePathRaw.trim();
|
|
90239
90639
|
if (!excludeRelPath)
|
|
90240
90640
|
return;
|
|
90241
|
-
const excludePath =
|
|
90641
|
+
const excludePath = path109.isAbsolute(excludeRelPath) ? excludeRelPath : path109.join(directory, excludeRelPath);
|
|
90242
90642
|
if (checkIgnoreExitCode !== 0) {
|
|
90243
90643
|
try {
|
|
90244
|
-
|
|
90644
|
+
fs86.mkdirSync(path109.dirname(excludePath), { recursive: true });
|
|
90245
90645
|
let existing = "";
|
|
90246
90646
|
try {
|
|
90247
|
-
existing =
|
|
90647
|
+
existing = fs86.readFileSync(excludePath, "utf8");
|
|
90248
90648
|
} catch {}
|
|
90249
90649
|
if (!fileCoversSwarm(existing)) {
|
|
90250
|
-
|
|
90650
|
+
fs86.appendFileSync(excludePath, `
|
|
90251
90651
|
# opencode-swarm local runtime state
|
|
90252
90652
|
.swarm/
|
|
90253
90653
|
`, "utf8");
|
|
@@ -90257,7 +90657,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
90257
90657
|
}
|
|
90258
90658
|
} catch {}
|
|
90259
90659
|
}
|
|
90260
|
-
const trackedProc =
|
|
90660
|
+
const trackedProc = _internals34.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
|
|
90261
90661
|
let trackedExitCode;
|
|
90262
90662
|
let trackedOutput;
|
|
90263
90663
|
try {
|
|
@@ -90282,13 +90682,13 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
90282
90682
|
}
|
|
90283
90683
|
|
|
90284
90684
|
// src/hooks/diff-scope.ts
|
|
90285
|
-
var
|
|
90685
|
+
var _internals35 = { bunSpawn };
|
|
90286
90686
|
function getDeclaredScope(taskId, directory) {
|
|
90287
90687
|
try {
|
|
90288
|
-
const planPath =
|
|
90289
|
-
if (!
|
|
90688
|
+
const planPath = path110.join(directory, ".swarm", "plan.json");
|
|
90689
|
+
if (!fs87.existsSync(planPath))
|
|
90290
90690
|
return null;
|
|
90291
|
-
const raw =
|
|
90691
|
+
const raw = fs87.readFileSync(planPath, "utf-8");
|
|
90292
90692
|
const plan = JSON.parse(raw);
|
|
90293
90693
|
for (const phase of plan.phases ?? []) {
|
|
90294
90694
|
for (const task of phase.tasks ?? []) {
|
|
@@ -90317,7 +90717,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
|
|
|
90317
90717
|
};
|
|
90318
90718
|
async function getChangedFiles(directory) {
|
|
90319
90719
|
try {
|
|
90320
|
-
const proc =
|
|
90720
|
+
const proc = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
|
|
90321
90721
|
cwd: directory,
|
|
90322
90722
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
90323
90723
|
});
|
|
@@ -90334,7 +90734,7 @@ async function getChangedFiles(directory) {
|
|
|
90334
90734
|
return stdout.trim().split(`
|
|
90335
90735
|
`).map((f) => f.trim()).filter((f) => f.length > 0);
|
|
90336
90736
|
}
|
|
90337
|
-
const proc2 =
|
|
90737
|
+
const proc2 = _internals35.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
|
|
90338
90738
|
cwd: directory,
|
|
90339
90739
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
90340
90740
|
});
|
|
@@ -90422,7 +90822,7 @@ var TIER_3_PATTERNS = [
|
|
|
90422
90822
|
];
|
|
90423
90823
|
function matchesTier3Pattern(files) {
|
|
90424
90824
|
for (const file3 of files) {
|
|
90425
|
-
const fileName =
|
|
90825
|
+
const fileName = path111.basename(file3);
|
|
90426
90826
|
for (const pattern of TIER_3_PATTERNS) {
|
|
90427
90827
|
if (pattern.test(fileName)) {
|
|
90428
90828
|
return true;
|
|
@@ -90436,8 +90836,8 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
90436
90836
|
if (hasActiveTurboMode()) {
|
|
90437
90837
|
const resolvedDir2 = workingDirectory;
|
|
90438
90838
|
try {
|
|
90439
|
-
const planPath =
|
|
90440
|
-
const planRaw =
|
|
90839
|
+
const planPath = path111.join(resolvedDir2, ".swarm", "plan.json");
|
|
90840
|
+
const planRaw = fs88.readFileSync(planPath, "utf-8");
|
|
90441
90841
|
const plan = JSON.parse(planRaw);
|
|
90442
90842
|
for (const planPhase of plan.phases ?? []) {
|
|
90443
90843
|
for (const task of planPhase.tasks ?? []) {
|
|
@@ -90506,8 +90906,8 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
90506
90906
|
}
|
|
90507
90907
|
try {
|
|
90508
90908
|
const resolvedDir2 = workingDirectory;
|
|
90509
|
-
const planPath =
|
|
90510
|
-
const planRaw =
|
|
90909
|
+
const planPath = path111.join(resolvedDir2, ".swarm", "plan.json");
|
|
90910
|
+
const planRaw = fs88.readFileSync(planPath, "utf-8");
|
|
90511
90911
|
const plan = JSON.parse(planRaw);
|
|
90512
90912
|
for (const planPhase of plan.phases ?? []) {
|
|
90513
90913
|
for (const task of planPhase.tasks ?? []) {
|
|
@@ -90696,8 +91096,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
90696
91096
|
};
|
|
90697
91097
|
}
|
|
90698
91098
|
}
|
|
90699
|
-
normalizedDir =
|
|
90700
|
-
const pathParts = normalizedDir.split(
|
|
91099
|
+
normalizedDir = path111.normalize(args2.working_directory);
|
|
91100
|
+
const pathParts = normalizedDir.split(path111.sep);
|
|
90701
91101
|
if (pathParts.includes("..")) {
|
|
90702
91102
|
return {
|
|
90703
91103
|
success: false,
|
|
@@ -90707,11 +91107,11 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
90707
91107
|
]
|
|
90708
91108
|
};
|
|
90709
91109
|
}
|
|
90710
|
-
const resolvedDir =
|
|
91110
|
+
const resolvedDir = path111.resolve(normalizedDir);
|
|
90711
91111
|
try {
|
|
90712
|
-
const realPath =
|
|
90713
|
-
const planPath =
|
|
90714
|
-
if (!
|
|
91112
|
+
const realPath = fs88.realpathSync(resolvedDir);
|
|
91113
|
+
const planPath = path111.join(realPath, ".swarm", "plan.json");
|
|
91114
|
+
if (!fs88.existsSync(planPath)) {
|
|
90715
91115
|
return {
|
|
90716
91116
|
success: false,
|
|
90717
91117
|
message: `Invalid working_directory: plan not found in "${realPath}"`,
|
|
@@ -90742,22 +91142,22 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
90742
91142
|
}
|
|
90743
91143
|
if (args2.status === "in_progress") {
|
|
90744
91144
|
try {
|
|
90745
|
-
const evidencePath =
|
|
90746
|
-
|
|
90747
|
-
const fd =
|
|
91145
|
+
const evidencePath = path111.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
91146
|
+
fs88.mkdirSync(path111.dirname(evidencePath), { recursive: true });
|
|
91147
|
+
const fd = fs88.openSync(evidencePath, "wx");
|
|
90748
91148
|
let writeOk = false;
|
|
90749
91149
|
try {
|
|
90750
|
-
|
|
91150
|
+
fs88.writeSync(fd, JSON.stringify({
|
|
90751
91151
|
taskId: args2.task_id,
|
|
90752
91152
|
required_gates: ["reviewer", "test_engineer"],
|
|
90753
91153
|
gates: {}
|
|
90754
91154
|
}, null, 2));
|
|
90755
91155
|
writeOk = true;
|
|
90756
91156
|
} finally {
|
|
90757
|
-
|
|
91157
|
+
fs88.closeSync(fd);
|
|
90758
91158
|
if (!writeOk) {
|
|
90759
91159
|
try {
|
|
90760
|
-
|
|
91160
|
+
fs88.unlinkSync(evidencePath);
|
|
90761
91161
|
} catch {}
|
|
90762
91162
|
}
|
|
90763
91163
|
}
|
|
@@ -90767,8 +91167,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir) {
|
|
|
90767
91167
|
recoverTaskStateFromDelegations(args2.task_id);
|
|
90768
91168
|
let phaseRequiresReviewer = true;
|
|
90769
91169
|
try {
|
|
90770
|
-
const planPath =
|
|
90771
|
-
const planRaw =
|
|
91170
|
+
const planPath = path111.join(directory, ".swarm", "plan.json");
|
|
91171
|
+
const planRaw = fs88.readFileSync(planPath, "utf-8");
|
|
90772
91172
|
const plan = JSON.parse(planRaw);
|
|
90773
91173
|
const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
|
|
90774
91174
|
if (taskPhase?.required_agents && !taskPhase.required_agents.includes("reviewer")) {
|
|
@@ -91078,8 +91478,8 @@ init_utils2();
|
|
|
91078
91478
|
init_ledger();
|
|
91079
91479
|
init_manager();
|
|
91080
91480
|
init_create_tool();
|
|
91081
|
-
import
|
|
91082
|
-
import
|
|
91481
|
+
import fs89 from "node:fs";
|
|
91482
|
+
import path112 from "node:path";
|
|
91083
91483
|
function derivePlanId5(plan) {
|
|
91084
91484
|
return `${plan.swarm}-${plan.title}`.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
91085
91485
|
}
|
|
@@ -91130,7 +91530,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
91130
91530
|
entries: [evidenceEntry]
|
|
91131
91531
|
};
|
|
91132
91532
|
const filename = "drift-verifier.json";
|
|
91133
|
-
const relativePath =
|
|
91533
|
+
const relativePath = path112.join("evidence", String(phase), filename);
|
|
91134
91534
|
let validatedPath;
|
|
91135
91535
|
try {
|
|
91136
91536
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -91141,12 +91541,12 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
91141
91541
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
91142
91542
|
}, null, 2);
|
|
91143
91543
|
}
|
|
91144
|
-
const evidenceDir =
|
|
91544
|
+
const evidenceDir = path112.dirname(validatedPath);
|
|
91145
91545
|
try {
|
|
91146
|
-
await
|
|
91147
|
-
const tempPath =
|
|
91148
|
-
await
|
|
91149
|
-
await
|
|
91546
|
+
await fs89.promises.mkdir(evidenceDir, { recursive: true });
|
|
91547
|
+
const tempPath = path112.join(evidenceDir, `.${filename}.tmp`);
|
|
91548
|
+
await fs89.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
91549
|
+
await fs89.promises.rename(tempPath, validatedPath);
|
|
91150
91550
|
let snapshotInfo;
|
|
91151
91551
|
let snapshotError;
|
|
91152
91552
|
let qaProfileLocked;
|
|
@@ -91240,8 +91640,8 @@ var write_drift_evidence = createSwarmTool({
|
|
|
91240
91640
|
init_zod();
|
|
91241
91641
|
init_utils2();
|
|
91242
91642
|
init_create_tool();
|
|
91243
|
-
import
|
|
91244
|
-
import
|
|
91643
|
+
import fs90 from "node:fs";
|
|
91644
|
+
import path113 from "node:path";
|
|
91245
91645
|
function normalizeVerdict2(verdict) {
|
|
91246
91646
|
switch (verdict) {
|
|
91247
91647
|
case "APPROVED":
|
|
@@ -91289,7 +91689,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
91289
91689
|
entries: [evidenceEntry]
|
|
91290
91690
|
};
|
|
91291
91691
|
const filename = "hallucination-guard.json";
|
|
91292
|
-
const relativePath =
|
|
91692
|
+
const relativePath = path113.join("evidence", String(phase), filename);
|
|
91293
91693
|
let validatedPath;
|
|
91294
91694
|
try {
|
|
91295
91695
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -91300,12 +91700,12 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
91300
91700
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
91301
91701
|
}, null, 2);
|
|
91302
91702
|
}
|
|
91303
|
-
const evidenceDir =
|
|
91703
|
+
const evidenceDir = path113.dirname(validatedPath);
|
|
91304
91704
|
try {
|
|
91305
|
-
await
|
|
91306
|
-
const tempPath =
|
|
91307
|
-
await
|
|
91308
|
-
await
|
|
91705
|
+
await fs90.promises.mkdir(evidenceDir, { recursive: true });
|
|
91706
|
+
const tempPath = path113.join(evidenceDir, `.${filename}.tmp`);
|
|
91707
|
+
await fs90.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
91708
|
+
await fs90.promises.rename(tempPath, validatedPath);
|
|
91309
91709
|
return JSON.stringify({
|
|
91310
91710
|
success: true,
|
|
91311
91711
|
phase,
|
|
@@ -91351,8 +91751,8 @@ var write_hallucination_evidence = createSwarmTool({
|
|
|
91351
91751
|
init_zod();
|
|
91352
91752
|
init_utils2();
|
|
91353
91753
|
init_create_tool();
|
|
91354
|
-
import
|
|
91355
|
-
import
|
|
91754
|
+
import fs91 from "node:fs";
|
|
91755
|
+
import path114 from "node:path";
|
|
91356
91756
|
function normalizeVerdict3(verdict) {
|
|
91357
91757
|
switch (verdict) {
|
|
91358
91758
|
case "PASS":
|
|
@@ -91426,7 +91826,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
91426
91826
|
entries: [evidenceEntry]
|
|
91427
91827
|
};
|
|
91428
91828
|
const filename = "mutation-gate.json";
|
|
91429
|
-
const relativePath =
|
|
91829
|
+
const relativePath = path114.join("evidence", String(phase), filename);
|
|
91430
91830
|
let validatedPath;
|
|
91431
91831
|
try {
|
|
91432
91832
|
validatedPath = validateSwarmPath(directory, relativePath);
|
|
@@ -91437,12 +91837,12 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
91437
91837
|
message: error93 instanceof Error ? error93.message : "Failed to validate path"
|
|
91438
91838
|
}, null, 2);
|
|
91439
91839
|
}
|
|
91440
|
-
const evidenceDir =
|
|
91840
|
+
const evidenceDir = path114.dirname(validatedPath);
|
|
91441
91841
|
try {
|
|
91442
|
-
await
|
|
91443
|
-
const tempPath =
|
|
91444
|
-
await
|
|
91445
|
-
await
|
|
91842
|
+
await fs91.promises.mkdir(evidenceDir, { recursive: true });
|
|
91843
|
+
const tempPath = path114.join(evidenceDir, `.${filename}.tmp`);
|
|
91844
|
+
await fs91.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
|
|
91845
|
+
await fs91.promises.rename(tempPath, validatedPath);
|
|
91446
91846
|
return JSON.stringify({
|
|
91447
91847
|
success: true,
|
|
91448
91848
|
phase,
|
|
@@ -91734,7 +92134,7 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
91734
92134
|
const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
|
|
91735
92135
|
preflightTriggerManager = new PTM(automationConfig);
|
|
91736
92136
|
const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
|
|
91737
|
-
const swarmDir =
|
|
92137
|
+
const swarmDir = path115.resolve(ctx.directory, ".swarm");
|
|
91738
92138
|
statusArtifact = new ASA(swarmDir);
|
|
91739
92139
|
statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
|
|
91740
92140
|
if (automationConfig.capabilities?.evidence_auto_summaries === true) {
|
|
@@ -91840,6 +92240,7 @@ async function initializeOpenCodeSwarm(ctx) {
|
|
|
91840
92240
|
completion_verify,
|
|
91841
92241
|
complexity_hotspots,
|
|
91842
92242
|
submit_council_verdicts,
|
|
92243
|
+
submit_phase_council_verdicts,
|
|
91843
92244
|
convene_general_council,
|
|
91844
92245
|
curator_analyze,
|
|
91845
92246
|
declare_council_criteria,
|