@paths.design/caws-cli 4.0.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.
Files changed (76) hide show
  1. package/dist/commands/archive.d.ts +50 -0
  2. package/dist/commands/archive.d.ts.map +1 -0
  3. package/dist/commands/archive.js +353 -0
  4. package/dist/commands/iterate.d.ts.map +1 -1
  5. package/dist/commands/iterate.js +12 -13
  6. package/dist/commands/mode.d.ts +24 -0
  7. package/dist/commands/mode.d.ts.map +1 -0
  8. package/dist/commands/mode.js +259 -0
  9. package/dist/commands/plan.d.ts +49 -0
  10. package/dist/commands/plan.d.ts.map +1 -0
  11. package/dist/commands/plan.js +448 -0
  12. package/dist/commands/quality-gates.d.ts +52 -0
  13. package/dist/commands/quality-gates.d.ts.map +1 -0
  14. package/dist/commands/quality-gates.js +490 -0
  15. package/dist/commands/specs.d.ts +71 -0
  16. package/dist/commands/specs.d.ts.map +1 -0
  17. package/dist/commands/specs.js +735 -0
  18. package/dist/commands/status.d.ts +4 -3
  19. package/dist/commands/status.d.ts.map +1 -1
  20. package/dist/commands/status.js +552 -22
  21. package/dist/commands/tutorial.d.ts +55 -0
  22. package/dist/commands/tutorial.d.ts.map +1 -0
  23. package/dist/commands/tutorial.js +481 -0
  24. package/dist/commands/validate.d.ts +10 -3
  25. package/dist/commands/validate.d.ts.map +1 -1
  26. package/dist/commands/validate.js +137 -54
  27. package/dist/config/modes.d.ts +225 -0
  28. package/dist/config/modes.d.ts.map +1 -0
  29. package/dist/config/modes.js +321 -0
  30. package/dist/constants/spec-types.d.ts +41 -0
  31. package/dist/constants/spec-types.d.ts.map +1 -0
  32. package/dist/constants/spec-types.js +42 -0
  33. package/dist/index-new.d.ts +5 -0
  34. package/dist/index-new.d.ts.map +1 -0
  35. package/dist/index-new.js +317 -0
  36. package/dist/index.js +225 -10
  37. package/dist/index.js.backup +4711 -0
  38. package/dist/scaffold/git-hooks.d.ts.map +1 -1
  39. package/dist/scaffold/git-hooks.js +32 -44
  40. package/dist/scaffold/index.d.ts.map +1 -1
  41. package/dist/scaffold/index.js +19 -0
  42. package/dist/utils/quality-gates-errors.js +520 -0
  43. package/dist/utils/quality-gates.d.ts +49 -0
  44. package/dist/utils/quality-gates.d.ts.map +1 -0
  45. package/dist/utils/quality-gates.js +361 -0
  46. package/dist/utils/spec-resolver.d.ts +88 -0
  47. package/dist/utils/spec-resolver.d.ts.map +1 -0
  48. package/dist/utils/spec-resolver.js +602 -0
  49. package/package.json +6 -5
  50. package/templates/.cursor/hooks/caws-scope-guard.sh +64 -8
  51. package/templates/.cursor/hooks/validate-spec.sh +22 -12
  52. package/templates/.cursor/rules/{01-claims-verification.mdc → 00-claims-verification.mdc} +1 -1
  53. package/templates/.cursor/rules/01-working-style.mdc +50 -0
  54. package/templates/.cursor/rules/{02-testing-standards.mdc → 02-quality-gates.mdc} +84 -29
  55. package/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
  56. package/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
  57. package/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
  58. package/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
  59. package/templates/.cursor/rules/07-process-ops.mdc +20 -0
  60. package/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
  61. package/templates/.cursor/rules/09-docstrings.mdc +89 -0
  62. package/templates/.cursor/rules/10-authorship-and-attribution.mdc +15 -0
  63. package/templates/.cursor/rules/11-documentation-quality-standards.mdc +390 -0
  64. package/templates/.cursor/rules/12-scope-management-waivers.mdc +385 -0
  65. package/templates/.cursor/rules/13-implementation-completeness.mdc +516 -0
  66. package/templates/.cursor/rules/14-language-agnostic-standards.mdc +588 -0
  67. package/templates/.cursor/rules/15-sophisticated-todo-detection.mdc +425 -0
  68. package/templates/.cursor/rules/README.md +93 -7
  69. package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
  70. package/templates/apps/tools/caws/provenance.js.backup +73 -0
  71. package/templates/scripts/quality-gates/check-god-objects.js +146 -0
  72. package/templates/scripts/quality-gates/run-quality-gates.js +50 -0
  73. package/templates/scripts/v3/analysis/todo_analyzer.py +1950 -0
  74. package/templates/.cursor/rules/03-infrastructure-standards.mdc +0 -251
  75. package/templates/.cursor/rules/04-documentation-integrity.mdc +0 -291
  76. package/templates/.cursor/rules/05-production-readiness-checklist.mdc +0 -214
