/**
 * Polka Codes Scripting API
 *
 * This module provides a high-level TypeScript API for programmatic access to
 * polka-codes workflows. All functions support both interactive and non-interactive modes.
 *
 * @example
 * ```typescript
 * import { commit, code, review } from '@polka-codes/cli'
 *
 * // Non-interactive scripting
 * await commit({ all: true, context: 'Fix login bug', interactive: false })
 *
 * // Interactive use (default)
 * await code({ task: 'Add user authentication' })
 * ```
 */
import type { ExitReason, UsageMeter } from '@polka-codes/core';
import type { ExecutionContext } from './runWorkflow';
import type { ScriptContext } from './script/runner';
import { type JsonFilePart, type JsonImagePart, type PlanWorkflowOutput, type ReviewResult } from './workflows';
/**
 * Reusable execution context for CLI options.
 * This interface extends the ExecutionContext from runWorkflow.ts
 * and can be used both from CLI and as a scripting API.
 */
export interface BaseOptions extends Partial<ExecutionContext> {
    /**
     * Callback invoked when usage meter is created, allowing tracking of API costs
     */
    onUsage?: (meter: UsageMeter) => void;
}
/**
 * Options for commit function
 */
export interface CommitOptions extends BaseOptions {
    /**
     * Stage all files before committing
     * @default false
     */
    all?: boolean;
    /**
     * Specific files to stage before committing
     * If provided, only these files will be staged
     */
    files?: string[];
    /**
     * Additional context for commit message generation
     */
    context?: string;
    /**
     * Whether to prompt for confirmation (non-interactive commits will auto-confirm)
     * @default true
     */
    interactive?: boolean;
}
/**
 * Creates a commit with an AI-generated message
 *
 * @param options - Commit options
 * @returns The generated commit message, or undefined if cancelled
 *
 * @example
 * ```typescript
 * // Commit all changes with context
 * const message = await commit({
 *   all: true,
 *   context: 'Fix authentication bug'
 * })
 *
 * // Non-interactive commit
 * await commit({ all: true, interactive: false })
 * ```
 */
export declare function commit(options?: CommitOptions): Promise<string | undefined>;
/**
 * Options for createPr function
 */
export interface CreatePrOptions extends BaseOptions {
    /**
     * Additional context for PR description generation
     */
    context?: string;
    /**
     * Whether to prompt for confirmation
     * @default true
     */
    interactive?: boolean;
}
/**
 * Creates a GitHub pull request with AI-generated title and description
 *
 * @param options - PR creation options
 * @returns The PR URL and details, or undefined if cancelled
 *
 * @example
 * ```typescript
 * // Create PR with context
 * const pr = await createPr({
 *   context: 'Implements user authentication flow'
 * })
 *
 * // Non-interactive PR creation
 * await createPr({ interactive: false })
 * ```
 */
export declare function createPr(options?: CreatePrOptions): Promise<{
    title: string;
    description: string;
} | undefined>;
/**
 * Options for code function
 */
export interface CodeOptions extends BaseOptions {
    /**
     * The task to implement
     */
    task: string;
    /**
     * Files to include as context (images or attachments)
     */
    files?: Array<JsonFilePart | JsonImagePart>;
    /**
     * Execution mode
     * @default 'interactive'
     */
    mode?: 'interactive' | 'noninteractive';
    /**
     * Additional instructions for the AI agent
     */
    additionalInstructions?: string;
    /**
     * Whether to prompt for confirmations
     * @default true
     */
    interactive?: boolean;
}
/**
 * Plans and implements a feature or task using AI agents
 *
 * @param options - Code generation options
 * @returns Implementation result with summaries
 *
 * @example
 * ```typescript
 * // Implement a feature
 * const result = await code({
 *   task: 'Add OAuth2 login with Google'
 * })
 *
 * // With custom files
 * await code({
 *   task: 'Implement this design',
 *   files: [{ type: 'image', mediaType: 'image/png', image: 'base64...' }]
 * })
 * ```
 */
export declare function code(options: CodeOptions): Promise<{
    success: boolean;
    summaries?: string[];
    reason?: string;
} | undefined>;
/**
 * Options for reviewCode function
 */
