import { loadConfig } from '../../core/config.js'; import { suggestDelegation, autoDelegate } from '../../core/services/delegateService.js'; export async function delegate(cwd: string, options: { auto?: boolean } = {}): Promise { const config = loadConfig(cwd); const suggestion = suggestDelegation(cwd); if (!suggestion) { console.log('No open tasks to delegate.'); return; } console.log('Suggested delegation:'); console.log(` Task: ${suggestion.task.id} — ${suggestion.task.title}`); console.log(` Role: ${suggestion.role}`); console.log(` Preferred agent: ${suggestion.preferredAgent}`); if (config.delegationMode === 'auto' || options.auto) { autoDelegate(cwd); console.log('AgentHub: Handoff created automatically'); } else { console.log('Run with --auto to create the handoff, or run:'); console.log(` agenthub handoff create --taskId ${suggestion.task.id}`); } }