spec-gen-cli 1.2.6 → 1.2.8

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 (198) hide show
  1. package/README.md +175 -55
  2. package/dist/api/analyze.d.ts.map +1 -1
  3. package/dist/api/analyze.js +6 -1
  4. package/dist/api/analyze.js.map +1 -1
  5. package/dist/api/audit.d.ts +10 -0
  6. package/dist/api/audit.d.ts.map +1 -0
  7. package/dist/api/audit.js +117 -0
  8. package/dist/api/audit.js.map +1 -0
  9. package/dist/api/generate.d.ts.map +1 -1
  10. package/dist/api/generate.js +10 -1
  11. package/dist/api/generate.js.map +1 -1
  12. package/dist/api/index.d.ts +3 -2
  13. package/dist/api/index.d.ts.map +1 -1
  14. package/dist/api/index.js +1 -0
  15. package/dist/api/index.js.map +1 -1
  16. package/dist/api/run.d.ts.map +1 -1
  17. package/dist/api/run.js +5 -1
  18. package/dist/api/run.js.map +1 -1
  19. package/dist/api/types.d.ts +15 -4
  20. package/dist/api/types.d.ts.map +1 -1
  21. package/dist/cli/commands/analyze.d.ts +3 -0
  22. package/dist/cli/commands/analyze.d.ts.map +1 -1
  23. package/dist/cli/commands/analyze.js +112 -17
  24. package/dist/cli/commands/analyze.js.map +1 -1
  25. package/dist/cli/commands/audit.d.ts +9 -0
  26. package/dist/cli/commands/audit.d.ts.map +1 -0
  27. package/dist/cli/commands/audit.js +98 -0
  28. package/dist/cli/commands/audit.js.map +1 -0
  29. package/dist/cli/commands/drift.d.ts.map +1 -1
  30. package/dist/cli/commands/drift.js +8 -10
  31. package/dist/cli/commands/drift.js.map +1 -1
  32. package/dist/cli/commands/generate.d.ts.map +1 -1
  33. package/dist/cli/commands/generate.js +15 -37
  34. package/dist/cli/commands/generate.js.map +1 -1
  35. package/dist/cli/commands/mcp.d.ts +102 -2
  36. package/dist/cli/commands/mcp.d.ts.map +1 -1
  37. package/dist/cli/commands/mcp.js +134 -2
  38. package/dist/cli/commands/mcp.js.map +1 -1
  39. package/dist/cli/commands/run.d.ts.map +1 -1
  40. package/dist/cli/commands/run.js +9 -47
  41. package/dist/cli/commands/run.js.map +1 -1
  42. package/dist/cli/commands/setup.d.ts +17 -0
  43. package/dist/cli/commands/setup.d.ts.map +1 -0
  44. package/dist/cli/commands/setup.js +201 -0
  45. package/dist/cli/commands/setup.js.map +1 -0
  46. package/dist/cli/commands/verify.d.ts.map +1 -1
  47. package/dist/cli/commands/verify.js +7 -8
  48. package/dist/cli/commands/verify.js.map +1 -1
  49. package/dist/cli/index.js +14 -8
  50. package/dist/cli/index.js.map +1 -1
  51. package/dist/constants.d.ts +14 -0
  52. package/dist/constants.d.ts.map +1 -1
  53. package/dist/constants.js +14 -0
  54. package/dist/constants.js.map +1 -1
  55. package/dist/core/analyzer/ai-config-generator.d.ts +54 -0
  56. package/dist/core/analyzer/ai-config-generator.d.ts.map +1 -0
  57. package/dist/core/analyzer/ai-config-generator.js +85 -0
  58. package/dist/core/analyzer/ai-config-generator.js.map +1 -0
  59. package/dist/core/analyzer/artifact-generator.d.ts +27 -2
  60. package/dist/core/analyzer/artifact-generator.d.ts.map +1 -1
  61. package/dist/core/analyzer/artifact-generator.js +86 -8
  62. package/dist/core/analyzer/artifact-generator.js.map +1 -1
  63. package/dist/core/analyzer/codebase-digest.d.ts.map +1 -1
  64. package/dist/core/analyzer/codebase-digest.js +12 -11
  65. package/dist/core/analyzer/codebase-digest.js.map +1 -1
  66. package/dist/core/analyzer/env-extractor.d.ts +33 -0
  67. package/dist/core/analyzer/env-extractor.d.ts.map +1 -0
  68. package/dist/core/analyzer/env-extractor.js +196 -0
  69. package/dist/core/analyzer/env-extractor.js.map +1 -0
  70. package/dist/core/analyzer/http-route-parser.d.ts +36 -1
  71. package/dist/core/analyzer/http-route-parser.d.ts.map +1 -1
  72. package/dist/core/analyzer/http-route-parser.js +276 -0
  73. package/dist/core/analyzer/http-route-parser.js.map +1 -1
  74. package/dist/core/analyzer/middleware-extractor.d.ts +29 -0
  75. package/dist/core/analyzer/middleware-extractor.d.ts.map +1 -0
  76. package/dist/core/analyzer/middleware-extractor.js +195 -0
  77. package/dist/core/analyzer/middleware-extractor.js.map +1 -0
  78. package/dist/core/analyzer/schema-extractor.d.ts +41 -0
  79. package/dist/core/analyzer/schema-extractor.d.ts.map +1 -0
  80. package/dist/core/analyzer/schema-extractor.js +229 -0
  81. package/dist/core/analyzer/schema-extractor.js.map +1 -0
  82. package/dist/core/analyzer/spec-snapshot-generator.d.ts +17 -0
  83. package/dist/core/analyzer/spec-snapshot-generator.d.ts.map +1 -0
  84. package/dist/core/analyzer/spec-snapshot-generator.js +201 -0
  85. package/dist/core/analyzer/spec-snapshot-generator.js.map +1 -0
  86. package/dist/core/analyzer/ui-component-extractor.d.ts +43 -0
  87. package/dist/core/analyzer/ui-component-extractor.d.ts.map +1 -0
  88. package/dist/core/analyzer/ui-component-extractor.js +245 -0
  89. package/dist/core/analyzer/ui-component-extractor.js.map +1 -0
  90. package/dist/core/generator/openspec-format-generator.d.ts.map +1 -1
  91. package/dist/core/generator/openspec-format-generator.js +8 -0
  92. package/dist/core/generator/openspec-format-generator.js.map +1 -1
  93. package/dist/core/generator/spec-pipeline.d.ts +9 -0
  94. package/dist/core/generator/spec-pipeline.d.ts.map +1 -1
  95. package/dist/core/generator/spec-pipeline.js +94 -2
  96. package/dist/core/generator/spec-pipeline.js.map +1 -1
  97. package/dist/core/generator/stages/stage1-survey.d.ts.map +1 -1
  98. package/dist/core/generator/stages/stage1-survey.js +43 -0
  99. package/dist/core/generator/stages/stage1-survey.js.map +1 -1
  100. package/dist/core/generator/stages/stage2-entities.d.ts.map +1 -1
  101. package/dist/core/generator/stages/stage2-entities.js +6 -2
  102. package/dist/core/generator/stages/stage2-entities.js.map +1 -1
  103. package/dist/core/generator/stages/stage3-services.d.ts.map +1 -1
  104. package/dist/core/generator/stages/stage3-services.js +9 -2
  105. package/dist/core/generator/stages/stage3-services.js.map +1 -1
  106. package/dist/core/generator/stages/stage4-api.d.ts.map +1 -1
  107. package/dist/core/generator/stages/stage4-api.js +6 -2
  108. package/dist/core/generator/stages/stage4-api.js.map +1 -1
  109. package/dist/core/services/llm-service.d.ts +26 -10
  110. package/dist/core/services/llm-service.d.ts.map +1 -1
  111. package/dist/core/services/llm-service.js +171 -16
  112. package/dist/core/services/llm-service.js.map +1 -1
  113. package/dist/core/services/mcp-handlers/analysis.d.ts +32 -1
  114. package/dist/core/services/mcp-handlers/analysis.d.ts.map +1 -1
  115. package/dist/core/services/mcp-handlers/analysis.js +185 -2
  116. package/dist/core/services/mcp-handlers/analysis.js.map +1 -1
  117. package/dist/core/verifier/verification-engine.d.ts +67 -6
  118. package/dist/core/verifier/verification-engine.d.ts.map +1 -1
  119. package/dist/core/verifier/verification-engine.js +316 -90
  120. package/dist/core/verifier/verification-engine.js.map +1 -1
  121. package/dist/types/index.d.ts +70 -1
  122. package/dist/types/index.d.ts.map +1 -1
  123. package/dist/types/pipeline.d.ts +9 -0
  124. package/dist/types/pipeline.d.ts.map +1 -1
  125. package/dist/utils/command-helpers.d.ts +30 -0
  126. package/dist/utils/command-helpers.d.ts.map +1 -1
  127. package/dist/utils/command-helpers.js +69 -1
  128. package/dist/utils/command-helpers.js.map +1 -1
  129. package/examples/bmad/README.md +113 -0
  130. package/examples/bmad/agents/architect.md +226 -0
  131. package/examples/bmad/agents/dev-brownfield.md +69 -0
  132. package/examples/bmad/setup/architect.customize.yaml +14 -0
  133. package/examples/bmad/tasks/implement-story.md +254 -0
  134. package/examples/bmad/tasks/onboarding.md +169 -0
  135. package/examples/bmad/tasks/refactor.md +178 -0
  136. package/examples/bmad/tasks/sprint-planning.md +168 -0
  137. package/examples/bmad/templates/story.md +108 -0
  138. package/examples/cline-workflows/spec-gen-analyze-codebase.md +100 -0
  139. package/examples/cline-workflows/spec-gen-check-spec-drift.md +102 -0
  140. package/examples/cline-workflows/spec-gen-execute-refactor.md +194 -0
  141. package/examples/cline-workflows/spec-gen-implement-feature.md +238 -0
  142. package/examples/cline-workflows/spec-gen-plan-refactor.md +255 -0
  143. package/examples/cline-workflows/spec-gen-refactor-codebase.md +16 -0
  144. package/examples/drift-demo/openspec/config.yaml +14 -0
  145. package/examples/drift-demo/openspec/specs/architecture/spec.md +30 -0
  146. package/examples/drift-demo/openspec/specs/auth/spec.md +71 -0
  147. package/examples/drift-demo/openspec/specs/database/spec.md +33 -0
  148. package/examples/drift-demo/openspec/specs/overview/spec.md +20 -0
  149. package/examples/drift-demo/openspec/specs/projects/spec.md +55 -0
  150. package/examples/drift-demo/openspec/specs/tasks/spec.md +78 -0
  151. package/examples/drift-demo/package.json +21 -0
  152. package/examples/drift-demo/src/auth/auth-middleware.ts +30 -0
  153. package/examples/drift-demo/src/auth/auth-routes.ts +29 -0
  154. package/examples/drift-demo/src/auth/auth-service.ts +45 -0
  155. package/examples/drift-demo/src/database/connection.ts +27 -0
  156. package/examples/drift-demo/src/index.ts +16 -0
  157. package/examples/drift-demo/src/projects/project-model.ts +15 -0
  158. package/examples/drift-demo/src/projects/project-service.ts +34 -0
  159. package/examples/drift-demo/src/tasks/task-model.ts +37 -0
  160. package/examples/drift-demo/src/tasks/task-routes.ts +53 -0
  161. package/examples/drift-demo/src/tasks/task-service.ts +60 -0
  162. package/examples/drift-demo/src/utils/validation.ts +11 -0
  163. package/examples/drift-demo/tests/auth.test.ts +4 -0
  164. package/examples/drift-demo/tests/tasks.test.ts +4 -0
  165. package/examples/drift-demo/tsconfig.json +10 -0
  166. package/examples/drift-test/run-drift-test.sh +1087 -0
  167. package/examples/gsd/README.md +119 -0
  168. package/examples/gsd/commands/gsd/spec-gen-drift.md +111 -0
  169. package/examples/gsd/commands/gsd/spec-gen-orient.md +191 -0
  170. package/examples/mistral-vibe/README.md +101 -0
  171. package/examples/mistral-vibe/antipatterns-template.md +18 -0
  172. package/examples/mistral-vibe/skills/spec-gen-analyze-codebase/SKILL.md +123 -0
  173. package/examples/mistral-vibe/skills/spec-gen-brainstorm/SKILL.md +379 -0
  174. package/examples/mistral-vibe/skills/spec-gen-debug/SKILL.md +320 -0
  175. package/examples/mistral-vibe/skills/spec-gen-execute-refactor/SKILL.md +210 -0
  176. package/examples/mistral-vibe/skills/spec-gen-generate/SKILL.md +245 -0
  177. package/examples/mistral-vibe/skills/spec-gen-implement-story/SKILL.md +274 -0
  178. package/examples/mistral-vibe/skills/spec-gen-plan-refactor/SKILL.md +251 -0
  179. package/examples/openspec-analysis/README.md +59 -0
  180. package/examples/openspec-analysis/SUMMARY.md +72 -0
  181. package/examples/openspec-analysis/config.json +16 -0
  182. package/examples/openspec-analysis/dependencies.mermaid +35 -0
  183. package/examples/openspec-analysis/dependency-graph.json +12116 -0
  184. package/examples/openspec-analysis/llm-context.json +119 -0
  185. package/examples/openspec-analysis/repo-structure.json +871 -0
  186. package/examples/openspec-cli/README.md +67 -0
  187. package/examples/openspec-cli/openspec/config.yaml +26 -0
  188. package/examples/openspec-cli/openspec/specs/architecture/spec.md +178 -0
  189. package/examples/openspec-cli/openspec/specs/artifact-graph/spec.md +143 -0
  190. package/examples/openspec-cli/openspec/specs/cli/spec.md +138 -0
  191. package/examples/openspec-cli/openspec/specs/overview/spec.md +60 -0
  192. package/examples/openspec-cli/openspec/specs/parsing/spec.md +123 -0
  193. package/examples/openspec-cli/openspec/specs/validation/spec.md +108 -0
  194. package/examples/spec-kit/README.md +104 -0
  195. package/examples/spec-kit/commands/drift.md +87 -0
  196. package/examples/spec-kit/commands/orient.md +138 -0
  197. package/examples/spec-kit/extension.yml +54 -0
  198. package/package.json +3 -6
