export const THINKING_LEVELS = [ "off", "minimal", "low", "medium", "high", "xhigh", "max", ] as const; export type ThinkingLevel = (typeof THINKING_LEVELS)[number]; /** * Resolved model规格 captured from the subprocess JSONL stream, used to * verify the subprocess actually ran the requested model. Optional because * older or minimal Pi builds may not emit a model resolution event. */ export interface ResolvedModel { provider: string; id: string; contextWindow: number; maxTokens: number; } /** * Outcome of a single isolated agent execution. * * `ok:false` covers terminal failures (terminated, aborted, no output, model * mismatch). `partialText` preserves any assistant text observed before the * failure for diagnostics only; it must never feed findings, validation, or * aggregation. */ export type AgentOutcome = | { ok: true; text: string; stopReason: string; partialText: string; resolvedModel?: ResolvedModel; piRetryAttempts: number; } | { ok: false; stopReason: string; errorMessage: string; partialText: string; resolvedModel?: ResolvedModel; piRetryAttempts: number; }; export type PullRequestTarget = | { kind: "current" } | { kind: "number"; number: number } | { kind: "url"; url: string; owner: string; repo: string; number: number }; export interface ReviewOptions { target: PullRequestTarget; comment: boolean; model?: string; thinking?: ThinkingLevel; } export interface ModelSelection { model: string; thinking: ThinkingLevel; } export interface ChangedFile { path: string; previousPath?: string; status: string; additions: number; deletions: number; } export interface LinkedIssue { number: number; title: string; body: string; url: string; } export interface PullRequestSnapshot { owner: string; repo: string; number: number; url: string; state: string; isDraft: boolean; author: string; title: string; body: string; baseSha: string; headSha: string; files: ChangedFile[]; diff: string; linkedIssues: LinkedIssue[]; existingReviewUrl?: string; } export type FindingCategory = | "instructions" | "bug" | "regression" | "permission" | "security" | "maintenance" | "goal" | "scope"; interface FindingBase { id: string; category: FindingCategory; title: string; description: string; evidence: string; introducedByPr: string; suggestion?: string; } export interface CodeFinding extends FindingBase { kind: "code"; path: string; line: number; startLine?: number; side: "LEFT" | "RIGHT"; } export interface TaskOmissionFinding extends FindingBase { kind: "task-omission"; requirement: string; path?: string; } export type Finding = CodeFinding | TaskOmissionFinding; export interface CoverageReceipt { complete: boolean; reviewedFiles: string[]; } export interface ReviewerOutput { schemaVersion: 1; coverage: CoverageReceipt; findings: Finding[]; } export interface ValidatorOutput { schemaVersion: 1; findingId: string; valid: boolean; confidence: number; evidence: string; rejectionReason?: string; finding: Finding; } export type ReviewStatus = "complete" | "skipped" | "incomplete" | "aborted"; export interface ReviewResult { status: ReviewStatus; snapshot?: PullRequestSnapshot; findings: Finding[]; reason?: string; failures: string[]; }