opencode-swarm 7.0.0-beta.1 → 7.0.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 (541) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1265 -40
  3. package/dist/__tests__/acknowledge-spec-drift.test.d.ts +1 -0
  4. package/dist/__tests__/cli-version.adversarial.test.d.ts +1 -0
  5. package/dist/__tests__/cli-version.test.d.ts +1 -0
  6. package/dist/__tests__/conflict-resolution.test.d.ts +1 -0
  7. package/dist/__tests__/convene-general-council.test.d.ts +10 -0
  8. package/dist/__tests__/critic_drift_verifier-whitelist.test.d.ts +1 -0
  9. package/dist/__tests__/critic_hallucination_verifier-whitelist.test.d.ts +1 -0
  10. package/dist/__tests__/disagreement-detector.test.d.ts +7 -0
  11. package/dist/__tests__/evidence-lock.adversarial.test.d.ts +8 -0
  12. package/dist/__tests__/evidence-lock.test.d.ts +6 -0
  13. package/dist/__tests__/gate-evidence.adversarial.test.d.ts +7 -0
  14. package/dist/__tests__/general-council-service.test.d.ts +7 -0
  15. package/dist/__tests__/lint-spec.test.d.ts +1 -0
  16. package/dist/__tests__/preflight-phase.test.d.ts +1 -0
  17. package/dist/__tests__/qa-gate-hardening.test.d.ts +12 -0
  18. package/dist/__tests__/req-coverage.test.d.ts +1 -0
  19. package/dist/__tests__/security-adversarial.test.d.ts +1 -0
  20. package/dist/__tests__/sounding-board-parser.test.d.ts +1 -0
  21. package/dist/__tests__/spec-hash.test.d.ts +1 -0
  22. package/dist/__tests__/spec-schema.test.d.ts +1 -0
  23. package/dist/__tests__/web-search-provider.test.d.ts +6 -0
  24. package/dist/__tests__/write-drift-evidence-requirement-coverage.test.d.ts +4 -0
  25. package/dist/adversarial-tests.test.d.ts +1 -0
  26. package/dist/agents/architect-permission.adversarial.test.d.ts +5 -0
  27. package/dist/agents/architect.commands-list.adversarial.test.d.ts +1 -0
  28. package/dist/agents/architect.commands-list.test.d.ts +1 -0
  29. package/dist/agents/architect.d.ts +57 -0
  30. package/dist/agents/architect.dark-matter.test.d.ts +1 -0
  31. package/dist/agents/architect.designer-gate.test.d.ts +1 -0
  32. package/dist/agents/coder.d.ts +2 -0
  33. package/dist/agents/council-member.d.ts +30 -0
  34. package/dist/agents/council-member.test.d.ts +8 -0
  35. package/dist/agents/council-moderator.d.ts +20 -0
  36. package/dist/agents/critic.d.ts +34 -0
  37. package/dist/agents/curator-agent.d.ts +14 -0
  38. package/dist/agents/designer.d.ts +2 -0
  39. package/dist/agents/docs.d.ts +2 -0
  40. package/dist/agents/explorer-consumer-contract.test.d.ts +1 -0
  41. package/dist/agents/explorer-role-boundary.test.d.ts +1 -0
  42. package/dist/agents/explorer.d.ts +5 -0
  43. package/dist/agents/index.d.ts +52 -0
  44. package/dist/agents/reviewer.d.ts +5 -0
  45. package/dist/agents/sme.d.ts +2 -0
  46. package/dist/agents/test-engineer.adversarial.test.d.ts +5 -0
  47. package/dist/agents/test-engineer.d.ts +2 -0
  48. package/dist/agents/test-engineer.security.test.d.ts +1 -0
  49. package/dist/background/circuit-breaker.d.ts +149 -0
  50. package/dist/background/event-bus.d.ts +60 -0
  51. package/dist/background/evidence-summary-integration.d.ts +73 -0
  52. package/dist/background/index.d.ts +22 -0
  53. package/dist/background/manager.d.ts +122 -0
  54. package/dist/background/plan-sync-worker.d.ts +122 -0
  55. package/dist/background/queue.d.ts +117 -0
  56. package/dist/background/status-artifact.d.ts +115 -0
  57. package/dist/background/trigger.d.ts +179 -0
  58. package/dist/background/trigger.vulnerability.test.d.ts +1 -0
  59. package/dist/background/worker.d.ts +92 -0
  60. package/dist/cli/index.d.ts +7 -0
  61. package/dist/cli/index.js +31227 -11423
  62. package/dist/commands/acknowledge-spec-drift.d.ts +5 -0
  63. package/dist/commands/brainstorm.d.ts +13 -0
  64. package/dist/commands/brainstorm.test.d.ts +1 -0
  65. package/dist/commands/checkpoint.d.ts +5 -0
  66. package/dist/commands/close.d.ts +11 -0
  67. package/dist/commands/command-adapters.security.test.d.ts +14 -0
  68. package/dist/commands/commands.test.d.ts +1 -0
  69. package/dist/commands/config.d.ts +5 -0
  70. package/dist/commands/council.d.ts +17 -0
  71. package/dist/commands/council.test.d.ts +4 -0
  72. package/dist/commands/curate.test.d.ts +1 -0
  73. package/dist/commands/doctor.d.ts +17 -0
  74. package/dist/commands/full-auto-config-guard.test.d.ts +7 -0
  75. package/dist/commands/full-auto-discoverability.test.d.ts +8 -0
  76. package/dist/commands/full-auto-registration.test.d.ts +5 -0
  77. package/dist/commands/full-auto-sessionid.test.d.ts +5 -0
  78. package/dist/commands/full-auto.d.ts +10 -0
  79. package/dist/commands/full-auto.regression.test.d.ts +10 -0
  80. package/dist/commands/full-auto.test.d.ts +6 -0
  81. package/dist/commands/index.d.ts +50 -0
  82. package/dist/commands/index.help-text.test.d.ts +1 -0
  83. package/dist/commands/issue.d.ts +13 -0
  84. package/dist/{knowledge.d.ts → commands/knowledge.d.ts} +2 -0
  85. package/dist/commands/pr-review.d.ts +11 -0
  86. package/dist/commands/qa-gates.d.ts +15 -0
  87. package/dist/commands/qa-gates.test.d.ts +1 -0
  88. package/dist/commands/registry-documentation.test.d.ts +1 -0
  89. package/dist/commands/registry-type.test.d.ts +1 -0
  90. package/dist/commands/registry.d.ts +282 -0
  91. package/dist/commands/reset-session.d.ts +7 -0
  92. package/dist/commands/shortcut-routing.test.d.ts +11 -0
  93. package/dist/{sync-plan.d.ts → commands/sync-plan.d.ts} +3 -1
  94. package/dist/commands/turbo-registration.test.d.ts +5 -0
  95. package/dist/commands/turbo-sessionid.test.d.ts +5 -0
  96. package/dist/commands/turbo.regression.test.d.ts +11 -0
  97. package/dist/commands/turbo.test.d.ts +5 -0
  98. package/dist/config/agent-categories.d.ts +12 -0
  99. package/dist/config/cache-paths.d.ts +11 -0
  100. package/dist/config/constants.architect-whitelist.test.d.ts +1 -0
  101. package/dist/config/constants.d.ts +72 -0
  102. package/dist/config/evidence-schema.d.ts +1352 -0
  103. package/dist/config/index.d.ts +11 -0
  104. package/dist/{config.d.ts → config/loader.d.ts} +11 -6
  105. package/dist/config/plan-schema.d.ts +191 -0
  106. package/dist/config/schema.d.ts +1078 -0
  107. package/dist/config/spec-schema.d.ts +113 -0
  108. package/dist/context/role-filter.d.ts +27 -0
  109. package/dist/context/zone-classifier.d.ts +17 -0
  110. package/dist/council/__tests__/council-evidence-writer.adversarial.test.d.ts +6 -0
  111. package/dist/council/council-advisory.d.ts +46 -0
  112. package/dist/council/council-evidence-writer.d.ts +18 -0
  113. package/dist/council/council-service.d.ts +21 -0
  114. package/dist/council/criteria-store.d.ts +9 -0
  115. package/dist/council/disagreement-detector.d.ts +24 -0
  116. package/dist/council/general-council-advisory.d.ts +29 -0
  117. package/dist/council/general-council-service.d.ts +22 -0
  118. package/dist/council/general-council-types.d.ts +98 -0
  119. package/dist/council/types.d.ts +126 -0
  120. package/dist/council/web-search-provider.d.ts +35 -0
  121. package/dist/db/global-db.d.ts +22 -0
  122. package/dist/db/global-db.test.d.ts +7 -0
  123. package/dist/db/index.d.ts +13 -0
  124. package/dist/db/project-db.d.ts +40 -0
  125. package/dist/db/project-db.test.d.ts +4 -0
  126. package/dist/db/qa-gate-profile.d.ts +107 -0
  127. package/dist/db/qa-gate-profile.test.d.ts +4 -0
  128. package/dist/diff/__tests__/semantic-classifier.test.d.ts +1 -0
  129. package/dist/diff/__tests__/summary-generator.test.d.ts +1 -0
  130. package/dist/diff/ast-diff.d.ts +21 -0
  131. package/dist/diff/semantic-classifier.d.ts +59 -0
  132. package/dist/diff/summary-generator.d.ts +33 -0
  133. package/dist/environment/index.d.ts +3 -0
  134. package/dist/environment/profile.d.ts +50 -0
  135. package/dist/environment/prompt-renderer.d.ts +6 -0
  136. package/dist/evidence/index.d.ts +2 -0
  137. package/dist/evidence/lock.d.ts +36 -0
  138. package/dist/evidence/manager.d.ts +78 -0
  139. package/dist/gate-evidence.d.ts +69 -0
  140. package/dist/gate-evidence.test.d.ts +1 -0
  141. package/dist/git/branch.d.ts +70 -0
  142. package/dist/git/index.d.ts +22 -0
  143. package/dist/git/pr.d.ts +28 -0
  144. package/dist/graph/graph-builder.d.ts +39 -0
  145. package/dist/graph/graph-query.d.ts +42 -0
  146. package/dist/graph/graph-store.d.ts +27 -0
  147. package/dist/graph/import-extractor.d.ts +44 -0
  148. package/dist/graph/index.d.ts +16 -0
  149. package/dist/graph/symbol-extractor.d.ts +17 -0
  150. package/dist/graph/types.d.ts +84 -0
  151. package/dist/hooks/__tests__/semantic-diff-injection.test.d.ts +1 -0
  152. package/dist/hooks/adversarial-detector.d.ts +50 -0
  153. package/dist/hooks/agent-activity.d.ts +38 -0
  154. package/dist/hooks/co-change-suggester.d.ts +51 -0
  155. package/dist/hooks/compaction-customizer.d.ts +11 -0
  156. package/dist/hooks/conflict-resolution.d.ts +12 -0
  157. package/dist/hooks/context-budget.d.ts +34 -0
  158. package/dist/hooks/context-scoring.d.ts +70 -0
  159. package/dist/hooks/curator-drift-advisory.test.d.ts +1 -0
  160. package/dist/hooks/curator-drift.d.ts +30 -0
  161. package/dist/hooks/curator-llm-factory.d.ts +20 -0
  162. package/dist/hooks/curator-types.d.ts +103 -0
  163. package/dist/hooks/curator.d.ts +108 -0
  164. package/dist/hooks/dark-matter-detector.d.ts +38 -0
  165. package/dist/hooks/delegation-gate.d.ts +78 -0
  166. package/dist/hooks/delegation-gate.evidence.test.d.ts +4 -0
  167. package/dist/hooks/delegation-gate.getEvidenceTaskId.test.d.ts +20 -0
  168. package/dist/hooks/delegation-gate.plan-fallback-security.test.d.ts +13 -0
  169. package/dist/hooks/delegation-gate.plan-fallback.test.d.ts +5 -0
  170. package/dist/hooks/delegation-gate.seed-state.test.d.ts +1 -0
  171. package/dist/hooks/delegation-gate.turbo-evidence.test.d.ts +8 -0
  172. package/dist/hooks/delegation-gate.verify.test.d.ts +11 -0
  173. package/dist/hooks/delegation-ledger.d.ts +37 -0
  174. package/dist/hooks/delegation-ledger.test.d.ts +11 -0
  175. package/dist/hooks/delegation-sanitizer.d.ts +24 -0
  176. package/dist/hooks/delegation-tracker.d.ts +15 -0
  177. package/dist/hooks/diff-scope.d.ts +12 -0
  178. package/dist/hooks/diff-scope.test.d.ts +1 -0
  179. package/dist/hooks/extractors.d.ts +53 -0
  180. package/dist/hooks/full-auto-intercept.d.ts +77 -0
  181. package/dist/hooks/guardrails.d.ts +174 -0
  182. package/dist/hooks/hive-promoter.d.ts +40 -0
  183. package/dist/hooks/incremental-verify.d.ts +34 -0
  184. package/dist/hooks/incremental-verify.test.d.ts +1 -0
  185. package/dist/hooks/index.d.ts +20 -0
  186. package/dist/hooks/knowledge-curator.d.ts +27 -0
  187. package/dist/hooks/knowledge-injector.d.ts +20 -0
  188. package/dist/hooks/knowledge-migrator.d.ts +11 -0
  189. package/dist/hooks/knowledge-reader.d.ts +22 -0
  190. package/dist/hooks/knowledge-store.d.ts +30 -0
  191. package/dist/hooks/knowledge-types.d.ts +131 -0
  192. package/dist/hooks/knowledge-validator.d.ts +29 -0
  193. package/dist/hooks/loop-detector.d.ts +17 -0
  194. package/dist/hooks/loop-detector.test.d.ts +1 -0
  195. package/dist/hooks/message-priority.d.ts +105 -0
  196. package/dist/hooks/messages-transform.d.ts +13 -0
  197. package/dist/hooks/model-limits.d.ts +96 -0
  198. package/dist/hooks/normalize-tool-name.d.ts +25 -0
  199. package/dist/hooks/phase-monitor.d.ts +29 -0
  200. package/dist/hooks/pipeline-tracker.d.ts +41 -0
  201. package/dist/hooks/repo-graph-builder.d.ts +32 -0
  202. package/dist/hooks/repo-graph-injection.d.ts +45 -0
  203. package/dist/hooks/review-receipt.d.ts +189 -0
  204. package/dist/hooks/scope-guard-throw-behavior.test.d.ts +15 -0
  205. package/dist/hooks/scope-guard.adversarial.test.d.ts +1 -0
  206. package/dist/hooks/scope-guard.d.ts +43 -0
  207. package/dist/hooks/scope-guard.test.d.ts +14 -0
  208. package/dist/hooks/self-review.d.ts +14 -0
  209. package/dist/hooks/self-review.test.d.ts +14 -0
  210. package/dist/hooks/semantic-diff-injection.d.ts +24 -0
  211. package/dist/hooks/slop-detector.adversarial.test.d.ts +1 -0
  212. package/dist/hooks/slop-detector.d.ts +17 -0
  213. package/dist/hooks/slop-detector.test.d.ts +1 -0
  214. package/dist/hooks/spawn-helper.d.ts +5 -0
  215. package/dist/hooks/spawn-helper.test.d.ts +1 -0
  216. package/dist/hooks/steering-consumed.d.ts +30 -0
  217. package/dist/hooks/system-enhancer.d.ts +30 -0
  218. package/dist/hooks/tool-summarizer.d.ts +28 -0
  219. package/dist/hooks/trajectory-logger.d.ts +69 -0
  220. package/dist/hooks/utils.d.ts +20 -0
  221. package/dist/hooks/watchdog.integration.test.d.ts +9 -0
  222. package/dist/index.adversarial-bootstrap.test.d.ts +1 -0
  223. package/dist/index.bootstrap-adversarial.test.d.ts +1 -0
  224. package/dist/index.bootstrap-directory.test.d.ts +1 -0
  225. package/dist/index.d.ts +8 -1
  226. package/dist/index.js +74704 -47714
  227. package/dist/knowledge/identity.d.ts +25 -0
  228. package/dist/knowledge/index.d.ts +2 -0
  229. package/dist/lang/detector.d.ts +20 -0
  230. package/dist/lang/framework-detector.d.ts +98 -0
  231. package/dist/lang/grammars/tree-sitter-dart.wasm +0 -0
  232. package/dist/lang/grammars/tree-sitter-kotlin.wasm +0 -0
  233. package/dist/lang/grammars/tree-sitter-swift.wasm +0 -0
  234. package/dist/lang/grammars/tree-sitter.wasm +0 -0
  235. package/dist/lang/index.d.ts +4 -0
  236. package/dist/lang/profiles.d.ts +72 -0
  237. package/dist/lang/registry.d.ts +24 -0
  238. package/dist/lang/runtime.d.ts +35 -0
  239. package/dist/model-fallback.adversarial.test.d.ts +22 -0
  240. package/dist/model-fallback.test.d.ts +12 -0
  241. package/dist/mutation/__tests__/engine.adversarial.test.d.ts +1 -0
  242. package/dist/mutation/__tests__/engine.test.d.ts +1 -0
  243. package/dist/mutation/__tests__/equivalence.adversarial.test.d.ts +1 -0
  244. package/dist/mutation/__tests__/equivalence.test.d.ts +1 -0
  245. package/dist/mutation/__tests__/gate.adversarial.test.d.ts +1 -0
  246. package/dist/mutation/__tests__/gate.test.d.ts +1 -0
  247. package/dist/mutation/__tests__/generator.test.d.ts +1 -0
  248. package/dist/mutation/engine.d.ts +47 -0
  249. package/dist/mutation/equivalence.d.ts +35 -0
  250. package/dist/mutation/gate.d.ts +28 -0
  251. package/dist/mutation/generator.d.ts +16 -0
  252. package/dist/output/agent-writer.d.ts +27 -0
  253. package/dist/output/index.d.ts +1 -0
  254. package/dist/parallel/dependency-graph.d.ts +34 -0
  255. package/dist/parallel/dispatcher/index.d.ts +12 -0
  256. package/dist/parallel/dispatcher/noop-dispatcher.d.ts +18 -0
  257. package/dist/parallel/dispatcher/noop-dispatcher.test.d.ts +10 -0
  258. package/dist/parallel/dispatcher/parallel-dispatcher.d.ts +18 -0
  259. package/dist/parallel/dispatcher/types.d.ts +33 -0
  260. package/dist/parallel/file-locks.d.ts +40 -0
  261. package/dist/parallel/index.d.ts +5 -0
  262. package/dist/parallel/meta-indexer.d.ts +32 -0
  263. package/dist/parallel/review-router.d.ts +29 -0
  264. package/dist/plan/checkpoint.d.ts +25 -0
  265. package/dist/plan/checkpoint.test.d.ts +1 -0
  266. package/dist/plan/index.d.ts +1 -0
  267. package/dist/plan/ledger-integrity.test.d.ts +5 -0
  268. package/dist/plan/ledger-snapshot-adversarial.test.d.ts +1 -0
  269. package/dist/plan/ledger.d.ts +286 -0
  270. package/dist/plan/ledger.test.d.ts +1 -0
  271. package/dist/plan/manager.cas-backoff.test.d.ts +10 -0
  272. package/dist/plan/manager.d.ts +90 -0
  273. package/dist/plan/manager.ledger-aware.test.d.ts +1 -0
  274. package/dist/plan/manager.loadplan-validation-guard.test.d.ts +13 -0
  275. package/dist/plan/manager.update-task-status.test.d.ts +1 -0
  276. package/dist/plan/migration-revert.regression.test.d.ts +8 -0
  277. package/dist/prm/__tests__/course-correction.test.d.ts +1 -0
  278. package/dist/prm/__tests__/escalation-queue-drain.test.d.ts +1 -0
  279. package/dist/prm/__tests__/escalation.test.d.ts +1 -0
  280. package/dist/prm/__tests__/index.test.d.ts +1 -0
  281. package/dist/prm/__tests__/integration.test.d.ts +1 -0
  282. package/dist/prm/__tests__/pattern-detector.test.d.ts +5 -0
  283. package/dist/prm/__tests__/replay.test.d.ts +1 -0
  284. package/dist/prm/__tests__/trajectory-store.test.d.ts +7 -0
  285. package/dist/prm/course-correction.d.ts +20 -0
  286. package/dist/prm/escalation.d.ts +73 -0
  287. package/dist/prm/index.d.ts +58 -0
  288. package/dist/prm/pattern-detector.d.ts +71 -0
  289. package/dist/prm/replay.d.ts +44 -0
  290. package/dist/prm/trajectory-store.d.ts +66 -0
  291. package/dist/prm/types.d.ts +120 -0
  292. package/dist/quality/index.d.ts +1 -0
  293. package/dist/quality/metrics.d.ts +25 -0
  294. package/dist/sast/rules/c.d.ts +9 -0
  295. package/dist/sast/rules/csharp.d.ts +9 -0
  296. package/dist/sast/rules/go.d.ts +9 -0
  297. package/dist/sast/rules/index.d.ts +72 -0
  298. package/dist/sast/rules/java.d.ts +9 -0
  299. package/dist/sast/rules/javascript.d.ts +9 -0
  300. package/dist/sast/rules/php.d.ts +9 -0
  301. package/dist/sast/rules/python.d.ts +9 -0
  302. package/dist/sast/semgrep.d.ts +68 -0
  303. package/dist/sast/semgrep.test.d.ts +1 -0
  304. package/dist/sbom/cyclonedx.d.ts +101 -0
  305. package/dist/sbom/detectors/dart.d.ts +7 -0
  306. package/dist/sbom/detectors/dotnet.d.ts +7 -0
  307. package/dist/sbom/detectors/go.d.ts +7 -0
  308. package/dist/sbom/detectors/index.d.ts +53 -0
  309. package/dist/sbom/detectors/java.d.ts +7 -0
  310. package/dist/sbom/detectors/nodejs.d.ts +7 -0
  311. package/dist/sbom/detectors/python.d.ts +7 -0
  312. package/dist/sbom/detectors/rust.d.ts +7 -0
  313. package/dist/sbom/detectors/swift.d.ts +7 -0
  314. package/dist/scope/scope-persistence.d.ts +109 -0
  315. package/dist/scope/scope-persistence.test.d.ts +13 -0
  316. package/dist/services/compaction-service.d.ts +28 -0
  317. package/dist/services/compaction-service.test.d.ts +1 -0
  318. package/dist/services/config-doctor.d.ts +125 -0
  319. package/dist/services/config-doctor.security.test.d.ts +1 -0
  320. package/dist/services/config-doctor.test.d.ts +1 -0
  321. package/dist/services/context-budget-service.d.ts +101 -0
  322. package/dist/services/decision-drift-analyzer.d.ts +96 -0
  323. package/dist/services/diagnose-service.d.ts +41 -0
  324. package/dist/services/evidence-service.d.ts +65 -0
  325. package/dist/services/evidence-summary-service.d.ts +75 -0
  326. package/dist/services/export-service.d.ts +30 -0
  327. package/dist/services/handoff-service.d.ts +74 -0
  328. package/dist/services/history-service.d.ts +35 -0
  329. package/dist/services/index.d.ts +13 -0
  330. package/dist/services/plan-service.d.ts +25 -0
  331. package/dist/services/preflight-integration.d.ts +38 -0
  332. package/dist/services/preflight-service.d.ts +62 -0
  333. package/dist/services/run-memory.d.ts +66 -0
  334. package/dist/services/status-service.d.ts +35 -0
  335. package/dist/services/status-service.turbo-indicator.test.d.ts +5 -0
  336. package/dist/services/tool-doctor.d.ts +26 -0
  337. package/dist/services/tool-doctor.test.d.ts +1 -0
  338. package/dist/services/version-check.d.ts +28 -0
  339. package/dist/services/warning-buffer.d.ts +9 -0
  340. package/dist/session/snapshot-reader.d.ts +37 -0
  341. package/dist/session/snapshot-writer.d.ts +115 -0
  342. package/dist/skills/index.d.ts +30 -0
  343. package/dist/state/agent-run-context.d.ts +24 -0
  344. package/dist/state.agent-run-context.test.d.ts +10 -0
  345. package/dist/state.d.ts +501 -1
  346. package/dist/state.rehydrate.test.d.ts +1 -0
  347. package/dist/state.rehydration-adversarial.test.d.ts +1 -0
  348. package/dist/state.rehydration-integration.test.d.ts +1 -0
  349. package/dist/state.session-restart.test.d.ts +7 -0
  350. package/dist/summaries/index.d.ts +2 -0
  351. package/dist/summaries/manager.d.ts +29 -0
  352. package/dist/summaries/summarizer.d.ts +38 -0
  353. package/dist/telemetry.d.ts +59 -0
  354. package/dist/telemetry.test.d.ts +1 -0
  355. package/dist/test-impact/__tests__/analyzer-import-fix.adversarial.test.d.ts +1 -0
  356. package/dist/test-impact/__tests__/analyzer-import-fix.test.d.ts +1 -0
  357. package/dist/test-impact/__tests__/analyzer.adversarial.test.d.ts +1 -0
  358. package/dist/test-impact/__tests__/analyzer.test.d.ts +1 -0
  359. package/dist/test-impact/__tests__/council-fixes.test.d.ts +1 -0
  360. package/dist/test-impact/__tests__/failure-classifier.adversarial.test.d.ts +1 -0
  361. package/dist/test-impact/__tests__/failure-classifier.test.d.ts +1 -0
  362. package/dist/test-impact/__tests__/flaky-detector.adversarial.test.d.ts +1 -0
  363. package/dist/test-impact/__tests__/flaky-detector.test.d.ts +1 -0
  364. package/dist/test-impact/__tests__/history-store.adversarial.test.d.ts +1 -0
  365. package/dist/test-impact/__tests__/history-store.test.d.ts +1 -0
  366. package/dist/test-impact/__tests__/test-impact.adversarial.test.d.ts +1 -0
  367. package/dist/test-impact/__tests__/test-impact.test.d.ts +1 -0
  368. package/dist/test-impact/analyzer.d.ts +9 -0
  369. package/dist/test-impact/failure-classifier.d.ts +26 -0
  370. package/dist/test-impact/flaky-detector.d.ts +14 -0
  371. package/dist/test-impact/history-store.d.ts +15 -0
  372. package/dist/tools/__tests__/barrel-exports.test.d.ts +1 -0
  373. package/dist/tools/__tests__/diff-ast-fallback.test.d.ts +1 -0
  374. package/dist/tools/__tests__/diff-markdown-summary.test.d.ts +1 -0
  375. package/dist/tools/__tests__/diff-semantic.test.d.ts +1 -0
  376. package/dist/tools/__tests__/diff-summary.adversarial.test.d.ts +1 -0
  377. package/dist/tools/__tests__/diff-summary.test.d.ts +1 -0
  378. package/dist/tools/__tests__/mutation-test.adversarial.test.d.ts +1 -0
  379. package/dist/tools/__tests__/mutation-test.sourcefiles.test.d.ts +1 -0
  380. package/dist/tools/__tests__/mutation-test.test.d.ts +1 -0
  381. package/dist/tools/__tests__/test-runner-history.test.d.ts +1 -0
  382. package/dist/tools/__tests__/test-runner-impact.adversarial.test.d.ts +1 -0
  383. package/dist/tools/__tests__/test-runner-impact.test.d.ts +1 -0
  384. package/dist/tools/__tests__/test-runner-source-files.test.d.ts +1 -0
  385. package/dist/tools/barrel-export-check-gate-status.test.d.ts +6 -0
  386. package/dist/tools/batch-symbols.d.ts +24 -0
  387. package/dist/tools/batch-symbols.test.d.ts +1 -0
  388. package/dist/tools/build-check.d.ts +50 -0
  389. package/dist/tools/check-gate-status.adversarial.test.d.ts +1 -0
  390. package/dist/tools/check-gate-status.d.ts +7 -0
  391. package/dist/tools/check-gate-status.gates.test.d.ts +1 -0
  392. package/dist/tools/check-gate-status.plugin-registration.test.d.ts +1 -0
  393. package/dist/tools/checkpoint.d.ts +2 -0
  394. package/dist/tools/co-change-analyzer.d.ts +45 -0
  395. package/dist/tools/completion-verify.d.ts +25 -0
  396. package/dist/tools/complexity-hotspots.d.ts +2 -0
  397. package/dist/tools/convene-council.d.ts +53 -0
  398. package/dist/tools/convene-general-council.d.ts +25 -0
  399. package/dist/{create-tool.d.ts → tools/create-tool.d.ts} +13 -1
  400. package/dist/tools/curator-analyze.d.ts +7 -0
  401. package/dist/tools/curator-analyze.test.d.ts +1 -0
  402. package/dist/tools/declare-council-criteria.d.ts +14 -0
  403. package/dist/tools/declare-scope.d.ts +50 -0
  404. package/dist/tools/diff-summary.d.ts +12 -0
  405. package/dist/tools/diff.d.ts +24 -0
  406. package/dist/tools/doc-scan.d.ts +38 -0
  407. package/dist/tools/domain-detector.d.ts +6 -0
  408. package/dist/tools/evidence-check.d.ts +8 -0
  409. package/dist/tools/file-extractor.d.ts +9 -0
  410. package/dist/tools/generate-mutants.d.ts +15 -0
  411. package/dist/tools/get-approved-plan.d.ts +55 -0
  412. package/dist/tools/get-qa-gate-profile.d.ts +27 -0
  413. package/dist/tools/gitingest.d.ts +18 -0
  414. package/dist/tools/imports.d.ts +5 -0
  415. package/dist/tools/index.d.ts +66 -0
  416. package/dist/tools/knowledge-add.d.ts +2 -0
  417. package/dist/tools/knowledge-query.d.ts +5 -0
  418. package/dist/tools/knowledge-recall.d.ts +2 -0
  419. package/dist/tools/knowledge-remove.d.ts +2 -0
  420. package/dist/tools/knowledge-tools.integration.test.d.ts +1 -0
  421. package/dist/tools/lint-spec.d.ts +2 -0
  422. package/dist/tools/lint.d.ts +63 -0
  423. package/dist/tools/mutation-test.d.ts +2 -0
  424. package/dist/tools/mutation-test.security.test.d.ts +1 -0
  425. package/dist/tools/phase-complete.d.ts +25 -0
  426. package/dist/tools/pkg-audit.d.ts +2 -0
  427. package/dist/tools/placeholder-scan.d.ts +28 -0
  428. package/dist/tools/plugin-registration-adversarial.test.d.ts +1 -0
  429. package/dist/tools/pre-check-batch.d.ts +89 -0
  430. package/dist/tools/quality-budget.d.ts +26 -0
  431. package/dist/tools/repo-graph.d.ts +226 -0
  432. package/dist/tools/repo-map.d.ts +2 -0
  433. package/dist/tools/req-coverage.d.ts +47 -0
  434. package/dist/tools/resolve-working-directory.d.ts +35 -0
  435. package/dist/tools/resolve-working-directory.test.d.ts +1 -0
  436. package/dist/tools/retrieve-summary.d.ts +2 -0
  437. package/dist/tools/sast-baseline.d.ts +126 -0
  438. package/dist/tools/sast-scan.d.ts +87 -0
  439. package/dist/tools/save-plan.d.ts +95 -0
  440. package/dist/tools/save-plan.subdirectory-rejection.test.d.ts +1 -0
  441. package/dist/tools/sbom-generate.d.ts +26 -0
  442. package/dist/tools/schema-drift.d.ts +2 -0
  443. package/dist/tools/search.adversarial.test.d.ts +1 -0
  444. package/dist/tools/search.d.ts +29 -0
  445. package/dist/tools/search.test.d.ts +1 -0
  446. package/dist/tools/secretscan.d.ts +35 -0
  447. package/dist/tools/set-qa-gates.d.ts +40 -0
  448. package/dist/tools/suggest-patch.adversarial.test.d.ts +1 -0
  449. package/dist/tools/suggest-patch.d.ts +37 -0
  450. package/dist/tools/suggest-patch.test.d.ts +1 -0
  451. package/dist/tools/symbols.d.ts +21 -0
  452. package/dist/tools/syntax-check.d.ts +37 -0
  453. package/dist/tools/test-impact.d.ts +2 -0
  454. package/dist/tools/test-runner.d.ts +86 -0
  455. package/dist/tools/test-runner.security-adversarial.test.d.ts +5 -0
  456. package/dist/tools/todo-extract.d.ts +2 -0
  457. package/dist/tools/tool-names.d.ts +10 -0
  458. package/dist/tools/update-task-status.adversarial.test.d.ts +13 -0
  459. package/dist/tools/update-task-status.d.ts +114 -0
  460. package/dist/tools/update-task-status.gates.test.d.ts +1 -0
  461. package/dist/tools/update-task-status.test.d.ts +1 -0
  462. package/dist/tools/update-task-status.turbo-bypass.test.d.ts +1 -0
  463. package/dist/tools/verify-six-tools-registration.test.d.ts +9 -0
  464. package/dist/tools/web-search.d.ts +13 -0
  465. package/dist/tools/write-drift-evidence.d.ts +31 -0
  466. package/dist/tools/write-hallucination-evidence.d.ts +30 -0
  467. package/dist/tools/write-mutation-evidence.d.ts +34 -0
  468. package/dist/tools/write-mutation-evidence.test.d.ts +1 -0
  469. package/dist/tools/write-retro.d.ts +55 -0
  470. package/dist/transient-retry.test.d.ts +10 -0
  471. package/dist/types/delegation.d.ts +24 -0
  472. package/dist/types/events.d.ts +125 -0
  473. package/dist/utils/errors.d.ts +33 -0
  474. package/dist/utils/gitignore-warning.d.ts +17 -0
  475. package/dist/utils/index.d.ts +4 -0
  476. package/dist/utils/logger.d.ts +3 -0
  477. package/dist/utils/merge.d.ts +5 -0
  478. package/dist/utils/path-security.d.ts +36 -0
  479. package/dist/utils/regex.d.ts +30 -0
  480. package/dist/utils/spec-hash.d.ts +15 -0
  481. package/dist/utils/tool-output.d.ts +12 -0
  482. package/dist/validation/task-id.d.ts +43 -0
  483. package/package.json +21 -14
  484. package/dist/architect.d.ts +0 -7
  485. package/dist/checkpoint.d.ts +0 -7
  486. package/dist/co-change-analyzer.d.ts +0 -1
  487. package/dist/compat.d.ts +0 -12
  488. package/dist/config-doctor.d.ts +0 -1
  489. package/dist/detector.d.ts +0 -7
  490. package/dist/diagnose-service.d.ts +0 -1
  491. package/dist/doctor.d.ts +0 -5
  492. package/dist/evidence-schema.d.ts +0 -2
  493. package/dist/evidence-service.d.ts +0 -1
  494. package/dist/export-service.d.ts +0 -1
  495. package/dist/handoff-service.d.ts +0 -1
  496. package/dist/history-service.d.ts +0 -1
  497. package/dist/hive-promoter.d.ts +0 -2
  498. package/dist/knowledge-migrator.d.ts +0 -2
  499. package/dist/knowledge-store.d.ts +0 -1
  500. package/dist/knowledge-types.d.ts +0 -1
  501. package/dist/knowledge-validator.d.ts +0 -2
  502. package/dist/loader.d.ts +0 -1
  503. package/dist/manager.d.ts +0 -1
  504. package/dist/models.d.ts +0 -1
  505. package/dist/plan-service.d.ts +0 -1
  506. package/dist/preflight-service.d.ts +0 -1
  507. package/dist/profiles.d.ts +0 -7
  508. package/dist/register.d.ts +0 -36
  509. package/dist/schema.d.ts +0 -2
  510. package/dist/snapshot-writer.d.ts +0 -1
  511. package/dist/status-service.d.ts +0 -15
  512. package/dist/telemetry/src/events.d.ts +0 -308
  513. package/dist/telemetry/src/guards.d.ts +0 -14
  514. package/dist/telemetry/src/index.d.ts +0 -4
  515. package/dist/telemetry/src/version.d.ts +0 -1
  516. package/dist/utils.d.ts +0 -1
  517. package/dist/write-retro.d.ts +0 -1
  518. /package/dist/{discovery.d.ts → build/discovery.d.ts} +0 -0
  519. /package/dist/{agents.d.ts → commands/agents.d.ts} +0 -0
  520. /package/dist/{analyze.d.ts → commands/analyze.d.ts} +0 -0
  521. /package/dist/{archive.d.ts → commands/archive.d.ts} +0 -0
  522. /package/dist/{benchmark.d.ts → commands/benchmark.d.ts} +0 -0
  523. /package/dist/{clarify.d.ts → commands/clarify.d.ts} +0 -0
  524. /package/dist/{curate.d.ts → commands/curate.d.ts} +0 -0
  525. /package/dist/{dark-matter.d.ts → commands/dark-matter.d.ts} +0 -0
  526. /package/dist/{diagnose.d.ts → commands/diagnose.d.ts} +0 -0
  527. /package/dist/{evidence.d.ts → commands/evidence.d.ts} +0 -0
  528. /package/dist/{export.d.ts → commands/export.d.ts} +0 -0
  529. /package/dist/{handoff.d.ts → commands/handoff.d.ts} +0 -0
  530. /package/dist/{history.d.ts → commands/history.d.ts} +0 -0
  531. /package/dist/{plan.d.ts → commands/plan.d.ts} +0 -0
  532. /package/dist/{preflight.d.ts → commands/preflight.d.ts} +0 -0
  533. /package/dist/{promote.d.ts → commands/promote.d.ts} +0 -0
  534. /package/dist/{reset.d.ts → commands/reset.d.ts} +0 -0
  535. /package/dist/{retrieve.d.ts → commands/retrieve.d.ts} +0 -0
  536. /package/dist/{rollback.d.ts → commands/rollback.d.ts} +0 -0
  537. /package/dist/{simulate.d.ts → commands/simulate.d.ts} +0 -0
  538. /package/dist/{specify.d.ts → commands/specify.d.ts} +0 -0
  539. /package/dist/{status.d.ts → commands/status.d.ts} +0 -0
  540. /package/dist/{turbo.d.ts → commands/turbo.d.ts} +0 -0
  541. /package/dist/{write_retro.d.ts → commands/write-retro.d.ts} +0 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Message Priority Classifier Hook
