diff --git a/src/bin/cw.ts b/src/bin/cw.ts index 3dd8e0f..d78f09f 100644 --- a/src/bin/cw.ts +++ b/src/bin/cw.ts @@ -1,8 +1,26 @@ #!/usr/bin/env node /** * Codewalk District CLI Entry Point + * + * Users can install globally via: + * - npm link (during development) + * - npm i -g codewalk-district (for release) */ -import { VERSION } from '../index.js'; +import { createCli } from '../cli/index.js'; -console.log(`cw cli v${VERSION}`); +const program = createCli(); + +// Handle uncaught errors gracefully +process.on('uncaughtException', (error) => { + console.error('Fatal error:', error.message); + process.exit(1); +}); + +process.on('unhandledRejection', (reason) => { + console.error('Unhandled promise rejection:', reason); + process.exit(1); +}); + +// Parse command line arguments +program.parse(process.argv); diff --git a/src/cli/index.ts b/src/cli/index.ts new file mode 100644 index 0000000..1d2592e --- /dev/null +++ b/src/cli/index.ts @@ -0,0 +1,46 @@ +/** + * Codewalk District CLI + * + * Commander-based CLI with help system and version display. + */ + +import { Command } from 'commander'; +import { VERSION } from '../index.js'; + +/** + * Creates and configures the CLI program. + * + * @returns Configured Commander program ready for parsing + */ +export function createCli(): Command { + const program = new Command(); + + program + .name('cw') + .description('Multi-agent workspace for orchestrating multiple Claude Code agents') + .version(VERSION, '-v, --version', 'Display version number'); + + // Placeholder commands - will be implemented in later phases + program + .command('status') + .description('Show workspace status') + .action(() => { + console.log('cw status: not implemented'); + }); + + program + .command('agent') + .description('Manage agents') + .action(() => { + console.log('cw agent: not implemented'); + }); + + program + .command('task') + .description('Manage tasks') + .action(() => { + console.log('cw task: not implemented'); + }); + + return program; +}