#!/usr/bin/env node import { Command } from 'commander'; import chalk from 'chalk'; import { GroveApp } from './components/GroveApp.js'; import { loadConfig } from './utils/config.js'; import { setupWorktree } from './utils/git.js'; import type { CLIOptions } from './types/index.js'; const program = new Command(); program .name('grove') .description('Manage Claude Code sessions with git worktrees') .version('0.1.0') .argument('', 'Feature name for the worktree') .option('-l, --location ', 'Custom worktree location') .option('-p, --project ', 'Override project name') .option('-c, --continue', 'Continue existing worktree session') .action(async (feature: string, options: CLIOptions) => { try { // Load configuration const config = await loadConfig(); // Setup worktree const worktree = await setupWorktree(feature, { ...options, config }); // Start the Grove app const app = new GroveApp({ worktree, config }); // Wait for the app to exit await app.start(); } catch (error) { console.error(chalk.red('❌ Error:'), error instanceof Error ? error.message : String(error)); process.exit(1); } }); program.parse();