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,174 @@
1
+ /**
2
+ * Guardrails Hook Module
3
+ *
4
+ * Circuit breaker for runaway LLM agents. Monitors tool usage via OpenCode Plugin API hooks
5
+ * and implements two-layer protection:
6
+ * - Layer 1 (Soft Warning @ warning_threshold): Sets warning flag for messagesTransform to inject warning
7
+ * - Layer 2 (Hard Block @ 100%): Throws error in toolBefore to block further calls, injects STOP message
8
+ */
9
+ import * as path from 'node:path';
10
+ import { type AuthorityConfig, type GuardrailsConfig } from '../config/schema';
11
+ import { type FileZone } from '../context/zone-classifier';
12
+ /**
13
+ * Retrieves stored input args for a given callID.
14
+ * Used by other hooks (e.g., delegation-gate) to access tool input args.
15
+ * @param callID The callID to look up
16
+ * @returns The stored args or undefined if not found
17
+ */
18
+ export declare function getStoredInputArgs(callID: string): unknown | undefined;
19
+ /**
20
+ * Stores input args for a given callID.
21
+ * Used by guardrails toolBefore hook; may be used by other hooks if needed.
22
+ * @param callID The callID to store args under
23
+ * @param args The tool input args to store
24
+ */
25
+ export declare function setStoredInputArgs(callID: string, args: unknown): void;
26
+ /**
27
+ * Deletes stored input args for a given callID (cleanup after retrieval).
28
+ * @param callID The callID to delete
29
+ */
30
+ export declare function deleteStoredInputArgs(callID: string): void;
31
+ /**
32
+ * Redacts sensitive values from a shell command string before audit logging.
33
+ * Covers env-var assignments, CLI flags, Bearer/Basic auth, and -H header flags.
34
+ * Conservative: only redacts patterns with well-known secret-bearing names.
35
+ * Export allows unit testing without spinning up a full hooks factory.
36
+ */
37
+ export declare function redactShellCommand(cmd: string): string;
38
+ /**
39
+ * Creates guardrails hooks for circuit breaker protection
40
+ * @param directory Working directory from plugin init context (required)
41
+ * @param directoryOrConfig Guardrails configuration object (when passed as second arg, replaces legacy config param)
42
+ * @param config Guardrails configuration (optional)
43
+ * @returns Tool before/after hooks and messages transform hook
44
+ */
45
+ export declare function createGuardrailsHooks(directory: string, directoryOrConfig?: string | GuardrailsConfig, config?: GuardrailsConfig, authorityConfig?: AuthorityConfig): {
46
+ toolBefore: (input: {
47
+ tool: string;
48
+ sessionID: string;
49
+ callID: string;
50
+ }, output: {
51
+ args: unknown;
52
+ }) => Promise<void>;
53
+ toolAfter: (input: {
54
+ tool: string;
55
+ sessionID: string;
56
+ callID: string;
57
+ args?: Record<string, unknown>;
58
+ }, output: {
59
+ title: string;
60
+ output: string;
61
+ metadata: unknown;
62
+ }) => Promise<void>;
63
+ messagesTransform: (input: Record<string, never>, output: {
64
+ messages?: Array<{
65
+ info: {
66
+ role: string;
67
+ agent?: string;
68
+ sessionID?: string;
69
+ };
70
+ parts: Array<{
71
+ type: string;
72
+ text?: string;
73
+ [key: string]: unknown;
74
+ }>;
75
+ }>;
76
+ }) => Promise<void>;
77
+ };
78
+ /**
79
+ * Hashes tool arguments for repetition detection
80
+ * @param args Tool arguments to hash
81
+ * @returns Numeric hash (0 if hashing fails)
82
+ */
83
+ export declare function hashArgs(args: unknown): number;
84
+ /** A record of an agent attesting to (resolving/suppressing/deferring) a finding. */
85
+ export interface AttestationRecord {
86
+ findingId: string;
87
+ agent: string;
88
+ attestation: string;
89
+ action: 'resolve' | 'suppress' | 'defer';
90
+ timestamp: string;
91
+ }
92
+ /**
93
+ * Validates that an attestation string meets the minimum length requirement.
94
+ */
95
+ export declare function validateAttestation(attestation: string, _findingId: string, _agent: string, _action: 'resolve' | 'suppress' | 'defer'): {
96
+ valid: true;
97
+ } | {
98
+ valid: false;
99
+ reason: string;
100
+ };
101
+ /**
102
+ * Appends an attestation record to `.swarm/evidence/attestations.jsonl`.
103
+ */
104
+ export declare function recordAttestation(dir: string, record: AttestationRecord): Promise<void>;
105
+ /**
106
+ * Validates an attestation and, on success, records it; on failure, logs a rejection event.
107
+ */
108
+ export declare function validateAndRecordAttestation(dir: string, findingId: string, agent: string, attestation: string, action: 'resolve' | 'suppress' | 'defer'): Promise<{
109
+ valid: true;
110
+ } | {
111
+ valid: false;
112
+ reason: string;
113
+ }>;
114
+ /**
115
+ * Clears all guardrails caches.
116
+ * Use this for test isolation or when guardrails config reloads at runtime.
117
+ */
118
+ export declare function clearGuardrailsCaches(): void;
119
+ type AgentRule = {
120
+ readOnly?: boolean;
121
+ blockedExact?: string[];
122
+ allowedExact?: string[];
123
+ blockedPrefix?: string[];
124
+ allowedPrefix?: string[];
125
+ blockedZones?: FileZone[];
126
+ blockedGlobs?: string[];
127
+ allowedGlobs?: string[];
128
+ };
129
+ export declare const DEFAULT_AGENT_AUTHORITY_RULES: Record<string, AgentRule>;
130
+ /**
131
+ * Checks whether a write target path (or any ancestor strictly inside cwd)
132
+ * is a symlink. Writing through a symlink can redirect the write to a
133
+ * location outside the working directory, bypassing scope containment.
134
+ *
135
+ * The walk stops at cwd — cwd itself is NOT lstat'd. A user's chosen
136
+ * working directory may legitimately be reached via a symlink (e.g.,
137
+ * macOS's /tmp → /private/tmp), and that symlink does not constitute a
138
+ * redirect *within* the workspace. Only attacker-plantable symlinks
139
+ * BELOW cwd are relevant to this guard.
140
+ *
141
+ * ENOENT on any node in the chain is allowed — the file/dir doesn't exist yet.
142
+ * Any other lstat error (EPERM, EACCES, ENAMETOOLONG, …) fails closed:
143
+ * an unverifiable ancestor must not be written through, even if the OS
144
+ * would eventually reject the write. Defense-in-depth over optimism.
145
+ *
146
+ * @returns A block reason string if a symlink is detected, null if all clear.
147
+ */
148
+ export declare function checkWriteTargetForSymlink(targetPath: string, cwd: string): string | null;
149
+ /**
150
+ * Returns true when `targetAbsolute` and `cwdAbsolute` resolve to different
151
+ * filesystem roots. On POSIX this is always false (single root `/`); on
152
+ * Windows it is true when the two paths sit on different drive letters or
153
+ * different UNC roots — the symptom Codex flagged on PR #501, where
154
+ * `path.relative('C:\\repo', 'D:\\secret.txt')` returns the absolute
155
+ * `'D:\\secret.txt'` and slips past `startsWith('../')` containment.
156
+ *
157
+ * Exposed (and accepts an injectable `pathLib`) so the cross-drive guard
158
+ * is falsifiable on Linux CI without depending on a Windows runner: tests
159
+ * pass `path.win32` / `path.posix` directly.
160
+ */
161
+ export declare function isOnDifferentFilesystemRoot(targetAbsolute: string, cwdAbsolute: string, pathLib?: Pick<typeof path, 'parse'>): boolean;
162
+ /**
163
+ * Checks whether the given agent is authorised to write to the given file path.
164
+ */
165
+ export declare function checkFileAuthority(agentName: string, filePath: string, cwd: string, authorityConfig?: AuthorityConfig, options?: {
166
+ declaredScope?: string[] | null;
167
+ }): {
168
+ allowed: true;
169
+ } | {
170
+ allowed: false;
171
+ reason: string;
172
+ zone?: FileZone;
173
+ };
174
+ export {};
@@ -0,0 +1,40 @@
1
+ /** Hive promoter hook for opencode-swarm v6.17 two-tier knowledge system. */
2
+ import type { KnowledgeConfig, SwarmKnowledgeEntry } from './knowledge-types.js';
3
+ /** Hive promotion summary for curator state */
4
+ export interface HivePromotionSummary {
5
+ timestamp: string;
6
+ new_promotions: number;
7
+ encounters_incremented: number;
8
+ advancements: number;
9
+ total_hive_entries: number;
10
+ }
11
+ /**
12
+ * Main promotion logic: checks swarm entries and promotes eligible ones to hive.
13
+ * Also updates existing hive entries with new project confirmations.
14
+ * Returns a summary of the promotion activity for curator state.
15
+ *
16
+ * @note The 'hive-fast-track' tag is treated as privileged — it bypasses the
17
+ * 3-phase confirmation requirement. It should only be set by authorized tooling
18
+ * (inferTags() never produces it automatically).
19
+ */
20
+ export declare function checkHivePromotions(swarmEntries: SwarmKnowledgeEntry[], config: KnowledgeConfig): Promise<HivePromotionSummary>;
21
+ /**
22
+ * Create a hook that promotes swarm entries to the hive.
23
+ * The hook fires unconditionally - the caller decides when to invoke it.
24
+ */
25
+ export declare function createHivePromoterHook(directory: string, config: KnowledgeConfig): (input: unknown, output: unknown) => Promise<void>;
26
+ /**
27
+ * Promote a lesson directly to the hive (manual promotion).
28
+ * @param directory - Project directory
29
+ * @param lesson - The lesson text to promote
30
+ * @param category - Optional category (defaults to 'process')
31
+ * @returns Confirmation message
32
+ */
33
+ export declare function promoteToHive(directory: string, lesson: string, category?: string): Promise<string>;
34
+ /**
35
+ * Promote a lesson from swarm knowledge to hive.
36
+ * @param directory - Project directory
37
+ * @param lessonId - The ID of the lesson to promote from swarm
38
+ * @returns Confirmation message
39
+ */
40
+ export declare function promoteFromSwarm(directory: string, lessonId: string): Promise<string>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Incremental verification hook — runs a typecheck after each coder Task delegation.
3
+ * Fires in tool.execute.after when input.tool === 'Task' and the delegated agent was 'coder'.
4
+ * Advisory only — never blocks. 30-second hard timeout. Uses directory from context.
5
+ */
6
+ import type { IncrementalVerifyConfig } from '../config/schema';
7
+ export type { IncrementalVerifyConfig };
8
+ export { detectTypecheckCommand };
9
+ export interface IncrementalVerifyHook {
10
+ toolAfter: (input: {
11
+ tool: string;
12
+ sessionID: string;
13
+ args?: unknown;
14
+ }, output: {
15
+ output?: unknown;
16
+ args?: unknown;
17
+ }) => Promise<void>;
18
+ }
19
+ /** For test isolation — call in beforeEach/afterEach */
20
+ export declare function resetAdvisoryDedup(): void;
21
+ /**
22
+ * Detect the typecheck/build check command for the project.
23
+ * Returns { command, language } where command is null if no default checker exists,
24
+ * or null overall if no supported language is detected.
25
+ * Checks in order: TypeScript (package.json) → Go (go.mod) → Rust (Cargo.toml)
26
+ * → Python (pyproject.toml/requirements.txt/setup.py) → C# (*.csproj/*.sln)
27
+ * First match wins; package.json only short-circuits when TypeScript markers are present.
28
+ * Otherwise the function falls through to Go/Rust/Python/C# detection.
29
+ */
30
+ declare function detectTypecheckCommand(projectDir: string): {
31
+ command: string[] | null;
32
+ language: string;
33
+ } | null;
34
+ export declare function createIncrementalVerifyHook(config: IncrementalVerifyConfig, projectDir: string, injectMessage: (sessionId: string, message: string) => void): IncrementalVerifyHook;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ export { createAgentActivityHooks } from './agent-activity';
2
+ export { createCompactionCustomizerHook } from './compaction-customizer';
3
+ export { createContextBudgetHandler } from './context-budget';
4
+ export { createCuratorLLMDelegate } from './curator-llm-factory';
5
+ export { createDelegationGateHook } from './delegation-gate';
6
+ export { createDelegationSanitizerHook } from './delegation-sanitizer';
7
+ export { createDelegationTrackerHook } from './delegation-tracker';
8
+ export { extractCurrentPhase, extractCurrentPhaseFromPlan, extractCurrentTask, extractCurrentTaskFromPlan, extractDecisions, extractIncompleteTasks, extractIncompleteTasksFromPlan, extractPatterns, } from './extractors';
9
+ export { createFullAutoInterceptHook } from './full-auto-intercept';
10
+ export { checkFileAuthority, createGuardrailsHooks, DEFAULT_AGENT_AUTHORITY_RULES, } from './guardrails';
11
+ export { classifyMessage, classifyMessages, containsPlanContent, isDuplicateToolRead, isStaleError, isToolResult, MessagePriority, type MessagePriorityType, type MessageWithParts, } from './message-priority';
12
+ export { consolidateSystemMessages } from './messages-transform';
13
+ export { extractModelInfo, NATIVE_MODEL_LIMITS, PROVIDER_CAPS, resolveModelLimit, } from './model-limits';
14
+ export { type CuratorDelegateFactory, createPhaseMonitorHook, } from './phase-monitor';
15
+ export { createPipelineTrackerHook } from './pipeline-tracker';
16
+ export { createRepoGraphBuilderHook, type RepoGraphBuilderHook, } from './repo-graph-builder';
17
+ export { buildApprovedReceipt, buildReceiptContextForDrift, buildRejectedReceipt, persistReviewReceipt, readAllReceipts, readReceiptsByScopeHash, } from './review-receipt';
18
+ export { createSystemEnhancerHook } from './system-enhancer';
19
+ export { createToolSummarizerHook, resetSummaryIdCounter, } from './tool-summarizer';
20
+ export { composeHandlers, estimateTokens, readSwarmFileAsync, safeHook, validateSwarmPath, } from './utils';
@@ -0,0 +1,27 @@
1
+ /** Knowledge curator hook for opencode-swarm v6.17 two-tier knowledge system. */
2
+ import type { KnowledgeConfig } from './knowledge-types.js';
3
+ /**
4
+ * Check if the input is a write operation targeting an evidence file.
5
+ * Exported for testing purposes only.
6
+ */
7
+ export declare function isWriteToEvidenceFile(input: unknown): boolean;
8
+ /**
9
+ * Curate and store swarm knowledge entries from lessons.
10
+ * @returns Promise resolving to an object with counts of stored, skipped, and rejected lessons.
11
+ */
12
+ export declare function curateAndStoreSwarm(lessons: string[], projectName: string, phaseInfo: {
13
+ phase_number: number;
14
+ }, directory: string, config: KnowledgeConfig): Promise<{
15
+ stored: number;
16
+ skipped: number;
17
+ rejected: number;
18
+ }>;
19
+ /**
20
+ * Auto-promote swarm entries based on phase confirmations and age.
21
+ */
22
+ export declare function runAutoPromotion(directory: string, config: KnowledgeConfig): Promise<void>;
23
+ /**
24
+ * Create the knowledge curator hook.
25
+ * Watches for writes to .swarm/plan.md and extracts lessons from the retrospective section.
26
+ */
27
+ export declare function createKnowledgeCuratorHook(directory: string, config: KnowledgeConfig): (input: unknown, output: unknown) => Promise<void>;
@@ -0,0 +1,20 @@
1
+ /** Phase-Start Knowledge Injection Hook for opencode-swarm v6.17.
2
+ *
3
+ * Injects relevant knowledge (from both swarm + hive tiers) into the architect's
4
+ * context at phase start. Caches the injection text for re-injection after
5
+ * compaction. Skips for non-architect agents. Appends rejected-pattern warnings
6
+ * to prevent re-learning loops.
7
+ */
8
+ import type { KnowledgeConfig, MessageWithParts } from './knowledge-types.js';
9
+ /**
10
+ * Creates a knowledge injection hook that injects relevant knowledge into the
11
+ * architect's message context at phase start. Supports caching for re-injection
12
+ * after compaction.
13
+ *
14
+ * @param directory - The project directory containing .swarm/
15
+ * @param config - Knowledge system configuration
16
+ * @returns A hook function that injects knowledge into messages
17
+ */
18
+ export declare function createKnowledgeInjectorHook(directory: string, config: KnowledgeConfig): (input: Record<string, never>, output: {
19
+ messages?: MessageWithParts[];
20
+ }) => Promise<void>;
@@ -0,0 +1,11 @@
1
+ /** One-time migration from .swarm/context.md → .swarm/knowledge.jsonl for existing projects. */
2
+ import type { KnowledgeConfig } from './knowledge-types.js';
3
+ export interface MigrationResult {
4
+ migrated: boolean;
5
+ entriesMigrated: number;
6
+ entriesDropped: number;
7
+ entriesTotal: number;
8
+ skippedReason?: 'sentinel-exists' | 'no-context-file' | 'empty-context' | 'external-sentinel-exists';
9
+ }
10
+ export declare function migrateKnowledgeToExternal(_directory: string, _config: KnowledgeConfig): Promise<MigrationResult>;
11
+ export declare function migrateContextToKnowledge(directory: string, config: KnowledgeConfig): Promise<MigrationResult>;
@@ -0,0 +1,22 @@
1
+ /** Read path for the opencode-swarm v6.17 two-tier knowledge system.
2
+ * Merges swarm + hive knowledge, deduplicates (hive wins), ranks by composite score,
3
+ * and provides utility tracking.
4
+ */
5
+ import type { KnowledgeConfig, KnowledgeEntryBase } from './knowledge-types.js';
6
+ export interface ProjectContext {
7
+ projectName: string;
8
+ currentPhase: string;
9
+ techStack?: string[];
10
+ recentErrors?: string[];
11
+ }
12
+ export interface RankedEntry extends KnowledgeEntryBase {
13
+ tier: 'swarm' | 'hive';
14
+ relevanceScore: {
15
+ category: number;
16
+ confidence: number;
17
+ keywords: number;
18
+ };
19
+ finalScore: number;
20
+ }
21
+ export declare function readMergedKnowledge(directory: string, config: KnowledgeConfig, context?: ProjectContext): Promise<RankedEntry[]>;
22
+ export declare function updateRetrievalOutcome(directory: string, phaseInfo: string, phaseSucceeded: boolean): Promise<void>;
@@ -0,0 +1,30 @@
1
+ /** Core storage layer for the opencode-swarm v6.17 two-tier knowledge system. */
2
+ import type { KnowledgeEntryBase, RejectedLesson } from './knowledge-types.js';
3
+ export declare function getPlatformConfigDir(): string;
4
+ export declare function resolveSwarmKnowledgePath(directory: string): string;
5
+ export declare function resolveSwarmRejectedPath(directory: string): string;
6
+ export declare function resolveHiveKnowledgePath(): string;
7
+ export declare function resolveHiveRejectedPath(): string;
8
+ export declare function readKnowledge<T>(filePath: string): Promise<T[]>;
9
+ export declare function readRejectedLessons(directory: string): Promise<RejectedLesson[]>;
10
+ export declare function appendKnowledge<T>(filePath: string, entry: T): Promise<void>;
11
+ export declare function rewriteKnowledge<T>(filePath: string, entries: T[]): Promise<void>;
12
+ export declare function enforceKnowledgeCap<T>(filePath: string, maxEntries: number): Promise<void>;
13
+ export interface SweepResult {
14
+ scanned: number;
15
+ aged: number;
16
+ archived: number;
17
+ removed: number;
18
+ skipped_promoted: number;
19
+ }
20
+ export declare function sweepAgedEntries<T extends KnowledgeEntryBase>(filePath: string, defaultMaxPhases: number): Promise<SweepResult>;
21
+ export declare function sweepStaleTodos<T extends KnowledgeEntryBase>(filePath: string, todoMaxPhases: number): Promise<SweepResult>;
22
+ export declare function appendRejectedLesson(directory: string, lesson: RejectedLesson): Promise<void>;
23
+ export declare function normalize(text: string): string;
24
+ export declare function wordBigrams(text: string): Set<string>;
25
+ export declare function jaccardBigram(a: Set<string>, b: Set<string>): number;
26
+ export declare function findNearDuplicate<T extends {
27
+ lesson: string;
28
+ }>(candidate: string, entries: T[], threshold?: number): T | undefined;
29
+ export declare function computeConfidence(confirmedByCount: number, autoGenerated: boolean): number;
30
+ export declare function inferTags(lesson: string): string[];
@@ -0,0 +1,131 @@
1
+ /** Type definitions for the opencode-swarm v6.17 two-tier knowledge system. */
2
+ export type KnowledgeCategory = 'process' | 'architecture' | 'tooling' | 'security' | 'testing' | 'debugging' | 'performance' | 'integration' | 'todo' | 'other';
3
+ export interface PhaseConfirmationRecord {
4
+ phase_number: number;
5
+ confirmed_at: string;
6
+ project_name: string;
7
+ }
8
+ export interface ProjectConfirmationRecord {
9
+ project_name: string;
10
+ confirmed_at: string;
11
+ phase_number?: number;
12
+ }
13
+ export interface RetrievalOutcome {
14
+ applied_count: number;
15
+ succeeded_after_count: number;
16
+ failed_after_count: number;
17
+ last_applied_at?: string;
18
+ }
19
+ export interface KnowledgeEntryBase {
20
+ id: string;
21
+ tier: 'swarm' | 'hive';
22
+ lesson: string;
23
+ category: KnowledgeCategory;
24
+ tags: string[];
25
+ scope: string;
26
+ confidence: number;
27
+ status: 'candidate' | 'established' | 'promoted' | 'archived';
28
+ confirmed_by: PhaseConfirmationRecord[] | ProjectConfirmationRecord[];
29
+ retrieval_outcomes: RetrievalOutcome;
30
+ schema_version: number;
31
+ created_at: string;
32
+ updated_at: string;
33
+ hive_eligible?: boolean;
34
+ auto_generated?: boolean;
35
+ phases_alive?: number;
36
+ max_phases?: number;
37
+ }
38
+ export interface SwarmKnowledgeEntry extends KnowledgeEntryBase {
39
+ tier: 'swarm';
40
+ confirmed_by: PhaseConfirmationRecord[];
41
+ project_name: string;
42
+ }
43
+ export interface HiveKnowledgeEntry extends KnowledgeEntryBase {
44
+ tier: 'hive';
45
+ confirmed_by: ProjectConfirmationRecord[];
46
+ source_project: string;
47
+ /** Weighted encounter score for hive advancement. Starts at 1.0 for originating project. */
48
+ encounter_score: number;
49
+ /** @deprecated Legacy field for backward compatibility. Use encounter_score for weighting. */
50
+ encounter_count?: number;
51
+ }
52
+ export interface RejectedLesson {
53
+ id: string;
54
+ lesson: string;
55
+ rejection_reason: string;
56
+ rejected_at: string;
57
+ rejection_layer: 1 | 2 | 3;
58
+ }
59
+ export interface KnowledgeConfig {
60
+ /** Enable or disable the entire knowledge system. Default: true */
61
+ enabled: boolean;
62
+ /** Maximum entries to keep in swarm knowledge.jsonl. Default: 100 */
63
+ swarm_max_entries: number;
64
+ /** Maximum entries to keep in hive shared-learnings.jsonl. Default: 200 */
65
+ hive_max_entries: number;
66
+ /** Days before auto-promotion to hive tier. Default: 90 */
67
+ auto_promote_days: number;
68
+ /** Maximum knowledge entries to inject per architect message. Default: 5 */
69
+ max_inject_count: number;
70
+ /** Maximum total chars for the entire injection block. Default: 2000 */
71
+ inject_char_budget?: number;
72
+ /** Minimum headroom chars required before knowledge injection activates. Default: 300 */
73
+ context_budget_threshold?: number;
74
+ /** Maximum display chars per lesson at injection time. Default: 120 */
75
+ max_lesson_display_chars?: number;
76
+ /** Jaccard bigram similarity threshold for deduplication. Default: 0.6 */
77
+ dedup_threshold: number;
78
+ /** Scope filters to apply when reading knowledge. Default: ['global'] */
79
+ scope_filter: string[];
80
+ /** Enable hive (cross-project) tier reads and writes. Default: true */
81
+ hive_enabled: boolean;
82
+ /** Maximum rejected lesson fingerprints to retain. Default: 20 */
83
+ rejected_max_entries: number;
84
+ /** Enable validation gate before storing lessons. Default: true */
85
+ validation_enabled: boolean;
86
+ /** Confidence threshold for marking an entry evergreen. Default: 0.9 */
87
+ evergreen_confidence: number;
88
+ /** Utility score threshold for marking an entry evergreen. Default: 0.8 */
89
+ evergreen_utility: number;
90
+ /** Utility score at or below which an entry is considered low-utility. Default: 0.3 */
91
+ low_utility_threshold: number;
92
+ /** Minimum retrieval count before utility scoring begins. Default: 3 */
93
+ min_retrievals_for_utility: number;
94
+ /** JSONL schema version. Default: 1 */
95
+ schema_version: number;
96
+ /** Weighted scoring: multiplier for encounters from the source project. Default: 1.0 */
97
+ same_project_weight: number;
98
+ /** Weighted scoring: multiplier for encounters from other projects. Default: 0.5 */
99
+ cross_project_weight: number;
100
+ /** Weighted scoring: minimum encounter score floor. Default: 0.1 */
101
+ min_encounter_score: number;
102
+ /** Weighted scoring: initial score for newly promoted hive entries. Default: 1.0 */
103
+ initial_encounter_score: number;
104
+ /** Weighted scoring: score increment per encounter. Default: 0.1 */
105
+ encounter_increment: number;
106
+ /** Weighted scoring: maximum encounter score cap. Default: 10.0 */
107
+ max_encounter_score: number;
108
+ /** Default N-phase TTL for knowledge entries. Default: 10 */
109
+ default_max_phases: number;
110
+ /** N-phase TTL for 'todo' category entries. Default: 3 */
111
+ todo_max_phases: number;
112
+ /** Enable age-based sweep of knowledge entries. Default: true */
113
+ sweep_enabled: boolean;
114
+ }
115
+ export interface MessageInfo {
116
+ role: string;
117
+ agent?: string;
118
+ sessionID?: string;
119
+ modelID?: string;
120
+ providerID?: string;
121
+ [key: string]: unknown;
122
+ }
123
+ export interface MessagePart {
124
+ type: string;
125
+ text?: string;
126
+ [key: string]: unknown;
127
+ }
128
+ export interface MessageWithParts {
129
+ info: MessageInfo;
130
+ parts: MessagePart[];
131
+ }
@@ -0,0 +1,29 @@
1
+ /** Three-layer validation gate for the opencode-swarm v6.17 knowledge system. */
2
+ import type { KnowledgeCategory, KnowledgeEntryBase } from './knowledge-types.js';
3
+ export interface ValidationResult {
4
+ valid: boolean;
5
+ layer: 1 | 2 | 3 | null;
6
+ reason: string | null;
7
+ severity: 'error' | 'warning' | null;
8
+ }
9
+ export declare const DANGEROUS_COMMAND_PATTERNS: RegExp[];
10
+ export declare const SECURITY_DEGRADING_PATTERNS: RegExp[];
11
+ export declare const INVISIBLE_FORMAT_CHARS: RegExp;
12
+ export declare const INJECTION_PATTERNS: RegExp[];
13
+ export declare function validateLesson(candidate: string, existingLessons: string[], meta: {
14
+ category: KnowledgeCategory;
15
+ scope: string;
16
+ confidence: number;
17
+ }): ValidationResult;
18
+ export interface QuarantinedEntry extends KnowledgeEntryBase {
19
+ quarantine_reason: string;
20
+ quarantined_at: string;
21
+ reported_by: 'architect' | 'user' | 'auto';
22
+ }
23
+ export interface EntryHealthResult {
24
+ healthy: boolean;
25
+ concern?: string;
26
+ }
27
+ export declare function auditEntryHealth(entry: KnowledgeEntryBase): EntryHealthResult;
28
+ export declare function quarantineEntry(directory: string, entryId: string, reason: string, reportedBy: 'architect' | 'user' | 'auto'): Promise<void>;
29
+ export declare function restoreEntry(directory: string, entryId: string): Promise<void>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Loop detector for Task tool delegations.
3
+ * Tracks the last 10 delegation patterns per session using a sliding window.
4
+ * Detects loops when the same (toolName + targetAgent + firstArgKey) hash
5
+ * appears 3 or more consecutive times.
6
+ */
7
+ export interface LoopDetectResult {
8
+ looping: boolean;
9
+ count: number;
10
+ pattern: string;
11
+ }
12
+ /**
13
+ * Detect delegation loops for a session.
14
+ * Only tracks Task tool calls (agent delegations).
15
+ * Returns the current loop state after recording this call.
16
+ */
17
+ export declare function detectLoop(sessionId: string, toolName: string, args: unknown): LoopDetectResult;
@@ -0,0 +1 @@
1
+ export {};