@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.
Files changed (33) hide show
  1. package/README.zh.md +1 -1
  2. package/dist/cli/index.js +1 -1
  3. package/dist/commands/artifact-workflow.js +22 -2
  4. package/dist/commands/validate.d.ts +5 -0
  5. package/dist/commands/validate.js +65 -3
  6. package/dist/core/skill-discovery.d.ts +2 -2
  7. package/dist/core/skill-discovery.js +16 -3
  8. package/dist/core/task-graph/index.d.ts +2 -0
  9. package/dist/core/task-graph/index.js +2 -0
  10. package/dist/core/task-graph/mermaid-renderer.d.ts +22 -0
  11. package/dist/core/task-graph/mermaid-renderer.js +128 -0
  12. package/dist/core/templates/agents-template.d.ts +1 -1
  13. package/dist/core/templates/agents-template.js +60 -37
  14. package/dist/core/templates/skill-templates.js +42 -0
  15. package/dist/core/templates/slash-command-templates.js +25 -2
  16. package/dist/core/templates/tasks-template.d.ts +23 -0
  17. package/dist/core/templates/tasks-template.js +79 -0
  18. package/dist/core/templates/tdd-tasks-template.d.ts +24 -0
  19. package/dist/core/templates/tdd-tasks-template.js +116 -0
  20. package/dist/core/validation/strict-rules.d.ts +60 -0
  21. package/dist/core/validation/strict-rules.js +287 -0
  22. package/dist/core/validation/types.d.ts +10 -0
  23. package/dist/core/validation/validator.d.ts +5 -0
  24. package/dist/core/validation/validator.js +103 -1
  25. package/package.json +1 -1
  26. package/schemas/spec-driven/schema.yaml +13 -13
  27. package/schemas/spec-driven/templates/design.md +6 -6
  28. package/schemas/spec-driven/templates/proposal.md +7 -7
  29. package/schemas/spec-driven/templates/spec.md +4 -4
  30. package/schemas/tdd/schema.yaml +107 -107
  31. package/schemas/tdd/templates/implementation.md +5 -5
  32. package/schemas/tdd/templates/spec.md +6 -6
  33. package/schemas/tdd/templates/test.md +7 -7
@@ -1,177 +1,177 @@
1
1
  name: tdd
2
2
  version: 1
3
- description: Test-driven development workflow - tests → implementation → docs
3
+ description: 测试驱动开发工作流 - 测试 → 实现 → 文档
4
4
  artifacts:
5
5
  - id: spec
6
6
  generates: spec.md
7
- description: Feature specification defining requirements
7
+ description: 定义需求的特性规格说明
8
8
  template: spec.md
9
9
  instruction: |
10
- Create the feature specification that defines WHAT to build.
10
+ 创建定义「要构建什么」的特性规格说明。
11
11
 
12
- Sections:
13
- - **Feature**: Name and high-level description of the feature's purpose and user value
14
- - **Requirements**: List of specific requirements. Use SHALL/MUST for normative language.
15
- - **Acceptance Criteria**: Testable criteria in WHEN/THEN format
12
+ 章节:
13
+ - **Feature**: 特性名称及高层描述,说明其用途和用户价值
14
+ - **Requirements**: 具体需求列表。使用 SHALL/MUST 作为规范性语言。
15
+ - **Acceptance Criteria**: 使用 WHEN/THEN 格式的可测试验收标准
16
16
 
17
- Format requirements:
18
- - Each requirement should be specific and testable
19
- - Use `#### Scenario: <name>` with WHEN/THEN format for acceptance criteria
20
- - Define edge cases and error scenarios explicitly
21
- - Every requirement MUST have at least one scenario
17
+ 格式要求:
18
+ - 每个需求应具体且可测试
19
+ - 使用 `#### Scenario: <名称>` 配合 WHEN/THEN 格式编写验收标准
20
+ - 明确定义边界情况和错误场景
21
+ - 每个需求必须至少有一个场景
22
22
 
