From 436862484e53e9cf06b2594bcefd99621e603a72 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Wed, 25 Mar 2026 05:15:52 +0000 Subject: feat: add ct-submit script for permission-free task creation Wraps POST /api/tasks + run in a single script callable from /workspace/** (auto-permitted). Used by the ct-create skill to avoid per-call auth prompts. Co-Authored-By: Claude Sonnet 4.6 --- scripts/ct-submit | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 scripts/ct-submit diff --git a/scripts/ct-submit b/scripts/ct-submit new file mode 100644 index 0000000..26213c5 --- /dev/null +++ b/scripts/ct-submit @@ -0,0 +1,62 @@ +#!/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" -- cgit v1.2.3