summaryrefslogtreecommitdiff
path: root/scripts/next-task
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/next-task')
-rwxr-xr-xscripts/next-task7
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/next-task b/scripts/next-task
index e74ca26..9df09f0 100755
--- a/scripts/next-task
+++ b/scripts/next-task
@@ -11,7 +11,7 @@
# Usage: next_id=$(scripts/next-task)
# Example: scripts/start-next-task
-DB_PATH="/site/doot.terst.org/data/claudomator.db"
+DB_PATH="${DB_PATH:-/site/doot.terst.org/data/claudomator.db}"
# 1. Fetch the most recently updated COMPLETED or READY 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;")
@@ -32,7 +32,7 @@ fi
if [ -z "$next_task" ]; then
# 4. No child/sibling found: fall back to highest-priority oldest PENDING task
- next_task=$(sqlite3 "$DB_PATH" "SELECT id FROM tasks WHERE state = 'PENDING' AND id != '$id'
+ FALLBACK_SQL="SELECT id FROM tasks WHERE state IN ('PENDING', 'QUEUED') AND id != '$id'
ORDER BY
CASE priority
WHEN 'critical' THEN 4
@@ -42,7 +42,8 @@ if [ -z "$next_task" ]; then
ELSE 0
END DESC,
created_at ASC
- LIMIT 1;")
+ LIMIT 1;"
+ next_task=$(sqlite3 "$DB_PATH" "$FALLBACK_SQL")
fi
echo "$next_task"