@paths.design/caws-cli 2.0.1 → 3.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 (52) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +1463 -121
  3. package/package.json +3 -2
  4. package/templates/agents.md +820 -0
  5. package/templates/apps/tools/caws/COMPLETION_REPORT.md +331 -0
  6. package/templates/apps/tools/caws/MIGRATION_SUMMARY.md +360 -0
  7. package/templates/apps/tools/caws/README.md +463 -0
  8. package/templates/apps/tools/caws/TEST_STATUS.md +365 -0
  9. package/templates/apps/tools/caws/attest.js +357 -0
  10. package/templates/apps/tools/caws/ci-optimizer.js +642 -0
  11. package/templates/apps/tools/caws/config.ts +245 -0
  12. package/templates/apps/tools/caws/cross-functional.js +876 -0
  13. package/templates/apps/tools/caws/dashboard.js +1112 -0
  14. package/templates/apps/tools/caws/flake-detector.ts +362 -0
  15. package/templates/apps/tools/caws/gates.js +198 -0
  16. package/templates/apps/tools/caws/gates.ts +237 -0
  17. package/templates/apps/tools/caws/language-adapters.ts +381 -0
  18. package/templates/apps/tools/caws/language-support.d.ts +367 -0
  19. package/templates/apps/tools/caws/language-support.d.ts.map +1 -0
  20. package/templates/apps/tools/caws/language-support.js +585 -0
  21. package/templates/apps/tools/caws/legacy-assessment.ts +408 -0
  22. package/templates/apps/tools/caws/legacy-assessor.js +764 -0
  23. package/templates/apps/tools/caws/mutant-analyzer.js +734 -0
  24. package/templates/apps/tools/caws/perf-budgets.ts +349 -0
  25. package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
  26. package/templates/apps/tools/caws/property-testing.js +707 -0
  27. package/templates/apps/tools/caws/provenance.d.ts +14 -0
  28. package/templates/apps/tools/caws/provenance.d.ts.map +1 -0
  29. package/templates/apps/tools/caws/provenance.js +132 -0
  30. package/templates/apps/tools/caws/provenance.js.backup +73 -0
  31. package/templates/apps/tools/caws/provenance.ts +211 -0
  32. package/templates/apps/tools/caws/schemas/waivers.schema.json +30 -0
  33. package/templates/apps/tools/caws/schemas/working-spec.schema.json +115 -0
  34. package/templates/apps/tools/caws/scope-guard.js +208 -0
  35. package/templates/apps/tools/caws/security-provenance.ts +483 -0
  36. package/templates/apps/tools/caws/shared/base-tool.ts +281 -0
  37. package/templates/apps/tools/caws/shared/config-manager.ts +366 -0
  38. package/templates/apps/tools/caws/shared/gate-checker.ts +597 -0
  39. package/templates/apps/tools/caws/shared/types.ts +444 -0
  40. package/templates/apps/tools/caws/shared/validator.ts +305 -0
  41. package/templates/apps/tools/caws/shared/waivers-manager.ts +174 -0
  42. package/templates/apps/tools/caws/spec-test-mapper.ts +391 -0
  43. package/templates/apps/tools/caws/templates/working-spec.template.yml +60 -0
  44. package/templates/apps/tools/caws/test-quality.js +578 -0
  45. package/templates/apps/tools/caws/tools-allow.json +331 -0
  46. package/templates/apps/tools/caws/validate.js +76 -0
  47. package/templates/apps/tools/caws/validate.ts +228 -0
  48. package/templates/apps/tools/caws/waivers.js +344 -0
  49. package/templates/apps/tools/caws/waivers.yml +19 -0
  50. package/templates/codemod/README.md +1 -0
  51. package/templates/codemod/test.js +1 -0
  52. package/templates/docs/README.md +150 -0
