specweave 0.22.3 → 0.22.4

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 (55) hide show
  1. package/CLAUDE.md +281 -1050
  2. package/dist/src/cli/commands/sync-specs.d.ts +4 -1
  3. package/dist/src/cli/commands/sync-specs.d.ts.map +1 -1
  4. package/dist/src/cli/commands/sync-specs.js +99 -49
  5. package/dist/src/cli/commands/sync-specs.js.map +1 -1
  6. package/dist/src/core/cicd/workflow-monitor.d.ts +4 -0
  7. package/dist/src/core/cicd/workflow-monitor.d.ts.map +1 -1
  8. package/dist/src/core/cicd/workflow-monitor.js +6 -2
  9. package/dist/src/core/cicd/workflow-monitor.js.map +1 -1
  10. package/dist/src/core/increment/increment-archiver.d.ts +4 -1
  11. package/dist/src/core/increment/increment-archiver.d.ts.map +1 -1
  12. package/dist/src/core/increment/increment-archiver.js +21 -9
  13. package/dist/src/core/increment/increment-archiver.js.map +1 -1
  14. package/dist/src/core/increment/metadata-manager.d.ts +22 -0
  15. package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
  16. package/dist/src/core/increment/metadata-manager.js +57 -5
  17. package/dist/src/core/increment/metadata-manager.js.map +1 -1
  18. package/dist/src/core/increment/spec-sync-manager.d.ts +5 -1
  19. package/dist/src/core/increment/spec-sync-manager.d.ts.map +1 -1
  20. package/dist/src/core/increment/spec-sync-manager.js +4 -2
  21. package/dist/src/core/increment/spec-sync-manager.js.map +1 -1
  22. package/dist/src/core/increment-utils.d.ts.map +1 -1
  23. package/dist/src/core/increment-utils.js +18 -1
  24. package/dist/src/core/increment-utils.js.map +1 -1
  25. package/dist/src/core/living-docs/living-docs-sync.d.ts +5 -1
  26. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  27. package/dist/src/core/living-docs/living-docs-sync.js +34 -32
  28. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  29. package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
  30. package/dist/src/core/living-docs/task-project-specific-generator.js +13 -8
  31. package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
  32. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  33. package/dist/src/core/status-line/status-line-manager.js +3 -1
  34. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  35. package/dist/src/integrations/jira/jira-incremental-mapper.d.ts.map +1 -1
  36. package/dist/src/integrations/jira/jira-incremental-mapper.js +4 -0
  37. package/dist/src/integrations/jira/jira-incremental-mapper.js.map +1 -1
  38. package/dist/src/integrations/jira/jira-mapper.d.ts.map +1 -1
  39. package/dist/src/integrations/jira/jira-mapper.js +4 -0
  40. package/dist/src/integrations/jira/jira-mapper.js.map +1 -1
  41. package/dist/src/utils/logger.d.ts +48 -0
  42. package/dist/src/utils/logger.d.ts.map +1 -0
  43. package/dist/src/utils/logger.js +53 -0
  44. package/dist/src/utils/logger.js.map +1 -0
  45. package/package.json +3 -2
  46. package/plugins/specweave/agents/code-standards-detective/AGENT.md +828 -0
  47. package/plugins/specweave/agents/test-aware-planner/templates/task-non-testable.md.template +12 -0
  48. package/plugins/specweave/agents/test-aware-planner/templates/task-testable.md.template +12 -0
  49. package/plugins/specweave/commands/specweave-analyze-standards.sh +315 -0
  50. package/plugins/specweave/commands/specweave-done.md +33 -2
  51. package/plugins/specweave/commands/specweave-sync-docs.md +66 -18
  52. package/plugins/specweave/hooks/lib/update-status-line.sh +5 -2
  53. package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +40 -3
  54. package/plugins/specweave/skills/code-standards-analyzer/SKILL.md +455 -0
  55. package/plugins/specweave/templates/coding-standards.md.template +447 -0
