opencode-swarm 7.143.2 → 7.143.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/cli/{config-doctor-xadt4kv5.js → config-doctor-az6nqawx.js} +2 -2
  2. package/dist/cli/{core-vpefadja.js → core-a6rzajem.js} +1 -1
  3. package/dist/cli/{curator-llm-factory-xjw5j2jj.js → curator-llm-factory-j42j5rcr.js} +17 -17
  4. package/dist/cli/{curator-wahbxxw9.js → curator-tbw9przg.js} +17 -17
  5. package/dist/cli/{evidence-summary-service-m0jes2yb.js → evidence-summary-service-3f319cst.js} +6 -6
  6. package/dist/cli/{gate-evidence-sf9hbhm0.js → gate-evidence-k2yycngf.js} +2 -2
  7. package/dist/cli/{guardrail-explain-9vdjkz5x.js → guardrail-explain-tsgsw91f.js} +18 -18
  8. package/dist/cli/{guardrail-log-xr0cv07v.js → guardrail-log-70cxb3va.js} +3 -3
  9. package/dist/cli/{hive-promoter-ften3m3h.js → hive-promoter-nksqxfs4.js} +17 -17
  10. package/dist/cli/{index-6hwedxn7.js → index-19wyta2k.js} +3 -3
  11. package/dist/cli/{index-fq0b44vq.js → index-5qqyvwqw.js} +4 -4
  12. package/dist/cli/{index-8hxbjgyk.js → index-6htwcbxh.js} +1 -1
  13. package/dist/cli/{index-je3jmcc1.js → index-8fq18k02.js} +3 -3
  14. package/dist/cli/{index-kjgma6hg.js → index-8qmnqd6g.js} +1 -1
  15. package/dist/cli/{index-x0ja3n3g.js → index-9m5gz9ea.js} +2 -2
  16. package/dist/cli/{index-xacfcpyn.js → index-bt47jrhx.js} +2 -2
  17. package/dist/cli/{index-jvbqryky.js → index-c9d5y70c.js} +3 -3
  18. package/dist/cli/{index-2pxq133w.js → index-dmtq7tvd.js} +1 -1
  19. package/dist/cli/{index-qswsp6s3.js → index-f39n8pbr.js} +1 -1
  20. package/dist/cli/{index-7e91cs99.js → index-f3xf9dv5.js} +5 -5
  21. package/dist/cli/{index-nvt1152n.js → index-gbr0jbxy.js} +1 -1
  22. package/dist/cli/{index-6f80e8r5.js → index-gz3z9d64.js} +179 -122
  23. package/dist/cli/{index-yr997mhn.js → index-ja15rdzd.js} +1 -1
  24. package/dist/cli/{index-r0j1sh38.js → index-jmgm1npc.js} +1 -1
  25. package/dist/cli/{index-h5fmwg5b.js → index-mewk624g.js} +19 -19
  26. package/dist/cli/{index-kc9tfc7e.js → index-seedt8m3.js} +3 -3
  27. package/dist/cli/{index-700yppfy.js → index-td2ga37v.js} +1 -1
  28. package/dist/cli/{index-4g1bnzma.js → index-v9qmhrj9.js} +2 -2
  29. package/dist/cli/{index-yw4atzww.js → index-z0j133c4.js} +1 -1
  30. package/dist/cli/{index-6q3wx600.js → index-z4g05zbr.js} +1 -1
  31. package/dist/cli/index.js +17 -17
  32. package/dist/cli/{knowledge-escalator-9xesv2xx.js → knowledge-escalator-8akk4n18.js} +6 -6
  33. package/dist/cli/{knowledge-events-s8nvbdyk.js → knowledge-events-51qk8fq2.js} +4 -4
  34. package/dist/cli/{knowledge-store-2zt0b10b.js → knowledge-store-7rsezhav.js} +1 -1
  35. package/dist/cli/{knowledge-validator-nt955tw0.js → knowledge-validator-nq75s9et.js} +2 -2
  36. package/dist/cli/{scan-cursor-emrg35t0.js → scan-cursor-em4vrcw6.js} +2 -2
  37. package/dist/cli/{schema-tpbz8f0x.js → schema-1wmfgtm9.js} +1 -1
  38. package/dist/cli/{scope-persistence-1hf839ys.js → scope-persistence-8ehnjgsg.js} +4 -4
  39. package/dist/cli/{skill-generator-fja22m4q.js → skill-generator-3jstr1sx.js} +7 -7
  40. package/dist/cli/{worktree-isolation-gnqvy10j.js → worktree-isolation-cc3x13ng.js} +17 -17
  41. package/dist/commands/registry.d.ts +2 -2
  42. package/dist/hooks/review-receipt-collector.d.ts +1 -0
  43. package/dist/index.d.ts +6 -1
  44. package/dist/index.js +77 -69
  45. package/dist/session/snapshot-reader.d.ts +11 -0
  46. package/dist/session/snapshot-writer.d.ts +12 -0
  47. package/dist/state.d.ts +4 -3
  48. package/dist/tools/dispatch-lanes.d.ts +1 -0
  49. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  // @bun
2
2
  import {
3
3
  stableCanonicalStringify
4
- } from "./index-8hxbjgyk.js";
4
+ } from "./index-6htwcbxh.js";
5
5
  import {
6
6
  detectStraySwarmDirs,
7
7
  readDoctorArtifact,
8
8
  removeStraySwarmDir,
9
9
  runConfigDoctor
10
- } from "./index-yr997mhn.js";
10
+ } from "./index-ja15rdzd.js";
11
11
  import {
12
12
  MAX_TRANSIENT_RETRIES,
13
13
  archiveEvidence,
@@ -54,7 +54,7 @@ import {
54
54
  updateTaskCheckpointReceipt,
55
55
  updateTaskStatus,
56
56
  validateProjectRoot
57
- } from "./index-jvbqryky.js";
57
+ } from "./index-c9d5y70c.js";
58
58
  import {
59
59
  loadDatabaseCtor
60
60
  } from "./index-134d35c1.js";
@@ -106,7 +106,7 @@ import {
106
106
  alreadyCuratedThisGeneration,
107
107
  claimNextScanBatch,
108
108
  resolveCohortId
109
- } from "./index-2pxq133w.js";
109
+ } from "./index-dmtq7tvd.js";
110
110
  import {
111
111
  CURATOR_INIT_PROMPT,
112
112
  CURATOR_PHASE_PROMPT,
@@ -141,7 +141,7 @@ import {
141
141
  startupOrphanRecovery,
142
142
  withTaskEvidenceTransaction,
143
143
  writeWorkflowWalFile
144
- } from "./index-700yppfy.js";
144
+ } from "./index-td2ga37v.js";
145
145
  import {
146
146
  changedFilesSinceSnapshot,
147
147
  parsePorcelainV2Snapshot,
@@ -188,16 +188,16 @@ import {
188
188
  retireSkill,
189
189
  selectCandidateEntries,
190
190
  syncBundledProjectSkillsIfMissingAsync
191
- } from "./index-6hwedxn7.js";
191
+ } from "./index-19wyta2k.js";
192
192
  import {
193
193
  readRecentEscalations
194
- } from "./index-7e91cs99.js";
194
+ } from "./index-f3xf9dv5.js";
195
195
  import {
196
196
  MAX_PENDING_SCOPE_BINDINGS,
197
197
  clearAllScopes,
198
198
  clearScopeBindingFromDisk,
199
199
  clearScopeBindings
200
- } from "./index-4g1bnzma.js";
200
+ } from "./index-v9qmhrj9.js";
201
201
  import {
202
202
  appendLedgerEvent,
203
203
  computePlanHash,
@@ -210,7 +210,7 @@ import {
210
210
  readPlanEpochIdentity,
211
211
  replayFromLedgerWithStatus,
212
212
  takeSnapshotEvent
213
- } from "./index-kjgma6hg.js";
213
+ } from "./index-8qmnqd6g.js";
214
214
  import {
215
215
  isPathWithinDeclaredScope
216
216
  } from "./index-556ja8an.js";
@@ -238,7 +238,7 @@ import {
238
238
  import {
239
239
  provisionWorktree,
240
240
  removeWorktree
241
- } from "./index-nvt1152n.js";
241
+ } from "./index-gbr0jbxy.js";
242
242
  import {
243
243
  SandboxCapabilityProbe,
244
244
  init_capability_probe
@@ -262,10 +262,10 @@ import {
262
262
  recordKnowledgeEvent,
263
263
  recordPhaseCloseIntent,
264
264
  resolveKnowledgeEventsPath
265
- } from "./index-je3jmcc1.js";
265
+ } from "./index-8fq18k02.js";
266
266
  import {
267
267
  resolveWorktreeIsolationConfig
268
- } from "./index-x0ja3n3g.js";
268
+ } from "./index-9m5gz9ea.js";
269
269
  import {
270
270
  RetrospectiveEvidenceSchema
271
271
  } from "./index-gprxjmm7.js";
