@paths.design/caws-cli 7.0.2 → 7.0.3
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.
- package/dist/budget-derivation.js +5 -4
- package/dist/commands/diagnose.js +24 -19
- package/dist/commands/init.js +51 -4
- package/dist/commands/specs.js +40 -1
- package/dist/commands/status.js +2 -2
- package/dist/commands/tool.js +2 -3
- package/dist/config/index.js +17 -8
- package/dist/generators/working-spec.js +19 -6
- package/dist/scaffold/git-hooks.js +127 -29
- package/dist/scaffold/index.js +53 -7
- package/dist/templates/.caws/tools/README.md +20 -0
- package/dist/templates/.cursor/README.md +311 -0
- package/dist/templates/.cursor/hooks/audit.sh +55 -0
- package/dist/templates/.cursor/hooks/block-dangerous.sh +83 -0
- package/dist/templates/.cursor/hooks/caws-quality-check.sh +52 -0
- package/dist/templates/.cursor/hooks/caws-scope-guard.sh +130 -0
- package/dist/templates/.cursor/hooks/caws-tool-validation.sh +121 -0
- package/dist/templates/.cursor/hooks/format.sh +38 -0
- package/dist/templates/.cursor/hooks/naming-check.sh +64 -0
- package/dist/templates/.cursor/hooks/scan-secrets.sh +46 -0
- package/dist/templates/.cursor/hooks/scope-guard.sh +52 -0
- package/dist/templates/.cursor/hooks/validate-spec.sh +83 -0
- package/dist/templates/.cursor/hooks.json +59 -0
- package/dist/templates/.cursor/rules/00-claims-verification.mdc +144 -0
- package/dist/templates/.cursor/rules/01-working-style.mdc +50 -0
- package/dist/templates/.cursor/rules/02-quality-gates.mdc +370 -0
- package/dist/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
- package/dist/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
- package/dist/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
- package/dist/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
- package/dist/templates/.cursor/rules/07-process-ops.mdc +20 -0
- package/dist/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
- package/dist/templates/.cursor/rules/09-docstrings.mdc +89 -0
- package/dist/templates/.cursor/rules/10-documentation-quality-standards.mdc +390 -0
- package/dist/templates/.cursor/rules/11-scope-management-waivers.mdc +385 -0
- package/dist/templates/.cursor/rules/12-implementation-completeness.mdc +516 -0
- package/dist/templates/.cursor/rules/13-language-agnostic-standards.mdc +588 -0
- package/dist/templates/.cursor/rules/README.md +148 -0
- package/dist/templates/.github/copilot/instructions.md +311 -0
- package/dist/templates/.idea/runConfigurations/CAWS_Evaluate.xml +5 -0
- package/dist/templates/.idea/runConfigurations/CAWS_Validate.xml +5 -0
- package/dist/templates/.vscode/launch.json +56 -0
- package/dist/templates/.vscode/settings.json +93 -0
- package/dist/templates/.windsurf/workflows/caws-guided-development.md +92 -0
- package/dist/templates/COMMIT_CONVENTIONS.md +86 -0
- package/dist/templates/OIDC_SETUP.md +300 -0
- package/dist/templates/agents.md +1047 -0
- package/dist/templates/codemod/README.md +1 -0
- package/dist/templates/codemod/test.js +93 -0
- package/dist/templates/docs/README.md +150 -0
- package/dist/templates/scripts/quality-gates/check-god-objects.js +146 -0
- package/dist/templates/scripts/quality-gates/run-quality-gates.js +50 -0
- package/dist/templates/scripts/v3/analysis/todo_analyzer.py +1997 -0
- package/dist/tool-loader.js +6 -1
- package/dist/tool-validator.js +8 -2
- package/dist/utils/detection.js +4 -3
- package/dist/utils/git-lock.js +118 -0
- package/dist/utils/gitignore-updater.js +148 -0
- package/dist/utils/quality-gates.js +47 -7
- package/dist/utils/spec-resolver.js +23 -3
- package/dist/utils/yaml-validation.js +155 -0
- package/dist/validation/spec-validation.js +81 -2
- package/package.json +2 -2
- package/templates/.caws/schemas/waivers.schema.json +30 -0
- package/templates/.caws/schemas/working-spec.schema.json +133 -0
- package/templates/.caws/templates/working-spec.template.yml +74 -0
- package/templates/.caws/tools/README.md +20 -0
- package/templates/.caws/tools/scope-guard.js +208 -0
- package/templates/.caws/tools-allow.json +331 -0
- package/templates/.caws/waivers.yml +19 -0
- package/templates/.cursor/hooks/scope-guard.sh +2 -2
- package/templates/.cursor/hooks/validate-spec.sh +42 -7
- package/templates/apps/tools/caws/COMPLETION_REPORT.md +0 -331
- package/templates/apps/tools/caws/MIGRATION_SUMMARY.md +0 -360
- package/templates/apps/tools/caws/README.md +0 -463
- package/templates/apps/tools/caws/TEST_STATUS.md +0 -365
- package/templates/apps/tools/caws/attest.js +0 -357
- package/templates/apps/tools/caws/ci-optimizer.js +0 -642
- package/templates/apps/tools/caws/config.ts +0 -245
- package/templates/apps/tools/caws/cross-functional.js +0 -876
- package/templates/apps/tools/caws/dashboard.js +0 -1112
- package/templates/apps/tools/caws/flake-detector.ts +0 -362
- package/templates/apps/tools/caws/gates.js +0 -198
- package/templates/apps/tools/caws/gates.ts +0 -271
- package/templates/apps/tools/caws/language-adapters.ts +0 -381
- package/templates/apps/tools/caws/language-support.d.ts +0 -367
- package/templates/apps/tools/caws/language-support.d.ts.map +0 -1
- package/templates/apps/tools/caws/language-support.js +0 -585
- package/templates/apps/tools/caws/legacy-assessment.ts +0 -408
- package/templates/apps/tools/caws/legacy-assessor.js +0 -764
- package/templates/apps/tools/caws/mutant-analyzer.js +0 -734
- package/templates/apps/tools/caws/perf-budgets.ts +0 -349
- package/templates/apps/tools/caws/prompt-lint.js.backup +0 -274
- package/templates/apps/tools/caws/property-testing.js +0 -707
- package/templates/apps/tools/caws/provenance.d.ts +0 -14
- package/templates/apps/tools/caws/provenance.d.ts.map +0 -1
- package/templates/apps/tools/caws/provenance.js +0 -132
- package/templates/apps/tools/caws/provenance.js.backup +0 -73
- package/templates/apps/tools/caws/provenance.ts +0 -211
- package/templates/apps/tools/caws/security-provenance.ts +0 -483
- package/templates/apps/tools/caws/shared/base-tool.ts +0 -281
- package/templates/apps/tools/caws/shared/config-manager.ts +0 -366
- package/templates/apps/tools/caws/shared/gate-checker.ts +0 -849
- package/templates/apps/tools/caws/shared/types.ts +0 -444
- package/templates/apps/tools/caws/shared/validator.ts +0 -305
- package/templates/apps/tools/caws/shared/waivers-manager.ts +0 -174
- package/templates/apps/tools/caws/spec-test-mapper.ts +0 -391
- package/templates/apps/tools/caws/test-quality.js +0 -578
- package/templates/apps/tools/caws/validate.js +0 -76
- package/templates/apps/tools/caws/validate.ts +0 -228
- package/templates/apps/tools/caws/waivers.js +0 -344
- /package/{templates/apps/tools/caws → dist/templates/.caws}/schemas/waivers.schema.json +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/schemas/working-spec.schema.json +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/templates/working-spec.template.yml +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws/tools}/scope-guard.js +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/tools-allow.json +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/waivers.yml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Codemod Scripts
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Template Codemod for CAWS Framework
|
|
5
|
+
* Automated code transformations for refactoring
|
|
6
|
+
* @author CAWS Framework
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const tsMorph = require('ts-morph');
|
|
10
|
+
|
|
11
|
+
function applyCodemod(dryRun = true) {
|
|
12
|
+
console.log('🔧 Applying codemod transformations...');
|
|
13
|
+
|
|
14
|
+
const project = new tsMorph.Project();
|
|
15
|
+
|
|
16
|
+
// Load all TypeScript source files
|
|
17
|
+
const sourceFiles = project.addSourceFilesAtPaths('src/**/*.ts');
|
|
18
|
+
|
|
19
|
+
if (sourceFiles.length === 0) {
|
|
20
|
+
console.log('⚠️ No TypeScript source files found in src/ directory');
|
|
21
|
+
return { filesProcessed: 0, changesApplied: 0 };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log(`📁 Processing ${sourceFiles.length} source files`);
|
|
25
|
+
let totalChanges = 0;
|
|
26
|
+
|
|
27
|
+
for (const sourceFile of sourceFiles) {
|
|
28
|
+
const filePath = sourceFile.getFilePath();
|
|
29
|
+
console.log(`Processing: ${filePath}`);
|
|
30
|
+
|
|
31
|
+
let fileChanges = 0;
|
|
32
|
+
|
|
33
|
+
// Example transformations - customize these for your specific needs:
|
|
34
|
+
|
|
35
|
+
// 1. Add JSDoc to exported functions without documentation
|
|
36
|
+
const exportedFunctions = sourceFile
|
|
37
|
+
.getFunctions()
|
|
38
|
+
.filter((func) => func.isExported && !func.getJsDocs().length);
|
|
39
|
+
|
|
40
|
+
for (const func of exportedFunctions) {
|
|
41
|
+
func.addJsDoc({
|
|
42
|
+
description: `Handles ${func.getName()} operations`,
|
|
43
|
+
tags: [
|
|
44
|
+
{ tagName: 'param', text: 'options - Configuration options' },
|
|
45
|
+
{ tagName: 'returns', text: 'Result of the operation' },
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
fileChanges++;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 2. Add type annotations to untyped parameters (example)
|
|
52
|
+
// const untypedParams = sourceFile.getDescendantsOfKind(tsMorph.SyntaxKind.Parameter)
|
|
53
|
+
// .filter(param => !param.getTypeNode());
|
|
54
|
+
// Add your transformation logic here...
|
|
55
|
+
|
|
56
|
+
if (fileChanges > 0) {
|
|
57
|
+
console.log(` ✅ Applied ${fileChanges} transformations`);
|
|
58
|
+
totalChanges += fileChanges;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
console.log(`📊 Codemod complete: ${totalChanges} total transformations`);
|
|
63
|
+
|
|
64
|
+
if (!dryRun) {
|
|
65
|
+
console.log('💾 Saving changes...');
|
|
66
|
+
project.saveSync();
|
|
67
|
+
console.log('✅ All changes saved successfully');
|
|
68
|
+
} else {
|
|
69
|
+
console.log('🔍 Dry run - no files were modified');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
filesProcessed: sourceFiles.length,
|
|
74
|
+
changesApplied: totalChanges,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// CLI interface
|
|
79
|
+
if (require.main === module) {
|
|
80
|
+
const args = process.argv.slice(2);
|
|
81
|
+
const dryRun = !args.includes('--apply');
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const result = applyCodemod(dryRun);
|
|
85
|
+
console.log('✅ Codemod execution completed');
|
|
86
|
+
process.exit(0);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error('❌ Codemod execution failed:', error.message);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = { applyCodemod };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# CAWS Project Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This project is built with the **Coding Agent Workflow System (CAWS)** - an engineering-grade framework that ensures quality, reliability, and maintainability in AI-assisted development.
|
|
5
|
+
|
|
6
|
+
## Key Features
|
|
7
|
+
- 🔒 **Quality Gates**: Automated validation of scope, budget, and standards
|
|
8
|
+
- 🧪 **Comprehensive Testing**: Unit, contract, integration, and mutation testing
|
|
9
|
+
- 📊 **Observability**: Structured logging, metrics, and tracing
|
|
10
|
+
- 🔄 **Rollback Ready**: Feature flags and migration support
|
|
11
|
+
- 📦 **Provenance Tracking**: SBOM and SLSA attestation generation
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
### 1. Project Setup
|
|
16
|
+
The project is already scaffolded with CAWS. Review and customize:
|
|
17
|
+
- `.caws/working-spec.yaml` - Project specification and requirements
|
|
18
|
+
- `.caws/policy/tier-policy.json` - Risk tier definitions
|
|
19
|
+
- `.github/workflows/caws.yml` - CI/CD quality gates
|
|
20
|
+
|
|
21
|
+
### 2. Development Workflow
|
|
22
|
+
1. **Plan**: Update working spec with requirements and scope
|
|
23
|
+
2. **Implement**: Follow agent conduct rules and mode constraints
|
|
24
|
+
3. **Verify**: Run tests and quality gates locally
|
|
25
|
+
4. **Document**: Update documentation and generate provenance
|
|
26
|
+
|
|
27
|
+
### 3. Quality Assurance
|
|
28
|
+
- Run `npm run test` for all tests
|
|
29
|
+
- Check trust score with CAWS tools
|
|
30
|
+
- Validate against working specification
|
|
31
|
+
- Ensure rollback capabilities
|
|
32
|
+
|
|
33
|
+
## Architecture
|
|
34
|
+
|
|
35
|
+
### Directory Structure
|
|
36
|
+
```
|
|
37
|
+
src/ # Source code
|
|
38
|
+
├── core/ # Core business logic
|
|
39
|
+
├── api/ # API endpoints
|
|
40
|
+
├── models/ # Data models
|
|
41
|
+
└── utils/ # Utilities
|
|
42
|
+
|
|
43
|
+
tests/ # Test suites
|
|
44
|
+
├── unit/ # Unit tests
|
|
45
|
+
├── contract/ # Contract tests
|
|
46
|
+
├── integration/ # Integration tests
|
|
47
|
+
└── e2e/ # End-to-end tests
|
|
48
|
+
|
|
49
|
+
apps/tools/caws/ # CAWS utilities
|
|
50
|
+
└── prompt-lint.js # Prompt validation
|
|
51
|
+
└── attest.js # SBOM/attestation generation
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Key Patterns
|
|
55
|
+
- **Dependency Injection**: For testability and determinism
|
|
56
|
+
- **Interface Segregation**: Clean boundaries and contracts
|
|
57
|
+
- **Observability**: Structured logging and metrics
|
|
58
|
+
- **Property Testing**: Edge cases and invariants
|
|
59
|
+
|
|
60
|
+
## Development Guidelines
|
|
61
|
+
|
|
62
|
+
### Agent Conduct Rules
|
|
63
|
+
1. **Spec Adherence**: Stay within declared scope and mode
|
|
64
|
+
2. **Determinism**: Inject time, UUID, and random dependencies
|
|
65
|
+
3. **Comprehensive Testing**: Unit + property + integration tests
|
|
66
|
+
4. **Observability**: Log, metric, and trace key operations
|
|
67
|
+
5. **Rollback Ready**: Feature flags and migration support
|
|
68
|
+
|
|
69
|
+
### Code Quality
|
|
70
|
+
- **Type Safety**: Full TypeScript coverage
|
|
71
|
+
- **Test Coverage**: 80%+ branch coverage, 50%+ mutation score
|
|
72
|
+
- **Performance**: API p95 < 250ms, accessibility compliance
|
|
73
|
+
- **Security**: Input validation, rate limiting, secret scanning
|
|
74
|
+
|
|
75
|
+
## Deployment
|
|
76
|
+
|
|
77
|
+
### CI/CD Pipeline
|
|
78
|
+
The project includes automated quality gates:
|
|
79
|
+
- Static analysis and security scanning
|
|
80
|
+
- Unit and integration testing
|
|
81
|
+
- Performance and accessibility validation
|
|
82
|
+
- Provenance and attestation generation
|
|
83
|
+
|
|
84
|
+
### Environment Setup
|
|
85
|
+
1. Configure environment variables
|
|
86
|
+
2. Set up monitoring and alerting
|
|
87
|
+
3. Establish rollback procedures
|
|
88
|
+
4. Document operational runbooks
|
|
89
|
+
|
|
90
|
+
## Monitoring & Observability
|
|
91
|
+
|
|
92
|
+
### Metrics
|
|
93
|
+
- Request latency and throughput
|
|
94
|
+
- Error rates and types
|
|
95
|
+
- Resource utilization
|
|
96
|
+
- Business metrics
|
|
97
|
+
|
|
98
|
+
### Logging
|
|
99
|
+
- Structured logs with correlation IDs
|
|
100
|
+
- Error tracking and alerting
|
|
101
|
+
- Performance monitoring
|
|
102
|
+
- Security event logging
|
|
103
|
+
|
|
104
|
+
### Tracing
|
|
105
|
+
- Distributed request tracing
|
|
106
|
+
- Performance profiling
|
|
107
|
+
- Dependency analysis
|
|
108
|
+
- Root cause identification
|
|
109
|
+
|
|
110
|
+
## Troubleshooting
|
|
111
|
+
|
|
112
|
+
### Common Issues
|
|
113
|
+
1. **Trust Score Low**: Check test coverage and quality gates
|
|
114
|
+
2. **Scope Violations**: Ensure changes align with working spec
|
|
115
|
+
3. **Budget Exceeded**: Review change size and complexity
|
|
116
|
+
4. **Flaky Tests**: Use property testing and proper mocking
|
|
117
|
+
|
|
118
|
+
### Support
|
|
119
|
+
- Check `agents.md` for comprehensive documentation
|
|
120
|
+
- Review CI/CD logs for quality gate failures
|
|
121
|
+
- Use CAWS tools for validation and debugging
|
|
122
|
+
- Follow agent conduct rules for collaboration
|
|
123
|
+
|
|
124
|
+
## Contributing
|
|
125
|
+
|
|
126
|
+
### Development Process
|
|
127
|
+
1. Update working specification
|
|
128
|
+
2. Create comprehensive tests
|
|
129
|
+
3. Implement with quality gates
|
|
130
|
+
4. Generate provenance artifacts
|
|
131
|
+
5. Document changes thoroughly
|
|
132
|
+
|
|
133
|
+
### Code Review
|
|
134
|
+
- Review against working specification
|
|
135
|
+
- Check trust score and quality gates
|
|
136
|
+
- Validate observability and rollback
|
|
137
|
+
- Ensure documentation completeness
|
|
138
|
+
|
|
139
|
+
## Resources
|
|
140
|
+
|
|
141
|
+
- **[CAWS Framework](agents.md)**: Complete system documentation
|
|
142
|
+
- **[Working Specification](.caws/working-spec.yaml)**: Project requirements
|
|
143
|
+
- **[Quality Gates](.github/workflows/caws.yml)**: CI/CD pipeline
|
|
144
|
+
- **[Tools](apps/tools/caws/)**: Development utilities
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
**Maintainer**: @darianrosebrook
|
|
149
|
+
**Framework**: CAWS v1.0
|
|
150
|
+
**Updated**: $(date)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* God Object Detector
|
|
5
|
+
*
|
|
6
|
+
* Checks for god objects (large files) in staged files only.
|
|
7
|
+
* This script is automatically generated by CAWS scaffold.
|
|
8
|
+
*
|
|
9
|
+
* @author @darianrosebrook
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { execSync } = require('child_process');
|
|
15
|
+
|
|
16
|
+
// Configuration
|
|
17
|
+
const CONFIG = {
|
|
18
|
+
godObjectThresholds: {
|
|
19
|
+
warning: 1750,
|
|
20
|
+
critical: 2000,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Collect staged Rust files only
|
|
25
|
+
function collectStagedRustFiles() {
|
|
26
|
+
try {
|
|
27
|
+
// Get staged files
|
|
28
|
+
const stagedFiles = execSync("git diff --cached --name-only", {
|
|
29
|
+
encoding: "utf8",
|
|
30
|
+
})
|
|
31
|
+
.trim()
|
|
32
|
+
.split("\n")
|
|
33
|
+
.filter((file) => file.trim() !== "");
|
|
34
|
+
|
|
35
|
+
// Filter for Rust files
|
|
36
|
+
const rustFiles = stagedFiles.filter((file) => file.endsWith(".rs"));
|
|
37
|
+
|
|
38
|
+
// Convert to absolute paths
|
|
39
|
+
const RUST_FILES = [];
|
|
40
|
+
for (const file of rustFiles) {
|
|
41
|
+
const fullPath = path.resolve(file);
|
|
42
|
+
if (fs.existsSync(fullPath)) {
|
|
43
|
+
RUST_FILES.push(fullPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`📁 Found ${rustFiles.length} staged Rust files to check`);
|
|
48
|
+
return RUST_FILES;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn(`⚠️ Could not get staged files: ${error.message}`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Check for god objects
|
|
56
|
+
function checkGodObjects() {
|
|
57
|
+
const RUST_FILES = collectStagedRustFiles();
|
|
58
|
+
|
|
59
|
+
if (RUST_FILES.length === 0) {
|
|
60
|
+
console.log("✅ No staged Rust files to check for god objects");
|
|
61
|
+
return { violations: [], warnings: [] };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const violations = [];
|
|
65
|
+
const warnings = [];
|
|
66
|
+
|
|
67
|
+
for (const filePath of RUST_FILES) {
|
|
68
|
+
try {
|
|
69
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
70
|
+
const lineCount = content.split('\n').length;
|
|
71
|
+
const relativePath = path.relative(process.cwd(), filePath);
|
|
72
|
+
|
|
73
|
+
if (lineCount >= CONFIG.godObjectThresholds.critical) {
|
|
74
|
+
violations.push({
|
|
75
|
+
file: relativePath,
|
|
76
|
+
lines: lineCount,
|
|
77
|
+
message: `CRITICAL: ${lineCount} LOC exceeds god object threshold (${CONFIG.godObjectThresholds.critical}+ LOC)`
|
|
78
|
+
});
|
|
79
|
+
} else if (lineCount >= CONFIG.godObjectThresholds.warning) {
|
|
80
|
+
warnings.push({
|
|
81
|
+
file: relativePath,
|
|
82
|
+
lines: lineCount,
|
|
83
|
+
message: `WARNING: ${lineCount} LOC approaches god object territory (${CONFIG.godObjectThresholds.warning}+ LOC)`
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.warn(`⚠️ Could not analyze ${filePath}: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { violations, warnings };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Check for god object regression
|
|
95
|
+
function checkGodObjectRegression() {
|
|
96
|
+
const RUST_FILES = collectStagedRustFiles();
|
|
97
|
+
|
|
98
|
+
if (RUST_FILES.length === 0) {
|
|
99
|
+
return { regression: false };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// This is a simplified check - in a real implementation,
|
|
103
|
+
// you might want to compare against previous commits
|
|
104
|
+
const results = checkGodObjects();
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
regression: results.violations.length > 0,
|
|
108
|
+
violations: results.violations,
|
|
109
|
+
warnings: results.warnings
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Main execution
|
|
114
|
+
function main() {
|
|
115
|
+
console.log("🏗️ Checking god objects...");
|
|
116
|
+
|
|
117
|
+
const results = checkGodObjects();
|
|
118
|
+
|
|
119
|
+
if (results.violations.length > 0) {
|
|
120
|
+
console.log(" ❌ God object violations detected:");
|
|
121
|
+
results.violations.forEach(violation => {
|
|
122
|
+
console.log(` ${violation.file}: ${violation.message}`);
|
|
123
|
+
});
|
|
124
|
+
process.exit(1);
|
|
125
|
+
} else {
|
|
126
|
+
console.log(" ✅ No blocking god object violations");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (results.warnings.length > 0) {
|
|
130
|
+
console.log(" ⚠️ God object warnings:");
|
|
131
|
+
results.warnings.forEach(warning => {
|
|
132
|
+
console.log(` ${warning.file}: ${warning.message}`);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Run if called directly
|
|
138
|
+
if (require.main === module) {
|
|
139
|
+
main();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
checkGodObjects,
|
|
144
|
+
checkGodObjectRegression,
|
|
145
|
+
collectStagedRustFiles,
|
|
146
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Quality Gates Runner
|
|
5
|
+
*
|
|
6
|
+
* Runs comprehensive quality gates on staged files only.
|
|
7
|
+
* This script is automatically generated by CAWS scaffold.
|
|
8
|
+
*
|
|
9
|
+
* @author @darianrosebrook
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { runQualityGates } = require('@paths.design/caws-cli/src/utils/quality-gates');
|
|
13
|
+
|
|
14
|
+
// Parse command line arguments
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
const options = {
|
|
17
|
+
languages: ['rust'],
|
|
18
|
+
checkTodos: true,
|
|
19
|
+
checkGodObjects: true,
|
|
20
|
+
ci: args.includes('--ci') || args.includes('--ci-mode')
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Extract languages from arguments
|
|
24
|
+
const langIndex = args.indexOf('--languages');
|
|
25
|
+
if (langIndex !== -1 && args[langIndex + 1]) {
|
|
26
|
+
options.languages = args[langIndex + 1].split(',').map(lang => lang.trim());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check for disable flags
|
|
30
|
+
if (args.includes('--no-todos')) {
|
|
31
|
+
options.checkTodos = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (args.includes('--no-god-objects')) {
|
|
35
|
+
options.checkGodObjects = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Run quality gates
|
|
39
|
+
try {
|
|
40
|
+
const results = runQualityGates(options);
|
|
41
|
+
|
|
42
|
+
if (!results.passed && options.ci) {
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(`❌ Quality gates failed: ${error.message}`);
|
|
47
|
+
if (options.ci) {
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|