#!/usr/bin/env node
import { runM3IoSkillCommand } from "./src/m3-io-skill-client.mjs";

try {
  const result = await runM3IoSkillCommand(process.argv.slice(2));
  const pretty = process.argv.includes("--pretty");
  process.stdout.write(`${JSON.stringify(result, null, pretty ? 2 : 0)}\n`);
  process.exitCode = result.ok ? 0 : 2;
} catch (error) {
  process.stdout.write(`${JSON.stringify({
    ok: false,
    status: "failed",
    code: "skill_cli_failed",
    message: error instanceof Error ? error.message : String(error)
  })}\n`);
  process.exitCode = 1;
}
