@codemcp/workflows 5.3.0 → 6.0.1

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 (451) hide show
  1. package/README.md +91 -0
  2. package/package.json +77 -17
  3. package/packages/cli/dist/chunk-R5U7XKVJ.js +16 -0
  4. package/packages/cli/dist/chunk-RTDQR2KY.js +6718 -0
  5. package/packages/cli/dist/cli-CZ4FMSWR.js +1421 -0
  6. package/packages/cli/dist/dist-KZOA4GL5.js +65 -0
  7. package/packages/cli/dist/dist-UGVUJIDN.js +14475 -0
  8. package/packages/cli/dist/index.js +21 -0
  9. package/packages/cli/package.json +28 -0
  10. package/packages/core/dist/beads-integration.d.ts +50 -0
  11. package/packages/core/dist/beads-integration.js +387 -0
  12. package/packages/core/dist/beads-integration.js.map +1 -0
  13. package/packages/core/dist/beads-state-manager.d.ts +58 -0
  14. package/packages/core/dist/beads-state-manager.js +212 -0
  15. package/packages/core/dist/beads-state-manager.js.map +1 -0
  16. package/packages/core/dist/config-manager.d.ts +24 -0
  17. package/packages/core/dist/config-manager.js +68 -0
  18. package/packages/core/dist/config-manager.js.map +1 -0
  19. package/packages/core/dist/conversation-manager.d.ts +98 -0
  20. package/packages/core/dist/conversation-manager.js +382 -0
  21. package/packages/core/dist/conversation-manager.js.map +1 -0
  22. package/packages/core/dist/file-detection-manager.d.ts +53 -0
  23. package/packages/core/dist/file-detection-manager.js +221 -0
  24. package/packages/core/dist/file-detection-manager.js.map +1 -0
  25. package/packages/core/dist/file-storage.d.ts +93 -0
  26. package/packages/core/dist/file-storage.js +301 -0
  27. package/packages/core/dist/file-storage.js.map +1 -0
  28. package/packages/core/dist/git-manager.d.ts +22 -0
  29. package/packages/core/dist/git-manager.js +123 -0
  30. package/packages/core/dist/git-manager.js.map +1 -0
  31. package/packages/core/dist/index.d.ts +24 -0
  32. package/packages/core/dist/index.js +31 -0
  33. package/packages/core/dist/index.js.map +1 -0
  34. package/packages/core/dist/instruction-generator.d.ts +40 -0
  35. package/packages/core/dist/instruction-generator.js +89 -0
  36. package/packages/core/dist/instruction-generator.js.map +1 -0
  37. package/packages/core/dist/interaction-logger.d.ts +37 -0
  38. package/packages/core/dist/interaction-logger.js +87 -0
  39. package/packages/core/dist/interaction-logger.js.map +1 -0
  40. package/packages/core/dist/interfaces/index.d.ts +9 -0
  41. package/packages/core/dist/interfaces/index.js +10 -0
  42. package/packages/core/dist/interfaces/index.js.map +1 -0
  43. package/packages/core/dist/interfaces/instruction-generator.interface.d.ts +41 -0
  44. package/packages/core/dist/interfaces/instruction-generator.interface.js +8 -0
  45. package/packages/core/dist/interfaces/instruction-generator.interface.js.map +1 -0
  46. package/packages/core/dist/interfaces/plan-manager.interface.d.ts +55 -0
  47. package/packages/core/dist/interfaces/plan-manager.interface.js +8 -0
  48. package/packages/core/dist/interfaces/plan-manager.interface.js.map +1 -0
  49. package/packages/core/dist/interfaces/task-backend-client.interface.d.ts +52 -0
  50. package/packages/core/dist/interfaces/task-backend-client.interface.js +8 -0
  51. package/packages/core/dist/interfaces/task-backend-client.interface.js.map +1 -0
  52. package/packages/core/dist/logger.d.ts +64 -0
  53. package/packages/core/dist/logger.js +283 -0
  54. package/packages/core/dist/logger.js.map +1 -0
  55. package/packages/core/dist/path-validation-utils.d.ts +75 -0
  56. package/packages/core/dist/path-validation-utils.js +238 -0
  57. package/packages/core/dist/path-validation-utils.js.map +1 -0
  58. package/packages/core/dist/persistence-interface.d.ts +91 -0
  59. package/packages/core/dist/persistence-interface.js +9 -0
  60. package/packages/core/dist/persistence-interface.js.map +1 -0
  61. package/{dist/components/beads/beads-plan-manager.d.ts → packages/core/dist/plan-manager.d.ts} +15 -15
  62. package/{dist/components/beads/beads-plan-manager.js → packages/core/dist/plan-manager.js} +66 -50
  63. package/packages/core/dist/plan-manager.js.map +1 -0
  64. package/packages/core/dist/project-docs-manager.d.ts +119 -0
  65. package/packages/core/dist/project-docs-manager.js +366 -0
  66. package/packages/core/dist/project-docs-manager.js.map +1 -0
  67. package/packages/core/dist/state-machine-loader.d.ts +61 -0
  68. package/packages/core/dist/state-machine-loader.js +273 -0
  69. package/packages/core/dist/state-machine-loader.js.map +1 -0
  70. package/packages/core/dist/state-machine-types.d.ts +64 -0
  71. package/packages/core/dist/state-machine-types.js +7 -0
  72. package/packages/core/dist/state-machine-types.js.map +1 -0
  73. package/packages/core/dist/state-machine.d.ts +52 -0
  74. package/packages/core/dist/state-machine.js +256 -0
  75. package/packages/core/dist/state-machine.js.map +1 -0
  76. package/packages/core/dist/system-prompt-generator.d.ts +14 -0
  77. package/packages/core/dist/system-prompt-generator.js +42 -0
  78. package/packages/core/dist/system-prompt-generator.js.map +1 -0
  79. package/packages/core/dist/task-backend.d.ts +45 -0
  80. package/packages/core/dist/task-backend.js +176 -0
  81. package/packages/core/dist/task-backend.js.map +1 -0
  82. package/packages/core/dist/template-manager.d.ts +61 -0
  83. package/packages/core/dist/template-manager.js +231 -0
  84. package/packages/core/dist/template-manager.js.map +1 -0
  85. package/packages/core/dist/transition-engine.d.ts +77 -0
  86. package/packages/core/dist/transition-engine.js +244 -0
  87. package/packages/core/dist/transition-engine.js.map +1 -0
  88. package/packages/core/dist/types.d.ts +54 -0
  89. package/packages/core/dist/types.js +5 -0
  90. package/packages/core/dist/workflow-manager.d.ts +89 -0
  91. package/packages/core/dist/workflow-manager.js +468 -0
  92. package/packages/core/dist/workflow-manager.js.map +1 -0
  93. package/packages/core/package.json +33 -0
  94. package/packages/docs/.vitepress/dist/.gitignore +2 -0
  95. package/packages/docs/.vitepress/dist/404.html +23 -0
  96. package/packages/docs/.vitepress/dist/assets/app.Dz3lZH3M.js +1 -0
  97. package/packages/docs/.vitepress/dist/assets/chunks/framework.DZS7lpav.js +19 -0
  98. package/packages/docs/.vitepress/dist/assets/chunks/theme.q5Ewb3F1.js +206 -0
  99. package/packages/docs/.vitepress/dist/assets/dev_ARCHITECTURE.md.da_vFDwM.js +130 -0
  100. package/packages/docs/.vitepress/dist/assets/dev_ARCHITECTURE.md.da_vFDwM.lean.js +1 -0
  101. package/packages/docs/.vitepress/dist/assets/dev_DEVELOPMENT.md.DWl9cccE.js +72 -0
  102. package/packages/docs/.vitepress/dist/assets/dev_DEVELOPMENT.md.DWl9cccE.lean.js +1 -0
  103. package/packages/docs/.vitepress/dist/assets/dev_LOGGING.md.BebvbW7z.js +34 -0
  104. package/packages/docs/.vitepress/dist/assets/dev_LOGGING.md.BebvbW7z.lean.js +1 -0
  105. package/packages/docs/.vitepress/dist/assets/dev_PUBLISHING.md.CQqbiIOF.js +1 -0
  106. package/packages/docs/.vitepress/dist/assets/dev_PUBLISHING.md.CQqbiIOF.lean.js +1 -0
  107. package/packages/docs/.vitepress/dist/assets/index.md.D6ROLohf.js +2 -0
  108. package/packages/docs/.vitepress/dist/assets/index.md.D6ROLohf.lean.js +1 -0
  109. package/packages/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  110. package/packages/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  111. package/packages/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  112. package/packages/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  113. package/packages/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  114. package/packages/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  115. package/packages/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  116. package/packages/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  117. package/packages/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  118. package/packages/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  119. package/packages/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  120. package/packages/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  121. package/packages/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  122. package/packages/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  123. package/packages/docs/.vitepress/dist/assets/mcp-interaction-pattern.VdvOPuTt.png +0 -0
  124. package/packages/docs/.vitepress/dist/assets/placeholder-demo-greenfield.B8lG_tBI.png +0 -0
  125. package/packages/docs/.vitepress/dist/assets/style.CAgdBzOq.css +1 -0
  126. package/packages/docs/.vitepress/dist/assets/user_advanced-engineering.md.MkETYNtq.js +50 -0
  127. package/packages/docs/.vitepress/dist/assets/user_advanced-engineering.md.MkETYNtq.lean.js +1 -0
  128. package/packages/docs/.vitepress/dist/assets/user_agent-setup.md.B54OLL2H.js +24 -0
  129. package/packages/docs/.vitepress/dist/assets/user_agent-setup.md.B54OLL2H.lean.js +1 -0
  130. package/packages/docs/.vitepress/dist/assets/user_beads-integration.md.BzdR5Fif.js +15 -0
  131. package/packages/docs/.vitepress/dist/assets/user_beads-integration.md.BzdR5Fif.lean.js +1 -0
  132. package/packages/docs/.vitepress/dist/assets/user_crowd-mcp-integration.md.C15kSdIJ.js +157 -0
  133. package/packages/docs/.vitepress/dist/assets/user_crowd-mcp-integration.md.C15kSdIJ.lean.js +1 -0
  134. package/packages/docs/.vitepress/dist/assets/user_custom-workflows.md.Cz4IYCXa.js +143 -0
  135. package/packages/docs/.vitepress/dist/assets/user_custom-workflows.md.Cz4IYCXa.lean.js +1 -0
  136. package/packages/docs/.vitepress/dist/assets/user_git-commit-feature.md.UcTvDR-O.js +1 -0
  137. package/packages/docs/.vitepress/dist/assets/user_git-commit-feature.md.UcTvDR-O.lean.js +1 -0
  138. package/packages/docs/.vitepress/dist/assets/user_how-it-works.md.DiOXNgaL.js +23 -0
  139. package/packages/docs/.vitepress/dist/assets/user_how-it-works.md.DiOXNgaL.lean.js +1 -0
  140. package/packages/docs/.vitepress/dist/assets/user_long-term-memory.md.DZh0tjNa.js +43 -0
  141. package/packages/docs/.vitepress/dist/assets/user_long-term-memory.md.DZh0tjNa.lean.js +1 -0
  142. package/packages/docs/.vitepress/dist/assets/user_packaged-workflows.md.s1HT89ZU.js +2 -0
  143. package/packages/docs/.vitepress/dist/assets/user_packaged-workflows.md.s1HT89ZU.lean.js +1 -0
  144. package/packages/docs/.vitepress/dist/assets/user_tutorial.md.Dmj8zLB2.js +3 -0
  145. package/packages/docs/.vitepress/dist/assets/user_tutorial.md.Dmj8zLB2.lean.js +1 -0
  146. package/packages/docs/.vitepress/dist/assets/user_workflow-selection.md.CrPGw9Hr.js +7 -0
  147. package/packages/docs/.vitepress/dist/assets/user_workflow-selection.md.CrPGw9Hr.lean.js +1 -0
  148. package/packages/docs/.vitepress/dist/assets/workflows.md.Bm5sGt3u.js +1 -0
  149. package/packages/docs/.vitepress/dist/assets/workflows.md.Bm5sGt3u.lean.js +1 -0
  150. package/packages/docs/.vitepress/dist/assets/workflows_adr.md.DEaXkbRp.js +1 -0
  151. package/packages/docs/.vitepress/dist/assets/workflows_adr.md.DEaXkbRp.lean.js +1 -0
  152. package/packages/docs/.vitepress/dist/assets/workflows_big-bang-conversion.md.BA5R1LxZ.js +1 -0
  153. package/packages/docs/.vitepress/dist/assets/workflows_big-bang-conversion.md.BA5R1LxZ.lean.js +1 -0
  154. package/packages/docs/.vitepress/dist/assets/workflows_boundary-testing.md.DBcYnMhx.js +1 -0
  155. package/packages/docs/.vitepress/dist/assets/workflows_boundary-testing.md.DBcYnMhx.lean.js +1 -0
  156. package/packages/docs/.vitepress/dist/assets/workflows_bugfix.md.CZRCL0Hp.js +1 -0
  157. package/packages/docs/.vitepress/dist/assets/workflows_bugfix.md.CZRCL0Hp.lean.js +1 -0
  158. package/packages/docs/.vitepress/dist/assets/workflows_business-analysis.md.fGLml8Hw.js +1 -0
  159. package/packages/docs/.vitepress/dist/assets/workflows_business-analysis.md.fGLml8Hw.lean.js +1 -0
  160. package/packages/docs/.vitepress/dist/assets/workflows_c4-analysis.md.Dnssqzuf.js +1 -0
  161. package/packages/docs/.vitepress/dist/assets/workflows_c4-analysis.md.Dnssqzuf.lean.js +1 -0
  162. package/packages/docs/.vitepress/dist/assets/workflows_epcc.md.M6DnIhpp.js +1 -0
  163. package/packages/docs/.vitepress/dist/assets/workflows_epcc.md.M6DnIhpp.lean.js +1 -0
  164. package/packages/docs/.vitepress/dist/assets/workflows_game-beginner.md.CNxzWLtd.js +1 -0
  165. package/packages/docs/.vitepress/dist/assets/workflows_game-beginner.md.CNxzWLtd.lean.js +1 -0
  166. package/packages/docs/.vitepress/dist/assets/workflows_greenfield.md.vx_g-WOe.js +1 -0
  167. package/packages/docs/.vitepress/dist/assets/workflows_greenfield.md.vx_g-WOe.lean.js +1 -0
  168. package/packages/docs/.vitepress/dist/assets/workflows_minor.md.DdnfwMf4.js +1 -0
  169. package/packages/docs/.vitepress/dist/assets/workflows_minor.md.DdnfwMf4.lean.js +1 -0
  170. package/packages/docs/.vitepress/dist/assets/workflows_posts.md.SOldXvq7.js +1 -0
  171. package/packages/docs/.vitepress/dist/assets/workflows_posts.md.SOldXvq7.lean.js +1 -0
  172. package/packages/docs/.vitepress/dist/assets/workflows_sdd-bugfix-crowd.md.-lSf42gJ.js +1 -0
  173. package/packages/docs/.vitepress/dist/assets/workflows_sdd-bugfix-crowd.md.-lSf42gJ.lean.js +1 -0
  174. package/packages/docs/.vitepress/dist/assets/workflows_sdd-bugfix.md.oRAsEVbc.js +1 -0
  175. package/packages/docs/.vitepress/dist/assets/workflows_sdd-bugfix.md.oRAsEVbc.lean.js +1 -0
  176. package/packages/docs/.vitepress/dist/assets/workflows_sdd-feature-crowd.md.DAtnfCAd.js +1 -0
  177. package/packages/docs/.vitepress/dist/assets/workflows_sdd-feature-crowd.md.DAtnfCAd.lean.js +1 -0
  178. package/packages/docs/.vitepress/dist/assets/workflows_sdd-feature.md.Ce3-H_g3.js +1 -0
  179. package/packages/docs/.vitepress/dist/assets/workflows_sdd-feature.md.Ce3-H_g3.lean.js +1 -0
  180. package/packages/docs/.vitepress/dist/assets/workflows_sdd-greenfield-crowd.md.8DUvcmLe.js +1 -0
  181. package/packages/docs/.vitepress/dist/assets/workflows_sdd-greenfield-crowd.md.8DUvcmLe.lean.js +1 -0
  182. package/packages/docs/.vitepress/dist/assets/workflows_sdd-greenfield.md.eEN6U0J4.js +1 -0
  183. package/packages/docs/.vitepress/dist/assets/workflows_sdd-greenfield.md.eEN6U0J4.lean.js +1 -0
  184. package/packages/docs/.vitepress/dist/assets/workflows_slides.md.Cqt-19_1.js +1 -0
  185. package/packages/docs/.vitepress/dist/assets/workflows_slides.md.Cqt-19_1.lean.js +1 -0
  186. package/packages/docs/.vitepress/dist/assets/workflows_tdd.md.BjVC69tu.js +1 -0
  187. package/packages/docs/.vitepress/dist/assets/workflows_tdd.md.BjVC69tu.lean.js +1 -0
  188. package/packages/docs/.vitepress/dist/assets/workflows_waterfall.md.CL6jTZP9.js +1 -0
  189. package/packages/docs/.vitepress/dist/assets/workflows_waterfall.md.CL6jTZP9.lean.js +1 -0
  190. package/packages/docs/.vitepress/dist/dev/ARCHITECTURE.html +155 -0
  191. package/packages/docs/.vitepress/dist/dev/DEVELOPMENT.html +97 -0
  192. package/packages/docs/.vitepress/dist/dev/LOGGING.html +59 -0
  193. package/packages/docs/.vitepress/dist/dev/PUBLISHING.html +30 -0
  194. package/packages/docs/.vitepress/dist/hashmap.json +1 -0
  195. package/packages/docs/.vitepress/dist/index.html +27 -0
  196. package/packages/docs/.vitepress/dist/user/advanced-engineering.html +75 -0
  197. package/packages/docs/.vitepress/dist/user/agent-setup.html +49 -0
  198. package/packages/docs/.vitepress/dist/user/beads-integration.html +40 -0
  199. package/packages/docs/.vitepress/dist/user/crowd-mcp-integration.html +182 -0
  200. package/packages/docs/.vitepress/dist/user/custom-workflows.html +168 -0
  201. package/packages/docs/.vitepress/dist/user/git-commit-feature.html +30 -0
  202. package/packages/docs/.vitepress/dist/user/how-it-works.html +48 -0
  203. package/packages/docs/.vitepress/dist/user/long-term-memory.html +68 -0
  204. package/packages/docs/.vitepress/dist/user/packaged-workflows.html +27 -0
  205. package/packages/docs/.vitepress/dist/user/tutorial.html +28 -0
  206. package/packages/docs/.vitepress/dist/user/workflow-selection.html +32 -0
  207. package/packages/docs/.vitepress/dist/vp-icons.css +0 -0
  208. package/packages/docs/.vitepress/dist/workflows/adr.html +26 -0
  209. package/packages/docs/.vitepress/dist/workflows/adr.yaml +157 -0
  210. package/packages/docs/.vitepress/dist/workflows/big-bang-conversion.html +26 -0
  211. package/packages/docs/.vitepress/dist/workflows/big-bang-conversion.yaml +592 -0
  212. package/packages/docs/.vitepress/dist/workflows/boundary-testing.html +26 -0
  213. package/packages/docs/.vitepress/dist/workflows/boundary-testing.yaml +376 -0
  214. package/packages/docs/.vitepress/dist/workflows/bugfix.html +26 -0
  215. package/packages/docs/.vitepress/dist/workflows/bugfix.yaml +177 -0
  216. package/packages/docs/.vitepress/dist/workflows/business-analysis.html +26 -0
  217. package/packages/docs/.vitepress/dist/workflows/business-analysis.yaml +597 -0
  218. package/packages/docs/.vitepress/dist/workflows/c4-analysis.html +26 -0
  219. package/packages/docs/.vitepress/dist/workflows/c4-analysis.yaml +471 -0
  220. package/packages/docs/.vitepress/dist/workflows/epcc.html +26 -0
  221. package/packages/docs/.vitepress/dist/workflows/epcc.yaml +183 -0
  222. package/packages/docs/.vitepress/dist/workflows/game-beginner.html +26 -0
  223. package/packages/docs/.vitepress/dist/workflows/game-beginner.yaml +434 -0
  224. package/packages/docs/.vitepress/dist/workflows/greenfield.html +26 -0
  225. package/packages/docs/.vitepress/dist/workflows/greenfield.yaml +201 -0
  226. package/packages/docs/.vitepress/dist/workflows/minor.html +26 -0
  227. package/packages/docs/.vitepress/dist/workflows/minor.yaml +138 -0
  228. package/packages/docs/.vitepress/dist/workflows/posts.html +26 -0
  229. package/packages/docs/.vitepress/dist/workflows/posts.yaml +193 -0
  230. package/packages/docs/.vitepress/dist/workflows/sdd-bugfix-crowd.html +26 -0
  231. package/packages/docs/.vitepress/dist/workflows/sdd-bugfix-crowd.yaml +608 -0
  232. package/packages/docs/.vitepress/dist/workflows/sdd-bugfix.html +26 -0
  233. package/packages/docs/.vitepress/dist/workflows/sdd-bugfix.yaml +381 -0
  234. package/packages/docs/.vitepress/dist/workflows/sdd-feature-crowd.html +26 -0
  235. package/packages/docs/.vitepress/dist/workflows/sdd-feature-crowd.yaml +713 -0
  236. package/packages/docs/.vitepress/dist/workflows/sdd-feature.html +26 -0
  237. package/packages/docs/.vitepress/dist/workflows/sdd-feature.yaml +471 -0
  238. package/packages/docs/.vitepress/dist/workflows/sdd-greenfield-crowd.html +26 -0
  239. package/packages/docs/.vitepress/dist/workflows/sdd-greenfield-crowd.yaml +336 -0
  240. package/packages/docs/.vitepress/dist/workflows/sdd-greenfield.html +26 -0
  241. package/packages/docs/.vitepress/dist/workflows/sdd-greenfield.yaml +463 -0
  242. package/packages/docs/.vitepress/dist/workflows/slides.html +26 -0
  243. package/packages/docs/.vitepress/dist/workflows/slides.yaml +237 -0
  244. package/packages/docs/.vitepress/dist/workflows/tdd.html +26 -0
  245. package/packages/docs/.vitepress/dist/workflows/tdd.yaml +160 -0
  246. package/packages/docs/.vitepress/dist/workflows/waterfall.html +26 -0
  247. package/packages/docs/.vitepress/dist/workflows/waterfall.yaml +209 -0
  248. package/packages/docs/.vitepress/dist/workflows.html +26 -0
  249. package/packages/docs/package.json +32 -0
  250. package/packages/mcp-server/dist/index.js +10546 -0
  251. package/packages/mcp-server/package.json +41 -0
  252. package/packages/visualizer/dist/WorkflowVisualizer.vue +1147 -0
  253. package/packages/visualizer/dist/index.ts +17 -0
  254. package/packages/visualizer/dist/main.ts +673 -0
  255. package/packages/visualizer/dist/services/BundledWorkflows.ts +35 -0
  256. package/packages/visualizer/dist/services/FileUploadHandler.ts +166 -0
  257. package/packages/visualizer/dist/services/WorkflowLoader.ts +198 -0
  258. package/packages/visualizer/dist/services/YamlParser.ts +248 -0
  259. package/packages/visualizer/dist/services/workflow-list.ts +23 -0
  260. package/packages/visualizer/dist/types/ui-types.ts +84 -0
  261. package/packages/visualizer/dist/types/visualization-types.ts +95 -0
  262. package/packages/visualizer/dist/types/vite-env.d.ts +12 -0
  263. package/packages/visualizer/dist/utils/DomHelpers.ts +206 -0
  264. package/packages/visualizer/dist/utils/ErrorHandler.ts +170 -0
  265. package/packages/visualizer/dist/utils/PlantUMLEncoder.ts +121 -0
  266. package/packages/visualizer/dist/visualization/DiagramRenderer.ts +430 -0
  267. package/packages/visualizer/dist/visualization/LayoutEngine.ts +339 -0
  268. package/packages/visualizer/dist/visualization/PlantUMLRenderer.ts +507 -0
  269. package/packages/visualizer/dist/visualization/StateRenderer.ts +339 -0
  270. package/packages/visualizer/dist/visualization/TransitionRenderer.ts +432 -0
  271. package/packages/visualizer/package.json +39 -0
  272. package/resources/.DS_Store +0 -0
  273. package/resources/agents/architect.yaml +61 -0
  274. package/resources/agents/business-analyst.yaml +60 -0
  275. package/resources/agents/developer.yaml +61 -0
  276. package/resources/state-machine-schema.json +114 -0
  277. package/resources/templates/architecture/arc42/arc42-template-EN.md +1077 -0
  278. package/resources/templates/architecture/arc42/images/01_2_iso-25010-topics-EN.drawio-2023.png +0 -0
  279. package/resources/templates/architecture/arc42/images/01_2_iso-25010-topics-EN.drawio.png +0 -0
  280. package/resources/templates/architecture/arc42/images/05_building_blocks-EN.png +0 -0
  281. package/resources/templates/architecture/arc42/images/08-concepts-EN.drawio.png +0 -0
  282. package/resources/templates/architecture/arc42/images/arc42-logo.png +0 -0
  283. package/resources/templates/architecture/c4.md +224 -0
  284. package/resources/templates/architecture/freestyle.md +53 -0
  285. package/resources/templates/architecture/game.md +250 -0
  286. package/resources/templates/architecture/none.md +17 -0
  287. package/resources/templates/design/comprehensive.md +207 -0
  288. package/resources/templates/design/freestyle.md +37 -0
  289. package/resources/templates/design/game.md +66 -0
  290. package/resources/templates/design/none.md +17 -0
  291. package/resources/templates/requirements/ears.md +90 -0
  292. package/resources/templates/requirements/freestyle.md +42 -0
  293. package/resources/templates/requirements/game.md +162 -0
  294. package/resources/templates/requirements/none.md +17 -0
  295. package/resources/templates/skills/POWER.md +23 -0
  296. package/resources/templates/skills/SKILL.md +19 -0
  297. package/resources/workflows/adr.yaml +157 -0
  298. package/resources/workflows/big-bang-conversion.yaml +592 -0
  299. package/resources/workflows/boundary-testing.yaml +376 -0
  300. package/resources/workflows/bugfix.yaml +177 -0
  301. package/resources/workflows/business-analysis.yaml +597 -0
  302. package/resources/workflows/c4-analysis.yaml +471 -0
  303. package/resources/workflows/epcc.yaml +183 -0
  304. package/resources/workflows/game-beginner.yaml +434 -0
  305. package/resources/workflows/greenfield.yaml +201 -0
  306. package/resources/workflows/minor.yaml +138 -0
  307. package/resources/workflows/posts.yaml +193 -0
  308. package/resources/workflows/sdd-bugfix-crowd.yaml +608 -0
  309. package/resources/workflows/sdd-bugfix.yaml +381 -0
  310. package/resources/workflows/sdd-feature-crowd.yaml +713 -0
  311. package/resources/workflows/sdd-feature.yaml +471 -0
  312. package/resources/workflows/sdd-greenfield-crowd.yaml +336 -0
  313. package/resources/workflows/sdd-greenfield.yaml +463 -0
  314. package/resources/workflows/slides.yaml +237 -0
  315. package/resources/workflows/tdd.yaml +160 -0
  316. package/resources/workflows/waterfall.yaml +209 -0
  317. package/dist/components/beads/beads-instruction-generator.d.ts +0 -44
  318. package/dist/components/beads/beads-instruction-generator.d.ts.map +0 -1
  319. package/dist/components/beads/beads-instruction-generator.js +0 -160
  320. package/dist/components/beads/beads-instruction-generator.js.map +0 -1
  321. package/dist/components/beads/beads-plan-manager.d.ts.map +0 -1
  322. package/dist/components/beads/beads-plan-manager.js.map +0 -1
  323. package/dist/components/beads/beads-task-backend-client.d.ts +0 -43
  324. package/dist/components/beads/beads-task-backend-client.d.ts.map +0 -1
  325. package/dist/components/beads/beads-task-backend-client.js +0 -175
  326. package/dist/components/beads/beads-task-backend-client.js.map +0 -1
  327. package/dist/index.d.ts +0 -9
  328. package/dist/index.d.ts.map +0 -1
  329. package/dist/index.js +0 -74
  330. package/dist/index.js.map +0 -1
  331. package/dist/notification-service.d.ts +0 -14
  332. package/dist/notification-service.d.ts.map +0 -1
  333. package/dist/notification-service.js +0 -18
  334. package/dist/notification-service.js.map +0 -1
  335. package/dist/plugin-system/beads-plugin.d.ts +0 -71
  336. package/dist/plugin-system/beads-plugin.d.ts.map +0 -1
  337. package/dist/plugin-system/beads-plugin.js +0 -465
  338. package/dist/plugin-system/beads-plugin.js.map +0 -1
  339. package/dist/plugin-system/commit-plugin.d.ts +0 -40
  340. package/dist/plugin-system/commit-plugin.d.ts.map +0 -1
  341. package/dist/plugin-system/commit-plugin.js +0 -204
  342. package/dist/plugin-system/commit-plugin.js.map +0 -1
  343. package/dist/plugin-system/index.d.ts +0 -9
  344. package/dist/plugin-system/index.d.ts.map +0 -1
  345. package/dist/plugin-system/index.js +0 -9
  346. package/dist/plugin-system/index.js.map +0 -1
  347. package/dist/plugin-system/plugin-interfaces.d.ts +0 -98
  348. package/dist/plugin-system/plugin-interfaces.d.ts.map +0 -1
  349. package/dist/plugin-system/plugin-interfaces.js +0 -9
  350. package/dist/plugin-system/plugin-interfaces.js.map +0 -1
  351. package/dist/plugin-system/plugin-registry.d.ts +0 -44
  352. package/dist/plugin-system/plugin-registry.d.ts.map +0 -1
  353. package/dist/plugin-system/plugin-registry.js +0 -132
  354. package/dist/plugin-system/plugin-registry.js.map +0 -1
  355. package/dist/resource-handlers/conversation-state.d.ts +0 -15
  356. package/dist/resource-handlers/conversation-state.d.ts.map +0 -1
  357. package/dist/resource-handlers/conversation-state.js +0 -40
  358. package/dist/resource-handlers/conversation-state.js.map +0 -1
  359. package/dist/resource-handlers/development-plan.d.ts +0 -14
  360. package/dist/resource-handlers/development-plan.d.ts.map +0 -1
  361. package/dist/resource-handlers/development-plan.js +0 -31
  362. package/dist/resource-handlers/development-plan.js.map +0 -1
  363. package/dist/resource-handlers/index.d.ts +0 -24
  364. package/dist/resource-handlers/index.d.ts.map +0 -1
  365. package/dist/resource-handlers/index.js +0 -62
  366. package/dist/resource-handlers/index.js.map +0 -1
  367. package/dist/resource-handlers/system-prompt.d.ts +0 -15
  368. package/dist/resource-handlers/system-prompt.d.ts.map +0 -1
  369. package/dist/resource-handlers/system-prompt.js +0 -40
  370. package/dist/resource-handlers/system-prompt.js.map +0 -1
  371. package/dist/resource-handlers/workflow-resource.d.ts +0 -15
  372. package/dist/resource-handlers/workflow-resource.d.ts.map +0 -1
  373. package/dist/resource-handlers/workflow-resource.js +0 -85
  374. package/dist/resource-handlers/workflow-resource.js.map +0 -1
  375. package/dist/response-renderer.d.ts +0 -30
  376. package/dist/response-renderer.d.ts.map +0 -1
  377. package/dist/response-renderer.js +0 -94
  378. package/dist/response-renderer.js.map +0 -1
  379. package/dist/server-config.d.ts +0 -34
  380. package/dist/server-config.d.ts.map +0 -1
  381. package/dist/server-config.js +0 -503
  382. package/dist/server-config.js.map +0 -1
  383. package/dist/server-helpers.d.ts +0 -70
  384. package/dist/server-helpers.d.ts.map +0 -1
  385. package/dist/server-helpers.js +0 -171
  386. package/dist/server-helpers.js.map +0 -1
  387. package/dist/server-implementation.d.ts +0 -74
  388. package/dist/server-implementation.d.ts.map +0 -1
  389. package/dist/server-implementation.js +0 -201
  390. package/dist/server-implementation.js.map +0 -1
  391. package/dist/server.d.ts +0 -6
  392. package/dist/server.d.ts.map +0 -1
  393. package/dist/server.js +0 -5
  394. package/dist/server.js.map +0 -1
  395. package/dist/tool-handlers/base-tool-handler.d.ts +0 -50
  396. package/dist/tool-handlers/base-tool-handler.d.ts.map +0 -1
  397. package/dist/tool-handlers/base-tool-handler.js +0 -81
  398. package/dist/tool-handlers/base-tool-handler.js.map +0 -1
  399. package/dist/tool-handlers/conduct-review.d.ts +0 -49
  400. package/dist/tool-handlers/conduct-review.d.ts.map +0 -1
  401. package/dist/tool-handlers/conduct-review.js +0 -104
  402. package/dist/tool-handlers/conduct-review.js.map +0 -1
  403. package/dist/tool-handlers/get-tool-info.d.ts +0 -75
  404. package/dist/tool-handlers/get-tool-info.d.ts.map +0 -1
  405. package/dist/tool-handlers/get-tool-info.js +0 -168
  406. package/dist/tool-handlers/get-tool-info.js.map +0 -1
  407. package/dist/tool-handlers/index.d.ts +0 -41
  408. package/dist/tool-handlers/index.d.ts.map +0 -1
  409. package/dist/tool-handlers/index.js +0 -71
  410. package/dist/tool-handlers/index.js.map +0 -1
  411. package/dist/tool-handlers/list-workflows.d.ts +0 -35
  412. package/dist/tool-handlers/list-workflows.d.ts.map +0 -1
  413. package/dist/tool-handlers/list-workflows.js +0 -43
  414. package/dist/tool-handlers/list-workflows.js.map +0 -1
  415. package/dist/tool-handlers/no-idea.d.ts +0 -41
  416. package/dist/tool-handlers/no-idea.d.ts.map +0 -1
  417. package/dist/tool-handlers/no-idea.js +0 -29
  418. package/dist/tool-handlers/no-idea.js.map +0 -1
  419. package/dist/tool-handlers/proceed-to-phase.d.ts +0 -41
  420. package/dist/tool-handlers/proceed-to-phase.d.ts.map +0 -1
  421. package/dist/tool-handlers/proceed-to-phase.js +0 -165
  422. package/dist/tool-handlers/proceed-to-phase.js.map +0 -1
  423. package/dist/tool-handlers/reset-development.d.ts +0 -31
  424. package/dist/tool-handlers/reset-development.d.ts.map +0 -1
  425. package/dist/tool-handlers/reset-development.js +0 -48
  426. package/dist/tool-handlers/reset-development.js.map +0 -1
  427. package/dist/tool-handlers/resume-workflow.d.ts +0 -87
  428. package/dist/tool-handlers/resume-workflow.d.ts.map +0 -1
  429. package/dist/tool-handlers/resume-workflow.js +0 -212
  430. package/dist/tool-handlers/resume-workflow.js.map +0 -1
  431. package/dist/tool-handlers/setup-project-docs.d.ts +0 -37
  432. package/dist/tool-handlers/setup-project-docs.d.ts.map +0 -1
  433. package/dist/tool-handlers/setup-project-docs.js +0 -138
  434. package/dist/tool-handlers/setup-project-docs.js.map +0 -1
  435. package/dist/tool-handlers/start-development.d.ts +0 -79
  436. package/dist/tool-handlers/start-development.d.ts.map +0 -1
  437. package/dist/tool-handlers/start-development.js +0 -484
  438. package/dist/tool-handlers/start-development.js.map +0 -1
  439. package/dist/tool-handlers/whats-next.d.ts +0 -41
  440. package/dist/tool-handlers/whats-next.d.ts.map +0 -1
  441. package/dist/tool-handlers/whats-next.js +0 -123
  442. package/dist/tool-handlers/whats-next.js.map +0 -1
  443. package/dist/types.d.ts +0 -119
  444. package/dist/types.d.ts.map +0 -1
  445. package/dist/types.js +0 -5
  446. package/dist/version-info.d.ts +0 -30
  447. package/dist/version-info.d.ts.map +0 -1
  448. package/dist/version-info.js +0 -178
  449. package/dist/version-info.js.map +0 -1
  450. package/skill/SKILL.md +0 -28
  451. /package/{dist → packages/core/dist}/types.js.map +0 -0
