UNPKG

@phren/cli

Version:

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

48 lines (47 loc) • 2.54 kB
/** * Size budgets for tool output. * * Claude Code rejects an MCP tool result over about 25k tokens, and the call * then fails outright. Store text is long-lined (task Context fields and * consolidated reference lines run to several KB), so line-based snippets and * per-item limits alone do not bound a response. These budgets are in * characters of the serialized result; JSON-escaped markdown is roughly 3–4 * characters per token. */ /** Most characters one search result's snippet may use. */ export declare const SNIPPET_MAX_CHARS = 1200; /** Characters shared by all snippets in one search response (each also appears in `data`). */ export declare const SNIPPETS_TOTAL_CHARS = 6000; /** Floor for a snippet when many results split the total. */ export declare const SNIPPET_MIN_CHARS = 240; /** Per-field cap for text shown in list views (task context, truths). */ export declare const LIST_TEXT_MAX_CHARS = 300; /** Most characters of a project's summary.md shown by get_project_summary. */ export declare const SUMMARY_MAX_CHARS = 6000; /** Most truths listed by get_project_summary. */ export declare const SUMMARY_MAX_TRUTHS = 20; /** Target ceiling for a list response before it shrinks its page size. */ export declare const LIST_RESPONSE_MAX_CHARS = 40000; /** Page size for full-document reads (get_memory_detail). */ export declare const DETAIL_PAGE_CHARS = 16000; /** Hard ceiling for any MCP response; past this the payload is replaced, not sent. */ export declare const MCP_RESPONSE_MAX_CHARS = 60000; /** Per-result snippet budget when `count` results share one response. */ export declare function snippetBudget(count: number): number; /** Cut `text` to at most `max` characters, ending with an ellipsis when cut. */ export declare function clipText(text: string, max: number): string; /** Cut `text` to at most `max` characters, keeping the end (for append-only notes). */ export declare function clipTail(text: string, max: number): string; /** * Cut `text` to at most `max` characters, keeping a window around the first * occurrence of any term (lowercase). Falls back to the start when no term hits. */ export declare function focusText(text: string, terms: string[], max: number): string; /** * Build a list payload, halving its page size until the serialized result fits * `maxChars` (or the size reaches 1). `build` receives the size to use. */ export declare function shrinkToBudget<T>(initialSize: number, build: (size: number) => T, maxChars?: number): { payload: T; size: number; };