/** * Shared upward config-discovery walk (chant #1117). * * Before this, `chant build ` and `lint.policies` * (`./lint/policy.ts`'s `evaluateProjectPolicies`) each searched only the * build directory and its immediate parent for `chant.config.ts`/`.json`, * while `chant lint`/`chant graph` (`./lint/config.ts`'s old, file-local * `findProjectRoot`) already walked all the way up. A project with a deeper * `src/` layout — `chant build src/` two or more levels below * the project root — silently never found the root config: `buildParams`' * declared `env:` mappings went inert, `ownership`/`lint.policies`/etc quietly * fell back to defaults, and nothing warned (loomster#162: `LOOM_TIER`/ * `LOOM_ENV` inert under every `npm run synth:*` for two releases). * * `findProjectConfig` is the one walk every config-discovery call site now * shares. It stops at the first of: * * 1. A directory holding `chant.config.ts` or `chant.config.json` — found. * 2. A directory holding `.git` or `package.json` with no chant config of its * own — the project boundary. Discovery must never wander past the actual * project into an unrelated ancestor directory just because this project * happens not to declare a config (a stray `chant.config.ts` two levels * above an unrelated git repo must never be picked up). * 3. `startDir` itself, unchanged, if the walk reaches the filesystem root * without ever finding a config OR a boundary marker. This is not just a * "give up gracefully" nicety — several callers (`resolveProjectLexicons` * -> `findInfraFiles`) scope a real directory walk off this function's * result; if a rootless/marker-less start dir (a bare tmpdir, as chant's * own test suites use) resolved all the way to `/`, that downstream walk * would scan the entire filesystem instead of failing fast. Falling back * to `startDir` keeps every caller's blast radius local no matter how far * up the walk had to look. */ export interface ProjectConfigSearch { /** The resolved project root: the config's directory, the boundary directory, or the (resolved) `startDir` when neither was found. */ dir: string; /** Absolute path to the discovered `chant.config.ts`/`.json`, if any. */ configPath?: string; } /** Walk up from `startDir` (inclusive) to the nearest chant config or project boundary. See {@link ProjectConfigSearch}. */ export declare function findProjectConfig(startDir: string): ProjectConfigSearch; /** * Walk up from `startDir` to the nearest ancestor holding a chant project * config (`chant.config.ts` or `chant.config.json`), the `.git`/`package.json` * project boundary, or `startDir` itself when neither is found. Thin wrapper * over {@link findProjectConfig} for callers that only need the directory * (e.g. `chant lint`'s rule/plugin resolution, which just needs *a* stable * root to resolve relative paths against). */ export declare function findProjectRoot(startDir: string): string; //# sourceMappingURL=project-root.d.ts.map