@@ -0,0 +1,382 @@
1
+ /**
2
+ * Conversation Manager
3
+ *
4
+ * Handles conversation identification, state persistence, and coordination
5
+ * between components. Generates unique conversation identifiers from
6
+ * project path + git branch combination.
7
+ */
8
+ import { execSync } from 'node:child_process';
9
+ import { resolve } from 'node:path';
10
+ import { existsSync } from 'node:fs';
11
+ import { createLogger } from './logger.js';
12
+ import { getPathBasename } from './path-validation-utils.js';
13
+ import { PlanManager } from './plan-manager.js';
14
+ const logger = createLogger('ConversationManager');
15
+ export class ConversationManager {
16
+ database;
17
+ projectPath;
18
+ workflowManager;
19
+ constructor(database, workflowManager, projectPath) {
20
+ this.database = database;
21
+ this.workflowManager = workflowManager;
22
+ this.projectPath = projectPath;
23
+ }
24
+ /**
25
+ * Get conversation state by ID
26
+ */
27
+ async getConversationState(conversationId) {
28
+ return await this.database.getConversationState(conversationId);
29
+ }
30
+ /**
31
+ * Get the current conversation context
32
+ *
33
+ * Detects the current project path and git branch, then retrieves an existing
34
+ * conversation state for this context. Does NOT create a new conversation.
35
+ *
36
+ * @throws Error if no conversation exists for this context
37
+ */
38
+ async getConversationContext() {
39
+ const projectPath = this.getProjectPath();
40
+ const gitBranch = this.getGitBranch(projectPath);
41
+ logger.debug('Getting conversation context', { projectPath, gitBranch });
42
+ // Generate a unique conversation ID based on project path and git branch
43
+ const conversationId = this.generateConversationId(projectPath, gitBranch);
44
+ // Try to find existing conversation state
45
+ const state = await this.database.getConversationState(conversationId);
46
+ // If no existing state, throw an error - conversation must be created with start_development first
47
+ if (!state) {
48
+ logger.warn('No conversation found for context', {
49
+ projectPath,
50
+ gitBranch,
51
+ conversationId,
52
+ });
53
+ throw new Error('No development conversation exists for this project. Use the start_development tool first to initialize development with a workflow.');
54
+ }
55
+ // Return the conversation context
56
+ return {
57
+ conversationId: state.conversationId,
58
+ projectPath: state.projectPath,
59
+ gitBranch: state.gitBranch,
60
+ currentPhase: state.currentPhase,
61
+ planFilePath: state.planFilePath,
62
+ workflowName: state.workflowName,
63
+ };
64
+ }
65
+ /**
66
+ * Create a new conversation context
67
+ *
68
+ * This should only be called by the start_development tool to explicitly
69
+ * create a new conversation with a selected workflow.
70
+ *
71
+ * @param workflowName - The workflow to use for this conversation
72
+ * @param projectPathOverride - Optional project path override
73
+ * @returns The newly created conversation context
74
+ */
75
+ async createConversationContext(workflowName, projectPathOverride) {
76
+ const projectPath = projectPathOverride || this.getProjectPath();
77
+ const gitBranch = this.getGitBranch(projectPath);
78
+ logger.debug('Creating conversation context', {
79
+ projectPath,
80
+ gitBranch,
81
+ workflowName,
82
+ });
83
+ // Generate a unique conversation ID based on project path and git branch
84
+ const conversationId = this.generateConversationId(projectPath, gitBranch);
85
+ // Check if a conversation already exists
86
+ const existingState = await this.database.getConversationState(conversationId);
87
+ if (existingState) {
88
+ // Check if user is trying to change workflow
89
+ if (existingState.workflowName !== workflowName) {
90
+ const errorMessage = `Development conversation already exists with workflow '${existingState.workflowName}'. Cannot change to '${workflowName}'. Use reset_development() first to start with a new workflow.`;
91
+ logger.error('Attempted workflow change on existing conversation', new Error(errorMessage), {
92
+ existingWorkflow: existingState.workflowName,
93
+ requestedWorkflow: workflowName,
94
+ conversationId,
95
+ });
96
+ throw new Error(errorMessage);
97
+ }
98
+ logger.debug('Conversation already exists, returning existing context', {
99
+ conversationId,
100
+ });
101
+ return {
102
+ conversationId: existingState.conversationId,
103
+ projectPath: existingState.projectPath,
104
+ gitBranch: existingState.gitBranch,
105
+ currentPhase: existingState.currentPhase,
106
+ planFilePath: existingState.planFilePath,
107
+ workflowName: existingState.workflowName,
108
+ };
109
+ }
110
+ // Create a new conversation state
111
+ const state = await this.createNewConversationState(conversationId, projectPath, gitBranch, workflowName);
112
+ // Return the conversation context
113
+ return {
114
+ conversationId: state.conversationId,
115
+ projectPath: state.projectPath,
116
+ gitBranch: state.gitBranch,
117
+ currentPhase: state.currentPhase,
118
+ planFilePath: state.planFilePath,
119
+ workflowName: state.workflowName,
120
+ };
121
+ }
122
+ /**
123
+ * Update the conversation state
124
+ *
125
+ * @param conversationId - ID of the conversation to update
126
+ * @param updates - Partial state updates to apply
127
+ */
128
+ async updateConversationState(conversationId, updates) {
129
+ logger.debug('Updating conversation state', { conversationId, updates });
130
+ // Get current state
131
+ const currentState = await this.database.getConversationState(conversationId);
132
+ if (!currentState) {
133
+ throw new Error(`Conversation state not found for ID: ${conversationId}`);
134
+ }
135
+ // Apply updates
136
+ const updatedState = {
137
+ ...currentState,
138
+ ...updates,
139
+ updatedAt: new Date().toISOString(),
140
+ };
141
+ // Save updated state
142
+ await this.database.saveConversationState(updatedState);
143
+ logger.info('Conversation state updated', {
144
+ conversationId,
145
+ currentPhase: updatedState.currentPhase,
146
+ });
147
+ }
148
+ /**
149
+ * Create a new conversation state
150
+ *
151
+ * @param conversationId - ID for the new conversation
152
+ * @param projectPath - Path to the project
153
+ * @param gitBranch - Git branch name
154
+ */
155
+ async createNewConversationState(conversationId, projectPath, gitBranch, workflowName = 'waterfall') {
156
+ logger.info('Creating new conversation state', {
157
+ conversationId,
158
+ projectPath,
159
+ gitBranch,
160
+ });
161
+ const timestamp = new Date().toISOString();
162
+ // Generate a plan file path based on the branch name
163
+ // Sanitize branch name by replacing slashes and other special characters
164
+ const sanitizedBranch = gitBranch.replace(/[/\\]/g, '-');
165
+ const planFileName = gitBranch === 'main' || gitBranch === 'master'
166
+ ? 'development-plan.md'
167
+ : `development-plan-${sanitizedBranch}.md`;
168
+ const planFilePath = resolve(projectPath, '.vibe', planFileName);
169
+ // Get initial state from the appropriate workflow
170
+ const stateMachine = this.workflowManager.loadWorkflowForProject(projectPath, workflowName);
171
+ const initialPhase = stateMachine.initial_state;
172
+ // Create new state
173
+ const newState = {
174
+ conversationId,
175
+ projectPath,
176
+ gitBranch,
177
+ currentPhase: initialPhase,
178
+ planFilePath,
179
+ workflowName,
180
+ requireReviewsBeforePhaseTransition: false, // Default to false for new conversations
181
+ createdAt: timestamp,
182
+ updatedAt: timestamp,
183
+ };
184
+ // Save to database
185
+ await this.database.saveConversationState(newState);
186
+ logger.info('New conversation state created', {
187
+ conversationId,
188
+ planFilePath,
189
+ initialPhase,
190
+ });
191
+ return newState;
192
+ }
193
+ /**
194
+ * Generate a unique conversation ID based on project path and git branch
195
+ *
196
+ * @param projectPath - Path to the project
197
+ * @param gitBranch - Git branch name
198
+ */
199
+ generateConversationId(projectPath, gitBranch) {
200
+ // Extract project name from path (cross-platform: handles both / and \)
201
+ const projectName = getPathBasename(projectPath, 'unknown-project');
202
+ // Clean branch name for use in ID
203
+ const cleanBranch = gitBranch
204
+ .replace(/[^a-zA-Z0-9-]/g, '-')
205
+ .replace(/-+/g, '-')
206
+ .replace(/^-|-$/g, '');
207
+ // For tests, use a deterministic ID
208
+ if (process.env['NODE_ENV'] === 'test') {
209
+ return `${projectName}-${cleanBranch}-p423k1`;
210
+ }
211
+ // Generate a deterministic ID based on project path and branch
212
+ // This ensures the same project/branch combination always gets the same conversation ID
213
+ let hash = 0;
214
+ const str = `${projectPath}:${gitBranch}`;
215
+ for (let i = 0; i < str.length; i++) {
216
+ const char = str.charCodeAt(i);
217
+ hash = (hash << 5) - hash + char;
218
+ hash = hash & hash; // Convert to 32-bit integer
219
+ }
220
+ const hashStr = Math.abs(hash).toString(36).substring(0, 6);
221
+ return `${projectName}-${cleanBranch}-${hashStr}`;
222
+ }
223
+ /**
224
+ * Get the current project path
225
+ */
226
+ getProjectPath() {
227
+ return this.projectPath;
228
+ }
229
+ /**
230
+ * Get the current git branch for a project
231
+ *
232
+ * @param projectPath - Path to the project
233
+ */
234
+ getGitBranch(projectPath) {
235
+ try {
236
+ // Check if this is a git repository
237
+ if (!existsSync(`${projectPath}/.git`)) {
238
+ logger.debug('Not a git repository, using "default" as branch name', {
239
+ projectPath,
240
+ });
241
+ return 'default';
242
+ }
243
+ // Get current branch name
244
+ // Use symbolic-ref which works even without commits (unlike rev-parse --abbrev-ref HEAD)
245
+ const branch = execSync('git symbolic-ref --short HEAD', {
246
+ cwd: projectPath,
247
+ encoding: 'utf-8',
248
+ stdio: ['ignore', 'pipe', 'ignore'], // Suppress stderr
249
+ }).trim();
250
+ logger.debug('Detected git branch', { projectPath, branch });
251
+ return branch;
252
+ }
253
+ catch (_error) {
254
+ logger.debug('Failed to get git branch, using "default" as branch name', {
255
+ projectPath,
256
+ });
257
+ return 'default';
258
+ }
259
+ }
260
+ /**
261
+ * Check if a conversation has any previous interactions
262
+ * Used to determine if this is the first interaction in a conversation
263
+ */
264
+ async hasInteractions(conversationId) {
265
+ try {
266
+ // Get all interactions for this conversation
267
+ const interactions = await this.database.getInteractionsByConversationId(conversationId);
268
+ const count = interactions.length;
269
+ logger.debug('Checked interaction count for conversation', {
270
+ conversationId,
271
+ count,
272
+ });
273
+ return count > 0;
274
+ }
275
+ catch (error) {
276
+ logger.error('Failed to check interaction count', error, {
277
+ conversationId,
278
+ });
279
+ // If we can't check, assume this is the first interaction to be safe
280
+ return false;
281
+ }
282
+ }
283
+ /**
284
+ * Reset conversation data (hybrid approach)
285
+ */
286
+ async resetConversation(confirm, reason) {
287
+ logger.info('Starting conversation reset', { confirm, reason });
288
+ // Validate reset request
289
+ this.validateResetRequest(confirm);
290
+ const context = await this.getConversationContext();
291
+ const resetItems = [];
292
+ try {
293
+ // Step 1: Soft delete interaction logs
294
+ await this.database.softDeleteInteractionLogs(context.conversationId);
295
+ resetItems.push('interaction_logs');
296
+ logger.debug('Interaction logs soft deleted');
297
+ // Step 2: Hard delete conversation state
298
+ await this.database.deleteConversationState(context.conversationId);
299
+ resetItems.push('conversation_state');
300
+ logger.debug('Conversation state hard deleted');
301
+ // Step 3: Hard delete plan file
302
+ const planManager = new PlanManager();
303
+ await planManager.deletePlanFile(context.planFilePath);
304
+ resetItems.push('plan_file');
305
+ logger.debug('Plan file deleted');
306
+ // Verify cleanup
307
+ await this.verifyResetCleanup(context.conversationId, context.planFilePath);
308
+ const message = `Successfully reset conversation ${context.conversationId}. Reset items: ${resetItems.join(', ')}${reason ? `. Reason: ${reason}` : ''}`;
309
+ logger.info('Conversation reset completed successfully', {
310
+ conversationId: context.conversationId,
311
+ resetItems,
312
+ reason,
313
+ });
314
+ return {
315
+ success: true,
316
+ resetItems,
317
+ conversationId: context.conversationId,
318
+ message,
319
+ };
320
+ }
321
+ catch (error) {
322
+ logger.error('Failed to reset conversation', error, {
323
+ conversationId: context.conversationId,
324
+ resetItems,
325
+ reason,
326
+ });
327
+ throw new Error(`Reset failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
328
+ }
329
+ }
330
+ /**
331
+ * Validate reset request parameters
332
+ */
333
+ validateResetRequest(confirm) {
334
+ if (!confirm) {
335
+ throw new Error('Reset operation requires explicit confirmation. Set confirm parameter to true.');
336
+ }
337
+ }
338
+ /**
339
+ * Verify that reset cleanup was successful
340
+ */
341
+ async verifyResetCleanup(conversationId, planFilePath) {
342
+ logger.debug('Verifying reset cleanup', { conversationId, planFilePath });
343
+ try {
344
+ // Check that conversation state is deleted
345
+ const state = await this.database.getConversationState(conversationId);
346
+ if (state) {
347
+ throw new Error('Conversation state was not properly deleted');
348
+ }
349
+ // Check that plan file is deleted
350
+ const planManager = new PlanManager();
351
+ const isDeleted = await planManager.ensurePlanFileDeleted(planFilePath);
352
+ if (!isDeleted) {
353
+ throw new Error('Plan file was not properly deleted');
354
+ }
355
+ logger.debug('Reset cleanup verification successful');
356
+ }
357
+ catch (error) {
358
+ logger.error('Reset cleanup verification failed', error);
359
+ throw error;
360
+ }
361
+ }
362
+ /**
363
+ * Clean up conversation data (used internally)
364
+ */
365
+ async cleanupConversationData(conversationId) {
366
+ logger.debug('Cleaning up conversation data', { conversationId });
367
+ try {
368
+ // This method can be used for additional cleanup if needed
369
+ // Currently, the main cleanup is handled by resetConversation
370
+ await this.database.softDeleteInteractionLogs(conversationId);
371
+ await this.database.deleteConversationState(conversationId);
372
+ logger.debug('Conversation data cleanup completed', { conversationId });
373
+ }
374
+ catch (error) {
375
+ logger.error('Failed to cleanup conversation data', error, {
376
+ conversationId,
377
+ });
378
+ throw error;
379
+ }
380
+ }
381
+ }
382
+ //# sourceMappingURL=conversation-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-manager.js","sourceRoot":"","sources":["../src/conversation-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAI7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAEnD,MAAM,OAAO,mBAAmB;IACtB,QAAQ,CAAe;IACvB,WAAW,CAAS;IACpB,eAAe,CAAkB;IAEzC,YACE,QAAsB,EACtB,eAAgC,EAChC,WAAmB;QAEnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,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mCAAmC,EAAE,KAAc,CAAC,CAAC;YAClE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,uBAAuB,CAAC,cAAsB;QAClD,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC;YACH,2DAA2D;YAC3D,8DAA8D;YAC9D,MAAM,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,cAAc,CAAC,CAAC;YAC9D,MAAM,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;YAE5D,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAC1E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAc,EAAE;gBAClE,cAAc;aACf,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * File Detection Manager
3
+ *
4
+ * Handles pattern-based file discovery and suggestions for existing documentation files.
5
+ * Supports auto-detection of common documentation patterns in projects.
6
+ */
7
+ export interface DetectedFile {
8
+ path: string;
9
+ relativePath: string;
10
+ type: 'architecture' | 'requirements' | 'design';
11
+ confidence: 'high' | 'medium' | 'low';
12
+ }
13
+ export interface FileDetectionResult {
14
+ architecture: DetectedFile[];
15
+ requirements: DetectedFile[];
16
+ design: DetectedFile[];
17
+ }
18
+ export declare class FileDetectionManager {
19
+ private projectPath;
20
+ constructor(projectPath: string);
21
+ /**
22
+ * Detect existing documentation files in the project
23
+ */
24
+ detectDocumentationFiles(): Promise<FileDetectionResult>;
25
+ /**
26
+ * Get search locations for documentation files
27
+ */
28
+ private getSearchLocations;
29
+ /**
30
+ * Scan a location for files
31
+ */
32
+ private scanLocation;
33
+ /**
34
+ * Match a file against documentation patterns
35
+ */
36
+ private matchFileToPatterns;
37
+ /**
38
+ * Check if file matches any of the patterns
39
+ */
40
+ private matchesPatterns;
41
+ /**
42
+ * Determine confidence level for a match
43
+ */
44
+ private getConfidence;
45
+ /**
46
+ * Sort by confidence and remove duplicates
47
+ */
48
+ private sortAndDeduplicate;
49
+ /**
50
+ * Format file suggestions for LLM responses
51
+ */
52
+ formatSuggestions(detectionResult: FileDetectionResult): string;
53
+ }
@@ -0,0 +1,221 @@
1
+ /**
2
+ * File Detection Manager
3
+ *
4
+ * Handles pattern-based file discovery and suggestions for existing documentation files.
5
+ * Supports auto-detection of common documentation patterns in projects.
6
+ */
7
+ import { readdir, access } from 'node:fs/promises';
8
+ import { join, basename } from 'node:path';
9
+ import { createLogger } from './logger.js';
10
+ import { PathValidationUtils } from './path-validation-utils.js';
11
+ const logger = createLogger('FileDetectionManager');
12
+ export class FileDetectionManager {
13
+ projectPath;
14
+ constructor(projectPath) {
15
+ this.projectPath = projectPath;
16
+ }
17
+ /**
18
+ * Detect existing documentation files in the project
19
+ */
20
+ async detectDocumentationFiles() {
21
+ logger.debug('Starting documentation file detection', {
22
+ projectPath: this.projectPath,
23
+ });
24
+ const searchLocations = this.getSearchLocations();
25
+ const patterns = PathValidationUtils.getCommonDocumentationPatterns();
26
+ const result = {
27
+ architecture: [],
28
+ requirements: [],
29
+ design: [],
30
+ };
31
+ // Search in each location
32
+ for (const location of searchLocations) {
33
+ try {
34
+ await access(location);
35
+ const files = await this.scanLocation(location);
36
+ // Match files against patterns
37
+ for (const file of files) {
38
+ const matches = this.matchFileToPatterns(file, patterns);
39
+ for (const match of matches) {
40
+ result[match.type].push({
41
+ path: file.path,
42
+ relativePath: file.relativePath,
43
+ type: match.type,
44
+ confidence: match.confidence,
45
+ });
46
+ }
47
+ }
48
+ }
49
+ catch (error) {
50
+ logger.debug('Search location not accessible', {
51
+ location,
52
+ error: error instanceof Error ? error.message : 'Unknown error',
53
+ });
54
+ }
55
+ }
56
+ // Sort by confidence and remove duplicates
57
+ result.architecture = this.sortAndDeduplicate(result.architecture);
58
+ result.requirements = this.sortAndDeduplicate(result.requirements);
59
+ result.design = this.sortAndDeduplicate(result.design);
60
+ logger.info('Documentation file detection completed', {
61
+ found: {
62
+ architecture: result.architecture.length,
63
+ requirements: result.requirements.length,
64
+ design: result.design.length,
65
+ },
66
+ });
67
+ return result;
68
+ }
69
+ /**
70
+ * Get search locations for documentation files
71
+ */
72
+ getSearchLocations() {
73
+ return [
74
+ this.projectPath, // Project root
75
+ join(this.projectPath, 'docs'), // docs/ folder
76
+ join(this.projectPath, 'doc'), // doc/ folder
77
+ join(this.projectPath, '.vibe', 'docs'), // .vibe/docs/ folder
78
+ join(this.projectPath, 'documentation'), // documentation/ folder
79
+ ];
80
+ }
81
+ /**
82
+ * Scan a location for files
83
+ */
84
+ async scanLocation(location) {
85
+ try {
86
+ const entries = await readdir(location, { withFileTypes: true });
87
+ const files = [];
88
+ for (const entry of entries) {
89
+ if (entry.isFile()) {
90
+ const fullPath = join(location, entry.name);
91
+ const relativePath = fullPath.replace(this.projectPath + '/', '');
92
+ files.push({
93
+ path: fullPath,
94
+ relativePath,
95
+ });
96
+ }
97
+ }
98
+ return files;
99
+ }
100
+ catch (error) {
101
+ logger.debug('Failed to scan location', {
102
+ location,
103
+ error: error instanceof Error ? error.message : 'Unknown error',
104
+ });
105
+ return [];
106
+ }
107
+ }
108
+ /**
109
+ * Match a file against documentation patterns
110
+ */
111
+ matchFileToPatterns(file, patterns) {
112
+ const fileName = basename(file.path).toLowerCase();
113
+ const relativePath = file.relativePath.toLowerCase();
114
+ const matches = [];
115
+ // Check architecture patterns
116
+ if (this.matchesPatterns(fileName, relativePath, patterns.architecture)) {
117
+ const confidence = this.getConfidence(fileName, 'architecture');
118
+ matches.push({ type: 'architecture', confidence });
119
+ }
120
+ // Check requirements patterns
121
+ if (this.matchesPatterns(fileName, relativePath, patterns.requirements)) {
122
+ const confidence = this.getConfidence(fileName, 'requirements');
123
+ matches.push({ type: 'requirements', confidence });
124
+ }
125
+ // Check design patterns
126
+ if (this.matchesPatterns(fileName, relativePath, patterns.design)) {
127
+ const confidence = this.getConfidence(fileName, 'design');
128
+ matches.push({ type: 'design', confidence });
129
+ }
130
+ return matches;
131
+ }
132
+ /**
133
+ * Check if file matches any of the patterns
134
+ */
135
+ matchesPatterns(fileName, relativePath, patterns) {
136
+ return patterns.some(pattern => {
137
+ const normalizedPattern = pattern.toLowerCase();
138
+ // Exact filename match
139
+ if (fileName === normalizedPattern) {
140
+ return true;
141
+ }
142
+ // Relative path match
143
+ if (relativePath === normalizedPattern) {
144
+ return true;
145
+ }
146
+ // Pattern matching with wildcards
147
+ if (normalizedPattern.includes('*')) {
148
+ const regex = new RegExp(normalizedPattern.replace(/\*/g, '.*'));
149
+ return regex.test(fileName) || regex.test(relativePath);
150
+ }
151
+ return false;
152
+ });
153
+ }
154
+ /**
155
+ * Determine confidence level for a match
156
+ */
157
+ getConfidence(fileName, type) {
158
+ // High confidence for exact type matches
159
+ if (fileName.includes(type.toLowerCase())) {
160
+ return 'high';
161
+ }
162
+ // Medium confidence for README files (could contain any type)
163
+ if (fileName.includes('readme')) {
164
+ return 'medium';
165
+ }
166
+ // Low confidence for other matches
167
+ return 'low';
168
+ }
169
+ /**
170
+ * Sort by confidence and remove duplicates
171
+ */
172
+ sortAndDeduplicate(files) {
173
+ // Remove duplicates by path
174
+ const unique = files.filter((file, index, array) => array.findIndex(f => f.path === file.path) === index);
175
+ // Sort by confidence (high first) and then by path length (shorter first)
176
+ return unique.sort((a, b) => {
177
+ const confidenceOrder = { high: 0, medium: 1, low: 2 };
178
+ const confidenceDiff = confidenceOrder[a.confidence] - confidenceOrder[b.confidence];
179
+ if (confidenceDiff !== 0) {
180
+ return confidenceDiff;
181
+ }
182
+ return a.relativePath.length - b.relativePath.length;
183
+ });
184
+ }
185
+ /**
186
+ * Format file suggestions for LLM responses
187
+ */
188
+ formatSuggestions(detectionResult) {
189
+ const suggestions = [];
190
+ if (detectionResult.architecture.length > 0) {
191
+ suggestions.push(`**Architecture files found:**`);
192
+ for (const file of detectionResult.architecture.slice(0, 3)) {
193
+ suggestions.push(` - ${file.relativePath} (${file.confidence} confidence)`);
194
+ }
195
+ }
196
+ if (detectionResult.requirements.length > 0) {
197
+ suggestions.push(`**Requirements files found:**`);
198
+ for (const file of detectionResult.requirements.slice(0, 3)) {
199
+ suggestions.push(` - ${file.relativePath} (${file.confidence} confidence)`);
200
+ }
201
+ }
202
+ if (detectionResult.design.length > 0) {
203
+ suggestions.push(`**Design files found:**`);
204
+ for (const file of detectionResult.design.slice(0, 3)) {
205
+ suggestions.push(` - ${file.relativePath} (${file.confidence} confidence)`);
206
+ }
207
+ }
208
+ if (suggestions.length === 0) {
209
+ return 'No existing documentation files detected.';
210
+ }
211
+ return [
212
+ 'Existing documentation files detected:',
213
+ '',
214
+ ...suggestions,
215
+ '',
216
+ 'You can use these files with `setup_project_docs` by providing the file paths instead of template names.',
217
+ 'Example: `setup_project_docs({ architecture: "README.md", requirements: "docs/requirements.md", design: "freestyle" })`',
218
+ ].join('\n');
219
+ }
220
+ }
221
+ //# sourceMappingURL=file-detection-manager.js.map