@spectrl/cli 0.6.1 → 0.6.3

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 (4) hide show
  1. package/README.md +446 -281
  2. package/dist/cli.js +216 -194
  3. package/package.json +25 -15
  4. package/LICENSE +0 -21
package/README.md CHANGED
@@ -1,14 +1,17 @@
1
- # Spectrl
1
+ # Spectrl CLI
2
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.
3
+ > Local-first spec registry with public registry support
4
4
 
5
- **Key benefits:**
5
+ Spectrl is a command-line tool for managing structured documents (PRDs, TDDs, ADRs, etc.) as versioned, installable specs. It supports both local-first development and public registry sharing.
6
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
7
+ ## Features
8
+
9
+ - 📦 **Local-first**: All data lives in your repo, works offline
10
+ - 🔄 **Reproducible**: Deterministic registry state
11
+ - 🧩 **Composable**: Specs can depend on other specs
12
+ - 🤖 **Agent-readable**: Schema-defined structure for LLMs
13
+ - 🌐 **Public registry**: Share and discover specs globally
14
+ - 🔐 **Secure authentication**: GitHub OAuth with device flow
12
15
 
13
16
  ## Installation
14
17
 
@@ -16,428 +19,590 @@ Spectrl is a local-first spec registry that treats structured documents (PRDs, T
16
19
  npm install -g @spectrl/cli
17
20
  ```
18
21
 
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
22
  ## Quick Start
30
23
 
31
- ### 1. Create a spec (in a separate location)
24
+ ### Local Development
32
25
 
33
26
  ```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`.
27
+ # Initialize a new project
28
+ spectrl init
40
29
 
41
- ### 2. Publish to local registry
30
+ # Create a new spec
31
+ spectrl new my-api-spec --description "REST API specification"
42
32
 
43
- ```bash
44
- cd my-feature
33
+ # Publish to local registry
45
34
  spectrl publish
46
- # Published my-feature@0.1.0
47
- ```
48
35
 
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)
36
+ # Install from local registry
37
+ spectrl install my-api-spec
56
38
  ```
57
39
 
58
- ### 4. Install the spec
40
+ ### Public Registry
59
41
 
60
42
  ```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
- ```
43
+ # Authenticate with GitHub
44
+ spectrl login
66
45
 
67
- ## Core Concepts
46
+ # Publish to public registry
47
+ spectrl publish
48
+ # Choose "Public registry" when prompted
68
49
 
69
- Spectrl applies package manager principles to structured documentation:
50
+ # Search for specs
51
+ spectrl search api
70
52
 
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
53
+ # Get spec information
54
+ spectrl info alice/api-spec
75
55
 
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/`).
56
+ # Install from public registry
57
+ spectrl install alice/api-spec
77
58
 
78
- ## Commands
59
+ # List all installed specs
60
+ spectrl list
61
+ ```
79
62
 
80
- ### `spectrl init`
63
+ ## Commands
81
64
 
82
- Initialize a new project index.
65
+ ### Project Management
83
66
 
84
- ```bash
85
- spectrl init
86
- ```
67
+ #### `spectrl init`
87
68
 
88
- Creates `.spectrl/spectrl-index.json` in the current directory.
69
+ Initialize a new project with a local spec index.
89
70
 
90
- **Options:**
71
+ ```bash
72
+ spectrl init [options]
91
73
 
92
- - `--skip-agents` - Skip AGENTS.md creation
93
- - `--force-agents` - Create/append AGENTS.md without prompting
74
+ Options:
75
+ --skip-agents Skip AGENTS.md creation/update entirely
76
+ --force-agents Force overwrite AGENTS.md with fresh template
77
+ ```
94
78
 
95
79
  **Example:**
96
80
 
97
81
  ```bash
98
82
  spectrl init
99
- # Created .spectrl/spectrl-index.json
100
- # Would you like to create AGENTS.md? (y/n)
83
+ # Creates .spectrl/index.json and AGENTS.md
101
84
  ```
102
85
 
103
- ### `spectrl new`
86
+ #### `spectrl new <name>`
104
87
 
105
88
  Create a new spec with a manifest template.
106
89
 
107
90
  ```bash
108
91
  spectrl new <name> [options]
109
- ```
110
92
 
111
- **Arguments:**
93
+ Arguments:
94
+ name Name of the spec (lowercase alphanumeric with hyphens)
112
95
 
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
96
+ Options:
97
+ --version Initial version (default: 0.1.0)
98
+ --description Description of the spec
99
+ ```
119
100
 
120
101
  **Example:**
121
102
 
122
103
  ```bash
123
- spectrl new user-auth --version 1.0.0 --description "User authentication system"
124
- # Created user-auth/spectrl.json
104
+ spectrl new api-spec --version 1.0.0 --description "REST API specification"
105
+ # Creates spectrl.json and basic file structure
125
106
  ```
126
107
 
127
- ### `spectrl publish`
108
+ ### Local Registry
128
109
 
129
- Publish the current spec to the local registry.
110
+ #### `spectrl publish`
111
+
112
+ Publish a spec to local or public registry.
130
113
 
131
114
  ```bash
132
115
  spectrl publish
133
116
  ```
134
117
 
135
- Run from a directory containing `spectrl.json`. Publishes to `~/.spectrl/registry/{name}/{version}/` with content hash.
118
+ **Interactive prompts:**
119
+
120
+ - Choose destination: Local registry or Public registry
121
+ - For public: Requires authentication (`spectrl login`)
136
122
 
137
123
  **Example:**
138
124
 
139
125
  ```bash
140
126
  spectrl publish
141
- # Published my-feature@1.0.0
127
+ ? Where do you want to publish?
128
+ ❯ Local registry (~/.spectrl/registry/)
129
+ Public registry (registry.spectrl.dev)
142
130
  ```
143
131
 
144
- ### `spectrl install`
132
+ #### `spectrl install [spec]`
145
133
 
146
- Install specs from the local registry.
134
+ Install specs from local or public registry.
147
135
 
148
136
  ```bash
149
- # Restore all specs from project index
137
+ spectrl install [spec]
138
+
139
+ Arguments:
140
+ spec Optional spec reference to install
141
+ - Local: my-spec or my-spec@1.0.0
142
+ - Public: username/spec or username/spec@1.0.0
143
+ ```
144
+
145
+ **Examples:**
146
+
147
+ ```bash
148
+ # Install all specs from project index
150
149
  spectrl install
151
150
 
152
- # Install specific spec (latest version)
153
- spectrl install <name>
151
+ # Install from local registry
152
+ spectrl install my-spec@1.0.0
154
153
 
155
- # Install specific version
156
- spectrl install <name>@<version>
154
+ # Install from public registry
155
+ spectrl install alice/api-spec
156
+ spectrl install alice/api-spec@2.1.0
157
157
  ```
158
158
 
159
- **Options:**
159
+ ### Authentication
160
160
 
161
- - `--registry <path>` - Custom registry path (default: `~/.spectrl/registry`)
161
+ #### `spectrl login`
162
162
 
163
- **Example:**
163
+ Authenticate with GitHub to access the public registry.
164
164
 
165
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
166
+ spectrl login
170
167
  ```
171
168
 
172
- ## Workflows
169
+ **Flow:**
173
170
 
174
- ### Team Collaboration
171
+ 1. Opens browser to GitHub device authorization
172
+ 2. Enter the displayed code
173
+ 3. Authorize Spectrl application
174
+ 4. Token stored securely in OS keychain
175
175
 
176
- Share specs across team members using the project index and lock file.
176
+ **Example:**
177
177
 
178
178
  ```bash
179
- # Developer A: Publish and install specs in project
180
- cd my-feature
181
- spectrl publish
179
+ spectrl login
180
+ Initiating GitHub authentication...
182
181
 
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
182
+ Please visit: https://github.com/login/device
183
+ Enter code: ABCD-1234
187
184
 
188
- spectrl install base-spec
189
- # Resolving base-spec... found version 2.0.0
190
- # Installed base-spec@2.0.0
185
+ Opening browser...
186
+ Waiting for authorization...
187
+ Logged in as alice
188
+ ```
191
189
 
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
190
+ #### `spectrl logout`
196
191
 
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
192
+ Remove stored GitHub authentication token.
193
+
194
+ ```bash
195
+ spectrl logout
203
196
  ```
204
197
 
205
- ### Multi-File Spec
198
+ #### `spectrl whoami`
206
199
 
207
- Bundle related documents together in a single spec.
200
+ Show current authenticated GitHub user.
208
201
 
209
202
  ```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
203
+ spectrl whoami
239
204
  ```
240
205
 
241
- ## File Formats
206
+ **Examples:**
242
207
 
243
- ### Manifest (`spectrl.json`)
244
-
245
- Defines a spec. **Required:** `name`, `version`, `files`.
208
+ ```bash
209
+ spectrl whoami
210
+ Logged in as alice
246
211
 
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
- }
212
+ # When not logged in
213
+ spectrl whoami
214
+ Not logged in
215
+ Run: spectrl login
257
216
  ```
258
217
 
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
- ```
218
+ ### Discovery
219
+
220
+ #### `spectrl search <query>`
221
+
222
+ Search for specs in the public registry.
223
+
224
+ ```bash
225
+ spectrl search <query>
283
226
 
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
- }
227
+ Arguments:
228
+ query Search query (keywords, tags, or spec names)
314
229
  ```
315
230
 
316
- **Fields:**
231
+ **Example:**
317
232
 
318
- - `createdAt`: Generation timestamp
319
- - `entries`: Array of resolved specs
320
- - `name`, `version`, `hash`, `source`: Spec metadata
321
- - `deps`: Direct dependencies (`name@version` format)
233
+ ```bash
234
+ spectrl search api
322
235
 
