sdd-forge 0.1.0-alpha.3 → 0.1.0-alpha.31

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 (263) hide show
  1. package/README.md +173 -30
  2. package/docs/cli_commands.md +259 -0
  3. package/docs/configuration.md +191 -0
  4. package/docs/internal_design.md +359 -0
  5. package/docs/ja/README.md +188 -0
  6. package/docs/ja/cli_commands.md +442 -0
  7. package/docs/ja/configuration.md +238 -0
  8. package/docs/ja/internal_design.md +333 -0
  9. package/docs/ja/overview.md +109 -0
  10. package/docs/ja-translate/README.md +188 -0
  11. package/docs/ja-translate/cli_commands.md +372 -0
  12. package/docs/ja-translate/configuration.md +193 -0
  13. package/docs/ja-translate/internal_design.md +325 -0
  14. package/docs/ja-translate/overview.md +148 -0
  15. package/docs/overview.md +144 -0
  16. package/package.json +15 -7
  17. package/src/README.md +201 -0
  18. package/src/docs/commands/agents.js +213 -0
  19. package/src/docs/commands/changelog.js +242 -0
  20. package/src/docs/commands/data.js +188 -0
  21. package/src/docs/commands/enrich.js +439 -0
  22. package/src/docs/commands/forge.js +475 -0
  23. package/src/docs/commands/init.js +256 -0
  24. package/src/docs/commands/readme.js +187 -0
  25. package/src/docs/commands/review.js +355 -0
  26. package/src/docs/commands/scan.js +232 -0
  27. package/src/docs/commands/snapshot.js +208 -0
  28. package/src/docs/commands/text.js +640 -0
  29. package/src/docs/commands/translate.js +228 -0
  30. package/src/docs/data/agents.js +138 -0
  31. package/src/docs/data/docs.js +219 -0
  32. package/src/docs/data/lang.js +109 -0
  33. package/src/docs/data/project.js +56 -0
  34. package/src/docs/lib/command-context.js +180 -0
  35. package/src/docs/lib/concurrency.js +47 -0
  36. package/src/docs/lib/data-source-loader.js +44 -0
  37. package/src/docs/lib/data-source.js +102 -0
  38. package/src/docs/lib/directive-parser.js +314 -0
  39. package/src/docs/lib/forge-prompts.js +199 -0
  40. package/src/docs/lib/resolver-factory.js +118 -0
  41. package/src/docs/lib/review-parser.js +215 -0
  42. package/src/docs/lib/scan-source.js +59 -0
  43. package/src/docs/lib/scanner.js +292 -0
  44. package/src/docs/lib/template-merger.js +386 -0
  45. package/src/docs/lib/test-env-detection.js +50 -0
  46. package/src/docs/lib/text-prompts.js +286 -0
  47. package/src/docs.js +216 -0
  48. package/src/flow/commands/cleanup.js +86 -0
  49. package/src/flow/commands/merge.js +88 -0
  50. package/src/flow/commands/review.js +301 -0
  51. package/src/flow/{flow.js → commands/start.js} +65 -35
  52. package/src/flow/commands/status.js +209 -0
  53. package/src/flow.js +58 -0
  54. package/src/help.js +65 -42
  55. package/src/lib/agent.js +343 -0
  56. package/src/lib/agents-md.js +25 -0
  57. package/src/lib/cli.js +66 -0
  58. package/src/lib/config.js +74 -2
  59. package/src/lib/entrypoint.js +23 -0
  60. package/src/lib/flow-state.js +137 -0
  61. package/src/lib/i18n.js +274 -0
  62. package/src/lib/presets.js +81 -0
  63. package/src/lib/progress.js +217 -0
  64. package/src/lib/types.js +241 -0
  65. package/src/locale/en/messages.json +110 -0
  66. package/src/locale/en/prompts.json +70 -0
  67. package/src/locale/en/ui.json +348 -0
  68. package/src/locale/ja/messages.json +110 -0
  69. package/src/locale/ja/prompts.json +70 -0
  70. package/src/locale/ja/ui.json +348 -0
  71. package/src/presets/base/data/package.js +52 -0
  72. package/src/presets/base/preset.json +11 -0
  73. package/src/presets/base/templates/en/AGENTS.sdd.md +24 -0
  74. package/src/presets/base/templates/en/development.md +40 -0
  75. package/src/presets/base/templates/en/guardrail.md +18 -0
  76. package/src/presets/base/templates/en/overview.md +43 -0
  77. package/src/presets/base/templates/en/project_structure.md +33 -0
  78. package/src/presets/base/templates/en/stack_and_ops.md +40 -0
  79. package/src/presets/base/templates/ja/AGENTS.sdd.md +24 -0
  80. package/src/presets/base/templates/ja/development.md +40 -0
  81. package/src/presets/base/templates/ja/guardrail.md +18 -0
  82. package/src/presets/base/templates/ja/overview.md +43 -0
  83. package/src/presets/base/templates/ja/project_structure.md +33 -0
  84. package/src/presets/base/templates/ja/stack_and_ops.md +40 -0
  85. package/src/presets/cakephp2/data/config.js +176 -0
  86. package/src/presets/cakephp2/data/controllers.js +117 -0
  87. package/src/presets/cakephp2/data/docker.js +17 -0
  88. package/src/presets/cakephp2/data/email.js +35 -0
  89. package/src/presets/cakephp2/data/libs.js +76 -0
  90. package/src/presets/cakephp2/data/models.js +118 -0
  91. package/src/presets/cakephp2/data/shells.js +48 -0
  92. package/src/presets/cakephp2/data/tables.js +122 -0
  93. package/src/presets/cakephp2/data/tests.js +30 -0
  94. package/src/presets/cakephp2/data/views.js +56 -0
  95. package/src/presets/cakephp2/preset.json +14 -0
  96. package/src/presets/cakephp2/scan/assets.js +68 -0
  97. package/src/presets/cakephp2/scan/base-classes.js +170 -0
  98. package/src/presets/cakephp2/scan/business.js +102 -0
  99. package/src/presets/cakephp2/scan/config.js +129 -0
  100. package/src/{analyzers/analyze-models.js → presets/cakephp2/scan/models.js} +3 -1
  101. package/src/presets/cakephp2/scan/notifications.js +78 -0
  102. package/src/presets/cakephp2/scan/security.js +85 -0
  103. package/src/presets/cakephp2/scan/shells-detail.js +56 -0
  104. package/src/presets/cakephp2/scan/testing.js +37 -0
  105. package/src/presets/cakephp2/scan/views.js +228 -0
  106. package/src/presets/cakephp2/templates/en/guardrail.md +11 -0
  107. package/src/presets/cakephp2/templates/ja/auth_and_session.md +22 -0
  108. package/src/presets/cakephp2/templates/ja/controller_routes.md +13 -0
  109. package/src/presets/cakephp2/templates/ja/db_tables.md +22 -0
  110. package/src/presets/cakephp2/templates/ja/development.md +50 -0
  111. package/src/presets/cakephp2/templates/ja/guardrail.md +11 -0
  112. package/src/presets/cakephp2/templates/ja/project_structure.md +39 -0
  113. package/src/presets/cakephp2/templates/ja/stack_and_ops.md +48 -0
  114. package/src/presets/cli/data/modules.js +52 -0
  115. package/src/presets/cli/preset.json +13 -0
  116. package/src/presets/cli/templates/en/README.md +37 -0
  117. package/src/presets/cli/templates/en/commands.md +40 -0
  118. package/src/presets/cli/templates/en/config.md +40 -0
  119. package/src/presets/cli/templates/en/guardrail.md +8 -0
  120. package/src/presets/cli/templates/ja/README.md +37 -0
  121. package/src/presets/cli/templates/ja/commands.md +40 -0
  122. package/src/presets/cli/templates/ja/config.md +40 -0
  123. package/src/presets/cli/templates/ja/guardrail.md +8 -0
  124. package/src/presets/laravel/data/commands.js +24 -0
  125. package/src/presets/laravel/data/config.js +97 -0
  126. package/src/presets/laravel/data/controllers.js +81 -0
  127. package/src/presets/laravel/data/models.js +80 -0
  128. package/src/presets/laravel/data/routes.js +56 -0
  129. package/src/presets/laravel/data/tables.js +85 -0
  130. package/src/presets/laravel/preset.json +16 -0
  131. package/src/presets/laravel/scan/config.js +93 -0
  132. package/src/presets/laravel/scan/controllers.js +77 -0
  133. package/src/presets/laravel/scan/migrations.js +147 -0
  134. package/src/presets/laravel/scan/models.js +157 -0
  135. package/src/presets/laravel/scan/routes.js +121 -0
  136. package/src/presets/laravel/templates/en/guardrail.md +11 -0
  137. package/src/presets/laravel/templates/ja/auth_and_session.md +29 -0
  138. package/src/presets/laravel/templates/ja/controller_routes.md +44 -0
  139. package/src/presets/laravel/templates/ja/db_tables.md +22 -0
  140. package/src/presets/laravel/templates/ja/guardrail.md +11 -0
  141. package/src/presets/laravel/templates/ja/project_structure.md +13 -0
  142. package/src/presets/laravel/templates/ja/stack_and_ops.md +42 -0
  143. package/src/presets/lib/composer-utils.js +61 -0
  144. package/src/presets/library/preset.json +13 -0
  145. package/src/presets/library/templates/en/guardrail.md +5 -0
  146. package/src/presets/library/templates/ja/README.md +18 -0
  147. package/src/presets/library/templates/ja/guardrail.md +5 -0
  148. package/src/presets/library/templates/ja/public_api.md +33 -0
  149. package/src/presets/library/templates/ja/usage.md +40 -0
  150. package/src/presets/node-cli/preset.json +16 -0
  151. package/src/presets/node-cli/templates/en/README.md +31 -0
  152. package/src/presets/node-cli/templates/en/cli_commands.md +30 -0
  153. package/src/presets/node-cli/templates/en/configuration.md +30 -0
  154. package/src/presets/node-cli/templates/en/development_testing.md +48 -0
  155. package/src/presets/node-cli/templates/en/guardrail.md +5 -0
  156. package/src/presets/node-cli/templates/en/internal_design.md +35 -0
  157. package/src/presets/node-cli/templates/en/overview.md +30 -0
  158. package/src/presets/node-cli/templates/ja/README.md +31 -0
  159. package/src/presets/node-cli/templates/ja/cli_commands.md +30 -0
  160. package/src/presets/node-cli/templates/ja/commands.md +2 -0
  161. package/src/presets/node-cli/templates/ja/config.md +2 -0
  162. package/src/presets/node-cli/templates/ja/configuration.md +30 -0
  163. package/src/presets/node-cli/templates/ja/development.md +2 -0
  164. package/src/presets/node-cli/templates/ja/development_testing.md +48 -0
  165. package/src/presets/node-cli/templates/ja/guardrail.md +5 -0
  166. package/src/presets/node-cli/templates/ja/internal_design.md +35 -0
  167. package/src/presets/node-cli/templates/ja/overview.md +30 -0
  168. package/src/presets/node-cli/templates/ja/project_structure.md +2 -0
  169. package/src/presets/node-cli/templates/ja/stack_and_ops.md +2 -0
  170. package/src/presets/symfony/data/commands.js +24 -0
  171. package/src/presets/symfony/data/config.js +92 -0
  172. package/src/presets/symfony/data/controllers.js +72 -0
  173. package/src/presets/symfony/data/entities.js +67 -0
  174. package/src/presets/symfony/data/routes.js +70 -0
  175. package/src/presets/symfony/data/tables.js +67 -0
  176. package/src/presets/symfony/preset.json +16 -0
  177. package/src/presets/symfony/scan/config.js +101 -0
  178. package/src/presets/symfony/scan/controllers.js +96 -0
  179. package/src/presets/symfony/scan/entities.js +142 -0
  180. package/src/presets/symfony/scan/migrations.js +149 -0
  181. package/src/presets/symfony/scan/routes.js +199 -0
  182. package/src/presets/symfony/templates/en/guardrail.md +11 -0
  183. package/src/presets/symfony/templates/ja/auth_and_session.md +29 -0
  184. package/src/presets/symfony/templates/ja/controller_routes.md +42 -0
  185. package/src/presets/symfony/templates/ja/db_tables.md +29 -0
  186. package/src/presets/symfony/templates/ja/guardrail.md +11 -0
  187. package/src/presets/symfony/templates/ja/project_structure.md +13 -0
  188. package/src/presets/symfony/templates/ja/stack_and_ops.md +42 -0
  189. package/src/presets/webapp/data/controllers.js +74 -0
  190. package/src/presets/webapp/data/models.js +86 -0
  191. package/src/presets/webapp/data/routes.js +68 -0
  192. package/src/presets/webapp/data/shells.js +65 -0
  193. package/src/presets/webapp/data/tables.js +63 -0
  194. package/src/presets/webapp/data/webapp-data-source.js +26 -0
  195. package/src/presets/webapp/preset.json +17 -0
  196. package/src/presets/webapp/templates/en/guardrail.md +14 -0
  197. package/src/presets/webapp/templates/ja/README.md +24 -0
  198. package/src/presets/webapp/templates/ja/auth_and_session.md +46 -0
  199. package/src/presets/webapp/templates/ja/batch_and_shell.md +43 -0
  200. package/src/presets/webapp/templates/ja/business_logic.md +46 -0
  201. package/src/presets/webapp/templates/ja/controller_routes.md +50 -0
  202. package/src/presets/webapp/templates/ja/database_architecture.md +40 -0
  203. package/src/presets/webapp/templates/ja/db_tables.md +32 -0
  204. package/src/presets/webapp/templates/ja/guardrail.md +14 -0
  205. package/src/presets-cmd.js +67 -0
  206. package/src/sdd-forge.js +59 -0
  207. package/src/setup.js +576 -0
  208. package/src/spec/commands/gate.js +310 -0
  209. package/src/spec/commands/guardrail.js +251 -0
  210. package/src/spec/commands/init.js +324 -0
  211. package/src/spec.js +39 -0
  212. package/src/templates/config.example.json +56 -0
  213. package/src/templates/skills/sdd-forge.flow-impl/SKILL.md +103 -0
  214. package/src/templates/skills/sdd-forge.flow-merge/SKILL.md +142 -0
  215. package/src/templates/skills/sdd-forge.flow-plan/SKILL.md +176 -0
  216. package/src/templates/skills/sdd-forge.flow-status/SKILL.md +94 -0
  217. package/src/upgrade.js +183 -0
  218. package/src/analyzers/analyze-controllers.js +0 -85
  219. package/src/analyzers/analyze-extras.js +0 -944
  220. package/src/analyzers/analyze-routes.js +0 -50
  221. package/src/analyzers/analyze-shells.js +0 -75
  222. package/src/analyzers/scan.js +0 -116
  223. package/src/bin/sdd-forge.js +0 -133
  224. package/src/engine/directive-parser.js +0 -72
  225. package/src/engine/init.js +0 -253
  226. package/src/engine/populate.js +0 -192
  227. package/src/engine/readme.js +0 -174
  228. package/src/engine/renderers.js +0 -150
  229. package/src/engine/resolver.js +0 -568
  230. package/src/engine/tfill.js +0 -617
  231. package/src/forge/forge.js +0 -684
  232. package/src/projects/add.js +0 -73
  233. package/src/projects/projects.js +0 -91
  234. package/src/projects/setdefault.js +0 -37
  235. package/src/spec/gate.js +0 -101
  236. package/src/spec/spec.js +0 -198
  237. package/src/templates/checks/check-controller-coverage.sh +0 -46
  238. package/src/templates/checks/check-db-coverage.sh +0 -87
  239. package/src/templates/checks/check-node-cli-docs.sh +0 -125
  240. package/src/templates/checks/check-temp-docs.sh +0 -100
  241. package/src/templates/checks/generate-change-log.sh +0 -142
  242. package/src/templates/checks/self-review-temp-docs.sh +0 -19
  243. package/src/templates/locale/ja/messages.json +0 -9
  244. package/src/templates/locale/ja/node-cli/01_overview.md +0 -23
  245. package/src/templates/locale/ja/node-cli/02_cli_commands.md +0 -23
  246. package/src/templates/locale/ja/node-cli/03_configuration.md +0 -23
  247. package/src/templates/locale/ja/node-cli/04_internal_design.md +0 -30
  248. package/src/templates/locale/ja/node-cli/05_development.md +0 -49
  249. package/src/templates/locale/ja/node-cli/README.md +0 -41
  250. package/src/templates/locale/ja/php-mvc/01_architecture.md +0 -23
  251. package/src/templates/locale/ja/php-mvc/02_stack_and_ops.md +0 -45
  252. package/src/templates/locale/ja/php-mvc/03_project_structure.md +0 -46
  253. package/src/templates/locale/ja/php-mvc/04_development.md +0 -69
  254. package/src/templates/locale/ja/php-mvc/05_auth_and_session.md +0 -48
  255. package/src/templates/locale/ja/php-mvc/06_database_architecture.md +0 -23
  256. package/src/templates/locale/ja/php-mvc/07_db_tables.md +0 -31
  257. package/src/templates/locale/ja/php-mvc/08_controller_routes.md +0 -33
  258. package/src/templates/locale/ja/php-mvc/09_business_logic.md +0 -27
  259. package/src/templates/locale/ja/php-mvc/10_batch_and_shell.md +0 -25
  260. package/src/templates/locale/ja/php-mvc/README.md +0 -34
  261. package/src/templates/locale/ja/prompts.json +0 -4
  262. package/src/templates/locale/ja/sections.json +0 -6
  263. /package/src/{analyzers → docs}/lib/php-array-parser.js +0 -0
