Skip to content

Commit 94decdc

Browse files
authored
Merge pull request #10 from rhyek/fix-agent-recording
Record the agent conversations to their end, and keep events -f from skipping a line
2 parents 4e61924 + 190c33a commit 94decdc

10 files changed

Lines changed: 159 additions & 131 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.5.1
4+
5+
### Fixes
6+
7+
- **`stackctl events -f` no longer skips a line written as it starts.**
8+
39
## 0.5.0
410

511
### Features

‎docs/ai/overview.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ outputs folded as Claude Code folds them. The agent has the rules file and the s
2525
**The app is down.** Someone restarted Postgres from another terminal, and the backend crashed.
2626
The agent finds who in the [event log](../reference/events.md):
2727

28-
<llm-exclude><TerminalPlayer src="/casts/agent-restart-1794503803.cast" label="Claude Code finds the crashed backend, restarts it through stackctl and explains the crash" /></llm-exclude>
28+
<llm-exclude><TerminalPlayer src="/casts/agent-restart-1794524629.cast" label="Claude Code finds the crashed backend, restarts it through stackctl and explains the crash" /></llm-exclude>
2929
<llm-only>
3030

3131
```text
@@ -87,7 +87,7 @@ The agent finds who in the [event log](../reference/events.md):
8787
**Running the tests.** They call the backend, so the agent runs them against a test-mode session
8888
of their own:
8989

90-
<llm-exclude><TerminalPlayer src="/casts/agent-tests-1794505772.cast" label="Claude Code starts a test-mode session, runs the backend's tests in it and stops it" /></llm-exclude>
90+
<llm-exclude><TerminalPlayer src="/casts/agent-tests-1794524604.cast" label="Claude Code starts a test-mode session, runs the backend's tests in it and stops it" /></llm-exclude>
9191
<llm-only>
9292

9393
```text

‎docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ agents:
3434
details: It works from the config you wrote, so it knows what your stack is made of. It can start, stop and restart your services, check which are healthy, run your tests in a session of their own and read the logs when something breaks.
3535
linkText: stackctl for coding agents
3636
link: /ai/overview
37-
src: /casts/agent-tests-1794505772.cast
37+
src: /casts/agent-tests-1794524604.cast
3838
alt: Claude Code starts a test-mode session, runs the backend's tests in it and stops it
3939

4040
features:

