#!/usr/bin/env node

import { existsSync } from "node:fs"
import { dirname, resolve } from "node:path"
import { fileURLToPath, pathToFileURL } from "node:url"

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..")
const cli = resolve(root, "dist", "src", "cli", "index.js")

if (!existsSync(cli)) {
  console.error("seed-agent CLI is not built yet. Run `npm run build` from the package root first.")
  process.exit(1)
}

const { runCli } = await import(pathToFileURL(cli).href)
const exitCode = await runCli(process.argv.slice(2))
process.exit(exitCode)