@@ -275,7 +275,7 @@ import {
275
275
  init_loader,
276
276
  loadPluginConfig,
277
277
  loadPluginConfigWithMeta
278
- } from "./index-qswsp6s3.js";
278
+ } from "./index-f39n8pbr.js";
279
279
  import {
280
280
  DEFAULT_SKILL_OPT_CONFIG,
281
281
  FALLBACK_MODELS_MAX,
@@ -289,7 +289,7 @@ import {
289
289
  package_default,
290
290
  resolveAutoReviewConfig,
291
291
  stripKnownSwarmPrefix
292
- } from "./index-6q3wx600.js";
292
+ } from "./index-z4g05zbr.js";
293
293
  import {
294
294
  readSwarmFileAsync,
295
295
  safeHook,
@@ -324,7 +324,7 @@ import {
324
324
  validateActionableFields,
325
325
  validateLesson,
326
326
  validateSkillPath
327
- } from "./index-yw4atzww.js";
327
+ } from "./index-z0j133c4.js";
328
328
  import {
329
329
  authorizeCuration,
330
330
  buildConfigFingerprintInput
@@ -361,7 +361,7 @@ import {
361
361
  transactFile,
362
362
  transactKnowledge,
363
363
  wordBigrams
364
- } from "./index-fq0b44vq.js";
364
+ } from "./index-5qqyvwqw.js";
365
365
  import {
366
366
  resolveHiveDataDir,
367
367
  resolveHiveEventsPath,
@@ -4153,7 +4153,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
4153
4153
  awaitingMergeByCallID,
4154
4154
  cleanupStandardWorktreeForCallId,
4155
4155
  standardWorktreeByCallID
4156
- } = await import("./worktree-isolation-gnqvy10j.js");
4156
+ } = await import("./worktree-isolation-cc3x13ng.js");
4157
4157
  standardWorktreeByCallID.delete(descriptor.callID);
4158
4158
  if (hasResidue)
4159
4159
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -4232,7 +4232,7 @@ async function recoverCoderSettlement(directory, taskId) {
4232
4232
  awaitingMergeByCallID,
4233
4233
  finishStandardWorktreeDispatch,
4234
4234
  standardWorktreeByCallID
4235
- } = await import("./worktree-isolation-gnqvy10j.js");
4235
+ } = await import("./worktree-isolation-cc3x13ng.js");
4236
4236
  const descriptor = wal.worktree;
4237
4237
  const reconstructedDispatch = {
4238
4238
  callID: descriptor.callID,
@@ -14931,7 +14931,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
14931
14931
  };
14932
14932
  }
14933
14933
  async function sweepActiveNearDuplicates(directory, options = {}) {
14934
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-kc9tfc7e.js");
14934
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-seedt8m3.js");
14935
14935
  const { config } = loadPluginConfigWithMeta2(directory);
14936
14936
  const sweepConfig = config.learning?.dedup_sweep;
14937
14937
  if (sweepConfig?.enabled === false)
@@ -16015,7 +16015,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
16015
16015
  }
16016
16016
  if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
16017
16017
  try {
16018
- const skillModule = await import("./skill-generator-fja22m4q.js");
16018
+ const skillModule = await import("./skill-generator-3jstr1sx.js");
16019
16019
  for (const cand of skillCandidates) {
16020
16020
  if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
16021
16021
  continue;
@@ -16475,7 +16475,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
16475
16475
  } catch {}
16476
16476
  }
16477
16477
  if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
