/** * Workspace Discovery Utilities * * Shared helpers for discovering workspace packages in pnpm/yarn/npm * monorepos. Used by the TypeScript, ESLint, and AI-code scanners so * they operate on every package rather than only the repo root. * * Supports: * - npm/yarn `package.json` `workspaces` field (array or `{packages:[]}`) * - pnpm `pnpm-workspace.yaml` `packages` field * * @module util/workspaces */ /** * Returns true iff `candidate` is `root` itself or a strict descendant. * Rejects paths that start with ".." (escape via traversal) and paths that * are absolute but outside `root` (e.g. "/etc" planted in workspace globs). * * Exported so sibling modules (e.g. typescript.ts) can reuse the same check. * * NOTE: this is a string-level check — `relative`/`resolve` do not follow * symlinks, so a symlink *inside* the tree pointing out of it would pass. That * residual is acceptable here (the project root is already realpath-validated * by `validateProjectPath`, so this is defence-in-depth against hostile config * files in the scanned repo). For symlink-aware containment use the realpath * helpers in `paths.ts`. */ export declare function isContained(root: string, candidate: string): boolean; /** * Walk up from `startDir` to find the directory whose `package.json` has a * `workspaces` field, or that contains a `pnpm-workspace.yaml`. * Falls back to `startDir` itself if no workspace root is found. */ export declare function findWorkspaceRoot(startDir: string): Promise; /** * Discover all workspace package directories rooted at `root`. * * Sources: * 1. `root/package.json` `workspaces` globs (array or `{packages:[]}`) * 2. `root/pnpm-workspace.yaml` `packages` globs * * Rules: * - `root` itself is always included. * - Matched paths inside `node_modules` are excluded. * - Result is deduped and contains absolute paths. * * @returns Absolute paths of all workspace package directories (includes root). */ export declare function discoverWorkspaceDirs(root: string): Promise; /** * Discover all directories in `root` that are independently auditable npm * packages — i.e. they contain both a `package.json` AND at least one * lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`). * * Returns the UNION of: * 1. `discoverWorkspaceDirs(root)` — declared workspace packages. * 2. A bounded downward walk that catches undeclared sub-projects * (e.g. `apps/web` with its own lockfile that is NOT listed in root * `workspaces`). * * Rules: * - `root` itself is always included. * - Entries under `node_modules`, `.git`, `dist`, `.next` are never * returned and are not descended into. * - Result is deduped by resolved absolute path. * - Depth cap: 4 levels below `root`. * - Count cap: 25 total dirs. On hitting the cap a warning is logged. * * @param root — Absolute path that has already been validated by * `validateProjectPath()`. */ export declare function discoverPackageDirs(root: string): Promise; //# sourceMappingURL=workspaces.d.ts.map