jdd-sprint-kit 0.3.1

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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +253 -0
  3. package/bin/cli.js +48 -0
  4. package/compat/baseline.json +6 -0
  5. package/package.json +40 -0
  6. package/src/commands/compat-check.js +178 -0
  7. package/src/commands/init.js +267 -0
  8. package/src/commands/update.js +132 -0
  9. package/src/lib/adapters/codex.js +68 -0
  10. package/src/lib/copy.js +131 -0
  11. package/src/lib/detect.js +81 -0
  12. package/src/lib/fingerprint.js +152 -0
  13. package/src/lib/manifest.js +51 -0
  14. package/src/lib/merge.js +109 -0
  15. package/src/lib/prompts.js +196 -0
  16. package/templates/.claude/agents/auto-sprint.md +882 -0
  17. package/templates/.claude/agents/brownfield-scanner.md +259 -0
  18. package/templates/.claude/agents/deliverable-generator.md +429 -0
  19. package/templates/.claude/agents/judge-business.md +91 -0
  20. package/templates/.claude/agents/judge-quality.md +82 -0
  21. package/templates/.claude/agents/judge-security.md +80 -0
  22. package/templates/.claude/agents/scope-gate.md +219 -0
  23. package/templates/.claude/agents/worker.md +82 -0
  24. package/templates/.claude/commands/circuit-breaker.md +106 -0
  25. package/templates/.claude/commands/parallel.md +110 -0
  26. package/templates/.claude/commands/preview.md +85 -0
  27. package/templates/.claude/commands/specs.md +206 -0
  28. package/templates/.claude/commands/sprint.md +552 -0
  29. package/templates/.claude/commands/summarize-prd.md +290 -0
  30. package/templates/.claude/commands/validate.md +143 -0
  31. package/templates/.claude/hooks/desktop-notify.sh +9 -0
  32. package/templates/.claude/hooks/protect-readonly-paths.sh +42 -0
  33. package/templates/.claude/hooks/sprint-pre-compact.sh +42 -0
  34. package/templates/.claude/hooks/sprint-session-recovery.sh +33 -0
  35. package/templates/.claude/rules/bmad-mcp-search.md +97 -0
  36. package/templates/.claude/rules/bmad-sprint-guide.md +176 -0
  37. package/templates/.claude/rules/bmad-sprint-protocol.md +178 -0
  38. package/templates/.claude/settings.json +50 -0
  39. package/templates/.mcp.json.example +16 -0
  40. package/templates/_bmad/docs/architecture-to-epics-checklist.md +59 -0
  41. package/templates/_bmad/docs/blueprint-format-guide.md +387 -0
  42. package/templates/_bmad/docs/brownfield-context-format.md +167 -0
  43. package/templates/_bmad/docs/prd-format-guide.md +538 -0
  44. package/templates/_bmad/docs/sprint-input-format.md +496 -0
  45. package/templates/preview-template/.redocly.yaml +10 -0
  46. package/templates/preview-template/api/.gitkeep +0 -0
  47. package/templates/preview-template/index.html +12 -0
  48. package/templates/preview-template/package-lock.json +5547 -0
  49. package/templates/preview-template/package.json +33 -0
  50. package/templates/preview-template/public/mockServiceWorker.js +307 -0
  51. package/templates/preview-template/src/App.tsx +9 -0
  52. package/templates/preview-template/src/api/client.ts +32 -0
  53. package/templates/preview-template/src/components/.gitkeep +0 -0
  54. package/templates/preview-template/src/components/DevPanel.tsx +76 -0
  55. package/templates/preview-template/src/main.tsx +26 -0
  56. package/templates/preview-template/src/mocks/browser.ts +4 -0
  57. package/templates/preview-template/src/mocks/handlers.ts +3 -0
  58. package/templates/preview-template/src/pages/.gitkeep +0 -0
  59. package/templates/preview-template/src/vite-env.d.ts +1 -0
  60. package/templates/preview-template/tsconfig.json +21 -0
  61. package/templates/preview-template/vite.config.ts +6 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kangmin Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # JDD Sprint Kit
