autosnippet
Version:
Extract code patterns into a knowledge base for AI coding assistants
39 lines (38 loc) • 1.47 kB
TypeScript
/**
* RecommendationPipeline — 统一推荐管线
*
* 多阶段处理:
* 1. Recall — 多策略并行召回候选 (Rule / AI / Vector / Popularity)
* 2. Score — 综合评分 (信号强度 × 用户偏好 × 新鲜度)
* 3. Rank — 排序 + 截断
* 4. Filter — 去重、过滤已有 Skill、过滤频繁忽略的类别
* 5. Deliver — 输出最终推荐列表 + 触发 Hook
*
* 设计原则:
* - 静默降级: 任何策略失败不影响其他策略
* - 离线优先: 无 AI 时降级到规则召回
* - 反馈闪环: 利用 FeedbackStore 调整排序权重
*/
import type { FeedbackStore } from './FeedbackStore.js';
import type { SkillHooks } from './SkillHooks.js';
import type { RecallStrategy, RecommendationContext, ScoredRecommendation } from './types.js';
export declare class RecommendationPipeline {
#private;
constructor(opts?: {
feedbackStore?: FeedbackStore | null;
skillHooks?: SkillHooks | null;
});
/** 注册召回策略 */
addStrategy(strategy: RecallStrategy): void;
/** 获取已注册策略列表 */
getStrategies(): ReadonlyArray<RecallStrategy>;
/**
* 执行推荐管线
*
* @param context 推荐上下文
* @param topK 最多返回数量
* @returns 排序后的推荐结果列表
*/
recommend(context: RecommendationContext, topK?: number): Promise<ScoredRecommendation[]>;
}
export default RecommendationPipeline;