Files
work-queue-api/skill/bin/wq_add
Marcus A. 33d65c35e9
All checks were successful
ci / build-test-push (push) Successful in 1m26s
feat(skill): cover full API — projects, delete, health, all WorkCreate fields
2026-04-11 16:11:13 -05:00

45 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# wq_add — submit a new work item
# Usage: wq add <type> <description> [options]
# Options:
# --agent <agent> Assign to agent (does NOT dispatch, just assigns)
# --project-id <id> Link to a project
# --priority <1-5> 1=highest, 3=default
# --payload <json> Arbitrary JSON payload
# --created-by <name> Who/what created this (default: marcus-a)
API_URL="${WORK_QUEUE_API_URL:-}"
[[ -z "$API_URL" ]] && API_URL=$(cat ~/.config/work_queue_api_url 2>/dev/null || echo "")
[[ -z "$API_URL" ]] && { echo "Error: WORK_QUEUE_API_URL not set" >&2; exit 1; }
type="" desc="" agent="" project_id="" priority="" payload_json="" created_by="marcus-a"
while [[ $# -gt 0 ]]; do
case "$1" in
--agent) agent="$2"; shift 2;;
--project-id) project_id="$2"; shift 2;;
--priority) priority="$2"; shift 2;;
--payload) payload_json="$2"; shift 2;;
--created-by) created_by="$2"; shift 2;;
--) shift; break;;
-*) echo "Unknown option: $1" >&2; exit 1;;
*)
if [[ -z "$type" ]]; then type="$1"
elif [[ -z "$desc" ]]; then desc="$1"
fi
shift;;
esac
done
[[ -z "$type" ]] || [[ -z "$desc" ]] && { echo "Usage: wq add <type> <description> [--agent <agent>] [--project-id <id>] [--priority 1-5>] [--payload <json>] [--created-by <name>]" >&2; exit 1; }
body="{\"type\":\"$type\",\"description\":\"$desc\",\"created_by\":\"$created_by\"}"
[[ -n "$agent" ]] && body=$(echo "$body" | jq ".assigned_agent=\"$agent\"")
[[ -n "$project_id" ]] && body=$(echo "$body" | jq ".project_id=\"$project_id\"")
[[ -n "$priority" ]] && body=$(echo "$body" | jq ".priority=$priority")
[[ -n "$payload_json" ]] && body=$(echo "$body" | jq ".payload=$payload_json")
curl -sf -X POST "$API_URL/work" \
-H "Content-Type: application/json" \
-d "$body" | jq .