/** * scanner — recursive `.md` walker for `cleo docs import`. * * Walks a directory tree from a single root, returning one entry per * markdown file discovered. Each entry carries the absolute path, the * project-relative source-dir prefix used by the type classifier, and a * SHA-256 of the file's content so the dedup gate can decide whether * the bytes are already in the docs SSoT. * * Excludes well-known transient/build directories by default * (`node_modules`, `.git`, `dist`, `coverage`, `build`). * * @epic T9628 (Saga T9625) * @task T9710 (ST-MIG-1a) */ /** * Document import classification used by the type classifier. * * CLI-level concept distinct from {@link DocKind} — `research`, `note`, * and `spec` ride in `meta.importType` while the blob backend stores * them as `agent-output`. `adr` maps 1:1 to the existing DocKind. */ export type DocImportType = 'research' | 'adr' | 'note' | 'spec'; /** A single markdown file discovered during scanning. */ export interface ScannedFile { /** Absolute filesystem path of the markdown file. */ readonly absPath: string; /** Path relative to the scan root (e.g. `.cleo/research/foo.md`). */ readonly relPath: string; /** SHA-256 of the file bytes, hex encoded. */ readonly contentSha: string; /** Classified import type per the source-dir rules table. */ readonly suggestedType: DocImportType; /** Raw file content (UTF-8). Cached to avoid re-reading during import. */ readonly content: string; } /** Options for {@link scanDirectory}. */ export interface ScanOptions { /** Absolute filesystem path to scan recursively. */ readonly root: string; /** * Directory names to skip during the walk. Default: * `node_modules`, `.git`, `dist`, `coverage`, `build`. */ readonly excludeDirs?: ReadonlySet; /** * Override for the default type classifier. When provided this overrides * the source-dir rules table for the given `relPath`. */ readonly classify?: (relPath: string) => DocImportType; } /** * Default directory names skipped by the scanner. */ export declare const DEFAULT_EXCLUDE_DIRS: ReadonlySet; /** * Default type classifier — see ADR-073 / T9639 spec for the rules table: * * ``` * .cleo/adrs/ → adr * .cleo/research/ → research * .cleo/agent-outputs → note * .cleo/rcasd/ → research (T9791 — added so rcasd dirs classify * when the scan root is the project root) * docs/specs/ → spec * docs/ → spec (catch-all) * * → note (default) * ``` * * NOTE: This function expects {@link relPath} to start with the source-dir * prefix (e.g. `.cleo/adrs/`). When the scanner is invoked with a scan root * INSIDE one of these source dirs (e.g. `scanRoot = .cleo/adrs/`), every * file's relPath will be missing that prefix and default to `note`. Callers * SHOULD pass a {@link makeClassifierForScanRoot} closure to recover the * correct classification in that scenario. * * @param relPath - Path relative to the scan root. * @returns Classified import type. */ export declare function classifyByRelPath(relPath: string): DocImportType; /** * Map a canonical source-dir name to its {@link DocImportType}. * * Source-dir aware classification: when `cleo docs import .cleo/adrs` is run, * the scanner sees relPaths like `ADR-001.md` (no `.cleo/adrs/` prefix) so * {@link classifyByRelPath} would fall through to `note`. This map records * the canonical mapping by source-dir name so the CLI can pre-resolve the * classification before scanning. * * Keys are project-relative POSIX paths without trailing slash. * * @task T9791 */ export declare const SOURCE_DIR_TO_TYPE: ReadonlyMap; /** * Detect the source-dir for an absolute or project-relative scan root and * build a classifier closure that returns the matching {@link DocImportType} * for every file it sees. * * When the scan root does not match any canonical source-dir the returned * closure falls back to {@link classifyByRelPath} so callers retain the * pre-T9791 behaviour. * * @param scanRoot - Absolute (or project-relative) path passed to the scanner. * @param projectRoot - Absolute project root for resolving the project-relative * form of {@link scanRoot}. * @returns A classifier that resolves the type for any scanned file under * {@link scanRoot}. * * @task T9791 */ export declare function makeClassifierForScanRoot(scanRoot: string, projectRoot: string): (relPath: string) => DocImportType; /** * Recursively walk `root` and return every `.md` file with its sha + type. * * Symbolic links are skipped (we only follow regular files and directories) * to avoid pathological cycles. Files that fail to read are silently * skipped — callers can detect this via the `errorCount` they maintain * around the scan. * * @param options - Scan options including the root directory. * @returns One {@link ScannedFile} per discovered `.md` file. */ export declare function scanDirectory(options: ScanOptions): Promise; //# sourceMappingURL=scanner.d.ts.map