@@ -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,22 +119,216 @@ program
113
119
  // Validate command
114
120
  program
115
121
  .command('validate')
116
- .description('Validate CAWS working spec with suggestions')
117
- .argument('[spec-file]', 'Path to working spec file (default: .caws/working-spec.yaml)')
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)
120
128
  .option('--dry-run', 'Preview auto-fixes without applying them', false)
121
129
  .option('--format <format>', 'Output format (text, json)', 'text')
122
130
  .action(validateCommand);
123
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
+
124
200
  // Status command
125
201
  program
126
202
  .command('status')
127
203
  .description('Show project health overview')
128
- .option('-s, --spec <path>', 'Path to working spec file', '.caws/working-spec.yaml')
129
- .option('--json', 'Output in JSON format', false)
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)
130
208
  .action(statusCommand);
131
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
+
132
332
  // Templates command
133
333
  program
134
334
  .command('templates [subcommand]')
@@ -140,6 +340,7 @@ program
140
340
  program
141
341
  .command('diagnose')
142
342
  .description('Run health checks and suggest fixes')
343
+ .option('--spec-id <id>', 'Feature-specific spec ID')
143
344
  .option('--fix', 'Apply automatic fixes', false)
144
345
  .action(diagnoseCommand);
145
346
 
@@ -147,13 +348,15 @@ program
147
348
  program
148
349
  .command('evaluate [spec-file]')
149
350
  .description('Evaluate work against CAWS quality standards')
351
+ .option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
150
352
  .option('-v, --verbose', 'Show detailed error information', false)
151
353
  .action(evaluateCommand);
152
354
 
153
355
  // Iterate command
154
356
  program
155
357
  .command('iterate [spec-file]')
156
- .description('Get iterative development guidance based on current progress')
358
+ .description('Get iterative development guidance')
359
+ .option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
157
360
  .option('--current-state <json>', 'Current implementation state as JSON', '{}')
158
361
  .option('-v, --verbose', 'Show detailed error information', false)
159
362
  .action(iterateCommand);
@@ -202,7 +405,8 @@ waiversCmd
202
405
  // Workflow command group
203
406
  const workflowCmd = program
204
407
  .command('workflow <type>')
205
- .description('Get workflow-specific guidance for development tasks')
408
+ .description('Get workflow-specific guidance')
409
+ .option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
206
410
  .option('--step <number>', 'Current step in workflow', '1')
207
411
  .option('--current-state <json>', 'Current implementation state as JSON', '{}')
208
412
  .option('-v, --verbose', 'Show detailed error information', false)
@@ -212,6 +416,7 @@ const workflowCmd = program
212
416
  program
213
417
  .command('quality-monitor <action>')
214
418
  .description('Monitor code quality impact in real-time')
419
+ .option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
215
420
  .option('--files <files>', 'Files affected (comma-separated)')
216
421
  .option('--context <json>', 'Additional context as JSON', '{}')
217
422
  .option('-v, --verbose', 'Show detailed error information', false)
@@ -236,13 +441,12 @@ program
236
441
  // Test Analysis command
237
442
  program
238
443
  .command('test-analysis <subcommand> [options...]')
239
- .description('Statistical analysis for budget prediction and test optimization')
444
+ .description('Statistical analysis for budget prediction')
445
+ .option('--spec-id <id>', 'Feature-specific spec ID (e.g., user-auth)')
240
446
  .action(testAnalysisCommand);
241
447
 
242
448
  // Provenance command group
243
- const provenanceCmd = program
244
- .command('provenance')
245
- .description('Manage CAWS provenance tracking and audit trails');
449
+ const provenanceCmd = program.command('provenance').description('Manage CAWS provenance tracking');
246
450
 
247
451
  // Subcommands
248
452
  provenanceCmd
@@ -380,6 +584,11 @@ program.exitOverride((err) => {
380
584
  'validate',
381
585
  'scaffold',
382
586
  'status',
587
+ 'archive',
588
+ 'specs',
589
+ 'mode',
590
+ 'tutorial',
591
+ 'plan',
383
592
  'templates',
384
593
  'diagnose',
385
594
  'evaluate',
@@ -475,6 +684,12 @@ if (require.main === module) {
475
684
  'init',
476
685
  'validate',
477
686
  'scaffold',
687
+ 'status',
688
+ 'archive',
689
+ 'specs',
690
+ 'mode',
691
+ 'tutorial',
692
+ 'plan',
478
693
  'provenance',
479
694
  'hooks',
480
695
  'burnup',