specweave 0.23.2 → 0.23.5

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 (106) hide show
  1. package/CLAUDE.md +367 -0
  2. package/dist/plugins/specweave/lib/utils/fs-native.d.ts +133 -0
  3. package/dist/plugins/specweave/lib/utils/fs-native.d.ts.map +1 -0
  4. package/dist/plugins/specweave/lib/utils/fs-native.js +224 -0
  5. package/dist/plugins/specweave/lib/utils/fs-native.js.map +1 -0
  6. package/dist/plugins/specweave-github/lib/github-client-v2.js +1 -1
  7. package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
  8. package/dist/plugins/specweave-github/lib/github-feature-sync.d.ts.map +1 -1
  9. package/dist/plugins/specweave-github/lib/github-feature-sync.js +52 -20
  10. package/dist/plugins/specweave-github/lib/github-feature-sync.js.map +1 -1
  11. package/dist/plugins/specweave-github/lib/user-story-issue-builder.d.ts.map +1 -1
  12. package/dist/plugins/specweave-github/lib/user-story-issue-builder.js +24 -0
  13. package/dist/plugins/specweave-github/lib/user-story-issue-builder.js.map +1 -1
  14. package/dist/src/cli/helpers/init/initial-increment-generator.d.ts.map +1 -1
  15. package/dist/src/cli/helpers/init/initial-increment-generator.js +2 -1
  16. package/dist/src/cli/helpers/init/initial-increment-generator.js.map +1 -1
  17. package/dist/src/core/ac-test-validator-cli.d.ts +16 -0
  18. package/dist/src/core/ac-test-validator-cli.d.ts.map +1 -0
  19. package/dist/src/core/ac-test-validator-cli.js +118 -0
  20. package/dist/src/core/ac-test-validator-cli.js.map +1 -0
  21. package/dist/src/core/ac-test-validator.d.ts +111 -0
  22. package/dist/src/core/ac-test-validator.d.ts.map +1 -0
  23. package/dist/src/core/ac-test-validator.js +292 -0
  24. package/dist/src/core/ac-test-validator.js.map +1 -0
  25. package/dist/src/core/increment/desync-detector.d.ts +142 -0
  26. package/dist/src/core/increment/desync-detector.d.ts.map +1 -0
  27. package/dist/src/core/increment/desync-detector.js +270 -0
  28. package/dist/src/core/increment/desync-detector.js.map +1 -0
  29. package/dist/src/core/increment/metadata-manager.d.ts +8 -4
  30. package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
  31. package/dist/src/core/increment/metadata-manager.js +45 -21
  32. package/dist/src/core/increment/metadata-manager.js.map +1 -1
  33. package/dist/src/core/qa/qa-runner.js +9 -2
  34. package/dist/src/core/qa/qa-runner.js.map +1 -1
  35. package/dist/src/sync/sync-coordinator.d.ts +1 -1
  36. package/dist/src/sync/sync-coordinator.d.ts.map +1 -1
  37. package/dist/src/sync/sync-coordinator.js +40 -2
  38. package/dist/src/sync/sync-coordinator.js.map +1 -1
  39. package/dist/src/utils/fs-native.d.ts +133 -0
  40. package/dist/src/utils/fs-native.d.ts.map +1 -0
  41. package/dist/src/utils/fs-native.js +224 -0
  42. package/dist/src/utils/fs-native.js.map +1 -0
  43. package/package.json +1 -1
  44. package/plugins/specweave/.claude-plugin/plugin.json +12 -0
  45. package/plugins/specweave/agents/AGENTS-INDEX.md +216 -0
  46. package/plugins/specweave/agents/architect/AGENT.md +17 -0
  47. package/plugins/specweave/agents/code-standards-detective/AGENT.md +16 -0
  48. package/plugins/specweave/agents/docs-writer/AGENT.md +16 -0
  49. package/plugins/specweave/agents/increment-quality-judge-v2/AGENT.md +704 -0
  50. package/plugins/specweave/agents/infrastructure/AGENT.md +16 -0
  51. package/plugins/specweave/agents/performance/AGENT.md +16 -0
  52. package/plugins/specweave/agents/pm/AGENT.md +17 -0
  53. package/plugins/specweave/agents/qa-lead/AGENT.md +15 -0
  54. package/plugins/specweave/agents/reflective-reviewer/AGENT.md +16 -0
  55. package/plugins/specweave/agents/security/AGENT.md +16 -0
  56. package/plugins/specweave/agents/tdd-orchestrator/AGENT.md +16 -0
  57. package/plugins/specweave/agents/tech-lead/AGENT.md +16 -0
  58. package/plugins/specweave/agents/test-aware-planner/AGENT.md +16 -0
  59. package/plugins/specweave/agents/translator/AGENT.md +13 -0
  60. package/plugins/specweave/commands/specweave-done.md +14 -0
  61. package/plugins/specweave/commands/specweave-qa.md +11 -1
  62. package/plugins/specweave/commands/specweave-sync-status.md +356 -0
  63. package/plugins/specweave/commands/specweave-validate.md +10 -1
  64. package/plugins/specweave/hooks/pre-task-completion.sh +196 -0
  65. package/plugins/specweave/lib/hooks/git-diff-analyzer.js +3 -3
  66. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts +3 -3
  67. package/plugins/specweave/lib/hooks/invoke-translator-skill.js +3 -2
  68. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts +3 -2
  69. package/plugins/specweave/lib/hooks/prepare-reflection-context.js +3 -3
  70. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts +3 -3
  71. package/plugins/specweave/lib/hooks/reflection-config-loader.js +4 -4
  72. package/plugins/specweave/lib/hooks/reflection-config-loader.ts +4 -4
  73. package/plugins/specweave/lib/hooks/reflection-storage.js +9 -9
  74. package/plugins/specweave/lib/hooks/reflection-storage.ts +9 -9
  75. package/plugins/specweave/lib/hooks/sync-cache.js +9 -8
  76. package/plugins/specweave/lib/hooks/sync-living-docs.js +57 -6
  77. package/plugins/specweave/lib/hooks/sync-us-tasks.js +6 -6
  78. package/plugins/specweave/lib/hooks/translate-file.js +3 -2
  79. package/plugins/specweave/lib/hooks/translate-file.ts +3 -2
  80. package/plugins/specweave/lib/hooks/translate-living-docs.js +4 -3
  81. package/plugins/specweave/lib/hooks/translate-living-docs.ts +4 -3
  82. package/plugins/specweave/lib/hooks/update-tasks-md.js +3 -3
  83. package/plugins/specweave/lib/hooks/update-tasks-md.ts +3 -3
  84. package/plugins/specweave/lib/utils/fs-native.js +182 -0
  85. package/plugins/specweave/lib/utils/fs-native.ts +283 -0
  86. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.d.ts +8 -4
  87. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +45 -21
  88. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -1
  89. package/plugins/specweave/skills/SKILLS-INDEX.md +26 -2
  90. package/plugins/specweave/skills/increment-planner/SKILL.md +2 -2
  91. package/plugins/specweave-ado/commands/specweave-ado-close-workitem.md +1 -1
  92. package/plugins/specweave-ado/commands/specweave-ado-create-workitem.md +1 -1
  93. package/plugins/specweave-ado/commands/specweave-ado-status.md +1 -1
  94. package/plugins/specweave-ado/commands/specweave-ado-sync.md +1 -1
  95. package/plugins/specweave-diagrams/agents/diagrams-architect/AGENT.md +1 -1
  96. package/plugins/specweave-diagrams/skills/diagrams-generator/SKILL.md +4 -4
  97. package/plugins/specweave-github/lib/github-client-v2.js +2 -1
  98. package/plugins/specweave-github/lib/github-client-v2.ts +1 -1
  99. package/plugins/specweave-github/lib/github-feature-sync.js +30 -17
  100. package/plugins/specweave-github/lib/github-feature-sync.ts +54 -24
  101. package/plugins/specweave-github/lib/user-story-issue-builder.js +24 -0
  102. package/plugins/specweave-github/lib/user-story-issue-builder.ts +33 -0
  103. package/plugins/specweave-mobile/README.md +1 -1
  104. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +72 -0
  105. package/src/templates/CLAUDE.md.template +13 -0
  106. package/plugins/specweave/skills/task-builder/README.md +0 -84
