sdd-forge 0.1.0-alpha.28 → 0.1.0-alpha.29

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 (135) hide show
  1. package/README.md +74 -50
  2. package/docs/cli_commands.md +321 -0
  3. package/docs/configuration.md +168 -0
  4. package/docs/ja/README.md +43 -19
  5. package/docs/ja/cli_commands.md +321 -0
  6. package/docs/ja/configuration.md +168 -0
  7. package/docs/ja/overview.md +121 -0
  8. package/docs/overview.md +121 -0
  9. package/package.json +1 -1
  10. package/src/docs/commands/agents.js +35 -28
  11. package/src/docs/commands/changelog.js +14 -16
  12. package/src/docs/commands/data.js +11 -11
  13. package/src/docs/commands/default-project.js +7 -18
  14. package/src/docs/commands/enrich.js +425 -0
  15. package/src/docs/commands/forge.js +76 -87
  16. package/src/docs/commands/init.js +25 -21
  17. package/src/docs/commands/readme.js +12 -13
  18. package/src/docs/commands/review.js +64 -40
  19. package/src/docs/commands/scan.js +97 -75
  20. package/src/docs/commands/setup.js +6 -23
  21. package/src/docs/commands/text.js +161 -45
  22. package/src/docs/commands/translate.js +6 -8
  23. package/src/docs/commands/upgrade.js +12 -14
  24. package/src/docs/data/agents.js +2 -2
  25. package/src/docs/data/docs.js +8 -4
  26. package/src/docs/data/project.js +9 -0
  27. package/src/docs/lib/command-context.js +28 -19
  28. package/src/docs/lib/data-source.js +11 -0
  29. package/src/docs/lib/forge-prompts.js +53 -28
  30. package/src/docs/lib/resolver-factory.js +1 -1
  31. package/src/docs/lib/review-parser.js +42 -0
  32. package/src/docs/lib/scan-source.js +14 -4
  33. package/src/docs/lib/scanner.js +110 -35
  34. package/src/docs/lib/template-merger.js +7 -2
  35. package/src/docs/lib/test-env-detection.js +5 -6
  36. package/src/docs/lib/text-prompts.js +98 -37
  37. package/src/docs.js +29 -13
  38. package/src/flow.js +11 -12
  39. package/src/help.js +7 -8
  40. package/src/lib/agent.js +99 -43
  41. package/src/lib/config.js +1 -52
  42. package/src/lib/i18n.js +187 -51
  43. package/src/lib/progress.js +25 -0
  44. package/src/lib/types.js +29 -21
  45. package/src/locale/en/prompts.json +11 -5
  46. package/src/locale/en/ui.json +13 -2
  47. package/src/locale/ja/prompts.json +11 -5
  48. package/src/locale/ja/ui.json +13 -2
  49. package/src/presets/base/data/package.js +52 -0
  50. package/src/presets/base/templates/en/AGENTS.sdd.md +64 -59
  51. package/src/presets/base/templates/en/development.md +5 -11
  52. package/src/presets/base/templates/en/overview.md +4 -1
  53. package/src/presets/base/templates/en/project_structure.md +1 -1
  54. package/src/presets/base/templates/ja/AGENTS.sdd.md +63 -58
  55. package/src/presets/base/templates/ja/development.md +5 -11
  56. package/src/presets/base/templates/ja/overview.md +4 -1
  57. package/src/presets/base/templates/ja/project_structure.md +1 -1
  58. package/src/presets/cakephp2/data/config.js +33 -52
  59. package/src/presets/cakephp2/data/controllers.js +16 -22
  60. package/src/presets/cakephp2/data/email.js +12 -14
  61. package/src/presets/cakephp2/data/libs.js +28 -54
  62. package/src/presets/cakephp2/data/models.js +12 -11
  63. package/src/presets/cakephp2/data/shells.js +8 -2
  64. package/src/presets/cakephp2/data/tests.js +12 -14
  65. package/src/presets/cakephp2/data/views.js +23 -48
  66. package/src/presets/cakephp2/preset.json +7 -23
  67. package/src/presets/cakephp2/scan/models.js +2 -0
  68. package/src/presets/cakephp2/templates/ja/development.md +0 -15
  69. package/src/presets/cakephp2/templates/ja/project_structure.md +3 -15
  70. package/src/presets/cakephp2/templates/ja/stack_and_ops.md +1 -1
  71. package/src/presets/cli/data/modules.js +11 -8
  72. package/src/presets/cli/templates/en/README.md +37 -0
  73. package/src/presets/cli/templates/en/commands.md +40 -0
  74. package/src/presets/cli/templates/en/config.md +40 -0
  75. package/src/presets/cli/templates/ja/commands.md +3 -3
  76. package/src/presets/cli/templates/ja/config.md +3 -3
  77. package/src/presets/laravel/data/config.js +19 -10
  78. package/src/presets/laravel/data/controllers.js +14 -4
  79. package/src/presets/laravel/data/models.js +13 -4
  80. package/src/presets/laravel/data/routes.js +12 -3
  81. package/src/presets/laravel/data/tables.js +14 -5
  82. package/src/presets/laravel/preset.json +9 -22
  83. package/src/presets/laravel/scan/controllers.js +4 -1
  84. package/src/presets/laravel/scan/models.js +4 -1
  85. package/src/presets/laravel/templates/ja/auth_and_session.md +3 -3
  86. package/src/presets/laravel/templates/ja/controller_routes.md +1 -1
  87. package/src/presets/library/templates/ja/public_api.md +3 -3
  88. package/src/presets/library/templates/ja/usage.md +2 -2
  89. package/src/presets/node-cli/preset.json +2 -6
  90. package/src/presets/node-cli/templates/en/README.md +31 -0
  91. package/src/presets/node-cli/templates/en/cli_commands.md +30 -0
  92. package/src/presets/node-cli/templates/en/configuration.md +30 -0
  93. package/src/presets/node-cli/templates/en/development_testing.md +48 -0
  94. package/src/presets/node-cli/templates/en/internal_design.md +35 -0
  95. package/src/presets/node-cli/templates/en/overview.md +30 -0
  96. package/src/presets/node-cli/templates/ja/cli_commands.md +7 -7
  97. package/src/presets/node-cli/templates/ja/configuration.md +6 -6
  98. package/src/presets/node-cli/templates/ja/development_testing.md +6 -15
  99. package/src/presets/node-cli/templates/ja/internal_design.md +7 -7
  100. package/src/presets/node-cli/templates/ja/overview.md +6 -6
  101. package/src/presets/symfony/data/config.js +18 -10
  102. package/src/presets/symfony/data/controllers.js +10 -4
  103. package/src/presets/symfony/data/entities.js +11 -6
  104. package/src/presets/symfony/data/routes.js +10 -4
  105. package/src/presets/symfony/data/tables.js +10 -4
  106. package/src/presets/symfony/preset.json +9 -22
  107. package/src/presets/symfony/scan/controllers.js +4 -1
  108. package/src/presets/symfony/scan/entities.js +4 -1
  109. package/src/presets/symfony/templates/ja/auth_and_session.md +3 -3
  110. package/src/presets/symfony/templates/ja/controller_routes.md +1 -1
  111. package/src/presets/webapp/data/controllers.js +13 -12
  112. package/src/presets/webapp/data/models.js +13 -12
  113. package/src/presets/webapp/data/routes.js +11 -13
  114. package/src/presets/webapp/data/shells.js +13 -12
  115. package/src/presets/webapp/data/tables.js +7 -4
  116. package/src/presets/webapp/data/webapp-data-source.js +26 -0
  117. package/src/presets/webapp/templates/ja/auth_and_session.md +4 -4
  118. package/src/presets/webapp/templates/ja/batch_and_shell.md +1 -1
  119. package/src/presets/webapp/templates/ja/business_logic.md +3 -3
  120. package/src/presets/webapp/templates/ja/controller_routes.md +2 -2
  121. package/src/presets/webapp/templates/ja/database_architecture.md +2 -2
  122. package/src/presets-cmd.js +3 -7
  123. package/src/specs/commands/gate.js +7 -8
  124. package/src/specs/commands/init.js +8 -8
  125. package/src/templates/config.example.json +3 -3
  126. package/src/templates/skills/sdd-flow-close/SKILL.md +31 -2
  127. package/src/templates/skills/sdd-flow-start/SKILL.md +3 -3
  128. package/docs/01_overview.md +0 -101
  129. package/docs/02_cli_commands.md +0 -287
  130. package/docs/03_configuration.md +0 -139
  131. package/docs/04_internal_design.md +0 -302
  132. package/docs/ja/01_overview.md +0 -98
  133. package/docs/ja/02_cli_commands.md +0 -309
  134. package/docs/ja/03_configuration.md +0 -136
  135. package/docs/ja/04_internal_design.md +0 -310
