feat(12-06): add plan CLI commands and architect decompose command
Add CLI commands for plan management: - cw plan list --phase <id>: List plans in a phase - cw plan create --phase <id> --name <name>: Create a plan - cw plan get <id>: Get plan details - cw plan tasks <id>: List tasks in a plan Add architect decompose command: - cw architect decompose <planId>: Spawn agent to decompose plan into tasks
This commit is contained in:
116
src/cli/index.ts
116
src/cli/index.ts
@@ -800,6 +800,122 @@ export function createCli(serverHandler?: (port?: number) => Promise<void>): Com
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// cw architect decompose <plan-id>
|
||||||
|
architectCommand
|
||||||
|
.command('decompose <planId>')
|
||||||
|
.description('Decompose a plan into tasks')
|
||||||
|
.requiredOption('--name <name>', 'Agent name')
|
||||||
|
.option('-c, --context <context>', 'Additional context')
|
||||||
|
.action(async (planId: string, options: { name: string; context?: string }) => {
|
||||||
|
try {
|
||||||
|
const client = createDefaultTrpcClient();
|
||||||
|
const agent = await client.spawnArchitectDecompose.mutate({
|
||||||
|
name: options.name,
|
||||||
|
planId,
|
||||||
|
context: options.context,
|
||||||
|
});
|
||||||
|
console.log(`Started architect agent in decompose mode`);
|
||||||
|
console.log(` Agent: ${agent.name} (${agent.id})`);
|
||||||
|
console.log(` Mode: ${agent.mode}`);
|
||||||
|
console.log(` Plan: ${planId}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to start decompose:', (error as Error).message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Plan command group
|
||||||
|
const planCommand = program
|
||||||
|
.command('plan')
|
||||||
|
.description('Plan management');
|
||||||
|
|
||||||
|
// cw plan list --phase <phaseId>
|
||||||
|
planCommand
|
||||||
|
.command('list')
|
||||||
|
.description('List plans in a phase')
|
||||||
|
.requiredOption('--phase <id>', 'Phase ID')
|
||||||
|
.action(async (options: { phase: string }) => {
|
||||||
|
try {
|
||||||
|
const client = createDefaultTrpcClient();
|
||||||
|
const plans = await client.listPlans.query({ phaseId: options.phase });
|
||||||
|
if (plans.length === 0) {
|
||||||
|
console.log('No plans found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.table(plans.map(p => ({
|
||||||
|
id: p.id,
|
||||||
|
number: p.number,
|
||||||
|
name: p.name,
|
||||||
|
status: p.status,
|
||||||
|
})));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to list plans:', (error as Error).message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// cw plan create --phase <phaseId> --name <name>
|
||||||
|
planCommand
|
||||||
|
.command('create')
|
||||||
|
.description('Create a plan in a phase')
|
||||||
|
.requiredOption('--phase <id>', 'Phase ID')
|
||||||
|
.requiredOption('--name <name>', 'Plan name')
|
||||||
|
.option('--description <desc>', 'Plan description')
|
||||||
|
.action(async (options: { phase: string; name: string; description?: string }) => {
|
||||||
|
try {
|
||||||
|
const client = createDefaultTrpcClient();
|
||||||
|
const plan = await client.createPlan.mutate({
|
||||||
|
phaseId: options.phase,
|
||||||
|
name: options.name,
|
||||||
|
description: options.description,
|
||||||
|
});
|
||||||
|
console.log(`Created plan: ${plan.id} (${plan.name})`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to create plan:', (error as Error).message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// cw plan get <id>
|
||||||
|
planCommand
|
||||||
|
.command('get <id>')
|
||||||
|
.description('Get plan details')
|
||||||
|
.action(async (id: string) => {
|
||||||
|
try {
|
||||||
|
const client = createDefaultTrpcClient();
|
||||||
|
const plan = await client.getPlan.query({ id });
|
||||||
|
console.log(JSON.stringify(plan, null, 2));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to get plan:', (error as Error).message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// cw plan tasks <id>
|
||||||
|
planCommand
|
||||||
|
.command('tasks <id>')
|
||||||
|
.description('List tasks in a plan')
|
||||||
|
.action(async (id: string) => {
|
||||||
|
try {
|
||||||
|
const client = createDefaultTrpcClient();
|
||||||
|
const tasks = await client.listTasks.query({ planId: id });
|
||||||
|
if (tasks.length === 0) {
|
||||||
|
console.log('No tasks found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.table(tasks.map(t => ({
|
||||||
|
id: t.id,
|
||||||
|
order: t.order,
|
||||||
|
name: t.name,
|
||||||
|
type: t.type,
|
||||||
|
status: t.status,
|
||||||
|
})));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to list tasks:', (error as Error).message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user