@@ -10,6 +10,22 @@ capabilities:
10
10
  - Security best practices integration
11
11
  ---
12
12
 
13
+ # infrastructure Agent
14
+
15
+ ## 🚀 How to Invoke This Agent
16
+
17
+ ```typescript
18
+ // CORRECT invocation
19
+ Task({
20
+ subagent_type: "specweave:infrastructure:infrastructure",
21
+ prompt: "Your task description here"
22
+ });
23
+
24
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
25
+ // - plugin: specweave
26
+ // - directory: infrastructure (folder name)
27
+ // - name: infrastructure (from YAML frontmatter above)
28
+ ```
13
29
  # Infrastructure Agent
14
30
 
15
31
  I'm a serverless infrastructure specialist who generates production-ready Infrastructure-as-Code (IaC) using Terraform. I transform platform recommendations from the architect agent into deployable infrastructure configurations.
@@ -8,6 +8,22 @@ cost_profile: planning
8
8
  fallback_behavior: strict
9
9
  ---
10
10
 
11
+ # performance Agent
12
+
13
+ ## 🚀 How to Invoke This Agent
14
+
15
+ ```typescript
16
+ // CORRECT invocation
17
+ Task({
18
+ subagent_type: "specweave:performance:performance",
19
+ prompt: "Your task description here"
20
+ });
21
+
22
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
23
+ // - plugin: specweave
24
+ // - directory: performance (folder name)
25
+ // - name: performance (from YAML frontmatter above)
26
+ ```
11
27
  # Performance Agent - Optimization & Scalability Expert