@@ -6,6 +6,18 @@
6
6
  **Estimate**: {estimate} hours
7
7
  **Status**: [ ] pending
8
8
 
9
+ **⚠️ SOURCE OF TRUTH REMINDER** (for AI agents):
10
+ ```
11
+ When you complete this task:
12
+ 1. ✅ Update internal TODO: TodoWrite([{task: "T-{task_number}", status: "completed"}])
13
+ 2. ⚠️ IMMEDIATELY update this line: **Status**: [ ] pending → **Status**: [x] completed
14
+ 3. ⚠️ IMMEDIATELY update spec.md: - [ ] **AC-{ac_ids}** → - [x] **AC-{ac_ids}**
15
+ 4. ✅ Verify both files before moving to next task
16
+
17
+ NEVER mark internal TODO as complete without updating these source files!
18
+ See CLAUDE.md Rule #7 for details.
19
+ ```
20
+
9
21
  **Test Plan**: N/A ({task_type} task)
10
22
 
11
23
  **Validation**:
@@ -6,6 +6,18 @@
6
6
  **Estimate**: {estimate} hours
7
7
  **Status**: [ ] pending
8
8
 
9
+ **⚠️ SOURCE OF TRUTH REMINDER** (for AI agents):
10
+ ```
11
+ When you complete this task:
12
+ 1. ✅ Update internal TODO: TodoWrite([{task: "T-{task_number}", status: "completed"}])
13
+ 2. ⚠️ IMMEDIATELY update this line: **Status**: [ ] pending → **Status**: [x] completed
14
+ 3. ⚠️ IMMEDIATELY update spec.md: - [ ] **AC-{ac_ids}** → - [x] **AC-{ac_ids}**
15
+ 4. ✅ Verify both files before moving to next task
16
+
17
+ NEVER mark internal TODO as complete without updating these source files!
18
+ See CLAUDE.md Rule #7 for details.
19
+ ```
20
+
9
21
  **Test Plan**:
10
22
  - **Given** {given_condition}
11
23
  - **When** {when_action}
