介绍
# Perry Coding Agents
将任务分派到 Perry 工作区的 OpenCode/Claude Code。
## 规则 - **务必首先创建 dex 任务** — 在任何分派之前,无一例外 - **无硬性超时** — 后台分派,让 agent 运行 - **使用 IP** — 容器中 MagicDNS 不可用(用 `tailscale status` 获取 IP) - **每个 PR 一个任务** — 同一会话持续直至完成 - **复用会话** — OpenCode 在 `~/.opencode/` 中保持上下文 - **切勿直接编码** — 始终分派给 agents
## 命令 ```bash # OpenCode (primary) ssh -o StrictHostKeyChecking=no workspace@<IP> "cd ~/<project> && /home/workspace/.opencode/bin/opencode run 'task'" &
# Claude Code (needs TTY) ssh -t workspace@<IP> "cd ~/<project> && /home/workspace/.local/bin/claude 'task'" ```
## 分派模式 ```bash WAKE_IP=$(tailscale status --self --json | jq -r '.Self.TailscaleIPs[0]')
ssh -o StrictHostKeyChecking=no workspace@<IP> "cd ~/<project> && /home/workspace/.opencode/bin/opencode run 'Your task.
When done: curl -X POST http://${WAKE_IP}:18789/hooks/wake -H \"Content-Type: application/json\" -H \"Authorization: Bearer <hooks-token>\" -d \"{\\\"text\\\": \\\"Done: summary\\\", \\\"mode\\\": \\\"now\\\"}\" '" & ```
## 任务追踪 在分派前创建任务,包含:工作区 IP、分支、目标、完成标准。 同一任务直到 CI 变绿。完成后附结果摘要。
## 示例:完整 PR 流程
```bash # 1. Create task # Track: workspace feat1 (100.109.173.45), branch feat/auth, goal: add auth
# 2. Get wake info WAKE_IP=$(tailscale status --self --json | jq -r '.Self.TailscaleIPs[0]')
# 3. Dispatch (background, no timeout) ssh -o StrictHostKeyChecking=no [email protected] "cd ~/perry && /home/workspace/.opencode/bin/opencode run 'Add bearer token auth to all API endpoints. Create PR when done.
When finished: curl -X POST http://${WAKE_IP}:18789/hooks/wake -H \"Content-Type: application/json\" -H \"Authorization: Bearer <token>\" -d \"{\\\"text\\\": \\\"Done: Auth PR created\\\", \\\"mode\\\": \\\"now\\\"}\" '" &
# 4. Wake received → check CI ssh [email protected] "cd ~/perry && gh pr checks 145"
# 5. CI fails → dispatch follow-up (same task, agent has context) ssh -o StrictHostKeyChecking=no [email protected] "cd ~/perry && /home/workspace/.opencode/bin/opencode run 'CI failing: test/auth.test.ts line 42. Fix and push.
When fixed: curl -X POST http://${WAKE_IP}:18789/hooks/wake ...'" &
# 6. CI green → complete task with result ```
## 故障排除 - **无法连接**:`tailscale status | grep <name>` - **命令未找到**:使用完整路径(`/home/workspace/.opencode/bin/opencode`) - **唤醒未触发**:检查 IP/token,用 curl 测试