opencode-swarm 7.148.4 → 7.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/{config-doctor-ycf9ws4p.js → config-doctor-fx8d6pma.js} +3 -3
- package/dist/cli/{core-a1bhs3xa.js → core-0v762txd.js} +3 -3
- package/dist/cli/{curation-policy-fbvctttr.js → curation-policy-4jxx3ey4.js} +6 -6
- package/dist/cli/{curator-8y57gq1g.js → curator-6w4frzdz.js} +32 -31
- package/dist/cli/{curator-llm-factory-rj4vw5fd.js → curator-llm-factory-8fstpeqh.js} +32 -31
- package/dist/cli/{evidence-summary-service-wkp0gfpd.js → evidence-summary-service-x00z38n2.js} +15 -14
- package/dist/cli/{gate-evidence-qty15skw.js → gate-evidence-ejdek2td.js} +9 -9
- package/dist/cli/{guardrail-explain-2n3ahs0m.js → guardrail-explain-nynjhbzk.js} +33 -32
- package/dist/cli/{guardrail-log-bmxrb3r2.js → guardrail-log-6bktj08e.js} +6 -4
- package/dist/cli/{guardrail-reset-be3sx0am.js → guardrail-reset-hsfd5ykq.js} +32 -31
- package/dist/cli/{hive-promoter-te5d78yt.js → hive-promoter-32artf8c.js} +32 -31
- package/dist/cli/{index-sxtz2d26.js → index-01q7mb83.js} +6 -6
- package/dist/cli/{index-yq89bgnz.js → index-41n0thtd.js} +2 -1
- package/dist/cli/{index-bccfz7br.js → index-42habrdv.js} +4 -4
- package/dist/cli/{index-622phhp5.js → index-5q5ws00e.js} +11 -11
- package/dist/cli/{index-9m8jy3av.js → index-6thxr1q7.js} +3 -3
- package/dist/cli/{index-6kw1a3bk.js → index-79pwr8hc.js} +9 -12
- package/dist/cli/{index-gswx08pr.js → index-8hkxm9mh.js} +4 -4
- package/dist/cli/{index-qpewzk0q.js → index-8yan955h.js} +2 -2
- package/dist/cli/{index-vrp2zva8.js → index-a90c1gtn.js} +1 -1
- package/dist/cli/{index-kg4knw6r.js → index-ame8ek9g.js} +7 -6
- package/dist/cli/{index-hj1xd3pg.js → index-bcfcekx9.js} +1314 -371
- package/dist/cli/{index-nq4tkfpc.js → index-bmaz2yy4.js} +1 -1
- package/dist/cli/{index-k1s8gxjh.js → index-c1h0rdkr.js} +1 -1
- package/dist/cli/index-c83bztkp.js +881 -0
- package/dist/cli/{index-1vbmra32.js → index-ccyve4pb.js} +1 -1
- package/dist/cli/{index-vhefvcta.js → index-cfvbd3dg.js} +2 -2
- package/dist/cli/{index-ye7kpzrk.js → index-ef0wracg.js} +5 -5
- package/dist/cli/{index-9qzkcmry.js → index-hbhw2qd7.js} +3 -3
- package/dist/cli/{index-rzzwem6x.js → index-ka2vav7t.js} +34 -33
- package/dist/cli/{index-b1c83zf9.js → index-kb1p6dpx.js} +18 -17
- package/dist/cli/{index-8kzrgjt6.js → index-mza55jmc.js} +4 -4
- package/dist/cli/{index-t25evmna.js → index-n6jykega.js} +1 -1
- package/dist/cli/{index-skgeytf6.js → index-pgfn8h50.js} +10 -10
- package/dist/cli/{index-7rerkeg8.js → index-q8e2yd98.js} +1 -1
- package/dist/cli/{index-w00hn0dd.js → index-s7t2c9jd.js} +2 -2
- package/dist/cli/{index-j382eh60.js → index-vfv4vnnc.js} +1 -1
- package/dist/cli/{index-qwmrt51t.js → index-wbz365gn.js} +1 -1
- package/dist/cli/{index-ghbkknjz.js → index-wj0gnab0.js} +72 -41
- package/dist/cli/{index-b94487xm.js → index-wsar7d91.js} +1 -1
- package/dist/cli/{index-0045n7qe.js → index-xdp0bx28.js} +2 -2
- package/dist/cli/{index-8djgxw2w.js → index-z6471b7r.js} +2 -2
- package/dist/cli/{index-qbvq3xt2.js → index-zkcwan96.js} +1 -1
- package/dist/cli/index.js +32 -31
- package/dist/cli/{knowledge-escalator-9w53tx55.js → knowledge-escalator-ty2kesdj.js} +14 -14
- package/dist/cli/{knowledge-events-my31zepa.js → knowledge-events-x3rd7r3j.js} +12 -12
- package/dist/cli/{knowledge-link-spw879rs.js → knowledge-link-a5f89833.js} +5 -5
- package/dist/cli/{knowledge-store-yf59mxp5.js → knowledge-store-zsz4dxjq.js} +6 -6
- package/dist/cli/{knowledge-validator-8n569fp4.js → knowledge-validator-bdhgkw9f.js} +8 -8
- package/dist/cli/{pending-delegations-f4wvyzbf.js → pending-delegations-aez8ebdr.js} +3 -3
- package/dist/cli/{pr-subscriptions-f4xw1rxy.js → pr-subscriptions-cpnwvc6y.js} +3 -3
- package/dist/cli/{runner-rk26nk58.js → runner-9mnkfjw7.js} +6 -6
- package/dist/cli/{scan-cursor-www6dbn8.js → scan-cursor-3ba1spad.js} +7 -7
- package/dist/cli/{schema-vyg0k7rh.js → schema-h251vmd1.js} +1 -1
- package/dist/cli/{scope-persistence-3qbr019s.js → scope-persistence-h1b31ba2.js} +8 -10
- package/dist/cli/{skill-generator-fh8emssb.js → skill-generator-esrn40th.js} +16 -16
- package/dist/cli/{telemetry-1pnsftp0.js → telemetry-jtq6px7k.js} +1 -1
- package/dist/cli/{workspace-snapshot-nq25j94x.js → workspace-snapshot-8269e1p9.js} +2 -2
- package/dist/cli/{worktree-collision-ownership-wqy7mgb3.js → worktree-collision-ownership-r8j31h06.js} +8 -8
- package/dist/cli/{worktree-isolation-sbsdx1yj.js → worktree-isolation-pbr4d5m9.js} +32 -31
- package/dist/commands/close.d.ts +1 -0
- package/dist/events/core-events.d.ts +250 -0
- package/dist/full-auto/oversight.d.ts +5 -3
- package/dist/hooks/full-auto-delegation.d.ts +24 -0
- package/dist/hooks/full-auto-input-probe.d.ts +11 -0
- package/dist/hooks/steering-consumed.d.ts +12 -4
- package/dist/index.js +588 -603
- package/dist/observability/catalog.d.ts +9 -7
- package/dist/sast/rules/javascript-call-classifier.d.ts +4 -0
- package/dist/services/spec-drift-recovery.d.ts +9 -2
- package/dist/telemetry.d.ts +24 -1
- package/package.json +2 -1
- package/dist/cli/{curator-drift-fv4rttf4.js → curator-drift-2h1d2fnq.js} +1 -1
- package/dist/cli/{index-g8wwj0sz.js → index-vnn7qq8c.js} +3 -3
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
resolveExecutableFromPath,
|
|
7
7
|
runEvaluation,
|
|
8
8
|
runExternalTool
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-vfv4vnnc.js";
|
|
10
10
|
import {
|
|
11
11
|
normalizeToolNameLowerCase,
|
|
12
12
|
stableCanonicalStringify
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-wsar7d91.js";
|
|
14
14
|
import {
|
|
15
15
|
detectStraySwarmDirs,
|
|
16
16
|
readDoctorArtifact,
|
|
17
17
|
removeStraySwarmDir,
|
|
18
18
|
runConfigDoctor
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-ccyve4pb.js";
|
|
20
20
|
import {
|
|
21
21
|
MAX_TRANSIENT_RETRIES,
|
|
22
22
|
archiveEvidence,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
updateTaskStatus,
|
|
63
63
|
validateProjectRoot,
|
|
64
64
|
validateSymlinkBoundary
|
|
65
|
-
} from "./index-
|
|
65
|
+
} from "./index-kb1p6dpx.js";
|
|
66
66
|
import {
|
|
67
67
|
EvaluationTaskV1Schema,
|
|
68
68
|
GateAuditManifestV1Schema,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
saveGateAuditResult,
|
|
80
80
|
savePromotionDecision,
|
|
81
81
|
saveTaskSetSnapshot
|
|
82
|
-
} from "./index-
|
|
82
|
+
} from "./index-z6471b7r.js";
|
|
83
83
|
import {
|
|
84
84
|
loadDatabaseCtor
|
|
85
85
|
} from "./index-134d35c1.js";
|
|
@@ -105,12 +105,12 @@ import {
|
|
|
105
105
|
} from "./index-y8552snf.js";
|
|
106
106
|
import {
|
|
107
107
|
readRecentEscalations
|
|
108
|
-
} from "./index-
|
|
108
|
+
} from "./index-ef0wracg.js";
|
|
109
109
|
import {
|
|
110
110
|
alreadyCuratedThisGeneration,
|
|
111
111
|
claimNextScanBatch,
|
|
112
112
|
resolveCohortId
|
|
113
|
-
} from "./index-
|
|
113
|
+
} from "./index-s7t2c9jd.js";
|
|
114
114
|
import {
|
|
115
115
|
CURATOR_INIT_PROMPT,
|
|
116
116
|
CURATOR_PHASE_PROMPT,
|
|
@@ -153,13 +153,13 @@ import {
|
|
|
153
153
|
resolveRemoteRefsContainingHead,
|
|
154
154
|
resolveRemoteRefsContainingHeadAsync,
|
|
155
155
|
switchPrFeedbackTrackingCandidateAsync
|
|
156
|
-
} from "./index-
|
|
156
|
+
} from "./index-vnn7qq8c.js";
|
|
157
157
|
import {
|
|
158
158
|
buildCorrelationId,
|
|
159
159
|
listActive,
|
|
160
160
|
subscribe,
|
|
161
161
|
unsubscribe
|
|
162
|
-
} from "./index-
|
|
162
|
+
} from "./index-wbz365gn.js";
|
|
163
163
|
import {
|
|
164
164
|
BUNDLED_PROJECT_SKILL_ROOT,
|
|
165
165
|
DEFAULT_SKILL_MIN_CONFIDENCE,
|
|
@@ -180,7 +180,7 @@ import {
|
|
|
180
180
|
retireSkill,
|
|
181
181
|
selectCandidateEntries,
|
|
182
182
|
syncBundledProjectSkillsIfMissingAsync
|
|
183
|
-
} from "./index-
|
|
183
|
+
} from "./index-42habrdv.js";
|
|
184
184
|
import {
|
|
185
185
|
appendUnactionable,
|
|
186
186
|
quarantineEntry,
|
|
@@ -191,11 +191,11 @@ import {
|
|
|
191
191
|
validateActionableFields,
|
|
192
192
|
validateLesson,
|
|
193
193
|
validateSkillPath
|
|
194
|
-
} from "./index-
|
|
194
|
+
} from "./index-8hkxm9mh.js";
|
|
195
195
|
import {
|
|
196
196
|
authorizeCuration,
|
|
197
197
|
buildConfigFingerprintInput
|
|
198
|
-
} from "./index-
|
|
198
|
+
} from "./index-bmaz2yy4.js";
|
|
199
199
|
import {
|
|
200
200
|
cohortConfigFingerprint
|
|
201
201
|
} from "./index-rtry5xyf.js";
|
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
scanBackgroundCoderReservationsForAdmission,
|
|
220
220
|
scanDelegationsForRecovery,
|
|
221
221
|
sweepStaleDelegations
|
|
222
|
-
} from "./index-
|
|
222
|
+
} from "./index-n6jykega.js";
|
|
223
223
|
import {
|
|
224
224
|
WORKTREE_LIFECYCLE_LOCK_FILE,
|
|
225
225
|
recordWorktreeProvisioningOwner,
|
|
@@ -252,18 +252,18 @@ import {
|
|
|
252
252
|
transitionTaskWorkflowEvidence,
|
|
253
253
|
withTaskEvidenceTransaction,
|
|
254
254
|
writeWorkflowWalFile
|
|
255
|
-
} from "./index-
|
|
255
|
+
} from "./index-5q5ws00e.js";
|
|
256
256
|
import {
|
|
257
257
|
provisionWorktree,
|
|
258
258
|
removeWorktree
|
|
259
|
-
} from "./index-
|
|
259
|
+
} from "./index-mza55jmc.js";
|
|
260
260
|
import {
|
|
261
261
|
MAX_PENDING_SCOPE_BINDINGS,
|
|
262
262
|
canonicalWorkspaceIdentity,
|
|
263
263
|
clearAllScopes,
|
|
264
264
|
clearScopeBindingFromDisk,
|
|
265
265
|
clearScopeBindings
|
|
266
|
-
} from "./index-
|
|
266
|
+
} from "./index-79pwr8hc.js";
|
|
267
267
|
import {
|
|
268
268
|
appendLedgerEvent,
|
|
269
269
|
computePlanHash,
|
|
@@ -278,7 +278,17 @@ import {
|
|
|
278
278
|
readPlanEpochIdentity,
|
|
279
279
|
replayFromLedgerWithStatus,
|
|
280
280
|
takeSnapshotEvent
|
|
281
|
-
} from "./index-
|
|
281
|
+
} from "./index-6thxr1q7.js";
|
|
282
|
+
import {
|
|
283
|
+
CORE_EVENT_LOCKED,
|
|
284
|
+
appendCoreEventSync,
|
|
285
|
+
appendCoreEventsSync,
|
|
286
|
+
finalizeCoreEventsForClose,
|
|
287
|
+
getCoreEventCoverage,
|
|
288
|
+
hasSpecDriftAuditEvent,
|
|
289
|
+
hasTaskRepairAuditEvent,
|
|
290
|
+
readCoreEvents
|
|
291
|
+
} from "./index-c83bztkp.js";
|
|
282
292
|
import {
|
|
283
293
|
isPathWithinDeclaredScope,
|
|
284
294
|
sanitizeDiagnosticText
|
|
@@ -330,7 +340,7 @@ import {
|
|
|
330
340
|
transactFile,
|
|
331
341
|
transactKnowledge,
|
|
332
342
|
wordBigrams
|
|
333
|
-
} from "./index-
|
|
343
|
+
} from "./index-01q7mb83.js";
|
|
334
344
|
import {
|
|
335
345
|
MAX_EVENT_LOG_ENTRIES,
|
|
336
346
|
_internals as _internals2,
|
|
@@ -344,20 +354,32 @@ import {
|
|
|
344
354
|
recordKnowledgeEvent,
|
|
345
355
|
recordPhaseCloseIntent,
|
|
346
356
|
resolveKnowledgeEventsPath
|
|
347
|
-
} from "./index-
|
|
357
|
+
} from "./index-pgfn8h50.js";
|
|
348
358
|
import {
|
|
349
359
|
resolveWorktreeIsolationConfig
|
|
350
|
-
} from "./index-
|
|
360
|
+
} from "./index-xdp0bx28.js";
|
|
351
361
|
import {
|
|
352
362
|
RetrospectiveEvidenceSchema
|
|
353
363
|
} from "./index-gprxjmm7.js";
|
|
364
|
+
import {
|
|
365
|
+
readSwarmFileAsync,
|
|
366
|
+
safeHook,
|
|
367
|
+
validateSwarmPath
|
|
368
|
+
} from "./index-4cgee5vh.js";
|
|
369
|
+
import {
|
|
370
|
+
bunSpawn,
|
|
371
|
+
bunSpawnSync,
|
|
372
|
+
bunWrite,
|
|
373
|
+
mergeEnvForChild,
|
|
374
|
+
sleep
|
|
375
|
+
} from "./index-r3mvsbtq.js";
|
|
354
376
|
import {
|
|
355
377
|
PlanSchema,
|
|
356
378
|
exports_loader,
|
|
357
379
|
init_loader,
|
|
358
380
|
loadPluginConfig,
|
|
359
381
|
loadPluginConfigWithMeta
|
|
360
|
-
} from "./index-
|
|
382
|
+
} from "./index-q8e2yd98.js";
|
|
361
383
|
import {
|
|
362
384
|
DEFAULT_SKILL_OPT_CONFIG,
|
|
363
385
|
FALLBACK_MODELS_MAX,
|
|
@@ -371,7 +393,7 @@ import {
|
|
|
371
393
|
package_default,
|
|
372
394
|
resolveAutoReviewConfig,
|
|
373
395
|
stripKnownSwarmPrefix
|
|
374
|
-
} from "./index-
|
|
396
|
+
} from "./index-41n0thtd.js";
|
|
375
397
|
import {
|
|
376
398
|
AGENT_TOOL_MAP,
|
|
377
399
|
ALL_AGENT_NAMES,
|
|
@@ -396,18 +418,6 @@ import {
|
|
|
396
418
|
getDeferredWarnings,
|
|
397
419
|
init_warning_buffer
|
|
398
420
|
} from "./index-4rhhvd1a.js";
|
|
399
|
-
import {
|
|
400
|
-
readSwarmFileAsync,
|
|
401
|
-
safeHook,
|
|
402
|
-
validateSwarmPath
|
|
403
|
-
} from "./index-4cgee5vh.js";
|
|
404
|
-
import {
|
|
405
|
-
bunSpawn,
|
|
406
|
-
bunSpawnSync,
|
|
407
|
-
bunWrite,
|
|
408
|
-
mergeEnvForChild,
|
|
409
|
-
sleep
|
|
410
|
-
} from "./index-r3mvsbtq.js";
|
|
411
421
|
import {
|
|
412
422
|
resolveHiveDataDir,
|
|
413
423
|
resolveHiveEventsPath,
|
|
@@ -423,10 +433,10 @@ import {
|
|
|
423
433
|
resolveLinkDir,
|
|
424
434
|
sanitizeLinkId,
|
|
425
435
|
writeLinkPointer
|
|
426
|
-
} from "./index-
|
|
436
|
+
} from "./index-c1h0rdkr.js";
|
|
427
437
|
import {
|
|
428
438
|
atomicWriteFile
|
|
429
|
-
} from "./index-
|
|
439
|
+
} from "./index-cfvbd3dg.js";
|
|
430
440
|
import {
|
|
431
441
|
KNOWLEDGE_SCHEMA_VERSION,
|
|
432
442
|
OUTCOME_BLOCK_THRESHOLD,
|
|
@@ -438,7 +448,7 @@ import {
|
|
|
438
448
|
atomicWriteSwarmFileSync,
|
|
439
449
|
matchTempGrammar,
|
|
440
450
|
parseTargetBasename
|
|
441
|
-
} from "./index-
|
|
451
|
+
} from "./index-ame8ek9g.js";
|
|
442
452
|
import {
|
|
443
453
|
assertProjectRoot,
|
|
444
454
|
hasExplicitProjectBoundary,
|
|
@@ -446,12 +456,12 @@ import {
|
|
|
446
456
|
listActiveLocks,
|
|
447
457
|
tryAcquireLock,
|
|
448
458
|
withEvidenceLock
|
|
449
|
-
} from "./index-
|
|
459
|
+
} from "./index-a90c1gtn.js";
|
|
450
460
|
import {
|
|
451
461
|
emit,
|
|
452
462
|
getLastHeartbeat,
|
|
453
463
|
telemetry
|
|
454
|
-
} from "./index-
|
|
464
|
+
} from "./index-wj0gnab0.js";
|
|
455
465
|
import {
|
|
456
466
|
require_proper_lockfile
|
|
457
467
|
} from "./index-7g4c7s5r.js";
|
|
@@ -1991,9 +2001,9 @@ var storedInputArgs = new Map;
|
|
|
1991
2001
|
|
|
1992
2002
|
// src/hooks/skill-propagation-gate.ts
|
|
1993
2003
|
init_schema();
|
|
1994
|
-
init_logger();
|
|
1995
2004
|
import * as fs4 from "fs";
|
|
1996
2005
|
import * as path6 from "path";
|
|
2006
|
+
init_logger();
|
|
1997
2007
|
|
|
1998
2008
|
// src/hooks/skill-scoring.ts
|
|
1999
2009
|
import * as fs3 from "fs";
|
|
@@ -4382,14 +4392,8 @@ function extractSkillsFieldFromPrompt(prompt) {
|
|
|
4382
4392
|
return "";
|
|
4383
4393
|
}
|
|
4384
4394
|
function writeWarnEvent(directory, record) {
|
|
4385
|
-
const filePath = path6.join(directory, ".swarm", "events.jsonl");
|
|
4386
4395
|
try {
|
|
4387
|
-
|
|
4388
|
-
if (!_internals10.existsSync(dir)) {
|
|
4389
|
-
_internals10.mkdirSync(dir, { recursive: true });
|
|
4390
|
-
}
|
|
4391
|
-
_internals10.appendFileSync(filePath, `${JSON.stringify(record)}
|
|
4392
|
-
`, "utf-8");
|
|
4396
|
+
appendCoreEventSync(directory, record);
|
|
4393
4397
|
} catch (err) {
|
|
4394
4398
|
warn(`[skill-propagation-gate] failed to write warning event: ${err instanceof Error ? err.message : String(err)}`);
|
|
4395
4399
|
}
|
|
@@ -5401,8 +5405,7 @@ init_logger();
|
|
|
5401
5405
|
import { spawnSync } from "child_process";
|
|
5402
5406
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5403
5407
|
import { existsSync as existsSync6 } from "fs";
|
|
5404
|
-
import {
|
|
5405
|
-
import { dirname as dirname7 } from "path";
|
|
5408
|
+
import { readdir as readdir2 } from "fs/promises";
|
|
5406
5409
|
init_warning_buffer();
|
|
5407
5410
|
init_git_executable();
|
|
5408
5411
|
init_logger();
|
|
@@ -5440,32 +5443,17 @@ async function writeWal(filePath, wal) {
|
|
|
5440
5443
|
await writeWorkflowWalFile("coder-settlement", filePath, wal);
|
|
5441
5444
|
}
|
|
5442
5445
|
async function appendSettlementEvent(directory, action, wal, extra) {
|
|
5443
|
-
const line = `${JSON.stringify({
|
|
5444
|
-
type: "coder_settlement",
|
|
5445
|
-
action,
|
|
5446
|
-
timestamp: new Date().toISOString(),
|
|
5447
|
-
taskId: wal.taskId,
|
|
5448
|
-
transitionId: wal.transitionId,
|
|
5449
|
-
actor: wal.actor,
|
|
5450
|
-
...extra ?? {}
|
|
5451
|
-
})}
|
|
5452
|
-
`;
|
|
5453
5446
|
try {
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5447
|
+
appendCoreEventSync(directory, {
|
|
5448
|
+
type: "coder_settlement",
|
|
5449
|
+
action,
|
|
5450
|
+
timestamp: new Date().toISOString(),
|
|
5451
|
+
taskId: wal.taskId,
|
|
5452
|
+
transitionId: wal.transitionId,
|
|
5453
|
+
actor: wal.actor,
|
|
5454
|
+
...extra ?? {}
|
|
5455
|
+
});
|
|
5457
5456
|
} catch (error2) {
|
|
5458
|
-
const code = error2.code;
|
|
5459
|
-
if (code === "EBUSY" || code === "EPERM") {
|
|
5460
|
-
try {
|
|
5461
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
5462
|
-
await appendFile2(eventsPath, line, "utf-8");
|
|
5463
|
-
return;
|
|
5464
|
-
} catch (retryError) {
|
|
5465
|
-
criticalWarn(`[coder-settlement] lifecycle event write failed after retry (${action} ${wal.taskId}): ${retryError instanceof Error ? retryError.message : String(retryError)}`);
|
|
5466
|
-
return;
|
|
5467
|
-
}
|
|
5468
|
-
}
|
|
5469
5457
|
criticalWarn(`[coder-settlement] lifecycle event write failed (${action} ${wal.taskId}): ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
5470
5458
|
}
|
|
5471
5459
|
}
|
|
@@ -5608,7 +5596,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
|
|
|
5608
5596
|
awaitingMergeByCallID,
|
|
5609
5597
|
cleanupStandardWorktreeForCallId,
|
|
5610
5598
|
standardWorktreeByCallID
|
|
5611
|
-
} = await import("./worktree-isolation-
|
|
5599
|
+
} = await import("./worktree-isolation-pbr4d5m9.js");
|
|
5612
5600
|
standardWorktreeByCallID.delete(descriptor.callID);
|
|
5613
5601
|
if (hasResidue)
|
|
5614
5602
|
awaitingMergeByCallID.set(descriptor.callID, {
|
|
@@ -5710,7 +5698,7 @@ async function recoverCoderSettlement(directory, taskId) {
|
|
|
5710
5698
|
awaitingMergeByCallID,
|
|
5711
5699
|
finishStandardWorktreeDispatch,
|
|
5712
5700
|
standardWorktreeByCallID
|
|
5713
|
-
} = await import("./worktree-isolation-
|
|
5701
|
+
} = await import("./worktree-isolation-pbr4d5m9.js");
|
|
5714
5702
|
const descriptor = wal.worktree;
|
|
5715
5703
|
const reconstructedDispatch = {
|
|
5716
5704
|
callID: descriptor.callID,
|
|
@@ -5980,17 +5968,15 @@ var _internals13 = {
|
|
|
5980
5968
|
};
|
|
5981
5969
|
|
|
5982
5970
|
// src/workflow/task-repair.ts
|
|
5983
|
-
import { appendFile as appendFile3, readFile as readFile4 } from "fs/promises";
|
|
5984
5971
|
async function recoverPreparedTaskRepairWithPlanLock(directory, taskId, actor, currentPlan) {
|
|
5985
5972
|
const walPath2 = validateSwarmPath(directory, `task-repairs/${taskId}.json`);
|
|
5986
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
5987
5973
|
const wal = await readWal2(walPath2, taskId);
|
|
5988
5974
|
if (wal === null)
|
|
5989
5975
|
return null;
|
|
5990
5976
|
if (wal.state === "ABORTED")
|
|
5991
5977
|
return null;
|
|
5992
5978
|
if (wal.state === "COMMITTED") {
|
|
5993
|
-
await ensureAuditEvent(directory,
|
|
5979
|
+
await ensureAuditEvent(directory, wal);
|
|
5994
5980
|
return null;
|
|
5995
5981
|
}
|
|
5996
5982
|
const task = currentPlan.phases.flatMap((phase) => phase.tasks).find((candidate) => candidate.id === taskId);
|
|
@@ -6030,57 +6016,15 @@ async function recoverPreparedTaskRepairUnderPlanLock(directory, taskId, actor,
|
|
|
6030
6016
|
async function readWal2(filePath, taskId) {
|
|
6031
6017
|
return readWorkflowWalFile("task-repair", filePath, taskId);
|
|
6032
6018
|
}
|
|
6033
|
-
async function readText(filePath) {
|
|
6034
|
-
try {
|
|
6035
|
-
return await readFile4(filePath, "utf-8");
|
|
6036
|
-
} catch (error2) {
|
|
6037
|
-
if (error2.code === "ENOENT")
|
|
6038
|
-
return null;
|
|
6039
|
-
throw error2;
|
|
6040
|
-
}
|
|
6041
|
-
}
|
|
6042
6019
|
async function writeWal2(filePath, wal) {
|
|
6043
6020
|
await writeWorkflowWalFile("task-repair", filePath, wal);
|
|
6044
6021
|
}
|
|
6045
|
-
function
|
|
6046
|
-
|
|
6047
|
-
return JSON.parse(line);
|
|
6048
|
-
} catch {
|
|
6049
|
-
return null;
|
|
6050
|
-
}
|
|
6051
|
-
}
|
|
6052
|
-
function findRepairEvent(content, taskId, transitionId) {
|
|
6053
|
-
if (!content)
|
|
6054
|
-
return false;
|
|
6055
|
-
const transitionNeedle = JSON.stringify(transitionId).slice(1, -1);
|
|
6056
|
-
const taskNeedle = JSON.stringify(taskId).slice(1, -1);
|
|
6057
|
-
if (!content.includes(transitionNeedle) || !content.includes(taskNeedle))
|
|
6058
|
-
return false;
|
|
6059
|
-
for (const line of content.split(`
|
|
6060
|
-
`)) {
|
|
6061
|
-
if (!line.trim())
|
|
6062
|
-
continue;
|
|
6063
|
-
const event = parseAuditEventLine(line);
|
|
6064
|
-
if (!event)
|
|
6065
|
-
continue;
|
|
6066
|
-
if (event.type === "task_workflow_repaired" && event.taskId === taskId && event.transitionId === transitionId) {
|
|
6067
|
-
return true;
|
|
6068
|
-
}
|
|
6069
|
-
}
|
|
6070
|
-
return false;
|
|
6071
|
-
}
|
|
6072
|
-
async function ensureAuditEvent(directory, eventsPath, wal) {
|
|
6073
|
-
if (findRepairEvent(await readText(eventsPath), wal.taskId, wal.transitionId))
|
|
6022
|
+
async function ensureAuditEvent(directory, wal) {
|
|
6023
|
+
if (hasTaskRepairAuditEvent(directory, wal.taskId, wal.transitionId)) {
|
|
6074
6024
|
return;
|
|
6075
|
-
const lock = await tryAcquireLock(directory, "events.jsonl", "task-repair-audit", `task-repair:${wal.taskId}:${wal.transitionId}`);
|
|
6076
|
-
if (!lock.acquired) {
|
|
6077
|
-
throw new Error("TASK_REPAIR_AUDIT_LOCKED");
|
|
6078
6025
|
}
|
|
6079
6026
|
try {
|
|
6080
|
-
|
|
6081
|
-
if (findRepairEvent(existing, wal.taskId, wal.transitionId))
|
|
6082
|
-
return;
|
|
6083
|
-
await appendFile3(eventsPath, `${JSON.stringify({
|
|
6027
|
+
appendCoreEventSync(directory, {
|
|
6084
6028
|
type: "task_workflow_repaired",
|
|
6085
6029
|
timestamp: new Date().toISOString(),
|
|
6086
6030
|
taskId: wal.taskId,
|
|
@@ -6092,15 +6036,15 @@ async function ensureAuditEvent(directory, eventsPath, wal) {
|
|
|
6092
6036
|
oldWorkflowState: wal.oldWorkflowState,
|
|
6093
6037
|
newWorkflowState: wal.newWorkflowState,
|
|
6094
6038
|
generation: wal.generation
|
|
6095
|
-
})
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
throw new Error("TASK_REPAIR_AUDIT_UNVERIFIED");
|
|
6039
|
+
}, { dedupeOnAuthorityKey: true });
|
|
6040
|
+
} catch (error2) {
|
|
6041
|
+
if (error2 instanceof Error && error2.message === CORE_EVENT_LOCKED) {
|
|
6042
|
+
throw new Error("TASK_REPAIR_AUDIT_LOCKED");
|
|
6100
6043
|
}
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6044
|
+
throw error2;
|
|
6045
|
+
}
|
|
6046
|
+
if (!hasTaskRepairAuditEvent(directory, wal.taskId, wal.transitionId)) {
|
|
6047
|
+
throw new Error("TASK_REPAIR_AUDIT_UNVERIFIED");
|
|
6104
6048
|
}
|
|
6105
6049
|
}
|
|
6106
6050
|
function workflowMatchesCommittedRepair(evidence, wal) {
|
|
@@ -6109,7 +6053,6 @@ function workflowMatchesCommittedRepair(evidence, wal) {
|
|
|
6109
6053
|
}
|
|
6110
6054
|
async function repairTaskWorkflowUnderPlanLock(options) {
|
|
6111
6055
|
const walPath2 = validateSwarmPath(options.directory, `task-repairs/${options.taskId}.json`);
|
|
6112
|
-
const eventsPath = validateSwarmPath(options.directory, "events.jsonl");
|
|
6113
6056
|
return withTaskEvidenceTransaction(options.directory, options.taskId, options.actor, async (transaction) => {
|
|
6114
6057
|
await assertNoUnsettledCoderDispatch(options.directory, options.taskId);
|
|
6115
6058
|
let evidence = transaction.read();
|
|
@@ -6127,7 +6070,7 @@ async function repairTaskWorkflowUnderPlanLock(options) {
|
|
|
6127
6070
|
throw new Error(`TASK_REPAIR_IDEMPOTENCY_CONFLICT: transition ${options.transitionId} was prepared with different reason or workflow CAS fields`);
|
|
6128
6071
|
}
|
|
6129
6072
|
if (existingWal?.state === "COMMITTED" && options.currentPlanStatus === "in_progress" && workflowMatchesCommittedRepair(evidence, existingWal)) {
|
|
6130
|
-
await ensureAuditEvent(options.directory,
|
|
6073
|
+
await ensureAuditEvent(options.directory, existingWal);
|
|
6131
6074
|
return {
|
|
6132
6075
|
plan: options.currentPlan,
|
|
6133
6076
|
alreadyApplied: true,
|
|
@@ -6180,7 +6123,7 @@ async function repairTaskWorkflowUnderPlanLock(options) {
|
|
|
6180
6123
|
}
|
|
6181
6124
|
}
|
|
6182
6125
|
await writeWal2(walPath2, { ...wal, state: "COMMITTED" });
|
|
6183
|
-
await ensureAuditEvent(options.directory,
|
|
6126
|
+
await ensureAuditEvent(options.directory, wal);
|
|
6184
6127
|
return {
|
|
6185
6128
|
plan,
|
|
6186
6129
|
alreadyApplied: false,
|
|
@@ -9022,7 +8965,7 @@ async function settlePresumedStalePrWorkflowLanes(directory, sessionID) {
|
|
|
9022
8965
|
});
|
|
9023
8966
|
} catch {}
|
|
9024
8967
|
try {
|
|
9025
|
-
|
|
8968
|
+
appendCoreEventSync(directory, {
|
|
9026
8969
|
type: "pr_workflow_lanes_presumed_stale",
|
|
9027
8970
|
timestamp: isoNow(),
|
|
9028
8971
|
sessionID,
|
|
@@ -9031,8 +8974,7 @@ async function settlePresumedStalePrWorkflowLanes(directory, sessionID) {
|
|
|
9031
8974
|
probeStatus: probe.degradedReason ?? "ok",
|
|
9032
8975
|
probedAliveLanes: probedAliveLaneIds.slice(0, MAX_DISCLOSED_LANE_IDS),
|
|
9033
8976
|
disclosure
|
|
9034
|
-
})
|
|
9035
|
-
`, "utf-8");
|
|
8977
|
+
});
|
|
9036
8978
|
} catch {}
|
|
9037
8979
|
return {
|
|
9038
8980
|
openLaneIds,
|
|
@@ -9123,9 +9065,7 @@ async function abortPrWorkflow(directory, sessionID, options = { kind: "recovery
|
|
|
9123
9065
|
reason: sanitizedReason
|
|
9124
9066
|
};
|
|
9125
9067
|
try {
|
|
9126
|
-
|
|
9127
|
-
await fsp2.appendFile(eventsPath, `${JSON.stringify(abortEvent)}
|
|
9128
|
-
`, "utf-8");
|
|
9068
|
+
appendCoreEventSync(directory, abortEvent);
|
|
9129
9069
|
} catch {}
|
|
9130
9070
|
const casEscape = recovery.salvaged && !recovery.revisionSalvageable;
|
|
9131
9071
|
await _test_exports2.beforeAbortClear?.();
|
|
@@ -9133,7 +9073,7 @@ async function abortPrWorkflow(directory, sessionID, options = { kind: "recovery
|
|
|
9133
9073
|
await clearPrWorkflowGateState(directory, sessionID, casEscape ? undefined : state.revision, { allowSalvagedRead: recovery.salvaged });
|
|
9134
9074
|
} catch (error2) {
|
|
9135
9075
|
try {
|
|
9136
|
-
|
|
9076
|
+
appendCoreEventSync(directory, {
|
|
9137
9077
|
type: "pr_workflow_abort_not_completed",
|
|
9138
9078
|
timestamp: isoNow(),
|
|
9139
9079
|
sessionID: state.sessionID,
|
|
@@ -9146,8 +9086,7 @@ async function abortPrWorkflow(directory, sessionID, options = { kind: "recovery
|
|
|
9146
9086
|
} : {},
|
|
9147
9087
|
failure: (error2 instanceof Error ? error2.message : String(error2)).slice(0, MAX_BASE_COVERAGE_DIAGNOSTIC_CHARS),
|
|
9148
9088
|
disclosure: "RETRACTION: the pr_workflow_aborted record for this session did NOT complete \u2014 " + "the clear failed and the gate state may still be active. Revalidate the current " + "session state before retrying the abort." + (overridesProbeRetention ? " The probe-retention override finalized no record: it runs only after the " + "clear succeeds, and this clear failed. Other lanes in the same settlement " + "batch may already have been finalized as presumed-stale, and a concurrent abort for this session may have finalized more \u2014 revalidate the lane records rather than assuming they are untouched." : "")
|
|
9149
|
-
})
|
|
9150
|
-
`, "utf-8");
|
|
9089
|
+
});
|
|
9151
9090
|
} catch {}
|
|
9152
9091
|
throw error2;
|
|
9153
9092
|
}
|
|
@@ -12116,8 +12055,8 @@ ${USAGE}`;
|
|
|
12116
12055
|
|
|
12117
12056
|
// src/services/spec-drift-recovery.ts
|
|
12118
12057
|
import { createHash as createHash6 } from "crypto";
|
|
12119
|
-
import {
|
|
12120
|
-
import { dirname as
|
|
12058
|
+
import { mkdir as mkdir4, readFile as readFile5, unlink as unlink2 } from "fs/promises";
|
|
12059
|
+
import { dirname as dirname9 } from "path";
|
|
12121
12060
|
var SPEC_DRIFT_RECOVERY_AGENT = "spec-drift-recovery";
|
|
12122
12061
|
var _internals16 = {
|
|
12123
12062
|
appendEvent,
|
|
@@ -12177,7 +12116,7 @@ function parseWal(raw) {
|
|
|
12177
12116
|
}
|
|
12178
12117
|
async function readFileText(filePath) {
|
|
12179
12118
|
try {
|
|
12180
|
-
return await
|
|
12119
|
+
return await readFile5(filePath, "utf-8");
|
|
12181
12120
|
} catch (error2) {
|
|
12182
12121
|
if (error2?.code === "ENOENT") {
|
|
12183
12122
|
return null;
|
|
@@ -12197,7 +12136,7 @@ async function unlinkIfExists(filePath) {
|
|
|
12197
12136
|
}
|
|
12198
12137
|
}
|
|
12199
12138
|
async function writeWal4(walPath2, wal) {
|
|
12200
|
-
await
|
|
12139
|
+
await mkdir4(dirname9(walPath2), { recursive: true });
|
|
12201
12140
|
await atomicWriteFile(walPath2, `${JSON.stringify(wal, null, 2)}
|
|
12202
12141
|
`);
|
|
12203
12142
|
}
|
|
@@ -12243,37 +12182,18 @@ async function ensureSnapshotEvent(directory, plan, transitionId) {
|
|
|
12243
12182
|
approvalMetadata: { specDriftTransitionId: transitionId }
|
|
12244
12183
|
});
|
|
12245
12184
|
}
|
|
12246
|
-
async function appendEvent(
|
|
12247
|
-
const existing = await _internals16.verifyEventPresence(
|
|
12185
|
+
async function appendEvent(directory, event) {
|
|
12186
|
+
const existing = await _internals16.verifyEventPresence(directory, event.type, event.transitionId);
|
|
12248
12187
|
if (existing)
|
|
12249
12188
|
return;
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
const verified = await _internals16.verifyEventPresence(eventsPath, event.type, event.transitionId);
|
|
12189
|
+
appendCoreEventSync(directory, { ...event }, { dedupeOnAuthorityKey: true });
|
|
12190
|
+
const verified = await _internals16.verifyEventPresence(directory, event.type, event.transitionId);
|
|
12253
12191
|
if (!verified) {
|
|
12254
12192
|
throw new Error(`spec drift audit verification failed for transition ${event.transitionId}`);
|
|
12255
12193
|
}
|
|
12256
12194
|
}
|
|
12257
|
-
async function verifyEventPresence(
|
|
12258
|
-
|
|
12259
|
-
if (raw === null)
|
|
12260
|
-
return false;
|
|
12261
|
-
for (const line of raw.split(`
|
|
12262
|
-
`)) {
|
|
12263
|
-
const trimmed = line.trim();
|
|
12264
|
-
if (trimmed.length === 0)
|
|
12265
|
-
continue;
|
|
12266
|
-
let parsed;
|
|
12267
|
-
try {
|
|
12268
|
-
parsed = JSON.parse(trimmed);
|
|
12269
|
-
} catch (error2) {
|
|
12270
|
-
throw new Error(`events.jsonl is not valid JSONL near "${trimmed.slice(0, 80)}": ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
12271
|
-
}
|
|
12272
|
-
if (parsed.type === eventType && parsed.transitionId === transitionId) {
|
|
12273
|
-
return true;
|
|
12274
|
-
}
|
|
12275
|
-
}
|
|
12276
|
-
return false;
|
|
12195
|
+
async function verifyEventPresence(directory, eventType, transitionId) {
|
|
12196
|
+
return hasSpecDriftAuditEvent(directory, eventType, transitionId);
|
|
12277
12197
|
}
|
|
12278
12198
|
function buildTransitionId(mode, markerHash, previousHash, newHash) {
|
|
12279
12199
|
return sha2562(`${mode}:${markerHash}:${previousHash ?? "(null)"}:${newHash ?? "(null)"}`);
|
|
@@ -12316,7 +12236,6 @@ async function reconcileSpecDrift(directory, options) {
|
|
|
12316
12236
|
const markerPath = _internals16.validateSwarmPath(directory, "spec-staleness.json");
|
|
12317
12237
|
const walPath2 = _internals16.validateSwarmPath(directory, "spec-drift-recovery.json");
|
|
12318
12238
|
const snapshotPath = _internals16.validateSwarmPath(directory, "spec-snapshot.md");
|
|
12319
|
-
const eventsPath = _internals16.validateSwarmPath(directory, "events.jsonl");
|
|
12320
12239
|
const markerMaybe = await _internals16.readFileText(markerPath);
|
|
12321
12240
|
if (markerMaybe === null) {
|
|
12322
12241
|
return {
|
|
@@ -12463,7 +12382,7 @@ async function reconcileSpecDrift(directory, options) {
|
|
|
12463
12382
|
previousHash: wal.previousHash,
|
|
12464
12383
|
transitionId
|
|
12465
12384
|
});
|
|
12466
|
-
await _internals16.appendEvent(
|
|
12385
|
+
await _internals16.appendEvent(directory, event);
|
|
12467
12386
|
await _internals16.writeWal(walPath2, { ...wal, state: "COMMITTED" });
|
|
12468
12387
|
}
|
|
12469
12388
|
if (markerReplacedDuringPrepared) {
|
|
@@ -12888,7 +12807,7 @@ import * as path14 from "path";
|
|
|
12888
12807
|
|
|
12889
12808
|
// src/evaluation/gate-ground-truth.ts
|
|
12890
12809
|
init_zod();
|
|
12891
|
-
import { mkdir as
|
|
12810
|
+
import { mkdir as mkdir5, readFile as readFile6 } from "fs/promises";
|
|
12892
12811
|
import * as path13 from "path";
|
|
12893
12812
|
var GateGroundTruthV1Schema = exports_external.object({
|
|
12894
12813
|
v: exports_external.literal(1),
|
|
@@ -12941,11 +12860,11 @@ async function saveGateGroundTruth(directory, runId, input) {
|
|
|
12941
12860
|
}
|
|
12942
12861
|
const target = absolutePath(directory, runId);
|
|
12943
12862
|
assertProjectRoot(directory);
|
|
12944
|
-
await
|
|
12863
|
+
await mkdir5(path13.dirname(target), { recursive: true });
|
|
12945
12864
|
return withEvidenceLock(directory, relativePath(runId), "gate-ground-truth", runId, async () => {
|
|
12946
12865
|
let existingEvents = [];
|
|
12947
12866
|
try {
|
|
12948
|
-
existingEvents = parseStrict(await
|
|
12867
|
+
existingEvents = parseStrict(await readFile6(target, "utf8"));
|
|
12949
12868
|
} catch (error2) {
|
|
12950
12869
|
if (error2.code !== "ENOENT")
|
|
12951
12870
|
throw error2;
|
|
@@ -12974,7 +12893,7 @@ async function recordTestImpactGateGroundTruth(directory, runId, input) {
|
|
|
12974
12893
|
async function readGateGroundTruth(directory, runId) {
|
|
12975
12894
|
let content;
|
|
12976
12895
|
try {
|
|
12977
|
-
content = await
|
|
12896
|
+
content = await readFile6(absolutePath(directory, runId), "utf8");
|
|
12978
12897
|
} catch (error2) {
|
|
12979
12898
|
if (error2.code === "ENOENT") {
|
|
12980
12899
|
return { events: [], malformed: 0 };
|
|
@@ -14115,13 +14034,10 @@ function writeCheckpointLog(log2, directory) {
|
|
|
14115
14034
|
}
|
|
14116
14035
|
function appendRetentionEvent(directory, event) {
|
|
14117
14036
|
try {
|
|
14118
|
-
|
|
14119
|
-
const line = `${JSON.stringify({
|
|
14037
|
+
appendCoreEventSync(directory, {
|
|
14120
14038
|
...event,
|
|
14121
14039
|
timestamp: new Date().toISOString()
|
|
14122
|
-
})
|
|
14123
|
-
`;
|
|
14124
|
-
fs10.appendFileSync(eventsPath, line);
|
|
14040
|
+
});
|
|
14125
14041
|
} catch {}
|
|
14126
14042
|
}
|
|
14127
14043
|
function loadCheckpointConfig(directory) {
|
|
@@ -17295,7 +17211,7 @@ function formatLearningSummary(metrics) {
|
|
|
17295
17211
|
}
|
|
17296
17212
|
|
|
17297
17213
|
// src/services/recommendation-ledger.ts
|
|
17298
|
-
import { readFile as
|
|
17214
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
17299
17215
|
import * as path20 from "path";
|
|
17300
17216
|
|
|
17301
17217
|
// src/learning/fingerprint.ts
|
|
@@ -17458,7 +17374,7 @@ function parseLedgerJsonl(content) {
|
|
|
17458
17374
|
}
|
|
17459
17375
|
async function readLedgerForTransaction(filePath) {
|
|
17460
17376
|
try {
|
|
17461
|
-
return parseLedgerJsonl(await
|
|
17377
|
+
return parseLedgerJsonl(await readFile7(filePath, "utf-8"));
|
|
17462
17378
|
} catch (err) {
|
|
17463
17379
|
if (err?.code === "ENOENT")
|
|
17464
17380
|
return [];
|
|
@@ -17468,7 +17384,7 @@ async function readLedgerForTransaction(filePath) {
|
|
|
17468
17384
|
async function readLedgerStrict(directory) {
|
|
17469
17385
|
const filePath = _internals23.resolveRecommendationLedgerPath(directory);
|
|
17470
17386
|
try {
|
|
17471
|
-
return parseLedgerJsonl(await
|
|
17387
|
+
return parseLedgerJsonl(await readFile7(filePath, "utf-8"));
|
|
17472
17388
|
} catch (err) {
|
|
17473
17389
|
if (err?.code === "ENOENT")
|
|
17474
17390
|
return [];
|
|
@@ -17747,13 +17663,13 @@ function buildPromotedExternalInputFromSkill(directory, skillSlug, usage, ageDay
|
|
|
17747
17663
|
|
|
17748
17664
|
// src/services/skill-reviser.ts
|
|
17749
17665
|
init_logger();
|
|
17750
|
-
import { readFile as
|
|
17666
|
+
import { readFile as readFile8, rename as rename3, writeFile as writeFile5 } from "fs/promises";
|
|
17751
17667
|
var REVISION_VIOLATION_THRESHOLD = 0.15;
|
|
17752
17668
|
var MAX_REVISION_CALLS_PER_PHASE = 3;
|
|
17753
17669
|
var DEFAULT_MAX_CALLS = 10;
|
|
17754
17670
|
async function getSkillVersion(skillPath) {
|
|
17755
17671
|
try {
|
|
17756
|
-
const content = await
|
|
17672
|
+
const content = await readFile8(skillPath, "utf-8");
|
|
17757
17673
|
const match = content.match(/^version:\s*(\d+)\s*$/m);
|
|
17758
17674
|
return match ? parseInt(match[1], 10) : 1;
|
|
17759
17675
|
} catch {
|
|
@@ -18386,7 +18302,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
|
|
|
18386
18302
|
};
|
|
18387
18303
|
}
|
|
18388
18304
|
async function sweepActiveNearDuplicates(directory, options = {}) {
|
|
18389
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
18305
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hbhw2qd7.js");
|
|
18390
18306
|
const { config } = loadPluginConfigWithMeta2(directory);
|
|
18391
18307
|
const sweepConfig = config.learning?.dedup_sweep;
|
|
18392
18308
|
if (sweepConfig?.enabled === false)
|
|
@@ -19347,8 +19263,19 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19347
19263
|
already_digested: true
|
|
19348
19264
|
};
|
|
19349
19265
|
}
|
|
19350
|
-
const
|
|
19351
|
-
const phaseEvents =
|
|
19266
|
+
const eventsWindow = readCoreEvents(directory);
|
|
19267
|
+
const phaseEvents = eventsWindow.text.length > 0 ? _internals25.filterPhaseEvents(eventsWindow.text, phase) : [];
|
|
19268
|
+
if (eventsWindow.coverage === "truncated") {
|
|
19269
|
+
try {
|
|
19270
|
+
appendCoreEventSync(directory, {
|
|
19271
|
+
timestamp: new Date().toISOString(),
|
|
19272
|
+
event: "curator_skipped",
|
|
19273
|
+
scope: "phase_digest",
|
|
19274
|
+
phase,
|
|
19275
|
+
reason: "events_window_truncated"
|
|
19276
|
+
});
|
|
19277
|
+
} catch {}
|
|
19278
|
+
}
|
|
19352
19279
|
const contextMd = await readSwarmFileAsync(directory, "context.md");
|
|
19353
19280
|
const requiredAgents = ["reviewer", "test_engineer"];
|
|
19354
19281
|
const complianceObservations = _internals25.checkPhaseCompliance(phaseEvents, agentsDispatched, requiredAgents, phase);
|
|
@@ -19491,20 +19418,21 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
|
|
|
19491
19418
|
warn(`[curator] failed to persist application findings: ${err instanceof Error ? err.message : String(err)}`);
|
|
19492
19419
|
}
|
|
19493
19420
|
}
|
|
19494
|
-
|
|
19495
|
-
|
|
19496
|
-
await appendKnowledge(eventsPath, {
|
|
19421
|
+
try {
|
|
19422
|
+
appendCoreEventsSync(directory, complianceObservations.map((obs) => ({
|
|
19497
19423
|
type: "curator_compliance",
|
|
19498
19424
|
timestamp: obs.timestamp,
|
|
19499
19425
|
phase: obs.phase,
|
|
19500
19426
|
observation_type: obs.type,
|
|
19501
19427
|
severity: obs.severity,
|
|
19502
19428
|
description: obs.description
|
|
19503
|
-
});
|
|
19429
|
+
})));
|
|
19430
|
+
} catch (err) {
|
|
19431
|
+
warn(`[curator] failed to append compliance events: ${err instanceof Error ? err.message : String(err)}`);
|
|
19504
19432
|
}
|
|
19505
19433
|
if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
|
|
19506
19434
|
try {
|
|
19507
|
-
const skillModule = await import("./skill-generator-
|
|
19435
|
+
const skillModule = await import("./skill-generator-esrn40th.js");
|
|
19508
19436
|
for (const cand of skillCandidates) {
|
|
19509
19437
|
if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
|
|
19510
19438
|
continue;
|
|
@@ -19976,7 +19904,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
|
|
|
19976
19904
|
} catch {}
|
|
19977
19905
|
}
|
|
19978
19906
|
if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
|
|
19979
|
-
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-
|
|
19907
|
+
const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-ty2kesdj.js");
|
|
19980
19908
|
for (const { id } of contradictedEntries) {
|
|
19981
19909
|
try {
|
|
19982
19910
|
await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
|
|
@@ -20795,7 +20723,7 @@ async function runCuratorPostMortem(directory, options = {}) {
|
|
|
20795
20723
|
warnings.push("Failed to collect knowledge summary.");
|
|
20796
20724
|
}
|
|
20797
20725
|
try {
|
|
20798
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
20726
|
+
const { getScanStatus } = await import("./scan-cursor-3ba1spad.js");
|
|
20799
20727
|
const scanStatus = await getScanStatus(directory);
|
|
20800
20728
|
if (scanStatus.remaining_estimate > 0) {
|
|
20801
20729
|
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.`);
|
|
@@ -20967,9 +20895,9 @@ var _internals26 = {
|
|
|
20967
20895
|
verifyPostMortemKnowledgeActions,
|
|
20968
20896
|
repairPostMortemActions,
|
|
20969
20897
|
loadDefaultKnowledgeConfig: async (directory) => {
|
|
20970
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
20898
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-h251vmd1.js");
|
|
20971
20899
|
try {
|
|
20972
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
20900
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hbhw2qd7.js");
|
|
20973
20901
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
20974
20902
|
return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
20975
20903
|
} catch {
|
|
@@ -20977,11 +20905,11 @@ var _internals26 = {
|
|
|
20977
20905
|
}
|
|
20978
20906
|
},
|
|
20979
20907
|
applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
|
|
20980
|
-
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-
|
|
20908
|
+
const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-6w4frzdz.js");
|
|
20981
20909
|
return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
|
|
20982
20910
|
},
|
|
20983
20911
|
checkHivePromotions: async (entries, knowledgeConfig, directory) => {
|
|
20984
|
-
const { checkHivePromotions } = await import("./hive-promoter-
|
|
20912
|
+
const { checkHivePromotions } = await import("./hive-promoter-32artf8c.js");
|
|
20985
20913
|
return checkHivePromotions(entries, knowledgeConfig, directory);
|
|
20986
20914
|
},
|
|
20987
20915
|
applyProposalTriage: async (directory, triage) => {
|
|
@@ -20990,7 +20918,7 @@ var _internals26 = {
|
|
|
20990
20918
|
activateProposal,
|
|
20991
20919
|
listSkills: listSkills2,
|
|
20992
20920
|
sanitizeSlug
|
|
20993
|
-
} = await import("./skill-generator-
|
|
20921
|
+
} = await import("./skill-generator-esrn40th.js");
|
|
20994
20922
|
const result = {
|
|
20995
20923
|
approved: [],
|
|
20996
20924
|
rejected: [],
|
|
@@ -21032,7 +20960,7 @@ var _internals26 = {
|
|
|
21032
20960
|
return result;
|
|
21033
20961
|
},
|
|
21034
20962
|
readPriorDriftReports: async (directory) => {
|
|
21035
|
-
const { readPriorDriftReports } = await import("./curator-drift-
|
|
20963
|
+
const { readPriorDriftReports } = await import("./curator-drift-2h1d2fnq.js");
|
|
21036
20964
|
return readPriorDriftReports(directory);
|
|
21037
20965
|
},
|
|
21038
20966
|
readSwarmKnowledge: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory))
|
|
@@ -21172,7 +21100,7 @@ function failedGateNames(decision) {
|
|
|
21172
21100
|
|
|
21173
21101
|
// src/hooks/hive-transaction.ts
|
|
21174
21102
|
var import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
|
|
21175
|
-
import { appendFile as
|
|
21103
|
+
import { appendFile as appendFile2, mkdir as mkdir7, realpath as realpath2 } from "fs/promises";
|
|
21176
21104
|
import * as path25 from "path";
|
|
21177
21105
|
init_logger();
|
|
21178
21106
|
var HIVE_LOCK_STALE_MS = 5000;
|
|
@@ -21197,7 +21125,7 @@ async function transactHiveStore(mutate) {
|
|
|
21197
21125
|
const eventsPath = _internals27.resolveHiveEventsPath();
|
|
21198
21126
|
const diagnostics = [];
|
|
21199
21127
|
try {
|
|
21200
|
-
await
|
|
21128
|
+
await mkdir7(dataDir, { recursive: true });
|
|
21201
21129
|
} catch (err) {
|
|
21202
21130
|
diagnostics.push(`hive data dir create failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
21203
21131
|
return { committed: false, return: undefined, diagnostics };
|
|
@@ -21250,13 +21178,13 @@ async function transactHiveStore(mutate) {
|
|
|
21250
21178
|
const rejectBlock = `${outcome.rejects.map((r) => JSON.stringify(r)).join(`
|
|
21251
21179
|
`)}
|
|
21252
21180
|
`;
|
|
21253
|
-
await
|
|
21181
|
+
await appendFile2(rejectedPath, rejectBlock, "utf-8");
|
|
21254
21182
|
}
|
|
21255
21183
|
if (outcome.audit && outcome.audit.length > 0) {
|
|
21256
21184
|
const auditBlock = `${outcome.audit.map((a) => a.line).join(`
|
|
21257
21185
|
`)}
|
|
21258
21186
|
`;
|
|
21259
|
-
await
|
|
21187
|
+
await appendFile2(eventsPath, auditBlock, "utf-8");
|
|
21260
21188
|
try {
|
|
21261
21189
|
await trimHiveEventsUnderLock(eventsPath);
|
|
21262
21190
|
} catch (err) {
|
|
@@ -21316,11 +21244,11 @@ async function realpathQuiet(target) {
|
|
|
21316
21244
|
}
|
|
21317
21245
|
}
|
|
21318
21246
|
async function trimHiveEventsUnderLock(eventsPath) {
|
|
21319
|
-
const { readFile:
|
|
21247
|
+
const { readFile: readFile9 } = await import("fs/promises");
|
|
21320
21248
|
const { existsSync: existsSync15 } = await import("fs");
|
|
21321
21249
|
if (!existsSync15(eventsPath))
|
|
21322
21250
|
return;
|
|
21323
|
-
const content = await
|
|
21251
|
+
const content = await readFile9(eventsPath, "utf-8");
|
|
21324
21252
|
const lines = content.split(`
|
|
21325
21253
|
`).filter((l) => l.trim().length > 0);
|
|
21326
21254
|
if (lines.length <= MAX_EVENT_LOG_ENTRIES)
|
|
@@ -21339,7 +21267,7 @@ var _internals27 = {
|
|
|
21339
21267
|
resolveHiveKnowledgePath,
|
|
21340
21268
|
resolveHiveRejectedPath,
|
|
21341
21269
|
resolveHiveEventsPath,
|
|
21342
|
-
appendFile:
|
|
21270
|
+
appendFile: appendFile2,
|
|
21343
21271
|
path: path25
|
|
21344
21272
|
};
|
|
21345
21273
|
|
|
@@ -22087,20 +22015,14 @@ async function promoteFromSwarm(directory, lessonId, options, config) {
|
|
|
22087
22015
|
// src/hooks/knowledge-curator.ts
|
|
22088
22016
|
import { createHash as createHash10 } from "crypto";
|
|
22089
22017
|
import { existsSync as existsSync15 } from "fs";
|
|
22090
|
-
import {
|
|
22091
|
-
appendFile as appendFile7,
|
|
22092
|
-
mkdir as mkdir10,
|
|
22093
|
-
readFile as readFile11,
|
|
22094
|
-
realpath as realpath3,
|
|
22095
|
-
writeFile as writeFile7
|
|
22096
|
-
} from "fs/promises";
|
|
22018
|
+
import { readFile as readFile10, realpath as realpath3, writeFile as writeFile7 } from "fs/promises";
|
|
22097
22019
|
import * as path28 from "path";
|
|
22098
22020
|
|
|
22099
22021
|
// src/services/synonym-map.ts
|
|
22100
22022
|
var import_proper_lockfile5 = __toESM(require_proper_lockfile(), 1);
|
|
22101
22023
|
import {
|
|
22102
|
-
mkdir as
|
|
22103
|
-
readFile as
|
|
22024
|
+
mkdir as mkdir8,
|
|
22025
|
+
readFile as readFile9,
|
|
22104
22026
|
rename as rename4,
|
|
22105
22027
|
stat as stat3,
|
|
22106
22028
|
unlink as unlink3,
|
|
@@ -22254,14 +22176,14 @@ async function readSynonymMap(directory, maxPairs = DEFAULT_MAX_PAIRS) {
|
|
|
22254
22176
|
const st = await stat3(filePath);
|
|
22255
22177
|
if (st.size > ceiling)
|
|
22256
22178
|
return emptySynonymMap();
|
|
22257
|
-
const raw = await
|
|
22179
|
+
const raw = await readFile9(filePath, "utf-8");
|
|
22258
22180
|
return coerceSynonymMap(JSON.parse(raw), maxPairs);
|
|
22259
22181
|
} catch {
|
|
22260
22182
|
return emptySynonymMap();
|
|
22261
22183
|
}
|
|
22262
22184
|
}
|
|
22263
22185
|
async function writeSynonymMapAtomic(filePath, map) {
|
|
22264
|
-
await
|
|
22186
|
+
await mkdir8(path27.dirname(filePath), { recursive: true });
|
|
22265
22187
|
const tmp = `${filePath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
|
|
22266
22188
|
try {
|
|
22267
22189
|
await writeFile6(tmp, JSON.stringify(map, null, 2), "utf-8");
|
|
@@ -22275,7 +22197,7 @@ async function writeSynonymMapAtomic(filePath, map) {
|
|
|
22275
22197
|
async function rebuildSynonymMap(directory, entries, maxPairs = DEFAULT_MAX_PAIRS) {
|
|
22276
22198
|
const filePath = resolveSynonymMapPath(directory);
|
|
22277
22199
|
const dir = path27.dirname(filePath);
|
|
22278
|
-
await
|
|
22200
|
+
await mkdir8(dir, { recursive: true });
|
|
22279
22201
|
let release = null;
|
|
22280
22202
|
try {
|
|
22281
22203
|
release = await import_proper_lockfile5.default.lock(dir, {
|
|
@@ -22326,9 +22248,9 @@ function hashContent(content) {
|
|
|
22326
22248
|
return createHash10("sha1").update(content).digest("hex");
|
|
22327
22249
|
}
|
|
22328
22250
|
async function loadConfigForPolicyCurator(directory) {
|
|
22329
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
22251
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-h251vmd1.js");
|
|
22330
22252
|
try {
|
|
22331
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
22253
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hbhw2qd7.js");
|
|
22332
22254
|
const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
|
|
22333
22255
|
return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
|
|
22334
22256
|
} catch {
|
|
@@ -22806,16 +22728,13 @@ RETRY: your last output was missing ${result.missing.join("; ")}; produce valid
|
|
|
22806
22728
|
}
|
|
22807
22729
|
async function appendCuratorSkippedEvent(directory, record) {
|
|
22808
22730
|
try {
|
|
22809
|
-
|
|
22810
|
-
await mkdir10(path28.dirname(filePath), { recursive: true });
|
|
22811
|
-
await appendFile7(filePath, `${JSON.stringify({
|
|
22731
|
+
appendCoreEventSync(directory, {
|
|
22812
22732
|
timestamp: new Date().toISOString(),
|
|
22813
22733
|
event: "curator_skipped",
|
|
22814
22734
|
entry_id: record.entry_id,
|
|
22815
22735
|
lesson: record.lesson.slice(0, 200),
|
|
22816
22736
|
reason: record.reason
|
|
22817
|
-
})
|
|
22818
|
-
`, "utf-8");
|
|
22737
|
+
});
|
|
22819
22738
|
} catch {}
|
|
22820
22739
|
}
|
|
22821
22740
|
var MESO_INSIGHT_BATCH_LIMIT = 20;
|
|
@@ -22850,7 +22769,7 @@ async function consumeInsightCandidates(directory, batchLimit = MESO_INSIGHT_BAT
|
|
|
22850
22769
|
if (!existsSync15(filePath))
|
|
22851
22770
|
return [];
|
|
22852
22771
|
const consumed = [];
|
|
22853
|
-
await transactFile(filePath, async (p) => readInsightJsonl2(await
|
|
22772
|
+
await transactFile(filePath, async (p) => readInsightJsonl2(await readFile10(p, "utf-8").catch(() => "")), async (p, data) => {
|
|
22854
22773
|
const body = data.length === 0 ? "" : `${data.map((c) => JSON.stringify(c)).join(`
|
|
22855
22774
|
`)}
|
|
22856
22775
|
`;
|
|
@@ -24707,9 +24626,9 @@ var import_proper_lockfile6 = __toESM(require_proper_lockfile(), 1);
|
|
|
24707
24626
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
24708
24627
|
import { existsSync as existsSync17, readFileSync as readFileSync14, writeFileSync as writeFileSync8 } from "fs";
|
|
24709
24628
|
import {
|
|
24710
|
-
appendFile as
|
|
24711
|
-
mkdir as
|
|
24712
|
-
readFile as
|
|
24629
|
+
appendFile as appendFile3,
|
|
24630
|
+
mkdir as mkdir9,
|
|
24631
|
+
readFile as readFile11,
|
|
24713
24632
|
rename as rename5,
|
|
24714
24633
|
truncate,
|
|
24715
24634
|
writeFile as writeFile8
|
|
@@ -25876,7 +25795,7 @@ class LocalJsonlMemoryProvider {
|
|
|
25876
25795
|
}
|
|
25877
25796
|
async withOutcomeStoreLock(fn) {
|
|
25878
25797
|
const storageDirectory = path31.dirname(this.pathFor("memories"));
|
|
25879
|
-
await
|
|
25798
|
+
await mkdir9(storageDirectory, { recursive: true });
|
|
25880
25799
|
const release = await lockfile6.lock(storageDirectory, {
|
|
25881
25800
|
realpath: false,
|
|
25882
25801
|
stale: 1e4,
|
|
@@ -26079,7 +25998,7 @@ function validateLoadedProposals(values, config) {
|
|
|
26079
25998
|
async function readJsonl(filePath) {
|
|
26080
25999
|
if (!existsSync17(filePath))
|
|
26081
26000
|
return [];
|
|
26082
|
-
const content = await
|
|
26001
|
+
const content = await readFile11(filePath, "utf-8");
|
|
26083
26002
|
const records = [];
|
|
26084
26003
|
for (const line of content.split(`
|
|
26085
26004
|
`)) {
|
|
@@ -26154,12 +26073,12 @@ function parseRewardEvent(value) {
|
|
|
26154
26073
|
};
|
|
26155
26074
|
}
|
|
26156
26075
|
async function appendJsonl(filePath, value) {
|
|
26157
|
-
await
|
|
26158
|
-
await
|
|
26076
|
+
await mkdir9(path31.dirname(filePath), { recursive: true });
|
|
26077
|
+
await appendFile3(filePath, `${JSON.stringify(value)}
|
|
26159
26078
|
`, "utf-8");
|
|
26160
26079
|
}
|
|
26161
26080
|
async function writeJsonlAtomic(filePath, values) {
|
|
26162
|
-
await
|
|
26081
|
+
await mkdir9(path31.dirname(filePath), { recursive: true });
|
|
26163
26082
|
const tmp = `${filePath}.tmp.${randomUUID6()}`;
|
|
26164
26083
|
const content = values.map((value) => JSON.stringify(value)).join(`
|
|
26165
26084
|
`) + (values.length > 0 ? `
|
|
@@ -26170,7 +26089,7 @@ async function writeJsonlAtomic(filePath, values) {
|
|
|
26170
26089
|
async function repairIncompleteJsonlTail(filePath) {
|
|
26171
26090
|
if (!existsSync17(filePath))
|
|
26172
26091
|
return;
|
|
26173
|
-
const content = await
|
|
26092
|
+
const content = await readFile11(filePath, "utf-8");
|
|
26174
26093
|
if (content.length === 0 || content.endsWith(`
|
|
26175
26094
|
`))
|
|
26176
26095
|
return;
|
|
@@ -26551,7 +26470,7 @@ function resolveRerankerCacheDir() {
|
|
|
26551
26470
|
|
|
26552
26471
|
// src/memory/jsonl-migration.ts
|
|
26553
26472
|
import { existsSync as existsSync18, renameSync as renameSync7, unlinkSync as unlinkSync6 } from "fs";
|
|
26554
|
-
import { copyFile, mkdir as
|
|
26473
|
+
import { copyFile, mkdir as mkdir10, readFile as readFile12, stat as stat4, writeFile as writeFile9 } from "fs/promises";
|
|
26555
26474
|
import * as path34 from "path";
|
|
26556
26475
|
var LEGACY_JSONL_MIGRATION_VERSION = 2;
|
|
26557
26476
|
var LEGACY_JSONL_MIGRATION_NAME = "legacy_jsonl_import_complete";
|
|
@@ -26589,7 +26508,7 @@ async function readLegacyJsonl(rootDirectory, config = {}) {
|
|
|
26589
26508
|
async function backupLegacyJsonl(rootDirectory, config = {}) {
|
|
26590
26509
|
const storageDir = resolveMemoryStorageDir(rootDirectory, config);
|
|
26591
26510
|
const backupDir = path34.join(storageDir, "backups");
|
|
26592
|
-
await
|
|
26511
|
+
await mkdir10(backupDir, { recursive: true });
|
|
26593
26512
|
const results = [];
|
|
26594
26513
|
for (const filename of [
|
|
26595
26514
|
"memories.jsonl",
|
|
@@ -26611,7 +26530,7 @@ async function backupLegacyJsonl(rootDirectory, config = {}) {
|
|
|
26611
26530
|
}
|
|
26612
26531
|
async function writeJsonlExport(rootDirectory, config, memories, proposals, outcomeEvents = []) {
|
|
26613
26532
|
const exportDir = path34.join(resolveMemoryStorageDir(rootDirectory, config), "export");
|
|
26614
|
-
await
|
|
26533
|
+
await mkdir10(exportDir, { recursive: true });
|
|
26615
26534
|
const memoriesPath = path34.join(exportDir, "memories.jsonl");
|
|
26616
26535
|
const proposalsPath = path34.join(exportDir, "proposals.jsonl");
|
|
26617
26536
|
const outcomesPath = path34.join(exportDir, "outcome-events.jsonl");
|
|
@@ -26649,7 +26568,7 @@ async function writeJsonlExport(rootDirectory, config, memories, proposals, outc
|
|
|
26649
26568
|
}
|
|
26650
26569
|
async function writeMigrationReport(rootDirectory, report, config = {}) {
|
|
26651
26570
|
const reportPath = path34.join(resolveMemoryStorageDir(rootDirectory, config), "migration-report.json");
|
|
26652
|
-
await
|
|
26571
|
+
await mkdir10(path34.dirname(reportPath), { recursive: true });
|
|
26653
26572
|
const reportTempPath = path34.join(path34.dirname(reportPath), `${path34.basename(reportPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
26654
26573
|
try {
|
|
26655
26574
|
await writeFile9(reportTempPath, `${JSON.stringify(report, null, 2)}
|
|
@@ -26668,7 +26587,7 @@ async function readMigrationReport(rootDirectory, config = {}) {
|
|
|
26668
26587
|
if (!existsSync18(reportPath))
|
|
26669
26588
|
return null;
|
|
26670
26589
|
try {
|
|
26671
|
-
return JSON.parse(await
|
|
26590
|
+
return JSON.parse(await readFile12(reportPath, "utf-8"));
|
|
26672
26591
|
} catch {
|
|
26673
26592
|
return null;
|
|
26674
26593
|
}
|
|
@@ -26822,7 +26741,7 @@ async function readJsonlRows(filePath) {
|
|
|
26822
26741
|
if (!existsSync18(filePath)) {
|
|
26823
26742
|
return { rows: [], invalidRows: [], totalRows: 0 };
|
|
26824
26743
|
}
|
|
26825
|
-
const content = await
|
|
26744
|
+
const content = await readFile12(filePath, "utf-8");
|
|
26826
26745
|
const rows = [];
|
|
26827
26746
|
const invalidRows = [];
|
|
26828
26747
|
let totalRows = 0;
|
|
@@ -30106,7 +30025,10 @@ async function gatherLedgerRejections(directory, sessionId) {
|
|
|
30106
30025
|
}
|
|
30107
30026
|
return readLedger(target);
|
|
30108
30027
|
};
|
|
30109
|
-
let content =
|
|
30028
|
+
let content = readCoreEvents(directory).text;
|
|
30029
|
+
if (content === "") {
|
|
30030
|
+
content = null;
|
|
30031
|
+
}
|
|
30110
30032
|
if (content === null) {
|
|
30111
30033
|
try {
|
|
30112
30034
|
const archiveRoot = path39.join(directory, ".swarm", "archive");
|
|
@@ -30126,6 +30048,8 @@ async function gatherLedgerRejections(directory, sessionId) {
|
|
|
30126
30048
|
continue;
|
|
30127
30049
|
try {
|
|
30128
30050
|
const parsed = JSON.parse(trimmed);
|
|
30051
|
+
if (parsed.type === "swarm-events-manifest")
|
|
30052
|
+
continue;
|
|
30129
30053
|
if (typeof parsed.type === "string" && REJECTION_LEDGER_EVENT_TYPES.has(parsed.type)) {
|
|
30130
30054
|
if (sessionId !== undefined) {
|
|
30131
30055
|
const eventSession = typeof parsed.sessionId === "string" ? parsed.sessionId : typeof parsed.sessionID === "string" ? parsed.sessionID : undefined;
|
|
@@ -30652,12 +30576,12 @@ var _internals35 = {
|
|
|
30652
30576
|
|
|
30653
30577
|
// src/services/skill-improver.ts
|
|
30654
30578
|
import { existsSync as existsSync22 } from "fs";
|
|
30655
|
-
import { mkdir as
|
|
30579
|
+
import { mkdir as mkdir12, readFile as readFile13 } from "fs/promises";
|
|
30656
30580
|
import * as path41 from "path";
|
|
30657
30581
|
init_logger();
|
|
30658
30582
|
|
|
30659
30583
|
// src/services/trajectory-cluster.ts
|
|
30660
|
-
import { mkdir as
|
|
30584
|
+
import { mkdir as mkdir11, writeFile as writeFile10 } from "fs/promises";
|
|
30661
30585
|
import * as path40 from "path";
|
|
30662
30586
|
init_logger();
|
|
30663
30587
|
var MACRO_TRAJECTORY_WINDOW = 200;
|
|
@@ -30826,7 +30750,7 @@ async function writeMotifProposals(directory, opts = {}) {
|
|
|
30826
30750
|
if (emitted.length === 0)
|
|
30827
30751
|
return result;
|
|
30828
30752
|
const proposalsDir = validateSwarmPath(directory, path40.join("skills", "proposals"));
|
|
30829
|
-
await
|
|
30753
|
+
await mkdir11(proposalsDir, { recursive: true });
|
|
30830
30754
|
const written = [];
|
|
30831
30755
|
for (const decision of emitted) {
|
|
30832
30756
|
const motif = selected[decision.index];
|
|
@@ -31016,7 +30940,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
|
|
|
31016
30940
|
if (emitted.length === 0)
|
|
31017
30941
|
return result;
|
|
31018
30942
|
const proposalsDir = validateSwarmPath(directory, path40.join("skills", "proposals"));
|
|
31019
|
-
await
|
|
30943
|
+
await mkdir11(proposalsDir, { recursive: true });
|
|
31020
30944
|
const written = [];
|
|
31021
30945
|
for (const decision of emitted) {
|
|
31022
30946
|
const motif = selected[decision.index];
|
|
@@ -31159,7 +31083,7 @@ function timestampSlug(d) {
|
|
|
31159
31083
|
return d.toISOString().replace(/[:.]/g, "-");
|
|
31160
31084
|
}
|
|
31161
31085
|
async function atomicWrite(p, content) {
|
|
31162
|
-
await
|
|
31086
|
+
await mkdir12(path41.dirname(p), { recursive: true });
|
|
31163
31087
|
await atomicWriteSwarmFile(p, content);
|
|
31164
31088
|
}
|
|
31165
31089
|
async function gatherInventory(directory) {
|
|
@@ -31174,7 +31098,7 @@ async function gatherInventory(directory) {
|
|
|
31174
31098
|
for (const skill of skills.active) {
|
|
31175
31099
|
let content;
|
|
31176
31100
|
try {
|
|
31177
|
-
content = await
|
|
31101
|
+
content = await readFile13(skill.path, "utf-8");
|
|
31178
31102
|
} catch {
|
|
31179
31103
|
continue;
|
|
31180
31104
|
}
|
|
@@ -31350,7 +31274,7 @@ async function reconcileStaleActiveSkills(directory, options = {}) {
|
|
|
31350
31274
|
for (const skill of skills.active) {
|
|
31351
31275
|
let content;
|
|
31352
31276
|
try {
|
|
31353
|
-
content = await
|
|
31277
|
+
content = await readFile13(skill.path, "utf-8");
|
|
31354
31278
|
} catch {
|
|
31355
31279
|
continue;
|
|
31356
31280
|
}
|
|
@@ -33094,6 +33018,7 @@ var ARCHIVE_ARTIFACTS = [
|
|
|
33094
33018
|
"plan-ledger.jsonl",
|
|
33095
33019
|
"context.md",
|
|
33096
33020
|
"events.jsonl",
|
|
33021
|
+
"events-authority-index.json",
|
|
33097
33022
|
"handoff.md",
|
|
33098
33023
|
"handoff-prompt.md",
|
|
33099
33024
|
"handoff-consumed.md",
|
|
@@ -33127,6 +33052,7 @@ var ACTIVE_STATE_TO_CLEAN = [
|
|
|
33127
33052
|
"plan.md",
|
|
33128
33053
|
"plan-ledger.jsonl",
|
|
33129
33054
|
"events.jsonl",
|
|
33055
|
+
"events-authority-index.json",
|
|
33130
33056
|
"handoff.md",
|
|
33131
33057
|
"handoff-prompt.md",
|
|
33132
33058
|
"handoff-consumed.md",
|
|
@@ -33524,7 +33450,7 @@ async function runFinalizeStage(ctx) {
|
|
|
33524
33450
|
}
|
|
33525
33451
|
}
|
|
33526
33452
|
try {
|
|
33527
|
-
const { CuratorConfigSchema: CCS } = await import("./schema-
|
|
33453
|
+
const { CuratorConfigSchema: CCS } = await import("./schema-h251vmd1.js");
|
|
33528
33454
|
const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
|
|
33529
33455
|
const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
|
|
33530
33456
|
if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
|
|
@@ -33563,6 +33489,12 @@ async function runArchiveStage(ctx) {
|
|
|
33563
33489
|
const msg = finalizeErr instanceof Error ? finalizeErr.message : String(finalizeErr);
|
|
33564
33490
|
ctx.warnings.push(`Context-map telemetry finalize before archive failed: ${msg}`);
|
|
33565
33491
|
}
|
|
33492
|
+
try {
|
|
33493
|
+
_internals41.finalizeCoreEvents(ctx.directory);
|
|
33494
|
+
} catch (finalizeErr) {
|
|
33495
|
+
const msg = finalizeErr instanceof Error ? finalizeErr.message : String(finalizeErr);
|
|
33496
|
+
ctx.warnings.push(`Core events finalize before archive failed: ${msg}`);
|
|
33497
|
+
}
|
|
33566
33498
|
const linkedKnowledgeShared = isLinked(ctx.directory);
|
|
33567
33499
|
if (linkedKnowledgeShared) {
|
|
33568
33500
|
ctx.warnings.push("Worktree is linked: shared knowledge (knowledge.jsonl, knowledge-rejected.jsonl) lives in the link store and is not archived or cleaned by /swarm close. Manage it via the link.");
|
|
@@ -34388,11 +34320,14 @@ var _internals41 = {
|
|
|
34388
34320
|
closePlanTerminalState: reconcileCloseTerminalStateForPlan,
|
|
34389
34321
|
endAgentSession,
|
|
34390
34322
|
flushAndDrainTelemetry: async () => {
|
|
34391
|
-
const { flushAndDrainTelemetry } = await import("./telemetry-
|
|
34323
|
+
const { flushAndDrainTelemetry } = await import("./telemetry-jtq6px7k.js");
|
|
34392
34324
|
return flushAndDrainTelemetry();
|
|
34393
34325
|
},
|
|
34394
34326
|
finalizeContextTelemetry: (directory) => {
|
|
34395
34327
|
finalizeContextTelemetry(directory);
|
|
34328
|
+
},
|
|
34329
|
+
finalizeCoreEvents: (directory) => {
|
|
34330
|
+
finalizeCoreEventsForClose(directory);
|
|
34396
34331
|
}
|
|
34397
34332
|
};
|
|
34398
34333
|
|
|
@@ -34657,7 +34592,7 @@ init_schema();
|
|
|
34657
34592
|
|
|
34658
34593
|
// src/services/skill-consolidation.ts
|
|
34659
34594
|
import { existsSync as existsSync28 } from "fs";
|
|
34660
|
-
import { mkdir as
|
|
34595
|
+
import { mkdir as mkdir13, readFile as readFile14 } from "fs/promises";
|
|
34661
34596
|
import * as path48 from "path";
|
|
34662
34597
|
var DEFAULT_CONSOLIDATION_INTERVAL_HOURS = 24;
|
|
34663
34598
|
var DEFAULT_CONSOLIDATION_MAX_CALLS_PER_RUN = 1;
|
|
@@ -34671,7 +34606,7 @@ async function readState2(directory) {
|
|
|
34671
34606
|
if (!existsSync28(filePath))
|
|
34672
34607
|
return {};
|
|
34673
34608
|
try {
|
|
34674
|
-
const parsed = JSON.parse(await
|
|
34609
|
+
const parsed = JSON.parse(await readFile14(filePath, "utf-8"));
|
|
34675
34610
|
if (!parsed || typeof parsed !== "object")
|
|
34676
34611
|
return {};
|
|
34677
34612
|
return parsed;
|
|
@@ -34680,7 +34615,7 @@ async function readState2(directory) {
|
|
|
34680
34615
|
}
|
|
34681
34616
|
}
|
|
34682
34617
|
async function atomicWrite2(filePath, content) {
|
|
34683
|
-
await
|
|
34618
|
+
await mkdir13(path48.dirname(filePath), { recursive: true });
|
|
34684
34619
|
await atomicWriteSwarmFile(filePath, content);
|
|
34685
34620
|
}
|
|
34686
34621
|
async function writeState2(directory, state) {
|
|
@@ -35006,7 +34941,7 @@ import { promisify as promisify2 } from "util";
|
|
|
35006
34941
|
init_zod();
|
|
35007
34942
|
import * as child_process3 from "child_process";
|
|
35008
34943
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
35009
|
-
import { readdir as readdir4, readFile as
|
|
34944
|
+
import { readdir as readdir4, readFile as readFile15, stat as stat5 } from "fs/promises";
|
|
35010
34945
|
import * as path49 from "path";
|
|
35011
34946
|
import { promisify } from "util";
|
|
35012
34947
|
function getExecFileAsync() {
|
|
@@ -35133,7 +35068,7 @@ async function getStaticEdges(directory) {
|
|
|
35133
35068
|
const sourceFiles = await scanSourceFiles(directory);
|
|
35134
35069
|
for (const sourceFile of sourceFiles) {
|
|
35135
35070
|
try {
|
|
35136
|
-
const content = await
|
|
35071
|
+
const content = await readFile15(sourceFile, "utf-8");
|
|
35137
35072
|
const importRegex = /(?:import|require)\s*(?:\(?\s*['"`]|.*?from\s+['"`])([^'"`]+)['"`]/g;
|
|
35138
35073
|
for (let match = importRegex.exec(content);match !== null; match = importRegex.exec(content)) {
|
|
35139
35074
|
const importPath = match[1].trim();
|
|
@@ -35717,9 +35652,9 @@ var _internals45 = {
|
|
|
35717
35652
|
loadPluginConfigWithMeta,
|
|
35718
35653
|
loadCuratorDeps: async () => {
|
|
35719
35654
|
const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
|
|
35720
|
-
import("./schema-
|
|
35721
|
-
import("./curator-
|
|
35722
|
-
import("./curator-llm-factory-
|
|
35655
|
+
import("./schema-h251vmd1.js"),
|
|
35656
|
+
import("./curator-6w4frzdz.js"),
|
|
35657
|
+
import("./curator-llm-factory-8fstpeqh.js")
|
|
35723
35658
|
]);
|
|
35724
35659
|
return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
|
|
35725
35660
|
}
|
|
@@ -36360,7 +36295,7 @@ init_git_executable();
|
|
|
36360
36295
|
// src/services/knowledge-diagnostics.ts
|
|
36361
36296
|
init_package();
|
|
36362
36297
|
import { existsSync as existsSync31, readFileSync as readFileSync21 } from "fs";
|
|
36363
|
-
import { readFile as
|
|
36298
|
+
import { readFile as readFile16 } from "fs/promises";
|
|
36364
36299
|
import { join as join41 } from "path";
|
|
36365
36300
|
|
|
36366
36301
|
// src/services/version-check.ts
|
|
@@ -36437,7 +36372,7 @@ var INSIGHT_BACKLOG_WARN = 50;
|
|
|
36437
36372
|
async function readRawLines(filePath) {
|
|
36438
36373
|
if (!existsSync31(filePath))
|
|
36439
36374
|
return { entries: [], corrupt: 0 };
|
|
36440
|
-
const content = await
|
|
36375
|
+
const content = await readFile16(filePath, "utf-8");
|
|
36441
36376
|
const entries = [];
|
|
36442
36377
|
let corrupt = 0;
|
|
36443
36378
|
for (const line of content.split(`
|
|
@@ -36709,7 +36644,7 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36709
36644
|
let scanCompleted = false;
|
|
36710
36645
|
let scanRemaining = 0;
|
|
36711
36646
|
try {
|
|
36712
|
-
const { getScanStatus } = await import("./scan-cursor-
|
|
36647
|
+
const { getScanStatus } = await import("./scan-cursor-3ba1spad.js");
|
|
36713
36648
|
const status = await getScanStatus(directory);
|
|
36714
36649
|
scanGeneration = status.generation;
|
|
36715
36650
|
scanCompleted = status.completed;
|
|
@@ -36717,19 +36652,19 @@ async function computeCurationDiagnostics(directory, entries) {
|
|
|
36717
36652
|
} catch {}
|
|
36718
36653
|
let configMatch = null;
|
|
36719
36654
|
try {
|
|
36720
|
-
const { isLinked: isLinked2 } = await import("./knowledge-link-
|
|
36655
|
+
const { isLinked: isLinked2 } = await import("./knowledge-link-a5f89833.js");
|
|
36721
36656
|
if (isLinked2(directory)) {
|
|
36722
|
-
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-
|
|
36657
|
+
const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-h251vmd1.js");
|
|
36723
36658
|
let config;
|
|
36724
36659
|
try {
|
|
36725
|
-
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-
|
|
36660
|
+
const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-hbhw2qd7.js");
|
|
36726
36661
|
const loaded = loadPluginConfigWithMeta2(directory);
|
|
36727
36662
|
config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
|
|
36728
36663
|
} catch {
|
|
36729
36664
|
config = KnowledgeConfigSchema2.parse({});
|
|
36730
36665
|
}
|
|
36731
36666
|
const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
|
|
36732
|
-
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-
|
|
36667
|
+
const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-4jxx3ey4.js");
|
|
36733
36668
|
const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
|
|
36734
36669
|
const cohortFp = await readCohortConfigFingerprint(directory);
|
|
36735
36670
|
configMatch = cohortFp === null ? null : currentFp === cohortFp;
|
|
@@ -36764,7 +36699,7 @@ async function countPendingProposals(directory) {
|
|
|
36764
36699
|
if (!existsSync31(proposalsPath))
|
|
36765
36700
|
return 0;
|
|
36766
36701
|
try {
|
|
36767
|
-
const content = await
|
|
36702
|
+
const content = await readFile16(proposalsPath, "utf-8");
|
|
36768
36703
|
let n = 0;
|
|
36769
36704
|
for (const line of content.split(`
|
|
36770
36705
|
`)) {
|
|
@@ -36786,7 +36721,7 @@ async function safeJsonlCount(filePath) {
|
|
|
36786
36721
|
if (!filePath || !existsSync31(filePath))
|
|
36787
36722
|
return 0;
|
|
36788
36723
|
try {
|
|
36789
|
-
const content = await
|
|
36724
|
+
const content = await readFile16(filePath, "utf-8");
|
|
36790
36725
|
let n = 0;
|
|
36791
36726
|
for (const line of content.split(`
|
|
36792
36727
|
`)) {
|
|
@@ -37331,8 +37266,7 @@ async function checkCheckpointManifest(directory) {
|
|
|
37331
37266
|
}
|
|
37332
37267
|
}
|
|
37333
37268
|
async function checkEventStreamIntegrity(directory) {
|
|
37334
|
-
|
|
37335
|
-
if (!existsSync32(eventsPath)) {
|
|
37269
|
+
if (getCoreEventCoverage(directory) === "empty") {
|
|
37336
37270
|
return {
|
|
37337
37271
|
name: "Event Stream",
|
|
37338
37272
|
status: "\u2705",
|
|
@@ -37340,8 +37274,8 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
37340
37274
|
};
|
|
37341
37275
|
}
|
|
37342
37276
|
try {
|
|
37343
|
-
const
|
|
37344
|
-
const lines =
|
|
37277
|
+
const window = readCoreEvents(directory);
|
|
37278
|
+
const lines = window.text.split(`
|
|
37345
37279
|
`).filter((line) => line.trim() !== "");
|
|
37346
37280
|
let malformedCount = 0;
|
|
37347
37281
|
for (const line of lines) {
|
|
@@ -37351,11 +37285,12 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
37351
37285
|
malformedCount++;
|
|
37352
37286
|
}
|
|
37353
37287
|
}
|
|
37288
|
+
const coverageNote = window.coverage === "truncated" ? " (retained window \u2014 compacted history excluded)" : "";
|
|
37354
37289
|
if (malformedCount === 0) {
|
|
37355
37290
|
return {
|
|
37356
37291
|
name: "Event Stream",
|
|
37357
37292
|
status: "\u2705",
|
|
37358
|
-
detail: `events.jsonl is valid \u2014 ${lines.length} event(s)`
|
|
37293
|
+
detail: `events.jsonl is valid \u2014 ${lines.length} event(s)${coverageNote}`
|
|
37359
37294
|
};
|
|
37360
37295
|
}
|
|
37361
37296
|
return {
|
|
@@ -37372,8 +37307,7 @@ async function checkEventStreamIntegrity(directory) {
|
|
|
37372
37307
|
}
|
|
37373
37308
|
}
|
|
37374
37309
|
async function checkSteeringDirectives(directory) {
|
|
37375
|
-
|
|
37376
|
-
if (!existsSync32(eventsPath)) {
|
|
37310
|
+
if (getCoreEventCoverage(directory) === "empty") {
|
|
37377
37311
|
return {
|
|
37378
37312
|
name: "Steering Directives",
|
|
37379
37313
|
status: "\u2705",
|
|
@@ -37381,8 +37315,8 @@ async function checkSteeringDirectives(directory) {
|
|
|
37381
37315
|
};
|
|
37382
37316
|
}
|
|
37383
37317
|
try {
|
|
37384
|
-
const
|
|
37385
|
-
const lines =
|
|
37318
|
+
const window = readCoreEvents(directory);
|
|
37319
|
+
const lines = window.text.split(`
|
|
37386
37320
|
`).filter((line) => line.trim() !== "");
|
|
37387
37321
|
const directivesIssued = [];
|
|
37388
37322
|
const consumedIds = new Set;
|
|
@@ -37399,10 +37333,11 @@ async function checkSteeringDirectives(directory) {
|
|
|
37399
37333
|
}
|
|
37400
37334
|
const unconsumed = directivesIssued.filter((id) => !consumedIds.has(id));
|
|
37401
37335
|
if (unconsumed.length === 0) {
|
|
37336
|
+
const coverageNote = window.coverage === "truncated" ? " (within the retained event window)" : "";
|
|
37402
37337
|
return {
|
|
37403
37338
|
name: "Steering Directives",
|
|
37404
37339
|
status: "\u2705",
|
|
37405
|
-
detail:
|
|
37340
|
+
detail: `All steering directives acknowledged (or none issued)${coverageNote}`
|
|
37406
37341
|
};
|
|
37407
37342
|
}
|
|
37408
37343
|
return {
|
|
@@ -38033,7 +37968,7 @@ async function handleDoctorCommand(directory, args) {
|
|
|
38033
37968
|
const result = runConfigDoctor(config, directory);
|
|
38034
37969
|
let output;
|
|
38035
37970
|
if (enableAutoFix && result.hasAutoFixableIssues) {
|
|
38036
|
-
const { runConfigDoctorWithFixes } = await import("./config-doctor-
|
|
37971
|
+
const { runConfigDoctorWithFixes } = await import("./config-doctor-fx8d6pma.js");
|
|
38037
37972
|
const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
|
|
38038
37973
|
applyLossy: true
|
|
38039
37974
|
});
|
|
@@ -38973,7 +38908,7 @@ async function handleEvidenceCommand(directory, args) {
|
|
|
38973
38908
|
return formatTaskEvidenceMarkdown(evidenceData);
|
|
38974
38909
|
}
|
|
38975
38910
|
async function handleEvidenceSummaryCommand(directory) {
|
|
38976
|
-
const { buildEvidenceSummary } = await import("./evidence-summary-service-
|
|
38911
|
+
const { buildEvidenceSummary } = await import("./evidence-summary-service-x00z38n2.js");
|
|
38977
38912
|
const artifact = await buildEvidenceSummary(directory);
|
|
38978
38913
|
if (!artifact) {
|
|
38979
38914
|
return "No plan found. Run `/swarm plan` to check plan status.";
|
|
@@ -41962,7 +41897,974 @@ var javaRules = [
|
|
|
41962
41897
|
}
|
|
41963
41898
|
];
|
|
41964
41899
|
|
|
41900
|
+
// src/sast/rules/javascript-call-classifier.ts
|
|
41901
|
+
var MAX_ANALYSIS_BYTES = 512 * 1024;
|
|
41902
|
+
var CHILD_PROCESS_MODULES = new Set(["child_process", "node:child_process"]);
|
|
41903
|
+
var analysisByContext = new WeakMap;
|
|
41904
|
+
var dispositionByContext = new WeakMap;
|
|
41905
|
+
var tokenPairsByList = new WeakMap;
|
|
41906
|
+
var ASSIGNMENTS = new Set([
|
|
41907
|
+
"=",
|
|
41908
|
+
"+=",
|
|
41909
|
+
"-=",
|
|
41910
|
+
"*=",
|
|
41911
|
+
"/=",
|
|
41912
|
+
"%=",
|
|
41913
|
+
"&&=",
|
|
41914
|
+
"||=",
|
|
41915
|
+
"??="
|
|
41916
|
+
]);
|
|
41917
|
+
var DECLARATION_KEYWORDS = new Set(["const", "let", "var"]);
|
|
41918
|
+
function isIdentifierStart(char) {
|
|
41919
|
+
return /[A-Za-z_$]/.test(char);
|
|
41920
|
+
}
|
|
41921
|
+
function isIdentifierPart(char) {
|
|
41922
|
+
return /[A-Za-z0-9_$]/.test(char);
|
|
41923
|
+
}
|
|
41924
|
+
function canStartRegex(previous) {
|
|
41925
|
+
if (!previous)
|
|
41926
|
+
return true;
|
|
41927
|
+
if (previous.kind === "identifier") {
|
|
41928
|
+
return [
|
|
41929
|
+
"return",
|
|
41930
|
+
"throw",
|
|
41931
|
+
"case",
|
|
41932
|
+
"delete",
|
|
41933
|
+
"typeof",
|
|
41934
|
+
"void",
|
|
41935
|
+
"yield",
|
|
41936
|
+
"await"
|
|
41937
|
+
].includes(previous.value);
|
|
41938
|
+
}
|
|
41939
|
+
return previous.kind === "punctuator" && [
|
|
41940
|
+
"(",
|
|
41941
|
+
"[",
|
|
41942
|
+
"{",
|
|
41943
|
+
"=",
|
|
41944
|
+
":",
|
|
41945
|
+
",",
|
|
41946
|
+
";",
|
|
41947
|
+
"!",
|
|
41948
|
+
"?",
|
|
41949
|
+
"=>",
|
|
41950
|
+
"&&",
|
|
41951
|
+
"||",
|
|
41952
|
+
"??"
|
|
41953
|
+
].includes(previous.value);
|
|
41954
|
+
}
|
|
41955
|
+
function tokenize2(content) {
|
|
41956
|
+
const tokens = [];
|
|
41957
|
+
let malformed = false;
|
|
41958
|
+
let index = 0;
|
|
41959
|
+
while (index < content.length) {
|
|
41960
|
+
const char = content[index];
|
|
41961
|
+
const next = content[index + 1];
|
|
41962
|
+
if (/\s/.test(char)) {
|
|
41963
|
+
index++;
|
|
41964
|
+
continue;
|
|
41965
|
+
}
|
|
41966
|
+
if (char === "/" && next === "/") {
|
|
41967
|
+
index += 2;
|
|
41968
|
+
while (index < content.length && content[index] !== `
|
|
41969
|
+
`)
|
|
41970
|
+
index++;
|
|
41971
|
+
continue;
|
|
41972
|
+
}
|
|
41973
|
+
if (char === "/" && next === "*") {
|
|
41974
|
+
const start = index;
|
|
41975
|
+
index += 2;
|
|
41976
|
+
while (index < content.length && !(content[index] === "*" && content[index + 1] === "/")) {
|
|
41977
|
+
index++;
|
|
41978
|
+
}
|
|
41979
|
+
if (index >= content.length) {
|
|
41980
|
+
malformed = true;
|
|
41981
|
+
break;
|
|
41982
|
+
}
|
|
41983
|
+
index += 2;
|
|
41984
|
+
if (index <= start)
|
|
41985
|
+
malformed = true;
|
|
41986
|
+
continue;
|
|
41987
|
+
}
|
|
41988
|
+
if (char === '"' || char === "'") {
|
|
41989
|
+
const quote = char;
|
|
41990
|
+
const start = index++;
|
|
41991
|
+
let value2 = "";
|
|
41992
|
+
let closed = false;
|
|
41993
|
+
while (index < content.length) {
|
|
41994
|
+
const current = content[index];
|
|
41995
|
+
if (current === "\\") {
|
|
41996
|
+
value2 += current;
|
|
41997
|
+
if (index + 1 < content.length)
|
|
41998
|
+
value2 += content[index + 1];
|
|
41999
|
+
index += 2;
|
|
42000
|
+
continue;
|
|
42001
|
+
}
|
|
42002
|
+
if (current === quote) {
|
|
42003
|
+
index++;
|
|
42004
|
+
closed = true;
|
|
42005
|
+
break;
|
|
42006
|
+
}
|
|
42007
|
+
value2 += current;
|
|
42008
|
+
index++;
|
|
42009
|
+
}
|
|
42010
|
+
if (!closed)
|
|
42011
|
+
malformed = true;
|
|
42012
|
+
tokens.push({ kind: "string", value: value2, start, end: index });
|
|
42013
|
+
continue;
|
|
42014
|
+
}
|
|
42015
|
+
if (char === "`") {
|
|
42016
|
+
const start = index++;
|
|
42017
|
+
tokens.push({ kind: "template", value: "", start, end: start + 1 });
|
|
42018
|
+
let closed = false;
|
|
42019
|
+
while (index < content.length) {
|
|
42020
|
+
if (content[index] === "\\") {
|
|
42021
|
+
index += 2;
|
|
42022
|
+
continue;
|
|
42023
|
+
}
|
|
42024
|
+
if (content[index] === "$" && content[index + 1] === "{") {
|
|
42025
|
+
const expressionStart = index + 2;
|
|
42026
|
+
let cursor = expressionStart;
|
|
42027
|
+
let depth = 1;
|
|
42028
|
+
let quote = null;
|
|
42029
|
+
while (cursor < content.length && depth > 0) {
|
|
42030
|
+
const current = content[cursor];
|
|
42031
|
+
if (quote) {
|
|
42032
|
+
if (current === "\\")
|
|
42033
|
+
cursor++;
|
|
42034
|
+
else if (current === quote)
|
|
42035
|
+
quote = null;
|
|
42036
|
+
} else if (current === '"' || current === "'")
|
|
42037
|
+
quote = current;
|
|
42038
|
+
else if (current === "{")
|
|
42039
|
+
depth++;
|
|
42040
|
+
else if (current === "}")
|
|
42041
|
+
depth--;
|
|
42042
|
+
cursor++;
|
|
42043
|
+
}
|
|
42044
|
+
if (depth !== 0) {
|
|
42045
|
+
malformed = true;
|
|
42046
|
+
index = cursor;
|
|
42047
|
+
break;
|
|
42048
|
+
}
|
|
42049
|
+
const nested = tokenize2(content.slice(expressionStart, cursor - 1));
|
|
42050
|
+
for (const token of nested.tokens) {
|
|
42051
|
+
tokens.push({
|
|
42052
|
+
...token,
|
|
42053
|
+
start: token.start + expressionStart,
|
|
42054
|
+
end: token.end + expressionStart
|
|
42055
|
+
});
|
|
42056
|
+
}
|
|
42057
|
+
malformed ||= nested.malformed;
|
|
42058
|
+
index = cursor;
|
|
42059
|
+
continue;
|
|
42060
|
+
}
|
|
42061
|
+
if (content[index] === "`") {
|
|
42062
|
+
index++;
|
|
42063
|
+
closed = true;
|
|
42064
|
+
break;
|
|
42065
|
+
}
|
|
42066
|
+
index++;
|
|
42067
|
+
}
|
|
42068
|
+
if (!closed)
|
|
42069
|
+
malformed = true;
|
|
42070
|
+
continue;
|
|
42071
|
+
}
|
|
42072
|
+
if (char === "/" && canStartRegex(tokens.at(-1))) {
|
|
42073
|
+
const start = index++;
|
|
42074
|
+
let inClass = false;
|
|
42075
|
+
let closed = false;
|
|
42076
|
+
while (index < content.length) {
|
|
42077
|
+
const current = content[index];
|
|
42078
|
+
if (current === "\\") {
|
|
42079
|
+
index += 2;
|
|
42080
|
+
continue;
|
|
42081
|
+
}
|
|
42082
|
+
if (current === "[")
|
|
42083
|
+
inClass = true;
|
|
42084
|
+
if (current === "]")
|
|
42085
|
+
inClass = false;
|
|
42086
|
+
if (current === "/" && !inClass) {
|
|
42087
|
+
index++;
|
|
42088
|
+
while (index < content.length && /[A-Za-z]/.test(content[index]))
|
|
42089
|
+
index++;
|
|
42090
|
+
closed = true;
|
|
42091
|
+
break;
|
|
42092
|
+
}
|
|
42093
|
+
if (current === `
|
|
42094
|
+
`)
|
|
42095
|
+
break;
|
|
42096
|
+
index++;
|
|
42097
|
+
}
|
|
42098
|
+
if (!closed)
|
|
42099
|
+
malformed = true;
|
|
42100
|
+
tokens.push({
|
|
42101
|
+
kind: "regex",
|
|
42102
|
+
value: content.slice(start, index),
|
|
42103
|
+
start,
|
|
42104
|
+
end: index
|
|
42105
|
+
});
|
|
42106
|
+
continue;
|
|
42107
|
+
}
|
|
42108
|
+
if (isIdentifierStart(char)) {
|
|
42109
|
+
const start = index++;
|
|
42110
|
+
while (index < content.length && isIdentifierPart(content[index]))
|
|
42111
|
+
index++;
|
|
42112
|
+
tokens.push({
|
|
42113
|
+
kind: "identifier",
|
|
42114
|
+
value: content.slice(start, index),
|
|
42115
|
+
start,
|
|
42116
|
+
end: index
|
|
42117
|
+
});
|
|
42118
|
+
continue;
|
|
42119
|
+
}
|
|
42120
|
+
if (/\d/.test(char)) {
|
|
42121
|
+
const start = index++;
|
|
42122
|
+
while (index < content.length && /[\w.]/.test(content[index]))
|
|
42123
|
+
index++;
|
|
42124
|
+
tokens.push({
|
|
42125
|
+
kind: "number",
|
|
42126
|
+
value: content.slice(start, index),
|
|
42127
|
+
start,
|
|
42128
|
+
end: index
|
|
42129
|
+
});
|
|
42130
|
+
continue;
|
|
42131
|
+
}
|
|
42132
|
+
const punctuator = [
|
|
42133
|
+
"?.",
|
|
42134
|
+
"=>",
|
|
42135
|
+
"===",
|
|
42136
|
+
"!==",
|
|
42137
|
+
"==",
|
|
42138
|
+
"!=",
|
|
42139
|
+
"++",
|
|
42140
|
+
"--",
|
|
42141
|
+
"+=",
|
|
42142
|
+
"-=",
|
|
42143
|
+
"*=",
|
|
42144
|
+
"/=",
|
|
42145
|
+
"%=",
|
|
42146
|
+
"&&=",
|
|
42147
|
+
"||=",
|
|
42148
|
+
"??=",
|
|
42149
|
+
"&&",
|
|
42150
|
+
"||",
|
|
42151
|
+
"??",
|
|
42152
|
+
"..."
|
|
42153
|
+
].find((candidate) => content.startsWith(candidate, index));
|
|
42154
|
+
const value = punctuator ?? char;
|
|
42155
|
+
tokens.push({
|
|
42156
|
+
kind: "punctuator",
|
|
42157
|
+
value,
|
|
42158
|
+
start: index,
|
|
42159
|
+
end: index + value.length
|
|
42160
|
+
});
|
|
42161
|
+
index += value.length;
|
|
42162
|
+
}
|
|
42163
|
+
return { tokens, malformed };
|
|
42164
|
+
}
|
|
42165
|
+
function addDeclaration(analysis, name) {
|
|
42166
|
+
analysis.declarations.set(name, (analysis.declarations.get(name) ?? 0) + 1);
|
|
42167
|
+
}
|
|
42168
|
+
function addFact(analysis, name, fact, tokenIndex) {
|
|
42169
|
+
const facts = analysis.facts.get(name) ?? new Set;
|
|
42170
|
+
facts.add(fact);
|
|
42171
|
+
analysis.facts.set(name, facts);
|
|
42172
|
+
const scope = declarationScope(analysis, tokenIndex);
|
|
42173
|
+
const scopedFacts = analysis.factScopes.get(name) ?? new Map;
|
|
42174
|
+
const factsAtScope = scopedFacts.get(scope) ?? new Set;
|
|
42175
|
+
factsAtScope.add(fact);
|
|
42176
|
+
scopedFacts.set(scope, factsAtScope);
|
|
42177
|
+
analysis.factScopes.set(name, scopedFacts);
|
|
42178
|
+
}
|
|
42179
|
+
function addScopedMarker(store, name, scope) {
|
|
42180
|
+
const scopes = store.get(name) ?? new Set;
|
|
42181
|
+
scopes.add(scope);
|
|
42182
|
+
store.set(name, scopes);
|
|
42183
|
+
}
|
|
42184
|
+
function hasScopedMarker(store, name, scope) {
|
|
42185
|
+
return scope !== null && (store.get(name)?.has(scope) ?? false);
|
|
42186
|
+
}
|
|
42187
|
+
function visibleScopeAt(analysis, name, callIndex) {
|
|
42188
|
+
return visibleDeclarationScope(analysis, name, callIndex) ?? analysis.scopeAtToken[callIndex] ?? 0;
|
|
42189
|
+
}
|
|
42190
|
+
function hasVisibleMarker(analysis, store, name, callIndex) {
|
|
42191
|
+
let scope = visibleScopeAt(analysis, name, callIndex);
|
|
42192
|
+
while (scope >= 0) {
|
|
42193
|
+
if (store.get(name)?.has(scope))
|
|
42194
|
+
return true;
|
|
42195
|
+
scope = analysis.scopeParents[scope] ?? -1;
|
|
42196
|
+
}
|
|
42197
|
+
return false;
|
|
42198
|
+
}
|
|
42199
|
+
function factsAtVisibleScope(analysis, name, callIndex) {
|
|
42200
|
+
const scope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42201
|
+
return scope === null ? undefined : analysis.factScopes.get(name)?.get(scope);
|
|
42202
|
+
}
|
|
42203
|
+
function tokenPairs(tokens) {
|
|
42204
|
+
const cached = tokenPairsByList.get(tokens);
|
|
42205
|
+
if (cached)
|
|
42206
|
+
return cached;
|
|
42207
|
+
const pairs = new Map;
|
|
42208
|
+
const stack = [];
|
|
42209
|
+
const matching = { ")": "(", "]": "[", "}": "{" };
|
|
42210
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42211
|
+
const value = tokens[index]?.value;
|
|
42212
|
+
if (value === "(" || value === "[" || value === "{") {
|
|
42213
|
+
stack.push({ value, index });
|
|
42214
|
+
continue;
|
|
42215
|
+
}
|
|
42216
|
+
const open2 = matching[value ?? ""];
|
|
42217
|
+
if (!open2)
|
|
42218
|
+
continue;
|
|
42219
|
+
const top = stack.at(-1);
|
|
42220
|
+
if (!top || top.value !== open2)
|
|
42221
|
+
continue;
|
|
42222
|
+
stack.pop();
|
|
42223
|
+
pairs.set(top.index, index);
|
|
42224
|
+
pairs.set(index, top.index);
|
|
42225
|
+
}
|
|
42226
|
+
tokenPairsByList.set(tokens, pairs);
|
|
42227
|
+
return pairs;
|
|
42228
|
+
}
|
|
42229
|
+
function pairedToken(tokens, index) {
|
|
42230
|
+
return tokenPairs(tokens).get(index) ?? -1;
|
|
42231
|
+
}
|
|
42232
|
+
function buildScopes(tokens) {
|
|
42233
|
+
const scopeAtToken = [];
|
|
42234
|
+
const scopeParents = [-1];
|
|
42235
|
+
const scopeIsFunction = [true];
|
|
42236
|
+
const stack = [0];
|
|
42237
|
+
const braceCreatesScope = [];
|
|
42238
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42239
|
+
scopeAtToken[index] = stack.at(-1);
|
|
42240
|
+
if (tokens[index]?.value === "{") {
|
|
42241
|
+
const previous = tokens[index - 1];
|
|
42242
|
+
let cursor = index - 1;
|
|
42243
|
+
let importClause = false;
|
|
42244
|
+
while (cursor >= 0 && ![";", "{", "}"].includes(tokens[cursor].value)) {
|
|
42245
|
+
if (tokens[cursor]?.value === "import")
|
|
42246
|
+
importClause = true;
|
|
42247
|
+
cursor--;
|
|
42248
|
+
}
|
|
42249
|
+
const createsScope = !importClause && !DECLARATION_KEYWORDS.has(previous?.value ?? "") && !["=", "(", "[", ",", ":", "return"].includes(previous?.value ?? "");
|
|
42250
|
+
braceCreatesScope.push(createsScope);
|
|
42251
|
+
if (createsScope) {
|
|
42252
|
+
const child = scopeParents.length;
|
|
42253
|
+
scopeParents.push(stack.at(-1));
|
|
42254
|
+
const previousValue = previous?.value;
|
|
42255
|
+
let functionBody = previousValue === "=>";
|
|
42256
|
+
if (previousValue === ")") {
|
|
42257
|
+
const open2 = pairedToken(tokens, index - 1);
|
|
42258
|
+
for (let cursor2 = open2 - 1;cursor2 >= 0; cursor2--) {
|
|
42259
|
+
const value = tokens[cursor2]?.value;
|
|
42260
|
+
if (value === "function") {
|
|
42261
|
+
functionBody = true;
|
|
42262
|
+
break;
|
|
42263
|
+
}
|
|
42264
|
+
if (value === ";" || value === "{" || value === "}")
|
|
42265
|
+
break;
|
|
42266
|
+
}
|
|
42267
|
+
}
|
|
42268
|
+
scopeIsFunction.push(functionBody);
|
|
42269
|
+
stack.push(child);
|
|
42270
|
+
}
|
|
42271
|
+
} else if (tokens[index]?.value === "}") {
|
|
42272
|
+
if (braceCreatesScope.pop() && stack.length > 1)
|
|
42273
|
+
stack.pop();
|
|
42274
|
+
}
|
|
42275
|
+
}
|
|
42276
|
+
return { scopeAtToken, scopeParents, scopeIsFunction };
|
|
42277
|
+
}
|
|
42278
|
+
function declarationScope(analysis, tokenIndex) {
|
|
42279
|
+
if (analysis.varDeclarationIndexes.has(tokenIndex)) {
|
|
42280
|
+
let scope = analysis.scopeAtToken[tokenIndex] ?? 0;
|
|
42281
|
+
while (scope > 0 && !analysis.scopeIsFunction[scope]) {
|
|
42282
|
+
scope = analysis.scopeParents[scope] ?? 0;
|
|
42283
|
+
}
|
|
42284
|
+
return scope;
|
|
42285
|
+
}
|
|
42286
|
+
const parameterScope = analysis.parameterScopes.get(tokenIndex);
|
|
42287
|
+
if (parameterScope !== undefined)
|
|
42288
|
+
return parameterScope;
|
|
42289
|
+
return analysis.scopeAtToken[tokenIndex] ?? 0;
|
|
42290
|
+
}
|
|
42291
|
+
function visibleDeclarationScope(analysis, name, callIndex) {
|
|
42292
|
+
const scopes = analysis.declarationScopes.get(name);
|
|
42293
|
+
if (!scopes)
|
|
42294
|
+
return null;
|
|
42295
|
+
let scope = analysis.scopeAtToken[callIndex] ?? 0;
|
|
42296
|
+
while (scope >= 0) {
|
|
42297
|
+
if (scopes.has(scope))
|
|
42298
|
+
return scope;
|
|
42299
|
+
scope = analysis.scopeParents[scope] ?? -1;
|
|
42300
|
+
}
|
|
42301
|
+
return null;
|
|
42302
|
+
}
|
|
42303
|
+
function matchingToken(tokens, start, open2, close) {
|
|
42304
|
+
if (tokens[start]?.value !== open2)
|
|
42305
|
+
return -1;
|
|
42306
|
+
const match = pairedToken(tokens, start);
|
|
42307
|
+
return tokens[match]?.value === close ? match : -1;
|
|
42308
|
+
}
|
|
42309
|
+
function moduleAtCall(tokens, start, callee) {
|
|
42310
|
+
if (tokens[start]?.value !== callee || tokens[start + 1]?.value !== "(" || tokens[start + 2]?.kind !== "string" || tokens[start + 3]?.value !== ")") {
|
|
42311
|
+
return null;
|
|
42312
|
+
}
|
|
42313
|
+
return tokens[start + 2].value;
|
|
42314
|
+
}
|
|
42315
|
+
function declarationNames(tokens, start, end) {
|
|
42316
|
+
const names = [];
|
|
42317
|
+
if (tokens[start]?.value === "{") {
|
|
42318
|
+
for (let index = start + 1;index < end; index++) {
|
|
42319
|
+
const token = tokens[index];
|
|
42320
|
+
if (token?.kind !== "identifier")
|
|
42321
|
+
continue;
|
|
42322
|
+
if (tokens[index + 1]?.value === ":") {
|
|
42323
|
+
const local = tokens[index + 2];
|
|
42324
|
+
if (local?.kind === "identifier")
|
|
42325
|
+
names.push({ name: local.value, index: index + 2 });
|
|
42326
|
+
index += 2;
|
|
42327
|
+
} else if (tokens[index - 1]?.value !== ":") {
|
|
42328
|
+
names.push({ name: token.value, index });
|
|
42329
|
+
}
|
|
42330
|
+
}
|
|
42331
|
+
} else if (tokens[start]?.kind === "identifier") {
|
|
42332
|
+
names.push({ name: tokens[start].value, index: start });
|
|
42333
|
+
}
|
|
42334
|
+
return names;
|
|
42335
|
+
}
|
|
42336
|
+
function nextFunctionOpen(tokens, start) {
|
|
42337
|
+
for (let index = start + 1;index < tokens.length; index++) {
|
|
42338
|
+
const value = tokens[index]?.value;
|
|
42339
|
+
if (value === "(")
|
|
42340
|
+
return index;
|
|
42341
|
+
if (value === "{" || value === ";" || value === "=>")
|
|
42342
|
+
return -1;
|
|
42343
|
+
}
|
|
42344
|
+
return -1;
|
|
42345
|
+
}
|
|
42346
|
+
function nextFunctionBody(tokens, start) {
|
|
42347
|
+
for (let index = start;index < tokens.length; index++) {
|
|
42348
|
+
const value = tokens[index]?.value;
|
|
42349
|
+
if (value === "{")
|
|
42350
|
+
return index;
|
|
42351
|
+
if (value === ";" || value === "=>")
|
|
42352
|
+
return -1;
|
|
42353
|
+
}
|
|
42354
|
+
return -1;
|
|
42355
|
+
}
|
|
42356
|
+
function collectDeclarations(analysis) {
|
|
42357
|
+
const { tokens } = analysis;
|
|
42358
|
+
const declarationTokenIndexes = new Set;
|
|
42359
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42360
|
+
const token = tokens[index];
|
|
42361
|
+
if (!token)
|
|
42362
|
+
continue;
|
|
42363
|
+
if (token.value === "import") {
|
|
42364
|
+
if (tokens[index + 1]?.value === "type")
|
|
42365
|
+
continue;
|
|
42366
|
+
if (tokens[index + 1]?.value === "{") {
|
|
42367
|
+
const close = matchingToken(tokens, index + 1, "{", "}");
|
|
42368
|
+
for (let cursor = index + 2;cursor > 0 && cursor < close; cursor++) {
|
|
42369
|
+
const imported = tokens[cursor];
|
|
42370
|
+
if (imported?.kind !== "identifier")
|
|
42371
|
+
continue;
|
|
42372
|
+
if (imported.value === "type") {
|
|
42373
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42374
|
+
cursor++;
|
|
42375
|
+
continue;
|
|
42376
|
+
}
|
|
42377
|
+
const local = tokens[cursor + 1]?.value === "as" ? tokens[cursor + 2] : imported;
|
|
42378
|
+
if (local?.kind === "identifier") {
|
|
42379
|
+
addDeclaration(analysis, local.value);
|
|
42380
|
+
declarationTokenIndexes.add(tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
|
|
42381
|
+
}
|
|
42382
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42383
|
+
cursor++;
|
|
42384
|
+
}
|
|
42385
|
+
} else if (tokens[index + 1]?.value === "*" && tokens[index + 2]?.value === "as") {
|
|
42386
|
+
const local = tokens[index + 3];
|
|
42387
|
+
if (local?.kind === "identifier") {
|
|
42388
|
+
addDeclaration(analysis, local.value);
|
|
42389
|
+
declarationTokenIndexes.add(index + 3);
|
|
42390
|
+
}
|
|
42391
|
+
} else if (tokens[index + 1]?.kind === "identifier") {
|
|
42392
|
+
addDeclaration(analysis, tokens[index + 1].value);
|
|
42393
|
+
declarationTokenIndexes.add(index + 1);
|
|
42394
|
+
}
|
|
42395
|
+
}
|
|
42396
|
+
if (DECLARATION_KEYWORDS.has(token.value)) {
|
|
42397
|
+
const start = index + 1;
|
|
42398
|
+
const close = tokens[start]?.value === "{" ? matchingToken(tokens, start, "{", "}") : start + 1;
|
|
42399
|
+
for (const item of declarationNames(tokens, start, close)) {
|
|
42400
|
+
addDeclaration(analysis, item.name);
|
|
42401
|
+
declarationTokenIndexes.add(item.index);
|
|
42402
|
+
if (token.value === "var")
|
|
42403
|
+
analysis.varDeclarationIndexes.add(item.index);
|
|
42404
|
+
}
|
|
42405
|
+
}
|
|
42406
|
+
if ((token.value === "function" || token.value === "class") && tokens[index + 1]?.kind === "identifier") {
|
|
42407
|
+
addDeclaration(analysis, tokens[index + 1].value);
|
|
42408
|
+
declarationTokenIndexes.add(index + 1);
|
|
42409
|
+
}
|
|
42410
|
+
if (token.value === "function") {
|
|
42411
|
+
const open2 = nextFunctionOpen(tokens, index);
|
|
42412
|
+
if (open2 > index) {
|
|
42413
|
+
const close = matchingToken(tokens, open2, "(", ")");
|
|
42414
|
+
const body = close >= 0 ? nextFunctionBody(tokens, close + 1) : -1;
|
|
42415
|
+
const bodyScope = body >= 0 ? analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body] : undefined;
|
|
42416
|
+
for (let cursor = open2 + 1;cursor < close; cursor++) {
|
|
42417
|
+
if (tokens[cursor]?.kind === "identifier" && tokens[cursor - 1]?.value !== ".") {
|
|
42418
|
+
addDeclaration(analysis, tokens[cursor].value);
|
|
42419
|
+
declarationTokenIndexes.add(cursor);
|
|
42420
|
+
if (bodyScope !== undefined)
|
|
42421
|
+
analysis.parameterScopes.set(cursor, bodyScope);
|
|
42422
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42423
|
+
cursor++;
|
|
42424
|
+
}
|
|
42425
|
+
}
|
|
42426
|
+
}
|
|
42427
|
+
}
|
|
42428
|
+
if (token.value === "catch" && tokens[index + 1]?.value === "(" && tokens[index + 2]?.kind === "identifier") {
|
|
42429
|
+
addDeclaration(analysis, tokens[index + 2].value);
|
|
42430
|
+
declarationTokenIndexes.add(index + 2);
|
|
42431
|
+
}
|
|
42432
|
+
if (token.kind === "identifier" && tokens[index + 1]?.value === "=>") {
|
|
42433
|
+
addDeclaration(analysis, token.value);
|
|
42434
|
+
declarationTokenIndexes.add(index);
|
|
42435
|
+
const body = nextFunctionBody(tokens, index + 2);
|
|
42436
|
+
if (body >= 0)
|
|
42437
|
+
analysis.parameterScopes.set(index, analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body]);
|
|
42438
|
+
}
|
|
42439
|
+
if (token.value === "=>") {
|
|
42440
|
+
let close = index - 1;
|
|
42441
|
+
while (close >= 0 && tokens[close]?.value !== ")")
|
|
42442
|
+
close--;
|
|
42443
|
+
let cursor = close - 1;
|
|
42444
|
+
let depth = 1;
|
|
42445
|
+
while (cursor >= 0 && depth > 0) {
|
|
42446
|
+
if (tokens[cursor]?.value === ")")
|
|
42447
|
+
depth++;
|
|
42448
|
+
else if (tokens[cursor]?.value === "(")
|
|
42449
|
+
depth--;
|
|
42450
|
+
cursor--;
|
|
42451
|
+
}
|
|
42452
|
+
const body = nextFunctionBody(tokens, index + 1);
|
|
42453
|
+
const bodyScope = body >= 0 ? analysis.scopeAtToken[body + 1] ?? analysis.scopeAtToken[body] : undefined;
|
|
42454
|
+
for (cursor += 2;cursor < close; cursor++) {
|
|
42455
|
+
if (tokens[cursor]?.kind === "identifier") {
|
|
42456
|
+
addDeclaration(analysis, tokens[cursor].value);
|
|
42457
|
+
declarationTokenIndexes.add(cursor);
|
|
42458
|
+
if (bodyScope !== undefined)
|
|
42459
|
+
analysis.parameterScopes.set(cursor, bodyScope);
|
|
42460
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42461
|
+
cursor++;
|
|
42462
|
+
}
|
|
42463
|
+
}
|
|
42464
|
+
}
|
|
42465
|
+
}
|
|
42466
|
+
return declarationTokenIndexes;
|
|
42467
|
+
}
|
|
42468
|
+
function collectFacts(analysis) {
|
|
42469
|
+
const { tokens } = analysis;
|
|
42470
|
+
for (let index = 0;index < tokens.length; index++) {
|
|
42471
|
+
if (tokens[index]?.value === "import" && tokens[index + 1]?.value !== "type") {
|
|
42472
|
+
if (tokens[index + 1]?.value === "{") {
|
|
42473
|
+
const close = matchingToken(tokens, index + 1, "{", "}");
|
|
42474
|
+
const module2 = tokens[close + 1]?.value === "from" ? tokens[close + 2]?.value : null;
|
|
42475
|
+
for (let cursor = index + 2;cursor > 0 && cursor < close; cursor++) {
|
|
42476
|
+
const imported = tokens[cursor];
|
|
42477
|
+
if (imported?.kind !== "identifier")
|
|
42478
|
+
continue;
|
|
42479
|
+
if (imported.value === "type") {
|
|
42480
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42481
|
+
cursor++;
|
|
42482
|
+
continue;
|
|
42483
|
+
}
|
|
42484
|
+
const local2 = tokens[cursor + 1]?.value === "as" ? tokens[cursor + 2] : imported;
|
|
42485
|
+
if (local2?.kind === "identifier") {
|
|
42486
|
+
if (CHILD_PROCESS_MODULES.has(module2 ?? "") && imported.value === "exec") {
|
|
42487
|
+
addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
|
|
42488
|
+
} else if (module2)
|
|
42489
|
+
addFact(analysis, local2.value, "other-import", tokens[cursor + 1]?.value === "as" ? cursor + 2 : cursor);
|
|
42490
|
+
}
|
|
42491
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42492
|
+
cursor++;
|
|
42493
|
+
}
|
|
42494
|
+
} else if (tokens[index + 1]?.value === "*" && tokens[index + 2]?.value === "as") {
|
|
42495
|
+
const local2 = tokens[index + 3];
|
|
42496
|
+
const module2 = tokens[index + 4]?.value === "from" ? tokens[index + 5]?.value : null;
|
|
42497
|
+
if (local2?.kind === "identifier" && module2) {
|
|
42498
|
+
addFact(analysis, local2.value, CHILD_PROCESS_MODULES.has(module2) ? "child-namespace" : "other-import", index + 3);
|
|
42499
|
+
analysis.requireDerived.add(local2.value);
|
|
42500
|
+
addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, index + 3));
|
|
42501
|
+
}
|
|
42502
|
+
} else if (tokens[index + 1]?.kind === "identifier" && tokens[index + 2]?.value === "=" && tokens[index + 3]?.value === "require") {
|
|
42503
|
+
const module2 = moduleAtCall(tokens, index + 3, "require");
|
|
42504
|
+
if (module2)
|
|
42505
|
+
addFact(analysis, tokens[index + 1].value, CHILD_PROCESS_MODULES.has(module2) ? "child-namespace" : "other-import", index + 1);
|
|
42506
|
+
} else if (tokens[index + 1]?.kind === "identifier" && tokens[index + 2]?.value === "from" && tokens[index + 3]?.kind === "string") {
|
|
42507
|
+
const local2 = tokens[index + 1];
|
|
42508
|
+
addFact(analysis, local2.value, CHILD_PROCESS_MODULES.has(tokens[index + 3].value) ? "child-namespace" : "other-import", index + 1);
|
|
42509
|
+
}
|
|
42510
|
+
}
|
|
42511
|
+
if (!DECLARATION_KEYWORDS.has(tokens[index]?.value ?? ""))
|
|
42512
|
+
continue;
|
|
42513
|
+
const start = index + 1;
|
|
42514
|
+
if (tokens[start]?.value === "{") {
|
|
42515
|
+
const close = matchingToken(tokens, start, "{", "}");
|
|
42516
|
+
const rhs2 = close + 1;
|
|
42517
|
+
const module2 = tokens[rhs2]?.value === "=" ? moduleAtCall(tokens, rhs2 + 1, "require") : null;
|
|
42518
|
+
const namespace = tokens[rhs2]?.value === "=" && tokens[rhs2 + 1]?.kind === "identifier" ? tokens[rhs2 + 1].value : null;
|
|
42519
|
+
for (let cursor = start + 1;cursor < close; cursor++) {
|
|
42520
|
+
const imported = tokens[cursor];
|
|
42521
|
+
if (imported?.kind !== "identifier")
|
|
42522
|
+
continue;
|
|
42523
|
+
const local2 = tokens[cursor + 1]?.value === ":" ? tokens[cursor + 2] : imported;
|
|
42524
|
+
if (local2?.kind === "identifier" && imported.value === "exec") {
|
|
42525
|
+
if (module2 && CHILD_PROCESS_MODULES.has(module2)) {
|
|
42526
|
+
addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor);
|
|
42527
|
+
analysis.requireDerived.add(local2.value);
|
|
42528
|
+
addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor));
|
|
42529
|
+
} else if (namespace && hasUniqueFact(analysis, namespace, rhs2 + 1, "child-namespace")) {
|
|
42530
|
+
addFact(analysis, local2.value, "child-direct", tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor);
|
|
42531
|
+
if (hasScopedMarker(analysis.requireDerivedScopes, namespace, visibleDeclarationScope(analysis, namespace, rhs2 + 1))) {
|
|
42532
|
+
analysis.requireDerived.add(local2.value);
|
|
42533
|
+
addScopedMarker(analysis.requireDerivedScopes, local2.value, declarationScope(analysis, tokens[cursor + 1]?.value === ":" ? cursor + 2 : cursor));
|
|
42534
|
+
}
|
|
42535
|
+
}
|
|
42536
|
+
}
|
|
42537
|
+
while (cursor < close && tokens[cursor]?.value !== ",")
|
|
42538
|
+
cursor++;
|
|
42539
|
+
}
|
|
42540
|
+
continue;
|
|
42541
|
+
}
|
|
42542
|
+
const local = tokens[start];
|
|
42543
|
+
if (local?.kind !== "identifier" || tokens[start + 1]?.value !== "=")
|
|
42544
|
+
continue;
|
|
42545
|
+
const rhs = start + 2;
|
|
42546
|
+
const module = moduleAtCall(tokens, rhs, "require");
|
|
42547
|
+
if (module) {
|
|
42548
|
+
addFact(analysis, local.value, CHILD_PROCESS_MODULES.has(module) ? "child-namespace" : "other-import", start);
|
|
42549
|
+
analysis.requireDerived.add(local.value);
|
|
42550
|
+
addScopedMarker(analysis.requireDerivedScopes, local.value, declarationScope(analysis, start));
|
|
42551
|
+
} else if (tokens[rhs]?.value === "import" || tokens[rhs]?.value === "await" && tokens[rhs + 1]?.value === "import") {
|
|
42552
|
+
const importIndex = tokens[rhs]?.value === "await" ? rhs + 1 : rhs;
|
|
42553
|
+
const importedModule = moduleAtCall(tokens, importIndex, "import");
|
|
42554
|
+
if (importedModule) {
|
|
42555
|
+
addFact(analysis, local.value, CHILD_PROCESS_MODULES.has(importedModule) ? "child-namespace" : "other-import", start);
|
|
42556
|
+
}
|
|
42557
|
+
} else if (tokens[rhs]?.kind === "regex" || tokens[rhs]?.value === "new" && tokens[rhs + 1]?.value === "RegExp") {
|
|
42558
|
+
addFact(analysis, local.value, "regex", start);
|
|
42559
|
+
} else if (tokens[rhs]?.kind === "identifier" && (tokens[rhs + 1]?.value === "." || tokens[rhs + 1]?.value === "?.") && tokens[rhs + 2]?.value === "exec" && hasUniqueFact(analysis, tokens[rhs].value, rhs, "child-namespace")) {
|
|
42560
|
+
addFact(analysis, local.value, "child-direct", start);
|
|
42561
|
+
if (hasScopedMarker(analysis.requireDerivedScopes, tokens[rhs].value, visibleDeclarationScope(analysis, tokens[rhs].value, rhs))) {
|
|
42562
|
+
analysis.requireDerived.add(local.value);
|
|
42563
|
+
addScopedMarker(analysis.requireDerivedScopes, local.value, declarationScope(analysis, start));
|
|
42564
|
+
}
|
|
42565
|
+
}
|
|
42566
|
+
}
|
|
42567
|
+
}
|
|
42568
|
+
function hasUniqueFact(analysis, name, callIndex, fact) {
|
|
42569
|
+
const scope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42570
|
+
const facts = scope === null ? undefined : analysis.factScopes.get(name)?.get(scope);
|
|
42571
|
+
return scope !== null && analysis.declarationScopes.get(name)?.get(scope) === 1 && !hasScopedMarker(analysis.reassignedScopes, name, scope) && facts?.size === 1 && facts.has(fact);
|
|
42572
|
+
}
|
|
42573
|
+
function buildAnalysis(context) {
|
|
42574
|
+
const lineStarts = [0];
|
|
42575
|
+
for (let index = 0;index < context.content.length; index++) {
|
|
42576
|
+
if (context.content[index] === `
|
|
42577
|
+
`)
|
|
42578
|
+
lineStarts.push(index + 1);
|
|
42579
|
+
}
|
|
42580
|
+
if (context.content.length > MAX_ANALYSIS_BYTES) {
|
|
42581
|
+
return {
|
|
42582
|
+
tokens: [],
|
|
42583
|
+
lineStarts,
|
|
42584
|
+
scopeAtToken: [],
|
|
42585
|
+
scopeParents: [-1],
|
|
42586
|
+
scopeIsFunction: [true],
|
|
42587
|
+
declarations: new Map,
|
|
42588
|
+
declarationScopes: new Map,
|
|
42589
|
+
facts: new Map,
|
|
42590
|
+
factScopes: new Map,
|
|
42591
|
+
reassigned: new Set,
|
|
42592
|
+
reassignedScopes: new Map,
|
|
42593
|
+
mutatedMembers: new Set,
|
|
42594
|
+
mutatedMemberScopes: new Map,
|
|
42595
|
+
requireDerived: new Set,
|
|
42596
|
+
requireDerivedScopes: new Map,
|
|
42597
|
+
parameterScopes: new Map,
|
|
42598
|
+
varDeclarationIndexes: new Set,
|
|
42599
|
+
oversizedOrMalformed: true
|
|
42600
|
+
};
|
|
42601
|
+
}
|
|
42602
|
+
const tokenized = tokenize2(context.content);
|
|
42603
|
+
const scopes = buildScopes(tokenized.tokens);
|
|
42604
|
+
const analysis = {
|
|
42605
|
+
tokens: tokenized.tokens,
|
|
42606
|
+
lineStarts,
|
|
42607
|
+
scopeAtToken: scopes.scopeAtToken,
|
|
42608
|
+
scopeParents: scopes.scopeParents,
|
|
42609
|
+
scopeIsFunction: scopes.scopeIsFunction,
|
|
42610
|
+
declarations: new Map,
|
|
42611
|
+
declarationScopes: new Map,
|
|
42612
|
+
facts: new Map,
|
|
42613
|
+
factScopes: new Map,
|
|
42614
|
+
reassigned: new Set,
|
|
42615
|
+
reassignedScopes: new Map,
|
|
42616
|
+
mutatedMembers: new Set,
|
|
42617
|
+
mutatedMemberScopes: new Map,
|
|
42618
|
+
requireDerived: new Set,
|
|
42619
|
+
requireDerivedScopes: new Map,
|
|
42620
|
+
parameterScopes: new Map,
|
|
42621
|
+
varDeclarationIndexes: new Set,
|
|
42622
|
+
oversizedOrMalformed: tokenized.malformed
|
|
42623
|
+
};
|
|
42624
|
+
const declarationIndexes = collectDeclarations(analysis);
|
|
42625
|
+
for (const index of declarationIndexes) {
|
|
42626
|
+
const name = analysis.tokens[index]?.value;
|
|
42627
|
+
if (!name)
|
|
42628
|
+
continue;
|
|
42629
|
+
const scope = declarationScope(analysis, index);
|
|
42630
|
+
const counts = analysis.declarationScopes.get(name) ?? new Map;
|
|
42631
|
+
counts.set(scope, (counts.get(scope) ?? 0) + 1);
|
|
42632
|
+
analysis.declarationScopes.set(name, counts);
|
|
42633
|
+
}
|
|
42634
|
+
collectFacts(analysis);
|
|
42635
|
+
for (let index = 0;index < analysis.tokens.length; index++) {
|
|
42636
|
+
const token = analysis.tokens[index];
|
|
42637
|
+
if (token?.kind !== "identifier" || declarationIndexes.has(index))
|
|
42638
|
+
continue;
|
|
42639
|
+
const previous = analysis.tokens[index - 1]?.value;
|
|
42640
|
+
if (previous === "." || previous === "?.") {
|
|
42641
|
+
if (token.value === "exec" && (ASSIGNMENTS.has(analysis.tokens[index + 1]?.value ?? "") || analysis.tokens[index - 3]?.value === "delete")) {
|
|
42642
|
+
const receiver = analysis.tokens[index - 2];
|
|
42643
|
+
if (receiver?.kind === "identifier") {
|
|
42644
|
+
analysis.mutatedMembers.add(receiver.value);
|
|
42645
|
+
addScopedMarker(analysis.mutatedMemberScopes, receiver.value, visibleDeclarationScope(analysis, receiver.value, index - 2) ?? analysis.scopeAtToken[index - 2] ?? 0);
|
|
42646
|
+
}
|
|
42647
|
+
}
|
|
42648
|
+
continue;
|
|
42649
|
+
}
|
|
42650
|
+
if (ASSIGNMENTS.has(analysis.tokens[index + 1]?.value ?? "") || previous === "++" || previous === "--" || analysis.tokens[index + 1]?.value === "++" || analysis.tokens[index + 1]?.value === "--") {
|
|
42651
|
+
analysis.reassigned.add(token.value);
|
|
42652
|
+
addScopedMarker(analysis.reassignedScopes, token.value, visibleDeclarationScope(analysis, token.value, index) ?? analysis.scopeAtToken[index] ?? 0);
|
|
42653
|
+
}
|
|
42654
|
+
}
|
|
42655
|
+
return analysis;
|
|
42656
|
+
}
|
|
42657
|
+
function getAnalysis(context) {
|
|
42658
|
+
let analysis = analysisByContext.get(context);
|
|
42659
|
+
if (!analysis) {
|
|
42660
|
+
analysis = buildAnalysis(context);
|
|
42661
|
+
analysisByContext.set(context, analysis);
|
|
42662
|
+
}
|
|
42663
|
+
return analysis;
|
|
42664
|
+
}
|
|
42665
|
+
function tokenIndexAtOffset(tokens, offset) {
|
|
42666
|
+
let low = 0;
|
|
42667
|
+
let high = tokens.length - 1;
|
|
42668
|
+
while (low <= high) {
|
|
42669
|
+
const mid = low + high >>> 1;
|
|
42670
|
+
const token = tokens[mid];
|
|
42671
|
+
if (offset < token.start)
|
|
42672
|
+
high = mid - 1;
|
|
42673
|
+
else if (offset >= token.end)
|
|
42674
|
+
low = mid + 1;
|
|
42675
|
+
else
|
|
42676
|
+
return mid;
|
|
42677
|
+
}
|
|
42678
|
+
return -1;
|
|
42679
|
+
}
|
|
42680
|
+
function directRequireBefore(tokens, dotIndex) {
|
|
42681
|
+
if (tokens[dotIndex - 1]?.value !== ")")
|
|
42682
|
+
return false;
|
|
42683
|
+
for (let start = dotIndex - 2;start >= 0 && start >= dotIndex - 5; start--) {
|
|
42684
|
+
const module = moduleAtCall(tokens, start, "require");
|
|
42685
|
+
if (module && start + 4 === dotIndex)
|
|
42686
|
+
return CHILD_PROCESS_MODULES.has(module);
|
|
42687
|
+
}
|
|
42688
|
+
return false;
|
|
42689
|
+
}
|
|
42690
|
+
function isTransparentWrapperCall(tokens, openIndex) {
|
|
42691
|
+
return tokens[openIndex - 1]?.kind === "identifier" ? tokens[openIndex - 1].value === "promisify" : false;
|
|
42692
|
+
}
|
|
42693
|
+
function shouldSkipTrailingClose(tokens, nameIndex, closeIndex) {
|
|
42694
|
+
const openIndex = pairedToken(tokens, closeIndex);
|
|
42695
|
+
if (openIndex < 0 || openIndex > nameIndex)
|
|
42696
|
+
return false;
|
|
42697
|
+
const beforeOpen = tokens[openIndex - 1];
|
|
42698
|
+
if (!beforeOpen || beforeOpen.kind !== "identifier" && beforeOpen.kind !== "string" && beforeOpen.kind !== "regex" && beforeOpen.value !== ")" && beforeOpen.value !== "]") {
|
|
42699
|
+
return true;
|
|
42700
|
+
}
|
|
42701
|
+
return isTransparentWrapperCall(tokens, openIndex);
|
|
42702
|
+
}
|
|
42703
|
+
function parseCallee(tokens, nameIndex) {
|
|
42704
|
+
const nameToken = tokens[nameIndex];
|
|
42705
|
+
if (!nameToken)
|
|
42706
|
+
return null;
|
|
42707
|
+
let cursor = nameIndex + 1;
|
|
42708
|
+
if (nameToken.kind === "string") {
|
|
42709
|
+
if (tokens[nameIndex - 1]?.value !== "[" || tokens[nameIndex + 1]?.value !== "]")
|
|
42710
|
+
return null;
|
|
42711
|
+
cursor = nameIndex + 2;
|
|
42712
|
+
}
|
|
42713
|
+
while (tokens[cursor]?.value === ")" && shouldSkipTrailingClose(tokens, nameIndex, cursor)) {
|
|
42714
|
+
cursor++;
|
|
42715
|
+
}
|
|
42716
|
+
if (tokens[cursor]?.value === "?.")
|
|
42717
|
+
cursor++;
|
|
42718
|
+
if (tokens[cursor]?.value !== "(")
|
|
42719
|
+
return null;
|
|
42720
|
+
const callee = { name: nameToken.value, openParen: cursor };
|
|
42721
|
+
const accessIndex = nameToken.kind === "string" ? nameIndex - 1 : nameIndex - 1;
|
|
42722
|
+
if (nameToken.kind === "string") {
|
|
42723
|
+
const receiver = tokens[nameIndex - 2];
|
|
42724
|
+
if (receiver?.kind === "identifier") {
|
|
42725
|
+
callee.receiver = receiver.value;
|
|
42726
|
+
callee.receiverKind = "identifier";
|
|
42727
|
+
} else if (receiver?.kind === "regex")
|
|
42728
|
+
callee.receiverKind = "regex";
|
|
42729
|
+
return callee;
|
|
42730
|
+
}
|
|
42731
|
+
if (tokens[accessIndex]?.value === "." || tokens[accessIndex]?.value === "?.") {
|
|
42732
|
+
const receiver = tokens[accessIndex - 1];
|
|
42733
|
+
if (receiver?.kind === "identifier") {
|
|
42734
|
+
callee.receiver = receiver.value;
|
|
42735
|
+
callee.receiverKind = "identifier";
|
|
42736
|
+
} else if (receiver?.kind === "regex")
|
|
42737
|
+
callee.receiverKind = "regex";
|
|
42738
|
+
else if (directRequireBefore(tokens, accessIndex))
|
|
42739
|
+
callee.receiverKind = "direct-child-require";
|
|
42740
|
+
}
|
|
42741
|
+
return callee;
|
|
42742
|
+
}
|
|
42743
|
+
function bindingDisposition(analysis, name, confirmedFact, callIndex) {
|
|
42744
|
+
const visibleScope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42745
|
+
if (visibleScope === null)
|
|
42746
|
+
return "ambiguous";
|
|
42747
|
+
const declarationCount = analysis.declarationScopes.get(name)?.get(visibleScope) ?? 0;
|
|
42748
|
+
const facts = analysis.factScopes.get(name)?.get(visibleScope);
|
|
42749
|
+
if (hasScopedMarker(analysis.requireDerivedScopes, name, visibleScope) && globalDisposition(analysis, "require", callIndex) !== "confirmed") {
|
|
42750
|
+
return "ambiguous";
|
|
42751
|
+
}
|
|
42752
|
+
if (declarationCount !== 1 || hasScopedMarker(analysis.reassignedScopes, name, visibleScope) || !facts || facts.size !== 1) {
|
|
42753
|
+
return "ambiguous";
|
|
42754
|
+
}
|
|
42755
|
+
if (facts.has(confirmedFact))
|
|
42756
|
+
return "confirmed";
|
|
42757
|
+
if (facts.has("other-import") || facts.has("regex"))
|
|
42758
|
+
return "safe";
|
|
42759
|
+
return "ambiguous";
|
|
42760
|
+
}
|
|
42761
|
+
function globalDisposition(analysis, name, callIndex) {
|
|
42762
|
+
const visibleScope = visibleDeclarationScope(analysis, name, callIndex);
|
|
42763
|
+
if (visibleScope === null && !hasVisibleMarker(analysis, analysis.reassignedScopes, name, callIndex)) {
|
|
42764
|
+
return "confirmed";
|
|
42765
|
+
}
|
|
42766
|
+
const facts = visibleScope === null ? undefined : analysis.factScopes.get(name)?.get(visibleScope);
|
|
42767
|
+
if (facts?.size === 1 && facts.has("other-import") && visibleScope !== null && analysis.declarationScopes.get(name)?.get(visibleScope) === 1 && !hasScopedMarker(analysis.reassignedScopes, name, visibleScope)) {
|
|
42768
|
+
return "safe";
|
|
42769
|
+
}
|
|
42770
|
+
return "ambiguous";
|
|
42771
|
+
}
|
|
42772
|
+
function firstArgument(tokens, openParen) {
|
|
42773
|
+
return tokens[openParen + 1];
|
|
42774
|
+
}
|
|
42775
|
+
function oversizedCandidate(match, family) {
|
|
42776
|
+
const expected = family === "exec" ? ["exec"] : family === "eval" ? ["eval"] : family === "function-constructor" ? ["Function"] : family === "timer-string" ? ["setTimeout", "setInterval"] : family === "document-write" ? ["write"] : ["addEventListener"];
|
|
42777
|
+
return expected.includes(match.text) ? "ambiguous" : "none";
|
|
42778
|
+
}
|
|
42779
|
+
function classifyJavascriptCallUncached(match, context, family) {
|
|
42780
|
+
const analysis = getAnalysis(context);
|
|
42781
|
+
if (analysis.oversizedOrMalformed)
|
|
42782
|
+
return oversizedCandidate(match, family);
|
|
42783
|
+
const offset = (analysis.lineStarts[match.line - 1] ?? 0) + match.column - 1;
|
|
42784
|
+
const tokenIndex = tokenIndexAtOffset(analysis.tokens, offset);
|
|
42785
|
+
if (tokenIndex < 0)
|
|
42786
|
+
return "none";
|
|
42787
|
+
const callee = parseCallee(analysis.tokens, tokenIndex);
|
|
42788
|
+
if (!callee)
|
|
42789
|
+
return "none";
|
|
42790
|
+
const argument = firstArgument(analysis.tokens, callee.openParen);
|
|
42791
|
+
switch (family) {
|
|
42792
|
+
case "exec":
|
|
42793
|
+
if (!argument || argument.value === ")")
|
|
42794
|
+
return "none";
|
|
42795
|
+
if (callee.receiverKind === "regex")
|
|
42796
|
+
return "safe";
|
|
42797
|
+
if (callee.receiverKind === "direct-child-require") {
|
|
42798
|
+
if (callee.name !== "exec")
|
|
42799
|
+
return "none";
|
|
42800
|
+
return globalDisposition(analysis, "require", tokenIndex) === "confirmed" ? "confirmed" : "ambiguous";
|
|
42801
|
+
}
|
|
42802
|
+
if (callee.receiver) {
|
|
42803
|
+
if (callee.name !== "exec")
|
|
42804
|
+
return "none";
|
|
42805
|
+
if (hasScopedMarker(analysis.mutatedMemberScopes, callee.receiver, visibleDeclarationScope(analysis, callee.receiver, tokenIndex))) {
|
|
42806
|
+
return "ambiguous";
|
|
42807
|
+
}
|
|
42808
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex);
|
|
42809
|
+
}
|
|
42810
|
+
if (callee.name === "exec" || factsAtVisibleScope(analysis, callee.name, tokenIndex)?.has("child-direct")) {
|
|
42811
|
+
return bindingDisposition(analysis, callee.name, "child-direct", tokenIndex);
|
|
42812
|
+
}
|
|
42813
|
+
return "none";
|
|
42814
|
+
case "eval":
|
|
42815
|
+
if (callee.name !== "eval")
|
|
42816
|
+
return "none";
|
|
42817
|
+
if (callee.receiver) {
|
|
42818
|
+
if (["globalThis", "window", "self"].includes(callee.receiver)) {
|
|
42819
|
+
return globalDisposition(analysis, callee.receiver, tokenIndex);
|
|
42820
|
+
}
|
|
42821
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
|
|
42822
|
+
}
|
|
42823
|
+
return globalDisposition(analysis, "eval", tokenIndex);
|
|
42824
|
+
case "function-constructor":
|
|
42825
|
+
if (callee.name !== "Function" || analysis.tokens[tokenIndex - 1]?.value !== "new")
|
|
42826
|
+
return "none";
|
|
42827
|
+
return globalDisposition(analysis, "Function", tokenIndex);
|
|
42828
|
+
case "timer-string":
|
|
42829
|
+
if (!["setTimeout", "setInterval"].includes(callee.name) || !argument || !["string", "template"].includes(argument.kind))
|
|
42830
|
+
return "none";
|
|
42831
|
+
if (callee.receiver) {
|
|
42832
|
+
if (["globalThis", "window", "self"].includes(callee.receiver))
|
|
42833
|
+
return globalDisposition(analysis, callee.receiver, tokenIndex);
|
|
42834
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
|
|
42835
|
+
}
|
|
42836
|
+
return globalDisposition(analysis, callee.name, tokenIndex);
|
|
42837
|
+
case "document-write":
|
|
42838
|
+
if (callee.name !== "write" || callee.receiver !== "document")
|
|
42839
|
+
return "none";
|
|
42840
|
+
return globalDisposition(analysis, "document", tokenIndex) === "confirmed" ? "confirmed" : "ambiguous";
|
|
42841
|
+
case "postmessage":
|
|
42842
|
+
if (callee.name !== "addEventListener" || argument?.kind !== "string" || argument.value !== "message")
|
|
42843
|
+
return "none";
|
|
42844
|
+
if (callee.receiver) {
|
|
42845
|
+
if (["globalThis", "window", "self"].includes(callee.receiver))
|
|
42846
|
+
return globalDisposition(analysis, callee.receiver, tokenIndex);
|
|
42847
|
+
return bindingDisposition(analysis, callee.receiver, "child-namespace", tokenIndex) === "safe" ? "safe" : "ambiguous";
|
|
42848
|
+
}
|
|
42849
|
+
return globalDisposition(analysis, "addEventListener", tokenIndex);
|
|
42850
|
+
}
|
|
42851
|
+
}
|
|
42852
|
+
function classifyJavascriptCall(match, context, family) {
|
|
42853
|
+
const key = `${family}:${match.line}:${match.column}:${match.text}`;
|
|
42854
|
+
const cache2 = dispositionByContext.get(context) ?? new Map;
|
|
42855
|
+
const cached = cache2.get(key);
|
|
42856
|
+
if (cached !== undefined)
|
|
42857
|
+
return cached;
|
|
42858
|
+
const disposition = classifyJavascriptCallUncached(match, context, family);
|
|
42859
|
+
cache2.set(key, disposition);
|
|
42860
|
+
dispositionByContext.set(context, cache2);
|
|
42861
|
+
return disposition;
|
|
42862
|
+
}
|
|
42863
|
+
|
|
41965
42864
|
// src/sast/rules/javascript.ts
|
|
42865
|
+
function hasDisposition(family, disposition) {
|
|
42866
|
+
return (match, context) => classifyJavascriptCall(match, context, family) === disposition;
|
|
42867
|
+
}
|
|
41966
42868
|
var javascriptRules = [
|
|
41967
42869
|
{
|
|
41968
42870
|
id: "sast/js-eval",
|
|
@@ -41971,7 +42873,18 @@ var javascriptRules = [
|
|
|
41971
42873
|
languages: ["javascript", "typescript"],
|
|
41972
42874
|
description: "Dangerous use of eval() detected - allows arbitrary code execution",
|
|
41973
42875
|
remediation: "Avoid using eval(). If you must parse dynamic content, use JSON.parse() or a proper parser instead.",
|
|
41974
|
-
pattern: /\beval\
|
|
42876
|
+
pattern: /\beval\b/,
|
|
42877
|
+
validate: hasDisposition("eval", "confirmed")
|
|
42878
|
+
},
|
|
42879
|
+
{
|
|
42880
|
+
id: "sast/js-eval-review",
|
|
42881
|
+
name: "Unresolved eval-like call",
|
|
42882
|
+
severity: "low",
|
|
42883
|
+
languages: ["javascript", "typescript"],
|
|
42884
|
+
description: "Unresolved eval-like call requires manual review",
|
|
42885
|
+
remediation: "Verify the callee binding and avoid dynamic code evaluation.",
|
|
42886
|
+
pattern: /\beval\b/,
|
|
42887
|
+
validate: hasDisposition("eval", "ambiguous")
|
|
41975
42888
|
},
|
|
41976
42889
|
{
|
|
41977
42890
|
id: "sast/js-dangerous-function",
|
|
@@ -41980,7 +42893,18 @@ var javascriptRules = [
|
|
|
41980
42893
|
languages: ["javascript", "typescript"],
|
|
41981
42894
|
description: "Dangerous use of new Function() detected - allows arbitrary code execution",
|
|
41982
42895
|
remediation: "Avoid using new Function(). Use a safer alternative like JSON.parse() or a proper expression parser.",
|
|
41983
|
-
pattern: /\
|
|
42896
|
+
pattern: /\bFunction\b/,
|
|
42897
|
+
validate: hasDisposition("function-constructor", "confirmed")
|
|
42898
|
+
},
|
|
42899
|
+
{
|
|
42900
|
+
id: "sast/js-function-constructor-review",
|
|
42901
|
+
name: "Unresolved Function-like constructor",
|
|
42902
|
+
severity: "low",
|
|
42903
|
+
languages: ["javascript", "typescript"],
|
|
42904
|
+
description: "Unresolved Function-like constructor requires manual review",
|
|
42905
|
+
remediation: "Verify the constructor binding and avoid dynamic code construction.",
|
|
42906
|
+
pattern: /\bFunction\b/,
|
|
42907
|
+
validate: hasDisposition("function-constructor", "ambiguous")
|
|
41984
42908
|
},
|
|
41985
42909
|
{
|
|
41986
42910
|
id: "sast/js-command-injection",
|
|
@@ -41989,10 +42913,18 @@ var javascriptRules = [
|
|
|
41989
42913
|
languages: ["javascript", "typescript"],
|
|
41990
42914
|
description: "Potential command injection via child_process.exec() with unsanitized input",
|
|
41991
42915
|
remediation: "Never pass user input directly to exec(). Use execFile() with arguments array or sanitize input thoroughly.",
|
|
41992
|
-
pattern: /
|
|
41993
|
-
validate: (
|
|
41994
|
-
|
|
41995
|
-
|
|
42916
|
+
pattern: /[A-Za-z_$][\w$]*/,
|
|
42917
|
+
validate: hasDisposition("exec", "confirmed")
|
|
42918
|
+
},
|
|
42919
|
+
{
|
|
42920
|
+
id: "sast/js-command-exec-review",
|
|
42921
|
+
name: "Unresolved exec-like call",
|
|
42922
|
+
severity: "low",
|
|
42923
|
+
languages: ["javascript", "typescript"],
|
|
42924
|
+
description: "Unresolved exec-like call requires manual review",
|
|
42925
|
+
remediation: "Verify whether the callee reaches child_process; prefer execFile() with an arguments array.",
|
|
42926
|
+
pattern: /[A-Za-z_$][\w$]*/,
|
|
42927
|
+
validate: hasDisposition("exec", "ambiguous")
|
|
41996
42928
|
},
|
|
41997
42929
|
{
|
|
41998
42930
|
id: "sast/js-set-timeout-string",
|
|
@@ -42001,7 +42933,18 @@ var javascriptRules = [
|
|
|
42001
42933
|
languages: ["javascript", "typescript"],
|
|
42002
42934
|
description: "setTimeout/setInterval called with string argument - similar to eval()",
|
|
42003
42935
|
remediation: 'Use function references instead of strings: setTimeout(() => ..., 1000) instead of setTimeout("...", 1000)',
|
|
42004
|
-
pattern:
|
|
42936
|
+
pattern: /\b(?:setTimeout|setInterval)\b/,
|
|
42937
|
+
validate: hasDisposition("timer-string", "confirmed")
|
|
42938
|
+
},
|
|
42939
|
+
{
|
|
42940
|
+
id: "sast/js-timer-string-review",
|
|
42941
|
+
name: "Unresolved string timer call",
|
|
42942
|
+
severity: "low",
|
|
42943
|
+
languages: ["javascript", "typescript"],
|
|
42944
|
+
description: "Unresolved string timer call requires manual review",
|
|
42945
|
+
remediation: "Verify the timer binding and replace string callbacks with functions.",
|
|
42946
|
+
pattern: /\b(?:setTimeout|setInterval)\b/,
|
|
42947
|
+
validate: hasDisposition("timer-string", "ambiguous")
|
|
42005
42948
|
},
|
|
42006
42949
|
{
|
|
42007
42950
|
id: "sast/js-innerhtml",
|
|
@@ -42019,7 +42962,18 @@ var javascriptRules = [
|
|
|
42019
42962
|
languages: ["javascript", "typescript"],
|
|
42020
42963
|
description: "document.write() can introduce XSS vulnerabilities",
|
|
42021
42964
|
remediation: "Use DOM manipulation methods (createElement, appendChild, textContent) instead.",
|
|
42022
|
-
pattern:
|
|
42965
|
+
pattern: /\bwrite\b/,
|
|
42966
|
+
validate: hasDisposition("document-write", "confirmed")
|
|
42967
|
+
},
|
|
42968
|
+
{
|
|
42969
|
+
id: "sast/js-document-write-review",
|
|
42970
|
+
name: "Unresolved document.write-like call",
|
|
42971
|
+
severity: "low",
|
|
42972
|
+
languages: ["javascript", "typescript"],
|
|
42973
|
+
description: "Unresolved document.write-like call requires manual review",
|
|
42974
|
+
remediation: "Verify the document binding and use safe DOM construction.",
|
|
42975
|
+
pattern: /\bwrite\b/,
|
|
42976
|
+
validate: hasDisposition("document-write", "ambiguous")
|
|
42023
42977
|
},
|
|
42024
42978
|
{
|
|
42025
42979
|
id: "sast/js-postmessage",
|
|
@@ -42028,7 +42982,18 @@ var javascriptRules = [
|
|
|
42028
42982
|
languages: ["javascript", "typescript"],
|
|
42029
42983
|
description: "postMessage event listener without origin validation",
|
|
42030
42984
|
remediation: "Always validate the origin in postMessage event handlers: event.origin === expectedOrigin",
|
|
42031
|
-
pattern:
|
|
42985
|
+
pattern: /\baddEventListener\b/,
|
|
42986
|
+
validate: hasDisposition("postmessage", "confirmed")
|
|
42987
|
+
},
|
|
42988
|
+
{
|
|
42989
|
+
id: "sast/js-postmessage-review",
|
|
42990
|
+
name: "Unresolved message-listener call",
|
|
42991
|
+
severity: "low",
|
|
42992
|
+
languages: ["javascript", "typescript"],
|
|
42993
|
+
description: "Unresolved message-listener call requires manual review",
|
|
42994
|
+
remediation: "Verify the event target and validate message origins where applicable.",
|
|
42995
|
+
pattern: /\baddEventListener\b/,
|
|
42996
|
+
validate: hasDisposition("postmessage", "ambiguous")
|
|
42032
42997
|
},
|
|
42033
42998
|
{
|
|
42034
42999
|
id: "sast/js-hardcoded-secret",
|
|
@@ -42338,23 +43303,23 @@ function executeRulesSync(filePath, content, language) {
|
|
|
42338
43303
|
const findings = [];
|
|
42339
43304
|
const normalizedLang = language.toLowerCase();
|
|
42340
43305
|
const rules = getRulesForLanguage(normalizedLang);
|
|
43306
|
+
const lines = content.split(`
|
|
43307
|
+
`);
|
|
43308
|
+
const context = {
|
|
43309
|
+
filePath,
|
|
43310
|
+
content,
|
|
43311
|
+
language: normalizedLang
|
|
43312
|
+
};
|
|
42341
43313
|
for (const rule of rules) {
|
|
42342
43314
|
if (!rule.pattern)
|
|
42343
43315
|
continue;
|
|
42344
43316
|
const matches = findPatternMatches(content, rule.pattern);
|
|
42345
43317
|
for (const match of matches) {
|
|
42346
43318
|
if (rule.validate) {
|
|
42347
|
-
const context = {
|
|
42348
|
-
filePath,
|
|
42349
|
-
content,
|
|
42350
|
-
language: normalizedLang
|
|
42351
|
-
};
|
|
42352
43319
|
if (!rule.validate(match, context)) {
|
|
42353
43320
|
continue;
|
|
42354
43321
|
}
|
|
42355
43322
|
}
|
|
42356
|
-
const lines = content.split(`
|
|
42357
|
-
`);
|
|
42358
43323
|
const excerpt = lines[match.line - 1]?.trim() || "";
|
|
42359
43324
|
findings.push({
|
|
42360
43325
|
rule_id: rule.id,
|
|
@@ -45161,9 +46126,9 @@ import { createHash as createHash19, createHmac, randomBytes, randomUUID as rand
|
|
|
45161
46126
|
import {
|
|
45162
46127
|
chmod,
|
|
45163
46128
|
copyFile as copyFile2,
|
|
45164
|
-
mkdir as
|
|
46129
|
+
mkdir as mkdir14,
|
|
45165
46130
|
readdir as readdir5,
|
|
45166
|
-
readFile as
|
|
46131
|
+
readFile as readFile17,
|
|
45167
46132
|
realpath as realpath4,
|
|
45168
46133
|
rm as rm2,
|
|
45169
46134
|
stat as stat6,
|
|
@@ -45958,10 +46923,10 @@ function emitMaintenanceTelemetry(payload) {
|
|
|
45958
46923
|
}
|
|
45959
46924
|
var _internals60 = {
|
|
45960
46925
|
emit,
|
|
45961
|
-
readFile:
|
|
46926
|
+
readFile: readFile17,
|
|
45962
46927
|
writeFile: writeFile11,
|
|
45963
46928
|
copyFile: copyFile2,
|
|
45964
|
-
mkdir:
|
|
46929
|
+
mkdir: mkdir14,
|
|
45965
46930
|
stat: stat6,
|
|
45966
46931
|
readdir: readdir5,
|
|
45967
46932
|
resolveHiveDataDir,
|
|
@@ -46283,7 +47248,7 @@ init_schema();
|
|
|
46283
47248
|
init_logger();
|
|
46284
47249
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
46285
47250
|
import { existsSync as existsSync41, readFileSync as readFileSync32 } from "fs";
|
|
46286
|
-
import { mkdir as
|
|
47251
|
+
import { mkdir as mkdir15, readFile as readFile18, writeFile as writeFile12 } from "fs/promises";
|
|
46287
47252
|
import * as os9 from "os";
|
|
46288
47253
|
import * as path68 from "path";
|
|
46289
47254
|
init_knowledge_types();
|
|
@@ -46349,8 +47314,8 @@ var _internals62 = {
|
|
|
46349
47314
|
resolveLegacyHiveKnowledgePath,
|
|
46350
47315
|
existsSync: existsSync41,
|
|
46351
47316
|
readFileSync: readFileSync32,
|
|
46352
|
-
readFile:
|
|
46353
|
-
mkdir:
|
|
47317
|
+
readFile: readFile18,
|
|
47318
|
+
mkdir: mkdir15,
|
|
46354
47319
|
writeFile: writeFile12
|
|
46355
47320
|
};
|
|
46356
47321
|
async function migrateContextToKnowledge(directory, config) {
|
|
@@ -46375,7 +47340,7 @@ async function migrateContextToKnowledge(directory, config) {
|
|
|
46375
47340
|
skippedReason: "no-context-file"
|
|
46376
47341
|
};
|
|
46377
47342
|
}
|
|
46378
|
-
const contextContent = await
|
|
47343
|
+
const contextContent = await readFile18(contextPath, "utf-8");
|
|
46379
47344
|
if (contextContent.trim().length === 0) {
|
|
46380
47345
|
return {
|
|
46381
47346
|
migrated: false,
|
|
@@ -47164,14 +48129,14 @@ var _internals63 = {
|
|
|
47164
48129
|
};
|
|
47165
48130
|
|
|
47166
48131
|
// src/commands/link.ts
|
|
47167
|
-
import { mkdir as
|
|
48132
|
+
import { mkdir as mkdir17, writeFile as writeFile13 } from "fs/promises";
|
|
47168
48133
|
import * as path70 from "path";
|
|
47169
48134
|
init_schema();
|
|
47170
48135
|
|
|
47171
48136
|
// src/knowledge/family-migration.ts
|
|
47172
48137
|
var import_proper_lockfile7 = __toESM(require_proper_lockfile(), 1);
|
|
47173
48138
|
import { existsSync as existsSync42, readFileSync as readFileSync33 } from "fs";
|
|
47174
|
-
import { mkdir as
|
|
48139
|
+
import { mkdir as mkdir16 } from "fs/promises";
|
|
47175
48140
|
import * as path69 from "path";
|
|
47176
48141
|
|
|
47177
48142
|
// src/knowledge/family-manifest.ts
|
|
@@ -47454,7 +48419,7 @@ async function snapshotSourceFamily(storeDir) {
|
|
|
47454
48419
|
const snapshot = {};
|
|
47455
48420
|
let release = null;
|
|
47456
48421
|
try {
|
|
47457
|
-
await
|
|
48422
|
+
await mkdir16(storeDir, { recursive: true });
|
|
47458
48423
|
} catch {}
|
|
47459
48424
|
try {
|
|
47460
48425
|
release = await import_proper_lockfile7.default.lock(storeDir, {
|
|
@@ -47473,7 +48438,7 @@ async function snapshotSourceFamily(storeDir) {
|
|
|
47473
48438
|
return snapshot;
|
|
47474
48439
|
}
|
|
47475
48440
|
async function migrateKnowledgeFamily(destinationDir, sourceDir) {
|
|
47476
|
-
await
|
|
48441
|
+
await mkdir16(destinationDir, { recursive: true });
|
|
47477
48442
|
let destRelease = null;
|
|
47478
48443
|
try {
|
|
47479
48444
|
destRelease = await import_proper_lockfile7.default.lock(destinationDir, {
|
|
@@ -47623,7 +48588,7 @@ ${formatStatus(directory)}`;
|
|
|
47623
48588
|
const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
|
|
47624
48589
|
const config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
47625
48590
|
const fingerprint = cohortConfigFingerprint(buildConfigFingerprintInput(config));
|
|
47626
|
-
await
|
|
48591
|
+
await mkdir17(linkDir, { recursive: true });
|
|
47627
48592
|
await writeFile13(path70.join(linkDir, "cohort-config.json"), JSON.stringify({ fingerprint, updated_at: new Date().toISOString() }, null, 2), "utf-8");
|
|
47628
48593
|
} catch {}
|
|
47629
48594
|
const relinkNote = existing ? `
|
|
@@ -52347,7 +53312,7 @@ function readDeadAnchorMemoryIds(directory) {
|
|
|
52347
53312
|
return new Set(Array.isArray(digest?.deadAnchorMemoryIds) ? digest.deadAnchorMemoryIds.filter((value) => typeof value === "string") : []);
|
|
52348
53313
|
}
|
|
52349
53314
|
// src/memory/consolidation-log.ts
|
|
52350
|
-
import { appendFile as
|
|
53315
|
+
import { appendFile as appendFile4, mkdir as mkdir19, readFile as readFile22 } from "fs/promises";
|
|
52351
53316
|
import * as path76 from "path";
|
|
52352
53317
|
var LOG_RELATIVE_PATH = path76.join("memory", "consolidation-log.jsonl");
|
|
52353
53318
|
var LOG_BASENAME = "consolidation-log.jsonl";
|
|
@@ -52364,7 +53329,7 @@ async function readConsolidationLog(target) {
|
|
|
52364
53329
|
const filePath = resolveLogPath2(target);
|
|
52365
53330
|
let raw;
|
|
52366
53331
|
try {
|
|
52367
|
-
raw = await
|
|
53332
|
+
raw = await readFile22(filePath, "utf-8");
|
|
52368
53333
|
} catch {
|
|
52369
53334
|
return [];
|
|
52370
53335
|
}
|
|
@@ -53011,14 +53976,14 @@ function truncate2(value, maxLength) {
|
|
|
53011
53976
|
}
|
|
53012
53977
|
|
|
53013
53978
|
// src/commands/memory-link.ts
|
|
53014
|
-
import { mkdir as
|
|
53979
|
+
import { mkdir as mkdir21, writeFile as writeFile15 } from "fs/promises";
|
|
53015
53980
|
import * as path79 from "path";
|
|
53016
53981
|
init_schema();
|
|
53017
53982
|
|
|
53018
53983
|
// src/memory/memory-family-migration.ts
|
|
53019
53984
|
var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
|
|
53020
53985
|
import { copyFileSync as copyFileSync4, existsSync as existsSync45, readFileSync as readFileSync35, unlinkSync as unlinkSync13 } from "fs";
|
|
53021
|
-
import { mkdir as
|
|
53986
|
+
import { mkdir as mkdir20, rename as rename8 } from "fs/promises";
|
|
53022
53987
|
import * as path78 from "path";
|
|
53023
53988
|
init_logger();
|
|
53024
53989
|
|
|
@@ -53310,7 +54275,7 @@ async function countRowsSafe(dbPath) {
|
|
|
53310
54275
|
async function migrateMemoryFamily(destRoot, sourceRoot) {
|
|
53311
54276
|
const destStoragePath = rootStoragePath(destRoot);
|
|
53312
54277
|
const sourceStoragePath = rootStoragePath(sourceRoot);
|
|
53313
|
-
await
|
|
54278
|
+
await mkdir20(destStoragePath, { recursive: true });
|
|
53314
54279
|
let destRelease = null;
|
|
53315
54280
|
try {
|
|
53316
54281
|
destRelease = await import_proper_lockfile9.default.lock(destStoragePath, {
|
|
@@ -53357,7 +54322,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
|
|
|
53357
54322
|
}
|
|
53358
54323
|
if (isCohortRoot(sourceRoot)) {
|
|
53359
54324
|
const backupDir = path78.join(destStoragePath, "backups");
|
|
53360
|
-
await
|
|
54325
|
+
await mkdir20(backupDir, { recursive: true });
|
|
53361
54326
|
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
53362
54327
|
const sourceDbPath = path78.join(sourceStoragePath, "memory.db");
|
|
53363
54328
|
if (existsSync45(sourceDbPath)) {
|
|
@@ -53493,7 +54458,7 @@ ${formatStatus2(directory)}`;
|
|
|
53493
54458
|
return `\u274C Failed to migrate the memory family into the cohort store: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
53494
54459
|
}
|
|
53495
54460
|
try {
|
|
53496
|
-
await
|
|
54461
|
+
await mkdir21(cohortRoot.cohortRoot, { recursive: true });
|
|
53497
54462
|
const fingerprintInput = buildMemoryCohortFingerprintInput(memoryConfig);
|
|
53498
54463
|
const fingerprint = computeMemoryCohortFingerprint(fingerprintInput);
|
|
53499
54464
|
await writeFile15(path79.join(cohortRoot.cohortRoot, "memory-cohort-config.json"), JSON.stringify({
|
|
@@ -58034,7 +58999,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
58034
58999
|
const absoluteFile = resolveWorkspacePath(file, workingDir);
|
|
58035
59000
|
const relativeFile = path85.relative(workingDir, absoluteFile);
|
|
58036
59001
|
const basename20 = path85.basename(absoluteFile);
|
|
58037
|
-
const
|
|
59002
|
+
const dirname36 = path85.dirname(absoluteFile);
|
|
58038
59003
|
const preferRelativeOutput = !path85.isAbsolute(file);
|
|
58039
59004
|
if (isConventionTestFilePath(relativeFile) || isConventionTestFilePath(file)) {
|
|
58040
59005
|
dedupePush(testFiles, toWorkspaceOutputPath(absoluteFile, workingDir, preferRelativeOutput));
|
|
@@ -58050,7 +59015,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
58050
59015
|
const colocatedCandidates = [
|
|
58051
59016
|
...genericTestNames,
|
|
58052
59017
|
...languageSpecificTestNames
|
|
58053
|
-
].map((candidateName) => path85.join(
|
|
59018
|
+
].map((candidateName) => path85.join(dirname36, candidateName));
|
|
58054
59019
|
const testDirectoryNames = [
|
|
58055
59020
|
basename20,
|
|
58056
59021
|
...genericTestNames,
|
|
@@ -58059,7 +59024,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
|
|
|
58059
59024
|
const repoLevelDirectories = getRepoLevelCandidateDirectories(workingDir, relativeFile, ext);
|
|
58060
59025
|
const possibleTestFiles = [
|
|
58061
59026
|
...colocatedCandidates,
|
|
58062
|
-
...TEST_DIRECTORY_NAMES.flatMap((dirName) => testDirectoryNames.map((candidateName) => path85.join(
|
|
59027
|
+
...TEST_DIRECTORY_NAMES.flatMap((dirName) => testDirectoryNames.map((candidateName) => path85.join(dirname36, dirName, candidateName))),
|
|
58063
59028
|
...repoLevelDirectories.flatMap((candidateDir) => testDirectoryNames.map((candidateName) => path85.join(candidateDir, candidateName)))
|
|
58064
59029
|
];
|
|
58065
59030
|
for (const testFile of possibleTestFiles) {
|
|
@@ -60636,34 +61601,17 @@ async function handleQaGatesCommand(directory, args, sessionID) {
|
|
|
60636
61601
|
}
|
|
60637
61602
|
|
|
60638
61603
|
// src/workflow/stage-a-repair.ts
|
|
60639
|
-
import {
|
|
60640
|
-
import { dirname as dirname38 } from "path";
|
|
61604
|
+
import { readdir as readdir8 } from "fs/promises";
|
|
60641
61605
|
init_logger();
|
|
60642
61606
|
var MAX_STAGE_A_REPAIR_SCAN = 200;
|
|
60643
|
-
var RETRYABLE_EVENT_CODES = new Set(["EBUSY", "EPERM"]);
|
|
60644
61607
|
async function appendStageARepairEvent(directory, payload) {
|
|
60645
|
-
const line = `${JSON.stringify({
|
|
60646
|
-
type: "stage_a_repair",
|
|
60647
|
-
timestamp: new Date().toISOString(),
|
|
60648
|
-
...payload
|
|
60649
|
-
})}
|
|
60650
|
-
`;
|
|
60651
61608
|
try {
|
|
60652
|
-
|
|
60653
|
-
|
|
60654
|
-
|
|
61609
|
+
appendCoreEventSync(directory, {
|
|
61610
|
+
type: "stage_a_repair",
|
|
61611
|
+
timestamp: new Date().toISOString(),
|
|
61612
|
+
...payload
|
|
61613
|
+
});
|
|
60655
61614
|
} catch (error2) {
|
|
60656
|
-
const code = error2.code;
|
|
60657
|
-
if (code && RETRYABLE_EVENT_CODES.has(code)) {
|
|
60658
|
-
try {
|
|
60659
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
60660
|
-
await appendFile10(eventsPath, line, "utf-8");
|
|
60661
|
-
return;
|
|
60662
|
-
} catch (retryError) {
|
|
60663
|
-
criticalWarn(`[stage-a-repair] audit event write failed after retry: ${retryError instanceof Error ? retryError.message : String(retryError)}`);
|
|
60664
|
-
return;
|
|
60665
|
-
}
|
|
60666
|
-
}
|
|
60667
61615
|
criticalWarn(`[stage-a-repair] audit event write failed: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
60668
61616
|
}
|
|
60669
61617
|
}
|
|
@@ -61738,6 +62686,7 @@ async function handleResetCommand(directory, args) {
|
|
|
61738
62686
|
"plan-export/SWARM_PLAN.json",
|
|
61739
62687
|
"checkpoints.json",
|
|
61740
62688
|
"events.jsonl",
|
|
62689
|
+
"events-authority-index.json",
|
|
61741
62690
|
"run-memory.jsonl",
|
|
61742
62691
|
"reproduction.json",
|
|
61743
62692
|
"issue-publication.json",
|
|
@@ -66216,7 +67165,6 @@ async function restoreGitCheckpoint(directory, selected) {
|
|
|
66216
67165
|
if (parsed.success !== true) {
|
|
66217
67166
|
return `Error: ${parsed.error || `Failed to restore checkpoint "${selected.label}"`}`;
|
|
66218
67167
|
}
|
|
66219
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
66220
67168
|
const rollbackEvent = {
|
|
66221
67169
|
type: "rollback",
|
|
66222
67170
|
label: selected.label,
|
|
@@ -66225,8 +67173,7 @@ async function restoreGitCheckpoint(directory, selected) {
|
|
|
66225
67173
|
source: "checkpoints.json"
|
|
66226
67174
|
};
|
|
66227
67175
|
try {
|
|
66228
|
-
|
|
66229
|
-
`);
|
|
67176
|
+
appendCoreEventSync(directory, rollbackEvent);
|
|
66230
67177
|
} catch (error2) {
|
|
66231
67178
|
log("Failed to write rollback event:", error2 instanceof Error ? error2.message : String(error2));
|
|
66232
67179
|
}
|
|
@@ -66373,7 +67320,6 @@ async function handleRollbackCommand(directory, args) {
|
|
|
66373
67320
|
`);
|
|
66374
67321
|
}
|
|
66375
67322
|
}
|
|
66376
|
-
const eventsPath = validateSwarmPath(directory, "events.jsonl");
|
|
66377
67323
|
const rollbackEvent = {
|
|
66378
67324
|
type: "rollback",
|
|
66379
67325
|
phase: targetPhase,
|
|
@@ -66381,8 +67327,7 @@ async function handleRollbackCommand(directory, args) {
|
|
|
66381
67327
|
timestamp: new Date().toISOString()
|
|
66382
67328
|
};
|
|
66383
67329
|
try {
|
|
66384
|
-
|
|
66385
|
-
`);
|
|
67330
|
+
appendCoreEventSync(directory, rollbackEvent);
|
|
66386
67331
|
} catch (error2) {
|
|
66387
67332
|
log("Failed to write rollback event:", error2 instanceof Error ? error2.message : String(error2));
|
|
66388
67333
|
}
|
|
@@ -68374,7 +69319,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
|
|
|
68374
69319
|
if (!input.dispatcher) {
|
|
68375
69320
|
throw new Error("no evaluation dispatcher available (cannot run validation)");
|
|
68376
69321
|
}
|
|
68377
|
-
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-
|
|
69322
|
+
const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-9mnkfjw7.js");
|
|
68378
69323
|
const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
|
|
68379
69324
|
const result = await _internals95.evaluateCandidateV1({
|
|
68380
69325
|
projectRoot: input.directory,
|
|
@@ -68890,7 +69835,7 @@ async function handleSpecifyCommand(_directory, args) {
|
|
|
68890
69835
|
|
|
68891
69836
|
// src/services/status-service.ts
|
|
68892
69837
|
import * as fsSync3 from "fs";
|
|
68893
|
-
import { readFile as
|
|
69838
|
+
import { readFile as readFile24 } from "fs/promises";
|
|
68894
69839
|
import * as path109 from "path";
|
|
68895
69840
|
init_loader();
|
|
68896
69841
|
init_schema();
|
|
@@ -69931,7 +70876,7 @@ async function safeLineCount(filePath) {
|
|
|
69931
70876
|
try {
|
|
69932
70877
|
if (!fsSync3.existsSync(filePath))
|
|
69933
70878
|
return 0;
|
|
69934
|
-
const content = await
|
|
70879
|
+
const content = await readFile24(filePath, "utf-8");
|
|
69935
70880
|
let n = 0;
|
|
69936
70881
|
for (const line of content.split(`
|
|
69937
70882
|
`)) {
|
|
@@ -70409,7 +71354,7 @@ function buildDetailedHelp(commandName, entry) {
|
|
|
70409
71354
|
async function handleHelpCommand(ctx) {
|
|
70410
71355
|
const targetCommand = ctx.args.join(" ");
|
|
70411
71356
|
if (!targetCommand) {
|
|
70412
|
-
const { buildHelpText } = await import("./index-
|
|
71357
|
+
const { buildHelpText } = await import("./index-ka2vav7t.js");
|
|
70413
71358
|
return buildHelpText();
|
|
70414
71359
|
}
|
|
70415
71360
|
const tokens = targetCommand.split(/\s+/);
|
|
@@ -70418,7 +71363,7 @@ async function handleHelpCommand(ctx) {
|
|
|
70418
71363
|
return _internals98.buildDetailedHelp(resolved.key, resolved.entry);
|
|
70419
71364
|
}
|
|
70420
71365
|
const similar = _internals98.findSimilarCommands(targetCommand);
|
|
70421
|
-
const { buildHelpText: fullHelp } = await import("./index-
|
|
71366
|
+
const { buildHelpText: fullHelp } = await import("./index-ka2vav7t.js");
|
|
70422
71367
|
if (similar.length > 0) {
|
|
70423
71368
|
return `Command '/swarm ${targetCommand}' not found.
|
|
70424
71369
|
|
|
@@ -70598,7 +71543,7 @@ var COMMAND_REGISTRY = {
|
|
|
70598
71543
|
},
|
|
70599
71544
|
"guardrail explain": {
|
|
70600
71545
|
handler: async (ctx) => {
|
|
70601
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
71546
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-nynjhbzk.js");
|
|
70602
71547
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
70603
71548
|
},
|
|
70604
71549
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -70608,7 +71553,7 @@ var COMMAND_REGISTRY = {
|
|
|
70608
71553
|
},
|
|
70609
71554
|
"guardrail reset": {
|
|
70610
71555
|
handler: async (ctx) => {
|
|
70611
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
71556
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-hsfd5ykq.js");
|
|
70612
71557
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
70613
71558
|
},
|
|
70614
71559
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -70617,7 +71562,7 @@ var COMMAND_REGISTRY = {
|
|
|
70617
71562
|
},
|
|
70618
71563
|
"guardrail-explain": {
|
|
70619
71564
|
handler: async (ctx) => {
|
|
70620
|
-
const { handleGuardrailExplain } = await import("./guardrail-explain-
|
|
71565
|
+
const { handleGuardrailExplain } = await import("./guardrail-explain-nynjhbzk.js");
|
|
70621
71566
|
return handleGuardrailExplain(ctx.directory, ctx.args);
|
|
70622
71567
|
},
|
|
70623
71568
|
description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
|
|
@@ -70627,7 +71572,7 @@ var COMMAND_REGISTRY = {
|
|
|
70627
71572
|
},
|
|
70628
71573
|
"guardrail-reset": {
|
|
70629
71574
|
handler: async (ctx) => {
|
|
70630
|
-
const { handleGuardrailReset } = await import("./guardrail-reset-
|
|
71575
|
+
const { handleGuardrailReset } = await import("./guardrail-reset-hsfd5ykq.js");
|
|
70631
71576
|
return handleGuardrailReset(ctx.args, ctx.sessionID);
|
|
70632
71577
|
},
|
|
70633
71578
|
description: "Reset one exact active invocation/action circuit after repair",
|
|
@@ -70637,7 +71582,7 @@ var COMMAND_REGISTRY = {
|
|
|
70637
71582
|
},
|
|
70638
71583
|
"guardrail-log": {
|
|
70639
71584
|
handler: async (ctx) => {
|
|
70640
|
-
const { handleGuardrailLog } = await import("./guardrail-log-
|
|
71585
|
+
const { handleGuardrailLog } = await import("./guardrail-log-6bktj08e.js");
|
|
70641
71586
|
return handleGuardrailLog(ctx.directory, ctx.args);
|
|
70642
71587
|
},
|
|
70643
71588
|
description: "Read the guardrail decision log (use --blocks-only for blocks)",
|
|
@@ -75872,16 +76817,14 @@ async function forceRecordPlanCriticApproval(directory, sessionID, options = {})
|
|
|
75872
76817
|
payloadHashOverride: computePlanStructureHash(plan)
|
|
75873
76818
|
});
|
|
75874
76819
|
try {
|
|
75875
|
-
|
|
75876
|
-
await fs52.promises.appendFile(eventsPath, `${JSON.stringify({
|
|
76820
|
+
appendCoreEventSync(directory, {
|
|
75877
76821
|
type: "plan_critic_gate_manual_approval",
|
|
75878
76822
|
timestamp: recordedAt,
|
|
75879
76823
|
sessionID,
|
|
75880
76824
|
plan_id: planId,
|
|
75881
76825
|
user_confirmed: userConfirmed,
|
|
75882
76826
|
...sanitizedReason ? { reason: sanitizedReason } : {}
|
|
75883
|
-
})
|
|
75884
|
-
`, "utf-8");
|
|
76827
|
+
});
|
|
75885
76828
|
} catch (err) {
|
|
75886
76829
|
warn(`[delegation-gate] plan_critic_gate_manual_approval audit event write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
75887
76830
|
}
|
|
@@ -77064,7 +78007,7 @@ function getDisplayBudget() {
|
|
|
77064
78007
|
async function rehydratePrSubscriptions(sessionID, directory) {
|
|
77065
78008
|
const map = new Map;
|
|
77066
78009
|
try {
|
|
77067
|
-
const { listActive: listActive2 } = await import("./pr-subscriptions-
|
|
78010
|
+
const { listActive: listActive2 } = await import("./pr-subscriptions-cpnwvc6y.js");
|
|
77068
78011
|
const records = await listActive2(directory);
|
|
77069
78012
|
for (const record of records) {
|
|
77070
78013
|
if (record.sessionID !== sessionID)
|
|
@@ -77480,7 +78423,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
|
|
|
77480
78423
|
return extracted === expectedSessionId;
|
|
77481
78424
|
}
|
|
77482
78425
|
async function inspectStandardWorktreeCollisionOwnership(identity) {
|
|
77483
|
-
const collisionOwnership = await import("./worktree-collision-ownership-
|
|
78426
|
+
const collisionOwnership = await import("./worktree-collision-ownership-r8j31h06.js");
|
|
77484
78427
|
return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
|
|
77485
78428
|
}
|
|
77486
78429
|
async function precreateStandardWorktreeSession(args) {
|
|
@@ -77628,7 +78571,7 @@ async function precreateStandardWorktreeSession(args) {
|
|
|
77628
78571
|
const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, provisionResult.worktreePath);
|
|
77629
78572
|
if (laneProfile) {
|
|
77630
78573
|
try {
|
|
77631
|
-
const { writeLaneProfileToDiskReal } = await import("./core-
|
|
78574
|
+
const { writeLaneProfileToDiskReal } = await import("./core-0v762txd.js");
|
|
77632
78575
|
await writeLaneProfileToDiskReal(provisionResult.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
|
|
77633
78576
|
} catch {}
|
|
77634
78577
|
}
|
|
@@ -78286,7 +79229,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
|
|
|
78286
79229
|
}
|
|
78287
79230
|
clearWorktreeMergeStatus(statusKey);
|
|
78288
79231
|
try {
|
|
78289
|
-
const { removeLaneProfileFromDiskReal } = await import("./core-
|
|
79232
|
+
const { removeLaneProfileFromDiskReal } = await import("./core-0v762txd.js");
|
|
78290
79233
|
await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
|
|
78291
79234
|
} catch {}
|
|
78292
79235
|
const state = serializationStateBySessionID.get(dispatch.parentSessionID);
|