UNPKG

@phren/cli

Version:

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

62 lines (61 loc) • 2.71 kB
import type { RecallDocRef, RecallFloorReason, RecallResult } from "./types.js"; /** Why the hook stopped before recall ran: another agent's message, or a prompt with no keywords. */ export type RecallSkipReason = "machine-prompt" | "no-keywords"; export interface RecallTraceFloorRow { path: string; passed: boolean; reason: RecallFloorReason; distinct: number; rarity: number; overlap: number; matched: string[]; } export interface RecallTraceEntry { at: string; session?: string; project: string | null; prompt: string; /** Set when the hook stopped before recall ran; the recall fields are then absent. */ skipped?: RecallSkipReason; keywords?: string[]; intent?: string; abstained?: string | null; candidates?: number; floor?: RecallTraceFloorRow[]; /** Store-relative paths and score keys of what was injected, after the summary block and budget trim; `id` is what clanker mode printed. */ injected?: Array<{ path: string; key: string; type: string; id?: string; }>; /** Rows skipped because this session injected their bullet within the repeat window. */ suppressedRepeats?: number; tokens?: number; budget?: number; ms?: Record<string, number>; } export declare function recallTraceFile(phrenPath: string): string; /** The trace line for a prompt recall ran on. `injected` is what the hook finally printed. */ export declare function traceEntryFromResult(phrenPath: string, prompt: string, result: RecallResult, injected: Array<RecallDocRef & { key: string; id?: string; }>, extra?: { session?: string; indexMs?: number; }): RecallTraceEntry; /** The trace line for a prompt the hook stopped on before recall. */ export declare function skippedTraceEntry(prompt: string, skipped: RecallSkipReason, project: string | null, session?: string): RecallTraceEntry; /** Append one entry. Best-effort: a trace failure never breaks the hook. */ export declare function recordRecallTrace(phrenPath: string, entry: RecallTraceEntry): void; /** Every parsed entry, oldest first; malformed lines are skipped. */ export declare function readRecallTrace(phrenPath: string): RecallTraceEntry[]; export interface MemoryOpenEntry { at: string; session: string; id: string; } export declare function memoryOpensFile(phrenPath: string): string; /** One get_memory_detail call; Claude Code passes its session id to the MCP server, and without one there is nothing to pair. */ export declare function recordMemoryOpen(phrenPath: string, id: string, session?: string | undefined): void; export declare function readMemoryOpens(phrenPath: string): MemoryOpenEntry[];