Repository navigation
Expand file tree
/
Copy pathJustfile
More file actions
284 lines (251 loc) · 8.9 KB
/
Copy pathJustfile
File metadata and controls
284 lines (251 loc) · 8.9 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
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
# Unit tests + type check: backend pytest, frontend tsc, frontend vitest.
test:
#!/usr/bin/env sh
set -eu
printf '%s\n' "== backend (pytest) =="
python3 -m pytest backend/tests -q
printf '\n%s\n' "== frontend (tsc) =="
node scripts/run-node-tool.mjs tsc --noEmit
printf '\n%s\n' "== frontend (vitest) =="
node scripts/run-node-tool.mjs vitest run
# End-to-end smoke: throwaway collector on a scratch port + temp DB, drive the
# real bridge with canned payloads for all three agents, assert the API output.
# Never touches the live collector (31337) or ~/.cot/cot.db.
smoke:
#!/usr/bin/env sh
set -eu
port="${COT_SMOKE_PORT:-31399}"
endpoint="http://127.0.0.1:${port}"
container="cot-smoke-$$"
cleanup() { docker rm -f "${container}" >/dev/null 2>&1 || true; }
trap cleanup EXIT INT TERM
printf '%s\n' "cot smoke: starting scratch collector on ${port}"
docker compose run --rm -d --name "${container}" \
-p "127.0.0.1:${port}:31337" -e COT_DB_PATH=/tmp/cot-smoke.db api >/dev/null
i=0
until curl -fsS "${endpoint}/health" >/dev/null 2>&1; do
i=$((i + 1))
if [ "${i}" -gt 30 ]; then
printf '%s\n' "smoke collector never became healthy at ${endpoint}" >&2
docker logs "${container}" 2>&1 | tail -40 >&2 || true
exit 1
fi
sleep 1
done
python3 scripts/smoke_e2e.py "${endpoint}"
# Fresh web install in a sandbox: runs `curl cot.run/install | sh` with HOME in a
# temp dir, so the collector container, ~/.cot and hook files never touch yours.
# just fresh collector built from origin/main
# just fresh release the published image users pull today
# just fresh down remove the container and sandbox
# COT_FRESH_HISTORY=1 imports your real transcripts read-only.
# Fresh web install in a sandbox: up | release | down
fresh action="up":
#!/usr/bin/env sh
set -eu
case "{{action}}" in
up) scripts/fresh-install.sh ;;
release) scripts/fresh-install.sh --release ;;
down) scripts/fresh-install.sh down ;;
*) printf '%s\n' "unknown action: {{action}} (up|release|down)" >&2; exit 2 ;;
esac
# Desktop app (Tauri): cot.app that runs the frozen collector, self-updates.
# just desktop dev run the shell in dev mode (stages the collector once)
# just desktop build build cot.app (dashboard + frozen collector + shell)
# just desktop shell rebuild dashboard + shell only, reusing the frozen collector
# just desktop dmg build cot.app and the DMG
# just desktop fresh build a sandboxed DMG for fresh onboarding
# just desktop linux build the Linux .deb and .AppImage in Docker (host's arch)
# just desktop verify check the built app's collector answers /health
# just desktop install install the built app to /Applications (old one kept in ~/cot-app-backups)
# just desktop deploy build, verify, install
# just desktop prod install origin/main like a release: clean build, install, bridge + hooks
# just desktop test Rust unit tests
# just desktop clean drop build output and staged resources
# Desktop app: dev | build | shell | dmg | fresh | linux | verify | install | deploy | prod | test | clean
desktop action="build":
#!/usr/bin/env sh
set -eu
scripts/ensure-node-deps.sh desktop
cd desktop
case "{{action}}" in
dev) npx tauri dev ;;
build) scripts/build.sh ;;
shell) scripts/build.sh --shell ;;
dmg) scripts/build.sh --dmg ;;
fresh) scripts/build.sh --sandbox ;;
linux) scripts/build-linux.sh ;;
verify) scripts/verify-bundle.sh ;;
install) scripts/install.sh ;;
deploy) scripts/build.sh && scripts/verify-bundle.sh && scripts/install.sh ;;
prod) scripts/install-main.sh ;;
test) cargo test --manifest-path src-tauri/Cargo.toml ;;
clean) rm -rf build src-tauri/target src-tauri/resources && printf '%s\n' "removed desktop build output" ;;
*) printf '%s\n' "unknown action: {{action}} (dev|build|shell|dmg|fresh|linux|verify|install|deploy|prod|test|clean)" >&2; exit 2 ;;
esac
# Cut a release locally: bump backend/app/__init__.py, test, commit, annotated tag.
# Never pushes; prints the push commands (pushing the tag publishes the Docker
# image and the desktop app).
# just release 1.11.0 "Signal Forest design and extension observability"
# Release: bump version, test, commit and tag locally (prints the push commands)
release version summary:
scripts/release.sh "{{version}}" "{{summary}}"