@@ -0,0 +1,315 @@
1
+ #!/usr/bin/env bash
2
+ # ---
3
+ # name: specweave-analyze-standards
4
+ # description: Analyze and document coding standards from codebase. Detects naming conventions, import patterns, type usage, and anti-patterns. Generates evidence-based standards documentation with confidence levels. Supports full analysis, drift detection, and standards updates.
5
+ # usage: /specweave:analyze-standards [--drift] [--update] [--verbose]
6
+ # ---
7
+
8
+ set -e
9
+
10
+ # Detect project root (where .specweave/ is located)
11
+ PROJECT_ROOT="$(pwd)"
12
+ while [[ ! -d "$PROJECT_ROOT/.specweave" ]] && [[ "$PROJECT_ROOT" != "/" ]]; do
13
+ PROJECT_ROOT="$(dirname "$PROJECT_ROOT")"
14
+ done
15
+
16
+ if [[ ! -d "$PROJECT_ROOT/.specweave" ]]; then
17
+ echo "❌ Error: Not in a SpecWeave project (no .specweave/ directory found)"
18
+ exit 1
19
+ fi
20
+
21
+ cd "$PROJECT_ROOT"
22
+
23
+ # Parse arguments
24
+ MODE="full"
25
+ VERBOSE=false
26
+
27
+ while [[ $# -gt 0 ]]; do
28
+ case $1 in
29
+ --drift)
30
+ MODE="drift"
31
+ shift
32
+ ;;
33
+ --update)
34
+ MODE="update"
35
+ shift
36
+ ;;
37
+ --verbose)
38
+ VERBOSE=true
39
+ shift
40
+ ;;
41
+ *)
42
+ echo "❌ Unknown option: $1"
43
+ echo "Usage: /specweave:analyze-standards [--drift] [--update] [--verbose]"
44
+ exit 1
45
+ ;;
46
+ esac
47
+ done
48
+
49
+ # Ensure governance directory exists
50
+ GOVERNANCE_DIR="$PROJECT_ROOT/.specweave/docs/internal/governance"
51
+ mkdir -p "$GOVERNANCE_DIR"
52
+
53
+ # Display banner
54
+ echo "🔍 Code Standards Analysis"
55
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
56
+ echo ""
57
+
58
+ case $MODE in
59
+ full)
60
+ echo "Mode: Full Analysis"
61
+ echo "Output: $GOVERNANCE_DIR/coding-standards-analysis.md"
62
+ echo ""
63
+ echo "📊 Analyzing codebase..."
64
+ echo ""
65
+
66
+ # Launch code-standards-detective agent
67
+ cat <<'AGENT_PROMPT'
68
+ You are the code-standards-detective agent. Perform a complete coding standards analysis:
69
+
70
+ ## Your Mission
71
+
72
+ Analyze this codebase and generate comprehensive coding standards documentation.
73
+
74
+ ## Steps
75
+
76
+ ### Phase 1: Explicit Standards (5 seconds)
77
+ 1. Check for existing `.specweave/docs/internal/governance/coding-standards.md`
78
+ 2. Parse ESLint config (`.eslintrc.json`, `.eslintrc.js`)
79
+ 3. Parse Prettier config (`.prettierrc`, `.prettierrc.json`)
80
+ 4. Parse TypeScript config (`tsconfig.json`)
81
+ 5. Extract standards from `CLAUDE.md`, `CONTRIBUTING.md`
82
+
83
+ ### Phase 2: Implicit Standards (30 seconds)
84
+ 1. Find all source files: `src/**/*.{ts,js,tsx,jsx}`
85
+ 2. Analyze naming conventions (variables, functions, classes, constants)
86
+ 3. Detect import patterns (extensions, ordering)
87
+ 4. Measure function characteristics (length, style)
88
+ 5. Assess type usage (any, interfaces vs types)
89
+ 6. Identify error handling patterns
90
+
91
+ ### Phase 3: Anti-Pattern Detection (15 seconds)
92
+ 1. Detect console.* usage in src/
93
+ 2. Find hardcoded secrets (API keys, passwords)
94
+ 3. Identify large files (>500 lines)
95
+ 4. Find long functions (>100 lines)
96
+ 5. Check error handling coverage
97
+ 6. Detect N+1 query patterns
98
+
99
+ ### Phase 4: Documentation Generation (10 seconds)
100
+ 1. Merge explicit + implicit standards
101
+ 2. Calculate confidence levels
102
+ 3. Extract real code examples
103
+ 4. Highlight inconsistencies
104
+ 5. Provide recommendations
105
+
106
+ ## Output
107
+
108
+ Write comprehensive analysis to:
109
+ `.specweave/docs/internal/governance/coding-standards-analysis.md`
110
+
111
+ Include:
112
+ - Summary with confidence levels
113
+ - Naming conventions with examples
114
+ - Import patterns
115
+ - Function guidelines
116
+ - Type safety assessment
117
+ - Error handling analysis
118
+ - Anti-patterns and security issues
119
+ - Actionable recommendations
120
+
121
+ ## Console Summary
122
+
123
+ Print summary to stdout:
124
+ ```
125
+ ✅ Analysis complete!
126
+
127
+ 📊 Summary:
128
+ - Files: X
129
+ - LOC: Y
130
+ - Confidence: Z%
131
+
132
+ ✅ Strengths: [list]
133
+ ⚠️ Issues: [list]
134
+
135
+ 📄 Full report: .specweave/docs/internal/governance/coding-standards-analysis.md
136
+ ```
137
+
138
+ Execute the analysis now.
139
+ AGENT_PROMPT
140
+ ;;
141
+
142
+ drift)
143
+ echo "Mode: Drift Detection"
144
+ echo ""
145
+
146
+ # Check if standards exist
147
+ if [[ ! -f "$GOVERNANCE_DIR/coding-standards.md" ]]; then
148
+ echo "❌ Error: No coding standards found at:"
149
+ echo " $GOVERNANCE_DIR/coding-standards.md"
150
+ echo ""
151
+ echo "💡 Tip: Run /specweave:analyze-standards first to generate baseline standards"
152
+ exit 1
153
+ fi
154
+
155
+ echo "📊 Comparing declared standards vs actual code..."
156
+ echo ""
157
+
158
+ # Launch agent in drift-detection mode
159
+ cat <<'AGENT_PROMPT'
160
+ You are the code-standards-detective agent in DRIFT DETECTION mode.
161
+
162
+ ## Your Mission
163
+
164
+ Compare declared coding standards against actual codebase to detect drift.
165
+
166
+ ## Steps
167
+
168
+ 1. Read existing standards:
169
+ `.specweave/docs/internal/governance/coding-standards.md`
170
+
171
+ 2. Analyze current codebase (same as Phase 2-3 in full analysis)
172
+
173
+ 3. Compare declared vs actual:
174
+ - For each declared standard, check compliance percentage
175
+ - Identify violations
176
+ - Calculate drift score
177
+
178
+ 4. Report findings:
179
+ - Standards with high compliance (90%+) ✅
180
+ - Standards with drift (70-89%) ⚠️
181
+ - Standards violated (<70%) 🔴
182
+
183
+ ## Output Format
184
+
185
+ ```markdown
186
+ # Standards Drift Report
187
+
188
+ **Date**: {timestamp}
189
+ **Overall Compliance**: {percentage}%
190
+
191
+ ## ✅ Compliant Standards (90%+)
192
+ - Naming conventions: 98% compliant
193
+ - Import extensions: 100% compliant
194
+
195
+ ## ⚠️ Drift Detected (70-89%)
196
+ - Constant naming: 85% compliant (15% use camelCase instead of UPPER_SNAKE_CASE)
197
+ - Recommendation: Update 8 files or relax standard
198
+
199
+ ## 🔴 Violations (<70%)
200
+ - Function length: 65% compliant (35% have functions >100 lines)
201
+ - Critical: src/core/orchestrator.ts:processIncrement() - 156 lines
202
+ - Recommendation: Refactor large functions or update standard
203
+
204
+ ## New Patterns Detected
205
+ - Pattern: Using Zod for validation (34% of files)
206
+ - Not documented in standards
207
+ - Recommendation: Add to official standards
208
+ ```
209
+
210
+ Write to: `.specweave/docs/internal/governance/coding-standards-drift.md`
211
+
212
+ Print summary to stdout.
213
+
214
+ Execute drift detection now.
215
+ AGENT_PROMPT
216
+ ;;
217
+
218
+ update)
219
+ echo "Mode: Update Standards"
220
+ echo ""
221
+
222
+ # Check if analysis exists
223
+ if [[ ! -f "$GOVERNANCE_DIR/coding-standards-analysis.md" ]]; then
224
+ echo "⚠️ No analysis found. Running full analysis first..."
225
+ echo ""
226
+ MODE="full"
227
+ # Re-run in full mode (recursive call avoided by changing MODE)
228
+ fi
229
+
230
+ echo "📊 Generating updated standards..."
231
+ echo ""
232
+
233
+ # Launch agent in update mode
234
+ cat <<'AGENT_PROMPT'
235
+ You are the code-standards-detective agent in UPDATE mode.
236
+
237
+ ## Your Mission
238
+
239
+ Update official coding standards based on latest analysis.
240
+
241
+ ## Steps
242
+
243
+ 1. Read existing standards (if exist):
244
+ `.specweave/docs/internal/governance/coding-standards.md`
245
+
246
+ 2. Read latest analysis:
247
+ `.specweave/docs/internal/governance/coding-standards-analysis.md`
248
+
249
+ 3. Merge intelligently:
250
+ - Keep manually curated sections
251
+ - Update statistics from analysis
252
+ - Add new patterns if high confidence (>90%)
253
+ - Flag conflicts for human review
254
+
255
+ 4. Generate updated standards document
256
+
257
+ ## Important Rules
258
+
259
+ - NEVER remove manually written content without asking
260
+ - Mark auto-generated sections clearly
261
+ - Add "Last Updated" timestamp
262
+ - Preserve human rationale/explanations
263
+ - Flag breaking changes
264
+
265
+ ## Output
266
+
267
+ Write to: `.specweave/docs/internal/governance/coding-standards.md`
268
+
269
+ Also write summary to: `.specweave/docs/internal/governance/coding-standards-history.md`
270
+ - Append entry with timestamp
271
+ - List what changed
272
+ - Explain why
273
+
274
+ Execute update now.
275
+ AGENT_PROMPT
276
+ ;;
277
+ esac
278
+
279
+ echo ""
280
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
281
+ echo "✅ Code standards analysis complete!"
282
+ echo ""
283
+ echo "📂 Files generated:"
284
+ case $MODE in
285
+ full)
286
+ echo " - $GOVERNANCE_DIR/coding-standards-analysis.md"
287
+ ;;
288
+ drift)
289
+ echo " - $GOVERNANCE_DIR/coding-standards-drift.md"
290
+ ;;
291
+ update)
292
+ echo " - $GOVERNANCE_DIR/coding-standards.md (updated)"
293
+ echo " - $GOVERNANCE_DIR/coding-standards-history.md (appended)"
294
+ ;;
295
+ esac
296
+ echo ""
297
+ echo "🎯 Next steps:"
298
+ case $MODE in
299
+ full)
300
+ echo " 1. Review the analysis report"
301
+ echo " 2. Fix critical issues (hardcoded secrets, etc.)"
302
+ echo " 3. Run /specweave:analyze-standards --update to formalize"
303
+ ;;
304
+ drift)
305
+ echo " 1. Review drift report"
306
+ echo " 2. Fix violations or update standards"
307
+ echo " 3. Re-run analysis to verify"
308
+ ;;
309
+ update)
310
+ echo " 1. Review updated standards"
311
+ echo " 2. Commit to git if satisfied"
312
+ echo " 3. Share with team"
313
+ ;;
314
+ esac
315
+ echo ""
@@ -94,14 +94,45 @@ Proceeding to PM validation...
94
94
  ```
95
95
 
96
96
  **What Gate 0 validates**:
97
- - [ ] All acceptance criteria are checked (`- [x] **AC-...`)
98
- - [ ] All tasks are completed (`**Status**: [x] completed`)
97
+ - [ ] All acceptance criteria are checked in **spec.md** (`- [x] **AC-...`)
98
+ - [ ] All tasks are completed in **tasks.md** (`**Status**: [x] completed`)
99
99
  - [ ] Required files exist (`spec.md`, `tasks.md`)
100
+ - [ ] **NEW**: Tasks count in frontmatter matches checked tasks (source of truth validation)
101
+
102
+ **⚠️ SOURCE OF TRUTH ENFORCEMENT (CRITICAL)**:
103
+
104
+ Gate 0 now validates that `tasks.md` and `spec.md` are the ACTUAL source of truth, not internal TODO lists:
105
+
106
+ ```typescript
107
+ // 1. Count completed tasks in tasks.md (ACTUAL source of truth)
108
+ const tasksInFile = await countCompletedTasks(tasksPath);
109
+
110
+ // 2. Compare with frontmatter
111
+ const { total_tasks } = readTasksFrontmatter(tasksPath);
112
+
113
+ // 3. BLOCK if mismatch
114
+ if (tasksInFile < total_tasks) {
115
+ throw new ValidationError(
116
+ `CRITICAL: Source of truth violation!\n` +
117
+ `tasks.md shows ${tasksInFile}/${total_tasks} tasks completed.\n` +
118
+ `Internal TODO lists are NOT the source of truth.\n` +
119
+ `You MUST update tasks.md checkboxes before closing.\n` +
120
+ `See CLAUDE.md Rule #7 for details.`
121
+ );
122
+ }
123
+ ```
124
+
125
+ **This prevents**:
126
+ - ❌ Closing increments with `[ ] pending` tasks in tasks.md
127
+ - ❌ Relying on internal TODO lists instead of source files
128
+ - ❌ Marking work "done" without updating acceptance criteria
129
+ - ❌ The critical violation from increment 0044 (2025-11-19)
100
130
 
101
131
  **Why Gate 0 matters**:
102
132
  - **Prevents false completion**: Can't mark increment "completed" with open work
103
133
  - **Fast feedback**: Fails immediately (< 1s) vs waiting for PM agent (30s+)
104
134
  - **Data integrity**: Ensures status matches reality (no spec.md desync)
135
+ - **Source of truth discipline**: Enforces tasks.md and spec.md as the ONLY source of truth
105
136
 
106
137
  **CRITICAL**: Gate 0 is MANDATORY and CANNOT be bypassed. If validation fails, increment stays "in-progress" and command exits.
107
138
 
@@ -17,34 +17,60 @@ Arguments provided: [user's arguments]
17
17
 
18
18
  **Parse the input**:
19
19
  - Check for explicit mode: `review`, `update`, or none (auto-detect)
20
- - Check for increment ID: `0001`, `0002`, etc., or none (find current)
20
+ - Check for increment ID: `0001`, `0002`, etc., or none (sync all - NEW DEFAULT)
21
+ - Check for `--all` flag (explicit sync all)
22
+
23
+ **NEW DEFAULT BEHAVIOR (v0.23.0+)**:
24
+ - **No arguments** → Sync all increments with spec.md (batch mode)
25
+ - **Specific increment ID** → Sync that increment only
26
+ - **`--all` flag** → Sync all increments (explicit)
21
27
 
22
28
  **Auto-detect logic**:
23
29
 
24
- 1. **If increment ID provided**:
30
+ 1. **If no increment ID provided (NEW DEFAULT)**:
25
31
  ```bash