package/README.md CHANGED
@@ -8,21 +8,46 @@
8
8
 
9
9
  > **Alpha:** This tool is currently in alpha. APIs, command structure, and configuration formats may change without notice. Not recommended for production use.
10
10
 
11
- **A CLI tool that automatically generates and maintains project documentation using source code analysis + AI.**
11
+ **A CLI tool that generates documentation from programmatic source code analysis based on facts, not AI guesswork.**
12
12
 
13
- Statically analyzes your codebase and combines templates with AI to auto-generate `docs/`.
14
- The Spec-Driven Development (SDD) workflow also automates documentation updates when adding features or making changes.
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
15
25
 
16
26
  ## Features
17
27
 
18
- - **Zero dependencies** — Runs on Node.js 18+ only. No npm packages required
19
- - **Automatic source analysis** — Statically analyzes controllers, models, routes, and config files to extract structural data
20
- - **AI document generation** — AI automatically expands `{{text}}` directives in templates
21
- - **Template inheritance** — Four-layer inheritance (base → arch → preset → project-local) for full customization
22
- - **SDD workflow** Manage the development cycle of spec gate → implement → forge → review via commands
23
- - **Multi-language support** Auto-generate documentation in multiple languages using translate/generate modes
24
- - **AI agent integration** Supports Claude Code (skills) and Codex CLI
25
- - **Multi-preset** — Supports Node.js CLI / CakePHP2 / Laravel / Symfony
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
26
51
 
