sdd-forge 0.1.0-alpha.29 → 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 (118) hide show
  1. package/README.md +5 -5
  2. package/docs/cli_commands.md +133 -195
  3. package/docs/configuration.md +99 -76
  4. package/docs/internal_design.md +359 -0
  5. package/docs/ja/README.md +5 -5
  6. package/docs/ja/cli_commands.md +289 -168
  7. package/docs/ja/configuration.md +152 -82
  8. package/docs/ja/internal_design.md +333 -0
  9. package/docs/ja/overview.md +74 -86
  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 +98 -75
  16. package/package.json +1 -1
  17. package/src/README.md +1 -1
  18. package/src/docs/commands/agents.js +1 -1
  19. package/src/docs/commands/data.js +5 -0
  20. package/src/docs/commands/enrich.js +58 -44
  21. package/src/docs/commands/forge.js +6 -7
  22. package/src/docs/commands/readme.js +32 -2
  23. package/src/docs/commands/review.js +1 -2
  24. package/src/docs/commands/text.js +6 -12
  25. package/src/docs/commands/translate.js +101 -70
  26. package/src/docs/data/project.js +1 -1
  27. package/src/docs/lib/command-context.js +4 -3
  28. package/src/docs/lib/data-source.js +30 -3
  29. package/src/docs/lib/directive-parser.js +6 -2
  30. package/src/docs.js +17 -14
  31. package/src/flow/commands/cleanup.js +86 -0
  32. package/src/flow/commands/merge.js +88 -0
  33. package/src/flow/commands/review.js +301 -0
  34. package/src/flow/commands/start.js +213 -0
  35. package/src/flow/commands/status.js +209 -0
  36. package/src/flow.js +52 -207
  37. package/src/help.js +18 -18
  38. package/src/lib/agent.js +82 -20
  39. package/src/lib/flow-state.js +86 -6
  40. package/src/locale/en/messages.json +19 -7
  41. package/src/locale/en/ui.json +42 -46
  42. package/src/locale/ja/messages.json +19 -7
  43. package/src/locale/ja/ui.json +42 -46
  44. package/src/presets/base/templates/en/AGENTS.sdd.md +4 -104
  45. package/src/presets/base/templates/en/development.md +1 -1
  46. package/src/presets/base/templates/en/guardrail.md +18 -0
  47. package/src/presets/base/templates/en/overview.md +3 -3
  48. package/src/presets/base/templates/en/project_structure.md +1 -1
  49. package/src/presets/base/templates/en/stack_and_ops.md +1 -1
  50. package/src/presets/base/templates/ja/AGENTS.sdd.md +4 -104
  51. package/src/presets/base/templates/ja/development.md +1 -1
  52. package/src/presets/base/templates/ja/guardrail.md +18 -0
  53. package/src/presets/base/templates/ja/overview.md +3 -3
  54. package/src/presets/base/templates/ja/project_structure.md +1 -1
  55. package/src/presets/base/templates/ja/stack_and_ops.md +1 -1
  56. package/src/presets/cakephp2/data/config.js +29 -10
  57. package/src/presets/cakephp2/data/libs.js +8 -5
  58. package/src/presets/cakephp2/data/models.js +9 -5
  59. package/src/presets/cakephp2/data/tables.js +5 -2
  60. package/src/presets/cakephp2/data/views.js +6 -6
  61. package/src/presets/cakephp2/templates/en/guardrail.md +11 -0
  62. package/src/presets/cakephp2/templates/ja/guardrail.md +11 -0
  63. package/src/presets/cli/data/modules.js +2 -2
  64. package/src/presets/cli/templates/en/README.md +2 -2
  65. package/src/presets/cli/templates/en/commands.md +1 -1
  66. package/src/presets/cli/templates/en/config.md +1 -1
  67. package/src/presets/cli/templates/en/guardrail.md +8 -0
  68. package/src/presets/cli/templates/ja/README.md +2 -2
  69. package/src/presets/cli/templates/ja/commands.md +1 -1
  70. package/src/presets/cli/templates/ja/config.md +1 -1
  71. package/src/presets/cli/templates/ja/guardrail.md +8 -0
  72. package/src/presets/laravel/data/commands.js +2 -2
  73. package/src/presets/laravel/data/config.js +6 -4
  74. package/src/presets/laravel/data/controllers.js +5 -3
  75. package/src/presets/laravel/data/tables.js +2 -2
  76. package/src/presets/laravel/templates/en/guardrail.md +11 -0
  77. package/src/presets/laravel/templates/ja/guardrail.md +11 -0
  78. package/src/presets/library/templates/en/guardrail.md +5 -0
  79. package/src/presets/library/templates/ja/README.md +2 -2
  80. package/src/presets/library/templates/ja/guardrail.md +5 -0
  81. package/src/presets/library/templates/ja/public_api.md +1 -1
  82. package/src/presets/library/templates/ja/usage.md +1 -1
  83. package/src/presets/node-cli/templates/en/guardrail.md +5 -0
  84. package/src/presets/node-cli/templates/ja/guardrail.md +5 -0
  85. package/src/presets/symfony/data/commands.js +2 -2
  86. package/src/presets/symfony/data/config.js +6 -4
  87. package/src/presets/symfony/data/controllers.js +5 -3
  88. package/src/presets/symfony/data/tables.js +2 -2
  89. package/src/presets/symfony/templates/en/guardrail.md +11 -0
  90. package/src/presets/symfony/templates/ja/guardrail.md +11 -0
  91. package/src/presets/webapp/data/controllers.js +2 -2
  92. package/src/presets/webapp/data/shells.js +2 -2
  93. package/src/presets/webapp/data/tables.js +2 -2
  94. package/src/presets/webapp/templates/en/guardrail.md +14 -0
  95. package/src/presets/webapp/templates/ja/README.md +2 -2
  96. package/src/presets/webapp/templates/ja/auth_and_session.md +1 -1
  97. package/src/presets/webapp/templates/ja/batch_and_shell.md +1 -1
  98. package/src/presets/webapp/templates/ja/business_logic.md +1 -1
  99. package/src/presets/webapp/templates/ja/controller_routes.md +1 -1
  100. package/src/presets/webapp/templates/ja/database_architecture.md +1 -1
  101. package/src/presets/webapp/templates/ja/db_tables.md +1 -1
  102. package/src/presets/webapp/templates/ja/guardrail.md +14 -0
  103. package/src/sdd-forge.js +24 -81
  104. package/src/{docs/commands/setup.js → setup.js} +74 -151
  105. package/src/spec/commands/gate.js +310 -0
  106. package/src/spec/commands/guardrail.js +251 -0
  107. package/src/{specs → spec}/commands/init.js +18 -11
  108. package/src/spec.js +12 -2
  109. package/src/templates/config.example.json +30 -11
  110. package/src/templates/skills/sdd-forge.flow-impl/SKILL.md +103 -0
  111. package/src/templates/skills/{sdd-flow-close → sdd-forge.flow-merge}/SKILL.md +43 -14
  112. package/src/templates/skills/{sdd-flow-start → sdd-forge.flow-plan}/SKILL.md +38 -19
  113. package/src/templates/skills/sdd-forge.flow-status/SKILL.md +94 -0
  114. package/src/{docs/commands/upgrade.js → upgrade.js} +9 -8
  115. package/src/docs/commands/default-project.js +0 -49
  116. package/src/lib/projects.js +0 -127
  117. package/src/specs/commands/gate.js +0 -142
  118. package/src/templates/skills/sdd-flow-status/SKILL.md +0 -71
