@spectrl/cli 0.6.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/LICENSE +21 -0
- package/README.md +443 -0
- package/dist/cli.js +7792 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pasha Naumov
|
|
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,443 @@
|
|
|
1
|
+
# Spectrl
|
|
2
|
+
|
|
3
|
+
Spectrl is a local-first spec registry that treats structured documents (PRDs, TDDs, ADRs) as versioned, installable packages. Think npm for your documentation.
|
|
4
|
+
|
|
5
|
+
**Key benefits:**
|
|
6
|
+
|
|
7
|
+
- **Local-first**: Works offline, all data in your repo
|
|
8
|
+
- **Reproducible**: Content hashing ensures deterministic state
|
|
9
|
+
- **Composable**: Specs can depend on other specs
|
|
10
|
+
- **Agent-readable**: Schema-defined for LLM workflows
|
|
11
|
+
- **Backend-optional**: No server required
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @spectrl/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or use directly with npx (no installation required):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @spectrl/cli init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Requirements:**
|
|
26
|
+
|
|
27
|
+
- Node.js 20+ or Bun
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Create a spec (in a separate location)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd ~/specs # Or any location outside your project
|
|
35
|
+
spectrl new my-feature
|
|
36
|
+
# Created my-feature/spectrl.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Add your documentation files and update the `files` array in `spectrl.json`.
|
|
40
|
+
|
|
41
|
+
### 2. Publish to local registry
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd my-feature
|
|
45
|
+
spectrl publish
|
|
46
|
+
# Published my-feature@0.1.0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Initialize your project
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cd /path/to/your/project
|
|
53
|
+
spectrl init
|
|
54
|
+
# Created .spectrl/spectrl-index.json
|
|
55
|
+
# Would you like to create AGENTS.md? (y/n)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 4. Install the spec
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
spectrl install my-feature
|
|
62
|
+
# Resolving my-feature... found version 0.1.0
|
|
63
|
+
# Installed my-feature@0.1.0
|
|
64
|
+
# Updated .spectrl/spectrl-index.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Core Concepts
|
|
68
|
+
|
|
69
|
+
Spectrl applies package manager principles to structured documentation:
|
|
70
|
+
|
|
71
|
+
- **Manifest** (`spectrl.json`): Defines a spec with name, version, files, and dependencies
|
|
72
|
+
- **Registry** (`~/.spectrl/registry/`): Local storage for published specs with content hashing
|
|
73
|
+
- **Project Index** (`.spectrl/spectrl-index.json`): Lists installed specs with sources and hashes
|
|
74
|
+
- **Lock File** (`.spectrl/lock.json`): Captures resolved dependency tree
|
|
75
|
+
|
|
76
|
+
**Version Control:** Commit `.spectrl/spectrl-index.json` and `.spectrl/lock.json` (like `package.json` and `package-lock.json`). Add `.spectrl/specs/` to `.gitignore` (like `node_modules/`).
|
|
77
|
+
|
|
78
|
+
## Commands
|
|
79
|
+
|
|
80
|
+
### `spectrl init`
|
|
81
|
+
|
|
82
|
+
Initialize a new project index.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
spectrl init
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Creates `.spectrl/spectrl-index.json` in the current directory.
|
|
89
|
+
|
|
90
|
+
**Options:**
|
|
91
|
+
|
|
92
|
+
- `--skip-agents` - Skip AGENTS.md creation
|
|
93
|
+
- `--force-agents` - Create/append AGENTS.md without prompting
|
|
94
|
+
|
|
95
|
+
**Example:**
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
spectrl init
|
|
99
|
+
# Created .spectrl/spectrl-index.json
|
|
100
|
+
# Would you like to create AGENTS.md? (y/n)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `spectrl new`
|
|
104
|
+
|
|
105
|
+
Create a new spec with a manifest template.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
spectrl new <name> [options]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Arguments:**
|
|
112
|
+
|
|
113
|
+
- `<name>` - Spec name (lowercase alphanumeric with hyphens)
|
|
114
|
+
|
|
115
|
+
**Options:**
|
|
116
|
+
|
|
117
|
+
- `--version <version>` - Initial version (default: `0.1.0`)
|
|
118
|
+
- `--description <desc>` - Spec description
|
|
119
|
+
|
|
120
|
+
**Example:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
spectrl new user-auth --version 1.0.0 --description "User authentication system"
|
|
124
|
+
# Created user-auth/spectrl.json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### `spectrl publish`
|
|
128
|
+
|
|
129
|
+
Publish the current spec to the local registry.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
spectrl publish
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Run from a directory containing `spectrl.json`. Publishes to `~/.spectrl/registry/{name}/{version}/` with content hash.
|
|
136
|
+
|
|
137
|
+
**Example:**
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
spectrl publish
|
|
141
|
+
# Published my-feature@1.0.0
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### `spectrl install`
|
|
145
|
+
|
|
146
|
+
Install specs from the local registry.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Restore all specs from project index
|
|
150
|
+
spectrl install
|
|
151
|
+
|
|
152
|
+
# Install specific spec (latest version)
|
|
153
|
+
spectrl install <name>
|
|
154
|
+
|
|
155
|
+
# Install specific version
|
|
156
|
+
spectrl install <name>@<version>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Options:**
|
|
160
|
+
|
|
161
|
+
- `--registry <path>` - Custom registry path (default: `~/.spectrl/registry`)
|
|
162
|
+
|
|
163
|
+
**Example:**
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
spectrl install user-auth
|
|
167
|
+
# Resolving user-auth... found version 2.1.0
|
|
168
|
+
# Installed user-auth@2.1.0
|
|
169
|
+
# Updated .spectrl/spectrl-index.json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Workflows
|
|
173
|
+
|
|
174
|
+
### Team Collaboration
|
|
175
|
+
|
|
176
|
+
Share specs across team members using the project index and lock file.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Developer A: Publish and install specs in project
|
|
180
|
+
cd my-feature
|
|
181
|
+
spectrl publish
|
|
182
|
+
|
|
183
|
+
cd /path/to/project
|
|
184
|
+
spectrl install my-feature@1.0.0
|
|
185
|
+
# Installed my-feature@1.0.0
|
|
186
|
+
# Updated .spectrl/spectrl-index.json
|
|
187
|
+
|
|
188
|
+
spectrl install base-spec
|
|
189
|
+
# Resolving base-spec... found version 2.0.0
|
|
190
|
+
# Installed base-spec@2.0.0
|
|
191
|
+
|
|
192
|
+
# Commit index and lock file (like package.json and package-lock.json)
|
|
193
|
+
git add .spectrl/spectrl-index.json .spectrl/lock.json
|
|
194
|
+
git commit -m "Add specs"
|
|
195
|
+
git push
|
|
196
|
+
|
|
197
|
+
# Developer B: Clone and restore all specs from index
|
|
198
|
+
git clone <repo>
|
|
199
|
+
cd <repo>
|
|
200
|
+
spectrl install
|
|
201
|
+
# Installed my-feature@1.0.0
|
|
202
|
+
# Installed base-spec@2.0.0
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Multi-File Spec
|
|
206
|
+
|
|
207
|
+
Bundle related documents together in a single spec.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Create spec directory structure
|
|
211
|
+
mkdir -p my-feature/docs
|
|
212
|
+
|
|
213
|
+
# Add documentation files
|
|
214
|
+
cat > my-feature/docs/prd.md << 'EOF'
|
|
215
|
+
# Product Requirements
|
|
216
|
+
...
|
|
217
|
+
EOF
|
|
218
|
+
|
|
219
|
+
cat > my-feature/docs/tdd.md << 'EOF'
|
|
220
|
+
# Technical Design
|
|
221
|
+
...
|
|
222
|
+
EOF
|
|
223
|
+
|
|
224
|
+
# Create manifest with multiple files and dependencies
|
|
225
|
+
cat > my-feature/spectrl.json << 'EOF'
|
|
226
|
+
{
|
|
227
|
+
"name": "user-auth",
|
|
228
|
+
"version": "1.0.0",
|
|
229
|
+
"description": "User authentication feature spec",
|
|
230
|
+
"files": ["docs/prd.md", "docs/tdd.md"],
|
|
231
|
+
"dependencies": {"security-standards": "2.0.0"}
|
|
232
|
+
}
|
|
233
|
+
EOF
|
|
234
|
+
|
|
235
|
+
# Publish to registry
|
|
236
|
+
cd my-feature
|
|
237
|
+
spectrl publish
|
|
238
|
+
# Published user-auth@1.0.0
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## File Formats
|
|
242
|
+
|
|
243
|
+
### Manifest (`spectrl.json`)
|
|
244
|
+
|
|
245
|
+
Defines a spec. **Required:** `name`, `version`, `files`.
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"name": "spec-name",
|
|
250
|
+
"version": "1.0.0",
|
|
251
|
+
"description": "What this spec contains",
|
|
252
|
+
"files": ["doc1.md", "doc2.md"],
|
|
253
|
+
"dependencies": {
|
|
254
|
+
"other-spec": "1.0.0"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Fields:**
|
|
260
|
+
|
|
261
|
+
- `name` (required): Lowercase alphanumeric with hyphens
|
|
262
|
+
- `version` (required): Semantic version (e.g., `1.0.0`)
|
|
263
|
+
- `files` (required): Array of relative file paths (no `..`)
|
|
264
|
+
- `description` (optional): Human-readable description
|
|
265
|
+
- `dependencies` (optional): Spec name to version map
|
|
266
|
+
|
|
267
|
+
### Project Index (`.spectrl/spectrl-index.json`)
|
|
268
|
+
|
|
269
|
+
Lists installed specs with registry locations and hashes. All transitive dependencies must be listed.
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"spec-name@1.0.0": {
|
|
274
|
+
"source": "~/.spectrl/registry/spec-name/1.0.0",
|
|
275
|
+
"hash": "sha256:abc123..."
|
|
276
|
+
},
|
|
277
|
+
"other-spec@1.0.0": {
|
|
278
|
+
"source": "~/.spectrl/registry/other-spec/1.0.0",
|
|
279
|
+
"hash": "sha256:def456..."
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Fields:**
|
|
285
|
+
|
|
286
|
+
- Key: `name@version` format
|
|
287
|
+
- `source`: Registry path
|
|
288
|
+
- `hash`: SHA-256 content hash
|
|
289
|
+
|
|
290
|
+
### Lock File (`.spectrl/lock.json`)
|
|
291
|
+
|
|
292
|
+
Auto-generated by `spectrl install`. Captures resolved dependency tree. **Do not edit manually.**
|
|
293
|
+
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"createdAt": "2025-11-10T13:40:00Z",
|
|
297
|
+
"entries": [
|
|
298
|
+
{
|
|
299
|
+
"name": "other-spec",
|
|
300
|
+
"version": "1.0.0",
|
|
301
|
+
"hash": "sha256:def456...",
|
|
302
|
+
"source": "~/.spectrl/registry/other-spec/1.0.0",
|
|
303
|
+
"deps": []
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"name": "spec-name",
|
|
307
|
+
"version": "1.0.0",
|
|
308
|
+
"hash": "sha256:abc123...",
|
|
309
|
+
"source": "~/.spectrl/registry/spec-name/1.0.0",
|
|
310
|
+
"deps": ["other-spec@1.0.0"]
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Fields:**
|
|
317
|
+
|
|
318
|
+
- `createdAt`: Generation timestamp
|
|
319
|
+
- `entries`: Array of resolved specs
|
|
320
|
+
- `name`, `version`, `hash`, `source`: Spec metadata
|
|
321
|
+
- `deps`: Direct dependencies (`name@version` format)
|
|
322
|
+
|
|
323
|
+
## Troubleshooting
|
|
324
|
+
|
|
325
|
+
### Registry Errors
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
Error: Spec my-spec@1.0.0 not found in registry
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Publish the spec first:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
cd path/to/my-spec && spectrl publish
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
Error: Spec missing-spec not found in registry
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
The spec doesn't exist in your registry:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
cd path/to/missing-spec && spectrl publish
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Validation Errors
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
Error: Invalid spec reference format. Use: name or name@version
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Use correct format:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
spectrl install my-spec
|
|
357
|
+
# or
|
|
358
|
+
spectrl install my-spec@1.0.0
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Error: Validation failed: file path contains '..'
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Use relative paths only (no parent directory references):
|
|
366
|
+
|
|
367
|
+
```json
|
|
368
|
+
{
|
|
369
|
+
"files": ["docs/design/architecture.md"]
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
Error: Validation failed: files array cannot be empty
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Add at least one file in `spectrl.json`:
|
|
378
|
+
|
|
379
|
+
```json
|
|
380
|
+
{
|
|
381
|
+
"files": ["README.md"]
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
Error: File not found: docs/missing.md
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Verify the file exists:
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
ls -la docs/missing.md
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Dependency Errors
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
Error: Missing dependency middleware@0.5.0. Add it to .spectrl/spectrl-index.json
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Install the missing dependency:
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
spectrl install middleware@0.5.0
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
Error: Manifest mismatch for app@1.0.0: found name=app, version=0.9.0
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Update the index key or manifest to match. Check `spectrl.json` version field.
|
|
412
|
+
|
|
413
|
+
```
|
|
414
|
+
Error: Cyclic dependency detected: dep-x@1.0.0 → dep-y@1.0.0 → dep-x@1.0.0
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Remove the circular dependency from your spec manifests.
|
|
418
|
+
|
|
419
|
+
### Integrity Errors
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
Error: Integrity breach: hash mismatch for app@1.0.0
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Spec content changed after publishing. Republish or verify source:
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
cd path/to/app && spectrl publish
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
```
|
|
432
|
+
Hash changes unexpectedly
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Check for file modifications, line endings (LF vs CRLF), or trailing whitespace:
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
diff my-spec/docs/prd.md ~/.spectrl/registry/my-spec/1.0.0/files/docs/prd.md
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## License
|
|
442
|
+
|
|
443
|
+
MIT
|