/** * analyze-context-guard — 分析上下文爆炸防护引擎(v6.75.0) * * 核心能力: * 1. 预估分析上下文大小(基于文件数、端数、模块数、代码量) * 2. 智能分段策略推荐(一次性 / 按端 / 按模块 / 按功能单元) * 3. 交互式确认:提示用户当前预估大小,建议分段策略 * 4. 自动降级:非交互模式下自动选择最优策略 * * 预估模型: * - 基础 overhead:每个 prompt 模板约 2K tokens * - 每端 overhead:读取索引 + 分析指令约 3K tokens * - 每模块 overhead:需求文档 + 关联代码约 5K tokens * - 每功能单元 overhead:详细设计约 8K tokens * - 全局文档 overhead:FUNCTION_MAP + API_CONTRACT 约 4K tokens */ /** 上下文大小等级 */ export type ContextSizeLevel = 'small' | 'medium' | 'large' | 'xlarge'; /** 分段策略 */ export type SegmentationStrategy = 'all-at-once' | 'by-platform' | 'by-module' | 'by-feature-unit'; /** 上下文预估结果 */ export interface ContextEstimate { /** 预估 tokens 数(近似值) */ estimatedTokens: number; /** 大小等级 */ level: ContextSizeLevel; /** 推荐策略 */ recommendedStrategy: SegmentationStrategy; /** 预估原因 */ reasons: string[]; /** 各维度详情 */ details: { platformCount: number; moduleCount: number; featureUnitCount: number; totalFileSize: number; codeFileCount: number; docFileCount: number; }; } /** 分段计划 */ export interface SegmentationPlan { strategy: SegmentationStrategy; segments: Segment[]; totalEstimatedTokens: number; explanation: string; } /** 单个分段 */ export interface Segment { id: string; name: string; type: 'global' | 'platform' | 'module' | 'feature-unit'; target: string; estimatedTokens: number; dependencies: string[]; inputs: string[]; outputs: string[]; } /** * 预估分析上下文大小 * @param iterDir 迭代目录 * @param options 分析选项 */ export declare function estimateContextSize(iterDir: string, options?: { withCode?: boolean; platform?: string; feature?: string; }): Promise; /** * 生成分段计划 */ export declare function buildSegmentationPlan(estimate: ContextEstimate, iterDir: string, options?: { withCode?: boolean; }): Promise; /** * 显示上下文预估报告并获取用户确认(交互模式) * @returns 用户选择的策略 */ export declare function promptSegmentationStrategy(estimate: ContextEstimate, plan: SegmentationPlan, interactive: boolean): Promise; /** * 生成上下文防护提示(用于 prompt 输出) */ export declare function buildContextGuardPrompt(estimate: ContextEstimate, plan: SegmentationPlan): string; //# sourceMappingURL=analyze-context-guard.d.ts.map