/** * CLI argument parser for the contextatlas binary. * * Two modes: subcommand-dispatched operations and the no-subcommand * default that starts the MCP server over stdio. The distinction * lives in {@link ParsedArgs.subcommand}. * * Per ADR-12: flags compose, subcommands partition. Subcommand parsing * runs before flag parsing — the first non-flag positional argument * is inspected against the known subcommand table. Flags may appear on * either side of the subcommand name, so both * `contextatlas --config-root /x index` and * `contextatlas index --config-root /x` parse the same way. * * Flags (all accepted by default subcommand; `index` filters per * ADR-12's spec): * * --config-root (ADR-08) Directory that acts as the * resolution base for the config file and for * the paths the config names (atlas.path, * atlas.local_cache, source.root). * Default: process.cwd(). * * --config (ADR-08) Specific config file to load. When * relative, resolved against --config-root. * When absent, defaults to * `/.contextatlas.yml`. * * --check (ADR-11) Boolean flag on the default * (no-subcommand) invocation. Produces a * staleness probe and exits. Rejected when * combined with any subcommand — see ADR-12. * * --full (ADR-12) Accepted only with `index`. Bypass * SHA-diff gating and re-extract every prose * file regardless of staleness. * * --json (ADR-12) Accepted only with `index`. Emit * the completion summary as a JSON object on * stdout instead of the default `key=value` * lines. * * --budget-warn (v0.2 Stream A #2) Accepted only with `index`. * When the cumulative extraction API cost * exceeds this threshold during a run, a * single warning is logged to stderr. Not a * hard cap — run continues. Overrides * `extraction.budget_warn_usd` from the config * file when both are specified. * * --verbose (v0.2 Stream A #3) Accepted only with `index`. * Emits per-file unresolved-token detail to * stderr at the end of the run (grouped by * source file, with claim text and frontmatter- * vs-claim origin). Default stdout summary * unchanged; verbose affects the diagnostic * channel only. * * --narrow-attribution= * (v0.3 Theme 1.2 Fix 2) Accepted only with * `index`. Enables claim-attribution narrowing * to mitigate the muddy-bundle mechanism * documented in Phase 6 §5.1. `drop` removes * frontmatter inheritance entirely (the * cleanest experimental knob). `drop-with- * fallback` drops, but recovers claims that * would otherwise attach to zero symbols. * Overrides `extraction.narrow_attribution` * from the config file when both are specified. * Both `--narrow-attribution drop` and * `--narrow-attribution=drop` forms accepted. * * --cc-only (v0.6 Step 4.1) Accepted only with `init`. * Boolean opt-in for B13-flags single- * dependency architecture (claude-code-only) * per Q5 lock + v0.6 Step 4.0 Q4.0.5 + Q4.0.11 * locks. Default false ("anthropic-api-claude- * code" current dual-dependency). * * --observe (v0.6 Step 6.2) Accepted with `init` (writes * `observability.enabled: true` into the config * file) and with `mcp` (per-session override * that enables observation logging without * editing the config file). The flag IS the * consent signal per Q6.0.4 hybrid wiring lock * + ADR-20 cohort observability contract. * Rejected with `index` or `doctor` (no MCP * tool surface to observe). * * Unknown arguments throw with actionable errors. Unknown * subcommand names get the "did you mean?" suggestion treatment when * they're close to a real name (prominently "reindex" → "index", per * ADR-12's note about muscle memory from ADR-11's pre-amendment text). * * Extracted from `src/index.ts` so it's testable without triggering * `main()` as a side effect of importing. */ export type Subcommand = "mcp" | "index" | "doctor" | "init" | "generate-adrs" | "resolve-symbols" | "validate-atlas" | "validate-adrs" | "list-extraction-sources" | "validate-extraction"; export interface ParsedArgs { /** * Which operation the user invoked. `"mcp"` is the no-subcommand * default — the binary starts the MCP server on stdio. Named * subcommands (v0.1: just `"index"`) short-circuit into their own * code paths before MCP setup runs. */ subcommand: Subcommand; /** * Value of `--config-root` if passed; otherwise null. Callers * resolve null to `process.cwd()` themselves — this module does * not touch the filesystem or introduce cwd-dependent defaults. */ configRoot: string | null; /** * Value of `--config` if passed; otherwise null. Callers pass this * through to `loadConfig(root, configPath?)`, which resolves a * relative value against the root and uses an absolute value as-is. */ configFile: string | null; /** * True when `--check` was passed. Signals the caller to short-circuit * into staleness-detection mode rather than start the MCP server. * Rejected when combined with any subcommand — see ADR-12. */ check: boolean; /** * True when `--full` was passed alongside `index`. Bypasses SHA-diff * gating in the extraction pipeline. Rejected on any non-`index` * invocation. Per ADR-12. */ full: boolean; /** * True when `--json` was passed alongside `index`. Switches the * completion summary from `key=value` lines to a single JSON * object. Rejected on any non-`index` invocation. Per ADR-12. */ json: boolean; /** * Value of `--budget-warn ` if passed; otherwise null. When * present, overrides `extraction.budget_warn_usd` from the config * file. Non-negative finite number. Rejected on any non-`index` * invocation. Per v0.2 Stream A #2. */ budgetWarn: number | null; /** * True when `--verbose` was passed alongside `index`. Emits * per-file unresolved-token detail on stderr. Rejected on any * non-`index` invocation. Per v0.2 Stream A #3. */ verbose: boolean; /** * Value of `--narrow-attribution=` if passed; otherwise null. * When present, overrides `extraction.narrow_attribution` from the * config file. One of "drop" | "drop-with-fallback". Rejected on any * non-`index` invocation. Per v0.3 Theme 1.2 Fix 2 (Phase 6 §5.1 * muddy-bundle mechanism). */ narrowAttribution: "drop" | "drop-with-fallback" | null; /** * True when `--cc-only` was passed alongside `init`. Originally * a B13-flags opt-in at v0.6; deprecated at v0.7+ per Path-3 * entry-point-determined architecture (ADR-02 v0.7 Step 1.4b * amendment). CLI cannot bridge to Skills mechanism; flag has * no functional effect at v0.7+; init emits stderr redirect * warning to `/index-atlas` Claude Code skill. Flag removed at * v0.8+ per honest deprecation cycle. Rejected on any non- * `init` invocation. */ ccOnly: boolean; /** * True when `--observe` was passed. Accepted with `init` (writes * `observability.enabled: true` into the config file) and with * `mcp` (per-session override that enables observation logging * without editing the config). The flag IS the consent signal per * Q6.0.4 hybrid wiring lock + ADR-20 cohort observability contract. * Rejected on `index` or `doctor` invocations. v0.6 Step 6.2. */ observe: boolean; /** * `--reference-context ` CLI flag value for the * `generate-adrs` subcommand (per v0.7 Step 2.1.a Travis SECOND * substantive reframe — reference-context-aided generate-adrs). * `null` when the flag is absent. Step 2.2.a.1 ships flag parsing; * Step 2.2.a.2 lands substantive consumption via * `GeneratorContext.referenceContextPath`. */ referenceContext: string | null; /** * `--output ` CLI flag for the `list-extraction-sources` * subcommand. When provided, the manifest is written to the given * file path (resolved against configRoot); when null, manifest * goes to stdout. v0.7.1 Step 1.1.b.0 + Q1.1.G.α — substrate- * equivalence closure at /index-atlas Skill surface. */ output: string | null; /** * True when `--yes` (or alias `--no-confirm`) was passed alongside * `generate-adrs`. Bypasses the pre-flight cost-estimate * confirmation prompt — required for CI/CD / non-interactive * usage per v0.7 Step 2.2.a.2 Lock 3 two-phase cost reporting. * Default false (interactive y/N prompt before API call). */ yes: boolean; /** * True when `--version` was passed. Causes the binary to print the * ContextAtlas version + exit 0 before any subcommand dispatch. * Standard POSIX-convention launch-readiness flag per v0.7 Step * 2.2.b.0 FO-4 fix. */ version: boolean; /** * True when `--help` was passed. Causes the binary to print the * help text + exit 0 before any subcommand dispatch. Standard * POSIX-convention launch-readiness flag per v0.7 Step 2.2.b.0 * FO-4 fix. */ help: boolean; } export declare const KNOWN_SUBCOMMANDS: readonly Subcommand[]; /** * Built from KNOWN_SUBCOMMANDS so the usage string can never drift from * the actual set of accepted subcommands (substrate-consistency * invariant per v0.7 Step 2.1.a FO-1 fix). */ export declare const USAGE: string; /** * Help text emitted on `contextatlas --help`. v0.7 Step 2.2.b.0 FO-4 * fix — substantive launch-readiness UX so v1.0 users get a useful * answer to `contextatlas --help` instead of the * Unknown-argument-error path. Subcommand list is rendered from * KNOWN_SUBCOMMANDS at module-eval time so this can't drift from the * accepted subcommand set. */ export declare const HELP_TEXT = "contextatlas \u2014 codebase-architectural context engine\n\nUsage: contextatlas [options]\n\nSubcommands:\n init Scaffold .contextatlas.yml config + onboarding pipeline\n doctor Verify ContextAtlas setup + adapter prerequisites\n index Extract architectural claims into atlas (requires ANTHROPIC_API_KEY)\n generate-adrs Generate ADRs from codebase (requires ANTHROPIC_API_KEY; one-time-per-repo)\n resolve-symbols Enrich Skill-produced atlas with LSP-resolved symbol IDs (no API key needed)\n validate-atlas Validate atlas.json against canonical schema (no API key needed)\n validate-adrs Validate docs/adr/*.md against canonical depth-floor invariants (no API key needed)\n list-extraction-sources\n Walk ADRs + source-symbols + filtered commits; emit JSON manifest for Skill consumption (no API key needed)\n validate-extraction Validate atlas.json against extraction-quality invariants (per-ADR depth + source coverage; no API key needed)\n\nGlobal options:\n --version Show version + exit\n --help Show this help + exit\n --config-root Override config root (default: cwd)\n --config Override config file path\n\nSubcommand options (selected; see individual subcommand for full set):\n index, generate-adrs:\n --budget-warn Emit warning if cumulative cost exceeds threshold\n index:\n --full Bypass SHA-diff gating; re-extract everything\n --verbose Per-file unresolved-token detail on stderr\n --narrow-attribution \n Override extraction.narrow_attribution config\n generate-adrs:\n --reference-context \n Walk reference documentation as prompt input\n --yes / --no-confirm Bypass pre-flight cost-estimate confirmation prompt\n list-extraction-sources:\n --output Write manifest to file instead of stdout\n init:\n --observe Enable observability (per ADR-20)\n mcp (default; no subcommand):\n --observe Per-session observability override\n\nSee https://github.com/traviswye/ContextAtlas for full documentation\nand architectural decision records."; export declare function parseArgs(argv: readonly string[]): ParsedArgs; //# sourceMappingURL=cli-args.d.ts.map