UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

57 lines (56 loc) 2.02 kB
/** * SkillAdvisor — 基于使用模式的 Skill 推荐引擎 * * 分析项目使用行为并推荐创建 Skill: * 1. Guard 违规模式 — 同类违规反复出现 → 编码规范 Skill * 2. Memory 偏好积累 — 用户偏好超过阈值 → 约定总结 Skill * 3. Recipe 分布缺口 — 某类 Recipe 高频使用但无对应 Skill * 4. 搜索 miss — 高频搜索但低命中 → 知识盲区 Skill * * 设计原则: * - 只做分析和推荐,不自动创建(由 Agent 决策执行 create_skill) * - 静默降级:任何数据源读取失败不影响其他维度 * - 零 AI 调用 — 纯规则分析,确保即时返回 * - 推荐结果包含 draft 草稿(name + description + rationale), * Agent 可直接调用 create_skill 创建 */ import type { AuditRepositoryImpl } from '../../repository/audit/AuditRepository.js'; import type { KnowledgeRepositoryImpl } from '../../repository/knowledge/KnowledgeRepository.impl.js'; export interface SkillSuggestion { name: string; description: string; rationale: string; source: string; priority: 'high' | 'medium' | 'low'; signals: Record<string, unknown>; } interface SkillAdvisorOpts { knowledgeRepo?: KnowledgeRepositoryImpl | null; auditRepo?: AuditRepositoryImpl | null; } export declare class SkillAdvisor { #private; constructor(projectRoot: string, { knowledgeRepo, auditRepo }?: SkillAdvisorOpts); /** * 生成 Skill 推荐列表 * * @returns {{ * suggestions: Array<{ * name: string, * description: string, * rationale: string, * source: string, * priority: 'high' | 'medium' | 'low', * signals: object * }>, * analysisContext: object * }} */ suggest(): Promise<{ suggestions: SkillSuggestion[]; existingProjectSkills: unknown[]; analysisContext: Record<string, unknown>; hint: string; }>; } export default SkillAdvisor;