@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
38 lines • 2.07 kB
TypeScript
import { type SessionSummary } from "./session-summary.ts";
import type { FileStamp } from "./session-summary-lru.ts";
/**
* Name of the summary index inside the sessions directory it describes. The
* extension is deliberately not `.jsonl`: every `*.jsonl` there is a session.
*/
export declare const SESSION_SUMMARY_INDEX_FILE = ".session-summaries.index";
/** One indexed session file: its basename, the stamp it was read at, and its summary. */
export type IndexEntry = {
readonly file: string;
readonly stamp: FileStamp;
readonly summary: SessionSummary;
/** Serialized line, newline included. */
readonly line: string;
readonly lineBytes: number;
};
/** An index as loaded from disk; an absent or unusable file loads as `usable: false`. */
export type LoadedIndex = {
readonly usable: boolean;
/** Deduplicated entries, last line wins. */
readonly entries: ReadonlyMap<string, IndexEntry>;
/** Bytes after the header line, including torn and superseded lines. */
readonly entryBytes: number;
/** False when the file ends in a torn line, so the next append must start a new line. */
readonly endsWithNewline: boolean;
};
/** Serialize one entry, or undefined when the summary would not survive a JSON round trip. */
export declare function toIndexEntry(file: string, stamp: FileStamp, summary: SessionSummary): IndexEntry | undefined;
/**
* Load an index, tolerating every failure: a missing file, a missing or foreign
* version header, or a read error loads as unusable; a line that does not parse
* (a torn append, truncation, garbage) is skipped.
*/
export declare function loadIndexFile(path: string): Promise<LoadedIndex>;
/** Append entries one whole line per write, first closing a torn tail when there is one. */
export declare function appendIndexEntries(path: string, entries: readonly IndexEntry[], endsWithNewline: boolean): Promise<void>;
export declare function rewriteIndexFile(path: string, entries: readonly IndexEntry[]): Promise<void>;
//# sourceMappingURL=session-summary-index-file.d.ts.map