opencode-swarm 7.139.0 → 7.139.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/cli/{config-doctor-aszp7z1h.js → config-doctor-tgnr91q3.js} +2 -2
- package/dist/cli/{core-3s832mxx.js → core-g2dfh9fq.js} +1 -1
- package/dist/cli/{curation-policy-a3hs73f7.js → curation-policy-2qnhgdtt.js} +7 -7
- package/dist/cli/{curator-drift-jpap6hv4.js → curator-drift-vfh07mqy.js} +5 -2
- package/dist/cli/{curator-llm-factory-e8ngwyjm.js → curator-llm-factory-1ftzece0.js} +28 -28
- package/dist/cli/{curator-zxjqcc8r.js → curator-nbsag633.js} +28 -28
- package/dist/cli/{evidence-summary-service-qfhjfxdz.js → evidence-summary-service-kzxr71yd.js} +9 -9
- package/dist/cli/{gate-evidence-m2grv70v.js → gate-evidence-z2b1ymnw.js} +5 -5
- package/dist/cli/{guardrail-explain-rqpmzxyy.js → guardrail-explain-vb9k9zwm.js} +29 -29
- package/dist/cli/{guardrail-log-vd4a0ng5.js → guardrail-log-0djnvfas.js} +3 -3
- package/dist/cli/{hive-promoter-jc5vym27.js → hive-promoter-bpt26yew.js} +28 -28
- package/dist/cli/{index-4ft523nb.js → index-0wp67gqj.js} +143 -89
- package/dist/cli/{index-s428dmy6.js → index-0ymhx85c.js} +2 -2
- package/dist/cli/{index-rtetrxxq.js → index-15526t16.js} +8 -3
- package/dist/cli/{index-ymszzvnr.js → index-3eddtgxt.js} +1 -1
- package/dist/cli/{index-p2dz85tv.js → index-4xbyy6aw.js} +2 -2
- package/dist/cli/{index-a614s16f.js → index-5j6chvj8.js} +1 -1
- package/dist/cli/{index-tcdcj1g2.js → index-5w7ekpy3.js} +2 -2
- package/dist/cli/{index-nbgw5dxa.js → index-5zyk8qgv.js} +2 -2
- package/dist/cli/{index-tyh0p5e8.js → index-668dpw5e.js} +1 -1
- package/dist/cli/{index-zd15ya1w.js → index-91s653xx.js} +1 -1
- package/dist/cli/{index-85hstja2.js → index-a12906mj.js} +1 -1
- package/dist/cli/{index-chvqee1j.js → index-a5eba0t8.js} +2 -2
- package/dist/cli/{index-kv36s0x0.js → index-aymt7hzw.js} +6 -3
- package/dist/cli/{index-t31cc7kv.js → index-db7wf6ke.js} +7 -7
- package/dist/cli/{index-q3qtgtd0.js → index-dw09fz3w.js} +1 -1
- package/dist/cli/{index-fsrp8wp3.js → index-ed5ykebp.js} +25 -2
- package/dist/cli/{index-3nr2sn32.js → index-en6qq954.js} +3 -3
- package/dist/cli/{index-nc544sfw.js → index-gvhvz176.js} +2 -2
- package/dist/cli/{index-6q240xgm.js → index-hgrkhxbk.js} +2 -2
- package/dist/cli/{index-nsnfvckc.js → index-hn0mdcmj.js} +1 -1
- package/dist/cli/{index-gytyqv1d.js → index-ht4q3548.js} +2 -2
- package/dist/cli/{index-t26nfmcs.js → index-prmb5qfp.js} +2 -2
- package/dist/cli/{index-x20cgr2q.js → index-q7ezzgwq.js} +16 -2
- package/dist/cli/{index-z1tkxzq4.js → index-s608d3hw.js} +2 -2
- package/dist/cli/{index-84s6x604.js → index-vxbppwvf.js} +5 -5
- package/dist/cli/{index-ddmnhv4h.js → index-wrt6m5ze.js} +1 -1
- package/dist/cli/{index-4qzeef9h.js → index-x9q4bbhd.js} +1 -1
- package/dist/cli/{index-67yqywan.js → index-xec724kg.js} +2 -2
- package/dist/cli/{index-y46anh5e.js → index-xka8s8jw.js} +30 -30
- package/dist/cli/{index-r3pth9a7.js → index-xr07r80d.js} +507 -441
- package/dist/cli/{index-5bkpyvdf.js → index-y1zcsf2a.js} +1 -1
- package/dist/cli/{index-0tsetsxs.js → index-ywysg26s.js} +4 -4
- package/dist/cli/index.js +28 -28
- package/dist/cli/{knowledge-escalator-6473ey4c.js → knowledge-escalator-pjg2x75c.js} +8 -8
- package/dist/cli/{knowledge-events-wwzpz8m4.js → knowledge-events-vxheptk8.js} +6 -6
- package/dist/cli/{knowledge-link-trfydkzm.js → knowledge-link-3tq8w6gs.js} +5 -5
- package/dist/cli/{knowledge-store-99gd42jy.js → knowledge-store-36mascwz.js} +6 -6
- package/dist/cli/{knowledge-validator-v2eevvdg.js → knowledge-validator-anats6rj.js} +9 -9
- package/dist/cli/{pending-delegations-p6n83x67.js → pending-delegations-tmyf18p4.js} +5 -5
- package/dist/cli/{pr-subscriptions-xbrfr51c.js → pr-subscriptions-hhx6yk24.js} +5 -5
- package/dist/cli/{runner-9an52tmz.js → runner-w30gazew.js} +6 -6
- package/dist/cli/{scan-cursor-39zxpw34.js → scan-cursor-apbz9eez.js} +7 -7
- package/dist/cli/{schema-xhfwr6b2.js → schema-x9fr2ey8.js} +3 -1
- package/dist/cli/{scope-persistence-nsa6ra9s.js → scope-persistence-3f0d4fwv.js} +4 -4
- package/dist/cli/{skill-generator-5px81476.js → skill-generator-20czn4kd.js} +10 -10
- package/dist/cli/{telemetry-7nt7zhyp.js → telemetry-4tgrfhaz.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-9x4s4890.js → worktree-collision-ownership-vexb0b6r.js} +38 -8
- package/dist/config/context-window.d.ts +210 -0
- package/dist/config/schema.d.ts +18 -0
- package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +18 -0
- package/dist/evaluation/model-dispatcher.d.ts +1 -0
- package/dist/hooks/delegate-ack-collector.d.ts +1 -1
- package/dist/hooks/delegation-gate/worktree-collision-ownership.d.ts +7 -0
- package/dist/hooks/delegation-gate/worktree-isolation.d.ts +2 -1
- package/dist/hooks/delegation-gate/worktree-provisioning-owner.d.ts +6 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/init-orphan-recovery.d.ts +4 -1
- package/dist/hooks/knowledge-application-gate.d.ts +2 -1
- package/dist/hooks/knowledge-application.d.ts +5 -4
- package/dist/hooks/knowledge-injector.d.ts +16 -0
- package/dist/hooks/knowledge-types.d.ts +1 -1
- package/dist/hooks/messages-transform.d.ts +18 -0
- package/dist/hooks/model-limits.d.ts +88 -30
- package/dist/index.js +454 -451
- package/dist/memory/injector.d.ts +2 -0
- package/dist/services/context-budget-service.d.ts +6 -1
- package/dist/services/status-service.d.ts +14 -0
- package/dist/state.d.ts +37 -0
- package/dist/tools/context-status.d.ts +3 -1
- package/dist/turbo/lean/runner.d.ts +10 -0
- package/dist/utils/ephemeral-session-teardown.d.ts +98 -0
- package/dist/utils/path-security.d.ts +75 -5
- package/dist/utils/swarm-artifact-cache.d.ts +13 -0
- package/dist/worktree/index.d.ts +1 -1
- package/dist/worktree/merge.d.ts +36 -3
- package/package.json +1 -1
|
@@ -13,16 +13,16 @@ import {
|
|
|
13
13
|
resolveExecutableFromPath,
|
|
14
14
|
runEvaluation,
|
|
15
15
|
runExternalTool
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-wrt6m5ze.js";
|
|
17
17
|
import {
|
|
18
18
|
stableCanonicalStringify
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-y1zcsf2a.js";
|
|
20
20
|
import {
|
|
21
21
|
detectStraySwarmDirs,
|
|
22
22
|
readDoctorArtifact,
|
|
23
23
|
removeStraySwarmDir,
|
|
24
24
|
runConfigDoctor
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-91s653xx.js";
|
|
26
26
|
import {
|
|
27
27
|
MAX_TRANSIENT_RETRIES,
|
|
28
28
|
archiveEvidence,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
savePlan,
|
|
62
62
|
transientBackoff,
|
|
63
63
|
validateProjectRoot
|
|
64
|
-
} from "./index-
|
|
64
|
+
} from "./index-0wp67gqj.js";
|
|
65
65
|
import {
|
|
66
66
|
EvaluationTaskV1Schema,
|
|
67
67
|
GateAuditManifestV1Schema,
|
|
@@ -78,7 +78,7 @@ import {
|
|
|
78
78
|
saveGateAuditResult,
|
|
79
79
|
savePromotionDecision,
|
|
80
80
|
saveTaskSetSnapshot
|
|
81
|
-
} from "./index-
|
|
81
|
+
} from "./index-s608d3hw.js";
|
|
82
82
|
import {
|
|
83
83
|
canonicalHash,
|
|
84
84
|
canonicalJson,
|
|
@@ -116,15 +116,15 @@ import {
|
|
|
116
116
|
retireSkill,
|
|
117
117
|
selectCandidateEntries,
|
|
118
118
|
syncBundledProjectSkillsIfMissingAsync
|
|
119
|
-
} from "./index-
|
|
119
|
+
} from "./index-en6qq954.js";
|
|
120
120
|
import {
|
|
121
121
|
readRecentEscalations
|
|
122
|
-
} from "./index-
|
|
122
|
+
} from "./index-vxbppwvf.js";
|
|
123
123
|
import {
|
|
124
124
|
alreadyCuratedThisGeneration,
|
|
125
125
|
claimNextScanBatch,
|
|
126
126
|
resolveCohortId
|
|
127
|
-
} from "./index-
|
|
127
|
+
} from "./index-0ymhx85c.js";
|
|
128
128
|
import {
|
|
129
129
|
CURATOR_INIT_PROMPT,
|
|
130
130
|
CURATOR_PHASE_PROMPT,
|
|
@@ -177,11 +177,11 @@ import {
|
|
|
177
177
|
validateActionableFields,
|
|
178
178
|
validateLesson,
|
|
179
179
|
validateSkillPath
|
|
180
|
-
} from "./index-
|
|
180
|
+
} from "./index-ywysg26s.js";
|
|
181
181
|
import {
|
|
182
182
|
authorizeCuration,
|
|
183
183
|
buildConfigFingerprintInput
|
|
184
|
-
} from "./index-
|
|
184
|
+
} from "./index-xec724kg.js";
|
|
185
185
|
import {
|
|
186
186
|
cohortConfigFingerprint
|
|
187
187
|
} from "./index-rtry5xyf.js";
|
|
@@ -214,7 +214,7 @@ import {
|
|
|
214
214
|
transactFile,
|
|
215
215
|
transactKnowledge,
|
|
216
216
|
wordBigrams
|
|
217
|
-
} from "./index-
|
|
217
|
+
} from "./index-db7wf6ke.js";
|
|
218
218
|
import {
|
|
219
219
|
MAX_EVENT_LOG_ENTRIES,
|
|
220
220
|
_internals,
|
|
@@ -224,7 +224,7 @@ import {
|
|
|
224
224
|
recordHiveKnowledgeEvent,
|
|
225
225
|
recordKnowledgeEvent,
|
|
226
226
|
resolveKnowledgeEventsPath
|
|
227
|
-
} from "./index-
|
|
227
|
+
} from "./index-aymt7hzw.js";
|
|
228
228
|
import {
|
|
229
229
|
resolveHiveDataDir,
|
|
230
230
|
resolveHiveEventsPath,
|
|
@@ -240,16 +240,16 @@ import {
|
|
|
240
240
|
resolveLinkDir,
|
|
241
241
|
sanitizeLinkId,
|
|
242
242
|
writeLinkPointer
|
|
243
|
-
} from "./index-
|
|
243
|
+
} from "./index-668dpw5e.js";
|
|
244
244
|
import {
|
|
245
245
|
atomicWriteFile
|
|
246
|
-
} from "./index-
|
|
246
|
+
} from "./index-gvhvz176.js";
|
|
247
247
|
import {
|
|
248
248
|
exports_loader,
|
|
249
249
|
init_loader,
|
|
250
250
|
loadPluginConfig,
|
|
251
251
|
loadPluginConfigWithMeta
|
|
252
|
-
} from "./index-
|
|
252
|
+
} from "./index-dw09fz3w.js";
|
|
253
253
|
import {
|
|
254
254
|
RetrospectiveEvidenceSchema
|
|
255
255
|
} from "./index-gprxjmm7.js";
|
|
@@ -260,12 +260,13 @@ import {
|
|
|
260
260
|
MemoryConfigSchema,
|
|
261
261
|
SkillImproverConfigSchema,
|
|
262
262
|
getCanonicalAgentRole,
|
|
263
|
+
init_context_window,
|
|
263
264
|
init_package,
|
|
264
265
|
init_schema,
|
|
265
266
|
package_default,
|
|
266
267
|
resolveAutoReviewConfig,
|
|
267
268
|
stripKnownSwarmPrefix
|
|
268
|
-
} from "./index-
|
|
269
|
+
} from "./index-15526t16.js";
|
|
269
270
|
import {
|
|
270
271
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
271
272
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -281,13 +282,13 @@ import {
|
|
|
281
282
|
listActive,
|
|
282
283
|
subscribe,
|
|
283
284
|
unsubscribe
|
|
284
|
-
} from "./index-
|
|
285
|
+
} from "./index-5zyk8qgv.js";
|
|
285
286
|
import {
|
|
286
287
|
MAX_PENDING_SCOPE_BINDINGS,
|
|
287
288
|
clearAllScopes,
|
|
288
289
|
clearScopeBindingFromDisk,
|
|
289
290
|
clearScopeBindings
|
|
290
|
-
} from "./index-
|
|
291
|
+
} from "./index-3eddtgxt.js";
|
|
291
292
|
import {
|
|
292
293
|
appendLedgerEvent,
|
|
293
294
|
computePlanHash,
|
|
@@ -295,7 +296,7 @@ import {
|
|
|
295
296
|
derivePlanId,
|
|
296
297
|
initLedger,
|
|
297
298
|
takeSnapshotEvent
|
|
298
|
-
} from "./index-
|
|
299
|
+
} from "./index-4xbyy6aw.js";
|
|
299
300
|
import {
|
|
300
301
|
PlanSchema
|
|
301
302
|
} from "./index-1kz6da87.js";
|
|
@@ -322,16 +323,20 @@ import {
|
|
|
322
323
|
import {
|
|
323
324
|
findByBatchId,
|
|
324
325
|
readDelegations
|
|
325
|
-
} from "./index-
|
|
326
|
+
} from "./index-prmb5qfp.js";
|
|
326
327
|
import {
|
|
327
328
|
readSwarmFileAsync,
|
|
328
329
|
safeHook,
|
|
329
330
|
validateSwarmPath
|
|
330
|
-
} from "./index-
|
|
331
|
+
} from "./index-x9q4bbhd.js";
|
|
332
|
+
import {
|
|
333
|
+
invalidateCachedArtifact,
|
|
334
|
+
resetSwarmArtifactCache
|
|
335
|
+
} from "./index-ed5ykebp.js";
|
|
331
336
|
import {
|
|
332
337
|
tryAcquireLock,
|
|
333
338
|
withEvidenceLock
|
|
334
|
-
} from "./index-
|
|
339
|
+
} from "./index-5j6chvj8.js";
|
|
335
340
|
import {
|
|
336
341
|
require_proper_lockfile
|
|
337
342
|
} from "./index-7g4c7s5r.js";
|
|
@@ -339,7 +344,7 @@ import {
|
|
|
339
344
|
emit,
|
|
340
345
|
getLastHeartbeat,
|
|
341
346
|
telemetry
|
|
342
|
-
} from "./index-
|
|
347
|
+
} from "./index-a5eba0t8.js";
|
|
343
348
|
import {
|
|
344
349
|
exports_external,
|
|
345
350
|
init_zod
|
|
@@ -5681,6 +5686,8 @@ var swarmState = {
|
|
|
5681
5686
|
gateDenialCounts: new Map,
|
|
5682
5687
|
generatedAgentNames: [],
|
|
5683
5688
|
lastBudgetPct: 0,
|
|
5689
|
+
lastBudgetTokens: 0,
|
|
5690
|
+
liveContextWindows: new Map,
|
|
5684
5691
|
agentSessions: defaultRunContext.agentSessions,
|
|
5685
5692
|
pendingRehydrations: new Set,
|
|
5686
5693
|
fullAutoEnabledInConfig: false,
|
|
@@ -5693,6 +5700,8 @@ function resetSwarmState() {
|
|
|
5693
5700
|
swarmState.delegationChains.clear();
|
|
5694
5701
|
swarmState.pendingEvents = 0;
|
|
5695
5702
|
swarmState.lastBudgetPct = 0;
|
|
5703
|
+
swarmState.lastBudgetTokens = 0;
|
|
5704
|
+
swarmState.liveContextWindows.clear();
|
|
5696
5705
|
swarmState.agentSessions.clear();
|
|
5697
5706
|
_lastIdleSweepAtMs = 0;
|
|
5698
5707
|
clearTrajectoryCache();
|
|
@@ -6523,7 +6532,7 @@ function hasActiveEpicMode(sessionID) {
|
|
|
6523
6532
|
async function rehydratePrSubscriptions(sessionID, directory) {
|
|
6524
6533
|
const map = new Map;
|
|
6525
6534
|
try {
|
|
6526
|
-
const { listActive: listActive2 } = await import("./pr-subscriptions-
|
|
6535
|
+
const { listActive: listActive2 } = await import("./pr-subscriptions-hhx6yk24.js");
|
|
6527
6536
|
const records = await listActive2(directory);
|
|
6528
6537
|
for (const record of records) {
|
|
6529
6538
|
if (record.sessionID !== sessionID)
|
|
@@ -6685,7 +6694,7 @@ async function listLaneBranches(directory) {
|
|
|
6685
6694
|
}
|
|
6686
6695
|
return [...branches];
|
|
6687
6696
|
}
|
|
6688
|
-
async function cleanupOrphanedBranches(directory, activeSessionIds = []) {
|
|
6697
|
+
async function cleanupOrphanedBranches(directory, activeSessionIds = [], options = {}) {
|
|
6689
6698
|
const removed = [];
|
|
6690
6699
|
const skipped = [];
|
|
6691
6700
|
const skippedRecoveryBranches = [];
|
|
@@ -6713,7 +6722,7 @@ async function cleanupOrphanedBranches(directory, activeSessionIds = []) {
|
|
|
6713
6722
|
skippedRecoveryBranches.push(branch);
|
|
6714
6723
|
continue;
|
|
6715
6724
|
}
|
|
6716
|
-
const deleteResult = await runGit(["branch", "-D", branch], directory);
|
|
6725
|
+
const deleteResult = await runGit(["branch", options.preserveUnmerged ? "-d" : "-D", branch], directory);
|
|
6717
6726
|
if (deleteResult.exitCode === 0) {
|
|
6718
6727
|
removed.push(branch);
|
|
6719
6728
|
} else {
|
|
@@ -11988,6 +11997,7 @@ init_constants();
|
|
|
11988
11997
|
init_schema();
|
|
11989
11998
|
|
|
11990
11999
|
// src/hooks/model-limits.ts
|
|
12000
|
+
init_context_window();
|
|
11991
12001
|
var loggedFirstCalls = new Set;
|
|
11992
12002
|
|
|
11993
12003
|
// src/hooks/guardrails/nontransient-circuit.ts
|
|
@@ -18978,7 +18988,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
18978
18988
|
};
|
|
18979
18989
|
}
|
|
18980
18990
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
18981
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18991
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
18982
18992
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
18983
18993
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
18984
18994
|
if (sweepConfig?.enabled === false)
|
|
@@ -20020,6 +20030,7 @@ async function writeCuratorSummaryState(filePath, state) {
|
|
|
20020
20030
|
if (!state.summary)
|
|
20021
20031
|
return;
|
|
20022
20032
|
await bunWrite(filePath, JSON.stringify(state.summary, null, 2));
|
|
20033
|
+
invalidateCachedArtifact(filePath);
|
|
20023
20034
|
}
|
|
20024
20035
|
async function transactCuratorSummary(directory, mutate) {
|
|
20025
20036
|
const resolvedPath = validateSwarmPath(directory, "curator-summary.json");
|
|
@@ -20554,6 +20565,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
20554
20565
|
fs12.mkdirSync(evidenceDir, { recursive: true });
|
|
20555
20566
|
const findingsPath = path32.join(evidenceDir, "curator-findings.json");
|
|
20556
20567
|
await bunWrite(findingsPath, JSON.stringify({ findings: knowledgeApplicationFindings }, null, 2));
|
|
20568
|
+
invalidateCachedArtifact(findingsPath);
|
|
20557
20569
|
} catch (err) {
|
|
20558
20570
|
warn(`[curator] failed to persist application findings: ${err instanceof Error ? err.message : String(err)}`);
|
|
20559
20571
|
}
|
|
@@ -20571,7 +20583,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
20571
20583
|
}
|
|
20572
20584
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
20573
20585
|
try {
|
|
20574
|
-
const skillModule = await import("./skill-generator-
|
|
20586
|
+
const skillModule = await import("./skill-generator-20czn4kd.js");
|
|
20575
20587
|
for (const cand of skillCandidates) {
|
|
20576
20588
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
20577
20589
|
continue;
|
|
@@ -21031,7 +21043,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
21031
21043
|
} catch {}
|
|
21032
21044
|
}
|
|
21033
21045
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
21034
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
21046
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-pjg2x75c.js");
|
|
21035
21047
|
for (const { id } of contradictedEntries) {
|
|
21036
21048
|
try {
|
|
21037
21049
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -21850,7 +21862,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
21850
21862
|
warnings.push("Failed to collect knowledge summary.");
|
|
21851
21863
|
}
|
|
21852
21864
|
try {
|
|
21853
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
21865
|
+
const { getScanStatus } = await import("./scan-cursor-apbz9eez.js");
|
|
21854
21866
|
const scanStatus = await getScanStatus(directory);
|
|
21855
21867
|
if (scanStatus.remaining_estimate > 0) {
|
|
21856
21868
|
warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
|
|
@@ -22022,9 +22034,9 @@ var _internals24 = {
|
|
|
22022
22034
|
verifyPostMortemKnowledgeActions,
|
|
22023
22035
|
repairPostMortemActions,
|
|
22024
22036
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
22025
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
22037
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-x9fr2ey8.js");
|
|
22026
22038
|
try {
|
|
22027
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
22039
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
22028
22040
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
22029
22041
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
22030
22042
|
} catch {
|
|
@@ -22032,11 +22044,11 @@ var _internals24 = {
|
|
|
22032
22044
|
}
|
|
22033
22045
|
},
|
|
22034
22046
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
22035
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
22047
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-nbsag633.js");
|
|
22036
22048
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
22037
22049
|
},
|
|
22038
22050
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
22039
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
22051
|
+
const { checkHivePromotions } = await import("./hive-promoter-bpt26yew.js");
|
|
22040
22052
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
22041
22053
|
},
|
|
22042
22054
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -22045,7 +22057,7 @@ var _internals24 = {
|
|
|
22045
22057
|
activateProposal,
|
|
22046
22058
|
listSkills: listSkills2,
|
|
22047
22059
|
sanitizeSlug
|
|
22048
|
-
} = await import("./skill-generator-
|
|
22060
|
+
} = await import("./skill-generator-20czn4kd.js");
|
|
22049
22061
|
const result = {
|
|
22050
22062
|
approved: [],
|
|
22051
22063
|
rejected: [],
|
|
@@ -22087,7 +22099,7 @@ var _internals24 = {
|
|
|
22087
22099
|
return result;
|
|
22088
22100
|
},
|
|
22089
22101
|
readPriorDriftReports: async (directory) => {
|
|
22090
|
-
const { readPriorDriftReports } = await import("./curator-drift-
|
|
22102
|
+
const { readPriorDriftReports } = await import("./curator-drift-vfh07mqy.js");
|
|
22091
22103
|
return readPriorDriftReports(directory);
|
|
22092
22104
|
},
|
|
22093
22105
|
readSwarmKnowledge: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory))
|
|
@@ -24312,6 +24324,7 @@ ${newSection}`;
|
|
|
24312
24324
|
_internals28.mkdirSync(swarmDir, { recursive: true });
|
|
24313
24325
|
}
|
|
24314
24326
|
_internals28.writeFileSync(contextPath, updatedContent, "utf-8");
|
|
24327
|
+
invalidateCachedArtifact(contextPath);
|
|
24315
24328
|
}
|
|
24316
24329
|
} catch (err) {
|
|
24317
24330
|
warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -24672,9 +24685,9 @@ function hashContent(content) {
|
|
|
24672
24685
|
return createHash9("sha1").update(content).digest("hex");
|
|
24673
24686
|
}
|
|
24674
24687
|
async function loadConfigForPolicyCurator(directory) {
|
|
24675
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
24688
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-x9fr2ey8.js");
|
|
24676
24689
|
try {
|
|
24677
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
24690
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
24678
24691
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
24679
24692
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
24680
24693
|
} catch {
|
|
@@ -25774,6 +25787,53 @@ import * as path41 from "path";
|
|
|
25774
25787
|
// src/hooks/skill-improver-llm-factory.ts
|
|
25775
25788
|
init_schema();
|
|
25776
25789
|
|
|
25790
|
+
// src/utils/ephemeral-session-teardown.ts
|
|
25791
|
+
init_logger();
|
|
25792
|
+
var DEFAULT_EPHEMERAL_ABORT_TIMEOUT_MS = 5000;
|
|
25793
|
+
var DEFAULT_EPHEMERAL_TEARDOWN_DELETE_TIMEOUT_MS = 2000;
|
|
25794
|
+
async function boundedSessionCall(call, timeoutMs, timeoutLabel, failureLabel, sessionId) {
|
|
25795
|
+
let timer;
|
|
25796
|
+
try {
|
|
25797
|
+
await Promise.race([
|
|
25798
|
+
call(),
|
|
25799
|
+
new Promise((_resolve, reject) => {
|
|
25800
|
+
timer = setTimeout(() => reject(new Error(`${timeoutLabel} after ${timeoutMs}ms`)), Math.max(1, timeoutMs));
|
|
25801
|
+
})
|
|
25802
|
+
]);
|
|
25803
|
+
} catch (error2) {
|
|
25804
|
+
_internals31.log(`${failureLabel} for ephemeral session`, {
|
|
25805
|
+
sessionId,
|
|
25806
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
25807
|
+
});
|
|
25808
|
+
} finally {
|
|
25809
|
+
if (timer)
|
|
25810
|
+
clearTimeout(timer);
|
|
25811
|
+
}
|
|
25812
|
+
}
|
|
25813
|
+
async function boundedAbortEphemeralSession(session, sessionId, timeoutMs = DEFAULT_EPHEMERAL_ABORT_TIMEOUT_MS) {
|
|
25814
|
+
if (typeof session.abort !== "function")
|
|
25815
|
+
return;
|
|
25816
|
+
await _internals31.boundedSessionCall(() => session.abort({ path: { id: sessionId } }), timeoutMs, "ephemeral session abort timed out", "ephemeral session abort failed", sessionId);
|
|
25817
|
+
}
|
|
25818
|
+
async function boundedDeleteEphemeralSession(session, sessionId, timeoutMs = DEFAULT_EPHEMERAL_TEARDOWN_DELETE_TIMEOUT_MS) {
|
|
25819
|
+
await _internals31.boundedSessionCall(() => session.delete({ path: { id: sessionId } }), timeoutMs, "ephemeral session delete timed out", "ephemeral session delete failed", sessionId);
|
|
25820
|
+
}
|
|
25821
|
+
async function teardownEphemeralSession(session, sessionId, options = {}) {
|
|
25822
|
+
const abortTimeoutMs = options.abortTimeoutMs ?? DEFAULT_EPHEMERAL_ABORT_TIMEOUT_MS;
|
|
25823
|
+
const deleteTimeoutMs = options.deleteTimeoutMs ?? DEFAULT_EPHEMERAL_TEARDOWN_DELETE_TIMEOUT_MS;
|
|
25824
|
+
const skipAbort = options.skipAbort ?? false;
|
|
25825
|
+
if (!skipAbort) {
|
|
25826
|
+
await _internals31.boundedAbort(session, sessionId, abortTimeoutMs);
|
|
25827
|
+
}
|
|
25828
|
+
await _internals31.boundedDelete(session, sessionId, deleteTimeoutMs);
|
|
25829
|
+
}
|
|
25830
|
+
var _internals31 = {
|
|
25831
|
+
boundedSessionCall,
|
|
25832
|
+
boundedAbort: boundedAbortEphemeralSession,
|
|
25833
|
+
boundedDelete: boundedDeleteEphemeralSession,
|
|
25834
|
+
log
|
|
25835
|
+
};
|
|
25836
|
+
|
|
25777
25837
|
// src/utils/model-dispatch-fallback.ts
|
|
25778
25838
|
function parseModelString(model) {
|
|
25779
25839
|
if (!model || !model.trim())
|
|
@@ -25889,11 +25949,11 @@ function createSkillImproverLLMDelegate(directory, sessionId) {
|
|
|
25889
25949
|
return;
|
|
25890
25950
|
return async (systemPrompt, userInput, signal) => {
|
|
25891
25951
|
let ephemeralSessionId;
|
|
25892
|
-
const cleanup = () => {
|
|
25952
|
+
const cleanup = async () => {
|
|
25893
25953
|
if (ephemeralSessionId) {
|
|
25894
25954
|
const id = ephemeralSessionId;
|
|
25895
25955
|
ephemeralSessionId = undefined;
|
|
25896
|
-
client.session
|
|
25956
|
+
await teardownEphemeralSession(client.session, id);
|
|
25897
25957
|
}
|
|
25898
25958
|
};
|
|
25899
25959
|
if (signal?.aborted) {
|
|
@@ -25963,7 +26023,7 @@ ${userInput}` : userInput;
|
|
|
25963
26023
|
throw new Error("SKILL_IMPROVER_LLM_TIMEOUT");
|
|
25964
26024
|
throw err;
|
|
25965
26025
|
} finally {
|
|
25966
|
-
cleanup();
|
|
26026
|
+
await cleanup();
|
|
25967
26027
|
}
|
|
25968
26028
|
};
|
|
25969
26029
|
}
|
|
@@ -26090,7 +26150,7 @@ function gatherSkillViolations(directory, sessionId) {
|
|
|
26090
26150
|
if (!sessionId)
|
|
26091
26151
|
return [];
|
|
26092
26152
|
try {
|
|
26093
|
-
const entries =
|
|
26153
|
+
const entries = _internals32.readSkillUsageEntriesTail(directory, {
|
|
26094
26154
|
sessionID: sessionId
|
|
26095
26155
|
});
|
|
26096
26156
|
const bySkill = new Map;
|
|
@@ -26123,7 +26183,7 @@ async function gatherContradictionCandidates(directory, sessionStart, dedupThres
|
|
|
26123
26183
|
if (!Number.isFinite(sessionStartMs))
|
|
26124
26184
|
return [];
|
|
26125
26185
|
try {
|
|
26126
|
-
const all = await
|
|
26186
|
+
const all = await _internals32.readKnowledge(resolveSwarmKnowledgePath(directory));
|
|
26127
26187
|
const sessionCreated = all.filter((e) => {
|
|
26128
26188
|
if (typeof e.created_at !== "string")
|
|
26129
26189
|
return false;
|
|
@@ -26171,7 +26231,7 @@ async function gatherRealtimeAdmissionCounts(directory, sessionStart) {
|
|
|
26171
26231
|
if (!Number.isFinite(sessionStartMs))
|
|
26172
26232
|
return;
|
|
26173
26233
|
try {
|
|
26174
|
-
const entries = await
|
|
26234
|
+
const entries = await _internals32.readKnowledge(resolveSwarmKnowledgePath(directory));
|
|
26175
26235
|
let admitted = 0;
|
|
26176
26236
|
let reinforced = 0;
|
|
26177
26237
|
for (const e of entries) {
|
|
@@ -26190,7 +26250,7 @@ async function gatherRealtimeAdmissionCounts(directory, sessionStart) {
|
|
|
26190
26250
|
}
|
|
26191
26251
|
let rejected = 0;
|
|
26192
26252
|
try {
|
|
26193
|
-
const rejectedLessons = await
|
|
26253
|
+
const rejectedLessons = await _internals32.readRejectedLessons(directory);
|
|
26194
26254
|
rejected = rejectedLessons.filter((r) => {
|
|
26195
26255
|
const ms = Date.parse(r.rejected_at ?? "");
|
|
26196
26256
|
return Number.isFinite(ms) && ms >= sessionStartMs;
|
|
@@ -26486,9 +26546,9 @@ async function runSessionReflection(input) {
|
|
|
26486
26546
|
const agentDispatches = gatherAgentDispatches(input.agentSessions);
|
|
26487
26547
|
const { lessons, taxonomy } = await gatherRetroLessonsAndTaxonomy(input.directory);
|
|
26488
26548
|
const gateFailures = await gatherGateFailures(input.directory);
|
|
26489
|
-
const skillViolations =
|
|
26490
|
-
const contradictionCandidates = await
|
|
26491
|
-
const realtimeCounts = await
|
|
26549
|
+
const skillViolations = _internals32.gatherSkillViolations(input.directory, input.sessionId);
|
|
26550
|
+
const contradictionCandidates = await _internals32.gatherContradictionCandidates(input.directory, input.sessionStart, input.dedupThreshold ?? DEFAULT_DEDUP_THRESHOLD2);
|
|
26551
|
+
const realtimeCounts = await _internals32.gatherRealtimeAdmissionCounts(input.directory, input.sessionStart);
|
|
26492
26552
|
const knowledgeDelta = input.knowledgeDelta ? {
|
|
26493
26553
|
...input.knowledgeDelta,
|
|
26494
26554
|
admitted: realtimeCounts?.admitted ?? input.knowledgeDelta.admitted,
|
|
@@ -26548,7 +26608,7 @@ async function writeSessionReflection(directory, result) {
|
|
|
26548
26608
|
await fs15.writeFile(reflectionPath, content, "utf-8");
|
|
26549
26609
|
return reflectionPath;
|
|
26550
26610
|
}
|
|
26551
|
-
var
|
|
26611
|
+
var _internals32 = {
|
|
26552
26612
|
gatherToolProblems,
|
|
26553
26613
|
gatherAgentDispatches,
|
|
26554
26614
|
gatherRetroLessonsAndTaxonomy,
|
|
@@ -26734,9 +26794,9 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
26734
26794
|
return result;
|
|
26735
26795
|
const max = opts.maxProposals ?? 10;
|
|
26736
26796
|
const selected = motifs.slice(0, max);
|
|
26737
|
-
const producedAt =
|
|
26797
|
+
const producedAt = _internals33.now().toISOString();
|
|
26738
26798
|
const candidates = selected.map((motif) => buildMotifCandidate(motif, opts.sessionId));
|
|
26739
|
-
const dedupCheck = await
|
|
26799
|
+
const dedupCheck = await _internals33.checkRecommendations(directory, candidates);
|
|
26740
26800
|
const emitted = dedupCheck.decisions.filter((decision) => decision.emit);
|
|
26741
26801
|
result.duplicatesSuppressed = dedupCheck.decisions.length - emitted.length;
|
|
26742
26802
|
if (emitted.length === 0)
|
|
@@ -26758,7 +26818,7 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
26758
26818
|
result.proposalsWritten.push(filePath);
|
|
26759
26819
|
written.push(candidate);
|
|
26760
26820
|
}
|
|
26761
|
-
await
|
|
26821
|
+
await _internals33.recordEmittedRecommendations(directory, written, {
|
|
26762
26822
|
producedAt
|
|
26763
26823
|
});
|
|
26764
26824
|
return result;
|
|
@@ -26924,9 +26984,9 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
26924
26984
|
return result;
|
|
26925
26985
|
const max = opts.maxProposals ?? 10;
|
|
26926
26986
|
const selected = motifs.slice(0, max);
|
|
26927
|
-
const producedAt =
|
|
26987
|
+
const producedAt = _internals33.now().toISOString();
|
|
26928
26988
|
const candidates = selected.map((motif) => buildWorkflowCandidate(motif, opts.sessionId));
|
|
26929
|
-
const dedupCheck = await
|
|
26989
|
+
const dedupCheck = await _internals33.checkRecommendations(directory, candidates);
|
|
26930
26990
|
const emitted = dedupCheck.decisions.filter((decision) => decision.emit);
|
|
26931
26991
|
result.duplicatesSuppressed = dedupCheck.decisions.length - emitted.length;
|
|
26932
26992
|
if (emitted.length === 0)
|
|
@@ -26948,7 +27008,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
26948
27008
|
result.proposalsWritten.push(filePath);
|
|
26949
27009
|
written.push(candidate);
|
|
26950
27010
|
}
|
|
26951
|
-
await
|
|
27011
|
+
await _internals33.recordEmittedRecommendations(directory, written, {
|
|
26952
27012
|
producedAt
|
|
26953
27013
|
});
|
|
26954
27014
|
return result;
|
|
@@ -26957,7 +27017,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
26957
27017
|
return result;
|
|
26958
27018
|
}
|
|
26959
27019
|
}
|
|
26960
|
-
var
|
|
27020
|
+
var _internals33 = {
|
|
26961
27021
|
now: () => new Date,
|
|
26962
27022
|
checkRecommendations,
|
|
26963
27023
|
recordEmittedRecommendations
|
|
@@ -27286,7 +27346,7 @@ async function reconcileStaleActiveSkills(directory, options = {}) {
|
|
|
27286
27346
|
continue;
|
|
27287
27347
|
}
|
|
27288
27348
|
try {
|
|
27289
|
-
const regen = await
|
|
27349
|
+
const regen = await _internals34.regenerateSkill(directory, skill.slug, {
|
|
27290
27350
|
evaluate: false
|
|
27291
27351
|
});
|
|
27292
27352
|
if (regen.regenerated) {
|
|
@@ -27542,7 +27602,7 @@ async function runSkillImprover(req) {
|
|
|
27542
27602
|
autoApply
|
|
27543
27603
|
};
|
|
27544
27604
|
}
|
|
27545
|
-
var
|
|
27605
|
+
var _internals34 = {
|
|
27546
27606
|
runSkillImprover,
|
|
27547
27607
|
buildDeterministicProposal,
|
|
27548
27608
|
buildLLMProposalFrame,
|
|
@@ -27904,13 +27964,13 @@ var write_retro = createSwarmTool({
|
|
|
27904
27964
|
task_id: args.task_id !== undefined ? String(args.task_id) : undefined,
|
|
27905
27965
|
metadata: args.metadata
|
|
27906
27966
|
};
|
|
27907
|
-
return await
|
|
27967
|
+
return await _internals35.executeWriteRetro(writeRetroArgs, directory);
|
|
27908
27968
|
} catch {
|
|
27909
27969
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
27910
27970
|
}
|
|
27911
27971
|
}
|
|
27912
27972
|
});
|
|
27913
|
-
var
|
|
27973
|
+
var _internals35 = {
|
|
27914
27974
|
executeWriteRetro,
|
|
27915
27975
|
write_retro
|
|
27916
27976
|
};
|
|
@@ -27923,7 +27983,7 @@ import * as fsSync2 from "fs";
|
|
|
27923
27983
|
import path45 from "path";
|
|
27924
27984
|
var DEFAULT_MAX_SOURCE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
27925
27985
|
var DEFAULT_BUSY_TIMEOUT_MS = 5000;
|
|
27926
|
-
var
|
|
27986
|
+
var _internals36 = {
|
|
27927
27987
|
existsSync: fsSync2.existsSync,
|
|
27928
27988
|
statSync: fsSync2.statSync,
|
|
27929
27989
|
renameSync: fsSync2.renameSync,
|
|
@@ -27933,11 +27993,11 @@ var _internals35 = {
|
|
|
27933
27993
|
DatabaseCtor: null
|
|
27934
27994
|
};
|
|
27935
27995
|
function resolveDatabaseCtor() {
|
|
27936
|
-
return
|
|
27996
|
+
return _internals36.DatabaseCtor ?? loadDatabaseCtor();
|
|
27937
27997
|
}
|
|
27938
27998
|
function safeRemoveTemp(tempPath) {
|
|
27939
27999
|
try {
|
|
27940
|
-
|
|
28000
|
+
_internals36.rmSync(tempPath, {
|
|
27941
28001
|
force: true,
|
|
27942
28002
|
recursive: true,
|
|
27943
28003
|
maxRetries: 3,
|
|
@@ -27993,7 +28053,7 @@ function captureRowCounts(db) {
|
|
|
27993
28053
|
async function archiveSqliteSnapshot(opts) {
|
|
27994
28054
|
const maxSourceBytes = opts.maxSourceBytes ?? DEFAULT_MAX_SOURCE_BYTES;
|
|
27995
28055
|
const busyTimeoutMs = opts.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS;
|
|
27996
|
-
if (!
|
|
28056
|
+
if (!_internals36.existsSync(opts.sourcePath)) {
|
|
27997
28057
|
return {
|
|
27998
28058
|
requiredness: "required",
|
|
27999
28059
|
attempt: "not_attempted",
|
|
@@ -28006,10 +28066,10 @@ async function archiveSqliteSnapshot(opts) {
|
|
|
28006
28066
|
let sourceBytes = 0;
|
|
28007
28067
|
for (const suffix of ["", "-wal", "-shm"]) {
|
|
28008
28068
|
const sidecar = opts.sourcePath + suffix;
|
|
28009
|
-
if (!
|
|
28069
|
+
if (!_internals36.existsSync(sidecar))
|
|
28010
28070
|
continue;
|
|
28011
28071
|
try {
|
|
28012
|
-
sourceBytes +=
|
|
28072
|
+
sourceBytes += _internals36.statSync(sidecar).size;
|
|
28013
28073
|
} catch (err) {
|
|
28014
28074
|
if (suffix === "") {
|
|
28015
28075
|
return {
|
|
@@ -28036,7 +28096,7 @@ async function archiveSqliteSnapshot(opts) {
|
|
|
28036
28096
|
};
|
|
28037
28097
|
}
|
|
28038
28098
|
const destFinal = path45.join(opts.destDir, opts.destName);
|
|
28039
|
-
const destTemp = path45.join(opts.destDir, `.${opts.destName}.tmp.${
|
|
28099
|
+
const destTemp = path45.join(opts.destDir, `.${opts.destName}.tmp.${_internals36.now()}.${_internals36.randomSuffix()}`);
|
|
28040
28100
|
let Db;
|
|
28041
28101
|
try {
|
|
28042
28102
|
Db = resolveDatabaseCtor();
|
|
@@ -28135,7 +28195,7 @@ async function archiveSqliteSnapshot(opts) {
|
|
|
28135
28195
|
};
|
|
28136
28196
|
}
|
|
28137
28197
|
try {
|
|
28138
|
-
|
|
28198
|
+
_internals36.renameSync(destTemp, destFinal);
|
|
28139
28199
|
} catch (err) {
|
|
28140
28200
|
safeRemoveTemp(destTemp);
|
|
28141
28201
|
return {
|
|
@@ -28501,8 +28561,8 @@ async function runFinalizeStage(ctx) {
|
|
|
28501
28561
|
];
|
|
28502
28562
|
ctx.curationSucceeded = false;
|
|
28503
28563
|
try {
|
|
28504
|
-
ctx.curationResult = await
|
|
28505
|
-
llmDelegate:
|
|
28564
|
+
ctx.curationResult = await _internals37.curateAndStoreSwarm(ctx.allLessons, ctx.projectName, { phase_number: 0 }, ctx.directory, ctx.config, {
|
|
28565
|
+
llmDelegate: _internals37.createCuratorLLMDelegate(ctx.directory, "phase", ctx.options.sessionID),
|
|
28506
28566
|
enrichmentQuota: {
|
|
28507
28567
|
maxCalls: ctx.config.enrichment.max_calls_per_day,
|
|
28508
28568
|
window: ctx.config.enrichment.quota_window
|
|
@@ -28521,7 +28581,7 @@ async function runFinalizeStage(ctx) {
|
|
|
28521
28581
|
if (ctx.config.hive_enabled === false) {} else {
|
|
28522
28582
|
try {
|
|
28523
28583
|
const entries = await readKnowledge(resolveSwarmKnowledgePath(ctx.directory));
|
|
28524
|
-
const result = await
|
|
28584
|
+
const result = await _internals37.checkHivePromotions(entries, ctx.config, ctx.directory);
|
|
28525
28585
|
ctx.hivePromoted = result.new_promotions;
|
|
28526
28586
|
} catch (hiveErr) {
|
|
28527
28587
|
const msg = hiveErr instanceof Error ? hiveErr.message : String(hiveErr);
|
|
@@ -28542,7 +28602,7 @@ async function runFinalizeStage(ctx) {
|
|
|
28542
28602
|
ctx.knowledgeSkillHint = ctx.sessionKnowledgeCreated > 0 ? `${ctx.sessionKnowledgeCreated} knowledge entries created this session. Consider running skill_improve or skill_generate to compile mature entries into skills.` : "";
|
|
28543
28603
|
if (ctx.runSkillReview) {
|
|
28544
28604
|
try {
|
|
28545
|
-
const { config: loadedConfig } =
|
|
28605
|
+
const { config: loadedConfig } = _internals37.loadPluginConfigWithMeta(ctx.directory);
|
|
28546
28606
|
const skillImproverConfig = SkillImproverConfigSchema.parse(loadedConfig.skill_improver ?? {});
|
|
28547
28607
|
const skillReviewResult = await runAbortableSkillReview({
|
|
28548
28608
|
directory: ctx.directory,
|
|
@@ -28620,7 +28680,7 @@ async function runFinalizeStage(ctx) {
|
|
|
28620
28680
|
}
|
|
28621
28681
|
if (!ctx.planAlreadyDone || ctx.guaranteeResult.closedPhaseIds.length > 0 || ctx.guaranteeResult.closedTaskIds.length > 0) {
|
|
28622
28682
|
try {
|
|
28623
|
-
await
|
|
28683
|
+
await _internals37.closePlanTerminalState(ctx.directory, ctx.planData, {
|
|
28624
28684
|
closedPhaseIds: ctx.guaranteeResult.closedPhaseIds,
|
|
28625
28685
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
28626
28686
|
originalStatuses: ctx.originalStatuses
|
|
@@ -28636,12 +28696,12 @@ async function runFinalizeStage(ctx) {
|
|
|
28636
28696
|
}
|
|
28637
28697
|
}
|
|
28638
28698
|
try {
|
|
28639
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
28640
|
-
const { config: pmLoadedConfig } =
|
|
28699
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-x9fr2ey8.js");
|
|
28700
|
+
const { config: pmLoadedConfig } = _internals37.loadPluginConfigWithMeta(ctx.directory);
|
|
28641
28701
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
28642
28702
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
28643
|
-
const pmResult = await
|
|
28644
|
-
llmDelegate:
|
|
28703
|
+
const pmResult = await _internals37.runCuratorPostMortem(ctx.directory, {
|
|
28704
|
+
llmDelegate: _internals37.createCuratorLLMDelegate(ctx.directory, "postmortem", ctx.options.sessionID),
|
|
28645
28705
|
scope: "project",
|
|
28646
28706
|
sessionID: ctx.options.sessionID
|
|
28647
28707
|
});
|
|
@@ -28664,7 +28724,7 @@ async function runArchiveStage(ctx) {
|
|
|
28664
28724
|
try {
|
|
28665
28725
|
await fs16.mkdir(ctx.archiveDir, { recursive: true });
|
|
28666
28726
|
try {
|
|
28667
|
-
await
|
|
28727
|
+
await _internals37.flushAndDrainTelemetry();
|
|
28668
28728
|
} catch (flushErr) {
|
|
28669
28729
|
const msg = flushErr instanceof Error ? flushErr.message : String(flushErr);
|
|
28670
28730
|
ctx.warnings.push(`Telemetry flush before archive failed: ${msg}`);
|
|
@@ -28843,7 +28903,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
28843
28903
|
let cacheMaxBytes;
|
|
28844
28904
|
let cacheMaxRecords;
|
|
28845
28905
|
try {
|
|
28846
|
-
const { config: evidenceLoadedConfig } =
|
|
28906
|
+
const { config: evidenceLoadedConfig } = _internals37.loadPluginConfigWithMeta(ctx.directory);
|
|
28847
28907
|
const evidenceCfg = evidenceLoadedConfig.evidence ?? {};
|
|
28848
28908
|
if (typeof evidenceCfg.max_age_days === "number") {
|
|
28849
28909
|
maxAgeDays = evidenceCfg.max_age_days;
|
|
@@ -28859,7 +28919,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
28859
28919
|
}
|
|
28860
28920
|
} catch {}
|
|
28861
28921
|
try {
|
|
28862
|
-
await
|
|
28922
|
+
await _internals37.archiveEvidence(ctx.directory, maxAgeDays, maxBundles, {
|
|
28863
28923
|
report: true,
|
|
28864
28924
|
cacheMaxBytes,
|
|
28865
28925
|
cacheMaxRecords
|
|
@@ -29052,6 +29112,7 @@ async function runCleanStage(ctx) {
|
|
|
29052
29112
|
try {
|
|
29053
29113
|
await fs16.writeFile(contextTempPath, contextContent, "utf-8");
|
|
29054
29114
|
fsSync3.renameSync(contextTempPath, contextPath);
|
|
29115
|
+
invalidateCachedArtifact(contextPath);
|
|
29055
29116
|
} catch (error2) {
|
|
29056
29117
|
try {
|
|
29057
29118
|
fsSync3.unlinkSync(contextTempPath);
|
|
@@ -29071,9 +29132,9 @@ async function runAlignStage(ctx) {
|
|
|
29071
29132
|
const pruneBranches = ctx.args.includes("--prune-branches");
|
|
29072
29133
|
let gitAlignResult = "";
|
|
29073
29134
|
const prunedBranches = [];
|
|
29074
|
-
const gitStatus =
|
|
29135
|
+
const gitStatus = _internals37.getGitRepositoryStatus(ctx.directory);
|
|
29075
29136
|
if (gitStatus.isRepo) {
|
|
29076
|
-
const aggressiveResult = await
|
|
29137
|
+
const aggressiveResult = await _internals37.resetToMainAfterMerge(ctx.directory, {
|
|
29077
29138
|
pruneBranches
|
|
29078
29139
|
});
|
|
29079
29140
|
if (aggressiveResult.success) {
|
|
@@ -29085,7 +29146,7 @@ async function runAlignStage(ctx) {
|
|
|
29085
29146
|
ctx.warnings.push("Uncommitted changes were discarded during git alignment");
|
|
29086
29147
|
}
|
|
29087
29148
|
} else {
|
|
29088
|
-
const alignResult = await
|
|
29149
|
+
const alignResult = await _internals37.resetToRemoteBranch(ctx.directory, {
|
|
29089
29150
|
pruneBranches
|
|
29090
29151
|
});
|
|
29091
29152
|
gitAlignResult = alignResult.message;
|
|
@@ -29121,7 +29182,7 @@ async function runFinalizeDryRun(directory, swarmDir, planData, planExists) {
|
|
|
29121
29182
|
const wouldArchiveDirs = ACTIVE_STATE_DIRS_TO_CLEAN.filter(existsInSwarm);
|
|
29122
29183
|
const wouldRemoveTerminal = TERMINAL_STATE_FILES.filter(existsInSwarm);
|
|
29123
29184
|
const wouldCleanFiles = ACTIVE_STATE_TO_CLEAN.filter((f) => existsInSwarm(f) && !TERMINAL_STATE_FILES.includes(f));
|
|
29124
|
-
const gitStatus =
|
|
29185
|
+
const gitStatus = _internals37.getGitRepositoryStatus(directory);
|
|
29125
29186
|
const gitNote = gitStatus.isRepo ? "would align the working tree to main/remote (git reset), pruning merged branches only with --prune-branches" : "would skip git alignment (not a git repository / git unavailable)";
|
|
29126
29187
|
const lines = [
|
|
29127
29188
|
"## /swarm finalize \u2014 DRY RUN (no changes made)",
|
|
@@ -29193,12 +29254,12 @@ async function handleCloseCommand(directory, args, options = {}) {
|
|
|
29193
29254
|
}
|
|
29194
29255
|
}
|
|
29195
29256
|
if (args.includes("--dry-run")) {
|
|
29196
|
-
return
|
|
29257
|
+
return _internals37.runFinalizeDryRun(directory, swarmDir, planData, planExists);
|
|
29197
29258
|
}
|
|
29198
29259
|
let finalizeLock = {
|
|
29199
29260
|
acquired: false
|
|
29200
29261
|
};
|
|
29201
|
-
finalizeLock = await
|
|
29262
|
+
finalizeLock = await _internals37.acquireFinalizeLock(directory);
|
|
29202
29263
|
if (!finalizeLock.acquired) {
|
|
29203
29264
|
return `\u274C Another /swarm finalize is already running for this project. If you are certain no other run is active, wait for the lock to expire or remove the stale lock and retry.`;
|
|
29204
29265
|
}
|
|
@@ -29229,7 +29290,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29229
29290
|
if (planExists) {
|
|
29230
29291
|
planAlreadyDone = phases.length > 0 && phases.every((p) => p.status === "complete" || p.status === "completed" || p.status === "blocked" || p.status === "closed");
|
|
29231
29292
|
}
|
|
29232
|
-
const { config: loadedConfig } =
|
|
29293
|
+
const { config: loadedConfig } = _internals37.loadPluginConfigWithMeta(directory);
|
|
29233
29294
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
29234
29295
|
const ctx = {
|
|
29235
29296
|
directory,
|
|
@@ -29278,9 +29339,9 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29278
29339
|
archiveSuffix: "",
|
|
29279
29340
|
args
|
|
29280
29341
|
};
|
|
29281
|
-
ctx.fullAuto = options.sessionID ?
|
|
29342
|
+
ctx.fullAuto = options.sessionID ? _internals37.detectFullAuto(directory, options.sessionID) : false;
|
|
29282
29343
|
await runFinalizeStage(ctx);
|
|
29283
|
-
await
|
|
29344
|
+
await _internals37.runFinalizeRewardSweep({
|
|
29284
29345
|
directory,
|
|
29285
29346
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
29286
29347
|
memoryConfig: loadedConfig.memory
|
|
@@ -29352,6 +29413,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29352
29413
|
try {
|
|
29353
29414
|
await fs16.writeFile(closeSummaryTempPath, summaryContent, "utf-8");
|
|
29354
29415
|
fsSync3.renameSync(closeSummaryTempPath, closeSummaryPath);
|
|
29416
|
+
invalidateCachedArtifact(closeSummaryPath);
|
|
29355
29417
|
} catch (error2) {
|
|
29356
29418
|
try {
|
|
29357
29419
|
fsSync3.unlinkSync(closeSummaryTempPath);
|
|
@@ -29363,9 +29425,9 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29363
29425
|
try {
|
|
29364
29426
|
const sessionIdsToEnd = [...swarmState.agentSessions.keys()];
|
|
29365
29427
|
for (const sessionId of sessionIdsToEnd) {
|
|
29366
|
-
|
|
29428
|
+
_internals37.endAgentSession(sessionId);
|
|
29367
29429
|
}
|
|
29368
|
-
|
|
29430
|
+
_internals37.resetSwarmStatePreservingSingletons();
|
|
29369
29431
|
} catch (teardownError) {
|
|
29370
29432
|
const msg = teardownError instanceof Error ? teardownError.message : String(teardownError);
|
|
29371
29433
|
ctx.warnings.push(`Session teardown encountered an error after finalization completed (state may not be fully reset): ${msg}`);
|
|
@@ -29462,7 +29524,7 @@ function detectFullAuto(directory, sessionID) {
|
|
|
29462
29524
|
return false;
|
|
29463
29525
|
}
|
|
29464
29526
|
}
|
|
29465
|
-
var
|
|
29527
|
+
var _internals37 = {
|
|
29466
29528
|
ACTIVE_STATE_DIRS_TO_CLEAN,
|
|
29467
29529
|
countSessionKnowledgeEntries,
|
|
29468
29530
|
CLOSE_SKILL_REVIEW_TIMEOUT_MS,
|
|
@@ -29491,7 +29553,7 @@ var _internals36 = {
|
|
|
29491
29553
|
closePlanTerminalState,
|
|
29492
29554
|
endAgentSession,
|
|
29493
29555
|
flushAndDrainTelemetry: async () => {
|
|
29494
|
-
const { flushAndDrainTelemetry } = await import("./telemetry-
|
|
29556
|
+
const { flushAndDrainTelemetry } = await import("./telemetry-4tgrfhaz.js");
|
|
29495
29557
|
return flushAndDrainTelemetry();
|
|
29496
29558
|
}
|
|
29497
29559
|
};
|
|
@@ -29958,7 +30020,7 @@ function isValidTelemetryEntry(value) {
|
|
|
29958
30020
|
const obj = value;
|
|
29959
30021
|
return typeof obj.timestamp === "string" && typeof obj.task_id === "string" && typeof obj.agent_role === "string" && typeof obj.delegation_reason === "string" && typeof obj.token_estimate === "number" && typeof obj.cache_hits === "number" && typeof obj.cache_misses === "number" && typeof obj.stale_entries === "number" && typeof obj.recommended_reads === "number" && typeof obj.skipped_reads === "number" && typeof obj.success === "boolean";
|
|
29960
30022
|
}
|
|
29961
|
-
var
|
|
30023
|
+
var _internals38 = {
|
|
29962
30024
|
appendFileSync: fs17.appendFileSync,
|
|
29963
30025
|
readFileSync: fs17.readFileSync,
|
|
29964
30026
|
existsSync: fs17.existsSync,
|
|
@@ -29971,10 +30033,10 @@ function readTelemetry(directory) {
|
|
|
29971
30033
|
const filePath = telemetryFilePath(directory);
|
|
29972
30034
|
const entries = [];
|
|
29973
30035
|
try {
|
|
29974
|
-
if (!
|
|
30036
|
+
if (!_internals38.existsSync(filePath)) {
|
|
29975
30037
|
return entries;
|
|
29976
30038
|
}
|
|
29977
|
-
const raw =
|
|
30039
|
+
const raw = _internals38.readFileSync(filePath, "utf-8");
|
|
29978
30040
|
const lines = raw.split(`
|
|
29979
30041
|
`);
|
|
29980
30042
|
for (const line of lines) {
|
|
@@ -30411,9 +30473,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
30411
30473
|
} catch {
|
|
30412
30474
|
return [];
|
|
30413
30475
|
}
|
|
30414
|
-
const commitMap = await
|
|
30415
|
-
const matrix =
|
|
30416
|
-
const staticEdges = await
|
|
30476
|
+
const commitMap = await _internals39.parseGitLog(directory, maxCommitsToAnalyze);
|
|
30477
|
+
const matrix = _internals39.buildCoChangeMatrix(commitMap, maxFilesPerCommit);
|
|
30478
|
+
const staticEdges = await _internals39.getStaticEdges(directory);
|
|
30417
30479
|
const results = [];
|
|
30418
30480
|
for (const entry of matrix.values()) {
|
|
30419
30481
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -30529,11 +30591,11 @@ var co_change_analyzer = createSwarmTool({
|
|
|
30529
30591
|
npmiThreshold,
|
|
30530
30592
|
maxCommitsToAnalyze
|
|
30531
30593
|
};
|
|
30532
|
-
const pairs = await
|
|
30533
|
-
return
|
|
30594
|
+
const pairs = await _internals39.detectDarkMatter(directory, options);
|
|
30595
|
+
return _internals39.formatDarkMatterOutput(pairs);
|
|
30534
30596
|
}
|
|
30535
30597
|
});
|
|
30536
|
-
var
|
|
30598
|
+
var _internals39 = {
|
|
30537
30599
|
parseGitLog,
|
|
30538
30600
|
buildCoChangeMatrix,
|
|
30539
30601
|
getStaticEdges,
|
|
@@ -30550,7 +30612,7 @@ var DEFAULT_MAX_COMMITS = 500;
|
|
|
30550
30612
|
var cache = new Map;
|
|
30551
30613
|
async function readGitHead(directory) {
|
|
30552
30614
|
try {
|
|
30553
|
-
const { stdout } = await
|
|
30615
|
+
const { stdout } = await _internals40.execFile("git", ["rev-parse", "HEAD"], {
|
|
30554
30616
|
cwd: directory,
|
|
30555
30617
|
timeout: GIT_HEAD_TIMEOUT_MS
|
|
30556
30618
|
});
|
|
@@ -30576,9 +30638,9 @@ async function getCoChangeData(directory, options) {
|
|
|
30576
30638
|
let entries;
|
|
30577
30639
|
let commitsObserved;
|
|
30578
30640
|
try {
|
|
30579
|
-
const commitMap = await
|
|
30641
|
+
const commitMap = await _internals40.parseGitLog(directory, maxCommits);
|
|
30580
30642
|
commitsObserved = commitMap.size;
|
|
30581
|
-
const matrix =
|
|
30643
|
+
const matrix = _internals40.buildCoChangeMatrix(commitMap);
|
|
30582
30644
|
entries = Array.from(matrix.values());
|
|
30583
30645
|
} catch {
|
|
30584
30646
|
return { pairs: [], commitsObserved: 0 };
|
|
@@ -30602,10 +30664,10 @@ async function getCoChangePairs(directory, options) {
|
|
|
30602
30664
|
const data = await getCoChangeData(directory, options);
|
|
30603
30665
|
return data.pairs;
|
|
30604
30666
|
}
|
|
30605
|
-
var
|
|
30667
|
+
var _internals40 = {
|
|
30606
30668
|
execFile: execFileAsync,
|
|
30607
|
-
parseGitLog:
|
|
30608
|
-
buildCoChangeMatrix:
|
|
30669
|
+
parseGitLog: _internals39.parseGitLog,
|
|
30670
|
+
buildCoChangeMatrix: _internals39.buildCoChangeMatrix
|
|
30609
30671
|
};
|
|
30610
30672
|
|
|
30611
30673
|
// src/turbo/epic/coupling-report.ts
|
|
@@ -30829,7 +30891,7 @@ async function handleCouplingCommand(directory, args) {
|
|
|
30829
30891
|
|
|
30830
30892
|
Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>] [--format markdown|json] [--persist]`;
|
|
30831
30893
|
}
|
|
30832
|
-
const plan = await
|
|
30894
|
+
const plan = await _internals41.loadPlanJsonOnly(directory);
|
|
30833
30895
|
if (plan === null) {
|
|
30834
30896
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` to create one before measuring coupling.";
|
|
30835
30897
|
}
|
|
@@ -30853,7 +30915,7 @@ Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>
|
|
|
30853
30915
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
30854
30916
|
return { id: task.id, scope };
|
|
30855
30917
|
});
|
|
30856
|
-
const cochangePairs = await
|
|
30918
|
+
const cochangePairs = await _internals41.getCoChangePairs(directory);
|
|
30857
30919
|
const report = computeCouplingReport(tasks, cochangePairs, {
|
|
30858
30920
|
npmi: parsed.threshold,
|
|
30859
30921
|
minCoChanges: parsed.minCoChanges
|
|
@@ -30892,14 +30954,14 @@ _Warning: failed to persist report (${persistStatus.error})._`;
|
|
|
30892
30954
|
}
|
|
30893
30955
|
return `${formatCouplingReportMarkdown(report)}${persistTrailer}`;
|
|
30894
30956
|
}
|
|
30895
|
-
var
|
|
30957
|
+
var _internals41 = {
|
|
30896
30958
|
loadPlanJsonOnly,
|
|
30897
30959
|
getCoChangePairs
|
|
30898
30960
|
};
|
|
30899
30961
|
|
|
30900
30962
|
// src/commands/curate.ts
|
|
30901
30963
|
init_schema();
|
|
30902
|
-
var
|
|
30964
|
+
var _internals42 = {
|
|
30903
30965
|
checkHivePromotions,
|
|
30904
30966
|
readKnowledge,
|
|
30905
30967
|
resolveSwarmKnowledgePath,
|
|
@@ -30907,9 +30969,9 @@ var _internals41 = {
|
|
|
30907
30969
|
loadPluginConfigWithMeta,
|
|
30908
30970
|
loadCuratorDeps: async () => {
|
|
30909
30971
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
30910
|
-
import("./schema-
|
|
30911
|
-
import("./curator-
|
|
30912
|
-
import("./curator-llm-factory-
|
|
30972
|
+
import("./schema-x9fr2ey8.js"),
|
|
30973
|
+
import("./curator-nbsag633.js"),
|
|
30974
|
+
import("./curator-llm-factory-1ftzece0.js")
|
|
30913
30975
|
]);
|
|
30914
30976
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
30915
30977
|
}
|
|
@@ -30918,20 +30980,20 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
30918
30980
|
try {
|
|
30919
30981
|
let config;
|
|
30920
30982
|
try {
|
|
30921
|
-
const { config: loadedConfig } =
|
|
30983
|
+
const { config: loadedConfig } = _internals42.loadPluginConfigWithMeta(directory);
|
|
30922
30984
|
config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
30923
30985
|
} catch {
|
|
30924
30986
|
config = KnowledgeConfigSchema.parse({});
|
|
30925
30987
|
}
|
|
30926
|
-
const swarmPath =
|
|
30927
|
-
const swarmEntries = await
|
|
30928
|
-
const summary = await
|
|
30988
|
+
const swarmPath = _internals42.resolveSwarmKnowledgePath(directory);
|
|
30989
|
+
const swarmEntries = await _internals42.readKnowledge(swarmPath) ?? [];
|
|
30990
|
+
const summary = await _internals42.checkHivePromotions(swarmEntries, config, directory);
|
|
30929
30991
|
if (options?.sessionID) {
|
|
30930
30992
|
let onDemandPhase = 1;
|
|
30931
30993
|
try {
|
|
30932
|
-
const { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 } = await
|
|
30994
|
+
const { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 } = await _internals42.loadCuratorDeps();
|
|
30933
30995
|
const curatorConfig = CuratorConfigSchema.parse({});
|
|
30934
|
-
const priorSummary = await
|
|
30996
|
+
const priorSummary = await _internals42.readSwarmFileAsync(directory, "curator-summary.json");
|
|
30935
30997
|
if (priorSummary) {
|
|
30936
30998
|
try {
|
|
30937
30999
|
const parsed = JSON.parse(priorSummary);
|
|
@@ -30942,7 +31004,7 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
30942
31004
|
}
|
|
30943
31005
|
let planPhaseCount = Infinity;
|
|
30944
31006
|
try {
|
|
30945
|
-
const planRaw = await
|
|
31007
|
+
const planRaw = await _internals42.readSwarmFileAsync(directory, "plan.json");
|
|
30946
31008
|
if (planRaw) {
|
|
30947
31009
|
const plan = JSON.parse(planRaw);
|
|
30948
31010
|
if (Array.isArray(plan.phases))
|
|
@@ -30961,8 +31023,8 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
30961
31023
|
summary.knowledge_skipped = applied.skipped;
|
|
30962
31024
|
summary.curator_phase = onDemandPhase;
|
|
30963
31025
|
try {
|
|
30964
|
-
const updatedEntries = await
|
|
30965
|
-
const postUpdateHive = await
|
|
31026
|
+
const updatedEntries = await _internals42.readKnowledge(swarmPath) ?? [];
|
|
31027
|
+
const postUpdateHive = await _internals42.checkHivePromotions(updatedEntries, config, directory);
|
|
30966
31028
|
summary.new_promotions += postUpdateHive.new_promotions;
|
|
30967
31029
|
summary.encounters_incremented += postUpdateHive.encounters_incremented;
|
|
30968
31030
|
summary.advancements += postUpdateHive.advancements;
|
|
@@ -31028,7 +31090,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
31028
31090
|
}
|
|
31029
31091
|
let pairs;
|
|
31030
31092
|
try {
|
|
31031
|
-
pairs = await
|
|
31093
|
+
pairs = await _internals39.detectDarkMatter(directory, options);
|
|
31032
31094
|
} catch (err) {
|
|
31033
31095
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
31034
31096
|
return `## Dark Matter Analysis Failed
|
|
@@ -31293,7 +31355,7 @@ ${USAGE7}`;
|
|
|
31293
31355
|
// src/commands/design-docs.ts
|
|
31294
31356
|
init_warning_buffer();
|
|
31295
31357
|
var MAX_DESC_LEN = 2000;
|
|
31296
|
-
var
|
|
31358
|
+
var _internals43 = { loadPluginConfigWithMeta };
|
|
31297
31359
|
var USAGE8 = `Usage: /swarm design-docs <description> [--out <dir>] [--lang <name>] [--update]
|
|
31298
31360
|
|
|
31299
31361
|
Generate or sync language-agnostic design docs for the project under build:
|
|
@@ -31389,7 +31451,7 @@ async function handleDesignDocsCommand(directory, args) {
|
|
|
31389
31451
|
${USAGE8}`;
|
|
31390
31452
|
}
|
|
31391
31453
|
try {
|
|
31392
|
-
const { config } =
|
|
31454
|
+
const { config } = _internals43.loadPluginConfigWithMeta(directory);
|
|
31393
31455
|
if (config.design_docs?.enabled !== true) {
|
|
31394
31456
|
return "Error: design docs are disabled. Set `design_docs.enabled: true` in " + `opencode-swarm.json to enable the docs_design agent and this command.
|
|
31395
31457
|
|
|
@@ -31814,7 +31876,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
31814
31876
|
let scanCompleted = false;
|
|
31815
31877
|
let scanRemaining = 0;
|
|
31816
31878
|
try {
|
|
31817
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
31879
|
+
const { getScanStatus } = await import("./scan-cursor-apbz9eez.js");
|
|
31818
31880
|
const status = await getScanStatus(directory);
|
|
31819
31881
|
scanGeneration = status.generation;
|
|
31820
31882
|
scanCompleted = status.completed;
|
|
@@ -31822,19 +31884,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
31822
31884
|
} catch {}
|
|
31823
31885
|
let configMatch = null;
|
|
31824
31886
|
try {
|
|
31825
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
31887
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-3tq8w6gs.js");
|
|
31826
31888
|
if (isLinked2(directory)) {
|
|
31827
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
31889
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-x9fr2ey8.js");
|
|
31828
31890
|
let config;
|
|
31829
31891
|
try {
|
|
31830
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
31892
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
31831
31893
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
31832
31894
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
31833
31895
|
} catch {
|
|
31834
31896
|
config = KnowledgeConfigSchema2.parse({});
|
|
31835
31897
|
}
|
|
31836
31898
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
31837
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
31899
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-2qnhgdtt.js");
|
|
31838
31900
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
31839
31901
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
31840
31902
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -31996,7 +32058,7 @@ function resolveCachePackageRoot(cachePath) {
|
|
|
31996
32058
|
const nestedPackageRoot = path54.join(cachePath, "node_modules", "opencode-swarm");
|
|
31997
32059
|
return existsSync31(nestedPackageRoot) ? nestedPackageRoot : cachePath;
|
|
31998
32060
|
}
|
|
31999
|
-
var
|
|
32061
|
+
var _internals44 = {
|
|
32000
32062
|
detectSandboxCapability: () => sandboxCapabilityProbe.detect(),
|
|
32001
32063
|
getSandboxExecutor: getExecutor
|
|
32002
32064
|
};
|
|
@@ -32580,9 +32642,9 @@ async function checkCurator(directory) {
|
|
|
32580
32642
|
}
|
|
32581
32643
|
async function getSandboxStatus() {
|
|
32582
32644
|
try {
|
|
32583
|
-
const capability = await
|
|
32645
|
+
const capability = await _internals44.detectSandboxCapability();
|
|
32584
32646
|
const mechanism = capability.mechanism ?? "none";
|
|
32585
|
-
const executor = await
|
|
32647
|
+
const executor = await _internals44.getSandboxExecutor();
|
|
32586
32648
|
const hasExecutor = executor !== null;
|
|
32587
32649
|
if (hasExecutor) {
|
|
32588
32650
|
const executorStrength = executor?.strength;
|
|
@@ -33045,7 +33107,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
33045
33107
|
const result = runConfigDoctor(config, directory);
|
|
33046
33108
|
let output;
|
|
33047
33109
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
33048
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
33110
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-tgnr91q3.js");
|
|
33049
33111
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
33050
33112
|
applyLossy: true
|
|
33051
33113
|
});
|
|
@@ -33390,7 +33452,7 @@ function readPromotionEvidence(directory) {
|
|
|
33390
33452
|
}
|
|
33391
33453
|
|
|
33392
33454
|
// src/commands/epic.ts
|
|
33393
|
-
var
|
|
33455
|
+
var _internals45 = {
|
|
33394
33456
|
loadPluginConfigWithMeta,
|
|
33395
33457
|
loadPlanJsonOnly,
|
|
33396
33458
|
getCoChangeData,
|
|
@@ -33412,7 +33474,7 @@ async function handleEpicCommand(directory, args, sessionID) {
|
|
|
33412
33474
|
if (!sessionID || sessionID.trim() === "") {
|
|
33413
33475
|
return "Error: No active session context. Epic Mode requires an active session. Use /swarm epic from within an OpenCode session.";
|
|
33414
33476
|
}
|
|
33415
|
-
const session =
|
|
33477
|
+
const session = _internals45.ensureAgentSession(sessionID, undefined, directory);
|
|
33416
33478
|
const arg0 = args[0]?.toLowerCase();
|
|
33417
33479
|
switch (arg0) {
|
|
33418
33480
|
case "status":
|
|
@@ -33439,7 +33501,7 @@ Usage:
|
|
|
33439
33501
|
}
|
|
33440
33502
|
function enableAndAck(directory, sessionID, session) {
|
|
33441
33503
|
try {
|
|
33442
|
-
|
|
33504
|
+
_internals45.enableEpicMode(directory, sessionID);
|
|
33443
33505
|
} catch (err) {
|
|
33444
33506
|
return `Error enabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
33445
33507
|
}
|
|
@@ -33455,7 +33517,7 @@ function enableAndAck(directory, sessionID, session) {
|
|
|
33455
33517
|
}
|
|
33456
33518
|
function disableAndAck(directory, sessionID, session) {
|
|
33457
33519
|
try {
|
|
33458
|
-
|
|
33520
|
+
_internals45.disableEpicMode(directory, sessionID);
|
|
33459
33521
|
} catch (err) {
|
|
33460
33522
|
return `Error disabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
33461
33523
|
}
|
|
@@ -33464,12 +33526,12 @@ function disableAndAck(directory, sessionID, session) {
|
|
|
33464
33526
|
}
|
|
33465
33527
|
function renderStatus(directory, sessionID) {
|
|
33466
33528
|
const lines = ["## Epic Mode \u2014 Status", ""];
|
|
33467
|
-
if (
|
|
33529
|
+
if (_internals45.isStateUnreadable(directory)) {
|
|
33468
33530
|
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.");
|
|
33469
33531
|
return lines.join(`
|
|
33470
33532
|
`);
|
|
33471
33533
|
}
|
|
33472
|
-
const state =
|
|
33534
|
+
const state = _internals45.loadEpicSessionState(directory, sessionID);
|
|
33473
33535
|
if (!state) {
|
|
33474
33536
|
lines.push("Epic Mode has not been toggled for this session.");
|
|
33475
33537
|
return lines.join(`
|
|
@@ -33521,7 +33583,7 @@ function formatGreenfieldDetail(input) {
|
|
|
33521
33583
|
function renderLast(directory) {
|
|
33522
33584
|
let records;
|
|
33523
33585
|
try {
|
|
33524
|
-
records =
|
|
33586
|
+
records = _internals45.readPromotionEvidence(directory);
|
|
33525
33587
|
} catch (err) {
|
|
33526
33588
|
return `Error reading epic-promotions.jsonl: ${err instanceof Error ? err.message : String(err)}`;
|
|
33527
33589
|
}
|
|
@@ -33576,7 +33638,7 @@ function renderLast(directory) {
|
|
|
33576
33638
|
`);
|
|
33577
33639
|
}
|
|
33578
33640
|
function renderCalibration(directory) {
|
|
33579
|
-
if (
|
|
33641
|
+
if (_internals45.isCalibrationStateUnreadable(directory)) {
|
|
33580
33642
|
return [
|
|
33581
33643
|
"## Epic Mode \u2014 Calibration",
|
|
33582
33644
|
"",
|
|
@@ -33588,11 +33650,11 @@ function renderCalibration(directory) {
|
|
|
33588
33650
|
}
|
|
33589
33651
|
let state;
|
|
33590
33652
|
try {
|
|
33591
|
-
state =
|
|
33653
|
+
state = _internals45.loadCalibrationState(directory);
|
|
33592
33654
|
} catch (err) {
|
|
33593
33655
|
return `Error reading calibration state: ${err instanceof Error ? err.message : String(err)}`;
|
|
33594
33656
|
}
|
|
33595
|
-
const { config } =
|
|
33657
|
+
const { config } = _internals45.loadPluginConfigWithMeta(directory);
|
|
33596
33658
|
const staticThreshold = config.turbo?.epic?.mode?.activation_threshold ?? 0.3;
|
|
33597
33659
|
const calibrationCfg = config.turbo?.epic?.calibration;
|
|
33598
33660
|
const loosenWindow = calibrationCfg?.loosen_window ?? 10;
|
|
@@ -33640,7 +33702,7 @@ function renderCalibration(directory) {
|
|
|
33640
33702
|
lines.push("");
|
|
33641
33703
|
let recentDivergent = [];
|
|
33642
33704
|
try {
|
|
33643
|
-
const all =
|
|
33705
|
+
const all = _internals45.readDivergenceHistory(directory, { limit: 50 });
|
|
33644
33706
|
recentDivergent = all.filter((r) => !r.isClean).slice(-5);
|
|
33645
33707
|
} catch {}
|
|
33646
33708
|
lines.push("### Recent divergent tasks (tightened the threshold)");
|
|
@@ -33657,11 +33719,11 @@ function renderCalibration(directory) {
|
|
|
33657
33719
|
`);
|
|
33658
33720
|
}
|
|
33659
33721
|
async function renderDecide(directory) {
|
|
33660
|
-
const plan = await
|
|
33722
|
+
const plan = await _internals45.loadPlanJsonOnly(directory);
|
|
33661
33723
|
if (!plan) {
|
|
33662
33724
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` first.";
|
|
33663
33725
|
}
|
|
33664
|
-
const { config } =
|
|
33726
|
+
const { config } = _internals45.loadPluginConfigWithMeta(directory);
|
|
33665
33727
|
const modeCfg = config.turbo?.epic?.mode;
|
|
33666
33728
|
const cochangeCfg = config.turbo?.epic?.cochange;
|
|
33667
33729
|
const activationThreshold = modeCfg?.activation_threshold ?? 0.3;
|
|
@@ -33671,20 +33733,20 @@ async function renderDecide(directory) {
|
|
|
33671
33733
|
const tasks = [];
|
|
33672
33734
|
for (const phase of plan.phases) {
|
|
33673
33735
|
for (const task of phase.tasks) {
|
|
33674
|
-
const scopeFiles =
|
|
33736
|
+
const scopeFiles = _internals45.readTaskScopes(directory, task.id);
|
|
33675
33737
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
33676
33738
|
tasks.push({ id: task.id, scope });
|
|
33677
33739
|
}
|
|
33678
33740
|
}
|
|
33679
|
-
const { pairs, commitsObserved } = await
|
|
33741
|
+
const { pairs, commitsObserved } = await _internals45.getCoChangeData(directory);
|
|
33680
33742
|
const isGitProject = (() => {
|
|
33681
33743
|
try {
|
|
33682
|
-
return
|
|
33744
|
+
return _internals45.isGitRepo(directory);
|
|
33683
33745
|
} catch {
|
|
33684
33746
|
return false;
|
|
33685
33747
|
}
|
|
33686
33748
|
})();
|
|
33687
|
-
const verdict =
|
|
33749
|
+
const verdict = _internals45.decideEpicActivation(tasks, pairs, commitsObserved, {
|
|
33688
33750
|
activationThreshold,
|
|
33689
33751
|
minCommitsForSignal,
|
|
33690
33752
|
cochangeNpmiThreshold,
|
|
@@ -33728,7 +33790,7 @@ function formatVerdict(verdict) {
|
|
|
33728
33790
|
}
|
|
33729
33791
|
|
|
33730
33792
|
// src/services/evidence-service.ts
|
|
33731
|
-
var
|
|
33793
|
+
var _internals46 = {
|
|
33732
33794
|
loadEvidence,
|
|
33733
33795
|
listEvidenceTaskIds
|
|
33734
33796
|
};
|
|
@@ -33773,7 +33835,7 @@ function getVerdictEmoji(verdict) {
|
|
|
33773
33835
|
return getVerdictIcon(verdict);
|
|
33774
33836
|
}
|
|
33775
33837
|
async function getTaskEvidenceData(directory, taskId) {
|
|
33776
|
-
const result = await
|
|
33838
|
+
const result = await _internals46.loadEvidence(directory, taskId);
|
|
33777
33839
|
if (result.status !== "found") {
|
|
33778
33840
|
return {
|
|
33779
33841
|
hasEvidence: false,
|
|
@@ -33796,13 +33858,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
33796
33858
|
};
|
|
33797
33859
|
}
|
|
33798
33860
|
async function getEvidenceListData(directory) {
|
|
33799
|
-
const taskIds = await
|
|
33861
|
+
const taskIds = await _internals46.listEvidenceTaskIds(directory);
|
|
33800
33862
|
if (taskIds.length === 0) {
|
|
33801
33863
|
return { hasEvidence: false, tasks: [] };
|
|
33802
33864
|
}
|
|
33803
33865
|
const tasks = [];
|
|
33804
33866
|
for (const taskId of taskIds) {
|
|
33805
|
-
const result = await
|
|
33867
|
+
const result = await _internals46.loadEvidence(directory, taskId);
|
|
33806
33868
|
if (result.status === "found") {
|
|
33807
33869
|
tasks.push({
|
|
33808
33870
|
taskId,
|
|
@@ -33882,7 +33944,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
33882
33944
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
33883
33945
|
}
|
|
33884
33946
|
async function handleEvidenceSummaryCommand(directory) {
|
|
33885
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
33947
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-kzxr71yd.js");
|
|
33886
33948
|
const artifact = await buildEvidenceSummary(directory);
|
|
33887
33949
|
if (!artifact) {
|
|
33888
33950
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -34238,7 +34300,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
34238
34300
|
const strippedMutated = stripCode(mutatedCode);
|
|
34239
34301
|
return strippedOriginal === strippedMutated;
|
|
34240
34302
|
}
|
|
34241
|
-
var
|
|
34303
|
+
var _internals47 = {
|
|
34242
34304
|
isStaticallyEquivalent,
|
|
34243
34305
|
checkEquivalence,
|
|
34244
34306
|
batchCheckEquivalence
|
|
@@ -34278,7 +34340,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
34278
34340
|
const results = [];
|
|
34279
34341
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
34280
34342
|
try {
|
|
34281
|
-
const result = await
|
|
34343
|
+
const result = await _internals47.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
34282
34344
|
results.push(result);
|
|
34283
34345
|
} catch (err) {
|
|
34284
34346
|
results.push({
|
|
@@ -34352,10 +34414,10 @@ function isMissingExecutableFailure(message) {
|
|
|
34352
34414
|
return /\bENOENT\b/i.test(message) || /\bexecutable\b[^\r\n]*\bnot found\b/i.test(message) || /\bnot found in (?:the )?\$?PATH\b/i.test(message);
|
|
34353
34415
|
}
|
|
34354
34416
|
var runMutationCommand = async (args) => {
|
|
34355
|
-
const resolvedExecutable =
|
|
34417
|
+
const resolvedExecutable = _internals48.resolveExecutableFromPath([
|
|
34356
34418
|
args.executable
|
|
34357
34419
|
]);
|
|
34358
|
-
const result = await
|
|
34420
|
+
const result = await _internals48.runExternalTool({
|
|
34359
34421
|
executable: resolvedExecutable ?? args.executable,
|
|
34360
34422
|
args: args.args,
|
|
34361
34423
|
cwd: args.cwd,
|
|
@@ -34374,7 +34436,7 @@ var runMutationCommand = async (args) => {
|
|
|
34374
34436
|
};
|
|
34375
34437
|
var runLegacyTestSeam = async (args) => {
|
|
34376
34438
|
try {
|
|
34377
|
-
const result =
|
|
34439
|
+
const result = _internals48.spawnSync(args.executable, args.args, {
|
|
34378
34440
|
cwd: args.cwd,
|
|
34379
34441
|
timeout: args.timeoutMs,
|
|
34380
34442
|
stdio: "pipe"
|
|
@@ -34408,11 +34470,11 @@ var runLegacyTestSeam = async (args) => {
|
|
|
34408
34470
|
function selectRunner(options) {
|
|
34409
34471
|
if (options.runner)
|
|
34410
34472
|
return options.runner;
|
|
34411
|
-
if (
|
|
34473
|
+
if (_internals48.spawnSync !== defaultLegacySpawnSync)
|
|
34412
34474
|
return runLegacyTestSeam;
|
|
34413
|
-
return
|
|
34475
|
+
return _internals48.runCommand;
|
|
34414
34476
|
}
|
|
34415
|
-
var
|
|
34477
|
+
var _internals48 = {
|
|
34416
34478
|
executeMutation,
|
|
34417
34479
|
computeReport,
|
|
34418
34480
|
executeMutationSuite,
|
|
@@ -35656,11 +35718,11 @@ var quality_budget = createSwarmTool({
|
|
|
35656
35718
|
}).optional().describe("Quality budget thresholds")
|
|
35657
35719
|
},
|
|
35658
35720
|
async execute(args, directory) {
|
|
35659
|
-
const result = await
|
|
35721
|
+
const result = await _internals49.qualityBudget(args, directory);
|
|
35660
35722
|
return JSON.stringify(result);
|
|
35661
35723
|
}
|
|
35662
35724
|
});
|
|
35663
|
-
var
|
|
35725
|
+
var _internals49 = {
|
|
35664
35726
|
qualityBudget
|
|
35665
35727
|
};
|
|
35666
35728
|
|
|
@@ -36529,7 +36591,7 @@ var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
|
36529
36591
|
var DEFAULT_TIMEOUT_MS2 = 30000;
|
|
36530
36592
|
var MAX_OUTPUT_BYTES = 10 * 1024 * 1024;
|
|
36531
36593
|
var KILL_GRACE_MS = 2000;
|
|
36532
|
-
var
|
|
36594
|
+
var _internals50 = {
|
|
36533
36595
|
isSemgrepAvailable,
|
|
36534
36596
|
checkSemgrepAvailable,
|
|
36535
36597
|
resetSemgrepCache,
|
|
@@ -36555,7 +36617,7 @@ function isSemgrepAvailable() {
|
|
|
36555
36617
|
}
|
|
36556
36618
|
}
|
|
36557
36619
|
async function checkSemgrepAvailable() {
|
|
36558
|
-
return
|
|
36620
|
+
return _internals50.isSemgrepAvailable();
|
|
36559
36621
|
}
|
|
36560
36622
|
function resetSemgrepCache() {
|
|
36561
36623
|
semgrepAvailableCache = null;
|
|
@@ -36742,12 +36804,12 @@ async function runSemgrep(options) {
|
|
|
36742
36804
|
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS2;
|
|
36743
36805
|
if (files.length === 0) {
|
|
36744
36806
|
return {
|
|
36745
|
-
available:
|
|
36807
|
+
available: _internals50.isSemgrepAvailable(),
|
|
36746
36808
|
findings: [],
|
|
36747
36809
|
engine: "tier_a"
|
|
36748
36810
|
};
|
|
36749
36811
|
}
|
|
36750
|
-
if (!
|
|
36812
|
+
if (!_internals50.isSemgrepAvailable()) {
|
|
36751
36813
|
return {
|
|
36752
36814
|
available: false,
|
|
36753
36815
|
findings: [],
|
|
@@ -36909,7 +36971,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
36909
36971
|
}
|
|
36910
36972
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
36911
36973
|
countMap.set(baseKey, occIdx + 1);
|
|
36912
|
-
const fp =
|
|
36974
|
+
const fp = _internals51.fingerprintFinding(finding, directory, occIdx);
|
|
36913
36975
|
return {
|
|
36914
36976
|
finding,
|
|
36915
36977
|
index: occIdx,
|
|
@@ -36923,6 +36985,7 @@ async function acquireLock2(lockPath) {
|
|
|
36923
36985
|
try {
|
|
36924
36986
|
const fd = fs25.openSync(lockPath, "wx");
|
|
36925
36987
|
fs25.closeSync(fd);
|
|
36988
|
+
invalidateCachedArtifact(lockPath);
|
|
36926
36989
|
return () => {
|
|
36927
36990
|
try {
|
|
36928
36991
|
fs25.unlinkSync(lockPath);
|
|
@@ -36978,7 +37041,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
36978
37041
|
}
|
|
36979
37042
|
} catch {}
|
|
36980
37043
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
36981
|
-
const indexed =
|
|
37044
|
+
const indexed = _internals51.assignOccurrenceIndices(findings, directory);
|
|
36982
37045
|
if (existing && !opts?.force) {
|
|
36983
37046
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
36984
37047
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -37033,6 +37096,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
37033
37096
|
}
|
|
37034
37097
|
fs25.writeFileSync(tempPath, json2, "utf-8");
|
|
37035
37098
|
fs25.renameSync(tempPath, baselinePath);
|
|
37099
|
+
invalidateCachedArtifact(baselinePath);
|
|
37036
37100
|
return {
|
|
37037
37101
|
status: "merged",
|
|
37038
37102
|
path: baselinePath,
|
|
@@ -37065,6 +37129,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
37065
37129
|
}
|
|
37066
37130
|
fs25.writeFileSync(tempPath, json, "utf-8");
|
|
37067
37131
|
fs25.renameSync(tempPath, baselinePath);
|
|
37132
|
+
invalidateCachedArtifact(baselinePath);
|
|
37068
37133
|
return {
|
|
37069
37134
|
status: "written",
|
|
37070
37135
|
path: baselinePath,
|
|
@@ -37118,7 +37183,7 @@ function loadBaseline(directory, phase) {
|
|
|
37118
37183
|
};
|
|
37119
37184
|
}
|
|
37120
37185
|
}
|
|
37121
|
-
var
|
|
37186
|
+
var _internals51 = {
|
|
37122
37187
|
fingerprintFinding,
|
|
37123
37188
|
assignOccurrenceIndices,
|
|
37124
37189
|
captureOrMergeBaseline,
|
|
@@ -37232,7 +37297,7 @@ async function sastScan(input, directory, config) {
|
|
|
37232
37297
|
let filesScanned = 0;
|
|
37233
37298
|
let _filesSkipped = 0;
|
|
37234
37299
|
const scannedFilePaths = [];
|
|
37235
|
-
const semgrepAvailable = !offline_only &&
|
|
37300
|
+
const semgrepAvailable = !offline_only && _internals52.isSemgrepAvailable();
|
|
37236
37301
|
const engine = semgrepAvailable ? "tier_a+tier_b" : "tier_a";
|
|
37237
37302
|
const filesByLanguage = new Map;
|
|
37238
37303
|
for (const filePath of changed_files) {
|
|
@@ -37295,13 +37360,13 @@ async function sastScan(input, directory, config) {
|
|
|
37295
37360
|
let semgrepResult;
|
|
37296
37361
|
if (bucketKey.startsWith("auto:")) {
|
|
37297
37362
|
const lang = bucketKey.slice("auto:".length);
|
|
37298
|
-
semgrepResult = await
|
|
37363
|
+
semgrepResult = await _internals52.runSemgrep({
|
|
37299
37364
|
files: bucketFiles,
|
|
37300
37365
|
lang,
|
|
37301
37366
|
useAutoConfig: true
|
|
37302
37367
|
});
|
|
37303
37368
|
} else {
|
|
37304
|
-
semgrepResult = await
|
|
37369
|
+
semgrepResult = await _internals52.runSemgrep({
|
|
37305
37370
|
files: bucketFiles
|
|
37306
37371
|
});
|
|
37307
37372
|
}
|
|
@@ -37543,11 +37608,11 @@ var sast_scan = createSwarmTool({
|
|
|
37543
37608
|
capture_baseline: safeArgs.capture_baseline,
|
|
37544
37609
|
phase: safeArgs.phase
|
|
37545
37610
|
};
|
|
37546
|
-
const result = await
|
|
37611
|
+
const result = await _internals52.sastScan(input, directory);
|
|
37547
37612
|
return JSON.stringify(result, null, 2);
|
|
37548
37613
|
}
|
|
37549
37614
|
});
|
|
37550
|
-
var
|
|
37615
|
+
var _internals52 = {
|
|
37551
37616
|
sastScan,
|
|
37552
37617
|
sast_scan,
|
|
37553
37618
|
isSemgrepAvailable: () => isSemgrepAvailable(),
|
|
@@ -38378,7 +38443,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
38378
38443
|
if (!plan) {
|
|
38379
38444
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
38380
38445
|
}
|
|
38381
|
-
if (!
|
|
38446
|
+
if (!_internals53.validatePlanPhases(plan)) {
|
|
38382
38447
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
38383
38448
|
}
|
|
38384
38449
|
let currentPhase = null;
|
|
@@ -38520,9 +38585,9 @@ function extractPhaseMetrics(content) {
|
|
|
38520
38585
|
async function getHandoffData(directory) {
|
|
38521
38586
|
const now = new Date().toISOString();
|
|
38522
38587
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
38523
|
-
const sessionState =
|
|
38588
|
+
const sessionState = _internals53.parseSessionState(sessionContent);
|
|
38524
38589
|
const plan = await loadPlanJsonOnly(directory);
|
|
38525
|
-
const planInfo =
|
|
38590
|
+
const planInfo = _internals53.extractCurrentPhaseFromPlan(plan);
|
|
38526
38591
|
if (!plan) {
|
|
38527
38592
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
38528
38593
|
if (planMdContent) {
|
|
@@ -38541,8 +38606,8 @@ async function getHandoffData(directory) {
|
|
|
38541
38606
|
}
|
|
38542
38607
|
}
|
|
38543
38608
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
38544
|
-
const recentDecisions =
|
|
38545
|
-
const rawPhaseMetrics =
|
|
38609
|
+
const recentDecisions = _internals53.extractDecisions(contextContent);
|
|
38610
|
+
const rawPhaseMetrics = _internals53.extractPhaseMetrics(contextContent);
|
|
38546
38611
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
38547
38612
|
let delegationState = null;
|
|
38548
38613
|
if (sessionState?.delegationState) {
|
|
@@ -38706,7 +38771,7 @@ ${lines.join(`
|
|
|
38706
38771
|
`)}
|
|
38707
38772
|
\`\`\``;
|
|
38708
38773
|
}
|
|
38709
|
-
var
|
|
38774
|
+
var _internals53 = {
|
|
38710
38775
|
getHandoffData,
|
|
38711
38776
|
formatHandoffMarkdown,
|
|
38712
38777
|
formatContinuationPrompt,
|
|
@@ -38865,6 +38930,7 @@ async function writeSnapshot(directory, state) {
|
|
|
38865
38930
|
}
|
|
38866
38931
|
} catch {}
|
|
38867
38932
|
renameSync12(tempPath, resolvedPath);
|
|
38933
|
+
invalidateCachedArtifact(resolvedPath);
|
|
38868
38934
|
} catch (error2) {
|
|
38869
38935
|
log("[snapshot-writer] write failed", {
|
|
38870
38936
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
@@ -38873,15 +38939,15 @@ async function writeSnapshot(directory, state) {
|
|
|
38873
38939
|
}
|
|
38874
38940
|
function createSnapshotWriterHook(directory) {
|
|
38875
38941
|
return (_input, _output) => {
|
|
38876
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
38942
|
+
_writeInFlight = _writeInFlight.then(() => _internals54.writeSnapshot(directory, swarmState), () => _internals54.writeSnapshot(directory, swarmState));
|
|
38877
38943
|
return _writeInFlight;
|
|
38878
38944
|
};
|
|
38879
38945
|
}
|
|
38880
38946
|
async function flushPendingSnapshot(directory) {
|
|
38881
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
38947
|
+
_writeInFlight = _writeInFlight.then(() => _internals54.writeSnapshot(directory, swarmState), () => _internals54.writeSnapshot(directory, swarmState));
|
|
38882
38948
|
await _writeInFlight;
|
|
38883
38949
|
}
|
|
38884
|
-
var
|
|
38950
|
+
var _internals54 = {
|
|
38885
38951
|
writeSnapshot,
|
|
38886
38952
|
createSnapshotWriterHook,
|
|
38887
38953
|
flushPendingSnapshot
|
|
@@ -38911,6 +38977,7 @@ async function handleHandoffCommand(directory, _args, sessionID) {
|
|
|
38911
38977
|
} catch {}
|
|
38912
38978
|
throw renameErr;
|
|
38913
38979
|
}
|
|
38980
|
+
invalidateCachedArtifact(resolvedPath);
|
|
38914
38981
|
const continuationPrompt = formatContinuationPrompt(handoffData);
|
|
38915
38982
|
const promptPath = validateSwarmPath(directory, "handoff-prompt.md");
|
|
38916
38983
|
const promptTempPath = `${promptPath}.tmp.${crypto5.randomUUID()}`;
|
|
@@ -39166,7 +39233,7 @@ function parseIssueRef(input, directory) {
|
|
|
39166
39233
|
}
|
|
39167
39234
|
return null;
|
|
39168
39235
|
}
|
|
39169
|
-
var
|
|
39236
|
+
var _internals55 = {
|
|
39170
39237
|
writeFileSync: fs28.writeFileSync,
|
|
39171
39238
|
mkdirSync: fs28.mkdirSync,
|
|
39172
39239
|
renameSync: fs28.renameSync,
|
|
@@ -39177,18 +39244,18 @@ var _internals54 = {
|
|
|
39177
39244
|
function atomicWriteFileSync(dir, filename, content) {
|
|
39178
39245
|
const tmpPath = path67.join(dir, `.tmp-${filename}-${Date.now()}-${process.pid}`);
|
|
39179
39246
|
const finalPath = path67.join(dir, filename);
|
|
39180
|
-
|
|
39247
|
+
_internals55.writeFileSync(tmpPath, content, "utf-8");
|
|
39181
39248
|
try {
|
|
39182
|
-
|
|
39249
|
+
_internals55.renameSync(tmpPath, finalPath);
|
|
39183
39250
|
} catch {
|
|
39184
39251
|
try {
|
|
39185
|
-
|
|
39252
|
+
_internals55.unlinkSync(finalPath);
|
|
39186
39253
|
} catch {}
|
|
39187
39254
|
try {
|
|
39188
|
-
|
|
39255
|
+
_internals55.renameSync(tmpPath, finalPath);
|
|
39189
39256
|
} catch (retryErr) {
|
|
39190
39257
|
try {
|
|
39191
|
-
|
|
39258
|
+
_internals55.unlinkSync(tmpPath);
|
|
39192
39259
|
} catch {}
|
|
39193
39260
|
throw retryErr;
|
|
39194
39261
|
}
|
|
@@ -39241,10 +39308,10 @@ ${USAGE9}`;
|
|
|
39241
39308
|
};
|
|
39242
39309
|
let oldTraceState = null;
|
|
39243
39310
|
try {
|
|
39244
|
-
oldTraceState =
|
|
39311
|
+
oldTraceState = _internals55.readFileSync(path67.join(swarmDir, "issue-trace-state.json"), "utf-8");
|
|
39245
39312
|
} catch {}
|
|
39246
39313
|
try {
|
|
39247
|
-
|
|
39314
|
+
_internals55.mkdirSync(swarmDir, { recursive: true });
|
|
39248
39315
|
atomicWriteFileSync(swarmDir, "issue-trace-state.json", JSON.stringify(traceState, null, 2));
|
|
39249
39316
|
atomicWriteFileSync(swarmDir, "issue-reference.json", JSON.stringify(issueReference, null, 2));
|
|
39250
39317
|
} catch (e) {
|
|
@@ -39254,11 +39321,11 @@ ${USAGE9}`;
|
|
|
39254
39321
|
} catch {}
|
|
39255
39322
|
} else {
|
|
39256
39323
|
try {
|
|
39257
|
-
|
|
39324
|
+
_internals55.unlinkSync(path67.join(swarmDir, "issue-trace-state.json"));
|
|
39258
39325
|
} catch {}
|
|
39259
39326
|
}
|
|
39260
39327
|
try {
|
|
39261
|
-
|
|
39328
|
+
_internals55.unlinkSync(path67.join(swarmDir, "issue-reference.json"));
|
|
39262
39329
|
} catch {}
|
|
39263
39330
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
39264
39331
|
return `Error: Failed to persist issue reference durably: ${errMsg}
|
|
@@ -39291,7 +39358,7 @@ init_knowledge_types();
|
|
|
39291
39358
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
39292
39359
|
const externalSentinelPath = path68.join(_directory, ".swarm", ".knowledge-external-migrated");
|
|
39293
39360
|
const contextPath = path68.join(_directory, ".swarm", "context.md");
|
|
39294
|
-
if (
|
|
39361
|
+
if (_internals56.existsSync(externalSentinelPath)) {
|
|
39295
39362
|
return {
|
|
39296
39363
|
migrated: false,
|
|
39297
39364
|
entriesMigrated: 0,
|
|
@@ -39300,7 +39367,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39300
39367
|
skippedReason: "external-sentinel-exists"
|
|
39301
39368
|
};
|
|
39302
39369
|
}
|
|
39303
|
-
if (!
|
|
39370
|
+
if (!_internals56.existsSync(contextPath)) {
|
|
39304
39371
|
return {
|
|
39305
39372
|
migrated: false,
|
|
39306
39373
|
entriesMigrated: 0,
|
|
@@ -39309,7 +39376,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39309
39376
|
skippedReason: "no-context-file"
|
|
39310
39377
|
};
|
|
39311
39378
|
}
|
|
39312
|
-
const contextContent = await
|
|
39379
|
+
const contextContent = await _internals56.readFile(contextPath, "utf-8");
|
|
39313
39380
|
if (contextContent.trim().length === 0) {
|
|
39314
39381
|
return {
|
|
39315
39382
|
migrated: false,
|
|
@@ -39327,7 +39394,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39327
39394
|
entriesCount++;
|
|
39328
39395
|
}
|
|
39329
39396
|
}
|
|
39330
|
-
await
|
|
39397
|
+
await _internals56.writeSentinel(externalSentinelPath, entriesCount, entriesCount);
|
|
39331
39398
|
return {
|
|
39332
39399
|
migrated: true,
|
|
39333
39400
|
entriesMigrated: entriesCount,
|
|
@@ -39335,7 +39402,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39335
39402
|
entriesTotal: entriesCount
|
|
39336
39403
|
};
|
|
39337
39404
|
}
|
|
39338
|
-
var
|
|
39405
|
+
var _internals56 = {
|
|
39339
39406
|
appendKnowledge,
|
|
39340
39407
|
migrateContextToKnowledge,
|
|
39341
39408
|
migrateKnowledgeToExternal,
|
|
@@ -39386,9 +39453,9 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39386
39453
|
skippedReason: "empty-context"
|
|
39387
39454
|
};
|
|
39388
39455
|
}
|
|
39389
|
-
const rawEntries =
|
|
39456
|
+
const rawEntries = _internals56.parseContextMd(contextContent);
|
|
39390
39457
|
if (rawEntries.length === 0) {
|
|
39391
|
-
await
|
|
39458
|
+
await _internals56.writeSentinel(sentinelPath, 0, 0);
|
|
39392
39459
|
return {
|
|
39393
39460
|
migrated: true,
|
|
39394
39461
|
entriesMigrated: 0,
|
|
@@ -39399,10 +39466,10 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39399
39466
|
const existing = await readKnowledge(knowledgePath);
|
|
39400
39467
|
let migrated = 0;
|
|
39401
39468
|
let dropped = 0;
|
|
39402
|
-
const projectName =
|
|
39469
|
+
const projectName = _internals56.inferProjectName(directory);
|
|
39403
39470
|
for (const raw of rawEntries) {
|
|
39404
39471
|
if (config.validation_enabled !== false) {
|
|
39405
|
-
const category = raw.categoryHint ??
|
|
39472
|
+
const category = raw.categoryHint ?? _internals56.inferCategoryFromText(raw.text);
|
|
39406
39473
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
39407
39474
|
category,
|
|
39408
39475
|
scope: "global",
|
|
@@ -39422,8 +39489,8 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39422
39489
|
const entry = {
|
|
39423
39490
|
id: randomUUID8(),
|
|
39424
39491
|
tier: "swarm",
|
|
39425
|
-
lesson:
|
|
39426
|
-
category: raw.categoryHint ??
|
|
39492
|
+
lesson: _internals56.truncateLesson(raw.text),
|
|
39493
|
+
category: raw.categoryHint ?? _internals56.inferCategoryFromText(raw.text),
|
|
39427
39494
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
39428
39495
|
scope: "global",
|
|
39429
39496
|
confidence: 0.3,
|
|
@@ -39446,7 +39513,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39446
39513
|
if (migrated > 0) {
|
|
39447
39514
|
await rewriteKnowledge(knowledgePath, existing);
|
|
39448
39515
|
}
|
|
39449
|
-
await
|
|
39516
|
+
await _internals56.writeSentinel(sentinelPath, migrated, dropped);
|
|
39450
39517
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
39451
39518
|
return {
|
|
39452
39519
|
migrated: true,
|
|
@@ -39456,7 +39523,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39456
39523
|
};
|
|
39457
39524
|
}
|
|
39458
39525
|
async function migrateHiveKnowledgeLegacy(config) {
|
|
39459
|
-
const legacyHivePath =
|
|
39526
|
+
const legacyHivePath = _internals56.resolveLegacyHiveKnowledgePath();
|
|
39460
39527
|
const canonicalHivePath = resolveHiveKnowledgePath2();
|
|
39461
39528
|
const sentinelPath = path68.join(path68.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
39462
39529
|
if (existsSync39(sentinelPath)) {
|
|
@@ -39479,7 +39546,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39479
39546
|
}
|
|
39480
39547
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
39481
39548
|
if (legacyEntries.length === 0) {
|
|
39482
|
-
await
|
|
39549
|
+
await _internals56.writeSentinel(sentinelPath, 0, 0);
|
|
39483
39550
|
return {
|
|
39484
39551
|
migrated: true,
|
|
39485
39552
|
entriesMigrated: 0,
|
|
@@ -39527,7 +39594,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39527
39594
|
const newHiveEntry = {
|
|
39528
39595
|
id: resolvedId,
|
|
39529
39596
|
tier: "hive",
|
|
39530
|
-
lesson:
|
|
39597
|
+
lesson: _internals56.truncateLesson(lesson),
|
|
39531
39598
|
category,
|
|
39532
39599
|
tags: ["migration:legacy-hive"],
|
|
39533
39600
|
scope: scopeTag,
|
|
@@ -39546,7 +39613,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39546
39613
|
encounter_score: 1
|
|
39547
39614
|
};
|
|
39548
39615
|
try {
|
|
39549
|
-
await
|
|
39616
|
+
await _internals56.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
39550
39617
|
existingHiveEntries.push(newHiveEntry);
|
|
39551
39618
|
migrated++;
|
|
39552
39619
|
} catch (appendError) {
|
|
@@ -39562,7 +39629,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39562
39629
|
dropped++;
|
|
39563
39630
|
}
|
|
39564
39631
|
}
|
|
39565
|
-
await
|
|
39632
|
+
await _internals56.writeSentinel(sentinelPath, migrated, dropped);
|
|
39566
39633
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
39567
39634
|
return {
|
|
39568
39635
|
migrated: true,
|
|
@@ -39573,7 +39640,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39573
39640
|
};
|
|
39574
39641
|
}
|
|
39575
39642
|
function parseContextMd(content) {
|
|
39576
|
-
const sections =
|
|
39643
|
+
const sections = _internals56.splitIntoSections(content);
|
|
39577
39644
|
const entries = [];
|
|
39578
39645
|
const seen = new Set;
|
|
39579
39646
|
const sectionPatterns = [
|
|
@@ -39589,7 +39656,7 @@ function parseContextMd(content) {
|
|
|
39589
39656
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
39590
39657
|
if (!match)
|
|
39591
39658
|
continue;
|
|
39592
|
-
const bullets =
|
|
39659
|
+
const bullets = _internals56.extractBullets(section.body);
|
|
39593
39660
|
for (const bullet of bullets) {
|
|
39594
39661
|
if (bullet.length < 15)
|
|
39595
39662
|
continue;
|
|
@@ -39598,9 +39665,9 @@ function parseContextMd(content) {
|
|
|
39598
39665
|
continue;
|
|
39599
39666
|
seen.add(normalized);
|
|
39600
39667
|
entries.push({
|
|
39601
|
-
text:
|
|
39668
|
+
text: _internals56.truncateLesson(bullet),
|
|
39602
39669
|
sourceSection: match.sourceSection,
|
|
39603
|
-
categoryHint:
|
|
39670
|
+
categoryHint: _internals56.inferCategoryFromText(bullet)
|
|
39604
39671
|
});
|
|
39605
39672
|
}
|
|
39606
39673
|
}
|
|
@@ -39690,8 +39757,8 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
39690
39757
|
schema_version: 1,
|
|
39691
39758
|
migration_tool: "knowledge-migrator.ts"
|
|
39692
39759
|
};
|
|
39693
|
-
await
|
|
39694
|
-
await
|
|
39760
|
+
await _internals56.mkdir(path68.dirname(sentinelPath), { recursive: true });
|
|
39761
|
+
await _internals56.writeFile(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
39695
39762
|
}
|
|
39696
39763
|
function resolveLegacyHiveKnowledgePath() {
|
|
39697
39764
|
const platform = process.platform;
|
|
@@ -40103,7 +40170,7 @@ function timeoutMessage(timeoutMs) {
|
|
|
40103
40170
|
async function computeWithTimeout(directory, currentPhase, timeoutMs) {
|
|
40104
40171
|
const controller = new AbortController;
|
|
40105
40172
|
let timeout;
|
|
40106
|
-
const metricsPromise =
|
|
40173
|
+
const metricsPromise = _internals57.computeLearningMetrics(directory, {
|
|
40107
40174
|
currentPhase,
|
|
40108
40175
|
signal: controller.signal
|
|
40109
40176
|
});
|
|
@@ -40160,7 +40227,7 @@ ${JSON.stringify({
|
|
|
40160
40227
|
return `Error computing learning metrics: ${message}. Run /swarm diagnose to check .swarm/ health.`;
|
|
40161
40228
|
}
|
|
40162
40229
|
}
|
|
40163
|
-
var
|
|
40230
|
+
var _internals57 = {
|
|
40164
40231
|
computeLearningMetrics
|
|
40165
40232
|
};
|
|
40166
40233
|
|
|
@@ -40681,7 +40748,7 @@ async function readLatestLoopState(directory) {
|
|
|
40681
40748
|
return null;
|
|
40682
40749
|
}
|
|
40683
40750
|
}
|
|
40684
|
-
var
|
|
40751
|
+
var _internals58 = {
|
|
40685
40752
|
readLatestLoopState
|
|
40686
40753
|
};
|
|
40687
40754
|
var USAGE10 = `Usage: /swarm loop <objective> [--max-cycles 1..5] [--autonomy checkpoint|auto] [--depth standard|exhaustive] [--resume]
|
|
@@ -40794,7 +40861,7 @@ ${USAGE10}`;
|
|
|
40794
40861
|
}
|
|
40795
40862
|
let autonomy = parsed.autonomy;
|
|
40796
40863
|
if (parsed.resume && !parsed.autonomyExplicit) {
|
|
40797
|
-
const state = await
|
|
40864
|
+
const state = await _internals58.readLatestLoopState(_directory);
|
|
40798
40865
|
if (state?.autonomy && AUTONOMY_LEVELS.has(state.autonomy)) {
|
|
40799
40866
|
autonomy = state.autonomy;
|
|
40800
40867
|
}
|
|
@@ -42348,15 +42415,15 @@ async function handleMemoryUnlinkCommand(directory, args) {
|
|
|
42348
42415
|
}
|
|
42349
42416
|
|
|
42350
42417
|
// src/services/plan-service.ts
|
|
42351
|
-
var
|
|
42418
|
+
var _internals59 = {
|
|
42352
42419
|
loadPlanJsonOnly,
|
|
42353
42420
|
derivePlanMarkdown,
|
|
42354
42421
|
readSwarmFileAsync
|
|
42355
42422
|
};
|
|
42356
42423
|
async function getPlanData(directory, phaseArg) {
|
|
42357
|
-
const plan = await
|
|
42424
|
+
const plan = await _internals59.loadPlanJsonOnly(directory);
|
|
42358
42425
|
if (plan) {
|
|
42359
|
-
const fullMarkdown =
|
|
42426
|
+
const fullMarkdown = _internals59.derivePlanMarkdown(plan);
|
|
42360
42427
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
42361
42428
|
return {
|
|
42362
42429
|
hasPlan: true,
|
|
@@ -42399,7 +42466,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
42399
42466
|
isLegacy: false
|
|
42400
42467
|
};
|
|
42401
42468
|
}
|
|
42402
|
-
const planContent = await
|
|
42469
|
+
const planContent = await _internals59.readSwarmFileAsync(directory, "plan.md");
|
|
42403
42470
|
if (!planContent) {
|
|
42404
42471
|
return {
|
|
42405
42472
|
hasPlan: false,
|
|
@@ -42496,7 +42563,7 @@ async function handlePlanCommand(directory, args) {
|
|
|
42496
42563
|
return formatPlanMarkdown(planData);
|
|
42497
42564
|
}
|
|
42498
42565
|
// src/commands/post-mortem.ts
|
|
42499
|
-
var
|
|
42566
|
+
var _internals60 = {
|
|
42500
42567
|
createCuratorLLMDelegate,
|
|
42501
42568
|
runCuratorPostMortem
|
|
42502
42569
|
};
|
|
@@ -42544,10 +42611,10 @@ async function handlePostMortemCommand(directory, args, options) {
|
|
|
42544
42611
|
};
|
|
42545
42612
|
if (options?.sessionID) {
|
|
42546
42613
|
try {
|
|
42547
|
-
pmOptions.llmDelegate =
|
|
42614
|
+
pmOptions.llmDelegate = _internals60.createCuratorLLMDelegate(directory, "postmortem", options.sessionID);
|
|
42548
42615
|
} catch {}
|
|
42549
42616
|
}
|
|
42550
|
-
const result = await
|
|
42617
|
+
const result = await _internals60.runCuratorPostMortem(directory, pmOptions);
|
|
42551
42618
|
const lines = [];
|
|
42552
42619
|
if (result.success) {
|
|
42553
42620
|
lines.push("## Post-Mortem Report Generated");
|
|
@@ -42805,7 +42872,7 @@ function formatMergeGroupStatus(status, conclusion, htmlUrl) {
|
|
|
42805
42872
|
}
|
|
42806
42873
|
return parts.join(" ");
|
|
42807
42874
|
}
|
|
42808
|
-
var
|
|
42875
|
+
var _internals61 = {
|
|
42809
42876
|
formatRelativeTime,
|
|
42810
42877
|
formatMergeGroupStatus,
|
|
42811
42878
|
listActive,
|
|
@@ -42813,7 +42880,7 @@ var _internals60 = {
|
|
|
42813
42880
|
parseMergeGroupRuns
|
|
42814
42881
|
};
|
|
42815
42882
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID, source) {
|
|
42816
|
-
const allActive = await
|
|
42883
|
+
const allActive = await _internals61.listActive(directory);
|
|
42817
42884
|
const allSessions = source === "cli";
|
|
42818
42885
|
const subs = allSessions ? allActive : allActive.filter((record) => record.sessionID === sessionID);
|
|
42819
42886
|
if (subs.length === 0) {
|
|
@@ -42829,7 +42896,7 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID, source)
|
|
|
42829
42896
|
const index = i + 1;
|
|
42830
42897
|
lines.push(` ${index}. ${sub.repoFullName}#${sub.prNumber}`);
|
|
42831
42898
|
lines.push(` URL: ${sub.prUrl}`);
|
|
42832
|
-
const mergeGroupRuns = await
|
|
42899
|
+
const mergeGroupRuns = await _internals61.listMergeGroupRuns(directory, sub.repoFullName, sub.prNumber);
|
|
42833
42900
|
if (mergeGroupRuns.runs.length > 0) {
|
|
42834
42901
|
lines.push(" Merge-group runs:");
|
|
42835
42902
|
for (const run of mergeGroupRuns.runs) {
|
|
@@ -42970,7 +43037,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
42970
43037
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
42971
43038
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
42972
43039
|
try {
|
|
42973
|
-
const config =
|
|
43040
|
+
const config = _internals62.loadPluginConfig(directory);
|
|
42974
43041
|
const prMonitorConfig = config.pr_monitor;
|
|
42975
43042
|
if (!prMonitorConfig?.enabled) {
|
|
42976
43043
|
return [
|
|
@@ -42980,7 +43047,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
42980
43047
|
].join(`
|
|
42981
43048
|
`);
|
|
42982
43049
|
}
|
|
42983
|
-
await
|
|
43050
|
+
await _internals62.subscribe(directory, {
|
|
42984
43051
|
sessionID,
|
|
42985
43052
|
prNumber: prInfo.number,
|
|
42986
43053
|
repoFullName,
|
|
@@ -43008,7 +43075,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
43008
43075
|
`);
|
|
43009
43076
|
}
|
|
43010
43077
|
}
|
|
43011
|
-
var
|
|
43078
|
+
var _internals62 = {
|
|
43012
43079
|
loadPluginConfig,
|
|
43013
43080
|
subscribe
|
|
43014
43081
|
};
|
|
@@ -43031,9 +43098,9 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
43031
43098
|
`);
|
|
43032
43099
|
}
|
|
43033
43100
|
const refToken = rest[0];
|
|
43034
|
-
const prInfo =
|
|
43101
|
+
const prInfo = _internals63.parsePrRef(refToken, directory);
|
|
43035
43102
|
if (!prInfo) {
|
|
43036
|
-
if (
|
|
43103
|
+
if (_internals63.looksLikePrRef(refToken)) {
|
|
43037
43104
|
return [
|
|
43038
43105
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
43039
43106
|
"",
|
|
@@ -43054,8 +43121,8 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
43054
43121
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
43055
43122
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
43056
43123
|
try {
|
|
43057
|
-
const correlationId =
|
|
43058
|
-
const result = await
|
|
43124
|
+
const correlationId = _internals63.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
43125
|
+
const result = await _internals63.unsubscribe(directory, correlationId);
|
|
43059
43126
|
if (!result) {
|
|
43060
43127
|
return [
|
|
43061
43128
|
`Not subscribed to ${prUrl}`,
|
|
@@ -43082,7 +43149,7 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
43082
43149
|
`);
|
|
43083
43150
|
}
|
|
43084
43151
|
}
|
|
43085
|
-
var
|
|
43152
|
+
var _internals63 = {
|
|
43086
43153
|
unsubscribe,
|
|
43087
43154
|
buildCorrelationId,
|
|
43088
43155
|
parsePrRef,
|
|
@@ -43522,15 +43589,15 @@ var lint = createSwarmTool({
|
|
|
43522
43589
|
}
|
|
43523
43590
|
const { mode } = args;
|
|
43524
43591
|
const cwd = directory;
|
|
43525
|
-
const linter = await
|
|
43592
|
+
const linter = await _internals64.detectAvailableLinter(directory);
|
|
43526
43593
|
if (linter) {
|
|
43527
|
-
const result = await
|
|
43594
|
+
const result = await _internals64.runLint(linter, mode, directory);
|
|
43528
43595
|
return JSON.stringify(result, null, 2);
|
|
43529
43596
|
}
|
|
43530
|
-
const additionalLinter =
|
|
43597
|
+
const additionalLinter = _internals64.detectAdditionalLinter(cwd);
|
|
43531
43598
|
if (additionalLinter) {
|
|
43532
43599
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
43533
|
-
const result = await
|
|
43600
|
+
const result = await _internals64.runAdditionalLint(additionalLinter, mode, cwd);
|
|
43534
43601
|
return JSON.stringify(result, null, 2);
|
|
43535
43602
|
}
|
|
43536
43603
|
const errorResult = {
|
|
@@ -43544,7 +43611,7 @@ For Rust: rustup component add clippy`
|
|
|
43544
43611
|
return JSON.stringify(errorResult, null, 2);
|
|
43545
43612
|
}
|
|
43546
43613
|
});
|
|
43547
|
-
var
|
|
43614
|
+
var _internals64 = {
|
|
43548
43615
|
detectAvailableLinter,
|
|
43549
43616
|
runLint,
|
|
43550
43617
|
detectAdditionalLinter,
|
|
@@ -43916,13 +43983,13 @@ function readBoundedFile(filePath) {
|
|
|
43916
43983
|
let fd;
|
|
43917
43984
|
try {
|
|
43918
43985
|
const flags = fs31.constants.O_RDONLY | (O_NOFOLLOW !== undefined ? O_NOFOLLOW : 0);
|
|
43919
|
-
fd =
|
|
43986
|
+
fd = _internals65.openFile(filePath, flags);
|
|
43920
43987
|
} catch {
|
|
43921
43988
|
return { status: "incomplete", reason: "read_error" };
|
|
43922
43989
|
}
|
|
43923
43990
|
let outcome;
|
|
43924
43991
|
try {
|
|
43925
|
-
const stat6 =
|
|
43992
|
+
const stat6 = _internals65.fstatFile(fd);
|
|
43926
43993
|
const initialSize = stat6.size;
|
|
43927
43994
|
if (!stat6.isFile()) {
|
|
43928
43995
|
outcome = { status: "incomplete", reason: "non_file" };
|
|
@@ -43931,12 +43998,12 @@ function readBoundedFile(filePath) {
|
|
|
43931
43998
|
const buffer = Buffer.allocUnsafe(bufferLength);
|
|
43932
43999
|
let bytesRead = 0;
|
|
43933
44000
|
while (bytesRead < buffer.length) {
|
|
43934
|
-
const count =
|
|
44001
|
+
const count = _internals65.readFileChunk(fd, buffer, bytesRead, buffer.length - bytesRead, null);
|
|
43935
44002
|
if (count === 0)
|
|
43936
44003
|
break;
|
|
43937
44004
|
bytesRead += count;
|
|
43938
44005
|
}
|
|
43939
|
-
const postStat =
|
|
44006
|
+
const postStat = _internals65.fstatFile(fd);
|
|
43940
44007
|
if (postStat.size !== initialSize) {
|
|
43941
44008
|
outcome = {
|
|
43942
44009
|
status: "incomplete",
|
|
@@ -43954,7 +44021,7 @@ function readBoundedFile(filePath) {
|
|
|
43954
44021
|
outcome = { status: "incomplete", reason: "read_error" };
|
|
43955
44022
|
}
|
|
43956
44023
|
try {
|
|
43957
|
-
|
|
44024
|
+
_internals65.closeFile(fd);
|
|
43958
44025
|
} catch {
|
|
43959
44026
|
return { status: "incomplete", reason: "read_error" };
|
|
43960
44027
|
}
|
|
@@ -44142,8 +44209,8 @@ async function collectScannableFiles(dir, excludeExact, excludeGlobs, scanDir, v
|
|
|
44142
44209
|
while (true) {
|
|
44143
44210
|
if (state.entriesSinceYield >= DISCOVERY_YIELD_INTERVAL) {
|
|
44144
44211
|
state.entriesSinceYield = 0;
|
|
44145
|
-
await
|
|
44146
|
-
if (
|
|
44212
|
+
await _internals65.yieldToEventLoop();
|
|
44213
|
+
if (_internals65.now() >= state.deadline) {
|
|
44147
44214
|
state.deadlineExceeded = true;
|
|
44148
44215
|
recordIncompletePath(state.incompletePaths, scanDir, currentDir, "deadline");
|
|
44149
44216
|
stoppedEarly = true;
|
|
@@ -44206,7 +44273,7 @@ async function collectScannableFiles(dir, excludeExact, excludeGlobs, scanDir, v
|
|
|
44206
44273
|
}
|
|
44207
44274
|
} finally {
|
|
44208
44275
|
try {
|
|
44209
|
-
|
|
44276
|
+
_internals65.closeDirectory(directory);
|
|
44210
44277
|
} catch (error2) {
|
|
44211
44278
|
if (error2.code !== "ERR_DIR_CLOSED") {
|
|
44212
44279
|
state.cleanupFailed = true;
|
|
@@ -44328,7 +44395,7 @@ var secretscan = createSwarmTool({
|
|
|
44328
44395
|
symlinkSkipped: 0
|
|
44329
44396
|
};
|
|
44330
44397
|
const visited = new Set;
|
|
44331
|
-
const deadline =
|
|
44398
|
+
const deadline = _internals65.now() + SCAN_TIME_BUDGET_MS;
|
|
44332
44399
|
const discovery = {
|
|
44333
44400
|
files: [],
|
|
44334
44401
|
totalCandidates: 0,
|
|
@@ -44340,7 +44407,7 @@ var secretscan = createSwarmTool({
|
|
|
44340
44407
|
directoriesQueued: 1,
|
|
44341
44408
|
unexaminedDirectories: 0
|
|
44342
44409
|
};
|
|
44343
|
-
await
|
|
44410
|
+
await _internals65.yieldToEventLoop();
|
|
44344
44411
|
await collectScannableFiles(scanDir, excludeExact, excludeGlobs, scanDir, visited, stats, discovery);
|
|
44345
44412
|
const files = discovery.files;
|
|
44346
44413
|
files.sort(compareFilePaths);
|
|
@@ -44359,7 +44426,7 @@ var secretscan = createSwarmTool({
|
|
|
44359
44426
|
let skippedFiles = stats.skippedFiles;
|
|
44360
44427
|
let incompleteFiles = stats.fileErrors + Math.max(0, discovery.totalCandidates - filesToScan.length) + (discovery.deadlineExceeded || discovery.cleanupFailed ? 1 : 0) + discovery.unexaminedDirectories;
|
|
44361
44428
|
for (let index = 0;index < filesToScan.length; index++) {
|
|
44362
|
-
if (
|
|
44429
|
+
if (_internals65.now() >= deadline) {
|
|
44363
44430
|
for (const remaining of filesToScan.slice(index)) {
|
|
44364
44431
|
recordIncompletePath(discovery.incompletePaths, scanDir, remaining, "deadline");
|
|
44365
44432
|
}
|
|
@@ -44395,7 +44462,7 @@ var secretscan = createSwarmTool({
|
|
|
44395
44462
|
}
|
|
44396
44463
|
}
|
|
44397
44464
|
if (index + 1 < filesToScan.length) {
|
|
44398
|
-
await
|
|
44465
|
+
await _internals65.yieldToEventLoop();
|
|
44399
44466
|
}
|
|
44400
44467
|
}
|
|
44401
44468
|
allFindings.sort((a, b) => {
|
|
@@ -44458,7 +44525,7 @@ var secretscan = createSwarmTool({
|
|
|
44458
44525
|
});
|
|
44459
44526
|
async function runSecretscan(directory) {
|
|
44460
44527
|
try {
|
|
44461
|
-
const result = await
|
|
44528
|
+
const result = await _internals65.secretscan.execute({ directory }, {});
|
|
44462
44529
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
44463
44530
|
return JSON.parse(jsonStr);
|
|
44464
44531
|
} catch (e) {
|
|
@@ -44509,10 +44576,10 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44509
44576
|
if (files.length > filesToScan.length) {
|
|
44510
44577
|
recordIncompletePath(incompletePaths, canonicalRoot, canonicalRoot, "max_files");
|
|
44511
44578
|
}
|
|
44512
|
-
const deadline =
|
|
44513
|
-
await
|
|
44579
|
+
const deadline = _internals65.now() + SCAN_TIME_BUDGET_MS;
|
|
44580
|
+
await _internals65.yieldToEventLoop();
|
|
44514
44581
|
for (let index = 0;index < filesToScan.length; index++) {
|
|
44515
|
-
if (
|
|
44582
|
+
if (_internals65.now() >= deadline) {
|
|
44516
44583
|
for (const remaining of filesToScan.slice(index)) {
|
|
44517
44584
|
const remainingPath = path77.isAbsolute(remaining) ? path77.resolve(remaining) : path77.resolve(rawRoot, remaining);
|
|
44518
44585
|
recordIncompletePath(incompletePaths, canonicalRoot, remainingPath, "deadline");
|
|
@@ -44539,7 +44606,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44539
44606
|
}
|
|
44540
44607
|
let lstat3;
|
|
44541
44608
|
try {
|
|
44542
|
-
lstat3 =
|
|
44609
|
+
lstat3 = _internals65.lstatFile(resolvedPath);
|
|
44543
44610
|
} catch (error2) {
|
|
44544
44611
|
const err = error2;
|
|
44545
44612
|
if (err.code === "ENOENT") {
|
|
@@ -44608,7 +44675,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44608
44675
|
assertNever(outcome);
|
|
44609
44676
|
}
|
|
44610
44677
|
if (index + 1 < filesToScan.length) {
|
|
44611
|
-
await
|
|
44678
|
+
await _internals65.yieldToEventLoop();
|
|
44612
44679
|
}
|
|
44613
44680
|
}
|
|
44614
44681
|
findings.sort((a, b) => {
|
|
@@ -44638,7 +44705,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44638
44705
|
};
|
|
44639
44706
|
}
|
|
44640
44707
|
}
|
|
44641
|
-
var
|
|
44708
|
+
var _internals65 = {
|
|
44642
44709
|
secretscan,
|
|
44643
44710
|
runSecretscan,
|
|
44644
44711
|
runSecretscanOnFiles,
|
|
@@ -44922,7 +44989,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
44922
44989
|
}
|
|
44923
44990
|
return impactMap;
|
|
44924
44991
|
}
|
|
44925
|
-
var
|
|
44992
|
+
var _internals66 = {
|
|
44926
44993
|
validateProjectRoot,
|
|
44927
44994
|
normalizePath: normalizePath2,
|
|
44928
44995
|
isCacheStale,
|
|
@@ -44937,8 +45004,8 @@ var _internals65 = {
|
|
|
44937
45004
|
_clearGoModuleCache
|
|
44938
45005
|
};
|
|
44939
45006
|
async function buildImpactMap(cwd) {
|
|
44940
|
-
const impactMap = await
|
|
44941
|
-
await
|
|
45007
|
+
const impactMap = await _internals66.buildImpactMapInternal(cwd);
|
|
45008
|
+
await _internals66.saveImpactMap(cwd, impactMap);
|
|
44942
45009
|
return impactMap;
|
|
44943
45010
|
}
|
|
44944
45011
|
async function loadImpactMap(cwd, options) {
|
|
@@ -44952,7 +45019,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
44952
45019
|
const hasValidValues = Object.values(map).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
44953
45020
|
if (hasValidValues) {
|
|
44954
45021
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
44955
|
-
if (!
|
|
45022
|
+
if (!_internals66.isCacheStale(map, generatedAt)) {
|
|
44956
45023
|
return map;
|
|
44957
45024
|
}
|
|
44958
45025
|
if (options?.skipRebuild) {
|
|
@@ -44972,13 +45039,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
44972
45039
|
if (options?.skipRebuild) {
|
|
44973
45040
|
return {};
|
|
44974
45041
|
}
|
|
44975
|
-
return
|
|
45042
|
+
return _internals66.buildImpactMap(cwd);
|
|
44976
45043
|
}
|
|
44977
45044
|
async function saveImpactMap(cwd, impactMap) {
|
|
44978
45045
|
if (!path78.isAbsolute(cwd)) {
|
|
44979
45046
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
44980
45047
|
}
|
|
44981
|
-
|
|
45048
|
+
_internals66.validateProjectRoot(cwd);
|
|
44982
45049
|
const cacheDir2 = path78.join(cwd, ".swarm", "cache");
|
|
44983
45050
|
const cachePath = path78.join(cacheDir2, "impact-map.json");
|
|
44984
45051
|
if (!fs32.existsSync(cacheDir2)) {
|
|
@@ -45002,7 +45069,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
45002
45069
|
};
|
|
45003
45070
|
}
|
|
45004
45071
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
45005
|
-
const impactMap = await
|
|
45072
|
+
const impactMap = await _internals66.loadImpactMap(cwd);
|
|
45006
45073
|
const impactedTestsSet = new Set;
|
|
45007
45074
|
const untestedFiles = [];
|
|
45008
45075
|
let visitedCount = 0;
|
|
@@ -45279,7 +45346,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
45279
45346
|
}
|
|
45280
45347
|
const historyPath = getHistoryPath(workingDir);
|
|
45281
45348
|
const historyDir = path79.dirname(historyPath);
|
|
45282
|
-
|
|
45349
|
+
_internals67.validateProjectRoot(workingDir);
|
|
45283
45350
|
if (!fs33.existsSync(historyDir)) {
|
|
45284
45351
|
fs33.mkdirSync(historyDir, { recursive: true });
|
|
45285
45352
|
}
|
|
@@ -45402,7 +45469,7 @@ function getAllHistory(workingDir) {
|
|
|
45402
45469
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
45403
45470
|
return records;
|
|
45404
45471
|
}
|
|
45405
|
-
var
|
|
45472
|
+
var _internals67 = {
|
|
45406
45473
|
validateProjectRoot
|
|
45407
45474
|
};
|
|
45408
45475
|
|
|
@@ -45494,7 +45561,7 @@ var MAX_SAFE_TEST_FILES = 50;
|
|
|
45494
45561
|
var MAX_SAFE_SOURCE_FILES = 1;
|
|
45495
45562
|
async function estimateFanOut(sourceFiles, cwd) {
|
|
45496
45563
|
try {
|
|
45497
|
-
const impactMap = await
|
|
45564
|
+
const impactMap = await _internals68.loadImpactMap(cwd, {
|
|
45498
45565
|
skipRebuild: true
|
|
45499
45566
|
});
|
|
45500
45567
|
const uniqueTestFiles = new Set;
|
|
@@ -45584,45 +45651,45 @@ function hasDevDependency(devDeps, ...patterns) {
|
|
|
45584
45651
|
return hasPackageJsonDependency(devDeps, ...patterns);
|
|
45585
45652
|
}
|
|
45586
45653
|
function detectGoTest(cwd) {
|
|
45587
|
-
return
|
|
45654
|
+
return _internals68.existsSync(path81.join(cwd, "go.mod")) && _internals68.isCommandAvailable("go");
|
|
45588
45655
|
}
|
|
45589
45656
|
function detectJavaMaven(cwd) {
|
|
45590
|
-
return
|
|
45657
|
+
return _internals68.existsSync(path81.join(cwd, "pom.xml")) && _internals68.isCommandAvailable("mvn");
|
|
45591
45658
|
}
|
|
45592
45659
|
function detectGradle(cwd) {
|
|
45593
|
-
const hasBuildFile =
|
|
45594
|
-
const hasGradlew =
|
|
45595
|
-
return hasBuildFile && (hasGradlew ||
|
|
45660
|
+
const hasBuildFile = _internals68.existsSync(path81.join(cwd, "build.gradle")) || _internals68.existsSync(path81.join(cwd, "build.gradle.kts"));
|
|
45661
|
+
const hasGradlew = _internals68.existsSync(path81.join(cwd, "gradlew")) || _internals68.existsSync(path81.join(cwd, "gradlew.bat"));
|
|
45662
|
+
return hasBuildFile && (hasGradlew || _internals68.isCommandAvailable("gradle"));
|
|
45596
45663
|
}
|
|
45597
45664
|
function detectDotnetTest(cwd) {
|
|
45598
45665
|
try {
|
|
45599
|
-
const files =
|
|
45666
|
+
const files = _internals68.readdirSync(cwd);
|
|
45600
45667
|
const hasCsproj = files.some((f) => f.endsWith(".csproj"));
|
|
45601
|
-
return hasCsproj &&
|
|
45668
|
+
return hasCsproj && _internals68.isCommandAvailable("dotnet");
|
|
45602
45669
|
} catch {
|
|
45603
45670
|
return false;
|
|
45604
45671
|
}
|
|
45605
45672
|
}
|
|
45606
45673
|
function detectCTest(cwd) {
|
|
45607
|
-
const hasSource =
|
|
45608
|
-
const hasBuildCache =
|
|
45609
|
-
return (hasSource || hasBuildCache) &&
|
|
45674
|
+
const hasSource = _internals68.existsSync(path81.join(cwd, "CMakeLists.txt"));
|
|
45675
|
+
const hasBuildCache = _internals68.existsSync(path81.join(cwd, "CMakeCache.txt")) || _internals68.existsSync(path81.join(cwd, "build", "CMakeCache.txt"));
|
|
45676
|
+
return (hasSource || hasBuildCache) && _internals68.isCommandAvailable("ctest");
|
|
45610
45677
|
}
|
|
45611
45678
|
function detectSwiftTest(cwd) {
|
|
45612
|
-
return
|
|
45679
|
+
return _internals68.existsSync(path81.join(cwd, "Package.swift")) && _internals68.isCommandAvailable("swift");
|
|
45613
45680
|
}
|
|
45614
45681
|
function detectDartTest(cwd) {
|
|
45615
|
-
return
|
|
45682
|
+
return _internals68.existsSync(path81.join(cwd, "pubspec.yaml")) && (_internals68.isCommandAvailable("dart") || _internals68.isCommandAvailable("flutter"));
|
|
45616
45683
|
}
|
|
45617
45684
|
function detectRSpec(cwd) {
|
|
45618
|
-
const hasRSpecFile =
|
|
45619
|
-
const hasGemfile =
|
|
45620
|
-
const hasSpecDir =
|
|
45685
|
+
const hasRSpecFile = _internals68.existsSync(path81.join(cwd, ".rspec"));
|
|
45686
|
+
const hasGemfile = _internals68.existsSync(path81.join(cwd, "Gemfile"));
|
|
45687
|
+
const hasSpecDir = _internals68.existsSync(path81.join(cwd, "spec"));
|
|
45621
45688
|
const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
|
|
45622
|
-
return hasRSpec && (
|
|
45689
|
+
return hasRSpec && (_internals68.isCommandAvailable("bundle") || _internals68.isCommandAvailable("rspec"));
|
|
45623
45690
|
}
|
|
45624
45691
|
function detectMinitest(cwd) {
|
|
45625
|
-
return
|
|
45692
|
+
return _internals68.existsSync(path81.join(cwd, "test")) && (_internals68.existsSync(path81.join(cwd, "Gemfile")) || _internals68.existsSync(path81.join(cwd, "Rakefile"))) && _internals68.isCommandAvailable("ruby");
|
|
45626
45693
|
}
|
|
45627
45694
|
var DISPATCH_FRAMEWORK_MAP = {
|
|
45628
45695
|
bun: "bun",
|
|
@@ -45713,8 +45780,8 @@ async function detectTestFramework(cwd) {
|
|
|
45713
45780
|
const baseDir = cwd;
|
|
45714
45781
|
try {
|
|
45715
45782
|
const packageJsonPath = path81.join(baseDir, "package.json");
|
|
45716
|
-
if (
|
|
45717
|
-
const content =
|
|
45783
|
+
if (_internals68.existsSync(packageJsonPath)) {
|
|
45784
|
+
const content = _internals68.readFileSync(packageJsonPath, "utf-8");
|
|
45718
45785
|
const pkg = JSON.parse(content);
|
|
45719
45786
|
const _deps = pkg.dependencies || {};
|
|
45720
45787
|
const devDeps = pkg.devDependencies || {};
|
|
@@ -45733,7 +45800,7 @@ async function detectTestFramework(cwd) {
|
|
|
45733
45800
|
return "jest";
|
|
45734
45801
|
if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
|
|
45735
45802
|
return "mocha";
|
|
45736
|
-
if (
|
|
45803
|
+
if (_internals68.existsSync(path81.join(baseDir, "bun.lockb")) || _internals68.existsSync(path81.join(baseDir, "bun.lock"))) {
|
|
45737
45804
|
if (scripts.test?.includes("bun"))
|
|
45738
45805
|
return "bun";
|
|
45739
45806
|
}
|
|
@@ -45743,28 +45810,28 @@ async function detectTestFramework(cwd) {
|
|
|
45743
45810
|
const pyprojectTomlPath = path81.join(baseDir, "pyproject.toml");
|
|
45744
45811
|
const setupCfgPath = path81.join(baseDir, "setup.cfg");
|
|
45745
45812
|
const requirementsTxtPath = path81.join(baseDir, "requirements.txt");
|
|
45746
|
-
if (
|
|
45747
|
-
const content =
|
|
45813
|
+
if (_internals68.existsSync(pyprojectTomlPath)) {
|
|
45814
|
+
const content = _internals68.readFileSync(pyprojectTomlPath, "utf-8");
|
|
45748
45815
|
if (content.includes("[tool.pytest"))
|
|
45749
45816
|
return "pytest";
|
|
45750
45817
|
if (content.includes("pytest"))
|
|
45751
45818
|
return "pytest";
|
|
45752
45819
|
}
|
|
45753
|
-
if (
|
|
45754
|
-
const content =
|
|
45820
|
+
if (_internals68.existsSync(setupCfgPath)) {
|
|
45821
|
+
const content = _internals68.readFileSync(setupCfgPath, "utf-8");
|
|
45755
45822
|
if (content.includes("[pytest]"))
|
|
45756
45823
|
return "pytest";
|
|
45757
45824
|
}
|
|
45758
|
-
if (
|
|
45759
|
-
const content =
|
|
45825
|
+
if (_internals68.existsSync(requirementsTxtPath)) {
|
|
45826
|
+
const content = _internals68.readFileSync(requirementsTxtPath, "utf-8");
|
|
45760
45827
|
if (content.includes("pytest"))
|
|
45761
45828
|
return "pytest";
|
|
45762
45829
|
}
|
|
45763
45830
|
} catch {}
|
|
45764
45831
|
try {
|
|
45765
45832
|
const cargoTomlPath = path81.join(baseDir, "Cargo.toml");
|
|
45766
|
-
if (
|
|
45767
|
-
const content =
|
|
45833
|
+
if (_internals68.existsSync(cargoTomlPath)) {
|
|
45834
|
+
const content = _internals68.readFileSync(cargoTomlPath, "utf-8");
|
|
45768
45835
|
if (content.includes("[dev-dependencies]")) {
|
|
45769
45836
|
if (content.includes("tokio") || content.includes("mockall") || content.includes("pretty_assertions")) {
|
|
45770
45837
|
return "cargo";
|
|
@@ -45776,7 +45843,7 @@ async function detectTestFramework(cwd) {
|
|
|
45776
45843
|
const pesterConfigPath = path81.join(baseDir, "pester.config.ps1");
|
|
45777
45844
|
const pesterConfigJsonPath = path81.join(baseDir, "pester.config.ps1.json");
|
|
45778
45845
|
const pesterPs1Path = path81.join(baseDir, "tests.ps1");
|
|
45779
|
-
if (
|
|
45846
|
+
if (_internals68.existsSync(pesterConfigPath) || _internals68.existsSync(pesterConfigJsonPath) || _internals68.existsSync(pesterPs1Path)) {
|
|
45780
45847
|
return "pester";
|
|
45781
45848
|
}
|
|
45782
45849
|
} catch {}
|
|
@@ -45804,12 +45871,12 @@ async function detectTestFramework(cwd) {
|
|
|
45804
45871
|
return "none";
|
|
45805
45872
|
}
|
|
45806
45873
|
function detectPhpTest(cwd) {
|
|
45807
|
-
if (
|
|
45874
|
+
if (_internals68.existsSync(path81.join(cwd, "artisan")) && _internals68.existsSync(path81.join(cwd, "composer.json"))) {
|
|
45808
45875
|
return "php-artisan";
|
|
45809
45876
|
}
|
|
45810
|
-
if (
|
|
45877
|
+
if (_internals68.existsSync(path81.join(cwd, "Pest.php")))
|
|
45811
45878
|
return "pest";
|
|
45812
|
-
if (
|
|
45879
|
+
if (_internals68.existsSync(path81.join(cwd, "phpunit.xml")) || _internals68.existsSync(path81.join(cwd, "phpunit.xml.dist"))) {
|
|
45813
45880
|
return "phpunit";
|
|
45814
45881
|
}
|
|
45815
45882
|
return null;
|
|
@@ -46191,9 +46258,9 @@ function buildTestCommand(framework, scope, files, coverage, baseDir, bail) {
|
|
|
46191
46258
|
case "swift-test":
|
|
46192
46259
|
return ["swift", "test"];
|
|
46193
46260
|
case "dart-test":
|
|
46194
|
-
return
|
|
46261
|
+
return _internals68.isCommandAvailable("flutter") ? ["flutter", "test", ...files] : ["dart", "test", ...files];
|
|
46195
46262
|
case "rspec": {
|
|
46196
|
-
const args =
|
|
46263
|
+
const args = _internals68.isCommandAvailable("bundle") ? ["bundle", "exec", "rspec"] : ["rspec"];
|
|
46197
46264
|
if (bail)
|
|
46198
46265
|
args.push("--fail-fast");
|
|
46199
46266
|
if (scope !== "all" && files.length > 0) {
|
|
@@ -47206,7 +47273,7 @@ var test_runner = createSwarmTool({
|
|
|
47206
47273
|
return JSON.stringify(errorResult, null, 2);
|
|
47207
47274
|
}
|
|
47208
47275
|
try {
|
|
47209
|
-
const impactResult = await
|
|
47276
|
+
const impactResult = await _internals68.analyzeImpact(sourceFiles, workingDir, MAX_SAFE_TEST_FILES);
|
|
47210
47277
|
if (impactResult.budgetExceeded) {
|
|
47211
47278
|
const errorResult = {
|
|
47212
47279
|
success: false,
|
|
@@ -47296,7 +47363,7 @@ var test_runner = createSwarmTool({
|
|
|
47296
47363
|
return JSON.stringify(result, null, 2);
|
|
47297
47364
|
}
|
|
47298
47365
|
});
|
|
47299
|
-
var
|
|
47366
|
+
var _internals68 = {
|
|
47300
47367
|
analyzeImpact,
|
|
47301
47368
|
loadImpactMap,
|
|
47302
47369
|
isCommandAvailable,
|
|
@@ -47398,9 +47465,9 @@ function getVersionFileVersion(dir) {
|
|
|
47398
47465
|
async function runVersionCheck(dir, _timeoutMs) {
|
|
47399
47466
|
const startTime = Date.now();
|
|
47400
47467
|
try {
|
|
47401
|
-
const packageVersion =
|
|
47402
|
-
const changelogVersion =
|
|
47403
|
-
const versionFileVersion =
|
|
47468
|
+
const packageVersion = _internals69.getPackageVersion(dir);
|
|
47469
|
+
const changelogVersion = _internals69.getChangelogVersion(dir);
|
|
47470
|
+
const versionFileVersion = _internals69.getVersionFileVersion(dir);
|
|
47404
47471
|
const versions = [];
|
|
47405
47472
|
if (packageVersion)
|
|
47406
47473
|
versions.push(`package.json: ${packageVersion}`);
|
|
@@ -47589,7 +47656,7 @@ async function runTestsCheck(_dir, scope, timeoutMs) {
|
|
|
47589
47656
|
async function runSecretsCheck(dir, timeoutMs) {
|
|
47590
47657
|
const startTime = Date.now();
|
|
47591
47658
|
try {
|
|
47592
|
-
const secretsPromise =
|
|
47659
|
+
const secretsPromise = _internals69.runSecretscan(dir);
|
|
47593
47660
|
const timeoutPromise = new Promise((_, reject) => {
|
|
47594
47661
|
setTimeout(() => {
|
|
47595
47662
|
reject(new Error(`Secrets check timed out after ${timeoutMs}ms`));
|
|
@@ -47811,7 +47878,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47811
47878
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
47812
47879
|
let validatedDir;
|
|
47813
47880
|
try {
|
|
47814
|
-
validatedDir =
|
|
47881
|
+
validatedDir = _internals69.validateDirectoryPath(dir);
|
|
47815
47882
|
} catch (error2) {
|
|
47816
47883
|
return {
|
|
47817
47884
|
id: reportId,
|
|
@@ -47831,7 +47898,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47831
47898
|
}
|
|
47832
47899
|
let validatedTimeout;
|
|
47833
47900
|
try {
|
|
47834
|
-
validatedTimeout =
|
|
47901
|
+
validatedTimeout = _internals69.validateTimeout(config?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
47835
47902
|
} catch (error2) {
|
|
47836
47903
|
return {
|
|
47837
47904
|
id: reportId,
|
|
@@ -47872,12 +47939,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
47872
47939
|
});
|
|
47873
47940
|
const checks = [];
|
|
47874
47941
|
log("[Preflight] Running lint check...");
|
|
47875
|
-
const lintResult = await
|
|
47942
|
+
const lintResult = await _internals69.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
47876
47943
|
checks.push(lintResult);
|
|
47877
47944
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
47878
47945
|
if (!cfg.skipTests) {
|
|
47879
47946
|
log("[Preflight] Running tests check...");
|
|
47880
|
-
const testsResult = await
|
|
47947
|
+
const testsResult = await _internals69.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
47881
47948
|
checks.push(testsResult);
|
|
47882
47949
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
47883
47950
|
} else {
|
|
@@ -47889,7 +47956,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47889
47956
|
}
|
|
47890
47957
|
if (!cfg.skipSecrets) {
|
|
47891
47958
|
log("[Preflight] Running secrets check...");
|
|
47892
|
-
const secretsResult = await
|
|
47959
|
+
const secretsResult = await _internals69.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
47893
47960
|
checks.push(secretsResult);
|
|
47894
47961
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
47895
47962
|
} else {
|
|
@@ -47901,7 +47968,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47901
47968
|
}
|
|
47902
47969
|
if (!cfg.skipEvidence) {
|
|
47903
47970
|
log("[Preflight] Running evidence check...");
|
|
47904
|
-
const evidenceResult = await
|
|
47971
|
+
const evidenceResult = await _internals69.runEvidenceCheck(validatedDir);
|
|
47905
47972
|
checks.push(evidenceResult);
|
|
47906
47973
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
47907
47974
|
} else {
|
|
@@ -47912,12 +47979,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
47912
47979
|
});
|
|
47913
47980
|
}
|
|
47914
47981
|
log("[Preflight] Running requirement coverage check...");
|
|
47915
|
-
const reqCoverageResult = await
|
|
47982
|
+
const reqCoverageResult = await _internals69.runRequirementCoverageCheck(validatedDir, phase);
|
|
47916
47983
|
checks.push(reqCoverageResult);
|
|
47917
47984
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
47918
47985
|
if (!cfg.skipVersion) {
|
|
47919
47986
|
log("[Preflight] Running version check...");
|
|
47920
|
-
const versionResult = await
|
|
47987
|
+
const versionResult = await _internals69.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
47921
47988
|
checks.push(versionResult);
|
|
47922
47989
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
47923
47990
|
} else {
|
|
@@ -47980,10 +48047,10 @@ function formatPreflightMarkdown(report) {
|
|
|
47980
48047
|
async function handlePreflightCommand(directory, _args) {
|
|
47981
48048
|
const plan = await loadPlan(directory);
|
|
47982
48049
|
const phase = plan?.current_phase ?? 1;
|
|
47983
|
-
const report = await
|
|
47984
|
-
return
|
|
48050
|
+
const report = await _internals69.runPreflight(directory, phase);
|
|
48051
|
+
return _internals69.formatPreflightMarkdown(report);
|
|
47985
48052
|
}
|
|
47986
|
-
var
|
|
48053
|
+
var _internals69 = {
|
|
47987
48054
|
runPreflight,
|
|
47988
48055
|
formatPreflightMarkdown,
|
|
47989
48056
|
handlePreflightCommand,
|
|
@@ -48977,7 +49044,7 @@ function pruneOldResetBackups(backupsRoot, warnings) {
|
|
|
48977
49044
|
}
|
|
48978
49045
|
|
|
48979
49046
|
// src/commands/reset.ts
|
|
48980
|
-
var
|
|
49047
|
+
var _internals70 = {
|
|
48981
49048
|
backupSwarmStateBeforeReset
|
|
48982
49049
|
};
|
|
48983
49050
|
async function handleResetCommand(directory, args) {
|
|
@@ -49012,7 +49079,7 @@ async function handleResetCommand(directory, args) {
|
|
|
49012
49079
|
];
|
|
49013
49080
|
const results = [];
|
|
49014
49081
|
try {
|
|
49015
|
-
const backup =
|
|
49082
|
+
const backup = _internals70.backupSwarmStateBeforeReset(directory, "reset", [
|
|
49016
49083
|
...filesToReset,
|
|
49017
49084
|
"summaries"
|
|
49018
49085
|
]);
|
|
@@ -49564,7 +49631,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
|
|
|
49564
49631
|
}
|
|
49565
49632
|
|
|
49566
49633
|
// src/prm/index.ts
|
|
49567
|
-
var
|
|
49634
|
+
var _internals71 = {
|
|
49568
49635
|
getAgentSession,
|
|
49569
49636
|
readTrajectory,
|
|
49570
49637
|
getInMemoryTrajectory,
|
|
@@ -49592,12 +49659,12 @@ function resetPrmSessionState(session, sessionId) {
|
|
|
49592
49659
|
session.prmInjectedAdvisoryKeys = new Set;
|
|
49593
49660
|
session.replayArtifactPath = null;
|
|
49594
49661
|
if (sessionId) {
|
|
49595
|
-
|
|
49662
|
+
_internals71.clearTrajectoryCache(sessionId);
|
|
49596
49663
|
}
|
|
49597
49664
|
}
|
|
49598
49665
|
|
|
49599
49666
|
// src/commands/reset-session.ts
|
|
49600
|
-
var
|
|
49667
|
+
var _internals72 = {
|
|
49601
49668
|
cleanupOrphanedBranches,
|
|
49602
49669
|
backupSwarmStateBeforeReset
|
|
49603
49670
|
};
|
|
@@ -49609,7 +49676,7 @@ function errorMessage(err) {
|
|
|
49609
49676
|
async function handleResetSessionCommand(directory, _args) {
|
|
49610
49677
|
const results = [];
|
|
49611
49678
|
try {
|
|
49612
|
-
const backup =
|
|
49679
|
+
const backup = _internals72.backupSwarmStateBeforeReset(directory, "reset-session", ["session"]);
|
|
49613
49680
|
if (backup.backupDir && backup.copied.length > 0) {
|
|
49614
49681
|
const rel = path86.relative(directory, backup.backupDir);
|
|
49615
49682
|
results.push(`\uD83D\uDCE6 Backed up session state to ${rel}/ (restore by copying files back into .swarm/session/)`);
|
|
@@ -49676,7 +49743,7 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
49676
49743
|
results.push(`\u26A0\uFE0F Failed to remove .swarm-worktrees/: ${errorMessage(err)}`);
|
|
49677
49744
|
}
|
|
49678
49745
|
try {
|
|
49679
|
-
const branchResult = await
|
|
49746
|
+
const branchResult = await _internals72.cleanupOrphanedBranches(directory, []);
|
|
49680
49747
|
if (branchResult.removed.length > 0) {
|
|
49681
49748
|
results.push(`\u2705 Removed ${branchResult.removed.length} orphan swarm-lane branch(es)`);
|
|
49682
49749
|
}
|
|
@@ -49835,7 +49902,7 @@ function resolveReceiptsDir(directory) {
|
|
|
49835
49902
|
function resolveReceiptIndexPath(directory) {
|
|
49836
49903
|
return path88.join(resolveReceiptsDir(directory), "index.json");
|
|
49837
49904
|
}
|
|
49838
|
-
var
|
|
49905
|
+
var _internals73 = {
|
|
49839
49906
|
openSync: fs41.openSync,
|
|
49840
49907
|
lstatBigIntSync: (path89) => fs41.lstatSync(path89, { bigint: true }),
|
|
49841
49908
|
fstatBigIntSync: (fd) => fs41.fstatSync(fd, { bigint: true })
|
|
@@ -49847,7 +49914,7 @@ function pathsEqual(left, right) {
|
|
|
49847
49914
|
}
|
|
49848
49915
|
function captureCanonicalDirectory(directory, label, expected) {
|
|
49849
49916
|
const resolved = path88.resolve(directory);
|
|
49850
|
-
const stat6 =
|
|
49917
|
+
const stat6 = _internals73.lstatBigIntSync(resolved);
|
|
49851
49918
|
if (!stat6.isDirectory() || stat6.isSymbolicLink()) {
|
|
49852
49919
|
throw new Error(`${label} must be a real directory`);
|
|
49853
49920
|
}
|
|
@@ -49933,7 +50000,7 @@ function assertDirectReceiptFile(context, filePath, mustExist) {
|
|
|
49933
50000
|
throw new Error("review receipt file escapes its expected directory");
|
|
49934
50001
|
}
|
|
49935
50002
|
try {
|
|
49936
|
-
const stat6 =
|
|
50003
|
+
const stat6 = _internals73.lstatBigIntSync(resolved);
|
|
49937
50004
|
if (!stat6.isFile() || stat6.isSymbolicLink()) {
|
|
49938
50005
|
throw new Error("review receipt path must be a real file");
|
|
49939
50006
|
}
|
|
@@ -49957,7 +50024,7 @@ function readReviewReceiptText(directory, receiptPath, maxBytes = 1048576) {
|
|
|
49957
50024
|
const resolved = assertDirectReceiptFile(context, receiptPath, true);
|
|
49958
50025
|
if (path88.extname(resolved) !== ".json")
|
|
49959
50026
|
return null;
|
|
49960
|
-
const pathBeforeOpen =
|
|
50027
|
+
const pathBeforeOpen = _internals73.lstatBigIntSync(resolved);
|
|
49961
50028
|
if (!pathBeforeOpen.isFile() || pathBeforeOpen.isSymbolicLink() || pathBeforeOpen.size < 0n || pathBeforeOpen.size > BigInt(maxBytes)) {
|
|
49962
50029
|
return null;
|
|
49963
50030
|
}
|
|
@@ -49965,10 +50032,10 @@ function readReviewReceiptText(directory, receiptPath, maxBytes = 1048576) {
|
|
|
49965
50032
|
if (!pathsEqual(canonicalBeforeOpen, resolved))
|
|
49966
50033
|
return null;
|
|
49967
50034
|
assertReceiptContextCurrent(context);
|
|
49968
|
-
descriptor =
|
|
49969
|
-
const openedBeforeRead =
|
|
50035
|
+
descriptor = _internals73.openSync(canonicalBeforeOpen, "r");
|
|
50036
|
+
const openedBeforeRead = _internals73.fstatBigIntSync(descriptor);
|
|
49970
50037
|
assertReceiptContextCurrent(context);
|
|
49971
|
-
const pathAfterOpen =
|
|
50038
|
+
const pathAfterOpen = _internals73.lstatBigIntSync(resolved);
|
|
49972
50039
|
const canonicalAfterOpen = fs41.realpathSync(resolved);
|
|
49973
50040
|
if (!openedBeforeRead.isFile() || openedBeforeRead.size < 0n || openedBeforeRead.size > BigInt(maxBytes) || !sameFileSnapshot2(pathBeforeOpen, openedBeforeRead) || !sameFileSnapshot2(openedBeforeRead, pathAfterOpen) || !pathsEqual(canonicalBeforeOpen, canonicalAfterOpen)) {
|
|
49974
50041
|
return null;
|
|
@@ -49981,9 +50048,9 @@ function readReviewReceiptText(directory, receiptPath, maxBytes = 1048576) {
|
|
|
49981
50048
|
break;
|
|
49982
50049
|
bytesRead += count;
|
|
49983
50050
|
}
|
|
49984
|
-
const openedAfterRead =
|
|
50051
|
+
const openedAfterRead = _internals73.fstatBigIntSync(descriptor);
|
|
49985
50052
|
assertReceiptContextCurrent(context);
|
|
49986
|
-
const pathAfterRead =
|
|
50053
|
+
const pathAfterRead = _internals73.lstatBigIntSync(resolved);
|
|
49987
50054
|
const canonicalAfterRead = fs41.realpathSync(resolved);
|
|
49988
50055
|
if (bytesRead !== buffer.length || !sameFileSnapshot2(openedBeforeRead, openedAfterRead) || !sameFileSnapshot2(openedAfterRead, pathAfterRead) || !pathsEqual(canonicalBeforeOpen, canonicalAfterRead)) {
|
|
49989
50056
|
return null;
|
|
@@ -50527,7 +50594,7 @@ var HEAD_TIMEOUT_MS = 5000;
|
|
|
50527
50594
|
var HEAD_OUTPUT_BYTES = 256;
|
|
50528
50595
|
var HEAD_SHA_PATTERN = /^[0-9a-f]{40,64}$/i;
|
|
50529
50596
|
var REVIEWER_TASK_SCOPE_DESCRIPTION = "reviewer-task-files-v1";
|
|
50530
|
-
var
|
|
50597
|
+
var _internals74 = {
|
|
50531
50598
|
spawn: child_process7.spawn,
|
|
50532
50599
|
realpath: fs42.promises.realpath,
|
|
50533
50600
|
lstatBigInt: (path90) => fs42.promises.lstat(path90, { bigint: true }),
|
|
@@ -50567,7 +50634,7 @@ async function missingPathParentIsContained(root, absolutePath2) {
|
|
|
50567
50634
|
let current = path89.dirname(absolutePath2);
|
|
50568
50635
|
for (;; ) {
|
|
50569
50636
|
try {
|
|
50570
|
-
const canonical = await
|
|
50637
|
+
const canonical = await _internals74.realpath(current);
|
|
50571
50638
|
return samePath2(root, canonical) || isContained2(root, canonical);
|
|
50572
50639
|
} catch (error2) {
|
|
50573
50640
|
if (error2.code !== "ENOENT")
|
|
@@ -50594,7 +50661,7 @@ async function resolveHeadSha(directory) {
|
|
|
50594
50661
|
let child;
|
|
50595
50662
|
let timeoutHandle;
|
|
50596
50663
|
try {
|
|
50597
|
-
child =
|
|
50664
|
+
child = _internals74.spawn("git", ["rev-parse", "--verify", "HEAD"], {
|
|
50598
50665
|
cwd: directory,
|
|
50599
50666
|
stdio: ["ignore", "pipe", "ignore"],
|
|
50600
50667
|
timeout: HEAD_TIMEOUT_MS,
|
|
@@ -50657,7 +50724,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50657
50724
|
let realRoot;
|
|
50658
50725
|
try {
|
|
50659
50726
|
lexicalRoot = path89.resolve(directory);
|
|
50660
|
-
realRoot = await
|
|
50727
|
+
realRoot = await _internals74.realpath(lexicalRoot);
|
|
50661
50728
|
} catch {
|
|
50662
50729
|
return null;
|
|
50663
50730
|
}
|
|
@@ -50698,7 +50765,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50698
50765
|
for (const candidate of ordered) {
|
|
50699
50766
|
let before;
|
|
50700
50767
|
try {
|
|
50701
|
-
before = await
|
|
50768
|
+
before = await _internals74.lstatBigInt(candidate.absolutePath);
|
|
50702
50769
|
} catch (error2) {
|
|
50703
50770
|
if (error2.code === "ENOENT") {
|
|
50704
50771
|
if (!await missingPathParentIsContained(realRoot, candidate.absolutePath)) {
|
|
@@ -50717,7 +50784,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50717
50784
|
return null;
|
|
50718
50785
|
let realCandidate;
|
|
50719
50786
|
try {
|
|
50720
|
-
realCandidate = await
|
|
50787
|
+
realCandidate = await _internals74.realpath(candidate.absolutePath);
|
|
50721
50788
|
} catch {
|
|
50722
50789
|
return null;
|
|
50723
50790
|
}
|
|
@@ -50729,15 +50796,15 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50729
50796
|
let bytes;
|
|
50730
50797
|
let openedBefore;
|
|
50731
50798
|
try {
|
|
50732
|
-
handle = await
|
|
50733
|
-
openedBefore = await
|
|
50734
|
-
const canonicalAfterOpen = await
|
|
50799
|
+
handle = await _internals74.open(realCandidate, "r");
|
|
50800
|
+
openedBefore = await _internals74.fileHandleStatBigInt(handle);
|
|
50801
|
+
const canonicalAfterOpen = await _internals74.realpath(candidate.absolutePath);
|
|
50735
50802
|
if (!openedBefore.isFile() || !sameFileSnapshot3(before, openedBefore) || !samePath2(realCandidate, canonicalAfterOpen) || !isContained2(realRoot, canonicalAfterOpen)) {
|
|
50736
50803
|
return null;
|
|
50737
50804
|
}
|
|
50738
50805
|
bytes = await readBoundedHandle(handle, maxBytes - totalBytes);
|
|
50739
|
-
const openedAfter = await
|
|
50740
|
-
const canonicalAfterRead = await
|
|
50806
|
+
const openedAfter = await _internals74.fileHandleStatBigInt(handle);
|
|
50807
|
+
const canonicalAfterRead = await _internals74.realpath(candidate.absolutePath);
|
|
50741
50808
|
if (!sameFileSnapshot3(openedBefore, openedAfter) || !samePath2(realCandidate, canonicalAfterRead) || !isContained2(realRoot, canonicalAfterRead) || BigInt(bytes.byteLength) !== openedBefore.size) {
|
|
50742
50809
|
return null;
|
|
50743
50810
|
}
|
|
@@ -50761,8 +50828,8 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50761
50828
|
}
|
|
50762
50829
|
for (const stable of stableFiles) {
|
|
50763
50830
|
try {
|
|
50764
|
-
const current = await
|
|
50765
|
-
const canonical = await
|
|
50831
|
+
const current = await _internals74.lstatBigInt(stable.absolutePath);
|
|
50832
|
+
const canonical = await _internals74.realpath(stable.absolutePath);
|
|
50766
50833
|
if (!current.isFile() || current.isSymbolicLink() || !sameFileSnapshot3(stable.stat, current) || !samePath2(stable.canonicalPath, canonical) || !isContained2(realRoot, canonical)) {
|
|
50767
50834
|
return null;
|
|
50768
50835
|
}
|
|
@@ -50772,7 +50839,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50772
50839
|
}
|
|
50773
50840
|
for (const deletedPath of deletedPaths) {
|
|
50774
50841
|
try {
|
|
50775
|
-
await
|
|
50842
|
+
await _internals74.lstatBigInt(deletedPath);
|
|
50776
50843
|
return null;
|
|
50777
50844
|
} catch (error2) {
|
|
50778
50845
|
if (error2.code !== "ENOENT" || !await missingPathParentIsContained(realRoot, deletedPath)) {
|
|
@@ -50935,7 +51002,7 @@ function parseReviewerOutput(text, options = {}) {
|
|
|
50935
51002
|
outputMode: "legacy"
|
|
50936
51003
|
};
|
|
50937
51004
|
}
|
|
50938
|
-
var
|
|
51005
|
+
var _internals75 = {
|
|
50939
51006
|
delegationEnd: telemetry.delegationEnd,
|
|
50940
51007
|
resolveReviewerTaskScope,
|
|
50941
51008
|
buildReviewerTaskScope,
|
|
@@ -50974,6 +51041,7 @@ async function persistAutoReviewEvidence(directory, evidence2, options = {}) {
|
|
|
50974
51041
|
throw new Error("auto-review evidence temp path changed before commit");
|
|
50975
51042
|
}
|
|
50976
51043
|
fs43.renameSync(revalidatedTemp, safeTarget);
|
|
51044
|
+
invalidateCachedArtifact(safeTarget);
|
|
50977
51045
|
return safeTarget;
|
|
50978
51046
|
} finally {
|
|
50979
51047
|
try {
|
|
@@ -51140,7 +51208,7 @@ function scopeFreshnessMismatches(reviewed, current) {
|
|
|
51140
51208
|
}
|
|
51141
51209
|
function createScopeVerifier(input, reviewed, maxBytes) {
|
|
51142
51210
|
return async () => {
|
|
51143
|
-
const current = await
|
|
51211
|
+
const current = await _internals76.collectReviewDiff({
|
|
51144
51212
|
directory: input.directory,
|
|
51145
51213
|
selector: input.selector,
|
|
51146
51214
|
maxBytes
|
|
@@ -51149,7 +51217,7 @@ function createScopeVerifier(input, reviewed, maxBytes) {
|
|
|
51149
51217
|
};
|
|
51150
51218
|
}
|
|
51151
51219
|
async function stalePersistenceResult(input, maxBytes, message, modelCalls) {
|
|
51152
|
-
const current = await
|
|
51220
|
+
const current = await _internals76.collectReviewDiff({
|
|
51153
51221
|
directory: input.directory,
|
|
51154
51222
|
selector: input.selector,
|
|
51155
51223
|
maxBytes
|
|
@@ -51528,7 +51596,7 @@ async function persistErrorResult(input, diff, result, error2, dispatches, promp
|
|
|
51528
51596
|
evidence2.review.error = error2;
|
|
51529
51597
|
addCost(evidence2, dispatches);
|
|
51530
51598
|
try {
|
|
51531
|
-
result.evidencePath = await
|
|
51599
|
+
result.evidencePath = await _internals76.persistEvidence(input.directory, evidence2);
|
|
51532
51600
|
} catch {
|
|
51533
51601
|
if (input.config.final_review.mode === "gate") {
|
|
51534
51602
|
result.blocked = true;
|
|
@@ -51544,7 +51612,7 @@ async function runReviewEngine(input) {
|
|
|
51544
51612
|
const gateMode = input.config.final_review.mode === "gate";
|
|
51545
51613
|
const maxBytes = input.trigger === "task_completion" ? input.config.max_diff_kb * 1024 : input.config.final_review.max_diff_bytes;
|
|
51546
51614
|
const timeoutMs = input.trigger === "task_completion" ? input.config.timeout_ms : input.config.final_review.timeout_ms;
|
|
51547
|
-
const diff = await
|
|
51615
|
+
const diff = await _internals76.collectReviewDiff({
|
|
51548
51616
|
directory: input.directory,
|
|
51549
51617
|
selector: input.selector,
|
|
51550
51618
|
maxBytes
|
|
@@ -51558,7 +51626,7 @@ async function runReviewEngine(input) {
|
|
|
51558
51626
|
const evidence3 = baseEvidence(input, diff, "clean");
|
|
51559
51627
|
let evidencePath2;
|
|
51560
51628
|
try {
|
|
51561
|
-
evidencePath2 = await
|
|
51629
|
+
evidencePath2 = await _internals76.persistEvidence(input.directory, evidence3, { verifyCurrent: createScopeVerifier(input, diff, maxBytes) });
|
|
51562
51630
|
} catch (error2) {
|
|
51563
51631
|
if (error2 instanceof ReviewScopeStaleError) {
|
|
51564
51632
|
return stalePersistenceResult(input, maxBytes, "Review scope changed before clean evidence could be committed.", 0);
|
|
@@ -51580,7 +51648,7 @@ async function runReviewEngine(input) {
|
|
|
51580
51648
|
phase: input.phase
|
|
51581
51649
|
});
|
|
51582
51650
|
if (input.phase !== undefined && (input.trigger === "phase_completion" || input.trigger === "plan_completion")) {
|
|
51583
|
-
const existing =
|
|
51651
|
+
const existing = _internals76.readPhaseEvidence(input.directory, input.phase);
|
|
51584
51652
|
const integrity = existing ? validateAutoReviewEvidenceIntegrity(input.directory, existing, {
|
|
51585
51653
|
scopeHash: diff.scopeHash,
|
|
51586
51654
|
phase: input.phase,
|
|
@@ -51706,7 +51774,7 @@ async function runReviewEngine(input) {
|
|
|
51706
51774
|
validation: byId.get(finding.finding_id)
|
|
51707
51775
|
}));
|
|
51708
51776
|
}
|
|
51709
|
-
const currentScope = await
|
|
51777
|
+
const currentScope = await _internals76.collectReviewDiff({
|
|
51710
51778
|
directory: input.directory,
|
|
51711
51779
|
selector: input.selector,
|
|
51712
51780
|
maxBytes
|
|
@@ -51785,7 +51853,7 @@ async function runReviewEngine(input) {
|
|
|
51785
51853
|
findingValidations: findings.map((finding) => finding.validation).filter((item) => Boolean(item))
|
|
51786
51854
|
});
|
|
51787
51855
|
receiptId = receipt.id;
|
|
51788
|
-
receiptPath = await
|
|
51856
|
+
receiptPath = await _internals76.persistReceipt(input.directory, receipt, {
|
|
51789
51857
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
51790
51858
|
});
|
|
51791
51859
|
evidence2.receipt_path = receiptPath;
|
|
@@ -51815,7 +51883,7 @@ async function runReviewEngine(input) {
|
|
|
51815
51883
|
}
|
|
51816
51884
|
let evidencePath;
|
|
51817
51885
|
try {
|
|
51818
|
-
evidencePath = await
|
|
51886
|
+
evidencePath = await _internals76.persistEvidence(input.directory, evidence2, {
|
|
51819
51887
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
51820
51888
|
});
|
|
51821
51889
|
} catch (error2) {
|
|
@@ -51852,7 +51920,7 @@ async function runReviewEngine(input) {
|
|
|
51852
51920
|
input.injectAdvisory?.(input.sessionID, advisoryMessage(input, result));
|
|
51853
51921
|
return result;
|
|
51854
51922
|
}
|
|
51855
|
-
var
|
|
51923
|
+
var _internals76 = {
|
|
51856
51924
|
collectReviewDiff,
|
|
51857
51925
|
persistEvidence: persistAutoReviewEvidence,
|
|
51858
51926
|
persistReceipt: persistReviewReceipt,
|
|
@@ -52123,7 +52191,7 @@ async function handleReviewCommand(ctx) {
|
|
|
52123
52191
|
} catch (error2) {
|
|
52124
52192
|
return `Review configuration error: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
52125
52193
|
}
|
|
52126
|
-
const result = await
|
|
52194
|
+
const result = await _internals77.runReviewEngine({
|
|
52127
52195
|
directory: ctx.directory,
|
|
52128
52196
|
sessionID: ctx.sessionID,
|
|
52129
52197
|
trigger: "manual",
|
|
@@ -52137,10 +52205,10 @@ async function handleReviewCommand(ctx) {
|
|
|
52137
52205
|
validatorModel,
|
|
52138
52206
|
validatorFallbackModels
|
|
52139
52207
|
});
|
|
52140
|
-
const evidence2 =
|
|
52208
|
+
const evidence2 = _internals77.readEvidence(result.evidencePath, ctx.directory);
|
|
52141
52209
|
return parsed.json ? renderJson(result, evidence2, parsed.selector) : renderHuman(result, evidence2, parsed.selector);
|
|
52142
52210
|
}
|
|
52143
|
-
var
|
|
52211
|
+
var _internals77 = {
|
|
52144
52212
|
runReviewEngine,
|
|
52145
52213
|
readEvidence
|
|
52146
52214
|
};
|
|
@@ -52291,7 +52359,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
52291
52359
|
if (checkpointFiles.length === 0) {
|
|
52292
52360
|
return `Error: Checkpoint for phase ${targetPhase} is empty. Cannot rollback.`;
|
|
52293
52361
|
}
|
|
52294
|
-
const swarmDir = validateSwarmPath(directory, "");
|
|
52362
|
+
const swarmDir = path93.dirname(validateSwarmPath(directory, ".keep"));
|
|
52295
52363
|
const EXCLUDE_FILES = new Set([
|
|
52296
52364
|
"plan-ledger.jsonl",
|
|
52297
52365
|
"plan-ledger.quarantine"
|
|
@@ -52312,6 +52380,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
52312
52380
|
failures.push({ file, error: error2.message });
|
|
52313
52381
|
}
|
|
52314
52382
|
}
|
|
52383
|
+
resetSwarmArtifactCache();
|
|
52315
52384
|
if (failures.length > 0) {
|
|
52316
52385
|
return [
|
|
52317
52386
|
`Rollback partially completed. Successfully restored ${successes.length} files.`,
|
|
@@ -52385,7 +52454,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
52385
52454
|
// src/commands/sdd.ts
|
|
52386
52455
|
import * as fs47 from "fs";
|
|
52387
52456
|
import * as path94 from "path";
|
|
52388
|
-
var
|
|
52457
|
+
var _internals78 = {
|
|
52389
52458
|
writeProjectedSpecSync
|
|
52390
52459
|
};
|
|
52391
52460
|
var SWARM_SPEC_REL = path94.join(".swarm", "spec.md");
|
|
@@ -52781,7 +52850,7 @@ ${USAGE12}`;
|
|
|
52781
52850
|
|
|
52782
52851
|
${USAGE12}`;
|
|
52783
52852
|
}
|
|
52784
|
-
const result2 =
|
|
52853
|
+
const result2 = _internals78.writeProjectedSpecSync(directory, {
|
|
52785
52854
|
source: "speckit",
|
|
52786
52855
|
feature: resolution.feature,
|
|
52787
52856
|
dryRun: parsed.dryRun,
|
|
@@ -52839,7 +52908,7 @@ ${formatList(result2.projection.warnings)}` : ""
|
|
|
52839
52908
|
].join(`
|
|
52840
52909
|
`);
|
|
52841
52910
|
}
|
|
52842
|
-
const result =
|
|
52911
|
+
const result = _internals78.writeProjectedSpecSync(directory, {
|
|
52843
52912
|
changeId: parsed.changeId,
|
|
52844
52913
|
dryRun: parsed.dryRun,
|
|
52845
52914
|
overwrite: parsed.overwrite
|
|
@@ -52920,7 +52989,7 @@ async function handleSimulateCommand(directory, args) {
|
|
|
52920
52989
|
}
|
|
52921
52990
|
let darkMatterPairs;
|
|
52922
52991
|
try {
|
|
52923
|
-
darkMatterPairs = await
|
|
52992
|
+
darkMatterPairs = await _internals39.detectDarkMatter(directory, options);
|
|
52924
52993
|
} catch (err) {
|
|
52925
52994
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
52926
52995
|
return `## Simulate Report
|
|
@@ -53078,7 +53147,7 @@ function writeFileFsyncedThenRename(tempPath, targetPath, data) {
|
|
|
53078
53147
|
throw err;
|
|
53079
53148
|
}
|
|
53080
53149
|
}
|
|
53081
|
-
var
|
|
53150
|
+
var _internals79 = {
|
|
53082
53151
|
withEvidenceLock,
|
|
53083
53152
|
writeFileFsyncedThenRename,
|
|
53084
53153
|
writeFileSync: writeFileSyncAsync,
|
|
@@ -53097,7 +53166,7 @@ async function appendEvent(directory, eventInput) {
|
|
|
53097
53166
|
}
|
|
53098
53167
|
const filePath = ledgerPath(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
53099
53168
|
ensureCandidateDir(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
53100
|
-
return
|
|
53169
|
+
return _internals79.withEvidenceLock(directory, path95.join(".swarm", "evolution", "skills", eventInput.skillSlug, eventInput.candidateId, "lifecycle.jsonl"), "skill-opt-ledger", "append-skill-opt-event", async () => {
|
|
53101
53170
|
const existing = existsSync53(filePath) ? readFileSync39(filePath, "utf8") : "";
|
|
53102
53171
|
const events = parseEventsFromText(existing);
|
|
53103
53172
|
const nextSeq = events.length === 0 ? 1 : events[events.length - 1].seq + 1;
|
|
@@ -53128,8 +53197,8 @@ async function appendEvent(directory, eventInput) {
|
|
|
53128
53197
|
const validContent = events.map((e) => JSON.stringify(e)).join(`
|
|
53129
53198
|
`) + (events.length > 0 ? `
|
|
53130
53199
|
` : "");
|
|
53131
|
-
|
|
53132
|
-
const verify = parseEventsFromText(
|
|
53200
|
+
_internals79.writeFileFsyncedThenRename(tempPath, filePath, validContent + line);
|
|
53201
|
+
const verify = parseEventsFromText(_internals79.readFileSync(filePath, "utf8"));
|
|
53133
53202
|
const last = verify.length > 0 ? verify[verify.length - 1] : null;
|
|
53134
53203
|
if (!last || last.seq !== event.seq || last.hashAfter !== event.hashAfter) {
|
|
53135
53204
|
throw new Error(`skill-opt ledger append verification failed for candidate ${event.candidateId} seq ${event.seq}`);
|
|
@@ -53231,14 +53300,14 @@ function writeStateProjection(directory, skillSlug, candidateId2, replay) {
|
|
|
53231
53300
|
updatedAt: new Date().toISOString()
|
|
53232
53301
|
};
|
|
53233
53302
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
53234
|
-
|
|
53303
|
+
_internals79.writeFileFsyncedThenRename(tempPath, target, `${JSON.stringify(projection, null, 2)}
|
|
53235
53304
|
`);
|
|
53236
53305
|
}
|
|
53237
53306
|
function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
|
|
53238
53307
|
const dir = ensureCandidateDir(directory, skillSlug, candidateId2);
|
|
53239
53308
|
const target = path95.join(dir, fileName);
|
|
53240
53309
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
53241
|
-
|
|
53310
|
+
_internals79.writeFileFsyncedThenRename(tempPath, target, content);
|
|
53242
53311
|
return target;
|
|
53243
53312
|
}
|
|
53244
53313
|
function readArtifact(directory, skillSlug, candidateId2, fileName) {
|
|
@@ -53331,16 +53400,16 @@ function currentCandidateState(directory, skillSlug, candidateId2) {
|
|
|
53331
53400
|
function writeSkillFileAtomic(targetPath, content) {
|
|
53332
53401
|
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
53333
53402
|
try {
|
|
53334
|
-
|
|
53335
|
-
|
|
53403
|
+
_internals80.writeFileSync(tempPath, content, "utf8");
|
|
53404
|
+
_internals80.renameSync(tempPath, targetPath);
|
|
53336
53405
|
} finally {
|
|
53337
53406
|
try {
|
|
53338
53407
|
if (existsSync54(tempPath))
|
|
53339
|
-
|
|
53408
|
+
_internals80.unlinkSync(tempPath);
|
|
53340
53409
|
} catch {}
|
|
53341
53410
|
}
|
|
53342
53411
|
}
|
|
53343
|
-
var
|
|
53412
|
+
var _internals80 = {
|
|
53344
53413
|
writeFileSync: writeFileSync18,
|
|
53345
53414
|
renameSync: renameSync19,
|
|
53346
53415
|
unlinkSync: unlinkSync21
|
|
@@ -53797,7 +53866,7 @@ function buildGeneratorInputs(args) {
|
|
|
53797
53866
|
}
|
|
53798
53867
|
};
|
|
53799
53868
|
}
|
|
53800
|
-
var
|
|
53869
|
+
var _internals81 = {
|
|
53801
53870
|
draftDeterministic: defaultDeterministicDraft
|
|
53802
53871
|
};
|
|
53803
53872
|
function defaultDeterministicDraft(inputs) {
|
|
@@ -53867,7 +53936,7 @@ function countChangedLines(a, b) {
|
|
|
53867
53936
|
return changed;
|
|
53868
53937
|
}
|
|
53869
53938
|
function draftCandidate(inputs) {
|
|
53870
|
-
const candidate2 =
|
|
53939
|
+
const candidate2 = _internals81.draftDeterministic(inputs);
|
|
53871
53940
|
enforceTrustRegion(candidate2, inputs.budget);
|
|
53872
53941
|
return candidate2;
|
|
53873
53942
|
}
|
|
@@ -53910,7 +53979,7 @@ import * as path98 from "path";
|
|
|
53910
53979
|
// src/hooks/spawn-helper.ts
|
|
53911
53980
|
import * as child_process8 from "child_process";
|
|
53912
53981
|
var WIN32_CMD_BINARIES = new Set(["npm", "npx", "pnpm", "yarn"]);
|
|
53913
|
-
var
|
|
53982
|
+
var _internals82 = {
|
|
53914
53983
|
spawn: child_process8.spawn
|
|
53915
53984
|
};
|
|
53916
53985
|
function spawnAsync(command, cwd, timeoutMs) {
|
|
@@ -53918,7 +53987,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
53918
53987
|
try {
|
|
53919
53988
|
const [rawCmd, ...args] = command;
|
|
53920
53989
|
const cmd = process.platform === "win32" && WIN32_CMD_BINARIES.has(rawCmd) && !rawCmd.includes(".") ? `${rawCmd}.cmd` : rawCmd;
|
|
53921
|
-
const proc =
|
|
53990
|
+
const proc = _internals82.spawn(cmd, args, {
|
|
53922
53991
|
cwd,
|
|
53923
53992
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53924
53993
|
});
|
|
@@ -53984,7 +54053,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
53984
54053
|
}
|
|
53985
54054
|
|
|
53986
54055
|
// src/services/skill-optimizer/smoke.ts
|
|
53987
|
-
var
|
|
54056
|
+
var _internals83 = {
|
|
53988
54057
|
validateSkillPath,
|
|
53989
54058
|
isSymbolicLink: (p) => {
|
|
53990
54059
|
try {
|
|
@@ -54005,7 +54074,7 @@ var _internals82 = {
|
|
|
54005
54074
|
async function validateSkillSmoke(input) {
|
|
54006
54075
|
const notes = [];
|
|
54007
54076
|
const repoRel = path98.join(".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
|
|
54008
|
-
if (!
|
|
54077
|
+
if (!_internals83.validateSkillPath(repoRel)) {
|
|
54009
54078
|
return {
|
|
54010
54079
|
ok: false,
|
|
54011
54080
|
verdict: "VIOLATED",
|
|
@@ -54014,16 +54083,16 @@ async function validateSkillSmoke(input) {
|
|
|
54014
54083
|
}
|
|
54015
54084
|
const skillRoot = path98.join(input.directory, ".opencode", "skills", "generated", input.skillSlug);
|
|
54016
54085
|
if (existsSync55(skillRoot)) {
|
|
54017
|
-
if (
|
|
54086
|
+
if (_internals83.isSymbolicLink(skillRoot)) {
|
|
54018
54087
|
return {
|
|
54019
54088
|
ok: false,
|
|
54020
54089
|
verdict: "VIOLATED",
|
|
54021
54090
|
notes: ["skill root is a symlink (reparse denied)"]
|
|
54022
54091
|
};
|
|
54023
54092
|
}
|
|
54024
|
-
const realRoot =
|
|
54025
|
-
const realProjectDir =
|
|
54026
|
-
if (
|
|
54093
|
+
const realRoot = _internals83.realpath(skillRoot);
|
|
54094
|
+
const realProjectDir = _internals83.realpath(input.directory);
|
|
54095
|
+
if (_internals83.escapedRoot(realProjectDir, realRoot)) {
|
|
54027
54096
|
return {
|
|
54028
54097
|
ok: false,
|
|
54029
54098
|
verdict: "VIOLATED",
|
|
@@ -54041,7 +54110,7 @@ async function validateSkillSmoke(input) {
|
|
|
54041
54110
|
notes: [`frontmatter: ${fmError}`]
|
|
54042
54111
|
};
|
|
54043
54112
|
}
|
|
54044
|
-
const rejected = await
|
|
54113
|
+
const rejected = await _internals83.isRejectedSkillContent(input.directory, input.skillSlug, input.candidateContent);
|
|
54045
54114
|
if (rejected) {
|
|
54046
54115
|
return {
|
|
54047
54116
|
ok: false,
|
|
@@ -54051,7 +54120,7 @@ async function validateSkillSmoke(input) {
|
|
|
54051
54120
|
]
|
|
54052
54121
|
};
|
|
54053
54122
|
}
|
|
54054
|
-
const evalResult = await
|
|
54123
|
+
const evalResult = await _internals83.evaluateSkillChange({
|
|
54055
54124
|
directory: input.directory,
|
|
54056
54125
|
slug: input.skillSlug,
|
|
54057
54126
|
candidateContent: input.candidateContent,
|
|
@@ -54070,7 +54139,7 @@ async function validateSkillSmoke(input) {
|
|
|
54070
54139
|
notes.push(`phrase-eval passed (score ${evalResult.candidateScore.toFixed(2)})`);
|
|
54071
54140
|
}
|
|
54072
54141
|
if (input.checkCommand && input.checkCommand.length > 0) {
|
|
54073
|
-
const cmdResult = await
|
|
54142
|
+
const cmdResult = await _internals83.spawnAsync(input.checkCommand, input.directory, input.checkTimeoutMs ?? 60000);
|
|
54074
54143
|
if (!cmdResult || cmdResult.exitCode !== 0) {
|
|
54075
54144
|
return {
|
|
54076
54145
|
ok: false,
|
|
@@ -54140,14 +54209,14 @@ async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, base
|
|
|
54140
54209
|
candidate2.contentHash = await computeCandidateInputContentHash2(inputRoot, candidate2);
|
|
54141
54210
|
return { baseline, candidate: candidate2 };
|
|
54142
54211
|
}
|
|
54143
|
-
var
|
|
54212
|
+
var _internals84 = {
|
|
54144
54213
|
tryAcquireLock,
|
|
54145
54214
|
emitTelemetry: emit,
|
|
54146
54215
|
evaluateCandidateV1,
|
|
54147
54216
|
prepareCandidatePayloads
|
|
54148
54217
|
};
|
|
54149
54218
|
async function acquireProjectLock(directory) {
|
|
54150
|
-
const result = await
|
|
54219
|
+
const result = await _internals84.tryAcquireLock(directory, PROJECT_LOCK_PATH, "skill-opt-controller", "project-run");
|
|
54151
54220
|
if (!result.acquired)
|
|
54152
54221
|
return null;
|
|
54153
54222
|
return async () => {
|
|
@@ -54160,7 +54229,7 @@ async function acquireProjectLock(directory) {
|
|
|
54160
54229
|
}
|
|
54161
54230
|
async function acquireSkillLock(directory, skillSlug) {
|
|
54162
54231
|
const lockPath = path99.join(".swarm", "evolution", "skills", skillSlug, ".skill.lock");
|
|
54163
|
-
const result = await
|
|
54232
|
+
const result = await _internals84.tryAcquireLock(directory, lockPath, "skill-opt-controller", `skill-${skillSlug}`);
|
|
54164
54233
|
if (!result.acquired)
|
|
54165
54234
|
return null;
|
|
54166
54235
|
return async () => {
|
|
@@ -54357,13 +54426,13 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
54357
54426
|
while (true) {
|
|
54358
54427
|
try {
|
|
54359
54428
|
const evalInputRoot = input.inputRoot ?? input.directory;
|
|
54360
|
-
const { baseline, candidate: candidate2 } = await
|
|
54429
|
+
const { baseline, candidate: candidate2 } = await _internals84.prepareCandidatePayloads(evalInputRoot, candidateId2, input.skillSlug, input.baselineModel, input.candidateModel, baselineContent, candidateContent);
|
|
54361
54430
|
if (!input.dispatcher) {
|
|
54362
54431
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
54363
54432
|
}
|
|
54364
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
54433
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-w30gazew.js");
|
|
54365
54434
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
54366
|
-
const result = await
|
|
54435
|
+
const result = await _internals84.evaluateCandidateV1({
|
|
54367
54436
|
projectRoot: input.directory,
|
|
54368
54437
|
inputRoot: input.inputRoot ?? input.directory,
|
|
54369
54438
|
tasks: input.validationTasks,
|
|
@@ -54421,7 +54490,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
54421
54490
|
deadband: input.config.deadband
|
|
54422
54491
|
};
|
|
54423
54492
|
}
|
|
54424
|
-
|
|
54493
|
+
_internals84.emitTelemetry?.("loop_detected", {
|
|
54425
54494
|
skillSlug: input.skillSlug,
|
|
54426
54495
|
reason: message.slice(0, 160),
|
|
54427
54496
|
source: "skill-opt-controller"
|
|
@@ -55261,19 +55330,8 @@ function getCompactionMetrics(sessionId) {
|
|
|
55261
55330
|
return { compactionCount: total, lastSnapshotAt: lastSnapshot };
|
|
55262
55331
|
}
|
|
55263
55332
|
|
|
55264
|
-
// src/services/context-budget-service.ts
|
|
55265
|
-
init_logger();
|
|
55266
|
-
var DEFAULT_CONTEXT_BUDGET_CONFIG = {
|
|
55267
|
-
enabled: true,
|
|
55268
|
-
budgetTokens: 40000,
|
|
55269
|
-
warningPct: 70,
|
|
55270
|
-
criticalPct: 90,
|
|
55271
|
-
warningMode: "once",
|
|
55272
|
-
warningIntervalTurns: 20
|
|
55273
|
-
};
|
|
55274
|
-
|
|
55275
55333
|
// src/services/status-service.ts
|
|
55276
|
-
var
|
|
55334
|
+
var _internals85 = {
|
|
55277
55335
|
loadLeanTurboRunState,
|
|
55278
55336
|
hasActiveLeanTurbo,
|
|
55279
55337
|
hasActiveFullAuto,
|
|
@@ -55335,6 +55393,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55335
55393
|
isLegacy: false,
|
|
55336
55394
|
turboMode: hasActiveTurboMode(),
|
|
55337
55395
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
55396
|
+
contextBudgetTokens: swarmState.lastBudgetTokens > 0 ? swarmState.lastBudgetTokens : null,
|
|
55338
55397
|
compactionCount: metrics.compactionCount,
|
|
55339
55398
|
lastSnapshotAt: metrics.lastSnapshotAt
|
|
55340
55399
|
};
|
|
@@ -55351,6 +55410,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55351
55410
|
isLegacy: true,
|
|
55352
55411
|
turboMode: hasActiveTurboMode(),
|
|
55353
55412
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
55413
|
+
contextBudgetTokens: swarmState.lastBudgetTokens > 0 ? swarmState.lastBudgetTokens : null,
|
|
55354
55414
|
compactionCount: metrics.compactionCount,
|
|
55355
55415
|
lastSnapshotAt: metrics.lastSnapshotAt
|
|
55356
55416
|
};
|
|
@@ -55370,6 +55430,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55370
55430
|
isLegacy: true,
|
|
55371
55431
|
turboMode: hasActiveTurboMode(),
|
|
55372
55432
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
55433
|
+
contextBudgetTokens: swarmState.lastBudgetTokens > 0 ? swarmState.lastBudgetTokens : null,
|
|
55373
55434
|
compactionCount: metrics.compactionCount,
|
|
55374
55435
|
lastSnapshotAt: metrics.lastSnapshotAt
|
|
55375
55436
|
};
|
|
@@ -55449,11 +55510,11 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55449
55510
|
} catch {
|
|
55450
55511
|
status.memoryCohort = { linked: false };
|
|
55451
55512
|
}
|
|
55452
|
-
status.fullAutoActive =
|
|
55513
|
+
status.fullAutoActive = _internals85.hasActiveFullAuto();
|
|
55453
55514
|
if (status.fullAutoActive) {
|
|
55454
|
-
const sid =
|
|
55515
|
+
const sid = _internals85.getActiveFullAutoSessionID();
|
|
55455
55516
|
if (sid) {
|
|
55456
|
-
const runState =
|
|
55517
|
+
const runState = _internals85.loadFullAutoRunState(directory, sid);
|
|
55457
55518
|
if (runState?.lastEscalation) {
|
|
55458
55519
|
status.fullAutoEscalation = {
|
|
55459
55520
|
reason: runState.lastEscalation.reason,
|
|
@@ -55487,7 +55548,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55487
55548
|
}
|
|
55488
55549
|
function enrichWithLeanTurbo(status, directory) {
|
|
55489
55550
|
const turboMode = hasActiveTurboMode();
|
|
55490
|
-
const leanActive =
|
|
55551
|
+
const leanActive = _internals85.hasActiveLeanTurbo();
|
|
55491
55552
|
let turboStrategy = "off";
|
|
55492
55553
|
if (leanActive) {
|
|
55493
55554
|
turboStrategy = "lean";
|
|
@@ -55518,7 +55579,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
55518
55579
|
}
|
|
55519
55580
|
}
|
|
55520
55581
|
if (leanSessionID) {
|
|
55521
|
-
const runState =
|
|
55582
|
+
const runState = _internals85.loadLeanTurboRunState(directory, leanSessionID);
|
|
55522
55583
|
if (runState) {
|
|
55523
55584
|
status.leanTurboPhase = runState.phase;
|
|
55524
55585
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -55618,9 +55679,13 @@ function formatStatusMarkdown(status) {
|
|
|
55618
55679
|
}
|
|
55619
55680
|
if (status.contextBudgetPct !== null && status.contextBudgetPct > 0) {
|
|
55620
55681
|
const pct = status.contextBudgetPct.toFixed(1);
|
|
55621
|
-
const budgetTokens =
|
|
55622
|
-
|
|
55623
|
-
|
|
55682
|
+
const budgetTokens = status.contextBudgetTokens;
|
|
55683
|
+
if (budgetTokens !== undefined && budgetTokens !== null && budgetTokens > 0) {
|
|
55684
|
+
const est = Math.round(status.contextBudgetPct / 100 * budgetTokens);
|
|
55685
|
+
lines.push("", `**Context**: ${pct}% used (est. ${est.toLocaleString()} / ${budgetTokens.toLocaleString()} tokens)`);
|
|
55686
|
+
} else {
|
|
55687
|
+
lines.push("", `**Context**: ${pct}% used`);
|
|
55688
|
+
}
|
|
55624
55689
|
if (status.compactionCount > 0) {
|
|
55625
55690
|
lines.push(`**Compaction events**: ${status.compactionCount} triggered`);
|
|
55626
55691
|
}
|
|
@@ -55769,7 +55834,7 @@ init_logger();
|
|
|
55769
55834
|
var TURBO_BYPASS_DISCLOSURE = "Bypassed: Stage B (reviewer + test_engineer) for Tier 0-2 tasks; phase_complete Gates 1-5 " + "(completion-verify, drift-verifier, hallucination-guard, mutation-gate, phase-council). " + "Still enforced: Stage A (lint, imports, pre_check_batch); Tier 3 Stage B; Gate 5b " + "(architecture-supervisor); Gate 6 (final-council); Gate 7 (full-auto).";
|
|
55770
55835
|
|
|
55771
55836
|
// src/commands/turbo.ts
|
|
55772
|
-
var
|
|
55837
|
+
var _internals86 = {
|
|
55773
55838
|
loadPluginConfigWithMeta
|
|
55774
55839
|
};
|
|
55775
55840
|
async function handleTurboCommand(directory, args, sessionID) {
|
|
@@ -55829,7 +55894,7 @@ async function handleTurboCommand(directory, args, sessionID) {
|
|
|
55829
55894
|
if (arg0 === "on") {
|
|
55830
55895
|
let strategy = "standard";
|
|
55831
55896
|
try {
|
|
55832
|
-
const { config } =
|
|
55897
|
+
const { config } = _internals86.loadPluginConfigWithMeta(directory);
|
|
55833
55898
|
if (config.turbo?.strategy === "lean") {
|
|
55834
55899
|
strategy = "lean";
|
|
55835
55900
|
}
|
|
@@ -55926,7 +55991,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
55926
55991
|
let maxParallelCoders = 4;
|
|
55927
55992
|
let conflictPolicy = "serialize";
|
|
55928
55993
|
try {
|
|
55929
|
-
const { config } =
|
|
55994
|
+
const { config } = _internals86.loadPluginConfigWithMeta(directory);
|
|
55930
55995
|
const leanConfig = config.turbo?.lean;
|
|
55931
55996
|
if (leanConfig) {
|
|
55932
55997
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -56189,7 +56254,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
56189
56254
|
async function handleHelpCommand(ctx) {
|
|
56190
56255
|
const targetCommand = ctx.args.join(" ");
|
|
56191
56256
|
if (!targetCommand) {
|
|
56192
|
-
const { buildHelpText } = await import("./index-
|
|
56257
|
+
const { buildHelpText } = await import("./index-xka8s8jw.js");
|
|
56193
56258
|
return buildHelpText();
|
|
56194
56259
|
}
|
|
56195
56260
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -56198,7 +56263,7 @@ async function handleHelpCommand(ctx) {
|
|
|
56198
56263
|
return _internals14.buildDetailedHelp(resolved.key, resolved.entry);
|
|
56199
56264
|
}
|
|
56200
56265
|
const similar = _internals14.findSimilarCommands(targetCommand);
|
|
56201
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
56266
|
+
const { buildHelpText: fullHelp } = await import("./index-xka8s8jw.js");
|
|
56202
56267
|
if (similar.length > 0) {
|
|
56203
56268
|
return `Command '/swarm ${targetCommand}' not found.
|
|
56204
56269
|
|
|
@@ -56375,7 +56440,7 @@ var COMMAND_REGISTRY = {
|
|
|
56375
56440
|
},
|
|
56376
56441
|
"guardrail explain": {
|
|
56377
56442
|
handler: async (ctx) => {
|
|
56378
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
56443
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-vb9k9zwm.js");
|
|
56379
56444
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
56380
56445
|
},
|
|
56381
56446
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -56385,7 +56450,7 @@ var COMMAND_REGISTRY = {
|
|
|
56385
56450
|
},
|
|
56386
56451
|
"guardrail-explain": {
|
|
56387
56452
|
handler: async (ctx) => {
|
|
56388
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
56453
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-vb9k9zwm.js");
|
|
56389
56454
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
56390
56455
|
},
|
|
56391
56456
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -56395,7 +56460,7 @@ var COMMAND_REGISTRY = {
|
|
|
56395
56460
|
},
|
|
56396
56461
|
"guardrail-log": {
|
|
56397
56462
|
handler: async (ctx) => {
|
|
56398
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
56463
|
+
const { handleGuardrailLog } = await import("./guardrail-log-0djnvfas.js");
|
|
56399
56464
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
56400
56465
|
},
|
|
56401
56466
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -57865,10 +57930,11 @@ For every applicable directive in the block:
|
|
|
57865
57930
|
- Cite \`KNOWLEDGE_APPLIED: <id>\` in the next plan / delegation / gate action that complies with it.
|
|
57866
57931
|
- If a directive references a generated skill via \`skill: file:...\`, you MUST add that path to the SKILLS: field of any matching subagent delegation.
|
|
57867
57932
|
- If a directive does NOT apply to the current action, record \`KNOWLEDGE_IGNORED: <id> reason=<short reason>\` once in your reply.
|
|
57933
|
+
- If current system/repository/task authority or observed evidence disproves a directive, record \`KNOWLEDGE_CONTRADICTED: <id> reason=<observable conflict>\` and follow current authority.
|
|
57868
57934
|
- If runtime evidence shows a directive was violated (reviewer rejection, failing test, scope breach), record \`KNOWLEDGE_VIOLATED: <id> reason=<reason>\` and re-plan.
|
|
57869
57935
|
- NEVER silently ignore a \`priority: critical\` directive. The knowledge_application gate may run in 'enforce' mode; in that mode an omitted ack on a critical directive blocks the action for a bounded number of retries and time window (\`max_gate_denials\`, \`gate_staleness_ms\`), after which it auto-clears and logs the bypass \u2014 do not attempt out-of-band workarounds (editing .swarm/ state files, restarting sessions) to escape it; retry the ack with a correctly-terminated marker instead.
|
|
57870
57936
|
|
|
57871
|
-
Chat-text markers (KNOWLEDGE_APPLIED/IGNORED/VIOLATED) are the sole mechanism that satisfies the knowledge-application enforcement gate. The \`knowledge_receipt\` tool records knowledge-usage receipts for audit but does NOT satisfy the gate.
|
|
57937
|
+
Chat-text markers (KNOWLEDGE_APPLIED/IGNORED/CONTRADICTED/VIOLATED) are the sole mechanism that satisfies the knowledge-application enforcement gate. The \`knowledge_receipt\` tool records knowledge-usage receipts for audit but does NOT satisfy the gate.
|
|
57872
57938
|
|
|
57873
57939
|
## SKILL IMPROVER (low-frequency, expensive-model adviser)
|
|
57874
57940
|
|
|
@@ -59418,7 +59484,7 @@ WRONG: "I'll use the Task tool to call another agent to review this code"
|
|
|
59418
59484
|
RIGHT: "I'll read the changed files and review them myself"
|
|
59419
59485
|
|
|
59420
59486
|
## KNOWLEDGE RECEIPTS
|
|
59421
|
-
If you call \`knowledge_recall\` or receive a knowledge directive block with a trace_id, file exactly one \`knowledge_receipt\` before final output: mark each relevant entry as applied, ignored, or contradicted with evidence, or set \`no_relevant_knowledge:true\`. The receipt records audit events; it does not replace any required \`KNOWLEDGE_APPLIED\`, \`KNOWLEDGE_IGNORED\`, or \`KNOWLEDGE_VIOLATED\` directive-compliance line.
|
|
59487
|
+
If you call \`knowledge_recall\` or receive a knowledge directive block with a trace_id, file exactly one \`knowledge_receipt\` before final output: mark each relevant entry as applied, ignored, or contradicted with evidence, or set \`no_relevant_knowledge:true\`. The receipt records audit events; it does not replace any required \`KNOWLEDGE_APPLIED\`, \`KNOWLEDGE_IGNORED\`, \`KNOWLEDGE_CONTRADICTED\`, or \`KNOWLEDGE_VIOLATED\` directive-compliance line.
|
|
59422
59488
|
|
|
59423
59489
|
${READ_ONLY_LANE_GUIDANCE}
|
|
59424
59490
|
|
|
@@ -59905,11 +59971,11 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
|
|
|
59905
59971
|
return;
|
|
59906
59972
|
return async (_systemPrompt, userInput, signal) => {
|
|
59907
59973
|
let ephemeralSessionId;
|
|
59908
|
-
const cleanup = () => {
|
|
59974
|
+
const cleanup = async () => {
|
|
59909
59975
|
if (ephemeralSessionId) {
|
|
59910
59976
|
const id = ephemeralSessionId;
|
|
59911
59977
|
ephemeralSessionId = undefined;
|
|
59912
|
-
client.session
|
|
59978
|
+
await teardownEphemeralSession(client.session, id);
|
|
59913
59979
|
}
|
|
59914
59980
|
};
|
|
59915
59981
|
if (signal?.aborted) {
|
|
@@ -59979,7 +60045,7 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
|
|
|
59979
60045
|
}
|
|
59980
60046
|
throw err;
|
|
59981
60047
|
} finally {
|
|
59982
|
-
cleanup();
|
|
60048
|
+
await cleanup();
|
|
59983
60049
|
}
|
|
59984
60050
|
};
|
|
59985
60051
|
}
|