/** * context-budget.ts — 统一内容分级 + 预算(单一事实源) * * 目的:收敛「给 AI 组装上下文时,什么内容优先、各占多少预算」这一散点逻辑。 * 此前 prompt-builder(P0-P3)、unit-context-assembler(核心/关联/全局)、 * content-delivery(L0-L3)、analyze-context-guard(LEVEL 阈值)各自维护一套 * 分级/预算,改了这层没同步那层,反复出现「两层矛盾」—— * 例如需求文档一层说不截断、另一层却按低优先级砍掉。 * * 本模块是唯一入口:所有上下文组装处都引用这里的分级标准与预算常量。 * 以后调整「什么内容优先 / 各占多少预算」只改这一处。 * * v8.3.194+ 落地,替代 prompt-builder 本地的 isSpecContent / getPriority。 */ /** 内容优先级:0=需求/Spec(不裁剪) 1=代码卡片/源码 2=知识图谱/任务链 3=其他 */ export type ContentPriority = 0 | 1 | 2 | 3; /** 每档预算(字符数)。P0 需求/Spec 设真实上限(约 30K tokens),超限按中间态截断。 */ export declare const TIER_BUDGETS: { readonly P0: 40000; readonly P1: 10000; readonly P2: 5000; readonly P3: 3000; }; /** * 判断内容是否属于「需求/Spec」内容(最高优先级 P0,不裁剪)。 * 依据 name 判断(前缀 + 关键词)。 * 覆盖:需求/规格/数据库设计/技术方案/开发指南/分析/契约/任务上下文/ * 统一检索文档块(📄)/阅读清单(📚)/用户补充。 */ export declare function isSpecContent(name: string): boolean; /** * 统一内容分级(唯一实现,替代各处散落的 getPriority)。 * P0 需求/Spec → P1 代码卡片/源码/前端结构/INFO_GAP → P2 知识图谱/任务链 → P3 其他 */ export declare function classifyContent(name: string): ContentPriority; /** 可被统一预算裁剪的内容项(与 TaskExtraSpec 结构兼容) */ export interface BudgetItem { name: string; path: string; content: string; } /** 预算裁剪结果 */ export interface BudgetResult { kept: BudgetItem[]; used: { p0: number; p1: number; p2: number; p3: number; }; } /** * 统一的按分级 + 预算裁剪。 * 先按优先级排序,再逐档预算裁剪:P0 无条件保留,P1/P2/P3 超预算时截断或丢弃。 * 预算可通过 opts 覆盖(默认取 TIER_BUDGETS)。 */ export declare function applyTierBudget(items: BudgetItem[], opts?: { budgetP0?: number; budgetP1?: number; budgetP2?: number; budgetP3?: number; }): BudgetResult; //# sourceMappingURL=context-budget.d.ts.map