#!/usr/bin/env node
const { spawn } = require('child_process')
const path = require('path')
const fs = require('fs')

const binary = process.platform === 'win32' ? 'tfcode.exe' : 'tfcode'
const binaryPath = path.join(__dirname, binary)

if (!fs.existsSync(binaryPath)) {
  console.error('tfcode binary not found. Run: npm install @toothfairyai/tfcode')
  process.exit(1)
}

const child = spawn(binaryPath, process.argv.slice(2), {
  stdio: 'inherit',
  env: process.env
})

child.on('exit', (code) => process.exit(code || 0))
