speclore 0.1.2 → 0.1.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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 SpecLore Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SpecLore Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md CHANGED
@@ -1,240 +1,240 @@
1
- # SpecLore
2
-
3
- **中文** | [English](README.en.md)
4
-
5
- [![npm](https://img.shields.io/npm/v/speclore.svg)](https://www.npmjs.com/package/speclore)
6
- [![CI](https://github.com/cheneyzhang93/speclore/actions/workflows/ci.yml/badge.svg)](https://github.com/cheneyzhang93/speclore/actions/workflows/ci.yml)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
8
-
9
- **Product-engineering collaboration for the AI coding era — turn requirements into verifiable BDD specs, and verification into an automated pipeline.**
10
-
11
- SpecLore transforms scattered requirements (docs, chats, verbal specs) into structured BDD `.feature` acceptance criteria, generates coding constraints for AI tools like Cursor / Claude Code / Qoder, then runs tests and produces acceptance reports. Seamless collaboration with AI clients via MCP protocol.
12
-
13
- ```
14
- Requirements (any format) → BDD .feature → AI constraints + test scaffolding → acceptance report
15
- ```
16
-
17
- ---
18
-
19
- ## Install
20
-
21
- ```bash
22
- npm install -g speclore
23
- ```
24
-
25
- ## Quick Start
26
-
27
- Three steps from zero to acceptance:
28
-
29
- ```bash
30
- # 1. Initialize project (auto-detect AI tools, generate config)
31
- cd your-project && speclore setup
32
-
33
- # 2. Generate .feature acceptance criteria from requirements
34
- speclore spec "Patient registration requires phone verification, support WeChat login"
35
-
36
- # 3. Generate AI coding constraints + test scaffolding
37
- speclore code
38
- ```
39
-
40
- Then code in your AI client, and run acceptance when done:
41
-
42
- ```bash
43
- speclore verify
44
- ```
45
-
46
- That's it. You can also complete the entire workflow using natural language in your AI client (Cursor / Qoder / Claude Code) — `setup` already configured MCP automatically.
47
-
48
- ---
49
-
50
- ## Workflow
51
-
52
- ```
53
- speclore.status → speclore.spec → speclore.code → (AI codes) → speclore.verify
54
- check status generate feature constraints+scaffold implement verify tests
55
- ↓ ↓ ↓ ↓ ↓
56
- project state → specified → constrained → coding → verified
57
- ```
58
-
59
- Each tool returns current state and next-step guidance. Out-of-order calls produce clear errors:
60
-
61
- | Out-of-order scenario | Error message |
62
- |----------------------|---------------|
63
- | Call `code` without .feature files | `No .feature files found. Run speclore.spec first.` |
64
- | Call `verify` without test scaffolding | `No test scaffolding. Run speclore.code first.` |
65
- | Project not initialized | Auto-creates `.speclore/config.yaml` |
66
-
67
- ---
68
-
69
- ## Example
70
-
71
- A complete conversation in an AI client for "patient registration":
72
-
73
- **You**: Help me implement patient registration with phone verification
74
-
75
- **AI** (calls `speclore.spec`): Generated `specs/patient/register.feature` with 3 acceptance scenarios:
76
- - Successful phone registration
77
- - Reject invalid phone format
78
- - Conflict on duplicate phone number
79
-
80
- **AI** (calls `speclore.code`): Generated coding constraints and test scaffolding:
81
- - `.qoder/rules/speclore.md` — coding constraints (with business rules)
82
- - `tests/patient/register.test.ts` — test scaffolding (3 `it.skip` placeholders)
83
-
84
- **You**: OK, I'll implement the code and tests
85
-
86
- *(AI reads constraint rules while coding; you fill in the `it.skip` test scaffolding)*
87
-
88
- **You**: Run acceptance
89
-
90
- **AI** (calls `speclore.verify`): ✅ 3/3 scenarios passed (100%)
91
-
92
- ---
93
-
94
- ## Supported Input Formats
95
-
96
- Markdown · Word · Excel · PDF · Image (OCR) · URL · Plain text
97
-
98
- ```bash
99
- speclore spec requirements.md # Markdown
100
- speclore spec design.docx # Word
101
- speclore spec specs.xlsx # Excel
102
- speclore spec mockup.png # Image
103
- speclore spec https://jira.example/123 # URL
104
- speclore spec "Users need password reset" # Plain text
105
- ```
106
-
107
- ## Command Reference
108
-
109
- | Command | Purpose |
110
- |---------|---------|
111
- | `speclore` | Show project status |
112
- | `speclore setup` | Initialize project (detect AI tools → write MCP config → generate rules) |
113
- | `speclore spec <source>` | Requirement source → `.feature` acceptance criteria |
114
- | `speclore code` | `.feature` → AI coding constraints + test scaffolding |
115
- | `speclore verify` | Run tests → acceptance report (mapped to .feature scenarios) |
116
- | `speclore verify --watch` | Watch mode, auto-rerun on file changes |
117
- | `speclore status` | View project state, workflow progress, recommended actions |
118
- | `speclore migrate` | Migrate existing .feature files to workflow state after upgrade |
119
- | `speclore init` | Scan project structure, generate context file |
120
- | `speclore teardown` | Uninstall cleanup |
121
-
122
- ## MCP Tools
123
-
124
- SpecLore provides 4 MCP tools, called by AI clients via MCP protocol:
125
-
126
- | Tool | Purpose | State change |
127
- |------|---------|-------------|
128
- | `speclore.status` | Project status + recommended actions | — |
129
- | `speclore.spec` | Requirements → .feature | → `specified` |
130
- | `speclore.code` | .feature → constraints + test scaffolding | → `constrained` |
131
- | `speclore.verify` | Tests → acceptance report | → `verified` |
132
-
133
- Every tool response includes a `workflow` field (`currentState` + `nextStep`) to guide AI through the correct sequence.
134
-
135
- ## Supported AI Clients
136
-
137
- | Client | Config file | Constraint rules file |
138
- |--------|------------|----------------------|
139
- | Cursor | `.cursor/mcp.json` | `.cursor/rules/speclore.mdc` |
140
- | Claude Code | `.mcp.json` | `.claude/rules/speclore.md` |
141
- | Qoder | `.qoder/mcp.json` | `.qoder/rules/speclore.md` |
142
-
143
- `speclore setup` auto-detects and configures.
144
-
145
- ---
146
-
147
- ## Configuration
148
-
149
- Core config in `.speclore/config.yaml` (generated by `setup`):
150
-
151
- ```yaml
152
- verify:
153
- command: "pnpm test" # Your test command
154
- mapping:
155
- patterns:
156
- - feature: "specs/{module}/{name}.feature"
157
- test: "tests/{module}/{name}.test.*"
158
- ```
159
-
160
- <details>
161
- <summary>Full config reference</summary>
162
-
163
- ```yaml
164
- project:
165
- name: my-project
166
- profile: normal # strict | normal | minimal
167
- modules:
168
- order:
169
- path: src/order
170
- responsibility: Order management
171
- dependsOn: [inventory, payment]
172
-
173
- ai:
174
- provider: openai-compatible # openai-compatible | claude | ollama
175
- baseUrl: https://api.openai.com/v1
176
- model: gpt-4
177
- apiKeyEnv: OPENAI_API_KEY
178
-
179
- spec:
180
- outputDir: specs
181
- defaultLanguage: en
182
- confidenceThreshold: 0.6
183
-
184
- verify:
185
- command: npm test
186
- timeout: 300
187
- reportFormat: [json, html]
188
- mapping:
189
- patterns:
190
- - feature: "specs/{module}/{name}.feature"
191
- test: "tests/{module}/{name}.test.*"
192
- ```
193
-
194
- </details>
195
-
196
- ---
197
-
198
- ## Architecture
199
-
200
- ```
201
- ┌──────────────────────────────────────────────────────┐
202
- │ CLI / MCP Server │
203
- ├──────────┬──────────┬──────────┬──────────┬──────────┤
204
- │ Ingest │ Feature │Constraint│ Verify │ Context │
205
- │ (M1) │ Gen (M2) │ (M3) │ (M4) │ Eng (M5) │
206
- ├──────────┴──────────┴──────────┴──────────┴──────────┤
207
- │ State Manager · Test Scaffolder · Impact Analysis │
208
- ├──────────────────────────────────────────────────────┤
209
- │ AI Provider (OpenAI / Claude / Ollama) │
210
- ├──────────────────────────────────────────────────────┤
211
- │ Plugin System (Reader / Writer / Parser) │
212
- └──────────────────────────────────────────────────────┘
213
- ```
214
-
215
- ---
216
-
217
- ## Documentation
218
-
219
- | Doc | Description |
220
- |-----|-------------|
221
- | [Configuration](docs/configuration.md) | Full `config.yaml` reference, Profile modes, all CLI commands |
222
- | [MCP Tools](docs/mcp-reference.md) | Complete I/O for 4 MCP tools, workflow guards, auto-init & migration |
223
- | [Test Mapping](docs/test-mapping.md) | Three ways to map test results back to .feature scenarios |
224
- | [Plugin Development](docs/plugin-guide.md) | Build and publish Reader / Writer / Parser plugins |
225
- | [Product Spec](docs/product-spec.md) | Full product technical specification |
226
-
227
- ---
228
-
229
- ## Development
230
-
231
- ```bash
232
- git clone https://github.com/cheneyzhang93/speclore.git
233
- cd speclore && pnpm install && pnpm build
234
- pnpm test # 333 tests
235
- pnpm dev # watch mode
236
- ```
237
-
238
- ## License
239
-
240
- MIT
1
+ # SpecLore
2
+
3
+ **中文** | [English](README.en.md)
4
+
5
+ [![npm](https://img.shields.io/npm/v/speclore.svg)](https://www.npmjs.com/package/speclore)
6
+ [![CI](https://github.com/cheneyzhang93/speclore/actions/workflows/ci.yml/badge.svg)](https://github.com/cheneyzhang93/speclore/actions/workflows/ci.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ **Product-engineering collaboration for the AI coding era — turn requirements into verifiable BDD specs, and verification into an automated pipeline.**
10
+
11
+ SpecLore transforms scattered requirements (docs, chats, verbal specs) into structured BDD `.feature` acceptance criteria, generates coding constraints for AI tools like Cursor / Claude Code / Qoder, then runs tests and produces acceptance reports. Seamless collaboration with AI clients via MCP protocol.
12
+
13
+ ```
14
+ Requirements (any format) → BDD .feature → AI constraints + test scaffolding → acceptance report
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install -g speclore
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ Three steps from zero to acceptance:
28
+
29
+ ```bash
30
+ # 1. Initialize project (auto-detect AI tools, generate config)
31
+ cd your-project && speclore setup
32
+
33
+ # 2. Generate .feature acceptance criteria from requirements
34
+ speclore spec "Patient registration requires phone verification, support WeChat login"
35
+
36
+ # 3. Generate AI coding constraints + test scaffolding
37
+ speclore code
38
+ ```
39
+
40
+ Then code in your AI client, and run acceptance when done:
41
+
42
+ ```bash
43
+ speclore verify
44
+ ```
45
+
46
+ That's it. You can also complete the entire workflow using natural language in your AI client (Cursor / Qoder / Claude Code) — `setup` already configured MCP automatically.
47
+
48
+ ---
49
+
50
+ ## Workflow
51
+
52
+ ```
53
+ speclore.status → speclore.spec → speclore.code → (AI codes) → speclore.verify
54
+ check status generate feature constraints+scaffold implement verify tests
55
+ ↓ ↓ ↓ ↓ ↓
56
+ project state → specified → constrained → coding → verified
57
+ ```
58
+
59
+ Each tool returns current state and next-step guidance. Out-of-order calls produce clear errors:
60
+
61
+ | Out-of-order scenario | Error message |
62
+ |----------------------|---------------|
63
+ | Call `code` without .feature files | `No .feature files found. Run speclore.spec first.` |
64
+ | Call `verify` without test scaffolding | `No test scaffolding. Run speclore.code first.` |
65
+ | Project not initialized | Auto-creates `.speclore/config.yaml` |
66
+
67
+ ---
68
+
69
+ ## Example
70
+
71
+ A complete conversation in an AI client for "patient registration":
72
+
73
+ **You**: Help me implement patient registration with phone verification
74
+
75
+ **AI** (calls `speclore.spec`): Generated `specs/patient/register.feature` with 3 acceptance scenarios:
76
+ - Successful phone registration
77
+ - Reject invalid phone format
78
+ - Conflict on duplicate phone number
79
+
80
+ **AI** (calls `speclore.code`): Generated coding constraints and test scaffolding:
81
+ - `.qoder/rules/speclore.md` — coding constraints (with business rules)
82
+ - `tests/patient/register.test.ts` — test scaffolding (3 `it.skip` placeholders)
83
+
84
+ **You**: OK, I'll implement the code and tests
85
+
86
+ *(AI reads constraint rules while coding; you fill in the `it.skip` test scaffolding)*
87
+
88
+ **You**: Run acceptance
89
+
90
+ **AI** (calls `speclore.verify`): ✅ 3/3 scenarios passed (100%)
91
+
92
+ ---
93
+
94
+ ## Supported Input Formats
95
+
96
+ Markdown · Word · Excel · PDF · Image (OCR) · URL · Plain text
97
+
98
+ ```bash
99
+ speclore spec requirements.md # Markdown
100
+ speclore spec design.docx # Word
101
+ speclore spec specs.xlsx # Excel
102
+ speclore spec mockup.png # Image
103
+ speclore spec https://jira.example/123 # URL
104
+ speclore spec "Users need password reset" # Plain text
105
+ ```
106
+
107
+ ## Command Reference
108
+
109
+ | Command | Purpose |
110
+ |---------|---------|
111
+ | `speclore` | Show project status |
112
+ | `speclore setup` | Initialize project (detect AI tools → write MCP config → generate rules) |
113
+ | `speclore spec <source>` | Requirement source → `.feature` acceptance criteria |
114
+ | `speclore code` | `.feature` → AI coding constraints + test scaffolding |
115
+ | `speclore verify` | Run tests → acceptance report (mapped to .feature scenarios) |
116
+ | `speclore verify --watch` | Watch mode, auto-rerun on file changes |
117
+ | `speclore status` | View project state, workflow progress, recommended actions |
118
+ | `speclore migrate` | Migrate existing .feature files to workflow state after upgrade |
119
+ | `speclore init` | Scan project structure, generate context file |
120
+ | `speclore teardown` | Uninstall cleanup |
121
+
122
+ ## MCP Tools
123
+
124
+ SpecLore provides 4 MCP tools, called by AI clients via MCP protocol:
125
+
126
+ | Tool | Purpose | State change |
127
+ |------|---------|-------------|
128
+ | `speclore.status` | Project status + recommended actions | — |
129
+ | `speclore.spec` | Requirements → .feature | → `specified` |
130
+ | `speclore.code` | .feature → constraints + test scaffolding | → `constrained` |
131
+ | `speclore.verify` | Tests → acceptance report | → `verified` |
132
+
133
+ Every tool response includes a `workflow` field (`currentState` + `nextStep`) to guide AI through the correct sequence.
134
+
135
+ ## Supported AI Clients
136
+
137
+ | Client | Config file | Constraint rules file |
138
+ |--------|------------|----------------------|
139
+ | Cursor | `.cursor/mcp.json` | `.cursor/rules/speclore.mdc` |
140
+ | Claude Code | `.mcp.json` | `.claude/rules/speclore.md` |
141
+ | Qoder | `.qoder/mcp.json` | `.qoder/rules/speclore.md` |
142
+
143
+ `speclore setup` auto-detects and configures.
144
+
145
+ ---
146
+
147
+ ## Configuration
148
+
149
+ Core config in `.speclore/config.yaml` (generated by `setup`):
150
+
151
+ ```yaml
152
+ verify:
153
+ command: "pnpm test" # Your test command
154
+ mapping:
155
+ patterns:
156
+ - feature: "specs/{module}/{name}.feature"
157
+ test: "tests/{module}/{name}.test.*"
158
+ ```
159
+
160
+ <details>
161
+ <summary>Full config reference</summary>
162
+
163
+ ```yaml
164
+ project:
165
+ name: my-project
166
+ profile: normal # strict | normal | minimal
167
+ modules:
168
+ order:
169
+ path: src/order
170
+ responsibility: Order management
171
+ dependsOn: [inventory, payment]
172
+
173
+ ai:
174
+ provider: openai-compatible # openai-compatible | claude | ollama
175
+ baseUrl: https://api.openai.com/v1
176
+ model: gpt-4
177
+ apiKeyEnv: OPENAI_API_KEY
178
+
179
+ spec:
180
+ outputDir: specs
181
+ defaultLanguage: en
182
+ confidenceThreshold: 0.6
183
+
184
+ verify:
185
+ command: npm test
186
+ timeout: 300
187
+ reportFormat: [json, html]
188
+ mapping:
189
+ patterns:
190
+ - feature: "specs/{module}/{name}.feature"
191
+ test: "tests/{module}/{name}.test.*"
192
+ ```
193
+
194
+ </details>
195
+
196
+ ---
197
+
198
+ ## Architecture
199
+
200
+ ```
201
+ ┌──────────────────────────────────────────────────────┐
202
+ │ CLI / MCP Server │
203
+ ├──────────┬──────────┬──────────┬──────────┬──────────┤
204
+ │ Ingest │ Feature │Constraint│ Verify │ Context │
205
+ │ (M1) │ Gen (M2) │ (M3) │ (M4) │ Eng (M5) │
206
+ ├──────────┴──────────┴──────────┴──────────┴──────────┤
207
+ │ State Manager · Test Scaffolder · Impact Analysis │
208
+ ├──────────────────────────────────────────────────────┤
209
+ │ AI Provider (OpenAI / Claude / Ollama) │
210
+ ├──────────────────────────────────────────────────────┤
211
+ │ Plugin System (Reader / Writer / Parser) │
212
+ └──────────────────────────────────────────────────────┘
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Documentation
218
+
219
+ | Doc | Description |
220
+ |-----|-------------|
221
+ | [Configuration](docs/configuration.md) | Full `config.yaml` reference, Profile modes, all CLI commands |
222
+ | [MCP Tools](docs/mcp-reference.md) | Complete I/O for 4 MCP tools, workflow guards, auto-init & migration |
223
+ | [Test Mapping](docs/test-mapping.md) | Three ways to map test results back to .feature scenarios |
224
+ | [Plugin Development](docs/plugin-guide.md) | Build and publish Reader / Writer / Parser plugins |
225
+ | [Product Spec](docs/product-spec.md) | Full product technical specification |
226
+
227
+ ---
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ git clone https://github.com/cheneyzhang93/speclore.git
233
+ cd speclore && pnpm install && pnpm build
234
+ pnpm test # 333 tests
235
+ pnpm dev # watch mode
236
+ ```
237
+
238
+ ## License
239
+
240
+ MIT