UNPKG

@phren/cli

Version:

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

77 lines (76 loc) • 2.59 kB
import { type CitationFreshness } from "../content/citation-freshness.js"; import { type FindingItem } from "../data/access.js"; export declare const PROJECT_MEMORY_ROUTE: RegExp; export declare const MEMORY_LIMITS: { readonly findings: 500; }; export interface MemoryFinding { id: string; text: string; type: string | null; status: FindingItem["status"]; created: string | null; citationFreshness?: CitationFreshness; citation: { file: string | null; line: number | null; commit: string | null; name: string | null; } | null; } export interface ProjectMemory { project: string; store_id: string | null; remote: string | null; truncated: boolean; findings: MemoryFinding[]; truths: { text: string; }[]; tasks: { active: []; queue: []; done: []; }; } export declare function projectMemory(base: string, rawProject: string): ProjectMemory; export interface FileFinding extends MemoryFinding { match: "file" | "symbol"; } /** Findings about these repository files: cited by file, or citing a function, * type or variable the code index places in one of them. */ export declare function memoryForFiles(base: string, rawProject: string, paths: string[]): Promise<{ project: string; store_id: string | null; symbols: "indexed" | "unavailable"; truncated: boolean; findings: FileFinding[]; }>; export interface SearchHit { kind: "finding" | "truth"; score: number; matched: number; text: string; finding: MemoryFinding | null; } /** * Findings and truths ranked against `q` with phren's retrieval tokenizer and * chunk matcher (the hook's relevance floor). Each query token is weighted by * how rare it is across this project's findings and truths (the normalised IDF * `tokenRarity` uses), so a stack trace's common words count for little. * `score` is the matched share of that weight, 0 to 1; findings that are no * longer active count half. */ export declare function memorySearch(base: string, rawProject: string, q: string, limit: number): { project: string; query: string; results: SearchHit[]; }; /** Save one finding through the same path as the add_finding MCP tool: the * project's write permission, duplicate and conflict checks, the secret * scan and citation validation against the code index. */ export declare function saveFinding(base: string, rawProject: string, input: unknown): Promise<{ project: string; status: string; finding: MemoryFinding | null; }>;