/** * templateMiner.ts — learn templates, tileset profiles and adjacency rules from * the project the server is installed in. * * The bundled reference maps come from the RTP, which means they only fit * projects using RTP tilesets and they ride along in the npm package. Mining the * user's own maps addresses both: the knowledge is derived from art the user * already licensed, and what comes out matches the style they actually build in * — corridor widths, prop density, which ground tile they treat as default. * * Three things come out of one pass: * - semantic templates layouts with the art stripped out (see semantic.ts) * - tileset profiles which concrete tile ID plays each role, by observed * frequency, so a layout can be re-materialised onto any * tileset the project uses * - adjacency counts which tokens sit next to which, the statistics a * constraint-based generator needs * * Everything is written to .mcp-cache/, which is derived data: delete it and the * next mine rebuilds it. */ import { type SemanticTemplate, type TilesetProfile } from '../knowledge/semantic.js'; export declare const CACHE_DIR = ".mcp-cache"; export declare const CACHE_FILE = "project-templates.json"; export declare const MINE_VERSION = 1; export interface AdjacencyCounts { /** "tokenA>tokenB" -> how often B sits to the right of A. */ horizontal: Record; /** "tokenA>tokenB" -> how often B sits below A. */ vertical: Record; } export interface MineResult { version: number; minedAt: string; mapsScanned: number; mapsKept: number; skipped: { mapId: number; reason: string; }[]; templates: SemanticTemplate[]; profiles: Record; adjacency: AdjacencyCounts; } export interface MineOptions { /** Maps with fewer distinct tiles than this are test scratch, not content. */ minDistinctTiles?: number; /** Maps smaller than this many cells are ignored. */ minCells?: number; /** Cap on templates kept, largest maps first. 0 means no cap. */ limit?: number; /** Skip writing the cache file (used by callers that only want the result). */ noWrite?: boolean; } /** * Scan the project and cache what it learns. Read-only with respect to the * project's own data — the only thing written is .mcp-cache/. */ export declare function mineProject(projectPath: string, opts?: MineOptions): Promise; /** Read a previous mine, or null when there is none. */ export declare function loadMinedTemplates(projectPath: string): Promise; /** The mined profile for one tileset, or null when it was never observed. */ export declare function getMinedProfile(projectPath: string, tilesetId: number): Promise;