import { Command } from 'commander';
import { Result } from '@harness-engineering/core';
import { z } from 'zod';

interface Phase {
    name: string;
    description: string;
    required: boolean;
}
interface PreambleOptions {
    complexity?: 'light' | 'full';
    phases?: Phase[];
    principles?: string;
    phase?: string;
    priorState?: string;
    stateWarning?: string;
    party?: boolean;
}
declare function buildPreamble(options: PreambleOptions): string;

/**
 * CLI Exit Codes
 */
declare const ExitCode: {
    readonly SUCCESS: 0;
    readonly VALIDATION_FAILED: 1;
    readonly ERROR: 2;
};
type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];
/**
 * CLI-specific error with exit code
 */
declare class CLIError extends Error {
    readonly exitCode: ExitCodeType;
    constructor(message: string, exitCode?: ExitCodeType);
}
/**
 * Handle error and exit process
 */
declare function handleError(error: unknown): never;

interface CheckPhaseGateOptions {
    cwd?: string;
    configPath?: string;
    json?: boolean;
    verbose?: boolean;
    quiet?: boolean;
}
interface CheckPhaseGateResult {
    pass: boolean;
    skipped: boolean;
    severity?: 'error' | 'warning';
    missingSpecs: Array<{
        implFile: string;
        expectedSpec: string;
    }>;
    checkedFiles: number;
}
declare function runCheckPhaseGate(options: CheckPhaseGateOptions): Promise<Result<CheckPhaseGateResult, CLIError>>;

interface CrossCheckResult {
    specToPlan: string[];
    planToImpl: string[];
    staleness: string[];
    warnings: number;
}
interface CrossCheckOptions {
    specsDir: string;
    plansDir: string;
    projectPath: string;
}
declare function runCrossCheck(options: CrossCheckOptions): Promise<Result<CrossCheckResult, CLIError>>;

interface CreateSkillOptions {
    name: string;
    description: string;
    cognitiveMode?: string;
    reads?: string[];
    produces?: string;
    preChecks?: string[];
    postChecks?: string[];
    outputDir?: string;
}
interface GeneratedFiles {
    skillYamlPath: string;
    skillMdPath: string;
}
declare function generateSkillFiles(opts: CreateSkillOptions): GeneratedFiles;

declare const OutputMode: {
    readonly JSON: "json";
    readonly TEXT: "text";
    readonly QUIET: "quiet";
    readonly VERBOSE: "verbose";
};
type OutputModeType = (typeof OutputMode)[keyof typeof OutputMode];
interface ValidationIssue {
    file?: string;
    message: string;
    line?: number;
    suggestion?: string;
}
interface ValidationResult {
    valid: boolean;
    issues: ValidationIssue[];
}
declare class OutputFormatter {
    private mode;
    constructor(mode?: OutputModeType);
    /**
     * Format raw data (for JSON mode)
     */
    format(data: unknown): string;
    /**
     * Format validation result
     */
    formatValidation(result: ValidationResult): string;
    /**
     * Format a summary line
     */
    formatSummary(label: string, value: string | number, success: boolean): string;
}

declare const logger: {
    info: (message: string) => void;
    success: (message: string) => void;
    warn: (message: string) => void;
    error: (message: string) => void;
    dim: (message: string) => void;
    raw: (data: unknown) => void;
};

