HHerdr HandbookUbuntu
HERDR HANDBOOK · VI

Automation & Orchestration

Đi từ lệnh CLI đơn lẻ đến Bash + jq để tạo pane, start agent, gửi prompt, chờ trạng thái và đọc kết quả.

1. Ba primitives của automation

Primitive Trách nhiệm
Layout Workspace, tab, topology của panes
Pane Run command, gửi input, đọc output, wait output
Agent Điều khiển coding agent bằng identity + lifecycle state

2. Tận dụng JSON output

Phần lớn CLI commands trả JSON để script lấy ID ổn định. Cài jq:

sudo apt update && sudo apt install -y jq

3. Tạo pane và chạy process

split=$(herdr pane split --current --direction right --no-focus)
pane=$(printf '%s
' "$split" | jq -r '.result.pane.pane_id')

herdr pane run "$pane" "npm test"
herdr pane read "$pane" --source recent-unwrapped --lines 100

4. Tạo helper agent

herdr agent start reviewer --kind codex --pane "$pane"
herdr agent prompt reviewer "Review the current diff" --wait --timeout 120000
herdr agent read reviewer --source recent-unwrapped --lines 120

5. Script mẫu coder → reviewer

Ví dụ tối giản:

#!/usr/bin/env bash
set -euo pipefail

split=$(herdr pane split --current --direction right --no-focus)
review_pane=$(printf '%s
' "$split" | jq -r '.result.pane.pane_id')

herdr agent start reviewer --kind codex --pane "$review_pane"
herdr agent prompt reviewer   "Review the current git diff. Report critical issues first."   --wait --timeout 120000
herdr agent read reviewer --source recent-unwrapped --lines 120

6. Nguyên tắc automation

Luôn lấy ID từ response
Không hardcode pane/workspace IDs nếu script có thể lấy từ JSON response.