il2cpp-dump-analyzer-mcp
Version:
Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games
165 lines (164 loc) • 5.27 kB
TypeScript
/**
* @fileoverview Analyze Generic Types MCP Tool
*
* Provides comprehensive analysis of IL2CPP generic type relationships including:
* - Generic type definition analysis and constraint mapping
* - Type parameter relationship analysis
* - Generic instantiation tracking and usage patterns
* - Constraint complexity analysis and validation
*
* This tool implements the generic type analysis functionality from TypeAnalyzer
* as an MCP tool following established patterns and TFD methodology.
*/
import { z } from 'zod';
import { BaseAnalysisToolHandler, ToolExecutionContext } from '../base-tool-handler';
import { ValidationResult } from '../../utils/parameter-validator';
import { MCPResponse } from '../../utils/mcp-response-formatter';
/**
* Generic type analysis parameters interface
*/
interface AnalyzeGenericTypesParams {
target_type?: string;
include_constraints?: boolean;
include_instantiations?: boolean;
complexity_threshold?: number;
}
/**
* Generic type definition representation
*/
interface GenericTypeDefinition {
typeName: string;
namespace: string;
typeDefIndex: number;
genericParameters: string[];
constraints: string[];
constraintCount: number;
complexityScore: number;
isInterface: boolean;
}
/**
* Constraint relationship representation
*/
interface ConstraintRelationship {
sourceType: string;
targetParameter: string;
constraintType: string;
constraintTarget: string;
isTypeConstraint: boolean;
isInterfaceConstraint: boolean;
isClassConstraint: boolean;
}
/**
* Generic instantiation representation
*/
interface GenericInstantiation {
baseType: string;
typeArguments: string[];
instantiationContext: string;
usageLocation: string;
complexityScore: number;
}
/**
* Generic type complexity metrics
*/
interface GenericComplexityMetrics {
totalGenericTypes: number;
averageTypeParameters: number;
maxTypeParameters: number;
constraintComplexity: number;
nestingDepth: number;
}
/**
* Generic type analysis result
*/
interface GenericTypeAnalysisResult {
genericTypeDefinitions: GenericTypeDefinition[];
constraintRelationships: ConstraintRelationship[];
genericInstantiations: GenericInstantiation[];
complexityMetrics: GenericComplexityMetrics;
analysisMetadata: {
targetType?: string;
includeConstraints: boolean;
includeInstantiations: boolean;
complexityThreshold: number;
timestamp: string;
totalTypesAnalyzed: number;
};
}
/**
* Analyze Generic Types MCP Tool Implementation
*
* Analyzes IL2CPP generic type relationships and constraints using vector store search.
* Provides comprehensive generic type analysis with constraint mapping and instantiation tracking.
*/
export declare class AnalyzeGenericTypesTool extends BaseAnalysisToolHandler<AnalyzeGenericTypesParams, GenericTypeAnalysisResult> {
constructor(context: ToolExecutionContext);
/**
* Validate input parameters using Zod schema
*/
protected validateParameters(params: any): Promise<ValidationResult>;
/**
* Execute generic type analysis
*/
protected executeCore(params: AnalyzeGenericTypesParams): Promise<GenericTypeAnalysisResult>;
/**
* Analyze generic type definitions
*/
private analyzeGenericTypeDefinitions;
/**
* Analyze constraint relationships between generic types
*/
private analyzeConstraintRelationships;
/**
* Analyze generic instantiations in the codebase
*/
private analyzeGenericInstantiations;
/**
* Extract generic instantiation from document metadata
*/
private extractGenericInstantiation;
/**
* Calculate complexity metrics for generic types
*/
private calculateComplexityMetrics;
/**
* Determine constraint type from constraint target
*/
private getConstraintType;
/**
* Check if constraint is a type constraint
*/
private isTypeConstraint;
/**
* Check if constraint is an interface constraint
*/
private isInterfaceConstraint;
/**
* Format generic type analysis results
*/
protected formatResponse(result: GenericTypeAnalysisResult, warnings?: string[]): MCPResponse;
}
/**
* Zod schema for analyze generic types tool parameters
*/
export declare const analyzeGenericTypesSchema: z.ZodObject<{
target_type: z.ZodOptional<z.ZodString>;
include_constraints: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
include_instantiations: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
complexity_threshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
include_constraints: boolean;
include_instantiations: boolean;
complexity_threshold: number;
target_type?: string | undefined;
}, {
target_type?: string | undefined;
include_constraints?: boolean | undefined;
include_instantiations?: boolean | undefined;
complexity_threshold?: number | undefined;
}>;
/**
* Factory function to create and register the analyze generic types tool
*/
export declare function createAnalyzeGenericTypesTool(server: any, context: ToolExecutionContext): AnalyzeGenericTypesTool;
export {};