speclore 0.1.1

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 ADDED
@@ -0,0 +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.
package/README.en.md ADDED
@@ -0,0 +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
package/README.md ADDED
@@ -0,0 +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
+ **AI 编码时代的产研协同工具 — 把需求变成可验收的 BDD 规格,把验收变成自动化流水线。**
10
+
11
+ SpecLore 将散落在文档、聊天、口头中的需求,转化为结构化的 BDD `.feature` 验收标准,再为 Cursor / Claude Code / Qoder 等 AI 编码工具生成编码约束,最后自动运行测试并生成验收报告。全程通过 MCP 协议与 AI 客户端无缝协作。
12
+
13
+ ```
14
+ 需求(任意格式)→ BDD .feature → AI 编码约束 + 测试骨架 → 测试验收报告
15
+ ```
16
+
17
+ ---
18
+
19
+ ## 安装
20
+
21
+ ```bash
22
+ npm install -g speclore
23
+ ```
24
+
25
+ ## 快速开始
26
+
27
+ 三步从零到验收:
28
+
29
+ ```bash
30
+ # 1. 初始化项目(自动检测 AI 工具,生成配置)
31
+ cd your-project && speclore setup
32
+
33
+ # 2. 从需求生成 .feature 验收标准
34
+ speclore spec "患者注册需要手机号验证,支持微信登录"
35
+
36
+ # 3. 生成 AI 编码约束 + 测试骨架
37
+ speclore code
38
+ ```
39
+
40
+ 然后在 AI 客户端中编码,完成后运行验收:
41
+
42
+ ```bash
43
+ speclore verify
44
+ ```
45
+
46
+ 就这么简单。也可以在 AI 客户端(Cursor / Qoder / Claude Code)中用自然语言完成整个流程 — `setup` 已自动配置好 MCP。
47
+
48
+ ---
49
+
50
+ ## 工作流
51
+
52
+ ```
53
+ speclore.status → speclore.spec → speclore.code → (AI 编码) → speclore.verify
54
+ 查看状态 生成 feature 生成约束+骨架 实现代码 验收测试
55
+ ↓ ↓ ↓ ↓ ↓
56
+ 项目状态 → specified → constrained → coding → verified
57
+ ```
58
+
59
+ 每个工具调用后返回当前状态和下一步指引,乱序调用自动报错:
60
+
61
+ | 乱序场景 | 报错信息 |
62
+ |---------|---------|
63
+ | 没有 .feature 就调 `code` | `No .feature files found. Run speclore.spec first.` |
64
+ | 没有测试骨架就调 `verify` | `No test scaffolding. Run speclore.code first.` |
65
+ | 项目未初始化 | 自动创建 `.speclore/config.yaml` |
66
+
67
+ ---
68
+
69
+ ## 示例
70
+
71
+ 以「患者注册」为例,在 AI 客户端中的完整对话:
72
+
73
+ **你**:帮我实现患者注册功能,需要手机号验证
74
+
75
+ **AI**(自动调用 `speclore.spec`):已生成 `specs/patient/register.feature`,包含 3 个验收场景:
76
+ - 手机号注册成功
77
+ - 手机号格式错误时拒绝
78
+ - 重复手机号时提示冲突
79
+
80
+ **AI**(自动调用 `speclore.code`):已生成编码约束和测试骨架:
81
+ - `.qoder/rules/speclore.md` — 编码约束(含业务规则)
82
+ - `tests/patient/register.test.ts` — 测试骨架(3 个 `it.skip`)
83
+
84
+ **你**:好的,我来实现代码和测试
85
+
86
+ *(AI 编码时自动读取约束规则,你填充测试骨架中的 `it.skip`)*
87
+
88
+ **你**:运行验收
89
+
90
+ **AI**(调用 `speclore.verify`):✅ 3/3 场景通过 (100%)
91
+
92
+ ---
93
+
94
+ ## 支持的输入格式
95
+
96
+ Markdown · Word · Excel · PDF · 图片 (OCR) · URL · 直接文本
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 # 图片
103
+ speclore spec https://jira.example/123 # URL
104
+ speclore spec "用户需要能重置密码" # 直接文本
105
+ ```
106
+
107
+ ## 命令速查
108
+
109
+ | 命令 | 用途 |
110
+ |------|------|
111
+ | `speclore` | 显示项目状态 |
112
+ | `speclore setup` | 初始化项目(检测 AI 工具 → 写入 MCP 配置 → 生成规则) |
113
+ | `speclore spec <source>` | 需求来源 → `.feature` 验收标准 |
114
+ | `speclore code` | `.feature` → AI 编码约束 + 测试骨架 |
115
+ | `speclore verify` | 运行测试 → 验收报告(映射到 .feature 场景) |
116
+ | `speclore verify --watch` | 监听模式,文件变化自动重跑验收 |
117
+ | `speclore status` | 查看项目状态、工作流进度、推荐操作 |
118
+ | `speclore migrate` | 升级后迁移已有 .feature 文件到工作流状态 |
119
+ | `speclore init` | 扫描项目结构,生成上下文文件 |
120
+ | `speclore teardown` | 卸载清理 |
121
+
122
+ ## MCP 工具
123
+
124
+ SpecLore 提供 4 个 MCP 工具,AI 客户端通过 MCP 协议直接调用:
125
+
126
+ | 工具 | 用途 | 状态变化 |
127
+ |------|------|---------|
128
+ | `speclore.status` | 项目状态 + 推荐操作 | — |
129
+ | `speclore.spec` | 需求 → .feature | → `specified` |
130
+ | `speclore.code` | .feature → 约束 + 测试骨架 | → `constrained` |
131
+ | `speclore.verify` | 测试 → 验收报告 | → `verified` |
132
+
133
+ 每个工具响应包含 `workflow` 字段(`currentState` + `nextStep`),引导 AI 按正确顺序推进。
134
+
135
+ ## 支持的 AI 客户端
136
+
137
+ | 客户端 | 配置文件 | 约束规则文件 |
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` 自动检测并配置。
144
+
145
+ ---
146
+
147
+ ## 配置
148
+
149
+ `setup` 生成的 `.speclore/config.yaml` 核心配置:
150
+
151
+ ```yaml
152
+ verify:
153
+ command: "pnpm test" # 你的测试命令
154
+ mapping:
155
+ patterns:
156
+ - feature: "specs/{module}/{name}.feature"
157
+ test: "tests/{module}/{name}.test.*"
158
+ ```
159
+
160
+ <details>
161
+ <summary>完整配置参考</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: 订单管理
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: zh-CN
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
+ ## 技术架构
199
+
200
+ ```
201
+ ┌──────────────────────────────────────────────────────┐
202
+ │ CLI / MCP Server │
203
+ ├──────────┬──────────┬──────────┬──────────┬──────────┤
204
+ │ 需求摄入 │ Feature │ 约束编码 │ 验收验证 │ 上下文引擎 │
205
+ │ (M1) │ 生成(M2) │ (M3) │ (M4) │ (M5) │
206
+ ├──────────┴──────────┴──────────┴──────────┴──────────┤
207
+ │ 状态管理器 · 测试骨架生成 · 变更影响分析 │
208
+ ├──────────────────────────────────────────────────────┤
209
+ │ AI Provider (OpenAI / Claude / Ollama) │
210
+ ├──────────────────────────────────────────────────────┤
211
+ │ Plugin System (Reader / Writer / Parser) │
212
+ └──────────────────────────────────────────────────────┘
213
+ ```
214
+
215
+ ---
216
+
217
+ ## 完整文档
218
+
219
+ | 文档 | 说明 |
220
+ |------|------|
221
+ | [配置参考](docs/configuration.md) | `config.yaml` 完整配置、Profile 模式、所有 CLI 命令详细参考 |
222
+ | [MCP 工具参考](docs/mcp-reference.md) | 4 个 MCP 工具完整 I/O、流程强约束、自动初始化与迁移 |
223
+ | [测试映射](docs/test-mapping.md) | 测试结果与 .feature 场景的三种映射方式 |
224
+ | [插件开发](docs/plugin-guide.md) | Reader / Writer / Parser 插件开发与发布 |
225
+ | [产品技术规格](docs/product-spec.md) | 完整产品技术规格书 |
226
+
227
+ ---
228
+
229
+ ## 开发
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 模式
236
+ ```
237
+
238
+ ## License
239
+
240
+ MIT
@@ -0,0 +1,2 @@
1
+
2
+ export { }