@paths.design/caws-cli 8.0.1 → 8.2.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 (112) hide show
  1. package/README.md +5 -6
  2. package/dist/commands/archive.d.ts +1 -0
  3. package/dist/commands/archive.d.ts.map +1 -1
  4. package/dist/commands/archive.js +114 -6
  5. package/dist/commands/burnup.d.ts.map +1 -1
  6. package/dist/commands/burnup.js +109 -10
  7. package/dist/commands/diagnose.js +1 -1
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +185 -39
  10. package/dist/commands/mode.d.ts +2 -1
  11. package/dist/commands/mode.d.ts.map +1 -1
  12. package/dist/commands/mode.js +24 -14
  13. package/dist/commands/provenance.d.ts.map +1 -1
  14. package/dist/commands/provenance.js +216 -93
  15. package/dist/commands/quality-gates.d.ts.map +1 -1
  16. package/dist/commands/quality-gates.js +3 -1
  17. package/dist/commands/specs.d.ts.map +1 -1
  18. package/dist/commands/specs.js +184 -6
  19. package/dist/commands/status.d.ts.map +1 -1
  20. package/dist/commands/status.js +134 -10
  21. package/dist/commands/templates.js +2 -2
  22. package/dist/commands/worktree.d.ts +7 -0
  23. package/dist/commands/worktree.d.ts.map +1 -0
  24. package/dist/commands/worktree.js +136 -0
  25. package/dist/config/lite-scope.d.ts +33 -0
  26. package/dist/config/lite-scope.d.ts.map +1 -0
  27. package/dist/config/lite-scope.js +158 -0
  28. package/dist/config/modes.d.ts +90 -51
  29. package/dist/config/modes.d.ts.map +1 -1
  30. package/dist/config/modes.js +26 -0
  31. package/dist/error-handler.d.ts +3 -16
  32. package/dist/error-handler.d.ts.map +1 -1
  33. package/dist/error-handler.js +6 -98
  34. package/dist/generators/jest-config-generator.d.ts +32 -0
  35. package/dist/generators/jest-config-generator.d.ts.map +1 -0
  36. package/dist/generators/jest-config-generator.js +242 -0
  37. package/dist/index.js +40 -7
  38. package/dist/minimal-cli.js +3 -1
  39. package/dist/scaffold/claude-hooks.d.ts +28 -0
  40. package/dist/scaffold/claude-hooks.d.ts.map +1 -0
  41. package/dist/scaffold/claude-hooks.js +344 -0
  42. package/dist/scaffold/index.d.ts +2 -0
  43. package/dist/scaffold/index.d.ts.map +1 -1
  44. package/dist/scaffold/index.js +96 -76
  45. package/dist/templates/.caws/schemas/scope.schema.json +52 -0
  46. package/dist/templates/.caws/schemas/working-spec.schema.json +1 -1
  47. package/dist/templates/.caws/schemas/worktrees.schema.json +36 -0
  48. package/dist/templates/.claude/README.md +190 -0
  49. package/dist/templates/.claude/hooks/audit.sh +96 -0
  50. package/dist/templates/.claude/hooks/block-dangerous.sh +123 -0
  51. package/dist/templates/.claude/hooks/lite-sprawl-check.sh +117 -0
  52. package/dist/templates/.claude/hooks/naming-check.sh +97 -0
  53. package/dist/templates/.claude/hooks/quality-check.sh +68 -0
  54. package/dist/templates/.claude/hooks/scan-secrets.sh +85 -0
  55. package/dist/templates/.claude/hooks/scope-guard.sh +192 -0
  56. package/dist/templates/.claude/hooks/simplification-guard.sh +92 -0
  57. package/dist/templates/.claude/hooks/validate-spec.sh +76 -0
  58. package/dist/templates/.claude/settings.json +95 -0
  59. package/dist/templates/.cursor/README.md +0 -3
  60. package/dist/templates/.github/copilot-instructions.md +82 -0
  61. package/dist/templates/.junie/guidelines.md +73 -0
  62. package/dist/templates/.vscode/launch.json +0 -27
  63. package/dist/templates/.windsurf/rules/caws-quality-standards.md +54 -0
  64. package/dist/templates/CLAUDE.md +101 -0
  65. package/dist/templates/agents.md +73 -1016
  66. package/dist/templates/docs/README.md +5 -5
  67. package/dist/test-analysis.d.ts +50 -1
  68. package/dist/test-analysis.d.ts.map +1 -1
  69. package/dist/test-analysis.js +203 -10
  70. package/dist/utils/error-categories.d.ts +52 -0
  71. package/dist/utils/error-categories.d.ts.map +1 -0
  72. package/dist/utils/error-categories.js +210 -0
  73. package/dist/utils/gitignore-updater.d.ts +1 -1
  74. package/dist/utils/gitignore-updater.d.ts.map +1 -1
  75. package/dist/utils/gitignore-updater.js +4 -0
  76. package/dist/utils/ide-detection.js +133 -0
  77. package/dist/utils/quality-gates-utils.d.ts +49 -0
  78. package/dist/utils/quality-gates-utils.d.ts.map +1 -0
  79. package/dist/utils/quality-gates-utils.js +402 -0
  80. package/dist/utils/typescript-detector.d.ts +8 -5
  81. package/dist/utils/typescript-detector.d.ts.map +1 -1
  82. package/dist/utils/typescript-detector.js +36 -90
  83. package/dist/validation/spec-validation.d.ts.map +1 -1
  84. package/dist/validation/spec-validation.js +59 -6
  85. package/dist/worktree/worktree-manager.d.ts +54 -0
  86. package/dist/worktree/worktree-manager.d.ts.map +1 -0
  87. package/dist/worktree/worktree-manager.js +378 -0
  88. package/package.json +9 -3
  89. package/templates/.caws/schemas/scope.schema.json +52 -0
  90. package/templates/.caws/schemas/working-spec.schema.json +1 -1
  91. package/templates/.caws/schemas/worktrees.schema.json +36 -0
  92. package/templates/.claude/README.md +190 -0
  93. package/templates/.claude/hooks/audit.sh +96 -0
  94. package/templates/.claude/hooks/block-dangerous.sh +123 -0
  95. package/templates/.claude/hooks/lite-sprawl-check.sh +117 -0
  96. package/templates/.claude/hooks/naming-check.sh +97 -0
  97. package/templates/.claude/hooks/quality-check.sh +68 -0
  98. package/templates/.claude/hooks/scan-secrets.sh +85 -0
  99. package/templates/.claude/hooks/scope-guard.sh +192 -0
  100. package/templates/.claude/hooks/simplification-guard.sh +92 -0
  101. package/templates/.claude/hooks/validate-spec.sh +76 -0
  102. package/templates/.claude/settings.json +95 -0
  103. package/templates/.cursor/README.md +0 -3
  104. package/templates/.github/copilot-instructions.md +82 -0
  105. package/templates/.junie/guidelines.md +73 -0
  106. package/templates/.vscode/launch.json +0 -27
  107. package/templates/.windsurf/rules/caws-quality-standards.md +54 -0
  108. package/templates/AGENTS.md +104 -0
  109. package/templates/CLAUDE.md +101 -0
  110. package/templates/docs/README.md +5 -5
  111. package/templates/.github/copilot/instructions.md +0 -311
  112. package/templates/agents.md +0 -1047
