opencode-swarm 7.138.4 → 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-31yppse4.js → config-doctor-tgnr91q3.js} +2 -2
- package/dist/cli/{core-65c7rvqf.js → core-g2dfh9fq.js} +1 -1
- package/dist/cli/{curation-policy-hs9pc1rp.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-wm27ra25.js → curator-llm-factory-1ftzece0.js} +28 -28
- package/dist/cli/{curator-54n1y4j8.js → curator-nbsag633.js} +28 -28
- package/dist/cli/{evidence-summary-service-hrxcf29a.js → evidence-summary-service-kzxr71yd.js} +9 -9
- package/dist/cli/{gate-evidence-ecx4djaw.js → gate-evidence-z2b1ymnw.js} +5 -5
- package/dist/cli/{guardrail-explain-1729nse8.js → guardrail-explain-vb9k9zwm.js} +29 -29
- package/dist/cli/{guardrail-log-yjj5srkw.js → guardrail-log-0djnvfas.js} +3 -3
- package/dist/cli/{hive-promoter-es2x2b0e.js → hive-promoter-bpt26yew.js} +28 -28
- package/dist/cli/{index-mycqmsz5.js → index-0wp67gqj.js} +452 -159
- package/dist/cli/{index-c60whfgh.js → index-0ymhx85c.js} +2 -2
- package/dist/cli/{index-5q009kc4.js → index-15526t16.js} +8 -3
- package/dist/cli/{index-smsy2p8n.js → index-3eddtgxt.js} +1 -1
- package/dist/cli/{index-4fmztnrq.js → index-4xbyy6aw.js} +2 -2
- package/dist/cli/{index-xybtaph7.js → index-5j6chvj8.js} +1 -1
- package/dist/cli/{index-39k6y018.js → index-5w7ekpy3.js} +2 -2
- package/dist/cli/{index-z7jgvm9b.js → index-5zyk8qgv.js} +2 -2
- package/dist/cli/{index-en4fb04r.js → index-668dpw5e.js} +1 -1
- package/dist/cli/{index-m8txs2a9.js → index-91s653xx.js} +1 -1
- package/dist/cli/{index-y28n2wmq.js → index-a12906mj.js} +1 -1
- package/dist/cli/{index-10mz5js6.js → index-a5eba0t8.js} +2 -2
- package/dist/cli/{index-57stye65.js → index-aymt7hzw.js} +6 -3
- package/dist/cli/{index-1g6xpjk3.js → index-db7wf6ke.js} +7 -7
- package/dist/cli/{index-m1pwkwfe.js → index-dw09fz3w.js} +1 -1
- package/dist/cli/{index-fsrp8wp3.js → index-ed5ykebp.js} +25 -2
- package/dist/cli/{index-jbge0dyh.js → index-en6qq954.js} +3 -3
- package/dist/cli/{index-tqshdzaw.js → index-gvhvz176.js} +2 -2
- package/dist/cli/{index-e1kgxchq.js → index-hgrkhxbk.js} +2 -2
- package/dist/cli/{index-33q2gmgd.js → index-hn0mdcmj.js} +1 -1
- package/dist/cli/{index-a9xny52r.js → index-ht4q3548.js} +2 -2
- package/dist/cli/{index-q344kj84.js → index-prmb5qfp.js} +2 -2
- package/dist/cli/{index-x20cgr2q.js → index-q7ezzgwq.js} +16 -2
- package/dist/cli/{index-ngqxzkqm.js → index-s608d3hw.js} +2 -2
- package/dist/cli/{index-50mwt8fx.js → index-vxbppwvf.js} +5 -5
- package/dist/cli/{index-rrxcfxrd.js → index-wrt6m5ze.js} +1 -1
- package/dist/cli/{index-4qzeef9h.js → index-x9q4bbhd.js} +1 -1
- package/dist/cli/{index-m40ea3zk.js → index-xec724kg.js} +2 -2
- package/dist/cli/{index-k27a4e5g.js → index-xka8s8jw.js} +30 -30
- package/dist/cli/{index-a18hk2fw.js → index-xr07r80d.js} +513 -483
- package/dist/cli/{index-gm3pjfhb.js → index-y1zcsf2a.js} +1 -1
- package/dist/cli/{index-tjwz5tct.js → index-ywysg26s.js} +4 -4
- package/dist/cli/index.js +28 -28
- package/dist/cli/{knowledge-escalator-s6z1x65b.js → knowledge-escalator-pjg2x75c.js} +8 -8
- package/dist/cli/{knowledge-events-nnyn6hst.js → knowledge-events-vxheptk8.js} +6 -6
- package/dist/cli/{knowledge-link-xc6yhxmz.js → knowledge-link-3tq8w6gs.js} +5 -5
- package/dist/cli/{knowledge-store-x4yfc7v3.js → knowledge-store-36mascwz.js} +6 -6
- package/dist/cli/{knowledge-validator-1v047gsa.js → knowledge-validator-anats6rj.js} +9 -9
- package/dist/cli/{pending-delegations-7dbc0j2a.js → pending-delegations-tmyf18p4.js} +5 -5
- package/dist/cli/{pr-subscriptions-m943zn6g.js → pr-subscriptions-hhx6yk24.js} +5 -5
- package/dist/cli/{runner-x1hy047y.js → runner-w30gazew.js} +6 -6
- package/dist/cli/{scan-cursor-jxajj6s7.js → scan-cursor-apbz9eez.js} +7 -7
- package/dist/cli/{schema-fj32eyae.js → schema-x9fr2ey8.js} +3 -1
- package/dist/cli/{scope-persistence-w7zen2wz.js → scope-persistence-3f0d4fwv.js} +4 -4
- package/dist/cli/{skill-generator-rt0jqcsa.js → skill-generator-20czn4kd.js} +10 -10
- package/dist/cli/{telemetry-0yqed3jv.js → telemetry-4tgrfhaz.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-hjrt5hx2.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 +501 -499
- package/dist/memory/injector.d.ts +2 -0
- package/dist/plan/manager.d.ts +2 -0
- package/dist/services/context-budget-service.d.ts +6 -1
- package/dist/services/run-memory.d.ts +53 -5
- 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/tools/update-task-status.d.ts +2 -0
- 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 +95 -1
- 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,22 +13,24 @@ 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,
|
|
29
29
|
checkRequirementCoverage,
|
|
30
30
|
closePlanTerminalState,
|
|
31
31
|
computeSpecHash,
|
|
32
|
+
containsControlChars,
|
|
33
|
+
containsPathTraversal,
|
|
32
34
|
derivePlanMarkdown,
|
|
33
35
|
disableEpicMode,
|
|
34
36
|
enableEpicMode,
|
|
@@ -59,7 +61,7 @@ import {
|
|
|
59
61
|
savePlan,
|
|
60
62
|
transientBackoff,
|
|
61
63
|
validateProjectRoot
|
|
62
|
-
} from "./index-
|
|
64
|
+
} from "./index-0wp67gqj.js";
|
|
63
65
|
import {
|
|
64
66
|
EvaluationTaskV1Schema,
|
|
65
67
|
GateAuditManifestV1Schema,
|
|
@@ -76,7 +78,7 @@ import {
|
|
|
76
78
|
saveGateAuditResult,
|
|
77
79
|
savePromotionDecision,
|
|
78
80
|
saveTaskSetSnapshot
|
|
79
|
-
} from "./index-
|
|
81
|
+
} from "./index-s608d3hw.js";
|
|
80
82
|
import {
|
|
81
83
|
canonicalHash,
|
|
82
84
|
canonicalJson,
|
|
@@ -114,15 +116,15 @@ import {
|
|
|
114
116
|
retireSkill,
|
|
115
117
|
selectCandidateEntries,
|
|
116
118
|
syncBundledProjectSkillsIfMissingAsync
|
|
117
|
-
} from "./index-
|
|
119
|
+
} from "./index-en6qq954.js";
|
|
118
120
|
import {
|
|
119
121
|
readRecentEscalations
|
|
120
|
-
} from "./index-
|
|
122
|
+
} from "./index-vxbppwvf.js";
|
|
121
123
|
import {
|
|
122
124
|
alreadyCuratedThisGeneration,
|
|
123
125
|
claimNextScanBatch,
|
|
124
126
|
resolveCohortId
|
|
125
|
-
} from "./index-
|
|
127
|
+
} from "./index-0ymhx85c.js";
|
|
126
128
|
import {
|
|
127
129
|
CURATOR_INIT_PROMPT,
|
|
128
130
|
CURATOR_PHASE_PROMPT,
|
|
@@ -175,11 +177,11 @@ import {
|
|
|
175
177
|
validateActionableFields,
|
|
176
178
|
validateLesson,
|
|
177
179
|
validateSkillPath
|
|
178
|
-
} from "./index-
|
|
180
|
+
} from "./index-ywysg26s.js";
|
|
179
181
|
import {
|
|
180
182
|
authorizeCuration,
|
|
181
183
|
buildConfigFingerprintInput
|
|
182
|
-
} from "./index-
|
|
184
|
+
} from "./index-xec724kg.js";
|
|
183
185
|
import {
|
|
184
186
|
cohortConfigFingerprint
|
|
185
187
|
} from "./index-rtry5xyf.js";
|
|
@@ -212,7 +214,7 @@ import {
|
|
|
212
214
|
transactFile,
|
|
213
215
|
transactKnowledge,
|
|
214
216
|
wordBigrams
|
|
215
|
-
} from "./index-
|
|
217
|
+
} from "./index-db7wf6ke.js";
|
|
216
218
|
import {
|
|
217
219
|
MAX_EVENT_LOG_ENTRIES,
|
|
218
220
|
_internals,
|
|
@@ -222,7 +224,7 @@ import {
|
|
|
222
224
|
recordHiveKnowledgeEvent,
|
|
223
225
|
recordKnowledgeEvent,
|
|
224
226
|
resolveKnowledgeEventsPath
|
|
225
|
-
} from "./index-
|
|
227
|
+
} from "./index-aymt7hzw.js";
|
|
226
228
|
import {
|
|
227
229
|
resolveHiveDataDir,
|
|
228
230
|
resolveHiveEventsPath,
|
|
@@ -238,16 +240,16 @@ import {
|
|
|
238
240
|
resolveLinkDir,
|
|
239
241
|
sanitizeLinkId,
|
|
240
242
|
writeLinkPointer
|
|
241
|
-
} from "./index-
|
|
243
|
+
} from "./index-668dpw5e.js";
|
|
242
244
|
import {
|
|
243
245
|
atomicWriteFile
|
|
244
|
-
} from "./index-
|
|
246
|
+
} from "./index-gvhvz176.js";
|
|
245
247
|
import {
|
|
246
248
|
exports_loader,
|
|
247
249
|
init_loader,
|
|
248
250
|
loadPluginConfig,
|
|
249
251
|
loadPluginConfigWithMeta
|
|
250
|
-
} from "./index-
|
|
252
|
+
} from "./index-dw09fz3w.js";
|
|
251
253
|
import {
|
|
252
254
|
RetrospectiveEvidenceSchema
|
|
253
255
|
} from "./index-gprxjmm7.js";
|
|
@@ -258,12 +260,13 @@ import {
|
|
|
258
260
|
MemoryConfigSchema,
|
|
259
261
|
SkillImproverConfigSchema,
|
|
260
262
|
getCanonicalAgentRole,
|
|
263
|
+
init_context_window,
|
|
261
264
|
init_package,
|
|
262
265
|
init_schema,
|
|
263
266
|
package_default,
|
|
264
267
|
resolveAutoReviewConfig,
|
|
265
268
|
stripKnownSwarmPrefix
|
|
266
|
-
} from "./index-
|
|
269
|
+
} from "./index-15526t16.js";
|
|
267
270
|
import {
|
|
268
271
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
269
272
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -279,13 +282,13 @@ import {
|
|
|
279
282
|
listActive,
|
|
280
283
|
subscribe,
|
|
281
284
|
unsubscribe
|
|
282
|
-
} from "./index-
|
|
285
|
+
} from "./index-5zyk8qgv.js";
|
|
283
286
|
import {
|
|
284
287
|
MAX_PENDING_SCOPE_BINDINGS,
|
|
285
288
|
clearAllScopes,
|
|
286
289
|
clearScopeBindingFromDisk,
|
|
287
290
|
clearScopeBindings
|
|
288
|
-
} from "./index-
|
|
291
|
+
} from "./index-3eddtgxt.js";
|
|
289
292
|
import {
|
|
290
293
|
appendLedgerEvent,
|
|
291
294
|
computePlanHash,
|
|
@@ -293,7 +296,7 @@ import {
|
|
|
293
296
|
derivePlanId,
|
|
294
297
|
initLedger,
|
|
295
298
|
takeSnapshotEvent
|
|
296
|
-
} from "./index-
|
|
299
|
+
} from "./index-4xbyy6aw.js";
|
|
297
300
|
import {
|
|
298
301
|
PlanSchema
|
|
299
302
|
} from "./index-1kz6da87.js";
|
|
@@ -320,16 +323,20 @@ import {
|
|
|
320
323
|
import {
|
|
321
324
|
findByBatchId,
|
|
322
325
|
readDelegations
|
|
323
|
-
} from "./index-
|
|
326
|
+
} from "./index-prmb5qfp.js";
|
|
324
327
|
import {
|
|
325
328
|
readSwarmFileAsync,
|
|
326
329
|
safeHook,
|
|
327
330
|
validateSwarmPath
|
|
328
|
-
} from "./index-
|
|
331
|
+
} from "./index-x9q4bbhd.js";
|
|
332
|
+
import {
|
|
333
|
+
invalidateCachedArtifact,
|
|
334
|
+
resetSwarmArtifactCache
|
|
335
|
+
} from "./index-ed5ykebp.js";
|
|
329
336
|
import {
|
|
330
337
|
tryAcquireLock,
|
|
331
338
|
withEvidenceLock
|
|
332
|
-
} from "./index-
|
|
339
|
+
} from "./index-5j6chvj8.js";
|
|
333
340
|
import {
|
|
334
341
|
require_proper_lockfile
|
|
335
342
|
} from "./index-7g4c7s5r.js";
|
|
@@ -337,7 +344,7 @@ import {
|
|
|
337
344
|
emit,
|
|
338
345
|
getLastHeartbeat,
|
|
339
346
|
telemetry
|
|
340
|
-
} from "./index-
|
|
347
|
+
} from "./index-a5eba0t8.js";
|
|
341
348
|
import {
|
|
342
349
|
exports_external,
|
|
343
350
|
init_zod
|
|
@@ -5679,6 +5686,8 @@ var swarmState = {
|
|
|
5679
5686
|
gateDenialCounts: new Map,
|
|
5680
5687
|
generatedAgentNames: [],
|
|
5681
5688
|
lastBudgetPct: 0,
|
|
5689
|
+
lastBudgetTokens: 0,
|
|
5690
|
+
liveContextWindows: new Map,
|
|
5682
5691
|
agentSessions: defaultRunContext.agentSessions,
|
|
5683
5692
|
pendingRehydrations: new Set,
|
|
5684
5693
|
fullAutoEnabledInConfig: false,
|
|
@@ -5691,6 +5700,8 @@ function resetSwarmState() {
|
|
|
5691
5700
|
swarmState.delegationChains.clear();
|
|
5692
5701
|
swarmState.pendingEvents = 0;
|
|
5693
5702
|
swarmState.lastBudgetPct = 0;
|
|
5703
|
+
swarmState.lastBudgetTokens = 0;
|
|
5704
|
+
swarmState.liveContextWindows.clear();
|
|
5694
5705
|
swarmState.agentSessions.clear();
|
|
5695
5706
|
_lastIdleSweepAtMs = 0;
|
|
5696
5707
|
clearTrajectoryCache();
|
|
@@ -6521,7 +6532,7 @@ function hasActiveEpicMode(sessionID) {
|
|
|
6521
6532
|
async function rehydratePrSubscriptions(sessionID, directory) {
|
|
6522
6533
|
const map = new Map;
|
|
6523
6534
|
try {
|
|
6524
|
-
const { listActive: listActive2 } = await import("./pr-subscriptions-
|
|
6535
|
+
const { listActive: listActive2 } = await import("./pr-subscriptions-hhx6yk24.js");
|
|
6525
6536
|
const records = await listActive2(directory);
|
|
6526
6537
|
for (const record of records) {
|
|
6527
6538
|
if (record.sessionID !== sessionID)
|
|
@@ -6683,7 +6694,7 @@ async function listLaneBranches(directory) {
|
|
|
6683
6694
|
}
|
|
6684
6695
|
return [...branches];
|
|
6685
6696
|
}
|
|
6686
|
-
async function cleanupOrphanedBranches(directory, activeSessionIds = []) {
|
|
6697
|
+
async function cleanupOrphanedBranches(directory, activeSessionIds = [], options = {}) {
|
|
6687
6698
|
const removed = [];
|
|
6688
6699
|
const skipped = [];
|
|
6689
6700
|
const skippedRecoveryBranches = [];
|
|
@@ -6711,7 +6722,7 @@ async function cleanupOrphanedBranches(directory, activeSessionIds = []) {
|
|
|
6711
6722
|
skippedRecoveryBranches.push(branch);
|
|
6712
6723
|
continue;
|
|
6713
6724
|
}
|
|
6714
|
-
const deleteResult = await runGit(["branch", "-D", branch], directory);
|
|
6725
|
+
const deleteResult = await runGit(["branch", options.preserveUnmerged ? "-d" : "-D", branch], directory);
|
|
6715
6726
|
if (deleteResult.exitCode === 0) {
|
|
6716
6727
|
removed.push(branch);
|
|
6717
6728
|
} else {
|
|
@@ -11986,6 +11997,7 @@ init_constants();
|
|
|
11986
11997
|
init_schema();
|
|
11987
11998
|
|
|
11988
11999
|
// src/hooks/model-limits.ts
|
|
12000
|
+
init_context_window();
|
|
11989
12001
|
var loggedFirstCalls = new Set;
|
|
11990
12002
|
|
|
11991
12003
|
// src/hooks/guardrails/nontransient-circuit.ts
|
|
@@ -14645,47 +14657,6 @@ function resolveWriteTargets(command, writes, cwd) {
|
|
|
14645
14657
|
// src/hooks/write-target-resolver.ts
|
|
14646
14658
|
init_constants();
|
|
14647
14659
|
|
|
14648
|
-
// src/utils/path-security.ts
|
|
14649
|
-
function containsPathTraversal(str) {
|
|
14650
|
-
if (/\.\.[/\\]/.test(str))
|
|
14651
|
-
return true;
|
|
14652
|
-
if (/(?:^|[/\\])\.\.(?:[/\\]|$)/.test(str))
|
|
14653
|
-
return true;
|
|
14654
|
-
if (/%2e%2e/i.test(str))
|
|
14655
|
-
return true;
|
|
14656
|
-
if (/%2e\./i.test(str))
|
|
14657
|
-
return true;
|
|
14658
|
-
if (/%2e/i.test(str) && /\.\./.test(str))
|
|
14659
|
-
return true;
|
|
14660
|
-
if (/%252e%252e/i.test(str))
|
|
14661
|
-
return true;
|
|
14662
|
-
if (/\uff0e/.test(str))
|
|
14663
|
-
return true;
|
|
14664
|
-
if (/\u3002/.test(str))
|
|
14665
|
-
return true;
|
|
14666
|
-
if (/\uff65/.test(str))
|
|
14667
|
-
return true;
|
|
14668
|
-
if (/%2f/i.test(str))
|
|
14669
|
-
return true;
|
|
14670
|
-
if (/%5c/i.test(str))
|
|
14671
|
-
return true;
|
|
14672
|
-
return false;
|
|
14673
|
-
}
|
|
14674
|
-
function containsControlChars(str) {
|
|
14675
|
-
for (const ch of str) {
|
|
14676
|
-
const code = ch.codePointAt(0);
|
|
14677
|
-
if (code === undefined)
|
|
14678
|
-
continue;
|
|
14679
|
-
if (code <= 31 || code >= 127 && code <= 159)
|
|
14680
|
-
return true;
|
|
14681
|
-
if (code >= 8234 && code <= 8238)
|
|
14682
|
-
return true;
|
|
14683
|
-
if (code >= 8294 && code <= 8297)
|
|
14684
|
-
return true;
|
|
14685
|
-
}
|
|
14686
|
-
return false;
|
|
14687
|
-
}
|
|
14688
|
-
|
|
14689
14660
|
// src/tools/file-extractor-planner.ts
|
|
14690
14661
|
var cachedPlans = new WeakMap;
|
|
14691
14662
|
|
|
@@ -19017,7 +18988,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
19017
18988
|
};
|
|
19018
18989
|
}
|
|
19019
18990
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
19020
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18991
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
19021
18992
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
19022
18993
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
19023
18994
|
if (sweepConfig?.enabled === false)
|
|
@@ -20059,6 +20030,7 @@ async function writeCuratorSummaryState(filePath, state) {
|
|
|
20059
20030
|
if (!state.summary)
|
|
20060
20031
|
return;
|
|
20061
20032
|
await bunWrite(filePath, JSON.stringify(state.summary, null, 2));
|
|
20033
|
+
invalidateCachedArtifact(filePath);
|
|
20062
20034
|
}
|
|
20063
20035
|
async function transactCuratorSummary(directory, mutate) {
|
|
20064
20036
|
const resolvedPath = validateSwarmPath(directory, "curator-summary.json");
|
|
@@ -20593,6 +20565,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
20593
20565
|
fs12.mkdirSync(evidenceDir, { recursive: true });
|
|
20594
20566
|
const findingsPath = path32.join(evidenceDir, "curator-findings.json");
|
|
20595
20567
|
await bunWrite(findingsPath, JSON.stringify({ findings: knowledgeApplicationFindings }, null, 2));
|
|
20568
|
+
invalidateCachedArtifact(findingsPath);
|
|
20596
20569
|
} catch (err) {
|
|
20597
20570
|
warn(`[curator] failed to persist application findings: ${err instanceof Error ? err.message : String(err)}`);
|
|
20598
20571
|
}
|
|
@@ -20610,7 +20583,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
20610
20583
|
}
|
|
20611
20584
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
20612
20585
|
try {
|
|
20613
|
-
const skillModule = await import("./skill-generator-
|
|
20586
|
+
const skillModule = await import("./skill-generator-20czn4kd.js");
|
|
20614
20587
|
for (const cand of skillCandidates) {
|
|
20615
20588
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
20616
20589
|
continue;
|
|
@@ -21070,7 +21043,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
21070
21043
|
} catch {}
|
|
21071
21044
|
}
|
|
21072
21045
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
21073
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
21046
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-pjg2x75c.js");
|
|
21074
21047
|
for (const { id } of contradictedEntries) {
|
|
21075
21048
|
try {
|
|
21076
21049
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -21889,7 +21862,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
21889
21862
|
warnings.push("Failed to collect knowledge summary.");
|
|
21890
21863
|
}
|
|
21891
21864
|
try {
|
|
21892
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
21865
|
+
const { getScanStatus } = await import("./scan-cursor-apbz9eez.js");
|
|
21893
21866
|
const scanStatus = await getScanStatus(directory);
|
|
21894
21867
|
if (scanStatus.remaining_estimate > 0) {
|
|
21895
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.`);
|
|
@@ -22061,9 +22034,9 @@ var _internals24 = {
|
|
|
22061
22034
|
verifyPostMortemKnowledgeActions,
|
|
22062
22035
|
repairPostMortemActions,
|
|
22063
22036
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
22064
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
22037
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-x9fr2ey8.js");
|
|
22065
22038
|
try {
|
|
22066
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
22039
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
22067
22040
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
22068
22041
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
22069
22042
|
} catch {
|
|
@@ -22071,11 +22044,11 @@ var _internals24 = {
|
|
|
22071
22044
|
}
|
|
22072
22045
|
},
|
|
22073
22046
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
22074
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
22047
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-nbsag633.js");
|
|
22075
22048
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
22076
22049
|
},
|
|
22077
22050
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
22078
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
22051
|
+
const { checkHivePromotions } = await import("./hive-promoter-bpt26yew.js");
|
|
22079
22052
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
22080
22053
|
},
|
|
22081
22054
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -22084,7 +22057,7 @@ var _internals24 = {
|
|
|
22084
22057
|
activateProposal,
|
|
22085
22058
|
listSkills: listSkills2,
|
|
22086
22059
|
sanitizeSlug
|
|
22087
|
-
} = await import("./skill-generator-
|
|
22060
|
+
} = await import("./skill-generator-20czn4kd.js");
|
|
22088
22061
|
const result = {
|
|
22089
22062
|
approved: [],
|
|
22090
22063
|
rejected: [],
|
|
@@ -22126,7 +22099,7 @@ var _internals24 = {
|
|
|
22126
22099
|
return result;
|
|
22127
22100
|
},
|
|
22128
22101
|
readPriorDriftReports: async (directory) => {
|
|
22129
|
-
const { readPriorDriftReports } = await import("./curator-drift-
|
|
22102
|
+
const { readPriorDriftReports } = await import("./curator-drift-vfh07mqy.js");
|
|
22130
22103
|
return readPriorDriftReports(directory);
|
|
22131
22104
|
},
|
|
22132
22105
|
readSwarmKnowledge: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory))
|
|
@@ -24351,6 +24324,7 @@ ${newSection}`;
|
|
|
24351
24324
|
_internals28.mkdirSync(swarmDir, { recursive: true });
|
|
24352
24325
|
}
|
|
24353
24326
|
_internals28.writeFileSync(contextPath, updatedContent, "utf-8");
|
|
24327
|
+
invalidateCachedArtifact(contextPath);
|
|
24354
24328
|
}
|
|
24355
24329
|
} catch (err) {
|
|
24356
24330
|
warn(`[skill-propagation-gate] failed to write skill index to context.md: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -24711,9 +24685,9 @@ function hashContent(content) {
|
|
|
24711
24685
|
return createHash9("sha1").update(content).digest("hex");
|
|
24712
24686
|
}
|
|
24713
24687
|
async function loadConfigForPolicyCurator(directory) {
|
|
24714
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
24688
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-x9fr2ey8.js");
|
|
24715
24689
|
try {
|
|
24716
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
24690
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
24717
24691
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
24718
24692
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
24719
24693
|
} catch {
|
|
@@ -25813,6 +25787,53 @@ import * as path41 from "path";
|
|
|
25813
25787
|
// src/hooks/skill-improver-llm-factory.ts
|
|
25814
25788
|
init_schema();
|
|
25815
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
|
+
|
|
25816
25837
|
// src/utils/model-dispatch-fallback.ts
|
|
25817
25838
|
function parseModelString(model) {
|
|
25818
25839
|
if (!model || !model.trim())
|
|
@@ -25928,11 +25949,11 @@ function createSkillImproverLLMDelegate(directory, sessionId) {
|
|
|
25928
25949
|
return;
|
|
25929
25950
|
return async (systemPrompt, userInput, signal) => {
|
|
25930
25951
|
let ephemeralSessionId;
|
|
25931
|
-
const cleanup = () => {
|
|
25952
|
+
const cleanup = async () => {
|
|
25932
25953
|
if (ephemeralSessionId) {
|
|
25933
25954
|
const id = ephemeralSessionId;
|
|
25934
25955
|
ephemeralSessionId = undefined;
|
|
25935
|
-
client.session
|
|
25956
|
+
await teardownEphemeralSession(client.session, id);
|
|
25936
25957
|
}
|
|
25937
25958
|
};
|
|
25938
25959
|
if (signal?.aborted) {
|
|
@@ -26002,7 +26023,7 @@ ${userInput}` : userInput;
|
|
|
26002
26023
|
throw new Error("SKILL_IMPROVER_LLM_TIMEOUT");
|
|
26003
26024
|
throw err;
|
|
26004
26025
|
} finally {
|
|
26005
|
-
cleanup();
|
|
26026
|
+
await cleanup();
|
|
26006
26027
|
}
|
|
26007
26028
|
};
|
|
26008
26029
|
}
|
|
@@ -26129,7 +26150,7 @@ function gatherSkillViolations(directory, sessionId) {
|
|
|
26129
26150
|
if (!sessionId)
|
|
26130
26151
|
return [];
|
|
26131
26152
|
try {
|
|
26132
|
-
const entries =
|
|
26153
|
+
const entries = _internals32.readSkillUsageEntriesTail(directory, {
|
|
26133
26154
|
sessionID: sessionId
|
|
26134
26155
|
});
|
|
26135
26156
|
const bySkill = new Map;
|
|
@@ -26162,7 +26183,7 @@ async function gatherContradictionCandidates(directory, sessionStart, dedupThres
|
|
|
26162
26183
|
if (!Number.isFinite(sessionStartMs))
|
|
26163
26184
|
return [];
|
|
26164
26185
|
try {
|
|
26165
|
-
const all = await
|
|
26186
|
+
const all = await _internals32.readKnowledge(resolveSwarmKnowledgePath(directory));
|
|
26166
26187
|
const sessionCreated = all.filter((e) => {
|
|
26167
26188
|
if (typeof e.created_at !== "string")
|
|
26168
26189
|
return false;
|
|
@@ -26210,7 +26231,7 @@ async function gatherRealtimeAdmissionCounts(directory, sessionStart) {
|
|
|
26210
26231
|
if (!Number.isFinite(sessionStartMs))
|
|
26211
26232
|
return;
|
|
26212
26233
|
try {
|
|
26213
|
-
const entries = await
|
|
26234
|
+
const entries = await _internals32.readKnowledge(resolveSwarmKnowledgePath(directory));
|
|
26214
26235
|
let admitted = 0;
|
|
26215
26236
|
let reinforced = 0;
|
|
26216
26237
|
for (const e of entries) {
|
|
@@ -26229,7 +26250,7 @@ async function gatherRealtimeAdmissionCounts(directory, sessionStart) {
|
|
|
26229
26250
|
}
|
|
26230
26251
|
let rejected = 0;
|
|
26231
26252
|
try {
|
|
26232
|
-
const rejectedLessons = await
|
|
26253
|
+
const rejectedLessons = await _internals32.readRejectedLessons(directory);
|
|
26233
26254
|
rejected = rejectedLessons.filter((r) => {
|
|
26234
26255
|
const ms = Date.parse(r.rejected_at ?? "");
|
|
26235
26256
|
return Number.isFinite(ms) && ms >= sessionStartMs;
|
|
@@ -26525,9 +26546,9 @@ async function runSessionReflection(input) {
|
|
|
26525
26546
|
const agentDispatches = gatherAgentDispatches(input.agentSessions);
|
|
26526
26547
|
const { lessons, taxonomy } = await gatherRetroLessonsAndTaxonomy(input.directory);
|
|
26527
26548
|
const gateFailures = await gatherGateFailures(input.directory);
|
|
26528
|
-
const skillViolations =
|
|
26529
|
-
const contradictionCandidates = await
|
|
26530
|
-
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);
|
|
26531
26552
|
const knowledgeDelta = input.knowledgeDelta ? {
|
|
26532
26553
|
...input.knowledgeDelta,
|
|
26533
26554
|
admitted: realtimeCounts?.admitted ?? input.knowledgeDelta.admitted,
|
|
@@ -26587,7 +26608,7 @@ async function writeSessionReflection(directory, result) {
|
|
|
26587
26608
|
await fs15.writeFile(reflectionPath, content, "utf-8");
|
|
26588
26609
|
return reflectionPath;
|
|
26589
26610
|
}
|
|
26590
|
-
var
|
|
26611
|
+
var _internals32 = {
|
|
26591
26612
|
gatherToolProblems,
|
|
26592
26613
|
gatherAgentDispatches,
|
|
26593
26614
|
gatherRetroLessonsAndTaxonomy,
|
|
@@ -26773,9 +26794,9 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
26773
26794
|
return result;
|
|
26774
26795
|
const max = opts.maxProposals ?? 10;
|
|
26775
26796
|
const selected = motifs.slice(0, max);
|
|
26776
|
-
const producedAt =
|
|
26797
|
+
const producedAt = _internals33.now().toISOString();
|
|
26777
26798
|
const candidates = selected.map((motif) => buildMotifCandidate(motif, opts.sessionId));
|
|
26778
|
-
const dedupCheck = await
|
|
26799
|
+
const dedupCheck = await _internals33.checkRecommendations(directory, candidates);
|
|
26779
26800
|
const emitted = dedupCheck.decisions.filter((decision) => decision.emit);
|
|
26780
26801
|
result.duplicatesSuppressed = dedupCheck.decisions.length - emitted.length;
|
|
26781
26802
|
if (emitted.length === 0)
|
|
@@ -26797,7 +26818,7 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
26797
26818
|
result.proposalsWritten.push(filePath);
|
|
26798
26819
|
written.push(candidate);
|
|
26799
26820
|
}
|
|
26800
|
-
await
|
|
26821
|
+
await _internals33.recordEmittedRecommendations(directory, written, {
|
|
26801
26822
|
producedAt
|
|
26802
26823
|
});
|
|
26803
26824
|
return result;
|
|
@@ -26963,9 +26984,9 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
26963
26984
|
return result;
|
|
26964
26985
|
const max = opts.maxProposals ?? 10;
|
|
26965
26986
|
const selected = motifs.slice(0, max);
|
|
26966
|
-
const producedAt =
|
|
26987
|
+
const producedAt = _internals33.now().toISOString();
|
|
26967
26988
|
const candidates = selected.map((motif) => buildWorkflowCandidate(motif, opts.sessionId));
|
|
26968
|
-
const dedupCheck = await
|
|
26989
|
+
const dedupCheck = await _internals33.checkRecommendations(directory, candidates);
|
|
26969
26990
|
const emitted = dedupCheck.decisions.filter((decision) => decision.emit);
|
|
26970
26991
|
result.duplicatesSuppressed = dedupCheck.decisions.length - emitted.length;
|
|
26971
26992
|
if (emitted.length === 0)
|
|
@@ -26987,7 +27008,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
26987
27008
|
result.proposalsWritten.push(filePath);
|
|
26988
27009
|
written.push(candidate);
|
|
26989
27010
|
}
|
|
26990
|
-
await
|
|
27011
|
+
await _internals33.recordEmittedRecommendations(directory, written, {
|
|
26991
27012
|
producedAt
|
|
26992
27013
|
});
|
|
26993
27014
|
return result;
|
|
@@ -26996,7 +27017,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
26996
27017
|
return result;
|
|
26997
27018
|
}
|
|
26998
27019
|
}
|
|
26999
|
-
var
|
|
27020
|
+
var _internals33 = {
|
|
27000
27021
|
now: () => new Date,
|
|
27001
27022
|
checkRecommendations,
|
|
27002
27023
|
recordEmittedRecommendations
|
|
@@ -27325,7 +27346,7 @@ async function reconcileStaleActiveSkills(directory, options = {}) {
|
|
|
27325
27346
|
continue;
|
|
27326
27347
|
}
|
|
27327
27348
|
try {
|
|
27328
|
-
const regen = await
|
|
27349
|
+
const regen = await _internals34.regenerateSkill(directory, skill.slug, {
|
|
27329
27350
|
evaluate: false
|
|
27330
27351
|
});
|
|
27331
27352
|
if (regen.regenerated) {
|
|
@@ -27581,7 +27602,7 @@ async function runSkillImprover(req) {
|
|
|
27581
27602
|
autoApply
|
|
27582
27603
|
};
|
|
27583
27604
|
}
|
|
27584
|
-
var
|
|
27605
|
+
var _internals34 = {
|
|
27585
27606
|
runSkillImprover,
|
|
27586
27607
|
buildDeterministicProposal,
|
|
27587
27608
|
buildLLMProposalFrame,
|
|
@@ -27943,13 +27964,13 @@ var write_retro = createSwarmTool({
|
|
|
27943
27964
|
task_id: args.task_id !== undefined ? String(args.task_id) : undefined,
|
|
27944
27965
|
metadata: args.metadata
|
|
27945
27966
|
};
|
|
27946
|
-
return await
|
|
27967
|
+
return await _internals35.executeWriteRetro(writeRetroArgs, directory);
|
|
27947
27968
|
} catch {
|
|
27948
27969
|
return JSON.stringify({ success: false, phase: rawPhase, message: "Invalid arguments" }, null, 2);
|
|
27949
27970
|
}
|
|
27950
27971
|
}
|
|
27951
27972
|
});
|
|
27952
|
-
var
|
|
27973
|
+
var _internals35 = {
|
|
27953
27974
|
executeWriteRetro,
|
|
27954
27975
|
write_retro
|
|
27955
27976
|
};
|
|
@@ -27962,7 +27983,7 @@ import * as fsSync2 from "fs";
|
|
|
27962
27983
|
import path45 from "path";
|
|
27963
27984
|
var DEFAULT_MAX_SOURCE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
27964
27985
|
var DEFAULT_BUSY_TIMEOUT_MS = 5000;
|
|
27965
|
-
var
|
|
27986
|
+
var _internals36 = {
|
|
27966
27987
|
existsSync: fsSync2.existsSync,
|
|
27967
27988
|
statSync: fsSync2.statSync,
|
|
27968
27989
|
renameSync: fsSync2.renameSync,
|
|
@@ -27972,11 +27993,11 @@ var _internals35 = {
|
|
|
27972
27993
|
DatabaseCtor: null
|
|
27973
27994
|
};
|
|
27974
27995
|
function resolveDatabaseCtor() {
|
|
27975
|
-
return
|
|
27996
|
+
return _internals36.DatabaseCtor ?? loadDatabaseCtor();
|
|
27976
27997
|
}
|
|
27977
27998
|
function safeRemoveTemp(tempPath) {
|
|
27978
27999
|
try {
|
|
27979
|
-
|
|
28000
|
+
_internals36.rmSync(tempPath, {
|
|
27980
28001
|
force: true,
|
|
27981
28002
|
recursive: true,
|
|
27982
28003
|
maxRetries: 3,
|
|
@@ -28032,7 +28053,7 @@ function captureRowCounts(db) {
|
|
|
28032
28053
|
async function archiveSqliteSnapshot(opts) {
|
|
28033
28054
|
const maxSourceBytes = opts.maxSourceBytes ?? DEFAULT_MAX_SOURCE_BYTES;
|
|
28034
28055
|
const busyTimeoutMs = opts.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS;
|
|
28035
|
-
if (!
|
|
28056
|
+
if (!_internals36.existsSync(opts.sourcePath)) {
|
|
28036
28057
|
return {
|
|
28037
28058
|
requiredness: "required",
|
|
28038
28059
|
attempt: "not_attempted",
|
|
@@ -28045,10 +28066,10 @@ async function archiveSqliteSnapshot(opts) {
|
|
|
28045
28066
|
let sourceBytes = 0;
|
|
28046
28067
|
for (const suffix of ["", "-wal", "-shm"]) {
|
|
28047
28068
|
const sidecar = opts.sourcePath + suffix;
|
|
28048
|
-
if (!
|
|
28069
|
+
if (!_internals36.existsSync(sidecar))
|
|
28049
28070
|
continue;
|
|
28050
28071
|
try {
|
|
28051
|
-
sourceBytes +=
|
|
28072
|
+
sourceBytes += _internals36.statSync(sidecar).size;
|
|
28052
28073
|
} catch (err) {
|
|
28053
28074
|
if (suffix === "") {
|
|
28054
28075
|
return {
|
|
@@ -28075,7 +28096,7 @@ async function archiveSqliteSnapshot(opts) {
|
|
|
28075
28096
|
};
|
|
28076
28097
|
}
|
|
28077
28098
|
const destFinal = path45.join(opts.destDir, opts.destName);
|
|
28078
|
-
const destTemp = path45.join(opts.destDir, `.${opts.destName}.tmp.${
|
|
28099
|
+
const destTemp = path45.join(opts.destDir, `.${opts.destName}.tmp.${_internals36.now()}.${_internals36.randomSuffix()}`);
|
|
28079
28100
|
let Db;
|
|
28080
28101
|
try {
|
|
28081
28102
|
Db = resolveDatabaseCtor();
|
|
@@ -28174,7 +28195,7 @@ async function archiveSqliteSnapshot(opts) {
|
|
|
28174
28195
|
};
|
|
28175
28196
|
}
|
|
28176
28197
|
try {
|
|
28177
|
-
|
|
28198
|
+
_internals36.renameSync(destTemp, destFinal);
|
|
28178
28199
|
} catch (err) {
|
|
28179
28200
|
safeRemoveTemp(destTemp);
|
|
28180
28201
|
return {
|
|
@@ -28310,6 +28331,7 @@ var ARCHIVE_ARTIFACTS = [
|
|
|
28310
28331
|
"close-lessons.md",
|
|
28311
28332
|
"knowledge.jsonl",
|
|
28312
28333
|
"knowledge-rejected.jsonl",
|
|
28334
|
+
"run-memory.jsonl",
|
|
28313
28335
|
"repo-graph.json",
|
|
28314
28336
|
"doc-manifest.json",
|
|
28315
28337
|
"dark-matter.md",
|
|
@@ -28332,6 +28354,7 @@ var ACTIVE_STATE_TO_CLEAN = [
|
|
|
28332
28354
|
"handoff-consumed.md",
|
|
28333
28355
|
"escalation-report.md",
|
|
28334
28356
|
"knowledge-rejected.jsonl",
|
|
28357
|
+
"run-memory.jsonl",
|
|
28335
28358
|
"repo-graph.json",
|
|
28336
28359
|
"doc-manifest.json",
|
|
28337
28360
|
"dark-matter.md",
|
|
@@ -28538,8 +28561,8 @@ async function runFinalizeStage(ctx) {
|
|
|
28538
28561
|
];
|
|
28539
28562
|
ctx.curationSucceeded = false;
|
|
28540
28563
|
try {
|
|
28541
|
-
ctx.curationResult = await
|
|
28542
|
-
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),
|
|
28543
28566
|
enrichmentQuota: {
|
|
28544
28567
|
maxCalls: ctx.config.enrichment.max_calls_per_day,
|
|
28545
28568
|
window: ctx.config.enrichment.quota_window
|
|
@@ -28558,7 +28581,7 @@ async function runFinalizeStage(ctx) {
|
|
|
28558
28581
|
if (ctx.config.hive_enabled === false) {} else {
|
|
28559
28582
|
try {
|
|
28560
28583
|
const entries = await readKnowledge(resolveSwarmKnowledgePath(ctx.directory));
|
|
28561
|
-
const result = await
|
|
28584
|
+
const result = await _internals37.checkHivePromotions(entries, ctx.config, ctx.directory);
|
|
28562
28585
|
ctx.hivePromoted = result.new_promotions;
|
|
28563
28586
|
} catch (hiveErr) {
|
|
28564
28587
|
const msg = hiveErr instanceof Error ? hiveErr.message : String(hiveErr);
|
|
@@ -28579,7 +28602,7 @@ async function runFinalizeStage(ctx) {
|
|
|
28579
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.` : "";
|
|
28580
28603
|
if (ctx.runSkillReview) {
|
|
28581
28604
|
try {
|
|
28582
|
-
const { config: loadedConfig } =
|
|
28605
|
+
const { config: loadedConfig } = _internals37.loadPluginConfigWithMeta(ctx.directory);
|
|
28583
28606
|
const skillImproverConfig = SkillImproverConfigSchema.parse(loadedConfig.skill_improver ?? {});
|
|
28584
28607
|
const skillReviewResult = await runAbortableSkillReview({
|
|
28585
28608
|
directory: ctx.directory,
|
|
@@ -28657,7 +28680,7 @@ async function runFinalizeStage(ctx) {
|
|
|
28657
28680
|
}
|
|
28658
28681
|
if (!ctx.planAlreadyDone || ctx.guaranteeResult.closedPhaseIds.length > 0 || ctx.guaranteeResult.closedTaskIds.length > 0) {
|
|
28659
28682
|
try {
|
|
28660
|
-
await
|
|
28683
|
+
await _internals37.closePlanTerminalState(ctx.directory, ctx.planData, {
|
|
28661
28684
|
closedPhaseIds: ctx.guaranteeResult.closedPhaseIds,
|
|
28662
28685
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
28663
28686
|
originalStatuses: ctx.originalStatuses
|
|
@@ -28673,12 +28696,12 @@ async function runFinalizeStage(ctx) {
|
|
|
28673
28696
|
}
|
|
28674
28697
|
}
|
|
28675
28698
|
try {
|
|
28676
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
28677
|
-
const { config: pmLoadedConfig } =
|
|
28699
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-x9fr2ey8.js");
|
|
28700
|
+
const { config: pmLoadedConfig } = _internals37.loadPluginConfigWithMeta(ctx.directory);
|
|
28678
28701
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
28679
28702
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
28680
|
-
const pmResult = await
|
|
28681
|
-
llmDelegate:
|
|
28703
|
+
const pmResult = await _internals37.runCuratorPostMortem(ctx.directory, {
|
|
28704
|
+
llmDelegate: _internals37.createCuratorLLMDelegate(ctx.directory, "postmortem", ctx.options.sessionID),
|
|
28682
28705
|
scope: "project",
|
|
28683
28706
|
sessionID: ctx.options.sessionID
|
|
28684
28707
|
});
|
|
@@ -28701,7 +28724,7 @@ async function runArchiveStage(ctx) {
|
|
|
28701
28724
|
try {
|
|
28702
28725
|
await fs16.mkdir(ctx.archiveDir, { recursive: true });
|
|
28703
28726
|
try {
|
|
28704
|
-
await
|
|
28727
|
+
await _internals37.flushAndDrainTelemetry();
|
|
28705
28728
|
} catch (flushErr) {
|
|
28706
28729
|
const msg = flushErr instanceof Error ? flushErr.message : String(flushErr);
|
|
28707
28730
|
ctx.warnings.push(`Telemetry flush before archive failed: ${msg}`);
|
|
@@ -28880,7 +28903,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
28880
28903
|
let cacheMaxBytes;
|
|
28881
28904
|
let cacheMaxRecords;
|
|
28882
28905
|
try {
|
|
28883
|
-
const { config: evidenceLoadedConfig } =
|
|
28906
|
+
const { config: evidenceLoadedConfig } = _internals37.loadPluginConfigWithMeta(ctx.directory);
|
|
28884
28907
|
const evidenceCfg = evidenceLoadedConfig.evidence ?? {};
|
|
28885
28908
|
if (typeof evidenceCfg.max_age_days === "number") {
|
|
28886
28909
|
maxAgeDays = evidenceCfg.max_age_days;
|
|
@@ -28896,7 +28919,7 @@ async function runArchiveEvidenceRetention(ctx) {
|
|
|
28896
28919
|
}
|
|
28897
28920
|
} catch {}
|
|
28898
28921
|
try {
|
|
28899
|
-
await
|
|
28922
|
+
await _internals37.archiveEvidence(ctx.directory, maxAgeDays, maxBundles, {
|
|
28900
28923
|
report: true,
|
|
28901
28924
|
cacheMaxBytes,
|
|
28902
28925
|
cacheMaxRecords
|
|
@@ -29089,6 +29112,7 @@ async function runCleanStage(ctx) {
|
|
|
29089
29112
|
try {
|
|
29090
29113
|
await fs16.writeFile(contextTempPath, contextContent, "utf-8");
|
|
29091
29114
|
fsSync3.renameSync(contextTempPath, contextPath);
|
|
29115
|
+
invalidateCachedArtifact(contextPath);
|
|
29092
29116
|
} catch (error2) {
|
|
29093
29117
|
try {
|
|
29094
29118
|
fsSync3.unlinkSync(contextTempPath);
|
|
@@ -29108,9 +29132,9 @@ async function runAlignStage(ctx) {
|
|
|
29108
29132
|
const pruneBranches = ctx.args.includes("--prune-branches");
|
|
29109
29133
|
let gitAlignResult = "";
|
|
29110
29134
|
const prunedBranches = [];
|
|
29111
|
-
const gitStatus =
|
|
29135
|
+
const gitStatus = _internals37.getGitRepositoryStatus(ctx.directory);
|
|
29112
29136
|
if (gitStatus.isRepo) {
|
|
29113
|
-
const aggressiveResult = await
|
|
29137
|
+
const aggressiveResult = await _internals37.resetToMainAfterMerge(ctx.directory, {
|
|
29114
29138
|
pruneBranches
|
|
29115
29139
|
});
|
|
29116
29140
|
if (aggressiveResult.success) {
|
|
@@ -29122,7 +29146,7 @@ async function runAlignStage(ctx) {
|
|
|
29122
29146
|
ctx.warnings.push("Uncommitted changes were discarded during git alignment");
|
|
29123
29147
|
}
|
|
29124
29148
|
} else {
|
|
29125
|
-
const alignResult = await
|
|
29149
|
+
const alignResult = await _internals37.resetToRemoteBranch(ctx.directory, {
|
|
29126
29150
|
pruneBranches
|
|
29127
29151
|
});
|
|
29128
29152
|
gitAlignResult = alignResult.message;
|
|
@@ -29158,7 +29182,7 @@ async function runFinalizeDryRun(directory, swarmDir, planData, planExists) {
|
|
|
29158
29182
|
const wouldArchiveDirs = ACTIVE_STATE_DIRS_TO_CLEAN.filter(existsInSwarm);
|
|
29159
29183
|
const wouldRemoveTerminal = TERMINAL_STATE_FILES.filter(existsInSwarm);
|
|
29160
29184
|
const wouldCleanFiles = ACTIVE_STATE_TO_CLEAN.filter((f) => existsInSwarm(f) && !TERMINAL_STATE_FILES.includes(f));
|
|
29161
|
-
const gitStatus =
|
|
29185
|
+
const gitStatus = _internals37.getGitRepositoryStatus(directory);
|
|
29162
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)";
|
|
29163
29187
|
const lines = [
|
|
29164
29188
|
"## /swarm finalize \u2014 DRY RUN (no changes made)",
|
|
@@ -29230,12 +29254,12 @@ async function handleCloseCommand(directory, args, options = {}) {
|
|
|
29230
29254
|
}
|
|
29231
29255
|
}
|
|
29232
29256
|
if (args.includes("--dry-run")) {
|
|
29233
|
-
return
|
|
29257
|
+
return _internals37.runFinalizeDryRun(directory, swarmDir, planData, planExists);
|
|
29234
29258
|
}
|
|
29235
29259
|
let finalizeLock = {
|
|
29236
29260
|
acquired: false
|
|
29237
29261
|
};
|
|
29238
|
-
finalizeLock = await
|
|
29262
|
+
finalizeLock = await _internals37.acquireFinalizeLock(directory);
|
|
29239
29263
|
if (!finalizeLock.acquired) {
|
|
29240
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.`;
|
|
29241
29265
|
}
|
|
@@ -29266,7 +29290,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29266
29290
|
if (planExists) {
|
|
29267
29291
|
planAlreadyDone = phases.length > 0 && phases.every((p) => p.status === "complete" || p.status === "completed" || p.status === "blocked" || p.status === "closed");
|
|
29268
29292
|
}
|
|
29269
|
-
const { config: loadedConfig } =
|
|
29293
|
+
const { config: loadedConfig } = _internals37.loadPluginConfigWithMeta(directory);
|
|
29270
29294
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
29271
29295
|
const ctx = {
|
|
29272
29296
|
directory,
|
|
@@ -29315,9 +29339,9 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29315
29339
|
archiveSuffix: "",
|
|
29316
29340
|
args
|
|
29317
29341
|
};
|
|
29318
|
-
ctx.fullAuto = options.sessionID ?
|
|
29342
|
+
ctx.fullAuto = options.sessionID ? _internals37.detectFullAuto(directory, options.sessionID) : false;
|
|
29319
29343
|
await runFinalizeStage(ctx);
|
|
29320
|
-
await
|
|
29344
|
+
await _internals37.runFinalizeRewardSweep({
|
|
29321
29345
|
directory,
|
|
29322
29346
|
closedTaskIds: ctx.guaranteeResult.closedTaskIds,
|
|
29323
29347
|
memoryConfig: loadedConfig.memory
|
|
@@ -29389,6 +29413,7 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29389
29413
|
try {
|
|
29390
29414
|
await fs16.writeFile(closeSummaryTempPath, summaryContent, "utf-8");
|
|
29391
29415
|
fsSync3.renameSync(closeSummaryTempPath, closeSummaryPath);
|
|
29416
|
+
invalidateCachedArtifact(closeSummaryPath);
|
|
29392
29417
|
} catch (error2) {
|
|
29393
29418
|
try {
|
|
29394
29419
|
fsSync3.unlinkSync(closeSummaryTempPath);
|
|
@@ -29400,9 +29425,9 @@ This project was already finalized in a previous /swarm close run. The plan has
|
|
|
29400
29425
|
try {
|
|
29401
29426
|
const sessionIdsToEnd = [...swarmState.agentSessions.keys()];
|
|
29402
29427
|
for (const sessionId of sessionIdsToEnd) {
|
|
29403
|
-
|
|
29428
|
+
_internals37.endAgentSession(sessionId);
|
|
29404
29429
|
}
|
|
29405
|
-
|
|
29430
|
+
_internals37.resetSwarmStatePreservingSingletons();
|
|
29406
29431
|
} catch (teardownError) {
|
|
29407
29432
|
const msg = teardownError instanceof Error ? teardownError.message : String(teardownError);
|
|
29408
29433
|
ctx.warnings.push(`Session teardown encountered an error after finalization completed (state may not be fully reset): ${msg}`);
|
|
@@ -29499,7 +29524,7 @@ function detectFullAuto(directory, sessionID) {
|
|
|
29499
29524
|
return false;
|
|
29500
29525
|
}
|
|
29501
29526
|
}
|
|
29502
|
-
var
|
|
29527
|
+
var _internals37 = {
|
|
29503
29528
|
ACTIVE_STATE_DIRS_TO_CLEAN,
|
|
29504
29529
|
countSessionKnowledgeEntries,
|
|
29505
29530
|
CLOSE_SKILL_REVIEW_TIMEOUT_MS,
|
|
@@ -29528,7 +29553,7 @@ var _internals36 = {
|
|
|
29528
29553
|
closePlanTerminalState,
|
|
29529
29554
|
endAgentSession,
|
|
29530
29555
|
flushAndDrainTelemetry: async () => {
|
|
29531
|
-
const { flushAndDrainTelemetry } = await import("./telemetry-
|
|
29556
|
+
const { flushAndDrainTelemetry } = await import("./telemetry-4tgrfhaz.js");
|
|
29532
29557
|
return flushAndDrainTelemetry();
|
|
29533
29558
|
}
|
|
29534
29559
|
};
|
|
@@ -29995,7 +30020,7 @@ function isValidTelemetryEntry(value) {
|
|
|
29995
30020
|
const obj = value;
|
|
29996
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";
|
|
29997
30022
|
}
|
|
29998
|
-
var
|
|
30023
|
+
var _internals38 = {
|
|
29999
30024
|
appendFileSync: fs17.appendFileSync,
|
|
30000
30025
|
readFileSync: fs17.readFileSync,
|
|
30001
30026
|
existsSync: fs17.existsSync,
|
|
@@ -30008,10 +30033,10 @@ function readTelemetry(directory) {
|
|
|
30008
30033
|
const filePath = telemetryFilePath(directory);
|
|
30009
30034
|
const entries = [];
|
|
30010
30035
|
try {
|
|
30011
|
-
if (!
|
|
30036
|
+
if (!_internals38.existsSync(filePath)) {
|
|
30012
30037
|
return entries;
|
|
30013
30038
|
}
|
|
30014
|
-
const raw =
|
|
30039
|
+
const raw = _internals38.readFileSync(filePath, "utf-8");
|
|
30015
30040
|
const lines = raw.split(`
|
|
30016
30041
|
`);
|
|
30017
30042
|
for (const line of lines) {
|
|
@@ -30448,9 +30473,9 @@ async function detectDarkMatter(directory, options) {
|
|
|
30448
30473
|
} catch {
|
|
30449
30474
|
return [];
|
|
30450
30475
|
}
|
|
30451
|
-
const commitMap = await
|
|
30452
|
-
const matrix =
|
|
30453
|
-
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);
|
|
30454
30479
|
const results = [];
|
|
30455
30480
|
for (const entry of matrix.values()) {
|
|
30456
30481
|
const key = `${entry.fileA}::${entry.fileB}`;
|
|
@@ -30566,11 +30591,11 @@ var co_change_analyzer = createSwarmTool({
|
|
|
30566
30591
|
npmiThreshold,
|
|
30567
30592
|
maxCommitsToAnalyze
|
|
30568
30593
|
};
|
|
30569
|
-
const pairs = await
|
|
30570
|
-
return
|
|
30594
|
+
const pairs = await _internals39.detectDarkMatter(directory, options);
|
|
30595
|
+
return _internals39.formatDarkMatterOutput(pairs);
|
|
30571
30596
|
}
|
|
30572
30597
|
});
|
|
30573
|
-
var
|
|
30598
|
+
var _internals39 = {
|
|
30574
30599
|
parseGitLog,
|
|
30575
30600
|
buildCoChangeMatrix,
|
|
30576
30601
|
getStaticEdges,
|
|
@@ -30587,7 +30612,7 @@ var DEFAULT_MAX_COMMITS = 500;
|
|
|
30587
30612
|
var cache = new Map;
|
|
30588
30613
|
async function readGitHead(directory) {
|
|
30589
30614
|
try {
|
|
30590
|
-
const { stdout } = await
|
|
30615
|
+
const { stdout } = await _internals40.execFile("git", ["rev-parse", "HEAD"], {
|
|
30591
30616
|
cwd: directory,
|
|
30592
30617
|
timeout: GIT_HEAD_TIMEOUT_MS
|
|
30593
30618
|
});
|
|
@@ -30613,9 +30638,9 @@ async function getCoChangeData(directory, options) {
|
|
|
30613
30638
|
let entries;
|
|
30614
30639
|
let commitsObserved;
|
|
30615
30640
|
try {
|
|
30616
|
-
const commitMap = await
|
|
30641
|
+
const commitMap = await _internals40.parseGitLog(directory, maxCommits);
|
|
30617
30642
|
commitsObserved = commitMap.size;
|
|
30618
|
-
const matrix =
|
|
30643
|
+
const matrix = _internals40.buildCoChangeMatrix(commitMap);
|
|
30619
30644
|
entries = Array.from(matrix.values());
|
|
30620
30645
|
} catch {
|
|
30621
30646
|
return { pairs: [], commitsObserved: 0 };
|
|
@@ -30639,10 +30664,10 @@ async function getCoChangePairs(directory, options) {
|
|
|
30639
30664
|
const data = await getCoChangeData(directory, options);
|
|
30640
30665
|
return data.pairs;
|
|
30641
30666
|
}
|
|
30642
|
-
var
|
|
30667
|
+
var _internals40 = {
|
|
30643
30668
|
execFile: execFileAsync,
|
|
30644
|
-
parseGitLog:
|
|
30645
|
-
buildCoChangeMatrix:
|
|
30669
|
+
parseGitLog: _internals39.parseGitLog,
|
|
30670
|
+
buildCoChangeMatrix: _internals39.buildCoChangeMatrix
|
|
30646
30671
|
};
|
|
30647
30672
|
|
|
30648
30673
|
// src/turbo/epic/coupling-report.ts
|
|
@@ -30866,7 +30891,7 @@ async function handleCouplingCommand(directory, args) {
|
|
|
30866
30891
|
|
|
30867
30892
|
Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>] [--format markdown|json] [--persist]`;
|
|
30868
30893
|
}
|
|
30869
|
-
const plan = await
|
|
30894
|
+
const plan = await _internals41.loadPlanJsonOnly(directory);
|
|
30870
30895
|
if (plan === null) {
|
|
30871
30896
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` to create one before measuring coupling.";
|
|
30872
30897
|
}
|
|
@@ -30890,7 +30915,7 @@ Usage: /swarm coupling [--phase <n>] [--threshold <-1..1>] [--min-co-changes <n>
|
|
|
30890
30915
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
30891
30916
|
return { id: task.id, scope };
|
|
30892
30917
|
});
|
|
30893
|
-
const cochangePairs = await
|
|
30918
|
+
const cochangePairs = await _internals41.getCoChangePairs(directory);
|
|
30894
30919
|
const report = computeCouplingReport(tasks, cochangePairs, {
|
|
30895
30920
|
npmi: parsed.threshold,
|
|
30896
30921
|
minCoChanges: parsed.minCoChanges
|
|
@@ -30929,14 +30954,14 @@ _Warning: failed to persist report (${persistStatus.error})._`;
|
|
|
30929
30954
|
}
|
|
30930
30955
|
return `${formatCouplingReportMarkdown(report)}${persistTrailer}`;
|
|
30931
30956
|
}
|
|
30932
|
-
var
|
|
30957
|
+
var _internals41 = {
|
|
30933
30958
|
loadPlanJsonOnly,
|
|
30934
30959
|
getCoChangePairs
|
|
30935
30960
|
};
|
|
30936
30961
|
|
|
30937
30962
|
// src/commands/curate.ts
|
|
30938
30963
|
init_schema();
|
|
30939
|
-
var
|
|
30964
|
+
var _internals42 = {
|
|
30940
30965
|
checkHivePromotions,
|
|
30941
30966
|
readKnowledge,
|
|
30942
30967
|
resolveSwarmKnowledgePath,
|
|
@@ -30944,9 +30969,9 @@ var _internals41 = {
|
|
|
30944
30969
|
loadPluginConfigWithMeta,
|
|
30945
30970
|
loadCuratorDeps: async () => {
|
|
30946
30971
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
30947
|
-
import("./schema-
|
|
30948
|
-
import("./curator-
|
|
30949
|
-
import("./curator-llm-factory-
|
|
30972
|
+
import("./schema-x9fr2ey8.js"),
|
|
30973
|
+
import("./curator-nbsag633.js"),
|
|
30974
|
+
import("./curator-llm-factory-1ftzece0.js")
|
|
30950
30975
|
]);
|
|
30951
30976
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
30952
30977
|
}
|
|
@@ -30955,20 +30980,20 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
30955
30980
|
try {
|
|
30956
30981
|
let config;
|
|
30957
30982
|
try {
|
|
30958
|
-
const { config: loadedConfig } =
|
|
30983
|
+
const { config: loadedConfig } = _internals42.loadPluginConfigWithMeta(directory);
|
|
30959
30984
|
config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
30960
30985
|
} catch {
|
|
30961
30986
|
config = KnowledgeConfigSchema.parse({});
|
|
30962
30987
|
}
|
|
30963
|
-
const swarmPath =
|
|
30964
|
-
const swarmEntries = await
|
|
30965
|
-
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);
|
|
30966
30991
|
if (options?.sessionID) {
|
|
30967
30992
|
let onDemandPhase = 1;
|
|
30968
30993
|
try {
|
|
30969
|
-
const { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 } = await
|
|
30994
|
+
const { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 } = await _internals42.loadCuratorDeps();
|
|
30970
30995
|
const curatorConfig = CuratorConfigSchema.parse({});
|
|
30971
|
-
const priorSummary = await
|
|
30996
|
+
const priorSummary = await _internals42.readSwarmFileAsync(directory, "curator-summary.json");
|
|
30972
30997
|
if (priorSummary) {
|
|
30973
30998
|
try {
|
|
30974
30999
|
const parsed = JSON.parse(priorSummary);
|
|
@@ -30979,7 +31004,7 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
30979
31004
|
}
|
|
30980
31005
|
let planPhaseCount = Infinity;
|
|
30981
31006
|
try {
|
|
30982
|
-
const planRaw = await
|
|
31007
|
+
const planRaw = await _internals42.readSwarmFileAsync(directory, "plan.json");
|
|
30983
31008
|
if (planRaw) {
|
|
30984
31009
|
const plan = JSON.parse(planRaw);
|
|
30985
31010
|
if (Array.isArray(plan.phases))
|
|
@@ -30998,8 +31023,8 @@ async function handleCurateCommand(directory, _args, options) {
|
|
|
30998
31023
|
summary.knowledge_skipped = applied.skipped;
|
|
30999
31024
|
summary.curator_phase = onDemandPhase;
|
|
31000
31025
|
try {
|
|
31001
|
-
const updatedEntries = await
|
|
31002
|
-
const postUpdateHive = await
|
|
31026
|
+
const updatedEntries = await _internals42.readKnowledge(swarmPath) ?? [];
|
|
31027
|
+
const postUpdateHive = await _internals42.checkHivePromotions(updatedEntries, config, directory);
|
|
31003
31028
|
summary.new_promotions += postUpdateHive.new_promotions;
|
|
31004
31029
|
summary.encounters_incremented += postUpdateHive.encounters_incremented;
|
|
31005
31030
|
summary.advancements += postUpdateHive.advancements;
|
|
@@ -31065,7 +31090,7 @@ async function handleDarkMatterCommand(directory, args) {
|
|
|
31065
31090
|
}
|
|
31066
31091
|
let pairs;
|
|
31067
31092
|
try {
|
|
31068
|
-
pairs = await
|
|
31093
|
+
pairs = await _internals39.detectDarkMatter(directory, options);
|
|
31069
31094
|
} catch (err) {
|
|
31070
31095
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
31071
31096
|
return `## Dark Matter Analysis Failed
|
|
@@ -31330,7 +31355,7 @@ ${USAGE7}`;
|
|
|
31330
31355
|
// src/commands/design-docs.ts
|
|
31331
31356
|
init_warning_buffer();
|
|
31332
31357
|
var MAX_DESC_LEN = 2000;
|
|
31333
|
-
var
|
|
31358
|
+
var _internals43 = { loadPluginConfigWithMeta };
|
|
31334
31359
|
var USAGE8 = `Usage: /swarm design-docs <description> [--out <dir>] [--lang <name>] [--update]
|
|
31335
31360
|
|
|
31336
31361
|
Generate or sync language-agnostic design docs for the project under build:
|
|
@@ -31426,7 +31451,7 @@ async function handleDesignDocsCommand(directory, args) {
|
|
|
31426
31451
|
${USAGE8}`;
|
|
31427
31452
|
}
|
|
31428
31453
|
try {
|
|
31429
|
-
const { config } =
|
|
31454
|
+
const { config } = _internals43.loadPluginConfigWithMeta(directory);
|
|
31430
31455
|
if (config.design_docs?.enabled !== true) {
|
|
31431
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.
|
|
31432
31457
|
|
|
@@ -31851,7 +31876,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
31851
31876
|
let scanCompleted = false;
|
|
31852
31877
|
let scanRemaining = 0;
|
|
31853
31878
|
try {
|
|
31854
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
31879
|
+
const { getScanStatus } = await import("./scan-cursor-apbz9eez.js");
|
|
31855
31880
|
const status = await getScanStatus(directory);
|
|
31856
31881
|
scanGeneration = status.generation;
|
|
31857
31882
|
scanCompleted = status.completed;
|
|
@@ -31859,19 +31884,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
31859
31884
|
} catch {}
|
|
31860
31885
|
let configMatch = null;
|
|
31861
31886
|
try {
|
|
31862
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
31887
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-3tq8w6gs.js");
|
|
31863
31888
|
if (isLinked2(directory)) {
|
|
31864
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
31889
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-x9fr2ey8.js");
|
|
31865
31890
|
let config;
|
|
31866
31891
|
try {
|
|
31867
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
31892
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ht4q3548.js");
|
|
31868
31893
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
31869
31894
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
31870
31895
|
} catch {
|
|
31871
31896
|
config = KnowledgeConfigSchema2.parse({});
|
|
31872
31897
|
}
|
|
31873
31898
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
31874
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
31899
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-2qnhgdtt.js");
|
|
31875
31900
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
31876
31901
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
31877
31902
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -32033,7 +32058,7 @@ function resolveCachePackageRoot(cachePath) {
|
|
|
32033
32058
|
const nestedPackageRoot = path54.join(cachePath, "node_modules", "opencode-swarm");
|
|
32034
32059
|
return existsSync31(nestedPackageRoot) ? nestedPackageRoot : cachePath;
|
|
32035
32060
|
}
|
|
32036
|
-
var
|
|
32061
|
+
var _internals44 = {
|
|
32037
32062
|
detectSandboxCapability: () => sandboxCapabilityProbe.detect(),
|
|
32038
32063
|
getSandboxExecutor: getExecutor
|
|
32039
32064
|
};
|
|
@@ -32617,9 +32642,9 @@ async function checkCurator(directory) {
|
|
|
32617
32642
|
}
|
|
32618
32643
|
async function getSandboxStatus() {
|
|
32619
32644
|
try {
|
|
32620
|
-
const capability = await
|
|
32645
|
+
const capability = await _internals44.detectSandboxCapability();
|
|
32621
32646
|
const mechanism = capability.mechanism ?? "none";
|
|
32622
|
-
const executor = await
|
|
32647
|
+
const executor = await _internals44.getSandboxExecutor();
|
|
32623
32648
|
const hasExecutor = executor !== null;
|
|
32624
32649
|
if (hasExecutor) {
|
|
32625
32650
|
const executorStrength = executor?.strength;
|
|
@@ -33082,7 +33107,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
33082
33107
|
const result = runConfigDoctor(config, directory);
|
|
33083
33108
|
let output;
|
|
33084
33109
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
33085
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
33110
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-tgnr91q3.js");
|
|
33086
33111
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
33087
33112
|
applyLossy: true
|
|
33088
33113
|
});
|
|
@@ -33427,7 +33452,7 @@ function readPromotionEvidence(directory) {
|
|
|
33427
33452
|
}
|
|
33428
33453
|
|
|
33429
33454
|
// src/commands/epic.ts
|
|
33430
|
-
var
|
|
33455
|
+
var _internals45 = {
|
|
33431
33456
|
loadPluginConfigWithMeta,
|
|
33432
33457
|
loadPlanJsonOnly,
|
|
33433
33458
|
getCoChangeData,
|
|
@@ -33449,7 +33474,7 @@ async function handleEpicCommand(directory, args, sessionID) {
|
|
|
33449
33474
|
if (!sessionID || sessionID.trim() === "") {
|
|
33450
33475
|
return "Error: No active session context. Epic Mode requires an active session. Use /swarm epic from within an OpenCode session.";
|
|
33451
33476
|
}
|
|
33452
|
-
const session =
|
|
33477
|
+
const session = _internals45.ensureAgentSession(sessionID, undefined, directory);
|
|
33453
33478
|
const arg0 = args[0]?.toLowerCase();
|
|
33454
33479
|
switch (arg0) {
|
|
33455
33480
|
case "status":
|
|
@@ -33476,7 +33501,7 @@ Usage:
|
|
|
33476
33501
|
}
|
|
33477
33502
|
function enableAndAck(directory, sessionID, session) {
|
|
33478
33503
|
try {
|
|
33479
|
-
|
|
33504
|
+
_internals45.enableEpicMode(directory, sessionID);
|
|
33480
33505
|
} catch (err) {
|
|
33481
33506
|
return `Error enabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
33482
33507
|
}
|
|
@@ -33492,7 +33517,7 @@ function enableAndAck(directory, sessionID, session) {
|
|
|
33492
33517
|
}
|
|
33493
33518
|
function disableAndAck(directory, sessionID, session) {
|
|
33494
33519
|
try {
|
|
33495
|
-
|
|
33520
|
+
_internals45.disableEpicMode(directory, sessionID);
|
|
33496
33521
|
} catch (err) {
|
|
33497
33522
|
return `Error disabling Epic Mode: ${err instanceof Error ? err.message : String(err)}`;
|
|
33498
33523
|
}
|
|
@@ -33501,12 +33526,12 @@ function disableAndAck(directory, sessionID, session) {
|
|
|
33501
33526
|
}
|
|
33502
33527
|
function renderStatus(directory, sessionID) {
|
|
33503
33528
|
const lines = ["## Epic Mode \u2014 Status", ""];
|
|
33504
|
-
if (
|
|
33529
|
+
if (_internals45.isStateUnreadable(directory)) {
|
|
33505
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.");
|
|
33506
33531
|
return lines.join(`
|
|
33507
33532
|
`);
|
|
33508
33533
|
}
|
|
33509
|
-
const state =
|
|
33534
|
+
const state = _internals45.loadEpicSessionState(directory, sessionID);
|
|
33510
33535
|
if (!state) {
|
|
33511
33536
|
lines.push("Epic Mode has not been toggled for this session.");
|
|
33512
33537
|
return lines.join(`
|
|
@@ -33558,7 +33583,7 @@ function formatGreenfieldDetail(input) {
|
|
|
33558
33583
|
function renderLast(directory) {
|
|
33559
33584
|
let records;
|
|
33560
33585
|
try {
|
|
33561
|
-
records =
|
|
33586
|
+
records = _internals45.readPromotionEvidence(directory);
|
|
33562
33587
|
} catch (err) {
|
|
33563
33588
|
return `Error reading epic-promotions.jsonl: ${err instanceof Error ? err.message : String(err)}`;
|
|
33564
33589
|
}
|
|
@@ -33613,7 +33638,7 @@ function renderLast(directory) {
|
|
|
33613
33638
|
`);
|
|
33614
33639
|
}
|
|
33615
33640
|
function renderCalibration(directory) {
|
|
33616
|
-
if (
|
|
33641
|
+
if (_internals45.isCalibrationStateUnreadable(directory)) {
|
|
33617
33642
|
return [
|
|
33618
33643
|
"## Epic Mode \u2014 Calibration",
|
|
33619
33644
|
"",
|
|
@@ -33625,11 +33650,11 @@ function renderCalibration(directory) {
|
|
|
33625
33650
|
}
|
|
33626
33651
|
let state;
|
|
33627
33652
|
try {
|
|
33628
|
-
state =
|
|
33653
|
+
state = _internals45.loadCalibrationState(directory);
|
|
33629
33654
|
} catch (err) {
|
|
33630
33655
|
return `Error reading calibration state: ${err instanceof Error ? err.message : String(err)}`;
|
|
33631
33656
|
}
|
|
33632
|
-
const { config } =
|
|
33657
|
+
const { config } = _internals45.loadPluginConfigWithMeta(directory);
|
|
33633
33658
|
const staticThreshold = config.turbo?.epic?.mode?.activation_threshold ?? 0.3;
|
|
33634
33659
|
const calibrationCfg = config.turbo?.epic?.calibration;
|
|
33635
33660
|
const loosenWindow = calibrationCfg?.loosen_window ?? 10;
|
|
@@ -33677,7 +33702,7 @@ function renderCalibration(directory) {
|
|
|
33677
33702
|
lines.push("");
|
|
33678
33703
|
let recentDivergent = [];
|
|
33679
33704
|
try {
|
|
33680
|
-
const all =
|
|
33705
|
+
const all = _internals45.readDivergenceHistory(directory, { limit: 50 });
|
|
33681
33706
|
recentDivergent = all.filter((r) => !r.isClean).slice(-5);
|
|
33682
33707
|
} catch {}
|
|
33683
33708
|
lines.push("### Recent divergent tasks (tightened the threshold)");
|
|
@@ -33694,11 +33719,11 @@ function renderCalibration(directory) {
|
|
|
33694
33719
|
`);
|
|
33695
33720
|
}
|
|
33696
33721
|
async function renderDecide(directory) {
|
|
33697
|
-
const plan = await
|
|
33722
|
+
const plan = await _internals45.loadPlanJsonOnly(directory);
|
|
33698
33723
|
if (!plan) {
|
|
33699
33724
|
return "No plan found at `.swarm/plan.json`. Run `/swarm plan` first.";
|
|
33700
33725
|
}
|
|
33701
|
-
const { config } =
|
|
33726
|
+
const { config } = _internals45.loadPluginConfigWithMeta(directory);
|
|
33702
33727
|
const modeCfg = config.turbo?.epic?.mode;
|
|
33703
33728
|
const cochangeCfg = config.turbo?.epic?.cochange;
|
|
33704
33729
|
const activationThreshold = modeCfg?.activation_threshold ?? 0.3;
|
|
@@ -33708,20 +33733,20 @@ async function renderDecide(directory) {
|
|
|
33708
33733
|
const tasks = [];
|
|
33709
33734
|
for (const phase of plan.phases) {
|
|
33710
33735
|
for (const task of phase.tasks) {
|
|
33711
|
-
const scopeFiles =
|
|
33736
|
+
const scopeFiles = _internals45.readTaskScopes(directory, task.id);
|
|
33712
33737
|
const scope = scopeFiles ?? task.files_touched ?? [];
|
|
33713
33738
|
tasks.push({ id: task.id, scope });
|
|
33714
33739
|
}
|
|
33715
33740
|
}
|
|
33716
|
-
const { pairs, commitsObserved } = await
|
|
33741
|
+
const { pairs, commitsObserved } = await _internals45.getCoChangeData(directory);
|
|
33717
33742
|
const isGitProject = (() => {
|
|
33718
33743
|
try {
|
|
33719
|
-
return
|
|
33744
|
+
return _internals45.isGitRepo(directory);
|
|
33720
33745
|
} catch {
|
|
33721
33746
|
return false;
|
|
33722
33747
|
}
|
|
33723
33748
|
})();
|
|
33724
|
-
const verdict =
|
|
33749
|
+
const verdict = _internals45.decideEpicActivation(tasks, pairs, commitsObserved, {
|
|
33725
33750
|
activationThreshold,
|
|
33726
33751
|
minCommitsForSignal,
|
|
33727
33752
|
cochangeNpmiThreshold,
|
|
@@ -33765,7 +33790,7 @@ function formatVerdict(verdict) {
|
|
|
33765
33790
|
}
|
|
33766
33791
|
|
|
33767
33792
|
// src/services/evidence-service.ts
|
|
33768
|
-
var
|
|
33793
|
+
var _internals46 = {
|
|
33769
33794
|
loadEvidence,
|
|
33770
33795
|
listEvidenceTaskIds
|
|
33771
33796
|
};
|
|
@@ -33810,7 +33835,7 @@ function getVerdictEmoji(verdict) {
|
|
|
33810
33835
|
return getVerdictIcon(verdict);
|
|
33811
33836
|
}
|
|
33812
33837
|
async function getTaskEvidenceData(directory, taskId) {
|
|
33813
|
-
const result = await
|
|
33838
|
+
const result = await _internals46.loadEvidence(directory, taskId);
|
|
33814
33839
|
if (result.status !== "found") {
|
|
33815
33840
|
return {
|
|
33816
33841
|
hasEvidence: false,
|
|
@@ -33833,13 +33858,13 @@ async function getTaskEvidenceData(directory, taskId) {
|
|
|
33833
33858
|
};
|
|
33834
33859
|
}
|
|
33835
33860
|
async function getEvidenceListData(directory) {
|
|
33836
|
-
const taskIds = await
|
|
33861
|
+
const taskIds = await _internals46.listEvidenceTaskIds(directory);
|
|
33837
33862
|
if (taskIds.length === 0) {
|
|
33838
33863
|
return { hasEvidence: false, tasks: [] };
|
|
33839
33864
|
}
|
|
33840
33865
|
const tasks = [];
|
|
33841
33866
|
for (const taskId of taskIds) {
|
|
33842
|
-
const result = await
|
|
33867
|
+
const result = await _internals46.loadEvidence(directory, taskId);
|
|
33843
33868
|
if (result.status === "found") {
|
|
33844
33869
|
tasks.push({
|
|
33845
33870
|
taskId,
|
|
@@ -33919,7 +33944,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
33919
33944
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
33920
33945
|
}
|
|
33921
33946
|
async function handleEvidenceSummaryCommand(directory) {
|
|
33922
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
33947
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-kzxr71yd.js");
|
|
33923
33948
|
const artifact = await buildEvidenceSummary(directory);
|
|
33924
33949
|
if (!artifact) {
|
|
33925
33950
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -34275,7 +34300,7 @@ function isStaticallyEquivalent(originalCode, mutatedCode) {
|
|
|
34275
34300
|
const strippedMutated = stripCode(mutatedCode);
|
|
34276
34301
|
return strippedOriginal === strippedMutated;
|
|
34277
34302
|
}
|
|
34278
|
-
var
|
|
34303
|
+
var _internals47 = {
|
|
34279
34304
|
isStaticallyEquivalent,
|
|
34280
34305
|
checkEquivalence,
|
|
34281
34306
|
batchCheckEquivalence
|
|
@@ -34315,7 +34340,7 @@ async function batchCheckEquivalence(patches, llmJudge) {
|
|
|
34315
34340
|
const results = [];
|
|
34316
34341
|
for (const { patch, originalCode, mutatedCode } of patches) {
|
|
34317
34342
|
try {
|
|
34318
|
-
const result = await
|
|
34343
|
+
const result = await _internals47.checkEquivalence(patch, originalCode, mutatedCode, llmJudge);
|
|
34319
34344
|
results.push(result);
|
|
34320
34345
|
} catch (err) {
|
|
34321
34346
|
results.push({
|
|
@@ -34389,10 +34414,10 @@ function isMissingExecutableFailure(message) {
|
|
|
34389
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);
|
|
34390
34415
|
}
|
|
34391
34416
|
var runMutationCommand = async (args) => {
|
|
34392
|
-
const resolvedExecutable =
|
|
34417
|
+
const resolvedExecutable = _internals48.resolveExecutableFromPath([
|
|
34393
34418
|
args.executable
|
|
34394
34419
|
]);
|
|
34395
|
-
const result = await
|
|
34420
|
+
const result = await _internals48.runExternalTool({
|
|
34396
34421
|
executable: resolvedExecutable ?? args.executable,
|
|
34397
34422
|
args: args.args,
|
|
34398
34423
|
cwd: args.cwd,
|
|
@@ -34411,7 +34436,7 @@ var runMutationCommand = async (args) => {
|
|
|
34411
34436
|
};
|
|
34412
34437
|
var runLegacyTestSeam = async (args) => {
|
|
34413
34438
|
try {
|
|
34414
|
-
const result =
|
|
34439
|
+
const result = _internals48.spawnSync(args.executable, args.args, {
|
|
34415
34440
|
cwd: args.cwd,
|
|
34416
34441
|
timeout: args.timeoutMs,
|
|
34417
34442
|
stdio: "pipe"
|
|
@@ -34445,11 +34470,11 @@ var runLegacyTestSeam = async (args) => {
|
|
|
34445
34470
|
function selectRunner(options) {
|
|
34446
34471
|
if (options.runner)
|
|
34447
34472
|
return options.runner;
|
|
34448
|
-
if (
|
|
34473
|
+
if (_internals48.spawnSync !== defaultLegacySpawnSync)
|
|
34449
34474
|
return runLegacyTestSeam;
|
|
34450
|
-
return
|
|
34475
|
+
return _internals48.runCommand;
|
|
34451
34476
|
}
|
|
34452
|
-
var
|
|
34477
|
+
var _internals48 = {
|
|
34453
34478
|
executeMutation,
|
|
34454
34479
|
computeReport,
|
|
34455
34480
|
executeMutationSuite,
|
|
@@ -35693,11 +35718,11 @@ var quality_budget = createSwarmTool({
|
|
|
35693
35718
|
}).optional().describe("Quality budget thresholds")
|
|
35694
35719
|
},
|
|
35695
35720
|
async execute(args, directory) {
|
|
35696
|
-
const result = await
|
|
35721
|
+
const result = await _internals49.qualityBudget(args, directory);
|
|
35697
35722
|
return JSON.stringify(result);
|
|
35698
35723
|
}
|
|
35699
35724
|
});
|
|
35700
|
-
var
|
|
35725
|
+
var _internals49 = {
|
|
35701
35726
|
qualityBudget
|
|
35702
35727
|
};
|
|
35703
35728
|
|
|
@@ -36566,7 +36591,7 @@ var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
|
|
|
36566
36591
|
var DEFAULT_TIMEOUT_MS2 = 30000;
|
|
36567
36592
|
var MAX_OUTPUT_BYTES = 10 * 1024 * 1024;
|
|
36568
36593
|
var KILL_GRACE_MS = 2000;
|
|
36569
|
-
var
|
|
36594
|
+
var _internals50 = {
|
|
36570
36595
|
isSemgrepAvailable,
|
|
36571
36596
|
checkSemgrepAvailable,
|
|
36572
36597
|
resetSemgrepCache,
|
|
@@ -36592,7 +36617,7 @@ function isSemgrepAvailable() {
|
|
|
36592
36617
|
}
|
|
36593
36618
|
}
|
|
36594
36619
|
async function checkSemgrepAvailable() {
|
|
36595
|
-
return
|
|
36620
|
+
return _internals50.isSemgrepAvailable();
|
|
36596
36621
|
}
|
|
36597
36622
|
function resetSemgrepCache() {
|
|
36598
36623
|
semgrepAvailableCache = null;
|
|
@@ -36779,12 +36804,12 @@ async function runSemgrep(options) {
|
|
|
36779
36804
|
const timeoutMs = options.timeoutMs || DEFAULT_TIMEOUT_MS2;
|
|
36780
36805
|
if (files.length === 0) {
|
|
36781
36806
|
return {
|
|
36782
|
-
available:
|
|
36807
|
+
available: _internals50.isSemgrepAvailable(),
|
|
36783
36808
|
findings: [],
|
|
36784
36809
|
engine: "tier_a"
|
|
36785
36810
|
};
|
|
36786
36811
|
}
|
|
36787
|
-
if (!
|
|
36812
|
+
if (!_internals50.isSemgrepAvailable()) {
|
|
36788
36813
|
return {
|
|
36789
36814
|
available: false,
|
|
36790
36815
|
findings: [],
|
|
@@ -36946,7 +36971,7 @@ function assignOccurrenceIndices(findings, directory) {
|
|
|
36946
36971
|
}
|
|
36947
36972
|
const occIdx = countMap.get(baseKey) ?? 0;
|
|
36948
36973
|
countMap.set(baseKey, occIdx + 1);
|
|
36949
|
-
const fp =
|
|
36974
|
+
const fp = _internals51.fingerprintFinding(finding, directory, occIdx);
|
|
36950
36975
|
return {
|
|
36951
36976
|
finding,
|
|
36952
36977
|
index: occIdx,
|
|
@@ -36960,6 +36985,7 @@ async function acquireLock2(lockPath) {
|
|
|
36960
36985
|
try {
|
|
36961
36986
|
const fd = fs25.openSync(lockPath, "wx");
|
|
36962
36987
|
fs25.closeSync(fd);
|
|
36988
|
+
invalidateCachedArtifact(lockPath);
|
|
36963
36989
|
return () => {
|
|
36964
36990
|
try {
|
|
36965
36991
|
fs25.unlinkSync(lockPath);
|
|
@@ -37015,7 +37041,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
37015
37041
|
}
|
|
37016
37042
|
} catch {}
|
|
37017
37043
|
const scannedRelFiles = new Set(scannedFiles.map((f) => normalizeFindingPath(directory, f)));
|
|
37018
|
-
const indexed =
|
|
37044
|
+
const indexed = _internals51.assignOccurrenceIndices(findings, directory);
|
|
37019
37045
|
if (existing && !opts?.force) {
|
|
37020
37046
|
const prunedFingerprints = existing.fingerprints.filter((fp) => {
|
|
37021
37047
|
const relFile = fp.slice(0, fp.indexOf("|"));
|
|
@@ -37070,6 +37096,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
37070
37096
|
}
|
|
37071
37097
|
fs25.writeFileSync(tempPath, json2, "utf-8");
|
|
37072
37098
|
fs25.renameSync(tempPath, baselinePath);
|
|
37099
|
+
invalidateCachedArtifact(baselinePath);
|
|
37073
37100
|
return {
|
|
37074
37101
|
status: "merged",
|
|
37075
37102
|
path: baselinePath,
|
|
@@ -37102,6 +37129,7 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
|
|
|
37102
37129
|
}
|
|
37103
37130
|
fs25.writeFileSync(tempPath, json, "utf-8");
|
|
37104
37131
|
fs25.renameSync(tempPath, baselinePath);
|
|
37132
|
+
invalidateCachedArtifact(baselinePath);
|
|
37105
37133
|
return {
|
|
37106
37134
|
status: "written",
|
|
37107
37135
|
path: baselinePath,
|
|
@@ -37155,7 +37183,7 @@ function loadBaseline(directory, phase) {
|
|
|
37155
37183
|
};
|
|
37156
37184
|
}
|
|
37157
37185
|
}
|
|
37158
|
-
var
|
|
37186
|
+
var _internals51 = {
|
|
37159
37187
|
fingerprintFinding,
|
|
37160
37188
|
assignOccurrenceIndices,
|
|
37161
37189
|
captureOrMergeBaseline,
|
|
@@ -37269,7 +37297,7 @@ async function sastScan(input, directory, config) {
|
|
|
37269
37297
|
let filesScanned = 0;
|
|
37270
37298
|
let _filesSkipped = 0;
|
|
37271
37299
|
const scannedFilePaths = [];
|
|
37272
|
-
const semgrepAvailable = !offline_only &&
|
|
37300
|
+
const semgrepAvailable = !offline_only && _internals52.isSemgrepAvailable();
|
|
37273
37301
|
const engine = semgrepAvailable ? "tier_a+tier_b" : "tier_a";
|
|
37274
37302
|
const filesByLanguage = new Map;
|
|
37275
37303
|
for (const filePath of changed_files) {
|
|
@@ -37332,13 +37360,13 @@ async function sastScan(input, directory, config) {
|
|
|
37332
37360
|
let semgrepResult;
|
|
37333
37361
|
if (bucketKey.startsWith("auto:")) {
|
|
37334
37362
|
const lang = bucketKey.slice("auto:".length);
|
|
37335
|
-
semgrepResult = await
|
|
37363
|
+
semgrepResult = await _internals52.runSemgrep({
|
|
37336
37364
|
files: bucketFiles,
|
|
37337
37365
|
lang,
|
|
37338
37366
|
useAutoConfig: true
|
|
37339
37367
|
});
|
|
37340
37368
|
} else {
|
|
37341
|
-
semgrepResult = await
|
|
37369
|
+
semgrepResult = await _internals52.runSemgrep({
|
|
37342
37370
|
files: bucketFiles
|
|
37343
37371
|
});
|
|
37344
37372
|
}
|
|
@@ -37580,11 +37608,11 @@ var sast_scan = createSwarmTool({
|
|
|
37580
37608
|
capture_baseline: safeArgs.capture_baseline,
|
|
37581
37609
|
phase: safeArgs.phase
|
|
37582
37610
|
};
|
|
37583
|
-
const result = await
|
|
37611
|
+
const result = await _internals52.sastScan(input, directory);
|
|
37584
37612
|
return JSON.stringify(result, null, 2);
|
|
37585
37613
|
}
|
|
37586
37614
|
});
|
|
37587
|
-
var
|
|
37615
|
+
var _internals52 = {
|
|
37588
37616
|
sastScan,
|
|
37589
37617
|
sast_scan,
|
|
37590
37618
|
isSemgrepAvailable: () => isSemgrepAvailable(),
|
|
@@ -38415,7 +38443,7 @@ function extractCurrentPhaseFromPlan2(plan) {
|
|
|
38415
38443
|
if (!plan) {
|
|
38416
38444
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
38417
38445
|
}
|
|
38418
|
-
if (!
|
|
38446
|
+
if (!_internals53.validatePlanPhases(plan)) {
|
|
38419
38447
|
return { currentPhase: null, currentTask: null, incompleteTasks: [] };
|
|
38420
38448
|
}
|
|
38421
38449
|
let currentPhase = null;
|
|
@@ -38557,9 +38585,9 @@ function extractPhaseMetrics(content) {
|
|
|
38557
38585
|
async function getHandoffData(directory) {
|
|
38558
38586
|
const now = new Date().toISOString();
|
|
38559
38587
|
const sessionContent = await readSwarmFileAsync(directory, "session/state.json");
|
|
38560
|
-
const sessionState =
|
|
38588
|
+
const sessionState = _internals53.parseSessionState(sessionContent);
|
|
38561
38589
|
const plan = await loadPlanJsonOnly(directory);
|
|
38562
|
-
const planInfo =
|
|
38590
|
+
const planInfo = _internals53.extractCurrentPhaseFromPlan(plan);
|
|
38563
38591
|
if (!plan) {
|
|
38564
38592
|
const planMdContent = await readSwarmFileAsync(directory, "plan.md");
|
|
38565
38593
|
if (planMdContent) {
|
|
@@ -38578,8 +38606,8 @@ async function getHandoffData(directory) {
|
|
|
38578
38606
|
}
|
|
38579
38607
|
}
|
|
38580
38608
|
const contextContent = await readSwarmFileAsync(directory, "context.md");
|
|
38581
|
-
const recentDecisions =
|
|
38582
|
-
const rawPhaseMetrics =
|
|
38609
|
+
const recentDecisions = _internals53.extractDecisions(contextContent);
|
|
38610
|
+
const rawPhaseMetrics = _internals53.extractPhaseMetrics(contextContent);
|
|
38583
38611
|
const phaseMetrics = sanitizeString(rawPhaseMetrics, 1000);
|
|
38584
38612
|
let delegationState = null;
|
|
38585
38613
|
if (sessionState?.delegationState) {
|
|
@@ -38743,7 +38771,7 @@ ${lines.join(`
|
|
|
38743
38771
|
`)}
|
|
38744
38772
|
\`\`\``;
|
|
38745
38773
|
}
|
|
38746
|
-
var
|
|
38774
|
+
var _internals53 = {
|
|
38747
38775
|
getHandoffData,
|
|
38748
38776
|
formatHandoffMarkdown,
|
|
38749
38777
|
formatContinuationPrompt,
|
|
@@ -38902,6 +38930,7 @@ async function writeSnapshot(directory, state) {
|
|
|
38902
38930
|
}
|
|
38903
38931
|
} catch {}
|
|
38904
38932
|
renameSync12(tempPath, resolvedPath);
|
|
38933
|
+
invalidateCachedArtifact(resolvedPath);
|
|
38905
38934
|
} catch (error2) {
|
|
38906
38935
|
log("[snapshot-writer] write failed", {
|
|
38907
38936
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
@@ -38910,15 +38939,15 @@ async function writeSnapshot(directory, state) {
|
|
|
38910
38939
|
}
|
|
38911
38940
|
function createSnapshotWriterHook(directory) {
|
|
38912
38941
|
return (_input, _output) => {
|
|
38913
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
38942
|
+
_writeInFlight = _writeInFlight.then(() => _internals54.writeSnapshot(directory, swarmState), () => _internals54.writeSnapshot(directory, swarmState));
|
|
38914
38943
|
return _writeInFlight;
|
|
38915
38944
|
};
|
|
38916
38945
|
}
|
|
38917
38946
|
async function flushPendingSnapshot(directory) {
|
|
38918
|
-
_writeInFlight = _writeInFlight.then(() =>
|
|
38947
|
+
_writeInFlight = _writeInFlight.then(() => _internals54.writeSnapshot(directory, swarmState), () => _internals54.writeSnapshot(directory, swarmState));
|
|
38919
38948
|
await _writeInFlight;
|
|
38920
38949
|
}
|
|
38921
|
-
var
|
|
38950
|
+
var _internals54 = {
|
|
38922
38951
|
writeSnapshot,
|
|
38923
38952
|
createSnapshotWriterHook,
|
|
38924
38953
|
flushPendingSnapshot
|
|
@@ -38948,6 +38977,7 @@ async function handleHandoffCommand(directory, _args, sessionID) {
|
|
|
38948
38977
|
} catch {}
|
|
38949
38978
|
throw renameErr;
|
|
38950
38979
|
}
|
|
38980
|
+
invalidateCachedArtifact(resolvedPath);
|
|
38951
38981
|
const continuationPrompt = formatContinuationPrompt(handoffData);
|
|
38952
38982
|
const promptPath = validateSwarmPath(directory, "handoff-prompt.md");
|
|
38953
38983
|
const promptTempPath = `${promptPath}.tmp.${crypto5.randomUUID()}`;
|
|
@@ -39203,7 +39233,7 @@ function parseIssueRef(input, directory) {
|
|
|
39203
39233
|
}
|
|
39204
39234
|
return null;
|
|
39205
39235
|
}
|
|
39206
|
-
var
|
|
39236
|
+
var _internals55 = {
|
|
39207
39237
|
writeFileSync: fs28.writeFileSync,
|
|
39208
39238
|
mkdirSync: fs28.mkdirSync,
|
|
39209
39239
|
renameSync: fs28.renameSync,
|
|
@@ -39214,18 +39244,18 @@ var _internals54 = {
|
|
|
39214
39244
|
function atomicWriteFileSync(dir, filename, content) {
|
|
39215
39245
|
const tmpPath = path67.join(dir, `.tmp-${filename}-${Date.now()}-${process.pid}`);
|
|
39216
39246
|
const finalPath = path67.join(dir, filename);
|
|
39217
|
-
|
|
39247
|
+
_internals55.writeFileSync(tmpPath, content, "utf-8");
|
|
39218
39248
|
try {
|
|
39219
|
-
|
|
39249
|
+
_internals55.renameSync(tmpPath, finalPath);
|
|
39220
39250
|
} catch {
|
|
39221
39251
|
try {
|
|
39222
|
-
|
|
39252
|
+
_internals55.unlinkSync(finalPath);
|
|
39223
39253
|
} catch {}
|
|
39224
39254
|
try {
|
|
39225
|
-
|
|
39255
|
+
_internals55.renameSync(tmpPath, finalPath);
|
|
39226
39256
|
} catch (retryErr) {
|
|
39227
39257
|
try {
|
|
39228
|
-
|
|
39258
|
+
_internals55.unlinkSync(tmpPath);
|
|
39229
39259
|
} catch {}
|
|
39230
39260
|
throw retryErr;
|
|
39231
39261
|
}
|
|
@@ -39278,10 +39308,10 @@ ${USAGE9}`;
|
|
|
39278
39308
|
};
|
|
39279
39309
|
let oldTraceState = null;
|
|
39280
39310
|
try {
|
|
39281
|
-
oldTraceState =
|
|
39311
|
+
oldTraceState = _internals55.readFileSync(path67.join(swarmDir, "issue-trace-state.json"), "utf-8");
|
|
39282
39312
|
} catch {}
|
|
39283
39313
|
try {
|
|
39284
|
-
|
|
39314
|
+
_internals55.mkdirSync(swarmDir, { recursive: true });
|
|
39285
39315
|
atomicWriteFileSync(swarmDir, "issue-trace-state.json", JSON.stringify(traceState, null, 2));
|
|
39286
39316
|
atomicWriteFileSync(swarmDir, "issue-reference.json", JSON.stringify(issueReference, null, 2));
|
|
39287
39317
|
} catch (e) {
|
|
@@ -39291,11 +39321,11 @@ ${USAGE9}`;
|
|
|
39291
39321
|
} catch {}
|
|
39292
39322
|
} else {
|
|
39293
39323
|
try {
|
|
39294
|
-
|
|
39324
|
+
_internals55.unlinkSync(path67.join(swarmDir, "issue-trace-state.json"));
|
|
39295
39325
|
} catch {}
|
|
39296
39326
|
}
|
|
39297
39327
|
try {
|
|
39298
|
-
|
|
39328
|
+
_internals55.unlinkSync(path67.join(swarmDir, "issue-reference.json"));
|
|
39299
39329
|
} catch {}
|
|
39300
39330
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
39301
39331
|
return `Error: Failed to persist issue reference durably: ${errMsg}
|
|
@@ -39328,7 +39358,7 @@ init_knowledge_types();
|
|
|
39328
39358
|
async function migrateKnowledgeToExternal(_directory, _config) {
|
|
39329
39359
|
const externalSentinelPath = path68.join(_directory, ".swarm", ".knowledge-external-migrated");
|
|
39330
39360
|
const contextPath = path68.join(_directory, ".swarm", "context.md");
|
|
39331
|
-
if (
|
|
39361
|
+
if (_internals56.existsSync(externalSentinelPath)) {
|
|
39332
39362
|
return {
|
|
39333
39363
|
migrated: false,
|
|
39334
39364
|
entriesMigrated: 0,
|
|
@@ -39337,7 +39367,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39337
39367
|
skippedReason: "external-sentinel-exists"
|
|
39338
39368
|
};
|
|
39339
39369
|
}
|
|
39340
|
-
if (!
|
|
39370
|
+
if (!_internals56.existsSync(contextPath)) {
|
|
39341
39371
|
return {
|
|
39342
39372
|
migrated: false,
|
|
39343
39373
|
entriesMigrated: 0,
|
|
@@ -39346,7 +39376,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39346
39376
|
skippedReason: "no-context-file"
|
|
39347
39377
|
};
|
|
39348
39378
|
}
|
|
39349
|
-
const contextContent = await
|
|
39379
|
+
const contextContent = await _internals56.readFile(contextPath, "utf-8");
|
|
39350
39380
|
if (contextContent.trim().length === 0) {
|
|
39351
39381
|
return {
|
|
39352
39382
|
migrated: false,
|
|
@@ -39364,7 +39394,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39364
39394
|
entriesCount++;
|
|
39365
39395
|
}
|
|
39366
39396
|
}
|
|
39367
|
-
await
|
|
39397
|
+
await _internals56.writeSentinel(externalSentinelPath, entriesCount, entriesCount);
|
|
39368
39398
|
return {
|
|
39369
39399
|
migrated: true,
|
|
39370
39400
|
entriesMigrated: entriesCount,
|
|
@@ -39372,7 +39402,7 @@ async function migrateKnowledgeToExternal(_directory, _config) {
|
|
|
39372
39402
|
entriesTotal: entriesCount
|
|
39373
39403
|
};
|
|
39374
39404
|
}
|
|
39375
|
-
var
|
|
39405
|
+
var _internals56 = {
|
|
39376
39406
|
appendKnowledge,
|
|
39377
39407
|
migrateContextToKnowledge,
|
|
39378
39408
|
migrateKnowledgeToExternal,
|
|
@@ -39423,9 +39453,9 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39423
39453
|
skippedReason: "empty-context"
|
|
39424
39454
|
};
|
|
39425
39455
|
}
|
|
39426
|
-
const rawEntries =
|
|
39456
|
+
const rawEntries = _internals56.parseContextMd(contextContent);
|
|
39427
39457
|
if (rawEntries.length === 0) {
|
|
39428
|
-
await
|
|
39458
|
+
await _internals56.writeSentinel(sentinelPath, 0, 0);
|
|
39429
39459
|
return {
|
|
39430
39460
|
migrated: true,
|
|
39431
39461
|
entriesMigrated: 0,
|
|
@@ -39436,10 +39466,10 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39436
39466
|
const existing = await readKnowledge(knowledgePath);
|
|
39437
39467
|
let migrated = 0;
|
|
39438
39468
|
let dropped = 0;
|
|
39439
|
-
const projectName =
|
|
39469
|
+
const projectName = _internals56.inferProjectName(directory);
|
|
39440
39470
|
for (const raw of rawEntries) {
|
|
39441
39471
|
if (config.validation_enabled !== false) {
|
|
39442
|
-
const category = raw.categoryHint ??
|
|
39472
|
+
const category = raw.categoryHint ?? _internals56.inferCategoryFromText(raw.text);
|
|
39443
39473
|
const result = validateLesson(raw.text, existing.map((e) => e.lesson), {
|
|
39444
39474
|
category,
|
|
39445
39475
|
scope: "global",
|
|
@@ -39459,8 +39489,8 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39459
39489
|
const entry = {
|
|
39460
39490
|
id: randomUUID8(),
|
|
39461
39491
|
tier: "swarm",
|
|
39462
|
-
lesson:
|
|
39463
|
-
category: raw.categoryHint ??
|
|
39492
|
+
lesson: _internals56.truncateLesson(raw.text),
|
|
39493
|
+
category: raw.categoryHint ?? _internals56.inferCategoryFromText(raw.text),
|
|
39464
39494
|
tags: [...inferredTags, `migration:${raw.sourceSection}`],
|
|
39465
39495
|
scope: "global",
|
|
39466
39496
|
confidence: 0.3,
|
|
@@ -39483,7 +39513,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39483
39513
|
if (migrated > 0) {
|
|
39484
39514
|
await rewriteKnowledge(knowledgePath, existing);
|
|
39485
39515
|
}
|
|
39486
|
-
await
|
|
39516
|
+
await _internals56.writeSentinel(sentinelPath, migrated, dropped);
|
|
39487
39517
|
log(`[knowledge-migrator] Migrated ${migrated} entries, dropped ${dropped}`);
|
|
39488
39518
|
return {
|
|
39489
39519
|
migrated: true,
|
|
@@ -39493,7 +39523,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
39493
39523
|
};
|
|
39494
39524
|
}
|
|
39495
39525
|
async function migrateHiveKnowledgeLegacy(config) {
|
|
39496
|
-
const legacyHivePath =
|
|
39526
|
+
const legacyHivePath = _internals56.resolveLegacyHiveKnowledgePath();
|
|
39497
39527
|
const canonicalHivePath = resolveHiveKnowledgePath2();
|
|
39498
39528
|
const sentinelPath = path68.join(path68.dirname(canonicalHivePath), ".hive-knowledge-migrated");
|
|
39499
39529
|
if (existsSync39(sentinelPath)) {
|
|
@@ -39516,7 +39546,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39516
39546
|
}
|
|
39517
39547
|
const legacyEntries = await readKnowledge(legacyHivePath);
|
|
39518
39548
|
if (legacyEntries.length === 0) {
|
|
39519
|
-
await
|
|
39549
|
+
await _internals56.writeSentinel(sentinelPath, 0, 0);
|
|
39520
39550
|
return {
|
|
39521
39551
|
migrated: true,
|
|
39522
39552
|
entriesMigrated: 0,
|
|
@@ -39564,7 +39594,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39564
39594
|
const newHiveEntry = {
|
|
39565
39595
|
id: resolvedId,
|
|
39566
39596
|
tier: "hive",
|
|
39567
|
-
lesson:
|
|
39597
|
+
lesson: _internals56.truncateLesson(lesson),
|
|
39568
39598
|
category,
|
|
39569
39599
|
tags: ["migration:legacy-hive"],
|
|
39570
39600
|
scope: scopeTag,
|
|
@@ -39583,7 +39613,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39583
39613
|
encounter_score: 1
|
|
39584
39614
|
};
|
|
39585
39615
|
try {
|
|
39586
|
-
await
|
|
39616
|
+
await _internals56.appendKnowledge(canonicalHivePath, newHiveEntry);
|
|
39587
39617
|
existingHiveEntries.push(newHiveEntry);
|
|
39588
39618
|
migrated++;
|
|
39589
39619
|
} catch (appendError) {
|
|
@@ -39599,7 +39629,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39599
39629
|
dropped++;
|
|
39600
39630
|
}
|
|
39601
39631
|
}
|
|
39602
|
-
await
|
|
39632
|
+
await _internals56.writeSentinel(sentinelPath, migrated, dropped);
|
|
39603
39633
|
log(`[knowledge-migrator] Migrated ${migrated} legacy hive entries, dropped ${dropped}`);
|
|
39604
39634
|
return {
|
|
39605
39635
|
migrated: true,
|
|
@@ -39610,7 +39640,7 @@ async function migrateHiveKnowledgeLegacy(config) {
|
|
|
39610
39640
|
};
|
|
39611
39641
|
}
|
|
39612
39642
|
function parseContextMd(content) {
|
|
39613
|
-
const sections =
|
|
39643
|
+
const sections = _internals56.splitIntoSections(content);
|
|
39614
39644
|
const entries = [];
|
|
39615
39645
|
const seen = new Set;
|
|
39616
39646
|
const sectionPatterns = [
|
|
@@ -39626,7 +39656,7 @@ function parseContextMd(content) {
|
|
|
39626
39656
|
const match = sectionPatterns.find((sp) => sp.pattern.test(section.heading));
|
|
39627
39657
|
if (!match)
|
|
39628
39658
|
continue;
|
|
39629
|
-
const bullets =
|
|
39659
|
+
const bullets = _internals56.extractBullets(section.body);
|
|
39630
39660
|
for (const bullet of bullets) {
|
|
39631
39661
|
if (bullet.length < 15)
|
|
39632
39662
|
continue;
|
|
@@ -39635,9 +39665,9 @@ function parseContextMd(content) {
|
|
|
39635
39665
|
continue;
|
|
39636
39666
|
seen.add(normalized);
|
|
39637
39667
|
entries.push({
|
|
39638
|
-
text:
|
|
39668
|
+
text: _internals56.truncateLesson(bullet),
|
|
39639
39669
|
sourceSection: match.sourceSection,
|
|
39640
|
-
categoryHint:
|
|
39670
|
+
categoryHint: _internals56.inferCategoryFromText(bullet)
|
|
39641
39671
|
});
|
|
39642
39672
|
}
|
|
39643
39673
|
}
|
|
@@ -39727,8 +39757,8 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
|
|
|
39727
39757
|
schema_version: 1,
|
|
39728
39758
|
migration_tool: "knowledge-migrator.ts"
|
|
39729
39759
|
};
|
|
39730
|
-
await
|
|
39731
|
-
await
|
|
39760
|
+
await _internals56.mkdir(path68.dirname(sentinelPath), { recursive: true });
|
|
39761
|
+
await _internals56.writeFile(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
|
|
39732
39762
|
}
|
|
39733
39763
|
function resolveLegacyHiveKnowledgePath() {
|
|
39734
39764
|
const platform = process.platform;
|
|
@@ -40140,7 +40170,7 @@ function timeoutMessage(timeoutMs) {
|
|
|
40140
40170
|
async function computeWithTimeout(directory, currentPhase, timeoutMs) {
|
|
40141
40171
|
const controller = new AbortController;
|
|
40142
40172
|
let timeout;
|
|
40143
|
-
const metricsPromise =
|
|
40173
|
+
const metricsPromise = _internals57.computeLearningMetrics(directory, {
|
|
40144
40174
|
currentPhase,
|
|
40145
40175
|
signal: controller.signal
|
|
40146
40176
|
});
|
|
@@ -40197,7 +40227,7 @@ ${JSON.stringify({
|
|
|
40197
40227
|
return `Error computing learning metrics: ${message}. Run /swarm diagnose to check .swarm/ health.`;
|
|
40198
40228
|
}
|
|
40199
40229
|
}
|
|
40200
|
-
var
|
|
40230
|
+
var _internals57 = {
|
|
40201
40231
|
computeLearningMetrics
|
|
40202
40232
|
};
|
|
40203
40233
|
|
|
@@ -40718,7 +40748,7 @@ async function readLatestLoopState(directory) {
|
|
|
40718
40748
|
return null;
|
|
40719
40749
|
}
|
|
40720
40750
|
}
|
|
40721
|
-
var
|
|
40751
|
+
var _internals58 = {
|
|
40722
40752
|
readLatestLoopState
|
|
40723
40753
|
};
|
|
40724
40754
|
var USAGE10 = `Usage: /swarm loop <objective> [--max-cycles 1..5] [--autonomy checkpoint|auto] [--depth standard|exhaustive] [--resume]
|
|
@@ -40831,7 +40861,7 @@ ${USAGE10}`;
|
|
|
40831
40861
|
}
|
|
40832
40862
|
let autonomy = parsed.autonomy;
|
|
40833
40863
|
if (parsed.resume && !parsed.autonomyExplicit) {
|
|
40834
|
-
const state = await
|
|
40864
|
+
const state = await _internals58.readLatestLoopState(_directory);
|
|
40835
40865
|
if (state?.autonomy && AUTONOMY_LEVELS.has(state.autonomy)) {
|
|
40836
40866
|
autonomy = state.autonomy;
|
|
40837
40867
|
}
|
|
@@ -42385,15 +42415,15 @@ async function handleMemoryUnlinkCommand(directory, args) {
|
|
|
42385
42415
|
}
|
|
42386
42416
|
|
|
42387
42417
|
// src/services/plan-service.ts
|
|
42388
|
-
var
|
|
42418
|
+
var _internals59 = {
|
|
42389
42419
|
loadPlanJsonOnly,
|
|
42390
42420
|
derivePlanMarkdown,
|
|
42391
42421
|
readSwarmFileAsync
|
|
42392
42422
|
};
|
|
42393
42423
|
async function getPlanData(directory, phaseArg) {
|
|
42394
|
-
const plan = await
|
|
42424
|
+
const plan = await _internals59.loadPlanJsonOnly(directory);
|
|
42395
42425
|
if (plan) {
|
|
42396
|
-
const fullMarkdown =
|
|
42426
|
+
const fullMarkdown = _internals59.derivePlanMarkdown(plan);
|
|
42397
42427
|
if (phaseArg === undefined || phaseArg === null || phaseArg === "") {
|
|
42398
42428
|
return {
|
|
42399
42429
|
hasPlan: true,
|
|
@@ -42436,7 +42466,7 @@ async function getPlanData(directory, phaseArg) {
|
|
|
42436
42466
|
isLegacy: false
|
|
42437
42467
|
};
|
|
42438
42468
|
}
|
|
42439
|
-
const planContent = await
|
|
42469
|
+
const planContent = await _internals59.readSwarmFileAsync(directory, "plan.md");
|
|
42440
42470
|
if (!planContent) {
|
|
42441
42471
|
return {
|
|
42442
42472
|
hasPlan: false,
|
|
@@ -42533,7 +42563,7 @@ async function handlePlanCommand(directory, args) {
|
|
|
42533
42563
|
return formatPlanMarkdown(planData);
|
|
42534
42564
|
}
|
|
42535
42565
|
// src/commands/post-mortem.ts
|
|
42536
|
-
var
|
|
42566
|
+
var _internals60 = {
|
|
42537
42567
|
createCuratorLLMDelegate,
|
|
42538
42568
|
runCuratorPostMortem
|
|
42539
42569
|
};
|
|
@@ -42581,10 +42611,10 @@ async function handlePostMortemCommand(directory, args, options) {
|
|
|
42581
42611
|
};
|
|
42582
42612
|
if (options?.sessionID) {
|
|
42583
42613
|
try {
|
|
42584
|
-
pmOptions.llmDelegate =
|
|
42614
|
+
pmOptions.llmDelegate = _internals60.createCuratorLLMDelegate(directory, "postmortem", options.sessionID);
|
|
42585
42615
|
} catch {}
|
|
42586
42616
|
}
|
|
42587
|
-
const result = await
|
|
42617
|
+
const result = await _internals60.runCuratorPostMortem(directory, pmOptions);
|
|
42588
42618
|
const lines = [];
|
|
42589
42619
|
if (result.success) {
|
|
42590
42620
|
lines.push("## Post-Mortem Report Generated");
|
|
@@ -42842,7 +42872,7 @@ function formatMergeGroupStatus(status, conclusion, htmlUrl) {
|
|
|
42842
42872
|
}
|
|
42843
42873
|
return parts.join(" ");
|
|
42844
42874
|
}
|
|
42845
|
-
var
|
|
42875
|
+
var _internals61 = {
|
|
42846
42876
|
formatRelativeTime,
|
|
42847
42877
|
formatMergeGroupStatus,
|
|
42848
42878
|
listActive,
|
|
@@ -42850,7 +42880,7 @@ var _internals60 = {
|
|
|
42850
42880
|
parseMergeGroupRuns
|
|
42851
42881
|
};
|
|
42852
42882
|
async function handlePrMonitorStatusCommand(directory, _args, sessionID, source) {
|
|
42853
|
-
const allActive = await
|
|
42883
|
+
const allActive = await _internals61.listActive(directory);
|
|
42854
42884
|
const allSessions = source === "cli";
|
|
42855
42885
|
const subs = allSessions ? allActive : allActive.filter((record) => record.sessionID === sessionID);
|
|
42856
42886
|
if (subs.length === 0) {
|
|
@@ -42866,7 +42896,7 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID, source)
|
|
|
42866
42896
|
const index = i + 1;
|
|
42867
42897
|
lines.push(` ${index}. ${sub.repoFullName}#${sub.prNumber}`);
|
|
42868
42898
|
lines.push(` URL: ${sub.prUrl}`);
|
|
42869
|
-
const mergeGroupRuns = await
|
|
42899
|
+
const mergeGroupRuns = await _internals61.listMergeGroupRuns(directory, sub.repoFullName, sub.prNumber);
|
|
42870
42900
|
if (mergeGroupRuns.runs.length > 0) {
|
|
42871
42901
|
lines.push(" Merge-group runs:");
|
|
42872
42902
|
for (const run of mergeGroupRuns.runs) {
|
|
@@ -43007,7 +43037,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
43007
43037
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
43008
43038
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
43009
43039
|
try {
|
|
43010
|
-
const config =
|
|
43040
|
+
const config = _internals62.loadPluginConfig(directory);
|
|
43011
43041
|
const prMonitorConfig = config.pr_monitor;
|
|
43012
43042
|
if (!prMonitorConfig?.enabled) {
|
|
43013
43043
|
return [
|
|
@@ -43017,7 +43047,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
43017
43047
|
].join(`
|
|
43018
43048
|
`);
|
|
43019
43049
|
}
|
|
43020
|
-
await
|
|
43050
|
+
await _internals62.subscribe(directory, {
|
|
43021
43051
|
sessionID,
|
|
43022
43052
|
prNumber: prInfo.number,
|
|
43023
43053
|
repoFullName,
|
|
@@ -43045,7 +43075,7 @@ async function handlePrSubscribeCommand(directory, args, sessionID) {
|
|
|
43045
43075
|
`);
|
|
43046
43076
|
}
|
|
43047
43077
|
}
|
|
43048
|
-
var
|
|
43078
|
+
var _internals62 = {
|
|
43049
43079
|
loadPluginConfig,
|
|
43050
43080
|
subscribe
|
|
43051
43081
|
};
|
|
@@ -43068,9 +43098,9 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
43068
43098
|
`);
|
|
43069
43099
|
}
|
|
43070
43100
|
const refToken = rest[0];
|
|
43071
|
-
const prInfo =
|
|
43101
|
+
const prInfo = _internals63.parsePrRef(refToken, directory);
|
|
43072
43102
|
if (!prInfo) {
|
|
43073
|
-
if (
|
|
43103
|
+
if (_internals63.looksLikePrRef(refToken)) {
|
|
43074
43104
|
return [
|
|
43075
43105
|
`Error: Could not resolve PR reference from "${refToken}".`,
|
|
43076
43106
|
"",
|
|
@@ -43091,8 +43121,8 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
43091
43121
|
const repoFullName = `${prInfo.owner}/${prInfo.repo}`;
|
|
43092
43122
|
const prUrl = `https://github.com/${prInfo.owner}/${prInfo.repo}/pull/${prInfo.number}`;
|
|
43093
43123
|
try {
|
|
43094
|
-
const correlationId =
|
|
43095
|
-
const result = await
|
|
43124
|
+
const correlationId = _internals63.buildCorrelationId(sessionID, repoFullName, prInfo.number);
|
|
43125
|
+
const result = await _internals63.unsubscribe(directory, correlationId);
|
|
43096
43126
|
if (!result) {
|
|
43097
43127
|
return [
|
|
43098
43128
|
`Not subscribed to ${prUrl}`,
|
|
@@ -43119,7 +43149,7 @@ async function handlePrUnsubscribeCommand(directory, args, sessionID) {
|
|
|
43119
43149
|
`);
|
|
43120
43150
|
}
|
|
43121
43151
|
}
|
|
43122
|
-
var
|
|
43152
|
+
var _internals63 = {
|
|
43123
43153
|
unsubscribe,
|
|
43124
43154
|
buildCorrelationId,
|
|
43125
43155
|
parsePrRef,
|
|
@@ -43559,15 +43589,15 @@ var lint = createSwarmTool({
|
|
|
43559
43589
|
}
|
|
43560
43590
|
const { mode } = args;
|
|
43561
43591
|
const cwd = directory;
|
|
43562
|
-
const linter = await
|
|
43592
|
+
const linter = await _internals64.detectAvailableLinter(directory);
|
|
43563
43593
|
if (linter) {
|
|
43564
|
-
const result = await
|
|
43594
|
+
const result = await _internals64.runLint(linter, mode, directory);
|
|
43565
43595
|
return JSON.stringify(result, null, 2);
|
|
43566
43596
|
}
|
|
43567
|
-
const additionalLinter =
|
|
43597
|
+
const additionalLinter = _internals64.detectAdditionalLinter(cwd);
|
|
43568
43598
|
if (additionalLinter) {
|
|
43569
43599
|
warn(`[lint] Using ${additionalLinter} linter for this project`);
|
|
43570
|
-
const result = await
|
|
43600
|
+
const result = await _internals64.runAdditionalLint(additionalLinter, mode, cwd);
|
|
43571
43601
|
return JSON.stringify(result, null, 2);
|
|
43572
43602
|
}
|
|
43573
43603
|
const errorResult = {
|
|
@@ -43581,7 +43611,7 @@ For Rust: rustup component add clippy`
|
|
|
43581
43611
|
return JSON.stringify(errorResult, null, 2);
|
|
43582
43612
|
}
|
|
43583
43613
|
});
|
|
43584
|
-
var
|
|
43614
|
+
var _internals64 = {
|
|
43585
43615
|
detectAvailableLinter,
|
|
43586
43616
|
runLint,
|
|
43587
43617
|
detectAdditionalLinter,
|
|
@@ -43953,13 +43983,13 @@ function readBoundedFile(filePath) {
|
|
|
43953
43983
|
let fd;
|
|
43954
43984
|
try {
|
|
43955
43985
|
const flags = fs31.constants.O_RDONLY | (O_NOFOLLOW !== undefined ? O_NOFOLLOW : 0);
|
|
43956
|
-
fd =
|
|
43986
|
+
fd = _internals65.openFile(filePath, flags);
|
|
43957
43987
|
} catch {
|
|
43958
43988
|
return { status: "incomplete", reason: "read_error" };
|
|
43959
43989
|
}
|
|
43960
43990
|
let outcome;
|
|
43961
43991
|
try {
|
|
43962
|
-
const stat6 =
|
|
43992
|
+
const stat6 = _internals65.fstatFile(fd);
|
|
43963
43993
|
const initialSize = stat6.size;
|
|
43964
43994
|
if (!stat6.isFile()) {
|
|
43965
43995
|
outcome = { status: "incomplete", reason: "non_file" };
|
|
@@ -43968,12 +43998,12 @@ function readBoundedFile(filePath) {
|
|
|
43968
43998
|
const buffer = Buffer.allocUnsafe(bufferLength);
|
|
43969
43999
|
let bytesRead = 0;
|
|
43970
44000
|
while (bytesRead < buffer.length) {
|
|
43971
|
-
const count =
|
|
44001
|
+
const count = _internals65.readFileChunk(fd, buffer, bytesRead, buffer.length - bytesRead, null);
|
|
43972
44002
|
if (count === 0)
|
|
43973
44003
|
break;
|
|
43974
44004
|
bytesRead += count;
|
|
43975
44005
|
}
|
|
43976
|
-
const postStat =
|
|
44006
|
+
const postStat = _internals65.fstatFile(fd);
|
|
43977
44007
|
if (postStat.size !== initialSize) {
|
|
43978
44008
|
outcome = {
|
|
43979
44009
|
status: "incomplete",
|
|
@@ -43991,7 +44021,7 @@ function readBoundedFile(filePath) {
|
|
|
43991
44021
|
outcome = { status: "incomplete", reason: "read_error" };
|
|
43992
44022
|
}
|
|
43993
44023
|
try {
|
|
43994
|
-
|
|
44024
|
+
_internals65.closeFile(fd);
|
|
43995
44025
|
} catch {
|
|
43996
44026
|
return { status: "incomplete", reason: "read_error" };
|
|
43997
44027
|
}
|
|
@@ -44179,8 +44209,8 @@ async function collectScannableFiles(dir, excludeExact, excludeGlobs, scanDir, v
|
|
|
44179
44209
|
while (true) {
|
|
44180
44210
|
if (state.entriesSinceYield >= DISCOVERY_YIELD_INTERVAL) {
|
|
44181
44211
|
state.entriesSinceYield = 0;
|
|
44182
|
-
await
|
|
44183
|
-
if (
|
|
44212
|
+
await _internals65.yieldToEventLoop();
|
|
44213
|
+
if (_internals65.now() >= state.deadline) {
|
|
44184
44214
|
state.deadlineExceeded = true;
|
|
44185
44215
|
recordIncompletePath(state.incompletePaths, scanDir, currentDir, "deadline");
|
|
44186
44216
|
stoppedEarly = true;
|
|
@@ -44243,7 +44273,7 @@ async function collectScannableFiles(dir, excludeExact, excludeGlobs, scanDir, v
|
|
|
44243
44273
|
}
|
|
44244
44274
|
} finally {
|
|
44245
44275
|
try {
|
|
44246
|
-
|
|
44276
|
+
_internals65.closeDirectory(directory);
|
|
44247
44277
|
} catch (error2) {
|
|
44248
44278
|
if (error2.code !== "ERR_DIR_CLOSED") {
|
|
44249
44279
|
state.cleanupFailed = true;
|
|
@@ -44365,7 +44395,7 @@ var secretscan = createSwarmTool({
|
|
|
44365
44395
|
symlinkSkipped: 0
|
|
44366
44396
|
};
|
|
44367
44397
|
const visited = new Set;
|
|
44368
|
-
const deadline =
|
|
44398
|
+
const deadline = _internals65.now() + SCAN_TIME_BUDGET_MS;
|
|
44369
44399
|
const discovery = {
|
|
44370
44400
|
files: [],
|
|
44371
44401
|
totalCandidates: 0,
|
|
@@ -44377,7 +44407,7 @@ var secretscan = createSwarmTool({
|
|
|
44377
44407
|
directoriesQueued: 1,
|
|
44378
44408
|
unexaminedDirectories: 0
|
|
44379
44409
|
};
|
|
44380
|
-
await
|
|
44410
|
+
await _internals65.yieldToEventLoop();
|
|
44381
44411
|
await collectScannableFiles(scanDir, excludeExact, excludeGlobs, scanDir, visited, stats, discovery);
|
|
44382
44412
|
const files = discovery.files;
|
|
44383
44413
|
files.sort(compareFilePaths);
|
|
@@ -44396,7 +44426,7 @@ var secretscan = createSwarmTool({
|
|
|
44396
44426
|
let skippedFiles = stats.skippedFiles;
|
|
44397
44427
|
let incompleteFiles = stats.fileErrors + Math.max(0, discovery.totalCandidates - filesToScan.length) + (discovery.deadlineExceeded || discovery.cleanupFailed ? 1 : 0) + discovery.unexaminedDirectories;
|
|
44398
44428
|
for (let index = 0;index < filesToScan.length; index++) {
|
|
44399
|
-
if (
|
|
44429
|
+
if (_internals65.now() >= deadline) {
|
|
44400
44430
|
for (const remaining of filesToScan.slice(index)) {
|
|
44401
44431
|
recordIncompletePath(discovery.incompletePaths, scanDir, remaining, "deadline");
|
|
44402
44432
|
}
|
|
@@ -44432,7 +44462,7 @@ var secretscan = createSwarmTool({
|
|
|
44432
44462
|
}
|
|
44433
44463
|
}
|
|
44434
44464
|
if (index + 1 < filesToScan.length) {
|
|
44435
|
-
await
|
|
44465
|
+
await _internals65.yieldToEventLoop();
|
|
44436
44466
|
}
|
|
44437
44467
|
}
|
|
44438
44468
|
allFindings.sort((a, b) => {
|
|
@@ -44495,7 +44525,7 @@ var secretscan = createSwarmTool({
|
|
|
44495
44525
|
});
|
|
44496
44526
|
async function runSecretscan(directory) {
|
|
44497
44527
|
try {
|
|
44498
|
-
const result = await
|
|
44528
|
+
const result = await _internals65.secretscan.execute({ directory }, {});
|
|
44499
44529
|
const jsonStr = typeof result === "string" ? result : result.output;
|
|
44500
44530
|
return JSON.parse(jsonStr);
|
|
44501
44531
|
} catch (e) {
|
|
@@ -44546,10 +44576,10 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44546
44576
|
if (files.length > filesToScan.length) {
|
|
44547
44577
|
recordIncompletePath(incompletePaths, canonicalRoot, canonicalRoot, "max_files");
|
|
44548
44578
|
}
|
|
44549
|
-
const deadline =
|
|
44550
|
-
await
|
|
44579
|
+
const deadline = _internals65.now() + SCAN_TIME_BUDGET_MS;
|
|
44580
|
+
await _internals65.yieldToEventLoop();
|
|
44551
44581
|
for (let index = 0;index < filesToScan.length; index++) {
|
|
44552
|
-
if (
|
|
44582
|
+
if (_internals65.now() >= deadline) {
|
|
44553
44583
|
for (const remaining of filesToScan.slice(index)) {
|
|
44554
44584
|
const remainingPath = path77.isAbsolute(remaining) ? path77.resolve(remaining) : path77.resolve(rawRoot, remaining);
|
|
44555
44585
|
recordIncompletePath(incompletePaths, canonicalRoot, remainingPath, "deadline");
|
|
@@ -44576,7 +44606,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44576
44606
|
}
|
|
44577
44607
|
let lstat3;
|
|
44578
44608
|
try {
|
|
44579
|
-
lstat3 =
|
|
44609
|
+
lstat3 = _internals65.lstatFile(resolvedPath);
|
|
44580
44610
|
} catch (error2) {
|
|
44581
44611
|
const err = error2;
|
|
44582
44612
|
if (err.code === "ENOENT") {
|
|
@@ -44645,7 +44675,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44645
44675
|
assertNever(outcome);
|
|
44646
44676
|
}
|
|
44647
44677
|
if (index + 1 < filesToScan.length) {
|
|
44648
|
-
await
|
|
44678
|
+
await _internals65.yieldToEventLoop();
|
|
44649
44679
|
}
|
|
44650
44680
|
}
|
|
44651
44681
|
findings.sort((a, b) => {
|
|
@@ -44675,7 +44705,7 @@ async function runSecretscanOnFiles(files, directory) {
|
|
|
44675
44705
|
};
|
|
44676
44706
|
}
|
|
44677
44707
|
}
|
|
44678
|
-
var
|
|
44708
|
+
var _internals65 = {
|
|
44679
44709
|
secretscan,
|
|
44680
44710
|
runSecretscan,
|
|
44681
44711
|
runSecretscanOnFiles,
|
|
@@ -44959,7 +44989,7 @@ async function buildImpactMapInternal(cwd) {
|
|
|
44959
44989
|
}
|
|
44960
44990
|
return impactMap;
|
|
44961
44991
|
}
|
|
44962
|
-
var
|
|
44992
|
+
var _internals66 = {
|
|
44963
44993
|
validateProjectRoot,
|
|
44964
44994
|
normalizePath: normalizePath2,
|
|
44965
44995
|
isCacheStale,
|
|
@@ -44974,8 +45004,8 @@ var _internals65 = {
|
|
|
44974
45004
|
_clearGoModuleCache
|
|
44975
45005
|
};
|
|
44976
45006
|
async function buildImpactMap(cwd) {
|
|
44977
|
-
const impactMap = await
|
|
44978
|
-
await
|
|
45007
|
+
const impactMap = await _internals66.buildImpactMapInternal(cwd);
|
|
45008
|
+
await _internals66.saveImpactMap(cwd, impactMap);
|
|
44979
45009
|
return impactMap;
|
|
44980
45010
|
}
|
|
44981
45011
|
async function loadImpactMap(cwd, options) {
|
|
@@ -44989,7 +45019,7 @@ async function loadImpactMap(cwd, options) {
|
|
|
44989
45019
|
const hasValidValues = Object.values(map).every((v) => Array.isArray(v) && v.every((item) => typeof item === "string"));
|
|
44990
45020
|
if (hasValidValues) {
|
|
44991
45021
|
const generatedAt = new Date(data.generatedAt).getTime();
|
|
44992
|
-
if (!
|
|
45022
|
+
if (!_internals66.isCacheStale(map, generatedAt)) {
|
|
44993
45023
|
return map;
|
|
44994
45024
|
}
|
|
44995
45025
|
if (options?.skipRebuild) {
|
|
@@ -45009,13 +45039,13 @@ async function loadImpactMap(cwd, options) {
|
|
|
45009
45039
|
if (options?.skipRebuild) {
|
|
45010
45040
|
return {};
|
|
45011
45041
|
}
|
|
45012
|
-
return
|
|
45042
|
+
return _internals66.buildImpactMap(cwd);
|
|
45013
45043
|
}
|
|
45014
45044
|
async function saveImpactMap(cwd, impactMap) {
|
|
45015
45045
|
if (!path78.isAbsolute(cwd)) {
|
|
45016
45046
|
throw new Error(`saveImpactMap requires an absolute project root path, got: "${cwd}"`);
|
|
45017
45047
|
}
|
|
45018
|
-
|
|
45048
|
+
_internals66.validateProjectRoot(cwd);
|
|
45019
45049
|
const cacheDir2 = path78.join(cwd, ".swarm", "cache");
|
|
45020
45050
|
const cachePath = path78.join(cacheDir2, "impact-map.json");
|
|
45021
45051
|
if (!fs32.existsSync(cacheDir2)) {
|
|
@@ -45039,7 +45069,7 @@ async function analyzeImpact(changedFiles, cwd, budget) {
|
|
|
45039
45069
|
};
|
|
45040
45070
|
}
|
|
45041
45071
|
const validFiles = changedFiles.filter((f) => typeof f === "string" && f.length > 0 && !f.includes("\x00"));
|
|
45042
|
-
const impactMap = await
|
|
45072
|
+
const impactMap = await _internals66.loadImpactMap(cwd);
|
|
45043
45073
|
const impactedTestsSet = new Set;
|
|
45044
45074
|
const untestedFiles = [];
|
|
45045
45075
|
let visitedCount = 0;
|
|
@@ -45316,7 +45346,7 @@ function batchAppendTestRuns(records, workingDir) {
|
|
|
45316
45346
|
}
|
|
45317
45347
|
const historyPath = getHistoryPath(workingDir);
|
|
45318
45348
|
const historyDir = path79.dirname(historyPath);
|
|
45319
|
-
|
|
45349
|
+
_internals67.validateProjectRoot(workingDir);
|
|
45320
45350
|
if (!fs33.existsSync(historyDir)) {
|
|
45321
45351
|
fs33.mkdirSync(historyDir, { recursive: true });
|
|
45322
45352
|
}
|
|
@@ -45439,7 +45469,7 @@ function getAllHistory(workingDir) {
|
|
|
45439
45469
|
records.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
45440
45470
|
return records;
|
|
45441
45471
|
}
|
|
45442
|
-
var
|
|
45472
|
+
var _internals67 = {
|
|
45443
45473
|
validateProjectRoot
|
|
45444
45474
|
};
|
|
45445
45475
|
|
|
@@ -45531,7 +45561,7 @@ var MAX_SAFE_TEST_FILES = 50;
|
|
|
45531
45561
|
var MAX_SAFE_SOURCE_FILES = 1;
|
|
45532
45562
|
async function estimateFanOut(sourceFiles, cwd) {
|
|
45533
45563
|
try {
|
|
45534
|
-
const impactMap = await
|
|
45564
|
+
const impactMap = await _internals68.loadImpactMap(cwd, {
|
|
45535
45565
|
skipRebuild: true
|
|
45536
45566
|
});
|
|
45537
45567
|
const uniqueTestFiles = new Set;
|
|
@@ -45621,45 +45651,45 @@ function hasDevDependency(devDeps, ...patterns) {
|
|
|
45621
45651
|
return hasPackageJsonDependency(devDeps, ...patterns);
|
|
45622
45652
|
}
|
|
45623
45653
|
function detectGoTest(cwd) {
|
|
45624
|
-
return
|
|
45654
|
+
return _internals68.existsSync(path81.join(cwd, "go.mod")) && _internals68.isCommandAvailable("go");
|
|
45625
45655
|
}
|
|
45626
45656
|
function detectJavaMaven(cwd) {
|
|
45627
|
-
return
|
|
45657
|
+
return _internals68.existsSync(path81.join(cwd, "pom.xml")) && _internals68.isCommandAvailable("mvn");
|
|
45628
45658
|
}
|
|
45629
45659
|
function detectGradle(cwd) {
|
|
45630
|
-
const hasBuildFile =
|
|
45631
|
-
const hasGradlew =
|
|
45632
|
-
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"));
|
|
45633
45663
|
}
|
|
45634
45664
|
function detectDotnetTest(cwd) {
|
|
45635
45665
|
try {
|
|
45636
|
-
const files =
|
|
45666
|
+
const files = _internals68.readdirSync(cwd);
|
|
45637
45667
|
const hasCsproj = files.some((f) => f.endsWith(".csproj"));
|
|
45638
|
-
return hasCsproj &&
|
|
45668
|
+
return hasCsproj && _internals68.isCommandAvailable("dotnet");
|
|
45639
45669
|
} catch {
|
|
45640
45670
|
return false;
|
|
45641
45671
|
}
|
|
45642
45672
|
}
|
|
45643
45673
|
function detectCTest(cwd) {
|
|
45644
|
-
const hasSource =
|
|
45645
|
-
const hasBuildCache =
|
|
45646
|
-
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");
|
|
45647
45677
|
}
|
|
45648
45678
|
function detectSwiftTest(cwd) {
|
|
45649
|
-
return
|
|
45679
|
+
return _internals68.existsSync(path81.join(cwd, "Package.swift")) && _internals68.isCommandAvailable("swift");
|
|
45650
45680
|
}
|
|
45651
45681
|
function detectDartTest(cwd) {
|
|
45652
|
-
return
|
|
45682
|
+
return _internals68.existsSync(path81.join(cwd, "pubspec.yaml")) && (_internals68.isCommandAvailable("dart") || _internals68.isCommandAvailable("flutter"));
|
|
45653
45683
|
}
|
|
45654
45684
|
function detectRSpec(cwd) {
|
|
45655
|
-
const hasRSpecFile =
|
|
45656
|
-
const hasGemfile =
|
|
45657
|
-
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"));
|
|
45658
45688
|
const hasRSpec = hasRSpecFile || hasGemfile && hasSpecDir;
|
|
45659
|
-
return hasRSpec && (
|
|
45689
|
+
return hasRSpec && (_internals68.isCommandAvailable("bundle") || _internals68.isCommandAvailable("rspec"));
|
|
45660
45690
|
}
|
|
45661
45691
|
function detectMinitest(cwd) {
|
|
45662
|
-
return
|
|
45692
|
+
return _internals68.existsSync(path81.join(cwd, "test")) && (_internals68.existsSync(path81.join(cwd, "Gemfile")) || _internals68.existsSync(path81.join(cwd, "Rakefile"))) && _internals68.isCommandAvailable("ruby");
|
|
45663
45693
|
}
|
|
45664
45694
|
var DISPATCH_FRAMEWORK_MAP = {
|
|
45665
45695
|
bun: "bun",
|
|
@@ -45750,8 +45780,8 @@ async function detectTestFramework(cwd) {
|
|
|
45750
45780
|
const baseDir = cwd;
|
|
45751
45781
|
try {
|
|
45752
45782
|
const packageJsonPath = path81.join(baseDir, "package.json");
|
|
45753
|
-
if (
|
|
45754
|
-
const content =
|
|
45783
|
+
if (_internals68.existsSync(packageJsonPath)) {
|
|
45784
|
+
const content = _internals68.readFileSync(packageJsonPath, "utf-8");
|
|
45755
45785
|
const pkg = JSON.parse(content);
|
|
45756
45786
|
const _deps = pkg.dependencies || {};
|
|
45757
45787
|
const devDeps = pkg.devDependencies || {};
|
|
@@ -45770,7 +45800,7 @@ async function detectTestFramework(cwd) {
|
|
|
45770
45800
|
return "jest";
|
|
45771
45801
|
if (hasDevDependency(devDeps, "mocha", "@types/mocha"))
|
|
45772
45802
|
return "mocha";
|
|
45773
|
-
if (
|
|
45803
|
+
if (_internals68.existsSync(path81.join(baseDir, "bun.lockb")) || _internals68.existsSync(path81.join(baseDir, "bun.lock"))) {
|
|
45774
45804
|
if (scripts.test?.includes("bun"))
|
|
45775
45805
|
return "bun";
|
|
45776
45806
|
}
|
|
@@ -45780,28 +45810,28 @@ async function detectTestFramework(cwd) {
|
|
|
45780
45810
|
const pyprojectTomlPath = path81.join(baseDir, "pyproject.toml");
|
|
45781
45811
|
const setupCfgPath = path81.join(baseDir, "setup.cfg");
|
|
45782
45812
|
const requirementsTxtPath = path81.join(baseDir, "requirements.txt");
|
|
45783
|
-
if (
|
|
45784
|
-
const content =
|
|
45813
|
+
if (_internals68.existsSync(pyprojectTomlPath)) {
|
|
45814
|
+
const content = _internals68.readFileSync(pyprojectTomlPath, "utf-8");
|
|
45785
45815
|
if (content.includes("[tool.pytest"))
|
|
45786
45816
|
return "pytest";
|
|
45787
45817
|
if (content.includes("pytest"))
|
|
45788
45818
|
return "pytest";
|
|
45789
45819
|
}
|
|
45790
|
-
if (
|
|
45791
|
-
const content =
|
|
45820
|
+
if (_internals68.existsSync(setupCfgPath)) {
|
|
45821
|
+
const content = _internals68.readFileSync(setupCfgPath, "utf-8");
|
|
45792
45822
|
if (content.includes("[pytest]"))
|
|
45793
45823
|
return "pytest";
|
|
45794
45824
|
}
|
|
45795
|
-
if (
|
|
45796
|
-
const content =
|
|
45825
|
+
if (_internals68.existsSync(requirementsTxtPath)) {
|
|
45826
|
+
const content = _internals68.readFileSync(requirementsTxtPath, "utf-8");
|
|
45797
45827
|
if (content.includes("pytest"))
|
|
45798
45828
|
return "pytest";
|
|
45799
45829
|
}
|
|
45800
45830
|
} catch {}
|
|
45801
45831
|
try {
|
|
45802
45832
|
const cargoTomlPath = path81.join(baseDir, "Cargo.toml");
|
|
45803
|
-
if (
|
|
45804
|
-
const content =
|
|
45833
|
+
if (_internals68.existsSync(cargoTomlPath)) {
|
|
45834
|
+
const content = _internals68.readFileSync(cargoTomlPath, "utf-8");
|
|
45805
45835
|
if (content.includes("[dev-dependencies]")) {
|
|
45806
45836
|
if (content.includes("tokio") || content.includes("mockall") || content.includes("pretty_assertions")) {
|
|
45807
45837
|
return "cargo";
|
|
@@ -45813,7 +45843,7 @@ async function detectTestFramework(cwd) {
|
|
|
45813
45843
|
const pesterConfigPath = path81.join(baseDir, "pester.config.ps1");
|
|
45814
45844
|
const pesterConfigJsonPath = path81.join(baseDir, "pester.config.ps1.json");
|
|
45815
45845
|
const pesterPs1Path = path81.join(baseDir, "tests.ps1");
|
|
45816
|
-
if (
|
|
45846
|
+
if (_internals68.existsSync(pesterConfigPath) || _internals68.existsSync(pesterConfigJsonPath) || _internals68.existsSync(pesterPs1Path)) {
|
|
45817
45847
|
return "pester";
|
|
45818
45848
|
}
|
|
45819
45849
|
} catch {}
|
|
@@ -45841,12 +45871,12 @@ async function detectTestFramework(cwd) {
|
|
|
45841
45871
|
return "none";
|
|
45842
45872
|
}
|
|
45843
45873
|
function detectPhpTest(cwd) {
|
|
45844
|
-
if (
|
|
45874
|
+
if (_internals68.existsSync(path81.join(cwd, "artisan")) && _internals68.existsSync(path81.join(cwd, "composer.json"))) {
|
|
45845
45875
|
return "php-artisan";
|
|
45846
45876
|
}
|
|
45847
|
-
if (
|
|
45877
|
+
if (_internals68.existsSync(path81.join(cwd, "Pest.php")))
|
|
45848
45878
|
return "pest";
|
|
45849
|
-
if (
|
|
45879
|
+
if (_internals68.existsSync(path81.join(cwd, "phpunit.xml")) || _internals68.existsSync(path81.join(cwd, "phpunit.xml.dist"))) {
|
|
45850
45880
|
return "phpunit";
|
|
45851
45881
|
}
|
|
45852
45882
|
return null;
|
|
@@ -46228,9 +46258,9 @@ function buildTestCommand(framework, scope, files, coverage, baseDir, bail) {
|
|
|
46228
46258
|
case "swift-test":
|
|
46229
46259
|
return ["swift", "test"];
|
|
46230
46260
|
case "dart-test":
|
|
46231
|
-
return
|
|
46261
|
+
return _internals68.isCommandAvailable("flutter") ? ["flutter", "test", ...files] : ["dart", "test", ...files];
|
|
46232
46262
|
case "rspec": {
|
|
46233
|
-
const args =
|
|
46263
|
+
const args = _internals68.isCommandAvailable("bundle") ? ["bundle", "exec", "rspec"] : ["rspec"];
|
|
46234
46264
|
if (bail)
|
|
46235
46265
|
args.push("--fail-fast");
|
|
46236
46266
|
if (scope !== "all" && files.length > 0) {
|
|
@@ -47243,7 +47273,7 @@ var test_runner = createSwarmTool({
|
|
|
47243
47273
|
return JSON.stringify(errorResult, null, 2);
|
|
47244
47274
|
}
|
|
47245
47275
|
try {
|
|
47246
|
-
const impactResult = await
|
|
47276
|
+
const impactResult = await _internals68.analyzeImpact(sourceFiles, workingDir, MAX_SAFE_TEST_FILES);
|
|
47247
47277
|
if (impactResult.budgetExceeded) {
|
|
47248
47278
|
const errorResult = {
|
|
47249
47279
|
success: false,
|
|
@@ -47333,7 +47363,7 @@ var test_runner = createSwarmTool({
|
|
|
47333
47363
|
return JSON.stringify(result, null, 2);
|
|
47334
47364
|
}
|
|
47335
47365
|
});
|
|
47336
|
-
var
|
|
47366
|
+
var _internals68 = {
|
|
47337
47367
|
analyzeImpact,
|
|
47338
47368
|
loadImpactMap,
|
|
47339
47369
|
isCommandAvailable,
|
|
@@ -47435,9 +47465,9 @@ function getVersionFileVersion(dir) {
|
|
|
47435
47465
|
async function runVersionCheck(dir, _timeoutMs) {
|
|
47436
47466
|
const startTime = Date.now();
|
|
47437
47467
|
try {
|
|
47438
|
-
const packageVersion =
|
|
47439
|
-
const changelogVersion =
|
|
47440
|
-
const versionFileVersion =
|
|
47468
|
+
const packageVersion = _internals69.getPackageVersion(dir);
|
|
47469
|
+
const changelogVersion = _internals69.getChangelogVersion(dir);
|
|
47470
|
+
const versionFileVersion = _internals69.getVersionFileVersion(dir);
|
|
47441
47471
|
const versions = [];
|
|
47442
47472
|
if (packageVersion)
|
|
47443
47473
|
versions.push(`package.json: ${packageVersion}`);
|
|
@@ -47626,7 +47656,7 @@ async function runTestsCheck(_dir, scope, timeoutMs) {
|
|
|
47626
47656
|
async function runSecretsCheck(dir, timeoutMs) {
|
|
47627
47657
|
const startTime = Date.now();
|
|
47628
47658
|
try {
|
|
47629
|
-
const secretsPromise =
|
|
47659
|
+
const secretsPromise = _internals69.runSecretscan(dir);
|
|
47630
47660
|
const timeoutPromise = new Promise((_, reject) => {
|
|
47631
47661
|
setTimeout(() => {
|
|
47632
47662
|
reject(new Error(`Secrets check timed out after ${timeoutMs}ms`));
|
|
@@ -47848,7 +47878,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47848
47878
|
const reportId = `preflight-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
47849
47879
|
let validatedDir;
|
|
47850
47880
|
try {
|
|
47851
|
-
validatedDir =
|
|
47881
|
+
validatedDir = _internals69.validateDirectoryPath(dir);
|
|
47852
47882
|
} catch (error2) {
|
|
47853
47883
|
return {
|
|
47854
47884
|
id: reportId,
|
|
@@ -47868,7 +47898,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47868
47898
|
}
|
|
47869
47899
|
let validatedTimeout;
|
|
47870
47900
|
try {
|
|
47871
|
-
validatedTimeout =
|
|
47901
|
+
validatedTimeout = _internals69.validateTimeout(config?.checkTimeoutMs, DEFAULT_CONFIG.checkTimeoutMs);
|
|
47872
47902
|
} catch (error2) {
|
|
47873
47903
|
return {
|
|
47874
47904
|
id: reportId,
|
|
@@ -47909,12 +47939,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
47909
47939
|
});
|
|
47910
47940
|
const checks = [];
|
|
47911
47941
|
log("[Preflight] Running lint check...");
|
|
47912
|
-
const lintResult = await
|
|
47942
|
+
const lintResult = await _internals69.runLintCheck(validatedDir, cfg.linter, cfg.checkTimeoutMs);
|
|
47913
47943
|
checks.push(lintResult);
|
|
47914
47944
|
log(`[Preflight] Lint check: ${lintResult.status} ${lintResult.message}`);
|
|
47915
47945
|
if (!cfg.skipTests) {
|
|
47916
47946
|
log("[Preflight] Running tests check...");
|
|
47917
|
-
const testsResult = await
|
|
47947
|
+
const testsResult = await _internals69.runTestsCheck(validatedDir, cfg.testScope, cfg.checkTimeoutMs);
|
|
47918
47948
|
checks.push(testsResult);
|
|
47919
47949
|
log(`[Preflight] Tests check: ${testsResult.status} ${testsResult.message}`);
|
|
47920
47950
|
} else {
|
|
@@ -47926,7 +47956,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47926
47956
|
}
|
|
47927
47957
|
if (!cfg.skipSecrets) {
|
|
47928
47958
|
log("[Preflight] Running secrets check...");
|
|
47929
|
-
const secretsResult = await
|
|
47959
|
+
const secretsResult = await _internals69.runSecretsCheck(validatedDir, cfg.checkTimeoutMs);
|
|
47930
47960
|
checks.push(secretsResult);
|
|
47931
47961
|
log(`[Preflight] Secrets check: ${secretsResult.status} ${secretsResult.message}`);
|
|
47932
47962
|
} else {
|
|
@@ -47938,7 +47968,7 @@ async function runPreflight(dir, phase, config) {
|
|
|
47938
47968
|
}
|
|
47939
47969
|
if (!cfg.skipEvidence) {
|
|
47940
47970
|
log("[Preflight] Running evidence check...");
|
|
47941
|
-
const evidenceResult = await
|
|
47971
|
+
const evidenceResult = await _internals69.runEvidenceCheck(validatedDir);
|
|
47942
47972
|
checks.push(evidenceResult);
|
|
47943
47973
|
log(`[Preflight] Evidence check: ${evidenceResult.status} ${evidenceResult.message}`);
|
|
47944
47974
|
} else {
|
|
@@ -47949,12 +47979,12 @@ async function runPreflight(dir, phase, config) {
|
|
|
47949
47979
|
});
|
|
47950
47980
|
}
|
|
47951
47981
|
log("[Preflight] Running requirement coverage check...");
|
|
47952
|
-
const reqCoverageResult = await
|
|
47982
|
+
const reqCoverageResult = await _internals69.runRequirementCoverageCheck(validatedDir, phase);
|
|
47953
47983
|
checks.push(reqCoverageResult);
|
|
47954
47984
|
log(`[Preflight] Requirement coverage check: ${reqCoverageResult.status} ${reqCoverageResult.message}`);
|
|
47955
47985
|
if (!cfg.skipVersion) {
|
|
47956
47986
|
log("[Preflight] Running version check...");
|
|
47957
|
-
const versionResult = await
|
|
47987
|
+
const versionResult = await _internals69.runVersionCheck(validatedDir, cfg.checkTimeoutMs);
|
|
47958
47988
|
checks.push(versionResult);
|
|
47959
47989
|
log(`[Preflight] Version check: ${versionResult.status} ${versionResult.message}`);
|
|
47960
47990
|
} else {
|
|
@@ -48017,10 +48047,10 @@ function formatPreflightMarkdown(report) {
|
|
|
48017
48047
|
async function handlePreflightCommand(directory, _args) {
|
|
48018
48048
|
const plan = await loadPlan(directory);
|
|
48019
48049
|
const phase = plan?.current_phase ?? 1;
|
|
48020
|
-
const report = await
|
|
48021
|
-
return
|
|
48050
|
+
const report = await _internals69.runPreflight(directory, phase);
|
|
48051
|
+
return _internals69.formatPreflightMarkdown(report);
|
|
48022
48052
|
}
|
|
48023
|
-
var
|
|
48053
|
+
var _internals69 = {
|
|
48024
48054
|
runPreflight,
|
|
48025
48055
|
formatPreflightMarkdown,
|
|
48026
48056
|
handlePreflightCommand,
|
|
@@ -49014,7 +49044,7 @@ function pruneOldResetBackups(backupsRoot, warnings) {
|
|
|
49014
49044
|
}
|
|
49015
49045
|
|
|
49016
49046
|
// src/commands/reset.ts
|
|
49017
|
-
var
|
|
49047
|
+
var _internals70 = {
|
|
49018
49048
|
backupSwarmStateBeforeReset
|
|
49019
49049
|
};
|
|
49020
49050
|
async function handleResetCommand(directory, args) {
|
|
@@ -49044,11 +49074,12 @@ async function handleResetCommand(directory, args) {
|
|
|
49044
49074
|
"plan-export/SWARM_PLAN.md",
|
|
49045
49075
|
"plan-export/SWARM_PLAN.json",
|
|
49046
49076
|
"checkpoints.json",
|
|
49047
|
-
"events.jsonl"
|
|
49077
|
+
"events.jsonl",
|
|
49078
|
+
"run-memory.jsonl"
|
|
49048
49079
|
];
|
|
49049
49080
|
const results = [];
|
|
49050
49081
|
try {
|
|
49051
|
-
const backup =
|
|
49082
|
+
const backup = _internals70.backupSwarmStateBeforeReset(directory, "reset", [
|
|
49052
49083
|
...filesToReset,
|
|
49053
49084
|
"summaries"
|
|
49054
49085
|
]);
|
|
@@ -49600,7 +49631,7 @@ async function recordReplayEntry(artifactPath, sessionID, entry) {
|
|
|
49600
49631
|
}
|
|
49601
49632
|
|
|
49602
49633
|
// src/prm/index.ts
|
|
49603
|
-
var
|
|
49634
|
+
var _internals71 = {
|
|
49604
49635
|
getAgentSession,
|
|
49605
49636
|
readTrajectory,
|
|
49606
49637
|
getInMemoryTrajectory,
|
|
@@ -49628,12 +49659,12 @@ function resetPrmSessionState(session, sessionId) {
|
|
|
49628
49659
|
session.prmInjectedAdvisoryKeys = new Set;
|
|
49629
49660
|
session.replayArtifactPath = null;
|
|
49630
49661
|
if (sessionId) {
|
|
49631
|
-
|
|
49662
|
+
_internals71.clearTrajectoryCache(sessionId);
|
|
49632
49663
|
}
|
|
49633
49664
|
}
|
|
49634
49665
|
|
|
49635
49666
|
// src/commands/reset-session.ts
|
|
49636
|
-
var
|
|
49667
|
+
var _internals72 = {
|
|
49637
49668
|
cleanupOrphanedBranches,
|
|
49638
49669
|
backupSwarmStateBeforeReset
|
|
49639
49670
|
};
|
|
@@ -49645,7 +49676,7 @@ function errorMessage(err) {
|
|
|
49645
49676
|
async function handleResetSessionCommand(directory, _args) {
|
|
49646
49677
|
const results = [];
|
|
49647
49678
|
try {
|
|
49648
|
-
const backup =
|
|
49679
|
+
const backup = _internals72.backupSwarmStateBeforeReset(directory, "reset-session", ["session"]);
|
|
49649
49680
|
if (backup.backupDir && backup.copied.length > 0) {
|
|
49650
49681
|
const rel = path86.relative(directory, backup.backupDir);
|
|
49651
49682
|
results.push(`\uD83D\uDCE6 Backed up session state to ${rel}/ (restore by copying files back into .swarm/session/)`);
|
|
@@ -49712,7 +49743,7 @@ async function handleResetSessionCommand(directory, _args) {
|
|
|
49712
49743
|
results.push(`\u26A0\uFE0F Failed to remove .swarm-worktrees/: ${errorMessage(err)}`);
|
|
49713
49744
|
}
|
|
49714
49745
|
try {
|
|
49715
|
-
const branchResult = await
|
|
49746
|
+
const branchResult = await _internals72.cleanupOrphanedBranches(directory, []);
|
|
49716
49747
|
if (branchResult.removed.length > 0) {
|
|
49717
49748
|
results.push(`\u2705 Removed ${branchResult.removed.length} orphan swarm-lane branch(es)`);
|
|
49718
49749
|
}
|
|
@@ -49871,7 +49902,7 @@ function resolveReceiptsDir(directory) {
|
|
|
49871
49902
|
function resolveReceiptIndexPath(directory) {
|
|
49872
49903
|
return path88.join(resolveReceiptsDir(directory), "index.json");
|
|
49873
49904
|
}
|
|
49874
|
-
var
|
|
49905
|
+
var _internals73 = {
|
|
49875
49906
|
openSync: fs41.openSync,
|
|
49876
49907
|
lstatBigIntSync: (path89) => fs41.lstatSync(path89, { bigint: true }),
|
|
49877
49908
|
fstatBigIntSync: (fd) => fs41.fstatSync(fd, { bigint: true })
|
|
@@ -49883,7 +49914,7 @@ function pathsEqual(left, right) {
|
|
|
49883
49914
|
}
|
|
49884
49915
|
function captureCanonicalDirectory(directory, label, expected) {
|
|
49885
49916
|
const resolved = path88.resolve(directory);
|
|
49886
|
-
const stat6 =
|
|
49917
|
+
const stat6 = _internals73.lstatBigIntSync(resolved);
|
|
49887
49918
|
if (!stat6.isDirectory() || stat6.isSymbolicLink()) {
|
|
49888
49919
|
throw new Error(`${label} must be a real directory`);
|
|
49889
49920
|
}
|
|
@@ -49969,7 +50000,7 @@ function assertDirectReceiptFile(context, filePath, mustExist) {
|
|
|
49969
50000
|
throw new Error("review receipt file escapes its expected directory");
|
|
49970
50001
|
}
|
|
49971
50002
|
try {
|
|
49972
|
-
const stat6 =
|
|
50003
|
+
const stat6 = _internals73.lstatBigIntSync(resolved);
|
|
49973
50004
|
if (!stat6.isFile() || stat6.isSymbolicLink()) {
|
|
49974
50005
|
throw new Error("review receipt path must be a real file");
|
|
49975
50006
|
}
|
|
@@ -49993,7 +50024,7 @@ function readReviewReceiptText(directory, receiptPath, maxBytes = 1048576) {
|
|
|
49993
50024
|
const resolved = assertDirectReceiptFile(context, receiptPath, true);
|
|
49994
50025
|
if (path88.extname(resolved) !== ".json")
|
|
49995
50026
|
return null;
|
|
49996
|
-
const pathBeforeOpen =
|
|
50027
|
+
const pathBeforeOpen = _internals73.lstatBigIntSync(resolved);
|
|
49997
50028
|
if (!pathBeforeOpen.isFile() || pathBeforeOpen.isSymbolicLink() || pathBeforeOpen.size < 0n || pathBeforeOpen.size > BigInt(maxBytes)) {
|
|
49998
50029
|
return null;
|
|
49999
50030
|
}
|
|
@@ -50001,10 +50032,10 @@ function readReviewReceiptText(directory, receiptPath, maxBytes = 1048576) {
|
|
|
50001
50032
|
if (!pathsEqual(canonicalBeforeOpen, resolved))
|
|
50002
50033
|
return null;
|
|
50003
50034
|
assertReceiptContextCurrent(context);
|
|
50004
|
-
descriptor =
|
|
50005
|
-
const openedBeforeRead =
|
|
50035
|
+
descriptor = _internals73.openSync(canonicalBeforeOpen, "r");
|
|
50036
|
+
const openedBeforeRead = _internals73.fstatBigIntSync(descriptor);
|
|
50006
50037
|
assertReceiptContextCurrent(context);
|
|
50007
|
-
const pathAfterOpen =
|
|
50038
|
+
const pathAfterOpen = _internals73.lstatBigIntSync(resolved);
|
|
50008
50039
|
const canonicalAfterOpen = fs41.realpathSync(resolved);
|
|
50009
50040
|
if (!openedBeforeRead.isFile() || openedBeforeRead.size < 0n || openedBeforeRead.size > BigInt(maxBytes) || !sameFileSnapshot2(pathBeforeOpen, openedBeforeRead) || !sameFileSnapshot2(openedBeforeRead, pathAfterOpen) || !pathsEqual(canonicalBeforeOpen, canonicalAfterOpen)) {
|
|
50010
50041
|
return null;
|
|
@@ -50017,9 +50048,9 @@ function readReviewReceiptText(directory, receiptPath, maxBytes = 1048576) {
|
|
|
50017
50048
|
break;
|
|
50018
50049
|
bytesRead += count;
|
|
50019
50050
|
}
|
|
50020
|
-
const openedAfterRead =
|
|
50051
|
+
const openedAfterRead = _internals73.fstatBigIntSync(descriptor);
|
|
50021
50052
|
assertReceiptContextCurrent(context);
|
|
50022
|
-
const pathAfterRead =
|
|
50053
|
+
const pathAfterRead = _internals73.lstatBigIntSync(resolved);
|
|
50023
50054
|
const canonicalAfterRead = fs41.realpathSync(resolved);
|
|
50024
50055
|
if (bytesRead !== buffer.length || !sameFileSnapshot2(openedBeforeRead, openedAfterRead) || !sameFileSnapshot2(openedAfterRead, pathAfterRead) || !pathsEqual(canonicalBeforeOpen, canonicalAfterRead)) {
|
|
50025
50056
|
return null;
|
|
@@ -50563,7 +50594,7 @@ var HEAD_TIMEOUT_MS = 5000;
|
|
|
50563
50594
|
var HEAD_OUTPUT_BYTES = 256;
|
|
50564
50595
|
var HEAD_SHA_PATTERN = /^[0-9a-f]{40,64}$/i;
|
|
50565
50596
|
var REVIEWER_TASK_SCOPE_DESCRIPTION = "reviewer-task-files-v1";
|
|
50566
|
-
var
|
|
50597
|
+
var _internals74 = {
|
|
50567
50598
|
spawn: child_process7.spawn,
|
|
50568
50599
|
realpath: fs42.promises.realpath,
|
|
50569
50600
|
lstatBigInt: (path90) => fs42.promises.lstat(path90, { bigint: true }),
|
|
@@ -50603,7 +50634,7 @@ async function missingPathParentIsContained(root, absolutePath2) {
|
|
|
50603
50634
|
let current = path89.dirname(absolutePath2);
|
|
50604
50635
|
for (;; ) {
|
|
50605
50636
|
try {
|
|
50606
|
-
const canonical = await
|
|
50637
|
+
const canonical = await _internals74.realpath(current);
|
|
50607
50638
|
return samePath2(root, canonical) || isContained2(root, canonical);
|
|
50608
50639
|
} catch (error2) {
|
|
50609
50640
|
if (error2.code !== "ENOENT")
|
|
@@ -50630,7 +50661,7 @@ async function resolveHeadSha(directory) {
|
|
|
50630
50661
|
let child;
|
|
50631
50662
|
let timeoutHandle;
|
|
50632
50663
|
try {
|
|
50633
|
-
child =
|
|
50664
|
+
child = _internals74.spawn("git", ["rev-parse", "--verify", "HEAD"], {
|
|
50634
50665
|
cwd: directory,
|
|
50635
50666
|
stdio: ["ignore", "pipe", "ignore"],
|
|
50636
50667
|
timeout: HEAD_TIMEOUT_MS,
|
|
@@ -50693,7 +50724,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50693
50724
|
let realRoot;
|
|
50694
50725
|
try {
|
|
50695
50726
|
lexicalRoot = path89.resolve(directory);
|
|
50696
|
-
realRoot = await
|
|
50727
|
+
realRoot = await _internals74.realpath(lexicalRoot);
|
|
50697
50728
|
} catch {
|
|
50698
50729
|
return null;
|
|
50699
50730
|
}
|
|
@@ -50734,7 +50765,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50734
50765
|
for (const candidate of ordered) {
|
|
50735
50766
|
let before;
|
|
50736
50767
|
try {
|
|
50737
|
-
before = await
|
|
50768
|
+
before = await _internals74.lstatBigInt(candidate.absolutePath);
|
|
50738
50769
|
} catch (error2) {
|
|
50739
50770
|
if (error2.code === "ENOENT") {
|
|
50740
50771
|
if (!await missingPathParentIsContained(realRoot, candidate.absolutePath)) {
|
|
@@ -50753,7 +50784,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50753
50784
|
return null;
|
|
50754
50785
|
let realCandidate;
|
|
50755
50786
|
try {
|
|
50756
|
-
realCandidate = await
|
|
50787
|
+
realCandidate = await _internals74.realpath(candidate.absolutePath);
|
|
50757
50788
|
} catch {
|
|
50758
50789
|
return null;
|
|
50759
50790
|
}
|
|
@@ -50765,15 +50796,15 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50765
50796
|
let bytes;
|
|
50766
50797
|
let openedBefore;
|
|
50767
50798
|
try {
|
|
50768
|
-
handle = await
|
|
50769
|
-
openedBefore = await
|
|
50770
|
-
const canonicalAfterOpen = await
|
|
50799
|
+
handle = await _internals74.open(realCandidate, "r");
|
|
50800
|
+
openedBefore = await _internals74.fileHandleStatBigInt(handle);
|
|
50801
|
+
const canonicalAfterOpen = await _internals74.realpath(candidate.absolutePath);
|
|
50771
50802
|
if (!openedBefore.isFile() || !sameFileSnapshot3(before, openedBefore) || !samePath2(realCandidate, canonicalAfterOpen) || !isContained2(realRoot, canonicalAfterOpen)) {
|
|
50772
50803
|
return null;
|
|
50773
50804
|
}
|
|
50774
50805
|
bytes = await readBoundedHandle(handle, maxBytes - totalBytes);
|
|
50775
|
-
const openedAfter = await
|
|
50776
|
-
const canonicalAfterRead = await
|
|
50806
|
+
const openedAfter = await _internals74.fileHandleStatBigInt(handle);
|
|
50807
|
+
const canonicalAfterRead = await _internals74.realpath(candidate.absolutePath);
|
|
50777
50808
|
if (!sameFileSnapshot3(openedBefore, openedAfter) || !samePath2(realCandidate, canonicalAfterRead) || !isContained2(realRoot, canonicalAfterRead) || BigInt(bytes.byteLength) !== openedBefore.size) {
|
|
50778
50809
|
return null;
|
|
50779
50810
|
}
|
|
@@ -50797,8 +50828,8 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50797
50828
|
}
|
|
50798
50829
|
for (const stable of stableFiles) {
|
|
50799
50830
|
try {
|
|
50800
|
-
const current = await
|
|
50801
|
-
const canonical = await
|
|
50831
|
+
const current = await _internals74.lstatBigInt(stable.absolutePath);
|
|
50832
|
+
const canonical = await _internals74.realpath(stable.absolutePath);
|
|
50802
50833
|
if (!current.isFile() || current.isSymbolicLink() || !sameFileSnapshot3(stable.stat, current) || !samePath2(stable.canonicalPath, canonical) || !isContained2(realRoot, canonical)) {
|
|
50803
50834
|
return null;
|
|
50804
50835
|
}
|
|
@@ -50808,7 +50839,7 @@ async function buildReviewerTaskScope(directory, modifiedFiles, maxBytes = DEFAU
|
|
|
50808
50839
|
}
|
|
50809
50840
|
for (const deletedPath of deletedPaths) {
|
|
50810
50841
|
try {
|
|
50811
|
-
await
|
|
50842
|
+
await _internals74.lstatBigInt(deletedPath);
|
|
50812
50843
|
return null;
|
|
50813
50844
|
} catch (error2) {
|
|
50814
50845
|
if (error2.code !== "ENOENT" || !await missingPathParentIsContained(realRoot, deletedPath)) {
|
|
@@ -50971,7 +51002,7 @@ function parseReviewerOutput(text, options = {}) {
|
|
|
50971
51002
|
outputMode: "legacy"
|
|
50972
51003
|
};
|
|
50973
51004
|
}
|
|
50974
|
-
var
|
|
51005
|
+
var _internals75 = {
|
|
50975
51006
|
delegationEnd: telemetry.delegationEnd,
|
|
50976
51007
|
resolveReviewerTaskScope,
|
|
50977
51008
|
buildReviewerTaskScope,
|
|
@@ -51010,6 +51041,7 @@ async function persistAutoReviewEvidence(directory, evidence2, options = {}) {
|
|
|
51010
51041
|
throw new Error("auto-review evidence temp path changed before commit");
|
|
51011
51042
|
}
|
|
51012
51043
|
fs43.renameSync(revalidatedTemp, safeTarget);
|
|
51044
|
+
invalidateCachedArtifact(safeTarget);
|
|
51013
51045
|
return safeTarget;
|
|
51014
51046
|
} finally {
|
|
51015
51047
|
try {
|
|
@@ -51176,7 +51208,7 @@ function scopeFreshnessMismatches(reviewed, current) {
|
|
|
51176
51208
|
}
|
|
51177
51209
|
function createScopeVerifier(input, reviewed, maxBytes) {
|
|
51178
51210
|
return async () => {
|
|
51179
|
-
const current = await
|
|
51211
|
+
const current = await _internals76.collectReviewDiff({
|
|
51180
51212
|
directory: input.directory,
|
|
51181
51213
|
selector: input.selector,
|
|
51182
51214
|
maxBytes
|
|
@@ -51185,7 +51217,7 @@ function createScopeVerifier(input, reviewed, maxBytes) {
|
|
|
51185
51217
|
};
|
|
51186
51218
|
}
|
|
51187
51219
|
async function stalePersistenceResult(input, maxBytes, message, modelCalls) {
|
|
51188
|
-
const current = await
|
|
51220
|
+
const current = await _internals76.collectReviewDiff({
|
|
51189
51221
|
directory: input.directory,
|
|
51190
51222
|
selector: input.selector,
|
|
51191
51223
|
maxBytes
|
|
@@ -51564,7 +51596,7 @@ async function persistErrorResult(input, diff, result, error2, dispatches, promp
|
|
|
51564
51596
|
evidence2.review.error = error2;
|
|
51565
51597
|
addCost(evidence2, dispatches);
|
|
51566
51598
|
try {
|
|
51567
|
-
result.evidencePath = await
|
|
51599
|
+
result.evidencePath = await _internals76.persistEvidence(input.directory, evidence2);
|
|
51568
51600
|
} catch {
|
|
51569
51601
|
if (input.config.final_review.mode === "gate") {
|
|
51570
51602
|
result.blocked = true;
|
|
@@ -51580,7 +51612,7 @@ async function runReviewEngine(input) {
|
|
|
51580
51612
|
const gateMode = input.config.final_review.mode === "gate";
|
|
51581
51613
|
const maxBytes = input.trigger === "task_completion" ? input.config.max_diff_kb * 1024 : input.config.final_review.max_diff_bytes;
|
|
51582
51614
|
const timeoutMs = input.trigger === "task_completion" ? input.config.timeout_ms : input.config.final_review.timeout_ms;
|
|
51583
|
-
const diff = await
|
|
51615
|
+
const diff = await _internals76.collectReviewDiff({
|
|
51584
51616
|
directory: input.directory,
|
|
51585
51617
|
selector: input.selector,
|
|
51586
51618
|
maxBytes
|
|
@@ -51594,7 +51626,7 @@ async function runReviewEngine(input) {
|
|
|
51594
51626
|
const evidence3 = baseEvidence(input, diff, "clean");
|
|
51595
51627
|
let evidencePath2;
|
|
51596
51628
|
try {
|
|
51597
|
-
evidencePath2 = await
|
|
51629
|
+
evidencePath2 = await _internals76.persistEvidence(input.directory, evidence3, { verifyCurrent: createScopeVerifier(input, diff, maxBytes) });
|
|
51598
51630
|
} catch (error2) {
|
|
51599
51631
|
if (error2 instanceof ReviewScopeStaleError) {
|
|
51600
51632
|
return stalePersistenceResult(input, maxBytes, "Review scope changed before clean evidence could be committed.", 0);
|
|
@@ -51616,7 +51648,7 @@ async function runReviewEngine(input) {
|
|
|
51616
51648
|
phase: input.phase
|
|
51617
51649
|
});
|
|
51618
51650
|
if (input.phase !== undefined && (input.trigger === "phase_completion" || input.trigger === "plan_completion")) {
|
|
51619
|
-
const existing =
|
|
51651
|
+
const existing = _internals76.readPhaseEvidence(input.directory, input.phase);
|
|
51620
51652
|
const integrity = existing ? validateAutoReviewEvidenceIntegrity(input.directory, existing, {
|
|
51621
51653
|
scopeHash: diff.scopeHash,
|
|
51622
51654
|
phase: input.phase,
|
|
@@ -51742,7 +51774,7 @@ async function runReviewEngine(input) {
|
|
|
51742
51774
|
validation: byId.get(finding.finding_id)
|
|
51743
51775
|
}));
|
|
51744
51776
|
}
|
|
51745
|
-
const currentScope = await
|
|
51777
|
+
const currentScope = await _internals76.collectReviewDiff({
|
|
51746
51778
|
directory: input.directory,
|
|
51747
51779
|
selector: input.selector,
|
|
51748
51780
|
maxBytes
|
|
@@ -51821,7 +51853,7 @@ async function runReviewEngine(input) {
|
|
|
51821
51853
|
findingValidations: findings.map((finding) => finding.validation).filter((item) => Boolean(item))
|
|
51822
51854
|
});
|
|
51823
51855
|
receiptId = receipt.id;
|
|
51824
|
-
receiptPath = await
|
|
51856
|
+
receiptPath = await _internals76.persistReceipt(input.directory, receipt, {
|
|
51825
51857
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
51826
51858
|
});
|
|
51827
51859
|
evidence2.receipt_path = receiptPath;
|
|
@@ -51851,7 +51883,7 @@ async function runReviewEngine(input) {
|
|
|
51851
51883
|
}
|
|
51852
51884
|
let evidencePath;
|
|
51853
51885
|
try {
|
|
51854
|
-
evidencePath = await
|
|
51886
|
+
evidencePath = await _internals76.persistEvidence(input.directory, evidence2, {
|
|
51855
51887
|
verifyCurrent: createScopeVerifier(input, diff, maxBytes)
|
|
51856
51888
|
});
|
|
51857
51889
|
} catch (error2) {
|
|
@@ -51888,7 +51920,7 @@ async function runReviewEngine(input) {
|
|
|
51888
51920
|
input.injectAdvisory?.(input.sessionID, advisoryMessage(input, result));
|
|
51889
51921
|
return result;
|
|
51890
51922
|
}
|
|
51891
|
-
var
|
|
51923
|
+
var _internals76 = {
|
|
51892
51924
|
collectReviewDiff,
|
|
51893
51925
|
persistEvidence: persistAutoReviewEvidence,
|
|
51894
51926
|
persistReceipt: persistReviewReceipt,
|
|
@@ -52159,7 +52191,7 @@ async function handleReviewCommand(ctx) {
|
|
|
52159
52191
|
} catch (error2) {
|
|
52160
52192
|
return `Review configuration error: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
52161
52193
|
}
|
|
52162
|
-
const result = await
|
|
52194
|
+
const result = await _internals77.runReviewEngine({
|
|
52163
52195
|
directory: ctx.directory,
|
|
52164
52196
|
sessionID: ctx.sessionID,
|
|
52165
52197
|
trigger: "manual",
|
|
@@ -52173,10 +52205,10 @@ async function handleReviewCommand(ctx) {
|
|
|
52173
52205
|
validatorModel,
|
|
52174
52206
|
validatorFallbackModels
|
|
52175
52207
|
});
|
|
52176
|
-
const evidence2 =
|
|
52208
|
+
const evidence2 = _internals77.readEvidence(result.evidencePath, ctx.directory);
|
|
52177
52209
|
return parsed.json ? renderJson(result, evidence2, parsed.selector) : renderHuman(result, evidence2, parsed.selector);
|
|
52178
52210
|
}
|
|
52179
|
-
var
|
|
52211
|
+
var _internals77 = {
|
|
52180
52212
|
runReviewEngine,
|
|
52181
52213
|
readEvidence
|
|
52182
52214
|
};
|
|
@@ -52327,7 +52359,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
52327
52359
|
if (checkpointFiles.length === 0) {
|
|
52328
52360
|
return `Error: Checkpoint for phase ${targetPhase} is empty. Cannot rollback.`;
|
|
52329
52361
|
}
|
|
52330
|
-
const swarmDir = validateSwarmPath(directory, "");
|
|
52362
|
+
const swarmDir = path93.dirname(validateSwarmPath(directory, ".keep"));
|
|
52331
52363
|
const EXCLUDE_FILES = new Set([
|
|
52332
52364
|
"plan-ledger.jsonl",
|
|
52333
52365
|
"plan-ledger.quarantine"
|
|
@@ -52348,6 +52380,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
52348
52380
|
failures.push({ file, error: error2.message });
|
|
52349
52381
|
}
|
|
52350
52382
|
}
|
|
52383
|
+
resetSwarmArtifactCache();
|
|
52351
52384
|
if (failures.length > 0) {
|
|
52352
52385
|
return [
|
|
52353
52386
|
`Rollback partially completed. Successfully restored ${successes.length} files.`,
|
|
@@ -52421,7 +52454,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
52421
52454
|
// src/commands/sdd.ts
|
|
52422
52455
|
import * as fs47 from "fs";
|
|
52423
52456
|
import * as path94 from "path";
|
|
52424
|
-
var
|
|
52457
|
+
var _internals78 = {
|
|
52425
52458
|
writeProjectedSpecSync
|
|
52426
52459
|
};
|
|
52427
52460
|
var SWARM_SPEC_REL = path94.join(".swarm", "spec.md");
|
|
@@ -52817,7 +52850,7 @@ ${USAGE12}`;
|
|
|
52817
52850
|
|
|
52818
52851
|
${USAGE12}`;
|
|
52819
52852
|
}
|
|
52820
|
-
const result2 =
|
|
52853
|
+
const result2 = _internals78.writeProjectedSpecSync(directory, {
|
|
52821
52854
|
source: "speckit",
|
|
52822
52855
|
feature: resolution.feature,
|
|
52823
52856
|
dryRun: parsed.dryRun,
|
|
@@ -52875,7 +52908,7 @@ ${formatList(result2.projection.warnings)}` : ""
|
|
|
52875
52908
|
].join(`
|
|
52876
52909
|
`);
|
|
52877
52910
|
}
|
|
52878
|
-
const result =
|
|
52911
|
+
const result = _internals78.writeProjectedSpecSync(directory, {
|
|
52879
52912
|
changeId: parsed.changeId,
|
|
52880
52913
|
dryRun: parsed.dryRun,
|
|
52881
52914
|
overwrite: parsed.overwrite
|
|
@@ -52956,7 +52989,7 @@ async function handleSimulateCommand(directory, args) {
|
|
|
52956
52989
|
}
|
|
52957
52990
|
let darkMatterPairs;
|
|
52958
52991
|
try {
|
|
52959
|
-
darkMatterPairs = await
|
|
52992
|
+
darkMatterPairs = await _internals39.detectDarkMatter(directory, options);
|
|
52960
52993
|
} catch (err) {
|
|
52961
52994
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
52962
52995
|
return `## Simulate Report
|
|
@@ -53114,7 +53147,7 @@ function writeFileFsyncedThenRename(tempPath, targetPath, data) {
|
|
|
53114
53147
|
throw err;
|
|
53115
53148
|
}
|
|
53116
53149
|
}
|
|
53117
|
-
var
|
|
53150
|
+
var _internals79 = {
|
|
53118
53151
|
withEvidenceLock,
|
|
53119
53152
|
writeFileFsyncedThenRename,
|
|
53120
53153
|
writeFileSync: writeFileSyncAsync,
|
|
@@ -53133,7 +53166,7 @@ async function appendEvent(directory, eventInput) {
|
|
|
53133
53166
|
}
|
|
53134
53167
|
const filePath = ledgerPath(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
53135
53168
|
ensureCandidateDir(directory, eventInput.skillSlug, eventInput.candidateId);
|
|
53136
|
-
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 () => {
|
|
53137
53170
|
const existing = existsSync53(filePath) ? readFileSync39(filePath, "utf8") : "";
|
|
53138
53171
|
const events = parseEventsFromText(existing);
|
|
53139
53172
|
const nextSeq = events.length === 0 ? 1 : events[events.length - 1].seq + 1;
|
|
@@ -53164,8 +53197,8 @@ async function appendEvent(directory, eventInput) {
|
|
|
53164
53197
|
const validContent = events.map((e) => JSON.stringify(e)).join(`
|
|
53165
53198
|
`) + (events.length > 0 ? `
|
|
53166
53199
|
` : "");
|
|
53167
|
-
|
|
53168
|
-
const verify = parseEventsFromText(
|
|
53200
|
+
_internals79.writeFileFsyncedThenRename(tempPath, filePath, validContent + line);
|
|
53201
|
+
const verify = parseEventsFromText(_internals79.readFileSync(filePath, "utf8"));
|
|
53169
53202
|
const last = verify.length > 0 ? verify[verify.length - 1] : null;
|
|
53170
53203
|
if (!last || last.seq !== event.seq || last.hashAfter !== event.hashAfter) {
|
|
53171
53204
|
throw new Error(`skill-opt ledger append verification failed for candidate ${event.candidateId} seq ${event.seq}`);
|
|
@@ -53267,14 +53300,14 @@ function writeStateProjection(directory, skillSlug, candidateId2, replay) {
|
|
|
53267
53300
|
updatedAt: new Date().toISOString()
|
|
53268
53301
|
};
|
|
53269
53302
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
53270
|
-
|
|
53303
|
+
_internals79.writeFileFsyncedThenRename(tempPath, target, `${JSON.stringify(projection, null, 2)}
|
|
53271
53304
|
`);
|
|
53272
53305
|
}
|
|
53273
53306
|
function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
|
|
53274
53307
|
const dir = ensureCandidateDir(directory, skillSlug, candidateId2);
|
|
53275
53308
|
const target = path95.join(dir, fileName);
|
|
53276
53309
|
const tempPath = `${target}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
53277
|
-
|
|
53310
|
+
_internals79.writeFileFsyncedThenRename(tempPath, target, content);
|
|
53278
53311
|
return target;
|
|
53279
53312
|
}
|
|
53280
53313
|
function readArtifact(directory, skillSlug, candidateId2, fileName) {
|
|
@@ -53367,16 +53400,16 @@ function currentCandidateState(directory, skillSlug, candidateId2) {
|
|
|
53367
53400
|
function writeSkillFileAtomic(targetPath, content) {
|
|
53368
53401
|
const tempPath = `${targetPath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
53369
53402
|
try {
|
|
53370
|
-
|
|
53371
|
-
|
|
53403
|
+
_internals80.writeFileSync(tempPath, content, "utf8");
|
|
53404
|
+
_internals80.renameSync(tempPath, targetPath);
|
|
53372
53405
|
} finally {
|
|
53373
53406
|
try {
|
|
53374
53407
|
if (existsSync54(tempPath))
|
|
53375
|
-
|
|
53408
|
+
_internals80.unlinkSync(tempPath);
|
|
53376
53409
|
} catch {}
|
|
53377
53410
|
}
|
|
53378
53411
|
}
|
|
53379
|
-
var
|
|
53412
|
+
var _internals80 = {
|
|
53380
53413
|
writeFileSync: writeFileSync18,
|
|
53381
53414
|
renameSync: renameSync19,
|
|
53382
53415
|
unlinkSync: unlinkSync21
|
|
@@ -53833,7 +53866,7 @@ function buildGeneratorInputs(args) {
|
|
|
53833
53866
|
}
|
|
53834
53867
|
};
|
|
53835
53868
|
}
|
|
53836
|
-
var
|
|
53869
|
+
var _internals81 = {
|
|
53837
53870
|
draftDeterministic: defaultDeterministicDraft
|
|
53838
53871
|
};
|
|
53839
53872
|
function defaultDeterministicDraft(inputs) {
|
|
@@ -53903,7 +53936,7 @@ function countChangedLines(a, b) {
|
|
|
53903
53936
|
return changed;
|
|
53904
53937
|
}
|
|
53905
53938
|
function draftCandidate(inputs) {
|
|
53906
|
-
const candidate2 =
|
|
53939
|
+
const candidate2 = _internals81.draftDeterministic(inputs);
|
|
53907
53940
|
enforceTrustRegion(candidate2, inputs.budget);
|
|
53908
53941
|
return candidate2;
|
|
53909
53942
|
}
|
|
@@ -53946,7 +53979,7 @@ import * as path98 from "path";
|
|
|
53946
53979
|
// src/hooks/spawn-helper.ts
|
|
53947
53980
|
import * as child_process8 from "child_process";
|
|
53948
53981
|
var WIN32_CMD_BINARIES = new Set(["npm", "npx", "pnpm", "yarn"]);
|
|
53949
|
-
var
|
|
53982
|
+
var _internals82 = {
|
|
53950
53983
|
spawn: child_process8.spawn
|
|
53951
53984
|
};
|
|
53952
53985
|
function spawnAsync(command, cwd, timeoutMs) {
|
|
@@ -53954,7 +53987,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
53954
53987
|
try {
|
|
53955
53988
|
const [rawCmd, ...args] = command;
|
|
53956
53989
|
const cmd = process.platform === "win32" && WIN32_CMD_BINARIES.has(rawCmd) && !rawCmd.includes(".") ? `${rawCmd}.cmd` : rawCmd;
|
|
53957
|
-
const proc =
|
|
53990
|
+
const proc = _internals82.spawn(cmd, args, {
|
|
53958
53991
|
cwd,
|
|
53959
53992
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53960
53993
|
});
|
|
@@ -54020,7 +54053,7 @@ function spawnAsync(command, cwd, timeoutMs) {
|
|
|
54020
54053
|
}
|
|
54021
54054
|
|
|
54022
54055
|
// src/services/skill-optimizer/smoke.ts
|
|
54023
|
-
var
|
|
54056
|
+
var _internals83 = {
|
|
54024
54057
|
validateSkillPath,
|
|
54025
54058
|
isSymbolicLink: (p) => {
|
|
54026
54059
|
try {
|
|
@@ -54041,7 +54074,7 @@ var _internals82 = {
|
|
|
54041
54074
|
async function validateSkillSmoke(input) {
|
|
54042
54075
|
const notes = [];
|
|
54043
54076
|
const repoRel = path98.join(".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
|
|
54044
|
-
if (!
|
|
54077
|
+
if (!_internals83.validateSkillPath(repoRel)) {
|
|
54045
54078
|
return {
|
|
54046
54079
|
ok: false,
|
|
54047
54080
|
verdict: "VIOLATED",
|
|
@@ -54050,16 +54083,16 @@ async function validateSkillSmoke(input) {
|
|
|
54050
54083
|
}
|
|
54051
54084
|
const skillRoot = path98.join(input.directory, ".opencode", "skills", "generated", input.skillSlug);
|
|
54052
54085
|
if (existsSync55(skillRoot)) {
|
|
54053
|
-
if (
|
|
54086
|
+
if (_internals83.isSymbolicLink(skillRoot)) {
|
|
54054
54087
|
return {
|
|
54055
54088
|
ok: false,
|
|
54056
54089
|
verdict: "VIOLATED",
|
|
54057
54090
|
notes: ["skill root is a symlink (reparse denied)"]
|
|
54058
54091
|
};
|
|
54059
54092
|
}
|
|
54060
|
-
const realRoot =
|
|
54061
|
-
const realProjectDir =
|
|
54062
|
-
if (
|
|
54093
|
+
const realRoot = _internals83.realpath(skillRoot);
|
|
54094
|
+
const realProjectDir = _internals83.realpath(input.directory);
|
|
54095
|
+
if (_internals83.escapedRoot(realProjectDir, realRoot)) {
|
|
54063
54096
|
return {
|
|
54064
54097
|
ok: false,
|
|
54065
54098
|
verdict: "VIOLATED",
|
|
@@ -54077,7 +54110,7 @@ async function validateSkillSmoke(input) {
|
|
|
54077
54110
|
notes: [`frontmatter: ${fmError}`]
|
|
54078
54111
|
};
|
|
54079
54112
|
}
|
|
54080
|
-
const rejected = await
|
|
54113
|
+
const rejected = await _internals83.isRejectedSkillContent(input.directory, input.skillSlug, input.candidateContent);
|
|
54081
54114
|
if (rejected) {
|
|
54082
54115
|
return {
|
|
54083
54116
|
ok: false,
|
|
@@ -54087,7 +54120,7 @@ async function validateSkillSmoke(input) {
|
|
|
54087
54120
|
]
|
|
54088
54121
|
};
|
|
54089
54122
|
}
|
|
54090
|
-
const evalResult = await
|
|
54123
|
+
const evalResult = await _internals83.evaluateSkillChange({
|
|
54091
54124
|
directory: input.directory,
|
|
54092
54125
|
slug: input.skillSlug,
|
|
54093
54126
|
candidateContent: input.candidateContent,
|
|
@@ -54106,7 +54139,7 @@ async function validateSkillSmoke(input) {
|
|
|
54106
54139
|
notes.push(`phrase-eval passed (score ${evalResult.candidateScore.toFixed(2)})`);
|
|
54107
54140
|
}
|
|
54108
54141
|
if (input.checkCommand && input.checkCommand.length > 0) {
|
|
54109
|
-
const cmdResult = await
|
|
54142
|
+
const cmdResult = await _internals83.spawnAsync(input.checkCommand, input.directory, input.checkTimeoutMs ?? 60000);
|
|
54110
54143
|
if (!cmdResult || cmdResult.exitCode !== 0) {
|
|
54111
54144
|
return {
|
|
54112
54145
|
ok: false,
|
|
@@ -54176,14 +54209,14 @@ async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, base
|
|
|
54176
54209
|
candidate2.contentHash = await computeCandidateInputContentHash2(inputRoot, candidate2);
|
|
54177
54210
|
return { baseline, candidate: candidate2 };
|
|
54178
54211
|
}
|
|
54179
|
-
var
|
|
54212
|
+
var _internals84 = {
|
|
54180
54213
|
tryAcquireLock,
|
|
54181
54214
|
emitTelemetry: emit,
|
|
54182
54215
|
evaluateCandidateV1,
|
|
54183
54216
|
prepareCandidatePayloads
|
|
54184
54217
|
};
|
|
54185
54218
|
async function acquireProjectLock(directory) {
|
|
54186
|
-
const result = await
|
|
54219
|
+
const result = await _internals84.tryAcquireLock(directory, PROJECT_LOCK_PATH, "skill-opt-controller", "project-run");
|
|
54187
54220
|
if (!result.acquired)
|
|
54188
54221
|
return null;
|
|
54189
54222
|
return async () => {
|
|
@@ -54196,7 +54229,7 @@ async function acquireProjectLock(directory) {
|
|
|
54196
54229
|
}
|
|
54197
54230
|
async function acquireSkillLock(directory, skillSlug) {
|
|
54198
54231
|
const lockPath = path99.join(".swarm", "evolution", "skills", skillSlug, ".skill.lock");
|
|
54199
|
-
const result = await
|
|
54232
|
+
const result = await _internals84.tryAcquireLock(directory, lockPath, "skill-opt-controller", `skill-${skillSlug}`);
|
|
54200
54233
|
if (!result.acquired)
|
|
54201
54234
|
return null;
|
|
54202
54235
|
return async () => {
|
|
@@ -54393,13 +54426,13 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
54393
54426
|
while (true) {
|
|
54394
54427
|
try {
|
|
54395
54428
|
const evalInputRoot = input.inputRoot ?? input.directory;
|
|
54396
|
-
const { baseline, candidate: candidate2 } = await
|
|
54429
|
+
const { baseline, candidate: candidate2 } = await _internals84.prepareCandidatePayloads(evalInputRoot, candidateId2, input.skillSlug, input.baselineModel, input.candidateModel, baselineContent, candidateContent);
|
|
54397
54430
|
if (!input.dispatcher) {
|
|
54398
54431
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
54399
54432
|
}
|
|
54400
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
54433
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-w30gazew.js");
|
|
54401
54434
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
54402
|
-
const result = await
|
|
54435
|
+
const result = await _internals84.evaluateCandidateV1({
|
|
54403
54436
|
projectRoot: input.directory,
|
|
54404
54437
|
inputRoot: input.inputRoot ?? input.directory,
|
|
54405
54438
|
tasks: input.validationTasks,
|
|
@@ -54457,7 +54490,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
54457
54490
|
deadband: input.config.deadband
|
|
54458
54491
|
};
|
|
54459
54492
|
}
|
|
54460
|
-
|
|
54493
|
+
_internals84.emitTelemetry?.("loop_detected", {
|
|
54461
54494
|
skillSlug: input.skillSlug,
|
|
54462
54495
|
reason: message.slice(0, 160),
|
|
54463
54496
|
source: "skill-opt-controller"
|
|
@@ -55297,19 +55330,8 @@ function getCompactionMetrics(sessionId) {
|
|
|
55297
55330
|
return { compactionCount: total, lastSnapshotAt: lastSnapshot };
|
|
55298
55331
|
}
|
|
55299
55332
|
|
|
55300
|
-
// src/services/context-budget-service.ts
|
|
55301
|
-
init_logger();
|
|
55302
|
-
var DEFAULT_CONTEXT_BUDGET_CONFIG = {
|
|
55303
|
-
enabled: true,
|
|
55304
|
-
budgetTokens: 40000,
|
|
55305
|
-
warningPct: 70,
|
|
55306
|
-
criticalPct: 90,
|
|
55307
|
-
warningMode: "once",
|
|
55308
|
-
warningIntervalTurns: 20
|
|
55309
|
-
};
|
|
55310
|
-
|
|
55311
55333
|
// src/services/status-service.ts
|
|
55312
|
-
var
|
|
55334
|
+
var _internals85 = {
|
|
55313
55335
|
loadLeanTurboRunState,
|
|
55314
55336
|
hasActiveLeanTurbo,
|
|
55315
55337
|
hasActiveFullAuto,
|
|
@@ -55371,6 +55393,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55371
55393
|
isLegacy: false,
|
|
55372
55394
|
turboMode: hasActiveTurboMode(),
|
|
55373
55395
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
55396
|
+
contextBudgetTokens: swarmState.lastBudgetTokens > 0 ? swarmState.lastBudgetTokens : null,
|
|
55374
55397
|
compactionCount: metrics.compactionCount,
|
|
55375
55398
|
lastSnapshotAt: metrics.lastSnapshotAt
|
|
55376
55399
|
};
|
|
@@ -55387,6 +55410,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55387
55410
|
isLegacy: true,
|
|
55388
55411
|
turboMode: hasActiveTurboMode(),
|
|
55389
55412
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
55413
|
+
contextBudgetTokens: swarmState.lastBudgetTokens > 0 ? swarmState.lastBudgetTokens : null,
|
|
55390
55414
|
compactionCount: metrics.compactionCount,
|
|
55391
55415
|
lastSnapshotAt: metrics.lastSnapshotAt
|
|
55392
55416
|
};
|
|
@@ -55406,6 +55430,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55406
55430
|
isLegacy: true,
|
|
55407
55431
|
turboMode: hasActiveTurboMode(),
|
|
55408
55432
|
contextBudgetPct: swarmState.lastBudgetPct > 0 ? swarmState.lastBudgetPct : null,
|
|
55433
|
+
contextBudgetTokens: swarmState.lastBudgetTokens > 0 ? swarmState.lastBudgetTokens : null,
|
|
55409
55434
|
compactionCount: metrics.compactionCount,
|
|
55410
55435
|
lastSnapshotAt: metrics.lastSnapshotAt
|
|
55411
55436
|
};
|
|
@@ -55485,11 +55510,11 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55485
55510
|
} catch {
|
|
55486
55511
|
status.memoryCohort = { linked: false };
|
|
55487
55512
|
}
|
|
55488
|
-
status.fullAutoActive =
|
|
55513
|
+
status.fullAutoActive = _internals85.hasActiveFullAuto();
|
|
55489
55514
|
if (status.fullAutoActive) {
|
|
55490
|
-
const sid =
|
|
55515
|
+
const sid = _internals85.getActiveFullAutoSessionID();
|
|
55491
55516
|
if (sid) {
|
|
55492
|
-
const runState =
|
|
55517
|
+
const runState = _internals85.loadFullAutoRunState(directory, sid);
|
|
55493
55518
|
if (runState?.lastEscalation) {
|
|
55494
55519
|
status.fullAutoEscalation = {
|
|
55495
55520
|
reason: runState.lastEscalation.reason,
|
|
@@ -55523,7 +55548,7 @@ async function getStatusData(directory, agents, sessionId) {
|
|
|
55523
55548
|
}
|
|
55524
55549
|
function enrichWithLeanTurbo(status, directory) {
|
|
55525
55550
|
const turboMode = hasActiveTurboMode();
|
|
55526
|
-
const leanActive =
|
|
55551
|
+
const leanActive = _internals85.hasActiveLeanTurbo();
|
|
55527
55552
|
let turboStrategy = "off";
|
|
55528
55553
|
if (leanActive) {
|
|
55529
55554
|
turboStrategy = "lean";
|
|
@@ -55554,7 +55579,7 @@ function enrichWithLeanTurbo(status, directory) {
|
|
|
55554
55579
|
}
|
|
55555
55580
|
}
|
|
55556
55581
|
if (leanSessionID) {
|
|
55557
|
-
const runState =
|
|
55582
|
+
const runState = _internals85.loadLeanTurboRunState(directory, leanSessionID);
|
|
55558
55583
|
if (runState) {
|
|
55559
55584
|
status.leanTurboPhase = runState.phase;
|
|
55560
55585
|
status.leanMaxParallelCoders = runState.maxParallelCoders;
|
|
@@ -55654,9 +55679,13 @@ function formatStatusMarkdown(status) {
|
|
|
55654
55679
|
}
|
|
55655
55680
|
if (status.contextBudgetPct !== null && status.contextBudgetPct > 0) {
|
|
55656
55681
|
const pct = status.contextBudgetPct.toFixed(1);
|
|
55657
|
-
const budgetTokens =
|
|
55658
|
-
|
|
55659
|
-
|
|
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
|
+
}
|
|
55660
55689
|
if (status.compactionCount > 0) {
|
|
55661
55690
|
lines.push(`**Compaction events**: ${status.compactionCount} triggered`);
|
|
55662
55691
|
}
|
|
@@ -55805,7 +55834,7 @@ init_logger();
|
|
|
55805
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).";
|
|
55806
55835
|
|
|
55807
55836
|
// src/commands/turbo.ts
|
|
55808
|
-
var
|
|
55837
|
+
var _internals86 = {
|
|
55809
55838
|
loadPluginConfigWithMeta
|
|
55810
55839
|
};
|
|
55811
55840
|
async function handleTurboCommand(directory, args, sessionID) {
|
|
@@ -55865,7 +55894,7 @@ async function handleTurboCommand(directory, args, sessionID) {
|
|
|
55865
55894
|
if (arg0 === "on") {
|
|
55866
55895
|
let strategy = "standard";
|
|
55867
55896
|
try {
|
|
55868
|
-
const { config } =
|
|
55897
|
+
const { config } = _internals86.loadPluginConfigWithMeta(directory);
|
|
55869
55898
|
if (config.turbo?.strategy === "lean") {
|
|
55870
55899
|
strategy = "lean";
|
|
55871
55900
|
}
|
|
@@ -55962,7 +55991,7 @@ function enableLeanTurbo(session, directory, sessionID) {
|
|
|
55962
55991
|
let maxParallelCoders = 4;
|
|
55963
55992
|
let conflictPolicy = "serialize";
|
|
55964
55993
|
try {
|
|
55965
|
-
const { config } =
|
|
55994
|
+
const { config } = _internals86.loadPluginConfigWithMeta(directory);
|
|
55966
55995
|
const leanConfig = config.turbo?.lean;
|
|
55967
55996
|
if (leanConfig) {
|
|
55968
55997
|
maxParallelCoders = leanConfig.max_parallel_coders ?? 4;
|
|
@@ -56225,7 +56254,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
56225
56254
|
async function handleHelpCommand(ctx) {
|
|
56226
56255
|
const targetCommand = ctx.args.join(" ");
|
|
56227
56256
|
if (!targetCommand) {
|
|
56228
|
-
const { buildHelpText } = await import("./index-
|
|
56257
|
+
const { buildHelpText } = await import("./index-xka8s8jw.js");
|
|
56229
56258
|
return buildHelpText();
|
|
56230
56259
|
}
|
|
56231
56260
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -56234,7 +56263,7 @@ async function handleHelpCommand(ctx) {
|
|
|
56234
56263
|
return _internals14.buildDetailedHelp(resolved.key, resolved.entry);
|
|
56235
56264
|
}
|
|
56236
56265
|
const similar = _internals14.findSimilarCommands(targetCommand);
|
|
56237
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
56266
|
+
const { buildHelpText: fullHelp } = await import("./index-xka8s8jw.js");
|
|
56238
56267
|
if (similar.length > 0) {
|
|
56239
56268
|
return `Command '/swarm ${targetCommand}' not found.
|
|
56240
56269
|
|
|
@@ -56411,7 +56440,7 @@ var COMMAND_REGISTRY = {
|
|
|
56411
56440
|
},
|
|
56412
56441
|
"guardrail explain": {
|
|
56413
56442
|
handler: async (ctx) => {
|
|
56414
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
56443
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-vb9k9zwm.js");
|
|
56415
56444
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
56416
56445
|
},
|
|
56417
56446
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -56421,7 +56450,7 @@ var COMMAND_REGISTRY = {
|
|
|
56421
56450
|
},
|
|
56422
56451
|
"guardrail-explain": {
|
|
56423
56452
|
handler: async (ctx) => {
|
|
56424
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
56453
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-vb9k9zwm.js");
|
|
56425
56454
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
56426
56455
|
},
|
|
56427
56456
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -56431,7 +56460,7 @@ var COMMAND_REGISTRY = {
|
|
|
56431
56460
|
},
|
|
56432
56461
|
"guardrail-log": {
|
|
56433
56462
|
handler: async (ctx) => {
|
|
56434
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
56463
|
+
const { handleGuardrailLog } = await import("./guardrail-log-0djnvfas.js");
|
|
56435
56464
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
56436
56465
|
},
|
|
56437
56466
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -57901,10 +57930,11 @@ For every applicable directive in the block:
|
|
|
57901
57930
|
- Cite \`KNOWLEDGE_APPLIED: <id>\` in the next plan / delegation / gate action that complies with it.
|
|
57902
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.
|
|
57903
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.
|
|
57904
57934
|
- If runtime evidence shows a directive was violated (reviewer rejection, failing test, scope breach), record \`KNOWLEDGE_VIOLATED: <id> reason=<reason>\` and re-plan.
|
|
57905
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.
|
|
57906
57936
|
|
|
57907
|
-
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.
|
|
57908
57938
|
|
|
57909
57939
|
## SKILL IMPROVER (low-frequency, expensive-model adviser)
|
|
57910
57940
|
|
|
@@ -59454,7 +59484,7 @@ WRONG: "I'll use the Task tool to call another agent to review this code"
|
|
|
59454
59484
|
RIGHT: "I'll read the changed files and review them myself"
|
|
59455
59485
|
|
|
59456
59486
|
## KNOWLEDGE RECEIPTS
|
|
59457
|
-
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.
|
|
59458
59488
|
|
|
59459
59489
|
${READ_ONLY_LANE_GUIDANCE}
|
|
59460
59490
|
|
|
@@ -59941,11 +59971,11 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
|
|
|
59941
59971
|
return;
|
|
59942
59972
|
return async (_systemPrompt, userInput, signal) => {
|
|
59943
59973
|
let ephemeralSessionId;
|
|
59944
|
-
const cleanup = () => {
|
|
59974
|
+
const cleanup = async () => {
|
|
59945
59975
|
if (ephemeralSessionId) {
|
|
59946
59976
|
const id = ephemeralSessionId;
|
|
59947
59977
|
ephemeralSessionId = undefined;
|
|
59948
|
-
client.session
|
|
59978
|
+
await teardownEphemeralSession(client.session, id);
|
|
59949
59979
|
}
|
|
59950
59980
|
};
|
|
59951
59981
|
if (signal?.aborted) {
|
|
@@ -60015,7 +60045,7 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
|
|
|
60015
60045
|
}
|
|
60016
60046
|
throw err;
|
|
60017
60047
|
} finally {
|
|
60018
|
-
cleanup();
|
|
60048
|
+
await cleanup();
|
|
60019
60049
|
}
|
|
60020
60050
|
};
|
|
60021
60051
|
}
|