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,362 lines 69.2 kB
/** * @fileoverview Schema for focused unused code review. * * This module defines a simplified schema focused solely on detecting unused code. */ import { z } from 'zod'; import { StructuredOutputParser } from '@langchain/core/output_parsers'; /** * Confidence level for an unused code finding */ export type ConfidenceLevel = 'high' | 'medium' | 'low'; /** * Types of unused code elements */ export type UnusedElementType = 'file' | 'function' | 'class' | 'interface' | 'type' | 'variable' | 'import' | 'dead-branch' | 'parameter' | 'property' | 'enum' | 'export' | 'hook' | 'component'; /** * Schema for a single unused code element */ export declare const UnusedElementSchema: z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>; /** * Schema for the focused unused code review result */ export declare const FocusedUnusedCodeReviewSchema: z.ZodObject<{ /** * Unused files */ unusedFiles: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused functions */ unusedFunctions: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused classes */ unusedClasses: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused types and interfaces */ unusedTypesAndInterfaces: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Dead code branches */ deadCodeBranches: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused variables and imports */ unusedVariablesAndImports: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Summary statistics */ summary: z.ZodObject<{ totalUnusedElements: z.ZodNumber; highConfidenceCount: z.ZodNumber; filesWithUnusedCode: z.ZodNumber; potentialCodeReduction: z.ZodString; }, "strip", z.ZodTypeAny, { totalUnusedElements: number; highConfidenceCount: number; filesWithUnusedCode: number; potentialCodeReduction: string; }, { totalUnusedElements: number; highConfidenceCount: number; filesWithUnusedCode: number; potentialCodeReduction: string; }>; }, "strip", z.ZodTypeAny, { summary: { totalUnusedElements: number; highConfidenceCount: number; filesWithUnusedCode: number; potentialCodeReduction: string; }; unusedFiles: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedFunctions: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedClasses: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedTypesAndInterfaces: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; deadCodeBranches: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedVariablesAndImports: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; }, { summary: { totalUnusedElements: number; highConfidenceCount: number; filesWithUnusedCode: number; potentialCodeReduction: string; }; unusedFiles: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedFunctions: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedClasses: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedTypesAndInterfaces: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; deadCodeBranches: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; unusedVariablesAndImports: { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }[]; }>; /** * Type for an unused element */ export type UnusedElement = z.infer<typeof UnusedElementSchema>; /** * Type for the focused unused code review result */ export type FocusedUnusedCodeReview = z.infer<typeof FocusedUnusedCodeReviewSchema>; /** * LangChain parser for focused unused code review */ export declare const focusedUnusedCodeReviewParser: StructuredOutputParser<z.ZodObject<{ /** * Unused files */ unusedFiles: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused functions */ unusedFunctions: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused classes */ unusedClasses: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoolean>; /** * Elements that depend on this element (if any) */ dependents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; /** * Potential risks of removing this element */ removalRisks: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents: boolean; dependents?: string[] | undefined; removalRisks?: string | undefined; }, { name: string; location: { startLine: number; endLine?: number | undefined; }; filePath: string; confidence: "high" | "medium" | "low"; codeSnippet: string; elementType: "function" | "type" | "property" | "file" | "class" | "interface" | "variable" | "import" | "dead-branch" | "parameter" | "enum" | "export" | "hook" | "component"; confidenceReason: string; hasDependents?: boolean | undefined; dependents?: string[] | undefined; removalRisks?: string | undefined; }>, "many">; /** * Unused types and interfaces */ unusedTypesAndInterfaces: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Type of the unused element */ elementType: z.ZodEnum<["file", "function", "class", "interface", "type", "variable", "import", "dead-branch", "parameter", "property", "enum", "export", "hook", "component"]>; /** * Name of the element */ name: z.ZodString; /** * File where the element is located */ filePath: z.ZodString; /** * Line numbers where the element is defined */ location: z.ZodObject<{ startLine: z.ZodNumber; endLine: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { startLine: number; endLine?: number | undefined; }, { startLine: number; endLine?: number | undefined; }>; /** * Code snippet showing the unused element */ codeSnippet: z.ZodString; /** * Confidence level that this element is truly unused */ confidence: z.ZodEnum<["high", "medium", "low"]>; /** * Explanation for the confidence assessment */ confidenceReason: z.ZodString; /** * Whether other code depends on this element */ hasDependents: z.ZodDefault<z.ZodBoole