@@ -0,0 +1,242 @@
1
+ /**
2
+ * @fileoverview Jest Configuration Generator
3
+ * Generates Jest configuration for TypeScript projects
4
+ * @author @darianrosebrook
5
+ */
6
+
7
+ const fs = require('fs-extra');
8
+ const path = require('path');
9
+ const chalk = require('chalk');
10
+
11
+ /**
12
+ * Generate Jest configuration for TypeScript project
13
+ * @param {Object} options - Configuration options
14
+ * @returns {string} Jest configuration content
15
+ */
16
+ function generateJestConfig(options = {}) {
17
+ const {
18
+ preset = 'ts-jest',
19
+ testEnvironment = 'node',
20
+ rootDir = '.',
21
+ testMatch = ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
22
+ moduleFileExtensions = ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
23
+ collectCoverageFrom = ['src/**/*.ts', '!src/**/*.d.ts', '!src/**/*.test.ts'],
24
+ coverageThreshold = {
25
+ global: {
26
+ branches: 80,
27
+ functions: 80,
28
+ lines: 80,
29
+ statements: 80,
30
+ },
31
+ },
32
+ } = options;
33
+
34
+ const config = {
35
+ preset,
36
+ testEnvironment,
37
+ rootDir,
38
+ testMatch,
39
+ moduleFileExtensions,
40
+ collectCoverageFrom,
41
+ coverageThreshold,
42
+ transform: {
43
+ '^.+\\.tsx?$': [
44
+ 'ts-jest',
45
+ {
46
+ tsconfig: 'tsconfig.json',
47
+ },
48
+ ],
49
+ },
50
+ moduleNameMapper: {
51
+ '^@/(.*)$': '<rootDir>/src/$1',
52
+ },
53
+ };
54
+
55
+ return `module.exports = ${JSON.stringify(config, null, 2)};\n`;
56
+ }
57
+
58
+ /**
59
+ * Generate test setup file for TypeScript
60
+ * @returns {string} Setup file content
61
+ */
62
+ function generateTestSetup() {
63
+ return `/**
64
+ * Jest setup file for TypeScript tests
65
+ * @author @darianrosebrook
66
+ */
67
+
68
+ // Add custom matchers or global test setup here
69
+ beforeAll(() => {
70
+ // Global setup
71
+ });
72
+
73
+ afterAll(() => {
74
+ // Global teardown
75
+ });
76
+ `;
77
+ }
78
+
79
+ /**
80
+ * Install Jest and TypeScript dependencies
81
+ * @param {string} projectDir - Project directory
82
+ * @param {Object} packageJson - Existing package.json
83
+ * @returns {Promise<Object>} Installation result
84
+ */
85
+ async function installJestDependencies(projectDir, packageJson) {
86
+ const dependencies = ['jest', '@types/jest', 'ts-jest'];
87
+
88
+ // Check which dependencies are already installed
89
+ const allDeps = {
90
+ ...packageJson.dependencies,
91
+ ...packageJson.devDependencies,
92
+ };
93
+
94
+ const toInstall = dependencies.filter((dep) => !(dep in allDeps));
95
+
96
+ if (toInstall.length === 0) {
97
+ return {
98
+ installed: false,
99
+ message: 'All Jest dependencies already installed',
100
+ dependencies: [],
101
+ };
102
+ }
103
+
104
+ return {
105
+ installed: false,
106
+ needsInstall: true,
107
+ dependencies: toInstall,
108
+ installCommand: `npm install --save-dev ${toInstall.join(' ')}`,
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Configure Jest for TypeScript project
114
+ * @param {string} projectDir - Project directory path
115
+ * @param {Object} options - Configuration options
116
+ * @returns {Promise<Object>} Configuration result
117
+ */
118
+ async function configureJestForTypeScript(projectDir = process.cwd(), options = {}) {
119
+ const { force = false, quiet = false } = options;
120
+
121
+ // Check if Jest config already exists
122
+ const jestConfigPath = path.join(projectDir, 'jest.config.js');
123
+ if (fs.existsSync(jestConfigPath) && !force) {
124
+ return {
125
+ configured: false,
126
+ skipped: true,
127
+ message: 'Jest configuration already exists',
128
+ path: jestConfigPath,
129
+ };
130
+ }
131
+
132
+ // Generate Jest config
133
+ const jestConfig = generateJestConfig();
134
+ await fs.writeFile(jestConfigPath, jestConfig);
135
+
136
+ if (!quiet) {
137
+ console.log(chalk.green('✅ Created jest.config.js'));
138
+ }
139
+
140
+ // Generate test setup file
141
+ const setupPath = path.join(projectDir, 'tests', 'setup.ts');
142
+ await fs.ensureDir(path.join(projectDir, 'tests'));
143
+ await fs.writeFile(setupPath, generateTestSetup());
144
+
145
+ if (!quiet) {
146
+ console.log(chalk.green('✅ Created tests/setup.ts'));
147
+ }
148
+
149
+ // Update package.json with test script if needed
150
+ const packageJsonPath = path.join(projectDir, 'package.json');
151
+ if (fs.existsSync(packageJsonPath)) {
152
+ const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
153
+
154
+ if (!packageJson.scripts) {
155
+ packageJson.scripts = {};
156
+ }
157
+
158
+ if (!packageJson.scripts.test) {
159
+ packageJson.scripts.test = 'jest';
160
+ packageJson.scripts['test:coverage'] = 'jest --coverage';
161
+ packageJson.scripts['test:watch'] = 'jest --watch';
162
+
163
+ await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
164
+
165
+ if (!quiet) {
166
+ console.log(chalk.green('✅ Added test scripts to package.json'));
167
+ }
168
+ }
169
+ }
170
+
171
+ return {
172
+ configured: true,
173
+ files: [jestConfigPath, setupPath],
174
+ nextSteps: [
175
+ 'Install dependencies: npm install --save-dev jest @types/jest ts-jest',
176
+ 'Run tests: npm test',
177
+ 'Run with coverage: npm run test:coverage',
178
+ ],
179
+ };
180
+ }
181
+
182
+ /**
183
+ * Get Jest configuration recommendations
184
+ * @param {string} projectDir - Project directory path
185
+ * @returns {Object} Recommendations
186
+ */
187
+ function getJestRecommendations(projectDir = process.cwd()) {
188
+ const recommendations = [];
189
+ const hasJestConfig = fs.existsSync(path.join(projectDir, 'jest.config.js'));
190
+ const packageJsonPath = path.join(projectDir, 'package.json');
191
+
192
+ if (fs.existsSync(packageJsonPath)) {
193
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
194
+ const allDeps = {
195
+ ...packageJson.dependencies,
196
+ ...packageJson.devDependencies,
197
+ };
198
+
199
+ if (!hasJestConfig && !('jest' in allDeps)) {
200
+ recommendations.push({
201
+ type: 'missing_framework',
202
+ severity: 'high',
203
+ message: 'No testing framework detected',
204
+ fix: 'Install Jest: npm install --save-dev jest @types/jest ts-jest',
205
+ autoFixable: false,
206
+ });
207
+ }
208
+
209
+ if ('typescript' in allDeps && 'jest' in allDeps && !('ts-jest' in allDeps)) {
210
+ recommendations.push({
211
+ type: 'missing_ts_jest',
212
+ severity: 'high',
213
+ message: 'TypeScript project with Jest but missing ts-jest',
214
+ fix: 'Install ts-jest: npm install --save-dev ts-jest',
215
+ autoFixable: false,
216
+ });
217
+ }
218
+
219
+ if (!hasJestConfig && 'jest' in allDeps) {
220
+ recommendations.push({
221
+ type: 'missing_config',
222
+ severity: 'medium',
223
+ message: 'Jest installed but not configured',
224
+ fix: 'Run: caws scaffold to generate Jest configuration',
225
+ autoFixable: true,
226
+ });
227
+ }
228
+ }
229
+
230
+ return {
231
+ hasIssues: recommendations.length > 0,
232
+ recommendations,
233
+ };
234
+ }
235
+
236
+ module.exports = {
237
+ configureJestForTypeScript,
238
+ generateJestConfig,
239
+ generateTestSetup,
240
+ installJestDependencies,
241
+ getJestRecommendations,
242
+ };
package/dist/index.js CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * @fileoverview CAWS CLI - Scaffolding tool for Coding Agent Workflow System
5
- * Provides commands to initialize new projects and scaffold existing ones with CAWS
5
+ * Provides commands to initialize new projects and scaffold existing ones with CAWS.
6
+ * Includes spec management, quality gates, and AI-assisted development workflows.
6
7
  * @author @darianrosebrook
7
8
  */
8
9
 
@@ -48,6 +49,7 @@ const { specsCommand } = require('./commands/specs');
48
49
  const { modeCommand } = require('./commands/mode');
49
50
  const { tutorialCommand } = require('./commands/tutorial');
50
51
  const { planCommand } = require('./commands/plan');
52
+ const { worktreeCommand } = require('./commands/worktree');
51
53
 
52
54
  // Import scaffold functionality
53
55
  const { scaffoldProject, setScaffoldDependencies } = require('./scaffold');
@@ -104,6 +106,8 @@ program
104
106
  .option('-i, --interactive', 'Run interactive setup wizard', true)
105
107
  .option('--non-interactive', 'Skip interactive prompts (use defaults)', false)
106
108
  .option('--template <template>', 'Use specific project template')
109
+ .option('--mode <mode>', 'CAWS mode (lite, simple, standard, enterprise)')
110
+ .option('--ide <ides>', 'IDE integrations to install (comma-separated: cursor,claude,vscode,intellij,windsurf,copilot,all,none)')
107
111
  .action(initProject);
108
112
 
109
113
  // Scaffold command
@@ -115,6 +119,7 @@ program
115
119
  .option('--with-codemods', 'Include codemod scripts', false)
116
120
  .option('--with-oidc', 'Include OIDC trusted publisher setup', false)
117
121
  .option('--with-quality-gates', 'Install quality gates package and scripts', false)
122
+ .option('--ide <ides>', 'IDE integrations to install (comma-separated: cursor,claude,vscode,intellij,windsurf,copilot,all,none)')
118
123
  .action(scaffoldProject);
119
124
 
120
125
  // Validate command
@@ -342,6 +347,37 @@ program
342
347
  .option('--output <path>', 'Output file path for the plan')
343
348
  .action((action, options) => planCommand(action, options));
344
349
 
350
+ // Worktree command group
351
+ const worktreeCmd = program
352
+ .command('worktree')
353
+ .description('Manage git worktrees for agent scope isolation');
354
+
355
+ worktreeCmd
356
+ .command('create <name>')
357
+ .description('Create a new isolated worktree')
358
+ .option('--scope <patterns>', 'Sparse checkout patterns (comma-separated, e.g., "src/auth/**")')
359
+ .option('--base-branch <branch>', 'Base branch to create from')
360
+ .option('--spec-id <id>', 'Associated spec ID')
361
+ .action((name, options) => worktreeCommand('create', { name, ...options }));
362
+
363
+ worktreeCmd
364
+ .command('list')
365
+ .description('List all managed worktrees')
366
+ .action(() => worktreeCommand('list'));
367
+
368
+ worktreeCmd
369
+ .command('destroy <name>')
370
+ .description('Destroy a worktree')
371
+ .option('--delete-branch', 'Also delete the associated branch', false)
372
+ .option('--force', 'Force removal even if worktree is dirty', false)
373
+ .action((name, options) => worktreeCommand('destroy', { name, ...options }));
374
+
375
+ worktreeCmd
376
+ .command('prune')
377
+ .description('Clean up stale worktree entries')
378
+ .option('--max-age <days>', 'Remove entries older than N days', '30')
379
+ .action((options) => worktreeCommand('prune', options));
380
+
345
381
  // Templates command
346
382
  program
347
383
  .command('templates [subcommand]')
@@ -435,12 +471,8 @@ program
435
471
  .option('-v, --verbose', 'Show detailed error information', false)
436
472
  .action(qualityMonitorCommand);
437
473
 
438
- // Troubleshoot command - temporarily disabled due to registration issue
439
- // program
440
- // .command('troubleshoot [guide]')
441
- // .description('Display troubleshooting guides for common CAWS issues')
442
- // .option('-l, --list', 'List all available troubleshooting guides', false)
443
- // .action(troubleshootCommand);
474
+ // Troubleshoot command available via: caws diagnose --troubleshoot <guide>
475
+ // The standalone command was consolidated into the diagnose command.
444
476
 
445
477
  // Tool command
446
478
  program
@@ -614,6 +646,7 @@ program.exitOverride((err) => {
614
646
  'hooks',
615
647
  'burnup',
616
648
  'tool',
649
+ 'worktree',
617
650
  ];
618
651
  const similar = findSimilarCommand(commandName, validCommands);
619
652
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * @fileoverview Minimal CAWS CLI to test Chalk functionality
4
+ * @fileoverview Minimal CAWS CLI for testing and development
5
+ * Provides a lightweight CLI structure with version and help commands
6
+ * for quick verification of CLI functionality.
5
7
  * @author @darianrosebrook
6
8
  */
7
9
 
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Scaffold Claude Code hooks for a CAWS project
3
+ * Creates .claude/settings.json with hooks and .claude/hooks/ directory with scripts
4
+ *
5
+ * @param {string} projectDir - Project directory path
6
+ * @param {string[]} levels - Hook levels to enable: 'safety', 'quality', 'scope', 'audit'
7
+ */
8
+ export function scaffoldClaudeHooks(projectDir: string, levels?: string[]): Promise<void>;
9
+ /**
10
+ * Generate Claude Code settings with hooks configuration
11
+ * @param {string[]} levels - Enabled hook levels
12
+ * @param {Set<string>} enabledHooks - Set of enabled hook script names
13
+ * @returns {Object} Settings object for settings.json
14
+ */
15
+ export function generateClaudeSettings(levels: string[], _enabledHooks: any): any;
16
+ /**
17
+ * Check if Claude Code hooks are already configured
18
+ * @param {string} projectDir - Project directory
19
+ * @returns {boolean} True if hooks are configured
20
+ */
21
+ export function hasClaudeHooks(projectDir: string): boolean;
22
+ /**
23
+ * List configured Claude Code hooks
24
+ * @param {string} projectDir - Project directory
25
+ * @returns {Object} Hook configuration or null
26
+ */
27
+ export function getClaudeHooksConfig(projectDir: string): any;
28
+ //# sourceMappingURL=claude-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-hooks.d.ts","sourceRoot":"","sources":["../../src/scaffold/claude-hooks.js"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,gDAHW,MAAM,WACN,MAAM,EAAE,iBA6HlB;AAED;;;;;GAKG;AACH,+CAJW,MAAM,EAAE,2BAuJlB;AAED;;;;GAIG;AACH,2CAHW,MAAM,GACJ,OAAO,CAcnB;AAED;;;;GAIG;AACH,iDAHW,MAAM,OAehB"}