/** * PR Poll Handler * * Polls all watched PRs for a user and detects state changes. * Designed to be invoked by cron (no TTY) every 5 minutes. * * User-scoped: polls ALL watched PRs across all repos in a single invocation. * * @see .dev/features/github-pr.md for full specification */ import type { IGithubClient } from '../../../domain/interfaces/dal/IGithubClient'; import type { IPullRequestRepository } from '../../../domain/interfaces/dal/IPullRequestRepository'; import type { CheckStatus, PullRequestStatus } from '../../../domain/interfaces/types/IPullRequest'; import type { INotificationService } from '../../../domain/interfaces/INotificationService'; import type { IMemoryWriter } from '../../../domain/interfaces/IMemoryService'; /** * State change detected during polling. */ export interface IStateChange { readonly type: 'checks_updated' | 'new_comment' | 'comment_resolved' | 'pr_approved' | 'pr_merged' | 'pr_closed' | 'new_reply'; readonly description: string; readonly prNumber: number; readonly repo: string; } /** * Result for a single PR poll. */ export interface IPrPollItem { readonly number: number; readonly repo: string; readonly title: string; readonly previousState: { readonly status: PullRequestStatus; readonly checksStatus: CheckStatus; readonly unresolvedComments: number; }; readonly currentState: { readonly status: PullRequestStatus; readonly checksStatus: CheckStatus; readonly unresolvedComments: number; }; readonly changes: readonly IStateChange[]; readonly unwatched: boolean; readonly error?: string; } /** * Result from PrPollHandler. */ export interface IPrPollResult { readonly success: boolean; readonly message: string; readonly polledAt: string; readonly totalWatched: number; readonly totalChanges: number; readonly totalErrors: number; readonly items: readonly IPrPollItem[]; readonly logPath?: string; /** Auto-address output for PRs with new comments (when autoAddress is enabled) */ readonly addressOutput?: readonly IAutoAddressOutput[]; } /** * Auto-address output for a single PR. */ export interface IAutoAddressOutput { readonly prNumber: number; readonly repo: string; readonly formattedOutput: string; } /** * Options for poll command. */ export interface IPrPollOptions { /** Auto-unwatch merged/closed PRs (default: true) */ readonly autoUnwatch?: boolean; /** Write logs to file (default: true) */ readonly logToFile?: boolean; /** Limit concurrent GitHub API calls (default: 5) */ readonly concurrency?: number; /** Send desktop notifications for state changes (default: false) */ readonly notify?: boolean; /** Auto-address new comments by outputting formatted instructions (default: true) */ readonly autoAddress?: boolean; /** Poll a specific PR number instead of watched PRs */ readonly prNumber?: number; /** Repository for the target PR (owner/repo). Defaults to current repo. */ readonly repo?: string; /** Use current PR from branch (foreground watch). */ readonly current?: boolean; /** Use local cache for comment detection (no Neo4j). */ readonly useLocalCache?: boolean; } /** * Handler for PR polling operations. */ export declare class PrPollHandler { private readonly githubClient; private readonly prRepository; private readonly notificationService?; private readonly memoryService?; private readonly logPath; private readonly cachePath; constructor(githubClient: IGithubClient, prRepository: IPullRequestRepository, notificationService?: INotificationService | undefined, memoryService?: IMemoryWriter | undefined); /** * Poll all watched PRs for the current user. */ poll(options?: IPrPollOptions): Promise; /** * Poll a single PR and detect changes. */ private pollSinglePr; /** * Detect new comments and replies. */ private detectNewComments; /** * Detect comment resolution changes via GraphQL review threads. * Updates stored comments and returns state changes for newly resolved threads. */ private detectCommentResolution; /** * Calculate overall check status from individual checks. */ private calculateOverallCheckStatus; /** * Count unresolved comments. */ private countUnresolvedComments; /** * Map GitHub PR state to domain status. */ private mapPrStatus; /** * Map GitHub check state to domain status. */ private mapCheckStatus; /** * Get error message from unknown error. */ private getErrorMessage; /** * Write logs to file. */ private writeLog; /** * Split array into batches. */ private batchArray; private resolveTarget; private getCacheKey; private getCachedState; private loadCache; private writeCache; private countUnresolvedThreads; private detectNewCommentsFromCache; /** * Collect notifications from poll results. */ private collectNotifications; } //# sourceMappingURL=PrPollHandler.d.ts.map