specdx 0.4.0-alpha.16 → 0.4.0-alpha.18
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/.claude-plugin/plugin.json +1 -1
- package/README.md +435 -0
- package/dist/{check-6ULNLONS.js → check-PQQGR4KP.js} +6 -6
- package/dist/check-PQQGR4KP.js.map +1 -0
- package/dist/chunk-33FELECG.js +179 -0
- package/dist/chunk-33FELECG.js.map +1 -0
- package/dist/{chunk-4HPWTWBL.js → chunk-AXCGMUU7.js} +11 -6
- package/dist/chunk-AXCGMUU7.js.map +1 -0
- package/dist/{chunk-V7JOVK6D.js → chunk-FX4NRQHE.js} +139 -32
- package/dist/chunk-FX4NRQHE.js.map +1 -0
- package/dist/{chunk-PEC5LAVE.js → chunk-RI2SFGMR.js} +13 -5
- package/dist/chunk-RI2SFGMR.js.map +1 -0
- package/dist/{chunk-SDDTD4R3.js → chunk-TF7WSPFV.js} +31 -11
- package/dist/chunk-TF7WSPFV.js.map +1 -0
- package/dist/{diff-AWFDXYX4.js → diff-IOBAJMKU.js} +4 -4
- package/dist/diff-IOBAJMKU.js.map +1 -0
- package/dist/{dist-2YMKBA6A.js → dist-HRY2V5MO.js} +12 -6
- package/dist/dist-HRY2V5MO.js.map +1 -0
- package/dist/{dist-SWJSMLIP.js → dist-WXT4UJ55.js} +2 -2
- package/dist/generate-NSTYQOAV.js +21 -0
- package/dist/generate-NSTYQOAV.js.map +1 -0
- package/dist/{generate-story-OV3PFJN6.js → generate-story-RFAPULQY.js} +32 -7
- package/dist/generate-story-RFAPULQY.js.map +1 -0
- package/dist/{generate-test-plan-OGWEIXR2.js → generate-test-plan-M22PCW73.js} +13 -3
- package/dist/generate-test-plan-M22PCW73.js.map +1 -0
- package/dist/{graph-KZDCVMLT.js → graph-OKUMHR3Q.js} +2 -2
- package/dist/graph-OKUMHR3Q.js.map +1 -0
- package/dist/index.js +170 -141
- package/dist/index.js.map +1 -1
- package/dist/{lint-A5AXYDSO.js → lint-ADR7L6AP.js} +4 -4
- package/dist/lint-ADR7L6AP.js.map +1 -0
- package/dist/main.js +19 -142
- package/dist/main.js.map +1 -1
- package/dist/{mcp-CWJKX27S.js → mcp-A6CCWSS2.js} +3 -3
- package/dist/mcp-A6CCWSS2.js.map +1 -0
- package/dist/{migrate-76BXVREF.js → migrate-LAMRDT3V.js} +3 -3
- package/dist/migrate-LAMRDT3V.js.map +1 -0
- package/dist/{pack-I5WFM6B6.js → pack-B3KYRKUR.js} +3 -3
- package/dist/pack-B3KYRKUR.js.map +1 -0
- package/dist/{ready-2M5HXTRZ.js → ready-GH4YKVOX.js} +14 -5
- package/dist/ready-GH4YKVOX.js.map +1 -0
- package/dist/skills/core/specdx-onboard/SKILL.md +3 -2
- package/dist/{skills-IKRQ3IZP.js → skills-LHFTTEJ7.js} +3 -3
- package/dist/skills-LHFTTEJ7.js.map +1 -0
- package/dist/{status-QLG3ZKS7.js → status-PQKPTDP5.js} +4 -4
- package/dist/status-PQKPTDP5.js.map +1 -0
- package/dist/{update-HGZVLKSL.js → update-VAC6XV5E.js} +4 -4
- package/dist/update-VAC6XV5E.js.map +1 -0
- package/dist/{validate-HMOCZJ2M.js → validate-WIB246IE.js} +2 -2
- package/dist/validate-WIB246IE.js.map +1 -0
- package/hooks/hooks.json +1 -1
- package/package.json +19 -6
- package/dist/check-6ULNLONS.js.map +0 -1
- package/dist/chunk-4HPWTWBL.js.map +0 -1
- package/dist/chunk-PEC5LAVE.js.map +0 -1
- package/dist/chunk-SDDTD4R3.js.map +0 -1
- package/dist/chunk-V7JOVK6D.js.map +0 -1
- package/dist/diff-AWFDXYX4.js.map +0 -1
- package/dist/dist-2YMKBA6A.js.map +0 -1
- package/dist/explain-M2VXXXGP.js +0 -113
- package/dist/explain-M2VXXXGP.js.map +0 -1
- package/dist/generate-XG52JCWH.js +0 -15
- package/dist/generate-XG52JCWH.js.map +0 -1
- package/dist/generate-story-OV3PFJN6.js.map +0 -1
- package/dist/generate-test-plan-OGWEIXR2.js.map +0 -1
- package/dist/graph-KZDCVMLT.js.map +0 -1
- package/dist/lint-A5AXYDSO.js.map +0 -1
- package/dist/mcp-CWJKX27S.js.map +0 -1
- package/dist/migrate-76BXVREF.js.map +0 -1
- package/dist/pack-I5WFM6B6.js.map +0 -1
- package/dist/ready-2M5HXTRZ.js.map +0 -1
- package/dist/skills-IKRQ3IZP.js.map +0 -1
- package/dist/status-QLG3ZKS7.js.map +0 -1
- package/dist/update-HGZVLKSL.js.map +0 -1
- package/dist/validate-HMOCZJ2M.js.map +0 -1
- /package/dist/{dist-SWJSMLIP.js.map → dist-WXT4UJ55.js.map} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
# specdx
|
|
2
|
+
|
|
3
|
+
> The context engine for spec-driven development — keeps AI coding sessions grounded in validated, token-budgeted spec context.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/specdx)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/umxr/specdx/actions/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What is specdx?
|
|
12
|
+
|
|
13
|
+
specdx does a few things really well: it gives your project specs (PRDs, technical designs, user stories, test plans, ADRs, API contracts) a formal schema, **validates and lints** them, **packs** them into token-optimised context for LLM sessions, and **tracks freshness** so drift between specs gets caught before it compounds.
|
|
14
|
+
|
|
15
|
+
No LLM calls in the core pipeline. No API keys required. Deterministic validation you can run in CI.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g specdx
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## The Real-World Workflow
|
|
24
|
+
|
|
25
|
+
specdx fits into how developers actually work with AI coding tools. Here's what day-to-day usage looks like.
|
|
26
|
+
|
|
27
|
+
### Setting Up a New Project
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd your-project
|
|
31
|
+
specdx init --name "my-app" --template lightweight
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This creates `spec.config.yaml` and starter specs in `specs/`. Five templates available:
|
|
35
|
+
|
|
36
|
+
| Template | What you get | Best for |
|
|
37
|
+
|----------|-------------|----------|
|
|
38
|
+
| `lightweight` | PRD + Technical Design | Small projects, solo devs |
|
|
39
|
+
| `bmad` | PRD + Technical Design + Test Plan + stories/ + adr/ | Full methodology |
|
|
40
|
+
| `api-first` | Technical Design + API Contract + Test Plan | Backend/API projects |
|
|
41
|
+
| `quick` | Single Quick Spec | Rapid prototyping |
|
|
42
|
+
| `context` | Project Context only | Adding to existing projects |
|
|
43
|
+
|
|
44
|
+
### Adding specdx to an Existing Project
|
|
45
|
+
|
|
46
|
+
If you already have a codebase and want to introduce specs:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd existing-project
|
|
50
|
+
specdx init --name "my-app" --template context
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Start with `context` to create a project-context spec describing your stack, conventions, and constraints. Then add specs incrementally as you plan new work:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Add a PRD when you're planning a feature
|
|
57
|
+
# Add a technical design when you're making architecture decisions
|
|
58
|
+
# Add user stories when you're breaking work into tasks
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Edit `spec.config.yaml` to register each new spec with its type and dependencies.
|
|
62
|
+
|
|
63
|
+
### Daily Development Loop
|
|
64
|
+
|
|
65
|
+
This is the core loop. Every coding session follows the same pattern:
|
|
66
|
+
|
|
67
|
+
**1. Load context before you code**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
specdx pack --task "implement user authentication" --copy
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This scores every spec in your suite for relevance to your task, allocates a token budget, compresses boilerplate, and copies the result to your clipboard. Paste it into your LLM session or let the Claude Code skill handle it automatically.
|
|
74
|
+
|
|
75
|
+
**2. Write code informed by specs**
|
|
76
|
+
|
|
77
|
+
Your LLM session now has the right context — the PRD features you're implementing, the technical constraints, the acceptance criteria, the API contract. No manual copy-pasting, no guessing which specs matter.
|
|
78
|
+
|
|
79
|
+
**3. Lint before committing**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
specdx lint
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Validates frontmatter, checks required sections, verifies cross-references, detects circular dependencies, flags vague language, and catches hardcoded secrets in specs. Three presets: `minimal`, `recommended`, `strict`.
|
|
86
|
+
|
|
87
|
+
**4. Keep specs fresh**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
specdx diff # what changed, and which downstream specs it affects
|
|
91
|
+
specdx ready # is the suite fit to implement from?
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If you updated the PRD but not the test plan that depends on it, `diff` flags it before the staleness compounds.
|
|
95
|
+
|
|
96
|
+
### Planning New Work
|
|
97
|
+
|
|
98
|
+
When you're starting a new feature or project phase:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Check what state the spec suite is in
|
|
102
|
+
specdx status
|
|
103
|
+
|
|
104
|
+
# See the dependency graph
|
|
105
|
+
specdx graph
|
|
106
|
+
|
|
107
|
+
# Check if specs are ready for implementation
|
|
108
|
+
specdx ready
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`ready` validates that all required specs exist, lint is clean, no references are broken, no specs are stale, and PRD features have corresponding user stories. It's the gate between "planning" and "building."
|
|
112
|
+
|
|
113
|
+
### Reviewing Changes
|
|
114
|
+
|
|
115
|
+
When specs change (or should have changed):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# What specs changed since main?
|
|
119
|
+
specdx diff
|
|
120
|
+
|
|
121
|
+
# What's the downstream impact?
|
|
122
|
+
specdx diff --base main --head HEAD
|
|
123
|
+
|
|
124
|
+
# Generate a changelog for sprint review
|
|
125
|
+
specdx diff --base v1.0 --head HEAD --format changelog
|
|
126
|
+
|
|
127
|
+
# Include specs you haven't committed yet
|
|
128
|
+
specdx diff --working
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`diff` walks the dependency graph to find downstream specs affected by upstream changes. If you updated the PRD but forgot to update the test plan that depends on it, `diff` flags it.
|
|
132
|
+
|
|
133
|
+
### Onboarding New Team Members
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
specdx status
|
|
137
|
+
specdx graph
|
|
138
|
+
specdx pack --full
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`status` reports what specs exist and how healthy they are, `graph` shows how they relate, and `pack --full` loads the content itself. A new developer can understand the project's intent without opening a spec file. The `specdx-onboard` skill drives this sequence as a guided tour.
|
|
142
|
+
|
|
143
|
+
### CI Integration
|
|
144
|
+
|
|
145
|
+
Add spec health checks to your CI pipeline with the GitHub Action:
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
# .github/workflows/specs.yml
|
|
149
|
+
- uses: umxr/specdx/packages/github-action@v0.4.0
|
|
150
|
+
with:
|
|
151
|
+
working-directory: .
|
|
152
|
+
preset: recommended
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The action runs lint + diff on every PR, posts a formatted comment with results, and can block merges on spec health failures. Configure severity thresholds in `spec.config.yaml`:
|
|
156
|
+
|
|
157
|
+
```yaml
|
|
158
|
+
ci:
|
|
159
|
+
block_on: ["error"]
|
|
160
|
+
post_comment: true
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Experimental Features
|
|
166
|
+
|
|
167
|
+
These ship with specdx but are **not part of the stable surface** — they lean on static code analysis, which is inherently fuzzy, and their output and interfaces may change or produce noise. They are flagged `[experimental]` in CLI help.
|
|
168
|
+
|
|
169
|
+
| Command | What it does |
|
|
170
|
+
|---------|-------------|
|
|
171
|
+
| `specdx check` | Spec-to-implementation drift analysis: extracts routes (Express, Hono, Next.js), types (TS, Zod, Prisma), and tests from your code and compares them against specs |
|
|
172
|
+
| Declared artifacts | Framework-agnostic checkable surfaces for `check`: a spec's optional `artifacts:` frontmatter lists files that must exist and names they must export, so any project — static sites, CLIs, libraries — gets drift checking. See below. |
|
|
173
|
+
| `specdx check --ai` | Sends check findings to Claude for assessment (requires `ANTHROPIC_API_KEY`) |
|
|
174
|
+
| `specdx update --from-code` | Suggests spec updates from check findings |
|
|
175
|
+
| `specdx generate test-plan` | Generates test-plan stubs from story acceptance criteria |
|
|
176
|
+
| `specdx migrate` | Schema-version migration for spec suites |
|
|
177
|
+
|
|
178
|
+
Feedback on these is especially welcome — accuracy improvements (confidence scoring, better matching) are what graduates them to stable.
|
|
179
|
+
|
|
180
|
+
### Declared artifacts
|
|
181
|
+
|
|
182
|
+
When no framework extractor applies (Astro, static sites, CLIs, libraries), declare what "implemented" means directly in a spec's frontmatter:
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
artifacts:
|
|
186
|
+
- path: "middleware.ts"
|
|
187
|
+
- path: "scripts/export-crawler-log.mjs"
|
|
188
|
+
- path: "src/lib/bots.ts"
|
|
189
|
+
exports: ["BOT_SIGNATURES"]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`specdx check` verifies each `path` exists and each name in `exports` is exported from it (export checks use ts-morph and are skipped with a note — never silently passed — when it isn't installed). Declared artifacts count toward the implementation score as their own category and make a spec checkable on any stack.
|
|
193
|
+
|
|
194
|
+
**Enforcement follows the spec's `status`**, so you can declare artifacts in a spec written before the code exists:
|
|
195
|
+
|
|
196
|
+
| Spec status | Declared file or export missing | Exit code |
|
|
197
|
+
|---|---|---|
|
|
198
|
+
| `draft`, `review`, `superseded` | reported as **pending** — planned, not yet built. Excluded from the score. | 0 |
|
|
199
|
+
| `approved` | reported as a **missing** error — the spec says this should exist | 1 |
|
|
200
|
+
|
|
201
|
+
The rule applies identically to a planned `path` and a planned entry in `exports`, so a spec can declare that an existing file will gain a new export. Files and exports that *do* exist are always verified, whatever the status. Flipping a spec to `approved` is what makes its contract enforceable, so `check` can tell "this is a plan for unbuilt work" apart from "this was approved but three of its five artifacts are missing".
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Claude Code Integration
|
|
206
|
+
|
|
207
|
+
specdx ships as a Claude Code plugin with 9 skills that automate the workflow above.
|
|
208
|
+
|
|
209
|
+
### Automatic Setup
|
|
210
|
+
|
|
211
|
+
Install specdx as a dev dependency and the plugin is discovered automatically:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
npm install -D specdx
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Or install skills manually:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
specdx skills install
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Skills install to `.claude/skills/<name>/SKILL.md` and follow the
|
|
224
|
+
[Agent Skills specification](https://agentskills.io/specification).
|
|
225
|
+
|
|
226
|
+
### Skills
|
|
227
|
+
|
|
228
|
+
| Skill | What it does |
|
|
229
|
+
|-------|-------------|
|
|
230
|
+
| `specdx-start-task` | Loads spec context before coding — runs `pack --task` and injects the result |
|
|
231
|
+
| `specdx-author-spec` | Guides spec creation with iterative linting gates between sections |
|
|
232
|
+
| `specdx-plan-from-spec` | Generates implementation plans grounded in the spec suite |
|
|
233
|
+
| `specdx-verify` | *(experimental)* Verifies implementation against specs using `check` |
|
|
234
|
+
| `specdx-check-drift` | *(experimental)* Cross-references code changes vs spec definitions |
|
|
235
|
+
| `specdx-pre-commit` | Runs lint + diff before commits to catch drift early |
|
|
236
|
+
| `specdx-review-spec` | Multi-layer quality review (completeness, consistency, adversarial) |
|
|
237
|
+
| `specdx-onboard` | Guided overview for new developers |
|
|
238
|
+
| `specdx-sprint-review` | Generates shareable spec health summary for standups |
|
|
239
|
+
|
|
240
|
+
### MCP Server
|
|
241
|
+
|
|
242
|
+
specdx also exposes all tools over MCP (Model Context Protocol) for programmatic access:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
specdx mcp
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
7 tools available: `sdx_validate`, `sdx_lint`, `sdx_pack`, `sdx_status`, `sdx_check`, `sdx_diff`, `sdx_graph`.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Spec File Format
|
|
253
|
+
|
|
254
|
+
Every spec is a Markdown file with YAML frontmatter:
|
|
255
|
+
|
|
256
|
+
```markdown
|
|
257
|
+
---
|
|
258
|
+
id: "prd-001"
|
|
259
|
+
type: "prd"
|
|
260
|
+
title: "User Authentication System"
|
|
261
|
+
status: "approved"
|
|
262
|
+
version: "1.0"
|
|
263
|
+
created: "2026-03-01"
|
|
264
|
+
authors: ["alice"]
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Problem Statement
|
|
268
|
+
|
|
269
|
+
Our application has no authentication...
|
|
270
|
+
|
|
271
|
+
## Goals
|
|
272
|
+
|
|
273
|
+
1. Support email/password login
|
|
274
|
+
2. ...
|
|
275
|
+
|
|
276
|
+
## Non-Goals
|
|
277
|
+
|
|
278
|
+
- Social login (Phase 2)
|
|
279
|
+
- ...
|
|
280
|
+
|
|
281
|
+
## Features
|
|
282
|
+
|
|
283
|
+
- **F1 Login Flow**: Email and password with rate limiting...
|
|
284
|
+
- **F2 Session Management**: JWT tokens with refresh...
|
|
285
|
+
|
|
286
|
+
## Success Criteria
|
|
287
|
+
|
|
288
|
+
- 99.9% auth uptime
|
|
289
|
+
- < 200ms login response time
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Spec Types
|
|
293
|
+
|
|
294
|
+
| Type | Required Sections | Extra Fields |
|
|
295
|
+
|------|------------------|--------------|
|
|
296
|
+
| `prd` | Problem Statement, Goals, Non-Goals, Features, Success Criteria | — |
|
|
297
|
+
| `technical-design` | Overview, Architecture, Data Model, API Design, Dependencies, Risks, Open Questions | — |
|
|
298
|
+
| `user-story` | Description, Acceptance Criteria, Dependencies, Notes | `story_id`, `priority`, `estimate` |
|
|
299
|
+
| `test-plan` | Scope, Test Cases, Coverage Matrix, Edge Cases | — |
|
|
300
|
+
| `adr` | Context, Decision, Status, Consequences | — |
|
|
301
|
+
| `api-contract` | Endpoints, Request/Response Schemas, Auth, Error Codes | — |
|
|
302
|
+
| `epic` | Overview, Stories, Acceptance Criteria, Dependencies | `epic_id`, `priority` |
|
|
303
|
+
| `quick-spec` | Intent, Boundaries, Tasks | — |
|
|
304
|
+
| `project-context` | Technology Stack, Critical Implementation Rules, Coding Patterns | — |
|
|
305
|
+
|
|
306
|
+
### Required Frontmatter
|
|
307
|
+
|
|
308
|
+
| Field | Type | Description |
|
|
309
|
+
|-------|------|-------------|
|
|
310
|
+
| `id` | string | Unique identifier within the spec suite |
|
|
311
|
+
| `type` | enum | One of the 9 spec types above |
|
|
312
|
+
| `title` | string | Human-readable title |
|
|
313
|
+
| `status` | enum | `draft`, `review`, `approved`, `superseded` |
|
|
314
|
+
| `version` | string | Version string (e.g. `"1.0"`) |
|
|
315
|
+
| `created` | string | ISO 8601 date — must be quoted in YAML |
|
|
316
|
+
| `authors` | string[] | At least one author |
|
|
317
|
+
|
|
318
|
+
### Cross-References
|
|
319
|
+
|
|
320
|
+
Specs can reference each other in frontmatter:
|
|
321
|
+
|
|
322
|
+
```yaml
|
|
323
|
+
references:
|
|
324
|
+
- id: "tech-001"
|
|
325
|
+
relationship: "depends-on"
|
|
326
|
+
- id: "story-auth-001"
|
|
327
|
+
relationship: "decomposed-into"
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Relationships: `implemented-by`, `decomposed-into`, `depends-on`, `supersedes`, `related-to`.
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Configuration
|
|
335
|
+
|
|
336
|
+
`spec.config.yaml` at the project root:
|
|
337
|
+
|
|
338
|
+
```yaml
|
|
339
|
+
version: "1.0"
|
|
340
|
+
|
|
341
|
+
project:
|
|
342
|
+
name: "my-project"
|
|
343
|
+
|
|
344
|
+
specs:
|
|
345
|
+
prd:
|
|
346
|
+
path: specs/prd.md
|
|
347
|
+
type: prd
|
|
348
|
+
required: true
|
|
349
|
+
|
|
350
|
+
technical:
|
|
351
|
+
path: specs/technical-design.md
|
|
352
|
+
type: technical-design
|
|
353
|
+
requires: ["prd"]
|
|
354
|
+
|
|
355
|
+
stories:
|
|
356
|
+
path: "specs/stories/*.md"
|
|
357
|
+
type: user-story
|
|
358
|
+
requires: ["prd"]
|
|
359
|
+
|
|
360
|
+
test-plan:
|
|
361
|
+
path: specs/test-plan.md
|
|
362
|
+
type: test-plan
|
|
363
|
+
requires: ["technical"]
|
|
364
|
+
|
|
365
|
+
lint:
|
|
366
|
+
extends: "recommended"
|
|
367
|
+
rules:
|
|
368
|
+
consistency/naming-conventions: off
|
|
369
|
+
|
|
370
|
+
pack:
|
|
371
|
+
max_tokens: 12000
|
|
372
|
+
format: xml
|
|
373
|
+
compression:
|
|
374
|
+
strip_boilerplate: true
|
|
375
|
+
stable_days: 30
|
|
376
|
+
|
|
377
|
+
diff:
|
|
378
|
+
baseline_ref: main
|
|
379
|
+
staleness_threshold_days: 14
|
|
380
|
+
|
|
381
|
+
check:
|
|
382
|
+
framework: auto # auto | express | hono | nextjs
|
|
383
|
+
|
|
384
|
+
ci:
|
|
385
|
+
block_on: ["error"]
|
|
386
|
+
post_comment: true
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## CLI Reference
|
|
392
|
+
|
|
393
|
+
| Command | Description |
|
|
394
|
+
|---------|-------------|
|
|
395
|
+
| `specdx init --name <name>` | Scaffold a new spec suite |
|
|
396
|
+
| `specdx lint` | Lint all specs against configured rules |
|
|
397
|
+
| `specdx validate` | Validate `spec.config.yaml` |
|
|
398
|
+
| `specdx pack --task <task>` | Pack specs into token-optimised context |
|
|
399
|
+
| `specdx status` | Show spec suite health overview |
|
|
400
|
+
| `specdx check` | *(experimental)* Analyse spec-to-implementation drift |
|
|
401
|
+
| `specdx diff` | Show spec changes and downstream impact (`--working`, `--format changelog`) |
|
|
402
|
+
| `specdx graph` | Print the dependency graph |
|
|
403
|
+
| `specdx ready` | Check if specs are ready for implementation |
|
|
404
|
+
| `specdx generate story --from <id>` | Generate user story stubs from a PRD |
|
|
405
|
+
| `specdx generate test-plan` | *(experimental)* Generate test plan stub from stories |
|
|
406
|
+
| `specdx update` | *(experimental)* Suggest spec updates based on code drift |
|
|
407
|
+
| `specdx migrate` | *(experimental)* Check and validate spec schema version |
|
|
408
|
+
| `specdx skills install` | Install Claude Code skills (`--experimental` also installs the unpromoted ones) |
|
|
409
|
+
| `specdx mcp` | Start the MCP server |
|
|
410
|
+
|
|
411
|
+
Global flags: `--format pretty|json|github`, `--quiet`, `--verbose`.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## Why specdx?
|
|
416
|
+
|
|
417
|
+
**vs. Markdown linters** (markdownlint, remark-lint) — They check formatting. specdx checks semantics: required sections by spec type, cross-reference validity, dependency chain cycles, downstream staleness.
|
|
418
|
+
|
|
419
|
+
**vs. YAML validators** (JSON Schema + AJV) — They check structure. specdx combines schema validation with document-level semantic rules that understand spec relationships.
|
|
420
|
+
|
|
421
|
+
**What makes it different:**
|
|
422
|
+
|
|
423
|
+
1. **Dependency chains.** `requires` declarations build a DAG. Rules catch staleness and broken references across the entire suite.
|
|
424
|
+
2. **Context packing.** `specdx pack` assembles token-optimised payloads with relevance filtering, budget allocation, and boilerplate stripping.
|
|
425
|
+
3. **Drift detection.** `specdx diff` walks the dependency graph to find specs affected by upstream changes, and `specdx ready` gates implementation on suite health. (Experimental: `specdx check` compares specs against your actual implementation.)
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Contributing
|
|
430
|
+
|
|
431
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, how to write custom lint rules, and the PR process.
|
|
432
|
+
|
|
433
|
+
## License
|
|
434
|
+
|
|
435
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runCheck
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RI2SFGMR.js";
|
|
4
4
|
import {
|
|
5
5
|
sharedArgs
|
|
6
6
|
} from "./chunk-GAM4MXPC.js";
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
import "./chunk-SJCIM4TC.js";
|
|
14
14
|
import "./chunk-5WRI5ZAA.js";
|
|
15
15
|
|
|
16
|
-
// src/commands/check.ts
|
|
16
|
+
// src/commands/experimental/check.ts
|
|
17
17
|
import { defineCommand } from "citty";
|
|
18
18
|
var check_default = defineCommand({
|
|
19
19
|
meta: {
|
|
20
20
|
name: "check",
|
|
21
|
-
description: "
|
|
21
|
+
description: "Check spec-to-implementation drift. Exit codes: 0 ok, 1 errors found, 3 nothing checkable (coverage not assessed)"
|
|
22
22
|
},
|
|
23
23
|
args: {
|
|
24
24
|
...sharedArgs,
|
|
@@ -26,7 +26,7 @@ var check_default = defineCommand({
|
|
|
26
26
|
framework: { type: "string", description: "Framework override: express, hono, nextjs" },
|
|
27
27
|
ai: {
|
|
28
28
|
type: "boolean",
|
|
29
|
-
description: "
|
|
29
|
+
description: "Use AI to assess findings (requires ANTHROPIC_API_KEY)"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
async run({ args }) {
|
|
@@ -50,7 +50,7 @@ var check_default = defineCommand({
|
|
|
50
50
|
logger.debug(`Checking ${specs.length} specs...`);
|
|
51
51
|
const result = await runCheck(specs, configDir, checkConfig);
|
|
52
52
|
if (args.ai) {
|
|
53
|
-
const { analyzeWithAi } = await import("./dist-
|
|
53
|
+
const { analyzeWithAi } = await import("./dist-WXT4UJ55.js");
|
|
54
54
|
const aiResult = await analyzeWithAi(result.findings, args.spec ?? "full suite check");
|
|
55
55
|
if (args.format === "json") {
|
|
56
56
|
console.log(JSON.stringify({ ...result, ai: aiResult }, null, 2));
|
|
@@ -134,4 +134,4 @@ var check_default = defineCommand({
|
|
|
134
134
|
export {
|
|
135
135
|
check_default as default
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=check-
|
|
137
|
+
//# sourceMappingURL=check-PQQGR4KP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/experimental/check.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, parseSpec, resolveGlob, createLogger } from \"@specdx/core\";\nimport { runCheck } from \"@specdx/check\";\nimport type { ParsedSpec } from \"@specdx/core\";\nimport type { CheckConfig } from \"@specdx/check\";\nimport { sharedArgs } from \"../../shared-args.js\";\n\nexport default defineCommand({\n meta: {\n name: \"check\",\n description:\n \"Check spec-to-implementation drift. Exit codes: 0 ok, 1 errors found, 3 nothing checkable (coverage not assessed)\",\n },\n args: {\n ...sharedArgs,\n spec: { type: \"string\", description: \"Check a specific spec by ID\" },\n framework: { type: \"string\", description: \"Framework override: express, hono, nextjs\" },\n ai: {\n type: \"boolean\",\n description: \"Use AI to assess findings (requires ANTHROPIC_API_KEY)\",\n },\n },\n async run({ args }) {\n const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });\n const configDir = process.cwd();\n const config = await loadConfig(undefined, configDir);\n\n logger.debug(\"Loading specs...\");\n\n // Resolve and parse all specs\n const specs: ParsedSpec[] = [];\n for (const [, entry] of Object.entries(config.specs)) {\n const paths = await resolveGlob(entry.path, configDir);\n for (const p of paths) {\n const spec = await parseSpec(p);\n if (args.spec && spec.frontmatter.id !== args.spec) continue;\n specs.push(spec);\n }\n }\n\n const checkConfig: CheckConfig = {\n ...config.check,\n ...(args.framework ? { framework: args.framework as CheckConfig[\"framework\"] } : {}),\n };\n\n logger.debug(`Checking ${specs.length} specs...`);\n const result = await runCheck(specs, configDir, checkConfig);\n\n // AI analysis (opt-in)\n if (args.ai) {\n const { analyzeWithAi } = await import(\"@specdx/check\");\n const aiResult = await analyzeWithAi(result.findings, args.spec ?? \"full suite check\");\n\n if (args.format === \"json\") {\n console.log(JSON.stringify({ ...result, ai: aiResult }, null, 2));\n } else {\n console.log(`\\n sdx check --ai — ${result.score.overall}% coverage\\n`);\n console.log(` AI Assessment: ${aiResult.summary}\\n`);\n\n for (const assessment of aiResult.assessments) {\n const finding = result.findings[assessment.findingIndex];\n if (!finding) continue;\n const icon = assessment.isRealIssue ? \"✗\" : \"✓\";\n const label = assessment.isRealIssue ? \"REAL\" : \"FALSE POSITIVE\";\n console.log(` ${icon} [${label}] ${finding.expected}`);\n console.log(` ${assessment.reasoning}`);\n if (assessment.suggestedFix) {\n console.log(` Fix: ${assessment.suggestedFix}`);\n }\n }\n console.log();\n }\n\n if (aiResult.assessments.some((a) => a.isRealIssue)) {\n process.exit(1);\n }\n return;\n }\n\n if (args.format === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n } else {\n // Pretty format\n const headline = result.score.assessed\n ? `${result.score.overall}% implementation coverage`\n : \"coverage not assessed — no checkable surfaces found\";\n console.log(`\\n sdx check — ${headline}\\n`);\n\n for (const note of result.notes) {\n console.log(` ⚠ ${note}`);\n }\n if (result.notes.length > 0) console.log();\n\n if (args.verbose) {\n const fmt = (n: number | null) => (n === null ? \"not scanned\" : `${n} found`);\n console.log(` Scanned: framework=${result.scanned.framework ?? \"none detected\"}`);\n console.log(` routes: ${fmt(result.scanned.codeRoutes)}`);\n console.log(` types: ${fmt(result.scanned.codeTypes)}`);\n console.log(` tests: ${fmt(result.scanned.codeTests)}`);\n const artifacts =\n result.scanned.artifacts === null\n ? \"none declared\"\n : `${result.scanned.artifacts} verified`;\n const pending =\n result.scanned.artifactsPending > 0 ? `, ${result.scanned.artifactsPending} pending` : \"\";\n console.log(` artifacts: ${artifacts}${pending}\\n`);\n }\n\n for (const [category, stats] of Object.entries(result.score.byCategory)) {\n if (stats.total === 0) continue;\n console.log(` ${category} (${stats.matched}/${stats.total}):`);\n const categoryFindings = result.findings.filter(\n (f) => f.category === category.replace(/s$/, \"\"),\n );\n for (const f of categoryFindings) {\n const icon = f.severity === \"error\" ? \"✗\" : f.severity === \"warn\" ? \"⚠\" : \"ℹ\";\n const detail = f.actual ? ` — ${f.actual}` : \"\";\n const suggestion = f.suggestion ? ` (${f.suggestion})` : \"\";\n console.log(` ${icon} ${f.expected}${detail}${suggestion}`);\n }\n if (categoryFindings.length === 0) {\n console.log(\" ✓ all matched\");\n }\n }\n\n const errors = result.findings.filter((f) => f.severity === \"error\").length;\n const warnings = result.findings.filter((f) => f.severity === \"warn\").length;\n const info = result.findings.filter((f) => f.severity === \"info\").length;\n console.log(`\\n ${errors} errors, ${warnings} warnings, ${info} info\\n`);\n }\n\n if (result.findings.some((f) => f.severity === \"error\")) {\n process.exit(1);\n }\n // Distinct exit code so CI cannot mistake \"nothing was checkable\" for a pass\n if (!result.score.assessed) {\n process.exit(3);\n }\n },\n});\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REQUIRED_SECTIONS
|
|
3
|
+
} from "./chunk-SJCIM4TC.js";
|
|
4
|
+
|
|
5
|
+
// src/commands/core/init.ts
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var TEMPLATE_SPECS = {
|
|
10
|
+
lightweight: [
|
|
11
|
+
{ filename: "prd.md", type: "prd" },
|
|
12
|
+
{ filename: "technical-design.md", type: "technical-design" }
|
|
13
|
+
],
|
|
14
|
+
bmad: [
|
|
15
|
+
{ filename: "prd.md", type: "prd" },
|
|
16
|
+
{ filename: "technical-design.md", type: "technical-design" },
|
|
17
|
+
{ filename: "test-plan.md", type: "test-plan" }
|
|
18
|
+
],
|
|
19
|
+
"api-first": [
|
|
20
|
+
{ filename: "technical-design.md", type: "technical-design" },
|
|
21
|
+
{ filename: "api-contract.md", type: "api-contract" },
|
|
22
|
+
{ filename: "test-plan.md", type: "test-plan" }
|
|
23
|
+
],
|
|
24
|
+
quick: [{ filename: "quick-spec.md", type: "quick-spec" }],
|
|
25
|
+
context: [{ filename: "project-context.md", type: "project-context" }]
|
|
26
|
+
};
|
|
27
|
+
var TEMPLATE_EXTRA_DIRS = {
|
|
28
|
+
lightweight: [],
|
|
29
|
+
bmad: ["specs/stories", "specs/adr"],
|
|
30
|
+
"api-first": [],
|
|
31
|
+
quick: [],
|
|
32
|
+
context: []
|
|
33
|
+
};
|
|
34
|
+
function specIdFromFilename(filename) {
|
|
35
|
+
return filename.replace(/\.md$/, "");
|
|
36
|
+
}
|
|
37
|
+
function specTitleFromType(type) {
|
|
38
|
+
return type.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
39
|
+
}
|
|
40
|
+
function buildSpecFile(filename, type, projectName, today) {
|
|
41
|
+
const id = specIdFromFilename(filename);
|
|
42
|
+
const title = `${specTitleFromType(type)} \u2014 ${projectName}`;
|
|
43
|
+
const sections = REQUIRED_SECTIONS[type];
|
|
44
|
+
const frontmatter = [
|
|
45
|
+
"---",
|
|
46
|
+
`id: ${id}`,
|
|
47
|
+
`type: ${type}`,
|
|
48
|
+
`title: "${title}"`,
|
|
49
|
+
`status: draft`,
|
|
50
|
+
`version: "0.1"`,
|
|
51
|
+
`created: "${today}"`,
|
|
52
|
+
`authors: ["author"]`,
|
|
53
|
+
"---"
|
|
54
|
+
].join("\n");
|
|
55
|
+
const body = sections.map((section) => `
|
|
56
|
+
## ${section}
|
|
57
|
+
|
|
58
|
+
<!-- placeholder -->`).join("\n");
|
|
59
|
+
return `${frontmatter}
|
|
60
|
+
${body}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
function buildConfigYaml(projectName, specs) {
|
|
64
|
+
const specEntries = specs.map(({ filename, type }) => {
|
|
65
|
+
const key = specIdFromFilename(filename);
|
|
66
|
+
return ` ${key}:
|
|
67
|
+
path: specs/${filename}
|
|
68
|
+
type: ${type}`;
|
|
69
|
+
}).join("\n");
|
|
70
|
+
return [`version: "1.0"`, `project:`, ` name: "${projectName}"`, `specs:`, specEntries].join("\n") + "\n";
|
|
71
|
+
}
|
|
72
|
+
async function scaffoldProject({
|
|
73
|
+
projectName,
|
|
74
|
+
template,
|
|
75
|
+
targetDir
|
|
76
|
+
}) {
|
|
77
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
78
|
+
const specsDir = join(targetDir, "specs");
|
|
79
|
+
await mkdir(specsDir, { recursive: true });
|
|
80
|
+
for (const extraDir of TEMPLATE_EXTRA_DIRS[template]) {
|
|
81
|
+
await mkdir(join(targetDir, extraDir), { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
const specs = TEMPLATE_SPECS[template];
|
|
84
|
+
for (const { filename, type } of specs) {
|
|
85
|
+
const content = buildSpecFile(filename, type, projectName, today);
|
|
86
|
+
await writeFile(join(specsDir, filename), content, "utf-8");
|
|
87
|
+
}
|
|
88
|
+
const configContent = buildConfigYaml(projectName, specs);
|
|
89
|
+
await writeFile(join(targetDir, "spec.config.yaml"), configContent, "utf-8");
|
|
90
|
+
}
|
|
91
|
+
var init_default = defineCommand({
|
|
92
|
+
meta: {
|
|
93
|
+
name: "init",
|
|
94
|
+
description: "Initialize a new specdx project with spec scaffolding"
|
|
95
|
+
},
|
|
96
|
+
args: {
|
|
97
|
+
name: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "Project name",
|
|
100
|
+
required: true
|
|
101
|
+
},
|
|
102
|
+
template: {
|
|
103
|
+
type: "string",
|
|
104
|
+
description: "Template to use (lightweight, bmad, api-first)",
|
|
105
|
+
default: "lightweight"
|
|
106
|
+
},
|
|
107
|
+
dir: {
|
|
108
|
+
type: "string",
|
|
109
|
+
description: "Target directory",
|
|
110
|
+
default: "."
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
async run({ args }) {
|
|
114
|
+
const { name, template, dir } = args;
|
|
115
|
+
const validTemplates = ["lightweight", "bmad", "api-first", "quick", "context"];
|
|
116
|
+
if (!validTemplates.includes(template)) {
|
|
117
|
+
console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(", ")}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
console.log(`Scaffolding "${name}" with template "${template}" in ${dir}...`);
|
|
121
|
+
await scaffoldProject({ projectName: name, template, targetDir: dir });
|
|
122
|
+
console.log(`Done! Project "${name}" scaffolded successfully.`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/commands/registry.ts
|
|
127
|
+
var CORE_COMMANDS = [
|
|
128
|
+
"init",
|
|
129
|
+
"lint",
|
|
130
|
+
"validate",
|
|
131
|
+
"graph",
|
|
132
|
+
"skills",
|
|
133
|
+
"pack",
|
|
134
|
+
"diff",
|
|
135
|
+
"status",
|
|
136
|
+
"ready",
|
|
137
|
+
"generate",
|
|
138
|
+
"generate story",
|
|
139
|
+
"mcp"
|
|
140
|
+
];
|
|
141
|
+
var EXPERIMENTAL_COMMANDS = ["check", "update", "migrate", "generate test-plan"];
|
|
142
|
+
var COMMAND_NAMES = [...CORE_COMMANDS, ...EXPERIMENTAL_COMMANDS];
|
|
143
|
+
function bucketOf(name) {
|
|
144
|
+
return EXPERIMENTAL_COMMANDS.includes(name) ? "experimental" : "core";
|
|
145
|
+
}
|
|
146
|
+
function labelled(name, cmd) {
|
|
147
|
+
if (bucketOf(name) === "core") return cmd;
|
|
148
|
+
const meta = cmd.meta;
|
|
149
|
+
if (typeof meta !== "object" || meta === null || "then" in meta) return cmd;
|
|
150
|
+
return {
|
|
151
|
+
...cmd,
|
|
152
|
+
meta: { ...meta, description: `[experimental] ${meta.description ?? ""}`.trim() }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function bucketed(name, load) {
|
|
156
|
+
return () => load().then((cmd) => labelled(name, cmd));
|
|
157
|
+
}
|
|
158
|
+
var subCommands = {
|
|
159
|
+
init: init_default,
|
|
160
|
+
lint: bucketed("lint", () => import("./lint-ADR7L6AP.js").then((m) => m.default)),
|
|
161
|
+
validate: bucketed("validate", () => import("./validate-WIB246IE.js").then((m) => m.default)),
|
|
162
|
+
graph: bucketed("graph", () => import("./graph-OKUMHR3Q.js").then((m) => m.default)),
|
|
163
|
+
skills: bucketed("skills", () => import("./skills-LHFTTEJ7.js").then((m) => m.default)),
|
|
164
|
+
pack: bucketed("pack", () => import("./pack-B3KYRKUR.js").then((m) => m.default)),
|
|
165
|
+
diff: bucketed("diff", () => import("./diff-IOBAJMKU.js").then((m) => m.default)),
|
|
166
|
+
status: bucketed("status", () => import("./status-PQKPTDP5.js").then((m) => m.default)),
|
|
167
|
+
check: bucketed("check", () => import("./check-PQQGR4KP.js").then((m) => m.default)),
|
|
168
|
+
ready: bucketed("ready", () => import("./ready-GH4YKVOX.js").then((m) => m.default)),
|
|
169
|
+
update: bucketed("update", () => import("./update-VAC6XV5E.js").then((m) => m.default)),
|
|
170
|
+
generate: bucketed("generate", () => import("./generate-NSTYQOAV.js").then((m) => m.default)),
|
|
171
|
+
migrate: bucketed("migrate", () => import("./migrate-LAMRDT3V.js").then((m) => m.default)),
|
|
172
|
+
mcp: bucketed("mcp", () => import("./mcp-A6CCWSS2.js").then((m) => m.default))
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
labelled,
|
|
177
|
+
subCommands
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=chunk-33FELECG.js.map
|