16478
- const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-9xesv2xx.js");
16478
+ const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-8akk4n18.js");
16479
16479
  for (const { id } of contradictedEntries) {
16480
16480
  try {
16481
16481
  await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
@@ -17294,7 +17294,7 @@ async function runCuratorPostMortem(directory, options = {}) {
17294
17294
  warnings.push("Failed to collect knowledge summary.");
17295
17295
  }
17296
17296
  try {
17297
- const { getScanStatus } = await import("./scan-cursor-emrg35t0.js");
17297
+ const { getScanStatus } = await import("./scan-cursor-em4vrcw6.js");
17298
17298
  const scanStatus = await getScanStatus(directory);
17299
17299
  if (scanStatus.remaining_estimate > 0) {
17300
17300
  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.`);
@@ -17466,9 +17466,9 @@ var _internals23 = {
17466
17466
  verifyPostMortemKnowledgeActions,
17467
17467
  repairPostMortemActions,
17468
17468
  loadDefaultKnowledgeConfig: async (directory) => {
17469
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-tpbz8f0x.js");
17469
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-1wmfgtm9.js");
17470
17470
  try {
17471
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-kc9tfc7e.js");
17471
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-seedt8m3.js");
17472
17472
  const loaded = loadPluginConfigWithMeta2(directory);
17473
17473
  return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
17474
17474
  } catch {
@@ -17476,11 +17476,11 @@ var _internals23 = {
17476
17476
  }
17477
17477
  },
17478
17478
  applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
17479
- const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-wahbxxw9.js");
17479
+ const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-tbw9przg.js");
17480
17480
  return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
17481
17481
  },
17482
17482
  checkHivePromotions: async (entries, knowledgeConfig, directory) => {
17483
- const { checkHivePromotions } = await import("./hive-promoter-ften3m3h.js");
17483
+ const { checkHivePromotions } = await import("./hive-promoter-nksqxfs4.js");
17484
17484
  return checkHivePromotions(entries, knowledgeConfig, directory);
17485
17485
  },
17486
17486
  applyProposalTriage: async (directory, triage) => {
@@ -17489,7 +17489,7 @@ var _internals23 = {
17489
17489
  activateProposal,
17490
17490
  listSkills: listSkills2,
17491
17491
  sanitizeSlug
17492
- } = await import("./skill-generator-fja22m4q.js");
17492
+ } = await import("./skill-generator-3jstr1sx.js");
17493
17493
  const result = {
17494
17494
  approved: [],
17495
17495
  rejected: [],
@@ -18825,9 +18825,9 @@ function hashContent(content) {
18825
18825
  return createHash7("sha1").update(content).digest("hex");
18826
18826
  }
18827
18827
  async function loadConfigForPolicyCurator(directory) {
18828
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-tpbz8f0x.js");
18828
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-1wmfgtm9.js");
18829
18829
  try {
18830
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-kc9tfc7e.js");
18830
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-seedt8m3.js");
18831
18831
  const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
18832
18832
  return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
18833
18833
  } catch {
@@ -27669,7 +27669,7 @@ async function runFinalizeStage(ctx) {
27669
27669
  }
27670
27670
  }
27671
27671
  try {
27672
- const { CuratorConfigSchema: CCS } = await import("./schema-tpbz8f0x.js");
27672
+ const { CuratorConfigSchema: CCS } = await import("./schema-1wmfgtm9.js");
27673
27673
  const { config: pmLoadedConfig } = _internals36.loadPluginConfigWithMeta(ctx.directory);
27674
27674
  const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
27675
27675
  if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
@@ -28373,7 +28373,7 @@ No active state was archived or removed. Fix the reported durable-state problem,
28373
28373
  "",
28374
28374
  "## Context",
28375
28375
  "- Reset context.md for next session",
28376
- "- Cleared agent sessions and delegation chains",
28376
+ "- Cleared agent sessions, delegation chains, and active-agent mappings",
28377
28377
  ...cleanResult.configBackupsRemoved > 0 ? [
28378
28378
  `- Removed ${cleanResult.configBackupsRemoved} stale config backup file(s)`
28379
28379
  ] : [],
@@ -29947,9 +29947,9 @@ var _internals41 = {
29947
29947
  loadPluginConfigWithMeta,
29948
29948
  loadCuratorDeps: async () => {
29949
29949
  const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
29950
- import("./schema-tpbz8f0x.js"),
29951
- import("./curator-wahbxxw9.js"),
29952
- import("./curator-llm-factory-xjw5j2jj.js")
29950
+ import("./schema-1wmfgtm9.js"),
29951
+ import("./curator-tbw9przg.js"),
29952
+ import("./curator-llm-factory-j42j5rcr.js")
29953
29953
  ]);
29954
29954
  return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
29955
29955
  }
@@ -30854,7 +30854,7 @@ async function computeCurationDiagnostics(directory, entries) {
30854
30854
  let scanCompleted = false;
30855
30855
  let scanRemaining = 0;
30856
30856
  try {
30857
- const { getScanStatus } = await import("./scan-cursor-emrg35t0.js");
30857
+ const { getScanStatus } = await import("./scan-cursor-em4vrcw6.js");
30858
30858
  const status = await getScanStatus(directory);
30859
30859
  scanGeneration = status.generation;
30860
30860
  scanCompleted = status.completed;
@@ -30864,10 +30864,10 @@ async function computeCurationDiagnostics(directory, entries) {
30864
30864
  try {
30865
30865
  const { isLinked: isLinked2 } = await import("./knowledge-link-fn5j3r4q.js");
30866
30866
  if (isLinked2(directory)) {
30867
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-tpbz8f0x.js");
30867
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-1wmfgtm9.js");
30868
30868
  let config;
30869
30869
  try {
30870
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-kc9tfc7e.js");
30870
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-seedt8m3.js");
30871
30871
  const loaded = loadPluginConfigWithMeta2(directory);
30872
30872
  config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
30873
30873
  } catch {
@@ -32085,7 +32085,7 @@ async function handleDoctorCommand(directory, args) {
32085
32085
  const result = runConfigDoctor(config, directory);
32086
32086
  let output;
32087
32087
  if (enableAutoFix && result.hasAutoFixableIssues) {
32088
- const { runConfigDoctorWithFixes } = await import("./config-doctor-xadt4kv5.js");
32088
+ const { runConfigDoctorWithFixes } = await import("./config-doctor-az6nqawx.js");
32089
32089
  const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
32090
32090
  applyLossy: true
32091
32091
  });
@@ -32922,7 +32922,7 @@ async function handleEvidenceCommand(directory, args) {
32922
32922
  return formatTaskEvidenceMarkdown(evidenceData);
32923
32923
  }
32924
32924
  async function handleEvidenceSummaryCommand(directory) {
32925
- const { buildEvidenceSummary } = await import("./evidence-summary-service-m0jes2yb.js");
32925
+ const { buildEvidenceSummary } = await import("./evidence-summary-service-3f319cst.js");
32926
32926
  const artifact = await buildEvidenceSummary(directory);
32927
32927
  if (!artifact) {
32928
32928
  return "No plan found. Run `/swarm plan` to check plan status.";
@@ -36531,8 +36531,10 @@ async function sastScan(input, directory, config) {
36531
36531
  break;
36532
36532
  }
36533
36533
  }
36534
+ let zeroCoverageError;
36534
36535
  if (filesScanned === 0) {
36535
36536
  verdict = "fail";
36537
+ zeroCoverageError = "SAST requires at least one file to scan; zero files were scanned";
36536
36538
  }
36537
36539
  const summary = {
36538
36540
  engine,
@@ -36561,7 +36563,8 @@ async function sastScan(input, directory, config) {
36561
36563
  const result = {
36562
36564
  verdict,
36563
36565
  findings: finalFindings,
36564
- summary
36566
+ summary,
36567
+ ...zeroCoverageError ? { error: zeroCoverageError } : {}
36565
36568
  };
36566
36569
  if (baselineUsed) {
36567
36570
  result.new_findings = newFindings;
@@ -37436,7 +37439,7 @@ async function handleGateStatsCommand(directory, args) {
37436
37439
 
37437
37440
  // src/commands/handoff.ts
37438
37441
  import crypto5 from "crypto";
37439
- import { renameSync as renameSync12, unlinkSync as unlinkSync9 } from "fs";
37442
+ import { renameSync as renameSync11, unlinkSync as unlinkSync10 } from "fs";
37440
37443
 
37441
37444
  // src/services/handoff-service.ts
37442
37445
  var RTL_OVERRIDE_PATTERN = /[\u202e\u202d\u202c\u200f]/g;
@@ -37821,9 +37824,41 @@ var _internals52 = {
37821
37824
  };
37822
37825
 
37823
37826
  // src/session/snapshot-writer.ts
37824
- import { closeSync as closeSync7, fsyncSync as fsyncSync2, mkdirSync as mkdirSync19, openSync as openSync7, renameSync as renameSync11 } from "fs";
37827
+ import {
37828
+ closeSync as closeSync7,
37829
+ existsSync as existsSync36,
37830
+ fsyncSync as fsyncSync2,
37831
+ mkdirSync as mkdirSync19,
37832
+ openSync as openSync7,
37833
+ unlinkSync as unlinkSync9
37834
+ } from "fs";
37835
+ import { rename as fsRename } from "fs/promises";
37825
37836
  import * as path62 from "path";
37826
37837
  var _writeInFlight = Promise.resolve();
37838
+ var SNAPSHOT_RENAME_MAX_ATTEMPTS = 3;
37839
+ var SNAPSHOT_RENAME_RETRY_DELAY_MS = 50;
37840
+ async function renameWithTransientRetry(tempPath, targetPath) {
37841
+ let lastError;
37842
+ for (let attempt = 0;attempt < SNAPSHOT_RENAME_MAX_ATTEMPTS; attempt++) {
37843
+ try {
37844
+ await _internals53.rename(tempPath, targetPath);
37845
+ return;
37846
+ } catch (error2) {
37847
+ lastError = error2;
37848
+ const code = error2.code;
37849
+ if (code === "ENOENT" && attempt > 0 && !existsSync36(tempPath) && existsSync36(targetPath)) {
37850
+ return;
37851
+ }
37852
+ if (code !== "EEXIST" && code !== "EBUSY" && code !== "EPERM") {
37853
+ break;
37854
+ }
37855
+ if (attempt < SNAPSHOT_RENAME_MAX_ATTEMPTS - 1) {
37856
+ await new Promise((resolve20) => setTimeout(resolve20, SNAPSHOT_RENAME_RETRY_DELAY_MS));
37857
+ }
37858
+ }
37859
+ }
37860
+ throw lastError;
37861
+ }
37827
37862
  function serializeAgentSession(s) {
37828
37863
  const gateLog = {};
37829
37864
  const rawGateLog = s.gateLog ?? new Map;
@@ -37966,7 +38001,13 @@ async function writeSnapshot(directory, state) {
37966
38001
  closeSync7(fd);
37967
38002
  }
37968
38003
  } catch {}
37969
- renameSync11(tempPath, resolvedPath);
38004
+ try {
38005
+ await renameWithTransientRetry(tempPath, resolvedPath);
38006
+ } finally {
38007
+ try {
38008
+ unlinkSync9(tempPath);
38009
+ } catch {}
38010
+ }
37970
38011
  invalidateCachedArtifact(resolvedPath);
37971
38012
  } catch (error2) {
37972
38013
  log("[snapshot-writer] write failed", {
@@ -37987,7 +38028,8 @@ async function flushPendingSnapshot(directory) {
37987
38028
  var _internals53 = {
37988
38029
  writeSnapshot,
37989
38030
  createSnapshotWriterHook,
37990
- flushPendingSnapshot
38031
+ flushPendingSnapshot,
38032
+ rename: fsRename
37991
38033
  };
37992
38034
 
37993
38035
  // src/commands/handoff.ts
@@ -38007,10 +38049,10 @@ async function handleHandoffCommand(directory, _args, sessionID) {
38007
38049
  const tempPath = `${resolvedPath}.tmp.${crypto5.randomUUID()}`;
38008
38050
  await bunWrite(tempPath, formatSessionScopedHandoffMarkdown(markdown, sessionID));
38009
38051
  try {
38010
- renameSync12(tempPath, resolvedPath);
38052
+ renameSync11(tempPath, resolvedPath);
38011
38053
  } catch (renameErr) {
38012
38054
  try {
38013
- unlinkSync9(tempPath);
38055
+ unlinkSync10(tempPath);
38014
38056
  } catch {}
38015
38057
  throw renameErr;
38016
38058
  }
@@ -38020,10 +38062,10 @@ async function handleHandoffCommand(directory, _args, sessionID) {
38020
38062
  const promptTempPath = `${promptPath}.tmp.${crypto5.randomUUID()}`;
38021
38063
  await bunWrite(promptTempPath, continuationPrompt);
38022
38064
  try {
38023
- renameSync12(promptTempPath, promptPath);
38065
+ renameSync11(promptTempPath, promptPath);
38024
38066
  } catch (renameErr) {
38025
38067
  try {
38026
- unlinkSync9(promptTempPath);
38068
+ unlinkSync10(promptTempPath);
38027
38069
  } catch {}
38028
38070
  throw renameErr;
38029
38071
  }
@@ -39326,7 +39368,7 @@ init_schema();
39326
39368
  // src/hooks/knowledge-migrator.ts
39327
39369
  init_logger();
39328
39370
  import { randomUUID as randomUUID9 } from "crypto";
39329
- import { existsSync as existsSync37, readFileSync as readFileSync29 } from "fs";
39371
+ import { existsSync as existsSync38, readFileSync as readFileSync29 } from "fs";
39330
39372
  import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile13 } from "fs/promises";
39331
39373
  import * as os8 from "os";
39332
39374
  import * as path65 from "path";
@@ -39391,7 +39433,7 @@ var _internals56 = {
39391
39433
  inferProjectName,
39392
39434
  writeSentinel,
39393
39435
  resolveLegacyHiveKnowledgePath,
39394
- existsSync: existsSync37,
39436
+ existsSync: existsSync38,
39395
39437
  readFileSync: readFileSync29,
39396
39438
  readFile: readFile19,
39397
39439
  mkdir: mkdir17,
@@ -39401,7 +39443,7 @@ async function migrateContextToKnowledge(directory, config) {
39401
39443
  const sentinelPath = path65.join(directory, ".swarm", ".knowledge-migrated");
39402
39444
  const contextPath = path65.join(directory, ".swarm", "context.md");
39403
39445
  const knowledgePath = resolveSwarmKnowledgePath(directory);
39404
- if (existsSync37(sentinelPath)) {
39446
+ if (existsSync38(sentinelPath)) {
39405
39447
  return {
39406
39448
  migrated: false,
39407
39449
  entriesMigrated: 0,
@@ -39410,7 +39452,7 @@ async function migrateContextToKnowledge(directory, config) {
39410
39452
  skippedReason: "sentinel-exists"
39411
39453
  };
39412
39454
  }
39413
- if (!existsSync37(contextPath)) {
39455
+ if (!existsSync38(contextPath)) {
39414
39456
  return {
39415
39457
  migrated: false,
39416
39458
  entriesMigrated: 0,
@@ -39502,7 +39544,7 @@ async function migrateHiveKnowledgeLegacy(config) {
39502
39544
  const legacyHivePath = _internals56.resolveLegacyHiveKnowledgePath();
39503
39545
  const canonicalHivePath = resolveHiveKnowledgePath2();
39504
39546
  const sentinelPath = path65.join(path65.dirname(canonicalHivePath), ".hive-knowledge-migrated");
39505
- if (existsSync37(sentinelPath)) {
39547
+ if (existsSync38(sentinelPath)) {
39506
39548
  return {
39507
39549
  migrated: false,
39508
39550
  entriesMigrated: 0,
@@ -39511,7 +39553,7 @@ async function migrateHiveKnowledgeLegacy(config) {
39511
39553
  skippedReason: "sentinel-exists"
39512
39554
  };
39513
39555
  }
39514
- if (!existsSync37(legacyHivePath)) {
39556
+ if (!existsSync38(legacyHivePath)) {
39515
39557
  return {
39516
39558
  migrated: false,
39517
39559
  entriesMigrated: 0,
@@ -39713,7 +39755,7 @@ function truncateLesson2(text) {
39713
39755
  }
39714
39756
  function inferProjectName(directory) {
39715
39757
  const packageJsonPath = path65.join(directory, "package.json");
39716
- if (existsSync37(packageJsonPath)) {
39758
+ if (existsSync38(packageJsonPath)) {
39717
39759
  try {
39718
39760
  const pkg = JSON.parse(readFileSync29(packageJsonPath, "utf-8"));
39719
39761
  if (pkg.name && typeof pkg.name === "string") {
@@ -40214,7 +40256,7 @@ init_schema();
40214
40256
 
40215
40257
  // src/knowledge/family-migration.ts
40216
40258
  var import_proper_lockfile6 = __toESM(require_proper_lockfile(), 1);
40217
- import { existsSync as existsSync38, readFileSync as readFileSync30 } from "fs";
40259
+ import { existsSync as existsSync39, readFileSync as readFileSync30 } from "fs";
40218
40260
  import { mkdir as mkdir18 } from "fs/promises";
40219
40261
  import * as path66 from "path";
40220
40262
 
@@ -40323,7 +40365,7 @@ var MIGRATION_LOCK_RETRIES = {
40323
40365
  // src/knowledge/family-migration.ts
40324
40366
  var DEDUP_THRESHOLD = 0.6;
40325
40367
  function readJsonl2(filePath) {
40326
- if (!existsSync38(filePath))
40368
+ if (!existsSync39(filePath))
40327
40369
  return [];
40328
40370
  try {
40329
40371
  const content = readFileSync30(filePath, "utf-8");
@@ -40343,7 +40385,7 @@ function readJsonl2(filePath) {
40343
40385
  }
40344
40386
  }
40345
40387
  function readJson(filePath) {
40346
- if (!existsSync38(filePath))
40388
+ if (!existsSync39(filePath))
40347
40389
  return null;
40348
40390
  try {
40349
40391
  return JSON.parse(readFileSync30(filePath, "utf-8"));
@@ -40851,7 +40893,7 @@ ${USAGE11}`;
40851
40893
 
40852
40894
  // src/commands/memory.ts
40853
40895
  init_loader();
40854
- import { existsSync as existsSync39 } from "fs";
40896
+ import { existsSync as existsSync40 } from "fs";
40855
40897
  import * as path70 from "path";
40856
40898
  import { fileURLToPath as fileURLToPath3 } from "url";
40857
40899
  // src/memory/evaluation.ts
@@ -41425,7 +41467,7 @@ async function handleMemoryStatusCommand(directory, _args) {
41425
41467
  `- Provider: \`${config.provider}\``,
41426
41468
  `- Storage: \`${storageDir}\``,
41427
41469
  `- SQLite path: \`${sqlitePath}\``,
41428
- `- SQLite database exists: \`${existsSync39(sqlitePath)}\``,
41470
+ `- SQLite database exists: \`${existsSync40(sqlitePath)}\``,
41429
41471
  `- Automatic destructive cleanup: \`disabled\``,
41430
41472
  "",
41431
41473
  "### Legacy JSONL"
@@ -41910,7 +41952,7 @@ init_schema();
41910
41952
 
41911
41953
  // src/memory/memory-family-migration.ts
41912
41954
  var import_proper_lockfile7 = __toESM(require_proper_lockfile(), 1);
41913
- import { copyFileSync as copyFileSync4, existsSync as existsSync40, readFileSync as readFileSync31, unlinkSync as unlinkSync11 } from "fs";
41955
+ import { copyFileSync as copyFileSync4, existsSync as existsSync41, readFileSync as readFileSync31, unlinkSync as unlinkSync12 } from "fs";
41914
41956
  import { mkdir as mkdir21, rename as rename8 } from "fs/promises";
41915
41957
  import * as path71 from "path";
41916
41958
  init_logger();
@@ -41971,7 +42013,7 @@ var MIGRATED_MEMORY_FILENAMES = MEMORY_FAMILY.filter((m) => m.mergeStrategy !==
41971
42013
  // src/memory/memory-family-migration.ts
41972
42014
  var MAX_BACKUPS = 5;
41973
42015
  function readJsonl3(filePath) {
41974
- if (!existsSync40(filePath))
42016
+ if (!existsSync41(filePath))
41975
42017
  return [];
41976
42018
  try {
41977
42019
  const content = readFileSync31(filePath, "utf-8");
@@ -42036,13 +42078,13 @@ function validateSerializedJsonl(serialized) {
42036
42078
  }
42037
42079
  function stageSqliteDb(sourceStoragePath, destDir) {
42038
42080
  const sourceDbPath = path71.join(sourceStoragePath, "memory.db");
42039
- if (!existsSync40(sourceDbPath))
42081
+ if (!existsSync41(sourceDbPath))
42040
42082
  return null;
42041
42083
  const stagedPath = path71.join(destDir, ".memory.db.stage");
42042
42084
  copyFileSync4(sourceDbPath, stagedPath);
42043
42085
  for (const suffix of ["-wal", "-shm"]) {
42044
42086
  const sidecar = `${sourceDbPath}${suffix}`;
42045
- if (existsSync40(sidecar)) {
42087
+ if (existsSync41(sidecar)) {
42046
42088
  try {
42047
42089
  copyFileSync4(sidecar, `${stagedPath}${suffix}`);
42048
42090
  } catch {}
@@ -42052,11 +42094,11 @@ function stageSqliteDb(sourceStoragePath, destDir) {
42052
42094
  }
42053
42095
  async function mergeStagedSqlite(destStoragePath, stagedPath) {
42054
42096
  const destDbPath = path71.join(destStoragePath, "memory.db");
42055
- if (!existsSync40(destDbPath)) {
42097
+ if (!existsSync41(destDbPath)) {
42056
42098
  await rename8(stagedPath, destDbPath);
42057
42099
  for (const suffix of ["-wal", "-shm"]) {
42058
42100
  const stagedSidecar = `${stagedPath}${suffix}`;
42059
- if (existsSync40(stagedSidecar)) {
42101
+ if (existsSync41(stagedSidecar)) {
42060
42102
  try {
42061
42103
  await rename8(stagedSidecar, `${destDbPath}${suffix}`);
42062
42104
  } catch {}
@@ -42101,10 +42143,10 @@ async function mergeStagedSqlite(destStoragePath, stagedPath) {
42101
42143
  } finally {
42102
42144
  db.close();
42103
42145
  try {
42104
- unlinkSync11(stagedPath);
42146
+ unlinkSync12(stagedPath);
42105
42147
  for (const suffix of ["-wal", "-shm"]) {
42106
42148
  try {
42107
- unlinkSync11(`${stagedPath}${suffix}`);
42149
+ unlinkSync12(`${stagedPath}${suffix}`);
42108
42150
  } catch {}
42109
42151
  }
42110
42152
  } catch {}
@@ -42147,7 +42189,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
42147
42189
  const srcPath = path71.join(sourceStoragePath, member.filename);
42148
42190
  const destPath = path71.join(destStoragePath, member.filename);
42149
42191
  if (member.mergeStrategy === "sqlite-file-copy") {
42150
- if (!existsSync40(srcPath)) {
42192
+ if (!existsSync41(srcPath)) {
42151
42193
  perMember.push({ filename: member.filename, merged: 0, skipped: 0 });
42152
42194
  continue;
42153
42195
  }
@@ -42161,7 +42203,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
42161
42203
  continue;
42162
42204
  }
42163
42205
  if (member.mergeStrategy === "append-union") {
42164
- if (!existsSync40(srcPath)) {
42206
+ if (!existsSync41(srcPath)) {
42165
42207
  perMember.push({ filename: member.filename, merged: 0, skipped: 0 });
42166
42208
  continue;
42167
42209
  }
@@ -42181,7 +42223,7 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
42181
42223
  await mkdir21(backupDir, { recursive: true });
42182
42224
  const stamp = new Date().toISOString().replace(/[:.]/g, "-");
42183
42225
  const sourceDbPath = path71.join(sourceStoragePath, "memory.db");
42184
- if (existsSync40(sourceDbPath)) {
42226
+ if (existsSync41(sourceDbPath)) {
42185
42227
  try {
42186
42228
  copyFileSync4(sourceDbPath, path71.join(backupDir, `memory.db.pre-merge-${stamp}`));
42187
42229
  } catch {}
@@ -49946,6 +49988,9 @@ async function handleResetSessionCommand(directory, _args) {
49946
49988
  const chainCount = swarmState.delegationChains.size;
49947
49989
  swarmState.delegationChains.clear();
49948
49990
  results.push(`\u2705 Cleared ${chainCount} delegation chain(s)`);
49991
+ const activeAgentCount = swarmState.activeAgent.size;
49992
+ swarmState.activeAgent.clear();
49993
+ results.push(`\u2705 Cleared ${activeAgentCount} active-agent mapping(s)`);
49949
49994
  const worktreesDir = path81.resolve(path81.dirname(directory), SWARM_WORKTREE_DIR_NAME);
49950
49995
  try {
49951
49996
  if (fs36.existsSync(worktreesDir)) {
@@ -52157,6 +52202,7 @@ function parseReviewerOutput(text, options = {}) {
52157
52202
  };
52158
52203
  }
52159
52204
  var _internals75 = {
52205
+ delegationBegin: telemetry.delegationBegin,
52160
52206
  delegationEnd: telemetry.delegationEnd,
52161
52207
  resolveReviewerTaskScope,
52162
52208
  buildReviewerTaskScope,
@@ -52622,6 +52668,7 @@ async function dispatchReviewerWithFallback(input, prompt, timeoutMs, promptByte
52622
52668
  const models = [input.reviewerModel, ...input.reviewerFallbackModels ?? []];
52623
52669
  const attempts = [];
52624
52670
  for (let index = 0;index < models.length; index++) {
52671
+ telemetry.delegationBegin(input.sessionID, input.reviewerAgent, input.trigger);
52625
52672
  const result = await input.dispatcher.dispatch({
52626
52673
  directory: input.directory,
52627
52674
  parentSessionId: input.sessionID,
@@ -52916,6 +52963,7 @@ async function runReviewEngine(input) {
52916
52963
  validationError = validation.error;
52917
52964
  for (const [retryIndex, attempt] of validation.attempts.entries()) {
52918
52965
  allDispatches.push(attempt);
52966
+ telemetry.delegationBegin(input.sessionID, input.validatorAgent, input.trigger);
52919
52967
  telemetry.delegationEnd(input.sessionID, input.validatorAgent, input.trigger, attempt.status, {
52920
52968
  ...attempt.costFields,
52921
52969
  gate: "finding_validation",
@@ -54128,7 +54176,7 @@ async function handleSddCommand(_directory, _args) {
54128
54176
  }
54129
54177
 
54130
54178
  // src/commands/simulate.ts
54131
- import { renameSync as renameSync16, unlinkSync as unlinkSync18 } from "fs";
54179
+ import { renameSync as renameSync15, unlinkSync as unlinkSync19 } from "fs";
54132
54180
  async function handleSimulateCommand(directory, args) {
54133
54181
  const thresholdIndex = args.indexOf("--threshold");
54134
54182
  const minCommitsIndex = args.indexOf("--min-commits");
@@ -54183,10 +54231,10 @@ Ensure this is a git repository with commit history.`;
54183
54231
  const reportTempPath = path91.join(path91.dirname(reportPath), `${path91.basename(reportPath)}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
54184
54232
  try {
54185
54233
  await fs45.writeFile(reportTempPath, report, "utf-8");
54186
- renameSync16(reportTempPath, reportPath);
54234
+ renameSync15(reportTempPath, reportPath);
54187
54235
  } catch (err) {
54188
54236
  try {
54189
- unlinkSync18(reportTempPath);
54237
+ unlinkSync19(reportTempPath);
54190
54238
  } catch {}
54191
54239
  throw err;
54192
54240
  }
@@ -54199,16 +54247,16 @@ Ensure this is a git repository with commit history.`;
54199
54247
 
54200
54248
  // src/commands/skill-opt.ts
54201
54249
  init_schema();
54202
- import { copyFileSync as copyFileSync5, existsSync as existsSync56, mkdirSync as mkdirSync29, readFileSync as readFileSync42 } from "fs";
54250
+ import { copyFileSync as copyFileSync5, existsSync as existsSync57, mkdirSync as mkdirSync29, readFileSync as readFileSync42 } from "fs";
54203
54251
  import * as path97 from "path";
54204
54252
 
54205
54253
  // src/services/skill-optimizer/activation.ts
54206
54254
  import {
54207
- existsSync as existsSync52,
54255
+ existsSync as existsSync53,
54208
54256
  mkdirSync as mkdirSync26,
54209
54257
  readFileSync as readFileSync39,
54210
- renameSync as renameSync18,
54211
- unlinkSync as unlinkSync20,
54258
+ renameSync as renameSync17,
54259
+ unlinkSync as unlinkSync21,
54212
54260
  writeFileSync as writeFileSync17
54213
54261
  } from "fs";
54214
54262
  import * as path92 from "path";
@@ -54217,14 +54265,14 @@ import * as path92 from "path";
54217
54265
  import { createHash as createHash18, randomUUID as randomUUID11 } from "crypto";
54218
54266
  import {
54219
54267
  closeSync as closeSync13,
54220
- existsSync as existsSync51,
54268
+ existsSync as existsSync52,
54221
54269
  fsyncSync as fsyncSync3,
54222
54270
  mkdirSync as mkdirSync25,
54223
54271
  openSync as openSync13,
54224
54272
  readFileSync as readFileSync38,
54225
- renameSync as renameSync17,
54273
+ renameSync as renameSync16,
54226
54274
  statSync as statSync16,
54227
- unlinkSync as unlinkSync19,
54275
+ unlinkSync as unlinkSync20,
54228
54276
  writeFileSync as writeFileSync16,
54229
54277
  writeFileSync as writeFileSyncAsync
54230
54278
  } from "fs";
@@ -54284,7 +54332,7 @@ function stateProjectionPath(directory, skillSlug, candidateId2) {
54284
54332
  }
54285
54333
  function ensureCandidateDir(directory, skillSlug, candidateId2) {
54286
54334
  const dir = candidateDir(directory, skillSlug, candidateId2);
54287
- if (!existsSync51(dir))
54335
+ if (!existsSync52(dir))
54288
54336
  mkdirSync25(dir, { recursive: true });
54289
54337
  return dir;
54290
54338
  }
@@ -54297,10 +54345,10 @@ function writeFileFsyncedThenRename(tempPath, targetPath, data) {
54297
54345
  closeSync13(fd);
54298
54346
  }
54299
54347
  try {
54300
- renameSync17(tempPath, targetPath);
54348
+ renameSync16(tempPath, targetPath);
54301
54349
  } catch (err) {
54302
54350
  try {
54303
- unlinkSync19(tempPath);
54351
+ unlinkSync20(tempPath);
54304
54352
  } catch {}
54305
54353
  throw err;
54306
54354
  }
@@ -54310,9 +54358,9 @@ var _internals79 = {
54310
54358
  writeFileFsyncedThenRename,
54311
54359
  writeFileSync: writeFileSyncAsync,
54312
54360
  readFileSync: readFileSync38,
54313
- renameSync: renameSync17,
54314
- unlinkSync: unlinkSync19,
54315
- existsSync: existsSync51,
54361
+ renameSync: renameSync16,
54362
+ unlinkSync: unlinkSync20,
54363
+ existsSync: existsSync52,
54316
54364
  statSync: statSync16
54317
54365
  };
54318
54366
  async function appendEvent2(directory, eventInput) {
@@ -54326,7 +54374,7 @@ async function appendEvent2(directory, eventInput) {
54326
54374
  const filePath = ledgerPath(directory, eventInput.skillSlug, eventInput.candidateId);
54327
54375
  return _internals79.withEvidenceLock(directory, path91.join(".swarm", "evolution", "skills", eventInput.skillSlug, eventInput.candidateId, "lifecycle.jsonl"), "skill-opt-ledger", "append-skill-opt-event", async () => {
54328
54376
  ensureCandidateDir(directory, eventInput.skillSlug, eventInput.candidateId);
54329
- const existing = existsSync51(filePath) ? readFileSync38(filePath, "utf8") : "";
54377
+ const existing = existsSync52(filePath) ? readFileSync38(filePath, "utf8") : "";
54330
54378
  const events = parseEventsFromText(existing);
54331
54379
  const nextSeq = events.length === 0 ? 1 : events[events.length - 1].seq + 1;
54332
54380
  const lastEvent = events.length === 0 ? null : events[events.length - 1];
@@ -54384,7 +54432,7 @@ function parseEventsFromText(text) {
54384
54432
  }
54385
54433
  function replayCandidate(directory, skillSlug, candidateId2) {
54386
54434
  const filePath = ledgerPath(directory, skillSlug, candidateId2);
54387
- if (!existsSync51(filePath)) {
54435
+ if (!existsSync52(filePath)) {
54388
54436
  return {
54389
54437
  events: [],
54390
54438
  state: null,
@@ -54438,7 +54486,7 @@ function replayCandidate(directory, skillSlug, candidateId2) {
54438
54486
  function quarantineSuffix(directory, skillSlug, badSuffix) {
54439
54487
  assertProjectRoot(directory);
54440
54488
  const dir = path91.join(directory, ".swarm", "evolution", "skills");
54441
- if (!existsSync51(dir))
54489
+ if (!existsSync52(dir))
54442
54490
  mkdirSync25(dir, { recursive: true });
54443
54491
  const hash = computeStateHash(badSuffix).slice(0, 12);
54444
54492
  const stamp = Date.now();
@@ -54474,7 +54522,7 @@ function writeArtifact(directory, skillSlug, candidateId2, fileName, content) {
54474
54522
  }
54475
54523
  function readArtifact(directory, skillSlug, candidateId2, fileName) {
54476
54524
  const target = path91.join(candidateDir(directory, skillSlug, candidateId2), fileName);
54477
- if (!existsSync51(target))
54525
+ if (!existsSync52(target))
54478
54526
  return null;
54479
54527
  return readFileSync38(target, "utf8");
54480
54528
  }
@@ -54566,19 +54614,19 @@ function writeSkillFileAtomic(targetPath, content) {
54566
54614
  _internals80.renameSync(tempPath, targetPath);
54567
54615
  } finally {
54568
54616
  try {
54569
- if (existsSync52(tempPath))
54617
+ if (existsSync53(tempPath))
54570
54618
  _internals80.unlinkSync(tempPath);
54571
54619
  } catch {}
54572
54620
  }
54573
54621
  }
54574
54622
  var _internals80 = {
54575
54623
  writeFileSync: writeFileSync17,
54576
- renameSync: renameSync18,
54577
- unlinkSync: unlinkSync20
54624
+ renameSync: renameSync17,
54625
+ unlinkSync: unlinkSync21
54578
54626
  };
54579
54627
  async function activateCandidate(input) {
54580
54628
  const skillPath = path92.join(input.directory, ".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
54581
- const incumbent = existsSync52(skillPath) ? readFileSync39(skillPath, "utf8") : "";
54629
+ const incumbent = existsSync53(skillPath) ? readFileSync39(skillPath, "utf8") : "";
54582
54630
  const currentHash = computeContentHash2(incumbent);
54583
54631
  if (currentHash !== input.expectedContentHash) {
54584
54632
  return {
@@ -54605,7 +54653,7 @@ async function activateCandidate(input) {
54605
54653
  }
54606
54654
  const rollbackSnapshotRef = writeArtifact(input.directory, input.skillSlug, input.candidateId, "rollback.md", incumbent);
54607
54655
  const skillRoot = path92.dirname(skillPath);
54608
- if (!existsSync52(skillRoot))
54656
+ if (!existsSync53(skillRoot))
54609
54657
  mkdirSync26(skillRoot, { recursive: true });
54610
54658
  writeSkillFileAtomic(skillPath, candidateContent);
54611
54659
  await recordTransition({
@@ -54644,7 +54692,7 @@ async function rollbackCandidate(input) {
54644
54692
  };
54645
54693
  }
54646
54694
  const skillPath = path92.join(input.directory, ".opencode", "skills", "generated", input.skillSlug, "SKILL.md");
54647
- const beforeContent = existsSync52(skillPath) ? readFileSync39(skillPath, "utf8") : "";
54695
+ const beforeContent = existsSync53(skillPath) ? readFileSync39(skillPath, "utf8") : "";
54648
54696
  writeSkillFileAtomic(skillPath, snapshot);
54649
54697
  await recordTransition({
54650
54698
  directory: input.directory,
@@ -54663,7 +54711,7 @@ async function rollbackCandidate(input) {
54663
54711
 
54664
54712
  // src/services/skill-optimizer/controller.ts
54665
54713
  import { randomUUID as randomUUID12 } from "crypto";
54666
- import { existsSync as existsSync54, mkdirSync as mkdirSync27, readFileSync as readFileSync41, writeFileSync as writeFileSync18 } from "fs";
54714
+ import { existsSync as existsSync55, mkdirSync as mkdirSync27, readFileSync as readFileSync41, writeFileSync as writeFileSync18 } from "fs";
54667
54715
  import * as path95 from "path";
54668
54716
 
54669
54717
  // src/evaluation/pr-review-recovery.ts
@@ -55135,7 +55183,7 @@ async function deterministicSeed(input) {
55135
55183
  }
55136
55184
 
55137
55185
  // src/services/skill-optimizer/smoke.ts
55138
- import { existsSync as existsSync53, lstatSync as lstatSync9, readFileSync as readFileSync40, realpathSync as realpathSync13 } from "fs";
55186
+ import { existsSync as existsSync54, lstatSync as lstatSync9, readFileSync as readFileSync40, realpathSync as realpathSync13 } from "fs";
55139
55187
  import * as path94 from "path";
55140
55188
 
55141
55189
  // src/hooks/spawn-helper.ts
@@ -55244,7 +55292,7 @@ async function validateSkillSmoke(input) {
55244
55292
  };
55245
55293
  }
55246
55294
  const skillRoot = path94.join(input.directory, ".opencode", "skills", "generated", input.skillSlug);
55247
- if (existsSync53(skillRoot)) {
55295
+ if (existsSync54(skillRoot)) {
55248
55296
  if (_internals83.isSymbolicLink(skillRoot)) {
55249
55297
  return {
55250
55298
  ok: false,
@@ -55330,7 +55378,7 @@ function checkFrontmatter(content) {
55330
55378
  }
55331
55379
  function readIncumbentContent(directory, skillSlug) {
55332
55380
  const incumbent = path94.join(directory, ".opencode", "skills", "generated", skillSlug, "SKILL.md");
55333
- if (!existsSync53(incumbent))
55381
+ if (!existsSync54(incumbent))
55334
55382
  return "";
55335
55383
  try {
55336
55384
  return readFileSync40(incumbent, "utf8");
@@ -55344,7 +55392,7 @@ var PROJECT_LOCK_PATH = path95.join(".swarm", "evolution", "skills", ".run.lock"
55344
55392
  var CONVERGENCE_FILE = path95.join(".swarm", "evolution", "skills", ".convergence.json");
55345
55393
  async function prepareCandidatePayloads(inputRoot, candidateId2, skillSlug, baselineModel, candidateModel, baselineContent, candidateContent) {
55346
55394
  const payloadSubdir = path95.join(inputRoot, "candidates", candidateId2);
55347
- if (!existsSync54(payloadSubdir))
55395
+ if (!existsSync55(payloadSubdir))
55348
55396
  mkdirSync27(payloadSubdir, { recursive: true });
55349
55397
  const baselinePayloadRel = path95.join("candidates", candidateId2, "baseline.md");
55350
55398
  const candidatePayloadRel = path95.join("candidates", candidateId2, "candidate.md");
@@ -55670,7 +55718,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
55670
55718
  }
55671
55719
  function readConvergenceState(directory) {
55672
55720
  const file = path95.join(directory, CONVERGENCE_FILE);
55673
- if (!existsSync54(file))
55721
+ if (!existsSync55(file))
55674
55722
  return { nonImprovements: 0 };
55675
55723
  try {
55676
55724
  return JSON.parse(readFileSync41(file, "utf8"));
@@ -55681,7 +55729,7 @@ function readConvergenceState(directory) {
55681
55729
  function writeConvergenceState(directory, nonImprovements) {
55682
55730
  assertProjectRoot(directory);
55683
55731
  const dir = path95.dirname(path95.join(directory, CONVERGENCE_FILE));
55684
- if (!existsSync54(dir))
55732
+ if (!existsSync55(dir))
55685
55733
  mkdirSync27(dir, { recursive: true });
55686
55734
  writeFileSync18(path95.join(directory, CONVERGENCE_FILE), JSON.stringify({ nonImprovements }), "utf8");
55687
55735
  }
@@ -55738,7 +55786,7 @@ async function runOptimizationLoop(input) {
55738
55786
  }
55739
55787
 
55740
55788
  // src/services/skill-optimizer/skill-eval-tasks.ts
55741
- import { existsSync as existsSync55, mkdirSync as mkdirSync28, writeFileSync as writeFileSync19 } from "fs";
55789
+ import { existsSync as existsSync56, mkdirSync as mkdirSync28, writeFileSync as writeFileSync19 } from "fs";
55742
55790
  import * as path96 from "path";
55743
55791
  var DEFAULT_SKILL_EVAL_TASKS = [
55744
55792
  {
@@ -55780,7 +55828,7 @@ function buildSkillEvalTasks(args) {
55780
55828
  const result = [];
55781
55829
  for (const spec of tasks) {
55782
55830
  const taskDir = path96.join(args.inputRoot, "skill-eval", spec.id);
55783
- if (!existsSync55(taskDir))
55831
+ if (!existsSync56(taskDir))
55784
55832
  mkdirSync28(taskDir, { recursive: true });
55785
55833
  const instructionPath = path96.join("skill-eval", spec.id, "instruction.md");
55786
55834
  writeFileSync19(path96.join(args.inputRoot, instructionPath), `${spec.instruction}
@@ -55879,7 +55927,7 @@ ${JSON.stringify(result, null, 2)}
55879
55927
  function readSkillOptConfigFromProject(directory) {
55880
55928
  try {
55881
55929
  const cfgPath = path97.join(directory, "opencode.json");
55882
- if (!existsSync56(cfgPath))
55930
+ if (!existsSync57(cfgPath))
55883
55931
  return { ...DEFAULT_SKILL_OPT_CONFIG };
55884
55932
  const raw = JSON.parse(readFileSync42(cfgPath, "utf8"));
55885
55933
  const block = raw?.skill_opt ?? raw?.swarm?.skill_opt;
@@ -55929,14 +55977,14 @@ async function handleSkillOptRun(directory, args, runtime = {}) {
55929
55977
  }
55930
55978
  const models = parsed.models.length > 0 ? parsed.models : ["default"];
55931
55979
  const inputRoot = path97.join(directory, ".swarm", "evolution", "skills", "_eval-input");
55932
- if (!existsSync56(inputRoot))
55980
+ if (!existsSync57(inputRoot))
55933
55981
  mkdirSync29(inputRoot, { recursive: true });
55934
55982
  const scorerDir = path97.join(inputRoot, "scoring");
55935
- if (!existsSync56(scorerDir))
55983
+ if (!existsSync57(scorerDir))
55936
55984
  mkdirSync29(scorerDir, { recursive: true });
55937
55985
  const scorerSource = path97.join(directory, "evaluation-fixtures", "skill-eval", "scoring", "score-skill-eval.cjs");
55938
55986
  const scorerDest = path97.join(scorerDir, "score-skill-eval.cjs");
55939
- if (existsSync56(scorerSource)) {
55987
+ if (existsSync57(scorerSource)) {
55940
55988
  copyFileSync5(scorerSource, scorerDest);
55941
55989
  }
55942
55990
  const scorerRelPath = path97.join("scoring", "score-skill-eval.cjs");
@@ -57426,7 +57474,7 @@ function buildDetailedHelp(commandName, entry) {
57426
57474
  async function handleHelpCommand(ctx) {
57427
57475
  const targetCommand = ctx.args.join(" ");
57428
57476
  if (!targetCommand) {
57429
- const { buildHelpText } = await import("./index-h5fmwg5b.js");
57477
+ const { buildHelpText } = await import("./index-mewk624g.js");
57430
57478
  return buildHelpText();
57431
57479
  }
57432
57480
  const tokens = targetCommand.split(/\s+/);
@@ -57435,7 +57483,7 @@ async function handleHelpCommand(ctx) {
57435
57483
  return _internals87.buildDetailedHelp(resolved.key, resolved.entry);
57436
57484
  }
57437
57485
  const similar = _internals87.findSimilarCommands(targetCommand);
57438
- const { buildHelpText: fullHelp } = await import("./index-h5fmwg5b.js");
57486
+ const { buildHelpText: fullHelp } = await import("./index-mewk624g.js");
57439
57487
  if (similar.length > 0) {
57440
57488
  return `Command '/swarm ${targetCommand}' not found.
57441
57489
 
@@ -57612,7 +57660,7 @@ var COMMAND_REGISTRY = {
57612
57660
  },
57613
57661
  "guardrail explain": {
57614
57662
  handler: async (ctx) => {
57615
- const { handleGuardrailExplain } = await import("./guardrail-explain-9vdjkz5x.js");
57663
+ const { handleGuardrailExplain } = await import("./guardrail-explain-tsgsw91f.js");
57616
57664
  return handleGuardrailExplain(ctx.directory, ctx.args);
57617
57665
  },
57618
57666
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -57622,7 +57670,7 @@ var COMMAND_REGISTRY = {
57622
57670
  },
57623
57671
  "guardrail-explain": {
57624
57672
  handler: async (ctx) => {
57625
- const { handleGuardrailExplain } = await import("./guardrail-explain-9vdjkz5x.js");
57673
+ const { handleGuardrailExplain } = await import("./guardrail-explain-tsgsw91f.js");
57626
57674
  return handleGuardrailExplain(ctx.directory, ctx.args);
57627
57675
  },
57628
57676
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -57632,7 +57680,7 @@ var COMMAND_REGISTRY = {
57632
57680
  },
57633
57681
  "guardrail-log": {
57634
57682
  handler: async (ctx) => {
57635
- const { handleGuardrailLog } = await import("./guardrail-log-xr0cv07v.js");
57683
+ const { handleGuardrailLog } = await import("./guardrail-log-70cxb3va.js");
57636
57684
  return handleGuardrailLog(ctx.directory, ctx.args);
57637
57685
  },
57638
57686
  description: "Read the guardrail decision log (use --blocks-only for blocks)",
@@ -57928,7 +57976,7 @@ var COMMAND_REGISTRY = {
57928
57976
  sessionID: ctx.sessionID
57929
57977
  }),
57930
57978
  description: "Use /swarm finalize to finalize the swarm project and archive evidence",
57931
- details: "Idempotent 4-stage terminal finalization: (1) finalize writes retrospectives for in-progress phases, (2) archive creates timestamped bundle of swarm artifacts and evidence, (3) clean removes active-state files for a clean slate, (4) align performs aggressive git reset --hard to the default remote branch, discarding uncommitted changes and gitignored build artifacts (user-created untracked files are preserved); falls back to a cautious reset that preserves uncommitted changes when the aggressive path cannot proceed. WARNING: alignment discards local changes and gitignored files. Resets agent sessions and delegation chains. Reads .swarm/close-lessons.md for explicit lessons and runs curation. Use --skill-review to run the quota-bounded skill_improver in proposal mode. Use --dry-run to preview what finalize would archive, clean, and align without taking the lock or changing anything.",
57979
+ details: "Idempotent 4-stage terminal finalization: (1) finalize writes retrospectives for in-progress phases, (2) archive creates timestamped bundle of swarm artifacts and evidence, (3) clean removes active-state files for a clean slate, (4) align performs aggressive git reset --hard to the default remote branch, discarding uncommitted changes and gitignored build artifacts (user-created untracked files are preserved); falls back to a cautious reset that preserves uncommitted changes when the aggressive path cannot proceed. WARNING: alignment discards local changes and gitignored files. Resets agent sessions, delegation chains, and active-agent mappings. Reads .swarm/close-lessons.md for explicit lessons and runs curation. Use --skill-review to run the quota-bounded skill_improver in proposal mode. Use --dry-run to preview what finalize would archive, clean, and align without taking the lock or changing anything.",
57932
57980
  args: "--prune-branches, --skill-review, --dry-run",
57933
57981
  category: "core",
57934
57982
  toolPolicy: "none"
@@ -58284,7 +58332,7 @@ Subcommands:
58284
58332
  "reset-session": {
58285
58333
  handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args),
58286
58334
  description: "Clear session state while preserving plan, evidence, and knowledge",
58287
- details: "Deletes only .swarm/session/state.json and any other session files. Clears in-memory agent sessions and delegation chains. Preserves plan, evidence, and knowledge for cross-session continuity. Before deleting, auto-backs up the session files it removes to .swarm/reset-backups/<timestamp>/ (newest 5 kept).",
58335
+ details: "Deletes only .swarm/session/state.json and any other session files. Clears in-memory agent sessions, delegation chains, and active-agent mappings. Preserves plan, evidence, and knowledge for cross-session continuity. Before deleting, auto-backs up the session files it removes to .swarm/reset-backups/<timestamp>/ (newest 5 kept).",
58288
58336
  args: "",
58289
58337
  category: "utility",
58290
58338
  toolPolicy: "restricted"
@@ -59326,6 +59374,13 @@ Every loaded mode skill is written with active-swarm role phrases. Before follow
59326
59374
 
59327
59375
  Do not delegate to the literal natural-language phrase. Delegate only to the concrete rendered agent name for the active swarm.
59328
59376
 
59377
+ ### SKILL LOADING (self-load protocol for MODE actions)
59378
+ When a MODE section says "ACTION: Load skill file:<path>", load the skill yourself using the search tool:
59379
+ - Strip the \`file:\` prefix to get the repo-relative path.
59380
+ - Call the search tool with \`include\` set to that exact repo-relative path, \`mode: regex\`, \`query: .*\`, \`max_results: 10000\`, and \`max_lines: 10000\`.
59381
+ - If \`total === 0\` (file does not exist or is empty) OR \`truncated\` is \`true\` (the file exceeded even \`max_results: 10000\`), report \`SKILL_LOAD_FAILED: <path>\`, stop, and ask the user how to proceed. Do NOT continue without the complete skill and do NOT substitute a partial or improvised protocol.
59382
+ - If the search result has \`total > 0\` and \`truncated\` is \`false\`, reconstruct the full skill content from the line-by-line matches and follow the loaded protocol.
59383
+
59329
59384
  ### MODE: BRAINSTORM
59330
59385
  Activates when: user invokes /swarm brainstorm, uses brainstorm-style phrasing, or the problem is exploratory and requirements need structured dialogue.
59331
59386
 
@@ -60863,7 +60918,7 @@ ACCEPTANCE HANDLING: ACCEPTANCE is the authoritative definition of "done" for th
60863
60918
 
60864
60919
  SKILLS HANDLING: If SKILLS is present and not "none", read the skill names/descriptions first, then load every referenced skill that applies before beginning your review. If uncertain whether a skill applies, load it.
60865
60920
  - A file entry may include a short description after the path; use the description to decide whether the full skill body is relevant.
60866
- - For \`file:\` entries, use the search tool to read the referenced \`SKILL.md\` file with \`include\` set to that exact repo-relative path, \`mode: regex\`, \`query: .*\`, \`max_results: 1000\`, and \`max_lines: 1000\`.
60921
+ - For \`file:\` entries, use the search tool to read the referenced \`SKILL.md\` file with \`include\` set to that exact repo-relative path, \`mode: regex\`, \`query: .*\`, \`max_results: 10000\`, and \`max_lines: 10000\`.
60867
60922
  - After running search, inspect the result: if \`total === 0\` (file does not exist or is empty) OR \`truncated\` is \`true\` (file was too large and content was cut off), stop and report \`SKILL_LOAD_FAILED: <path>\`. Do NOT continue without the complete skill.
60868
60923
  - If the search result has \`total > 0\` and \`truncated\` is \`false\`, reconstruct the full skill content from the line-by-line matches and apply it.
60869
60924
  - If inline \`--- skill-name ---\` sections are present, read them directly.
@@ -61006,7 +61061,7 @@ SKILLS: [optional \u2014 either "none", repo-relative file: references (preferre
61006
61061
 
61007
61062
  SKILLS HANDLING: If SKILLS is present and not "none", read the skill names/descriptions first, then load every referenced skill that applies before formulating your recommendation. If uncertain whether a skill applies, load it.
61008
61063
  - A file entry may include a short description after the path; use the description to decide whether the full skill body is relevant.
61009
- - For \`file:\` entries, use the search tool to read the referenced \`SKILL.md\` file with \`include\` set to that exact repo-relative path, \`mode: regex\`, \`query: .*\`, \`max_results: 1000\`, and \`max_lines: 1000\`.
61064
+ - For \`file:\` entries, use the search tool to read the referenced \`SKILL.md\` file with \`include\` set to that exact repo-relative path, \`mode: regex\`, \`query: .*\`, \`max_results: 10000\`, and \`max_lines: 10000\`.
61010
61065
  - After running search, inspect the result: if \`total === 0\` (file does not exist or is empty) OR \`truncated\` is \`true\` (file was too large and content was cut off), stop and report \`SKILL_LOAD_FAILED: <path>\`. Do NOT continue without the complete skill.
61011
61066
  - If the search result has \`total > 0\` and \`truncated\` is \`false\`, reconstruct the full skill content from the line-by-line matches and apply it.
61012
61067
  - If inline \`--- skill-name ---\` sections are present, read them directly.
@@ -63754,6 +63809,7 @@ function sweepStaleSessions(staleDurationMs = STALE_SESSION_TTL_MS, now2 = Date.
63754
63809
  for (const id of staleIds) {
63755
63810
  swarmState.agentSessions.delete(id);
63756
63811
  swarmState.delegationChains.delete(id);
63812
+ swarmState.activeAgent.delete(id);
63757
63813
  }
63758
63814
  return staleIds;
63759
63815
  }
@@ -63879,6 +63935,8 @@ function endAgentSession(sessionId) {
63879
63935
  });
63880
63936
  }
63881
63937
  swarmState.agentSessions.delete(sessionId);
63938
+ swarmState.activeAgent.delete(sessionId);
63939
+ swarmState.delegationChains.delete(sessionId);
63882
63940
  clearRealtimeLearningNudgeSession(sessionId);
63883
63941
  resetSessionQueue(sessionId);
63884
63942
  resetPrmPatternSupport(sessionId);
@@ -64142,7 +64200,6 @@ function beginInvocation(sessionId, agentName) {
64142
64200
  const key = `${stripped}:${newId}`;
64143
64201
  session.windows[key] = window;
64144
64202
  pruneOldWindows(sessionId, 24 * 60 * 60 * 1000, 50);
64145
- telemetry.delegationBegin(sessionId, stripped, session.currentTaskId ?? "unknown");
64146
64203
  return window;
64147
64204
  }
64148
64205
  function getActiveWindow(sessionId) {
@@ -64983,7 +65040,7 @@ async function precreateStandardWorktreeSession(args) {
64983
65040
  const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, provisionResult.worktreePath);
64984
65041
  if (laneProfile) {
64985
65042
  try {
64986
- const { writeLaneProfileToDiskReal } = await import("./core-vpefadja.js");
65043
+ const { writeLaneProfileToDiskReal } = await import("./core-a6rzajem.js");
64987
65044
  await writeLaneProfileToDiskReal(provisionResult.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
64988
65045
  } catch {}
64989
65046
  }
@@ -65482,7 +65539,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
65482
65539
  }
65483
65540
  clearWorktreeMergeStatus(statusKey);
65484
65541
  try {
65485
- const { removeLaneProfileFromDiskReal } = await import("./core-vpefadja.js");
65542
+ const { removeLaneProfileFromDiskReal } = await import("./core-a6rzajem.js");
65486
65543
  await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
65487
65544
  } catch {}
65488
65545
  const state = serializationStateBySessionID.get(dispatch.parentSessionID);