@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.
- package/BUSYBOX-CONTRACT.md +440 -0
- package/CHANGELOG.md +441 -0
- package/README.md +464 -35
- package/package.json +7 -4
- package/skills/busybox-applets/SKILL.md +142 -15
- package/skills/managed-tools/SKILL.md +201 -25
- package/skills/managed-tools-reference/SKILL.md +206 -38
- package/src/agentops.ts +813 -0
- package/src/agenttools.ts +391 -0
- package/src/bashtool.ts +103 -0
- package/src/build.ts +142 -0
- package/src/context.ts +157 -0
- package/src/display.ts +79 -0
- package/src/extension.ts +817 -28
- package/src/guard.ts +437 -0
- package/src/jobs.ts +1052 -0
- package/src/timing.ts +364 -0
- package/src/tools.ts +525 -42
- package/src/userstdin.ts +524 -0
- package/src/wrap.ts +683 -0
package/README.md
CHANGED
|
@@ -14,7 +14,6 @@ tools:
|
|
|
14
14
|
| `rg` (ripgrep) | [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) | the `grep` tool | `<agent dir>/bin/rg` (`rg.exe` on Windows) |
|
|
15
15
|
| `bat` | [sharkdp/bat](https://github.com/sharkdp/bat) | `bash` only | `<agent dir>/bin/bat` |
|
|
16
16
|
| `prek` | [j178/prek](https://github.com/j178/prek) | `bash` only | `<agent dir>/bin/prek` |
|
|
17
|
-
| `rtk` | [rtk-ai/rtk](https://github.com/rtk-ai/rtk) `rtk-oss-*` build (Apache-2.0) | `bash` only | `<agent dir>/bin/rtk` |
|
|
18
17
|
| `just` | [casey/just](https://github.com/casey/just) | `bash` only | `<agent dir>/bin/just` |
|
|
19
18
|
| `gron` | [tomnomnom/gron](https://github.com/tomnomnom/gron) | `bash` only | `<agent dir>/bin/gron` |
|
|
20
19
|
| `shellcheck` | [koalaman/shellcheck](https://github.com/koalaman/shellcheck) | `bash` only | `<agent dir>/bin/shellcheck` |
|
|
@@ -34,7 +33,7 @@ tools:
|
|
|
34
33
|
| `miller` | [johnkerl/miller](https://github.com/johnkerl/miller) | `bash` only | `<agent dir>/bin/mlr` |
|
|
35
34
|
| `sd` | [chmln/sd](https://github.com/chmln/sd) | `bash` only | `<agent dir>/bin/sd` |
|
|
36
35
|
| `difftastic` | [Wilfred/difftastic](https://github.com/Wilfred/difftastic) | `bash` only | `<agent dir>/bin/difft` |
|
|
37
|
-
| `busybox` | [rob-c/busybox-static](https://github.com/rob-c/busybox-static) | `bash`
|
|
36
|
+
| `busybox` | [rob-c/busybox-static](https://github.com/rob-c/busybox-static) | **every `bash` call**, plus three model tools | `<agent dir>/bin/busybox` (276 applets on Darwin, 62 exposed by name in `<agent dir>/busybox-applets`) |
|
|
38
37
|
|
|
39
38
|
That download logic lives in `dist/utils/tools-manager.js` of
|
|
40
39
|
`@earendil-works/pi-coding-agent`: `ensureTool()` downloads the latest release
|
|
@@ -42,6 +41,12 @@ That download logic lives in `dist/utils/tools-manager.js` of
|
|
|
42
41
|
over anything on `PATH`. So a machine that installed pi a year ago keeps
|
|
43
42
|
whatever `fd`/`rg` release it fetched then, however many newer releases exist.
|
|
44
43
|
|
|
44
|
+
**`rtk` is no longer part of this package.** It is not downloaded, updated or
|
|
45
|
+
advertised any more: summarising output is a preference, not a pinned binary, and a proxy
|
|
46
|
+
that rewrites what a command printed is the wrong default for a model that must read
|
|
47
|
+
diffs and edit files. An existing `<agent dir>/bin/rtk` is left alone — nothing reads it,
|
|
48
|
+
and `managed_tools` will not mention it.
|
|
49
|
+
|
|
45
50
|
This package fills that gap. On a session start (at most once per interval) it
|
|
46
51
|
resolves the latest release of each project, compares it with the managed copy,
|
|
47
52
|
and replaces the copy in place — the same path pi already uses. pi's `find` and
|
|
@@ -69,8 +74,10 @@ manages.
|
|
|
69
74
|
|
|
70
75
|
### Command shadowing
|
|
71
76
|
|
|
72
|
-
pi searches `<agent dir>/bin` first,
|
|
73
|
-
|
|
77
|
+
pi searches `<agent dir>/bin` first, then `<agent dir>/busybox-applets` (the
|
|
78
|
+
curated applet names, see *BusyBox applet names on PATH*), then the user's own
|
|
79
|
+
`PATH` entries, so these win over anything else. That is intended for
|
|
80
|
+
`fd`/`rg`/`bat`. Two cases are worth knowing:
|
|
74
81
|
|
|
75
82
|
- `ast-grep` also installs its deprecated `sg` shim, which shadows util-linux's
|
|
76
83
|
`/usr/bin/sg` on Linux (the group-switching helper used by `newgrp`). Delete
|
|
@@ -108,10 +115,12 @@ That is intended for `fd`/`rg`/`bat`. Two cases are worth knowing:
|
|
|
108
115
|
here that deliberately manages a tool whose job is managing other versions.
|
|
109
116
|
- **`busybox` is a multicall binary** that dispatches on `argv[0]`, so it is only
|
|
110
117
|
installed under the name `busybox` — renaming or copying it breaks every applet.
|
|
111
|
-
Use it as `busybox <applet
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
Use it as `busybox <applet>`, or by the bare applet name for the 62 in the
|
|
119
|
+
curated list (below). **Never run `busybox --install -s <dir>`**: in pi's bin
|
|
120
|
+
directory, which is first on `PATH`, that would put 276 applets ahead of the real
|
|
121
|
+
coreutils, including `sh`, `rm`, `mount` and `init`. The package links a curated
|
|
122
|
+
set into its own directory instead. Per-applet read-only vs mutating
|
|
123
|
+
classification is in the `busybox-applets` skill.
|
|
115
124
|
- **`sd` rewrites files in place.** With no file arguments it filters stdin to
|
|
116
125
|
stdout, but `sd FIND REPLACE file...` edits those files. Use `-p` to preview.
|
|
117
126
|
Its release binary also reports `sd 1.0.0` for tag `v1.1.0`; the tag is trusted
|
|
@@ -131,47 +140,94 @@ The package ships two skills:
|
|
|
131
140
|
|
|
132
141
|
## How it integrates with pi
|
|
133
142
|
|
|
134
|
-
|
|
143
|
+
Four surfaces, in order of how reliably they reach the model:
|
|
135
144
|
|
|
136
145
|
1. **`tool_call`** (deterministic) — an absolute host path for a managed binary is
|
|
137
146
|
rewritten to its bare name before the command runs, so `/usr/bin/jq -r .a`
|
|
138
147
|
executes as `jq -r .a` and the packaged build runs. Only command-position tokens
|
|
139
|
-
are touched and only names this package manages
|
|
140
|
-
turns it off.
|
|
141
|
-
2.
|
|
148
|
+
are touched and only names this package manages (or links as an applet name), so
|
|
149
|
+
`/usr/bin/tar` is untouched. `PI_MANAGED_TOOLS_REWRITE=off` turns it off.
|
|
150
|
+
2. **PATH** (deterministic) — at session start the extension rebuilds
|
|
151
|
+
`process.env.PATH` as
|
|
152
|
+
`<agent dir>/bin : <agent dir>/busybox-applets : <user dirs> : <system dirs>`,
|
|
153
|
+
dropping any earlier occurrence of its own two entries first. pi's
|
|
154
|
+
`getShellEnv()` re-reads that value for every `bash` spawn and only prepends the
|
|
155
|
+
bin directory when it is *absent*, so this is the one hook that reaches every
|
|
156
|
+
command — including the case where a shell rc appended
|
|
157
|
+
`$HOME/.pi/agent/bin` to `PATH` and defeated pi's prepend.
|
|
158
|
+
3. **`before_agent_start`** (deterministic) — the two environment rules are appended
|
|
142
159
|
to `systemPromptOptions.promptGuidelines`, and a `managed_tools_environment`
|
|
143
160
|
section states the facts outright: that the bin directory is first on `PATH`,
|
|
144
|
-
which packaged versions that means,
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
which packaged versions that means, that the busybox applet names are on `PATH`
|
|
162
|
+
as well, and that no probing turn is needed. Idempotent, and the section text
|
|
163
|
+
is stable so pi does not re-patch it each turn.
|
|
164
|
+
4. **Skills** (opportunistic) — name, description and path are always in the system
|
|
147
165
|
prompt; the body loads only when the model decides it is relevant, which it does
|
|
148
166
|
not do for one-liners.
|
|
149
167
|
|
|
150
|
-
`/managed-tools status` reports how many absolute paths were rewritten this session
|
|
168
|
+
`/managed-tools status` reports how many absolute paths were rewritten this session,
|
|
169
|
+
how many applet names are linked (62 with the default policy), and what the installed
|
|
170
|
+
build says about itself (`busybox --caps`: version, applet count, features) — which is
|
|
171
|
+
the only honest answer when a binary was installed by hand ahead of a release.
|
|
172
|
+
|
|
173
|
+
### BusyBox applet names on PATH
|
|
174
|
+
|
|
175
|
+
`<agent dir>/busybox-applets` holds symlinks named after applets, each pointing at
|
|
176
|
+
`<agent dir>/bin/busybox`, so `xxd`, `hexdump`, `sha256sum`, `unzip`, `timeout` and
|
|
177
|
+
57 more run without the `busybox` prefix. The links live in a second directory, not
|
|
178
|
+
in the bin directory, because PATH order is the only thing that decides which build
|
|
179
|
+
a bare name runs and two names in one directory have no order. The dedicated static
|
|
180
|
+
builds stay first.
|
|
181
|
+
|
|
182
|
+
The default list is curated, not "all 276":
|
|
183
|
+
|
|
184
|
+
- **In** when the host may not have the tool (`cpio`, `dpkg-deb`, `rpm2cpio`,
|
|
185
|
+
`nproc`, `setsid`, `sha3sum`, `uuidgen`, `ipcalc`, `wget`, ...), when the busybox
|
|
186
|
+
implementation accepts the flags anyone actually passes (`xxd`, `hexdump`, `od`,
|
|
187
|
+
`strings`, `gzip`, `unzip`, `timeout`, ...), or when it is an agent-facing applet
|
|
188
|
+
with a distinctive name and no side effects (`peek`, `waitfor`, `doctor`, `brief`,
|
|
189
|
+
`why`, `patchcheck`).
|
|
190
|
+
- **Out** whenever a host build is near-universal and functionally richer, so no
|
|
191
|
+
working command changes meaning: `sed`, `grep`, `find`, `awk`, `tar`, `diff`,
|
|
192
|
+
`ls`, `cat`, `cp`, `mv`, `rm`, `ln`, `chmod`, `stat`, `df`, `du`, `ps`, `kill`,
|
|
193
|
+
`bc`, `mktemp`, `which`, `date`, `patch` and `tree` (busybox `tree` takes a
|
|
194
|
+
directory and no flags, so the usual `tree -L 2` fails). So do `replace`, `run`,
|
|
195
|
+
`log`, `bench`, `check`, `json` and `snapshot`: some run a command, some write a file,
|
|
196
|
+
and the rest are names a project script or another tool already owns. Everything left
|
|
197
|
+
out stays reachable as `busybox <applet>`, which is a deliberate act.
|
|
198
|
+
- **Never**, under any policy: shells (`sh`, `ash`, `hush`, `login`, `su`), boot and
|
|
199
|
+
device administration (`init`, `mount`, `mdev`, `sysctl`, `insmod`), servers
|
|
200
|
+
(`httpd`, `telnetd`, `tftpd`) and package managers (`dpkg`, `rpm`).
|
|
201
|
+
|
|
202
|
+
`PI_MANAGED_TOOLS_APPLETS` widens or disables it: `all` links every applet the
|
|
203
|
+
build has minus the never-list (the aggressive version, where busybox `sed` and
|
|
204
|
+
`grep` do win), `off` links nothing and leaves only the bin directory ahead. An
|
|
205
|
+
unrecognised value is the default, never a silent opt-in to `all`.
|
|
151
206
|
|
|
152
207
|
The always-on skill also pins two environment rules, because both are silent when
|
|
153
208
|
broken: call the packaged binaries by **bare name** (an absolute path like
|
|
154
209
|
`/usr/bin/jq` bypasses pi's `PATH` prepend and `getToolPath()`), and run multi-step
|
|
155
210
|
shell logic through **`busybox sh -c '…'`** so the shell does not depend on which
|
|
156
211
|
bash the host resolved. `busybox sh` covers `[[ ]]`, `<(…)`, `<<<`, `$'…'`, `local`
|
|
157
|
-
and `pipefail`, but not arrays, `${v^^}`, `read -a`, `mapfile` or `coproc`.
|
|
212
|
+
and `pipefail`, but not arrays, `${v^^}`, `read -a`, `mapfile` or `coproc`. The
|
|
213
|
+
curated applet names are bare on `PATH` too; the names that are *not* linked need the
|
|
214
|
+
`busybox` prefix.
|
|
158
215
|
|
|
159
216
|
- **`managed-tools`** — always advertised. pi adds every skill's *name and
|
|
160
217
|
description* to the system prompt and nothing else, so this description is the
|
|
161
|
-
advert: it sets the preference order (
|
|
162
|
-
|
|
163
|
-
- **`busybox-applets`** — loaded on demand, only when busybox is in play. All
|
|
218
|
+
advert: it sets the preference order (these binaries over the system ones), names all
|
|
219
|
+
twenty-four tools, and routes to the reference for flags.
|
|
220
|
+
- **`busybox-applets`** — loaded on demand, only when busybox is in play. All 276
|
|
164
221
|
applets classified read-only / mutating / destructive / exec, with the flags that
|
|
165
|
-
cause a write.
|
|
222
|
+
cause a write, plus the contract the six agent-facing applets share.
|
|
166
223
|
- **`managed-tools-reference`** — loaded on demand. The exact flag set and one
|
|
167
224
|
or two worked examples per tool, transcribed from the binaries this package
|
|
168
225
|
installs rather than from upstream docs, because the versions are pinned.
|
|
169
226
|
|
|
170
|
-
Both skills
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
plain commands as the fallback when unsure.
|
|
227
|
+
Both skills say where reduction happens now that `rtk` is gone: `busybox brief -d`
|
|
228
|
+
collapses identical records without cutting one in half, `-R` keeps a stack trace as a
|
|
229
|
+
single record, and `busybox_run` retains the full capture in an artifact, so a reduced
|
|
230
|
+
view never destroys the evidence. Nothing here summarises a diff behind your back.
|
|
175
231
|
|
|
176
232
|
That pinning is the point: the tool surface is fully known at install time, so
|
|
177
233
|
the skills can state flag names instead of telling the model to run `--help` and
|
|
@@ -180,6 +236,297 @@ without documenting it in both skills fails the suite, as does a description ove
|
|
|
180
236
|
the Agent Skills 1024-character limit or a version list that disagrees between
|
|
181
237
|
the two files.
|
|
182
238
|
|
|
239
|
+
### Pi-Time: every bash call is a timeline
|
|
240
|
+
|
|
241
|
+
**Pi-Time** is the name for what the wrapper gives the model: the concept of time, which a
|
|
242
|
+
plain text capture of an execution does not carry — and which a hosted LLM needs to reason
|
|
243
|
+
about a run instead of guessing. Three facts come back with every command, and each exists
|
|
244
|
+
because its absence made the model misread an execution:
|
|
245
|
+
|
|
246
|
+
- **Which stream.** Every line is tagged `out` or `err`, so a warning on stderr is never
|
|
247
|
+
misread as program output, and a tool's diagnostics keep their identity. A `2>&1` in the
|
|
248
|
+
command destroys exactly this — it merges stderr into stdout inside the child, before
|
|
249
|
+
the wrapper can tag anything — so the skills forbid it.
|
|
250
|
+
- **When.** A microsecond offset on every line, and a `timing:` digest on slow runs, so
|
|
251
|
+
ordering, durations and silences are readable facts. A merged capture does not just
|
|
252
|
+
lack them — it lies: block buffering puts a 0s stdout burst after an 8s stderr line, and
|
|
253
|
+
the probe below shows a model repeating that inverted order.
|
|
254
|
+
- **How long is too long.** A default deadline on every call, so a hang ends in a named
|
|
255
|
+
`TIMEOUT` state with its partial capture intact, instead of minutes of silence or an
|
|
256
|
+
exit code that reads like a failure.
|
|
257
|
+
|
|
258
|
+
Mechanically: pi's `bash` tool is re-registered (the supported override path: pi's own
|
|
259
|
+
runner with a spawn hook) so each command executes as
|
|
260
|
+
`busybox run --timestamps ... -- /bin/bash -c '<command>'`.
|
|
261
|
+
|
|
262
|
+
The **model** reads one interleaved line per record, with its offset in seconds and the
|
|
263
|
+
stream it arrived on:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
run=R134 exit_code=0 timed_out=false cancelled=false idle=false duration_ms=8421
|
|
267
|
+
timeline_lines=4 shown=4 truncated=false
|
|
268
|
+
--- timeline ---
|
|
269
|
+
[0.011354789 out] ok 1
|
|
270
|
+
[= out] ok 2
|
|
271
|
+
[2.320004125 err] FAILED test_x
|
|
272
|
+
[8.421130000 out] done
|
|
273
|
+
timing: 8.42s total, 4 lines, output from 0.01s, stderr from 2.32s, longest pause 6.10s (2.32s → 8.42s)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The child gets a pseudo-terminal (`busybox run --pty-split`): stdout on the pty, stderr
|
|
277
|
+
on a pipe. That is what makes the offsets honest: libc line-buffers when stdout is a
|
|
278
|
+
terminal, so a program that buffers on a pipe emits each line as it happens. A C program
|
|
279
|
+
printing three lines 1.2 s apart reported all three at `3.740564` on a pipe and at
|
|
280
|
+
`0.004561 / 1.209525 / 2.414571` on the pty; Python and Ruby have environment switches
|
|
281
|
+
(the wrapper sets them too), C stdio, Java and Go's `bufio` have only this. stderr is
|
|
282
|
+
unbuffered either way, so it keeps its own pipe and its `err` tag. `isatty()` is now true for the child, which is the one behavioural
|
|
283
|
+
change: programs take their terminal path (colours are suppressed by `NO_COLOR`/
|
|
284
|
+
`TERM=dumb`, pagers by `PAGER=cat`). `PI_MANAGED_TOOLS_PTY=off` restores plain pipes;
|
|
285
|
+
`merged` gives 0/1/2 one pty; `raw` adds `--pty-raw`.
|
|
286
|
+
|
|
287
|
+
A run longer than a second also gets the **`timing:` digest** appended to the tool
|
|
288
|
+
result, for the model only: total, line count, where output began, and the longest
|
|
289
|
+
silence (or the silence after the last line). It is a derived line, not a replacement
|
|
290
|
+
for the offsets, and the renderer strips it for the human.
|
|
291
|
+
|
|
292
|
+
`[= out]` is a line that arrived at the same offset as the one above: within a burst the
|
|
293
|
+
offset is printed once, and the stream tag stays on every line. (Stamps were measured at
|
|
294
|
+
a quarter of all bash-result bytes; `PI_MANAGED_TOOLS_COMPACT_STAMPS=off` prints them in
|
|
295
|
+
full.) The exact shape of a stamp is the build's — padded to 0.6.0, unpadded since — so
|
|
296
|
+
the example the model is shown is cut from a line the installed binary really printed,
|
|
297
|
+
at session start.
|
|
298
|
+
|
|
299
|
+
That is the ordering a merged stdout/stderr block destroys: the failure came after
|
|
300
|
+
`ok 1` and before `done`, and lines sharing one timestamp are a writer that flushed at
|
|
301
|
+
exit rather than streaming.
|
|
302
|
+
|
|
303
|
+
The **human** sees the command's own lines: the bash renderer strips the wrapper's
|
|
304
|
+
header, section markers and `[0.012345789 out]` prefixes, and keeps everything the
|
|
305
|
+
command printed — indentation, blank lines, a truncated view's `... [N bytes] ...`
|
|
306
|
+
marker — plus pi's usual `(full output: …)` hint when pi truncates. The tool result is
|
|
307
|
+
untouched, so the model's copy and the session transcript keep the timeline; only the
|
|
308
|
+
rendering differs (TUI and HTML export).
|
|
309
|
+
|
|
310
|
+
The wrapper is transparent in the ways that matter: the child's exit status, cwd and
|
|
311
|
+
shell are unchanged (still `/bin/bash`, so `[[ ]]` and arrays keep working), and the
|
|
312
|
+
unbuffered environment travels with the command rather than being exported into pi:
|
|
313
|
+
`PYTHONUNBUFFERED=1`, `PYTHONIOENCODING=utf-8`, `PYTHONDONTWRITEBYTECODE=1`, `NO_COLOR=1`,
|
|
314
|
+
`CLICOLOR=0`, `FORCE_COLOR=0`, `TERM=dumb`, `PAGER=cat`, `GIT_PAGER=cat`,
|
|
315
|
+
`GIT_TERMINAL_PROMPT=0`, `CARGO_TERM_COLOR=never`, `DEBIAN_FRONTEND=noninteractive`,
|
|
316
|
+
`MAVEN_ARGS=-B -ntp`, `GRADLE_OPTS=-Dorg.gradle.console=plain -Dorg.gradle.daemon=false`,
|
|
317
|
+
and `RUBYOPT=-r<agent dir>/pi-unbuffer.rb` for Ruby's `$stdout.sync`. Where no switch
|
|
318
|
+
exists — Go's `bufio.Writer`, Java's `System.out` — the timeline shows the flush: every
|
|
319
|
+
line of a burst carries the same offset.
|
|
320
|
+
|
|
321
|
+
Two escapes: `PI_MANAGED_TOOLS_WRAP=off` for the session, and `command <cmd>` for one
|
|
322
|
+
call (accepted at the start of the command or of any `&&`/`;` segment), which runs it
|
|
323
|
+
unwrapped for byte-exact output.
|
|
324
|
+
|
|
325
|
+
The human's own `!` commands go through the wrapper too (pi's `user_bash` hook hands the
|
|
326
|
+
local backend a wrapped command): the split pseudo-terminal and the unbuffered
|
|
327
|
+
environment, with the command's own bytes shown and nothing else — no timeline, because
|
|
328
|
+
the reader is a person in the TUI. No deadline is applied (a `!` command belongs to its
|
|
329
|
+
owner, Ctrl-C included), the `command` escape falls through to pi's plain path, and
|
|
330
|
+
`PI_MANAGED_TOOLS_USER_WRAP=off` turns it off.
|
|
331
|
+
|
|
332
|
+
**You can answer a `!` command.** pi starts every command with its stdin closed, so a
|
|
333
|
+
`[y/N]` prompt used to read end-of-file, take its default and exit 0; and `busybox run -q`
|
|
334
|
+
prints only when the command exits, so nothing was shown until then. Now:
|
|
335
|
+
|
|
336
|
+
- the output is shown as it arrives, an unfinished prompt line included (the run's capture
|
|
337
|
+
files are followed while it runs);
|
|
338
|
+
- when the command looks like it is waiting — output stopped on an unfinished line, or
|
|
339
|
+
three seconds of silence — pi's input dialog opens, titled with the command. Enter sends
|
|
340
|
+
the line to the command, through `busybox run --stdin` and the pty; the dialog reopens
|
|
341
|
+
for the next question;
|
|
342
|
+
- Esc in the dialog means "no more input": the command reads end-of-file and carries on,
|
|
343
|
+
and you get the editor back. Esc again stops the command, as before;
|
|
344
|
+
- **you have five minutes to answer** — not the two a model's command gets, because this
|
|
345
|
+
clock times a person, not a program. The dialog's title counts down, and the clock runs
|
|
346
|
+
only while the dialog is open: a command that is working is never timed by it. When it
|
|
347
|
+
runs out the command is **stopped**, with exit status 124 and a line in its output
|
|
348
|
+
saying it waited and nobody typed. It is not given end-of-file instead, because a
|
|
349
|
+
`[Y/n]` prompt would read that as *yes*. `PI_MANAGED_TOOLS_STDIN_TIMEOUT=<seconds>`
|
|
350
|
+
changes the wait; `0` waits for as long as it takes;
|
|
351
|
+
- what you type is **not** added to the output, which is recorded in the session and read
|
|
352
|
+
by the model — a password stays out of it. It is visible in the dialog while you type.
|
|
353
|
+
|
|
354
|
+
A command that draws to the whole screen (an editor, `less`, `top`) is still not something
|
|
355
|
+
a `!` command can host. This path keeps no capture afterwards: the run's private folder is
|
|
356
|
+
removed when the command ends. `PI_MANAGED_TOOLS_USER_STDIN=off` restores the old
|
|
357
|
+
behaviour (stdin empty, output at exit, capture kept for `busybox log`).
|
|
358
|
+
|
|
359
|
+
The model cannot be answered by anyone, and is told so: its commands read end-of-file at
|
|
360
|
+
once, so it puts the answer in the command (`printf 'y\n' | cmd`, a heredoc, `--yes`) or
|
|
361
|
+
in `busybox_run`'s `stdin` parameter.
|
|
362
|
+
|
|
363
|
+
Every wrapped command gets a 120-second deadline by default, so a hang cannot hold the
|
|
364
|
+
model in silence. A caller's own `timeout` still wins — the wrapper takes it over one
|
|
365
|
+
second earlier (`--timeout N-1`) because the applet's deadline cancels the child's process
|
|
366
|
+
group and still prints the timeline, while a SIGKILL from pi would print nothing at all.
|
|
367
|
+
`PI_MANAGED_TOOLS_TIMEOUT=<seconds>` changes the default for a session; `0` or `off`
|
|
368
|
+
removes it.
|
|
369
|
+
|
|
370
|
+
When the deadline fires, the result opens with `TIMEOUT — not a failure of the command` and
|
|
371
|
+
explains that the `exit_code=-1` / "Command exited with code 3" statuses are the kill, not
|
|
372
|
+
the command's own exit code; the partial capture is retrievable with `busybox log <run>`.
|
|
373
|
+
|
|
374
|
+
Stamps are nanosecond (`--stamp-ns`) where the build has them — two events in the same
|
|
375
|
+
microsecond stay distinguishable — and every shape a build has printed still parses:
|
|
376
|
+
padded microseconds, zero-padded nanoseconds (0.6.0), unpadded (0.6.1 on).
|
|
377
|
+
|
|
378
|
+
A 120-second silence watchdog (`run -W`) rides with every deadline: a command producing no
|
|
379
|
+
output at all is killed and reported `idle=true` — a hang, not slow work — even when the
|
|
380
|
+
deadline was raised. The result's notice names it `IDLE`, distinct from `TIMEOUT`, and
|
|
381
|
+
rules stdin out as the cause (stdin is empty under pi, so a read returns end-of-file at
|
|
382
|
+
once) in favour of a socket, a lock or a child that never exits.
|
|
383
|
+
`PI_MANAGED_TOOLS_IDLE=<seconds>` changes it; `0` disables it. And
|
|
384
|
+
`busybox run --format json` now reports what the command *did*, not just what it printed:
|
|
385
|
+
`cpu_user_ms`/`cpu_sys_ms`, `max_rss_kb`, `binary` (the output is not text), `dropped_bytes`,
|
|
386
|
+
`final_newline`, `cwd_start` and a re-runnable `replay` line — the `busybox_run` tool
|
|
387
|
+
surfaces the interpretation-changing ones on a `meta` line of its result.
|
|
388
|
+
|
|
389
|
+
### What a result says, and what is refused
|
|
390
|
+
|
|
391
|
+
A result is only as good as what the model can conclude from it without guessing. Each of
|
|
392
|
+
these was a place where it had to guess, or was told something false.
|
|
393
|
+
|
|
394
|
+
- **How it ended comes first, when that was not the command's own exit.** `TIMEOUT`,
|
|
395
|
+
`IDLE`, `CANCELLED` and `KILLED` open the result. A timeout used to start with
|
|
396
|
+
`exit_code=-1`, then up to 48 KB of output, and only then say nothing had failed.
|
|
397
|
+
- **A truncated view names what it lacks.** `busybox run` keeps the head *and* the tail of
|
|
398
|
+
a long timeline and marks the cut. The line after the result names the omitted range,
|
|
399
|
+
gives the command that reads from it, and says how many of the omitted lines are on
|
|
400
|
+
stderr — a view with no `[err]` line otherwise reads as "no errors".
|
|
401
|
+
- **pi's own cut is repaired.** pi's bash tool keeps the last 2000 lines or 50 KB. When
|
|
402
|
+
that removes the `run=` header, it is restored from the full output pi kept aside, and
|
|
403
|
+
the cut is said.
|
|
404
|
+
- **Facts instead of "unknown".** The guest shell leaves its last pipeline's stage
|
|
405
|
+
statuses and its final directory in the run's folder (an EXIT trap, about 4 ms). So
|
|
406
|
+
`cmd | head` gets `pipeline stage statuses: 1 141 0` — or no note at all when every
|
|
407
|
+
stage exited 0 — and a `cd` gets `this command ended in /repo/build; the next bash
|
|
408
|
+
call starts back in /repo`. A command that sets its own EXIT trap gets the old caveats.
|
|
409
|
+
- **A caveat is given in full once.** After that it comes back in a few words; the same
|
|
410
|
+
two lines on every `| head` call were being skimmed past.
|
|
411
|
+
- **A command that cannot end is refused before it runs**, with the rewrite: a pager, an
|
|
412
|
+
editor, `tail -f`, `watch`, `top`, `git rebase -i`, a foreground server. Nobody can
|
|
413
|
+
press a key here, so it would sit until the deadline and return a `TIMEOUT` with
|
|
414
|
+
nothing learned. Only the first word of a statement or pipeline stage is judged,
|
|
415
|
+
heredoc bodies are skipped, and `timeout …`, a trailing `&`, or a pipeline that ends
|
|
416
|
+
(`tail -f log | grep -m1 ready`) pass. `# pitime-safe` overrides it, as for a merge.
|
|
417
|
+
- **`busybox sh -c '…'` is wrapped.** Every direct `busybox …` call used to count as
|
|
418
|
+
"already wrapped" — and the guidelines recommend `busybox sh -c` for multi-step logic,
|
|
419
|
+
so exactly the longest commands ran with no timeline and no deadline. Only the applets
|
|
420
|
+
whose output is their own record (`run`, `log`, `peek`, `json`, …) are left alone now.
|
|
421
|
+
- **The binary is asked, not assumed.** At session start it is run once with the flags a
|
|
422
|
+
wrapped command gets. Its feature list decides `--stamp-ns` and the silence watchdog;
|
|
423
|
+
a refused pseudo-terminal means plain pipes for the session; and a binary that fails
|
|
424
|
+
turns the wrapper off, with a warning, instead of failing every bash call.
|
|
425
|
+
- **Captures are not deleted from under another session.** The artifact root is shared by
|
|
426
|
+
every session on the machine, and `--prune 20` let twenty commands in one delete a run
|
|
427
|
+
another had just been pointed at. Nothing is pruned by count now: the sweep removes a
|
|
428
|
+
run only when it is beyond the newest 200 *and* more than two hours old.
|
|
429
|
+
- **Other extensions see the model's command.** The wrapper is applied inside the bash
|
|
430
|
+
tool's own `execute`, not by rewriting the call in the `tool_call` hook, so a permission
|
|
431
|
+
or safety extension matches its rules against `npm test`, not `busybox run … -c '…'`.
|
|
432
|
+
|
|
433
|
+
### Buffering
|
|
434
|
+
|
|
435
|
+
An offset is only the truth if the program wrote the line when it printed it. On the
|
|
436
|
+
terminal most runtimes do. But a stage inside a pipeline (`make | tee build.log`,
|
|
437
|
+
`./server | grep ERROR`) and output sent to a file a later call reads write to a pipe or
|
|
438
|
+
a file, where a runtime that block-buffers holds its lines until 4–64 KB have piled up.
|
|
439
|
+
Measured with a probe per runtime (print, wait a second, print; stdout a pipe), on macOS
|
|
440
|
+
and Debian:
|
|
441
|
+
|
|
442
|
+
| Runtime | On a pipe, untouched | With the wrapper | How |
|
|
443
|
+
|---|---|---|---|
|
|
444
|
+
| sh builtins, Node, Deno, Bun, PHP, Tcl, R, Java, Elixir, Go, Rust, C++ iostream | live | live | nothing needed |
|
|
445
|
+
| Python | late | live | `PYTHONUNBUFFERED=1` |
|
|
446
|
+
| Ruby, Perl | late | live | a prelude loaded through `RUBYOPT` / `PERL5OPT` |
|
|
447
|
+
| LuaJIT | late | live | `LUA_INIT` |
|
|
448
|
+
| C stdio on macOS: compiled C, Swift, `grep`, `sed`, `awk`, `cut`, `tr`, `jq` | late | live | `STDBUF1=L`, read by the C library itself |
|
|
449
|
+
| C stdio on Linux | late | late — live with `PI_MANAGED_TOOLS_PRELOAD=on` | glibc has no variable; `stdbuf`'s preload library |
|
|
450
|
+
| Haskell (GHC), OCaml `Printf`, `mawk` | late | late | nothing outside the program changes it |
|
|
451
|
+
|
|
452
|
+
`RUBYOPT`, `PERL5OPT`, `MAVEN_ARGS` and `GRADLE_OPTS` are appended to what you already have
|
|
453
|
+
(a `GRADLE_OPTS=-Xmx4g` used to be replaced). The cost is bulk output: a line at a time is
|
|
454
|
+
a system call at a time — on macOS five million lines into a file took 15.5 s instead of
|
|
455
|
+
0.6 s, about 3 µs a line. `STDBUF1=F cmd` exempts one command, `PI_MANAGED_TOOLS_EXTRA_ENV`
|
|
456
|
+
set to `STDBUF1=F` every command, and `PI_MANAGED_TOOLS_UNBUFFER=off` turns all of it off.
|
|
457
|
+
The Linux preload is off by default because it reaches every program a command starts,
|
|
458
|
+
and an AddressSanitizer build refuses to run under one.
|
|
459
|
+
|
|
460
|
+
### What the model is sent of what it has already read
|
|
461
|
+
|
|
462
|
+
- **Old timelines lose their offsets at compaction.** A wrapped result older than the
|
|
463
|
+
latest compaction is sent with the command's own lines, `err| ` on its stderr lines, its
|
|
464
|
+
header and its digest — no stamps. Only then, because rewriting an old message changes
|
|
465
|
+
the prompt's prefix, and compaction is the one moment the prefix is rebuilt anyway.
|
|
466
|
+
The session file is never touched.
|
|
467
|
+
- **A `!` command reaches the model as a timeline.** You see the command's own bytes; the
|
|
468
|
+
capture took a timeline anyway, and the recorded message is swapped for it on the way
|
|
469
|
+
to the model.
|
|
470
|
+
|
|
471
|
+
### `busybox_job`: a command that outlives the call
|
|
472
|
+
|
|
473
|
+
pi has no background mode: a dev server in a bash call ends in a `TIMEOUT`, and `&` loses
|
|
474
|
+
the output. `busybox_job` starts a command under its own `busybox run`, returns a job id,
|
|
475
|
+
and then: `status` gives only the output that is new (stderr lines marked `err| `),
|
|
476
|
+
`wait_for` returns the moment a literal appears and says whether it did, `stop` ends the
|
|
477
|
+
whole process group. Jobs are stopped when the session ends; at most eight run at once.
|
|
478
|
+
|
|
479
|
+
### Agent-facing applets and the three tools
|
|
480
|
+
|
|
481
|
+
The packaged build carries fifteen applets that exist for a coding agent rather than a
|
|
482
|
+
shell, and they share one contract: text by default, `--format json` with
|
|
483
|
+
`"schema":1` on request, explicit byte budgets, `shown_bytes`/`truncated` always
|
|
484
|
+
reported, and exit codes that never use 124 or 128+N.
|
|
485
|
+
|
|
486
|
+
| applet | what it adds |
|
|
487
|
+
|---|---|
|
|
488
|
+
| `peek FILE -l A:B` | numbered lines **and** the file's `sha256` from the same bytes, a `--from-byte` continuation, merged `--around` windows, binary input flagged rather than dumped |
|
|
489
|
+
| `replace FILE --old S --new S` | literal replacement validated against the whole file before any write, `--expect N`, `--sha256` precondition, atomic write, `--dry-run` diff, `flock` for cooperating writers |
|
|
490
|
+
| `run -- CMD...` | exec argv verbatim or `--shell`, stdout/stderr captured to 0600 artifacts, bounded head+tail view, own deadline and process-group cleanup |
|
|
491
|
+
| `log RUN` | re-read a capture by `--lines`, `--match` (literal), `--context`, `--stream`, `--meta` |
|
|
492
|
+
| `waitfor` | bounded `--file`/`--tcp`/`--unix`/`--http` readiness with one deadline |
|
|
493
|
+
| `doctor` | cwd, argv[0] resolution, shell, writable temp, `--deps a,b` paths — no environment dump |
|
|
494
|
+
|
|
495
|
+
Three of them are wrapped as model tools, because the built-ins they resemble lack
|
|
496
|
+
exactly one property each:
|
|
497
|
+
|
|
498
|
+
- **`busybox_peek`** — a read that returns the file version, so the next edit can be
|
|
499
|
+
refused if the file moved underneath it. `read` is still the default for reading.
|
|
500
|
+
- **`busybox_replace`** — `edit` with a `sha256` precondition: a stale hash is
|
|
501
|
+
`STALE_INPUT` and the file stays byte-identical, `dry_run` returns the diff, and
|
|
502
|
+
several edits are all validated before any is written. `edit` stays the default.
|
|
503
|
+
- **`busybox_run`** — `bash` with retrievable evidence: the capture is complete even
|
|
504
|
+
when the view is trimmed, so `run_id` fetches the lines that were left out. A
|
|
505
|
+
nonzero `exit_code` is reported as the command's status, never as a tool failure.
|
|
506
|
+
`bash` stays the default.
|
|
507
|
+
|
|
508
|
+
Each tool spawns the packaged binary and formats the JSON it prints; none of the
|
|
509
|
+
guarantees (byte budget, `flock`, process-group cleanup, 0600 artifacts) is
|
|
510
|
+
re-implemented in TypeScript, so the plugin and the binary cannot disagree about
|
|
511
|
+
what "stale" or "truncated" means. Cancelling a tool call sends TERM to the applet
|
|
512
|
+
and KILL after two seconds, and the applet cleans up its own process group.
|
|
513
|
+
|
|
514
|
+
The exact argv, JSON field names, exit codes and payload shapes this plugin depends
|
|
515
|
+
on are written down for the upstream repository in
|
|
516
|
+
[`BUSYBOX-CONTRACT.md`](./BUSYBOX-CONTRACT.md), with
|
|
517
|
+
`scripts/capture-busybox-contract.sh` to re-capture them from any build. Two shapes
|
|
518
|
+
in that document differ from the binary's own design notes and are only right there
|
|
519
|
+
because they were captured: `peek`'s `next` is `{"from_byte":N}`, not a number, and
|
|
520
|
+
a zero-match `replace` answers `INVALID_ARGUMENT` with an empty message rather than
|
|
521
|
+
`NOT_FOUND`.
|
|
522
|
+
|
|
523
|
+
**Known build bug in the packaged binary:** `run --format json` prints an invalid
|
|
524
|
+
payload when the view is truncated (the head and the tail become two adjacent quoted
|
|
525
|
+
strings). The metadata is intact and the capture is complete, so `busybox_run`
|
|
526
|
+
recovers the fields and points at `run_id` for the view; it never re-runs the
|
|
527
|
+
command, because that repeats its side effects. `log --format json` and
|
|
528
|
+
`peek --format json` are unaffected.
|
|
529
|
+
|
|
183
530
|
## Verification
|
|
184
531
|
|
|
185
532
|
Every archive is checked against the sha256 digest GitHub records for the
|
|
@@ -283,11 +630,15 @@ export PATH="$HOME/.pi/agent/bin:$PATH" # add to ~/.zshrc or ~/.bashrc
|
|
|
283
630
|
|
|
284
631
|
Because pi searches that directory first, a managed copy **shadows** a copy you
|
|
285
632
|
installed yourself with Homebrew, cargo, `uv`, or a version manager. That is the
|
|
286
|
-
point for `fd`/`rg`/`bat`; if you deliberately pin `prek`
|
|
633
|
+
point for `fd`/`rg`/`bat`; if you deliberately pin `prek` to a specific
|
|
287
634
|
version, check `/managed-tools` before assuming which binary ran.
|
|
288
635
|
|
|
289
636
|
## What a session start does
|
|
290
637
|
|
|
638
|
+
0. `PATH` is rebuilt as `<agent dir>/bin : <agent dir>/busybox-applets : rest`, and
|
|
639
|
+
the applet directory is re-synced against the installed busybox (one
|
|
640
|
+
`busybox --list`, a readdir, and only symlinks touched). Local, so it happens
|
|
641
|
+
even when no network check is due.
|
|
291
642
|
1. A managed binary is missing, or the last check is older than the interval:
|
|
292
643
|
resolve `https://github.com/<repo>/releases/latest` (the redirect, not the
|
|
293
644
|
rate-limited API; the API is only a fallback).
|
|
@@ -304,9 +655,8 @@ Status lines are shown in the TUI only when something changed. Print mode
|
|
|
304
655
|
(`pi -p`) still updates, silently.
|
|
305
656
|
|
|
306
657
|
A tool with no release for the current platform is skipped and does **not**
|
|
307
|
-
force a check on every start. `
|
|
308
|
-
|
|
309
|
-
keep working. `sd` has no Windows arm64 build either, `busybox` has no Windows
|
|
658
|
+
force a check on every start. `sd` publishes no `aarch64-pc-windows-msvc` archive, so
|
|
659
|
+
on Windows on ARM it is reported as unsupported while the others keep working. `sd` has no Windows arm64 build either, `busybox` has no Windows
|
|
310
660
|
build at all, and `difftastic` uses the gnu Linux build because it publishes no
|
|
311
661
|
linux-arm64 musl asset.
|
|
312
662
|
|
|
@@ -318,9 +668,32 @@ linux-arm64 musl asset.
|
|
|
318
668
|
| `PI_MANAGED_TOOLS_INTERVAL_HOURS` | `12` | Minimum hours between startup checks; `0` checks every start |
|
|
319
669
|
| `PI_MANAGED_TOOLS_ALLOW_UNVERIFIED` | unset | `1`/`true`/`yes` installs an archive whose digest cannot be confirmed |
|
|
320
670
|
| `PI_MANAGED_TOOLS_REWRITE` | on | `off`/`0`/`false` disables rewriting absolute tool paths in bash tool calls |
|
|
671
|
+
| `PI_MANAGED_TOOLS_WRAP` | on | `off`/`0`/`false` stops wrapping bash commands (no timeline, no unbuffered environment) |
|
|
672
|
+
| `PI_MANAGED_TOOLS_VERBOSITY` | `normal` | `quiet` (6 KB view), `normal` (48 KB), `verbose` (49 KB, the most pi passes on) or `brief` (repeats collapsed, no timeline); `/managed-tools verbosity` overrides it for one session |
|
|
673
|
+
| `PI_MANAGED_TOOLS_EXTRA_ENV` | unset | Extra `NAME=VALUE,NAME2=VALUE2` pairs for wrapped commands, after the wrapper's own, so a pair here wins (`STDBUF1=F`) |
|
|
674
|
+
| `PI_MANAGED_TOOLS_UNBUFFER` | on | `off` leaves every program's output buffering as it is (see Buffering) |
|
|
675
|
+
| `PI_MANAGED_TOOLS_PRELOAD` | off | `on` preloads GNU coreutils' `libstdbuf.so` on Linux so C-stdio programs line-buffer too |
|
|
676
|
+
| `PI_MANAGED_TOOLS_GUARD` | on | `off` disables both refusals: a stream merge at a command's tail, and a command that cannot end |
|
|
677
|
+
| `PI_MANAGED_TOOLS_COMPACT_STAMPS` | on | `off` prints the full offset on every line instead of `[= out]` within a burst |
|
|
678
|
+
| `PI_MANAGED_TOOLS_AGE_OUT` | on | `off` keeps the offsets of results older than the latest compaction |
|
|
679
|
+
| `PI_MANAGED_TOOLS_USER_STDIN` | on | `off` runs `!` commands as before: stdin empty, output at exit |
|
|
680
|
+
| `PI_MANAGED_TOOLS_STDIN_TIMEOUT` | `300` | Seconds a `!` command may wait for you to answer before it is stopped; `0` waits for ever |
|
|
681
|
+
| `PI_MANAGED_TOOLS_APPLETS` | `core` | BusyBox applet names to link into `<agent dir>/busybox-applets`: `core` (curated), `all` (every applet except the never-list), `off` (none) |
|
|
321
682
|
| `GITHUB_TOKEN` / `GH_TOKEN` | unset | Optional. Raises the 60/hour anonymous quota used to read release digests |
|
|
322
683
|
| `PI_OFFLINE` | unset | Same `1`/`true`/`yes` values pi itself honours; disables startup checks |
|
|
323
684
|
|
|
685
|
+
Every one of these can also be set once, in pi's own settings file (global or project),
|
|
686
|
+
under a `managedTools` block — an exported variable still wins for one run:
|
|
687
|
+
|
|
688
|
+
```json
|
|
689
|
+
{ "managedTools": { "verbosity": "quiet", "timeout": 300, "preload": true, "extraEnv": "STDBUF1=F" } }
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
The keys are `wrap`, `verbosity`, `pty`, `timeout`, `idle`, `guard`, `unbuffer`, `preload`,
|
|
693
|
+
`extraEnv`, `userWrap`, `userStdin`, `stdinTimeout`, `compactStamps`, `ageOut` and `rewrite`.
|
|
694
|
+
A `/managed-tools verbosity` or `pty` switch is recorded in the session, so a resumed
|
|
695
|
+
session keeps it.
|
|
696
|
+
|
|
324
697
|
## Platform support
|
|
325
698
|
|
|
326
699
|
Downloads match what pi would have fetched itself:
|
|
@@ -337,7 +710,6 @@ Rust triple convention and are handled per tool:
|
|
|
337
710
|
|
|
338
711
|
| Tool | Asset scheme | Notable gaps |
|
|
339
712
|
|---|---|---|
|
|
340
|
-
| `rtk` | `rtk-oss-<rust triple>` | no Windows arm64 |
|
|
341
713
|
| `gron` | `gron-<os>-<go arch>-<version>.tgz` (`.zip` on Windows) | no 32-bit arm |
|
|
342
714
|
| `shellcheck` | `shellcheck-v<ver>.<os>.<arch>.tar.gz` | one arch-less `.zip` for Windows x64 only |
|
|
343
715
|
| `ast-grep` | `app-<rust triple>.zip` (zip on every platform) | none |
|
|
@@ -363,8 +735,9 @@ Rust triple convention and are handled per tool:
|
|
|
363
735
|
installed version is recorded in the state file rather than read back from the
|
|
364
736
|
binary.
|
|
365
737
|
|
|
366
|
-
`rtk` is installed
|
|
367
|
-
|
|
738
|
+
`rtk` is **no longer installed** by this package (see the note below the table). It
|
|
739
|
+
used to come from the `rtk-oss-` family — the plain `rtk-<target>` release bundles a
|
|
740
|
+
BUSL-1.1 engine (`LICENSE-ENGINE`), which is why the OSS build was used. `rtk-oss-` is the
|
|
368
741
|
Apache-2.0-only build of the same tool, with the same binary name and version
|
|
369
742
|
banner. Nothing here is redistributed — the binary is fetched from GitHub on the
|
|
370
743
|
user's own machine — but the distinction is kept explicit so the default install
|
|
@@ -374,16 +747,72 @@ is not silently pulling a source-available component.
|
|
|
374
747
|
|
|
375
748
|
```
|
|
376
749
|
package.json pi manifest: loads src/extension.ts
|
|
377
|
-
src/extension.ts session_start check,
|
|
378
|
-
src/tools.ts registry, release targets, digests, download/extract/install, cooldown
|
|
750
|
+
src/extension.ts session_start check, PATH + applet sync, command and tools
|
|
751
|
+
src/tools.ts registry, release targets, digests, download/extract/install, cooldown,
|
|
752
|
+
busybox applet directory and PATH ordering
|
|
753
|
+
src/agentops.ts the agent-facing wrappers: argv, JSON, formatters, salvage, cancellation
|
|
754
|
+
BUSYBOX-CONTRACT.md what the binary must keep providing (handed to the busybox repo)
|
|
379
755
|
skills/managed-tools/ always-advertised short skill
|
|
380
756
|
skills/managed-tools-reference/ exact flags and examples per tool
|
|
381
757
|
tests/tools.test.ts offline tests: fixtures are real archives served by a fake fetch
|
|
382
758
|
tests/extension.test.ts loads the extension against a stand-in pi and agent directory
|
|
759
|
+
tests/agentops.test.ts wrapper argv/formatters plus a stand-in multicall binary
|
|
383
760
|
tests/skills.test.ts keeps the two skills in step with the tool registry
|
|
384
761
|
scripts/verify.sh runs the installed plugin inside the pi on PATH
|
|
762
|
+
scripts/capture-busybox-contract.sh re-captures every invocation and payload
|
|
385
763
|
```
|
|
386
764
|
|
|
765
|
+
## Does Pi-Time help the model?
|
|
766
|
+
|
|
767
|
+
A paired probe answers it with numbers instead of opinion: `npm run measure:timing`
|
|
768
|
+
(`-- --runs N`, `-- --keep`). One command (prints at 0 s, warns on stderr at 2 s, prints at
|
|
769
|
+
8 s) plus five questions whose answers are known, run with the wrapper on and off, same
|
|
770
|
+
model, alternating order.
|
|
771
|
+
|
|
772
|
+
| fact | wrapped | plain capture |
|
|
773
|
+
|---|---|---|
|
|
774
|
+
| order of the stderr line vs the first stdout line | 3/3 | **0/3** — reports "before", truth is "after" |
|
|
775
|
+
| which stream carried the warning | 3/3 | 3/3 (a lucky prior) |
|
|
776
|
+
| seconds between first and last line | 3/3 | 0/3 |
|
|
777
|
+
| where the longest silence was | 3/3 | 1/3 |
|
|
778
|
+
| streamed or flushed at exit | 3/3 | 1/3 |
|
|
779
|
+
| **total** | **15/15** | **5/15** |
|
|
780
|
+
|
|
781
|
+
The plain arm is wrong rather than vague: block-buffered stdout only appears at exit, so
|
|
782
|
+
the merged capture shows the stderr line first and a reader repeats that. The script prints
|
|
783
|
+
the observed order for each arm (`on: phase1 first (true order)` / `off: deprecated first
|
|
784
|
+
(inverted)`), so that claim is one command away rather than a claim about a temp file. The
|
|
785
|
+
timing questions come back as "undetermined — no timestamps". Both arms used one bash call,
|
|
786
|
+
so this is about the quality of one answer, not extra turns.
|
|
787
|
+
|
|
788
|
+
n=3, one model, one prompt shape — it shows the direction and the mechanism, not an effect
|
|
789
|
+
size. One trap for anyone re-running it: a probe launched from inside a wrapped bash call
|
|
790
|
+
inherits `PYTHONUNBUFFERED=1` and the plain arm silently becomes unbuffered; the script
|
|
791
|
+
strips the wrapper's variables first.
|
|
792
|
+
|
|
793
|
+
## Testbench
|
|
794
|
+
|
|
795
|
+
`npm test` covers the pure logic against stand-ins. `npm run testbench` drives the
|
|
796
|
+
*installed* extension through pi's real bash engine and the real busybox — no model in the
|
|
797
|
+
loop — so a failure is a bug rather than a prompt misunderstanding:
|
|
798
|
+
|
|
799
|
+
```sh
|
|
800
|
+
npm run testbench # 17 scenarios, ~30s
|
|
801
|
+
npm run testbench -- --list
|
|
802
|
+
npm run testbench -- --only pty # scenarios whose name matches
|
|
803
|
+
npm run testbench -- --verbose # every check, not only the failures
|
|
804
|
+
npm run testbench -- --keep # keep the scratch dirs
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
Each scenario runs in its own process with its own scratch `<agent dir>` — containing a
|
|
808
|
+
space, on purpose — and its own `TMPDIR`, so the wrapper's quoting, the applet symlinks and
|
|
809
|
+
the run-artifact sweep are exercised the way a real install exercises them. The checks
|
|
810
|
+
assert on tool results and exit codes, never on what a model said.
|
|
811
|
+
|
|
812
|
+
It found: an empty busybox silently silencing every command, zip installs broken by the
|
|
813
|
+
plugin's own `unzip` symlink, a truncated view with no way back, `busybox_run` losing its
|
|
814
|
+
timeline and looking for a match in stdout only, and unbounded run artifacts.
|
|
815
|
+
|
|
387
816
|
## Tests
|
|
388
817
|
|
|
389
818
|
```bash
|