3
+ *
4
+ * Provides zero-cost message priority classification to enable intelligent
5
+ * context pruning. Messages are tagged with priority tiers (0-4) so that
6
+ * low-priority messages are removed first during context budget pressure.
7
+ *
8
+ * Priority tiers:
9
+ * - CRITICAL (0): System prompt, plan state, active instructions
10
+ * - HIGH (1): User messages, current task context, tool definitions
11
+ * - MEDIUM (2): Recent assistant responses, recent tool results
12
+ * - LOW (3): Old assistant responses, old tool results, confirmations
13
+ * - DISPOSABLE (4): Duplicate reads, superseded writes, stale errors
14
+ */
15
+ /**
16
+ * Message priority tiers for context pruning decisions.
17
+ * Lower values = higher priority (kept longer during pruning).
18
+ */
19
+ export declare const MessagePriority: {
20
+ /** System prompt, plan state, active instructions - never prune */
21
+ readonly CRITICAL: 0;
22
+ /** User messages, current task context, tool definitions */
23
+ readonly HIGH: 1;
24
+ /** Recent assistant responses, recent tool results (within recentWindowSize) */
25
+ readonly MEDIUM: 2;
26
+ /** Old assistant responses, old tool results */
27
+ readonly LOW: 3;
28
+ /** Duplicate reads, superseded writes, stale errors - prune first */
29
+ readonly DISPOSABLE: 4;
30
+ };
31
+ export type MessagePriorityType = (typeof MessagePriority)[keyof typeof MessagePriority];
32
+ /** Message structure matching the format from context-budget.ts */
33
+ interface MessageInfo {
34
+ role?: string;
35
+ agent?: string;
36
+ sessionID?: string;
37
+ modelID?: string;
38
+ providerID?: string;
39
+ toolName?: string;
40
+ toolArgs?: unknown;
41
+ [key: string]: unknown;
42
+ }
43
+ interface MessagePart {
44
+ type?: string;
45
+ text?: string;
46
+ [key: string]: unknown;
47
+ }
48
+ export interface MessageWithParts {
49
+ info?: MessageInfo;
50
+ parts?: MessagePart[];
51
+ }
52
+ /**
53
+ * Checks if text contains .swarm/plan or .swarm/context references
54
+ * indicating swarm state that should be preserved.
55
+ *
56
+ * @param text - The text content to check
57
+ * @returns true if the text contains plan/context references
58
+ */
59
+ export declare function containsPlanContent(text: string): boolean;
60
+ /**
61
+ * Checks if a message is a tool result (assistant message with tool call).
62
+ *
63
+ * @param message - The message to check
64
+ * @returns true if the message appears to be a tool result
65
+ */
66
+ export declare function isToolResult(message: MessageWithParts): boolean;
67
+ /**
68
+ * Checks if two consecutive tool read calls are duplicates
69
+ * (same tool with same first argument).
70
+ *
71
+ * @param current - The current message
72
+ * @param previous - The previous message
73
+ * @returns true if this is a duplicate tool read
74
+ */
75
+ export declare function isDuplicateToolRead(current: MessageWithParts, previous: MessageWithParts): boolean;
76
+ /**
77
+ * Checks if a message contains an error pattern and is stale
78
+ * (more than the specified number of turns old).
79
+ *
80
+ * @param text - The message text to check
81
+ * @param turnsAgo - How many turns ago the message was sent
82
+ * @returns true if the message is a stale error
83
+ */
84
+ export declare function isStaleError(text: string, turnsAgo: number): boolean;
85
+ /**
86
+ * Classifies a message by priority tier for intelligent pruning.
87
+ *
88
+ * @param message - The message to classify
89
+ * @param index - Position in messages array (0-indexed)
90
+ * @param totalMessages - Total number of messages
91
+ * @param recentWindowSize - Number of recent messages to consider MEDIUM (default 10)
92
+ * @returns Priority tier (0=CRITICAL, 1=HIGH, 2=MEDIUM, 3=LOW, 4=DISPOSABLE)
93
+ */
94
+ export declare function classifyMessage(message: MessageWithParts, index: number, totalMessages: number, recentWindowSize?: number): MessagePriorityType;
95
+ /**
96
+ * Classifies a batch of messages with duplicate detection.
97
+ * This function should be called in order (oldest to newest) to properly
98
+ * detect consecutive duplicate tool reads.
99
+ *
100
+ * @param messages - Array of messages to classify
101
+ * @param recentWindowSize - Number of recent messages to consider MEDIUM (default 10)
102
+ * @returns Array of priority classifications matching message order
103
+ */
104
+ export declare function classifyMessages(messages: MessageWithParts[], recentWindowSize?: number): MessagePriorityType[];
105
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Consolidates multiple system messages into a single system message at index 0.
3
+ *
4
+ * Note: Merged content order matches original insertion order (OpenCode base prompt
5
+ * first, then swarm agent prompt) - this assumes sequential message construction.
6
+ */
7
+ type Message = {
8
+ role: string;
9
+ content: unknown;
10
+ [key: string]: unknown;
11
+ };
12
+ export declare function consolidateSystemMessages(messages: Message[]): Message[];
13
+ export {};
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Provider-Aware Model Limit Resolution
3
+ *
4
+ * Resolves context window limits based on the model and provider platform.
5
+ * The same model has different context limits depending on the provider:
6
+ * - Claude Sonnet 4.6: 200k native, 128k on Copilot
7
+ * - GPT-5: 400k native, 128k on Copilot
8
+ * - Copilot caps ALL models at 128k prompt, regardless of native limit
9
+ */
10
+ /**
11
+ * Native model context limits (in tokens) when used on their native platform.
12
+ */
13
+ export declare const NATIVE_MODEL_LIMITS: Record<string, number>;
14
+ /**
15
+ * Provider-specific context caps that override native limits.
16
+ * These are typically lower than native limits (e.g., Copilot caps at 128k).
17
+ */
18
+ export declare const PROVIDER_CAPS: Record<string, number>;
19
+ /**
20
+ * Message structure from experimental.chat.messages.transform hook.
21
+ */
22
+ interface MessageInfo {
23
+ role: string;
24
+ agent?: string;
25
+ sessionID?: string;
26
+ modelID?: string;
27
+ providerID?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ interface MessagePart {
31
+ type: string;
32
+ text?: string;
33
+ [key: string]: unknown;
34
+ }
35
+ interface MessageWithParts {
36
+ info: MessageInfo;
37
+ parts: MessagePart[];
38
+ }
39
+ /**
40
+ * Extracts modelID and providerID from the most recent assistant message.
41
+ *
42
+ * @param messages - Array of messages from experimental.chat.messages.transform hook
43
+ * @returns Object containing modelID and/or providerID if found
44
+ *
45
+ * @example
46
+ * const info = extractModelInfo(messages);
47
+ * // Returns: { modelID: 'claude-sonnet-4-6', providerID: 'anthropic' }
48
+ * // Or: {} if no assistant messages or fields not found
49
+ */
50
+ export declare function extractModelInfo(messages: MessageWithParts[]): {
51
+ modelID?: string;
52
+ providerID?: string;
53
+ };
54
+ /**
55
+ * Resolves the context limit for a given model/provider combination.
56
+ *
57
+ * Resolution order (first match wins):
58
+ * 1. Check configOverrides["provider/model"] (e.g., "copilot/claude-sonnet-4-6": 200000)
59
+ * 2. Check configOverrides[modelID] (e.g., "claude-sonnet-4-6": 200000)
60
+ * 3. Check PROVIDER_CAPS[providerID] (e.g., copilot → 128000)
61
+ * 4. Check NATIVE_MODEL_LIMITS with prefix matching (e.g., "claude-sonnet-4" matches "claude-sonnet-4-6-20260301")
62
+ * 5. Check configOverrides.default
63
+ * 6. Fall back to 128000
64
+ *
65
+ * @param modelID - The model identifier (e.g., "claude-sonnet-4-6", "gpt-5")
66
+ * @param providerID - The provider identifier (e.g., "copilot", "anthropic")
67
+ * @param configOverrides - User configuration overrides
68
+ * @returns The resolved context limit in tokens
69
+ *
70
+ * @example
71
+ * // Provider cap (copilot)
72
+ * resolveModelLimit("claude-sonnet-4-6", "copilot", {})
73
+ * // Returns: 128000
74
+ *
75
+ * @example
76
+ * // Native limit (anthropic)
77
+ * resolveModelLimit("claude-sonnet-4-6", "anthropic", {})
78
+ * // Returns: 200000
79
+ *
80
+ * @example
81
+ * // Override beats cap
82
+ * resolveModelLimit("gpt-5", "copilot", { "copilot/gpt-5": 200000 })
83
+ * // Returns: 200000
84
+ *
85
+ * @example
86
+ * // Prefix match for model variants
87
+ * resolveModelLimit("claude-sonnet-4-6-20260301", "anthropic", {})
88
+ * // Returns: 200000
89
+ *
90
+ * @example
91
+ * // Full fallback
92
+ * resolveModelLimit(undefined, undefined, {})
93
+ * // Returns: 128000
94
+ */
95
+ export declare function resolveModelLimit(modelID?: string, providerID?: string, configOverrides?: Record<string, number>): number;
96
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Canonical tool-name normalization helpers
3
+ *
4
+ * Strip namespace prefixes (e.g., "mega:write", "mega.search") to get the base tool name.
5
+ */
6
+ /**
7
+ * Strip namespace prefix from a tool name.
8
+ *
9
+ * Examples:
10
+ * "opencode:write" → "write"
11
+ * "opencode.bash" → "bash"
12
+ * "write" → "write"
13
+ * undefined/null → undefined
14
+ */
15
+ export declare function normalizeToolName(toolName: string): string;
16
+ export declare function normalizeToolName(toolName: null | undefined): string | undefined;
17
+ /**
18
+ * Strip namespace prefix and lowercase the result.
19
+ *
20
+ * Examples:
21
+ * "opencode:WRITE" → "write"
22
+ * "opencode.bash" → "bash"
23
+ * "write" → "write"
24
+ */
25
+ export declare function normalizeToolNameLowerCase(toolName: string): string;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Phase Monitor Hook
3
+ *
4
+ * Detects phase transitions by reading plan state on each system prompt transform.
5
+ * When a phase change is detected, triggers preflight via PreflightTriggerManager.
6
+ * Wrapped in safeHook — errors must never propagate.
7
+ */
8
+ import type { PreflightTriggerManager } from '../background/trigger';
9
+ import { type CuratorLLMDelegate } from './curator';
10
+ import type { CuratorConfig, CuratorInitResult } from './curator-types';
11
+ /** Injectable curator runner type — allows test injection without module mocking. */
12
+ export type CuratorInitRunner = (directory: string, config: CuratorConfig, llmDelegate?: CuratorLLMDelegate) => Promise<CuratorInitResult>;
13
+ /** Factory that creates a CuratorLLMDelegate for a given session — enables session-aware resolution. */
14
+ export type CuratorDelegateFactory = (sessionId?: string) => CuratorLLMDelegate | undefined;
15
+ /**
16
+ * Creates a hook that monitors plan phase transitions and triggers preflight.
17
+ *
18
+ * @param directory - Project directory (where .swarm/ lives)
19
+ * @param preflightManager - Optional PreflightTriggerManager to call on phase change.
20
+ * When undefined, preflight checks are skipped but curator initialization still runs
21
+ * at session start (useful when knowledge.enabled but phase_preflight is disabled).
22
+ * @param curatorRunner - Optional curator init runner (defaults to runCuratorInit; injectable for tests)
23
+ * @param delegateFactory - Optional factory that creates a CuratorLLMDelegate for the calling session.
24
+ * Called lazily at hook invocation time with the session ID extracted from the hook input,
25
+ * enabling correct multi-swarm curator resolution. For test injection of a pre-built delegate,
26
+ * pass `() => myDelegate`.
27
+ * @returns A safeHook-wrapped system.transform handler
28
+ */
29
+ export declare function createPhaseMonitorHook(directory: string, preflightManager?: PreflightTriggerManager, curatorRunner?: CuratorInitRunner, delegateFactory?: CuratorDelegateFactory): (input: unknown, output: unknown) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Pipeline Tracker Hook
3
+ *
4
+ * Injects phase reminders into messages to keep the Architect on track.
5
+ * Uses experimental.chat.messages.transform so it doesn't show in UI.
6
+ *
7
+ * Research: "LLMs Get Lost In Multi-Turn Conversation" shows ~40% compliance
8
+ * drop after 2-3 turns without reminders.
9
+ */
10
+ import type { PluginConfig } from '../config';
11
+ /**
12
+ * Build dynamic phase reminder with compliance escalation based on phase number.
13
+ * Counteracts temporal compliance decay discovered during field testing.
14
+ */
15
+ export declare function buildPhaseReminder(phaseNumber: number | null): string;
16
+ interface MessageInfo {
17
+ role: string;
18
+ agent?: string;
19
+ sessionID?: string;
20
+ }
21
+ interface MessagePart {
22
+ type: string;
23
+ text?: string;
24
+ [key: string]: unknown;
25
+ }
26
+ interface MessageWithParts {
27
+ info: MessageInfo;
28
+ parts: MessagePart[];
29
+ }
30
+ /**
31
+ * Creates the experimental.chat.messages.transform hook for pipeline tracking.
32
+ * Only injects for the architect agent.
33
+ */
34
+ export declare function createPipelineTrackerHook(config: PluginConfig, directory?: string): {
35
+ 'experimental.chat.messages.transform'?: undefined;
36
+ } | {
37
+ 'experimental.chat.messages.transform': (input: Record<string, never>, output: {
38
+ messages?: MessageWithParts[];
39
+ }) => Promise<void>;
40
+ };
41
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Repo Graph Builder Hook
3
+ *
4
+ * Startup hook that builds or refreshes the repo dependency graph when a session starts.
5
+ * Write-trigger hook that incrementally updates the graph when write tools are called.
6
+ * Wrapped in try/catch — failures are logged but never block plugin initialization.
7
+ */
8
+ import { type RepoGraph } from '../tools/repo-graph';
9
+ export interface RepoGraphBuilderHook {
10
+ init(): Promise<void>;
11
+ toolAfter(input: {
12
+ tool: string;
13
+ sessionID: string;
14
+ args?: unknown;
15
+ }, output: {
16
+ output?: unknown;
17
+ args?: unknown;
18
+ }): Promise<void>;
19
+ }
20
+ export interface RepoGraphDeps {
21
+ buildWorkspaceGraph: (workspace: string, options?: {
22
+ maxFileSizeBytes?: number;
23
+ maxFiles?: number;
24
+ }) => RepoGraph;
25
+ saveGraph: (workspace: string, graph: RepoGraph, options?: {
26
+ createAtomic?: boolean;
27
+ }) => Promise<void>;
28
+ updateGraphForFiles: (workspace: string, files: string[], options?: {
29
+ forceRebuild?: boolean;
30
+ }) => Promise<RepoGraph>;
31
+ }
32
+ export declare function createRepoGraphBuilderHook(workspaceRoot: string, deps?: Partial<RepoGraphDeps>): RepoGraphBuilderHook;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Repo graph context injection for the system-enhancer hook.
3
+ *
4
+ * Produces compact text blocks that surface structural information
5
+ * (importers, dependents, blast radius) for the file the agent is about
6
+ * to edit. Designed to fit within the system-enhancer's per-block budget
7
+ * (~300-500 chars).
8
+ *
9
+ * Failure mode: silent. If no graph exists (`.swarm/repo-graph.json`
10
+ * absent or invalid), this module returns `null` for every helper —
11
+ * the agent simply doesn't get the extra context. The graph is built
12
+ * on-demand by the agent calling `repo_map` with action="build".
13
+ *
14
+ * Caching: the loaded graph is cached per-directory in module scope to
15
+ * avoid re-reading the JSON on every system prompt construction. The
16
+ * cache is bypassed if the file's mtime advances.
17
+ */
18
+ import { type RepoGraph } from '../graph';
19
+ /**
20
+ * Load the repo graph for `directory`, using a per-directory cache that
21
+ * invalidates on file mtime change. Returns null if no graph exists.
22
+ *
23
+ * Exported only for tests; production callers use the buildXxxBlock helpers below.
24
+ */
25
+ export declare function getCachedGraph(directory: string): RepoGraph | null;
26
+ /** Test-only: clear the per-directory cache. */
27
+ export declare function resetGraphInjectionCache(): void;
28
+ /**
29
+ * Build a localization block for a target file. Used by the coder agent
30
+ * to surface importers/dependencies/blast-radius before editing.
31
+ *
32
+ * Returns null when:
33
+ * - No graph exists.
34
+ * - The target isn't tracked in the graph (file too new, language unsupported).
35
+ */
36
+ export declare function buildCoderLocalizationBlock(directory: string, targetFile: string): string | null;
37
+ /**
38
+ * Build a blast-radius block for a list of changed files. Used by the
39
+ * reviewer agent to spot-check whether unseen consumers might break.
40
+ *
41
+ * Returns null when no graph exists or when none of the files are in the
42
+ * graph. The result is bounded to the top 8 dependents to stay within
43
+ * the per-block context budget.
44
+ */
45
+ export declare function buildReviewerBlastRadiusBlock(directory: string, changedFiles: string[]): string | null;
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Review receipt persistence for opencode-swarm.
3
+ *
4
+ * Persists reviewer and curator review receipts to disk so that future
5
+ * re-reviews and drift verification have durable evidence of prior judgments.
6
+ *
7
+ * Two receipt types:
8
+ * RejectedReviewReceipt — full-detail artifact with blocking findings,
9
+ * exact evidence refs, scope fingerprint/hash,
10
+ * and re-review pass conditions.
11
+ * ApprovedReviewReceipt — compact artifact with what was checked, claims
12
+ * validated, scope fingerprint, and caveats.
13
+ *
14
+ * Storage: .swarm/review-receipts/<YYYY-MM-DD>-<id>.json (one file per receipt)
15
+ * .swarm/review-receipts/index.json (manifest for fast lookup)
16
+ *
17
+ * Staleness: receipts are invalidated when the scope fingerprint changes
18
+ * materially (any character-level change to the canonical diff/hash).
19
+ * Consumers MUST check isScopeStale() before trusting an approved receipt.
20
+ *
21
+ * Critic drift verification can consume prior receipts as supporting context
22
+ * but MUST NOT blindly trust them — staleness check is mandatory.
23
+ */
24
+ export type ReceiptVerdict = 'rejected' | 'approved';
25
+ /** Identity of the reviewer/curator that produced the receipt. */
26
+ export interface ReviewerIdentity {
27
+ /** Agent name (e.g. 'reviewer', 'critic', 'curator') */
28
+ agent: string;
29
+ /** Optional session ID for traceability */
30
+ session_id?: string;
31
+ }
32
+ /** A canonical fingerprint/hash of the reviewed scope or diff. */
33
+ export interface ScopeFingerprint {
34
+ /** SHA-256 hex digest of the canonical scope content */
35
+ hash: string;
36
+ /** Short description of what was hashed (e.g. 'git-diff', 'file-content', 'spec-md') */
37
+ scope_description: string;
38
+ /** Length of the original content in characters */
39
+ content_length: number;
40
+ }
41
+ /** A blocking finding recorded in a rejected review. */
42
+ export interface BlockingFinding {
43
+ /** File path (relative) or identifier */
44
+ location: string;
45
+ /** One-line summary of the finding */
46
+ summary: string;
47
+ /** Line number if applicable */
48
+ line?: number;
49
+ /** Severity: 'critical' | 'high' | 'medium' */
50
+ severity: 'critical' | 'high' | 'medium';
51
+ }
52
+ /**
53
+ * Rejected review receipt.
54
+ * Full-detail artifact. Persisted for re-review reference.
55
+ */
56
+ export interface RejectedReviewReceipt {
57
+ schema_version: 1;
58
+ id: string;
59
+ receipt_type: 'rejected';
60
+ verdict: 'rejected';
61
+ /** Reviewer/curator that produced this receipt */
62
+ reviewer: ReviewerIdentity;
63
+ /** ISO 8601 timestamp */
64
+ reviewed_at: string;
65
+ /** Fingerprint of the reviewed scope */
66
+ scope_fingerprint: ScopeFingerprint;
67
+ /** Blocking findings that caused rejection */
68
+ blocking_findings: BlockingFinding[];
69
+ /** Exact evidence references (file paths, line numbers, etc.) */
70
+ evidence_references: string[];
71
+ /** Conditions that must be met for a re-review to pass */
72
+ pass_conditions: string[];
73
+ /** Optional free-text summary */
74
+ summary?: string;
75
+ }
76
+ /**
77
+ * Approved review receipt.
78
+ * Compact artifact. Supporting evidence, not durable proof.
79
+ */
80
+ export interface ApprovedReviewReceipt {
81
+ schema_version: 1;
82
+ id: string;
83
+ receipt_type: 'approved';
84
+ verdict: 'approved';
85
+ /** Reviewer/curator that produced this receipt */
86
+ reviewer: ReviewerIdentity;
87
+ /** ISO 8601 timestamp */
88
+ reviewed_at: string;
89
+ /** Fingerprint of the reviewed scope */
90
+ scope_fingerprint: ScopeFingerprint;
91
+ /** What aspects were checked (e.g. ['security', 'correctness', 'test coverage']) */
92
+ checked_aspects: string[];
93
+ /** Claims that were validated during review */
94
+ validated_claims: string[];
95
+ /** Residual risk or caveats */
96
+ caveats?: string[];
97
+ }
98
+ export type ReviewReceipt = RejectedReviewReceipt | ApprovedReviewReceipt;
99
+ /** Index entry for fast lookup without reading every receipt file. */
100
+ export interface ReceiptIndexEntry {
101
+ id: string;
102
+ verdict: ReceiptVerdict;
103
+ reviewed_at: string;
104
+ scope_hash: string;
105
+ agent: string;
106
+ filename: string;
107
+ }
108
+ /** Receipt index manifest stored in .swarm/review-receipts/index.json */
109
+ export interface ReceiptIndex {
110
+ schema_version: 1;
111
+ entries: ReceiptIndexEntry[];
112
+ }
113
+ /** Returns the .swarm/review-receipts/ directory path. */
114
+ export declare function resolveReceiptsDir(directory: string): string;
115
+ /** Returns the index file path. */
116
+ export declare function resolveReceiptIndexPath(directory: string): string;
117
+ /**
118
+ * Compute a SHA-256 scope fingerprint for a given content string.
119
+ * The hash is deterministic: same content → same hash.
120
+ */
121
+ export declare function computeScopeFingerprint(content: string, scopeDescription: string): ScopeFingerprint;
122
+ /**
123
+ * Returns true if the current scope content is materially different from
124
+ * the fingerprint recorded in the receipt. Any character-level change to the
125
+ * canonical content (same scopeDescription) invalidates the receipt.
126
+ *
127
+ * If `currentContent` is undefined (scope no longer available), the receipt
128
+ * is treated as stale (conservative: assume the scope has changed).
129
+ */
130
+ export declare function isScopeStale(receipt: ReviewReceipt, currentContent: string | undefined): boolean;
131
+ /**
132
+ * Persist a review receipt (rejected or approved) to disk.
133
+ * Creates .swarm/review-receipts/<date>-<id>.json and updates the index.
134
+ * Returns the absolute path of the written receipt file.
135
+ */
136
+ export declare function persistReviewReceipt(directory: string, receipt: ReviewReceipt): Promise<string>;
137
+ /**
138
+ * Read a single receipt by ID. Returns null if not found or unreadable.
139
+ */
140
+ export declare function readReceiptById(directory: string, receiptId: string): Promise<ReviewReceipt | null>;
141
+ /**
142
+ * Read all receipts for a given scope hash (latest first).
143
+ * Useful for drift verification to find prior reviews of the same scope.
144
+ */
145
+ export declare function readReceiptsByScopeHash(directory: string, scopeHash: string): Promise<ReviewReceipt[]>;
146
+ /**
147
+ * Read all receipts from the index (all verdicts, latest first).
148
+ * Useful for drift verification context.
149
+ */
150
+ export declare function readAllReceipts(directory: string): Promise<ReviewReceipt[]>;
151
+ /**
152
+ * Build a RejectedReviewReceipt.
153
+ * `scopeContent` is hashed to produce the fingerprint.
154
+ */
155
+ export declare function buildRejectedReceipt(opts: {
156
+ agent: string;
157
+ sessionId?: string;
158
+ scopeContent: string;
159
+ scopeDescription: string;
160
+ blockingFindings: BlockingFinding[];
161
+ evidenceReferences: string[];
162
+ passConditions: string[];
163
+ summary?: string;
164
+ }): RejectedReviewReceipt;
165
+ /**
166
+ * Build an ApprovedReviewReceipt.
167
+ * `scopeContent` is hashed to produce the fingerprint.
168
+ */
169
+ export declare function buildApprovedReceipt(opts: {
170
+ agent: string;
171
+ sessionId?: string;
172
+ scopeContent: string;
173
+ scopeDescription: string;
174
+ checkedAspects: string[];
175
+ validatedClaims: string[];
176
+ caveats?: string[];
177
+ }): ApprovedReviewReceipt;
178
+ /**
179
+ * Build a structured context summary of prior receipts for critic drift
180
+ * verification. Returns a compact string that can be injected into context.
181
+ *
182
+ * Approved receipts that are scope-stale are flagged explicitly so the critic
183
+ * knows they are supporting evidence only, not proof of current state.
184
+ *
185
+ * @param receipts - Array of prior receipts (from readAllReceipts or readReceiptsByScopeHash)
186
+ * @param currentScopeContent - Optional current scope content for staleness check
187
+ * @param maxChars - Maximum output length (default 1000)
188
+ */
189
+ export declare function buildReceiptContextForDrift(receipts: ReviewReceipt[], currentScopeContent?: string, maxChars?: number): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Smoke test: documents the confirmed behavior that tool.execute.before hook
3
+ * throws propagate as tool rejection, not session crash.
4
+ *
5
+ * VERIFIED from src/hooks/guardrails.ts existing patterns:
6
+ * - Loop circuit breaker (count >= 5): throw new Error('CIRCUIT BREAKER...')
7
+ * - Full test suite block: throw new Error('BLOCKED: Full test suite...')
8
+ * - Plan state violation: throw new Error('PLAN STATE VIOLATION...')
9
+ * All throw in toolBefore, and the plugin propagates as tool rejection.
10
+ *
11
+ * SAFE MECHANISM for scope-guard.ts:
12
+ * throw new Error(`SCOPE VIOLATION: [agent] attempted to modify [file] not in task [id] scope`)
13
+ * This is the CORRECT blocking pattern. DO NOT use return-value signals.
14
+ */
15
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * SCOPE GUARD (v6.31 Task 3.1)
3
+ *
4
+ * CONFIRMED THROW MECHANISM: throwing in tool.execute.before propagates as tool rejection,
5
+ * NOT as session crash. Verified from guardrails.ts multiple existing throw sites.
6
+ * Safe blocking pattern: throw new Error(`SCOPE VIOLATION: ...`)
7
+ *
8
+ * Fires BEFORE write/edit tools execute. When a non-architect agent attempts to
9
+ * modify a file outside the declared task scope, blocks the call and injects an advisory.
10
+ */
11
+ /**
12
+ * Configuration for scope guard behavior.
13
+ */
14
+ export interface ScopeGuardConfig {
15
+ /** Whether scope guard is enabled (default: true) */
16
+ enabled: boolean;
17
+ /** Whether to skip in turbo mode (default: false — NOT skippable by design) */
18
+ skip_in_turbo: boolean;
19
+ }
20
+ /**
21
+ * Creates the scope-guard hook that blocks out-of-scope writes.
22
+ * @param config - ScopeGuardConfig (enabled, skip_in_turbo)
23
+ * @param _directory - The workspace directory (reserved for future use)
24
+ * @param injectAdvisory - Optional callback to push advisory to architect session
25
+ */
26
+ export declare function createScopeGuardHook(config: Partial<ScopeGuardConfig>, directory: string, injectAdvisory?: (sessionId: string, message: string) => void): {
27
+ toolBefore: (input: {
28
+ tool: string;
29
+ sessionID: string;
30
+ callID: string;
31
+ }, output: {
32
+ args: unknown;
33
+ }) => Promise<void>;
34
+ };
35
+ /**
36
+ * Check if a file path is within declared scope entries.
37
+ * Handles exact match and directory containment.
38
+ *
39
+ * @param filePath - The file path to check
40
+ * @param scopeEntries - Array of declared scope entries (files or directories)
41
+ * @returns true if the file is within scope, false otherwise
42
+ */
43
+ export declare function isFileInScope(filePath: string, scopeEntries: string[], directory?: string): boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * scope-guard.test.ts
3
+ *
4
+ * Tests for scope-guard hook (Task 3.1):
5
+ * 1. Returns early (no throw) when guard is disabled (config.enabled = false)
6
+ * 2. Returns early when tool is not in WRITE_TOOLS set (e.g., 'read')
7
+ * 3. Returns early when session is the architect (agentName = 'Architect')
8
+ * 4. Returns early when declaredCoderScope is null (no scope declared)
9
+ * 5. Throws 'SCOPE VIOLATION' when non-architect writes file outside declared scope
10
+ * 6. Does NOT throw when non-architect writes file INSIDE declared scope
11
+ * 7. Sanitizes path with \r\n to prevent log injection (SEC-1 fix)
12
+ * 8. isFileInScope correctly handles exact match and directory containment
13
+ */
14
+ export {};
@@ -0,0 +1,14 @@
1
+ export interface SelfReviewConfig {
2
+ enabled: boolean;
3
+ skip_in_turbo: boolean;
4
+ }
5
+ export declare function createSelfReviewHook(config: Partial<SelfReviewConfig>, injectAdvisory: (sessionId: string, message: string) => void): {
6
+ toolAfter: (input: {
7
+ tool: string;
8
+ sessionID: string;
9
+ callID: string;
10
+ }, output: {
11
+ args?: Record<string, unknown>;
12
+ output?: unknown;
13
+ }) => Promise<void>;
14
+ };