26
- # Read the increment's spec.md to check status
27
- INCREMENT_PATH=".specweave/increments/{increment_id}"
28
- STATUS=$(grep "^status:" "$INCREMENT_PATH/spec.md" | cut -d: -f2 | tr -d ' ')
32
+ # Sync ALL increments with spec.md
33
+ echo "🔄 Syncing all increments..."
34
+ npx specweave sync-specs
35
+ # This will sync all non-archived increments
29
36
  ```
30
37
 
31
- 2. **If no increment ID provided**:
38
+ 2. **If increment ID provided**:
32
39
  ```bash
33
- # Find the most recent increment
34
- LATEST=$(ls -1 .specweave/increments/ | grep -E '^[0-9]{4}' | sort -r | head -1)
40
+ # Read the increment's spec.md to check status
41
+ INCREMENT_PATH=".specweave/increments/{increment_id}"
42
+ STATUS=$(grep "^status:" "$INCREMENT_PATH/spec.md" | cut -d: -f2 | tr -d ' ')
35
43
  ```
36
44
 
37
45
  3. **Determine mode**:
38
46
  ```
39
- If status = "planned"REVIEW MODE
40
- If status = "in-progress" → UPDATE MODE
41
- If status = "completed" → UPDATE MODE
42
- If status = "closed" → UPDATE MODE
47
+ If no increment IDBATCH SYNC MODE (sync all)
48
+
49
+ If increment ID provided:
50
+ If status = "planned" → REVIEW MODE
51
+ If status = "in-progress" → UPDATE MODE
52
+ If status = "completed" → UPDATE MODE
53
+ If status = "closed" → UPDATE MODE
43
54
 
