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,450 @@
1
+ /**
2
+ * AST Tools using ast-grep
3
+ *
4
+ * Provides AST-aware code search and transformation:
5
+ * - Pattern matching with meta-variables ($VAR, $$$)
6
+ * - Code replacement while preserving structure
7
+ * - Support for 25+ programming languages
8
+ */
9
+ import { z } from "zod";
10
+ import { readFileSync, readdirSync, statSync, writeFileSync } from "fs";
11
+ import { join, extname, resolve } from "path";
12
+ // Dynamic import for @ast-grep/napi (ESM module)
13
+ let sgModule = null;
14
+ async function getSgModule() {
15
+ if (!sgModule) {
16
+ sgModule = await import("@ast-grep/napi");
17
+ }
18
+ return sgModule;
19
+ }
20
+ /**
21
+ * Convert lowercase language string to ast-grep Lang enum value
22
+ * This provides type-safe language conversion without using 'as any'
23
+ */
24
+ function toLangEnum(sg, language) {
25
+ const langMap = {
26
+ javascript: sg.Lang.JavaScript,
27
+ typescript: sg.Lang.TypeScript,
28
+ tsx: sg.Lang.Tsx,
29
+ python: sg.Lang.Python,
30
+ ruby: sg.Lang.Ruby,
31
+ go: sg.Lang.Go,
32
+ rust: sg.Lang.Rust,
33
+ java: sg.Lang.Java,
34
+ kotlin: sg.Lang.Kotlin,
35
+ swift: sg.Lang.Swift,
36
+ c: sg.Lang.C,
37
+ cpp: sg.Lang.Cpp,
38
+ csharp: sg.Lang.CSharp,
39
+ html: sg.Lang.Html,
40
+ css: sg.Lang.Css,
41
+ json: sg.Lang.Json,
42
+ yaml: sg.Lang.Yaml,
43
+ };
44
+ const lang = langMap[language];
45
+ if (!lang) {
46
+ throw new Error(`Unsupported language: ${language}`);
47
+ }
48
+ return lang;
49
+ }
50
+ /**
51
+ * Supported languages for AST analysis
52
+ * Maps to ast-grep language identifiers
53
+ */
54
+ export const SUPPORTED_LANGUAGES = [
55
+ "javascript",
56
+ "typescript",
57
+ "tsx",
58
+ "python",
59
+ "ruby",
60
+ "go",
61
+ "rust",
62
+ "java",
63
+ "kotlin",
64
+ "swift",
65
+ "c",
66
+ "cpp",
67
+ "csharp",
68
+ "html",
69
+ "css",
70
+ "json",
71
+ "yaml",
72
+ ];
73
+ /**
74
+ * Map file extensions to ast-grep language identifiers
75
+ */
76
+ const EXT_TO_LANG = {
77
+ ".js": "javascript",
78
+ ".mjs": "javascript",
79
+ ".cjs": "javascript",
80
+ ".jsx": "javascript",
81
+ ".ts": "typescript",
82
+ ".mts": "typescript",
83
+ ".cts": "typescript",
84
+ ".tsx": "tsx",
85
+ ".py": "python",
86
+ ".rb": "ruby",
87
+ ".go": "go",
88
+ ".rs": "rust",
89
+ ".java": "java",
90
+ ".kt": "kotlin",
91
+ ".kts": "kotlin",
92
+ ".swift": "swift",
93
+ ".c": "c",
94
+ ".h": "c",
95
+ ".cpp": "cpp",
96
+ ".cc": "cpp",
97
+ ".cxx": "cpp",
98
+ ".hpp": "cpp",
99
+ ".cs": "csharp",
100
+ ".html": "html",
101
+ ".htm": "html",
102
+ ".css": "css",
103
+ ".json": "json",
104
+ ".yaml": "yaml",
105
+ ".yml": "yaml",
106
+ };
107
+ /**
108
+ * Get files matching the language in a directory
109
+ */
110
+ function getFilesForLanguage(dirPath, language, maxFiles = 1000) {
111
+ const files = [];
112
+ const extensions = Object.entries(EXT_TO_LANG)
113
+ .filter(([_, lang]) => lang === language)
114
+ .map(([ext]) => ext);
115
+ function walk(dir) {
116
+ if (files.length >= maxFiles)
117
+ return;
118
+ try {
119
+ const entries = readdirSync(dir, { withFileTypes: true });
120
+ for (const entry of entries) {
121
+ if (files.length >= maxFiles)
122
+ return;
123
+ const fullPath = join(dir, entry.name);
124
+ // Skip common non-source directories
125
+ if (entry.isDirectory()) {
126
+ if (![
127
+ "node_modules",
128
+ ".git",
129
+ "dist",
130
+ "build",
131
+ "__pycache__",
132
+ ".venv",
133
+ "venv",
134
+ ].includes(entry.name)) {
135
+ walk(fullPath);
136
+ }
137
+ }
138
+ else if (entry.isFile()) {
139
+ const ext = extname(entry.name).toLowerCase();
140
+ if (extensions.includes(ext)) {
141
+ files.push(fullPath);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ catch {
147
+ // Ignore permission errors
148
+ }
149
+ }
150
+ const resolvedPath = resolve(dirPath);
151
+ const stat = statSync(resolvedPath);
152
+ if (stat.isFile()) {
153
+ return [resolvedPath];
154
+ }
155
+ walk(resolvedPath);
156
+ return files;
157
+ }
158
+ /**
159
+ * Format a match result for display
160
+ */
161
+ function formatMatch(filePath, matchText, startLine, endLine, context, fileContent) {
162
+ const lines = fileContent.split("\n");
163
+ const contextStart = Math.max(0, startLine - context - 1);
164
+ const contextEnd = Math.min(lines.length, endLine + context);
165
+ const contextLines = lines.slice(contextStart, contextEnd);
166
+ const numberedLines = contextLines.map((line, i) => {
167
+ const lineNum = contextStart + i + 1;
168
+ const isMatch = lineNum >= startLine && lineNum <= endLine;
169
+ const prefix = isMatch ? ">" : " ";
170
+ return `${prefix} ${lineNum.toString().padStart(4)}: ${line}`;
171
+ });
172
+ return `${filePath}:${startLine}\n${numberedLines.join("\n")}`;
173
+ }
174
+ /**
175
+ * AST Grep Search Tool - Find code patterns using AST matching
176
+ */
177
+ export const astGrepSearchTool = {
178
+ name: "ast_grep_search",
179
+ description: `Search for code patterns using AST matching. More precise than text search.
180
+
181
+ Use meta-variables in patterns:
182
+ - $NAME - matches any single AST node (identifier, expression, etc.)
183
+ - $$$ARGS - matches multiple nodes (for function arguments, list items, etc.)
184
+
185
+ Examples:
186
+ - "function $NAME($$$ARGS)" - find all function declarations
187
+ - "console.log($MSG)" - find all console.log calls
188
+ - "if ($COND) { $$$BODY }" - find all if statements
189
+ - "$X === null" - find null equality checks
190
+ - "import $$$IMPORTS from '$MODULE'" - find imports
191
+
192
+ Note: Patterns must be valid AST nodes for the language.`,
193
+ schema: {
194
+ pattern: z
195
+ .string()
196
+ .describe("AST pattern with meta-variables ($VAR, $$$VARS)"),
197
+ language: z.enum(SUPPORTED_LANGUAGES).describe("Programming language"),
198
+ path: z
199
+ .string()
200
+ .optional()
201
+ .describe("Directory or file to search (default: current directory)"),
202
+ context: z
203
+ .number()
204
+ .int()
205
+ .min(0)
206
+ .max(10)
207
+ .optional()
208
+ .describe("Lines of context around matches (default: 2)"),
209
+ maxResults: z
210
+ .number()
211
+ .int()
212
+ .min(1)
213
+ .max(100)
214
+ .optional()
215
+ .describe("Maximum results to return (default: 20)"),
216
+ },
217
+ handler: async (args) => {
218
+ const { pattern, language, path = ".", context = 2, maxResults = 20, } = args;
219
+ try {
220
+ const sg = await getSgModule();
221
+ const files = getFilesForLanguage(path, language);
222
+ if (files.length === 0) {
223
+ return {
224
+ content: [
225
+ {
226
+ type: "text",
227
+ text: `No ${language} files found in ${path}`,
228
+ },
229
+ ],
230
+ };
231
+ }
232
+ const results = [];
233
+ let totalMatches = 0;
234
+ for (const filePath of files) {
235
+ if (totalMatches >= maxResults)
236
+ break;
237
+ try {
238
+ const content = readFileSync(filePath, "utf-8");
239
+ const root = sg.parse(toLangEnum(sg, language), content).root();
240
+ const matches = root.findAll(pattern);
241
+ for (const match of matches) {
242
+ if (totalMatches >= maxResults)
243
+ break;
244
+ const range = match.range();
245
+ const startLine = range.start.line + 1;
246
+ const endLine = range.end.line + 1;
247
+ results.push(formatMatch(filePath, match.text(), startLine, endLine, context, content));
248
+ totalMatches++;
249
+ }
250
+ }
251
+ catch {
252
+ // Skip files that fail to parse
253
+ }
254
+ }
255
+ if (results.length === 0) {
256
+ return {
257
+ content: [
258
+ {
259
+ type: "text",
260
+ text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}\n\nTip: Ensure the pattern is a valid AST node. For example:\n- Use "function $NAME" not just "$NAME"\n- Use "console.log($X)" not "console.log"`,
261
+ },
262
+ ],
263
+ };
264
+ }
265
+ const header = `Found ${totalMatches} match(es) in ${files.length} file(s)\nPattern: ${pattern}\n\n`;
266
+ return {
267
+ content: [
268
+ {
269
+ type: "text",
270
+ text: header + results.join("\n\n---\n\n"),
271
+ },
272
+ ],
273
+ };
274
+ }
275
+ catch (error) {
276
+ return {
277
+ content: [
278
+ {
279
+ type: "text",
280
+ text: `Error in AST search: ${error instanceof Error ? error.message : String(error)}\n\nCommon issues:\n- Pattern must be a complete AST node\n- Language must match file type\n- Check that @ast-grep/napi is installed`,
281
+ },
282
+ ],
283
+ };
284
+ }
285
+ },
286
+ };
287
+ /**
288
+ * AST Grep Replace Tool - Replace code patterns using AST matching
289
+ */
290
+ export const astGrepReplaceTool = {
291
+ name: "ast_grep_replace",
292
+ description: `Replace code patterns using AST matching. Preserves matched content via meta-variables.
293
+
294
+ Use meta-variables in both pattern and replacement:
295
+ - $NAME in pattern captures a node, use $NAME in replacement to insert it
296
+ - $$$ARGS captures multiple nodes
297
+
298
+ Examples:
299
+ - Pattern: "console.log($MSG)" → Replacement: "logger.info($MSG)"
300
+ - Pattern: "var $NAME = $VALUE" → Replacement: "const $NAME = $VALUE"
301
+ - Pattern: "$OBJ.forEach(($ITEM) => { $$$BODY })" → Replacement: "for (const $ITEM of $OBJ) { $$$BODY }"
302
+
303
+ IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to apply.`,
304
+ schema: {
305
+ pattern: z.string().describe("Pattern to match"),
306
+ replacement: z
307
+ .string()
308
+ .describe("Replacement pattern (use same meta-variables)"),
309
+ language: z.enum(SUPPORTED_LANGUAGES).describe("Programming language"),
310
+ path: z
311
+ .string()
312
+ .optional()
313
+ .describe("Directory or file to search (default: current directory)"),
314
+ dryRun: z
315
+ .boolean()
316
+ .optional()
317
+ .describe("Preview only, don't apply changes (default: true)"),
318
+ },
319
+ handler: async (args) => {
320
+ const { pattern, replacement, language, path = ".", dryRun = true } = args;
321
+ try {
322
+ const sg = await getSgModule();
323
+ const files = getFilesForLanguage(path, language);
324
+ if (files.length === 0) {
325
+ return {
326
+ content: [
327
+ {
328
+ type: "text",
329
+ text: `No ${language} files found in ${path}`,
330
+ },
331
+ ],
332
+ };
333
+ }
334
+ const changes = [];
335
+ let totalReplacements = 0;
336
+ for (const filePath of files) {
337
+ try {
338
+ const content = readFileSync(filePath, "utf-8");
339
+ const root = sg.parse(toLangEnum(sg, language), content).root();
340
+ const matches = root.findAll(pattern);
341
+ if (matches.length === 0)
342
+ continue;
343
+ // Collect all edits for this file
344
+ const edits = [];
345
+ for (const match of matches) {
346
+ const range = match.range();
347
+ const startOffset = range.start.index;
348
+ const endOffset = range.end.index;
349
+ // Build replacement by substituting meta-variables
350
+ let finalReplacement = replacement;
351
+ // Get all captured meta-variables
352
+ // ast-grep captures are accessed via match.getMatch() or by variable name
353
+ // For simplicity, we'll use a basic approach here
354
+ const matchedText = match.text();
355
+ // Try to get named captures
356
+ try {
357
+ // Replace meta-variables in the replacement string
358
+ const metaVars = replacement.match(/\$\$?\$?[A-Z_][A-Z0-9_]*/g) || [];
359
+ for (const metaVar of metaVars) {
360
+ const varName = metaVar.replace(/^\$+/, "");
361
+ const captured = match.getMatch(varName);
362
+ if (captured) {
363
+ finalReplacement = finalReplacement.replace(metaVar, captured.text());
364
+ }
365
+ }
366
+ }
367
+ catch {
368
+ // If meta-variable extraction fails, use pattern as-is
369
+ }
370
+ edits.push({
371
+ start: startOffset,
372
+ end: endOffset,
373
+ replacement: finalReplacement,
374
+ line: range.start.line + 1,
375
+ before: matchedText,
376
+ });
377
+ }
378
+ // Sort edits in reverse order to apply from end to start
379
+ edits.sort((a, b) => b.start - a.start);
380
+ let newContent = content;
381
+ for (const edit of edits) {
382
+ const before = newContent.slice(edit.start, edit.end);
383
+ newContent =
384
+ newContent.slice(0, edit.start) +
385
+ edit.replacement +
386
+ newContent.slice(edit.end);
387
+ changes.push({
388
+ file: filePath,
389
+ before,
390
+ after: edit.replacement,
391
+ line: edit.line,
392
+ });
393
+ totalReplacements++;
394
+ }
395
+ if (!dryRun && edits.length > 0) {
396
+ writeFileSync(filePath, newContent, "utf-8");
397
+ }
398
+ }
399
+ catch {
400
+ // Skip files that fail to parse
401
+ }
402
+ }
403
+ if (changes.length === 0) {
404
+ return {
405
+ content: [
406
+ {
407
+ type: "text",
408
+ text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}`,
409
+ },
410
+ ],
411
+ };
412
+ }
413
+ const mode = dryRun ? "DRY RUN (no changes applied)" : "CHANGES APPLIED";
414
+ const header = `${mode}\n\nFound ${totalReplacements} replacement(s) in ${files.length} file(s)\nPattern: ${pattern}\nReplacement: ${replacement}\n\n`;
415
+ const changeList = changes
416
+ .slice(0, 50)
417
+ .map((c) => `${c.file}:${c.line}\n - ${c.before}\n + ${c.after}`)
418
+ .join("\n\n");
419
+ const footer = changes.length > 50
420
+ ? `\n\n... and ${changes.length - 50} more changes`
421
+ : "";
422
+ return {
423
+ content: [
424
+ {
425
+ type: "text",
426
+ text: header +
427
+ changeList +
428
+ footer +
429
+ (dryRun ? "\n\nTo apply changes, run with dryRun: false" : ""),
430
+ },
431
+ ],
432
+ };
433
+ }
434
+ catch (error) {
435
+ return {
436
+ content: [
437
+ {
438
+ type: "text",
439
+ text: `Error in AST replace: ${error instanceof Error ? error.message : String(error)}`,
440
+ },
441
+ ],
442
+ };
443
+ }
444
+ },
445
+ };
446
+ /**
447
+ * Get all AST tool definitions
448
+ */
449
+ export const astTools = [astGrepSearchTool, astGrepReplaceTool];
450
+ //# sourceMappingURL=ast-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-tools.js","sourceRoot":"","sources":["../../src/tools/ast-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAA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E,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,KAAK,EAAE,CAAC;iBAClE,IAAI,CAAC,MAAM,CAAC,CAAC;YAEhB,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,GAAG,EAAE;gBACjB,CAAC,CAAC,eAAe,OAAO,CAAC,MAAM,GAAG,EAAE,eAAe;gBACnD,CAAC,CAAC,EAAE,CAAC;YAET,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EACF,MAAM;4BACN,UAAU;4BACV,MAAM;4BACN,CAAC,MAAM,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,EAAE,CAAC;qBACjE;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACxF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Tool Registry and MCP Server Creation
3
+ *
4
+ * This module exports all custom tools and provides helpers
5
+ * for creating MCP servers with the Claude Agent SDK.
6
+ */
7
+ import { z } from 'zod';
8
+ export { lspTools } from './lsp-tools.js';
9
+ export { astTools } from './ast-tools.js';
10
+ /**
11
+ * Generic tool definition type
12
+ */
13
+ export interface GenericToolDefinition {
14
+ name: string;
15
+ description: string;
16
+ schema: z.ZodRawShape;
17
+ handler: (args: unknown) => Promise<{
18
+ content: Array<{
19
+ type: 'text';
20
+ text: string;
21
+ }>;
22
+ }>;
23
+ }
24
+ /**
25
+ * All custom tools available in the system
26
+ */
27
+ export declare const allCustomTools: GenericToolDefinition[];
28
+ /**
29
+ * Get tools by category
30
+ */
31
+ export declare function getToolsByCategory(category: 'lsp' | 'ast' | 'all'): GenericToolDefinition[];
32
+ /**
33
+ * Create a Zod schema object from a tool's schema definition
34
+ */
35
+ export declare function createZodSchema<T extends z.ZodRawShape>(schema: T): z.ZodObject<T>;
36
+ /**
37
+ * Format for creating tools compatible with Claude Agent SDK
38
+ */
39
+ export interface SdkToolFormat {
40
+ name: string;
41
+ description: string;
42
+ inputSchema: {
43
+ type: 'object';
44
+ properties: Record<string, unknown>;
45
+ required: string[];
46
+ };
47
+ }
48
+ /**
49
+ * Convert our tool definitions to SDK format
50
+ */
51
+ export declare function toSdkToolFormat(tool: GenericToolDefinition): SdkToolFormat;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CACzF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,qBAAqB,EAGjD,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,qBAAqB,EAAE,CAS3F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAElF;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,qBAAqB,GAAG,aAAa,CAS1E"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Tool Registry and MCP Server Creation
3
+ *
4
+ * This module exports all custom tools and provides helpers
5
+ * for creating MCP servers with the Claude Agent SDK.
6
+ */
7
+ import { z } from 'zod';
8
+ import { lspTools } from './lsp-tools.js';
9
+ import { astTools } from './ast-tools.js';
10
+ export { lspTools } from './lsp-tools.js';
11
+ export { astTools } from './ast-tools.js';
12
+ /**
13
+ * All custom tools available in the system
14
+ */
15
+ export const allCustomTools = [
16
+ ...lspTools,
17
+ ...astTools
18
+ ];
19
+ /**
20
+ * Get tools by category
21
+ */
22
+ export function getToolsByCategory(category) {
23
+ switch (category) {
24
+ case 'lsp':
25
+ return lspTools;
26
+ case 'ast':
27
+ return astTools;
28
+ case 'all':
29
+ return allCustomTools;
30
+ }
31
+ }
32
+ /**
33
+ * Create a Zod schema object from a tool's schema definition
34
+ */
35
+ export function createZodSchema(schema) {
36
+ return z.object(schema);
37
+ }
38
+ /**
39
+ * Convert our tool definitions to SDK format
40
+ */
41
+ export function toSdkToolFormat(tool) {
42
+ const zodSchema = z.object(tool.schema);
43
+ const jsonSchema = zodToJsonSchema(zodSchema);
44
+ return {
45
+ name: tool.name,
46
+ description: tool.description,
47
+ inputSchema: jsonSchema
48
+ };
49
+ }
50
+ /**
51
+ * Simple Zod to JSON Schema converter for tool definitions
52
+ */
53
+ function zodToJsonSchema(schema) {
54
+ const shape = schema.shape;
55
+ const properties = {};
56
+ const required = [];
57
+ for (const [key, value] of Object.entries(shape)) {
58
+ const zodType = value;
59
+ properties[key] = zodTypeToJsonSchema(zodType);
60
+ // Check if the field is required (not optional)
61
+ if (!zodType.isOptional()) {
62
+ required.push(key);
63
+ }
64
+ }
65
+ return {
66
+ type: 'object',
67
+ properties,
68
+ required
69
+ };
70
+ }
71
+ /**
72
+ * Convert individual Zod types to JSON Schema
73
+ */
74
+ function zodTypeToJsonSchema(zodType) {
75
+ const result = {};
76
+ // Handle optional wrapper
77
+ if (zodType instanceof z.ZodOptional) {
78
+ return zodTypeToJsonSchema(zodType._def.innerType);
79
+ }
80
+ // Handle default wrapper
81
+ if (zodType instanceof z.ZodDefault) {
82
+ const inner = zodTypeToJsonSchema(zodType._def.innerType);
83
+ inner.default = zodType._def.defaultValue();
84
+ return inner;
85
+ }
86
+ // Get description if available
87
+ const description = zodType._def.description;
88
+ if (description) {
89
+ result.description = description;
90
+ }
91
+ // Handle basic types
92
+ if (zodType instanceof z.ZodString) {
93
+ result.type = 'string';
94
+ }
95
+ else if (zodType instanceof z.ZodNumber) {
96
+ result.type = zodType._def.checks?.some((c) => c.kind === 'int')
97
+ ? 'integer'
98
+ : 'number';
99
+ }
100
+ else if (zodType instanceof z.ZodBoolean) {
101
+ result.type = 'boolean';
102
+ }
103
+ else if (zodType instanceof z.ZodArray) {
104
+ result.type = 'array';
105
+ result.items = zodTypeToJsonSchema(zodType._def.type);
106
+ }
107
+ else if (zodType instanceof z.ZodEnum) {
108
+ result.type = 'string';
109
+ result.enum = zodType._def.values;
110
+ }
111
+ else if (zodType instanceof z.ZodObject) {
112
+ return zodToJsonSchema(zodType);
113
+ }
114
+ else {
115
+ // Fallback for unknown types
116
+ result.type = 'string';
117
+ }
118
+ return result;
119
+ }
120
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY1C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA4B;IACrD,GAAG,QAA8C;IACjD,GAAG,QAA8C;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAA+B;IAChE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK;YACR,OAAO,QAA8C,CAAC;QACxD,KAAK,KAAK;YACR,OAAO,QAA8C,CAAC;QACxD,KAAK,KAAK;YACR,OAAO,cAAc,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAA0B,MAAS;IAChE,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAeD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAA2B;IACzD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE9C,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,UAAU;KACxB,CA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