task-o-matic-core 0.1.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 (447) hide show
  1. package/README.md +646 -0
  2. package/dist/index.d.ts +27 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +46 -0
  5. package/dist/lib/ai-service/ai-operations.d.ts +45 -0
  6. package/dist/lib/ai-service/ai-operations.d.ts.map +1 -0
  7. package/dist/lib/ai-service/ai-operations.js +60 -0
  8. package/dist/lib/ai-service/base-operations.d.ts +43 -0
  9. package/dist/lib/ai-service/base-operations.d.ts.map +1 -0
  10. package/dist/lib/ai-service/base-operations.js +119 -0
  11. package/dist/lib/ai-service/documentation-operations.d.ts +18 -0
  12. package/dist/lib/ai-service/documentation-operations.d.ts.map +1 -0
  13. package/dist/lib/ai-service/documentation-operations.js +308 -0
  14. package/dist/lib/ai-service/filesystem-tools.d.ts +69 -0
  15. package/dist/lib/ai-service/filesystem-tools.d.ts.map +1 -0
  16. package/dist/lib/ai-service/filesystem-tools.js +70 -0
  17. package/dist/lib/ai-service/json-parser.d.ts +34 -0
  18. package/dist/lib/ai-service/json-parser.d.ts.map +1 -0
  19. package/dist/lib/ai-service/json-parser.js +177 -0
  20. package/dist/lib/ai-service/mcp-client.d.ts +9 -0
  21. package/dist/lib/ai-service/mcp-client.d.ts.map +1 -0
  22. package/dist/lib/ai-service/mcp-client.js +48 -0
  23. package/dist/lib/ai-service/model-provider.d.ts +12 -0
  24. package/dist/lib/ai-service/model-provider.d.ts.map +1 -0
  25. package/dist/lib/ai-service/model-provider.js +146 -0
  26. package/dist/lib/ai-service/prd-operations.d.ts +25 -0
  27. package/dist/lib/ai-service/prd-operations.d.ts.map +1 -0
  28. package/dist/lib/ai-service/prd-operations.js +592 -0
  29. package/dist/lib/ai-service/research-tools.d.ts +4 -0
  30. package/dist/lib/ai-service/research-tools.d.ts.map +1 -0
  31. package/dist/lib/ai-service/research-tools.js +8 -0
  32. package/dist/lib/ai-service/retry-handler.d.ts +8 -0
  33. package/dist/lib/ai-service/retry-handler.d.ts.map +1 -0
  34. package/dist/lib/ai-service/retry-handler.js +63 -0
  35. package/dist/lib/ai-service/task-operations.d.ts +13 -0
  36. package/dist/lib/ai-service/task-operations.d.ts.map +1 -0
  37. package/dist/lib/ai-service/task-operations.js +220 -0
  38. package/dist/lib/benchmark/registry.d.ts +11 -0
  39. package/dist/lib/benchmark/registry.d.ts.map +1 -0
  40. package/dist/lib/benchmark/registry.js +212 -0
  41. package/dist/lib/benchmark/runner.d.ts +6 -0
  42. package/dist/lib/benchmark/runner.d.ts.map +1 -0
  43. package/dist/lib/benchmark/runner.js +150 -0
  44. package/dist/lib/benchmark/storage.d.ts +13 -0
  45. package/dist/lib/benchmark/storage.d.ts.map +1 -0
  46. package/dist/lib/benchmark/storage.js +100 -0
  47. package/dist/lib/benchmark/types.d.ts +104 -0
  48. package/dist/lib/benchmark/types.d.ts.map +1 -0
  49. package/dist/lib/benchmark/types.js +2 -0
  50. package/dist/lib/better-t-stack-cli.d.ts +50 -0
  51. package/dist/lib/better-t-stack-cli.d.ts.map +1 -0
  52. package/dist/lib/better-t-stack-cli.js +428 -0
  53. package/dist/lib/bootstrap/cli-bootstrap.d.ts +14 -0
  54. package/dist/lib/bootstrap/cli-bootstrap.d.ts.map +1 -0
  55. package/dist/lib/bootstrap/cli-bootstrap.js +322 -0
  56. package/dist/lib/bootstrap/index.d.ts +3 -0
  57. package/dist/lib/bootstrap/index.d.ts.map +1 -0
  58. package/dist/lib/bootstrap/index.js +18 -0
  59. package/dist/lib/bootstrap/medusa-bootstrap.d.ts +14 -0
  60. package/dist/lib/bootstrap/medusa-bootstrap.d.ts.map +1 -0
  61. package/dist/lib/bootstrap/medusa-bootstrap.js +215 -0
  62. package/dist/lib/config-validation.d.ts +215 -0
  63. package/dist/lib/config-validation.d.ts.map +1 -0
  64. package/dist/lib/config-validation.js +254 -0
  65. package/dist/lib/config.d.ts +55 -0
  66. package/dist/lib/config.d.ts.map +1 -0
  67. package/dist/lib/config.js +351 -0
  68. package/dist/lib/context-builder.d.ts +66 -0
  69. package/dist/lib/context-builder.d.ts.map +1 -0
  70. package/dist/lib/context-builder.js +322 -0
  71. package/dist/lib/executors/claude-code-executor.d.ts +9 -0
  72. package/dist/lib/executors/claude-code-executor.d.ts.map +1 -0
  73. package/dist/lib/executors/claude-code-executor.js +69 -0
  74. package/dist/lib/executors/codex-executor.d.ts +9 -0
  75. package/dist/lib/executors/codex-executor.d.ts.map +1 -0
  76. package/dist/lib/executors/codex-executor.js +73 -0
  77. package/dist/lib/executors/executor-factory.d.ts +5 -0
  78. package/dist/lib/executors/executor-factory.d.ts.map +1 -0
  79. package/dist/lib/executors/executor-factory.js +27 -0
  80. package/dist/lib/executors/gemini-executor.d.ts +9 -0
  81. package/dist/lib/executors/gemini-executor.d.ts.map +1 -0
  82. package/dist/lib/executors/gemini-executor.js +67 -0
  83. package/dist/lib/executors/kilo-executor.d.ts +9 -0
  84. package/dist/lib/executors/kilo-executor.d.ts.map +1 -0
  85. package/dist/lib/executors/kilo-executor.js +69 -0
  86. package/dist/lib/executors/opencode-executor.d.ts +9 -0
  87. package/dist/lib/executors/opencode-executor.d.ts.map +1 -0
  88. package/dist/lib/executors/opencode-executor.js +67 -0
  89. package/dist/lib/git-utils.d.ts +88 -0
  90. package/dist/lib/git-utils.d.ts.map +1 -0
  91. package/dist/lib/git-utils.js +242 -0
  92. package/dist/lib/hooks.d.ts +73 -0
  93. package/dist/lib/hooks.d.ts.map +1 -0
  94. package/dist/lib/hooks.js +62 -0
  95. package/dist/lib/index.d.ts +100 -0
  96. package/dist/lib/index.d.ts.map +1 -0
  97. package/dist/lib/index.js +143 -0
  98. package/dist/lib/logger.d.ts +20 -0
  99. package/dist/lib/logger.d.ts.map +1 -0
  100. package/dist/lib/logger.js +32 -0
  101. package/dist/lib/notifications.d.ts +7 -0
  102. package/dist/lib/notifications.d.ts.map +1 -0
  103. package/dist/lib/notifications.js +81 -0
  104. package/dist/lib/prompt-builder.d.ts +70 -0
  105. package/dist/lib/prompt-builder.d.ts.map +1 -0
  106. package/dist/lib/prompt-builder.js +344 -0
  107. package/dist/lib/prompt-registry.d.ts +22 -0
  108. package/dist/lib/prompt-registry.d.ts.map +1 -0
  109. package/dist/lib/prompt-registry.js +409 -0
  110. package/dist/lib/provider-defaults.json +32 -0
  111. package/dist/lib/storage/file-system.d.ts +57 -0
  112. package/dist/lib/storage/file-system.d.ts.map +1 -0
  113. package/dist/lib/storage/file-system.js +638 -0
  114. package/dist/lib/storage/storage-callbacks.d.ts +17 -0
  115. package/dist/lib/storage/storage-callbacks.d.ts.map +1 -0
  116. package/dist/lib/storage/storage-callbacks.js +94 -0
  117. package/dist/lib/storage/types.d.ts +43 -0
  118. package/dist/lib/storage/types.d.ts.map +1 -0
  119. package/dist/lib/storage/types.js +2 -0
  120. package/dist/lib/task-execution-core.d.ts +7 -0
  121. package/dist/lib/task-execution-core.d.ts.map +1 -0
  122. package/dist/lib/task-execution-core.js +381 -0
  123. package/dist/lib/task-execution.d.ts +7 -0
  124. package/dist/lib/task-execution.d.ts.map +1 -0
  125. package/dist/lib/task-execution.js +40 -0
  126. package/dist/lib/task-loop-execution.d.ts +7 -0
  127. package/dist/lib/task-loop-execution.d.ts.map +1 -0
  128. package/dist/lib/task-loop-execution.js +156 -0
  129. package/dist/lib/task-planning.d.ts +29 -0
  130. package/dist/lib/task-planning.d.ts.map +1 -0
  131. package/dist/lib/task-planning.js +103 -0
  132. package/dist/lib/task-review.d.ts +27 -0
  133. package/dist/lib/task-review.d.ts.map +1 -0
  134. package/dist/lib/task-review.js +103 -0
  135. package/dist/lib/validation.d.ts +26 -0
  136. package/dist/lib/validation.d.ts.map +1 -0
  137. package/dist/lib/validation.js +98 -0
  138. package/dist/prompts/documentation-detection.d.ts +2 -0
  139. package/dist/prompts/documentation-detection.d.ts.map +1 -0
  140. package/dist/prompts/documentation-detection.js +24 -0
  141. package/dist/prompts/documentation-recap.d.ts +3 -0
  142. package/dist/prompts/documentation-recap.d.ts.map +1 -0
  143. package/dist/prompts/documentation-recap.js +13 -0
  144. package/dist/prompts/index.d.ts +15 -0
  145. package/dist/prompts/index.d.ts.map +1 -0
  146. package/dist/prompts/index.js +30 -0
  147. package/dist/prompts/prd-combination.d.ts +2 -0
  148. package/dist/prompts/prd-combination.d.ts.map +1 -0
  149. package/dist/prompts/prd-combination.js +35 -0
  150. package/dist/prompts/prd-generation.d.ts +2 -0
  151. package/dist/prompts/prd-generation.d.ts.map +1 -0
  152. package/dist/prompts/prd-generation.js +49 -0
  153. package/dist/prompts/prd-parsing.d.ts +3 -0
  154. package/dist/prompts/prd-parsing.d.ts.map +1 -0
  155. package/dist/prompts/prd-parsing.js +172 -0
  156. package/dist/prompts/prd-question-answer.d.ts +3 -0
  157. package/dist/prompts/prd-question-answer.d.ts.map +1 -0
  158. package/dist/prompts/prd-question-answer.js +27 -0
  159. package/dist/prompts/prd-question.d.ts +3 -0
  160. package/dist/prompts/prd-question.d.ts.map +1 -0
  161. package/dist/prompts/prd-question.js +40 -0
  162. package/dist/prompts/prd-rework.d.ts +3 -0
  163. package/dist/prompts/prd-rework.d.ts.map +1 -0
  164. package/dist/prompts/prd-rework.js +81 -0
  165. package/dist/prompts/prd-suggest-stack.d.ts +3 -0
  166. package/dist/prompts/prd-suggest-stack.d.ts.map +1 -0
  167. package/dist/prompts/prd-suggest-stack.js +99 -0
  168. package/dist/prompts/task-breakdown.d.ts +3 -0
  169. package/dist/prompts/task-breakdown.d.ts.map +1 -0
  170. package/dist/prompts/task-breakdown.js +151 -0
  171. package/dist/prompts/task-enhancement.d.ts +3 -0
  172. package/dist/prompts/task-enhancement.d.ts.map +1 -0
  173. package/dist/prompts/task-enhancement.js +140 -0
  174. package/dist/prompts/task-execution.d.ts +3 -0
  175. package/dist/prompts/task-execution.d.ts.map +1 -0
  176. package/dist/prompts/task-execution.js +24 -0
  177. package/dist/prompts/task-planning.d.ts +3 -0
  178. package/dist/prompts/task-planning.d.ts.map +1 -0
  179. package/dist/prompts/task-planning.js +66 -0
  180. package/dist/prompts/workflow-assistance.d.ts +32 -0
  181. package/dist/prompts/workflow-assistance.d.ts.map +1 -0
  182. package/dist/prompts/workflow-assistance.js +130 -0
  183. package/dist/prompts/workflow-prompts.d.ts +9 -0
  184. package/dist/prompts/workflow-prompts.d.ts.map +1 -0
  185. package/dist/prompts/workflow-prompts.js +93 -0
  186. package/dist/services/benchmark.d.ts +26 -0
  187. package/dist/services/benchmark.d.ts.map +1 -0
  188. package/dist/services/benchmark.js +343 -0
  189. package/dist/services/prd.d.ts +136 -0
  190. package/dist/services/prd.d.ts.map +1 -0
  191. package/dist/services/prd.js +550 -0
  192. package/dist/services/tasks.d.ts +388 -0
  193. package/dist/services/tasks.d.ts.map +1 -0
  194. package/dist/services/tasks.js +1150 -0
  195. package/dist/services/workflow-ai-assistant.d.ts +74 -0
  196. package/dist/services/workflow-ai-assistant.d.ts.map +1 -0
  197. package/dist/services/workflow-ai-assistant.js +175 -0
  198. package/dist/services/workflow-benchmark.d.ts +34 -0
  199. package/dist/services/workflow-benchmark.d.ts.map +1 -0
  200. package/dist/services/workflow-benchmark.js +318 -0
  201. package/dist/services/workflow.d.ts +107 -0
  202. package/dist/services/workflow.d.ts.map +1 -0
  203. package/dist/services/workflow.js +580 -0
  204. package/dist/test/hooks.test.d.ts +2 -0
  205. package/dist/test/hooks.test.d.ts.map +1 -0
  206. package/dist/test/hooks.test.js +67 -0
  207. package/dist/test/integration/callbacks.test.d.ts +2 -0
  208. package/dist/test/integration/callbacks.test.d.ts.map +1 -0
  209. package/dist/test/integration/callbacks.test.js +64 -0
  210. package/dist/test/lib/ai-service/task-operations.test.d.ts +2 -0
  211. package/dist/test/lib/ai-service/task-operations.test.d.ts.map +1 -0
  212. package/dist/test/lib/ai-service/task-operations.test.js +362 -0
  213. package/dist/test/lib/config.test.d.ts +2 -0
  214. package/dist/test/lib/config.test.d.ts.map +1 -0
  215. package/dist/test/lib/config.test.js +128 -0
  216. package/dist/test/lib/git-utils.test.d.ts +2 -0
  217. package/dist/test/lib/git-utils.test.d.ts.map +1 -0
  218. package/dist/test/lib/git-utils.test.js +168 -0
  219. package/dist/test/mocks/mock-ai-operations.d.ts +15 -0
  220. package/dist/test/mocks/mock-ai-operations.d.ts.map +1 -0
  221. package/dist/test/mocks/mock-ai-operations.js +107 -0
  222. package/dist/test/mocks/mock-context-builder.d.ts +10 -0
  223. package/dist/test/mocks/mock-context-builder.d.ts.map +1 -0
  224. package/dist/test/mocks/mock-context-builder.js +81 -0
  225. package/dist/test/mocks/mock-model-provider.d.ts +7 -0
  226. package/dist/test/mocks/mock-model-provider.d.ts.map +1 -0
  227. package/dist/test/mocks/mock-model-provider.js +21 -0
  228. package/dist/test/mocks/mock-service-factory.d.ts +11 -0
  229. package/dist/test/mocks/mock-service-factory.d.ts.map +1 -0
  230. package/dist/test/mocks/mock-service-factory.js +61 -0
  231. package/dist/test/mocks/mock-storage.d.ts +50 -0
  232. package/dist/test/mocks/mock-storage.d.ts.map +1 -0
  233. package/dist/test/mocks/mock-storage.js +145 -0
  234. package/dist/test/model-parsing.test.d.ts +2 -0
  235. package/dist/test/model-parsing.test.d.ts.map +1 -0
  236. package/dist/test/model-parsing.test.js +73 -0
  237. package/dist/test/services/task-service.test.d.ts +2 -0
  238. package/dist/test/services/task-service.test.d.ts.map +1 -0
  239. package/dist/test/services/task-service.test.js +459 -0
  240. package/dist/test/storage.test.d.ts +2 -0
  241. package/dist/test/storage.test.d.ts.map +1 -0
  242. package/dist/test/storage.test.js +207 -0
  243. package/dist/test/task-loop-git.test.d.ts +2 -0
  244. package/dist/test/task-loop-git.test.d.ts.map +1 -0
  245. package/dist/test/task-loop-git.test.js +95 -0
  246. package/dist/test/test-mock-setup.d.ts +26 -0
  247. package/dist/test/test-mock-setup.d.ts.map +1 -0
  248. package/dist/test/test-mock-setup.js +41 -0
  249. package/dist/test/test-setup.d.ts +9 -0
  250. package/dist/test/test-setup.d.ts.map +1 -0
  251. package/dist/test/test-setup.js +44 -0
  252. package/dist/test/test-utils.d.ts +22 -0
  253. package/dist/test/test-utils.d.ts.map +1 -0
  254. package/dist/test/test-utils.js +37 -0
  255. package/dist/test/utils/ai-operation-utility.test.d.ts +2 -0
  256. package/dist/test/utils/ai-operation-utility.test.d.ts.map +1 -0
  257. package/dist/test/utils/ai-operation-utility.test.js +290 -0
  258. package/dist/test/utils/error-handling.test.d.ts +2 -0
  259. package/dist/test/utils/error-handling.test.d.ts.map +1 -0
  260. package/dist/test/utils/error-handling.test.js +231 -0
  261. package/dist/test/utils/file-utils.test.d.ts +2 -0
  262. package/dist/test/utils/file-utils.test.d.ts.map +1 -0
  263. package/dist/test/utils/file-utils.test.js +76 -0
  264. package/dist/test/utils/id-generator.test.d.ts +2 -0
  265. package/dist/test/utils/id-generator.test.d.ts.map +1 -0
  266. package/dist/test/utils/id-generator.test.js +41 -0
  267. package/dist/test/utils/model-parser.test.d.ts +2 -0
  268. package/dist/test/utils/model-parser.test.d.ts.map +1 -0
  269. package/dist/test/utils/model-parser.test.js +65 -0
  270. package/dist/test/validation.test.d.ts +2 -0
  271. package/dist/test/validation.test.d.ts.map +1 -0
  272. package/dist/test/validation.test.js +22 -0
  273. package/dist/types/callbacks.d.ts +30 -0
  274. package/dist/types/callbacks.d.ts.map +1 -0
  275. package/dist/types/callbacks.js +2 -0
  276. package/dist/types/index.d.ts +435 -0
  277. package/dist/types/index.d.ts.map +1 -0
  278. package/dist/types/index.js +30 -0
  279. package/dist/types/mcp.d.ts +3 -0
  280. package/dist/types/mcp.d.ts.map +1 -0
  281. package/dist/types/mcp.js +3 -0
  282. package/dist/types/options.d.ts +112 -0
  283. package/dist/types/options.d.ts.map +1 -0
  284. package/dist/types/options.js +2 -0
  285. package/dist/types/results.d.ts +200 -0
  286. package/dist/types/results.d.ts.map +1 -0
  287. package/dist/types/results.js +2 -0
  288. package/dist/types/workflow-options.d.ts +82 -0
  289. package/dist/types/workflow-options.d.ts.map +1 -0
  290. package/dist/types/workflow-options.js +2 -0
  291. package/dist/types/workflow-results.d.ts +82 -0
  292. package/dist/types/workflow-results.d.ts.map +1 -0
  293. package/dist/types/workflow-results.js +2 -0
  294. package/dist/utils/ai-config-builder.d.ts +14 -0
  295. package/dist/utils/ai-config-builder.d.ts.map +1 -0
  296. package/dist/utils/ai-config-builder.js +22 -0
  297. package/dist/utils/ai-operation-utility.d.ts +142 -0
  298. package/dist/utils/ai-operation-utility.d.ts.map +1 -0
  299. package/dist/utils/ai-operation-utility.js +303 -0
  300. package/dist/utils/ai-service-factory.d.ts +34 -0
  301. package/dist/utils/ai-service-factory.d.ts.map +1 -0
  302. package/dist/utils/ai-service-factory.js +99 -0
  303. package/dist/utils/error-utils.d.ts +70 -0
  304. package/dist/utils/error-utils.d.ts.map +1 -0
  305. package/dist/utils/error-utils.js +104 -0
  306. package/dist/utils/file-utils.d.ts +107 -0
  307. package/dist/utils/file-utils.d.ts.map +1 -0
  308. package/dist/utils/file-utils.js +171 -0
  309. package/dist/utils/id-generator.d.ts +92 -0
  310. package/dist/utils/id-generator.d.ts.map +1 -0
  311. package/dist/utils/id-generator.js +146 -0
  312. package/dist/utils/metadata-utils.d.ts +40 -0
  313. package/dist/utils/metadata-utils.d.ts.map +1 -0
  314. package/dist/utils/metadata-utils.js +43 -0
  315. package/dist/utils/model-executor-parser.d.ts +38 -0
  316. package/dist/utils/model-executor-parser.d.ts.map +1 -0
  317. package/dist/utils/model-executor-parser.js +69 -0
  318. package/dist/utils/model-parser.d.ts +6 -0
  319. package/dist/utils/model-parser.d.ts.map +1 -0
  320. package/dist/utils/model-parser.js +49 -0
  321. package/dist/utils/stack-formatter.d.ts +12 -0
  322. package/dist/utils/stack-formatter.d.ts.map +1 -0
  323. package/dist/utils/stack-formatter.js +36 -0
  324. package/dist/utils/storage-utils.d.ts +49 -0
  325. package/dist/utils/storage-utils.d.ts.map +1 -0
  326. package/dist/utils/storage-utils.js +80 -0
  327. package/dist/utils/streaming-utils.d.ts +38 -0
  328. package/dist/utils/streaming-utils.d.ts.map +1 -0
  329. package/dist/utils/streaming-utils.js +64 -0
  330. package/dist/utils/task-o-matic-error.d.ts +206 -0
  331. package/dist/utils/task-o-matic-error.d.ts.map +1 -0
  332. package/dist/utils/task-o-matic-error.js +304 -0
  333. package/package.json +40 -0
  334. package/src/index.ts +36 -0
  335. package/src/lib/ai-service/ai-operations.ts +310 -0
  336. package/src/lib/ai-service/base-operations.ts +139 -0
  337. package/src/lib/ai-service/documentation-operations.ts +438 -0
  338. package/src/lib/ai-service/filesystem-tools.ts +73 -0
  339. package/src/lib/ai-service/gemini-proxy.ts.bak +52 -0
  340. package/src/lib/ai-service/json-parser.ts +203 -0
  341. package/src/lib/ai-service/mcp-client.ts +54 -0
  342. package/src/lib/ai-service/model-provider.ts +192 -0
  343. package/src/lib/ai-service/prd-operations.ts +854 -0
  344. package/src/lib/ai-service/research-tools.ts +207 -0
  345. package/src/lib/ai-service/retry-handler.ts +89 -0
  346. package/src/lib/ai-service/task-operations.ts +342 -0
  347. package/src/lib/benchmark/registry.ts +307 -0
  348. package/src/lib/benchmark/runner.ts +190 -0
  349. package/src/lib/benchmark/storage.ts +140 -0
  350. package/src/lib/benchmark/types.ts +121 -0
  351. package/src/lib/better-t-stack-cli.ts +524 -0
  352. package/src/lib/bootstrap/cli-bootstrap.ts +397 -0
  353. package/src/lib/bootstrap/index.ts +2 -0
  354. package/src/lib/bootstrap/medusa-bootstrap.ts +261 -0
  355. package/src/lib/config-validation.ts +278 -0
  356. package/src/lib/config.ts +435 -0
  357. package/src/lib/context-builder.ts +383 -0
  358. package/src/lib/executors/claude-code-executor.ts +83 -0
  359. package/src/lib/executors/codex-executor.ts +85 -0
  360. package/src/lib/executors/executor-factory.ts +28 -0
  361. package/src/lib/executors/gemini-executor.ts +80 -0
  362. package/src/lib/executors/kilo-executor.ts +83 -0
  363. package/src/lib/executors/opencode-executor.ts +81 -0
  364. package/src/lib/git-utils.ts +334 -0
  365. package/src/lib/hooks.ts +121 -0
  366. package/src/lib/index.ts +166 -0
  367. package/src/lib/logger.ts +43 -0
  368. package/src/lib/notifications.ts +103 -0
  369. package/src/lib/prompt-builder.ts +471 -0
  370. package/src/lib/prompt-registry.ts +491 -0
  371. package/src/lib/provider-defaults.json +32 -0
  372. package/src/lib/storage/file-system.ts +864 -0
  373. package/src/lib/storage/storage-callbacks.ts +120 -0
  374. package/src/lib/storage/types.ts +58 -0
  375. package/src/lib/task-execution-core.ts +591 -0
  376. package/src/lib/task-execution.ts +59 -0
  377. package/src/lib/task-loop-execution.ts +214 -0
  378. package/src/lib/task-planning.ts +157 -0
  379. package/src/lib/task-review.ts +138 -0
  380. package/src/lib/validation.ts +140 -0
  381. package/src/prompts/documentation-detection.ts +21 -0
  382. package/src/prompts/documentation-recap.ts +11 -0
  383. package/src/prompts/index.ts +14 -0
  384. package/src/prompts/prd-combination.ts +32 -0
  385. package/src/prompts/prd-generation.ts +46 -0
  386. package/src/prompts/prd-parsing.ts +170 -0
  387. package/src/prompts/prd-question-answer.ts +25 -0
  388. package/src/prompts/prd-question.ts +38 -0
  389. package/src/prompts/prd-rework.ts +79 -0
  390. package/src/prompts/prd-suggest-stack.ts +97 -0
  391. package/src/prompts/task-breakdown.ts +149 -0
  392. package/src/prompts/task-enhancement.ts +138 -0
  393. package/src/prompts/task-execution.ts +22 -0
  394. package/src/prompts/task-planning.ts +64 -0
  395. package/src/prompts/workflow-assistance.ts +151 -0
  396. package/src/prompts/workflow-prompts.ts +97 -0
  397. package/src/services/benchmark.ts +433 -0
  398. package/src/services/prd.ts +845 -0
  399. package/src/services/tasks.ts +1515 -0
  400. package/src/services/workflow-ai-assistant.ts +298 -0
  401. package/src/services/workflow-benchmark.ts +339 -0
  402. package/src/services/workflow.ts +779 -0
  403. package/src/test/hooks.test.ts +77 -0
  404. package/src/test/integration/callbacks.test.ts +39 -0
  405. package/src/test/lib/ai-service/task-operations.test.ts +430 -0
  406. package/src/test/lib/config.test.ts +150 -0
  407. package/src/test/lib/git-utils.test.ts +198 -0
  408. package/src/test/mocks/mock-ai-operations.ts +205 -0
  409. package/src/test/mocks/mock-context-builder.ts +84 -0
  410. package/src/test/mocks/mock-model-provider.ts +21 -0
  411. package/src/test/mocks/mock-service-factory.ts +64 -0
  412. package/src/test/mocks/mock-storage.ts +204 -0
  413. package/src/test/model-parsing.test.ts +78 -0
  414. package/src/test/services/task-service.test.ts +551 -0
  415. package/src/test/storage.test.ts +206 -0
  416. package/src/test/task-loop-git.test.ts +142 -0
  417. package/src/test/test-mock-setup.ts +46 -0
  418. package/src/test/test-setup.ts +48 -0
  419. package/src/test/test-utils.ts +45 -0
  420. package/src/test/utils/ai-operation-utility.test.ts +306 -0
  421. package/src/test/utils/error-handling.test.ts +241 -0
  422. package/src/test/utils/file-utils.test.ts +80 -0
  423. package/src/test/utils/id-generator.test.ts +44 -0
  424. package/src/test/utils/model-parser.test.ts +67 -0
  425. package/src/test/validation.test.ts +19 -0
  426. package/src/types/callbacks.ts +14 -0
  427. package/src/types/index.ts +628 -0
  428. package/src/types/mcp.ts +5 -0
  429. package/src/types/options.ts +165 -0
  430. package/src/types/results.ts +216 -0
  431. package/src/types/workflow-options.ts +113 -0
  432. package/src/types/workflow-results.ts +87 -0
  433. package/src/utils/ai-config-builder.ts +33 -0
  434. package/src/utils/ai-operation-utility.ts +380 -0
  435. package/src/utils/ai-service-factory.ts +125 -0
  436. package/src/utils/error-utils.ts +124 -0
  437. package/src/utils/file-utils.ts +197 -0
  438. package/src/utils/id-generator.ts +168 -0
  439. package/src/utils/metadata-utils.ts +48 -0
  440. package/src/utils/model-executor-parser.ts +80 -0
  441. package/src/utils/model-parser.ts +58 -0
  442. package/src/utils/stack-formatter.ts +53 -0
  443. package/src/utils/storage-utils.ts +94 -0
  444. package/src/utils/streaming-utils.ts +91 -0
  445. package/src/utils/task-o-matic-error.ts +393 -0
  446. package/tsconfig.json +20 -0
  447. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,307 @@
