specweave 0.22.3 → 0.22.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 (63) hide show
  1. package/CLAUDE.md +281 -1050
  2. package/dist/src/cli/commands/init.d.ts +2 -0
  3. package/dist/src/cli/commands/init.d.ts.map +1 -1
  4. package/dist/src/cli/commands/init.js +141 -95
  5. package/dist/src/cli/commands/init.js.map +1 -1
  6. package/dist/src/cli/commands/sync-specs.d.ts +4 -1
  7. package/dist/src/cli/commands/sync-specs.d.ts.map +1 -1
  8. package/dist/src/cli/commands/sync-specs.js +99 -49
  9. package/dist/src/cli/commands/sync-specs.js.map +1 -1
  10. package/dist/src/core/cicd/workflow-monitor.d.ts +4 -0
  11. package/dist/src/core/cicd/workflow-monitor.d.ts.map +1 -1
  12. package/dist/src/core/cicd/workflow-monitor.js +6 -2
  13. package/dist/src/core/cicd/workflow-monitor.js.map +1 -1
  14. package/dist/src/core/increment/increment-archiver.d.ts +4 -1
  15. package/dist/src/core/increment/increment-archiver.d.ts.map +1 -1
  16. package/dist/src/core/increment/increment-archiver.js +21 -9
  17. package/dist/src/core/increment/increment-archiver.js.map +1 -1
  18. package/dist/src/core/increment/metadata-manager.d.ts +22 -0
  19. package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
  20. package/dist/src/core/increment/metadata-manager.js +57 -5
  21. package/dist/src/core/increment/metadata-manager.js.map +1 -1
  22. package/dist/src/core/increment/spec-sync-manager.d.ts +5 -1
  23. package/dist/src/core/increment/spec-sync-manager.d.ts.map +1 -1
  24. package/dist/src/core/increment/spec-sync-manager.js +4 -2
  25. package/dist/src/core/increment/spec-sync-manager.js.map +1 -1
  26. package/dist/src/core/increment-utils.d.ts.map +1 -1
  27. package/dist/src/core/increment-utils.js +18 -1
  28. package/dist/src/core/increment-utils.js.map +1 -1
  29. package/dist/src/core/living-docs/living-docs-sync.d.ts +5 -1
  30. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  31. package/dist/src/core/living-docs/living-docs-sync.js +34 -32
  32. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  33. package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
  34. package/dist/src/core/living-docs/task-project-specific-generator.js +13 -8
  35. package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
  36. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  37. package/dist/src/core/status-line/status-line-manager.js +3 -1
  38. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  39. package/dist/src/integrations/jira/jira-incremental-mapper.d.ts.map +1 -1
  40. package/dist/src/integrations/jira/jira-incremental-mapper.js +4 -0
  41. package/dist/src/integrations/jira/jira-incremental-mapper.js.map +1 -1
  42. package/dist/src/integrations/jira/jira-mapper.d.ts.map +1 -1
  43. package/dist/src/integrations/jira/jira-mapper.js +4 -0
  44. package/dist/src/integrations/jira/jira-mapper.js.map +1 -1
  45. package/dist/src/utils/logger.d.ts +48 -0
  46. package/dist/src/utils/logger.d.ts.map +1 -0
  47. package/dist/src/utils/logger.js +53 -0
  48. package/dist/src/utils/logger.js.map +1 -0
  49. package/package.json +3 -2
  50. package/plugins/specweave/agents/code-standards-detective/AGENT.md +828 -0
  51. package/plugins/specweave/agents/test-aware-planner/templates/task-non-testable.md.template +12 -0
  52. package/plugins/specweave/agents/test-aware-planner/templates/task-testable.md.template +12 -0
  53. package/plugins/specweave/commands/specweave-analyze-standards.sh +315 -0
  54. package/plugins/specweave/commands/specweave-done.md +33 -2
  55. package/plugins/specweave/commands/specweave-sync-docs.md +66 -18
  56. package/plugins/specweave/hooks/lib/update-status-line.sh +5 -2
  57. package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +40 -3
  58. package/plugins/specweave/skills/code-standards-analyzer/SKILL.md +455 -0
  59. package/plugins/specweave/templates/coding-standards.md.template +447 -0
  60. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +1 -0
  61. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
  62. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  63. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +5238 -0
