@paths.design/caws-cli 6.0.0 → 7.0.1
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.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/quality-gates.d.ts +52 -0
- package/dist/commands/quality-gates.d.ts.map +1 -0
- package/dist/commands/quality-gates.js +4 -2
- 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/status.d.ts +44 -0
- package/dist/commands/status.d.ts.map +1 -0
- 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/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/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.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/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 +65 -7
- package/dist/scaffold/index.d.ts +20 -0
- package/dist/scaffold/index.d.ts.map +1 -0
- package/dist/scaffold/index.js +179 -41
- 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/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/project-analysis.js +103 -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/COMMIT_CONVENTIONS.md +86 -0
- package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
- package/templates/apps/tools/caws/provenance.js.backup +73 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export namespace SPEC_TYPES {
|
|
2
|
+
namespace feature {
|
|
3
|
+
let color: chalk.Chalk;
|
|
4
|
+
let icon: string;
|
|
5
|
+
let description: string;
|
|
6
|
+
}
|
|
7
|
+
namespace fix {
|
|
8
|
+
let color_1: chalk.Chalk;
|
|
9
|
+
export { color_1 as color };
|
|
10
|
+
let icon_1: string;
|
|
11
|
+
export { icon_1 as icon };
|
|
12
|
+
let description_1: string;
|
|
13
|
+
export { description_1 as description };
|
|
14
|
+
}
|
|
15
|
+
namespace refactor {
|
|
16
|
+
let color_2: chalk.Chalk;
|
|
17
|
+
export { color_2 as color };
|
|
18
|
+
let icon_2: string;
|
|
19
|
+
export { icon_2 as icon };
|
|
20
|
+
let description_2: string;
|
|
21
|
+
export { description_2 as description };
|
|
22
|
+
}
|
|
23
|
+
namespace chore {
|
|
24
|
+
let color_3: chalk.Chalk;
|
|
25
|
+
export { color_3 as color };
|
|
26
|
+
let icon_3: string;
|
|
27
|
+
export { icon_3 as icon };
|
|
28
|
+
let description_3: string;
|
|
29
|
+
export { description_3 as description };
|
|
30
|
+
}
|
|
31
|
+
namespace docs {
|
|
32
|
+
let color_4: chalk.Chalk;
|
|
33
|
+
export { color_4 as color };
|
|
34
|
+
let icon_4: string;
|
|
35
|
+
export { icon_4 as icon };
|
|
36
|
+
let description_4: string;
|
|
37
|
+
export { description_4 as description };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
import chalk = require("chalk");
|
|
41
|
+
//# sourceMappingURL=spec-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-types.d.ts","sourceRoot":"","sources":["../../src/constants/spec-types.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced error class with category and recovery suggestions
|
|
3
|
+
*/
|
|
4
|
+
export class CAWSError extends Error {
|
|
5
|
+
constructor(message: any, category?: any, suggestions?: any[]);
|
|
6
|
+
category: any;
|
|
7
|
+
suggestions: any[];
|
|
8
|
+
timestamp: Date;
|
|
9
|
+
executionTime: any;
|
|
10
|
+
}
|
|
11
|
+
export namespace ERROR_CATEGORIES {
|
|
12
|
+
let VALIDATION: string;
|
|
13
|
+
let PERMISSION: string;
|
|
14
|
+
let FILESYSTEM: string;
|
|
15
|
+
let NETWORK: string;
|
|
16
|
+
let CONFIGURATION: string;
|
|
17
|
+
let USER_INPUT: string;
|
|
18
|
+
let DEPENDENCY: string;
|
|
19
|
+
let UNKNOWN: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execution timing utilities
|
|
23
|
+
*/
|
|
24
|
+
export class ExecutionTimer {
|
|
25
|
+
startTime: bigint;
|
|
26
|
+
endTime: bigint;
|
|
27
|
+
start(): void;
|
|
28
|
+
end(): number;
|
|
29
|
+
getDuration(): number;
|
|
30
|
+
formatDuration(): string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get error category from error object or message
|
|
34
|
+
* @param {Error|string} error - Error object or message
|
|
35
|
+
* @returns {string} Error category
|
|
36
|
+
*/
|
|
37
|
+
export function getErrorCategory(error: Error | string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Wrap async operations with consistent error handling and timing
|
|
40
|
+
* @param {Function} operation - Async operation to wrap
|
|
41
|
+
* @param {string} context - Context for error messages
|
|
42
|
+
* @param {boolean} includeTiming - Whether to include timing in results
|
|
43
|
+
* @returns {Promise<any>} Operation result or throws handled error
|
|
44
|
+
*/
|
|
45
|
+
export function safeAsync(operation: Function, context?: string, includeTiming?: boolean): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* Wrap sync operations with timing
|
|
48
|
+
* @param {Function} operation - Sync operation to wrap
|
|
49
|
+
* @param {string} context - Context for error messages
|
|
50
|
+
* @param {boolean} includeTiming - Whether to include timing in results
|
|
51
|
+
* @returns {any} Operation result or throws handled error
|
|
52
|
+
*/
|
|
53
|
+
export function safeSync(operation: Function, context?: string, includeTiming?: boolean): any;
|
|
54
|
+
/**
|
|
55
|
+
* Handle CLI errors with consistent formatting and user guidance
|
|
56
|
+
* @param {Error} error - Error to handle
|
|
57
|
+
* @param {Object} context - Error context (command, option, etc.)
|
|
58
|
+
* @param {boolean} exit - Whether to exit the process (default: true)
|
|
59
|
+
*/
|
|
60
|
+
export function handleCliError(error: Error, context?: any, exit?: boolean): void;
|
|
61
|
+
/**
|
|
62
|
+
* Validate required environment and dependencies
|
|
63
|
+
* @returns {Object} Validation result with any errors
|
|
64
|
+
*/
|
|
65
|
+
export function validateEnvironment(): any;
|
|
66
|
+
/**
|
|
67
|
+
* Get recovery suggestions based on error category
|
|
68
|
+
* @param {Error} error - Original error
|
|
69
|
+
* @param {string} category - Error category
|
|
70
|
+
* @param {Object} context - Additional context (command, options, etc.)
|
|
71
|
+
* @returns {string[]} Array of recovery suggestions
|
|
72
|
+
*/
|
|
73
|
+
export function getRecoverySuggestions(error: Error, category: string, context?: any): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Get documentation link for error category
|
|
76
|
+
* @param {string} category - Error category
|
|
77
|
+
* @param {Object} context - Additional context
|
|
78
|
+
* @returns {string} Documentation URL
|
|
79
|
+
*/
|
|
80
|
+
export function getDocumentationLink(category: string, context?: any): string;
|
|
81
|
+
/**
|
|
82
|
+
* Find similar command using Levenshtein distance
|
|
83
|
+
* @param {string} input - User's input command
|
|
84
|
+
* @param {string[]} validCommands - List of valid commands
|
|
85
|
+
* @returns {string|null} Most similar command or null
|
|
86
|
+
*/
|
|
87
|
+
export function findSimilarCommand(input: string, validCommands: string[]): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Command-specific error suggestions
|
|
90
|
+
*/
|
|
91
|
+
export const COMMAND_SUGGESTIONS: {
|
|
92
|
+
'unknown option': (option: any, command: any) => any[];
|
|
93
|
+
'unknown command': (command: any) => string[];
|
|
94
|
+
'template not found': () => string[];
|
|
95
|
+
'not a caws project': () => string[];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* JSON output formatter for programmatic use
|
|
99
|
+
* @param {Object} data - Data to format as JSON
|
|
100
|
+
* @param {boolean} pretty - Whether to pretty-print (default: true)
|
|
101
|
+
*/
|
|
102
|
+
export function formatJsonOutput(data: any, pretty?: boolean): string;
|
|
103
|
+
/**
|
|
104
|
+
* Check if user requested JSON output
|
|
105
|
+
* @returns {boolean} True if --json flag is present
|
|
106
|
+
*/
|
|
107
|
+
export function isJsonOutput(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Output data in appropriate format (JSON or human-readable)
|
|
110
|
+
* @param {Object} data - Data to output
|
|
111
|
+
* @param {boolean} success - Whether this is a success response
|
|
112
|
+
*/
|
|
113
|
+
export function outputResult(data: any, success?: boolean): any;
|
|
114
|
+
/**
|
|
115
|
+
* Troubleshooting guide system
|
|
116
|
+
*/
|
|
117
|
+
export const TROUBLESHOOTING_GUIDES: {
|
|
118
|
+
'coverage-report-not-found': {
|
|
119
|
+
title: string;
|
|
120
|
+
symptoms: string[];
|
|
121
|
+
rootCauses: string[];
|
|
122
|
+
solutions: string[];
|
|
123
|
+
commands: string[];
|
|
124
|
+
};
|
|
125
|
+
'mutation-report-not-found': {
|
|
126
|
+
title: string;
|
|
127
|
+
symptoms: string[];
|
|
128
|
+
rootCauses: string[];
|
|
129
|
+
solutions: string[];
|
|
130
|
+
commands: string[];
|
|
131
|
+
};
|
|
132
|
+
'working-spec-validation': {
|
|
133
|
+
title: string;
|
|
134
|
+
symptoms: string[];
|
|
135
|
+
rootCauses: string[];
|
|
136
|
+
solutions: string[];
|
|
137
|
+
commands: string[];
|
|
138
|
+
};
|
|
139
|
+
'monorepo-detection': {
|
|
140
|
+
title: string;
|
|
141
|
+
symptoms: string[];
|
|
142
|
+
rootCauses: string[];
|
|
143
|
+
solutions: string[];
|
|
144
|
+
commands: string[];
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Get troubleshooting guide for a specific issue
|
|
149
|
+
* @param {string} issueKey - Key for the troubleshooting guide
|
|
150
|
+
* @returns {Object|null} Troubleshooting guide or null if not found
|
|
151
|
+
*/
|
|
152
|
+
export function getTroubleshootingGuide(issueKey: string): any | null;
|
|
153
|
+
/**
|
|
154
|
+
* Get all available troubleshooting guides
|
|
155
|
+
* @returns {Object} All troubleshooting guides
|
|
156
|
+
*/
|
|
157
|
+
export function getAllTroubleshootingGuides(): any;
|
|
158
|
+
/**
|
|
159
|
+
* Suggest troubleshooting guide based on error message
|
|
160
|
+
* @param {string} errorMessage - Error message to analyze
|
|
161
|
+
* @returns {string|null} Issue key if match found, null otherwise
|
|
162
|
+
*/
|
|
163
|
+
export function suggestTroubleshootingGuide(errorMessage: string): string | null;
|
|
164
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../src/error-handler.js"],"names":[],"mappings":"AA0GA;;GAEG;AACH;IACE,+DAOC;IAJC,cAAqD;IACrD,mBAA2F;IAC3F,gBAA2B;IAC3B,mBAAyB;CAE5B;;;;;;;;;;;AAED;;GAEG;AACH;IAEI,kBAAqB;IACrB,gBAAmB;IAGrB,cAEC;IAED,cAGC;IAED,sBAIC;IAED,yBAMC;CACF;AAjHD;;;;GAIG;AACH,wCAHW,KAAK,GAAC,MAAM,GACV,MAAM,CA+DlB;AAiDD;;;;;;GAMG;AACH,yDAJW,MAAM,kBACN,OAAO,GACL,OAAO,CAAC,GAAG,CAAC,CA8BxB;AAED;;;;;;GAMG;AACH,wDAJW,MAAM,kBACN,OAAO,GACL,GAAG,CA8Bf;AAgSD;;;;;GAKG;AACH,sCAJW,KAAK,wBAEL,OAAO,QAmDjB;AA0JD;;;GAGG;AACH,2CAqBC;AAnXD;;;;;;GAMG;AACH,8CALW,KAAK,YACL,MAAM,kBAEJ,MAAM,EAAE,CAwDpB;AAED;;;;;GAKG;AACH,+CAJW,MAAM,kBAEJ,MAAM,CA4BlB;AAxJD;;;;;GAKG;AACH,0CAJW,MAAM,iBACN,MAAM,EAAE,GACN,MAAM,GAAC,IAAI,CAiBvB;AAjHD;;GAEG;AACH;;;;;EAuFE;AA4JF;;;;GAIG;AACH,qDAFW,OAAO,UAIjB;AAED;;;GAGG;AACH,gCAFa,OAAO,CAQnB;AAED;;;;GAIG;AACH,kDAFW,OAAO,OAcjB;AA2DD;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0GE;AAEF;;;;GAIG;AACH,kDAHW,MAAM,GACJ,MAAO,IAAI,CAIvB;AAED;;;GAGG;AACH,mDAEC;AAED;;;;GAIG;AACH,0DAHW,MAAM,GACJ,MAAM,GAAC,IAAI,CAmBvB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configure Jest for TypeScript project
|
|
3
|
+
* @param {string} projectDir - Project directory path
|
|
4
|
+
* @param {Object} options - Configuration options
|
|
5
|
+
* @returns {Promise<Object>} Configuration result
|
|
6
|
+
*/
|
|
7
|
+
export function configureJestForTypeScript(projectDir?: string, options?: any): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Generate Jest configuration for TypeScript project
|
|
10
|
+
* @param {Object} options - Configuration options
|
|
11
|
+
* @returns {string} Jest configuration content
|
|
12
|
+
*/
|
|
13
|
+
export function generateJestConfig(options?: any): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate test setup file for TypeScript
|
|
16
|
+
* @returns {string} Setup file content
|
|
17
|
+
*/
|
|
18
|
+
export function generateTestSetup(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Install Jest and TypeScript dependencies
|
|
21
|
+
* @param {string} projectDir - Project directory
|
|
22
|
+
* @param {Object} packageJson - Existing package.json
|
|
23
|
+
* @returns {Promise<Object>} Installation result
|
|
24
|
+
*/
|
|
25
|
+
export function installJestDependencies(projectDir: string, packageJson: any): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Get Jest configuration recommendations
|
|
28
|
+
* @param {string} projectDir - Project directory path
|
|
29
|
+
* @returns {Object} Recommendations
|
|
30
|
+
*/
|
|
31
|
+
export function getJestRecommendations(projectDir?: string): any;
|
|
32
|
+
//# sourceMappingURL=jest-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-config.d.ts","sourceRoot":"","sources":["../../src/generators/jest-config.js"],"names":[],"mappings":"AA+GA;;;;;GAKG;AACH,wDAJW,MAAM,kBAEJ,OAAO,KAAQ,CAgE3B;AAzKD;;;;GAIG;AACH,mDAFa,MAAM,CA0ClB;AAED;;;GAGG;AACH,qCAFa,MAAM,CAiBlB;AAED;;;;;GAKG;AACH,oDAJW,MAAM,qBAEJ,OAAO,KAAQ,CA2B3B;AAwED;;;;GAIG;AACH,oDAHW,MAAM,OAkDhB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate working spec YAML with user input
|
|
3
|
+
* @param {Object} answers - User responses
|
|
4
|
+
* @returns {string} - Generated YAML content
|
|
5
|
+
*/
|
|
6
|
+
export function generateWorkingSpec(answers: any): string;
|
|
7
|
+
/**
|
|
8
|
+
* Validate generated working spec against JSON schema
|
|
9
|
+
* @param {string} specContent - YAML spec content
|
|
10
|
+
* @param {Object} answers - User responses for error context
|
|
11
|
+
*/
|
|
12
|
+
export function validateGeneratedSpec(specContent: string, _answers: any): void;
|
|
13
|
+
//# sourceMappingURL=working-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-spec.d.ts","sourceRoot":"","sources":["../../src/generators/working-spec.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,mDAFa,MAAM,CAqJlB;AAED;;;;GAIG;AACH,mDAHW,MAAM,uBA8BhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-new.d.ts","sourceRoot":"","sources":["../src/index-new.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview CAWS CLI - Scaffolding tool for Coding Agent Workflow System
|
|
5
|
+
* Provides commands to initialize new projects and scaffold existing ones with CAWS
|
|
6
|
+
* @author @darianrosebrook
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { Command } = require('commander');
|
|
10
|
+
const fs = require('fs-extra');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const yaml = require('js-yaml');
|
|
13
|
+
const chalk = require('chalk');
|
|
14
|
+
|
|
15
|
+
// Import configuration and utilities
|
|
16
|
+
const {
|
|
17
|
+
CLI_VERSION,
|
|
18
|
+
initializeGlobalSetup,
|
|
19
|
+
loadProvenanceTools,
|
|
20
|
+
initializeLanguageSupport,
|
|
21
|
+
} = require('./config');
|
|
22
|
+
|
|
23
|
+
// Import command handlers
|
|
24
|
+
const { initProject } = require('./commands/init');
|
|
25
|
+
|
|
26
|
+
// Import scaffold functionality
|
|
27
|
+
const { scaffoldProject, setScaffoldDependencies } = require('./scaffold');
|
|
28
|
+
|
|
29
|
+
// Import validation functionality
|
|
30
|
+
const { validateWorkingSpecWithSuggestions } = require('./validation/spec-validation');
|
|
31
|
+
|
|
32
|
+
// Import finalization utilities
|
|
33
|
+
const {
|
|
34
|
+
finalizeProject,
|
|
35
|
+
continueToSuccess,
|
|
36
|
+
setFinalizationDependencies,
|
|
37
|
+
} = require('./utils/finalization');
|
|
38
|
+
|
|
39
|
+
// Import generators
|
|
40
|
+
const { generateWorkingSpec, validateGeneratedSpec } = require('./generators/working-spec');
|
|
41
|
+
|
|
42
|
+
// Import tool system
|
|
43
|
+
const ToolLoader = require('./tool-loader');
|
|
44
|
+
const ToolValidator = require('./tool-validator');
|
|
45
|
+
|
|
46
|
+
// Initialize global configuration
|
|
47
|
+
const program = new Command();
|
|
48
|
+
|
|
49
|
+
// Initialize global state
|
|
50
|
+
const cawsSetup = initializeGlobalSetup();
|
|
51
|
+
const languageSupport = initializeLanguageSupport();
|
|
52
|
+
|
|
53
|
+
// Set up dependencies for modules that need them
|
|
54
|
+
setScaffoldDependencies({
|
|
55
|
+
cawsSetup,
|
|
56
|
+
loadProvenanceTools,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
setFinalizationDependencies({
|
|
60
|
+
languageSupport,
|
|
61
|
+
loadProvenanceTools,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Tool system state
|
|
65
|
+
let toolLoader = null;
|
|
66
|
+
let toolValidator = null;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Initialize tool system
|
|
70
|
+
*/
|
|
71
|
+
async function initializeToolSystem() {
|
|
72
|
+
if (toolLoader) return toolLoader;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
toolLoader = new ToolLoader({
|
|
76
|
+
toolsDir: path.join(process.cwd(), 'apps/tools/caws'),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
toolValidator = new ToolValidator();
|
|
80
|
+
|
|
81
|
+
// Set up event listeners for tool system
|
|
82
|
+
toolLoader.on('discovery:complete', ({ tools: _tools, count }) => {
|
|
83
|
+
if (count > 0) {
|
|
84
|
+
console.log(chalk.blue(`🔧 Discovered ${count} tools`));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
toolLoader.on('tool:loaded', ({ id, metadata }) => {
|
|
89
|
+
console.log(chalk.gray(` ✓ Loaded tool: ${metadata.name} (${id})`));
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
toolLoader.on('tool:error', ({ id, error }) => {
|
|
93
|
+
console.warn(chalk.yellow(`⚠️ Failed to load tool ${id}: ${error}`));
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Auto-discover tools on initialization
|
|
97
|
+
await toolLoader.discoverTools();
|
|
98
|
+
|
|
99
|
+
return toolLoader;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.warn(chalk.yellow('⚠️ Tool system initialization failed:'), error.message);
|
|
102
|
+
console.warn(chalk.blue('💡 Continuing without dynamic tools'));
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Validate command handler
|
|
109
|
+
*/
|
|
110
|
+
async function validateCommand(specFile, options) {
|
|
111
|
+
try {
|
|
112
|
+
let specPath = specFile || path.join('.caws', 'working-spec.yaml');
|
|
113
|
+
|
|
114
|
+
if (!fs.existsSync(specPath)) {
|
|
115
|
+
console.error(chalk.red(`❌ Spec file not found: ${specPath}`));
|
|
116
|
+
console.error(chalk.blue('💡 Run "caws init" first to create a working spec'));
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const specContent = fs.readFileSync(specPath, 'utf8');
|
|
121
|
+
const spec = yaml.load(specContent);
|
|
122
|
+
|
|
123
|
+
console.log(chalk.cyan('🔍 Validating CAWS working spec...'));
|
|
124
|
+
|
|
125
|
+
const result = validateWorkingSpecWithSuggestions(spec, {
|
|
126
|
+
autoFix: options.autoFix,
|
|
127
|
+
suggestions: !options.quiet,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (result.valid) {
|
|
131
|
+
console.log(chalk.green('✅ Working spec validation passed'));
|
|
132
|
+
if (!options.quiet) {
|
|
133
|
+
console.log(chalk.gray(` Risk tier: ${spec.risk_tier}`));
|
|
134
|
+
console.log(chalk.gray(` Mode: ${spec.mode}`));
|
|
135
|
+
if (spec.title) {
|
|
136
|
+
console.log(chalk.gray(` Title: ${spec.title}`));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
console.log(chalk.red('❌ Working spec validation failed'));
|
|
141
|
+
|
|
142
|
+
// Show errors
|
|
143
|
+
result.errors.forEach((error, index) => {
|
|
144
|
+
console.log(` ${index + 1}. ${chalk.red(error.message)}`);
|
|
145
|
+
if (error.suggestion) {
|
|
146
|
+
console.log(` ${chalk.blue('💡 ' + error.suggestion)}`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Show warnings
|
|
151
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
152
|
+
console.log(chalk.yellow('\n⚠️ Warnings:'));
|
|
153
|
+
result.warnings.forEach((warning, index) => {
|
|
154
|
+
console.log(` ${index + 1}. ${chalk.yellow(warning.message)}`);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error(chalk.red('❌ Error during validation:'), error.message);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Tool execution command handler
|
|
168
|
+
*/
|
|
169
|
+
async function executeTool(toolId, options) {
|
|
170
|
+
try {
|
|
171
|
+
// Initialize tool system
|
|
172
|
+
const loader = await initializeToolSystem();
|
|
173
|
+
|
|
174
|
+
if (!loader) {
|
|
175
|
+
console.error(chalk.red('❌ Tool system not available'));
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Load all tools first
|
|
180
|
+
await loader.loadAllTools();
|
|
181
|
+
const tool = loader.getTool(toolId);
|
|
182
|
+
|
|
183
|
+
if (!tool) {
|
|
184
|
+
console.error(chalk.red(`❌ Tool '${toolId}' not found`));
|
|
185
|
+
console.log(chalk.blue('💡 Available tools:'));
|
|
186
|
+
const tools = loader.getAllTools();
|
|
187
|
+
for (const [id, t] of tools) {
|
|
188
|
+
console.log(` - ${id}: ${t.metadata.name}`);
|
|
189
|
+
}
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Validate tool before execution
|
|
194
|
+
const validation = await toolValidator.validateTool(tool);
|
|
195
|
+
if (!validation.valid) {
|
|
196
|
+
console.error(chalk.red('❌ Tool validation failed:'));
|
|
197
|
+
validation.errors.forEach((error) => {
|
|
198
|
+
console.error(` ${chalk.red('✗')} ${error}`);
|
|
199
|
+
});
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Parse parameters
|
|
204
|
+
let params = {};
|
|
205
|
+
if (options.params) {
|
|
206
|
+
try {
|
|
207
|
+
params = JSON.parse(options.params);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error(chalk.red('❌ Invalid JSON parameters:'), error.message);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
console.log(chalk.blue(`🚀 Executing tool: ${tool.metadata.name}`));
|
|
215
|
+
|
|
216
|
+
// Execute tool
|
|
217
|
+
const result = await tool.module.execute(params, {
|
|
218
|
+
workingDirectory: process.cwd(),
|
|
219
|
+
timeout: options.timeout,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Display results
|
|
223
|
+
if (result.success) {
|
|
224
|
+
console.log(chalk.green('✅ Tool execution successful'));
|
|
225
|
+
if (result.output && typeof result.output === 'object') {
|
|
226
|
+
console.log(chalk.gray('Output:'), JSON.stringify(result.output, null, 2));
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
console.error(chalk.red('❌ Tool execution failed'));
|
|
230
|
+
result.errors.forEach((error) => {
|
|
231
|
+
console.error(` ${chalk.red('✗')} ${error}`);
|
|
232
|
+
});
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error(chalk.red(`❌ Error executing tool ${toolId}:`), error.message);
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Setup CLI program
|
|
242
|
+
program.name('caws').description('CAWS - Coding Agent Workflow System CLI').version(CLI_VERSION);
|
|
243
|
+
|
|
244
|
+
// Init command
|
|
245
|
+
program
|
|
246
|
+
.command('init')
|
|
247
|
+
.description('Initialize a new project with CAWS')
|
|
248
|
+
.argument('[project-name]', 'Name of the project to create (use "." for current directory)')
|
|
249
|
+
.option('-i, --interactive', 'Run interactive setup wizard', true)
|
|
250
|
+
.option('--non-interactive', 'Skip interactive prompts (use defaults)', false)
|
|
251
|
+
.option('--template <template>', 'Use specific project template')
|
|
252
|
+
.action(initProject);
|
|
253
|
+
|
|
254
|
+
// Scaffold command
|
|
255
|
+
program
|
|
256
|
+
.command('scaffold')
|
|
257
|
+
.description('Add CAWS components to existing project')
|
|
258
|
+
.option('-f, --force', 'Overwrite existing files', false)
|
|
259
|
+
.option('--minimal', 'Only essential components', false)
|
|
260
|
+
.option('--with-codemods', 'Include codemod scripts', false)
|
|
261
|
+
.option('--with-oidc', 'Include OIDC trusted publisher setup', false)
|
|
262
|
+
.action(scaffoldProject);
|
|
263
|
+
|
|
264
|
+
// Validate command
|
|
265
|
+
program
|
|
266
|
+
.command('validate')
|
|
267
|
+
.description('Validate CAWS working spec with suggestions')
|
|
268
|
+
.argument('[spec-file]', 'Path to working spec file (default: .caws/working-spec.yaml)')
|
|
269
|
+
.option('-q, --quiet', 'Suppress suggestions and warnings', false)
|
|
270
|
+
.option('--auto-fix', 'Automatically fix safe validation issues', false)
|
|
271
|
+
.action(validateCommand);
|
|
272
|
+
|
|
273
|
+
// Tool command
|
|
274
|
+
program
|
|
275
|
+
.command('tool')
|
|
276
|
+
.description('Execute CAWS tools programmatically')
|
|
277
|
+
.argument('<tool-id>', 'ID of the tool to execute')
|
|
278
|
+
.option('-p, --params <json>', 'Parameters as JSON string', '{}')
|
|
279
|
+
.option('-t, --timeout <ms>', 'Execution timeout in milliseconds', parseInt, 30000)
|
|
280
|
+
.action(executeTool);
|
|
281
|
+
|
|
282
|
+
// Error handling
|
|
283
|
+
program.exitOverride((err) => {
|
|
284
|
+
if (
|
|
285
|
+
err.code === 'commander.help' ||
|
|
286
|
+
err.code === 'commander.version' ||
|
|
287
|
+
err.message.includes('outputHelp')
|
|
288
|
+
) {
|
|
289
|
+
process.exit(0);
|
|
290
|
+
}
|
|
291
|
+
console.error(chalk.red('❌ Error:'), err.message);
|
|
292
|
+
process.exit(1);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Parse and run
|
|
296
|
+
if (require.main === module) {
|
|
297
|
+
try {
|
|
298
|
+
program.parse();
|
|
299
|
+
} catch (error) {
|
|
300
|
+
if (
|
|
301
|
+
error.code === 'commander.help' ||
|
|
302
|
+
error.code === 'commander.version' ||
|
|
303
|
+
error.message.includes('outputHelp')
|
|
304
|
+
) {
|
|
305
|
+
process.exit(0);
|
|
306
|
+
} else {
|
|
307
|
+
console.error(chalk.red('❌ Error:'), error.message);
|
|
308
|
+
process.exit(1);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Export functions for testing
|
|
314
|
+
module.exports = {
|
|
315
|
+
generateWorkingSpec,
|
|
316
|
+
validateGeneratedSpec,
|
|
317
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|