diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-05 17:41:09 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-05 17:41:09 +0000 |
| commit | ddfb922584dd990481f44aad1a989e5bdf188823 (patch) | |
| tree | bdcf5a0ac974ef44229f2afddc45f92ae48e0a2f /scripts | |
| parent | 6511d6e0ff139495413c7848a9b4aabb9d9ee4e2 (diff) | |
scripts: make next-task machine-readable, simplify start-next-task
next-task now outputs only the task ID (or nothing), removing prose
prefixes that made downstream parsing fragile. start-next-task
simplifies to a direct empty-check with no awk required.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/next-task | 33 | ||||
| -rwxr-xr-x | scripts/start-next-task | 15 |
2 files changed, 48 insertions, 0 deletions
diff --git a/scripts/next-task b/scripts/next-task new file mode 100755 index 0000000..8bd958c --- /dev/null +++ b/scripts/next-task @@ -0,0 +1,33 @@ +#!/bin/bash + +DB_PATH="/site/doot.terst.org/data/claudomator.db" + +# 1. Fetch the most recently updated task +target=$(sqlite3 "$DB_PATH" "SELECT id, state, parent_task_id FROM tasks WHERE state IN ('COMPLETED', 'READY') ORDER BY updated_at DESC LIMIT 1;") + +if [ -z "$target" ]; then + exit 0 +fi + +IFS='|' read -r id state parent_id <<< "$target" + +if [ "$state" == "COMPLETED" ]; then + # 2. Find next sibling task that is currently PENDING + next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE parent_task_id = '$parent_id' AND state = 'PENDING' LIMIT 1;") + +elif [ "$state" == "READY" ]; then + # 3. Find next task ordered by priority then oldest + next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE state = 'PENDING' AND id != '$id' + ORDER BY + CASE priority + WHEN 'critical' THEN 4 + WHEN 'high' THEN 3 + WHEN 'normal' THEN 2 + WHEN 'low' THEN 1 + ELSE 0 + END DESC, + created_at ASC + LIMIT 1;") +fi + +echo "$next_task" diff --git a/scripts/start-next-task b/scripts/start-next-task new file mode 100755 index 0000000..1e45eb3 --- /dev/null +++ b/scripts/start-next-task @@ -0,0 +1,15 @@ +#!/bin/bash +# start-next-task — run the next task selected by scripts/next-task + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +task_id=$("$SCRIPT_DIR/next-task") + +if [[ -z "$task_id" ]]; then + echo "No task to start." + exit 0 +fi + +echo claudomator start "$task_id" |