@@ -0,0 +1,67 @@
1
+ # Example: OpenSpec CLI Specifications
2
+
3
+ This example demonstrates spec-gen output by reverse-engineering the OpenSpec CLI tool itself.
4
+
5
+ ## Source Project
6
+
7
+ - **Project**: OpenSpec CLI
8
+ - **Version**: 1.1.0
9
+ - **Repository**: https://github.com/Fission-AI/OpenSpec
10
+ - **Tech Stack**: Node.js, TypeScript, Commander.js, Zod
11
+
12
+ ## Generated Specifications
13
+
14
+ ```
15
+ openspec/
16
+ ├── config.yaml # Project configuration with detected context
17
+ └── specs/
18
+ ├── overview/spec.md # System overview and capabilities
19
+ ├── validation/spec.md # Schema validation and RFC 2119 rules
20
+ ├── parsing/spec.md # Markdown parsing and extraction
21
+ ├── cli/spec.md # Command-line interface
22
+ ├── artifact-graph/spec.md # Dependency resolution
23
+ └── architecture/spec.md # System architecture
24
+ ```
25
+
26
+ ## Domains Identified
27
+
28
+ | Domain | Description | Requirements |
29
+ |--------|-------------|--------------|
30
+ | Overview | System capabilities and initialization | 3 |
31
+ | Validation | Schema validation, RFC 2119 keywords, delta limits | 5 |
32
+ | Parsing | Markdown parsing, requirement extraction, delta blocks | 5 |
33
+ | CLI | Commands, interactive prompts, output formats | 6 |
34
+ | Artifact Graph | Schema resolution, dependency validation, instruction loading | 6 |
35
+ | Architecture | Layer separation, adapter pattern, design decisions | 5 |
36
+
37
+ ## Key Patterns Documented
38
+
39
+ 1. **Zod Schema-First Design** - All data structures defined as Zod schemas
40
+ 2. **Multi-Location Resolution** - Project > User > Package precedence
41
+ 3. **Adapter Pattern** - Support for multiple AI tools
42
+ 4. **Layered Architecture** - CLI → Commands → Core → Utils
43
+
44
+ ## Verification
45
+
46
+ These specs were generated following OpenSpec conventions:
47
+
48
+ - ✅ Requirements use RFC 2119 keywords (SHALL, MUST, SHOULD, MAY)
49
+ - ✅ Scenarios use `####` heading level
50
+ - ✅ Scenarios follow Given/When/Then format
51
+ - ✅ Technical notes link to source files
52
+ - ✅ config.yaml includes detected context
53
+
54
+ ## Usage
55
+
56
+ To validate these specs (requires OpenSpec CLI):
57
+
58
+ ```bash
59
+ cd openspec-cli
60
+ openspec validate --all
61
+ ```
62
+
63
+ To view a specific spec:
64
+
65
+ ```bash
66
+ openspec show specs/validation
67
+ ```
@@ -0,0 +1,26 @@
1
+ schema: spec-driven
2
+
3
+ context: |
4
+ OpenSpec is an AI-native spec-driven development framework.
5
+
6
+ Tech stack: Node.js 20+, TypeScript, Commander.js, Zod, Inquirer
7
+ Architecture: Layered (CLI → Commands → Core → Utils)
8
+
9
+ Key patterns:
10
+ - Zod schemas as single source of truth
11
+ - Multi-location resolution (project > user > package)
12
+ - Adapter pattern for multi-tool AI support
13
+ - Interactive-first with non-TTY fallback
14
+
15
+ # Auto-detected by spec-gen
16
+ spec-gen:
17
+ generatedAt: "2025-01-30T12:00:00Z"
18
+ domains:
19
+ - overview
20
+ - validation
21
+ - parsing
22
+ - cli
23
+ - artifact-graph
24
+ - architecture
25
+ confidence: 0.85
26
+ sourceProject: "OpenSpec CLI v1.1.0"
@@ -0,0 +1,178 @@
1
+ # Architecture Specification
2
+
3
+ > Generated by spec-gen on 2025-01-30
4
+ > Source files: src/core/*, src/commands/*, src/cli/index.ts
5
+
6
+ ## Purpose
7
+
8
+ Documents the architectural patterns and structure of the OpenSpec CLI tool, including its layered design, dependency flow, and key design decisions.
9
+
10
+ ## Architecture Style
11
+
12
+ OpenSpec follows a **layered architecture** with clear separation between CLI, Commands, and Core:
13
+
14
+ ```
15
+ ┌─────────────────────────────────────────────────────────┐
16
+ │ CLI Layer │
17
+ │ (src/cli/index.ts) │
18
+ │ Entry point, Commander.js setup │
19
+ ├─────────────────────────────────────────────────────────┤
20
+ │ Commands Layer │
21
+ │ (src/commands/*.ts) │
22
+ │ Spec, Change, Validate, Schema, Config, Init │
23
+ ├─────────────────────────────────────────────────────────┤
24
+ │ Core Layer │
25
+ │ (src/core/*.ts) │
26
+ │ Validation, Parsing, Artifact Graph, Schemas │
27
+ ├─────────────────────────────────────────────────────────┤
28
+ │ Utils Layer │
29
+ │ (src/utils/*.ts) │
30
+ │ File I/O, Interactive prompts, Formatting │
31
+ └─────────────────────────────────────────────────────────┘
32
+ ```
33
+
34
+ ## Requirements
35
+
36
+ ### Requirement: LayerSeparation
37
+
38
+ The system SHALL maintain separation between CLI, Commands, Core, and Utils layers.
39
+
40
+ #### Scenario: CoreIndependence
41
+ - **GIVEN** a core module like validation
42
+ - **WHEN** its imports are analyzed
43
+ - **THEN** it does not import from commands or CLI layers
44
+
45
+ #### Scenario: CommandsUseCore
46
+ - **GIVEN** a command module like spec.ts
47
+ - **WHEN** it needs validation logic
48
+ - **THEN** it imports from core/validation, not implementing its own
49
+
50
+ ### Requirement: SchemaFirstDesign
51
+
52
+ The system SHALL use Zod schemas as the single source of truth for data structures.
53
+
54
+ #### Scenario: TypeInference
55
+ - **GIVEN** a Zod schema for Spec
56
+ - **WHEN** TypeScript types are needed
57
+ - **THEN** types are inferred from schema using z.infer<>
58
+
59
+ #### Scenario: RuntimeValidation
60
+ - **GIVEN** user input that should match a schema
61
+ - **WHEN** the data is processed
62
+ - **THEN** Zod schema validates at runtime
63
+
64
+ ### Requirement: AdapterPattern
65
+
66
+ The system SHALL use adapters to support multiple AI tools with a single codebase.
67
+
68
+ #### Scenario: CommandGeneration
69
+ - **GIVEN** a skill definition for "new change"
70
+ - **WHEN** commands are generated for different tools
71
+ - **THEN** each tool's adapter produces tool-specific format
72
+
73
+ #### Scenario: AddingNewTool
74
+ - **GIVEN** a new AI tool needs support
75
+ - **WHEN** a developer creates an adapter
76
+ - **THEN** all existing skills work with the new tool
77
+
78
+ ### Requirement: MultiLocationResolution
79
+
80
+ The system SHALL support configuration and schemas from multiple locations with clear precedence.
81
+
82
+ #### Scenario: ProjectOverridesUser
83
+ - **GIVEN** config exists in both project and user locations
84
+ - **WHEN** configuration is loaded
85
+ - **THEN** project config takes precedence
86
+
87
+ #### Scenario: PackageFallback
88
+ - **GIVEN** a schema only exists in the package
89
+ - **WHEN** the schema is requested
90
+ - **THEN** the package schema is used as fallback
91
+
92
+ ### Requirement: InteractiveByDefault
93
+
94
+ The system SHALL default to interactive mode with graceful fallback for non-TTY environments.
95
+
96
+ #### Scenario: TTYPrompts
97
+ - **GIVEN** a command missing required arguments
98
+ - **WHEN** running in a TTY terminal
99
+ - **THEN** interactive prompts are shown
100
+
101
+ #### Scenario: NonTTYErrors
102
+ - **GIVEN** a command missing required arguments
103
+ - **WHEN** running in a non-TTY environment (CI/CD)
104
+ - **THEN** clear error messages are returned instead of prompts
105
+
106
+ ### Requirement: ProgressiveDisclosure
107
+
108
+ The system SHOULD present information progressively, showing summaries first with detail on demand.
109
+
110
+ #### Scenario: ValidationSummary
111
+ - **GIVEN** validation of 10 specs
112
+ - **WHEN** validation completes
113
+ - **THEN** a summary (8 passed, 2 failed) is shown first
114
+ - **AND** details are available with --verbose flag
115
+
116
+ ## Layers
117
+
118
+ ### CLI Layer
119
+
120
+ **Purpose**: Entry point and Commander.js program setup
121
+ **Location**: `src/cli/index.ts`
122
+ **Responsibilities**:
123
+ - Parse command-line arguments
124
+ - Route to appropriate command handlers
125
+ - Handle global options (--version, --help)
126
+
127
+ ### Commands Layer
128
+
129
+ **Purpose**: Individual command implementations
130
+ **Location**: `src/commands/*.ts`
131
+ **Key Files**:
132
+ - `spec.ts` - Spec viewing and listing
133
+ - `change.ts` - Change management
134
+ - `validate.ts` - Validation operations
135
+ - `schema.ts` - Schema inspection
136
+ - `config.ts` - Configuration management
137
+ - `init.ts` - Project initialization
138
+
139
+ ### Core Layer
140
+
141
+ **Purpose**: Business logic independent of CLI
142
+ **Location**: `src/core/*.ts`
143
+ **Key Modules**:
144
+ - `validation/` - Schema and rule validation
145
+ - `parsers/` - Markdown parsing
146
+ - `artifact-graph/` - Dependency resolution
147
+ - `schemas/` - Zod schema definitions
148
+
149
+ ### Utils Layer
150
+
151
+ **Purpose**: Shared utilities
152
+ **Location**: `src/utils/*.ts`
153
+ **Key Files**:
154
+ - `file-system.ts` - File operations
155
+ - `interactive.ts` - Prompt utilities
156
+ - `formatting.ts` - Output formatting
157
+
158
+ ## Data Flow
159
+
160
+ 1. **User Input** → CLI parses arguments
161
+ 2. **Command Handler** → Validates options, prompts if needed
162
+ 3. **Core Logic** → Processes request using schemas and parsers
163
+ 4. **Output** → Formats and displays results
164
+
165
+ ## External Integrations
166
+
167
+ | System | Purpose | Location |
168
+ |--------|---------|----------|
169
+ | PostHog | Optional telemetry | `src/telemetry/` |
170
+ | YAML Parser | Schema/config files | Throughout |
171
+ | Inquirer | Interactive prompts | `src/utils/interactive.ts` |
172
+
173
+ ## Technical Notes
174
+
175
+ - **Pattern**: Layered Architecture with Dependency Injection
176
+ - **Build**: esbuild for fast compilation
177
+ - **Testing**: Vitest with fixtures
178
+ - **Distribution**: npm package with bin entry
@@ -0,0 +1,143 @@
1
+ # Artifact Graph Specification
2
+
3
+ > Generated by spec-gen on 2025-01-30
4
+ > Source files: src/core/artifact-graph/types.ts, src/core/artifact-graph/schema.ts, src/core/artifact-graph/resolver.ts, src/core/artifact-graph/graph.ts
5
+
6
+ ## Purpose
7
+
8
+ Manages artifact dependencies and workflow ordering for spec-driven development. Provides schema resolution from multiple locations, dependency graph validation, and instruction loading with context injection.
9
+
10
+ ## Entities
11
+
12
+ ### Artifact
13
+
14
+ | Property | Type | Description |
15
+ |----------|------|-------------|
16
+ | id | string | Unique artifact identifier |
17
+ | generates | string | Output file/directory pattern |
18
+ | template | string | Template name for generation |
19
+ | instruction | string | AI instruction content |
20
+ | requires | string[] | IDs of dependent artifacts |
21
+
22
+ ### SchemaYaml
23
+
24
+ | Property | Type | Description |
25
+ |----------|------|-------------|
26
+ | name | string | Schema name |
27
+ | version | number | Schema version |
28
+ | artifacts | Artifact[] | Ordered artifact definitions |
29
+
30
+ ### ResolvedSchema
31
+
32
+ | Property | Type | Description |
33
+ |----------|------|-------------|
34
+ | schema | SchemaYaml | Parsed schema content |
35
+ | source | 'project' \| 'user' \| 'package' | Resolution location |
36
+ | path | string | File system path |
37
+
38
+ ## Requirements
39
+
40
+ ### Requirement: SchemaResolution
41
+
42
+ The system SHALL resolve schemas from multiple locations with defined precedence: project > user > package.
43
+
44
+ #### Scenario: ProjectSchemaOverride
45
+ - **GIVEN** a schema "custom" exists in both project and package locations
46
+ - **WHEN** schema resolution is performed
47
+ - **THEN** the project schema is returned
48
+ - **AND** the source is marked as "project"
49
+
50
+ #### Scenario: FallbackToPackage
51
+ - **GIVEN** a schema "spec-driven" only exists in package location
52
+ - **WHEN** schema resolution is performed
53
+ - **THEN** the package schema is returned
54
+ - **AND** the source is marked as "package"
55
+
56
+ #### Scenario: SchemaNotFound
57
+ - **GIVEN** a requested schema "nonexistent" is not in any location
58
+ - **WHEN** schema resolution is attempted
59
+ - **THEN** an error is returned indicating schema not found
60
+
61
+ ### Requirement: DependencyValidation
62
+
63
+ The system SHALL validate artifact dependency graphs for cycles and missing dependencies.
64
+
65
+ #### Scenario: ValidDAG
66
+ - **GIVEN** artifacts A → B → C with no cycles
67
+ - **WHEN** graph validation is performed
68
+ - **THEN** validation passes
69
+ - **AND** topological order is [A, B, C]
70
+
71
+ #### Scenario: CycleDetection
72
+ - **GIVEN** artifacts A → B → C → A forming a cycle
73
+ - **WHEN** graph validation is performed
74
+ - **THEN** validation fails with "CYCLE_DETECTED" error
75
+ - **AND** the cycle path is reported
76
+
77
+ #### Scenario: MissingDependency
78
+ - **GIVEN** artifact A requires artifact "missing" which doesn't exist
79
+ - **WHEN** graph validation is performed
80
+ - **THEN** validation fails with "MISSING_DEPENDENCY" error
81
+
82
+ ### Requirement: TopologicalOrdering
83
+
84
+ The system SHALL provide topologically sorted artifact order for workflow execution.
85
+
86
+ #### Scenario: LinearDependencies
87
+ - **GIVEN** artifacts: proposal → specs → design → tasks
88
+ - **WHEN** topological sort is computed
89
+ - **THEN** order is [proposal, specs, design, tasks]
90
+
91
+ #### Scenario: ParallelArtifacts
92
+ - **GIVEN** specs and design both only require proposal
93
+ - **WHEN** topological sort is computed
94
+ - **THEN** proposal comes first
95
+ - **AND** specs and design can be in either order after proposal
96
+
97
+ ### Requirement: InstructionLoading
98
+
99
+ The system SHALL load artifact instructions with context injection and dependency content.
100
+
101
+ #### Scenario: ContextInjection
102
+ - **GIVEN** project config with context field "This is an API project"
103
+ - **WHEN** instructions are loaded for an artifact
104
+ - **THEN** the context is injected into the instruction template
105
+
106
+ #### Scenario: DependencyContentInclusion
107
+ - **GIVEN** artifact "design" requires artifact "specs"
108
+ - **WHEN** instructions are loaded for "design"
109
+ - **THEN** the content of completed "specs" artifact is included
110
+
111
+ #### Scenario: RulesApplication
112
+ - **GIVEN** config.yaml has rules for "specs" artifact
113
+ - **WHEN** instructions are loaded for "specs"
114
+ - **THEN** the artifact-specific rules are appended
115
+
116
+ ### Requirement: ArtifactStateTracking
117
+
118
+ The system SHALL track which artifacts have been completed for a change.
119
+
120
+ #### Scenario: CheckArtifactCompletion
121
+ - **GIVEN** a change with "proposal.md" file present
122
+ - **WHEN** artifact state is checked
123
+ - **THEN** "proposal" artifact is marked as complete
124
+
125
+ #### Scenario: IdentifyNextArtifact
126
+ - **GIVEN** "proposal" is complete but "specs" is not
127
+ - **WHEN** next artifact is requested
128
+ - **THEN** "specs" is returned as the next artifact to work on
129
+
130
+ ### Requirement: SchemaVersioning
131
+
132
+ The system SHOULD support schema versioning for backwards compatibility.
133
+
134
+ #### Scenario: VersionMismatchWarning
135
+ - **GIVEN** a project using schema version 1
136
+ - **WHEN** package provides schema version 2
137
+ - **THEN** a warning is issued about version mismatch
138
+
139
+ ## Technical Notes
140
+
141
+ - **Implementation**: `src/core/artifact-graph/schema.ts`, `src/core/artifact-graph/resolver.ts`, `src/core/artifact-graph/graph.ts`
142
+ - **Pattern**: Multi-location resolution with caching
143
+ - **Dependencies**: YAML parser for schema files
@@ -0,0 +1,138 @@
1
+ # CLI Specification
2
+
3
+ > Generated by spec-gen on 2025-01-30
4
+ > Source files: src/commands/spec.ts, src/commands/change.ts, src/commands/validate.ts, src/commands/schema.ts
5
+
6
+ ## Purpose
7
+
8
+ Provides command-line interface for managing OpenSpec projects, including spec viewing, change management, validation, and schema inspection. Supports both interactive and non-interactive modes with multiple output formats.
9
+
10
+ ## Entities
11
+
12
+ ### CommandOptions
13
+
14
+ | Property | Type | Description |
15
+ |----------|------|-------------|
16
+ | json | boolean | Output as JSON instead of formatted text |
17
+ | noInteractive | boolean | Disable interactive prompts |
18
+ | verbose | boolean | Enable detailed output |
19
+ | all | boolean | Apply to all items |
20
+
21
+ ### OutputFormat
22
+
23
+ | Value | Description |
24
+ |-------|-------------|
25
+ | text | Human-readable formatted markdown |
26
+ | json | Machine-readable JSON structure |
27
+
28
+ ## Requirements
29
+
30
+ ### Requirement: SpecViewing
31
+
32
+ The system SHALL display spec content in human-readable or JSON format.
33
+
34
+ #### Scenario: ViewSpecAsMarkdown
35
+ - **GIVEN** a valid spec file at `openspec/specs/user/spec.md`
36
+ - **WHEN** the user runs `openspec show specs/user`
37
+ - **THEN** the spec content is displayed with formatted markdown
38
+
39
+ #### Scenario: ViewSpecAsJSON
40
+ - **GIVEN** a valid spec file
41
+ - **WHEN** the user runs `openspec show specs/user --json`
42
+ - **THEN** the spec is output as a JSON object
43
+ - **AND** the JSON includes parsed requirements and scenarios
44
+
45
+ ### Requirement: SpecListing
46
+
47
+ The system SHALL list all specs in the project with summary information.
48
+
49
+ #### Scenario: ListAllSpecs
50
+ - **GIVEN** a project with 5 spec files
51
+ - **WHEN** the user runs `openspec list --specs`
52
+ - **THEN** all 5 specs are listed with names and paths
53
+
54
+ ### Requirement: ChangeManagement
55
+
56
+ The system SHALL support creating, listing, and viewing changes.
57
+
58
+ #### Scenario: CreateNewChange
59
+ - **GIVEN** an initialized OpenSpec project
60
+ - **WHEN** the user runs `openspec change my-feature`
61
+ - **THEN** a directory `openspec/changes/my-feature/` is created
62
+ - **AND** template files (proposal.md, etc.) are generated
63
+
64
+ #### Scenario: ListActiveChanges
65
+ - **GIVEN** a project with 3 active changes
66
+ - **WHEN** the user runs `openspec list --changes`
67
+ - **THEN** all 3 changes are listed with status information
68
+
69
+ ### Requirement: BulkValidation
70
+
71
+ The system SHALL validate multiple specs/changes concurrently with configurable parallelism.
72
+
73
+ #### Scenario: ValidateAllSpecs
74
+ - **GIVEN** a project with 10 spec files
75
+ - **WHEN** the user runs `openspec validate --all`
76
+ - **THEN** all specs are validated
77
+ - **AND** a summary report shows pass/fail counts
78
+
79
+ #### Scenario: ValidationWithConcurrency
80
+ - **GIVEN** 20 spec files to validate
81
+ - **WHEN** validation runs with default concurrency
82
+ - **THEN** multiple files are validated in parallel
83
+ - **AND** total validation time is reduced
84
+
85
+ ### Requirement: InteractivePrompts
86
+
87
+ The system SHALL prompt for missing required arguments when in interactive mode.
88
+
89
+ #### Scenario: MissingSpecIdPrompt
90
+ - **GIVEN** the user runs `openspec show` without specifying a spec
91
+ - **WHEN** interactive mode is enabled (default)
92
+ - **THEN** a prompt lists available specs for selection
93
+
94
+ #### Scenario: NonInteractiveFailure
95
+ - **GIVEN** the user runs `openspec show --no-interactive` without a spec
96
+ - **WHEN** the command executes
97
+ - **THEN** an error is returned indicating missing required argument
98
+
99
+ ### Requirement: SchemaInspection
100
+
101
+ The system SHALL allow inspection of workflow schemas including artifact dependencies.
102
+
103
+ #### Scenario: ListSchemas
104
+ - **GIVEN** schemas in project, user, and package locations
105
+ - **WHEN** the user runs `openspec schema list`
106
+ - **THEN** all available schemas are listed with source location
107
+
108
+ #### Scenario: ShowSchemaDetails
109
+ - **GIVEN** a schema named "spec-driven"
110
+ - **WHEN** the user runs `openspec schema show spec-driven`
111
+ - **THEN** the schema artifacts and dependencies are displayed
112
+
113
+ #### Scenario: ValidateSchemaGraph
114
+ - **GIVEN** a schema with artifact dependencies
115
+ - **WHEN** the user runs `openspec schema validate spec-driven`
116
+ - **THEN** cycle detection is performed
117
+ - **AND** dependency graph is validated
118
+
119
+ ### Requirement: OutputFormatting
120
+
121
+ The system SHALL support multiple output formats for different use cases.
122
+
123
+ #### Scenario: ColoredTerminalOutput
124
+ - **GIVEN** a TTY terminal environment
125
+ - **WHEN** commands produce output
126
+ - **THEN** colors and formatting enhance readability
127
+
128
+ #### Scenario: PlainTextForPipes
129
+ - **GIVEN** output is piped to another command
130
+ - **WHEN** commands produce output
131
+ - **THEN** ANSI codes are stripped
132
+ - **AND** plain text is output
133
+
134
+ ## Technical Notes
135
+
136
+ - **Implementation**: `src/commands/spec.ts`, `src/commands/change.ts`, `src/commands/validate.ts`
137
+ - **Framework**: Commander.js for command parsing, Inquirer for prompts
138
+ - **Dependencies**: validation, parsing
@@ -0,0 +1,60 @@
1
+ # System Overview
2
+
3
+ > Generated by spec-gen on 2025-01-30
4
+ > Source files: package.json, src/cli/index.ts, src/core/init.ts
5
+
6
+ ## Purpose
7
+
8
+ OpenSpec is an AI-native spec-driven development framework that helps teams define, validate, and evolve software specifications. It provides CLI tools for managing specs and changes, multi-tool AI integration, and artifact-guided workflows.
9
+
10
+ ## Domains
11
+
12
+ | Domain | Description | Spec |
13
+ |--------|-------------|------|
14
+ | validation | Schema validation and rule enforcement | [spec.md](../validation/spec.md) |
15
+ | parsing | Markdown parsing and content extraction | [spec.md](../parsing/spec.md) |
16
+ | cli | Command-line interface and user interaction | [spec.md](../cli/spec.md) |
17
+ | artifact-graph | Dependency resolution and workflow ordering | [spec.md](../artifact-graph/spec.md) |
18
+
19
+ ## Requirements
20
+
21
+ ### Requirement: ProjectInitialization
22
+
23
+ The system SHALL initialize OpenSpec projects with proper directory structure and configuration files.
24
+
25
+ #### Scenario: NewProjectSetup
26
+ - **GIVEN** a directory without OpenSpec configuration
27
+ - **WHEN** the user runs `openspec init`
28
+ - **THEN** the system creates `openspec/` directory structure
29
+ - **AND** generates `openspec/config.yaml` with default settings
30
+
31
+ ### Requirement: MultiToolSupport
32
+
33
+ The system SHALL support multiple AI tools through an adapter-based command generation system.
34
+
35
+ #### Scenario: ClaudeCodeSkillGeneration
36
+ - **GIVEN** a user selects Claude Code during initialization
37
+ - **WHEN** the init process completes
38
+ - **THEN** skill files are generated in `.claude/skills/`
39
+ - **AND** the skills follow Claude Code's expected format
40
+
41
+ #### Scenario: CursorCommandGeneration
42
+ - **GIVEN** a user selects Cursor during initialization
43
+ - **WHEN** the init process completes
44
+ - **THEN** command files are generated in `.cursor/commands/`
45
+
46
+ ### Requirement: SpecDrivenWorkflow
47
+
48
+ The system SHALL enforce a spec-driven development workflow where specifications precede implementation.
49
+
50
+ #### Scenario: ChangeProposalFlow
51
+ - **GIVEN** a developer wants to make a change
52
+ - **WHEN** they run `openspec change my-feature`
53
+ - **THEN** a change directory is created with proposal template
54
+ - **AND** the workflow guides them through spec → design → tasks
55
+
56
+ ## Technical Notes
57
+
58
+ - **Implementation**: `src/cli/index.ts`, `src/core/init.ts`
59
+ - **Framework**: Commander.js for CLI, Inquirer for prompts
60
+ - **Dependencies**: validation, parsing, artifact-graph