@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
101 lines (100 loc) • 3.59 kB
TypeScript
import { type CitationStates } from "../content/citation-states.js";
export interface StoreHealthCounts {
activeFindings: number;
archivedBullets: number;
olderBullets: number;
retiredBullets: number;
contradictedBullets: number;
bulletsWithoutFid: number;
duplicateFids: number;
duplicateTexts: number;
citations: {
none: number;
timestampOnly: number;
withFile: number;
withCommit: number;
withSymbol: number;
withRemote: number;
};
/**
* Active findings whose citation this computer last checked to valid, drifted or broken (the daily
* sweep's `.runtime/citation-states.json`), and of those the ones that name a file.
*/
checkableCitations: {
any: number;
withFile: number;
};
reviewEntries: number;
}
export interface StoreHealthRecall {
prompts: number;
injected: number;
abstained: number;
skipped: number;
suppressedRepeats: number;
byAbstainReason: Record<string, number>;
/** Distinct session and id pairs clanker mode injected, and of those the ones get_memory_detail opened later in that session. */
clankerIds: {
injected: number;
opened: number;
};
}
/** What `.runtime` holds, by kind: the first two are regenerable and the only ones age-out may remove. */
export type RuntimeClass = "codeIndexes" | "fanoutArchive" | "fanouts" | "sessions" | "packages" | "logs" | "other";
export interface OverBudget {
component: "reviewEntries" | "runtimeBytes" | "fanoutArchiveBytes";
store?: string;
project?: string;
value: number;
budget: number;
/** What the budget stops while the component is over it. */
effect: string;
}
type AgeOutCounts = Record<"codeIndexes" | "fanoutArchive", {
count: number;
bytes: number;
}>;
export interface RuntimeAgeOut {
enabled: boolean;
days: number;
/** Days since this computer first saw age-out on (null while off); it acts from 7. */
enabledDays: number | null;
/** Earlier daily lines that reported runtime classes; it acts from 7. */
reportLines: number;
acted: boolean;
/** What age-out removes, or would remove, today. */
candidates: AgeOutCounts;
}
export interface StoreHealth {
at: string;
computer: string;
stores: Array<{
name: string;
path: string;
projects: Array<StoreHealthCounts & {
project: string;
}>;
totals: StoreHealthCounts;
/** Share of the store's active findings whose citation is checkable on this computer, to three places. */
citationCoverage: number;
}>;
runtimeBytes: Record<string, number>;
runtimeClasses: Record<RuntimeClass, number>;
budgets: {
over: OverBudget[];
};
recall: StoreHealthRecall | null;
/** Set by the daily record, not by a plain collection. */
runtimeAgeOut?: RuntimeAgeOut;
}
export declare function collectStoreHealth(phrenPath: string, now?: Date, computer?: string, citationStates?: CitationStates): StoreHealth;
export declare function recordStoreHealth(phrenPath: string, now?: Date, computer?: string): boolean;
export declare function budgetComponentName(row: OverBudget): string;
export declare function readLatestStoreHealth(phrenPath: string): StoreHealth | undefined;
/** Doctor's warn-only budgets line, from the latest daily health record: it never fails the check. */
export declare function budgetDoctorCheck(phrenPath: string): {
name: string;
ok: true;
detail: string;
};
export {};