@@ -0,0 +1,455 @@
1
+ ---
2
+ name: code-standards-analyzer
3
+ description: Coding standards discovery and documentation expert. Analyzes codebase to detect naming conventions, patterns, anti-patterns, and best practices. Generates or updates coding standards documentation in .specweave/docs/internal/governance/. Detects ESLint/Prettier configs, analyzes TypeScript/JavaScript patterns, finds security issues, and creates evidence-based standards with confidence levels. Activates for analyze coding standards, discover conventions, code style analysis, detect patterns, coding guidelines, what are the standards, code quality check, naming conventions, linting rules, best practices analysis, standards audit, code review standards, detect anti-patterns.
4
+ allowed-tools: Read, Grep, Glob, Bash, Write, Edit
5
+ ---
6
+
7
+ # Code Standards Analyzer
8
+
9
+ **Purpose**: Discover, document, and maintain coding standards from existing codebases using evidence-based analysis.
10
+
11
+ **Philosophy**: Standards should reflect REALITY (what the code actually does) not ASPIRATIONS (what we wish it did). Measure, then document.
12
+
13
+ ---
14
+
15
+ ## When to Use
16
+
17
+ ### Primary Use Cases:
18
+ 1. **Brownfield Onboarding** - "What are this project's coding conventions?"
19
+ 2. **Standards Audit** - "Are we following our declared standards?"
20
+ 3. **New Contributor Onboarding** - "Teach me the project patterns"
21
+ 4. **Living Documentation** - "Keep standards in sync with codebase"
22
+ 5. **Greenfield Setup** - "Initialize standards from best practices"
23
+
24
+ ### Activation Triggers
25
+
26
+ **Keywords**: analyze coding standards, discover conventions, code style, detect patterns, coding guidelines, what are the standards, naming conventions, best practices, code quality, standards audit, anti-patterns
27
+
28
+ **User Requests**:
29
+ - "What are the coding standards for this project?"
30
+ - "Analyze the codebase and document our conventions"
31
+ - "Check if we're following our declared standards"
32
+ - "Find anti-patterns in the code"
33
+ - "Generate coding standards documentation"
34
+ - "What naming conventions does this project use?"
35
+
36
+ ---
37
+
38
+ ## Capabilities
39
+
40
+ ### 1. **Explicit Standards Discovery** (Fast - 5 seconds)
41
+ - ✅ Detect existing `.specweave/docs/internal/governance/coding-standards.md`
42
+ - ✅ Parse ESLint configuration (`.eslintrc.json`, `.eslintrc.js`)
43
+ - ✅ Parse Prettier configuration (`.prettierrc`, `.prettierrc.json`)
44
+ - ✅ Parse TypeScript configuration (`tsconfig.json`)
45
+ - ✅ Parse EditorConfig (`.editorconfig`)
46
+ - ✅ Extract standards from `CLAUDE.md`, `CONTRIBUTING.md`
47
+
48
+ ### 2. **Implicit Standards Detection** (Medium - 30 seconds)
49
+ - ✅ Naming convention analysis (variables, functions, classes, constants)
50
+ - ✅ Import pattern detection (extensions, ordering, aliasing)
51
+ - ✅ Function characteristics (avg length, max length, arrow vs regular)
52
+ - ✅ Type safety analysis (`any` usage, interface vs type preference)
53
+ - ✅ Error handling patterns (try/catch usage, custom errors)
54
+ - ✅ Comment style analysis
55
+ - ✅ File organization patterns
56
+
57
+ ### 3. **Anti-Pattern Detection** (Fast - 15 seconds)
58
+ - 🚨 `console.*` usage in production code
59
+ - 🚨 Hardcoded secrets (API keys, passwords)
60
+ - 🚨 `any` type overuse
61
+ - 🚨 Large files (>500 lines)
62
+ - 🚨 Long functions (>100 lines)
63
+ - 🚨 Missing error handling
64
+ - 🚨 N+1 query patterns
65
+ - 🚨 Security vulnerabilities
66
+
67
+ ### 4. **Documentation Generation** (Fast - 10 seconds)
68
+ - ✅ Generate standards document with examples
69
+ - ✅ Include statistical confidence levels
70
+ - ✅ Extract real code examples from codebase
71
+ - ✅ Highlight inconsistencies and conflicts
72
+ - ✅ Provide actionable recommendations
73
+ - ✅ Link to violating files
74
+
75
+ ---
76
+
77
+ ## Analysis Process
78
+
79
+ ### Phase 1: Explicit Standards (5 seconds)
80
+
81
+ **Sources Checked**:
82
+ 1. `.specweave/docs/internal/governance/coding-standards.md` (HIGH confidence)
83
+ 2. `CLAUDE.md` (HIGH confidence - AI instructions)
84
+ 3. `.eslintrc.json` (ENFORCED by tooling)
85
+ 4. `.prettierrc` (ENFORCED by tooling)
86
+ 5. `tsconfig.json` (ENFORCED by compiler)
87
+ 6. `.editorconfig` (ENFORCED by editor)
88
+ 7. `CONTRIBUTING.md` (MEDIUM confidence - may be outdated)
89
+
90
+ **Output**:
91
+ ```markdown
92
+ ## Explicit Standards Found
93
+
94
+ ✅ .eslintrc.json (ENFORCED - ESLint active)
95
+ ✅ .prettierrc (ENFORCED - Prettier active)
96
+ ✅ tsconfig.json (ENFORCED - TypeScript compiler)
97
+ ✅ CLAUDE.md (HIGH - AI development rules)
98
+ ⚠️ CONTRIBUTING.md (MEDIUM - human guidelines)
99
+ ❌ No .specweave/docs/internal/governance/coding-standards.md
100
+ ```
101
+
102
+ ### Phase 2: Implicit Standards (30 seconds)
103
+
104
+ **Analysis Performed**:
105
+ - Scan `src/**/*.{ts,js,tsx,jsx}` files
106
+ - Parse Abstract Syntax Trees (AST)
107
+ - Calculate statistical patterns
108
+ - Identify dominant conventions
109
+
110
+ **Example Output**:
111
+ ```markdown
112
+ ## Detected Patterns
113
+
114
+ ### Naming Conventions (Confidence: 95%)
115
+ - Variables: camelCase (1,234 samples, 98% compliance)
116
+ - Functions: camelCase (567 samples, 100% compliance)
117
+ - Classes: PascalCase (89 samples, 100% compliance)
118
+ - Constants: UPPER_SNAKE_CASE (234 samples, 92% compliance)
119
+ ⚠️ 8% use camelCase (inconsistency detected)
120
+
121
+ ### Import Patterns (Confidence: 100%)
122
+ - Extensions: .js suffix required (100% compliance)
123
+ - Order: external → internal → types (87% compliance)
124
+
125
+ ### Function Characteristics
126
+ - Average length: 35 lines
127
+ - Max length: 156 lines (src/core/analyzer.ts:45)
128
+ - Style: Arrow functions (78%), Regular (22%)
129
+
130
+ ### Type Safety (Confidence: 85%)
131
+ - any usage: 12 instances (REVIEW NEEDED)
132
+ - Preference: Interfaces (89%) over Types (11%)
133
+ ```
134
+
135
+ ### Phase 3: Anti-Pattern Detection (15 seconds)
136
+
137
+ **Checks Performed**:
138
+ - Security: Hardcoded secrets, SQL injection risks
139
+ - Maintainability: Large files, complex functions
140
+ - Performance: N+1 queries, missing caching
141
+ - Robustness: Missing error handling
142
+
143
+ **Example Output**:
144
+ ```markdown
145
+ ## Issues Found
146
+
147
+ ### 🔴 CRITICAL (2 issues)
148
+ - Hardcoded Secrets: 2 instances
149
+ - src/config/api.ts:12
150
+ - src/utils/auth.ts:45
151
+ Fix: Use process.env variables
152
+
153
+ ### 🟠 HIGH (5 issues)
154
+ - console.* Usage: 5 instances in src/
155
+ - src/core/analyzer.ts:67
156
+ Fix: Use logger abstraction
157
+
158
+ ### 🟡 MEDIUM (12 issues)
159
+ - Large Files: 3 files > 500 lines
160
+ - src/core/orchestrator.ts (678 lines)
161
+ Fix: Split into modules
162
+ ```
163
+
164
+ ### Phase 4: Documentation Generation (10 seconds)
165
+
166
+ **Merge Strategy**:
167
+ 1. Explicit standards = source of truth
168
+ 2. Implicit standards = fill gaps
169
+ 3. Anti-patterns = warnings + recommendations
170
+
171
+ **Output**: `.specweave/docs/internal/governance/coding-standards-analysis.md`
172
+
173
+ ---
174
+
175
+ ## Integration Points
176
+
177
+ ### 1. Brownfield Analyzer Integration
178
+
179
+ **Automatic**: Runs as part of brownfield analysis
180
+
181
+ ```
182
+ User: "Analyze this brownfield project"
183
+
184
+ Workflow:
185
+ 1. Scan project structure
186
+ 2. Classify documents
187
+ 3. Detect external tools
188
+ 4. → RUN code-standards-detective agent
189
+ 5. → GENERATE coding-standards.md
190
+ 6. Generate migration plan
191
+ ```
192
+
193
+ ### 2. Increment Planning
194
+
195
+ **Reference**: Standards included in technical constraints
196
+
197
+ ```markdown
198
+ ## Technical Constraints
199
+
200
+ Coding Standards: .specweave/docs/internal/governance/coding-standards.md
201
+ - Naming: camelCase (vars), PascalCase (classes)
202
+ - Functions: < 50 lines target
203
+ - No console.* - use logger
204
+ ```
205
+
206
+ ### 3. Increment Completion
207
+
208
+ **Optional**: Re-analyze on increment done
209
+
210
+ ```bash
211
+ /specweave:done 0046 --update-standards
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Usage Examples
217
+
218
+ ### Example 1: First-Time Analysis
219
+
220
+ ```
221
+ User: "What are the coding standards for this project?"
222
+
223
+ Skill: code-standards-analyzer
224
+
225
+ Actions:
226
+ 1. Check for existing standards (none found)
227
+ 2. Parse .eslintrc.json, .prettierrc
228
+ 3. Analyze 1,234 TypeScript files
229
+ 4. Detect patterns with 95% confidence
230
+ 5. Generate standards document
231
+
232
+ Output:
233
+ "✅ Analysis complete! Generated coding standards at:
234
+ .specweave/docs/internal/governance/coding-standards-analysis.md
235
+
236
+ Key findings:
237
+ - Naming: 98% camelCase compliance
238
+ - Imports: 100% use .js extensions
239
+ - Issues: 5 console.* usages, 2 hardcoded secrets
240
+ - Recommendation: Formalize detected patterns as official standards"
241
+ ```
242
+
243
+ ### Example 2: Standards Audit
244
+
245
+ ```
246
+ User: "Check if we're following our declared standards"
247
+
248
+ Skill: code-standards-analyzer
249
+
250
+ Actions:
251
+ 1. Read existing coding-standards.md
252
+ 2. Analyze current codebase
253
+ 3. Compare declared vs actual
254
+ 4. Report violations
255
+
256
+ Output:
257
+ "📊 Standards Compliance: 87%
258
+
259
+ ✅ Passing:
260
+ - Naming conventions: 98% compliant
261
+ - Import patterns: 100% compliant
262
+
263
+ ⚠️ Violations:
264
+ - console.* usage: 12 instances (should be 0)
265
+ - Large files: 3 files > 500 lines (should be 0)
266
+
267
+ Recommendation: Fix violations or update standards to reflect reality"
268
+ ```
269
+
270
+ ### Example 3: New Contributor Onboarding
271
+
272
+ ```
273
+ User: "I'm new to this codebase. What conventions should I follow?"
274
+
275
+ Skill: code-standards-analyzer
276
+
277
+ Actions:
278
+ 1. Load existing coding-standards.md
279
+ 2. Extract key rules with examples
280
+ 3. Highlight SpecWeave-specific patterns
281
+
282
+ Output:
283
+ "📚 Coding Standards Summary
284
+
285
+ 1. Naming:
286
+ - Variables: camelCase (e.g., `userId`, `isActive`)
287
+ - Functions: camelCase (e.g., `getUserById()`)
288
+ - Classes: PascalCase (e.g., `UserService`)
289
+
290
+ 2. Imports:
291
+ - Always use .js extensions
292
+ - Example: import { foo } from './bar.js'
293
+
294
+ 3. Error Handling:
295
+ - Use custom error types
296
+ - Example: throw new UserNotFoundError(id)
297
+
298
+ 4. Logging:
299
+ - NEVER use console.*
300
+ - Use logger abstraction instead
301
+
302
+ Full standards: .specweave/docs/internal/governance/coding-standards.md"
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Commands
308
+
309
+ ### Manual Analysis
310
+
311
+ ```bash
312
+ # Full analysis
313
+ /specweave:analyze-standards
314
+
315
+ # Drift detection only
316
+ /specweave:analyze-standards --drift
317
+
318
+ # Update existing standards
319
+ /specweave:analyze-standards --update
320
+ ```
321
+
322
+ ---
323
+
324
+ ## Output Files
325
+
326
+ ### 1. `coding-standards-analysis.md` (Auto-Generated)
327
+
328
+ **Location**: `.specweave/docs/internal/governance/coding-standards-analysis.md`
329
+
330
+ **Purpose**: Latest analysis report (gitignored, temporary)
331
+
332
+ **Contents**:
333
+ - Detected patterns with confidence levels
334
+ - Real code examples
335
+ - Statistical evidence
336
+ - Violation warnings
337
+ - Recommendations
338
+
339
+ ### 2. `coding-standards.md` (Source of Truth)
340
+
341
+ **Location**: `.specweave/docs/internal/governance/coding-standards.md`
342
+
343
+ **Purpose**: Official coding standards (git-tracked, manual + auto)
344
+
345
+ **Contents**:
346
+ - Naming conventions
347
+ - Import patterns
348
+ - Function guidelines
349
+ - Type safety rules
350
+ - Error handling
351
+ - Security practices
352
+ - Performance guidelines
353
+
354
+ ### 3. `coding-standards-history.md` (Change Log)
355
+
356
+ **Location**: `.specweave/docs/internal/governance/coding-standards-history.md`
357
+
358
+ **Purpose**: Track standard evolution over time
359
+
360
+ **Contents**:
361
+ - Timestamp of each analysis
362
+ - Changes detected
363
+ - Migration guides
364
+ - Rationale for updates
365
+
366
+ ---
367
+
368
+ ## Best Practices
369
+
370
+ ### 1. Run During Onboarding
371
+ - Analyze standards as part of brownfield analysis
372
+ - Generate baseline documentation
373
+ - Establish project context
374
+
375
+ ### 2. Periodic Re-Analysis
376
+ - Quarterly reviews
377
+ - After major refactors
378
+ - On team onboarding
379
+
380
+ ### 3. Team Review Required
381
+ - Don't auto-commit changes
382
+ - Review generated standards
383
+ - Discuss inconsistencies
384
+ - Formalize decisions
385
+
386
+ ### 4. Living Documentation
387
+ - Keep standards in sync with code
388
+ - Update when patterns change
389
+ - Track evolution in history
390
+
391
+ ### 5. Enforcement Through Tooling
392
+ - Most standards → ESLint/Prettier
393
+ - This skill → document what tools can't catch
394
+ - Focus on SpecWeave-specific patterns
395
+
396
+ ---
397
+
398
+ ## Related Documentation
399
+
400
+ - [Coding Standards](.specweave/docs/internal/governance/coding-standards.md) - Official standards
401
+ - [Code Review Standards](.specweave/docs/internal/delivery/core/code-review-standards.md) - Review process
402
+ - [Brownfield Analyzer](../brownfield-analyzer/SKILL.md) - Project analysis
403
+
404
+ ---
405
+
406
+ ## Technical Details
407
+
408
+ ### Supported Languages
409
+ - ✅ TypeScript (primary)
410
+ - ✅ JavaScript (ES6+)
411
+ - 🔜 Python (future)
412
+ - 🔜 Java (future)
413
+ - 🔜 Go (future)
414
+
415
+ ### Detection Algorithms
416
+
417
+ **Naming Convention Detection**:
418
+ - Regex pattern matching
419
+ - Statistical frequency analysis
420
+ - AST node analysis
421
+ - Confidence scoring (samples / total)
422
+
423
+ **Anti-Pattern Detection**:
424
+ - Static analysis (grep, AST parsing)
425
+ - Rule-based checks
426
+ - Security scanning
427
+ - Complexity metrics
428
+
429
+ **Confidence Levels**:
430
+ - ENFORCED: Linter/compiler enforced (100%)
431
+ - HIGH: 90%+ compliance in codebase
432
+ - MEDIUM: 70-89% compliance
433
+ - LOW: 50-69% compliance
434
+ - CONFLICT: <50% compliance (inconsistent)
435
+
436
+ ---
437
+
438
+ ## Limitations
439
+
440
+ 1. **Implicit Standards**: Requires representative codebase sample
441
+ 2. **False Positives**: Anti-pattern detection may flag intentional code
442
+ 3. **Language Support**: Currently TypeScript/JavaScript only
443
+ 4. **Context**: Can't understand business rationale for patterns
444
+
445
+ ---
446
+
447
+ ## Future Enhancements
448
+
449
+ - [ ] Multi-language support (Python, Java, Go)
450
+ - [ ] Auto-generate ESLint rules from detected patterns
451
+ - [ ] AI-powered suggestions from top OSS projects
452
+ - [ ] Team-specific standards in multi-project mode
453
+ - [ ] Pre-commit hook integration for enforcement
454
+ - [ ] Real-time drift alerts
455
+ - [ ] Standards comparison across projects