import { AsyncLocalStorage } from 'node:async_hooks'; export interface ForgeContextData { args: Record; commandChain: string[]; /** * Process-unique identifiers of every CLI instance from the root down to * the currently-running command. Used by `getCommandContext(cli)` to * validate the CLI reference passed as a type witness is any command on * the active chain — the root app, an ancestor, or the running command * itself. Accepting ancestors matters because standalone-composed * subcommands don't track their parent in the type system, so users * reliably have a reference to the root `app` but not always to the * specific running subcommand. */ commandIdChain: string[]; /** Pre-resolved eager providers and cached factory results */ providers: Map; /** Factory registrations for lazy resolution */ providerFactories: Map; /** Whether inject() is currently allowed (only during handler phase) */ handlerPhase: boolean; /** Keys whose factories are currently being resolved — used for cycle detection */ resolving: Set; } export const contextStorage = new AsyncLocalStorage();