@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.
- package/README.md +295 -150
- package/dist/budget-derivation.d.ts +35 -0
- package/dist/budget-derivation.d.ts.map +1 -0
- package/dist/budget-derivation.js +204 -0
- package/dist/cicd-optimizer.d.ts +142 -0
- package/dist/cicd-optimizer.d.ts.map +1 -0
- package/dist/cicd-optimizer.js +504 -0
- package/dist/commands/burnup.d.ts +6 -0
- package/dist/commands/burnup.d.ts.map +1 -0
- package/dist/commands/burnup.js +90 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +514 -0
- package/dist/commands/provenance.d.ts +22 -0
- package/dist/commands/provenance.d.ts.map +1 -0
- package/dist/commands/provenance.js +594 -0
- package/dist/commands/tool.d.ts +13 -0
- package/dist/commands/tool.d.ts.map +1 -0
- package/dist/commands/tool.js +138 -0
- package/dist/commands/validate.d.ts +7 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +80 -0
- package/dist/config/index.d.ts +29 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +132 -0
- package/dist/error-handler.d.ts +50 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +253 -0
- package/dist/generators/working-spec.d.ts +13 -0
- package/dist/generators/working-spec.d.ts.map +1 -0
- package/dist/generators/working-spec.js +204 -0
- package/dist/index-new.d.ts +5 -0
- package/dist/index-new.d.ts.map +1 -0
- package/dist/index-new.js +317 -0
- package/dist/index.d.ts +3 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -1659
- package/dist/index.js.backup +4711 -0
- package/dist/scaffold/cursor-hooks.d.ts +7 -0
- package/dist/scaffold/cursor-hooks.d.ts.map +1 -0
- package/dist/scaffold/cursor-hooks.js +152 -0
- package/dist/scaffold/index.d.ts +20 -0
- package/dist/scaffold/index.d.ts.map +1 -0
- package/dist/scaffold/index.js +486 -0
- package/dist/test-analysis.d.ts +182 -0
- package/dist/test-analysis.d.ts.map +1 -0
- package/dist/test-analysis.js +580 -0
- package/dist/tool-interface.d.ts +236 -0
- package/dist/tool-interface.d.ts.map +1 -0
- package/dist/tool-interface.js +314 -0
- package/dist/tool-loader.d.ts +77 -0
- package/dist/tool-loader.d.ts.map +1 -0
- package/dist/tool-loader.js +298 -0
- package/dist/tool-validator.d.ts +72 -0
- package/dist/tool-validator.d.ts.map +1 -0
- package/dist/tool-validator.js +387 -0
- package/dist/utils/detection.d.ts +7 -0
- package/dist/utils/detection.d.ts.map +1 -0
- package/dist/utils/detection.js +174 -0
- package/dist/utils/finalization.d.ts +17 -0
- package/dist/utils/finalization.d.ts.map +1 -0
- package/dist/utils/finalization.js +229 -0
- package/dist/utils/project-analysis.d.ts +14 -0
- package/dist/utils/project-analysis.d.ts.map +1 -0
- package/dist/utils/project-analysis.js +105 -0
- package/dist/validation/spec-validation.d.ts +29 -0
- package/dist/validation/spec-validation.d.ts.map +1 -0
- package/dist/validation/spec-validation.js +376 -0
- package/dist/waivers-manager.d.ts +167 -0
- package/dist/waivers-manager.d.ts.map +1 -0
- package/dist/waivers-manager.js +549 -0
- package/package.json +10 -12
- package/templates/.cursor/README.md +311 -0
- package/templates/.cursor/hooks/audit.sh +55 -0
- package/templates/.cursor/hooks/block-dangerous.sh +77 -0
- package/templates/.cursor/hooks/caws-quality-check.sh +52 -0
- package/templates/.cursor/hooks/caws-scope-guard.sh +74 -0
- package/templates/.cursor/hooks/caws-tool-validation.sh +121 -0
- package/templates/.cursor/hooks/format.sh +38 -0
- package/templates/.cursor/hooks/naming-check.sh +64 -0
- package/templates/.cursor/hooks/scan-secrets.sh +46 -0
- package/templates/.cursor/hooks/scope-guard.sh +52 -0
- package/templates/.cursor/hooks/validate-spec.sh +38 -0
- package/templates/.cursor/hooks.json +59 -0
- package/templates/.github/copilot/instructions.md +311 -0
- package/templates/.idea/runConfigurations/CAWS_Evaluate.xml +5 -0
- package/templates/.idea/runConfigurations/CAWS_Validate.xml +5 -0
- package/templates/.vscode/launch.json +56 -0
- package/templates/.vscode/settings.json +93 -0
- package/templates/.windsurf/workflows/caws-guided-development.md +92 -0
- package/templates/apps/tools/caws/README.md +1 -1
- package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
- package/templates/apps/tools/caws/provenance.js.backup +73 -0
- package/templates/apps/tools/caws/schemas/working-spec.schema.json +21 -3
- package/templates/codemod/test.js +93 -1
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CAWS Init Command Handler
|
|
3
|
+
* Handles project initialization with CAWS setup
|
|
4
|
+
* @author @darianrosebrook
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs-extra');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const inquirer = require('inquirer');
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
|
|
12
|
+
// Import shared utilities
|
|
13
|
+
const { detectCAWSSetup } = require('../utils/detection');
|
|
14
|
+
const { detectProjectType } = require('../utils/project-analysis');
|
|
15
|
+
const { shouldInitInCurrentDirectory } = require('../utils/project-analysis');
|
|
16
|
+
const { generateWorkingSpec } = require('../generators/working-spec');
|
|
17
|
+
const { finalizeProject } = require('../utils/finalization');
|
|
18
|
+
const { scaffoldCursorHooks } = require('../scaffold/cursor-hooks');
|
|
19
|
+
const { scaffoldIDEIntegrations } = require('../scaffold/index');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Initialize a new project with CAWS
|
|
23
|
+
*/
|
|
24
|
+
async function initProject(projectName, options) {
|
|
25
|
+
const currentDir = process.cwd();
|
|
26
|
+
const isCurrentDirInit = shouldInitInCurrentDirectory(projectName, currentDir);
|
|
27
|
+
|
|
28
|
+
if (!isCurrentDirInit && projectName !== '.') {
|
|
29
|
+
console.log(chalk.cyan(`š Initializing new CAWS project: ${projectName}`));
|
|
30
|
+
console.log(chalk.gray(` (Creating subdirectory: ${projectName}/)`));
|
|
31
|
+
} else {
|
|
32
|
+
console.log(
|
|
33
|
+
chalk.cyan(`š Initializing CAWS in current project: ${path.basename(currentDir)}`)
|
|
34
|
+
);
|
|
35
|
+
console.log(chalk.gray(` (Adding CAWS files to existing project)`));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let answers; // Will be set either interactively or with defaults
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Validate project name
|
|
42
|
+
if (!projectName || projectName.trim() === '') {
|
|
43
|
+
console.error(chalk.red('ā Project name is required'));
|
|
44
|
+
console.error(chalk.blue('š” Usage: caws init <project-name>'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Special case: '.' means current directory, don't sanitize
|
|
49
|
+
if (projectName !== '.') {
|
|
50
|
+
// Sanitize project name
|
|
51
|
+
const sanitizedName = projectName.replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();
|
|
52
|
+
if (sanitizedName !== projectName) {
|
|
53
|
+
console.warn(chalk.yellow(`ā ļø Project name sanitized to: ${sanitizedName}`));
|
|
54
|
+
projectName = sanitizedName;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Validate project name length
|
|
59
|
+
if (projectName.length > 50) {
|
|
60
|
+
console.error(chalk.red('ā Project name is too long (max 50 characters)'));
|
|
61
|
+
console.error(chalk.blue('š” Usage: caws init <project-name>'));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Validate project name format
|
|
66
|
+
if (projectName.length === 0) {
|
|
67
|
+
console.error(chalk.red('ā Project name cannot be empty'));
|
|
68
|
+
console.error(chalk.blue('š” Usage: caws init <project-name>'));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check for invalid characters that should cause immediate failure
|
|
73
|
+
if (projectName.includes('/') || projectName.includes('\\') || projectName.includes('..')) {
|
|
74
|
+
console.error(chalk.red('ā Project name contains invalid characters'));
|
|
75
|
+
console.error(chalk.blue('š” Usage: caws init <project-name>'));
|
|
76
|
+
console.error(chalk.blue('š” Project name should not contain: / \\ ..'));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Determine if initializing in current directory
|
|
81
|
+
const initInCurrentDir = projectName === '.';
|
|
82
|
+
const targetDir = initInCurrentDir ? process.cwd() : path.resolve(process.cwd(), projectName);
|
|
83
|
+
|
|
84
|
+
// Check if target directory already exists and has content (skip check for current directory)
|
|
85
|
+
if (!initInCurrentDir && fs.existsSync(projectName)) {
|
|
86
|
+
const existingFiles = fs.readdirSync(projectName);
|
|
87
|
+
if (existingFiles.length > 0) {
|
|
88
|
+
console.error(chalk.red(`ā Directory '${projectName}' already exists and contains files`));
|
|
89
|
+
console.error(chalk.blue('š” To initialize CAWS in current directory instead:'));
|
|
90
|
+
console.error(` ${chalk.cyan('caws init .')}`);
|
|
91
|
+
console.error(chalk.blue('š” Or choose a different name/remove existing directory'));
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Check if current directory has project files when trying to init in subdirectory
|
|
97
|
+
if (!initInCurrentDir) {
|
|
98
|
+
const currentDirFiles = fs.readdirSync(process.cwd());
|
|
99
|
+
const hasProjectFiles = currentDirFiles.some(
|
|
100
|
+
(file) => !file.startsWith('.') && file !== 'node_modules' && file !== '.git'
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
if (hasProjectFiles && !options.nonInteractive) {
|
|
104
|
+
console.warn(chalk.yellow('ā ļø Current directory contains project files'));
|
|
105
|
+
console.warn(
|
|
106
|
+
chalk.blue('š” You might want to initialize CAWS in current directory instead:')
|
|
107
|
+
);
|
|
108
|
+
console.warn(` ${chalk.cyan('caws init .')}`);
|
|
109
|
+
console.warn(chalk.blue(' Or continue to create subdirectory (Ctrl+C to cancel)'));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Save the original template directory before changing directories
|
|
114
|
+
const cawsSetup = detectCAWSSetup(targetDir);
|
|
115
|
+
const originalTemplateDir = cawsSetup?.hasTemplateDir ? cawsSetup.templateDir : null;
|
|
116
|
+
|
|
117
|
+
// Check for existing agents.md/caws.md in target directory
|
|
118
|
+
const existingAgentsMd = fs.existsSync(path.join(targetDir, 'agents.md'));
|
|
119
|
+
const existingCawsMd = fs.existsSync(path.join(targetDir, 'caws.md'));
|
|
120
|
+
|
|
121
|
+
// Create project directory and change to it (unless already in current directory)
|
|
122
|
+
if (!initInCurrentDir) {
|
|
123
|
+
await fs.ensureDir(projectName);
|
|
124
|
+
process.chdir(projectName);
|
|
125
|
+
console.log(chalk.green(`š Created project directory: ${projectName}`));
|
|
126
|
+
} else {
|
|
127
|
+
console.log(chalk.green(`š Initializing in current directory`));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Detect and adapt to existing setup
|
|
131
|
+
const currentSetup = detectCAWSSetup(process.cwd());
|
|
132
|
+
|
|
133
|
+
if (currentSetup.type === 'new') {
|
|
134
|
+
// Create minimal CAWS structure
|
|
135
|
+
await fs.ensureDir('.caws');
|
|
136
|
+
await fs.ensureDir('.agent');
|
|
137
|
+
console.log(chalk.blue('ā¹ļø Created basic CAWS structure'));
|
|
138
|
+
|
|
139
|
+
// Copy agents.md guide if templates are available
|
|
140
|
+
if (originalTemplateDir) {
|
|
141
|
+
try {
|
|
142
|
+
const agentsMdSource = path.join(originalTemplateDir, 'agents.md');
|
|
143
|
+
let targetFile = 'agents.md';
|
|
144
|
+
|
|
145
|
+
if (fs.existsSync(agentsMdSource)) {
|
|
146
|
+
// Use the pre-checked values for conflicts
|
|
147
|
+
if (existingAgentsMd) {
|
|
148
|
+
// Conflict: user already has agents.md
|
|
149
|
+
if (options.interactive && !options.nonInteractive) {
|
|
150
|
+
// Interactive mode: ask user
|
|
151
|
+
const overwriteAnswer = await inquirer.prompt([
|
|
152
|
+
{
|
|
153
|
+
type: 'confirm',
|
|
154
|
+
name: 'overwrite',
|
|
155
|
+
message: 'ā ļø agents.md already exists. Overwrite with CAWS guide?',
|
|
156
|
+
default: false,
|
|
157
|
+
},
|
|
158
|
+
]);
|
|
159
|
+
|
|
160
|
+
if (overwriteAnswer.overwrite) {
|
|
161
|
+
targetFile = 'agents.md';
|
|
162
|
+
} else {
|
|
163
|
+
targetFile = 'caws.md';
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
// Non-interactive mode: use caws.md instead
|
|
167
|
+
targetFile = 'caws.md';
|
|
168
|
+
console.log(chalk.blue('ā¹ļø agents.md exists, using caws.md for CAWS guide'));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// If caws.md also exists and that's our target, skip
|
|
173
|
+
if (targetFile === 'caws.md' && existingCawsMd) {
|
|
174
|
+
console.log(
|
|
175
|
+
chalk.yellow('ā ļø Both agents.md and caws.md exist, skipping guide copy')
|
|
176
|
+
);
|
|
177
|
+
} else {
|
|
178
|
+
const agentsMdDest = path.join(process.cwd(), targetFile);
|
|
179
|
+
await fs.copyFile(agentsMdSource, agentsMdDest);
|
|
180
|
+
console.log(chalk.green(`ā
Added ${targetFile} guide`));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} catch (templateError) {
|
|
184
|
+
console.warn(chalk.yellow('ā ļø Could not copy agents guide:'), templateError.message);
|
|
185
|
+
console.warn(
|
|
186
|
+
chalk.blue('š” You can manually copy the guide from the caws-template package')
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
// Already has CAWS setup
|
|
192
|
+
console.log(chalk.green('ā
CAWS project detected - skipping template copy'));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Handle interactive wizard or template-based setup
|
|
196
|
+
if (options.interactive && !options.nonInteractive) {
|
|
197
|
+
console.log(chalk.cyan('šÆ CAWS Interactive Setup Wizard'));
|
|
198
|
+
console.log(chalk.blue('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
199
|
+
console.log(chalk.gray('This wizard will guide you through creating a CAWS working spec\n'));
|
|
200
|
+
|
|
201
|
+
// Detect project type
|
|
202
|
+
const detectedType = detectProjectType(process.cwd());
|
|
203
|
+
console.log(chalk.blue(`š¦ Detected project type: ${chalk.cyan(detectedType)}`));
|
|
204
|
+
|
|
205
|
+
// Get package.json info if available
|
|
206
|
+
let packageJson = {};
|
|
207
|
+
try {
|
|
208
|
+
packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'));
|
|
209
|
+
} catch (e) {
|
|
210
|
+
// No package.json, that's fine
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const wizardQuestions = [
|
|
214
|
+
{
|
|
215
|
+
type: 'list',
|
|
216
|
+
name: 'projectType',
|
|
217
|
+
message: 'ā What type of project is this?',
|
|
218
|
+
choices: [
|
|
219
|
+
{
|
|
220
|
+
name: 'š VS Code Extension (webview, commands, integrations)',
|
|
221
|
+
value: 'extension',
|
|
222
|
+
short: 'VS Code Extension',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'š Library/Package (reusable components, utilities)',
|
|
226
|
+
value: 'library',
|
|
227
|
+
short: 'Library',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'š Web Application (frontend/backend, full-stack)',
|
|
231
|
+
value: 'application',
|
|
232
|
+
short: 'Web Application',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: 'š„ļø CLI Tool (command-line interface, scripts)',
|
|
236
|
+
value: 'cli',
|
|
237
|
+
short: 'CLI Tool',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'š± Mobile App (iOS/Android, React Native, etc.)',
|
|
241
|
+
value: 'mobile',
|
|
242
|
+
short: 'Mobile App',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'š ļø Infrastructure (DevOps, deployment, cloud)',
|
|
246
|
+
value: 'infrastructure',
|
|
247
|
+
short: 'Infrastructure',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'š Data/Analytics (ETL, ML, dashboards)',
|
|
251
|
+
value: 'data',
|
|
252
|
+
short: 'Data/Analytics',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'š® Game Development (Unity, Godot, custom engine)',
|
|
256
|
+
value: 'game',
|
|
257
|
+
short: 'Game',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'š§ Other/Custom (please specify)',
|
|
261
|
+
value: 'other',
|
|
262
|
+
short: 'Other',
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
default: detectedType,
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
type: 'input',
|
|
269
|
+
name: 'projectTitle',
|
|
270
|
+
message: 'š What is the project title?',
|
|
271
|
+
default: packageJson.name || path.basename(process.cwd()),
|
|
272
|
+
validate: (input) => {
|
|
273
|
+
if (input.trim().length < 3) {
|
|
274
|
+
return 'Project title must be at least 3 characters';
|
|
275
|
+
}
|
|
276
|
+
if (input.length > 100) {
|
|
277
|
+
return 'Project title must be less than 100 characters';
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
type: 'input',
|
|
284
|
+
name: 'projectDescription',
|
|
285
|
+
message: 'š Provide a brief project description (1-2 sentences):',
|
|
286
|
+
default: packageJson.description || '',
|
|
287
|
+
validate: (input) => {
|
|
288
|
+
if (input.trim().length < 10) {
|
|
289
|
+
return 'Description must be at least 10 characters';
|
|
290
|
+
}
|
|
291
|
+
if (input.length > 500) {
|
|
292
|
+
return 'Description must be less than 500 characters';
|
|
293
|
+
}
|
|
294
|
+
return true;
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
type: 'list',
|
|
299
|
+
name: 'riskTier',
|
|
300
|
+
message: 'ā ļø What risk tier does this project fall into?',
|
|
301
|
+
choices: [
|
|
302
|
+
{
|
|
303
|
+
name: 'š“ Tier 1 - High Risk (auth, billing, migrations, critical infrastructure)',
|
|
304
|
+
value: 1,
|
|
305
|
+
short: 'High Risk (T1)',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: 'š” Tier 2 - Medium Risk (features, APIs, data writes)',
|
|
309
|
+
value: 2,
|
|
310
|
+
short: 'Medium Risk (T2)',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: 'š¢ Tier 3 - Low Risk (UI, internal tools, docs)',
|
|
314
|
+
value: 3,
|
|
315
|
+
short: 'Low Risk (T3)',
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
default: 2,
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
type: 'input',
|
|
322
|
+
name: 'projectId',
|
|
323
|
+
message: 'š Project ID (e.g., PROJ-001, FEAT-123):',
|
|
324
|
+
default: () => {
|
|
325
|
+
const randomNum = Math.floor(Math.random() * 1000) + 1;
|
|
326
|
+
return `PROJ-${randomNum.toString().padStart(3, '0')}`;
|
|
327
|
+
},
|
|
328
|
+
validate: (input) => {
|
|
329
|
+
if (!input.match(/^[A-Z]+-\d+$/)) {
|
|
330
|
+
return 'Project ID must be in format PREFIX-NUMBER (e.g., PROJ-001)';
|
|
331
|
+
}
|
|
332
|
+
if (input.length > 20) {
|
|
333
|
+
return 'Project ID must be less than 20 characters';
|
|
334
|
+
}
|
|
335
|
+
return true;
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: 'confirm',
|
|
340
|
+
name: 'useCursorHooks',
|
|
341
|
+
message: 'šÆ Enable Cursor IDE hooks for real-time quality gates?',
|
|
342
|
+
default: true,
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
type: 'confirm',
|
|
346
|
+
name: 'generateExamples',
|
|
347
|
+
message: 'š Generate example code and documentation?',
|
|
348
|
+
default: true,
|
|
349
|
+
},
|
|
350
|
+
];
|
|
351
|
+
|
|
352
|
+
// Ask questions and get answers
|
|
353
|
+
answers = await inquirer.prompt(wizardQuestions);
|
|
354
|
+
|
|
355
|
+
// Generate working spec
|
|
356
|
+
console.log(chalk.blue('\nš Generating CAWS working spec...'));
|
|
357
|
+
const specContent = generateWorkingSpec(answers);
|
|
358
|
+
|
|
359
|
+
// Write working spec
|
|
360
|
+
await fs.ensureDir('.caws');
|
|
361
|
+
await fs.writeFile(path.join('.caws', 'working-spec.yaml'), specContent);
|
|
362
|
+
console.log(chalk.green('ā
Created .caws/working-spec.yaml'));
|
|
363
|
+
|
|
364
|
+
// Generate additional files if requested
|
|
365
|
+
if (answers.generateExamples) {
|
|
366
|
+
console.log(chalk.blue('š Generating example files...'));
|
|
367
|
+
|
|
368
|
+
// Generate .caws/getting-started.md
|
|
369
|
+
const gettingStartedGuide = `# ${answers.projectTitle} - Getting Started
|
|
370
|
+
|
|
371
|
+
## Project Overview
|
|
372
|
+
${answers.projectDescription}
|
|
373
|
+
|
|
374
|
+
## Risk Tier: ${answers.riskTier === 1 ? 'High (T1)' : answers.riskTier === 2 ? 'Medium (T2)' : 'Low (T3)'}
|
|
375
|
+
|
|
376
|
+
## Next Steps
|
|
377
|
+
1. Review and customize \`.caws/working-spec.yaml\`
|
|
378
|
+
2. Set up your development environment
|
|
379
|
+
3. Implement features according to the spec
|
|
380
|
+
4. Run \`caws validate\` to check your progress
|
|
381
|
+
|
|
382
|
+
## Quality Gates
|
|
383
|
+
- **Coverage**: ${answers.riskTier === 1 ? '90%+' : answers.riskTier === 2 ? '80%+' : '70%+'}
|
|
384
|
+
- **Mutation Score**: ${answers.riskTier === 1 ? '70%+' : answers.riskTier === 2 ? '50%+' : '30%+'}
|
|
385
|
+
- **Review**: ${answers.riskTier === 1 ? 'Manual' : 'Optional'}
|
|
386
|
+
|
|
387
|
+
Happy coding! šÆ
|
|
388
|
+
`;
|
|
389
|
+
|
|
390
|
+
await fs.writeFile(path.join('.caws', 'getting-started.md'), gettingStartedGuide);
|
|
391
|
+
console.log(chalk.green('ā
Created .caws/getting-started.md'));
|
|
392
|
+
|
|
393
|
+
// Generate basic directory structure
|
|
394
|
+
await fs.ensureDir('tests');
|
|
395
|
+
await fs.ensureDir('tests/unit');
|
|
396
|
+
await fs.ensureDir('tests/integration');
|
|
397
|
+
await fs.ensureDir('tests/e2e');
|
|
398
|
+
await fs.ensureDir('docs');
|
|
399
|
+
console.log(chalk.green('ā
Created test and docs directories'));
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Setup Cursor hooks if requested
|
|
403
|
+
if (answers.useCursorHooks) {
|
|
404
|
+
console.log(chalk.blue('šÆ Setting up Cursor hooks...'));
|
|
405
|
+
await scaffoldCursorHooks(process.cwd());
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Setup IDE integrations for comprehensive development experience
|
|
409
|
+
console.log(chalk.blue('šØ Setting up IDE integrations...'));
|
|
410
|
+
await scaffoldIDEIntegrations(process.cwd(), { force: false });
|
|
411
|
+
|
|
412
|
+
// Finalize project
|
|
413
|
+
await finalizeProject(projectName, options, answers);
|
|
414
|
+
} else {
|
|
415
|
+
// Non-interactive mode - generate basic spec with defaults
|
|
416
|
+
console.log(chalk.blue('š Generating basic CAWS working spec...'));
|
|
417
|
+
|
|
418
|
+
const detectedType = detectProjectType(process.cwd());
|
|
419
|
+
const defaultAnswers = {
|
|
420
|
+
projectType: detectedType,
|
|
421
|
+
projectTitle: path.basename(process.cwd()),
|
|
422
|
+
projectDescription: `A ${detectedType} project managed with CAWS`,
|
|
423
|
+
riskTier: 2,
|
|
424
|
+
projectId: `PROJ-${Math.floor(Math.random() * 1000) + 1}`,
|
|
425
|
+
useCursorHooks: true,
|
|
426
|
+
generateExamples: false,
|
|
427
|
+
projectMode: 'feature',
|
|
428
|
+
maxFiles: 25,
|
|
429
|
+
maxLoc: 1000,
|
|
430
|
+
blastModules: 'src, tests',
|
|
431
|
+
dataMigration: false,
|
|
432
|
+
rollbackSlo: '5m',
|
|
433
|
+
projectThreats: '',
|
|
434
|
+
scopeIn: 'src/, tests/',
|
|
435
|
+
scopeOut: 'node_modules/, dist/, build/',
|
|
436
|
+
projectInvariants: 'System maintains data consistency',
|
|
437
|
+
acceptanceCriteria: 'Given current state, when action occurs, then expected result',
|
|
438
|
+
a11yRequirements: 'keyboard',
|
|
439
|
+
perfBudget: 250,
|
|
440
|
+
securityRequirements: 'validation',
|
|
441
|
+
contractType: '',
|
|
442
|
+
contractPath: '',
|
|
443
|
+
observabilityLogs: '',
|
|
444
|
+
observabilityMetrics: '',
|
|
445
|
+
observabilityTraces: '',
|
|
446
|
+
migrationPlan: '',
|
|
447
|
+
rollbackPlan: '',
|
|
448
|
+
needsOverride: false,
|
|
449
|
+
overrideApprover: '',
|
|
450
|
+
overrideRationale: '',
|
|
451
|
+
waivedGates: [],
|
|
452
|
+
overrideExpiresDays: 7,
|
|
453
|
+
isExperimental: false,
|
|
454
|
+
experimentalRationale: '',
|
|
455
|
+
experimentalExpiresDays: 30,
|
|
456
|
+
experimentalSandbox: '',
|
|
457
|
+
aiConfidence: 0.8,
|
|
458
|
+
uncertaintyAreas: '',
|
|
459
|
+
complexityFactors: ''
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
const specContent = generateWorkingSpec(defaultAnswers);
|
|
463
|
+
await fs.ensureDir('.caws');
|
|
464
|
+
await fs.writeFile(path.join('.caws', 'working-spec.yaml'), specContent);
|
|
465
|
+
console.log(chalk.green('ā
Created .caws/working-spec.yaml'));
|
|
466
|
+
|
|
467
|
+
// Setup Cursor hooks by default in non-interactive mode
|
|
468
|
+
console.log(chalk.blue('šÆ Setting up Cursor hooks...'));
|
|
469
|
+
await scaffoldCursorHooks(process.cwd());
|
|
470
|
+
|
|
471
|
+
// Setup IDE integrations by default in non-interactive mode
|
|
472
|
+
console.log(chalk.blue('šØ Setting up IDE integrations...'));
|
|
473
|
+
await scaffoldIDEIntegrations(process.cwd(), { force: false });
|
|
474
|
+
|
|
475
|
+
// Finalize project
|
|
476
|
+
await finalizeProject(projectName, options, defaultAnswers);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Success message
|
|
480
|
+
console.log(chalk.green('\nš CAWS project initialized successfully!'));
|
|
481
|
+
console.log(chalk.blue('\nNext steps:'));
|
|
482
|
+
console.log('1. Review .caws/working-spec.yaml');
|
|
483
|
+
console.log('2. Customize the specification for your needs');
|
|
484
|
+
console.log('3. Run "caws validate" to check your setup');
|
|
485
|
+
if (answers?.useCursorHooks || options.interactive === false) {
|
|
486
|
+
console.log('4. Restart Cursor IDE to activate quality gates');
|
|
487
|
+
}
|
|
488
|
+
console.log('5. Start implementing your features!');
|
|
489
|
+
} catch (error) {
|
|
490
|
+
console.error(chalk.red('ā Error during initialization:'), error.message);
|
|
491
|
+
if (error.stack) {
|
|
492
|
+
console.error(chalk.gray(error.stack));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Cleanup on error (only for new directory creation)
|
|
496
|
+
if (projectName && projectName !== '.' && fs.existsSync(projectName)) {
|
|
497
|
+
try {
|
|
498
|
+
await fs.remove(projectName);
|
|
499
|
+
console.log(chalk.green('ā
Cleanup completed'));
|
|
500
|
+
} catch (cleanupError) {
|
|
501
|
+
console.warn(
|
|
502
|
+
chalk.yellow('ā ļø Could not clean up:'),
|
|
503
|
+
cleanupError?.message || cleanupError
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
process.exit(1);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
module.exports = {
|
|
513
|
+
initProject,
|
|
514
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance command handler
|
|
3
|
+
* @param {string} subcommand - The subcommand to execute
|
|
4
|
+
* @param {Object} options - Command options
|
|
5
|
+
*/
|
|
6
|
+
export function provenanceCommand(subcommand: string, options: any): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Update provenance with new commit information
|
|
9
|
+
* @param {Object} options - Command options
|
|
10
|
+
*/
|
|
11
|
+
export function updateProvenance(options: any): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Show current provenance information
|
|
14
|
+
* @param {Object} options - Command options
|
|
15
|
+
*/
|
|
16
|
+
export function showProvenance(options: any): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Verify provenance chain integrity
|
|
19
|
+
* @param {Object} options - Command options
|
|
20
|
+
*/
|
|
21
|
+
export function verifyProvenance(options: any): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../src/commands/provenance.js"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,8CAHW,MAAM,+BAuBhB;AAED;;;GAGG;AACH,8DA4EC;AAED;;;GAGG;AACH,4DAsDC;AAED;;;GAGG;AACH,8DA8CC"}
|