@zhuan-ai/zhuanspec 2.0.0 → 2.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/README.zh.md +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/commands/artifact-workflow.js +22 -2
- package/dist/commands/validate.d.ts +5 -0
- package/dist/commands/validate.js +65 -3
- package/dist/core/skill-discovery.d.ts +2 -2
- package/dist/core/skill-discovery.js +16 -3
- package/dist/core/task-graph/index.d.ts +2 -0
- package/dist/core/task-graph/index.js +2 -0
- package/dist/core/task-graph/mermaid-renderer.d.ts +22 -0
- package/dist/core/task-graph/mermaid-renderer.js +128 -0
- package/dist/core/templates/agents-template.d.ts +1 -1
- package/dist/core/templates/agents-template.js +60 -37
- package/dist/core/templates/skill-templates.js +42 -0
- package/dist/core/templates/slash-command-templates.js +25 -2
- package/dist/core/templates/tasks-template.d.ts +23 -0
- package/dist/core/templates/tasks-template.js +79 -0
- package/dist/core/templates/tdd-tasks-template.d.ts +24 -0
- package/dist/core/templates/tdd-tasks-template.js +116 -0
- package/dist/core/validation/strict-rules.d.ts +60 -0
- package/dist/core/validation/strict-rules.js +287 -0
- package/dist/core/validation/types.d.ts +10 -0
- package/dist/core/validation/validator.d.ts +5 -0
- package/dist/core/validation/validator.js +103 -1
- package/package.json +1 -1
- package/schemas/spec-driven/schema.yaml +13 -13
- package/schemas/spec-driven/templates/design.md +6 -6
- package/schemas/spec-driven/templates/proposal.md +7 -7
- package/schemas/spec-driven/templates/spec.md +4 -4
- package/schemas/tdd/schema.yaml +107 -107
- package/schemas/tdd/templates/implementation.md +5 -5
- package/schemas/tdd/templates/spec.md +6 -6
- package/schemas/tdd/templates/test.md +7 -7
package/schemas/tdd/schema.yaml
CHANGED
|
@@ -1,177 +1,177 @@
|
|
|
1
1
|
name: tdd
|
|
2
2
|
version: 1
|
|
3
|
-
description:
|
|
3
|
+
description: 测试驱动开发工作流 - 测试 → 实现 → 文档
|
|
4
4
|
artifacts:
|
|
5
5
|
- id: spec
|
|
6
6
|
generates: spec.md
|
|
7
|
-
description:
|
|
7
|
+
description: 定义需求的特性规格说明
|
|
8
8
|
template: spec.md
|
|
9
9
|
instruction: |
|
|
10
|
-
|
|
10
|
+
创建定义「要构建什么」的特性规格说明。
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
- **Feature**:
|
|
14
|
-
- **Requirements**:
|
|
15
|
-
- **Acceptance Criteria**:
|
|
12
|
+
章节:
|
|
13
|
+
- **Feature**: 特性名称及高层描述,说明其用途和用户价值
|
|
14
|
+
- **Requirements**: 具体需求列表。使用 SHALL/MUST 作为规范性语言。
|
|
15
|
+
- **Acceptance Criteria**: 使用 WHEN/THEN 格式的可测试验收标准
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
17
|
+
格式要求:
|
|
18
|
+
- 每个需求应具体且可测试
|
|
19
|
+
- 使用 `#### Scenario: <名称>` 配合 WHEN/THEN 格式编写验收标准
|
|
20
|
+
- 明确定义边界情况和错误场景
|
|
21
|
+
- 每个需求必须至少有一个场景
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
示例:
|
|
24
24
|
```
|
|
25
|
-
## Feature:
|
|
25
|
+
## Feature: 用户认证
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
用户可以安全地登录应用程序。
|
|
28
28
|
|
|
29
29
|
## Requirements
|
|
30
30
|
|
|
31
|
-
### Requirement:
|
|
32
|
-
|
|
31
|
+
### Requirement: 密码验证
|
|
32
|
+
系统 SHALL 验证密码满足最低安全要求。
|
|
33
33
|
|
|
34
|
-
#### Scenario:
|
|
35
|
-
- **WHEN**
|
|
36
|
-
- **THEN**
|
|
34
|
+
#### Scenario: 有效密码被接受
|
|
35
|
+
- **WHEN** 密码包含 8+ 字符、大写字母、小写字母和数字
|
|
36
|
+
- **THEN** 密码被接受
|
|
37
37
|
|
|
38
|
-
#### Scenario:
|
|
39
|
-
- **WHEN**
|
|
40
|
-
- **THEN**
|
|
38
|
+
#### Scenario: 弱密码被拒绝
|
|
39
|
+
- **WHEN** 密码少于 8 个字符
|
|
40
|
+
- **THEN** 系统显示 "Password too short" 错误
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
此规格驱动测试创建 - 每个场景成为一个测试用例。
|
|
44
44
|
requires: []
|
|
45
45
|
|
|
46
46
|
- id: tests
|
|
47
47
|
generates: "tests/*.test.ts"
|
|
48
|
-
description:
|
|
48
|
+
description: 在实现之前编写的测试文件
|
|
49
49
|
template: test.md
|
|
50
50
|
instruction: |
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
在实现之前编写测试(TDD 红阶段)。
|
|
52
|
+
|
|
53
|
+
文件命名:
|
|
54
|
+
- 创建测试文件为 `tests/<feature>.test.ts`
|
|
55
|
+
- 每个特性/能力一个测试文件
|
|
56
|
+
- 使用与规格匹配的描述性名称
|
|
57
|
+
|
|
58
|
+
测试结构:
|
|
59
|
+
- 使用与规格场景匹配的 Given/When/Then 格式
|
|
60
|
+
- 使用 `describe()` 块分组相关测试
|
|
61
|
+
- 规格中的每个场景至少成为一个 `it()` 测试
|
|
62
|
+
|
|
63
|
+
覆盖要求:
|
|
64
|
+
- 覆盖规格中的每个需求
|
|
65
|
+
- 包含正常路径(成功场景)
|
|
66
|
+
- 包含边界情况(边界条件)
|
|
67
|
+
- 包含错误场景(无效输入、失败)
|
|
68
|
+
- 测试最初应该失败(还没有实现)
|
|
69
|
+
|
|
70
|
+
示例:
|
|
71
71
|
```typescript
|
|
72
72
|
describe('Password validation', () => {
|
|
73
73
|
it('accepts valid password with all requirements', () => {
|
|
74
|
-
// GIVEN
|
|
74
|
+
// GIVEN 一个满足所有要求的密码
|
|
75
75
|
const password = 'SecurePass1';
|
|
76
|
-
// WHEN
|
|
76
|
+
// WHEN 进行验证
|
|
77
77
|
const result = validatePassword(password);
|
|
78
|
-
// THEN
|
|
78
|
+
// THEN 应该被接受
|
|
79
79
|
expect(result.valid).toBe(true);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('rejects password shorter than 8 characters', () => {
|
|
83
|
-
// GIVEN
|
|
83
|
+
// GIVEN 一个短密码
|
|
84
84
|
const password = 'Short1';
|
|
85
|
-
// WHEN
|
|
85
|
+
// WHEN 进行验证
|
|
86
86
|
const result = validatePassword(password);
|
|
87
|
-
// THEN
|
|
87
|
+
// THEN 应该被拒绝并显示消息
|
|
88
88
|
expect(result.valid).toBe(false);
|
|
89
89
|
expect(result.error).toBe('Password too short');
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
严格遵循规格需求 - 测试验证规格。
|
|
95
95
|
requires:
|
|
96
96
|
- spec
|
|
97
97
|
|
|
98
98
|
- id: implementation
|
|
99
99
|
generates: "src/*.ts"
|
|
100
|
-
description:
|
|
100
|
+
description: 使测试通过的实现代码
|
|
101
101
|
template: implementation.md
|
|
102
102
|
instruction: |
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
TDD
|
|
106
|
-
1.
|
|
107
|
-
2.
|
|
108
|
-
3.
|
|
109
|
-
4.
|
|
110
|
-
5.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
实现特性以使测试通过(TDD 绿阶段)。
|
|
104
|
+
|
|
105
|
+
TDD 工作流:
|
|
106
|
+
1. 运行测试 - 确认它们失败(红)
|
|
107
|
+
2. 编写最小代码通过一个测试
|
|
108
|
+
3. 运行测试 - 确认该测试通过(绿)
|
|
109
|
+
4. 如有需要重构,同时保持测试通过
|
|
110
|
+
5. 对下一个失败的测试重复上述步骤
|
|
111
|
+
|
|
112
|
+
实现指南:
|
|
113
|
+
- 编写最小代码通过每个测试 - 不多不少
|
|
114
|
+
- 频繁运行测试以验证进度
|
|
115
|
+
- 保持函数小而专注
|
|
116
|
+
- 使用清晰、描述性的名称
|
|
117
|
+
|
|
118
|
+
代码组织:
|
|
119
|
+
- 在 `src/<feature>.ts` 中创建源文件
|
|
120
|
+
- 清晰导出公共 API
|
|
121
|
+
- 保持实现细节私有
|
|
122
|
+
- 为公共函数添加 JSDoc 注释
|
|
123
|
+
|
|
124
|
+
示例结构:
|
|
125
125
|
```typescript
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @param password -
|
|
129
|
-
* @returns
|
|
127
|
+
* 验证密码是否满足安全要求。
|
|
128
|
+
* @param password - 要验证的密码
|
|
129
|
+
* @returns 验证结果,包含有效标志和可选错误信息
|
|
130
130
|
*/
|
|
131
131
|
export function validatePassword(password: string): ValidationResult {
|
|
132
132
|
if (password.length < 8) {
|
|
133
133
|
return { valid: false, error: 'Password too short' };
|
|
134
134
|
}
|
|
135
|
-
// ...
|
|
135
|
+
// ... 额外的检查
|
|
136
136
|
return { valid: true };
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
不要过度设计 - 只实现测试要求的内容。
|
|
141
141
|
requires:
|
|
142
142
|
- tests
|
|
143
143
|
|
|
144
144
|
- id: docs
|
|
145
145
|
generates: "docs/*.md"
|
|
146
|
-
description:
|
|
146
|
+
description: 已实现特性的文档
|
|
147
147
|
template: docs.md
|
|
148
148
|
instruction: |
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
- **Overview**:
|
|
153
|
-
- **Getting Started**:
|
|
154
|
-
- **Examples**:
|
|
155
|
-
- **Reference**:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
149
|
+
为已实现的特性编写文档。
|
|
150
|
+
|
|
151
|
+
章节:
|
|
152
|
+
- **Overview**: 特性功能及存在原因(1-2 段落)
|
|
153
|
+
- **Getting Started**: 立即使用该特性的快速入门指南
|
|
154
|
+
- **Examples**: 展示常见用例的代码示例
|
|
155
|
+
- **Reference**: 详细的 API 文档、配置选项
|
|
156
|
+
|
|
157
|
+
指南:
|
|
158
|
+
- 为用户编写,而非开发者
|
|
159
|
+
- 从最常见的用例开始
|
|
160
|
+
- 包含可复制粘贴的代码示例
|
|
161
|
+
- 记录所有配置选项及其默认值
|
|
162
|
+
- 注意任何限制、边界情况或注意事项
|
|
163
|
+
- 链接到相关特性或规格
|
|
164
|
+
|
|
165
|
+
示例结构:
|
|
166
166
|
```markdown
|
|
167
167
|
## Overview
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
密码验证确保用户密码在账户创建或密码更改前
|
|
170
|
+
满足安全要求。
|
|
171
171
|
|
|
172
172
|
## Getting Started
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
导入并使用验证函数:
|
|
175
175
|
|
|
176
176
|
```typescript
|
|
177
177
|
import { validatePassword } from './password';
|
|
@@ -184,10 +184,10 @@ artifacts:
|
|
|
184
184
|
|
|
185
185
|
## Examples
|
|
186
186
|
|
|
187
|
-
###
|
|
187
|
+
### 基础验证
|
|
188
188
|
...
|
|
189
189
|
|
|
190
|
-
###
|
|
190
|
+
### 自定义错误处理
|
|
191
191
|
...
|
|
192
192
|
|
|
193
193
|
## Reference
|
|
@@ -196,12 +196,12 @@ artifacts:
|
|
|
196
196
|
|
|
197
197
|
| Parameter | Type | Description |
|
|
198
198
|
|-----------|------|-------------|
|
|
199
|
-
| password | string |
|
|
199
|
+
| password | string | 要验证的密码 |
|
|
200
200
|
|
|
201
201
|
**Returns**: `{ valid: boolean, error?: string }`
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
参考规格了解需求,参考实现了解细节。
|
|
205
205
|
requires:
|
|
206
206
|
- implementation
|
|
207
207
|
|
|
@@ -209,5 +209,5 @@ apply:
|
|
|
209
209
|
requires: [tests]
|
|
210
210
|
tracks: null
|
|
211
211
|
instruction: |
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
运行测试查看失败。编写最小代码通过每个测试。
|
|
213
|
+
在保持测试通过的同时进行重构。
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 功能:<!-- 功能名称 -->
|
|
2
2
|
|
|
3
|
-
<!--
|
|
3
|
+
<!-- 功能描述 -->
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 需求
|
|
6
6
|
|
|
7
|
-
<!--
|
|
7
|
+
<!-- 需求列表 -->
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 验收标准
|
|
10
10
|
|
|
11
|
-
<!--
|
|
11
|
+
<!-- 验收标准列表 -->
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 测试计划
|
|
2
2
|
|
|
3
|
-
<!--
|
|
3
|
+
<!-- 描述测试策略 -->
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 测试用例
|
|
6
6
|
|
|
7
|
-
### <!--
|
|
7
|
+
### <!-- 测试用例名称 -->
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
9
|
+
- **假设:** <!-- 前置条件 -->
|
|
10
|
+
- **当:** <!-- 操作 -->
|
|
11
|
+
- **则:** <!-- 预期结果 -->
|