/** * Atlas — a committable projection of the codebase index. * * The index itself is a 180 MB SQLite database under `~/.wrongstack/projects/`: * machine-local, binary, and unreviewable. That means every fresh clone, every * CI run and every teammate starts cold, and nobody can see in a pull request * what the index believes about the code. * * The atlas is the derived, human-sized answer to that: a small, deterministic * set of files written into the repository at `.wrongstack/atlas/`. The * database stays canonical — this is strictly a one-way projection, and * regenerating it from an unchanged index must produce byte-identical output. * * ## Determinism is a hard requirement * * Anything that varies between two runs over the same index turns every * indexing run into a merge conflict. So: no timestamps, no host paths, keys * emitted in sorted order, floats rounded to a fixed precision, and LF line * endings (the pre-commit hook enforces those repo-wide anyway). * * ## Staleness is reported, never guessed * * A committed atlas describing code that has since moved is worse than no * atlas, because it is confidently wrong. {@link checkAtlasFreshness} compares * the recorded per-file content hashes against the live index and says exactly * which files drifted. */ import type { AtlasDocument, AtlasEdge, AtlasFile, AtlasManifest, AtlasPackage, AtlasProjection, AtlasSymbol } from './atlas-types.js'; import type { FileRankRow } from './graph-rank.js'; import { type IndexStore } from './writer.js'; /** Directory the projection is written to, relative to the project root. */ export declare const ATLAS_DIR: string; export declare const ATLAS_JSON = "atlas.json"; export declare const ATLAS_MARKDOWN = "ATLAS.md"; export declare const ATLAS_MANIFEST = "manifest.json"; /** * Bumped when the emitted shape changes. A reader seeing a different schema * reports the atlas as stale rather than misinterpreting its fields. */ export declare const ATLAS_SCHEMA = 2; /** * Files carried in the projection. Enough to describe the architecture, * small enough to read in a diff — the full 8k-file list would be neither. */ export declare const ATLAS_FILE_LIMIT = 300; /** * Code-unit string order. `localeCompare` follows the host's ICU locale, so * the same index sorted `B`/`a` (or `I`/`ı` under tr-TR) differently on two * machines — a committed atlas that must be byte-identical everywhere * churned on every regeneration by someone with another locale. */ export declare function compareText(a: string, b: string): number; /** * The package a file is shown under. Single source for the projection AND the * brief: a file with an empty `package` label is grouped by its first path * segment. */ export declare function atlasPackageName(packageLabel: string | undefined, relativePath: string): string; /** * Indexed files per displayed package name. Counting by the raw label gave * every path-derived package the total of ALL unlabelled files (they share * the '' label), and counted '' itself as a package. */ export declare function atlasPackageFileCounts(store: IndexStore, relativeOf: (file: string) => string): Map; export type { AtlasDocument, AtlasEdge, AtlasFile, AtlasManifest, AtlasPackage, AtlasProjection, AtlasSymbol, }; /** * Build the projection from the index. Pure with respect to the filesystem — * {@link writeAtlas} is what touches disk. */ export declare function buildAtlas(store: IndexStore, projectRoot: string): AtlasProjection; export interface WrittenAtlas { dir: string; files: string[]; fileCount: number; packageCount: number; } /** Write the projection into `/.wrongstack/atlas/`. */ export declare function writeAtlas(store: IndexStore, projectRoot: string): Promise; export interface AtlasFreshness { fresh: boolean; /** Why it is not fresh. Absent when `fresh`. */ reason?: 'missing' | 'unreadable' | 'schema' | 'drift' | undefined; /** Atlas files whose content hash no longer matches the index. */ changed: string[]; /** Atlas files the index no longer knows about. */ removed: string[]; /** Indexed files absent from the atlas manifest. */ added: number; /** True when the whole-repository digest still matches. */ digestMatches: boolean; } /** Files listed in a drift report before it is summarised rather than enumerated. */ export declare const MAX_REPORTED_DRIFT = 20; /** * Compare the committed atlas against the live index. * * Reads only the manifest — the atlas document and markdown are derived from * the same data, so a manifest that matches means all three are current. */ export declare function checkAtlasFreshness(store: IndexStore, projectRoot: string): Promise; /** * Project-level entry points. * * These own the store lifetime so callers outside this package never have to * touch `indexStorePool`. Both refuse to run when there is no index yet: * opening a store CREATES the database, and neither writing an atlas nor * checking one should be the thing that indexes a project. */ export type AtlasIndexMissing = { indexed: false; }; /** Write the atlas for a project, or report that it has no index yet. */ export declare function writeProjectAtlas(projectRoot: string, opts?: { indexDir?: string | undefined; }): Promise; /** Check a project's written atlas against its index. */ export declare function checkProjectAtlasFreshness(projectRoot: string, opts?: { indexDir?: string | undefined; }): Promise; /** * Build a project's static HTML atlas, or report that it has no index yet. * * Returns the markup rather than writing it: where the file belongs is the * caller's decision (a CI artifact directory, a temp file the CLI opens, an * HTTP response body), and this package should not guess. */ export declare function exportProjectAtlasHtml(projectRoot: string, opts?: { indexDir?: string | undefined; projectName?: string | undefined; }): Promise; /** Re-exported for callers that render rank rows next to atlas output. */ export type { FileRankRow }; //# sourceMappingURL=atlas-projection.d.ts.map