44
55
  If explicit mode provided → Use that mode
45
56
  ```
46
57
 
47
- **Output**:
58
+ **Output (Batch Mode)**:
59
+ ```
60
+ 🔄 Syncing all increments...
61
+
62
+ 📚 Syncing 0040-vitest-living-docs-mock-fixes → FS-040...
63
+ ✅ Synced 3 tasks to US-001
64
+ ✅ Synced 0040 → FS-040
65
+
66
+ 📚 Syncing 0041-living-docs-test-fixes → FS-041...
67
+ ✅ Synced 2 tasks to US-001
68
+ ✅ Synced 0041 → FS-041
69
+
70
+ ✅ Sync complete: 15 increments synced, 0 failed
71
+ ```
72
+
73
+ **Output (Single Mode)**:
48
74
  ```
49
75
  🔍 Detected increment: {increment_id}
50
76
  📊 Status: {status}
@@ -679,20 +705,42 @@ Usage: /specweave:sync-docs [review|update] [increment_id]
679
705
 
680
706
  ## EXAMPLES
681
707
 
682
- ### Example 1: Auto-detect mode for current increment
708
+ ### Example 1: Sync all increments (NEW DEFAULT)
683
709
  ```
684
710
  User: /specweave:sync-docs
685
711
 
686
712
  Output:
687
- 🔍 Detected increment: 0002
713
+ 🔄 Syncing all increments...
714
+
715
+ 📚 Syncing 0040-vitest-living-docs-mock-fixes → FS-040...
716
+ ✅ Synced 3 tasks to US-001
717
+ ✅ Synced 0040 → FS-040
718
+
719
+ 📚 Syncing 0041-living-docs-test-fixes → FS-041...
720
+ ✅ Synced 2 tasks to US-001
721
+ ✅ Synced 0041 → FS-041
722
+
723
+ 📚 Syncing 0042-test-infrastructure-cleanup → FS-042...
724
+ ✅ Synced 5 tasks to US-002
725
+ ✅ Synced 0042 → FS-042
726
+
727
+ ✅ Sync complete: 15 increments synced, 0 failed
728
+ ```
729
+
730
+ ### Example 2: Sync specific increment
731
+ ```
732
+ User: /specweave:sync-docs 0042
733
+
734
+ Output:
735
+ 🔍 Detected increment: 0042
688
736
  📊 Status: completed
689
737
  🎯 Mode: UPDATE
690
738
 
691
739
  Proceeding with UPDATE mode...
692
- {... executes update mode}
740
+ {... executes update mode for 0042 only}
693
741
  ```
