@zhuan-ai/zhuanspec 2.2.5 → 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 -244
  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 -156
  80. package/dist/core/templates/slash-command-templates.d.ts +1 -1
  81. package/dist/core/templates/slash-command-templates.js +352 -21
  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,8 +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
- - If the task mentions unit tests ("单元测试", "UT", "unit test"), AFTER code generation you MUST invoke \`generate-mockito-unit-test\` (or \`generate-mockito-unit-test-skill\`) to generate tests
269
- - Run unit tests and verify they pass (e.g., \`mvn -Dtest=<TestClass> test\` or module-level \`mvn test\`); do not mark task complete until tests pass
268
+ - Apply 阶段不生成单元测试文件;仅完成功能实现并保持任务状态准确
270
269
  - Keep changes minimal and focused
271
270
  - Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
272
271
  - Continue to next task
@@ -285,80 +284,26 @@ export function getApplyChangeSkillTemplate() {
285
284
  - If all done: proceed to code review step (step 8)
286
285
  - If paused: explain why and wait for guidance
287
286
 
288
- 8. **Code Review (when all tasks complete)**
287
+ 8. **三轨并行审查门禁(auto, once after all tasks complete)**
289
288
 
290
289
  **WHEN** all tasks are complete (\`state: "all_done"\`):
291
-
292
- a. **Prompt for code review**
293
-
294
- Use the **AskUserQuestion tool** with options:
295
- - "是,进行代码审查" / "Yes, perform code review"
296
- - "跳过,直接归档" / "Skip, proceed to archive"
297
-
298
- Wait for user selection before proceeding.
299
-
300
- b. **If user selects "Yes, perform code review"**:
301
-
302
- 1. **Read code files related to the change**
303
- - Based on context files from apply instructions
304
- - Scan the change directory for code files (e.g., \`*.java\`, \`*.ts\`, \`*.py\`, etc.)
305
- - Read all relevant code files that were modified or created for this change
306
-
307
- 2. **Perform code review**
308
-
309
- Review code for:
310
- - **Code standards and conventions compliance**: naming, formatting, structure
311
- - **Logic correctness**: edge cases, error handling, business logic
312
- - **Performance issues**: inefficient algorithms, unnecessary operations, potential bottlenecks
313
- - **Security concerns**: input validation, authentication, authorization, data exposure
314
- - **Best practices adherence**: design patterns, SOLID principles, maintainability
315
-
316
- **For Java code specifically**, pay special attention to:
317
- - Java-specific patterns and conventions (e.g., builder pattern, factory pattern)
318
- - Common Java pitfalls:
319
- - Null handling (NullPointerException prevention)
320
- - Exception handling (proper try-catch, resource management)
321
- - Resource management (try-with-resources, closing streams/connections)
322
- - Performance considerations:
323
- - Collections usage (ArrayList vs LinkedList, HashMap vs TreeMap)
324
- - Streams vs loops (when to use each)
325
- - Concurrency (thread safety, synchronization)
326
-
327
- 3. **Generate review report**
328
-
329
- Create a structured report listing:
330
- - **Issues found** (if any):
331
- - Severity (Critical, High, Medium, Low)
332
- - Location (file path and line number)
333
- - Description
334
- - Suggestion for improvement
335
- - **Suggestions for improvement** (even if no critical issues)
336
- - **Positive findings** (good practices observed)
337
-
338
- 4. **Handle review results**
339
-
340
- - **If issues are found**:
341
-
342
- Display the review report with all issues.
343
-
344
- Use **AskUserQuestion tool** with options:
345
- - "是,现在修复" / "Yes, fix now"
346
- - "稍后修复" / "Fix later"
347
- - "跳过" / "Skip"
348
-
349
- - If user chooses "Yes, fix now": proceed with fixing the issues one by one
350
- - If user chooses "Fix later" or "Skip": continue to archive workflow
351
-
352
- - **If no issues are found**:
353
-
354
- Display: "代码审查完成,未发现问题。" (or "Code review complete. No issues found.")
355
- Proceed to suggest archive workflow.
356
-
357
- c. **If user selects "Skip, proceed to archive"**:
358
-
359
- Skip the code review step.
360
- Proceed directly to suggesting archive workflow.
361
- 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.
362
307
 
363
308
  **Output During Implementation**
364
309
 
@@ -710,8 +655,8 @@ Main specs are now updated. The change remains active - archive when implementat
710
655
  export function getProposeChangeSkillTemplate() {
711
656
  return {
712
657
  name: 'zhuanspec-propose-change',
713
- 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.',
714
- 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.
715
660
 
716
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.
717
662
 
@@ -766,7 +711,7 @@ export function getProposeChangeSkillTemplate() {
766
711
  zhuanspec status --change "<name>" --json
767
712
  \`\`\`
768
713
 
769
- b. **For each artifact in dependency order** (proposal → specs → design → tasks):
714
+ b. **For each artifact in dependency order** (techDesign(design) → proposal → specs → tasks):
770
715
  - Get instructions: \`zhuanspec instructions <artifact-id> --change "<name>" --json\`
771
716
  - Read any completed dependency files for context
772
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.
@@ -1057,7 +1002,7 @@ export function getOpsxProposeCommandTemplate() {
1057
1002
  4. **Generate all planning artifacts** in dependency order:
1058
1003
  - For each artifact: \`zhuanspec instructions <id> --change "<name>" --json\`
1059
1004
  - Read dependencies, create artifact, show progress
1060
- - Artifacts: proposal.md → specs/ → design.md (if needed) → tasks.md
1005
+ - Artifacts: design.md(techDesign 阶段产物)→ proposal.md → specs/ → tasks.md
1061
1006
 
1062
1007
  ⚠️ **CHECKPOINT [SKILL-TAGGING]**:
1063
1008
  1. You MUST run \`zhuanspec skills list\` first and record discovered skills in the Skill Mapping table
@@ -1195,7 +1140,7 @@ export function getOpsxNewCommandTemplate() {
1195
1140
  Use the **AskUserQuestion tool** to let the user choose a workflow:
1196
1141
  - Present each schema with its description
1197
1142
  - Mark \`spec-driven\` as "(default)" if it's available
1198
- - 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"
1199
1144
 
1200
1145
  If user doesn't have a preference, default to \`spec-driven\`.
1201
1146
 
@@ -1327,7 +1272,7 @@ The artifact types and their purpose depend on the schema. Use the \`instruction
1327
1272
 
1328
1273
  Common artifact patterns:
1329
1274
 
1330
- **spec-driven schema** (proposal → specs → design → tasks):
1275
+ **spec-driven schema** (techDesign(design) → proposal → specs → tasks):
1331
1276
  - **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
1332
1277
  - The Capabilities section is critical - each capability listed will need a spec file.
1333
1278
  - **specs/*.md**: Create one spec per capability listed in the proposal.
@@ -1424,8 +1369,7 @@ export function getOpsxApplyCommandTemplate() {
1424
1369
  - Parse the task text for \`@skill\` tags (format: \`@skill:name1,name2\`)
1425
1370
  - If \`@skill\` tags found, invoke the corresponding skill(s) for guidance before making changes
1426
1371
  - Make the code changes required
1427
- - If the task mentions unit tests ("单元测试", "UT", "unit test"), AFTER code generation you MUST invoke \`generate-mockito-unit-test\` (or \`generate-mockito-unit-test-skill\`) to generate tests
1428
- - Run unit tests and verify they pass (e.g., \`mvn -Dtest=<TestClass> test\` or module-level \`mvn test\`); do not mark task complete until tests pass
1372
+ - Apply 阶段不生成单元测试文件;仅完成功能实现并保持任务状态准确
1429
1373
  - Keep changes minimal and focused
1430
1374
  - Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
1431
1375
  - Continue to next task
@@ -1444,80 +1388,26 @@ export function getOpsxApplyCommandTemplate() {
1444
1388
  - If all done: proceed to code review step (step 8)
1445
1389
  - If paused: explain why and wait for guidance
1446
1390
 
1447
- 8. **Code Review (when all tasks complete)**
1391
+ 8. **三轨并行审查门禁(auto, once after all tasks complete)**
1448
1392
 
1449
1393
  **WHEN** all tasks are complete (\`state: "all_done"\`):
1450
-
1451
- a. **Prompt for code review**
1452
-
1453
- Use the **AskUserQuestion tool** with options:
1454
- - "是,进行代码审查" / "Yes, perform code review"
1455
- - "跳过,直接归档" / "Skip, proceed to archive"
1456
-
1457
- Wait for user selection before proceeding.
1458
-
1459
- b. **If user selects "Yes, perform code review"**:
1460
-
1461
- 1. **Read code files related to the change**
1462
- - Based on context files from apply instructions
1463
- - Scan the change directory for code files (e.g., \`*.java\`, \`*.ts\`, \`*.py\`, etc.)
1464
- - Read all relevant code files that were modified or created for this change
1465
-
1466
- 2. **Perform code review**
1467
-
1468
- Review code for:
1469
- - **Code standards and conventions compliance**: naming, formatting, structure
1470
- - **Logic correctness**: edge cases, error handling, business logic
1471
- - **Performance issues**: inefficient algorithms, unnecessary operations, potential bottlenecks
1472
- - **Security concerns**: input validation, authentication, authorization, data exposure
1473
- - **Best practices adherence**: design patterns, SOLID principles, maintainability
1474
-
1475
- **For Java code specifically**, pay special attention to:
1476
- - Java-specific patterns and conventions (e.g., builder pattern, factory pattern)
1477
- - Common Java pitfalls:
1478
- - Null handling (NullPointerException prevention)
1479
- - Exception handling (proper try-catch, resource management)
1480
- - Resource management (try-with-resources, closing streams/connections)
1481
- - Performance considerations:
1482
- - Collections usage (ArrayList vs LinkedList, HashMap vs TreeMap)
1483
- - Streams vs loops (when to use each)
1484
- - Concurrency (thread safety, synchronization)
1485
-
1486
- 3. **Generate review report**
1487
-
1488
- Create a structured report listing:
1489
- - **Issues found** (if any):
1490
- - Severity (Critical, High, Medium, Low)
1491
- - Location (file path and line number)
1492
- - Description
1493
- - Suggestion for improvement
1494
- - **Suggestions for improvement** (even if no critical issues)
1495
- - **Positive findings** (good practices observed)
1496
-
1497
- 4. **Handle review results**
1498
-
1499
- - **If issues are found**:
1500
-
1501
- Display the review report with all issues.
1502
-
1503
- Use **AskUserQuestion tool** with options:
1504
- - "是,现在修复" / "Yes, fix now"
1505
- - "稍后修复" / "Fix later"
1506
- - "跳过" / "Skip"
1507
-
1508
- - If user chooses "Yes, fix now": proceed with fixing the issues one by one
1509
- - If user chooses "Fix later" or "Skip": continue to archive workflow
1510
-
1511
- - **If no issues are found**:
1512
-
1513
- Display: "代码审查完成,未发现问题。" (or "Code review complete. No issues found.")
1514
- Proceed to suggest archive workflow.
1515
-
1516
- c. **If user selects "Skip, proceed to archive"**:
1517
-
1518
- Skip the code review step.
1519
- Proceed directly to suggesting archive workflow.
1520
- 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.
1521
1411
 
1522
1412
  **Output During Implementation**
1523
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