UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

51 lines • 2.62 kB
import { type RepositoryIdentity } from "./repository-identity.ts"; import type { SessionHeader } from "./session-manager.ts"; /** * Everything a picker row needs from one session file, derived from every record * in the file. Exact by construction: no window, no marker heuristic, so a first * user message, a rename, or an out-of-order activity timestamp is found no * matter how deep in the transcript it sits. */ export type SessionSummary = { readonly header: SessionHeader; /** Latest `session_info` name anywhere in the file, including explicit clears. */ readonly name: string | undefined; /** First visible user message text anywhere in the file. */ readonly firstUserMessage: string; /** Count of records that parsed as `type: "message"`. */ readonly messageCount: number; /** Max user/assistant activity time seen, regardless of record order. */ readonly lastActivityTime: number | undefined; /** Full user/assistant transcript text in file order. */ readonly allMessagesText: string; /** Latest repository identity the session recorded, so a moved repository's sessions can be found. */ readonly repositoryIdentity?: RepositoryIdentity; }; /** What a completed {@link readFileLines} pass saw. */ export type FileLinesRead = { /** False when `onLine` stopped the pass early. */ readonly completed: boolean; /** Bytes read from the file. */ readonly bytes: number; /** Whether the last byte read was a newline (a torn tail has none). */ readonly endsWithNewline: boolean; }; /** * Read a file line by line through one reused 1 MiB buffer, handing each line * (LF-split, a trailing CR dropped) to `onLine` until it returns false. * * This replaces `readline`, whose per-line async iteration dominated summary * cost (senpi#2087). Only the unfinished tail of a chunk is carried between * reads, and the next newline search resumes where the carried tail ends, so a * record larger than the buffer is not rescanned per chunk. Read errors throw. */ export declare function readFileLines(filePath: string, onLine: (line: string) => boolean): Promise<FileLinesRead>; /** * Read one session file line by line and fold it into an exact summary. * * Memory stays bounded by one read buffer plus the transcript text the summary * contract requires; no full-file string is ever materialized. A file whose * first record is not a session header, or that cannot be read, yields null. */ export declare function readSessionSummary(filePath: string): Promise<SessionSummary | null>; //# sourceMappingURL=session-summary.d.ts.map