#!/usr/bin/env node // ============================================================================ // AI Testing Suite - Entry Point // Multi-Agent LangGraph Orchestration for Node.js/TypeScript Testing // ============================================================================ import { Command } from 'commander'; import chalk from 'chalk'; import boxen from 'boxen'; import figures from 'figures'; import { startInteractiveCli } from './cli'; import { loadConfig, validateConfig, resolveProjectPath } from './config'; import { executeWorkflow } from './graph/workflow'; import { logger } from './utils/logger'; import { CliMode } from './types'; const program = new Command(); program .name('ai-test') .description('AI Testing Suite - Multi-Agent LangGraph Testing Pipeline') .version('1.0.0'); program .option('-m, --mode ', 'Mode: full|analyze|generate|run|security|report|interactive', 'interactive') .option('-p, --path ', 'Project path (default: current directory)', './') .option('-o, --output ', 'Test output directory', './tests') .option('-r, --reports ', 'Reports directory', './reports') .option('-v, --verbose', 'Verbose output', true) .option('--provider ', 'LLM Provider: openai|anthropic|openai_compatible|ollama') .option('--model ', 'LLM Model') .option('--api-key ', 'API Key') .option('--no-security', 'Disable security scan') .option('--no-zero-day', 'Disable zero-day check') .option('--depth ', 'Security scan depth: basic|standard|deep', 'deep') .option('--runner ', 'Test runner: vitest|jest|node (default: auto-detect)') .option('--e2e ', 'E2E runner: playwright|supertest|none (default: auto-detect)') .option('--coverage ', 'Coverage tool: v8|c8|istanbul (default: v8)'); program.parse(process.argv); const opts = program.opts(); async function main(): Promise { const configOverrides: Record = {}; if (opts.path) configOverrides.projectPath = resolveProjectPath(opts.path); if (opts.output) configOverrides.outputDir = opts.output; if (opts.reports) configOverrides.reportsDir = opts.reports; if (opts.provider) configOverrides.llmProvider = opts.provider; if (opts.model) configOverrides.llmModel = opts.model; if (opts.apiKey) configOverrides.apiKey = opts.apiKey; if (opts.depth) configOverrides.securityScanDepth = opts.depth; if (opts.verbose !== undefined) configOverrides.verbose = opts.verbose; if (opts.security === false) configOverrides.testTypes = ['unit', 'integration', 'e2e']; if (opts.zeroDay === false) configOverrides.checkZeroDay = false; if (opts.runner) configOverrides.testRunner = opts.runner; if (opts.e2e) configOverrides.e2eRunner = opts.e2e; if (opts.coverage) configOverrides.coverageTool = opts.coverage; const mode: CliMode = opts.mode || 'interactive'; if (mode === 'interactive') { await startInteractiveCli(configOverrides); } else { // Non-interactive: show startup banner console.log( boxen( [ chalk.bold.redBright('AI TESTING SUITE'), chalk.gray(`Mode: ${chalk.white(mode.toUpperCase())} ${figures.pointer} LangGraph Multi-Agent Pipeline`), ].join('\n'), { padding: { top: 0, bottom: 0, left: 2, right: 2 }, margin: { top: 1, bottom: 0, left: 0, right: 0 }, borderStyle: 'round', borderColor: 'red', textAlignment: 'center', } ) ); const config = loadConfig(configOverrides); const errors = validateConfig(config); if (errors.length > 0) { for (const err of errors) { logger.warning(err); } } try { const state = await executeWorkflow(config.projectPath, config, mode); if (state.status === 'completed') { logger.success('Workflow completed successfully!'); process.exit(0); } else { logger.error('Workflow ended with errors.'); process.exit(1); } } catch (error) { const errMsg = error instanceof Error ? error.message : String(error); logger.error(`Fatal error: ${errMsg}`); process.exit(1); } } } main().catch(err => { console.error(`${chalk.red(figures.cross)} Fatal error:`, err); process.exit(1); });