declare const HarnessConfigSchema: z.ZodObject<{
    version: z.ZodLiteral<1>;
    name: z.ZodOptional<z.ZodString>;
    rootDir: z.ZodDefault<z.ZodString>;
    layers: z.ZodOptional<z.ZodArray<z.ZodObject<{
        name: z.ZodString;
        pattern: z.ZodString;
        allowedDependencies: z.ZodArray<z.ZodString, "many">;
    }, "strip", z.ZodTypeAny, {
        name: string;
        pattern: string;
        allowedDependencies: string[];
    }, {
        name: string;
        pattern: string;
        allowedDependencies: string[];
    }>, "many">>;
    forbiddenImports: z.ZodOptional<z.ZodArray<z.ZodObject<{
        from: z.ZodString;
        disallow: z.ZodArray<z.ZodString, "many">;
        message: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        from: string;
        disallow: string[];
        message?: string | undefined;
    }, {
        from: string;
        disallow: string[];
        message?: string | undefined;
    }>, "many">>;
    boundaries: z.ZodOptional<z.ZodObject<{
        requireSchema: z.ZodArray<z.ZodString, "many">;
    }, "strip", z.ZodTypeAny, {
        requireSchema: string[];
    }, {
        requireSchema: string[];
    }>>;
    agentsMapPath: z.ZodDefault<z.ZodString>;
    docsDir: z.ZodDefault<z.ZodString>;
    agent: z.ZodOptional<z.ZodObject<{
        executor: z.ZodDefault<z.ZodEnum<["subprocess", "cloud", "noop"]>>;
        timeout: z.ZodDefault<z.ZodNumber>;
        skills: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
    }, "strip", z.ZodTypeAny, {
        executor: "subprocess" | "cloud" | "noop";
        timeout: number;
        skills?: string[] | undefined;
    }, {
        executor?: "subprocess" | "cloud" | "noop" | undefined;
        timeout?: number | undefined;
        skills?: string[] | undefined;
    }>>;
    entropy: z.ZodOptional<z.ZodObject<{
        excludePatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
        autoFix: z.ZodDefault<z.ZodBoolean>;
    }, "strip", z.ZodTypeAny, {
        excludePatterns: string[];
        autoFix: boolean;
    }, {
        excludePatterns?: string[] | undefined;
        autoFix?: boolean | undefined;
    }>>;
    template: z.ZodOptional<z.ZodObject<{
        level: z.ZodEnum<["basic", "intermediate", "advanced"]>;
        framework: z.ZodOptional<z.ZodString>;
        version: z.ZodNumber;
    }, "strip", z.ZodTypeAny, {
        version: number;
        level: "basic" | "intermediate" | "advanced";
        framework?: string | undefined;
    }, {
        version: number;
        level: "basic" | "intermediate" | "advanced";
        framework?: string | undefined;
    }>>;
    phaseGates: z.ZodOptional<z.ZodObject<{
        enabled: z.ZodDefault<z.ZodBoolean>;
        severity: z.ZodDefault<z.ZodEnum<["error", "warning"]>>;
        mappings: z.ZodDefault<z.ZodArray<z.ZodObject<{
            implPattern: z.ZodString;
            specPattern: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            implPattern: string;
            specPattern: string;
        }, {
            implPattern: string;
            specPattern: string;
        }>, "many">>;
    }, "strip", z.ZodTypeAny, {
        enabled: boolean;
        severity: "error" | "warning";
        mappings: {
            implPattern: string;
            specPattern: string;
        }[];
    }, {
        enabled?: boolean | undefined;
        severity?: "error" | "warning" | undefined;
        mappings?: {
            implPattern: string;
            specPattern: string;
        }[] | undefined;
    }>>;
}, "strip", z.ZodTypeAny, {
    version: 1;
    rootDir: string;
    agentsMapPath: string;
    docsDir: string;
    name?: string | undefined;
    layers?: {
        name: string;
        pattern: string;
        allowedDependencies: string[];
    }[] | undefined;
    forbiddenImports?: {
        from: string;
        disallow: string[];
        message?: string | undefined;
    }[] | undefined;
    boundaries?: {
        requireSchema: string[];
    } | undefined;
    agent?: {
        executor: "subprocess" | "cloud" | "noop";
        timeout: number;
        skills?: string[] | undefined;
    } | undefined;
    entropy?: {
        excludePatterns: string[];
        autoFix: boolean;
    } | undefined;
    template?: {
        version: number;
        level: "basic" | "intermediate" | "advanced";
        framework?: string | undefined;
    } | undefined;
    phaseGates?: {
        enabled: boolean;
        severity: "error" | "warning";
        mappings: {
            implPattern: string;
            specPattern: string;
        }[];
    } | undefined;
}, {
    version: 1;
    name?: string | undefined;
    rootDir?: string | undefined;
    layers?: {
        name: string;
        pattern: string;
        allowedDependencies: string[];
    }[] | undefined;
    forbiddenImports?: {
        from: string;
        disallow: string[];
        message?: string | undefined;
    }[] | undefined;
    boundaries?: {
        requireSchema: string[];
    } | undefined;
    agentsMapPath?: string | undefined;
    docsDir?: string | undefined;
    agent?: {
        executor?: "subprocess" | "cloud" | "noop" | undefined;
        timeout?: number | undefined;
        skills?: string[] | undefined;
    } | undefined;
    entropy?: {
        excludePatterns?: string[] | undefined;
        autoFix?: boolean | undefined;
    } | undefined;
    template?: {
        version: number;
        level: "basic" | "intermediate" | "advanced";
        framework?: string | undefined;
    } | undefined;
    phaseGates?: {
        enabled?: boolean | undefined;
        severity?: "error" | "warning" | undefined;
        mappings?: {
            implPattern: string;
            specPattern: string;
        }[] | undefined;
    } | undefined;
}>;
type HarnessConfig = z.infer<typeof HarnessConfigSchema>;

