UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

444 lines 15.7 kB
/** * TypeScript interfaces for Knowledge Generation framework * Implements advanced prompting techniques for domain-specific architectural knowledge */ import { z } from 'zod'; /** * Base prompt object for knowledge generation */ export interface PromptObject { /** The main prompt text */ prompt: string; /** Instructions for using the prompt */ instructions: string; /** Additional context data */ context: any; } export type ArchitecturalDomain = 'web-applications' | 'mobile-applications' | 'microservices' | 'database-design' | 'cloud-infrastructure' | 'devops-cicd' | 'security-patterns' | 'performance-optimization' | 'api-design' | 'data-architecture'; export type KnowledgeCategory = 'best-practices' | 'design-patterns' | 'anti-patterns' | 'technology-specific' | 'performance-considerations' | 'security-guidelines' | 'scalability-patterns' | 'testing-strategies'; export type KnowledgeDepth = 'basic' | 'intermediate' | 'advanced'; export type CacheStrategy = 'aggressive' | 'moderate' | 'minimal'; /** * Represents a single piece of architectural knowledge */ export interface KnowledgeItem { /** Category of knowledge */ category: KnowledgeCategory; /** Title of the knowledge item */ title: string; /** Detailed content of the knowledge */ content: string; /** Relevance score (0-1 scale) */ relevance: number; /** Evidence supporting this knowledge */ evidence: string[]; /** Tags for categorization */ tags: string[]; /** Optional sources of the knowledge */ sources?: string[]; } export declare const KnowledgeItemSchema: z.ZodObject<{ category: z.ZodEnum<{ "best-practices": "best-practices"; "design-patterns": "design-patterns"; "anti-patterns": "anti-patterns"; "technology-specific": "technology-specific"; "performance-considerations": "performance-considerations"; "security-guidelines": "security-guidelines"; "scalability-patterns": "scalability-patterns"; "testing-strategies": "testing-strategies"; }>; title: z.ZodString; content: z.ZodString; relevance: z.ZodNumber; evidence: z.ZodArray<z.ZodString>; tags: z.ZodArray<z.ZodString>; sources: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>; /** * Metadata about knowledge generation process */ export interface KnowledgeMetadata { /** Timestamp when knowledge was generated */ generatedAt: string; /** Time taken to generate knowledge (milliseconds) */ generationTime: number; /** Cache key for storing/retrieving knowledge */ cacheKey: string; /** Architectural domains covered */ domains: ArchitecturalDomain[]; /** Confidence level of generated knowledge (0-1 scale) */ confidence: number; /** Version of the knowledge generation system */ version: string; } /** * Knowledge collection for a specific architectural domain */ export interface DomainKnowledge { /** The architectural domain this knowledge covers */ domain: ArchitecturalDomain; /** Collection of knowledge items */ knowledge: KnowledgeItem[]; /** Overall confidence in the knowledge (0-1 scale) */ confidence: number; /** Timestamp when knowledge was collected */ timestamp: string; /** Sources used to generate the knowledge */ sources: string[]; /** Metadata about the generation process */ metadata: KnowledgeMetadata; } export declare const DomainKnowledgeSchema: z.ZodObject<{ domain: z.ZodEnum<{ "web-applications": "web-applications"; "mobile-applications": "mobile-applications"; microservices: "microservices"; "database-design": "database-design"; "cloud-infrastructure": "cloud-infrastructure"; "devops-cicd": "devops-cicd"; "security-patterns": "security-patterns"; "performance-optimization": "performance-optimization"; "api-design": "api-design"; "data-architecture": "data-architecture"; }>; knowledge: z.ZodArray<z.ZodObject<{ category: z.ZodEnum<{ "best-practices": "best-practices"; "design-patterns": "design-patterns"; "anti-patterns": "anti-patterns"; "technology-specific": "technology-specific"; "performance-considerations": "performance-considerations"; "security-guidelines": "security-guidelines"; "scalability-patterns": "scalability-patterns"; "testing-strategies": "testing-strategies"; }>; title: z.ZodString; content: z.ZodString; relevance: z.ZodNumber; evidence: z.ZodArray<z.ZodString>; tags: z.ZodArray<z.ZodString>; sources: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>>; confidence: z.ZodNumber; timestamp: z.ZodString; sources: z.ZodArray<z.ZodString>; metadata: z.ZodObject<{ generatedAt: z.ZodString; generationTime: z.ZodNumber; cacheKey: z.ZodString; domains: z.ZodArray<z.ZodString>; confidence: z.ZodNumber; version: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; /** * Configuration for knowledge generation process */ export interface KnowledgeGenerationConfig { /** Architectural domains to generate knowledge for */ domains?: ArchitecturalDomain[]; /** Depth of knowledge to generate */ depth?: KnowledgeDepth; /** Whether to enable caching of generated knowledge */ cacheEnabled?: boolean; /** Cache time-to-live in seconds */ cacheTTL?: number; /** Whether to perform security validation on generated knowledge */ securityValidation?: boolean; /** Custom templates for domain-specific knowledge */ customTemplates?: DomainTemplate[]; /** Maximum number of knowledge items to generate */ maxKnowledgeItems?: number; /** Maximum tokens to use for generation */ maxTokens?: number; /** Minimum relevance threshold (0-1 scale) */ relevanceThreshold?: number; /** Whether to generate knowledge in parallel */ parallelGeneration?: boolean; } export declare const KnowledgeGenerationConfigSchema: z.ZodObject<{ domains: z.ZodOptional<z.ZodArray<z.ZodString>>; depth: z.ZodOptional<z.ZodEnum<{ basic: "basic"; intermediate: "intermediate"; advanced: "advanced"; }>>; cacheEnabled: z.ZodOptional<z.ZodBoolean>; cacheTTL: z.ZodOptional<z.ZodNumber>; securityValidation: z.ZodOptional<z.ZodBoolean>; customTemplates: z.ZodOptional<z.ZodArray<z.ZodAny>>; maxKnowledgeItems: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; relevanceThreshold: z.ZodOptional<z.ZodNumber>; parallelGeneration: z.ZodOptional<z.ZodBoolean>; }, z.core.$strip>; export interface ToolKnowledgeConfig { enableKnowledgeGeneration: boolean; domains: ArchitecturalDomain[]; knowledgeDepth: KnowledgeDepth; cacheStrategy: CacheStrategy; autoDetectDomains?: boolean; customKnowledgeTemplates?: string[]; } /** * Context about the architectural environment for knowledge generation */ export interface ArchitecturalContext { /** Path to the project being analyzed */ projectPath?: string; /** Technologies used in the project */ technologies?: string[]; /** Architectural patterns detected or used */ patterns?: string[]; /** Existing ADRs in the project */ existingAdrs?: string[]; /** Type of project (web app, microservice, etc.) */ projectType?: string; /** Size of the development team */ teamSize?: number; /** Known constraints or limitations */ constraints?: string[]; /** Project goals and objectives */ goals?: string[]; } /** * Detailed context about a project for knowledge generation */ export interface ProjectContext { /** Absolute path to the project */ path: string; /** Project name */ name?: string; /** Project description */ description?: string; /** Technologies detected in the project */ technologies: string[]; /** File types found in the project */ fileTypes: string[]; /** Directory structure of the project */ directoryStructure: string[]; /** Package management files (package.json, requirements.txt, etc.) */ packageFiles: string[]; /** Configuration files found */ configFiles: string[]; } export interface DomainTemplate { domain: ArchitecturalDomain; categories: TemplateCategoryDefinition[]; metadata: TemplateMetadata; } export interface TemplateCategoryDefinition { category: KnowledgeCategory; items: string[]; priority: number; applicability: string[]; } export interface TemplateMetadata { version: string; author: string; lastUpdated: string; description: string; tags: string[]; } /** * Result of knowledge generation process */ export interface KnowledgeGenerationResult { /** Generated prompt with knowledge integration */ knowledgePrompt: PromptObject; /** Enhanced version of the prompt (if applicable) */ enhancedPrompt?: PromptObject; /** Generated domain-specific knowledge */ domainKnowledge: DomainKnowledge[]; /** Cache key for storing/retrieving this result */ cacheKey: string; /** Metadata about the generation process */ metadata: GenerationMetadata; /** Security validation results */ securityCheck?: KnowledgeSecurityCheck; } export interface GenerationMetadata { totalGenerationTime: number; domainsProcessed: ArchitecturalDomain[]; knowledgeItemsGenerated: number; cacheHits: number; cacheMisses: number; averageConfidence: number; qualityScore: number; } export interface KnowledgeSecurityCheck { contentSafety: boolean; sourceReliability: number; relevanceScore: number; qualityScore: number; warnings: string[]; recommendations: string[]; validationTime: number; } export interface KnowledgeValidationResult { isValid: boolean; confidence: number; issues: ValidationIssue[]; suggestions: string[]; qualityMetrics: QualityMetrics; } export interface ValidationIssue { type: 'error' | 'warning' | 'info'; category: string; message: string; severity: number; suggestion?: string; } export interface QualityMetrics { completeness: number; accuracy: number; relevance: number; clarity: number; actionability: number; } export interface KnowledgeCacheEntry { key: string; domainKnowledge: DomainKnowledge[]; generatedAt: string; expiresAt: string; accessCount: number; lastAccessed: string; size: number; metadata: CacheEntryMetadata; } export interface CacheEntryMetadata { domains: ArchitecturalDomain[]; config: KnowledgeGenerationConfig; contextHash: string; version: string; compressionUsed: boolean; } export interface KnowledgePerformanceMetrics { generationTime: number; cacheHitRate: number; averageKnowledgeQuality: number; memoryUsage: number; concurrentGenerations: number; errorRate: number; } export interface KnowledgeIntegrationOptions { combineWithOriginalPrompt: boolean; knowledgeWeight: number; formatAsContext: boolean; includeMetadata: boolean; customIntegrationTemplate?: string; } export interface DomainDetectionResult { detectedDomains: ArchitecturalDomain[]; confidence: number; evidence: DomainEvidence[]; recommendations: string[]; fallbackDomains: ArchitecturalDomain[]; } export interface DomainEvidence { domain: ArchitecturalDomain; evidence: string[]; confidence: number; sources: string[]; } export interface KnowledgeGenerationError { code: string; message: string; domain?: ArchitecturalDomain; context?: any; timestamp: string; recoverable: boolean; } export interface KnowledgeGenerationStatus { status: 'pending' | 'generating' | 'completed' | 'failed' | 'cached'; progress: number; currentDomain?: ArchitecturalDomain; estimatedTimeRemaining?: number; errors: KnowledgeGenerationError[]; } export declare const ArchitecturalContextSchema: z.ZodObject<{ projectPath: z.ZodOptional<z.ZodString>; technologies: z.ZodOptional<z.ZodArray<z.ZodString>>; patterns: z.ZodOptional<z.ZodArray<z.ZodString>>; existingAdrs: z.ZodOptional<z.ZodArray<z.ZodString>>; projectType: z.ZodOptional<z.ZodString>; teamSize: z.ZodOptional<z.ZodNumber>; constraints: z.ZodOptional<z.ZodArray<z.ZodString>>; goals: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>; export declare const KnowledgeGenerationResultSchema: z.ZodObject<{ knowledgePrompt: z.ZodObject<{ prompt: z.ZodString; instructions: z.ZodString; context: z.ZodAny; }, z.core.$strip>; enhancedPrompt: z.ZodOptional<z.ZodObject<{ prompt: z.ZodString; instructions: z.ZodString; context: z.ZodAny; }, z.core.$strip>>; domainKnowledge: z.ZodArray<z.ZodObject<{ domain: z.ZodEnum<{ "web-applications": "web-applications"; "mobile-applications": "mobile-applications"; microservices: "microservices"; "database-design": "database-design"; "cloud-infrastructure": "cloud-infrastructure"; "devops-cicd": "devops-cicd"; "security-patterns": "security-patterns"; "performance-optimization": "performance-optimization"; "api-design": "api-design"; "data-architecture": "data-architecture"; }>; knowledge: z.ZodArray<z.ZodObject<{ category: z.ZodEnum<{ "best-practices": "best-practices"; "design-patterns": "design-patterns"; "anti-patterns": "anti-patterns"; "technology-specific": "technology-specific"; "performance-considerations": "performance-considerations"; "security-guidelines": "security-guidelines"; "scalability-patterns": "scalability-patterns"; "testing-strategies": "testing-strategies"; }>; title: z.ZodString; content: z.ZodString; relevance: z.ZodNumber; evidence: z.ZodArray<z.ZodString>; tags: z.ZodArray<z.ZodString>; sources: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>>; confidence: z.ZodNumber; timestamp: z.ZodString; sources: z.ZodArray<z.ZodString>; metadata: z.ZodObject<{ generatedAt: z.ZodString; generationTime: z.ZodNumber; cacheKey: z.ZodString; domains: z.ZodArray<z.ZodString>; confidence: z.ZodNumber; version: z.ZodString; }, z.core.$strip>; }, z.core.$strip>>; cacheKey: z.ZodString; metadata: z.ZodObject<{ totalGenerationTime: z.ZodNumber; domainsProcessed: z.ZodArray<z.ZodString>; knowledgeItemsGenerated: z.ZodNumber; cacheHits: z.ZodNumber; cacheMisses: z.ZodNumber; averageConfidence: z.ZodNumber; qualityScore: z.ZodNumber; }, z.core.$strip>; securityCheck: z.ZodOptional<z.ZodObject<{ contentSafety: z.ZodBoolean; sourceReliability: z.ZodNumber; relevanceScore: z.ZodNumber; qualityScore: z.ZodNumber; warnings: z.ZodArray<z.ZodString>; recommendations: z.ZodArray<z.ZodString>; validationTime: z.ZodNumber; }, z.core.$strip>>; }, z.core.$strip>; //# sourceMappingURL=knowledge-generation.d.ts.map