feat(cli): wire up all commands in commander entrypoint

This commit is contained in:
chahinebrini 2026-06-24 23:46:29 +02:00
parent 5adaaad216
commit abab656969
2 changed files with 129 additions and 0 deletions

125
src/cli/index.ts Normal file
View File

@ -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 <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>', '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;
}

4
src/index.ts Normal file
View File

@ -0,0 +1,4 @@
import { createProgram } from './cli/index.js';
const program = createProgram(process.cwd());
program.parse();