blob: 26213c5617f3c38fc6c279890bd7803f277fa552 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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"
|