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,107 @@
1
+ /**
2
+ * Validates that a file exists at the given path (synchronous).
3
+ * Throws an error with a custom message if the file doesn't exist.
4
+ *
5
+ * @param filePath - Path to the file to validate
6
+ * @param customMessage - Optional custom error message
7
+ * @throws TaskOMaticError if file doesn't exist
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * validateFileExists("./config.json", "Configuration file not found");
12
+ * // Throws: TaskOMaticError with code INVALID_INPUT if file doesn't exist
13
+ * ```
14
+ */
15
+ export declare function validateFileExists(filePath: string, customMessage?: string): void;
16
+ /**
17
+ * Validates that a file exists at the given path (asynchronous).
18
+ * Throws an error with a custom message if the file doesn't exist.
19
+ *
20
+ * @param filePath - Path to the file to validate
21
+ * @param customMessage - Optional custom error message
22
+ * @throws TaskOMaticError if file doesn't exist
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * await validateFileExistsAsync("./data.json");
27
+ * // Throws: TaskOMaticError with code INVALID_INPUT if file doesn't exist
28
+ * ```
29
+ */
30
+ export declare function validateFileExistsAsync(filePath: string, customMessage?: string): Promise<void>;
31
+ /**
32
+ * Checks if a file exists at the given path (synchronous).
33
+ * Returns true if file exists, false otherwise.
34
+ * Unlike validateFileExists, this doesn't throw an error.
35
+ *
36
+ * @param filePath - Path to check
37
+ * @returns true if file exists, false otherwise
38
+ */
39
+ export declare function fileExists(filePath: string): boolean;
40
+ /**
41
+ * Checks if a file exists at the given path (asynchronous).
42
+ * Returns true if file exists, false otherwise.
43
+ * Unlike validateFileExistsAsync, this doesn't throw an error.
44
+ *
45
+ * @param filePath - Path to check
46
+ * @returns Promise resolving to true if file exists, false otherwise
47
+ */
48
+ export declare function fileExistsAsync(filePath: string): Promise<boolean>;
49
+ /**
50
+ * Saves a file to the PRD directory, ensuring the directory exists.
51
+ * If no output directory is specified, uses `.task-o-matic/prd/` by default.
52
+ *
53
+ * @param content - Content to write to the file
54
+ * @param filename - Filename (defaults to "prd.md")
55
+ * @param outputDir - Optional output directory override
56
+ * @returns Full path to the saved file
57
+ * @throws TaskOMaticError if file saving fails
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Save to default location (.task-o-matic/prd/prd.md)
62
+ * const path = savePRDFile("# My PRD\n...");
63
+ *
64
+ * // Save with custom filename
65
+ * const path = savePRDFile("# My PRD\n...", "custom-prd.md");
66
+ *
67
+ * // Save to custom directory
68
+ * const path = savePRDFile("# My PRD\n...", "prd.md", "./docs");
69
+ * ```
70
+ */
71
+ export declare function savePRDFile(content: string, filename?: string, outputDir?: string): string;
72
+ /**
73
+ * Saves a stack configuration to a JSON file.
74
+ * If no output path is specified, saves to `.task-o-matic/stack.json`.
75
+ *
76
+ * @param config - BTSConfig object to save
77
+ * @param outputPath - Optional custom output path
78
+ * @returns Full path to the saved file
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * // Save to default location
83
+ * const path = saveStackFile(config);
84
+ *
85
+ * // Save to custom location
86
+ * const path = saveStackFile(config, "./my-project/stack.json");
87
+ * ```
88
+ */
89
+ export declare function saveStackFile(config: object, outputPath?: string): string;
90
+ /**
91
+ * Loads a stack configuration from a JSON file.
92
+ * If no input path is specified, loads from `.task-o-matic/stack.json`.
93
+ *
94
+ * @param inputPath - Optional custom input path
95
+ * @returns The parsed BTSConfig object, or null if file doesn't exist
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * // Load from default location
100
+ * const config = loadStackFile();
101
+ *
102
+ * // Load from custom location
103
+ * const config = loadStackFile("./my-project/stack.json");
104
+ * ```
105
+ */
106
+ export declare function loadStackFile<T = Record<string, unknown>>(inputPath?: string): T | null;
107
+ //# sourceMappingURL=file-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GACrB,IAAI,CAUN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOxE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAiB,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAYR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAWzE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvD,SAAS,CAAC,EAAE,MAAM,GACjB,CAAC,GAAG,IAAI,CAUV"}
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateFileExists = validateFileExists;
4
+ exports.validateFileExistsAsync = validateFileExistsAsync;
5
+ exports.fileExists = fileExists;
6
+ exports.fileExistsAsync = fileExistsAsync;
7
+ exports.savePRDFile = savePRDFile;
8
+ exports.saveStackFile = saveStackFile;
9
+ exports.loadStackFile = loadStackFile;
10
+ const fs_1 = require("fs");
11
+ const promises_1 = require("fs/promises");
12
+ const path_1 = require("path");
13
+ const task_o_matic_error_1 = require("./task-o-matic-error");
14
+ const config_1 = require("../lib/config");
15
+ /**
16
+ * Validates that a file exists at the given path (synchronous).
17
+ * Throws an error with a custom message if the file doesn't exist.
18
+ *
19
+ * @param filePath - Path to the file to validate
20
+ * @param customMessage - Optional custom error message
21
+ * @throws TaskOMaticError if file doesn't exist
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * validateFileExists("./config.json", "Configuration file not found");
26
+ * // Throws: TaskOMaticError with code INVALID_INPUT if file doesn't exist
27
+ * ```
28
+ */
29
+ function validateFileExists(filePath, customMessage) {
30
+ if (!(0, fs_1.existsSync)(filePath)) {
31
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, customMessage || `File not found: ${filePath}`, {
32
+ suggestions: ["Verify the file path is correct."],
33
+ });
34
+ }
35
+ }
36
+ /**
37
+ * Validates that a file exists at the given path (asynchronous).
38
+ * Throws an error with a custom message if the file doesn't exist.
39
+ *
40
+ * @param filePath - Path to the file to validate
41
+ * @param customMessage - Optional custom error message
42
+ * @throws TaskOMaticError if file doesn't exist
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * await validateFileExistsAsync("./data.json");
47
+ * // Throws: TaskOMaticError with code INVALID_INPUT if file doesn't exist
48
+ * ```
49
+ */
50
+ async function validateFileExistsAsync(filePath, customMessage) {
51
+ try {
52
+ await (0, promises_1.access)(filePath, promises_1.constants.F_OK);
53
+ }
54
+ catch {
55
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.INVALID_INPUT, customMessage || `File not found: ${filePath}`, {
56
+ suggestions: ["Verify the file path is correct."],
57
+ });
58
+ }
59
+ }
60
+ /**
61
+ * Checks if a file exists at the given path (synchronous).
62
+ * Returns true if file exists, false otherwise.
63
+ * Unlike validateFileExists, this doesn't throw an error.
64
+ *
65
+ * @param filePath - Path to check
66
+ * @returns true if file exists, false otherwise
67
+ */
68
+ function fileExists(filePath) {
69
+ return (0, fs_1.existsSync)(filePath);
70
+ }
71
+ /**
72
+ * Checks if a file exists at the given path (asynchronous).
73
+ * Returns true if file exists, false otherwise.
74
+ * Unlike validateFileExistsAsync, this doesn't throw an error.
75
+ *
76
+ * @param filePath - Path to check
77
+ * @returns Promise resolving to true if file exists, false otherwise
78
+ */
79
+ async function fileExistsAsync(filePath) {
80
+ try {
81
+ await (0, promises_1.access)(filePath, promises_1.constants.F_OK);
82
+ return true;
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ }
88
+ /**
89
+ * Saves a file to the PRD directory, ensuring the directory exists.
90
+ * If no output directory is specified, uses `.task-o-matic/prd/` by default.
91
+ *
92
+ * @param content - Content to write to the file
93
+ * @param filename - Filename (defaults to "prd.md")
94
+ * @param outputDir - Optional output directory override
95
+ * @returns Full path to the saved file
96
+ * @throws TaskOMaticError if file saving fails
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * // Save to default location (.task-o-matic/prd/prd.md)
101
+ * const path = savePRDFile("# My PRD\n...");
102
+ *
103
+ * // Save with custom filename
104
+ * const path = savePRDFile("# My PRD\n...", "custom-prd.md");
105
+ *
106
+ * // Save to custom directory
107
+ * const path = savePRDFile("# My PRD\n...", "prd.md", "./docs");
108
+ * ```
109
+ */
110
+ function savePRDFile(content, filename = "prd.md", outputDir) {
111
+ const taskOMaticDir = config_1.configManager.getTaskOMaticDir();
112
+ const prdDir = outputDir || (0, path_1.join)(taskOMaticDir, "prd");
113
+ if (!(0, fs_1.existsSync)(prdDir)) {
114
+ (0, fs_1.mkdirSync)(prdDir, { recursive: true });
115
+ }
116
+ const path = (0, path_1.join)(prdDir, filename);
117
+ (0, fs_1.writeFileSync)(path, content);
118
+ return path;
119
+ }
120
+ /**
121
+ * Saves a stack configuration to a JSON file.
122
+ * If no output path is specified, saves to `.task-o-matic/stack.json`.
123
+ *
124
+ * @param config - BTSConfig object to save
125
+ * @param outputPath - Optional custom output path
126
+ * @returns Full path to the saved file
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * // Save to default location
131
+ * const path = saveStackFile(config);
132
+ *
133
+ * // Save to custom location
134
+ * const path = saveStackFile(config, "./my-project/stack.json");
135
+ * ```
136
+ */
137
+ function saveStackFile(config, outputPath) {
138
+ const taskOMaticDir = config_1.configManager.getTaskOMaticDir();
139
+ const stackPath = outputPath || (0, path_1.join)(taskOMaticDir, "stack.json");
140
+ const dir = (0, path_1.dirname)(stackPath);
141
+ if (!(0, fs_1.existsSync)(dir)) {
142
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
143
+ }
144
+ (0, fs_1.writeFileSync)(stackPath, JSON.stringify(config, null, 2));
145
+ return stackPath;
146
+ }
147
+ /**
148
+ * Loads a stack configuration from a JSON file.
149
+ * If no input path is specified, loads from `.task-o-matic/stack.json`.
150
+ *
151
+ * @param inputPath - Optional custom input path
152
+ * @returns The parsed BTSConfig object, or null if file doesn't exist
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * // Load from default location
157
+ * const config = loadStackFile();
158
+ *
159
+ * // Load from custom location
160
+ * const config = loadStackFile("./my-project/stack.json");
161
+ * ```
162
+ */
163
+ function loadStackFile(inputPath) {
164
+ const taskOMaticDir = config_1.configManager.getTaskOMaticDir();
165
+ const stackPath = inputPath || (0, path_1.join)(taskOMaticDir, "stack.json");
166
+ if (!(0, fs_1.existsSync)(stackPath)) {
167
+ return null;
168
+ }
169
+ const content = (0, fs_1.readFileSync)(stackPath, "utf-8");
170
+ return JSON.parse(content);
171
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Generates unique task IDs with consistent format.
3
+ * Uses timestamp + random hex for uniqueness.
4
+ */
5
+ export declare class TaskIDGenerator {
6
+ /**
7
+ * Generates a unique task ID with format: prefix-timestamp-random
8
+ *
9
+ * @param prefix - Prefix for the ID (default: "task")
10
+ * @returns Unique task ID
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const id = TaskIDGenerator.generate();
15
+ * // Returns: "task-1733750400000-a1b2c3d4"
16
+ *
17
+ * const customId = TaskIDGenerator.generate("subtask");
18
+ * // Returns: "subtask-1733750400000-e5f6g7h8"
19
+ * ```
20
+ */
21
+ static generate(prefix?: string): string;
22
+ /**
23
+ * Validates a task ID format.
24
+ * Accepts three formats:
25
+ * - Timestamped: "task-1234567890-abcd1234"
26
+ * - Hierarchical: "1.2.3"
27
+ * - Numeric: "123"
28
+ *
29
+ * @param id - Task ID to validate
30
+ * @returns true if ID format is valid
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * TaskIDGenerator.validate("task-1234-abcd"); // true
35
+ * TaskIDGenerator.validate("1.2.3"); // true
36
+ * TaskIDGenerator.validate("123"); // true
37
+ * TaskIDGenerator.validate("invalid!"); // false
38
+ * ```
39
+ */
40
+ static validate(id: string): boolean;
41
+ /**
42
+ * Checks if an ID is unique within a set of existing IDs.
43
+ *
44
+ * @param id - ID to check
45
+ * @param existingIds - Set of existing IDs
46
+ * @returns true if ID is unique
47
+ */
48
+ static isUnique(id: string, existingIds: Set<string>): boolean;
49
+ /**
50
+ * Generates a unique ID that doesn't exist in the provided set.
51
+ * Retries up to maxAttempts times if collisions occur.
52
+ *
53
+ * @param existingIds - Set of existing IDs to avoid
54
+ * @param prefix - Prefix for the ID
55
+ * @param maxAttempts - Maximum number of generation attempts
56
+ * @returns Unique task ID
57
+ * @throws TaskOMaticError if unable to generate unique ID after maxAttempts
58
+ */
59
+ static generateUnique(existingIds: Set<string>, prefix?: string, maxAttempts?: number): string;
60
+ /**
61
+ * Generates a hierarchical child ID from a parent ID.
62
+ * If parent is "1.2", generates "1.2.1", "1.2.2", etc.
63
+ *
64
+ * @param parentId - Parent task ID
65
+ * @param childIndex - Index of the child (1-based)
66
+ * @returns Child task ID
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * TaskIDGenerator.generateChildId("1", 1); // "1.1"
71
+ * TaskIDGenerator.generateChildId("1.2", 3); // "1.2.3"
72
+ * ```
73
+ */
74
+ static generateChildId(parentId: string, childIndex: number): string;
75
+ /**
76
+ * Parses a hierarchical ID to extract parent ID and child index.
77
+ *
78
+ * @param id - Hierarchical task ID
79
+ * @returns Object with parentId and childIndex, or null if not hierarchical
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * TaskIDGenerator.parseHierarchicalId("1.2.3");
84
+ * // Returns: { parentId: "1.2", childIndex: 3 }
85
+ * ```
86
+ */
87
+ static parseHierarchicalId(id: string): {
88
+ parentId: string;
89
+ childIndex: number;
90
+ } | null;
91
+ }
92
+ //# sourceMappingURL=id-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-generator.d.ts","sourceRoot":"","sources":["../../src/utils/id-generator.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAE,MAAe,GAAG,MAAM;IAMhD;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IA0BpC;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO;IAI9D;;;;;;;;;OASG;IACH,MAAM,CAAC,cAAc,CACnB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,MAAM,GAAE,MAAe,EACvB,WAAW,GAAE,MAAW,GACvB,MAAM;IAoBT;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAIpE;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,mBAAmB,CACxB,EAAE,EAAE,MAAM,GACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAcnD"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskIDGenerator = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const task_o_matic_error_1 = require("./task-o-matic-error");
6
+ /**
7
+ * Generates unique task IDs with consistent format.
8
+ * Uses timestamp + random hex for uniqueness.
9
+ */
10
+ class TaskIDGenerator {
11
+ /**
12
+ * Generates a unique task ID with format: prefix-timestamp-random
13
+ *
14
+ * @param prefix - Prefix for the ID (default: "task")
15
+ * @returns Unique task ID
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const id = TaskIDGenerator.generate();
20
+ * // Returns: "task-1733750400000-a1b2c3d4"
21
+ *
22
+ * const customId = TaskIDGenerator.generate("subtask");
23
+ * // Returns: "subtask-1733750400000-e5f6g7h8"
24
+ * ```
25
+ */
26
+ static generate(prefix = "task") {
27
+ const timestamp = Date.now();
28
+ const random = (0, crypto_1.randomBytes)(4).toString("hex");
29
+ return `${prefix}-${timestamp}-${random}`;
30
+ }
31
+ /**
32
+ * Validates a task ID format.
33
+ * Accepts three formats:
34
+ * - Timestamped: "task-1234567890-abcd1234"
35
+ * - Hierarchical: "1.2.3"
36
+ * - Numeric: "123"
37
+ *
38
+ * @param id - Task ID to validate
39
+ * @returns true if ID format is valid
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * TaskIDGenerator.validate("task-1234-abcd"); // true
44
+ * TaskIDGenerator.validate("1.2.3"); // true
45
+ * TaskIDGenerator.validate("123"); // true
46
+ * TaskIDGenerator.validate("invalid!"); // false
47
+ * ```
48
+ */
49
+ static validate(id) {
50
+ if (!id || typeof id !== "string") {
51
+ return false;
52
+ }
53
+ // Format 1: Timestamped (task-timestamp-random)
54
+ const timestampedPattern = /^[a-z]+-\d+-[a-f0-9]{8}$/;
55
+ if (timestampedPattern.test(id)) {
56
+ return true;
57
+ }
58
+ // Format 2: Hierarchical (1.2.3)
59
+ const hierarchicalPattern = /^[\d.]+$/;
60
+ if (hierarchicalPattern.test(id)) {
61
+ return true;
62
+ }
63
+ // Format 3: Numeric (123)
64
+ const numericPattern = /^\d+$/;
65
+ if (numericPattern.test(id)) {
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+ /**
71
+ * Checks if an ID is unique within a set of existing IDs.
72
+ *
73
+ * @param id - ID to check
74
+ * @param existingIds - Set of existing IDs
75
+ * @returns true if ID is unique
76
+ */
77
+ static isUnique(id, existingIds) {
78
+ return !existingIds.has(id);
79
+ }
80
+ /**
81
+ * Generates a unique ID that doesn't exist in the provided set.
82
+ * Retries up to maxAttempts times if collisions occur.
83
+ *
84
+ * @param existingIds - Set of existing IDs to avoid
85
+ * @param prefix - Prefix for the ID
86
+ * @param maxAttempts - Maximum number of generation attempts
87
+ * @returns Unique task ID
88
+ * @throws TaskOMaticError if unable to generate unique ID after maxAttempts
89
+ */
90
+ static generateUnique(existingIds, prefix = "task", maxAttempts = 10) {
91
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
92
+ const id = this.generate(prefix);
93
+ if (this.isUnique(id, existingIds)) {
94
+ return id;
95
+ }
96
+ }
97
+ throw (0, task_o_matic_error_1.createStandardError)(task_o_matic_error_1.TaskOMaticErrorCodes.UNEXPECTED_ERROR, `Failed to generate unique ID after ${maxAttempts} attempts`, {
98
+ context: `Could not find a unique ID with prefix '${prefix}' after ${maxAttempts} attempts.`,
99
+ suggestions: [
100
+ "Increase maxAttempts if you have a very large number of tasks.",
101
+ ],
102
+ });
103
+ }
104
+ /**
105
+ * Generates a hierarchical child ID from a parent ID.
106
+ * If parent is "1.2", generates "1.2.1", "1.2.2", etc.
107
+ *
108
+ * @param parentId - Parent task ID
109
+ * @param childIndex - Index of the child (1-based)
110
+ * @returns Child task ID
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * TaskIDGenerator.generateChildId("1", 1); // "1.1"
115
+ * TaskIDGenerator.generateChildId("1.2", 3); // "1.2.3"
116
+ * ```
117
+ */
118
+ static generateChildId(parentId, childIndex) {
119
+ return `${parentId}.${childIndex}`;
120
+ }
121
+ /**
122
+ * Parses a hierarchical ID to extract parent ID and child index.
123
+ *
124
+ * @param id - Hierarchical task ID
125
+ * @returns Object with parentId and childIndex, or null if not hierarchical
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * TaskIDGenerator.parseHierarchicalId("1.2.3");
130
+ * // Returns: { parentId: "1.2", childIndex: 3 }
131
+ * ```
132
+ */
133
+ static parseHierarchicalId(id) {
134
+ const parts = id.split(".");
135
+ if (parts.length < 2) {
136
+ return null;
137
+ }
138
+ const childIndex = parseInt(parts[parts.length - 1], 10);
139
+ if (isNaN(childIndex)) {
140
+ return null;
141
+ }
142
+ const parentId = parts.slice(0, -1).join(".");
143
+ return { parentId, childIndex };
144
+ }
145
+ }
146
+ exports.TaskIDGenerator = TaskIDGenerator;
@@ -0,0 +1,40 @@
1
+ import { AIConfig } from "../types";
2
+ /**
3
+ * Creates base AI metadata object with common fields.
4
+ * Caller can extend with operation-specific fields.
5
+ *
6
+ * @param taskId - The ID of the task
7
+ * @param aiConfig - AI configuration used for the operation
8
+ * @param promptOverride - Optional custom prompt override
9
+ * @param defaultPrompt - Default prompt if no override provided
10
+ * @param confidence - Confidence score (0-1) for the AI operation
11
+ * @returns Base metadata object
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const baseMetadata = createBaseAIMetadata(
16
+ * "task-123",
17
+ * { provider: "anthropic", model: "claude-sonnet-4.5" },
18
+ * undefined,
19
+ * "Split task into subtasks",
20
+ * 0.9
21
+ * );
22
+ *
23
+ * // Extend with operation-specific fields
24
+ * const subtaskMetadata = {
25
+ * ...baseMetadata,
26
+ * parentTaskId: "parent-123",
27
+ * subtaskIndex: 1
28
+ * };
29
+ * ```
30
+ */
31
+ export declare function createBaseAIMetadata(taskId: string, aiConfig: Partial<AIConfig>, promptOverride?: string, defaultPrompt?: string, confidence?: number): {
32
+ taskId: string;
33
+ aiGenerated: boolean;
34
+ aiPrompt: string;
35
+ confidence: number;
36
+ aiProvider: "custom" | "openai" | "anthropic" | "openrouter" | "gemini" | "zai" | undefined;
37
+ aiModel: string | undefined;
38
+ generatedAt: number;
39
+ };
40
+ //# sourceMappingURL=metadata-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-utils.d.ts","sourceRoot":"","sources":["../../src/utils/metadata-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC3B,cAAc,CAAC,EAAE,MAAM,EACvB,aAAa,GAAE,MAA4B,EAC3C,UAAU,GAAE,MAAY;;;;;;;;EAWzB"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBaseAIMetadata = createBaseAIMetadata;
4
+ /**
5
+ * Creates base AI metadata object with common fields.
6
+ * Caller can extend with operation-specific fields.
7
+ *
8
+ * @param taskId - The ID of the task
9
+ * @param aiConfig - AI configuration used for the operation
10
+ * @param promptOverride - Optional custom prompt override
11
+ * @param defaultPrompt - Default prompt if no override provided
12
+ * @param confidence - Confidence score (0-1) for the AI operation
13
+ * @returns Base metadata object
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const baseMetadata = createBaseAIMetadata(
18
+ * "task-123",
19
+ * { provider: "anthropic", model: "claude-sonnet-4.5" },
20
+ * undefined,
21
+ * "Split task into subtasks",
22
+ * 0.9
23
+ * );
24
+ *
25
+ * // Extend with operation-specific fields
26
+ * const subtaskMetadata = {
27
+ * ...baseMetadata,
28
+ * parentTaskId: "parent-123",
29
+ * subtaskIndex: 1
30
+ * };
31
+ * ```
32
+ */
33
+ function createBaseAIMetadata(taskId, aiConfig, promptOverride, defaultPrompt = "AI-generated task", confidence = 0.9) {
34
+ return {
35
+ taskId,
36
+ aiGenerated: true,
37
+ aiPrompt: promptOverride || defaultPrompt,
38
+ confidence,
39
+ aiProvider: aiConfig.provider,
40
+ aiModel: aiConfig.model,
41
+ generatedAt: Date.now(),
42
+ };
43
+ }
@@ -0,0 +1,38 @@
1
+ import { ExecutorTool, ModelAttemptConfig } from "../types";
2
+ /**
3
+ * Valid executor tools
4
+ */
5
+ export declare const VALID_EXECUTORS: ExecutorTool[];
6
+ /**
7
+ * Parse --try-models option into ModelAttemptConfig array
8
+ * Supports formats:
9
+ * - "model1,model2,model3" - just models (uses default executor)
10
+ * - "opencode:gpt-4o,claude:sonnet-4" - executor:model format
11
+ * - Mixed: "gpt-4o,claude:sonnet-4,gemini:gemini-2.0"
12
+ *
13
+ * @param value - Comma-separated model/executor specifications
14
+ * @returns Array of model attempt configurations
15
+ * @throws TaskOMaticError if an invalid executor is specified
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * parseTryModels("gpt-4o-mini,gpt-4o"); // [{ model: "gpt-4o-mini" }, { model: "gpt-4o" }]
20
+ * parseTryModels("opencode:gpt-4o,claude:sonnet-4"); // [{ executor: "opencode", model: "gpt-4o" }, ...]
21
+ * ```
22
+ */
23
+ export declare function parseTryModels(value: string): ModelAttemptConfig[];
24
+ /**
25
+ * Validate that an executor name is valid
26
+ *
27
+ * @param executor - Executor name to validate
28
+ * @returns Type guard confirming executor is valid
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * if (validateExecutor(options.tool)) {
33
+ * // TypeScript knows options.tool is ExecutorTool
34
+ * }
35
+ * ```
36
+ */
37
+ export declare function validateExecutor(executor: string): executor is ExecutorTool;
38
+ //# sourceMappingURL=model-executor-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-executor-parser.d.ts","sourceRoot":"","sources":["../../src/utils/model-executor-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAM5D;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,EAMzC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,EAAE,CA4BlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,YAAY,CAE3E"}