@zhuan-ai/zhuanspec 2.2.4 → 2.4.8

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 (103) hide show
  1. package/bin/zhuanspec-hook.js +3 -0
  2. package/dist/cli/hooks.d.ts +14 -0
  3. package/dist/cli/hooks.js +465 -0
  4. package/dist/cli/index.js +100 -0
  5. package/dist/commands/artifact-workflow.js +15 -34
  6. package/dist/commands/design.d.ts +42 -0
  7. package/dist/commands/design.js +337 -0
  8. package/dist/commands/progress.d.ts +32 -0
  9. package/dist/commands/progress.js +278 -0
  10. package/dist/commands/review.d.ts +32 -0
  11. package/dist/commands/review.js +472 -0
  12. package/dist/commands/validate.d.ts +14 -0
  13. package/dist/commands/validate.js +161 -10
  14. package/dist/core/archive.d.ts +1 -0
  15. package/dist/core/archive.js +45 -3
  16. package/dist/core/completions/command-registry.js +67 -0
  17. package/dist/core/configurators/slash/amazon-q.js +32 -2
  18. package/dist/core/configurators/slash/antigravity.js +8 -2
  19. package/dist/core/configurators/slash/auggie.js +16 -1
  20. package/dist/core/configurators/slash/base.js +1 -1
  21. package/dist/core/configurators/slash/claude.d.ts +4 -0
  22. package/dist/core/configurators/slash/claude.js +56 -1
  23. package/dist/core/configurators/slash/cline.js +8 -2
  24. package/dist/core/configurators/slash/codebuddy.js +22 -1
  25. package/dist/core/configurators/slash/codex.js +21 -0
  26. package/dist/core/configurators/slash/costrict.js +15 -0
  27. package/dist/core/configurators/slash/crush.js +22 -1
  28. package/dist/core/configurators/slash/cursor.js +22 -1
  29. package/dist/core/configurators/slash/factory.js +16 -1
  30. package/dist/core/configurators/slash/gemini.js +8 -2
  31. package/dist/core/configurators/slash/github-copilot.js +19 -1
  32. package/dist/core/configurators/slash/iflow.js +22 -1
  33. package/dist/core/configurators/slash/kilocode.js +4 -1
  34. package/dist/core/configurators/slash/opencode.js +27 -0
  35. package/dist/core/configurators/slash/qoder.d.ts +4 -0
  36. package/dist/core/configurators/slash/qoder.js +59 -1
  37. package/dist/core/configurators/slash/qwen.js +8 -2
  38. package/dist/core/configurators/slash/roocode.js +8 -2
  39. package/dist/core/configurators/slash/windsurf.js +8 -2
  40. package/dist/core/dashboard/metrics.d.ts +33 -0
  41. package/dist/core/dashboard/metrics.js +114 -0
  42. package/dist/core/hooks/collect-knowledge.d.ts +16 -0
  43. package/dist/core/hooks/collect-knowledge.js +203 -0
  44. package/dist/core/hooks/context-load-hook.d.ts +25 -0
  45. package/dist/core/hooks/context-load-hook.js +159 -0
  46. package/dist/core/hooks/deviation-check.d.ts +27 -0
  47. package/dist/core/hooks/deviation-check.js +403 -0
  48. package/dist/core/hooks/deviation-handler.d.ts +43 -0
  49. package/dist/core/hooks/deviation-handler.js +98 -0
  50. package/dist/core/hooks/init.d.ts +14 -0
  51. package/dist/core/hooks/init.js +244 -0
  52. package/dist/core/hooks/notify-milestone.d.ts +14 -0
  53. package/dist/core/hooks/notify-milestone.js +170 -0
  54. package/dist/core/hooks/post-apply.d.ts +29 -0
  55. package/dist/core/hooks/post-apply.js +173 -0
  56. package/dist/core/hooks/post-archive.d.ts +7 -0
  57. package/dist/core/hooks/post-archive.js +208 -0
  58. package/dist/core/hooks/pre-apply.d.ts +34 -0
  59. package/dist/core/hooks/pre-apply.js +139 -0
  60. package/dist/core/hooks/pre-archive.d.ts +7 -0
  61. package/dist/core/hooks/pre-archive.js +50 -0
  62. package/dist/core/hooks/record-progress.d.ts +49 -0
  63. package/dist/core/hooks/record-progress.js +494 -0
  64. package/dist/core/hooks/review-hooks.d.ts +89 -0
  65. package/dist/core/hooks/review-hooks.js +345 -0
  66. package/dist/core/hooks/review-orchestrator.d.ts +40 -0
  67. package/dist/core/hooks/review-orchestrator.js +146 -0
  68. package/dist/core/hooks/summarize.d.ts +15 -0
  69. package/dist/core/hooks/summarize.js +282 -0
  70. package/dist/core/hooks/user-input-hook.d.ts +25 -0
  71. package/dist/core/hooks/user-input-hook.js +179 -0
  72. package/dist/core/init.d.ts +8 -0
  73. package/dist/core/init.js +251 -23
  74. package/dist/core/parsers/requirement-blocks.js +13 -10
  75. package/dist/core/templates/agents-template.d.ts +1 -1
  76. package/dist/core/templates/agents-template.js +510 -243
  77. package/dist/core/templates/index.d.ts +1 -0
  78. package/dist/core/templates/index.js +1 -0
  79. package/dist/core/templates/skill-templates.js +46 -152
  80. package/dist/core/templates/slash-command-templates.d.ts +1 -1
  81. package/dist/core/templates/slash-command-templates.js +352 -20
  82. package/dist/core/templates/tasks-template.d.ts +7 -0
  83. package/dist/core/templates/tasks-template.js +130 -24
  84. package/dist/core/templates/tdd-tasks-template.d.ts +3 -0
  85. package/dist/core/templates/tdd-tasks-template.js +91 -38
  86. package/dist/core/templates/test-cases-template.d.ts +41 -0
  87. package/dist/core/templates/test-cases-template.js +128 -0
  88. package/dist/core/validation/strict-rules.d.ts +44 -5
  89. package/dist/core/validation/strict-rules.js +302 -8
  90. package/dist/core/validation/validator.js +52 -2
  91. package/dist/core/view.d.ts +1 -0
  92. package/dist/core/view.js +60 -2
  93. package/dist/mcp/index.d.ts +28 -0
  94. package/dist/mcp/index.js +31 -0
  95. package/dist/utils/file-system.d.ts +1 -0
  96. package/dist/utils/file-system.js +11 -0
  97. package/dist/utils/item-discovery.js +24 -2
  98. package/dist/utils/phase-utils.d.ts +36 -0
  99. package/dist/utils/phase-utils.js +117 -0
  100. package/package.json +22 -23
  101. package/schemas/spec-driven/schema.yaml +45 -31
  102. package/schemas/spec-driven/templates/spec.md +142 -5
  103. package/schemas/spec-driven/templates/tasks.md +73 -9
