import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { PiGitConfig } from "./config.js"; import { type FileDetail } from "./file-selector.js"; import type { MessageAction } from "./confirmation.js"; import type { PipelineResult, PipelineCallbacks } from "./commit-events.js"; /** * Snapshot of pipeline state passed to hooks. */ export interface PipelineContext { /** pi extension API, needed for pipeline operations. */ pi: ExtensionAPI; /** Files the user selected to include in this commit */ selectedFiles: string[]; /** Per-file diff details (for QuickLook preview) */ fileDetails: Map | undefined; /** Combined staged diff (git diff --cached) */ stagedDiff: string; /** Staged stat (git diff --cached --stat) */ stagedStat: string; /** Staged name-status (git diff --cached --name-status) */ stagedNameStatus: string; } /** * Hooks to customise pipeline behaviour per command. */ export interface CommitPipelineHooks { /** * Called after staging and file selection, before LLM message generation. * * Use this for pre-generation workflows. * Throw to abort the pipeline (cleanup is handled automatically). */ onBeforeGenerate?: (ctx: PipelineContext, options: CommitPipelineOptions) => Promise; /** * Called after the commit message has been generated (or inline message * resolved). Implement the confirmation loop here. * * When undefined, the pipeline commits immediately without confirmation * (used by auto-commit). */ onMessageGenerated?: (message: string) => Promise; /** * Called after a successful commit. Reserved for future extensions * (e.g. post-commit actions). */ postCommit?: () => Promise; } /** * Options for customising the commit pipeline. */ export interface CommitPipelineOptions { hooks?: CommitPipelineHooks; /** * Optional callbacks for real-time progress during execution. */ callbacks?: PipelineCallbacks; /** * When set, skip LLM generation and use this message directly. * Staging and file selection still run. */ inlineMessage?: string; /** * When true, skip the actual `git commit` command. * All other steps (staging, file selection, LLM generation, * confirmation) run normally. No files are unstaged on dry-run. */ dryRun?: boolean; /** * When true, skip the interactive file selection UI. * All staged files are included in the commit. * Used by auto-commit. */ skipFileSelection?: boolean; /** * Label for the confirm button in the file selector. * Defaults to "confirm" when omitted. */ confirmLabel?: string; } /** * Run the full commit pipeline. * * Steps: * 1. Verify git repository * 2. Check for merge conflicts * 3. Check for uncommitted changes * 4. Stage all files (`git add -A`) * 5. File selection (interactive or skip) * 6. Unstage files the user did NOT select * 7. Collect staged diff/stat/name-status * 8. Call `onBeforeGenerate` hook * 9. Determine commit message (inline, LLM, or heuristic fallback) * 10. Call `onMessageGenerated` hook for confirmation * 11. Execute `git commit` (unless dryRun) * 12. Call `postCommit` hook * * Returns a `PipelineResult` with a structured events array that the caller * (presenter in index.ts) maps to UI calls. * * Error boundary: on any error (hook throw, git failure, etc.), the pipeline * guarantees `unstageAll` cleanup then re-throws. Footer-status updates * are the caller's responsibility (handled in catch blocks in index.ts). */ export declare function runCommitPipeline(pi: ExtensionAPI, ctx: ExtensionContext, config: PiGitConfig, options?: CommitPipelineOptions): Promise; //# sourceMappingURL=pipeline.d.ts.map