@dedesfr/prompter 0.6.15 → 0.7.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 (375) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/cli/index.js +144 -12
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/archive.d.ts +11 -0
  5. package/dist/commands/archive.d.ts.map +1 -0
  6. package/dist/commands/archive.js +280 -0
  7. package/dist/commands/archive.js.map +1 -0
  8. package/dist/commands/change.d.ts +35 -0
  9. package/dist/commands/change.d.ts.map +1 -0
  10. package/dist/commands/change.js +277 -0
  11. package/dist/commands/change.js.map +1 -0
  12. package/dist/commands/config.d.ts +8 -0
  13. package/dist/commands/config.d.ts.map +1 -0
  14. package/dist/commands/config.js +198 -0
  15. package/dist/commands/config.js.map +1 -0
  16. package/dist/commands/list.d.ts +2 -2
  17. package/dist/commands/list.d.ts.map +1 -1
  18. package/dist/commands/list.js +153 -47
  19. package/dist/commands/list.js.map +1 -1
  20. package/dist/commands/show.d.ts +14 -0
  21. package/dist/commands/show.d.ts.map +1 -0
  22. package/dist/commands/show.js +132 -0
  23. package/dist/commands/show.js.map +1 -0
  24. package/dist/commands/spec.d.ts +15 -0
  25. package/dist/commands/spec.d.ts.map +1 -0
  26. package/dist/commands/spec.js +225 -0
  27. package/dist/commands/spec.js.map +1 -0
  28. package/dist/commands/validate.d.ts +24 -0
  29. package/dist/commands/validate.d.ts.map +1 -0
  30. package/dist/commands/validate.js +294 -0
  31. package/dist/commands/validate.js.map +1 -0
  32. package/dist/core/artifact-graph/graph.d.ts +56 -0
  33. package/dist/core/artifact-graph/graph.d.ts.map +1 -0
  34. package/dist/core/artifact-graph/graph.js +141 -0
  35. package/dist/core/artifact-graph/graph.js.map +1 -0
  36. package/dist/core/artifact-graph/index.d.ts +7 -0
  37. package/dist/core/artifact-graph/index.d.ts.map +1 -0
  38. package/dist/core/artifact-graph/index.js +13 -0
  39. package/dist/core/artifact-graph/index.js.map +1 -0
  40. package/dist/core/artifact-graph/instruction-loader.d.ts +130 -0
  41. package/dist/core/artifact-graph/instruction-loader.d.ts.map +1 -0
  42. package/dist/core/artifact-graph/instruction-loader.js +173 -0
  43. package/dist/core/artifact-graph/instruction-loader.js.map +1 -0
  44. package/dist/core/artifact-graph/resolver.d.ts +61 -0
  45. package/dist/core/artifact-graph/resolver.d.ts.map +1 -0
  46. package/dist/core/artifact-graph/resolver.js +187 -0
  47. package/dist/core/artifact-graph/resolver.js.map +1 -0
  48. package/dist/core/artifact-graph/schema.d.ts +13 -0
  49. package/dist/core/artifact-graph/schema.d.ts.map +1 -0
  50. package/dist/core/artifact-graph/schema.js +108 -0
  51. package/dist/core/artifact-graph/schema.js.map +1 -0
  52. package/dist/core/artifact-graph/state.d.ts +12 -0
  53. package/dist/core/artifact-graph/state.d.ts.map +1 -0
  54. package/dist/core/artifact-graph/state.js +54 -0
  55. package/dist/core/artifact-graph/state.js.map +1 -0
  56. package/dist/core/artifact-graph/types.d.ts +45 -0
  57. package/dist/core/artifact-graph/types.d.ts.map +1 -0
  58. package/dist/core/artifact-graph/types.js +43 -0
  59. package/dist/core/artifact-graph/types.js.map +1 -0
  60. package/dist/core/completions/command-registry.d.ts +7 -0
  61. package/dist/core/completions/command-registry.d.ts.map +1 -0
  62. package/dist/core/completions/command-registry.js +380 -0
  63. package/dist/core/completions/command-registry.js.map +1 -0
  64. package/dist/core/completions/completion-provider.d.ts +60 -0
  65. package/dist/core/completions/completion-provider.d.ts.map +1 -0
  66. package/dist/core/completions/completion-provider.js +102 -0
  67. package/dist/core/completions/completion-provider.js.map +1 -0
  68. package/dist/core/completions/generators/bash-generator.d.ts +32 -0
  69. package/dist/core/completions/generators/bash-generator.d.ts.map +1 -0
  70. package/dist/core/completions/generators/bash-generator.js +174 -0
  71. package/dist/core/completions/generators/bash-generator.js.map +1 -0
  72. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  73. package/dist/core/completions/generators/fish-generator.d.ts.map +1 -0
  74. package/dist/core/completions/generators/fish-generator.js +157 -0
  75. package/dist/core/completions/generators/fish-generator.js.map +1 -0
  76. package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
  77. package/dist/core/completions/generators/powershell-generator.d.ts.map +1 -0
  78. package/dist/core/completions/generators/powershell-generator.js +207 -0
  79. package/dist/core/completions/generators/powershell-generator.js.map +1 -0
  80. package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
  81. package/dist/core/completions/generators/zsh-generator.d.ts.map +1 -0
  82. package/dist/core/completions/generators/zsh-generator.js +250 -0
  83. package/dist/core/completions/generators/zsh-generator.js.map +1 -0
  84. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  85. package/dist/core/completions/templates/bash-templates.d.ts.map +1 -0
  86. package/dist/core/completions/templates/bash-templates.js +24 -0
  87. package/dist/core/completions/templates/bash-templates.js.map +1 -0
  88. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  89. package/dist/core/completions/templates/fish-templates.d.ts.map +1 -0
  90. package/dist/core/completions/templates/fish-templates.js +39 -0
  91. package/dist/core/completions/templates/fish-templates.js.map +1 -0
  92. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  93. package/dist/core/completions/templates/powershell-templates.d.ts.map +1 -0
  94. package/dist/core/completions/templates/powershell-templates.js +25 -0
  95. package/dist/core/completions/templates/powershell-templates.js.map +1 -0
  96. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  97. package/dist/core/completions/templates/zsh-templates.d.ts.map +1 -0
  98. package/dist/core/completions/templates/zsh-templates.js +36 -0
  99. package/dist/core/completions/templates/zsh-templates.js.map +1 -0
  100. package/dist/core/completions/types.d.ts +78 -0
  101. package/dist/core/completions/types.d.ts.map +1 -0
  102. package/dist/core/completions/types.js +2 -0
  103. package/dist/core/completions/types.js.map +1 -0
  104. package/dist/core/config-schema.d.ts +76 -0
  105. package/dist/core/config-schema.d.ts.map +1 -0
  106. package/dist/core/config-schema.js +200 -0
  107. package/dist/core/config-schema.js.map +1 -0
  108. package/dist/core/config.d.ts.map +1 -1
  109. package/dist/core/config.js +18 -0
  110. package/dist/core/config.js.map +1 -1
  111. package/dist/core/configurators/slash/antigravity.d.ts.map +1 -1
  112. package/dist/core/configurators/slash/antigravity.js +6 -0
  113. package/dist/core/configurators/slash/antigravity.js.map +1 -1
  114. package/dist/core/configurators/slash/base.js +1 -1
  115. package/dist/core/configurators/slash/base.js.map +1 -1
  116. package/dist/core/configurators/slash/claude.d.ts.map +1 -1
  117. package/dist/core/configurators/slash/claude.js +6 -0
  118. package/dist/core/configurators/slash/claude.js.map +1 -1
  119. package/dist/core/configurators/slash/codex.d.ts.map +1 -1
  120. package/dist/core/configurators/slash/codex.js +6 -0
  121. package/dist/core/configurators/slash/codex.js.map +1 -1
  122. package/dist/core/configurators/slash/github-copilot.d.ts.map +1 -1
  123. package/dist/core/configurators/slash/github-copilot.js +6 -0
  124. package/dist/core/configurators/slash/github-copilot.js.map +1 -1
  125. package/dist/core/configurators/slash/kilocode.d.ts.map +1 -1
  126. package/dist/core/configurators/slash/kilocode.js +6 -0
  127. package/dist/core/configurators/slash/kilocode.js.map +1 -1
  128. package/dist/core/configurators/slash/opencode.d.ts.map +1 -1
  129. package/dist/core/configurators/slash/opencode.js +6 -0
  130. package/dist/core/configurators/slash/opencode.js.map +1 -1
  131. package/dist/core/converters/json-converter.d.ts +6 -0
  132. package/dist/core/converters/json-converter.d.ts.map +1 -0
  133. package/dist/core/converters/json-converter.js +51 -0
  134. package/dist/core/converters/json-converter.js.map +1 -0
  135. package/dist/core/global-config.d.ts +39 -0
  136. package/dist/core/global-config.d.ts.map +1 -0
  137. package/dist/core/global-config.js +115 -0
  138. package/dist/core/global-config.js.map +1 -0
  139. package/dist/core/parsers/change-parser.d.ts +13 -0
  140. package/dist/core/parsers/change-parser.d.ts.map +1 -0
  141. package/dist/core/parsers/change-parser.js +193 -0
  142. package/dist/core/parsers/change-parser.js.map +1 -0
  143. package/dist/core/parsers/markdown-parser.d.ts +22 -0
  144. package/dist/core/parsers/markdown-parser.d.ts.map +1 -0
  145. package/dist/core/parsers/markdown-parser.js +187 -0
  146. package/dist/core/parsers/markdown-parser.js.map +1 -0
  147. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  148. package/dist/core/parsers/requirement-blocks.d.ts.map +1 -0
  149. package/dist/core/parsers/requirement-blocks.js +201 -0
  150. package/dist/core/parsers/requirement-blocks.js.map +1 -0
  151. package/dist/core/prompt-templates.d.ts +3 -0
  152. package/dist/core/prompt-templates.d.ts.map +1 -1
  153. package/dist/core/prompt-templates.js +66 -0
  154. package/dist/core/prompt-templates.js.map +1 -1
  155. package/dist/core/schemas/base.schema.d.ts +13 -0
  156. package/dist/core/schemas/base.schema.d.ts.map +1 -0
  157. package/dist/core/schemas/base.schema.js +13 -0
  158. package/dist/core/schemas/base.schema.js.map +1 -0
  159. package/dist/core/schemas/change.schema.d.ts +73 -0
  160. package/dist/core/schemas/change.schema.d.ts.map +1 -0
  161. package/dist/core/schemas/change.schema.js +31 -0
  162. package/dist/core/schemas/change.schema.js.map +1 -0
  163. package/dist/core/schemas/index.d.ts +4 -0
  164. package/dist/core/schemas/index.d.ts.map +1 -0
  165. package/dist/core/schemas/index.js +4 -0
  166. package/dist/core/schemas/index.js.map +1 -0
  167. package/dist/core/schemas/spec.schema.d.ts +18 -0
  168. package/dist/core/schemas/spec.schema.d.ts.map +1 -0
  169. package/dist/core/schemas/spec.schema.js +15 -0
  170. package/dist/core/schemas/spec.schema.js.map +1 -0
  171. package/dist/core/specs-apply.d.ts +73 -0
  172. package/dist/core/specs-apply.d.ts.map +1 -0
  173. package/dist/core/specs-apply.js +384 -0
  174. package/dist/core/specs-apply.js.map +1 -0
  175. package/dist/core/styles/palette.d.ts +7 -0
  176. package/dist/core/styles/palette.d.ts.map +1 -0
  177. package/dist/core/styles/palette.js +8 -0
  178. package/dist/core/styles/palette.js.map +1 -0
  179. package/dist/core/templates/slash-command-templates.d.ts +1 -1
  180. package/dist/core/templates/slash-command-templates.d.ts.map +1 -1
  181. package/dist/core/templates/slash-command-templates.js +4 -1
  182. package/dist/core/templates/slash-command-templates.js.map +1 -1
  183. package/dist/core/validation/constants.d.ts +34 -0
  184. package/dist/core/validation/constants.d.ts.map +1 -0
  185. package/dist/core/validation/constants.js +40 -0
  186. package/dist/core/validation/constants.js.map +1 -0
  187. package/dist/core/validation/types.d.ts +18 -0
  188. package/dist/core/validation/types.d.ts.map +1 -0
  189. package/dist/core/validation/types.js +2 -0
  190. package/dist/core/validation/types.js.map +1 -0
  191. package/dist/core/validation/validator.d.ts +33 -0
  192. package/dist/core/validation/validator.d.ts.map +1 -0
  193. package/dist/core/validation/validator.js +409 -0
  194. package/dist/core/validation/validator.js.map +1 -0
  195. package/dist/core/view.d.ts +8 -0
  196. package/dist/core/view.d.ts.map +1 -0
  197. package/dist/core/view.js +168 -0
  198. package/dist/core/view.js.map +1 -0
  199. package/dist/utils/change-metadata.d.ts +47 -0
  200. package/dist/utils/change-metadata.d.ts.map +1 -0
  201. package/dist/utils/change-metadata.js +130 -0
  202. package/dist/utils/change-metadata.js.map +1 -0
  203. package/dist/utils/change-utils.d.ts +51 -0
  204. package/dist/utils/change-utils.d.ts.map +1 -0
  205. package/dist/utils/change-utils.js +100 -0
  206. package/dist/utils/change-utils.js.map +1 -0
  207. package/dist/utils/file-system.d.ts +25 -0
  208. package/dist/utils/file-system.d.ts.map +1 -0
  209. package/dist/utils/file-system.js +218 -0
  210. package/dist/utils/file-system.js.map +1 -0
  211. package/dist/utils/index.d.ts +4 -0
  212. package/dist/utils/index.d.ts.map +1 -0
  213. package/dist/utils/index.js +5 -0
  214. package/dist/utils/index.js.map +1 -0
  215. package/dist/utils/interactive.d.ts +18 -0
  216. package/dist/utils/interactive.d.ts.map +1 -0
  217. package/dist/utils/interactive.js +21 -0
  218. package/dist/utils/interactive.js.map +1 -0
  219. package/dist/utils/item-discovery.d.ts +4 -0
  220. package/dist/utils/item-discovery.d.ts.map +1 -0
  221. package/dist/utils/item-discovery.js +72 -0
  222. package/dist/utils/item-discovery.js.map +1 -0
  223. package/dist/utils/match.d.ts +3 -0
  224. package/dist/utils/match.d.ts.map +1 -0
  225. package/dist/utils/match.js +22 -0
  226. package/dist/utils/match.js.map +1 -0
  227. package/dist/utils/shell-detection.d.ts +20 -0
  228. package/dist/utils/shell-detection.d.ts.map +1 -0
  229. package/dist/utils/shell-detection.js +41 -0
  230. package/dist/utils/shell-detection.js.map +1 -0
  231. package/dist/utils/task-progress.d.ts +8 -0
  232. package/dist/utils/task-progress.d.ts.map +1 -0
  233. package/dist/utils/task-progress.js +36 -0
  234. package/dist/utils/task-progress.js.map +1 -0
  235. package/docs/tasks.md +1 -1
  236. package/package.json +6 -2
  237. package/prompt/apply.md +17 -0
  238. package/prompt/archive.md +21 -0
  239. package/prompt/proposal.md +22 -0
  240. package/src/cli/index.ts +151 -16
  241. package/src/commands/archive.ts +302 -0
  242. package/src/commands/change.ts +292 -0
  243. package/src/commands/config.ts +233 -0
  244. package/src/commands/list.ts +176 -66
  245. package/src/commands/show.ts +138 -0
  246. package/src/commands/spec.ts +251 -0
  247. package/src/commands/validate.ts +326 -0
  248. package/src/core/artifact-graph/graph.ts +167 -0
  249. package/src/core/artifact-graph/index.ts +44 -0
  250. package/src/core/artifact-graph/instruction-loader.ts +302 -0
  251. package/src/core/artifact-graph/resolver.ts +226 -0
  252. package/src/core/artifact-graph/schema.ts +124 -0
  253. package/src/core/artifact-graph/state.ts +64 -0
  254. package/src/core/artifact-graph/types.ts +65 -0
  255. package/src/core/completions/command-registry.ts +382 -0
  256. package/src/core/completions/completion-provider.ts +128 -0
  257. package/src/core/completions/generators/bash-generator.ts +191 -0
  258. package/src/core/completions/generators/fish-generator.ts +188 -0
  259. package/src/core/completions/generators/powershell-generator.ts +223 -0
  260. package/src/core/completions/generators/zsh-generator.ts +281 -0
  261. package/src/core/completions/templates/bash-templates.ts +24 -0
  262. package/src/core/completions/templates/fish-templates.ts +40 -0
  263. package/src/core/completions/templates/powershell-templates.ts +25 -0
  264. package/src/core/completions/templates/zsh-templates.ts +36 -0
  265. package/src/core/completions/types.ts +90 -0
  266. package/src/core/config-schema.ts +230 -0
  267. package/src/core/config.ts +18 -0
  268. package/src/core/configurators/slash/antigravity.ts +6 -0
  269. package/src/core/configurators/slash/base.ts +1 -1
  270. package/src/core/configurators/slash/claude.ts +6 -0
  271. package/src/core/configurators/slash/codex.ts +6 -0
  272. package/src/core/configurators/slash/github-copilot.ts +6 -0
  273. package/src/core/configurators/slash/kilocode.ts +6 -0
  274. package/src/core/configurators/slash/opencode.ts +6 -0
  275. package/src/core/converters/json-converter.ts +62 -0
  276. package/src/core/global-config.ts +136 -0
  277. package/src/core/parsers/change-parser.ts +234 -0
  278. package/src/core/parsers/markdown-parser.ts +237 -0
  279. package/src/core/parsers/requirement-blocks.ts +234 -0
  280. package/src/core/prompt-templates.ts +69 -0
  281. package/src/core/schemas/base.schema.ts +20 -0
  282. package/src/core/schemas/change.schema.ts +42 -0
  283. package/src/core/schemas/index.ts +20 -0
  284. package/src/core/schemas/spec.schema.ts +17 -0
  285. package/src/core/specs-apply.ts +483 -0
  286. package/src/core/styles/palette.ts +8 -0
  287. package/src/core/templates/slash-command-templates.ts +7 -1
  288. package/src/core/validation/constants.ts +48 -0
  289. package/src/core/validation/types.ts +19 -0
  290. package/src/core/validation/validator.ts +449 -0
  291. package/src/core/view.ts +219 -0
  292. package/src/utils/change-metadata.ts +171 -0
  293. package/src/utils/change-utils.ts +131 -0
  294. package/src/utils/file-system.ts +252 -0
  295. package/src/utils/index.ts +12 -0
  296. package/src/utils/interactive.ts +29 -0
  297. package/src/utils/item-discovery.ts +66 -0
  298. package/src/utils/match.ts +26 -0
  299. package/src/utils/shell-detection.ts +62 -0
  300. package/src/utils/task-progress.ts +43 -0
  301. package/dist/commands/ai-humanizer.d.ts +0 -11
  302. package/dist/commands/ai-humanizer.d.ts.map +0 -1
  303. package/dist/commands/ai-humanizer.js +0 -97
  304. package/dist/commands/ai-humanizer.js.map +0 -1
  305. package/dist/commands/api-contract-generator.d.ts +0 -11
  306. package/dist/commands/api-contract-generator.d.ts.map +0 -1
  307. package/dist/commands/api-contract-generator.js +0 -97
  308. package/dist/commands/api-contract-generator.js.map +0 -1
  309. package/dist/commands/design-system.d.ts +0 -11
  310. package/dist/commands/design-system.d.ts.map +0 -1
  311. package/dist/commands/design-system.js +0 -97
  312. package/dist/commands/design-system.js.map +0 -1
  313. package/dist/commands/document-explainer.d.ts +0 -11
  314. package/dist/commands/document-explainer.d.ts.map +0 -1
  315. package/dist/commands/document-explainer.js +0 -97
  316. package/dist/commands/document-explainer.js.map +0 -1
  317. package/dist/commands/epic-generator.d.ts +0 -11
  318. package/dist/commands/epic-generator.d.ts.map +0 -1
  319. package/dist/commands/epic-generator.js +0 -97
  320. package/dist/commands/epic-generator.js.map +0 -1
  321. package/dist/commands/erd-generator.d.ts +0 -11
  322. package/dist/commands/erd-generator.d.ts.map +0 -1
  323. package/dist/commands/erd-generator.js +0 -97
  324. package/dist/commands/erd-generator.js.map +0 -1
  325. package/dist/commands/fsd-generator.d.ts +0 -11
  326. package/dist/commands/fsd-generator.d.ts.map +0 -1
  327. package/dist/commands/fsd-generator.js +0 -97
  328. package/dist/commands/fsd-generator.js.map +0 -1
  329. package/dist/commands/prd-agent-generator.d.ts +0 -11
  330. package/dist/commands/prd-agent-generator.d.ts.map +0 -1
  331. package/dist/commands/prd-agent-generator.js +0 -95
  332. package/dist/commands/prd-agent-generator.js.map +0 -1
  333. package/dist/commands/prd-generator.d.ts +0 -11
  334. package/dist/commands/prd-generator.d.ts.map +0 -1
  335. package/dist/commands/prd-generator.js +0 -97
  336. package/dist/commands/prd-generator.js.map +0 -1
  337. package/dist/commands/product-brief.d.ts +0 -11
  338. package/dist/commands/product-brief.d.ts.map +0 -1
  339. package/dist/commands/product-brief.js +0 -97
  340. package/dist/commands/product-brief.js.map +0 -1
  341. package/dist/commands/skill-creator.d.ts +0 -11
  342. package/dist/commands/skill-creator.d.ts.map +0 -1
  343. package/dist/commands/skill-creator.js +0 -101
  344. package/dist/commands/skill-creator.js.map +0 -1
  345. package/dist/commands/story-generator.d.ts +0 -11
  346. package/dist/commands/story-generator.d.ts.map +0 -1
  347. package/dist/commands/story-generator.js +0 -97
  348. package/dist/commands/story-generator.js.map +0 -1
  349. package/dist/commands/tdd-generator.d.ts +0 -11
  350. package/dist/commands/tdd-generator.d.ts.map +0 -1
  351. package/dist/commands/tdd-generator.js +0 -97
  352. package/dist/commands/tdd-generator.js.map +0 -1
  353. package/dist/commands/tdd-lite-generator.d.ts +0 -11
  354. package/dist/commands/tdd-lite-generator.d.ts.map +0 -1
  355. package/dist/commands/tdd-lite-generator.js +0 -97
  356. package/dist/commands/tdd-lite-generator.js.map +0 -1
  357. package/dist/commands/wireframe-generator.d.ts +0 -11
  358. package/dist/commands/wireframe-generator.d.ts.map +0 -1
  359. package/dist/commands/wireframe-generator.js +0 -97
  360. package/dist/commands/wireframe-generator.js.map +0 -1
  361. package/src/commands/ai-humanizer.ts +0 -118
  362. package/src/commands/api-contract-generator.ts +0 -118
  363. package/src/commands/design-system.ts +0 -118
  364. package/src/commands/document-explainer.ts +0 -118
  365. package/src/commands/epic-generator.ts +0 -118
  366. package/src/commands/erd-generator.ts +0 -118
  367. package/src/commands/fsd-generator.ts +0 -118
  368. package/src/commands/prd-agent-generator.ts +0 -115
  369. package/src/commands/prd-generator.ts +0 -118
  370. package/src/commands/product-brief.ts +0 -118
  371. package/src/commands/skill-creator.ts +0 -123
  372. package/src/commands/story-generator.ts +0 -118
  373. package/src/commands/tdd-generator.ts +0 -118
  374. package/src/commands/tdd-lite-generator.ts +0 -118
  375. package/src/commands/wireframe-generator.ts +0 -118
