tasks: allow numeric ID only resolving to full slug

This commit is contained in:
Rai (Michael Pokorny)
2025-06-24 13:41:53 -07:00
parent 3fe8b3c5a9
commit 12dced2d53
2 changed files with 20 additions and 5 deletions

View File

@@ -28,7 +28,8 @@ Tasks live under `agentydragon/tasks/` as individual Markdown files. Please upda
- **Worktree helper**: in `agentydragon/tasks/`, run:
-
- ```sh
- create-task-worktree.sh [--agent] <task-id>-<task-slug>
- # Accept either a full slug (NN-slug) or just the two-digit task ID:
- create-task-worktree.sh [--agent] <task-slug|NN>
- ```
-
- Without `--agent`, this creates or reuses a worktree at

View File

@@ -30,13 +30,27 @@ if [ "$#" -ne 1 ]; then
exit 1
fi
task_slug="$1"
branch="agentydragon/$task_slug"
# Capture raw input so we can accept just a two-digit task ID
task_input="$1"
# Determine repository root
# Determine repository root and tasks directory
repo_root=$(git rev-parse --show-toplevel)
tasks_dir="$repo_root/agentydragon/tasks"
# If given only a two-digit ID, resolve to the full task slug
if [[ "$task_input" =~ ^[0-9]{2}$ ]]; then
matches=( "$tasks_dir/${task_input}-"*.md )
if [ "${#matches[@]}" -eq 1 ]; then
task_slug="$(basename "${matches[0]}" .md)"
echo "Resolved task ID '$task_input' to slug '$task_slug'"
else
echo "Error: expected exactly one task file matching '${task_input}-*.md', found ${#matches[@]}" >&2
exit 1
fi
else
task_slug="$task_input"
fi
branch="agentydragon/$task_slug"
worktrees_dir="$tasks_dir/.worktrees"
worktree_path="$worktrees_dir/$task_slug"