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

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 (52) hide show
  1. package/README.md +69 -120
  2. package/package.json +2 -3
  3. package/src/docs/commands/changelog.js +1 -1
  4. package/src/docs/commands/enrich.js +3 -3
  5. package/src/docs/commands/forge.js +4 -21
  6. package/src/docs/commands/init.js +3 -3
  7. package/src/docs/commands/readme.js +4 -4
  8. package/src/docs/commands/review.js +42 -89
  9. package/src/docs/commands/scan.js +139 -6
  10. package/src/docs/commands/text.js +103 -29
  11. package/src/docs/commands/translate.js +1 -1
  12. package/src/docs/data/docs.js +3 -3
  13. package/src/docs/data/lang.js +2 -2
  14. package/src/docs/lib/command-context.js +1 -1
  15. package/src/docs/lib/review-parser.js +1 -131
  16. package/src/docs.js +1 -2
  17. package/src/flow/commands/resume.js +163 -0
  18. package/src/flow/commands/status.js +20 -2
  19. package/src/flow.js +1 -0
  20. package/src/help.js +4 -0
  21. package/src/lib/agent.js +5 -6
  22. package/src/lib/config.js +1 -1
  23. package/src/lib/flow-state.js +78 -16
  24. package/src/lib/types.js +73 -63
  25. package/src/locale/en/messages.json +12 -5
  26. package/src/locale/en/prompts.json +1 -1
  27. package/src/locale/en/ui.json +8 -2
  28. package/src/locale/ja/messages.json +12 -5
  29. package/src/locale/ja/prompts.json +1 -1
  30. package/src/locale/ja/ui.json +8 -2
  31. package/src/setup.js +8 -13
  32. package/src/spec/commands/guardrail.js +2 -2
  33. package/src/templates/config.example.json +11 -18
  34. package/src/templates/skills/sdd-forge.flow-impl/SKILL.md +71 -26
  35. package/src/templates/skills/sdd-forge.flow-merge/SKILL.md +59 -23
  36. package/src/templates/skills/sdd-forge.flow-plan/SKILL.md +124 -46
  37. package/src/templates/skills/sdd-forge.flow-resume/SKILL.md +33 -0
  38. package/docs/cli_commands.md +0 -259
  39. package/docs/configuration.md +0 -191
  40. package/docs/internal_design.md +0 -359
  41. package/docs/ja/README.md +0 -188
  42. package/docs/ja/cli_commands.md +0 -442
  43. package/docs/ja/configuration.md +0 -238
  44. package/docs/ja/internal_design.md +0 -333
  45. package/docs/ja/overview.md +0 -109
  46. package/docs/ja-translate/README.md +0 -188
  47. package/docs/ja-translate/cli_commands.md +0 -372
  48. package/docs/ja-translate/configuration.md +0 -193
  49. package/docs/ja-translate/internal_design.md +0 -325
  50. package/docs/ja-translate/overview.md +0 -148
  51. package/docs/overview.md +0 -144
  52. package/src/docs/commands/snapshot.js +0 -208