package/README.md CHANGED
@@ -104,11 +104,10 @@ That's it — `docs/` and `README.md` are generated.
104
104
  | `changelog` | Generate change log from specs/ |
105
105
  | `agents` | Update AGENTS.md |
106
106
 
107
- ### Project Management
107
+ ### Other
108
108
 
109
109
  | Command | Description |
110
110
  |---|---|
111
- | `default` | Set the default project |
112
111
  | `presets` | List available presets |
113
112
  | `help` | Show command list |
114
113
 
@@ -178,9 +177,10 @@ Add project-specific templates and data sources:
178
177
  <!-- {{data: docs.chapters("Chapter|Summary")}} -->
179
178
  | Chapter | Summary |
180
179
  | --- | --- |
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… |
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
184
  <!-- {{/data}} -->
185
185
 
186
186
  ## License
@@ -3,7 +3,7 @@
3
3
  ## Description
4
4
 
5
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.
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
7
  <!-- {{/text}} -->
8
8
 
9
9
  ## Content
@@ -11,311 +11,249 @@ This chapter documents all 20 CLI commands available in sdd-forge, covering proj
11
11
  ### Command List
12
12
 
13
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 | |
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` |
36
39
  <!-- {{/text}} -->
37
40
 
38
41
  ### Global Options
39
42
 
40
43
  <!-- {{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.
44
+ The following options are recognized at the top level or shared across most subcommands via the common `parseArgs` utility:
42
45
 
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. |
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`. |
48
52
 
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.
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.
50
54
  <!-- {{/text}} -->
51
55
 
52
56
  ### Command Details
53
57
 
54
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.}} -->
55
- #### help
59
+ #### sdd-forge help
56
60
 
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.
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.
58
62
 
59
63
  ```
60
64
  sdd-forge help
61
- sdd-forge # no arguments also shows help
65
+ sdd-forge --help
62
66
  sdd-forge -h
63
67
  ```
64
68
 
65
- #### setup
69
+ #### sdd-forge setup
66
70
 
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.
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.
68
72
 
69
73
  ```
70
74
  sdd-forge setup
71
- sdd-forge setup --name myapp --path /path/to/src --type webapp/cakephp2 --agent claude
75
+ sdd-forge setup --name myapp --path /path/to/src --type webapp/cakephp2
72
76
  ```
73
77
 
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 |
78
+ When all required options (`--name`, `--path`, `--type`, `--purpose`, `--tone`) are provided, the wizard runs non-interactively.
86
79
 
87
- #### upgrade
80
+ #### sdd-forge upgrade
88
81
 
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`.
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.
90
83
 
91
84
  ```
92
85
  sdd-forge upgrade
