opencode-swarm 7.154.2 → 7.155.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.
Files changed (79) hide show
  1. package/dist/cli/{coder-settlement-xqs49g07.js → coder-settlement-2kdtysrg.js} +7 -7
  2. package/dist/cli/{config-doctor-69eebk90.js → config-doctor-s6p9aqfv.js} +2 -2
  3. package/dist/cli/{core-dyp14hcb.js → core-ev2ebc4v.js} +1 -1
  4. package/dist/cli/{curation-policy-jm9jsxtt.js → curation-policy-jabphe51.js} +4 -4
  5. package/dist/cli/{curator-he8n9z9n.js → curator-adp0dsv4.js} +28 -28
  6. package/dist/cli/{curator-drift-h57z6tm3.js → curator-drift-g6w4ga1q.js} +1 -1
  7. package/dist/cli/{curator-llm-factory-5tq9c4v5.js → curator-llm-factory-kd8v16jj.js} +28 -28
  8. package/dist/cli/{evidence-summary-service-05s5y8d6.js → evidence-summary-service-kpjpd86j.js} +10 -10
  9. package/dist/cli/{gate-evidence-3ptr9af3.js → gate-evidence-etbcms2v.js} +5 -5
  10. package/dist/cli/{guardrail-explain-tebk344k.js → guardrail-explain-wqb5h7kk.js} +29 -29
  11. package/dist/cli/{guardrail-log-x3gz3x17.js → guardrail-log-614g1pta.js} +3 -3
  12. package/dist/cli/{guardrail-reset-716pdyf5.js → guardrail-reset-0wdj53cp.js} +28 -28
  13. package/dist/cli/{hive-promoter-nvwpj2t9.js → hive-promoter-b1wv52fs.js} +28 -28
  14. package/dist/cli/{index-4xqa0sgz.js → index-0q8kywcf.js} +2 -2
  15. package/dist/cli/{index-8v69hfpt.js → index-26cvxrym.js} +3 -3
  16. package/dist/cli/{index-bxvkn0ye.js → index-2gfe61qp.js} +345 -221
  17. package/dist/cli/{index-57t97rtr.js → index-34wn2ztk.js} +5 -2
  18. package/dist/cli/{index-kemxyzc0.js → index-6bqqzfbe.js} +2 -2
  19. package/dist/cli/{index-dm9tc6qb.js → index-79qymsxf.js} +1 -1
  20. package/dist/cli/{index-r0dactw2.js → index-85p1850w.js} +1 -1
  21. package/dist/cli/{index-14bz2t7b.js → index-aqg7c1z9.js} +1 -1
  22. package/dist/cli/{index-xq2v52tt.js → index-c590qxts.js} +1 -1
  23. package/dist/cli/{index-fv9ddfta.js → index-c9nabqzd.js} +1 -1
  24. package/dist/cli/{index-nh4axsxc.js → index-caqe8x14.js} +2 -2
  25. package/dist/cli/{index-n0gqre56.js → index-ctsct3hy.js} +6 -6
  26. package/dist/cli/{index-4cgee5vh.js → index-dtn0pne5.js} +20 -1
  27. package/dist/cli/{index-ynvw5kxc.js → index-dw2q720x.js} +2 -2
  28. package/dist/cli/{index-xt6jx41g.js → index-e90g4dsw.js} +4 -4
  29. package/dist/cli/{index-9avdncr2.js → index-egnpzfe3.js} +5 -5
  30. package/dist/cli/{index-j6q3k628.js → index-ew6fykvv.js} +1 -1
  31. package/dist/cli/{index-6rns7b2m.js → index-fjcm6wwf.js} +2 -2
  32. package/dist/cli/{index-mnxtkt8s.js → index-ketfp4rv.js} +3 -3
  33. package/dist/cli/{index-f6qmar4k.js → index-kgdbtwfm.js} +5 -5
  34. package/dist/cli/{index-399e8aze.js → index-kyc2c7hq.js} +1 -1
  35. package/dist/cli/{index-07n87ctw.js → index-mm7ase9k.js} +1 -1
  36. package/dist/cli/{index-p7ey2w90.js → index-qj9jrjvr.js} +6 -6
  37. package/dist/cli/{index-v2ryvr8k.js → index-qzqpq75z.js} +30 -30
  38. package/dist/cli/{index-v9585wjc.js → index-rb4t72we.js} +2 -2
  39. package/dist/cli/{index-2w6vy9a9.js → index-spbxf9vn.js} +1 -1
  40. package/dist/cli/{index-6qwp46k0.js → index-t3xqpece.js} +3 -3
  41. package/dist/cli/{index-pj2nycpg.js → index-veajr5x7.js} +1 -1
  42. package/dist/cli/{index-vhhdj49x.js → index-wwv3cbv1.js} +8 -9
  43. package/dist/cli/{index-7tw116n6.js → index-x9tbe9v7.js} +2 -2
  44. package/dist/cli/{index-6rcx6vr6.js → index-xn23xnnk.js} +4 -4
  45. package/dist/cli/{index-dsqat5pg.js → index-zvp68qx6.js} +1 -1
  46. package/dist/cli/index.js +28 -28
  47. package/dist/cli/{knowledge-escalator-s0tye368.js → knowledge-escalator-z09aqvfe.js} +10 -10
  48. package/dist/cli/{knowledge-events-eyy9yf6b.js → knowledge-events-03f1rwm8.js} +8 -8
  49. package/dist/cli/{knowledge-link-rb11f06y.js → knowledge-link-4frk38w8.js} +3 -3
  50. package/dist/cli/{knowledge-store-zjq5mz2d.js → knowledge-store-sn28k13f.js} +4 -4
  51. package/dist/cli/{knowledge-validator-yw5qqqpd.js → knowledge-validator-rwrt3yja.js} +6 -6
  52. package/dist/cli/{pending-delegations-rdzjq3nw.js → pending-delegations-qe16vfrj.js} +2 -2
  53. package/dist/cli/{pr-subscriptions-2f5fne6z.js → pr-subscriptions-00evnffe.js} +3 -3
  54. package/dist/cli/{runner-yaqrj388.js → runner-k1rkbjm8.js} +4 -4
  55. package/dist/cli/{scan-cursor-8f0s883y.js → scan-cursor-h3mfzjc9.js} +5 -5
  56. package/dist/cli/{schema-2xw94dh3.js → schema-c37h5xw4.js} +1 -1
  57. package/dist/cli/{scope-persistence-tap2q94x.js → scope-persistence-35z42pj5.js} +5 -5
  58. package/dist/cli/{skill-generator-2xbfryqb.js → skill-generator-60px2mvb.js} +12 -12
  59. package/dist/cli/{worktree-collision-ownership-5gwey8ms.js → worktree-collision-ownership-2pc20ypq.js} +4 -4
  60. package/dist/cli/{worktree-isolation-xsy14t5a.js → worktree-isolation-w4yamc3b.js} +28 -28
  61. package/dist/commands/close.d.ts +2 -0
  62. package/dist/config/schema.d.ts +8 -0
  63. package/dist/hooks/final-context-accounting.d.ts +60 -0
  64. package/dist/hooks/index.d.ts +1 -0
  65. package/dist/hooks/knowledge-injector.d.ts +1 -1
  66. package/dist/hooks/repo-graph-injection.d.ts +40 -0
  67. package/dist/hooks/system-enhancer.d.ts +13 -0
  68. package/dist/hooks/utils.d.ts +11 -0
  69. package/dist/index.js +414 -389
  70. package/dist/memory/reflection-service.d.ts +8 -2
  71. package/dist/memory/schema.d.ts +4 -4
  72. package/dist/services/compaction-service.d.ts +9 -3
  73. package/dist/services/context-budget-service.d.ts +7 -3
  74. package/dist/services/injection-budget.d.ts +103 -26
  75. package/dist/state.d.ts +69 -0
  76. package/dist/summaries/summarizer.d.ts +34 -3
  77. package/dist/tools/repo-graph/indexed-storage.d.ts +136 -0
  78. package/dist/tools/repo-graph/query.d.ts +7 -0
  79. package/package.json +3 -1
