/** * Pipeline Executor - Command Pipeline Execution Engine * * Issue: #144 - Command Composition * Phase: 3 - Implementation * * Executes command pipelines with: * - Sequential and parallel execution * - Context passing between commands * - Error handling and rollback * - Checkpoint and resume functionality */ import { EventEmitter } from 'events'; /** * Supported command types */ export type CommandType = 'create-issue' | 'agent-run' | 'review' | 'test' | 'security-scan' | 'deploy' | 'verify' | 'generate-docs' | 'miyabi-auto' | 'miyabi-todos'; /** * Pipeline operator types */ export type PipelineOperator = '|' | '&&' | '||' | '&'; /** * Command execution status */ export type CommandStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped'; /** * Pipeline context - shared state between commands */ export interface PipelineContext { pipelineId: string; startedAt: Date; issueNumber?: number; issueNumbers?: number[]; issueUrl?: string; prNumber?: number; prUrl?: string; qualityScore?: number; testsPassed?: boolean; coveragePercent?: number; deploymentUrl?: string; deploymentVersion?: string; environment?: 'staging' | 'production'; errors: PipelineError[]; warnings: string[]; checkpoints: Checkpoint[]; currentStep: number; totalSteps: number; customData: Record; } /** * Pipeline error */ export interface PipelineError { code: string; message: string; command: string; timestamp: string; recoverable: boolean; } /** * Checkpoint for resume functionality */ export interface Checkpoint { id: string; step: number; command: string; context: Partial; timestamp: string; } /** * Command definition in a pipeline */ export interface PipelineCommand { type: CommandType; args: Record; operator?: PipelineOperator; } /** * Command result */ export interface CommandResult { success: boolean; data?: Record; error?: PipelineError; duration: number; } /** * Pipeline definition */ export interface Pipeline { id: string; name: string; commands: PipelineCommand[]; createdAt: string; } /** * Pipeline execution options */ export interface ExecutionOptions { dryRun?: boolean; verbose?: boolean; maxRetries?: number; retryDelay?: number; checkpointInterval?: number; onProgress?: (step: number, total: number, command: string) => void; } /** * Retry policy */ export interface RetryPolicy { maxRetries: number; backoff: 'linear' | 'exponential'; initialDelay: number; maxDelay: number; retryableErrors: string[]; } /** * Parse pipeline string into commands */ export declare function parsePipeline(pipelineStr: string): PipelineCommand[]; /** * PipelineExecutor - Execute command pipelines */ export declare class PipelineExecutor extends EventEmitter { private context; private options; private retryPolicy; private commandHandlers; private aborted; constructor(options?: ExecutionOptions, retryPolicy?: Partial); /** * Create empty context */ private createEmptyContext; /** * Register default command handlers */ private registerDefaultHandlers; /** * Register a command handler */ registerHandler(type: CommandType, handler: CommandHandler): void; /** * Execute a pipeline */ execute(pipeline: Pipeline | string): Promise; /** * Execute a single command with retry */ private executeCommand; /** * Execute commands in parallel */ private executeParallel; /** * Calculate retry delay with backoff */ private calculateRetryDelay; /** * Create a checkpoint */ private createCheckpoint; /** * Resume from checkpoint */ resume(checkpointId: string, pipeline: Pipeline | string): Promise; /** * Abort execution */ abort(): void; /** * Get current context */ getContext(): PipelineContext; /** * Get checkpoints */ getCheckpoints(): Checkpoint[]; /** * Sleep utility */ private sleep; } /** * Command handler function type */ type CommandHandler = (args: Record, context: PipelineContext) => Promise; /** * Full development cycle pipeline */ export declare const FULL_CYCLE_PIPELINE = "/agent-run | /review --threshold 80 | /test | /security-scan | /deploy --env staging | /verify"; /** * Quick deploy pipeline */ export declare const QUICK_DEPLOY_PIPELINE = "/verify && /deploy"; /** * Quality gate pipeline */ export declare const QUALITY_GATE_PIPELINE = "/review && /test && /security-scan"; /** * Auto-fix pipeline */ export declare const AUTO_FIX_PIPELINE = "/review --auto-fix"; export default PipelineExecutor; //# sourceMappingURL=pipeline-executor.d.ts.map