export interface ReviewCodeOptions extends BaseOptions {
    /**
     * Pull request number to review (if not provided, reviews local changes)
     */
    pr?: number;
    /**
     * Git range to review (e.g., "HEAD~3..HEAD", "origin/main..HEAD")
     */
    range?: string;
    /**
     * Specific files to review (if not provided, reviews all changes)
     */
    files?: string[];
    /**
     * Additional context for the review
     */
    context?: string;
    /**
     * Whether to prompt for confirmations
     * @default true
     */
    interactive?: boolean;
}
/**
 * Reviews code changes (PR or local)
 *
 * @param options - Review options
 * @returns Review result with overview and specific feedback
 *
 * @example
 * ```typescript
 * // Review local changes
 * const review = await reviewCode({})
 *
 * // Review specific PR
 * const review = await reviewCode({ pr: 123 })
 * ```
 */
export declare function reviewCode(options?: ReviewCodeOptions): Promise<ReviewResult | undefined>;
/**
 * Options for fix function
 */
export interface FixOptions extends BaseOptions {
    /**
     * Command to run to detect issues
     * @default Uses check and test scripts from config
     */
    command?: string;
    /**
     * Task description for fixing
     */
    task?: string;
    /**
     * Additional prompt for the agent
     */
    prompt?: string;
    /**
     * Whether to prompt for confirmations
     * @default true
     */
    interactive?: boolean;
}
/**
 * Fixes issues by running a command and letting AI fix errors
 *
 * @param options - Fix options
 * @returns Fix result with summaries
 *
 * @example
 * ```typescript
 * // Fix test failures
 * const result = await fix({
 *   command: 'npm test',
 *   task: 'Fix failing unit tests'
 * })
 *
 * // Use default check/test scripts from config
 * await fix({})
 * ```
 */
export declare function fix(options?: FixOptions): Promise<{
    success: boolean;
    summaries?: string[];
    reason?: string;
} | undefined>;
/**
 * Options for task function
 */
export interface TaskOptions extends BaseOptions {
    /**
     * The task to perform
     */
    task: string;
    /**
     * Whether to output JSON
     * @default false
     */
    jsonMode?: boolean;
    /**
     * Whether to run in read-only mode (no file modifications or command execution)
     * @default false
     */
    readonly?: boolean;
    /**
     * Custom system prompt to override the default
     */
    systemPrompt?: string;
    /**
     * Whether to prompt for confirmations
     * @default true
     */
    interactive?: boolean;
}
/**
 * Performs a generic task using an AI agent
 *
 * @param options - Task options
 * @returns Task completion result (ExitReason with agent output)
 *
 * @example
 * ```typescript
 * // Run a simple task
 * const result = await task({
 *   task: 'Refactor the auth module'
 * })
 *
 * // Non-interactive mode with JSON output
 * const result = await task({
 *   task: 'Update dependencies',
 *   jsonMode: true,
 *   interactive: false
 * })
 * ```
 */
export declare function task(options: TaskOptions): Promise<ExitReason | undefined>;
/**
 * Options for plan function
 */
export interface PlanOptions extends BaseOptions {
    /**
     * The task to plan
     */
    task?: string;
    /**
     * Existing plan file content to update
     */
    fileContent?: string;
    /**
     * Path to save/load the plan file
     */
    planFile?: string;
    /**
     * Files to include as context
     */
    files?: Array<JsonFilePart | JsonImagePart>;
    /**
     * Planning mode
     * @default 'interactive'
     */
    mode?: 'interactive' | 'confirm' | 'noninteractive';
    /**
     * Whether to prompt for confirmations
     * @default true
     */
    interactive?: boolean;
}
/**
 * Creates or updates an implementation plan
 *
 * @param options - Planning options
 * @returns The generated plan and related files
 *
 * @example
 * ```typescript
 * // Create a new plan
 * const plan = await plan({
 *   task: 'Design and implement user dashboard'
 * })
 *
 * // Update existing plan
 * await plan({
 *   task: 'Add dark mode',
 *   fileContent: existingPlan,
 *   planFile: '.plans/dashboard.md'
 * })
 * ```
 */
export declare function plan(options?: PlanOptions): Promise<PlanWorkflowOutput | undefined>;
/**
 * Export ScriptContext for use in user scripts
 */
export type { ScriptContext };
//# sourceMappingURL=api.d.ts.map