23
- Example:
23
+ 示例:
24
24
  ```
25
- ## Feature: User Authentication
25
+ ## Feature: 用户认证
26
26
 
27
- Users can securely log into the application.
27
+ 用户可以安全地登录应用程序。
28
28
 
29
29
  ## Requirements
30
30
 
31
- ### Requirement: Password validation
32
- The system SHALL validate passwords meet minimum security requirements.
31
+ ### Requirement: 密码验证
32
+ 系统 SHALL 验证密码满足最低安全要求。
33
33
 
34
- #### Scenario: Valid password accepted
35
- - **WHEN** password has 8+ chars, uppercase, lowercase, and number
36
- - **THEN** password is accepted
34
+ #### Scenario: 有效密码被接受
35
+ - **WHEN** 密码包含 8+ 字符、大写字母、小写字母和数字
36
+ - **THEN** 密码被接受
37
37
 
38
- #### Scenario: Weak password rejected
39
- - **WHEN** password is less than 8 characters
40
- - **THEN** system displays "Password too short" error
38
+ #### Scenario: 弱密码被拒绝
39
+ - **WHEN** 密码少于 8 个字符
40
+ - **THEN** 系统显示 "Password too short" 错误
41
41
  ```
42
42
 
43
- This spec drives test creation - each scenario becomes a test case.
43
+ 此规格驱动测试创建 - 每个场景成为一个测试用例。
44
44
  requires: []
45
45
 
46
46
  - id: tests
47
47
  generates: "tests/*.test.ts"
48
- description: Test files written before implementation
48
+ description: 在实现之前编写的测试文件
49
49
  template: test.md
50
50
  instruction: |
51
- Write tests BEFORE implementation (TDD red phase).
52
-
53
- File naming:
54
- - Create test files as `tests/<feature>.test.ts`
55
- - One test file per feature/capability
56
- - Use descriptive names matching the spec
57
-
58
- Test structure:
59
- - Use Given/When/Then format matching spec scenarios
60
- - Group related tests with `describe()` blocks
61
- - Each scenario from spec becomes at least one `it()` test
62
-
63
- Coverage requirements:
64
- - Cover each requirement from the spec
65
- - Include happy path (success cases)
66
- - Include edge cases (boundary conditions)
67
- - Include error scenarios (invalid input, failures)
68
- - Tests should fail initially (no implementation yet)
69
-
70
- Example:
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 a password meeting all requirements
74
+ // GIVEN 一个满足所有要求的密码
75
75
  const password = 'SecurePass1';
76
- // WHEN validating
76
+ // WHEN 进行验证
77
77
  const result = validatePassword(password);
78
- // THEN it should be accepted
78
+ // THEN 应该被接受
79
79
  expect(result.valid).toBe(true);
80
80
  });
81
81
 
