upfynai-code 0.1.0 → 2.2.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 (340) hide show
  1. package/client/dist/api-docs.html +879 -0
  2. package/client/dist/assets/AppContent-CTSHQdyq.js +513 -0
  3. package/client/dist/assets/CanvasPanel-Cig0Mo9s.js +6 -0
  4. package/client/dist/assets/CanvasPanel-q4HEqNtV.css +1 -0
  5. package/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  6. package/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  7. package/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  8. package/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  9. package/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  10. package/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  11. package/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  12. package/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  13. package/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  14. package/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  15. package/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  16. package/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  17. package/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  18. package/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  19. package/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  20. package/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  21. package/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  22. package/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  23. package/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  24. package/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  25. package/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  26. package/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  27. package/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  28. package/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  29. package/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  30. package/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  31. package/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  32. package/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  33. package/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  34. package/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  35. package/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  36. package/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  37. package/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  38. package/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  39. package/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  40. package/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  41. package/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  42. package/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  43. package/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  44. package/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  45. package/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  46. package/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  47. package/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  48. package/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  49. package/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  50. package/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  51. package/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  52. package/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  53. package/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  54. package/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  55. package/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  56. package/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  57. package/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  58. package/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  59. package/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  60. package/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  61. package/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  62. package/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  63. package/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  64. package/client/dist/assets/LoginModal-silya-zP.js +11 -0
  65. package/client/dist/assets/MarkdownPreview-B3c7OEj6.js +1 -0
  66. package/client/dist/assets/Onboarding-Coxo6mFA.js +1 -0
  67. package/client/dist/assets/SetupForm-BzYOsbji.js +1 -0
  68. package/client/dist/assets/Tableau10-B-NsZVaP.js +1 -0
  69. package/client/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  70. package/client/dist/assets/ar-SA-G6X2FPQ2-Bmw2-hDt.js +10 -0
  71. package/client/dist/assets/arc-BMqY7_Ci.js +1 -0
  72. package/client/dist/assets/array-BKyUJesY.js +1 -0
  73. package/client/dist/assets/az-AZ-76LH7QW2-Dh1le_qs.js +1 -0
  74. package/client/dist/assets/bg-BG-XCXSNQG7-Cbav8Z9z.js +5 -0
  75. package/client/dist/assets/blockDiagram-38ab4fdb-ChHJxsXw.js +118 -0
  76. package/client/dist/assets/bn-BD-2XOGV67Q-DCNjOaWz.js +5 -0
  77. package/client/dist/assets/c4Diagram-3d4e48cf-b8Xue4Z6.js +10 -0
  78. package/client/dist/assets/ca-ES-6MX7JW3Y-Dl_vM7NS.js +8 -0
  79. package/client/dist/assets/channel-CSnvHe_M.js +1 -0
  80. package/client/dist/assets/classDiagram-70f12bd4-BheP7Ggo.js +2 -0
  81. package/client/dist/assets/classDiagram-v2-f2320105-xtym7GEZ.js +2 -0
  82. package/client/dist/assets/clone-B75abXxS.js +1 -0
  83. package/client/dist/assets/createText-2e5e7dd3-_n4jI_fO.js +5 -0
  84. package/client/dist/assets/cs-CZ-2BRQDIVT-ftsKDdz4.js +11 -0
  85. package/client/dist/assets/da-DK-5WZEPLOC-DAjdwGRO.js +5 -0
  86. package/client/dist/assets/de-DE-XR44H4JA-BJXczHGT.js +8 -0
  87. package/client/dist/assets/directory-open-01563666-DWU9wJ6I.js +1 -0
  88. package/client/dist/assets/directory-open-4ed118d0-CunoC1EB.js +1 -0
  89. package/client/dist/assets/edges-e0da2a9e-CfPZr4YM.js +4 -0
  90. package/client/dist/assets/el-GR-BZB4AONW-DW2p_uy7.js +10 -0
  91. package/client/dist/assets/erDiagram-9861fffd-CF33V-Of.js +51 -0
  92. package/client/dist/assets/es-ES-U4NZUMDT-DLOIGnrl.js +9 -0
  93. package/client/dist/assets/eu-ES-A7QVB2H4-LJXbf89m.js +11 -0
  94. package/client/dist/assets/fa-IR-HGAKTJCU-Dvx65fgW.js +8 -0
  95. package/client/dist/assets/fi-FI-Z5N7JZ37-EoL65BQh.js +6 -0
  96. package/client/dist/assets/file-open-002ab408-DIuFHtCF.js +1 -0
  97. package/client/dist/assets/file-open-7c801643-684qeFg4.js +1 -0
  98. package/client/dist/assets/file-save-3189631c-C1wFhQhH.js +1 -0
  99. package/client/dist/assets/file-save-745eba88-Bb9F9Kg7.js +1 -0
  100. package/client/dist/assets/flowDb-956e92f1-HgoXVy2H.js +10 -0
  101. package/client/dist/assets/flowDiagram-66a62f08-tffoET0H.js +4 -0
  102. package/client/dist/assets/flowDiagram-v2-96b9c2cf-Byc3JCHh.js +1 -0
  103. package/client/dist/assets/flowchart-elk-definition-4a651766-DJbI2dpv.js +139 -0
  104. package/client/dist/assets/fr-FR-RHASNOE6-DNk_jdDs.js +9 -0
  105. package/client/dist/assets/ganttDiagram-c361ad54-2XX670FU.js +257 -0
  106. package/client/dist/assets/gitGraphDiagram-72cf32ee-CcUfruAo.js +70 -0
  107. package/client/dist/assets/gl-ES-HMX3MZ6V-dxzFjZlG.js +10 -0
  108. package/client/dist/assets/graph-BSbiMSBC.js +1 -0
  109. package/client/dist/assets/he-IL-6SHJWFNN-Cogsfdt1.js +10 -0
  110. package/client/dist/assets/hi-IN-IWLTKZ5I-L6wbgi4F.js +4 -0
  111. package/client/dist/assets/hu-HU-A5ZG7DT2-DSA6ZDsH.js +7 -0
  112. package/client/dist/assets/id-ID-SAP4L64H-BK_vGGS6.js +10 -0
  113. package/client/dist/assets/image-blob-reduce.esm-BLtmMM_J.js +2 -0
  114. package/client/dist/assets/index-3862675e-Bv32HUgT.js +1 -0
  115. package/client/dist/assets/index-B8wwD_Xo.css +1 -0
  116. package/client/dist/assets/index-BPwf8Fw3.js +27 -0
  117. package/client/dist/assets/index-D1urGMYu.js +95 -0
  118. package/client/dist/assets/infoDiagram-f8f76790-w4mR4pxn.js +7 -0
  119. package/client/dist/assets/init-Gi6I4Gst.js +1 -0
  120. package/client/dist/assets/it-IT-JPQ66NNP-BLdHYMhn.js +11 -0
  121. package/client/dist/assets/ja-JP-DBVTYXUO-B_vmexl_.js +8 -0
  122. package/client/dist/assets/journeyDiagram-49397b02-D9nmO17e.js +139 -0
  123. package/client/dist/assets/kaa-6HZHGXH3-5s-3jl6F.js +1 -0
  124. package/client/dist/assets/kab-KAB-ZGHBKWFO-2QaVDuSf.js +8 -0
  125. package/client/dist/assets/kk-KZ-P5N5QNE5-CTC52Vbi.js +1 -0
  126. package/client/dist/assets/km-KH-HSX4SM5Z-DxawH8UZ.js +11 -0
  127. package/client/dist/assets/ko-KR-MTYHY66A-CmosEM8_.js +9 -0
  128. package/client/dist/assets/ku-TR-6OUDTVRD-DbiLen4y.js +9 -0
  129. package/client/dist/assets/layout-jmt3H9tA.js +1 -0
  130. package/client/dist/assets/line-JTlRayUJ.js +1 -0
  131. package/client/dist/assets/linear-DJeB5p7x.js +1 -0
  132. package/client/dist/assets/lt-LT-XHIRWOB4-CH15wrjA.js +3 -0
  133. package/client/dist/assets/lv-LV-5QDEKY6T-dhgfPuCQ.js +7 -0
  134. package/client/dist/assets/mindmap-definition-fc14e90a-BOOrexmz.js +415 -0
  135. package/client/dist/assets/mr-IN-CRQNXWMA-3Gi6iq7A.js +13 -0
  136. package/client/dist/assets/my-MM-5M5IBNSE-CpH4rdJj.js +1 -0
  137. package/client/dist/assets/nb-NO-T6EIAALU-Du6iiGql.js +10 -0
  138. package/client/dist/assets/nl-NL-IS3SIHDZ-BGvsd1MT.js +8 -0
  139. package/client/dist/assets/nn-NO-6E72VCQL-B-odvJZW.js +8 -0
  140. package/client/dist/assets/oc-FR-POXYY2M6-COC8xNjo.js +8 -0
  141. package/client/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  142. package/client/dist/assets/pa-IN-N4M65BXN-CE21PUQH.js +4 -0
  143. package/client/dist/assets/path-CbwjOpE9.js +1 -0
  144. package/client/dist/assets/pdf-TYrZqVzP.js +12 -0
  145. package/client/dist/assets/pdf.worker-BA9kU3Pw.mjs +61080 -0
  146. package/client/dist/assets/percentages-BXMCSKIN-C9GT0OD3.js +199 -0
  147. package/client/dist/assets/pica-VkdyTzi8.js +2 -0
  148. package/client/dist/assets/pieDiagram-8a3498a8-Cvfh7Qr5.js +35 -0
  149. package/client/dist/assets/pl-PL-T2D74RX3-D4xFVSoT.js +9 -0
  150. package/client/dist/assets/pt-BR-5N22H2LF-CCq257gA.js +9 -0
  151. package/client/dist/assets/pt-PT-UZXXM6DQ-1l8gt5vA.js +9 -0
  152. package/client/dist/assets/quadrantDiagram-120e2f19-BA0js1aD.js +7 -0
  153. package/client/dist/assets/requirementDiagram-deff3bca-B0QNFfIn.js +52 -0
  154. package/client/dist/assets/ro-RO-JPDTUUEW-yosBW01E.js +11 -0
  155. package/client/dist/assets/roundRect-mAH3dD0p.js +1 -0
  156. package/client/dist/assets/ru-RU-B4JR7IUQ-8LkEJUix.js +9 -0
  157. package/client/dist/assets/sankeyDiagram-04a897e0-D4T9eCXn.js +8 -0
  158. package/client/dist/assets/sequenceDiagram-704730f1-CfBUTCrO.js +122 -0
  159. package/client/dist/assets/si-LK-N5RQ5JYF-D8rjbqtd.js +1 -0
  160. package/client/dist/assets/sk-SK-C5VTKIMK-Bg14sAzN.js +6 -0
  161. package/client/dist/assets/sl-SI-NN7IZMDC-CMTib6Zs.js +6 -0
  162. package/client/dist/assets/stateDiagram-587899a1-BGgvmVSZ.js +1 -0
  163. package/client/dist/assets/stateDiagram-v2-d93cdb3a-Qn3DpYuO.js +1 -0
  164. package/client/dist/assets/styles-6aaf32cf-IdVZLPrD.js +207 -0
  165. package/client/dist/assets/styles-9a916d00-BAC3L45X.js +160 -0
  166. package/client/dist/assets/styles-c10674c1-COhXxX8c.js +116 -0
  167. package/client/dist/assets/subset-shared.chunk-BWHnFai4.js +22 -0
  168. package/client/dist/assets/subset-worker.chunk-C8QUSruZ.js +1 -0
  169. package/client/dist/assets/sv-SE-XGPEYMSR-C1425rOF.js +10 -0
  170. package/client/dist/assets/svgDrawCommon-08f97a94-Cfk-fgnN.js +1 -0
  171. package/client/dist/assets/ta-IN-2NMHFXQM-BHHo1zpF.js +9 -0
  172. package/client/dist/assets/th-TH-HPSO5L25-CZVzm_WT.js +2 -0
  173. package/client/dist/assets/timeline-definition-85554ec2-VAvuJith.js +61 -0
  174. package/client/dist/assets/tr-TR-DEFEU3FU-DE1lclCq.js +7 -0
  175. package/client/dist/assets/uk-UA-QMV73CPH-D4lJZ85O.js +6 -0
  176. package/client/dist/assets/vendor-codemirror-BARtJV1V.js +16 -0
  177. package/client/dist/assets/vendor-codemirror-langs-52_y1wip.js +20 -0
  178. package/client/dist/assets/vendor-i18n-ByAl-gdx.js +1 -0
  179. package/client/dist/assets/vendor-icons-D33IkSIf.js +1 -0
  180. package/client/dist/assets/vendor-markdown-CIVH08vJ.js +298 -0
  181. package/client/dist/assets/vendor-react-CHoMc7ka.js +8 -0
  182. package/client/dist/assets/vendor-syntax-Djb62v3a.js +9 -0
  183. package/client/dist/assets/vendor-xterm-DBb3RXlu.js +66 -0
  184. package/client/dist/assets/vendor-xterm-DrlLKa8f.css +1 -0
  185. package/client/dist/assets/vi-VN-M7AON7JQ-Dgc_SShk.js +5 -0
  186. package/client/dist/assets/xychartDiagram-e933f94c-BeyVBJhb.js +7 -0
  187. package/client/dist/assets/zh-CN-LNUGB5OW-MH4Yh8in.js +10 -0
  188. package/client/dist/assets/zh-HK-E62DVLB3-D4XHehjx.js +1 -0
  189. package/client/dist/assets/zh-TW-RAJ6MFWO--efj3evj.js +9 -0
  190. package/client/dist/clear-cache.html +85 -0
  191. package/client/dist/convert-icons.md +53 -0
  192. package/client/dist/favicon.png +0 -0
  193. package/client/dist/favicon.svg +9 -0
  194. package/client/dist/generate-icons.js +49 -0
  195. package/client/dist/icons/claude-ai-icon.svg +1 -0
  196. package/client/dist/icons/codex-white.svg +3 -0
  197. package/client/dist/icons/codex.svg +3 -0
  198. package/client/dist/icons/cursor-white.svg +12 -0
  199. package/client/dist/icons/cursor.svg +1 -0
  200. package/client/dist/icons/icon-128x128.png +0 -0
  201. package/client/dist/icons/icon-128x128.svg +12 -0
  202. package/client/dist/icons/icon-144x144.png +0 -0
  203. package/client/dist/icons/icon-144x144.svg +12 -0
  204. package/client/dist/icons/icon-152x152.png +0 -0
  205. package/client/dist/icons/icon-152x152.svg +12 -0
  206. package/client/dist/icons/icon-192x192.png +0 -0
  207. package/client/dist/icons/icon-192x192.svg +12 -0
  208. package/client/dist/icons/icon-384x384.png +0 -0
  209. package/client/dist/icons/icon-384x384.svg +12 -0
  210. package/client/dist/icons/icon-512x512.png +0 -0
  211. package/client/dist/icons/icon-512x512.svg +12 -0
  212. package/client/dist/icons/icon-72x72.png +0 -0
  213. package/client/dist/icons/icon-72x72.svg +12 -0
  214. package/client/dist/icons/icon-96x96.png +0 -0
  215. package/client/dist/icons/icon-96x96.svg +12 -0
  216. package/client/dist/icons/icon-template.svg +12 -0
  217. package/client/dist/index.html +128 -0
  218. package/client/dist/logo-128.png +0 -0
  219. package/client/dist/logo-256.png +0 -0
  220. package/client/dist/logo-32.png +0 -0
  221. package/client/dist/logo-512.png +0 -0
  222. package/client/dist/logo-64.png +0 -0
  223. package/client/dist/logo.svg +17 -0
  224. package/client/dist/manifest.json +61 -0
  225. package/client/dist/mcp-docs.html +119 -0
  226. package/client/dist/screenshots/cli-selection.png +0 -0
  227. package/client/dist/screenshots/desktop-main.png +0 -0
  228. package/client/dist/screenshots/mobile-chat.png +0 -0
  229. package/client/dist/screenshots/tools-modal.png +0 -0
  230. package/client/dist/sw.js +19 -0
  231. package/commands/upfynai-connect.md +46 -0
  232. package/commands/upfynai-disconnect.md +31 -0
  233. package/commands/upfynai-doctor.md +99 -0
  234. package/commands/upfynai-export.md +49 -0
  235. package/commands/upfynai-local.md +82 -0
  236. package/commands/upfynai-status.md +75 -0
  237. package/commands/upfynai-stop.md +49 -0
  238. package/commands/upfynai-uninstall.md +58 -0
  239. package/commands/upfynai.md +50 -0
  240. package/package.json +106 -47
  241. package/scripts/build-client.js +17 -0
  242. package/scripts/fix-node-pty.js +67 -0
  243. package/scripts/install-commands.js +78 -0
  244. package/server/claude-sdk.js +714 -0
  245. package/server/cli.js +419 -0
  246. package/server/constants/config.js +5 -0
  247. package/server/cursor-cli.js +270 -0
  248. package/server/database/auth.db +0 -0
  249. package/server/database/db.js +606 -0
  250. package/server/database/init.sql +70 -0
  251. package/server/index.js +2269 -0
  252. package/server/load-env.js +26 -0
  253. package/server/mcp-server.js +620 -0
  254. package/server/middleware/auth.js +158 -0
  255. package/server/openai-codex.js +403 -0
  256. package/server/projects.js +1849 -0
  257. package/server/relay-client.js +314 -0
  258. package/server/routes/agent.js +1231 -0
  259. package/server/routes/auth.js +220 -0
  260. package/server/routes/cli-auth.js +263 -0
  261. package/server/routes/codex.js +344 -0
  262. package/server/routes/commands.js +601 -0
  263. package/server/routes/cursor.js +808 -0
  264. package/server/routes/git.js +1165 -0
  265. package/server/routes/mcp-utils.js +48 -0
  266. package/server/routes/mcp.js +552 -0
  267. package/server/routes/payments.js +172 -0
  268. package/server/routes/projects.js +549 -0
  269. package/server/routes/settings.js +178 -0
  270. package/server/routes/taskmaster.js +1964 -0
  271. package/server/routes/user.js +106 -0
  272. package/server/utils/commandParser.js +303 -0
  273. package/server/utils/gitConfig.js +24 -0
  274. package/server/utils/mcp-detector.js +198 -0
  275. package/server/utils/taskmaster-websocket.js +129 -0
  276. package/shared/modelConstants.js +67 -0
  277. package/LICENSE +0 -22
  278. package/bin/cli.js +0 -86
  279. package/dist/assets/CanvasPanel-B48gAKVY.js +0 -538
  280. package/dist/assets/CanvasPanel-B48gAKVY.js.map +0 -1
  281. package/dist/assets/CanvasPanel-BsOG3EVs.css +0 -1
  282. package/dist/assets/index-CEhTwG68.css +0 -1
  283. package/dist/assets/index-GqAGWpJI.js +0 -70
  284. package/dist/assets/index-GqAGWpJI.js.map +0 -1
  285. package/dist/index.html +0 -18
  286. package/index.html +0 -17
  287. package/src/App.tsx +0 -226
  288. package/src/components/canvas/CanvasPanel.tsx +0 -62
  289. package/src/components/canvas/layout/graph-builder.ts +0 -136
  290. package/src/components/canvas/shapes/CompactionNodeShape.tsx +0 -76
  291. package/src/components/canvas/shapes/SessionNodeShape.tsx +0 -93
  292. package/src/components/canvas/shapes/StatuslineWidgetShape.tsx +0 -125
  293. package/src/components/canvas/shapes/TextResponseNodeShape.tsx +0 -86
  294. package/src/components/canvas/shapes/ToolCallNodeShape.tsx +0 -107
  295. package/src/components/canvas/shapes/ToolResultNodeShape.tsx +0 -87
  296. package/src/components/canvas/shapes/shared-styles.ts +0 -35
  297. package/src/components/chat/ChatPanel.tsx +0 -96
  298. package/src/components/chat/InputBar.tsx +0 -81
  299. package/src/components/chat/MessageList.tsx +0 -130
  300. package/src/components/chat/PermissionDialog.tsx +0 -70
  301. package/src/components/layout/FolderSelector.tsx +0 -152
  302. package/src/components/layout/ModelSelector.tsx +0 -65
  303. package/src/components/layout/SessionManager.tsx +0 -115
  304. package/src/components/statusline/StatuslineBar.tsx +0 -114
  305. package/src/main.tsx +0 -10
  306. package/src/server/claude-session.ts +0 -156
  307. package/src/server/index.ts +0 -149
  308. package/src/services/stream-consumer.ts +0 -330
  309. package/src/statusline-core/bin/statusline.sh +0 -121
  310. package/src/statusline-core/commands/sls-config.md +0 -42
  311. package/src/statusline-core/commands/sls-doctor.md +0 -35
  312. package/src/statusline-core/commands/sls-help.md +0 -48
  313. package/src/statusline-core/commands/sls-layout.md +0 -38
  314. package/src/statusline-core/commands/sls-preview.md +0 -34
  315. package/src/statusline-core/commands/sls-theme.md +0 -40
  316. package/src/statusline-core/installer.js +0 -228
  317. package/src/statusline-core/layouts/compact.sh +0 -21
  318. package/src/statusline-core/layouts/full.sh +0 -62
  319. package/src/statusline-core/layouts/standard.sh +0 -39
  320. package/src/statusline-core/lib/core.sh +0 -389
  321. package/src/statusline-core/lib/helpers.sh +0 -81
  322. package/src/statusline-core/lib/json-parser.sh +0 -71
  323. package/src/statusline-core/themes/catppuccin.sh +0 -32
  324. package/src/statusline-core/themes/default.sh +0 -37
  325. package/src/statusline-core/themes/gruvbox.sh +0 -32
  326. package/src/statusline-core/themes/nord.sh +0 -32
  327. package/src/statusline-core/themes/tokyo-night.sh +0 -32
  328. package/src/store/canvas-store.ts +0 -50
  329. package/src/store/chat-store.ts +0 -60
  330. package/src/store/permission-store.ts +0 -29
  331. package/src/store/session-store.ts +0 -52
  332. package/src/store/statusline-store.ts +0 -160
  333. package/src/styles/global.css +0 -117
  334. package/src/themes/index.ts +0 -149
  335. package/src/types/canvas-graph.ts +0 -24
  336. package/src/types/sdk-messages.ts +0 -156
  337. package/src/types/statusline-fields.ts +0 -67
  338. package/src/vite-env.d.ts +0 -1
  339. package/tsconfig.json +0 -26
  340. package/vite.config.ts +0 -24