323
- ## Troubleshooting
236
+ Found 3 specs matching "api":
324
237
 
325
- ### Registry Errors
238
+ ┌─────────────────────────┬─────────────────────────────────────┬──────────────────┬─────────┐
239
+ │ Spec │ Description │ Tags │ Version │
240
+ ├─────────────────────────┼─────────────────────────────────────┼──────────────────┼─────────┤
241
+ │ alice/api-spec │ REST API specification template │ api, rest │ 2.1.0 │
242
+ │ bob/graphql-api │ GraphQL API design patterns │ api, graphql │ 1.5.2 │
243
+ │ charlie/openapi-starter │ OpenAPI 3.0 starter template │ api, openapi │ 1.0.0 │
244
+ └─────────────────────────┴─────────────────────────────────────┴──────────────────┴─────────┘
326
245
 
246
+ Install with: spectrl install <spec>
327
247
  ```
328
- Error: Spec my-spec@1.0.0 not found in registry
329
- ```
330
248
 
331
- Publish the spec first:
249
+ #### `spectrl info <spec>`
250
+
251
+ Show detailed information about a spec from the public registry.
332
252
 
333
253
  ```bash
334
- cd path/to/my-spec && spectrl publish
335
- ```
254
+ spectrl info <spec>
336
255
 
