speclore 0.1.2 → 0.1.4

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.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
- **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
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
package/dist/cli/index.js CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __esm = (fn, res) => function __init() {
6
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
+ var __esm = (fn, res, err) => function __init() {
6
+ if (err) throw err[0];
7
+ try {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ } catch (e) {
10
+ throw err = [e], e;
11
+ }
7
12
  };
8
13
  var __export = (target, all) => {
9
14
  for (var name in all)
@@ -5064,7 +5069,7 @@ var init_server = __esm({
5064
5069
  description: STATUS_TOOL_DESC,
5065
5070
  inputSchema: statusInputSchema.shape
5066
5071
  },
5067
- async (args) => {
5072
+ (args) => {
5068
5073
  const result = executeStatusTool(
5069
5074
  { feature: args.feature },
5070
5075
  getProjectRoot()