@@ -0,0 +1,449 @@
1
+ import { z, ZodError } from 'zod';
2
+ import { readFileSync, promises as fs } from 'fs';
3
+ import path from 'path';
4
+ import { SpecSchema, ChangeSchema, Spec, Change } from '../schemas/index.js';
5
+ import { MarkdownParser } from '../parsers/markdown-parser.js';
6
+ import { ChangeParser } from '../parsers/change-parser.js';
7
+ import { ValidationReport, ValidationIssue, ValidationLevel } from './types.js';
8
+ import {
9
+ MIN_PURPOSE_LENGTH,
10
+ MAX_REQUIREMENT_TEXT_LENGTH,
11
+ VALIDATION_MESSAGES
12
+ } from './constants.js';
13
+ import { parseDeltaSpec, normalizeRequirementName } from '../parsers/requirement-blocks.js';
14
+ import { FileSystemUtils } from '../../utils/file-system.js';
15
+
16
+ export class Validator {
17
+ private strictMode: boolean;
18
+
19
+ constructor(strictMode: boolean = false) {
20
+ this.strictMode = strictMode;
21
+ }
22
+
23
+ async validateSpec(filePath: string): Promise<ValidationReport> {
24
+ const issues: ValidationIssue[] = [];
25
+ const specName = this.extractNameFromPath(filePath);
26
+ try {
27
+ const content = readFileSync(filePath, 'utf-8');
28
+ const parser = new MarkdownParser(content);
29
+
30
+ const spec = parser.parseSpec(specName);
31
+
32
+ const result = SpecSchema.safeParse(spec);
33
+
34
+ if (!result.success) {
35
+ issues.push(...this.convertZodErrors(result.error));
36
+ }
37
+
38
+ issues.push(...this.applySpecRules(spec, content));
39
+
40
+ } catch (error) {
41
+ const baseMessage = error instanceof Error ? error.message : 'Unknown error';
42
+ const enriched = this.enrichTopLevelError(specName, baseMessage);
43
+ issues.push({
44
+ level: 'ERROR',
45
+ path: 'file',
46
+ message: enriched,
47
+ });
48
+ }
49
+
50
+ return this.createReport(issues);
51
+ }
52
+
53
+ /**
54
+ * Validate spec content from a string (used for pre-write validation of rebuilt specs)
55
+ */
56
+ async validateSpecContent(specName: string, content: string): Promise<ValidationReport> {
57
+ const issues: ValidationIssue[] = [];
58
+ try {
59
+ const parser = new MarkdownParser(content);
60
+ const spec = parser.parseSpec(specName);
61
+ const result = SpecSchema.safeParse(spec);
62
+ if (!result.success) {
63
+ issues.push(...this.convertZodErrors(result.error));
64
+ }
65
+ issues.push(...this.applySpecRules(spec, content));
66
+ } catch (error) {
67
+ const baseMessage = error instanceof Error ? error.message : 'Unknown error';
68
+ const enriched = this.enrichTopLevelError(specName, baseMessage);
69
+ issues.push({ level: 'ERROR', path: 'file', message: enriched });
70
+ }
71
+ return this.createReport(issues);
72
+ }
73
+
74
+ async validateChange(filePath: string): Promise<ValidationReport> {
75
+ const issues: ValidationIssue[] = [];
76
+ const changeName = this.extractNameFromPath(filePath);
77
+ try {
78
+ const content = readFileSync(filePath, 'utf-8');
79
+ const changeDir = path.dirname(filePath);
80
+ const parser = new ChangeParser(content, changeDir);
81
+
82
+ const change = await parser.parseChangeWithDeltas(changeName);
83
+
84
+ const result = ChangeSchema.safeParse(change);
85
+
86
+ if (!result.success) {
87
+ issues.push(...this.convertZodErrors(result.error));
88
+ }
89
+
90
+ issues.push(...this.applyChangeRules(change, content));
91
+
92
+ } catch (error) {
93
+ const baseMessage = error instanceof Error ? error.message : 'Unknown error';
94
+ const enriched = this.enrichTopLevelError(changeName, baseMessage);
95
+ issues.push({
96
+ level: 'ERROR',
97
+ path: 'file',
98
+ message: enriched,
99
+ });
100
+ }
101
+
102
+ return this.createReport(issues);
103
+ }
104
+
105
+ /**
106
+ * Validate delta-formatted spec files under a change directory.
107
+ * Enforces:
108
+ * - At least one delta across all files
109
+ * - ADDED/MODIFIED: each requirement has SHALL/MUST and at least one scenario
110
+ * - REMOVED: names only; no scenario/description required
111
+ * - RENAMED: pairs well-formed
112
+ * - No duplicates within sections; no cross-section conflicts per spec
113
+ */
114
+ async validateChangeDeltaSpecs(changeDir: string): Promise<ValidationReport> {
115
+ const issues: ValidationIssue[] = [];
116
+ const specsDir = path.join(changeDir, 'specs');
117
+ let totalDeltas = 0;
118
+ const missingHeaderSpecs: string[] = [];
119
+ const emptySectionSpecs: Array<{ path: string; sections: string[] }> = [];
120
+
121
+ try {
122
+ const entries = await fs.readdir(specsDir, { withFileTypes: true });
123
+ for (const entry of entries) {
124
+ if (!entry.isDirectory()) continue;
125
+ const specName = entry.name;
126
+ const specFile = path.join(specsDir, specName, 'spec.md');
127
+ let content: string | undefined;
128
+ try {
129
+ content = await fs.readFile(specFile, 'utf-8');
130
+ } catch {
131
+ continue;
132
+ }
133
+
134
+ const plan = parseDeltaSpec(content);
135
+ const entryPath = `${specName}/spec.md`;
136
+ const sectionNames: string[] = [];
137
+ if (plan.sectionPresence.added) sectionNames.push('## ADDED Requirements');
138
+ if (plan.sectionPresence.modified) sectionNames.push('## MODIFIED Requirements');
139
+ if (plan.sectionPresence.removed) sectionNames.push('## REMOVED Requirements');
140
+ if (plan.sectionPresence.renamed) sectionNames.push('## RENAMED Requirements');
141
+ const hasSections = sectionNames.length > 0;
142
+ const hasEntries = plan.added.length + plan.modified.length + plan.removed.length + plan.renamed.length > 0;
143
+ if (!hasEntries) {
144
+ if (hasSections) emptySectionSpecs.push({ path: entryPath, sections: sectionNames });
145
+ else missingHeaderSpecs.push(entryPath);
146
+ }
147
+
148
+ const addedNames = new Set<string>();
149
+ const modifiedNames = new Set<string>();
150
+ const removedNames = new Set<string>();
151
+ const renamedFrom = new Set<string>();
152
+ const renamedTo = new Set<string>();
153
+
154
+ // Validate ADDED
155
+ for (const block of plan.added) {
156
+ const key = normalizeRequirementName(block.name);
157
+ totalDeltas++;
158
+ if (addedNames.has(key)) {
159
+ issues.push({ level: 'ERROR', path: entryPath, message: `Duplicate requirement in ADDED: "${block.name}"` });
160
+ } else {
161
+ addedNames.add(key);
162
+ }
163
+ const requirementText = this.extractRequirementText(block.raw);
164
+ if (!requirementText) {
165
+ issues.push({ level: 'ERROR', path: entryPath, message: `ADDED "${block.name}" is missing requirement text` });
166
+ } else if (!this.containsShallOrMust(requirementText)) {
167
+ issues.push({ level: 'ERROR', path: entryPath, message: `ADDED "${block.name}" must contain SHALL or MUST` });
168
+ }
169
+ const scenarioCount = this.countScenarios(block.raw);
170
+ if (scenarioCount < 1) {
171
+ issues.push({ level: 'ERROR', path: entryPath, message: `ADDED "${block.name}" must include at least one scenario` });
172
+ }
173
+ }
174
+
175
+ // Validate MODIFIED
176
+ for (const block of plan.modified) {
177
+ const key = normalizeRequirementName(block.name);
178
+ totalDeltas++;
179
+ if (modifiedNames.has(key)) {
180
+ issues.push({ level: 'ERROR', path: entryPath, message: `Duplicate requirement in MODIFIED: "${block.name}"` });
181
+ } else {
182
+ modifiedNames.add(key);
183
+ }
184
+ const requirementText = this.extractRequirementText(block.raw);
185
+ if (!requirementText) {
186
+ issues.push({ level: 'ERROR', path: entryPath, message: `MODIFIED "${block.name}" is missing requirement text` });
187
+ } else if (!this.containsShallOrMust(requirementText)) {
188
+ issues.push({ level: 'ERROR', path: entryPath, message: `MODIFIED "${block.name}" must contain SHALL or MUST` });
189
+ }
190
+ const scenarioCount = this.countScenarios(block.raw);
191
+ if (scenarioCount < 1) {
192
+ issues.push({ level: 'ERROR', path: entryPath, message: `MODIFIED "${block.name}" must include at least one scenario` });
193
+ }
194
+ }
195
+
196
+ // Validate REMOVED (names only)
197
+ for (const name of plan.removed) {
198
+ const key = normalizeRequirementName(name);
199
+ totalDeltas++;
200
+ if (removedNames.has(key)) {
201
+ issues.push({ level: 'ERROR', path: entryPath, message: `Duplicate requirement in REMOVED: "${name}"` });
202
+ } else {
203
+ removedNames.add(key);
204
+ }
205
+ }
206
+
207
+ // Validate RENAMED pairs
208
+ for (const { from, to } of plan.renamed) {
209
+ const fromKey = normalizeRequirementName(from);
210
+ const toKey = normalizeRequirementName(to);
211
+ totalDeltas++;
212
+ if (renamedFrom.has(fromKey)) {
213
+ issues.push({ level: 'ERROR', path: entryPath, message: `Duplicate FROM in RENAMED: "${from}"` });
214
+ } else {
215
+ renamedFrom.add(fromKey);
216
+ }
217
+ if (renamedTo.has(toKey)) {
218
+ issues.push({ level: 'ERROR', path: entryPath, message: `Duplicate TO in RENAMED: "${to}"` });
219
+ } else {
220
+ renamedTo.add(toKey);
221
+ }
222
+ }
223
+
224
+ // Cross-section conflicts (within the same spec file)
225
+ for (const n of modifiedNames) {
226
+ if (removedNames.has(n)) {
227
+ issues.push({ level: 'ERROR', path: entryPath, message: `Requirement present in both MODIFIED and REMOVED: "${n}"` });
228
+ }
229
+ if (addedNames.has(n)) {
230
+ issues.push({ level: 'ERROR', path: entryPath, message: `Requirement present in both MODIFIED and ADDED: "${n}"` });
231
+ }
232
+ }
233
+ for (const n of addedNames) {
234
+ if (removedNames.has(n)) {
235
+ issues.push({ level: 'ERROR', path: entryPath, message: `Requirement present in both ADDED and REMOVED: "${n}"` });
236
+ }
237
+ }
238
+ for (const { from, to } of plan.renamed) {
239
+ const fromKey = normalizeRequirementName(from);
240
+ const toKey = normalizeRequirementName(to);
241
+ if (modifiedNames.has(fromKey)) {
242
+ issues.push({ level: 'ERROR', path: entryPath, message: `MODIFIED references old name from RENAMED. Use new header for "${to}"` });
243
+ }
244
+ if (addedNames.has(toKey)) {
245
+ issues.push({ level: 'ERROR', path: entryPath, message: `RENAMED TO collides with ADDED for "${to}"` });
246
+ }
247
+ }
248
+ }
249
+ } catch {
250
+ // If no specs dir, treat as no deltas
251
+ }
252
+
253
+ for (const { path: specPath, sections } of emptySectionSpecs) {
254
+ issues.push({
255
+ level: 'ERROR',
256
+ path: specPath,
257
+ message: `Delta sections ${this.formatSectionList(sections)} were found, but no requirement entries parsed. Ensure each section includes at least one "### Requirement:" block (REMOVED may use bullet list syntax).`,
258
+ });
259
+ }
260
+ for (const path of missingHeaderSpecs) {
261
+ issues.push({
262
+ level: 'ERROR',
263
+ path,
264
+ message: 'No delta sections found. Add headers such as "## ADDED Requirements" or move non-delta notes outside specs/.',
265
+ });
266
+ }
267
+
268
+ if (totalDeltas === 0) {
269
+ issues.push({ level: 'ERROR', path: 'file', message: this.enrichTopLevelError('change', VALIDATION_MESSAGES.CHANGE_NO_DELTAS) });
270
+ }
271
+
272
+ return this.createReport(issues);
273
+ }
274
+
275
+ private convertZodErrors(error: ZodError): ValidationIssue[] {
276
+ return error.issues.map(err => {
277
+ let message = err.message;
278
+ if (message === VALIDATION_MESSAGES.CHANGE_NO_DELTAS) {
279
+ message = `${message}. ${VALIDATION_MESSAGES.GUIDE_NO_DELTAS}`;
280
+ }
281
+ return {
282
+ level: 'ERROR' as ValidationLevel,
283
+ path: err.path.join('.'),
284
+ message,
285
+ };
286
+ });
287
+ }
288
+
289
+ private applySpecRules(spec: Spec, content: string): ValidationIssue[] {
290
+ const issues: ValidationIssue[] = [];
291
+
292
+ if (spec.overview.length < MIN_PURPOSE_LENGTH) {
293
+ issues.push({
294
+ level: 'WARNING',
295
+ path: 'overview',
296
+ message: VALIDATION_MESSAGES.PURPOSE_TOO_BRIEF,
297
+ });
298
+ }
299
+
300
+ spec.requirements.forEach((req, index) => {
301
+ if (req.text.length > MAX_REQUIREMENT_TEXT_LENGTH) {
302
+ issues.push({
303
+ level: 'INFO',
304
+ path: `requirements[${index}]`,
305
+ message: VALIDATION_MESSAGES.REQUIREMENT_TOO_LONG,
306
+ });
307
+ }
308
+
309
+ if (req.scenarios.length === 0) {
310
+ issues.push({
311
+ level: 'WARNING',
312
+ path: `requirements[${index}].scenarios`,
313
+ message: `${VALIDATION_MESSAGES.REQUIREMENT_NO_SCENARIOS}. ${VALIDATION_MESSAGES.GUIDE_SCENARIO_FORMAT}`,
314
+ });
315
+ }
316
+ });
317
+
318
+ return issues;
319
+ }
320
+
321
+ private applyChangeRules(change: Change, content: string): ValidationIssue[] {
322
+ const issues: ValidationIssue[] = [];
323
+
324
+ const MIN_DELTA_DESCRIPTION_LENGTH = 10;
325
+
326
+ change.deltas.forEach((delta, index) => {
327
+ if (!delta.description || delta.description.length < MIN_DELTA_DESCRIPTION_LENGTH) {
328
+ issues.push({
329
+ level: 'WARNING',
330
+ path: `deltas[${index}].description`,
331
+ message: VALIDATION_MESSAGES.DELTA_DESCRIPTION_TOO_BRIEF,
332
+ });
333
+ }
334
+
335
+ if ((delta.operation === 'ADDED' || delta.operation === 'MODIFIED') &&
336
+ (!delta.requirements || delta.requirements.length === 0)) {
337
+ issues.push({
338
+ level: 'WARNING',
339
+ path: `deltas[${index}].requirements`,
340
+ message: `${delta.operation} ${VALIDATION_MESSAGES.DELTA_MISSING_REQUIREMENTS}`,
341
+ });
342
+ }
343
+ });
344
+
345
+ return issues;
346
+ }
347
+
348
+ private enrichTopLevelError(itemId: string, baseMessage: string): string {
349
+ const msg = baseMessage.trim();
350
+ if (msg === VALIDATION_MESSAGES.CHANGE_NO_DELTAS) {
351
+ return `${msg}. ${VALIDATION_MESSAGES.GUIDE_NO_DELTAS}`;
352
+ }
353
+ if (msg.includes('Spec must have a Purpose section') || msg.includes('Spec must have a Requirements section')) {
354
+ return `${msg}. ${VALIDATION_MESSAGES.GUIDE_MISSING_SPEC_SECTIONS}`;
355
+ }
356
+ if (msg.includes('Change must have a Why section') || msg.includes('Change must have a What Changes section')) {
357
+ return `${msg}. ${VALIDATION_MESSAGES.GUIDE_MISSING_CHANGE_SECTIONS}`;
358
+ }
359
+ return msg;
360
+ }
361
+
362
+ private extractNameFromPath(filePath: string): string {
363
+ const normalizedPath = FileSystemUtils.toPosixPath(filePath);
364
+ const parts = normalizedPath.split('/');
365
+
366
+ // Look for the directory name after 'specs' or 'changes'
367
+ for (let i = parts.length - 1; i >= 0; i--) {
368
+ if (parts[i] === 'specs' || parts[i] === 'changes') {
369
+ if (i < parts.length - 1) {
370
+ return parts[i + 1];
371
+ }
372
+ }
373
+ }
374
+
375
+ // Fallback to filename without extension if not in expected structure
376
+ const fileName = parts[parts.length - 1] ?? '';
377
+ const dotIndex = fileName.lastIndexOf('.');
378
+ return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;
379
+ }
380
+
381
+ private createReport(issues: ValidationIssue[]): ValidationReport {
382
+ const errors = issues.filter(i => i.level === 'ERROR').length;
383
+ const warnings = issues.filter(i => i.level === 'WARNING').length;
384
+ const info = issues.filter(i => i.level === 'INFO').length;
385
+
386
+ const valid = this.strictMode
387
+ ? errors === 0 && warnings === 0
388
+ : errors === 0;
389
+
390
+ return {
391
+ valid,
392
+ issues,
393
+ summary: {
394
+ errors,
395
+ warnings,
396
+ info,
397
+ },
398
+ };
399
+ }
400
+
401
+ isValid(report: ValidationReport): boolean {
402
+ return report.valid;
403
+ }
404
+
405
+ private extractRequirementText(blockRaw: string): string | undefined {
406
+ const lines = blockRaw.split('\n');
407
+ // Skip header line (index 0)
408
+ let i = 1;
409
+
410
+ // Find the first substantial text line, skipping metadata and blank lines
411
+ for (; i < lines.length; i++) {
412
+ const line = lines[i];
413
+
414
+ // Stop at scenario headers
415
+ if (/^####\s+/.test(line)) break;
416
+
417
+ const trimmed = line.trim();
418
+
419
+ // Skip blank lines
420
+ if (trimmed.length === 0) continue;
421
+
422
+ // Skip metadata lines (lines starting with ** like **ID**, **Priority**, etc.)
423
+ if (/^\*\*[^*]+\*\*:/.test(trimmed)) continue;
424
+
425
+ // Found first non-metadata, non-blank line - this is the requirement text
426
+ return trimmed;
427
+ }
428
+
429
+ // No requirement text found
430
+ return undefined;
431
+ }
432
+
433
+ private containsShallOrMust(text: string): boolean {
434
+ return /\b(SHALL|MUST)\b/.test(text);
435
+ }
436
+
437
+ private countScenarios(blockRaw: string): number {
438
+ const matches = blockRaw.match(/^####\s+/gm);
439
+ return matches ? matches.length : 0;
440
+ }
441
+
442
+ private formatSectionList(sections: string[]): string {
443
+ if (sections.length === 0) return '';
444
+ if (sections.length === 1) return sections[0];
445
+ const head = sections.slice(0, -1);
446
+ const last = sections[sections.length - 1];
447
+ return `${head.join(', ')} and ${last}`;
448
+ }
449
+ }
@@ -0,0 +1,219 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import chalk from 'chalk';
4
+ import { getTaskProgressForChange, formatTaskStatus } from '../utils/task-progress.js';
5
+ import { MarkdownParser } from './parsers/markdown-parser.js';
6
+
7
+ export class ViewCommand {
8
+ async execute(targetPath: string = '.'): Promise<void> {
9
+ const prompterDir = path.join(targetPath, 'prompter');
10
+
11
+ if (!fs.existsSync(prompterDir)) {
12
+ console.error(chalk.red('No prompter directory found'));
13
+ process.exit(1);
14
+ }
15
+
16
+ console.log(chalk.bold('\nPrompter Dashboard\n'));
17
+ console.log('═'.repeat(60));
18
+
19
+ // Get changes and specs data
20
+ const changesData = await this.getChangesData(prompterDir);
21
+ const specsData = await this.getSpecsData(prompterDir);
22
+
23
+ // Display summary metrics
24
+ this.displaySummary(changesData, specsData);
25
+
26
+ // Display draft changes
27
+ if (changesData.draft.length > 0) {
28
+ console.log(chalk.bold.gray('\nDraft Changes'));
29
+ console.log('─'.repeat(60));
30
+ changesData.draft.forEach((change) => {
31
+ console.log(` ${chalk.gray('○')} ${change.name}`);
32
+ });
33
+ }
34
+
35
+ // Display active changes
36
+ if (changesData.active.length > 0) {
37
+ console.log(chalk.bold.cyan('\nActive Changes'));
38
+ console.log('─'.repeat(60));
39
+ changesData.active.forEach((change) => {
40
+ const progressBar = this.createProgressBar(change.progress.completed, change.progress.total);
41
+ const percentage =
42
+ change.progress.total > 0
43
+ ? Math.round((change.progress.completed / change.progress.total) * 100)
44
+ : 0;
45
+
46
+ console.log(
47
+ ` ${chalk.yellow('◉')} ${chalk.bold(change.name.padEnd(30))} ${progressBar} ${chalk.dim(`${percentage}%`)}`
48
+ );
49
+ });
50
+ }
51
+
52
+ // Display completed changes
53
+ if (changesData.completed.length > 0) {
54
+ console.log(chalk.bold.green('\nCompleted Changes'));
55
+ console.log('─'.repeat(60));
56
+ changesData.completed.forEach((change) => {
57
+ console.log(` ${chalk.green('✓')} ${change.name}`);
58
+ });
59
+ }
60
+
61
+ // Display specifications
62
+ if (specsData.length > 0) {
63
+ console.log(chalk.bold.blue('\nSpecifications'));
64
+ console.log('─'.repeat(60));
65
+
66
+ // Sort specs by requirement count (descending)
67
+ specsData.sort((a, b) => b.requirementCount - a.requirementCount);
68
+
69
+ specsData.forEach(spec => {
70
+ const reqLabel = spec.requirementCount === 1 ? 'requirement' : 'requirements';
71
+ console.log(
72
+ ` ${chalk.blue('▪')} ${chalk.bold(spec.name.padEnd(30))} ${chalk.dim(`${spec.requirementCount} ${reqLabel}`)}`
73
+ );
74
+ });
75
+ }
76
+
77
+ console.log('\n' + '═'.repeat(60));
78
+ console.log(chalk.dim(`\nUse ${chalk.white('prompter list --changes')} or ${chalk.white('prompter list --specs')} for detailed views`));
79
+ }
80
+
81
+ private async getChangesData(prompterDir: string): Promise<{
82
+ draft: Array<{ name: string }>;
83
+ active: Array<{ name: string; progress: { total: number; completed: number } }>;
84
+ completed: Array<{ name: string }>;
85
+ }> {
86
+ const changesDir = path.join(prompterDir, 'changes');
87
+
88
+ if (!fs.existsSync(changesDir)) {
89
+ return { draft: [], active: [], completed: [] };
90
+ }
91
+
92
+ const draft: Array<{ name: string }> = [];
93
+ const active: Array<{ name: string; progress: { total: number; completed: number } }> = [];
94
+ const completed: Array<{ name: string }> = [];
95
+
96
+ const entries = fs.readdirSync(changesDir, { withFileTypes: true });
97
+
98
+ for (const entry of entries) {
99
+ if (entry.isDirectory() && entry.name !== 'archive') {
100
+ const progress = await getTaskProgressForChange(changesDir, entry.name);
101
+
102
+ if (progress.total === 0) {
103
+ // No tasks defined yet - still in planning/draft phase
104
+ draft.push({ name: entry.name });
105
+ } else if (progress.completed === progress.total) {
106
+ // All tasks complete
107
+ completed.push({ name: entry.name });
108
+ } else {
109
+ // Has tasks but not all complete
110
+ active.push({ name: entry.name, progress });
111
+ }
112
+ }
113
+ }
114
+
115
+ // Sort all categories by name for deterministic ordering
116
+ draft.sort((a, b) => a.name.localeCompare(b.name));
117
+
118
+ // Sort active changes by completion percentage (ascending) and then by name
119
+ active.sort((a, b) => {
120
+ const percentageA = a.progress.total > 0 ? a.progress.completed / a.progress.total : 0;
121
+ const percentageB = b.progress.total > 0 ? b.progress.completed / b.progress.total : 0;
122
+
123
+ if (percentageA < percentageB) return -1;
124
+ if (percentageA > percentageB) return 1;
125
+ return a.name.localeCompare(b.name);
126
+ });
127
+ completed.sort((a, b) => a.name.localeCompare(b.name));
128
+
129
+ return { draft, active, completed };
130
+ }
131
+
132
+ private async getSpecsData(prompterDir: string): Promise<Array<{ name: string; requirementCount: number }>> {
133
+ const specsDir = path.join(prompterDir, 'specs');
134
+
135
+ if (!fs.existsSync(specsDir)) {
136
+ return [];
137
+ }
138
+
139
+ const specs: Array<{ name: string; requirementCount: number }> = [];
140
+ const entries = fs.readdirSync(specsDir, { withFileTypes: true });
141
+
142
+ for (const entry of entries) {
143
+ if (entry.isDirectory()) {
144
+ const specFile = path.join(specsDir, entry.name, 'spec.md');
145
+
146
+ if (fs.existsSync(specFile)) {
147
+ try {
148
+ const content = fs.readFileSync(specFile, 'utf-8');
149
+ const parser = new MarkdownParser(content);
150
+ const spec = parser.parseSpec(entry.name);
151
+ const requirementCount = spec.requirements.length;
152
+ specs.push({ name: entry.name, requirementCount });
153
+ } catch (error) {
154
+ // If spec cannot be parsed, include with 0 count
155
+ specs.push({ name: entry.name, requirementCount: 0 });
156
+ }
157
+ }
158
+ }
159
+ }
160
+
161
+ return specs;
162
+ }
163
+
164
+ private displaySummary(
165
+ changesData: { draft: any[]; active: any[]; completed: any[] },
166
+ specsData: any[]
167
+ ): void {
168
+ const totalChanges =
169
+ changesData.draft.length + changesData.active.length + changesData.completed.length;
170
+ const totalSpecs = specsData.length;
171
+ const totalRequirements = specsData.reduce((sum, spec) => sum + spec.requirementCount, 0);
172
+
173
+ // Calculate total task progress
174
+ let totalTasks = 0;
175
+ let completedTasks = 0;
176
+
177
+ changesData.active.forEach((change) => {
178
+ totalTasks += change.progress.total;
179
+ completedTasks += change.progress.completed;
180
+ });
181
+
182
+ changesData.completed.forEach(() => {
183
+ // Completed changes count as 100% done (we don't know exact task count)
184
+ // This is a simplification
185
+ });
186
+
187
+ console.log(chalk.bold('Summary:'));
188
+ console.log(
189
+ ` ${chalk.cyan('●')} Specifications: ${chalk.bold(totalSpecs)} specs, ${chalk.bold(totalRequirements)} requirements`
190
+ );
191
+ if (changesData.draft.length > 0) {
192
+ console.log(` ${chalk.gray('●')} Draft Changes: ${chalk.bold(changesData.draft.length)}`);
193
+ }
194
+ console.log(
195
+ ` ${chalk.yellow('●')} Active Changes: ${chalk.bold(changesData.active.length)} in progress`
196
+ );
197
+ console.log(` ${chalk.green('●')} Completed Changes: ${chalk.bold(changesData.completed.length)}`);
198
+
199
+ if (totalTasks > 0) {
200
+ const overallProgress = Math.round((completedTasks / totalTasks) * 100);
201
+ console.log(
202
+ ` ${chalk.magenta('●')} Task Progress: ${chalk.bold(`${completedTasks}/${totalTasks}`)} (${overallProgress}% complete)`
203
+ );
204
+ }
205
+ }
206
+
207
+ private createProgressBar(completed: number, total: number, width: number = 20): string {
208
+ if (total === 0) return chalk.dim('─'.repeat(width));
209
+
210
+ const percentage = completed / total;
211
+ const filled = Math.round(percentage * width);
212
+ const empty = width - filled;
213
+
214
+ const filledBar = chalk.green('█'.repeat(filled));
215
+ const emptyBar = chalk.dim('░'.repeat(empty));
216
+
217
+ return `[${filledBar}${emptyBar}]`;
218
+ }
219
+ }