"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAboutCommand = createAboutCommand;
const errors_1 = require("../../lib/errors");
const output_1 = require("../../lib/output");
const runtime_contract_1 = require("../../lib/runtime/runtime-contract");
const automation_protocol_1 = require("../../lib/automation-protocol");
async function createAboutCommand() {
    const { Command } = await import("commander");
    const command = new Command("about");
    command
        .description("Show compact runtime, command registry, helper, format, and exit-code discovery.")
        .action((_, commandInstance) => {
        const format = (0, output_1.resolveOutputFormat)(commandInstance.optsWithGlobals().format);
        if (format === null) {
            throw (0, errors_1.createUnsupportedOutputFormatError)({
                received: commandInstance.optsWithGlobals().format,
                commandBoundary: "about command output format"
            });
        }
        const runtimeDetails = (0, runtime_contract_1.getRuntimeContractDetails)();
        (0, output_1.emitSuccess)({
            command: "about",
            format,
            text: (0, runtime_contract_1.renderRuntimeContractSummary)(),
            data: {
                automationProtocol: (0, automation_protocol_1.getAutomationProtocolFeatureManifest)(),
                cli: {
                    name: runtime_contract_1.CLI_NAME,
                    description: runtime_contract_1.CLI_DESCRIPTION
                },
                runtime: {
                    ...runtimeDetails.runtime
                },
                release: runtimeDetails.release,
                output: {
                    defaultFormat: "text",
                    supportedFormats: ["text", "json"]
                },
                commandInventory: {
                    command: "commands inventory",
                    jsonExample: `${runtime_contract_1.CLI_NAME} --format json commands inventory`,
                    generatedFrom: [
                        "commander-tree",
                        "command-capability-registry"
                    ],
                    noWriteBoundary: "Use this read-only command for command-surface availability, write posture, selected-artifact requirements, callable status, registry-only entries, and mixed-posture family evidence."
                },
                exitCodes: {
                    success: 0,
                    warningsTreatedAsFailures: 1,
                    errorFindings: 2,
                    usageOrNonInteractiveFailure: 3,
                    unexpectedError: 4,
                    invalidConfig: 5
                }
            }
        });
    });
    return command;
}