@@ -14,4 +14,5 @@ export declare class TemplateManager {
14
14
  }
15
15
  export { ProjectContext } from './project-template.js';
16
16
  export type { SlashCommandId } from './slash-command-templates.js';
17
+ export { getTestCasesTemplate, getMinimalTestCasesTemplate, formatFetchedTestCases, TestCasesTemplateOptions } from './test-cases-template.js';
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -34,4 +34,5 @@ export class TemplateManager {
34
34
  return getSlashCommandBody(id);
35
35
  }
36
36
  }
37
+ export { getTestCasesTemplate, getMinimalTestCasesTemplate, formatFetchedTestCases } from './test-cases-template.js';
37
38
  //# sourceMappingURL=index.js.map
@@ -37,7 +37,7 @@ export function getNewChangeSkillTemplate() {
37
37
  Use the **AskUserQuestion tool** to let the user choose a workflow:
38
38
  - Present each schema with its description
39
39
  - Mark \`spec-driven\` as "(default)" if it's available
40
- - Example options: "spec-driven - proposal → specs → design → tasks (default)", "tdd - tests → implementation → docs"
40
+ - Example options: "spec-driven - techDesign(design) → proposal → specs → tasks (default)", "tdd - tests → implementation → docs"
41
41
 
42
42
  If user doesn't have a preference, default to \`spec-driven\`.
43
43
 
@@ -169,7 +169,7 @@ The artifact types and their purpose depend on the schema. Use the \`instruction
169
169
 
170
170
  Common artifact patterns:
171
171
 
172
- **spec-driven schema** (proposal → specs → design → tasks):
172
+ **spec-driven schema** (techDesign(design) → proposal → specs → tasks):
173
173
  - **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
174
174
  - The Capabilities section is critical - each capability listed will need a spec file.
175
175
  - **specs/*.md**: Create one spec per capability listed in the proposal.
@@ -265,6 +265,7 @@ export function getApplyChangeSkillTemplate() {
265
265
  - Parse the task text for \`@skill\` tags (format: \`@skill:name1,name2\`)
266
266
  - If \`@skill\` tags found, invoke the corresponding skill(s) for guidance before making changes
267
267
  - Make the code changes required
268
+ - Apply 阶段不生成单元测试文件;仅完成功能实现并保持任务状态准确
268
269
  - Keep changes minimal and focused
269
270
  - Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
270
271
  - Continue to next task
@@ -283,80 +284,26 @@ export function getApplyChangeSkillTemplate() {
283
284
  - If all done: proceed to code review step (step 8)
284
285
  - If paused: explain why and wait for guidance
285
286
 
286
- 8. **Code Review (when all tasks complete)**
287
+ 8. **三轨并行审查门禁(auto, once after all tasks complete)**
287
288
 
288
289
  **WHEN** all tasks are complete (\`state: "all_done"\`):
289
-
290
- a. **Prompt for code review**
291
-
292
- Use the **AskUserQuestion tool** with options:
293
- - "是,进行代码审查" / "Yes, perform code review"
294
- - "跳过,直接归档" / "Skip, proceed to archive"
295
-
296
- Wait for user selection before proceeding.
297
-
298
- b. **If user selects "Yes, perform code review"**:
299
-
300
- 1. **Read code files related to the change**
301
- - Based on context files from apply instructions
302
- - Scan the change directory for code files (e.g., \`*.java\`, \`*.ts\`, \`*.py\`, etc.)
303
- - Read all relevant code files that were modified or created for this change
304
-
305
- 2. **Perform code review**
306
-
307
- Review code for:
308
- - **Code standards and conventions compliance**: naming, formatting, structure
309
- - **Logic correctness**: edge cases, error handling, business logic
310
- - **Performance issues**: inefficient algorithms, unnecessary operations, potential bottlenecks
311
- - **Security concerns**: input validation, authentication, authorization, data exposure
312
- - **Best practices adherence**: design patterns, SOLID principles, maintainability
313
-
314
- **For Java code specifically**, pay special attention to:
315
- - Java-specific patterns and conventions (e.g., builder pattern, factory pattern)
316
- - Common Java pitfalls:
317
- - Null handling (NullPointerException prevention)
318
- - Exception handling (proper try-catch, resource management)
319
- - Resource management (try-with-resources, closing streams/connections)
320
- - Performance considerations:
321
- - Collections usage (ArrayList vs LinkedList, HashMap vs TreeMap)
322
- - Streams vs loops (when to use each)
323
- - Concurrency (thread safety, synchronization)
324
-
325
- 3. **Generate review report**
326
-
327
- Create a structured report listing:
328
- - **Issues found** (if any):
329
- - Severity (Critical, High, Medium, Low)
330
- - Location (file path and line number)
331
- - Description
332
- - Suggestion for improvement
333
- - **Suggestions for improvement** (even if no critical issues)
334
- - **Positive findings** (good practices observed)
335
-
336
- 4. **Handle review results**
337
-
338
- - **If issues are found**:
339
-
340
- Display the review report with all issues.
341
-
342
- Use **AskUserQuestion tool** with options:
343
- - "是,现在修复" / "Yes, fix now"
344
- - "稍后修复" / "Fix later"
345
- - "跳过" / "Skip"
346
-
347
- - If user chooses "Yes, fix now": proceed with fixing the issues one by one
348
- - If user chooses "Fix later" or "Skip": continue to archive workflow
349
-
350
- - **If no issues are found**:
351
-
352
- Display: "代码审查完成,未发现问题。" (or "Code review complete. No issues found.")
353
- Proceed to suggest archive workflow.
354
-
355
- c. **If user selects "Skip, proceed to archive"**:
356
-
357
- Skip the code review step.
358
- Proceed directly to suggesting archive workflow.
359
- The workflow SHALL NOT be blocked.
290
+
291
+ 1. 并行执行三条轨道(not per task, only once after all tasks complete):
292
+ - 轨道 A(CR):invoke \`code-review-expert\` skill.
293
+ - 轨道 B(UT):invoke \`generate-mockito-unit-test-skill\` 并执行测试命令.
294
+ - 轨道 C(Spec-Code):run \`zhuanspec validate <change-id> --strict\` 并确认 \`spec-code-consistent\` 通过.
295
+
296
+ 2. 汇总执行一次 \`zhuanspec review <change-id>\` 产出统一报告。
297
+
298
+ 3. Gate criteria:
299
+ - Review PASSED and Critical = 0.
300
+ - Unit tests PASSED.
301
+ - Spec-Code consistency PASSED.
302
+ - Coverage meets threshold when configured.
303
+
304
+ 4. If gate fails:
305
+ - Fix issues, rerun tests/strict validation, rerun \`zhuanspec review\`.
306
+ - Do not proceed to archive until gate passes.
360
307
 
361
308
  **Output During Implementation**
362
309
 
@@ -708,8 +655,8 @@ Main specs are now updated. The change remains active - archive when implementat
708
655
  export function getProposeChangeSkillTemplate() {
709
656
  return {
710
657
  name: 'zhuanspec-propose-change',
711
- description: 'Create a complete ZhuanSpec change proposal in one step. Use when the user wants to propose a new feature, fix, or modification. Generates proposal, specs, design, and tasks all at once.',
712
- instructions: `Create a complete change proposal in one step - proposal, specs, design, and tasks.
658
+ description: 'Create a complete ZhuanSpec change proposal in one step. Use when the user wants to propose a new feature, fix, or modification. Generates design, proposal, specs, and tasks all at once.',
659
+ instructions: `Create a complete change proposal in one step - design, proposal, specs, and tasks.
713
660
 
714
661
  **Input**: The user's request should describe what they want to build or change. Can include a change name (kebab-case) or a natural language description.
715
662
 
@@ -764,7 +711,7 @@ export function getProposeChangeSkillTemplate() {
764
711
  zhuanspec status --change "<name>" --json
765
712
  \`\`\`
766
713
 
767
- b. **For each artifact in dependency order** (proposal → specs → design → tasks):
714
+ b. **For each artifact in dependency order** (techDesign(design) → proposal → specs → tasks):
768
715
  - Get instructions: \`zhuanspec instructions <artifact-id> --change "<name>" --json\`
769
716
  - Read any completed dependency files for context
770
717
  - **For proposal artifact**: When filling Skill Mapping section, analyze each skill's description and match based on actual functionality (not just module names). Simple changes like enum modifications should map to general coding standards, not architecture-level skills.
@@ -1055,7 +1002,7 @@ export function getOpsxProposeCommandTemplate() {
1055
1002
  4. **Generate all planning artifacts** in dependency order:
1056
1003
  - For each artifact: \`zhuanspec instructions <id> --change "<name>" --json\`
1057
1004
  - Read dependencies, create artifact, show progress
1058
- - Artifacts: proposal.md → specs/ → design.md (if needed) → tasks.md
1005
+ - Artifacts: design.md(techDesign 阶段产物)→ proposal.md → specs/ → tasks.md
1059
1006
 
1060
1007
  ⚠️ **CHECKPOINT [SKILL-TAGGING]**:
1061
1008
  1. You MUST run \`zhuanspec skills list\` first and record discovered skills in the Skill Mapping table
@@ -1193,7 +1140,7 @@ export function getOpsxNewCommandTemplate() {
1193
1140
  Use the **AskUserQuestion tool** to let the user choose a workflow:
1194
1141
  - Present each schema with its description
1195
1142
  - Mark \`spec-driven\` as "(default)" if it's available
1196
- - Example options: "spec-driven - proposal → specs → design → tasks (default)", "tdd - tests → implementation → docs"
1143
+ - Example options: "spec-driven - techDesign(design) → proposal → specs → tasks (default)", "tdd - tests → implementation → docs"
1197
1144
 
1198
1145
  If user doesn't have a preference, default to \`spec-driven\`.
1199
1146
 
@@ -1325,7 +1272,7 @@ The artifact types and their purpose depend on the schema. Use the \`instruction
1325
1272
 
1326
1273
  Common artifact patterns:
1327
1274
 
1328
- **spec-driven schema** (proposal → specs → design → tasks):
1275
+ **spec-driven schema** (techDesign(design) → proposal → specs → tasks):
1329
1276
  - **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
1330
1277
  - The Capabilities section is critical - each capability listed will need a spec file.
1331
1278
  - **specs/*.md**: Create one spec per capability listed in the proposal.
@@ -1422,6 +1369,7 @@ export function getOpsxApplyCommandTemplate() {
1422
1369
  - Parse the task text for \`@skill\` tags (format: \`@skill:name1,name2\`)
1423
1370
  - If \`@skill\` tags found, invoke the corresponding skill(s) for guidance before making changes
1424
1371
  - Make the code changes required
1372
+ - Apply 阶段不生成单元测试文件;仅完成功能实现并保持任务状态准确
1425
1373
  - Keep changes minimal and focused
1426
1374
  - Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
1427
1375
  - Continue to next task
@@ -1440,80 +1388,26 @@ export function getOpsxApplyCommandTemplate() {
1440
1388
  - If all done: proceed to code review step (step 8)
1441
1389
  - If paused: explain why and wait for guidance
1442
1390
 
1443
- 8. **Code Review (when all tasks complete)**
1391
+ 8. **三轨并行审查门禁(auto, once after all tasks complete)**
1444
1392
 
1445
1393
  **WHEN** all tasks are complete (\`state: "all_done"\`):
1446
-
1447
- a. **Prompt for code review**
1448
-
1449
- Use the **AskUserQuestion tool** with options:
1450
- - "是,进行代码审查" / "Yes, perform code review"
1451
- - "跳过,直接归档" / "Skip, proceed to archive"
1452
-
1453
- Wait for user selection before proceeding.
1454
-
1455
- b. **If user selects "Yes, perform code review"**:
1456
-
1457
- 1. **Read code files related to the change**
1458
- - Based on context files from apply instructions
1459
- - Scan the change directory for code files (e.g., \`*.java\`, \`*.ts\`, \`*.py\`, etc.)
1460
- - Read all relevant code files that were modified or created for this change
1461
-
1462
- 2. **Perform code review**
1463
-
1464
- Review code for:
1465
- - **Code standards and conventions compliance**: naming, formatting, structure
1466
- - **Logic correctness**: edge cases, error handling, business logic
1467
- - **Performance issues**: inefficient algorithms, unnecessary operations, potential bottlenecks
1468
- - **Security concerns**: input validation, authentication, authorization, data exposure
1469
- - **Best practices adherence**: design patterns, SOLID principles, maintainability
1470
-
1471
- **For Java code specifically**, pay special attention to:
1472
- - Java-specific patterns and conventions (e.g., builder pattern, factory pattern)
1473
- - Common Java pitfalls:
1474
- - Null handling (NullPointerException prevention)
1475
- - Exception handling (proper try-catch, resource management)
1476
- - Resource management (try-with-resources, closing streams/connections)
1477
- - Performance considerations:
1478
- - Collections usage (ArrayList vs LinkedList, HashMap vs TreeMap)
1479
- - Streams vs loops (when to use each)
1480
- - Concurrency (thread safety, synchronization)
1481
-
1482
- 3. **Generate review report**
1483
-
1484
- Create a structured report listing:
1485
- - **Issues found** (if any):
1486
- - Severity (Critical, High, Medium, Low)
1487
- - Location (file path and line number)
1488
- - Description
1489
- - Suggestion for improvement
1490
- - **Suggestions for improvement** (even if no critical issues)
1491
- - **Positive findings** (good practices observed)
1492
-
1493
- 4. **Handle review results**
1494
-
1495
- - **If issues are found**:
1496
-
1497
- Display the review report with all issues.
1498
-
1499
- Use **AskUserQuestion tool** with options:
1500
- - "是,现在修复" / "Yes, fix now"
1501
- - "稍后修复" / "Fix later"
1502
- - "跳过" / "Skip"
1503
-
1504
- - If user chooses "Yes, fix now": proceed with fixing the issues one by one
1505
- - If user chooses "Fix later" or "Skip": continue to archive workflow
1506
-
1507
- - **If no issues are found**:
1508
-
1509
- Display: "代码审查完成,未发现问题。" (or "Code review complete. No issues found.")
1510
- Proceed to suggest archive workflow.
1511
-
1512
- c. **If user selects "Skip, proceed to archive"**:
1513
-
1514
- Skip the code review step.
1515
- Proceed directly to suggesting archive workflow.
1516
- The workflow SHALL NOT be blocked.
1394
+
1395
+ 1. 并行执行三条轨道(not per task, only once after all tasks complete):
1396
+ - 轨道 A(CR):invoke \`code-review-expert\` skill.
1397
+ - 轨道 B(UT):invoke \`generate-mockito-unit-test-skill\` 并执行测试命令.
1398
+ - 轨道 C(Spec-Code):run \`zhuanspec validate <change-id> --strict\` 并确认 \`spec-code-consistent\` 通过.
1399
+
1400
+ 2. 汇总执行一次 \`zhuanspec review <change-id>\` 产出统一报告。
1401
+
1402
+ 3. Gate criteria:
1403
+ - Review PASSED and Critical = 0.
1404
+ - Unit tests PASSED.
1405
+ - Spec-Code consistency PASSED.
1406
+ - Coverage meets threshold when configured.
1407
+
1408
+ 4. If gate fails:
1409
+ - Fix issues, rerun tests/strict validation, rerun \`zhuanspec review\`.
1410
+ - Do not proceed to archive until gate passes.
1517
1411
 
1518
1412
  **Output During Implementation**
1519
1413
 
@@ -1,4 +1,4 @@
1
- export type SlashCommandId = 'proposal' | 'apply' | 'archive';
1
+ export type SlashCommandId = 'proposal' | 'design' | 'apply' | 'review' | 'archive' | 'knowledge';
2
2
  export declare const slashCommandBodies: Record<SlashCommandId, string>;
3
3
  export declare function getSlashCommandBody(id: SlashCommandId): string;
4
4
  //# sourceMappingURL=slash-command-templates.d.ts.map