#!/usr/bin/env bash # ct-submit — Create and immediately run a Claudomator task # # Usage: # ct-submit --name "task name" --repo "/site/git.terst.org/repos/doot.git" --instructions "..." # ct-submit --name "task name" --instructions-file /tmp/instructions.txt # # Reads instructions from --instructions or --instructions-file. # Prints the task ID on success. set -euo pipefail API="http://localhost:8484" NAME="" REPO="/site/git.terst.org/repos/claudomator.git" INSTRUCTIONS="" INSTRUCTIONS_FILE="" while [[ $# -gt 0 ]]; do case "$1" in --name) NAME="$2"; shift 2 ;; --repo) REPO="$2"; shift 2 ;; --instructions) INSTRUCTIONS="$2"; shift 2 ;; --instructions-file) INSTRUCTIONS_FILE="$2"; shift 2 ;; *) echo "Unknown arg: $1" >&2; exit 1 ;; esac done if [[ -z "$NAME" ]]; then echo "Error: --name is required" >&2 exit 1 fi if [[ -n "$INSTRUCTIONS_FILE" ]]; then INSTRUCTIONS="$(cat "$INSTRUCTIONS_FILE")" fi if [[ -z "$INSTRUCTIONS" ]]; then echo "Error: --instructions or --instructions-file is required" >&2 exit 1 fi PAYLOAD="$(jq -n \ --arg name "$NAME" \ --arg repo "$REPO" \ --arg inst "$INSTRUCTIONS" \ '{name: $name, repository_url: $repo, agent: {type: "claude", instructions: $inst}}')" RESPONSE="$(curl -s -X POST "$API/api/tasks" \ -H "Content-Type: application/json" \ -d "$PAYLOAD")" TASK_ID="$(echo "$RESPONSE" | jq -r '.id // empty')" if [[ -z "$TASK_ID" ]]; then echo "Error creating task:" >&2 echo "$RESPONSE" >&2 exit 1 fi curl -s -X POST "$API/api/tasks/$TASK_ID/run" > /dev/null echo "$TASK_ID"