import type { CommitSummary } from "./types"; /** `authorEmail` is optional because briefs cached before it was added lack it. */ export type CommitBrief = Pick & { authorEmail?: string; }; export function toBrief(commit: CommitSummary): CommitBrief { return { sha: commit.sha, shortSha: commit.shortSha, subject: commit.subject, authorName: commit.authorName, authorEmail: commit.authorEmail, committedAt: commit.committedAt, }; } /** A run of consecutive final-version lines (0-based `start`) attributed to one commit. */ export type BlameRange = { start: number; count: number; sha: string }; export type BlameResult = { lines: string[]; ranges: BlameRange[]; commits: Record; }; export type CodeSearchHit = { owner: string; repo: string; ref: string; path: string; snippet: string; /** Matching lines with highlight spans; empty for path-only queries. */ lines: CodeSearchLine[]; /** Lines in the file that matched, which can exceed `lines`. */ matchCount: number; }; export type CodeSearchLine = { number: number; text: string; ranges: Array<{ start: number; end: number }>; clippedStart: boolean; clippedEnd: boolean; }; export type CodeSearchPage = { hits: CodeSearchHit[]; page: number; hasMore: boolean; total: number; totalCapped: boolean; }; export const SNIPPET_OPEN = "\u0001"; export const SNIPPET_CLOSE = "\u0002"; export type NotebookOutput = { id: number } & ( | { kind: "text"; text: string; stderr: boolean } | { kind: "image"; mime: string; data: string } | { kind: "error"; text: string } ); export type NotebookCell = { id: number } & ( | { kind: "markdown"; html: string } | { kind: "code"; source: string; executionCount: number | null; outputs: NotebookOutput[] } | { kind: "raw"; text: string } ); export type Notebook = { language: string; cells: NotebookCell[]; truncated: boolean };