import type { AuthorType, ReviewThread, PrComment, Review, MergeStatusResult, ViewerAuthorization, CheckConclusion, SuggestionBlock } from "./github.mts"; import type { ClassifiedCheck, TriagedCheck } from "./check-classification.mts"; import type { AgentThreadComment } from "./agent-thread.mts"; import type { CheckAnnotation } from "./check-annotations.mts"; import type { PrActivitySummary } from "./activity.mts"; import type { MergeQueueReport } from "./merge-queue.mts"; export interface FirstLookThread extends ReviewThread { firstLookStatus: "outdated" | "resolved" | "minimized"; autoResolved?: boolean; edited?: boolean; } export interface FirstLookComment extends PrComment { firstLookStatus: "minimized"; edited?: boolean; } export type ActionableComment = PrComment & { edited?: boolean; }; export type ShepherdStatus = "MERGED" | "CLOSED" | "READY" | "FAILING" | "PENDING" | "IN_PROGRESS" | "UNRESOLVED_COMMENTS" | "UNKNOWN"; export interface ShepherdReport { pr: number; /** GitHub node ID of the PR — used for mutations (e.g. markPullRequestReadyForReview). */ nodeId: string; /** GitHub PR head OID from the same batch used to decide the action. */ headSha?: string; /** Internal. True when this report was reused from the fingerprint cache. */ fingerprintReused?: true; repo: string; /** Raw GitHub viewer fields used to decide which remote actions may be offered. */ viewerAuthorization?: ViewerAuthorization; status: ShepherdStatus; /** PR base branch from the GraphQL batch. */ baseBranch: string; /** Git OID of the base branch tip observed with this report, when available. */ baseRefOid?: string; mergeStatus: MergeStatusResult; checks: { passing: ClassifiedCheck[]; failing: TriagedCheck[]; inProgress: ClassifiedCheck[]; skipped: ClassifiedCheck[]; /** Checks filtered out because they were triggered by a non-PR event (push, schedule, etc.). */ filtered: ClassifiedCheck[]; /** Ignored checks with unseen annotations; omitted when empty. */ ignored?: ClassifiedCheck[]; filteredNames: string[]; blockedByFilteredCheck: boolean; ignoredNames?: string[]; supersededNames?: string[]; }; threads: { actionable: ReviewThread[]; /** Unresolved threads that need a GitHub resolve mutation but do not require code edits. */ resolutionOnly: ReviewThread[]; autoResolved: ReviewThread[]; autoResolveErrors: string[]; /** First-look items — outdated/resolved/minimized threads not yet seen by the agent. */ firstLook: FirstLookThread[]; /** Thread IDs matched by user classification rules with autoResolve:true — routed to resolveThreadIds. */ ruleAutoResolveIds?: string[]; }; comments: { actionable: ActionableComment[]; /** Visible PR comments that should be passed to `--minimize-comment-ids`. */ minimizeIds?: string[]; /** First-look items — minimized comments not yet seen by the agent. */ firstLook: FirstLookComment[]; }; changesRequestedReviews: Review[]; /** COMMENTED reviews already seen — eligible for `--minimize-comment-ids` without re-rendering. */ reviewSummaries: Review[]; /** COMMENTED reviews not yet seen — body must be surfaced before minimizing. */ firstLookSummaries: Review[]; /** COMMENTED reviews whose body changed since last seen — surface updated body, but do NOT re-add to `--minimize-comment-ids`. */ editedSummaries: Review[]; /** APPROVED reviews not yet minimized — opt-in minimize target. */ approvedReviews: Review[]; /** COMMENTED review summary IDs matched by user rules with autoResolve:true — minimized without surfacing to agent. */ ruleAutoResolveReviewSummaryIds?: string[]; /** Branch protection rule for the PR's base branch. Null when no rule exists or the base ref is unavailable. */ branchProtection: import("./github.mts").BranchProtection | null; activity?: PrActivitySummary; mergeQueue?: MergeQueueReport; } export interface ResolveOptions { resolveThreadIds?: string[]; replyThreadIds?: string[]; minimizeCommentIds?: string[]; dismissReviewIds?: string[]; dismissMessage?: string; /** When set, shepherd verifies GitHub has received this commit before resolving. */ requireSha?: string; } export interface AgentThread { id: string; /** Raw GitHub capability; omitted only in legacy/incomplete snapshots. */ viewerCanReply?: boolean; /** Raw GitHub capability; omitted only in legacy/incomplete snapshots. */ viewerCanResolve?: boolean; reviewId?: string; path: string | null; line: number | null; startLine?: number; author: string; authorType?: AuthorType; authorAssociation?: import("./github.mts").CommentAuthorAssociation; viewerDidAuthor?: true; body: string; url: string; comments?: AgentThreadComment[]; suggestion?: SuggestionBlock; edited?: boolean; } /** Comment shape emitted to the iterate agent — stripped of always-false flags. */ export interface AgentComment { id: string; /** Raw GitHub capability; omitted only in legacy/incomplete snapshots. */ viewerCanMinimize?: boolean; author: string; authorType?: AuthorType; authorAssociation?: import("./github.mts").CommentAuthorAssociation; body: string; url: string; edited?: boolean; } /** Check shape emitted to the iterate agent under `fix_code` or check escalation. */ export interface AgentCheck { name: string; runId: string | null; /** Fallback for checks where runId is null (e.g. external status checks). */ detailsUrl: string | null; /** Raw GitHub check conclusion; may be null for some completed checks from upstream data. */ conclusion: CheckConclusion; /** Workflow display name (e.g. `"CI"`). Populated on a best-effort basis when available from the jobs API. */ workflowName?: string; /** Name of the matched job (e.g. `"tests (ubuntu)"`). Distinct from check name for matrix builds. */ jobName?: string; /** Name of the first failed step (e.g. `"Run tests"`, `"Set up job"`). */ failedStep?: string; /** One-line status text shown in the GitHub UI (e.g. "67.68% of diff hit (target 85.00%)"). */ summary?: string; logExcerpt?: string; /** `gh run rerun` command, present only when the check has a runId and the viewer's repository role grants Actions rerun capability (WRITE+). */ rerunCommand?: string; /** Workflow-run attempt number, surfaced only after the initial attempt. */ runAttempt?: number; annotations?: CheckAnnotation[]; annotationOnly?: true; scope?: "merge_group"; commitOid?: string; } /** * A single CI check that is relevant to PR readiness — triggered by a PR event * (or by a StatusContext with null event), completed, and not skipped/neutral. * * Included in every iterate result so the agent always sees the full CI picture * regardless of which action fired. */ export interface RelevantCheck { name: string; conclusion: Exclude; runId: string | null; detailsUrl: string | null; /** Workflow display name (e.g. `"CI"`). Available for all checks with a runId. */ workflowName?: string; /** Name of the matched job (e.g. `"tests (ubuntu)"`). Distinct from check name for matrix builds. */ jobName?: string; /** Name of the first failed step in the matched job. */ failedStep?: string; /** One-line status text shown in the GitHub UI (e.g. "67.68% of diff hit (target 85.00%)"). */ summary?: string; logExcerpt?: string; /** Marker-gated inline annotations from this check. */ annotations?: CheckAnnotation[]; scope?: "merge_group"; commitOid?: string; } export interface GlobalOptions { prNumber?: number; targetRepository?: { owner: string; name: string; }; format: "text" | "json"; verbose?: boolean; }