12
28
 
13
29
  You are an expert Performance Engineer with 10+ years of experience optimizing web applications, databases, and distributed systems.
@@ -8,6 +8,23 @@ cost_profile: planning
8
8
  fallback_behavior: strict
9
9
  ---
10
10
 
11
+ # Product Manager Agent
12
+
13
+ ## 🚀 How to Invoke This Agent
14
+
15
+ ```typescript
16
+ // CORRECT invocation
17
+ Task({
18
+ subagent_type: "specweave:pm:pm",
19
+ prompt: "Create product requirements for user dashboard feature"
20
+ });
21
+
22
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
23
+ // - plugin: specweave
24
+ // - directory: pm (folder name)
25
+ // - name: pm (from YAML frontmatter above)
26
+ ```
27
+
11
28
  # PM Agent - Product Manager AI Assistant
12
29
 
13
30
  ## ⛔ CRITICAL: Increment Folder Structure (MANDATORY)
@@ -10,6 +10,21 @@ fallback_behavior: flexible
10
10
 
11
11
  # QA Lead Agent
12
12
 
13
+ ## 🚀 How to Invoke This Agent
14
+
15
+ ```typescript
16
+ // CORRECT invocation
17
+ Task({
18
+ subagent_type: "specweave:qa-lead:qa-lead",
19
+ prompt: "Create test strategy for permission gates feature"
20
+ });
21
+
22
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
23
+ // - plugin: specweave
24
+ // - directory: qa-lead (folder name)
25
+ // - name: qa-lead (from YAML frontmatter above)
26
+ ```
27
+
13
28
  ## 📚 Required Reading (LOAD FIRST)
14
29
 
15
30
  **CRITICAL**: Before creating test strategies, read this guide:
@@ -9,6 +9,22 @@ description: |
9
9
  allowed-tools: Read, Grep, Glob
10
10
  ---
11
11
 
