@paths.design/caws-cli 3.5.0 → 4.1.0

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 (87) hide show
  1. package/dist/budget-derivation.d.ts +41 -2
  2. package/dist/budget-derivation.d.ts.map +1 -1
  3. package/dist/budget-derivation.js +417 -30
  4. package/dist/commands/archive.d.ts +50 -0
  5. package/dist/commands/archive.d.ts.map +1 -0
  6. package/dist/commands/archive.js +353 -0
  7. package/dist/commands/iterate.d.ts.map +1 -1
  8. package/dist/commands/iterate.js +12 -13
  9. package/dist/commands/mode.d.ts +24 -0
  10. package/dist/commands/mode.d.ts.map +1 -0
  11. package/dist/commands/mode.js +259 -0
  12. package/dist/commands/plan.d.ts +49 -0
  13. package/dist/commands/plan.d.ts.map +1 -0
  14. package/dist/commands/plan.js +448 -0
  15. package/dist/commands/quality-gates.d.ts +52 -0
  16. package/dist/commands/quality-gates.d.ts.map +1 -0
  17. package/dist/commands/quality-gates.js +490 -0
  18. package/dist/commands/specs.d.ts +71 -0
  19. package/dist/commands/specs.d.ts.map +1 -0
  20. package/dist/commands/specs.js +735 -0
  21. package/dist/commands/status.d.ts +4 -3
  22. package/dist/commands/status.d.ts.map +1 -1
  23. package/dist/commands/status.js +552 -22
  24. package/dist/commands/tutorial.d.ts +55 -0
  25. package/dist/commands/tutorial.d.ts.map +1 -0
  26. package/dist/commands/tutorial.js +481 -0
  27. package/dist/commands/validate.d.ts +10 -2
  28. package/dist/commands/validate.d.ts.map +1 -1
  29. package/dist/commands/validate.js +199 -39
  30. package/dist/config/modes.d.ts +225 -0
  31. package/dist/config/modes.d.ts.map +1 -0
  32. package/dist/config/modes.js +321 -0
  33. package/dist/constants/spec-types.d.ts +41 -0
  34. package/dist/constants/spec-types.d.ts.map +1 -0
  35. package/dist/constants/spec-types.js +42 -0
  36. package/dist/index-new.d.ts +5 -0
  37. package/dist/index-new.d.ts.map +1 -0
  38. package/dist/index-new.js +317 -0
  39. package/dist/index.js +227 -10
  40. package/dist/index.js.backup +4711 -0
  41. package/dist/policy/PolicyManager.d.ts +104 -0
  42. package/dist/policy/PolicyManager.d.ts.map +1 -0
  43. package/dist/policy/PolicyManager.js +399 -0
  44. package/dist/scaffold/cursor-hooks.d.ts.map +1 -1
  45. package/dist/scaffold/cursor-hooks.js +15 -0
  46. package/dist/scaffold/git-hooks.d.ts.map +1 -1
  47. package/dist/scaffold/git-hooks.js +32 -44
  48. package/dist/scaffold/index.d.ts.map +1 -1
  49. package/dist/scaffold/index.js +19 -0
  50. package/dist/spec/SpecFileManager.d.ts +146 -0
  51. package/dist/spec/SpecFileManager.d.ts.map +1 -0
  52. package/dist/spec/SpecFileManager.js +419 -0
  53. package/dist/utils/quality-gates-errors.js +520 -0
  54. package/dist/utils/quality-gates.d.ts +49 -0
  55. package/dist/utils/quality-gates.d.ts.map +1 -0
  56. package/dist/utils/quality-gates.js +361 -0
  57. package/dist/utils/spec-resolver.d.ts +88 -0
  58. package/dist/utils/spec-resolver.d.ts.map +1 -0
  59. package/dist/utils/spec-resolver.js +602 -0
  60. package/dist/validation/spec-validation.d.ts +14 -0
  61. package/dist/validation/spec-validation.d.ts.map +1 -1
  62. package/dist/validation/spec-validation.js +225 -13
  63. package/package.json +6 -5
  64. package/templates/.cursor/hooks/caws-scope-guard.sh +64 -8
  65. package/templates/.cursor/hooks/validate-spec.sh +22 -12
  66. package/templates/.cursor/rules/00-claims-verification.mdc +144 -0
  67. package/templates/.cursor/rules/01-working-style.mdc +50 -0
  68. package/templates/.cursor/rules/02-quality-gates.mdc +370 -0
  69. package/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
  70. package/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
  71. package/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
  72. package/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
  73. package/templates/.cursor/rules/07-process-ops.mdc +20 -0
  74. package/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
  75. package/templates/.cursor/rules/09-docstrings.mdc +89 -0
  76. package/templates/.cursor/rules/10-authorship-and-attribution.mdc +15 -0
  77. package/templates/.cursor/rules/11-documentation-quality-standards.mdc +390 -0
  78. package/templates/.cursor/rules/12-scope-management-waivers.mdc +385 -0
  79. package/templates/.cursor/rules/13-implementation-completeness.mdc +516 -0
  80. package/templates/.cursor/rules/14-language-agnostic-standards.mdc +588 -0
  81. package/templates/.cursor/rules/15-sophisticated-todo-detection.mdc +425 -0
  82. package/templates/.cursor/rules/README.md +150 -0
  83. package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
  84. package/templates/apps/tools/caws/provenance.js.backup +73 -0
  85. package/templates/scripts/quality-gates/check-god-objects.js +146 -0
  86. package/templates/scripts/quality-gates/run-quality-gates.js +50 -0
  87. package/templates/scripts/v3/analysis/todo_analyzer.py +1950 -0
