UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

87 lines (86 loc) • 3.27 kB
export type DreamTranscriptSource = "claude" | "codex" | "copilot" | "opencode"; export declare const DEFAULT_TRANSCRIPT_BUDGET_CHARS = 120000; export interface DreamTranscriptRoot { source: DreamTranscriptSource; root: string; maxDepth: number; } export interface DreamTranscript { source: DreamTranscriptSource; session: string; cwd: string; first: string; last: string; turns: number; /** Trimmed rendering: `[t<n>] user|assistant|tools: ...` lines. */ text: string; trimmed?: true; } export interface DreamFindingInput { fid: string; date: string; text: string; status: string; citation?: string; } export interface DreamPageInput { slug: string; title: string; summary: string; } export interface DreamBudgetState { sizeBytes: number; budgetBytes: number; over: boolean; candidates: string[]; } export interface DreamInputs { project: string; from: string; to: string; repoDir?: string; transcripts: DreamTranscript[]; transcriptChars: number; /** Sessions in the window left out entirely for budget. */ transcriptsDropped: number; /** Unattributed OpenCode sessions hold the watermark back. */ unresolvedTranscripts?: number; findings: DreamFindingInput[]; truths: string[]; topics: Array<{ slug: string; label: string; }>; pages: DreamPageInput[]; gitLog: string[]; journal: string[]; budget: DreamBudgetState; } export interface CollectOptions { from: Date; to: Date; budgetChars?: number; injectBudgetKB?: number; /** Transcript locations; defaults to every harness Phren reads on this computer. */ roots?: DreamTranscriptRoot[]; /** Folders whose sessions belong to the project; defaults to its source path and that repo's worktrees. */ projectDirs?: string[]; /** Replace the git reader (tests); false skips git. */ gitLog?: false | ((dir: string) => string[]); } export declare function defaultTranscriptRoots(): DreamTranscriptRoot[]; export declare function projectStoreDir(phrenPath: string, project: string): string; export declare function underDirs(cwd: string, dirs: string[]): boolean; /** One transcript trimmed to the window, or undefined when it is not the project's or has nothing in the window. */ export declare function readTranscript(source: DreamTranscriptSource, file: string, dirs: string[], from: number, to: number, metadataCwd?: string): DreamTranscript | undefined; /** Fit transcripts into the budget, newest session first; the oldest turns of a session are trimmed before it is dropped. */ export declare function budgetTranscripts(all: DreamTranscript[], budgetChars: number): { kept: DreamTranscript[]; chars: number; dropped: number; }; /** The repo's own folder plus its other worktrees, where agents also work on this project. */ export declare function projectDirsFor(phrenPath: string, project: string): string[]; export declare function readTruths(phrenPath: string, project: string): string[]; export declare function journalFile(phrenPath: string, project: string): string; export declare function collect(phrenPath: string, project: string, options: CollectOptions): Promise<DreamInputs>;