/**
 * Self-Improvement Service
 *
 * Enables the orchestrator to safely modify the Crewly codebase,
 * using the marker system to persist state across hot-reload restarts.
 *
 * @module services/orchestrator/self-improvement
 */
import { ImprovementMarker } from './improvement-marker.service.js';
/**
 * Improvement request configuration
 */
export interface ImprovementRequest {
    /** Description of the improvement */
    description: string;
    /** Files that will be modified */
    targetFiles: string[];
    /** Planned changes to apply */
    changes: Array<{
        file: string;
        type: 'create' | 'modify' | 'delete';
        description: string;
        content?: string;
    }>;
    /** Slack context for notifications */
    slackContext?: {
        channelId: string;
        threadTs: string;
        userId: string;
    };
}
/**
 * Improvement plan returned after planning
 */
export interface ImprovementPlan {
    /** Unique improvement ID */
    id: string;
    /** Description of the improvement */
    description: string;
    /** Target files */
    targetFiles: string[];
    /** Planned changes */
    changes: Array<{
        file: string;
        type: 'create' | 'modify' | 'delete';
        description: string;
    }>;
    /** Risk level assessment */
    riskLevel: 'low' | 'medium' | 'high';
    /** Whether changes require restart */
    requiresRestart: boolean;
}
/**
 * Result of an improvement execution
 */
export interface ImprovementResult {
    /** Whether the improvement was started */
    started: boolean;
    /** Message about what happened */
    message: string;
    /** Task ID for tracking */
    taskId?: string;
}
/**
 * SelfImprovementService class
 *
 * Manages the self-improvement workflow using the marker system
 * to persist state across hot-reload restarts.
 *
 * Flow:
 * 1. planImprovement() - Creates marker in 'planning' phase
 * 2. executeImprovement() - Creates backups, applies changes
 * 3. Process is killed by hot-reload
 * 4. Startup hook handles validation and rollback
 *
 * @example
 * ```typescript
 * const service = getSelfImprovementService();
 *
 * const plan = await service.planImprovement({
 *   description: 'Add new feature',
 *   targetFiles: ['src/feature.ts'],
 *   changes: [{ file: 'src/feature.ts', type: 'create', description: 'New feature', content: '...' }],
 * });
 *
 * const result = await service.executeImprovement(request);
 * // Hot-reload will kill the process, startup hook will validate
 * ```
 */
export declare class SelfImprovementService {
    private projectRoot;
    private logger;
    /**
     * Create a new SelfImprovementService.
     *
     * @param projectRoot - Root directory of the project (defaults to process.cwd())
     */
    constructor(projectRoot?: string);
    /**
     * Plan an improvement (creates marker in 'planning' phase).
     *
     * @param request - The improvement request configuration
     * @returns ImprovementPlan for review before execution
     * @throws Error if another improvement is already pending
     */
    planImprovement(request: ImprovementRequest): Promise<ImprovementPlan>;
    /**
     * Execute the planned improvement.
     *
     * IMPORTANT: This method:
     * 1. Creates backups
     * 2. Writes marker with backup info
     * 3. Applies changes (triggers hot-reload)
     * 4. Process gets killed by hot-reload
     * 5. Startup hook handles validation
     *
     * @param request - The improvement request with content
     * @returns Result indicating that changes were started
     * @throws Error if no improvement is planned
     */
    executeImprovement(request: ImprovementRequest): Promise<ImprovementResult>;
    /**
     * Cancel a planned improvement.
     *
     * @throws Error if improvement is past planning phase
     */
    cancelImprovement(): Promise<void>;
    /**
     * Get current improvement status.
     *
     * @returns Current improvement marker or null
     */
    getStatus(): Promise<ImprovementMarker | null>;
    /**
     * Get improvement history.
     *
     * @param limit - Maximum number of history items to return
     * @returns Array of historical improvement markers
     */
    getHistory(limit?: number): Promise<ImprovementMarker[]>;
    /**
     * Create git checkpoint.
     *
     * @returns Git commit and branch info
     */
    private createGitCheckpoint;
    /**
     * Create file backups.
     *
     * @param files - Files to backup
     * @returns Array of backup records
     */
    private createFileBackups;
    /**
     * Apply file changes.
     *
     * @param changes - Changes to apply
     * @returns Array of applied changes
     */
    private applyChanges;
    /**
     * Analyze risk level.
     *
     * @param files - Files to analyze
     * @returns Risk level
     */
    private analyzeRisk;
    /**
     * Check if changes require restart.
     *
     * @param files - Files being changed
     * @returns True if restart is needed
     */
    private checkRequiresRestart;
    /**
     * Run shell command.
     *
     * @param cmd - Command to run
     * @param args - Command arguments
     * @returns Command output
     */
    private runCommand;
    /**
     * Send Slack notification.
     *
     * @param message - Message to send
     * @param urgency - Urgency level
     */
    private notifySlack;
}
/**
 * Get singleton instance.
 *
 * @returns SelfImprovementService instance
 */
export declare function getSelfImprovementService(): SelfImprovementService;
/**
 * Reset instance (for testing).
 */
export declare function resetSelfImprovementService(): void;
//# sourceMappingURL=self-improvement.service.d.ts.map