bmalph 1.0.0 → 2.2.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 (455) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +398 -217
  3. package/bmad/bmm/agents/analyst.agent.yaml +43 -36
  4. package/bmad/bmm/agents/architect.agent.yaml +29 -28
  5. package/bmad/bmm/agents/dev.agent.yaml +38 -38
  6. package/bmad/bmm/agents/pm.agent.yaml +44 -46
  7. package/bmad/bmm/agents/qa.agent.yaml +58 -0
  8. package/bmad/bmm/agents/quick-flow-solo-dev.agent.yaml +32 -32
  9. package/bmad/bmm/agents/sm.agent.yaml +37 -36
  10. package/bmad/bmm/agents/tech-writer/tech-writer-sidecar/documentation-standards.md +223 -223
  11. package/bmad/bmm/agents/tech-writer/tech-writer.agent.yaml +46 -45
  12. package/bmad/bmm/agents/ux-designer.agent.yaml +27 -26
  13. package/bmad/bmm/data/project-context-template.md +26 -26
  14. package/bmad/bmm/module-help.csv +31 -31
  15. package/bmad/bmm/module.yaml +50 -44
  16. package/bmad/bmm/teams/default-party.csv +20 -21
  17. package/bmad/bmm/teams/team-fullstack.yaml +12 -12
  18. package/bmad/bmm/workflows/1-analysis/create-product-brief/product-brief.template.md +10 -10
  19. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-01-init.md +177 -177
  20. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-01b-continue.md +161 -161
  21. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-02-vision.md +199 -199
  22. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-03-users.md +202 -202
  23. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-04-metrics.md +205 -205
  24. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-05-scope.md +219 -219
  25. package/bmad/bmm/workflows/1-analysis/create-product-brief/steps/step-06-complete.md +162 -162
  26. package/bmad/bmm/workflows/1-analysis/create-product-brief/workflow.md +57 -58
  27. package/bmad/bmm/workflows/1-analysis/research/domain-steps/step-01-init.md +137 -137
  28. package/bmad/bmm/workflows/1-analysis/research/domain-steps/step-02-domain-analysis.md +229 -229
  29. package/bmad/bmm/workflows/1-analysis/research/domain-steps/step-03-competitive-landscape.md +238 -238
  30. package/bmad/bmm/workflows/1-analysis/research/domain-steps/step-04-regulatory-focus.md +206 -206
  31. package/bmad/bmm/workflows/1-analysis/research/domain-steps/step-05-technical-trends.md +234 -234
  32. package/bmad/bmm/workflows/1-analysis/research/domain-steps/step-06-research-synthesis.md +443 -443
  33. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-01-init.md +182 -182
  34. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-02-customer-behavior.md +237 -237
  35. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-03-customer-pain-points.md +249 -249
  36. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-04-customer-decisions.md +259 -259
  37. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-05-competitive-analysis.md +177 -177
  38. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-06-research-completion.md +475 -475
  39. package/bmad/bmm/workflows/1-analysis/research/research.template.md +29 -29
  40. package/bmad/bmm/workflows/1-analysis/research/technical-steps/step-01-init.md +137 -137
  41. package/bmad/bmm/workflows/1-analysis/research/technical-steps/step-02-technical-overview.md +239 -239
  42. package/bmad/bmm/workflows/1-analysis/research/technical-steps/step-03-integration-patterns.md +248 -248
  43. package/bmad/bmm/workflows/1-analysis/research/technical-steps/step-04-architectural-patterns.md +202 -202
  44. package/bmad/bmm/workflows/1-analysis/research/technical-steps/step-05-implementation-research.md +233 -239
  45. package/bmad/bmm/workflows/1-analysis/research/technical-steps/step-06-research-synthesis.md +486 -486
  46. package/bmad/bmm/workflows/1-analysis/research/workflow-domain-research.md +54 -0
  47. package/bmad/bmm/workflows/1-analysis/research/workflow-market-research.md +54 -0
  48. package/bmad/bmm/workflows/1-analysis/research/workflow-technical-research.md +54 -0
  49. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/data/domain-complexity.csv +14 -12
  50. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/data/prd-purpose.md +197 -197
  51. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/data/project-types.csv +10 -10
  52. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-01-init.md +191 -191
  53. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-01b-continue.md +153 -153
  54. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-02-discovery.md +224 -224
  55. package/bmad/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02b-vision.md +154 -0
  56. package/bmad/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02c-executive-summary.md +170 -0
  57. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-03-success.md +226 -226
  58. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-04-journeys.md +213 -213
  59. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-05-domain.md +207 -207
  60. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-06-innovation.md +226 -226
  61. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-07-project-type.md +237 -237
  62. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-08-scoping.md +228 -228
  63. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-09-functional.md +231 -231
  64. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-10-nonfunctional.md +242 -242
  65. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-11-polish.md +217 -217
  66. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-c/step-12-complete.md +124 -124
  67. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-e/step-e-01-discovery.md +247 -247
  68. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-e/step-e-01b-legacy-conversion.md +208 -208
  69. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-e/step-e-02-review.md +249 -249
  70. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-e/step-e-03-edit.md +253 -253
  71. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-e/step-e-04-complete.md +168 -168
  72. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-01-discovery.md +226 -218
  73. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-02-format-detection.md +191 -191
  74. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-02b-parity-check.md +209 -209
  75. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-03-density-validation.md +174 -174
  76. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-04-brief-coverage-validation.md +214 -214
  77. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-05-measurability-validation.md +228 -228
  78. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-06-traceability-validation.md +217 -217
  79. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-07-implementation-leakage-validation.md +205 -205
  80. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-08-domain-compliance-validation.md +243 -243
  81. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-09-project-type-validation.md +263 -263
  82. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-10-smart-validation.md +209 -209
  83. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-11-holistic-quality-validation.md +264 -264
  84. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-12-completeness-validation.md +242 -242
  85. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/steps-v/step-v-13-report-complete.md +231 -231
  86. package/bmad/bmm/workflows/2-plan-workflows/{prd → create-prd}/templates/prd-template.md +10 -10
  87. package/bmad/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md +63 -0
  88. package/bmad/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +65 -0
  89. package/bmad/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +63 -0
  90. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-01-init.md +135 -135
  91. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-01b-continue.md +127 -127
  92. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-02-discovery.md +190 -190
  93. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-03-core-experience.md +216 -216
  94. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-04-emotional-response.md +219 -219
  95. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-05-inspiration.md +234 -234
  96. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-06-design-system.md +252 -252
  97. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-07-defining-experience.md +254 -254
  98. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-08-visual-foundation.md +224 -224
  99. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-09-design-directions.md +224 -224
  100. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-10-user-journeys.md +241 -241
  101. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-11-component-strategy.md +248 -248
  102. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-12-ux-patterns.md +237 -237
  103. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-13-responsive-accessibility.md +264 -264
  104. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-14-complete.md +171 -171
  105. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/ux-design-template.md +13 -13
  106. package/bmad/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +42 -43
  107. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-01-document-discovery.md +184 -190
  108. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-02-prd-analysis.md +172 -178
  109. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-03-epic-coverage-validation.md +173 -179
  110. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-04-ux-alignment.md +133 -139
  111. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-05-epic-quality-review.md +245 -252
  112. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-06-final-assessment.md +129 -135
  113. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/templates/readiness-report-template.md +4 -4
  114. package/bmad/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +54 -55
  115. package/bmad/bmm/workflows/3-solutioning/create-architecture/architecture-decision-template.md +12 -12
  116. package/bmad/bmm/workflows/3-solutioning/create-architecture/data/domain-complexity.csv +12 -10
  117. package/bmad/bmm/workflows/3-solutioning/create-architecture/data/project-types.csv +6 -6
  118. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-01-init.md +153 -153
  119. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-01b-continue.md +164 -164
  120. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-02-context.md +224 -224
  121. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-03-starter.md +331 -331
  122. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-04-decisions.md +318 -318
  123. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-05-patterns.md +359 -359
  124. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-06-structure.md +379 -379
  125. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-07-validation.md +359 -359
  126. package/bmad/bmm/workflows/3-solutioning/create-architecture/steps/step-08-complete.md +76 -76
  127. package/bmad/bmm/workflows/3-solutioning/create-architecture/workflow.md +49 -50
  128. package/bmad/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-01-validate-prerequisites.md +259 -259
  129. package/bmad/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-02-design-epics.md +233 -233
  130. package/bmad/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-03-create-stories.md +272 -272
  131. package/bmad/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-04-final-validation.md +149 -149
  132. package/bmad/bmm/workflows/3-solutioning/create-epics-and-stories/templates/epics-template.md +57 -57
  133. package/bmad/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +58 -59
  134. package/bmad/bmm/workflows/4-implementation/code-review/checklist.md +23 -23
  135. package/bmad/bmm/workflows/4-implementation/code-review/instructions.xml +226 -226
  136. package/bmad/bmm/workflows/4-implementation/code-review/workflow.yaml +44 -51
  137. package/bmad/bmm/workflows/4-implementation/correct-course/checklist.md +288 -288
  138. package/bmad/bmm/workflows/4-implementation/correct-course/instructions.md +207 -206
  139. package/bmad/bmm/workflows/4-implementation/correct-course/workflow.yaml +54 -60
  140. package/bmad/bmm/workflows/4-implementation/create-story/checklist.md +358 -358
  141. package/bmad/bmm/workflows/4-implementation/create-story/instructions.xml +346 -345
  142. package/bmad/bmm/workflows/4-implementation/create-story/template.md +49 -49
  143. package/bmad/bmm/workflows/4-implementation/create-story/workflow.yaml +53 -61
  144. package/bmad/bmm/workflows/4-implementation/dev-story/checklist.md +80 -80
  145. package/bmad/bmm/workflows/4-implementation/dev-story/instructions.xml +410 -410
  146. package/bmad/bmm/workflows/4-implementation/dev-story/workflow.yaml +21 -27
  147. package/bmad/bmm/workflows/4-implementation/retrospective/instructions.md +1444 -1443
  148. package/bmad/bmm/workflows/4-implementation/retrospective/workflow.yaml +53 -58
  149. package/bmad/bmm/workflows/4-implementation/sprint-planning/checklist.md +33 -33
  150. package/bmad/bmm/workflows/4-implementation/sprint-planning/instructions.md +226 -225
  151. package/bmad/bmm/workflows/4-implementation/sprint-planning/sprint-status-template.yaml +55 -55
  152. package/bmad/bmm/workflows/4-implementation/sprint-planning/workflow.yaml +47 -54
  153. package/bmad/bmm/workflows/4-implementation/sprint-status/instructions.md +230 -229
  154. package/bmad/bmm/workflows/4-implementation/sprint-status/workflow.yaml +25 -36
  155. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-01-mode-detection.md +174 -156
  156. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-02-context-gathering.md +118 -120
  157. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-03-execute.md +111 -113
  158. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-04-self-check.md +111 -113
  159. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-05-adversarial-review.md +104 -106
  160. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-06-resolve-findings.md +146 -140
  161. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +50 -50
  162. package/bmad/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-01-understand.md +191 -189
  163. package/bmad/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-02-investigate.md +144 -144
  164. package/bmad/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-03-generate.md +127 -128
  165. package/bmad/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-04-review.md +200 -191
  166. package/bmad/bmm/workflows/bmad-quick-flow/quick-spec/tech-spec-template.md +74 -74
  167. package/bmad/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +79 -79
  168. package/bmad/bmm/workflows/document-project/checklist.md +245 -245
  169. package/bmad/bmm/workflows/document-project/documentation-requirements.csv +12 -12
  170. package/bmad/bmm/workflows/document-project/instructions.md +130 -221
  171. package/bmad/bmm/workflows/document-project/templates/deep-dive-template.md +345 -345
  172. package/bmad/bmm/workflows/document-project/templates/index-template.md +169 -169
  173. package/bmad/bmm/workflows/document-project/templates/project-overview-template.md +103 -103
  174. package/bmad/bmm/workflows/document-project/templates/project-scan-report-schema.json +160 -160
  175. package/bmad/bmm/workflows/document-project/templates/source-tree-template.md +135 -135
  176. package/bmad/bmm/workflows/document-project/workflow.yaml +22 -30
  177. package/bmad/bmm/workflows/document-project/workflows/deep-dive-instructions.md +298 -298
  178. package/bmad/bmm/workflows/document-project/workflows/deep-dive.yaml +31 -31
  179. package/bmad/bmm/workflows/document-project/workflows/full-scan-instructions.md +1106 -1106
  180. package/bmad/bmm/workflows/document-project/workflows/full-scan.yaml +31 -31
  181. package/bmad/bmm/workflows/generate-project-context/project-context-template.md +21 -0
  182. package/bmad/bmm/workflows/generate-project-context/steps/step-01-discover.md +184 -0
  183. package/bmad/bmm/workflows/generate-project-context/steps/step-02-generate.md +318 -0
  184. package/bmad/bmm/workflows/generate-project-context/steps/step-03-complete.md +278 -0
  185. package/bmad/bmm/workflows/generate-project-context/workflow.md +49 -0
  186. package/bmad/bmm/workflows/qa/automate/checklist.md +33 -0
  187. package/bmad/bmm/workflows/qa/automate/instructions.md +110 -0
  188. package/bmad/bmm/workflows/qa/automate/workflow.yaml +44 -0
  189. package/bmad/core/agents/bmad-master.agent.yaml +30 -30
  190. package/bmad/core/module-help.csv +9 -11
  191. package/bmad/core/module.yaml +25 -25
  192. package/bmad/core/tasks/editorial-review-prose.xml +102 -91
  193. package/bmad/core/tasks/editorial-review-structure.xml +209 -198
  194. package/bmad/core/tasks/help.md +85 -0
  195. package/bmad/core/tasks/index-docs.xml +64 -64
  196. package/bmad/core/tasks/review-adversarial-general.xml +48 -48
  197. package/bmad/core/tasks/shard-doc.xml +107 -108
  198. package/bmad/core/tasks/workflow.xml +234 -234
  199. package/bmad/core/workflows/advanced-elicitation/methods.csv +51 -51
  200. package/bmad/core/workflows/advanced-elicitation/workflow.xml +116 -116
  201. package/bmad/core/workflows/brainstorming/brain-methods.csv +61 -61
  202. package/bmad/core/workflows/brainstorming/steps/step-01-session-setup.md +197 -197
  203. package/bmad/core/workflows/brainstorming/steps/step-01b-continue.md +122 -122
  204. package/bmad/core/workflows/brainstorming/steps/step-02a-user-selected.md +225 -225
  205. package/bmad/core/workflows/brainstorming/steps/step-02b-ai-recommended.md +237 -237
  206. package/bmad/core/workflows/brainstorming/steps/step-02c-random-selection.md +209 -209
  207. package/bmad/core/workflows/brainstorming/steps/step-02d-progressive-flow.md +264 -264
  208. package/bmad/core/workflows/brainstorming/steps/step-03-technique-execution.md +399 -399
  209. package/bmad/core/workflows/brainstorming/steps/step-04-idea-organization.md +303 -303
  210. package/bmad/core/workflows/brainstorming/template.md +15 -15
  211. package/bmad/core/workflows/brainstorming/workflow.md +58 -58
  212. package/bmad/core/workflows/party-mode/steps/step-01-agent-loading.md +138 -138
  213. package/bmad/core/workflows/party-mode/steps/step-02-discussion-orchestration.md +187 -187
  214. package/bmad/core/workflows/party-mode/steps/step-03-graceful-exit.md +168 -157
  215. package/bmad/core/workflows/party-mode/workflow.md +194 -194
  216. package/bundled-versions.json +3 -0
  217. package/dist/cli.js +61 -6
  218. package/dist/commands/check-updates.d.ts +5 -0
  219. package/dist/commands/check-updates.js +63 -0
  220. package/dist/commands/doctor.d.ts +39 -1
  221. package/dist/commands/doctor.js +348 -79
  222. package/dist/commands/init.d.ts +2 -0
  223. package/dist/commands/init.js +41 -15
  224. package/dist/commands/status.d.ts +7 -1
  225. package/dist/commands/status.js +111 -42
  226. package/dist/commands/upgrade.d.ts +7 -1
  227. package/dist/commands/upgrade.js +43 -12
  228. package/dist/installer.d.ts +19 -2
  229. package/dist/installer.js +305 -66
  230. package/dist/transition/artifacts.d.ts +2 -0
  231. package/dist/transition/artifacts.js +46 -0
  232. package/dist/transition/context.d.ts +19 -0
  233. package/dist/transition/context.js +261 -0
  234. package/dist/transition/fix-plan.d.ts +15 -0
  235. package/dist/transition/fix-plan.js +94 -0
  236. package/dist/transition/index.d.ts +9 -0
  237. package/dist/transition/index.js +16 -0
  238. package/dist/transition/orchestration.d.ts +2 -0
  239. package/dist/transition/orchestration.js +243 -0
  240. package/dist/transition/specs-changelog.d.ts +3 -0
  241. package/dist/transition/specs-changelog.js +75 -0
  242. package/dist/transition/specs-index.d.ts +22 -0
  243. package/dist/transition/specs-index.js +157 -0
  244. package/dist/transition/story-parsing.d.ts +7 -0
  245. package/dist/transition/story-parsing.js +124 -0
  246. package/dist/transition/tech-stack.d.ts +3 -0
  247. package/dist/transition/tech-stack.js +79 -0
  248. package/dist/transition/types.d.ts +60 -0
  249. package/dist/transition/types.js +1 -0
  250. package/dist/utils/config.d.ts +4 -0
  251. package/dist/utils/config.js +14 -4
  252. package/dist/utils/constants.d.ts +70 -0
  253. package/dist/utils/constants.js +97 -0
  254. package/dist/utils/dryrun.d.ts +7 -0
  255. package/dist/utils/dryrun.js +48 -0
  256. package/dist/utils/errors.d.ts +63 -0
  257. package/dist/utils/errors.js +86 -0
  258. package/dist/utils/file-system.d.ts +24 -0
  259. package/dist/utils/file-system.js +99 -0
  260. package/dist/utils/github.d.ts +83 -0
  261. package/dist/utils/github.js +230 -0
  262. package/dist/utils/json.js +3 -3
  263. package/dist/utils/logger.d.ts +6 -0
  264. package/dist/utils/logger.js +27 -0
  265. package/dist/utils/state.d.ts +4 -7
  266. package/dist/utils/state.js +147 -26
  267. package/dist/utils/validate.d.ts +40 -0
  268. package/dist/utils/validate.js +175 -1
  269. package/package.json +75 -59
  270. package/ralph/RALPH-REFERENCE.md +412 -0
  271. package/ralph/lib/circuit_breaker.sh +463 -330
  272. package/ralph/lib/date_utils.sh +104 -53
  273. package/ralph/lib/enable_core.sh +815 -0
  274. package/ralph/lib/response_analyzer.sh +884 -768
  275. package/ralph/lib/task_sources.sh +577 -0
  276. package/ralph/lib/timeout_utils.sh +145 -145
  277. package/ralph/lib/wizard_utils.sh +547 -0
  278. package/ralph/ralph_import.sh +636 -0
  279. package/ralph/ralph_loop.sh +1793 -1391
  280. package/ralph/ralph_monitor.sh +125 -0
  281. package/ralph/templates/AGENT.md +158 -158
  282. package/ralph/templates/PROMPT.md +285 -292
  283. package/ralph/templates/fix_plan.md +27 -27
  284. package/ralph/templates/ralphrc.template +102 -0
  285. package/ralph/templates/specs/.gitkeep +1 -1
  286. package/slash-commands/advanced-elicitation.md +1 -1
  287. package/slash-commands/adversarial-review.md +1 -1
  288. package/slash-commands/analyst.md +1 -1
  289. package/slash-commands/architect.md +1 -1
  290. package/slash-commands/bmad-help.md +1 -1
  291. package/slash-commands/bmalph-implement.md +152 -152
  292. package/slash-commands/brainstorm-project.md +1 -1
  293. package/slash-commands/brainstorming.md +1 -1
  294. package/slash-commands/correct-course.md +1 -1
  295. package/slash-commands/create-architecture.md +1 -1
  296. package/slash-commands/create-brief.md +1 -1
  297. package/slash-commands/create-epics-stories.md +1 -1
  298. package/slash-commands/create-prd.md +1 -1
  299. package/slash-commands/create-story.md +1 -1
  300. package/slash-commands/create-ux.md +1 -1
  301. package/slash-commands/dev.md +1 -1
  302. package/slash-commands/document-project.md +1 -1
  303. package/slash-commands/domain-research.md +1 -1
  304. package/slash-commands/editorial-prose.md +1 -1
  305. package/slash-commands/editorial-structure.md +1 -1
  306. package/slash-commands/execute-workflow.md +1 -1
  307. package/slash-commands/generate-project-context.md +1 -0
  308. package/slash-commands/implementation-readiness.md +1 -1
  309. package/slash-commands/index-docs.md +1 -1
  310. package/slash-commands/market-research.md +1 -1
  311. package/slash-commands/party-mode.md +1 -1
  312. package/slash-commands/pm.md +1 -1
  313. package/slash-commands/qa-automate.md +1 -0
  314. package/slash-commands/qa.md +1 -0
  315. package/slash-commands/quick-dev.md +1 -1
  316. package/slash-commands/quick-flow-solo-dev.md +1 -1
  317. package/slash-commands/retrospective.md +1 -1
  318. package/slash-commands/shard-doc.md +1 -1
  319. package/slash-commands/sm.md +1 -1
  320. package/slash-commands/sprint-planning.md +1 -1
  321. package/slash-commands/sprint-status.md +1 -1
  322. package/slash-commands/tech-spec.md +1 -1
  323. package/slash-commands/tech-writer.md +1 -0
  324. package/slash-commands/technical-research.md +1 -1
  325. package/slash-commands/ux-designer.md +1 -1
  326. package/slash-commands/validate-architecture.md +1 -1
  327. package/slash-commands/validate-brief.md +1 -1
  328. package/slash-commands/validate-epics-stories.md +1 -1
  329. package/slash-commands/validate-prd.md +1 -1
  330. package/slash-commands/validate-story.md +1 -1
  331. package/slash-commands/validate-ux.md +1 -1
  332. package/bmad/bmm/agents/tea.agent.yaml +0 -63
  333. package/bmad/bmm/sub-modules/claude-code/config.yaml +0 -4
  334. package/bmad/bmm/sub-modules/claude-code/injections.yaml +0 -242
  335. package/bmad/bmm/sub-modules/claude-code/readme.md +0 -87
  336. package/bmad/bmm/testarch/knowledge/adr-quality-readiness-checklist.md +0 -350
  337. package/bmad/bmm/testarch/knowledge/api-request.md +0 -442
  338. package/bmad/bmm/testarch/knowledge/api-testing-patterns.md +0 -843
  339. package/bmad/bmm/testarch/knowledge/auth-session.md +0 -552
  340. package/bmad/bmm/testarch/knowledge/burn-in.md +0 -273
  341. package/bmad/bmm/testarch/knowledge/ci-burn-in.md +0 -675
  342. package/bmad/bmm/testarch/knowledge/component-tdd.md +0 -486
  343. package/bmad/bmm/testarch/knowledge/contract-testing.md +0 -957
  344. package/bmad/bmm/testarch/knowledge/data-factories.md +0 -500
  345. package/bmad/bmm/testarch/knowledge/email-auth.md +0 -721
  346. package/bmad/bmm/testarch/knowledge/error-handling.md +0 -725
  347. package/bmad/bmm/testarch/knowledge/feature-flags.md +0 -750
  348. package/bmad/bmm/testarch/knowledge/file-utils.md +0 -463
  349. package/bmad/bmm/testarch/knowledge/fixture-architecture.md +0 -401
  350. package/bmad/bmm/testarch/knowledge/fixtures-composition.md +0 -382
  351. package/bmad/bmm/testarch/knowledge/intercept-network-call.md +0 -430
  352. package/bmad/bmm/testarch/knowledge/log.md +0 -429
  353. package/bmad/bmm/testarch/knowledge/network-error-monitor.md +0 -405
  354. package/bmad/bmm/testarch/knowledge/network-first.md +0 -486
  355. package/bmad/bmm/testarch/knowledge/network-recorder.md +0 -527
  356. package/bmad/bmm/testarch/knowledge/nfr-criteria.md +0 -670
  357. package/bmad/bmm/testarch/knowledge/overview.md +0 -286
  358. package/bmad/bmm/testarch/knowledge/playwright-config.md +0 -730
  359. package/bmad/bmm/testarch/knowledge/probability-impact.md +0 -601
  360. package/bmad/bmm/testarch/knowledge/recurse.md +0 -421
  361. package/bmad/bmm/testarch/knowledge/risk-governance.md +0 -615
  362. package/bmad/bmm/testarch/knowledge/selective-testing.md +0 -732
  363. package/bmad/bmm/testarch/knowledge/selector-resilience.md +0 -527
  364. package/bmad/bmm/testarch/knowledge/test-healing-patterns.md +0 -644
  365. package/bmad/bmm/testarch/knowledge/test-levels-framework.md +0 -473
  366. package/bmad/bmm/testarch/knowledge/test-priorities-matrix.md +0 -373
  367. package/bmad/bmm/testarch/knowledge/test-quality.md +0 -664
  368. package/bmad/bmm/testarch/knowledge/timing-debugging.md +0 -372
  369. package/bmad/bmm/testarch/knowledge/visual-debugging.md +0 -524
  370. package/bmad/bmm/testarch/tea-index.csv +0 -35
  371. package/bmad/bmm/workflows/1-analysis/research/market-steps/step-02-customer-insights.md +0 -200
  372. package/bmad/bmm/workflows/1-analysis/research/workflow.md +0 -173
  373. package/bmad/bmm/workflows/2-plan-workflows/prd/validation-report-prd-workflow.md +0 -433
  374. package/bmad/bmm/workflows/2-plan-workflows/prd/workflow.md +0 -150
  375. package/bmad/bmm/workflows/bmad-quick-flow/quick-dev/data/project-levels.yaml +0 -59
  376. package/bmad/bmm/workflows/excalidraw-diagrams/_shared/excalidraw-library.json +0 -90
  377. package/bmad/bmm/workflows/excalidraw-diagrams/_shared/excalidraw-templates.yaml +0 -127
  378. package/bmad/bmm/workflows/excalidraw-diagrams/create-dataflow/checklist.md +0 -39
  379. package/bmad/bmm/workflows/excalidraw-diagrams/create-dataflow/instructions.md +0 -130
  380. package/bmad/bmm/workflows/excalidraw-diagrams/create-dataflow/workflow.yaml +0 -27
  381. package/bmad/bmm/workflows/excalidraw-diagrams/create-diagram/checklist.md +0 -43
  382. package/bmad/bmm/workflows/excalidraw-diagrams/create-diagram/instructions.md +0 -141
  383. package/bmad/bmm/workflows/excalidraw-diagrams/create-diagram/workflow.yaml +0 -27
  384. package/bmad/bmm/workflows/excalidraw-diagrams/create-flowchart/checklist.md +0 -49
  385. package/bmad/bmm/workflows/excalidraw-diagrams/create-flowchart/instructions.md +0 -241
  386. package/bmad/bmm/workflows/excalidraw-diagrams/create-flowchart/workflow.yaml +0 -27
  387. package/bmad/bmm/workflows/excalidraw-diagrams/create-wireframe/checklist.md +0 -38
  388. package/bmad/bmm/workflows/excalidraw-diagrams/create-wireframe/instructions.md +0 -133
  389. package/bmad/bmm/workflows/excalidraw-diagrams/create-wireframe/workflow.yaml +0 -27
  390. package/bmad/bmm/workflows/testarch/atdd/atdd-checklist-template.md +0 -363
  391. package/bmad/bmm/workflows/testarch/atdd/checklist.md +0 -374
  392. package/bmad/bmm/workflows/testarch/atdd/instructions.md +0 -806
  393. package/bmad/bmm/workflows/testarch/atdd/workflow.yaml +0 -47
  394. package/bmad/bmm/workflows/testarch/automate/checklist.md +0 -582
  395. package/bmad/bmm/workflows/testarch/automate/instructions.md +0 -1324
  396. package/bmad/bmm/workflows/testarch/automate/workflow.yaml +0 -54
  397. package/bmad/bmm/workflows/testarch/ci/checklist.md +0 -247
  398. package/bmad/bmm/workflows/testarch/ci/github-actions-template.yaml +0 -198
  399. package/bmad/bmm/workflows/testarch/ci/gitlab-ci-template.yaml +0 -149
  400. package/bmad/bmm/workflows/testarch/ci/instructions.md +0 -536
  401. package/bmad/bmm/workflows/testarch/ci/workflow.yaml +0 -47
  402. package/bmad/bmm/workflows/testarch/framework/checklist.md +0 -320
  403. package/bmad/bmm/workflows/testarch/framework/instructions.md +0 -481
  404. package/bmad/bmm/workflows/testarch/framework/workflow.yaml +0 -49
  405. package/bmad/bmm/workflows/testarch/nfr-assess/checklist.md +0 -407
  406. package/bmad/bmm/workflows/testarch/nfr-assess/instructions.md +0 -726
  407. package/bmad/bmm/workflows/testarch/nfr-assess/nfr-report-template.md +0 -461
  408. package/bmad/bmm/workflows/testarch/nfr-assess/workflow.yaml +0 -49
  409. package/bmad/bmm/workflows/testarch/test-design/checklist.md +0 -407
  410. package/bmad/bmm/workflows/testarch/test-design/instructions.md +0 -1158
  411. package/bmad/bmm/workflows/testarch/test-design/test-design-architecture-template.md +0 -213
  412. package/bmad/bmm/workflows/testarch/test-design/test-design-qa-template.md +0 -286
  413. package/bmad/bmm/workflows/testarch/test-design/test-design-template.md +0 -294
  414. package/bmad/bmm/workflows/testarch/test-design/workflow.yaml +0 -71
  415. package/bmad/bmm/workflows/testarch/test-review/checklist.md +0 -472
  416. package/bmad/bmm/workflows/testarch/test-review/instructions.md +0 -628
  417. package/bmad/bmm/workflows/testarch/test-review/test-review-template.md +0 -390
  418. package/bmad/bmm/workflows/testarch/test-review/workflow.yaml +0 -48
  419. package/bmad/bmm/workflows/testarch/trace/checklist.md +0 -642
  420. package/bmad/bmm/workflows/testarch/trace/instructions.md +0 -1030
  421. package/bmad/bmm/workflows/testarch/trace/trace-template.md +0 -675
  422. package/bmad/bmm/workflows/testarch/trace/workflow.yaml +0 -57
  423. package/bmad/core/resources/excalidraw/README.md +0 -160
  424. package/bmad/core/resources/excalidraw/excalidraw-helpers.md +0 -127
  425. package/bmad/core/resources/excalidraw/library-loader.md +0 -50
  426. package/bmad/core/resources/excalidraw/validate-json-instructions.md +0 -79
  427. package/bmad/core/tasks/bmad-help.md +0 -62
  428. package/dist/commands/guide.d.ts +0 -1
  429. package/dist/commands/guide.js +0 -19
  430. package/dist/commands/implement.d.ts +0 -1
  431. package/dist/commands/implement.js +0 -83
  432. package/dist/commands/plan.d.ts +0 -5
  433. package/dist/commands/plan.js +0 -44
  434. package/dist/commands/reset.d.ts +0 -5
  435. package/dist/commands/reset.js +0 -35
  436. package/dist/commands/resume.d.ts +0 -1
  437. package/dist/commands/resume.js +0 -44
  438. package/dist/commands/start.d.ts +0 -5
  439. package/dist/commands/start.js +0 -54
  440. package/dist/transition.d.ts +0 -52
  441. package/dist/transition.js +0 -656
  442. package/slash-commands/atdd.md +0 -1
  443. package/slash-commands/continuous-integration.md +0 -1
  444. package/slash-commands/create-dataflow.md +0 -1
  445. package/slash-commands/create-diagram.md +0 -1
  446. package/slash-commands/create-flowchart.md +0 -1
  447. package/slash-commands/create-wireframe.md +0 -1
  448. package/slash-commands/nfr-assess.md +0 -1
  449. package/slash-commands/tea.md +0 -1
  450. package/slash-commands/test-automate.md +0 -1
  451. package/slash-commands/test-design.md +0 -1
  452. package/slash-commands/test-framework.md +0 -1
  453. package/slash-commands/test-review.md +0 -1
  454. package/slash-commands/test-trace.md +0 -1
  455. package/slash-commands/validate-test-design.md +0 -1
