From abab656969fdabc529785708992a6218a1d018d9 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Wed, 24 Jun 2026 23:46:29 +0200 Subject: [PATCH] feat(cli): wire up all commands in commander entrypoint --- src/cli/index.ts | 125 +++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 4 ++ 2 files changed, 129 insertions(+) create mode 100644 src/cli/index.ts create mode 100644 src/index.ts diff --git a/src/cli/index.ts b/src/cli/index.ts new file mode 100644 index 0000000..1d67a75 --- /dev/null +++ b/src/cli/index.ts @@ -0,0 +1,125 @@ +import { Command } from 'commander'; +import { init } from './commands/init.js'; +import { status } from './commands/status.js'; +import { memoryAdd, memorySearch, memoryList } from './commands/memory.js'; +import { taskCreate, taskList, taskShow, taskClaim, taskDone } from './commands/task.js'; +import { handoffCreate, handoffRead, handoffList } from './commands/handoff.js'; +import { decisionCreate, decisionList } from './commands/decision.js'; +import { delegate } from './commands/delegate.js'; +import { serverStart } from './commands/server.js'; + +export function createProgram(cwd: string): Command { + const program = new Command('agenthub') + .description('Local coordination layer for AI coding agents') + .version('0.1.0'); + + program + .command('init') + .description('Initialize AgentHub in the current directory') + .option('-n, --project-name ', 'Project name') + .option('-y, --yes', 'Use defaults without prompts') + .action((options) => init(cwd, options)); + + program + .command('status') + .description('Show project status') + .option('-u, --update', 'Regenerate status before showing') + .action((options) => status(cwd, options)); + + const memoryCmd = new Command('memory').description('Manage memory entries'); + memoryCmd + .command('add') + .description('Add a memory entry') + .option('--title ', 'Title') + .option('--category <category>', 'Category') + .option('--content <content>', 'Content') + .action((options) => memoryAdd(cwd, options)); + memoryCmd + .command('search <query>') + .description('Search memory and tasks') + .action((query) => memorySearch(cwd, query)); + memoryCmd + .command('list') + .description('List memory entries') + .action(() => memoryList(cwd)); + program.addCommand(memoryCmd); + + const taskCmd = new Command('task').description('Manage tasks'); + taskCmd + .command('create') + .description('Create a task') + .option('--title <title>', 'Title') + .option('--role <role>', 'Role') + .option('--priority <priority>', 'Priority') + .action((options) => taskCreate(cwd, options)); + taskCmd + .command('list') + .description('List tasks') + .option('--status <status>', 'Filter by status') + .option('--role <role>', 'Filter by role') + .action((options) => taskList(cwd, options)); + taskCmd + .command('show <id>') + .description('Show a task') + .action((id) => taskShow(cwd, id)); + taskCmd + .command('claim <id>') + .description('Claim a task') + .requiredOption('--agent <agent>', 'Agent name') + .action((id, options) => taskClaim(cwd, id, options.agent)); + taskCmd + .command('done <id>') + .description('Mark task as done') + .action((id) => taskDone(cwd, id)); + program.addCommand(taskCmd); + + const handoffCmd = new Command('handoff').description('Manage handoffs'); + handoffCmd + .command('create') + .description('Create a handoff') + .option('--fromRole <role>', 'From role') + .option('--toRole <role>', 'To role') + .option('--taskId <id>', 'Related task id') + .option('--summary <summary>', 'Summary') + .option('--context <context>', 'Context') + .action((options) => handoffCreate(cwd, options)); + handoffCmd + .command('read <id>') + .description('Read a handoff') + .action((id) => handoffRead(cwd, id)); + handoffCmd + .command('list') + .description('List handoffs') + .action(() => handoffList(cwd)); + program.addCommand(handoffCmd); + + const decisionCmd = new Command('decision').description('Manage decisions'); + decisionCmd + .command('create') + .description('Create a decision record') + .option('--title <title>', 'Title') + .option('--context <context>', 'Context') + .option('--decision <decision>', 'Decision') + .action((options) => decisionCreate(cwd, options)); + decisionCmd + .command('list') + .description('List decisions') + .action(() => decisionList(cwd)); + program.addCommand(decisionCmd); + + program + .command('delegate') + .description('Suggest or auto-delegate open tasks') + .option('--auto', 'Create handoff automatically') + .action((options) => delegate(cwd, options)); + + const serverCmd = new Command('server').description('Optional local API server'); + serverCmd + .command('start') + .description('Start the optional AgentHub API server') + .option('-p, --port <port>', 'Port', '3377') + .action((options) => serverStart(cwd, { port: parseInt(options.port, 10) })); + program.addCommand(serverCmd); + + return program; +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..9b6e811 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,4 @@ +import { createProgram } from './cli/index.js'; + +const program = createProgram(process.cwd()); +program.parse();