‎docs/public/casts/agent-restart-1794503803.cast‎

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{"version":2,"width":74,"height":30,"theme":{"fg":"#cfd3d7","bg":"#24292e","palette":"#3b4048:#df6974:#36cb61:#e5c07b:#4e9ccd:#9b72e3:#4ec9d3:#cfd3d7:#6d6d98:#f97583:#56d364:#ffc777:#79c0ff:#c8a2ff:#56d4dd:#ffffff"}}
2+
[0.118047208,"o","\u001b[2J\u001b[H\u001b[?25l"]
3+
[0.7206318749999999,"o","\u001b[2m>\u001b[0m t"]
4+
[0.7699013329999999,"o","h"]
5+
[0.812791166,"o","e"]
6+
[0.858986,"o"," "]
7+
[0.9076105829999999,"o","a"]
8+
[0.9740863749999998,"o","p"]
9+
[1.00434375,"o","p"]
10+
[1.051552458,"o"," "]
11+
[1.09736225,"o","i"]
12+
[1.1504965829999998,"o","s"]
13+
[1.1961735409999998,"o","n"]
14+
[1.250237208,"o","'"]
15+
[1.292682791,"o","t"]
16+
[1.337333083,"o"," "]
17+
[1.38489,"o","l"]
18+
[1.4315025829999999,"o","o"]
19+
[1.4783523749999998,"o","a"]
20+
[1.5240284999999998,"o","d"]
21+
[1.5701709579999998,"o","i"]
22+
[1.616321041,"o","n"]
23+
[1.662503916,"o","g"]
24+
[1.70868625,"o",","]
25+
[1.754351083,"o"," "]
26+
[1.800198416,"o","c"]
27+
[1.8453340409999999,"o","a"]
28+
[1.8915067079999999,"o","n"]
29+
[1.937638375,"o"," "]
30+
[1.983411708,"o","y"]
31+
[2.0296091659999997,"o","o"]
32+
[2.0752046660000003,"o","u"]
33+
[2.1214957500000002,"o"," "]
34+
[2.167532666,"o","c"]
35+
[2.217251458,"o","h"]
36+
[2.26260525,"o","e"]
37+
[2.309050166,"o","c"]
38+
[2.3541425,"o","k"]
39+
[2.4077783329999995,"o"," "]
40+
[2.4647072079999996,"o","w"]
41+
[2.505002125,"o","h"]
42+
[2.551469291,"o","a"]
43+
[2.5969141249999996,"o","t"]
44+
[2.643084583,"o","'"]
45+
[2.6895929579999995,"o","s"]
46+
[2.734726875,"o"," "]
47+
[2.78106075,"o","g"]
48+
[2.8329766249999997,"o","o"]
49+
[2.879000375,"o","i"]
50+
[2.924342625,"o","n"]
51+
[2.969222625,"o","g"]
52+
[3.014537458,"o"," "]
53+
[3.0604435829999996,"o","o"]
54+
[3.106094375,"o","n"]
55+
[3.152290958,"o","?"]
56+
[3.899672083,"o","\r\n\r\n"]
57+
[3.91449875,"o","\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
58+
[5.501234125000001,"o","\r\u001b[2K"]
59+
[5.503056208,"o","\u001b[32m●\u001b[0m \u001b[1mRead(node_modules/stackctl/docs/llms.txt)\u001b[0m\r\n"]
60+
[6.208485958,"o"," \u001b[2m⎿\u001b[0m \u001b[2mRead 47 lines\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
61+
[7.106220083,"o","\r\u001b[2K"]
62+
[7.106746125000001,"o","\u001b[32m●\u001b[0m \u001b[1mRead(node_modules/stackctl/docs/ai/playbook.md)\u001b[0m\r\n"]
63+
[7.8180770410000004,"o"," \u001b[2m⎿\u001b[0m \u001b[2mRead 245 lines\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
64+
[9.219068416,"o","\r\u001b[2K"]
65+
[9.21942425,"o","\u001b[32m●\u001b[0m \u001b[1mBash(pnpm stackctl --mode development status)\u001b[0m\r\n"]
66+
[10.428010250000002,"o"," \u001b[2m⎿\u001b[0m \u001b[2mdevelopment session: running since today 11:14:34 (pid 68544, contro…\u001b[0m\r\n \u001b[2mservices backend running, not ready\u001b[0m\r\n \u001b[2m frontend running, not ready\u001b[0m\r\n \u001b[2m worker running, ready\u001b[0m\r\n \u001b[2m… +9 lines (ctrl+o to expand)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
67+
[12.621401,"o","\r\u001b[2K"]
68+
[12.621996375,"o","\u001b[32m●\u001b[0m \u001b[1mBash(pnpm stackctl --mode development logs | grep -iE\u001b[0m\r\n \u001b[1m'error|exception|fail|refused' | tail -30; pnpm stackctl --mode\u001b[0m\r\n \u001b[1mdevelopment events -n 30)\u001b[0m\r\n"]
69+
[14.023600625,"o"," \u001b[2m⎿\u001b[0m \u001b[2m2026-11-12 11:14:41 [backend ] throw er; // Unhandled 'error' …\u001b[0m\r\n \u001b[2m2026-11-12 11:14:41 [backend ] error: terminating connection due t…\u001b[0m\r\n \u001b[2m2026-11-12 11:14:41 [backend ] at parseErrorMessage (node_modu…\u001b[0m\r\n \u001b[2m2026-11-12 11:14:41 [backend ] Emitted 'error' event on BoundPool …\u001b[0m\r\n \u001b[2m… +19 lines (ctrl+o to expand)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
70+
[15.824291666,"o","\r\u001b[2K"]
71+
[15.824759666,"o","\u001b[32m●\u001b[0m \u001b[1mBash(pnpm stackctl --mode development service restart -s backend && pnpm\u001b[0m\r\n \u001b[1mstackctl --mode development status)\u001b[0m\r\n"]
72+
[18.426786500000002,"o"," \u001b[2m⎿\u001b[0m \u001b[2mrestarting backend\u001b[0m\r\n \u001b[2mstackctl: waiting for backend to be healthy\u001b[0m\r\n \u001b[2mstackctl: everything is healthy\u001b[0m\r\n \u001b[2mdevelopment session: running since today 11:14:34 (pid 68544, contro…\u001b[0m\r\n \u001b[2m… +13 lines (ctrl+o to expand)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mThinking…\u001b[0m"]
73+
[21.026852916,"o","\r\u001b[2K"]
74+
[21.027651458,"o","● The app is loading again: I restarted the backend and all three services\r\n now report healthy.\r\n\r\n \u001b[1mCause:\u001b[0m the database was restarted at 11:14:40 (\u001b[94minfra restart -s db\u001b[0m, run\r\n from the CLI by a person). That cut the backend's Postgres connection\r\n with \u001b[94mterminating connection due to administrator command\u001b[0m. The backend\r\n crashed on an unhandled pg error. Its watch-mode dev script stayed alive\r\n waiting for a file change, so the service showed \u001b[94mrunning, not ready\u001b[0m. The\r\n frontend went not-ready because it depends on the backend.\r\n\r\n \u001b[1mFix:\u001b[0m \u001b[94mstackctl --mode development service restart -s backend\u001b[0m. Backend,\r\n frontend and worker are now \u001b[94mrunning, ready\u001b[0m, and the db and mail infra\r\n are up.\r\n\r\n \u001b[1mUnderlying bug:\u001b[0m the backend has no error handler on its pg pool, so any\r\n future database restart will crash it the same way. Adding a\r\n \u001b[94mpool.on('error', …)\u001b[0m handler, or reconnect logic, in the backend would\r\n fix that. I haven't changed any"]
75+
[21.02769425,"o"," code. Want me to look at it?\r\n\r\n"]
76+
[24.430104500000002,"o","\u001b[?25h"]

‎docs/public/casts/agent-tests-1794505772.cast‎

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{"version":2,"width":74,"height":30,"theme":{"fg":"#cfd3d7","bg":"#24292e","palette":"#3b4048:#df6974:#36cb61:#e5c07b:#4e9ccd:#9b72e3:#4ec9d3:#cfd3d7:#6d6d98:#f97583:#56d364:#ffc777:#79c0ff:#c8a2ff:#56d4dd:#ffffff"}}
2+
[0.10297391699999998,"o","\u001b[2J\u001b[H\u001b[?25l"]
3+
[0.704655459,"o","\u001b[2m>\u001b[0m r"]
4+
[0.750615625,"o","u"]
5+
[0.7967698750000001,"o","n"]
6+
[0.84371225,"o"," "]
7+
[0.893338125,"o","t"]
8+
[0.9359288750000001,"o","h"]
9+
[0.9817992090000002,"o","e"]
10+
[1.028205959,"o"," "]
11+
[1.075266292,"o","b"]
12+
[1.120473292,"o","a"]
13+
[1.1677350839999998,"o","c"]
14+
[1.2139996669999997,"o","k"]
15+
[1.260268417,"o","e"]
16+
[1.30556425,"o","n"]
17+
[1.3508322499999998,"o","d"]
18+
[1.39694225,"o","'"]
19+
[1.4431215,"o","s"]
20+
[1.4892737499999997,"o"," "]
21+
[1.5353998749999997,"o","t"]
22+
[1.58155475,"o","e"]
23+
[1.627705542,"o","s"]
24+
[1.673963167,"o","t"]
25+
[1.720051917,"o","s"]
26+
[2.467257625,"o","\r\n\r\n"]
27+
[2.479181709,"o","\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
28+
[4.069746292,"o","\r\u001b[2K\u001b[32m●\u001b[0m \u001b[1mRead(node_modules/stackctl/docs/llms.txt)\u001b[0m\r\n"]
29+
[4.770679917,"o"," \u001b[2m⎿\u001b[0m \u001b[2mRead 47 lines\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
30+
[5.671751167,"o","\r\u001b[2K"]
31+
[5.671892584,"o","\u001b[32m●\u001b[0m \u001b[1mRead(node_modules/stackctl/docs/ai/playbook.md)\u001b[0m\r\n"]
32+
[6.3731332919999995,"o"," \u001b[2m⎿\u001b[0m \u001b[2mRead 245 lines\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
33+
[7.774406084,"o","\r\u001b[2K"]
34+
[7.77582975,"o","\u001b[32m●\u001b[0m \u001b[1mBash(ls; ls .env* ; npx stackctl --mode test status; npx stackctl --mode\u001b[0m\r\n \u001b[1mdevelopment status; npx stackctl --mode test show-config | jq '.services\u001b[0m\r\n \u001b[1m| keys')\u001b[0m\r\n"]
35+
[9.376390125,"o"," \u001b[2m⎿\u001b[0m \u001b[2mapps\u001b[0m\r\n \u001b[2mdocker-compose.yaml\u001b[0m\r\n \u001b[2mlibs\u001b[0m\r\n \u001b[2mnode_modules\u001b[0m\r\n \u001b[2m… +25 lines (ctrl+o to expand)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mThinking…\u001b[0m"]
36+
[10.977376875,"o","\r\u001b[2K"]
37+
[10.977701291999999,"o","● Test mode exists, no session running. Start a test session of the\r\n backend in the background.\r\n\r\n"]
38+
[11.478852084,"o","\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
39+
[12.379415834,"o","\r\u001b[2K\u001b[32m●\u001b[0m \u001b[1mBash(npx stackctl --mode test --headless -s backend)\u001b[0m\r\n"]
40+
[13.080572334000001,"o"," \u001b[2m⎿\u001b[0m \u001b[2mRunning in the background (↓ to manage)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
41+
[13.981618375,"o","\r\u001b[2K"]
42+
[13.981718709,"o","\u001b[32m●\u001b[0m \u001b[1mBash(npx stackctl --mode test wait && npx stackctl --mode test run\u001b[0m\r\n \u001b[1mbackend test)\u001b[0m\r\n"]
43+
[17.983090209,"o"," \u001b[2m⎿\u001b[0m \u001b[2mstackctl: waiting for backend to be healthy\u001b[0m\r\n \u001b[2mstackctl: everything is healthy\u001b[0m\r\n \u001b[2mtest session ready: pid 66053, control API on 14045, log node_module…\u001b[0m\r\n \u001b[2m✔ lists the todos (81.360709ms)\u001b[0m\r\n \u001b[2m… +10 lines (ctrl+o to expand)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mWorking…\u001b[0m"]
44+
[18.884035667,"o","\r\u001b[2K\u001b[32m●\u001b[0m \u001b[1mBash(npx stackctl --mode test stop)\u001b[0m\r\n"]
45+
[20.08570075,"o"," \u001b[2m⎿\u001b[0m \u001b[2mstopped test session (pid 66053)\u001b[0m\r\n\r\n\u001b[33m✻\u001b[0m \u001b[2mThinking…\u001b[0m"]
46+
[22.087772875000002,"o","\r\u001b[2K● All 3 backend tests passed:\r\n\r\n - lists the todos\r\n - rejects a todo without a title\r\n - adds a todo, completes it and deletes it\r\n\r\n I ran them in stackctl's \u001b[94mtest\u001b[0m mode. I started a test session for the\r\n backend, ran \u001b[94mstackctl --mode test run backend test\u001b[0m, then stopped the\r\n session. The development session wasn't running, and I didn't touch it.\r\n\r\n"]
47+
[25.489581459,"o","\u001b[?25h"]

‎maintenance/scripts/demo/record.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ const stage: Stage = {
227227
await sleep(50);
228228
}
229229
},
230+
async waitForExit(timeout = 180_000) {
231+
const until = performance.now() + timeout;
232+
// `exited` is set by the driver's exit event, between these sleeps.
233+
for (;;) {
234+
if (exited) {
235+
return;
236+
}
237+
if (performance.now() > until) {
238+
throw new Error(`the program never exited:\n${screen.dump()}`);
239+
}
240+
await sleep(50);
241+
}
242+
},
230243
copied: () => copied,
231244
rowOf: (text) => screen.find(text)?.row ?? null,
232245
text(value) {

0 commit comments

Comments
 (0)