27
52
  ## Quick Start
28
53
 
@@ -39,44 +64,44 @@ yarn global add <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
39
64
  pnpm add -g <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
40
65
  </pre>
41
66
 
42
- ### Setup & Document Generation
67
+ ### Setup & Generate
43
68
 
44
69
  <pre>
45
70
  # 1. Register your project (interactive wizard)
46
71
  <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> setup
47
72
 
48
- # 2. Generate all documentation (scan → init → data → text → readme → agents → translate)
73
+ # 2. Generate all documentation (scan → enrich → init → data → text → readme → agents → translate)
49
74
  <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> build
50
75
  </pre>
51
76
 
52
- This will generate `docs/` and `README.md` in one step.
77
+ That's it `docs/` and `README.md` are generated.
53
78
 
54
79
  ## Commands
55
80
 
56
- ### Document Generation
81
+ ### Documentation Generation
57
82
 
58
83
  | Command | Description |
59
84
  |---|---|
60
- | `setup` | Register project + generate config file |
61
- | `build` | Run the full document generation pipeline |
85
+ | `setup` | Register project + generate config |
86
+ | `build` | Run the full documentation pipeline |
62
87
  | `scan` | Analyze source code → `analysis.json` |
63
88
  | `init` | Initialize `docs/` from templates |
64
- | `data` | Resolve `{{data}}` directives with analyzed data |
89
+ | `data` | Resolve `{{data}}` directives with analysis data |
65
90
  | `text` | Resolve `{{text}}` directives with AI |
66
- | `readme` | Auto-generate `README.md` from `docs/` |
67
- | `forge` | Iteratively improve documentation with AI |
68
- | `review` | Check documentation quality |
69
- | `translate` | Translate to other languages (from default language) |
70
- | `upgrade` | Update preset templates to the latest version |
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 |
71
96
 
72
97
  ### SDD Workflow
73
98
 
74
99
  | Command | Description |
75
100
  |---|---|
76
- | `spec` | Create a spec document + feature branch |
101
+ | `spec` | Create spec + feature branch |
77
102
  | `gate` | Pre-implementation spec check |
78
103
  | `flow` | Run the SDD workflow automatically |
79
- | `changelog` | Generate change history from specs/ |
104
+ | `changelog` | Generate change log from specs/ |
80
105
  | `agents` | Update AGENTS.md |
81
106
 
82
107
  ### Project Management
