context-forge
Version:
AI orchestration platform with autonomous teams, enhancement planning, migration tools, 25+ slash commands, checkpoints & hooks. Multi-IDE: Claude, Cursor, Windsurf, Cline, Copilot
100 lines ⢠4.99 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const inquirer_1 = __importDefault(require("inquirer"));
const validationExecutor_1 = require("../services/validationExecutor");
const validationCommands_1 = require("../data/validationCommands");
exports.validateCommand = new commander_1.Command('validate')
.description('Run validation commands for your project')
.option('-p, --path <path>', 'Project path', process.cwd())
.option('-l, --levels <levels>', 'Comma-separated list of validation levels to run')
.option('-a, --all', 'Run all validation levels including optional ones')
.option('-r, --report', 'Show detailed validation report')
.action(async (options) => {
try {
console.log(chalk_1.default.bold.blue('š Context Forge - Validation Runner\n'));
// Check if project has been initialized
const configPath = path_1.default.join(options.path, '.context-forge', 'config.json');
if (!(await fs_extra_1.default.pathExists(configPath))) {
console.error(chalk_1.default.red('ā No context-forge configuration found.'));
console.log(chalk_1.default.yellow('Run "context-forge init" first to initialize your project.'));
process.exit(1);
}
// Load project configuration
const config = await fs_extra_1.default.readJson(configPath);
console.log(chalk_1.default.gray(`Project: ${config.projectName}`));
console.log(chalk_1.default.gray(`Tech Stack: ${Object.entries(config.techStack)
.filter(([_, value]) => value)
.map(([key, value]) => `${key}: ${value}`)
.join(', ')}\n`));
// Determine which validation levels to run
let levelsToRun = [];
if (options.levels) {
levelsToRun = options.levels.split(',').map((l) => l.trim());
}
else if (options.all) {
levelsToRun = Object.keys(validationCommands_1.validationLevels);
}
else {
// Interactive selection
const { selectedLevels } = await inquirer_1.default.prompt([
{
type: 'checkbox',
name: 'selectedLevels',
message: 'Select validation levels to run:',
choices: Object.entries(validationCommands_1.validationLevels).map(([key, info]) => ({
name: `${info.name} - ${info.description}`,
value: key,
checked: info.critical,
})),
},
]);
levelsToRun = selectedLevels;
}
if (levelsToRun.length === 0) {
console.log(chalk_1.default.yellow('No validation levels selected.'));
return;
}
// Run validation
const executor = new validationExecutor_1.ValidationExecutor(options.path, config);
const report = await executor.runValidation(levelsToRun);
// Show detailed report if requested
if (options.report) {
console.log(chalk_1.default.bold.blue('\nš Detailed Report\n'));
report.results.forEach((result) => {
const icon = result.success ? 'ā
' : 'ā';
const color = result.success ? chalk_1.default.green : chalk_1.default.red;
console.log(color(`${icon} ${result.level}`));
console.log(chalk_1.default.gray(` Command: ${result.command}`));
console.log(chalk_1.default.gray(` Duration: ${result.duration}ms`));
if (!result.success && result.error) {
console.log(chalk_1.default.red(` Error: ${result.error.split('\n')[0]}`));
}
console.log();
});
}
// Save validation gate if PRP is enabled
if (config.extras.prp) {
const validationGate = await executor.generateValidationGate();
const prpDir = path_1.default.join(options.path, 'PRPs');
await fs_extra_1.default.ensureDir(prpDir);
await fs_extra_1.default.writeFile(path_1.default.join(prpDir, 'validation-gate.md'), validationGate);
console.log(chalk_1.default.green('\nā Validation gate saved to PRPs/validation-gate.md'));
}
// Exit with appropriate code
process.exit(report.overallSuccess ? 0 : 1);
}
catch (error) {
console.error(chalk_1.default.red('\nā Validation failed:'));
console.error(error);
process.exit(1);
}
});
//# sourceMappingURL=validate.js.map