@fission-ai/openspec 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.
Files changed (77) hide show
  1. package/README.md +119 -0
  2. package/bin/openspec.js +3 -0
  3. package/dist/cli/index.d.ts +2 -0
  4. package/dist/cli/index.js +240 -0
  5. package/dist/commands/change.d.ts +35 -0
  6. package/dist/commands/change.js +276 -0
  7. package/dist/commands/show.d.ts +14 -0
  8. package/dist/commands/show.js +131 -0
  9. package/dist/commands/spec.d.ts +15 -0
  10. package/dist/commands/spec.js +224 -0
  11. package/dist/commands/validate.d.ts +23 -0
  12. package/dist/commands/validate.js +275 -0
  13. package/dist/core/archive.d.ts +15 -0
  14. package/dist/core/archive.js +529 -0
  15. package/dist/core/config.d.ts +14 -0
  16. package/dist/core/config.js +12 -0
  17. package/dist/core/configurators/base.d.ts +7 -0
  18. package/dist/core/configurators/base.js +2 -0
  19. package/dist/core/configurators/claude.d.ts +8 -0
  20. package/dist/core/configurators/claude.js +15 -0
  21. package/dist/core/configurators/registry.d.ts +9 -0
  22. package/dist/core/configurators/registry.js +22 -0
  23. package/dist/core/converters/json-converter.d.ts +6 -0
  24. package/dist/core/converters/json-converter.js +48 -0
  25. package/dist/core/diff.d.ts +11 -0
  26. package/dist/core/diff.js +193 -0
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.js +2 -0
  29. package/dist/core/init.d.ts +10 -0
  30. package/dist/core/init.js +109 -0
  31. package/dist/core/list.d.ts +4 -0
  32. package/dist/core/list.js +89 -0
  33. package/dist/core/parsers/change-parser.d.ts +13 -0
  34. package/dist/core/parsers/change-parser.js +192 -0
  35. package/dist/core/parsers/markdown-parser.d.ts +21 -0
  36. package/dist/core/parsers/markdown-parser.js +183 -0
  37. package/dist/core/parsers/requirement-blocks.d.ts +31 -0
  38. package/dist/core/parsers/requirement-blocks.js +173 -0
  39. package/dist/core/schemas/base.schema.d.ts +13 -0
  40. package/dist/core/schemas/base.schema.js +13 -0
  41. package/dist/core/schemas/change.schema.d.ts +73 -0
  42. package/dist/core/schemas/change.schema.js +31 -0
  43. package/dist/core/schemas/index.d.ts +4 -0
  44. package/dist/core/schemas/index.js +4 -0
  45. package/dist/core/schemas/spec.schema.d.ts +18 -0
  46. package/dist/core/schemas/spec.schema.js +15 -0
  47. package/dist/core/templates/claude-template.d.ts +2 -0
  48. package/dist/core/templates/claude-template.js +96 -0
  49. package/dist/core/templates/index.d.ts +11 -0
  50. package/dist/core/templates/index.js +21 -0
  51. package/dist/core/templates/project-template.d.ts +8 -0
  52. package/dist/core/templates/project-template.js +32 -0
  53. package/dist/core/templates/readme-template.d.ts +2 -0
  54. package/dist/core/templates/readme-template.js +519 -0
  55. package/dist/core/update.d.ts +4 -0
  56. package/dist/core/update.js +47 -0
  57. package/dist/core/validation/constants.d.ts +34 -0
  58. package/dist/core/validation/constants.js +40 -0
  59. package/dist/core/validation/types.d.ts +18 -0
  60. package/dist/core/validation/types.js +2 -0
  61. package/dist/core/validation/validator.d.ts +32 -0
  62. package/dist/core/validation/validator.js +355 -0
  63. package/dist/index.d.ts +3 -0
  64. package/dist/index.js +3 -0
  65. package/dist/utils/file-system.d.ts +10 -0
  66. package/dist/utils/file-system.js +83 -0
  67. package/dist/utils/index.d.ts +2 -0
  68. package/dist/utils/index.js +2 -0
  69. package/dist/utils/interactive.d.ts +2 -0
  70. package/dist/utils/interactive.js +8 -0
  71. package/dist/utils/item-discovery.d.ts +3 -0
  72. package/dist/utils/item-discovery.js +49 -0
  73. package/dist/utils/match.d.ts +3 -0
  74. package/dist/utils/match.js +22 -0
  75. package/dist/utils/task-progress.d.ts +8 -0
  76. package/dist/utils/task-progress.js +36 -0
  77. package/package.json +68 -0
