olympus-ai 1.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 (573) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +691 -0
  3. package/dist/__tests__/example.test.d.ts +2 -0
  4. package/dist/__tests__/example.test.d.ts.map +1 -0
  5. package/dist/__tests__/example.test.js +20 -0
  6. package/dist/__tests__/example.test.js.map +1 -0
  7. package/dist/__tests__/hooks.test.d.ts +2 -0
  8. package/dist/__tests__/hooks.test.d.ts.map +1 -0
  9. package/dist/__tests__/hooks.test.js +644 -0
  10. package/dist/__tests__/hooks.test.js.map +1 -0
  11. package/dist/__tests__/installer.test.d.ts +2 -0
  12. package/dist/__tests__/installer.test.d.ts.map +1 -0
  13. package/dist/__tests__/installer.test.js +369 -0
  14. package/dist/__tests__/installer.test.js.map +1 -0
  15. package/dist/__tests__/model-routing.test.d.ts +2 -0
  16. package/dist/__tests__/model-routing.test.d.ts.map +1 -0
  17. package/dist/__tests__/model-routing.test.js +814 -0
  18. package/dist/__tests__/model-routing.test.js.map +1 -0
  19. package/dist/__tests__/skills.test.d.ts +2 -0
  20. package/dist/__tests__/skills.test.d.ts.map +1 -0
  21. package/dist/__tests__/skills.test.js +126 -0
  22. package/dist/__tests__/skills.test.js.map +1 -0
  23. package/dist/__tests__/types.test.d.ts +2 -0
  24. package/dist/__tests__/types.test.d.ts.map +1 -0
  25. package/dist/__tests__/types.test.js +77 -0
  26. package/dist/__tests__/types.test.js.map +1 -0
  27. package/dist/agents/definitions.d.ts +105 -0
  28. package/dist/agents/definitions.d.ts.map +1 -0
  29. package/dist/agents/definitions.js +1379 -0
  30. package/dist/agents/definitions.js.map +1 -0
  31. package/dist/agents/document-writer.d.ts +11 -0
  32. package/dist/agents/document-writer.d.ts.map +1 -0
  33. package/dist/agents/document-writer.js +209 -0
  34. package/dist/agents/document-writer.js.map +1 -0
  35. package/dist/agents/explore.d.ts +12 -0
  36. package/dist/agents/explore.d.ts.map +1 -0
  37. package/dist/agents/explore.js +103 -0
  38. package/dist/agents/explore.js.map +1 -0
  39. package/dist/agents/frontend-engineer.d.ts +11 -0
  40. package/dist/agents/frontend-engineer.d.ts.map +1 -0
  41. package/dist/agents/frontend-engineer.js +115 -0
  42. package/dist/agents/frontend-engineer.js.map +1 -0
  43. package/dist/agents/index.d.ts +21 -0
  44. package/dist/agents/index.d.ts.map +1 -0
  45. package/dist/agents/index.js +27 -0
  46. package/dist/agents/index.js.map +1 -0
  47. package/dist/agents/librarian.d.ts +12 -0
  48. package/dist/agents/librarian.d.ts.map +1 -0
  49. package/dist/agents/librarian.js +103 -0
  50. package/dist/agents/librarian.js.map +1 -0
  51. package/dist/agents/metis.d.ts +12 -0
  52. package/dist/agents/metis.d.ts.map +1 -0
  53. package/dist/agents/metis.js +117 -0
  54. package/dist/agents/metis.js.map +1 -0
  55. package/dist/agents/momus.d.ts +12 -0
  56. package/dist/agents/momus.d.ts.map +1 -0
  57. package/dist/agents/momus.js +128 -0
  58. package/dist/agents/momus.js.map +1 -0
  59. package/dist/agents/multimodal-looker.d.ts +11 -0
  60. package/dist/agents/multimodal-looker.d.ts.map +1 -0
  61. package/dist/agents/multimodal-looker.js +70 -0
  62. package/dist/agents/multimodal-looker.js.map +1 -0
  63. package/dist/agents/olympian.d.ts +12 -0
  64. package/dist/agents/olympian.d.ts.map +1 -0
  65. package/dist/agents/olympian.js +93 -0
  66. package/dist/agents/olympian.js.map +1 -0
  67. package/dist/agents/oracle.d.ts +13 -0
  68. package/dist/agents/oracle.d.ts.map +1 -0
  69. package/dist/agents/oracle.js +191 -0
  70. package/dist/agents/oracle.js.map +1 -0
  71. package/dist/agents/orchestrator-olympus.d.ts +11 -0
  72. package/dist/agents/orchestrator-olympus.d.ts.map +1 -0
  73. package/dist/agents/orchestrator-olympus.js +115 -0
  74. package/dist/agents/orchestrator-olympus.js.map +1 -0
  75. package/dist/agents/orchestrator-sisyphus.d.ts +11 -0
  76. package/dist/agents/orchestrator-sisyphus.d.ts.map +1 -0
  77. package/dist/agents/orchestrator-sisyphus.js +115 -0
  78. package/dist/agents/orchestrator-sisyphus.js.map +1 -0
  79. package/dist/agents/prometheus.d.ts +12 -0
  80. package/dist/agents/prometheus.d.ts.map +1 -0
  81. package/dist/agents/prometheus.js +156 -0
  82. package/dist/agents/prometheus.js.map +1 -0
  83. package/dist/agents/qa-tester.d.ts +16 -0
  84. package/dist/agents/qa-tester.d.ts.map +1 -0
  85. package/dist/agents/qa-tester.js +367 -0
  86. package/dist/agents/qa-tester.js.map +1 -0
  87. package/dist/agents/sisyphus-junior.d.ts +12 -0
  88. package/dist/agents/sisyphus-junior.d.ts.map +1 -0
  89. package/dist/agents/sisyphus-junior.js +93 -0
  90. package/dist/agents/sisyphus-junior.js.map +1 -0
  91. package/dist/agents/types.d.ts +120 -0
  92. package/dist/agents/types.d.ts.map +1 -0
  93. package/dist/agents/types.js +38 -0
  94. package/dist/agents/types.js.map +1 -0
  95. package/dist/agents/utils.d.ts +49 -0
  96. package/dist/agents/utils.d.ts.map +1 -0
  97. package/dist/agents/utils.js +164 -0
  98. package/dist/agents/utils.js.map +1 -0
  99. package/dist/cli/index.d.ts +13 -0
  100. package/dist/cli/index.d.ts.map +1 -0
  101. package/dist/cli/index.js +496 -0
  102. package/dist/cli/index.js.map +1 -0
  103. package/dist/commands/index.d.ts +78 -0
  104. package/dist/commands/index.d.ts.map +1 -0
  105. package/dist/commands/index.js +148 -0
  106. package/dist/commands/index.js.map +1 -0
  107. package/dist/config/index.d.ts +5 -0
  108. package/dist/config/index.d.ts.map +1 -0
  109. package/dist/config/index.js +5 -0
  110. package/dist/config/index.js.map +1 -0
  111. package/dist/config/loader.d.ts +49 -0
  112. package/dist/config/loader.d.ts.map +1 -0
  113. package/dist/config/loader.js +380 -0
  114. package/dist/config/loader.js.map +1 -0
  115. package/dist/features/auto-update.d.ts +187 -0
  116. package/dist/features/auto-update.d.ts.map +1 -0
  117. package/dist/features/auto-update.js +539 -0
  118. package/dist/features/auto-update.js.map +1 -0
  119. package/dist/features/background-agent/concurrency.d.ts +53 -0
  120. package/dist/features/background-agent/concurrency.d.ts.map +1 -0
  121. package/dist/features/background-agent/concurrency.js +121 -0
  122. package/dist/features/background-agent/concurrency.js.map +1 -0
  123. package/dist/features/background-agent/index.d.ts +12 -0
  124. package/dist/features/background-agent/index.d.ts.map +1 -0
  125. package/dist/features/background-agent/index.js +12 -0
  126. package/dist/features/background-agent/index.js.map +1 -0
  127. package/dist/features/background-agent/manager.d.ts +134 -0
  128. package/dist/features/background-agent/manager.d.ts.map +1 -0
  129. package/dist/features/background-agent/manager.js +412 -0
  130. package/dist/features/background-agent/manager.js.map +1 -0
  131. package/dist/features/background-agent/types.d.ts +99 -0
  132. package/dist/features/background-agent/types.d.ts.map +1 -0
  133. package/dist/features/background-agent/types.js +9 -0
  134. package/dist/features/background-agent/types.js.map +1 -0
  135. package/dist/features/background-tasks.d.ts +99 -0
  136. package/dist/features/background-tasks.d.ts.map +1 -0
  137. package/dist/features/background-tasks.js +265 -0
  138. package/dist/features/background-tasks.js.map +1 -0
  139. package/dist/features/boulder-state/constants.d.ts +20 -0
  140. package/dist/features/boulder-state/constants.d.ts.map +1 -0
  141. package/dist/features/boulder-state/constants.js +20 -0
  142. package/dist/features/boulder-state/constants.js.map +1 -0
  143. package/dist/features/boulder-state/index.d.ts +12 -0
  144. package/dist/features/boulder-state/index.d.ts.map +1 -0
  145. package/dist/features/boulder-state/index.js +13 -0
  146. package/dist/features/boulder-state/index.js.map +1 -0
  147. package/dist/features/boulder-state/storage.d.ts +58 -0
  148. package/dist/features/boulder-state/storage.d.ts.map +1 -0
  149. package/dist/features/boulder-state/storage.js +174 -0
  150. package/dist/features/boulder-state/storage.js.map +1 -0
  151. package/dist/features/boulder-state/types.d.ts +48 -0
  152. package/dist/features/boulder-state/types.d.ts.map +1 -0
  153. package/dist/features/boulder-state/types.js +10 -0
  154. package/dist/features/boulder-state/types.js.map +1 -0
  155. package/dist/features/builtin-skills/index.d.ts +10 -0
  156. package/dist/features/builtin-skills/index.d.ts.map +1 -0
  157. package/dist/features/builtin-skills/index.js +10 -0
  158. package/dist/features/builtin-skills/index.js.map +1 -0
  159. package/dist/features/builtin-skills/skills.d.ts +21 -0
  160. package/dist/features/builtin-skills/skills.d.ts.map +1 -0
  161. package/dist/features/builtin-skills/skills.js +1082 -0
  162. package/dist/features/builtin-skills/skills.js.map +1 -0
  163. package/dist/features/builtin-skills/types.d.ts +60 -0
  164. package/dist/features/builtin-skills/types.d.ts.map +1 -0
  165. package/dist/features/builtin-skills/types.js +9 -0
  166. package/dist/features/builtin-skills/types.js.map +1 -0
  167. package/dist/features/context-injector/collector.d.ts +56 -0
  168. package/dist/features/context-injector/collector.d.ts.map +1 -0
  169. package/dist/features/context-injector/collector.js +122 -0
  170. package/dist/features/context-injector/collector.js.map +1 -0
  171. package/dist/features/context-injector/index.d.ts +12 -0
  172. package/dist/features/context-injector/index.d.ts.map +1 -0
  173. package/dist/features/context-injector/index.js +13 -0
  174. package/dist/features/context-injector/index.js.map +1 -0
  175. package/dist/features/context-injector/injector.d.ts +47 -0
  176. package/dist/features/context-injector/injector.d.ts.map +1 -0
  177. package/dist/features/context-injector/injector.js +103 -0
  178. package/dist/features/context-injector/injector.js.map +1 -0
  179. package/dist/features/context-injector/types.d.ts +103 -0
  180. package/dist/features/context-injector/types.d.ts.map +1 -0
  181. package/dist/features/context-injector/types.js +11 -0
  182. package/dist/features/context-injector/types.js.map +1 -0
  183. package/dist/features/continuation-enforcement.d.ts +36 -0
  184. package/dist/features/continuation-enforcement.d.ts.map +1 -0
  185. package/dist/features/continuation-enforcement.js +175 -0
  186. package/dist/features/continuation-enforcement.js.map +1 -0
  187. package/dist/features/index.d.ts +12 -0
  188. package/dist/features/index.d.ts.map +1 -0
  189. package/dist/features/index.js +49 -0
  190. package/dist/features/index.js.map +1 -0
  191. package/dist/features/magic-keywords.d.ts +28 -0
  192. package/dist/features/magic-keywords.d.ts.map +1 -0
  193. package/dist/features/magic-keywords.js +421 -0
  194. package/dist/features/magic-keywords.js.map +1 -0
  195. package/dist/features/model-routing/index.d.ts +34 -0
  196. package/dist/features/model-routing/index.d.ts.map +1 -0
  197. package/dist/features/model-routing/index.js +48 -0
  198. package/dist/features/model-routing/index.js.map +1 -0
  199. package/dist/features/model-routing/prompts/haiku.d.ts +54 -0
  200. package/dist/features/model-routing/prompts/haiku.d.ts.map +1 -0
  201. package/dist/features/model-routing/prompts/haiku.js +141 -0
  202. package/dist/features/model-routing/prompts/haiku.js.map +1 -0
  203. package/dist/features/model-routing/prompts/index.d.ts +45 -0
  204. package/dist/features/model-routing/prompts/index.d.ts.map +1 -0
  205. package/dist/features/model-routing/prompts/index.js +116 -0
  206. package/dist/features/model-routing/prompts/index.js.map +1 -0
  207. package/dist/features/model-routing/prompts/opus.d.ts +34 -0
  208. package/dist/features/model-routing/prompts/opus.d.ts.map +1 -0
  209. package/dist/features/model-routing/prompts/opus.js +153 -0
  210. package/dist/features/model-routing/prompts/opus.js.map +1 -0
  211. package/dist/features/model-routing/prompts/sonnet.d.ts +38 -0
  212. package/dist/features/model-routing/prompts/sonnet.d.ts.map +1 -0
  213. package/dist/features/model-routing/prompts/sonnet.js +149 -0
  214. package/dist/features/model-routing/prompts/sonnet.js.map +1 -0
  215. package/dist/features/model-routing/router.d.ts +92 -0
  216. package/dist/features/model-routing/router.d.ts.map +1 -0
  217. package/dist/features/model-routing/router.js +267 -0
  218. package/dist/features/model-routing/router.js.map +1 -0
  219. package/dist/features/model-routing/rules.d.ts +32 -0
  220. package/dist/features/model-routing/rules.d.ts.map +1 -0
  221. package/dist/features/model-routing/rules.js +224 -0
  222. package/dist/features/model-routing/rules.js.map +1 -0
  223. package/dist/features/model-routing/scorer.d.ts +35 -0
  224. package/dist/features/model-routing/scorer.d.ts.map +1 -0
  225. package/dist/features/model-routing/scorer.js +241 -0
  226. package/dist/features/model-routing/scorer.js.map +1 -0
  227. package/dist/features/model-routing/signals.d.ts +26 -0
  228. package/dist/features/model-routing/signals.d.ts.map +1 -0
  229. package/dist/features/model-routing/signals.js +283 -0
  230. package/dist/features/model-routing/signals.js.map +1 -0
  231. package/dist/features/model-routing/types.d.ts +195 -0
  232. package/dist/features/model-routing/types.d.ts.map +1 -0
  233. package/dist/features/model-routing/types.js +86 -0
  234. package/dist/features/model-routing/types.js.map +1 -0
  235. package/dist/hooks/agent-usage-reminder/constants.d.ts +17 -0
  236. package/dist/hooks/agent-usage-reminder/constants.d.ts.map +1 -0
  237. package/dist/hooks/agent-usage-reminder/constants.js +58 -0
  238. package/dist/hooks/agent-usage-reminder/constants.js.map +1 -0
  239. package/dist/hooks/agent-usage-reminder/index.d.ts +36 -0
  240. package/dist/hooks/agent-usage-reminder/index.d.ts.map +1 -0
  241. package/dist/hooks/agent-usage-reminder/index.js +89 -0
  242. package/dist/hooks/agent-usage-reminder/index.js.map +1 -0
  243. package/dist/hooks/agent-usage-reminder/storage.d.ts +12 -0
  244. package/dist/hooks/agent-usage-reminder/storage.d.ts.map +1 -0
  245. package/dist/hooks/agent-usage-reminder/storage.js +39 -0
  246. package/dist/hooks/agent-usage-reminder/storage.js.map +1 -0
  247. package/dist/hooks/agent-usage-reminder/types.d.ts +14 -0
  248. package/dist/hooks/agent-usage-reminder/types.d.ts.map +1 -0
  249. package/dist/hooks/agent-usage-reminder/types.js +9 -0
  250. package/dist/hooks/agent-usage-reminder/types.js.map +1 -0
  251. package/dist/hooks/ascent-verifier/index.d.ts +72 -0
  252. package/dist/hooks/ascent-verifier/index.d.ts.map +1 -0
  253. package/dist/hooks/ascent-verifier/index.js +223 -0
  254. package/dist/hooks/ascent-verifier/index.js.map +1 -0
  255. package/dist/hooks/auto-slash-command/constants.d.ts +19 -0
  256. package/dist/hooks/auto-slash-command/constants.d.ts.map +1 -0
  257. package/dist/hooks/auto-slash-command/constants.js +28 -0
  258. package/dist/hooks/auto-slash-command/constants.js.map +1 -0
  259. package/dist/hooks/auto-slash-command/detector.d.ts +33 -0
  260. package/dist/hooks/auto-slash-command/detector.d.ts.map +1 -0
  261. package/dist/hooks/auto-slash-command/detector.js +73 -0
  262. package/dist/hooks/auto-slash-command/detector.js.map +1 -0
  263. package/dist/hooks/auto-slash-command/executor.d.ts +29 -0
  264. package/dist/hooks/auto-slash-command/executor.d.ts.map +1 -0
  265. package/dist/hooks/auto-slash-command/executor.js +214 -0
  266. package/dist/hooks/auto-slash-command/executor.js.map +1 -0
  267. package/dist/hooks/auto-slash-command/index.d.ts +53 -0
  268. package/dist/hooks/auto-slash-command/index.d.ts.map +1 -0
  269. package/dist/hooks/auto-slash-command/index.js +105 -0
  270. package/dist/hooks/auto-slash-command/index.js.map +1 -0
  271. package/dist/hooks/auto-slash-command/types.d.ts +77 -0
  272. package/dist/hooks/auto-slash-command/types.d.ts.map +1 -0
  273. package/dist/hooks/auto-slash-command/types.js +9 -0
  274. package/dist/hooks/auto-slash-command/types.js.map +1 -0
  275. package/dist/hooks/background-notification/index.d.ts +60 -0
  276. package/dist/hooks/background-notification/index.d.ts.map +1 -0
  277. package/dist/hooks/background-notification/index.js +180 -0
  278. package/dist/hooks/background-notification/index.js.map +1 -0
  279. package/dist/hooks/background-notification/types.d.ts +64 -0
  280. package/dist/hooks/background-notification/types.d.ts.map +1 -0
  281. package/dist/hooks/background-notification/types.js +8 -0
  282. package/dist/hooks/background-notification/types.js.map +1 -0
  283. package/dist/hooks/bridge.d.ts +68 -0
  284. package/dist/hooks/bridge.d.ts.map +1 -0
  285. package/dist/hooks/bridge.js +321 -0
  286. package/dist/hooks/bridge.js.map +1 -0
  287. package/dist/hooks/comment-checker/constants.d.ts +28 -0
  288. package/dist/hooks/comment-checker/constants.d.ts.map +1 -0
  289. package/dist/hooks/comment-checker/constants.js +189 -0
  290. package/dist/hooks/comment-checker/constants.js.map +1 -0
  291. package/dist/hooks/comment-checker/filters.d.ts +39 -0
  292. package/dist/hooks/comment-checker/filters.d.ts.map +1 -0
  293. package/dist/hooks/comment-checker/filters.js +126 -0
  294. package/dist/hooks/comment-checker/filters.js.map +1 -0
  295. package/dist/hooks/comment-checker/index.d.ts +58 -0
  296. package/dist/hooks/comment-checker/index.d.ts.map +1 -0
  297. package/dist/hooks/comment-checker/index.js +298 -0
  298. package/dist/hooks/comment-checker/index.js.map +1 -0
  299. package/dist/hooks/comment-checker/types.d.ts +88 -0
  300. package/dist/hooks/comment-checker/types.d.ts.map +1 -0
  301. package/dist/hooks/comment-checker/types.js +9 -0
  302. package/dist/hooks/comment-checker/types.js.map +1 -0
  303. package/dist/hooks/context-window-limit-recovery/constants.d.ts +28 -0
  304. package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +1 -0
  305. package/dist/hooks/context-window-limit-recovery/constants.js +85 -0
  306. package/dist/hooks/context-window-limit-recovery/constants.js.map +1 -0
  307. package/dist/hooks/context-window-limit-recovery/index.d.ts +62 -0
  308. package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -0
  309. package/dist/hooks/context-window-limit-recovery/index.js +201 -0
  310. package/dist/hooks/context-window-limit-recovery/index.js.map +1 -0
  311. package/dist/hooks/context-window-limit-recovery/parser.d.ts +31 -0
  312. package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +1 -0
  313. package/dist/hooks/context-window-limit-recovery/parser.js +241 -0
  314. package/dist/hooks/context-window-limit-recovery/parser.js.map +1 -0
  315. package/dist/hooks/context-window-limit-recovery/types.d.ts +84 -0
  316. package/dist/hooks/context-window-limit-recovery/types.d.ts.map +1 -0
  317. package/dist/hooks/context-window-limit-recovery/types.js +34 -0
  318. package/dist/hooks/context-window-limit-recovery/types.js.map +1 -0
  319. package/dist/hooks/directory-readme-injector/constants.d.ts +15 -0
  320. package/dist/hooks/directory-readme-injector/constants.d.ts.map +1 -0
  321. package/dist/hooks/directory-readme-injector/constants.js +17 -0
  322. package/dist/hooks/directory-readme-injector/constants.js.map +1 -0
  323. package/dist/hooks/directory-readme-injector/index.d.ts +41 -0
  324. package/dist/hooks/directory-readme-injector/index.d.ts.map +1 -0
  325. package/dist/hooks/directory-readme-injector/index.js +162 -0
  326. package/dist/hooks/directory-readme-injector/index.js.map +1 -0
  327. package/dist/hooks/directory-readme-injector/storage.d.ts +20 -0
  328. package/dist/hooks/directory-readme-injector/storage.d.ts.map +1 -0
  329. package/dist/hooks/directory-readme-injector/storage.js +56 -0
  330. package/dist/hooks/directory-readme-injector/storage.js.map +1 -0
  331. package/dist/hooks/directory-readme-injector/types.d.ts +20 -0
  332. package/dist/hooks/directory-readme-injector/types.d.ts.map +1 -0
  333. package/dist/hooks/directory-readme-injector/types.js +9 -0
  334. package/dist/hooks/directory-readme-injector/types.js.map +1 -0
  335. package/dist/hooks/edit-error-recovery/index.d.ts +62 -0
  336. package/dist/hooks/edit-error-recovery/index.d.ts.map +1 -0
  337. package/dist/hooks/edit-error-recovery/index.js +89 -0
  338. package/dist/hooks/edit-error-recovery/index.js.map +1 -0
  339. package/dist/hooks/empty-message-sanitizer/constants.d.ts +33 -0
  340. package/dist/hooks/empty-message-sanitizer/constants.d.ts.map +1 -0
  341. package/dist/hooks/empty-message-sanitizer/constants.js +37 -0
  342. package/dist/hooks/empty-message-sanitizer/constants.js.map +1 -0
  343. package/dist/hooks/empty-message-sanitizer/index.d.ts +59 -0
  344. package/dist/hooks/empty-message-sanitizer/index.d.ts.map +1 -0
  345. package/dist/hooks/empty-message-sanitizer/index.js +171 -0
  346. package/dist/hooks/empty-message-sanitizer/index.js.map +1 -0
  347. package/dist/hooks/empty-message-sanitizer/types.d.ts +79 -0
  348. package/dist/hooks/empty-message-sanitizer/types.d.ts.map +1 -0
  349. package/dist/hooks/empty-message-sanitizer/types.js +10 -0
  350. package/dist/hooks/empty-message-sanitizer/types.js.map +1 -0
  351. package/dist/hooks/index.d.ts +35 -0
  352. package/dist/hooks/index.d.ts.map +1 -0
  353. package/dist/hooks/index.js +81 -0
  354. package/dist/hooks/index.js.map +1 -0
  355. package/dist/hooks/keyword-detector/index.d.ts +40 -0
  356. package/dist/hooks/keyword-detector/index.d.ts.map +1 -0
  357. package/dist/hooks/keyword-detector/index.js +88 -0
  358. package/dist/hooks/keyword-detector/index.js.map +1 -0
  359. package/dist/hooks/non-interactive-env/constants.d.ts +35 -0
  360. package/dist/hooks/non-interactive-env/constants.d.ts.map +1 -0
  361. package/dist/hooks/non-interactive-env/constants.js +69 -0
  362. package/dist/hooks/non-interactive-env/constants.js.map +1 -0
  363. package/dist/hooks/non-interactive-env/detector.d.ts +2 -0
  364. package/dist/hooks/non-interactive-env/detector.d.ts.map +1 -0
  365. package/dist/hooks/non-interactive-env/detector.js +16 -0
  366. package/dist/hooks/non-interactive-env/detector.js.map +1 -0
  367. package/dist/hooks/non-interactive-env/index.d.ts +14 -0
  368. package/dist/hooks/non-interactive-env/index.d.ts.map +1 -0
  369. package/dist/hooks/non-interactive-env/index.js +72 -0
  370. package/dist/hooks/non-interactive-env/index.js.map +1 -0
  371. package/dist/hooks/non-interactive-env/types.d.ts +14 -0
  372. package/dist/hooks/non-interactive-env/types.d.ts.map +1 -0
  373. package/dist/hooks/non-interactive-env/types.js +2 -0
  374. package/dist/hooks/non-interactive-env/types.js.map +1 -0
  375. package/dist/hooks/olympus-orchestrator/constants.d.ts +23 -0
  376. package/dist/hooks/olympus-orchestrator/constants.d.ts.map +1 -0
  377. package/dist/hooks/olympus-orchestrator/constants.js +142 -0
  378. package/dist/hooks/olympus-orchestrator/constants.js.map +1 -0
  379. package/dist/hooks/olympus-orchestrator/index.d.ts +113 -0
  380. package/dist/hooks/olympus-orchestrator/index.d.ts.map +1 -0
  381. package/dist/hooks/olympus-orchestrator/index.js +283 -0
  382. package/dist/hooks/olympus-orchestrator/index.js.map +1 -0
  383. package/dist/hooks/persistent-mode/index.d.ts +40 -0
  384. package/dist/hooks/persistent-mode/index.d.ts.map +1 -0
  385. package/dist/hooks/persistent-mode/index.js +322 -0
  386. package/dist/hooks/persistent-mode/index.js.map +1 -0
  387. package/dist/hooks/plugin-patterns/index.d.ts +107 -0
  388. package/dist/hooks/plugin-patterns/index.d.ts.map +1 -0
  389. package/dist/hooks/plugin-patterns/index.js +289 -0
  390. package/dist/hooks/plugin-patterns/index.js.map +1 -0
  391. package/dist/hooks/preemptive-compaction/constants.d.ts +48 -0
  392. package/dist/hooks/preemptive-compaction/constants.d.ts.map +1 -0
  393. package/dist/hooks/preemptive-compaction/constants.js +90 -0
  394. package/dist/hooks/preemptive-compaction/constants.js.map +1 -0
  395. package/dist/hooks/preemptive-compaction/index.d.ts +55 -0
  396. package/dist/hooks/preemptive-compaction/index.d.ts.map +1 -0
  397. package/dist/hooks/preemptive-compaction/index.js +227 -0
  398. package/dist/hooks/preemptive-compaction/index.js.map +1 -0
  399. package/dist/hooks/preemptive-compaction/types.d.ts +76 -0
  400. package/dist/hooks/preemptive-compaction/types.d.ts.map +1 -0
  401. package/dist/hooks/preemptive-compaction/types.js +9 -0
  402. package/dist/hooks/preemptive-compaction/types.js.map +1 -0
  403. package/dist/hooks/ralph-loop/index.d.ts +60 -0
  404. package/dist/hooks/ralph-loop/index.d.ts.map +1 -0
  405. package/dist/hooks/ralph-loop/index.js +155 -0
  406. package/dist/hooks/ralph-loop/index.js.map +1 -0
  407. package/dist/hooks/ralph-verifier/index.d.ts +72 -0
  408. package/dist/hooks/ralph-verifier/index.d.ts.map +1 -0
  409. package/dist/hooks/ralph-verifier/index.js +223 -0
  410. package/dist/hooks/ralph-verifier/index.js.map +1 -0
  411. package/dist/hooks/rules-injector/constants.d.ts +25 -0
  412. package/dist/hooks/rules-injector/constants.d.ts.map +1 -0
  413. package/dist/hooks/rules-injector/constants.js +40 -0
  414. package/dist/hooks/rules-injector/constants.js.map +1 -0
  415. package/dist/hooks/rules-injector/finder.d.ts +24 -0
  416. package/dist/hooks/rules-injector/finder.d.ts.map +1 -0
  417. package/dist/hooks/rules-injector/finder.js +215 -0
  418. package/dist/hooks/rules-injector/finder.js.map +1 -0
  419. package/dist/hooks/rules-injector/index.d.ts +45 -0
  420. package/dist/hooks/rules-injector/index.d.ts.map +1 -0
  421. package/dist/hooks/rules-injector/index.js +187 -0
  422. package/dist/hooks/rules-injector/index.js.map +1 -0
  423. package/dist/hooks/rules-injector/matcher.d.ts +25 -0
  424. package/dist/hooks/rules-injector/matcher.d.ts.map +1 -0
  425. package/dist/hooks/rules-injector/matcher.js +70 -0
  426. package/dist/hooks/rules-injector/matcher.js.map +1 -0
  427. package/dist/hooks/rules-injector/parser.d.ts +20 -0
  428. package/dist/hooks/rules-injector/parser.d.ts.map +1 -0
  429. package/dist/hooks/rules-injector/parser.js +179 -0
  430. package/dist/hooks/rules-injector/parser.js.map +1 -0
  431. package/dist/hooks/rules-injector/storage.d.ts +26 -0
  432. package/dist/hooks/rules-injector/storage.d.ts.map +1 -0
  433. package/dist/hooks/rules-injector/storage.js +61 -0
  434. package/dist/hooks/rules-injector/storage.js.map +1 -0
  435. package/dist/hooks/rules-injector/types.d.ts +101 -0
  436. package/dist/hooks/rules-injector/types.d.ts.map +1 -0
  437. package/dist/hooks/rules-injector/types.js +10 -0
  438. package/dist/hooks/rules-injector/types.js.map +1 -0
  439. package/dist/hooks/session-recovery/constants.d.ts +56 -0
  440. package/dist/hooks/session-recovery/constants.d.ts.map +1 -0
  441. package/dist/hooks/session-recovery/constants.js +78 -0
  442. package/dist/hooks/session-recovery/constants.js.map +1 -0
  443. package/dist/hooks/session-recovery/index.d.ts +53 -0
  444. package/dist/hooks/session-recovery/index.d.ts.map +1 -0
  445. package/dist/hooks/session-recovery/index.js +321 -0
  446. package/dist/hooks/session-recovery/index.js.map +1 -0
  447. package/dist/hooks/session-recovery/storage.d.ts +76 -0
  448. package/dist/hooks/session-recovery/storage.d.ts.map +1 -0
  449. package/dist/hooks/session-recovery/storage.js +383 -0
  450. package/dist/hooks/session-recovery/storage.js.map +1 -0
  451. package/dist/hooks/session-recovery/types.d.ts +145 -0
  452. package/dist/hooks/session-recovery/types.d.ts.map +1 -0
  453. package/dist/hooks/session-recovery/types.js +8 -0
  454. package/dist/hooks/session-recovery/types.js.map +1 -0
  455. package/dist/hooks/sisyphus-orchestrator/constants.d.ts +23 -0
  456. package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +1 -0
  457. package/dist/hooks/sisyphus-orchestrator/constants.js +142 -0
  458. package/dist/hooks/sisyphus-orchestrator/constants.js.map +1 -0
  459. package/dist/hooks/sisyphus-orchestrator/index.d.ts +113 -0
  460. package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -0
  461. package/dist/hooks/sisyphus-orchestrator/index.js +283 -0
  462. package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -0
  463. package/dist/hooks/the-ascent/index.d.ts +60 -0
  464. package/dist/hooks/the-ascent/index.d.ts.map +1 -0
  465. package/dist/hooks/the-ascent/index.js +155 -0
  466. package/dist/hooks/the-ascent/index.js.map +1 -0
  467. package/dist/hooks/think-mode/detector.d.ts +28 -0
  468. package/dist/hooks/think-mode/detector.d.ts.map +1 -0
  469. package/dist/hooks/think-mode/detector.js +105 -0
  470. package/dist/hooks/think-mode/detector.js.map +1 -0
  471. package/dist/hooks/think-mode/index.d.ts +70 -0
  472. package/dist/hooks/think-mode/index.d.ts.map +1 -0
  473. package/dist/hooks/think-mode/index.js +144 -0
  474. package/dist/hooks/think-mode/index.js.map +1 -0
  475. package/dist/hooks/think-mode/switcher.d.ts +39 -0
  476. package/dist/hooks/think-mode/switcher.d.ts.map +1 -0
  477. package/dist/hooks/think-mode/switcher.js +180 -0
  478. package/dist/hooks/think-mode/switcher.js.map +1 -0
  479. package/dist/hooks/think-mode/types.d.ts +60 -0
  480. package/dist/hooks/think-mode/types.d.ts.map +1 -0
  481. package/dist/hooks/think-mode/types.js +9 -0
  482. package/dist/hooks/think-mode/types.js.map +1 -0
  483. package/dist/hooks/thinking-block-validator/constants.d.ts +37 -0
  484. package/dist/hooks/thinking-block-validator/constants.d.ts.map +1 -0
  485. package/dist/hooks/thinking-block-validator/constants.js +50 -0
  486. package/dist/hooks/thinking-block-validator/constants.js.map +1 -0
  487. package/dist/hooks/thinking-block-validator/index.d.ts +35 -0
  488. package/dist/hooks/thinking-block-validator/index.d.ts.map +1 -0
  489. package/dist/hooks/thinking-block-validator/index.js +156 -0
  490. package/dist/hooks/thinking-block-validator/index.js.map +1 -0
  491. package/dist/hooks/thinking-block-validator/types.d.ts +67 -0
  492. package/dist/hooks/thinking-block-validator/types.d.ts.map +1 -0
  493. package/dist/hooks/thinking-block-validator/types.js +9 -0
  494. package/dist/hooks/thinking-block-validator/types.js.map +1 -0
  495. package/dist/hooks/todo-continuation/index.d.ts +39 -0
  496. package/dist/hooks/todo-continuation/index.d.ts.map +1 -0
  497. package/dist/hooks/todo-continuation/index.js +140 -0
  498. package/dist/hooks/todo-continuation/index.js.map +1 -0
  499. package/dist/hooks/ultrawork-state/index.d.ts +60 -0
  500. package/dist/hooks/ultrawork-state/index.d.ts.map +1 -0
  501. package/dist/hooks/ultrawork-state/index.js +207 -0
  502. package/dist/hooks/ultrawork-state/index.js.map +1 -0
  503. package/dist/index.d.ts +117 -0
  504. package/dist/index.d.ts.map +1 -0
  505. package/dist/index.js +175 -0
  506. package/dist/index.js.map +1 -0
  507. package/dist/installer/hooks.d.ts +196 -0
  508. package/dist/installer/hooks.d.ts.map +1 -0
  509. package/dist/installer/hooks.js +1385 -0
  510. package/dist/installer/hooks.js.map +1 -0
  511. package/dist/installer/index.d.ts +92 -0
  512. package/dist/installer/index.d.ts.map +1 -0
  513. package/dist/installer/index.js +2249 -0
  514. package/dist/installer/index.js.map +1 -0
  515. package/dist/mcp/index.d.ts +6 -0
  516. package/dist/mcp/index.d.ts.map +1 -0
  517. package/dist/mcp/index.js +5 -0
  518. package/dist/mcp/index.js.map +1 -0
  519. package/dist/mcp/servers.d.ts +77 -0
  520. package/dist/mcp/servers.d.ts.map +1 -0
  521. package/dist/mcp/servers.js +122 -0
  522. package/dist/mcp/servers.js.map +1 -0
  523. package/dist/shared/index.d.ts +5 -0
  524. package/dist/shared/index.d.ts.map +1 -0
  525. package/dist/shared/index.js +5 -0
  526. package/dist/shared/index.js.map +1 -0
  527. package/dist/shared/types.d.ts +159 -0
  528. package/dist/shared/types.d.ts.map +1 -0
  529. package/dist/shared/types.js +5 -0
  530. package/dist/shared/types.js.map +1 -0
  531. package/dist/tools/ast-tools.d.ts +63 -0
  532. package/dist/tools/ast-tools.d.ts.map +1 -0
  533. package/dist/tools/ast-tools.js +450 -0
  534. package/dist/tools/ast-tools.js.map +1 -0
  535. package/dist/tools/index.d.ts +52 -0
  536. package/dist/tools/index.d.ts.map +1 -0
  537. package/dist/tools/index.js +120 -0
  538. package/dist/tools/index.js.map +1 -0
  539. package/dist/tools/lsp/client.d.ts +201 -0
  540. package/dist/tools/lsp/client.d.ts.map +1 -0
  541. package/dist/tools/lsp/client.js +454 -0
  542. package/dist/tools/lsp/client.js.map +1 -0
  543. package/dist/tools/lsp/index.d.ts +9 -0
  544. package/dist/tools/lsp/index.d.ts.map +1 -0
  545. package/dist/tools/lsp/index.js +7 -0
  546. package/dist/tools/lsp/index.js.map +1 -0
  547. package/dist/tools/lsp/servers.d.ts +37 -0
  548. package/dist/tools/lsp/servers.d.ts.map +1 -0
  549. package/dist/tools/lsp/servers.js +149 -0
  550. package/dist/tools/lsp/servers.js.map +1 -0
  551. package/dist/tools/lsp/utils.d.ts +58 -0
  552. package/dist/tools/lsp/utils.d.ts.map +1 -0
  553. package/dist/tools/lsp/utils.js +236 -0
  554. package/dist/tools/lsp/utils.js.map +1 -0
  555. package/dist/tools/lsp-tools.d.ts +151 -0
  556. package/dist/tools/lsp-tools.d.ts.map +1 -0
  557. package/dist/tools/lsp-tools.js +358 -0
  558. package/dist/tools/lsp-tools.js.map +1 -0
  559. package/package.json +85 -0
  560. package/scripts/claude-sisyphus.sh +9 -0
  561. package/scripts/install.sh +1774 -0
  562. package/scripts/keyword-detector.mjs +209 -0
  563. package/scripts/keyword-detector.sh +71 -0
  564. package/scripts/persistent-mode.mjs +241 -0
  565. package/scripts/persistent-mode.sh +300 -0
  566. package/scripts/post-tool-verifier.mjs +217 -0
  567. package/scripts/post-tool-verifier.sh +196 -0
  568. package/scripts/pre-tool-enforcer.mjs +99 -0
  569. package/scripts/pre-tool-enforcer.sh +76 -0
  570. package/scripts/sisyphus-aliases.sh +18 -0
  571. package/scripts/stop-continuation.sh +31 -0
  572. package/scripts/test-pr25.sh +525 -0
  573. package/scripts/uninstall.sh +171 -0
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Popular Plugin Patterns
3
+ *
4
+ * Common hook patterns from the Claude Code community:
5
+ * - Auto-format on file save
6
+ * - Lint validation before commit
7
+ * - Commit message validation
8
+ * - Test runner before commit
9
+ * - Type checking enforcement
10
+ */
11
+ export interface FormatConfig {
12
+ /** File extensions to format */
13
+ extensions: string[];
14
+ /** Formatter command (e.g., 'prettier --write', 'black') */
15
+ command: string;
16
+ /** Whether to run on file save */
17
+ enabled: boolean;
18
+ }
19
+ /**
20
+ * Get formatter command for a file extension
21
+ */
22
+ export declare function getFormatter(ext: string): string | null;
23
+ /**
24
+ * Check if a formatter is available
25
+ */
26
+ export declare function isFormatterAvailable(command: string): boolean;
27
+ /**
28
+ * Format a file using the appropriate formatter
29
+ */
30
+ export declare function formatFile(filePath: string): {
31
+ success: boolean;
32
+ message: string;
33
+ };
34
+ export interface LintConfig {
35
+ /** Lint command to run */
36
+ command: string;
37
+ /** File patterns to lint */
38
+ patterns: string[];
39
+ /** Whether to block on lint errors */
40
+ blocking: boolean;
41
+ }
42
+ /**
43
+ * Get linter command for a file extension
44
+ */
45
+ export declare function getLinter(ext: string): string | null;
46
+ /**
47
+ * Run linter on a file
48
+ */
49
+ export declare function lintFile(filePath: string): {
50
+ success: boolean;
51
+ message: string;
52
+ };
53
+ export interface CommitConfig {
54
+ /** Conventional commit types allowed */
55
+ types: string[];
56
+ /** Maximum subject length */
57
+ maxSubjectLength: number;
58
+ /** Require scope */
59
+ requireScope: boolean;
60
+ /** Require body */
61
+ requireBody: boolean;
62
+ }
63
+ /**
64
+ * Validate a commit message against conventional commit format
65
+ */
66
+ export declare function validateCommitMessage(message: string, config?: Partial<CommitConfig>): {
67
+ valid: boolean;
68
+ errors: string[];
69
+ };
70
+ /**
71
+ * Run TypeScript type checking
72
+ */
73
+ export declare function runTypeCheck(directory: string): {
74
+ success: boolean;
75
+ message: string;
76
+ };
77
+ /**
78
+ * Detect and run tests for a project
79
+ */
80
+ export declare function runTests(directory: string): {
81
+ success: boolean;
82
+ message: string;
83
+ };
84
+ export interface PreCommitResult {
85
+ canCommit: boolean;
86
+ checks: Array<{
87
+ name: string;
88
+ passed: boolean;
89
+ message: string;
90
+ }>;
91
+ }
92
+ /**
93
+ * Run all pre-commit checks
94
+ */
95
+ export declare function runPreCommitChecks(directory: string, commitMessage?: string): PreCommitResult;
96
+ /**
97
+ * Generate pre-commit check reminder message
98
+ */
99
+ export declare function getPreCommitReminderMessage(result: PreCommitResult): string;
100
+ /**
101
+ * Generate auto-format reminder message
102
+ */
103
+ export declare function getAutoFormatMessage(filePath: string, result: {
104
+ success: boolean;
105
+ message: string;
106
+ }): string;
107
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/plugin-patterns/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB;AAgBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAS7D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,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CAAC;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACrB,eAAe,CAyBjB;AAMD;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAqB3E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAmB5G"}
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Popular Plugin Patterns
3
+ *
4
+ * Common hook patterns from the Claude Code community:
5
+ * - Auto-format on file save
6
+ * - Lint validation before commit
7
+ * - Commit message validation
8
+ * - Test runner before commit
9
+ * - Type checking enforcement
10
+ */
11
+ import { existsSync, readFileSync } from 'fs';
12
+ import { join, extname } from 'path';
13
+ import { execSync } from 'child_process';
14
+ const DEFAULT_FORMATTERS = {
15
+ '.ts': 'prettier --write',
16
+ '.tsx': 'prettier --write',
17
+ '.js': 'prettier --write',
18
+ '.jsx': 'prettier --write',
19
+ '.json': 'prettier --write',
20
+ '.css': 'prettier --write',
21
+ '.scss': 'prettier --write',
22
+ '.md': 'prettier --write',
23
+ '.py': 'black',
24
+ '.go': 'gofmt -w',
25
+ '.rs': 'rustfmt'
26
+ };
27
+ /**
28
+ * Get formatter command for a file extension
29
+ */
30
+ export function getFormatter(ext) {
31
+ return DEFAULT_FORMATTERS[ext] || null;
32
+ }
33
+ /**
34
+ * Check if a formatter is available
35
+ */
36
+ export function isFormatterAvailable(command) {
37
+ try {
38
+ const binary = command.split(' ')[0];
39
+ const checkCommand = process.platform === 'win32' ? 'where' : 'which';
40
+ execSync(`${checkCommand} ${binary}`, { encoding: 'utf-8', stdio: 'pipe' });
41
+ return true;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ /**
48
+ * Format a file using the appropriate formatter
49
+ */
50
+ export function formatFile(filePath) {
51
+ const ext = extname(filePath);
52
+ const formatter = getFormatter(ext);
53
+ if (!formatter) {
54
+ return { success: true, message: `No formatter configured for ${ext}` };
55
+ }
56
+ if (!isFormatterAvailable(formatter)) {
57
+ return { success: true, message: `Formatter ${formatter} not available` };
58
+ }
59
+ try {
60
+ execSync(`${formatter} "${filePath}"`, { encoding: 'utf-8', stdio: 'pipe' });
61
+ return { success: true, message: `Formatted ${filePath}` };
62
+ }
63
+ catch (_error) {
64
+ return { success: false, message: `Format failed: ${_error}` };
65
+ }
66
+ }
67
+ const DEFAULT_LINTERS = {
68
+ '.ts': 'eslint --fix',
69
+ '.tsx': 'eslint --fix',
70
+ '.js': 'eslint --fix',
71
+ '.jsx': 'eslint --fix',
72
+ '.py': 'ruff check --fix',
73
+ '.go': 'golangci-lint run',
74
+ '.rs': 'cargo clippy'
75
+ };
76
+ /**
77
+ * Get linter command for a file extension
78
+ */
79
+ export function getLinter(ext) {
80
+ return DEFAULT_LINTERS[ext] || null;
81
+ }
82
+ /**
83
+ * Run linter on a file
84
+ */
85
+ export function lintFile(filePath) {
86
+ const ext = extname(filePath);
87
+ const linter = getLinter(ext);
88
+ if (!linter) {
89
+ return { success: true, message: `No linter configured for ${ext}` };
90
+ }
91
+ try {
92
+ const binary = linter.split(' ')[0];
93
+ const checkCommand = process.platform === 'win32' ? 'where' : 'which';
94
+ execSync(`${checkCommand} ${binary}`, { encoding: 'utf-8', stdio: 'pipe' });
95
+ }
96
+ catch {
97
+ return { success: true, message: `Linter ${linter} not available` };
98
+ }
99
+ try {
100
+ execSync(`${linter} "${filePath}"`, { encoding: 'utf-8', stdio: 'pipe' });
101
+ return { success: true, message: `Lint passed for ${filePath}` };
102
+ }
103
+ catch (_error) {
104
+ return { success: false, message: `Lint errors in ${filePath}` };
105
+ }
106
+ }
107
+ const DEFAULT_COMMIT_TYPES = [
108
+ 'feat', // New feature
109
+ 'fix', // Bug fix
110
+ 'docs', // Documentation
111
+ 'style', // Formatting, no code change
112
+ 'refactor', // Refactoring
113
+ 'perf', // Performance improvement
114
+ 'test', // Adding tests
115
+ 'build', // Build system changes
116
+ 'ci', // CI configuration
117
+ 'chore', // Maintenance
118
+ 'revert' // Revert previous commit
119
+ ];
120
+ const CONVENTIONAL_COMMIT_REGEX = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-z0-9-]+\))?(!)?:\s.+$/;
121
+ /**
122
+ * Validate a commit message against conventional commit format
123
+ */
124
+ export function validateCommitMessage(message, config) {
125
+ const errors = [];
126
+ const lines = message.trim().split('\n');
127
+ const subject = lines[0];
128
+ // Check subject line
129
+ if (!subject) {
130
+ errors.push('Commit message cannot be empty');
131
+ return { valid: false, errors };
132
+ }
133
+ // Check conventional commit format
134
+ if (!CONVENTIONAL_COMMIT_REGEX.test(subject)) {
135
+ errors.push('Subject must follow conventional commit format: type(scope?): description');
136
+ errors.push(`Allowed types: ${DEFAULT_COMMIT_TYPES.join(', ')}`);
137
+ }
138
+ // Check subject length
139
+ const maxLength = config?.maxSubjectLength || 72;
140
+ if (subject.length > maxLength) {
141
+ errors.push(`Subject line exceeds ${maxLength} characters`);
142
+ }
143
+ // Check for scope if required
144
+ if (config?.requireScope) {
145
+ const hasScope = /\([a-z0-9-]+\)/.test(subject);
146
+ if (!hasScope) {
147
+ errors.push('Scope is required in commit message');
148
+ }
149
+ }
150
+ // Check for body if required
151
+ if (config?.requireBody) {
152
+ if (lines.length < 3 || !lines[2]) {
153
+ errors.push('Commit body is required');
154
+ }
155
+ }
156
+ return { valid: errors.length === 0, errors };
157
+ }
158
+ // =============================================================================
159
+ // TYPE CHECKING PATTERN
160
+ // =============================================================================
161
+ /**
162
+ * Run TypeScript type checking
163
+ */
164
+ export function runTypeCheck(directory) {
165
+ const tsconfigPath = join(directory, 'tsconfig.json');
166
+ if (!existsSync(tsconfigPath)) {
167
+ return { success: true, message: 'No tsconfig.json found' };
168
+ }
169
+ try {
170
+ const checkCommand = process.platform === 'win32' ? 'where' : 'which';
171
+ execSync(`${checkCommand} tsc`, { encoding: 'utf-8', stdio: 'pipe' });
172
+ }
173
+ catch {
174
+ return { success: true, message: 'TypeScript not installed' };
175
+ }
176
+ try {
177
+ execSync('tsc --noEmit', { cwd: directory, encoding: 'utf-8', stdio: 'pipe' });
178
+ return { success: true, message: 'Type check passed' };
179
+ }
180
+ catch (_error) {
181
+ return { success: false, message: 'Type errors found' };
182
+ }
183
+ }
184
+ // =============================================================================
185
+ // TEST RUNNER PATTERN
186
+ // =============================================================================
187
+ /**
188
+ * Detect and run tests for a project
189
+ */
190
+ export function runTests(directory) {
191
+ const packageJsonPath = join(directory, 'package.json');
192
+ if (existsSync(packageJsonPath)) {
193
+ try {
194
+ const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
195
+ if (pkg.scripts?.test) {
196
+ execSync('npm test', { cwd: directory, encoding: 'utf-8', stdio: 'pipe' });
197
+ return { success: true, message: 'Tests passed' };
198
+ }
199
+ }
200
+ catch (_error) {
201
+ return { success: false, message: 'Tests failed' };
202
+ }
203
+ }
204
+ // Check for pytest
205
+ if (existsSync(join(directory, 'pytest.ini')) || existsSync(join(directory, 'pyproject.toml'))) {
206
+ try {
207
+ execSync('pytest', { cwd: directory, encoding: 'utf-8', stdio: 'pipe' });
208
+ return { success: true, message: 'Tests passed' };
209
+ }
210
+ catch (_error) {
211
+ return { success: false, message: 'Tests failed' };
212
+ }
213
+ }
214
+ return { success: true, message: 'No test runner found' };
215
+ }
216
+ /**
217
+ * Run all pre-commit checks
218
+ */
219
+ export function runPreCommitChecks(directory, commitMessage) {
220
+ const checks = [];
221
+ // Type checking
222
+ const typeCheck = runTypeCheck(directory);
223
+ checks.push({
224
+ name: 'Type Check',
225
+ passed: typeCheck.success,
226
+ message: typeCheck.message
227
+ });
228
+ // Commit message validation
229
+ if (commitMessage) {
230
+ const commitCheck = validateCommitMessage(commitMessage);
231
+ checks.push({
232
+ name: 'Commit Message',
233
+ passed: commitCheck.valid,
234
+ message: commitCheck.valid ? 'Valid format' : commitCheck.errors.join('; ')
235
+ });
236
+ }
237
+ // All checks must pass
238
+ const canCommit = checks.every(c => c.passed);
239
+ return { canCommit, checks };
240
+ }
241
+ // =============================================================================
242
+ // HOOK MESSAGE GENERATORS
243
+ // =============================================================================
244
+ /**
245
+ * Generate pre-commit check reminder message
246
+ */
247
+ export function getPreCommitReminderMessage(result) {
248
+ if (result.canCommit) {
249
+ return '';
250
+ }
251
+ const failedChecks = result.checks.filter(c => !c.passed);
252
+ return `<pre-commit-validation>
253
+
254
+ [PRE-COMMIT CHECKS FAILED]
255
+
256
+ The following checks did not pass:
257
+ ${failedChecks.map(c => `- ${c.name}: ${c.message}`).join('\n')}
258
+
259
+ Please fix these issues before committing.
260
+
261
+ </pre-commit-validation>
262
+
263
+ ---
264
+
265
+ `;
266
+ }
267
+ /**
268
+ * Generate auto-format reminder message
269
+ */
270
+ export function getAutoFormatMessage(filePath, result) {
271
+ if (result.success) {
272
+ return '';
273
+ }
274
+ return `<auto-format>
275
+
276
+ [FORMAT WARNING]
277
+
278
+ File ${filePath} could not be auto-formatted:
279
+ ${result.message}
280
+
281
+ Please check the file manually.
282
+
283
+ </auto-format>
284
+
285
+ ---
286
+
287
+ `;
288
+ }
289
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/plugin-patterns/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAezC,MAAM,kBAAkB,GAA2B;IACjD,KAAK,EAAE,kBAAkB;IAC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H,MAAM,UAAU,oBAAoB,CAAC,QAAgB,EAAE,MAA6C;IAClG,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;;;;OAIF,QAAQ;EACb,MAAM,CAAC,OAAO;;;;;;;;CAQf,CAAC;AACF,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Preemptive Compaction Constants
3
+ *
4
+ * Thresholds and messages for context usage monitoring.
5
+ *
6
+ * Adapted from oh-my-opencode's preemptive-compaction hook.
7
+ */
8
+ /**
9
+ * Default threshold ratio to trigger warning (85%)
10
+ */
11
+ export declare const DEFAULT_THRESHOLD = 0.85;
12
+ /**
13
+ * Critical threshold ratio (95%)
14
+ */
15
+ export declare const CRITICAL_THRESHOLD = 0.95;
16
+ /**
17
+ * Minimum tokens before considering compaction
18
+ */
19
+ export declare const MIN_TOKENS_FOR_COMPACTION = 50000;
20
+ /**
21
+ * Cooldown period between compaction warnings (1 minute)
22
+ */
23
+ export declare const COMPACTION_COOLDOWN_MS = 60000;
24
+ /**
25
+ * Maximum warnings per session before stopping
26
+ */
27
+ export declare const MAX_WARNINGS = 3;
28
+ /**
29
+ * Default context limits for Claude models
30
+ */
31
+ export declare const CLAUDE_DEFAULT_CONTEXT_LIMIT: number;
32
+ /**
33
+ * Average characters per token estimate
34
+ */
35
+ export declare const CHARS_PER_TOKEN = 4;
36
+ /**
37
+ * Warning message when context usage is high
38
+ */
39
+ export declare const CONTEXT_WARNING_MESSAGE = "CONTEXT WINDOW WARNING - APPROACHING LIMIT\n\nYour context usage is getting high. Consider these actions to prevent hitting the limit:\n\n1. USE COMPACT COMMAND\n - Run /compact to summarize the conversation\n - This frees up context space while preserving important information\n\n2. BE MORE CONCISE\n - Show only relevant code portions\n - Use file paths instead of full code blocks\n - Summarize instead of repeating information\n\n3. FOCUS YOUR REQUESTS\n - Work on one task at a time\n - Complete current tasks before starting new ones\n - Avoid unnecessary back-and-forth\n\nCurrent Status: Context usage is high but recoverable.\nAction recommended: Use /compact when convenient.\n";
40
+ /**
41
+ * Critical warning message when context is almost full
42
+ */
43
+ export declare const CONTEXT_CRITICAL_MESSAGE = "CRITICAL: CONTEXT WINDOW ALMOST FULL\n\nYour context usage is critically high. Immediate action required:\n\n1. COMPACT NOW\n - Run /compact immediately to summarize the conversation\n - Without compaction, the next few messages may fail\n\n2. AVOID LARGE OUTPUTS\n - Do not show full files\n - Use summaries instead of detailed outputs\n - Be as concise as possible\n\n3. PREPARE FOR SESSION HANDOFF\n - If compaction doesn't help enough, prepare to continue in a new session\n - Note your current progress and next steps\n\nWARNING: Further messages may fail if context is not reduced.\nAction required: Run /compact now.\n";
44
+ /**
45
+ * Message when compaction was successful
46
+ */
47
+ export declare const COMPACTION_SUCCESS_MESSAGE = "Context compacted successfully. Session can continue normally.";
48
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/preemptive-compaction/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,4BAA4B,QAI5B,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,uBAAuB,qsBAoBnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,ooBAmBpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,mEAAmE,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Preemptive Compaction Constants
3
+ *
4
+ * Thresholds and messages for context usage monitoring.
5
+ *
6
+ * Adapted from oh-my-opencode's preemptive-compaction hook.
7
+ */
8
+ /**
9
+ * Default threshold ratio to trigger warning (85%)
10
+ */
11
+ export const DEFAULT_THRESHOLD = 0.85;
12
+ /**
13
+ * Critical threshold ratio (95%)
14
+ */
15
+ export const CRITICAL_THRESHOLD = 0.95;
16
+ /**
17
+ * Minimum tokens before considering compaction
18
+ */
19
+ export const MIN_TOKENS_FOR_COMPACTION = 50_000;
20
+ /**
21
+ * Cooldown period between compaction warnings (1 minute)
22
+ */
23
+ export const COMPACTION_COOLDOWN_MS = 60_000;
24
+ /**
25
+ * Maximum warnings per session before stopping
26
+ */
27
+ export const MAX_WARNINGS = 3;
28
+ /**
29
+ * Default context limits for Claude models
30
+ */
31
+ export const CLAUDE_DEFAULT_CONTEXT_LIMIT = process.env.ANTHROPIC_1M_CONTEXT === 'true' ||
32
+ process.env.VERTEX_ANTHROPIC_1M_CONTEXT === 'true'
33
+ ? 1_000_000
34
+ : 200_000;
35
+ /**
36
+ * Average characters per token estimate
37
+ */
38
+ export const CHARS_PER_TOKEN = 4;
39
+ /**
40
+ * Warning message when context usage is high
41
+ */
42
+ export const CONTEXT_WARNING_MESSAGE = `CONTEXT WINDOW WARNING - APPROACHING LIMIT
43
+
44
+ Your context usage is getting high. Consider these actions to prevent hitting the limit:
45
+
46
+ 1. USE COMPACT COMMAND
47
+ - Run /compact to summarize the conversation
48
+ - This frees up context space while preserving important information
49
+
50
+ 2. BE MORE CONCISE
51
+ - Show only relevant code portions
52
+ - Use file paths instead of full code blocks
53
+ - Summarize instead of repeating information
54
+
55
+ 3. FOCUS YOUR REQUESTS
56
+ - Work on one task at a time
57
+ - Complete current tasks before starting new ones
58
+ - Avoid unnecessary back-and-forth
59
+
60
+ Current Status: Context usage is high but recoverable.
61
+ Action recommended: Use /compact when convenient.
62
+ `;
63
+ /**
64
+ * Critical warning message when context is almost full
65
+ */
66
+ export const CONTEXT_CRITICAL_MESSAGE = `CRITICAL: CONTEXT WINDOW ALMOST FULL
67
+
68
+ Your context usage is critically high. Immediate action required:
69
+
70
+ 1. COMPACT NOW
71
+ - Run /compact immediately to summarize the conversation
72
+ - Without compaction, the next few messages may fail
73
+
74
+ 2. AVOID LARGE OUTPUTS
75
+ - Do not show full files
76
+ - Use summaries instead of detailed outputs
77
+ - Be as concise as possible
78
+
79
+ 3. PREPARE FOR SESSION HANDOFF
80
+ - If compaction doesn't help enough, prepare to continue in a new session
81
+ - Note your current progress and next steps
82
+
83
+ WARNING: Further messages may fail if context is not reduced.
84
+ Action required: Run /compact now.
85
+ `;
86
+ /**
87
+ * Message when compaction was successful
88
+ */
89
+ export const COMPACTION_SUCCESS_MESSAGE = `Context compacted successfully. Session can continue normally.`;
90
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/preemptive-compaction/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GACvC,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM;IAC3C,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM;IAChD,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,OAAO,CAAC;AAEd;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBtC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gEAAgE,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Preemptive Compaction Hook
3
+ *
4
+ * Monitors context usage and warns before hitting the context limit.
5
+ * Encourages proactive compaction to prevent context overflow.
6
+ *
7
+ * Adapted from oh-my-opencode's preemptive-compaction hook.
8
+ *
9
+ * Note: This is a simplified version for Claude Code's shell hook system.
10
+ * The original uses OpenCode's plugin event system for automatic summarization.
11
+ * This version injects warning messages to prompt manual compaction.
12
+ */
13
+ import type { ContextUsageResult, PreemptiveCompactionConfig } from './types.js';
14
+ /**
15
+ * Estimate tokens from text content
16
+ */
17
+ export declare function estimateTokens(text: string): number;
18
+ /**
19
+ * Analyze context usage based on conversation content
20
+ */
21
+ export declare function analyzeContextUsage(content: string, config?: PreemptiveCompactionConfig): ContextUsageResult;
22
+ /**
23
+ * Create preemptive compaction hook
24
+ *
25
+ * This hook monitors context usage and injects warning messages
26
+ * when approaching the context limit.
27
+ */
28
+ export declare function createPreemptiveCompactionHook(config?: PreemptiveCompactionConfig): {
29
+ /**
30
+ * PostToolUse - Check context usage after large tool outputs
31
+ */
32
+ postToolUse: (input: {
33
+ tool_name: string;
34
+ session_id: string;
35
+ tool_input: Record<string, unknown>;
36
+ tool_response?: string;
37
+ }) => string | null;
38
+ /**
39
+ * Stop event - Check context before stopping
40
+ */
41
+ stop: (input: {
42
+ session_id: string;
43
+ }) => string | null;
44
+ };
45
+ /**
46
+ * Get estimated token usage for a session
47
+ */
48
+ export declare function getSessionTokenEstimate(sessionId: string): number;
49
+ /**
50
+ * Reset token estimate for a session (e.g., after compaction)
51
+ */
52
+ export declare function resetSessionTokenEstimate(sessionId: string): void;
53
+ export type { ContextUsageResult, PreemptiveCompactionConfig, } from './types.js';
54
+ export { DEFAULT_THRESHOLD, CRITICAL_THRESHOLD, COMPACTION_COOLDOWN_MS, MAX_WARNINGS, CLAUDE_DEFAULT_CONTEXT_LIMIT, CHARS_PER_TOKEN, CONTEXT_WARNING_MESSAGE, CONTEXT_CRITICAL_MESSAGE, } from './constants.js';
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/preemptive-compaction/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH,OAAO,KAAK,EACV,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AA6CpB;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,0BAA0B,GAClC,kBAAkB,CAyBpB;AA+DD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,CAAC,EAAE,0BAA0B;IAiBjC;;OAEG;yBACkB;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,KAAG,MAAM,GAAG,IAAI;IAwDjB;;OAEG;kBACW;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,KAAG,MAAM,GAAG,IAAI;EAevD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAOjE;AAGD,YAAY,EACV,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,4BAA4B,EAC5B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC"}