/** * CLI JSON output wrapper — Sprint 2 . * * Provides a shared `withJsonOutput` helper for all CLI commands that adds * `--output json` support returning the standard ForgeResponse envelope. * * Usage pattern: * * subcommand * .option("--output ", "Output format: json | text (default: text)") * .action(async (opts) => { * await withJsonOutput("forge gate status", params, opts, async () => { * const data = await client.get(...); * renderHumanOutput(data); * return data; * }); * }); * * Contract: * - The handler fn returns the raw data for envelope wrapping. * - When `--output json` is active, human-readable rendering is suppressed; * callers should guard with `if (!useJson) { console.log(...) }`. * - Exit code semantics: 0 = ok, 1 = error, 2 = blocked. * - All ANSI codes are stripped from JSON output. * * Design: single import covers the entire output contract — callers never * import buildEnvelope or buildErrorEnvelope directly when using this helper. */ import type { NextAction } from "../shared/types.js"; export interface JsonOutputOptions { output?: string; /** Legacy --json flag support (deprecated, prefer --output json). */ json?: boolean; } /** * Determine whether structured JSON output (envelope) is requested. * Checks both `--output json` (new) and `--json` (legacy). */ export declare function isJsonOutput(opts: JsonOutputOptions): boolean; /** * Run an async CLI action and wrap its result in a ForgeResponse envelope * when `--output json` is active. * * @param command Human-readable command name (e.g. "forge gate status"). * @param params Parameters dict used for idempotency token computation. * @param opts Commander options object — checked for --output / --json. * @param fn Async function that performs the actual work. * MUST return the data object to be enveloped. * Should only call console.log when !isJsonOutput(opts). * @param nextActions Optional explicit next_actions to include in the envelope. */ export declare function withJsonOutput(command: string, params: Record, opts: JsonOutputOptions, fn: () => Promise, nextActions?: NextAction[]): Promise; //# sourceMappingURL=json-output.d.ts.map