@@ -6,7 +6,7 @@ import {
6
6
  resolveExecutableFromPath,
7
7
  runEvaluation,
8
8
  runExternalTool
9
- } from "./index-399e8aze.js";
9
+ } from "./index-kyc2c7hq.js";
10
10
  import {
11
11
  finalizeShellAuditForClose,
12
12
  isPolicyProtectedPath,
@@ -14,13 +14,13 @@ import {
14
14
  protectedRoots,
15
15
  redactDecisionLineForArchive,
16
16
  stableCanonicalStringify
17
- } from "./index-xq2v52tt.js";
17
+ } from "./index-c590qxts.js";
18
18
  import {
19
19
  detectStraySwarmDirs,
20
20
  readDoctorArtifact,
21
21
  removeStraySwarmDir,
22
22
  runConfigDoctor
23
- } from "./index-07n87ctw.js";
23
+ } from "./index-mm7ase9k.js";
24
24
  import {
25
25
  MAX_TRANSIENT_RETRIES,
26
26
  archiveEvidence,
@@ -67,7 +67,7 @@ import {
67
67
  validateProjectRoot,
68
68
  validateSymlinkBoundary,
69
69
  validateTargetWithinRoot
70
- } from "./index-vhhdj49x.js";
70
+ } from "./index-wwv3cbv1.js";
71
71
  import {
72
72
  EvaluationTaskV1Schema,
73
73
  GateAuditManifestV1Schema,
@@ -84,7 +84,7 @@ import {
84
84
  saveGateAuditResult,
85
85
  savePromotionDecision,
86
86
  saveTaskSetSnapshot
87
- } from "./index-fv9ddfta.js";
87
+ } from "./index-c9nabqzd.js";
88
88
  import {
89
89
  loadDatabaseCtor
90
90
  } from "./index-134d35c1.js";
@@ -110,12 +110,12 @@ import {
110
110
  } from "./index-y8552snf.js";
111
111
  import {
112
112
  readRecentEscalations
113
- } from "./index-f6qmar4k.js";
113
+ } from "./index-kgdbtwfm.js";
114
114
  import {
115
115
  alreadyCuratedThisGeneration,
116
116
  claimNextScanBatch,
117
117
  resolveCohortId
118
- } from "./index-v9585wjc.js";
118
+ } from "./index-rb4t72we.js";
119
119
  import {
120
120
  CURATOR_INIT_PROMPT,
121
121
  CURATOR_PHASE_PROMPT,
@@ -139,7 +139,7 @@ import {
139
139
  listActive,
140
140
  subscribe,
141
141
  unsubscribe
142
- } from "./index-6rns7b2m.js";
142
+ } from "./index-fjcm6wwf.js";
143
143
  import {
144
144
  clearWorktreeMergeStatus,
145
145
  getAllWorktreeMergeFailures,
@@ -151,12 +151,12 @@ import {
151
151
  listCoderSettlementWalStates,
152
152
  recoverCoderSettlement,
153
153
  recoverStaleCoderSettlements
154
- } from "./index-9avdncr2.js";
154
+ } from "./index-egnpzfe3.js";
155
155
  import {
156
156
  WORKTREE_LIFECYCLE_LOCK_FILE,
157
157
  recordWorktreeProvisioningOwner,
158
158
  removeWorktreeProvisioningOwner
159
- } from "./index-4xqa0sgz.js";
159
+ } from "./index-0q8kywcf.js";
160
160
  import {
161
161
  BUNDLED_PROJECT_SKILL_ROOT,
162
162
  DEFAULT_SKILL_MIN_CONFIDENCE,
@@ -177,7 +177,7 @@ import {
177
177
  retireSkill,
178
178
  selectCandidateEntries,
179
179
  syncBundledProjectSkillsIfMissingAsync
180
- } from "./index-6rcx6vr6.js";
180
+ } from "./index-xn23xnnk.js";
181
181
  import {
182
182
  appendUnactionable,
183
183
  quarantineEntry,
@@ -188,11 +188,11 @@ import {
188
188
  validateActionableFields,
189
189
  validateLesson,
190
190
  validateSkillPath
191
- } from "./index-xt6jx41g.js";
191
+ } from "./index-e90g4dsw.js";
192
192
  import {
193
193
  authorizeCuration,
194
194
  buildConfigFingerprintInput
195
- } from "./index-14bz2t7b.js";
195
+ } from "./index-aqg7c1z9.js";
196
196
  import {
197
197
  cohortConfigFingerprint
198
198
  } from "./index-rtry5xyf.js";
@@ -223,12 +223,12 @@ import {
223
223
  transitionTaskWorkflowEvidence,
224
224
  withTaskEvidenceTransaction,
225
225
  writeWorkflowWalFile
226
- } from "./index-8v69hfpt.js";
226
+ } from "./index-26cvxrym.js";
227
227
  import {
228
228
  makeWorktreeBranchName,
229
229
  provisionWorktree,
230
230
  removeWorktree
231
- } from "./index-2w6vy9a9.js";
231
+ } from "./index-spbxf9vn.js";
232
232
  import {
233
233
  DEFAULT_STALE_DELEGATION_TIMEOUT_MS,
234
234
  DELEGATION_COMPACTION_HIGH_WATER_BYTES,
@@ -243,7 +243,7 @@ import {
243
243
  scanBackgroundCoderReservationsForAdmission,
244
244
  scanDelegationsForRecovery,
245
245
  sweepStaleDelegations
246
- } from "./index-nh4axsxc.js";
246
+ } from "./index-caqe8x14.js";
247
247
  import {
248
248
  compositeSessionKey,
249
249
  sessionKeySuffix
@@ -279,7 +279,7 @@ import {
279
279
  clearAllScopes,
280
280
  clearScopeBindingFromDisk,
281
281
  clearScopeBindings
282
- } from "./index-6qwp46k0.js";
282
+ } from "./index-t3xqpece.js";
283
283
  import {
284
284
  appendLedgerEvent,
285
285
  computePlanHash,
@@ -294,7 +294,7 @@ import {
294
294
  readPlanEpochIdentity,
295
295
  replayFromLedgerWithStatus,
296
296
  takeSnapshotEvent
297
- } from "./index-dsqat5pg.js";
297
+ } from "./index-zvp68qx6.js";
298
298
  import {
299
299
  CORE_EVENT_LOCKED,
300
300
  appendCoreEventSync,
@@ -353,7 +353,7 @@ import {
353
353
  transactFile,
354
354
  transactKnowledge,
355
355
  wordBigrams
356
- } from "./index-n0gqre56.js";
356
+ } from "./index-ctsct3hy.js";
357
357
  import {
358
358
  MAX_EVENT_LOG_ENTRIES,
359
359
  _internals as _internals2,
@@ -369,18 +369,19 @@ import {
369
369
  recordKnowledgeEvent,
370
370
  recordPhaseCloseIntent,
371
371
  resolveKnowledgeEventsPath
372
- } from "./index-p7ey2w90.js";
372
+ } from "./index-qj9jrjvr.js";
373
373
  import {
374
374
  resolveWorktreeIsolationConfig
375
- } from "./index-ynvw5kxc.js";
375
+ } from "./index-dw2q720x.js";
376
376
  import {
377
377
  RetrospectiveEvidenceSchema
378
378
  } from "./index-gprxjmm7.js";
