export type Source = { kind: "working" | "staged" | "base"; ref?: string }; export type DiffLine = { kind: "context" | "add" | "delete" | "meta"; text: string; oldLine?: number; newLine?: number; }; export type Hunk = { id: string; path: string; oldPath?: string; header: string; lines: DiffLine[]; }; export type Snapshot = { id: string; repoRoot: string; source: Source; base: string; head: string; hunks: Hunk[]; skipped: Array<{ path: string; reason: string }>; }; export type Layer = { id: string; title: string; summary: string; hunks: Array<{ id: string; summary: string }>; flow?: string[]; }; export type Plan = { summary: string; cohorts: Array<{ title: string; layers: Layer[] }>; }; export type Finding = { id: string; hunkId: string; side: "old" | "new"; line: number; severity: "question" | "minor" | "major"; text: string; }; export type Draft = { reviewed: string[]; findings: Finding[]; notes: string; }; export type ForgeComment = { id: string; url: string; author: string; body: string; kind: "discussion" | "review" | "inline"; path?: string; side?: "old" | "new"; line?: number; commit?: string; replyTo?: string; outdated: boolean; }; export type ForgeReview = { provider: string; providerLabel: string; repository: string; number: number; url: string; title: string; body: string; author: string; baseRef: string; baseSha: string; headRef: string; headSha: string; checkoutBranch: string; comments: ForgeComment[]; }; export type Review = { snapshot: Snapshot; plan: Plan; draft: Draft; forge?: ForgeReview; }; export type Feedback = Draft & { snapshotId: string }; export type AskExchange = { question: string; answer: string; hunkId: string | null; }; export type AskThread = { layerId: string | null; messages: AskExchange[]; }; export type AskRequest = { layerId: string | null; hunkId: string | null; question: string; history: AskExchange[]; }; export type ReviewServer = { url: string; close(): Promise; }; export type ReviewLifecycleEvent = | { type: "draft"; draft: Draft } | { type: "verified-current" } | { type: "answering" } | { type: "refreshing" } | { type: "ready"; review: Review } | { type: "stale" } | { type: "feedback-sent" } | { type: "error"; message: string }; export type ServerOptions = { review: Review; isCurrent(signal: AbortSignal): Promise; refresh(signal: AbortSignal): Promise; ask(request: AskRequest, signal: AbortSignal): Promise; save(draft: Draft): void; submit(feedback: Feedback): Promise; onLifecycle?(event: ReviewLifecycleEvent): void; onClose?(): void; };