goatcode-sh 0.0.1 → 0.1.2

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 (854) hide show
  1. package/.github/workflows/ci.yml +85 -0
  2. package/.github/workflows/release.yml +107 -0
  3. package/.opencode/plugins/goatcode.js +1 -0
  4. package/AGENTS.md +59 -0
  5. package/CONTRIBUTING.md +110 -0
  6. package/LICENSE +21 -0
  7. package/README.md +106 -12
  8. package/bun.lock +2081 -0
  9. package/bunfig.toml +3 -0
  10. package/dist/agents/advisor/config.d.ts +4 -0
  11. package/dist/agents/advisor/index.d.ts +2 -0
  12. package/dist/agents/advisor/plugin.d.ts +1 -0
  13. package/dist/agents/advisor/prompt-meta.d.ts +2 -0
  14. package/dist/agents/advisor/prompt.d.ts +1 -0
  15. package/dist/agents/agent-builder.d.ts +10 -0
  16. package/dist/agents/agent-registry.d.ts +8 -0
  17. package/dist/agents/builtin-agents.d.ts +2 -0
  18. package/dist/agents/deep-worker/config.d.ts +4 -0
  19. package/dist/agents/deep-worker/index.d.ts +2 -0
  20. package/dist/agents/deep-worker/plugin.d.ts +1 -0
  21. package/dist/agents/deep-worker/prompt-meta.d.ts +2 -0
  22. package/dist/agents/deep-worker/prompt.d.ts +1 -0
  23. package/dist/agents/explorer/config.d.ts +4 -0
  24. package/dist/agents/explorer/index.d.ts +2 -0
  25. package/dist/agents/explorer/plugin.d.ts +1 -0
  26. package/dist/agents/explorer/prompt-meta.d.ts +2 -0
  27. package/dist/agents/explorer/prompt.d.ts +1 -0
  28. package/dist/agents/fallback-chains.d.ts +2 -0
  29. package/dist/agents/index.d.ts +14 -0
  30. package/dist/agents/orchestrator/config.d.ts +4 -0
  31. package/dist/agents/orchestrator/index.d.ts +2 -0
  32. package/dist/agents/orchestrator/plugin.d.ts +1 -0
  33. package/dist/agents/orchestrator/prompt-meta.d.ts +2 -0
  34. package/dist/agents/orchestrator/prompt.d.ts +1 -0
  35. package/dist/agents/planner/config.d.ts +4 -0
  36. package/dist/agents/planner/index.d.ts +2 -0
  37. package/dist/agents/planner/plugin.d.ts +1 -0
  38. package/dist/agents/planner/prompt-meta.d.ts +2 -0
  39. package/dist/agents/planner/prompt.d.ts +1 -0
  40. package/dist/agents/prompt-meta.d.ts +11 -0
  41. package/dist/agents/prompt-registry.d.ts +4 -0
  42. package/dist/agents/researcher/config.d.ts +4 -0
  43. package/dist/agents/researcher/index.d.ts +2 -0
  44. package/dist/agents/researcher/plugin.d.ts +1 -0
  45. package/dist/agents/researcher/prompt-meta.d.ts +2 -0
  46. package/dist/agents/researcher/prompt.d.ts +1 -0
  47. package/dist/agents/tool-restrictions.d.ts +7 -0
  48. package/dist/agents/worker/config.d.ts +4 -0
  49. package/dist/agents/worker/index.d.ts +2 -0
  50. package/dist/agents/worker/plugin.d.ts +1 -0
  51. package/dist/agents/worker/prompt-meta.d.ts +2 -0
  52. package/dist/agents/worker/prompt.d.ts +1 -0
  53. package/dist/bootstrap.d.ts +3 -0
  54. package/dist/cli/cli.d.ts +3 -0
  55. package/dist/cli/commands/install.d.ts +12 -0
  56. package/dist/cli/commands/update.d.ts +1 -0
  57. package/dist/cli/config-generator.d.ts +26 -0
  58. package/dist/cli/index.d.ts +2 -0
  59. package/dist/config/defaults.d.ts +3 -0
  60. package/dist/config/define-config.d.ts +27 -0
  61. package/dist/config/index.d.ts +6 -0
  62. package/dist/config/loader.d.ts +3 -0
  63. package/dist/config/paths.d.ts +4 -0
  64. package/dist/config/schema.d.ts +273 -0
  65. package/dist/config/validator.d.ts +9 -0
  66. package/dist/features/auto-update/index.d.ts +3 -0
  67. package/dist/features/auto-update/plugin.d.ts +2 -0
  68. package/dist/features/auto-update/update-checker.d.ts +7 -0
  69. package/dist/features/background-agent/concurrency.d.ts +10 -0
  70. package/dist/features/background-agent/index.d.ts +6 -0
  71. package/dist/features/background-agent/manager.d.ts +18 -0
  72. package/dist/features/background-agent/poller.d.ts +17 -0
  73. package/dist/features/background-agent/singleton.d.ts +7 -0
  74. package/dist/features/background-agent/spawner.d.ts +6 -0
  75. package/dist/features/background-agent/types.d.ts +18 -0
  76. package/dist/features/builtin-features.d.ts +2 -0
  77. package/dist/features/categories/category-config.d.ts +9 -0
  78. package/dist/features/categories/category-resolver.d.ts +6 -0
  79. package/dist/features/categories/index.d.ts +3 -0
  80. package/dist/features/categories/prompt-appends.d.ts +10 -0
  81. package/dist/features/loops/file-store.d.ts +22 -0
  82. package/dist/features/loops/handler.d.ts +9 -0
  83. package/dist/features/loops/index.d.ts +5 -0
  84. package/dist/features/loops/memory-store.d.ts +11 -0
  85. package/dist/features/loops/plugin.d.ts +34 -0
  86. package/dist/features/loops/shared/event-utils.d.ts +7 -0
  87. package/dist/features/loops/state.d.ts +22 -0
  88. package/dist/features/prompt-builder/agent-table-builder.d.ts +6 -0
  89. package/dist/features/prompt-builder/category-section-builder.d.ts +2 -0
  90. package/dist/features/prompt-builder/dynamic-prompt-builder.d.ts +9 -0
  91. package/dist/features/prompt-builder/index.d.ts +7 -0
  92. package/dist/features/prompt-builder/skill-section-builder.d.ts +5 -0
  93. package/dist/features/session-state/index.d.ts +5 -0
  94. package/dist/features/session-state/session-cursor.d.ts +13 -0
  95. package/dist/features/session-state/session-store.d.ts +12 -0
  96. package/dist/features/session-state/session-tools-store.d.ts +4 -0
  97. package/dist/features/skills/builtin/git-master.d.ts +2 -0
  98. package/dist/features/skills/index.d.ts +10 -0
  99. package/dist/features/skills/skill-loader.d.ts +22 -0
  100. package/dist/features/skills/skill-merger.d.ts +2 -0
  101. package/dist/features/slash-commands/command-registry.d.ts +3 -0
  102. package/dist/features/slash-commands/commands/cancel-loop.d.ts +2 -0
  103. package/dist/features/slash-commands/commands/handoff.d.ts +2 -0
  104. package/dist/features/slash-commands/commands/init-deep.d.ts +2 -0
  105. package/dist/features/slash-commands/commands/loop.d.ts +2 -0
  106. package/dist/features/slash-commands/commands/start-work.d.ts +2 -0
  107. package/dist/features/slash-commands/commands/stop-continuation.d.ts +2 -0
  108. package/dist/features/slash-commands/index.d.ts +2 -0
  109. package/dist/features/slash-commands/types.d.ts +5 -0
  110. package/dist/hooks/anthropic-effort/handler.d.ts +5 -0
  111. package/dist/hooks/anthropic-effort/index.d.ts +3 -0
  112. package/dist/hooks/anthropic-effort/plugin.d.ts +1 -0
  113. package/dist/hooks/builtin-hooks.d.ts +2 -0
  114. package/dist/hooks/comment-checker/handler.d.ts +5 -0
  115. package/dist/hooks/comment-checker/index.d.ts +2 -0
  116. package/dist/hooks/comment-checker/plugin.d.ts +1 -0
  117. package/dist/hooks/compaction-context/handler.d.ts +2 -0
  118. package/dist/hooks/compaction-context/index.d.ts +2 -0
  119. package/dist/hooks/compaction-context/plugin.d.ts +1 -0
  120. package/dist/hooks/compaction-todo-preserver/handler.d.ts +4 -0
  121. package/dist/hooks/compaction-todo-preserver/index.d.ts +2 -0
  122. package/dist/hooks/compaction-todo-preserver/plugin.d.ts +1 -0
  123. package/dist/hooks/context-injector/handlers/agents.d.ts +1 -0
  124. package/dist/hooks/context-injector/handlers/readme.d.ts +1 -0
  125. package/dist/hooks/context-injector/handlers/rules.d.ts +1 -0
  126. package/dist/hooks/context-injector/index.d.ts +4 -0
  127. package/dist/hooks/context-injector/plugin.d.ts +1 -0
  128. package/dist/hooks/context-window-limit/handler.d.ts +6 -0
  129. package/dist/hooks/context-window-limit/index.d.ts +2 -0
  130. package/dist/hooks/context-window-limit/plugin.d.ts +1 -0
  131. package/dist/hooks/delegate-retry/handler.d.ts +16 -0
  132. package/dist/hooks/delegate-retry/index.d.ts +3 -0
  133. package/dist/hooks/delegate-retry/plugin.d.ts +1 -0
  134. package/dist/hooks/edit-error/handler.d.ts +6 -0
  135. package/dist/hooks/edit-error/index.d.ts +2 -0
  136. package/dist/hooks/edit-error/plugin.d.ts +1 -0
  137. package/dist/hooks/empty-response-detector/handler.d.ts +5 -0
  138. package/dist/hooks/empty-response-detector/index.d.ts +2 -0
  139. package/dist/hooks/empty-response-detector/plugin.d.ts +1 -0
  140. package/dist/hooks/error-diagnostics/handler.d.ts +6 -0
  141. package/dist/hooks/error-diagnostics/patterns.d.ts +3 -0
  142. package/dist/hooks/error-diagnostics/plugin.d.ts +1 -0
  143. package/dist/hooks/error-diagnostics/types.d.ts +14 -0
  144. package/dist/hooks/foreground-fallback/handler.d.ts +22 -0
  145. package/dist/hooks/foreground-fallback/index.d.ts +2 -0
  146. package/dist/hooks/foreground-fallback/plugin.d.ts +1 -0
  147. package/dist/hooks/hashline-diff-enhancer/handler.d.ts +28 -0
  148. package/dist/hooks/hashline-diff-enhancer/index.d.ts +2 -0
  149. package/dist/hooks/hashline-diff-enhancer/plugin.d.ts +1 -0
  150. package/dist/hooks/hashline-read-enhancer/handler.d.ts +4 -0
  151. package/dist/hooks/hashline-read-enhancer/index.d.ts +2 -0
  152. package/dist/hooks/hashline-read-enhancer/plugin.d.ts +1 -0
  153. package/dist/hooks/hook-composer.d.ts +4 -0
  154. package/dist/hooks/hook-ordering.d.ts +9 -0
  155. package/dist/hooks/hook-types.d.ts +3 -0
  156. package/dist/hooks/index.d.ts +6 -0
  157. package/dist/hooks/json-error/handler.d.ts +6 -0
  158. package/dist/hooks/json-error/index.d.ts +2 -0
  159. package/dist/hooks/json-error/plugin.d.ts +1 -0
  160. package/dist/hooks/keyword-detector/handler.d.ts +8 -0
  161. package/dist/hooks/keyword-detector/index.d.ts +3 -0
  162. package/dist/hooks/keyword-detector/plugin.d.ts +1 -0
  163. package/dist/hooks/model-fallback/handler.d.ts +21 -0
  164. package/dist/hooks/model-fallback/index.d.ts +2 -0
  165. package/dist/hooks/model-fallback/plugin.d.ts +1 -0
  166. package/dist/hooks/phase-reminder/handler.d.ts +5 -0
  167. package/dist/hooks/phase-reminder/index.d.ts +2 -0
  168. package/dist/hooks/phase-reminder/plugin.d.ts +1 -0
  169. package/dist/hooks/post-read-nudge/handler.d.ts +5 -0
  170. package/dist/hooks/post-read-nudge/index.d.ts +2 -0
  171. package/dist/hooks/post-read-nudge/plugin.d.ts +1 -0
  172. package/dist/hooks/preemptive-compaction/handler.d.ts +31 -0
  173. package/dist/hooks/preemptive-compaction/index.d.ts +2 -0
  174. package/dist/hooks/preemptive-compaction/plugin.d.ts +1 -0
  175. package/dist/hooks/runtime-fallback/handler.d.ts +21 -0
  176. package/dist/hooks/runtime-fallback/index.d.ts +2 -0
  177. package/dist/hooks/runtime-fallback/plugin.d.ts +1 -0
  178. package/dist/hooks/safe-hook-wrapper.d.ts +2 -0
  179. package/dist/hooks/session-recovery/handler.d.ts +6 -0
  180. package/dist/hooks/session-recovery/index.d.ts +2 -0
  181. package/dist/hooks/session-recovery/plugin.d.ts +1 -0
  182. package/dist/hooks/skill-discovery/plugin.d.ts +1 -0
  183. package/dist/hooks/stop-guard/handler.d.ts +4 -0
  184. package/dist/hooks/stop-guard/index.d.ts +2 -0
  185. package/dist/hooks/stop-guard/plugin.d.ts +1 -0
  186. package/dist/hooks/task-resume-info/handler.d.ts +4 -0
  187. package/dist/hooks/task-resume-info/index.d.ts +2 -0
  188. package/dist/hooks/task-resume-info/plugin.d.ts +1 -0
  189. package/dist/hooks/think-mode/handler.d.ts +4 -0
  190. package/dist/hooks/think-mode/index.d.ts +2 -0
  191. package/dist/hooks/think-mode/plugin.d.ts +1 -0
  192. package/dist/hooks/thinking-block-validator/handler.d.ts +4 -0
  193. package/dist/hooks/thinking-block-validator/index.d.ts +2 -0
  194. package/dist/hooks/thinking-block-validator/plugin.d.ts +1 -0
  195. package/dist/hooks/todo-enforcer/handler.d.ts +4 -0
  196. package/dist/hooks/todo-enforcer/index.d.ts +2 -0
  197. package/dist/hooks/todo-enforcer/plugin.d.ts +1 -0
  198. package/dist/hooks/todowrite-disabler/handler.d.ts +6 -0
  199. package/dist/hooks/todowrite-disabler/index.d.ts +2 -0
  200. package/dist/hooks/todowrite-disabler/plugin.d.ts +1 -0
  201. package/dist/hooks/tool-output-truncator/handler.d.ts +4 -0
  202. package/dist/hooks/tool-output-truncator/index.d.ts +2 -0
  203. package/dist/hooks/tool-output-truncator/plugin.d.ts +1 -0
  204. package/dist/hooks/write-file-guard/handler.d.ts +7 -0
  205. package/dist/hooks/write-file-guard/index.d.ts +2 -0
  206. package/dist/hooks/write-file-guard/plugin.d.ts +1 -0
  207. package/dist/index.d.ts +5 -0
  208. package/dist/index.js +8547 -0
  209. package/dist/plugin/compositor.d.ts +9 -0
  210. package/dist/plugin/index.d.ts +1 -0
  211. package/dist/plugin-api/define-plugin.d.ts +33 -0
  212. package/dist/plugin-api/index.d.ts +3 -0
  213. package/dist/plugin-api/types.d.ts +10 -0
  214. package/dist/registry/agent-aggregator.d.ts +3 -0
  215. package/dist/registry/contribution-aggregator.d.ts +10 -0
  216. package/dist/registry/dependency-resolver.d.ts +3 -0
  217. package/dist/registry/hook-aggregator.d.ts +2 -0
  218. package/dist/registry/index.d.ts +6 -0
  219. package/dist/registry/plugin-registry.d.ts +16 -0
  220. package/dist/registry/tool-aggregator.d.ts +3 -0
  221. package/dist/registry/types.d.ts +9 -0
  222. package/dist/runtime/index.d.ts +7 -0
  223. package/dist/shared/data-path.d.ts +4 -0
  224. package/dist/shared/deep-merge.d.ts +13 -0
  225. package/dist/shared/fallback-chain.d.ts +1 -0
  226. package/dist/shared/index.d.ts +19 -0
  227. package/dist/shared/logger.d.ts +4 -0
  228. package/dist/shared/model-availability.d.ts +1 -0
  229. package/dist/shared/model-normalization.d.ts +6 -0
  230. package/dist/shared/model-prefix-map.d.ts +11 -0
  231. package/dist/shared/model-resolution-pipeline.d.ts +14 -0
  232. package/dist/shared/models-dev.d.ts +29 -0
  233. package/dist/shared/provider-discovery.d.ts +28 -0
  234. package/dist/shared/provider-registry.d.ts +16 -0
  235. package/dist/shared/safe-create-hook.d.ts +3 -0
  236. package/dist/shared/snake-case.d.ts +1 -0
  237. package/dist/shared/truncate-description.d.ts +1 -0
  238. package/dist/test-utils/index.d.ts +6 -0
  239. package/dist/test-utils/mock-agent-config.d.ts +5 -0
  240. package/dist/test-utils/mock-hook-inputs.d.ts +20 -0
  241. package/dist/test-utils/mock-hook-outputs.d.ts +20 -0
  242. package/dist/test-utils/mock-plugin-context.d.ts +6 -0
  243. package/dist/test-utils/mock-sdk-client.d.ts +41 -0
  244. package/dist/test-utils/mock-tool-context.d.ts +6 -0
  245. package/dist/tools/ast-grep/index.d.ts +4 -0
  246. package/dist/tools/ast-grep/replace/handler.d.ts +7 -0
  247. package/dist/tools/ast-grep/replace/plugin.d.ts +1 -0
  248. package/dist/tools/ast-grep/replace/types.d.ts +37 -0
  249. package/dist/tools/ast-grep/search/handler.d.ts +14 -0
  250. package/dist/tools/ast-grep/search/plugin.d.ts +1 -0
  251. package/dist/tools/ast-grep/search/types.d.ts +37 -0
  252. package/dist/tools/background-task/cancel/handler.d.ts +4 -0
  253. package/dist/tools/background-task/cancel/plugin.d.ts +2 -0
  254. package/dist/tools/background-task/cancel/types.d.ts +4 -0
  255. package/dist/tools/background-task/index.d.ts +2 -0
  256. package/dist/tools/background-task/output/handler.d.ts +3 -0
  257. package/dist/tools/background-task/output/plugin.d.ts +2 -0
  258. package/dist/tools/background-task/output/types.d.ts +11 -0
  259. package/dist/tools/bridge.d.ts +7 -0
  260. package/dist/tools/builtin-tools.d.ts +2 -0
  261. package/dist/tools/delegate-task/category-resolver.d.ts +4 -0
  262. package/dist/tools/delegate-task/constants.d.ts +3 -0
  263. package/dist/tools/delegate-task/executor.d.ts +10 -0
  264. package/dist/tools/delegate-task/handler.d.ts +3 -0
  265. package/dist/tools/delegate-task/index.d.ts +7 -0
  266. package/dist/tools/delegate-task/plugin.d.ts +2 -0
  267. package/dist/tools/delegate-task/types.d.ts +17 -0
  268. package/dist/tools/glob/handler.d.ts +7 -0
  269. package/dist/tools/glob/index.d.ts +2 -0
  270. package/dist/tools/glob/plugin.d.ts +1 -0
  271. package/dist/tools/glob/types.d.ts +7 -0
  272. package/dist/tools/grep/handler.d.ts +13 -0
  273. package/dist/tools/grep/index.d.ts +2 -0
  274. package/dist/tools/grep/plugin.d.ts +1 -0
  275. package/dist/tools/grep/types.d.ts +15 -0
  276. package/dist/tools/hashline-edit/constants.d.ts +4 -0
  277. package/dist/tools/hashline-edit/edit-operations.d.ts +4 -0
  278. package/dist/tools/hashline-edit/handler.d.ts +5 -0
  279. package/dist/tools/hashline-edit/hash-computation.d.ts +2 -0
  280. package/dist/tools/hashline-edit/index.d.ts +5 -0
  281. package/dist/tools/hashline-edit/plugin.d.ts +3 -0
  282. package/dist/tools/hashline-edit/types.d.ts +21 -0
  283. package/dist/tools/index.d.ts +4 -0
  284. package/dist/tools/look-at/handler.d.ts +6 -0
  285. package/dist/tools/look-at/index.d.ts +3 -0
  286. package/dist/tools/look-at/plugin.d.ts +1 -0
  287. package/dist/tools/look-at/types.d.ts +9 -0
  288. package/dist/tools/lsp/client.d.ts +7 -0
  289. package/dist/tools/lsp/diagnostics/handler.d.ts +2 -0
  290. package/dist/tools/lsp/diagnostics/plugin.d.ts +1 -0
  291. package/dist/tools/lsp/diagnostics/types.d.ts +13 -0
  292. package/dist/tools/lsp/find-references/handler.d.ts +2 -0
  293. package/dist/tools/lsp/find-references/plugin.d.ts +1 -0
  294. package/dist/tools/lsp/find-references/types.d.ts +8 -0
  295. package/dist/tools/lsp/goto-definition/handler.d.ts +2 -0
  296. package/dist/tools/lsp/goto-definition/plugin.d.ts +1 -0
  297. package/dist/tools/lsp/goto-definition/types.d.ts +7 -0
  298. package/dist/tools/lsp/index.d.ts +6 -0
  299. package/dist/tools/lsp/prepare-rename/handler.d.ts +2 -0
  300. package/dist/tools/lsp/prepare-rename/plugin.d.ts +1 -0
  301. package/dist/tools/lsp/prepare-rename/types.d.ts +7 -0
  302. package/dist/tools/lsp/rename/handler.d.ts +2 -0
  303. package/dist/tools/lsp/rename/plugin.d.ts +1 -0
  304. package/dist/tools/lsp/rename/types.d.ts +8 -0
  305. package/dist/tools/lsp/symbols/handler.d.ts +2 -0
  306. package/dist/tools/lsp/symbols/plugin.d.ts +1 -0
  307. package/dist/tools/lsp/symbols/types.d.ts +11 -0
  308. package/dist/tools/session-manager/client-context.d.ts +3 -0
  309. package/dist/tools/session-manager/index.d.ts +5 -0
  310. package/dist/tools/session-manager/info/handler.d.ts +3 -0
  311. package/dist/tools/session-manager/info/plugin.d.ts +1 -0
  312. package/dist/tools/session-manager/info/types.d.ts +3 -0
  313. package/dist/tools/session-manager/list/handler.d.ts +3 -0
  314. package/dist/tools/session-manager/list/plugin.d.ts +1 -0
  315. package/dist/tools/session-manager/list/types.d.ts +6 -0
  316. package/dist/tools/session-manager/read/handler.d.ts +3 -0
  317. package/dist/tools/session-manager/read/plugin.d.ts +1 -0
  318. package/dist/tools/session-manager/read/types.d.ts +6 -0
  319. package/dist/tools/session-manager/search/handler.d.ts +3 -0
  320. package/dist/tools/session-manager/search/plugin.d.ts +1 -0
  321. package/dist/tools/session-manager/search/types.d.ts +6 -0
  322. package/dist/tools/session-manager/session-formatter.d.ts +29 -0
  323. package/dist/tools/session-manager/types.d.ts +36 -0
  324. package/dist/tools/shared/constants.d.ts +3 -0
  325. package/dist/tools/skill/handler.d.ts +4 -0
  326. package/dist/tools/skill/index.d.ts +3 -0
  327. package/dist/tools/skill/plugin.d.ts +1 -0
  328. package/dist/tools/skill/types.d.ts +12 -0
  329. package/dist/tools/skill-mcp/handler.d.ts +5 -0
  330. package/dist/tools/skill-mcp/index.d.ts +3 -0
  331. package/dist/tools/skill-mcp/plugin.d.ts +1 -0
  332. package/dist/tools/skill-mcp/types.d.ts +13 -0
  333. package/dist/tools/task/create/handler.d.ts +2 -0
  334. package/dist/tools/task/create/plugin.d.ts +1 -0
  335. package/dist/tools/task/format-task.d.ts +2 -0
  336. package/dist/tools/task/get/handler.d.ts +2 -0
  337. package/dist/tools/task/get/plugin.d.ts +1 -0
  338. package/dist/tools/task/index.d.ts +4 -0
  339. package/dist/tools/task/list/handler.d.ts +2 -0
  340. package/dist/tools/task/list/plugin.d.ts +1 -0
  341. package/dist/tools/task/storage.d.ts +7 -0
  342. package/dist/tools/task/types.d.ts +84 -0
  343. package/dist/tools/task/update/handler.d.ts +2 -0
  344. package/dist/tools/task/update/plugin.d.ts +1 -0
  345. package/dist/tools/tool-builder.d.ts +7 -0
  346. package/dist/tools/tool-registry-adapter.d.ts +3 -0
  347. package/dist/types/agent.d.ts +40 -0
  348. package/dist/types/category.d.ts +22 -0
  349. package/dist/types/config.d.ts +23 -0
  350. package/dist/types/hook.d.ts +18 -0
  351. package/dist/types/index.d.ts +12 -0
  352. package/dist/types/plugin.d.ts +41 -0
  353. package/dist/types/tool.d.ts +7 -0
  354. package/eval/README.md +160 -0
  355. package/eval/ablation-config.yaml +43 -0
  356. package/eval/assertions/ablation-scorer.ts +81 -0
  357. package/eval/assertions/hook-impact.ts +152 -0
  358. package/eval/assertions/task-completion.ts +65 -0
  359. package/eval/assertions/tool-accuracy.ts +56 -0
  360. package/eval/promptfooconfig.yaml +42 -0
  361. package/eval/providers/opencode-baseline.ts +63 -0
  362. package/eval/providers/opencode-client.ts +112 -0
  363. package/eval/providers/opencode-provider.ts +66 -0
  364. package/eval/spike/config.yaml +13 -0
  365. package/eval/spike/provider.ts +15 -0
  366. package/npm-reserve/README.md +19 -0
  367. package/npm-reserve/package.json +24 -0
  368. package/opencode.json +6 -0
  369. package/package.json +47 -8
  370. package/src/agents/advisor/config.ts +6 -0
  371. package/src/agents/advisor/index.ts +2 -0
  372. package/src/agents/advisor/plugin.test.ts +48 -0
  373. package/src/agents/advisor/plugin.ts +17 -0
  374. package/src/agents/advisor/prompt-meta.ts +14 -0
  375. package/src/agents/advisor/prompt.ts +93 -0
  376. package/src/agents/agent-builder.test.ts +66 -0
  377. package/src/agents/agent-builder.ts +97 -0
  378. package/src/agents/agent-plugins.test.ts +98 -0
  379. package/src/agents/agent-registry.ts +25 -0
  380. package/src/agents/builtin-agents.ts +18 -0
  381. package/src/agents/deep-worker/config.ts +6 -0
  382. package/src/agents/deep-worker/index.ts +2 -0
  383. package/src/agents/deep-worker/plugin.test.ts +31 -0
  384. package/src/agents/deep-worker/plugin.ts +16 -0
  385. package/src/agents/deep-worker/prompt-meta.ts +14 -0
  386. package/src/agents/deep-worker/prompt.ts +121 -0
  387. package/src/agents/disabled/analyst/config.ts +6 -0
  388. package/src/agents/disabled/analyst/index.ts +2 -0
  389. package/src/agents/disabled/analyst/plugin.ts +16 -0
  390. package/src/agents/disabled/analyst/prompt.ts +1 -0
  391. package/src/agents/disabled/executor/config.ts +9 -0
  392. package/src/agents/disabled/executor/index.ts +2 -0
  393. package/src/agents/disabled/executor/plugin.ts +16 -0
  394. package/src/agents/disabled/executor/prompt.ts +1 -0
  395. package/src/agents/disabled/inspector/config.ts +6 -0
  396. package/src/agents/disabled/inspector/index.ts +2 -0
  397. package/src/agents/disabled/inspector/plugin.ts +18 -0
  398. package/src/agents/disabled/inspector/prompt.ts +1 -0
  399. package/src/agents/disabled/reviewer/config.ts +6 -0
  400. package/src/agents/disabled/reviewer/index.ts +2 -0
  401. package/src/agents/disabled/reviewer/plugin.ts +18 -0
  402. package/src/agents/disabled/reviewer/prompt.ts +1 -0
  403. package/src/agents/explorer/config.ts +6 -0
  404. package/src/agents/explorer/index.ts +2 -0
  405. package/src/agents/explorer/plugin.test.ts +36 -0
  406. package/src/agents/explorer/plugin.ts +15 -0
  407. package/src/agents/explorer/prompt-meta.ts +14 -0
  408. package/src/agents/explorer/prompt.ts +96 -0
  409. package/src/agents/fallback-chains.ts +13 -0
  410. package/src/agents/index.ts +18 -0
  411. package/src/agents/model-resolution.test.ts +79 -0
  412. package/src/agents/orchestrator/config.ts +10 -0
  413. package/src/agents/orchestrator/index.ts +2 -0
  414. package/src/agents/orchestrator/plugin.test.ts +31 -0
  415. package/src/agents/orchestrator/plugin.ts +16 -0
  416. package/src/agents/orchestrator/prompt-meta.ts +14 -0
  417. package/src/agents/orchestrator/prompt.ts +143 -0
  418. package/src/agents/planner/config.ts +6 -0
  419. package/src/agents/planner/index.ts +2 -0
  420. package/src/agents/planner/plugin.test.ts +31 -0
  421. package/src/agents/planner/plugin.ts +16 -0
  422. package/src/agents/planner/prompt-meta.ts +14 -0
  423. package/src/agents/planner/prompt.ts +138 -0
  424. package/src/agents/prompt-meta.ts +12 -0
  425. package/src/agents/prompt-registry.test.ts +98 -0
  426. package/src/agents/prompt-registry.ts +22 -0
  427. package/src/agents/researcher/config.ts +6 -0
  428. package/src/agents/researcher/index.ts +2 -0
  429. package/src/agents/researcher/plugin.test.ts +31 -0
  430. package/src/agents/researcher/plugin.ts +16 -0
  431. package/src/agents/researcher/prompt-meta.ts +14 -0
  432. package/src/agents/researcher/prompt.ts +116 -0
  433. package/src/agents/tool-restrictions.ts +87 -0
  434. package/src/agents/worker/config.ts +6 -0
  435. package/src/agents/worker/index.ts +2 -0
  436. package/src/agents/worker/plugin.test.ts +31 -0
  437. package/src/agents/worker/plugin.ts +15 -0
  438. package/src/agents/worker/prompt-meta.ts +14 -0
  439. package/src/agents/worker/prompt.ts +83 -0
  440. package/src/bootstrap.integration.test.ts +168 -0
  441. package/src/bootstrap.ts +171 -0
  442. package/src/cli/cli.ts +42 -0
  443. package/src/cli/commands/install.test.ts +40 -0
  444. package/src/cli/commands/install.ts +125 -0
  445. package/src/cli/commands/update.test.ts +84 -0
  446. package/src/cli/commands/update.ts +45 -0
  447. package/src/cli/config-generator.test.ts +178 -0
  448. package/src/cli/config-generator.ts +119 -0
  449. package/src/cli/index.test.ts +34 -0
  450. package/src/cli/index.ts +4 -0
  451. package/src/config/defaults.ts +24 -0
  452. package/src/config/define-config.ts +38 -0
  453. package/src/config/index.ts +6 -0
  454. package/src/config/loader.test.ts +218 -0
  455. package/src/config/loader.ts +89 -0
  456. package/src/config/paths.ts +30 -0
  457. package/src/config/schema.test.ts +69 -0
  458. package/src/config/schema.ts +57 -0
  459. package/src/config/validator.ts +24 -0
  460. package/src/features/auto-update/auto-update.test.ts +105 -0
  461. package/src/features/auto-update/index.ts +4 -0
  462. package/src/features/auto-update/plugin.ts +45 -0
  463. package/src/features/auto-update/update-checker.ts +66 -0
  464. package/src/features/background-agent/concurrency.test.ts +65 -0
  465. package/src/features/background-agent/concurrency.ts +44 -0
  466. package/src/features/background-agent/index.ts +12 -0
  467. package/src/features/background-agent/manager.ts +214 -0
  468. package/src/features/background-agent/poller.test.ts +33 -0
  469. package/src/features/background-agent/poller.ts +75 -0
  470. package/src/features/background-agent/singleton.ts +26 -0
  471. package/src/features/background-agent/spawner.ts +51 -0
  472. package/src/features/background-agent/types.ts +20 -0
  473. package/src/features/builtin-features.ts +5 -0
  474. package/src/features/categories/categories.test.ts +68 -0
  475. package/src/features/categories/category-config.ts +70 -0
  476. package/src/features/categories/category-resolver.ts +36 -0
  477. package/src/features/categories/index.ts +8 -0
  478. package/src/features/categories/prompt-appends.ts +38 -0
  479. package/src/features/loops/file-store.ts +151 -0
  480. package/src/features/loops/handler.ts +89 -0
  481. package/src/features/loops/index.ts +28 -0
  482. package/src/features/loops/loops.test.ts +175 -0
  483. package/src/features/loops/memory-store.ts +53 -0
  484. package/src/features/loops/plugin.ts +107 -0
  485. package/src/features/loops/shared/event-utils.ts +50 -0
  486. package/src/features/loops/state.ts +44 -0
  487. package/src/features/prompt-builder/agent-table-builder.ts +23 -0
  488. package/src/features/prompt-builder/category-section-builder.ts +21 -0
  489. package/src/features/prompt-builder/dynamic-prompt-builder.ts +42 -0
  490. package/src/features/prompt-builder/index.ts +7 -0
  491. package/src/features/prompt-builder/prompt-builder.test.ts +244 -0
  492. package/src/features/prompt-builder/skill-section-builder.ts +25 -0
  493. package/src/features/session-state/index.ts +17 -0
  494. package/src/features/session-state/session-cursor.test.ts +137 -0
  495. package/src/features/session-state/session-cursor.ts +80 -0
  496. package/src/features/session-state/session-store.test.ts +82 -0
  497. package/src/features/session-state/session-store.ts +37 -0
  498. package/src/features/session-state/session-tools-store.ts +18 -0
  499. package/src/features/skills/builtin/git-master.ts +109 -0
  500. package/src/features/skills/index.ts +97 -0
  501. package/src/features/skills/skill-loader.ts +133 -0
  502. package/src/features/skills/skill-merger.ts +15 -0
  503. package/src/features/skills/skills.test.ts +120 -0
  504. package/src/features/slash-commands/command-registry.ts +36 -0
  505. package/src/features/slash-commands/commands/cancel-loop.ts +17 -0
  506. package/src/features/slash-commands/commands/handoff.ts +59 -0
  507. package/src/features/slash-commands/commands/init-deep.ts +40 -0
  508. package/src/features/slash-commands/commands/loop.ts +39 -0
  509. package/src/features/slash-commands/commands/start-work.ts +39 -0
  510. package/src/features/slash-commands/commands/stop-continuation.ts +21 -0
  511. package/src/features/slash-commands/index.ts +2 -0
  512. package/src/features/slash-commands/slash-commands.test.ts +68 -0
  513. package/src/features/slash-commands/types.ts +5 -0
  514. package/src/hooks/anthropic-effort/handler.test.ts +156 -0
  515. package/src/hooks/anthropic-effort/handler.ts +64 -0
  516. package/src/hooks/anthropic-effort/index.ts +3 -0
  517. package/src/hooks/anthropic-effort/plugin.ts +17 -0
  518. package/src/hooks/builtin-hooks.ts +64 -0
  519. package/src/hooks/comment-checker/handler.test.ts +65 -0
  520. package/src/hooks/comment-checker/handler.ts +60 -0
  521. package/src/hooks/comment-checker/index.ts +2 -0
  522. package/src/hooks/comment-checker/plugin.ts +15 -0
  523. package/src/hooks/compaction-context/handler.test.ts +160 -0
  524. package/src/hooks/compaction-context/handler.ts +179 -0
  525. package/src/hooks/compaction-context/index.ts +5 -0
  526. package/src/hooks/compaction-context/plugin.ts +40 -0
  527. package/src/hooks/compaction-todo-preserver/handler.test.ts +155 -0
  528. package/src/hooks/compaction-todo-preserver/handler.ts +129 -0
  529. package/src/hooks/compaction-todo-preserver/index.ts +2 -0
  530. package/src/hooks/compaction-todo-preserver/plugin.ts +18 -0
  531. package/src/hooks/context-injection.test.ts +124 -0
  532. package/src/hooks/context-injector/handlers/agents.test.ts +90 -0
  533. package/src/hooks/context-injector/handlers/agents.ts +81 -0
  534. package/src/hooks/context-injector/handlers/readme.ts +55 -0
  535. package/src/hooks/context-injector/handlers/rules.ts +62 -0
  536. package/src/hooks/context-injector/index.ts +4 -0
  537. package/src/hooks/context-injector/plugin.ts +56 -0
  538. package/src/hooks/context-window-limit/handler.test.ts +103 -0
  539. package/src/hooks/context-window-limit/handler.ts +128 -0
  540. package/src/hooks/context-window-limit/index.ts +6 -0
  541. package/src/hooks/context-window-limit/plugin.ts +15 -0
  542. package/src/hooks/continuation.test.ts +103 -0
  543. package/src/hooks/delegate-retry/handler.test.ts +212 -0
  544. package/src/hooks/delegate-retry/handler.ts +137 -0
  545. package/src/hooks/delegate-retry/index.ts +8 -0
  546. package/src/hooks/delegate-retry/plugin.ts +15 -0
  547. package/src/hooks/edit-error/handler.test.ts +82 -0
  548. package/src/hooks/edit-error/handler.ts +50 -0
  549. package/src/hooks/edit-error/index.ts +6 -0
  550. package/src/hooks/edit-error/plugin.ts +15 -0
  551. package/src/hooks/empty-response-detector/handler.test.ts +133 -0
  552. package/src/hooks/empty-response-detector/handler.ts +62 -0
  553. package/src/hooks/empty-response-detector/index.ts +2 -0
  554. package/src/hooks/empty-response-detector/plugin.ts +18 -0
  555. package/src/hooks/error-diagnostics/error-diagnostics.test.ts +116 -0
  556. package/src/hooks/error-diagnostics/handler.test.ts +147 -0
  557. package/src/hooks/error-diagnostics/handler.ts +135 -0
  558. package/src/hooks/error-diagnostics/patterns.ts +93 -0
  559. package/src/hooks/error-diagnostics/plugin.ts +11 -0
  560. package/src/hooks/error-diagnostics/types.ts +26 -0
  561. package/src/hooks/error-recovery.test.ts +85 -0
  562. package/src/hooks/foreground-fallback/handler.test.ts +229 -0
  563. package/src/hooks/foreground-fallback/handler.ts +294 -0
  564. package/src/hooks/foreground-fallback/index.ts +2 -0
  565. package/src/hooks/foreground-fallback/plugin.ts +18 -0
  566. package/src/hooks/hashline-diff-enhancer/handler.test.ts +166 -0
  567. package/src/hooks/hashline-diff-enhancer/handler.ts +186 -0
  568. package/src/hooks/hashline-diff-enhancer/index.ts +6 -0
  569. package/src/hooks/hashline-diff-enhancer/plugin.ts +24 -0
  570. package/src/hooks/hashline-read-enhancer/handler.test.ts +121 -0
  571. package/src/hooks/hashline-read-enhancer/handler.ts +165 -0
  572. package/src/hooks/hashline-read-enhancer/index.ts +2 -0
  573. package/src/hooks/hashline-read-enhancer/plugin.ts +18 -0
  574. package/src/hooks/hook-composer.test.ts +52 -0
  575. package/src/hooks/hook-composer.ts +17 -0
  576. package/src/hooks/hook-composition.integration.test.ts +274 -0
  577. package/src/hooks/hook-ordering.ts +41 -0
  578. package/src/hooks/hook-types.ts +22 -0
  579. package/src/hooks/index.ts +6 -0
  580. package/src/hooks/json-error/handler.test.ts +95 -0
  581. package/src/hooks/json-error/handler.ts +82 -0
  582. package/src/hooks/json-error/index.ts +6 -0
  583. package/src/hooks/json-error/plugin.ts +15 -0
  584. package/src/hooks/keyword-detector/handler.test.ts +113 -0
  585. package/src/hooks/keyword-detector/handler.ts +73 -0
  586. package/src/hooks/keyword-detector/index.ts +8 -0
  587. package/src/hooks/keyword-detector/plugin.ts +24 -0
  588. package/src/hooks/model-fallback/handler.test.ts +163 -0
  589. package/src/hooks/model-fallback/handler.ts +178 -0
  590. package/src/hooks/model-fallback/index.ts +2 -0
  591. package/src/hooks/model-fallback/plugin.ts +11 -0
  592. package/src/hooks/model-management.test.ts +121 -0
  593. package/src/hooks/phase-reminder/handler.test.ts +105 -0
  594. package/src/hooks/phase-reminder/handler.ts +54 -0
  595. package/src/hooks/phase-reminder/index.ts +2 -0
  596. package/src/hooks/phase-reminder/plugin.ts +18 -0
  597. package/src/hooks/post-read-nudge/handler.test.ts +106 -0
  598. package/src/hooks/post-read-nudge/handler.ts +28 -0
  599. package/src/hooks/post-read-nudge/index.ts +2 -0
  600. package/src/hooks/post-read-nudge/plugin.ts +18 -0
  601. package/src/hooks/preemptive-compaction/handler.test.ts +130 -0
  602. package/src/hooks/preemptive-compaction/handler.ts +84 -0
  603. package/src/hooks/preemptive-compaction/index.ts +2 -0
  604. package/src/hooks/preemptive-compaction/plugin.ts +15 -0
  605. package/src/hooks/productivity.test.ts +332 -0
  606. package/src/hooks/quality.test.ts +330 -0
  607. package/src/hooks/runtime-fallback/handler.test.ts +142 -0
  608. package/src/hooks/runtime-fallback/handler.ts +171 -0
  609. package/src/hooks/runtime-fallback/index.ts +2 -0
  610. package/src/hooks/runtime-fallback/plugin.ts +13 -0
  611. package/src/hooks/safe-hook-wrapper.test.ts +35 -0
  612. package/src/hooks/safe-hook-wrapper.ts +12 -0
  613. package/src/hooks/session-recovery/handler.test.ts +88 -0
  614. package/src/hooks/session-recovery/handler.ts +87 -0
  615. package/src/hooks/session-recovery/index.ts +6 -0
  616. package/src/hooks/session-recovery/plugin.ts +15 -0
  617. package/src/hooks/skill-discovery/plugin.ts +45 -0
  618. package/src/hooks/stop-guard/handler.test.ts +147 -0
  619. package/src/hooks/stop-guard/handler.ts +127 -0
  620. package/src/hooks/stop-guard/index.ts +2 -0
  621. package/src/hooks/stop-guard/plugin.ts +15 -0
  622. package/src/hooks/task-hooks.test.ts +324 -0
  623. package/src/hooks/task-resume-info/handler.test.ts +180 -0
  624. package/src/hooks/task-resume-info/handler.ts +61 -0
  625. package/src/hooks/task-resume-info/index.ts +2 -0
  626. package/src/hooks/task-resume-info/plugin.ts +15 -0
  627. package/src/hooks/think-mode/handler.test.ts +139 -0
  628. package/src/hooks/think-mode/handler.ts +50 -0
  629. package/src/hooks/think-mode/index.ts +2 -0
  630. package/src/hooks/think-mode/plugin.ts +15 -0
  631. package/src/hooks/thinking-block-validator/handler.test.ts +79 -0
  632. package/src/hooks/thinking-block-validator/handler.ts +93 -0
  633. package/src/hooks/thinking-block-validator/index.ts +2 -0
  634. package/src/hooks/thinking-block-validator/plugin.ts +18 -0
  635. package/src/hooks/todo-enforcer/handler.test.ts +153 -0
  636. package/src/hooks/todo-enforcer/handler.ts +100 -0
  637. package/src/hooks/todo-enforcer/index.ts +2 -0
  638. package/src/hooks/todo-enforcer/plugin.ts +15 -0
  639. package/src/hooks/todowrite-disabler/handler.test.ts +119 -0
  640. package/src/hooks/todowrite-disabler/handler.ts +50 -0
  641. package/src/hooks/todowrite-disabler/index.ts +6 -0
  642. package/src/hooks/todowrite-disabler/plugin.ts +46 -0
  643. package/src/hooks/tool-output-truncator/handler.test.ts +113 -0
  644. package/src/hooks/tool-output-truncator/handler.ts +83 -0
  645. package/src/hooks/tool-output-truncator/index.ts +2 -0
  646. package/src/hooks/tool-output-truncator/plugin.ts +18 -0
  647. package/src/hooks/tool-output.test.ts +238 -0
  648. package/src/hooks/workflow-reminders.test.ts +187 -0
  649. package/src/hooks/write-file-guard/handler.test.ts +107 -0
  650. package/src/hooks/write-file-guard/handler.ts +166 -0
  651. package/src/hooks/write-file-guard/index.ts +2 -0
  652. package/src/hooks/write-file-guard/plugin.ts +23 -0
  653. package/src/index.ts +8 -0
  654. package/src/plugin/compositor.ts +99 -0
  655. package/src/plugin/index.ts +1 -0
  656. package/src/plugin-api/define-plugin.test.ts +66 -0
  657. package/src/plugin-api/define-plugin.ts +36 -0
  658. package/src/plugin-api/index.ts +26 -0
  659. package/src/plugin-api/types.ts +28 -0
  660. package/src/registry/agent-aggregator.ts +13 -0
  661. package/src/registry/contribution-aggregator.test.ts +62 -0
  662. package/src/registry/contribution-aggregator.ts +114 -0
  663. package/src/registry/contribution-conflicts.integration.test.ts +186 -0
  664. package/src/registry/dependency-resolver.test.ts +35 -0
  665. package/src/registry/dependency-resolver.ts +64 -0
  666. package/src/registry/hook-aggregator.test.ts +78 -0
  667. package/src/registry/hook-aggregator.ts +63 -0
  668. package/src/registry/index.ts +6 -0
  669. package/src/registry/plugin-lifecycle.integration.test.ts +94 -0
  670. package/src/registry/plugin-overrides.integration.test.ts +140 -0
  671. package/src/registry/plugin-registry.test.ts +56 -0
  672. package/src/registry/plugin-registry.ts +82 -0
  673. package/src/registry/tool-aggregator.ts +13 -0
  674. package/src/registry/types.ts +11 -0
  675. package/src/runtime/index.ts +43 -0
  676. package/src/shared/data-path.ts +18 -0
  677. package/src/shared/deep-merge.test.ts +36 -0
  678. package/src/shared/deep-merge.ts +61 -0
  679. package/src/shared/fallback-chain.ts +8 -0
  680. package/src/shared/index.ts +59 -0
  681. package/src/shared/logger.ts +54 -0
  682. package/src/shared/model-availability.ts +18 -0
  683. package/src/shared/model-normalization.test.ts +75 -0
  684. package/src/shared/model-normalization.ts +28 -0
  685. package/src/shared/model-prefix-map.test.ts +75 -0
  686. package/src/shared/model-prefix-map.ts +58 -0
  687. package/src/shared/model-resolution-pipeline.test.ts +111 -0
  688. package/src/shared/model-resolution-pipeline.ts +55 -0
  689. package/src/shared/models-dev.test.ts +277 -0
  690. package/src/shared/models-dev.ts +176 -0
  691. package/src/shared/provider-discovery.test.ts +97 -0
  692. package/src/shared/provider-discovery.ts +73 -0
  693. package/src/shared/provider-registry.test.ts +212 -0
  694. package/src/shared/provider-registry.ts +157 -0
  695. package/src/shared/safe-create-hook.ts +15 -0
  696. package/src/shared/snake-case.ts +7 -0
  697. package/src/shared/truncate-description.ts +6 -0
  698. package/src/test-utils/index.ts +6 -0
  699. package/src/test-utils/mock-agent-config.ts +13 -0
  700. package/src/test-utils/mock-hook-inputs.ts +148 -0
  701. package/src/test-utils/mock-hook-outputs.ts +153 -0
  702. package/src/test-utils/mock-plugin-context.test.ts +32 -0
  703. package/src/test-utils/mock-plugin-context.ts +21 -0
  704. package/src/test-utils/mock-sdk-client.ts +52 -0
  705. package/src/test-utils/mock-tool-context.ts +24 -0
  706. package/src/tools/ast-grep/index.ts +4 -0
  707. package/src/tools/ast-grep/replace/handler.test.ts +93 -0
  708. package/src/tools/ast-grep/replace/handler.ts +89 -0
  709. package/src/tools/ast-grep/replace/plugin.ts +10 -0
  710. package/src/tools/ast-grep/replace/types.ts +14 -0
  711. package/src/tools/ast-grep/search/handler.test.ts +94 -0
  712. package/src/tools/ast-grep/search/handler.ts +93 -0
  713. package/src/tools/ast-grep/search/plugin.ts +10 -0
  714. package/src/tools/ast-grep/search/types.ts +42 -0
  715. package/src/tools/background-task/background-task.test.ts +185 -0
  716. package/src/tools/background-task/cancel/handler.test.ts +141 -0
  717. package/src/tools/background-task/cancel/handler.ts +52 -0
  718. package/src/tools/background-task/cancel/plugin.ts +30 -0
  719. package/src/tools/background-task/cancel/types.ts +4 -0
  720. package/src/tools/background-task/index.ts +2 -0
  721. package/src/tools/background-task/output/handler.test.ts +142 -0
  722. package/src/tools/background-task/output/handler.ts +93 -0
  723. package/src/tools/background-task/output/plugin.ts +60 -0
  724. package/src/tools/background-task/output/types.ts +11 -0
  725. package/src/tools/bridge.test.ts +55 -0
  726. package/src/tools/bridge.ts +13 -0
  727. package/src/tools/builtin-tools.ts +54 -0
  728. package/src/tools/code-search.test.ts +203 -0
  729. package/src/tools/delegate-task/category-resolver.ts +18 -0
  730. package/src/tools/delegate-task/constants.ts +43 -0
  731. package/src/tools/delegate-task/delegate-task.test.ts +245 -0
  732. package/src/tools/delegate-task/executor.ts +157 -0
  733. package/src/tools/delegate-task/handler.ts +74 -0
  734. package/src/tools/delegate-task/index.ts +7 -0
  735. package/src/tools/delegate-task/plugin.ts +21 -0
  736. package/src/tools/delegate-task/types.ts +19 -0
  737. package/src/tools/glob/handler.test.ts +80 -0
  738. package/src/tools/glob/handler.ts +74 -0
  739. package/src/tools/glob/index.ts +2 -0
  740. package/src/tools/glob/plugin.ts +10 -0
  741. package/src/tools/glob/types.ts +14 -0
  742. package/src/tools/grep/handler.test.ts +79 -0
  743. package/src/tools/grep/handler.ts +104 -0
  744. package/src/tools/grep/index.ts +2 -0
  745. package/src/tools/grep/plugin.ts +10 -0
  746. package/src/tools/grep/types.ts +28 -0
  747. package/src/tools/hashline-edit/constants.ts +10 -0
  748. package/src/tools/hashline-edit/edit-operations.ts +115 -0
  749. package/src/tools/hashline-edit/handler.test.ts +105 -0
  750. package/src/tools/hashline-edit/handler.ts +33 -0
  751. package/src/tools/hashline-edit/hash-computation.ts +20 -0
  752. package/src/tools/hashline-edit/hashline-edit.test.ts +62 -0
  753. package/src/tools/hashline-edit/index.ts +5 -0
  754. package/src/tools/hashline-edit/plugin.ts +28 -0
  755. package/src/tools/hashline-edit/types.ts +42 -0
  756. package/src/tools/index.ts +4 -0
  757. package/src/tools/look-at/handler.test.ts +189 -0
  758. package/src/tools/look-at/handler.ts +232 -0
  759. package/src/tools/look-at/index.ts +3 -0
  760. package/src/tools/look-at/look-at.test.ts +200 -0
  761. package/src/tools/look-at/plugin.ts +10 -0
  762. package/src/tools/look-at/types.ts +17 -0
  763. package/src/tools/lsp/client.ts +145 -0
  764. package/src/tools/lsp/diagnostics/handler.test.ts +94 -0
  765. package/src/tools/lsp/diagnostics/handler.ts +39 -0
  766. package/src/tools/lsp/diagnostics/plugin.ts +10 -0
  767. package/src/tools/lsp/diagnostics/types.ts +15 -0
  768. package/src/tools/lsp/find-references/handler.test.ts +79 -0
  769. package/src/tools/lsp/find-references/handler.ts +38 -0
  770. package/src/tools/lsp/find-references/plugin.ts +10 -0
  771. package/src/tools/lsp/find-references/types.ts +10 -0
  772. package/src/tools/lsp/goto-definition/handler.test.ts +80 -0
  773. package/src/tools/lsp/goto-definition/handler.ts +38 -0
  774. package/src/tools/lsp/goto-definition/plugin.ts +10 -0
  775. package/src/tools/lsp/goto-definition/types.ts +9 -0
  776. package/src/tools/lsp/index.ts +6 -0
  777. package/src/tools/lsp/lsp-tools.test.ts +150 -0
  778. package/src/tools/lsp/prepare-rename/handler.test.ts +81 -0
  779. package/src/tools/lsp/prepare-rename/handler.ts +34 -0
  780. package/src/tools/lsp/prepare-rename/plugin.ts +10 -0
  781. package/src/tools/lsp/prepare-rename/types.ts +9 -0
  782. package/src/tools/lsp/rename/handler.test.ts +87 -0
  783. package/src/tools/lsp/rename/handler.ts +34 -0
  784. package/src/tools/lsp/rename/plugin.ts +10 -0
  785. package/src/tools/lsp/rename/types.ts +10 -0
  786. package/src/tools/lsp/symbols/handler.test.ts +108 -0
  787. package/src/tools/lsp/symbols/handler.ts +43 -0
  788. package/src/tools/lsp/symbols/plugin.ts +10 -0
  789. package/src/tools/lsp/symbols/types.ts +13 -0
  790. package/src/tools/session-manager/client-context.ts +16 -0
  791. package/src/tools/session-manager/index.ts +5 -0
  792. package/src/tools/session-manager/info/handler.test.ts +100 -0
  793. package/src/tools/session-manager/info/handler.ts +27 -0
  794. package/src/tools/session-manager/info/plugin.ts +40 -0
  795. package/src/tools/session-manager/info/types.ts +3 -0
  796. package/src/tools/session-manager/list/handler.test.ts +122 -0
  797. package/src/tools/session-manager/list/handler.ts +56 -0
  798. package/src/tools/session-manager/list/plugin.ts +52 -0
  799. package/src/tools/session-manager/list/types.ts +6 -0
  800. package/src/tools/session-manager/read/handler.test.ts +114 -0
  801. package/src/tools/session-manager/read/handler.ts +36 -0
  802. package/src/tools/session-manager/read/plugin.ts +57 -0
  803. package/src/tools/session-manager/read/types.ts +6 -0
  804. package/src/tools/session-manager/search/handler.test.ts +115 -0
  805. package/src/tools/session-manager/search/handler.ts +72 -0
  806. package/src/tools/session-manager/search/plugin.ts +57 -0
  807. package/src/tools/session-manager/search/types.ts +6 -0
  808. package/src/tools/session-manager/session-formatter.ts +315 -0
  809. package/src/tools/session-manager/session-manager.test.ts +254 -0
  810. package/src/tools/session-manager/types.ts +41 -0
  811. package/src/tools/shared/constants.ts +3 -0
  812. package/src/tools/skill/handler.test.ts +57 -0
  813. package/src/tools/skill/handler.ts +27 -0
  814. package/src/tools/skill/index.ts +3 -0
  815. package/src/tools/skill/plugin.ts +41 -0
  816. package/src/tools/skill/types.ts +14 -0
  817. package/src/tools/skill-mcp/handler.test.ts +68 -0
  818. package/src/tools/skill-mcp/handler.ts +84 -0
  819. package/src/tools/skill-mcp/index.ts +3 -0
  820. package/src/tools/skill-mcp/plugin.ts +37 -0
  821. package/src/tools/skill-mcp/types.ts +15 -0
  822. package/src/tools/skill-tools.test.ts +172 -0
  823. package/src/tools/task/create/handler.test.ts +64 -0
  824. package/src/tools/task/create/handler.ts +43 -0
  825. package/src/tools/task/create/plugin.ts +10 -0
  826. package/src/tools/task/format-task.test.ts +37 -0
  827. package/src/tools/task/format-task.ts +19 -0
  828. package/src/tools/task/get/handler.test.ts +76 -0
  829. package/src/tools/task/get/handler.ts +35 -0
  830. package/src/tools/task/get/plugin.ts +10 -0
  831. package/src/tools/task/index.ts +4 -0
  832. package/src/tools/task/list/handler.test.ts +70 -0
  833. package/src/tools/task/list/handler.ts +48 -0
  834. package/src/tools/task/list/plugin.ts +10 -0
  835. package/src/tools/task/storage.ts +14 -0
  836. package/src/tools/task/task.test.ts +165 -0
  837. package/src/tools/task/types.ts +51 -0
  838. package/src/tools/task/update/handler.test.ts +86 -0
  839. package/src/tools/task/update/handler.ts +54 -0
  840. package/src/tools/task/update/plugin.ts +10 -0
  841. package/src/tools/tool-builder.test.ts +32 -0
  842. package/src/tools/tool-builder.ts +24 -0
  843. package/src/tools/tool-registry-adapter.test.ts +51 -0
  844. package/src/tools/tool-registry-adapter.ts +19 -0
  845. package/src/types/agent.ts +53 -0
  846. package/src/types/category.ts +32 -0
  847. package/src/types/config.ts +26 -0
  848. package/src/types/hook.ts +44 -0
  849. package/src/types/index.ts +12 -0
  850. package/src/types/plugin.ts +47 -0
  851. package/src/types/tool.ts +10 -0
  852. package/test-setup.ts +8 -0
  853. package/tsconfig.json +20 -0
  854. /package/{index.js → npm-reserve/index.js} +0 -0
