UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

324 lines (323 loc) 11.9 kB
/** * mcp-tools.ts MCP 工具输入 Zod Schema * * 每个 MCP 工具的输入参数定义为 Zod Schema,既做运行时校验, * 又可通过 zodToJsonSchema() 自动生成 inputSchema 声明(消除双重维护)。 * * 命名约定:`{ToolSuffix}Input`,如 `SearchInput` 对应 `autosnippet_search`。 * * @module shared/schemas/mcp-tools */ import { z } from 'zod'; export declare const HealthInput: z.ZodObject<{}, z.core.$strip>; export type HealthInput = z.infer<typeof HealthInput>; export declare const SearchInput: z.ZodObject<{ query: z.ZodString; mode: z.ZodDefault<z.ZodEnum<{ auto: "auto"; context: "context"; keyword: "keyword"; semantic: "semantic"; bm25: "bm25"; }>>; kind: z.ZodDefault<z.ZodEnum<{ pattern: "pattern"; rule: "rule"; fact: "fact"; all: "all"; }>>; limit: z.ZodDefault<z.ZodNumber>; language: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; sessionHistory: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>; }, z.core.$strip>; export type SearchInput = z.infer<typeof SearchInput>; export declare const KnowledgeInput: z.ZodObject<{ operation: z.ZodDefault<z.ZodEnum<{ get: "get"; list: "list"; insights: "insights"; confirm_usage: "confirm_usage"; }>>; id: z.ZodOptional<z.ZodString>; kind: z.ZodOptional<z.ZodEnum<{ pattern: "pattern"; rule: "rule"; fact: "fact"; all: "all"; }>>; language: z.ZodOptional<z.ZodString>; category: z.ZodOptional<z.ZodString>; knowledgeType: z.ZodOptional<z.ZodString>; status: z.ZodOptional<z.ZodString>; complexity: z.ZodOptional<z.ZodString>; limit: z.ZodDefault<z.ZodNumber>; usageType: z.ZodOptional<z.ZodEnum<{ adoption: "adoption"; application: "application"; }>>; feedback: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type KnowledgeInput = z.infer<typeof KnowledgeInput>; export declare const StructureInput: z.ZodObject<{ operation: z.ZodDefault<z.ZodEnum<{ metadata: "metadata"; files: "files"; targets: "targets"; }>>; targetName: z.ZodOptional<z.ZodString>; includeSummary: z.ZodDefault<z.ZodBoolean>; includeContent: z.ZodDefault<z.ZodBoolean>; contentMaxLines: z.ZodDefault<z.ZodNumber>; maxFiles: z.ZodDefault<z.ZodNumber>; }, z.core.$strip>; export type StructureInput = z.infer<typeof StructureInput>; export declare const GraphInput: z.ZodObject<{ operation: z.ZodEnum<{ path: "path"; stats: "stats"; query: "query"; impact: "impact"; }>; nodeId: z.ZodOptional<z.ZodString>; nodeType: z.ZodDefault<z.ZodString>; fromId: z.ZodOptional<z.ZodString>; toId: z.ZodOptional<z.ZodString>; direction: z.ZodDefault<z.ZodEnum<{ out: "out"; in: "in"; both: "both"; }>>; maxDepth: z.ZodDefault<z.ZodNumber>; relation: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type GraphInput = z.infer<typeof GraphInput>; export declare const CallContextInput: z.ZodObject<{ methodName: z.ZodString; direction: z.ZodDefault<z.ZodEnum<{ both: "both"; impact: "impact"; callers: "callers"; callees: "callees"; }>>; maxDepth: z.ZodDefault<z.ZodNumber>; }, z.core.$strip>; export type CallContextInput = z.infer<typeof CallContextInput>; export declare const GuardInput: z.ZodObject<{ operation: z.ZodOptional<z.ZodEnum<{ check: "check"; review: "review"; reverse_audit: "reverse_audit"; coverage_matrix: "coverage_matrix"; compliance_report: "compliance_report"; }>>; files: z.ZodOptional<z.ZodArray<z.ZodString>>; code: z.ZodOptional<z.ZodString>; language: z.ZodOptional<z.ZodString>; filePath: z.ZodOptional<z.ZodString>; maxFiles: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>; export type GuardInput = z.infer<typeof GuardInput>; /** * 单条知识条目字段定义(items 数组内部元素的严格 Schema) * 用于文档/类型推导,实际 items 使用 z.record() 宽容接收后在 handler 层校验。 */ export declare const SubmitKnowledgeItemSchema: z.ZodObject<{ title: z.ZodString; language: z.ZodString; content: z.ZodObject<{ pattern: z.ZodOptional<z.ZodString>; markdown: z.ZodOptional<z.ZodString>; rationale: z.ZodString; steps: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>; codeChanges: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>; verification: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, z.core.$strip>; kind: z.ZodEnum<{ pattern: "pattern"; rule: "rule"; fact: "fact"; }>; doClause: z.ZodString; dontClause: z.ZodString; whenClause: z.ZodString; coreCode: z.ZodString; category: z.ZodString; trigger: z.ZodString; description: z.ZodString; headers: z.ZodArray<z.ZodString>; usageGuide: z.ZodString; knowledgeType: z.ZodString; reasoning: z.ZodObject<{ whyStandard: z.ZodString; sources: z.ZodArray<z.ZodString>; confidence: z.ZodNumber; qualitySignals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; alternatives: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>; topicHint: z.ZodOptional<z.ZodString>; complexity: z.ZodOptional<z.ZodEnum<{ intermediate: "intermediate"; advanced: "advanced"; beginner: "beginner"; }>>; scope: z.ZodOptional<z.ZodEnum<{ universal: "universal"; "project-specific": "project-specific"; "target-specific": "target-specific"; }>>; difficulty: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString>>; constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; relations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; headerPaths: z.ZodOptional<z.ZodArray<z.ZodString>>; moduleName: z.ZodOptional<z.ZodString>; includeHeaders: z.ZodOptional<z.ZodBoolean>; source: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export declare const SubmitKnowledgeInput: z.ZodObject<{ items: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>; target_name: z.ZodOptional<z.ZodString>; source: z.ZodOptional<z.ZodString>; skipConsolidation: z.ZodDefault<z.ZodBoolean>; skipDuplicateCheck: z.ZodDefault<z.ZodBoolean>; client_id: z.ZodOptional<z.ZodString>; dimensionId: z.ZodOptional<z.ZodString>; supersedes: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type SubmitKnowledgeInput = z.infer<typeof SubmitKnowledgeInput>; export declare const SkillInput: z.ZodObject<{ operation: z.ZodEnum<{ delete: "delete"; create: "create"; update: "update"; load: "load"; list: "list"; suggest: "suggest"; }>; name: z.ZodOptional<z.ZodString>; skillName: z.ZodOptional<z.ZodString>; section: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; content: z.ZodOptional<z.ZodString>; overwrite: z.ZodDefault<z.ZodBoolean>; createdBy: z.ZodDefault<z.ZodEnum<{ manual: "manual"; "external-ai": "external-ai"; "system-ai": "system-ai"; "user-ai": "user-ai"; }>>; }, z.core.$strip>; export type SkillInput = z.infer<typeof SkillInput>; export declare const BootstrapInput: z.ZodObject<{}, z.core.$strip>; export type BootstrapInput = z.infer<typeof BootstrapInput>; export declare const RescanInput: z.ZodObject<{ dimensions: z.ZodOptional<z.ZodArray<z.ZodString>>; reason: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type RescanInput = z.infer<typeof RescanInput>; export declare const DimensionCompleteInput: z.ZodObject<{ sessionId: z.ZodOptional<z.ZodString>; dimensionId: z.ZodString; submittedRecipeIds: z.ZodOptional<z.ZodArray<z.ZodString>>; analysisText: z.ZodString; referencedFiles: z.ZodOptional<z.ZodArray<z.ZodString>>; keyFindings: z.ZodOptional<z.ZodArray<z.ZodString>>; candidateCount: z.ZodOptional<z.ZodNumber>; crossDimensionHints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; }, z.core.$strip>; export type DimensionCompleteInput = z.infer<typeof DimensionCompleteInput>; export declare const WikiInput: z.ZodObject<{ operation: z.ZodEnum<{ plan: "plan"; finalize: "finalize"; }>; language: z.ZodOptional<z.ZodEnum<{ en: "en"; zh: "zh"; }>>; sessionId: z.ZodOptional<z.ZodString>; articlesWritten: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>; export type WikiInput = z.infer<typeof WikiInput>; export declare const CapabilitiesInput: z.ZodObject<{}, z.core.$strip>; export type CapabilitiesInput = z.infer<typeof CapabilitiesInput>; export declare const TaskInput: z.ZodObject<{ operation: z.ZodEnum<{ create: "create"; close: "close"; prime: "prime"; fail: "fail"; record_decision: "record_decision"; }>; title: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; id: z.ZodOptional<z.ZodString>; taskId: z.ZodOptional<z.ZodString>; reason: z.ZodOptional<z.ZodString>; rationale: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString>>; userQuery: z.ZodOptional<z.ZodString>; activeFile: z.ZodOptional<z.ZodString>; language: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type TaskInput = z.infer<typeof TaskInput>; export declare const EnrichCandidatesInput: z.ZodObject<{ candidateIds: z.ZodArray<z.ZodString>; }, z.core.$strip>; export type EnrichCandidatesInput = z.infer<typeof EnrichCandidatesInput>; export declare const KnowledgeLifecycleInput: z.ZodObject<{ id: z.ZodString; action: z.ZodEnum<{ approve: "approve"; publish: "publish"; submit: "submit"; reject: "reject"; deprecate: "deprecate"; reactivate: "reactivate"; to_draft: "to_draft"; fast_track: "fast_track"; }>; reason: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type KnowledgeLifecycleInput = z.infer<typeof KnowledgeLifecycleInput>; export declare const PanoramaInput: z.ZodObject<{ operation: z.ZodDefault<z.ZodEnum<{ overview: "overview"; gaps: "gaps"; module: "module"; health: "health"; enhancement_suggestions: "enhancement_suggestions"; governance_cycle: "governance_cycle"; decay_report: "decay_report"; staging_check: "staging_check"; }>>; module: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type PanoramaInput = z.infer<typeof PanoramaInput>; export declare const EvolveInput: z.ZodObject<{ decisions: z.ZodArray<z.ZodObject<{ recipeId: z.ZodString; action: z.ZodEnum<{ propose_evolution: "propose_evolution"; confirm_deprecation: "confirm_deprecation"; skip: "skip"; }>; evidence: z.ZodOptional<z.ZodObject<{ codeSnippet: z.ZodString; filePath: z.ZodString; type: z.ZodEnum<{ enhance: "enhance"; correction: "correction"; }>; suggestedChanges: z.ZodString; }, z.core.$strip>>; reason: z.ZodOptional<z.ZodString>; skipReason: z.ZodOptional<z.ZodEnum<{ still_valid: "still_valid"; insufficient_info: "insufficient_info"; }>>; }, z.core.$strip>>; }, z.core.$strip>; export type EvolveInput = z.infer<typeof EvolveInput>; export declare const TOOL_SCHEMAS: Record<string, z.ZodType>;