@@ -0,0 +1,1964 @@
1
+ /**
2
+ * TASKMASTER API ROUTES
3
+ * ====================
4
+ *
5
+ * This module provides API endpoints for TaskMaster integration including:
6
+ * - .taskmaster folder detection in project directories
7
+ * - MCP server configuration detection
8
+ * - TaskMaster state and metadata management
9
+ */
10
+
11
+ import express from 'express';
12
+ import fs from 'fs';
13
+ import path from 'path';
14
+ import { promises as fsPromises } from 'fs';
15
+ import { spawn } from 'child_process';
16
+ import { fileURLToPath } from 'url';
17
+ import { dirname } from 'path';
18
+ import os from 'os';
19
+ import { extractProjectDirectory } from '../projects.js';
20
+ import { detectTaskMasterMCPServer } from '../utils/mcp-detector.js';
21
+ import { broadcastTaskMasterProjectUpdate, broadcastTaskMasterTasksUpdate } from '../utils/taskmaster-websocket.js';
22
+
23
+ const __filename = fileURLToPath(import.meta.url);
24
+ const __dirname = dirname(__filename);
25
+
26
+ const router = express.Router();
27
+
28
+ /**
29
+ * Check if TaskMaster CLI is installed globally
30
+ * @returns {Promise<Object>} Installation status result
31
+ */
32
+ async function checkTaskMasterInstallation() {
33
+ return new Promise((resolve) => {
34
+ // Check if task-master command is available
35
+ const whichCmd = process.platform === 'win32' ? 'where' : 'which';
36
+ const child = spawn(whichCmd, ['task-master'], {
37
+ stdio: ['ignore', 'pipe', 'pipe'],
38
+ shell: true
39
+ });
40
+
41
+ let output = '';
42
+ let errorOutput = '';
43
+
44
+ child.stdout.on('data', (data) => {
45
+ output += data.toString();
46
+ });
47
+
48
+ child.stderr.on('data', (data) => {
49
+ errorOutput += data.toString();
50
+ });
51
+
52
+ child.on('close', (code) => {
53
+ if (code === 0 && output.trim()) {
54
+ // TaskMaster is installed, get version
55
+ const versionChild = spawn('task-master', ['--version'], {
56
+ stdio: ['ignore', 'pipe', 'pipe'],
57
+ shell: true
58
+ });
59
+
60
+ let versionOutput = '';
61
+
62
+ versionChild.stdout.on('data', (data) => {
63
+ versionOutput += data.toString();
64
+ });
65
+
66
+ versionChild.on('close', (versionCode) => {
67
+ resolve({
68
+ isInstalled: true,
69
+ installPath: output.trim(),
70
+ version: versionCode === 0 ? versionOutput.trim() : 'unknown',
71
+ reason: null
72
+ });
73
+ });
74
+
75
+ versionChild.on('error', () => {
76
+ resolve({
77
+ isInstalled: true,
78
+ installPath: output.trim(),
79
+ version: 'unknown',
80
+ reason: null
81
+ });
82
+ });
83
+ } else {
84
+ resolve({
85
+ isInstalled: false,
86
+ installPath: null,
87
+ version: null,
88
+ reason: 'TaskMaster CLI not found in PATH'
89
+ });
90
+ }
91
+ });
92
+
93
+ child.on('error', (error) => {
94
+ resolve({
95
+ isInstalled: false,
96
+ installPath: null,
97
+ version: null,
98
+ reason: `Error checking installation: ${error.message}`
99
+ });
100
+ });
101
+ });
102
+ }
103
+
104
+ /**
105
+ * Detect .taskmaster folder presence in a given project directory
106
+ * @param {string} projectPath - Absolute path to project directory
107
+ * @returns {Promise<Object>} Detection result with status and metadata
108
+ */
109
+ async function detectTaskMasterFolder(projectPath) {
110
+ try {
111
+ const taskMasterPath = path.join(projectPath, '.taskmaster');
112
+
113
+ // Check if .taskmaster directory exists
114
+ try {
115
+ const stats = await fsPromises.stat(taskMasterPath);
116
+ if (!stats.isDirectory()) {
117
+ return {
118
+ hasTaskmaster: false,
119
+ reason: '.taskmaster exists but is not a directory'
120
+ };
121
+ }
122
+ } catch (error) {
123
+ if (error.code === 'ENOENT') {
124
+ return {
125
+ hasTaskmaster: false,
126
+ reason: '.taskmaster directory not found'
127
+ };
128
+ }
129
+ throw error;
130
+ }
131
+
132
+ // Check for key TaskMaster files
133
+ const keyFiles = [
134
+ 'tasks/tasks.json',
135
+ 'config.json'
136
+ ];
137
+
138
+ const fileStatus = {};
139
+ let hasEssentialFiles = true;
140
+
141
+ for (const file of keyFiles) {
142
+ const filePath = path.join(taskMasterPath, file);
143
+ try {
144
+ await fsPromises.access(filePath, fs.constants.R_OK);
145
+ fileStatus[file] = true;
146
+ } catch (error) {
147
+ fileStatus[file] = false;
148
+ if (file === 'tasks/tasks.json') {
149
+ hasEssentialFiles = false;
150
+ }
151
+ }
152
+ }
153
+
154
+ // Parse tasks.json if it exists for metadata
155
+ let taskMetadata = null;
156
+ if (fileStatus['tasks/tasks.json']) {
157
+ try {
158
+ const tasksPath = path.join(taskMasterPath, 'tasks/tasks.json');
159
+ const tasksContent = await fsPromises.readFile(tasksPath, 'utf8');
160
+ const tasksData = JSON.parse(tasksContent);
161
+
162
+ // Handle both tagged and legacy formats
163
+ let tasks = [];
164
+ if (tasksData.tasks) {
165
+ // Legacy format
166
+ tasks = tasksData.tasks;
167
+ } else {
168
+ // Tagged format - get tasks from all tags
169
+ Object.values(tasksData).forEach(tagData => {
170
+ if (tagData.tasks) {
171
+ tasks = tasks.concat(tagData.tasks);
172
+ }
173
+ });
174
+ }
175
+
176
+ // Calculate task statistics
177
+ const stats = tasks.reduce((acc, task) => {
178
+ acc.total++;
179
+ acc[task.status] = (acc[task.status] || 0) + 1;
180
+
181
+ // Count subtasks
182
+ if (task.subtasks) {
183
+ task.subtasks.forEach(subtask => {
184
+ acc.subtotalTasks++;
185
+ acc.subtasks = acc.subtasks || {};
186
+ acc.subtasks[subtask.status] = (acc.subtasks[subtask.status] || 0) + 1;
187
+ });
188
+ }
189
+
190
+ return acc;
191
+ }, {
192
+ total: 0,
193
+ subtotalTasks: 0,
194
+ pending: 0,
195
+ 'in-progress': 0,
196
+ done: 0,
197
+ review: 0,
198
+ deferred: 0,
199
+ cancelled: 0,
200
+ subtasks: {}
201
+ });
202
+
203
+ taskMetadata = {
204
+ taskCount: stats.total,
205
+ subtaskCount: stats.subtotalTasks,
206
+ completed: stats.done || 0,
207
+ pending: stats.pending || 0,
208
+ inProgress: stats['in-progress'] || 0,
209
+ review: stats.review || 0,
210
+ completionPercentage: stats.total > 0 ? Math.round((stats.done / stats.total) * 100) : 0,
211
+ lastModified: (await fsPromises.stat(tasksPath)).mtime.toISOString()
212
+ };
213
+ } catch (parseError) {
214
+ console.warn('Failed to parse tasks.json:', parseError.message);
215
+ taskMetadata = { error: 'Failed to parse tasks.json' };
216
+ }
217
+ }
218
+
219
+ return {
220
+ hasTaskmaster: true,
221
+ hasEssentialFiles,
222
+ files: fileStatus,
223
+ metadata: taskMetadata,
224
+ path: taskMasterPath
225
+ };
226
+
227
+ } catch (error) {
228
+ console.error('Error detecting TaskMaster folder:', error);
229
+ return {
230
+ hasTaskmaster: false,
231
+ reason: `Error checking directory: ${error.message}`
232
+ };
233
+ }
234
+ }
235
+
236
+ // MCP detection is now handled by the centralized utility
237
+
238
+ // API Routes
239
+
240
+ /**
241
+ * GET /api/taskmaster/installation-status
242
+ * Check if TaskMaster CLI is installed on the system
243
+ */
244
+ router.get('/installation-status', async (req, res) => {
245
+ try {
246
+ const installationStatus = await checkTaskMasterInstallation();
247
+
248
+ // Also check for MCP server configuration
249
+ const mcpStatus = await detectTaskMasterMCPServer();
250
+
251
+ res.json({
252
+ success: true,
253
+ installation: installationStatus,
254
+ mcpServer: mcpStatus,
255
+ isReady: installationStatus.isInstalled && mcpStatus.hasMCPServer
256
+ });
257
+ } catch (error) {
258
+ console.error('Error checking TaskMaster installation:', error);
259
+ res.status(500).json({
260
+ success: false,
261
+ error: 'Failed to check TaskMaster installation status',
262
+ installation: {
263
+ isInstalled: false,
264
+ reason: `Server error: ${error.message}`
265
+ },
266
+ mcpServer: {
267
+ hasMCPServer: false,
268
+ reason: `Server error: ${error.message}`
269
+ },
270
+ isReady: false
271
+ });
272
+ }
273
+ });
274
+
275
+ /**
276
+ * GET /api/taskmaster/detect/:projectName
277
+ * Detect TaskMaster configuration for a specific project
278
+ */
279
+ router.get('/detect/:projectName', async (req, res) => {
280
+ try {
281
+ const { projectName } = req.params;
282
+
283
+ // Use the existing extractProjectDirectory function to get actual project path
284
+ let projectPath;
285
+ try {
286
+ projectPath = await extractProjectDirectory(projectName);
287
+ } catch (error) {
288
+ console.error('Error extracting project directory:', error);
289
+ return res.status(404).json({
290
+ error: 'Project path not found',
291
+ projectName,
292
+ message: error.message
293
+ });
294
+ }
295
+
296
+ // Verify the project path exists
297
+ try {
298
+ await fsPromises.access(projectPath, fs.constants.R_OK);
299
+ } catch (error) {
300
+ return res.status(404).json({
301
+ error: 'Project path not accessible',
302
+ projectPath,
303
+ projectName,
304
+ message: error.message
305
+ });
306
+ }
307
+
308
+ // Run detection in parallel
309
+ const [taskMasterResult, mcpResult] = await Promise.all([
310
+ detectTaskMasterFolder(projectPath),
311
+ detectTaskMasterMCPServer()
312
+ ]);
313
+
314
+ // Determine overall status
315
+ let status = 'not-configured';
316
+ if (taskMasterResult.hasTaskmaster && taskMasterResult.hasEssentialFiles) {
317
+ if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
318
+ status = 'fully-configured';
319
+ } else {
320
+ status = 'taskmaster-only';
321
+ }
322
+ } else if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
323
+ status = 'mcp-only';
324
+ }
325
+
326
+ const responseData = {
327
+ projectName,
328
+ projectPath,
329
+ status,
330
+ taskmaster: taskMasterResult,
331
+ mcp: mcpResult,
332
+ timestamp: new Date().toISOString()
333
+ };
334
+
335
+ res.json(responseData);
336
+
337
+ } catch (error) {
338
+ console.error('TaskMaster detection error:', error);
339
+ res.status(500).json({
340
+ error: 'Failed to detect TaskMaster configuration',
341
+ message: error.message
342
+ });
343
+ }
344
+ });
345
+
346
+ /**
347
+ * GET /api/taskmaster/detect-all
348
+ * Detect TaskMaster configuration for all known projects
349
+ * This endpoint works with the existing projects system
350
+ */
351
+ router.get('/detect-all', async (req, res) => {
352
+ try {
353
+ // Import getProjects from the projects module
354
+ const { getProjects } = await import('../projects.js');
355
+ const projects = await getProjects();
356
+
357
+ // Run detection for all projects in parallel
358
+ const detectionPromises = projects.map(async (project) => {
359
+ try {
360
+ // Use the project's fullPath if available, otherwise extract the directory
361
+ let projectPath;
362
+ if (project.fullPath) {
363
+ projectPath = project.fullPath;
364
+ } else {
365
+ try {
366
+ projectPath = await extractProjectDirectory(project.name);
367
+ } catch (error) {
368
+ throw new Error(`Failed to extract project directory: ${error.message}`);
369
+ }
370
+ }
371
+
372
+ const [taskMasterResult, mcpResult] = await Promise.all([
373
+ detectTaskMasterFolder(projectPath),
374
+ detectTaskMasterMCPServer()
375
+ ]);
376
+
377
+ // Determine status
378
+ let status = 'not-configured';
379
+ if (taskMasterResult.hasTaskmaster && taskMasterResult.hasEssentialFiles) {
380
+ if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
381
+ status = 'fully-configured';
382
+ } else {
383
+ status = 'taskmaster-only';
384
+ }
385
+ } else if (mcpResult.hasMCPServer && mcpResult.isConfigured) {
386
+ status = 'mcp-only';
387
+ }
388
+
389
+ return {
390
+ projectName: project.name,
391
+ displayName: project.displayName,
392
+ projectPath,
393
+ status,
394
+ taskmaster: taskMasterResult,
395
+ mcp: mcpResult
396
+ };
397
+ } catch (error) {
398
+ return {
399
+ projectName: project.name,
400
+ displayName: project.displayName,
401
+ status: 'error',
402
+ error: error.message
403
+ };
404
+ }
405
+ });
406
+
407
+ const results = await Promise.all(detectionPromises);
408
+
409
+ res.json({
410
+ projects: results,
411
+ summary: {
412
+ total: results.length,
413
+ fullyConfigured: results.filter(p => p.status === 'fully-configured').length,
414
+ taskmasterOnly: results.filter(p => p.status === 'taskmaster-only').length,
415
+ mcpOnly: results.filter(p => p.status === 'mcp-only').length,
416
+ notConfigured: results.filter(p => p.status === 'not-configured').length,
417
+ errors: results.filter(p => p.status === 'error').length
418
+ },
419
+ timestamp: new Date().toISOString()
420
+ });
421
+
422
+ } catch (error) {
423
+ console.error('Bulk TaskMaster detection error:', error);
424
+ res.status(500).json({
425
+ error: 'Failed to detect TaskMaster configuration for projects',
426
+ message: error.message
427
+ });
428
+ }
429
+ });
430
+
431
+ /**
432
+ * POST /api/taskmaster/initialize/:projectName
433
+ * Initialize TaskMaster in a project (placeholder for future CLI integration)
434
+ */
435
+ router.post('/initialize/:projectName', async (req, res) => {
436
+ try {
437
+ const { projectName } = req.params;
438
+ const { rules } = req.body; // Optional rule profiles
439
+
440
+ // This will be implemented in a later subtask with CLI integration
441
+ res.status(501).json({
442
+ error: 'TaskMaster initialization not yet implemented',
443
+ message: 'This endpoint will execute task-master init via CLI in a future update',
444
+ projectName,
445
+ rules
446
+ });
447
+
448
+ } catch (error) {
449
+ console.error('TaskMaster initialization error:', error);
450
+ res.status(500).json({
451
+ error: 'Failed to initialize TaskMaster',
452
+ message: error.message
453
+ });
454
+ }
455
+ });
456
+
457
+ /**
458
+ * GET /api/taskmaster/next/:projectName
459
+ * Get the next recommended task using task-master CLI
460
+ */
461
+ router.get('/next/:projectName', async (req, res) => {
462
+ try {
463
+ const { projectName } = req.params;
464
+
465
+ // Get project path
466
+ let projectPath;
467
+ try {
468
+ projectPath = await extractProjectDirectory(projectName);
469
+ } catch (error) {
470
+ return res.status(404).json({
471
+ error: 'Project not found',
472
+ message: `Project "${projectName}" does not exist`
473
+ });
474
+ }
475
+
476
+ // Try to execute task-master next command
477
+ try {
478
+ const { spawn } = await import('child_process');
479
+
480
+ const nextTaskCommand = spawn('task-master', ['next'], {
481
+ cwd: projectPath,
482
+ stdio: ['pipe', 'pipe', 'pipe']
483
+ });
484
+
485
+ let stdout = '';
486
+ let stderr = '';
487
+
488
+ nextTaskCommand.stdout.on('data', (data) => {
489
+ stdout += data.toString();
490
+ });
491
+
492
+ nextTaskCommand.stderr.on('data', (data) => {
493
+ stderr += data.toString();
494
+ });
495
+
496
+ await new Promise((resolve, reject) => {
497
+ nextTaskCommand.on('close', (code) => {
498
+ if (code === 0) {
499
+ resolve();
500
+ } else {
501
+ reject(new Error(`task-master next failed with code ${code}: ${stderr}`));
502
+ }
503
+ });
504
+
505
+ nextTaskCommand.on('error', (error) => {
506
+ reject(error);
507
+ });
508
+ });
509
+
510
+ // Parse the output - task-master next usually returns JSON
511
+ let nextTaskData = null;
512
+ if (stdout.trim()) {
513
+ try {
514
+ nextTaskData = JSON.parse(stdout);
515
+ } catch (parseError) {
516
+ // If not JSON, treat as plain text
517
+ nextTaskData = { message: stdout.trim() };
518
+ }
519
+ }
520
+
521
+ res.json({
522
+ projectName,
523
+ projectPath,
524
+ nextTask: nextTaskData,
525
+ timestamp: new Date().toISOString()
526
+ });
527
+
528
+ } catch (cliError) {
529
+ console.warn('Failed to execute task-master CLI:', cliError.message);
530
+
531
+ // Fallback to loading tasks and finding next one locally
532
+ // Use localhost to bypass proxy for internal server-to-server calls
533
+ const tasksResponse = await fetch(`http://localhost:${process.env.PORT || 3001}/api/taskmaster/tasks/${encodeURIComponent(projectName)}`, {
534
+ headers: {
535
+ 'Authorization': req.headers.authorization
536
+ }
537
+ });
538
+
539
+ if (tasksResponse.ok) {
540
+ const tasksData = await tasksResponse.json();
541
+ const nextTask = tasksData.tasks?.find(task =>
542
+ task.status === 'pending' || task.status === 'in-progress'
543
+ ) || null;
544
+
545
+ res.json({
546
+ projectName,
547
+ projectPath,
548
+ nextTask,
549
+ fallback: true,
550
+ message: 'Used fallback method (CLI not available)',
551
+ timestamp: new Date().toISOString()
552
+ });
553
+ } else {
554
+ throw new Error('Failed to load tasks via fallback method');
555
+ }
556
+ }
557
+
558
+ } catch (error) {
559
+ console.error('TaskMaster next task error:', error);
560
+ res.status(500).json({
561
+ error: 'Failed to get next task',
562
+ message: error.message
563
+ });
564
+ }
565
+ });
566
+
567
+ /**
568
+ * GET /api/taskmaster/tasks/:projectName
569
+ * Load actual tasks from .taskmaster/tasks/tasks.json
570
+ */
571
+ router.get('/tasks/:projectName', async (req, res) => {
572
+ try {
573
+ const { projectName } = req.params;
574
+
575
+ // Get project path
576
+ let projectPath;
577
+ try {
578
+ projectPath = await extractProjectDirectory(projectName);
579
+ } catch (error) {
580
+ return res.status(404).json({
581
+ error: 'Project not found',
582
+ message: `Project "${projectName}" does not exist`
583
+ });
584
+ }
585
+
586
+ const taskMasterPath = path.join(projectPath, '.taskmaster');
587
+ const tasksFilePath = path.join(taskMasterPath, 'tasks', 'tasks.json');
588
+
589
+ // Check if tasks file exists
590
+ try {
591
+ await fsPromises.access(tasksFilePath);
592
+ } catch (error) {
593
+ return res.json({
594
+ projectName,
595
+ tasks: [],
596
+ message: 'No tasks.json file found'
597
+ });
598
+ }
599
+
600
+ // Read and parse tasks file
601
+ try {
602
+ const tasksContent = await fsPromises.readFile(tasksFilePath, 'utf8');
603
+ const tasksData = JSON.parse(tasksContent);
604
+
605
+ let tasks = [];
606
+ let currentTag = 'master';
607
+
608
+ // Handle both tagged and legacy formats
609
+ if (Array.isArray(tasksData)) {
610
+ // Legacy format
611
+ tasks = tasksData;
612
+ } else if (tasksData.tasks) {
613
+ // Simple format with tasks array
614
+ tasks = tasksData.tasks;
615
+ } else {
616
+ // Tagged format - get tasks from current tag or master
617
+ if (tasksData[currentTag] && tasksData[currentTag].tasks) {
618
+ tasks = tasksData[currentTag].tasks;
619
+ } else if (tasksData.master && tasksData.master.tasks) {
620
+ tasks = tasksData.master.tasks;
621
+ } else {
622
+ // Get tasks from first available tag
623
+ const firstTag = Object.keys(tasksData).find(key =>
624
+ tasksData[key].tasks && Array.isArray(tasksData[key].tasks)
625
+ );
626
+ if (firstTag) {
627
+ tasks = tasksData[firstTag].tasks;
628
+ currentTag = firstTag;
629
+ }
630
+ }
631
+ }
632
+
633
+ // Transform tasks to ensure all have required fields
634
+ const transformedTasks = tasks.map(task => ({
635
+ id: task.id,
636
+ title: task.title || 'Untitled Task',
637
+ description: task.description || '',
638
+ status: task.status || 'pending',
639
+ priority: task.priority || 'medium',
640
+ dependencies: task.dependencies || [],
641
+ createdAt: task.createdAt || task.created || new Date().toISOString(),
642
+ updatedAt: task.updatedAt || task.updated || new Date().toISOString(),
643
+ details: task.details || '',
644
+ testStrategy: task.testStrategy || task.test_strategy || '',
645
+ subtasks: task.subtasks || []
646
+ }));
647
+
648
+ res.json({
649
+ projectName,
650
+ projectPath,
651
+ tasks: transformedTasks,
652
+ currentTag,
653
+ totalTasks: transformedTasks.length,
654
+ tasksByStatus: {
655
+ pending: transformedTasks.filter(t => t.status === 'pending').length,
656
+ 'in-progress': transformedTasks.filter(t => t.status === 'in-progress').length,
657
+ done: transformedTasks.filter(t => t.status === 'done').length,
658
+ review: transformedTasks.filter(t => t.status === 'review').length,
659
+ deferred: transformedTasks.filter(t => t.status === 'deferred').length,
660
+ cancelled: transformedTasks.filter(t => t.status === 'cancelled').length
661
+ },
662
+ timestamp: new Date().toISOString()
663
+ });
664
+
665
+ } catch (parseError) {
666
+ console.error('Failed to parse tasks.json:', parseError);
667
+ return res.status(500).json({
668
+ error: 'Failed to parse tasks file',
669
+ message: parseError.message
670
+ });
671
+ }
672
+
673
+ } catch (error) {
674
+ console.error('TaskMaster tasks loading error:', error);
675
+ res.status(500).json({
676
+ error: 'Failed to load TaskMaster tasks',
677
+ message: error.message
678
+ });
679
+ }
680
+ });
681
+
682
+ /**
683
+ * GET /api/taskmaster/prd/:projectName
684
+ * List all PRD files in the project's .taskmaster/docs directory
685
+ */
686
+ router.get('/prd/:projectName', async (req, res) => {
687
+ try {
688
+ const { projectName } = req.params;
689
+
690
+ // Get project path
691
+ let projectPath;
692
+ try {
693
+ projectPath = await extractProjectDirectory(projectName);
694
+ } catch (error) {
695
+ return res.status(404).json({
696
+ error: 'Project not found',
697
+ message: `Project "${projectName}" does not exist`
698
+ });
699
+ }
700
+
701
+ const docsPath = path.join(projectPath, '.taskmaster', 'docs');
702
+
703
+ // Check if docs directory exists
704
+ try {
705
+ await fsPromises.access(docsPath, fs.constants.R_OK);
706
+ } catch (error) {
707
+ return res.json({
708
+ projectName,
709
+ prdFiles: [],
710
+ message: 'No .taskmaster/docs directory found'
711
+ });
712
+ }
713
+
714
+ // Read directory and filter for PRD files
715
+ try {
716
+ const files = await fsPromises.readdir(docsPath);
717
+ const prdFiles = [];
718
+
719
+ for (const file of files) {
720
+ const filePath = path.join(docsPath, file);
721
+ const stats = await fsPromises.stat(filePath);
722
+
723
+ if (stats.isFile() && (file.endsWith('.txt') || file.endsWith('.md'))) {
724
+ prdFiles.push({
725
+ name: file,
726
+ path: path.relative(projectPath, filePath),
727
+ size: stats.size,
728
+ modified: stats.mtime.toISOString(),
729
+ created: stats.birthtime.toISOString()
730
+ });
731
+ }
732
+ }
733
+
734
+ res.json({
735
+ projectName,
736
+ projectPath,
737
+ prdFiles: prdFiles.sort((a, b) => new Date(b.modified) - new Date(a.modified)),
738
+ timestamp: new Date().toISOString()
739
+ });
740
+
741
+ } catch (readError) {
742
+ console.error('Error reading docs directory:', readError);
743
+ return res.status(500).json({
744
+ error: 'Failed to read PRD files',
745
+ message: readError.message
746
+ });
747
+ }
748
+
749
+ } catch (error) {
750
+ console.error('PRD list error:', error);
751
+ res.status(500).json({
752
+ error: 'Failed to list PRD files',
753
+ message: error.message
754
+ });
755
+ }
756
+ });
757
+
758
+ /**
759
+ * POST /api/taskmaster/prd/:projectName
760
+ * Create or update a PRD file in the project's .taskmaster/docs directory
761
+ */
762
+ router.post('/prd/:projectName', async (req, res) => {
763
+ try {
764
+ const { projectName } = req.params;
765
+ const { fileName, content } = req.body;
766
+
767
+ if (!fileName || !content) {
768
+ return res.status(400).json({
769
+ error: 'Missing required fields',
770
+ message: 'fileName and content are required'
771
+ });
772
+ }
773
+
774
+ // Validate filename
775
+ if (!fileName.match(/^[\w\-. ]+\.(txt|md)$/)) {
776
+ return res.status(400).json({
777
+ error: 'Invalid filename',
778
+ message: 'Filename must end with .txt or .md and contain only alphanumeric characters, spaces, dots, and dashes'
779
+ });
780
+ }
781
+
782
+ // Get project path
783
+ let projectPath;
784
+ try {
785
+ projectPath = await extractProjectDirectory(projectName);
786
+ } catch (error) {
787
+ return res.status(404).json({
788
+ error: 'Project not found',
789
+ message: `Project "${projectName}" does not exist`
790
+ });
791
+ }
792
+
793
+ const docsPath = path.join(projectPath, '.taskmaster', 'docs');
794
+ const filePath = path.join(docsPath, fileName);
795
+
796
+ // Ensure docs directory exists
797
+ try {
798
+ await fsPromises.mkdir(docsPath, { recursive: true });
799
+ } catch (error) {
800
+ console.error('Failed to create docs directory:', error);
801
+ return res.status(500).json({
802
+ error: 'Failed to create directory',
803
+ message: error.message
804
+ });
805
+ }
806
+
807
+ // Write the PRD file
808
+ try {
809
+ await fsPromises.writeFile(filePath, content, 'utf8');
810
+
811
+ // Get file stats
812
+ const stats = await fsPromises.stat(filePath);
813
+
814
+ res.json({
815
+ projectName,
816
+ projectPath,
817
+ fileName,
818
+ filePath: path.relative(projectPath, filePath),
819
+ size: stats.size,
820
+ created: stats.birthtime.toISOString(),
821
+ modified: stats.mtime.toISOString(),
822
+ message: 'PRD file saved successfully',
823
+ timestamp: new Date().toISOString()
824
+ });
825
+
826
+ } catch (writeError) {
827
+ console.error('Failed to write PRD file:', writeError);
828
+ return res.status(500).json({
829
+ error: 'Failed to write PRD file',
830
+ message: writeError.message
831
+ });
832
+ }
833
+
834
+ } catch (error) {
835
+ console.error('PRD create/update error:', error);
836
+ res.status(500).json({
837
+ error: 'Failed to create/update PRD file',
838
+ message: error.message
839
+ });
840
+ }
841
+ });
842
+
843
+ /**
844
+ * GET /api/taskmaster/prd/:projectName/:fileName
845
+ * Get content of a specific PRD file
846
+ */
847
+ router.get('/prd/:projectName/:fileName', async (req, res) => {
848
+ try {
849
+ const { projectName, fileName } = req.params;
850
+
851
+ // Get project path
852
+ let projectPath;
853
+ try {
854
+ projectPath = await extractProjectDirectory(projectName);
855
+ } catch (error) {
856
+ return res.status(404).json({
857
+ error: 'Project not found',
858
+ message: `Project "${projectName}" does not exist`
859
+ });
860
+ }
861
+
862
+ const filePath = path.join(projectPath, '.taskmaster', 'docs', fileName);
863
+
864
+ // Check if file exists
865
+ try {
866
+ await fsPromises.access(filePath, fs.constants.R_OK);
867
+ } catch (error) {
868
+ return res.status(404).json({
869
+ error: 'PRD file not found',
870
+ message: `File "${fileName}" does not exist`
871
+ });
872
+ }
873
+
874
+ // Read file content
875
+ try {
876
+ const content = await fsPromises.readFile(filePath, 'utf8');
877
+ const stats = await fsPromises.stat(filePath);
878
+
879
+ res.json({
880
+ projectName,
881
+ projectPath,
882
+ fileName,
883
+ filePath: path.relative(projectPath, filePath),
884
+ content,
885
+ size: stats.size,
886
+ created: stats.birthtime.toISOString(),
887
+ modified: stats.mtime.toISOString(),
888
+ timestamp: new Date().toISOString()
889
+ });
890
+
891
+ } catch (readError) {
892
+ console.error('Failed to read PRD file:', readError);
893
+ return res.status(500).json({
894
+ error: 'Failed to read PRD file',
895
+ message: readError.message
896
+ });
897
+ }
898
+
899
+ } catch (error) {
900
+ console.error('PRD read error:', error);
901
+ res.status(500).json({
902
+ error: 'Failed to read PRD file',
903
+ message: error.message
904
+ });
905
+ }
906
+ });
907
+
908
+ /**
909
+ * DELETE /api/taskmaster/prd/:projectName/:fileName
910
+ * Delete a specific PRD file
911
+ */
912
+ router.delete('/prd/:projectName/:fileName', async (req, res) => {
913
+ try {
914
+ const { projectName, fileName } = req.params;
915
+
916
+ // Get project path
917
+ let projectPath;
918
+ try {
919
+ projectPath = await extractProjectDirectory(projectName);
920
+ } catch (error) {
921
+ return res.status(404).json({
922
+ error: 'Project not found',
923
+ message: `Project "${projectName}" does not exist`
924
+ });
925
+ }
926
+
927
+ const filePath = path.join(projectPath, '.taskmaster', 'docs', fileName);
928
+
929
+ // Check if file exists
930
+ try {
931
+ await fsPromises.access(filePath, fs.constants.F_OK);
932
+ } catch (error) {
933
+ return res.status(404).json({
934
+ error: 'PRD file not found',
935
+ message: `File "${fileName}" does not exist`
936
+ });
937
+ }
938
+
939
+ // Delete the file
940
+ try {
941
+ await fsPromises.unlink(filePath);
942
+
943
+ res.json({
944
+ projectName,
945
+ projectPath,
946
+ fileName,
947
+ message: 'PRD file deleted successfully',
948
+ timestamp: new Date().toISOString()
949
+ });
950
+
951
+ } catch (deleteError) {
952
+ console.error('Failed to delete PRD file:', deleteError);
953
+ return res.status(500).json({
954
+ error: 'Failed to delete PRD file',
955
+ message: deleteError.message
956
+ });
957
+ }
958
+
959
+ } catch (error) {
960
+ console.error('PRD delete error:', error);
961
+ res.status(500).json({
962
+ error: 'Failed to delete PRD file',
963
+ message: error.message
964
+ });
965
+ }
966
+ });
967
+
968
+ /**
969
+ * POST /api/taskmaster/init/:projectName
970
+ * Initialize TaskMaster in a project
971
+ */
972
+ router.post('/init/:projectName', async (req, res) => {
973
+ try {
974
+ const { projectName } = req.params;
975
+
976
+ // Get project path
977
+ let projectPath;
978
+ try {
979
+ projectPath = await extractProjectDirectory(projectName);
980
+ } catch (error) {
981
+ return res.status(404).json({
982
+ error: 'Project not found',
983
+ message: `Project "${projectName}" does not exist`
984
+ });
985
+ }
986
+
987
+ // Check if TaskMaster is already initialized
988
+ const taskMasterPath = path.join(projectPath, '.taskmaster');
989
+ try {
990
+ await fsPromises.access(taskMasterPath, fs.constants.F_OK);
991
+ return res.status(400).json({
992
+ error: 'TaskMaster already initialized',
993
+ message: 'TaskMaster is already configured for this project'
994
+ });
995
+ } catch (error) {
996
+ // Directory doesn't exist, we can proceed
997
+ }
998
+
999
+ // Run taskmaster init command
1000
+ const initProcess = spawn('npx', ['task-master', 'init'], {
1001
+ cwd: projectPath,
1002
+ stdio: ['pipe', 'pipe', 'pipe']
1003
+ });
1004
+
1005
+ let stdout = '';
1006
+ let stderr = '';
1007
+
1008
+ initProcess.stdout.on('data', (data) => {
1009
+ stdout += data.toString();
1010
+ });
1011
+
1012
+ initProcess.stderr.on('data', (data) => {
1013
+ stderr += data.toString();
1014
+ });
1015
+
1016
+ initProcess.on('close', (code) => {
1017
+ if (code === 0) {
1018
+ // Broadcast TaskMaster project update via WebSocket
1019
+ if (req.app.locals.wss) {
1020
+ broadcastTaskMasterProjectUpdate(
1021
+ req.app.locals.wss,
1022
+ projectName,
1023
+ { hasTaskmaster: true, status: 'initialized' }
1024
+ );
1025
+ }
1026
+
1027
+ res.json({
1028
+ projectName,
1029
+ projectPath,
1030
+ message: 'TaskMaster initialized successfully',
1031
+ output: stdout,
1032
+ timestamp: new Date().toISOString()
1033
+ });
1034
+ } else {
1035
+ console.error('TaskMaster init failed:', stderr);
1036
+ res.status(500).json({
1037
+ error: 'Failed to initialize TaskMaster',
1038
+ message: stderr || stdout,
1039
+ code
1040
+ });
1041
+ }
1042
+ });
1043
+
1044
+ // Send 'yes' responses to automated prompts
1045
+ initProcess.stdin.write('yes\n');
1046
+ initProcess.stdin.end();
1047
+
1048
+ } catch (error) {
1049
+ console.error('TaskMaster init error:', error);
1050
+ res.status(500).json({
1051
+ error: 'Failed to initialize TaskMaster',
1052
+ message: error.message
1053
+ });
1054
+ }
1055
+ });
1056
+
1057
+ /**
1058
+ * POST /api/taskmaster/add-task/:projectName
1059
+ * Add a new task to the project
1060
+ */
1061
+ router.post('/add-task/:projectName', async (req, res) => {
1062
+ try {
1063
+ const { projectName } = req.params;
1064
+ const { prompt, title, description, priority = 'medium', dependencies } = req.body;
1065
+
1066
+ if (!prompt && (!title || !description)) {
1067
+ return res.status(400).json({
1068
+ error: 'Missing required parameters',
1069
+ message: 'Either "prompt" or both "title" and "description" are required'
1070
+ });
1071
+ }
1072
+
1073
+ // Get project path
1074
+ let projectPath;
1075
+ try {
1076
+ projectPath = await extractProjectDirectory(projectName);
1077
+ } catch (error) {
1078
+ return res.status(404).json({
1079
+ error: 'Project not found',
1080
+ message: `Project "${projectName}" does not exist`
1081
+ });
1082
+ }
1083
+
1084
+ // Build the task-master add-task command
1085
+ const args = ['task-master-ai', 'add-task'];
1086
+
1087
+ if (prompt) {
1088
+ args.push('--prompt', prompt);
1089
+ args.push('--research'); // Use research for AI-generated tasks
1090
+ } else {
1091
+ args.push('--prompt', `Create a task titled "${title}" with description: ${description}`);
1092
+ }
1093
+
1094
+ if (priority) {
1095
+ args.push('--priority', priority);
1096
+ }
1097
+
1098
+ if (dependencies) {
1099
+ args.push('--dependencies', dependencies);
1100
+ }
1101
+
1102
+ // Run task-master add-task command
1103
+ const addTaskProcess = spawn('npx', args, {
1104
+ cwd: projectPath,
1105
+ stdio: ['pipe', 'pipe', 'pipe']
1106
+ });
1107
+
1108
+ let stdout = '';
1109
+ let stderr = '';
1110
+
1111
+ addTaskProcess.stdout.on('data', (data) => {
1112
+ stdout += data.toString();
1113
+ });
1114
+
1115
+ addTaskProcess.stderr.on('data', (data) => {
1116
+ stderr += data.toString();
1117
+ });
1118
+
1119
+ addTaskProcess.on('close', (code) => {
1120
+ console.log('Add task process completed with code:', code);
1121
+ console.log('Stdout:', stdout);
1122
+ console.log('Stderr:', stderr);
1123
+
1124
+ if (code === 0) {
1125
+ // Broadcast task update via WebSocket
1126
+ if (req.app.locals.wss) {
1127
+ broadcastTaskMasterTasksUpdate(
1128
+ req.app.locals.wss,
1129
+ projectName
1130
+ );
1131
+ }
1132
+
1133
+ res.json({
1134
+ projectName,
1135
+ projectPath,
1136
+ message: 'Task added successfully',
1137
+ output: stdout,
1138
+ timestamp: new Date().toISOString()
1139
+ });
1140
+ } else {
1141
+ console.error('Add task failed:', stderr);
1142
+ res.status(500).json({
1143
+ error: 'Failed to add task',
1144
+ message: stderr || stdout,
1145
+ code
1146
+ });
1147
+ }
1148
+ });
1149
+
1150
+ addTaskProcess.stdin.end();
1151
+
1152
+ } catch (error) {
1153
+ console.error('Add task error:', error);
1154
+ res.status(500).json({
1155
+ error: 'Failed to add task',
1156
+ message: error.message
1157
+ });
1158
+ }
1159
+ });
1160
+
1161
+ /**
1162
+ * PUT /api/taskmaster/update-task/:projectName/:taskId
1163
+ * Update a specific task using TaskMaster CLI
1164
+ */
1165
+ router.put('/update-task/:projectName/:taskId', async (req, res) => {
1166
+ try {
1167
+ const { projectName, taskId } = req.params;
1168
+ const { title, description, status, priority, details } = req.body;
1169
+
1170
+ // Get project path
1171
+ let projectPath;
1172
+ try {
1173
+ projectPath = await extractProjectDirectory(projectName);
1174
+ } catch (error) {
1175
+ return res.status(404).json({
1176
+ error: 'Project not found',
1177
+ message: `Project "${projectName}" does not exist`
1178
+ });
1179
+ }
1180
+
1181
+ // If only updating status, use set-status command
1182
+ if (status && Object.keys(req.body).length === 1) {
1183
+ const setStatusProcess = spawn('npx', ['task-master-ai', 'set-status', `--id=${taskId}`, `--status=${status}`], {
1184
+ cwd: projectPath,
1185
+ stdio: ['pipe', 'pipe', 'pipe']
1186
+ });
1187
+
1188
+ let stdout = '';
1189
+ let stderr = '';
1190
+
1191
+ setStatusProcess.stdout.on('data', (data) => {
1192
+ stdout += data.toString();
1193
+ });
1194
+
1195
+ setStatusProcess.stderr.on('data', (data) => {
1196
+ stderr += data.toString();
1197
+ });
1198
+
1199
+ setStatusProcess.on('close', (code) => {
1200
+ if (code === 0) {
1201
+ // Broadcast task update via WebSocket
1202
+ if (req.app.locals.wss) {
1203
+ broadcastTaskMasterTasksUpdate(req.app.locals.wss, projectName);
1204
+ }
1205
+
1206
+ res.json({
1207
+ projectName,
1208
+ projectPath,
1209
+ taskId,
1210
+ message: 'Task status updated successfully',
1211
+ output: stdout,
1212
+ timestamp: new Date().toISOString()
1213
+ });
1214
+ } else {
1215
+ console.error('Set task status failed:', stderr);
1216
+ res.status(500).json({
1217
+ error: 'Failed to update task status',
1218
+ message: stderr || stdout,
1219
+ code
1220
+ });
1221
+ }
1222
+ });
1223
+
1224
+ setStatusProcess.stdin.end();
1225
+ } else {
1226
+ // For other updates, use update-task command with a prompt describing the changes
1227
+ const updates = [];
1228
+ if (title) updates.push(`title: "${title}"`);
1229
+ if (description) updates.push(`description: "${description}"`);
1230
+ if (priority) updates.push(`priority: "${priority}"`);
1231
+ if (details) updates.push(`details: "${details}"`);
1232
+
1233
+ const prompt = `Update task with the following changes: ${updates.join(', ')}`;
1234
+
1235
+ const updateProcess = spawn('npx', ['task-master-ai', 'update-task', `--id=${taskId}`, `--prompt=${prompt}`], {
1236
+ cwd: projectPath,
1237
+ stdio: ['pipe', 'pipe', 'pipe']
1238
+ });
1239
+
1240
+ let stdout = '';
1241
+ let stderr = '';
1242
+
1243
+ updateProcess.stdout.on('data', (data) => {
1244
+ stdout += data.toString();
1245
+ });
1246
+
1247
+ updateProcess.stderr.on('data', (data) => {
1248
+ stderr += data.toString();
1249
+ });
1250
+
1251
+ updateProcess.on('close', (code) => {
1252
+ if (code === 0) {
1253
+ // Broadcast task update via WebSocket
1254
+ if (req.app.locals.wss) {
1255
+ broadcastTaskMasterTasksUpdate(req.app.locals.wss, projectName);
1256
+ }
1257
+
1258
+ res.json({
1259
+ projectName,
1260
+ projectPath,
1261
+ taskId,
1262
+ message: 'Task updated successfully',
1263
+ output: stdout,
1264
+ timestamp: new Date().toISOString()
1265
+ });
1266
+ } else {
1267
+ console.error('Update task failed:', stderr);
1268
+ res.status(500).json({
1269
+ error: 'Failed to update task',
1270
+ message: stderr || stdout,
1271
+ code
1272
+ });
1273
+ }
1274
+ });
1275
+
1276
+ updateProcess.stdin.end();
1277
+ }
1278
+
1279
+ } catch (error) {
1280
+ console.error('Update task error:', error);
1281
+ res.status(500).json({
1282
+ error: 'Failed to update task',
1283
+ message: error.message
1284
+ });
1285
+ }
1286
+ });
1287
+
1288
+ /**
1289
+ * POST /api/taskmaster/parse-prd/:projectName
1290
+ * Parse a PRD file to generate tasks
1291
+ */
1292
+ router.post('/parse-prd/:projectName', async (req, res) => {
1293
+ try {
1294
+ const { projectName } = req.params;
1295
+ const { fileName = 'prd.txt', numTasks, append = false } = req.body;
1296
+
1297
+ // Get project path
1298
+ let projectPath;
1299
+ try {
1300
+ projectPath = await extractProjectDirectory(projectName);
1301
+ } catch (error) {
1302
+ return res.status(404).json({
1303
+ error: 'Project not found',
1304
+ message: `Project "${projectName}" does not exist`
1305
+ });
1306
+ }
1307
+
1308
+ const prdPath = path.join(projectPath, '.taskmaster', 'docs', fileName);
1309
+
1310
+ // Check if PRD file exists
1311
+ try {
1312
+ await fsPromises.access(prdPath, fs.constants.F_OK);
1313
+ } catch (error) {
1314
+ return res.status(404).json({
1315
+ error: 'PRD file not found',
1316
+ message: `File "${fileName}" does not exist in .taskmaster/docs/`
1317
+ });
1318
+ }
1319
+
1320
+ // Build the command args
1321
+ const args = ['task-master-ai', 'parse-prd', prdPath];
1322
+
1323
+ if (numTasks) {
1324
+ args.push('--num-tasks', numTasks.toString());
1325
+ }
1326
+
1327
+ if (append) {
1328
+ args.push('--append');
1329
+ }
1330
+
1331
+ args.push('--research'); // Use research for better PRD parsing
1332
+
1333
+ // Run task-master parse-prd command
1334
+ const parsePRDProcess = spawn('npx', args, {
1335
+ cwd: projectPath,
1336
+ stdio: ['pipe', 'pipe', 'pipe']
1337
+ });
1338
+
1339
+ let stdout = '';
1340
+ let stderr = '';
1341
+
1342
+ parsePRDProcess.stdout.on('data', (data) => {
1343
+ stdout += data.toString();
1344
+ });
1345
+
1346
+ parsePRDProcess.stderr.on('data', (data) => {
1347
+ stderr += data.toString();
1348
+ });
1349
+
1350
+ parsePRDProcess.on('close', (code) => {
1351
+ if (code === 0) {
1352
+ // Broadcast task update via WebSocket
1353
+ if (req.app.locals.wss) {
1354
+ broadcastTaskMasterTasksUpdate(
1355
+ req.app.locals.wss,
1356
+ projectName
1357
+ );
1358
+ }
1359
+
1360
+ res.json({
1361
+ projectName,
1362
+ projectPath,
1363
+ prdFile: fileName,
1364
+ message: 'PRD parsed and tasks generated successfully',
1365
+ output: stdout,
1366
+ timestamp: new Date().toISOString()
1367
+ });
1368
+ } else {
1369
+ console.error('Parse PRD failed:', stderr);
1370
+ res.status(500).json({
1371
+ error: 'Failed to parse PRD',
1372
+ message: stderr || stdout,
1373
+ code
1374
+ });
1375
+ }
1376
+ });
1377
+
1378
+ parsePRDProcess.stdin.end();
1379
+
1380
+ } catch (error) {
1381
+ console.error('Parse PRD error:', error);
1382
+ res.status(500).json({
1383
+ error: 'Failed to parse PRD',
1384
+ message: error.message
1385
+ });
1386
+ }
1387
+ });
1388
+
1389
+ /**
1390
+ * GET /api/taskmaster/prd-templates
1391
+ * Get available PRD templates
1392
+ */
1393
+ router.get('/prd-templates', async (req, res) => {
1394
+ try {
1395
+ // Return built-in templates
1396
+ const templates = [
1397
+ {
1398
+ id: 'web-app',
1399
+ name: 'Web Application',
1400
+ description: 'Template for web application projects with frontend and backend components',
1401
+ category: 'web',
1402
+ content: `# Product Requirements Document - Web Application
1403
+
1404
+ ## Overview
1405
+ **Product Name:** [Your App Name]
1406
+ **Version:** 1.0
1407
+ **Date:** ${new Date().toISOString().split('T')[0]}
1408
+ **Author:** [Your Name]
1409
+
1410
+ ## Executive Summary
1411
+ Brief description of what this web application will do and why it's needed.
1412
+
1413
+ ## Product Goals
1414
+ - Goal 1: [Specific measurable goal]
1415
+ - Goal 2: [Specific measurable goal]
1416
+ - Goal 3: [Specific measurable goal]
1417
+
1418
+ ## User Stories
1419
+ ### Core Features
1420
+ 1. **User Registration & Authentication**
1421
+ - As a user, I want to create an account so I can access personalized features
1422
+ - As a user, I want to log in securely so my data is protected
1423
+ - As a user, I want to reset my password if I forget it
1424
+
1425
+ 2. **Main Application Features**
1426
+ - As a user, I want to [core feature 1] so I can [benefit]
1427
+ - As a user, I want to [core feature 2] so I can [benefit]
1428
+ - As a user, I want to [core feature 3] so I can [benefit]
1429
+
1430
+ 3. **User Interface**
1431
+ - As a user, I want a responsive design so I can use the app on any device
1432
+ - As a user, I want intuitive navigation so I can easily find features
1433
+
1434
+ ## Technical Requirements
1435
+ ### Frontend
1436
+ - Framework: React/Vue/Angular or vanilla JavaScript
1437
+ - Styling: CSS framework (Tailwind, Bootstrap, etc.)
1438
+ - State Management: Redux/Vuex/Context API
1439
+ - Build Tools: Webpack/Vite
1440
+ - Testing: Jest/Vitest for unit tests
1441
+
1442
+ ### Backend
1443
+ - Runtime: Node.js/Python/Java
1444
+ - Database: PostgreSQL/MySQL/MongoDB
1445
+ - API: RESTful API or GraphQL
1446
+ - Authentication: JWT tokens
1447
+ - Testing: Integration and unit tests
1448
+
1449
+ ### Infrastructure
1450
+ - Hosting: Cloud provider (AWS, Azure, GCP)
1451
+ - CI/CD: GitHub Actions/GitLab CI
1452
+ - Monitoring: Application monitoring tools
1453
+ - Security: HTTPS, input validation, rate limiting
1454
+
1455
+ ## Success Metrics
1456
+ - User engagement metrics
1457
+ - Performance benchmarks (load time < 2s)
1458
+ - Error rates < 1%
1459
+ - User satisfaction scores
1460
+
1461
+ ## Timeline
1462
+ - Phase 1: Core functionality (4-6 weeks)
1463
+ - Phase 2: Advanced features (2-4 weeks)
1464
+ - Phase 3: Polish and launch (2 weeks)
1465
+
1466
+ ## Constraints & Assumptions
1467
+ - Budget constraints
1468
+ - Technical limitations
1469
+ - Team size and expertise
1470
+ - Timeline constraints`
1471
+ },
1472
+ {
1473
+ id: 'api',
1474
+ name: 'REST API',
1475
+ description: 'Template for REST API development projects',
1476
+ category: 'backend',
1477
+ content: `# Product Requirements Document - REST API
1478
+
1479
+ ## Overview
1480
+ **API Name:** [Your API Name]
1481
+ **Version:** v1.0
1482
+ **Date:** ${new Date().toISOString().split('T')[0]}
1483
+ **Author:** [Your Name]
1484
+
1485
+ ## Executive Summary
1486
+ Description of the API's purpose, target users, and primary use cases.
1487
+
1488
+ ## API Goals
1489
+ - Goal 1: Provide secure data access
1490
+ - Goal 2: Ensure scalable architecture
1491
+ - Goal 3: Maintain high availability (99.9% uptime)
1492
+
1493
+ ## Functional Requirements
1494
+ ### Core Endpoints
1495
+ 1. **Authentication Endpoints**
1496
+ - POST /api/auth/login - User authentication
1497
+ - POST /api/auth/logout - User logout
1498
+ - POST /api/auth/refresh - Token refresh
1499
+ - POST /api/auth/register - User registration
1500
+
1501
+ 2. **Data Management Endpoints**
1502
+ - GET /api/resources - List resources with pagination
1503
+ - GET /api/resources/{id} - Get specific resource
1504
+ - POST /api/resources - Create new resource
1505
+ - PUT /api/resources/{id} - Update existing resource
1506
+ - DELETE /api/resources/{id} - Delete resource
1507
+
1508
+ 3. **Administrative Endpoints**
1509
+ - GET /api/admin/users - Manage users (admin only)
1510
+ - GET /api/admin/analytics - System analytics
1511
+ - POST /api/admin/backup - Trigger system backup
1512
+
1513
+ ## Technical Requirements
1514
+ ### API Design
1515
+ - RESTful architecture following OpenAPI 3.0 specification
1516
+ - JSON request/response format
1517
+ - Consistent error response format
1518
+ - API versioning strategy
1519
+
1520
+ ### Authentication & Security
1521
+ - JWT token-based authentication
1522
+ - Role-based access control (RBAC)
1523
+ - Rate limiting (100 requests/minute per user)
1524
+ - Input validation and sanitization
1525
+ - HTTPS enforcement
1526
+
1527
+ ### Database
1528
+ - Database type: [PostgreSQL/MongoDB/MySQL]
1529
+ - Connection pooling
1530
+ - Database migrations
1531
+ - Backup and recovery procedures
1532
+
1533
+ ### Performance Requirements
1534
+ - Response time: < 200ms for 95% of requests
1535
+ - Throughput: 1000+ requests/second
1536
+ - Concurrent users: 10,000+
1537
+ - Database query optimization
1538
+
1539
+ ### Documentation
1540
+ - Auto-generated API documentation (Swagger/OpenAPI)
1541
+ - Code examples for common use cases
1542
+ - SDK development for major languages
1543
+ - Postman collection for testing
1544
+
1545
+ ## Error Handling
1546
+ - Standardized error codes and messages
1547
+ - Proper HTTP status codes
1548
+ - Detailed error logging
1549
+ - Graceful degradation strategies
1550
+
1551
+ ## Testing Strategy
1552
+ - Unit tests (80%+ coverage)
1553
+ - Integration tests for all endpoints
1554
+ - Load testing and performance testing
1555
+ - Security testing (OWASP compliance)
1556
+
1557
+ ## Monitoring & Logging
1558
+ - Application performance monitoring
1559
+ - Error tracking and alerting
1560
+ - Access logs and audit trails
1561
+ - Health check endpoints
1562
+
1563
+ ## Deployment
1564
+ - Containerized deployment (Docker)
1565
+ - CI/CD pipeline setup
1566
+ - Environment management (dev, staging, prod)
1567
+ - Blue-green deployment strategy
1568
+
1569
+ ## Success Metrics
1570
+ - API uptime > 99.9%
1571
+ - Average response time < 200ms
1572
+ - Zero critical security vulnerabilities
1573
+ - Developer adoption metrics`
1574
+ },
1575
+ {
1576
+ id: 'mobile-app',
1577
+ name: 'Mobile Application',
1578
+ description: 'Template for mobile app development projects (iOS/Android)',
1579
+ category: 'mobile',
1580
+ content: `# Product Requirements Document - Mobile Application
1581
+
1582
+ ## Overview
1583
+ **App Name:** [Your App Name]
1584
+ **Platform:** iOS / Android / Cross-platform
1585
+ **Version:** 1.0
1586
+ **Date:** ${new Date().toISOString().split('T')[0]}
1587
+ **Author:** [Your Name]
1588
+
1589
+ ## Executive Summary
1590
+ Brief description of the mobile app's purpose, target audience, and key value proposition.
1591
+
1592
+ ## Product Goals
1593
+ - Goal 1: [Specific user engagement goal]
1594
+ - Goal 2: [Specific functionality goal]
1595
+ - Goal 3: [Specific performance goal]
1596
+
1597
+ ## User Stories
1598
+ ### Core Features
1599
+ 1. **Onboarding & Authentication**
1600
+ - As a new user, I want a simple onboarding process
1601
+ - As a user, I want to sign up with email or social media
1602
+ - As a user, I want biometric authentication for security
1603
+
1604
+ 2. **Main App Features**
1605
+ - As a user, I want [core feature 1] accessible from home screen
1606
+ - As a user, I want [core feature 2] to work offline
1607
+ - As a user, I want to sync data across devices
1608
+
1609
+ 3. **User Experience**
1610
+ - As a user, I want intuitive navigation patterns
1611
+ - As a user, I want fast loading times
1612
+ - As a user, I want accessibility features
1613
+
1614
+ ## Technical Requirements
1615
+ ### Mobile Development
1616
+ - **Cross-platform:** React Native / Flutter / Xamarin
1617
+ - **Native:** Swift (iOS) / Kotlin (Android)
1618
+ - **State Management:** Redux / MobX / Provider
1619
+ - **Navigation:** React Navigation / Flutter Navigation
1620
+
1621
+ ### Backend Integration
1622
+ - REST API or GraphQL integration
1623
+ - Real-time features (WebSockets/Push notifications)
1624
+ - Offline data synchronization
1625
+ - Background processing
1626
+
1627
+ ### Device Features
1628
+ - Camera and photo library access
1629
+ - GPS location services
1630
+ - Push notifications
1631
+ - Biometric authentication
1632
+ - Device storage
1633
+
1634
+ ### Performance Requirements
1635
+ - App launch time < 3 seconds
1636
+ - Screen transition animations < 300ms
1637
+ - Memory usage optimization
1638
+ - Battery usage optimization
1639
+
1640
+ ## Platform-Specific Considerations
1641
+ ### iOS Requirements
1642
+ - iOS 13.0+ minimum version
1643
+ - App Store guidelines compliance
1644
+ - iOS design guidelines (Human Interface Guidelines)
1645
+ - TestFlight beta testing
1646
+
1647
+ ### Android Requirements
1648
+ - Android 8.0+ (API level 26) minimum
1649
+ - Google Play Store guidelines
1650
+ - Material Design guidelines
1651
+ - Google Play Console testing
1652
+
1653
+ ## User Interface Design
1654
+ - Responsive design for different screen sizes
1655
+ - Dark mode support
1656
+ - Accessibility compliance (WCAG 2.1)
1657
+ - Consistent design system
1658
+
1659
+ ## Security & Privacy
1660
+ - Secure data storage (Keychain/Keystore)
1661
+ - API communication encryption
1662
+ - Privacy policy compliance (GDPR/CCPA)
1663
+ - App security best practices
1664
+
1665
+ ## Testing Strategy
1666
+ - Unit testing (80%+ coverage)
1667
+ - UI/E2E testing (Detox/Appium)
1668
+ - Device testing on multiple screen sizes
1669
+ - Performance testing
1670
+ - Security testing
1671
+
1672
+ ## App Store Deployment
1673
+ - App store optimization (ASO)
1674
+ - App icons and screenshots
1675
+ - Store listing content
1676
+ - Release management strategy
1677
+
1678
+ ## Analytics & Monitoring
1679
+ - User analytics (Firebase/Analytics)
1680
+ - Crash reporting (Crashlytics/Sentry)
1681
+ - Performance monitoring
1682
+ - User feedback collection
1683
+
1684
+ ## Success Metrics
1685
+ - App store ratings > 4.0
1686
+ - User retention rates
1687
+ - Daily/Monthly active users
1688
+ - App performance metrics
1689
+ - Conversion rates`
1690
+ },
1691
+ {
1692
+ id: 'data-analysis',
1693
+ name: 'Data Analysis Project',
1694
+ description: 'Template for data analysis and visualization projects',
1695
+ category: 'data',
1696
+ content: `# Product Requirements Document - Data Analysis Project
1697
+
1698
+ ## Overview
1699
+ **Project Name:** [Your Analysis Project]
1700
+ **Analysis Type:** [Descriptive/Predictive/Prescriptive]
1701
+ **Date:** ${new Date().toISOString().split('T')[0]}
1702
+ **Author:** [Your Name]
1703
+
1704
+ ## Executive Summary
1705
+ Description of the business problem, data sources, and expected insights.
1706
+
1707
+ ## Project Goals
1708
+ - Goal 1: [Specific business question to answer]
1709
+ - Goal 2: [Specific prediction to make]
1710
+ - Goal 3: [Specific recommendation to provide]
1711
+
1712
+ ## Business Requirements
1713
+ ### Key Questions
1714
+ 1. What patterns exist in the current data?
1715
+ 2. What factors influence [target variable]?
1716
+ 3. What predictions can be made for [future outcome]?
1717
+ 4. What recommendations can improve [business metric]?
1718
+
1719
+ ### Success Criteria
1720
+ - Actionable insights for stakeholders
1721
+ - Statistical significance in findings
1722
+ - Reproducible analysis pipeline
1723
+ - Clear visualization and reporting
1724
+
1725
+ ## Data Requirements
1726
+ ### Data Sources
1727
+ 1. **Primary Data**
1728
+ - Source: [Database/API/Files]
1729
+ - Format: [CSV/JSON/SQL]
1730
+ - Size: [Volume estimate]
1731
+ - Update frequency: [Real-time/Daily/Monthly]
1732
+
1733
+ 2. **External Data**
1734
+ - Third-party APIs
1735
+ - Public datasets
1736
+ - Market research data
1737
+
1738
+ ### Data Quality Requirements
1739
+ - Data completeness (< 5% missing values)
1740
+ - Data accuracy validation
1741
+ - Data consistency checks
1742
+ - Historical data availability
1743
+
1744
+ ## Technical Requirements
1745
+ ### Data Pipeline
1746
+ - Data extraction and ingestion
1747
+ - Data cleaning and preprocessing
1748
+ - Data transformation and feature engineering
1749
+ - Data validation and quality checks
1750
+
1751
+ ### Analysis Tools
1752
+ - **Programming:** Python/R/SQL
1753
+ - **Libraries:** pandas, numpy, scikit-learn, matplotlib
1754
+ - **Visualization:** Tableau, PowerBI, or custom dashboards
1755
+ - **Version Control:** Git for code and DVC for data
1756
+
1757
+ ### Computing Resources
1758
+ - Local development environment
1759
+ - Cloud computing (AWS/GCP/Azure) if needed
1760
+ - Database access and permissions
1761
+ - Storage requirements
1762
+
1763
+ ## Analysis Methodology
1764
+ ### Data Exploration
1765
+ 1. Descriptive statistics and data profiling
1766
+ 2. Data visualization and pattern identification
1767
+ 3. Correlation analysis
1768
+ 4. Outlier detection and handling
1769
+
1770
+ ### Statistical Analysis
1771
+ 1. Hypothesis formulation
1772
+ 2. Statistical testing
1773
+ 3. Confidence intervals
1774
+ 4. Effect size calculations
1775
+
1776
+ ### Machine Learning (if applicable)
1777
+ 1. Feature selection and engineering
1778
+ 2. Model selection and training
1779
+ 3. Cross-validation and evaluation
1780
+ 4. Model interpretation and explainability
1781
+
1782
+ ## Deliverables
1783
+ ### Reports
1784
+ - Executive summary for stakeholders
1785
+ - Technical analysis report
1786
+ - Data quality report
1787
+ - Methodology documentation
1788
+
1789
+ ### Visualizations
1790
+ - Interactive dashboards
1791
+ - Static charts and graphs
1792
+ - Data story presentations
1793
+ - Key findings infographics
1794
+
1795
+ ### Code & Documentation
1796
+ - Reproducible analysis scripts
1797
+ - Data pipeline code
1798
+ - Documentation and comments
1799
+ - Testing and validation code
1800
+
1801
+ ## Timeline
1802
+ - Phase 1: Data collection and exploration (2 weeks)
1803
+ - Phase 2: Analysis and modeling (3 weeks)
1804
+ - Phase 3: Reporting and visualization (1 week)
1805
+ - Phase 4: Stakeholder presentation (1 week)
1806
+
1807
+ ## Risks & Assumptions
1808
+ - Data availability and quality risks
1809
+ - Technical complexity assumptions
1810
+ - Resource and timeline constraints
1811
+ - Stakeholder engagement assumptions
1812
+
1813
+ ## Success Metrics
1814
+ - Stakeholder satisfaction with insights
1815
+ - Accuracy of predictions (if applicable)
1816
+ - Business impact of recommendations
1817
+ - Reproducibility of results`
1818
+ }
1819
+ ];
1820
+
1821
+ res.json({
1822
+ templates,
1823
+ timestamp: new Date().toISOString()
1824
+ });
1825
+
1826
+ } catch (error) {
1827
+ console.error('PRD templates error:', error);
1828
+ res.status(500).json({
1829
+ error: 'Failed to get PRD templates',
1830
+ message: error.message
1831
+ });
1832
+ }
1833
+ });
1834
+
1835
+ /**
1836
+ * POST /api/taskmaster/apply-template/:projectName
1837
+ * Apply a PRD template to create a new PRD file
1838
+ */
1839
+ router.post('/apply-template/:projectName', async (req, res) => {
1840
+ try {
1841
+ const { projectName } = req.params;
1842
+ const { templateId, fileName = 'prd.txt', customizations = {} } = req.body;
1843
+
1844
+ if (!templateId) {
1845
+ return res.status(400).json({
1846
+ error: 'Missing required parameter',
1847
+ message: 'templateId is required'
1848
+ });
1849
+ }
1850
+
1851
+ // Get project path
1852
+ let projectPath;
1853
+ try {
1854
+ projectPath = await extractProjectDirectory(projectName);
1855
+ } catch (error) {
1856
+ return res.status(404).json({
1857
+ error: 'Project not found',
1858
+ message: `Project "${projectName}" does not exist`
1859
+ });
1860
+ }
1861
+
1862
+ // Get the template content (this would normally fetch from the templates list)
1863
+ const templates = await getAvailableTemplates();
1864
+ const template = templates.find(t => t.id === templateId);
1865
+
1866
+ if (!template) {
1867
+ return res.status(404).json({
1868
+ error: 'Template not found',
1869
+ message: `Template "${templateId}" does not exist`
1870
+ });
1871
+ }
1872
+
1873
+ // Apply customizations to template content
1874
+ let content = template.content;
1875
+
1876
+ // Replace placeholders with customizations
1877
+ for (const [key, value] of Object.entries(customizations)) {
1878
+ const placeholder = `[${key}]`;
1879
+ content = content.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'), value);
1880
+ }
1881
+
1882
+ // Ensure .taskmaster/docs directory exists
1883
+ const docsDir = path.join(projectPath, '.taskmaster', 'docs');
1884
+ try {
1885
+ await fsPromises.mkdir(docsDir, { recursive: true });
1886
+ } catch (error) {
1887
+ console.error('Failed to create docs directory:', error);
1888
+ }
1889
+
1890
+ const filePath = path.join(docsDir, fileName);
1891
+
1892
+ // Write the template content to the file
1893
+ try {
1894
+ await fsPromises.writeFile(filePath, content, 'utf8');
1895
+
1896
+ res.json({
1897
+ projectName,
1898
+ projectPath,
1899
+ templateId,
1900
+ templateName: template.name,
1901
+ fileName,
1902
+ filePath: filePath,
1903
+ message: 'PRD template applied successfully',
1904
+ timestamp: new Date().toISOString()
1905
+ });
1906
+
1907
+ } catch (writeError) {
1908
+ console.error('Failed to write PRD template:', writeError);
1909
+ return res.status(500).json({
1910
+ error: 'Failed to write PRD template',
1911
+ message: writeError.message
1912
+ });
1913
+ }
1914
+
1915
+ } catch (error) {
1916
+ console.error('Apply template error:', error);
1917
+ res.status(500).json({
1918
+ error: 'Failed to apply PRD template',
1919
+ message: error.message
1920
+ });
1921
+ }
1922
+ });
1923
+
1924
+ // Helper function to get available templates
1925
+ async function getAvailableTemplates() {
1926
+ // This could be extended to read from files or database
1927
+ return [
1928
+ {
1929
+ id: 'web-app',
1930
+ name: 'Web Application',
1931
+ description: 'Template for web application projects',
1932
+ category: 'web',
1933
+ content: `# Product Requirements Document - Web Application
1934
+
1935
+ ## Overview
1936
+ **Product Name:** [Your App Name]
1937
+ **Version:** 1.0
1938
+ **Date:** ${new Date().toISOString().split('T')[0]}
1939
+ **Author:** [Your Name]
1940
+
1941
+ ## Executive Summary
1942
+ Brief description of what this web application will do and why it's needed.
1943
+
1944
+ ## User Stories
1945
+ 1. As a user, I want [feature] so I can [benefit]
1946
+ 2. As a user, I want [feature] so I can [benefit]
1947
+ 3. As a user, I want [feature] so I can [benefit]
1948
+
1949
+ ## Technical Requirements
1950
+ - Frontend framework
1951
+ - Backend services
1952
+ - Database requirements
1953
+ - Security considerations
1954
+
1955
+ ## Success Metrics
1956
+ - User engagement metrics
1957
+ - Performance benchmarks
1958
+ - Business objectives`
1959
+ },
1960
+ // Add other templates here if needed
1961
+ ];
1962
+ }
1963
+
1964
+ export default router;