@@ -0,0 +1,385 @@
1
+ ---
2
+ description: Scope management, change budgets, and emergency waiver procedures for critical fixes
3
+ globs:
4
+ alwaysApply: true
5
+ ---
6
+
7
+ # Scope Management & Waiver System
8
+
9
+ ## Core Principle
10
+
11
+ **All changes must stay within defined scope and budget limits.** Emergency situations require structured waiver procedures with proper documentation and mitigation plans.
12
+
13
+ ## Change Budget Enforcement
14
+
15
+ ### Budget Definition
16
+
17
+ ```yaml
18
+ # Working spec requirements
19
+ change_budget:
20
+ max_files: 25
21
+ max_loc: 1000
22
+ max_days: 3
23
+ max_complexity: 10 # Cyclomatic complexity
24
+ ```
25
+
26
+ ### Scope Boundaries
27
+
28
+ ```yaml
29
+ scope:
30
+ in: ['src/auth/', 'tests/auth/', 'package.json']
31
+ out: ['src/billing/', 'node_modules/', 'dist/']
32
+ blast_radius:
33
+ modules: ['auth', 'api']
34
+ data_migration: false
35
+ external_apis: false
36
+ ```
37
+
38
+ ### Automatic Detection
39
+
40
+ **CI/CD Integration:**
41
+
42
+ - Block commits that touch files outside `scope.in`
43
+ - Fail if change exceeds `max_files` or `max_loc`
44
+ - Require justification for budget increases
45
+ - Track scope violations in metrics
46
+
47
+ ## Emergency Waiver System
48
+
49
+ ### Waiver Triggers
50
+
51
+ **Critical situations requiring waivers:**
52
+
53
+ - Security vulnerabilities
54
+ - Production outages
55
+ - Data corruption
56
+ - Critical business impact
57
+ - Regulatory compliance issues
58
+
59
+ ### Waiver Process
60
+
61
+ ```yaml
62
+ # Emergency waiver workflow
63
+ waiver:
64
+ id: 'CRITICAL-FIX-001'
65
+ title: 'Security Hotfix for Auth Bypass'
66
+ reason: 'security_vulnerability'
67
+ impact_level: 'high' # low, medium, high, critical
68
+ approved_by: 'security_team'
69
+ expires_at: '2024-01-15'
70
+ gates_waived: ['coverage_threshold', 'mutation_score']
71
+ mitigation_plan: 'Full test suite added in follow-up PR'
72
+ rollback_plan: 'Revert to previous auth implementation'
73
+ ```
74
+
75
+ ### Waiver Documentation Requirements
76
+
77
+ **Must include:**
78
+
79
+ - Root cause analysis
80
+ - Minimal fix description
81
+ - Risk assessment
82
+ - Mitigation timeline
83
+ - Prevention measures
84
+ - Rollback procedures
85
+
86
+ ## Scope Blowout Protocols
87
+
88
+ ### Detection & Response
89
+
90
+ **Automatic Detection:**
91
+
92
+ ```bash
93
+ # Check for scope violations
94
+ git diff --name-only HEAD~1 | grep -v -E "^($(echo "${SCOPE_IN}" | tr ' ' '|'))"
95
+ ```
96
+
97
+ **Response Strategies:**
98
+
99
+ 1. **Split Strategy**: Break large changes into focused PRs
100
+ 2. **Budget Increase**: Requires human approval with justification
101
+ 3. **Emergency Override**: Security fixes can bypass scope limits
102
+ 4. **Scope Update**: Modify scope.in with proper documentation
103
+
104
+ ### Budget Increase Process
105
+
106
+ **Requirements for budget increase:**
107
+
108
+ - Detailed justification
109
+ - Risk assessment
110
+ - Mitigation plan
111
+ - Timeline for completion
112
+ - Human approval (not automated)
113
+
114
+ ## Critical Fix Procedures
115
+
116
+ ### Emergency Fix Workflow
117
+
118
+ ```yaml
119
+ emergency_fix:
120
+ triggers:
121
+ - security_vulnerability
122
+ - production_outage
123
+ - data_corruption
124
+ - critical_business_impact
125
+
126
+ process: 1. "Create emergency waiver"
127
+ 2. "Implement minimal fix"
128
+ 3. "Deploy with monitoring"
129
+ 4. "Follow up with comprehensive solution"
130
+
131
+ documentation:
132
+ - 'Root cause analysis'
133
+ - 'Minimal fix description'
134
+ - 'Risk assessment'
135
+ - 'Mitigation timeline'
136
+ - 'Prevention measures'
137
+ ```
138
+
139
+ ### Emergency Override Conditions
140
+
141
+ **Can bypass scope limits when:**
142
+
143
+ - Security vulnerability with active exploitation
144
+ - Production system completely down
145
+ - Data corruption in progress
146
+ - Regulatory compliance deadline
147
+
148
+ **Cannot bypass:**
149
+
150
+ - Code quality gates (linting, type checking)
151
+ - Security scanning
152
+ - Basic testing requirements
153
+ - Documentation standards
154
+
155
+ ## Waiver Management Commands
156
+
157
+ ### CAWS Integration
158
+
159
+ ```bash
160
+ # Create waiver
161
+ caws waivers create \
162
+ --title "Security Hotfix" \
163
+ --reason "security_vulnerability" \
164
+ --gates "coverage_threshold,mutation_score" \
165
+ --expires-at "2024-01-15" \
166
+ --approved-by "security_team" \
167
+ --impact-level "high" \
168
+ --mitigation-plan "Full test suite in follow-up PR"
169
+
170
+ # List active waivers
171
+ caws waivers list --status=active
172
+
173
+ # Check waiver status
174
+ caws waivers status --waiver-id="CRITICAL-FIX-001"
175
+ ```
176
+
177
+ ## Quality Gates by Risk Tier
178
+
179
+ ### Tier 1 (Critical Systems)
180
+
181
+ - **Coverage**: 90%+ line, 95%+ branch
182
+ - **Mutation Score**: 70%+
183
+ - **Contracts**: Required
184
+ - **Review**: Manual required
185
+ - **Security Scan**: Required
186
+ - **Waiver Approval**: Security team
187
+
188
+ ### Tier 2 (Standard Features)
189
+
190
+ - **Coverage**: 80%+ line, 90%+ branch
191
+ - **Mutation Score**: 50%+
192
+ - **Contracts**: Required
193
+ - **Review**: Optional
194
+ - **Security Scan**: Required
195
+ - **Waiver Approval**: Tech lead
196
+
197
+ ### Tier 3 (Low Risk)
198
+
199
+ - **Coverage**: 70%+ line, 80%+ branch
200
+ - **Mutation Score**: 30%+
201
+ - **Contracts**: Optional
202
+ - **Review**: Optional
203
+ - **Security Scan**: Recommended
204
+ - **Waiver Approval**: Developer
205
+
206
+ ## Enforcement Mechanisms
207
+
208
+ ### Pre-Commit Hooks
209
+
210
+ ```bash
211
+ # Check scope compliance
212
+ check-scope-compliance() {
213
+ local changed_files=$(git diff --cached --name-only)
214
+ local scope_violations=$(echo "$changed_files" | grep -v -E "^($(echo "${SCOPE_IN}" | tr ' ' '|'))")
215
+
216
+ if [ -n "$scope_violations" ]; then
217
+ echo "❌ Scope violation detected:"
218
+ echo "$scope_violations"
219
+ echo "Files outside scope.in boundaries"
220
+ exit 1
221
+ fi
222
+ }
223
+
224
+ # Check change budget
225
+ check-change-budget() {
226
+ local file_count=$(git diff --cached --name-only | wc -l)
227
+ local loc_count=$(git diff --cached --numstat | awk '{sum += $1 + $2} END {print sum}')
228
+
229
+ if [ "$file_count" -gt 25 ]; then
230
+ echo "❌ Change exceeds file budget: $file_count > 25"
231
+ echo "Consider splitting into smaller commits"
232
+ exit 1
233
+ fi
234
+
235
+ if [ "$loc_count" -gt 1000 ]; then
236
+ echo "❌ Change exceeds LOC budget: $loc_count > 1000"
237
+ echo "Consider splitting into smaller commits"
238
+ exit 1
239
+ fi
240
+ }
241
+ ```
242
+
243
+ ### CI/CD Integration
244
+
245
+ ```yaml
246
+ # GitHub Actions example
247
+ - name: Check Scope Compliance
248
+ run: |
249
+ if ! caws validate --scope-check; then
250
+ echo "❌ Scope violation detected"
251
+ exit 1
252
+ fi
253
+
254
+ - name: Check Change Budget
255
+ run: |
256
+ file_count=$(git diff --name-only HEAD~1 | wc -l)
257
+ loc_count=$(git diff --numstat HEAD~1 | awk '{sum += $1 + $2} END {print sum}')
258
+
259
+ if [ "$file_count" -gt 25 ]; then
260
+ echo "❌ Change exceeds file budget: $file_count > 25"
261
+ exit 1
262
+ fi
263
+
264
+ if [ "$loc_count" -gt 1000 ]; then
265
+ echo "❌ Change exceeds LOC budget: $loc_count > 1000"
266
+ exit 1
267
+ fi
268
+
269
+ - name: Check Active Waivers
270
+ run: |
271
+ active_waivers=$(caws waivers list --status=active --format=count)
272
+ if [ "$active_waivers" -gt 5 ]; then
273
+ echo "⚠️ High number of active waivers: $active_waivers"
274
+ fi
275
+ ```
276
+
277
+ ## Metrics & Monitoring
278
+
279
+ ### Scope Compliance Metrics
280
+
281
+ - **Scope Violation Rate**: % of commits violating scope
282
+ - **Budget Overrun Rate**: % of changes exceeding budget
283
+ - **Waiver Usage**: Number of active waivers by type
284
+ - **Emergency Fix Frequency**: Rate of emergency fixes
285
+ - **Mitigation Completion**: % of waivers with completed mitigation
286
+
287
+ ### Quality Trends
288
+
289
+ - **Coverage by Tier**: Track coverage trends per risk tier
290
+ - **Mutation Score Trends**: Monitor mutation testing scores
291
+ - **Review Coverage**: % of changes with proper review
292
+ - **Security Scan Results**: Track security scan violations
293
+
294
+ ## CAWS-Specific Integration
295
+
296
+ ### Working Spec Integration
297
+
298
+ ```yaml
299
+ # In .caws/working-spec.yaml
300
+ scope:
301
+ in: ['src/auth/', 'tests/auth/', 'docs/auth/']
302
+ out: ['src/billing/', 'src/payments/', 'node_modules/']
303
+ blast_radius:
304
+ modules: ['auth', 'api']
305
+ data_migration: false
306
+ external_apis: false
307
+
308
+ change_budget:
309
+ max_files: 25
310
+ max_loc: 1000
311
+ max_days: 3
312
+ max_complexity: 10
313
+
314
+ risk_tier: 'T2' # T1, T2, or T3
315
+ ```
316
+
317
+ ### CAWS Commands
318
+
319
+ ```bash
320
+ # Validate scope compliance
321
+ caws validate --scope-check
322
+
323
+ # Check change budget
324
+ caws validate --budget-check
325
+
326
+ # Create emergency waiver
327
+ caws waivers create \
328
+ --title "Critical Auth Fix" \
329
+ --reason "security_vulnerability" \
330
+ --gates "coverage_threshold" \
331
+ --expires-at "2024-01-15" \
332
+ --approved-by "security_team" \
333
+ --impact-level "critical" \
334
+ --mitigation-plan "Full test suite in follow-up PR"
335
+
336
+ # List active waivers
337
+ caws waivers list --status=active
338
+
339
+ # Check waiver status
340
+ caws waivers status --waiver-id="AUTH-FIX-001"
341
+ ```
342
+
343
+ ### Quality Gate Integration
344
+
345
+ ```bash
346
+ # Run quality gates with tier-specific requirements
347
+ caws quality-gates --tier=T2
348
+
349
+ # Check if waiver is required
350
+ caws quality-gates --check-waiver-required
351
+
352
+ # Apply waiver to quality gates
353
+ caws quality-gates --apply-waiver=AUTH-FIX-001
354
+ ```
355
+
356
+ ## Continuous Improvement
357
+
358
+ ### Monthly Reviews
359
+
360
+ - Review scope violation patterns
361
+ - Analyze waiver usage and effectiveness
362
+ - Update scope boundaries based on project evolution
363
+ - Refine budget limits based on team capacity
364
+
365
+ ### Quarterly Audits
366
+
367
+ - Full scope compliance audit
368
+ - Waiver effectiveness review
369
+ - Emergency procedure testing
370
+ - Quality gate threshold review
371
+
372
+ ### CAWS Integration Points
373
+
374
+ ```bash
375
+ # Track scope compliance in CAWS metrics
376
+ caws metrics track --metric="scope_violations" --value=0
377
+
378
+ # Update progress with scope compliance
379
+ caws progress update --criterion-id="SCOPE-001" --status="completed"
380
+
381
+ # Archive changes with scope compliance verification
382
+ caws archive FEAT-001 --verify-scope-compliance
383
+ ```
384
+
385
+ This rule ensures proper scope management while providing structured escape hatches for critical situations that require immediate attention, fully integrated with CAWS workflow and quality gates.