/** * Spec 12 — Convention Mining * * Mines five domains of unwritten codebase conventions from the SQLite function * index. All mining runs on the existing `functions` and `function_calls` tables; * no new parsing infrastructure required. * * Domains: * 1. usage-pair — calls that always co-occur (from function_calls table) * 2. import-form — dominant import style per (source, directory) * 3. error-handling — dominant error-handling shape per directory * 4. export-shape — dominant export style per directory * 5. naming — dominant exported-symbol casing per directory */ import Database from 'better-sqlite3'; import type { Convention, ConventionMiningConfig } from '../types.js'; /** Escape regex special characters in a string. */ export declare function escapeRegex(s: string): string; /** Detect whether a string contains non-Latin-script characters (Spec 21 R5.4). */ export declare function hasNonLatinChars(name: string): boolean; /** Classify a symbol name into a casing convention. Returns null for * non-Latin, unclassifiable, or ambiguous names. */ export declare function detectCase(name: string): string | null; /** * Parse import statements from raw file content. * * Handles: import default, import named, import namespace, import side-effect, * require default, require destructured. * Multi-line imports supported via {}-accumulation. */ export declare function parseFileImports(content: string): Array<{ source: string; localNames: string[]; form: 'default' | 'named' | 'namespace' | 'side-effect' | 'require'; line: number; }>; /** * Parse the export form for a specific exported function from its source file. * Returns null if we can't determine the form. */ export declare function detectExportForm(filePath: string, functionName: string): 'default' | 'named' | null; /** * Detect the error-handling shape used in a function body. * Returns null if no error handling is present (function should not be counted * in the corpus for mode computation). */ export declare function detectErrorHandlingShape(body: string | undefined | null): string | null; /** * Compute a content hash of the miner inputs for change detection. * Callers can store this in the meta table to skip re-mining when unchanged. */ /** * Increment this when the miner algorithm changes (new domains, new logic, * threshold changes not captured by ConventionMiningConfig). The version is * folded into the skip-hash so that miner upgrades force re-mining rather * than silently reusing stale results from the old algorithm. */ export declare const MINER_VERSION = 1; /** * Compute a content hash of the miner inputs for change detection. * Callers can store this in the meta table to skip re-mining when unchanged. * Includes MINER_VERSION so that algorithm changes force a re-mine. */ export declare function computeMinerInputHash(db: Database.Database, config: ConventionMiningConfig): string; /** * Mine all five convention domains from the SQLite index. * * @param db The better-sqlite3 database instance. * @param config Threshold configuration for the miner. * @param projectRoot Optional project root — required for import-form and * export-shape mining to resolve file paths. * @returns Array of mined conventions (uncapped — caller should upsert). */ export declare function mineConventions(db: Database.Database, config: ConventionMiningConfig, projectRoot?: string): Convention[]; //# sourceMappingURL=conventionMiner.d.ts.map