UNPKG

agentic-qe

Version:

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

140 lines 5.59 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createQueueCommand = void 0; const commander_1 = require("commander"); const chalk_1 = __importDefault(require("chalk")); const testQueue = []; function createQueueCommand() { const command = new commander_1.Command('queue'); command.description('Manage test queue for scheduled execution'); // Status subcommand command .command('status') .description('Show current queue status') .action(() => { console.log(chalk_1.default.bold('Queue Status:')); console.log(chalk_1.default.gray(`Total items: ${testQueue.length}\n`)); if (testQueue.length === 0) { console.log(chalk_1.default.yellow('Queue is empty')); return; } testQueue.forEach((item, index) => { const priorityColor = { low: chalk_1.default.gray, medium: chalk_1.default.yellow, high: chalk_1.default.red }[item.priority]; console.log(`${index + 1}. ${item.test}`); console.log(` Priority: ${priorityColor(item.priority)}`); console.log(` Added: ${item.addedAt.toISOString()}\n`); }); }); // Add subcommand command .command('add <pattern>') .description('Add tests to queue') .option('-p, --priority <level>', 'Priority level (low|medium|high)', 'medium') .action((pattern, options) => { const tests = expandPattern(pattern); tests.forEach(test => { const item = { id: generateId(), test, priority: options.priority, addedAt: new Date() }; testQueue.push(item); console.log(chalk_1.default.green(`✓ Added to queue: ${test}`)); }); console.log(chalk_1.default.gray(`\nTotal queued: ${testQueue.length}`)); }); // Remove subcommand command .command('remove <pattern>') .description('Remove tests from queue') .action((pattern) => { const regex = new RegExp(pattern.replace(/\*/g, '.*')); const before = testQueue.length; for (let i = testQueue.length - 1; i >= 0; i--) { if (regex.test(testQueue[i].test)) { const removed = testQueue.splice(i, 1)[0]; console.log(chalk_1.default.green(`✓ Removed from queue: ${removed.test}`)); } } const removed = before - testQueue.length; console.log(chalk_1.default.gray(`\nRemoved ${removed} item(s)`)); }); // Clear subcommand command .command('clear') .description('Clear entire queue') .action(() => { const count = testQueue.length; testQueue.length = 0; console.log(chalk_1.default.green(`✓ Queue cleared (${count} items removed)`)); }); // Process subcommand command .command('process') .description('Process queued tests') .option('-p, --priority <level>', 'Process only specific priority') .action(async (options) => { const items = options.priority ? testQueue.filter(item => item.priority === options.priority) : testQueue; if (items.length === 0) { console.log(chalk_1.default.yellow('No tests to process')); return; } console.log(chalk_1.default.bold(`Processing ${items.length} tests...\n`)); // Sort by priority items.sort((a, b) => { const priorities = { high: 3, medium: 2, low: 1 }; return priorities[b.priority] - priorities[a.priority]; }); for (const item of items) { console.log(chalk_1.default.cyan(`Running: ${item.test}`)); await new Promise(resolve => setTimeout(resolve, 500)); console.log(chalk_1.default.green(`✓ Completed: ${item.test}\n`)); // Remove from queue after processing const index = testQueue.findIndex(q => q.id === item.id); if (index !== -1) { testQueue.splice(index, 1); } } console.log(chalk_1.default.green('✓ Queue processing complete')); }); // Stats subcommand command .command('stats') .description('Show queue statistics') .action(() => { const stats = { total: testQueue.length, high: testQueue.filter(i => i.priority === 'high').length, medium: testQueue.filter(i => i.priority === 'medium').length, low: testQueue.filter(i => i.priority === 'low').length }; console.log(chalk_1.default.bold('Queue Statistics:')); console.log(`Total: ${stats.total}`); console.log(chalk_1.default.red(`High priority: ${stats.high}`)); console.log(chalk_1.default.yellow(`Medium priority: ${stats.medium}`)); console.log(chalk_1.default.gray(`Low priority: ${stats.low}`)); }); return command; } exports.createQueueCommand = createQueueCommand; function expandPattern(pattern) { // Mock implementation - in real scenario, use glob return [ 'tests/unit/sample.test.ts', 'tests/integration/sample.test.ts' ]; } function generateId() { return `test-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; } //# sourceMappingURL=queue.js.map