93
86
  sdd-forge upgrade --dry-run
94
87
  ```
95
88
 
96
- #### default
89
+ #### sdd-forge presets list
97
90
 
98
- Without arguments, lists all registered projects and marks the current default. With a project name, changes the default.
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.
99
92
 
100
93
  ```
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
94
+ sdd-forge presets list
129
95
  ```
130
96
 
131
- #### forge
97
+ #### sdd-forge docs build
132
98
 
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.
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.
134
100
 
135
101
  ```
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
102
+ sdd-forge docs build
103
+ sdd-forge docs build --force --verbose
104
+ sdd-forge docs build --dry-run
138
105
  ```
139
106
 
140
107
  | Option | Description |
141
108
  |---|---|
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
- ```
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 |
164
113
 
165
- #### agents
114
+ #### sdd-forge docs enrich
166
115
 
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.
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.
168
117
 
169
118
  ```
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
119
+ sdd-forge docs enrich
120
+ sdd-forge docs enrich --dry-run --stdout
174
121
  ```
175
122
 
176
- #### readme
123
+ #### sdd-forge docs readme
177
124
 
178
- Generates `README.md` in the project root from the docs content and preset README template.
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.
179
126
 
180
127
  ```
181
- sdd-forge readme
182
- sdd-forge readme --dry-run
128
+ sdd-forge docs readme
129
+ sdd-forge docs readme --lang ja --output docs/ja/README.md
130
+ sdd-forge docs readme --dry-run
183
131
  ```
184
132
 
185
- #### translate
133
+ #### sdd-forge docs forge
186
134
 
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.
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.
188
136
 
189
137
  ```
190
- sdd-forge translate
191
- sdd-forge translate --lang ja --force
192
- sdd-forge translate --dry-run
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"
193
141
  ```
194
142
 
195
143
  | Option | Description |
196
144
  |---|---|
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 |
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` |
200
151
 
201
- #### scan
152
+ #### sdd-forge docs translate
202
153
 
203
- Parses the source code under the configured `sourcePath` and writes structured analysis data to `.sdd-forge/output/analysis.json`.
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).
204
155
 
205
156
  ```
206
- sdd-forge scan
157
+ sdd-forge docs translate
158
+ sdd-forge docs translate --lang ja --force
159
+ sdd-forge docs translate --dry-run
207
160
  ```
208
161
 
209
- #### enrich
162
+ #### sdd-forge docs agents
210
163
 
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`.
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.
212
165
 
213
166
  ```
214
- sdd-forge enrich --agent claude
167
+ sdd-forge docs agents
168
+ sdd-forge docs agents --dry-run
215
169
  ```
216
170
 
217
- #### data
171
+ #### sdd-forge spec init
218
172
 
219
- Resolves all `{{data: …}}` directives in `docs/` files in place, replacing directive blocks with generated Markdown. Skips `{{text}}` blocks without re-processing them.
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.
220
174
 
221
175
  ```
222
- sdd-forge data
223
- sdd-forge data --dry-run
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
224
179
  ```
225
180
 
226
- #### text
181
+ #### sdd-forge spec gate
227
182
 
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.
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.
229
184
 
230
185
  ```
231
- sdd-forge text --agent claude
232
- sdd-forge text --agent claude --dry-run
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
233
189
  ```
234
190
 
235
- #### spec
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
236
198
 
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.
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`.
238
200
 
239
201
  ```
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
202
+ sdd-forge spec guardrail init
203
+ sdd-forge spec guardrail init --force --dry-run
204
+ sdd-forge spec guardrail update --agent claude
244
205
  ```
245
206
 
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 |
207
+ #### sdd-forge flow start
254
208
 
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.
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.
258
210
 
259
211
  ```
260
- sdd-forge gate --spec specs/042-contact-form/spec.md
261
- sdd-forge gate --spec specs/042-contact-form/spec.md --phase post
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
262
215
  ```
263
216
 
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 |
217
+ Gate failure exits with code 2 and displays unresolved items. If user confirmation is missing, specific instructions are shown.
268
218
 
269
- #### flow
219
+ #### sdd-forge flow status
270
220
 
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.
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.
272
222
 
273
223
  ```
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
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
277
229
  ```
278
230
 
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
231
+ #### sdd-forge flow review
292
232
 
293
- Displays the full preset inheritance tree, showing arch-level nodes and their leaf presets together with aliases and configured scan categories.
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.
294
234
 
295
235
  ```
296
- sdd-forge presets list
297
- sdd-forge presets # also shows the list
236
+ sdd-forge flow review
237
+ sdd-forge flow review --dry-run
238
+ sdd-forge flow review --skip-confirm
298
239
  ```
299
240
  <!-- {{/text}} -->
300
241
 
301
242
  ### Exit Codes and Output
302
243
 
303
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.}} -->
304
- | Exit Code | Meaning | Typical Source |
245
+ | Exit Code | Meaning | Used By |
305
246
  |---|---|---|
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`.
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) |
313
250
 
314
- **stderr conventions**
251
+ **stdout/stderr conventions:**
315
252
 
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**
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 |
319
257
 
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.
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.
321
259
  <!-- {{/text}} -->