drt-method 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/AGENTS.md +45 -0
  2. package/GETTING-STARTED.md +269 -0
  3. package/README.md +233 -0
  4. package/drt-method-1.0.0.tgz +0 -0
  5. package/drt-modules.yaml +1 -0
  6. package/package.json +51 -0
  7. package/scripts/install-from-github.ps1 +22 -0
  8. package/scripts/install-from-github.sh +17 -0
  9. package/src/core-skills/drt-advanced-elicitation/SKILL.md +142 -0
  10. package/src/core-skills/drt-advanced-elicitation/methods.csv +72 -0
  11. package/src/core-skills/drt-brainstorming/SKILL.md +80 -0
  12. package/src/core-skills/drt-brainstorming/assets/brain-icons.json +166 -0
  13. package/src/core-skills/drt-brainstorming/assets/brain-methods.csv +109 -0
  14. package/src/core-skills/drt-brainstorming/assets/brain-selector.html +326 -0
  15. package/src/core-skills/drt-brainstorming/customize.toml +84 -0
  16. package/src/core-skills/drt-brainstorming/references/converge.md +24 -0
  17. package/src/core-skills/drt-brainstorming/references/finalize.md +26 -0
  18. package/src/core-skills/drt-brainstorming/references/headless.md +54 -0
  19. package/src/core-skills/drt-brainstorming/references/in-chat-techniques.md +18 -0
  20. package/src/core-skills/drt-brainstorming/references/mode-autonomous.md +10 -0
  21. package/src/core-skills/drt-brainstorming/references/mode-facilitator.md +11 -0
  22. package/src/core-skills/drt-brainstorming/references/mode-partner.md +16 -0
  23. package/src/core-skills/drt-brainstorming/references/resume.md +5 -0
  24. package/src/core-skills/drt-brainstorming/scripts/brain.py +740 -0
  25. package/src/core-skills/drt-customize/SKILL.md +111 -0
  26. package/src/core-skills/drt-customize/scripts/list_customizable_skills.py +231 -0
  27. package/src/core-skills/drt-editorial-review-prose/SKILL.md +86 -0
  28. package/src/core-skills/drt-editorial-review-structure/SKILL.md +179 -0
  29. package/src/core-skills/drt-forge-idea/SKILL.md +107 -0
  30. package/src/core-skills/drt-forge-idea/customize.toml +42 -0
  31. package/src/core-skills/drt-forge-idea/scripts/resolve_personas.py +270 -0
  32. package/src/core-skills/drt-help/SKILL.md +75 -0
  33. package/src/core-skills/drt-index-docs/SKILL.md +66 -0
  34. package/src/core-skills/drt-party-mode/SKILL.md +60 -0
  35. package/src/core-skills/drt-party-mode/customize.toml +211 -0
  36. package/src/core-skills/drt-party-mode/references/create-party.md +70 -0
  37. package/src/core-skills/drt-party-mode/references/mode-agent-team.md +13 -0
  38. package/src/core-skills/drt-party-mode/references/mode-auto.md +13 -0
  39. package/src/core-skills/drt-party-mode/references/mode-subagent.md +31 -0
  40. package/src/core-skills/drt-party-mode/references/party-memory.md +51 -0
  41. package/src/core-skills/drt-party-mode/scripts/resolve_party.py +272 -0
  42. package/src/core-skills/drt-review-adversarial-general/SKILL.md +37 -0
  43. package/src/core-skills/drt-review-edge-case-hunter/SKILL.md +73 -0
  44. package/src/core-skills/drt-review-edge-case-hunter/references/deletion-check.md +14 -0
  45. package/src/core-skills/drt-review-verification-gap/SKILL.md +106 -0
  46. package/src/core-skills/drt-shard-doc/SKILL.md +105 -0
  47. package/src/core-skills/drt-spec/SKILL.md +160 -0
  48. package/src/core-skills/drt-spec/assets/headless-schemas.md +33 -0
  49. package/src/core-skills/drt-spec/assets/spec-template.md +49 -0
  50. package/src/core-skills/drt-spec/assets/stories-schema.md +44 -0
  51. package/src/core-skills/drt-spec/customize.toml +53 -0
  52. package/src/core-skills/module-help.csv +14 -0
  53. package/src/core-skills/module.yaml +33 -0
  54. package/src/drt-skills/1-analysis/drt-agent-analyst/SKILL.md +76 -0
  55. package/src/drt-skills/1-analysis/drt-agent-analyst/customize.toml +90 -0
  56. package/src/drt-skills/1-analysis/drt-agent-tech-writer/SKILL.md +76 -0
  57. package/src/drt-skills/1-analysis/drt-agent-tech-writer/customize.toml +81 -0
  58. package/src/drt-skills/1-analysis/drt-agent-tech-writer/explain-concept.md +20 -0
  59. package/src/drt-skills/1-analysis/drt-agent-tech-writer/mermaid-gen.md +20 -0
  60. package/src/drt-skills/1-analysis/drt-agent-tech-writer/validate-doc.md +19 -0
  61. package/src/drt-skills/1-analysis/drt-agent-tech-writer/write-document.md +20 -0
  62. package/src/drt-skills/1-analysis/drt-document-project/SKILL.md +62 -0
  63. package/src/drt-skills/1-analysis/drt-document-project/checklist.md +245 -0
  64. package/src/drt-skills/1-analysis/drt-document-project/customize.toml +41 -0
  65. package/src/drt-skills/1-analysis/drt-document-project/documentation-requirements.csv +12 -0
  66. package/src/drt-skills/1-analysis/drt-document-project/instructions.md +128 -0
  67. package/src/drt-skills/1-analysis/drt-document-project/templates/deep-dive-template.md +345 -0
  68. package/src/drt-skills/1-analysis/drt-document-project/templates/index-template.md +169 -0
  69. package/src/drt-skills/1-analysis/drt-document-project/templates/project-overview-template.md +103 -0
  70. package/src/drt-skills/1-analysis/drt-document-project/templates/project-scan-report-schema.json +160 -0
  71. package/src/drt-skills/1-analysis/drt-document-project/templates/source-tree-template.md +135 -0
  72. package/src/drt-skills/1-analysis/drt-document-project/workflows/deep-dive-instructions.md +300 -0
  73. package/src/drt-skills/1-analysis/drt-document-project/workflows/deep-dive-workflow.md +34 -0
  74. package/src/drt-skills/1-analysis/drt-document-project/workflows/full-scan-instructions.md +1111 -0
  75. package/src/drt-skills/1-analysis/drt-document-project/workflows/full-scan-workflow.md +34 -0
  76. package/src/drt-skills/1-analysis/drt-prfaq/SKILL.md +135 -0
  77. package/src/drt-skills/1-analysis/drt-prfaq/agents/artifact-analyzer.md +60 -0
  78. package/src/drt-skills/1-analysis/drt-prfaq/agents/web-researcher.md +49 -0
  79. package/src/drt-skills/1-analysis/drt-prfaq/assets/prfaq-template.md +62 -0
  80. package/src/drt-skills/1-analysis/drt-prfaq/bmad-manifest.json +16 -0
  81. package/src/drt-skills/1-analysis/drt-prfaq/customize.toml +41 -0
  82. package/src/drt-skills/1-analysis/drt-prfaq/references/customer-faq.md +55 -0
  83. package/src/drt-skills/1-analysis/drt-prfaq/references/internal-faq.md +51 -0
  84. package/src/drt-skills/1-analysis/drt-prfaq/references/press-release.md +60 -0
  85. package/src/drt-skills/1-analysis/drt-prfaq/references/verdict.md +83 -0
  86. package/src/drt-skills/1-analysis/drt-product-brief/SKILL.md +91 -0
  87. package/src/drt-skills/1-analysis/drt-product-brief/assets/brief-template.md +41 -0
  88. package/src/drt-skills/1-analysis/drt-product-brief/customize.toml +99 -0
  89. package/src/drt-skills/1-analysis/research/drt-domain-research/SKILL.md +96 -0
  90. package/src/drt-skills/1-analysis/research/drt-domain-research/customize.toml +41 -0
  91. package/src/drt-skills/1-analysis/research/drt-domain-research/domain-steps/step-01-init.md +137 -0
  92. package/src/drt-skills/1-analysis/research/drt-domain-research/domain-steps/step-02-domain-analysis.md +229 -0
  93. package/src/drt-skills/1-analysis/research/drt-domain-research/domain-steps/step-03-competitive-landscape.md +238 -0
  94. package/src/drt-skills/1-analysis/research/drt-domain-research/domain-steps/step-04-regulatory-focus.md +206 -0
  95. package/src/drt-skills/1-analysis/research/drt-domain-research/domain-steps/step-05-technical-trends.md +234 -0
  96. package/src/drt-skills/1-analysis/research/drt-domain-research/domain-steps/step-06-research-synthesis.md +450 -0
  97. package/src/drt-skills/1-analysis/research/drt-domain-research/research.template.md +29 -0
  98. package/src/drt-skills/1-analysis/research/drt-market-research/SKILL.md +96 -0
  99. package/src/drt-skills/1-analysis/research/drt-market-research/customize.toml +41 -0
  100. package/src/drt-skills/1-analysis/research/drt-market-research/research.template.md +29 -0
  101. package/src/drt-skills/1-analysis/research/drt-market-research/steps/step-01-init.md +184 -0
  102. package/src/drt-skills/1-analysis/research/drt-market-research/steps/step-02-customer-behavior.md +239 -0
  103. package/src/drt-skills/1-analysis/research/drt-market-research/steps/step-03-customer-pain-points.md +251 -0
  104. package/src/drt-skills/1-analysis/research/drt-market-research/steps/step-04-customer-decisions.md +261 -0
  105. package/src/drt-skills/1-analysis/research/drt-market-research/steps/step-05-competitive-analysis.md +173 -0
  106. package/src/drt-skills/1-analysis/research/drt-market-research/steps/step-06-research-completion.md +484 -0
  107. package/src/drt-skills/1-analysis/research/drt-technical-research/SKILL.md +96 -0
  108. package/src/drt-skills/1-analysis/research/drt-technical-research/customize.toml +41 -0
  109. package/src/drt-skills/1-analysis/research/drt-technical-research/research.template.md +29 -0
  110. package/src/drt-skills/1-analysis/research/drt-technical-research/technical-steps/step-01-init.md +137 -0
  111. package/src/drt-skills/1-analysis/research/drt-technical-research/technical-steps/step-02-technical-overview.md +239 -0
  112. package/src/drt-skills/1-analysis/research/drt-technical-research/technical-steps/step-03-integration-patterns.md +248 -0
  113. package/src/drt-skills/1-analysis/research/drt-technical-research/technical-steps/step-04-architectural-patterns.md +202 -0
  114. package/src/drt-skills/1-analysis/research/drt-technical-research/technical-steps/step-05-implementation-research.md +233 -0
  115. package/src/drt-skills/1-analysis/research/drt-technical-research/technical-steps/step-06-research-synthesis.md +493 -0
  116. package/src/drt-skills/2-plan-workflows/drt-agent-pm/SKILL.md +76 -0
  117. package/src/drt-skills/2-plan-workflows/drt-agent-pm/customize.toml +75 -0
  118. package/src/drt-skills/2-plan-workflows/drt-agent-ux-designer/SKILL.md +76 -0
  119. package/src/drt-skills/2-plan-workflows/drt-agent-ux-designer/customize.toml +60 -0
  120. package/src/drt-skills/2-plan-workflows/drt-create-prd/SKILL.md +30 -0
  121. package/src/drt-skills/2-plan-workflows/drt-create-prd/customize.toml +41 -0
  122. package/src/drt-skills/2-plan-workflows/drt-edit-prd/SKILL.md +30 -0
  123. package/src/drt-skills/2-plan-workflows/drt-edit-prd/customize.toml +42 -0
  124. package/src/drt-skills/2-plan-workflows/drt-prd/SKILL.md +92 -0
  125. package/src/drt-skills/2-plan-workflows/drt-prd/assets/headless-schemas.md +76 -0
  126. package/src/drt-skills/2-plan-workflows/drt-prd/assets/prd-template.md +165 -0
  127. package/src/drt-skills/2-plan-workflows/drt-prd/assets/prd-validation-checklist.md +135 -0
  128. package/src/drt-skills/2-plan-workflows/drt-prd/assets/validation-report-template.html +325 -0
  129. package/src/drt-skills/2-plan-workflows/drt-prd/customize.toml +147 -0
  130. package/src/drt-skills/2-plan-workflows/drt-prd/references/headless.md +39 -0
  131. package/src/drt-skills/2-plan-workflows/drt-prd/references/validate.md +97 -0
  132. package/src/drt-skills/2-plan-workflows/drt-ux/SKILL.md +90 -0
  133. package/src/drt-skills/2-plan-workflows/drt-ux/assets/color-themes.md +9 -0
  134. package/src/drt-skills/2-plan-workflows/drt-ux/assets/design-directions.md +9 -0
  135. package/src/drt-skills/2-plan-workflows/drt-ux/assets/design-example-editorial.md +158 -0
  136. package/src/drt-skills/2-plan-workflows/drt-ux/assets/design-example-mobile.md +93 -0
  137. package/src/drt-skills/2-plan-workflows/drt-ux/assets/design-example-shadcn.md +109 -0
  138. package/src/drt-skills/2-plan-workflows/drt-ux/assets/excalidraw-wireframe.md +19 -0
  139. package/src/drt-skills/2-plan-workflows/drt-ux/assets/experience-example-mobile.md +112 -0
  140. package/src/drt-skills/2-plan-workflows/drt-ux/assets/experience-example-shadcn.md +133 -0
  141. package/src/drt-skills/2-plan-workflows/drt-ux/assets/headless-schemas.md +84 -0
  142. package/src/drt-skills/2-plan-workflows/drt-ux/assets/key-screens.md +29 -0
  143. package/src/drt-skills/2-plan-workflows/drt-ux/assets/validation-report-template.html +319 -0
  144. package/src/drt-skills/2-plan-workflows/drt-ux/customize.toml +100 -0
  145. package/src/drt-skills/2-plan-workflows/drt-ux/references/creative-tools.md +19 -0
  146. package/src/drt-skills/2-plan-workflows/drt-ux/references/design-md-spec.md +50 -0
  147. package/src/drt-skills/2-plan-workflows/drt-ux/references/headless.md +37 -0
  148. package/src/drt-skills/2-plan-workflows/drt-ux/references/validate.md +115 -0
  149. package/src/drt-skills/2-plan-workflows/drt-validate-prd/SKILL.md +30 -0
  150. package/src/drt-skills/2-plan-workflows/drt-validate-prd/customize.toml +42 -0
  151. package/src/drt-skills/3-solutioning/drt-agent-architect/SKILL.md +76 -0
  152. package/src/drt-skills/3-solutioning/drt-agent-architect/customize.toml +65 -0
  153. package/src/drt-skills/3-solutioning/drt-architecture/SKILL.md +85 -0
  154. package/src/drt-skills/3-solutioning/drt-architecture/assets/spine-template.md +79 -0
  155. package/src/drt-skills/3-solutioning/drt-architecture/customize.toml +100 -0
  156. package/src/drt-skills/3-solutioning/drt-architecture/references/headless.md +26 -0
  157. package/src/drt-skills/3-solutioning/drt-architecture/references/reviewer-gate.md +13 -0
  158. package/src/drt-skills/3-solutioning/drt-architecture/scripts/lint_spine.py +257 -0
  159. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/SKILL.md +91 -0
  160. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/customize.toml +41 -0
  161. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/steps/step-01-document-discovery.md +179 -0
  162. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/steps/step-02-prd-analysis.md +168 -0
  163. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/steps/step-03-epic-coverage-validation.md +169 -0
  164. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/steps/step-04-ux-alignment.md +129 -0
  165. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/steps/step-05-epic-quality-review.md +241 -0
  166. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/steps/step-06-final-assessment.md +132 -0
  167. package/src/drt-skills/3-solutioning/drt-check-implementation-readiness/templates/readiness-report-template.md +4 -0
  168. package/src/drt-skills/3-solutioning/drt-create-architecture/SKILL.md +30 -0
  169. package/src/drt-skills/3-solutioning/drt-create-architecture/customize.toml +41 -0
  170. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/SKILL.md +93 -0
  171. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/customize.toml +41 -0
  172. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/steps/step-01-validate-prerequisites.md +263 -0
  173. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/steps/step-02-design-epics.md +242 -0
  174. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/steps/step-03-create-stories.md +255 -0
  175. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/steps/step-04-final-validation.md +143 -0
  176. package/src/drt-skills/3-solutioning/drt-create-epics-and-stories/templates/epics-template.md +61 -0
  177. package/src/drt-skills/3-solutioning/drt-generate-project-context/SKILL.md +81 -0
  178. package/src/drt-skills/3-solutioning/drt-generate-project-context/customize.toml +41 -0
  179. package/src/drt-skills/3-solutioning/drt-generate-project-context/project-context-template.md +21 -0
  180. package/src/drt-skills/3-solutioning/drt-generate-project-context/steps/step-01-discover.md +186 -0
  181. package/src/drt-skills/3-solutioning/drt-generate-project-context/steps/step-02-generate.md +321 -0
  182. package/src/drt-skills/3-solutioning/drt-generate-project-context/steps/step-03-complete.md +284 -0
  183. package/src/drt-skills/4-implementation/drt-agent-dev/SKILL.md +76 -0
  184. package/src/drt-skills/4-implementation/drt-agent-dev/customize.toml +95 -0
  185. package/src/drt-skills/4-implementation/drt-checkpoint-preview/SKILL.md +68 -0
  186. package/src/drt-skills/4-implementation/drt-checkpoint-preview/customize.toml +41 -0
  187. package/src/drt-skills/4-implementation/drt-checkpoint-preview/generate-trail.md +38 -0
  188. package/src/drt-skills/4-implementation/drt-checkpoint-preview/step-01-orientation.md +105 -0
  189. package/src/drt-skills/4-implementation/drt-checkpoint-preview/step-02-walkthrough.md +89 -0
  190. package/src/drt-skills/4-implementation/drt-checkpoint-preview/step-03-detail-pass.md +106 -0
  191. package/src/drt-skills/4-implementation/drt-checkpoint-preview/step-04-testing.md +74 -0
  192. package/src/drt-skills/4-implementation/drt-checkpoint-preview/step-05-wrapup.md +30 -0
  193. package/src/drt-skills/4-implementation/drt-code-review/SKILL.md +90 -0
  194. package/src/drt-skills/4-implementation/drt-code-review/customize.toml +93 -0
  195. package/src/drt-skills/4-implementation/drt-code-review/steps/step-01-gather-context.md +84 -0
  196. package/src/drt-skills/4-implementation/drt-code-review/steps/step-02-review.md +32 -0
  197. package/src/drt-skills/4-implementation/drt-code-review/steps/step-03-triage.md +50 -0
  198. package/src/drt-skills/4-implementation/drt-code-review/steps/step-04-present.md +132 -0
  199. package/src/drt-skills/4-implementation/drt-correct-course/SKILL.md +301 -0
  200. package/src/drt-skills/4-implementation/drt-correct-course/checklist.md +288 -0
  201. package/src/drt-skills/4-implementation/drt-correct-course/customize.toml +41 -0
  202. package/src/drt-skills/4-implementation/drt-create-story/SKILL.md +432 -0
  203. package/src/drt-skills/4-implementation/drt-create-story/checklist.md +357 -0
  204. package/src/drt-skills/4-implementation/drt-create-story/customize.toml +41 -0
  205. package/src/drt-skills/4-implementation/drt-create-story/discover-inputs.md +88 -0
  206. package/src/drt-skills/4-implementation/drt-create-story/template.md +49 -0
  207. package/src/drt-skills/4-implementation/drt-dev-auto/SKILL.md +123 -0
  208. package/src/drt-skills/4-implementation/drt-dev-auto/compile-epic-context.md +62 -0
  209. package/src/drt-skills/4-implementation/drt-dev-auto/customize.toml +108 -0
  210. package/src/drt-skills/4-implementation/drt-dev-auto/spec-template.md +98 -0
  211. package/src/drt-skills/4-implementation/drt-dev-auto/step-01-clarify-and-route.md +84 -0
  212. package/src/drt-skills/4-implementation/drt-dev-auto/step-02-plan.md +31 -0
  213. package/src/drt-skills/4-implementation/drt-dev-auto/step-03-implement.md +42 -0
  214. package/src/drt-skills/4-implementation/drt-dev-auto/step-04-review.md +95 -0
  215. package/src/drt-skills/4-implementation/drt-dev-story/SKILL.md +500 -0
  216. package/src/drt-skills/4-implementation/drt-dev-story/checklist.md +80 -0
  217. package/src/drt-skills/4-implementation/drt-dev-story/customize.toml +41 -0
  218. package/src/drt-skills/4-implementation/drt-implement-task/SKILL.md +101 -0
  219. package/src/drt-skills/4-implementation/drt-implement-task/assets/task-spec-template.md +60 -0
  220. package/src/drt-skills/4-implementation/drt-implement-task/customize.toml +17 -0
  221. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-01-gather-intent.md +42 -0
  222. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-02-plan-and-approve.md +43 -0
  223. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-03-confirm-dependencies.md +38 -0
  224. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-04-implement.md +42 -0
  225. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-05-qc-test.md +31 -0
  226. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-06-quality-review.md +30 -0
  227. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-07-fix-findings.md +33 -0
  228. package/src/drt-skills/4-implementation/drt-implement-task/steps/step-08-complete.md +35 -0
  229. package/src/drt-skills/4-implementation/drt-qa-generate-e2e-tests/SKILL.md +176 -0
  230. package/src/drt-skills/4-implementation/drt-qa-generate-e2e-tests/checklist.md +33 -0
  231. package/src/drt-skills/4-implementation/drt-qa-generate-e2e-tests/customize.toml +41 -0
  232. package/src/drt-skills/4-implementation/drt-quick-dev/SKILL.md +13 -0
  233. package/src/drt-skills/4-implementation/drt-quick-dev/compile-epic-context.md +62 -0
  234. package/src/drt-skills/4-implementation/drt-quick-dev/customize.toml +83 -0
  235. package/src/drt-skills/4-implementation/drt-quick-dev/render.js +206 -0
  236. package/src/drt-skills/4-implementation/drt-quick-dev/spec-template.md +89 -0
  237. package/src/drt-skills/4-implementation/drt-quick-dev/step-01-clarify-and-route.md +103 -0
  238. package/src/drt-skills/4-implementation/drt-quick-dev/step-02-plan.md +47 -0
  239. package/src/drt-skills/4-implementation/drt-quick-dev/step-03-implement.md +45 -0
  240. package/src/drt-skills/4-implementation/drt-quick-dev/step-04-review.md +55 -0
  241. package/src/drt-skills/4-implementation/drt-quick-dev/step-05-present.md +78 -0
  242. package/src/drt-skills/4-implementation/drt-quick-dev/step-oneshot.md +78 -0
  243. package/src/drt-skills/4-implementation/drt-quick-dev/sync-sprint-status.md +19 -0
  244. package/src/drt-skills/4-implementation/drt-quick-dev/workflow.md +85 -0
  245. package/src/drt-skills/4-implementation/drt-retrospective/SKILL.md +1527 -0
  246. package/src/drt-skills/4-implementation/drt-retrospective/customize.toml +41 -0
  247. package/src/drt-skills/4-implementation/drt-sprint-planning/SKILL.md +319 -0
  248. package/src/drt-skills/4-implementation/drt-sprint-planning/checklist.md +34 -0
  249. package/src/drt-skills/4-implementation/drt-sprint-planning/customize.toml +41 -0
  250. package/src/drt-skills/4-implementation/drt-sprint-planning/sprint-status-template.yaml +69 -0
  251. package/src/drt-skills/4-implementation/drt-sprint-status/SKILL.md +311 -0
  252. package/src/drt-skills/4-implementation/drt-sprint-status/customize.toml +41 -0
  253. package/src/drt-skills/module-help.csv +32 -0
  254. package/src/drt-skills/module.yaml +95 -0
  255. package/src/scripts/lib/load-toml.js +43 -0
  256. package/src/scripts/lib/merge-utils.js +89 -0
  257. package/src/scripts/memlog.js +184 -0
  258. package/src/scripts/package.json +7 -0
  259. package/src/scripts/resolve-config.js +56 -0
  260. package/src/scripts/resolve-customization.js +77 -0
  261. package/tools/installer/cli-utils.js +53 -0
  262. package/tools/installer/commands/install.js +149 -0
  263. package/tools/installer/commands/status.js +65 -0
  264. package/tools/installer/commands/uninstall.js +167 -0
  265. package/tools/installer/core/config.js +73 -0
  266. package/tools/installer/core/existing-install.js +121 -0
  267. package/tools/installer/core/install-paths.js +132 -0
  268. package/tools/installer/core/installer.js +1762 -0
  269. package/tools/installer/core/legacy-warnings.js +151 -0
  270. package/tools/installer/core/manifest-generator.js +859 -0
  271. package/tools/installer/core/manifest.js +433 -0
  272. package/tools/installer/core/uv-check.js +97 -0
  273. package/tools/installer/core/wsl-node-check.js +109 -0
  274. package/tools/installer/drt-cli.js +104 -0
  275. package/tools/installer/file-ops.js +204 -0
  276. package/tools/installer/fs-native.js +116 -0
  277. package/tools/installer/ide/_config-driven.js +972 -0
  278. package/tools/installer/ide/manager.js +324 -0
  279. package/tools/installer/ide/platform-codes.js +80 -0
  280. package/tools/installer/ide/platform-codes.yaml +343 -0
  281. package/tools/installer/ide/shared/installed-skills.js +50 -0
  282. package/tools/installer/ide/shared/path-utils.js +217 -0
  283. package/tools/installer/ide/shared/skill-manifest.js +57 -0
  284. package/tools/installer/install-messages.yaml +29 -0
  285. package/tools/installer/list-options.js +210 -0
  286. package/tools/installer/message-loader.js +83 -0
  287. package/tools/installer/modules/channel-plan.js +203 -0
  288. package/tools/installer/modules/channel-resolver.js +241 -0
  289. package/tools/installer/modules/custom-module-manager.js +918 -0
  290. package/tools/installer/modules/external-manager.js +667 -0
  291. package/tools/installer/modules/module-help-schema.js +13 -0
  292. package/tools/installer/modules/official-modules.js +2257 -0
  293. package/tools/installer/modules/plugin-resolver.js +398 -0
  294. package/tools/installer/modules/version-resolver.js +336 -0
  295. package/tools/installer/project-root.js +224 -0
  296. package/tools/installer/prompts.js +852 -0
  297. package/tools/installer/set-overrides.js +330 -0
  298. package/tools/installer/ui.js +2090 -0
  299. package/tools/installer/yaml-format.js +245 -0
