The missing autonomy step: an implementer no longer needs a human prompt
per task. `agenthub work --agent <name> --role <role>` announces, then:
- claims an already-open task addressed to the agent immediately, or
- blocks on the SSE stream until one appears (newly delegated OR
reopened after review), then claims + prints it.
Loop: work → implement → `task review` → work. New/reopened tasks are
picked up automatically; run it in the background so the wait doesn't tie
up the turn.
- src/cli/commands/start.ts: extracted announceAgent / findAddressedOpenTask
/ claimAndPrintTask (shared by start + work); addressed-match now also
covers assignedTo (reopened tasks coming back for rework).
- src/cli/commands/work.ts: wait-and-claim via /events, with a gap-close
re-check after subscribing and an optional --timeout.
- index.ts: `agenthub work` command.
- templates: implementer guides lead with `work` (the autonomous loop),
keep `start` as the one-shot.
- tests: immediate claim (local) + wait-then-claim (server SSE). 119/119.
Bump 0.3.1 -> 0.4.0.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
79 lines
3.5 KiB
TypeScript
79 lines
3.5 KiB
TypeScript
export function agentsMd(projectName: string): string {
|
|
return `# AgentHub — ${projectName}
|
|
|
|
This project coordinates multiple AI agents via AgentHub. The hub server runs on
|
|
the team's hub machine; you connect **automatically** (the project config's
|
|
\`serverUrl\`, or LAN auto-discovery) — no manual setup, no \`--server\` flag.
|
|
|
|
## Start here
|
|
**If you are an implementer, RUN this on your first turn (don't just read it):**
|
|
\`agenthub start --agent <you> --role implementer\` — it announces you, claims the
|
|
task addressed to you, and prints it + its handoff so you can begin immediately.
|
|
|
|
## Golden rules (every agent)
|
|
1. Announce yourself on start (\`agenthub start …\`, or \`agenthub hello --agent <you> --role <your-role>\`).
|
|
2. Read \`.agenthub/status/latest.md\` and the handoff(s) for your task first.
|
|
3. **Only the architect marks a task \`done\`.** Implementers submit finished work
|
|
with \`agenthub task review <id>\` — never \`agenthub task done\`.
|
|
4. Report results as memory: \`agenthub memory add --title "<TSK> result" --content "…"\`.
|
|
5. Never delete or overwrite files in \`.agenthub/\` unless explicitly asked.
|
|
|
|
Drive the AgentHub CLI yourself — the human does not type these commands for you.
|
|
`;
|
|
}
|
|
|
|
export function claudeMd(): string {
|
|
return `# Claude Code — AgentHub role: architect
|
|
|
|
Read \`AGENTS.md\` first. You are the **architect**: you delegate work and you hold
|
|
final say. Implementers cannot close their own tasks.
|
|
|
|
On start: \`agenthub hello --agent <you> --role architect\`, then \`agenthub watch\`.
|
|
|
|
- **Delegate:** \`agenthub task create --role implementer …\` + \`agenthub handoff create
|
|
--toRole implementer …\` with scope + acceptance criteria.
|
|
- **Review gate — only you close tasks.** When the stream shows
|
|
\`AgentHub: Task review … by <agent>\`, inspect the work + its memory, then:
|
|
- Satisfied → \`agenthub task done <id>\`.
|
|
- Not satisfied → \`agenthub task reopen <id>\` + a feedback handoff (what to fix).
|
|
- Record architecture choices: \`agenthub decision create\`.
|
|
`;
|
|
}
|
|
|
|
function implementerMd(cliName: string, agentName: string, roles: string): string {
|
|
return `# ${cliName} — AgentHub roles: ${roles}
|
|
|
|
**On your first turn, RUN this and follow its output — do not just summarize:**
|
|
|
|
\`\`\`
|
|
agenthub work --agent ${agentName} --role implementer
|
|
\`\`\`
|
|
|
|
\`work\` waits until a task addressed to you is ready (newly delegated OR reopened
|
|
after review), claims it, and prints the task + its handoff. Then:
|
|
|
|
1. Implement the task.
|
|
2. **Submit for review (NOT done):** \`agenthub task review <id>\`
|
|
and report: \`agenthub memory add --title "<id> result" --category implementation
|
|
--content "<what you did / how to verify it>"\`
|
|
3. **Run \`agenthub work --agent ${agentName} --role implementer\` again** — it blocks
|
|
until your next task (or a reopened one) is ready, then auto-claims it. This is
|
|
the loop: work → implement → review → work. Run it in the background so the wait
|
|
doesn't tie up your turn.
|
|
|
|
(\`agenthub start --agent ${agentName} --role implementer\` is the one-shot variant:
|
|
it claims an already-open task but does not wait.)
|
|
|
|
⚠️ NEVER run \`agenthub task done\` — only the architect approves and closes tasks.
|
|
You drive the AgentHub CLI yourself; the human does not type these commands for you.
|
|
`;
|
|
}
|
|
|
|
export function codexMd(): string {
|
|
return implementerMd('Codex CLI', 'codex', 'implementer, tester');
|
|
}
|
|
|
|
export function kimiMd(): string {
|
|
return implementerMd('Kimi Code CLI', 'kimi', 'implementer');
|
|
}
|