@rob-c/pi-managed-tools 0.0.0-stage → 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 +775 -0
- package/LICENSE +338 -0
- package/README.md +849 -2
- package/package.json +79 -5
- package/skills/busybox-applets/SKILL.md +266 -0
- package/skills/managed-tools/SKILL.md +328 -0
- package/skills/managed-tools-reference/SKILL.md +738 -0
- 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 +1229 -0
- package/src/guard.ts +437 -0
- package/src/jobs.ts +1052 -0
- package/src/timing.ts +364 -0
- package/src/tools.ts +2223 -0
- package/src/userstdin.ts +524 -0
- package/src/wrap.ts +683 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: managed-tools
|
|
3
|
+
description: "Prefer this toolkit over the system binaries: it is the pinned set, first on PATH. Wrap multi-step shell logic as `busybox sh -c '...'`; plain bash only for arrays, ${v^^} or mapfile. Every bash result is a `[00000.012345789 out]`-prefixed ns timeline, and a slow run gets a `timing:` digest line; prefix a command with `command` for byte-exact output. BusyBox applet names are bare on PATH (`xxd`, `hexdump`, `brief`, `peek`, `waitfor`, `json`, `snapshot`); `sed`/`grep`/`find`/`awk`/`tar` are not. Versioned reads: busybox_peek. Guarded edits: busybox_replace. Captured runs: busybox_run. Prefer rg over grep, fd over find, bat over cat (bat -n -r A:B reads a line range), jq for JSON, gron to explore it, ast-grep over regex edits, just/ninja over guessed builds, shellcheck for shell, prek for hooks. Never `2>&1` — it merges the streams before the timeline can tag them. Call them by bare name: the packaged copy is first on PATH. Flags and which write: managed-tools-reference. Busybox safety: busybox-applets."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Managed tools
|
|
7
|
+
|
|
8
|
+
Twenty-four binaries on `PATH`, installed and version-tracked by `pi-managed-tools`.
|
|
9
|
+
Their flags are fully known — load `managed-tools-reference` instead of running
|
|
10
|
+
`--help`.
|
|
11
|
+
|
|
12
|
+
fd 10.5.2 · rg 15.2.0 · bat 0.26.1 · just 1.59.0 · gron 0.7.1 ·
|
|
13
|
+
shellcheck 0.11.0 · ast-grep 0.51.3 · ninja 1.13.2 · prek 0.5.11
|
|
14
|
+
jq 1.8.2 · yq 4.54.3 · fzf 0.75.0 · uv 0.13.9 · gh 2.105.0 · bd 1.3.4
|
|
15
|
+
agent-browser 0.43.0 · ruff 0.17.6 · mise 2026.11.11
|
|
16
|
+
scc 4.1.0 · duckdb 2.0.1 · miller 6.22.0 · sd 1.1.0 · difftastic 0.72.0
|
|
17
|
+
busybox 1.39.0 (236 applets — see busybox-applets)
|
|
18
|
+
|
|
19
|
+
## Start here
|
|
20
|
+
|
|
21
|
+
Before exploring an unfamiliar repo, spend one command on how this CLI is wired.
|
|
22
|
+
Skipping it is how a small model ends up with inconsistent results and blames the
|
|
23
|
+
code instead of the environment.
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
busybox sh -c 'echo "PATH0=${PATH%%:*}"; command -v rg fd jq bat scc busybox'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Read it as three facts, then continue:
|
|
30
|
+
|
|
31
|
+
1. **`PATH0` is `<agent dir>/bin`** → the packaged binaries are what run. If it is
|
|
32
|
+
not, say so once (see *Which binary runs*) and keep using bare names anyway.
|
|
33
|
+
2. **Every tool resolves under `<agent dir>/bin`** → versions are the ones in the
|
|
34
|
+
version list above, not the host's.
|
|
35
|
+
3. **`busybox` is present** → multi-step shell logic can use `busybox sh -c '…'`,
|
|
36
|
+
and the applet names listed under *Which binary runs* are bare on `PATH`.
|
|
37
|
+
|
|
38
|
+
Do not re-derive this per step: once at the start is enough, and re-checking it
|
|
39
|
+
mid-task is how a session drifts back to `awk`/`python3 -c`.
|
|
40
|
+
|
|
41
|
+
## Order of preference
|
|
42
|
+
|
|
43
|
+
1. **These binaries over system ones** — they are the same tools, newer, and already on
|
|
44
|
+
`PATH` ahead of `/usr/bin`.
|
|
45
|
+
2. **`brief` when output is long** — `busybox brief -d` collapses repeats without cutting
|
|
46
|
+
a record in half, and `busybox_run` keeps the full capture so nothing is lost.
|
|
47
|
+
3. Plain commands only when you need the bytes exactly as written.
|
|
48
|
+
|
|
49
|
+
This holds for one-liners as much as for whole tasks: a 25-line excerpt is still
|
|
50
|
+
read with `bat`, a single JSON field is still extracted with `jq`, a directory
|
|
51
|
+
listing is still `fd`. Reaching for `awk`/`sed`/`python3 -c`/`cat` skips a tool
|
|
52
|
+
that is already installed and documented.
|
|
53
|
+
|
|
54
|
+
## Which binary runs
|
|
55
|
+
|
|
56
|
+
Use the bare name — `jq`, `gh`, `rg`, `bat`, `scc` — never an absolute path such as
|
|
57
|
+
`/usr/bin/jq`, `/opt/homebrew/bin/gh` or `/Users/<you>/.pi/agent/bin/rg`. The
|
|
58
|
+
packaged copy is already first on `PATH` in every bash call, so the bare name
|
|
59
|
+
resolves to it; an absolute path is how you silently pick the host's older build
|
|
60
|
+
(`/usr/bin/jq` is 1.7.1 on this class of machine, the packaged one is 1.8.2).
|
|
61
|
+
|
|
62
|
+
Check rather than assume: `command -v jq` should print `<agent dir>/bin/jq`.
|
|
63
|
+
|
|
64
|
+
This package sets `PATH` itself at session start —
|
|
65
|
+
`<agent dir>/bin : <agent dir>/busybox-applets : everything else` — so it holds even
|
|
66
|
+
when a shell rc appended the agent bin instead of prepending it. If `command -v jq`
|
|
67
|
+
still prints a host path, do not work around it with an absolute path and do not
|
|
68
|
+
`export PATH=…` in a command (each bash call is a fresh shell): report it and show
|
|
69
|
+
`/managed-tools status`.
|
|
70
|
+
|
|
71
|
+
BusyBox applet names are bare on `PATH` too — `xxd`, `hexdump`, `od`, `strings`,
|
|
72
|
+
`sha256sum` and the other `sha*sum`s, `base64`, `gzip`/`gunzip`/`unzip`, `cpio`,
|
|
73
|
+
`dpkg-deb`, `rpm2cpio`, `timeout`, `setsid`, `nproc`, `realpath`, `seq`, `nl`,
|
|
74
|
+
`paste`, `ts`. `sed`, `grep`, `find`, `awk`, `tar`, `diff`, `ls`, `cp`, `rm`,
|
|
75
|
+
`stat`, `date`, `patch` and `sh` are **not** shadowed, so those keep the host
|
|
76
|
+
build: write `busybox sed …` when you want busybox.
|
|
77
|
+
|
|
78
|
+
One exception: an absolute path is correct when the task is to *inspect* the host
|
|
79
|
+
copy ("is `/usr/bin/jq` older?"). That is a deliberate comparison, not a choice of
|
|
80
|
+
which binary to run — say which one you are running and why.
|
|
81
|
+
|
|
82
|
+
## Shell
|
|
83
|
+
|
|
84
|
+
Run multi-step shell logic through **`busybox sh`**, not the ambient shell. It is the
|
|
85
|
+
same static ash binary on every platform this package supports, so a command means
|
|
86
|
+
the same thing everywhere and does not depend on which bash is installed, whether
|
|
87
|
+
`/bin/bash` exists, or what the user's zsh does.
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
busybox sh -c 'for f in src/*.ts; do echo "$f $(wc -l < "$f")"; done'
|
|
91
|
+
busybox sh <<'EOF'
|
|
92
|
+
set -eu
|
|
93
|
+
for d in skills/*/; do echo "$(basename "$d")"; done
|
|
94
|
+
EOF
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
busybox ash is POSIX plus extensions, so these work: `[[ ]]`, `<(…)`, `<<<`, `$'…'`,
|
|
98
|
+
`local`, `function`, `set -o pipefail`, `${v//a/b}`, `${v:1:2}`, `printf -v`,
|
|
99
|
+
`trap … ERR`, `$RANDOM`.
|
|
100
|
+
|
|
101
|
+
These do **not** work — for one of these, drop the prefix and let pi's own shell run
|
|
102
|
+
the command (`/bin/bash` on macOS, `sh`/`bash` from `PATH` on Linux), and say why:
|
|
103
|
+
|
|
104
|
+
- arrays: `a=(1 2)`, `a+=(x)`, `declare -A`
|
|
105
|
+
- `${v^^}` / `${v,,}` case modification
|
|
106
|
+
- `read -a`, `mapfile` / `readarray`
|
|
107
|
+
- `coproc`, `extglob` (`@(…)`)
|
|
108
|
+
|
|
109
|
+
Quoting: pi runs your command through its own shell first, so `busybox sh -c '…'` is
|
|
110
|
+
nested. Use double quotes inside it, or the heredoc form for anything long.
|
|
111
|
+
|
|
112
|
+
## Before anything that writes
|
|
113
|
+
|
|
114
|
+
`managed-tools-reference` carries a read-only vs mutating table for all twenty-five
|
|
115
|
+
tools. Check it before any command that can rewrite, delete or upload — several
|
|
116
|
+
mutate with **no flag at all** (`sd`, `ruff format`, `just`, `ninja`, `uv run`,
|
|
117
|
+
`duckdb FILE`, `agent-browser open`). Prefer the dry run: `just -n`, `ninja -n`,
|
|
118
|
+
`uv --dry-run`, `mise -n`, `prek run --dry-run`, `bd --readonly`,
|
|
119
|
+
`duckdb -readonly`, `sd -p`, `ast-grep` without `-U`.
|
|
120
|
+
|
|
121
|
+
## Every command comes back as a timeline
|
|
122
|
+
|
|
123
|
+
This is **Pi-Time**: the wrapper attaches time itself — stream, offset, deadline — to
|
|
124
|
+
every execution, because a plain capture cannot say which stream a line came from, when it
|
|
125
|
+
arrived, or how long is too long.
|
|
126
|
+
|
|
127
|
+
pi's `bash` tool is re-registered so each command runs through
|
|
128
|
+
`busybox run --timestamps`: one interleaved line per record, with its offset in seconds and
|
|
129
|
+
the stream it arrived on.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
[0.011354789 out] ok 1
|
|
133
|
+
[= out] ok 2
|
|
134
|
+
[2.320004125 err] FAILED test_x
|
|
135
|
+
[8.421130000 out] done
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`[= out]` is a line that arrived at the same offset as the one above it: within a burst
|
|
139
|
+
the offset is printed once, and the stream tag stays on every line. (An older build pads
|
|
140
|
+
the number — `[ 0.011354 out]` — and it is the same field.)
|
|
141
|
+
|
|
142
|
+
That is the ordering information a merged stdout/stderr block throws away: the failure
|
|
143
|
+
came *after* `ok 1` and *before* `done`, and a burst of lines sharing one timestamp means
|
|
144
|
+
the writer flushed at exit rather than streaming. Read the offsets before concluding
|
|
145
|
+
anything about causality.
|
|
146
|
+
|
|
147
|
+
- The child gets a split pseudo-terminal: stdout is a tty, so Python, Node, Ruby, C
|
|
148
|
+
stdio and Java line-buffer and their lines carry real intervals; stderr stays a pipe
|
|
149
|
+
and keeps its `err` tag. `isatty()` is therefore **true** — a program that takes a
|
|
150
|
+
different path when interactive will take it here.
|
|
151
|
+
- The timeline is for you. The human watching sees the same output with the prefixes
|
|
152
|
+
stripped, so do not strip or re-print them yourself. A run over a second also gets a
|
|
153
|
+
`timing:` line (total, where output began, the longest silence) — that is the quickest
|
|
154
|
+
way to see where the time went.
|
|
155
|
+
- **Byte-exact output, rarely**: prefix one `&&`/`;` segment with `command`
|
|
156
|
+
(e.g. `command sha256sum f`) and it runs unwrapped — no timeline, no stream tags, no
|
|
157
|
+
timing. That is the point, so do not do it by reflex: keep the timeline unless a
|
|
158
|
+
consumer genuinely needs exact bytes.
|
|
159
|
+
- The wrapper keeps the child's exit status, cwd, shell and environment; it adds
|
|
160
|
+
`PYTHONUNBUFFERED=1`, `NO_COLOR=1`, `TERM=dumb`, `PAGER=cat`, `MAVEN_ARGS=-B -ntp`,
|
|
161
|
+
`GRADLE_OPTS=...console=plain` and a Ruby prelude through `RUBYOPT`, so runtimes stream
|
|
162
|
+
what they can and draw no progress bars.
|
|
163
|
+
- A truncated view is retrievable: `busybox_run run_id=<R> match=<literal>` or
|
|
164
|
+
`busybox log <R> --stream timeline`.
|
|
165
|
+
- **Never `2>&1`** (nor `>&2 2>&1`, `|&`, `2>&1 |`). It merges stderr into stdout *inside
|
|
166
|
+
the child*, before the wrapper can tag anything, so every line arrives `[out]` and the
|
|
167
|
+
warning you needed to see as `[err]` loses its identity — it defeats Pi-Time. The two
|
|
168
|
+
streams are captured separately already: keep them separate and read the tags. Use the
|
|
169
|
+
replacement, not the reflex: to silence noise, drop only the stream you do not want
|
|
170
|
+
(`cmd >/dev/null` keeps stderr tagged; `cmd 2>/dev/null` keeps stdout); to filter
|
|
171
|
+
stderr, run the command plainly and read the `[err]` lines, or re-read a past run with
|
|
172
|
+
`busybox log <R> --stream stderr --match <literal>`; to log a background server, two
|
|
173
|
+
files — `cmd >srv.log 2>srv.err &` — never `>srv.log 2>&1 &`, so a crash report in the
|
|
174
|
+
log keeps its identity as stderr when you read it back. For a quiet test of a command's
|
|
175
|
+
exit status, `cmd >/dev/null` is enough (its stderr stays tagged); for "is a port
|
|
176
|
+
ready", `waitfor --tcp host:port` — not `lsof >/dev/null 2>&1`.
|
|
177
|
+
- **The guard enforces the tail reflex.** A merge at the very end of a command (last
|
|
178
|
+
couple of lines) is refused *before running*: the call comes back blocked with the
|
|
179
|
+
rewrite, so write the replacement instead of retrying the same text. A merge buried
|
|
180
|
+
deep inside a script you authored is left alone; if you genuinely want a merge and will
|
|
181
|
+
not read that output back as evidence, append `# pitime-safe` and the result will say
|
|
182
|
+
its tags are not evidence.
|
|
183
|
+
- **What a result cannot show, it says.** A command that discards a stream
|
|
184
|
+
(`>/dev/null`, `2>/dev/null`), leaves a process in the background, or ran unwrapped
|
|
185
|
+
via `command` gets a line on its result naming exactly what you cannot know from it.
|
|
186
|
+
A pipeline ending in `grep`, `head`/`tail`, or a `|| true` mask gets a line saying whose
|
|
187
|
+
exit code the header shows (grep's 1 = "no match"; `head` SIGPIPEs the command).
|
|
188
|
+
- **Two facts about the shell, worth knowing before they bite**: each bash call starts
|
|
189
|
+
fresh in the session's cwd — `cd` does not persist between calls; and a command's stdin
|
|
190
|
+
is empty: a read returns end-of-file at once, so a prompt (`[y/N]`, a password) takes
|
|
191
|
+
its default or fails instead of waiting, and nobody can answer it. Put the answer in the
|
|
192
|
+
command (`printf 'y\n' | cmd`, `cmd < file`, a heredoc, a `--yes` flag) or in
|
|
193
|
+
`busybox_run`'s `stdin`.
|
|
194
|
+
- Every command has a **120s default deadline**, plus a **120s silence watchdog**: a
|
|
195
|
+
command that produces *no output* for 120s is killed even under a raised deadline, and
|
|
196
|
+
its result says `IDLE — not a failure of the command and not a timeout … this was a
|
|
197
|
+
hang, not slow work` — never stdin (it is empty; a read ends at once), so look at a
|
|
198
|
+
socket, a lock, or a child process that never exits.
|
|
199
|
+
When the deadline fires the result says `TIMEOUT — not a failure of the command`: the
|
|
200
|
+
command was killed for overrunning, it did not error. Genuinely long work? Raise
|
|
201
|
+
`timeout` (seconds) on the bash call, narrow the command, or background it and poll
|
|
202
|
+
with `waitfor`. The partial capture is complete — read it with `busybox log <R>` before
|
|
203
|
+
deciding.
|
|
204
|
+
|
|
205
|
+
Verbosity is per session: `managed_tools` with action `verbosity` (or
|
|
206
|
+
`/managed-tools verbosity`) takes `quiet` (6 KB view), `normal` (48 KB, the default),
|
|
207
|
+
`verbose` (49 KB, the most pi passes on) or `brief` (repeats collapsed, no timeline). `PI_MANAGED_TOOLS_WRAP=off`
|
|
208
|
+
turns the wrapper off entirely.
|
|
209
|
+
|
|
210
|
+
Reading a result, in the order it is laid out:
|
|
211
|
+
|
|
212
|
+
- **A first line in capitals is how it ended, when that was not the command's own exit**:
|
|
213
|
+
`TIMEOUT`, `IDLE`, `CANCELLED`, `KILLED`. Nothing failed; the notice says what to do.
|
|
214
|
+
- **`truncated=true` means the middle is missing.** The view keeps the head and the tail
|
|
215
|
+
with a `... [timeline truncated: …] ...` line between them. The line after the result
|
|
216
|
+
names the omitted lines, the `busybox log <R> --stream timeline --lines A:B` that reads
|
|
217
|
+
from them, and how many of them are on stderr — do not conclude "no errors" from a view
|
|
218
|
+
whose omitted part holds stderr lines.
|
|
219
|
+
- **`pipeline stage statuses: 1 141 0`** is each stage's own exit status, in order; the
|
|
220
|
+
header's `exit_code` is the last one. 141 is a stage cut off because the next one stopped
|
|
221
|
+
reading (`head`), not a failure. No such line means every stage exited 0.
|
|
222
|
+
- **`this command ended in <dir>`** is where a `cd` left it; the next call starts back in
|
|
223
|
+
the session's directory.
|
|
224
|
+
|
|
225
|
+
Three things cannot work in a bash call, because nobody can press a key: answering a
|
|
226
|
+
prompt (stdin is empty — put the answer in the command), a pager or an editor, and anything
|
|
227
|
+
that never ends (`tail -f`, `watch`, a foreground server). The last two are refused before
|
|
228
|
+
they run, with what to write instead. For a command that must keep running, use
|
|
229
|
+
**`busybox_job`**: `action: "start"` with `shell` and a `wait_for` readiness line, then
|
|
230
|
+
`action: "status"` for the output that is new (stderr lines start `err| `), and
|
|
231
|
+
`action: "stop"` when done.
|
|
232
|
+
|
|
233
|
+
## Guarded reads, edits and runs
|
|
234
|
+
|
|
235
|
+
Three tools wrap the packaged busybox agent applets. Each exists because the built-in
|
|
236
|
+
it resembles cannot do one thing:
|
|
237
|
+
|
|
238
|
+
| need | tool | why not the built-in |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| read a file you are about to edit | `busybox_peek` | returns the file sha256 with the lines, so a later edit can be refused if the file moved |
|
|
241
|
+
| edit with a version guard | `busybox_replace` | a stale sha256 is `STALE_INPUT` and the file stays byte-identical; `dry_run` prints the diff; every edit is validated before anything is written |
|
|
242
|
+
| run something whose output you may need twice | `busybox_run` | stdout and stderr go to artifacts, so `run_id` retrieves lines the bounded view left out; a nonzero `exit_code` is the command status, not a tool failure |
|
|
243
|
+
|
|
244
|
+
Read with `read`, edit with `edit`, run with `bash` when none of those three things
|
|
245
|
+
matter - they are the defaults, and a versioned read costs a call you may not need.
|
|
246
|
+
|
|
247
|
+
The same applets are bare commands for shell work: `peek file -l 20:40`,
|
|
248
|
+
`waitfor --tcp 127.0.0.1:8080`, `doctor`. `replace`, `run`, `log`, `json`, `bench`,
|
|
249
|
+
`snapshot` and `check` are reached as `busybox <applet>` because those words are too generic
|
|
250
|
+
to put ahead of the host.
|
|
251
|
+
|
|
252
|
+
Seven more applets exist for jobs that otherwise become a `python3 -c` one-liner — reach for
|
|
253
|
+
them before writing a script:
|
|
254
|
+
|
|
255
|
+
| instead of | use | what it gives you back |
|
|
256
|
+
|---|---|---|
|
|
257
|
+
| `sleep 5` and hope the server is up | `waitfor --tcp 127.0.0.1:8080 -T 20` | ready/not-ready as an exit code (0 ready, 3 deadline) |
|
|
258
|
+
| `python3 -c 'import json…'` | `busybox json -f pkg.json -g '.deps.react'` (`-k` keys, `-t` type, `-n` count, `-c` validate) | one value on stdout, or `INVALID_JSON at byte N` |
|
|
259
|
+
| `find … -newer` / a manual tree checksum | `busybox snapshot -d src -o before.txt`, later `busybox snapshot --diff before.txt after.txt` | `added=1 removed=0 changed=0` plus the paths |
|
|
260
|
+
| "does this patch series still parse?" | `patchcheck -d patches` | `ok <file>` lines + `checked=N bad=M` (format only, not apply) |
|
|
261
|
+
| timing a command by hand | `busybox bench -n 5 -w 1 -- ./build.sh` | `min_ms/median_ms/max_ms` and a status per run |
|
|
262
|
+
| "why is this applet missing from my build?" | `why grep --format json` | `state`, `decided_by`, and the config/prune line that decided it |
|
|
263
|
+
| "what CLI am I on?" | `doctor --deps git,python3` | platform, cwd, exe, shell, writable temp, dep paths — no environment dump |
|
|
264
|
+
|
|
265
|
+
Full flags and one worked example per applet: `managed-tools-reference`.
|
|
266
|
+
|
|
267
|
+
## Long output: timing first, reduction second
|
|
268
|
+
|
|
269
|
+
Every bash result is already a timeline, so a long run comes with its own order and
|
|
270
|
+
offsets; a run that took more than a second also gets a `timing:` line saying where the
|
|
271
|
+
time went (`3.2s total, silent 2.8s after the last line`). Read that before concluding a
|
|
272
|
+
command "hung" or "was slow": the silence usually names the phase.
|
|
273
|
+
|
|
274
|
+
When the *volume* is the problem, `brief` reduces a log to its shape without cutting a
|
|
275
|
+
record in half. Pick by the question you are asking:
|
|
276
|
+
|
|
277
|
+
| you want | command | why that flag |
|
|
278
|
+
|---|---|---|
|
|
279
|
+
| what failed | `brief -o error -o FAILED log` | selection only: every matching record, whole, nothing merged |
|
|
280
|
+
| what dominates this noise | `brief -s -t 10 log` | `-s` masks digits so lines that differ only by id/percent collapse (646 lines → 8 records, 33 500 B → 381 B on a pytest log); `-d` alone merges only *identical* lines and rarely fires |
|
|
281
|
+
| which file has the most errors | `brief -o error -c 1 -t 10 -i : log` | count instead of list; `-i :` for `path:line: error` output |
|
|
282
|
+
| one failure with its traceback | `brief -R FAILED log` | `-R` is a *literal* substring (no regex): the record starts at each match and runs to the next, so the trace and its summary stay one record |
|
|
283
|
+
| these lines verbatim | `brief -s -k FAILED log` | `-k` records are never merged |
|
|
284
|
+
|
|
285
|
+
Read the `[brief] …` marker line before trusting the view: `merged=N` is what collapsed,
|
|
286
|
+
`dropped_records` is what was not shown, `truncated_by=budget|selection|record_size` is
|
|
287
|
+
*why*, and `in_bytes` vs `bytes` is the saving. `-F json` returns the same numbers plus a
|
|
288
|
+
one-sentence `summary` and `hints[]` naming the flag that would change the answer.
|
|
289
|
+
|
|
290
|
+
- **Never reduce the only copy.** Keep the capture (`busybox_run`, `busybox log RUN`) and
|
|
291
|
+
reduce a view of it; a reduction is a lens, not the evidence.
|
|
292
|
+
- **Need exact bytes** (a diff you will edit, JSON you will parse, a checksum): no `brief`.
|
|
293
|
+
Use `bat --paging=never`, `git diff`, `rg`, or prefix the command with `command`.
|
|
294
|
+
- **One call for a run**: `busybox run --brief both` pipes both streams through `brief -d`.
|
|
295
|
+
`--timestamps` silently wins over `--brief` in this build, so choose one.
|
|
296
|
+
- **Unsure**: run it plainly. A re-run costs more than the tokens saved.
|
|
297
|
+
|
|
298
|
+
## Tool choice
|
|
299
|
+
|
|
300
|
+
| Instead of | Use |
|
|
301
|
+
|---|---|
|
|
302
|
+
| `find` | `fd` |
|
|
303
|
+
| `grep -r` | `rg` (add `--hidden -I` when hidden or gitignored files matter) |
|
|
304
|
+
| `cat` | `bat --paging=never` |
|
|
305
|
+
| regex edit of code | `ast-grep run -p '<pattern>'` (preview, then `-r`) |
|
|
306
|
+
| ad-hoc JSON poking | `gron`, or `jq -c` |
|
|
307
|
+
| guessing a task command | `just -l` then `just -n` |
|
|
308
|
+
| guessing a build | `ninja -t targets`, then `ninja -n` |
|
|
309
|
+
| eyeballing shell bugs | `shellcheck -f gcc` (advisory; never rewrite) |
|
|
310
|
+
| reading a line range of a file | `bat --paging=never -n -r 900:925 file` — not awk/sed/head |
|
|
311
|
+
| reading or querying JSON | `jq -r '.path'`, `jq -c 'select(...)'` — not python3 -c or grep |
|
|
312
|
+
| editing a JSON document | `busybox json -f f.json -g '.a.b' --set --json-value 42` (or `--delete`, `--dry-run` first) — guarded, no python one-liner |
|
|
313
|
+
| exploring an unknown JSON document | `gron file.json \| rg 'users'` |
|
|
314
|
+
| hand-run hooks | `prek run` (`install` mutates `.git/hooks` — confirm first) |
|
|
315
|
+
| a JSON/YAML fishing trip | `gron`, `jq -r`, or `yq -o json` |
|
|
316
|
+
| `python -m venv` + pip | `uv run <cmd>` |
|
|
317
|
+
| `curl` against the GitHub API | `gh api` |
|
|
318
|
+
| writing a picker | `fzf --filter` (interactive needs a TTY you do not have) |
|
|
319
|
+
| tracking work in a scratch file | `bd q` / `bd list` — but `bd init` rewrites `AGENTS.md`, so ask first |
|
|
320
|
+
| curl-ing a page to read it | `agent-browser read <url>`, then `open` + `snapshot` for interaction |
|
|
321
|
+
| `python -m py_compile` / eyeballing style | `ruff check --statistics`, `ruff format --check` |
|
|
322
|
+
| guessing which runtime version a repo wants | `mise exec -- <cmd>` (activation never happens in pi's bash) |
|
|
323
|
+
| counting lines of code | `scc .` (`--by-file`, `-f csv`) |
|
|
324
|
+
| awk-ing CSV or joining tables | `mlr --csv ...` or `duckdb -c "select ..."` |
|
|
325
|
+
| regex rewrite of many files | `sd -p` first, then `sd` (it edits in place) |
|
|
326
|
+
| reading a big diff | `difft --display inline` (structural, falls back to lines) |
|
|
327
|
+
| an applet this package links by bare name (`xxd`, `hexdump`, `sha256sum`, `unzip`, `timeout`, `nproc`, `cpio`) | just the name — it is on `PATH` |
|
|
328
|
+
| an applet it does not (`sed`, `grep`, `find`, `awk`, `tar`, `patch`, `tree`) | `busybox <applet>` — never `busybox --install -s` |
|