@rob-c/pi-managed-tools 0.0.0-stage → 0.16.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/README.md CHANGED
@@ -1,3 +1,421 @@
1
- # Temporary Holding Version
1
+ # pi-managed-tools
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Published as **`@rob-c/pi-managed-tools`** on npm — install with
4
+ `pi install npm:@rob-c/pi-managed-tools`. The unscoped `pi-managed-tools` name
5
+ was an earlier publish of the same code and is deprecated; do not use it.
6
+
7
+ Pi ships no `fd` and no `rg` binary. It downloads exactly two static binaries on
8
+ demand, into the directory it searches first, and uses them for two built-in
9
+ tools:
10
+
11
+ | Tool | From | Used by | Installed to |
12
+ |---|---|---|---|
13
+ | `fd` | [sharkdp/fd](https://github.com/sharkdp/fd) | the `find` tool | `<agent dir>/bin/fd` (`fd.exe` on Windows) |
14
+ | `rg` (ripgrep) | [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) | the `grep` tool | `<agent dir>/bin/rg` (`rg.exe` on Windows) |
15
+ | `bat` | [sharkdp/bat](https://github.com/sharkdp/bat) | `bash` only | `<agent dir>/bin/bat` |
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
+ | `just` | [casey/just](https://github.com/casey/just) | `bash` only | `<agent dir>/bin/just` |
19
+ | `gron` | [tomnomnom/gron](https://github.com/tomnomnom/gron) | `bash` only | `<agent dir>/bin/gron` |
20
+ | `shellcheck` | [koalaman/shellcheck](https://github.com/koalaman/shellcheck) | `bash` only | `<agent dir>/bin/shellcheck` |
21
+ | `ast-grep` | [ast-grep/ast-grep](https://github.com/ast-grep/ast-grep) | `bash` only | `<agent dir>/bin/ast-grep` and `sg` |
22
+ | `ninja` | [ninja-build/ninja](https://github.com/ninja-build/ninja) | `bash` only | `<agent dir>/bin/ninja` |
23
+ | `jq` | [jqlang/jq](https://github.com/jqlang/jq) | `bash` only | `<agent dir>/bin/jq` |
24
+ | `yq` | [mikefarah/yq](https://github.com/mikefarah/yq) (v4, Go) | `bash` only | `<agent dir>/bin/yq` |
25
+ | `fzf` | [junegunn/fzf](https://github.com/junegunn/fzf) | `bash` only | `<agent dir>/bin/fzf` |
26
+ | `uv` | [astral-sh/uv](https://github.com/astral-sh/uv) | `bash` only | `<agent dir>/bin/uv` and `uvx` |
27
+ | `gh` | [cli/cli](https://github.com/cli/cli) | `bash` only | `<agent dir>/bin/gh` |
28
+ | `bd` | [gastownhall/beads](https://github.com/gastownhall/beads) | `bash` only | `<agent dir>/bin/bd` |
29
+ | `agent-browser` | [vercel-labs/agent-browser](https://github.com/vercel-labs/agent-browser) | `bash` only | `<agent dir>/bin/agent-browser` |
30
+ | `ruff` | [astral-sh/ruff](https://github.com/astral-sh/ruff) | `bash` only | `<agent dir>/bin/ruff` |
31
+ | `mise` | [jdx/mise](https://github.com/jdx/mise) | `bash` only | `<agent dir>/bin/mise` |
32
+ | `scc` | [boyter/scc](https://github.com/boyter/scc) | `bash` only | `<agent dir>/bin/scc` |
33
+ | `duckdb` | [duckdb/duckdb](https://github.com/duckdb/duckdb) | `bash` only | `<agent dir>/bin/duckdb` |
34
+ | `miller` | [johnkerl/miller](https://github.com/johnkerl/miller) | `bash` only | `<agent dir>/bin/mlr` |
35
+ | `sd` | [chmln/sd](https://github.com/chmln/sd) | `bash` only | `<agent dir>/bin/sd` |
36
+ | `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` only | `<agent dir>/bin/busybox` (236 applets) |
38
+
39
+ That download logic lives in `dist/utils/tools-manager.js` of
40
+ `@earendil-works/pi-coding-agent`: `ensureTool()` downloads the latest release
41
+ **only when the file is missing**, and `getToolPath()` prefers `<agent dir>/bin`
42
+ over anything on `PATH`. So a machine that installed pi a year ago keeps
43
+ whatever `fd`/`rg` release it fetched then, however many newer releases exist.
44
+
45
+ This package fills that gap. On a session start (at most once per interval) it
46
+ resolves the latest release of each project, compares it with the managed copy,
47
+ and replaces the copy in place — the same path pi already uses. pi's `find` and
48
+ `grep` tools call `getToolPath()` for every run, and pi puts `<agent dir>/bin`
49
+ first on the `PATH` of every `bash` command it runs, so both see the new binary
50
+ immediately.
51
+
52
+ Note that `find` and `grep` are not enabled by default: pi's `defaultTools` is
53
+ `read`, `bash`, `edit`, `write`. Turn them on with `pi --tools +grep,+find` or
54
+ `"defaultTools": ["+grep", "+find"]` in settings (see `docs/settings.md`
55
+ inside the pi package). The binaries and the update are the same either way —
56
+ pi's interactive mode prepares them at startup regardless of which tools are
57
+ enabled.
58
+
59
+ **Only `fd` and `rg` back a pi built-in tool.** Everything else is installed so
60
+ `bash` commands can use it, and `/managed-tools` reports that distinction rather
61
+ than implying otherwise.
62
+
63
+ ### `tree` is not here
64
+
65
+ Upstream (`Old-Man-Programmer/tree`) publishes git tags but **no release
66
+ assets**, so there is no binary to download and nothing to verify. `fd -d 2 -td`
67
+ covers most of what `tree` is used for, from a binary this package already
68
+ manages.
69
+
70
+ ### Command shadowing
71
+
72
+ pi searches `<agent dir>/bin` first, so these win over anything else on `PATH`.
73
+ That is intended for `fd`/`rg`/`bat`. Two cases are worth knowing:
74
+
75
+ - `ast-grep` also installs its deprecated `sg` shim, which shadows util-linux's
76
+ `/usr/bin/sg` on Linux (the group-switching helper used by `newgrp`). Delete
77
+ `<agent dir>/bin/sg` if you need the system one.
78
+ - `git`, `python3`, `node`, `tree` and the rest of the toolchain still come from
79
+ the system. Nothing here replaces an *interpreter* — their versions belong to
80
+ each project's lockfile. `uv` is the one exception in spirit: it is a package
81
+ manager, so it creates its own Python toolchains and caches outside this bin
82
+ directory. Prefer `uv run <cmd>` so the project's pinned version is used.
83
+ - `yq` here is **mikefarah/yq v4** (Go). `kislyuk/yq` is a different tool with
84
+ different flags and no releases of this shape.
85
+ - `gh` is **credential-bearing**: it keeps an OAuth token in
86
+ `~/.config/gh/hosts.yml`. Its downloads are digest-verified like every other
87
+ tool, but auto-updating a binary that holds a token is a trust decision worth
88
+ making deliberately.
89
+ - `fzf` needs a TTY for interactive use, and pi's `bash` tool does not provide
90
+ one. `fzf --filter` works; the interactive picker does not.
91
+ - **`bd init` mutates the project.** It creates `.beads/` with an embedded Dolt
92
+ database, **rewrites `AGENTS.md` by default**, and installs editor/agent
93
+ integration files unless given `--skip-agents` or `--stealth`. `bd setup <tool>`
94
+ writes those integration files too. The read-only commands (`list`, `show`,
95
+ `status`, `query`) are safe.
96
+ - **`bd` sends anonymous usage metrics by default** — command names, version and
97
+ OS platform, not issues or paths. Set `DO_NOT_TRACK=1` to disable it. That is
98
+ the user's decision, so this package does not set it for you.
99
+ - **`agent-browser` needs a browser and leaves a daemon running.** It drives a
100
+ local Chrome/Chromium (or an existing one via `connect`), keeps state across
101
+ invocations through a background daemon, and `close --all` stops it. Its own
102
+ `agent-browser skills get core` **fails** on this build — the release binary
103
+ ships no skills directory, whatever `--help` claims. No win32-arm64 release.
104
+ - **`mise` is a version manager.** A managed copy sits ahead of whatever the user
105
+ installed, and its `activate` shell hook never runs in pi's `bash`, so only
106
+ `mise exec -- <cmd>` reliably picks up a project's pins. It installs toolchains
107
+ under `~/.local/share/mise`, outside this bin directory. This is the one entry
108
+ here that deliberately manages a tool whose job is managing other versions.
109
+ - **`busybox` is a multicall binary** that dispatches on `argv[0]`, so it is only
110
+ installed under the name `busybox` — renaming or copying it breaks every applet.
111
+ Use it as `busybox <applet>`. **Never run `busybox --install -s <dir>`**: in pi's
112
+ bin directory, which is first on `PATH`, that would put 236 applets ahead of the
113
+ real coreutils, and busybox `sed`/`grep`/`find`/`tar` are not GNU-compatible.
114
+ Per-applet read-only vs mutating classification is in the `busybox-applets` skill.
115
+ - **`sd` rewrites files in place.** With no file arguments it filters stdin to
116
+ stdout, but `sd FIND REPLACE file...` edits those files. Use `-p` to preview.
117
+ Its release binary also reports `sd 1.0.0` for tag `v1.1.0`; the tag is trusted
118
+ for version comparison (the digest already proves the asset), so it does not
119
+ reinstall in a loop.
120
+ - **`duckdb` prints an agent-mode banner** before every result when `AI_AGENT` is
121
+ set and stdout is not a terminal — which is always true inside pi. Pass
122
+ `-no-agent` (or set `DUCKDB_AGENT_MODE=0`).
123
+ - **`ruff` is normally pinned by the project.** Prefer `uv run ruff ...` so the
124
+ version CI uses decides the rules; the managed copy is for a check outside a
125
+ project environment, and should never rewrite files the project's own version
126
+ would format differently.
127
+
128
+ ## Skills
129
+
130
+ The package ships two skills:
131
+
132
+ ## How it integrates with pi
133
+
134
+ Three surfaces, in order of how reliably they reach the model:
135
+
136
+ 1. **`tool_call`** (deterministic) — an absolute host path for a managed binary is
137
+ rewritten to its bare name before the command runs, so `/usr/bin/jq -r .a`
138
+ executes as `jq -r .a` and the packaged build runs. Only command-position tokens
139
+ are touched and only names this package manages. `PI_MANAGED_TOOLS_REWRITE=off`
140
+ turns it off.
141
+ 2. **`before_agent_start`** (deterministic) — the two environment rules are appended
142
+ to `systemPromptOptions.promptGuidelines`, and a `managed_tools_environment`
143
+ section states the facts outright: that the bin directory is first on `PATH`,
144
+ which packaged versions that means, and that no probing turn is needed.
145
+ Idempotent, and the section text is stable so pi does not re-patch it each turn.
146
+ 3. **Skills** (opportunistic) — name, description and path are always in the system
147
+ prompt; the body loads only when the model decides it is relevant, which it does
148
+ not do for one-liners.
149
+
150
+ `/managed-tools status` reports how many absolute paths were rewritten this session.
151
+
152
+ The always-on skill also pins two environment rules, because both are silent when
153
+ broken: call the packaged binaries by **bare name** (an absolute path like
154
+ `/usr/bin/jq` bypasses pi's `PATH` prepend and `getToolPath()`), and run multi-step
155
+ shell logic through **`busybox sh -c '…'`** so the shell does not depend on which
156
+ bash the host resolved. `busybox sh` covers `[[ ]]`, `<(…)`, `<<<`, `$'…'`, `local`
157
+ and `pipefail`, but not arrays, `${v^^}`, `read -a`, `mapfile` or `coproc`.
158
+
159
+ - **`managed-tools`** — always advertised. pi adds every skill's *name and
160
+ description* to the system prompt and nothing else, so this description is the
161
+ advert: it sets the preference order (rtk first, then these binaries over the
162
+ system ones), names all twenty-five tools, and routes to the reference for flags.
163
+ - **`busybox-applets`** — loaded on demand, only when busybox is in play. All 236
164
+ applets classified read-only / mutating / destructive / exec, with the flags that
165
+ cause a write.
166
+ - **`managed-tools-reference`** — loaded on demand. The exact flag set and one
167
+ or two worked examples per tool, transcribed from the binaries this package
168
+ installs rather than from upstream docs, because the versions are pinned.
169
+
170
+ Both skills are explicit about the trap in `rtk`: it summarises, so it is right
171
+ for "did it pass" (`rtk test`, `rtk err`, `rtk deps`) and wrong for "show me what
172
+ changed" — `rtk git diff` reduces a diff to a file list, and `rtk err` keeps
173
+ stderr while dropping stdout. The rule is stated as verdict-versus-content, with
174
+ plain commands as the fallback when unsure.
175
+
176
+ That pinning is the point: the tool surface is fully known at install time, so
177
+ the skills can state flag names instead of telling the model to run `--help` and
178
+ spend the tokens anyway. `tests/skills.test.ts` keeps them honest — adding a tool
179
+ without documenting it in both skills fails the suite, as does a description over
180
+ the Agent Skills 1024-character limit or a version list that disagrees between
181
+ the two files.
182
+
183
+ ## Verification
184
+
185
+ Every archive is checked against the sha256 digest GitHub records for the
186
+ release asset, **before** it is extracted. That digest is computed by GitHub at
187
+ upload time, so it does not depend on the project publishing sidecar checksums —
188
+ `fd` and `bat` publish none at all. It also means a compromised release page
189
+ cannot pass by replacing a binary and its `.sha256` sidecar together.
190
+
191
+ Verification is **fail-closed**:
192
+
193
+ - a digest mismatch fails the install and keeps the previous binary;
194
+ - a release API that cannot be reached fails the install rather than guessing;
195
+ - an asset published without a digest fails the install.
196
+
197
+ The single opt-out is `PI_MANAGED_TOOLS_ALLOW_UNVERIFIED=1`, which installs the
198
+ archive and records its digest anyway. Such an install is reported as
199
+ `UNVERIFIED` rather than `verified`, including in the TUI update line.
200
+
201
+ Digests are read from `api.github.com`, whose anonymous quota is 60 requests per
202
+ hour **per IP** and shared with everything else on the host. A verification only
203
+ runs when an update is actually downloaded, so a normal cycle costs one request
204
+ per outdated tool. If the quota is exhausted, installs fail closed with a
205
+ message saying so; set `GITHUB_TOKEN` (or `GH_TOKEN`) to raise the limit. The
206
+ installed binaries are never damaged by a failed verification.
207
+
208
+ After the swap the installed binary is **executed** and its version read back. A
209
+ binary that cannot run — wrong architecture, glibc against a musl build, a
210
+ truncated download — is rolled back to the previous copy and reported as a
211
+ failure. Reporting the version that was requested instead would claim success
212
+ for a dead file.
213
+
214
+ Installs land through a staged file on the same filesystem, so a failed download
215
+ or extraction never leaves a partial binary where pi expects a working one. On
216
+ POSIX the final rename replaces the old inode atomically, so a running pi keeps
217
+ working.
218
+
219
+ ## Install
220
+
221
+ ```bash
222
+ pi install npm:@rob-c/pi-managed-tools
223
+ pi list # shows the package
224
+ ```
225
+
226
+ Then in a session:
227
+
228
+ ```text
229
+ /managed-tools # status: versions, path, and any damaged binary
230
+ /managed-tools update # download the latest releases now
231
+ /managed-tools reinstall # replace every managed binary that cannot run
232
+ /managed-tools reinstall bat # force one tool to be re-downloaded
233
+ ```
234
+
235
+ The model can do the same through the `managed_tools` tool (`action: "status"`,
236
+ optionally `check_latest: false` to stay offline; `action: "update"`; or
237
+ `action: "reinstall"` with an optional `tool`).
238
+
239
+ ### Repairing a damaged binary
240
+
241
+ A managed binary can be broken without looking broken: truncated by a killed
242
+ download, left behind by a disk error, or copied from another architecture. A
243
+ version check misses all three, because the file is still at the expected path.
244
+ `status` therefore *executes* each managed binary and flags any that fail to run:
245
+
246
+ ```text
247
+ bat: installed 0.26.1 - DAMAGED (present but does not execute); run reinstall
248
+ ```
249
+
250
+ `/managed-tools reinstall` with no argument replaces only those. Naming a tool
251
+ forces a fresh download even when the version already matches upstream, which is
252
+ what you want when the file is wrong in a way that still reports a version.
253
+
254
+ Bundled shims are covered. `ast-grep`'s archive also installs `sg`, a deprecated
255
+ alias that is a small binary which **execs `ast-grep`** — so it dies the moment
256
+ its sibling is missing or unreadable. `status` probes every name an archive
257
+ provides and names the broken one:
258
+
259
+ ```text
260
+ ast-grep: installed 0.51.3 - DAMAGED (sg does not execute); run reinstall
261
+ ```
262
+
263
+ `/managed-tools reinstall sg` resolves to `ast-grep`, because that archive is
264
+ where `sg` comes from, and reinstalls the bundle.
265
+
266
+ An install is atomic per archive: every target is backed up, swapped, then
267
+ probed, and any failure restores all of them. A broken shim in a release can
268
+ never leave a new primary beside a dead one.
269
+
270
+ A repair still verifies the archive digest, still rolls back if the new binary
271
+ will not run, and falls back to the version already on disk when the release
272
+ lookup fails — so it works with a broken network, which is when a repair is most
273
+ likely to be needed.
274
+
275
+ To remove it: `pi remove npm:@rob-c/pi-managed-tools`.
276
+
277
+ To use the same binaries in your own shell (pi only adds them to the `PATH` of
278
+ its own `bash` tool):
279
+
280
+ ```bash
281
+ export PATH="$HOME/.pi/agent/bin:$PATH" # add to ~/.zshrc or ~/.bashrc
282
+ ```
283
+
284
+ Because pi searches that directory first, a managed copy **shadows** a copy you
285
+ installed yourself with Homebrew, cargo, `uv`, or a version manager. That is the
286
+ point for `fd`/`rg`/`bat`; if you deliberately pin `prek` or `rtk` to a specific
287
+ version, check `/managed-tools` before assuming which binary ran.
288
+
289
+ ## What a session start does
290
+
291
+ 1. A managed binary is missing, or the last check is older than the interval:
292
+ resolve `https://github.com/<repo>/releases/latest` (the redirect, not the
293
+ rate-limited API; the API is only a fallback).
294
+ 2. Each binary whose installed version is older — or absent — is downloaded,
295
+ verified against GitHub's digest, extracted and renamed into place. The
296
+ archive is fetched and unpacked inside the bin directory so the final rename
297
+ stays on one filesystem and cannot leave a truncated binary where pi expects
298
+ a working one.
299
+ 3. The result is recorded in `<agent dir>/bin/.pi-managed-tools.json`, which is
300
+ what the interval is measured against.
301
+ 4. Otherwise nothing happens and no network request is made.
302
+
303
+ Status lines are shown in the TUI only when something changed. Print mode
304
+ (`pi -p`) still updates, silently.
305
+
306
+ A tool with no release for the current platform is skipped and does **not**
307
+ force a check on every start. `rtk` publishes no `aarch64-pc-windows-msvc`
308
+ archive, so on Windows on ARM it is reported as unsupported while the other 20
309
+ keep working. `sd` has no Windows arm64 build either, `busybox` has no Windows
310
+ build at all, and `difftastic` uses the gnu Linux build because it publishes no
311
+ linux-arm64 musl asset.
312
+
313
+ ## Configuration
314
+
315
+ | Variable | Default | Meaning |
316
+ |---|---|---|
317
+ | `PI_MANAGED_TOOLS` | on | `off`/`0`/`false` disables the startup check (the `/managed-tools update` command and `managed_tools` tool still work) |
318
+ | `PI_MANAGED_TOOLS_INTERVAL_HOURS` | `12` | Minimum hours between startup checks; `0` checks every start |
319
+ | `PI_MANAGED_TOOLS_ALLOW_UNVERIFIED` | unset | `1`/`true`/`yes` installs an archive whose digest cannot be confirmed |
320
+ | `PI_MANAGED_TOOLS_REWRITE` | on | `off`/`0`/`false` disables rewriting absolute tool paths in bash tool calls |
321
+ | `GITHUB_TOKEN` / `GH_TOKEN` | unset | Optional. Raises the 60/hour anonymous quota used to read release digests |
322
+ | `PI_OFFLINE` | unset | Same `1`/`true`/`yes` values pi itself honours; disables startup checks |
323
+
324
+ ## Platform support
325
+
326
+ Downloads match what pi would have fetched itself:
327
+
328
+ | Platform | Archive |
329
+ |---|---|
330
+ | macOS (arm64 / x64) | `…-apple-darwin.tar.gz` |
331
+ | Linux (arm64 / x64, musl) | `…-unknown-linux-musl.tar.gz` |
332
+ | Windows (arm64 / x64) | `…-pc-windows-msvc.zip` |
333
+
334
+ Other architectures are left alone: these projects publish no matching prebuilt
335
+ binary and pi does not guess one either. Three of the projects deviate from the
336
+ Rust triple convention and are handled per tool:
337
+
338
+ | Tool | Asset scheme | Notable gaps |
339
+ |---|---|---|
340
+ | `rtk` | `rtk-oss-<rust triple>` | no Windows arm64 |
341
+ | `gron` | `gron-<os>-<go arch>-<version>.tgz` (`.zip` on Windows) | no 32-bit arm |
342
+ | `shellcheck` | `shellcheck-v<ver>.<os>.<arch>.tar.gz` | one arch-less `.zip` for Windows x64 only |
343
+ | `ast-grep` | `app-<rust triple>.zip` (zip on every platform) | none |
344
+ | `just` | `just-<ver>-<rust triple>` | none |
345
+ | `ninja` | `ninja-mac.zip` / `ninja-linux.zip` / `ninja-linux-aarch64.zip` / `ninja-win.zip` / `ninja-winarm64.zip` | none; the macOS asset is universal2, so one file covers x86_64 and arm64 |
346
+ | `jq` | bare executable: `jq-macos-arm64`, `jq-linux-amd64` | no archive at all — the download is the binary |
347
+ | `yq` | bare executable: `yq_darwin_arm64`, `yq_linux_amd64` | no archive at all |
348
+ | `fzf` | `fzf-<ver>-darwin_arm64.tar.gz` (`.zip` on Windows) | none |
349
+ | `uv` | `uv-<rust triple>.tar.gz` / `.zip` | archive also contains `uvx` |
350
+ | `gh` | `gh_<ver>_linux_amd64.tar.gz`, `gh_<ver>_macOS_arm64.zip` | macOS ships a **zip**, Linux a tar.gz |
351
+ | `bd` | `beads_<ver>_darwin_arm64.tar.gz` | assets are named after the project, the binary is `bd`; Dolt is embedded |
352
+ | `agent-browser` | bare executable `agent-browser-darwin-arm64` | `x64` not `amd64`; **no win32-arm64** |
353
+ | `ruff` | `ruff-<rust triple>` | bare version tags |
354
+ | `mise` | `mise-v<ver>-macos-arm64.tar.gz` | dated tags; binary nests at `mise/bin/mise` |
355
+ | `scc` | `scc_Darwin_arm64.tar.gz` | capitalised OS, underscore, no version |
356
+ | `duckdb` | `duckdb-cli-osx-arm64.tar.gz` | says `osx`/`amd64`; bare binary in the archive |
357
+ | `miller` | `miller-6.22.0-darwin-arm64.tar.gz` | installs `mlr`, not `miller` |
358
+ | `sd` | `sd-v1.1.0-aarch64-apple-darwin.tar.gz` | keeps the `v`; **binary reports 1.0.0 for tag 1.1.0** |
359
+ | `difftastic` | `difft-0.72.0-aarch64-apple-darwin.tar.gz` | installs `difft`; linux uses gnu |
360
+ | `busybox` | `busybox-static-1.39.0-aac079e-darwin-universal` | bare binary; one universal2 mac asset; **no Windows build** |
361
+
362
+ `gron`'s release build reports no version at all (`gron version dev`), so its
363
+ installed version is recorded in the state file rather than read back from the
364
+ binary.
365
+
366
+ `rtk` is installed from the **`rtk-oss-`** family. The plain `rtk-<target>`
367
+ release bundles a BUSL-1.1 engine (`LICENSE-ENGINE`); `rtk-oss-` is the
368
+ Apache-2.0-only build of the same tool, with the same binary name and version
369
+ banner. Nothing here is redistributed — the binary is fetched from GitHub on the
370
+ user's own machine — but the distinction is kept explicit so the default install
371
+ is not silently pulling a source-available component.
372
+
373
+ ## Layout
374
+
375
+ ```
376
+ package.json pi manifest: loads src/extension.ts
377
+ src/extension.ts session_start check, /managed-tools command, managed_tools tool
378
+ src/tools.ts registry, release targets, digests, download/extract/install, cooldown
379
+ skills/managed-tools/ always-advertised short skill
380
+ skills/managed-tools-reference/ exact flags and examples per tool
381
+ tests/tools.test.ts offline tests: fixtures are real archives served by a fake fetch
382
+ tests/extension.test.ts loads the extension against a stand-in pi and agent directory
383
+ tests/skills.test.ts keeps the two skills in step with the tool registry
384
+ scripts/verify.sh runs the installed plugin inside the pi on PATH
385
+ ```
386
+
387
+ ## Tests
388
+
389
+ ```bash
390
+ npm test # node --test; no network access
391
+ npm run typecheck # tsc --noEmit
392
+ ./scripts/verify.sh # end-to-end inside the installed pi (needs a model key)
393
+ ```
394
+
395
+ The suite builds real `tar.gz` release archives in a temp directory, serves them
396
+ through a stub `fetch` that also synthesises the release API response from the
397
+ same bytes, and asserts the installed binary runs, reports the expected version,
398
+ replaces the old copy, and leaves no archive or staging directory behind. The
399
+ stub computes real digests, so verification is exercised rather than bypassed:
400
+ a tampered asset, a missing digest, and a binary that exits without printing a
401
+ version are each asserted to fail without damaging the installed copy. A second
402
+ file loads the extension itself against a stand-in `pi` to check registration,
403
+ the command, the tool, and that a startup inside the check interval, or with
404
+ `PI_MANAGED_TOOLS=off`/`PI_OFFLINE`, makes no network request at all.
405
+
406
+ ## Licence
407
+
408
+ GPL-2.0-only. See [LICENSE](LICENSE).
409
+
410
+ This is a deliberate choice: the plugin itself is copyleft, so anyone distributing a
411
+ modified version must publish their source under the same terms.
412
+
413
+ Two things it does not cover, both by design:
414
+
415
+ - **The binaries it downloads are not distributed here.** `shellcheck` (GPL-3.0) and
416
+ `busybox` (GPL-2.0) among them are fetched from their own upstream releases onto
417
+ the user's machine. Bundling any of them into this package would create a licence
418
+ conflict, so don't.
419
+ - **pi itself is MIT** and is declared as a `peerDependency`, never bundled. Its own
420
+ dependency tree contains Apache-2.0 packages, which is fine precisely because none
421
+ of it ships in this tarball.
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
- "name": "@rob-c/pi-managed-tools",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@rob-c/pi-managed-tools",
3
+ "version": "0.16.0",
4
+ "description": "Keeps pi's managed binaries, and a few PATH-only extras, at the latest upstream release",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi",
8
+ "pi-coding-agent",
9
+ "fd",
10
+ "ripgrep",
11
+ "bat",
12
+ "prek",
13
+ "rtk",
14
+ "just",
15
+ "gron",
16
+ "shellcheck",
17
+ "ast-grep",
18
+ "ninja",
19
+ "jq",
20
+ "yq",
21
+ "fzf",
22
+ "uv",
23
+ "gh",
24
+ "bd",
25
+ "agent-browser",
26
+ "ruff",
27
+ "mise",
28
+ "scc",
29
+ "duckdb",
30
+ "miller",
31
+ "sd",
32
+ "difftastic",
33
+ "busybox"
34
+ ],
35
+ "type": "module",
36
+ "license": "GPL-2.0-only",
37
+ "pi": {
38
+ "extensions": [
39
+ "./src/extension.ts"
40
+ ],
41
+ "skills": [
42
+ "./skills"
43
+ ],
44
+ "changelogPath": "./CHANGELOG.md"
45
+ },
46
+ "files": [
47
+ "src/",
48
+ "skills/",
49
+ "README.md",
50
+ "CHANGELOG.md"
51
+ ],
52
+ "scripts": {
53
+ "test": "node --test tests/tools.test.ts tests/extension.test.ts tests/skills.test.ts",
54
+ "typecheck": "tsc -p .",
55
+ "verify": "./scripts/verify.sh"
56
+ },
57
+ "peerDependencies": {
58
+ "@earendil-works/pi-coding-agent": "*",
59
+ "typebox": "*"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^22.0.0",
63
+ "typescript": "^5.0.0"
64
+ },
65
+ "engines": {
66
+ "node": ">=22.19.0"
67
+ },
68
+ "author": "Robert Currie (https://github.com/rob-c)",
69
+ "repository": {
70
+ "type": "git",
71
+ "url": "git+https://github.com/rob-c/pi-managed-tools.git"
72
+ },
73
+ "homepage": "https://github.com/rob-c/pi-managed-tools#readme",
74
+ "bugs": {
75
+ "url": "https://github.com/rob-c/pi-managed-tools/issues"
76
+ }
77
+ }
@@ -0,0 +1,139 @@
1
+ ---
2
+ name: busybox-applets
3
+ description: "All 236 BusyBox applets with a read-only vs mutating classification: which applets never change anything, which write, which are destructive or system-level, and which flags cause the write. Load before running any busybox applet that is not obviously an inspection command."
4
+ ---
5
+
6
+ # BusyBox applets
7
+
8
+ `busybox <applet> [args]` — 236 applets inside one static binary (v1.39.0).
9
+ BusyBox dispatches on **argv[0]**, so the installed file must stay named `busybox`;
10
+ if you copy or rename it, `busybox` no longer works and the new name is treated as
11
+ the applet name.
12
+
13
+ **Never run `busybox --install -s <dir>`.** Inside pi's bin directory — which is
14
+ first on `PATH` for every bash command — that would create 236 symlinks ahead of the
15
+ real coreutils, and busybox `sed`, `grep`, `find`, `tar`, `awk` and `xxd` are not
16
+ GNU-compatible. Every later command in the session, including the other tools in
17
+ this package, would silently change behaviour.
18
+
19
+ Prefer the dedicated tools where they exist: `rg` over `busybox grep`, `fd` over
20
+ `busybox find`, `bat` over `busybox cat`, `jq` over `busybox awk`, `diff`/`difft`
21
+ over `busybox diff`, `scc` over `busybox wc`-loops. Use busybox for the applets
22
+ nothing else covers (`hexdump`, `xxd`, `unzip`, `gzip`, `patch`, `cpio`, `dpkg-deb`,
23
+ `date`, `hostname`, `sha*sum`).
24
+
25
+ Legend: **R** never changes state · **M** writes files or state · **M★**
26
+ destructive, irreversible or system-level · **E** runs a program you name, so its
27
+ effect is whatever that program does.
28
+
29
+ ## Read-only (R)
30
+
31
+ Safe for inspection. These only read input and write to stdout/stderr.
32
+
33
+ ```
34
+ [ [[ arch ascii base32 base64 basename bc blkid bzcat cal cat chat cksum clear cmp
35
+ comm crc32 cut dc df diff dirname dnsdomainname du echo egrep expand expr factor
36
+ false fgconsole fgrep fold getopt grep groups hd head hexdump hostid id iostat ipcalc
37
+ join less logname ls lsattr lsof lspci lsscsi lsusb lzcat man md5sum mkpasswd more
38
+ mountpoint mpstat netstat nl nmeter nologin nproc nslookup od paste pipe_progress
39
+ printenv printf pscan pwd pwdx readlink realpath resize rev rpm2cpio scriptreplay
40
+ seq sha1sum sha256sum sha384sum sha3sum sha512sum sleep stat strings sum svok tac
41
+ tail test tr tree true ts tsort tty ttysize uname unexpand usleep uuencode uuidgen
42
+ vmstat volname wc which whoami whois xxd xzcat yes zcat
43
+ ```
44
+
45
+ Two caveats inside "read-only": `busybox xxd -r` only prints (it cannot write back),
46
+ and `busybox find` is read-only **only** with its default `-print`.
47
+
48
+ ## Writes files or state (M)
49
+
50
+ | applet | what it writes | how |
51
+ |---|---|---|
52
+ | `add-shell` | `/etc/shells` | appends each argument |
53
+ | `awk` | files anywhere | `print > file`, `>> file`, `system()` |
54
+ | `bootchartd` | `/var/log/bootchart.tgz` | `start`, `stop`, `init` |
55
+ | `chattr` | inode attributes | `-,+,=attr`, `-R` |
56
+ | `chgrp` `chmod` `chown` | ownership and mode bits | normal form, `-R` |
57
+ | `dos2unix` | the file, in place | any file argument |
58
+ | `dpkg-deb` | extracted tree | `-e DIR`, `-x DIR`, `-X DIR` |
59
+ | `fatattr` | FAT attributes | `-/+rhsvda` |
60
+ | `flock` | lock file (created if absent) | `FILE`, `FILE -c PROG` |
61
+ | `fsync` | flushes blocks (no content change) | any file argument |
62
+ | `link` | new hard link | `FILE LINK` |
63
+ | `ln` | links; removes an existing target | `-f`, `-b` |
64
+ | `logger` | syslog | always writes |
65
+ | `lpr` | print queue | any file argument |
66
+ | `mesg` | terminal write permission | `y` / `n` |
67
+ | `mkdir` `mkfifo` `mknod` `mktemp` | new filesystem entries | normal form, `-p`, `-m` |
68
+ | `nc` | hex-dump file | `-o FILE` |
69
+ | `nohup` | `nohup.out` | when stdout is a tty |
70
+ | `remove-shell` | `/etc/shells` | rewrites it |
71
+ | `renice` | nice values of running processes | `PRIORITY ID`, `-p/-g/-u` |
72
+ | `run-parts` | whatever the scripts do | `DIRECTORY` |
73
+ | `rx` | received file | `FILE` |
74
+ | `script` | `typescript` + timing file | `OUTFILE`, `-a` |
75
+ | `sed` | files in place | `-i[SFX]` — without it, stdout only |
76
+ | `shuf` `sort` | output file | `-o FILE` (default stdout) |
77
+ | `split` | `PREFIX*` output files | `INPUT PREFIX`, `-b`, `-l` |
78
+ | `time` | result file | `-o FILE`, `-a` |
79
+ | `touch` | creates/updates timestamps | any file argument |
80
+ | `uniq` | truncated output file | second positional `OUTFILE` |
81
+ | `unix2dos` | the file, in place | any file argument |
82
+ | `uudecode` | output file | `-o FILE` |
83
+ | `wget` | downloads into cwd | `URL`, `-O FILE`, `-P DIR` |
84
+ | `fakeidentd` | network service | daemon mode |
85
+
86
+ ## Destructive or system-level (M★)
87
+
88
+ Deletes, overwrites, truncates, formats, kills, mounts, or changes the machine.
89
+ Confirm before running any of these.
90
+
91
+ | applet | what it destroys or changes | how |
92
+ |---|---|---|
93
+ | `rm` `rmdir` `unlink` | deletes files / empty dirs | `-r`, `-f`, `-p` |
94
+ | `mv` | overwrites destination | `-f` |
95
+ | `cp` | overwrites destination | `-f`, `-r`, `-a` |
96
+ | `dd` | block device or file, truncated | `of=`, `seek=`, `conv=notrunc` |
97
+ | `truncate` | truncates and creates | `-s SIZE` (`-c` only stops creation) |
98
+ | `shred` | overwrites then deletes | `-n`, `-z`, `-u` |
99
+ | `tee` | truncates every file named | any file arg (`-a` appends) |
100
+ | `tar` | creates/extracts, overwrites | `c`, `x`, `-C DIR` (`t` only lists) |
101
+ | `unzip` `unxz` `unlzma` `gunzip` `xz` `gzip` `bzip2` `bunzip2` `lzma` `lzop` | write output and **delete the input** unless `-k` | `-f` forces overwrite; `-c`/`-t` are read-only |
102
+ | `patch` | rewrites targets in place | `-i DIFF`, `ORIGFILE` |
103
+ | `ed` `vi` `hexedit` | overwrite the file on save | file argument (`vi -R` is read-only) |
104
+ | `kill` `killall` `killall5` | terminate processes | `-SIG PID`, name |
105
+ | `timeout` | signals the child | `-s`, `-k` |
106
+ | `start-stop-daemon` `svc` | start/kill supervised processes | `-S`, `-K`, `-u -d -o` |
107
+ | `date` `rdate` `hwclock` | set the system clock | `-s`, `-w`, `--systz` |
108
+ | `hostname` | system hostname | `HOSTNAME`, `-F` (`-s/-i/-d` read) |
109
+ | `sysctl` | kernel parameters | `-w`, `-p`, `KEY=VALUE` |
110
+ | `stty` | terminal/device settings | any setting arg (`-a`, `-g` read) |
111
+ | `devmem` `setconsole` `setkeycodes` `chvt` `deallocvt` `resume` `swaplabel` `fdformat` `fbset` `makedevs` `rtcwake` | devices, kernel maps, consoles, RTC alarm and sleep state | positional args, `-s SEC`, `-t TIME` |
112
+ | `microcom` `getty` | writes to a serial/tty device | `TTY` |
113
+ | `dpkg` `rpm` | install/remove packages system-wide | `-i`, `-r`, `-P` |
114
+ | `chroot` | changes root, runs `PROG` | `NEWROOT PROG` |
115
+ | `install` | copies and overwrites, sets owner/mode | always writes |
116
+ | `cpio` | extracts or creates archives | `-i`, `-o -F`, `-p DIR` |
117
+ | `fatlabel` | FAT label on a block device | `BLOCKDEV LABEL` |
118
+ | `ftpd` `ftpput` `ftpget` `tftpd` `tftp` `telnet` `telnetd` `httpd` `inetd` `ssl_server` `tcpsvd` `udpsvd` | serve, upload or run remote-triggered commands | server/upload modes |
119
+ | `find` | deletes or runs commands | `-delete`, `-exec CMD ;` |
120
+ | `mim` | runs shell commands from a spec | `-f FILE` |
121
+ | `ash` `sh` `hush` | anything the script does | `-c SCRIPT`, script file |
122
+ | `sync` | flushes all buffers | no flags needed |
123
+ | `lpq` | cancels print jobs | `-d JOBID` |
124
+ | `lpd` | spool queue files | always writes |
125
+ | `getty` | utmp/wtmp, login | `TTY` |
126
+
127
+ ## Runs a program you name (E)
128
+
129
+ Read-only *by themselves*; the effect is entirely the child's. `env`, `envdir`,
130
+ `nice`, `setsid`, `cttyhack`, `xargs` (`-a FILE` only reads), plus `find -exec`,
131
+ `awk system()`, `sed e`, `tar --to-command`, `vi !cmd`.
132
+
133
+ ## BusyBox is not GNU
134
+
135
+ Before reaching for an applet that shadows a GNU tool, remember the flag gaps:
136
+ `grep` has no `-P`, `find` has no `-printf`, `sed -i` exists but `sed` lacks many
137
+ GNU extensions, `tar` has no `--exclude-from` in the same form, `xxd` accepts one
138
+ FILE, `ls` has no `--color=auto` nuance. When the GNU-compatible tool exists in
139
+ this package (`rg`, `fd`, `bat`, `jq`, `scc`, `difft`), use it instead.