sdd-forge 0.1.0-alpha.23 → 0.1.0-alpha.25
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.
- package/README.md +22 -22
- package/docs/01_overview.md +92 -0
- package/docs/02_cli_commands.md +250 -3
- package/docs/03_configuration.md +118 -5
- package/docs/04_internal_design.md +239 -5
- package/docs/ja/01_overview.md +114 -0
- package/docs/ja/02_cli_commands.md +270 -0
- package/docs/ja/03_configuration.md +136 -0
- package/docs/ja/04_internal_design.md +261 -0
- package/docs/ja/README.md +160 -0
- package/package.json +1 -1
- package/src/docs/commands/agents.js +2 -2
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# {{data: project.name("")}}sdd-forge{{/data}}
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/sdd-forge)
|
|
4
4
|
|
|
5
|
-
> **Alpha:** This tool is currently in alpha. APIs, command
|
|
5
|
+
> **Alpha:** This tool is currently in alpha. APIs, command structure, and configuration formats may change without notice. Not recommended for production use.
|
|
6
6
|
|
|
7
|
-
**A CLI tool that automatically generates and maintains project documentation
|
|
7
|
+
**A CLI tool that automatically generates and maintains project documentation via source code analysis + AI.**
|
|
8
8
|
|
|
9
9
|
Statically analyzes your codebase and combines templates with AI to auto-generate `docs/`.
|
|
10
|
-
Spec-Driven Development (SDD)
|
|
10
|
+
The Spec-Driven Development (SDD) workflow also automates documentation updates when adding features or making changes.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
14
|
- **Zero dependencies** — Runs on Node.js 18+ only. No npm packages required
|
|
15
15
|
- **Automatic source analysis** — Statically analyzes controllers, models, routes, and config files to extract structural data
|
|
16
16
|
- **AI document generation** — AI automatically expands `{{text}}` directives in templates
|
|
17
|
-
- **Template inheritance** —
|
|
18
|
-
- **SDD workflow** — Manage the spec → gate → implement → forge → review cycle with commands
|
|
17
|
+
- **Template inheritance** — Four-layer inheritance (base → arch → preset → project-local) for full customization
|
|
18
|
+
- **SDD workflow** — Manage the spec → gate → implement → forge → review development cycle with commands
|
|
19
19
|
- **Multi-language support** — Auto-generate documentation in multiple languages via translate / generate modes
|
|
20
20
|
- **AI agent integration** — Supports Claude Code (skills) and Codex CLI
|
|
21
21
|
- **Multi-preset** — Supports Node.js CLI / CakePHP2 / Laravel / Symfony
|
|
@@ -26,26 +26,26 @@ Spec-Driven Development (SDD) workflows further automate documentation updates w
|
|
|
26
26
|
|
|
27
27
|
<pre>
|
|
28
28
|
# npm
|
|
29
|
-
npm install -g
|
|
29
|
+
npm install -g {{data: project.name("")}}sdd-forge{{/data}}
|
|
30
30
|
|
|
31
31
|
# yarn
|
|
32
|
-
yarn global add
|
|
32
|
+
yarn global add {{data: project.name("")}}sdd-forge{{/data}}
|
|
33
33
|
|
|
34
34
|
# pnpm
|
|
35
|
-
pnpm add -g
|
|
35
|
+
pnpm add -g {{data: project.name("")}}sdd-forge{{/data}}
|
|
36
36
|
</pre>
|
|
37
37
|
|
|
38
38
|
### Setup & Document Generation
|
|
39
39
|
|
|
40
40
|
<pre>
|
|
41
41
|
# 1. Register your project (interactive wizard)
|
|
42
|
-
|
|
42
|
+
{{data: project.name("")}}sdd-forge{{/data}} setup
|
|
43
43
|
|
|
44
|
-
# 2. Generate all documentation
|
|
45
|
-
|
|
44
|
+
# 2. Generate all documentation (scan → init → data → text → readme → agents → translate)
|
|
45
|
+
{{data: project.name("")}}sdd-forge{{/data}} build
|
|
46
46
|
</pre>
|
|
47
47
|
|
|
48
|
-
This
|
|
48
|
+
This generates `docs/` and `README.md` in one step.
|
|
49
49
|
|
|
50
50
|
## Commands
|
|
51
51
|
|
|
@@ -62,7 +62,7 @@ This alone generates `docs/` and `README.md`.
|
|
|
62
62
|
| `readme` | Auto-generate `README.md` from `docs/` |
|
|
63
63
|
| `forge` | Iteratively improve documentation with AI |
|
|
64
64
|
| `review` | Check documentation quality |
|
|
65
|
-
| `translate` | Multi-language translation (default language →
|
|
65
|
+
| `translate` | Multi-language translation (default language → others) |
|
|
66
66
|
| `upgrade` | Update preset templates to the latest version |
|
|
67
67
|
|
|
68
68
|
### SDD Workflow
|
|
@@ -70,7 +70,7 @@ This alone generates `docs/` and `README.md`.
|
|
|
70
70
|
| Command | Description |
|
|
71
71
|
|---|---|
|
|
72
72
|
| `spec` | Create a spec document + feature branch |
|
|
73
|
-
| `gate` | Pre-implementation check for spec |
|
|
73
|
+
| `gate` | Pre-implementation check for the spec |
|
|
74
74
|
| `flow` | Automatically run the SDD workflow |
|
|
75
75
|
| `changelog` | Generate change history from specs/ |
|
|
76
76
|
| `agents` | Update AGENTS.md |
|
|
@@ -81,16 +81,16 @@ This alone generates `docs/` and `README.md`.
|
|
|
81
81
|
|---|---|
|
|
82
82
|
| `default` | Set the default project |
|
|
83
83
|
| `presets` | List available presets |
|
|
84
|
-
| `help` |
|
|
84
|
+
| `help` | Display command list |
|
|
85
85
|
|
|
86
86
|
## SDD Workflow
|
|
87
87
|
|
|
88
88
|
The feature addition / change flow:
|
|
89
89
|
|
|
90
90
|
```
|
|
91
|
-
spec Create
|
|
91
|
+
spec Create spec (feature branch + spec.md)
|
|
92
92
|
↓
|
|
93
|
-
gate Spec gate check (PASS when no open
|
|
93
|
+
gate Spec gate check (PASS when no open questions)
|
|
94
94
|
↓
|
|
95
95
|
implement Write code after gate PASS
|
|
96
96
|
↓
|
|
@@ -121,7 +121,7 @@ $sdd-flow-close — Finish with forge → review → commit → merge
|
|
|
121
121
|
|
|
122
122
|
## Configuration
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
`sdd-forge setup` generates `.sdd-forge/config.json`.
|
|
125
125
|
|
|
126
126
|
```jsonc
|
|
127
127
|
{
|
|
@@ -149,9 +149,9 @@ You can add project-specific templates and data sources:
|
|
|
149
149
|
<!-- {{data: docs.chapters("Chapter|Overview")}} -->
|
|
150
150
|
| Chapter | Overview |
|
|
151
151
|
| --- | --- |
|
|
152
|
-
| [01. System Overview](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/01_overview.md) |
|
|
153
|
-
| [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/02_cli_commands.md) |
|
|
154
|
-
| [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/03_configuration.md) |
|
|
152
|
+
| [01. System Overview](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/01_overview.md) | This chapter provides a structural overview of sdd-forge, a Node.js CLI tool that automates documentation generation … |
|
|
153
|
+
| [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/02_cli_commands.md) | This chapter covers all 18 subcommands available in `sdd-forge`, organized into documentation generation commands (ro… |
|
|
154
|
+
| [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/03_configuration.md) | This chapter covers all configuration files used by sdd-forge, the full range of options available in `.sdd-forge/con… |
|
|
155
155
|
| [04. Internal Design](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/04_internal_design.md) | |
|
|
156
156
|
<!-- {{/data}} -->
|
|
157
157
|
|
package/docs/01_overview.md
CHANGED
|
@@ -4,20 +4,112 @@
|
|
|
4
4
|
|
|
5
5
|
<!-- {{text: Write a 1-2 sentence overview of this chapter. Include the project's architecture and whether it integrates with external systems.}} -->
|
|
6
6
|
|
|
7
|
+
This chapter provides a structural overview of sdd-forge, a Node.js CLI tool that automates documentation generation through source code analysis and drives feature development via a Spec-Driven Development (SDD) workflow. The tool follows a three-layer command dispatch architecture and integrates with external AI agents (such as Claude CLI) to generate and refine documentation text.
|
|
8
|
+
|
|
7
9
|
## Content
|
|
8
10
|
|
|
9
11
|
### Architecture Diagram
|
|
10
12
|
|
|
11
13
|
<!-- {{text: Generate a mermaid flowchart showing the project architecture. Include data flows between major components. Output only the mermaid code block.}} -->
|
|
12
14
|
|
|
15
|
+
```mermaid
|
|
16
|
+
flowchart TD
|
|
17
|
+
User["User (CLI)"]
|
|
18
|
+
|
|
19
|
+
subgraph Entry["Entry Layer"]
|
|
20
|
+
SDF["sdd-forge.js\n(Entry Point)"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
subgraph Dispatch["Dispatcher Layer"]
|
|
24
|
+
DOCS["docs.js"]
|
|
25
|
+
SPEC["spec.js"]
|
|
26
|
+
FLOW["flow.js"]
|
|
27
|
+
HELP["help.js"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
subgraph Commands["Command Layer"]
|
|
31
|
+
SCAN["scan"]
|
|
32
|
+
DATA["data"]
|
|
33
|
+
TEXT["text"]
|
|
34
|
+
FORGE["forge"]
|
|
35
|
+
REVIEW["review"]
|
|
36
|
+
SPEC_INIT["spec init"]
|
|
37
|
+
GATE["gate"]
|
|
38
|
+
OTHER["readme / agents / changelog / …"]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
subgraph Lib["Core Libraries"]
|
|
42
|
+
AGENT["agent.js\n(AI Agent Caller)"]
|
|
43
|
+
CONFIG["config.js\n(Config & Paths)"]
|
|
44
|
+
SCANNER["scanner.js\n(Source Analyzer)"]
|
|
45
|
+
PARSER["directive-parser.js"]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
subgraph Storage["File System"]
|
|
49
|
+
SRC["Source Code\n(project root)"]
|
|
50
|
+
ANALYSIS[".sdd-forge/output/\nanalysis.json / summary.json"]
|
|
51
|
+
DOCFILES["docs/*.md\n(generated docs)"]
|
|
52
|
+
SPECS["specs/NNN-xxx/spec.md"]
|
|
53
|
+
CFGFILE[".sdd-forge/config.json"]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
AI["External AI Agent\n(e.g. Claude CLI)"]
|
|
57
|
+
|
|
58
|
+
User --> SDF
|
|
59
|
+
SDF --> DOCS & SPEC & FLOW & HELP
|
|
60
|
+
DOCS --> SCAN & DATA & TEXT & FORGE & REVIEW & OTHER
|
|
61
|
+
SPEC --> SPEC_INIT & GATE
|
|
62
|
+
SCAN --> SCANNER --> SRC
|
|
63
|
+
SCANNER --> ANALYSIS
|
|
64
|
+
DATA --> PARSER --> DOCFILES
|
|
65
|
+
TEXT --> AGENT --> AI
|
|
66
|
+
FORGE --> AGENT
|
|
67
|
+
REVIEW --> AGENT
|
|
68
|
+
AGENT --> DOCFILES
|
|
69
|
+
CONFIG --> CFGFILE
|
|
70
|
+
SPEC_INIT --> SPECS
|
|
71
|
+
GATE --> SPECS
|
|
72
|
+
```
|
|
73
|
+
|
|
13
74
|
### Component Responsibilities
|
|
14
75
|
|
|
15
76
|
<!-- {{text: Describe the major components with their location, responsibilities, and I/O in table format.}} -->
|
|
16
77
|
|
|
78
|
+
| Component | Location | Responsibility | Input | Output |
|
|
79
|
+
|---|---|---|---|---|
|
|
80
|
+
| CLI Entry Point | `src/sdd-forge.js` | Resolves project context; routes subcommands to the appropriate dispatcher | CLI arguments, env vars (`SDD_SOURCE_ROOT`, `SDD_WORK_ROOT`) | Dispatched command execution |
|
|
81
|
+
| Docs Dispatcher | `src/docs.js` | Routes `build`, `scan`, `init`, `data`, `text`, `forge`, `review`, and related subcommands | Subcommand name + flags | Delegates to `docs/commands/*.js` |
|
|
82
|
+
| Spec Dispatcher | `src/spec.js` | Routes `spec` and `gate` subcommands | Subcommand name + flags | Delegates to `specs/commands/*.js` |
|
|
83
|
+
| SDD Flow Runner | `src/flow.js` | Automates the full SDD cycle end-to-end | `--request` prompt string | Orchestrated spec → gate → implement → forge → review sequence |
|
|
84
|
+
| Source Scanner | `src/docs/lib/scanner.js` | Parses project source files; extracts modules, routes, and structure | Source root directory | `.sdd-forge/output/analysis.json`, `summary.json` |
|
|
85
|
+
| Directive Parser | `src/docs/lib/directive-parser.js` | Parses `{{data}}` and `{{text}}` directives in Markdown templates | `.md` template files | Directive AST for resolvers |
|
|
86
|
+
| Data Resolver | `src/docs/lib/resolver-factory.js` | Injects structured analysis data into `{{data}}` directives | `analysis.json`, directive AST | Resolved Markdown sections |
|
|
87
|
+
| AI Agent Caller | `src/lib/agent.js` | Invokes external AI agent processes synchronously or asynchronously | Prompt string, agent config | AI-generated text (stdout) |
|
|
88
|
+
| Config Manager | `src/lib/config.js` | Loads and validates `.sdd-forge/config.json`; resolves standard paths | `.sdd-forge/` directory | Typed config object, file paths |
|
|
89
|
+
| Spec Gate | `src/specs/commands/gate.js` | Validates a spec against pre/post implementation checklists | `spec.md` path, `--phase` flag | PASS / FAIL report |
|
|
90
|
+
| Forge Engine | `src/docs/commands/forge.js` | Iteratively improves `docs/` by prompting the AI agent | Change summary prompt, `spec.md` path | Updated `docs/*.md` files |
|
|
91
|
+
|
|
17
92
|
### External Integrations
|
|
18
93
|
|
|
19
94
|
<!-- {{text: If there are external system integrations, describe their purpose and connection method in table format.}} -->
|
|
20
95
|
|
|
96
|
+
| System | Purpose | Connection Method | Configuration |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| AI Agent (e.g. Claude CLI) | Generates and refines documentation text for `{{text}}` directives; drives `forge`, `review`, `agents`, and `text` commands | Spawned as a child process via `execFileSync` (sync) or `spawn` (async streaming) in `src/lib/agent.js` | Defined under `providers` in `.sdd-forge/config.json`; selected by `defaultAgent` key |
|
|
99
|
+
|
|
100
|
+
The AI agent is the only external integration. All other operations — file scanning, directive parsing, template merging, spec management — rely exclusively on Node.js built-in modules (`fs`, `path`, `child_process`, `os`). The agent command, arguments, timeout, and system-prompt delivery method (`--system-prompt` or `--system-prompt-file`) are all configurable per project.
|
|
101
|
+
|
|
21
102
|
### Environment Differences
|
|
22
103
|
|
|
23
104
|
<!-- {{text: Describe the configuration differences across environments (local/staging/production).}} -->
|
|
105
|
+
|
|
106
|
+
As a local CLI tool, sdd-forge does not have distinct deployment environments in the traditional sense. Configuration differences are instead expressed through per-project `.sdd-forge/config.json` settings and environment variables.
|
|
107
|
+
|
|
108
|
+
| Aspect | Local Development | CI / Automated Pipeline | Multi-Project Setup |
|
|
109
|
+
|---|---|---|---|
|
|
110
|
+
| Project resolution | Interactive; `--project` flag or `.sdd-forge/projects.json` `default` key | `SDD_SOURCE_ROOT` and `SDD_WORK_ROOT` env vars set explicitly per job | `.sdd-forge/projects.json` registers named projects; `--project <name>` selects the target |
|
|
111
|
+
| AI agent | Configured via `providers` + `defaultAgent` in `config.json`; runs interactively | Same config; `stdin: "ignore"` prevents CLI hang in non-TTY environments (`callAgentAsync`) | Each project carries its own `config.json` with independent agent settings |
|
|
112
|
+
| Language / output | `lang` and `output.languages` control CLI language and doc output locale | Same config values apply; no separate override mechanism | Per-project `config.json` allows different languages per project |
|
|
113
|
+
| Concurrency | `limits.concurrency` (default: 5) controls parallel file processing | Can be raised for faster execution on high-core machines | Independently tunable per project |
|
|
114
|
+
| Timeouts | `limits.designTimeoutMs` / per-provider `timeoutMs` | Should be increased for slow CI agents; default constants: 120 s / 180 s / 300 s | Configurable per project |
|
|
115
|
+
```
|
package/docs/02_cli_commands.md
CHANGED
|
@@ -4,20 +4,267 @@
|
|
|
4
4
|
|
|
5
5
|
<!-- {{text: Write a 1–2 sentence overview of this chapter. Cover the total number of commands, whether global options exist, and the subcommand structure.}} -->
|
|
6
6
|
|
|
7
|
+
This chapter covers all 18 subcommands available in `sdd-forge`, organized into documentation generation commands (routed through `docs.js`), spec workflow commands (routed through `spec.js`), and directly executed commands (`flow`, `presets`). All commands share a common set of global options, and most require a resolved project context before execution.
|
|
8
|
+
|
|
7
9
|
## Contents
|
|
8
10
|
|
|
9
11
|
### Command List
|
|
10
12
|
|
|
11
|
-
<!-- {{text: List all commands in a table
|
|
13
|
+
<!-- {{text: List all commands in a table format. Include command name, description, and main options. Commands can be identified from the modules list in the analysis data. Include both commands routed through dispatchers (docs.js, spec.js) and directly executed commands (flow, presets). Note that build is a composite command (scan → init → data → text → readme → agents → translate pipeline). Be sure to include translate (multilingual translation), upgrade (template update), and default (default project configuration).}} -->
|
|
14
|
+
|
|
15
|
+
| Command | Description | Key Options |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `build` | Runs the full documentation pipeline (`scan → init → data → text → readme → agents → translate`) in one step | `--project` |
|
|
18
|
+
| `scan` | Analyzes source code and writes `analysis.json` and `summary.json` | `--project` |
|
|
19
|
+
| `init` | Initializes `docs/` from preset templates | `--project` |
|
|
20
|
+
| `data` | Resolves `{{data: ...}}` directives using analysis output | `--project` |
|
|
21
|
+
| `text` | Resolves `{{text: ...}}` directives using the configured AI agent | `--file`, `--agent`, `--project` |
|
|
22
|
+
| `readme` | Auto-generates `README.md` from docs content via AI | `--project` |
|
|
23
|
+
| `forge` | Iteratively improves docs using AI, guided by a prompt | `--prompt`, `--spec`, `--project` |
|
|
24
|
+
| `review` | Runs an AI quality check on docs and reports PASS/FAIL | `--project` |
|
|
25
|
+
| `changelog` | Generates `change_log.md` from all spec files under `specs/` | `--project` |
|
|
26
|
+
| `agents` | Updates `AGENTS.md` with the latest SDD template and PROJECT section | `--sdd`, `--project-only`, `--dry-run` |
|
|
27
|
+
| `translate` | Translates docs into additional output languages defined in config | `--lang`, `--force`, `--dry-run` |
|
|
28
|
+
| `upgrade` | Updates SDD-managed template sections to match the installed package version | `--project` |
|
|
29
|
+
| `setup` | Registers a project and generates initial `.sdd-forge/config.json` | — |
|
|
30
|
+
| `default` | Sets or displays the default project in `projects.json` | — |
|
|
31
|
+
| `spec` | Creates a new spec file and optionally a feature branch | `--title`, `--no-branch` |
|
|
32
|
+
| `gate` | Validates a spec against acceptance criteria before or after implementation | `--spec`, `--phase` |
|
|
33
|
+
| `flow` | Automates the full SDD flow from a natural-language request | `--request` |
|
|
34
|
+
| `presets` | Lists all bundled project type presets | — |
|
|
35
|
+
| `help` | Displays available subcommands and descriptions | `-h`, `--help` |
|
|
12
36
|
|
|
13
37
|
### Global Options
|
|
14
38
|
|
|
15
|
-
<!-- {{text:
|
|
39
|
+
<!-- {{text: List global options common to all commands in a table format. Include --project, --help/-h, and --version/-v/-V. Also note that setup, default, help, and presets skip project context resolution.}} -->
|
|
40
|
+
|
|
41
|
+
| Option | Aliases | Description |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `--project <name>` | — | Specifies the target project by name, as registered in `.sdd-forge/projects.json`. When omitted, the project marked as `default` in `projects.json` is used. |
|
|
44
|
+
| `--help` | `-h` | Prints the help text for the given subcommand and exits. |
|
|
45
|
+
| `--version` | `-v`, `-V` | Prints the current `sdd-forge` version from `package.json` and exits. |
|
|
46
|
+
|
|
47
|
+
> **Note:** The `setup`, `default`, `help`, and `presets` commands skip project context resolution entirely. They do not require a registered project and ignore the `--project` flag.
|
|
16
48
|
|
|
17
49
|
### Command Details
|
|
18
50
|
|
|
19
51
|
<!-- {{text: Describe the usage, options, and examples for each command in detail. Create a #### subsection for each command. For the build pipeline, list all steps: scan → init → data → text → readme → agents → translate. The translate command has --lang, --force, and --dry-run options.}} -->
|
|
20
52
|
|
|
53
|
+
Each command below is documented with its purpose, available options, and representative usage examples. Commands that involve AI generation require a valid `defaultAgent` or `providers` entry in `.sdd-forge/config.json`. Commands that modify files on disk always operate within the resolved project's `docs/` directory unless otherwise noted.
|
|
54
|
+
|
|
55
|
+
#### build
|
|
56
|
+
|
|
57
|
+
Runs the complete documentation generation pipeline in a single step. The pipeline executes the following stages in order: `scan → init → data → text → readme → agents → translate`. This is the standard entry point for first-time setup or full regeneration of project docs.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
sdd-forge build
|
|
61
|
+
sdd-forge build --project myproject
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### scan
|
|
65
|
+
|
|
66
|
+
Analyzes the project source code according to the configured preset (e.g., `cli/node-cli`, `webapp/cakephp2`) and writes results to `.sdd-forge/output/analysis.json` and `.sdd-forge/output/summary.json`. The `summary.json` is a lightweight version intended for AI consumption.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
sdd-forge scan
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### init
|
|
73
|
+
|
|
74
|
+
Initializes the `docs/` directory structure by copying preset templates. Templates are resolved from `src/presets/{preset}/templates/{lang}/`. Existing files are not overwritten unless explicitly forced.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
sdd-forge init
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### data
|
|
81
|
+
|
|
82
|
+
Resolves all `{{data: ...}}` directives found in `docs/` files, replacing them with structured data extracted from `analysis.json`. Directives outside template boundaries are left untouched.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
sdd-forge data
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### text
|
|
89
|
+
|
|
90
|
+
Resolves `{{text: ...}}` directives in `docs/` files using the configured AI agent. Processes files concurrently up to the `limits.concurrency` setting. Optionally targets a single file.
|
|
91
|
+
|
|
92
|
+
| Option | Description |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `--file <path>` | Process only the specified docs file |
|
|
95
|
+
| `--agent <name>` | Override the AI agent to use |
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
sdd-forge text
|
|
99
|
+
sdd-forge text --file docs/02_cli_commands.md
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### readme
|
|
103
|
+
|
|
104
|
+
Auto-generates `README.md` in the project root using the content of `docs/` as source material. The output is driven by the AI agent defined in the project config.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
sdd-forge readme
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### forge
|
|
111
|
+
|
|
112
|
+
Iteratively improves one or more docs files using AI, guided by a prompt describing recent changes. When `--spec` is provided, the spec file is included as additional context for the AI.
|
|
113
|
+
|
|
114
|
+
| Option | Description |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `--prompt <text>` | Description of changes to reflect in docs (required) |
|
|
117
|
+
| `--spec <path>` | Path to the spec file for additional context |
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
sdd-forge forge --prompt "Added translate command with --lang option"
|
|
121
|
+
sdd-forge forge --prompt "Refactored scanner" --spec specs/010-refactor/spec.md
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### review
|
|
125
|
+
|
|
126
|
+
Runs a quality check over the generated docs using AI, validating completeness, accuracy, and consistency with the source code. Outputs a PASS or FAIL result with actionable feedback.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
sdd-forge review
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### changelog
|
|
133
|
+
|
|
134
|
+
Generates `change_log.md` by aggregating all spec files under `specs/`. Each spec contributes a changelog entry describing the feature or fix it represents.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
sdd-forge changelog
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### agents
|
|
141
|
+
|
|
142
|
+
Updates `AGENTS.md` with the latest SDD instruction template and a newly generated PROJECT section derived from `analysis.json` / `summary.json`. The command supports partial updates via flags.
|
|
143
|
+
|
|
144
|
+
| Option | Description |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `--sdd` | Update only the `<!-- SDD:START/END -->` section |
|
|
147
|
+
| `--project` | Update only the `<!-- PROJECT:START/END -->` section |
|
|
148
|
+
| `--dry-run` | Preview output without writing to disk |
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
sdd-forge agents
|
|
152
|
+
sdd-forge agents --sdd
|
|
153
|
+
sdd-forge agents --dry-run
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### translate
|
|
157
|
+
|
|
158
|
+
Translates the generated docs into one or more additional output languages, as specified by `output.languages` in the project config. Uses `output.mode` (`translate` or `generate`) to determine the translation strategy.
|
|
159
|
+
|
|
160
|
+
| Option | Description |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `--lang <code>` | Target language code to translate into (e.g., `en`, `ja`) |
|
|
163
|
+
| `--force` | Overwrite existing translated files |
|
|
164
|
+
| `--dry-run` | Preview without writing to disk |
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
sdd-forge translate --lang en
|
|
168
|
+
sdd-forge translate --lang en --force
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### upgrade
|
|
172
|
+
|
|
173
|
+
Updates the SDD-managed sections of `docs/` templates to match the latest version bundled with the installed `sdd-forge` package. Content outside directive boundaries is preserved.
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
sdd-forge upgrade
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### setup
|
|
180
|
+
|
|
181
|
+
Registers a new project with `sdd-forge` and generates the initial `.sdd-forge/config.json`. Guides the user through selecting a project type preset and configuring output language settings. Also creates `AGENTS.md` and a `CLAUDE.md` symlink.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
sdd-forge setup
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### default
|
|
188
|
+
|
|
189
|
+
Sets or displays the default project for the current tool installation. The default project is stored in `.sdd-forge/projects.json` and used when `--project` is not specified.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
sdd-forge default
|
|
193
|
+
sdd-forge default myproject
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### spec
|
|
197
|
+
|
|
198
|
+
Creates a new spec file under `specs/NNN-<slug>/spec.md` and optionally creates a feature branch. Used at the start of the SDD workflow for any new feature or fix.
|
|
199
|
+
|
|
200
|
+
| Option | Description |
|
|
201
|
+
|---|---|
|
|
202
|
+
| `--title <name>` | Title of the spec / feature (required) |
|
|
203
|
+
| `--no-branch` | Skip branch creation (e.g., when already inside a worktree) |
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
sdd-forge spec --title "Add translate command"
|
|
207
|
+
sdd-forge spec --title "Fix scanner" --no-branch
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### gate
|
|
211
|
+
|
|
212
|
+
Validates a spec file against defined acceptance criteria before (`--phase pre`) or after (`--phase post`) implementation. Reports each check item as PASS or FAIL.
|
|
213
|
+
|
|
214
|
+
| Option | Description |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `--spec <path>` | Path to the spec file to validate (required) |
|
|
217
|
+
| `--phase <pre\|post>` | Gate phase; defaults to `pre` |
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
sdd-forge gate --spec specs/010-translate/spec.md
|
|
221
|
+
sdd-forge gate --spec specs/010-translate/spec.md --phase post
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### flow
|
|
225
|
+
|
|
226
|
+
Automatically executes the full SDD flow — spec creation, gate check, and implementation scaffolding — for a given natural-language request. Intended for AI agent environments where manual step-by-step execution is not practical.
|
|
227
|
+
|
|
228
|
+
| Option | Description |
|
|
229
|
+
|---|---|
|
|
230
|
+
| `--request <text>` | Natural-language description of the feature or fix |
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
sdd-forge flow --request "Add support for multilingual output"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### presets
|
|
237
|
+
|
|
238
|
+
Lists all available project type presets bundled with `sdd-forge`, including architecture-layer presets (`webapp`, `cli`, `library`) and framework-specific presets (`cakephp2`, `laravel`, `symfony`, `node-cli`).
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
sdd-forge presets
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
#### help
|
|
245
|
+
|
|
246
|
+
Displays a summary of all available subcommands and their descriptions. Equivalent to running `sdd-forge` with no arguments.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
sdd-forge help
|
|
250
|
+
sdd-forge -h
|
|
251
|
+
```
|
|
252
|
+
|
|
21
253
|
### Exit Codes and Output
|
|
22
254
|
|
|
23
|
-
<!-- {{text: Describe exit code definitions (0=success, 1=general error, etc.) and the rules for stdout/stderr usage in a table. Include the
|
|
255
|
+
<!-- {{text: Describe exit code definitions (0=success, 1=general error, etc.) and the rules for stdout/stderr usage in a table format. Include the fact that gate and review PASS/FAIL results are printed to stdout.}} -->
|
|
256
|
+
|
|
257
|
+
| Exit Code | Meaning |
|
|
258
|
+
|---|---|
|
|
259
|
+
| `0` | Command completed successfully |
|
|
260
|
+
| `1` | General error (missing required option, file not found, configuration invalid, etc.) |
|
|
261
|
+
| `2` | Gate or review check failed (FAIL result reported; see stdout for details) |
|
|
262
|
+
|
|
263
|
+
**stdout / stderr usage:**
|
|
264
|
+
|
|
265
|
+
| Stream | Content |
|
|
266
|
+
|---|---|
|
|
267
|
+
| `stdout` | Primary command output: generated text, rendered tables, PASS/FAIL results from `gate` and `review`, dry-run previews |
|
|
268
|
+
| `stderr` | Progress indicators, warnings, debug information, and error messages |
|
|
269
|
+
|
|
270
|
+
`gate` and `review` always print their PASS/FAIL verdict and per-item check results to **stdout**, making them suitable for capture in CI pipelines. Error messages describing why a command could not run (missing config, invalid arguments, etc.) are written to **stderr** and do not appear in captured stdout.
|
package/docs/03_configuration.md
CHANGED
|
@@ -2,22 +2,135 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
<!-- {{text: Describe the overview of this chapter in 1
|
|
5
|
+
<!-- {{text: Describe the overview of this chapter in 1-2 sentences. Cover the types of configuration files, the range of configurable options, and customization points.}} -->
|
|
6
|
+
|
|
7
|
+
This chapter covers all configuration files used by sdd-forge, the full range of options available in `.sdd-forge/config.json`, and the customization points for AI providers, document style, project type, merge strategy, and concurrency.
|
|
6
8
|
|
|
7
9
|
## Contents
|
|
8
10
|
|
|
9
11
|
### Configuration Files
|
|
10
12
|
|
|
11
|
-
<!-- {{text: List
|
|
13
|
+
<!-- {{text: List all configuration files loaded by this tool in a table, including their locations and roles. Main files: .sdd-forge/config.json (project settings), .sdd-forge/context.json (project context), .sdd-forge/projects.json (multi-project management), .sdd-forge/current-spec (SDD flow state), .sdd-forge/output/analysis.json (analysis results), .sdd-forge/output/summary.json (lightweight version for AI).}} -->
|
|
14
|
+
|
|
15
|
+
All configuration and state files are stored under the `.sdd-forge/` directory at the working root of your project.
|
|
16
|
+
|
|
17
|
+
| File | Location | Role |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `config.json` | `.sdd-forge/config.json` | Primary project configuration. Defines output languages, project type, AI agent settings, document style, and workflow options. Validated on load. |
|
|
20
|
+
| `context.json` | `.sdd-forge/context.json` | Free-form project context string passed to AI during text generation. Takes priority over `textFill.projectContext` in `config.json`. |
|
|
21
|
+
| `projects.json` | `.sdd-forge/projects.json` | Multi-project registry. Maps project names to their source and work root paths. Generated by `sdd-forge setup`. |
|
|
22
|
+
| `current-spec` | `.sdd-forge/current-spec` | JSON file tracking the active SDD flow state, including spec path, base branch, feature branch, and worktree information. Deleted on flow completion. |
|
|
23
|
+
| `analysis.json` | `.sdd-forge/output/analysis.json` | Full source code analysis result produced by `sdd-forge scan`. Stored without indentation for compact output. |
|
|
24
|
+
| `summary.json` | `.sdd-forge/output/summary.json` | Lightweight version of `analysis.json` optimized for AI consumption. Used in preference to `analysis.json` wherever available. |
|
|
12
25
|
|
|
13
26
|
### Configuration Reference
|
|
14
27
|
|
|
15
|
-
<!-- {{text: Describe all fields in .sdd-forge/config.json in a table format. Include field name, whether required, type, default value, and description. Main fields: output.languages (
|
|
28
|
+
<!-- {{text: Describe all fields in .sdd-forge/config.json in a table format. Include field name, whether required, type, default value, and description. Main fields: output.languages (output language list), output.default (default language), output.mode (translate/generate), lang (CLI operating language), type (project type), documentStyle (purpose/tone/customInstruction), textFill (projectContext/preamblePatterns), defaultAgent, providers (AI agent definitions), flow.merge (squash/ff-only/merge), limits (concurrency/designTimeoutMs).}} -->
|
|
29
|
+
|
|
30
|
+
The table below describes every supported field in `.sdd-forge/config.json`.
|
|
31
|
+
|
|
32
|
+
| Field | Required | Type | Default | Description |
|
|
33
|
+
|---|---|---|---|---|
|
|
34
|
+
| `output.languages` | ✅ | `string[]` | — | List of output languages for generated docs (e.g., `["ja"]`, `["en", "ja"]`). |
|
|
35
|
+
| `output.default` | ✅ | `string` | — | The primary output language used when generating documents. |
|
|
36
|
+
| `output.mode` | — | `"translate"` \| `"generate"` | `"translate"` | How non-default languages are produced: `translate` uses the default output as source; `generate` calls AI independently. |
|
|
37
|
+
| `lang` | ✅ | `string` | — | Operating language for the CLI, AGENTS.md, skill prompts, and spec files. |
|
|
38
|
+
| `type` | ✅ | `string` | — | Project type that selects the active preset (e.g., `"cli/node-cli"`, `"webapp/cakephp2"`). |
|
|
39
|
+
| `uiLang` | — | `"en"` \| `"ja"` | — | Language for sdd-forge's own UI messages. |
|
|
40
|
+
| `documentStyle.purpose` | — | `string` | — | A short description of the document's intended audience or purpose, passed to AI during generation. |
|
|
41
|
+
| `documentStyle.tone` | — | `"polite"` \| `"formal"` \| `"casual"` | — | Writing tone applied to AI-generated text sections. |
|
|
42
|
+
| `documentStyle.customInstruction` | — | `string` | — | Additional freeform instruction appended to AI prompts for every text generation task. |
|
|
43
|
+
| `textFill.projectContext` | — | `string` | — | Project overview text supplied to AI. Overridden by `context.json` when that file exists. |
|
|
44
|
+
| `textFill.preamblePatterns` | — | `object[]` | — | Patterns used to strip LLM-generated preamble text from AI responses before inserting into docs. |
|
|
45
|
+
| `defaultAgent` | — | `string` | — | Name of the AI provider entry (from `providers`) used when no agent is explicitly specified. |
|
|
46
|
+
| `providers` | — | `object` | — | Map of named AI agent definitions. Each entry specifies `command`, `args`, optional `timeoutMs`, and `systemPromptFlag`. |
|
|
47
|
+
| `flow.merge` | — | `"squash"` \| `"ff-only"` \| `"merge"` | `"squash"` | Git merge strategy applied when closing an SDD flow. |
|
|
48
|
+
| `limits.concurrency` | — | `number` | `5` | Maximum number of files processed in parallel during document generation. |
|
|
49
|
+
| `limits.designTimeoutMs` | — | `number` | — | Timeout in milliseconds for AI agent calls during document generation. |
|
|
16
50
|
|
|
17
51
|
### Customization Points
|
|
18
52
|
|
|
19
|
-
<!-- {{text:
|
|
53
|
+
<!-- {{text: Explain the items users can customize. (1) AI provider settings (providers field, command/args/timeoutMs/systemPromptFlag) with configuration examples, (2) document style (purpose/tone/customInstruction), (3) preset selection (type field), (4) merge strategy (flow.merge), (5) concurrency (limits.concurrency). Include a JSON configuration example for each item.}} -->
|
|
54
|
+
|
|
55
|
+
**1. AI Provider Settings**
|
|
56
|
+
|
|
57
|
+
The `providers` field defines one or more named AI agents. Each entry specifies the executable command, argument list, an optional timeout, and how system prompts are passed. Use `defaultAgent` to select which provider is active by default.
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"defaultAgent": "claude",
|
|
62
|
+
"providers": {
|
|
63
|
+
"claude": {
|
|
64
|
+
"command": "claude",
|
|
65
|
+
"args": ["--model", "claude-opus-4-5", "{{PROMPT}}"],
|
|
66
|
+
"timeoutMs": 180000,
|
|
67
|
+
"systemPromptFlag": "--system-prompt"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The `{{PROMPT}}` placeholder in `args` marks where the generated prompt is injected. If omitted, the prompt is appended at the end of the argument list. Set `systemPromptFlag` to `"--system-prompt-file"` when the agent expects a file path rather than an inline string.
|
|
74
|
+
|
|
75
|
+
**2. Document Style**
|
|
76
|
+
|
|
77
|
+
The `documentStyle` field controls the tone and purpose of AI-generated documentation. Use `customInstruction` to enforce project-specific writing conventions.
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"documentStyle": {
|
|
82
|
+
"purpose": "Internal reference for backend engineers",
|
|
83
|
+
"tone": "formal",
|
|
84
|
+
"customInstruction": "Always include code examples for each API method."
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**3. Preset Selection**
|
|
90
|
+
|
|
91
|
+
The `type` field selects the preset that determines which source files are scanned and which document chapters are generated. Choose the value that best matches your project's architecture.
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"type": "cli/node-cli"
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Available built-in values include `"cli/node-cli"`, `"webapp/cakephp2"`, `"webapp/laravel"`, and `"webapp/symfony"`. Refer to the preset list for the full set of supported aliases.
|
|
100
|
+
|
|
101
|
+
**4. Merge Strategy**
|
|
102
|
+
|
|
103
|
+
The `flow.merge` field controls how feature branches are merged into the base branch at the end of an SDD flow.
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"flow": {
|
|
108
|
+
"merge": "squash"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use `"squash"` to condense all feature commits into one, `"ff-only"` for a linear history without a merge commit, or `"merge"` for a standard merge commit.
|
|
114
|
+
|
|
115
|
+
**5. Concurrency**
|
|
116
|
+
|
|
117
|
+
Adjust `limits.concurrency` to control how many files are processed in parallel during document generation. Lower this value if AI rate limits are being hit; raise it to speed up generation on large codebases.
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"limits": {
|
|
122
|
+
"concurrency": 3,
|
|
123
|
+
"designTimeoutMs": 240000
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
20
127
|
|
|
21
128
|
### Environment Variables
|
|
22
129
|
|
|
23
|
-
<!-- {{text: List the environment variables referenced by the tool and their purposes in a table. SDD_SOURCE_ROOT (source code root), SDD_WORK_ROOT (
|
|
130
|
+
<!-- {{text: List the environment variables referenced by the tool and their purposes in a table. SDD_SOURCE_ROOT (source code root), SDD_WORK_ROOT (working root, location of .sdd-forge/), CLAUDECODE (internal variable removed to prevent Claude CLI hangs).}} -->
|
|
131
|
+
|
|
132
|
+
| Variable | Purpose |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `SDD_SOURCE_ROOT` | Absolute path to the source code root being analyzed. When set, overrides the path resolved from `git rev-parse` or the current working directory. |
|
|
135
|
+
| `SDD_WORK_ROOT` | Absolute path to the working root, i.e., the directory containing `.sdd-forge/`. When set, takes priority over the git-resolved root. |
|
|
136
|
+
| `CLAUDECODE` | An internal variable that sdd-forge actively removes from the environment before spawning AI agent processes. This prevents the Claude CLI from hanging when launched as a child process. |
|