/**
 * Find config file starting from given directory
 */
declare function findConfigFile(startDir?: string): Result<string, CLIError>;
/**
 * Load and validate config from file
 */
declare function loadConfig(configPath: string): Result<HarnessConfig, CLIError>;
/**
 * Load config from default location or specified path
 */
declare function resolveConfig(configPath?: string): Result<HarnessConfig, CLIError>;

declare const TemplateMetadataSchema: z.ZodObject<{
    name: z.ZodString;
    description: z.ZodString;
    level: z.ZodOptional<z.ZodEnum<["basic", "intermediate", "advanced"]>>;
    framework: z.ZodOptional<z.ZodString>;
    extends: z.ZodOptional<z.ZodString>;
    mergeStrategy: z.ZodDefault<z.ZodObject<{
        json: z.ZodDefault<z.ZodEnum<["deep-merge", "overlay-wins"]>>;
        files: z.ZodDefault<z.ZodLiteral<"overlay-wins">>;
    }, "strip", z.ZodTypeAny, {
        json: "deep-merge" | "overlay-wins";
        files: "overlay-wins";
    }, {
        json?: "deep-merge" | "overlay-wins" | undefined;
        files?: "overlay-wins" | undefined;
    }>>;
    version: z.ZodLiteral<1>;
}, "strip", z.ZodTypeAny, {
    name: string;
    version: 1;
    description: string;
    mergeStrategy: {
        json: "deep-merge" | "overlay-wins";
        files: "overlay-wins";
    };
    level?: "basic" | "intermediate" | "advanced" | undefined;
    framework?: string | undefined;
    extends?: string | undefined;
}, {
    name: string;
    version: 1;
    description: string;
    level?: "basic" | "intermediate" | "advanced" | undefined;
    framework?: string | undefined;
    extends?: string | undefined;
    mergeStrategy?: {
        json?: "deep-merge" | "overlay-wins" | undefined;
        files?: "overlay-wins" | undefined;
    } | undefined;
}>;
type TemplateMetadata = z.infer<typeof TemplateMetadataSchema>;

interface TemplateContext {
    projectName: string;
    level: string;
    framework?: string;
}
interface TemplateFile {
    relativePath: string;
    absolutePath: string;
    isHandlebars: boolean;
    sourceTemplate: string;
}
interface ResolvedTemplate {
    metadata: TemplateMetadata;
    files: TemplateFile[];
    overlayMetadata?: TemplateMetadata;
}
interface RenderedFile {
    relativePath: string;
    content: string;
}
interface RenderedFiles {
    files: RenderedFile[];
}
interface WriteOptions {
    overwrite: boolean;
}
declare class TemplateEngine {
    private templatesDir;
    constructor(templatesDir: string);
    listTemplates(): Result<TemplateMetadata[], Error>;
    resolveTemplate(level: string, framework?: string): Result<ResolvedTemplate, Error>;
    render(template: ResolvedTemplate, context: TemplateContext): Result<RenderedFiles, Error>;
    write(files: RenderedFiles, targetDir: string, options: WriteOptions): Result<string[], Error>;
    private findTemplateDir;
    private collectFiles;
    private mergeFileLists;
}