694
742
 
695
- ### Example 2: Explicit review mode
743
+ ### Example 3: Explicit review mode
696
744
  ```
697
745
  User: /specweave:sync-docs review 0003
698
746
 
@@ -704,7 +752,7 @@ Output:
704
752
  {... shows strategic documentation summary}
705
753
  ```
706
754
 
707
- ### Example 3: Explicit update mode with increment
755
+ ### Example 4: Explicit update mode with increment
708
756
  ```
709
757
  User: /specweave:sync-docs update 0002
710
758
 
@@ -106,8 +106,11 @@ if [[ -f "$TASKS_FILE" ]]; then
106
106
  TOTAL_TASKS=$(grep -cE '^##+ T-' "$TASKS_FILE" 2>/dev/null || echo 0)
107
107
  TOTAL_TASKS=$(echo "$TOTAL_TASKS" | tr -d '\n\r ' || echo 0)
108
108
 
109
- # Count completed tasks - use most reliable single marker (**Completed**: format)
110
- COMPLETED_TASKS=$(grep -c '\*\*Completed\*\*:' "$TASKS_FILE" 2>/dev/null || echo 0)
109
+ # Count completed tasks - recognize all three completion marker formats:
110
+ # 1. **Completed**: <date> (preferred format)
111
+ # 2. **Status**: [x] (legacy format)
112
+ # 3. [x] at line start (legacy checkbox format)
113
+ COMPLETED_TASKS=$(grep -cE '(\*\*Completed\*\*:|\*\*Status\*\*:\s*\[x\]|^\[x\])' "$TASKS_FILE" 2>/dev/null || echo 0)
111
114
  COMPLETED_TASKS=$(echo "$COMPLETED_TASKS" | tr -d '\n\r ' || echo 0)
112
115
 
113
116
  # Calculate percentage
@@ -20,9 +20,10 @@ description: Analyzes existing brownfield projects to map documentation structur
20
20
  3. **Classify Documents** - Identify PRD, HLD, ADR, Spec, Runbook candidates
21
21
  4. **Detect External Tools** - Find Jira, ADO, GitHub project references
22
22
  5. **Analyze Diagrams** - Identify architecture diagrams (PNG, SVG, drawio)
23
- 6. **Generate Migration Plan** - Create actionable migration plan with effort estimate
24
- 7. **Suggest Increment Mapping** - Map Jira Epics/ADO Features to SpecWeave Increments
25
- 8. **Support Two Paths** - Quick Start (incremental) OR Comprehensive (upfront) 🆕
23
+ 6. **Discover Coding Standards** - Auto-detect naming conventions, patterns, linting rules 🆕
24
+ 7. **Generate Migration Plan** - Create actionable migration plan with effort estimate
25
+ 8. **Suggest Increment Mapping** - Map Jira Epics/ADO Features to SpecWeave Increments
26
+ 9. **Support Two Paths** - Quick Start (incremental) OR Comprehensive (upfront) 🆕
26
27
 
27
28
  ---
28
29
 
@@ -336,6 +337,42 @@ build/**
336
337
  - PNG/DrawIO → Suggest Mermaid conversion
337
338
  - Estimate: 15-30 minutes per diagram
338
339
 
340
+ ### Step 4.5: Coding Standards Discovery 🆕
341
+
342
+ **Auto-detect coding standards from codebase** using code-standards-detective agent.
343
+
344
+ **Execution**:
345
+ ```bash
346
+ # Run during brownfield analysis (automatic)
347
+ # Or manually: /specweave:analyze-standards
348
+ ```
349
+
350
+ **What it discovers**:
351
+ 1. **Explicit Standards** - Parse ESLint, Prettier, TypeScript, EditorConfig
352
+ 2. **Implicit Standards** - Analyze naming conventions (98% camelCase?), import patterns, function styles
353
+ 3. **Anti-Patterns** - Detect console.* usage, hardcoded secrets, large files (>500 lines)
354
+ 4. **Type Safety** - Count `any` usage, interface vs type preference
355
+ 5. **Error Handling** - Analyze try/catch patterns, custom error classes
356
+
357
+ **Statistical Analysis**:
358
+ - Confidence levels (HIGH 90%+, MEDIUM 70-89%, LOW 50-69%)
359
+ - Real code examples from codebase
360
+ - Inconsistency warnings
361
+
362
+ **Output**:
363
+ ```
364
+ .specweave/docs/internal/governance/coding-standards-analysis.md
365
+ ```
366
+
367
+ **Benefits**:
368
+ - ✅ New contributors understand project conventions immediately
369
+ - ✅ Documents "tribal knowledge" that only exists in code
370
+ - ✅ Detects security issues (hardcoded secrets, missing validation)
371
+ - ✅ Provides baseline for code quality improvements
372
+ - ✅ Identifies technical debt (large functions, missing error handling)
373
+
374
+ **Integration**: This step runs automatically during brownfield analysis, providing coding standards context alongside documentation structure.
375
+
339
376
  ### Step 5: Effort Estimation
340
377
 
341
378
  **Calculate total effort**: