@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.
- package/README.md +5 -6
- package/dist/commands/archive.d.ts +1 -0
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +114 -6
- package/dist/commands/burnup.d.ts.map +1 -1
- package/dist/commands/burnup.js +109 -10
- package/dist/commands/diagnose.js +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +185 -39
- package/dist/commands/mode.d.ts +2 -1
- package/dist/commands/mode.d.ts.map +1 -1
- package/dist/commands/mode.js +24 -14
- package/dist/commands/provenance.d.ts.map +1 -1
- package/dist/commands/provenance.js +216 -93
- package/dist/commands/quality-gates.d.ts.map +1 -1
- package/dist/commands/quality-gates.js +3 -1
- package/dist/commands/specs.d.ts.map +1 -1
- package/dist/commands/specs.js +184 -6
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +134 -10
- package/dist/commands/templates.js +2 -2
- package/dist/commands/worktree.d.ts +7 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +136 -0
- package/dist/config/lite-scope.d.ts +33 -0
- package/dist/config/lite-scope.d.ts.map +1 -0
- package/dist/config/lite-scope.js +158 -0
- package/dist/config/modes.d.ts +90 -51
- package/dist/config/modes.d.ts.map +1 -1
- package/dist/config/modes.js +26 -0
- package/dist/error-handler.d.ts +3 -16
- package/dist/error-handler.d.ts.map +1 -1
- package/dist/error-handler.js +6 -98
- package/dist/generators/jest-config-generator.d.ts +32 -0
- package/dist/generators/jest-config-generator.d.ts.map +1 -0
- package/dist/generators/jest-config-generator.js +242 -0
- package/dist/index.js +40 -7
- package/dist/minimal-cli.js +3 -1
- package/dist/scaffold/claude-hooks.d.ts +28 -0
- package/dist/scaffold/claude-hooks.d.ts.map +1 -0
- package/dist/scaffold/claude-hooks.js +344 -0
- package/dist/scaffold/index.d.ts +2 -0
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +96 -76
- package/dist/templates/.caws/schemas/scope.schema.json +52 -0
- package/dist/templates/.caws/schemas/working-spec.schema.json +1 -1
- package/dist/templates/.caws/schemas/worktrees.schema.json +36 -0
- package/dist/templates/.claude/README.md +190 -0
- package/dist/templates/.claude/hooks/audit.sh +96 -0
- package/dist/templates/.claude/hooks/block-dangerous.sh +123 -0
- package/dist/templates/.claude/hooks/lite-sprawl-check.sh +117 -0
- package/dist/templates/.claude/hooks/naming-check.sh +97 -0
- package/dist/templates/.claude/hooks/quality-check.sh +68 -0
- package/dist/templates/.claude/hooks/scan-secrets.sh +85 -0
- package/dist/templates/.claude/hooks/scope-guard.sh +192 -0
- package/dist/templates/.claude/hooks/simplification-guard.sh +92 -0
- package/dist/templates/.claude/hooks/validate-spec.sh +76 -0
- package/dist/templates/.claude/settings.json +95 -0
- package/dist/templates/.cursor/README.md +0 -3
- package/dist/templates/.github/copilot-instructions.md +82 -0
- package/dist/templates/.junie/guidelines.md +73 -0
- package/dist/templates/.vscode/launch.json +0 -27
- package/dist/templates/.windsurf/rules/caws-quality-standards.md +54 -0
- package/dist/templates/CLAUDE.md +101 -0
- package/dist/templates/agents.md +73 -1016
- package/dist/templates/docs/README.md +5 -5
- package/dist/test-analysis.d.ts +50 -1
- package/dist/test-analysis.d.ts.map +1 -1
- package/dist/test-analysis.js +203 -10
- package/dist/utils/error-categories.d.ts +52 -0
- package/dist/utils/error-categories.d.ts.map +1 -0
- package/dist/utils/error-categories.js +210 -0
- package/dist/utils/gitignore-updater.d.ts +1 -1
- package/dist/utils/gitignore-updater.d.ts.map +1 -1
- package/dist/utils/gitignore-updater.js +4 -0
- package/dist/utils/ide-detection.js +133 -0
- package/dist/utils/quality-gates-utils.d.ts +49 -0
- package/dist/utils/quality-gates-utils.d.ts.map +1 -0
- package/dist/utils/quality-gates-utils.js +402 -0
- package/dist/utils/typescript-detector.d.ts +8 -5
- package/dist/utils/typescript-detector.d.ts.map +1 -1
- package/dist/utils/typescript-detector.js +36 -90
- package/dist/validation/spec-validation.d.ts.map +1 -1
- package/dist/validation/spec-validation.js +59 -6
- package/dist/worktree/worktree-manager.d.ts +54 -0
- package/dist/worktree/worktree-manager.d.ts.map +1 -0
- package/dist/worktree/worktree-manager.js +378 -0
- package/package.json +9 -3
- package/templates/.caws/schemas/scope.schema.json +52 -0
- package/templates/.caws/schemas/working-spec.schema.json +1 -1
- package/templates/.caws/schemas/worktrees.schema.json +36 -0
- package/templates/.claude/README.md +190 -0
- package/templates/.claude/hooks/audit.sh +96 -0
- package/templates/.claude/hooks/block-dangerous.sh +123 -0
- package/templates/.claude/hooks/lite-sprawl-check.sh +117 -0
- package/templates/.claude/hooks/naming-check.sh +97 -0
- package/templates/.claude/hooks/quality-check.sh +68 -0
- package/templates/.claude/hooks/scan-secrets.sh +85 -0
- package/templates/.claude/hooks/scope-guard.sh +192 -0
- package/templates/.claude/hooks/simplification-guard.sh +92 -0
- package/templates/.claude/hooks/validate-spec.sh +76 -0
- package/templates/.claude/settings.json +95 -0
- package/templates/.cursor/README.md +0 -3
- package/templates/.github/copilot-instructions.md +82 -0
- package/templates/.junie/guidelines.md +73 -0
- package/templates/.vscode/launch.json +0 -27
- package/templates/.windsurf/rules/caws-quality-standards.md +54 -0
- package/templates/AGENTS.md +104 -0
- package/templates/CLAUDE.md +101 -0
- package/templates/docs/README.md +5 -5
- package/templates/.github/copilot/instructions.md +0 -311
- package/templates/agents.md +0 -1047
package/dist/commands/specs.js
CHANGED
|
@@ -164,9 +164,9 @@ async function createSpec(id, options = {}) {
|
|
|
164
164
|
console.log(chalk.blue(`📝 Creating spec with new name: ${newId}`));
|
|
165
165
|
return await createSpec(newId, { ...options, interactive: false });
|
|
166
166
|
} else if (answer === 'merge') {
|
|
167
|
-
|
|
168
|
-
console.log(chalk.blue('
|
|
169
|
-
return
|
|
167
|
+
// Merge new spec data with existing spec
|
|
168
|
+
console.log(chalk.blue('🔄 Merging with existing spec...'));
|
|
169
|
+
return await mergeSpec(id, options);
|
|
170
170
|
} else if (answer === 'override') {
|
|
171
171
|
console.log(chalk.yellow('⚠️ Overriding existing spec...'));
|
|
172
172
|
}
|
|
@@ -385,6 +385,133 @@ async function updateSpec(id, updates = {}) {
|
|
|
385
385
|
return true;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Merge new spec data with an existing spec
|
|
390
|
+
* Combines acceptance criteria, updates metadata, preserves history
|
|
391
|
+
* @param {string} id - Spec identifier
|
|
392
|
+
* @param {Object} options - Options including new spec data to merge
|
|
393
|
+
* @returns {Promise<Object>} Merged spec
|
|
394
|
+
*/
|
|
395
|
+
async function mergeSpec(id, options = {}) {
|
|
396
|
+
const existingSpec = await loadSpec(id);
|
|
397
|
+
if (!existingSpec) {
|
|
398
|
+
throw new Error(`Spec '${id}' not found`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
console.log(chalk.blue(`\n📋 Merging into existing spec: ${id}`));
|
|
402
|
+
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
403
|
+
|
|
404
|
+
// Show existing spec summary
|
|
405
|
+
console.log(chalk.gray(`Existing spec:`));
|
|
406
|
+
console.log(chalk.gray(` Title: ${existingSpec.title}`));
|
|
407
|
+
console.log(chalk.gray(` Status: ${existingSpec.status}`));
|
|
408
|
+
console.log(
|
|
409
|
+
chalk.gray(` Acceptance Criteria: ${existingSpec.acceptance_criteria?.length || 0}`)
|
|
410
|
+
);
|
|
411
|
+
console.log('');
|
|
412
|
+
|
|
413
|
+
// Prepare merge data from options
|
|
414
|
+
const {
|
|
415
|
+
title: newTitle,
|
|
416
|
+
description: newDescription,
|
|
417
|
+
acceptance_criteria: newCriteria,
|
|
418
|
+
mode: newMode,
|
|
419
|
+
risk_tier: newRiskTier,
|
|
420
|
+
} = options;
|
|
421
|
+
|
|
422
|
+
const mergedSpec = { ...existingSpec };
|
|
423
|
+
|
|
424
|
+
// Track what was merged
|
|
425
|
+
const mergeLog = [];
|
|
426
|
+
|
|
427
|
+
// Merge title (prefer new if provided)
|
|
428
|
+
if (newTitle && newTitle !== existingSpec.title) {
|
|
429
|
+
mergedSpec.title = newTitle;
|
|
430
|
+
mergeLog.push(`Title updated: "${existingSpec.title}" → "${newTitle}"`);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Merge description
|
|
434
|
+
if (newDescription) {
|
|
435
|
+
if (existingSpec.description) {
|
|
436
|
+
mergedSpec.description = `${existingSpec.description}\n\n---\n\n${newDescription}`;
|
|
437
|
+
mergeLog.push('Description appended');
|
|
438
|
+
} else {
|
|
439
|
+
mergedSpec.description = newDescription;
|
|
440
|
+
mergeLog.push('Description added');
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Merge acceptance criteria (append new ones, avoid duplicates)
|
|
445
|
+
if (newCriteria && Array.isArray(newCriteria) && newCriteria.length > 0) {
|
|
446
|
+
const existingCriteria = existingSpec.acceptance_criteria || [];
|
|
447
|
+
const existingIds = new Set(existingCriteria.map((c) => c.id));
|
|
448
|
+
|
|
449
|
+
const criteriaToAdd = newCriteria.filter((c) => !existingIds.has(c.id));
|
|
450
|
+
if (criteriaToAdd.length > 0) {
|
|
451
|
+
mergedSpec.acceptance_criteria = [...existingCriteria, ...criteriaToAdd];
|
|
452
|
+
mergeLog.push(`Added ${criteriaToAdd.length} new acceptance criteria`);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// Also update the 'acceptance' array if it exists
|
|
456
|
+
if (existingSpec.acceptance) {
|
|
457
|
+
const existingAcceptIds = new Set(existingSpec.acceptance.map((a) => a.id));
|
|
458
|
+
const acceptToAdd = newCriteria.filter((c) => !existingAcceptIds.has(c.id));
|
|
459
|
+
if (acceptToAdd.length > 0) {
|
|
460
|
+
mergedSpec.acceptance = [...existingSpec.acceptance, ...acceptToAdd];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Merge mode (prefer higher tier if both provided)
|
|
466
|
+
if (newMode && newMode !== existingSpec.mode) {
|
|
467
|
+
// Mode priority: crisis > standard > minimal
|
|
468
|
+
const modePriority = { minimal: 1, standard: 2, crisis: 3 };
|
|
469
|
+
if ((modePriority[newMode] || 0) > (modePriority[existingSpec.mode] || 0)) {
|
|
470
|
+
mergedSpec.mode = newMode;
|
|
471
|
+
mergeLog.push(`Mode upgraded: ${existingSpec.mode} → ${newMode}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Merge risk tier (prefer higher risk if both provided)
|
|
476
|
+
if (newRiskTier && newRiskTier !== existingSpec.risk_tier) {
|
|
477
|
+
// Risk priority: T1 > T2 > T3
|
|
478
|
+
const riskPriority = { T3: 1, T2: 2, T1: 3, 3: 1, 2: 2, 1: 3 };
|
|
479
|
+
if ((riskPriority[newRiskTier] || 0) > (riskPriority[existingSpec.risk_tier] || 0)) {
|
|
480
|
+
mergedSpec.risk_tier = newRiskTier;
|
|
481
|
+
mergeLog.push(`Risk tier updated: ${existingSpec.risk_tier} → ${newRiskTier}`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Update metadata
|
|
486
|
+
mergedSpec.updated_at = new Date().toISOString();
|
|
487
|
+
|
|
488
|
+
// Add merge history entry
|
|
489
|
+
if (!mergedSpec.history) {
|
|
490
|
+
mergedSpec.history = [];
|
|
491
|
+
}
|
|
492
|
+
mergedSpec.history.push({
|
|
493
|
+
action: 'merge',
|
|
494
|
+
timestamp: new Date().toISOString(),
|
|
495
|
+
changes: mergeLog,
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// Save merged spec
|
|
499
|
+
await updateSpec(id, mergedSpec);
|
|
500
|
+
|
|
501
|
+
// Display merge results
|
|
502
|
+
console.log(chalk.green('✅ Merge completed:'));
|
|
503
|
+
if (mergeLog.length > 0) {
|
|
504
|
+
mergeLog.forEach((change) => {
|
|
505
|
+
console.log(chalk.gray(` • ${change}`));
|
|
506
|
+
});
|
|
507
|
+
} else {
|
|
508
|
+
console.log(chalk.gray(' • No changes needed (specs were identical)'));
|
|
509
|
+
}
|
|
510
|
+
console.log('');
|
|
511
|
+
|
|
512
|
+
return mergedSpec;
|
|
513
|
+
}
|
|
514
|
+
|
|
388
515
|
/**
|
|
389
516
|
* Delete a spec file
|
|
390
517
|
* @param {string} id - Spec identifier
|
|
@@ -544,9 +671,12 @@ async function migrateFromLegacy(options = {}, createSpecFn = createSpec) {
|
|
|
544
671
|
let selectedFeatures = features;
|
|
545
672
|
|
|
546
673
|
if (options.interactive) {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
674
|
+
selectedFeatures = await selectFeaturesInteractively(features);
|
|
675
|
+
if (selectedFeatures.length === 0) {
|
|
676
|
+
console.log(chalk.yellow('⚠️ No features selected. Migration cancelled.'));
|
|
677
|
+
return { migrated: 0, total: features.length, createdSpecs: [], legacySpec: legacySpec.id };
|
|
678
|
+
}
|
|
679
|
+
console.log(chalk.blue(`\n📋 Migrating ${selectedFeatures.length} selected features`));
|
|
550
680
|
}
|
|
551
681
|
|
|
552
682
|
if (options.features && options.features.length > 0) {
|
|
@@ -614,6 +744,54 @@ async function migrateFromLegacy(options = {}, createSpecFn = createSpec) {
|
|
|
614
744
|
};
|
|
615
745
|
}
|
|
616
746
|
|
|
747
|
+
/**
|
|
748
|
+
* Interactive feature selection for migration
|
|
749
|
+
* @param {Array} features - Array of suggested features
|
|
750
|
+
* @returns {Promise<Array>} Selected features
|
|
751
|
+
*/
|
|
752
|
+
async function selectFeaturesInteractively(features) {
|
|
753
|
+
const readline = require('readline');
|
|
754
|
+
const rl = readline.createInterface({
|
|
755
|
+
input: process.stdin,
|
|
756
|
+
output: process.stdout,
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
console.log(chalk.cyan('\n📋 Select features to migrate:\n'));
|
|
760
|
+
features.forEach((f, i) => {
|
|
761
|
+
const scope = f.scope?.in?.join(', ') || 'N/A';
|
|
762
|
+
console.log(` ${chalk.yellow(i + 1)}. ${chalk.bold(f.id || f.name)} - ${f.title || f.description}`);
|
|
763
|
+
console.log(chalk.gray(` Scope: ${scope}`));
|
|
764
|
+
});
|
|
765
|
+
console.log(chalk.cyan(`\nEnter numbers separated by commas, or 'all' for all features:`));
|
|
766
|
+
console.log(chalk.gray(`Example: 1,3,5 or all`));
|
|
767
|
+
|
|
768
|
+
try {
|
|
769
|
+
const answer = await question(rl, '> ');
|
|
770
|
+
const trimmed = answer.trim().toLowerCase();
|
|
771
|
+
|
|
772
|
+
if (trimmed === 'all' || trimmed === '*') {
|
|
773
|
+
return features;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (trimmed === '' || trimmed === 'none' || trimmed === 'q' || trimmed === 'quit') {
|
|
777
|
+
return [];
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// Parse comma-separated numbers
|
|
781
|
+
const indices = trimmed
|
|
782
|
+
.split(',')
|
|
783
|
+
.map(n => parseInt(n.trim(), 10) - 1)
|
|
784
|
+
.filter(i => !isNaN(i) && i >= 0 && i < features.length);
|
|
785
|
+
|
|
786
|
+
// Remove duplicates and sort
|
|
787
|
+
const uniqueIndices = [...new Set(indices)].sort((a, b) => a - b);
|
|
788
|
+
|
|
789
|
+
return features.filter((_, i) => uniqueIndices.includes(i));
|
|
790
|
+
} finally {
|
|
791
|
+
await closeReadline(rl);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
617
795
|
/**
|
|
618
796
|
* Ask user how to resolve spec creation conflicts
|
|
619
797
|
* @returns {Promise<string>} User's choice: 'cancel', 'rename', 'merge', 'override'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.js"],"names":[],"mappings":"AA02BA;;;GAGG;AACH,2DA+IC;AA/+BD;;;;GAIG;AACH,2CAHW,MAAM,GACJ,OAAO,CAAC,MAAO,IAAI,CAAC,CAahC;AAgBD;;;GAGG;AACH,iCAFa,OAAO,KAAQ,CAgC3B;AAED;;;GAGG;AACH,uCAFa,OAAO,KAAQ,CA+B3B;AAED;;;GAGG;AACH,oCAFa,OAAO,KAAQ,CA0D3B;AAED;;;GAGG;AACH,qCAFa,OAAO,KAAQ,CAO3B;AA8HD;;;GAGG;AACH,+CAgGC;AAED;;;;;GAKG;AACH,4DAHW,MAAM,GACJ,MAAM,EAAE,CAoCpB"}
|
package/dist/commands/status.js
CHANGED
|
@@ -8,6 +8,7 @@ const fs = require('fs-extra');
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const yaml = require('js-yaml');
|
|
10
10
|
const chalk = require('chalk');
|
|
11
|
+
// child_process removed - execSync no longer used directly
|
|
11
12
|
const { safeAsync, outputResult } = require('../error-handler');
|
|
12
13
|
const { parallel } = require('../utils/async-utils');
|
|
13
14
|
|
|
@@ -181,14 +182,114 @@ async function loadWaiverStatus() {
|
|
|
181
182
|
* @returns {Promise<Object>} Quality gates status
|
|
182
183
|
*/
|
|
183
184
|
async function checkQualityGates() {
|
|
184
|
-
// For now, return a placeholder
|
|
185
|
-
// Quality gates are available via CLI or MCP
|
|
186
185
|
return {
|
|
187
186
|
checked: false,
|
|
188
187
|
message: 'Run: caws quality-gates or use MCP tool caws_quality_gates_run for full gate status',
|
|
189
188
|
};
|
|
190
189
|
}
|
|
191
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Get test coverage from coverage reports
|
|
193
|
+
* Looks for common coverage report locations and formats
|
|
194
|
+
* @returns {Promise<Object>} Coverage data with percentage and details
|
|
195
|
+
*/
|
|
196
|
+
async function getTestCoverage() {
|
|
197
|
+
const coverageLocations = [
|
|
198
|
+
// Jest/Istanbul coverage
|
|
199
|
+
{ path: 'coverage/coverage-summary.json', type: 'istanbul' },
|
|
200
|
+
{ path: 'coverage/lcov-report/index.html', type: 'lcov-html' },
|
|
201
|
+
{ path: 'coverage/coverage-final.json', type: 'istanbul-final' },
|
|
202
|
+
// NYC coverage
|
|
203
|
+
{ path: '.nyc_output/coverage-summary.json', type: 'nyc' },
|
|
204
|
+
// C8 coverage
|
|
205
|
+
{ path: 'coverage/c8/coverage-summary.json', type: 'c8' },
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
for (const loc of coverageLocations) {
|
|
210
|
+
const coveragePath = path.join(process.cwd(), loc.path);
|
|
211
|
+
if (await fs.pathExists(coveragePath)) {
|
|
212
|
+
if (loc.type === 'istanbul' || loc.type === 'nyc' || loc.type === 'c8') {
|
|
213
|
+
const content = await fs.readFile(coveragePath, 'utf8');
|
|
214
|
+
const data = JSON.parse(content);
|
|
215
|
+
|
|
216
|
+
// Istanbul/NYC format has a "total" key with coverage percentages
|
|
217
|
+
if (data.total) {
|
|
218
|
+
const lines = data.total.lines?.pct || 0;
|
|
219
|
+
const statements = data.total.statements?.pct || 0;
|
|
220
|
+
const branches = data.total.branches?.pct || 0;
|
|
221
|
+
const functions = data.total.functions?.pct || 0;
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
available: true,
|
|
225
|
+
percentage: Math.round((lines + statements + branches + functions) / 4),
|
|
226
|
+
lines: Math.round(lines),
|
|
227
|
+
statements: Math.round(statements),
|
|
228
|
+
branches: Math.round(branches),
|
|
229
|
+
functions: Math.round(functions),
|
|
230
|
+
source: loc.path,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
} else if (loc.type === 'istanbul-final') {
|
|
234
|
+
// coverage-final.json has per-file data, need to aggregate
|
|
235
|
+
const content = await fs.readFile(coveragePath, 'utf8');
|
|
236
|
+
const data = JSON.parse(content);
|
|
237
|
+
|
|
238
|
+
let totalStatements = 0;
|
|
239
|
+
let coveredStatements = 0;
|
|
240
|
+
|
|
241
|
+
for (const file of Object.values(data)) {
|
|
242
|
+
const s = file.s || {};
|
|
243
|
+
for (const count of Object.values(s)) {
|
|
244
|
+
totalStatements++;
|
|
245
|
+
if (count > 0) coveredStatements++;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (totalStatements > 0) {
|
|
250
|
+
const percentage = Math.round((coveredStatements / totalStatements) * 100);
|
|
251
|
+
return {
|
|
252
|
+
available: true,
|
|
253
|
+
percentage,
|
|
254
|
+
source: loc.path,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Try running test coverage command if no reports found
|
|
262
|
+
try {
|
|
263
|
+
// Check if package.json has a coverage script
|
|
264
|
+
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
265
|
+
if (await fs.pathExists(pkgPath)) {
|
|
266
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
|
|
267
|
+
if (pkg.scripts && (pkg.scripts.coverage || pkg.scripts['test:coverage'])) {
|
|
268
|
+
return {
|
|
269
|
+
available: false,
|
|
270
|
+
percentage: null,
|
|
271
|
+
message: 'Run npm run coverage to generate coverage report',
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
} catch {
|
|
276
|
+
// Ignore package.json errors
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
available: false,
|
|
281
|
+
percentage: null,
|
|
282
|
+
message: 'No coverage report found',
|
|
283
|
+
};
|
|
284
|
+
} catch (error) {
|
|
285
|
+
return {
|
|
286
|
+
available: false,
|
|
287
|
+
percentage: null,
|
|
288
|
+
message: `Error reading coverage: ${error.message}`,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
192
293
|
/**
|
|
193
294
|
* Get time since last update
|
|
194
295
|
* @param {string} timestamp - ISO timestamp
|
|
@@ -388,7 +489,7 @@ function getProgressColor(percentage) {
|
|
|
388
489
|
* @param {Object} data - Status data
|
|
389
490
|
* @param {string} currentMode - Current CAWS mode
|
|
390
491
|
*/
|
|
391
|
-
function displayVisualStatus(data, currentMode) {
|
|
492
|
+
async function displayVisualStatus(data, currentMode) {
|
|
392
493
|
const { spec, specs, hooks, provenance, waivers, gates } = data;
|
|
393
494
|
const modes = require('../config/modes');
|
|
394
495
|
const tierConfig = modes.getTier(currentMode);
|
|
@@ -497,12 +598,35 @@ function displayVisualStatus(data, currentMode) {
|
|
|
497
598
|
);
|
|
498
599
|
}
|
|
499
600
|
|
|
500
|
-
// Test Coverage
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
601
|
+
// Test Coverage
|
|
602
|
+
const coverage = await getTestCoverage();
|
|
603
|
+
if (coverage.available && coverage.percentage !== null) {
|
|
604
|
+
const coverageColor =
|
|
605
|
+
coverage.percentage >= 80
|
|
606
|
+
? chalk.green
|
|
607
|
+
: coverage.percentage >= 50
|
|
608
|
+
? chalk.yellow
|
|
609
|
+
: chalk.red;
|
|
610
|
+
const coverageBar = createProgressBar(coverage.percentage, 100);
|
|
611
|
+
console.log(
|
|
612
|
+
chalk.gray(
|
|
613
|
+
` Test Coverage: ${coverageColor(`${coverage.percentage}%`)} ${coverageBar}`
|
|
614
|
+
)
|
|
615
|
+
);
|
|
616
|
+
if (coverage.lines !== undefined) {
|
|
617
|
+
console.log(
|
|
618
|
+
chalk.gray(
|
|
619
|
+
` Lines: ${coverage.lines}% | Branches: ${coverage.branches}% | Functions: ${coverage.functions}%`
|
|
620
|
+
)
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
} else {
|
|
624
|
+
console.log(
|
|
625
|
+
chalk.gray(
|
|
626
|
+
` Test Coverage: ${chalk.yellow('N/A')} ${createProgressBar(0, 100)} ${chalk.gray(coverage.message || 'No report')}`
|
|
627
|
+
)
|
|
628
|
+
);
|
|
629
|
+
}
|
|
506
630
|
|
|
507
631
|
// Risk Tier Indicator
|
|
508
632
|
const riskColor =
|
|
@@ -839,7 +963,7 @@ async function statusCommand(options = {}) {
|
|
|
839
963
|
console.log(JSON.stringify(result, null, 2));
|
|
840
964
|
} else {
|
|
841
965
|
// Visual output
|
|
842
|
-
displayVisualStatus(
|
|
966
|
+
await displayVisualStatus(
|
|
843
967
|
{
|
|
844
968
|
spec,
|
|
845
969
|
specs,
|
|
@@ -149,7 +149,7 @@ function listTemplates() {
|
|
|
149
149
|
const totalTemplates = Object.keys(templates).length;
|
|
150
150
|
|
|
151
151
|
if (totalAvailable < totalTemplates) {
|
|
152
|
-
console.log(chalk.yellow(`\n⏳ ${totalTemplates - totalAvailable} templates
|
|
152
|
+
console.log(chalk.yellow(`\n⏳ ${totalTemplates - totalAvailable} additional templates in development`));
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
console.log(chalk.blue('\n📚 Learn more:'));
|
|
@@ -181,7 +181,7 @@ function showTemplateInfo(templateId) {
|
|
|
181
181
|
console.log(chalk.white(`Risk Tier: ${template.tier}`));
|
|
182
182
|
console.log(
|
|
183
183
|
chalk.white(
|
|
184
|
-
`Status: ${template.available ? chalk.green('Available') : chalk.yellow('
|
|
184
|
+
`Status: ${template.available ? chalk.green('Available') : chalk.yellow('In Development')}`
|
|
185
185
|
)
|
|
186
186
|
);
|
|
187
187
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/commands/worktree.js"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,4CAHW,MAAM,gCAuBhB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CAWS Worktree CLI Command
|
|
3
|
+
* Manages git worktrees for agent scope isolation
|
|
4
|
+
* @author @darianrosebrook
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const chalk = require('chalk');
|
|
8
|
+
const {
|
|
9
|
+
createWorktree,
|
|
10
|
+
listWorktrees,
|
|
11
|
+
destroyWorktree,
|
|
12
|
+
pruneWorktrees,
|
|
13
|
+
} = require('../worktree/worktree-manager');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Handle worktree subcommands
|
|
17
|
+
* @param {string} subcommand - Subcommand name
|
|
18
|
+
* @param {Object} options - Command options
|
|
19
|
+
*/
|
|
20
|
+
async function worktreeCommand(subcommand, options = {}) {
|
|
21
|
+
try {
|
|
22
|
+
switch (subcommand) {
|
|
23
|
+
case 'create':
|
|
24
|
+
return handleCreate(options);
|
|
25
|
+
case 'list':
|
|
26
|
+
return handleList();
|
|
27
|
+
case 'destroy':
|
|
28
|
+
return handleDestroy(options);
|
|
29
|
+
case 'prune':
|
|
30
|
+
return handlePrune(options);
|
|
31
|
+
default:
|
|
32
|
+
console.error(chalk.red(`Unknown worktree subcommand: ${subcommand}`));
|
|
33
|
+
console.log(chalk.blue('Available: create, list, destroy, prune'));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(chalk.red(`❌ ${error.message}`));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handleCreate(options) {
|
|
43
|
+
const { name, scope, baseBranch, specId } = options;
|
|
44
|
+
|
|
45
|
+
if (!name) {
|
|
46
|
+
console.error(chalk.red('❌ Worktree name is required'));
|
|
47
|
+
console.log(chalk.blue('Usage: caws worktree create <name> [--scope "src/auth/**"]'));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(chalk.cyan(`🌿 Creating worktree: ${name}`));
|
|
52
|
+
|
|
53
|
+
const entry = createWorktree(name, { scope, baseBranch, specId });
|
|
54
|
+
|
|
55
|
+
console.log(chalk.green(`✅ Worktree created`));
|
|
56
|
+
console.log(chalk.gray(` Path: ${entry.path}`));
|
|
57
|
+
console.log(chalk.gray(` Branch: ${entry.branch}`));
|
|
58
|
+
if (entry.scope) console.log(chalk.gray(` Scope: ${entry.scope}`));
|
|
59
|
+
if (entry.specId) console.log(chalk.gray(` Spec: ${entry.specId}`));
|
|
60
|
+
console.log(chalk.blue(`\n💡 cd ${entry.path} to start working in the isolated worktree`));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function handleList() {
|
|
64
|
+
const entries = listWorktrees();
|
|
65
|
+
|
|
66
|
+
if (entries.length === 0) {
|
|
67
|
+
console.log(chalk.gray('No worktrees registered.'));
|
|
68
|
+
console.log(chalk.blue('Create one with: caws worktree create <name>'));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log(chalk.bold.cyan('🌿 CAWS Worktrees'));
|
|
73
|
+
console.log(chalk.cyan('━'.repeat(70)));
|
|
74
|
+
console.log(
|
|
75
|
+
chalk.bold(
|
|
76
|
+
'Name'.padEnd(20) +
|
|
77
|
+
'Status'.padEnd(12) +
|
|
78
|
+
'Branch'.padEnd(20) +
|
|
79
|
+
'Scope'
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
console.log(chalk.gray('─'.repeat(70)));
|
|
83
|
+
|
|
84
|
+
for (const entry of entries) {
|
|
85
|
+
const statusColor =
|
|
86
|
+
entry.status === 'active'
|
|
87
|
+
? chalk.green
|
|
88
|
+
: entry.status === 'destroyed'
|
|
89
|
+
? chalk.gray
|
|
90
|
+
: chalk.yellow;
|
|
91
|
+
|
|
92
|
+
console.log(
|
|
93
|
+
entry.name.padEnd(20) +
|
|
94
|
+
statusColor(entry.status.padEnd(12)) +
|
|
95
|
+
(entry.branch || '').padEnd(20) +
|
|
96
|
+
(entry.scope || '-')
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log('');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function handleDestroy(options) {
|
|
104
|
+
const { name, deleteBranch, force } = options;
|
|
105
|
+
|
|
106
|
+
if (!name) {
|
|
107
|
+
console.error(chalk.red('❌ Worktree name is required'));
|
|
108
|
+
console.log(chalk.blue('Usage: caws worktree destroy <name> [--delete-branch] [--force]'));
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log(chalk.cyan(`🗑️ Destroying worktree: ${name}`));
|
|
113
|
+
destroyWorktree(name, { deleteBranch, force });
|
|
114
|
+
console.log(chalk.green(`✅ Worktree '${name}' destroyed`));
|
|
115
|
+
if (deleteBranch) {
|
|
116
|
+
console.log(chalk.gray(' Branch also deleted'));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function handlePrune(options) {
|
|
121
|
+
const maxAge = options.maxAge !== undefined ? parseInt(options.maxAge, 10) : 30;
|
|
122
|
+
|
|
123
|
+
console.log(chalk.cyan(`🧹 Pruning worktrees (max age: ${maxAge} days)`));
|
|
124
|
+
const pruned = pruneWorktrees({ maxAgeDays: maxAge });
|
|
125
|
+
|
|
126
|
+
if (pruned.length === 0) {
|
|
127
|
+
console.log(chalk.gray('Nothing to prune.'));
|
|
128
|
+
} else {
|
|
129
|
+
console.log(chalk.green(`✅ Pruned ${pruned.length} worktree(s):`));
|
|
130
|
+
for (const entry of pruned) {
|
|
131
|
+
console.log(chalk.gray(` - ${entry.name} (created ${entry.createdAt})`));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
module.exports = { worktreeCommand };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load lite scope configuration from .caws/scope.json
|
|
3
|
+
* @param {string} [projectRoot] - Project root directory (defaults to cwd)
|
|
4
|
+
* @returns {Object} Scope configuration (defaults if file not found)
|
|
5
|
+
*/
|
|
6
|
+
export function loadLiteScope(projectRoot?: string): any;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a file path is allowed by the scope configuration
|
|
9
|
+
* @param {string} filePath - Relative file path to check
|
|
10
|
+
* @param {Object} [scope] - Scope configuration (loads from disk if not provided)
|
|
11
|
+
* @param {string} [projectRoot] - Project root directory
|
|
12
|
+
* @returns {boolean} Whether the path is allowed
|
|
13
|
+
*/
|
|
14
|
+
export function isPathAllowed(filePath: string, scope?: any, projectRoot?: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a filename or path matches any banned pattern
|
|
17
|
+
* @param {string} filePath - File path to check
|
|
18
|
+
* @param {Object} [scope] - Scope configuration (loads from disk if not provided)
|
|
19
|
+
* @param {string} [projectRoot] - Project root directory
|
|
20
|
+
* @returns {{ matched: boolean, pattern: string|null, category: string|null }} Match result
|
|
21
|
+
*/
|
|
22
|
+
export function matchesBannedPattern(filePath: string, scope?: any, projectRoot?: string): {
|
|
23
|
+
matched: boolean;
|
|
24
|
+
pattern: string | null;
|
|
25
|
+
category: string | null;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Default scope configuration for lite mode
|
|
29
|
+
* @returns {Object} Default scope.json contents
|
|
30
|
+
*/
|
|
31
|
+
export function getLiteScopeDefaults(): any;
|
|
32
|
+
export const SCOPE_FILE: ".caws/scope.json";
|
|
33
|
+
//# sourceMappingURL=lite-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lite-scope.d.ts","sourceRoot":"","sources":["../../src/config/lite-scope.js"],"names":[],"mappings":"AA8BA;;;;GAIG;AACH,4CAHW,MAAM,OAgChB;AAED;;;;;;GAMG;AACH,wCALW,MAAM,6BAEN,MAAM,GACJ,OAAO,CAiCnB;AAED;;;;;;GAMG;AACH,+CALW,MAAM,6BAEN,MAAM,GACJ;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAC,IAAI,CAAA;CAAE,CAsC7E;AAzID;;;GAGG;AACH,4CAYC;AAlBD,yBAAmB,kBAAkB,CAAC"}
|