@paths.design/caws-cli 3.0.0 → 3.1.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.
Files changed (95) hide show
  1. package/README.md +295 -150
  2. package/dist/budget-derivation.d.ts +35 -0
  3. package/dist/budget-derivation.d.ts.map +1 -0
  4. package/dist/budget-derivation.js +204 -0
  5. package/dist/cicd-optimizer.d.ts +142 -0
  6. package/dist/cicd-optimizer.d.ts.map +1 -0
  7. package/dist/cicd-optimizer.js +504 -0
  8. package/dist/commands/burnup.d.ts +6 -0
  9. package/dist/commands/burnup.d.ts.map +1 -0
  10. package/dist/commands/burnup.js +90 -0
  11. package/dist/commands/init.d.ts +5 -0
  12. package/dist/commands/init.d.ts.map +1 -0
  13. package/dist/commands/init.js +514 -0
  14. package/dist/commands/provenance.d.ts +22 -0
  15. package/dist/commands/provenance.d.ts.map +1 -0
  16. package/dist/commands/provenance.js +594 -0
  17. package/dist/commands/tool.d.ts +13 -0
  18. package/dist/commands/tool.d.ts.map +1 -0
  19. package/dist/commands/tool.js +138 -0
  20. package/dist/commands/validate.d.ts +7 -0
  21. package/dist/commands/validate.d.ts.map +1 -0
  22. package/dist/commands/validate.js +80 -0
  23. package/dist/config/index.d.ts +29 -0
  24. package/dist/config/index.d.ts.map +1 -0
  25. package/dist/config/index.js +132 -0
  26. package/dist/error-handler.d.ts +50 -0
  27. package/dist/error-handler.d.ts.map +1 -0
  28. package/dist/error-handler.js +253 -0
  29. package/dist/generators/working-spec.d.ts +13 -0
  30. package/dist/generators/working-spec.d.ts.map +1 -0
  31. package/dist/generators/working-spec.js +204 -0
  32. package/dist/index-new.d.ts +5 -0
  33. package/dist/index-new.d.ts.map +1 -0
  34. package/dist/index-new.js +317 -0
  35. package/dist/index.d.ts +3 -12
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +100 -1659
  38. package/dist/index.js.backup +4711 -0
  39. package/dist/scaffold/cursor-hooks.d.ts +7 -0
  40. package/dist/scaffold/cursor-hooks.d.ts.map +1 -0
  41. package/dist/scaffold/cursor-hooks.js +152 -0
  42. package/dist/scaffold/index.d.ts +20 -0
  43. package/dist/scaffold/index.d.ts.map +1 -0
  44. package/dist/scaffold/index.js +486 -0
  45. package/dist/test-analysis.d.ts +182 -0
  46. package/dist/test-analysis.d.ts.map +1 -0
  47. package/dist/test-analysis.js +580 -0
  48. package/dist/tool-interface.d.ts +236 -0
  49. package/dist/tool-interface.d.ts.map +1 -0
  50. package/dist/tool-interface.js +314 -0
  51. package/dist/tool-loader.d.ts +77 -0
  52. package/dist/tool-loader.d.ts.map +1 -0
  53. package/dist/tool-loader.js +298 -0
  54. package/dist/tool-validator.d.ts +72 -0
  55. package/dist/tool-validator.d.ts.map +1 -0
  56. package/dist/tool-validator.js +387 -0
  57. package/dist/utils/detection.d.ts +7 -0
  58. package/dist/utils/detection.d.ts.map +1 -0
  59. package/dist/utils/detection.js +174 -0
  60. package/dist/utils/finalization.d.ts +17 -0
  61. package/dist/utils/finalization.d.ts.map +1 -0
  62. package/dist/utils/finalization.js +229 -0
  63. package/dist/utils/project-analysis.d.ts +14 -0
  64. package/dist/utils/project-analysis.d.ts.map +1 -0
  65. package/dist/utils/project-analysis.js +105 -0
  66. package/dist/validation/spec-validation.d.ts +29 -0
  67. package/dist/validation/spec-validation.d.ts.map +1 -0
  68. package/dist/validation/spec-validation.js +376 -0
  69. package/dist/waivers-manager.d.ts +167 -0
  70. package/dist/waivers-manager.d.ts.map +1 -0
  71. package/dist/waivers-manager.js +549 -0
  72. package/package.json +10 -12
  73. package/templates/.cursor/README.md +311 -0
  74. package/templates/.cursor/hooks/audit.sh +55 -0
  75. package/templates/.cursor/hooks/block-dangerous.sh +77 -0
  76. package/templates/.cursor/hooks/caws-quality-check.sh +52 -0
  77. package/templates/.cursor/hooks/caws-scope-guard.sh +74 -0
  78. package/templates/.cursor/hooks/caws-tool-validation.sh +121 -0
  79. package/templates/.cursor/hooks/format.sh +38 -0
  80. package/templates/.cursor/hooks/naming-check.sh +64 -0
  81. package/templates/.cursor/hooks/scan-secrets.sh +46 -0
  82. package/templates/.cursor/hooks/scope-guard.sh +52 -0
  83. package/templates/.cursor/hooks/validate-spec.sh +38 -0
  84. package/templates/.cursor/hooks.json +59 -0
  85. package/templates/.github/copilot/instructions.md +311 -0
  86. package/templates/.idea/runConfigurations/CAWS_Evaluate.xml +5 -0
  87. package/templates/.idea/runConfigurations/CAWS_Validate.xml +5 -0
  88. package/templates/.vscode/launch.json +56 -0
  89. package/templates/.vscode/settings.json +93 -0
  90. package/templates/.windsurf/workflows/caws-guided-development.md +92 -0
  91. package/templates/apps/tools/caws/README.md +1 -1
  92. package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
  93. package/templates/apps/tools/caws/provenance.js.backup +73 -0
  94. package/templates/apps/tools/caws/schemas/working-spec.schema.json +21 -3
  95. package/templates/codemod/test.js +93 -1
