Skip to content

feat: add coordinator agent with subagent-based worker dispatch#420

Merged
Maleick merged 1 commit into
mainfrom
feat/autoship-coordinator
May 11, 2026
Merged

feat: add coordinator agent with subagent-based worker dispatch#420
Maleick merged 1 commit into
mainfrom
feat/autoship-coordinator

Conversation

@Maleick
Copy link
Copy Markdown
Owner

@Maleick Maleick commented May 11, 2026

Summary

  • Adds coordinator.sh hook — starts an OpenCode session that scans for QUEUED workspaces and spawns implementer subagents via the task tool
  • Adds autoship-coordinator skill defining the coordinator workflow
  • Each worker gets a task_id persisted in <workspace>/task_id for tracking and session-resume
  • Supports AUTOSHIP_COORDINATOR_MODEL env var for coordinator model selection
  • Configurable concurrency cap from config.json (max_workers / max_concurrent)
  • Call via bash hooks/opencode/coordinator.sh or set AUTOSHIP_COORDINATOR_MODE=true with existing runner.sh

How it works

The coordinator runs as an OpenCode agent that scans .autoship/workspaces/*/ for QUEUED workspaces and calls task(subagent_type=general, prompt=<prompt>) per workspace, replacing fire-and-forget background subshells with tracked subagents.

Adds the autoship-coordinator skill and coordinator.sh that uses
OpenCode's task tool to spawn general subagents per queued workspace.
Supports task_id tracking, resume via existing task_ids, and configurable
concurrency. Enable by calling coordinator.sh directly or via runner.sh
with AUTOSHIP_COORDINATOR_MODE=true.
Copilot AI review requested due to automatic review settings May 11, 2026 15:42
@Maleick Maleick merged commit 72be680 into main May 11, 2026
1 of 2 checks passed
@Maleick Maleick deleted the feat/autoship-coordinator branch May 11, 2026 15:43
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an AutoShip “coordinator” entrypoint intended to orchestrate queued workspaces by starting an OpenCode session that dispatches implementer subagents via the task tool, along with a skill document describing the coordinator workflow.

Changes:

  • Added hooks/opencode/coordinator.sh to scan for QUEUED workspaces, generate a coordinator prompt, and start an OpenCode run for coordination.
  • Added skills/autoship-coordinator/SKILL.md documenting the coordinator’s intended lifecycle, dispatch, and tracking behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
skills/autoship-coordinator/SKILL.md Adds a skill definition documenting the coordinator’s workflow and boundaries.
hooks/opencode/coordinator.sh Adds a new hook script to batch queued workspaces and start an OpenCode coordinator session.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

*) echo "Unknown: $1"; exit 1 ;;
esac
done

Comment on lines +40 to +45
# Resolve max concurrency
MAX_CONCURRENT=5
if [[ -f "$CONFIG_FILE" ]]; then
config_max=$(jq -r '.max_workers // .maxConcurrent // .max_concurrent // 5' "$CONFIG_FILE" 2>/dev/null || echo 5)
[[ "$config_max" =~ ^[0-9]+$ && "$config_max" -gt 0 ]] && MAX_CONCURRENT=$config_max
fi
Comment on lines +49 to +67
# Scan for QUEUED workspaces
queued=()
if [[ -d "$WORKSPACES_DIR" ]]; then
for ws_dir in "$WORKSPACES_DIR"/*/; do
[[ -d "$ws_dir" ]] || continue
s=$(tr -d '[:space:]' <"$ws_dir/status" 2>/dev/null || true)
[[ -f "$ws_dir/AUTOSHIP_PROMPT.md" && "$s" == "QUEUED" ]] && queued+=("$(basename "$ws_dir")")
done
fi

if [[ ${#queued[@]} -eq 0 ]]; then
log "No QUEUED workspaces. Exiting."
exit 0
fi

log "Found ${#queued[@]} QUEUED: ${queued[*]}"

batch=("${queued[@]:0:$MAX_CONCURRENT}")
[[ "$DRY_RUN" == "true" ]] && { log "DRY-RUN: would start for ${batch[*]}"; exit 0; }
Comment on lines +102 to +104
opencode run --model "$COORDINATOR_MODEL" "$(cat "$COORDINATOR_PROMPT")" 2>&1 | tee -a "$LOG_FILE"

coordinator_exit=$?
coordinator_exit=$?
log "Coordinator exited with code $coordinator_exit"

[[ "$ONCE" == "false" ]] && { log "Re-scanning..."; exec bash "$0" --once; }

echo ""
echo "Concurrency cap: $MAX_CONCURRENT"
echo "Spare multiple subagents concurrently by calling task multiple times in one message."
AUTOSHIP_DIR="${AUTOSHIP_DIR:-.autoship}"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
WORKSPACES_DIR="$REPO_ROOT/$AUTOSHIP_DIR/workspaces"
STATE_FILE="$REPO_ROOT/$AUTOSHIP_DIR/state.json"
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants