/** * @fileoverview Project-context resolver. * * Walks up from `cwd` looking for an opensip-tools project (i.e. an * ancestor where `resolveProjectConfigPath` would succeed). Returns a * single `ProjectContext` carrying everything downstream consumers * need: cwd, cwdExplicit, projectRoot, configPath, walkedUp, scope. * * The walker leans on `resolveProjectConfigPath` at each ancestor so * the `package.json#opensip-tools.configPath` pointer is honored * everywhere it works at a single directory (matches existing * `resolveProjectConfigPath` contract). * * Strict `--config` semantics: when the caller passes `explicitConfigPath` * and `resolveProjectConfigPath` rejects it at the starting ancestor, * the resolver propagates the underlying `ValidationError` rather than * silently walking up. Silently walking up would let `--config /typo.yml` * land on some unrelated ancestor's config — exactly the surprise this * module exists to prevent. Implicit ancestor discovery still swallows * "no config at this directory" errors (that's the walking signal). */ /** Resolved per-invocation project context — read by every downstream consumer. */ export interface ProjectContext { /** Literal cwd at invocation (or the value of an explicit `--cwd` flag). Absolute. */ readonly cwd: string; /** True when the user passed `--cwd` on the command line (vs Commander defaulting it). */ readonly cwdExplicit: boolean; /** * Resolved project root. If an ancestor has a config file, that ancestor. * Otherwise equals `cwd` (no discovery; commands like `init` fall back to here). */ readonly projectRoot: string; /** Resolved config file path at `projectRoot`, or undefined when no project was found. */ readonly configPath: string | undefined; /** Ancestor steps walked from `cwd` to `projectRoot`. 0 when cwd is the root. */ readonly walkedUp: number; /** `'project'` iff a config was discovered; `'none'` otherwise. */ readonly scope: 'project' | 'none'; } /** Input to {@link resolveProjectContext}: cwd plus optional overrides controlling discovery. */ export interface ResolveProjectContextInput { /** Literal cwd or `--cwd` value. */ readonly cwd: string; /** True when `--cwd` was passed on the command line. */ readonly cwdExplicit: boolean; /** * Optional `--config ` override. Honored at the *start* ancestor only. * Strict: if provided and the path doesn't resolve, the resolver throws. */ readonly explicitConfigPath?: string; /** * Absolute path beyond which the walker stops. Used by tests to prevent the * walker from escaping fixture directories and finding the real repo's config * above. Defaults to the filesystem root. */ readonly stopAt?: string; } /** * Resolve the project context for an invocation. Pure function — no side * effects beyond debug logging. * * @throws {ValidationError} when `explicitConfigPath` is provided and * `resolveProjectConfigPath` rejects it at the starting ancestor. */ export declare function resolveProjectContext(input: ResolveProjectContextInput): ProjectContext; //# sourceMappingURL=project-context.d.ts.map