il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
136 lines (135 loc) • 5.14 kB
TypeScript
/**
* Find Design Patterns Tool Implementation
* Detects common design patterns in IL2CPP code with confidence scoring
*/
import { z } from 'zod';
import { BaseAnalysisToolHandler, ToolExecutionContext } from '../base-tool-handler';
import { ValidationResult } from '../../utils/parameter-validator';
import { MCPResponse } from '../../utils/mcp-response-formatter';
/**
* Find design patterns parameters interface
*/
interface FindDesignPatternsParams {
pattern_types: string[];
confidence_threshold?: number;
include_partial_matches?: boolean;
namespace_scope?: string;
exclude_unity_patterns?: boolean;
max_results_per_pattern?: number;
}
/**
* Design pattern match interface
*/
interface DesignPatternMatch {
className: string;
fullName: string;
namespace: string;
confidence: number;
evidence: string[];
implementation: 'full' | 'partial' | 'variant';
isPartialMatch: boolean;
suggestions: string[];
isUnitySpecific: boolean;
}
/**
* Design patterns result interface
*/
interface DesignPatternsResult {
detectedPatterns: Record<string, DesignPatternMatch[]>;
summary: {
totalPatternsFound: number;
patternTypeCount: number;
averageConfidence: number;
architecturalInsights: string[];
};
metadata: {
searchedPatterns: string[];
confidenceThreshold: number;
includePartialMatches: boolean;
namespaceScope?: string;
excludeUnityPatterns: boolean;
maxResultsPerPattern: number;
timestamp: string;
};
}
/**
* Find Design Patterns Tool Handler
* Detects common design patterns in IL2CPP code with confidence scoring
*/
export declare class FindDesignPatternsToolHandler extends BaseAnalysisToolHandler<FindDesignPatternsParams, DesignPatternsResult> {
constructor(context: ToolExecutionContext);
/**
* Validate design patterns parameters
*/
protected validateParameters(params: FindDesignPatternsParams): Promise<ValidationResult>;
/**
* Execute design pattern detection
*/
protected executeCore(params: FindDesignPatternsParams): Promise<DesignPatternsResult>;
/**
* Detect a specific design pattern
*/
private detectPattern;
/**
* Detect Singleton pattern
*/
private detectSingleton;
/**
* Detect Observer pattern
*/
private detectObserver;
/**
* Detect Factory pattern
*/
private detectFactory;
/**
* Detect Strategy pattern
*/
private detectStrategy;
/**
* Detect Command pattern
*/
private detectCommand;
/**
* Calculate pattern summary statistics
*/
private calculatePatternSummary;
/**
* Generate architectural insights based on detected patterns
*/
private generateArchitecturalInsights;
/**
* Format pattern detection results
*/
protected formatResponse(result: DesignPatternsResult, warnings?: string[]): MCPResponse;
}
/**
* Zod schema for find design patterns tool parameters
*/
export declare const findDesignPatternsSchema: z.ZodObject<{
pattern_types: z.ZodArray<z.ZodEnum<["singleton", "observer", "factory", "strategy", "command", "state", "decorator", "adapter", "facade", "proxy", "builder", "template_method", "chain_of_responsibility", "mediator", "memento", "visitor", "flyweight", "composite", "bridge", "abstract_factory", "prototype", "iterator"]>, "many">;
confidence_threshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
include_partial_matches: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
namespace_scope: z.ZodOptional<z.ZodString>;
exclude_unity_patterns: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
max_results_per_pattern: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
confidence_threshold: number;
max_results_per_pattern: number;
include_partial_matches: boolean;
exclude_unity_patterns: boolean;
pattern_types: ("singleton" | "observer" | "factory" | "strategy" | "command" | "state" | "decorator" | "adapter" | "facade" | "proxy" | "builder" | "template_method" | "chain_of_responsibility" | "mediator" | "memento" | "visitor" | "flyweight" | "composite" | "bridge" | "abstract_factory" | "prototype" | "iterator")[];
namespace_scope?: string | undefined;
}, {
pattern_types: ("singleton" | "observer" | "factory" | "strategy" | "command" | "state" | "decorator" | "adapter" | "facade" | "proxy" | "builder" | "template_method" | "chain_of_responsibility" | "mediator" | "memento" | "visitor" | "flyweight" | "composite" | "bridge" | "abstract_factory" | "prototype" | "iterator")[];
confidence_threshold?: number | undefined;
max_results_per_pattern?: number | undefined;
include_partial_matches?: boolean | undefined;
exclude_unity_patterns?: boolean | undefined;
namespace_scope?: string | undefined;
}>;
/**
* Factory function to create and register the find design patterns tool
*/
export declare function createFindDesignPatternsTool(server: any, context: ToolExecutionContext): FindDesignPatternsToolHandler;
export {};