feat(cli): add delegate command with suggest/auto mode
This commit is contained in:
parent
fed43e70ed
commit
d728c616d1
39
src/cli/commands/delegate.ts
Normal file
39
src/cli/commands/delegate.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { loadConfig } from '../../core/config.js';
|
||||
import { Index } from '../../core/index.js';
|
||||
import { handoffCreate } from './handoff.js';
|
||||
|
||||
export async function delegate(cwd: string, options: { auto?: boolean } = {}): Promise<void> {
|
||||
const config = loadConfig(cwd);
|
||||
const index = new Index(cwd);
|
||||
const openTasks = index.list('task', { status: 'open' });
|
||||
index.close();
|
||||
|
||||
if (openTasks.length === 0) {
|
||||
console.log('No open tasks to delegate.');
|
||||
return;
|
||||
}
|
||||
|
||||
const task = openTasks[0];
|
||||
const role = task.role ?? 'implementer';
|
||||
const preferredAgent = config.roles[role]?.preferredAgent ?? 'codex';
|
||||
|
||||
console.log('Suggested delegation:');
|
||||
console.log(` Task: ${task.id} — ${task.title}`);
|
||||
console.log(` Role: ${role}`);
|
||||
console.log(` Preferred agent: ${preferredAgent}`);
|
||||
|
||||
if (config.delegationMode === 'auto' || options.auto) {
|
||||
await handoffCreate(cwd, {
|
||||
fromRole: 'user',
|
||||
toRole: role,
|
||||
toAgent: preferredAgent,
|
||||
taskId: task.id,
|
||||
summary: `Delegate ${task.id} to ${role}`,
|
||||
context: `Task "${task.title}" should be handled by ${preferredAgent} in ${role} role.`,
|
||||
});
|
||||
console.log('Handoff created automatically.');
|
||||
} else {
|
||||
console.log('Run with --auto to create the handoff, or run:');
|
||||
console.log(` agenthub handoff create --taskId ${task.id}`);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user