@@ -0,0 +1,186 @@
1
+ import { describe, expect, it, mock } from "bun:test";
2
+
3
+ import type { PluginAgentContribution } from "../types/agent";
4
+ import type { PluginDefinition, PluginHookHandler } from "../types/plugin";
5
+ import type { PluginToolContribution } from "../types/tool";
6
+
7
+ const logSpy = mock(() => {});
8
+
9
+ mock.module("../shared/logger", () => ({
10
+ log: logSpy,
11
+ }));
12
+
13
+ import { wrapSafely } from "../hooks/safe-hook-wrapper";
14
+ import { aggregateAgents } from "./agent-aggregator";
15
+ import { aggregateHooks } from "./hook-aggregator";
16
+ import { aggregateTools } from "./tool-aggregator";
17
+
18
+ function makeToolContribution(id: string): PluginToolContribution {
19
+ return {
20
+ execute: async () => id,
21
+ } as unknown as PluginToolContribution;
22
+ }
23
+
24
+ function makeAgentContribution(model: string): PluginAgentContribution {
25
+ return {
26
+ instructions: "integration-test",
27
+ model,
28
+ } as unknown as PluginAgentContribution;
29
+ }
30
+
31
+ describe("aggregateTools", () => {
32
+ describe("#given two plugins that register the same tool name", () => {
33
+ describe("#when aggregateTools runs in replace conflict mode", () => {
34
+ it("#then the last plugin tool wins and a conflict warning is logged", () => {
35
+ const toolA = makeToolContribution("plugin-a");
36
+ const toolB = makeToolContribution("plugin-b");
37
+ const plugins: PluginDefinition[] = [
38
+ { name: "plugin-a", tools: { search: toolA } },
39
+ { name: "plugin-b", tools: { search: toolB } },
40
+ ];
41
+ const callsBefore = logSpy.mock.calls.length;
42
+
43
+ const aggregated = aggregateTools(plugins);
44
+
45
+ expect(aggregated.search).toBe(toolB);
46
+ expect(aggregated.search).not.toBe(toolA);
47
+ expect(logSpy.mock.calls.length).toBeGreaterThan(callsBefore);
48
+ expect(
49
+ logSpy.mock.calls
50
+ .slice(callsBefore)
51
+ .some(
52
+ (call) =>
53
+ typeof call[0] === "string" &&
54
+ call[0].includes("CONFLICT") &&
55
+ call[0].includes('"search"'),
56
+ ),
57
+ ).toBe(true);
58
+ });
59
+ });
60
+ });
61
+ });
62
+
63
+ describe("aggregateAgents", () => {
64
+ describe("#given two plugins that register the same agent name", () => {
65
+ describe("#when aggregateAgents runs in replace conflict mode", () => {
66
+ it("#then the second plugin agent overwrites the first", () => {
67
+ const firstAgent = makeAgentContribution("model-a");
68
+ const secondAgent = makeAgentContribution("model-b");
69
+ const plugins: PluginDefinition[] = [
70
+ { name: "plugin-a", agents: { advisor: firstAgent } },
71
+ { name: "plugin-b", agents: { advisor: secondAgent } },
72
+ ];
73
+
74
+ const aggregated = aggregateAgents(plugins);
75
+
76
+ expect(aggregated.advisor).toBe(secondAgent);
77
+ expect(aggregated.advisor).not.toBe(firstAgent);
78
+ });
79
+ });
80
+ });
81
+ });
82
+
83
+ describe("aggregateHooks", () => {
84
+ describe("#given two plugins that register the same hook event", () => {
85
+ describe("#when aggregateHooks runs in append conflict mode", () => {
86
+ it("#then both handlers are collected in plugin order", () => {
87
+ type ToolExecuteBeforeHandler = NonNullable<
88
+ PluginDefinition["hooks"]
89
+ >["tool.execute.before"];
90
+ const first: ToolExecuteBeforeHandler = async () => {};
91
+ const second: ToolExecuteBeforeHandler = async () => {};
92
+ const plugins: PluginDefinition[] = [
93
+ { name: "plugin-a", hooks: { "tool.execute.before": first } },
94
+ { name: "plugin-b", hooks: { "tool.execute.before": second } },
95
+ ];
96
+
97
+ const aggregated = aggregateHooks(plugins);
98
+
99
+ expect(aggregated.get("tool.execute.before")).toEqual([first, second]);
100
+ });
101
+ });
102
+ });
103
+ });
104
+
105
+ describe("wrapSafely", () => {
106
+ describe("#given a hook handler partially mutates output before throwing", () => {
107
+ describe("#when the wrapped handler executes", () => {
108
+ it("#then the throw is swallowed and partial mutation remains", async () => {
109
+ const handler: PluginHookHandler = async (_input, output) => {
110
+ const mutableOutput = output as { output: string };
111
+ mutableOutput.output = "partial";
112
+ throw new Error("boom");
113
+ };
114
+ const wrapped = wrapSafely("test", handler);
115
+ const output = { output: "" };
116
+
117
+ await expect(wrapped({}, output)).resolves.toBeUndefined();
118
+ expect(output.output).toBe("partial");
119
+ });
120
+ });
121
+ });
122
+
123
+ describe("#given handlers that throw non-Error values", () => {
124
+ describe("#when each handler is wrapped and executed", () => {
125
+ it("#then string, number, and object throws are all swallowed", async () => {
126
+ const nonErrorThrows = ["string error", 42, { code: "ERR_CUSTOM" }] as const;
127
+
128
+ for (const thrownValue of nonErrorThrows) {
129
+ const handler: PluginHookHandler = async () => {
130
+ throw thrownValue;
131
+ };
132
+ const wrapped = wrapSafely("non-error", handler);
133
+
134
+ await expect(wrapped({}, {})).resolves.toBeUndefined();
135
+ }
136
+ });
137
+ });
138
+ });
139
+ });
140
+
141
+ describe("disabled contributions", () => {
142
+ describe("#given hook, tool, and agent entries that are disabled by name", () => {
143
+ describe("#when each aggregator runs with disabled arrays", () => {
144
+ it("#then disabled entries are excluded from aggregated output", () => {
145
+ const hooksPlugins: PluginDefinition[] = [
146
+ {
147
+ name: "hooks-plugin",
148
+ hooks: {
149
+ "comment-checker": async () => {},
150
+ "tool.execute.before": async () => {},
151
+ } as unknown as NonNullable<PluginDefinition["hooks"]>,
152
+ },
153
+ ];
154
+ const toolsPlugins: PluginDefinition[] = [
155
+ {
156
+ name: "tools-plugin",
157
+ tools: {
158
+ grep: makeToolContribution("grep"),
159
+ safe_tool: makeToolContribution("safe-tool"),
160
+ },
161
+ },
162
+ ];
163
+ const agentsPlugins: PluginDefinition[] = [
164
+ {
165
+ name: "agents-plugin",
166
+ agents: {
167
+ advisor: makeAgentContribution("model-advisor"),
168
+ worker: makeAgentContribution("model-worker"),
169
+ },
170
+ },
171
+ ];
172
+
173
+ const hooks = aggregateHooks(hooksPlugins, ["comment-checker"]);
174
+ const tools = aggregateTools(toolsPlugins, ["grep"]);
175
+ const agents = aggregateAgents(agentsPlugins, ["advisor"]);
176
+
177
+ expect(hooks.has("comment-checker")).toBe(false);
178
+ expect(hooks.has("tool.execute.before")).toBe(true);
179
+ expect(tools.grep).toBeUndefined();
180
+ expect(tools.safe_tool).toBeDefined();
181
+ expect(agents.advisor).toBeUndefined();
182
+ expect(agents.worker).toBeDefined();
183
+ });
184
+ });
185
+ });
186
+ });
@@ -0,0 +1,35 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import type { PluginDefinition } from "../types/plugin";
4
+
5
+ import { resolvePluginOrder } from "./dependency-resolver";
6
+
7
+ function makePlugin(name: string, deps: string[] = []): PluginDefinition {
8
+ return { name, dependencies: deps };
9
+ }
10
+
11
+ describe("resolvePluginOrder", () => {
12
+ test("returns all plugins in registration order when no dependencies", () => {
13
+ const plugins = [makePlugin("a"), makePlugin("b"), makePlugin("c")];
14
+ const { order } = resolvePluginOrder(plugins);
15
+ expect(order.map((plugin) => plugin.name)).toEqual(["a", "b", "c"]);
16
+ });
17
+
18
+ test("orders dependencies before dependents", () => {
19
+ const plugins = [makePlugin("c", ["b"]), makePlugin("b", ["a"]), makePlugin("a")];
20
+ const { order } = resolvePluginOrder(plugins);
21
+ const names = order.map((plugin) => plugin.name);
22
+ expect(names.indexOf("a")).toBeLessThan(names.indexOf("b"));
23
+ expect(names.indexOf("b")).toBeLessThan(names.indexOf("c"));
24
+ });
25
+
26
+ test("throws on circular dependencies", () => {
27
+ const plugins = [makePlugin("a", ["b"]), makePlugin("b", ["a"])];
28
+ expect(() => resolvePluginOrder(plugins)).toThrow("Circular dependency");
29
+ });
30
+
31
+ test("throws on unknown dependency", () => {
32
+ const plugins = [makePlugin("a", ["unknown"])];
33
+ expect(() => resolvePluginOrder(plugins)).toThrow('unknown plugin "unknown"');
34
+ });
35
+ });
@@ -0,0 +1,64 @@
1
+ import type { PluginDefinition } from "../types/plugin";
2
+
3
+ import type { ResolvedPlugin, ResolutionResult } from "./types";
4
+
5
+ export function resolvePluginOrder(plugins: PluginDefinition[]): ResolutionResult {
6
+ const pluginMap = new Map(plugins.map((plugin) => [plugin.name, plugin]));
7
+ const inDegree = new Map<string, number>();
8
+ const dependents = new Map<string, string[]>();
9
+
10
+ for (const plugin of plugins) {
11
+ inDegree.set(plugin.name, inDegree.get(plugin.name) ?? 0);
12
+ for (const dep of plugin.dependencies ?? []) {
13
+ if (!pluginMap.has(dep)) {
14
+ throw new Error(`Plugin "${plugin.name}" depends on unknown plugin "${dep}"`);
15
+ }
16
+
17
+ inDegree.set(plugin.name, (inDegree.get(plugin.name) ?? 0) + 1);
18
+ const list = dependents.get(dep) ?? [];
19
+ list.push(plugin.name);
20
+ dependents.set(dep, list);
21
+ }
22
+ }
23
+
24
+ const queue = plugins
25
+ .filter((plugin) => (inDegree.get(plugin.name) ?? 0) === 0)
26
+ .map((plugin) => plugin.name);
27
+ const order: PluginDefinition[] = [];
28
+
29
+ while (queue.length > 0) {
30
+ const name = queue.shift();
31
+ if (!name) {
32
+ break;
33
+ }
34
+
35
+ const plugin = pluginMap.get(name);
36
+ if (!plugin) {
37
+ continue;
38
+ }
39
+ order.push(plugin);
40
+
41
+ for (const dependent of dependents.get(name) ?? []) {
42
+ const next = (inDegree.get(dependent) ?? 0) - 1;
43
+ inDegree.set(dependent, next);
44
+ if (next === 0) {
45
+ queue.push(dependent);
46
+ }
47
+ }
48
+ }
49
+
50
+ if (order.length !== plugins.length) {
51
+ const resolvedNames = new Set(order.map((plugin) => plugin.name));
52
+ const remaining = plugins
53
+ .filter((plugin) => !resolvedNames.has(plugin.name))
54
+ .map((plugin) => plugin.name);
55
+ throw new Error(`Circular dependency detected among plugins: ${remaining.join(", ")}`);
56
+ }
57
+
58
+ const resultMap = new Map<string, ResolvedPlugin>();
59
+ order.forEach((plugin, orderIndex) => {
60
+ resultMap.set(plugin.name, { plugin, order: orderIndex });
61
+ });
62
+
63
+ return { order, map: resultMap };
64
+ }
@@ -0,0 +1,78 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { withPriority } from "../hooks/hook-ordering";
3
+ import type { PluginDefinition } from "../types/plugin";
4
+ import { aggregateHooks } from "./hook-aggregator";
5
+
6
+ describe("aggregateHooks", () => {
7
+ it("orders handlers by explicit priority", async () => {
8
+ const execution: string[] = [];
9
+
10
+ const low = withPriority(async () => {
11
+ execution.push("low");
12
+ }, 20);
13
+
14
+ const high = withPriority(async () => {
15
+ execution.push("high");
16
+ }, -20);
17
+
18
+ const pluginA: PluginDefinition = {
19
+ name: "plugin-a",
20
+ hooks: {
21
+ "tool.execute.after": low,
22
+ },
23
+ };
24
+
25
+ const pluginB: PluginDefinition = {
26
+ name: "plugin-b",
27
+ hooks: {
28
+ "tool.execute.after": high,
29
+ },
30
+ };
31
+
32
+ const map = aggregateHooks([pluginA, pluginB]);
33
+ const handlers = map.get("tool.execute.after");
34
+
35
+ expect(handlers).toBeDefined();
36
+ for (const handler of handlers ?? []) {
37
+ await handler({}, {});
38
+ }
39
+
40
+ expect(execution).toEqual(["high", "low"]);
41
+ });
42
+
43
+ it("keeps registration order when priorities are equal", async () => {
44
+ const execution: string[] = [];
45
+
46
+ const first = async () => {
47
+ execution.push("first");
48
+ };
49
+
50
+ const second = async () => {
51
+ execution.push("second");
52
+ };
53
+
54
+ const pluginA: PluginDefinition = {
55
+ name: "plugin-a",
56
+ hooks: {
57
+ "chat.message": first,
58
+ },
59
+ };
60
+
61
+ const pluginB: PluginDefinition = {
62
+ name: "plugin-b",
63
+ hooks: {
64
+ "chat.message": second,
65
+ },
66
+ };
67
+
68
+ const map = aggregateHooks([pluginA, pluginB]);
69
+ const handlers = map.get("chat.message");
70
+
71
+ expect(handlers).toBeDefined();
72
+ for (const handler of handlers ?? []) {
73
+ await handler({}, {});
74
+ }
75
+
76
+ expect(execution).toEqual(["first", "second"]);
77
+ });
78
+ });
@@ -0,0 +1,63 @@
1
+ import type { PluginDefinition, PluginHookHandler } from "../types/plugin";
2
+ import { log } from "../shared/logger";
3
+ import { HOOK_TIERS, type HookTier } from "../hooks/hook-types";
4
+ import { getHookPriority, sortByPriority } from "../hooks/hook-ordering";
5
+
6
+ const TIER_PRIORITIES: Record<HookTier, number> = {
7
+ config: 0,
8
+ message: 10,
9
+ transform: 20,
10
+ event: 30,
11
+ tool: 40,
12
+ };
13
+
14
+ export function aggregateHooks(
15
+ plugins: PluginDefinition[],
16
+ disabledHooks?: string[],
17
+ ): Map<string, PluginHookHandler[]> {
18
+ const disabled = new Set(disabledHooks ?? []);
19
+ const hookMap = new Map<string, PluginHookHandler[]>();
20
+ const skippedHooks: string[] = [];
21
+
22
+ for (const plugin of plugins) {
23
+ if (!plugin.hooks) {
24
+ continue;
25
+ }
26
+
27
+ for (const [eventName, handler] of Object.entries(plugin.hooks)) {
28
+ if (handler === undefined) {
29
+ continue;
30
+ }
31
+ if (disabled.has(eventName)) {
32
+ skippedHooks.push(eventName);
33
+ continue;
34
+ }
35
+
36
+ const handlers = hookMap.get(eventName) ?? [];
37
+ // Type cast is necessary: TypeScript cannot narrow the union type HookHandlerFor<Name>
38
+ // in a generic loop. The cast is safe because each handler is registered under its
39
+ // correct event name and will be called with the appropriate arguments by the compositor.
40
+ handlers.push(handler as PluginHookHandler);
41
+ hookMap.set(eventName, handlers);
42
+ }
43
+ }
44
+
45
+ for (const [eventName, handlers] of hookMap.entries()) {
46
+ const tier = HOOK_TIERS[eventName as keyof typeof HOOK_TIERS];
47
+ const tierPriority = tier ? TIER_PRIORITIES[tier] : 100;
48
+ const prioritized = handlers.map((handler, order) => ({
49
+ handler,
50
+ priority: tierPriority + getHookPriority(handler),
51
+ order,
52
+ }));
53
+ hookMap.set(eventName, sortByPriority(prioritized));
54
+ }
55
+
56
+ if (skippedHooks.length > 0) {
57
+ log(
58
+ `[hook-aggregator] Skipped ${skippedHooks.length} disabled hook(s): ${skippedHooks.join(", ")}`,
59
+ );
60
+ }
61
+
62
+ return hookMap;
63
+ }
@@ -0,0 +1,6 @@
1
+ export { aggregateAgents } from "./agent-aggregator";
2
+ export { resolvePluginOrder } from "./dependency-resolver";
3
+ export { aggregateHooks } from "./hook-aggregator";
4
+ export { PluginRegistry } from "./plugin-registry";
5
+ export { aggregateTools } from "./tool-aggregator";
6
+ export type { ResolutionResult, ResolvedPlugin } from "./types";
@@ -0,0 +1,94 @@
1
+ import { describe, expect, it, mock } from "bun:test";
2
+ import { createMockPluginContext } from "../test-utils/mock-plugin-context";
3
+ import type { PluginDefinition } from "../types/plugin";
4
+ import type { PluginToolContribution } from "../types/tool";
5
+ import { PluginRegistry } from "./plugin-registry";
6
+
7
+ function makeTool(): PluginToolContribution {
8
+ return { execute: async () => "ok" } as unknown as PluginToolContribution;
9
+ }
10
+
11
+ describe("plugin lifecycle integration", () => {
12
+ it("resolves, sets up, aggregates, and composes a valid plugin graph", async () => {
13
+ const setupCore = mock(async () => {});
14
+ const setupAddon = mock(async () => {});
15
+
16
+ const core: PluginDefinition = {
17
+ name: "core",
18
+ setup: setupCore,
19
+ tools: { core_tool: makeTool() },
20
+ };
21
+
22
+ const addon: PluginDefinition = {
23
+ name: "addon",
24
+ dependencies: ["core"],
25
+ setup: setupAddon,
26
+ hooks: {
27
+ "tool.execute.before": async () => {},
28
+ },
29
+ };
30
+
31
+ const registry = new PluginRegistry();
32
+ registry.register(addon);
33
+ registry.register(core);
34
+
35
+ const resolved = registry.resolve();
36
+ expect(resolved.map((plugin) => plugin.name)).toEqual(["core", "addon"]);
37
+
38
+ const initialized = await registry.setup(resolved, createMockPluginContext());
39
+ expect(initialized.map((plugin) => plugin.name)).toEqual(["core", "addon"]);
40
+ expect(setupCore).toHaveBeenCalledTimes(1);
41
+ expect(setupAddon).toHaveBeenCalledTimes(1);
42
+
43
+ const aggregated = registry.aggregate(initialized);
44
+ expect(Object.keys(aggregated.tools)).toContain("core_tool");
45
+ expect(aggregated.hooks.get("tool.execute.before")?.length).toBe(1);
46
+
47
+ expect(aggregated.tools.core_tool).toBeDefined();
48
+ expect(aggregated.hooks.get("tool.execute.before")?.length).toBe(1);
49
+ });
50
+
51
+ it("fails resolution when a dependency is missing", () => {
52
+ const registry = new PluginRegistry();
53
+ registry.register({ name: "feature", dependencies: ["missing"] });
54
+
55
+ expect(() => registry.resolve()).toThrow("depends on unknown plugin");
56
+ });
57
+
58
+ it("fails resolution when dependencies are circular", () => {
59
+ const registry = new PluginRegistry();
60
+ registry.register({ name: "a", dependencies: ["b"] });
61
+ registry.register({ name: "b", dependencies: ["a"] });
62
+
63
+ expect(() => registry.resolve()).toThrow("Circular dependency");
64
+ });
65
+
66
+ it("continues setup when one plugin setup fails", async () => {
67
+ const registry = new PluginRegistry();
68
+ const badSetup = mock(async () => {
69
+ throw new Error("setup failed");
70
+ });
71
+ const goodSetup = mock(async () => {});
72
+
73
+ registry.register({
74
+ name: "bad",
75
+ setup: badSetup,
76
+ tools: { bad_tool: makeTool() },
77
+ });
78
+ registry.register({
79
+ name: "good",
80
+ setup: goodSetup,
81
+ tools: { good_tool: makeTool() },
82
+ });
83
+
84
+ const resolved = registry.resolve();
85
+ const initialized = await registry.setup(resolved, createMockPluginContext());
86
+
87
+ expect(initialized.map((plugin) => plugin.name)).toEqual(["good"]);
88
+ expect(goodSetup).toHaveBeenCalledTimes(1);
89
+
90
+ const aggregated = registry.aggregate(initialized);
91
+ expect(Object.keys(aggregated.tools)).toContain("good_tool");
92
+ expect(Object.keys(aggregated.tools)).not.toContain("bad_tool");
93
+ });
94
+ });
@@ -0,0 +1,140 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { buildAgent } from "../agents/agent-builder";
3
+ import type { AgentConfig, AgentFactory } from "../types/agent";
4
+ import type { PluginDefinition } from "../types/plugin";
5
+ import type { PluginToolContribution } from "../types/tool";
6
+ import { aggregateAgents } from "./agent-aggregator";
7
+ import { aggregateHooks } from "./hook-aggregator";
8
+ import { PluginRegistry } from "./plugin-registry";
9
+ import { aggregateTools } from "./tool-aggregator";
10
+
11
+ function makeTool(): PluginToolContribution {
12
+ return { execute: async () => "ok" } as unknown as PluginToolContribution;
13
+ }
14
+
15
+ function makeAgent(overrides: Partial<AgentConfig> = {}): AgentConfig {
16
+ return {
17
+ instructions: "test agent",
18
+ model: "test-model",
19
+ temperature: 0.5,
20
+ ...overrides,
21
+ } as AgentConfig;
22
+ }
23
+
24
+ describe("plugin overrides integration", () => {
25
+ describe("aggregateAgents", () => {
26
+ describe("#given a plugin contributing an agent named 'advisor'", () => {
27
+ describe("#when aggregated with disabledAgents containing 'advisor'", () => {
28
+ it("#then 'advisor' is not present in the aggregated output", () => {
29
+ const plugin: PluginDefinition = {
30
+ name: "test-plugin",
31
+ agents: { advisor: makeAgent() },
32
+ };
33
+
34
+ const result = aggregateAgents([plugin], ["advisor"]);
35
+
36
+ expect(result).not.toHaveProperty("advisor");
37
+ expect(Object.keys(result)).toHaveLength(0);
38
+ });
39
+ });
40
+ });
41
+ });
42
+
43
+ describe("aggregateTools", () => {
44
+ describe("#given a plugin contributing a tool named 'grep'", () => {
45
+ describe("#when aggregated with disabledTools containing 'grep'", () => {
46
+ it("#then 'grep' is not present in the aggregated output", () => {
47
+ const plugin: PluginDefinition = {
48
+ name: "test-plugin",
49
+ tools: { grep: makeTool() },
50
+ };
51
+
52
+ const result = aggregateTools([plugin], ["grep"]);
53
+
54
+ expect(result).not.toHaveProperty("grep");
55
+ expect(Object.keys(result)).toHaveLength(0);
56
+ });
57
+ });
58
+ });
59
+ });
60
+
61
+ describe("aggregateHooks", () => {
62
+ describe("#given a plugin contributing a 'tool.execute.before' hook handler", () => {
63
+ describe("#when aggregated with disabledHooks containing 'tool.execute.before'", () => {
64
+ it("#then 'tool.execute.before' is absent from the result map", () => {
65
+ const plugin: PluginDefinition = {
66
+ name: "test-plugin",
67
+ hooks: {
68
+ "tool.execute.before": async () => {},
69
+ },
70
+ };
71
+
72
+ const result = aggregateHooks([plugin], ["tool.execute.before"]);
73
+
74
+ expect(result.has("tool.execute.before")).toBe(false);
75
+ expect(result.size).toBe(0);
76
+ });
77
+ });
78
+ });
79
+ });
80
+
81
+ describe("buildAgent", () => {
82
+ describe("#given an agent factory returning model 'original-model' and temperature 0.5", () => {
83
+ describe("#when built with overrides model 'override-model' and temperature 0.9", () => {
84
+ it("#then the returned config has the overridden model and temperature", () => {
85
+ const factory: AgentFactory = Object.assign(
86
+ (_model: string): AgentConfig =>
87
+ ({
88
+ instructions: "test agent",
89
+ model: "original-model",
90
+ temperature: 0.5,
91
+ }) as AgentConfig,
92
+ { mode: "all" as const },
93
+ );
94
+
95
+ const result = buildAgent(factory, "base-model", undefined, {
96
+ model: "override-model",
97
+ temperature: 0.9,
98
+ });
99
+
100
+ expect(result.model).toBe("override-model");
101
+ expect(result.temperature).toBe(0.9);
102
+ expect(result.instructions).toBe("test agent");
103
+ });
104
+ });
105
+ });
106
+ });
107
+
108
+ describe("PluginRegistry.aggregate", () => {
109
+ describe("#given a plugin with agent 'advisor', tool 'grep', and hook 'tool.execute.before'", () => {
110
+ describe("#when aggregated with disabledAgents=['advisor'] and disabledTools=['grep']", () => {
111
+ it("#then 'advisor' not in agents, 'grep' not in tools, but hook is still present", () => {
112
+ const plugin: PluginDefinition = {
113
+ name: "test-plugin",
114
+ agents: { advisor: makeAgent() },
115
+ tools: { grep: makeTool() },
116
+ hooks: {
117
+ "tool.execute.before": async () => {},
118
+ },
119
+ };
120
+
121
+ const registry = new PluginRegistry();
122
+ registry.register(plugin);
123
+ const resolved = registry.resolve();
124
+
125
+ const aggregated = registry.aggregate(resolved, {
126
+ disabledAgents: ["advisor"],
127
+ disabledTools: ["grep"],
128
+ });
129
+
130
+ expect(aggregated.agents).not.toHaveProperty("advisor");
131
+ expect(Object.keys(aggregated.agents)).toHaveLength(0);
132
+ expect(aggregated.tools).not.toHaveProperty("grep");
133
+ expect(Object.keys(aggregated.tools)).toHaveLength(0);
134
+ expect(aggregated.hooks.has("tool.execute.before")).toBe(true);
135
+ expect(aggregated.hooks.get("tool.execute.before")).toHaveLength(1);
136
+ });
137
+ });
138
+ });
139
+ });
140
+ });