337
- ```
338
- Error: Spec missing-spec not found in registry
256
+ Arguments:
257
+ spec Spec reference in format username/spec
339
258
  ```
340
259
 
341
- The spec doesn't exist in your registry:
260
+ **Example:**
342
261
 
343
262
  ```bash
344
- cd path/to/missing-spec && spectrl publish
345
- ```
263
+ spectrl info alice/api-spec
346
264
 
347
- ### Validation Errors
265
+ alice/api-spec
266
+ REST API specification template
348
267
 
268
+ Tags: api, rest, openapi
269
+
270
+ Versions:
271
+ ┌─────────┬──────────────────────┬─────────────┐
272
+ │ Version │ Published │ Downloads │
273
+ ├─────────┼──────────────────────┼─────────────┤
274
+ │ 2.1.0 │ 2024-12-08 (2d ago) │ 145 │
275
+ │ 2.0.0 │ 2024-11-15 (23d ago) │ 89 │
276
+ │ 1.5.0 │ 2024-10-01 (68d ago) │ 234 │
277
+ └─────────┴──────────────────────┴─────────────┘
278
+
279
+ Install latest: spectrl install alice/api-spec
280
+ Install specific: spectrl install alice/api-spec@2.1.0
349
281
  ```
350
- Error: Invalid spec reference format. Use: name or name@version
351
- ```
352
282
 
353
- Use correct format:
283
+ #### `spectrl list`
284
+
285
+ Show all installed specs (local and public).
354
286
 
355
287
  ```bash
356
- spectrl install my-spec
357
- # or
358
- spectrl install my-spec@1.0.0
288
+ spectrl list
359
289
  ```
