@rob-c/pi-managed-tools 0.16.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,440 @@
1
+ # What `pi-managed-tools` requires from the busybox binary
2
+
3
+ A handoff contract for the **busybox-static** repository: everything below is what
4
+ this plugin actually executes and parses, captured from a real build rather than
5
+ from the design notes. If a change to the binary breaks one of these, the plugin
6
+ breaks silently — most of these fields are read with a default when missing.
7
+
8
+ - **Build this was verified against:** project release **v0.5.0**, busybox
9
+ `1.39.0.git`, asset `busybox-static-1.39.0-aac079e-darwin-universal`, **276 applets**,
10
+ `--caps` features `gnu-long-opts,peek,replace,waitfor,run,log,doctor,json`.
11
+ - **Plugin side:** `src/agentops.ts` (argv building, payload parsing, salvage) and
12
+ the three tools in `src/extension.ts`.
13
+ - **Re-capture it yourself:** `./scripts/capture-busybox-contract.sh` in this repo
14
+ prints every invocation below with its real payload.
15
+
16
+ The plugin **never re-implements a guarantee**: byte budgets, `flock`, atomic
17
+ rename, process-group cleanup and 0600 artifacts are all yours. It also never
18
+ retries a mutation and never infers success from log text.
19
+
20
+ ---
21
+
22
+ ## 1. Identity checks
23
+
24
+ | call | what the plugin reads |
25
+ |---|---|
26
+ | `busybox --list` | applet names, one per line; used to build the symlinked applet directory |
27
+ | the release's asset list (`GET /repos/rob-c/busybox-static/releases/tags/v0.4.0`) | the asset to download, matched by `^busybox-static-[\d.]+(-[0-9a-f]+)?-<target>$` — the project version is in the tag, the *busybox* version is in the asset name |
28
+ | `busybox --caps --format json` | `.version`, `.count`, `.features[]` — printed by `/managed-tools status` |
29
+
30
+ `--list` output must stay newline-separated bare names: the plugin intersects it with
31
+ its curated list and creates `<agent dir>/busybox-applets/<name>` symlinks. A name
32
+ that disappears from `--list` silently loses its bare name on `PATH`.
33
+
34
+ `--caps` is the only honest source for "which build is installed": the plugin's state
35
+ file records the release tag, and a hand-installed build is often ahead of it.
36
+
37
+ **Keep the asset naming as it is and say so if it changes.** Since 0.4.0 the tag is the
38
+ project version (`v0.4.0`) while the assets carry the busybox version
39
+ (`busybox-static-1.39.0-aac079e-darwin-universal`). The plugin therefore matches the
40
+ asset by pattern instead of constructing it from the tag, and treats a recorded
41
+ `1.39.0-aac079e` (the old scheme, which sorts *above* 0.4.0) as older than any release.
42
+ The `-pure` asset must stay distinguishable by name: it drops `nslookup`, which the
43
+ curated applet set uses, so the pattern deliberately does not match `…-universal-pure`.
44
+
45
+ ```json
46
+ {"schema":1,"version":"1.39.0.git","platform":"darwin","arch":"arm64","count":269,
47
+ "features":["gnu-long-opts","peek","replace","waitfor","run","log","doctor","json"],
48
+ "names":["[","[[","add-shell", "…"]}
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 2. `peek` — read with a version
54
+
55
+ Invocations the plugin issues (`src/agentops.ts: peekArgs`, `contentVersion`):
56
+
57
+ ```sh
58
+ busybox peek PATH [--lines A:B | --around STR [--context N] [--regex]] \
59
+ [--from-byte N] [--max-bytes N] --format json
60
+ # version probe (one line, one byte, still carries the whole-file hash):
61
+ busybox peek PATH --lines 1:1 --max-bytes 1 --format json
62
+ ```
63
+
64
+ Payload it parses (single file and `--request` both wrap in `results`):
65
+
66
+ ```json
67
+ {"schema":1,"results":[{"path":"f.ts","status":"ok","binary":false,
68
+ "version":"sha256:750d3541c856269c36e78295976696e2f78e5d72d6eb3f6236330392a4555345",
69
+ "lines":[[2,3]],
70
+ "content":[{"n":2,"text":"\tlet total = 0;"}],
71
+ "shown_bytes":57,"truncated":false,"next":null}],"shown_bytes":57}
72
+ ```
73
+
74
+ Non-ok and truncated answers it must keep producing:
75
+
76
+ ```json
77
+ {"results":[{"path":"nope.ts","status":"error","code":"NOT_FOUND","message":"No such file or directory"}]}
78
+ {"results":[{"path":"f.ts","status":"ok","truncated":true,"next":{"from_byte":36},"shown_bytes":40, …}]}
79
+ {"results":[{"path":"b.bin","status":"ok","binary":true,"version":"sha256:4163…","content":[],"shown_bytes":0}]}
80
+ ```
81
+
82
+ **Fields the plugin depends on:** `results[].status`, `.path`, `.version`, `.lines[]`
83
+ pairs, `.content[].n/.text`, `.shown_bytes`, `.truncated`, `.next`, `.binary`,
84
+ `.code`, `.message`, and top-level `.unprocessed`.
85
+
86
+ Two things worth keeping exactly as they are:
87
+
88
+ - `next` is an **object** `{"from_byte": N}`. It was nearly read as a bare number,
89
+ which silently drops the continuation and forces a re-read. Do not change it to a
90
+ number without saying so.
91
+ - `version` is the hash of the **whole file as read**, not of the shown range. The
92
+ plugin hands it back to `replace` as a precondition; if it ever became a
93
+ range-hash, stale-edit detection would silently stop working.
94
+ - `--lines`/`--around` remain mutually exclusive (the plugin sends one or the other).
95
+
96
+ `guessed_type` and a hex `preview` for binary files are **not** in this build's
97
+ payload; the formatter tolerates their absence. Adding them is welcome — the plugin
98
+ renders `preview` if present and ignores `guessed_type` when absent.
99
+
100
+ ---
101
+
102
+ ## 3. `replace` — guarded edit
103
+
104
+ Invocations:
105
+
106
+ ```sh
107
+ # one edit, the guarded form (hash checked under the lock):
108
+ busybox replace PATH --old STR --new STR [--expect N] [--sha256 HEX] \
109
+ [--dry-run] [--follow] [--max-diff-bytes N] --format json
110
+ # several edits: the only form that validates each against the file as it stands
111
+ busybox replace --request <0600 temp file> [--dry-run] [--follow] --format json
112
+ # {"edits":[{"path":"…","old":"…","new":"…","expect":1}]}
113
+ ```
114
+
115
+ A single-file answer is **flat**, a `--request` answer wraps in `results` — both
116
+ shapes must stay:
117
+
118
+ ```json
119
+ {"schema":1,"path":"r1.ts","status":"ok","dry_run":false,"changes":1,
120
+ "old_version":"sha256:750d…","new_version":"sha256:824a…","changed":true,
121
+ "diff":"@@ -4,1 +4,1 @@\n \t\n-return total + 1;\n+return total;\n","diff_truncated":false}
122
+ ```
123
+
124
+ ```json
125
+ {"schema":1,"path":"r3.ts","status":"error","code":"STALE_INPUT","message":"content version is sha256:750d…"}
126
+ {"schema":1,"path":"r4.ts","status":"error","code":"AMBIGUOUS_MATCH","message":"expected 1 occurrence(s), found 3; candidate lines: 2,3,4","candidates":[2,3,4]}
127
+ {"schema":1,"results":[{"path":"r6.ts","status":"error","code":"INVALID_ARGUMENT","message":""},{"path":"r6.ts","status":"ok", …}]}
128
+ ```
129
+
130
+ **Fields depended on:** `status`, `path`, `code`, `message`, `changes`, `dry_run`,
131
+ `changed`, `old_version`, `new_version`, `diff`, `diff_truncated`, and `results[]`
132
+ for batch. `candidates[]` is not read (the message carries the lines).
133
+
134
+ The plugin resolves a **short version prefix** (the 12 characters `peek` prints)
135
+ against the current file before handing the full hash to `--sha256`, so the exact
136
+ comparison under your lock is preserved. If `--sha256` ever accepted prefixes itself,
137
+ that resolution would be redundant but harmless.
138
+
139
+ ---
140
+
141
+ ## 4. `run` / `log` — captured execution
142
+
143
+ Invocations:
144
+
145
+ ```sh
146
+ busybox run [--timeout SECS|-T] [--kill-after SECS|-k] [--max-bytes N|-B] \
147
+ [--capture-limit N|-C] [--dir PATH|-D] [--cwd DIR|-d] [--shell|-s] \
148
+ [--stdin FILE|-i] [--pgid|-P] [--env NAME=VALUE|-e] [--prune N|-r] \
149
+ [--quiet|-q] [--timestamps|-t] [--brief-json|-j] \
150
+ [--brief stdout|stderr|both|-b] [--error-ids|-I] [--format text|json|-F] \
151
+ -- ARGV…
152
+ # the timeline, which the plugin turns on for every bash call:
153
+ busybox run --timestamps --max-bytes 48000 --env PYTHONUNBUFFERED=1 -- /bin/bash -c '…'
154
+ busybox log RUN [--lines A:B] [--match STR] [--context N] \
155
+ [--stream stdout|stderr|timeline|both] [--meta] [--diff R1:R2] \
156
+ [-B N] --format json
157
+ ```
158
+
159
+ `-Y/--pty`, `--pty-raw`, `--pty-split` and `--pty-size COLSxROWS` give the child a
160
+ pseudo-terminal. The plugin uses **`--pty-split`** for every bash call: stdout on the pty
161
+ (so libc line-buffers and the offsets are real), stderr on its own pipe (unbuffered
162
+ anyway, and it keeps the `err` tag). Measured with a C program that `printf`s three lines
163
+ 1.2 s apart, built `-O0` without an `fflush`: on a pipe every line carried `3.740564`; on
164
+ the pty the lines carried `0.004561 / 1.209525 / 2.414571`. Python and Ruby have their own
165
+ switches (the wrapper sets those too); C stdio, Java and Go's `bufio` have only the
166
+ terminal. `isatty()` is true for the child in pty mode — the
167
+ environment is otherwise untouched, and `--pty-split` keeps the streams apart. stdin is
168
+ fed through the master and terminated with `VEOF`, so a prompt sees EOF instead of
169
+ hanging. `--format json` reports `"pty":true`, and the timeline is unchanged.
170
+
171
+ `-t/--timestamps` prints one interleaved line per record, `[ 0.011354 out] text`;
172
+ `--quiet` drops the summary but is ignored when `-t` is set; `--brief WHICH` reduces a
173
+ stream through `brief -d` and is *also* ignored when `-t` is set (the timeline branch is
174
+ taken first). The plugin therefore uses `-t` for the timeline modes and `--brief` only
175
+ for its `brief` verbosity, which has no timeline. `brief` is reachable on its own too
176
+ (`busybox brief -d -t 5`), and prints a `[brief] lines_in=… records=… merged=…` marker
177
+ line of its own.
178
+
179
+ `run` payload for a complete view (intact, this is the shape relied on):
180
+
181
+ ```json
182
+ {"schema":1,"run":"R12","cmd":"sh -c echo out1","dir":"/…/busybox-run/R12","pgid":55107,
183
+ "exit_code":0,"timed_out":false,"cancelled":false,"capture_complete":true,"duration_ms":20,
184
+ "stdout_bytes":5,"stderr_bytes":5,"view_truncated":false,
185
+ "stdout_view":"out1\n","stderr_view":"err1\n"}
186
+ ```
187
+
188
+ With `-t` the payload gains the timing the plugin cares about (microseconds from
189
+ process start, one entry per line, both streams in arrival order):
190
+
191
+ ```json
192
+ {"schema":1,"run":"R111","started_unix_us":1795375794796448,
193
+ "timeline":[{"us":6926,"stream":"out","text":"x"},{"us":6952,"stream":"err","text":"y"}],
194
+ "timeline_lines":2,"timeline_shown":2,"timeline_truncated":false, …}
195
+ ```
196
+
197
+ `log --stream timeline` replays that view from the run directory (it needs a run created
198
+ with `-t`: without it the artifact does not exist and the answer is
199
+ `{"status":"error","code":"NOT_FOUND","message":"run not found or stream missing"}`);
200
+ `--stream both --format json` returns two objects. A truncated `stdout_view` is a single
201
+ JSON string with an in-band marker — `… line 5\n... [310 bytes] ...\ne 34 …` — which is
202
+ valid JSON since 0.4.0.
203
+
204
+ `log` payloads:
205
+
206
+ ```json
207
+ {"schema":1,"stream":"stdout","status":"ok","lines":[[1,2]],"content":[{"n":1,"text":"FAILED t1"}],"shown_bytes":21,"truncated":false}
208
+ {"schema":1,"run":"R17","meta":"cmd=…\ncwd=…\nexit_code=0\n…"} # --meta is a text blob
209
+ {"schema":1,"stream":"stdout","status":"error","code":"NOT_FOUND","message":"no match"}
210
+ ```
211
+
212
+ **Fields depended on:** `run`, `dir`, `exit_code`, `timed_out`, `cancelled`,
213
+ `capture_complete`, `duration_ms`, `stdout_bytes`, `stderr_bytes`, `view_truncated`,
214
+ `stdout_view`, `stderr_view`; for `log`: `stream`, `status`, `code`, `message`,
215
+ `lines`, `content[].n/.text`, `shown_bytes`, `truncated`, `meta`.
216
+
217
+ `run`'s exit code is passed through to the tool result but **is not** read as success
218
+ or failure: `exit_code: 3` with `timed_out:false` is a child that exited 3. Only
219
+ `timed_out`, `cancelled` and an unparseable payload mark a wrapper failure.
220
+
221
+ ### Fixed in 0.4.0: `run --format json` was invalid when the view was truncated
222
+
223
+ `dump_bounded()` prints the head with `json_write_str()`, then the tail with
224
+ `json_write_str()` again, producing two adjacent quoted strings at the seam:
225
+
226
+ ```sh
227
+ busybox run --max-bytes 120 --format json -- sh -c 'i=0; while [ $i -lt 40 ]; do echo "line $i"; i=$((i+1)); done' | jq .
228
+ # jq: parse error: Expected separator between values at line 1, column …
229
+ {"schema":1,"run":"R16",…,"view_truncated":true,"stdout_view":"line 0\n…\nlin""e 34\n…","stderr_view":""}
230
+ ```
231
+
232
+ 0.4.0 emits a single string with an omission marker (`... [310 bytes] ...`), which
233
+ parses. `salvageRunPayload()` in `src/agentops.ts` is kept as the fallback for older
234
+ builds: it recovers the scalars from the text and points at `busybox log RUN`, and
235
+ deliberately never re-runs the command (the command may have side effects).
236
+
237
+ Expected fix: build one buffer (head + an omission marker + tail), escape it once, and
238
+ keep `stdout_view` a single JSON string. A schema-compatible alternative is an array of
239
+ strings, but a string is what the current consumers expect.
240
+
241
+ ### Defect 2: a spawn failure is reported as a child exit code
242
+
243
+ ```sh
244
+ busybox run --format json -- /nonexistent/prog ; echo $? # exit_code:127, exit 127
245
+ ```
246
+
247
+ `--help` documents exit 1 for "when the command could not be started", and the shared
248
+ contract says wrapper failures are distinguishable. At `127` the plugin cannot tell a
249
+ missing binary from a child that chose 127, and must not guess from the
250
+ `run: can't execute …` text. Suggested: exit 1 plus `"code":"UNSUPPORTED"` (or a new
251
+ `SPAWN_FAILED`) in the JSON, keeping `exit_code` for children that actually ran.
252
+
253
+ ---
254
+
255
+ ### Closed in 0.5.0: an external signal used to leak the child
256
+
257
+ ```sh
258
+ busybox run --timestamps -- sleep 30 & pid=$!
259
+ kill -TERM $pid ; wait $pid # exit=143, and `sleep 30` is still running
260
+ pgrep -fl "sleep 30" # 68292 sleep 30
261
+ ```
262
+
263
+ 0.5.0 fixes the two causes named here. `run` installed its handler on SIGHUP/SIGALRM
264
+ (`bb_signals()` takes `1 << signo`, and `run` passed `1 << (signo - 1)`), so a SIGTERM
265
+ killed it outright; and a watchdog in its own process group now kills the command's group
266
+ when the wrapper disappears for any reason, SIGKILL included. Both verified on 0.5.0:
267
+
268
+ ```sh
269
+ run -- sh -c 'sleep 31337' & kill -TERM $! # exit 3, cancelled=true, no survivor
270
+ run -- sh -c 'sleep 31337' & kill -9 $! # no survivor after the watchdog fires
271
+ ```
272
+
273
+ What the plugin still does, now as belt-and-braces rather than necessity:
274
+
275
+ - takes pi's per-call deadline over one second earlier (`--timeout N-1`), so the applet
276
+ owns the deadline and the timeline is still printed when it expires;
277
+ - for its own tools, `runApplet()` stops waiting three seconds after its TERM and resolves
278
+ the tool call regardless, so a wedged wrapper cannot hold a tool open.
279
+
280
+ Also fixed in 0.5.0: two concurrent runs in one artifact root could pick the same run id
281
+ and truncate each other's artifacts. pi issues bash calls in parallel, so this mattered.
282
+
283
+ ### Defect (open): `unzip -d DIR` extracts nothing and exits 0
284
+
285
+ ```sh
286
+ busybox unzip -q pkg.zip -d out ; echo $? # 0, and `out` is empty
287
+ busybox unzip -q pkg.zip # extracts into cwd, correctly
288
+ ```
289
+
290
+ Same archive, same binary: with `-d` nothing is written, without it the files appear. This
291
+ is the applet the plugin links as a bare `unzip`, and the one its own zip installer used to
292
+ resolve — which silently broke every zip-based install (ast-grep, ninja, gh) once the applet
293
+ directory was on PATH. The plugin now resolves a system unzip/bsdtar first, so it is only a
294
+ model-facing annoyance, but a model that runs `unzip -d out pkg.zip` gets an empty directory
295
+ and a success code.
296
+
297
+ ### Defect (fixed, 2026-11-24 build): `unzip -d DIR` used to extract nothing
298
+
299
+ `unzip -d ex t.zip` exits 0 having extracted nothing in older builds; this build extracts
300
+ correctly (verified: `k.txt` present in `ex/`, rc 0). The plugin's extraction still
301
+ resolves the system unzip/bsdtar first — deliberate defense in depth, not a workaround
302
+ that needs undoing.
303
+
304
+ ### Gap (open): `run -x/--effects` prints nothing in text mode
305
+
306
+ `-x` reports `effects: [{op, path, size}]` in `--format json` only; text mode (including
307
+ `--timestamps` and `-q`) prints no effects section at all. The bash path reads text, so
308
+ the model never sees a wrapped call's effects — add a text section (e.g. after the views:
309
+ `effects: +new.txt, -old.txt`) for parity. The busybox_run tool surfaces them from the
310
+ JSON payload meanwhile.
311
+
312
+ ### Gap (open, re-verified on the 2026-11-24 09:42 build): the `run --format json` payload does not report the idle kill
313
+
314
+ `-W` firing sets `idle=true` in the text-mode header, but the JSON payload reports only
315
+ `timed_out:false, cancelled:false, exit_code:-1` — the plugin detects the signature from
316
+ those. Add `idle` to the JSON payload for parity.
317
+
318
+ ### Defect (fixed in 0.6.0): `--prune N` used to be ignored whenever `--timestamps` was set
319
+
320
+ ```sh
321
+ for i in $(seq 6); do run -t --prune 3 -- true ; done # 3 directories left (0.6.0)
322
+ ```
323
+
324
+ Verified fixed on the 0.6.0 build (279 applets): six runs with `--timestamps --prune 3`
325
+ left exactly 3 directories. The plugin's own sweep (`sweepRunArtifacts`, newest 20) stays
326
+ as belt-and-braces — it also covers paths `run` does not prune, and older builds where the
327
+ defect still stands
328
+
329
+ ### Behaviour worth stating: the text timeline keeps only the head
330
+
331
+ `run -t` prints `timeline_lines=N shown=M truncated=true` and then the first M lines — no
332
+ tail, unlike the JSON `stdout_view`, which keeps head and tail around an omission marker.
333
+ For a failing test suite the interesting part is the end, so the plugin's digest names
334
+ `busybox log RUN --lines <N-40>:<N>`. A `--tail-lines N` (or head+tail in text mode) would
335
+ remove that round trip.
336
+
337
+ ### Defect (open): `-B 0` shows nothing, while the JSON hint calls it "no limit"
338
+
339
+ ```sh
340
+ brief -B 0 pytest.log # marker only: shown_lines=0 bytes=0 truncated=1 truncated_by=budget
341
+ brief -B 40000 pytest.log # the whole body (33719 bytes) — a big number is how you say "all"
342
+ brief -d -B 400 -F json … # hints: ["the byte budget stopped the view: raise -B, or -B 0 for no limit"]
343
+ ```
344
+
345
+ The hint tells the caller to use `-B 0` for "no limit"; `-B 0` is a *zero* budget. Either
346
+ the flag should treat 0 as unlimited (matching the hint) or the hint should stop saying so.
347
+ The plugin's skills document the real behaviour, since the hint is the thing a model reads.
348
+
349
+ ### Behaviour worth stating: `-R` matches literal text, not a regex
350
+
351
+ ```sh
352
+ brief -R '^FAILED' pytest.log # matched=1, shown_lines=0 — the caret is part of the string
353
+ brief -R FAILED pytest.log # the failure record through the next match, as intended
354
+ ```
355
+
356
+ `-R STR` is documented as "containing STR", which is accurate, but an anchored pattern is
357
+ the natural thing to write and it yields `matched=1, shown_lines=0, truncated_by=record_size`
358
+ — a match reported, nothing shown. The skills say "literal,
359
+ not a regex" and a test forbids an anchored `-R` in an example.
360
+
361
+ ### Behaviour worth stating: split streams can tie
362
+
363
+ With `--pty-split` a stdout line and a stderr line written in the same instant can be
364
+ ordered either way by a few hundred microseconds, because they travel via different kernel
365
+ paths. The timestamps show the tie (`0.226112` vs `0.226200`); only `--pty` (merged) gives a
366
+ single-kernel-path order. Do not promise a strict cross-stream order for concurrent writes.
367
+
368
+ ## 5. `waitfor` / `doctor` — informational
369
+
370
+ Not wrapped as tools yet; they are linked as bare names and only need their current
371
+ shapes stabilised:
372
+
373
+ ```json
374
+ {"schema":1,"ready":true,"kind":"file","target":"/tmp/f","attempts":1,"elapsed_ms":0}
375
+ {"schema":1,"ready":false,"kind":"file","target":"/tmp/nope","attempts":9,"elapsed_ms":1000,"code":"TIMEOUT"}
376
+ {"schema":1,"platform":"darwin","cwd":"/tmp/x","exe":"/…/busybox","shell":"busybox sh","tmp":"/var/folders/…/T/","tmp_writable":true,"deps":{"git":"/usr/bin/git"}}
377
+ ```
378
+
379
+ ---
380
+
381
+ ## 6. Fixed in 0.4.0: a 0-match `replace` reported `INVALID_ARGUMENT` with no message
382
+
383
+ ```sh
384
+ busybox replace r5.ts --old zzzz --new x --format json ; echo $?
385
+ {"schema":1,"path":"r5.ts","status":"error","code":"INVALID_ARGUMENT","message":""}
386
+ 1
387
+ ```
388
+
389
+ 0.4.0 answers `NOT_FOUND` with `"expected 1 occurrence(s), found none"`, and
390
+ `--sha256` now accepts the 12-character prefix `peek` prints (the plugin still resolves
391
+ a prefix itself, which is harmless and keeps 0.3.x usable). `peek -p --format json` also
392
+ emits `preview` (hex) and `guessed_type`, which the peek formatter already renders.
393
+
394
+ Related: in `--request` mode the loop continues past `INVALID_ARGUMENT` and only
395
+ breaks on `STALE_INPUT`/`NOT_FOUND`. The plugin's batch summary therefore says
396
+ "check each result", not "later edits were skipped".
397
+
398
+ ---
399
+
400
+ ## 6b. `run --help` does not list the options that exist
401
+
402
+ 0.5.0 added `-Y`, `--pty-raw`, `--pty-split` and `--pty-size` to `run --help`, but
403
+ `-t/--timestamps`, `-q/--quiet`, `-j/--brief-json` and `-I/--error-ids` are still missing
404
+ from it while being accepted by `getopt32long`, and `log --help` still describes `--stream`
405
+ without `timeline`. The plugin documents these itself, but a binary should not hide its own
406
+ features.
407
+
408
+ ## 7. Compatibility checklist
409
+
410
+ Safe to change without telling anyone:
411
+
412
+ - adding applets (the plugin intersects with its own list and reports `--caps` counts);
413
+ - adding JSON fields (unknown keys are ignored);
414
+ - the text (non-`--format json`) output of anything, since no tool parses it.
415
+
416
+ **Tell the plugin first** if any of these move:
417
+
418
+ - a JSON field name the tables above lean on, or `next` losing its object shape;
419
+ - `results[]` appearing/disappearing around single-file `replace` answers;
420
+ - `--lines`/`--around` no longer being mutually exclusive;
421
+ - `version` becoming a range hash instead of a whole-file hash;
422
+ - `run`'s wrapper failure no longer being distinguishable from a child's exit status;
423
+ - `--timestamps`/`--brief` precedence changing (today the timeline wins and `--brief` is
424
+ ignored), or the timeline prefix format `[ 0.012345 out] ` changing — the bash
425
+ renderer strips exactly that shape for the human;
426
+ - `--pty-split` semantics changing (stdout a terminal, stderr a pipe, environment
427
+ untouched): the wrapper's honest timing depends on stdout being a tty, and every
428
+ command's `isatty()` answer depends on `--pty-split` staying the split one;
429
+ - the `"pty"` field, the watchdog's behaviour on SIGKILL, or `run`'s exit 3 on a signal;
430
+ - `--list`, `--caps --format json`, or `log --meta` changing shape;
431
+ - exit codes leaving the 0/1/2/3 set, or truncation ceasing to be exit 0.
432
+
433
+ ## 8. How this side verifies it
434
+
435
+ `npm test` (134 tests) covers argv building, payload rendering, the salvage path and
436
+ cancellation against a stand-in binary; `tests/agentops.test.ts` asserts the shapes in
437
+ this document, including the broken `run` payload as a fixture. The end-to-end check
438
+ is a real pi session running: `busybox_peek` → `busybox_replace` with the returned
439
+ version → `busybox_run` of a failing command → `busybox_run run_id=… match=…` → the
440
+ same `busybox_replace` again, which must answer `STALE_INPUT` and change nothing.