UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

45 lines (44 loc) 1.35 kB
/** * ToolRequirementAnalyzer — 工具需求分析器 * * 分析结构化意图,确定满足需求的最佳路径: * 1. Reuse — 注册表中已有完全匹配的工具 * 2. Compose — 可通过组合已有工具满足 * 3. Generate — 必须由 LLM 生成新工具代码 */ interface ToolRegistryLike { has(name: string): boolean; getToolNames(): string[]; } export interface ToolRequirement { /** 用户意图描述 */ intent: string; /** 关键动作词(如 read / search / transform / validate) */ action: string; /** 目标对象(如 file / database / API) */ target: string; /** 附加约束 */ constraints?: string[]; } export type ForgeMode = 'reuse' | 'compose' | 'generate'; export interface AnalysisResult { /** 推荐的 Forge 模式 */ mode: ForgeMode; /** 置信度 0-1 */ confidence: number; /** 推理理由 */ reasoning: string; /** mode=reuse 时:匹配的工具名 */ matchedTool?: string; /** mode=compose 时:建议参与组合的工具列表 */ composableTools?: string[]; } export declare class ToolRequirementAnalyzer { #private; constructor(registry: ToolRegistryLike); /** * 分析需求并推荐 Forge 模式 */ analyze(requirement: ToolRequirement): AnalysisResult; } export {};