1
+ import { BenchmarkableOperation, WorkflowBenchmarkInput } from "./types";
2
+ import { prdService } from "../../services/prd";
3
+ import { taskService } from "../../services/tasks";
4
+ import { workflowBenchmarkService } from "../../services/workflow-benchmark";
5
+ import { AIOptions } from "../../utils/ai-config-builder";
6
+ import { StreamingOptions } from "../../types";
7
+
8
+ export class BenchmarkRegistry {
9
+ private operations: Map<string, BenchmarkableOperation> = new Map();
10
+
11
+ constructor() {
12
+ this.registerDefaults();
13
+ }
14
+
15
+ register(op: BenchmarkableOperation) {
16
+ this.operations.set(op.id, op);
17
+ }
18
+
19
+ get(id: string): BenchmarkableOperation | undefined {
20
+ return this.operations.get(id);
21
+ }
22
+
23
+ list(): BenchmarkableOperation[] {
24
+ return Array.from(this.operations.values());
25
+ }
26
+
27
+ private registerDefaults() {
28
+ // PRD Parsing Adapter
29
+ this.register({
30
+ id: "prd-parse",
31
+ name: "PRD Parsing",
32
+ description: "Parse a PRD file into tasks",
33
+ validateInput: (input: any) =>
34
+ typeof input.file === "string" && input.file.length > 0,
35
+ execute: async (
36
+ input: any,
37
+ aiOptions: AIOptions,
38
+ streamingOptions?: StreamingOptions
39
+ ) => {
40
+ return await prdService.parsePRD({
41
+ file: input.file,
42
+ workingDirectory: input.workingDirectory,
43
+ enableFilesystemTools: input.tools,
44
+ promptOverride: input.prompt,
45
+ messageOverride: input.message,
46
+ aiOptions,
47
+ streamingOptions,
48
+ callbacks: {},
49
+ });
50
+ },
51
+ });
52
+
53
+ // PRD Rework Adapter
54
+ this.register({
55
+ id: "prd-rework",
56
+ name: "PRD Rework",
57
+ description: "Rework a PRD based on feedback",
58
+ validateInput: (input: any) =>
59
+ typeof input.file === "string" && typeof input.feedback === "string",
60
+ execute: async (
61
+ input: any,
62
+ aiOptions: AIOptions,
63
+ streamingOptions?: StreamingOptions
64
+ ) => {
65
+ return await prdService.reworkPRD({
66
+ file: input.file,
67
+ feedback: input.feedback,
68
+ workingDirectory: input.workingDirectory,
69
+ enableFilesystemTools: input.tools,
70
+ promptOverride: input.prompt,
71
+ messageOverride: input.message,
72
+ aiOptions,
73
+ streamingOptions,
74
+ callbacks: {},
75
+ });
76
+ },
77
+ });
78
+
79
+ // Task Breakdown Adapter
80
+ this.register({
81
+ id: "task-breakdown",
82
+ name: "Task Breakdown",
83
+ description: "Break down a task into subtasks",
84
+ validateInput: (input: any) => typeof input.taskId === "string",
85
+ execute: async (
86
+ input: any,
87
+ aiOptions: AIOptions,
88
+ streamingOptions?: StreamingOptions
89
+ ) => {
90
+ return await taskService.splitTask(
91
+ input.taskId,
92
+ aiOptions,
93
+ input.prompt,
94
+ input.message,
95
+ streamingOptions, // streaming options
96
+ input.tools
97
+ );
98
+ },
99
+ });
100
+
101
+ // Workflow Full Execution
102
+ this.register({
103
+ id: "workflow-full",
104
+ name: "Complete Workflow",
105
+ description: "Execute the complete workflow: initialization, PRD creation, task generation, and splitting",
106
+ validateInput: (input: any) => workflowBenchmarkService.validateInput(input),
107
+ execute: async (
108
+ input: WorkflowBenchmarkInput,
109
+ aiOptions: AIOptions,
110
+ streamingOptions?: StreamingOptions
111
+ ) => {
112
+ return await workflowBenchmarkService.executeWorkflow(
113
+ input,
114
+ aiOptions,
115
+ streamingOptions
116
+ );
117
+ },
118
+ });
119
+
120
+ // Task Create with AI Enhancement
121
+ this.register({
122
+ id: "task-create",
123
+ name: "Task Creation (AI-Enhanced)",
124
+ description: "Create a new task with AI enhancement using Context7 documentation",
125
+ validateInput: (input: any) =>
126
+ typeof input.title === "string" && input.title.length > 0,
127
+ execute: async (
128
+ input: any,
129
+ aiOptions: AIOptions,
130
+ streamingOptions?: StreamingOptions
131
+ ) => {
132
+ return await taskService.createTask({
133
+ title: input.title,
134
+ content: input.content,
135
+ parentId: input.parentId,
136
+ effort: input.effort,
137
+ aiEnhance: true, // Always use AI enhancement for benchmarking
138
+ aiOptions,
139
+ streamingOptions,
140
+ });
141
+ },
142
+ });
143
+
144
+ // Task Enhancement
145
+ this.register({
146
+ id: "task-enhance",
147
+ name: "Task Enhancement",
148
+ description: "Enhance an existing task with AI using Context7 documentation",
149
+ validateInput: (input: any) => typeof input.taskId === "string",
150
+ execute: async (
151
+ input: any,
152
+ aiOptions: AIOptions,
153
+ streamingOptions?: StreamingOptions
154
+ ) => {
155
+ return await taskService.enhanceTask(
156
+ input.taskId,
157
+ aiOptions,
158
+ streamingOptions
159
+ );
160
+ },
161
+ });
162
+
163
+ // Task Planning
164
+ this.register({
165
+ id: "task-plan",
166
+ name: "Task Planning",
167
+ description: "Create a detailed implementation plan for a task",
168
+ validateInput: (input: any) => typeof input.taskId === "string",
169
+ execute: async (
170
+ input: any,
171
+ aiOptions: AIOptions,
172
+ streamingOptions?: StreamingOptions
173
+ ) => {
174
+ return await taskService.planTask(
175
+ input.taskId,
176
+ aiOptions,
177
+ streamingOptions
178
+ );
179
+ },
180
+ });
181
+
182
+ // Task Documentation
183
+ this.register({
184
+ id: "task-document",
185
+ name: "Task Documentation",
186
+ description: "Analyze and generate documentation for a task",
187
+ validateInput: (input: any) => typeof input.taskId === "string",
188
+ execute: async (
189
+ input: any,
190
+ aiOptions: AIOptions,
191
+ streamingOptions?: StreamingOptions
192
+ ) => {
193
+ return await taskService.documentTask(
194
+ input.taskId,
195
+ input.force || false,
196
+ aiOptions,
197
+ streamingOptions
198
+ );
199
+ },
200
+ });
201
+
202
+ // PRD Creation
203
+ this.register({
204
+ id: "prd-create",
205
+ name: "PRD Creation",
206
+ description: "Generate a Product Requirements Document from a description",
207
+ validateInput: (input: any) =>
208
+ typeof input.description === "string" && input.description.length > 0,
209
+ execute: async (
210
+ input: any,
211
+ aiOptions: AIOptions,
212
+ streamingOptions?: StreamingOptions
213
+ ) => {
214
+ return await prdService.generatePRD({
215
+ description: input.description,
216
+ outputDir: input.outputDir,
217
+ filename: input.filename,
218
+ aiOptions,
219
+ streamingOptions,
220
+ callbacks: {},
221
+ });
222
+ },
223
+ });
224
+
225
+ // PRD Combine
226
+ this.register({
227
+ id: "prd-combine",
228
+ name: "PRD Combination",
229
+ description: "Combine multiple PRD files into a single master PRD",
230
+ validateInput: (input: any) =>
231
+ Array.isArray(input.prds) &&
232
+ input.prds.length > 0 &&
233
+ typeof input.originalDescription === "string",
234
+ execute: async (
235
+ input: any,
236
+ aiOptions: AIOptions,
237
+ streamingOptions?: StreamingOptions
238
+ ) => {
239
+ return await prdService.combinePRDs({
240
+ prds: input.prds,
241
+ originalDescription: input.originalDescription,
242
+ outputDir: input.outputDir,
243
+ filename: input.filename,
244
+ aiOptions,
245
+ streamingOptions,
246
+ callbacks: {},
247
+ });
248
+ },
249
+ });
250
+
251
+ // PRD Question Generation
252
+ this.register({
253
+ id: "prd-question",
254
+ name: "PRD Question Generation",
255
+ description: "Generate clarifying questions for a PRD",
256
+ validateInput: (input: any) =>
257
+ typeof input.file === "string" && input.file.length > 0,
258
+ execute: async (
259
+ input: any,
260
+ aiOptions: AIOptions,
261
+ streamingOptions?: StreamingOptions
262
+ ) => {
263
+ return await prdService.generateQuestions({
264
+ file: input.file,
265
+ workingDirectory: input.workingDirectory,
266
+ enableFilesystemTools: input.tools,
267
+ promptOverride: input.prompt,
268
+ messageOverride: input.message,
269
+ aiOptions,
270
+ streamingOptions,
271
+ callbacks: {},
272
+ });
273
+ },
274
+ });
275
+
276
+ // PRD Refinement
277
+ this.register({
278
+ id: "prd-refine",
279
+ name: "PRD Refinement",
280
+ description: "Refine a PRD by generating questions and incorporating answers",
281
+ validateInput: (input: any) =>
282
+ typeof input.file === "string" &&
283
+ input.file.length > 0 &&
284
+ typeof input.questionMode === "string" &&
285
+ (input.questionMode === "user" || input.questionMode === "ai"),
286
+ execute: async (
287
+ input: any,
288
+ aiOptions: AIOptions,
289
+ streamingOptions?: StreamingOptions
290
+ ) => {
291
+ return await prdService.refinePRDWithQuestions({
292
+ file: input.file,
293
+ questionMode: input.questionMode,
294
+ answers: input.answers,
295
+ questionAIOptions: input.questionAIOptions,
296
+ workingDirectory: input.workingDirectory,
297
+ enableFilesystemTools: input.tools,
298
+ aiOptions,
299
+ streamingOptions,
300
+ callbacks: {},
301
+ });
302
+ },
303
+ });
304
+ }
305
+ }
306
+
307
+ export const benchmarkRegistry = new BenchmarkRegistry();
@@ -0,0 +1,190 @@
1
+ import {
2
+ BenchmarkConfig,
3
+ BenchmarkResult,
4
+ BenchmarkRun,
5
+ BenchmarkProgressEvent,
6
+ } from "./types";
7
+ import { benchmarkRegistry } from "./registry";
8
+ import { benchmarkStorage } from "./storage";
9
+ import { AIConfig } from "../../types";
10
+ import { configManager } from "../config";
11
+
12
+ export class BenchmarkRunner {
13
+ async run(
14
+ operationId: string,
15
+ input: any,
16
+ config: BenchmarkConfig,
17
+ onProgress?: (event: BenchmarkProgressEvent) => void
18
+ ): Promise<BenchmarkRun> {
19
+ const operation = benchmarkRegistry.get(operationId);
20
+ if (!operation) {
21
+ throw new Error(`Operation ${operationId} not found`);
22
+ }
23
+
24
+ if (!operation.validateInput(input)) {
25
+ throw new Error(`Invalid input for operation ${operationId}`);
26
+ }
27
+
28
+ const runId = `run-${Date.now()}`;
29
+ const results: BenchmarkResult[] = [];
30
+
31
+ // Create a queue of models to process
32
+ const queue = [...config.models];
33
+ const activePromises: Promise<void>[] = [];
34
+
35
+ // Helper to process a single model
36
+ const processModel = async (modelConfig: any) => {
37
+ const modelId = `${modelConfig.provider}:${modelConfig.model}${
38
+ modelConfig.reasoningTokens
39
+ ? `:reasoning=${modelConfig.reasoningTokens}`
40
+ : ""
41
+ }`;
42
+
43
+ const startTime = Date.now();
44
+ let output: any;
45
+ let error: string | undefined;
46
+ let tokenUsage:
47
+ | { prompt: number; completion: number; total: number }
48
+ | undefined;
49
+ let responseSize = 0;
50
+ let firstTokenTime: number | undefined;
51
+
52
+ // Emit start event
53
+ onProgress?.({ type: "start", modelId });
54
+
55
+ try {
56
+ // Construct AI options for this specific run
57
+ const aiOptions: any = {
58
+ aiProvider: modelConfig.provider,
59
+ aiModel: modelConfig.model,
60
+ aiReasoning: modelConfig.reasoningTokens,
61
+ };
62
+
63
+ // Setup streaming options to capture metrics
64
+ const streamingOptions = {
65
+ onFinish: async (result: any) => {
66
+ if (result.usage) {
67
+ tokenUsage = {
68
+ prompt:
69
+ result.usage.inputTokens || result.usage.promptTokens || 0,
70
+ completion:
71
+ result.usage.outputTokens ||
72
+ result.usage.completionTokens ||
73
+ 0,
74
+ total: result.usage.totalTokens || 0,
75
+ };
76
+ }
77
+ // Estimate response size from text length if available, or JSON stringify
78
+ if (result.text) {
79
+ responseSize = Buffer.byteLength(result.text, "utf8");
80
+ }
81
+ },
82
+ onChunk: (chunk: string) => {
83
+ if (chunk) {
84
+ if (!firstTokenTime) {
85
+ firstTokenTime = Date.now();
86
+ }
87
+ const chunkSize = Buffer.byteLength(chunk, "utf8");
88
+ responseSize += chunkSize;
89
+
90
+ const currentDuration = Date.now() - startTime;
91
+ const currentBps =
92
+ currentDuration > 0
93
+ ? Math.round(responseSize / (currentDuration / 1000))
94
+ : 0;
95
+
96
+ onProgress?.({
97
+ type: "progress",
98
+ modelId,
99
+ currentSize: responseSize,
100
+ currentBps,
101
+ chunk: chunk,
102
+ duration: currentDuration,
103
+ });
104
+ }
105
+ },
106
+ };
107
+
108
+ // Execute operation
109
+ output = await operation.execute(input, aiOptions, streamingOptions);
110
+
111
+ // If responseSize wasn't captured via streaming (e.g. non-streaming response), calculate from output
112
+ if (responseSize === 0 && output) {
113
+ const outputStr =
114
+ typeof output === "string" ? output : JSON.stringify(output);
115
+ responseSize = Buffer.byteLength(outputStr, "utf8");
116
+ }
117
+ } catch (e: any) {
118
+ error = e.message || String(e);
119
+ onProgress?.({ type: "error", modelId, error });
120
+ }
121
+
122
+ const duration = Date.now() - startTime;
123
+ const bps =
124
+ duration > 0 && responseSize > 0
125
+ ? Math.round(responseSize / (duration / 1000))
126
+ : 0;
127
+ const tps =
128
+ duration > 0 && tokenUsage?.completion
129
+ ? Math.round(tokenUsage.completion / (duration / 1000))
130
+ : 0;
131
+
132
+ results.push({
133
+ modelId,
134
+ output,
135
+ duration,
136
+ error,
137
+ timestamp: Date.now(),
138
+ tokenUsage,
139
+ responseSize,
140
+ bps,
141
+ tps,
142
+ timeToFirstToken: firstTokenTime
143
+ ? firstTokenTime - startTime
144
+ : undefined,
145
+ });
146
+
147
+ // Emit complete event
148
+ onProgress?.({ type: "complete", modelId, duration });
149
+ };
150
+
151
+ // Process queue with concurrency limit
152
+ while (queue.length > 0 || activePromises.length > 0) {
153
+ // Fill active promises up to concurrency limit
154
+ while (queue.length > 0 && activePromises.length < config.concurrency) {
155
+ const modelConfig = queue.shift();
156
+ if (modelConfig) {
157
+ const promise = processModel(modelConfig).then(() => {
158
+ // Remove self from active promises
159
+ activePromises.splice(activePromises.indexOf(promise), 1);
160
+ });
161
+ activePromises.push(promise);
162
+
163
+ // Add delay if configured and there are more items
164
+ if (config.delay > 0 && queue.length > 0) {
165
+ await new Promise((resolve) => setTimeout(resolve, config.delay));
166
+ }
167
+ }
168
+ }
169
+
170
+ // Wait for at least one promise to complete if we're at capacity or queue is empty
171
+ if (activePromises.length > 0) {
172
+ await Promise.race(activePromises);
173
+ }
174
+ }
175
+
176
+ const run: BenchmarkRun = {
177
+ id: runId,
178
+ timestamp: Date.now(),
179
+ command: operationId,
180
+ input,
181
+ config,
182
+ results,
183
+ };
184
+
185
+ benchmarkStorage.saveRun(run);
186
+ return run;
187
+ }
188
+ }
189
+
190
+ export const benchmarkRunner = new BenchmarkRunner();
@@ -0,0 +1,140 @@
1
+ import { join } from "path";
2
+ import {
3
+ existsSync,
4
+ mkdirSync,
5
+ writeFileSync,
6
+ readFileSync,
7
+ readdirSync,
8
+ } from "fs";
9
+ import { configManager } from "../config";
10
+ import { BenchmarkRun } from "./types";
11
+ import { logger } from "../logger";
12
+
13
+ export class BenchmarkStorage {
14
+ private getBenchmarkDir(): string {
15
+ const taskOMaticDir = configManager.getTaskOMaticDir();
16
+ const benchmarkDir = join(taskOMaticDir, "benchmarks");
17
+ if (!existsSync(benchmarkDir)) {
18
+ mkdirSync(benchmarkDir, { recursive: true });
19
+ }
20
+ return benchmarkDir;
21
+ }
22
+
23
+ saveRun(run: BenchmarkRun): string {
24
+ const dir = this.getBenchmarkDir();
25
+ const runDir = join(dir, run.id);
26
+
27
+ if (!existsSync(runDir)) {
28
+ mkdirSync(runDir, { recursive: true });
29
+ }
30
+
31
+ // Save metadata
32
+ writeFileSync(
33
+ join(runDir, "metadata.json"),
34
+ JSON.stringify(
35
+ {
36
+ id: run.id,
37
+ timestamp: run.timestamp,
38
+ command: run.command,
39
+ config: run.config,
40
+ },
41
+ null,
42
+ 2
43
+ )
44
+ );
45
+
46
+ // Save input
47
+ writeFileSync(
48
+ join(runDir, "input.json"),
49
+ JSON.stringify(run.input, null, 2)
50
+ );
51
+
52
+ // Save results
53
+ const resultsDir = join(runDir, "results");
54
+ if (!existsSync(resultsDir)) {
55
+ mkdirSync(resultsDir);
56
+ }
57
+
58
+ run.results.forEach((result) => {
59
+ // Sanitize filename: replace : and / with -
60
+ const filename = result.modelId.replace(/[:\/]/g, "-") + ".json";
61
+ writeFileSync(
62
+ join(resultsDir, filename),
63
+ JSON.stringify(result, null, 2)
64
+ );
65
+ });
66
+
67
+ return runDir;
68
+ }
69
+
70
+ getRun(id: string): BenchmarkRun | null {
71
+ const dir = this.getBenchmarkDir();
72
+ const runDir = join(dir, id);
73
+
74
+ if (!existsSync(runDir)) {
75
+ return null;
76
+ }
77
+
78
+ try {
79
+ const metadata = JSON.parse(
80
+ readFileSync(join(runDir, "metadata.json"), "utf-8")
81
+ );
82
+ const input = JSON.parse(
83
+ readFileSync(join(runDir, "input.json"), "utf-8")
84
+ );
85
+
86
+ const resultsDir = join(runDir, "results");
87
+ const results = [];
88
+
89
+ if (existsSync(resultsDir)) {
90
+ const files = readdirSync(resultsDir).filter((f) =>
91
+ f.endsWith(".json")
92
+ );
93
+ for (const file of files) {
94
+ results.push(
95
+ JSON.parse(readFileSync(join(resultsDir, file), "utf-8"))
96
+ );
97
+ }
98
+ }
99
+
100
+ return {
101
+ ...metadata,
102
+ input,
103
+ results,
104
+ };
105
+ } catch (error) {
106
+ logger.error(`Failed to load benchmark run ${id}: ${error}`);
107
+ return null;
108
+ }
109
+ }
110
+
111
+ listRuns(): Array<{ id: string; timestamp: number; command: string }> {
112
+ const dir = this.getBenchmarkDir();
113
+ if (!existsSync(dir)) return [];
114
+
115
+ const runs = [];
116
+ const entries = readdirSync(dir, { withFileTypes: true });
117
+
118
+ for (const entry of entries) {
119
+ if (entry.isDirectory()) {
120
+ try {
121
+ const metadataPath = join(dir, entry.name, "metadata.json");
122
+ if (existsSync(metadataPath)) {
123
+ const metadata = JSON.parse(readFileSync(metadataPath, "utf-8"));
124
+ runs.push({
125
+ id: metadata.id,
126
+ timestamp: metadata.timestamp,
127
+ command: metadata.command,
128
+ });
129
+ }
130
+ } catch (e) {
131
+ // Skip invalid runs
132
+ }
133
+ }
134
+ }
135
+
136
+ return runs.sort((a, b) => b.timestamp - a.timestamp);
137
+ }
138
+ }
139
+
140
+ export const benchmarkStorage = new BenchmarkStorage();