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