@@ -89,74 +114,73 @@ This will generate `docs/` and `README.md` in one step.
89
114
 
90
115
  ## SDD Workflow
91
116
 
92
- Feature development and change flow:
117
+ Feature development flow:
93
118
 
94
119
  ```
95
- spec Create a spec (feature branch + spec.md)
120
+ spec Create spec (feature branch + spec.md)
96
121
 
97
- gate Spec gate check (PASS when no unresolved issues)
122
+ gate Spec gate check verified by program (not AI)
98
123
 
99
- implement Write code after gate PASS
124
+ implement Code after gate PASS
100
125
 
101
- forge Auto-update documentation
126
+ forge AI updates documentation
102
127
 
103
- review Quality check (repeat until PASS)
128
+ review AI quality check (repeat until PASS)
104
129
  ```
105
130
 
106
131
  ### AI Agent Integration
107
132
 
108
133
  #### Claude Code
109
134
 
110
- Run the SDD workflow using skills:
135
+ Run SDD workflows via skills:
111
136
 
112
137
  ```
113
- /sdd-flow-start — Start spec creation → gate → implementation
114
- /sdd-flow-close — Finish with forge → review → commit → merge
138
+ /sdd-flow-start — create spec → gate → start implementation
139
+ /sdd-flow-close — forge → review → commit → merge
115
140
  ```
116
141
 
117
142
  #### Codex CLI
118
143
 
119
- Run the workflow from prompts:
144
+ Run workflows from the `$` prompt:
120
145
 
121
146
  ```
122
- $sdd-flow-start — Start spec creation → gate → implementation
123
- $sdd-flow-close — Finish with forge → review → commit → merge
147
+ $sdd-flow-start — create spec → gate → start implementation
148
+ $sdd-flow-close — forge → review → commit → merge
124
149
  ```
125
150
 
126
151
  ## Configuration
127
152
 
128
- Running `sdd-forge setup` generates `.sdd-forge/config.json`.
153
+ `sdd-forge setup` generates `.sdd-forge/config.json`:
129
154
 
130
155
  ```jsonc
131
156
  {
132
- "type": "cli/node-cli", // Project type (preset selection)
133
- "lang": "en", // Documentation language
157
+ "type": "cli/node-cli", // project type (preset selection)
158
+ "lang": "en", // documentation language
134
159
  "defaultAgent": "claude", // AI agent
135
- "providers": { ... } // Agent configuration
160
+ "providers": { ... } // agent settings
136
161
  }
137
162
  ```
138
163
 
139
164
  ### Customization
140
165
 
141
- You can add project-specific templates and data sources:
166
+ Add project-specific templates and data sources:
142
167
 
143
168
  ```
144
169
  .sdd-forge/
145
170
  ├── templates/{lang}/
146
- │ ├── docs/ ← Chapter templates / README overrides
171
+ │ ├── docs/ ← chapter template & README overrides
147
172
  │ └── specs/ ← spec.md / qa.md templates
148
- └── data/ ← Custom data source modules
173
+ └── data/ ← custom data source modules
149
174
  ```
150
175
 
151
176
  ## Documentation
152
177
 
153
- <!-- {{data: docs.chapters("Chapter|Overview")}} -->
154
- | Chapter | Overview |
178
+ <!-- {{data: docs.chapters("Chapter|Summary")}} -->
179
+ | Chapter | Summary |
155
180
  | --- | --- |
156
- | [01. System Overview](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/01_overview.md) | This chapter describes the overall architecture of sdd-forge a Node.js CLI tool that automates documentation genera… |
157
- | [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/02_cli_commands.md) | This chapter covers all 19 subcommands available in `sdd-forge`, organized by their routing layer: documentation comm… |
158
- | [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/03_configuration.md) | |
159
- | [04. Internal Design](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/04_internal_design.md) | |
181
+ | [01. Tool Overview and Architecture](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/overview.md) | This chapter introduces `sdd-forge`, a CLI tool that automates documentation generation from source code analysis and… |
182
+ | [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/cli_commands.md) | This chapter documents all 20 CLI commands available in sdd-forge, covering project setup, documentation generation, … |
183
+ | [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/configuration.md) | This chapter covers the configuration files that sdd-forge reads to tailor its behavior to your project, including th… |
160
184
  <!-- {{/data}} -->
