UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

152 lines (151 loc) 4.5 kB
/** * MCP Handlers 知识浏览类 (V3: 使用 knowledgeService) * listByKind, listRecipes, getRecipe, recipeInsights, confirmUsage * * 投影原则:只交付 Agent 可操作的信号,不交付内部运营/审计数据。 * - _projectItem list 列表摘要(精简 ~10 字段) * - _projectForAgent get 详情(去除噪音 ~25 字段) */ import type { BrowseGetArgs, BrowseListArgs, ConfirmUsageArgs, McpContext } from './types.js'; export declare function listByKind(ctx: McpContext, kind: string, args: BrowseListArgs): Promise<{ success: boolean; errorCode: string | null; message: string; data: { kind: string; count: any; total: any; items: any; } | null; meta: { source?: string | undefined; responseTimeMs?: number | undefined; version: string; tool?: string | undefined; }; }>; export declare function listRecipes(ctx: McpContext, args: BrowseListArgs): Promise<{ success: boolean; errorCode: string | null; message: string; data: { count: any; total: any; items: any; } | null; meta: { source?: string | undefined; responseTimeMs?: number | undefined; version: string; tool?: string | undefined; }; }>; export declare function getRecipe(ctx: McpContext, args: BrowseGetArgs): Promise<{ success: boolean; errorCode: string | null; message: string; data: { id: string; title: string; description: string | undefined; trigger: string; kind: string | undefined; language: string | undefined; category: string | undefined; knowledgeType: string | undefined; complexity: string | undefined; tags: string[] | undefined; whenClause: string | undefined; doClause: string | undefined; dontClause: string | undefined; coreCode: string | undefined; content: { steps?: unknown[] | undefined; rationale?: string | undefined; markdown?: string | undefined; pattern?: string | undefined; } | undefined; headers: string[] | undefined; reasoning: { sources?: unknown[] | undefined; confidence?: number | undefined; whyStandard?: string | undefined; } | undefined; relations: Record<string, unknown[]> | undefined; constraints: { sideEffects?: unknown[] | undefined; guards?: unknown[] | undefined; } | undefined; } | null; meta: { source?: string | undefined; responseTimeMs?: number | undefined; version: string; tool?: string | undefined; }; }>; export declare function recipeInsights(ctx: McpContext, args: BrowseGetArgs): Promise<{ success: boolean; errorCode: string | null; message: string; data: { id: any; title: any; trigger: any; kind: any; lifecycle: any; language: any; category: any; knowledgeType: any; quality: { overall: any; completeness: any; adaptation: any; documentation: any; }; stats: { adoptions: any; applications: any; guardHits: any; views: any; searchHits: any; }; content: { hasPattern: boolean; hasRationale: boolean; hasMarkdown: boolean; stepsCount: any; codeChangesCount: any; }; relations: Record<string, number>; constraints: Record<string, unknown[]>; tags: any; complexity: any; scope: any; createdBy: any; createdAt: any; updatedAt: any; } | null; meta: { source?: string | undefined; responseTimeMs?: number | undefined; version: string; tool?: string | undefined; }; }>; export declare function confirmUsage(ctx: McpContext, args: ConfirmUsageArgs): Promise<{ success: boolean; errorCode: string | null; message: string; data: { recipeId: string; usageType: string; feedback: string | null; } | null; meta: { source?: string | undefined; responseTimeMs?: number | undefined; version: string; tool?: string | undefined; }; }>;