declare const PersonaSchema: z.ZodObject<{
    version: z.ZodLiteral<1>;
    name: z.ZodString;
    description: z.ZodString;
    role: z.ZodString;
    skills: z.ZodArray<z.ZodString, "many">;
    commands: z.ZodArray<z.ZodString, "many">;
    triggers: z.ZodArray<z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
        event: z.ZodLiteral<"on_pr">;
        conditions: z.ZodOptional<z.ZodObject<{
            paths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
        }, "strip", z.ZodTypeAny, {
            paths?: string[] | undefined;
        }, {
            paths?: string[] | undefined;
        }>>;
    }, "strip", z.ZodTypeAny, {
        event: "on_pr";
        conditions?: {
            paths?: string[] | undefined;
        } | undefined;
    }, {
        event: "on_pr";
        conditions?: {
            paths?: string[] | undefined;
        } | undefined;
    }>, z.ZodObject<{
        event: z.ZodLiteral<"on_commit">;
        conditions: z.ZodOptional<z.ZodObject<{
            branches: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
        }, "strip", z.ZodTypeAny, {
            branches?: string[] | undefined;
        }, {
            branches?: string[] | undefined;
        }>>;
    }, "strip", z.ZodTypeAny, {
        event: "on_commit";
        conditions?: {
            branches?: string[] | undefined;
        } | undefined;
    }, {
        event: "on_commit";
        conditions?: {
            branches?: string[] | undefined;
        } | undefined;
    }>, z.ZodObject<{
        event: z.ZodLiteral<"scheduled">;
        cron: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        event: "scheduled";
        cron: string;
    }, {
        event: "scheduled";
        cron: string;
    }>]>, "many">;
    config: z.ZodDefault<z.ZodObject<{
        severity: z.ZodDefault<z.ZodEnum<["error", "warning"]>>;
        autoFix: z.ZodDefault<z.ZodBoolean>;
        timeout: z.ZodDefault<z.ZodNumber>;
    }, "strip", z.ZodTypeAny, {
        timeout: number;
        autoFix: boolean;
        severity: "error" | "warning";
    }, {
        timeout?: number | undefined;
        autoFix?: boolean | undefined;
        severity?: "error" | "warning" | undefined;
    }>>;
    outputs: z.ZodDefault<z.ZodObject<{
        'agents-md': z.ZodDefault<z.ZodBoolean>;
        'ci-workflow': z.ZodDefault<z.ZodBoolean>;
        'runtime-config': z.ZodDefault<z.ZodBoolean>;
    }, "strip", z.ZodTypeAny, {
        'agents-md': boolean;
        'ci-workflow': boolean;
        'runtime-config': boolean;
    }, {
        'agents-md'?: boolean | undefined;
        'ci-workflow'?: boolean | undefined;
        'runtime-config'?: boolean | undefined;
    }>>;
}, "strip", z.ZodTypeAny, {
    name: string;
    skills: string[];
    version: 1;
    description: string;
    role: string;
    commands: string[];
    triggers: ({
        event: "on_pr";
        conditions?: {
            paths?: string[] | undefined;
        } | undefined;
    } | {
        event: "on_commit";
        conditions?: {
            branches?: string[] | undefined;
        } | undefined;
    } | {
        event: "scheduled";
        cron: string;
    })[];
    config: {
        timeout: number;
        autoFix: boolean;
        severity: "error" | "warning";
    };
    outputs: {
        'agents-md': boolean;
        'ci-workflow': boolean;
        'runtime-config': boolean;
    };
}, {
    name: string;
    skills: string[];
    version: 1;
    description: string;
    role: string;
    commands: string[];
    triggers: ({
        event: "on_pr";
        conditions?: {
            paths?: string[] | undefined;
        } | undefined;
    } | {
        event: "on_commit";
        conditions?: {
            branches?: string[] | undefined;
        } | undefined;
    } | {
        event: "scheduled";
        cron: string;
    })[];
    config?: {
        timeout?: number | undefined;
        autoFix?: boolean | undefined;
        severity?: "error" | "warning" | undefined;
    } | undefined;
    outputs?: {
        'agents-md'?: boolean | undefined;
        'ci-workflow'?: boolean | undefined;
        'runtime-config'?: boolean | undefined;
    } | undefined;
}>;
type Persona = z.infer<typeof PersonaSchema>;

interface PersonaMetadata {
    name: string;
    description: string;
    filePath: string;
}
declare function loadPersona(filePath: string): Result<Persona, Error>;
declare function listPersonas(dir: string): Result<PersonaMetadata[], Error>;

declare function generateRuntime(persona: Persona): Result<string, Error>;

declare function generateAgentsMd(persona: Persona): Result<string, Error>;

declare function generateCIWorkflow(persona: Persona, platform: 'github' | 'gitlab'): Result<string, Error>;

interface PersonaRunReport {
    persona: string;
    status: 'pass' | 'fail' | 'partial';
    commands: Array<{
        name: string;
        status: 'pass' | 'fail' | 'skipped';
        result?: unknown;
        error?: string;
        durationMs: number;
    }>;
    totalDurationMs: number;
}
type CommandExecutor = (command: string) => Promise<Result<unknown, Error>>;
declare function runPersona(persona: Persona, executor: CommandExecutor): Promise<PersonaRunReport>;

declare function createProgram(): Command;

export { CLIError, type CommandExecutor, type CreateSkillOptions, ExitCode, type HarnessConfig, OutputFormatter, OutputMode, type Persona, type PersonaMetadata, type PersonaRunReport, type RenderedFiles, type TemplateContext, TemplateEngine, buildPreamble, createProgram, findConfigFile, generateAgentsMd, generateCIWorkflow, generateRuntime, generateSkillFiles, handleError, listPersonas, loadConfig, loadPersona, logger, resolveConfig, runCheckPhaseGate, runCrossCheck, runPersona };
