/** * Project-root discovery — the one source of truth for "which `.aidlc/` tree is * this?" (cwd-project-root/AC-1 … AC-7). * * Every command previously read `process.cwd()` and treated it as the project * root. Run from a subdirectory that is silently wrong: `cost record` reported * success while writing into a freshly-created `.aidlc/state/.aidlc/` tree no * report reads, and `status`/`metrics` rendered zeroes as if measured. The * failure had no error path because nothing was checking. * * This lives in `core/` for the reason `tty.ts` records: `commands/`, `doctor/` * and `events/` all need it, and `menu/index.ts` imports the command registrars, * so siting it anywhere those import from would close a cycle. * * ## Nearest wins, not primary * * `roadmap/paths.ts` resolves the **primary checkout** via `git rev-parse * --git-common-dir`, deliberately: a backlog written inside a feature worktree is * stranded on that branch until it merges. That is the correct rule for the * roadmap and the wrong one here. Instance state and cost belong to the worktree * that produced them, so this walks to the *nearest enclosing* `.aidlc/` * (AC-5, AC-19). The two rules coexist on purpose; neither is a fallback for the * other. * * ## Two commands must not use this * * `init` and `discover` keep reading `process.cwd()` (AC-16). `init` creates a * project — searching upward would make `aidlc init` inside an existing project * silently reconfigure the ancestor instead of initializing where the user is * standing. `discover` scans a codebase for the same reason. `test/project-root- * call-sites.test.ts` names both as expected exemptions, so a *new* unrouted * `process.cwd()` fails the suite rather than being found later by a user. * * @module */ /** The directory whose presence marks a project root. */ export declare const PROJECT_MARKER = ".aidlc"; /** * The nearest ancestor of `from` (including `from`) containing a `.aidlc/` * directory, or `from` itself when there is none. * * Falling back to `from` keeps behaviour outside a project byte-identical to * today (AC-2) — that is what makes this a safe change to route ~20 call sites * through at once. A caller that needs to distinguish "found" from "fell back" * should use {@link findProjectRoot}. * * No subprocess and no `git` (AC-6): a project need not be a repository, and * spawning `git` once per command to answer a question `statSync` answers would * be slower and would fail differently outside a repo. */ export declare function resolveProjectRoot(from?: string): string; /** * As {@link resolveProjectRoot}, but null when no ancestor holds the marker. * * Exists for the callers that must *report* rather than assume — a command can * say "not in an AIDLC project" instead of inventing a root and then finding it * empty, which is the shape of the original defect. */ export declare function findProjectRoot(from?: string): string | null; //# sourceMappingURL=project-root.d.ts.map