@paths.design/caws-cli 5.0.1 → 5.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.
- package/README.md +15 -12
- package/dist/budget-derivation.d.ts +74 -0
- package/dist/budget-derivation.d.ts.map +1 -0
- package/dist/cicd-optimizer.d.ts +142 -0
- package/dist/cicd-optimizer.d.ts.map +1 -0
- package/dist/commands/archive.d.ts +50 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/burnup.d.ts +6 -0
- package/dist/commands/burnup.d.ts.map +1 -0
- package/dist/commands/diagnose.d.ts +52 -0
- package/dist/commands/diagnose.d.ts.map +1 -0
- package/dist/commands/evaluate.d.ts +8 -0
- package/dist/commands/evaluate.d.ts.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/iterate.d.ts +8 -0
- package/dist/commands/iterate.d.ts.map +1 -0
- package/dist/commands/mode.d.ts +24 -0
- package/dist/commands/mode.d.ts.map +1 -0
- package/dist/commands/plan.d.ts +49 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/provenance.d.ts +32 -0
- package/dist/commands/provenance.d.ts.map +1 -0
- package/dist/commands/provenance.js +27 -22
- package/dist/commands/quality-gates.d.ts +52 -0
- package/dist/commands/quality-gates.d.ts.map +1 -0
- package/dist/commands/quality-gates.js +190 -455
- package/dist/commands/quality-monitor.d.ts +17 -0
- package/dist/commands/quality-monitor.d.ts.map +1 -0
- package/dist/commands/specs.d.ts +71 -0
- package/dist/commands/specs.d.ts.map +1 -0
- package/dist/commands/specs.js +34 -35
- package/dist/commands/status.d.ts +44 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +10 -7
- package/dist/commands/templates.d.ts +74 -0
- package/dist/commands/templates.d.ts.map +1 -0
- package/dist/commands/tool.d.ts +13 -0
- package/dist/commands/tool.d.ts.map +1 -0
- package/dist/commands/tool.js +63 -63
- package/dist/commands/troubleshoot.d.ts +8 -0
- package/dist/commands/troubleshoot.d.ts.map +1 -0
- package/dist/commands/tutorial.d.ts +55 -0
- package/dist/commands/tutorial.d.ts.map +1 -0
- package/dist/commands/validate.d.ts +15 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/waivers.d.ts +8 -0
- package/dist/commands/waivers.d.ts.map +1 -0
- package/dist/commands/waivers.js +38 -39
- package/dist/commands/workflow.d.ts +85 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/config/index.d.ts +29 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/modes.d.ts +225 -0
- package/dist/config/modes.d.ts.map +1 -0
- package/dist/constants/spec-types.d.ts +41 -0
- package/dist/constants/spec-types.d.ts.map +1 -0
- package/dist/error-handler.d.ts +164 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/generators/jest-config.d.ts +32 -0
- package/dist/generators/jest-config.d.ts.map +1 -0
- package/dist/generators/working-spec.d.ts +13 -0
- package/dist/generators/working-spec.d.ts.map +1 -0
- package/dist/index-new.d.ts +5 -0
- package/dist/index-new.d.ts.map +1 -0
- package/dist/index-new.js +317 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.backup +4711 -0
- package/dist/minimal-cli.d.ts +3 -0
- package/dist/minimal-cli.d.ts.map +1 -0
- package/dist/policy/PolicyManager.d.ts +104 -0
- package/dist/policy/PolicyManager.d.ts.map +1 -0
- package/dist/policy/PolicyManager.js +60 -28
- package/dist/scaffold/cursor-hooks.d.ts +7 -0
- package/dist/scaffold/cursor-hooks.d.ts.map +1 -0
- package/dist/scaffold/git-hooks.d.ts +20 -0
- package/dist/scaffold/git-hooks.d.ts.map +1 -0
- package/dist/scaffold/git-hooks.js +89 -27
- package/dist/scaffold/index.d.ts +20 -0
- package/dist/scaffold/index.d.ts.map +1 -0
- package/dist/scaffold/index.js +25 -0
- package/dist/spec/SpecFileManager.d.ts +146 -0
- package/dist/spec/SpecFileManager.d.ts.map +1 -0
- package/dist/test-analysis.d.ts +182 -0
- package/dist/test-analysis.d.ts.map +1 -0
- package/dist/tool-interface.d.ts +236 -0
- package/dist/tool-interface.d.ts.map +1 -0
- package/dist/tool-loader.d.ts +77 -0
- package/dist/tool-loader.d.ts.map +1 -0
- package/dist/tool-validator.d.ts +72 -0
- package/dist/tool-validator.d.ts.map +1 -0
- package/dist/utils/async-utils.js +188 -0
- package/dist/utils/command-wrapper.js +200 -0
- package/dist/utils/detection.d.ts +7 -0
- package/dist/utils/detection.d.ts.map +1 -0
- package/dist/utils/finalization.d.ts +17 -0
- package/dist/utils/finalization.d.ts.map +1 -0
- package/dist/utils/project-analysis.d.ts +14 -0
- package/dist/utils/project-analysis.d.ts.map +1 -0
- package/dist/utils/promise-utils.js +72 -0
- package/dist/utils/quality-gates.d.ts +49 -0
- package/dist/utils/quality-gates.d.ts.map +1 -0
- package/dist/utils/spec-resolver.d.ts +88 -0
- package/dist/utils/spec-resolver.d.ts.map +1 -0
- package/dist/utils/typescript-detector.d.ts +63 -0
- package/dist/utils/typescript-detector.d.ts.map +1 -0
- package/dist/validation/spec-validation.d.ts +43 -0
- package/dist/validation/spec-validation.d.ts.map +1 -0
- package/dist/waivers-manager.d.ts +167 -0
- package/dist/waivers-manager.d.ts.map +1 -0
- package/package.json +1 -1
- package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
- package/templates/apps/tools/caws/provenance.js.backup +73 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"minimal-cli.d.ts","sourceRoot":"","sources":["../src/minimal-cli.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy Manager - Handles policy loading with intelligent caching
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - TTL-based caching for performance
|
|
6
|
+
* - Graceful fallback to defaults when policy.yaml missing
|
|
7
|
+
* - Cache inspection and management API
|
|
8
|
+
* - Waiver validation and delta application
|
|
9
|
+
*/
|
|
10
|
+
export class PolicyManager {
|
|
11
|
+
constructor(options?: {});
|
|
12
|
+
enableCaching: any;
|
|
13
|
+
cacheTTL: any;
|
|
14
|
+
policyCache: Map<any, any>;
|
|
15
|
+
/**
|
|
16
|
+
* Load CAWS policy from policy.yaml with caching
|
|
17
|
+
*
|
|
18
|
+
* @param {string} projectRoot - Project root directory
|
|
19
|
+
* @param {Object} options - Loading options
|
|
20
|
+
* @param {boolean} options.useCache - Use cache if available (default: true)
|
|
21
|
+
* @param {number} options.cacheTTL - Cache TTL override in milliseconds
|
|
22
|
+
* @returns {Promise<Object>} Policy object
|
|
23
|
+
*/
|
|
24
|
+
loadPolicy(projectRoot: string, options?: {
|
|
25
|
+
useCache: boolean;
|
|
26
|
+
cacheTTL: number;
|
|
27
|
+
}): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Load a waiver document by ID
|
|
30
|
+
*
|
|
31
|
+
* @param {string} waiverId - Waiver ID (e.g., WV-0001)
|
|
32
|
+
* @param {string} projectRoot - Project root directory
|
|
33
|
+
* @returns {Promise<Object|null>} Waiver document or null if not found
|
|
34
|
+
*/
|
|
35
|
+
loadWaiver(waiverId: string, projectRoot: string): Promise<any | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a waiver is currently valid
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} waiver - Waiver document
|
|
40
|
+
* @returns {boolean} True if waiver is valid and active
|
|
41
|
+
*/
|
|
42
|
+
isWaiverValid(waiver: any): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Apply waivers to baseline budget
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} baseline - Baseline budget from policy
|
|
47
|
+
* @param {string[]} waiverIds - Array of waiver IDs to apply
|
|
48
|
+
* @param {string} projectRoot - Project root directory
|
|
49
|
+
* @returns {Promise<Object>} Effective budget with waivers applied
|
|
50
|
+
*/
|
|
51
|
+
applyWaivers(baseline: any, waiverIds: string[], projectRoot: string): Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* Validate policy structure
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} policy - Policy to validate
|
|
56
|
+
* @throws {Error} If policy is invalid
|
|
57
|
+
*/
|
|
58
|
+
validatePolicy(policy: any): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get default CAWS policy
|
|
61
|
+
*
|
|
62
|
+
* Returns sensible defaults when policy.yaml doesn't exist.
|
|
63
|
+
*
|
|
64
|
+
* @returns {Object} Default policy configuration
|
|
65
|
+
*/
|
|
66
|
+
getDefaultPolicy(): any;
|
|
67
|
+
/**
|
|
68
|
+
* Clear policy cache
|
|
69
|
+
*
|
|
70
|
+
* @param {string} [projectRoot] - Specific project to clear, or all if omitted
|
|
71
|
+
*/
|
|
72
|
+
clearCache(projectRoot?: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Get cache status for a project
|
|
75
|
+
*
|
|
76
|
+
* @param {string} projectRoot - Project root directory
|
|
77
|
+
* @returns {Object} Cache status information
|
|
78
|
+
*/
|
|
79
|
+
getCacheStatus(projectRoot: string): any;
|
|
80
|
+
/**
|
|
81
|
+
* Reload policy from disk (bypassing cache)
|
|
82
|
+
*
|
|
83
|
+
* @param {string} projectRoot - Project root directory
|
|
84
|
+
* @returns {Promise<Object>} Fresh policy
|
|
85
|
+
*/
|
|
86
|
+
reloadPolicy(projectRoot: string): Promise<any>;
|
|
87
|
+
/**
|
|
88
|
+
* Get all cached projects
|
|
89
|
+
*
|
|
90
|
+
* @returns {string[]} Array of project roots with cached policies
|
|
91
|
+
*/
|
|
92
|
+
getCachedProjects(): string[];
|
|
93
|
+
/**
|
|
94
|
+
* Get cache statistics
|
|
95
|
+
*
|
|
96
|
+
* @returns {Object} Cache statistics
|
|
97
|
+
*/
|
|
98
|
+
getCacheStats(): any;
|
|
99
|
+
}
|
|
100
|
+
export const defaultPolicyManager: PolicyManager;
|
|
101
|
+
export declare function loadPolicy(projectRoot: any, options: any): Promise<any>;
|
|
102
|
+
export declare function clearCache(projectRoot: any): void;
|
|
103
|
+
export declare function getCacheStatus(projectRoot: any): any;
|
|
104
|
+
//# sourceMappingURL=PolicyManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolicyManager.d.ts","sourceRoot":"","sources":["../../src/policy/PolicyManager.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH;IACE,0BAIC;IAHC,mBAAkD;IAClD,cAA0C;IAC1C,2BAA4B;IAG9B;;;;;;;;OAQG;IACH,wBANW,MAAM,YAEd;QAAyB,QAAQ,EAAzB,OAAO;QACS,QAAQ,EAAxB,MAAM;KACd,GAAU,OAAO,KAAQ,CAuE3B;IAED;;;;;;OAMG;IACH,qBAJW,MAAM,eACN,MAAM,GACJ,OAAO,CAAC,MAAO,IAAI,CAAC,CAchC;IAED;;;;;OAKG;IACH,4BAFa,OAAO,CA2BnB;IAED;;;;;;;OAOG;IACH,uCAJW,MAAM,EAAE,eACR,MAAM,GACJ,OAAO,KAAQ,CA2B3B;IAED;;;;;OAKG;IACH,kCA8BC;IAED;;;;;;OAMG;IACH,wBAoDC;IAED;;;;OAIG;IACH,yBAFW,MAAM,QAQhB;IAED;;;;;OAKG;IACH,4BAHW,MAAM,OAmBhB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,KAAQ,CAK3B;IAED;;;;OAIG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;;;OAIG;IACH,qBA2BC;CACF;AAGD,iDAAiD;AAOnC,iFAA+E;AAC/E,2DAA6D;AACzD,8DAAiE"}
|
|
@@ -54,51 +54,83 @@ class PolicyManager {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// Load from file
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
// Load from file - check multiple locations for backward compatibility
|
|
58
|
+
const policyPaths = [
|
|
59
|
+
path.join(projectRoot, '.caws', 'policy.yaml'), // Preferred location
|
|
60
|
+
path.join(projectRoot, '.caws', 'policy', 'tier-policy.json'), // Legacy location
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
let policyPath = null;
|
|
64
|
+
let policyContent = null;
|
|
65
|
+
|
|
66
|
+
// Try each path in order
|
|
67
|
+
for (const candidatePath of policyPaths) {
|
|
68
|
+
try {
|
|
69
|
+
if (await fs.pathExists(candidatePath)) {
|
|
70
|
+
policyPath = candidatePath;
|
|
71
|
+
const content = await fs.readFile(candidatePath, 'utf-8');
|
|
72
|
+
|
|
73
|
+
// Handle JSON format (legacy)
|
|
74
|
+
if (candidatePath.endsWith('.json')) {
|
|
75
|
+
policyContent = JSON.parse(content);
|
|
76
|
+
} else {
|
|
77
|
+
// Handle YAML format (preferred)
|
|
78
|
+
policyContent = yaml.load(content);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
// Continue to next path if this one fails
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
63
87
|
|
|
88
|
+
if (policyPath && policyContent) {
|
|
64
89
|
// Validate policy structure
|
|
65
|
-
this.validatePolicy(
|
|
90
|
+
this.validatePolicy(policyContent);
|
|
66
91
|
|
|
67
92
|
// Update cache
|
|
68
93
|
if (this.enableCaching) {
|
|
69
94
|
this.policyCache.set(projectRoot, {
|
|
70
|
-
policy,
|
|
95
|
+
policy: policyContent,
|
|
71
96
|
cachedAt: Date.now(),
|
|
72
97
|
ttl: cacheTTL,
|
|
73
98
|
});
|
|
74
99
|
}
|
|
75
100
|
|
|
101
|
+
// Warn if using legacy location
|
|
102
|
+
if (policyPath.endsWith('.json')) {
|
|
103
|
+
console.warn(
|
|
104
|
+
'⚠️ Using legacy policy file location: .caws/policy/tier-policy.json\n' +
|
|
105
|
+
' Migrate to .caws/policy.yaml for better compatibility\n' +
|
|
106
|
+
' Run: caws init --migrate-policy'
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
76
110
|
return {
|
|
77
|
-
...
|
|
111
|
+
...policyContent,
|
|
78
112
|
_cacheHit: false,
|
|
79
113
|
_loadDuration: Date.now() - startTime,
|
|
114
|
+
_policyPath: policyPath,
|
|
80
115
|
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const defaultPolicy = this.getDefaultPolicy();
|
|
85
|
-
|
|
86
|
-
if (this.enableCaching) {
|
|
87
|
-
this.policyCache.set(projectRoot, {
|
|
88
|
-
policy: defaultPolicy,
|
|
89
|
-
cachedAt: Date.now(),
|
|
90
|
-
ttl: cacheTTL,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
116
|
+
} else {
|
|
117
|
+
// Policy file doesn't exist - use default
|
|
118
|
+
const defaultPolicy = this.getDefaultPolicy();
|
|
93
119
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
120
|
+
if (this.enableCaching) {
|
|
121
|
+
this.policyCache.set(projectRoot, {
|
|
122
|
+
policy: defaultPolicy,
|
|
123
|
+
cachedAt: Date.now(),
|
|
124
|
+
ttl: cacheTTL,
|
|
125
|
+
});
|
|
100
126
|
}
|
|
101
|
-
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
...defaultPolicy,
|
|
130
|
+
_isDefault: true,
|
|
131
|
+
_cacheHit: false,
|
|
132
|
+
_loadDuration: Date.now() - startTime,
|
|
133
|
+
};
|
|
102
134
|
}
|
|
103
135
|
} catch (error) {
|
|
104
136
|
throw new Error(`Policy load failed: ${error.message}`);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaffold Cursor hooks for a CAWS project
|
|
3
|
+
* @param {string} projectDir - Project directory path
|
|
4
|
+
* @param {string[]} levels - Hook levels to enable
|
|
5
|
+
*/
|
|
6
|
+
export function scaffoldCursorHooks(projectDir: string, levels?: string[]): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=cursor-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-hooks.d.ts","sourceRoot":"","sources":["../../src/scaffold/cursor-hooks.js"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,gDAHW,MAAM,WACN,MAAM,EAAE,iBAqJlB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaffold git hooks for CAWS provenance tracking
|
|
3
|
+
* @param {string} projectDir - Project directory path
|
|
4
|
+
* @param {Object} options - Hook options
|
|
5
|
+
*/
|
|
6
|
+
export function scaffoldGitHooks(projectDir: string, options?: any): Promise<{
|
|
7
|
+
added: number;
|
|
8
|
+
skipped: number;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Remove CAWS git hooks
|
|
12
|
+
* @param {string} projectDir - Project directory path
|
|
13
|
+
*/
|
|
14
|
+
export function removeGitHooks(projectDir: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Check git hooks status
|
|
17
|
+
* @param {string} projectDir - Project directory path
|
|
18
|
+
*/
|
|
19
|
+
export function checkGitHooksStatus(projectDir: string): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=git-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-hooks.d.ts","sourceRoot":"","sources":["../../src/scaffold/git-hooks.js"],"names":[],"mappings":"AASA;;;;GAIG;AACH,6CAHW,MAAM;;;GAwGhB;AAwND;;;GAGG;AACH,2CAFW,MAAM,iBAkChB;AAED;;;GAGG;AACH,gDAFW,MAAM,iBAgDhB"}
|
|
@@ -117,6 +117,7 @@ async function scaffoldGitHooks(projectDir, options = {}) {
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Generate pre-commit hook content with staged file quality gates
|
|
120
|
+
* Implements fallback chain: Node script → CLI → Python scripts → Skip gracefully
|
|
120
121
|
*/
|
|
121
122
|
function generatePreCommitHook(options) {
|
|
122
123
|
const { qualityGates = true, stagedOnly = true } = options;
|
|
@@ -124,6 +125,7 @@ function generatePreCommitHook(options) {
|
|
|
124
125
|
return `#!/bin/bash
|
|
125
126
|
# CAWS Pre-commit Hook
|
|
126
127
|
# Runs validation and quality checks before commits
|
|
128
|
+
# Implements graceful fallback chain to avoid blocking commits
|
|
127
129
|
|
|
128
130
|
set -e
|
|
129
131
|
|
|
@@ -136,39 +138,87 @@ if [ ! -d ".caws" ]; then
|
|
|
136
138
|
exit 0
|
|
137
139
|
fi
|
|
138
140
|
|
|
139
|
-
#
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
# Fallback chain for quality gates:
|
|
142
|
+
# 1. Try Node.js script (if exists)
|
|
143
|
+
# 2. Try CAWS CLI
|
|
144
|
+
# 3. Try Makefile target
|
|
145
|
+
# 4. Try Python scripts
|
|
146
|
+
# 5. Skip gracefully (warn only)
|
|
147
|
+
|
|
148
|
+
QUALITY_GATES_RAN=false
|
|
149
|
+
|
|
150
|
+
# Option 1: Node.js quality gates script
|
|
151
|
+
if [ -f "scripts/quality-gates/run-quality-gates.js" ]; then
|
|
152
|
+
if command -v node >/dev/null 2>&1; then
|
|
153
|
+
echo "📁 Running Node.js quality gates script..."
|
|
154
|
+
if node scripts/quality-gates/run-quality-gates.js; then
|
|
155
|
+
echo "✅ Quality gates passed"
|
|
156
|
+
QUALITY_GATES_RAN=true
|
|
157
|
+
else
|
|
158
|
+
echo "❌ Quality gates failed - commit blocked"
|
|
159
|
+
echo "💡 Fix the violations above before committing"
|
|
160
|
+
exit 1
|
|
161
|
+
fi
|
|
162
|
+
fi
|
|
163
|
+
# Option 2: CAWS CLI validation
|
|
164
|
+
elif command -v caws >/dev/null 2>&1; then
|
|
165
|
+
echo "📋 Running CAWS CLI validation..."
|
|
166
|
+
if caws validate --quiet 2>/dev/null; then
|
|
167
|
+
echo "✅ CAWS validation passed"
|
|
168
|
+
QUALITY_GATES_RAN=true
|
|
143
169
|
else
|
|
144
|
-
echo "
|
|
145
|
-
echo "💡
|
|
146
|
-
|
|
147
|
-
|
|
170
|
+
echo "⚠️ CAWS validation failed, but allowing commit (non-blocking)"
|
|
171
|
+
echo "💡 Run 'caws validate' for details"
|
|
172
|
+
QUALITY_GATES_RAN=true
|
|
173
|
+
fi
|
|
174
|
+
# Option 3: Makefile target
|
|
175
|
+
elif [ -f "Makefile" ] && grep -q "caws-validate\\|caws-gates" Makefile; then
|
|
176
|
+
echo "🔧 Running Makefile quality gates..."
|
|
177
|
+
if make caws-validate >/dev/null 2>&1 || make caws-gates >/dev/null 2>&1; then
|
|
178
|
+
echo "✅ Makefile quality gates passed"
|
|
179
|
+
QUALITY_GATES_RAN=true
|
|
180
|
+
else
|
|
181
|
+
echo "⚠️ Makefile quality gates failed, but allowing commit (non-blocking)"
|
|
182
|
+
QUALITY_GATES_RAN=true
|
|
183
|
+
fi
|
|
184
|
+
# Option 4: Python scripts
|
|
185
|
+
elif [ -f "scripts/simple_gates.py" ] && command -v python3 >/dev/null 2>&1; then
|
|
186
|
+
echo "🐍 Running Python quality gates script..."
|
|
187
|
+
if python3 scripts/simple_gates.py all --tier 2 --profile backend-api >/dev/null 2>&1; then
|
|
188
|
+
echo "✅ Python quality gates passed"
|
|
189
|
+
QUALITY_GATES_RAN=true
|
|
190
|
+
else
|
|
191
|
+
echo "⚠️ Python quality gates failed, but allowing commit (non-blocking)"
|
|
192
|
+
QUALITY_GATES_RAN=true
|
|
148
193
|
fi
|
|
194
|
+
# Option 5: Skip gracefully
|
|
149
195
|
else
|
|
150
|
-
echo "⚠️
|
|
151
|
-
echo "💡
|
|
152
|
-
|
|
196
|
+
echo "⚠️ Quality gates not available - skipping"
|
|
197
|
+
echo "💡 Available options:"
|
|
198
|
+
echo " • Install: npm install -g @paths.design/caws-cli"
|
|
199
|
+
echo " • Use Python: python3 scripts/simple_gates.py"
|
|
200
|
+
echo " • Use Makefile: make caws-gates"
|
|
201
|
+
QUALITY_GATES_RAN=true
|
|
153
202
|
fi
|
|
154
203
|
|
|
155
|
-
# Run hidden TODO analysis on staged files only
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if python3 scripts/v3/analysis/todo_analyzer.py
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
204
|
+
# Run hidden TODO analysis on staged files only (if Python available)
|
|
205
|
+
if [ "$QUALITY_GATES_RAN" = true ]; then
|
|
206
|
+
echo "🔍 Checking for hidden TODOs in staged files..."
|
|
207
|
+
if command -v python3 >/dev/null 2>&1 && [ -f "scripts/v3/analysis/todo_analyzer.py" ]; then
|
|
208
|
+
if python3 scripts/v3/analysis/todo_analyzer.py --staged-only --ci-mode --min-confidence 0.8 >/dev/null 2>&1; then
|
|
209
|
+
echo "✅ No critical hidden TODOs found in staged files"
|
|
210
|
+
else
|
|
211
|
+
echo "❌ Critical hidden TODOs detected in staged files - commit blocked"
|
|
212
|
+
echo "💡 Fix stub implementations and placeholder code before committing"
|
|
213
|
+
echo "📖 See docs/PLACEHOLDER-DETECTION-GUIDE.md for classification"
|
|
214
|
+
echo ""
|
|
215
|
+
echo "🔍 Running detailed analysis on staged files..."
|
|
216
|
+
python3 scripts/v3/analysis/todo_analyzer.py --staged-only --min-confidence 0.8
|
|
217
|
+
exit 1
|
|
218
|
+
fi
|
|
219
|
+
elif command -v python3 >/dev/null 2>&1; then
|
|
220
|
+
echo "⚠️ Python3 found but TODO analyzer not available - skipping"
|
|
168
221
|
fi
|
|
169
|
-
else
|
|
170
|
-
echo "⚠️ Python3 not found - skipping hidden TODO analysis"
|
|
171
|
-
echo "💡 Install Python3 to enable automatic TODO checking"
|
|
172
222
|
fi
|
|
173
223
|
|
|
174
224
|
echo "✅ All quality checks passed - proceeding with commit"
|
|
@@ -280,6 +330,18 @@ if [ -f "package.json" ]; then
|
|
|
280
330
|
# Don't fail on warnings, just warn
|
|
281
331
|
fi
|
|
282
332
|
fi
|
|
333
|
+
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
|
|
334
|
+
# Python project security checks
|
|
335
|
+
if command -v pip-audit >/dev/null 2>&1; then
|
|
336
|
+
echo "🔍 Checking Python vulnerabilities..."
|
|
337
|
+
pip-audit --desc 2>/dev/null || echo "⚠️ Install pip-audit for vulnerability checks: pip install pip-audit"
|
|
338
|
+
fi
|
|
339
|
+
elif [ -f "Cargo.toml" ]; then
|
|
340
|
+
# Rust project security checks
|
|
341
|
+
if command -v cargo-audit >/dev/null 2>&1; then
|
|
342
|
+
echo "🔍 Checking Rust vulnerabilities..."
|
|
343
|
+
cargo audit 2>/dev/null || echo "⚠️ Install cargo-audit for vulnerability checks: cargo install cargo-audit"
|
|
344
|
+
fi
|
|
283
345
|
fi
|
|
284
346
|
|
|
285
347
|
echo "🎉 Pre-push checks completed!"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaffold existing project with CAWS components
|
|
3
|
+
* @param {Object} options - Scaffold options
|
|
4
|
+
*/
|
|
5
|
+
export function scaffoldProject(options: any): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Scaffold IDE integrations for comprehensive CAWS development experience
|
|
8
|
+
* @param {string} targetDir - Target directory for scaffolding
|
|
9
|
+
* @param {Object} options - Scaffold options
|
|
10
|
+
*/
|
|
11
|
+
export function scaffoldIDEIntegrations(targetDir: string, options: any): Promise<{
|
|
12
|
+
added: number;
|
|
13
|
+
skipped: number;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Set dependencies for scaffold module
|
|
17
|
+
* @param {Object} deps - Dependencies object
|
|
18
|
+
*/
|
|
19
|
+
export function setScaffoldDependencies(deps: any): void;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.js"],"names":[],"mappings":"AAkKA;;;GAGG;AACH,6DA6VC;AAhfD;;;;GAIG;AACH,mDAHW,MAAM;;;GA8HhB;AAMD;;;GAGG;AACH,yDAGC"}
|
package/dist/scaffold/index.js
CHANGED
|
@@ -330,6 +330,31 @@ async function scaffoldProject(options) {
|
|
|
330
330
|
required: false,
|
|
331
331
|
});
|
|
332
332
|
|
|
333
|
+
// Install quality gates package if requested
|
|
334
|
+
if (options.withQualityGates) {
|
|
335
|
+
console.log(chalk.blue('\n📦 Installing quality gates package...'));
|
|
336
|
+
try {
|
|
337
|
+
const { execSync } = require('child_process');
|
|
338
|
+
const npmCommand = fs.existsSync(path.join(currentDir, 'package.json'))
|
|
339
|
+
? 'npm install --save-dev @paths.design/quality-gates'
|
|
340
|
+
: 'npm install -g @paths.design/quality-gates';
|
|
341
|
+
|
|
342
|
+
console.log(chalk.gray(` Running: ${npmCommand}`));
|
|
343
|
+
execSync(npmCommand, {
|
|
344
|
+
cwd: currentDir,
|
|
345
|
+
stdio: 'inherit',
|
|
346
|
+
});
|
|
347
|
+
console.log(chalk.green('✅ Quality gates package installed'));
|
|
348
|
+
console.log(chalk.blue('💡 You can now use: caws quality-gates'));
|
|
349
|
+
} catch (error) {
|
|
350
|
+
console.log(chalk.yellow(`⚠️ Failed to install quality gates package: ${error.message}`));
|
|
351
|
+
console.log(
|
|
352
|
+
chalk.gray(' You can install manually: npm install -g @paths.design/quality-gates')
|
|
353
|
+
);
|
|
354
|
+
console.log(chalk.gray(' Or use Python scripts: python3 scripts/simple_gates.py'));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
333
358
|
// Add commit conventions for setups that don't have them
|
|
334
359
|
if (!setup.hasTemplates || !fs.existsSync(path.join(currentDir, 'COMMIT_CONVENTIONS.md'))) {
|
|
335
360
|
enhancements.push({
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec File Manager - Handles WorkingSpec file operations and YAML conversion
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Bidirectional WorkingSpec ↔ YAML conversion
|
|
6
|
+
* - Temporary file support for validation workflows
|
|
7
|
+
* - Backup/restore capabilities
|
|
8
|
+
* - Automatic cleanup of old temporary files
|
|
9
|
+
*/
|
|
10
|
+
export class SpecFileManager {
|
|
11
|
+
constructor(config?: {});
|
|
12
|
+
projectRoot: any;
|
|
13
|
+
useTemporaryFiles: any;
|
|
14
|
+
tempDir: any;
|
|
15
|
+
/**
|
|
16
|
+
* Convert WorkingSpec object to YAML string
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} spec - WorkingSpec to convert
|
|
19
|
+
* @returns {string} YAML string representation
|
|
20
|
+
*/
|
|
21
|
+
specToYaml(spec: any): string;
|
|
22
|
+
/**
|
|
23
|
+
* Parse YAML string to WorkingSpec object
|
|
24
|
+
*
|
|
25
|
+
* @param {string} yamlContent - YAML string to parse
|
|
26
|
+
* @returns {Object} Parsed WorkingSpec object
|
|
27
|
+
* @throws {Error} If YAML is invalid or doesn't match WorkingSpec schema
|
|
28
|
+
*/
|
|
29
|
+
yamlToSpec(yamlContent: string): any;
|
|
30
|
+
/**
|
|
31
|
+
* Get path to .caws/working-spec.yaml in project
|
|
32
|
+
*
|
|
33
|
+
* @returns {string} Absolute path to working spec file
|
|
34
|
+
*/
|
|
35
|
+
getSpecFilePath(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Check if working spec file exists
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise<boolean>} True if file exists
|
|
40
|
+
*/
|
|
41
|
+
specFileExists(): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Read working spec from .caws/working-spec.yaml
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<Object>} Parsed WorkingSpec object
|
|
46
|
+
* @throws {Error} If file doesn't exist or is invalid
|
|
47
|
+
*/
|
|
48
|
+
readSpecFile(): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Write WorkingSpec to file
|
|
51
|
+
*
|
|
52
|
+
* Writes to .caws/working-spec.yaml or a temporary file based on configuration.
|
|
53
|
+
*
|
|
54
|
+
* @param {Object} spec - WorkingSpec to write
|
|
55
|
+
* @param {Object} options - Write options
|
|
56
|
+
* @param {boolean} options.useTemp - Override temp file usage
|
|
57
|
+
* @param {boolean} options.backup - Create backup before writing
|
|
58
|
+
* @returns {Promise<Object>} Write result with file path and cleanup function
|
|
59
|
+
*/
|
|
60
|
+
writeSpecFile(spec: any, options?: {
|
|
61
|
+
useTemp: boolean;
|
|
62
|
+
backup: boolean;
|
|
63
|
+
}): Promise<any>;
|
|
64
|
+
/**
|
|
65
|
+
* Update existing working spec file
|
|
66
|
+
*
|
|
67
|
+
* Reads current spec, merges changes, and writes back.
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} updates - Partial WorkingSpec with fields to update
|
|
70
|
+
* @returns {Promise<Object>} Updated WorkingSpec
|
|
71
|
+
*/
|
|
72
|
+
updateSpecFile(updates: any): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* Create backup of working spec
|
|
75
|
+
*
|
|
76
|
+
* @returns {Promise<string>} Path to backup file
|
|
77
|
+
*/
|
|
78
|
+
backupSpecFile(): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Restore working spec from backup
|
|
81
|
+
*
|
|
82
|
+
* @param {string} backupPath - Path to backup file
|
|
83
|
+
* @returns {Promise<void>}
|
|
84
|
+
*/
|
|
85
|
+
restoreSpecFile(backupPath: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* List all backup files
|
|
88
|
+
*
|
|
89
|
+
* @returns {Promise<string[]>} Array of backup file paths
|
|
90
|
+
*/
|
|
91
|
+
listBackups(): Promise<string[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Delete old backup files
|
|
94
|
+
*
|
|
95
|
+
* @param {Object} options - Cleanup options
|
|
96
|
+
* @param {number} options.maxAge - Maximum age in milliseconds (default: 7 days)
|
|
97
|
+
* @param {number} options.keep - Minimum number of backups to keep (default: 5)
|
|
98
|
+
* @returns {Promise<number>} Number of backups deleted
|
|
99
|
+
*/
|
|
100
|
+
cleanupBackups(options?: {
|
|
101
|
+
maxAge: number;
|
|
102
|
+
keep: number;
|
|
103
|
+
}): Promise<number>;
|
|
104
|
+
/**
|
|
105
|
+
* Validate spec file exists and is parseable
|
|
106
|
+
*
|
|
107
|
+
* @returns {Promise<Object>} Validation result
|
|
108
|
+
*/
|
|
109
|
+
validateSpecFile(): Promise<any>;
|
|
110
|
+
/**
|
|
111
|
+
* Clean up old temporary spec files
|
|
112
|
+
*
|
|
113
|
+
* Removes temp files older than specified age.
|
|
114
|
+
*
|
|
115
|
+
* @param {number} maxAge - Maximum age in milliseconds (default: 1 hour)
|
|
116
|
+
* @returns {Promise<number>} Number of files cleaned up
|
|
117
|
+
*/
|
|
118
|
+
cleanupTempFiles(maxAge?: number): Promise<number>;
|
|
119
|
+
/**
|
|
120
|
+
* Get spec file stats (size, modified date, etc.)
|
|
121
|
+
*
|
|
122
|
+
* @returns {Promise<Object>} File stats
|
|
123
|
+
*/
|
|
124
|
+
getSpecFileStats(): Promise<any>;
|
|
125
|
+
/**
|
|
126
|
+
* Create a new SpecFileManager instance with different configuration
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} config - New configuration
|
|
129
|
+
* @returns {SpecFileManager} New instance
|
|
130
|
+
*/
|
|
131
|
+
withConfig(config: any): SpecFileManager;
|
|
132
|
+
}
|
|
133
|
+
export const defaultSpecFileManager: SpecFileManager;
|
|
134
|
+
/**
|
|
135
|
+
* Create a SpecFileManager instance with default configuration
|
|
136
|
+
*
|
|
137
|
+
* @param {string} projectRoot - Project root directory
|
|
138
|
+
* @param {Object} options - Additional options
|
|
139
|
+
* @returns {SpecFileManager} SpecFileManager instance
|
|
140
|
+
*/
|
|
141
|
+
export function createSpecFileManager(projectRoot: string, options?: any): SpecFileManager;
|
|
142
|
+
export declare function specToYaml(spec: any): string;
|
|
143
|
+
export declare function yamlToSpec(yaml: any): any;
|
|
144
|
+
export declare function readSpecFile(projectRoot: any): Promise<any>;
|
|
145
|
+
export declare function writeSpecFile(spec: any, projectRoot: any, options: any): Promise<any>;
|
|
146
|
+
//# sourceMappingURL=SpecFileManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpecFileManager.d.ts","sourceRoot":"","sources":["../../src/spec/SpecFileManager.js"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AACH;IACE,yBAIC;IAHC,iBAAsD;IACtD,uBAA0D;IAC1D,aAA4C;IAG9C;;;;;OAKG;IACH,uBAFa,MAAM,CASlB;IAED;;;;;;OAMG;IACH,wBAJW,MAAM,OAqBhB;IAED;;;;OAIG;IACH,mBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,kBAFa,OAAO,CAAC,OAAO,CAAC,CAS5B;IAED;;;;;OAKG;IACH,gBAHa,OAAO,KAAQ,CAe3B;IAED;;;;;;;;;;OAUG;IACH,mCAJG;QAAyB,OAAO,EAAxB,OAAO;QACU,MAAM,EAAvB,OAAO;KACf,GAAU,OAAO,KAAQ,CA2C3B;IAED;;;;;;;OAOG;IACH,8BAFa,OAAO,KAAQ,CAa3B;IAED;;;;OAIG;IACH,kBAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAKzB;IAED;;;;OAIG;IACH,eAFa,OAAO,CAAC,MAAM,EAAE,CAAC,CAoB7B;IAED;;;;;;;OAOG;IACH,yBAJG;QAAwB,MAAM,EAAtB,MAAM;QACU,IAAI,EAApB,MAAM;KACd,GAAU,OAAO,CAAC,MAAM,CAAC,CA+B3B;IAED;;;;OAIG;IACH,oBAFa,OAAO,KAAQ,CAe3B;IAED;;;;;;;OAOG;IACH,0BAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CA6B3B;IAED;;;;OAIG;IACH,oBAFa,OAAO,KAAQ,CA0B3B;IAED;;;;;OAKG;IACH,yBAFa,eAAe,CAS3B;CACF;AAiBD,qDAAqD;AAfrD;;;;;;GAMG;AACH,mDAJW,MAAM,kBAEJ,eAAe,CAO3B;AAWa,sDAAiD;AACjD,mDAAiD;AAC/C,qEAKb;AACc,+FAKd"}
|