/** * GitHubFetcher - Fetch PR metadata and check results from GitHub API * * Uses `gh` CLI to fetch: * - Complete PR metadata (title, author, labels, linked issues, etc.) * - Check results (GitHub Actions + external status checks) * - Run logs from GitHub Actions * - File changes from git diff * * @packageDocumentation */ import { type GitHubJob } from '@vibe-validate/git'; import type { ChangesContext, CheckConclusion, CheckStatus, PRMetadata } from '../schemas/watch-pr-result.schema.js'; /** * Check result (internal type for classification) */ export interface CheckResult { /** Check type (github_action or external) */ type: 'github_action' | 'external'; /** Check name */ name: string; /** Check status */ status: CheckStatus; /** Check conclusion (if completed) */ conclusion?: CheckConclusion; /** GitHub run ID (for GitHub Actions) */ run_id?: number; /** GitHub job ID (for matrix strategy jobs) */ job_id?: number; /** Workflow name (for GitHub Actions) */ workflow?: string; /** Started at (ISO 8601) */ started_at?: string; /** Duration (human-readable) */ duration?: string; /** URL (for external checks) */ url?: string; /** Provider name (for external checks) */ provider?: string; } /** * Run details (returned by fetchRunDetails) */ export interface RunDetails { /** GitHub run ID */ run_id: number; /** Check/job name */ name: string; /** Workflow name */ workflow: string; /** Run status */ status: CheckStatus; /** Run conclusion (if completed) */ conclusion?: CheckConclusion; /** Started at (ISO 8601) */ started_at: string; /** Duration (human-readable) */ duration: string; /** Run URL */ url: string; } /** * GitHubFetcher - Fetch PR data from GitHub API via gh CLI */ export declare class GitHubFetcher { private readonly owner?; private readonly repo?; /** * Create GitHubFetcher * * @param owner - Repository owner (optional, defaults to current repo) * @param repo - Repository name (optional, defaults to current repo) */ constructor(owner?: string, repo?: string); /** * Fetch complete PR metadata * * @param prNumber - PR number * @returns PR metadata */ fetchPRDetails(prNumber: number): Promise; /** * Fetch check results (GitHub Actions + external) * * @param prNumber - PR number * @returns Check results */ fetchChecks(prNumber: number): Promise; /** * Fetch run logs for a GitHub Actions run * * @param runId - GitHub run ID * @param jobId - GitHub job ID (optional, for matrix strategy jobs) * @returns Raw log output * * When jobId is provided, fetches logs for a specific job within the run. * This is critical for matrix strategy builds where extraction needs job-specific logs. */ fetchRunLogs(runId: number, jobId?: number): Promise; /** * Fetch details for a specific GitHub Actions run * * Useful for watching specific failed runs to test extraction. * * @param runId - GitHub run ID * @returns Run details */ fetchRunDetails(runId: number): Promise; /** * Fetch jobs for a workflow run * * @param runId - Run ID * @returns List of jobs for the run */ fetchRunJobs(runId: number): Promise; /** * Fetch all workflow runs for a PR * * @param prNumber - PR number * @returns List of workflow runs */ fetchRunsForPR(prNumber: number): Promise>; /** * Fetch file changes for a PR * * Uses git diff --numstat to get file change statistics. * * @param _prNumber - PR number (unused - we use git diff from current branch) * @param baseBranch - Base branch name (e.g., 'main', 'master', 'develop') * @returns File change context */ fetchFileChanges(_prNumber: number, baseBranch: string): Promise; /** * Classify check type * * @param check - Check object from GitHub API * @returns 'CheckRun' or 'StatusContext' */ private classifyCheck; /** * Map CheckRun to internal CheckResult * * @param check - CheckRun from GitHub API * @returns CheckResult */ private mapCheckRun; /** * Map StatusContext to internal CheckResult * * @param check - StatusContext from GitHub API * @returns CheckResult */ private mapStatusContext; /** * Extract run ID from GitHub Actions URL * * @param url - GitHub Actions URL * @returns Run ID or null */ private extractRunId; /** * Extract job ID from GitHub Actions URL * * Matrix strategy jobs have URLs like: * https://github.com/owner/repo/actions/runs/12345/job/67890 * * @param url - GitHub Actions URL * @returns Job ID or null */ private extractJobId; /** * Extract workflow name from check name * * @param checkName - Check name (e.g., "CI / Build") * @returns Workflow name */ private extractWorkflowName; /** * Calculate duration between two timestamps * * @param start - Start time (ISO 8601) * @param end - End time (ISO 8601, optional - defaults to now) * @returns Human-readable duration (e.g., "2m30s") */ private calculateDuration; /** * Normalize GitHub status to CheckStatus * * @param status - GitHub status * @returns CheckStatus */ private normalizeStatus; /** * Normalize GitHub conclusion to CheckConclusion * * @param conclusion - GitHub conclusion * @returns CheckConclusion */ private normalizeConclusion; /** * Normalize StatusContext state to CheckConclusion * * @param state - StatusContext state * @returns CheckConclusion */ private normalizeStatusContextState; /** * Normalize merge state status * * @param status - GitHub merge state status * @returns MergeStateStatus */ private normalizeMergeStateStatus; /** * Extract linked issues from closing issues references * * @param closingIssuesReferences - Closing issues references from GitHub API * @returns Linked issues */ private extractLinkedIssues; /** * Detect provider from check name * * @param checkName - Check name * @returns Provider name */ private detectProvider; } //# sourceMappingURL=github-fetcher.d.ts.map