12
+ # reflective-reviewer Agent
13
+
14
+ ## 🚀 How to Invoke This Agent
15
+
16
+ ```typescript
17
+ // CORRECT invocation
18
+ Task({
19
+ subagent_type: "specweave:reflective-reviewer:reflective-reviewer",
20
+ prompt: "Your task description here"
21
+ });
22
+
23
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
24
+ // - plugin: specweave
25
+ // - directory: reflective-reviewer (folder name)
26
+ // - name: reflective-reviewer (from YAML frontmatter above)
27
+ ```
12
28
  # Reflective Reviewer Agent
13
29
 
14
30
  You are a senior software engineer performing self-reflection on recently completed work. Your role is to analyze code changes comprehensively and provide actionable feedback that helps developers catch issues early, improve code quality, and learn from experience.
@@ -8,6 +8,22 @@ cost_profile: planning
8
8
  fallback_behavior: strict
9
9
  ---
10
10
 
11
+ # security Agent
12
+
13
+ ## 🚀 How to Invoke This Agent
14
+
15
+ ```typescript
16
+ // CORRECT invocation
17
+ Task({
18
+ subagent_type: "specweave:security:security",
19
+ prompt: "Your task description here"
20
+ });
21
+
22
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
23
+ // - plugin: specweave
24
+ // - directory: security (folder name)
25
+ // - name: security (from YAML frontmatter above)
26
+ ```
11
27
  # Security Agent - Application Security & Threat Modeling Expert
12
28
 
13
29
  You are an expert Security Engineer with 10+ years of experience in application security, penetration testing, and security compliance across web and cloud applications.
@@ -7,6 +7,22 @@ cost_profile: execution
7
7
  fallback_behavior: flexible
8
8
  ---
9
9
 
10
+ # tdd-orchestrator Agent
11
+
12
+ ## 🚀 How to Invoke This Agent
13
+
14
+ ```typescript
15
+ // CORRECT invocation
16
+ Task({
17
+ subagent_type: "specweave:tdd-orchestrator:tdd-orchestrator",
18
+ prompt: "Your task description here"
19
+ });
20
+
21
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
22
+ // - plugin: specweave
23
+ // - directory: tdd-orchestrator (folder name)
24
+ // - name: tdd-orchestrator (from YAML frontmatter above)
25
+ ```
10
26
  You are an expert TDD orchestrator specializing in comprehensive test-driven development coordination, modern TDD practices, and multi-agent workflow management.
11
27
 
12
28
  ## Expert Purpose
@@ -8,6 +8,22 @@ cost_profile: execution
8
8
  fallback_behavior: flexible
9
9
  ---
10
10
 
11
+ # tech-lead Agent
12
+
13
+ ## 🚀 How to Invoke This Agent
14
+
15
+ ```typescript
16
+ // CORRECT invocation
17
+ Task({
18
+ subagent_type: "specweave:tech-lead:tech-lead",
19
+ prompt: "Your task description here"
20
+ });
21
+
22
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
23
+ // - plugin: specweave
24
+ // - directory: tech-lead (folder name)
25
+ // - name: tech-lead (from YAML frontmatter above)
26
+ ```
11
27
  # Tech Lead Agent - Technical Leadership & Code Excellence
12
28
 
13
29
  You are an expert Technical Lead with 12+ years of hands-on development experience and 5+ years leading engineering teams. You bridge the gap between architecture and implementation, ensuring code quality, team productivity, and technical excellence.
@@ -8,6 +8,22 @@ cost_profile: planning
8
8
  fallback_behavior: strict
9
9
  ---
10
10
 
11
+ # test-aware-planner Agent
12
+
13
+ ## 🚀 How to Invoke This Agent
14
+
15
+ ```typescript
16
+ // CORRECT invocation
17
+ Task({
18
+ subagent_type: "specweave:test-aware-planner:test-aware-planner",
19
+ prompt: "Your task description here"
20
+ });
21
+
22
+ // Naming pattern: {plugin}:{directory}:{name-from-yaml}
23
+ // - plugin: specweave
24
+ // - directory: test-aware-planner (folder name)
25
+ // - name: test-aware-planner (from YAML frontmatter above)
26
+ ```
11
27
  # Test-Aware Planner Agent
