@paths.design/caws-cli 4.0.0 → 5.0.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/commands/archive.js +353 -0
- package/dist/commands/iterate.js +12 -13
- package/dist/commands/mode.js +259 -0
- package/dist/commands/plan.js +448 -0
- package/dist/commands/quality-gates.js +490 -0
- package/dist/commands/specs.js +735 -0
- package/dist/commands/status.js +552 -22
- package/dist/commands/tutorial.js +481 -0
- package/dist/commands/validate.js +137 -54
- package/dist/commands/waivers.js +101 -26
- package/dist/config/modes.js +321 -0
- package/dist/constants/spec-types.js +42 -0
- package/dist/index.js +225 -10
- package/dist/scaffold/git-hooks.js +32 -44
- package/dist/scaffold/index.js +19 -0
- package/dist/utils/quality-gates-errors.js +520 -0
- package/dist/utils/quality-gates.js +361 -0
- package/dist/utils/spec-resolver.js +602 -0
- package/dist/waivers-manager.js +49 -4
- 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/{01-claims-verification.mdc → 00-claims-verification.mdc} +1 -1
- package/templates/.cursor/rules/01-working-style.mdc +50 -0
- package/templates/.cursor/rules/{02-testing-standards.mdc → 02-quality-gates.mdc} +84 -29
- 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 +93 -7
- 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
- package/dist/budget-derivation.d.ts +0 -74
- package/dist/budget-derivation.d.ts.map +0 -1
- package/dist/cicd-optimizer.d.ts +0 -142
- package/dist/cicd-optimizer.d.ts.map +0 -1
- package/dist/commands/burnup.d.ts +0 -6
- package/dist/commands/burnup.d.ts.map +0 -1
- package/dist/commands/diagnose.d.ts +0 -52
- package/dist/commands/diagnose.d.ts.map +0 -1
- package/dist/commands/evaluate.d.ts +0 -8
- package/dist/commands/evaluate.d.ts.map +0 -1
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/iterate.d.ts +0 -8
- package/dist/commands/iterate.d.ts.map +0 -1
- package/dist/commands/provenance.d.ts +0 -32
- package/dist/commands/provenance.d.ts.map +0 -1
- package/dist/commands/quality-monitor.d.ts +0 -17
- package/dist/commands/quality-monitor.d.ts.map +0 -1
- package/dist/commands/status.d.ts +0 -43
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/templates.d.ts +0 -74
- package/dist/commands/templates.d.ts.map +0 -1
- package/dist/commands/tool.d.ts +0 -13
- package/dist/commands/tool.d.ts.map +0 -1
- package/dist/commands/troubleshoot.d.ts +0 -8
- package/dist/commands/troubleshoot.d.ts.map +0 -1
- package/dist/commands/validate.d.ts +0 -8
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/waivers.d.ts +0 -8
- package/dist/commands/waivers.d.ts.map +0 -1
- package/dist/commands/workflow.d.ts +0 -85
- package/dist/commands/workflow.d.ts.map +0 -1
- package/dist/config/index.d.ts +0 -29
- package/dist/config/index.d.ts.map +0 -1
- package/dist/error-handler.d.ts +0 -164
- package/dist/error-handler.d.ts.map +0 -1
- package/dist/generators/jest-config.d.ts +0 -32
- package/dist/generators/jest-config.d.ts.map +0 -1
- package/dist/generators/working-spec.d.ts +0 -13
- package/dist/generators/working-spec.d.ts.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/minimal-cli.d.ts +0 -3
- package/dist/minimal-cli.d.ts.map +0 -1
- package/dist/policy/PolicyManager.d.ts +0 -104
- package/dist/policy/PolicyManager.d.ts.map +0 -1
- package/dist/scaffold/cursor-hooks.d.ts +0 -7
- package/dist/scaffold/cursor-hooks.d.ts.map +0 -1
- package/dist/scaffold/git-hooks.d.ts +0 -20
- package/dist/scaffold/git-hooks.d.ts.map +0 -1
- package/dist/scaffold/index.d.ts +0 -20
- package/dist/scaffold/index.d.ts.map +0 -1
- package/dist/spec/SpecFileManager.d.ts +0 -146
- package/dist/spec/SpecFileManager.d.ts.map +0 -1
- package/dist/test-analysis.d.ts +0 -182
- package/dist/test-analysis.d.ts.map +0 -1
- package/dist/tool-interface.d.ts +0 -236
- package/dist/tool-interface.d.ts.map +0 -1
- package/dist/tool-loader.d.ts +0 -77
- package/dist/tool-loader.d.ts.map +0 -1
- package/dist/tool-validator.d.ts +0 -72
- package/dist/tool-validator.d.ts.map +0 -1
- package/dist/utils/detection.d.ts +0 -7
- package/dist/utils/detection.d.ts.map +0 -1
- package/dist/utils/finalization.d.ts +0 -17
- package/dist/utils/finalization.d.ts.map +0 -1
- package/dist/utils/project-analysis.d.ts +0 -14
- package/dist/utils/project-analysis.d.ts.map +0 -1
- package/dist/utils/typescript-detector.d.ts +0 -63
- package/dist/utils/typescript-detector.d.ts.map +0 -1
- package/dist/validation/spec-validation.d.ts +0 -43
- package/dist/validation/spec-validation.d.ts.map +0 -1
- package/dist/waivers-manager.d.ts +0 -167
- package/dist/waivers-manager.d.ts.map +0 -1
- package/templates/.cursor/rules/03-infrastructure-standards.mdc +0 -251
- package/templates/.cursor/rules/04-documentation-integrity.mdc +0 -291
- package/templates/.cursor/rules/05-production-readiness-checklist.mdc +0 -214
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CAWS Archive Command
|
|
3
|
+
* Archive completed changes with lifecycle management (multi-spec aware)
|
|
4
|
+
* @author @darianrosebrook
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs-extra');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const yaml = require('js-yaml');
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const { safeAsync, outputResult } = require('../error-handler');
|
|
12
|
+
|
|
13
|
+
// Import spec resolution system
|
|
14
|
+
const { resolveSpec } = require('../utils/spec-resolver');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Load change folder structure
|
|
18
|
+
* @param {string} changeId - Change identifier
|
|
19
|
+
* @returns {Promise<Object|null>} Change data or null
|
|
20
|
+
*/
|
|
21
|
+
async function loadChange(changeId) {
|
|
22
|
+
const changesDir = '.caws/changes';
|
|
23
|
+
const changePath = path.join(changesDir, changeId);
|
|
24
|
+
|
|
25
|
+
if (!(await fs.pathExists(changePath))) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const metadataPath = path.join(changePath, 'metadata.yaml');
|
|
31
|
+
const workingSpecPath = path.join(changePath, 'working-spec.yaml');
|
|
32
|
+
|
|
33
|
+
const metadata = (await fs.pathExists(metadataPath))
|
|
34
|
+
? yaml.load(await fs.readFile(metadataPath, 'utf8'))
|
|
35
|
+
: {};
|
|
36
|
+
|
|
37
|
+
const workingSpec = (await fs.pathExists(workingSpecPath))
|
|
38
|
+
? yaml.load(await fs.readFile(workingSpecPath, 'utf8'))
|
|
39
|
+
: null;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
id: changeId,
|
|
43
|
+
path: changePath,
|
|
44
|
+
metadata,
|
|
45
|
+
workingSpec,
|
|
46
|
+
exists: true,
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Validate all acceptance criteria are met
|
|
55
|
+
* @param {Object} workingSpec - Working specification
|
|
56
|
+
* @returns {Promise<Object>} Validation result
|
|
57
|
+
*/
|
|
58
|
+
async function validateAcceptanceCriteria(workingSpec) {
|
|
59
|
+
if (!workingSpec || !workingSpec.acceptance_criteria) {
|
|
60
|
+
return {
|
|
61
|
+
valid: false,
|
|
62
|
+
message: 'No acceptance criteria found in working spec',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const criteria = workingSpec.acceptance_criteria;
|
|
67
|
+
const incomplete = [];
|
|
68
|
+
|
|
69
|
+
for (const criterion of criteria) {
|
|
70
|
+
if (!criterion.completed) {
|
|
71
|
+
incomplete.push(criterion.id || 'unknown');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (incomplete.length > 0) {
|
|
76
|
+
return {
|
|
77
|
+
valid: false,
|
|
78
|
+
message: `Incomplete acceptance criteria: ${incomplete.join(', ')}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
valid: true,
|
|
84
|
+
message: `All ${criteria.length} acceptance criteria completed`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Validate change meets quality gates
|
|
90
|
+
* @param {string} changeId - Change identifier
|
|
91
|
+
* @returns {Promise<Object>} Quality gate result
|
|
92
|
+
*/
|
|
93
|
+
async function validateQualityGates(_changeId) {
|
|
94
|
+
// For now, return success - in full implementation would run actual gate checks
|
|
95
|
+
return {
|
|
96
|
+
valid: true,
|
|
97
|
+
message: 'Quality gates passed (implementation pending)',
|
|
98
|
+
gates: ['test-coverage', 'linting', 'type-checking'],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Generate change summary for archival
|
|
104
|
+
* @param {Object} change - Change data
|
|
105
|
+
* @returns {Promise<string>} Summary text
|
|
106
|
+
*/
|
|
107
|
+
async function generateChangeSummary(change) {
|
|
108
|
+
const { workingSpec, metadata } = change;
|
|
109
|
+
|
|
110
|
+
let summary = `# Change Summary: ${change.id}\n\n`;
|
|
111
|
+
|
|
112
|
+
if (workingSpec) {
|
|
113
|
+
summary += `**Title**: ${workingSpec.title || 'Untitled'}\n`;
|
|
114
|
+
summary += `**Risk Tier**: ${workingSpec.risk_tier || 'Unknown'}\n`;
|
|
115
|
+
summary += `**Mode**: ${workingSpec.mode || 'Unknown'}\n\n`;
|
|
116
|
+
|
|
117
|
+
if (workingSpec.acceptance_criteria) {
|
|
118
|
+
const total = workingSpec.acceptance_criteria.length;
|
|
119
|
+
const completed = workingSpec.acceptance_criteria.filter((c) => c.completed).length;
|
|
120
|
+
summary += `**Acceptance Criteria**: ${completed}/${total} completed\n\n`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (metadata.created_at) {
|
|
125
|
+
summary += `**Created**: ${new Date(metadata.created_at).toISOString()}\n`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (metadata.completed_at) {
|
|
129
|
+
summary += `**Completed**: ${new Date(metadata.completed_at).toISOString()}\n`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
summary += `\n**Files Changed**: ${metadata.files_changed || 0}\n`;
|
|
133
|
+
summary += `**Lines Added**: ${metadata.lines_added || 0}\n`;
|
|
134
|
+
summary += `**Lines Removed**: ${metadata.lines_removed || 0}\n`;
|
|
135
|
+
|
|
136
|
+
return summary;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Archive change folder to archive directory
|
|
141
|
+
* @param {Object} change - Change data
|
|
142
|
+
* @returns {Promise<void>}
|
|
143
|
+
*/
|
|
144
|
+
async function archiveChange(change) {
|
|
145
|
+
const archiveDir = '.caws/archive';
|
|
146
|
+
const archivePath = path.join(archiveDir, change.id);
|
|
147
|
+
|
|
148
|
+
// Ensure archive directory exists
|
|
149
|
+
await fs.ensureDir(archiveDir);
|
|
150
|
+
|
|
151
|
+
// Move change folder to archive
|
|
152
|
+
await fs.move(change.path, archivePath);
|
|
153
|
+
|
|
154
|
+
console.log(chalk.green(` ✅ Moved to: ${archivePath}`));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Update provenance with completion
|
|
159
|
+
* @param {Object} change - Change data
|
|
160
|
+
* @returns {Promise<void>}
|
|
161
|
+
*/
|
|
162
|
+
async function updateProvenance(change) {
|
|
163
|
+
const provenanceDir = '.caws/provenance';
|
|
164
|
+
const chainPath = path.join(provenanceDir, 'chain.json');
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
let chain = [];
|
|
168
|
+
|
|
169
|
+
if (await fs.pathExists(chainPath)) {
|
|
170
|
+
chain = JSON.parse(await fs.readFile(chainPath, 'utf8'));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Add completion entry
|
|
174
|
+
const completionEntry = {
|
|
175
|
+
timestamp: new Date().toISOString(),
|
|
176
|
+
action: 'change_completed',
|
|
177
|
+
change_id: change.id,
|
|
178
|
+
metadata: {
|
|
179
|
+
title: change.workingSpec?.title,
|
|
180
|
+
risk_tier: change.workingSpec?.risk_tier,
|
|
181
|
+
files_changed: change.metadata?.files_changed || 0,
|
|
182
|
+
lines_added: change.metadata?.lines_added || 0,
|
|
183
|
+
lines_removed: change.metadata?.lines_removed || 0,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
chain.push(completionEntry);
|
|
188
|
+
|
|
189
|
+
await fs.ensureDir(provenanceDir);
|
|
190
|
+
await fs.writeFile(chainPath, JSON.stringify(chain, null, 2));
|
|
191
|
+
|
|
192
|
+
console.log(chalk.green(` ✅ Provenance updated: ${chain.length} total entries`));
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.log(chalk.yellow(` ⚠️ Could not update provenance: ${error.message}`));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Display archive results
|
|
200
|
+
* @param {Object} change - Change data
|
|
201
|
+
* @param {Object} validation - Validation result
|
|
202
|
+
* @param {Object} qualityGates - Quality gates result
|
|
203
|
+
*/
|
|
204
|
+
function displayArchiveResults(change, validation, qualityGates) {
|
|
205
|
+
console.log(chalk.bold.cyan(`\n📦 Archiving Change: ${change.id}`));
|
|
206
|
+
console.log(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
207
|
+
|
|
208
|
+
// Validation status
|
|
209
|
+
if (validation.valid) {
|
|
210
|
+
console.log(chalk.green('✅ Acceptance Criteria'));
|
|
211
|
+
console.log(chalk.gray(` ${validation.message}`));
|
|
212
|
+
} else {
|
|
213
|
+
console.log(chalk.red('❌ Acceptance Criteria'));
|
|
214
|
+
console.log(chalk.gray(` ${validation.message}`));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
console.log('');
|
|
218
|
+
|
|
219
|
+
// Quality gates status
|
|
220
|
+
if (qualityGates.valid) {
|
|
221
|
+
console.log(chalk.green('✅ Quality Gates'));
|
|
222
|
+
console.log(chalk.gray(` ${qualityGates.message}`));
|
|
223
|
+
} else {
|
|
224
|
+
console.log(chalk.red('❌ Quality Gates'));
|
|
225
|
+
console.log(chalk.gray(` ${qualityGates.message}`));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
console.log('');
|
|
229
|
+
|
|
230
|
+
// Archive action
|
|
231
|
+
console.log(chalk.blue('📂 Archive Actions:'));
|
|
232
|
+
console.log(chalk.gray(' • Moving change folder to archive'));
|
|
233
|
+
console.log(chalk.gray(' • Updating provenance chain'));
|
|
234
|
+
console.log(chalk.gray(' • Generating change summary'));
|
|
235
|
+
|
|
236
|
+
console.log('');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Archive command handler
|
|
241
|
+
* @param {string} changeId - Change identifier to archive
|
|
242
|
+
* @param {Object} options - Command options
|
|
243
|
+
*/
|
|
244
|
+
async function archiveCommand(changeId, options = {}) {
|
|
245
|
+
return safeAsync(
|
|
246
|
+
async () => {
|
|
247
|
+
if (!changeId) {
|
|
248
|
+
throw new Error('Change ID is required. Usage: caws archive <change-id>');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Load change data
|
|
252
|
+
const change = await loadChange(changeId);
|
|
253
|
+
if (!change) {
|
|
254
|
+
throw new Error(`Change '${changeId}' not found in .caws/changes/`);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Resolve spec using priority system
|
|
258
|
+
let workingSpec = change.workingSpec;
|
|
259
|
+
if (!workingSpec && options.specId) {
|
|
260
|
+
// If change doesn't have a working spec but spec-id is provided, load it
|
|
261
|
+
try {
|
|
262
|
+
const resolved = await resolveSpec({
|
|
263
|
+
specId: options.specId,
|
|
264
|
+
warnLegacy: false,
|
|
265
|
+
});
|
|
266
|
+
workingSpec = resolved.spec;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.log(
|
|
269
|
+
chalk.yellow(`⚠️ Could not load spec '${options.specId}': ${error.message}`)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Validate acceptance criteria
|
|
275
|
+
const validation = await validateAcceptanceCriteria(workingSpec);
|
|
276
|
+
|
|
277
|
+
// Validate quality gates
|
|
278
|
+
const qualityGates = await validateQualityGates(changeId);
|
|
279
|
+
|
|
280
|
+
// Display results
|
|
281
|
+
displayArchiveResults(change, validation, qualityGates);
|
|
282
|
+
|
|
283
|
+
// Check if we should proceed with archival
|
|
284
|
+
if (!validation.valid) {
|
|
285
|
+
console.log(chalk.yellow('⚠️ Cannot archive: Incomplete acceptance criteria'));
|
|
286
|
+
if (!options.force) {
|
|
287
|
+
console.log(chalk.yellow('💡 Use --force to archive anyway'));
|
|
288
|
+
return outputResult({
|
|
289
|
+
command: 'archive',
|
|
290
|
+
change: changeId,
|
|
291
|
+
archived: false,
|
|
292
|
+
reason: 'incomplete_criteria',
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (!qualityGates.valid) {
|
|
298
|
+
console.log(chalk.yellow('⚠️ Cannot archive: Quality gates not met'));
|
|
299
|
+
if (!options.force) {
|
|
300
|
+
console.log(chalk.yellow('💡 Use --force to archive anyway'));
|
|
301
|
+
return outputResult({
|
|
302
|
+
command: 'archive',
|
|
303
|
+
change: changeId,
|
|
304
|
+
archived: false,
|
|
305
|
+
reason: 'quality_gates_failed',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Perform archival
|
|
311
|
+
console.log(chalk.blue('🔄 Performing archival...'));
|
|
312
|
+
|
|
313
|
+
// Update metadata with completion timestamp
|
|
314
|
+
change.metadata.completed_at = new Date().toISOString();
|
|
315
|
+
change.metadata.archived = true;
|
|
316
|
+
|
|
317
|
+
// Generate and save summary
|
|
318
|
+
const summary = await generateChangeSummary(change);
|
|
319
|
+
const summaryPath = path.join(change.path, 'archive-summary.md');
|
|
320
|
+
await fs.writeFile(summaryPath, summary);
|
|
321
|
+
|
|
322
|
+
// Archive the change
|
|
323
|
+
await archiveChange(change);
|
|
324
|
+
|
|
325
|
+
// Update provenance
|
|
326
|
+
await updateProvenance(change);
|
|
327
|
+
|
|
328
|
+
console.log(chalk.green(`\n🎉 Successfully archived change: ${changeId}`));
|
|
329
|
+
|
|
330
|
+
return outputResult({
|
|
331
|
+
command: 'archive',
|
|
332
|
+
change: changeId,
|
|
333
|
+
archived: true,
|
|
334
|
+
validation: validation.valid,
|
|
335
|
+
qualityGates: qualityGates.valid,
|
|
336
|
+
summary: summary,
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
'archive change',
|
|
340
|
+
true
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
module.exports = {
|
|
345
|
+
archiveCommand,
|
|
346
|
+
loadChange,
|
|
347
|
+
validateAcceptanceCriteria,
|
|
348
|
+
validateQualityGates,
|
|
349
|
+
generateChangeSummary,
|
|
350
|
+
archiveChange,
|
|
351
|
+
updateProvenance,
|
|
352
|
+
displayArchiveResults,
|
|
353
|
+
};
|
package/dist/commands/iterate.js
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const path = require('path');
|
|
12
|
-
const yaml = require('js-yaml');
|
|
13
12
|
const chalk = require('chalk');
|
|
14
13
|
const { initializeGlobalSetup } = require('../config');
|
|
15
14
|
|
|
15
|
+
// Import spec resolution system
|
|
16
|
+
const { resolveSpec } = require('../utils/spec-resolver');
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Iterate command handler
|
|
18
20
|
*
|
|
@@ -21,6 +23,15 @@ const { initializeGlobalSetup } = require('../config');
|
|
|
21
23
|
*/
|
|
22
24
|
async function iterateCommand(specFile = '.caws/working-spec.yaml', options = {}) {
|
|
23
25
|
try {
|
|
26
|
+
// Resolve spec using priority system
|
|
27
|
+
const resolved = await resolveSpec({
|
|
28
|
+
specId: options.specId,
|
|
29
|
+
specFile,
|
|
30
|
+
warnLegacy: false,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const { spec } = resolved;
|
|
34
|
+
|
|
24
35
|
console.log('🔍 Detecting CAWS setup...');
|
|
25
36
|
const setup = initializeGlobalSetup();
|
|
26
37
|
|
|
@@ -29,18 +40,6 @@ async function iterateCommand(specFile = '.caws/working-spec.yaml', options = {}
|
|
|
29
40
|
console.log(` Capabilities: ${setup.capabilities.join(', ')}`);
|
|
30
41
|
}
|
|
31
42
|
|
|
32
|
-
// Load working spec
|
|
33
|
-
const specPath = path.isAbsolute(specFile) ? specFile : path.join(process.cwd(), specFile);
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(specPath)) {
|
|
36
|
-
console.error(chalk.red(`\n❌ Working spec not found: ${specFile}`));
|
|
37
|
-
console.error(chalk.yellow('💡 Run: caws init to create a working spec'));
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const specContent = fs.readFileSync(specPath, 'utf8');
|
|
42
|
-
const spec = yaml.load(specContent);
|
|
43
|
-
|
|
44
43
|
// Parse current state from options
|
|
45
44
|
const currentState = options.currentState ? JSON.parse(options.currentState) : {};
|
|
46
45
|
const stateDescription = currentState.description || 'Starting implementation';
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CAWS Mode Command
|
|
3
|
+
* Manage CAWS complexity tiers and switch between modes
|
|
4
|
+
* @author @darianrosebrook
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const chalk = require('chalk');
|
|
8
|
+
const { safeAsync, outputResult } = require('../error-handler');
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
getTier,
|
|
12
|
+
getAvailableTiers,
|
|
13
|
+
getCurrentMode,
|
|
14
|
+
setCurrentMode,
|
|
15
|
+
displayTierComparison,
|
|
16
|
+
getTierRecommendation,
|
|
17
|
+
} = require('../config/modes');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Display current mode status
|
|
21
|
+
*/
|
|
22
|
+
function displayCurrentMode() {
|
|
23
|
+
console.log(chalk.bold.cyan('\n🔧 CAWS Current Mode'));
|
|
24
|
+
console.log(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
25
|
+
|
|
26
|
+
// This will be implemented when we load the current mode
|
|
27
|
+
console.log(chalk.yellow('Mode display will be implemented...'));
|
|
28
|
+
console.log('');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Display mode details
|
|
33
|
+
* @param {string} mode - Mode to display
|
|
34
|
+
*/
|
|
35
|
+
function displayModeDetails(mode) {
|
|
36
|
+
const tier = getTier(mode);
|
|
37
|
+
const tierColor = tier.color;
|
|
38
|
+
const icon = tier.icon;
|
|
39
|
+
|
|
40
|
+
console.log(chalk.bold.cyan(`\n📋 ${icon} ${tierColor(tier.name)} Mode Details`));
|
|
41
|
+
console.log(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
42
|
+
|
|
43
|
+
console.log(`${tierColor(tier.name)} - ${tier.description}\n`);
|
|
44
|
+
|
|
45
|
+
// Quality Requirements
|
|
46
|
+
console.log(chalk.bold('Quality Requirements:'));
|
|
47
|
+
console.log(chalk.gray(` Test Coverage: ${tier.qualityRequirements.testCoverage}%`));
|
|
48
|
+
console.log(chalk.gray(` Mutation Score: ${tier.qualityRequirements.mutationScore}%`));
|
|
49
|
+
console.log(chalk.gray(` Contracts: ${tier.qualityRequirements.contracts}\n`));
|
|
50
|
+
|
|
51
|
+
// Supported Risk Tiers
|
|
52
|
+
console.log(chalk.bold('Supported Risk Tiers:'));
|
|
53
|
+
tier.riskTiers.forEach((riskTier) => {
|
|
54
|
+
const riskColor =
|
|
55
|
+
riskTier === 'T1' ? chalk.red : riskTier === 'T2' ? chalk.yellow : chalk.green;
|
|
56
|
+
console.log(chalk.gray(` ${riskColor(riskTier)}`));
|
|
57
|
+
});
|
|
58
|
+
console.log('');
|
|
59
|
+
|
|
60
|
+
// Available Commands
|
|
61
|
+
console.log(chalk.bold('Available Commands:'));
|
|
62
|
+
Object.entries(tier.commands)
|
|
63
|
+
.filter(([, available]) => available)
|
|
64
|
+
.forEach(([command]) => {
|
|
65
|
+
console.log(chalk.gray(` ✅ caws ${command}`));
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const disabledCommands = Object.entries(tier.commands)
|
|
69
|
+
.filter(([, available]) => !available)
|
|
70
|
+
.map(([command]) => command);
|
|
71
|
+
|
|
72
|
+
if (disabledCommands.length > 0) {
|
|
73
|
+
console.log(chalk.bold('\nDisabled Commands:'));
|
|
74
|
+
disabledCommands.forEach((command) => {
|
|
75
|
+
console.log(chalk.gray(` ❌ caws ${command}`));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Interactive mode selection
|
|
84
|
+
* @returns {Promise<string>} Selected mode
|
|
85
|
+
*/
|
|
86
|
+
async function interactiveModeSelection() {
|
|
87
|
+
const readline = require('readline');
|
|
88
|
+
|
|
89
|
+
const rl = readline.createInterface({
|
|
90
|
+
input: process.stdin,
|
|
91
|
+
output: process.stdout,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return new Promise((resolve) => {
|
|
95
|
+
console.log(chalk.bold.cyan('\n🔧 Select CAWS Complexity Tier'));
|
|
96
|
+
console.log(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
97
|
+
|
|
98
|
+
const tiers = getAvailableTiers();
|
|
99
|
+
tiers.forEach((tier, index) => {
|
|
100
|
+
const tierConfig = getTier(tier);
|
|
101
|
+
const tierColor = tierConfig.color;
|
|
102
|
+
const icon = tierConfig.icon;
|
|
103
|
+
console.log(`${index + 1}. ${icon} ${tierColor(tier)} - ${tierConfig.description}`);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log('\nEnter your choice (1-3): ');
|
|
107
|
+
|
|
108
|
+
rl.on('line', (input) => {
|
|
109
|
+
const choice = parseInt(input.trim());
|
|
110
|
+
if (choice >= 1 && choice <= tiers.length) {
|
|
111
|
+
rl.close();
|
|
112
|
+
resolve(tiers[choice - 1]);
|
|
113
|
+
} else {
|
|
114
|
+
console.log(chalk.red('Invalid choice. Please enter 1-3:'));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Mode command handler
|
|
122
|
+
* @param {string} action - Action to perform (current, set, compare, recommend)
|
|
123
|
+
* @param {Object} options - Command options
|
|
124
|
+
*/
|
|
125
|
+
async function modeCommand(action, options = {}) {
|
|
126
|
+
return safeAsync(
|
|
127
|
+
async () => {
|
|
128
|
+
switch (action) {
|
|
129
|
+
case 'current': {
|
|
130
|
+
const currentMode = await getCurrentMode();
|
|
131
|
+
displayCurrentMode();
|
|
132
|
+
|
|
133
|
+
const tier = getTier(currentMode);
|
|
134
|
+
console.log(chalk.bold(`Current Mode: ${tier.icon} ${tier.color(currentMode)}`));
|
|
135
|
+
console.log(chalk.gray(`Description: ${tier.description}`));
|
|
136
|
+
console.log(
|
|
137
|
+
chalk.gray(
|
|
138
|
+
`Quality: ${tier.qualityRequirements.testCoverage}% coverage, ${tier.qualityRequirements.mutationScore}% mutation`
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
return outputResult({
|
|
143
|
+
command: 'mode current',
|
|
144
|
+
mode: currentMode,
|
|
145
|
+
tier: tier,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
case 'set': {
|
|
150
|
+
let targetMode;
|
|
151
|
+
|
|
152
|
+
if (options.mode) {
|
|
153
|
+
targetMode = options.mode;
|
|
154
|
+
} else if (options.interactive) {
|
|
155
|
+
targetMode = await interactiveModeSelection();
|
|
156
|
+
} else {
|
|
157
|
+
throw new Error('Mode not specified. Use --mode <mode> or --interactive');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!getAvailableTiers().includes(targetMode)) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
`Invalid mode: ${targetMode}. Available: ${getAvailableTiers().join(', ')}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const success = await setCurrentMode(targetMode);
|
|
167
|
+
if (!success) {
|
|
168
|
+
throw new Error(`Failed to set mode to ${targetMode}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
console.log(
|
|
172
|
+
chalk.green(
|
|
173
|
+
`✅ Successfully switched to ${getTier(targetMode).icon} ${getTier(targetMode).color(targetMode)} mode`
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return outputResult({
|
|
178
|
+
command: 'mode set',
|
|
179
|
+
mode: targetMode,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
case 'compare': {
|
|
184
|
+
displayTierComparison();
|
|
185
|
+
|
|
186
|
+
return outputResult({
|
|
187
|
+
command: 'mode compare',
|
|
188
|
+
tiers: getAvailableTiers(),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
case 'recommend': {
|
|
193
|
+
const projectInfo = {};
|
|
194
|
+
|
|
195
|
+
if (options.size) projectInfo.size = options.size;
|
|
196
|
+
if (options.teamSize) projectInfo.teamSize = parseInt(options.teamSize);
|
|
197
|
+
if (options.compliance) projectInfo.compliance = options.compliance === 'true';
|
|
198
|
+
if (options.audit) projectInfo.auditRequired = options.audit === 'true';
|
|
199
|
+
|
|
200
|
+
const recommendation = getTierRecommendation(projectInfo);
|
|
201
|
+
const recommendedTier = getTier(recommendation);
|
|
202
|
+
|
|
203
|
+
console.log(chalk.bold.cyan('\n🎯 Recommended CAWS Tier'));
|
|
204
|
+
console.log(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
205
|
+
|
|
206
|
+
console.log(
|
|
207
|
+
`${recommendedTier.icon} ${recommendedTier.color(recommendedTier.name)} - ${recommendedTier.description}`
|
|
208
|
+
);
|
|
209
|
+
console.log(
|
|
210
|
+
chalk.gray(
|
|
211
|
+
`Quality: ${recommendedTier.qualityRequirements.testCoverage}% coverage, ${recommendedTier.qualityRequirements.mutationScore}% mutation`
|
|
212
|
+
)
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
if (options.details) {
|
|
216
|
+
console.log('');
|
|
217
|
+
displayModeDetails(recommendation);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return outputResult({
|
|
221
|
+
command: 'mode recommend',
|
|
222
|
+
recommendation,
|
|
223
|
+
tier: recommendedTier,
|
|
224
|
+
projectInfo,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
case 'details': {
|
|
229
|
+
if (!options.mode) {
|
|
230
|
+
throw new Error('Mode not specified. Use --mode <mode>');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
displayModeDetails(options.mode);
|
|
234
|
+
|
|
235
|
+
return outputResult({
|
|
236
|
+
command: 'mode details',
|
|
237
|
+
mode: options.mode,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
default:
|
|
242
|
+
throw new Error(
|
|
243
|
+
`Unknown mode action: ${action}. Use: current, set, compare, recommend, details`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
`mode ${action}`,
|
|
248
|
+
true
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
module.exports = {
|
|
253
|
+
modeCommand,
|
|
254
|
+
getCurrentMode,
|
|
255
|
+
setCurrentMode,
|
|
256
|
+
displayCurrentMode,
|
|
257
|
+
displayModeDetails,
|
|
258
|
+
interactiveModeSelection,
|
|
259
|
+
};
|