/** * Prefer-local re-exec at the CLI entrypoint (mmnto-ai/totem#2018 L1). * * Promotes the deterministic tiers of the ADR-072 resolve cascade (shipped * for git hooks in mmnto-ai/totem#2053) into the binary itself: when a * foreign totem — typically an ambient global install — starts inside a * project that carries its own `@mmnto/cli`, the entrypoint delegates to the * project-local build instead of running with the wrong dependency tree. * Tenet 14 (Never Tie Governance to Volatile State): the pinned local install * is deterministic; the PATH global is ambient. This forecloses both variants * of the recurring class — missing externalized peer SDKs (mmnto-ai/totem#2018) * and stale-version shadowing (mmnto-ai/totem#2053) — by making the wrong * binary unreachable from inside a workspace. * * The delegation is announced on stderr, never silent, and `TOTEM_NO_REEXEC=1` * opts out (it also rides the child environment as the loop guard, so a * pathological realpath mismatch can never re-exec recursively). */ import { sync as spawnSync } from 'cross-spawn'; export interface LocalEntry { /** Absolute path to the local `dist/index.js` to delegate to. */ entry: string; /** The local install's version, when its package.json is readable. */ version?: string; /** Which cascade tier matched: workspace-HEAD or the pinned dependency. */ tier: 'workspace' | 'pinned'; } /** * Resolve the project-local CLI entry by walking up from `cwd`, mirroring the * ADR-072 cascade's deterministic tiers: * * 1. **Workspace-HEAD** — `packages/cli/dist/index.js`, identity-guarded on * `packages/cli/package.json` declaring `@mmnto/cli` (the dogfood monorepo; * the build you just made wins over any installed copy). * 2. **Pinned dependency** — `node_modules/@mmnto/cli/dist/index.js`, the * project's version-locked install via the package's own entry point. * * Both tiers require the BUILT entry to exist — an unbuilt checkout falls * through to running in place (where the mmnto-ai/totem#2018 L2 hint explains * the build step). */ export declare function resolveLocalEntry(cwd: string): LocalEntry | undefined; export interface ReexecOptions { cwd?: string; /** Forwarded argv (everything after `node `). */ argv?: string[]; env?: NodeJS.ProcessEnv; /** The running entry script — `process.argv[1]` in production. */ selfPath?: string; /** This binary's own version, for the delegation notice. */ selfVersion?: string; spawn?: typeof spawnSync; } /** * Delegate to the project-local CLI when this binary is not it. * * Returns the child's exit code when delegation happened (the caller exits * with it), or `undefined` to run in place. A null child status maps to * failure (1), never silent success. */ export declare function maybeReexecLocal(opts?: ReexecOptions): number | undefined; //# sourceMappingURL=reexec-local.d.ts.map