UNPKG

@bobmatnyc/ai-code-review

Version:

A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter

1,266 lines 55.6 kB
/** * @fileoverview Improved schema for unused code review structured output. * * This module defines an enhanced schema for structured output from the unused code review, * using Zod for schema validation and LangChain for parsing. */ import { z } from 'zod'; import { StructuredOutputParser } from '@langchain/core/output_parsers'; /** * Risk level for removing unused code */ export type RiskLevel = 'high' | 'medium' | 'low'; /** * Impact level for unused code issues */ export type ImpactLevel = 'high' | 'medium' | 'low'; /** * Categories of unused code */ export type UnusedCodeCategory = 'unusedFile' | 'unusedFunction' | 'unusedClass' | 'unusedModule' | 'deadCode' | 'unreachableCode' | 'unusedVariable' | 'unusedImport' | 'commentedCode' | 'redundantCode' | 'deprecatedFeature' | 'featureFlag' | 'unusedParameter' | 'unusedProperty' | 'unusedType' | 'other'; /** * Schema for an unused code issue with more detailed categorization */ export declare const ImprovedUnusedCodeIssueSchema: z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>; /** * Enhanced schema for the complete unused code review result */ export declare const ImprovedUnusedCodeReviewSchema: z.ZodObject<{ /** * Array of high impact unused code issues */ highImpactIssues: z.ZodArray<z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>, "many">; /** * Array of medium impact unused code issues */ mediumImpactIssues: z.ZodArray<z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>, "many">; /** * Array of low impact unused code issues */ lowImpactIssues: z.ZodArray<z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>, "many">; /** * Summary of the unused code review */ summary: z.ZodString; /** * General recommendations for preventing unused code */ recommendations: z.ZodArray<z.ZodString, "many">; /** * Project-wide patterns observed */ codebasePatterns: z.ZodOptional<z.ZodArray<z.ZodObject<{ pattern: z.ZodString; impact: z.ZodString; suggestion: z.ZodString; }, "strip", z.ZodTypeAny, { impact: string; pattern: string; suggestion: string; }, { impact: string; pattern: string; suggestion: string; }>, "many">>; /** * Static analysis tools that could help */ recommendedTools: z.ZodOptional<z.ZodArray<z.ZodObject<{ tool: z.ZodString; description: z.ZodString; configuration: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { description: string; tool: string; configuration?: string | undefined; }, { description: string; tool: string; configuration?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { summary: string; recommendations: string[]; highImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; mediumImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; lowImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; codebasePatterns?: { impact: string; pattern: string; suggestion: string; }[] | undefined; recommendedTools?: { description: string; tool: string; configuration?: string | undefined; }[] | undefined; }, { summary: string; recommendations: string[]; highImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; mediumImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; lowImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; codebasePatterns?: { impact: string; pattern: string; suggestion: string; }[] | undefined; recommendedTools?: { description: string; tool: string; configuration?: string | undefined; }[] | undefined; }>; /** * Type for an improved unused code issue */ export type ImprovedUnusedCodeIssue = z.infer<typeof ImprovedUnusedCodeIssueSchema>; /** * Type for the complete improved unused code review result */ export type ImprovedUnusedCodeReview = z.infer<typeof ImprovedUnusedCodeReviewSchema>; /** * LangChain parser for improved unused code review output */ export declare const improvedUnusedCodeReviewParser: StructuredOutputParser<z.ZodObject<{ /** * Array of high impact unused code issues */ highImpactIssues: z.ZodArray<z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>, "many">; /** * Array of medium impact unused code issues */ mediumImpactIssues: z.ZodArray<z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>, "many">; /** * Array of low impact unused code issues */ lowImpactIssues: z.ZodArray<z.ZodObject<{ /** * Title/name of the unused code issue */ title: z.ZodString; /** * Detailed description of the unused code issue */ description: z.ZodString; /** * Location information (file and line numbers) */ location: z.ZodObject<{ file: z.ZodOptional<z.ZodString>; lineStart: z.ZodOptional<z.ZodNumber>; lineEnd: z.ZodOptional<z.ZodNumber>; codeSnippet: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }, { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }>; /** * Assessment of confidence that this code is truly unused */ assessment: z.ZodObject<{ confidence: z.ZodEnum<["high", "medium", "low"]>; reasoning: z.ZodString; staticAnalysisHint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }, { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }>; /** * Suggested action (remove or keep with explanation) */ suggestedAction: z.ZodObject<{ action: z.ZodEnum<["remove", "refactor", "keep"]>; replacement: z.ZodOptional<z.ZodString>; explanation: z.ZodString; }, "strip", z.ZodTypeAny, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }, { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }>; /** * Risk level of removing this code */ riskLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Impact level of the issue */ impactLevel: z.ZodEnum<["high", "medium", "low"]>; /** * Category of unused code (more detailed than before) */ category: z.ZodEnum<["unusedFile", "unusedFunction", "unusedClass", "unusedModule", "deadCode", "unreachableCode", "unusedVariable", "unusedImport", "commentedCode", "redundantCode", "deprecatedFeature", "featureFlag", "unusedParameter", "unusedProperty", "unusedType", "other"]>; /** * Flag indicating if this is a complete element (file, function, class) that can be entirely removed */ isCompleteElement: z.ZodBoolean; /** * Potential dependencies or references that should be checked */ relatedChecks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }, { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }>, "many">; /** * Summary of the unused code review */ summary: z.ZodString; /** * General recommendations for preventing unused code */ recommendations: z.ZodArray<z.ZodString, "many">; /** * Project-wide patterns observed */ codebasePatterns: z.ZodOptional<z.ZodArray<z.ZodObject<{ pattern: z.ZodString; impact: z.ZodString; suggestion: z.ZodString; }, "strip", z.ZodTypeAny, { impact: string; pattern: string; suggestion: string; }, { impact: string; pattern: string; suggestion: string; }>, "many">>; /** * Static analysis tools that could help */ recommendedTools: z.ZodOptional<z.ZodArray<z.ZodObject<{ tool: z.ZodString; description: z.ZodString; configuration: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { description: string; tool: string; configuration?: string | undefined; }, { description: string; tool: string; configuration?: string | undefined; }>, "many">>; }, "strip", z.ZodTypeAny, { summary: string; recommendations: string[]; highImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; impactLevel: "high" | "medium" | "low"; category: "other" | "unusedFile" | "unusedFunction" | "unusedClass" | "unusedModule" | "deadCode" | "unreachableCode" | "unusedVariable" | "unusedImport" | "commentedCode" | "redundantCode" | "deprecatedFeature" | "featureFlag" | "unusedParameter" | "unusedProperty" | "unusedType"; isCompleteElement: boolean; relatedChecks?: string[] | undefined; }[]; mediumImpactIssues: { description: string; location: { file?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; codeSnippet?: string | undefined; }; title: string; assessment: { reasoning: string; confidence: "high" | "medium" | "low"; staticAnalysisHint?: string | undefined; }; suggestedAction: { explanation: string; action: "remove" | "refactor" | "keep"; replacement?: string | undefined; }; riskLevel: "high" | "medium" | "low"; imp