autosnippet
Version:
Extract code patterns into a knowledge base for AI coding assistants
84 lines (83 loc) • 2.04 kB
TypeScript
/** Plan 步骤 */
interface PlanStep {
description: string;
status: 'pending' | 'done';
keywords?: string[];
}
/** Plan 对象 */
interface Plan {
steps: PlanStep[];
createdAtIteration: number;
}
/** Trace 统计数据 */
interface TraceStats {
totalRounds: number;
thoughtCount: number;
totalActions: number;
totalObservations: number;
reflectionCount: number;
}
/** 工具动作 */
interface ToolAction {
tool: string;
params?: Record<string, unknown>;
}
/** ActiveContext 追踪接口 */
export interface ActiveTrace {
expectPlan?(): void;
getPlan?(): Plan | null;
getPlanStepsMutable?(): PlanStep[];
getCurrentRoundActions?(): ToolAction[];
getStats?(): TraceStats;
}
/** checkPlanning 的状态参数 */
interface PlanCheckState {
metrics: {
iteration: number;
};
budget: {
maxIterations: number;
};
strategy: {
replanInterval?: number;
};
}
export declare class PlanTracker {
#private;
/** 获取计划进度 */
get progress(): {
coveredSteps: number;
totalSteps: number;
deviationScore: number;
unplannedActions: number;
lastReplanIteration: number | null;
consecutiveOffPlan: number;
};
/**
* 检查是否需要触发规划 + 生成规划 nudge
*
* @param state 从 ExplorationTracker 传入
* @param trace ActiveContext 实例
* @returns |null}
*/
checkPlanning(state: PlanCheckState, trace: ActiveTrace | null): {
type: string;
text: string;
} | null;
/**
* 更新计划进度(从 ReasoningLayer 迁入)
* 将本轮工具调用与 plan 步骤进行模糊匹配
*
* @param trace ActiveContext 实例
*/
updatePlanProgress(trace: ActiveTrace | null): void;
/**
* 推理质量评分
* @returns }
*/
getQualityMetrics(trace: ActiveTrace | null): {
score: number;
breakdown: Record<string, number>;
};
}
export {};