/** * Hallucination Checker * * Detects non-existent imports, fabricated APIs, and incorrect patterns * commonly produced by AI code generation. * * Resolution algorithm (monorepo-aware): * 1. `import type` statements are skipped entirely. * 2. Relative / absolute-path imports are checked against the filesystem. * 3. Node built-ins and `node:` scheme imports are always considered valid. * 4. For every source file, walk up from its directory to the workspace root * collecting all `package.json` manifests and merging * dependencies + devDependencies + peerDependencies + optionalDependencies. * A package declared in ANY of them counts as installed. * 5. Workspace package names (from root `workspaces` globs and * `pnpm-workspace.yaml`) are valid internal specifiers. * 6. tsconfig `compilerOptions.paths` and `baseUrl` aliases are LOCAL * references, never flagged as npm packages. The nearest tsconfig * (following `extends`) is resolved per file. * * @module scanners/ai-code/hallucination-checker */ import type { HallucinationFinding, HallucinationType } from "./types.js"; interface ImportInfo { source: string; specifiers: string[]; line: number; isRelative: boolean; isPackage: boolean; } /** * Parse ES module and CommonJS imports from source content. * `import type` statements are excluded — they carry no runtime dependency. */ export declare function parseImports(content: string, filePath: string): ImportInfo[]; export declare function checkRelativeImport(importInfo: ImportInfo, sourceFilePath: string, projectPath: string): Promise; export declare function checkPackageImport(importInfo: ImportInfo, projectPath: string, sourceFilePath?: string): Promise; export declare function checkDeprecatedAPIs(content: string, filePath: string): HallucinationFinding[]; export declare function checkMixedFrameworks(content: string, filePath: string): HallucinationFinding[]; export declare function checkFileForHallucinations(filePath: string, projectPath: string, content?: string): Promise; export declare function scanDirectoryForHallucinations(projectPath: string, options?: { extensions?: string[]; exclude?: string[]; }): Promise<{ files: number; findings: HallucinationFinding[]; summary: { byType: Record; bySeverity: Record; }; }>; export declare function calculateHallucinationScore(findings: HallucinationFinding[]): number; export {}; //# sourceMappingURL=hallucination-checker.d.ts.map