-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
179 lines (159 loc) · 4.4 KB
/
Copy pathJustfile
File metadata and controls
179 lines (159 loc) · 4.4 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
default:
@just --list
check:
ruff check backend
python3 -m pytest -q backend/tests
status:
#!/usr/bin/env sh
set -eu
endpoint="${COT_ENDPOINT:-http://127.0.0.1:31337}"
bridge="${COT_BRIDGE:-${HOME}/.cot/bin/cot}"
printf '%s\n' "Collector: ${endpoint}"
if curl -fsS "${endpoint}/health" >/dev/null 2>&1; then
curl -fsS "${endpoint}/health"
printf '\n'
else
printf '%s\n' "collector health check failed"
fi
printf '\n%s\n' "Compose:"
docker compose ps || true
printf '\n%s\n' "Bridge:"
if [ -x "${bridge}" ]; then
"${bridge}" status
else
printf '%s\n' "bridge not installed at ${bridge}"
fi
logs target="dev":
#!/usr/bin/env sh
set -eu
case "{{target}}" in
dev|compose)
docker compose logs -f
;;
api|web)
docker compose logs -f "{{target}}"
;;
prod|docker)
just docker-logs
;;
*)
printf '%s\n' "usage: just logs [dev|compose|api|web|prod|docker]" >&2
exit 2
;;
esac
docker-logs:
#!/usr/bin/env sh
set -eu
container="${COT_CONTAINER:-cot}"
docker logs -f "${container}"
dev action:
#!/usr/bin/env sh
set -eu
endpoint="${COT_ENDPOINT:-http://127.0.0.1:31337}"
agents="${COT_AGENTS:-claude cursor codex}"
wait_for_health() {
i=0
until curl -fsS "${endpoint}/health" >/dev/null 2>&1; do
i=$((i + 1))
if [ "${i}" -gt 60 ]; then
printf '%s\n' "cot dev collector did not become healthy at ${endpoint}" >&2
printf '%s\n' "Recent API logs:" >&2
docker compose logs --tail=80 api >&2 || true
exit 1
fi
sleep 1
done
}
case "{{action}}" in
up)
env COT_DOCKER_UID="$(id -u)" COT_DOCKER_GID="$(id -g)" docker compose up --build -d
wait_for_health
env COT_ENDPOINT="${endpoint}" COT_AGENTS="${agents}" just bridge install
printf '%s\n' "cot dev is up at ${endpoint}"
;;
down)
docker compose down
;;
status)
env COT_ENDPOINT="${endpoint}" just status
;;
logs)
just logs dev
;;
*)
printf '%s\n' "usage: just dev <up|down|status|logs>" >&2
exit 2
;;
esac
bridge action:
#!/usr/bin/env sh
set -eu
endpoint="${COT_ENDPOINT:-http://127.0.0.1:31337}"
agents="${COT_AGENTS:-claude cursor codex}"
bridge="${COT_BRIDGE:-${HOME}/.cot/bin/cot}"
agent_query=$(printf '%s' "${agents}" | tr ' ' ',')
case "{{action}}" in
install)
script=$(mktemp)
trap 'rm -f "${script}"' EXIT
curl -fsSL "${endpoint}/install.sh" -o "${script}"
env COT_ENDPOINT="${endpoint}" COT_AGENTS="${agents}" sh "${script}"
;;
repair)
script=$(mktemp)
trap 'rm -f "${script}"' EXIT
curl -fsSL "${endpoint}/repair.sh?agents=${agent_query}" -o "${script}"
env COT_ENDPOINT="${endpoint}" COT_AGENTS="${agents}" sh "${script}"
;;
status)
if [ -x "${bridge}" ]; then
"${bridge}" status
else
printf '%s\n' "bridge not installed at ${bridge}" >&2
exit 1
fi
;;
path)
printf '%s\n' "${bridge}"
;;
*)
printf '%s\n' "usage: just bridge <install|repair|status|path>" >&2
exit 2
;;
esac
prod action:
#!/usr/bin/env sh
set -eu
container="${COT_CONTAINER:-cot}"
agents="${COT_AGENTS:-claude cursor codex}"
bridge="${COT_BRIDGE:-${HOME}/.cot/bin/cot}"
case "{{action}}" in
up)
script=$(mktemp)
trap 'rm -f "${script}"' EXIT
curl -fsSL https://cot.run/install -o "${script}"
env COT_AGENTS="${agents}" sh "${script}"
;;
down)
if docker stop "${container}" >/dev/null 2>&1; then
printf '%s\n' "cot prod container stopped: ${container}"
else
printf '%s\n' "No running cot prod container named ${container}."
fi
;;
status)
docker ps --filter "name=^/${container}$" || true
if [ -x "${bridge}" ]; then
"${bridge}" status
else
printf '%s\n' "bridge not installed at ${bridge}"
fi
;;
logs)
just docker-logs
;;
*)
printf '%s\n' "usage: just prod <up|down|status|logs>" >&2
exit 2
;;
esac