speclore 0.1.6 → 0.1.7
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/README.en.md +116 -65
- package/README.md +113 -62
- package/dist/cli/index.js +378 -173
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +378 -173
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +159 -113
- package/dist/mcp/server.js.map +1 -1
- package/package.json +12 -4
package/README.en.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
[](https://github.com/cheneyzhang93/speclore/actions/workflows/ci.yml)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**Requirements-driven AI coding tool — turn requirements into verifiable BDD specs, with constrained coding, automated acceptance, and full traceability.**
|
|
10
10
|
|
|
11
|
-
SpecLore
|
|
11
|
+
SpecLore solves the core pain points of AI-assisted development: requirements scattered across docs, chats, and verbal specs; AI-generated code lacking business constraints; tests disconnected from requirements. It transforms requirements in any format 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 the MCP protocol.
|
|
12
12
|
|
|
13
13
|
```
|
|
14
14
|
Requirements (any format) → BDD .feature → AI constraints + test scaffolding → acceptance report
|
|
@@ -22,33 +22,92 @@ Requirements (any format) → BDD .feature → AI constraints + test scaffolding
|
|
|
22
22
|
npm install -g speclore
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
> **Prerequisites**: Node.js 18+
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
25
29
|
## Quick Start
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
SpecLore offers three ways to work — pick the one that fits your workflow:
|
|
32
|
+
|
|
33
|
+
| Approach | Best for | Core experience |
|
|
34
|
+
|----------|----------|----------------|
|
|
35
|
+
| **CLI** | Terminal-oriented developers | Manual commands, full control |
|
|
36
|
+
| **MCP + AI Client** (Recommended) | Cursor / Qoder / Claude Code users | Natural language conversation, AI handles the full pipeline |
|
|
37
|
+
| **Hybrid** | Best of both worlds | CLI for setup, AI client for the rest |
|
|
38
|
+
|
|
39
|
+
### Approach 1: CLI
|
|
40
|
+
|
|
41
|
+
For developers who prefer terminal operations and precise control over each step.
|
|
28
42
|
|
|
29
43
|
```bash
|
|
30
|
-
# 1. Initialize project (
|
|
44
|
+
# 1. Initialize project (detect AI tools → write MCP config → generate config files)
|
|
31
45
|
cd your-project && speclore setup
|
|
32
46
|
|
|
33
47
|
# 2. Generate .feature acceptance criteria from requirements
|
|
34
|
-
speclore spec "Patient registration requires phone verification
|
|
48
|
+
speclore spec "Patient registration requires phone verification and WeChat login"
|
|
35
49
|
|
|
36
50
|
# 3. Generate AI coding constraints + test scaffolding
|
|
37
51
|
speclore code
|
|
52
|
+
|
|
53
|
+
# 4. After coding in your AI client, run acceptance
|
|
54
|
+
speclore verify
|
|
38
55
|
```
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
That's it. `setup` runs only once — after that, each new requirement is just `spec` → `code` → `verify`.
|
|
58
|
+
|
|
59
|
+
### Approach 2: MCP + AI Client (Recommended)
|
|
60
|
+
|
|
61
|
+
If you use Cursor, Qoder, or Claude Code, this is the most natural way — conversation replaces commands.
|
|
62
|
+
|
|
63
|
+
**Step 1**: Open your project in the AI client first. `setup` needs to detect the client's marker before writing MCP config (Cursor requires `.cursor/`, Qoder requires `.qoder/`, Claude Code requires `.claude/` or `CLAUDE.md`).
|
|
64
|
+
|
|
65
|
+
**Step 2**: Run `speclore setup` in your project directory. It auto-detects your AI client and writes the MCP config. You **don't need to manually edit any MCP config**.
|
|
66
|
+
|
|
67
|
+
**Step 3**: **Restart or reopen** your AI client so it loads the new MCP configuration.
|
|
68
|
+
|
|
69
|
+
**Step 4**: Start chatting:
|
|
70
|
+
|
|
71
|
+
> **You**: Help me implement patient registration with phone verification
|
|
72
|
+
|
|
73
|
+
> **AI** (calls `speclore.spec`): Generated `specs/patient/register.feature` with 3 acceptance scenarios:
|
|
74
|
+
> - Successful phone registration
|
|
75
|
+
> - Reject invalid phone format
|
|
76
|
+
> - Conflict on duplicate phone number
|
|
77
|
+
|
|
78
|
+
> **AI** (calls `speclore.code`): Generated coding constraints and test scaffolding:
|
|
79
|
+
> - `.qoder/rules/speclore.md` — coding constraints (with business rules)
|
|
80
|
+
> - `tests/patient/register.test.ts` — test scaffolding (3 `it.skip` placeholders)
|
|
81
|
+
|
|
82
|
+
> **You**: OK, I'll implement the code and tests
|
|
83
|
+
|
|
84
|
+
> *(AI reads constraint rules while coding; you fill in the `it.skip` test scaffolding)*
|
|
85
|
+
|
|
86
|
+
> **You**: Run acceptance
|
|
87
|
+
|
|
88
|
+
> **AI** (calls `speclore.verify`): ✅ 3/3 scenarios passed (100%)
|
|
89
|
+
|
|
90
|
+
No manual CLI commands needed. The AI calls SpecLore tools directly via MCP, automatically advancing the workflow state.
|
|
91
|
+
|
|
92
|
+
### Approach 3: Hybrid
|
|
93
|
+
|
|
94
|
+
Use CLI for initialization and requirement generation, AI client for coding and acceptance:
|
|
41
95
|
|
|
42
96
|
```bash
|
|
43
|
-
|
|
97
|
+
# CLI: initialize + generate .feature
|
|
98
|
+
speclore setup
|
|
99
|
+
speclore spec requirements.md
|
|
100
|
+
speclore code
|
|
44
101
|
```
|
|
45
102
|
|
|
46
|
-
|
|
103
|
+
Then code in your AI client, and let AI call `speclore.verify` for acceptance.
|
|
47
104
|
|
|
48
105
|
---
|
|
49
106
|
|
|
50
107
|
## Workflow
|
|
51
108
|
|
|
109
|
+
SpecLore's workflow is a stateful pipeline — each step has explicit state transitions:
|
|
110
|
+
|
|
52
111
|
```
|
|
53
112
|
speclore.status → speclore.spec → speclore.code → (AI codes) → speclore.verify
|
|
54
113
|
check status generate feature constraints+scaffold implement verify tests
|
|
@@ -56,7 +115,7 @@ speclore.status → speclore.spec → speclore.code → (AI codes) → speclore.
|
|
|
56
115
|
project state → specified → constrained → coding → verified
|
|
57
116
|
```
|
|
58
117
|
|
|
59
|
-
Each tool returns current state and next-step guidance. Out-of-order calls produce clear errors:
|
|
118
|
+
Each tool returns the current state and next-step guidance. Out-of-order calls produce clear errors:
|
|
60
119
|
|
|
61
120
|
| Out-of-order scenario | Error message |
|
|
62
121
|
|----------------------|---------------|
|
|
@@ -66,87 +125,77 @@ Each tool returns current state and next-step guidance. Out-of-order calls produ
|
|
|
66
125
|
|
|
67
126
|
---
|
|
68
127
|
|
|
69
|
-
##
|
|
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)*
|
|
128
|
+
## Supported Input Formats
|
|
87
129
|
|
|
88
|
-
|
|
130
|
+
SpecLore generates `.feature` files from any requirement source:
|
|
89
131
|
|
|
90
|
-
|
|
132
|
+
| Format | Example |
|
|
133
|
+
|--------|---------|
|
|
134
|
+
| Markdown | `speclore spec requirements.md` |
|
|
135
|
+
| Word | `speclore spec design.docx` |
|
|
136
|
+
| Excel | `speclore spec specs.xlsx` |
|
|
137
|
+
| PDF | `speclore spec design.pdf` |
|
|
138
|
+
| Image (OCR) | `speclore spec mockup.png` |
|
|
139
|
+
| URL | `speclore spec https://jira.example/123` |
|
|
140
|
+
| Plain text | `speclore spec "Users need password reset"` |
|
|
91
141
|
|
|
92
142
|
---
|
|
93
143
|
|
|
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
144
|
## Command Reference
|
|
108
145
|
|
|
109
146
|
| Command | Purpose |
|
|
110
147
|
|---------|---------|
|
|
111
|
-
| `speclore` | Show project status |
|
|
112
148
|
| `speclore setup` | Initialize project (detect AI tools → write MCP config → generate rules) |
|
|
113
149
|
| `speclore spec <source>` | Requirement source → `.feature` acceptance criteria |
|
|
114
150
|
| `speclore code` | `.feature` → AI coding constraints + test scaffolding |
|
|
115
151
|
| `speclore verify` | Run tests → acceptance report (mapped to .feature scenarios) |
|
|
116
152
|
| `speclore verify --watch` | Watch mode, auto-rerun on file changes |
|
|
117
153
|
| `speclore status` | View project state, workflow progress, recommended actions |
|
|
154
|
+
| `speclore init` | Scan project structure, generate context (optional — auto-runs on first spec/code call) |
|
|
118
155
|
| `speclore migrate` | Migrate existing .feature files to workflow state after upgrade |
|
|
119
|
-
| `speclore
|
|
156
|
+
| `speclore mcp add <client>` | Manually write MCP config for a specific client (cursor \| claude \| qoder) |
|
|
157
|
+
| `speclore mcp remove <client>` | Manually remove MCP config from a specific client |
|
|
158
|
+
| `speclore mcp list` | Show MCP configuration status for all clients |
|
|
120
159
|
| `speclore teardown` | Uninstall cleanup |
|
|
121
160
|
|
|
122
|
-
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## MCP Integration
|
|
123
164
|
|
|
124
|
-
SpecLore provides 4 MCP tools
|
|
165
|
+
SpecLore provides 4 MCP tools that AI clients can call directly:
|
|
125
166
|
|
|
126
|
-
| Tool | Purpose | State change |
|
|
127
|
-
|
|
167
|
+
| MCP Tool | Purpose | State change |
|
|
168
|
+
|----------|---------|-------------|
|
|
128
169
|
| `speclore.status` | Project status + recommended actions | — |
|
|
129
170
|
| `speclore.spec` | Requirements → .feature | → `specified` |
|
|
130
171
|
| `speclore.code` | .feature → constraints + test scaffolding | → `constrained` |
|
|
131
172
|
| `speclore.verify` | Tests → acceptance report | → `verified` |
|
|
132
173
|
|
|
133
|
-
|
|
174
|
+
`speclore setup` auto-detects your AI client and writes the corresponding MCP config (only for clients actually detected):
|
|
175
|
+
|
|
176
|
+
| AI Client | Detection marker | MCP Config File |
|
|
177
|
+
|-----------|-----------------|----------------|
|
|
178
|
+
| Cursor | `.cursor/` directory exists | `.cursor/mcp.json` |
|
|
179
|
+
| Claude Code | `.claude/` directory or `CLAUDE.md` exists | `.mcp.json` (project root) |
|
|
180
|
+
| Qoder | `.qoder/` directory exists | `.qoder/mcp.json` |
|
|
134
181
|
|
|
135
|
-
|
|
182
|
+
**Manual MCP configuration**: If `setup` did not detect your AI client, configure it manually:
|
|
136
183
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
184
|
+
```bash
|
|
185
|
+
speclore mcp add cursor # Write MCP config for Cursor (auto-creates .cursor/)
|
|
186
|
+
speclore mcp add claude # Write MCP config for Claude Code
|
|
187
|
+
speclore mcp add qoder # Write MCP config for Qoder (auto-creates .qoder/)
|
|
188
|
+
speclore mcp remove qoder # Remove MCP config from Qoder
|
|
189
|
+
speclore mcp list # Show MCP config status for all clients
|
|
190
|
+
```
|
|
142
191
|
|
|
143
|
-
`
|
|
192
|
+
Every MCP tool response includes a `workflow` field (`currentState` + `nextStep`) to guide the AI through the correct sequence.
|
|
144
193
|
|
|
145
194
|
---
|
|
146
195
|
|
|
147
196
|
## Configuration
|
|
148
197
|
|
|
149
|
-
Core config in `.speclore/config.yaml` (generated by `setup`):
|
|
198
|
+
Core config in `.speclore/config.yaml` (generated by `speclore setup`):
|
|
150
199
|
|
|
151
200
|
```yaml
|
|
152
201
|
verify:
|
|
@@ -198,7 +247,7 @@ verify:
|
|
|
198
247
|
## Architecture
|
|
199
248
|
|
|
200
249
|
```
|
|
201
|
-
|
|
250
|
+
──────────────────────────────────────────────────────┐
|
|
202
251
|
│ CLI / MCP Server │
|
|
203
252
|
├──────────┬──────────┬──────────┬──────────┬──────────┤
|
|
204
253
|
│ Ingest │ Feature │Constraint│ Verify │ Context │
|
|
@@ -218,11 +267,13 @@ verify:
|
|
|
218
267
|
|
|
219
268
|
| Doc | Description |
|
|
220
269
|
|-----|-------------|
|
|
221
|
-
| [
|
|
222
|
-
| [
|
|
223
|
-
| [
|
|
224
|
-
| [
|
|
225
|
-
| [
|
|
270
|
+
| [Getting Started](docs/en/guide/getting-started.md) | Complete tutorial with all three usage approaches |
|
|
271
|
+
| [Workflow](docs/en/guide/workflow.md) | State machine-driven workflow guide |
|
|
272
|
+
| [Configuration](docs/en/reference/configuration.md) | Full `config.yaml` reference, Profile modes, all CLI commands |
|
|
273
|
+
| [MCP Tools](docs/en/reference/mcp-tools.md) | Complete I/O for 4 MCP tools, workflow guards, auto-init & migration |
|
|
274
|
+
| [Test Mapping](docs/en/reference/test-mapping.md) | Three ways to map test results back to .feature scenarios |
|
|
275
|
+
| [Plugin Development](docs/en/advanced/plugin-guide.md) | Build and publish Reader / Writer / Parser plugins |
|
|
276
|
+
| [Product Spec](docs/en/advanced/architecture.md) | Full product technical specification |
|
|
226
277
|
|
|
227
278
|
---
|
|
228
279
|
|
|
@@ -231,8 +282,8 @@ verify:
|
|
|
231
282
|
```bash
|
|
232
283
|
git clone https://github.com/cheneyzhang93/speclore.git
|
|
233
284
|
cd speclore && pnpm install && pnpm build
|
|
234
|
-
pnpm test #
|
|
235
|
-
pnpm dev #
|
|
285
|
+
pnpm test # Run tests
|
|
286
|
+
pnpm dev # Watch mode
|
|
236
287
|
```
|
|
237
288
|
|
|
238
289
|
## License
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
[](https://github.com/cheneyzhang93/speclore/actions/workflows/ci.yml)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**需求驱动的 AI 编码工具 — 把需求变成可验收的 BDD 规格,让 AI 编码有约束、有验收、可追溯。**
|
|
10
10
|
|
|
11
|
-
SpecLore
|
|
11
|
+
SpecLore 解决 AI 编码时代的核心痛点:需求散落在文档、聊天和口头沟通中,AI 生成的代码缺乏业务约束,测试与需求脱节。它将任意格式的需求转化为结构化 BDD `.feature` 验收标准,为 Cursor / Claude Code / Qoder 等 AI 编码工具生成编码约束,最后自动运行测试并生成验收报告。全程通过 MCP 协议与 AI 客户端无缝协作。
|
|
12
12
|
|
|
13
13
|
```
|
|
14
14
|
需求(任意格式)→ BDD .feature → AI 编码约束 + 测试骨架 → 测试验收报告
|
|
@@ -22,12 +22,26 @@ SpecLore 将散落在文档、聊天、口头中的需求,转化为结构化
|
|
|
22
22
|
npm install -g speclore
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
> **前提条件**:Node.js 18+
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
25
29
|
## 快速开始
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
SpecLore 提供三种使用方式,根据你的工作习惯选择:
|
|
32
|
+
|
|
33
|
+
| 方式 | 适合谁 | 核心体验 |
|
|
34
|
+
|------|--------|---------|
|
|
35
|
+
| **方式一:CLI 命令行** | 习惯终端操作的开发者 | 手动执行命令,完全掌控流程 |
|
|
36
|
+
| **方式二:MCP + AI 客户端**(推荐) | 使用 Cursor / Qoder / Claude Code 的开发者 | 用自然语言对话,AI 自动完成全流程 |
|
|
37
|
+
| **方式三:混合使用** | 两者都想要的开发者 | CLI 做初始化,AI 客户端做后续操作 |
|
|
38
|
+
|
|
39
|
+
### 方式一:CLI 命令行
|
|
40
|
+
|
|
41
|
+
适合喜欢终端操作、需要精确控制每一步的开发者。
|
|
28
42
|
|
|
29
43
|
```bash
|
|
30
|
-
# 1.
|
|
44
|
+
# 1. 初始化项目(检测 AI 工具 → 写入 MCP 配置 → 生成配置文件)
|
|
31
45
|
cd your-project && speclore setup
|
|
32
46
|
|
|
33
47
|
# 2. 从需求生成 .feature 验收标准
|
|
@@ -35,20 +49,65 @@ speclore spec "患者注册需要手机号验证,支持微信登录"
|
|
|
35
49
|
|
|
36
50
|
# 3. 生成 AI 编码约束 + 测试骨架
|
|
37
51
|
speclore code
|
|
52
|
+
|
|
53
|
+
# 4. 在 AI 客户端中编码后,运行验收
|
|
54
|
+
speclore verify
|
|
38
55
|
```
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
就这么简单。`setup` 只需执行一次,之后每个新需求只需 `spec` → `code` → `verify` 三步。
|
|
58
|
+
|
|
59
|
+
### 方式二:MCP + AI 客户端(推荐)
|
|
60
|
+
|
|
61
|
+
如果你使用 Cursor、Qoder 或 Claude Code,这是最自然的方式 — 用对话代替命令。
|
|
62
|
+
|
|
63
|
+
**第一步**:先用 AI 客户端打开项目。`setup` 需要检测到客户端标志才能写入 MCP 配置(Cursor 需要 `.cursor/`,Qoder 需要 `.qoder/`,Claude Code 需要 `.claude/` 或 `CLAUDE.md`)。
|
|
64
|
+
|
|
65
|
+
**第二步**:在项目目录运行 `speclore setup`,它会自动检测已打开的 AI 客户端并写入 MCP 配置。你**不需要手动编辑任何 MCP 配置**。
|
|
66
|
+
|
|
67
|
+
**第三步**:**重启或重新打开** AI 客户端,让它加载新的 MCP 配置。
|
|
68
|
+
|
|
69
|
+
**第四步**:直接对话:
|
|
70
|
+
|
|
71
|
+
> **你**:帮我实现患者注册功能,需要手机号验证
|
|
72
|
+
|
|
73
|
+
> **AI**(自动调用 `speclore.spec`):已生成 `specs/patient/register.feature`,包含 3 个验收场景:
|
|
74
|
+
> - 手机号注册成功
|
|
75
|
+
> - 手机号格式错误时拒绝
|
|
76
|
+
> - 重复手机号时提示冲突
|
|
77
|
+
|
|
78
|
+
> **AI**(自动调用 `speclore.code`):已生成编码约束和测试骨架:
|
|
79
|
+
> - `.qoder/rules/speclore.md` — 编码约束(含业务规则)
|
|
80
|
+
> - `tests/patient/register.test.ts` — 测试骨架(3 个 `it.skip`)
|
|
81
|
+
|
|
82
|
+
> **你**:好的,我来实现代码和测试
|
|
83
|
+
|
|
84
|
+
> *(AI 编码时自动读取约束规则,你填充测试骨架中的 `it.skip`)*
|
|
85
|
+
|
|
86
|
+
> **你**:运行验收
|
|
87
|
+
|
|
88
|
+
> **AI**(调用 `speclore.verify`):✅ 3/3 场景通过 (100%)
|
|
89
|
+
|
|
90
|
+
全程无需手动执行任何 CLI 命令。AI 通过 MCP 协议直接调用 SpecLore 的工具,自动推进工作流状态。
|
|
91
|
+
|
|
92
|
+
### 方式三:混合使用
|
|
93
|
+
|
|
94
|
+
用 CLI 做初始化和需求生成,用 AI 客户端做编码和验收:
|
|
41
95
|
|
|
42
96
|
```bash
|
|
43
|
-
|
|
97
|
+
# CLI:初始化 + 生成 .feature
|
|
98
|
+
speclore setup
|
|
99
|
+
speclore spec requirements.md
|
|
100
|
+
speclore code
|
|
44
101
|
```
|
|
45
102
|
|
|
46
|
-
|
|
103
|
+
然后在 AI 客户端中编码,最后让 AI 调用 `speclore.verify` 运行验收。
|
|
47
104
|
|
|
48
105
|
---
|
|
49
106
|
|
|
50
107
|
## 工作流
|
|
51
108
|
|
|
109
|
+
SpecLore 的工作流是一个有状态流水线,每个步骤都有明确的状态转换:
|
|
110
|
+
|
|
52
111
|
```
|
|
53
112
|
speclore.status → speclore.spec → speclore.code → (AI 编码) → speclore.verify
|
|
54
113
|
查看状态 生成 feature 生成约束+骨架 实现代码 验收测试
|
|
@@ -56,7 +115,7 @@ speclore.status → speclore.spec → speclore.code → (AI 编码) → speclore
|
|
|
56
115
|
项目状态 → specified → constrained → coding → verified
|
|
57
116
|
```
|
|
58
117
|
|
|
59
|
-
|
|
118
|
+
每个工具调用后返回当前状态和下一步指引,乱序调用会自动报错:
|
|
60
119
|
|
|
61
120
|
| 乱序场景 | 报错信息 |
|
|
62
121
|
|---------|---------|
|
|
@@ -66,87 +125,77 @@ speclore.status → speclore.spec → speclore.code → (AI 编码) → speclore
|
|
|
66
125
|
|
|
67
126
|
---
|
|
68
127
|
|
|
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`)*
|
|
128
|
+
## 支持的输入格式
|
|
87
129
|
|
|
88
|
-
|
|
130
|
+
SpecLore 可以从任意格式的需求来源生成 `.feature` 文件:
|
|
89
131
|
|
|
90
|
-
|
|
132
|
+
| 格式 | 示例 |
|
|
133
|
+
|------|------|
|
|
134
|
+
| Markdown | `speclore spec requirements.md` |
|
|
135
|
+
| Word | `speclore spec design.docx` |
|
|
136
|
+
| Excel | `speclore spec specs.xlsx` |
|
|
137
|
+
| PDF | `speclore spec design.pdf` |
|
|
138
|
+
| 图片 (OCR) | `speclore spec mockup.png` |
|
|
139
|
+
| URL | `speclore spec https://jira.example/123` |
|
|
140
|
+
| 直接文本 | `speclore spec "用户需要能重置密码"` |
|
|
91
141
|
|
|
92
142
|
---
|
|
93
143
|
|
|
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
144
|
## 命令速查
|
|
108
145
|
|
|
109
146
|
| 命令 | 用途 |
|
|
110
147
|
|------|------|
|
|
111
|
-
| `speclore` | 显示项目状态 |
|
|
112
148
|
| `speclore setup` | 初始化项目(检测 AI 工具 → 写入 MCP 配置 → 生成规则) |
|
|
113
149
|
| `speclore spec <source>` | 需求来源 → `.feature` 验收标准 |
|
|
114
150
|
| `speclore code` | `.feature` → AI 编码约束 + 测试骨架 |
|
|
115
151
|
| `speclore verify` | 运行测试 → 验收报告(映射到 .feature 场景) |
|
|
116
152
|
| `speclore verify --watch` | 监听模式,文件变化自动重跑验收 |
|
|
117
153
|
| `speclore status` | 查看项目状态、工作流进度、推荐操作 |
|
|
154
|
+
| `speclore init` | 扫描项目结构,生成上下文(可选,首次 spec/code 时自动执行) |
|
|
118
155
|
| `speclore migrate` | 升级后迁移已有 .feature 文件到工作流状态 |
|
|
119
|
-
| `speclore
|
|
156
|
+
| `speclore mcp add <client>` | 手动为指定客户端写入 MCP 配置(cursor \| claude \| qoder) |
|
|
157
|
+
| `speclore mcp remove <client>` | 手动从指定客户端移除 MCP 配置 |
|
|
158
|
+
| `speclore mcp list` | 查看所有客户端的 MCP 配置状态 |
|
|
120
159
|
| `speclore teardown` | 卸载清理 |
|
|
121
160
|
|
|
122
|
-
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## MCP 集成
|
|
123
164
|
|
|
124
|
-
SpecLore
|
|
165
|
+
SpecLore 通过 MCP(Model Context Protocol)为 AI 客户端提供 4 个工具,AI 可以直接调用:
|
|
125
166
|
|
|
126
|
-
| 工具 | 用途 | 状态变化 |
|
|
127
|
-
|
|
167
|
+
| MCP 工具 | 用途 | 状态变化 |
|
|
168
|
+
|----------|------|---------|
|
|
128
169
|
| `speclore.status` | 项目状态 + 推荐操作 | — |
|
|
129
170
|
| `speclore.spec` | 需求 → .feature | → `specified` |
|
|
130
171
|
| `speclore.code` | .feature → 约束 + 测试骨架 | → `constrained` |
|
|
131
172
|
| `speclore.verify` | 测试 → 验收报告 | → `verified` |
|
|
132
173
|
|
|
133
|
-
|
|
174
|
+
`speclore setup` 会自动检测已打开的 AI 客户端并写入对应的 MCP 配置(只为实际检测到的客户端写入):
|
|
175
|
+
|
|
176
|
+
| AI 客户端 | 检测标志 | MCP 配置文件 |
|
|
177
|
+
|-----------|---------|-------------|
|
|
178
|
+
| Cursor | `.cursor/` 目录存在 | `.cursor/mcp.json` |
|
|
179
|
+
| Claude Code | `.claude/` 目录或 `CLAUDE.md` 存在 | `.mcp.json`(项目根目录) |
|
|
180
|
+
| Qoder | `.qoder/` 目录存在 | `.qoder/mcp.json` |
|
|
134
181
|
|
|
135
|
-
|
|
182
|
+
**手动配置 MCP**:如果 `setup` 未检测到你的 AI 客户端,可以手动配置:
|
|
136
183
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
184
|
+
```bash
|
|
185
|
+
speclore mcp add cursor # 为 Cursor 写入 MCP 配置(自动创建 .cursor/)
|
|
186
|
+
speclore mcp add claude # 为 Claude Code 写入 MCP 配置
|
|
187
|
+
speclore mcp add qoder # 为 Qoder 写入 MCP 配置(自动创建 .qoder/)
|
|
188
|
+
speclore mcp remove qoder # 从 Qoder 移除 MCP 配置
|
|
189
|
+
speclore mcp list # 查看所有客户端的 MCP 配置状态
|
|
190
|
+
```
|
|
142
191
|
|
|
143
|
-
`
|
|
192
|
+
每个 MCP 工具响应包含 `workflow` 字段(`currentState` + `nextStep`),引导 AI 按正确顺序推进工作流。
|
|
144
193
|
|
|
145
194
|
---
|
|
146
195
|
|
|
147
196
|
## 配置
|
|
148
197
|
|
|
149
|
-
`setup` 生成的 `.speclore/config.yaml` 核心配置:
|
|
198
|
+
`speclore setup` 生成的 `.speclore/config.yaml` 核心配置:
|
|
150
199
|
|
|
151
200
|
```yaml
|
|
152
201
|
verify:
|
|
@@ -218,11 +267,13 @@ verify:
|
|
|
218
267
|
|
|
219
268
|
| 文档 | 说明 |
|
|
220
269
|
|------|------|
|
|
221
|
-
| [
|
|
222
|
-
| [
|
|
223
|
-
| [
|
|
224
|
-
| [
|
|
225
|
-
| [
|
|
270
|
+
| [快速开始](docs/guide/getting-started.md) | 完整入门教程,三种使用方式详解 |
|
|
271
|
+
| [工作流](docs/guide/workflow.md) | 状态机驱动的完整工作流说明 |
|
|
272
|
+
| [配置参考](docs/reference/configuration.md) | `config.yaml` 完整配置、Profile 模式、所有 CLI 命令详细参考 |
|
|
273
|
+
| [MCP 工具参考](docs/reference/mcp-tools.md) | 4 个 MCP 工具完整 I/O、流程强约束、自动初始化与迁移 |
|
|
274
|
+
| [测试映射](docs/reference/test-mapping.md) | 测试结果与 .feature 场景的三种映射方式 |
|
|
275
|
+
| [插件开发](docs/advanced/plugin-guide.md) | Reader / Writer / Parser 插件开发与发布 |
|
|
276
|
+
| [产品技术规格](docs/advanced/architecture.md) | 完整产品技术规格书 |
|
|
226
277
|
|
|
227
278
|
---
|
|
228
279
|
|
|
@@ -231,7 +282,7 @@ verify:
|
|
|
231
282
|
```bash
|
|
232
283
|
git clone https://github.com/cheneyzhang93/speclore.git
|
|
233
284
|
cd speclore && pnpm install && pnpm build
|
|
234
|
-
pnpm test #
|
|
285
|
+
pnpm test # 运行测试
|
|
235
286
|
pnpm dev # watch 模式
|
|
236
287
|
```
|
|
237
288
|
|