"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMetadataValidateUpdateCommand = createMetadataValidateUpdateCommand;
const runtime_contract_1 = require("../../../lib/runtime/runtime-contract");
const metadata_update_operation_1 = require("../metadata-update-operation");
async function createMetadataValidateUpdateCommand() {
    const { Command } = await import("commander");
    const command = new Command("validate-update");
    command
        .description("Run helper-backed metadata update validation as a no-write evidence surface without writing files.")
        .requiredOption("--artifact <path>", "Repository-relative artifact path to validate.")
        .option("--active-artifact <path>", "Repository-relative active artifact path expected by the current handoff.")
        .option("--field <key=value>", "Direct intended metadata update. Repeat for multiple fields.", collectFieldAssignment, [])
        .action((_, commandInstance) => {
        const repositoryContext = (0, runtime_contract_1.createRepositoryContext)((0, runtime_contract_1.detectRepositoryRoot)(), false);
        (0, metadata_update_operation_1.executeMetadataUpdateOperation)({
            commandName: "metadata validate-update",
            write: false,
            commandInstance,
            repositoryRoot: repositoryContext.root,
            detectionSource: repositoryContext.detectionSource
        });
    });
    return command;
}
function collectFieldAssignment(value, previous) {
    previous.push(value);
    return previous;
}
