oh-my-claude-sisyphus 3.7.3 → 3.7.5

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 (387) hide show
  1. package/agents/build-fixer-low.md +2 -2
  2. package/agents/build-fixer.md +74 -19
  3. package/agents/code-reviewer.md +7 -7
  4. package/agents/designer-high.md +2 -2
  5. package/agents/designer-low.md +1 -1
  6. package/agents/designer.md +17 -2
  7. package/agents/security-reviewer.md +86 -17
  8. package/agents/tdd-guide.md +151 -12
  9. package/commands/hud.md +3 -1
  10. package/dist/__tests__/analytics/analytics-summary.test.d.ts +2 -0
  11. package/dist/__tests__/analytics/analytics-summary.test.d.ts.map +1 -0
  12. package/dist/__tests__/analytics/analytics-summary.test.js +267 -0
  13. package/dist/__tests__/analytics/analytics-summary.test.js.map +1 -0
  14. package/dist/__tests__/analytics/cost-estimator.test.d.ts +2 -0
  15. package/dist/__tests__/analytics/cost-estimator.test.d.ts.map +1 -0
  16. package/dist/__tests__/analytics/cost-estimator.test.js +212 -0
  17. package/dist/__tests__/analytics/cost-estimator.test.js.map +1 -0
  18. package/dist/__tests__/analytics/output-estimator.test.js +18 -0
  19. package/dist/__tests__/analytics/output-estimator.test.js.map +1 -1
  20. package/dist/__tests__/analytics/token-extractor.test.js +44 -0
  21. package/dist/__tests__/analytics/token-extractor.test.js.map +1 -1
  22. package/dist/__tests__/analytics/token-tracker.test.d.ts +2 -0
  23. package/dist/__tests__/analytics/token-tracker.test.d.ts.map +1 -0
  24. package/dist/__tests__/analytics/token-tracker.test.js +189 -0
  25. package/dist/__tests__/analytics/token-tracker.test.js.map +1 -0
  26. package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts +7 -0
  27. package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts.map +1 -0
  28. package/dist/__tests__/hooks/auto-slash-command/executor.test.js +374 -0
  29. package/dist/__tests__/hooks/auto-slash-command/executor.test.js.map +1 -0
  30. package/dist/__tests__/hud/analytics-display.test.js +3 -8
  31. package/dist/__tests__/hud/analytics-display.test.js.map +1 -1
  32. package/dist/__tests__/hud/auto-tracking.integration.test.d.ts +2 -0
  33. package/dist/__tests__/hud/auto-tracking.integration.test.d.ts.map +1 -0
  34. package/dist/__tests__/hud/auto-tracking.integration.test.js +12 -0
  35. package/dist/__tests__/hud/auto-tracking.integration.test.js.map +1 -0
  36. package/dist/__tests__/hud/top-agents.test.d.ts +8 -0
  37. package/dist/__tests__/hud/top-agents.test.d.ts.map +1 -0
  38. package/dist/__tests__/hud/top-agents.test.js +157 -0
  39. package/dist/__tests__/hud/top-agents.test.js.map +1 -0
  40. package/dist/__tests__/installer.test.js +1 -1
  41. package/dist/__tests__/learned-skills/config.test.d.ts +2 -0
  42. package/dist/__tests__/learned-skills/config.test.d.ts.map +1 -0
  43. package/dist/__tests__/learned-skills/config.test.js +37 -0
  44. package/dist/__tests__/learned-skills/config.test.js.map +1 -0
  45. package/dist/__tests__/learned-skills/detector.test.d.ts +2 -0
  46. package/dist/__tests__/learned-skills/detector.test.d.ts.map +1 -0
  47. package/dist/__tests__/learned-skills/detector.test.js +99 -0
  48. package/dist/__tests__/learned-skills/detector.test.js.map +1 -0
  49. package/dist/__tests__/learned-skills/finder.test.d.ts +2 -0
  50. package/dist/__tests__/learned-skills/finder.test.d.ts.map +1 -0
  51. package/dist/__tests__/learned-skills/finder.test.js +59 -0
  52. package/dist/__tests__/learned-skills/finder.test.js.map +1 -0
  53. package/dist/__tests__/learned-skills/loader.test.d.ts +2 -0
  54. package/dist/__tests__/learned-skills/loader.test.d.ts.map +1 -0
  55. package/dist/__tests__/learned-skills/loader.test.js +69 -0
  56. package/dist/__tests__/learned-skills/loader.test.js.map +1 -0
  57. package/dist/__tests__/learned-skills/parser.test.d.ts +2 -0
  58. package/dist/__tests__/learned-skills/parser.test.d.ts.map +1 -0
  59. package/dist/__tests__/learned-skills/parser.test.js +81 -0
  60. package/dist/__tests__/learned-skills/parser.test.js.map +1 -0
  61. package/dist/__tests__/learned-skills/validator.test.d.ts +2 -0
  62. package/dist/__tests__/learned-skills/validator.test.d.ts.map +1 -0
  63. package/dist/__tests__/learned-skills/validator.test.js +85 -0
  64. package/dist/__tests__/learned-skills/validator.test.js.map +1 -0
  65. package/dist/__tests__/skills.test.js +6 -5
  66. package/dist/__tests__/skills.test.js.map +1 -1
  67. package/dist/agents/codex-agents.d.ts +20 -0
  68. package/dist/agents/codex-agents.d.ts.map +1 -0
  69. package/dist/agents/codex-agents.js +36 -0
  70. package/dist/agents/codex-agents.js.map +1 -0
  71. package/dist/agents/definitions.js +1 -1
  72. package/dist/agents/definitions.js.map +1 -1
  73. package/dist/agents/document-writer.d.ts +11 -0
  74. package/dist/agents/document-writer.d.ts.map +1 -0
  75. package/dist/agents/document-writer.js +209 -0
  76. package/dist/agents/document-writer.js.map +1 -0
  77. package/dist/agents/frontend-engineer.d.ts +11 -0
  78. package/dist/agents/frontend-engineer.d.ts.map +1 -0
  79. package/dist/agents/frontend-engineer.js +115 -0
  80. package/dist/agents/frontend-engineer.js.map +1 -0
  81. package/dist/agents/librarian.d.ts +12 -0
  82. package/dist/agents/librarian.d.ts.map +1 -0
  83. package/dist/agents/librarian.js +103 -0
  84. package/dist/agents/librarian.js.map +1 -0
  85. package/dist/agents/metis.d.ts +12 -0
  86. package/dist/agents/metis.d.ts.map +1 -0
  87. package/dist/agents/metis.js +117 -0
  88. package/dist/agents/metis.js.map +1 -0
  89. package/dist/agents/momus.d.ts +12 -0
  90. package/dist/agents/momus.d.ts.map +1 -0
  91. package/dist/agents/momus.js +128 -0
  92. package/dist/agents/momus.js.map +1 -0
  93. package/dist/agents/multimodal-looker.d.ts +11 -0
  94. package/dist/agents/multimodal-looker.d.ts.map +1 -0
  95. package/dist/agents/multimodal-looker.js +70 -0
  96. package/dist/agents/multimodal-looker.js.map +1 -0
  97. package/dist/agents/oracle.d.ts +13 -0
  98. package/dist/agents/oracle.d.ts.map +1 -0
  99. package/dist/agents/oracle.js +191 -0
  100. package/dist/agents/oracle.js.map +1 -0
  101. package/dist/agents/orchestrator-sisyphus.d.ts +11 -0
  102. package/dist/agents/orchestrator-sisyphus.d.ts.map +1 -0
  103. package/dist/agents/orchestrator-sisyphus.js +115 -0
  104. package/dist/agents/orchestrator-sisyphus.js.map +1 -0
  105. package/dist/agents/prometheus.d.ts +12 -0
  106. package/dist/agents/prometheus.d.ts.map +1 -0
  107. package/dist/agents/prometheus.js +195 -0
  108. package/dist/agents/prometheus.js.map +1 -0
  109. package/dist/agents/sisyphus-junior.d.ts +12 -0
  110. package/dist/agents/sisyphus-junior.d.ts.map +1 -0
  111. package/dist/agents/sisyphus-junior.js +93 -0
  112. package/dist/agents/sisyphus-junior.js.map +1 -0
  113. package/dist/analytics/output-estimator.d.ts.map +1 -1
  114. package/dist/analytics/output-estimator.js +5 -1
  115. package/dist/analytics/output-estimator.js.map +1 -1
  116. package/dist/analytics/token-extractor.js +2 -2
  117. package/dist/analytics/token-extractor.js.map +1 -1
  118. package/dist/cli/analytics.js +0 -0
  119. package/dist/cli/components/CostDashboard.d.ts +15 -0
  120. package/dist/cli/components/CostDashboard.d.ts.map +1 -0
  121. package/dist/cli/components/CostDashboard.js +15 -0
  122. package/dist/cli/components/CostDashboard.js.map +1 -0
  123. package/dist/cli/components/LiveStats.d.ts +16 -0
  124. package/dist/cli/components/LiveStats.d.ts.map +1 -0
  125. package/dist/cli/components/LiveStats.js +16 -0
  126. package/dist/cli/components/LiveStats.js.map +1 -0
  127. package/dist/cli/components/SessionBrowser.d.ts +14 -0
  128. package/dist/cli/components/SessionBrowser.d.ts.map +1 -0
  129. package/dist/cli/components/SessionBrowser.js +14 -0
  130. package/dist/cli/components/SessionBrowser.js.map +1 -0
  131. package/dist/cli/index.js +0 -0
  132. package/dist/cli/tui.d.ts +21 -0
  133. package/dist/cli/tui.d.ts.map +1 -0
  134. package/dist/cli/tui.js +21 -0
  135. package/dist/cli/tui.js.map +1 -0
  136. package/dist/compatibility/discovery.d.ts.map +1 -1
  137. package/dist/compatibility/discovery.js +3 -1
  138. package/dist/compatibility/discovery.js.map +1 -1
  139. package/dist/hooks/autopilot/prompts.d.ts.map +1 -1
  140. package/dist/hooks/autopilot/prompts.js +17 -3
  141. package/dist/hooks/autopilot/prompts.js.map +1 -1
  142. package/dist/hooks/autopilot/signals.d.ts +20 -0
  143. package/dist/hooks/autopilot/signals.d.ts.map +1 -0
  144. package/dist/hooks/autopilot/signals.js +75 -0
  145. package/dist/hooks/autopilot/signals.js.map +1 -0
  146. package/dist/hooks/autopilot/summary.d.ts +27 -0
  147. package/dist/hooks/autopilot/summary.d.ts.map +1 -0
  148. package/dist/hooks/autopilot/summary.js +160 -0
  149. package/dist/hooks/autopilot/summary.js.map +1 -0
  150. package/dist/hooks/autopilot/transition.d.ts +39 -0
  151. package/dist/hooks/autopilot/transition.d.ts.map +1 -0
  152. package/dist/hooks/autopilot/transition.js +216 -0
  153. package/dist/hooks/autopilot/transition.js.map +1 -0
  154. package/dist/hooks/context-window-limit-recovery/constants.d.ts +28 -0
  155. package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +1 -0
  156. package/dist/hooks/context-window-limit-recovery/constants.js +85 -0
  157. package/dist/hooks/context-window-limit-recovery/constants.js.map +1 -0
  158. package/dist/hooks/context-window-limit-recovery/index.d.ts +62 -0
  159. package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -0
  160. package/dist/hooks/context-window-limit-recovery/index.js +201 -0
  161. package/dist/hooks/context-window-limit-recovery/index.js.map +1 -0
  162. package/dist/hooks/context-window-limit-recovery/parser.d.ts +31 -0
  163. package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +1 -0
  164. package/dist/hooks/context-window-limit-recovery/parser.js +241 -0
  165. package/dist/hooks/context-window-limit-recovery/parser.js.map +1 -0
  166. package/dist/hooks/context-window-limit-recovery/types.d.ts +84 -0
  167. package/dist/hooks/context-window-limit-recovery/types.d.ts.map +1 -0
  168. package/dist/hooks/context-window-limit-recovery/types.js +34 -0
  169. package/dist/hooks/context-window-limit-recovery/types.js.map +1 -0
  170. package/dist/hooks/edit-error-recovery/index.d.ts +62 -0
  171. package/dist/hooks/edit-error-recovery/index.d.ts.map +1 -0
  172. package/dist/hooks/edit-error-recovery/index.js +89 -0
  173. package/dist/hooks/edit-error-recovery/index.js.map +1 -0
  174. package/dist/hooks/github-auto-responder/classifier.d.ts +43 -0
  175. package/dist/hooks/github-auto-responder/classifier.d.ts.map +1 -0
  176. package/dist/hooks/github-auto-responder/classifier.js +150 -0
  177. package/dist/hooks/github-auto-responder/classifier.js.map +1 -0
  178. package/dist/hooks/github-auto-responder/config.d.ts +109 -0
  179. package/dist/hooks/github-auto-responder/config.d.ts.map +1 -0
  180. package/dist/hooks/github-auto-responder/config.js +69 -0
  181. package/dist/hooks/github-auto-responder/config.js.map +1 -0
  182. package/dist/hooks/github-auto-responder/constants.d.ts +45 -0
  183. package/dist/hooks/github-auto-responder/constants.d.ts.map +1 -0
  184. package/dist/hooks/github-auto-responder/constants.js +60 -0
  185. package/dist/hooks/github-auto-responder/constants.js.map +1 -0
  186. package/dist/hooks/github-auto-responder/filters.d.ts +95 -0
  187. package/dist/hooks/github-auto-responder/filters.d.ts.map +1 -0
  188. package/dist/hooks/github-auto-responder/filters.js +174 -0
  189. package/dist/hooks/github-auto-responder/filters.js.map +1 -0
  190. package/dist/hooks/github-auto-responder/github-client.d.ts +65 -0
  191. package/dist/hooks/github-auto-responder/github-client.d.ts.map +1 -0
  192. package/dist/hooks/github-auto-responder/github-client.js +128 -0
  193. package/dist/hooks/github-auto-responder/github-client.js.map +1 -0
  194. package/dist/hooks/github-auto-responder/idempotency.d.ts +68 -0
  195. package/dist/hooks/github-auto-responder/idempotency.d.ts.map +1 -0
  196. package/dist/hooks/github-auto-responder/idempotency.js +147 -0
  197. package/dist/hooks/github-auto-responder/idempotency.js.map +1 -0
  198. package/dist/hooks/github-auto-responder/index.d.ts +140 -0
  199. package/dist/hooks/github-auto-responder/index.d.ts.map +1 -0
  200. package/dist/hooks/github-auto-responder/index.js +145 -0
  201. package/dist/hooks/github-auto-responder/index.js.map +1 -0
  202. package/dist/hooks/github-auto-responder/persona.d.ts +40 -0
  203. package/dist/hooks/github-auto-responder/persona.d.ts.map +1 -0
  204. package/dist/hooks/github-auto-responder/persona.js +99 -0
  205. package/dist/hooks/github-auto-responder/persona.js.map +1 -0
  206. package/dist/hooks/github-auto-responder/responder.d.ts +122 -0
  207. package/dist/hooks/github-auto-responder/responder.d.ts.map +1 -0
  208. package/dist/hooks/github-auto-responder/responder.js +264 -0
  209. package/dist/hooks/github-auto-responder/responder.js.map +1 -0
  210. package/dist/hooks/github-auto-responder/server.d.ts +140 -0
  211. package/dist/hooks/github-auto-responder/server.d.ts.map +1 -0
  212. package/dist/hooks/github-auto-responder/server.js +301 -0
  213. package/dist/hooks/github-auto-responder/server.js.map +1 -0
  214. package/dist/hooks/github-auto-responder/signature.d.ts +34 -0
  215. package/dist/hooks/github-auto-responder/signature.d.ts.map +1 -0
  216. package/dist/hooks/github-auto-responder/signature.js +79 -0
  217. package/dist/hooks/github-auto-responder/signature.js.map +1 -0
  218. package/dist/hooks/github-auto-responder/templates.d.ts +16 -0
  219. package/dist/hooks/github-auto-responder/templates.d.ts.map +1 -0
  220. package/dist/hooks/github-auto-responder/templates.js +93 -0
  221. package/dist/hooks/github-auto-responder/templates.js.map +1 -0
  222. package/dist/hooks/github-auto-responder/types.d.ts +246 -0
  223. package/dist/hooks/github-auto-responder/types.d.ts.map +1 -0
  224. package/dist/hooks/github-auto-responder/types.js +7 -0
  225. package/dist/hooks/github-auto-responder/types.js.map +1 -0
  226. package/dist/hooks/learned-skills/config.d.ts +53 -0
  227. package/dist/hooks/learned-skills/config.d.ts.map +1 -0
  228. package/dist/hooks/learned-skills/config.js +103 -0
  229. package/dist/hooks/learned-skills/config.js.map +1 -0
  230. package/dist/hooks/learned-skills/constants.d.ts +24 -0
  231. package/dist/hooks/learned-skills/constants.d.ts.map +1 -0
  232. package/dist/hooks/learned-skills/constants.js +26 -0
  233. package/dist/hooks/learned-skills/constants.js.map +1 -0
  234. package/dist/hooks/learned-skills/detection-hook.d.ts +39 -0
  235. package/dist/hooks/learned-skills/detection-hook.d.ts.map +1 -0
  236. package/dist/hooks/learned-skills/detection-hook.js +83 -0
  237. package/dist/hooks/learned-skills/detection-hook.js.map +1 -0
  238. package/dist/hooks/learned-skills/detector.d.ts +30 -0
  239. package/dist/hooks/learned-skills/detector.d.ts.map +1 -0
  240. package/dist/hooks/learned-skills/detector.js +150 -0
  241. package/dist/hooks/learned-skills/detector.js.map +1 -0
  242. package/dist/hooks/learned-skills/finder.d.ts +21 -0
  243. package/dist/hooks/learned-skills/finder.d.ts.map +1 -0
  244. package/dist/hooks/learned-skills/finder.js +117 -0
  245. package/dist/hooks/learned-skills/finder.js.map +1 -0
  246. package/dist/hooks/learned-skills/index.d.ts +62 -0
  247. package/dist/hooks/learned-skills/index.d.ts.map +1 -0
  248. package/dist/hooks/learned-skills/index.js +137 -0
  249. package/dist/hooks/learned-skills/index.js.map +1 -0
  250. package/dist/hooks/learned-skills/loader.d.ts +20 -0
  251. package/dist/hooks/learned-skills/loader.d.ts.map +1 -0
  252. package/dist/hooks/learned-skills/loader.js +107 -0
  253. package/dist/hooks/learned-skills/loader.js.map +1 -0
  254. package/dist/hooks/learned-skills/parser.d.ts +21 -0
  255. package/dist/hooks/learned-skills/parser.d.ts.map +1 -0
  256. package/dist/hooks/learned-skills/parser.js +190 -0
  257. package/dist/hooks/learned-skills/parser.js.map +1 -0
  258. package/dist/hooks/learned-skills/promotion.d.ts +29 -0
  259. package/dist/hooks/learned-skills/promotion.d.ts.map +1 -0
  260. package/dist/hooks/learned-skills/promotion.js +87 -0
  261. package/dist/hooks/learned-skills/promotion.js.map +1 -0
  262. package/dist/hooks/learned-skills/types.d.ts +109 -0
  263. package/dist/hooks/learned-skills/types.d.ts.map +1 -0
  264. package/dist/hooks/learned-skills/types.js +8 -0
  265. package/dist/hooks/learned-skills/types.js.map +1 -0
  266. package/dist/hooks/learned-skills/validator.d.ts +15 -0
  267. package/dist/hooks/learned-skills/validator.d.ts.map +1 -0
  268. package/dist/hooks/learned-skills/validator.js +87 -0
  269. package/dist/hooks/learned-skills/validator.js.map +1 -0
  270. package/dist/hooks/learned-skills/writer.d.ts +27 -0
  271. package/dist/hooks/learned-skills/writer.d.ts.map +1 -0
  272. package/dist/hooks/learned-skills/writer.js +126 -0
  273. package/dist/hooks/learned-skills/writer.js.map +1 -0
  274. package/dist/hooks/mnemosyne/config.d.ts +53 -0
  275. package/dist/hooks/mnemosyne/config.d.ts.map +1 -0
  276. package/dist/hooks/mnemosyne/config.js +103 -0
  277. package/dist/hooks/mnemosyne/config.js.map +1 -0
  278. package/dist/hooks/mnemosyne/constants.d.ts +24 -0
  279. package/dist/hooks/mnemosyne/constants.d.ts.map +1 -0
  280. package/dist/hooks/mnemosyne/constants.js +26 -0
  281. package/dist/hooks/mnemosyne/constants.js.map +1 -0
  282. package/dist/hooks/mnemosyne/detection-hook.d.ts +39 -0
  283. package/dist/hooks/mnemosyne/detection-hook.d.ts.map +1 -0
  284. package/dist/hooks/mnemosyne/detection-hook.js +83 -0
  285. package/dist/hooks/mnemosyne/detection-hook.js.map +1 -0
  286. package/dist/hooks/mnemosyne/detector.d.ts +30 -0
  287. package/dist/hooks/mnemosyne/detector.d.ts.map +1 -0
  288. package/dist/hooks/mnemosyne/detector.js +150 -0
  289. package/dist/hooks/mnemosyne/detector.js.map +1 -0
  290. package/dist/hooks/mnemosyne/finder.d.ts +21 -0
  291. package/dist/hooks/mnemosyne/finder.d.ts.map +1 -0
  292. package/dist/hooks/mnemosyne/finder.js +117 -0
  293. package/dist/hooks/mnemosyne/finder.js.map +1 -0
  294. package/dist/hooks/mnemosyne/index.d.ts +62 -0
  295. package/dist/hooks/mnemosyne/index.d.ts.map +1 -0
  296. package/dist/hooks/mnemosyne/index.js +137 -0
  297. package/dist/hooks/mnemosyne/index.js.map +1 -0
  298. package/dist/hooks/mnemosyne/loader.d.ts +20 -0
  299. package/dist/hooks/mnemosyne/loader.d.ts.map +1 -0
  300. package/dist/hooks/mnemosyne/loader.js +113 -0
  301. package/dist/hooks/mnemosyne/loader.js.map +1 -0
  302. package/dist/hooks/mnemosyne/parser.d.ts +21 -0
  303. package/dist/hooks/mnemosyne/parser.d.ts.map +1 -0
  304. package/dist/hooks/mnemosyne/parser.js +190 -0
  305. package/dist/hooks/mnemosyne/parser.js.map +1 -0
  306. package/dist/hooks/mnemosyne/promotion.d.ts +29 -0
  307. package/dist/hooks/mnemosyne/promotion.d.ts.map +1 -0
  308. package/dist/hooks/mnemosyne/promotion.js +87 -0
  309. package/dist/hooks/mnemosyne/promotion.js.map +1 -0
  310. package/dist/hooks/mnemosyne/types.d.ts +109 -0
  311. package/dist/hooks/mnemosyne/types.d.ts.map +1 -0
  312. package/dist/hooks/mnemosyne/types.js +8 -0
  313. package/dist/hooks/mnemosyne/types.js.map +1 -0
  314. package/dist/hooks/mnemosyne/validator.d.ts +15 -0
  315. package/dist/hooks/mnemosyne/validator.d.ts.map +1 -0
  316. package/dist/hooks/mnemosyne/validator.js +87 -0
  317. package/dist/hooks/mnemosyne/validator.js.map +1 -0
  318. package/dist/hooks/mnemosyne/writer.d.ts +27 -0
  319. package/dist/hooks/mnemosyne/writer.d.ts.map +1 -0
  320. package/dist/hooks/mnemosyne/writer.js +126 -0
  321. package/dist/hooks/mnemosyne/writer.js.map +1 -0
  322. package/dist/hooks/pre-compact/index.d.ts +2 -4
  323. package/dist/hooks/pre-compact/index.d.ts.map +1 -1
  324. package/dist/hooks/pre-compact/index.js +3 -4
  325. package/dist/hooks/pre-compact/index.js.map +1 -1
  326. package/dist/hooks/ralph-loop/index.d.ts +116 -0
  327. package/dist/hooks/ralph-loop/index.d.ts.map +1 -0
  328. package/dist/hooks/ralph-loop/index.js +322 -0
  329. package/dist/hooks/ralph-loop/index.js.map +1 -0
  330. package/dist/hooks/ralph-prd/index.d.ts +130 -0
  331. package/dist/hooks/ralph-prd/index.d.ts.map +1 -0
  332. package/dist/hooks/ralph-prd/index.js +310 -0
  333. package/dist/hooks/ralph-prd/index.js.map +1 -0
  334. package/dist/hooks/ralph-progress/index.d.ts +102 -0
  335. package/dist/hooks/ralph-progress/index.d.ts.map +1 -0
  336. package/dist/hooks/ralph-progress/index.js +408 -0
  337. package/dist/hooks/ralph-progress/index.js.map +1 -0
  338. package/dist/hooks/ralph-verifier/index.d.ts +72 -0
  339. package/dist/hooks/ralph-verifier/index.d.ts.map +1 -0
  340. package/dist/hooks/ralph-verifier/index.js +223 -0
  341. package/dist/hooks/ralph-verifier/index.js.map +1 -0
  342. package/dist/hooks/session-recovery/constants.d.ts +56 -0
  343. package/dist/hooks/session-recovery/constants.d.ts.map +1 -0
  344. package/dist/hooks/session-recovery/constants.js +78 -0
  345. package/dist/hooks/session-recovery/constants.js.map +1 -0
  346. package/dist/hooks/session-recovery/index.d.ts +53 -0
  347. package/dist/hooks/session-recovery/index.d.ts.map +1 -0
  348. package/dist/hooks/session-recovery/index.js +321 -0
  349. package/dist/hooks/session-recovery/index.js.map +1 -0
  350. package/dist/hooks/session-recovery/storage.d.ts +76 -0
  351. package/dist/hooks/session-recovery/storage.d.ts.map +1 -0
  352. package/dist/hooks/session-recovery/storage.js +383 -0
  353. package/dist/hooks/session-recovery/storage.js.map +1 -0
  354. package/dist/hooks/session-recovery/types.d.ts +145 -0
  355. package/dist/hooks/session-recovery/types.d.ts.map +1 -0
  356. package/dist/hooks/session-recovery/types.js +8 -0
  357. package/dist/hooks/session-recovery/types.js.map +1 -0
  358. package/dist/hooks/sisyphus-orchestrator/constants.d.ts +23 -0
  359. package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +1 -0
  360. package/dist/hooks/sisyphus-orchestrator/constants.js +142 -0
  361. package/dist/hooks/sisyphus-orchestrator/constants.js.map +1 -0
  362. package/dist/hooks/sisyphus-orchestrator/index.d.ts +113 -0
  363. package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -0
  364. package/dist/hooks/sisyphus-orchestrator/index.js +309 -0
  365. package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -0
  366. package/dist/hooks/ultraqa-loop/index.d.ts +94 -0
  367. package/dist/hooks/ultraqa-loop/index.d.ts.map +1 -0
  368. package/dist/hooks/ultraqa-loop/index.js +216 -0
  369. package/dist/hooks/ultraqa-loop/index.js.map +1 -0
  370. package/dist/hooks/ultrawork-state/index.d.ts +62 -0
  371. package/dist/hooks/ultrawork-state/index.d.ts.map +1 -0
  372. package/dist/hooks/ultrawork-state/index.js +208 -0
  373. package/dist/hooks/ultrawork-state/index.js.map +1 -0
  374. package/dist/hud/analytics-display.d.ts.map +1 -1
  375. package/dist/hud/analytics-display.js +0 -1
  376. package/dist/hud/analytics-display.js.map +1 -1
  377. package/dist/hud/index.js +52 -3
  378. package/dist/hud/index.js.map +1 -1
  379. package/dist/hud/sisyphus-state.d.ts +31 -0
  380. package/dist/hud/sisyphus-state.d.ts.map +1 -0
  381. package/dist/hud/sisyphus-state.js +163 -0
  382. package/dist/hud/sisyphus-state.js.map +1 -0
  383. package/dist/installer/index.d.ts +1 -1
  384. package/dist/installer/index.js +1 -1
  385. package/package.json +1 -1
  386. package/scripts/github-webhook-server.ts +141 -0
  387. package/skills/hud/SKILL.md +3 -1
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Autopilot Phase Transitions
3
+ *
4
+ * Handles transitions between phases, especially the critical Ralph → UltraQA
5
+ * and UltraQA → Validation transitions that must respect mutual exclusion.
6
+ */
7
+ import { readRalphState, clearRalphState, clearLinkedUltraworkState } from '../ralph-loop/index.js';
8
+ import { startUltraQA, clearUltraQAState, readUltraQAState } from '../ultraqa-loop/index.js';
9
+ import { readAutopilotState, transitionPhase, updateExecution, updateQA } from './state.js';
10
+ /**
11
+ * Transition from Ralph (Phase 2: Execution) to UltraQA (Phase 3: QA)
12
+ *
13
+ * This handles the mutual exclusion by:
14
+ * 1. Saving Ralph's progress to autopilot state
15
+ * 2. Cleanly terminating Ralph mode (and linked Ultrawork)
16
+ * 3. Starting UltraQA mode
17
+ * 4. Preserving context for potential rollback
18
+ */
19
+ export function transitionRalphToUltraQA(directory, sessionId) {
20
+ const autopilotState = readAutopilotState(directory);
21
+ if (!autopilotState || autopilotState.phase !== 'execution') {
22
+ return {
23
+ success: false,
24
+ error: 'Not in execution phase - cannot transition to QA'
25
+ };
26
+ }
27
+ const ralphState = readRalphState(directory);
28
+ // Step 1: Preserve Ralph progress in autopilot state
29
+ const executionUpdated = updateExecution(directory, {
30
+ ralph_iterations: ralphState?.iteration ?? autopilotState.execution.ralph_iterations,
31
+ ralph_completed_at: new Date().toISOString(),
32
+ ultrawork_active: false
33
+ });
34
+ if (!executionUpdated) {
35
+ return {
36
+ success: false,
37
+ error: 'Failed to update execution state'
38
+ };
39
+ }
40
+ // Step 2: Cleanly terminate Ralph (and linked Ultrawork)
41
+ if (ralphState?.linked_ultrawork) {
42
+ clearLinkedUltraworkState(directory);
43
+ }
44
+ const ralphCleared = clearRalphState(directory);
45
+ if (!ralphCleared) {
46
+ return {
47
+ success: false,
48
+ error: 'Failed to clear Ralph state'
49
+ };
50
+ }
51
+ // Step 3: Transition to QA phase
52
+ const newState = transitionPhase(directory, 'qa');
53
+ if (!newState) {
54
+ return {
55
+ success: false,
56
+ error: 'Failed to transition to QA phase'
57
+ };
58
+ }
59
+ // Step 4: Start UltraQA
60
+ const qaResult = startUltraQA(directory, 'tests', sessionId, { maxCycles: 5 });
61
+ if (!qaResult.success) {
62
+ // Rollback on failure - restore execution phase
63
+ transitionPhase(directory, 'execution');
64
+ updateExecution(directory, { ralph_completed_at: undefined });
65
+ return {
66
+ success: false,
67
+ error: qaResult.error || 'Failed to start UltraQA'
68
+ };
69
+ }
70
+ return {
71
+ success: true,
72
+ state: newState
73
+ };
74
+ }
75
+ /**
76
+ * Transition from UltraQA (Phase 3: QA) to Validation (Phase 4)
77
+ */
78
+ export function transitionUltraQAToValidation(directory) {
79
+ const autopilotState = readAutopilotState(directory);
80
+ if (!autopilotState || autopilotState.phase !== 'qa') {
81
+ return {
82
+ success: false,
83
+ error: 'Not in QA phase - cannot transition to validation'
84
+ };
85
+ }
86
+ const qaState = readUltraQAState(directory);
87
+ // Preserve QA progress
88
+ const qaUpdated = updateQA(directory, {
89
+ ultraqa_cycles: qaState?.cycle ?? autopilotState.qa.ultraqa_cycles,
90
+ qa_completed_at: new Date().toISOString()
91
+ });
92
+ if (!qaUpdated) {
93
+ return {
94
+ success: false,
95
+ error: 'Failed to update QA state'
96
+ };
97
+ }
98
+ // Terminate UltraQA
99
+ clearUltraQAState(directory);
100
+ // Transition to validation
101
+ const newState = transitionPhase(directory, 'validation');
102
+ if (!newState) {
103
+ return {
104
+ success: false,
105
+ error: 'Failed to transition to validation phase'
106
+ };
107
+ }
108
+ return {
109
+ success: true,
110
+ state: newState
111
+ };
112
+ }
113
+ /**
114
+ * Transition from Validation (Phase 4) to Complete
115
+ */
116
+ export function transitionToComplete(directory) {
117
+ const state = transitionPhase(directory, 'complete');
118
+ if (!state) {
119
+ return {
120
+ success: false,
121
+ error: 'Failed to transition to complete phase'
122
+ };
123
+ }
124
+ return { success: true, state };
125
+ }
126
+ /**
127
+ * Transition to failed state
128
+ */
129
+ export function transitionToFailed(directory, error) {
130
+ const state = transitionPhase(directory, 'failed');
131
+ if (!state) {
132
+ return {
133
+ success: false,
134
+ error: 'Failed to transition to failed phase'
135
+ };
136
+ }
137
+ return { success: true, state };
138
+ }
139
+ /**
140
+ * Get a prompt for Claude to execute the transition
141
+ */
142
+ export function getTransitionPrompt(fromPhase, toPhase) {
143
+ if (fromPhase === 'execution' && toPhase === 'qa') {
144
+ return `## PHASE TRANSITION: Execution → QA
145
+
146
+ The execution phase is complete. Transitioning to QA phase.
147
+
148
+ **CRITICAL**: Ralph mode must be cleanly terminated before UltraQA can start.
149
+
150
+ The transition handler has:
151
+ 1. Preserved Ralph iteration count and progress
152
+ 2. Cleared Ralph state (and linked Ultrawork)
153
+ 3. Started UltraQA in 'tests' mode
154
+
155
+ You are now in QA phase. Run the QA cycle:
156
+ 1. Build: npm run build (or equivalent)
157
+ 2. Lint: npm run lint (or equivalent)
158
+ 3. Test: npm test (or equivalent)
159
+
160
+ Fix any failures and repeat until all pass.
161
+
162
+ Signal when QA passes: QA_COMPLETE
163
+ `;
164
+ }
165
+ if (fromPhase === 'qa' && toPhase === 'validation') {
166
+ return `## PHASE TRANSITION: QA → Validation
167
+
168
+ All QA checks have passed. Transitioning to validation phase.
169
+
170
+ The transition handler has:
171
+ 1. Preserved UltraQA cycle count
172
+ 2. Cleared UltraQA state
173
+ 3. Updated phase to 'validation'
174
+
175
+ You are now in validation phase. Spawn parallel validation architects:
176
+
177
+ \`\`\`
178
+ // Spawn all three in parallel
179
+ Task(subagent_type="oh-my-claudecode:architect", model="opus",
180
+ prompt="FUNCTIONAL COMPLETENESS REVIEW: Verify all requirements from spec are implemented")
181
+
182
+ Task(subagent_type="oh-my-claudecode:security-reviewer", model="opus",
183
+ prompt="SECURITY REVIEW: Check for vulnerabilities, injection risks, auth issues")
184
+
185
+ Task(subagent_type="oh-my-claudecode:code-reviewer", model="opus",
186
+ prompt="CODE QUALITY REVIEW: Check patterns, maintainability, test coverage")
187
+ \`\`\`
188
+
189
+ Aggregate verdicts:
190
+ - All APPROVED → Signal: AUTOPILOT_COMPLETE
191
+ - Any REJECTED → Fix issues and re-validate (max 3 rounds)
192
+ `;
193
+ }
194
+ if (fromPhase === 'expansion' && toPhase === 'planning') {
195
+ return `## PHASE TRANSITION: Expansion → Planning
196
+
197
+ The idea has been expanded into a detailed specification.
198
+
199
+ Read the spec and create an implementation plan using the Architect agent (direct planning mode).
200
+
201
+ Signal when Critic approves the plan: PLANNING_COMPLETE
202
+ `;
203
+ }
204
+ if (fromPhase === 'planning' && toPhase === 'execution') {
205
+ return `## PHASE TRANSITION: Planning → Execution
206
+
207
+ The plan has been approved. Starting execution phase with Ralph + Ultrawork.
208
+
209
+ Execute tasks from the plan in parallel where possible.
210
+
211
+ Signal when all tasks complete: EXECUTION_COMPLETE
212
+ `;
213
+ }
214
+ return '';
215
+ }
216
+ //# sourceMappingURL=transition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transition.js","sourceRoot":"","sources":["../../../src/hooks/autopilot/transition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAElB,eAAe,EACf,eAAe,EACf,QAAQ,EAET,MAAM,YAAY,CAAC;AASpB;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAAiB,EACjB,SAAiB;IAEjB,MAAM,cAAc,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAErD,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QAC5D,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,kDAAkD;SAC1D,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAE7C,qDAAqD;IACrD,MAAM,gBAAgB,GAAG,eAAe,CAAC,SAAS,EAAE;QAClD,gBAAgB,EAAE,UAAU,EAAE,SAAS,IAAI,cAAc,CAAC,SAAS,CAAC,gBAAgB;QACpF,kBAAkB,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC5C,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;IAEH,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,kCAAkC;SAC1C,CAAC;IACJ,CAAC;IAED,yDAAyD;IACzD,IAAI,UAAU,EAAE,gBAAgB,EAAE,CAAC;QACjC,yBAAyB,CAAC,SA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AED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAAe;IAEf,IAAI,SAAS,KAAK,WAAW,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAClD,OAAO;;;;;;;;;;;;;;;;;;;CAmBV,CAAC;IACA,CAAC;IAED,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QACnD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BV,CAAC;IACA,CAAC;IAED,IAAI,SAAS,KAAK,WAAW,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QACxD,OAAO;;;;;;;CAOV,CAAC;IACA,CAAC;IAED,IAAI,SAAS,KAAK,UAAU,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QACxD,OAAO;;;;;;;CAOV,CAAC;IACA,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Context Window Limit Recovery Constants
3
+ *
4
+ * Messages and prompts for recovery from context limit errors.
5
+ *
6
+ * Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
7
+ */
8
+ /**
9
+ * Recovery message when context window limit is hit
10
+ */
11
+ export declare const CONTEXT_LIMIT_RECOVERY_MESSAGE = "CONTEXT WINDOW LIMIT REACHED - IMMEDIATE ACTION REQUIRED\n\nThe conversation has exceeded the model's context window limit. To continue working effectively, you must take one of these actions:\n\n1. SUMMARIZE THE CONVERSATION\n - Use the /compact command if available\n - Or provide a concise summary of what has been accomplished so far\n - Include key decisions, code changes, and remaining tasks\n\n2. START A FRESH CONTEXT\n - If summarization isn't sufficient, suggest starting a new session\n - Provide a handoff message with essential context\n\n3. REDUCE OUTPUT SIZE\n - When showing code, show only relevant portions\n - Use file paths and line numbers instead of full code blocks\n - Be more concise in explanations\n\nIMPORTANT: Do not attempt to continue without addressing this limit.\nThe API will reject further requests until the context is reduced.\n\nCurrent Status:\n- Context limit exceeded\n- Further API calls will fail until context is reduced\n- Action required before continuing\n";
12
+ /**
13
+ * Short notification for context limit
14
+ */
15
+ export declare const CONTEXT_LIMIT_SHORT_MESSAGE = "Context window limit reached. Please use /compact to summarize the conversation or start a new session.";
16
+ /**
17
+ * Recovery message for non-empty content errors
18
+ */
19
+ export declare const NON_EMPTY_CONTENT_RECOVERY_MESSAGE = "API ERROR: Non-empty content validation failed.\n\nThis error typically occurs when:\n- A message has empty text content\n- The conversation structure is invalid\n\nSuggested actions:\n1. Continue with a new message\n2. If the error persists, start a new session\n\nThe system will attempt automatic recovery.\n";
20
+ /**
21
+ * Recovery message when truncation was applied
22
+ */
23
+ export declare const TRUNCATION_APPLIED_MESSAGE = "CONTEXT OPTIMIZATION APPLIED\n\nSome tool outputs have been truncated to fit within the context window.\nThe conversation can now continue normally.\n\nIf you need to see the full output of a previous tool call, you can:\n- Re-run the specific command\n- Ask to see a particular file or section\n\nContinuing with the current task...\n";
24
+ /**
25
+ * Message when recovery fails
26
+ */
27
+ export declare const RECOVERY_FAILED_MESSAGE = "CONTEXT RECOVERY FAILED\n\nAll automatic recovery attempts have been exhausted.\nPlease start a new session to continue.\n\nBefore starting a new session:\n1. Note what has been accomplished\n2. Save any important code changes\n3. Document the current state of the task\n\nYou can copy this conversation summary to continue in a new session.\n";
28
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B,kgCAyB1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,4GAA4G,CAAC;AAErJ;;GAEG;AACH,eAAO,MAAM,kCAAkC,4TAW9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,oVAUtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,4VAWnC,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Context Window Limit Recovery Constants
3
+ *
4
+ * Messages and prompts for recovery from context limit errors.
5
+ *
6
+ * Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
7
+ */
8
+ /**
9
+ * Recovery message when context window limit is hit
10
+ */
11
+ export const CONTEXT_LIMIT_RECOVERY_MESSAGE = `CONTEXT WINDOW LIMIT REACHED - IMMEDIATE ACTION REQUIRED
12
+
13
+ The conversation has exceeded the model's context window limit. To continue working effectively, you must take one of these actions:
14
+
15
+ 1. SUMMARIZE THE CONVERSATION
16
+ - Use the /compact command if available
17
+ - Or provide a concise summary of what has been accomplished so far
18
+ - Include key decisions, code changes, and remaining tasks
19
+
20
+ 2. START A FRESH CONTEXT
21
+ - If summarization isn't sufficient, suggest starting a new session
22
+ - Provide a handoff message with essential context
23
+
24
+ 3. REDUCE OUTPUT SIZE
25
+ - When showing code, show only relevant portions
26
+ - Use file paths and line numbers instead of full code blocks
27
+ - Be more concise in explanations
28
+
29
+ IMPORTANT: Do not attempt to continue without addressing this limit.
30
+ The API will reject further requests until the context is reduced.
31
+
32
+ Current Status:
33
+ - Context limit exceeded
34
+ - Further API calls will fail until context is reduced
35
+ - Action required before continuing
36
+ `;
37
+ /**
38
+ * Short notification for context limit
39
+ */
40
+ export const CONTEXT_LIMIT_SHORT_MESSAGE = `Context window limit reached. Please use /compact to summarize the conversation or start a new session.`;
41
+ /**
42
+ * Recovery message for non-empty content errors
43
+ */
44
+ export const NON_EMPTY_CONTENT_RECOVERY_MESSAGE = `API ERROR: Non-empty content validation failed.
45
+
46
+ This error typically occurs when:
47
+ - A message has empty text content
48
+ - The conversation structure is invalid
49
+
50
+ Suggested actions:
51
+ 1. Continue with a new message
52
+ 2. If the error persists, start a new session
53
+
54
+ The system will attempt automatic recovery.
55
+ `;
56
+ /**
57
+ * Recovery message when truncation was applied
58
+ */
59
+ export const TRUNCATION_APPLIED_MESSAGE = `CONTEXT OPTIMIZATION APPLIED
60
+
61
+ Some tool outputs have been truncated to fit within the context window.
62
+ The conversation can now continue normally.
63
+
64
+ If you need to see the full output of a previous tool call, you can:
65
+ - Re-run the specific command
66
+ - Ask to see a particular file or section
67
+
68
+ Continuing with the current task...
69
+ `;
70
+ /**
71
+ * Message when recovery fails
72
+ */
73
+ export const RECOVERY_FAILED_MESSAGE = `CONTEXT RECOVERY FAILED
74
+
75
+ All automatic recovery attempts have been exhausted.
76
+ Please start a new session to continue.
77
+
78
+ Before starting a new session:
79
+ 1. Note what has been accomplished
80
+ 2. Save any important code changes
81
+ 3. Document the current state of the task
82
+
83
+ You can copy this conversation summary to continue in a new session.
84
+ `;
85
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyB7C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,yGAAyG,CAAC;AAErJ;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;;;;;;;;;CAWjD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;CAUzC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;CAWtC,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Context Window Limit Recovery Hook
3
+ *
4
+ * Detects context window limit errors and injects recovery messages
5
+ * to help Claude recover gracefully.
6
+ *
7
+ * Adapted from oh-my-opencode's anthropic-context-window-limit-recovery 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 more sophisticated
11
+ * recovery like automatic summarization and truncation.
12
+ */
13
+ import type { ParsedTokenLimitError, RecoveryResult } from './types.js';
14
+ /**
15
+ * Configuration for context limit recovery hook
16
+ */
17
+ export interface ContextLimitRecoveryConfig {
18
+ /** Whether to show detailed recovery messages */
19
+ detailed?: boolean;
20
+ /** Custom recovery message */
21
+ customMessage?: string;
22
+ /** Whether to enable the hook */
23
+ enabled?: boolean;
24
+ }
25
+ /**
26
+ * Create context window limit recovery hook
27
+ *
28
+ * This hook monitors for token/context limit errors and injects
29
+ * helpful recovery messages when detected.
30
+ */
31
+ export declare function createContextLimitRecoveryHook(config?: ContextLimitRecoveryConfig): {
32
+ /**
33
+ * PostToolUse - Check for context limit errors in tool responses
34
+ */
35
+ postToolUse: (input: {
36
+ tool_name: string;
37
+ session_id: string;
38
+ tool_input: Record<string, unknown>;
39
+ tool_response?: string;
40
+ }) => string | null;
41
+ /**
42
+ * Notification - Check for error notifications
43
+ * (Called when errors are passed through notification system)
44
+ */
45
+ onError: (input: {
46
+ session_id: string;
47
+ error: unknown;
48
+ }) => RecoveryResult;
49
+ };
50
+ /**
51
+ * Check if text contains a context limit error
52
+ */
53
+ export declare function detectContextLimitError(text: string): boolean;
54
+ /**
55
+ * Parse error to get detailed token limit info
56
+ */
57
+ export declare function parseContextLimitError(error: unknown): ParsedTokenLimitError | null;
58
+ export type { ParsedTokenLimitError, RetryState, TruncateState, RecoveryResult, } from './types.js';
59
+ export { RETRY_CONFIG, TRUNCATE_CONFIG } from './types.js';
60
+ export { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, TRUNCATION_APPLIED_MESSAGE, RECOVERY_FAILED_MESSAGE, } from './constants.js';
61
+ export { parseTokenLimitError, containsTokenLimitError, TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, } from './parser.js';
62
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH,OAAO,KAAK,EACV,qBAAqB,EAGrB,cAAc,EACf,MAAM,YAAY,CAAC;AAsEpB;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,CAAC,EAAE,0BAA0B;IAUjC;;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;IAmCjB;;;OAGG;qBACc;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,OAAO,CAAC;KAChB,KAAG,cAAc;EA6BrB;AA8DD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,qBAAqB,GAAG,IAAI,CAE9B;AAGD,YAAY,EACV,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Context Window Limit Recovery Hook
3
+ *
4
+ * Detects context window limit errors and injects recovery messages
5
+ * to help Claude recover gracefully.
6
+ *
7
+ * Adapted from oh-my-opencode's anthropic-context-window-limit-recovery 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 more sophisticated
11
+ * recovery like automatic summarization and truncation.
12
+ */
13
+ import * as fs from 'fs';
14
+ import * as path from 'path';
15
+ import { tmpdir } from 'os';
16
+ import { parseTokenLimitError, containsTokenLimitError, } from './parser.js';
17
+ import { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, RECOVERY_FAILED_MESSAGE, } from './constants.js';
18
+ import { RETRY_CONFIG } from './types.js';
19
+ const DEBUG = process.env.CONTEXT_LIMIT_RECOVERY_DEBUG === '1';
20
+ const DEBUG_FILE = path.join(tmpdir(), 'context-limit-recovery-debug.log');
21
+ function debugLog(...args) {
22
+ if (DEBUG) {
23
+ const msg = `[${new Date().toISOString()}] [context-limit-recovery] ${args
24
+ .map((a) => typeof a === 'object' ? JSON.stringify(a, null, 2) : String(a))
25
+ .join(' ')}\n`;
26
+ fs.appendFileSync(DEBUG_FILE, msg);
27
+ }
28
+ }
29
+ const sessionStates = new Map();
30
+ const STATE_TTL = 300_000; // 5 minutes
31
+ /**
32
+ * Get or create session state
33
+ */
34
+ function getSessionState(sessionId) {
35
+ let state = sessionStates.get(sessionId);
36
+ const now = Date.now();
37
+ // Reset stale state
38
+ if (state && now - state.lastErrorTime > STATE_TTL) {
39
+ state = undefined;
40
+ }
41
+ if (!state) {
42
+ state = {
43
+ retryState: { attempt: 0, lastAttemptTime: 0 },
44
+ truncateState: { truncateAttempt: 0 },
45
+ lastErrorTime: now,
46
+ errorCount: 0,
47
+ };
48
+ sessionStates.set(sessionId, state);
49
+ }
50
+ return state;
51
+ }
52
+ /**
53
+ * Clean up old session states
54
+ */
55
+ function cleanupSessionStates() {
56
+ const now = Date.now();
57
+ for (const [sessionId, state] of sessionStates) {
58
+ if (now - state.lastErrorTime > STATE_TTL) {
59
+ sessionStates.delete(sessionId);
60
+ }
61
+ }
62
+ }
63
+ // Run cleanup periodically
64
+ let cleanupIntervalStarted = false;
65
+ /**
66
+ * Create context window limit recovery hook
67
+ *
68
+ * This hook monitors for token/context limit errors and injects
69
+ * helpful recovery messages when detected.
70
+ */
71
+ export function createContextLimitRecoveryHook(config) {
72
+ debugLog('createContextLimitRecoveryHook called', { config });
73
+ if (!cleanupIntervalStarted) {
74
+ cleanupIntervalStarted = true;
75
+ setInterval(cleanupSessionStates, 60_000);
76
+ }
77
+ return {
78
+ /**
79
+ * PostToolUse - Check for context limit errors in tool responses
80
+ */
81
+ postToolUse: (input) => {
82
+ if (!input.tool_response) {
83
+ return null;
84
+ }
85
+ // Check if response contains token limit error
86
+ const parsed = parseTokenLimitError(input.tool_response);
87
+ if (!parsed && !containsTokenLimitError(input.tool_response)) {
88
+ return null;
89
+ }
90
+ debugLog('detected token limit error', {
91
+ tool: input.tool_name,
92
+ sessionId: input.session_id,
93
+ parsed,
94
+ });
95
+ const state = getSessionState(input.session_id);
96
+ state.lastErrorTime = Date.now();
97
+ state.errorCount++;
98
+ // Generate appropriate recovery message
99
+ const recovery = generateRecoveryMessage(parsed, state, config);
100
+ if (recovery.message) {
101
+ debugLog('injecting recovery message', {
102
+ errorType: recovery.errorType,
103
+ attempt: state.retryState.attempt,
104
+ });
105
+ return recovery.message;
106
+ }
107
+ return null;
108
+ },
109
+ /**
110
+ * Notification - Check for error notifications
111
+ * (Called when errors are passed through notification system)
112
+ */
113
+ onError: (input) => {
114
+ const parsed = parseTokenLimitError(input.error);
115
+ if (!parsed) {
116
+ return {
117
+ attempted: false,
118
+ success: false,
119
+ };
120
+ }
121
+ debugLog('error notification contains token limit error', {
122
+ sessionId: input.session_id,
123
+ parsed,
124
+ });
125
+ const state = getSessionState(input.session_id);
126
+ state.lastErrorTime = Date.now();
127
+ state.errorCount++;
128
+ const recovery = generateRecoveryMessage(parsed, state, config);
129
+ return {
130
+ attempted: true,
131
+ success: !!recovery.message,
132
+ message: recovery.message,
133
+ errorType: recovery.errorType,
134
+ };
135
+ },
136
+ };
137
+ }
138
+ /**
139
+ * Generate appropriate recovery message based on error and state
140
+ */
141
+ function generateRecoveryMessage(parsed, state, config) {
142
+ // Use custom message if provided
143
+ if (config?.customMessage) {
144
+ return {
145
+ message: config.customMessage,
146
+ errorType: parsed?.errorType,
147
+ };
148
+ }
149
+ // Handle non-empty content error
150
+ if (parsed?.errorType?.includes('non-empty content')) {
151
+ return {
152
+ message: NON_EMPTY_CONTENT_RECOVERY_MESSAGE,
153
+ errorType: 'non-empty content',
154
+ };
155
+ }
156
+ // Check retry limits
157
+ state.retryState.attempt++;
158
+ state.retryState.lastAttemptTime = Date.now();
159
+ if (state.retryState.attempt > RETRY_CONFIG.maxAttempts) {
160
+ return {
161
+ message: RECOVERY_FAILED_MESSAGE,
162
+ errorType: 'recovery_exhausted',
163
+ };
164
+ }
165
+ // Return detailed or short message based on config
166
+ if (config?.detailed !== false) {
167
+ let message = CONTEXT_LIMIT_RECOVERY_MESSAGE;
168
+ // Add token info if available
169
+ if (parsed?.currentTokens && parsed?.maxTokens) {
170
+ message += `\nToken Details:
171
+ - Current: ${parsed.currentTokens.toLocaleString()} tokens
172
+ - Maximum: ${parsed.maxTokens.toLocaleString()} tokens
173
+ - Over limit by: ${(parsed.currentTokens - parsed.maxTokens).toLocaleString()} tokens
174
+ `;
175
+ }
176
+ return {
177
+ message,
178
+ errorType: parsed?.errorType || 'token_limit_exceeded',
179
+ };
180
+ }
181
+ return {
182
+ message: CONTEXT_LIMIT_SHORT_MESSAGE,
183
+ errorType: parsed?.errorType || 'token_limit_exceeded',
184
+ };
185
+ }
186
+ /**
187
+ * Check if text contains a context limit error
188
+ */
189
+ export function detectContextLimitError(text) {
190
+ return containsTokenLimitError(text);
191
+ }
192
+ /**
193
+ * Parse error to get detailed token limit info
194
+ */
195
+ export function parseContextLimitError(error) {
196
+ return parseTokenLimitError(error);
197
+ }
198
+ export { RETRY_CONFIG, TRUNCATE_CONFIG } from './types.js';
199
+ export { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, TRUNCATION_APPLIED_MESSAGE, RECOVERY_FAILED_MESSAGE, } from './constants.js';
200
+ export { parseTokenLimitError, containsTokenLimitError, TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, } from './parser.js';
201
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAC;AAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,kCAAkC,CAAC,CAAC;AAE3E,SAAS,QAAQ,CAAC,GAAG,IAAe;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,GAAG,GAAG,IAAI,IAAI,IAAI,EAAE,C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OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAUD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Context Window Limit Error Parser
3
+ *
4
+ * Parses error responses to detect token/context limit errors.
5
+ *
6
+ * Adapted from oh-my-opencode's anthropic-context-window-limit-recovery hook.
7
+ */
8
+ import type { ParsedTokenLimitError } from './types.js';
9
+ /**
10
+ * Patterns to extract token counts from error messages
11
+ */
12
+ declare const TOKEN_LIMIT_PATTERNS: RegExp[];
13
+ /**
14
+ * Keywords indicating token limit errors
15
+ */
16
+ declare const TOKEN_LIMIT_KEYWORDS: string[];
17
+ /**
18
+ * Patterns indicating thinking block structure errors (NOT token limit)
19
+ * These should be handled differently
20
+ */
21
+ declare const THINKING_BLOCK_ERROR_PATTERNS: RegExp[];
22
+ /**
23
+ * Parse an error to detect if it's a token limit error
24
+ */
25
+ export declare function parseTokenLimitError(err: unknown): ParsedTokenLimitError | null;
26
+ /**
27
+ * Check if a string contains a token limit error indication
28
+ */
29
+ export declare function containsTokenLimitError(text: string): boolean;
30
+ export { TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, THINKING_BLOCK_ERROR_PATTERNS, };
31
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/hooks/context-window-limit-recovery/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;GAEG;AACH,QAAA,MAAM,oBAAoB,UAMzB,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,oBAAoB,UASzB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,6BAA6B,UAOlC,CAAC;AAuDF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,GACX,qBAAqB,GAAG,IAAI,CA8J9B;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAGD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,6BAA6B,GAC9B,CAAC"}