12
28
 
13
29
  **Role**: Generate implementation tasks with embedded test plans (NO separate tests.md)
@@ -1,5 +1,18 @@
1
1
  # Translator Agent
2
2
 
3
+ ## 🚀 How to Invoke This Agent
4
+
5
+ ```typescript
6
+ // CORRECT invocation
7
+ Task({
8
+ subagent_type: "specweave:translator:AGENT",
9
+ prompt: "Translate documentation to Spanish"
10
+ });
11
+
12
+ // Note: This agent uses a special naming pattern
13
+ // Check the plugin configuration for the exact subagent_type
14
+ ```
15
+
3
16
  **Role**: Batch Translation Specialist
4
17
  **Expertise**: Multi-file translation coordination, consistency management, quality assurance
5
18
  **Uses**: translator skill (for actual translation work)
@@ -59,6 +59,20 @@ You are acting as the Product Manager to validate increment completion before cl
59
59
 
60
60
  ```typescript
61
61
  import { IncrementCompletionValidator } from '../../../src/core/increment/completion-validator.js';
62
+ import { DesyncDetector } from '../../../src/core/increment/desync-detector.js';
63
+
64
+ // **NEW (2025-11-20)**: Validate no status desync exists
65
+ // This prevents closing increments with inconsistent metadata.json and spec.md
66
+ const desyncDetector = new DesyncDetector();
67
+ try {
68
+ await desyncDetector.validateOrThrow(incrementId);
69
+ } catch (error) {
70
+ console.error('❌ CANNOT CLOSE INCREMENT - Status desync detected');
71
+ console.error('');
72
+ console.error(error.message);
73
+ console.error('');
74
+ process.exit(1);
75
+ }
62
76
 
63
77
  // Validate increment is ready for completion
64
78
  const validation = await IncrementCompletionValidator.validateCompletion(incrementId);
@@ -73,7 +73,17 @@ The command runs 120+ validation checks on increment files:
73
73
 
74
74
  ### Step 2: AI Quality Assessment (Optional, skip with `--no-ai`)
75
75
 
76
- Invoke the `increment-quality-judge-v2` skill to evaluate:
76
+ **IMPORTANT**: This step uses the `increment-quality-judge-v2` **agent** (not skill).
77
+
78
+ If implementing programmatically, invoke via Task tool:
79
+ ```typescript
80
+ Task({
81
+ subagent_type: "specweave:increment-quality-judge-v2:increment-quality-judge-v2",
82
+ prompt: `Assess quality of increment ${incrementId}`
83
+ });
84
+ ```
85
+
86
+ The agent evaluates:
77
87
  - **7 Dimensions**:
78
88
  1. Clarity (18% weight)
79
89
  2. Testability (22% weight)
@@ -0,0 +1,356 @@
1
+ ---
2
+ name: specweave:sync-status
3
+ description: Detect and fix status desyncs between metadata.json and spec.md
4
+ ---
5
+
6
+ # Sync Status - Desync Detection & Recovery
7
+
8
+ **CRITICAL**: Detects and fixes status desyncs between metadata.json and spec.md to maintain source-of-truth integrity.
9
+
10
+ ## Overview
11
+
12
+ This command scans increments for status desyncs where metadata.json and spec.md have different status values. This violates CLAUDE.md Rule #7 (source-of-truth discipline) and causes:
13
+ - Status line showing wrong increment
14
+ - Commands operating on wrong data
15
+ - User confusion and broken trust
16
+
17
+ **Incident Reference**: 2025-11-20 - Silent failure in /specweave:done caused increment 0047 to have metadata.json="completed" while spec.md="active", breaking status line.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ # Scan all increments for desyncs
23
+ /specweave:sync-status
24
+
25
+ # Check specific increment
26
+ /specweave:sync-status 0047
27
+
28
+ # Auto-fix all desyncs (non-interactive)
29
+ /specweave:sync-status --fix
30
+
31
+ # Scan and show detailed report
32
+ /specweave:sync-status --verbose
33
+ ```
34
+
35
+ ## Arguments
36
+
37
+ - `<increment-id>` - Optional. Specific increment to check (e.g., "0047", "0001-test")
38
+ - `--fix` - Auto-fix all desyncs without prompting
39
+ - `--verbose` - Show detailed report including healthy increments
40
+
41
+ ---
42
+
43
+ ## Workflow
44
+
45
+ ### Mode 1: Scan All Increments (Default)
46
+
47
+ **When to use**: Regular maintenance, pre-commit checks, incident investigation
48
+
49
+ **Steps**:
50
+
51
+ 1. **Scan all increments**:
52
+ ```typescript
53
+ import { DesyncDetector } from '../../../src/core/increment/desync-detector.js';
54
+
55
+ const detector = new DesyncDetector();
56
+ const report = await detector.scanAll();
57
+ ```
58
+
59
+ 2. **Display report**:
60
+ ```typescript
61
+ console.log(detector.formatReport(report));
62
+ ```
63
+
64
+ 3. **Example output** (desyncs found):
65
+ ```
66
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
67
+ STATUS DESYNC DETECTION REPORT
68
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
69
+
70
+ Total Scanned: 47 increments
71
+ Healthy: 46
72
+ Desyncs Found: 1 ⚠️
73
+ Errors: 0
74
+
75
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
76
+ DESYNCS DETECTED (CRITICAL!)
77
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
78
+
79
+ ❌ 0047-us-task-linkage
80
+ metadata.json: completed
81
+ spec.md: active
82
+
83
+ Fix command: /specweave:sync-status --fix
84
+
85
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
86
+ ```
87
+
88
+ 4. **If desyncs found, prompt user**:
89
+ ```typescript
90
+ if (report.totalDesyncs > 0) {
91
+ const shouldFix = await promptUser(
92
+ `Found ${report.totalDesyncs} desync(s). Fix them? (y/n): `
93
+ );
94
+
95
+ if (shouldFix) {
96
+ // Fix all desyncs
97
+ for (const desync of report.desyncs) {
98
+ const fixed = await detector.fixDesync(desync.incrementId);
99
+ if (fixed) {
100
+ console.log(`✅ Fixed ${desync.incrementId}`);
101
+ } else {
102
+ console.error(`❌ Failed to fix ${desync.incrementId}`);
103
+ }
104
+ }
105
+
106
+ console.log('');
107
+ console.log('All desyncs fixed! Run /specweave:sync-status to verify.');
108
+ }
109
+ }
110
+ ```
111
+
112
+ 5. **Example output** (no desyncs):
113
+ ```
114
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
115
+ STATUS DESYNC DETECTION REPORT
116
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
117
+
118
+ Total Scanned: 47 increments
119
+ Healthy: 47
120
+ Desyncs Found: 0 ⚠️
121
+ Errors: 0
122
+
123
+ ✅ All increments healthy - no desyncs detected!
124
+
125
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
126
+ ```
127
+
128
+ ### Mode 2: Check Specific Increment
129
+
130
+ **When to use**: Investigating specific increment, post-fix verification
131
+
132
+ **Steps**:
133
+
134
+ 1. **Check increment**:
135
+ ```typescript
136
+ const detector = new DesyncDetector();
137
+ const result = await detector.checkIncrement(incrementId);
138
+ ```
139
+
140
+ 2. **Display result**:
141
+ ```typescript
142
+ if (result.error) {
143
+ console.error(`❌ Error checking ${incrementId}: ${result.error}`);
144
+ process.exit(1);
145
+ }
146
+
147
+ if (result.hasDesync) {
148
+ console.log('━'.repeat(80));
149
+ console.log(`❌ DESYNC DETECTED: ${incrementId}`);
150
+ console.log('━'.repeat(80));
151
+ console.log('');
152
+ console.log(`metadata.json: ${result.metadataStatus}`);
153
+ console.log(`spec.md: ${result.specStatus}`);
154
+ console.log('');
155
+ console.log('This violates source-of-truth discipline (CLAUDE.md Rule #7)');
156
+ console.log('');
157
+ console.log(`Fix: /specweave:sync-status ${incrementId} --fix`);
158
+ console.log('━'.repeat(80));
159
+ } else {
160
+ console.log(`✅ ${incrementId} - No desync detected`);
161
+ console.log(` Status: ${result.metadataStatus}`);
162
+ }
163
+ ```
164
+
165
+ 3. **Example output** (desync found):
166
+ ```
167
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
168
+ ❌ DESYNC DETECTED: 0047-us-task-linkage
169
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
170
+
171
+ metadata.json: completed
172
+ spec.md: active
173
+
174
+ This violates source-of-truth discipline (CLAUDE.md Rule #7)
175
+
176
+ Fix: /specweave:sync-status 0047 --fix
177
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
178
+ ```
179
+
180
+ ### Mode 3: Auto-Fix (Non-Interactive)
181
+
182
+ **When to use**: CI/CD pipelines, automated recovery, pre-commit hooks
183
+
184
+ **Steps**:
185
+
186
+ 1. **Scan and fix**:
187
+ ```typescript
188
+ const detector = new DesyncDetector();
189
+ const report = await detector.scanAll();
190
+
191
+ if (report.totalDesyncs > 0) {
192
+ console.log(`Found ${report.totalDesyncs} desync(s) - fixing...`);
193
+ console.log('');
194
+
195
+ for (const desync of report.desyncs) {
196
+ const fixed = await detector.fixDesync(desync.incrementId);
197
+ if (fixed) {
198
+ console.log(`✅ Fixed ${desync.incrementId}: ${desync.specStatus} → ${desync.metadataStatus}`);
199
+ } else {
200
+ console.error(`❌ Failed to fix ${desync.incrementId}`);
201
+ }
202
+ }
203
+
204
+ console.log('');
205
+ console.log('✅ All desyncs fixed!');
206
+ } else {
207
+ console.log('✅ No desyncs found - all healthy');
208
+ }
209
+ ```
210
+
211
+ 2. **Example output**:
212
+ ```
213
+ Found 1 desync(s) - fixing...
214
+
215
+ ✅ Fixed 0047-us-task-linkage: active → completed
216
+
217
+ ✅ All desyncs fixed!
218
+ ```
219
+
220
+ ---
221
+
222
+ ## How Desyncs Are Fixed
223
+
224
+ **Fix Strategy**: metadata.json is considered the source of truth for status updates.
225
+
226
+ **Rationale**:
227
+ - metadata.json is updated atomically by CLI commands
228
+ - metadata.json is used for increment state management
229
+ - spec.md should mirror metadata.json for consistency
230
+
231
+ **Fix Process**:
232
+ 1. Read current status from metadata.json
233
+ 2. Read current status from spec.md
234
+ 3. Update spec.md frontmatter to match metadata.json
235
+ 4. Write spec.md atomically (temp file → rename)
236
+ 5. Verify fix by re-checking
237
+
238
+ **What gets updated**:
239
+ - ✅ spec.md YAML frontmatter `status` field
240
+ - ❌ metadata.json (already correct)
241
+
242
+ **Example fix**:
243
+ ```yaml
244
+ # Before (spec.md)
245
+ ---
246
+ status: active
247
+ ---
248
+
249
+ # After (spec.md)
250
+ ---
251
+ status: completed
252
+ ---
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Post-Fix Actions
258
+
259
+ After fixing desyncs, the following actions happen automatically:
260
+
261
+ 1. **Status Line Cache Update**:
262
+ ```bash
263
+ # Automatically triggered by spec.md change
264
+ bash plugins/specweave/hooks/lib/update-status-line.sh
265
+ ```
266
+
267
+ 2. **Git Status**:
268
+ ```bash
269
+ # spec.md will be modified - commit the fix
270
+ git status
271
+ git add .specweave/increments/*/spec.md
272
+ git commit -m "fix: sync spec.md status with metadata.json"
273
+ ```
274
+
275
+ 3. **Verification**:
276
+ ```bash
277
+ # Verify no desyncs remain
278
+ /specweave:sync-status
279
+ ```
280
+
281
+ ---
282
+
283
+ ## Error Handling
284
+
285
+ ### Increment Not Found
286
+ ```
287
+ ❌ Error: Increment 0047-us-task-linkage not found
288
+
289
+ Check increment ID and try again.
290
+ ```
291
+
292
+ ### File Permission Error
293
+ ```
294
+ ❌ Failed to fix desync for 0047-us-task-linkage
295
+ Error: EACCES: permission denied, open '.specweave/increments/0047-us-task-linkage/spec.md'
296
+
297
+ Fix permissions:
298
+ chmod u+w .specweave/increments/0047-us-task-linkage/spec.md
299
+ ```
300
+
301
+ ### YAML Parse Error
302
+ ```
303
+ ❌ Failed to fix desync for 0047-us-task-linkage
304
+ Error: Invalid YAML frontmatter in spec.md
305
+
306
+ Check YAML syntax:
307
+ vim .specweave/increments/0047-us-task-linkage/spec.md
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Prevention
313
+
314
+ **To prevent future desyncs**:
315
+
316
+ 1. ✅ **Fixed in v0.23.0+**: Atomic transaction pattern in `metadata-manager.ts`
317
+ - Updates spec.md FIRST, then metadata.json
318
+ - If spec.md fails, metadata.json is never updated
319
+ - No silent failures
320
+
321
+ 2. ✅ **Added in v0.23.0+**: Desync detection in `/specweave:done`
322
+ - Validates before closing increment
323
+ - Blocks closure if desync detected
324
+
325
+ 3. ✅ **Added in v0.23.0+**: Pre-commit hook validation
326
+ - Scans for desyncs before commit
327
+ - Blocks commit if desyncs found
328
+ - Auto-fix option available
329
+
330
+ 4. ✅ **Added in v0.23.0+**: Comprehensive tests
331
+ - Unit tests for DesyncDetector
332
+ - Integration tests for status updates
333
+ - E2E tests for recovery scenarios
334
+
335
+ ---
336
+
337
+ ## Related Commands
338
+
339
+ - `/specweave:done` - Close increment (includes desync validation)
340
+ - `/specweave:validate` - Validate increment quality
341
+ - `/specweave:status` - Show increment status overview
342
+
343
+ ---
344
+
345
+ ## Related Files
346
+
347
+ - `src/core/increment/desync-detector.ts` - Detection & fix logic
348
+ - `src/core/increment/metadata-manager.ts` - Atomic status updates
349
+ - `src/core/increment/spec-frontmatter-updater.ts` - spec.md updates
350
+ - `scripts/pre-commit-desync-check.sh` - Pre-commit validation
351
+
352
+ ---
353
+
354
+ **Important**: This command is part of the incident response to the 2025-11-20 silent failure bug. It ensures source-of-truth discipline is maintained across the entire increment lifecycle.
355
+
356
+ **Best Practice**: Run `/specweave:sync-status` regularly (weekly or before releases) to catch any desyncs early.
@@ -232,7 +232,16 @@ Choice: _
232
232
 
233
233
  ### Step 4: Run AI Quality Assessment (If Approved)
234
234
 
235
- **Invoke `increment-quality-judge` skill** with these parameters:
235
+ **IMPORTANT**: Invoke `increment-quality-judge-v2` **agent** (not skill) via Task tool:
236
+
237
+ ```typescript
238
+ Task({
239
+ subagent_type: "specweave:increment-quality-judge-v2:increment-quality-judge-v2",
240
+ prompt: `Assess quality of increment ${incrementId}`
241
+ });
242
+ ```
243
+
244
+ Pass these parameters:
236
245
  - increment_id: "0001"
237
246
  - files: ["spec.md", "plan.md", "tests.md"]
238
247
  - dimensions: ["clarity", "testability", "completeness", "feasibility", "maintainability", "edge_cases"]