@@ -0,0 +1,636 @@
1
+ #!/bin/bash
2
+
3
+ # Ralph Import - Convert PRDs to Ralph format using Claude Code
4
+ # Version: 0.9.8 - Modern CLI support with JSON output parsing
5
+ set -e
6
+
7
+ # Configuration
8
+ CLAUDE_CODE_CMD="claude"
9
+
10
+ # Modern CLI Configuration (Phase 1.1)
11
+ # These flags enable structured JSON output and controlled file operations
12
+ CLAUDE_OUTPUT_FORMAT="json"
13
+ # Use bash array for proper quoting of each tool argument
14
+ declare -a CLAUDE_ALLOWED_TOOLS=('Read' 'Write' 'Bash(mkdir:*)' 'Bash(cp:*)')
15
+ CLAUDE_MIN_VERSION="2.0.76" # Minimum version for modern CLI features
16
+
17
+ # Temporary file names
18
+ CONVERSION_OUTPUT_FILE=".ralph_conversion_output.json"
19
+ CONVERSION_PROMPT_FILE=".ralph_conversion_prompt.md"
20
+
21
+ # Global parsed conversion result variables
22
+ # Set by parse_conversion_response() when parsing JSON output from Claude CLI
23
+ declare PARSED_RESULT="" # Result/summary text from Claude response
24
+ declare PARSED_SESSION_ID="" # Session ID for potential continuation
25
+ declare PARSED_FILES_CHANGED="" # Count of files changed
26
+ declare PARSED_HAS_ERRORS="" # Boolean flag indicating errors occurred
27
+ declare PARSED_COMPLETION_STATUS="" # Completion status (complete/partial/failed)
28
+ declare PARSED_ERROR_MESSAGE="" # Error message if conversion failed
29
+ declare PARSED_ERROR_CODE="" # Error code if conversion failed
30
+ declare PARSED_FILES_CREATED="" # JSON array of files created
31
+ declare PARSED_MISSING_FILES="" # JSON array of files that should exist but don't
32
+
33
+ # Colors
34
+ RED='\033[0;31m'
35
+ GREEN='\033[0;32m'
36
+ YELLOW='\033[1;33m'
37
+ BLUE='\033[0;34m'
38
+ NC='\033[0m'
39
+
40
+ log() {
41
+ local level=$1
42
+ local message=$2
43
+ local color=""
44
+
45
+ case $level in
46
+ "INFO") color=$BLUE ;;
47
+ "WARN") color=$YELLOW ;;
48
+ "ERROR") color=$RED ;;
49
+ "SUCCESS") color=$GREEN ;;
50
+ esac
51
+
52
+ echo -e "${color}[$(date '+%H:%M:%S')] [$level] $message${NC}"
53
+ }
54
+
55
+ # =============================================================================
56
+ # JSON OUTPUT FORMAT DETECTION AND PARSING
57
+ # =============================================================================
58
+
59
+ # detect_response_format - Detect whether file contains JSON or plain text output
60
+ #
61
+ # Parameters:
62
+ # $1 (output_file) - Path to the file to inspect
63
+ #
64
+ # Returns:
65
+ # Echoes "json" if file is non-empty, starts with { or [, and validates as JSON
66
+ # Echoes "text" otherwise (empty file, non-JSON content, or invalid JSON)
67
+ #
68
+ # Dependencies:
69
+ # - jq (used for JSON validation; if unavailable, falls back to "text")
70
+ #
71
+ detect_response_format() {
72
+ local output_file=$1
73
+
74
+ if [[ ! -f "$output_file" ]] || [[ ! -s "$output_file" ]]; then
75
+ echo "text"
76
+ return
77
+ fi
78
+
79
+ # Check if file starts with { or [ (JSON indicators)
80
+ # Use grep to find first non-whitespace character (handles leading whitespace)
81
+ local first_char=$(grep -m1 -o '[^[:space:]]' "$output_file" 2>/dev/null)
82
+
83
+ if [[ "$first_char" != "{" && "$first_char" != "[" ]]; then
84
+ echo "text"
85
+ return
86
+ fi
87
+
88
+ # Validate as JSON using jq
89
+ if command -v jq &>/dev/null && jq empty "$output_file" 2>/dev/null; then
90
+ echo "json"
91
+ else
92
+ echo "text"
93
+ fi
94
+ }
95
+
96
+ # parse_conversion_response - Parse JSON response and extract conversion status
97
+ #
98
+ # Parameters:
99
+ # $1 (output_file) - Path to JSON file containing Claude CLI response
100
+ #
101
+ # Returns:
102
+ # 0 on success (valid JSON parsed)
103
+ # 1 on error (file not found, jq unavailable, or invalid JSON)
104
+ #
105
+ # Sets Global Variables:
106
+ # PARSED_RESULT - Result/summary text from response
107
+ # PARSED_SESSION_ID - Session ID for continuation
108
+ # PARSED_FILES_CHANGED - Count of files changed
109
+ # PARSED_HAS_ERRORS - "true"/"false" indicating errors
110
+ # PARSED_COMPLETION_STATUS - Status: "complete", "partial", "failed", "unknown"
111
+ # PARSED_ERROR_MESSAGE - Error message if conversion failed
112
+ # PARSED_ERROR_CODE - Error code if conversion failed
113
+ # PARSED_FILES_CREATED - JSON array string of created files
114
+ # PARSED_MISSING_FILES - JSON array string of missing files
115
+ #
116
+ # Dependencies:
117
+ # - jq (required for JSON parsing)
118
+ #
119
+ parse_conversion_response() {
120
+ local output_file=$1
121
+
122
+ if [[ ! -f "$output_file" ]]; then
123
+ return 1
124
+ fi
125
+
126
+ # Check if jq is available
127
+ if ! command -v jq &>/dev/null; then
128
+ log "WARN" "jq not found, skipping JSON parsing"
129
+ return 1
130
+ fi
131
+
132
+ # Validate JSON first
133
+ if ! jq empty "$output_file" 2>/dev/null; then
134
+ log "WARN" "Invalid JSON in output, falling back to text parsing"
135
+ return 1
136
+ fi
137
+
138
+ # Extract fields from JSON response
139
+ # Supports both flat format and Claude CLI format with metadata
140
+
141
+ # Result/summary field
142
+ PARSED_RESULT=$(jq -r '.result // .summary // ""' "$output_file" 2>/dev/null)
143
+
144
+ # Session ID (for potential continuation)
145
+ PARSED_SESSION_ID=$(jq -r '.sessionId // .session_id // ""' "$output_file" 2>/dev/null)
146
+
147
+ # Files changed count
148
+ PARSED_FILES_CHANGED=$(jq -r '.metadata.files_changed // .files_changed // 0' "$output_file" 2>/dev/null)
149
+
150
+ # Has errors flag
151
+ PARSED_HAS_ERRORS=$(jq -r '.metadata.has_errors // .has_errors // false' "$output_file" 2>/dev/null)
152
+
153
+ # Completion status
154
+ PARSED_COMPLETION_STATUS=$(jq -r '.metadata.completion_status // .completion_status // "unknown"' "$output_file" 2>/dev/null)
155
+
156
+ # Error message (if any)
157
+ PARSED_ERROR_MESSAGE=$(jq -r '.metadata.error_message // .error_message // ""' "$output_file" 2>/dev/null)
158
+
159
+ # Error code (if any)
160
+ PARSED_ERROR_CODE=$(jq -r '.metadata.error_code // .error_code // ""' "$output_file" 2>/dev/null)
161
+
162
+ # Files created (as array)
163
+ PARSED_FILES_CREATED=$(jq -r '.metadata.files_created // [] | @json' "$output_file" 2>/dev/null)
164
+
165
+ # Missing files (as array)
166
+ PARSED_MISSING_FILES=$(jq -r '.metadata.missing_files // [] | @json' "$output_file" 2>/dev/null)
167
+
168
+ return 0
169
+ }
170
+
171
+ # check_claude_version - Verify Claude Code CLI version meets minimum requirements
172
+ #
173
+ # Checks if the installed Claude Code CLI version is at or above CLAUDE_MIN_VERSION.
174
+ # Uses numeric semantic version comparison (major.minor.patch).
175
+ #
176
+ # Parameters:
177
+ # None (uses global CLAUDE_CODE_CMD and CLAUDE_MIN_VERSION)
178
+ #
179
+ # Returns:
180
+ # 0 if version is >= CLAUDE_MIN_VERSION
181
+ # 1 if version cannot be determined or is below CLAUDE_MIN_VERSION
182
+ #
183
+ # Side Effects:
184
+ # Logs warning via log() if version check fails
185
+ #
186
+ check_claude_version() {
187
+ local version
188
+ version=$($CLAUDE_CODE_CMD --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
189
+
190
+ if [[ -z "$version" ]]; then
191
+ log "WARN" "Could not determine Claude Code CLI version"
192
+ return 1
193
+ fi
194
+
195
+ # Numeric semantic version comparison
196
+ # Split versions into major.minor.patch components
197
+ local ver_major ver_minor ver_patch
198
+ local min_major min_minor min_patch
199
+
200
+ IFS='.' read -r ver_major ver_minor ver_patch <<< "$version"
201
+ IFS='.' read -r min_major min_minor min_patch <<< "$CLAUDE_MIN_VERSION"
202
+
203
+ # Default empty components to 0 (handles versions like "2.1" without patch)
204
+ ver_major=${ver_major:-0}
205
+ ver_minor=${ver_minor:-0}
206
+ ver_patch=${ver_patch:-0}
207
+ min_major=${min_major:-0}
208
+ min_minor=${min_minor:-0}
209
+ min_patch=${min_patch:-0}
210
+
211
+ # Compare major version
212
+ if [[ $ver_major -lt $min_major ]]; then
213
+ log "WARN" "Claude Code CLI version $version is below recommended $CLAUDE_MIN_VERSION"
214
+ return 1
215
+ elif [[ $ver_major -gt $min_major ]]; then
216
+ return 0
217
+ fi
218
+
219
+ # Major equal, compare minor version
220
+ if [[ $ver_minor -lt $min_minor ]]; then
221
+ log "WARN" "Claude Code CLI version $version is below recommended $CLAUDE_MIN_VERSION"
222
+ return 1
223
+ elif [[ $ver_minor -gt $min_minor ]]; then
224
+ return 0
225
+ fi
226
+
227
+ # Minor equal, compare patch version
228
+ if [[ $ver_patch -lt $min_patch ]]; then
229
+ log "WARN" "Claude Code CLI version $version is below recommended $CLAUDE_MIN_VERSION"
230
+ return 1
231
+ fi
232
+
233
+ return 0
234
+ }
235
+
236
+ show_help() {
237
+ cat << HELPEOF
238
+ Ralph Import - Convert PRDs to Ralph Format
239
+
240
+ Usage: $0 <source-file> [project-name]
241
+
242
+ Arguments:
243
+ source-file Path to your PRD/specification file (any format)
244
+ project-name Name for the new Ralph project (optional, defaults to filename)
245
+
246
+ Examples:
247
+ $0 my-app-prd.md
248
+ $0 requirements.txt my-awesome-app
249
+ $0 project-spec.json
250
+ $0 design-doc.docx webapp
251
+
252
+ Supported formats:
253
+ - Markdown (.md)
254
+ - Text files (.txt)
255
+ - JSON (.json)
256
+ - Word documents (.docx)
257
+ - PDFs (.pdf)
258
+ - Any text-based format
259
+
260
+ The command will:
261
+ 1. Create a new Ralph project
262
+ 2. Use Claude Code to intelligently convert your PRD into:
263
+ - .ralph/PROMPT.md (Ralph instructions)
264
+ - .ralph/fix_plan.md (prioritized tasks)
265
+ - .ralph/specs/ (technical specifications)
266
+
267
+ HELPEOF
268
+ }
269
+
270
+ # Check dependencies
271
+ check_dependencies() {
272
+ if ! command -v ralph-setup &> /dev/null; then
273
+ log "ERROR" "Ralph not installed. Run ./install.sh first"
274
+ exit 1
275
+ fi
276
+
277
+ if ! command -v jq &> /dev/null; then
278
+ log "WARN" "jq not found. Install it (brew install jq | sudo apt-get install jq | choco install jq) for faster JSON parsing."
279
+ fi
280
+
281
+ if ! command -v "$CLAUDE_CODE_CMD" &> /dev/null 2>&1; then
282
+ log "WARN" "Claude Code CLI ($CLAUDE_CODE_CMD) not found. It will be downloaded when first used."
283
+ fi
284
+ }
285
+
286
+ # Convert PRD using Claude Code
287
+ convert_prd() {
288
+ local source_file=$1
289
+ local project_name=$2
290
+ local use_modern_cli=true
291
+ local cli_exit_code=0
292
+
293
+ log "INFO" "Converting PRD to Ralph format using Claude Code..."
294
+
295
+ # Check for modern CLI support
296
+ if ! check_claude_version 2>/dev/null; then
297
+ log "INFO" "Using standard CLI mode (modern features may not be available)"
298
+ use_modern_cli=false
299
+ else
300
+ log "INFO" "Using modern CLI with JSON output format"
301
+ fi
302
+
303
+ # Create conversion prompt
304
+ cat > "$CONVERSION_PROMPT_FILE" << 'PROMPTEOF'
305
+ # PRD to Ralph Conversion Task
306
+
307
+ You are tasked with converting a Product Requirements Document (PRD) or specification into Ralph for Claude Code format.
308
+
309
+ ## Input Analysis
310
+ Analyze the provided specification file and extract:
311
+ - Project goals and objectives
312
+ - Core features and requirements
313
+ - Technical constraints and preferences
314
+ - Priority levels and phases
315
+ - Success criteria
316
+
317
+ ## Required Outputs
318
+
319
+ Create these files in the .ralph/ subdirectory:
320
+
321
+ ### 1. .ralph/PROMPT.md
322
+ Transform the PRD into Ralph development instructions:
323
+ ```markdown
324
+ # Ralph Development Instructions
325
+
326
+ ## Context
327
+ You are Ralph, an autonomous AI development agent working on a [PROJECT NAME] project.
328
+
329
+ ## Current Objectives
330
+ [Extract and prioritize 4-6 main objectives from the PRD]
331
+
332
+ ## Key Principles
333
+ - ONE task per loop - focus on the most important thing
334
+ - Search the codebase before assuming something isn't implemented
335
+ - Use subagents for expensive operations (file searching, analysis)
336
+ - Write comprehensive tests with clear documentation
337
+ - Update fix_plan.md with your learnings
338
+ - Commit working changes with descriptive messages
339
+
340
+ ## 🧪 Testing Guidelines (CRITICAL)
341
+ - LIMIT testing to ~20% of your total effort per loop
342
+ - PRIORITIZE: Implementation > Documentation > Tests
343
+ - Only write tests for NEW functionality you implement
344
+ - Do NOT refactor existing tests unless broken
345
+ - Focus on CORE functionality first, comprehensive testing later
346
+
347
+ ## Project Requirements
348
+ [Convert PRD requirements into clear, actionable development requirements]
349
+
350
+ ## Technical Constraints
351
+ [Extract any technical preferences, frameworks, languages mentioned]
352
+
353
+ ## Success Criteria
354
+ [Define what "done" looks like based on the PRD]
355
+
356
+ ## Current Task
357
+ Follow fix_plan.md and choose the most important item to implement next.
358
+ ```
359
+
360
+ ### 2. .ralph/fix_plan.md
361
+ Convert requirements into a prioritized task list:
362
+ ```markdown
363
+ # Ralph Fix Plan
364
+
365
+ ## High Priority
366
+ [Extract and convert critical features into actionable tasks]
367
+
368
+ ## Medium Priority
369
+ [Secondary features and enhancements]
370
+
371
+ ## Low Priority
372
+ [Nice-to-have features and optimizations]
373
+
374
+ ## Completed
375
+ - [x] Project initialization
376
+
377
+ ## Notes
378
+ [Any important context from the original PRD]
379
+ ```
380
+
381
+ ### 3. .ralph/specs/requirements.md
382
+ Create detailed technical specifications:
383
+ ```markdown
384
+ # Technical Specifications
385
+
386
+ [Convert PRD into detailed technical requirements including:]
387
+ - System architecture requirements
388
+ - Data models and structures
389
+ - API specifications
390
+ - User interface requirements
391
+ - Performance requirements
392
+ - Security considerations
393
+ - Integration requirements
394
+
395
+ [Preserve all technical details from the original PRD]
396
+ ```
397
+
398
+ ## Instructions
399
+ 1. Read and analyze the attached specification file
400
+ 2. Create the three files above with content derived from the PRD
401
+ 3. Ensure all requirements are captured and properly prioritized
402
+ 4. Make the PROMPT.md actionable for autonomous development
403
+ 5. Structure fix_plan.md with clear, implementable tasks
404
+
405
+ PROMPTEOF
406
+
407
+ # Append the PRD source content to the conversion prompt
408
+ local source_basename
409
+ source_basename=$(basename "$source_file")
410
+
411
+ if [[ -f "$source_file" ]]; then
412
+ echo "" >> "$CONVERSION_PROMPT_FILE"
413
+ echo "---" >> "$CONVERSION_PROMPT_FILE"
414
+ echo "" >> "$CONVERSION_PROMPT_FILE"
415
+ echo "## Source PRD File: $source_basename" >> "$CONVERSION_PROMPT_FILE"
416
+ echo "" >> "$CONVERSION_PROMPT_FILE"
417
+ cat "$source_file" >> "$CONVERSION_PROMPT_FILE"
418
+ else
419
+ log "ERROR" "Source file not found: $source_file"
420
+ rm -f "$CONVERSION_PROMPT_FILE"
421
+ exit 1
422
+ fi
423
+
424
+ # Build and execute Claude Code command
425
+ # Modern CLI: Use --output-format json and --allowedTools for structured output
426
+ # Fallback: Standard CLI invocation for older versions
427
+ # Note: stderr is written to separate file to avoid corrupting JSON output
428
+ local stderr_file="${CONVERSION_OUTPUT_FILE}.err"
429
+
430
+ if [[ "$use_modern_cli" == "true" ]]; then
431
+ # Modern CLI invocation with JSON output and controlled tool permissions
432
+ # --print: Required for piped input (prevents interactive session hang)
433
+ # --allowedTools: Permits file operations without user prompts
434
+ # --strict-mcp-config: Skip loading user MCP servers (faster startup)
435
+ if $CLAUDE_CODE_CMD --print --strict-mcp-config --output-format "$CLAUDE_OUTPUT_FORMAT" --allowedTools "${CLAUDE_ALLOWED_TOOLS[@]}" < "$CONVERSION_PROMPT_FILE" > "$CONVERSION_OUTPUT_FILE" 2> "$stderr_file"; then
436
+ cli_exit_code=0
437
+ else
438
+ cli_exit_code=$?
439
+ fi
440
+ else
441
+ # Standard CLI invocation (backward compatible)
442
+ # --print: Required for piped input (prevents interactive session hang)
443
+ if $CLAUDE_CODE_CMD --print < "$CONVERSION_PROMPT_FILE" > "$CONVERSION_OUTPUT_FILE" 2> "$stderr_file"; then
444
+ cli_exit_code=0
445
+ else
446
+ cli_exit_code=$?
447
+ fi
448
+ fi
449
+
450
+ # Log stderr if there was any (for debugging)
451
+ if [[ -s "$stderr_file" ]]; then
452
+ log "WARN" "CLI stderr output detected (see $stderr_file)"
453
+ fi
454
+
455
+ # Process the response
456
+ local output_format="text"
457
+ local json_parsed=false
458
+
459
+ if [[ -f "$CONVERSION_OUTPUT_FILE" ]]; then
460
+ output_format=$(detect_response_format "$CONVERSION_OUTPUT_FILE")
461
+
462
+ if [[ "$output_format" == "json" ]]; then
463
+ if parse_conversion_response "$CONVERSION_OUTPUT_FILE"; then
464
+ json_parsed=true
465
+ log "INFO" "Parsed JSON response from Claude CLI"
466
+
467
+ # Check for errors in JSON response
468
+ if [[ "$PARSED_HAS_ERRORS" == "true" && "$PARSED_COMPLETION_STATUS" == "failed" ]]; then
469
+ log "ERROR" "PRD conversion failed"
470
+ if [[ -n "$PARSED_ERROR_MESSAGE" ]]; then
471
+ log "ERROR" "Error: $PARSED_ERROR_MESSAGE"
472
+ fi
473
+ if [[ -n "$PARSED_ERROR_CODE" ]]; then
474
+ log "ERROR" "Error code: $PARSED_ERROR_CODE"
475
+ fi
476
+ rm -f "$CONVERSION_PROMPT_FILE" "$CONVERSION_OUTPUT_FILE" "$stderr_file"
477
+ exit 1
478
+ fi
479
+
480
+ # Log session ID if available (for potential continuation)
481
+ if [[ -n "$PARSED_SESSION_ID" && "$PARSED_SESSION_ID" != "null" ]]; then
482
+ log "INFO" "Session ID: $PARSED_SESSION_ID"
483
+ fi
484
+
485
+ # Log files changed from metadata
486
+ if [[ -n "$PARSED_FILES_CHANGED" && "$PARSED_FILES_CHANGED" != "0" ]]; then
487
+ log "INFO" "Files changed: $PARSED_FILES_CHANGED"
488
+ fi
489
+ fi
490
+ fi
491
+ fi
492
+
493
+ # Check CLI exit code
494
+ if [[ $cli_exit_code -ne 0 ]]; then
495
+ log "ERROR" "PRD conversion failed (exit code: $cli_exit_code)"
496
+ rm -f "$CONVERSION_PROMPT_FILE" "$CONVERSION_OUTPUT_FILE" "$stderr_file"
497
+ exit 1
498
+ fi
499
+
500
+ # Use PARSED_RESULT for success message if available
501
+ if [[ "$json_parsed" == "true" && -n "$PARSED_RESULT" && "$PARSED_RESULT" != "null" ]]; then
502
+ log "SUCCESS" "PRD conversion completed: $PARSED_RESULT"
503
+ else
504
+ log "SUCCESS" "PRD conversion completed"
505
+ fi
506
+
507
+ # Clean up temp files
508
+ rm -f "$CONVERSION_PROMPT_FILE" "$CONVERSION_OUTPUT_FILE" "$stderr_file"
509
+
510
+ # Verify files were created
511
+ # Use PARSED_FILES_CREATED from JSON if available, otherwise check filesystem
512
+ local missing_files=()
513
+ local created_files=()
514
+ local expected_files=(".ralph/PROMPT.md" ".ralph/fix_plan.md" ".ralph/specs/requirements.md")
515
+
516
+ # If JSON provided files_created, use that to inform verification
517
+ if [[ "$json_parsed" == "true" && -n "$PARSED_FILES_CREATED" && "$PARSED_FILES_CREATED" != "[]" ]]; then
518
+ # Validate that PARSED_FILES_CREATED is a valid JSON array before iteration
519
+ local is_array
520
+ is_array=$(echo "$PARSED_FILES_CREATED" | jq -e 'type == "array"' 2>/dev/null)
521
+ if [[ "$is_array" == "true" ]]; then
522
+ # Parse JSON array and verify each file exists
523
+ local json_files
524
+ json_files=$(echo "$PARSED_FILES_CREATED" | jq -r '.[]' 2>/dev/null)
525
+ if [[ -n "$json_files" ]]; then
526
+ while IFS= read -r file; do
527
+ if [[ -n "$file" && -f "$file" ]]; then
528
+ created_files+=("$file")
529
+ elif [[ -n "$file" ]]; then
530
+ missing_files+=("$file")
531
+ fi
532
+ done <<< "$json_files"
533
+ fi
534
+ fi
535
+ fi
536
+
537
+ # Always verify expected files exist (filesystem is source of truth)
538
+ for file in "${expected_files[@]}"; do
539
+ if [[ -f "$file" ]]; then
540
+ # Add to created_files if not already there
541
+ if [[ ! " ${created_files[*]} " =~ " ${file} " ]]; then
542
+ created_files+=("$file")
543
+ fi
544
+ else
545
+ # Add to missing_files if not already there
546
+ if [[ ! " ${missing_files[*]} " =~ " ${file} " ]]; then
547
+ missing_files+=("$file")
548
+ fi
549
+ fi
550
+ done
551
+
552
+ # Report created files
553
+ if [[ ${#created_files[@]} -gt 0 ]]; then
554
+ log "INFO" "Created files: ${created_files[*]}"
555
+ fi
556
+
557
+ # Report and handle missing files
558
+ if [[ ${#missing_files[@]} -ne 0 ]]; then
559
+ log "WARN" "Some files were not created: ${missing_files[*]}"
560
+
561
+ # If JSON parsing provided missing files info, use that for better feedback
562
+ if [[ "$json_parsed" == "true" && -n "$PARSED_MISSING_FILES" && "$PARSED_MISSING_FILES" != "[]" ]]; then
563
+ log "INFO" "Missing files reported by Claude: $PARSED_MISSING_FILES"
564
+ fi
565
+
566
+ log "INFO" "You may need to create these files manually or run the conversion again"
567
+ fi
568
+ }
569
+
570
+ # Main function
571
+ main() {
572
+ local source_file="$1"
573
+ local project_name="$2"
574
+
575
+ # Validate arguments
576
+ if [[ -z "$source_file" ]]; then
577
+ log "ERROR" "Source file is required"
578
+ show_help
579
+ exit 1
580
+ fi
581
+
582
+ if [[ ! -f "$source_file" ]]; then
583
+ log "ERROR" "Source file does not exist: $source_file"
584
+ exit 1
585
+ fi
586
+
587
+ # Default project name from filename
588
+ if [[ -z "$project_name" ]]; then
589
+ project_name=$(basename "$source_file" | sed 's/\.[^.]*$//')
590
+ fi
591
+
592
+ log "INFO" "Converting PRD: $source_file"
593
+ log "INFO" "Project name: $project_name"
594
+
595
+ check_dependencies
596
+
597
+ # Create project directory
598
+ log "INFO" "Creating Ralph project: $project_name"
599
+ ralph-setup "$project_name"
600
+ cd "$project_name"
601
+
602
+ # Copy source file to project (uses basename since we cd'd into project)
603
+ local source_basename
604
+ source_basename=$(basename "$source_file")
605
+ if [[ "$source_file" == /* ]]; then
606
+ cp "$source_file" "$source_basename"
607
+ else
608
+ cp "../$source_file" "$source_basename"
609
+ fi
610
+
611
+ # Run conversion using local copy (basename, not original path)
612
+ convert_prd "$source_basename" "$project_name"
613
+
614
+ log "SUCCESS" "🎉 PRD imported successfully!"
615
+ echo ""
616
+ echo "Next steps:"
617
+ echo " 1. Review and edit the generated files:"
618
+ echo " - .ralph/PROMPT.md (Ralph instructions)"
619
+ echo " - .ralph/fix_plan.md (task priorities)"
620
+ echo " - .ralph/specs/requirements.md (technical specs)"
621
+ echo " 2. Start autonomous development:"
622
+ echo " ralph --monitor"
623
+ echo ""
624
+ echo "Project created in: $(pwd)"
625
+ }
626
+
627
+ # Handle command line arguments
628
+ case "${1:-}" in
629
+ -h|--help|"")
630
+ show_help
631
+ exit 0
632
+ ;;
633
+ *)
634
+ main "$@"
635
+ ;;
636
+ esac