@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/CHANGELOG.md +334 -0
- package/LICENSE +338 -0
- package/README.md +420 -2
- package/package.json +76 -5
- package/skills/busybox-applets/SKILL.md +139 -0
- package/skills/managed-tools/SKILL.md +152 -0
- package/skills/managed-tools-reference/SKILL.md +570 -0
- package/src/extension.ts +440 -0
- package/src/tools.ts +1740 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: managed-tools
|
|
3
|
+
description: "Prefer rtk to shrink command output, then this toolkit over system binaries. rtk returns the verdict or failures only (rtk test/err/git diff/ls/find/json/deps/env) — use it whenever you need the result, not the content. Every multi-step shell command must be wrapped: `busybox sh -c '...'` — wrap it before writing the loop, pipeline or `for` — with plain bash only for arrays, ${v^^} or mapfile. Ground yourself once with `command -v rg jq bat` before exploring. Otherwise prefer rg over grep, fd over find, bat over cat (bat -n -r A:B reads a line range), jq to read or query JSON, gron to explore it, ast-grep over regex edits, just/ninja over guessed builds, shellcheck for shell, prek for hooks. Applies to one-liners too. Call them by bare name, never by absolute path (/usr/bin/jq): the packaged copy is first on PATH. Exact flags and which of them write: managed-tools-reference. Per-applet busybox safety: busybox-applets."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Managed tools
|
|
7
|
+
|
|
8
|
+
Twenty-five 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 · rtk 1.2.1
|
|
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
|
+
|
|
37
|
+
Do not re-derive this per step: once at the start is enough, and re-checking it
|
|
38
|
+
mid-task is how a session drifts back to `awk`/`python3 -c`.
|
|
39
|
+
|
|
40
|
+
## Order of preference
|
|
41
|
+
|
|
42
|
+
1. **`rtk <cmd>` first** for any command whose output you only need to *judge*.
|
|
43
|
+
2. **These binaries over system ones** — they are the same tools, newer, and
|
|
44
|
+
already on `PATH` ahead of `/usr/bin`.
|
|
45
|
+
3. Plain commands only when you need the bytes.
|
|
46
|
+
|
|
47
|
+
This holds for one-liners as much as for whole tasks: a 25-line excerpt is still
|
|
48
|
+
read with `bat`, a single JSON field is still extracted with `jq`, a directory
|
|
49
|
+
listing is still `fd`. Reaching for `awk`/`sed`/`python3 -c`/`cat` skips a tool
|
|
50
|
+
that is already installed and documented.
|
|
51
|
+
|
|
52
|
+
## Which binary runs
|
|
53
|
+
|
|
54
|
+
Use the bare name — `jq`, `gh`, `rg`, `bat`, `scc` — never an absolute path such as
|
|
55
|
+
`/usr/bin/jq`, `/opt/homebrew/bin/gh` or `/Users/<you>/.pi/agent/bin/rg`. The
|
|
56
|
+
packaged copy is already first on `PATH` in every bash call, so the bare name
|
|
57
|
+
resolves to it; an absolute path is how you silently pick the host's older build
|
|
58
|
+
(`/usr/bin/jq` is 1.7.1 on this class of machine, the packaged one is 1.8.2).
|
|
59
|
+
|
|
60
|
+
Check rather than assume: `command -v jq` should print `<agent dir>/bin/jq`.
|
|
61
|
+
|
|
62
|
+
If it prints a host path, the user's shell rc has the agent bin *appended* rather
|
|
63
|
+
than prepended, and pi leaves `PATH` alone when the directory is already present.
|
|
64
|
+
Do not work around it with an absolute path, and do not `export PATH=…` in a
|
|
65
|
+
command — each bash call is a fresh shell, so it fixes nothing beyond that one call.
|
|
66
|
+
Report it instead: the durable fix is
|
|
67
|
+
`export PATH="$HOME/.pi/agent/bin:$PATH"` in the shell rc, followed by a pi restart
|
|
68
|
+
(the running process keeps the env it started with).
|
|
69
|
+
|
|
70
|
+
One exception: an absolute path is correct when the task is to *inspect* the host
|
|
71
|
+
copy ("is `/usr/bin/jq` older?"). That is a deliberate comparison, not a choice of
|
|
72
|
+
which binary to run — say which one you are running and why.
|
|
73
|
+
|
|
74
|
+
## Shell
|
|
75
|
+
|
|
76
|
+
Run multi-step shell logic through **`busybox sh`**, not the ambient shell. It is the
|
|
77
|
+
same static ash binary on every platform this package supports, so a command means
|
|
78
|
+
the same thing everywhere and does not depend on which bash is installed, whether
|
|
79
|
+
`/bin/bash` exists, or what the user's zsh does.
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
busybox sh -c 'for f in src/*.ts; do echo "$f $(wc -l < "$f")"; done'
|
|
83
|
+
busybox sh <<'EOF'
|
|
84
|
+
set -eu
|
|
85
|
+
for d in skills/*/; do echo "$(basename "$d")"; done
|
|
86
|
+
EOF
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
busybox ash is POSIX plus extensions, so these work: `[[ ]]`, `<(…)`, `<<<`, `$'…'`,
|
|
90
|
+
`local`, `function`, `set -o pipefail`, `${v//a/b}`, `${v:1:2}`, `printf -v`,
|
|
91
|
+
`trap … ERR`, `$RANDOM`.
|
|
92
|
+
|
|
93
|
+
These do **not** work — for one of these, drop the prefix and let pi's own shell run
|
|
94
|
+
the command (`/bin/bash` on macOS, `sh`/`bash` from `PATH` on Linux), and say why:
|
|
95
|
+
|
|
96
|
+
- arrays: `a=(1 2)`, `a+=(x)`, `declare -A`
|
|
97
|
+
- `${v^^}` / `${v,,}` case modification
|
|
98
|
+
- `read -a`, `mapfile` / `readarray`
|
|
99
|
+
- `coproc`, `extglob` (`@(…)`)
|
|
100
|
+
|
|
101
|
+
Quoting: pi runs your command through its own shell first, so `busybox sh -c '…'` is
|
|
102
|
+
nested. Use double quotes inside it, or the heredoc form for anything long.
|
|
103
|
+
|
|
104
|
+
## Before anything that writes
|
|
105
|
+
|
|
106
|
+
`managed-tools-reference` carries a read-only vs mutating table for all twenty-five
|
|
107
|
+
tools. Check it before any command that can rewrite, delete or upload — several
|
|
108
|
+
mutate with **no flag at all** (`sd`, `ruff format`, `just`, `ninja`, `uv run`,
|
|
109
|
+
`duckdb FILE`, `agent-browser open`). Prefer the dry run: `just -n`, `ninja -n`,
|
|
110
|
+
`uv --dry-run`, `mise -n`, `prek run --dry-run`, `bd --readonly`,
|
|
111
|
+
`duckdb -readonly`, `sd -p`, `ast-grep` without `-U`.
|
|
112
|
+
|
|
113
|
+
## Verdict vs content
|
|
114
|
+
|
|
115
|
+
`rtk` summarises. It will happily replace a diff with `a.txt | 1 +`, and
|
|
116
|
+
`rtk err` keeps stderr while discarding stdout. That is the point for "did it
|
|
117
|
+
pass?" and dangerous for "show me what changed".
|
|
118
|
+
|
|
119
|
+
- Need the **verdict**: `rtk test <cmd>`, `rtk err <cmd>`, `rtk deps`, `rtk env`,
|
|
120
|
+
`rtk json f --keys-only`, `rtk ls`, `rtk find`.
|
|
121
|
+
- Need the **content**: plain `git diff`, `bat --paging=never`, `rg`, `gron`.
|
|
122
|
+
- Unsure? Run it plainly. A re-run costs more than the tokens saved.
|
|
123
|
+
|
|
124
|
+
## Tool choice
|
|
125
|
+
|
|
126
|
+
| Instead of | Use |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `find` | `fd` |
|
|
129
|
+
| `grep -r` | `rg` (add `--hidden -I` when hidden or gitignored files matter) |
|
|
130
|
+
| `cat` | `bat --paging=never` |
|
|
131
|
+
| regex edit of code | `ast-grep run -p '<pattern>'` (preview, then `-r`) |
|
|
132
|
+
| ad-hoc JSON poking | `gron`, or `rtk json` |
|
|
133
|
+
| guessing a task command | `just -l` then `just -n` |
|
|
134
|
+
| guessing a build | `ninja -t targets`, then `ninja -n` |
|
|
135
|
+
| eyeballing shell bugs | `shellcheck -f gcc` (advisory; never rewrite) |
|
|
136
|
+
| reading a line range of a file | `bat --paging=never -n -r 900:925 file` — not awk/sed/head |
|
|
137
|
+
| reading or querying JSON | `jq -r '.path'`, `jq -c 'select(...)'` — not python3 -c or grep |
|
|
138
|
+
| exploring an unknown JSON document | `gron file.json \| rg 'users'` |
|
|
139
|
+
| hand-run hooks | `prek run` (`install` mutates `.git/hooks` — confirm first) |
|
|
140
|
+
| a JSON/YAML fishing trip | `gron`, `jq -r`, or `yq -o json` |
|
|
141
|
+
| `python -m venv` + pip | `uv run <cmd>` |
|
|
142
|
+
| `curl` against the GitHub API | `gh api` |
|
|
143
|
+
| writing a picker | `fzf --filter` (interactive needs a TTY you do not have) |
|
|
144
|
+
| tracking work in a scratch file | `bd q` / `bd list` — but `bd init` rewrites `AGENTS.md`, so ask first |
|
|
145
|
+
| curl-ing a page to read it | `agent-browser read <url>`, then `open` + `snapshot` for interaction |
|
|
146
|
+
| `python -m py_compile` / eyeballing style | `ruff check --statistics`, `ruff format --check` |
|
|
147
|
+
| guessing which runtime version a repo wants | `mise exec -- <cmd>` (activation never happens in pi's bash) |
|
|
148
|
+
| counting lines of code | `scc .` (`--by-file`, `-f csv`) |
|
|
149
|
+
| awk-ing CSV or joining tables | `mlr --csv ...` or `duckdb -c "select ..."` |
|
|
150
|
+
| regex rewrite of many files | `sd -p` first, then `sd` (it edits in place) |
|
|
151
|
+
| reading a big diff | `difft --display inline` (structural, falls back to lines) |
|
|
152
|
+
| an applet this package lacks (`hexdump`, `unzip`, `patch`, `sha256sum`) | `busybox <applet>` — never `busybox --install -s` |
|