package/README.md CHANGED
@@ -5,172 +5,121 @@
5
5
  <!-- {{/data}} -->
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/sdd-forge.svg)](https://www.npmjs.com/package/sdd-forge)
8
+ [![license](https://img.shields.io/npm/l/sdd-forge.svg)](https://opensource.org/licenses/MIT)
9
+ [![downloads](https://img.shields.io/npm/dm/sdd-forge.svg)](https://www.npmjs.com/package/sdd-forge)
8
10
 
9
- > **Alpha:** This tool is currently in alpha. APIs, command structure, and configuration formats may change without notice. Not recommended for production use.
11
+ > **Alpha:** APIs, command structure, and configuration formats may change without notice.
10
12
 
11
- **A CLI tool that generates documentation from programmatic source code analysis — based on facts, not AI guesswork.**
13
+ ## Spec-Driven Development Design, implement, and document in a single flow
12
14
 
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
+ A spec-first development flow manager designed to work with AI coding agents.
15
16
 
16
- ## Why sdd-forge?
17
+ ## The SDD Flow
17
18
 
18
- Most AI documentation tools let AI "read" your code and write docs.
19
- sdd-forge is different.
19
+ Every feature goes through three phases, from spec to merge.
20
20
 
21
- - **Programmatic analysis** — A static analyzer parses controllers, models, routes, and configs instead of asking AI to read them. No hallucinations, no missed files
22
- - **Facts vs. generation** — `{{data}}` directives inject facts extracted mechanically from source code. `{{text}}` directives hold AI-generated explanations. What is trustworthy and what is inferred is structurally clear
23
- - **Mechanical gate checks** — Spec completeness is verified by program logic, not AI judgment. A quality gate you can rely on
24
- - **Structural stability** Directives define what goes where. AI cannot rearrange paragraphs or alter the document structure
25
-
26
- ## Features
27
-
28
- ### Analyze
29
-
30
- `scan` statically analyzes source code and produces `analysis.json`. A program — not AI — reads the structure.
31
-
32
- - Parses controllers, models, routes, and config files to extract structural data
33
- - `enrich` lets AI survey the whole picture and annotate each entry with role, summary, and chapter classification
34
- - Preset system adapts to various frameworks and project structures
21
+ ```
22
+ plan ─────── Specification
23
+ │ ├─ draft Refine requirements through dialogue
24
+ │ ├─ spec Create spec (feature branch + spec.md)
25
+ │ ├─ gate Spec validation + guardrail check
26
+ │ └─ test Review test plan → write test code
27
+
28
+ implement ── Implementation
29
+ │ ├─ code Write code after gate PASS
30
+ │ └─ review AI code review
31
+
32
+ merge ────── Wrap-up
33
+ ├─ docs Auto-update documentation
34
+ ├─ commit Commit changes
35
+ └─ merge Merge to base branch → cleanup
36
+ ```
35
37
 
36
- ### Generate
38
+ ### AI stays in its lane
37
39
 
38
- `{{data}}` injects facts, `{{text}}` injects AI explanations, both into templates. A single `build` command produces `docs/` and `README.md`.
40
+ Source code analysis, spec gate checks, and flow orchestration are all handled by deterministic commands. AI is not in charge of the flow — it assists with spec drafting, code review, and prose generation within well-defined boundaries.
39
41
 
40
- - Template inheritance4-layer override: base arch preset project-local
41
- - Multi-languagetranslate / generate modes for automatic localization
42
- - Zero dependenciesruns on Node.js 18+ only, no npm packages required
42
+ - **Spec gate**Programmatic validation of unresolved items and missing approvals. No PASS, no implementation
43
+ - **Guardrails**Project-specific design principles checked against each spec
44
+ - **Compaction resilience**Flow state and requirements are persisted, so you can resume after context compression
43
45
 
44
- ### Enforce
46
+ ## Automatic Doc Sync
45
47
 
46
- `gate` mechanically validates specs, `review` checks document quality. The SDD workflow keeps documentation fresh.
48
+ Source code is statically analyzed to extract file structure, classes, methods, configuration, and dependencies. The extracted data is injected into templates to produce structured documentation (`docs/`) and `README.md`.
47
49
 
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
50
+ Documentation is automatically refreshed during the merge phase, so docs and code never drift apart. With always-current docs, both humans and AI agents can understand the system without reading every source file.
51
51
 
52
52
  ## Quick Start
53
53
 
54
- ### Installation
54
+ ### Install
55
55
 
56
56
  <pre>
57
- # npm
58
57
  npm install -g <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
59
-
60
- # yarn
61
- yarn global add <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
62
-
63
- # pnpm
64
- pnpm add -g <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} -->
65
58
  </pre>
66
59
 
67
- ### Setup & Generate
60
+ ### Setup
68
61
 
69
62
  <pre>
70
- # 1. Register your project (interactive wizard)
71
63
  <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> setup
72
-
73
- # 2. Generate all documentation (scan → enrich → init → data → text → readme → agents → translate)
74
- <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> build
75
64
  </pre>
76
65
 
77
- That's it `docs/` and `README.md` are generated.
66
+ An interactive wizard configures your project type (preset) and AI agent.
78
67
 
79
- ## Commands
68
+ ### Generate docs for an existing project
80
69
 
81
- ### Documentation Generation
70
+ If you already have source code, generate documentation to get a complete picture of the system. Especially useful for onboarding onto legacy codebases.
82
71
 
83
- | Command | Description |
84
- |---|---|
85
- | `setup` | Register project + generate config |
86
- | `build` | Run the full documentation pipeline |
87
- | `scan` | Analyze source code → `analysis.json` |
88
- | `init` | Initialize `docs/` from templates |
89
- | `data` | Resolve `{{data}}` directives with analysis data |
90
- | `text` | Resolve `{{text}}` directives with AI |
91
- | `readme` | Generate `README.md` from `docs/` |
92
- | `forge` | Iteratively improve docs with AI |
93
- | `review` | Check document quality |
94
- | `translate` | Translate docs (default language → others) |
95
- | `upgrade` | Update preset templates to latest version |
96
-
97
- ### SDD Workflow
72
+ <pre>
73
+ <!-- {{data: project.name("")}} -->sdd-forge<!-- {{/data}} --> docs build
74
+ </pre>
98
75
 
99
- | Command | Description |
100
- |---|---|
101
- | `spec` | Create spec + feature branch |
102
- | `gate` | Pre-implementation spec check |
103
- | `flow` | Run the SDD workflow automatically |
104
- | `changelog` | Generate change log from specs/ |
105
- | `agents` | Update AGENTS.md |
76
+ ### Develop with the SDD flow
106
77
 
107
- ### Other
78
+ **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** — run each phase via skills:
108
79
 
109
- | Command | Description |
80
+ | Skill | Phase |
110
81
  |---|---|
111
- | `presets` | List available presets |
112
- | `help` | Show command list |
113
-
114
- ## SDD Workflow
82
+ | `/sdd-forge.flow-plan` | plan (specification) |
83
+ | `/sdd-forge.flow-impl` | implement (coding + review) |
84
+ | `/sdd-forge.flow-merge` | merge (wrap-up) |
115
85
 
116
- Feature development flow:
86
+ **[Codex CLI](https://github.com/openai/codex)** — invoke via `$` prefix:
117
87
 
118
- ```
119
- spec Create spec (feature branch + spec.md)
120
-
121
- gate Spec gate check verified by program (not AI)
122
-
123
- implement Code after gate PASS
124
-
125
- forge AI updates documentation
126
-
127
- review AI quality check (repeat until PASS)
128
- ```
129
-
130
- ### AI Agent Integration
131
-
132
- #### Claude Code
133
-
134
- Run SDD workflows via skills:
135
-
136
- ```
137
- /sdd-flow-start — create spec → gate → start implementation
138
- /sdd-flow-close — forge → review → commit → merge
139
- ```
88
+ | Command | Phase |
89
+ |---|---|
90
+ | `$sdd-forge flow start` | plan (start specification) |
91
+ | `$sdd-forge flow review` | implement (AI code review) |
92
+ | `$sdd-forge flow merge` | merge (wrap-up) |
140
93
 
141
- #### Codex CLI
94
+ ## Commands
142
95
 
143
- Run workflows from the `$` prompt:
96
+ | Command | Description |
97
+ |---|---|
98
+ | `setup` | Register project and generate config |
99
+ | `docs build` | Run the full documentation pipeline |
100
+ | `docs readme` | Generate `README.md` from `docs/` |
101
+ | `docs review` | Check documentation quality |
102
+ | `flow start` | Start the SDD flow |
103
+ | `flow status` | Show flow progress |
104
+ | `presets` | List available presets |
105
+ | `help` | Show all commands |
144
106
 
145
- ```
146
- $sdd-flow-start — create spec → gate → start implementation
147
- $sdd-flow-close — forge → review → commit → merge
148
- ```
107
+ See `sdd-forge help` or the [command reference](docs/cli_commands.md) for the full list.
149
108
 
150
109
  ## Configuration
151
110
 
152
- `sdd-forge setup` generates `.sdd-forge/config.json`:
111
+ `setup` generates `.sdd-forge/config.json`:
153
112
 
154
113
  ```jsonc
155
114
  {
156
115
  "type": "cli/node-cli", // project type (preset selection)
157
- "lang": "en", // documentation language
116
+ "lang": "en", // operating language
158
117
  "defaultAgent": "claude", // AI agent
159
118
  "providers": { ... } // agent settings
160
119
  }
161
120
  ```
162
121
 
163
- ### Customization
164
-
165
- Add project-specific templates and data sources:
166
-
167
- ```
168
- .sdd-forge/
169
- ├── templates/{lang}/
170
- │ ├── docs/ ← chapter template & README overrides
171
- │ └── specs/ ← spec.md / qa.md templates
172
- └── data/ ← custom data source modules
173
- ```
122
+ See the [configuration reference](docs/configuration.md) for details.
174
123
 
175
124
  ## Documentation
176
125
 
@@ -178,9 +127,9 @@ Add project-specific templates and data sources:
178
127
  | Chapter | Summary |
179
128
  | --- | --- |
180
129
  | [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/` →… |
130
+ | [02. CLI Command Reference](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/cli_commands.md) | sdd-forge provides over 20 CLI commands organized into four namespaces (`docs`, `spec`, `flow`, and standalone comman… |
131
+ | [03. Configuration and Customization](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/configuration.md) | sdd-forge uses a layered configuration system centered on `.sdd-forge/config.json`, supplemented by preset manifests … |
132
+ | [04. Internal Design](https://github.com/SpreadWorks/sdd-forge/blob/main/docs/internal_design.md) | This chapter describes sdd-forge's internal architecture: the three-layer directory structure under `src/`, the depen… |
184
133
  <!-- {{/data}} -->
185
134
 
186
135
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdd-forge",
3
- "version": "0.1.0-alpha.31",
3
+ "version": "0.1.0-alpha.32",
4
4
  "description": "Spec-Driven Development tooling for automated documentation generation",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,8 +11,7 @@
11
11
  "sdd-forge": "./src/sdd-forge.js"
12
12
  },
13
13
  "files": [
14
- "src/",
15
- "docs/"
14
+ "src/"
16
15
  ],
17
16
  "engines": {
18
17
  "node": ">=18.0.0"
@@ -132,7 +132,7 @@ function main() {
132
132
  let lang = DEFAULT_LANG;
133
133
  try {
134
134
  const cfgData = loadConfig(root);
135
- lang = cfgData.output?.default || cfgData.lang || DEFAULT_LANG;
135
+ lang = cfgData.docs?.defaultLanguage || cfgData.lang || DEFAULT_LANG;
136
136
  } catch (_) {}
137
137
  const t = translate();
138
138
 
@@ -361,12 +361,12 @@ async function main(ctx) {
361
361
  }
362
362
 
363
363
  // Split into batches (lines-based with item count fallback)
364
- const maxItems = Number(config.limits?.enrichBatchSize || 0) || DEFAULT_BATCH_SIZE;
365
- const maxLines = Number(config.limits?.enrichBatchLines || 0) || DEFAULT_BATCH_LINES;
364
+ const maxItems = Number(config.docs?.enrichBatchSize || 0) || DEFAULT_BATCH_SIZE;
365
+ const maxLines = Number(config.docs?.enrichBatchLines || 0) || DEFAULT_BATCH_LINES;
366
366
  const hasLines = pending.some((e) => e.lines > 0);
367
367
  const batches = splitIntoBatches(pending, hasLines ? maxLines : 0, maxItems);
368
368
 
369
- const timeoutMs = config.limits?.agentTimeout ? Number(config.limits.agentTimeout) * 1000 : DEFAULT_AGENT_TIMEOUT * 1000;
369
+ const timeoutMs = config.agent?.timeout ? Number(config.agent.timeout) * 1000 : DEFAULT_AGENT_TIMEOUT * 1000;
370
370
  let totalEnriched = 0;
371
371
 
372
372
  for (let b = 0; b < batches.length; b++) {
@@ -32,12 +32,8 @@ import {
32
32
  buildForgePrompt,
33
33
  } from "../lib/forge-prompts.js";
34
34
  import {
35
- FALLBACK_PATCH_ORDER,
36
35
  summarizeReview,
37
- parseReviewMisses,
38
36
  parseFileResults,
39
- patchGeneratedForMisses,
40
- summarizeNeedsInput,
41
37
  } from "../lib/review-parser.js";
42
38
 
43
39
  const DEFAULT_TIMEOUT_MS = DEFAULT_AGENT_TIMEOUT * 1000;
@@ -220,11 +216,11 @@ async function main() {
220
216
  const root = repoRoot(import.meta.url);
221
217
  const config = loadConfig(root);
222
218
  const type = resolveType(config.type || "");
223
- const lang = config.output.default;
219
+ const lang = config.docs.defaultLanguage;
224
220
  const t = translate();
225
221
  const agent = resolveAgent(config, "docs.forge");
226
222
  const mode = cli.mode || DEFAULT_MODE;
227
- const timeoutMs = config.limits?.agentTimeout ? Number(config.limits.agentTimeout) * 1000 : undefined;
223
+ const timeoutMs = config.agent?.timeout ? Number(config.agent.timeout) * 1000 : undefined;
228
224
 
229
225
  if (mode === "agent" && !agent) {
230
226
  throw new Error(
@@ -441,27 +437,14 @@ async function main() {
441
437
  currentTargetFiles = fileResults.failedFiles;
442
438
  }
443
439
 
444
- const misses = parseReviewMisses(reviewOut);
445
- console.log(
446
- `[forge] parsed misses: ${FALLBACK_PATCH_ORDER.map((k) => `${k}=${(misses[k] || []).length}`).join(", ")}`,
447
- );
448
- const patchResult = patchGeneratedForMisses(root, misses, analysisData);
449
- if (patchResult.changed) {
450
- console.log("[forge] local deterministic patch applied.");
451
- for (const file of patchResult.touched) {
452
- console.log(`- patched: ${file}`);
453
- }
454
- } else if (agentFailed) {
440
+ if (agentFailed) {
455
441
  console.log(
456
442
  "[forge] no local patch candidates found after agent failure."
457
443
  );
458
444
  } else if (mode === "local" && !usedAgent) {
459
445
  console.log(t("messages:forge.needsInput"));
460
446
  console.log(t("messages:forge.reviewFeedback"));
461
- const lines = summarizeNeedsInput(reviewOut);
462
- for (const line of lines) {
463
- console.log(`- ${line}`);
464
- }
447
+ console.log(reviewFeedback);
465
448
  process.exitCode = 2;
466
449
  return;
467
450
  }
@@ -154,8 +154,8 @@ function main(ctx) {
154
154
 
155
155
  // テンプレート解決(ボトムアップ方式)
156
156
  const projectLocalDir = path.join(root, ".sdd-forge", "templates", lang, "docs");
157
- const outputConfig = config?.output;
158
- const fallbackLangs = outputConfig?.languages?.filter((l) => l !== lang) || [];
157
+ const docsConfig = config?.docs;
158
+ const fallbackLangs = docsConfig?.languages?.filter((l) => l !== lang) || [];
159
159
  const configChapters = config?.chapters;
160
160
  const chaptersOrder = resolveChaptersOrder(type, configChapters);
161
161
 
@@ -201,7 +201,7 @@ function main(ctx) {
201
201
  summaryData,
202
202
  agent,
203
203
  root,
204
- config?.documentStyle?.purpose || "",
204
+ config?.docs?.style?.purpose || "",
205
205
  );
206
206
  }
207
207
 
@@ -53,7 +53,7 @@ async function main(ctx) {
53
53
  const t = tr();
54
54
  const h = t.raw("ui:help.cmdHelp.readme");
55
55
  const o = h.options;
56
- console.log([h.usage, "", ` ${h.desc}`, "", "Options:", ` ${o.dryRun}`, ` ${o.help}`].join("\n"));
56
+ console.log([h.usage, "", ` ${h.desc}`, "", "Options:", ` ${o.lang}`, ` ${o.output}`, ` ${o.dryRun}`, ` ${o.help}`].join("\n"));
57
57
  return;
58
58
  }
59
59
 
@@ -70,8 +70,8 @@ async function main(ctx) {
70
70
  }
71
71
 
72
72
  const projectLocalDir = path.join(root, ".sdd-forge", "templates", lang, "docs");
73
- const outputConfig = config?.output;
74
- const fallbackLangs = outputConfig?.languages?.filter((l) => l !== lang) || [];
73
+ const docsConfig = config?.docs;
74
+ const fallbackLangs = docsConfig?.languages?.filter((l) => l !== lang) || [];
75
75
 
76
76
  // ボトムアップでテンプレート解決
77
77
  const configChapters = config?.chapters;
@@ -143,7 +143,7 @@ async function main(ctx) {
143
143
  const agent = loadAgentConfig(cfg, "docs.readme");
144
144
  ensureAgentWorkDir(agent, root);
145
145
  const analysis = loadFullAnalysis(root) || {};
146
- const documentStyle = cfg.documentStyle;
146
+ const documentStyle = cfg.docs?.style;
147
147
  const systemPrompt = buildTextSystemPrompt(documentStyle, lang);
148
148
  const timeoutMs = DEFAULT_AGENT_TIMEOUT * 1000;
149
149