379
379
  import {
380
+ estimateTokens,
380
381
  readSwarmFileAsync,
381
382
  safeHook,
382
383
  validateSwarmPath
383
- } from "./index-4cgee5vh.js";
384
+ } from "./index-dtn0pne5.js";
384
385
  import {
385
386
  bunSpawn,
386
387
  bunSpawnSync,
@@ -394,7 +395,7 @@ import {
394
395
  init_loader,
395
396
  loadPluginConfig,
396
397
  loadPluginConfigWithMeta
397
- } from "./index-dm9tc6qb.js";
398
+ } from "./index-79qymsxf.js";
398
399
  import {
399
400
  DEFAULT_PR_REVIEW_RESILIENCE_CONFIG,
400
401
  DEFAULT_SKILL_OPT_CONFIG,
@@ -409,7 +410,7 @@ import {
409
410
  package_default,
410
411
  resolveAutoReviewConfig,
411
412
  stripKnownSwarmPrefix
412
- } from "./index-57t97rtr.js";
413
+ } from "./index-34wn2ztk.js";
413
414
  import {
414
415
  AGENT_TOOL_MAP,
415
416
  ALL_AGENT_NAMES,
@@ -449,10 +450,10 @@ import {
449
450
  resolveLinkDir,
450
451
  sanitizeLinkId,
451
452
  writeLinkPointer
452
- } from "./index-r0dactw2.js";
453
+ } from "./index-85p1850w.js";
453
454
  import {
454
455
  atomicWriteFile
455
- } from "./index-j6q3k628.js";
456
+ } from "./index-ew6fykvv.js";
456
457
  import {
457
458
  KNOWLEDGE_SCHEMA_VERSION,
458
459
  OUTCOME_BLOCK_THRESHOLD,
@@ -464,7 +465,7 @@ import {
464
465
  atomicWriteSwarmFileSync,
465
466
  matchTempGrammar,
466
467
  parseTargetBasename
467
- } from "./index-kemxyzc0.js";
468
+ } from "./index-6bqqzfbe.js";
468
469
  import {
469
470
  assertProjectRoot,
470
471
  hasExplicitProjectBoundary,
@@ -19486,7 +19487,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
19486
19487
  };
19487
19488
  }
19488
19489
  async function sweepActiveNearDuplicates(directory, options = {}) {
19489
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mnxtkt8s.js");
19490
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ketfp4rv.js");
19490
19491
  const { config } = loadPluginConfigWithMeta2(directory);
19491
19492
  const sweepConfig = config.learning?.dedup_sweep;
19492
19493
  if (sweepConfig?.enabled === false)
@@ -20616,7 +20617,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
20616
20617
  }
20617
20618
  if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
20618
20619
  try {
20619
- const skillModule = await import("./skill-generator-2xbfryqb.js");
20620
+ const skillModule = await import("./skill-generator-60px2mvb.js");
20620
20621
  for (const cand of skillCandidates) {
20621
20622
  if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
20622
20623
  continue;
@@ -21088,7 +21089,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
21088
21089
  } catch {}
21089
21090
  }
21090
21091
  if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