@@ -0,0 +1,463 @@
1
+ ## CAWS (Code Assessment Workflow System) Tools
2
+
3
+ A comprehensive suite of tools for code quality assessment, compliance checking, and trust scoring integrated into your development workflow.
4
+
5
+ ## 🎯 Overview
6
+
7
+ CAWS provides automated quality gates, performance monitoring, test variance detection, and spec-to-test traceability to ensure high-quality code delivery.
8
+
9
+ ---
10
+
11
+ ## 📦 Architecture
12
+
13
+ ### Shared Components (`shared/`)
14
+
15
+ All CAWS tools are built on a unified architecture with shared utilities:
16
+
17
+ - **`base-tool.ts`** - Base class providing common functionality
18
+ - **`types.ts`** - Centralized type definitions
19
+ - **`validator.ts`** - Validation utilities
20
+ - **`config-manager.ts`** - Configuration management
21
+ - **`gate-checker.ts`** - Gate checking logic
22
+ - **`waivers-manager.ts`** - Waivers management
23
+
24
+ ---
25
+
26
+ ## 🔧 Core Tools
27
+
28
+ ### Quality Gates
29
+
30
+ #### `gates.js`
31
+
32
+ Basic gate enforcement for coverage, mutation, trust score, and budget.
33
+
34
+ ```bash
35
+ node gates.js tier 2
36
+ node gates.js coverage 0.85
37
+ node gates.js mutation 0.60
38
+ node gates.js trust 85
39
+ node gates.js budget 20 800
40
+ ```
41
+
42
+ #### `validate.js`
43
+
44
+ Validates working specifications and project structure.
45
+
46
+ ```bash
47
+ node validate.js .caws/working-spec.yaml
48
+ ```
49
+
50
+ ### Provenance & Attestations
51
+
52
+ #### `provenance.js`
53
+
54
+ Generates provenance information for CAWS projects.
55
+
56
+ ```bash
57
+ node provenance.js
58
+ ```
59
+
60
+ #### `attest.js`
61
+
62
+ Generates SBOM and SLSA-style attestations.
63
+
64
+ ```bash
65
+ node attest.js /path/to/project .agent
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 🚀 Advanced Tools
71
+
72
+ ### Flake Detection
73
+
74
+ #### `flake-detector.ts`
75
+
76
+ Monitors test variance and quarantines flaky tests automatically.
77
+
78
+ ```bash
79
+ npx tsx flake-detector.ts detect
80
+ npx tsx flake-detector.ts quarantine "test name"
81
+ npx tsx flake-detector.ts release "test name"
82
+ npx tsx flake-detector.ts status
83
+ ```
84
+
85
+ **Features:**
86
+
87
+ - Analyzes test run variance
88
+ - Identifies intermittently failing tests
89
+ - Automatic quarantine based on flake rate threshold (15%)
90
+ - Tracks historical test data
91
+ - Variance score calculation
92
+
93
+ ---
94
+
95
+ ### Spec-to-Test Mapping
96
+
97
+ #### `spec-test-mapper.ts`
98
+
99
+ Links acceptance criteria to actual test cases for full traceability.
100
+
101
+ ```bash
102
+ npx tsx spec-test-mapper.ts report
103
+ npx tsx spec-test-mapper.ts save docs/spec-coverage.md
104
+ ```
105
+
106
+ **Features:**
107
+
108
+ - Maps acceptance criteria to test files
109
+ - Generates coverage reports
110
+ - Identifies uncovered criteria
111
+ - Supports multiple test types (unit, integration, e2e, property-based)
112
+ - Keyword-based test discovery
113
+
114
+ ---
115
+
116
+ ### Performance Budget Validation
117
+
118
+ #### `perf-budgets.ts`
119
+
120
+ Validates API performance against working spec budgets.
121
+
122
+ ```bash
123
+ npx tsx perf-budgets.ts
124
+ npx tsx perf-budgets.ts --real-data
125
+ ```
126
+
127
+ **Features:**
128
+
129
+ - Validates p95 latency against budgets
130
+ - Supports mock and real performance data
131
+ - Per-endpoint tracking
132
+ - Deviation percentage reporting
133
+ - CI/CD integration
134
+
135
+ ---
136
+
137
+ ### Configuration Management
138
+
139
+ #### `config.ts`
140
+
141
+ Comprehensive configuration management with YAML import/export.
142
+
143
+ ```bash
144
+ npx tsx config.ts get
145
+ npx tsx config.ts get gates
146
+ npx tsx config.ts set gates.coverage.enabled false
147
+ npx tsx config.ts export > config.yaml
148
+ npx tsx config.ts import config.yaml
149
+ npx tsx config.ts features
150
+ npx tsx config.ts paths
151
+ npx tsx config.ts gates
152
+ npx tsx config.ts tools
153
+ ```
154
+
155
+ **Features:**
156
+
157
+ - Get/set configuration values
158
+ - Import/export YAML
159
+ - Section-specific views
160
+ - Feature flag management
161
+ - Path configuration
162
+
163
+ ---
164
+
165
+ ### Waivers Management
166
+
167
+ #### `waivers.js`
168
+
169
+ Manages time-boxed waivers for quality gates.
170
+
171
+ ```bash
172
+ node waivers.js create HOTFIX-001 "Urgent fix" "mutation,coverage" urgent_fix "senior-dev" 3
173
+ node waivers.js list
174
+ node waivers.js check PROJECT-123 mutation
175
+ node waivers.js cleanup
176
+ ```
177
+
178
+ **Features:**
179
+
180
+ - Time-boxed exemptions
181
+ - Multiple gate support
182
+ - Approval tracking
183
+ - Automatic expiry
184
+ - Project-specific waivers
185
+
186
+ ---
187
+
188
+ ## 📊 Test Quality Tools
189
+
190
+ ### `test-quality.js`
191
+
192
+ Analyzes test meaningfulness beyond coverage.
193
+
194
+ ```bash
195
+ node test-quality.js analyze tests .caws/working-spec.yaml
196
+ ```
197
+
198
+ **Checks:**
199
+
200
+ - Meaningful assertions
201
+ - Spec coverage
202
+ - Property-based tests
203
+ - Edge case coverage
204
+ - Weak test detection
205
+
206
+ ---
207
+
208
+ ### `property-testing.js`
209
+
210
+ Property-based testing utilities.
211
+
212
+ ---
213
+
214
+ ### `mutant-analyzer.js`
215
+
216
+ Analyzes mutation testing results.
217
+
218
+ ---
219
+
220
+ ## 🌍 Multi-Language Support
221
+
222
+ ### `language-adapters.ts`
223
+
224
+ Adapts CAWS to different programming languages with language-specific tools and thresholds.
225
+
226
+ ```bash
227
+ npx tsx language-adapters.ts detect
228
+ npx tsx language-adapters.ts list
229
+ npx tsx language-adapters.ts config python
230
+ npx tsx language-adapters.ts tier rust 2
231
+ ```
232
+
233
+ **Supported Languages:**
234
+
235
+ - **TypeScript/JavaScript** - vitest, stryker, pact, eslint
236
+ - **Python** - pytest, mutmut, schemathesis, ruff
237
+ - **Rust** - cargo test/tarpaulin/mutants/clippy
238
+ - **Go** - go test, golangci-lint
239
+ - **Java** - maven (jacoco, pitest, pact, checkstyle)
240
+
241
+ **Features:**
242
+
243
+ - Auto-detect project language
244
+ - Language-specific tool configurations
245
+ - Adjusted tier policies per language
246
+ - Fallback strategies for unavailable tools
247
+ - Tool availability checking
248
+
249
+ ---
250
+
251
+ ## 🔒 Security & Compliance
252
+
253
+ ### `security-provenance.ts`
254
+
255
+ Cryptographic signing, SLSA attestations, and security scanning.
256
+
257
+ ```bash
258
+ npx tsx security-provenance.ts sign .agent/provenance.json
259
+ npx tsx security-provenance.ts verify .agent/provenance.json <signature>
260
+ npx tsx security-provenance.ts scan .
261
+ npx tsx security-provenance.ts slsa <commit-hash>
262
+ ```
263
+
264
+ **Features:**
265
+
266
+ - Cryptographic artifact signing
267
+ - Signature verification
268
+ - Model provenance tracking
269
+ - Prompt hashing for audit trails
270
+ - Secret scanning
271
+ - SAST integration placeholder
272
+ - Dependency scanning
273
+ - SLSA attestation generation
274
+
275
+ ---
276
+
277
+ ### `prompt-lint.js`
278
+
279
+ Validates prompts for secrets and tool allowlisting.
280
+
281
+ **Features:**
282
+
283
+ - Secret pattern detection
284
+ - Tool allowlist validation
285
+ - Provenance hashing
286
+
287
+ ---
288
+
289
+ ## 📊 Legacy Code Migration
290
+
291
+ ### `legacy-assessment.ts`
292
+
293
+ Assess legacy code for CAWS migration and generate phased migration plans.
294
+
295
+ ```bash
296
+ npx tsx legacy-assessment.ts assess src/auth
297
+ npx tsx legacy-assessment.ts plan .
298
+ ```
299
+
300
+ **Features:**
301
+
302
+ - Complexity analysis (cyclomatic complexity)
303
+ - Current coverage assessment
304
+ - Change frequency analysis
305
+ - Dependency analysis
306
+ - Recommended tier inference
307
+ - Migration priority calculation
308
+ - Quick wins identification
309
+ - Effort estimation
310
+ - Phased migration plan generation
311
+ - Critical path identification
312
+
313
+ **Assessment Metrics:**
314
+
315
+ - **Complexity** - Average cyclomatic complexity per file
316
+ - **Coverage** - Current test coverage percentage
317
+ - **Change Frequency** - How often the module changes
318
+ - **Dependencies** - Average imports per file
319
+ - **Recommended Tier** - Suggested CAWS tier based on risk
320
+ - **Migration Priority** - High/Medium/Low priority
321
+ - **Estimated Effort** - Small (2 days), Medium (5 days), Large (10 days)
322
+
323
+ ---
324
+
325
+ ## 📋 Configuration
326
+
327
+ ### Default Configuration Structure
328
+
329
+ ```json
330
+ {
331
+ "version": "1.0.0",
332
+ "environment": "development",
333
+ "gates": {
334
+ "coverage": {
335
+ "enabled": true,
336
+ "thresholds": {
337
+ "statements": 80,
338
+ "branches": 75,
339
+ "functions": 80,
340
+ "lines": 80
341
+ }
342
+ },
343
+ "mutation": {
344
+ "enabled": true,
345
+ "thresholds": {
346
+ "killed": 70,
347
+ "survived": 30
348
+ }
349
+ },
350
+ "contracts": {
351
+ "enabled": true,
352
+ "required": true
353
+ }
354
+ },
355
+ "tiers": {
356
+ "1": {
357
+ "min_branch": 0.9,
358
+ "min_coverage": 0.9,
359
+ "min_mutation": 0.8,
360
+ "requires_contracts": true
361
+ },
362
+ "2": {
363
+ "min_branch": 0.8,
364
+ "min_coverage": 0.8,
365
+ "min_mutation": 0.7,
366
+ "requires_contracts": true
367
+ },
368
+ "3": {
369
+ "min_branch": 0.7,
370
+ "min_coverage": 0.7,
371
+ "min_mutation": 0.6,
372
+ "requires_contracts": false
373
+ }
374
+ }
375
+ }
376
+ ```
377
+
378
+ ---
379
+
380
+ ## 🎯 Tier Policies
381
+
382
+ | Tier | Branch Coverage | Mutation Score | Contracts | Manual Review |
383
+ | ---- | --------------- | -------------- | --------- | ------------- |
384
+ | 1 | ≥90% | ≥80% | Required | Required |
385
+ | 2 | ≥80% | ≥70% | Required | Optional |
386
+ | 3 | ≥70% | ≥60% | Optional | Optional |
387
+
388
+ ---
389
+
390
+ ## 🔄 Workflow Integration
391
+
392
+ ### Pre-commit Hook
393
+
394
+ ```bash
395
+ #!/bin/bash
396
+ # .git/hooks/pre-commit
397
+
398
+ # Run CAWS quality gates
399
+ npx tsx apps/tools/caws/flake-detector.ts detect
400
+ npx tsx apps/tools/caws/spec-test-mapper.ts report
401
+ node apps/tools/caws/gates.js coverage 2
402
+ node apps/tools/caws/gates.js mutation 2
403
+ ```
404
+
405
+ ### CI/CD Pipeline
406
+
407
+ ```yaml
408
+ # .github/workflows/caws.yml
409
+ name: CAWS Quality Gates
410
+
411
+ on: [push, pull_request]
412
+
413
+ jobs:
414
+ quality:
415
+ runs-on: ubuntu-latest
416
+ steps:
417
+ - uses: actions/checkout@v2
418
+ - name: Run CAWS Gates
419
+ run: |
420
+ npm test -- --coverage
421
+ npx tsx apps/tools/caws/flake-detector.ts detect
422
+ npx tsx apps/tools/caws/perf-budgets.ts
423
+ node apps/tools/caws/gates.js tier 2
424
+ ```
425
+
426
+ ---
427
+
428
+ ## 📚 Documentation
429
+
430
+ - [Quick Start Guide](../../docs/QUICK_START_HOOKS.md)
431
+ - [Hook Strategy](../../docs/HOOK_STRATEGY.md)
432
+ - [Developer Guide](../../docs/caws-developer-guide.md)
433
+ - [API Documentation](../../docs/api/)
434
+
435
+ ---
436
+
437
+ ## 🤝 Contributing
438
+
439
+ When adding new CAWS tools:
440
+
441
+ 1. **Extend CawsBaseTool** - Use the shared base class
442
+ 2. **Use shared types** - Import from `shared/types.ts`
443
+ 3. **Leverage validators** - Use `CawsValidator`
444
+ 4. **Utilize config manager** - Use `CawsConfigManager`
445
+ 5. **Follow gate checker** - Use `CawsGateChecker`
446
+
447
+ ---
448
+
449
+ ## 📝 License
450
+
451
+ Part of the CAWS project - see main project LICENSE
452
+
453
+ ---
454
+
455
+ ## 🙏 Credits
456
+
457
+ **Author:** @darianrosebrook
458
+
459
+ Built with insights from production CAWS implementations in:
460
+
461
+ - obsidian-rag project
462
+ - Animator project
463
+ - Portfolio project