import type { Command } from "commander"; export { INFRA_DIRECTORY } from "../infra.js"; /** * The directory a scaffolded repo keeps runnable scripts in — at the repo * root, not inside `infra/`, so the loader never imports them. * * A cookbook that ships `scripts/` lands under `scripts//`, the same * namespacing `infra/` gets. Written once: unlike the skill half, these are * not discovered by agent convention, and duplicating them would put the * same runnable file in two places. */ export declare const SCRIPTS_DIRECTORY = "scripts"; export type ProjectDirOptions = { dir?: string; }; /** Declare `--dir` on a command that takes one. */ export declare function withProjectDir(command: Command): Command; /** * Move into the directory the command was pointed at. Commands run from the * project root so relative code paths (`defineWorker`/`defineApp`/`defineFile`) * and `cargo.state.json` resolve against it. */ export declare function enterProjectDir(opts: ProjectDirOptions): void; /** * The directory holding the CDK project, which is not always the one you are * standing in. A scaffolded repo keeps its resources in `infra/`, so that is * where the CDK dependency — and everything the loader may import — lives. * * This is not cosmetic. The loader imports every `.ts` under the directory it * is given, and a repo root also holds `scripts/`, whose files run on import. * Pointing a command at the root would execute them. * * It deliberately does NOT walk up. Finding the project from anywhere in the * repo is `cdkPackageRoot` (walk up to where the CDK is declared) composed with * this (resolve down to the resources): walk up, then down. A resolver that did * both was what `findCdkProjectRoot` used to be, and it accepted ANY `infra/` * directory — a Terraform or k8s one included — because a single function * cannot apply the strict test without the anchor to apply it from. */ export declare function cdkResourceDir(startDir: string): string | undefined; /** * @deprecated Renamed to `cdkResourceDir`: it answers "where are the resources * the loader scans", which is NOT the package root. Kept as an alias because * `@cargo-ai/cdk/cli` exports it. */ export declare const cdkProjectDir: typeof cdkResourceDir; /** * The root of the Cargo CDK repo `startDir` sits in, or undefined when it is * not in one. * * Three things this is not. It is not `cdkProjectDir`, which answers "where * would the loader run" and — to serve a scaffolded repo whose `infra/` has no * manifest — takes that directory's mere existence as the signal, so every * Terraform or k8s repo passes. It is not `findCdkProjectRoot` in * `projectRoot.ts`, which walks up unbounded and accepts `cargo.state.json` as * proof; this wants a manifest, because the things it gates (writing a * cookbook, naming a skill) need a package to write into. And it is not a * check of `startDir` alone: the scaffold puts the CDK dependency in the *root* * manifest and its README sends people to work in `infra/`, so looking only * down from where someone is standing reports "no project" in the likeliest * working directory. * * So: read `package.json` for a CDK dependency, walking up. `.git` stops the * walk, because a parent repo's project is not this one. */ export declare function cdkPackageRoot(startDir: string): string | undefined; /** * @deprecated Renamed to `cdkPackageRoot`: it answers "where is the CDK * declared", which is the anchor everything resolves from — NOT the resource * directory. Kept as an alias because `@cargo-ai/cdk/cli` exports it. */ export declare const cdkProjectRoot: typeof cdkPackageRoot; /** Whether `path` is a directory. False for a file, a broken link, or nothing. */ export declare function isDirectory(path: string): boolean; /** * Move into the CDK project, when the cwd is a repo that keeps it a level down. * A directory that is already the CDK project, or that we cannot identify at * all, is left alone — a command should still run on a hand-rolled layout. */ export declare function enterCdkProject(): void; /** * Where a state-touching command runs: the directory `--dir` points at, then * the CDK project inside it. * * Both steps, together, for every such command. Everything they do is keyed off * the directory they end up standing in — which resource files load, * where cargo.state.json is read and written, where the state lock and audit * log live, and the repo-relative position a harness agent binds to. They must * all choose the same one, or a `deploy` reads a different state file than the * `plan` the user just approved and applies a graph nobody previewed. * * This exists because they did not. `plan` and `check` entered the project * while `deploy`, `destroy`, `import`, `pull`, `refresh` and `rollback` stayed * wherever they were invoked — the repo root, for the scaffold's `npm run * deploy`, which also loaded `scripts/`, whose files run on import. */ export declare function enterProject(opts: ProjectDirOptions): void; /** * Run `operation` standing in `dir`, and come back afterwards. * * For the commands that do their own work at the repo root and only need the * project directory for one call. Passing a path is not the same as being * there: a resource body may resolve a path of its own against `process.cwd()` * — the scaffold's `defineContext({ dir: "../context" })` does — so loading a * project from its parent reports an ENOENT on a project that is fine. */ export declare function inDirectory(dir: string, operation: () => Promise): Promise; /** Whether `dir` looks like a Cargo project at all — scaffolded or hand-rolled. */ export declare function isCargoProject(dir: string): boolean; //# sourceMappingURL=project.d.ts.map