feat(skill): cover full API — projects, delete, health, all WorkCreate fields
All checks were successful
ci / build-test-push (push) Successful in 1m26s
All checks were successful
ci / build-test-push (push) Successful in 1m26s
This commit is contained in:
@@ -1,39 +1,44 @@
|
||||
#!/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)
|
||||
|
||||
wq_add() {
|
||||
local type desc agent project_id priority payload_json
|
||||
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; }
|
||||
|
||||
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;;
|
||||
--) 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
|
||||
type="" desc="" agent="" project_id="" priority="" payload_json="" created_by="marcus-a"
|
||||
|
||||
if [[ -z "$type" ]] || [[ -z "$desc" ]]; then
|
||||
echo "Usage: wq add <type> <description> [--agent <agent>] [--project-id <id>] [--priority 1-5>] [--payload <json>]" >&2
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
|
||||
local body="{\"type\":\"$type\",\"description\":\"$desc\"}"
|
||||
[[ -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")
|
||||
[[ -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; }
|
||||
|
||||
curl -sf -X POST "$API_URL/work" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$body" | jq .
|
||||
}
|
||||
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 .
|
||||
|
||||
Reference in New Issue
Block a user