package/README.md CHANGED
@@ -1,45 +1,188 @@
1
- # {{PROJECT_NAME}}
1
+ # <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
2
2
 
3
- {{PROJECT_DESCRIPTION}}
3
+ <!-- {{data: docs.langSwitcher("absolute")}} -->
4
+ **English** | [日本語](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/ja/README.md)
5
+ <!-- {{/data}} -->
4
6
 
5
- ## 技術スタック
7
+ [![npm version](https://img.shields.io/npm/v/sdd-forge.svg)](https://www.npmjs.com/package/sdd-forge)
6
8
 
7
- | カテゴリ | 技術 |
8
- |----------|------|
9
- | 言語 | Node.js (ES Modules) |
10
- | 配布 | npm |
11
- | テスト | — |
9
+ > **Alpha:** This tool is currently in alpha. APIs, command structure, and configuration formats may change without notice. Not recommended for production use.
12
10
 
13
- ## クイックスタート
11
+ **A CLI tool that generates documentation from programmatic source code analysis — based on facts, not AI guesswork.**
14
12
 
15
- ```bash
16
- npm install -g {{PACKAGE_NAME}}
17
- {{PACKAGE_NAME}} help
13
+ Mechanical gate checks and structured templates guarantee the reproducibility and accuracy that AI alone cannot deliver.
14
+ The Spec-Driven Development (SDD) workflow keeps your documentation in sync as features are added or changed.
15
+
16
+ ## Why sdd-forge?
17
+
18
+ Most AI documentation tools let AI "read" your code and write docs.
19
+ sdd-forge is different.
20
+
21
+ - **Programmatic analysis** — A static analyzer parses controllers, models, routes, and configs instead of asking AI to read them. No hallucinations, no missed files
22
+ - **Facts vs. generation** — `{{data}}` directives inject facts extracted mechanically from source code. `{{text}}` directives hold AI-generated explanations. What is trustworthy and what is inferred is structurally clear
23
+ - **Mechanical gate checks** — Spec completeness is verified by program logic, not AI judgment. A quality gate you can rely on
24
+ - **Structural stability** — Directives define what goes where. AI cannot rearrange paragraphs or alter the document structure
25
+
26
+ ## Features
27
+
28
+ ### Analyze
29
+
30
+ `scan` statically analyzes source code and produces `analysis.json`. A program — not AI — reads the structure.
31
+
32
+ - Parses controllers, models, routes, and config files to extract structural data
33
+ - `enrich` lets AI survey the whole picture and annotate each entry with role, summary, and chapter classification
34
+ - Preset system adapts to various frameworks and project structures
35
+
36
+ ### Generate
37
+
38
+ `{{data}}` injects facts, `{{text}}` injects AI explanations, both into templates. A single `build` command produces `docs/` and `README.md`.
39
+
40
+ - Template inheritance — 4-layer override: base → arch → preset → project-local
41
+ - Multi-language — translate / generate modes for automatic localization
42
+ - Zero dependencies — runs on Node.js 18+ only, no npm packages required
43
+
44
+ ### Enforce
45
+
46
+ `gate` mechanically validates specs, `review` checks document quality. The SDD workflow keeps documentation fresh.
47
+
48
+ - gate — detects unresolved items and missing approvals programmatically. Implementation blocked until PASS
49
+ - review — AI checks alignment between docs and source code
50
+ - AI agent integration — Claude Code (skills) and Codex CLI supported
51
+
52
+ ## Quick Start
53
+
54
+ ### Installation
55
+
56
+ <pre>
57
+ # npm
58
+ npm install -g <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
59
+
60
+ # yarn
61
+ yarn global add <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
62
+
63
+ # pnpm
64
+ pnpm add -g <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
65
+ </pre>
66
+
67
+ ### Setup & Generate
68
+
69
+ <pre>
70
+ # 1. Register your project (interactive wizard)
71
+ <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> setup
72
+
73
+ # 2. Generate all documentation (scan → enrich → init → data → text → readme → agents → translate)
74
+ <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> build
75
+ </pre>
76
+
77
+ That's it — `docs/` and `README.md` are generated.
78
+
79
+ ## Commands
80
+
81
+ ### Documentation Generation
82
+
83
+ | Command | Description |
84
+ |---|---|
85
+ | `setup` | Register project + generate config |
86
+ | `build` | Run the full documentation pipeline |
87
+ | `scan` | Analyze source code → `analysis.json` |
88
+ | `init` | Initialize `docs/` from templates |
89
+ | `data` | Resolve `{{data}}` directives with analysis data |
90
+ | `text` | Resolve `{{text}}` directives with AI |
91
+ | `readme` | Generate `README.md` from `docs/` |
92
+ | `forge` | Iteratively improve docs with AI |
93
+ | `review` | Check document quality |
94
+ | `translate` | Translate docs (default language → others) |
95
+ | `upgrade` | Update preset templates to latest version |
96
+
97
+ ### SDD Workflow
98
+
99
+ | Command | Description |
100
+ |---|---|
101
+ | `spec` | Create spec + feature branch |
102
+ | `gate` | Pre-implementation spec check |
103
+ | `flow` | Run the SDD workflow automatically |
104
+ | `changelog` | Generate change log from specs/ |
105
+ | `agents` | Update AGENTS.md |
106
+
107
+ ### Other
108
+
109
+ | Command | Description |
110
+ |---|---|
111
+ | `presets` | List available presets |
112
+ | `help` | Show command list |
113
+
114
+ ## SDD Workflow
115
+
116
+ Feature development flow:
117
+
118
+ ```
119
+ spec Create spec (feature branch + spec.md)
120
+
121
+ gate Spec gate check ← verified by program (not AI)
122
+
123
+ implement Code after gate PASS
124
+
125
+ forge AI updates documentation
126
+
127
+ review AI quality check (repeat until PASS)
128
+ ```
129
+
130
+ ### AI Agent Integration
131
+
132
+ #### Claude Code
133
+
134
+ Run SDD workflows via skills:
135
+
136
+ ```
137
+ /sdd-flow-start — create spec → gate → start implementation
138
+ /sdd-flow-close — forge → review → commit → merge
139
+ ```
140
+
141
+ #### Codex CLI
142
+
143
+ Run workflows from the `$` prompt:
144
+
145
+ ```
146
+ $sdd-flow-start — create spec → gate → start implementation
147
+ $sdd-flow-close — forge → review → commit → merge
18
148
  ```
19
149
 
20
- ## ドキュメント
150
+ ## Configuration
151
+
152
+ `sdd-forge setup` generates `.sdd-forge/config.json`:
21
153
 
22
- | 章 | 概要 |
23
- |----|------|
24
- | [01. ツール概要とアーキテクチャ](docs/01_overview.md) | `sdd-forge` は、PHP-MVC プロジェクト(CakePHP 等)における「仕様と実装の乖離」および「技術ドキュメントの作成・維持コスト」という課題を解決するための Node.js CLI ツールである。ソースコード静的解析(`scan`)・テンプレート駆動のドキュメント生成(`init` / `populate` / `tfill`)・仕様ゲート管理(`spec` / `gate`)・反復改善ループ(`forge`)を単一パッケージに統合し、Spec-Driven Development(SDD)ワークフローをコマンドラインから一貫して実行できる。 |
25
- | [02. CLI コマンドリファレンス](docs/02_cli_commands.md) | `SCRIPTS` オブジェクトから `scan:all` を含めると 19 コマンド(エントリは 18 だが `scan:all` は別処理)が確認できます。正確な数を数えます。 |
26
- | [03. 設定とカスタマイズ](docs/03_configuration.md) | sdd-forge の動作は `.sdd-forge/config.json` を中心とした複数の JSON 設定ファイルによって制御され、言語・テンプレートタイプ・AIプロバイダー・タイムアウト・テキスト生成挙動など幅広い項目をカスタマイズできる。プロジェクトごとのテンプレート差し替えは `project-overrides.json`、解析結果の表現上書きは `overrides.json` で行い、関心ごとに設定を分離できる構成になっている。 |
27
- | [04. 内部設計](docs/04_internal_design.md) | `src/bin/sdd-forge.js` がサブコマンドを各モジュール(`analyzers/`・`engine/`・`spec/`・`forge/`・`flow/`)へディスパッチし、共通ユーティリティ `lib/` を底辺として解析→生成→改善の方向で一方向に依存が流れる設計になっている。PHPソースを `analyzers/` が `analysis.json` へ変換し、`engine/populate` と `engine/tfill` がそのデータをテンプレートと組み合わせて `docs/` へ展開するパイプラインが中心的な処理フローである。 |
28
- | [05. 開発・テスト・配布](docs/05_development.md) | `npm link` を使ったビルド不要のローカル開発環境、外部依存ゼロの Node.js 実装、および `npm version` と `npm publish` による npm レジストリへのリリースフローを中心に構成された章である。テストフレームワークは現時点では導入されておらず、動作確認はコマンド直接実行による手動テストで行う。 |
154
+ ```jsonc
155
+ {
156
+ "type": "cli/node-cli", // project type (preset selection)
157
+ "lang": "en", // documentation language
158
+ "defaultAgent": "claude", // AI agent
159
+ "providers": { ... } // agent settings
160
+ }
161
+ ```
29
162
 
30
- ## 開発ワークフロー(SDD)
163
+ ### Customization
31
164
 
32
- 本プロジェクトは Spec-Driven Development(SDD)を採用しています。
165
+ Add project-specific templates and data sources:
33
166
 
34
167
  ```
35
- 1. sdd-forge spec --title "..." — 仕様ファイル作成
36
- 2. sdd-forge gate --spec ... — 仕様ゲート(未解決事項がなければ PASS)
37
- 3. 実装
38
- 4. sdd-forge forge --prompt "..." — ドキュメント自動更新
39
- 5. sdd-forge review — ドキュメントレビュー
168
+ .sdd-forge/
169
+ ├── templates/{lang}/
170
+ │ ├── docs/ ← chapter template & README overrides
171
+ │ └── specs/ ← spec.md / qa.md templates
172
+ └── data/ ← custom data source modules
40
173
  ```
41
174
 
42
- 詳細は [CLAUDE.md](CLAUDE.md) の「SDDフロー」セクションを参照してください。
175
+ ## Documentation
176
+
177
+ <!-- {{data: docs.chapters("Chapter|Summary")}} -->
178
+ | Chapter | Summary |
179
+ | --- | --- |
180
+ | [01. Tool Overview and Architecture](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/overview.md) | This chapter introduces sdd-forge, a CLI tool for Spec-Driven Development that automates technical documentation gene… |
181
+ | [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/cli_commands.md) | sdd-forge provides 20+ commands organized into four namespaces (`docs`, `spec`, `flow`, and standalone commands) thro… |
182
+ | [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/configuration.md) | sdd-forge is configured primarily through `.sdd-forge/config.json`, which controls output language, project type, doc… |
183
+ | [04. Internal Design](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/internal_design.md) | This chapter describes the internal architecture of sdd-forge, covering its three-layer directory structure (`src/` →… |
184
+ <!-- {{/data}} -->
185
+
186
+ ## License
43
187
 
44
- <!-- MANUAL:START -->
45
- <!-- MANUAL:END -->
188
+ MIT
@@ -0,0 +1,259 @@
1
+ # 02. CLI Command Reference
2
+
3
+ ## Description
4
+
5
+ <!-- {{text: Write a 1-2 sentence overview of this chapter. Include the total number of commands and subcommand structure.}} -->
6
+ sdd-forge provides 20+ commands organized into four namespaces (`docs`, `spec`, `flow`, and standalone commands) through a three-level dispatch architecture. The CLI entry point (`sdd-forge`) routes to namespace dispatchers, which in turn delegate to individual command implementations under `commands/` directories.
7
+ <!-- {{/text}} -->
8
+
9
+ ## Content
10
+
11
+ ### Command List
12
+
13
+ <!-- {{text[mode=deep]: List all commands in table format. Include command name, description, and key options. Extract comprehensively from command definitions and routing in the source code.}} -->
14
+ | Command | Description | Key Options |
15
+ |---|---|---|
16
+ | `sdd-forge help` | Display all available commands grouped by section | — |
17
+ | `sdd-forge setup` | Interactive project setup wizard; generates `.sdd-forge/config.json` | `--name`, `--path`, `--type`, `--purpose`, `--tone`, `--agent`, `--lang`, `--dry-run` |
18
+ | `sdd-forge upgrade` | Upgrade template-derived files (skills, etc.) to match installed version | `--dry-run` |
19
+ | `sdd-forge presets list` | Display the preset inheritance tree | — |
20
+ | `sdd-forge docs build` | Run the full documentation pipeline (scan→enrich→init→data→text→readme→agents→translate) | `--agent`, `--force`, `--dry-run`, `--verbose` |
21
+ | `sdd-forge docs scan` | Scan source code and generate `analysis.json` | — |
22
+ | `sdd-forge docs enrich` | AI-enrich analysis entries with summary, detail, chapter, and role metadata | `--agent`, `--dry-run`, `--stdout` |
23
+ | `sdd-forge docs init` | Initialize chapter files from preset templates | `--force`, `--dry-run` |
24
+ | `sdd-forge docs data` | Resolve `{{data}}` directives in chapter files | `--dry-run` |
25
+ | `sdd-forge docs text` | AI-fill `{{text}}` directives in chapter files | `--dry-run` |
26
+ | `sdd-forge docs readme` | Auto-generate `README.md` from chapter files and templates | `--dry-run`, `--lang`, `--output` |
27
+ | `sdd-forge docs forge` | Iteratively improve docs via AI agent and review cycles | `--prompt`, `--prompt-file`, `--spec`, `--max-runs`, `--review-cmd`, `--mode`, `--dry-run`, `--verbose` |
28
+ | `sdd-forge docs review` | Review generated documentation for quality issues | — |
29
+ | `sdd-forge docs translate` | Translate default-language docs to configured non-default languages | `--lang`, `--force`, `--dry-run` |
30
+ | `sdd-forge docs changelog` | Generate changelog from commit history | — |
31
+ | `sdd-forge docs agents` | Update AGENTS.md by resolving directives and AI-refining the PROJECT section | `--dry-run` |
32
+ | `sdd-forge docs snapshot` | Create a snapshot of current documentation state | — |
33
+ | `sdd-forge spec init` | Create a numbered feature branch and spec directory with templates | `--title`, `--base`, `--dry-run`, `--allow-dirty`, `--no-branch`, `--worktree` |
34
+ | `sdd-forge spec gate` | Pre-implementation gate check on spec completeness and guardrail compliance | `--spec`, `--phase`, `--skip-guardrail` |
35
+ | `sdd-forge spec guardrail` | Initialize or update project guardrail rules | Subcommands: `init`, `update`; `--force`, `--dry-run`, `--agent` |
36
+ | `sdd-forge flow start` | Run the full SDD flow (spec init → gate → forge) | `--request`, `--title`, `--spec`, `--agent`, `--max-runs`, `--forge-mode`, `--no-branch`, `--worktree`, `--dry-run` |
37
+ | `sdd-forge flow status` | Display or update SDD flow progress | `--step`, `--status`, `--summary`, `--req`, `--archive` |
38
+ | `sdd-forge flow review` | Run code quality review (draft → final → apply) after implementation | `--dry-run`, `--skip-confirm` |
39
+ <!-- {{/text}} -->
40
+
41
+ ### Global Options
42
+
43
+ <!-- {{text[mode=deep]: Describe global options shared by all commands in table format. Extract from argument parsing logic in the source code.}} -->
44
+ The following options are recognized at the top level or shared across most subcommands via the common `parseArgs` utility:
45
+
46
+ | Option | Description |
47
+ |---|---|
48
+ | `-h`, `--help` | Display help information for the current command or subcommand. Available on all commands. |
49
+ | `-v`, `--version`, `-V` | Print the installed sdd-forge version and exit. Handled at the top-level entry point. |
50
+ | `--dry-run` | Simulate the command without writing any files to disk. Supported by `build`, `init`, `data`, `text`, `readme`, `translate`, `agents`, `forge`, `setup`, `upgrade`, `spec init`, `flow start`, and `flow review`. |
51
+ | `--verbose` | Enable verbose output with detailed progress information. Supported by `build` and `forge`. |
52
+
53
+ Note: sdd-forge uses a custom `parseArgs` function (in `src/lib/cli.js`) that supports flag normalization (e.g., `--dry-run` → `dryRun`), option aliases (e.g., `-v` → `--verbose`), and default values. Each command declares its own accepted flags and options independently.
54
+ <!-- {{/text}} -->
55
+
56
+ ### Command Details
57
+
58
+ <!-- {{text[mode=deep]: Describe each command's usage, options, and examples in detail. Create a #### subsection for each command. Extract from argument definitions and help messages in the source code.}} -->
59
+ #### sdd-forge help
60
+
61
+ Displays all available commands organized into sections: Project, Docs, Spec, Flow, and Info. Uses ANSI formatting for terminal output. Language is determined by `.sdd-forge/config.json` `lang` setting.
62
+
63
+ ```
64
+ sdd-forge help
65
+ sdd-forge --help
66
+ sdd-forge -h
67
+ ```
68
+
69
+ #### sdd-forge setup
70
+
71
+ Interactive wizard that registers a project and generates `.sdd-forge/config.json`. Prompts for project name, source path, output language, architecture type, document style, and default agent. Creates required directories (`.sdd-forge/output`, `docs`, `specs`), sets up `AGENTS.md`, `CLAUDE.md`, and skill templates.
72
+
73
+ ```
74
+ sdd-forge setup
75
+ sdd-forge setup --name myapp --path /path/to/src --type webapp/cakephp2
76
+ ```
77
+
78
+ When all required options (`--name`, `--path`, `--type`, `--purpose`, `--tone`) are provided, the wizard runs non-interactively.
79
+
80
+ #### sdd-forge upgrade
81
+
82
+ Upgrades template-derived files to match the currently installed sdd-forge version. Compares skill templates in `src/templates/skills/` with `.agents/skills/` and overwrites changed files. Converts symlinks to real files if needed. Also checks `config.json` for missing settings and prints configuration hints.
83
+
84
+ ```
85
+ sdd-forge upgrade
86
+ sdd-forge upgrade --dry-run
87
+ ```
88
+
89
+ #### sdd-forge presets list
90
+
91
+ Displays the preset inheritance tree in a visual tree format. Shows base, architecture, and leaf presets with their labels, aliases, and scan keys. Indicates which architecture layers have templates directories.
92
+
93
+ ```
94
+ sdd-forge presets list
95
+ ```
96
+
97
+ #### sdd-forge docs build
98
+
99
+ Runs the full documentation generation pipeline in sequence: `scan` → `enrich` → `init` → `data` → `text` → `readme` → `agents` → `translate` (if multi-language is configured). Displays a progress bar during execution. Steps that require an AI agent (`enrich`, `text`) are skipped if no `defaultAgent` is configured.
100
+
101
+ ```
102
+ sdd-forge docs build
103
+ sdd-forge docs build --force --verbose
104
+ sdd-forge docs build --dry-run
105
+ ```
106
+
107
+ | Option | Description |
108
+ |---|---|
109
+ | `--agent` | Override the default agent for AI-powered steps |
110
+ | `--force` | Force regeneration of chapter files even if they exist |
111
+ | `--dry-run` | Simulate the pipeline without writing files |
112
+ | `--verbose` | Show detailed progress output |
113
+
114
+ #### sdd-forge docs enrich
115
+
116
+ Uses AI to annotate each entry in `analysis.json` with `summary`, `detail`, `chapter`, and `role` metadata. Processes entries in batches based on total line count (default: 3000 lines per batch) or item count (default: 20 items). Supports resume — previously enriched entries are skipped, and progress is saved after each batch.
117
+
118
+ ```
119
+ sdd-forge docs enrich
120
+ sdd-forge docs enrich --dry-run --stdout
121
+ ```
122
+
123
+ #### sdd-forge docs readme
124
+
125
+ Generates `README.md` from preset templates using bottom-up template resolution. Resolves `{{data}}` and `{{text}}` directives, strips block directives, and normalizes formatting. Supports multi-language output by switching `docsDir` to language-specific directories.
126
+
127
+ ```
128
+ sdd-forge docs readme
129
+ sdd-forge docs readme --lang ja --output docs/ja/README.md
130
+ sdd-forge docs readme --dry-run
131
+ ```
132
+
133
+ #### sdd-forge docs forge
134
+
135
+ Iteratively improves documentation through AI agent and review cycles. Operates in three modes: `local` (default), `assist`, and `agent`. Pre-populates `{{data}}` placeholders and `{{text}}` directives from analysis before running the AI. Supports spec-based file targeting via keyword matching.
136
+
137
+ ```
138
+ sdd-forge docs forge --prompt "improve API documentation"
139
+ sdd-forge docs forge --spec specs/001-feature/spec.md --mode agent
140
+ sdd-forge docs forge --max-runs 5 --review-cmd "sdd-forge docs review"
141
+ ```
142
+
143
+ | Option | Description |
144
+ |---|---|
145
+ | `--prompt` | Improvement prompt for the AI agent |
146
+ | `--prompt-file` | Read prompt from a file |
147
+ | `--spec` | Path to spec file for scoped file targeting |
148
+ | `--max-runs` | Maximum iteration rounds (default: 3) |
149
+ | `--review-cmd` | Review command to run after each round (default: `sdd-forge docs review`) |
150
+ | `--mode` | Agent mode: `local`, `assist`, or `agent` |
151
+
152
+ #### sdd-forge docs translate
153
+
154
+ Translates default-language documentation to configured non-default languages using AI. Compares `mtime` of source and target files for differential translation. Respects `documentStyle.tone` settings for language-appropriate style (e.g., です/ます for Japanese polite tone).
155
+
156
+ ```
157
+ sdd-forge docs translate
158
+ sdd-forge docs translate --lang ja --force
159
+ sdd-forge docs translate --dry-run
160
+ ```
161
+
162
+ #### sdd-forge docs agents
163
+
164
+ Updates `AGENTS.md` by resolving `{{data: agents.sdd}}` and `{{data: agents.project}}` directives. The PROJECT section is refined by AI using generated docs, `package.json` scripts, and the SDD section as context.
165
+
166
+ ```
167
+ sdd-forge docs agents
168
+ sdd-forge docs agents --dry-run
169
+ ```
170
+
171
+ #### sdd-forge spec init
172
+
173
+ Creates a numbered feature branch and spec directory with `spec.md` and `qa.md` templates. Supports three modes: default (creates a git branch), `--worktree` (creates an isolated git worktree), and `--no-branch` (spec files only). Automatically detects the next available sequence number from existing specs and branches.
174
+
175
+ ```
176
+ sdd-forge spec init --title "contact-form"
177
+ sdd-forge spec init --title "login-feature" --base development --worktree
178
+ sdd-forge spec init --title "quick-fix" --no-branch --allow-dirty
179
+ ```
180
+
181
+ #### sdd-forge spec gate
182
+
183
+ Pre-implementation gate check that verifies spec completeness. Detects unresolved tokens (`TBD`, `TODO`, `FIXME`, `NEEDS CLARIFICATION`), unchecked tasks, missing required sections (`Clarifications`, `Open Questions`, `User Confirmation`, `Acceptance Criteria`), and unapproved user confirmation checkboxes. Optionally runs AI-powered guardrail compliance checking.
184
+
185
+ ```
186
+ sdd-forge spec gate --spec specs/001-feature/spec.md
187
+ sdd-forge spec gate --spec specs/001-feature/spec.md --phase post
188
+ sdd-forge spec gate --spec specs/001-feature/spec.md --skip-guardrail
189
+ ```
190
+
191
+ | Option | Description |
192
+ |---|---|
193
+ | `--spec` | Path to spec.md file (required) |
194
+ | `--phase` | `pre` (default) or `post` — pre phase skips Status/Acceptance Criteria unchecked items |
195
+ | `--skip-guardrail` | Skip guardrail AI compliance check |
196
+
197
+ #### sdd-forge spec guardrail
198
+
199
+ Manages project guardrail rules (immutable principles for spec compliance). The `init` subcommand generates `guardrail.md` from preset templates with language fallback. The `update` subcommand uses AI to propose additional project-specific articles based on `analysis.json`.
200
+
201
+ ```
202
+ sdd-forge spec guardrail init
203
+ sdd-forge spec guardrail init --force --dry-run
204
+ sdd-forge spec guardrail update --agent claude
205
+ ```
206
+
207
+ #### sdd-forge flow start
208
+
209
+ Runs the complete SDD flow: spec init → gate check → forge. Requires `--request` to describe the feature or fix. Automatically creates a spec, inserts the request text, runs gate validation, saves flow state to `flow.json`, and launches the forge process.
210
+
211
+ ```
212
+ sdd-forge flow start --request "add login feature"
213
+ sdd-forge flow start --request "fix pagination bug" --forge-mode agent --max-runs 5
214
+ sdd-forge flow start --request "refactor auth" --worktree
215
+ ```
216
+
217
+ Gate failure exits with code 2 and displays unresolved items. If user confirmation is missing, specific instructions are shown.
218
+
219
+ #### sdd-forge flow status
220
+
221
+ Displays or updates SDD flow progress stored in `.sdd-forge/flow.json`. Without options, shows spec path, branch info, step progress (with ✓/>/- icons), and requirements checklist. Supports step updates, requirement management, and flow archival.
222
+
223
+ ```
224
+ sdd-forge flow status
225
+ sdd-forge flow status --step gate --status done
226
+ sdd-forge flow status --summary '["implement auth", "add tests", "update docs"]'
227
+ sdd-forge flow status --req 0 --status done
228
+ sdd-forge flow status --archive
229
+ ```
230
+
231
+ #### sdd-forge flow review
232
+
233
+ Post-implementation code quality review with three phases: draft (generate improvement proposals), final (AI validation of each proposal as APPROVED/REJECTED), and apply. Extracts review targets from spec `## Scope` section or falls back to full `git diff` against the base branch. Generates `review.md` in the spec directory with checkbox-formatted results.
234
+
235
+ ```
236
+ sdd-forge flow review
237
+ sdd-forge flow review --dry-run
238
+ sdd-forge flow review --skip-confirm
239
+ ```
240
+ <!-- {{/text}} -->
241
+
242
+ ### Exit Codes and Output
243
+
244
+ <!-- {{text[mode=deep]: Define exit codes and describe stdout/stderr conventions in table format. Extract from process.exit() calls and output patterns in the source code.}} -->
245
+ | Exit Code | Meaning | Used By |
246
+ |---|---|---|
247
+ | `0` | Success | All commands on successful completion |
248
+ | `1` | General error | Unknown subcommands, missing required options, missing config, runtime errors, build pipeline failures |
249
+ | `2` | Gate failure | `flow start` when `spec gate` check fails (unresolved items or missing user confirmation) |
250
+
251
+ **stdout/stderr conventions:**
252
+
253
+ | Stream | Content |
254
+ |---|---|
255
+ | `stdout` | Primary command output: generated content (`--dry-run` previews), status displays (`flow status`), spec file paths (`spec init`), tree displays (`presets list`), and help text |
256
+ | `stderr` | Progress indicators, step labels (e.g., `[draft] Generating proposals...`), warning messages (prefixed with `WARN:`), error messages (prefixed with `ERROR:`), and build pipeline progress bars |
257
+
258
+ Commands that support `--dry-run` write the would-be output to `stdout` while logging dry-run notices to `stderr`. The `forge` command uses `stderr` for progress tickers (dots printed at regular intervals during agent calls) and verbose agent output when `--verbose` is enabled. The `build` command uses a structured progress bar on `stderr` that tracks each pipeline step with weighted progress values.
259
+ <!-- {{/text}} -->