161
185
 
162
186
  ## License
@@ -0,0 +1,321 @@
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
+ This chapter documents all 20 CLI commands available in sdd-forge, covering project setup, documentation generation, spec management, and SDD workflow automation. Commands are routed through a three-layer dispatch architecture: the top-level entry point (`sdd-forge.js`) delegates to one of five dispatchers (`docs`, `spec`, `flow`, `presets-cmd`, `help`), which in turn load the appropriate implementation module.
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 | Dispatcher | Description | Key Options |
15
+ |---|---|---|---|
16
+ | `help` | `help.js` | Display all available commands with descriptions | — |
17
+ | `setup` | `docs` | Interactive project registration and config generation | `--name`, `--path`, `--type`, `--agent`, `--lang`, `--dry-run` |
18
+ | `upgrade` | `docs` | Upgrade template-derived skill files to the current sdd-forge version | `--dry-run` |
19
+ | `default [name]` | `docs` | List registered projects or set the default project | `[name]` positional arg |
20
+ | `build` | `docs` | Run the full documentation pipeline: scan → enrich → init → data → text → readme → agents → [translate] | `--agent`, `--force`, `--verbose`, `--dry-run` |
21
+ | `init` | `docs` | Initialize `docs/` from preset templates | `--force`, `--dry-run` |
22
+ | `forge` | `docs` | Iteratively improve docs using AI based on a prompt and spec | `--prompt`, `--spec`, `--max-runs`, `--mode`, `--agent`, `--dry-run` |
23
+ | `review` | `docs` | Run quality checks against the review checklist | — |
24
+ | `changelog` | `docs` | Generate `change_log.md` from `specs/` directories | — |
25
+ | `agents` | `docs` | Update `AGENTS.md` with SDD and project sections | `--sdd`, `--project`, `--dry-run` |
26
+ | `readme` | `docs` | Generate `README.md` from docs content | `--dry-run` |
27
+ | `translate` | `docs` | Translate default-language docs to configured non-default languages via AI | `--lang`, `--force`, `--dry-run` |
28
+ | `scan` | `docs` | Analyse source code and write `.sdd-forge/output/analysis.json` | — |
29
+ | `enrich` | `docs` | Enrich `analysis.json` entries with AI-generated roles, summaries, and chapter classifications | `--agent` |
30
+ | `data` | `docs` | Resolve all `{{data}}` directives in `docs/` files | `--dry-run` |
31
+ | `text` | `docs` | Resolve all `{{text}}` directives in `docs/` files using an AI agent | `--agent`, `--dry-run` |
32
+ | `spec` | `spec` | Create a numbered feature branch and initialise `specs/NNN-slug/spec.md` | `--title`, `--base`, `--no-branch`, `--worktree`, `--allow-dirty`, `--dry-run` |
33
+ | `gate` | `spec` | Validate a spec file for unresolved items before (or after) implementation | `--spec`, `--phase` |
34
+ | `flow` | `flow` (direct) | Automate the full SDD flow: spec init → gate → forge | `--request`, `--title`, `--spec`, `--agent`, `--max-runs`, `--forge-mode`, `--no-branch`, `--worktree`, `--dry-run` |
35
+ | `presets list` | `presets-cmd` (direct) | Display the preset inheritance tree | — |
36
+ <!-- {{/text}} -->
37
+
38
+ ### Global Options
39
+
40
+ <!-- {{text[mode=deep]: Describe global options shared by all commands in table format. Extract from argument parsing logic in the source code.}} -->
41
+ The following options are handled by `sdd-forge.js` before any subcommand is dispatched and apply regardless of which command is invoked.
42
+
43
+ | Option | Short | Description |
44
+ |---|---|---|
45
+ | `--project <name>` | — | Select a registered project by name. Sets `SDD_SOURCE_ROOT` and `SDD_WORK_ROOT` environment variables for the duration of the command. |
46
+ | `--version` | `-v`, `-V` | Print the installed sdd-forge package version and exit. |
47
+ | `--help` | `-h` | Display the top-level command list. When passed to an individual command, show that command's own help text. |
48
+
49
+ > **Note:** `--project` is silently stripped from `process.argv` before the subcommand arguments are forwarded to the dispatcher, so individual command modules never see it.
50
+ <!-- {{/text}} -->
51
+
52
+ ### Command Details
53
+
54
+ <!-- {{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.}} -->
55
+ #### help
56
+
57
+ Prints all available commands grouped by section (Project, Build, Docs, Scan, Spec, Flow, Info) along with a one-line description for each, sourced from the i18n `ui:help.commands.*` keys. The package version is read from `package.json` at runtime.
58
+
59
+ ```
60
+ sdd-forge help
61
+ sdd-forge # no arguments also shows help
62
+ sdd-forge -h
63
+ ```
64
+
65
+ #### setup
66
+
67
+ Launches an interactive wizard that registers a project, creates `.sdd-forge/config.json`, generates `AGENTS.md`, creates a `CLAUDE.md` symlink, and installs skill files under `.agents/skills/` and `.claude/skills/`. Each step can be supplied non-interactively via CLI flags.
68
+
69
+ ```
70
+ sdd-forge setup
71
+ sdd-forge setup --name myapp --path /path/to/src --type webapp/cakephp2 --agent claude
72
+ ```
73
+
74
+ | Option | Description |
75
+ |---|---|
76
+ | `--name <name>` | Project name |
77
+ | `--path <path>` | Source code directory |
78
+ | `--work-root <path>` | Working root (defaults to source path) |
79
+ | `--type <preset>` | Preset identifier (e.g. `webapp/cakephp2`, `cli/node-cli`) |
80
+ | `--purpose <text>` | Documentation purpose description |
81
+ | `--tone <text>` | Documentation tone |
82
+ | `--agent <name>` | Default AI agent name |
83
+ | `--lang <code>` | Output language code |
84
+ | `--set-default` | Mark this project as the default |
85
+ | `--dry-run` | Show what would be written without writing |
86
+
87
+ #### upgrade
88
+
89
+ Upgrades template-managed files — specifically the skill `SKILL.md` files under `.agents/skills/` — to match the templates bundled with the currently installed sdd-forge version. Safe to run repeatedly; only overwrites template-derived content and never touches `config.json`.
90
+
91
+ ```
92
+ sdd-forge upgrade
93
+ sdd-forge upgrade --dry-run
94
+ ```
95
+
96
+ #### default
97
+
98
+ Without arguments, lists all registered projects and marks the current default. With a project name, changes the default.
99
+
100
+ ```
101
+ sdd-forge default # list projects
102
+ sdd-forge default myapp # set "myapp" as default
103
+ ```
104
+
105
+ #### build
106
+
107
+ Executes the full documentation generation pipeline in order: `scan → enrich → init → data → text → readme → agents`. If `output.isMultiLang` is `true` in the configuration, a `translate` (or per-language generate) step is appended. Progress is reported via a weighted progress bar.
108
+
109
+ ```
110
+ sdd-forge build
111
+ sdd-forge build --agent claude --force --verbose
112
+ sdd-forge build --dry-run
113
+ ```
114
+
115
+ | Option | Description |
116
+ |---|---|
117
+ | `--agent <name>` | AI agent to use for `enrich` and `text` steps (overrides `config.defaultAgent`) |
118
+ | `--force` | Force re-initialisation of existing docs files |
119
+ | `--verbose` | Show per-step log output |
120
+ | `--dry-run` | Skip all file writes |
121
+
122
+ #### init
123
+
124
+ Initialises (or re-initialises) `docs/` from the preset templates. Existing files are skipped unless `--force` is set.
125
+
126
+ ```
127
+ sdd-forge init
128
+ sdd-forge init --force
129
+ ```
130
+
131
+ #### forge
132
+
133
+ Iteratively improves `docs/` content by prompting an AI agent with the given `--prompt` and, optionally, a linked spec. Runs up to `--max-runs` iterations until the review passes.
134
+
135
+ ```
136
+ sdd-forge forge --prompt "add enrich command section"
137
+ sdd-forge forge --prompt "describe gate phases" --spec specs/042-gate-docs/spec.md --max-runs 3
138
+ ```
139
+
140
+ | Option | Description |
141
+ |---|---|
142
+ | `--prompt <text>` | Improvement request (required) |
143
+ | `--spec <path>` | Path to the spec file for context |
144
+ | `--max-runs <n>` | Maximum improvement iterations (default: 5) |
145
+ | `--mode <mode>` | `local` \| `assist` \| `agent` |
146
+ | `--agent <name>` | Override the configured default agent |
147
+ | `--dry-run` | Skip writes |
148
+
149
+ #### review
150
+
151
+ Runs quality checks against the review checklist (`templates/review-checklist.md`) and reports any issues found in `docs/`. Exits non-zero if the check fails.
152
+
153
+ ```
154
+ sdd-forge review
155
+ ```
156
+
157
+ #### changelog
158
+
159
+ Reads all `specs/NNN-*/spec.md` files and generates or updates `change_log.md` in the project root.
160
+
161
+ ```
162
+ sdd-forge changelog
163
+ ```
164
+
165
+ #### agents
166
+
167
+ Updates `AGENTS.md` with the latest SDD section (from the `agents.sdd` data source) and/or the project section (from `agents.project`). Defaults to updating both sections.
168
+
169
+ ```
170
+ sdd-forge agents
171
+ sdd-forge agents --sdd # update SDD section only
172
+ sdd-forge agents --project # update project section only
173
+ sdd-forge agents --dry-run
174
+ ```
175
+
176
+ #### readme
177
+
178
+ Generates `README.md` in the project root from the docs content and preset README template.
179
+
180
+ ```
181
+ sdd-forge readme
182
+ sdd-forge readme --dry-run
183
+ ```
184
+
185
+ #### translate
186
+
187
+ Translates the default-language `docs/` files into every non-default language configured in `output.languages`. Re-translates a file only when its source has a newer `mtime` than the existing translation, unless `--force` is set.
188
+
189
+ ```
190
+ sdd-forge translate
191
+ sdd-forge translate --lang ja --force
192
+ sdd-forge translate --dry-run
193
+ ```
194
+
195
+ | Option | Description |
196
+ |---|---|
197
+ | `--lang <code>` | Translate into this language only |
198
+ | `--force` | Re-translate all files regardless of mtime |
199
+ | `--dry-run` | Show what would be translated without writing |
200
+
201
+ #### scan
202
+
203
+ Parses the source code under the configured `sourcePath` and writes structured analysis data to `.sdd-forge/output/analysis.json`.
204
+
205
+ ```
206
+ sdd-forge scan
207
+ ```
208
+
209
+ #### enrich
210
+
211
+ Reads `analysis.json` and uses an AI agent to annotate each entry with a `role`, `summary`, `detail`, and chapter classification. The enriched result is written back to `analysis.json`.
212
+
213
+ ```
214
+ sdd-forge enrich --agent claude
215
+ ```
216
+
217
+ #### data
218
+
219
+ Resolves all `{{data: …}}` directives in `docs/` files in place, replacing directive blocks with generated Markdown. Skips `{{text}}` blocks without re-processing them.
220
+
221
+ ```
222
+ sdd-forge data
223
+ sdd-forge data --dry-run
224
+ ```
225
+
226
+ #### text
227
+
228
+ Calls an AI agent for each `{{text: …}}` directive found in `docs/` files and inserts the generated text. Only directives with no existing body (or with a stale body when `--force` is used) are processed.
229
+
230
+ ```
231
+ sdd-forge text --agent claude
232
+ sdd-forge text --agent claude --dry-run
233
+ ```
234
+
235
+ #### spec
236
+
237
+ Creates a numbered feature branch (`feature/NNN-slug`) and scaffolds `specs/NNN-slug/spec.md` and `specs/NNN-slug/qa.md`. Supports three branching strategies: branch (default), worktree, or spec-only.
238
+
239
+ ```
240
+ sdd-forge spec --title "contact-form"
241
+ sdd-forge spec --title "contact-form" --worktree
242
+ sdd-forge spec --title "contact-form" --no-branch
243
+ sdd-forge spec --title "contact-form" --dry-run
244
+ ```
245
+
246
+ | Option | Description |
247
+ |---|---|
248
+ | `--title <text>` | Feature name — used for branch/directory slug (required) |
249
+ | `--base <branch>` | Base branch (defaults to current HEAD) |
250
+ | `--no-branch` | Create spec files only, no branch |
251
+ | `--worktree` | Create an isolated git worktree under `.sdd-forge/worktree/` |
252
+ | `--allow-dirty` | Skip the working-tree cleanliness check |
253
+ | `--dry-run` | Print what would be created without writing |
254
+
255
+ #### gate
256
+
257
+ Validates a `spec.md` file for completeness before (`--phase pre`, default) or after (`--phase post`) implementation. Checks for unresolved tokens (`TBD`, `TODO`, `FIXME`, `[NEEDS CLARIFICATION]`), unchecked task items, required sections (`## Clarifications`, `## Open Questions`, `## User Confirmation`, `## Acceptance Criteria`), and the `- [x] User approved this spec` approval marker.
258
+
259
+ ```
260
+ sdd-forge gate --spec specs/042-contact-form/spec.md
261
+ sdd-forge gate --spec specs/042-contact-form/spec.md --phase post
262
+ ```
263
+
264
+ | Option | Description |
265
+ |---|---|
266
+ | `--spec <path>` | Path to the spec file (required) |
267
+ | `--phase pre\|post` | Validation phase; `pre` skips task-item checks in Acceptance Criteria sections |
268
+
269
+ #### flow
270
+
271
+ Automates the complete SDD flow: creates a spec (if `--spec` is not given), runs `gate`, and — on gate success — runs `forge`. Exits with code `2` and prints `NEEDS_INPUT` when gate fails, listing up to eight blocking issues.
272
+
273
+ ```
274
+ sdd-forge flow --request "Add pagination to the user list"
275
+ sdd-forge flow --request "Fix CSV export encoding" --spec specs/040-csv-fix/spec.md
276
+ sdd-forge flow --request "Refactor auth module" --worktree --agent claude --max-runs 3
277
+ ```
278
+
279
+ | Option | Description |
280
+ |---|---|
281
+ | `--request <text>` | The user's change request (required) |
282
+ | `--title <text>` | Spec title slug (derived from `--request` if omitted) |
283
+ | `--spec <path>` | Use an existing spec instead of creating one |
284
+ | `--agent <name>` | AI agent to pass to `forge` |
285
+ | `--max-runs <n>` | Maximum `forge` iterations (default: 5) |
286
+ | `--forge-mode <mode>` | `local` \| `assist` \| `agent` (default: `local`) |
287
+ | `--no-branch` | Create spec without a new branch |
288
+ | `--worktree` | Create an isolated git worktree |
289
+ | `--dry-run` | Skip writes in spec-init and forge steps |
290
+
291
+ #### presets list
292
+
293
+ Displays the full preset inheritance tree, showing arch-level nodes and their leaf presets together with aliases and configured scan categories.
294
+
295
+ ```
296
+ sdd-forge presets list
297
+ sdd-forge presets # also shows the list
298
+ ```
299
+ <!-- {{/text}} -->
300
+
301
+ ### Exit Codes and Output
302
+
303
+ <!-- {{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.}} -->
304
+ | Exit Code | Meaning | Typical Source |
305
+ |---|---|---|
306
+ | `0` | Success | Normal completion of any command |
307
+ | `1` | General error | Unknown subcommand, missing required argument, file not found, AI agent failure, gate error thrown as exception |
308
+ | `2` | Gate check failed (blocking) | `flow` command when `gate` exits non-zero |
309
+
310
+ **stdout conventions**
311
+
312
+ Informational progress messages, generated Markdown previews (dry-run), and final success summaries are written to `stdout`. The `build` command uses a weighted progress bar (via `createProgress()`) that prints step labels and optionally verbose per-step logs when `--verbose` is set. Commands that produce structured output (e.g. `default` listing projects, `presets list` showing the tree) write their formatted text directly to `stdout`.
313
+
314
+ **stderr conventions**
315
+
316
+ Error messages — including unknown command notices, missing `--spec` warnings, gate failure reason lists, and pipeline step errors — are written to `stderr` via `console.error()`. The `flow` command forwards both `stdout` and `stderr` from its child processes (`spec init`, `gate`, `forge`) so that all output remains visible to the caller.
317
+
318
+ **dry-run output**
319
+
320
+ When `--dry-run` is active, commands print `[dry-run]`-prefixed lines describing each write operation that would occur, then exit `0` without modifying the filesystem.
321
+ <!-- {{/text}} -->