speckeeper 0.1.0

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 ADDED
@@ -0,0 +1,273 @@
1
+ # speckeeper
2
+
3
+ [![npm version](https://badge.fury.io/js/speckeeper.svg)](https://www.npmjs.com/package/speckeeper)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen)](https://nodejs.org)
6
+
7
+ **TypeScript-first specification validation framework** — validate design consistency and external SSOT integrity with full traceability.
8
+
9
+ ## Why speckeeper?
10
+
11
+ Requirements and design documents often drift from implementation. **speckeeper** treats specifications as **code** — type-safe, version-controlled, and continuously validated against your actual artifacts (tests, OpenAPI, DDL, IaC).
12
+
13
+ ```
14
+ design/*.ts ──────► Validation & Consistency Checks
15
+ │
16
+ ├─► speckeeper lint → Design integrity (IDs, references, phase gates)
17
+ ├─► speckeeper check → External SSOT validation (test coverage, etc.)
18
+ └─► speckeeper impact → Change impact analysis with traceability
19
+ ```
20
+
21
+ ## Features
22
+
23
+ - **TypeScript as SSOT** — Define requirements, architecture, and design in type-safe TypeScript
24
+ - **Design validation** — Lint rules for ID uniqueness, reference integrity, circular dependencies, and phase gates
25
+ - **External SSOT validation** — Check consistency with test files, and custom checkers for OpenAPI, DDL, etc.
26
+ - **Traceability** — Track relationships across model levels (L0-L3) with impact analysis
27
+ - **Custom models** — Extend with domain-specific models (Runbooks, Policies, etc.)
28
+ - **CI-ready** — Built-in lint, drift detection, and coverage checks
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ npm install speckeeper
34
+
35
+ # Verify installation
36
+ npx speckeeper --help
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ### 1. Initialize project
42
+
43
+ ```bash
44
+ npx speckeeper init
45
+ ```
46
+
47
+ This creates:
48
+ - `speckeeper.config.ts` — Configuration file
49
+ - `design/_models/` — Model definitions (Requirement, UseCase, Term, Entity, Component)
50
+ - `design/requirements.ts` — Sample specification file
51
+
52
+ The generated `speckeeper.config.ts`:
53
+
54
+ ```typescript
55
+ import { defineConfig } from 'speckeeper';
56
+ import { allModels } from './design/_models/index';
57
+
58
+ export default defineConfig({
59
+ projectName: 'my-project',
60
+ models: allModels,
61
+ });
62
+ ```
63
+
64
+ See [Model Definition Guide](./docs/model-guide.md) for customization details.
65
+
66
+ ### 2. Define your specifications
67
+
68
+ Edit files in `design/` to add your specifications:
69
+
70
+ ```typescript
71
+ // design/requirements.ts
72
+ import type { Requirement } from 'speckeeper';
73
+
74
+ export const requirements: Requirement[] = [
75
+ {
76
+ id: 'FR-001',
77
+ name: 'User Authentication',
78
+ type: 'functional',
79
+ description: 'Users can authenticate using email and password',
80
+ priority: 'must',
81
+ acceptanceCriteria: [
82
+ { id: 'FR-001-01', description: 'Valid credentials grant access', verificationMethod: 'test' },
83
+ { id: 'FR-001-02', description: 'Invalid credentials show error', verificationMethod: 'test' },
84
+ ],
85
+ },
86
+ ];
87
+ ```
88
+
89
+ ### 3. Run validation
90
+
91
+ ```bash
92
+ # Validate design integrity
93
+ npx speckeeper lint
94
+
95
+ # Check test coverage against requirements
96
+ npx speckeeper check test --coverage
97
+
98
+ # Analyze change impact
99
+ npx speckeeper impact FR-001
100
+ ```
101
+
102
+ ## CLI Commands
103
+
104
+ | Command | Description |
105
+ |---------|-------------|
106
+ | `speckeeper init` | Initialize a new project with starter templates |
107
+ | `speckeeper lint` | Validate design integrity (ID uniqueness, references, phase gates) |
108
+ | `speckeeper check` | Verify consistency with external SSOT |
109
+ | `speckeeper check test --coverage` | Verify test coverage for requirements |
110
+ | `speckeeper drift` | Detect manual edits to generated `specs/` files |
111
+ | `speckeeper impact <id>` | Analyze change impact for a specific element |
112
+
113
+ **Note**: `speckeeper build` generates machine-readable `specs/` output. For human-readable docs (`docs/`), use [embedoc](https://www.npmjs.com/package/embedoc) or similar tools with the model rendering API.
114
+
115
+ ## Validation Features
116
+
117
+ ### Design Integrity (lint)
118
+
119
+ ```bash
120
+ $ npx speckeeper lint
121
+
122
+ speckeeper lint
123
+
124
+ Design: design/
125
+ Loaded: 17 files
126
+
127
+ Running lint checks...
128
+
129
+ ✓ No issues found
130
+ ```
131
+
132
+ Checks include:
133
+ - **ID uniqueness** — No duplicate IDs within model types
134
+ - **ID conventions** — Enforce naming patterns (e.g., `FR-001`, `COMP-AUTH`)
135
+ - **Reference integrity** — All referenced IDs must exist
136
+ - **Circular dependency detection** — Prevent reference loops
137
+ - **Phase gates** — Ensure TBD items are resolved by target phase
138
+ - **Custom lint rules** — Define model-specific validation
139
+
140
+ ### External SSOT Validation (check)
141
+
142
+ Validate your specifications against actual implementation artifacts.
143
+
144
+ **Built-in: Test Coverage Check**
145
+
146
+ Define test references that link to your requirements:
147
+
148
+ ```typescript
149
+ // design/test-refs.ts
150
+ import type { TestRef } from 'speckeeper';
151
+
152
+ export const testRefs: TestRef[] = [
153
+ {
154
+ id: 'TEST-001',
155
+ description: 'Authentication tests',
156
+ source: { path: 'test/auth.test.ts', framework: 'vitest' },
157
+ verifiesRequirements: ['FR-001'],
158
+ testCasePatterns: [
159
+ { acceptanceCriteriaId: 'FR-001-01', pattern: 'valid credentials' },
160
+ { acceptanceCriteriaId: 'FR-001-02', pattern: 'invalid credentials' },
161
+ ],
162
+ },
163
+ ];
164
+ ```
165
+
166
+ ```bash
167
+ $ npx speckeeper check test --coverage
168
+
169
+ speckeeper check
170
+
171
+ Design: design/
172
+ Type: test
173
+
174
+ ✓ All checks passed
175
+
176
+ Coverage: TestRef → Requirement
177
+ Coverage: 100% (34/34 acceptance criteria covered)
178
+ ```
179
+
180
+ **Custom Checkers**
181
+
182
+ Implement `externalChecker` in model definitions to validate against any external source (OpenAPI, DDL, IaC, etc.). See [Model Definition Guide](./docs/model-guide.md) for details.
183
+
184
+ ## Model Levels & Traceability
185
+
186
+ speckeeper organizes models by abstraction level:
187
+
188
+ | Level | Focus | Examples |
189
+ |-------|-------|----------|
190
+ | **L0** | Business + Domain (Why) | UseCase, Actor, Term |
191
+ | **L1** | Requirements (What) | Requirement, Constraint |
192
+ | **L2** | Design (How) | Component, Entity, Layer |
193
+ | **L3** | Implementation (Build) | Screen, APIRef, TableRef |
194
+
195
+ Relations between models enable **impact analysis**:
196
+
197
+ ```bash
198
+ $ npx speckeeper impact FR-001
199
+
200
+ FR-001 (Requirement)
201
+ ├── implements: COMP-AUTH (Component)
202
+ ├── satisfies: UC-001 (UseCase)
203
+ └── verifies: TEST-001 (TestRef)
204
+ ```
205
+
206
+ See [Model Entity Catalog](./docs/model_entity_catalog.md) for relation types and level constraints.
207
+
208
+ ## Customizing Models
209
+
210
+ The starter templates provide basic models. You can customize them or add new domain-specific models:
211
+
212
+ ```typescript
213
+ import { z } from 'zod';
214
+ import { Model } from 'speckeeper';
215
+
216
+ const RunbookSchema = z.object({
217
+ id: z.string(),
218
+ title: z.string(),
219
+ severity: z.enum(['critical', 'high', 'medium', 'low']),
220
+ steps: z.array(z.object({
221
+ action: z.string(),
222
+ verification: z.string().optional(),
223
+ })),
224
+ });
225
+
226
+ class RunbookModel extends Model<typeof RunbookSchema> {
227
+ id = 'runbook';
228
+ name = 'Runbook';
229
+ idPrefix = 'RB';
230
+ schema = RunbookSchema;
231
+
232
+ lintRules = [
233
+ {
234
+ id: 'runbook-has-steps',
235
+ severity: 'error',
236
+ message: 'Runbook must have at least one step',
237
+ check: (spec) => spec.steps.length === 0,
238
+ },
239
+ ];
240
+ }
241
+ ```
242
+
243
+ ## Documentation
244
+
245
+ - **[Model Definition Guide](./docs/model-guide.md)** — Start here for model customization and API reference
246
+ - [Framework Requirements Specification](./docs/framework_requirements_spec.md) — Detailed feature specifications
247
+ - [Model Entity Catalog](./docs/model_entity_catalog.md) — Model hierarchy and relation types
248
+
249
+ ## Compatibility
250
+
251
+ - Node.js >= 20.0.0
252
+ - TypeScript >= 5.0
253
+
254
+ ## Contributing
255
+
256
+ ```bash
257
+ # Install dependencies
258
+ npm install
259
+
260
+ # Run tests
261
+ npm test
262
+
263
+ # Lint
264
+ npm run lint
265
+ npm run lint:design
266
+
267
+ # Full CI check
268
+ npm run ci
269
+ ```
270
+
271
+ ## License
272
+
273
+ MIT
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Use tsx to enable dynamic import of TypeScript files
4
+ import { register } from 'tsx/esm/api';
5
+
6
+ // Register tsx ESM loader
7
+ register();
8
+
9
+ // Run CLI
10
+ import('../dist/cli.js');
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node