82
82
  it('rejects password shorter than 8 characters', () => {
83
- // GIVEN a short password
83
+ // GIVEN 一个短密码
84
84
  const password = 'Short1';
85
- // WHEN validating
85
+ // WHEN 进行验证
86
86
  const result = validatePassword(password);
87
- // THEN it should be rejected with message
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
- Follow the spec requirements exactly - tests verify the spec.
94
+ 严格遵循规格需求 - 测试验证规格。
95
95
  requires:
96
96
  - spec
97
97
 
98
98
  - id: implementation
99
99
  generates: "src/*.ts"
100
- description: Implementation code to pass the tests
100
+ description: 使测试通过的实现代码
101
101
  template: implementation.md
102
102
  instruction: |
103
- Implement the feature to make tests pass (TDD green phase).
104
-
105
- TDD workflow:
106
- 1. Run tests - confirm they fail (red)
107
- 2. Write minimal code to pass ONE test
108
- 3. Run tests - confirm that test passes (green)
109
- 4. Refactor if needed while keeping tests green
110
- 5. Repeat for next failing test
111
-
112
- Implementation guidelines:
113
- - Write minimal code to pass each test - no more, no less
114
- - Run tests frequently to verify progress
115
- - Keep functions small and focused
116
- - Use clear, descriptive names
117
-
118
- Code organization:
119
- - Create source files in `src/<feature>.ts`
120
- - Export public API clearly
121
- - Keep implementation details private
122
- - Add JSDoc comments for public functions
123
-
124
- Example structure:
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
- * Validates a password meets security requirements.
128
- * @param password - The password to validate
129
- * @returns Validation result with valid flag and optional error
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
- // ... additional checks
135
+ // ... 额外的检查
136
136
  return { valid: true };
137
137
  }
138
138
  ```
139
139
 
140
- Don't over-engineer - implement only what tests require.
140
+ 不要过度设计 - 只实现测试要求的内容。
141
141
  requires:
142
142
  - tests
143
143
 
144
144
  - id: docs
145
145
  generates: "docs/*.md"
146
- description: Documentation for the implemented feature
146
+ description: 已实现特性的文档
147
147
  template: docs.md
148
148
  instruction: |
149
- Document the implemented feature.
150
-
151
- Sections:
152
- - **Overview**: What the feature does and why it exists (1-2 paragraphs)
153
- - **Getting Started**: Quick start guide to use the feature immediately
154
- - **Examples**: Code examples showing common use cases
155
- - **Reference**: Detailed API documentation, configuration options
156
-
157
- Guidelines:
158
- - Write for the user, not the developer
159
- - Start with the most common use case
160
- - Include copy-pasteable code examples
161
- - Document all configuration options with defaults
162
- - Note any limitations, edge cases, or gotchas
163
- - Link to related features or specs
164
-
165
- Example structure:
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
- Password validation ensures user passwords meet security requirements
170
- before account creation or password changes.
169
+ 密码验证确保用户密码在账户创建或密码更改前
170
+ 满足安全要求。
171
171
 
172
172
  ## Getting Started
173
173
 
174
- Import and use the validation function:
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
- ### Basic validation
187
+ ### 基础验证
188
188
  ...
189
189
 
190
- ### Custom error handling
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 | The password to validate |
199
+ | password | string | 要验证的密码 |
200
200
 
201
201
  **Returns**: `{ valid: boolean, error?: string }`
202
202
  ```
203
203
 
204
- Reference the spec for requirements, implementation for details.
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
- Run tests to see failures. Implement minimal code to pass each test.
213
- Refactor while keeping tests green.
212
+ 运行测试查看失败。编写最小代码通过每个测试。
213
+ 在保持测试通过的同时进行重构。
@@ -1,11 +1,11 @@
1
- ## Implementation Notes
1
+ ## 实现说明
2
2
 
3
- <!-- Technical implementation details -->
3
+ <!-- 技术实现细节 -->
4
4
 
5
5
  ## API
6
6
 
7
- <!-- Public API documentation -->
7
+ <!-- 公共 API 文档 -->
8
8
 
9
- ## Usage
9
+ ## 用法
10
10
 
11
- <!-- Usage examples -->
11
+ <!-- 用法示例 -->
@@ -1,11 +1,11 @@
1
- ## Feature: <!-- feature name -->
1
+ ## 功能:<!-- 功能名称 -->
2
2
 
3
- <!-- Feature description -->
3
+ <!-- 功能描述 -->
4
4
 
5
- ## Requirements
5
+ ## 需求
6
6
 
7
- <!-- List of requirements -->
7
+ <!-- 需求列表 -->
8
8
 
9
- ## Acceptance Criteria
9
+ ## 验收标准
10
10
 
11
- <!-- List of acceptance criteria -->
11
+ <!-- 验收标准列表 -->
@@ -1,11 +1,11 @@
1
- ## Test Plan
1
+ ## 测试计划
2
2
 
3
- <!-- Describe the testing strategy -->
3
+ <!-- 描述测试策略 -->
4
4
 
5
- ## Test Cases
5
+ ## 测试用例
6
6
 
7
- ### <!-- Test case name -->
7
+ ### <!-- 测试用例名称 -->
8
8
 
9
- - **Given:** <!-- preconditions -->
10
- - **When:** <!-- action -->
11
- - **Then:** <!-- expected result -->
9
+ - **假设:** <!-- 前置条件 -->
10
+ - **当:** <!-- 操作 -->
11
+ - **则:** <!-- 预期结果 -->