#!/usr/bin/env node

const { execSync } = require("child_process");
const path = require("path");

const args = process.argv.slice(2);
const scriptDir = path.join(__dirname, "..");
const initScript = path.join(scriptDir, "mk-init.sh");

if (args[0] === "init") {
  const passArgs = args.slice(1).join(" ");
  try {
    execSync(`bash "${initScript}" ${passArgs}`, {
      stdio: "inherit",
      cwd: process.cwd(),
    });
  } catch (e) {
    process.exit(e.status || 1);
  }
} else {
  console.log(`my-agent-kit — AI coding agent kit

Usage:
  my-agent-kit init [target-dir] [options]

Options:
  --dry-run          Preview what will be copied
  --force            Overwrite existing .claude/
  --upgrade          Clean upgrade — drop deleted paths before copy
  --skills-install   Install Python skill dependencies
  --copilot          Generate .github/copilot-instructions.md
  --codex            Generate .codex/ + .agents/skills/ for Codex CLI
  --all              Enable all cross-tool configs

Examples:
  npx my-agent-kit init                    # Install into current directory
  npx my-agent-kit init ./my-project       # Install into specific project
  npx my-agent-kit init . --all            # With Copilot + Codex support
  npx my-agent-kit init . --upgrade --force # Clean upgrade existing install
  npx my-agent-kit init . --dry-run        # Preview first`);
}
