opencode-swarm 7.99.2 → 7.99.4
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/cli/{evidence-summary-service-wxarfgt8.js → evidence-summary-service-5ww1npaa.js} +1 -1
- package/dist/cli/{guardrail-explain-t3prwa5b.js → guardrail-explain-3dxh8t8v.js} +3 -3
- package/dist/cli/{index-62tmq1kc.js → index-0avc4356.js} +27 -9
- package/dist/cli/{index-6wgwybzj.js → index-9twtnjkv.js} +28 -2
- package/dist/cli/{index-ryns3fqt.js → index-r431nee9.js} +3 -3
- package/dist/cli/{index-y4stbk2f.js → index-rq7arj2r.js} +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/config/plan-schema.d.ts +21 -0
- package/dist/index.js +659 -535
- package/dist/plan/manager.d.ts +6 -0
- package/dist/services/version-check.d.ts +32 -0
- package/dist/state.d.ts +35 -0
- package/dist/tools/update-task-status.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ var package_default;
|
|
|
69
69
|
var init_package = __esm(() => {
|
|
70
70
|
package_default = {
|
|
71
71
|
name: "opencode-swarm",
|
|
72
|
-
version: "7.99.
|
|
72
|
+
version: "7.99.4",
|
|
73
73
|
description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
74
74
|
main: "dist/index.js",
|
|
75
75
|
types: "dist/index.d.ts",
|
|
@@ -20525,6 +20525,25 @@ async function getLatestLedgerHash(directory) {
|
|
|
20525
20525
|
return "";
|
|
20526
20526
|
}
|
|
20527
20527
|
}
|
|
20528
|
+
async function surfaceLedgerStaleIfPersisted(directory, plan) {
|
|
20529
|
+
const resolvedWorkspace = path13.resolve(directory);
|
|
20530
|
+
if (!ledgerStaleWorkspaces.has(resolvedWorkspace)) {
|
|
20531
|
+
return plan;
|
|
20532
|
+
}
|
|
20533
|
+
try {
|
|
20534
|
+
const planHash = computePlanHash(plan);
|
|
20535
|
+
const ledgerHash = await getLatestLedgerHash(directory);
|
|
20536
|
+
if (ledgerHash !== "" && planHash === ledgerHash) {
|
|
20537
|
+
ledgerStaleWorkspaces.delete(resolvedWorkspace);
|
|
20538
|
+
return plan;
|
|
20539
|
+
}
|
|
20540
|
+
} catch {}
|
|
20541
|
+
plan._ledgerReplayStale = true;
|
|
20542
|
+
if (typeof plan._ledgerReplayStaleReason !== "string" || plan._ledgerReplayStaleReason.length === 0) {
|
|
20543
|
+
plan._ledgerReplayStaleReason = "plan.json still hash-mismatches the ledger after a startup ledger-replay failure (replay could not be applied and no critic-approved snapshot was available). Run /swarm reset-session if this persists.";
|
|
20544
|
+
}
|
|
20545
|
+
return plan;
|
|
20546
|
+
}
|
|
20528
20547
|
async function parsePlanJsonCached(directory) {
|
|
20529
20548
|
const planJsonPath = path13.resolve(directory, ".swarm", "plan.json");
|
|
20530
20549
|
return readCachedParsedFile(planJsonPath, PLAN_JSON_CACHE_NAMESPACE, () => readSwarmFileAsync(directory, "plan.json"), (planJsonContent) => {
|
|
@@ -20583,7 +20602,7 @@ async function isPlanMdInSync(directory, plan, cache) {
|
|
|
20583
20602
|
if (normalizedActual === normalizedExpected) {
|
|
20584
20603
|
return true;
|
|
20585
20604
|
}
|
|
20586
|
-
return
|
|
20605
|
+
return false;
|
|
20587
20606
|
}
|
|
20588
20607
|
async function regeneratePlanMarkdown(directory, plan) {
|
|
20589
20608
|
const swarmDir = path13.resolve(directory, ".swarm");
|
|
@@ -20664,6 +20683,12 @@ async function loadPlan(directory, cache) {
|
|
|
20664
20683
|
return approved.plan;
|
|
20665
20684
|
}
|
|
20666
20685
|
} catch {}
|
|
20686
|
+
{
|
|
20687
|
+
const runtimeStale = validated;
|
|
20688
|
+
runtimeStale._ledgerReplayStale = true;
|
|
20689
|
+
runtimeStale._ledgerReplayStaleReason = `Ledger replay failed during hash-mismatch rebuild and no approved snapshot was available: ${replayError instanceof Error ? replayError.message : String(replayError)}`;
|
|
20690
|
+
ledgerStaleWorkspaces.add(resolvedWorkspace);
|
|
20691
|
+
}
|
|
20667
20692
|
warn(`[loadPlan] Ledger replay failed during hash-mismatch rebuild: ${replayError instanceof Error ? replayError.message : String(replayError)}. Returning stale plan.json. To recover: check .swarm/plan-export/SWARM_PLAN.md for a checkpoint, or run /swarm reset-session.`);
|
|
20668
20693
|
}
|
|
20669
20694
|
}
|
|
@@ -20708,7 +20733,7 @@ async function loadPlan(directory, cache) {
|
|
|
20708
20733
|
} catch {}
|
|
20709
20734
|
}
|
|
20710
20735
|
}
|
|
20711
|
-
return validated;
|
|
20736
|
+
return await surfaceLedgerStaleIfPersisted(directory, validated);
|
|
20712
20737
|
}
|
|
20713
20738
|
} catch (error49) {
|
|
20714
20739
|
warn(`[loadPlan] plan.json validation failed: ${error49 instanceof Error ? error49.message : String(error49)}. Attempting rebuild from ledger. If rebuild fails, check .swarm/plan-export/SWARM_PLAN.md for a checkpoint.`);
|
|
@@ -21646,7 +21671,7 @@ function migrateLegacyPlan(planContent, swarmId) {
|
|
|
21646
21671
|
};
|
|
21647
21672
|
return plan;
|
|
21648
21673
|
}
|
|
21649
|
-
var PlanConcurrentModificationError, PlanTaskRemovalNotAcknowledgedError, startupLedgerCheckedWorkspaces, recoveryMutexes, PLAN_JSON_CACHE_NAMESPACE = "plan-json:validated:v1", _internals8, CAS_BACKOFF_START_MS = 5, CAS_BACKOFF_CAP_MS = 250, CAS_BACKOFF_JITTER = 0.25, CAS_MAX_RETRIES = 3;
|
|
21674
|
+
var PlanConcurrentModificationError, PlanTaskRemovalNotAcknowledgedError, startupLedgerCheckedWorkspaces, ledgerStaleWorkspaces, recoveryMutexes, PLAN_JSON_CACHE_NAMESPACE = "plan-json:validated:v1", _internals8, CAS_BACKOFF_START_MS = 5, CAS_BACKOFF_CAP_MS = 250, CAS_BACKOFF_JITTER = 0.25, CAS_MAX_RETRIES = 3;
|
|
21650
21675
|
var init_manager = __esm(() => {
|
|
21651
21676
|
init_plan_schema();
|
|
21652
21677
|
init_branch();
|
|
@@ -21678,6 +21703,7 @@ var init_manager = __esm(() => {
|
|
|
21678
21703
|
}
|
|
21679
21704
|
};
|
|
21680
21705
|
startupLedgerCheckedWorkspaces = new Set;
|
|
21706
|
+
ledgerStaleWorkspaces = new Set;
|
|
21681
21707
|
recoveryMutexes = new Map;
|
|
21682
21708
|
_internals8 = {
|
|
21683
21709
|
loadPlan,
|
|
@@ -47088,6 +47114,7 @@ var init_pr_subscriptions = __esm(() => {
|
|
|
47088
47114
|
var exports_state = {};
|
|
47089
47115
|
__export(exports_state, {
|
|
47090
47116
|
updateAgentEventTime: () => updateAgentEventTime,
|
|
47117
|
+
sweepStaleSessions: () => sweepStaleSessions,
|
|
47091
47118
|
swarmState: () => swarmState,
|
|
47092
47119
|
startAgentSession: () => startAgentSession,
|
|
47093
47120
|
setSessionEnvironment: () => setSessionEnvironment,
|
|
@@ -47099,6 +47126,7 @@ __export(exports_state, {
|
|
|
47099
47126
|
recordStageBCompletion: () => recordStageBCompletion,
|
|
47100
47127
|
recordPhaseAgentDispatch: () => recordPhaseAgentDispatch,
|
|
47101
47128
|
pruneOldWindows: () => pruneOldWindows,
|
|
47129
|
+
maybeSweepStaleSessions: () => maybeSweepStaleSessions,
|
|
47102
47130
|
isCouncilGateActive: () => isCouncilGateActive,
|
|
47103
47131
|
hasBothStageBCompletions: () => hasBothStageBCompletions,
|
|
47104
47132
|
hasActiveTurboMode: () => hasActiveTurboMode,
|
|
@@ -47144,6 +47172,7 @@ function resetSwarmState() {
|
|
|
47144
47172
|
swarmState.pendingEvents = 0;
|
|
47145
47173
|
swarmState.lastBudgetPct = 0;
|
|
47146
47174
|
swarmState.agentSessions.clear();
|
|
47175
|
+
_lastIdleSweepAtMs = 0;
|
|
47147
47176
|
clearTrajectoryCache();
|
|
47148
47177
|
clearTrajectoryStepCounters();
|
|
47149
47178
|
swarmState.pendingRehydrations.clear();
|
|
@@ -47185,8 +47214,7 @@ function resetSwarmStatePreservingSingletons() {
|
|
|
47185
47214
|
swarmState.specWriterAgentNames = preservedSpecWriterAgentNames;
|
|
47186
47215
|
swarmState.generatedAgentNames = preservedGeneratedAgentNames;
|
|
47187
47216
|
}
|
|
47188
|
-
function
|
|
47189
|
-
const now = Date.now();
|
|
47217
|
+
function sweepStaleSessions(staleDurationMs = STALE_SESSION_TTL_MS, now = Date.now()) {
|
|
47190
47218
|
const staleIds = [];
|
|
47191
47219
|
for (const [id, session] of swarmState.agentSessions) {
|
|
47192
47220
|
if (now - session.lastToolCallTime > staleDurationMs) {
|
|
@@ -47195,7 +47223,20 @@ function startAgentSession(sessionId, agentName, staleDurationMs = 7200000, dire
|
|
|
47195
47223
|
}
|
|
47196
47224
|
for (const id of staleIds) {
|
|
47197
47225
|
swarmState.agentSessions.delete(id);
|
|
47226
|
+
swarmState.delegationChains.delete(id);
|
|
47227
|
+
}
|
|
47228
|
+
return staleIds;
|
|
47229
|
+
}
|
|
47230
|
+
function maybeSweepStaleSessions(staleDurationMs = STALE_SESSION_TTL_MS, now = Date.now()) {
|
|
47231
|
+
if (now - _lastIdleSweepAtMs < IDLE_SWEEP_COOLDOWN_MS) {
|
|
47232
|
+
return [];
|
|
47198
47233
|
}
|
|
47234
|
+
_lastIdleSweepAtMs = now;
|
|
47235
|
+
return sweepStaleSessions(staleDurationMs, now);
|
|
47236
|
+
}
|
|
47237
|
+
function startAgentSession(sessionId, agentName, staleDurationMs = STALE_SESSION_TTL_MS, directory) {
|
|
47238
|
+
const now = Date.now();
|
|
47239
|
+
sweepStaleSessions(staleDurationMs, now);
|
|
47199
47240
|
const sessionState = {
|
|
47200
47241
|
agentName,
|
|
47201
47242
|
lastToolCallTime: now,
|
|
@@ -47446,6 +47487,7 @@ function ensureAgentSession(sessionId, agentName, directory) {
|
|
|
47446
47487
|
session.prSubscriptions = new Map;
|
|
47447
47488
|
}
|
|
47448
47489
|
session.lastToolCallTime = now;
|
|
47490
|
+
maybeSweepStaleSessions();
|
|
47449
47491
|
return session;
|
|
47450
47492
|
}
|
|
47451
47493
|
_internals25.startAgentSession(sessionId, agentName ?? "unknown", 7200000, directory);
|
|
@@ -47930,7 +47972,7 @@ async function rehydratePrSubscriptions(sessionID, directory) {
|
|
|
47930
47972
|
}
|
|
47931
47973
|
return map2;
|
|
47932
47974
|
}
|
|
47933
|
-
var _rehydrationCache = null, _councilDisagreementWarned, STATE_ORDER, _toolAggregates, defaultRunContext, _runContexts, swarmState, MAX_TRACKED_CRITICAL_SHOWN = 500, MAX_TRACKED_KNOWLEDGE_ACKS = 5000, _internals25;
|
|
47975
|
+
var _rehydrationCache = null, _councilDisagreementWarned, STATE_ORDER, _toolAggregates, defaultRunContext, _runContexts, swarmState, STALE_SESSION_TTL_MS = 7200000, IDLE_SWEEP_COOLDOWN_MS = 60000, _lastIdleSweepAtMs = 0, MAX_TRACKED_CRITICAL_SHOWN = 500, MAX_TRACKED_KNOWLEDGE_ACKS = 5000, _internals25;
|
|
47934
47976
|
var init_state2 = __esm(() => {
|
|
47935
47977
|
init_constants();
|
|
47936
47978
|
init_plan_schema();
|
|
@@ -76579,6 +76621,9 @@ var init_gate_bridge = __esm(() => {
|
|
|
76579
76621
|
import { existsSync as existsSync35, mkdirSync as mkdirSync21, readFileSync as readFileSync19, writeFileSync as writeFileSync13 } from "node:fs";
|
|
76580
76622
|
import { homedir as homedir8 } from "node:os";
|
|
76581
76623
|
import { join as join52 } from "node:path";
|
|
76624
|
+
function isStrictSemver(value) {
|
|
76625
|
+
return typeof value === "string" && STRICT_SEMVER.test(value);
|
|
76626
|
+
}
|
|
76582
76627
|
function cacheDir() {
|
|
76583
76628
|
const xdg = process.env.XDG_CACHE_HOME;
|
|
76584
76629
|
const base = xdg && xdg.length > 0 ? xdg : join52(homedir8(), ".cache");
|
|
@@ -76633,14 +76678,32 @@ function compareVersions(a, b) {
|
|
|
76633
76678
|
}
|
|
76634
76679
|
async function fetchLatestVersion(signal) {
|
|
76635
76680
|
try {
|
|
76636
|
-
const res = await fetch(NPM_REGISTRY_URL, {
|
|
76681
|
+
const res = await _internals43.fetch(NPM_REGISTRY_URL, {
|
|
76637
76682
|
signal,
|
|
76638
76683
|
headers: { Accept: "application/json" }
|
|
76639
76684
|
});
|
|
76640
76685
|
if (!res.ok)
|
|
76641
76686
|
return null;
|
|
76642
|
-
const
|
|
76643
|
-
|
|
76687
|
+
const contentType = (res.headers.get("content-type") ?? "").toLowerCase();
|
|
76688
|
+
if (!contentType.includes("json"))
|
|
76689
|
+
return null;
|
|
76690
|
+
const lengthHeader = res.headers.get("content-length");
|
|
76691
|
+
if (lengthHeader) {
|
|
76692
|
+
const advertised = Number.parseInt(lengthHeader, 10);
|
|
76693
|
+
if (Number.isFinite(advertised) && advertised > MAX_RESPONSE_BYTES) {
|
|
76694
|
+
return null;
|
|
76695
|
+
}
|
|
76696
|
+
}
|
|
76697
|
+
const text = await res.text();
|
|
76698
|
+
if (text.length > MAX_RESPONSE_BYTES)
|
|
76699
|
+
return null;
|
|
76700
|
+
let body;
|
|
76701
|
+
try {
|
|
76702
|
+
body = JSON.parse(text);
|
|
76703
|
+
} catch {
|
|
76704
|
+
return null;
|
|
76705
|
+
}
|
|
76706
|
+
return isStrictSemver(body.version) ? body.version : null;
|
|
76644
76707
|
} catch {
|
|
76645
76708
|
return null;
|
|
76646
76709
|
}
|
|
@@ -76682,9 +76745,14 @@ function maybeWarn(runningVersion, npmLatest, emitWarning) {
|
|
|
76682
76745
|
emitWarning(`[opencode-swarm] Update available: ${runningVersion} → ${npmLatest}. ` + "OpenCode caches plugins indefinitely. Run `bunx opencode-swarm update` to refresh.");
|
|
76683
76746
|
}
|
|
76684
76747
|
}
|
|
76685
|
-
var NPM_REGISTRY_URL = "https://registry.npmjs.org/opencode-swarm/latest", CHECK_INTERVAL_MS, FETCH_TIMEOUT_MS = 5000, _checkLatched = false;
|
|
76748
|
+
var NPM_REGISTRY_URL = "https://registry.npmjs.org/opencode-swarm/latest", CHECK_INTERVAL_MS, FETCH_TIMEOUT_MS = 5000, MAX_RESPONSE_BYTES, STRICT_SEMVER, _checkLatched = false, _internals43;
|
|
76686
76749
|
var init_version_check = __esm(() => {
|
|
76687
76750
|
CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
76751
|
+
MAX_RESPONSE_BYTES = 256 * 1024;
|
|
76752
|
+
STRICT_SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
76753
|
+
_internals43 = {
|
|
76754
|
+
fetch: (input, init) => fetch(input, init)
|
|
76755
|
+
};
|
|
76688
76756
|
});
|
|
76689
76757
|
|
|
76690
76758
|
// src/services/knowledge-diagnostics.ts
|
|
@@ -77482,9 +77550,9 @@ async function checkCurator(directory) {
|
|
|
77482
77550
|
}
|
|
77483
77551
|
async function getSandboxStatus() {
|
|
77484
77552
|
try {
|
|
77485
|
-
const capability = await
|
|
77553
|
+
const capability = await _internals44.detectSandboxCapability();
|
|
77486
77554
|
const mechanism = capability.mechanism ?? "none";
|
|
77487
|
-
const executor = await
|
|
77555
|
+
const executor = await _internals44.getSandboxExecutor();
|
|
77488
77556
|
const hasExecutor = executor !== null;
|
|
77489
77557
|
if (hasExecutor) {
|
|
77490
77558
|
return {
|
|
@@ -77733,7 +77801,7 @@ async function handleDiagnoseCommand(directory, _args) {
|
|
|
77733
77801
|
const diagnoseData = await getDiagnoseData(directory);
|
|
77734
77802
|
return formatDiagnoseMarkdown(diagnoseData);
|
|
77735
77803
|
}
|
|
77736
|
-
var version4, sandboxCapabilityProbe,
|
|
77804
|
+
var version4, sandboxCapabilityProbe, _internals44;
|
|
77737
77805
|
var init_diagnose_service = __esm(() => {
|
|
77738
77806
|
init_package();
|
|
77739
77807
|
init_cache_paths();
|
|
@@ -77750,7 +77818,7 @@ var init_diagnose_service = __esm(() => {
|
|
|
77750
77818
|
init_warning_buffer();
|
|
77751
77819
|
({ version: version4 } = package_default);
|
|
77752
77820
|
sandboxCapabilityProbe = new SandboxCapabilityProbe;
|
|
77753
|
-
|
|
77821
|
+
_internals44 = {
|
|
77754
77822
|
detectSandboxCapability: () => sandboxCapabilityProbe.detect(),
|
|
77755
77823
|
getSandboxExecutor: getExecutor
|
|
77756
77824
|
};
|
|
@@ -80140,7 +80208,7 @@ function isCommandAvailable(command) {
|
|
|
80140
80208
|
const isWindows = process.platform === "win32";
|
|
80141
80209
|
const cmd = isWindows ? `${command}.exe` : command;
|
|
80142
80210
|
try {
|
|
80143
|
-
const result =
|
|
80211
|
+
const result = _internals45.spawnSyncImpl(isWindows ? ["where", cmd] : ["which", cmd], {
|
|
80144
80212
|
cwd: process.cwd(),
|
|
80145
80213
|
stdin: "ignore",
|
|
80146
80214
|
stdout: "ignore",
|
|
@@ -80290,7 +80358,7 @@ async function discoverBuildCommands(workingDir, options) {
|
|
|
80290
80358
|
const scope = options?.scope ?? "all";
|
|
80291
80359
|
const changedFiles = options?.changedFiles ?? [];
|
|
80292
80360
|
const _filesToCheck = filterByScope(workingDir, scope, changedFiles);
|
|
80293
|
-
const profileResult = await
|
|
80361
|
+
const profileResult = await _internals45.discoverBuildCommandsFromProfiles(workingDir);
|
|
80294
80362
|
const profileCommands = profileResult.commands;
|
|
80295
80363
|
const profileSkipped = profileResult.skipped;
|
|
80296
80364
|
const coveredEcosystems = new Set;
|
|
@@ -80353,7 +80421,7 @@ function clearToolchainCache() {
|
|
|
80353
80421
|
function getEcosystems() {
|
|
80354
80422
|
return ECOSYSTEMS.map((e) => e.ecosystem);
|
|
80355
80423
|
}
|
|
80356
|
-
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, IS_COMMAND_AVAILABLE_TIMEOUT_MS = 3000,
|
|
80424
|
+
var ECOSYSTEMS, PROFILE_TO_ECOSYSTEM_NAMES, toolchainCache, IS_COMMAND_AVAILABLE_TIMEOUT_MS = 3000, _internals45, build_discovery;
|
|
80357
80425
|
var init_discovery = __esm(() => {
|
|
80358
80426
|
init_dist();
|
|
80359
80427
|
init_detector();
|
|
@@ -80471,7 +80539,7 @@ var init_discovery = __esm(() => {
|
|
|
80471
80539
|
php: ["php-composer"]
|
|
80472
80540
|
};
|
|
80473
80541
|
toolchainCache = new Map;
|
|
80474
|
-
|
|
80542
|
+
_internals45 = {
|
|
80475
80543
|
isCommandAvailable,
|
|
80476
80544
|
discoverBuildCommandsFromProfiles,
|
|
80477
80545
|
discoverBuildCommands,
|
|
@@ -81128,7 +81196,7 @@ async function handleEpicCommand(directory, args2, sessionID) {
|
|
|
81128
81196
|
if (!sessionID || sessionID.trim() === "") {
|
|
81129
81197
|
return "Error: No active session context. Epic Mode requires an active session. Use /swarm epic from within an OpenCode session.";
|
|
81130
81198
|
}
|
|
81131
|
-
const session =
|
|
81199
|
+
const session = _internals46.ensureAgentSession(sessionID, undefined, directory);
|
|
81132
81200
|
const arg0 = args2[0]?.toLowerCase();
|
|
81133
81201
|
switch (arg0) {
|
|
81134
81202
|
case "status":
|
|
@@ -81155,7 +81223,7 @@ Usage:
|
|
|
81155
81223
|
}
|
|
81156
81224
|
function enableAndAck(directory, sessionID, session) {
|
|
81157
81225
|
try {
|
|
81158
|
-
|
|
81226
|
+
_internals46.enableEpicMode(directory, sessionID);
|
|
81159
81227
|
} catch (err) {
|
|
81160
81228
|
return `Error enabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
81161
81229
|
}
|
|
@@ -81171,7 +81239,7 @@ function enableAndAck(directory, sessionID, session) {
|
|
|
81171
81239
|
}
|
|
81172
81240
|
function disableAndAck(directory, sessionID, session) {
|
|
81173
81241
|
try {
|
|
81174
|
-
|
|
81242
|
+
_internals46.disableEpicMode(directory, sessionID);
|
|
81175
81243
|
} catch (err) {
|
|
81176
81244
|
return `Error disabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
81177
81245
|
}
|
|
@@ -81180,12 +81248,12 @@ function disableAndAck(directory, sessionID, session) {
|
|
|
81180
81248
|
}
|
|
81181
81249
|
function renderStatus(directory, sessionID) {
|
|
81182
81250
|
const lines = ["## Epic Mode — Status", ""];
|
|
81183
|
-
if (
|
|
81251
|
+
if (_internals46.isStateUnreadable(directory)) {
|
|
81184
81252
|
lines.push("**Epic Mode state is unreadable** (`.swarm/epic-state.json` is corrupt or has an unexpected shape). Status cannot be reported until the file is repaired or removed. The fail-closed marker means `epic_decide_phase` will refuse to compute a verdict in this state.");
|
|
81185
81253
|
return lines.join(`
|
|
81186
81254
|
`);
|
|
81187
81255
|
}
|
|
81188
|
-
const state =
|
|
81256
|
+
const state = _internals46.loadEpicSessionState(directory, sessionID);
|
|
81189
81257
|
if (!state) {
|
|
81190
81258
|
lines.push("Epic Mode has not been toggled for this session.");
|
|
81191
81259
|
return lines.join(`
|
|
@@ -81237,7 +81305,7 @@ function formatGreenfieldDetail(input) {
|
|
|
81237
81305
|
function renderLast(directory) {
|
|
81238
81306
|
let records;
|
|
81239
81307
|
try {
|
|
81240
|
-
records =
|
|
81308
|
+
records = _internals46.readPromotionEvidence(directory);
|
|
81241
81309
|
} catch (err) {
|
|
81242
81310
|
return `Error reading epic-promotions.jsonl: ${err instanceof Error ? err.message : String(err)}`;
|
|
81243
81311
|
}
|
|
@@ -81292,7 +81360,7 @@ function renderLast(directory) {
|
|
|
81292
81360
|
`);
|
|
81293
81361
|
}
|
|
81294
81362
|
function renderCalibration(directory) {
|
|
81295
|
-
if (
|
|
81363
|
+
if (_internals46.isCalibrationStateUnreadable(directory)) {
|
|
81296
81364
|
return [
|
|
81297
81365
|
"## Epic Mode — Calibration",
|
|
81298
81366
|
"",
|
|
@@ -81304,11 +81372,11 @@ function renderCalibration(directory) {
|
|
|
81304
81372
|
}
|
|
81305
81373
|
let state;
|
|
81306
81374
|
try {
|
|
81307
|
-
state =
|
|
81375
|
+
state = _internals46.loadCalibrationState(directory);
|
|
81308
81376
|
} catch (err) {
|
|
81309
81377
|
return `Error reading calibration state: ${err instanceof Error ? err.message : String(err)}`;
|
|
81310
81378
|
}
|
|
81311
|
-
const { config: config3 } =
|
|
81379
|
+
const { config: config3 } = _internals46.loadPluginConfigWithMeta(directory);
|
|
81312
81380
|
const staticThreshold = config3.turbo?.epic?.mode?.activation_threshold ?? 0.3;
|
|
81313
81381
|
const calibrationCfg = config3.turbo?.epic?.calibration;
|
|
81314
81382
|
const loosenWindow = calibrationCfg?.loosen_window ?? 10;
|
|
@@ -81356,7 +81424,7 @@ function renderCalibration(directory) {
|
|
|
81356
81424
|
lines.push("");
|
|
81357
81425
|
let recentDivergent = [];
|
|
81358
81426
|
try {
|
|
81359
|
-
const all =
|
|
81427
|
+
const all = _internals46.readDivergenceHistory(directory, { limit: 50 });
|
|
81360
81428
|
recentDivergent = all.filter((r) => !r.isClean).slice(-5);
|
|
81361
81429
|
} catch {}
|
|
81362
81430
|
lines.push("### Recent divergent tasks (tightened the threshold)");
|
|
@@ -81373,11 +81441,11 @@ function renderCalibration(directory) {
|
|
|
81373
81441
|
`);
|
|
81374
81442
|
}
|
|
81375
81443
|
async function renderDecide(directory) {
|
|
81376
|
-
const plan = await
|
|
81444
|
+
const plan = await _internals46.loadPlanJsonOnly(directory);
|
|
81377
81445
|
if (!plan) {
|
|
81378
81446
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` first.";
|
|
81379
81447
|
}
|
|
81380
|
-
const { config: config3 } =
|
|
81448
|
+
const { config: config3 } = _internals46.loadPluginConfigWithMeta(directory);
|
|
81381
81449
|
const modeCfg = config3.turbo?.epic?.mode;
|
|
81382
81450
|
const cochangeCfg = config3.turbo?.epic?.cochange;
|
|
81383
81451
|
const activationThreshold = modeCfg?.activation_threshold ?? 0.3;
|
|
@@ -81387,20 +81455,20 @@ async function renderDecide(directory) {
|
|
|
81387
81455
|
const tasks = [];
|
|
81388
81456
|
for (const phase of plan.phases) {
|
|
81389
81457
|
for (const task of phase.tasks) {
|
|
81390
|
-
const scopeFiles =
|
|
81458
|
+
const scopeFiles = _internals46.readTaskScopes(directory, task.id);
|
|
81391
81459
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
81392
81460
|
tasks.push({ id: task.id, scope });
|
|
81393
81461
|
}
|
|
81394
81462
|
}
|
|
81395
|
-
const { pairs, commitsObserved } = await
|
|
81463
|
+
const { pairs, commitsObserved } = await _internals46.getCoChangeData(directory);
|
|
81396
81464
|
const isGitProject = (() => {
|
|
81397
81465
|
try {
|
|
81398
|
-
return
|
|
81466
|
+
return _internals46.isGitRepo(directory);
|
|
81399
81467
|
} catch {
|
|
81400
81468
|
return false;
|
|
81401
81469
|
}
|
|
81402
81470
|
})();
|
|
81403
|
-
const verdict =
|
|
81471
|
+
const verdict = _internals46.decideEpicActivation(tasks, pairs, commitsObserved, {
|
|
81404
81472
|
activationThreshold,
|
|
81405
81473
|
minCommitsForSignal,
|
|
81406
81474
|
cochangeNpmiThreshold,
|
|
@@ -81442,7 +81510,7 @@ function formatVerdict(verdict) {
|
|
|
81442
81510
|
return lines.join(`
|
|
81443
81511
|
`);
|
|
81444
81512
|
}
|
|
81445
|
-
var
|
|
81513
|
+
var _internals46;
|
|
81446
81514
|
var init_epic = __esm(() => {
|
|
81447
81515
|
init_config();
|
|
81448
81516
|
init_branch();
|
|
@@ -81455,7 +81523,7 @@ var init_epic = __esm(() => {
|
|
|
81455
81523
|
init_promotion_evidence();
|
|
81456
81524
|
init_state();
|
|
81457
81525
|
init_conflicts();
|
|
81458
|
-
|
|
81526
|
+
_internals46 = {
|
|
81459
81527
|
loadPluginConfigWithMeta,
|
|
81460
81528
|
loadPlanJsonOnly,
|
|
81461
81529
|
getCoChangeData,
|
|
@@ -81480,7 +81548,7 @@ var exports_evidence_summary_service = {};
|
|
|
81480
81548
|
__export(exports_evidence_summary_service, {
|
|
81481
81549
|
isAutoSummaryEnabled: () => isAutoSummaryEnabled,
|
|
81482
81550
|
buildEvidenceSummary: () => buildEvidenceSummary,
|
|
81483
|
-
_internals: () =>
|
|
81551
|
+
_internals: () => _internals47,
|
|
81484
81552
|
REQUIRED_EVIDENCE_TYPES: () => REQUIRED_EVIDENCE_TYPES,
|
|
81485
81553
|
EVIDENCE_SUMMARY_VERSION: () => EVIDENCE_SUMMARY_VERSION
|
|
81486
81554
|
});
|
|
@@ -81518,7 +81586,7 @@ function getTaskStatus(task, bundle) {
|
|
|
81518
81586
|
if (task?.status) {
|
|
81519
81587
|
return task.status;
|
|
81520
81588
|
}
|
|
81521
|
-
const entries =
|
|
81589
|
+
const entries = _internals47.normalizeBundleEntries(bundle);
|
|
81522
81590
|
if (entries.length > 0) {
|
|
81523
81591
|
return "completed";
|
|
81524
81592
|
}
|
|
@@ -81544,7 +81612,7 @@ function evidenceCompleteFromEntries(entries) {
|
|
|
81544
81612
|
};
|
|
81545
81613
|
}
|
|
81546
81614
|
function isEvidenceComplete(bundle) {
|
|
81547
|
-
return evidenceCompleteFromEntries(
|
|
81615
|
+
return evidenceCompleteFromEntries(_internals47.normalizeBundleEntries(bundle));
|
|
81548
81616
|
}
|
|
81549
81617
|
function getTaskBlockers(task, summary, status) {
|
|
81550
81618
|
const blockers = [];
|
|
@@ -81564,9 +81632,9 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
81564
81632
|
const bundle = result.status === "found" ? result.bundle : null;
|
|
81565
81633
|
const gateEvidence = await readDurableGateEvidence(directory, taskId);
|
|
81566
81634
|
const phase = task?.phase ?? 0;
|
|
81567
|
-
const status =
|
|
81568
|
-
const entries = mergeDurableGateEntriesFromEvidence(taskId,
|
|
81569
|
-
let evidenceCheck =
|
|
81635
|
+
const status = _internals47.getTaskStatus(task, bundle);
|
|
81636
|
+
const entries = mergeDurableGateEntriesFromEvidence(taskId, _internals47.normalizeBundleEntries(bundle), gateEvidence);
|
|
81637
|
+
let evidenceCheck = _internals47.evidenceCompleteFromEntries(entries);
|
|
81570
81638
|
if (gateEvidence) {
|
|
81571
81639
|
const gateStatus = getDurableGateEvidenceStatus(gateEvidence);
|
|
81572
81640
|
evidenceCheck = gateStatus.isComplete ? { isComplete: true, missingEvidence: [] } : {
|
|
@@ -81574,7 +81642,7 @@ async function buildTaskSummary(directory, task, taskId) {
|
|
|
81574
81642
|
missingEvidence: gateStatus.missingGates.map((gate) => `gate:${gate}`)
|
|
81575
81643
|
};
|
|
81576
81644
|
}
|
|
81577
|
-
const blockers =
|
|
81645
|
+
const blockers = _internals47.getTaskBlockers(task, evidenceCheck, status);
|
|
81578
81646
|
const hasReview = entries.some((e) => e.type === "review");
|
|
81579
81647
|
const hasTest = entries.some((e) => e.type === "test");
|
|
81580
81648
|
const hasApproval = entries.some((e) => e.type === "approval");
|
|
@@ -81603,12 +81671,12 @@ async function buildPhaseSummary(directory, phase) {
|
|
|
81603
81671
|
const taskSummaries = [];
|
|
81604
81672
|
const _taskMap = new Map(phase.tasks.map((t) => [t.id, t]));
|
|
81605
81673
|
for (const task of phase.tasks) {
|
|
81606
|
-
const summary = await
|
|
81674
|
+
const summary = await _internals47.buildTaskSummary(directory, task, task.id);
|
|
81607
81675
|
taskSummaries.push(summary);
|
|
81608
81676
|
}
|
|
81609
81677
|
const extraTaskIds = taskIds.filter((id) => !phaseTaskIds.has(id));
|
|
81610
81678
|
for (const taskId of extraTaskIds) {
|
|
81611
|
-
const summary = await
|
|
81679
|
+
const summary = await _internals47.buildTaskSummary(directory, undefined, taskId);
|
|
81612
81680
|
if (summary.phase === phase.id) {
|
|
81613
81681
|
taskSummaries.push(summary);
|
|
81614
81682
|
}
|
|
@@ -81709,7 +81777,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
81709
81777
|
let totalTasks = 0;
|
|
81710
81778
|
let completedTasks = 0;
|
|
81711
81779
|
for (const phase of phasesToProcess) {
|
|
81712
|
-
const summary = await
|
|
81780
|
+
const summary = await _internals47.buildPhaseSummary(directory, phase);
|
|
81713
81781
|
phaseSummaries.push(summary);
|
|
81714
81782
|
totalTasks += summary.totalTasks;
|
|
81715
81783
|
completedTasks += summary.completedTasks;
|
|
@@ -81731,7 +81799,7 @@ async function buildEvidenceSummary(directory, currentPhase) {
|
|
|
81731
81799
|
overallBlockers,
|
|
81732
81800
|
summaryText: ""
|
|
81733
81801
|
};
|
|
81734
|
-
artifact.summaryText =
|
|
81802
|
+
artifact.summaryText = _internals47.generateSummaryText(artifact);
|
|
81735
81803
|
log("[EvidenceSummary] Summary built", {
|
|
81736
81804
|
phases: phaseSummaries.length,
|
|
81737
81805
|
totalTasks,
|
|
@@ -81750,7 +81818,7 @@ function isAutoSummaryEnabled(automationConfig) {
|
|
|
81750
81818
|
}
|
|
81751
81819
|
return automationConfig.capabilities?.evidence_auto_summaries === true;
|
|
81752
81820
|
}
|
|
81753
|
-
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0",
|
|
81821
|
+
var VALID_EVIDENCE_TYPES2, REQUIRED_EVIDENCE_TYPES, EVIDENCE_SUMMARY_VERSION = "1.0.0", _internals47;
|
|
81754
81822
|
var init_evidence_summary_service = __esm(() => {
|
|
81755
81823
|
init_gate_bridge();
|
|
81756
81824
|
init_manager2();
|
|
@@ -81765,7 +81833,7 @@ var init_evidence_summary_service = __esm(() => {
|
|
|
81765
81833
|
"retrospective"
|
|
81766
81834
|
]);
|
|
81767
81835
|
REQUIRED_EVIDENCE_TYPES = ["review", "test"];
|
|
81768
|
-
|
|
81836
|
+
_internals47 = {
|
|
81769
81837
|
buildEvidenceSummary,
|
|
81770
81838
|
isAutoSummaryEnabled,
|
|
81771
81839
|
normalizeBundleEntries,
|
|
@@ -81821,7 +81889,7 @@ function getVerdictEmoji(verdict) {
|
|
|
81821
81889
|
return getVerdictIcon(verdict);
|
|
81822
81890
|
}
|
|
81823
81891
|
async function getTaskEvidenceData(directory, taskId) {
|
|
81824
|
-
const result = await
|
|
81892
|
+
const result = await _internals48.loadEvidence(directory, taskId);
|
|
81825
81893
|
if (result.status !== "found") {
|
|
81826
81894
|
return {
|
|
81827
81895
|
hasEvidence: false,
|
|
@@ -81844,13 +81912,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
81844
81912
|
};
|
|
81845
81913
|
}
|
|
81846
81914
|
async function getEvidenceListData(directory) {
|
|
81847
|
-
const taskIds = await
|
|
81915
|
+
const taskIds = await _internals48.listEvidenceTaskIds(directory);
|
|
81848
81916
|
if (taskIds.length === 0) {
|
|
81849
81917
|
return { hasEvidence: false, tasks: [] };
|
|
81850
81918
|
}
|
|
81851
81919
|
const tasks = [];
|
|
81852
81920
|
for (const taskId of taskIds) {
|
|
81853
|
-
const result = await
|
|
81921
|
+
const result = await _internals48.loadEvidence(directory, taskId);
|
|
81854
81922
|
if (result.status === "found") {
|
|
81855
81923
|
tasks.push({
|
|
81856
81924
|
taskId,
|
|
@@ -81964,10 +82032,10 @@ async function handleEvidenceSummaryCommand(directory) {
|
|
|
81964
82032
|
return lines.join(`
|
|
81965
82033
|
`);
|
|
81966
82034
|
}
|
|
81967
|
-
var
|
|
82035
|
+
var _internals48;
|
|
81968
82036
|
var init_evidence_service = __esm(() => {
|
|
81969
82037
|
init_manager2();
|
|
81970
|
-
|
|
82038
|
+
_internals48 = {
|
|
81971
82039
|
loadEvidence,
|
|
81972
82040
|
listEvidenceTaskIds
|
|
81973
82041
|
};
|
|
@@ -82616,7 +82684,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
82616
82684
|
if (!plan) {
|
|
82617
82685
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
82618
82686
|
}
|
|
82619
|
-
if (!
|
|
82687
|
+
if (!_internals49.validatePlanPhases(plan)) {
|
|
82620
82688
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
82621
82689
|
}
|
|
82622
82690
|
let currentPhase = null;
|
|
@@ -82758,9 +82826,9 @@ function extractPhaseMetrics(content) {
|
|
|
82758
82826
|
async function getHandoffData(directory) {
|
|
82759
82827
|
const now = new Date().toISOString();
|
|
82760
82828
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
82761
|
-
const sessionState =
|
|
82829
|
+
const sessionState = _internals49.parseSessionState(sessionContent);
|
|
82762
82830
|
const plan = await loadPlanJsonOnly(directory);
|
|
82763
|
-
const planInfo =
|
|
82831
|
+
const planInfo = _internals49.extractCurrentPhaseFromPlan(plan);
|
|
82764
82832
|
if (!plan) {
|
|
82765
82833
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
82766
82834
|
if (planMdContent) {
|
|
@@ -82779,8 +82847,8 @@ async function getHandoffData(directory) {
|
|
|
82779
82847
|
}
|
|
82780
82848
|
}
|
|
82781
82849
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
82782
|
-
const recentDecisions =
|
|
82783
|
-
const rawPhaseMetrics =
|
|
82850
|
+
const recentDecisions = _internals49.extractDecisions(contextContent);
|
|
82851
|
+
const rawPhaseMetrics = _internals49.extractPhaseMetrics(contextContent);
|
|
82784
82852
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
82785
82853
|
let delegationState = null;
|
|
82786
82854
|
if (sessionState?.delegationState) {
|
|
@@ -82944,13 +83012,13 @@ ${lines.join(`
|
|
|
82944
83012
|
`)}
|
|
82945
83013
|
\`\`\``;
|
|
82946
83014
|
}
|
|
82947
|
-
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20,
|
|
83015
|
+
var RTL_OVERRIDE_PATTERN, MAX_TASK_ID_LENGTH = 100, MAX_DECISION_LENGTH = 500, MAX_INCOMPLETE_TASKS = 20, _internals49;
|
|
82948
83016
|
var init_handoff_service = __esm(() => {
|
|
82949
83017
|
init_utils2();
|
|
82950
83018
|
init_manager();
|
|
82951
83019
|
init_utils();
|
|
82952
83020
|
RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
|
|
82953
|
-
|
|
83021
|
+
_internals49 = {
|
|
82954
83022
|
getHandoffData,
|
|
82955
83023
|
formatHandoffMarkdown,
|
|
82956
83024
|
formatContinuationPrompt,
|
|
@@ -83093,22 +83161,22 @@ async function writeSnapshot(directory, state) {
|
|
|
83093
83161
|
}
|
|
83094
83162
|
function createSnapshotWriterHook(directory) {
|
|
83095
83163
|
return (_input, _output) => {
|
|
83096
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
83164
|
+
_writeInFlight = _writeInFlight.then(() => _internals50.writeSnapshot(directory, swarmState), () => _internals50.writeSnapshot(directory, swarmState));
|
|
83097
83165
|
return _writeInFlight;
|
|
83098
83166
|
};
|
|
83099
83167
|
}
|
|
83100
83168
|
async function flushPendingSnapshot(directory) {
|
|
83101
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
83169
|
+
_writeInFlight = _writeInFlight.then(() => _internals50.writeSnapshot(directory, swarmState), () => _internals50.writeSnapshot(directory, swarmState));
|
|
83102
83170
|
await _writeInFlight;
|
|
83103
83171
|
}
|
|
83104
|
-
var _writeInFlight,
|
|
83172
|
+
var _writeInFlight, _internals50;
|
|
83105
83173
|
var init_snapshot_writer = __esm(() => {
|
|
83106
83174
|
init_utils2();
|
|
83107
83175
|
init_state2();
|
|
83108
83176
|
init_utils();
|
|
83109
83177
|
init_bun_compat();
|
|
83110
83178
|
_writeInFlight = Promise.resolve();
|
|
83111
|
-
|
|
83179
|
+
_internals50 = {
|
|
83112
83180
|
writeSnapshot,
|
|
83113
83181
|
createSnapshotWriterHook,
|
|
83114
83182
|
flushPendingSnapshot
|
|
@@ -83428,7 +83496,7 @@ function validateAndSanitizeGithubUrl(rawUrl, resource) {
|
|
|
83428
83496
|
}
|
|
83429
83497
|
function detectGitRemote(cwd) {
|
|
83430
83498
|
try {
|
|
83431
|
-
const result =
|
|
83499
|
+
const result = _internals51.spawnSync("git", ["remote", "get-url", "origin"], {
|
|
83432
83500
|
encoding: "utf-8",
|
|
83433
83501
|
stdio: ["ignore", "pipe", "pipe"],
|
|
83434
83502
|
timeout: 5000,
|
|
@@ -83473,7 +83541,7 @@ function parseGitRemoteUrl(remoteUrl) {
|
|
|
83473
83541
|
}
|
|
83474
83542
|
return null;
|
|
83475
83543
|
}
|
|
83476
|
-
var MAX_URL_LEN = 2048, IPV4_PRIVATE, IPV4_LOOPBACK, IPV4_LINK_LOCAL, IPV4_PRIVATE_172, IPV4_PRIVATE_192, IPV4_ZERO_NETWORK, IPV6_LINK_LOCAL, IPV6_UNIQUE_LOCAL,
|
|
83544
|
+
var MAX_URL_LEN = 2048, IPV4_PRIVATE, IPV4_LOOPBACK, IPV4_LINK_LOCAL, IPV4_PRIVATE_172, IPV4_PRIVATE_192, IPV4_ZERO_NETWORK, IPV6_LINK_LOCAL, IPV6_UNIQUE_LOCAL, _internals51;
|
|
83477
83545
|
var init_url_security = __esm(() => {
|
|
83478
83546
|
IPV4_PRIVATE = /^10\./;
|
|
83479
83547
|
IPV4_LOOPBACK = /^127\./;
|
|
@@ -83483,7 +83551,7 @@ var init_url_security = __esm(() => {
|
|
|
83483
83551
|
IPV4_ZERO_NETWORK = /^0\./;
|
|
83484
83552
|
IPV6_LINK_LOCAL = /^fe80:/i;
|
|
83485
83553
|
IPV6_UNIQUE_LOCAL = /^f[cd][0-9a-f]{2}:/i;
|
|
83486
|
-
|
|
83554
|
+
_internals51 = { spawnSync: spawnSync10 };
|
|
83487
83555
|
});
|
|
83488
83556
|
|
|
83489
83557
|
// src/commands/issue.ts
|
|
@@ -83619,7 +83687,7 @@ import * as path76 from "node:path";
|
|
|
83619
83687
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
83620
83688
|
const externalSentinelPath = path76.join(_directory, ".swarm", ".knowledge-external-migrated");
|
|
83621
83689
|
const contextPath = path76.join(_directory, ".swarm", "context.md");
|
|
83622
|
-
if (
|
|
83690
|
+
if (_internals52.existsSync(externalSentinelPath)) {
|
|
83623
83691
|
return {
|
|
83624
83692
|
migrated: false,
|
|
83625
83693
|
entriesMigrated: 0,
|
|
@@ -83628,7 +83696,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
83628
83696
|
skippedReason: "external-sentinel-exists"
|
|
83629
83697
|
};
|
|
83630
83698
|
}
|
|
83631
|
-
if (!
|
|
83699
|
+
if (!_internals52.existsSync(contextPath)) {
|
|
83632
83700
|
return {
|
|
83633
83701
|
migrated: false,
|
|
83634
83702
|
entriesMigrated: 0,
|
|
@@ -83637,7 +83705,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
83637
83705
|
skippedReason: "no-context-file"
|
|
83638
83706
|
};
|
|
83639
83707
|
}
|
|
83640
|
-
const contextContent = await
|
|
83708
|
+
const contextContent = await _internals52.readFile(contextPath, "utf-8");
|
|
83641
83709
|
if (contextContent.trim().length === 0) {
|
|
83642
83710
|
return {
|
|
83643
83711
|
migrated: false,
|
|
@@ -83655,7 +83723,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
83655
83723
|
entriesCount++;
|
|
83656
83724
|
}
|
|
83657
83725
|
}
|
|
83658
|
-
await
|
|
83726
|
+
await _internals52.writeSentinel(externalSentinelPath, entriesCount, entriesCount);
|
|
83659
83727
|
return {
|
|
83660
83728
|
migrated: true,
|
|
83661
83729
|
entriesMigrated: entriesCount,
|
|
@@ -83695,9 +83763,9 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
83695
83763
|
skippedReason: "empty-context"
|
|
83696
83764
|
};
|
|
83697
83765
|
}
|
|
83698
|
-
const rawEntries =
|
|
83766
|
+
const rawEntries = _internals52.parseContextMd(contextContent);
|
|
83699
83767
|
if (rawEntries.length === 0) {
|
|
83700
|
-
await
|
|
83768
|
+
await _internals52.writeSentinel(sentinelPath, 0, 0);
|
|
83701
83769
|
return {
|
|
83702
83770
|
migrated: true,
|
|
83703
83771
|
entriesMigrated: 0,
|
|
@@ -83708,10 +83776,10 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
83708
83776
|
const existing = await readKnowledge(knowledgePath);
|
|
83709
83777
|
let migrated = 0;
|
|
83710
83778
|
let dropped = 0;
|
|
83711
|
-
const projectName =
|
|
83779
|
+
const projectName = _internals52.inferProjectName(directory);
|
|
83712
83780
|
for (const raw of rawEntries) {
|
|
83713
83781
|
if (config3.validation_enabled !== false) {
|
|
83714
|
-
const category = raw.categoryHint ??
|
|
83782
|
+
const category = raw.categoryHint ?? _internals52.inferCategoryFromText(raw.text);
|
|
83715
83783
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
83716
83784
|
category,
|
|
83717
83785
|
scope: "global",
|
|
@@ -83731,8 +83799,8 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
83731
83799
|
const entry = {
|
|
83732
83800
|
id: randomUUID6(),
|
|
83733
83801
|
tier: "swarm",
|
|
83734
|
-
lesson:
|
|
83735
|
-
category: raw.categoryHint ??
|
|
83802
|
+
lesson: _internals52.truncateLesson(raw.text),
|
|
83803
|
+
category: raw.categoryHint ?? _internals52.inferCategoryFromText(raw.text),
|
|
83736
83804
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
83737
83805
|
scope: "global",
|
|
83738
83806
|
confidence: 0.3,
|
|
@@ -83755,7 +83823,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
83755
83823
|
if (migrated > 0) {
|
|
83756
83824
|
await rewriteKnowledge(knowledgePath, existing);
|
|
83757
83825
|
}
|
|
83758
|
-
await
|
|
83826
|
+
await _internals52.writeSentinel(sentinelPath, migrated, dropped);
|
|
83759
83827
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
83760
83828
|
return {
|
|
83761
83829
|
migrated: true,
|
|
@@ -83765,7 +83833,7 @@ async function migrateContextToKnowledge(directory, config3) {
|
|
|
83765
83833
|
};
|
|
83766
83834
|
}
|
|
83767
83835
|
async function migrateHiveKnowledgeLegacy(config3) {
|
|
83768
|
-
const legacyHivePath =
|
|
83836
|
+
const legacyHivePath = _internals52.resolveLegacyHiveKnowledgePath();
|
|
83769
83837
|
const canonicalHivePath = resolveHiveKnowledgePath();
|
|
83770
83838
|
const sentinelPath = path76.join(path76.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
83771
83839
|
if (existsSync44(sentinelPath)) {
|
|
@@ -83788,7 +83856,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
83788
83856
|
}
|
|
83789
83857
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
83790
83858
|
if (legacyEntries.length === 0) {
|
|
83791
|
-
await
|
|
83859
|
+
await _internals52.writeSentinel(sentinelPath, 0, 0);
|
|
83792
83860
|
return {
|
|
83793
83861
|
migrated: true,
|
|
83794
83862
|
entriesMigrated: 0,
|
|
@@ -83836,7 +83904,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
83836
83904
|
const newHiveEntry = {
|
|
83837
83905
|
id: resolvedId,
|
|
83838
83906
|
tier: "hive",
|
|
83839
|
-
lesson:
|
|
83907
|
+
lesson: _internals52.truncateLesson(lesson),
|
|
83840
83908
|
category,
|
|
83841
83909
|
tags: ["migration:legacy-hive"],
|
|
83842
83910
|
scope: scopeTag,
|
|
@@ -83855,7 +83923,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
83855
83923
|
encounter_score: 1
|
|
83856
83924
|
};
|
|
83857
83925
|
try {
|
|
83858
|
-
await
|
|
83926
|
+
await _internals52.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
83859
83927
|
existingHiveEntries.push(newHiveEntry);
|
|
83860
83928
|
migrated++;
|
|
83861
83929
|
} catch (appendError) {
|
|
@@ -83871,7 +83939,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
83871
83939
|
dropped++;
|
|
83872
83940
|
}
|
|
83873
83941
|
}
|
|
83874
|
-
await
|
|
83942
|
+
await _internals52.writeSentinel(sentinelPath, migrated, dropped);
|
|
83875
83943
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
83876
83944
|
return {
|
|
83877
83945
|
migrated: true,
|
|
@@ -83882,7 +83950,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
|
|
|
83882
83950
|
};
|
|
83883
83951
|
}
|
|
83884
83952
|
function parseContextMd(content) {
|
|
83885
|
-
const sections =
|
|
83953
|
+
const sections = _internals52.splitIntoSections(content);
|
|
83886
83954
|
const entries = [];
|
|
83887
83955
|
const seen = new Set;
|
|
83888
83956
|
const sectionPatterns = [
|
|
@@ -83898,7 +83966,7 @@ function parseContextMd(content) {
|
|
|
83898
83966
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
83899
83967
|
if (!match)
|
|
83900
83968
|
continue;
|
|
83901
|
-
const bullets =
|
|
83969
|
+
const bullets = _internals52.extractBullets(section.body);
|
|
83902
83970
|
for (const bullet of bullets) {
|
|
83903
83971
|
if (bullet.length < 15)
|
|
83904
83972
|
continue;
|
|
@@ -83907,9 +83975,9 @@ function parseContextMd(content) {
|
|
|
83907
83975
|
continue;
|
|
83908
83976
|
seen.add(normalized);
|
|
83909
83977
|
entries.push({
|
|
83910
|
-
text:
|
|
83978
|
+
text: _internals52.truncateLesson(bullet),
|
|
83911
83979
|
sourceSection: match.sourceSection,
|
|
83912
|
-
categoryHint:
|
|
83980
|
+
categoryHint: _internals52.inferCategoryFromText(bullet)
|
|
83913
83981
|
});
|
|
83914
83982
|
}
|
|
83915
83983
|
}
|
|
@@ -83999,8 +84067,8 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
83999
84067
|
schema_version: 1,
|
|
84000
84068
|
migration_tool: "knowledge-migrator.ts"
|
|
84001
84069
|
};
|
|
84002
|
-
await
|
|
84003
|
-
await
|
|
84070
|
+
await _internals52.mkdir(path76.dirname(sentinelPath), { recursive: true });
|
|
84071
|
+
await _internals52.writeFile(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
84004
84072
|
}
|
|
84005
84073
|
function resolveLegacyHiveKnowledgePath() {
|
|
84006
84074
|
const platform = process.platform;
|
|
@@ -84015,12 +84083,12 @@ function resolveLegacyHiveKnowledgePath() {
|
|
|
84015
84083
|
}
|
|
84016
84084
|
return path76.join(dataDir, "hive-knowledge.jsonl");
|
|
84017
84085
|
}
|
|
84018
|
-
var
|
|
84086
|
+
var _internals52;
|
|
84019
84087
|
var init_knowledge_migrator = __esm(() => {
|
|
84020
84088
|
init_logger();
|
|
84021
84089
|
init_knowledge_store();
|
|
84022
84090
|
init_knowledge_validator();
|
|
84023
|
-
|
|
84091
|
+
_internals52 = {
|
|
84024
84092
|
appendKnowledge,
|
|
84025
84093
|
migrateContextToKnowledge,
|
|
84026
84094
|
migrateKnowledgeToExternal,
|
|
@@ -84278,7 +84346,7 @@ function timeoutMessage(timeoutMs) {
|
|
|
84278
84346
|
async function computeWithTimeout(directory, currentPhase, timeoutMs) {
|
|
84279
84347
|
const controller = new AbortController;
|
|
84280
84348
|
let timeout;
|
|
84281
|
-
const metricsPromise =
|
|
84349
|
+
const metricsPromise = _internals53.computeLearningMetrics(directory, {
|
|
84282
84350
|
currentPhase,
|
|
84283
84351
|
signal: controller.signal
|
|
84284
84352
|
});
|
|
@@ -84335,7 +84403,7 @@ ${JSON.stringify({
|
|
|
84335
84403
|
return `Error computing learning metrics: ${message}. Run /swarm diagnose to check .swarm/ health.`;
|
|
84336
84404
|
}
|
|
84337
84405
|
}
|
|
84338
|
-
var DEFAULT_LEARNING_TIMEOUT_MS = 30000, MAX_LEARNING_TIMEOUT_MS = 300000, LearningMetricsTimeoutError,
|
|
84406
|
+
var DEFAULT_LEARNING_TIMEOUT_MS = 30000, MAX_LEARNING_TIMEOUT_MS = 300000, LearningMetricsTimeoutError, _internals53;
|
|
84339
84407
|
var init_learning = __esm(() => {
|
|
84340
84408
|
init_learning_metrics();
|
|
84341
84409
|
LearningMetricsTimeoutError = class LearningMetricsTimeoutError extends Error {
|
|
@@ -84346,7 +84414,7 @@ var init_learning = __esm(() => {
|
|
|
84346
84414
|
this.name = "LearningMetricsTimeoutError";
|
|
84347
84415
|
}
|
|
84348
84416
|
};
|
|
84349
|
-
|
|
84417
|
+
_internals53 = {
|
|
84350
84418
|
computeLearningMetrics
|
|
84351
84419
|
};
|
|
84352
84420
|
});
|
|
@@ -84639,7 +84707,7 @@ ${USAGE7}`;
|
|
|
84639
84707
|
}
|
|
84640
84708
|
let autonomy = parsed.autonomy;
|
|
84641
84709
|
if (parsed.resume && !parsed.autonomyExplicit) {
|
|
84642
|
-
const state = await
|
|
84710
|
+
const state = await _internals54.readLatestLoopState(_directory);
|
|
84643
84711
|
if (state?.autonomy && AUTONOMY_LEVELS.has(state.autonomy)) {
|
|
84644
84712
|
autonomy = state.autonomy;
|
|
84645
84713
|
}
|
|
@@ -84650,7 +84718,7 @@ ${USAGE7}`;
|
|
|
84650
84718
|
}
|
|
84651
84719
|
return `${header} ${objective}`;
|
|
84652
84720
|
}
|
|
84653
|
-
var MAX_OBJECTIVE_LEN = 2000, DEPTHS2, AUTONOMY_LEVELS, DEFAULT_DEPTH2 = "standard", DEFAULT_AUTONOMY = "auto", DEFAULT_MAX_CYCLES = 3, MIN_MAX_CYCLES = 1, MAX_MAX_CYCLES = 5,
|
|
84721
|
+
var MAX_OBJECTIVE_LEN = 2000, DEPTHS2, AUTONOMY_LEVELS, DEFAULT_DEPTH2 = "standard", DEFAULT_AUTONOMY = "auto", DEFAULT_MAX_CYCLES = 3, MIN_MAX_CYCLES = 1, MAX_MAX_CYCLES = 5, _internals54, USAGE7 = `Usage: /swarm loop <objective> [--max-cycles 1..5] [--autonomy checkpoint|auto] [--depth standard|exhaustive] [--resume]
|
|
84654
84722
|
|
|
84655
84723
|
Run a compound-engineering loop: brainstorm → plan → build → review → improve,
|
|
84656
84724
|
iterating until the objective is met or a budget stop condition fires.
|
|
@@ -84671,7 +84739,7 @@ Flags:
|
|
|
84671
84739
|
var init_loop = __esm(() => {
|
|
84672
84740
|
DEPTHS2 = new Set(["standard", "exhaustive"]);
|
|
84673
84741
|
AUTONOMY_LEVELS = new Set(["checkpoint", "auto"]);
|
|
84674
|
-
|
|
84742
|
+
_internals54 = {
|
|
84675
84743
|
readLatestLoopState
|
|
84676
84744
|
};
|
|
84677
84745
|
});
|
|
@@ -89679,9 +89747,9 @@ var init_memory2 = __esm(() => {
|
|
|
89679
89747
|
|
|
89680
89748
|
// src/services/plan-service.ts
|
|
89681
89749
|
async function getPlanData(directory, phaseArg) {
|
|
89682
|
-
const plan = await
|
|
89750
|
+
const plan = await _internals55.loadPlanJsonOnly(directory);
|
|
89683
89751
|
if (plan) {
|
|
89684
|
-
const fullMarkdown =
|
|
89752
|
+
const fullMarkdown = _internals55.derivePlanMarkdown(plan);
|
|
89685
89753
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
89686
89754
|
return {
|
|
89687
89755
|
hasPlan: true,
|
|
@@ -89724,7 +89792,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
89724
89792
|
isLegacy: false
|
|
89725
89793
|
};
|
|
89726
89794
|
}
|
|
89727
|
-
const planContent = await
|
|
89795
|
+
const planContent = await _internals55.readSwarmFileAsync(directory, "plan.md");
|
|
89728
89796
|
if (!planContent) {
|
|
89729
89797
|
return {
|
|
89730
89798
|
hasPlan: false,
|
|
@@ -89820,11 +89888,11 @@ async function handlePlanCommand(directory, args2) {
|
|
|
89820
89888
|
const planData = await getPlanData(directory, phaseArg);
|
|
89821
89889
|
return formatPlanMarkdown(planData);
|
|
89822
89890
|
}
|
|
89823
|
-
var
|
|
89891
|
+
var _internals55;
|
|
89824
89892
|
var init_plan_service = __esm(() => {
|
|
89825
89893
|
init_utils2();
|
|
89826
89894
|
init_manager();
|
|
89827
|
-
|
|
89895
|
+
_internals55 = {
|
|
89828
89896
|
loadPlanJsonOnly,
|
|
89829
89897
|
derivePlanMarkdown,
|
|
89830
89898
|
readSwarmFileAsync
|
|
@@ -89845,10 +89913,10 @@ async function handlePostMortemCommand(directory, args2, options) {
|
|
|
89845
89913
|
};
|
|
89846
89914
|
if (options?.sessionID) {
|
|
89847
89915
|
try {
|
|
89848
|
-
pmOptions.llmDelegate =
|
|
89916
|
+
pmOptions.llmDelegate = _internals56.createCuratorLLMDelegate(directory, "postmortem", options.sessionID);
|
|
89849
89917
|
} catch {}
|
|
89850
89918
|
}
|
|
89851
|
-
const result = await
|
|
89919
|
+
const result = await _internals56.runCuratorPostMortem(directory, pmOptions);
|
|
89852
89920
|
const lines = [];
|
|
89853
89921
|
if (result.success) {
|
|
89854
89922
|
lines.push("## Post-Mortem Report Generated");
|
|
@@ -89879,11 +89947,11 @@ async function handlePostMortemCommand(directory, args2, options) {
|
|
|
89879
89947
|
return `Error running post-mortem: ${message}. Run /swarm diagnose to check .swarm/ health.`;
|
|
89880
89948
|
}
|
|
89881
89949
|
}
|
|
89882
|
-
var
|
|
89950
|
+
var _internals56;
|
|
89883
89951
|
var init_post_mortem = __esm(() => {
|
|
89884
89952
|
init_curator_llm_factory();
|
|
89885
89953
|
init_curator_postmortem();
|
|
89886
|
-
|
|
89954
|
+
_internals56 = {
|
|
89887
89955
|
createCuratorLLMDelegate,
|
|
89888
89956
|
runCuratorPostMortem
|
|
89889
89957
|
};
|
|
@@ -90019,7 +90087,7 @@ function formatRelativeTime(epochMs) {
|
|
|
90019
90087
|
return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
|
|
90020
90088
|
}
|
|
90021
90089
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID, source) {
|
|
90022
|
-
const allActive = await
|
|
90090
|
+
const allActive = await _internals57.listActive(directory);
|
|
90023
90091
|
const allSessions = source === "cli";
|
|
90024
90092
|
const subs = allSessions ? allActive : allActive.filter((record3) => record3.sessionID === sessionID);
|
|
90025
90093
|
if (subs.length === 0) {
|
|
@@ -90052,10 +90120,10 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID, source)
|
|
|
90052
90120
|
return lines.join(`
|
|
90053
90121
|
`);
|
|
90054
90122
|
}
|
|
90055
|
-
var
|
|
90123
|
+
var _internals57;
|
|
90056
90124
|
var init_pr_monitor_status = __esm(() => {
|
|
90057
90125
|
init_pr_subscriptions();
|
|
90058
|
-
|
|
90126
|
+
_internals57 = {
|
|
90059
90127
|
formatRelativeTime,
|
|
90060
90128
|
listActive
|
|
90061
90129
|
};
|
|
@@ -90169,7 +90237,7 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
90169
90237
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
90170
90238
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
90171
90239
|
try {
|
|
90172
|
-
const config3 =
|
|
90240
|
+
const config3 = _internals58.loadPluginConfig(directory);
|
|
90173
90241
|
const prMonitorConfig = config3.pr_monitor;
|
|
90174
90242
|
if (!prMonitorConfig?.enabled) {
|
|
90175
90243
|
return [
|
|
@@ -90179,7 +90247,7 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
90179
90247
|
].join(`
|
|
90180
90248
|
`);
|
|
90181
90249
|
}
|
|
90182
|
-
await
|
|
90250
|
+
await _internals58.subscribe(directory, {
|
|
90183
90251
|
sessionID,
|
|
90184
90252
|
prNumber: prInfo.number,
|
|
90185
90253
|
repoFullName,
|
|
@@ -90203,12 +90271,12 @@ async function handlePrSubscribeCommand(directory, args2, sessionID) {
|
|
|
90203
90271
|
`);
|
|
90204
90272
|
}
|
|
90205
90273
|
}
|
|
90206
|
-
var
|
|
90274
|
+
var _internals58;
|
|
90207
90275
|
var init_pr_subscribe = __esm(() => {
|
|
90208
90276
|
init_pr_subscriptions();
|
|
90209
90277
|
init_loader();
|
|
90210
90278
|
init_pr_ref();
|
|
90211
|
-
|
|
90279
|
+
_internals58 = {
|
|
90212
90280
|
loadPluginConfig,
|
|
90213
90281
|
subscribe
|
|
90214
90282
|
};
|
|
@@ -90232,9 +90300,9 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
90232
90300
|
`);
|
|
90233
90301
|
}
|
|
90234
90302
|
const refToken = rest[0];
|
|
90235
|
-
const prInfo =
|
|
90303
|
+
const prInfo = _internals59.parsePrRef(refToken, directory);
|
|
90236
90304
|
if (!prInfo) {
|
|
90237
|
-
if (
|
|
90305
|
+
if (_internals59.looksLikePrRef(refToken)) {
|
|
90238
90306
|
return [
|
|
90239
90307
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
90240
90308
|
"",
|
|
@@ -90255,8 +90323,8 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
90255
90323
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
90256
90324
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
90257
90325
|
try {
|
|
90258
|
-
const correlationId =
|
|
90259
|
-
const result = await
|
|
90326
|
+
const correlationId = _internals59.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
90327
|
+
const result = await _internals59.unsubscribe(directory, correlationId);
|
|
90260
90328
|
if (!result) {
|
|
90261
90329
|
return [
|
|
90262
90330
|
`Not subscribed to ${prUrl}`,
|
|
@@ -90283,11 +90351,11 @@ async function handlePrUnsubscribeCommand(directory, args2, sessionID) {
|
|
|
90283
90351
|
`);
|
|
90284
90352
|
}
|
|
90285
90353
|
}
|
|
90286
|
-
var
|
|
90354
|
+
var _internals59;
|
|
90287
90355
|
var init_pr_unsubscribe = __esm(() => {
|
|
90288
90356
|
init_pr_subscriptions();
|
|
90289
90357
|
init_pr_ref();
|
|
90290
|
-
|
|
90358
|
+
_internals59 = {
|
|
90291
90359
|
unsubscribe,
|
|
90292
90360
|
buildCorrelationId,
|
|
90293
90361
|
parsePrRef,
|
|
@@ -90743,7 +90811,7 @@ async function runAdditionalLint(linter, mode, cwd) {
|
|
|
90743
90811
|
};
|
|
90744
90812
|
}
|
|
90745
90813
|
}
|
|
90746
|
-
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint,
|
|
90814
|
+
var MAX_OUTPUT_BYTES = 512000, MAX_COMMAND_LENGTH = 500, lint, _internals60;
|
|
90747
90815
|
var init_lint = __esm(() => {
|
|
90748
90816
|
init_zod();
|
|
90749
90817
|
init_discovery();
|
|
@@ -90775,15 +90843,15 @@ var init_lint = __esm(() => {
|
|
|
90775
90843
|
}
|
|
90776
90844
|
const { mode } = args2;
|
|
90777
90845
|
const cwd = directory;
|
|
90778
|
-
const linter = await
|
|
90846
|
+
const linter = await _internals60.detectAvailableLinter(directory);
|
|
90779
90847
|
if (linter) {
|
|
90780
|
-
const result = await
|
|
90848
|
+
const result = await _internals60.runLint(linter, mode, directory);
|
|
90781
90849
|
return JSON.stringify(result, null, 2);
|
|
90782
90850
|
}
|
|
90783
|
-
const additionalLinter =
|
|
90851
|
+
const additionalLinter = _internals60.detectAdditionalLinter(cwd);
|
|
90784
90852
|
if (additionalLinter) {
|
|
90785
90853
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
90786
|
-
const result = await
|
|
90854
|
+
const result = await _internals60.runAdditionalLint(additionalLinter, mode, cwd);
|
|
90787
90855
|
return JSON.stringify(result, null, 2);
|
|
90788
90856
|
}
|
|
90789
90857
|
const errorResult = {
|
|
@@ -90797,7 +90865,7 @@ For Rust: rustup component add clippy`
|
|
|
90797
90865
|
return JSON.stringify(errorResult, null, 2);
|
|
90798
90866
|
}
|
|
90799
90867
|
});
|
|
90800
|
-
|
|
90868
|
+
_internals60 = {
|
|
90801
90869
|
detectAvailableLinter,
|
|
90802
90870
|
runLint,
|
|
90803
90871
|
detectAdditionalLinter,
|
|
@@ -91111,7 +91179,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
|
|
|
91111
91179
|
}
|
|
91112
91180
|
async function runSecretscan(directory) {
|
|
91113
91181
|
try {
|
|
91114
|
-
const result = await
|
|
91182
|
+
const result = await _internals61.secretscan.execute({ directory }, {});
|
|
91115
91183
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
91116
91184
|
return JSON.parse(jsonStr);
|
|
91117
91185
|
} catch (e) {
|
|
@@ -91126,7 +91194,7 @@ async function runSecretscan(directory) {
|
|
|
91126
91194
|
return errorResult;
|
|
91127
91195
|
}
|
|
91128
91196
|
}
|
|
91129
|
-
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_PATTERNS2, O_NOFOLLOW, secretscan,
|
|
91197
|
+
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_PATTERNS2, O_NOFOLLOW, secretscan, _internals61;
|
|
91130
91198
|
var init_secretscan = __esm(() => {
|
|
91131
91199
|
init_zod();
|
|
91132
91200
|
init_path_security();
|
|
@@ -91498,7 +91566,7 @@ var init_secretscan = __esm(() => {
|
|
|
91498
91566
|
}
|
|
91499
91567
|
}
|
|
91500
91568
|
});
|
|
91501
|
-
|
|
91569
|
+
_internals61 = {
|
|
91502
91570
|
secretscan,
|
|
91503
91571
|
runSecretscan
|
|
91504
91572
|
};
|
|
@@ -92090,14 +92158,14 @@ function buildGoBackend() {
|
|
|
92090
92158
|
selectEntryPoints
|
|
92091
92159
|
};
|
|
92092
92160
|
}
|
|
92093
|
-
var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE,
|
|
92161
|
+
var PROFILE_ID = "go", IMPORT_REGEX_SINGLE, IMPORT_REGEX_GROUP, IMPORT_REGEX_GROUP_LINE, _internals62;
|
|
92094
92162
|
var init_go = __esm(() => {
|
|
92095
92163
|
init_default_backend();
|
|
92096
92164
|
init_profiles();
|
|
92097
92165
|
IMPORT_REGEX_SINGLE = /^\s*import\s+(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/gm;
|
|
92098
92166
|
IMPORT_REGEX_GROUP = /^\s*import\s*\(([\s\S]*?)\)/gm;
|
|
92099
92167
|
IMPORT_REGEX_GROUP_LINE = /(?:[a-zA-Z_.][a-zA-Z0-9_]*\s+)?"([^"]+)"/g;
|
|
92100
|
-
|
|
92168
|
+
_internals62 = { extractImports };
|
|
92101
92169
|
});
|
|
92102
92170
|
|
|
92103
92171
|
// src/lang/backends/python.ts
|
|
@@ -92209,13 +92277,13 @@ function buildPythonBackend() {
|
|
|
92209
92277
|
selectEntryPoints: selectEntryPoints2
|
|
92210
92278
|
};
|
|
92211
92279
|
}
|
|
92212
|
-
var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT,
|
|
92280
|
+
var PROFILE_ID2 = "python", IMPORT_REGEX_FROM_WITH_TARGETS, IMPORT_REGEX_IMPORT, _internals63;
|
|
92213
92281
|
var init_python = __esm(() => {
|
|
92214
92282
|
init_default_backend();
|
|
92215
92283
|
init_profiles();
|
|
92216
92284
|
IMPORT_REGEX_FROM_WITH_TARGETS = /^\s*from\s+(\.*[\w.]*)\s+import\s+(\([^)]*\)|[^\n#]+)/gm;
|
|
92217
92285
|
IMPORT_REGEX_IMPORT = /^\s*import\s+([^\n#]+)/gm;
|
|
92218
|
-
|
|
92286
|
+
_internals63 = { extractImports: extractImports2 };
|
|
92219
92287
|
});
|
|
92220
92288
|
|
|
92221
92289
|
// src/test-impact/analyzer.ts
|
|
@@ -92439,7 +92507,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
|
|
|
92439
92507
|
return;
|
|
92440
92508
|
}
|
|
92441
92509
|
if (PYTHON_EXTENSIONS.has(ext)) {
|
|
92442
|
-
const modules =
|
|
92510
|
+
const modules = _internals63.extractImports(testFile, content);
|
|
92443
92511
|
for (const mod of modules) {
|
|
92444
92512
|
const resolved = resolvePythonImport(testDir, mod);
|
|
92445
92513
|
if (resolved !== null)
|
|
@@ -92448,7 +92516,7 @@ function addImpactEdgesForTestFile(testFile, content, impactMap) {
|
|
|
92448
92516
|
return;
|
|
92449
92517
|
}
|
|
92450
92518
|
if (GO_EXTENSIONS.has(ext)) {
|
|
92451
|
-
const imports =
|
|
92519
|
+
const imports = _internals62.extractImports(testFile, content);
|
|
92452
92520
|
for (const importPath of imports) {
|
|
92453
92521
|
const sourceFiles = resolveGoImport(testDir, importPath);
|
|
92454
92522
|
for (const source of sourceFiles)
|
|
@@ -92475,8 +92543,8 @@ async function buildImpactMapInternal(cwd) {
|
|
|
92475
92543
|
return impactMap;
|
|
92476
92544
|
}
|
|
92477
92545
|
async function buildImpactMap(cwd) {
|
|
92478
|
-
const impactMap = await
|
|
92479
|
-
await
|
|
92546
|
+
const impactMap = await _internals64.buildImpactMapInternal(cwd);
|
|
92547
|
+
await _internals64.saveImpactMap(cwd, impactMap);
|
|
92480
92548
|
return impactMap;
|
|
92481
92549
|
}
|
|
92482
92550
|
async function loadImpactMap(cwd, options) {
|
|
@@ -92490,7 +92558,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
92490
92558
|
const hasValidValues = Object.values(map3).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
92491
92559
|
if (hasValidValues) {
|
|
92492
92560
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
92493
|
-
if (!
|
|
92561
|
+
if (!_internals64.isCacheStale(map3, generatedAt)) {
|
|
92494
92562
|
return map3;
|
|
92495
92563
|
}
|
|
92496
92564
|
if (options?.skipRebuild) {
|
|
@@ -92510,13 +92578,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
92510
92578
|
if (options?.skipRebuild) {
|
|
92511
92579
|
return {};
|
|
92512
92580
|
}
|
|
92513
|
-
return
|
|
92581
|
+
return _internals64.buildImpactMap(cwd);
|
|
92514
92582
|
}
|
|
92515
92583
|
async function saveImpactMap(cwd, impactMap) {
|
|
92516
92584
|
if (!path94.isAbsolute(cwd)) {
|
|
92517
92585
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
92518
92586
|
}
|
|
92519
|
-
|
|
92587
|
+
_internals64.validateProjectRoot(cwd);
|
|
92520
92588
|
const cacheDir2 = path94.join(cwd, ".swarm", "cache");
|
|
92521
92589
|
const cachePath = path94.join(cacheDir2, "impact-map.json");
|
|
92522
92590
|
if (!fs45.existsSync(cacheDir2)) {
|
|
@@ -92540,7 +92608,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
92540
92608
|
};
|
|
92541
92609
|
}
|
|
92542
92610
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
92543
|
-
const impactMap = await
|
|
92611
|
+
const impactMap = await _internals64.loadImpactMap(cwd);
|
|
92544
92612
|
const impactedTestsSet = new Set;
|
|
92545
92613
|
const untestedFiles = [];
|
|
92546
92614
|
let visitedCount = 0;
|
|
@@ -92625,7 +92693,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
92625
92693
|
budgetExceeded
|
|
92626
92694
|
};
|
|
92627
92695
|
}
|
|
92628
|
-
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache,
|
|
92696
|
+
var IMPORT_REGEX_ES, IMPORT_REGEX_REQUIRE, IMPORT_REGEX_REEXPORT, TS_EXTENSIONS, PYTHON_EXTENSIONS, GO_EXTENSIONS, EXTENSIONS_TO_TRY, goModuleCache, _internals64;
|
|
92629
92697
|
var init_analyzer = __esm(() => {
|
|
92630
92698
|
init_manager2();
|
|
92631
92699
|
init_go();
|
|
@@ -92638,7 +92706,7 @@ var init_analyzer = __esm(() => {
|
|
|
92638
92706
|
GO_EXTENSIONS = new Set([".go"]);
|
|
92639
92707
|
EXTENSIONS_TO_TRY = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
92640
92708
|
goModuleCache = new Map;
|
|
92641
|
-
|
|
92709
|
+
_internals64 = {
|
|
92642
92710
|
validateProjectRoot,
|
|
92643
92711
|
normalizePath: normalizePath2,
|
|
92644
92712
|
isCacheStale,
|
|
@@ -93021,7 +93089,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
93021
93089
|
}
|
|
93022
93090
|
const historyPath = getHistoryPath(workingDir);
|
|
93023
93091
|
const historyDir = path95.dirname(historyPath);
|
|
93024
|
-
|
|
93092
|
+
_internals65.validateProjectRoot(workingDir);
|
|
93025
93093
|
if (!fs46.existsSync(historyDir)) {
|
|
93026
93094
|
fs46.mkdirSync(historyDir, { recursive: true });
|
|
93027
93095
|
}
|
|
@@ -93144,7 +93212,7 @@ function getAllHistory(workingDir) {
|
|
|
93144
93212
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
93145
93213
|
return records;
|
|
93146
93214
|
}
|
|
93147
|
-
var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, HISTORY_WRITE_LOCK_TIMEOUT_MS = 5000, HISTORY_WRITE_LOCK_STALE_MS = 60000, HISTORY_WRITE_LOCK_BACKOFF_MS = 10, DANGEROUS_PROPERTY_NAMES,
|
|
93215
|
+
var MAX_HISTORY_PER_TEST = 20, MAX_ERROR_LENGTH = 500, MAX_STACK_LENGTH = 200, MAX_CHANGED_FILES = 50, HISTORY_WRITE_LOCK_TIMEOUT_MS = 5000, HISTORY_WRITE_LOCK_STALE_MS = 60000, HISTORY_WRITE_LOCK_BACKOFF_MS = 10, DANGEROUS_PROPERTY_NAMES, _internals65;
|
|
93148
93216
|
var init_history_store = __esm(() => {
|
|
93149
93217
|
init_manager2();
|
|
93150
93218
|
DANGEROUS_PROPERTY_NAMES = new Set([
|
|
@@ -93152,7 +93220,7 @@ var init_history_store = __esm(() => {
|
|
|
93152
93220
|
"constructor",
|
|
93153
93221
|
"prototype"
|
|
93154
93222
|
]);
|
|
93155
|
-
|
|
93223
|
+
_internals65 = {
|
|
93156
93224
|
validateProjectRoot
|
|
93157
93225
|
};
|
|
93158
93226
|
});
|
|
@@ -93191,7 +93259,7 @@ function resolveWorkingDirectory(workingDirectory, fallbackDirectory) {
|
|
|
93191
93259
|
};
|
|
93192
93260
|
}
|
|
93193
93261
|
}
|
|
93194
|
-
const rawPathParts = workingDirectory.split(
|
|
93262
|
+
const rawPathParts = workingDirectory.split(/[\\/]/);
|
|
93195
93263
|
if (rawPathParts.includes("..")) {
|
|
93196
93264
|
return {
|
|
93197
93265
|
success: false,
|
|
@@ -93402,7 +93470,7 @@ function readPackageJsonRaw(dir) {
|
|
|
93402
93470
|
}
|
|
93403
93471
|
}
|
|
93404
93472
|
function readPackageJson(dir) {
|
|
93405
|
-
return
|
|
93473
|
+
return _internals66.readPackageJsonRaw(dir);
|
|
93406
93474
|
}
|
|
93407
93475
|
function readPackageJsonTestScript(dir) {
|
|
93408
93476
|
return readPackageJson(dir)?.scripts?.test ?? null;
|
|
@@ -93572,7 +93640,7 @@ function buildTypescriptBackend() {
|
|
|
93572
93640
|
selectEntryPoints: selectEntryPoints3
|
|
93573
93641
|
};
|
|
93574
93642
|
}
|
|
93575
|
-
var PROFILE_ID4 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2,
|
|
93643
|
+
var PROFILE_ID4 = "typescript", IMPORT_REGEX_ES2, IMPORT_REGEX_BARE, IMPORT_REGEX_REQUIRE2, IMPORT_REGEX_DYNAMIC, IMPORT_REGEX_REEXPORT2, _internals66;
|
|
93576
93644
|
var init_typescript = __esm(() => {
|
|
93577
93645
|
init_default_backend();
|
|
93578
93646
|
init_profiles();
|
|
@@ -93581,7 +93649,7 @@ var init_typescript = __esm(() => {
|
|
|
93581
93649
|
IMPORT_REGEX_REQUIRE2 = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
93582
93650
|
IMPORT_REGEX_DYNAMIC = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
93583
93651
|
IMPORT_REGEX_REEXPORT2 = /export\s+(?:\{[^}]*\}|\*)\s+from\s+['"]([^'"]+)['"]/g;
|
|
93584
|
-
|
|
93652
|
+
_internals66 = {
|
|
93585
93653
|
readPackageJsonRaw,
|
|
93586
93654
|
readPackageJsonTestScript,
|
|
93587
93655
|
frameworkFromScriptsTest
|
|
@@ -93614,7 +93682,7 @@ __export(exports_dispatch, {
|
|
|
93614
93682
|
pickedProfiles: () => pickedProfiles,
|
|
93615
93683
|
pickBackend: () => pickBackend,
|
|
93616
93684
|
clearDispatchCache: () => clearDispatchCache,
|
|
93617
|
-
_internals: () =>
|
|
93685
|
+
_internals: () => _internals67
|
|
93618
93686
|
});
|
|
93619
93687
|
import * as fs50 from "node:fs";
|
|
93620
93688
|
import * as path99 from "node:path";
|
|
@@ -93669,7 +93737,7 @@ function findManifestRoot(start) {
|
|
|
93669
93737
|
return start;
|
|
93670
93738
|
}
|
|
93671
93739
|
function evictIfNeeded() {
|
|
93672
|
-
if (cache2.size <=
|
|
93740
|
+
if (cache2.size <= _internals67.cacheCapacity)
|
|
93673
93741
|
return;
|
|
93674
93742
|
let oldestKey;
|
|
93675
93743
|
let oldestOrder = Infinity;
|
|
@@ -93700,7 +93768,7 @@ async function pickBackend(dir) {
|
|
|
93700
93768
|
evictIfNeeded();
|
|
93701
93769
|
return null;
|
|
93702
93770
|
}
|
|
93703
|
-
const profiles = await
|
|
93771
|
+
const profiles = await _internals67.detectProjectLanguages(root);
|
|
93704
93772
|
if (profiles.length === 0) {
|
|
93705
93773
|
cache2.set(cacheKey, {
|
|
93706
93774
|
hash: hash4,
|
|
@@ -93732,12 +93800,12 @@ function clearDispatchCache() {
|
|
|
93732
93800
|
manifestRootCache.clear();
|
|
93733
93801
|
insertCounter = 0;
|
|
93734
93802
|
}
|
|
93735
|
-
var
|
|
93803
|
+
var _internals67, cache2, insertCounter = 0, MANIFEST_FILES, _MANIFEST_SET, manifestRootCache;
|
|
93736
93804
|
var init_dispatch = __esm(() => {
|
|
93737
93805
|
init_backends();
|
|
93738
93806
|
init_detector();
|
|
93739
93807
|
init_registry_backend();
|
|
93740
|
-
|
|
93808
|
+
_internals67 = {
|
|
93741
93809
|
detectProjectLanguages,
|
|
93742
93810
|
cacheCapacity: 64
|
|
93743
93811
|
};
|
|
@@ -95593,9 +95661,9 @@ function getVersionFileVersion(dir) {
|
|
|
95593
95661
|
async function runVersionCheck2(dir, _timeoutMs) {
|
|
95594
95662
|
const startTime = Date.now();
|
|
95595
95663
|
try {
|
|
95596
|
-
const packageVersion =
|
|
95597
|
-
const changelogVersion =
|
|
95598
|
-
const versionFileVersion =
|
|
95664
|
+
const packageVersion = _internals68.getPackageVersion(dir);
|
|
95665
|
+
const changelogVersion = _internals68.getChangelogVersion(dir);
|
|
95666
|
+
const versionFileVersion = _internals68.getVersionFileVersion(dir);
|
|
95599
95667
|
const versions3 = [];
|
|
95600
95668
|
if (packageVersion)
|
|
95601
95669
|
versions3.push(`package.json: ${packageVersion}`);
|
|
@@ -95959,7 +96027,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
95959
96027
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
95960
96028
|
let validatedDir;
|
|
95961
96029
|
try {
|
|
95962
|
-
validatedDir =
|
|
96030
|
+
validatedDir = _internals68.validateDirectoryPath(dir);
|
|
95963
96031
|
} catch (error93) {
|
|
95964
96032
|
return {
|
|
95965
96033
|
id: reportId,
|
|
@@ -95979,7 +96047,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
95979
96047
|
}
|
|
95980
96048
|
let validatedTimeout;
|
|
95981
96049
|
try {
|
|
95982
|
-
validatedTimeout =
|
|
96050
|
+
validatedTimeout = _internals68.validateTimeout(config3?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
95983
96051
|
} catch (error93) {
|
|
95984
96052
|
return {
|
|
95985
96053
|
id: reportId,
|
|
@@ -96020,12 +96088,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
96020
96088
|
});
|
|
96021
96089
|
const checks5 = [];
|
|
96022
96090
|
log("[Preflight] Running lint check...");
|
|
96023
|
-
const lintResult = await
|
|
96091
|
+
const lintResult = await _internals68.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
96024
96092
|
checks5.push(lintResult);
|
|
96025
96093
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
96026
96094
|
if (!cfg.skipTests) {
|
|
96027
96095
|
log("[Preflight] Running tests check...");
|
|
96028
|
-
const testsResult = await
|
|
96096
|
+
const testsResult = await _internals68.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
96029
96097
|
checks5.push(testsResult);
|
|
96030
96098
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
96031
96099
|
} else {
|
|
@@ -96037,7 +96105,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
96037
96105
|
}
|
|
96038
96106
|
if (!cfg.skipSecrets) {
|
|
96039
96107
|
log("[Preflight] Running secrets check...");
|
|
96040
|
-
const secretsResult = await
|
|
96108
|
+
const secretsResult = await _internals68.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
96041
96109
|
checks5.push(secretsResult);
|
|
96042
96110
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
96043
96111
|
} else {
|
|
@@ -96049,7 +96117,7 @@ async function runPreflight(dir, phase, config3) {
|
|
|
96049
96117
|
}
|
|
96050
96118
|
if (!cfg.skipEvidence) {
|
|
96051
96119
|
log("[Preflight] Running evidence check...");
|
|
96052
|
-
const evidenceResult = await
|
|
96120
|
+
const evidenceResult = await _internals68.runEvidenceCheck(validatedDir);
|
|
96053
96121
|
checks5.push(evidenceResult);
|
|
96054
96122
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
96055
96123
|
} else {
|
|
@@ -96060,12 +96128,12 @@ async function runPreflight(dir, phase, config3) {
|
|
|
96060
96128
|
});
|
|
96061
96129
|
}
|
|
96062
96130
|
log("[Preflight] Running requirement coverage check...");
|
|
96063
|
-
const reqCoverageResult = await
|
|
96131
|
+
const reqCoverageResult = await _internals68.runRequirementCoverageCheck(validatedDir, phase);
|
|
96064
96132
|
checks5.push(reqCoverageResult);
|
|
96065
96133
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
96066
96134
|
if (!cfg.skipVersion) {
|
|
96067
96135
|
log("[Preflight] Running version check...");
|
|
96068
|
-
const versionResult = await
|
|
96136
|
+
const versionResult = await _internals68.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
96069
96137
|
checks5.push(versionResult);
|
|
96070
96138
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
96071
96139
|
} else {
|
|
@@ -96128,10 +96196,10 @@ function formatPreflightMarkdown(report) {
|
|
|
96128
96196
|
async function handlePreflightCommand(directory, _args) {
|
|
96129
96197
|
const plan = await loadPlan(directory);
|
|
96130
96198
|
const phase = plan?.current_phase ?? 1;
|
|
96131
|
-
const report = await
|
|
96132
|
-
return
|
|
96199
|
+
const report = await _internals68.runPreflight(directory, phase);
|
|
96200
|
+
return _internals68.formatPreflightMarkdown(report);
|
|
96133
96201
|
}
|
|
96134
|
-
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG,
|
|
96202
|
+
var MIN_CHECK_TIMEOUT_MS = 5000, MAX_CHECK_TIMEOUT_MS = 300000, DEFAULT_CONFIG, _internals68;
|
|
96135
96203
|
var init_preflight_service = __esm(() => {
|
|
96136
96204
|
init_gate_bridge();
|
|
96137
96205
|
init_manager2();
|
|
@@ -96150,7 +96218,7 @@ var init_preflight_service = __esm(() => {
|
|
|
96150
96218
|
testScope: "convention",
|
|
96151
96219
|
linter: "biome"
|
|
96152
96220
|
};
|
|
96153
|
-
|
|
96221
|
+
_internals68 = {
|
|
96154
96222
|
runPreflight,
|
|
96155
96223
|
formatPreflightMarkdown,
|
|
96156
96224
|
handlePreflightCommand,
|
|
@@ -97977,7 +98045,7 @@ function resetPrmSessionState(session, sessionId) {
|
|
|
97977
98045
|
session.prmTrajectoryStep = 0;
|
|
97978
98046
|
session.replayArtifactPath = null;
|
|
97979
98047
|
if (sessionId) {
|
|
97980
|
-
|
|
98048
|
+
_internals69.clearTrajectoryCache(sessionId);
|
|
97981
98049
|
}
|
|
97982
98050
|
}
|
|
97983
98051
|
function createPrmHook(config3, directory) {
|
|
@@ -97986,26 +98054,26 @@ function createPrmHook(config3, directory) {
|
|
|
97986
98054
|
return;
|
|
97987
98055
|
}
|
|
97988
98056
|
const { sessionID } = context;
|
|
97989
|
-
const session =
|
|
98057
|
+
const session = _internals69.getAgentSession(sessionID);
|
|
97990
98058
|
if (!session || !session.delegationActive) {
|
|
97991
98059
|
return;
|
|
97992
98060
|
}
|
|
97993
98061
|
try {
|
|
97994
|
-
const cachedTrajectory =
|
|
97995
|
-
const trajectory = cachedTrajectory.length > 0 ? cachedTrajectory : await
|
|
97996
|
-
const detectionResult =
|
|
98062
|
+
const cachedTrajectory = _internals69.getInMemoryTrajectory(sessionID);
|
|
98063
|
+
const trajectory = cachedTrajectory.length > 0 ? cachedTrajectory : await _internals69.readTrajectory(sessionID, directory);
|
|
98064
|
+
const detectionResult = _internals69.detectPatterns(trajectory, config3, session.prmTrajectoryStep);
|
|
97997
98065
|
if (detectionResult.matches.length === 0) {
|
|
97998
98066
|
return;
|
|
97999
98067
|
}
|
|
98000
98068
|
const sessionPrmState = session;
|
|
98001
98069
|
let escalationTracker = sessionPrmState.prmEscalationTracker;
|
|
98002
98070
|
if (!sessionPrmState.replayArtifactPath) {
|
|
98003
|
-
sessionPrmState.replayArtifactPath = await
|
|
98071
|
+
sessionPrmState.replayArtifactPath = await _internals69.startReplayRecording(sessionID, directory);
|
|
98004
98072
|
}
|
|
98005
98073
|
const artifactPath = sessionPrmState.replayArtifactPath;
|
|
98006
98074
|
if (!sessionPrmState.prmInitialized) {
|
|
98007
98075
|
sessionPrmState.prmInitialized = true;
|
|
98008
|
-
|
|
98076
|
+
_internals69.cleanupOldTrajectoryFiles(directory).catch(() => {});
|
|
98009
98077
|
}
|
|
98010
98078
|
if (!escalationTracker) {
|
|
98011
98079
|
const initialState = session.prmLastPatternDetected ? {
|
|
@@ -98020,8 +98088,8 @@ function createPrmHook(config3, directory) {
|
|
|
98020
98088
|
}
|
|
98021
98089
|
const previousEscalationLevel = session.prmEscalationLevel;
|
|
98022
98090
|
for (const match of detectionResult.matches) {
|
|
98023
|
-
const correction =
|
|
98024
|
-
const formattedCorrection =
|
|
98091
|
+
const correction = _internals69.generateCourseCorrection(match, trajectory);
|
|
98092
|
+
const formattedCorrection = _internals69.formatCourseCorrectionForInjection(correction);
|
|
98025
98093
|
if (!session.pendingAdvisoryMessages) {
|
|
98026
98094
|
session.pendingAdvisoryMessages = [];
|
|
98027
98095
|
}
|
|
@@ -98037,10 +98105,10 @@ function createPrmHook(config3, directory) {
|
|
|
98037
98105
|
session.prmEscalationLevel = escalationLevel;
|
|
98038
98106
|
session.prmLastPatternDetected = match;
|
|
98039
98107
|
session.prmHardStopPending = hardStopPending;
|
|
98040
|
-
|
|
98041
|
-
|
|
98108
|
+
_internals69.telemetry.prmPatternDetected(sessionID, match.pattern, match.severity, match.category, match.stepRange);
|
|
98109
|
+
_internals69.telemetry.prmCourseCorrectionInjected(sessionID, match.pattern, escalationLevel);
|
|
98042
98110
|
if (artifactPath) {
|
|
98043
|
-
await
|
|
98111
|
+
await _internals69.recordReplayEntry(artifactPath, sessionID, {
|
|
98044
98112
|
type: "pattern_detected",
|
|
98045
98113
|
data: {
|
|
98046
98114
|
pattern: match.pattern,
|
|
@@ -98055,7 +98123,7 @@ function createPrmHook(config3, directory) {
|
|
|
98055
98123
|
});
|
|
98056
98124
|
}
|
|
98057
98125
|
if (artifactPath) {
|
|
98058
|
-
await
|
|
98126
|
+
await _internals69.recordReplayEntry(artifactPath, sessionID, {
|
|
98059
98127
|
type: "course_correction",
|
|
98060
98128
|
data: {
|
|
98061
98129
|
pattern: correction.pattern,
|
|
@@ -98071,7 +98139,7 @@ function createPrmHook(config3, directory) {
|
|
|
98071
98139
|
}
|
|
98072
98140
|
escalationTracker.clearPendingCorrections();
|
|
98073
98141
|
if (artifactPath && session.prmEscalationLevel > previousEscalationLevel) {
|
|
98074
|
-
await
|
|
98142
|
+
await _internals69.recordReplayEntry(artifactPath, sessionID, {
|
|
98075
98143
|
type: "escalation",
|
|
98076
98144
|
data: {
|
|
98077
98145
|
previousLevel: previousEscalationLevel,
|
|
@@ -98081,7 +98149,7 @@ function createPrmHook(config3, directory) {
|
|
|
98081
98149
|
});
|
|
98082
98150
|
}
|
|
98083
98151
|
if (artifactPath && session.prmHardStopPending && previousEscalationLevel < 3) {
|
|
98084
|
-
await
|
|
98152
|
+
await _internals69.recordReplayEntry(artifactPath, sessionID, {
|
|
98085
98153
|
type: "hard_stop",
|
|
98086
98154
|
data: {
|
|
98087
98155
|
escalationLevel: session.prmEscalationLevel,
|
|
@@ -98098,7 +98166,7 @@ function createPrmHook(config3, directory) {
|
|
|
98098
98166
|
}
|
|
98099
98167
|
return { toolAfter };
|
|
98100
98168
|
}
|
|
98101
|
-
var
|
|
98169
|
+
var _internals69;
|
|
98102
98170
|
var init_prm = __esm(() => {
|
|
98103
98171
|
init_course_correction();
|
|
98104
98172
|
init_escalation();
|
|
@@ -98110,7 +98178,7 @@ var init_prm = __esm(() => {
|
|
|
98110
98178
|
init_pattern_detector();
|
|
98111
98179
|
init_replay();
|
|
98112
98180
|
init_trajectory_store();
|
|
98113
|
-
|
|
98181
|
+
_internals69 = {
|
|
98114
98182
|
getAgentSession,
|
|
98115
98183
|
readTrajectory,
|
|
98116
98184
|
getInMemoryTrajectory,
|
|
@@ -99273,7 +99341,7 @@ async function getStatusData(directory, agents) {
|
|
|
99273
99341
|
}
|
|
99274
99342
|
function enrichWithLeanTurbo(status, directory) {
|
|
99275
99343
|
const turboMode = hasActiveTurboMode();
|
|
99276
|
-
const leanActive =
|
|
99344
|
+
const leanActive = _internals70.hasActiveLeanTurbo();
|
|
99277
99345
|
let turboStrategy = "off";
|
|
99278
99346
|
if (leanActive) {
|
|
99279
99347
|
turboStrategy = "lean";
|
|
@@ -99292,7 +99360,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
99292
99360
|
}
|
|
99293
99361
|
}
|
|
99294
99362
|
if (leanSessionID) {
|
|
99295
|
-
const runState =
|
|
99363
|
+
const runState = _internals70.loadLeanTurboRunState(directory, leanSessionID);
|
|
99296
99364
|
if (runState) {
|
|
99297
99365
|
status.leanTurboPhase = runState.phase;
|
|
99298
99366
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -99324,7 +99392,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
99324
99392
|
}
|
|
99325
99393
|
}
|
|
99326
99394
|
}
|
|
99327
|
-
status.fullAutoActive =
|
|
99395
|
+
status.fullAutoActive = _internals70.hasActiveFullAuto();
|
|
99328
99396
|
return status;
|
|
99329
99397
|
}
|
|
99330
99398
|
function formatStatusMarkdown(status) {
|
|
@@ -99452,7 +99520,7 @@ async function countProposals(directory) {
|
|
|
99452
99520
|
return 0;
|
|
99453
99521
|
}
|
|
99454
99522
|
}
|
|
99455
|
-
var
|
|
99523
|
+
var _internals70;
|
|
99456
99524
|
var init_status_service = __esm(() => {
|
|
99457
99525
|
init_extractors();
|
|
99458
99526
|
init_knowledge_escalator();
|
|
@@ -99463,7 +99531,7 @@ var init_status_service = __esm(() => {
|
|
|
99463
99531
|
init_state4();
|
|
99464
99532
|
init_compaction_service();
|
|
99465
99533
|
init_context_budget_service();
|
|
99466
|
-
|
|
99534
|
+
_internals70 = {
|
|
99467
99535
|
loadLeanTurboRunState,
|
|
99468
99536
|
hasActiveLeanTurbo,
|
|
99469
99537
|
hasActiveFullAuto
|
|
@@ -99560,7 +99628,7 @@ async function handleTurboCommand(directory, args2, sessionID) {
|
|
|
99560
99628
|
if (arg0 === "on") {
|
|
99561
99629
|
let strategy = "standard";
|
|
99562
99630
|
try {
|
|
99563
|
-
const { config: config3 } =
|
|
99631
|
+
const { config: config3 } = _internals71.loadPluginConfigWithMeta(directory);
|
|
99564
99632
|
if (config3.turbo?.strategy === "lean") {
|
|
99565
99633
|
strategy = "lean";
|
|
99566
99634
|
}
|
|
@@ -99657,7 +99725,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
99657
99725
|
let maxParallelCoders = 4;
|
|
99658
99726
|
let conflictPolicy = "serialize";
|
|
99659
99727
|
try {
|
|
99660
|
-
const { config: config3 } =
|
|
99728
|
+
const { config: config3 } = _internals71.loadPluginConfigWithMeta(directory);
|
|
99661
99729
|
const leanConfig = config3.turbo?.lean;
|
|
99662
99730
|
if (leanConfig) {
|
|
99663
99731
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -99727,14 +99795,14 @@ function buildStatusMessage2(session, directory, sessionID) {
|
|
|
99727
99795
|
].join(`
|
|
99728
99796
|
`);
|
|
99729
99797
|
}
|
|
99730
|
-
var
|
|
99798
|
+
var _internals71;
|
|
99731
99799
|
var init_turbo = __esm(() => {
|
|
99732
99800
|
init_config();
|
|
99733
99801
|
init_state2();
|
|
99734
99802
|
init_state();
|
|
99735
99803
|
init_state4();
|
|
99736
99804
|
init_logger();
|
|
99737
|
-
|
|
99805
|
+
_internals71 = {
|
|
99738
99806
|
loadPluginConfigWithMeta
|
|
99739
99807
|
};
|
|
99740
99808
|
});
|
|
@@ -106659,42 +106727,42 @@ var init_evidence_summary_integration = __esm(() => {
|
|
|
106659
106727
|
var exports_pr_event_subscribers = {};
|
|
106660
106728
|
__export(exports_pr_event_subscribers, {
|
|
106661
106729
|
registerPrEventSubscribers: () => registerPrEventSubscribers,
|
|
106662
|
-
_internals: () =>
|
|
106730
|
+
_internals: () => _internals72
|
|
106663
106731
|
});
|
|
106664
106732
|
function registerPrEventSubscribers(options) {
|
|
106665
106733
|
const { directory, config: config3 } = options;
|
|
106666
|
-
const bus =
|
|
106734
|
+
const bus = _internals72.getGlobalEventBus();
|
|
106667
106735
|
const unsubscribers = [];
|
|
106668
106736
|
for (const [eventType, configFlag] of Object.entries(EVENT_CONFIG_MAP)) {
|
|
106669
106737
|
if (!config3[configFlag]) {
|
|
106670
|
-
|
|
106738
|
+
_internals72.log(`[pr-monitor] Skipping ${eventType} subscriber (disabled by config)`);
|
|
106671
106739
|
continue;
|
|
106672
106740
|
}
|
|
106673
106741
|
const listener = async (event) => {
|
|
106674
106742
|
try {
|
|
106675
|
-
await
|
|
106743
|
+
await _internals72.handlePrEvent(event, directory, config3);
|
|
106676
106744
|
} catch (err) {
|
|
106677
|
-
|
|
106745
|
+
_internals72.log(`[pr-monitor] Error handling ${eventType}`, {
|
|
106678
106746
|
error: err instanceof Error ? err.message : String(err)
|
|
106679
106747
|
});
|
|
106680
106748
|
}
|
|
106681
106749
|
};
|
|
106682
106750
|
const unsub = bus.subscribe(eventType, listener);
|
|
106683
106751
|
unsubscribers.push(unsub);
|
|
106684
|
-
|
|
106752
|
+
_internals72.log(`[pr-monitor] Registered subscriber for ${eventType}`);
|
|
106685
106753
|
}
|
|
106686
106754
|
return () => {
|
|
106687
106755
|
for (const unsub of unsubscribers) {
|
|
106688
106756
|
unsub();
|
|
106689
106757
|
}
|
|
106690
|
-
|
|
106758
|
+
_internals72.log("[pr-monitor] Unregistered all PR event subscribers");
|
|
106691
106759
|
};
|
|
106692
106760
|
}
|
|
106693
106761
|
async function handlePrEvent(event, directory, config3) {
|
|
106694
106762
|
const payload = event.payload;
|
|
106695
106763
|
if (!payload?.prNumber || !payload?.repoFullName)
|
|
106696
106764
|
return;
|
|
106697
|
-
const subscriptions = await
|
|
106765
|
+
const subscriptions = await _internals72.listActive(directory);
|
|
106698
106766
|
const matching = subscriptions.filter((sub) => sub.prNumber === payload.prNumber && sub.repoFullName === payload.repoFullName);
|
|
106699
106767
|
if (matching.length === 0)
|
|
106700
106768
|
return;
|
|
@@ -106706,9 +106774,9 @@ async function handlePrEvent(event, directory, config3) {
|
|
|
106706
106774
|
return `[MODE: PR_FEEDBACK pr="${safePrUrl}"]`;
|
|
106707
106775
|
})() : null;
|
|
106708
106776
|
for (const sub of matching) {
|
|
106709
|
-
const session =
|
|
106777
|
+
const session = _internals72.getAgentSession(sub.sessionID);
|
|
106710
106778
|
if (!session) {
|
|
106711
|
-
|
|
106779
|
+
_internals72.log(`[pr-monitor] Session ${sub.sessionID} not found — skipping advisory delivery`);
|
|
106712
106780
|
continue;
|
|
106713
106781
|
}
|
|
106714
106782
|
session.pendingAdvisoryMessages ??= [];
|
|
@@ -106718,10 +106786,10 @@ async function handlePrEvent(event, directory, config3) {
|
|
|
106718
106786
|
continue;
|
|
106719
106787
|
}
|
|
106720
106788
|
session.pendingAdvisoryMessages.push(message);
|
|
106721
|
-
|
|
106789
|
+
_internals72.log(`[pr-monitor] Delivered ${event.type} advisory to session ${sub.sessionID}`);
|
|
106722
106790
|
if (modeSignal) {
|
|
106723
106791
|
session.pendingAdvisoryMessages.push(modeSignal);
|
|
106724
|
-
|
|
106792
|
+
_internals72.log(`[pr-monitor] Injected PR_FEEDBACK mode signal for session ${sub.sessionID} (${event.type})`);
|
|
106725
106793
|
}
|
|
106726
106794
|
}
|
|
106727
106795
|
}
|
|
@@ -106757,13 +106825,13 @@ function formatAdvisory(type, payload) {
|
|
|
106757
106825
|
return null;
|
|
106758
106826
|
}
|
|
106759
106827
|
}
|
|
106760
|
-
var
|
|
106828
|
+
var _internals72, AUTO_PR_FEEDBACK_EVENTS, EVENT_CONFIG_MAP;
|
|
106761
106829
|
var init_pr_event_subscribers = __esm(() => {
|
|
106762
106830
|
init_state2();
|
|
106763
106831
|
init_utils();
|
|
106764
106832
|
init_event_bus();
|
|
106765
106833
|
init_pr_subscriptions();
|
|
106766
|
-
|
|
106834
|
+
_internals72 = {
|
|
106767
106835
|
handlePrEvent,
|
|
106768
106836
|
getGlobalEventBus,
|
|
106769
106837
|
listActive,
|
|
@@ -107750,7 +107818,7 @@ __export(exports_runtime, {
|
|
|
107750
107818
|
getSupportedLanguages: () => getSupportedLanguages,
|
|
107751
107819
|
getInitializedLanguages: () => getInitializedLanguages,
|
|
107752
107820
|
clearParserCache: () => clearParserCache,
|
|
107753
|
-
_internals: () =>
|
|
107821
|
+
_internals: () => _internals81
|
|
107754
107822
|
});
|
|
107755
107823
|
import { existsSync as existsSync75, statSync as statSync24 } from "node:fs";
|
|
107756
107824
|
import * as path130 from "node:path";
|
|
@@ -107762,10 +107830,10 @@ async function initTreeSitter() {
|
|
|
107762
107830
|
const thisDir = path130.dirname(fileURLToPath4(import.meta.url));
|
|
107763
107831
|
const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
|
|
107764
107832
|
if (isSource) {
|
|
107765
|
-
await
|
|
107833
|
+
await _internals81.parserInit();
|
|
107766
107834
|
} else {
|
|
107767
107835
|
const grammarsDir = getGrammarsDirAbsolute();
|
|
107768
|
-
await
|
|
107836
|
+
await _internals81.parserInit({
|
|
107769
107837
|
locateFile(scriptName) {
|
|
107770
107838
|
return path130.join(grammarsDir, scriptName);
|
|
107771
107839
|
}
|
|
@@ -107880,12 +107948,12 @@ function getInitializedLanguages() {
|
|
|
107880
107948
|
function getSupportedLanguages() {
|
|
107881
107949
|
return Object.keys(LANGUAGE_WASM_MAP);
|
|
107882
107950
|
}
|
|
107883
|
-
var parserCache, inflightLoads, GRAMMAR_LOAD_TIMEOUT_MS = 1e4, initializedLanguages, treeSitterInitPromise = null,
|
|
107951
|
+
var parserCache, inflightLoads, GRAMMAR_LOAD_TIMEOUT_MS = 1e4, initializedLanguages, treeSitterInitPromise = null, _internals81, LANGUAGE_WASM_MAP;
|
|
107884
107952
|
var init_runtime = __esm(() => {
|
|
107885
107953
|
parserCache = new Map;
|
|
107886
107954
|
inflightLoads = new Map;
|
|
107887
107955
|
initializedLanguages = new Set;
|
|
107888
|
-
|
|
107956
|
+
_internals81 = {
|
|
107889
107957
|
parserInit: TreeSitterParser.init
|
|
107890
107958
|
};
|
|
107891
107959
|
LANGUAGE_WASM_MAP = {
|
|
@@ -108608,7 +108676,7 @@ async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
|
|
|
108608
108676
|
return data;
|
|
108609
108677
|
});
|
|
108610
108678
|
for (const id of shownIds) {
|
|
108611
|
-
await
|
|
108679
|
+
await _internals84.recordKnowledgeEvent(directory, {
|
|
108612
108680
|
type: "outcome",
|
|
108613
108681
|
knowledge_id: id,
|
|
108614
108682
|
phase: phaseInfo,
|
|
@@ -108677,13 +108745,13 @@ function scoreDirectiveAgainstContext(entry, ctx) {
|
|
|
108677
108745
|
score += 0.1;
|
|
108678
108746
|
return { triggerHit, actionHit, agentHit, score: Math.min(1, score) };
|
|
108679
108747
|
}
|
|
108680
|
-
var JACCARD_THRESHOLD2 = 0.6, HIVE_TIER_BOOST = 0.05, DEFAULT_SAME_PROJECT_PENALTY = -0.05, QUARANTINED_STATUS = "quarantined",
|
|
108748
|
+
var JACCARD_THRESHOLD2 = 0.6, HIVE_TIER_BOOST = 0.05, DEFAULT_SAME_PROJECT_PENALTY = -0.05, QUARANTINED_STATUS = "quarantined", _internals84;
|
|
108681
108749
|
var init_knowledge_reader = __esm(() => {
|
|
108682
108750
|
init_task_file();
|
|
108683
108751
|
init_logger();
|
|
108684
108752
|
init_knowledge_events();
|
|
108685
108753
|
init_knowledge_store();
|
|
108686
|
-
|
|
108754
|
+
_internals84 = {
|
|
108687
108755
|
readMergedKnowledge,
|
|
108688
108756
|
updateRetrievalOutcome,
|
|
108689
108757
|
scoreDirectiveAgainstContext,
|
|
@@ -108983,9 +109051,9 @@ var init_search_knowledge = __esm(() => {
|
|
|
108983
109051
|
var exports_knowledge_recall = {};
|
|
108984
109052
|
__export(exports_knowledge_recall, {
|
|
108985
109053
|
knowledge_recall: () => knowledge_recall,
|
|
108986
|
-
_internals: () =>
|
|
109054
|
+
_internals: () => _internals85
|
|
108987
109055
|
});
|
|
108988
|
-
var knowledge_recall,
|
|
109056
|
+
var knowledge_recall, _internals85;
|
|
108989
109057
|
var init_knowledge_recall = __esm(() => {
|
|
108990
109058
|
init_zod();
|
|
108991
109059
|
init_config();
|
|
@@ -109066,7 +109134,7 @@ var init_knowledge_recall = __esm(() => {
|
|
|
109066
109134
|
return JSON.stringify(result);
|
|
109067
109135
|
}
|
|
109068
109136
|
});
|
|
109069
|
-
|
|
109137
|
+
_internals85 = {
|
|
109070
109138
|
knowledge_recall
|
|
109071
109139
|
};
|
|
109072
109140
|
});
|
|
@@ -109121,7 +109189,7 @@ __export(exports_curator_drift, {
|
|
|
109121
109189
|
runDeterministicDriftCheck: () => runDeterministicDriftCheck,
|
|
109122
109190
|
readPriorDriftReports: () => readPriorDriftReports,
|
|
109123
109191
|
buildDriftInjectionText: () => buildDriftInjectionText,
|
|
109124
|
-
_internals: () =>
|
|
109192
|
+
_internals: () => _internals89
|
|
109125
109193
|
});
|
|
109126
109194
|
import * as fs87 from "node:fs";
|
|
109127
109195
|
import * as path149 from "node:path";
|
|
@@ -109170,7 +109238,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
|
|
|
109170
109238
|
try {
|
|
109171
109239
|
const planMd = await readSwarmFileAsync(directory, "plan.md");
|
|
109172
109240
|
const specMd = readEffectiveSpecSync(directory)?.content ?? null;
|
|
109173
|
-
const priorReports = await
|
|
109241
|
+
const priorReports = await _internals89.readPriorDriftReports(directory);
|
|
109174
109242
|
const complianceCount = curatorResult.compliance.length;
|
|
109175
109243
|
const warningCompliance = curatorResult.compliance.filter((obs) => obs.severity === "warning");
|
|
109176
109244
|
let alignment = "ALIGNED";
|
|
@@ -109233,7 +109301,7 @@ async function runDeterministicDriftCheck(directory, phase, curatorResult, confi
|
|
|
109233
109301
|
scope_additions: [],
|
|
109234
109302
|
injection_summary: injectionSummary
|
|
109235
109303
|
};
|
|
109236
|
-
const reportPath = await
|
|
109304
|
+
const reportPath = await _internals89.writeDriftReport(directory, report);
|
|
109237
109305
|
getGlobalEventBus().publish("curator.drift.completed", {
|
|
109238
109306
|
phase,
|
|
109239
109307
|
alignment,
|
|
@@ -109296,13 +109364,13 @@ function buildDriftInjectionText(report, maxChars) {
|
|
|
109296
109364
|
}
|
|
109297
109365
|
return text.slice(0, maxChars);
|
|
109298
109366
|
}
|
|
109299
|
-
var DRIFT_REPORT_PREFIX = "drift-report-phase-",
|
|
109367
|
+
var DRIFT_REPORT_PREFIX = "drift-report-phase-", _internals89;
|
|
109300
109368
|
var init_curator_drift = __esm(() => {
|
|
109301
109369
|
init_event_bus();
|
|
109302
109370
|
init_effective_spec();
|
|
109303
109371
|
init_logger();
|
|
109304
109372
|
init_utils2();
|
|
109305
|
-
|
|
109373
|
+
_internals89 = {
|
|
109306
109374
|
readPriorDriftReports,
|
|
109307
109375
|
writeDriftReport,
|
|
109308
109376
|
runDeterministicDriftCheck,
|
|
@@ -109314,7 +109382,7 @@ var init_curator_drift = __esm(() => {
|
|
|
109314
109382
|
var exports_design_doc_drift = {};
|
|
109315
109383
|
__export(exports_design_doc_drift, {
|
|
109316
109384
|
runDesignDocDriftCheck: () => runDesignDocDriftCheck,
|
|
109317
|
-
_internals: () =>
|
|
109385
|
+
_internals: () => _internals119
|
|
109318
109386
|
});
|
|
109319
109387
|
import * as fs124 from "node:fs";
|
|
109320
109388
|
import * as path195 from "node:path";
|
|
@@ -109447,7 +109515,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
|
|
|
109447
109515
|
return null;
|
|
109448
109516
|
}
|
|
109449
109517
|
}
|
|
109450
|
-
var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL,
|
|
109518
|
+
var DOC_DRIFT_REPORT_PREFIX = "doc-drift-phase-", MAX_TRACEABILITY_BYTES, DESIGN_DOC_FILES, TRACEABILITY_REL, _internals119;
|
|
109451
109519
|
var init_design_doc_drift = __esm(() => {
|
|
109452
109520
|
init_event_bus();
|
|
109453
109521
|
init_effective_spec();
|
|
@@ -109462,7 +109530,7 @@ var init_design_doc_drift = __esm(() => {
|
|
|
109462
109530
|
"idiom-notes": path195.join("reference", "idiom-notes.md")
|
|
109463
109531
|
};
|
|
109464
109532
|
TRACEABILITY_REL = path195.join("reference", "traceability.json");
|
|
109465
|
-
|
|
109533
|
+
_internals119 = {
|
|
109466
109534
|
mtimeMsOrNull,
|
|
109467
109535
|
resolveAnchorWithin,
|
|
109468
109536
|
DESIGN_DOC_FILES
|
|
@@ -109473,7 +109541,7 @@ var init_design_doc_drift = __esm(() => {
|
|
|
109473
109541
|
var exports_project_context = {};
|
|
109474
109542
|
__export(exports_project_context, {
|
|
109475
109543
|
buildProjectContext: () => buildProjectContext,
|
|
109476
|
-
_internals: () =>
|
|
109544
|
+
_internals: () => _internals137,
|
|
109477
109545
|
LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
|
|
109478
109546
|
});
|
|
109479
109547
|
import * as fs148 from "node:fs";
|
|
@@ -109557,7 +109625,7 @@ function selectLintCommand(backend, directory) {
|
|
|
109557
109625
|
return null;
|
|
109558
109626
|
}
|
|
109559
109627
|
async function buildProjectContext(directory) {
|
|
109560
|
-
const backend = await
|
|
109628
|
+
const backend = await _internals137.pickBackend(directory);
|
|
109561
109629
|
if (!backend)
|
|
109562
109630
|
return null;
|
|
109563
109631
|
const ctx = emptyProjectContext();
|
|
@@ -109596,17 +109664,17 @@ async function buildProjectContext(directory) {
|
|
|
109596
109664
|
if (backend.prompts.reviewerChecklist.length > 0) {
|
|
109597
109665
|
ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
|
|
109598
109666
|
}
|
|
109599
|
-
const profiles =
|
|
109667
|
+
const profiles = _internals137.pickedProfiles(directory);
|
|
109600
109668
|
if (profiles.length > 1) {
|
|
109601
109669
|
ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
|
|
109602
109670
|
}
|
|
109603
109671
|
return ctx;
|
|
109604
109672
|
}
|
|
109605
|
-
var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300,
|
|
109673
|
+
var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals137;
|
|
109606
109674
|
var init_project_context = __esm(() => {
|
|
109607
109675
|
init_dispatch();
|
|
109608
109676
|
init_framework_detector();
|
|
109609
|
-
|
|
109677
|
+
_internals137 = {
|
|
109610
109678
|
pickBackend,
|
|
109611
109679
|
pickedProfiles
|
|
109612
109680
|
};
|
|
@@ -110030,11 +110098,11 @@ async function ghExecAsync(args2, cwd) {
|
|
|
110030
110098
|
});
|
|
110031
110099
|
});
|
|
110032
110100
|
}
|
|
110033
|
-
var
|
|
110101
|
+
var _internals73 = { ghExec, ghExecAsync, spawnSyncWithTransientRetry };
|
|
110034
110102
|
async function getPRStatus(prNumber, repoFullName, cwd) {
|
|
110035
110103
|
let stdout;
|
|
110036
110104
|
try {
|
|
110037
|
-
stdout = await
|
|
110105
|
+
stdout = await _internals73.ghExecAsync([
|
|
110038
110106
|
"pr",
|
|
110039
110107
|
"view",
|
|
110040
110108
|
String(prNumber),
|
|
@@ -110055,13 +110123,13 @@ async function getPRComments(prNumber, repoFullName, cwd, since) {
|
|
|
110055
110123
|
let issueComments;
|
|
110056
110124
|
let reviewComments;
|
|
110057
110125
|
try {
|
|
110058
|
-
const issueRaw = await
|
|
110126
|
+
const issueRaw = await _internals73.ghExecAsync(["api", issueCommentsPath], cwd);
|
|
110059
110127
|
issueComments = JSON.parse(issueRaw);
|
|
110060
110128
|
} catch (err) {
|
|
110061
110129
|
throw new Error(`Failed to fetch issue comments for ${repoFullName}#${prNumber}: ${err instanceof Error ? err.message : String(err)}`);
|
|
110062
110130
|
}
|
|
110063
110131
|
try {
|
|
110064
|
-
const reviewRaw = await
|
|
110132
|
+
const reviewRaw = await _internals73.ghExecAsync(["api", reviewCommentsPath], cwd);
|
|
110065
110133
|
reviewComments = JSON.parse(reviewRaw);
|
|
110066
110134
|
} catch (err) {
|
|
110067
110135
|
throw new Error(`Failed to fetch review comments for ${repoFullName}#${prNumber}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -110088,7 +110156,7 @@ async function getPRComments(prNumber, repoFullName, cwd, since) {
|
|
|
110088
110156
|
async function getMergeState(prNumber, repoFullName, cwd) {
|
|
110089
110157
|
let stdout;
|
|
110090
110158
|
try {
|
|
110091
|
-
stdout = await
|
|
110159
|
+
stdout = await _internals73.ghExecAsync([
|
|
110092
110160
|
"pr",
|
|
110093
110161
|
"view",
|
|
110094
110162
|
String(prNumber),
|
|
@@ -110110,7 +110178,7 @@ async function getMergeState(prNumber, repoFullName, cwd) {
|
|
|
110110
110178
|
async function getPRReviewState(prNumber, repoFullName, cwd) {
|
|
110111
110179
|
let stdout;
|
|
110112
110180
|
try {
|
|
110113
|
-
stdout = await
|
|
110181
|
+
stdout = await _internals73.ghExecAsync([
|
|
110114
110182
|
"pr",
|
|
110115
110183
|
"view",
|
|
110116
110184
|
String(prNumber),
|
|
@@ -110218,7 +110286,7 @@ class PrMonitorWorker {
|
|
|
110218
110286
|
async executePollCycle() {
|
|
110219
110287
|
log("[PrMonitorWorker] Poll cycle starting");
|
|
110220
110288
|
try {
|
|
110221
|
-
const activeSubs = await
|
|
110289
|
+
const activeSubs = await _internals74.listActive(this.directory);
|
|
110222
110290
|
if (activeSubs.length === 0) {
|
|
110223
110291
|
log("[PrMonitorWorker] No active subscriptions");
|
|
110224
110292
|
await this.runSweep();
|
|
@@ -110290,10 +110358,10 @@ class PrMonitorWorker {
|
|
|
110290
110358
|
}
|
|
110291
110359
|
try {
|
|
110292
110360
|
const [statusResult, commentsResult, mergeResult, reviewResult] = await Promise.all([
|
|
110293
|
-
|
|
110294
|
-
|
|
110295
|
-
|
|
110296
|
-
|
|
110361
|
+
_internals74.getPRStatus(sub.prNumber, sub.repoFullName, this.directory),
|
|
110362
|
+
_internals74.getPRComments(sub.prNumber, sub.repoFullName, this.directory),
|
|
110363
|
+
_internals74.getMergeState(sub.prNumber, sub.repoFullName, this.directory),
|
|
110364
|
+
_internals74.getPRReviewState(sub.prNumber, sub.repoFullName, this.directory)
|
|
110297
110365
|
]);
|
|
110298
110366
|
if (isTimedOut?.()) {
|
|
110299
110367
|
log("[PrMonitorWorker] Skipping late result — poll already timed out", {
|
|
@@ -110310,7 +110378,7 @@ class PrMonitorWorker {
|
|
|
110310
110378
|
await this.applyChanges(sub, changes, isTimedOut);
|
|
110311
110379
|
if (!isTimedOut?.()) {
|
|
110312
110380
|
this.circuitBreakerMap.delete(correlationId);
|
|
110313
|
-
await
|
|
110381
|
+
await _internals74.updateSnapshot(this.directory, correlationId, {
|
|
110314
110382
|
errorCount: 0,
|
|
110315
110383
|
lastCheckedAt: Date.now()
|
|
110316
110384
|
});
|
|
@@ -110511,7 +110579,7 @@ class PrMonitorWorker {
|
|
|
110511
110579
|
this.mergedOrClosedKeys.add(`${sub.repoFullName}::${sub.prNumber}`);
|
|
110512
110580
|
}
|
|
110513
110581
|
if (changes.isMerged && this.config.auto_unsubscribe_on_merge) {
|
|
110514
|
-
await
|
|
110582
|
+
await _internals74.unsubscribe(this.directory, sub.correlationId);
|
|
110515
110583
|
this.reviewStateMap.delete(sub.correlationId);
|
|
110516
110584
|
this.circuitBreakerMap.delete(sub.correlationId);
|
|
110517
110585
|
log("[PrMonitorWorker] Auto-unsubscribed merged PR", {
|
|
@@ -110520,7 +110588,7 @@ class PrMonitorWorker {
|
|
|
110520
110588
|
return;
|
|
110521
110589
|
}
|
|
110522
110590
|
if (changes.isClosed && this.config.auto_unsubscribe_on_close) {
|
|
110523
|
-
await
|
|
110591
|
+
await _internals74.unsubscribe(this.directory, sub.correlationId);
|
|
110524
110592
|
this.reviewStateMap.delete(sub.correlationId);
|
|
110525
110593
|
this.circuitBreakerMap.delete(sub.correlationId);
|
|
110526
110594
|
log("[PrMonitorWorker] Auto-unsubscribed closed PR", {
|
|
@@ -110532,7 +110600,7 @@ class PrMonitorWorker {
|
|
|
110532
110600
|
log("[PrMonitorWorker] Skipping snapshot update — poll timed out before write", { correlationId: sub.correlationId });
|
|
110533
110601
|
return;
|
|
110534
110602
|
}
|
|
110535
|
-
await
|
|
110603
|
+
await _internals74.updateSnapshot(this.directory, sub.correlationId, changes.snapshotUpdates);
|
|
110536
110604
|
}
|
|
110537
110605
|
async handlePollError(sub, error93) {
|
|
110538
110606
|
const correlationId = sub.correlationId;
|
|
@@ -110542,7 +110610,7 @@ class PrMonitorWorker {
|
|
|
110542
110610
|
cooldownLevel: 0
|
|
110543
110611
|
};
|
|
110544
110612
|
cb.errorCount++;
|
|
110545
|
-
await
|
|
110613
|
+
await _internals74.updateSnapshot(this.directory, correlationId, {
|
|
110546
110614
|
errorCount: cb.errorCount,
|
|
110547
110615
|
lastCheckedAt: Date.now()
|
|
110548
110616
|
});
|
|
@@ -110581,7 +110649,7 @@ class PrMonitorWorker {
|
|
|
110581
110649
|
source: "pr-monitor-worker"
|
|
110582
110650
|
};
|
|
110583
110651
|
try {
|
|
110584
|
-
const bus =
|
|
110652
|
+
const bus = _internals74.getGlobalEventBus();
|
|
110585
110653
|
await bus.publish(type, payload, "pr-monitor-worker");
|
|
110586
110654
|
} catch (err) {
|
|
110587
110655
|
log("[PrMonitorWorker] Event publish failed", {
|
|
@@ -110599,7 +110667,7 @@ class PrMonitorWorker {
|
|
|
110599
110667
|
if (this.config.cleanup_ttl_days > 0) {
|
|
110600
110668
|
try {
|
|
110601
110669
|
const keysToPass = this.mergedOrClosedKeys.size > 0 ? this.mergedOrClosedKeys : undefined;
|
|
110602
|
-
await
|
|
110670
|
+
await _internals74.sweepStale(this.directory, this.config.cleanup_ttl_days, keysToPass);
|
|
110603
110671
|
} catch (err) {
|
|
110604
110672
|
log("[PrMonitorWorker] Sweep failed", {
|
|
110605
110673
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -110623,7 +110691,7 @@ class PrMonitorWorker {
|
|
|
110623
110691
|
}
|
|
110624
110692
|
}
|
|
110625
110693
|
}
|
|
110626
|
-
var
|
|
110694
|
+
var _internals74 = {
|
|
110627
110695
|
getPRStatus,
|
|
110628
110696
|
getPRComments,
|
|
110629
110697
|
getMergeState,
|
|
@@ -111094,7 +111162,7 @@ import * as path121 from "node:path";
|
|
|
111094
111162
|
import * as crypto9 from "node:crypto";
|
|
111095
111163
|
import * as fs65 from "node:fs";
|
|
111096
111164
|
import * as path120 from "node:path";
|
|
111097
|
-
var
|
|
111165
|
+
var _internals75 = {
|
|
111098
111166
|
readFileSync: fs65.readFileSync,
|
|
111099
111167
|
writeFileSync: fs65.writeFileSync,
|
|
111100
111168
|
mkdirSync: fs65.mkdirSync,
|
|
@@ -111104,7 +111172,7 @@ var _internals74 = {
|
|
|
111104
111172
|
createHash: crypto9.createHash.bind(crypto9)
|
|
111105
111173
|
};
|
|
111106
111174
|
function computeContentHash(content) {
|
|
111107
|
-
return
|
|
111175
|
+
return _internals75.createHash("sha256").update(content, "utf-8").digest("hex");
|
|
111108
111176
|
}
|
|
111109
111177
|
function createEmptyContextMap() {
|
|
111110
111178
|
return {
|
|
@@ -111119,10 +111187,10 @@ function createEmptyContextMap() {
|
|
|
111119
111187
|
function loadContextMap(directory) {
|
|
111120
111188
|
const filePath = path120.join(directory, ".swarm", "context-map.json");
|
|
111121
111189
|
try {
|
|
111122
|
-
if (!
|
|
111190
|
+
if (!_internals75.existsSync(filePath)) {
|
|
111123
111191
|
return null;
|
|
111124
111192
|
}
|
|
111125
|
-
const raw =
|
|
111193
|
+
const raw = _internals75.readFileSync(filePath, "utf-8");
|
|
111126
111194
|
const parsed = JSON.parse(raw);
|
|
111127
111195
|
if (typeof parsed !== "object" || parsed === null || parsed.schema_version !== 1) {
|
|
111128
111196
|
return null;
|
|
@@ -111136,14 +111204,14 @@ function saveContextMap(map3, directory) {
|
|
|
111136
111204
|
const swarmDir = path120.join(directory, ".swarm");
|
|
111137
111205
|
const tmpPath = path120.join(swarmDir, "context-map.tmp");
|
|
111138
111206
|
const finalPath = path120.join(swarmDir, "context-map.json");
|
|
111139
|
-
|
|
111207
|
+
_internals75.mkdirSync(swarmDir, { recursive: true });
|
|
111140
111208
|
const updated = {
|
|
111141
111209
|
...map3,
|
|
111142
111210
|
generated_at: new Date().toISOString()
|
|
111143
111211
|
};
|
|
111144
111212
|
const json3 = JSON.stringify(updated, null, 2);
|
|
111145
|
-
|
|
111146
|
-
|
|
111213
|
+
_internals75.writeFileSync(tmpPath, json3, "utf-8");
|
|
111214
|
+
_internals75.renameSync(tmpPath, finalPath);
|
|
111147
111215
|
}
|
|
111148
111216
|
function appendTaskHistory(map3, summary) {
|
|
111149
111217
|
return {
|
|
@@ -111309,10 +111377,10 @@ function deriveFinalStatus(params) {
|
|
|
111309
111377
|
}
|
|
111310
111378
|
function readFileContent(absolutePath) {
|
|
111311
111379
|
try {
|
|
111312
|
-
if (!
|
|
111380
|
+
if (!_internals76.existsSync(absolutePath)) {
|
|
111313
111381
|
return null;
|
|
111314
111382
|
}
|
|
111315
|
-
return
|
|
111383
|
+
return _internals76.readFileSync(absolutePath, "utf-8");
|
|
111316
111384
|
} catch {
|
|
111317
111385
|
return null;
|
|
111318
111386
|
}
|
|
@@ -111322,9 +111390,9 @@ function refreshFileEntry(relativePath, absolutePath, existingEntry) {
|
|
|
111322
111390
|
if (content === null) {
|
|
111323
111391
|
return null;
|
|
111324
111392
|
}
|
|
111325
|
-
return
|
|
111393
|
+
return _internals76.extractFileSummary(relativePath, content, absolutePath, existingEntry);
|
|
111326
111394
|
}
|
|
111327
|
-
var
|
|
111395
|
+
var _internals76 = {
|
|
111328
111396
|
loadContextMap,
|
|
111329
111397
|
saveContextMap,
|
|
111330
111398
|
createEmptyContextMap,
|
|
@@ -111343,10 +111411,10 @@ function extractEvidenceFindings(taskId, directory) {
|
|
|
111343
111411
|
};
|
|
111344
111412
|
try {
|
|
111345
111413
|
const evidenceDir = path122.join(directory, ".swarm", "evidence", taskId);
|
|
111346
|
-
if (!
|
|
111414
|
+
if (!_internals76.existsSync(evidenceDir)) {
|
|
111347
111415
|
return result;
|
|
111348
111416
|
}
|
|
111349
|
-
const evidenceFiles =
|
|
111417
|
+
const evidenceFiles = _internals76.readdirSync(evidenceDir);
|
|
111350
111418
|
const targetFiles = [
|
|
111351
111419
|
"evidence.json",
|
|
111352
111420
|
"reviewer.json",
|
|
@@ -111438,20 +111506,20 @@ function extractEvidenceFindings(taskId, directory) {
|
|
|
111438
111506
|
}
|
|
111439
111507
|
function updateContextMapAfterAgent(params) {
|
|
111440
111508
|
try {
|
|
111441
|
-
let map3 =
|
|
111509
|
+
let map3 = _internals76.loadContextMap(params.directory);
|
|
111442
111510
|
if (map3 === null) {
|
|
111443
|
-
map3 =
|
|
111511
|
+
map3 = _internals76.createEmptyContextMap();
|
|
111444
111512
|
}
|
|
111445
111513
|
const root = path122.resolve(params.directory);
|
|
111446
111514
|
const updatedFiles = {
|
|
111447
111515
|
...map3.files
|
|
111448
111516
|
};
|
|
111449
111517
|
const validFiles = [];
|
|
111450
|
-
const realRoot =
|
|
111518
|
+
const realRoot = _internals76.realpathSync(root);
|
|
111451
111519
|
for (const filePath of params.files_touched) {
|
|
111452
111520
|
try {
|
|
111453
111521
|
const resolved = path122.resolve(root, filePath);
|
|
111454
|
-
const realResolved =
|
|
111522
|
+
const realResolved = _internals76.realpathSync(resolved);
|
|
111455
111523
|
const relative20 = path122.relative(realRoot, realResolved);
|
|
111456
111524
|
if (relative20.startsWith("..") || path122.isAbsolute(relative20)) {
|
|
111457
111525
|
continue;
|
|
@@ -111489,7 +111557,7 @@ function updateContextMapAfterAgent(params) {
|
|
|
111489
111557
|
reviewer_findings: reviewerFindings.length > 0 ? reviewerFindings : undefined,
|
|
111490
111558
|
final_status: mergedRejectionReasons.length > 0 ? "rejected" : deriveFinalStatus(params)
|
|
111491
111559
|
};
|
|
111492
|
-
map3 =
|
|
111560
|
+
map3 = _internals76.appendTaskHistory(map3, taskSummary);
|
|
111493
111561
|
if (params.decisions) {
|
|
111494
111562
|
for (const entry of params.decisions) {
|
|
111495
111563
|
const decision = {
|
|
@@ -111499,17 +111567,17 @@ function updateContextMapAfterAgent(params) {
|
|
|
111499
111567
|
timestamp: new Date().toISOString(),
|
|
111500
111568
|
task_id: params.task_id
|
|
111501
111569
|
};
|
|
111502
|
-
map3 =
|
|
111570
|
+
map3 = _internals76.appendDecision(map3, decision);
|
|
111503
111571
|
}
|
|
111504
111572
|
}
|
|
111505
|
-
|
|
111573
|
+
_internals76.saveContextMap(map3, params.directory);
|
|
111506
111574
|
return map3;
|
|
111507
111575
|
} catch {
|
|
111508
111576
|
try {
|
|
111509
|
-
const fallback =
|
|
111577
|
+
const fallback = _internals76.loadContextMap(params.directory) ?? _internals76.createEmptyContextMap();
|
|
111510
111578
|
return fallback;
|
|
111511
111579
|
} catch {
|
|
111512
|
-
return
|
|
111580
|
+
return _internals76.createEmptyContextMap();
|
|
111513
111581
|
}
|
|
111514
111582
|
}
|
|
111515
111583
|
}
|
|
@@ -112840,7 +112908,7 @@ import * as path124 from "node:path";
|
|
|
112840
112908
|
function estimateTokens3(content) {
|
|
112841
112909
|
return Math.max(1, estimateTokens2(content));
|
|
112842
112910
|
}
|
|
112843
|
-
var
|
|
112911
|
+
var _internals77 = {
|
|
112844
112912
|
loadContextMap,
|
|
112845
112913
|
createEmptyContextMap,
|
|
112846
112914
|
computeContentHash,
|
|
@@ -112908,14 +112976,14 @@ function buildReadPolicy(files, map3, directory, invalidateOnHashChange = true,
|
|
|
112908
112976
|
const absolutePath = path124.join(directory, filePath);
|
|
112909
112977
|
let currentContent;
|
|
112910
112978
|
try {
|
|
112911
|
-
if (
|
|
112912
|
-
currentContent =
|
|
112979
|
+
if (_internals77.existsSync(absolutePath)) {
|
|
112980
|
+
currentContent = _internals77.readFileSync(absolutePath, "utf-8");
|
|
112913
112981
|
}
|
|
112914
112982
|
} catch {}
|
|
112915
112983
|
if (contentCache !== undefined) {
|
|
112916
112984
|
contentCache.set(filePath, currentContent);
|
|
112917
112985
|
}
|
|
112918
|
-
if (currentContent === undefined || invalidateOnHashChange &&
|
|
112986
|
+
if (currentContent === undefined || invalidateOnHashChange && _internals77.isFileStale(entry, currentContent)) {
|
|
112919
112987
|
policy.push({
|
|
112920
112988
|
file_path: filePath,
|
|
112921
112989
|
trust_summary: false,
|
|
@@ -112990,7 +113058,7 @@ function pruneCapsuleContent(sections, tokenEstimate, maxTokens, estimateFn) {
|
|
|
112990
113058
|
function buildCapsule(params) {
|
|
112991
113059
|
const { task_id, agent_role, delegation_reason, directory } = params;
|
|
112992
113060
|
const generatedAt = new Date().toISOString();
|
|
112993
|
-
const map3 =
|
|
113061
|
+
const map3 = _internals77.loadContextMap(directory) ?? _internals77.createEmptyContextMap();
|
|
112994
113062
|
let profile = DEFAULT_ROLE_PROFILES[agent_role];
|
|
112995
113063
|
if (params.mode === "conservative") {
|
|
112996
113064
|
profile = { ...profile, max_files: Math.ceil(profile.max_files * 1.5) };
|
|
@@ -113019,7 +113087,7 @@ function buildCapsule(params) {
|
|
|
113019
113087
|
const shouldCheckStaleness = params.invalidate_on_hash_change !== false;
|
|
113020
113088
|
if (shouldCheckStaleness) {
|
|
113021
113089
|
const currentContent = contentCache.get(filePath);
|
|
113022
|
-
if (currentContent === undefined ||
|
|
113090
|
+
if (currentContent === undefined || _internals77.isFileStale(entry, currentContent)) {
|
|
113023
113091
|
staleEntries++;
|
|
113024
113092
|
fileSummaries.push(`- ${filePath} — ${entry.purpose || "No summary available"} (stale)`);
|
|
113025
113093
|
} else {
|
|
@@ -113061,11 +113129,11 @@ function buildCapsule(params) {
|
|
|
113061
113129
|
}
|
|
113062
113130
|
const content = sections.join(`
|
|
113063
113131
|
`);
|
|
113064
|
-
let tokenEstimate =
|
|
113132
|
+
let tokenEstimate = _internals77.estimateTokens(content);
|
|
113065
113133
|
const maxCapsuleTokens = params.max_capsule_tokens ?? 2000;
|
|
113066
113134
|
let prunedContent = content;
|
|
113067
113135
|
if (tokenEstimate > maxCapsuleTokens) {
|
|
113068
|
-
const { prunedSections, prunedTokenEstimate } = pruneCapsuleContent(sections, tokenEstimate, maxCapsuleTokens,
|
|
113136
|
+
const { prunedSections, prunedTokenEstimate } = pruneCapsuleContent(sections, tokenEstimate, maxCapsuleTokens, _internals77.estimateTokens);
|
|
113069
113137
|
prunedContent = prunedSections.join(`
|
|
113070
113138
|
`);
|
|
113071
113139
|
tokenEstimate = prunedTokenEstimate;
|
|
@@ -113101,7 +113169,7 @@ function buildCapsule(params) {
|
|
|
113101
113169
|
// src/context-map/capsule-persistence.ts
|
|
113102
113170
|
import * as fs71 from "node:fs";
|
|
113103
113171
|
import * as path125 from "node:path";
|
|
113104
|
-
var
|
|
113172
|
+
var _internals78 = {
|
|
113105
113173
|
writeFileSync: fs71.writeFileSync,
|
|
113106
113174
|
readFileSync: fs71.readFileSync,
|
|
113107
113175
|
existsSync: fs71.existsSync,
|
|
@@ -113137,10 +113205,10 @@ function saveCapsule(capsule, directory) {
|
|
|
113137
113205
|
const capsulesDir = path125.join(directory, ".swarm", "capsules");
|
|
113138
113206
|
const finalPath = capsulePath(capsule.task_id, directory);
|
|
113139
113207
|
const tmpPath = path125.join(capsulesDir, `capsule-${capsule.task_id}.tmp`);
|
|
113140
|
-
|
|
113208
|
+
_internals78.mkdirSync(capsulesDir, { recursive: true });
|
|
113141
113209
|
const json3 = JSON.stringify(capsule, null, 2);
|
|
113142
|
-
|
|
113143
|
-
|
|
113210
|
+
_internals78.writeFileSync(tmpPath, json3, "utf-8");
|
|
113211
|
+
_internals78.renameSync(tmpPath, finalPath);
|
|
113144
113212
|
return {
|
|
113145
113213
|
success: true,
|
|
113146
113214
|
capsule_path: finalPath,
|
|
@@ -113168,7 +113236,7 @@ function saveCapsule(capsule, directory) {
|
|
|
113168
113236
|
// src/context-map/telemetry.ts
|
|
113169
113237
|
import * as fs72 from "node:fs";
|
|
113170
113238
|
import * as path126 from "node:path";
|
|
113171
|
-
var
|
|
113239
|
+
var _internals79 = {
|
|
113172
113240
|
appendFileSync: fs72.appendFileSync,
|
|
113173
113241
|
readFileSync: fs72.readFileSync,
|
|
113174
113242
|
existsSync: fs72.existsSync,
|
|
@@ -113181,10 +113249,10 @@ function recordTelemetry(entry, directory) {
|
|
|
113181
113249
|
const filePath = telemetryFilePath(directory);
|
|
113182
113250
|
const swarmDir = path126.join(directory, ".swarm");
|
|
113183
113251
|
try {
|
|
113184
|
-
|
|
113252
|
+
_internals79.mkdirSync(swarmDir, { recursive: true });
|
|
113185
113253
|
const line = `${JSON.stringify(entry)}
|
|
113186
113254
|
`;
|
|
113187
|
-
|
|
113255
|
+
_internals79.appendFileSync(filePath, line, "utf-8");
|
|
113188
113256
|
return true;
|
|
113189
113257
|
} catch {
|
|
113190
113258
|
return false;
|
|
@@ -113226,7 +113294,7 @@ function extractTaskGoal(taskId, directory) {
|
|
|
113226
113294
|
return "";
|
|
113227
113295
|
}
|
|
113228
113296
|
}
|
|
113229
|
-
var
|
|
113297
|
+
var _internals80 = {
|
|
113230
113298
|
buildCapsule,
|
|
113231
113299
|
recordTelemetry,
|
|
113232
113300
|
saveCapsule,
|
|
@@ -113294,21 +113362,21 @@ async function injectCapsule(input, output, config3, directory) {
|
|
|
113294
113362
|
const sessionID = input.sessionID;
|
|
113295
113363
|
if (!sessionID)
|
|
113296
113364
|
return;
|
|
113297
|
-
const agentName =
|
|
113365
|
+
const agentName = _internals80.getActiveAgent(sessionID);
|
|
113298
113366
|
if (!agentName)
|
|
113299
113367
|
return;
|
|
113300
113368
|
const role = extractCapsuleRole(agentName);
|
|
113301
113369
|
if (!role)
|
|
113302
113370
|
return;
|
|
113303
|
-
const taskId =
|
|
113371
|
+
const taskId = _internals80.getCurrentTaskId(sessionID);
|
|
113304
113372
|
const effectiveTaskId = taskId ?? "unknown";
|
|
113305
|
-
const files =
|
|
113373
|
+
const files = _internals80.readScopeFile(effectiveTaskId, directory);
|
|
113306
113374
|
if (files.length === 0)
|
|
113307
113375
|
return;
|
|
113308
113376
|
const maxTokens = config3.context_map?.max_capsule_tokens;
|
|
113309
|
-
const delegationReason =
|
|
113310
|
-
const taskGoal =
|
|
113311
|
-
const { capsule, metadata } =
|
|
113377
|
+
const delegationReason = _internals80.resolveCapsuleDelegationReason(_internals80.getSession(sessionID), role, effectiveTaskId);
|
|
113378
|
+
const taskGoal = _internals80.extractTaskGoal(effectiveTaskId, directory);
|
|
113379
|
+
const { capsule, metadata } = _internals80.buildCapsule({
|
|
113312
113380
|
task_id: effectiveTaskId,
|
|
113313
113381
|
agent_role: role,
|
|
113314
113382
|
delegation_reason: delegationReason,
|
|
@@ -113324,7 +113392,7 @@ async function injectCapsule(input, output, config3, directory) {
|
|
|
113324
113392
|
return;
|
|
113325
113393
|
output.system.push(capsule.content);
|
|
113326
113394
|
try {
|
|
113327
|
-
|
|
113395
|
+
_internals80.saveCapsule(capsule, directory);
|
|
113328
113396
|
} catch {}
|
|
113329
113397
|
const telemetryEntry = {
|
|
113330
113398
|
timestamp: new Date().toISOString(),
|
|
@@ -113340,7 +113408,7 @@ async function injectCapsule(input, output, config3, directory) {
|
|
|
113340
113408
|
success: metadata.success
|
|
113341
113409
|
};
|
|
113342
113410
|
try {
|
|
113343
|
-
|
|
113411
|
+
_internals80.recordTelemetry(telemetryEntry, directory);
|
|
113344
113412
|
} catch {}
|
|
113345
113413
|
}
|
|
113346
113414
|
|
|
@@ -116432,7 +116500,7 @@ function validateGraphEdge(edge) {
|
|
|
116432
116500
|
}
|
|
116433
116501
|
|
|
116434
116502
|
// src/tools/repo-graph/builder.ts
|
|
116435
|
-
var
|
|
116503
|
+
var _internals82 = {
|
|
116436
116504
|
safeRealpathSync,
|
|
116437
116505
|
extractTSSymbols,
|
|
116438
116506
|
extractPythonSymbols,
|
|
@@ -116521,12 +116589,12 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
|
|
|
116521
116589
|
if (specifier.startsWith(".")) {
|
|
116522
116590
|
const sourceDir = path134.dirname(sourceFile);
|
|
116523
116591
|
let resolved = path134.resolve(sourceDir, specifier);
|
|
116524
|
-
const initialRealResolved =
|
|
116592
|
+
const initialRealResolved = _internals82.safeRealpathSync(resolved, resolved);
|
|
116525
116593
|
if (initialRealResolved === null) {
|
|
116526
116594
|
return null;
|
|
116527
116595
|
}
|
|
116528
116596
|
let realResolved = initialRealResolved;
|
|
116529
|
-
const realRoot =
|
|
116597
|
+
const realRoot = _internals82.safeRealpathSync(workspaceRoot, path134.normalize(workspaceRoot));
|
|
116530
116598
|
if (realRoot === null) {
|
|
116531
116599
|
return null;
|
|
116532
116600
|
}
|
|
@@ -116550,7 +116618,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
|
|
|
116550
116618
|
}
|
|
116551
116619
|
}
|
|
116552
116620
|
if (found) {
|
|
116553
|
-
const foundRealPath =
|
|
116621
|
+
const foundRealPath = _internals82.safeRealpathSync(found, found);
|
|
116554
116622
|
if (foundRealPath === null) {
|
|
116555
116623
|
return null;
|
|
116556
116624
|
}
|
|
@@ -116931,7 +116999,7 @@ async function scanFileAsync(filePath, absoluteRoot, maxFileSize) {
|
|
|
116931
116999
|
return { node: null, edges: [], symbolEdges: [] };
|
|
116932
117000
|
}
|
|
116933
117001
|
const grammarId = getLanguage(filePath);
|
|
116934
|
-
const facts = await
|
|
117002
|
+
const facts = await _internals82.extractFileSymbols(grammarId, content);
|
|
116935
117003
|
if (facts === null) {
|
|
116936
117004
|
const moduleName2 = toModuleName(filePath, absoluteRoot);
|
|
116937
117005
|
return {
|
|
@@ -116942,7 +117010,7 @@ async function scanFileAsync(filePath, absoluteRoot, maxFileSize) {
|
|
|
116942
117010
|
imports: [],
|
|
116943
117011
|
language: grammarId,
|
|
116944
117012
|
mtime: fileStats.mtime.toISOString(),
|
|
116945
|
-
ontology:
|
|
117013
|
+
ontology: _internals82.extractFileOntology({
|
|
116946
117014
|
moduleName: moduleName2,
|
|
116947
117015
|
filePath,
|
|
116948
117016
|
content,
|
|
@@ -116975,7 +117043,7 @@ async function scanFileAsync(filePath, absoluteRoot, maxFileSize) {
|
|
|
116975
117043
|
imports,
|
|
116976
117044
|
language,
|
|
116977
117045
|
mtime: fileStats.mtime.toISOString(),
|
|
116978
|
-
ontology:
|
|
117046
|
+
ontology: _internals82.extractFileOntology({
|
|
116979
117047
|
moduleName,
|
|
116980
117048
|
filePath,
|
|
116981
117049
|
content,
|
|
@@ -117848,7 +117916,7 @@ import * as fsPromises6 from "node:fs/promises";
|
|
|
117848
117916
|
import * as path137 from "node:path";
|
|
117849
117917
|
var WINDOWS_RENAME_MAX_RETRIES2 = 5;
|
|
117850
117918
|
var WINDOWS_RENAME_RETRY_DELAY_MS2 = 100;
|
|
117851
|
-
var
|
|
117919
|
+
var _internals83 = {
|
|
117852
117920
|
safeRealpathSync,
|
|
117853
117921
|
fsRename: fsPromises6.rename.bind(fsPromises6),
|
|
117854
117922
|
retryDelayMs: WINDOWS_RENAME_RETRY_DELAY_MS2
|
|
@@ -118003,12 +118071,12 @@ async function saveGraph(workspace, graph, options) {
|
|
|
118003
118071
|
throw new Error("Graph must have edges array");
|
|
118004
118072
|
}
|
|
118005
118073
|
const normalizedWorkspace = path137.normalize(workspace);
|
|
118006
|
-
const realWorkspace =
|
|
118074
|
+
const realWorkspace = _internals83.safeRealpathSync(workspace, normalizedWorkspace);
|
|
118007
118075
|
if (realWorkspace === null) {
|
|
118008
118076
|
throw new Error(`Workspace realpath security check failed (non-ENOENT): ${workspace}`);
|
|
118009
118077
|
}
|
|
118010
118078
|
const normalizedGraphRoot = path137.normalize(graph.workspaceRoot);
|
|
118011
|
-
const realGraphRoot =
|
|
118079
|
+
const realGraphRoot = _internals83.safeRealpathSync(graph.workspaceRoot, normalizedGraphRoot);
|
|
118012
118080
|
if (realGraphRoot === null) {
|
|
118013
118081
|
throw new Error(`Graph workspaceRoot realpath security check failed (non-ENOENT): ${graph.workspaceRoot}`);
|
|
118014
118082
|
}
|
|
@@ -118046,7 +118114,7 @@ async function saveGraph(workspace, graph, options) {
|
|
|
118046
118114
|
} else {
|
|
118047
118115
|
for (let attempt = 0;attempt < WINDOWS_RENAME_MAX_RETRIES2; attempt++) {
|
|
118048
118116
|
try {
|
|
118049
|
-
await
|
|
118117
|
+
await _internals83.fsRename(tempPath, graphPath);
|
|
118050
118118
|
lastError = null;
|
|
118051
118119
|
break;
|
|
118052
118120
|
} catch (error93) {
|
|
@@ -118056,7 +118124,7 @@ async function saveGraph(workspace, graph, options) {
|
|
|
118056
118124
|
break;
|
|
118057
118125
|
}
|
|
118058
118126
|
if (attempt < WINDOWS_RENAME_MAX_RETRIES2 - 1) {
|
|
118059
|
-
await new Promise((resolve49) => setTimeout(resolve49,
|
|
118127
|
+
await new Promise((resolve49) => setTimeout(resolve49, _internals83.retryDelayMs));
|
|
118060
118128
|
}
|
|
118061
118129
|
}
|
|
118062
118130
|
}
|
|
@@ -121758,7 +121826,7 @@ function resolveDefaultReviewerAgent(generatedAgentNames) {
|
|
|
121758
121826
|
}
|
|
121759
121827
|
async function compileReviewPackage(directory, phase, sessionID, requireDiffSummary) {
|
|
121760
121828
|
const lanes = await listLaneEvidence(directory, phase);
|
|
121761
|
-
const persisted =
|
|
121829
|
+
const persisted = _internals86.readPersisted?.(directory) ?? null;
|
|
121762
121830
|
if (persisted) {
|
|
121763
121831
|
let matchingRunState = null;
|
|
121764
121832
|
for (const sessionState of Object.values(persisted.sessions)) {
|
|
@@ -121968,7 +122036,7 @@ Be specific and evidence-based. Do not approve a phase with unresolved degraded
|
|
|
121968
122036
|
client.session.delete({ path: { id: sessionId } }).catch(() => {});
|
|
121969
122037
|
}
|
|
121970
122038
|
}
|
|
121971
|
-
var
|
|
122039
|
+
var _internals86 = {
|
|
121972
122040
|
compileReviewPackage,
|
|
121973
122041
|
parseReviewerVerdict,
|
|
121974
122042
|
writeReviewerEvidence,
|
|
@@ -121985,28 +122053,28 @@ async function dispatchPhaseReviewer(directory, phase, sessionID, config3) {
|
|
|
121985
122053
|
};
|
|
121986
122054
|
const generatedAgentNames = swarmState.generatedAgentNames;
|
|
121987
122055
|
const agentName = mergedConfig.reviewerAgent || resolveDefaultReviewerAgent(generatedAgentNames);
|
|
121988
|
-
const pkg = await
|
|
122056
|
+
const pkg = await _internals86.compileReviewPackage(directory, phase, sessionID, mergedConfig.requireDiffSummary);
|
|
121989
122057
|
let responseText;
|
|
121990
122058
|
try {
|
|
121991
|
-
responseText = await
|
|
122059
|
+
responseText = await _internals86.dispatchReviewerAgent(directory, pkg, agentName, mergedConfig.timeoutMs, sessionID);
|
|
121992
122060
|
} catch (error93) {
|
|
121993
|
-
const evidencePath2 = await
|
|
122061
|
+
const evidencePath2 = await _internals86.writeReviewerEvidence(directory, phase, "REJECTED", error93 instanceof Error ? error93.message : String(error93));
|
|
121994
122062
|
return {
|
|
121995
122063
|
verdict: "REJECTED",
|
|
121996
122064
|
reason: `Reviewer dispatch failed: ${error93 instanceof Error ? error93.message : String(error93)}`,
|
|
121997
122065
|
evidencePath: evidencePath2
|
|
121998
122066
|
};
|
|
121999
122067
|
}
|
|
122000
|
-
const parsed =
|
|
122068
|
+
const parsed = _internals86.parseReviewerVerdict(responseText);
|
|
122001
122069
|
if (!parsed) {
|
|
122002
|
-
const evidencePath2 = await
|
|
122070
|
+
const evidencePath2 = await _internals86.writeReviewerEvidence(directory, phase, "REJECTED", "Reviewer response could not be parsed");
|
|
122003
122071
|
return {
|
|
122004
122072
|
verdict: "REJECTED",
|
|
122005
122073
|
reason: "Reviewer response could not be parsed",
|
|
122006
122074
|
evidencePath: evidencePath2
|
|
122007
122075
|
};
|
|
122008
122076
|
}
|
|
122009
|
-
const evidencePath = await
|
|
122077
|
+
const evidencePath = await _internals86.writeReviewerEvidence(directory, phase, parsed.verdict, parsed.reason);
|
|
122010
122078
|
return {
|
|
122011
122079
|
verdict: parsed.verdict,
|
|
122012
122080
|
reason: parsed.reason,
|
|
@@ -122190,7 +122258,7 @@ async function runAutoReview(input) {
|
|
|
122190
122258
|
phase
|
|
122191
122259
|
};
|
|
122192
122260
|
try {
|
|
122193
|
-
const diffResult = await
|
|
122261
|
+
const diffResult = await _internals87.computeExecutionDiff(directory, config3.max_diff_kb * 1024);
|
|
122194
122262
|
if (diffResult.status === "clean") {
|
|
122195
122263
|
writeAutoReviewEvent(directory, {
|
|
122196
122264
|
...base,
|
|
@@ -122212,7 +122280,7 @@ async function runAutoReview(input) {
|
|
|
122212
122280
|
const prompt = buildReviewPrompt(trigger, diff, taskId, phase);
|
|
122213
122281
|
let transcript;
|
|
122214
122282
|
try {
|
|
122215
|
-
transcript = await
|
|
122283
|
+
transcript = await _internals87.dispatchReviewer(directory, prompt, agentName, config3.timeout_ms, sessionID);
|
|
122216
122284
|
} catch (err) {
|
|
122217
122285
|
writeAutoReviewEvent(directory, {
|
|
122218
122286
|
...base,
|
|
@@ -122316,13 +122384,13 @@ function createAutoReviewHook(options) {
|
|
|
122316
122384
|
if (inFlightSessions.has(sessionID))
|
|
122317
122385
|
return;
|
|
122318
122386
|
const last = lastDispatchBySession.get(sessionID) ?? 0;
|
|
122319
|
-
if (
|
|
122387
|
+
if (_internals87.now() - last < COOLDOWN_MS)
|
|
122320
122388
|
return;
|
|
122321
122389
|
inFlightSessions.add(sessionID);
|
|
122322
122390
|
lastDispatchBySession.delete(sessionID);
|
|
122323
|
-
lastDispatchBySession.set(sessionID,
|
|
122391
|
+
lastDispatchBySession.set(sessionID, _internals87.now());
|
|
122324
122392
|
evictCooldownMap();
|
|
122325
|
-
|
|
122393
|
+
_internals87.runAutoReview({
|
|
122326
122394
|
directory,
|
|
122327
122395
|
sessionID,
|
|
122328
122396
|
trigger,
|
|
@@ -122342,7 +122410,7 @@ function createAutoReviewHook(options) {
|
|
|
122342
122410
|
}
|
|
122343
122411
|
};
|
|
122344
122412
|
}
|
|
122345
|
-
var
|
|
122413
|
+
var _internals87 = {
|
|
122346
122414
|
computeExecutionDiff,
|
|
122347
122415
|
dispatchReviewer,
|
|
122348
122416
|
runAutoReview,
|
|
@@ -122783,10 +122851,10 @@ async function getRunMemorySummary(directory) {
|
|
|
122783
122851
|
if (entries.length === 0) {
|
|
122784
122852
|
return null;
|
|
122785
122853
|
}
|
|
122786
|
-
const groups =
|
|
122854
|
+
const groups = _internals88.groupByTaskId(entries);
|
|
122787
122855
|
const summaries = [];
|
|
122788
122856
|
for (const [taskId, taskEntries] of groups) {
|
|
122789
|
-
const summary =
|
|
122857
|
+
const summary = _internals88.summarizeTask(taskId, taskEntries);
|
|
122790
122858
|
if (summary) {
|
|
122791
122859
|
summaries.push(summary);
|
|
122792
122860
|
}
|
|
@@ -122819,7 +122887,7 @@ Use this data to avoid repeating known failure patterns.`;
|
|
|
122819
122887
|
}
|
|
122820
122888
|
return prefix + summaryText + suffix;
|
|
122821
122889
|
}
|
|
122822
|
-
var
|
|
122890
|
+
var _internals88 = {
|
|
122823
122891
|
generateTaskFingerprint,
|
|
122824
122892
|
recordOutcome,
|
|
122825
122893
|
getTaskHistory,
|
|
@@ -123008,7 +123076,7 @@ async function injectForDelegate(params) {
|
|
|
123008
123076
|
currentTool: firstTool,
|
|
123009
123077
|
mode: "delegation"
|
|
123010
123078
|
};
|
|
123011
|
-
const searchFn = params.searchFn ?? (
|
|
123079
|
+
const searchFn = params.searchFn ?? (_internals90.searchKnowledge === defaultSearchKnowledge ? searchKnowledge : _internals90.searchKnowledge);
|
|
123012
123080
|
try {
|
|
123013
123081
|
const search = await searchFn({
|
|
123014
123082
|
directory,
|
|
@@ -123032,7 +123100,7 @@ async function injectForDelegate(params) {
|
|
|
123032
123100
|
ranks[e.id] = idx + 1;
|
|
123033
123101
|
scores[e.id] = e.finalScore;
|
|
123034
123102
|
});
|
|
123035
|
-
await
|
|
123103
|
+
await _internals90.recordKnowledgeEvent(directory, {
|
|
123036
123104
|
type: "retrieved",
|
|
123037
123105
|
trace_id: search.trace_id,
|
|
123038
123106
|
session_id: sessionId ?? "unknown",
|
|
@@ -123239,7 +123307,7 @@ function createKnowledgeInjectorHook(directory, config3, modelLimitOverrides = {
|
|
|
123239
123307
|
projectName,
|
|
123240
123308
|
currentPhase: phaseDescription
|
|
123241
123309
|
};
|
|
123242
|
-
const searchFn =
|
|
123310
|
+
const searchFn = _internals90.searchKnowledge === defaultSearchKnowledge ? searchKnowledge : _internals90.searchKnowledge;
|
|
123243
123311
|
const search = await searchFn({
|
|
123244
123312
|
directory,
|
|
123245
123313
|
config: config3,
|
|
@@ -123355,7 +123423,7 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
|
|
|
123355
123423
|
ranks[id] = idx + 1;
|
|
123356
123424
|
scores[id] = scoreById.get(id) ?? 0;
|
|
123357
123425
|
});
|
|
123358
|
-
await
|
|
123426
|
+
await _internals90.recordKnowledgeEvent(directory, {
|
|
123359
123427
|
type: "retrieved",
|
|
123360
123428
|
trace_id: search.trace_id,
|
|
123361
123429
|
session_id: systemMsg?.info?.sessionID ?? "unknown",
|
|
@@ -123368,7 +123436,7 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
|
|
|
123368
123436
|
ranks,
|
|
123369
123437
|
scores
|
|
123370
123438
|
});
|
|
123371
|
-
|
|
123439
|
+
_internals90.recordKnowledgeShown(directory, cachedShownIds, {
|
|
123372
123440
|
phase: phaseLabel,
|
|
123373
123441
|
tool: retrievalCtx.currentTool,
|
|
123374
123442
|
action: retrievalCtx.currentAction,
|
|
@@ -123378,7 +123446,7 @@ ${freshPreamble}` : `<curator_briefing>${truncatedBriefing}</curator_briefing>`;
|
|
|
123378
123446
|
}
|
|
123379
123447
|
});
|
|
123380
123448
|
}
|
|
123381
|
-
var
|
|
123449
|
+
var _internals90 = {
|
|
123382
123450
|
searchKnowledge,
|
|
123383
123451
|
recordKnowledgeEvent,
|
|
123384
123452
|
recordKnowledgeShown
|
|
@@ -125377,7 +125445,7 @@ async function knowledgeApplicationGateBefore(directory, input, config3) {
|
|
|
125377
125445
|
if (config3.mode === "enforce") {
|
|
125378
125446
|
throw new Error("KNOWLEDGE_ENFORCE_GATE_DENY: missing sessionID on tool.execute.before; refusing to evaluate critical-directive ack state");
|
|
125379
125447
|
}
|
|
125380
|
-
|
|
125448
|
+
_internals91.writeWarnEvent(directory, {
|
|
125381
125449
|
timestamp: new Date().toISOString(),
|
|
125382
125450
|
event: "knowledge_application_gate_warn",
|
|
125383
125451
|
tool: toolName,
|
|
@@ -125460,7 +125528,7 @@ async function knowledgeApplicationTransformScan(directory, output, sessionID) {
|
|
|
125460
125528
|
}
|
|
125461
125529
|
}
|
|
125462
125530
|
}
|
|
125463
|
-
var
|
|
125531
|
+
var _internals91 = {
|
|
125464
125532
|
knowledgeApplicationGateBefore,
|
|
125465
125533
|
knowledgeApplicationTransformScan,
|
|
125466
125534
|
HIGH_RISK_TOOLS,
|
|
@@ -126694,7 +126762,7 @@ function timeoutKillSignal(platform) {
|
|
|
126694
126762
|
}
|
|
126695
126763
|
function killProcess(proc) {
|
|
126696
126764
|
try {
|
|
126697
|
-
proc?.kill(timeoutKillSignal(
|
|
126765
|
+
proc?.kill(timeoutKillSignal(_internals92.platform()));
|
|
126698
126766
|
} catch {}
|
|
126699
126767
|
}
|
|
126700
126768
|
async function runExternalTool(options) {
|
|
@@ -126714,7 +126782,7 @@ async function runExternalTool(options) {
|
|
|
126714
126782
|
let exitSettled = false;
|
|
126715
126783
|
let settledExitCode = null;
|
|
126716
126784
|
try {
|
|
126717
|
-
proc =
|
|
126785
|
+
proc = _internals92.bunSpawn([options.executable, ...options.args], {
|
|
126718
126786
|
cwd: options.cwd,
|
|
126719
126787
|
env: options.env,
|
|
126720
126788
|
stdin: "ignore",
|
|
@@ -126782,7 +126850,7 @@ async function runExternalTool(options) {
|
|
|
126782
126850
|
}
|
|
126783
126851
|
}
|
|
126784
126852
|
}
|
|
126785
|
-
var
|
|
126853
|
+
var _internals92 = {
|
|
126786
126854
|
bunSpawn,
|
|
126787
126855
|
platform: () => process.platform
|
|
126788
126856
|
};
|
|
@@ -126799,7 +126867,7 @@ var MAX_WORKFLOW_FILES = 500;
|
|
|
126799
126867
|
var MAX_WORKFLOW_DIRS = 200;
|
|
126800
126868
|
var MAX_WORKFLOW_DEPTH = 20;
|
|
126801
126869
|
function resolveActionlintBinary() {
|
|
126802
|
-
return
|
|
126870
|
+
return _internals93.resolveExecutableFromPath(["actionlint"]);
|
|
126803
126871
|
}
|
|
126804
126872
|
function normalizeRelativeWorkflowFile(file3, workspace) {
|
|
126805
126873
|
if (!file3 || containsControlChars(file3) || containsPathTraversal(file3)) {
|
|
@@ -126913,7 +126981,7 @@ var actionlint_scan = createSwarmTool({
|
|
|
126913
126981
|
const discovery = requestedFiles ? {
|
|
126914
126982
|
files: requestedFiles.map((f) => normalizeRelativeWorkflowFile(f, directory)).filter((f) => Boolean(f)),
|
|
126915
126983
|
truncated: false
|
|
126916
|
-
} :
|
|
126984
|
+
} : _internals93.discoverWorkflowFiles(directory);
|
|
126917
126985
|
let files = discovery.files;
|
|
126918
126986
|
if (requestedFiles && files.length !== requestedFiles.length) {
|
|
126919
126987
|
return JSON.stringify({
|
|
@@ -126937,7 +127005,7 @@ var actionlint_scan = createSwarmTool({
|
|
|
126937
127005
|
note: discoveryTruncated ? `Workflow discovery was truncated at ${MAX_WORKFLOW_FILES} files, ${MAX_WORKFLOW_DIRS} directories, or depth ${MAX_WORKFLOW_DEPTH}; result is incomplete.` : "No GitHub Actions workflow YAML files found"
|
|
126938
127006
|
}, null, 2);
|
|
126939
127007
|
}
|
|
126940
|
-
const executable =
|
|
127008
|
+
const executable = _internals93.resolveActionlintBinary();
|
|
126941
127009
|
if (!executable) {
|
|
126942
127010
|
return JSON.stringify({
|
|
126943
127011
|
error: true,
|
|
@@ -126950,7 +127018,7 @@ var actionlint_scan = createSwarmTool({
|
|
|
126950
127018
|
"{{json .}}",
|
|
126951
127019
|
...files.map((file3) => `./${file3}`)
|
|
126952
127020
|
];
|
|
126953
|
-
const run = await
|
|
127021
|
+
const run = await _internals93.runExternalTool({
|
|
126954
127022
|
executable,
|
|
126955
127023
|
args: lintArgs,
|
|
126956
127024
|
cwd: directory,
|
|
@@ -126994,7 +127062,7 @@ var actionlint_scan = createSwarmTool({
|
|
|
126994
127062
|
}, null, 2);
|
|
126995
127063
|
}
|
|
126996
127064
|
});
|
|
126997
|
-
var
|
|
127065
|
+
var _internals93 = {
|
|
126998
127066
|
resolveExecutableFromPath,
|
|
126999
127067
|
resolveActionlintBinary,
|
|
127000
127068
|
runExternalTool,
|
|
@@ -127841,7 +127909,7 @@ function splitGlobPatterns(value) {
|
|
|
127841
127909
|
return value ? value.split(",").map((p) => p.trim()).filter(Boolean) : [];
|
|
127842
127910
|
}
|
|
127843
127911
|
function resolveAstGrepBinary() {
|
|
127844
|
-
return
|
|
127912
|
+
return _internals94.resolveExecutableFromPath(["ast-grep", "sg"]);
|
|
127845
127913
|
}
|
|
127846
127914
|
function toWorkspaceRelativePath(filePath, workspace) {
|
|
127847
127915
|
try {
|
|
@@ -127973,7 +128041,7 @@ var ast_grep = createSwarmTool({
|
|
|
127973
128041
|
message: "Workspace directory does not exist"
|
|
127974
128042
|
}, null, 2);
|
|
127975
128043
|
}
|
|
127976
|
-
const executable =
|
|
128044
|
+
const executable = _internals94.resolveAstGrepBinary();
|
|
127977
128045
|
if (!executable) {
|
|
127978
128046
|
return JSON.stringify({
|
|
127979
128047
|
error: true,
|
|
@@ -127999,7 +128067,7 @@ var ast_grep = createSwarmTool({
|
|
|
127999
128067
|
sgArgs.push("--globs", `!${glob}`);
|
|
128000
128068
|
}
|
|
128001
128069
|
sgArgs.push(".");
|
|
128002
|
-
const run = await
|
|
128070
|
+
const run = await _internals94.runExternalTool({
|
|
128003
128071
|
executable,
|
|
128004
128072
|
args: sgArgs,
|
|
128005
128073
|
cwd: directory,
|
|
@@ -128041,7 +128109,7 @@ var ast_grep = createSwarmTool({
|
|
|
128041
128109
|
}, null, 2);
|
|
128042
128110
|
}
|
|
128043
128111
|
});
|
|
128044
|
-
var
|
|
128112
|
+
var _internals94 = {
|
|
128045
128113
|
resolveExecutableFromPath,
|
|
128046
128114
|
resolveAstGrepBinary,
|
|
128047
128115
|
runExternalTool,
|
|
@@ -129770,7 +129838,7 @@ init_model_limits();
|
|
|
129770
129838
|
init_utils2();
|
|
129771
129839
|
init_state2();
|
|
129772
129840
|
init_create_tool();
|
|
129773
|
-
var
|
|
129841
|
+
var _internals95 = {
|
|
129774
129842
|
loadPluginConfig,
|
|
129775
129843
|
fetchSessionMessages: async (sessionID, directory, limit = 100) => {
|
|
129776
129844
|
if (!swarmState.opencodeClient?.session)
|
|
@@ -129819,13 +129887,13 @@ var context_status = createSwarmTool({
|
|
|
129819
129887
|
description: "Report current context-window headroom for the active session. Returns tokens-used, model-limit, usage-percent, threshold-state (none/warn/critical), model name, and provider. Pure read-only — no state mutation, no warning injection. Works whether context_budget.enabled is true or false.",
|
|
129820
129888
|
args: {},
|
|
129821
129889
|
async execute(_args, directory, ctx) {
|
|
129822
|
-
const config3 =
|
|
129890
|
+
const config3 = _internals95.loadPluginConfig(directory);
|
|
129823
129891
|
const warnThreshold = config3.context_budget?.warn_threshold ?? 0.7;
|
|
129824
129892
|
const criticalThreshold = config3.context_budget?.critical_threshold ?? 0.9;
|
|
129825
129893
|
const modelLimitsConfig = config3.context_budget?.model_limits ?? {};
|
|
129826
129894
|
let messages = [];
|
|
129827
129895
|
if (ctx?.sessionID) {
|
|
129828
|
-
const sessionMessages = await
|
|
129896
|
+
const sessionMessages = await _internals95.fetchSessionMessages(ctx.sessionID, directory);
|
|
129829
129897
|
if (sessionMessages) {
|
|
129830
129898
|
messages = sessionMessages;
|
|
129831
129899
|
}
|
|
@@ -129866,7 +129934,7 @@ var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
|
|
|
129866
129934
|
var COUNCIL_GATE_NAME = "council";
|
|
129867
129935
|
var COUNCIL_AGENT_ID = "architect";
|
|
129868
129936
|
var EvidenceFileSchema = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
129869
|
-
var
|
|
129937
|
+
var _internals96 = {
|
|
129870
129938
|
withTaskEvidenceLock
|
|
129871
129939
|
};
|
|
129872
129940
|
var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -129901,7 +129969,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
|
|
|
129901
129969
|
const dir = join131(workingDir, EVIDENCE_DIR2);
|
|
129902
129970
|
mkdirSync42(dir, { recursive: true });
|
|
129903
129971
|
const filePath = taskEvidencePath(workingDir, synthesis.taskId);
|
|
129904
|
-
await
|
|
129972
|
+
await _internals96.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
|
|
129905
129973
|
const existingRoot = Object.create(null);
|
|
129906
129974
|
if (existsSync95(filePath)) {
|
|
129907
129975
|
try {
|
|
@@ -132421,7 +132489,7 @@ var CollectLaneResultsArgsSchema = exports_external.object({
|
|
|
132421
132489
|
include_pending: exports_external.boolean().optional().describe("Include pending/running lanes in lane_results. Defaults to true for non-blocking polls and false for wait=true joins."),
|
|
132422
132490
|
cancel_pending: exports_external.boolean().optional().describe("Abort and mark pending/running lanes cancelled")
|
|
132423
132491
|
});
|
|
132424
|
-
var
|
|
132492
|
+
var _internals97 = {
|
|
132425
132493
|
getSessionOps: () => swarmState.opencodeClient?.session ?? null,
|
|
132426
132494
|
getGeneratedAgentNames: () => swarmState.generatedAgentNames,
|
|
132427
132495
|
createParallelDispatcher,
|
|
@@ -132445,7 +132513,7 @@ async function executeDispatchLanes(args2, directory, context = {}) {
|
|
|
132445
132513
|
errors: duplicateLaneIds.map((id) => `Duplicate lane id: ${id}`)
|
|
132446
132514
|
});
|
|
132447
132515
|
}
|
|
132448
|
-
const session =
|
|
132516
|
+
const session = _internals97.getSessionOps();
|
|
132449
132517
|
if (!session) {
|
|
132450
132518
|
return failureResult({
|
|
132451
132519
|
failure_class: "no_client",
|
|
@@ -132463,7 +132531,7 @@ async function executeDispatchLanes(args2, directory, context = {}) {
|
|
|
132463
132531
|
const lanes = applyExplorerFormatSuffix(common.lanes);
|
|
132464
132532
|
const maxConcurrent = Math.min(parsed.data.max_concurrent ?? lanes.length, lanes.length, MAX_LANES);
|
|
132465
132533
|
const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS3;
|
|
132466
|
-
const dispatcher =
|
|
132534
|
+
const dispatcher = _internals97.createParallelDispatcher({
|
|
132467
132535
|
enabled: true,
|
|
132468
132536
|
maxConcurrentTasks: maxConcurrent,
|
|
132469
132537
|
evidenceLockTimeoutMs: 0
|
|
@@ -132493,7 +132561,7 @@ async function executeDispatchLanesAsync(args2, directory, context = {}) {
|
|
|
132493
132561
|
errors: duplicateLaneIds.map((id) => `Duplicate lane id: ${id}`)
|
|
132494
132562
|
});
|
|
132495
132563
|
}
|
|
132496
|
-
const session =
|
|
132564
|
+
const session = _internals97.getSessionOps();
|
|
132497
132565
|
if (!session || typeof session.promptAsync !== "function") {
|
|
132498
132566
|
return asyncFailureResult({
|
|
132499
132567
|
failure_class: "no_client",
|
|
@@ -132519,7 +132587,7 @@ async function executeDispatchLanesAsync(args2, directory, context = {}) {
|
|
|
132519
132587
|
}
|
|
132520
132588
|
const maxConcurrent = Math.min(parsed.data.max_concurrent ?? lanes.length, lanes.length, MAX_LANES);
|
|
132521
132589
|
const launchTimeoutMs = parsed.data.launch_timeout_ms ?? parsed.data.timeout_ms ?? DEFAULT_ASYNC_LAUNCH_TIMEOUT_MS;
|
|
132522
|
-
const dispatcher =
|
|
132590
|
+
const dispatcher = _internals97.createParallelDispatcher({
|
|
132523
132591
|
enabled: true,
|
|
132524
132592
|
maxConcurrentTasks: maxConcurrent,
|
|
132525
132593
|
evidenceLockTimeoutMs: 0
|
|
@@ -132567,7 +132635,7 @@ async function executeCollectLaneResults(args2, directory, context = {}) {
|
|
|
132567
132635
|
errors: parsed.error.issues.map((issue3) => `${issue3.path.join(".")}: ${issue3.message}`)
|
|
132568
132636
|
});
|
|
132569
132637
|
}
|
|
132570
|
-
const session =
|
|
132638
|
+
const session = _internals97.getSessionOps();
|
|
132571
132639
|
if (!session || typeof session.messages !== "function") {
|
|
132572
132640
|
return collectFailureResult({
|
|
132573
132641
|
failure_class: "no_client",
|
|
@@ -132576,7 +132644,7 @@ async function executeCollectLaneResults(args2, directory, context = {}) {
|
|
|
132576
132644
|
});
|
|
132577
132645
|
}
|
|
132578
132646
|
const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_COLLECT_TIMEOUT_MS;
|
|
132579
|
-
const deadline =
|
|
132647
|
+
const deadline = _internals97.now() + timeoutMs;
|
|
132580
132648
|
const batchFilter = context.sessionID !== undefined ? { parentSessionId: context.sessionID } : undefined;
|
|
132581
132649
|
let records = findByBatchId(directory, parsed.data.batch_id, batchFilter);
|
|
132582
132650
|
if (records.length === 0) {
|
|
@@ -132596,11 +132664,11 @@ async function executeCollectLaneResults(args2, directory, context = {}) {
|
|
|
132596
132664
|
keepPolling = false;
|
|
132597
132665
|
continue;
|
|
132598
132666
|
}
|
|
132599
|
-
if (
|
|
132667
|
+
if (_internals97.now() >= deadline) {
|
|
132600
132668
|
keepPolling = false;
|
|
132601
132669
|
continue;
|
|
132602
132670
|
}
|
|
132603
|
-
await
|
|
132671
|
+
await _internals97.sleep(Math.min(pollIntervalMs, Math.max(0, deadline - _internals97.now())));
|
|
132604
132672
|
pollIntervalMs = nextCollectPollInterval(pollIntervalMs);
|
|
132605
132673
|
}
|
|
132606
132674
|
return buildCollectResult(parsed.data.batch_id, records, parsed.data.include_pending ?? parsed.data.wait !== true);
|
|
@@ -132829,7 +132897,7 @@ async function isLaneReadyForCollection(session, directory, sessionId) {
|
|
|
132829
132897
|
async function sweepStaleAsyncLaneRecords(session, directory, records, staleTimeoutMs) {
|
|
132830
132898
|
if (staleTimeoutMs <= 0)
|
|
132831
132899
|
return;
|
|
132832
|
-
const now =
|
|
132900
|
+
const now = _internals97.now();
|
|
132833
132901
|
for (const record3 of records) {
|
|
132834
132902
|
if (record3.status !== "pending" && record3.status !== "running" && record3.status !== "ingestion_error")
|
|
132835
132903
|
continue;
|
|
@@ -133040,7 +133108,7 @@ function failedLane(lane, role, startedAt, error93, slotId, runId, sessionId) {
|
|
|
133040
133108
|
};
|
|
133041
133109
|
}
|
|
133042
133110
|
function validateLaneAgent(agent, context) {
|
|
133043
|
-
const generatedAgentNames =
|
|
133111
|
+
const generatedAgentNames = _internals97.getGeneratedAgentNames();
|
|
133044
133112
|
const role = resolveGeneratedAgentRole(agent, generatedAgentNames);
|
|
133045
133113
|
if (!isKnownCanonicalRole(role)) {
|
|
133046
133114
|
return {
|
|
@@ -133191,7 +133259,7 @@ function applyCommonPrompt(lanes, commonPrompt) {
|
|
|
133191
133259
|
return { ok: true, lanes: merged };
|
|
133192
133260
|
}
|
|
133193
133261
|
function applyExplorerFormatSuffix(lanes) {
|
|
133194
|
-
const generatedAgentNames =
|
|
133262
|
+
const generatedAgentNames = _internals97.getGeneratedAgentNames();
|
|
133195
133263
|
return lanes.map((lane) => {
|
|
133196
133264
|
const role = resolveGeneratedAgentRole(lane.agent, generatedAgentNames);
|
|
133197
133265
|
if (role !== "explorer")
|
|
@@ -133264,7 +133332,7 @@ function boundErrorString(text) {
|
|
|
133264
133332
|
return `${text.slice(0, MAX_ERROR_CHARS)}${ERROR_TRUNCATION_SUFFIX}`;
|
|
133265
133333
|
}
|
|
133266
133334
|
function isoNow() {
|
|
133267
|
-
return new Date(
|
|
133335
|
+
return new Date(_internals97.now()).toISOString();
|
|
133268
133336
|
}
|
|
133269
133337
|
function buildLaneSessionCreateArgs(directory, lane, context) {
|
|
133270
133338
|
const parentID = context.sessionID?.trim();
|
|
@@ -133278,7 +133346,7 @@ function buildLaneSessionCreateArgs(directory, lane, context) {
|
|
|
133278
133346
|
};
|
|
133279
133347
|
}
|
|
133280
133348
|
function makeBatchId() {
|
|
133281
|
-
return `lanes-${
|
|
133349
|
+
return `lanes-${_internals97.now().toString(36)}`;
|
|
133282
133350
|
}
|
|
133283
133351
|
function promptHash(lane, directory, batchId) {
|
|
133284
133352
|
return digestText2(JSON.stringify({
|
|
@@ -133571,7 +133639,7 @@ function buildIsUpstreamCommittedWithStatus(directory, options) {
|
|
|
133571
133639
|
const max = options?.maxCommits ?? MAX_LOG_COMMITS;
|
|
133572
133640
|
let subjects;
|
|
133573
133641
|
try {
|
|
133574
|
-
subjects =
|
|
133642
|
+
subjects = _internals98.readGitLogSubjects(directory, max);
|
|
133575
133643
|
} catch (err) {
|
|
133576
133644
|
const msg = err instanceof Error ? err.message : String(err);
|
|
133577
133645
|
criticalWarn(`[epic:upstream-commits] git log scan failed (degrading to permissive predicate, the activation gate may flip fail-closed): ${msg}`);
|
|
@@ -133593,7 +133661,7 @@ function buildIsUpstreamCommittedWithStatus(directory, options) {
|
|
|
133593
133661
|
gitFailed: false
|
|
133594
133662
|
};
|
|
133595
133663
|
}
|
|
133596
|
-
var
|
|
133664
|
+
var _internals98 = {
|
|
133597
133665
|
readGitLogSubjects: (cwd, max) => {
|
|
133598
133666
|
return _internals4.gitExec(["log", "--no-merges", `--max-count=${max}`, "--pretty=%s"], cwd);
|
|
133599
133667
|
}
|
|
@@ -133998,7 +134066,7 @@ function readPlanJson(directory) {
|
|
|
133998
134066
|
}
|
|
133999
134067
|
async function executeEpicPlanWaves(args2) {
|
|
134000
134068
|
const { directory, phase, scopes } = args2;
|
|
134001
|
-
const plan =
|
|
134069
|
+
const plan = _internals99.readPlanJson(directory);
|
|
134002
134070
|
if (!plan) {
|
|
134003
134071
|
return {
|
|
134004
134072
|
success: false,
|
|
@@ -134051,7 +134119,7 @@ async function executeEpicPlanWaves(args2) {
|
|
|
134051
134119
|
try {
|
|
134052
134120
|
const tasksMissingScope = [];
|
|
134053
134121
|
for (const task of pendingTasks) {
|
|
134054
|
-
const declaredScope =
|
|
134122
|
+
const declaredScope = _internals99.readTaskScopes(directory, task.id);
|
|
134055
134123
|
const filesTouched = task.files_touched ?? [];
|
|
134056
134124
|
const providedScope = scopes && task.id in scopes ? scopes[task.id] : null;
|
|
134057
134125
|
if ((declaredScope === null || declaredScope.length === 0) && filesTouched.length === 0 && (providedScope === null || providedScope.length === 0)) {
|
|
@@ -134074,8 +134142,8 @@ async function executeEpicPlanWaves(args2) {
|
|
|
134074
134142
|
};
|
|
134075
134143
|
}
|
|
134076
134144
|
let isUpstreamCommitted;
|
|
134077
|
-
if (
|
|
134078
|
-
const evidence =
|
|
134145
|
+
if (_internals99.isGitRepo(directory)) {
|
|
134146
|
+
const evidence = _internals99.buildIsUpstreamCommittedWithStatus(directory);
|
|
134079
134147
|
if (evidence.gitFailed) {
|
|
134080
134148
|
criticalWarn(`[epic_plan_waves] wave-planning blocked for directory=${directory} phase=${phase}: git log scan failed. Any prior promote verdict in .swarm/evidence/epic-promotions.jsonl for this phase is not backed by actual parallel execution.`);
|
|
134081
134149
|
return {
|
|
@@ -134090,7 +134158,7 @@ async function executeEpicPlanWaves(args2) {
|
|
|
134090
134158
|
}
|
|
134091
134159
|
let leanConfig = { ...DEFAULT_LEAN_TURBO_CONFIG };
|
|
134092
134160
|
try {
|
|
134093
|
-
const loaded = await
|
|
134161
|
+
const loaded = await _internals99.loadPluginConfigWithMeta(directory);
|
|
134094
134162
|
const userLean = loaded?.config?.turbo?.lean;
|
|
134095
134163
|
if (userLean) {
|
|
134096
134164
|
leanConfig = { ...leanConfig, ...userLean };
|
|
@@ -134114,7 +134182,7 @@ async function executeEpicPlanWaves(args2) {
|
|
|
134114
134182
|
};
|
|
134115
134183
|
}
|
|
134116
134184
|
}
|
|
134117
|
-
var
|
|
134185
|
+
var _internals99 = {
|
|
134118
134186
|
readPlanJson,
|
|
134119
134187
|
readTaskScopes,
|
|
134120
134188
|
isGitRepo: (cwd) => isGitRepo(cwd),
|
|
@@ -134146,7 +134214,7 @@ init_state2();
|
|
|
134146
134214
|
init_divergence_recorder();
|
|
134147
134215
|
init_logger();
|
|
134148
134216
|
init_create_tool();
|
|
134149
|
-
var
|
|
134217
|
+
var _internals100 = {
|
|
134150
134218
|
hasActiveEpicMode,
|
|
134151
134219
|
getAgentSession,
|
|
134152
134220
|
readScopeFromDisk,
|
|
@@ -134155,7 +134223,7 @@ var _internals99 = {
|
|
|
134155
134223
|
};
|
|
134156
134224
|
async function findPhaseForTask(directory, taskId) {
|
|
134157
134225
|
try {
|
|
134158
|
-
const plan = await
|
|
134226
|
+
const plan = await _internals100.loadPlanJsonOnly(directory);
|
|
134159
134227
|
if (!plan)
|
|
134160
134228
|
return;
|
|
134161
134229
|
for (const phase of plan.phases) {
|
|
@@ -134168,20 +134236,20 @@ async function findPhaseForTask(directory, taskId) {
|
|
|
134168
134236
|
}
|
|
134169
134237
|
async function executeEpicRecordDivergence(args2) {
|
|
134170
134238
|
const { directory, taskId, sessionID } = args2;
|
|
134171
|
-
if (!
|
|
134239
|
+
if (!_internals100.hasActiveEpicMode(sessionID)) {
|
|
134172
134240
|
return { success: true, reason: "epic-mode-not-active" };
|
|
134173
134241
|
}
|
|
134174
|
-
const session =
|
|
134242
|
+
const session = _internals100.getAgentSession(sessionID);
|
|
134175
134243
|
if (!session) {
|
|
134176
134244
|
return { success: true, reason: "no-session" };
|
|
134177
134245
|
}
|
|
134178
|
-
const declaredScope =
|
|
134246
|
+
const declaredScope = _internals100.readScopeFromDisk(directory, taskId);
|
|
134179
134247
|
if (declaredScope === null) {
|
|
134180
134248
|
return { success: true, reason: "no-scope" };
|
|
134181
134249
|
}
|
|
134182
134250
|
const actualFiles = session.modifiedFilesThisCoderTask ?? [];
|
|
134183
134251
|
const phaseNumber = await findPhaseForTask(directory, taskId);
|
|
134184
|
-
const result =
|
|
134252
|
+
const result = _internals100.recordTaskDivergence({
|
|
134185
134253
|
directory,
|
|
134186
134254
|
sessionID,
|
|
134187
134255
|
taskId,
|
|
@@ -134563,7 +134631,7 @@ init_state4();
|
|
|
134563
134631
|
|
|
134564
134632
|
// src/turbo/lean/state-lock.ts
|
|
134565
134633
|
init_file_locks();
|
|
134566
|
-
var
|
|
134634
|
+
var _internals101 = { tryAcquireLock };
|
|
134567
134635
|
|
|
134568
134636
|
class TurboStateLockTimeoutError extends Error {
|
|
134569
134637
|
directory;
|
|
@@ -134591,7 +134659,7 @@ async function withTurboStateLock(directory, sessionID, fn2, timeoutMs = 30000)
|
|
|
134591
134659
|
while (true) {
|
|
134592
134660
|
let result;
|
|
134593
134661
|
try {
|
|
134594
|
-
result = await
|
|
134662
|
+
result = await _internals101.tryAcquireLock(directory, lockPath, agent, sessionID);
|
|
134595
134663
|
} catch (acquireErr) {
|
|
134596
134664
|
console.warn(`[lean-turbo] state lock acquisition error for ${sessionID} (${lockPath}), will retry: ${acquireErr instanceof Error ? acquireErr.message : String(acquireErr)}`);
|
|
134597
134665
|
}
|
|
@@ -135338,7 +135406,7 @@ ${fileList}
|
|
|
135338
135406
|
// src/tools/epic-run-phase.ts
|
|
135339
135407
|
init_logger();
|
|
135340
135408
|
init_create_tool();
|
|
135341
|
-
var
|
|
135409
|
+
var _internals102 = {
|
|
135342
135410
|
loadPluginConfigWithMeta,
|
|
135343
135411
|
loadPlanJsonOnly,
|
|
135344
135412
|
getCoChangeData,
|
|
@@ -135360,13 +135428,13 @@ var _internals101 = {
|
|
|
135360
135428
|
};
|
|
135361
135429
|
async function executeEpicDecidePhase(args2) {
|
|
135362
135430
|
const { directory, phase, sessionID } = args2;
|
|
135363
|
-
if (!
|
|
135431
|
+
if (!_internals102.isEpicModeActive(directory, sessionID)) {
|
|
135364
135432
|
return {
|
|
135365
135433
|
success: false,
|
|
135366
135434
|
reason: "epic-mode-not-active"
|
|
135367
135435
|
};
|
|
135368
135436
|
}
|
|
135369
|
-
const plan = await
|
|
135437
|
+
const plan = await _internals102.loadPlanJsonOnly(directory);
|
|
135370
135438
|
if (plan === null) {
|
|
135371
135439
|
return { success: false, reason: "no-plan" };
|
|
135372
135440
|
}
|
|
@@ -135396,7 +135464,7 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135396
135464
|
}
|
|
135397
135465
|
const tasksMissingScope = [];
|
|
135398
135466
|
for (const task of pendingTasks) {
|
|
135399
|
-
const declaredScope =
|
|
135467
|
+
const declaredScope = _internals102.readTaskScopes(directory, task.id);
|
|
135400
135468
|
const filesTouched = task.files_touched ?? [];
|
|
135401
135469
|
if ((declaredScope === null || declaredScope.length === 0) && filesTouched.length === 0) {
|
|
135402
135470
|
tasksMissingScope.push(task.id);
|
|
@@ -135416,7 +135484,7 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135416
135484
|
};
|
|
135417
135485
|
}
|
|
135418
135486
|
}
|
|
135419
|
-
const { config: config3 } =
|
|
135487
|
+
const { config: config3 } = _internals102.loadPluginConfigWithMeta(directory);
|
|
135420
135488
|
const modeCfg = config3.turbo?.epic?.mode;
|
|
135421
135489
|
const cochangeCfg = config3.turbo?.epic?.cochange;
|
|
135422
135490
|
const calibrationCfg = config3.turbo?.epic?.calibration;
|
|
@@ -135429,14 +135497,14 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135429
135497
|
let extraHotModules = [];
|
|
135430
135498
|
if (calibrationEnabled) {
|
|
135431
135499
|
try {
|
|
135432
|
-
const currentCalibration =
|
|
135500
|
+
const currentCalibration = _internals102.loadCalibrationState(directory);
|
|
135433
135501
|
if (currentCalibration !== null) {
|
|
135434
|
-
const history =
|
|
135502
|
+
const history = _internals102.readDivergenceHistory(directory, {
|
|
135435
135503
|
maxBytes: Number.POSITIVE_INFINITY
|
|
135436
135504
|
});
|
|
135437
135505
|
const newRecords = history.slice(currentCalibration.processedRecords);
|
|
135438
135506
|
if (newRecords.length > 0) {
|
|
135439
|
-
const updated =
|
|
135507
|
+
const updated = _internals102.applyCalibration(currentCalibration, newRecords, {
|
|
135440
135508
|
staticThreshold: staticActivationThreshold,
|
|
135441
135509
|
floorThreshold: calibrationCfg?.floor_threshold,
|
|
135442
135510
|
tightenStep: calibrationCfg?.tighten_step,
|
|
@@ -135445,17 +135513,17 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135445
135513
|
});
|
|
135446
135514
|
let savedSuccessfully = false;
|
|
135447
135515
|
try {
|
|
135448
|
-
|
|
135516
|
+
_internals102.saveCalibrationState(directory, updated);
|
|
135449
135517
|
savedSuccessfully = true;
|
|
135450
135518
|
} catch (err) {
|
|
135451
135519
|
criticalWarn(`[epic_run_phase] calibration persist failed; ignoring this run's calibration delta to avoid drift on next run: ${err instanceof Error ? err.message : String(err)}`);
|
|
135452
135520
|
}
|
|
135453
135521
|
const sourceForThisRun = savedSuccessfully ? updated : currentCalibration;
|
|
135454
|
-
effectiveThreshold =
|
|
135455
|
-
extraHotModules =
|
|
135522
|
+
effectiveThreshold = _internals102.effectiveActivationThreshold(staticActivationThreshold, sourceForThisRun);
|
|
135523
|
+
extraHotModules = _internals102.effectiveHotModules([], sourceForThisRun);
|
|
135456
135524
|
} else {
|
|
135457
|
-
effectiveThreshold =
|
|
135458
|
-
extraHotModules =
|
|
135525
|
+
effectiveThreshold = _internals102.effectiveActivationThreshold(staticActivationThreshold, currentCalibration);
|
|
135526
|
+
extraHotModules = _internals102.effectiveHotModules([], currentCalibration);
|
|
135459
135527
|
}
|
|
135460
135528
|
}
|
|
135461
135529
|
} catch (err) {
|
|
@@ -135471,14 +135539,14 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135471
135539
|
}
|
|
135472
135540
|
}
|
|
135473
135541
|
const tasks = rawTasks.map((task) => {
|
|
135474
|
-
const scopeFiles =
|
|
135542
|
+
const scopeFiles = _internals102.readTaskScopes(directory, task.id);
|
|
135475
135543
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
135476
135544
|
return { id: task.id, scope };
|
|
135477
135545
|
});
|
|
135478
|
-
const { pairs, commitsObserved } = await
|
|
135546
|
+
const { pairs, commitsObserved } = await _internals102.getCoChangeData(directory);
|
|
135479
135547
|
const isGitProject = (() => {
|
|
135480
135548
|
try {
|
|
135481
|
-
return
|
|
135549
|
+
return _internals102.isGitRepo(directory);
|
|
135482
135550
|
} catch {
|
|
135483
135551
|
return false;
|
|
135484
135552
|
}
|
|
@@ -135511,10 +135579,10 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135511
135579
|
const phantomDeps = [...phantomDepsSet];
|
|
135512
135580
|
let isUpstreamCommitted;
|
|
135513
135581
|
if (isGitProject) {
|
|
135514
|
-
const evidence =
|
|
135582
|
+
const evidence = _internals102.buildIsUpstreamCommittedWithStatus(directory);
|
|
135515
135583
|
isUpstreamCommitted = evidence.gitFailed ? () => false : evidence.predicate;
|
|
135516
135584
|
}
|
|
135517
|
-
const verdict =
|
|
135585
|
+
const verdict = _internals102.decideEpicActivation(tasks, pairs, commitsObserved, {
|
|
135518
135586
|
activationThreshold: effectiveThreshold,
|
|
135519
135587
|
minCommitsForSignal,
|
|
135520
135588
|
cochangeNpmiThreshold,
|
|
@@ -135526,7 +135594,7 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135526
135594
|
isUpstreamCommitted
|
|
135527
135595
|
});
|
|
135528
135596
|
try {
|
|
135529
|
-
|
|
135597
|
+
_internals102.appendPromotionEvidence(directory, {
|
|
135530
135598
|
timestamp: new Date().toISOString(),
|
|
135531
135599
|
sessionID,
|
|
135532
135600
|
phase,
|
|
@@ -135536,7 +135604,7 @@ async function executeEpicDecidePhase(args2) {
|
|
|
135536
135604
|
warn(`[epic_run_phase] promotion-evidence append failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
135537
135605
|
}
|
|
135538
135606
|
try {
|
|
135539
|
-
|
|
135607
|
+
_internals102.recordEpicDecision(directory, sessionID, {
|
|
135540
135608
|
decidedAt: new Date().toISOString(),
|
|
135541
135609
|
phase,
|
|
135542
135610
|
decision: verdict.decision,
|
|
@@ -135833,7 +135901,7 @@ function candidateFilePath(storePath3, id) {
|
|
|
135833
135901
|
}
|
|
135834
135902
|
return path173.join(storePath3, `${id}.json`);
|
|
135835
135903
|
}
|
|
135836
|
-
var
|
|
135904
|
+
var _internals103 = {
|
|
135837
135905
|
randomUUID: crypto12.randomUUID.bind(crypto12),
|
|
135838
135906
|
fs: {
|
|
135839
135907
|
mkdir: fs108.mkdir,
|
|
@@ -135846,11 +135914,11 @@ var _internals102 = {
|
|
|
135846
135914
|
function createExternalSkillStore(directory, config3) {
|
|
135847
135915
|
const storePath3 = path173.join(directory, ".swarm", "skills", "candidates");
|
|
135848
135916
|
async function add2(candidate) {
|
|
135849
|
-
const id =
|
|
135917
|
+
const id = _internals103.randomUUID();
|
|
135850
135918
|
const full = { ...candidate, id };
|
|
135851
135919
|
const filePath = path173.join(storePath3, `${id}.json`);
|
|
135852
|
-
await
|
|
135853
|
-
await
|
|
135920
|
+
await _internals103.fs.mkdir(storePath3, { recursive: true });
|
|
135921
|
+
await _internals103.atomicWriteFile(filePath, JSON.stringify(full, null, "\t"));
|
|
135854
135922
|
return full;
|
|
135855
135923
|
}
|
|
135856
135924
|
async function get2(id) {
|
|
@@ -135860,7 +135928,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
135860
135928
|
}
|
|
135861
135929
|
let raw;
|
|
135862
135930
|
try {
|
|
135863
|
-
raw = await
|
|
135931
|
+
raw = await _internals103.fs.readFile(filePath, "utf-8");
|
|
135864
135932
|
} catch (err) {
|
|
135865
135933
|
if (err.code === "ENOENT") {
|
|
135866
135934
|
return null;
|
|
@@ -135876,7 +135944,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
135876
135944
|
async function list(filter) {
|
|
135877
135945
|
let entries;
|
|
135878
135946
|
try {
|
|
135879
|
-
entries = await
|
|
135947
|
+
entries = await _internals103.fs.readdir(storePath3);
|
|
135880
135948
|
} catch (err) {
|
|
135881
135949
|
if (err.code === "ENOENT") {
|
|
135882
135950
|
return [];
|
|
@@ -135891,7 +135959,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
135891
135959
|
const filePath = path173.join(storePath3, entry);
|
|
135892
135960
|
let raw;
|
|
135893
135961
|
try {
|
|
135894
|
-
raw = await
|
|
135962
|
+
raw = await _internals103.fs.readFile(filePath, "utf-8");
|
|
135895
135963
|
} catch {
|
|
135896
135964
|
continue;
|
|
135897
135965
|
}
|
|
@@ -135958,7 +136026,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
135958
136026
|
...patch.evaluation_history
|
|
135959
136027
|
];
|
|
135960
136028
|
}
|
|
135961
|
-
await
|
|
136029
|
+
await _internals103.atomicWriteFile(filePath, JSON.stringify(updated, null, "\t"));
|
|
135962
136030
|
return updated;
|
|
135963
136031
|
}
|
|
135964
136032
|
async function deleteCandidate(id) {
|
|
@@ -135967,7 +136035,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
135967
136035
|
return false;
|
|
135968
136036
|
}
|
|
135969
136037
|
try {
|
|
135970
|
-
await
|
|
136038
|
+
await _internals103.fs.unlink(filePath);
|
|
135971
136039
|
return true;
|
|
135972
136040
|
} catch (err) {
|
|
135973
136041
|
if (err.code === "ENOENT") {
|
|
@@ -136005,7 +136073,7 @@ function createExternalSkillStore(directory, config3) {
|
|
|
136005
136073
|
|
|
136006
136074
|
// src/tools/external-skill-delete.ts
|
|
136007
136075
|
init_create_tool();
|
|
136008
|
-
var
|
|
136076
|
+
var _internals104 = {
|
|
136009
136077
|
loadConfig: (directory) => {
|
|
136010
136078
|
const pluginConfig = loadPluginConfig(directory);
|
|
136011
136079
|
return pluginConfig.external_skills;
|
|
@@ -136027,7 +136095,7 @@ var external_skill_delete = createSwarmTool({
|
|
|
136027
136095
|
} catch {}
|
|
136028
136096
|
let config3;
|
|
136029
136097
|
try {
|
|
136030
|
-
config3 =
|
|
136098
|
+
config3 = _internals104.loadConfig(directory);
|
|
136031
136099
|
} catch {
|
|
136032
136100
|
return JSON.stringify({
|
|
136033
136101
|
success: false,
|
|
@@ -136606,7 +136674,7 @@ function scanProvenanceIntegrity(candidate, trustLevel = "low", ttlDays) {
|
|
|
136606
136674
|
});
|
|
136607
136675
|
}
|
|
136608
136676
|
fieldsScanned.push("fetched_at");
|
|
136609
|
-
const now = new Date(
|
|
136677
|
+
const now = new Date(_internals105.getTimestamp()).getTime();
|
|
136610
136678
|
const fetchedAtMs = new Date(candidate.fetched_at).getTime();
|
|
136611
136679
|
if (Number.isNaN(fetchedAtMs)) {
|
|
136612
136680
|
findings.push({
|
|
@@ -136670,7 +136738,7 @@ function scanProvenanceIntegrity(candidate, trustLevel = "low", ttlDays) {
|
|
|
136670
136738
|
});
|
|
136671
136739
|
}
|
|
136672
136740
|
fieldsScanned.push("skill_body");
|
|
136673
|
-
const computedHash =
|
|
136741
|
+
const computedHash = _internals105.computeSha256(candidate.skill_body);
|
|
136674
136742
|
if (computedHash !== candidate.sha256) {
|
|
136675
136743
|
findings.push({
|
|
136676
136744
|
pattern: "content_hash_mismatch",
|
|
@@ -136720,7 +136788,7 @@ function evaluateCandidate(candidate, options) {
|
|
|
136720
136788
|
risk_flags: riskFlags
|
|
136721
136789
|
};
|
|
136722
136790
|
}
|
|
136723
|
-
var
|
|
136791
|
+
var _internals105 = {
|
|
136724
136792
|
getTimestamp: () => new Date().toISOString(),
|
|
136725
136793
|
computeSha256: (content) => createHash22("sha256").update(content).digest("hex"),
|
|
136726
136794
|
splitMarkdownCodeSegments,
|
|
@@ -136730,7 +136798,7 @@ var _internals104 = {
|
|
|
136730
136798
|
|
|
136731
136799
|
// src/tools/external-skill-discover.ts
|
|
136732
136800
|
init_create_tool();
|
|
136733
|
-
var
|
|
136801
|
+
var _internals106 = {
|
|
136734
136802
|
fetchContent: async (_url3, _timeoutMs) => {
|
|
136735
136803
|
const parsed = new URL(_url3);
|
|
136736
136804
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
@@ -136891,7 +136959,7 @@ var external_skill_discover = createSwarmTool({
|
|
|
136891
136959
|
resolvedContent = content;
|
|
136892
136960
|
} else {
|
|
136893
136961
|
try {
|
|
136894
|
-
const fetched = await
|
|
136962
|
+
const fetched = await _internals106.fetchContent(resolvedUrl, config3.fetch_timeout_ms);
|
|
136895
136963
|
if (fetched.finalUrl !== resolvedUrl && matchedSource && !isSubpathUrl(fetched.finalUrl, matchedSource.location)) {
|
|
136896
136964
|
return JSON.stringify({
|
|
136897
136965
|
success: false,
|
|
@@ -136913,14 +136981,14 @@ var external_skill_discover = createSwarmTool({
|
|
|
136913
136981
|
error: `Content too large: ${resolvedContent.length} bytes exceeds max_bytes_per_candidate (${config3.max_bytes_per_candidate})`
|
|
136914
136982
|
});
|
|
136915
136983
|
}
|
|
136916
|
-
const sha256 =
|
|
136984
|
+
const sha256 = _internals106.computeSha256(resolvedContent);
|
|
136917
136985
|
const candidate = {
|
|
136918
|
-
id:
|
|
136986
|
+
id: _internals106.uuid(),
|
|
136919
136987
|
source_url: resolvedUrl,
|
|
136920
136988
|
source_type: sourceType,
|
|
136921
136989
|
publisher,
|
|
136922
136990
|
sha256,
|
|
136923
|
-
fetched_at:
|
|
136991
|
+
fetched_at: _internals106.getTimestamp(),
|
|
136924
136992
|
skill_name: typeof skillName === "string" ? skillName : undefined,
|
|
136925
136993
|
skill_description: typeof skillDescription === "string" ? skillDescription : undefined,
|
|
136926
136994
|
skill_body: resolvedContent,
|
|
@@ -136938,7 +137006,7 @@ var external_skill_discover = createSwarmTool({
|
|
|
136938
137006
|
candidate.evaluation_history = [
|
|
136939
137007
|
{
|
|
136940
137008
|
verdict: result.overall_verdict,
|
|
136941
|
-
timestamp:
|
|
137009
|
+
timestamp: _internals106.getTimestamp(),
|
|
136942
137010
|
actor: "system",
|
|
136943
137011
|
reason: `Validation: ${result.gate_results.length} gates, ${result.all_findings.length} findings`,
|
|
136944
137012
|
gate_results: result.gate_results.map((gr) => ({
|
|
@@ -136983,7 +137051,7 @@ var external_skill_discover = createSwarmTool({
|
|
|
136983
137051
|
init_zod();
|
|
136984
137052
|
init_loader();
|
|
136985
137053
|
init_create_tool();
|
|
136986
|
-
var
|
|
137054
|
+
var _internals107 = {
|
|
136987
137055
|
loadConfig: (directory) => {
|
|
136988
137056
|
const pluginConfig = loadPluginConfig(directory);
|
|
136989
137057
|
return pluginConfig.external_skills;
|
|
@@ -137005,7 +137073,7 @@ var external_skill_inspect = createSwarmTool({
|
|
|
137005
137073
|
} catch {}
|
|
137006
137074
|
let config3;
|
|
137007
137075
|
try {
|
|
137008
|
-
config3 =
|
|
137076
|
+
config3 = _internals107.loadConfig(directory);
|
|
137009
137077
|
} catch {
|
|
137010
137078
|
return JSON.stringify({
|
|
137011
137079
|
success: false,
|
|
@@ -137047,7 +137115,7 @@ var external_skill_inspect = createSwarmTool({
|
|
|
137047
137115
|
init_zod();
|
|
137048
137116
|
init_loader();
|
|
137049
137117
|
init_create_tool();
|
|
137050
|
-
var
|
|
137118
|
+
var _internals108 = {
|
|
137051
137119
|
loadConfig: (directory) => {
|
|
137052
137120
|
const pluginConfig = loadPluginConfig(directory);
|
|
137053
137121
|
return pluginConfig.external_skills;
|
|
@@ -137083,7 +137151,7 @@ var external_skill_list = createSwarmTool({
|
|
|
137083
137151
|
} catch {}
|
|
137084
137152
|
let config3;
|
|
137085
137153
|
try {
|
|
137086
|
-
config3 =
|
|
137154
|
+
config3 = _internals108.loadConfig(directory);
|
|
137087
137155
|
} catch {
|
|
137088
137156
|
return JSON.stringify({
|
|
137089
137157
|
success: false,
|
|
@@ -137136,7 +137204,7 @@ import { createHash as createHash24 } from "node:crypto";
|
|
|
137136
137204
|
import * as fs109 from "node:fs/promises";
|
|
137137
137205
|
import * as path174 from "node:path";
|
|
137138
137206
|
init_create_tool();
|
|
137139
|
-
var
|
|
137207
|
+
var _internals109 = {
|
|
137140
137208
|
loadConfig: (directory) => {
|
|
137141
137209
|
const pluginConfig = loadPluginConfig(directory);
|
|
137142
137210
|
return pluginConfig.external_skills;
|
|
@@ -137206,7 +137274,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
137206
137274
|
} catch {}
|
|
137207
137275
|
let config3;
|
|
137208
137276
|
try {
|
|
137209
|
-
config3 =
|
|
137277
|
+
config3 = _internals109.loadConfig(directory);
|
|
137210
137278
|
} catch {
|
|
137211
137279
|
return JSON.stringify({
|
|
137212
137280
|
success: false,
|
|
@@ -137276,8 +137344,8 @@ var external_skill_promote = createSwarmTool({
|
|
|
137276
137344
|
}
|
|
137277
137345
|
const targetDir = path174.join(directory, ".opencode", "skills", "generated", sanitizedSlug);
|
|
137278
137346
|
const targetPath = path174.join(targetDir, "SKILL.md");
|
|
137279
|
-
const timestamp =
|
|
137280
|
-
const alreadyExists = await
|
|
137347
|
+
const timestamp = _internals109.getTimestamp();
|
|
137348
|
+
const alreadyExists = await _internals109.fileExists(targetPath);
|
|
137281
137349
|
if (alreadyExists) {
|
|
137282
137350
|
return JSON.stringify({
|
|
137283
137351
|
success: false,
|
|
@@ -137286,7 +137354,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
137286
137354
|
}
|
|
137287
137355
|
const skillMarkdown = buildSkillMarkdown(candidate, sanitizedSlug, timestamp);
|
|
137288
137356
|
try {
|
|
137289
|
-
await
|
|
137357
|
+
await _internals109.writeSkillFile(targetPath, skillMarkdown);
|
|
137290
137358
|
} catch (writeErr) {
|
|
137291
137359
|
const writeError = writeErr;
|
|
137292
137360
|
if (writeError?.code === "EEXIST") {
|
|
@@ -137363,7 +137431,7 @@ var external_skill_promote = createSwarmTool({
|
|
|
137363
137431
|
init_zod();
|
|
137364
137432
|
init_loader();
|
|
137365
137433
|
init_create_tool();
|
|
137366
|
-
var
|
|
137434
|
+
var _internals110 = {
|
|
137367
137435
|
loadConfig: (directory) => {
|
|
137368
137436
|
const pluginConfig = loadPluginConfig(directory);
|
|
137369
137437
|
return pluginConfig.external_skills;
|
|
@@ -137388,7 +137456,7 @@ var external_skill_reject = createSwarmTool({
|
|
|
137388
137456
|
} catch {}
|
|
137389
137457
|
let config3;
|
|
137390
137458
|
try {
|
|
137391
|
-
config3 =
|
|
137459
|
+
config3 = _internals110.loadConfig(directory);
|
|
137392
137460
|
} catch {
|
|
137393
137461
|
return JSON.stringify({
|
|
137394
137462
|
success: false,
|
|
@@ -137451,7 +137519,7 @@ init_zod();
|
|
|
137451
137519
|
init_loader();
|
|
137452
137520
|
import * as path175 from "node:path";
|
|
137453
137521
|
init_create_tool();
|
|
137454
|
-
var
|
|
137522
|
+
var _internals111 = {
|
|
137455
137523
|
loadConfig: (directory) => {
|
|
137456
137524
|
const pluginConfig = loadPluginConfig(directory);
|
|
137457
137525
|
return pluginConfig.external_skills;
|
|
@@ -137502,7 +137570,7 @@ var external_skill_revoke = createSwarmTool({
|
|
|
137502
137570
|
} catch {}
|
|
137503
137571
|
let config3;
|
|
137504
137572
|
try {
|
|
137505
|
-
config3 =
|
|
137573
|
+
config3 = _internals111.loadConfig(directory);
|
|
137506
137574
|
} catch {
|
|
137507
137575
|
return JSON.stringify({
|
|
137508
137576
|
success: false,
|
|
@@ -137549,8 +137617,8 @@ var external_skill_revoke = createSwarmTool({
|
|
|
137549
137617
|
});
|
|
137550
137618
|
}
|
|
137551
137619
|
const skillPath = path175.join(directory, ".opencode", "skills", "generated", slug, "SKILL.md");
|
|
137552
|
-
const skillFileRemoved = await
|
|
137553
|
-
const timestamp =
|
|
137620
|
+
const skillFileRemoved = await _internals111.retireSkillFile(skillPath);
|
|
137621
|
+
const timestamp = _internals111.getTimestamp();
|
|
137554
137622
|
const historyEntry = {
|
|
137555
137623
|
verdict: "revoked",
|
|
137556
137624
|
timestamp,
|
|
@@ -138071,7 +138139,7 @@ var ISSUE_FIELD_ALLOWLIST = new Set([
|
|
|
138071
138139
|
"updatedAt"
|
|
138072
138140
|
]);
|
|
138073
138141
|
function resolveGhBinary() {
|
|
138074
|
-
return
|
|
138142
|
+
return _internals112.resolveExecutableFromPath(["gh"]);
|
|
138075
138143
|
}
|
|
138076
138144
|
function normalizeRepo(value) {
|
|
138077
138145
|
if (value === undefined || value === null || value === "")
|
|
@@ -138159,7 +138227,7 @@ var gh_evidence = createSwarmTool({
|
|
|
138159
138227
|
if (!Array.isArray(fields)) {
|
|
138160
138228
|
return JSON.stringify(fields, null, 2);
|
|
138161
138229
|
}
|
|
138162
|
-
const executable =
|
|
138230
|
+
const executable = _internals112.resolveGhBinary();
|
|
138163
138231
|
if (!executable) {
|
|
138164
138232
|
return JSON.stringify({
|
|
138165
138233
|
error: true,
|
|
@@ -138171,7 +138239,7 @@ var gh_evidence = createSwarmTool({
|
|
|
138171
138239
|
if (repo) {
|
|
138172
138240
|
ghArgs.push("--repo", repo);
|
|
138173
138241
|
}
|
|
138174
|
-
const run = await
|
|
138242
|
+
const run = await _internals112.runExternalTool({
|
|
138175
138243
|
executable,
|
|
138176
138244
|
args: ghArgs,
|
|
138177
138245
|
cwd: directory,
|
|
@@ -138222,7 +138290,7 @@ var gh_evidence = createSwarmTool({
|
|
|
138222
138290
|
}, null, 2);
|
|
138223
138291
|
}
|
|
138224
138292
|
});
|
|
138225
|
-
var
|
|
138293
|
+
var _internals112 = {
|
|
138226
138294
|
resolveExecutableFromPath,
|
|
138227
138295
|
resolveGhBinary,
|
|
138228
138296
|
runExternalTool
|
|
@@ -140232,7 +140300,7 @@ init_zod();
|
|
|
140232
140300
|
init_config();
|
|
140233
140301
|
init_state2();
|
|
140234
140302
|
init_create_tool();
|
|
140235
|
-
var
|
|
140303
|
+
var _internals113 = {
|
|
140236
140304
|
LeanTurboRunner,
|
|
140237
140305
|
loadPluginConfigWithMeta
|
|
140238
140306
|
};
|
|
@@ -140242,9 +140310,9 @@ async function executeLeanTurboRunPhase(args2) {
|
|
|
140242
140310
|
let runError = null;
|
|
140243
140311
|
let runner = null;
|
|
140244
140312
|
try {
|
|
140245
|
-
const { config: config3 } =
|
|
140313
|
+
const { config: config3 } = _internals113.loadPluginConfigWithMeta(directory);
|
|
140246
140314
|
const leanConfig = config3.turbo?.strategy === "lean" ? config3.turbo.lean : undefined;
|
|
140247
|
-
runner = new
|
|
140315
|
+
runner = new _internals113.LeanTurboRunner({
|
|
140248
140316
|
directory,
|
|
140249
140317
|
sessionID,
|
|
140250
140318
|
opencodeClient: swarmState.opencodeClient ?? null,
|
|
@@ -140580,7 +140648,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
140580
140648
|
const strippedMutated = stripCode(mutatedCode);
|
|
140581
140649
|
return strippedOriginal === strippedMutated;
|
|
140582
140650
|
}
|
|
140583
|
-
var
|
|
140651
|
+
var _internals114 = {
|
|
140584
140652
|
isStaticallyEquivalent,
|
|
140585
140653
|
checkEquivalence,
|
|
140586
140654
|
batchCheckEquivalence
|
|
@@ -140620,7 +140688,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
140620
140688
|
const results = [];
|
|
140621
140689
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
140622
140690
|
try {
|
|
140623
|
-
const result = await
|
|
140691
|
+
const result = await _internals114.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
140624
140692
|
results.push(result);
|
|
140625
140693
|
} catch (err) {
|
|
140626
140694
|
results.push({
|
|
@@ -140680,7 +140748,7 @@ function validateTestCommand(testCommand) {
|
|
|
140680
140748
|
var MUTATION_TIMEOUT_MS = 30000;
|
|
140681
140749
|
var TOTAL_BUDGET_MS = 300000;
|
|
140682
140750
|
var GIT_APPLY_TIMEOUT_MS = 5000;
|
|
140683
|
-
var
|
|
140751
|
+
var _internals115 = {
|
|
140684
140752
|
executeMutation,
|
|
140685
140753
|
computeReport,
|
|
140686
140754
|
executeMutationSuite,
|
|
@@ -140712,7 +140780,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
140712
140780
|
};
|
|
140713
140781
|
}
|
|
140714
140782
|
try {
|
|
140715
|
-
const applyResult =
|
|
140783
|
+
const applyResult = _internals115.spawnSync("git", ["apply", "--", patchFile], {
|
|
140716
140784
|
cwd: workingDir,
|
|
140717
140785
|
timeout: GIT_APPLY_TIMEOUT_MS,
|
|
140718
140786
|
stdio: "pipe"
|
|
@@ -140743,7 +140811,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
140743
140811
|
try {
|
|
140744
140812
|
const safeTestFiles = testFiles.filter((f) => !f.startsWith("-"));
|
|
140745
140813
|
const testArgs = safeTestFiles.length > 0 ? [...testCommand.slice(1), ...safeTestFiles] : testCommand.slice(1);
|
|
140746
|
-
const spawnResult =
|
|
140814
|
+
const spawnResult = _internals115.spawnSync(testCommand[0], testArgs, {
|
|
140747
140815
|
cwd: workingDir,
|
|
140748
140816
|
timeout: MUTATION_TIMEOUT_MS,
|
|
140749
140817
|
stdio: "pipe"
|
|
@@ -140776,7 +140844,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
|
|
|
140776
140844
|
} finally {
|
|
140777
140845
|
if (patchFile) {
|
|
140778
140846
|
try {
|
|
140779
|
-
const revertResult =
|
|
140847
|
+
const revertResult = _internals115.spawnSync("git", ["apply", "-R", "--", patchFile], {
|
|
140780
140848
|
cwd: workingDir,
|
|
140781
140849
|
timeout: GIT_APPLY_TIMEOUT_MS,
|
|
140782
140850
|
stdio: "pipe"
|
|
@@ -140973,7 +141041,7 @@ async function executeMutationSuite(patches, testCommand, testFiles, workingDir,
|
|
|
140973
141041
|
}
|
|
140974
141042
|
|
|
140975
141043
|
// src/mutation/gate.ts
|
|
140976
|
-
var
|
|
141044
|
+
var _internals116 = {
|
|
140977
141045
|
evaluateMutationGate,
|
|
140978
141046
|
buildTestImprovementPrompt,
|
|
140979
141047
|
buildMessage
|
|
@@ -140994,8 +141062,8 @@ function evaluateMutationGate(report, passThreshold = PASS_THRESHOLD, warnThresh
|
|
|
140994
141062
|
} else {
|
|
140995
141063
|
verdict = "fail";
|
|
140996
141064
|
}
|
|
140997
|
-
const testImprovementPrompt =
|
|
140998
|
-
const message =
|
|
141065
|
+
const testImprovementPrompt = _internals116.buildTestImprovementPrompt(report, passThreshold, verdict);
|
|
141066
|
+
const message = _internals116.buildMessage(verdict, adjustedKillRate, report.killed, report.totalMutants, report.equivalent, warnThreshold);
|
|
140999
141067
|
return {
|
|
141000
141068
|
verdict,
|
|
141001
141069
|
killRate: report.killRate,
|
|
@@ -141140,7 +141208,7 @@ var OSV_MAX_STDERR_BYTES = 256 * 1024;
|
|
|
141140
141208
|
var DEFAULT_MAX_RESULTS3 = 200;
|
|
141141
141209
|
var HARD_CAP_RESULTS3 = 2000;
|
|
141142
141210
|
function resolveOsvScannerBinary() {
|
|
141143
|
-
return
|
|
141211
|
+
return _internals117.resolveExecutableFromPath(["osv-scanner"]);
|
|
141144
141212
|
}
|
|
141145
141213
|
function normalizeScanPath(value, workspace) {
|
|
141146
141214
|
const raw = typeof value === "string" && value.trim() ? value.trim() : ".";
|
|
@@ -141228,7 +141296,7 @@ var osv_scan = createSwarmTool({
|
|
|
141228
141296
|
}, null, 2);
|
|
141229
141297
|
}
|
|
141230
141298
|
const maxResults = sanitizeMaxResults2(obj.max_results);
|
|
141231
|
-
const executable =
|
|
141299
|
+
const executable = _internals117.resolveOsvScannerBinary();
|
|
141232
141300
|
if (!executable) {
|
|
141233
141301
|
return JSON.stringify({
|
|
141234
141302
|
error: true,
|
|
@@ -141238,7 +141306,7 @@ var osv_scan = createSwarmTool({
|
|
|
141238
141306
|
}
|
|
141239
141307
|
const target = scanPath === "." ? "." : `./${scanPath}`;
|
|
141240
141308
|
const osvArgs = ["scan", "--format", "json", target];
|
|
141241
|
-
const run = await
|
|
141309
|
+
const run = await _internals117.runExternalTool({
|
|
141242
141310
|
executable,
|
|
141243
141311
|
args: osvArgs,
|
|
141244
141312
|
cwd: directory,
|
|
@@ -141288,7 +141356,7 @@ var osv_scan = createSwarmTool({
|
|
|
141288
141356
|
}, null, 2);
|
|
141289
141357
|
}
|
|
141290
141358
|
});
|
|
141291
|
-
var
|
|
141359
|
+
var _internals117 = {
|
|
141292
141360
|
resolveExecutableFromPath,
|
|
141293
141361
|
resolveOsvScannerBinary,
|
|
141294
141362
|
runExternalTool,
|
|
@@ -142092,6 +142160,7 @@ var parse_lane_candidates = createSwarmTool({
|
|
|
142092
142160
|
// src/tools/phase-complete.ts
|
|
142093
142161
|
init_zod();
|
|
142094
142162
|
init_config();
|
|
142163
|
+
init_plan_schema();
|
|
142095
142164
|
init_schema();
|
|
142096
142165
|
init_manager2();
|
|
142097
142166
|
init_task_file();
|
|
@@ -142986,7 +143055,7 @@ function listLaneEvidenceSync(directory, phase) {
|
|
|
142986
143055
|
}
|
|
142987
143056
|
return laneIds;
|
|
142988
143057
|
}
|
|
142989
|
-
var
|
|
143058
|
+
var _internals118 = {
|
|
142990
143059
|
listActiveLocks,
|
|
142991
143060
|
readPersisted: readPersisted3,
|
|
142992
143061
|
readPlanJson: defaultReadPlanJson,
|
|
@@ -143047,7 +143116,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143047
143116
|
reason: "Lean Turbo state unreadable or missing"
|
|
143048
143117
|
};
|
|
143049
143118
|
}
|
|
143050
|
-
const persisted =
|
|
143119
|
+
const persisted = _internals118.readPersisted(directory);
|
|
143051
143120
|
if (!persisted) {
|
|
143052
143121
|
return {
|
|
143053
143122
|
ok: false,
|
|
@@ -143111,7 +143180,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143111
143180
|
}
|
|
143112
143181
|
}
|
|
143113
143182
|
if (runState.lanes.length > 0) {
|
|
143114
|
-
const evidenceLaneIds = new Set(
|
|
143183
|
+
const evidenceLaneIds = new Set(_internals118.listLaneEvidenceSync(directory, phase));
|
|
143115
143184
|
for (const lane of runState.lanes) {
|
|
143116
143185
|
if ((lane.status === "completed" || lane.status === "failed") && !evidenceLaneIds.has(lane.laneId)) {
|
|
143117
143186
|
return {
|
|
@@ -143121,7 +143190,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143121
143190
|
}
|
|
143122
143191
|
}
|
|
143123
143192
|
}
|
|
143124
|
-
const activeLocks =
|
|
143193
|
+
const activeLocks = _internals118.listActiveLocks(directory);
|
|
143125
143194
|
const phaseLaneIds = new Set(laneIds);
|
|
143126
143195
|
for (const lock of activeLocks) {
|
|
143127
143196
|
if (lock.laneId && phaseLaneIds.has(lock.laneId)) {
|
|
@@ -143141,7 +143210,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143141
143210
|
}
|
|
143142
143211
|
const serialDegradedTasks = runState.degradedTasks.filter((dt) => !laneTaskIds.has(dt.taskId));
|
|
143143
143212
|
if (serialDegradedTasks.length > 0) {
|
|
143144
|
-
const plan =
|
|
143213
|
+
const plan = _internals118.readPlanJson(directory);
|
|
143145
143214
|
if (!plan) {
|
|
143146
143215
|
return {
|
|
143147
143216
|
ok: false,
|
|
@@ -143185,7 +143254,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143185
143254
|
}
|
|
143186
143255
|
const serializedTasks = runState.serializedTasks;
|
|
143187
143256
|
if (Array.isArray(serializedTasks) && serializedTasks.length > 0) {
|
|
143188
|
-
const plan =
|
|
143257
|
+
const plan = _internals118.readPlanJson(directory);
|
|
143189
143258
|
if (!plan) {
|
|
143190
143259
|
return {
|
|
143191
143260
|
ok: false,
|
|
@@ -143244,7 +143313,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143244
143313
|
}
|
|
143245
143314
|
let reviewerVerdict = runState.lastReviewerVerdict;
|
|
143246
143315
|
if (!reviewerVerdict) {
|
|
143247
|
-
const evidence =
|
|
143316
|
+
const evidence = _internals118.readReviewerEvidence(directory, phase);
|
|
143248
143317
|
reviewerVerdict = evidence?.verdict ?? undefined;
|
|
143249
143318
|
}
|
|
143250
143319
|
if (mergedConfig.phase_reviewer) {
|
|
@@ -143257,7 +143326,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
|
|
|
143257
143326
|
}
|
|
143258
143327
|
let criticVerdict = runState.lastCriticVerdict;
|
|
143259
143328
|
if (!criticVerdict) {
|
|
143260
|
-
const evidence =
|
|
143329
|
+
const evidence = _internals118.readCriticEvidence(directory, phase);
|
|
143261
143330
|
criticVerdict = evidence?.verdict ?? undefined;
|
|
143262
143331
|
}
|
|
143263
143332
|
if (mergedConfig.phase_critic) {
|
|
@@ -144243,6 +144312,29 @@ function collectCrossSessionDispatchedAgents(phaseReferenceTimestamp, callerSess
|
|
|
144243
144312
|
}
|
|
144244
144313
|
return { agents, contributorSessionIds };
|
|
144245
144314
|
}
|
|
144315
|
+
async function fallbackWritePlanWithTrace(dir, planPath, candidate, phase, warnings) {
|
|
144316
|
+
const validation2 = PlanSchema.safeParse(candidate);
|
|
144317
|
+
if (!validation2.success) {
|
|
144318
|
+
const detail = validation2.error.issues.slice(0, 5).map((issue3) => `${issue3.path.join(".") || "<root>"}: ${issue3.message}`).join("; ");
|
|
144319
|
+
warn("[phase_complete] Last-resort plan.json write aborted — mutated plan failed PlanSchema validation:", detail);
|
|
144320
|
+
warnings.push(`Warning: last-resort plan.json write skipped — mutated plan failed schema validation (${detail})`);
|
|
144321
|
+
return false;
|
|
144322
|
+
}
|
|
144323
|
+
await atomicWriteFile(planPath, JSON.stringify(validation2.data, null, 2));
|
|
144324
|
+
try {
|
|
144325
|
+
const traceEvent = {
|
|
144326
|
+
event: "phase_complete_fallback_write",
|
|
144327
|
+
phase,
|
|
144328
|
+
timestamp: new Date().toISOString()
|
|
144329
|
+
};
|
|
144330
|
+
const eventsPath = validateSwarmPath(dir, "events.jsonl");
|
|
144331
|
+
fs125.appendFileSync(eventsPath, `${JSON.stringify(traceEvent)}
|
|
144332
|
+
`, "utf-8");
|
|
144333
|
+
} catch (eventError) {
|
|
144334
|
+
warnings.push(`Warning: failed to record phase_complete_fallback_write trace event: ${eventError instanceof Error ? eventError.message : String(eventError)}`);
|
|
144335
|
+
}
|
|
144336
|
+
return true;
|
|
144337
|
+
}
|
|
144246
144338
|
function _getDelegationsSince(sessionID, sinceTimestamp) {
|
|
144247
144339
|
const chain = swarmState.delegationChains.get(sessionID);
|
|
144248
144340
|
if (!chain) {
|
|
@@ -144548,7 +144640,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
144548
144640
|
phase_critic: leanConfig.phase_critic,
|
|
144549
144641
|
integrated_diff_required: leanConfig.integrated_diff_required
|
|
144550
144642
|
} : undefined;
|
|
144551
|
-
const leanCheck =
|
|
144643
|
+
const leanCheck = _internals118.verifyLeanTurboPhaseReady(dir, phase, sessionID, leanPhaseReadyConfig);
|
|
144552
144644
|
if (!leanCheck.ok) {
|
|
144553
144645
|
return JSON.stringify({
|
|
144554
144646
|
success: false,
|
|
@@ -144959,6 +145051,22 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
144959
145051
|
}
|
|
144960
145052
|
try {
|
|
144961
145053
|
const plan = await loadPlan(dir);
|
|
145054
|
+
const runtimePlan = plan;
|
|
145055
|
+
if (runtimePlan?._ledgerReplayStale === true) {
|
|
145056
|
+
const staleReason = runtimePlan._ledgerReplayStaleReason ?? "unknown reason";
|
|
145057
|
+
return JSON.stringify({
|
|
145058
|
+
success: false,
|
|
145059
|
+
phase: args2.phase,
|
|
145060
|
+
status: "incomplete",
|
|
145061
|
+
message: `Plan write refused: plan.json is stale from a failed ledger replay (${staleReason}). Refusing to complete phase ${args2.phase} against a known-stale plan.`,
|
|
145062
|
+
agentsDispatched,
|
|
145063
|
+
agentsMissing,
|
|
145064
|
+
warnings,
|
|
145065
|
+
errors: [`Stale plan from failed ledger replay: ${staleReason}`],
|
|
145066
|
+
recovery_guidance: "The ledger replay failed and no critic-approved snapshot was available, so loadPlan fell back to a stale plan.json. Do NOT retry blindly. Recover first: re-verify the plan (re-run completion verification), reset the session, or restore from the latest checkpoint under .swarm/plan-export/, then retry phase_complete.",
|
|
145067
|
+
_ledgerReplayStaleReason: staleReason
|
|
145068
|
+
});
|
|
145069
|
+
}
|
|
144962
145070
|
if (plan === null) {
|
|
144963
145071
|
if (await ledgerExists(dir)) {
|
|
144964
145072
|
try {
|
|
@@ -144985,7 +145093,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
144985
145093
|
const phaseObj = plan2.phases.find((p) => p.id === phase);
|
|
144986
145094
|
if (phaseObj) {
|
|
144987
145095
|
phaseObj.status = "complete";
|
|
144988
|
-
await
|
|
145096
|
+
await fallbackWritePlanWithTrace(dir, planPath, plan2, phase, warnings);
|
|
144989
145097
|
}
|
|
144990
145098
|
} catch {}
|
|
144991
145099
|
} else if (plan) {
|
|
@@ -145027,7 +145135,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
|
|
|
145027
145135
|
const phaseObj = plan.phases.find((p) => p.id === phase);
|
|
145028
145136
|
if (phaseObj) {
|
|
145029
145137
|
phaseObj.status = "complete";
|
|
145030
|
-
await
|
|
145138
|
+
await fallbackWritePlanWithTrace(dir, planPath, plan, phase, warnings);
|
|
145031
145139
|
}
|
|
145032
145140
|
} catch {}
|
|
145033
145141
|
} finally {
|
|
@@ -146945,11 +147053,11 @@ var quality_budget = createSwarmTool({
|
|
|
146945
147053
|
}).optional().describe("Quality budget thresholds")
|
|
146946
147054
|
},
|
|
146947
147055
|
async execute(args2, directory) {
|
|
146948
|
-
const result = await
|
|
147056
|
+
const result = await _internals120.qualityBudget(args2, directory);
|
|
146949
147057
|
return JSON.stringify(result);
|
|
146950
147058
|
}
|
|
146951
147059
|
});
|
|
146952
|
-
var
|
|
147060
|
+
var _internals120 = {
|
|
146953
147061
|
qualityBudget
|
|
146954
147062
|
};
|
|
146955
147063
|
|
|
@@ -147674,7 +147782,7 @@ var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
|
147674
147782
|
var DEFAULT_TIMEOUT_MS4 = 30000;
|
|
147675
147783
|
var MAX_OUTPUT_BYTES8 = 10 * 1024 * 1024;
|
|
147676
147784
|
var KILL_GRACE_MS = 2000;
|
|
147677
|
-
var
|
|
147785
|
+
var _internals121 = {
|
|
147678
147786
|
isSemgrepAvailable,
|
|
147679
147787
|
checkSemgrepAvailable,
|
|
147680
147788
|
resetSemgrepCache,
|
|
@@ -147700,7 +147808,7 @@ function isSemgrepAvailable() {
|
|
|
147700
147808
|
}
|
|
147701
147809
|
}
|
|
147702
147810
|
async function checkSemgrepAvailable() {
|
|
147703
|
-
return
|
|
147811
|
+
return _internals121.isSemgrepAvailable();
|
|
147704
147812
|
}
|
|
147705
147813
|
function resetSemgrepCache() {
|
|
147706
147814
|
semgrepAvailableCache = null;
|
|
@@ -147886,12 +147994,12 @@ async function runSemgrep(options) {
|
|
|
147886
147994
|
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS4;
|
|
147887
147995
|
if (files.length === 0) {
|
|
147888
147996
|
return {
|
|
147889
|
-
available:
|
|
147997
|
+
available: _internals121.isSemgrepAvailable(),
|
|
147890
147998
|
findings: [],
|
|
147891
147999
|
engine: "tier_a"
|
|
147892
148000
|
};
|
|
147893
148001
|
}
|
|
147894
|
-
if (!
|
|
148002
|
+
if (!_internals121.isSemgrepAvailable()) {
|
|
147895
148003
|
return {
|
|
147896
148004
|
available: false,
|
|
147897
148005
|
findings: [],
|
|
@@ -148058,7 +148166,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
148058
148166
|
}
|
|
148059
148167
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
148060
148168
|
countMap.set(baseKey, occIdx + 1);
|
|
148061
|
-
const fp =
|
|
148169
|
+
const fp = _internals122.fingerprintFinding(finding, directory, occIdx);
|
|
148062
148170
|
return {
|
|
148063
148171
|
finding,
|
|
148064
148172
|
index: occIdx,
|
|
@@ -148127,7 +148235,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
148127
148235
|
}
|
|
148128
148236
|
} catch {}
|
|
148129
148237
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
148130
|
-
const indexed =
|
|
148238
|
+
const indexed = _internals122.assignOccurrenceIndices(findings, directory);
|
|
148131
148239
|
if (existing && !opts?.force) {
|
|
148132
148240
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
148133
148241
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -148267,7 +148375,7 @@ function loadBaseline(directory, phase) {
|
|
|
148267
148375
|
};
|
|
148268
148376
|
}
|
|
148269
148377
|
}
|
|
148270
|
-
var
|
|
148378
|
+
var _internals122 = {
|
|
148271
148379
|
fingerprintFinding,
|
|
148272
148380
|
assignOccurrenceIndices,
|
|
148273
148381
|
captureOrMergeBaseline,
|
|
@@ -148677,11 +148785,11 @@ var sast_scan = createSwarmTool({
|
|
|
148677
148785
|
capture_baseline: safeArgs.capture_baseline,
|
|
148678
148786
|
phase: safeArgs.phase
|
|
148679
148787
|
};
|
|
148680
|
-
const result = await
|
|
148788
|
+
const result = await _internals123.sastScan(input, directory);
|
|
148681
148789
|
return JSON.stringify(result, null, 2);
|
|
148682
148790
|
}
|
|
148683
148791
|
});
|
|
148684
|
-
var
|
|
148792
|
+
var _internals123 = {
|
|
148685
148793
|
sastScan,
|
|
148686
148794
|
sast_scan
|
|
148687
148795
|
};
|
|
@@ -152255,10 +152363,10 @@ function resolvePackagedRipgrep() {
|
|
|
152255
152363
|
}
|
|
152256
152364
|
}
|
|
152257
152365
|
function resolveRipgrepBinary() {
|
|
152258
|
-
return
|
|
152366
|
+
return _internals124.resolvePackagedRipgrep() ?? _internals124.resolveExecutableFromPath(["rg"]);
|
|
152259
152367
|
}
|
|
152260
152368
|
async function ripgrepSearch(opts) {
|
|
152261
|
-
const rgPath =
|
|
152369
|
+
const rgPath = _internals124.resolveRipgrepBinary();
|
|
152262
152370
|
if (!rgPath) {
|
|
152263
152371
|
return {
|
|
152264
152372
|
error: true,
|
|
@@ -152281,7 +152389,7 @@ async function ripgrepSearch(opts) {
|
|
|
152281
152389
|
args2.push("--fixed-strings");
|
|
152282
152390
|
}
|
|
152283
152391
|
args2.push("--", opts.query, ".");
|
|
152284
|
-
const run = await
|
|
152392
|
+
const run = await _internals124.runExternalTool({
|
|
152285
152393
|
executable: rgPath,
|
|
152286
152394
|
args: args2,
|
|
152287
152395
|
cwd: opts.workspace,
|
|
@@ -152585,7 +152693,7 @@ var search = createSwarmTool({
|
|
|
152585
152693
|
}, null, 2);
|
|
152586
152694
|
}
|
|
152587
152695
|
let result;
|
|
152588
|
-
if (
|
|
152696
|
+
if (_internals124.resolveRipgrepBinary()) {
|
|
152589
152697
|
result = await ripgrepSearch({
|
|
152590
152698
|
query,
|
|
152591
152699
|
mode,
|
|
@@ -152612,7 +152720,7 @@ var search = createSwarmTool({
|
|
|
152612
152720
|
return JSON.stringify(result, null, 2);
|
|
152613
152721
|
}
|
|
152614
152722
|
});
|
|
152615
|
-
var
|
|
152723
|
+
var _internals124 = {
|
|
152616
152724
|
resolvePackagedRipgrep,
|
|
152617
152725
|
resolveExecutableFromPath,
|
|
152618
152726
|
resolveRipgrepBinary,
|
|
@@ -152973,18 +153081,18 @@ var run_stale_reconciliation = createSwarmTool({
|
|
|
152973
153081
|
if (typeof directory !== "string" || !directory) {
|
|
152974
153082
|
return JSON.stringify({ found: 0, skills: [] }, null, 2);
|
|
152975
153083
|
}
|
|
152976
|
-
const archivedIds = await
|
|
153084
|
+
const archivedIds = await _internals125.getArchivedKnowledgeIds(directory);
|
|
152977
153085
|
const archivedSet = new Set(archivedIds);
|
|
152978
153086
|
const allKnownIds = new Set;
|
|
152979
|
-
const swarmPath =
|
|
152980
|
-
const hivePath =
|
|
153087
|
+
const swarmPath = _internals125.resolveSwarmKnowledgePath(directory);
|
|
153088
|
+
const hivePath = _internals125.resolveHiveKnowledgePath();
|
|
152981
153089
|
try {
|
|
152982
|
-
const swarmEntries = await
|
|
153090
|
+
const swarmEntries = await _internals125.readKnowledge(swarmPath);
|
|
152983
153091
|
for (const e of swarmEntries)
|
|
152984
153092
|
allKnownIds.add(e.id);
|
|
152985
153093
|
} catch {}
|
|
152986
153094
|
try {
|
|
152987
|
-
const hiveEntries = await
|
|
153095
|
+
const hiveEntries = await _internals125.readKnowledge(hivePath);
|
|
152988
153096
|
for (const e of hiveEntries)
|
|
152989
153097
|
allKnownIds.add(e.id);
|
|
152990
153098
|
} catch {}
|
|
@@ -152993,9 +153101,9 @@ var run_stale_reconciliation = createSwarmTool({
|
|
|
152993
153101
|
join166(directory, ".opencode", "skills", "generated"),
|
|
152994
153102
|
join166(directory, ".swarm", "skills", "proposals")
|
|
152995
153103
|
]) {
|
|
152996
|
-
if (!
|
|
153104
|
+
if (!_internals125.existsSync(dir))
|
|
152997
153105
|
continue;
|
|
152998
|
-
const entries = await
|
|
153106
|
+
const entries = await _internals125.readdir(dir, { withFileTypes: true });
|
|
152999
153107
|
for (const entry of entries) {
|
|
153000
153108
|
if (entry.isDirectory()) {
|
|
153001
153109
|
skillEntries.push({
|
|
@@ -153016,10 +153124,10 @@ var run_stale_reconciliation = createSwarmTool({
|
|
|
153016
153124
|
const results = [];
|
|
153017
153125
|
for (const { slug, path: path210, isProposal } of skillEntries) {
|
|
153018
153126
|
const skillMdPath = isProposal ? path210 : join166(path210, "SKILL.md");
|
|
153019
|
-
if (!
|
|
153127
|
+
if (!_internals125.existsSync(skillMdPath))
|
|
153020
153128
|
continue;
|
|
153021
|
-
const content = await
|
|
153022
|
-
const fm =
|
|
153129
|
+
const content = await _internals125.readFile(skillMdPath, "utf-8");
|
|
153130
|
+
const fm = _internals125.parseDraftFrontmatter(content);
|
|
153023
153131
|
const sourceIds = fm?.sourceKnowledgeIds ?? [];
|
|
153024
153132
|
if (sourceIds.length === 0)
|
|
153025
153133
|
continue;
|
|
@@ -153029,9 +153137,9 @@ var run_stale_reconciliation = createSwarmTool({
|
|
|
153029
153137
|
if (args2.clear) {
|
|
153030
153138
|
if (!isProposal) {
|
|
153031
153139
|
const markerPath = join166(path210, "stale.marker");
|
|
153032
|
-
if (
|
|
153140
|
+
if (_internals125.existsSync(markerPath)) {
|
|
153033
153141
|
try {
|
|
153034
|
-
await
|
|
153142
|
+
await _internals125.clearSkillStale(path210);
|
|
153035
153143
|
results.push({
|
|
153036
153144
|
slug,
|
|
153037
153145
|
reason: affected.join(", "),
|
|
@@ -153043,7 +153151,7 @@ var run_stale_reconciliation = createSwarmTool({
|
|
|
153043
153151
|
} else {
|
|
153044
153152
|
if (!isProposal) {
|
|
153045
153153
|
try {
|
|
153046
|
-
await
|
|
153154
|
+
await _internals125.retireOrMarkStale(directory, path210, archivedSet);
|
|
153047
153155
|
results.push({
|
|
153048
153156
|
slug,
|
|
153049
153157
|
reason: affected.join(", "),
|
|
@@ -153056,7 +153164,7 @@ var run_stale_reconciliation = createSwarmTool({
|
|
|
153056
153164
|
return JSON.stringify({ found: results.length, skills: results }, null, 2);
|
|
153057
153165
|
}
|
|
153058
153166
|
});
|
|
153059
|
-
var
|
|
153167
|
+
var _internals125 = {
|
|
153060
153168
|
run_stale_reconciliation,
|
|
153061
153169
|
clearSkillStale,
|
|
153062
153170
|
retireOrMarkStale,
|
|
@@ -154034,7 +154142,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
154034
154142
|
evidenceRefs: exports_external.array(exports_external.string().min(1).max(500)).max(20).optional().describe("Evidence refs such as files, commits, test outputs, or URLs")
|
|
154035
154143
|
},
|
|
154036
154144
|
execute: async (args2, directory, ctx) => {
|
|
154037
|
-
const { config: config3 } =
|
|
154145
|
+
const { config: config3 } = _internals126.loadPluginConfigWithMeta(directory);
|
|
154038
154146
|
if (config3.memory?.enabled !== true) {
|
|
154039
154147
|
return JSON.stringify({
|
|
154040
154148
|
success: false,
|
|
@@ -154050,7 +154158,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
154050
154158
|
});
|
|
154051
154159
|
}
|
|
154052
154160
|
const agent = getContextAgent3(ctx);
|
|
154053
|
-
const gateway =
|
|
154161
|
+
const gateway = _internals126.createMemoryGateway({
|
|
154054
154162
|
directory,
|
|
154055
154163
|
sessionID: ctx?.sessionID,
|
|
154056
154164
|
agentRole: agent,
|
|
@@ -154075,7 +154183,7 @@ var swarm_memory_propose = createSwarmTool({
|
|
|
154075
154183
|
}
|
|
154076
154184
|
}
|
|
154077
154185
|
});
|
|
154078
|
-
var
|
|
154186
|
+
var _internals126 = {
|
|
154079
154187
|
loadPluginConfigWithMeta,
|
|
154080
154188
|
createMemoryGateway
|
|
154081
154189
|
};
|
|
@@ -154113,7 +154221,7 @@ var swarm_memory_recall = createSwarmTool({
|
|
|
154113
154221
|
maxItems: exports_external.number().int().min(1).max(20).optional().describe("Maximum memories to return")
|
|
154114
154222
|
},
|
|
154115
154223
|
execute: async (args2, directory, ctx) => {
|
|
154116
|
-
const { config: config3 } =
|
|
154224
|
+
const { config: config3 } = _internals127.loadPluginConfigWithMeta(directory);
|
|
154117
154225
|
if (config3.memory?.enabled !== true) {
|
|
154118
154226
|
return JSON.stringify({
|
|
154119
154227
|
success: false,
|
|
@@ -154129,7 +154237,7 @@ var swarm_memory_recall = createSwarmTool({
|
|
|
154129
154237
|
});
|
|
154130
154238
|
}
|
|
154131
154239
|
const agent = getContextAgent4(ctx);
|
|
154132
|
-
const gateway =
|
|
154240
|
+
const gateway = _internals127.createMemoryGateway({
|
|
154133
154241
|
directory,
|
|
154134
154242
|
sessionID: ctx?.sessionID,
|
|
154135
154243
|
agentRole: agent,
|
|
@@ -154162,7 +154270,7 @@ var RecallArgsSchema = exports_external.object({
|
|
|
154162
154270
|
kinds: exports_external.array(exports_external.enum(MEMORY_KINDS2)).optional(),
|
|
154163
154271
|
maxItems: exports_external.number().int().min(1).max(20).optional()
|
|
154164
154272
|
});
|
|
154165
|
-
var
|
|
154273
|
+
var _internals127 = {
|
|
154166
154274
|
loadPluginConfigWithMeta,
|
|
154167
154275
|
createMemoryGateway
|
|
154168
154276
|
};
|
|
@@ -154688,7 +154796,7 @@ import * as path215 from "node:path";
|
|
|
154688
154796
|
init_bun_compat();
|
|
154689
154797
|
import * as fs140 from "node:fs";
|
|
154690
154798
|
import * as path214 from "node:path";
|
|
154691
|
-
var
|
|
154799
|
+
var _internals128 = { bunSpawn };
|
|
154692
154800
|
var _swarmGitExcludedChecked = false;
|
|
154693
154801
|
function fileCoversSwarm(content) {
|
|
154694
154802
|
for (const rawLine of content.split(`
|
|
@@ -154721,7 +154829,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
154721
154829
|
checkIgnoreExitCode
|
|
154722
154830
|
] = await Promise.all([
|
|
154723
154831
|
(async () => {
|
|
154724
|
-
const proc =
|
|
154832
|
+
const proc = _internals128.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
|
|
154725
154833
|
try {
|
|
154726
154834
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
154727
154835
|
} finally {
|
|
@@ -154731,7 +154839,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
154731
154839
|
}
|
|
154732
154840
|
})(),
|
|
154733
154841
|
(async () => {
|
|
154734
|
-
const proc =
|
|
154842
|
+
const proc = _internals128.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
|
|
154735
154843
|
try {
|
|
154736
154844
|
return await Promise.all([proc.exited, proc.stdout.text()]);
|
|
154737
154845
|
} finally {
|
|
@@ -154741,7 +154849,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
154741
154849
|
}
|
|
154742
154850
|
})(),
|
|
154743
154851
|
(async () => {
|
|
154744
|
-
const proc =
|
|
154852
|
+
const proc = _internals128.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
|
|
154745
154853
|
try {
|
|
154746
154854
|
return await proc.exited;
|
|
154747
154855
|
} finally {
|
|
@@ -154780,7 +154888,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
154780
154888
|
}
|
|
154781
154889
|
} catch {}
|
|
154782
154890
|
}
|
|
154783
|
-
const trackedProc =
|
|
154891
|
+
const trackedProc = _internals128.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
|
|
154784
154892
|
let trackedExitCode;
|
|
154785
154893
|
let trackedOutput;
|
|
154786
154894
|
try {
|
|
@@ -154805,7 +154913,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
|
|
|
154805
154913
|
}
|
|
154806
154914
|
|
|
154807
154915
|
// src/hooks/diff-scope.ts
|
|
154808
|
-
var
|
|
154916
|
+
var _internals129 = { bunSpawn };
|
|
154809
154917
|
function getDeclaredScope(taskId, directory) {
|
|
154810
154918
|
try {
|
|
154811
154919
|
const planPath = path215.join(directory, ".swarm", "plan.json");
|
|
@@ -154840,7 +154948,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
|
|
|
154840
154948
|
};
|
|
154841
154949
|
async function getChangedFiles2(directory) {
|
|
154842
154950
|
try {
|
|
154843
|
-
const proc =
|
|
154951
|
+
const proc = _internals129.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
|
|
154844
154952
|
cwd: directory,
|
|
154845
154953
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
154846
154954
|
});
|
|
@@ -154857,7 +154965,7 @@ async function getChangedFiles2(directory) {
|
|
|
154857
154965
|
return stdout.trim().split(`
|
|
154858
154966
|
`).map((f) => f.trim()).filter((f) => f.length > 0);
|
|
154859
154967
|
}
|
|
154860
|
-
const proc2 =
|
|
154968
|
+
const proc2 = _internals129.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
|
|
154861
154969
|
cwd: directory,
|
|
154862
154970
|
...GIT_DIFF_SPAWN_OPTIONS
|
|
154863
154971
|
});
|
|
@@ -154916,7 +155024,7 @@ init_telemetry();
|
|
|
154916
155024
|
init_file_locks();
|
|
154917
155025
|
import * as fs142 from "node:fs";
|
|
154918
155026
|
import * as path216 from "node:path";
|
|
154919
|
-
var
|
|
155027
|
+
var _internals130 = {
|
|
154920
155028
|
listActiveLocks,
|
|
154921
155029
|
verifyLeanTurboTaskCompletion
|
|
154922
155030
|
};
|
|
@@ -155058,7 +155166,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
155058
155166
|
}
|
|
155059
155167
|
};
|
|
155060
155168
|
}
|
|
155061
|
-
const activeLocks =
|
|
155169
|
+
const activeLocks = _internals130.listActiveLocks(directory);
|
|
155062
155170
|
const laneLocks = activeLocks.filter((lock) => lock.laneId === lane.laneId);
|
|
155063
155171
|
if (laneLocks.length > 0) {
|
|
155064
155172
|
return {
|
|
@@ -155125,10 +155233,11 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
|
|
|
155125
155233
|
init_task_id();
|
|
155126
155234
|
init_create_tool();
|
|
155127
155235
|
init_resolve_working_directory();
|
|
155128
|
-
var
|
|
155236
|
+
var _internals131 = {
|
|
155129
155237
|
tryAcquireLock,
|
|
155130
155238
|
updateTaskStatus,
|
|
155131
|
-
resolveWorkingDirectory
|
|
155239
|
+
resolveWorkingDirectory,
|
|
155240
|
+
loadPlan
|
|
155132
155241
|
};
|
|
155133
155242
|
var VALID_STATUSES2 = [
|
|
155134
155243
|
"pending",
|
|
@@ -155222,7 +155331,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
|
|
|
155222
155331
|
}
|
|
155223
155332
|
let resolvedDir;
|
|
155224
155333
|
if (fallbackDir) {
|
|
155225
|
-
const resolveResult =
|
|
155334
|
+
const resolveResult = _internals131.resolveWorkingDirectory(workingDirectory, fallbackDir);
|
|
155226
155335
|
if (resolveResult.success) {
|
|
155227
155336
|
resolvedDir = resolveResult.directory;
|
|
155228
155337
|
} else {
|
|
@@ -155569,7 +155678,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
155569
155678
|
}
|
|
155570
155679
|
}
|
|
155571
155680
|
let directory;
|
|
155572
|
-
const resolveResult =
|
|
155681
|
+
const resolveResult = _internals131.resolveWorkingDirectory(args2.working_directory, fallbackDir);
|
|
155573
155682
|
if (!resolveResult.success) {
|
|
155574
155683
|
return {
|
|
155575
155684
|
success: false,
|
|
@@ -155599,6 +155708,21 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
155599
155708
|
};
|
|
155600
155709
|
}
|
|
155601
155710
|
}
|
|
155711
|
+
let loadedPlan = null;
|
|
155712
|
+
try {
|
|
155713
|
+
loadedPlan = await _internals131.loadPlan(directory);
|
|
155714
|
+
} catch {
|
|
155715
|
+
loadedPlan = null;
|
|
155716
|
+
}
|
|
155717
|
+
if (loadedPlan?._ledgerReplayStale === true) {
|
|
155718
|
+
const staleReason = loadedPlan._ledgerReplayStaleReason ?? "plan.json is stale relative to the authoritative ledger (.swarm/plan-ledger.jsonl)";
|
|
155719
|
+
return {
|
|
155720
|
+
success: false,
|
|
155721
|
+
message: `Task status update refused: plan.json is stale relative to the ledger (ledger replay failed). ${staleReason}`,
|
|
155722
|
+
errors: [staleReason],
|
|
155723
|
+
recovery_guidance: "Plan state could not be reconciled with the authoritative ledger (.swarm/plan-ledger.jsonl). " + "Restore from a critic-approved snapshot or re-run plan recovery to rebuild plan.json from the ledger, then retry update_task_status."
|
|
155724
|
+
};
|
|
155725
|
+
}
|
|
155602
155726
|
if (args2.status === "in_progress") {
|
|
155603
155727
|
try {
|
|
155604
155728
|
const evidencePath = path217.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
|
|
@@ -155662,7 +155786,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
155662
155786
|
}
|
|
155663
155787
|
let lockResult;
|
|
155664
155788
|
try {
|
|
155665
|
-
lockResult = await
|
|
155789
|
+
lockResult = await _internals131.tryAcquireLock(directory, planFilePath, agentName, lockTaskId);
|
|
155666
155790
|
} catch (error93) {
|
|
155667
155791
|
return {
|
|
155668
155792
|
success: false,
|
|
@@ -155681,7 +155805,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
|
|
|
155681
155805
|
};
|
|
155682
155806
|
}
|
|
155683
155807
|
try {
|
|
155684
|
-
const updatedPlan = await
|
|
155808
|
+
const updatedPlan = await _internals131.updateTaskStatus(directory, args2.task_id, args2.status);
|
|
155685
155809
|
if (args2.status === "completed") {
|
|
155686
155810
|
for (const [_sessionId, session] of swarmState.agentSessions) {
|
|
155687
155811
|
if (!(session.taskWorkflowStates instanceof Map)) {
|
|
@@ -156336,7 +156460,7 @@ var web_fetch = createSwarmTool({
|
|
|
156336
156460
|
};
|
|
156337
156461
|
return JSON.stringify(fail, null, 2);
|
|
156338
156462
|
}
|
|
156339
|
-
const config3 =
|
|
156463
|
+
const config3 = _internals132.loadPluginConfig(dirResult.directory);
|
|
156340
156464
|
const generalConfig = config3.council?.general;
|
|
156341
156465
|
if (!generalConfig || generalConfig.enabled !== true) {
|
|
156342
156466
|
const fail = {
|
|
@@ -156346,7 +156470,7 @@ var web_fetch = createSwarmTool({
|
|
|
156346
156470
|
};
|
|
156347
156471
|
return JSON.stringify(fail, null, 2);
|
|
156348
156472
|
}
|
|
156349
|
-
const validated = await validateFetchUrl(parsed.data.url,
|
|
156473
|
+
const validated = await validateFetchUrl(parsed.data.url, _internals132.dnsLookup);
|
|
156350
156474
|
if (!validated.ok) {
|
|
156351
156475
|
const fail = {
|
|
156352
156476
|
success: false,
|
|
@@ -156357,7 +156481,7 @@ var web_fetch = createSwarmTool({
|
|
|
156357
156481
|
}
|
|
156358
156482
|
const maxBytes = parsed.data.max_bytes ?? DEFAULT_MAX_BYTES;
|
|
156359
156483
|
const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS5;
|
|
156360
|
-
const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs,
|
|
156484
|
+
const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs, _internals132);
|
|
156361
156485
|
if (!result.ok) {
|
|
156362
156486
|
const fail = {
|
|
156363
156487
|
success: false,
|
|
@@ -156392,7 +156516,7 @@ var web_fetch = createSwarmTool({
|
|
|
156392
156516
|
});
|
|
156393
156517
|
async function captureFetchEvidence(directory, url3, title, text) {
|
|
156394
156518
|
try {
|
|
156395
|
-
const written = await
|
|
156519
|
+
const written = await _internals132.writeEvidenceDocuments(directory, [
|
|
156396
156520
|
{
|
|
156397
156521
|
sourceType: "crawl",
|
|
156398
156522
|
url: url3,
|
|
@@ -156413,7 +156537,7 @@ async function captureFetchEvidence(directory, url3, title, text) {
|
|
|
156413
156537
|
};
|
|
156414
156538
|
}
|
|
156415
156539
|
}
|
|
156416
|
-
var
|
|
156540
|
+
var _internals132 = {
|
|
156417
156541
|
httpRequest: performHttpRequest,
|
|
156418
156542
|
dnsLookup: lookup,
|
|
156419
156543
|
loadPluginConfig,
|
|
@@ -156727,7 +156851,7 @@ var web_search = createSwarmTool({
|
|
|
156727
156851
|
});
|
|
156728
156852
|
async function captureSearchEvidence(directory, query, results) {
|
|
156729
156853
|
try {
|
|
156730
|
-
const written = await
|
|
156854
|
+
const written = await _internals133.writeEvidenceDocuments(directory, results.map((result) => ({
|
|
156731
156855
|
sourceType: "web_search",
|
|
156732
156856
|
query,
|
|
156733
156857
|
title: result.title,
|
|
@@ -156755,7 +156879,7 @@ async function captureSearchEvidence(directory, query, results) {
|
|
|
156755
156879
|
};
|
|
156756
156880
|
}
|
|
156757
156881
|
}
|
|
156758
|
-
var
|
|
156882
|
+
var _internals133 = {
|
|
156759
156883
|
writeEvidenceDocuments
|
|
156760
156884
|
};
|
|
156761
156885
|
|
|
@@ -156963,7 +157087,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
156963
157087
|
message: "Invalid summary: must be a non-empty string"
|
|
156964
157088
|
}, null, 2);
|
|
156965
157089
|
}
|
|
156966
|
-
const normalizedVerdict =
|
|
157090
|
+
const normalizedVerdict = _internals134.normalizeVerdict2(args2.verdict);
|
|
156967
157091
|
const provenance = args2.provenanceAgentName || args2.provenanceSessionId ? {
|
|
156968
157092
|
agent_name: args2.provenanceAgentName,
|
|
156969
157093
|
session_id: args2.provenanceSessionId,
|
|
@@ -157060,7 +157184,7 @@ async function executeWriteDriftEvidence(args2, directory) {
|
|
|
157060
157184
|
}, null, 2);
|
|
157061
157185
|
}
|
|
157062
157186
|
}
|
|
157063
|
-
var
|
|
157187
|
+
var _internals134 = {
|
|
157064
157188
|
normalizeVerdict2,
|
|
157065
157189
|
VERDICT_SET_2,
|
|
157066
157190
|
isAcceptedVerdict2
|
|
@@ -157323,7 +157447,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
157323
157447
|
message: "Invalid summary: must be a non-empty string"
|
|
157324
157448
|
}, null, 2);
|
|
157325
157449
|
}
|
|
157326
|
-
const normalizedVerdict =
|
|
157450
|
+
const normalizedVerdict = _internals135.normalizeVerdict2(args2.verdict);
|
|
157327
157451
|
const evidenceEntry = {
|
|
157328
157452
|
type: "hallucination-verification",
|
|
157329
157453
|
verdict: normalizedVerdict,
|
|
@@ -157366,7 +157490,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
|
|
|
157366
157490
|
}, null, 2);
|
|
157367
157491
|
}
|
|
157368
157492
|
}
|
|
157369
|
-
var
|
|
157493
|
+
var _internals135 = {
|
|
157370
157494
|
normalizeVerdict2,
|
|
157371
157495
|
VERDICT_SET_2,
|
|
157372
157496
|
isAcceptedVerdict2
|
|
@@ -157447,7 +157571,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
157447
157571
|
message: "Invalid summary: must be a non-empty string"
|
|
157448
157572
|
}, null, 2);
|
|
157449
157573
|
}
|
|
157450
|
-
const normalizedVerdict =
|
|
157574
|
+
const normalizedVerdict = _internals136.normalizeVerdict4(args2.verdict);
|
|
157451
157575
|
const evidenceEntry = {
|
|
157452
157576
|
type: "mutation-gate",
|
|
157453
157577
|
verdict: normalizedVerdict,
|
|
@@ -157494,7 +157618,7 @@ async function executeWriteMutationEvidence(args2, directory) {
|
|
|
157494
157618
|
}, null, 2);
|
|
157495
157619
|
}
|
|
157496
157620
|
}
|
|
157497
|
-
var
|
|
157621
|
+
var _internals136 = {
|
|
157498
157622
|
normalizeVerdict4,
|
|
157499
157623
|
VERDICT_SET_4,
|
|
157500
157624
|
isAcceptedVerdict4
|