360
290
 
361
- ```
362
- Error: Validation failed: file path contains '..'
363
- ```
291
+ **Example:**
364
292
 
365
- Use relative paths only (no parent directory references):
293
+ ```bash
294
+ spectrl list
366
295
 
367
- ```json
368
- {
369
- "files": ["docs/design/architecture.md"]
370
- }
371
- ```
296
+ Installed specs:
372
297
 
373
- ```
374
- Error: Validation failed: files array cannot be empty
298
+ ┌──────────────────────────┬─────────┬──────────┐
299
+ Spec │ Version Source │
300
+ ├──────────────────────────┼─────────┼──────────┤
301
+ │ alice/api-spec │ 2.1.0 │ public │
302
+ │ bob/graphql-api │ 1.5.2 │ public │
303
+ │ my-local-spec │ 1.0.0 │ local │
304
+ └──────────────────────────┴─────────┴──────────┘
305
+
306
+ 3 specs installed
375
307
  ```
376
308
 
377
- Add at least one file in `spectrl.json`:
309
+ ### Management
378
310
 
379
- ```json
380
- {
381
- "files": ["README.md"]
382
- }
383
- ```
311
+ #### `spectrl update [spec]`
384
312
 
385
- ```
386
- Error: File not found: docs/missing.md
313
+ Check for and install updates for public specs.
314
+
315
+ ```bash
316
+ spectrl update [spec] [options]
317
+
318
+ Arguments:
319
+ spec Optional spec reference to update
320
+
321
+ Options:
322
+ --all Update all specs with available updates
387
323
  ```
388
324
 
389
- Verify the file exists:
325
+ **Examples:**
390
326
 
391
327
  ```bash
392
- ls -la docs/missing.md
393
- ```
328
+ # Check for updates
329
+ spectrl update
394
330
 
395
- ### Dependency Errors
331
+ Updates available:
396
332
 
333
+ ┌──────────────────────────┬─────────────┬────────────┐
334
+ │ Spec │ Installed │ Latest │
335
+ ├──────────────────────────┼─────────────┼────────────┤
336
+ │ alice/api-spec │ 2.0.0 │ 2.1.0 │
337
+ │ bob/graphql-api │ 1.5.0 │ 1.5.2 │
338
+ └──────────────────────────┴─────────────┴────────────┘
339
+
340
+ Run 'spectrl update <spec>' to update a specific spec
341
+ Run 'spectrl update --all' to update all specs
342
+
343
+ # Update specific spec
344
+ spectrl update alice/api-spec
345
+
346
+ # Update all specs
347
+ spectrl update --all
397
348
  ```
398
- Error: Missing dependency middleware@0.5.0. Add it to .spectrl/spectrl-index.json
399
- ```
400
349
 
401
- Install the missing dependency:
350
+ #### `spectrl unpublish <spec>`
351
+
352
+ Remove a spec version from the public registry (requires authentication).
402
353
 
403
354
  ```bash
404
- spectrl install middleware@0.5.0
405
- ```
355
+ spectrl unpublish <spec>
406
356
 
407
- ```
408
- Error: Manifest mismatch for app@1.0.0: found name=app, version=0.9.0
357
+ Arguments:
358
+ spec Spec reference in format username/spec@version
409
359
  ```
410
360
 
411
- Update the index key or manifest to match. Check `spectrl.json` version field.
361
+ **Example:**
412
362
 
413
- ```
414
- Error: Cyclic dependency detected: dep-x@1.0.0 → dep-y@1.0.0 → dep-x@1.0.0
415
- ```
363
+ ```bash
364
+ spectrl unpublish alice/api-spec@1.0.0
416
365
 
417
- Remove the circular dependency from your spec manifests.
366
+ ⚠️ This will permanently delete alice/api-spec@1.0.0 from the public registry.
418
367
 
419
- ### Integrity Errors
368
+ ? Are you sure you want to continue?
369
+ ❯ No, cancel
370
+ Yes, delete alice/api-spec@1.0.0
420
371
 
372
+ Unpublishing alice/api-spec@1.0.0...
373
+ ✓ Successfully unpublished alice/api-spec@1.0.0
421
374
  ```
