@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
109 lines (108 loc) • 3.71 kB
TypeScript
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;
readonly active: 200;
readonly queue: 200;
readonly done: 50;
};
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 MemoryTask {
id: string;
text: string;
created: string | null;
context: string | null;
}
export interface ProjectMemory {
project: string;
store_id: string | null;
remote: string | null;
truncated: boolean;
findings: MemoryFinding[];
truths: {
text: string;
}[];
tasks: {
active: MemoryTask[];
queue: MemoryTask[];
done: MemoryTask[];
};
}
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[];
};
/** Open tasks that name this branch (or its last segment) or the issue number
* in it (`fix/123-login`, `issue-123`, `gh-123`). One read of tasks.md. */
export declare function tasksForBranch(base: string, rawProject: string, branch: string): {
project: string;
branch: string;
truncated: boolean;
tasks: (MemoryTask & {
section: "active" | "queue";
match: "branch" | "issue";
})[];
};
/** 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;
}>;
/** Mark one open task done, by the stable id `/tasks?branch=` gave gitboy when
* its pull request merged. Exact ids only: no text matching, so a wrong guess
* can never complete another task. A task already done answers `already-done`. */
export declare function completeProjectTask(base: string, rawProject: string, input: unknown): {
project: string;
id: string;
status: "already-done";
} | {
project: string;
id: string;
status: "completed";
};