@@ -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,204 @@
1
+ /**
2
+ * @fileoverview Working Spec Generation Utilities
3
+ * Functions for generating and validating CAWS working specifications
4
+ * @author @darianrosebrook
5
+ */
6
+
7
+ const yaml = require('js-yaml');
8
+ const chalk = require('chalk');
9
+
10
+ // Import validation utilities
11
+ const { validateWorkingSpec } = require('../validation/spec-validation');
12
+
13
+ /**
14
+ * Generate working spec YAML with user input
15
+ * @param {Object} answers - User responses
16
+ * @returns {string} - Generated YAML content
17
+ */
18
+ function generateWorkingSpec(answers) {
19
+ const template = {
20
+ id: answers.projectId,
21
+ title: answers.projectTitle,
22
+ risk_tier: answers.riskTier,
23
+ mode: answers.projectMode,
24
+ change_budget: {
25
+ max_files: answers.maxFiles,
26
+ max_loc: answers.maxLoc,
27
+ },
28
+ blast_radius: {
29
+ modules: answers.blastModules
30
+ .split(',')
31
+ .map((m) => m.trim())
32
+ .filter((m) => m),
33
+ data_migration: answers.dataMigration,
34
+ },
35
+ operational_rollback_slo: answers.rollbackSlo,
36
+ threats: (answers.projectThreats || '')
37
+ .split('\n')
38
+ .map((t) => t.trim())
39
+ .filter((t) => t && !t.startsWith('-') === false), // Allow lines starting with -
40
+ scope: {
41
+ in: (answers.scopeIn || '')
42
+ .split(',')
43
+ .map((s) => s.trim())
44
+ .filter((s) => s),
45
+ out: (answers.scopeOut || '')
46
+ .split(',')
47
+ .map((s) => s.trim())
48
+ .filter((s) => s),
49
+ },
50
+ invariants: (answers.projectInvariants || '')
51
+ .split('\n')
52
+ .map((i) => i.trim())
53
+ .filter((i) => i),
54
+ acceptance: answers.acceptanceCriteria
55
+ .split('\n')
56
+ .filter((a) => a.trim())
57
+ .map((criteria, index) => {
58
+ const id = `A${index + 1}`;
59
+ const upperCriteria = criteria.toUpperCase();
60
+
61
+ // Try different variations of the format
62
+ let given = '';
63
+ let when = '';
64
+ let then = '';
65
+
66
+ if (
67
+ upperCriteria.includes('GIVEN') &&
68
+ upperCriteria.includes('WHEN') &&
69
+ upperCriteria.includes('THEN')
70
+ ) {
71
+ given = criteria.split(/WHEN/i)[0]?.replace(/GIVEN/i, '').trim() || '';
72
+ const whenThen = criteria.split(/WHEN/i)[1];
73
+ when = whenThen?.split(/THEN/i)[0]?.trim() || '';
74
+ then = whenThen?.split(/THEN/i)[1]?.trim() || '';
75
+ } else {
76
+ // Fallback: just split by lines and create simple criteria
77
+ given = 'Current system state';
78
+ when = criteria.replace(/^(GIVEN|WHEN|THEN)/i, '').trim();
79
+ then = 'Expected behavior occurs';
80
+ }
81
+
82
+ return {
83
+ id,
84
+ given: given || 'Current system state',
85
+ when: when || criteria,
86
+ then: then || 'Expected behavior occurs',
87
+ };
88
+ }),
89
+ non_functional: {
90
+ a11y: answers.a11yRequirements
91
+ .split(',')
92
+ .map((a) => a.trim())
93
+ .filter((a) => a),
94
+ perf: { api_p95_ms: answers.perfBudget },
95
+ security: answers.securityRequirements
96
+ .split(',')
97
+ .map((s) => s.trim())
98
+ .filter((s) => s),
99
+ },
100
+ contracts: [
101
+ {
102
+ type: answers.contractType,
103
+ path: answers.contractPath,
104
+ },
105
+ ],
106
+ observability: {
107
+ logs: answers.observabilityLogs
108
+ .split(',')
109
+ .map((l) => l.trim())
110
+ .filter((l) => l),
111
+ metrics: answers.observabilityMetrics
112
+ .split(',')
113
+ .map((m) => m.trim())
114
+ .filter((m) => m),
115
+ traces: answers.observabilityTraces
116
+ .split(',')
117
+ .map((t) => t.trim())
118
+ .filter((t) => t),
119
+ },
120
+ migrations: (answers.migrationPlan || '')
121
+ .split('\n')
122
+ .map((m) => m.trim())
123
+ .filter((m) => m),
124
+ rollback: (answers.rollbackPlan || '')
125
+ .split('\n')
126
+ .map((r) => r.trim())
127
+ .filter((r) => r),
128
+ human_override: answers.needsOverride
129
+ ? {
130
+ enabled: true,
131
+ approver: answers.overrideApprover,
132
+ rationale: answers.overrideRationale,
133
+ waived_gates: answers.waivedGates,
134
+ approved_at: new Date().toISOString(),
135
+ expires_at: new Date(
136
+ Date.now() + answers.overrideExpiresDays * 24 * 60 * 60 * 1000
137
+ ).toISOString(),
138
+ }
139
+ : undefined,
140
+ experimental_mode: answers.isExperimental
141
+ ? {
142
+ enabled: true,
143
+ rationale: answers.experimentalRationale,
144
+ expires_at: new Date(
145
+ Date.now() + answers.experimentalExpiresDays * 24 * 60 * 60 * 1000
146
+ ).toISOString(),
147
+ sandbox_location: answers.experimentalSandbox,
148
+ }
149
+ : undefined,
150
+ ai_assessment: {
151
+ confidence_level: answers.aiConfidence,
152
+ uncertainty_areas: answers.uncertaintyAreas
153
+ .split(',')
154
+ .map((a) => a.trim())
155
+ .filter((a) => a),
156
+ complexity_factors: answers.complexityFactors
157
+ .split(',')
158
+ .map((f) => f.trim())
159
+ .filter((f) => f),
160
+ risk_factors: [], // Could be populated by AI analysis
161
+ },
162
+ };
163
+
164
+ return yaml.dump(template, { indent: 2 });
165
+ }
166
+
167
+ /**
168
+ * Validate generated working spec against JSON schema
169
+ * @param {string} specContent - YAML spec content
170
+ * @param {Object} answers - User responses for error context
171
+ */
172
+ function validateGeneratedSpec(specContent, _answers) {
173
+ try {
174
+ const spec = yaml.load(specContent);
175
+
176
+ const isValid = validateWorkingSpec(spec);
177
+
178
+ if (!isValid) {
179
+ console.error(chalk.red('❌ Generated working spec failed validation:'));
180
+ validateWorkingSpec.errors.forEach((error) => {
181
+ console.error(` - ${error.instancePath || 'root'}: ${error.message}`);
182
+ });
183
+
184
+ // Provide helpful guidance
185
+ console.log(chalk.blue('\n💡 Validation Tips:'));
186
+ console.log(' - Ensure risk_tier is 1, 2, or 3');
187
+ console.log(' - Check that scope.in is not empty');
188
+ console.log(' - Verify invariants and acceptance criteria are provided');
189
+ console.log(' - For tier 1 and 2, ensure contracts are specified');
190
+
191
+ process.exit(1);
192
+ }
193
+
194
+ console.log(chalk.green('✅ Generated working spec passed validation'));
195
+ } catch (error) {
196
+ console.error(chalk.red('❌ Error validating working spec:'), error.message);
197
+ process.exit(1);
198
+ }
199
+ }
200
+
201
+ module.exports = {
202
+ generateWorkingSpec,
203
+ validateGeneratedSpec,
204
+ };
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { generateWorkingSpec } from "./generators/working-spec";
3
+ import { validateGeneratedSpec } from "./generators/working-spec";
4
+ export { generateWorkingSpec, validateGeneratedSpec };
5
+ //# sourceMappingURL=index-new.d.ts.map
@@ -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 CHANGED
@@ -1,14 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * Generate working spec YAML with user input
4
- * @param {Object} answers - User responses
5
- * @returns {string} - Generated YAML content
6
- */
7
- export function generateWorkingSpec(answers: any): string;
8
- /**
9
- * Validate generated working spec against JSON schema
10
- * @param {string} specContent - YAML spec content
11
- * @param {Object} answers - User responses for error context
12
- */
13
- export function validateGeneratedSpec(specContent: string, _answers: any): void;
2
+ import { generateWorkingSpec } from "./generators/working-spec";
3
+ import { validateGeneratedSpec } from "./generators/working-spec";
4
+ export { generateWorkingSpec, validateGeneratedSpec };
14
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAgYA;;;;GAIG;AACH,mDAFa,MAAM,CAqJlB;AAED;;;;GAIG;AACH,mDAHW,MAAM,uBA8BhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}