/** * `dead-code-scan` tool — find unused symbols using the codebase-index refs graph. * * How it works: * 1. Opens a pooled connection to the existing codebase-index SQLite store. * 2. Discovers entry-point symbols from package.json (bin, main, exports, types) * plus conventional entry files (src/index.ts, src/main.ts, index.ts). * 3. BFS-traverses the reference graph from those entry points to find every * symbol that is transitively reachable through imports, calls, type refs, * inheritance, and implementation edges. * 4. Everything NOT reached is a dead-code candidate. * * Known limitations (false positives possible): * - Dynamic imports / `require()` with computed paths are invisible. * - External consumers (npm installers, CI tools) can't be seen. * - Config-driven registration (plugin manifests, DI containers) won't appear. * - Type-only exports consumed only at the type level are still marked alive * because the refs graph tracks `type_ref` edges. */ import type { Tool } from '@wrongstack/core/types'; import type { SymbolKind, SymbolLang } from './schema.js'; import { type IndexStore } from './writer.js'; export interface DeadCodeScanInput { /** Project root (defaults to ctx.projectRoot). */ projectRoot?: string | undefined; /** * Override the index directory. Normally auto-resolved from projectRoot. */ indexDir?: string | undefined; /** * Additional entry-point file paths (absolute or relative to projectRoot) * to seed the reachability scan. These augment auto-discovered entry points. */ entryPoints?: string[] | undefined; } export interface DeadSymbol { name: string; kind: SymbolKind; lang: SymbolLang; file: string; line: number; /** Why this symbol is considered dead. */ reason: 'unreferenced' | 'unreferenced-export'; } export interface DeadFile { file: string; symbolCount: number; lang: string; } export interface DeadPackage { package: string; path: string; fileCount: number; } export interface DeadCodeScanOutput { /** Symbols found dead. Sorted: unreferenced-export first, then by file. */ deadSymbols: DeadSymbol[]; /** Files where every defined symbol is dead (likely orphaned modules). */ deadFiles: DeadFile[]; /** Packages in the workspace with zero used symbols. */ deadPackages: DeadPackage[]; /** Entry points used as traversal roots. */ entryPoints: string[]; stats: { totalSymbols: number; alive: number; dead: number; durationMs: number; }; } export declare const deadCodeScanTool: Tool; /** * Walk the workspace and discover entry-point files from package.json(s). */ export declare function discoverEntryPoints(projectRoot: string, userEntryPoints: string[] | undefined): string[]; export declare function runDeadCodeScan(projectRoot: string, opts?: { indexDir?: string | undefined; userEntryPoints?: string[] | undefined; store?: IndexStore | undefined; }): DeadCodeScanOutput; //# sourceMappingURL=dead-code-scan.d.ts.map