#!/usr/bin/env node import { Command } from 'commander'; import * as fs from 'fs'; import * as path from 'path'; // Import our modules import { todozi, Todozi, healthCheck, VERSION, Commands, isCommandType, createCommand, CommandExecutionError, TodoziError } from './index.js'; // CLI setup const program = new Command(); program .name('todozi') .description('Todozi - AI-powered task and knowledge management system') .version(VERSION); // Health check command program .command('health') .description('Check system health') .action(() => { const health = healthCheck(); console.log(`Status: ${health.status.toUpperCase()}`); console.log(`Version: ${health.version}`); console.log(`Timestamp: ${health.timestamp}`); console.log('\nComponents:'); Object.entries(health.components).forEach(([component, healthy]) => { console.log(` ${component}: ${healthy ? '✓' : '✗'}`); }); if (health.status === 'unhealthy') { process.exit(1); } }); // Initialize command program .command('init') .description('Initialize Todozi system') .option('--path ', 'Storage path', './todozi_data') .action(async (options) => { try { console.log('Initializing Todozi...'); // Create storage directory if (!fs.existsSync(options.path)) { fs.mkdirSync(options.path, { recursive: true }); console.log(`Created storage directory: ${options.path}`); } // Initialize the system await todozi.initialize(); console.log('✓ Todozi initialized successfully'); // Create some sample data if requested if (process.argv.includes('--sample')) { console.log('Creating sample data...'); // Add sample tasks, etc. } } catch (error) { console.error('Failed to initialize Todozi:', error); process.exit(1); } }); // Task management commands const taskCmd = program .command('task') .description('Task management commands'); taskCmd .command('add ') .description('Add a new task') .option('-p, --priority ', 'Priority (low|medium|high|urgent)', 'medium') .option('-t, --time