@@ -0,0 +1,2257 @@
1
+ const path = require('node:path');
2
+ const fs = require('../fs-native');
3
+ const yaml = require('yaml');
4
+ const prompts = require('../prompts');
5
+ const { getProjectRoot, getSourcePath, getModulePath } = require('../project-root');
6
+ const { CLIUtils } = require('../cli-utils');
7
+ const { ExternalModuleManager } = require('./external-manager');
8
+
9
+ class OfficialModules {
10
+ constructor(options = {}) {
11
+ this.externalModuleManager = new ExternalModuleManager();
12
+ // Config collection state (merged from ConfigCollector)
13
+ this.collectedConfig = {};
14
+ this._existingConfig = null;
15
+ // Tracked during interactive config collection so {directory_name}
16
+ // placeholder defaults can be resolved in buildQuestion().
17
+ this.currentProjectDir = null;
18
+ // Install-time channel flag state. Set by Config.build once, then used as
19
+ // the default for every findModuleSource/cloneExternalModule call so that
20
+ // pre-install config collection and the install step agree on which ref
21
+ // to clone.
22
+ this.channelOptions = options.channelOptions || null;
23
+ }
24
+
25
+ /**
26
+ * Module configurations collected during install.
27
+ */
28
+ get moduleConfigs() {
29
+ return this.collectedConfig;
30
+ }
31
+
32
+ /**
33
+ * Existing module configurations read from a previous installation.
34
+ */
35
+ get existingConfig() {
36
+ return this._existingConfig;
37
+ }
38
+
39
+ /**
40
+ * Build a configured OfficialModules instance from install config.
41
+ * @param {Object} config - Clean install config (from Config.build)
42
+ * @param {Object} paths - InstallPaths instance
43
+ * @returns {OfficialModules}
44
+ */
45
+ static async build(config, paths) {
46
+ const instance = new OfficialModules({ channelOptions: config.channelOptions });
47
+
48
+ // Pre-collected by UI or quickUpdate — store and load existing for path-change detection
49
+ if (config.moduleConfigs) {
50
+ instance.collectedConfig = config.moduleConfigs;
51
+ await instance.loadExistingConfig(paths.projectRoot);
52
+ return instance;
53
+ }
54
+
55
+ // Headless collection (--yes flag from CLI without UI, tests)
56
+ if (config.hasCoreConfig()) {
57
+ instance.collectedConfig.core = config.coreConfig;
58
+ instance.allAnswers = {};
59
+ for (const [key, value] of Object.entries(config.coreConfig)) {
60
+ instance.allAnswers[`core_${key}`] = value;
61
+ }
62
+ }
63
+
64
+ const toCollect = config.hasCoreConfig() ? config.modules.filter((m) => m !== 'core') : [...config.modules];
65
+
66
+ await instance.collectAllConfigurations(toCollect, paths.projectRoot, {
67
+ skipPrompts: config.skipPrompts,
68
+ });
69
+
70
+ return instance;
71
+ }
72
+
73
+ /**
74
+ * Copy a file to the target location
75
+ * @param {string} sourcePath - Source file path
76
+ * @param {string} targetPath - Target file path
77
+ * @param {boolean} overwrite - Whether to overwrite existing files (default: true)
78
+ */
79
+ async copyFile(sourcePath, targetPath, overwrite = true) {
80
+ await fs.copy(sourcePath, targetPath, { overwrite });
81
+ }
82
+
83
+ /**
84
+ * Copy a directory recursively
85
+ * @param {string} sourceDir - Source directory path
86
+ * @param {string} targetDir - Target directory path
87
+ * @param {boolean} overwrite - Whether to overwrite existing files (default: true)
88
+ */
89
+ async copyDirectory(sourceDir, targetDir, overwrite = true) {
90
+ await fs.ensureDir(targetDir);
91
+ const entries = await fs.readdir(sourceDir, { withFileTypes: true });
92
+
93
+ for (const entry of entries) {
94
+ const sourcePath = path.join(sourceDir, entry.name);
95
+ const targetPath = path.join(targetDir, entry.name);
96
+
97
+ if (entry.isDirectory()) {
98
+ await this.copyDirectory(sourcePath, targetPath, overwrite);
99
+ } else {
100
+ await this.copyFile(sourcePath, targetPath, overwrite);
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * List all available built-in modules (core and bmm).
107
+ * All other modules come from external-official-modules.yaml
108
+ * @returns {Object} Object with modules array
109
+ */
110
+ async listAvailable() {
111
+ const modules = [];
112
+
113
+ // Add built-in core module (directly under src/core-skills)
114
+ const corePath = getSourcePath('core-skills');
115
+ if (await fs.pathExists(corePath)) {
116
+ const coreInfo = await this.getModuleInfo(corePath, 'core', 'src/core-skills');
117
+ if (coreInfo) {
118
+ modules.push(coreInfo);
119
+ }
120
+ }
121
+
122
+ // Add built-in bmm module (directly under src/drt-skills)
123
+ const bmmPath = getSourcePath('drt-skills');
124
+ if (await fs.pathExists(bmmPath)) {
125
+ const bmmInfo = await this.getModuleInfo(bmmPath, 'drt', 'src/drt-skills');
126
+ if (bmmInfo) {
127
+ modules.push(bmmInfo);
128
+ }
129
+ }
130
+
131
+ return { modules };
132
+ }
133
+
134
+ /**
135
+ * Get module information from a module path
136
+ * @param {string} modulePath - Path to the module directory
137
+ * @param {string} defaultName - Default name for the module
138
+ * @param {string} sourceDescription - Description of where the module was found
139
+ * @returns {Object|null} Module info or null if not a valid module
140
+ */
141
+ async getModuleInfo(modulePath, defaultName, sourceDescription) {
142
+ const moduleConfigPath = path.join(modulePath, 'module.yaml');
143
+
144
+ if (!(await fs.pathExists(moduleConfigPath))) {
145
+ // Check resolution cache for strategy 5 modules (no module.yaml on disk)
146
+ const { CustomModuleManager } = require('./custom-module-manager');
147
+ const customMgr = new CustomModuleManager();
148
+ const resolved = customMgr.getResolution(defaultName);
149
+ if (resolved && resolved.synthesizedModuleYaml) {
150
+ return {
151
+ id: resolved.code,
152
+ path: modulePath,
153
+ name: resolved.name,
154
+ description: resolved.description,
155
+ version: resolved.version || '1.0.0',
156
+ source: sourceDescription,
157
+ dependencies: [],
158
+ defaultSelected: false,
159
+ };
160
+ }
161
+ return null;
162
+ }
163
+
164
+ const moduleInfo = {
165
+ id: defaultName,
166
+ path: modulePath,
167
+ name: defaultName
168
+ .split('-')
169
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
170
+ .join(' '),
171
+ description: 'DRT Module',
172
+ version: '5.0.0',
173
+ source: sourceDescription,
174
+ };
175
+
176
+ // Read module config for metadata
177
+ try {
178
+ const configContent = await fs.readFile(moduleConfigPath, 'utf8');
179
+ const config = yaml.parse(configContent);
180
+
181
+ // Use the code property as the id if available
182
+ if (config.code) {
183
+ moduleInfo.id = config.code;
184
+ }
185
+
186
+ moduleInfo.name = config.name || moduleInfo.name;
187
+ moduleInfo.description = config.description || moduleInfo.description;
188
+ moduleInfo.version = config.version || moduleInfo.version;
189
+ moduleInfo.dependencies = config.dependencies || [];
190
+ moduleInfo.defaultSelected = config.default_selected === undefined ? false : config.default_selected;
191
+ } catch (error) {
192
+ await prompts.log.warn(`Failed to read config for ${defaultName}: ${error.message}`);
193
+ }
194
+
195
+ return moduleInfo;
196
+ }
197
+
198
+ /**
199
+ * Find the source path for a module by searching all possible locations
200
+ * @param {string} moduleCode - Code of the module to find (from module.yaml)
201
+ * @returns {string|null} Path to the module source or null if not found
202
+ */
203
+ async findModuleSource(moduleCode, options = {}) {
204
+ // Inherit channelOptions from the install-scoped instance when the caller
205
+ // didn't pass one explicitly. Keeps pre-install config collection and the
206
+ // actual install step looking at the same git ref.
207
+ if (options.channelOptions === undefined && this.channelOptions) {
208
+ options = { ...options, channelOptions: this.channelOptions };
209
+ }
210
+ const projectRoot = getProjectRoot();
211
+
212
+ // Check for core module (directly under src/core-skills)
213
+ if (moduleCode === 'core') {
214
+ const corePath = getSourcePath('core-skills');
215
+ if (await fs.pathExists(corePath)) {
216
+ return corePath;
217
+ }
218
+ }
219
+
220
+ // Check for built-in bmm module (directly under src/drt-skills)
221
+ if (moduleCode === 'drt') {
222
+ const bmmPath = getSourcePath('drt-skills');
223
+ if (await fs.pathExists(bmmPath)) {
224
+ return bmmPath;
225
+ }
226
+ }
227
+
228
+ // Check external official modules (pass channelOptions so channel plan applies)
229
+ const externalSource = await this.externalModuleManager.findExternalModuleSource(moduleCode, options);
230
+ if (externalSource) {
231
+ return externalSource;
232
+ }
233
+
234
+ // Check custom modules (from user-provided URLs, already cloned to cache)
235
+ const { CustomModuleManager } = require('./custom-module-manager');
236
+ const customMgr = new CustomModuleManager();
237
+ const customSource = await customMgr.findModuleSourceByCode(moduleCode, options);
238
+ if (customSource) {
239
+ return customSource;
240
+ }
241
+
242
+ return null;
243
+ }
244
+
245
+ /**
246
+ * Install a module
247
+ * @param {string} moduleName - Code of the module to install (from module.yaml)
248
+ * @param {string} drtDir - Target drt directory
249
+ * @param {Function} fileTrackingCallback - Optional callback to track installed files
250
+ * @param {Object} options - Additional installation options
251
+ * @param {Array<string>} options.installedIDEs - Array of IDE codes that were installed
252
+ * @param {Object} options.moduleConfig - Module configuration from config collector
253
+ * @param {Object} options.logger - Logger instance for output
254
+ */
255
+ async install(moduleName, drtDir, fileTrackingCallback = null, options = {}) {
256
+ // Check if this module has a plugin resolution (custom marketplace install)
257
+ const { CustomModuleManager } = require('./custom-module-manager');
258
+ const customMgr = new CustomModuleManager();
259
+ const resolved = customMgr.getResolution(moduleName);
260
+ if (resolved) {
261
+ return this.installFromResolution(resolved, drtDir, fileTrackingCallback, options);
262
+ }
263
+
264
+ const sourcePath = await this.findModuleSource(moduleName, {
265
+ silent: options.silent,
266
+ channelOptions: options.channelOptions,
267
+ });
268
+ const targetPath = path.join(drtDir, moduleName);
269
+
270
+ if (!sourcePath) {
271
+ throw new Error(
272
+ `Source for module '${moduleName}' is not available. It will be retained but cannot be updated without its source files.`,
273
+ );
274
+ }
275
+
276
+ if (await fs.pathExists(targetPath)) {
277
+ await fs.remove(targetPath);
278
+ }
279
+
280
+ // Marketplace-plugin registry modules keep their installable skills outside
281
+ // the directory that holds module.yaml (sourcePath points at the -setup
282
+ // skill's assets/), so they cannot be installed by copying sourcePath. Copy
283
+ // the resolved skill directories instead, matching how custom marketplace
284
+ // installs lay out a module. Everything else (manifest, version info) flows
285
+ // through the standard external-module path below.
286
+ const moduleInfo = await this.externalModuleManager.getModuleByCode(moduleName);
287
+ if (moduleInfo && moduleInfo.marketplacePlugin) {
288
+ const pluginResolution = this.externalModuleManager.getPluginResolution(moduleName);
289
+ // Fail loud: copying sourcePath here would install only the -setup skill's
290
+ // assets/ (module.yaml + module-help.csv) and none of the skills — a
291
+ // silent, broken partial install. Abort instead.
292
+ if (!pluginResolution || !Array.isArray(pluginResolution.skillPaths) || pluginResolution.skillPaths.length === 0) {
293
+ throw new Error(
294
+ `Module '${moduleName}' is registered as a marketplace plugin but its skills could not be resolved ` +
295
+ `from .claude-plugin/marketplace.json (missing or malformed on the selected channel). ` +
296
+ `Aborting to avoid a partial install with no skills.`,
297
+ );
298
+ }
299
+ await this._copyResolvedSkills(pluginResolution, targetPath, fileTrackingCallback, options.moduleConfig);
300
+ } else {
301
+ await this.copyModuleWithFiltering(sourcePath, targetPath, fileTrackingCallback, options.moduleConfig);
302
+ }
303
+
304
+ if (!options.skipModuleInstaller) {
305
+ await this.createModuleDirectories(moduleName, drtDir, options);
306
+ }
307
+
308
+ const { Manifest } = require('../core/manifest');
309
+ const manifestObj = new Manifest();
310
+ const versionInfo = await manifestObj.getModuleVersionInfo(moduleName, drtDir, sourcePath);
311
+
312
+ // Pick up channel resolution recorded by the external manager (the only
313
+ // manager that does pre-clone resolution now that community is retired).
314
+ const resolution = this.externalModuleManager.getResolution(moduleName);
315
+
316
+ await manifestObj.addModule(drtDir, moduleName, {
317
+ version: resolution?.version || versionInfo.version,
318
+ source: versionInfo.source,
319
+ npmPackage: versionInfo.npmPackage,
320
+ repoUrl: versionInfo.repoUrl,
321
+ channel: resolution?.channel,
322
+ sha: resolution?.sha,
323
+ });
324
+
325
+ return { success: true, module: moduleName, path: targetPath, versionInfo };
326
+ }
327
+
328
+ /**
329
+ * Lay out a PluginResolver resolution on disk: copy each resolved skill
330
+ * directory (flattened by leaf name) into targetPath and place module-help.csv
331
+ * at the module root. Shared by both custom marketplace installs
332
+ * (installFromResolution) and official marketplace-plugin registry installs
333
+ * (install), so the two paths cannot drift.
334
+ * @param {Object} resolved - ResolvedModule from PluginResolver
335
+ * @param {string} targetPath - Destination module directory (e.g. drtDir/<code>)
336
+ * @param {Function} fileTrackingCallback - Optional callback to track installed files
337
+ * @param {Object} moduleConfig - Module configuration passed to copy filtering
338
+ */
339
+ async _copyResolvedSkills(resolved, targetPath, fileTrackingCallback = null, moduleConfig = {}) {
340
+ await fs.ensureDir(targetPath);
341
+
342
+ // Copy each skill directory, flattened by leaf name. Leaf names must be
343
+ // unique — two skills that flatten to the same directory would silently
344
+ // overwrite each other, so fail loud instead.
345
+ const seenLeaves = new Map();
346
+ for (const skillPath of resolved.skillPaths) {
347
+ const skillDirName = path.basename(skillPath);
348
+ if (seenLeaves.has(skillDirName)) {
349
+ throw new Error(
350
+ `Cannot install module '${resolved.code}': skill directories '${seenLeaves.get(skillDirName)}' and ` +
351
+ `'${skillPath}' share the leaf name '${skillDirName}' and would overwrite each other. ` +
352
+ `Skill directory names must be unique.`,
353
+ );
354
+ }
355
+ seenLeaves.set(skillDirName, skillPath);
356
+ const skillTarget = path.join(targetPath, skillDirName);
357
+ await this.copyModuleWithFiltering(skillPath, skillTarget, fileTrackingCallback, moduleConfig);
358
+ }
359
+
360
+ // Place module-help.csv at the module root.
361
+ const helpTarget = path.join(targetPath, 'module-help.csv');
362
+ if (resolved.moduleHelpCsvPath) {
363
+ // Strategies 1-4: copy the existing file.
364
+ await fs.copy(resolved.moduleHelpCsvPath, helpTarget, { overwrite: true });
365
+ if (fileTrackingCallback) fileTrackingCallback(helpTarget);
366
+ } else if (resolved.synthesizedHelpCsv) {
367
+ // Strategy 5: write synthesized content.
368
+ await fs.writeFile(helpTarget, resolved.synthesizedHelpCsv, 'utf8');
369
+ if (fileTrackingCallback) fileTrackingCallback(helpTarget);
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Install a module from a PluginResolver resolution result.
375
+ * Copies specific skill directories and places module-help.csv at the target root.
376
+ * @param {Object} resolved - ResolvedModule from PluginResolver
377
+ * @param {string} drtDir - Target drt directory
378
+ * @param {Function} fileTrackingCallback - Optional callback to track installed files
379
+ * @param {Object} options - Installation options
380
+ */
381
+ async installFromResolution(resolved, drtDir, fileTrackingCallback = null, options = {}) {
382
+ const targetPath = path.join(drtDir, resolved.code);
383
+
384
+ if (await fs.pathExists(targetPath)) {
385
+ await fs.remove(targetPath);
386
+ }
387
+
388
+ await this._copyResolvedSkills(resolved, targetPath, fileTrackingCallback, options.moduleConfig);
389
+
390
+ // Create directories declared in module.yaml (strategies 1-4 may have these)
391
+ if (!options.skipModuleInstaller) {
392
+ await this.createModuleDirectories(resolved.code, drtDir, options);
393
+ }
394
+
395
+ // Update manifest. For custom-source installs we derive channel from the
396
+ // cloneRef (present → pinned, absent → next; local paths have no channel).
397
+ const { Manifest } = require('../core/manifest');
398
+ const manifestObj = new Manifest();
399
+
400
+ const hasGitClone = !!resolved.repoUrl;
401
+ const manifestEntry = {
402
+ version: resolved.cloneRef || (hasGitClone ? 'main' : resolved.version || null),
403
+ source: 'custom',
404
+ npmPackage: null,
405
+ repoUrl: resolved.repoUrl || null,
406
+ };
407
+ if (hasGitClone) {
408
+ manifestEntry.channel = resolved.cloneRef ? 'pinned' : 'next';
409
+ if (resolved.cloneSha) manifestEntry.sha = resolved.cloneSha;
410
+ if (resolved.rawInput) manifestEntry.rawSource = resolved.rawInput;
411
+ }
412
+ if (resolved.localPath) manifestEntry.localPath = resolved.localPath;
413
+ await manifestObj.addModule(drtDir, resolved.code, manifestEntry);
414
+
415
+ return {
416
+ success: true,
417
+ module: resolved.code,
418
+ path: targetPath,
419
+ // Mirror the manifestEntry.version precedence above so downstream summary
420
+ // lines show the same string we just wrote to disk (custom git-backed
421
+ // installs show the cloned ref or 'main').
422
+ versionInfo: {
423
+ version: resolved.cloneRef || (hasGitClone ? 'main' : resolved.version || ''),
424
+ },
425
+ };
426
+ }
427
+
428
+ /**
429
+ * Update an existing module
430
+ * @param {string} moduleName - Name of the module to update
431
+ * @param {string} drtDir - Target drt directory
432
+ */
433
+ async update(moduleName, drtDir) {
434
+ const sourcePath = await this.findModuleSource(moduleName);
435
+ const targetPath = path.join(drtDir, moduleName);
436
+
437
+ if (!sourcePath) {
438
+ throw new Error(`Module '${moduleName}' not found in any source location`);
439
+ }
440
+
441
+ if (!(await fs.pathExists(targetPath))) {
442
+ throw new Error(`Module '${moduleName}' is not installed`);
443
+ }
444
+
445
+ await this.syncModule(sourcePath, targetPath);
446
+
447
+ return {
448
+ success: true,
449
+ module: moduleName,
450
+ path: targetPath,
451
+ };
452
+ }
453
+
454
+ /**
455
+ * Remove a module
456
+ * @param {string} moduleName - Name of the module to remove
457
+ * @param {string} drtDir - Target drt directory
458
+ */
459
+ async remove(moduleName, drtDir) {
460
+ const targetPath = path.join(drtDir, moduleName);
461
+
462
+ if (!(await fs.pathExists(targetPath))) {
463
+ throw new Error(`Module '${moduleName}' is not installed`);
464
+ }
465
+
466
+ await fs.remove(targetPath);
467
+
468
+ return {
469
+ success: true,
470
+ module: moduleName,
471
+ };
472
+ }
473
+
474
+ /**
475
+ * Check if a module is installed
476
+ * @param {string} moduleName - Name of the module
477
+ * @param {string} drtDir - Target drt directory
478
+ * @returns {boolean} True if module is installed
479
+ */
480
+ async isInstalled(moduleName, drtDir) {
481
+ const targetPath = path.join(drtDir, moduleName);
482
+ return await fs.pathExists(targetPath);
483
+ }
484
+
485
+ /**
486
+ * Get installed module info
487
+ * @param {string} moduleName - Name of the module
488
+ * @param {string} drtDir - Target drt directory
489
+ * @returns {Object|null} Module info or null if not installed
490
+ */
491
+ async getInstalledInfo(moduleName, drtDir) {
492
+ const targetPath = path.join(drtDir, moduleName);
493
+
494
+ if (!(await fs.pathExists(targetPath))) {
495
+ return null;
496
+ }
497
+
498
+ const configPath = path.join(targetPath, 'config.yaml');
499
+ const moduleInfo = {
500
+ id: moduleName,
501
+ path: targetPath,
502
+ installed: true,
503
+ };
504
+
505
+ if (await fs.pathExists(configPath)) {
506
+ try {
507
+ const configContent = await fs.readFile(configPath, 'utf8');
508
+ const config = yaml.parse(configContent);
509
+ Object.assign(moduleInfo, config);
510
+ } catch (error) {
511
+ await prompts.log.warn(`Failed to read installed module config: ${error.message}`);
512
+ }
513
+ }
514
+
515
+ return moduleInfo;
516
+ }
517
+
518
+ /**
519
+ * Copy module with filtering for localskip agents and conditional content
520
+ * @param {string} sourcePath - Source module path
521
+ * @param {string} targetPath - Target module path
522
+ * @param {Function} fileTrackingCallback - Optional callback to track installed files
523
+ * @param {Object} moduleConfig - Module configuration with conditional flags
524
+ */
525
+ async copyModuleWithFiltering(sourcePath, targetPath, fileTrackingCallback = null, moduleConfig = {}) {
526
+ // Get all files in source
527
+ const sourceFiles = await this.getFileList(sourcePath);
528
+
529
+ for (const file of sourceFiles) {
530
+ // Skip sub-modules directory - these are IDE-specific and handled separately
531
+ if (file.startsWith('sub-modules/')) {
532
+ continue;
533
+ }
534
+
535
+ // Skip sidecar directories - these contain agent-specific assets not needed at install time
536
+ const isInSidecarDirectory = path
537
+ .dirname(file)
538
+ .split('/')
539
+ .some((dir) => dir.toLowerCase().endsWith('-sidecar'));
540
+
541
+ if (isInSidecarDirectory) {
542
+ continue;
543
+ }
544
+
545
+ // Skip module.yaml at root - it's only needed at install time
546
+ if (file === 'module.yaml') {
547
+ continue;
548
+ }
549
+
550
+ // Skip module root config.yaml only - generated by config collector with actual values
551
+ // Workflow-level config.yaml (e.g. workflows/orchestrate-story/config.yaml) must be copied
552
+ // for custom modules that use workflow-specific configuration
553
+ if (file === 'config.yaml') {
554
+ continue;
555
+ }
556
+
557
+ const sourceFile = path.join(sourcePath, file);
558
+ const targetFile = path.join(targetPath, file);
559
+
560
+ // Check if this is an agent file
561
+ if (file.startsWith('agents/') && file.endsWith('.md')) {
562
+ // Read the file to check for localskip
563
+ const content = await fs.readFile(sourceFile, 'utf8');
564
+
565
+ // Check for localskip="true" in the agent tag
566
+ const agentMatch = content.match(/<agent[^>]*\slocalskip="true"[^>]*>/);
567
+ if (agentMatch) {
568
+ await prompts.log.message(` Skipping web-only agent: ${path.basename(file)}`);
569
+ continue; // Skip this agent
570
+ }
571
+ }
572
+
573
+ // Copy the file with placeholder replacement
574
+ await this.copyFile(sourceFile, targetFile);
575
+
576
+ // Track the file if callback provided
577
+ if (fileTrackingCallback) {
578
+ fileTrackingCallback(targetFile);
579
+ }
580
+ }
581
+ }
582
+
583
+ /**
584
+ * Create directories declared in module.yaml's `directories` key
585
+ * This replaces the security-risky module installer pattern with declarative config
586
+ * During updates, if a directory path changed, moves the old directory to the new path
587
+ * @param {string} moduleName - Name of the module
588
+ * @param {string} drtDir - Target drt directory
589
+ * @param {Object} options - Installation options
590
+ * @param {Object} options.moduleConfig - Module configuration from config collector
591
+ * @param {Object} options.existingModuleConfig - Previous module config (for detecting path changes during updates)
592
+ * @param {Object} options.coreConfig - Core configuration
593
+ * @returns {Promise<{createdDirs: string[], movedDirs: string[], createdWdsFolders: string[]}>} Created directories info
594
+ */
595
+ async createModuleDirectories(moduleName, drtDir, options = {}) {
596
+ const moduleConfig = options.moduleConfig || {};
597
+ const existingModuleConfig = options.existingModuleConfig || {};
598
+ const projectRoot = path.dirname(drtDir);
599
+ const emptyResult = { createdDirs: [], movedDirs: [], createdWdsFolders: [] };
600
+
601
+ // Special handling for core module - it's in src/core-skills not src/modules
602
+ let sourcePath;
603
+ if (moduleName === 'core') {
604
+ sourcePath = getSourcePath('core-skills');
605
+ } else {
606
+ sourcePath = await this.findModuleSource(moduleName, { silent: true });
607
+ if (!sourcePath) {
608
+ return emptyResult; // No source found, skip
609
+ }
610
+ }
611
+
612
+ // Read module.yaml to find the `directories` key
613
+ const moduleYamlPath = path.join(sourcePath, 'module.yaml');
614
+ if (!(await fs.pathExists(moduleYamlPath))) {
615
+ return emptyResult; // No module.yaml, skip
616
+ }
617
+
618
+ let moduleYaml;
619
+ try {
620
+ const yamlContent = await fs.readFile(moduleYamlPath, 'utf8');
621
+ moduleYaml = yaml.parse(yamlContent);
622
+ } catch (error) {
623
+ await prompts.log.warn(`Invalid module.yaml for ${moduleName}: ${error.message}`);
624
+ return emptyResult;
625
+ }
626
+
627
+ if (!moduleYaml || !moduleYaml.directories) {
628
+ return emptyResult; // No directories declared, skip
629
+ }
630
+
631
+ const directories = moduleYaml.directories;
632
+ const wdsFolders = moduleYaml.wds_folders || [];
633
+ const createdDirs = [];
634
+ const movedDirs = [];
635
+ const createdWdsFolders = [];
636
+
637
+ for (const dirRef of directories) {
638
+ // Parse variable reference like "{design_artifacts}"
639
+ const varMatch = dirRef.match(/^\{([^}]+)\}$/);
640
+ if (!varMatch) {
641
+ // Not a variable reference, skip
642
+ continue;
643
+ }
644
+
645
+ const configKey = varMatch[1];
646
+ const dirValue = moduleConfig[configKey];
647
+ if (!dirValue || typeof dirValue !== 'string') {
648
+ continue; // No value or not a string, skip
649
+ }
650
+
651
+ // Strip {project-root}/ prefix if present
652
+ let dirPath = dirValue.replace(/^\{project-root\}\/?/, '');
653
+
654
+ // Handle remaining {project-root} anywhere in the path
655
+ dirPath = dirPath.replaceAll('{project-root}', '');
656
+
657
+ // Resolve to absolute path
658
+ const fullPath = path.join(projectRoot, dirPath);
659
+
660
+ // Validate path is within project root (prevent directory traversal)
661
+ const normalizedPath = path.normalize(fullPath);
662
+ const normalizedRoot = path.normalize(projectRoot);
663
+ if (!normalizedPath.startsWith(normalizedRoot + path.sep) && normalizedPath !== normalizedRoot) {
664
+ const color = await prompts.getColor();
665
+ await prompts.log.warn(color.yellow(`${configKey} path escapes project root, skipping: ${dirPath}`));
666
+ continue;
667
+ }
668
+
669
+ // Check if directory path changed from previous config (update/modify scenario)
670
+ const oldDirValue = existingModuleConfig[configKey];
671
+ let oldFullPath = null;
672
+ let oldDirPath = null;
673
+ if (oldDirValue && typeof oldDirValue === 'string') {
674
+ // F3: Normalize both values before comparing to avoid false negatives
675
+ // from trailing slashes, separator differences, or prefix format variations
676
+ let normalizedOld = oldDirValue.replace(/^\{project-root\}\/?/, '');
677
+ normalizedOld = path.normalize(normalizedOld.replaceAll('{project-root}', ''));
678
+ const normalizedNew = path.normalize(dirPath);
679
+
680
+ if (normalizedOld !== normalizedNew) {
681
+ oldDirPath = normalizedOld;
682
+ oldFullPath = path.join(projectRoot, oldDirPath);
683
+ const normalizedOldAbsolute = path.normalize(oldFullPath);
684
+ if (!normalizedOldAbsolute.startsWith(normalizedRoot + path.sep) && normalizedOldAbsolute !== normalizedRoot) {
685
+ oldFullPath = null; // Old path escapes project root, ignore it
686
+ }
687
+
688
+ // F13: Prevent parent/child move (e.g. docs/planning → docs/planning/v2)
689
+ if (oldFullPath) {
690
+ const normalizedNewAbsolute = path.normalize(fullPath);
691
+ if (
692
+ normalizedOldAbsolute.startsWith(normalizedNewAbsolute + path.sep) ||
693
+ normalizedNewAbsolute.startsWith(normalizedOldAbsolute + path.sep)
694
+ ) {
695
+ const color = await prompts.getColor();
696
+ await prompts.log.warn(
697
+ color.yellow(
698
+ `${configKey}: cannot move between parent/child paths (${oldDirPath} / ${dirPath}), creating new directory instead`,
699
+ ),
700
+ );
701
+ oldFullPath = null;
702
+ }
703
+ }
704
+ }
705
+ }
706
+
707
+ const dirName = configKey.replaceAll('_', ' ');
708
+
709
+ if (oldFullPath && (await fs.pathExists(oldFullPath)) && !(await fs.pathExists(fullPath))) {
710
+ // Path changed and old dir exists → move old to new location
711
+ // F1: Use fs.move() instead of fs.rename() for cross-device/volume support
712
+ // F2: Wrap in try/catch — fallback to creating new dir on failure
713
+ try {
714
+ await fs.ensureDir(path.dirname(fullPath));
715
+ await fs.move(oldFullPath, fullPath);
716
+ movedDirs.push(`${dirName}: ${oldDirPath} → ${dirPath}`);
717
+ } catch (moveError) {
718
+ const color = await prompts.getColor();
719
+ await prompts.log.warn(
720
+ color.yellow(
721
+ `Failed to move ${oldDirPath} → ${dirPath}: ${moveError.message}\n Creating new directory instead. Please move contents from the old directory manually.`,
722
+ ),
723
+ );
724
+ await fs.ensureDir(fullPath);
725
+ createdDirs.push(`${dirName}: ${dirPath}`);
726
+ }
727
+ } else if (oldFullPath && (await fs.pathExists(oldFullPath)) && (await fs.pathExists(fullPath))) {
728
+ // F5: Both old and new directories exist — warn user about potential orphaned documents
729
+ const color = await prompts.getColor();
730
+ await prompts.log.warn(
731
+ color.yellow(
732
+ `${dirName}: path changed but both directories exist:\n Old: ${oldDirPath}\n New: ${dirPath}\n Old directory may contain orphaned documents — please review and merge manually.`,
733
+ ),
734
+ );
735
+ } else if (!(await fs.pathExists(fullPath))) {
736
+ // New directory doesn't exist yet → create it
737
+ createdDirs.push(`${dirName}: ${dirPath}`);
738
+ await fs.ensureDir(fullPath);
739
+ }
740
+
741
+ // Create WDS subfolders if this is the design_artifacts directory
742
+ if (configKey === 'design_artifacts' && wdsFolders.length > 0) {
743
+ for (const subfolder of wdsFolders) {
744
+ const subPath = path.join(fullPath, subfolder);
745
+ if (!(await fs.pathExists(subPath))) {
746
+ await fs.ensureDir(subPath);
747
+ createdWdsFolders.push(subfolder);
748
+ }
749
+ }
750
+ }
751
+ }
752
+
753
+ return { createdDirs, movedDirs, createdWdsFolders };
754
+ }
755
+
756
+ /**
757
+ * Private: Sync module files (preserving user modifications)
758
+ * @param {string} sourcePath - Source module path
759
+ * @param {string} targetPath - Target module path
760
+ */
761
+ async syncModule(sourcePath, targetPath) {
762
+ // Get list of all source files
763
+ const sourceFiles = await this.getFileList(sourcePath);
764
+
765
+ for (const file of sourceFiles) {
766
+ const sourceFile = path.join(sourcePath, file);
767
+ const targetFile = path.join(targetPath, file);
768
+
769
+ // Check if target file exists and has been modified
770
+ if (await fs.pathExists(targetFile)) {
771
+ const sourceStats = await fs.stat(sourceFile);
772
+ const targetStats = await fs.stat(targetFile);
773
+
774
+ // Skip if target is newer (user modified)
775
+ if (targetStats.mtime > sourceStats.mtime) {
776
+ continue;
777
+ }
778
+ }
779
+
780
+ // Copy file with placeholder replacement
781
+ await this.copyFile(sourceFile, targetFile);
782
+ }
783
+ }
784
+
785
+ /**
786
+ * Private: Get list of all files in a directory
787
+ * @param {string} dir - Directory path
788
+ * @param {string} baseDir - Base directory for relative paths
789
+ * @returns {Array} List of relative file paths
790
+ */
791
+ async getFileList(dir, baseDir = dir) {
792
+ const files = [];
793
+ const entries = await fs.readdir(dir, { withFileTypes: true });
794
+
795
+ for (const entry of entries) {
796
+ const fullPath = path.join(dir, entry.name);
797
+
798
+ if (entry.isDirectory()) {
799
+ const subFiles = await this.getFileList(fullPath, baseDir);
800
+ files.push(...subFiles);
801
+ } else {
802
+ files.push(path.relative(baseDir, fullPath));
803
+ }
804
+ }
805
+
806
+ return files;
807
+ }
808
+
809
+ // ─── Config collection methods (merged from ConfigCollector) ───
810
+
811
+ /**
812
+ * Find the drt installation directory in a project
813
+ * V6+ installations can use ANY folder name but ALWAYS have _config/manifest.yaml
814
+ * @param {string} projectDir - Project directory
815
+ * @returns {Promise<string>} Path to drt directory
816
+ */
817
+ async findDrtDir(projectDir) {
818
+ // Check if project directory exists
819
+ if (!(await fs.pathExists(projectDir))) {
820
+ // Project doesn't exist yet, return default
821
+ return path.join(projectDir, 'drt');
822
+ }
823
+
824
+ // V6+ strategy: Look for ANY directory with _config/manifest.yaml
825
+ // This is the definitive marker of a V6+ installation
826
+ try {
827
+ const entries = await fs.readdir(projectDir, { withFileTypes: true });
828
+ for (const entry of entries) {
829
+ if (entry.isDirectory()) {
830
+ const manifestPath = path.join(projectDir, entry.name, '_config', 'manifest.yaml');
831
+ if (await fs.pathExists(manifestPath)) {
832
+ // Found a V6+ installation
833
+ return path.join(projectDir, entry.name);
834
+ }
835
+ }
836
+ }
837
+ } catch {
838
+ // Ignore errors, fall through to default
839
+ }
840
+
841
+ // No V6+ installation found, return default
842
+ // This will be used for new installations
843
+ return path.join(projectDir, 'drt');
844
+ }
845
+
846
+ /**
847
+ * Detect the existing DRT folder name in a project
848
+ * @param {string} projectDir - Project directory
849
+ * @returns {Promise<string|null>} Folder name (just the name, not full path) or null if not found
850
+ */
851
+ async detectExistingDrtFolder(projectDir) {
852
+ // Check if project directory exists
853
+ if (!(await fs.pathExists(projectDir))) {
854
+ return null;
855
+ }
856
+
857
+ // Look for ANY directory with _config/manifest.yaml
858
+ try {
859
+ const entries = await fs.readdir(projectDir, { withFileTypes: true });
860
+ for (const entry of entries) {
861
+ if (entry.isDirectory()) {
862
+ const manifestPath = path.join(projectDir, entry.name, '_config', 'manifest.yaml');
863
+ if (await fs.pathExists(manifestPath)) {
864
+ // Found a V6+ installation, return just the folder name
865
+ return entry.name;
866
+ }
867
+ }
868
+ }
869
+ } catch {
870
+ // Ignore errors
871
+ }
872
+
873
+ return null;
874
+ }
875
+
876
+ /**
877
+ * Load existing config if it exists from module config files
878
+ * @param {string} projectDir - Target project directory
879
+ */
880
+ async loadExistingConfig(projectDir) {
881
+ this._existingConfig = {};
882
+
883
+ // Check if project directory exists first
884
+ if (!(await fs.pathExists(projectDir))) {
885
+ return false;
886
+ }
887
+
888
+ // Find the actual drt directory (handles custom folder names)
889
+ const drtDir = await this.findDrtDir(projectDir);
890
+
891
+ // Check if drt directory exists
892
+ if (!(await fs.pathExists(drtDir))) {
893
+ return false;
894
+ }
895
+
896
+ // Primary source: installer-written config.toml + config.user.toml (v6+).
897
+ // Both files together hold all install answers; config.user.toml carries
898
+ // user-scoped keys like user_name that would otherwise be re-prompted on
899
+ // every reinstall.
900
+ let foundAny = false;
901
+ for (const fileName of ['config.toml', 'config.user.toml']) {
902
+ const tomlPath = path.join(drtDir, fileName);
903
+ if (!(await fs.pathExists(tomlPath))) continue;
904
+ try {
905
+ const content = await fs.readFile(tomlPath, 'utf8');
906
+ const parsed = parseCentralToml(content);
907
+ for (const [section, values] of Object.entries(parsed)) {
908
+ if (values && typeof values === 'object' && !Array.isArray(values)) {
909
+ if (!this._existingConfig[section]) this._existingConfig[section] = {};
910
+ Object.assign(this._existingConfig[section], values);
911
+ foundAny = true;
912
+ }
913
+ }
914
+ } catch {
915
+ // Ignore parse errors
916
+ }
917
+ }
918
+
919
+ if (foundAny) {
920
+ return true;
921
+ }
922
+
923
+ // Fallback: legacy per-module config.yaml files (pre-v6 installations).
924
+ const entries = await fs.readdir(drtDir, { withFileTypes: true });
925
+ const nonModuleDirs = new Set(['_config', '_memory', 'memory', 'docs', 'scripts', 'custom']);
926
+ for (const entry of entries) {
927
+ if (entry.isDirectory()) {
928
+ if (nonModuleDirs.has(entry.name)) {
929
+ continue;
930
+ }
931
+
932
+ const moduleConfigPath = path.join(drtDir, entry.name, 'config.yaml');
933
+
934
+ if (await fs.pathExists(moduleConfigPath)) {
935
+ try {
936
+ const content = await fs.readFile(moduleConfigPath, 'utf8');
937
+ const moduleConfig = yaml.parse(content);
938
+ // Only keep plain object parses. A corrupt config.yaml that parses
939
+ // to a scalar or array would crash later code that does `key in cfg`
940
+ // / `Object.keys(cfg)`; treat it the same as a parse error.
941
+ if (moduleConfig && typeof moduleConfig === 'object' && !Array.isArray(moduleConfig)) {
942
+ this._existingConfig[entry.name] = moduleConfig;
943
+ foundAny = true;
944
+ }
945
+ } catch {
946
+ // Ignore parse errors for individual modules
947
+ }
948
+ }
949
+ }
950
+ }
951
+
952
+ if (foundAny) {
953
+ await this._hoistCoreKeysFromLegacyModuleConfigs();
954
+ }
955
+
956
+ return foundAny;
957
+ }
958
+
959
+ /**
960
+ * Migrate prior answers when a key has moved from a non-core module to core
961
+ * (e.g. project_name moving from bmm to core in #2279). Without this, the
962
+ * partition logic in writeCentralConfig drops the value from the bmm bucket
963
+ * (because it's now a core key) without re-homing it under [core], so the
964
+ * user's prior answer silently disappears on the next install/quick-update.
965
+ */
966
+ async _hoistCoreKeysFromLegacyModuleConfigs() {
967
+ const coreSchemaPath = path.join(getSourcePath(), 'core-skills', 'module.yaml');
968
+ if (!(await fs.pathExists(coreSchemaPath))) return;
969
+
970
+ let coreSchema;
971
+ try {
972
+ coreSchema = yaml.parse(await fs.readFile(coreSchemaPath, 'utf8'));
973
+ } catch {
974
+ return;
975
+ }
976
+ if (!coreSchema || typeof coreSchema !== 'object') return;
977
+
978
+ const coreKeys = new Set(
979
+ Object.entries(coreSchema)
980
+ .filter(([, v]) => v && typeof v === 'object' && 'prompt' in v)
981
+ .map(([k]) => k),
982
+ );
983
+ if (coreKeys.size === 0) return;
984
+
985
+ // Belt-and-suspenders: loadExistingConfig already filters non-object parses,
986
+ // but anyone calling _hoistCoreKeysFromLegacyModuleConfigs in isolation (or
987
+ // future code paths populating _existingConfig directly) shouldn't be able
988
+ // to crash this with a scalar / array.
989
+ const existingCore = this._existingConfig.core;
990
+ this._existingConfig.core = existingCore && typeof existingCore === 'object' && !Array.isArray(existingCore) ? existingCore : {};
991
+
992
+ for (const [moduleName, cfg] of Object.entries(this._existingConfig)) {
993
+ if (moduleName === 'core' || !cfg || typeof cfg !== 'object' || Array.isArray(cfg)) continue;
994
+ for (const key of Object.keys(cfg)) {
995
+ if (!coreKeys.has(key)) continue;
996
+ if (!(key in this._existingConfig.core)) {
997
+ this._existingConfig.core[key] = cfg[key];
998
+ }
999
+ delete cfg[key];
1000
+ }
1001
+ }
1002
+ }
1003
+
1004
+ /**
1005
+ * Pre-scan module schemas to gather metadata for the configuration gateway prompt.
1006
+ * Returns info about which modules have configurable options.
1007
+ * @param {Array} modules - List of non-core module names
1008
+ * @returns {Promise<Array>} Array of {moduleName, displayName, questionCount, hasFieldsWithoutDefaults}
1009
+ */
1010
+ async scanModuleSchemas(modules) {
1011
+ const metadataFields = new Set(['code', 'name', 'header', 'subheader', 'default_selected']);
1012
+ const results = [];
1013
+
1014
+ for (const moduleName of modules) {
1015
+ // Resolve module.yaml path - standard location first, then OfficialModules search
1016
+ let moduleConfigPath = null;
1017
+ const standardPath = path.join(getModulePath(moduleName), 'module.yaml');
1018
+ if (await fs.pathExists(standardPath)) {
1019
+ moduleConfigPath = standardPath;
1020
+ } else {
1021
+ const moduleSourcePath = await this.findModuleSource(moduleName, { silent: true });
1022
+ if (moduleSourcePath) {
1023
+ moduleConfigPath = path.join(moduleSourcePath, 'module.yaml');
1024
+ }
1025
+ }
1026
+
1027
+ if (!moduleConfigPath || !(await fs.pathExists(moduleConfigPath))) {
1028
+ continue;
1029
+ }
1030
+
1031
+ try {
1032
+ const content = await fs.readFile(moduleConfigPath, 'utf8');
1033
+ const moduleConfig = yaml.parse(content);
1034
+ if (!moduleConfig) continue;
1035
+
1036
+ const displayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1037
+ const configKeys = Object.keys(moduleConfig).filter((key) => key !== 'prompt');
1038
+ const questionKeys = configKeys.filter((key) => {
1039
+ if (metadataFields.has(key)) return false;
1040
+ const item = moduleConfig[key];
1041
+ return item && typeof item === 'object' && item.prompt;
1042
+ });
1043
+
1044
+ const hasFieldsWithoutDefaults = questionKeys.some((key) => {
1045
+ const item = moduleConfig[key];
1046
+ return item.default === undefined || item.default === null || item.default === '';
1047
+ });
1048
+
1049
+ results.push({
1050
+ moduleName,
1051
+ displayName,
1052
+ questionCount: questionKeys.length,
1053
+ hasFieldsWithoutDefaults,
1054
+ });
1055
+ } catch (error) {
1056
+ await prompts.log.warn(`Could not read schema for module "${moduleName}": ${error.message}`);
1057
+ }
1058
+ }
1059
+
1060
+ return results;
1061
+ }
1062
+
1063
+ /**
1064
+ * Collect configuration for all modules
1065
+ * @param {Array} modules - List of modules to configure (including 'core')
1066
+ * @param {string} projectDir - Target project directory
1067
+ * @param {Object} options - Additional options
1068
+ * @param {boolean} options.skipPrompts - Skip prompts and use defaults (for --yes flag)
1069
+ */
1070
+ async collectAllConfigurations(modules, projectDir, options = {}) {
1071
+ this.skipPrompts = options.skipPrompts || false;
1072
+ this.modulesToCustomize = undefined;
1073
+ await this.loadExistingConfig(projectDir);
1074
+
1075
+ // Check if core was already collected (e.g., in early collection phase)
1076
+ const coreAlreadyCollected = this.collectedConfig.core && Object.keys(this.collectedConfig.core).length > 0;
1077
+
1078
+ // If core wasn't already collected, include it
1079
+ const allModules = coreAlreadyCollected ? modules.filter((m) => m !== 'core') : ['core', ...modules.filter((m) => m !== 'core')];
1080
+
1081
+ // Store all answers across modules for cross-referencing
1082
+ if (!this.allAnswers) {
1083
+ this.allAnswers = {};
1084
+ }
1085
+
1086
+ // Split processing: core first, then gateway, then remaining modules
1087
+ const coreModules = allModules.filter((m) => m === 'core');
1088
+ const nonCoreModules = allModules.filter((m) => m !== 'core');
1089
+
1090
+ // Collect core config first (always fully prompted)
1091
+ for (const moduleName of coreModules) {
1092
+ await this.collectModuleConfig(moduleName, projectDir);
1093
+ }
1094
+
1095
+ // Show batch configuration gateway for non-core modules
1096
+ // Scan all non-core module schemas for display names and config metadata
1097
+ let scannedModules = [];
1098
+ if (!this.skipPrompts && nonCoreModules.length > 0) {
1099
+ scannedModules = await this.scanModuleSchemas(nonCoreModules);
1100
+ const customizableModules = scannedModules.filter((m) => m.questionCount > 0);
1101
+
1102
+ if (customizableModules.length > 0) {
1103
+ const configMode = await prompts.select({
1104
+ message: 'Module configuration',
1105
+ choices: [
1106
+ { name: 'Express Setup', value: 'express', hint: 'accept all defaults (recommended)' },
1107
+ { name: 'Customize', value: 'customize', hint: 'choose modules to configure' },
1108
+ ],
1109
+ default: 'express',
1110
+ });
1111
+
1112
+ if (configMode === 'customize') {
1113
+ const choices = customizableModules.map((m) => ({
1114
+ name: `${m.displayName} (${m.questionCount} option${m.questionCount === 1 ? '' : 's'})`,
1115
+ value: m.moduleName,
1116
+ hint: m.hasFieldsWithoutDefaults ? 'has fields without defaults' : undefined,
1117
+ checked: m.hasFieldsWithoutDefaults,
1118
+ }));
1119
+ const selected = await prompts.multiselect({
1120
+ message: 'Select modules to customize:',
1121
+ choices,
1122
+ required: false,
1123
+ });
1124
+ this.modulesToCustomize = new Set(selected);
1125
+ } else {
1126
+ // Express mode: no modules to customize
1127
+ this.modulesToCustomize = new Set();
1128
+ }
1129
+ } else {
1130
+ // All non-core modules have zero config - no gateway needed
1131
+ this.modulesToCustomize = new Set();
1132
+ }
1133
+ }
1134
+
1135
+ // Collect remaining non-core modules
1136
+ if (this.modulesToCustomize === undefined) {
1137
+ // No gateway was shown (skipPrompts, no non-core modules, or direct call) - process all normally
1138
+ for (const moduleName of nonCoreModules) {
1139
+ await this.collectModuleConfig(moduleName, projectDir);
1140
+ }
1141
+ } else {
1142
+ // Split into default modules (tasks progress) and customized modules (interactive)
1143
+ const defaultModules = nonCoreModules.filter((m) => !this.modulesToCustomize.has(m));
1144
+ const customizeModules = nonCoreModules.filter((m) => this.modulesToCustomize.has(m));
1145
+
1146
+ // Run default modules with a single spinner
1147
+ if (defaultModules.length > 0) {
1148
+ // Build display name map from all scanned modules for pre-call spinner messages
1149
+ const displayNameMap = new Map();
1150
+ for (const m of scannedModules) {
1151
+ displayNameMap.set(m.moduleName, m.displayName);
1152
+ }
1153
+
1154
+ const configSpinner = await prompts.spinner();
1155
+ configSpinner.start('Configuring modules...');
1156
+ try {
1157
+ for (const moduleName of defaultModules) {
1158
+ const displayName = displayNameMap.get(moduleName) || moduleName.toUpperCase();
1159
+ configSpinner.message(`Configuring ${displayName}...`);
1160
+ try {
1161
+ this._silentConfig = true;
1162
+ await this.collectModuleConfig(moduleName, projectDir);
1163
+ } finally {
1164
+ this._silentConfig = false;
1165
+ }
1166
+ }
1167
+ } finally {
1168
+ configSpinner.stop(customizeModules.length > 0 ? 'Module defaults applied' : 'Module configuration complete');
1169
+ }
1170
+ }
1171
+
1172
+ // Run customized modules individually (may show interactive prompts)
1173
+ for (const moduleName of customizeModules) {
1174
+ await this.collectModuleConfig(moduleName, projectDir);
1175
+ }
1176
+
1177
+ if (customizeModules.length > 0) {
1178
+ await prompts.log.step('Module configuration complete');
1179
+ }
1180
+ }
1181
+
1182
+ // Add metadata
1183
+ this.collectedConfig._meta = {
1184
+ version: require(path.join(getProjectRoot(), 'package.json')).version,
1185
+ installDate: new Date().toISOString(),
1186
+ lastModified: new Date().toISOString(),
1187
+ };
1188
+
1189
+ return this.collectedConfig;
1190
+ }
1191
+
1192
+ /**
1193
+ * Collect configuration for a single module (Quick Update mode - only new fields)
1194
+ * @param {string} moduleName - Module name
1195
+ * @param {string} projectDir - Target project directory
1196
+ * @param {boolean} silentMode - If true, only prompt for new/missing fields
1197
+ * @returns {boolean} True if new fields were prompted, false if all fields existed
1198
+ */
1199
+ async collectModuleConfigQuick(moduleName, projectDir, silentMode = true) {
1200
+ this.currentProjectDir = projectDir;
1201
+ // Load existing config if not already loaded
1202
+ if (!this._existingConfig) {
1203
+ await this.loadExistingConfig(projectDir);
1204
+ }
1205
+
1206
+ // Initialize allAnswers if not already initialized
1207
+ if (!this.allAnswers) {
1208
+ this.allAnswers = {};
1209
+ }
1210
+
1211
+ // Load module's config schema from module.yaml
1212
+ // First, try the standard src/modules location
1213
+ let moduleConfigPath = path.join(getModulePath(moduleName), 'module.yaml');
1214
+
1215
+ // If not found in src/modules, we need to find it by searching the project
1216
+ if (!(await fs.pathExists(moduleConfigPath))) {
1217
+ const moduleSourcePath = await this.findModuleSource(moduleName, { silent: true });
1218
+
1219
+ if (moduleSourcePath) {
1220
+ moduleConfigPath = path.join(moduleSourcePath, 'module.yaml');
1221
+ }
1222
+ }
1223
+
1224
+ if (!(await fs.pathExists(moduleConfigPath))) {
1225
+ // No config schema for this module - use existing values
1226
+ if (this._existingConfig && this._existingConfig[moduleName]) {
1227
+ if (!this.collectedConfig[moduleName]) {
1228
+ this.collectedConfig[moduleName] = {};
1229
+ }
1230
+ this.collectedConfig[moduleName] = { ...this._existingConfig[moduleName] };
1231
+ }
1232
+ return false;
1233
+ }
1234
+
1235
+ const configContent = await fs.readFile(moduleConfigPath, 'utf8');
1236
+ const moduleConfig = yaml.parse(configContent);
1237
+
1238
+ if (!moduleConfig) {
1239
+ return false;
1240
+ }
1241
+
1242
+ // Compare schema with existing config to find new/missing fields
1243
+ const configKeys = Object.keys(moduleConfig).filter((key) => key !== 'prompt');
1244
+ const existingKeys = this._existingConfig && this._existingConfig[moduleName] ? Object.keys(this._existingConfig[moduleName]) : [];
1245
+
1246
+ // Check if this module has no configuration keys at all (like CIS)
1247
+ // Filter out metadata fields and only count actual config objects
1248
+ const metadataFields = new Set(['code', 'name', 'header', 'subheader', 'default_selected']);
1249
+ const actualConfigKeys = configKeys.filter((key) => !metadataFields.has(key));
1250
+ const hasNoConfig = actualConfigKeys.length === 0;
1251
+
1252
+ // If module has no config keys at all, handle it specially
1253
+ if (hasNoConfig && moduleConfig.subheader) {
1254
+ const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1255
+ await prompts.log.step(moduleDisplayName);
1256
+ await prompts.log.message(` \u2713 ${moduleConfig.subheader}`);
1257
+ return false; // No new fields
1258
+ }
1259
+
1260
+ // Find new interactive fields (with prompt)
1261
+ const newKeys = configKeys.filter((key) => {
1262
+ const item = moduleConfig[key];
1263
+ // Check if it's a config item and doesn't exist in existing config
1264
+ return item && typeof item === 'object' && item.prompt && !existingKeys.includes(key);
1265
+ });
1266
+
1267
+ // Find new static fields (without prompt, just result)
1268
+ const newStaticKeys = configKeys.filter((key) => {
1269
+ const item = moduleConfig[key];
1270
+ return item && typeof item === 'object' && !item.prompt && item.result && !existingKeys.includes(key);
1271
+ });
1272
+
1273
+ // If in silent mode and no new keys (neither interactive nor static), use existing config and skip prompts
1274
+ if (silentMode && newKeys.length === 0 && newStaticKeys.length === 0) {
1275
+ if (this._existingConfig && this._existingConfig[moduleName]) {
1276
+ if (!this.collectedConfig[moduleName]) {
1277
+ this.collectedConfig[moduleName] = {};
1278
+ }
1279
+ this.collectedConfig[moduleName] = { ...this._existingConfig[moduleName] };
1280
+
1281
+ // Special handling for user_name: ensure it has a value
1282
+ if (
1283
+ moduleName === 'core' &&
1284
+ (!this.collectedConfig[moduleName].user_name || this.collectedConfig[moduleName].user_name === '[USER_NAME]')
1285
+ ) {
1286
+ this.collectedConfig[moduleName].user_name = this.getDefaultUsername();
1287
+ }
1288
+
1289
+ // Also populate allAnswers for cross-referencing
1290
+ for (const [key, value] of Object.entries(this._existingConfig[moduleName])) {
1291
+ // Ensure user_name is properly set in allAnswers too
1292
+ let finalValue = value;
1293
+ if (moduleName === 'core' && key === 'user_name' && (!value || value === '[USER_NAME]')) {
1294
+ finalValue = this.getDefaultUsername();
1295
+ }
1296
+ this.allAnswers[`${moduleName}_${key}`] = finalValue;
1297
+ }
1298
+ } else if (moduleName === 'core') {
1299
+ // No existing core config - ensure we at least have user_name
1300
+ if (!this.collectedConfig[moduleName]) {
1301
+ this.collectedConfig[moduleName] = {};
1302
+ }
1303
+ if (!this.collectedConfig[moduleName].user_name) {
1304
+ this.collectedConfig[moduleName].user_name = this.getDefaultUsername();
1305
+ this.allAnswers[`${moduleName}_user_name`] = this.getDefaultUsername();
1306
+ }
1307
+ }
1308
+
1309
+ // Show "no config" message for modules with no new questions (that have config keys)
1310
+ await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module already up to date`);
1311
+ return false; // No new fields
1312
+ }
1313
+
1314
+ // If we have new fields (interactive or static), process them
1315
+ if (newKeys.length > 0 || newStaticKeys.length > 0) {
1316
+ const questions = [];
1317
+ const staticAnswers = {};
1318
+
1319
+ // Build questions for interactive fields
1320
+ for (const key of newKeys) {
1321
+ const item = moduleConfig[key];
1322
+ const question = await this.buildQuestion(moduleName, key, item, moduleConfig);
1323
+ if (question) {
1324
+ questions.push(question);
1325
+ }
1326
+ }
1327
+
1328
+ // Prepare static answers (no prompt, just result)
1329
+ for (const key of newStaticKeys) {
1330
+ staticAnswers[`${moduleName}_${key}`] = undefined;
1331
+ }
1332
+
1333
+ // Collect all answers (static + prompted)
1334
+ let allAnswers = { ...staticAnswers };
1335
+
1336
+ if (questions.length > 0 && silentMode) {
1337
+ // In silent mode (quick update), use defaults for new fields instead of prompting
1338
+ for (const q of questions) {
1339
+ allAnswers[q.name] = typeof q.default === 'function' ? q.default({}) : q.default;
1340
+ }
1341
+ await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configured with defaults`);
1342
+ } else if (questions.length > 0) {
1343
+ // Only show header if we actually have questions
1344
+ await CLIUtils.displayModuleConfigHeader(moduleName, moduleConfig.header, moduleConfig.subheader);
1345
+ await prompts.log.message('');
1346
+ const promptedAnswers = await prompts.prompt(questions);
1347
+
1348
+ // Merge prompted answers with static answers
1349
+ Object.assign(allAnswers, promptedAnswers);
1350
+ } else if (newStaticKeys.length > 0) {
1351
+ // Only static fields, no questions - show no config message
1352
+ await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configuration updated`);
1353
+ }
1354
+
1355
+ // Store all answers for cross-referencing
1356
+ Object.assign(this.allAnswers, allAnswers);
1357
+
1358
+ // Process all answers (both static and prompted)
1359
+ // First, copy existing config to preserve values that aren't being updated
1360
+ if (this._existingConfig && this._existingConfig[moduleName]) {
1361
+ this.collectedConfig[moduleName] = { ...this._existingConfig[moduleName] };
1362
+ } else {
1363
+ this.collectedConfig[moduleName] = {};
1364
+ }
1365
+
1366
+ for (const key of Object.keys(allAnswers)) {
1367
+ const originalKey = key.replace(`${moduleName}_`, '');
1368
+ const item = moduleConfig[originalKey];
1369
+ const value = allAnswers[key];
1370
+
1371
+ let result;
1372
+ if (Array.isArray(value)) {
1373
+ result = value;
1374
+ } else if (item.result) {
1375
+ result = this.processResultTemplate(item.result, value);
1376
+ } else {
1377
+ result = value;
1378
+ }
1379
+
1380
+ // Update the collected config with new/updated values
1381
+ this.collectedConfig[moduleName][originalKey] = result;
1382
+ }
1383
+ }
1384
+
1385
+ // Copy over existing values for fields that weren't prompted
1386
+ if (this._existingConfig && this._existingConfig[moduleName]) {
1387
+ if (!this.collectedConfig[moduleName]) {
1388
+ this.collectedConfig[moduleName] = {};
1389
+ }
1390
+ for (const [key, value] of Object.entries(this._existingConfig[moduleName])) {
1391
+ if (!this.collectedConfig[moduleName][key]) {
1392
+ this.collectedConfig[moduleName][key] = value;
1393
+ this.allAnswers[`${moduleName}_${key}`] = value;
1394
+ }
1395
+ }
1396
+ }
1397
+
1398
+ await this.displayModulePostConfigNotes(moduleName, moduleConfig);
1399
+
1400
+ return newKeys.length > 0 || newStaticKeys.length > 0; // Return true if we had any new fields (interactive or static)
1401
+ }
1402
+
1403
+ /**
1404
+ * Process a result template with value substitution
1405
+ * @param {*} resultTemplate - The result template
1406
+ * @param {*} value - The value to substitute
1407
+ * @returns {*} Processed result
1408
+ */
1409
+ processResultTemplate(resultTemplate, value) {
1410
+ let result = resultTemplate;
1411
+
1412
+ if (typeof result === 'string' && value !== undefined) {
1413
+ if (typeof value === 'string') {
1414
+ result = result.replace('{value}', value);
1415
+ } else if (typeof value === 'boolean' || typeof value === 'number') {
1416
+ if (result === '{value}') {
1417
+ result = value;
1418
+ } else {
1419
+ result = result.replace('{value}', value);
1420
+ }
1421
+ } else {
1422
+ result = value;
1423
+ }
1424
+
1425
+ if (typeof result === 'string') {
1426
+ result = result.replaceAll(/{([^}]+)}/g, (match, configKey) => {
1427
+ if (configKey === 'project-root') {
1428
+ return '{project-root}';
1429
+ }
1430
+ if (configKey === 'value') {
1431
+ return match;
1432
+ }
1433
+
1434
+ let configValue = this.allAnswers[configKey] || this.allAnswers[`${configKey}`];
1435
+ if (!configValue) {
1436
+ for (const [answerKey, answerValue] of Object.entries(this.allAnswers)) {
1437
+ if (answerKey.endsWith(`_${configKey}`)) {
1438
+ configValue = answerValue;
1439
+ break;
1440
+ }
1441
+ }
1442
+ }
1443
+
1444
+ if (!configValue) {
1445
+ for (const mod of Object.keys(this.collectedConfig)) {
1446
+ if (mod !== '_meta' && this.collectedConfig[mod] && this.collectedConfig[mod][configKey]) {
1447
+ configValue = this.collectedConfig[mod][configKey];
1448
+ if (typeof configValue === 'string' && configValue.includes('{project-root}/')) {
1449
+ configValue = configValue.replace('{project-root}/', '');
1450
+ }
1451
+ break;
1452
+ }
1453
+ }
1454
+ }
1455
+
1456
+ return configValue || match;
1457
+ });
1458
+ }
1459
+ }
1460
+
1461
+ return result;
1462
+ }
1463
+
1464
+ /**
1465
+ * Get the default username from the system
1466
+ * @returns {string} Capitalized username\
1467
+ */
1468
+ getDefaultUsername() {
1469
+ let result = 'DRT';
1470
+ try {
1471
+ const os = require('node:os');
1472
+ const userInfo = os.userInfo();
1473
+ if (userInfo && userInfo.username) {
1474
+ const username = userInfo.username;
1475
+ result = username.charAt(0).toUpperCase() + username.slice(1);
1476
+ }
1477
+ } catch {
1478
+ // Do nothing, just return 'DRT'
1479
+ }
1480
+ return result;
1481
+ }
1482
+
1483
+ /**
1484
+ * Collect configuration for a single module
1485
+ * @param {string} moduleName - Module name
1486
+ * @param {string} projectDir - Target project directory
1487
+ * @param {boolean} skipLoadExisting - Skip loading existing config (for early core collection)
1488
+ * @param {boolean} skipCompletion - Skip showing completion message (for early core collection)
1489
+ */
1490
+ async collectModuleConfig(moduleName, projectDir, skipLoadExisting = false, skipCompletion = false) {
1491
+ this.currentProjectDir = projectDir;
1492
+ // Load existing config if needed and not already loaded
1493
+ if (!skipLoadExisting && !this._existingConfig) {
1494
+ await this.loadExistingConfig(projectDir);
1495
+ }
1496
+
1497
+ // Initialize allAnswers if not already initialized
1498
+ if (!this.allAnswers) {
1499
+ this.allAnswers = {};
1500
+ }
1501
+ // Load module's config
1502
+ let moduleConfigPath = path.join(getModulePath(moduleName), 'module.yaml');
1503
+
1504
+ // If not found in src/modules or custom paths, search the project
1505
+ if (!(await fs.pathExists(moduleConfigPath))) {
1506
+ const moduleSourcePath = await this.findModuleSource(moduleName, { silent: true });
1507
+
1508
+ if (moduleSourcePath) {
1509
+ moduleConfigPath = path.join(moduleSourcePath, 'module.yaml');
1510
+ }
1511
+ }
1512
+
1513
+ let configPath = null;
1514
+ if (await fs.pathExists(moduleConfigPath)) {
1515
+ configPath = moduleConfigPath;
1516
+ } else {
1517
+ // No config for this module
1518
+ return;
1519
+ }
1520
+
1521
+ const configContent = await fs.readFile(configPath, 'utf8');
1522
+ const moduleConfig = yaml.parse(configContent);
1523
+
1524
+ if (!moduleConfig) {
1525
+ return;
1526
+ }
1527
+
1528
+ // Process each config item
1529
+ const questions = [];
1530
+ const staticAnswers = {};
1531
+ const configKeys = Object.keys(moduleConfig).filter((key) => key !== 'prompt');
1532
+
1533
+ for (const key of configKeys) {
1534
+ const item = moduleConfig[key];
1535
+
1536
+ // Skip if not a config object
1537
+ if (!item || typeof item !== 'object') {
1538
+ continue;
1539
+ }
1540
+
1541
+ // Handle static values (no prompt, just result)
1542
+ if (!item.prompt && item.result) {
1543
+ // Add to static answers with a marker value
1544
+ staticAnswers[`${moduleName}_${key}`] = undefined;
1545
+ continue;
1546
+ }
1547
+
1548
+ // Handle interactive values (with prompt)
1549
+ if (item.prompt) {
1550
+ const question = await this.buildQuestion(moduleName, key, item, moduleConfig);
1551
+ if (question) {
1552
+ questions.push(question);
1553
+ }
1554
+ }
1555
+ }
1556
+
1557
+ // Collect all answers (static + prompted)
1558
+ let allAnswers = { ...staticAnswers };
1559
+
1560
+ // If there are questions to ask, prompt for accepting defaults vs customizing
1561
+ if (questions.length > 0) {
1562
+ const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1563
+
1564
+ // Skip prompts mode: use all defaults without asking
1565
+ if (this.skipPrompts) {
1566
+ await prompts.log.info(`Using default configuration for ${moduleDisplayName}`);
1567
+ // Use defaults for all questions
1568
+ for (const question of questions) {
1569
+ const hasDefault = question.default !== undefined && question.default !== null && question.default !== '';
1570
+ if (hasDefault && typeof question.default !== 'function') {
1571
+ allAnswers[question.name] = question.default;
1572
+ }
1573
+ }
1574
+ } else {
1575
+ if (!this._silentConfig) await prompts.log.step(`Configuring ${moduleDisplayName}`);
1576
+ let useDefaults = true;
1577
+ if (moduleName === 'core') {
1578
+ useDefaults = false; // Core: always show all questions
1579
+ } else if (this.modulesToCustomize === undefined) {
1580
+ // Fallback: original per-module confirm (backward compat for direct calls)
1581
+ const customizeAnswer = await prompts.prompt([
1582
+ {
1583
+ type: 'confirm',
1584
+ name: 'customize',
1585
+ message: 'Accept Defaults (no to customize)?',
1586
+ default: true,
1587
+ },
1588
+ ]);
1589
+ useDefaults = customizeAnswer.customize;
1590
+ } else {
1591
+ // Batch mode: use defaults unless module was selected for customization
1592
+ useDefaults = !this.modulesToCustomize.has(moduleName);
1593
+ }
1594
+
1595
+ if (useDefaults && moduleName !== 'core') {
1596
+ // Accept defaults - only ask questions that have NO default value
1597
+ const questionsWithoutDefaults = questions.filter((q) => q.default === undefined || q.default === null || q.default === '');
1598
+
1599
+ if (questionsWithoutDefaults.length > 0) {
1600
+ await prompts.log.message(` Asking required questions for ${moduleName.toUpperCase()}...`);
1601
+ const promptedAnswers = await prompts.prompt(questionsWithoutDefaults);
1602
+ Object.assign(allAnswers, promptedAnswers);
1603
+ }
1604
+
1605
+ // For questions with defaults that weren't asked, we need to process them with their default values
1606
+ const questionsWithDefaults = questions.filter((q) => q.default !== undefined && q.default !== null && q.default !== '');
1607
+ for (const question of questionsWithDefaults) {
1608
+ // Skip function defaults - these are dynamic and will be evaluated later
1609
+ if (typeof question.default === 'function') {
1610
+ continue;
1611
+ }
1612
+ allAnswers[question.name] = question.default;
1613
+ }
1614
+ } else {
1615
+ const promptedAnswers = await prompts.prompt(questions);
1616
+ Object.assign(allAnswers, promptedAnswers);
1617
+ }
1618
+ }
1619
+ }
1620
+
1621
+ // Store all answers for cross-referencing
1622
+ Object.assign(this.allAnswers, allAnswers);
1623
+
1624
+ // Process all answers (both static and prompted)
1625
+ // Always process if we have any answers or static answers
1626
+ if (Object.keys(allAnswers).length > 0 || Object.keys(staticAnswers).length > 0) {
1627
+ const answers = allAnswers;
1628
+
1629
+ // Process answers and build result values
1630
+ for (const key of Object.keys(answers)) {
1631
+ const originalKey = key.replace(`${moduleName}_`, '');
1632
+ const item = moduleConfig[originalKey];
1633
+ const value = answers[key];
1634
+
1635
+ // Build the result using the template
1636
+ let result;
1637
+
1638
+ // For arrays (multi-select), handle differently
1639
+ if (Array.isArray(value)) {
1640
+ result = value;
1641
+ } else if (item.result) {
1642
+ result = item.result;
1643
+
1644
+ // Replace placeholders only for strings
1645
+ if (typeof result === 'string' && value !== undefined) {
1646
+ // Replace {value} with the actual value
1647
+ if (typeof value === 'string') {
1648
+ result = result.replace('{value}', value);
1649
+ } else if (typeof value === 'boolean' || typeof value === 'number') {
1650
+ // For boolean and number values, if result is just "{value}", use the raw value
1651
+ if (result === '{value}') {
1652
+ result = value;
1653
+ } else {
1654
+ result = result.replace('{value}', value);
1655
+ }
1656
+ } else {
1657
+ result = value;
1658
+ }
1659
+
1660
+ // Only do further replacements if result is still a string
1661
+ if (typeof result === 'string') {
1662
+ // Replace references to other config values
1663
+ result = result.replaceAll(/{([^}]+)}/g, (match, configKey) => {
1664
+ // Check if it's a special placeholder
1665
+ if (configKey === 'project-root') {
1666
+ return '{project-root}';
1667
+ }
1668
+
1669
+ // Skip if it's the 'value' placeholder we already handled
1670
+ if (configKey === 'value') {
1671
+ return match;
1672
+ }
1673
+
1674
+ // Look for the config value across all modules
1675
+ // First check if it's in the current module's answers
1676
+ let configValue = answers[`${moduleName}_${configKey}`];
1677
+
1678
+ // Then check all answers (for cross-module references like outputFolder)
1679
+ if (!configValue) {
1680
+ // Try with various module prefixes
1681
+ for (const [answerKey, answerValue] of Object.entries(this.allAnswers)) {
1682
+ if (answerKey.endsWith(`_${configKey}`)) {
1683
+ configValue = answerValue;
1684
+ break;
1685
+ }
1686
+ }
1687
+ }
1688
+
1689
+ // Check in already collected config
1690
+ if (!configValue) {
1691
+ for (const mod of Object.keys(this.collectedConfig)) {
1692
+ if (mod !== '_meta' && this.collectedConfig[mod] && this.collectedConfig[mod][configKey]) {
1693
+ configValue = this.collectedConfig[mod][configKey];
1694
+ break;
1695
+ }
1696
+ }
1697
+ }
1698
+
1699
+ return configValue || match;
1700
+ });
1701
+ }
1702
+ }
1703
+ } else {
1704
+ result = value;
1705
+ }
1706
+
1707
+ // Store only the result value (no prompts, defaults, examples, etc.)
1708
+ if (!this.collectedConfig[moduleName]) {
1709
+ this.collectedConfig[moduleName] = {};
1710
+ }
1711
+ this.collectedConfig[moduleName][originalKey] = result;
1712
+ }
1713
+
1714
+ // No longer display completion boxes - keep output clean
1715
+ } else {
1716
+ // No questions for this module - show completion message with header if available
1717
+ const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1718
+
1719
+ // Check if this module has NO configuration keys at all (like CIS)
1720
+ // Filter out metadata fields and only count actual config objects
1721
+ const metadataFields = new Set(['code', 'name', 'header', 'subheader', 'default_selected']);
1722
+ const actualConfigKeys = configKeys.filter((key) => !metadataFields.has(key));
1723
+ const hasNoConfig = actualConfigKeys.length === 0;
1724
+
1725
+ if (!this._silentConfig) {
1726
+ if (hasNoConfig && (moduleConfig.subheader || moduleConfig.header)) {
1727
+ await prompts.log.step(moduleDisplayName);
1728
+ if (moduleConfig.subheader) {
1729
+ await prompts.log.message(` \u2713 ${moduleConfig.subheader}`);
1730
+ } else {
1731
+ await prompts.log.message(` \u2713 No custom configuration required`);
1732
+ }
1733
+ } else {
1734
+ // Module has config but just no questions to ask
1735
+ await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configured`);
1736
+ }
1737
+ }
1738
+ }
1739
+
1740
+ // If we have no collected config for this module, but we have a module schema,
1741
+ // ensure we have at least an empty object
1742
+ if (!this.collectedConfig[moduleName]) {
1743
+ this.collectedConfig[moduleName] = {};
1744
+
1745
+ // If we accepted defaults and have no answers, we still need to check
1746
+ // if there are any static values in the schema that should be applied
1747
+ if (moduleConfig) {
1748
+ for (const key of Object.keys(moduleConfig)) {
1749
+ if (key !== 'prompt' && moduleConfig[key] && typeof moduleConfig[key] === 'object') {
1750
+ const item = moduleConfig[key];
1751
+ // For static items (no prompt, just result), apply the result
1752
+ if (!item.prompt && item.result) {
1753
+ // Apply any placeholder replacements to the result
1754
+ let result = item.result;
1755
+ if (typeof result === 'string') {
1756
+ result = this.replacePlaceholders(result, moduleName, moduleConfig);
1757
+ }
1758
+ this.collectedConfig[moduleName][key] = result;
1759
+ }
1760
+ }
1761
+ }
1762
+ }
1763
+ }
1764
+
1765
+ await this.displayModulePostConfigNotes(moduleName, moduleConfig);
1766
+ }
1767
+
1768
+ /**
1769
+ * Replace placeholders in a string with collected config values
1770
+ * @param {string} str - String with placeholders
1771
+ * @param {string} currentModule - Current module name (to look up defaults in same module)
1772
+ * @param {Object} moduleConfig - Current module's config schema (to look up defaults)
1773
+ * @returns {string} String with placeholders replaced
1774
+ */
1775
+ replacePlaceholders(str, currentModule = null, moduleConfig = null) {
1776
+ if (typeof str !== 'string') {
1777
+ return str;
1778
+ }
1779
+
1780
+ return str.replaceAll(/{([^}]+)}/g, (match, configKey) => {
1781
+ // Preserve special placeholders
1782
+ if (configKey === 'project-root' || configKey === 'value' || configKey === 'directory_name') {
1783
+ return match;
1784
+ }
1785
+
1786
+ const configValue = this.resolveConfigValue(configKey, currentModule, moduleConfig);
1787
+
1788
+ return configValue || match;
1789
+ });
1790
+ }
1791
+
1792
+ /**
1793
+ * Clean a stored path-like value for prompt display/input reuse.
1794
+ * @param {*} value - Stored value
1795
+ * @returns {*} Cleaned value
1796
+ */
1797
+ cleanPromptValue(value) {
1798
+ if (typeof value === 'string' && value.startsWith('{project-root}/')) {
1799
+ return value.replace('{project-root}/', '');
1800
+ }
1801
+
1802
+ return value;
1803
+ }
1804
+
1805
+ /**
1806
+ * Resolve a config key from answers, collected config, existing config, or schema defaults.
1807
+ * @param {string} configKey - Config key to resolve
1808
+ * @param {string} currentModule - Current module name
1809
+ * @param {Object} moduleConfig - Current module config schema
1810
+ * @returns {*} Resolved value
1811
+ */
1812
+ resolveConfigValue(configKey, currentModule = null, moduleConfig = null) {
1813
+ // Look for the config value in allAnswers (already answered questions)
1814
+ let configValue = this.allAnswers?.[configKey] || this.allAnswers?.[`core_${configKey}`];
1815
+
1816
+ if (!configValue && this.allAnswers) {
1817
+ for (const [answerKey, answerValue] of Object.entries(this.allAnswers)) {
1818
+ if (answerKey.endsWith(`_${configKey}`)) {
1819
+ configValue = answerValue;
1820
+ break;
1821
+ }
1822
+ }
1823
+ }
1824
+
1825
+ // Prefer the current module's persisted value when re-prompting an existing install
1826
+ if (!configValue && currentModule && this._existingConfig?.[currentModule]?.[configKey] !== undefined) {
1827
+ configValue = this._existingConfig[currentModule][configKey];
1828
+ }
1829
+
1830
+ // Check in already collected config
1831
+ if (!configValue) {
1832
+ for (const mod of Object.keys(this.collectedConfig)) {
1833
+ if (mod !== '_meta' && this.collectedConfig[mod] && this.collectedConfig[mod][configKey]) {
1834
+ configValue = this.collectedConfig[mod][configKey];
1835
+ break;
1836
+ }
1837
+ }
1838
+ }
1839
+
1840
+ // Fall back to other existing module config values
1841
+ if (!configValue && this._existingConfig) {
1842
+ for (const mod of Object.keys(this._existingConfig)) {
1843
+ if (mod !== '_meta' && this._existingConfig[mod] && this._existingConfig[mod][configKey]) {
1844
+ configValue = this._existingConfig[mod][configKey];
1845
+ break;
1846
+ }
1847
+ }
1848
+ }
1849
+
1850
+ // If still not found and we're in the same module, use the default from the config schema
1851
+ if (!configValue && currentModule && moduleConfig && moduleConfig[configKey]) {
1852
+ const referencedItem = moduleConfig[configKey];
1853
+ if (referencedItem && referencedItem.default !== undefined) {
1854
+ configValue = referencedItem.default;
1855
+ }
1856
+ }
1857
+
1858
+ return this.cleanPromptValue(configValue);
1859
+ }
1860
+
1861
+ /**
1862
+ * Convert an existing stored value back into the prompt-facing value for templated fields.
1863
+ * For example, "{test_artifacts}/{value}" + "_drt-output/test-artifacts/test-design"
1864
+ * becomes "test-design" so the template is not applied twice on modify.
1865
+ * @param {*} existingValue - Stored config value
1866
+ * @param {string} moduleName - Module name
1867
+ * @param {Object} item - Config item definition
1868
+ * @param {Object} moduleConfig - Current module config schema
1869
+ * @returns {*} Prompt-facing default value
1870
+ */
1871
+ normalizeExistingValueForPrompt(existingValue, moduleName, item, moduleConfig = null) {
1872
+ const cleanedValue = this.cleanPromptValue(existingValue);
1873
+
1874
+ if (typeof cleanedValue !== 'string' || typeof item?.result !== 'string' || !item.result.includes('{value}')) {
1875
+ return cleanedValue;
1876
+ }
1877
+
1878
+ const [prefixTemplate = '', suffixTemplate = ''] = item.result.split('{value}');
1879
+ const prefix = this.cleanPromptValue(this.replacePlaceholders(prefixTemplate, moduleName, moduleConfig));
1880
+ const suffix = this.cleanPromptValue(this.replacePlaceholders(suffixTemplate, moduleName, moduleConfig));
1881
+
1882
+ if ((prefix && !cleanedValue.startsWith(prefix)) || (suffix && !cleanedValue.endsWith(suffix))) {
1883
+ return cleanedValue;
1884
+ }
1885
+
1886
+ const startIndex = prefix.length;
1887
+ const endIndex = suffix ? cleanedValue.length - suffix.length : cleanedValue.length;
1888
+ if (endIndex < startIndex) {
1889
+ return cleanedValue;
1890
+ }
1891
+
1892
+ let promptValue = cleanedValue.slice(startIndex, endIndex);
1893
+ if (promptValue.startsWith('/')) {
1894
+ promptValue = promptValue.slice(1);
1895
+ }
1896
+ if (promptValue.endsWith('/')) {
1897
+ promptValue = promptValue.slice(0, -1);
1898
+ }
1899
+
1900
+ return promptValue || cleanedValue;
1901
+ }
1902
+
1903
+ /**
1904
+ * Build a prompt question from a config item
1905
+ * @param {string} moduleName - Module name
1906
+ * @param {string} key - Config key
1907
+ * @param {Object} item - Config item definition
1908
+ * @param {Object} moduleConfig - Full module config schema (for resolving defaults)
1909
+ */
1910
+ async buildQuestion(moduleName, key, item, moduleConfig = null) {
1911
+ const questionName = `${moduleName}_${key}`;
1912
+
1913
+ // Check for existing value
1914
+ let existingValue = null;
1915
+ if (this._existingConfig && this._existingConfig[moduleName]) {
1916
+ existingValue = this._existingConfig[moduleName][key];
1917
+ existingValue = this.normalizeExistingValueForPrompt(existingValue, moduleName, item, moduleConfig);
1918
+ }
1919
+
1920
+ // Special handling for user_name: default to system user
1921
+ if (moduleName === 'core' && key === 'user_name' && !existingValue) {
1922
+ item.default = this.getDefaultUsername();
1923
+ }
1924
+
1925
+ // Determine question type and default value
1926
+ let questionType = 'input';
1927
+ let defaultValue = item.default;
1928
+ let choices = null;
1929
+
1930
+ // Check if default contains references to other fields in the same module
1931
+ const hasSameModuleReference = typeof defaultValue === 'string' && defaultValue.match(/{([^}]+)}/);
1932
+ let dynamicDefault = false;
1933
+
1934
+ // Replace placeholders in default value with collected config values
1935
+ if (typeof defaultValue === 'string') {
1936
+ if (defaultValue.includes('{directory_name}') && this.currentProjectDir) {
1937
+ const dirName = path.basename(this.currentProjectDir);
1938
+ defaultValue = defaultValue.replaceAll('{directory_name}', dirName);
1939
+ }
1940
+
1941
+ // Check if this references another field in the same module (for dynamic defaults)
1942
+ if (hasSameModuleReference && moduleConfig) {
1943
+ const matches = defaultValue.match(/{([^}]+)}/g);
1944
+ if (matches) {
1945
+ for (const match of matches) {
1946
+ const fieldName = match.slice(1, -1); // Remove { }
1947
+ // Check if this field exists in the same module config
1948
+ if (moduleConfig[fieldName]) {
1949
+ dynamicDefault = true;
1950
+ break;
1951
+ }
1952
+ }
1953
+ }
1954
+ }
1955
+
1956
+ // If not dynamic, replace placeholders now
1957
+ if (!dynamicDefault) {
1958
+ defaultValue = this.replacePlaceholders(defaultValue, moduleName, moduleConfig);
1959
+ }
1960
+
1961
+ // Strip {project-root}/ from defaults since it will be added back by result template
1962
+ // This makes the display cleaner and user input simpler
1963
+ if (defaultValue.includes('{project-root}/')) {
1964
+ defaultValue = defaultValue.replace('{project-root}/', '');
1965
+ }
1966
+ }
1967
+
1968
+ // Handle different question types
1969
+ if (item['single-select']) {
1970
+ questionType = 'list';
1971
+ choices = item['single-select'].map((choice) => {
1972
+ // If choice is an object with label and value
1973
+ if (typeof choice === 'object' && choice.label && choice.value !== undefined) {
1974
+ return {
1975
+ name: choice.label,
1976
+ value: choice.value,
1977
+ };
1978
+ }
1979
+ // Otherwise it's a simple string choice
1980
+ return {
1981
+ name: choice,
1982
+ value: choice,
1983
+ };
1984
+ });
1985
+ if (existingValue) {
1986
+ defaultValue = existingValue;
1987
+ }
1988
+ } else if (item['multi-select']) {
1989
+ questionType = 'checkbox';
1990
+ choices = item['multi-select'].map((choice) => {
1991
+ // If choice is an object with label and value
1992
+ if (typeof choice === 'object' && choice.label && choice.value !== undefined) {
1993
+ return {
1994
+ name: choice.label,
1995
+ value: choice.value,
1996
+ checked: existingValue
1997
+ ? existingValue.includes(choice.value)
1998
+ : item.default && Array.isArray(item.default)
1999
+ ? item.default.includes(choice.value)
2000
+ : false,
2001
+ };
2002
+ }
2003
+ // Otherwise it's a simple string choice
2004
+ return {
2005
+ name: choice,
2006
+ value: choice,
2007
+ checked: existingValue
2008
+ ? existingValue.includes(choice)
2009
+ : item.default && Array.isArray(item.default)
2010
+ ? item.default.includes(choice)
2011
+ : false,
2012
+ };
2013
+ });
2014
+ } else if (typeof defaultValue === 'boolean') {
2015
+ questionType = 'confirm';
2016
+ }
2017
+
2018
+ // Build the prompt message
2019
+ let message = '';
2020
+
2021
+ // Handle array prompts for multi-line messages
2022
+ if (Array.isArray(item.prompt)) {
2023
+ message = item.prompt.join('\n');
2024
+ } else {
2025
+ message = item.prompt;
2026
+ }
2027
+
2028
+ // Replace placeholders in prompt message with collected config values
2029
+ if (typeof message === 'string') {
2030
+ message = this.replacePlaceholders(message, moduleName, moduleConfig);
2031
+ }
2032
+
2033
+ // Add current value indicator for existing configs
2034
+ const color = await prompts.getColor();
2035
+ if (existingValue !== null && existingValue !== undefined) {
2036
+ if (typeof existingValue === 'boolean') {
2037
+ message += color.dim(` (current: ${existingValue ? 'true' : 'false'})`);
2038
+ } else if (Array.isArray(existingValue)) {
2039
+ message += color.dim(` (current: ${existingValue.join(', ')})`);
2040
+ } else if (questionType !== 'list') {
2041
+ // Show the cleaned value (without {project-root}/) for display
2042
+ message += color.dim(` (current: ${existingValue})`);
2043
+ }
2044
+ } else if (item.example && questionType === 'input') {
2045
+ // Show example for input fields
2046
+ let exampleText = typeof item.example === 'string' ? item.example : JSON.stringify(item.example);
2047
+ // Replace placeholders in example
2048
+ if (typeof exampleText === 'string') {
2049
+ exampleText = this.replacePlaceholders(exampleText, moduleName, moduleConfig);
2050
+ exampleText = exampleText.replace('{project-root}/', '');
2051
+ }
2052
+ message += color.dim(` (e.g., ${exampleText})`);
2053
+ }
2054
+
2055
+ // Build the question object
2056
+ const question = {
2057
+ type: questionType,
2058
+ name: questionName,
2059
+ message: message,
2060
+ };
2061
+
2062
+ // Set default - if it's dynamic, use a function that the prompt will evaluate with current answers
2063
+ // But if we have an existing value, always use that instead
2064
+ if (existingValue !== null && existingValue !== undefined && questionType !== 'list') {
2065
+ question.default = existingValue;
2066
+ } else if (dynamicDefault && typeof item.default === 'string') {
2067
+ const originalDefault = item.default;
2068
+ question.default = (answers) => {
2069
+ // Replace placeholders using answers from previous questions in the same batch
2070
+ let resolved = originalDefault;
2071
+ resolved = resolved.replaceAll(/{([^}]+)}/g, (match, fieldName) => {
2072
+ // Look for the answer in the current batch (prefixed with module name)
2073
+ const answerKey = `${moduleName}_${fieldName}`;
2074
+ if (answers[answerKey] !== undefined) {
2075
+ return answers[answerKey];
2076
+ }
2077
+ // Fall back to collected config
2078
+ return this.collectedConfig[moduleName]?.[fieldName] || match;
2079
+ });
2080
+ // Strip {project-root}/ for cleaner display
2081
+ if (resolved.includes('{project-root}/')) {
2082
+ resolved = resolved.replace('{project-root}/', '');
2083
+ }
2084
+ return resolved;
2085
+ };
2086
+ } else {
2087
+ question.default = defaultValue;
2088
+ }
2089
+
2090
+ // Add choices for select types
2091
+ if (choices) {
2092
+ question.choices = choices;
2093
+ }
2094
+
2095
+ // Add validation for input fields
2096
+ if (questionType === 'input') {
2097
+ question.validate = (input) => {
2098
+ if (!input && item.required) {
2099
+ return 'This field is required';
2100
+ }
2101
+ // Validate against regex pattern if provided
2102
+ if (input && item.regex) {
2103
+ const regex = new RegExp(item.regex);
2104
+ if (!regex.test(input)) {
2105
+ return `Invalid format. Must match pattern: ${item.regex}`;
2106
+ }
2107
+ }
2108
+ return true;
2109
+ };
2110
+ }
2111
+
2112
+ // Add validation for checkbox (multi-select) fields
2113
+ if (questionType === 'checkbox' && item.required) {
2114
+ question.validate = (answers) => {
2115
+ if (!answers || answers.length === 0) {
2116
+ return 'At least one option must be selected';
2117
+ }
2118
+ return true;
2119
+ };
2120
+ }
2121
+
2122
+ return question;
2123
+ }
2124
+
2125
+ /**
2126
+ * Display post-configuration notes for a module
2127
+ * Shows prerequisite guidance based on collected config values
2128
+ * Reads notes from the module's `post-install-notes` section in module.yaml
2129
+ * Supports two formats:
2130
+ * - Simple string: always displayed
2131
+ * - Object keyed by config field name, with value-specific messages
2132
+ * @param {string} moduleName - Module name
2133
+ * @param {Object} moduleConfig - Parsed module.yaml content
2134
+ */
2135
+ async displayModulePostConfigNotes(moduleName, moduleConfig) {
2136
+ if (this._silentConfig) return;
2137
+ if (!moduleConfig || !moduleConfig['post-install-notes']) return;
2138
+
2139
+ const notes = moduleConfig['post-install-notes'];
2140
+ const color = await prompts.getColor();
2141
+
2142
+ // Format 1: Simple string - always display
2143
+ if (typeof notes === 'string') {
2144
+ await prompts.log.message('');
2145
+ for (const line of notes.trim().split('\n')) {
2146
+ await prompts.log.message(color.dim(line));
2147
+ }
2148
+ return;
2149
+ }
2150
+
2151
+ // Format 2: Conditional on config values
2152
+ if (typeof notes === 'object') {
2153
+ const config = this.collectedConfig[moduleName];
2154
+ if (!config) return;
2155
+
2156
+ let hasOutput = false;
2157
+ for (const [configKey, valueMessages] of Object.entries(notes)) {
2158
+ const selectedValue = config[configKey];
2159
+ if (!selectedValue || !valueMessages[selectedValue]) continue;
2160
+
2161
+ if (hasOutput) await prompts.log.message('');
2162
+ hasOutput = true;
2163
+
2164
+ const message = valueMessages[selectedValue];
2165
+ for (const line of message.trim().split('\n')) {
2166
+ const trimmedLine = line.trim();
2167
+ if (trimmedLine.endsWith(':') && !trimmedLine.startsWith(' ')) {
2168
+ await prompts.log.info(color.bold(trimmedLine));
2169
+ } else {
2170
+ await prompts.log.message(color.dim(' ' + trimmedLine));
2171
+ }
2172
+ }
2173
+ }
2174
+ }
2175
+ }
2176
+
2177
+ /**
2178
+ * Deep merge two objects
2179
+ * @param {Object} target - Target object
2180
+ * @param {Object} source - Source object
2181
+ */
2182
+ deepMerge(target, source) {
2183
+ const result = { ...target };
2184
+
2185
+ for (const key in source) {
2186
+ if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
2187
+ if (result[key] && typeof result[key] === 'object' && !Array.isArray(result[key])) {
2188
+ result[key] = this.deepMerge(result[key], source[key]);
2189
+ } else {
2190
+ result[key] = source[key];
2191
+ }
2192
+ } else {
2193
+ result[key] = source[key];
2194
+ }
2195
+ }
2196
+
2197
+ return result;
2198
+ }
2199
+ }
2200
+
2201
+ /**
2202
+ * Parse a config.toml or config.user.toml written by writeCentralConfig.
2203
+ * Only handles the subset of TOML the installer produces: [core],
2204
+ * [modules.<code>], string/bool/number scalar values. [agents.*] and other
2205
+ * sections are ignored. Returns a plain object keyed by section name where
2206
+ * module sections use the bare code (e.g. "drt"), not the full "modules.drt".
2207
+ */
2208
+ function parseCentralToml(content) {
2209
+ const result = {};
2210
+ let currentSection = null;
2211
+
2212
+ for (const rawLine of content.split('\n')) {
2213
+ const line = rawLine.trim();
2214
+ if (!line || line.startsWith('#')) continue;
2215
+
2216
+ const sectionMatch = line.match(/^\[([^\]]+)\]\s*$/);
2217
+ if (sectionMatch) {
2218
+ const name = sectionMatch[1];
2219
+ if (name === 'core') {
2220
+ currentSection = 'core';
2221
+ } else if (name.startsWith('modules.')) {
2222
+ currentSection = name.slice('modules.'.length);
2223
+ } else {
2224
+ currentSection = null;
2225
+ }
2226
+ if (currentSection && !result[currentSection]) {
2227
+ result[currentSection] = {};
2228
+ }
2229
+ continue;
2230
+ }
2231
+
2232
+ if (!currentSection) continue;
2233
+
2234
+ const kvMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$/);
2235
+ if (!kvMatch) continue;
2236
+
2237
+ const key = kvMatch[1];
2238
+ const raw = kvMatch[2].trim();
2239
+ let value;
2240
+ if (raw.startsWith('"') && raw.endsWith('"')) {
2241
+ value = raw.slice(1, -1).replaceAll(/\\(["\\nrbt])/g, (_, c) => ({ '"': '"', '\\': '\\', n: '\n', r: '\r', b: '\b', t: '\t' })[c]);
2242
+ } else if (raw === 'true') {
2243
+ value = true;
2244
+ } else if (raw === 'false') {
2245
+ value = false;
2246
+ } else if (raw !== '' && !isNaN(raw)) {
2247
+ value = Number(raw);
2248
+ } else {
2249
+ value = raw;
2250
+ }
2251
+ result[currentSection][key] = value;
2252
+ }
2253
+
2254
+ return result;
2255
+ }
2256
+
2257
+ module.exports = { OfficialModules };