/** * portable-bundle-relocate.ts — rewrite a restored project's absolute paths * from its old root to its new root, and report every absolute path it * deliberately left alone. * * Rewrites are limited to STRUCTURAL locators: path-named columns and * path-named keys inside `*_json` columns. Historical records (audit logs, * observations, narratives, captured tool output, task text) are reported * but never edited: rewriting them would falsify history and invalidate * content hashes and signatures computed over the original text. * * Operates on a staged copy BEFORE it is placed, so a failed relocation * never leaves a half-rewritten live store. * * @task T12318 * @epic T12317 * @module store/portable-bundle-relocate */ import type { PortableRelocationReport } from '@cleocode/contracts'; /** * True when `value` is `root` or lies under it (path-boundary aware, so * `/a/b` does not match `/a/bc`; `..` escapes do not count as under). * * @param value - Candidate path. * @param root - Root path; a trailing separator is ignored. * @returns Whether `value` is at or under `root`. */ export declare function isUnderRoot(value: string, root: string): boolean; /** * Re-root `value` from `from` onto `to` (boundary aware). * * The remainder keeps its segments, with `.`/`..` resolved, and is joined * with `to`'s separator: `C:\p\a\b` moved from `C:\p` to `/home/me/p` * becomes `/home/me/p/a/b`, not the single POSIX filename `a\b`. * * @param value - Path under `from`. * @param from - Old root; a trailing separator is ignored. * @param to - New root; a trailing separator is ignored. * @returns The relocated path, or `value` unchanged when it is not under `from`. */ export declare function relocatePath(value: string, from: string, to: string): string; /** How a relocation treats one column: a path locator, path keys inside JSON, or neither. */ export type RelocatableColumn = 'path' | 'json' | null; /** * Whether {@link relocateDatabase} rewrites `column` of `table`, and how. * Historical tables and columns and `WITHOUT ROWID` tables are never * rewritten. * * @param table - Table name. * @param column - Column name. * @param withoutRowid - The table is `WITHOUT ROWID`. * @returns `path`, `json`, or `null` when the column is left alone. * @task T12336 */ export declare function relocatableColumn(table: string, column: string, withoutRowid: boolean): RelocatableColumn; /** * The value {@link relocateDatabase} would write for one text cell of a * relocatable column, or the value unchanged when it would not rewrite it. * The cloud vault hashes cells through this, so a relocated store hashes * exactly like its source. * * @param kind - The column's kind ({@link relocatableColumn}). * @param value - Cell text. * @param from - Old root. * @param to - New root. * @returns The relocated text. * @task T12336 */ export declare function relocateCell(kind: 'path' | 'json', value: string, from: string, to: string): string; /** * Relocate one SQLite database from `from` to `to`. * * @param dbPath - Staged database (modified in place). * @param dbLabel - Label used in finding locations (e.g. `cleo.db`). * @param from - Old project root. * @param to - New project root. * @param report - Report to append to. */ export declare function relocateDatabase(dbPath: string, dbLabel: string, from: string, to: string, report: PortableRelocationReport): void; /** Project JSON files whose string values are relocated wholesale. */ export declare const RELOCATED_JSON_FILES: readonly string[]; /** * A {@link RELOCATED_JSON_FILES} file's JSON with every string value that is * an absolute path under `from` re-rooted onto `to`, serialised compactly, so * two copies of one file relocated to different roots compare equal (the * cloud vault hashes them this way, T13005). * * @param text - File content. * @param from - Old root. * @param to - New root. * @returns Compact JSON, or `null` when `text` is not JSON. * @task T13005 */ export declare function relocatedJsonText(text: string, from: string, to: string): string | null; /** * Relocate the staged `.cleo/` files of one project and report text files that * still mention the old root. * * - `project-info.json`: left as is. `projectId` and the write-once * `projectHash` are identity keys (release ids, audit rows), never path * facts, so a relocation keeps both (T12557). * - `config.json`, `project-context.json`, `worktrees.json`: string values that * are absolute paths under the old root are rewritten. Paths embedded inside * prose strings are left and reported. * - Every other text file mentioning the old root is reported, not edited. * * @param stagedCleoDir - Staged copy of the project's `.cleo/` directory. * @param relPaths - Relative paths of the staged regular files. * @param from - Old project root. * @param to - New project root. * @param report - Report to append to. */ export declare function relocateProjectFiles(stagedCleoDir: string, relPaths: readonly string[], from: string, to: string, report: PortableRelocationReport): void; //# sourceMappingURL=portable-bundle-relocate.d.ts.map