@paths.design/caws-cli 3.5.0 → 4.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/dist/budget-derivation.d.ts +41 -2
- package/dist/budget-derivation.d.ts.map +1 -1
- package/dist/budget-derivation.js +417 -30
- package/dist/commands/archive.d.ts +50 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +353 -0
- package/dist/commands/iterate.d.ts.map +1 -1
- package/dist/commands/iterate.js +12 -13
- package/dist/commands/mode.d.ts +24 -0
- package/dist/commands/mode.d.ts.map +1 -0
- package/dist/commands/mode.js +259 -0
- package/dist/commands/plan.d.ts +49 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +448 -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 +490 -0
- package/dist/commands/specs.d.ts +71 -0
- package/dist/commands/specs.d.ts.map +1 -0
- package/dist/commands/specs.js +735 -0
- package/dist/commands/status.d.ts +4 -3
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +552 -22
- package/dist/commands/tutorial.d.ts +55 -0
- package/dist/commands/tutorial.d.ts.map +1 -0
- package/dist/commands/tutorial.js +481 -0
- package/dist/commands/validate.d.ts +10 -2
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +199 -39
- package/dist/config/modes.d.ts +225 -0
- package/dist/config/modes.d.ts.map +1 -0
- package/dist/config/modes.js +321 -0
- package/dist/constants/spec-types.d.ts +41 -0
- package/dist/constants/spec-types.d.ts.map +1 -0
- package/dist/constants/spec-types.js +42 -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.js +227 -10
- package/dist/index.js.backup +4711 -0
- package/dist/policy/PolicyManager.d.ts +104 -0
- package/dist/policy/PolicyManager.d.ts.map +1 -0
- package/dist/policy/PolicyManager.js +399 -0
- package/dist/scaffold/cursor-hooks.d.ts.map +1 -1
- package/dist/scaffold/cursor-hooks.js +15 -0
- package/dist/scaffold/git-hooks.d.ts.map +1 -1
- package/dist/scaffold/git-hooks.js +32 -44
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +19 -0
- package/dist/spec/SpecFileManager.d.ts +146 -0
- package/dist/spec/SpecFileManager.d.ts.map +1 -0
- package/dist/spec/SpecFileManager.js +419 -0
- package/dist/utils/quality-gates-errors.js +520 -0
- package/dist/utils/quality-gates.d.ts +49 -0
- package/dist/utils/quality-gates.d.ts.map +1 -0
- package/dist/utils/quality-gates.js +361 -0
- package/dist/utils/spec-resolver.d.ts +88 -0
- package/dist/utils/spec-resolver.d.ts.map +1 -0
- package/dist/utils/spec-resolver.js +602 -0
- package/dist/validation/spec-validation.d.ts +14 -0
- package/dist/validation/spec-validation.d.ts.map +1 -1
- package/dist/validation/spec-validation.js +225 -13
- package/package.json +6 -5
- package/templates/.cursor/hooks/caws-scope-guard.sh +64 -8
- package/templates/.cursor/hooks/validate-spec.sh +22 -12
- package/templates/.cursor/rules/00-claims-verification.mdc +144 -0
- package/templates/.cursor/rules/01-working-style.mdc +50 -0
- package/templates/.cursor/rules/02-quality-gates.mdc +370 -0
- package/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
- package/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
- package/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
- package/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
- package/templates/.cursor/rules/07-process-ops.mdc +20 -0
- package/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
- package/templates/.cursor/rules/09-docstrings.mdc +89 -0
- package/templates/.cursor/rules/10-authorship-and-attribution.mdc +15 -0
- package/templates/.cursor/rules/11-documentation-quality-standards.mdc +390 -0
- package/templates/.cursor/rules/12-scope-management-waivers.mdc +385 -0
- package/templates/.cursor/rules/13-implementation-completeness.mdc +516 -0
- package/templates/.cursor/rules/14-language-agnostic-standards.mdc +588 -0
- package/templates/.cursor/rules/15-sophisticated-todo-detection.mdc +425 -0
- package/templates/.cursor/rules/README.md +150 -0
- package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
- package/templates/apps/tools/caws/provenance.js.backup +73 -0
- package/templates/scripts/quality-gates/check-god-objects.js +146 -0
- package/templates/scripts/quality-gates/run-quality-gates.js +50 -0
- package/templates/scripts/v3/analysis/todo_analyzer.py +1950 -0
|
@@ -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.js
CHANGED
|
@@ -41,7 +41,13 @@ const { iterateCommand } = require('./commands/iterate');
|
|
|
41
41
|
const { waiversCommand } = require('./commands/waivers');
|
|
42
42
|
const { workflowCommand } = require('./commands/workflow');
|
|
43
43
|
const { qualityMonitorCommand } = require('./commands/quality-monitor');
|
|
44
|
+
const { qualityGatesCommand } = require('./commands/quality-gates');
|
|
44
45
|
const { troubleshootCommand } = require('./commands/troubleshoot');
|
|
46
|
+
const { archiveCommand } = require('./commands/archive');
|
|
47
|
+
const { specsCommand } = require('./commands/specs');
|
|
48
|
+
const { modeCommand } = require('./commands/mode');
|
|
49
|
+
const { tutorialCommand } = require('./commands/tutorial');
|
|
50
|
+
const { planCommand } = require('./commands/plan');
|
|
45
51
|
|
|
46
52
|
// Import scaffold functionality
|
|
47
53
|
const { scaffoldProject, setScaffoldDependencies } = require('./scaffold');
|
|
@@ -113,20 +119,216 @@ program
|
|
|
113
119
|
// Validate command
|
|
114
120
|
program
|
|
115
121
|
.command('validate')
|
|
116
|
-
.description('Validate CAWS
|
|
117
|
-
.argument('[spec-file]', 'Path to
|
|
122
|
+
.description('Validate CAWS spec with suggestions')
|
|
123
|
+
.argument('[spec-file]', 'Path to spec file (optional, uses spec resolution)')
|
|
124
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth, FEAT-001)')
|
|
125
|
+
.option('-i, --interactive', 'Interactive spec selection when multiple specs exist', false)
|
|
118
126
|
.option('-q, --quiet', 'Suppress suggestions and warnings', false)
|
|
119
127
|
.option('--auto-fix', 'Automatically fix safe validation issues', false)
|
|
128
|
+
.option('--dry-run', 'Preview auto-fixes without applying them', false)
|
|
129
|
+
.option('--format <format>', 'Output format (text, json)', 'text')
|
|
120
130
|
.action(validateCommand);
|
|
121
131
|
|
|
132
|
+
// Quality Gates command
|
|
133
|
+
program
|
|
134
|
+
.command('quality-gates')
|
|
135
|
+
.description('Run comprehensive quality gates (naming, duplication, god objects, documentation)')
|
|
136
|
+
.option('--ci', 'CI mode - exit with error code if violations found', false)
|
|
137
|
+
.option('--json', 'Output machine-readable JSON to stdout', false)
|
|
138
|
+
.option(
|
|
139
|
+
'--gates <gates>',
|
|
140
|
+
'Run only specific gates (comma-separated: naming,code_freeze,duplication,god_objects,documentation)',
|
|
141
|
+
''
|
|
142
|
+
)
|
|
143
|
+
.option('--fix', 'Attempt automatic fixes (experimental)', false)
|
|
144
|
+
.option('--help', 'Show detailed help and usage examples', false)
|
|
145
|
+
.action(async (options) => {
|
|
146
|
+
// Handle --help flag
|
|
147
|
+
if (options.help) {
|
|
148
|
+
console.log(`
|
|
149
|
+
CAWS Quality Gates - Enterprise Code Quality Enforcement
|
|
150
|
+
|
|
151
|
+
USAGE:
|
|
152
|
+
caws quality-gates [options]
|
|
153
|
+
|
|
154
|
+
DESCRIPTION:
|
|
155
|
+
Runs comprehensive quality gates to maintain code quality standards.
|
|
156
|
+
Supports selective gate execution, JSON output, and CI/CD integration.
|
|
157
|
+
|
|
158
|
+
OPTIONS:
|
|
159
|
+
--ci CI mode - exit with error code if violations found
|
|
160
|
+
--json Output machine-readable JSON to stdout
|
|
161
|
+
--gates=<gates> Run only specific gates (comma-separated)
|
|
162
|
+
--fix Attempt automatic fixes (experimental)
|
|
163
|
+
--help Show this help message
|
|
164
|
+
|
|
165
|
+
VALID GATES:
|
|
166
|
+
naming Check naming conventions and banned modifiers
|
|
167
|
+
code_freeze Enforce code freeze compliance
|
|
168
|
+
duplication Detect functional duplication
|
|
169
|
+
god_objects Prevent oversized files
|
|
170
|
+
documentation Check documentation quality
|
|
171
|
+
|
|
172
|
+
EXAMPLES:
|
|
173
|
+
# Run all gates in development mode
|
|
174
|
+
caws quality-gates
|
|
175
|
+
|
|
176
|
+
# Run only specific gates
|
|
177
|
+
caws quality-gates --gates=naming,duplication
|
|
178
|
+
|
|
179
|
+
# CI mode with JSON output
|
|
180
|
+
caws quality-gates --ci --json
|
|
181
|
+
|
|
182
|
+
# Show detailed help
|
|
183
|
+
caws quality-gates --help
|
|
184
|
+
|
|
185
|
+
OUTPUT:
|
|
186
|
+
- Console: Human-readable results with enforcement levels
|
|
187
|
+
- JSON: Machine-readable structured data (--json flag)
|
|
188
|
+
- Artifacts: docs-status/quality-gates-report.json
|
|
189
|
+
- GitHub Actions: Automatic step summaries when GITHUB_STEP_SUMMARY is set
|
|
190
|
+
|
|
191
|
+
For more information, see: packages/quality-gates/README.md
|
|
192
|
+
`);
|
|
193
|
+
process.exit(0);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Call the actual quality gates runner
|
|
197
|
+
await qualityGatesCommand(options);
|
|
198
|
+
});
|
|
199
|
+
|
|
122
200
|
// Status command
|
|
123
201
|
program
|
|
124
202
|
.command('status')
|
|
125
203
|
.description('Show project health overview')
|
|
126
|
-
.option('
|
|
127
|
-
.option('--
|
|
204
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
205
|
+
.option('-s, --spec <path>', 'Path to spec file (explicit override)')
|
|
206
|
+
.option('--visual', 'Enhanced visual output with progress bars', false)
|
|
207
|
+
.option('--json', 'Output in JSON format for automation', false)
|
|
128
208
|
.action(statusCommand);
|
|
129
209
|
|
|
210
|
+
// Archive command
|
|
211
|
+
program
|
|
212
|
+
.command('archive <change-id>')
|
|
213
|
+
.description('Archive completed change')
|
|
214
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
215
|
+
.option('-f, --force', 'Force archive even if criteria not met', false)
|
|
216
|
+
.option('--dry-run', 'Preview archive without performing it', false)
|
|
217
|
+
.action(archiveCommand);
|
|
218
|
+
|
|
219
|
+
// Specs command group
|
|
220
|
+
const specsCmd = program.command('specs').description('Manage multiple CAWS spec files');
|
|
221
|
+
|
|
222
|
+
// Specs subcommands
|
|
223
|
+
specsCmd
|
|
224
|
+
.command('list')
|
|
225
|
+
.description('List all available specs')
|
|
226
|
+
.action(() => specsCommand('list', {}));
|
|
227
|
+
|
|
228
|
+
specsCmd
|
|
229
|
+
.command('create <id>')
|
|
230
|
+
.description('Create a new spec (with conflict resolution)')
|
|
231
|
+
.option('-t, --type <type>', 'Spec type (feature, fix, refactor, chore, docs)', 'feature')
|
|
232
|
+
.option('--title <title>', 'Spec title')
|
|
233
|
+
.option('--tier <tier>', 'Risk tier (T1, T2, T3)', 'T3')
|
|
234
|
+
.option('--mode <mode>', 'Development mode', 'development')
|
|
235
|
+
.option('-f, --force', 'Override existing specs without confirmation', false)
|
|
236
|
+
.option('-i, --interactive', 'Ask for confirmation on conflicts', false)
|
|
237
|
+
.action((id, options) => specsCommand('create', { id, ...options }));
|
|
238
|
+
|
|
239
|
+
specsCmd
|
|
240
|
+
.command('show <id>')
|
|
241
|
+
.description('Show detailed spec information')
|
|
242
|
+
.action((id) => specsCommand('show', { id }));
|
|
243
|
+
|
|
244
|
+
specsCmd
|
|
245
|
+
.command('update <id>')
|
|
246
|
+
.description('Update spec properties')
|
|
247
|
+
.option('-s, --status <status>', 'Spec status (draft, active, completed)')
|
|
248
|
+
.option('--title <title>', 'Spec title')
|
|
249
|
+
.option('--description <desc>', 'Spec description')
|
|
250
|
+
.action((id, options) => specsCommand('update', { id, ...options }));
|
|
251
|
+
|
|
252
|
+
specsCmd
|
|
253
|
+
.command('delete <id>')
|
|
254
|
+
.description('Delete a spec')
|
|
255
|
+
.action((id) => specsCommand('delete', { id }));
|
|
256
|
+
|
|
257
|
+
specsCmd
|
|
258
|
+
.command('conflicts')
|
|
259
|
+
.description('Check for scope conflicts between specs')
|
|
260
|
+
.action(() => specsCommand('conflicts', {}));
|
|
261
|
+
|
|
262
|
+
specsCmd
|
|
263
|
+
.command('migrate')
|
|
264
|
+
.description('Migrate from legacy working-spec.yaml to feature-specific specs')
|
|
265
|
+
.option('-i, --interactive', 'Interactive feature selection', false)
|
|
266
|
+
.option('-f, --features <features>', 'Comma-separated list of features to migrate', (value) =>
|
|
267
|
+
value.split(',')
|
|
268
|
+
)
|
|
269
|
+
.action((options) => specsCommand('migrate', options));
|
|
270
|
+
|
|
271
|
+
specsCmd
|
|
272
|
+
.command('types')
|
|
273
|
+
.description('Show available spec types')
|
|
274
|
+
.action(() => specsCommand('types', {}));
|
|
275
|
+
|
|
276
|
+
// Mode command group
|
|
277
|
+
const modeCmd = program.command('mode').description('Manage CAWS complexity tiers');
|
|
278
|
+
|
|
279
|
+
// Mode subcommands
|
|
280
|
+
modeCmd
|
|
281
|
+
.command('current')
|
|
282
|
+
.description('Show current CAWS mode')
|
|
283
|
+
.action(() => modeCommand('current', {}));
|
|
284
|
+
|
|
285
|
+
modeCmd
|
|
286
|
+
.command('set <mode>')
|
|
287
|
+
.description('Set CAWS complexity tier')
|
|
288
|
+
.action((mode) => modeCommand('set', { mode }));
|
|
289
|
+
|
|
290
|
+
modeCmd
|
|
291
|
+
.command('set')
|
|
292
|
+
.description('Set CAWS complexity tier (interactive)')
|
|
293
|
+
.option('-i, --interactive', 'Interactive mode selection', false)
|
|
294
|
+
.option('-m, --mode <mode>', 'Specific mode to set')
|
|
295
|
+
.action((options) => modeCommand('set', options));
|
|
296
|
+
|
|
297
|
+
modeCmd
|
|
298
|
+
.command('compare')
|
|
299
|
+
.description('Compare all available tiers')
|
|
300
|
+
.action(() => modeCommand('compare', {}));
|
|
301
|
+
|
|
302
|
+
modeCmd
|
|
303
|
+
.command('recommend')
|
|
304
|
+
.description('Get tier recommendation for your project')
|
|
305
|
+
.option('--size <size>', 'Project size (small, medium, large)', 'medium')
|
|
306
|
+
.option('--team-size <size>', 'Team size (number)', '1')
|
|
307
|
+
.option('--compliance <required>', 'Compliance requirements (true/false)', 'false')
|
|
308
|
+
.option('--audit <required>', 'Audit requirements (true/false)', 'false')
|
|
309
|
+
.option('--details', 'Show detailed recommendation', false)
|
|
310
|
+
.action((options) => modeCommand('recommend', options));
|
|
311
|
+
|
|
312
|
+
modeCmd
|
|
313
|
+
.command('details <mode>')
|
|
314
|
+
.description('Show detailed information about a specific tier')
|
|
315
|
+
.action((mode) => modeCommand('details', { mode }));
|
|
316
|
+
|
|
317
|
+
// Tutorial command
|
|
318
|
+
program
|
|
319
|
+
.command('tutorial [type]')
|
|
320
|
+
.description('Interactive guided learning for CAWS')
|
|
321
|
+
.action(tutorialCommand);
|
|
322
|
+
|
|
323
|
+
// Plan command
|
|
324
|
+
program
|
|
325
|
+
.command('plan <action>')
|
|
326
|
+
.description('Generate implementation plans')
|
|
327
|
+
.option('--spec-id <id>', 'Spec ID to generate plan for')
|
|
328
|
+
.option('--spec <id>', 'Alias for --spec-id')
|
|
329
|
+
.option('--output <path>', 'Output file path for the plan')
|
|
330
|
+
.action((action, options) => planCommand(action, options));
|
|
331
|
+
|
|
130
332
|
// Templates command
|
|
131
333
|
program
|
|
132
334
|
.command('templates [subcommand]')
|
|
@@ -138,6 +340,7 @@ program
|
|
|
138
340
|
program
|
|
139
341
|
.command('diagnose')
|
|
140
342
|
.description('Run health checks and suggest fixes')
|
|
343
|
+
.option('--spec-id <id>', 'Feature-specific spec ID')
|
|
141
344
|
.option('--fix', 'Apply automatic fixes', false)
|
|
142
345
|
.action(diagnoseCommand);
|
|
143
346
|
|
|
@@ -145,13 +348,15 @@ program
|
|
|
145
348
|
program
|
|
146
349
|
.command('evaluate [spec-file]')
|
|
147
350
|
.description('Evaluate work against CAWS quality standards')
|
|
351
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
148
352
|
.option('-v, --verbose', 'Show detailed error information', false)
|
|
149
353
|
.action(evaluateCommand);
|
|
150
354
|
|
|
151
355
|
// Iterate command
|
|
152
356
|
program
|
|
153
357
|
.command('iterate [spec-file]')
|
|
154
|
-
.description('Get iterative development guidance
|
|
358
|
+
.description('Get iterative development guidance')
|
|
359
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
155
360
|
.option('--current-state <json>', 'Current implementation state as JSON', '{}')
|
|
156
361
|
.option('-v, --verbose', 'Show detailed error information', false)
|
|
157
362
|
.action(iterateCommand);
|
|
@@ -200,7 +405,8 @@ waiversCmd
|
|
|
200
405
|
// Workflow command group
|
|
201
406
|
const workflowCmd = program
|
|
202
407
|
.command('workflow <type>')
|
|
203
|
-
.description('Get workflow-specific guidance
|
|
408
|
+
.description('Get workflow-specific guidance')
|
|
409
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
204
410
|
.option('--step <number>', 'Current step in workflow', '1')
|
|
205
411
|
.option('--current-state <json>', 'Current implementation state as JSON', '{}')
|
|
206
412
|
.option('-v, --verbose', 'Show detailed error information', false)
|
|
@@ -210,6 +416,7 @@ const workflowCmd = program
|
|
|
210
416
|
program
|
|
211
417
|
.command('quality-monitor <action>')
|
|
212
418
|
.description('Monitor code quality impact in real-time')
|
|
419
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
213
420
|
.option('--files <files>', 'Files affected (comma-separated)')
|
|
214
421
|
.option('--context <json>', 'Additional context as JSON', '{}')
|
|
215
422
|
.option('-v, --verbose', 'Show detailed error information', false)
|
|
@@ -234,13 +441,12 @@ program
|
|
|
234
441
|
// Test Analysis command
|
|
235
442
|
program
|
|
236
443
|
.command('test-analysis <subcommand> [options...]')
|
|
237
|
-
.description('Statistical analysis for budget prediction
|
|
444
|
+
.description('Statistical analysis for budget prediction')
|
|
445
|
+
.option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
|
|
238
446
|
.action(testAnalysisCommand);
|
|
239
447
|
|
|
240
448
|
// Provenance command group
|
|
241
|
-
const provenanceCmd = program
|
|
242
|
-
.command('provenance')
|
|
243
|
-
.description('Manage CAWS provenance tracking and audit trails');
|
|
449
|
+
const provenanceCmd = program.command('provenance').description('Manage CAWS provenance tracking');
|
|
244
450
|
|
|
245
451
|
// Subcommands
|
|
246
452
|
provenanceCmd
|
|
@@ -378,6 +584,11 @@ program.exitOverride((err) => {
|
|
|
378
584
|
'validate',
|
|
379
585
|
'scaffold',
|
|
380
586
|
'status',
|
|
587
|
+
'archive',
|
|
588
|
+
'specs',
|
|
589
|
+
'mode',
|
|
590
|
+
'tutorial',
|
|
591
|
+
'plan',
|
|
381
592
|
'templates',
|
|
382
593
|
'diagnose',
|
|
383
594
|
'evaluate',
|
|
@@ -473,6 +684,12 @@ if (require.main === module) {
|
|
|
473
684
|
'init',
|
|
474
685
|
'validate',
|
|
475
686
|
'scaffold',
|
|
687
|
+
'status',
|
|
688
|
+
'archive',
|
|
689
|
+
'specs',
|
|
690
|
+
'mode',
|
|
691
|
+
'tutorial',
|
|
692
|
+
'plan',
|
|
476
693
|
'provenance',
|
|
477
694
|
'hooks',
|
|
478
695
|
'burnup',
|