422
- Error: Integrity breach: hash mismatch for app@1.0.0
423
- ```
424
375
 
425
- Spec content changed after publishing. Republish or verify source:
376
+ ## Configuration
377
+
378
+ ### Environment Variables
426
379
 
427
380
  ```bash
428
- cd path/to/app && spectrl publish
381
+ # API endpoint (optional, defaults to production)
382
+ export API_URL="https://api.spectrl.dev"
383
+
384
+ # Registry URL for downloading specs (optional)
385
+ export REGISTRY_URL="https://registry.spectrl.dev"
429
386
  ```
430
387
 
388
+ ### Token Storage
389
+
390
+ Spectrl securely stores GitHub tokens using:
391
+
392
+ - **macOS**: Keychain Access
393
+ - **Windows**: Credential Manager
394
+ - **Linux**: Secret Service (libsecret)
395
+ - **Fallback**: Encrypted file (`~/.spectrl/.auth`)
396
+
397
+ ## Spec Reference Formats
398
+
399
+ Spectrl supports different spec reference formats:
400
+
401
+ | Format | Description | Example |
402
+ | ----------------------- | ----------------------------- | ---------------------- |
403
+ | `name` | Local spec, latest version | `my-spec` |
404
+ | `name@version` | Local spec, specific version | `my-spec@1.0.0` |
405
+ | `username/name` | Public spec, latest version | `alice/api-spec` |
406
+ | `username/name@version` | Public spec, specific version | `alice/api-spec@2.1.0` |
407
+
408
+ ## Troubleshooting
409
+
410
+ ### Authentication Issues
411
+
412
+ **Problem**: `spectrl login` fails with "bad_verification_code"
413
+
414
+ **Solution**:
415
+
416
+ 1. Ensure Device Flow is enabled on the GitHub OAuth App
417
+ 2. Check that you're entering the code correctly
418
+ 3. Try the login process again
419
+
420
+ **Problem**: "Invalid client_id" error during login
421
+
422
+ **Solution**:
423
+
424
+ 1. Verify the GitHub OAuth App configuration
425
+ 2. Contact support if the issue persists
426
+
427
+ ### Token Issues
428
+
429
+ **Problem**: Commands fail with authentication errors after successful login
430
+
431
+ **Solution**:
432
+
433
+ 1. Check token validity: `spectrl whoami`
434
+ 2. Re-authenticate: `spectrl logout && spectrl login`
435
+ 3. Verify keychain permissions on macOS
436
+
437
+ ### Network Issues
438
+
439
+ **Problem**: Commands timeout or fail with network errors
440
+
441
+ **Solution**:
442
+
443
+ 1. Check internet connection
444
+ 2. Verify API_URL environment variable
445
+ 3. Try again later (temporary service issues)
446
+
447
+ ### Installation Issues
448
+
449
+ **Problem**: "Spec not found" when installing public specs
450
+
451
+ **Solution**:
452
+
453
+ 1. Verify spec name and username: `spectrl search <query>`
454
+ 2. Check spec exists: `spectrl info username/spec`
455
+ 3. Ensure you're using the correct format: `username/spec`
456
+
457
+ **Problem**: Symlink creation fails on Windows
458
+
459
+ **Solution**:
460
+
461
+ - Spectrl automatically falls back to copying files
462
+ - No action needed, this is expected behavior
463
+
464
+ ### Publishing Issues
465
+
466
+ **Problem**: Publish fails with "agent field missing"
467
+
468
+ **Solution**:
469
+
470
+ - Spectrl auto-populates the agent field
471
+ - Ensure your `spectrl.json` is valid
472
+ - Check file permissions
473
+
474
+ ## FAQ
475
+
476
+ ### General
477
+
478
+ **Q: What's the difference between local and public registry?**
479
+
480
+ A:
481
+
482
+ - **Local registry**: Specs stored in `~/.spectrl/registry/`, private to your machine
483
+ - **Public registry**: Specs shared globally, discoverable by others, requires authentication
484
+
485
+ **Q: Can I use both local and public specs in the same project?**
486
+
487
+ A: Yes! You can install specs from both sources. Use `spectrl list` to see the source of each spec.
488
+
489
+ **Q: How do I know if a spec is from local or public registry?**
490
+
491
+ A: Public specs have a username prefix (e.g., `alice/api-spec`), local specs don't (e.g., `my-spec`).
492
+
493
+ ### Authentication
494
+
495
+ **Q: Do I need to authenticate for local registry operations?**
496
+
497
+ A: No, authentication is only required for public registry operations (publish, unpublish).
498
+
499
+ **Q: How long do tokens last?**
500
+
501
+ A: GitHub tokens don't expire automatically, but you can revoke them anytime in GitHub settings.
502
+
503
+ **Q: Can I use Spectrl in CI/CD?**
504
+
505
+ A: Yes, but you'll need to handle authentication differently. Consider using GitHub Actions with GITHUB_TOKEN.
506
+
507
+ ### Specs and Versioning
508
+
509
+ **Q: What happens when I install a spec that already exists?**
510
+
511
+ A: Spectrl detects collisions and prompts you to choose: keep existing, replace, or cancel.
512
+
513
+ **Q: How do I update a published spec?**
514
+
515
+ A: Increment the version in `spectrl.json` and run `spectrl publish` again.
516
+
517
+ **Q: Can I unpublish a spec?**
518
+
519
+ A: Yes, but only specific versions: `spectrl unpublish username/spec@version`. This is permanent.
520
+
521
+ ### File Management
522
+
523
+ **Q: Where are specs stored locally?**
524
+
525
+ A:
526
+
527
+ - **Registry**: `~/.spectrl/registry/`
528
+ - **Project specs**: `.spectrl/specs/`
529
+ - **Project index**: `.spectrl/index.json`
530
+
531
+ **Q: What happens to files when I install a spec?**
532
+
533
+ A: Spectrl creates symlinks (or copies on Windows) from `.spectrl/specs/` to the registry.
534
+
535
+ **Q: Can I modify installed specs?**
536
+
537
+ A: You can view files, but modifications won't persist. Create your own spec instead.
538
+
539
+ ## Examples
540
+
541
+ ### Publishing Your First Spec
542
+
543
+ ```bash
544
+ # 1. Create a new spec
545
+ mkdir my-api-spec
546
+ cd my-api-spec
547
+ spectrl new api-spec --description "My REST API specification"
548
+
549
+ # 2. Add your content
550
+ echo "# API Specification" > README.md
551
+ echo "## Endpoints" >> README.md
552
+
553
+ # 3. Update spectrl.json to include README.md
554
+ # Edit spectrl.json: add "README.md" to files array
555
+
556
+ # 4. Login to Spectrl
557
+ spectrl login
558
+
559
+ # 5. Publish to public registry
560
+ spectrl publish
561
+ # Choose "Public registry"
562
+
563
+ # 6. Verify publication
564
+ spectrl search api-spec
565
+ spectrl info yourusername/api-spec
431
566
  ```
432
- Hash changes unexpectedly
567
+
568
+ ### Finding and Installing Specs
569
+
570
+ ```bash
571
+ # Search for API-related specs
572
+ spectrl search api
573
+
574
+ # Get detailed information
575
+ spectrl info alice/rest-api-template
576
+
577
+ # Install latest version
578
+ spectrl install alice/rest-api-template
579
+
580
+ # Install specific version
581
+ spectrl install alice/rest-api-template@1.2.0
582
+
583
+ # List all installed specs
584
+ spectrl list
433
585
  ```
434
586
 
435
- Check for file modifications, line endings (LF vs CRLF), or trailing whitespace:
587
+ ### Keeping Specs Updated
436
588
 
437
589
  ```bash
438
- diff my-spec/docs/prd.md ~/.spectrl/registry/my-spec/1.0.0/files/docs/prd.md
590
+ # Check for updates
591
+ spectrl update
592
+
593
+ # Update specific spec
594
+ spectrl update alice/rest-api-template
595
+
596
+ # Update all specs at once
597
+ spectrl update --all
439
598
  ```
440
599
 
600
+ ## Support
601
+
602
+ - **Documentation**: [docs.spectrl.dev](https://docs.spectrl.dev)
603
+ - **Issues**: [GitHub Issues](https://github.com/spectrl/spectrl/issues)
604
+ - **Discussions**: [GitHub Discussions](https://github.com/spectrl/spectrl/discussions)
605
+
441
606
  ## License
442
607
 
443
- MIT
608
+ MIT © [Spectrl](https://spectrl.dev)