2
+
3
+ **"A single-line brief becomes a working prototype."**
4
+
5
+ Judgment-Driven Development execution extension built on BMad Method. AI builds, humans judge. User inputs (meeting notes, references, existing system context) raise AI's first-generation quality, and human time is spent only at customer-lens judgment points (JP1, JP2).
6
+
7
+ > Design philosophy: [Judgment-Driven Development](docs/judgment-driven-development.md)
8
+ > Full architecture and Sprint walkthrough: [Blueprint](docs/blueprint.md)
9
+
10
+ ---
11
+
12
+ ## Overall Flow
13
+
14
+ ```mermaid
15
+ flowchart LR
16
+ A["1. Brief Input"] --> B["2. Existing System\n(Brownfield Scan)"]
17
+ B --> C["3. Planning\n(BMAD Auto-Pipeline)"]
18
+ C --> D["4. Specs\n(Specs Generation)"]
19
+ D --> JP1{{"JP1\nIs this the right\nproduct?"}}
20
+ JP1 -->|Approve| E["5. Deliverables\n(Deliverables Gen)"]
21
+ JP1 -->|Revise| C
22
+ E --> JP2{{"JP2\nIs this the right\nexperience?"}}
23
+ JP2 -->|Approve| F["6. Parallel\n(Implementation)"]
24
+ JP2 -->|Revise| E
25
+ JP2 -.->|Re-examine requirements| JP1
26
+ F --> G["7. Validate"]
27
+ G -->|Pass| H["Done"]
28
+ G -->|Repeated failure| CB["Course Correction\n(Circuit Breaker)"]
29
+ CB --> C
30
+
31
+ style JP1 fill:#FFD700,stroke:#333
32
+ style JP2 fill:#FFD700,stroke:#333
33
+ style CB fill:#FF6B6B,stroke:#333
34
+ ```
35
+
36
+ Human involvement happens at exactly **2 points** (JP1, JP2) — everything else runs autonomously. If JP2 reveals issues with the requirements themselves, it loops back to JP1 — this is not a failure, but a normal discovery prompted by concrete deliverables.
37
+
38
+ ---
39
+
40
+ ## What Gets Generated
41
+
42
+ A single Sprint run auto-generates the following artifacts:
43
+
44
+ - **3 spec documents** — requirements.md, design.md, tasks.md
45
+ - **OpenAPI 3.1 YAML** — API specification + MSW Mock + Specmatic contract tests
46
+ - **DBML schema** — Database design (viewable as ERD on dbdiagram.io)
47
+ - **BDD/Gherkin scenarios** — Given-When-Then acceptance tests
48
+ - **React + MSW prototype** — Clickable prototype via `npm run dev`
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ ### Prerequisites
55
+
56
+ - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI
57
+ - Node.js 18+
58
+ - Git, GitHub CLI (`gh`)
59
+ - [BMad Method](https://github.com/nicholasgriffintn/bmad-method) (`npx bmad-method install`)
60
+
61
+ ### Installation
62
+
63
+ ```bash
64
+ npx jdd-sprint-kit init
65
+ ```
66
+
67
+ An interactive wizard detects your environment and installs Sprint Kit files.
68
+
69
+ ### (Optional) MCP Setup
70
+
71
+ To connect existing service data, configure MCP servers:
72
+
73
+ ```bash
74
+ cp .mcp.json.example .mcp.json
75
+ # Edit .mcp.json: update local paths for your environment
76
+ ```
77
+
78
+ ### First Sprint Run
79
+
80
+ ```bash
81
+ # In Claude Code
82
+ /sprint "Describe the feature you want to build"
83
+ ```
84
+
85
+ ### Tutorial — Try Without MCP
86
+
87
+ To experience the full Sprint Kit pipeline, use the included example project:
88
+
89
+ ```bash
90
+ # In Claude Code
91
+ /sprint test-tutor-excl
92
+ ```
93
+
94
+ This is a scenario for adding a "tutor exclusion" feature to a fictional EduTalk service. 4 meeting notes are prepared in `specs/test-tutor-excl/inputs/`, and `brownfield-context.md` substitutes for MCP scan results. No MCP setup required.
95
+
96
+ ---
97
+
98
+ ## Route Selection
99
+
100
+ 3 routes are available based on your input readiness. All routes converge into the same pipeline.
101
+
102
+ ```
103
+ [Input + Brownfield + BMad] → [Specs] → JP1 → [Deliverables] → JP2 → [Execute]
104
+
105
+ Sprint: |←──────────────── Fully Auto ───────────────────────→|
106
+ Guided: |←── BMad Dialog ──→|←────────── Auto ───────────────→|
107
+ Direct: |←── Auto ──────────────────────→|
108
+ ```
109
+
110
+ | Route | Entry Point | Best When |
111
+ |-------|-------------|-----------|
112
+ | **Sprint** | `/sprint "Brief"` or `/sprint feature-name` | You have materials (meeting notes, references) — AI builds, you judge |
113
+ | **Guided** | BMad 12-step → `/specs` → `/preview` | Exploration needed — discover and define with AI |
114
+ | **Direct** | `/specs` → `/preview` | Planning is complete — execute immediately |
115
+
116
+ > For small tasks, use BMad Quick Flow: `/quick-spec` → `/dev-story` → `/code-review`
117
+
118
+ Routes are not fixed. If you have materials but need deep exploration, use Guided with materials as reference input. After completing BMad 12-step, `/specs` auto-detects the artifacts — same as Direct.
119
+
120
+ > Details: [Blueprint §4.3 Route Selection](docs/blueprint.md#43-route-selection)
121
+
122
+ ---
123
+
124
+ ## Brownfield — Existing System Integration
125
+
126
+ AI must understand the existing service structure to avoid creating duplicate APIs or breaking existing screen flows. Brownfield data is cumulatively collected from **3 sources**:
127
+
128
+ 1. **document-project artifacts** — Structured docs generated by BMad `/document-project` workflow scanning the existing codebase
129
+ 2. **MCP servers** — External memory stores the AI queries on demand
130
+ 3. **Local codebase** — Direct scan of source code in the same repository
131
+
132
+ ### Brownfield Context Generation
133
+
134
+ #### Auto-Generation (Sprint Route)
135
+
136
+ `/sprint` automatically generates brownfield-context.md:
137
+
138
+ 1. **Phase 0** — Topology detection: detect document-project presence, MCP connectivity, build tools to determine project type (`standalone` / `co-located` / `msa` / `monorepo`)
139
+ 2. **Pass 1 (Broad Scan)** — Collect domain concepts (L1) and behavior patterns (L2) based on Brief keywords
140
+ 3. **Pass 2 (Targeted Scan)** — After Architecture/Epics, collect integration points (L3) and code-level details (L4)
141
+
142
+ Results are recorded in `specs/{feature}/planning-artifacts/brownfield-context.md` as L1~L4 layers.
143
+
144
+ #### Pre-Sprint Preparation: document-project (Recommended)
145
+
146
+ Running BMad `/document-project` before Sprint improves scan quality:
147
+
148
+ ```bash
149
+ # In Claude Code
150
+ /document-project
151
+ ```
152
+
153
+ This analyzes the existing codebase and generates structured docs under `_bmad-output/` (`project-overview.md`, `api-contracts.md`, `data-models.md`, etc.). Sprint's Brownfield Scanner uses these as seed data to narrow MCP/local scan scope.
154
+
155
+ #### MCP Server Configuration
156
+
157
+ To connect external service data, configure MCP servers:
158
+
159
+ | MCP Server | Provided Information |
160
+ |------------|---------------------|
161
+ | `backend-docs` | API specs, domain policies, business rules, data models |
162
+ | `client-docs` | Component structure, state management patterns, code conventions, screen flows |
163
+ | `svc-map` | Customer journeys, screen screenshots, flow graphs, service maps |
164
+ | `figma` | Latest wireframes, design tokens, component specs (live OAuth) |
165
+
166
+ #### Manual Preparation (Without MCP)
167
+
168
+ You can manually write brownfield-context.md and provide it to Sprint without MCP:
169
+
170
+ ```bash
171
+ # Place directly in the feature directory
172
+ specs/{feature}/brownfield-context.md
173
+ # or
174
+ specs/{feature}/planning-artifacts/brownfield-context.md
175
+ ```
176
+
177
+ Sprint detects existing files and uses them instead of re-scanning those levels. See `_bmad/docs/brownfield-context-format.md` for the format. A manually written brownfield-context.md sample is included in the tutorial example (`specs/test-tutor-excl/`).
178
+
179
+ #### Greenfield Projects
180
+
181
+ For Greenfield projects with no existing system, Sprint works normally without Brownfield data. Auto-detected in Phase 0 — no configuration needed.
182
+
183
+ > Details: [Blueprint §4.1 System Components](docs/blueprint.md#41-system-components)
184
+
185
+ ---
186
+
187
+ ## Project Structure
188
+
189
+ ```
190
+ {project-root}/
191
+ ├── CLAUDE.md # Project-specific rules (user-maintained)
192
+ ├── .mcp.json # MCP server config (.gitignored)
193
+ ├── .claude/
194
+ │ ├── agents/ # Sprint agents (8)
195
+ │ ├── commands/ # Sprint commands + BMad agents/workflows
196
+ │ ├── rules/ # Sprint rules (bmad-*.md)
197
+ │ ├── hooks/ # Hook scripts (notification, protection, recovery)
198
+ │ └── settings.json # Hook settings
199
+ ├── _bmad/ # BMad Method (runtime reference)
200
+ │ └── docs/ # Format guides
201
+ ├── preview-template/ # Prototype scaffold (Vite + React + MSW)
202
+ ├── specs/ # Per-feature Sprint artifacts
203
+ │ └── {feature}/
204
+ │ ├── inputs/ # User Brief + reference materials
205
+ │ ├── planning-artifacts/ # BMad artifacts (PRD, Architecture, Epics)
206
+ │ ├── requirements.md # Requirements
207
+ │ ├── design.md # Design
208
+ │ ├── tasks.md # Tasks (Entropy + File Ownership)
209
+ │ ├── brownfield-context.md # Existing system context
210
+ │ ├── api-spec.yaml # OpenAPI 3.1
211
+ │ ├── schema.dbml # DB schema
212
+ │ ├── bdd-scenarios/ # Gherkin acceptance tests
213
+ │ └── preview/ # React + MSW prototype
214
+ └── docs/ # Framework documentation
215
+ ```
216
+
217
+ > Sprint Kit files (`.claude/agents/`, `.claude/commands/`, `.claude/rules/bmad-*`, `_bmad/`) should not be modified directly. Update via `npx jdd-sprint-kit update`.
218
+
219
+ ---
220
+
221
+ ## Multi-IDE Support
222
+
223
+ Sprint Kit's canonical definition files live in `.claude/`. Other AI IDEs beyond Claude Code are also supported.
224
+
225
+ **Claude Code** — Default IDE. No additional setup required.
226
+
227
+ **Codex CLI** — Use the `--ide` option during installation to generate Codex files:
228
+
229
+ ```bash
230
+ npx jdd-sprint-kit init --ide claude-code,codex
231
+ ```
232
+
233
+ In Codex, run Sprint commands via `$sprint`, `$specs`, `$preview`, `$parallel`, `$validate`.
234
+
235
+ **Gemini Code Assist** — TOML wrappers are auto-generated in `.gemini/commands/`.
236
+
237
+ > When the canonical files (`.claude/`) are modified, `npx jdd-sprint-kit update` also refreshes the converted files.
238
+
239
+ ---
240
+
241
+ ## Documentation
242
+
243
+ | Document | Contents |
244
+ |----------|----------|
245
+ | [Blueprint](docs/blueprint.md) | Full product picture — 8-Section (Problem → Thesis → User Model → Value Chain → Judgment → Constraints → Risk → Current State) |
246
+ | [Judgment-Driven Development](docs/judgment-driven-development.md) | Design philosophy + definition and discussion of design judgments |
247
+ | [BMad Method](https://github.com/nicholasgriffintn/bmad-method) | AI role-play framework (external) |
248
+
249
+ ---
250
+
251
+ ## License
252
+
253
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import { readFileSync } from 'node:fs';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { dirname, join } from 'node:path';
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
10
+
11
+ const program = new Command();
12
+
13
+ program
14
+ .name('jdd-sprint-kit')
15
+ .description('Judgment-Driven Development toolkit for BMad Method')
16
+ .version(pkg.version);
17
+
18
+ program
19
+ .command('init')
20
+ .description('Install Sprint Kit into the current project')
21
+ .option('-y, --yes', 'Non-interactive mode (accept all defaults)')
22
+ .option('--ide <tools>', 'IDE tools (comma-separated: claude-code,codex)', 'claude-code')
23
+ .option('--dry-run', 'Show what would be installed without making changes')
24
+ .action(async (options) => {
25
+ const { runInit } = await import('../src/commands/init.js');
26
+ await runInit(options);
27
+ });
28
+
29
+ program
30
+ .command('update')
31
+ .description('Update Sprint Kit files to the latest version')
32
+ .option('-y, --yes', 'Non-interactive mode (accept all defaults)')
33
+ .option('--dry-run', 'Show what would be updated without making changes')
34
+ .action(async (options) => {
35
+ const { runUpdate } = await import('../src/commands/update.js');
36
+ await runUpdate(options);
37
+ });
38
+
39
+ program
40
+ .command('compat-check')
41
+ .description('Verify BMad Method compatibility')
42
+ .option('--json', 'Output results as JSON')
43
+ .action(async (options) => {
44
+ const { runCompatCheck } = await import('../src/commands/compat-check.js');
45
+ await runCompatCheck(options);
46
+ });
47
+
48
+ program.parse();
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": "0.1.0",
3
+ "bmadVersion": "6.0.0-Beta.8",
4
+ "generatedAt": "2026-02-16",
5
+ "fingerprints": {}
6
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "jdd-sprint-kit",
3
+ "version": "0.3.1",
4
+ "description": "Judgment-Driven Development toolkit for BMad Method",
5
+ "type": "module",
6
+ "bin": {
7
+ "jdd-sprint-kit": "bin/cli.js"
8
+ },
9
+ "scripts": {
10
+ "prepublishOnly": "node scripts/build-templates.js"
11
+ },
12
+ "files": [
13
+ "bin/",
14
+ "src/",
15
+ "templates/",
16
+ "compat/"
17
+ ],
18
+ "dependencies": {
19
+ "commander": "^12.0.0",
20
+ "@clack/prompts": "^0.9.0",
21
+ "fs-extra": "^11.0.0"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/kangminlee-maker/jdd-sprint-kit.git"
30
+ },
31
+ "keywords": [
32
+ "bmad",
33
+ "sprint",
34
+ "ai-agent",
35
+ "claude-code",
36
+ "automation",
37
+ "jdd",
38
+ "judgment-driven-development"
39
+ ]
40
+ }
@@ -0,0 +1,178 @@
1
+ import * as p from '@clack/prompts';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { dirname } from 'node:path';
6
+ import { detect, checkBmadCompat } from '../lib/detect.js';
7
+ import { BMAD_COMPAT, BMAD_INTERFACES, SPRINT_KIT_VERSION } from '../lib/manifest.js';
8
+ import { collectFingerprints, compareFingerprints, resolveBmadPath } from '../lib/fingerprint.js';
9
+
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+
12
+ export async function runCompatCheck(options = {}) {
13
+ const { json: jsonOutput = false } = options;
14
+ const projectDir = process.cwd();
15
+
16
+ const env = detect(projectDir);
17
+ const results = {
18
+ version: SPRINT_KIT_VERSION,
19
+ bmadVersion: env.bmadVersion,
20
+ bmadCompat: checkBmadCompat(env.bmadVersion),
21
+ stages: [],
22
+ overallVerdict: 'PASS',
23
+ };
24
+
25
+ // --- Stage 1: Existence ---
26
+ const stage1 = { name: 'existence', checks: [], verdict: 'PASS' };
27
+
28
+ for (const iface of BMAD_INTERFACES) {
29
+ const filePath = resolveBmadPath(projectDir, iface);
30
+ const exists = filePath ? existsSync(filePath) : false;
31
+ stage1.checks.push({
32
+ interface: `${iface.type}:${iface.path}`,
33
+ exists,
34
+ path: filePath,
35
+ });
36
+ if (!exists) stage1.verdict = 'FAIL';
37
+ }
38
+
39
+ results.stages.push(stage1);
40
+
41
+ // --- Stage 2: Structure ---
42
+ const stage2 = { name: 'structure', checks: [], verdict: 'PASS' };
43
+
44
+ // Check config.yaml has required fields
45
+ const configPath = join(projectDir, '_bmad', 'bmm', 'config.yaml');
46
+ if (existsSync(configPath)) {
47
+ const configContent = readFileSync(configPath, 'utf-8');
48
+ const requiredFields = ['project_name', 'planning_artifacts', 'communication_language'];
49
+ for (const field of requiredFields) {
50
+ const has = new RegExp(`^${field}:`, 'm').test(configContent);
51
+ stage2.checks.push({ file: 'config.yaml', field, exists: has });
52
+ if (!has) stage2.verdict = 'WARN';
53
+ }
54
+ }
55
+
56
+ // Check agent-manifest.csv has expected columns
57
+ const manifestPath = join(projectDir, '_bmad', '_config', 'agent-manifest.csv');
58
+ if (existsSync(manifestPath)) {
59
+ const manifestContent = readFileSync(manifestPath, 'utf-8');
60
+ const firstLine = manifestContent.split('\n')[0] || '';
61
+ const requiredColumns = ['name', 'role', 'path'];
62
+ for (const col of requiredColumns) {
63
+ const has = firstLine.toLowerCase().includes(col);
64
+ stage2.checks.push({ file: 'agent-manifest.csv', column: col, exists: has });
65
+ if (!has) stage2.verdict = 'WARN';
66
+ }
67
+ }
68
+
69
+ results.stages.push(stage2);
70
+
71
+ // --- Stage 3: Interface fingerprint ---
72
+ const stage3 = { name: 'fingerprint', changes: [], verdict: 'PASS' };
73
+
74
+ const baselinePath = join(__dirname, '..', '..', 'compat', 'baseline.json');
75
+ if (existsSync(baselinePath)) {
76
+ const baseline = JSON.parse(readFileSync(baselinePath, 'utf-8'));
77
+ const currentFingerprints = collectFingerprints(projectDir);
78
+
79
+ for (const [key, currentFp] of Object.entries(currentFingerprints)) {
80
+ if (baseline.fingerprints[key]) {
81
+ const diff = compareFingerprints(baseline.fingerprints[key], currentFp);
82
+ if (diff.changes.length > 0) {
83
+ stage3.changes.push({ interface: key, ...diff });
84
+ if (diff.verdict === 'REVIEW_NEEDED') stage3.verdict = 'REVIEW_NEEDED';
85
+ else if (diff.verdict === 'WARN' && stage3.verdict === 'PASS') stage3.verdict = 'WARN';
86
+ }
87
+ }
88
+ }
89
+ } else {
90
+ stage3.verdict = 'SKIP';
91
+ stage3.reason = 'No baseline.json found';
92
+ }
93
+
94
+ results.stages.push(stage3);
95
+
96
+ // Overall verdict
97
+ if (results.stages.some(s => s.verdict === 'FAIL')) {
98
+ results.overallVerdict = 'FAIL';
99
+ } else if (results.stages.some(s => s.verdict === 'REVIEW_NEEDED')) {
100
+ results.overallVerdict = 'REVIEW_NEEDED';
101
+ } else if (results.stages.some(s => s.verdict === 'WARN')) {
102
+ results.overallVerdict = 'WARN';
103
+ }
104
+
105
+ // BMad version compat
106
+ if (results.bmadCompat === 'below_minimum') {
107
+ results.overallVerdict = 'FAIL';
108
+ }
109
+
110
+ // Output
111
+ if (jsonOutput) {
112
+ console.log(JSON.stringify(results, null, 2));
113
+ process.exit(results.overallVerdict === 'FAIL' ? 1 : 0);
114
+ return;
115
+ }
116
+
117
+ // Pretty output
118
+ p.intro(`BMad Compatibility Check — Sprint Kit v${SPRINT_KIT_VERSION}`);
119
+
120
+ // Version info
121
+ const compatLabel = {
122
+ compatible: '✓ compatible',
123
+ above_verified: '⚠ above verified',
124
+ below_minimum: '✗ below minimum',
125
+ unknown: '? unknown',
126
+ }[results.bmadCompat];
127
+
128
+ p.note(
129
+ [
130
+ `BMad Method: ${env.bmadVersion || 'not found'} ${compatLabel}`,
131
+ `Verified: ${BMAD_COMPAT.verified} (${BMAD_COMPAT.verifiedAt})`,
132
+ `Minimum: ${BMAD_COMPAT.minimum}`,
133
+ ].join('\n'),
134
+ '버전 호환성'
135
+ );
136
+
137
+ // Stage 1: Existence
138
+ const existLines = stage1.checks.map(c =>
139
+ ` ${c.exists ? '✓' : '✗'} ${c.interface}`
140
+ );
141
+ p.note(existLines.join('\n'), `Stage 1: 존재 검증 — ${stage1.verdict}`);
142
+
143
+ // Stage 2: Structure
144
+ if (stage2.checks.length > 0) {
145
+ const structLines = stage2.checks.map(c =>
146
+ ` ${c.exists ? '✓' : '✗'} ${c.file}: ${c.field || c.column}`
147
+ );
148
+ p.note(structLines.join('\n'), `Stage 2: 구조 검증 — ${stage2.verdict}`);
149
+ }
150
+
151
+ // Stage 3: Fingerprint
152
+ if (stage3.verdict === 'SKIP') {
153
+ p.log.info(`Stage 3: Fingerprint — SKIP (${stage3.reason})`);
154
+ } else if (stage3.changes.length === 0) {
155
+ p.log.success('Stage 3: Fingerprint — PASS (변경 없음)');
156
+ } else {
157
+ const fpLines = [];
158
+ for (const change of stage3.changes) {
159
+ fpLines.push(` ${change.interface}: ${change.verdict}`);
160
+ for (const c of change.changes) {
161
+ fpLines.push(` ${c.change} ${c.type}: ${c.value}`);
162
+ }
163
+ }
164
+ p.note(fpLines.join('\n'), `Stage 3: Fingerprint — ${stage3.verdict}`);
165
+ }
166
+
167
+ // Overall
168
+ const verdictEmoji = {
169
+ PASS: '✓',
170
+ WARN: '⚠',
171
+ REVIEW_NEEDED: '⚠',
172
+ FAIL: '✗',
173
+ }[results.overallVerdict];
174
+
175
+ p.outro(`${verdictEmoji} Overall: ${results.overallVerdict}`);
176
+
177
+ process.exit(results.overallVerdict === 'FAIL' ? 1 : 0);
178
+ }