@@ -0,0 +1,519 @@
1
+ export const readmeTemplate = `# OpenSpec Instructions
2
+
3
+ This document provides instructions for AI coding assistants on how to use OpenSpec conventions for spec-driven development. Follow these rules precisely when working on OpenSpec-enabled projects.
4
+
5
+ ## Core Principle
6
+
7
+ OpenSpec is an AI-native system for change-driven development where:
8
+ - **Specs** (\`specs/\`) reflect what IS currently built and deployed
9
+ - **Changes** (\`changes/\`) contain proposals for what SHOULD be changed
10
+ - **AI drives the process** - You generate proposals, humans review and approve
11
+ - **Specs are living documentation** - Always kept in sync with deployed code
12
+
13
+ ## Start Simple
14
+
15
+ **Default to minimal implementations:**
16
+ - New features should be <100 lines of code initially
17
+ - Use the simplest solution that works
18
+ - Avoid premature optimization (no caching, parallelization, or complex patterns without proven need)
19
+ - Choose boring technology over cutting-edge solutions
20
+
21
+ **Complexity triggers** - Only add complexity when you have:
22
+ - **Performance data** showing current solution is too slow
23
+ - **Scale requirements** with specific numbers (>1000 users, >100MB data)
24
+ - **Multiple use cases** requiring the same abstraction
25
+ - **Regulatory compliance** mandating specific patterns
26
+ - **Security threats** that simple solutions cannot address
27
+
28
+ When triggered, document the specific justification in your change proposal.
29
+
30
+ ## Directory Structure
31
+
32
+ \`\`\`
33
+ openspec/
34
+ ├── project.md # Project-specific context (tech stack, conventions)
35
+ ├── README.md # This file - OpenSpec instructions
36
+ ├── specs/ # Current truth - what IS built
37
+ │ ├── [capability]/ # Single, focused capability
38
+ │ │ ├── spec.md # WHAT the capability does and WHY
39
+ │ │ └── design.md # HOW it's built (established patterns)
40
+ │ └── ...
41
+ ├── changes/ # Proposed changes - what we're CHANGING
42
+ │ ├── [change-name]/
43
+ │ │ ├── proposal.md # Why, what, impact (consolidated)
44
+ │ │ ├── tasks.md # Implementation checklist
45
+ │ │ ├── design.md # Technical decisions (optional, for complex changes)
46
+ │ │ └── specs/ # Delta changes to specs
47
+ │ │ └── [capability]/
48
+ │ │ └── spec.md # Delta format (ADDED/MODIFIED/REMOVED/RENAMED)
49
+ │ └── archive/ # Completed changes (dated)
50
+ \`\`\`
51
+
52
+ ### Capability Organization
53
+
54
+ **Use capabilities, not features** - Each directory under \`specs/\` represents a single, focused responsibility:
55
+ - **Verb-noun naming**: \`user-auth\`, \`payment-capture\`, \`order-checkout\`
56
+ - **10-minute rule**: Each capability should be understandable in <10 minutes
57
+ - **Single purpose**: If it needs "AND" to describe it, split it
58
+
59
+ Examples:
60
+ \`\`\`
61
+ ✅ GOOD: user-auth, user-sessions, payment-capture, payment-refunds
62
+ ❌ BAD: users, payments, core, misc
63
+ \`\`\`
64
+
65
+ ## Key Behavioral Rules
66
+
67
+ ### 1. Always Start by Reading
68
+
69
+ Before any task:
70
+ 1. **Read relevant specs** in \`specs/[capability]/spec.md\` to understand current state
71
+ 2. **Check pending changes** in \`changes/\` directory for potential conflicts
72
+ 3. **Read project.md** for project-specific conventions
73
+
74
+ ### 2. When to Create Change Proposals
75
+
76
+ **ALWAYS create a change proposal for:**
77
+ - New features or functionality
78
+ - Breaking changes (API changes, schema updates)
79
+ - Architecture changes or new patterns
80
+ - Performance optimizations that change behavior
81
+ - Security updates affecting auth/access patterns
82
+ - Any change requiring multiple steps or affecting multiple systems
83
+
84
+ **SKIP proposals for:**
85
+ - Bug fixes that restore intended behavior
86
+ - Typos, formatting, or comment updates
87
+ - Dependency updates (unless breaking)
88
+ - Configuration or environment variable changes
89
+ - Adding tests for existing behavior
90
+ - Documentation fixes
91
+
92
+ **Complexity assessment:**
93
+ - If your solution requires >100 lines of new code, justify the complexity
94
+ - If adding dependencies, frameworks, or architectural patterns, document why simpler alternatives won't work
95
+ - Default to single-file implementations until proven insufficient
96
+
97
+ ### 3. Delta-Based Change Format
98
+
99
+ Changes use a delta format with clear sections:
100
+
101
+ \`\`\`markdown
102
+ ## ADDED Requirements
103
+ ### Requirement: New Feature
104
+ [Complete requirement content in structured format]
105
+
106
+ ## MODIFIED Requirements
107
+ ### Requirement: Existing Feature
108
+ [Complete modified requirement (header must match current spec)]
109
+
110
+ ## REMOVED Requirements
111
+ ### Requirement: Old Feature
112
+ **Reason for removal**: [Why removing]
113
+ **Migration path**: [How to handle existing usage]
114
+
115
+ ## RENAMED Requirements
116
+ - FROM: \`### Requirement: Old Name\`
117
+ - TO: \`### Requirement: New Name\`
118
+ \`\`\`
119
+
120
+ Key rules:
121
+ - Headers are matched using \`normalize(header) = trim(header)\`
122
+ - Include complete requirements (not diffs)
123
+ - Use standard symbols in CLI output: + (added), ~ (modified), - (removed), → (renamed)
124
+
125
+ ### 4. Creating a Change Proposal
126
+
127
+ When a user requests a significant change:
128
+
129
+ \`\`\`bash
130
+ # 1. Create the change directory
131
+ openspec/changes/[descriptive-name]/
132
+
133
+ # 2. Generate proposal.md with all context
134
+ ## Why
135
+ [1-2 sentences on the problem/opportunity]
136
+
137
+ ## What Changes
138
+ [Bullet list of changes, including breaking changes]
139
+
140
+ ## Impact
141
+ - Affected specs: [list capabilities that will change]
142
+ - Affected code: [list key files/systems]
143
+
144
+ # 3. Create delta specs for ALL affected capabilities
145
+ # - Store only the changes (not complete future state)
146
+ # - Use sections: ## ADDED, ## MODIFIED, ## REMOVED, ## RENAMED
147
+ # - Include complete requirements in their final form
148
+ # Example spec.md content:
149
+ # ## ADDED Requirements
150
+ # ### Requirement: Password Reset
151
+ # Users SHALL be able to reset passwords via email...
152
+ #
153
+ # ## MODIFIED Requirements
154
+ # ### Requirement: User Authentication
155
+ # [Complete modified requirement with new password reset hook]
156
+ specs/
157
+ └── [capability]/
158
+ └── spec.md # Contains delta sections
159
+
160
+ # 4. Create tasks.md with implementation steps
161
+ ## 1. [Task Group]
162
+ - [ ] 1.1 [Specific task]
163
+ - [ ] 1.2 [Specific task]
164
+
165
+ # 5. For complex changes, add design.md
166
+ [Technical decisions and trade-offs]
167
+ \`\`\`
168
+
169
+ ### 5. The Change Lifecycle
170
+
171
+ 1. **Propose** → Create change directory with delta-based documentation
172
+ 2. **Review** → User reviews and approves the proposal
173
+ 3. **Implement** → Follow the approved tasks.md (can be multiple PRs)
174
+ 4. **Deploy** → User confirms deployment
175
+ 5. **Update Specs** → Apply deltas to sync specs/ with new reality (IF the change affects system capabilities)
176
+ 6. **Archive** → Move to \`changes/archive/YYYY-MM-DD-[name]/\`
177
+
178
+ ### 6. Implementing Changes
179
+
180
+ When implementing an approved change:
181
+ 1. Follow the tasks.md checklist exactly
182
+ 2. **Mark completed tasks** in tasks.md as you finish them (e.g., \`- [x] 1.1 Task completed\`)
183
+ 3. Ensure code matches the proposed behavior
184
+ 4. Update any affected tests
185
+ 5. **Keep change in \`changes/\` directory** - do NOT archive in implementation PR
186
+
187
+ **Multiple Implementation PRs:**
188
+ - Changes can be implemented across multiple PRs
189
+ - Each PR should update tasks.md to mark what was completed
190
+ - Different developers can work on different task groups
191
+ - Example: PR #1 completes tasks 1.1-1.3, PR #2 completes tasks 2.1-2.4
192
+
193
+ ### 7. Updating Specs and Archiving After Deployment
194
+
195
+ **Create a separate PR after deployment** that:
196
+ 1. Moves change to \`changes/archive/YYYY-MM-DD-[name]/\`
197
+ 2. Updates relevant files in \`specs/\` to reflect new reality (if needed)
198
+ 3. If design.md exists, incorporates proven patterns into \`specs/[capability]/design.md\`
199
+
200
+ This ensures changes are only archived when truly complete and deployed.
201
+
202
+ ### 8. Types of Changes That Don't Require Specs
203
+
204
+ Some changes only affect development infrastructure and don't need specs:
205
+ - Initial project setup (package.json, tsconfig.json, etc.)
206
+ - Development tooling changes (linters, formatters, build tools)
207
+ - CI/CD configuration
208
+ - Development dependencies
209
+
210
+ For these changes:
211
+ 1. Implement → Deploy → Mark tasks complete → Archive
212
+ 2. Skip the "Update Specs" step entirely
213
+
214
+ ### What Deserves a Spec?
215
+
216
+ Ask yourself:
217
+ - Is this a system capability that users or other systems interact with?
218
+ - Does it have ongoing behavior that needs documentation?
219
+ - Would a new developer need to understand this to work with the system?
220
+
221
+ If NO to all → No spec needed (likely just tooling/infrastructure)
222
+
223
+ ## Understanding Specs vs Code
224
+
225
+ ### Specs Document WHAT and WHY
226
+ \`\`\`markdown
227
+ # Authentication Spec
228
+
229
+ Users SHALL authenticate with email and password.
230
+
231
+ WHEN credentials are valid THEN issue JWT token.
232
+ WHEN credentials are invalid THEN return generic error.
233
+
234
+ WHY: Prevent user enumeration attacks.
235
+ \`\`\`
236
+
237
+ ### Code Documents HOW
238
+ \`\`\`javascript
239
+ // Implementation details
240
+ const user = await db.users.findOne({ email });
241
+ const valid = await bcrypt.compare(password, user.hashedPassword);
242
+ \`\`\`
243
+
244
+ **Key Distinction**: Specs capture intent, constraints, and decisions that aren't obvious from code.
245
+
246
+ ## Common Scenarios
247
+
248
+ ### New Feature Request
249
+ \`\`\`
250
+ User: "Add password reset functionality"
251
+
252
+ You should:
253
+ 1. Read specs/user-auth/spec.md
254
+ 2. Check changes/ for pending auth changes
255
+ 3. Create changes/add-password-reset/ with:
256
+ - proposal.md describing the change
257
+ - specs/user-auth/spec.md with:
258
+ ## ADDED Requirements
259
+ ### Requirement: Password Reset
260
+ [Complete requirement for password reset]
261
+
262
+ ## MODIFIED Requirements
263
+ ### Requirement: User Authentication
264
+ [Updated to integrate with password reset]
265
+ 4. Wait for approval before implementing
266
+ \`\`\`
267
+
268
+ ### Bug Fix
269
+ \`\`\`
270
+ User: "Getting null pointer error when bio is empty"
271
+
272
+ You should:
273
+ 1. Check if spec says bios are optional
274
+ 2. If yes → Fix directly (it's a bug)
275
+ 3. If no → Create change proposal (it's a behavior change)
276
+ \`\`\`
277
+
278
+ ### Infrastructure Setup
279
+ \`\`\`
280
+ User: "Initialize TypeScript project"
281
+
282
+ You should:
283
+ 1. Create change proposal for TypeScript setup
284
+ 2. Implement configuration files (PR #1)
285
+ 3. Mark tasks complete in tasks.md
286
+ 4. After deployment, create separate PR to archive
287
+ (no specs update needed - this is tooling, not a capability)
288
+ \`\`\`
289
+
290
+ ## Summary Workflow
291
+
292
+ 1. **Receive request** → Determine if it needs a change proposal
293
+ 2. **Read current state** → Check specs and pending changes
294
+ 3. **Create proposal** → Generate complete change documentation
295
+ 4. **Get approval** → User reviews the proposal
296
+ 5. **Implement** → Follow approved tasks, mark completed items in tasks.md
297
+ 6. **Deploy** → User deploys the implementation
298
+ 7. **Archive PR** → Create separate PR to:
299
+ - Move change to archive
300
+ - Update specs if needed
301
+ - Mark change as complete
302
+
303
+ ## PR Workflow Examples
304
+
305
+ ### Single Developer, Simple Change
306
+ \`\`\`
307
+ PR #1: Implementation
308
+ - Implement all tasks
309
+ - Update tasks.md marking items complete
310
+ - Get merged and deployed
311
+
312
+ PR #2: Archive (after deployment)
313
+ - Move changes/feature-x/ → changes/archive/2025-01-15-feature-x/
314
+ - Update specs if needed
315
+ \`\`\`
316
+
317
+ ### Multiple Developers, Complex Change
318
+ \`\`\`
319
+ PR #1: Alice implements auth components
320
+ - Complete tasks 1.1, 1.2, 1.3
321
+ - Update tasks.md marking these complete
322
+
323
+ PR #2: Bob implements UI components
324
+ - Complete tasks 2.1, 2.2
325
+ - Update tasks.md marking these complete
326
+
327
+ PR #3: Alice fixes integration issues
328
+ - Complete remaining task 1.4
329
+ - Update tasks.md
330
+
331
+ [Deploy all changes]
332
+
333
+ PR #4: Archive
334
+ - Move to archive with deployment date
335
+ - Update specs to reflect new auth flow
336
+ \`\`\`
337
+
338
+ ### Key Rules
339
+ - **Never archive in implementation PRs** - changes aren't done until deployed
340
+ - **Always update tasks.md** - shows accurate progress
341
+ - **One archive PR per change** - clear completion boundary
342
+ - **Archive PR includes spec updates** - keeps specs current
343
+
344
+ ## Capability Organization Best Practices
345
+
346
+ ### Naming Capabilities
347
+ - Use **verb-noun** patterns: \`user-auth\`, \`payment-capture\`, \`order-checkout\`
348
+ - Be specific: \`payment-capture\` not just \`payments\`
349
+ - Keep flat: Avoid nesting capabilities within capabilities
350
+ - Singular focus: If you need "AND" to describe it, split it
351
+
352
+ ### When to Split Capabilities
353
+ Split when you have:
354
+ - Multiple unrelated API endpoints
355
+ - Different user personas or actors
356
+ - Separate deployment considerations
357
+ - Independent evolution paths
358
+
359
+ #### Capability Boundary Guidelines
360
+ - Would you import these separately? → Separate capabilities
361
+ - Different deployment cadence? → Separate capabilities
362
+ - Different teams own them? → Separate capabilities
363
+ - Shared data models are OK, shared business logic means combine
364
+
365
+ Examples:
366
+ - user-auth (login/logout) vs user-sessions (token management) → SEPARATE
367
+ - payment-capture vs payment-refunds → SEPARATE (different workflows)
368
+ - user-profile vs user-settings → COMBINE (same data model, same owner)
369
+
370
+ ### Cross-Cutting Concerns
371
+ For system-wide policies (rate limiting, error handling, security), document them in:
372
+ - \`project.md\` for project-wide conventions
373
+ - Within relevant capability specs where they apply
374
+ - Or create a dedicated capability if complex enough (e.g., \`api-rate-limiting/\`)
375
+
376
+ ### Examples of Well-Organized Capabilities
377
+ \`\`\`
378
+ specs/
379
+ ├── user-auth/ # Login, logout, password reset
380
+ ├── user-sessions/ # Token management, refresh
381
+ ├── user-profile/ # Profile CRUD operations
382
+ ├── payment-capture/ # Processing payments
383
+ ├── payment-refunds/ # Handling refunds
384
+ └── order-checkout/ # Checkout workflow
385
+ \`\`\`
386
+
387
+ For detailed guidance, see the [Capability Organization Guide](../docs/capability-organization.md).
388
+
389
+ ## Common Scenarios and Clarifications
390
+
391
+ ### Decision Ambiguity: Bug vs Behavior Change
392
+
393
+ When specs are missing or ambiguous:
394
+ - If NO spec exists → Treat current code behavior as implicit spec, require proposal
395
+ - If spec is VAGUE → Require proposal to clarify spec alongside fix
396
+ - If code and spec DISAGREE → Spec is truth, code is buggy (fix without proposal)
397
+ - If unsure → Default to creating a proposal (safer option)
398
+
399
+ Example:
400
+ \`\`\`
401
+ User: "The API returns 404 for missing users but should return 400"
402
+ AI: Is this a bug (spec says 400) or behavior change (spec says 404)?
403
+ \`\`\`
404
+
405
+ ### When You Don't Know the Scope
406
+ It's OK to explore first! Tell the user you need to investigate, then create an informed proposal.
407
+
408
+ ### Exploration Phase (When Needed)
409
+
410
+ BEFORE creating proposal, you may need exploration when:
411
+ - User request is vague or high-level
412
+ - Multiple implementation approaches exist
413
+ - Scope is unclear without seeing code
414
+
415
+ Exploration checklist:
416
+ 1. Tell user you need to explore first
417
+ 2. Use Grep/Read to understand current state
418
+ 3. Create initial proposal based on findings
419
+ 4. Refine with user feedback
420
+
421
+ Example:
422
+ \`\`\`
423
+ User: "Add caching to improve performance"
424
+ AI: "Let me explore the codebase to understand the current architecture and identify caching opportunities."
425
+ [After exploration]
426
+ AI: "Based on my analysis, I've identified three areas where caching would help. Here's my proposal..."
427
+ \`\`\`
428
+
429
+ ### When No Specs Exist
430
+ Treat current code as implicit spec. Your proposal should document current state AND proposed changes.
431
+
432
+ ### When in Doubt
433
+ Default to creating a proposal. It's easier to skip an unnecessary proposal than fix an undocumented change.
434
+
435
+ ### AI Workflow Adaptations
436
+
437
+ Task tracking with OpenSpec:
438
+ - Track exploration tasks separately from implementation
439
+ - Document proposal creation steps as you go
440
+ - Keep implementation tasks separate until proposal approved
441
+
442
+ Parallel operations encouraged:
443
+ - Read multiple specs simultaneously
444
+ - Check multiple pending changes at once
445
+ - Batch related searches for efficiency
446
+
447
+ Progress communication:
448
+ - "Exploring codebase to understand scope..."
449
+ - "Creating proposal based on findings..."
450
+ - "Implementing approved changes..."
451
+
452
+ ### For AI Assistants
453
+ - **Bias toward simplicity** - Propose the minimal solution that works
454
+ - Use your exploration tools liberally before proposing
455
+ - Batch operations for efficiency
456
+ - Communicate your progress
457
+ - It's OK to revise proposals based on discoveries
458
+ - **Question complexity** - If your solution feels complex, simplify first
459
+
460
+ ## Edge Case Handling
461
+
462
+ ### Multi-Capability Changes
463
+ Create ONE proposal that:
464
+ - Lists all affected capabilities
465
+ - Shows changes per capability
466
+ - Has unified task list
467
+ - Gets approved as a whole
468
+
469
+ ### Outdated Specs
470
+ If specs clearly outdated:
471
+ 1. Create proposal to update specs to match reality
472
+ 2. Implement new feature in separate proposal
473
+ 3. OR combine both in one proposal with clear sections
474
+
475
+ ### Emergency Hotfixes
476
+ For critical production issues:
477
+ 1. Announce: "This is an emergency fix"
478
+ 2. Implement fix immediately
479
+ 3. Create retroactive proposal
480
+ 4. Update specs after deployment
481
+ 5. Tag with [EMERGENCY] in archive
482
+
483
+ ### Pure Refactoring
484
+ No proposal needed for:
485
+ - Code formatting/style
486
+ - Internal refactoring (same API)
487
+ - Performance optimization (same behavior)
488
+ - Adding types to untyped code
489
+
490
+ Proposal REQUIRED for:
491
+ - API changes (even if compatible)
492
+ - Database schema changes
493
+ - Architecture changes
494
+ - New dependencies
495
+
496
+ ### Observability Additions
497
+ No proposal needed for:
498
+ - Adding log statements
499
+ - New metrics/traces
500
+ - Debugging additions
501
+ - Error tracking
502
+
503
+ Proposal REQUIRED if:
504
+ - Changes log format/structure
505
+ - Adds new monitoring service
506
+ - Changes what's logged (privacy)
507
+
508
+ ## Remember
509
+
510
+ - You are the process driver - automate documentation burden
511
+ - Specs must always reflect deployed reality
512
+ - Changes are proposed, not imposed
513
+ - Impact analysis prevents surprises
514
+ - Simplicity is the power - just markdown files, minimal solutions
515
+ - Start simple, add complexity only when justified
516
+
517
+ By following these conventions, you enable true spec-driven development where documentation stays current, changes are traceable, and evolution is intentional.
518
+ `;
519
+ //# sourceMappingURL=readme-template.js.map
@@ -0,0 +1,4 @@
1
+ export declare class UpdateCommand {
2
+ execute(projectPath: string): Promise<void>;
3
+ }
4
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1,47 @@
1
+ import path from 'path';
2
+ import { FileSystemUtils } from '../utils/file-system.js';
3
+ import { OPENSPEC_DIR_NAME } from './config.js';
4
+ import { readmeTemplate } from './templates/readme-template.js';
5
+ import { ToolRegistry } from './configurators/registry.js';
6
+ export class UpdateCommand {
7
+ async execute(projectPath) {
8
+ const resolvedProjectPath = path.resolve(projectPath);
9
+ const openspecDirName = OPENSPEC_DIR_NAME;
10
+ const openspecPath = path.join(resolvedProjectPath, openspecDirName);
11
+ // 1. Check openspec directory exists
12
+ if (!await FileSystemUtils.directoryExists(openspecPath)) {
13
+ throw new Error(`No OpenSpec directory found. Run 'openspec init' first.`);
14
+ }
15
+ // 2. Update README.md (full replacement)
16
+ const readmePath = path.join(openspecPath, 'README.md');
17
+ await FileSystemUtils.writeFile(readmePath, readmeTemplate);
18
+ // 3. Update existing AI tool configuration files only
19
+ const configurators = ToolRegistry.getAll();
20
+ let updatedFiles = [];
21
+ let failedFiles = [];
22
+ for (const configurator of configurators) {
23
+ const configFilePath = path.join(resolvedProjectPath, configurator.configFileName);
24
+ // Only update if the file already exists
25
+ if (await FileSystemUtils.fileExists(configFilePath)) {
26
+ try {
27
+ await configurator.configure(resolvedProjectPath, openspecPath);
28
+ updatedFiles.push(configurator.configFileName);
29
+ }
30
+ catch (error) {
31
+ failedFiles.push(configurator.configFileName);
32
+ console.error(`Failed to update ${configurator.configFileName}: ${error instanceof Error ? error.message : String(error)}`);
33
+ }
34
+ }
35
+ }
36
+ // 4. Success message (ASCII-safe)
37
+ const messages = ['Updated OpenSpec instructions (README.md)'];
38
+ if (updatedFiles.length > 0) {
39
+ messages.push(`Updated AI tool files: ${updatedFiles.join(', ')}`);
40
+ }
41
+ if (failedFiles.length > 0) {
42
+ messages.push(`Failed to update: ${failedFiles.join(', ')}`);
43
+ }
44
+ console.log(messages.join('\n'));
45
+ }
46
+ }
47
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Validation threshold constants
3
+ */
4
+ export declare const MIN_WHY_SECTION_LENGTH = 50;
5
+ export declare const MIN_PURPOSE_LENGTH = 50;
6
+ export declare const MAX_WHY_SECTION_LENGTH = 1000;
7
+ export declare const MAX_REQUIREMENT_TEXT_LENGTH = 500;
8
+ export declare const MAX_DELTAS_PER_CHANGE = 10;
9
+ export declare const VALIDATION_MESSAGES: {
10
+ readonly SCENARIO_EMPTY: "Scenario text cannot be empty";
11
+ readonly REQUIREMENT_EMPTY: "Requirement text cannot be empty";
12
+ readonly REQUIREMENT_NO_SHALL: "Requirement must contain SHALL or MUST keyword";
13
+ readonly REQUIREMENT_NO_SCENARIOS: "Requirement must have at least one scenario";
14
+ readonly SPEC_NAME_EMPTY: "Spec name cannot be empty";
15
+ readonly SPEC_PURPOSE_EMPTY: "Purpose section cannot be empty";
16
+ readonly SPEC_NO_REQUIREMENTS: "Spec must have at least one requirement";
17
+ readonly CHANGE_NAME_EMPTY: "Change name cannot be empty";
18
+ readonly CHANGE_WHY_TOO_SHORT: "Why section must be at least 50 characters";
19
+ readonly CHANGE_WHY_TOO_LONG: "Why section should not exceed 1000 characters";
20
+ readonly CHANGE_WHAT_EMPTY: "What Changes section cannot be empty";
21
+ readonly CHANGE_NO_DELTAS: "Change must have at least one delta";
22
+ readonly CHANGE_TOO_MANY_DELTAS: "Consider splitting changes with more than 10 deltas";
23
+ readonly DELTA_SPEC_EMPTY: "Spec name cannot be empty";
24
+ readonly DELTA_DESCRIPTION_EMPTY: "Delta description cannot be empty";
25
+ readonly PURPOSE_TOO_BRIEF: "Purpose section is too brief (less than 50 characters)";
26
+ readonly REQUIREMENT_TOO_LONG: "Requirement text is very long (>500 characters). Consider breaking it down.";
27
+ readonly DELTA_DESCRIPTION_TOO_BRIEF: "Delta description is too brief";
28
+ readonly DELTA_MISSING_REQUIREMENTS: "Delta should include requirements";
29
+ readonly GUIDE_NO_DELTAS: "No deltas found. Ensure your change has a specs/ directory with .md files using delta headers (## ADDED/MODIFIED/REMOVED/RENAMED Requirements) and that each requirement includes at least one \"#### Scenario:\" block. Tip: run \"openspec change show <change-id> --json --deltas-only\" to inspect parsed deltas.";
30
+ readonly GUIDE_MISSING_SPEC_SECTIONS: "Missing required sections. Expected headers: \"## Purpose\" and \"## Requirements\". Example:\n## Purpose\n[brief purpose]\n\n## Requirements\n### Requirement: Clear requirement statement\nUsers SHALL ...\n\n#### Scenario: Descriptive name\n- **WHEN** ...\n- **THEN** ...";
31
+ readonly GUIDE_MISSING_CHANGE_SECTIONS: "Missing required sections. Expected headers: \"## Why\" and \"## What Changes\". Ensure deltas are documented in specs/ using delta headers.";
32
+ readonly GUIDE_SCENARIO_FORMAT: "Scenarios must use level-4 headers. Convert bullet lists into:\n#### Scenario: Short name\n- **WHEN** ...\n- **THEN** ...\n- **AND** ...";
33
+ };
34
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Validation threshold constants
3
+ */
4
+ // Minimum character lengths
5
+ export const MIN_WHY_SECTION_LENGTH = 50;
6
+ export const MIN_PURPOSE_LENGTH = 50;
7
+ // Maximum character/item limits
8
+ export const MAX_WHY_SECTION_LENGTH = 1000;
9
+ export const MAX_REQUIREMENT_TEXT_LENGTH = 500;
10
+ export const MAX_DELTAS_PER_CHANGE = 10;
11
+ // Validation messages
12
+ export const VALIDATION_MESSAGES = {
13
+ // Required content
14
+ SCENARIO_EMPTY: 'Scenario text cannot be empty',
15
+ REQUIREMENT_EMPTY: 'Requirement text cannot be empty',
16
+ REQUIREMENT_NO_SHALL: 'Requirement must contain SHALL or MUST keyword',
17
+ REQUIREMENT_NO_SCENARIOS: 'Requirement must have at least one scenario',
18
+ SPEC_NAME_EMPTY: 'Spec name cannot be empty',
19
+ SPEC_PURPOSE_EMPTY: 'Purpose section cannot be empty',
20
+ SPEC_NO_REQUIREMENTS: 'Spec must have at least one requirement',
21
+ CHANGE_NAME_EMPTY: 'Change name cannot be empty',
22
+ CHANGE_WHY_TOO_SHORT: `Why section must be at least ${MIN_WHY_SECTION_LENGTH} characters`,
23
+ CHANGE_WHY_TOO_LONG: `Why section should not exceed ${MAX_WHY_SECTION_LENGTH} characters`,
24
+ CHANGE_WHAT_EMPTY: 'What Changes section cannot be empty',
25
+ CHANGE_NO_DELTAS: 'Change must have at least one delta',
26
+ CHANGE_TOO_MANY_DELTAS: `Consider splitting changes with more than ${MAX_DELTAS_PER_CHANGE} deltas`,
27
+ DELTA_SPEC_EMPTY: 'Spec name cannot be empty',
28
+ DELTA_DESCRIPTION_EMPTY: 'Delta description cannot be empty',
29
+ // Warnings
30
+ PURPOSE_TOO_BRIEF: `Purpose section is too brief (less than ${MIN_PURPOSE_LENGTH} characters)`,
31
+ REQUIREMENT_TOO_LONG: `Requirement text is very long (>${MAX_REQUIREMENT_TEXT_LENGTH} characters). Consider breaking it down.`,
32
+ DELTA_DESCRIPTION_TOO_BRIEF: 'Delta description is too brief',
33
+ DELTA_MISSING_REQUIREMENTS: 'Delta should include requirements',
34
+ // Guidance snippets (appended to primary messages for remediation)
35
+ GUIDE_NO_DELTAS: 'No deltas found. Ensure your change has a specs/ directory with .md files using delta headers (## ADDED/MODIFIED/REMOVED/RENAMED Requirements) and that each requirement includes at least one "#### Scenario:" block. Tip: run "openspec change show <change-id> --json --deltas-only" to inspect parsed deltas.',
36
+ GUIDE_MISSING_SPEC_SECTIONS: 'Missing required sections. Expected headers: "## Purpose" and "## Requirements". Example:\n## Purpose\n[brief purpose]\n\n## Requirements\n### Requirement: Clear requirement statement\nUsers SHALL ...\n\n#### Scenario: Descriptive name\n- **WHEN** ...\n- **THEN** ...',
37
+ GUIDE_MISSING_CHANGE_SECTIONS: 'Missing required sections. Expected headers: "## Why" and "## What Changes". Ensure deltas are documented in specs/ using delta headers.',
38
+ GUIDE_SCENARIO_FORMAT: 'Scenarios must use level-4 headers. Convert bullet lists into:\n#### Scenario: Short name\n- **WHEN** ...\n- **THEN** ...\n- **AND** ...',
39
+ };
40
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,18 @@
1
+ export type ValidationLevel = 'ERROR' | 'WARNING' | 'INFO';
2
+ export interface ValidationIssue {
3
+ level: ValidationLevel;
4
+ path: string;
5
+ message: string;
6
+ line?: number;
7
+ column?: number;
8
+ }
9
+ export interface ValidationReport {
10
+ valid: boolean;
11
+ issues: ValidationIssue[];
12
+ summary: {
13
+ errors: number;
14
+ warnings: number;
15
+ info: number;
16
+ };
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map