diff --git a/agentydragon/README.md b/agentydragon/README.md index 9045458e0a..5dea20ef97 100644 --- a/agentydragon/README.md +++ b/agentydragon/README.md @@ -61,14 +61,14 @@ Tasks live under `agentydragon/tasks/` as individual Markdown files. Please upda - `agentydragon/tasks/.worktrees/-` off the `agentydragon` branch. - With `--agent`, after setup it launches the Developer Codex agent in that workspace (using `prompts/developer.md` and the task file), - and when the developer agent exits, it automatically runs the Commit agent helper to stage fixes and commit the work. -- **Commit agent helper**: in `agentydragon/tasks/`, run: -- -- ```sh -- # Generate and apply commit for completed task in its worktree: -- agentydragon/tasks/launch-commit-agent.sh -- ``` -- --After the Developer agent finishes and updates the task file, the Commit agent will emit the commit message on stdout. An external orchestrator will then stage files, run pre-commit hooks, and perform the actual `git commit`. You do not need to run `git commit` manually. +**Commit agent helper**: in `agentydragon/tasks/`, run: + +```sh +# Generate and apply commit(s) for completed task(s) in their worktrees: +agentydragon/tasks/launch-commit-agent.sh [...] +``` + +After the Developer agent finishes and updates the task file, the Commit agent will emit the commit message on stdout. An external orchestrator will then stage files, run pre-commit hooks, and perform the actual `git commit`. You do not need to run `git commit` manually. --- diff --git a/agentydragon/tasks/launch-commit-agent.sh b/agentydragon/tasks/launch-commit-agent.sh old mode 100644 new mode 100755 index 091d302015..c0dd63f8fa --- a/agentydragon/tasks/launch-commit-agent.sh +++ b/agentydragon/tasks/launch-commit-agent.sh @@ -9,59 +9,57 @@ set -euo pipefail -# Accept either a two-digit task ID or full slug (NN-slug) -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " >&2 +# Usage: one or more task IDs or slugs +if [ "$#" -lt 1 ]; then + echo "Usage: $0 [...]" >&2 exit 1 fi -input="$1" -# Locate repository and directories +# Locate repository and tasks directory; commit prompt is constant repo_root=$(git rev-parse --show-toplevel) tasks_dir="$repo_root/agentydragon/tasks" +prompt_file="$repo_root/agentydragon/prompts/commit.md" -# Resolve numeric ID to full slug if needed -if [[ "$input" =~ ^[0-9]{2}$ ]]; then - matches=("$tasks_dir/${input}-"*.md) - if [ "${#matches[@]}" -eq 1 ]; then - task_slug="$(basename "${matches[0]}" .md)" - echo "Resolved task ID '$input' to slug '$task_slug'" +for input in "$@"; do + # Resolve numeric ID to full slug if needed + if [[ "$input" =~ ^[0-9]{2}$ ]]; then + matches=("$tasks_dir/${input}-"*.md) + if [ "${#matches[@]}" -eq 1 ]; then + task_slug="$(basename "${matches[0]}" .md)" + echo "Resolved task ID '$input' to slug '$task_slug'" + else + echo "Error: expected exactly one task file matching '${input}-*.md', found ${#matches[@]}" >&2 + exit 1 + fi else - echo "Error: expected exactly one task file matching '${input}-*.md', found ${#matches[@]}" >&2 + task_slug="$input" + fi + + # Paths for worktree and task file + worktrees_dir="$tasks_dir/.worktrees" + worktree_path="$worktrees_dir/$task_slug" + task_file="$tasks_dir/$task_slug.md" + + # Preconditions + if [ ! -d "$worktree_path" ]; then + echo "Error: worktree for '$task_slug' not found; run create-task-worktree.sh first" >&2 + exit 1 + fi + if [ ! -f "$prompt_file" ]; then + echo "Error: commit prompt not found at $prompt_file" >&2 + exit 1 + fi + if [ ! -f "$task_file" ]; then + echo "Error: task file not found at $task_file" >&2 exit 1 fi -else - task_slug="$input" -fi -# Paths for worktree and prompt/task files -worktrees_dir="$tasks_dir/.worktrees" -worktree_path="$worktrees_dir/$task_slug" -prompt_file="$repo_root/agentydragon/prompts/commit.md" -task_file="$tasks_dir/$task_slug.md" - -# Verify worktree exists -if [ ! -d "$worktree_path" ]; then - echo "Error: worktree for '$task_slug' not found; run create-task-worktree.sh first" >&2 - exit 1 -fi - -# Verify prompt and task files exist -if [ ! -f "$prompt_file" ]; then - echo "Error: commit prompt not found at $prompt_file" >&2 - exit 1 -fi -if [ ! -f "$task_file" ]; then - echo "Error: task file not found at $task_file" >&2 - exit 1 -fi - -# Change to the task worktree and invoke Codex in non-interactive mode -cd "$worktree_path" -# Invoke the Commit agent and pipe its output into git commit -cmd=(codex --full-auto exec) -echo "Running: ${cmd[*]}" -message=$("${cmd[@]}" "$(<"$prompt_file")"$'\n\n'"$(<"$task_file")") -# Stage all changes and commit with generated message -git add -u -git commit -m "$message" + # Perform commit in the task worktree + echo "--- Processing task $task_slug ---" + cd "$worktree_path" + cmd=(codex --full-auto exec) + echo "Running: ${cmd[*]}" + message=$("${cmd[@]}" "$(<"$prompt_file")"$'\n\n'"$(<"$task_file")") + git add -u + git commit -m "$message" +done