From 51ee798148e03ac1501e292de86b64124fcc3064 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 25 Feb 2026 14:17:48 -0600 Subject: [PATCH] Signed-off-by: Max --- scripts/README.md | 4 +++- scripts/task.sh | 14 ++++++++++++-- scripts/tests/refactor-cli-api.sh | 10 ++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/README.md b/scripts/README.md index ebb0c52..08a42dd 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -49,7 +49,7 @@ Authenticate once: ## `task.sh` ```bash -./task.sh list [status] [--status ] [--priority ] [--project ] [--assignee ] [--type ] [--limit ] [--json] +./task.sh list [status] [--status ] [--priority ] [--project ] [--assignee ] [--type ] [--limit ] [--json] ./task.sh get ./task.sh current-sprint ./task.sh create --title "" [--description "..."] [--type <task|bug|research|plan|idea>] [--status <status>] [--priority <priority>] [--project <name-or-id>] [--sprint <name-or-id|current>] [--assignee <name-or-id>] [--due-date YYYY-MM-DD] [--tags "a,b"] [--comments "..."] @@ -64,6 +64,8 @@ Notes: - `--interactive` is not supported in passthrough mode. - `--auto-create` is not supported in passthrough mode. +- `task.sh list` requests `GET /api/tasks?scope=active-sprint` and only returns tasks in the current sprint. +- If there is no current sprint, `task.sh list --json` returns `[]`. Bulk JSON format: diff --git a/scripts/task.sh b/scripts/task.sh index b5e68e3..dacc1e7 100755 --- a/scripts/task.sh +++ b/scripts/task.sh @@ -224,13 +224,16 @@ list_tasks() { done local response - response=$(api_call GET "/tasks?scope=all") + response=$(api_call GET "/tasks?scope=active-sprint") local tasks tasks=$(echo "$response" | jq '.tasks') if [[ -n "$status_filter" ]]; then - tasks=$(echo "$tasks" | jq --arg v "$status_filter" 'map(select(.status == $v))') + tasks=$(echo "$tasks" | jq --arg v "$status_filter" ' + ($v | split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(length > 0))) as $statuses + | map(select(.status as $s | ($statuses | index($s)))) + ') fi if [[ -n "$priority_filter" ]]; then tasks=$(echo "$tasks" | jq --arg v "$priority_filter" 'map(select(.priority == $v))') @@ -259,6 +262,13 @@ list_tasks() { local count count=$(echo "$tasks" | jq 'length') + if [[ "$count" -eq 0 ]]; then + local current_sprint_id + current_sprint_id="$(get_current_sprint 2>/dev/null || true)" + if [[ -z "$current_sprint_id" ]]; then + log_warning "No current sprint found. Returning 0 tasks." + fi + fi log_success "Found $count task(s)" printf "%-36s %-34s %-12s %-10s\n" "ID" "TITLE" "STATUS" "PRIORITY" diff --git a/scripts/tests/refactor-cli-api.sh b/scripts/tests/refactor-cli-api.sh index c50c97b..4f88f93 100755 --- a/scripts/tests/refactor-cli-api.sh +++ b/scripts/tests/refactor-cli-api.sh @@ -128,7 +128,7 @@ case "${method} ${url}" in respond '{"success":true}' 200 ;; "GET http://localhost:3000/api/tasks"|\ - "GET http://localhost:3000/api/tasks?scope=all") + "GET http://localhost:3000/api/tasks?scope=active-sprint") respond '{"tasks":[{"id":"t1","title":"Demo Task","status":"open","priority":"medium","type":"task","projectId":"p1","assigneeId":"u1","sprintId":"s1","comments":[],"tags":[],"attachments":[]}]}' 200 ;; "GET http://localhost:3000/api/tasks?taskId=t1&include=detail") @@ -186,6 +186,12 @@ cat > "$BULK_FILE" <<'BULK_EOF' BULK_EOF "$ROOT_DIR/scripts/task.sh" list --json >/dev/null +task_csv_status_json=$("$ROOT_DIR/scripts/task.sh" list --status open,todo,in-progress --json) +if [[ "$(echo "$task_csv_status_json" | jq 'length')" -ne 1 ]]; then + echo "Expected comma-separated --status filter to match task list output" >&2 + echo "$task_csv_status_json" >&2 + exit 1 +fi "$ROOT_DIR/scripts/task.sh" get t1 >/dev/null "$ROOT_DIR/scripts/task.sh" current-sprint >/dev/null "$ROOT_DIR/scripts/task.sh" create --title "API Task" --project "Proj" --assignee "Max" --sprint current --status todo --priority high >/dev/null @@ -260,7 +266,7 @@ assert_log_contains "POST http://localhost:3000/api/sprints/close" assert_log_contains "DELETE http://localhost:3000/api/sprints" assert_log_contains "GET http://localhost:3000/api/tasks" -assert_log_contains "GET http://localhost:3000/api/tasks?scope=all" +assert_log_contains "GET http://localhost:3000/api/tasks?scope=active-sprint" assert_log_contains "GET http://localhost:3000/api/tasks?taskId=t1&include=detail" assert_log_contains "POST http://localhost:3000/api/tasks" assert_log_contains "DELETE http://localhost:3000/api/tasks"