21091
- const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-s0tye368.js");
21092
+ const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-z09aqvfe.js");
21092
21093
  for (const { id } of contradictedEntries) {
21093
21094
  try {
21094
21095
  await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
@@ -21907,7 +21908,7 @@ async function runCuratorPostMortem(directory, options = {}) {
21907
21908
  warnings.push("Failed to collect knowledge summary.");
21908
21909
  }
21909
21910
  try {
21910
- const { getScanStatus } = await import("./scan-cursor-8f0s883y.js");
21911
+ const { getScanStatus } = await import("./scan-cursor-h3mfzjc9.js");
21911
21912
  const scanStatus = await getScanStatus(directory);
21912
21913
  if (scanStatus.remaining_estimate > 0) {
21913
21914
  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.`);
@@ -22079,9 +22080,9 @@ var _internals26 = {
22079
22080
  verifyPostMortemKnowledgeActions,
22080
22081
  repairPostMortemActions,
22081
22082
  loadDefaultKnowledgeConfig: async (directory) => {
22082
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-2xw94dh3.js");
22083
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-c37h5xw4.js");
22083
22084
  try {
22084
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mnxtkt8s.js");
22085
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ketfp4rv.js");
22085
22086
  const loaded = loadPluginConfigWithMeta2(directory);
22086
22087
  return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
22087
22088
  } catch {
@@ -22089,11 +22090,11 @@ var _internals26 = {
22089
22090
  }
22090
22091
  },
22091
22092
  applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
22092
- const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-he8n9z9n.js");
22093
+ const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-adp0dsv4.js");
22093
22094
  return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
22094
22095
  },
22095
22096
  checkHivePromotions: async (entries, knowledgeConfig, directory) => {
22096
- const { checkHivePromotions } = await import("./hive-promoter-nvwpj2t9.js");
22097
+ const { checkHivePromotions } = await import("./hive-promoter-b1wv52fs.js");
22097
22098
  return checkHivePromotions(entries, knowledgeConfig, directory);
22098
22099
  },
22099
22100
  applyProposalTriage: async (directory, triage) => {
@@ -22102,7 +22103,7 @@ var _internals26 = {
22102
22103
  activateProposal,
22103
22104
  listSkills: listSkills2,
22104
22105
  sanitizeSlug
22105
- } = await import("./skill-generator-2xbfryqb.js");
22106
+ } = await import("./skill-generator-60px2mvb.js");
22106
22107
  const result = {
22107
22108
  approved: [],
22108
22109
  rejected: [],
@@ -22144,7 +22145,7 @@ var _internals26 = {
22144
22145
  return result;
22145
22146
  },
22146
22147
  readPriorDriftReports: async (directory) => {
22147
- const { readPriorDriftReports } = await import("./curator-drift-h57z6tm3.js");
22148
+ const { readPriorDriftReports } = await import("./curator-drift-g6w4ga1q.js");
22148
22149
  return readPriorDriftReports(directory);
22149
22150
  },
22150
22151
  readSwarmKnowledge: (directory) => readKnowledge(resolveSwarmKnowledgePath(directory))
@@ -23432,9 +23433,9 @@ function hashContent(content) {
23432
23433
  return createHash12("sha1").update(content).digest("hex");
23433
23434
  }
23434
23435
  async function loadConfigForPolicyCurator(directory) {
23435
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-2xw94dh3.js");
23436
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-c37h5xw4.js");
23436
23437
  try {
23437
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mnxtkt8s.js");
23438
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ketfp4rv.js");
23438
23439
  const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
23439
23440
  return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
23440
23441
  } catch {
@@ -24449,6 +24450,241 @@ var _internals30 = {
24449
24450
  realpath: realpath3
24450
24451
  };
24451
24452
 
24453
+ // src/tools/repo-graph/indexed-storage.ts
24454
+ init_loader();
24455
+ init_schema();
24456
+ init_logger();
24457
+
24458
+ // src/tools/repo-graph/safe-realpath.ts
24459
+ import { realpathSync as realpathSync3 } from "fs";
24460
+ function safeRealpathSync(targetPath, fallback, realpathResolver = realpathSync3) {
24461
+ try {
24462
+ return realpathResolver(targetPath);
24463
+ } catch (error2) {
24464
+ if (error2 instanceof Error && error2.code === "ENOENT") {
24465
+ return fallback;
24466
+ }
24467
+ return null;
24468
+ }
24469
+ }
24470
+
24471
+ // src/tools/repo-graph/types.ts
24472
+ var GRAPH_SCHEMA_VERSION = "1.5.0";
24473
+ var FILE_ROLE_VALUES = [
24474
+ "api_route",
24475
+ "middleware",
24476
+ "service_module",
24477
+ "data_module",
24478
+ "swarm_tool",
24479
+ "agent",
24480
+ "hook",
24481
+ "config",
24482
+ "schema",
24483
+ "test_file",
24484
+ "cli_command",
24485
+ "documentation",
24486
+ "source_module"
24487
+ ];
24488
+ var ROUTE_METHOD_VALUES = [
24489
+ "GET",
24490
+ "POST",
24491
+ "PUT",
24492
+ "PATCH",
24493
+ "DELETE",
24494
+ "OPTIONS",
24495
+ "HEAD",
24496
+ "ALL"
24497
+ ];
24498
+ var ROUTE_SOURCE_VALUES = [
24499
+ "file_path",
24500
+ "handler_export",
24501
+ "router_call"
24502
+ ];
24503
+ var DATA_OPERATION_VALUES = [
24504
+ "read",
24505
+ "write",
24506
+ "delete",
24507
+ "transaction",
24508
+ "migration"
24509
+ ];
24510
+ var DATA_ACCESS_VALUES = [
24511
+ "database",
24512
+ "orm",
24513
+ "sql",
24514
+ "filesystem",
24515
+ "network",
24516
+ "unknown"
24517
+ ];
24518
+ var SECURITY_KIND_VALUES = [
24519
+ "authentication",
24520
+ "authorization",
24521
+ "input_validation",
24522
+ "csrf",
24523
+ "sanitization",
24524
+ "secret_handling"
24525
+ ];
24526
+ var SECURITY_CONFIDENCE_VALUES = ["low", "medium", "high"];
24527
+ var ONTOLOGY_FINDING_SEVERITY_VALUES = [
24528
+ "info",
24529
+ "low",
24530
+ "medium",
24531
+ "high"
24532
+ ];
24533
+ var IMPORT_TYPE_VALUES = [
24534
+ "default",
24535
+ "named",
24536
+ "namespace",
24537
+ "require",
24538
+ "sideeffect",
24539
+ "type"
24540
+ ];
24541
+ var SYMBOL_EDGE_KIND_VALUES = [
24542
+ "CALLS",
24543
+ "REFERENCES",
24544
+ "USES_TYPE",
24545
+ "INSTANTIATES",
24546
+ "IMPLEMENTS",
24547
+ "OVERRIDES"
24548
+ ];
24549
+ var SYMBOL_EDGE_RESOLUTION_VALUES = [
24550
+ "exact",
24551
+ "import_binding",
24552
+ "same_file_scope",
24553
+ "unique_name",
24554
+ "type_resolved",
24555
+ "lsp",
24556
+ "scip",
24557
+ "heuristic",
24558
+ "unresolved"
24559
+ ];
24560
+ var PACKAGE_BOUNDARY_ROOTS = new Set([
24561
+ "packages",
24562
+ "crates",
24563
+ "apps",
24564
+ "libs",
24565
+ "services"
24566
+ ]);
24567
+ function inferPackageBoundary(moduleName, hasManifest) {
24568
+ const normalized = moduleName.replace(/\\/g, "/").replace(/^(?:\.\/)+/, "");
24569
+ const parts = normalized.split("/").filter(Boolean);
24570
+ if (parts.length === 0)
24571
+ return ".";
24572
+ if (PACKAGE_BOUNDARY_ROOTS.has(parts[0]) && parts.length >= 2) {
24573
+ return `${parts[0]}/${parts[1]}`;
24574
+ }
24575
+ if (parts[0] === "src" && parts.length >= 2) {
24576
+ return `src/${parts[1]}`;
24577
+ }
24578
+ if (parts[0] === "tests" && parts.length >= 2) {
24579
+ return `tests/${parts[1]}`;
24580
+ }
24581
+ if (hasManifest && parts.length >= 2) {
24582
+ if (hasManifest(parts[0]) || hasManifest(`${parts[0]}/${parts[1]}`)) {
24583
+ return `${parts[0]}/${parts[1]}`;
24584
+ }
24585
+ }
24586
+ return parts[0];
24587
+ }
24588
+
24589
+ // src/tools/repo-graph/symbol-edge.ts
24590
+ var KIND_SET = new Set(SYMBOL_EDGE_KIND_VALUES);
24591
+ var RESOLUTION_SET = new Set(SYMBOL_EDGE_RESOLUTION_VALUES);
24592
+
24593
+ // src/tools/repo-graph/validation.ts
24594
+ var FILE_ROLE_SET = new Set(FILE_ROLE_VALUES);
24595
+ var ROUTE_METHOD_SET = new Set(ROUTE_METHOD_VALUES);
24596
+ var ROUTE_SOURCE_SET = new Set(ROUTE_SOURCE_VALUES);
24597
+ var DATA_OPERATION_SET = new Set(DATA_OPERATION_VALUES);
24598
+ var DATA_ACCESS_SET = new Set(DATA_ACCESS_VALUES);
24599
+ var SECURITY_KIND_SET = new Set(SECURITY_KIND_VALUES);
24600
+ var SECURITY_CONFIDENCE_SET = new Set(SECURITY_CONFIDENCE_VALUES);
24601
+ var ONTOLOGY_FINDING_SEVERITY_SET = new Set(ONTOLOGY_FINDING_SEVERITY_VALUES);
24602
+ var IMPORT_TYPE_SET = new Set(IMPORT_TYPE_VALUES);
24603
+ function validateWorkspace(workspace) {
24604
+ if (!workspace || typeof workspace !== "string" || workspace.trim() === "") {
24605
+ throw new Error("Invalid workspace: must be a non-empty string");
24606
+ }
24607
+ if (containsControlChars(workspace)) {
24608
+ throw new Error("Invalid workspace: control characters detected");
24609
+ }
24610
+ if (containsPathTraversal(workspace)) {
24611
+ throw new Error("Invalid workspace: path traversal detected");
24612
+ }
24613
+ }
24614
+
24615
+ // src/tools/repo-graph/indexed-storage.ts
24616
+ var REPO_MEMORY_FILENAME = "repo-memory.sqlite";
24617
+ var MIGRATIONS = [
24618
+ {
24619
+ version: 1,
24620
+ name: "create_graph_meta",
24621
+ sql: `CREATE TABLE graph_meta (
24622
+ key TEXT PRIMARY KEY,
24623
+ value TEXT NOT NULL
24624
+ )`
24625
+ },
24626
+ {
24627
+ version: 2,
24628
+ name: "create_files",
24629
+ sql: `CREATE TABLE files (
24630
+ path TEXT PRIMARY KEY,
24631
+ module_name TEXT NOT NULL,
24632
+ node_json TEXT NOT NULL
24633
+ )`
24634
+ },
24635
+ {
24636
+ version: 3,
24637
+ name: "create_files_module_name_index",
24638
+ sql: "CREATE INDEX idx_files_module_name ON files(module_name)"
24639
+ },
24640
+ {
24641
+ version: 4,
24642
+ name: "create_edges",
24643
+ sql: `CREATE TABLE edges (
24644
+ seq INTEGER PRIMARY KEY,
24645
+ source TEXT NOT NULL,
24646
+ target TEXT NOT NULL,
24647
+ edge_json TEXT NOT NULL
24648
+ )`
24649
+ },
24650
+ {
24651
+ version: 5,
24652
+ name: "create_edges_source_index",
24653
+ sql: "CREATE INDEX idx_edges_source ON edges(source)"
24654
+ },
24655
+ {
24656
+ version: 6,
24657
+ name: "create_edges_target_index",
24658
+ sql: "CREATE INDEX idx_edges_target ON edges(target)"
24659
+ }
24660
+ ];
24661
+ var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
24662
+ var _handles = new Map;
24663
+ function getRepoMemoryPath(workspace) {
24664
+ validateWorkspace(workspace);
24665
+ const basePath = validateSwarmPath(workspace, REPO_MEMORY_FILENAME);
24666
+ validateSymlinkBoundary(basePath, workspace);
24667
+ return basePath;
24668
+ }
24669
+ function closeHandleAt(storePath) {
24670
+ const db = _handles.get(storePath);
24671
+ if (!db)
24672
+ return;
24673
+ _handles.delete(storePath);
24674
+ try {
24675
+ db.close();
24676
+ } catch {}
24677
+ }
24678
+ function closeRepoMemory(workspace) {
24679
+ let storePath;
24680
+ try {
24681
+ storePath = getRepoMemoryPath(workspace);
24682
+ } catch {
24683
+ return;
24684
+ }
24685
+ closeHandleAt(storePath);
24686
+ }
24687
+
24452
24688
  // src/context-map/telemetry.ts
24453
24689
  import * as fs14 from "fs";
24454
24690
  import * as path30 from "path";
@@ -27283,7 +27519,7 @@ async function repairIncompleteJsonlTail(filePath) {
27283
27519
  }
27284
27520
 
27285
27521
  // src/memory/provider-pool.ts
27286
- import { realpathSync as realpathSync3 } from "fs";
27522
+ import { realpathSync as realpathSync4 } from "fs";
27287
27523
  import * as path37 from "path";
27288
27524
 
27289
27525
  // src/memory/sqlite-provider.ts
@@ -28066,7 +28302,7 @@ var FTS_INSERT_COLUMNS = [
28066
28302
  "id",
28067
28303
  ...FTS_INDEX_COLUMNS.map((column) => column.name)
28068
28304
  ];
28069
- var MIGRATIONS = [
28305
+ var MIGRATIONS2 = [
28070
28306
  {
28071
28307
  version: 1,
28072
28308
  name: "create_memory_provider_tables",
@@ -29201,7 +29437,7 @@ class SQLiteMemoryProvider {
29201
29437
  const row = db.query("SELECT MAX(version) as version FROM schema_migrations").get();
29202
29438
  const currentVersion = row?.version ?? 0;
29203
29439
  this.databaseStartedFresh = currentVersion === 0;
29204
- for (const migration of MIGRATIONS) {
29440
+ for (const migration of MIGRATIONS2) {
29205
29441
  if (migration.version <= currentVersion)
29206
29442
  continue;
29207
29443
  const apply = db.transaction(() => {
@@ -30336,7 +30572,7 @@ function getOrCreateProviderForRoot(root, config) {
30336
30572
  function resolvePoolKeyForRoot(root) {
30337
30573
  if (root.kind === "cohort") {
30338
30574
  try {
30339
- return `cohort:${realpathSync3(root.cohortRoot)}`;
30575
+ return `cohort:${realpathSync4(root.cohortRoot)}`;
30340
30576
  } catch {
30341
30577
  return `cohort:${path37.resolve(root.cohortRoot)}`;
30342
30578
  }
@@ -30419,7 +30655,7 @@ function unlinkEntry(entry) {
30419
30655
  function resolvePoolKey(directory) {
30420
30656
  const rawKey = path37.resolve(directory);
30421
30657
  try {
30422
- const canonical = realpathSync3(directory);
30658
+ const canonical = realpathSync4(directory);
30423
30659
  resolvedKeyCache.delete(rawKey);
30424
30660
  resolvedKeyCache.set(rawKey, canonical);
30425
30661
  if (resolvedKeyCache.size > MAX_POOL_SIZE) {
@@ -32296,7 +32532,7 @@ function buildSkillImproverApprovalRequest(input) {
32296
32532
  };
32297
32533
  }
32298
32534
  function estimateTokenCount(content) {
32299
- return Math.max(1, Math.ceil(content.length / 4));
32535
+ return Math.max(1, estimateTokens(content));
32300
32536
  }
32301
32537
  function toApprovalPath(directory, targetPath) {
32302
32538
  const relative7 = path42.relative(directory, targetPath).replace(/\\/g, "/");
@@ -35064,6 +35300,7 @@ var ARCHIVE_ARTIFACTS = [
35064
35300
  "telemetry.jsonl",
35065
35301
  "telemetry.jsonl.1",
35066
35302
  "swarm.db",
35303
+ REPO_MEMORY_FILENAME,
35067
35304
  "close-summary.md",
35068
35305
  "session-reflection.md",
35069
35306
  "spec.md",
@@ -35096,7 +35333,8 @@ var ACTIVE_STATE_TO_CLEAN = [
35096
35333
  "spec.md",
35097
35334
  "spec-staleness.json",
35098
35335
  "spec-snapshot.md",
35099
- "swarm.db"
35336
+ "swarm.db",
35337
+ REPO_MEMORY_FILENAME
35100
35338
  ];
35101
35339
  var TERMINAL_STATE_FILES = [
35102
35340
  "plan.json",
@@ -35478,7 +35716,7 @@ async function runFinalizeStage(ctx) {
35478
35716
  }
35479
35717
  }
35480
35718
  try {
35481
- const { CuratorConfigSchema: CCS } = await import("./schema-2xw94dh3.js");
35719
+ const { CuratorConfigSchema: CCS } = await import("./schema-c37h5xw4.js");
35482
35720
  const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
35483
35721
  const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
35484
35722
  if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
@@ -35540,7 +35778,7 @@ async function runArchiveStage(ctx) {
35540
35778
  const srcPath = path47.join(ctx.swarmDir, artifact);
35541
35779
  const destPath = path47.join(ctx.archiveDir, artifact);
35542
35780
  const requiredness = REQUIRED_ARTIFACTS.has(artifact) ? "required" : "optional";
35543
- if (artifact === "swarm.db") {
35781
+ if (artifact === "swarm.db" || artifact === REPO_MEMORY_FILENAME) {
35544
35782
  const r = await archiveSqliteSnapshot({
35545
35783
  sourcePath: srcPath,
35546
35784
  destDir: ctx.archiveDir,
@@ -35763,6 +36001,11 @@ async function runCleanStage(ctx) {
35763
36001
  closeProjectDb(ctx.directory);
35764
36002
  } catch {}
35765
36003
  }
36004
+ if (artifact === REPO_MEMORY_FILENAME) {
36005
+ try {
36006
+ _internals41.closeRepoMemory(ctx.directory);
36007
+ } catch {}
36008
+ }
35766
36009
  try {
35767
36010
  await fs17.unlink(filePath);
35768
36011
  cleanedFiles.push(artifact);
@@ -36326,6 +36569,7 @@ function detectFullAuto(directory, sessionID) {
36326
36569
  }
36327
36570
  }
36328
36571
  var _internals41 = {
36572
+ closeRepoMemory,
36329
36573
  ACTIVE_STATE_DIRS_TO_CLEAN,
36330
36574
  countSessionKnowledgeEntries,
36331
36575
  CLOSE_SKILL_REVIEW_TIMEOUT_MS,
@@ -37691,9 +37935,9 @@ var _internals45 = {
37691
37935
  loadPluginConfigWithMeta,
37692
37936
  loadCuratorDeps: async () => {
37693
37937
  const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
37694
- import("./schema-2xw94dh3.js"),
37695
- import("./curator-he8n9z9n.js"),
37696
- import("./curator-llm-factory-5tq9c4v5.js")
37938
+ import("./schema-c37h5xw4.js"),
37939
+ import("./curator-adp0dsv4.js"),
37940
+ import("./curator-llm-factory-kd8v16jj.js")
37697
37941
  ]);
37698
37942
  return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
37699
37943
  }
@@ -38702,7 +38946,7 @@ async function computeCurationDiagnostics(directory, entries) {
38702
38946
  let scanCompleted = false;
38703
38947
  let scanRemaining = 0;
38704
38948
  try {
38705
- const { getScanStatus } = await import("./scan-cursor-8f0s883y.js");
38949
+ const { getScanStatus } = await import("./scan-cursor-h3mfzjc9.js");
38706
38950
  const status = await getScanStatus(directory);
38707
38951
  scanGeneration = status.generation;
38708
38952
  scanCompleted = status.completed;
@@ -38710,19 +38954,19 @@ async function computeCurationDiagnostics(directory, entries) {
38710
38954
  } catch {}
38711
38955
  let configMatch = null;
38712
38956
  try {
38713
- const { isLinked: isLinked2 } = await import("./knowledge-link-rb11f06y.js");
38957
+ const { isLinked: isLinked2 } = await import("./knowledge-link-4frk38w8.js");
38714
38958
  if (isLinked2(directory)) {
38715
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-2xw94dh3.js");
38959
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-c37h5xw4.js");
38716
38960
  let config;
38717
38961
  try {
38718
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mnxtkt8s.js");
38962
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-ketfp4rv.js");
38719
38963
  const loaded = loadPluginConfigWithMeta2(directory);
38720
38964
  config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
38721
38965
  } catch {
38722
38966
  config = KnowledgeConfigSchema2.parse({});
38723
38967
  }
38724
38968
  const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
38725
- const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-jm9jsxtt.js");
38969
+ const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-jabphe51.js");
38726
38970
  const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
38727
38971
  const cohortFp = await readCohortConfigFingerprint(directory);
38728
38972
  configMatch = cohortFp === null ? null : currentFp === cohortFp;
@@ -40035,7 +40279,7 @@ async function handleDoctorCommand(directory, args) {
40035
40279
  const result = runConfigDoctor(config, directory);
40036
40280
  let output;
40037
40281
  if (enableAutoFix && result.hasAutoFixableIssues) {
40038
- const { runConfigDoctorWithFixes } = await import("./config-doctor-69eebk90.js");
40282
+ const { runConfigDoctorWithFixes } = await import("./config-doctor-s6p9aqfv.js");
40039
40283
  const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
40040
40284
  applyLossy: true
40041
40285
  });
@@ -40975,7 +41219,7 @@ async function handleEvidenceCommand(directory, args) {
40975
41219
  return formatTaskEvidenceMarkdown(evidenceData);
40976
41220
  }
40977
41221
  async function handleEvidenceSummaryCommand(directory) {
40978
- const { buildEvidenceSummary } = await import("./evidence-summary-service-05s5y8d6.js");
41222
+ const { buildEvidenceSummary } = await import("./evidence-summary-service-kpjpd86j.js");
40979
41223
  const artifact = await buildEvidenceSummary(directory);
40980
41224
  if (!artifact) {
40981
41225
  return "No plan found. Run `/swarm plan` to check plan status.";
@@ -52309,6 +52553,15 @@ function parseJsonObject(candidate) {
52309
52553
 
52310
52554
  // src/memory/injector.ts
52311
52555
  init_schema();
52556
+
52557
+ // src/services/injection-budget.ts
52558
+ var turnLedgers = new Map;
52559
+ function clearAllTurnLedgers() {
52560
+ turnLedgers.clear();
52561
+ }
52562
+
52563
+ // src/memory/injector.ts
52564
+ init_logger();
52312
52565
  // src/memory/reflection-service.ts
52313
52566
  import {
52314
52567
  closeSync as closeSync11,
@@ -55601,126 +55854,6 @@ var _internals66 = {
55601
55854
 
55602
55855
  // src/tools/repo-graph/ontology.ts
55603
55856
  import * as path75 from "path";
55604
-
55605
- // src/tools/repo-graph/types.ts
55606
- var GRAPH_SCHEMA_VERSION = "1.5.0";
55607
- var FILE_ROLE_VALUES = [
55608
- "api_route",
55609
- "middleware",
55610
- "service_module",
55611
- "data_module",
55612
- "swarm_tool",
55613
- "agent",
55614
- "hook",
55615
- "config",
55616
- "schema",
55617
- "test_file",
55618
- "cli_command",
55619
- "documentation",
55620
- "source_module"
55621
- ];
55622
- var ROUTE_METHOD_VALUES = [
55623
- "GET",
55624
- "POST",
55625
- "PUT",
55626
- "PATCH",
55627
- "DELETE",
55628
- "OPTIONS",
55629
- "HEAD",
55630
- "ALL"
55631
- ];
55632
- var ROUTE_SOURCE_VALUES = [
55633
- "file_path",
55634
- "handler_export",
55635
- "router_call"
55636
- ];
55637
- var DATA_OPERATION_VALUES = [
55638
- "read",
55639
- "write",
55640
- "delete",
55641
- "transaction",
55642
- "migration"
55643
- ];
55644
- var DATA_ACCESS_VALUES = [
55645
- "database",
55646
- "orm",
55647
- "sql",
55648
- "filesystem",
55649
- "network",
55650
- "unknown"
55651
- ];
55652
- var SECURITY_KIND_VALUES = [
55653
- "authentication",
55654
- "authorization",
55655
- "input_validation",
55656
- "csrf",
55657
- "sanitization",
55658
- "secret_handling"
55659
- ];
55660
- var SECURITY_CONFIDENCE_VALUES = ["low", "medium", "high"];
55661
- var ONTOLOGY_FINDING_SEVERITY_VALUES = [
55662
- "info",
55663
- "low",
55664
- "medium",
55665
- "high"
55666
- ];
55667
- var IMPORT_TYPE_VALUES = [
55668
- "default",
55669
- "named",
55670
- "namespace",
55671
- "require",
55672
- "sideeffect",
55673
- "type"
55674
- ];
55675
- var SYMBOL_EDGE_KIND_VALUES = [
55676
- "CALLS",
55677
- "REFERENCES",
55678
- "USES_TYPE",
55679
- "INSTANTIATES",
55680
- "IMPLEMENTS",
55681
- "OVERRIDES"
55682
- ];
55683
- var SYMBOL_EDGE_RESOLUTION_VALUES = [
55684
- "exact",
55685
- "import_binding",
55686
- "same_file_scope",
55687
- "unique_name",
55688
- "type_resolved",
55689
- "lsp",
55690
- "scip",
55691
- "heuristic",
55692
- "unresolved"
55693
- ];
55694
- var PACKAGE_BOUNDARY_ROOTS = new Set([
55695
- "packages",
55696
- "crates",
55697
- "apps",
55698
- "libs",
55699
- "services"
55700
- ]);
55701
- function inferPackageBoundary(moduleName, hasManifest) {
55702
- const normalized = moduleName.replace(/\\/g, "/").replace(/^(?:\.\/)+/, "");
55703
- const parts = normalized.split("/").filter(Boolean);
55704
- if (parts.length === 0)
55705
- return ".";
55706
- if (PACKAGE_BOUNDARY_ROOTS.has(parts[0]) && parts.length >= 2) {
55707
- return `${parts[0]}/${parts[1]}`;
55708
- }
55709
- if (parts[0] === "src" && parts.length >= 2) {
55710
- return `src/${parts[1]}`;
55711
- }
55712
- if (parts[0] === "tests" && parts.length >= 2) {
55713
- return `tests/${parts[1]}`;
55714
- }
55715
- if (hasManifest && parts.length >= 2) {
55716
- if (hasManifest(parts[0]) || hasManifest(`${parts[0]}/${parts[1]}`)) {
55717
- return `${parts[0]}/${parts[1]}`;
55718
- }
55719
- }
55720
- return parts[0];
55721
- }
55722
-
55723
- // src/tools/repo-graph/ontology.ts
55724
55857
  var HTTP_METHODS = [
55725
55858
  "GET",
55726
55859
  "POST",
@@ -56193,34 +56326,6 @@ function extractFileOntology(input) {
56193
56326
  };
56194
56327
  }
56195
56328
 
56196
- // src/tools/repo-graph/safe-realpath.ts
56197
- import { realpathSync as realpathSync7 } from "fs";
56198
- function safeRealpathSync(targetPath, fallback, realpathResolver = realpathSync7) {
56199
- try {
56200
- return realpathResolver(targetPath);
56201
- } catch (error2) {
56202
- if (error2 instanceof Error && error2.code === "ENOENT") {
56203
- return fallback;
56204
- }
56205
- return null;
56206
- }
56207
- }
56208
-
56209
- // src/tools/repo-graph/symbol-edge.ts
56210
- var KIND_SET = new Set(SYMBOL_EDGE_KIND_VALUES);
56211
- var RESOLUTION_SET = new Set(SYMBOL_EDGE_RESOLUTION_VALUES);
56212
-
56213
- // src/tools/repo-graph/validation.ts
56214
- var FILE_ROLE_SET = new Set(FILE_ROLE_VALUES);
56215
- var ROUTE_METHOD_SET = new Set(ROUTE_METHOD_VALUES);
56216
- var ROUTE_SOURCE_SET = new Set(ROUTE_SOURCE_VALUES);
56217
- var DATA_OPERATION_SET = new Set(DATA_OPERATION_VALUES);
56218
- var DATA_ACCESS_SET = new Set(DATA_ACCESS_VALUES);
56219
- var SECURITY_KIND_SET = new Set(SECURITY_KIND_VALUES);
56220
- var SECURITY_CONFIDENCE_SET = new Set(SECURITY_CONFIDENCE_VALUES);
56221
- var ONTOLOGY_FINDING_SEVERITY_SET = new Set(ONTOLOGY_FINDING_SEVERITY_VALUES);
56222
- var IMPORT_TYPE_SET = new Set(IMPORT_TYPE_VALUES);
56223
-
56224
56329
  // src/tools/repo-graph/builder.ts
56225
56330
  var _internals67 = {
56226
56331
  now: Date.now,
@@ -56969,6 +57074,7 @@ var RANGE_WIDENED_GRAMMARS = new Set([
56969
57074
  ]);
56970
57075
 
56971
57076
  // src/tools/repo-graph/query.ts
57077
+ var queryIndexCache = new WeakMap;
56972
57078
  var DEAD_EXPORT_EXCLUDED_ROLES = new Set([
56973
57079
  "api_route",
56974
57080
  "cli_command",
@@ -73531,7 +73637,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
73531
73637
  if (!input.dispatcher) {
73532
73638
  throw new Error("no evaluation dispatcher available (cannot run validation)");
73533
73639
  }
73534
- const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-yaqrj388.js");
73640
+ const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-k1rkbjm8.js");
73535
73641
  const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
73536
73642
  const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () => _internals97.evaluateCandidateV1({
73537
73643
  projectRoot: input.directory,
@@ -74892,9 +74998,13 @@ function formatStatusMarkdown(status) {
74892
74998
  const budgetTokens = status.contextBudgetTokens;
74893
74999
  if (budgetTokens !== undefined && budgetTokens !== null && budgetTokens > 0) {
74894
75000
  const est = Math.round(status.contextBudgetPct / 100 * budgetTokens);
74895
- lines.push("", `**Context**: ${pct}% used (est. ${est.toLocaleString()} / ${budgetTokens.toLocaleString()} tokens)`);
75001
+ lines.push("", `**Swarm injection footprint**: ${pct}% of model window (intermediate measurement; est. ${est.toLocaleString()} / ${budgetTokens.toLocaleString()} tokens)`);
74896
75002
  } else {
74897
- lines.push("", `**Context**: ${pct}% used`);
75003
+ lines.push("", `**Swarm injection footprint**: ${pct}% of model window (intermediate measurement)`);
75004
+ }
75005
+ const finalPressure = getDisplayFinalPromptPressure();
75006
+ if (finalPressure && finalPressure.pct > 0) {
75007
+ lines.push(`**Prompt pressure (final)**: ${finalPressure.pct.toFixed(1)}% estimated (est. ${finalPressure.usedTokens.toLocaleString()} / ${finalPressure.limitTokens.toLocaleString()} tokens; ${finalPressure.estimatorSource}${finalPressure.providerReported ? "; provider-reported" : ""})`);
74898
75008
  }
74899
75009
  if (status.compactionCount > 0) {
74900
75010
  lines.push(`**Compaction events**: ${status.compactionCount} triggered`);
@@ -75572,7 +75682,7 @@ function buildDetailedHelp(commandName, entry) {
75572
75682
  async function handleHelpCommand(ctx) {
75573
75683
  const targetCommand = ctx.args.join(" ");
75574
75684
  if (!targetCommand) {
75575
- const { buildHelpText } = await import("./index-v2ryvr8k.js");
75685
+ const { buildHelpText } = await import("./index-qzqpq75z.js");
75576
75686
  return buildHelpText();
75577
75687
  }
75578
75688
  const tokens = targetCommand.split(/\s+/);
@@ -75581,7 +75691,7 @@ async function handleHelpCommand(ctx) {
75581
75691
  return _internals100.buildDetailedHelp(resolved.key, resolved.entry);
75582
75692
  }
75583
75693
  const similar = _internals100.findSimilarCommands(targetCommand);
75584
- const { buildHelpText: fullHelp } = await import("./index-v2ryvr8k.js");
75694
+ const { buildHelpText: fullHelp } = await import("./index-qzqpq75z.js");
75585
75695
  if (similar.length > 0) {
75586
75696
  return `Command '/swarm ${targetCommand}' not found.
75587
75697
 
@@ -75768,7 +75878,7 @@ var COMMAND_REGISTRY = {
75768
75878
  },
75769
75879
  "guardrail explain": {
75770
75880
  handler: async (ctx) => {
75771
- const { handleGuardrailExplain } = await import("./guardrail-explain-tebk344k.js");
75881
+ const { handleGuardrailExplain } = await import("./guardrail-explain-wqb5h7kk.js");
75772
75882
  return handleGuardrailExplain(ctx.directory, ctx.args);
75773
75883
  },
75774
75884
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -75778,7 +75888,7 @@ var COMMAND_REGISTRY = {
75778
75888
  },
75779
75889
  "guardrail reset": {
75780
75890
  handler: async (ctx) => {
75781
- const { handleGuardrailReset } = await import("./guardrail-reset-716pdyf5.js");
75891
+ const { handleGuardrailReset } = await import("./guardrail-reset-0wdj53cp.js");
75782
75892
  return handleGuardrailReset(ctx.args, ctx.sessionID);
75783
75893
  },
75784
75894
  description: "Reset one exact active invocation/action circuit after repair",
@@ -75787,7 +75897,7 @@ var COMMAND_REGISTRY = {
75787
75897
  },
75788
75898
  "guardrail-explain": {
75789
75899
  handler: async (ctx) => {
75790
- const { handleGuardrailExplain } = await import("./guardrail-explain-tebk344k.js");
75900
+ const { handleGuardrailExplain } = await import("./guardrail-explain-wqb5h7kk.js");
75791
75901
  return handleGuardrailExplain(ctx.directory, ctx.args);
75792
75902
  },
75793
75903
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -75797,7 +75907,7 @@ var COMMAND_REGISTRY = {
75797
75907
  },
75798
75908
  "guardrail-reset": {
75799
75909
  handler: async (ctx) => {
75800
- const { handleGuardrailReset } = await import("./guardrail-reset-716pdyf5.js");
75910
+ const { handleGuardrailReset } = await import("./guardrail-reset-0wdj53cp.js");
75801
75911
  return handleGuardrailReset(ctx.args, ctx.sessionID);
75802
75912
  },
75803
75913
  description: "Reset one exact active invocation/action circuit after repair",
@@ -75807,7 +75917,7 @@ var COMMAND_REGISTRY = {
75807
75917
  },
75808
75918
  "guardrail-log": {
75809
75919
  handler: async (ctx) => {
75810
- const { handleGuardrailLog } = await import("./guardrail-log-x3gz3x17.js");
75920
+ const { handleGuardrailLog } = await import("./guardrail-log-614g1pta.js");
75811
75921
  return handleGuardrailLog(ctx.directory, ctx.args);
75812
75922
  },
75813
75923
  description: "Read the guardrail decision log (use --blocks-only for blocks)",
@@ -80778,6 +80888,8 @@ var swarmState = {
80778
80888
  gateDenialCounts: new Map,
80779
80889
  generatedAgentNames: [],
80780
80890
  lastBudgetBySession: new Map,
80891
+ finalPromptPressureBySession: new Map,
80892
+ finalAccountingWarningBandsBySession: new Map,
80781
80893
  liveContextWindows: new Map,
80782
80894
  agentSessions: defaultRunContext.agentSessions,
80783
80895
  pendingRehydrations: new Set,
@@ -80791,6 +80903,9 @@ function resetSwarmState() {
80791
80903
  swarmState.delegationChains.clear();
80792
80904
  swarmState.pendingEvents = 0;
80793
80905
  swarmState.lastBudgetBySession.clear();
80906
+ swarmState.finalPromptPressureBySession.clear();
80907
+ clearAllTurnLedgers();
80908
+ swarmState.finalAccountingWarningBandsBySession.clear();
80794
80909
  swarmState.liveContextWindows.clear();
80795
80910
  swarmState.agentSessions.clear();
80796
80911
  _lastIdleSweepAtMs = 0;
@@ -81765,10 +81880,19 @@ function getDisplayBudget() {
81765
81880
  }
81766
81881
  return best;
81767
81882
  }
81883
+ function getDisplayFinalPromptPressure() {
81884
+ let best = null;
81885
+ for (const entry of swarmState.finalPromptPressureBySession.values()) {
81886
+ if (entry.pct > 0 && (best === null || entry.pct > best.pct)) {
81887
+ best = entry;
81888
+ }
81889
+ }
81890
+ return best;
81891
+ }
81768
81892
  async function rehydratePrSubscriptions(sessionID, directory) {
81769
81893
  const map = new Map;
81770
81894
  try {
81771
- const { listActive: listActive2 } = await import("./pr-subscriptions-2f5fne6z.js");
81895
+ const { listActive: listActive2 } = await import("./pr-subscriptions-00evnffe.js");
81772
81896
  const records = await listActive2(directory);
81773
81897
  for (const record of records) {
81774
81898
  if (record.sessionID !== sessionID)
@@ -82214,7 +82338,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
82214
82338
  return extracted === expectedSessionId;
82215
82339
  }
82216
82340
  async function inspectStandardWorktreeCollisionOwnership(identity) {
82217
- const collisionOwnership = await import("./worktree-collision-ownership-5gwey8ms.js");
82341
+ const collisionOwnership = await import("./worktree-collision-ownership-2pc20ypq.js");
82218
82342
  return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
82219
82343
  }
82220
82344
  async function runRecoveryGit(directory, args, timeoutMs = 15000) {
@@ -82623,7 +82747,7 @@ async function precreateStandardWorktreeSession(args) {
82623
82747
  const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, handle.worktreePath);
82624
82748
  if (laneProfile) {
82625
82749
  try {
82626
- const { writeLaneProfileToDiskReal } = await import("./core-dyp14hcb.js");
82750
+ const { writeLaneProfileToDiskReal } = await import("./core-ev2ebc4v.js");
82627
82751
  await writeLaneProfileToDiskReal(handle.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
82628
82752
  } catch {}
82629
82753
  }
@@ -83548,7 +83672,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
83548
83672
  }
83549
83673
  clearWorktreeMergeStatus(statusKey);
83550
83674
  try {
83551
- const { removeLaneProfileFromDiskReal } = await import("./core-dyp14hcb.js");
83675
+ const { removeLaneProfileFromDiskReal } = await import("./core-ev2ebc4v.js");
83552
83676
  await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
83553
83677
  } catch {}
83554
83678
  const state = serializationStateBySessionID.get(dispatch.parentSessionID);
@@ -83751,4 +83875,4 @@ var _internals102 = {
83751
83875
  resolveGitExecutable
83752
83876
  };
83753
83877
 
83754
- export { resetActionCircuitExternally, getBlockingActionCircuit, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcExtractRecursiveRmTargets, dcEvaluateRecursiveDeleteTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, getSharedClassifierGuardrailBlock, classifyCommand, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, getAgentSession, parseLeanLaneIndex, computeLaneRuntimeProfile, MAX_TRACKED_STANDARD_WORKTREE_CALLS, awaitingMergeByCallID, standardWorktreeByCallID, standardWorktreeSerializationSessions, getStandardWorktreeDegradationReason, resetStandardWorktreeIsolationState, checkStandardWorktreeSerializationRelease, sanitizeWorktreeTaskId, preProvisionCollisionCheck, isLaneOwnedByCurrentSession, precreateStandardWorktreeSession, preserveBackgroundWorktreeOwnershipForCallId, preserveDirtyWorktreeForCallId, preserveDirtyWorktreeAtPath, cleanupStandardWorktreeForCallId, abortStandardWorktreeDispatch, finishStandardWorktreeDispatch, readLaneEnvFileFromDisk, _internals102 as _internals, handleAcknowledgeSpecDriftCommand, handleAgentsCommand, handleAnalyzeCommand, handleApproveWriteCommand, handleArchiveCommand, handleAutoProceedCommand, handleBenchmarkCommand, handleBrainstormCommand, handleCheckpointCommand, handleCiSimulateCommand, handleClarifyCommand, createCuratorLLMDelegate, _internals25 as _internals1, normalizeRecommendationEntryIdToken, parseKnowledgeRecommendations, parseKnowledgeRecommendationsWithDiagnostics, parseStructuredCuratorBlocks, readCuratorSummary, writeCuratorSummary, appendCuratorRecommendation, mergeCuratorPhaseSummary, filterPhaseEvents, checkPhaseCompliance, runCuratorInit, runCuratorPhase, applyCuratorKnowledgeUpdates, isHiveEligible, countDistinctProjects, checkHivePromotions, _internals29 as _internals2, createHivePromoterHook, promoteToHive, promoteFromSwarm, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCostsCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, VERSION_PINNED_LEAF, discoverVersionPinnedCachePaths, readCachePackageVersion, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleGateAuditCommand, handleGateStatsCommand, handleHandoffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleLinkCommand, safeRealpathSync, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryValueLogCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleRecoverCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleReviewCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleUnlinkCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS, _internals100 as _internals3, resolveCommand };
83878
+ export { resetActionCircuitExternally, getBlockingActionCircuit, dcNormalizeCommand, dcUnwrapWrappers, dcSplitSegments, dcExtractRecursiveRmTargets, dcEvaluateRecursiveDeleteTargets, dcCheckJunctionCreation, dcExtractWindowsCmdTargets, dcExtractPowerShellTargets, getSharedClassifierGuardrailBlock, classifyCommand, normalizeSwarmCommandInput, canonicalCommandKey, formatCommandNotFound, executeSwarmCommand, SWARM_COMMAND_TOOL_COMMANDS, SWARM_COMMAND_TOOL_ALLOWLIST, HUMAN_ONLY_SWARM_COMMANDS, classifySwarmCommandToolUse, classifySwarmCommandChatFallbackUse, detectPosixWrites, detectWindowsWrites, resolveWriteTargets, getAgentSession, parseLeanLaneIndex, computeLaneRuntimeProfile, MAX_TRACKED_STANDARD_WORKTREE_CALLS, awaitingMergeByCallID, standardWorktreeByCallID, standardWorktreeSerializationSessions, getStandardWorktreeDegradationReason, resetStandardWorktreeIsolationState, checkStandardWorktreeSerializationRelease, sanitizeWorktreeTaskId, preProvisionCollisionCheck, isLaneOwnedByCurrentSession, precreateStandardWorktreeSession, preserveBackgroundWorktreeOwnershipForCallId, preserveDirtyWorktreeForCallId, preserveDirtyWorktreeAtPath, cleanupStandardWorktreeForCallId, abortStandardWorktreeDispatch, finishStandardWorktreeDispatch, readLaneEnvFileFromDisk, _internals102 as _internals, handleAcknowledgeSpecDriftCommand, handleAgentsCommand, handleAnalyzeCommand, handleApproveWriteCommand, handleArchiveCommand, handleAutoProceedCommand, handleBenchmarkCommand, handleBrainstormCommand, handleCheckpointCommand, handleCiSimulateCommand, handleClarifyCommand, createCuratorLLMDelegate, _internals25 as _internals1, normalizeRecommendationEntryIdToken, parseKnowledgeRecommendations, parseKnowledgeRecommendationsWithDiagnostics, parseStructuredCuratorBlocks, readCuratorSummary, writeCuratorSummary, appendCuratorRecommendation, mergeCuratorPhaseSummary, filterPhaseEvents, checkPhaseCompliance, runCuratorInit, runCuratorPhase, applyCuratorKnowledgeUpdates, isHiveEligible, countDistinctProjects, checkHivePromotions, _internals29 as _internals2, createHivePromoterHook, promoteToHive, promoteFromSwarm, safeRealpathSync, handleCloseCommand, handleCodebaseReviewCommand, handleConcurrencyCommand, handleConfigCommand, handleConsolidateCommand, handleCostsCommand, handleCouncilCommand, handleCurateCommand, handleDarkMatterCommand, handleDeepDiveCommand, handleDeepResearchCommand, getPluginConfigDir, getPluginCachePaths, getPluginLockFilePaths, VERSION_PINNED_LEAF, discoverVersionPinnedCachePaths, readCachePackageVersion, handleDiagnoseCommand, handleDoctorCommand, handleEvidenceCommand, handleEvidenceSummaryCommand, handleExportCommand, handleFullAutoCommand, handleGateAuditCommand, handleGateStatsCommand, handleHandoffCommand, handleHistoryCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeMigrateCommand, handleKnowledgeListCommand, handleKnowledgeUnactionableCommand, handleKnowledgeRetryHardeningCommand, handleLearningCommand, handleLinkCommand, handleMemoryCommand, handleMemoryStatusCommand, handleMemoryValueLogCommand, handleMemoryMigrateCommand, handleMemoryImportCommand, handleMemoryExportCommand, handlePlanCommand, handlePreflightCommand, handlePromoteCommand, handleQaGatesCommand, handleRecoverCommand, handleResetCommand, handleResetSessionCommand, handleRetrieveCommand, handleReviewCommand, handleRollbackCommand, handleSddStatusCommand, handleSddValidateCommand, handleSddProjectCommand, handleSddCommand, handleSimulateCommand, handleSpecifyCommand, handleStatusCommand, handleSyncPlanCommand, handleTurboCommand, handleUnlinkCommand, handleWriteRetroCommand, handleHelpCommand, COMMAND_REGISTRY, VALID_COMMANDS, _internals100 as _internals3, resolveCommand };