This commit is contained in:
Rai (Michael Pokorny)
2025-06-25 01:40:26 -07:00
parent 9bf7f28b31
commit 6a660f616e
2 changed files with 52 additions and 54 deletions

View File

@@ -61,14 +61,14 @@ Tasks live under `agentydragon/tasks/` as individual Markdown files. Please upda
- `agentydragon/tasks/.worktrees/<task-id>-<task-slug>` 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 <task-slug|NN>
- ```
-
-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 <task-slug|NN> [<task-slug|NN>...]
```
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.
---

90
agentydragon/tasks/launch-commit-agent.sh Normal file → Executable file
View File

@@ -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 <task-slug|NN>" >&2
# Usage: one or more task IDs or slugs
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <task-slug|NN> [<task-slug|NN>...]" >&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