UNPKG

agentic-qe

Version:

Agentic Quality Engineering Fleet System - AI-driven quality management platform

155 lines 6.94 kB
"use strict"; /** * Config Validate Command - Validate configuration against JSON schema */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.configValidate = exports.ConfigValidateCommand = void 0; const fs = __importStar(require("fs-extra")); const chalk_1 = __importDefault(require("chalk")); const ora_1 = __importDefault(require("ora")); const ajv_1 = __importDefault(require("ajv")); const ajv_formats_1 = __importDefault(require("ajv-formats")); const schema_1 = require("./schema"); class ConfigValidateCommand { static async execute(options) { const spinner = (0, ora_1.default)('Validating configuration...').start(); try { // Determine config file path const configPath = options.config || this.DEFAULT_CONFIG_PATH; // Check if config exists if (!(await fs.pathExists(configPath))) { throw new Error(`Configuration file not found: ${configPath}`); } // Read configuration const config = await fs.readJson(configPath); // Initialize AJV with strict mode const ajv = new ajv_1.default({ allErrors: true, verbose: true, strict: true, strictTypes: false // Allow union types }); (0, ajv_formats_1.default)(ajv); // Compile schema const validate = ajv.compile(schema_1.AQEConfigSchema); // Validate configuration const valid = validate(config); const result = { valid, errors: [], warnings: [] }; if (!valid && validate.errors) { result.errors = validate.errors.map((err) => { const path = err.instancePath || err.schemaPath; const message = err.message || 'Unknown error'; return `${path}: ${message}`; }); } // Perform additional validation checks if (valid) { const warnings = this.performAdditionalChecks(config); result.warnings = warnings; } // Include schema in detailed mode if (options.detailed) { result.schema = schema_1.AQEConfigSchema; } spinner.stop(); // Display results if (result.valid) { console.log(chalk_1.default.green('\n✅ Configuration is valid!\n')); if (result.warnings && result.warnings.length > 0) { console.log(chalk_1.default.yellow('⚠️ Warnings:')); result.warnings.forEach((warning) => { console.log(chalk_1.default.yellow(` • ${warning}`)); }); } console.log(chalk_1.default.blue('\n📊 Configuration Summary:')); console.log(chalk_1.default.gray(` Version: ${config.version}`)); console.log(chalk_1.default.gray(` Topology: ${config.fleet.topology}`)); console.log(chalk_1.default.gray(` Max Agents: ${config.fleet.maxAgents}`)); if (config.fleet.testingFocus) { console.log(chalk_1.default.gray(` Testing Focus: ${config.fleet.testingFocus.join(', ')}`)); } } else { console.log(chalk_1.default.red('\n❌ Configuration validation failed!\n')); console.log(chalk_1.default.red('Errors:')); result.errors.forEach((error) => { console.log(chalk_1.default.red(` • ${error}`)); }); } if (options.detailed) { console.log(chalk_1.default.blue('\n📋 Schema Details:')); console.log(chalk_1.default.gray(JSON.stringify(schema_1.AQEConfigSchema, null, 2).slice(0, 500) + '...')); } return result; } catch (error) { spinner.fail(chalk_1.default.red('Validation failed')); throw error; } } static performAdditionalChecks(config) { const warnings = []; // Check if testingFocus is empty if (!config.fleet.testingFocus || config.fleet.testingFocus.length === 0) { warnings.push('No testing focus areas specified'); } // Check if environments is empty if (!config.fleet.environments || config.fleet.environments.length === 0) { warnings.push('No target environments specified'); } // Check for very low agent count if (config.fleet.maxAgents < 5) { warnings.push('Low agent count may impact parallel execution performance'); } // Check for very high agent count without mesh topology if (config.fleet.maxAgents > 30 && config.fleet.topology !== 'mesh') { warnings.push('High agent count recommended to use mesh topology for better coordination'); } // Check if security is disabled in production-like setup if (config.fleet.environments?.includes('production') && (!config.features?.security || config.features.security === false)) { warnings.push('Security features disabled for production environment'); } return warnings; } } exports.ConfigValidateCommand = ConfigValidateCommand; ConfigValidateCommand.DEFAULT_CONFIG_PATH = '.agentic-qe/config/aqe.config.json'; /** * Wrapper function for CLI usage */ async function configValidate(options) { return ConfigValidateCommand.execute(options); } exports.configValidate = configValidate; //# sourceMappingURL=validate.js.map