@nredd/pi-dev-tools0.9.0
Typed pi tools for git, ssh, Python (uv/ruff/ty/pytest) and Rust (cargo): compact structured results, explicit exit-code states, no-shell spawn, bounded output.
Works on omp
1 of 1 report says this package works on omp.
1 works0 broken
Reports 1
- worksTested by omp packages
Tested on omp 19.4.0: `omp plugin install` succeeds and the package loads with no errors. It adds tools cargo_add, cargo_bench, cargo_build, cargo_check, cargo_clippy, cargo_doc…. Its tools were not called.
Readme
pi-dev-tools
Published to npm as @nredd/pi-dev-tools (public). From 0.5.1, each version is cut by the monorepo Publish workflow from a signed @nredd/pi-dev-tools@<version> tag, with npm provenance and a GitHub release carrying the tarball, checksums and manifest (docs/releases.md); earlier versions were published manually without provenance. 0.6.0 moved resource_snapshot onto the published @nredd/pi-resource-sampler; current source pins 0.2.1 (breaking structuredContent, see Resource awareness). 0.5.1 adds createDevTools(options) (injectable ssh, py, cargo tool options; the default export is unchanged) and fixes process output that dropped a short line sharing a chunk with an oversized one.
Use the monorepo development commands. References below to standalone repositories,
chezmoi pins, and installed-runtime harness gates describe the legacy deployment, not verification
of this package.
Standalone use
The packed tarball is self-contained: Pi host modules (@earendil-works/pi-*, typebox) are * peers supplied by Pi, there are no runtime dependencies and no sibling plugin is required. Verified by installing the tarball alone and running it in exact stock Pi 1.3.0 (make check-package-contracts). Optional fork integrations (subagents, Plan mode) are absent in that setup; the exercised behavior does not need them.
Typed pi tools for the workflows agents otherwise drive through raw Bash: git, GitHub reads, ssh, Python
(uv, ruff, ty, pytest) and Rust (cargo). Each tool spawns the real binary with an argv array,
maps exit codes to named states, bounds output, and returns structuredContent alongside the
compact text the model reads.
Tool groups land one per PR. Current state is in the table below.
| Group | Tools | Status |
|---|---|---|
| core | run, bound, withLock, withFileLock, toolResult (shared, not model-visible) |
done |
| git | git_status, git_diff, git_log, git_show, git_commit, git_worktree_list, git_worktree_add, git_worktree_remove, git_worktree_prune, Bash guard |
done |
| gh | gh_issue_view, gh_issue_list, gh_pr_view, gh_pr_list, gh_pr_diff, gh_pr_checks, gh_run_view, gh_api (all read-only) |
done |
| ssh | ssh_exec, ssh_pull, ssh_push |
done |
| py | py_lint, py_format, py_typecheck, py_test, py_uv |
done |
| cargo | cargo_check, cargo_clippy, cargo_fmt, cargo_test, cargo_build, cargo_run, cargo_doc, cargo_bench, cargo_add |
done |
| resource | resource_snapshot |
done |
Conventions every tool follows
- No shell.
spawn(cmd, argv), stdin closed or fed a fixed script, child in its own process group, SIGTERM then SIGKILL 2s later on timeout or abort, hard resolve 1s after that so a grandchild holding the pipes cannot hang the caller. macOS and Linux only - When a command settles, including a normal leader exit, whatever is left of its process group
is SIGKILLed, so a background descendant cannot outlive the tool call. Only the owned group is
signalled (never a bare pid). The runner then polls
kill(-pgid, 0)until the group is gone (ESRCH), for at most the same 1s grace, because delivery and reparent-to-init reaping are asynchronous: the result is not returned while a killed member can still answerkill(pid, 0). SSH is the exception: the localsshis the group, so remote processes it started can keep running after the local client exits - Output is capped at pi's
DEFAULT_MAX_BYTES/DEFAULT_MAX_LINES, truncation notice included. When cut, the full text is written to$TMPDIR/pi-dev-tools-*/<label>-N.txtand the path is named in the result runcaps captured stdout/stderr independently. Its stderr line listener drops only individual oversized lines, through their newline or EOF; valid following lines are delivered even when coalesced into the same chunk or after the capture cap is reached. Listener errors are swallowed- Exit codes become named states (
violations,no-tests,tool-error, ...), never a bare "exit 1" annotations.readOnlyHintmeans no direct edits by the tool, not no side effects. Thepi-plan-modefork admits annotated read-only tools in Plan mode; everything else is denied there.cargo_check,cargo_test,cargo_docandpy_testrun repo code (build.rs,conftest.py, tests), which may write build or cache outputs (target/,.coverage,.pytest_cache) or anything else that code chooses. Plan is not a sandboxoutputSchema+structuredContenton every tool,isError: trueon red with the data intact- Default transcript renderer, so every call settles as one
call · summaryrow
Resource awareness
resource_snapshot({process_limit?, interval_ms?}) is an always-read-only observer for a parent or subagent to call before it knowingly starts a large test or compile. A before_agent_start hook adds the guidance as a structured resource_awareness section only when the session can call the observer or can discover it through search_tools; a deferred parent therefore learns how to promote it, while a restricted child without either capability receives no impossible instruction. Append-mode children inherit the parent section once, never a duplicate. It never forces activation, schedules work, locks commands, or changes concurrency.
- Collection is the published
@nredd/pi-resource-sampler, pinned to exactly0.2.1as a runtime dependency (installed from the registry, never the workspace copy; a test asserts the resolved module). npm would link the same-versionedpackages/resource-samplerworkspace, so the root lockfile carries an explicit nestedpackages/dev-tools/node_modules/@nredd/pi-resource-samplerregistry entry with the published integrity.npm ci/npm installkeep it;npm dedupeor regenerating the lockfile drops it, and that test then fails. Each call creates a private sampler, samples twiceinterval_msapart (default 500, 100..5000), up to twice more when a scan loses its process listing (worst case four scans, about 19 s at the 5000 maximum versus 7 s), then disposes it, which awaits any helper reaping. No background polling or state survives the call. - Reports logical CPU count, 1/5/15-minute load (
nullon Windows), aggregate host interval CPUcpu.utilization(0..100) andinterval.{requestedMs,measuredMs}, total/free memory (free pages on macOS), LinuxMemAvailable, and macOS available memory calculated from thevm_statfree, inactive, speculative and purgeable page counts and its reported page size; missing or duplicate page-size headers make the estimate unavailable. The text output labels it avm_statestimate. The sampler's separatememory.usageremains its App + Wired + Compressed estimate and is not used foravailableBytes. The macOSmemory_pressure -Qfree percentage is a separate pressure indicator, not the same measure as free pages or the available estimate; Linux reports PSIsome avg10from the sampler. Missing optional metrics remainnull, never invented. Sampler0.2.0copiesos.cpus()counters when sampled, so Bun's lazy counters no longer produce a false 0 or 100. - Returns at most 50 process entries, 12 by default: PID, parent PID, interval CPU, RSS bytes and
executable(see privacy below). Interval CPU is a typed metric (availablewith a value where 100 means one logical core, otherwisewarmingorunavailablewith a reason), never a zero stand-in. Linux and native-capable Darwin measure it; unavailable rows fall back to RSS ranking.rankingisinterval-cpu(measured entries first, then RSS) orrss. Nopslifetime or decaying average is reported or relabelled. coveragepasses through the sampler's bounded scan (complete,enumerated,sampled,skipped,bytesRead, finitereasons);truncatedis!coverage.complete. The scan is not atomic: a process exiting mid-scan marks it partial (complete: false) even when nothing else was cut, and short-lived work may be missed. Sampler0.2.1uses names-only/procenumeration, removing0.2.0's known mid-iteration PID-exit collection failure (#499). The errno behind the historical WSL missing-metadata incidents remains unproven; this pin is not native WSL qualification.resource_snapshotresamples at most twice more (sliding the window) when a scan reportsprocess-collection-unavailable, so one such host race does not drop process metadata; persistent failure still reportsunavailablewith that reason (#557).executableis the sampler's kernel executable basename: Darwinucomm(kinfop_comm, written at exec from the executable file name, cut to 16 bytes), Linux the basename ofreadlink /proc/PID/exe. Never argv, process title, Linux comm (node-MainThread), environment or user. Sampler0.1.0reported Darwinps -ccomm, which is argv[0] and leaked titles such asnpm exec rea-agents@6.5.0 mcp;0.1.1fixes that.""means unknown (Linux processes of other users without ptrace access, unreadable or over-budget links) and is never filled in; text output prints(unknown). Whoever names, links or copies the executable file chooses the name, so it stays untrusted display text, bounded and control-stripped. Cancellation and sampler failures reject the call rather than returning a partial snapshot, including a cancellation that lands after the second sample while the optional memory probes run. The optional Darwin pressure probe gets the same signal, and failed, aborted, timed-out or truncated pressure probes staynull. A disposal failure, rejected or thrown synchronously, never hides the sample, probe or cancellation error that caused it; after a successful snapshot it rejects the call.- Parent PIDs let a caller see real OS process trees, but OS process metadata has no proven link to a Pi parent, session, or agent. Use actual subagent/task information separately; do not claim process-to-agent attribution from this tool.
- macOS and Linux process metadata are supported. Other platforms return an explicit unavailable reason while retaining the portable memory fields.
API change from 0.5.x (structuredContent): entries drop cpuPercent (ps average) and elapsed, which the sampler does not measure, and gain parentPid plus the cpu metric. Additive: interval, cpu.utilization, processes.ranking, processes.coverage, and the interval_ms parameter. cpuSemantics, truncated, limit and the memory fields keep their names. The resourceSnapshot(limit, options, signal, intervalMs?) seams are now createSampler, readFile and run; the per-OS-primitive seams are gone.
Release: removing structuredContent fields is breaking, so this ships only as @nredd/pi-dev-tools 0.6.0, never a 0.5.x patch (0.5.2 was never published). It is cut by the signed-tag publish.yml flow in releases. The source pin is the published sampler 0.2.1, whose process-name privacy, Bun CPU and native Darwin interval-CPU fixes this API depends on; 0.1.0 must never be pinned again.
git
Reads (git_status, git_diff, git_log, git_show) are annotated read-only and run with
--no-pager --no-color --literal-pathspecs, GIT_TERMINAL_PROMPT=0, GIT_EDITOR=true,
LC_ALL=C, timeout_s default 60. Refs (base, ref, rev) may not start with - and go
after --end-of-options. git_status parses porcelain v2 (-z, renames and copies carry the
old path, a gone upstream reads gone). git_diff leads with the stat and caps the patch;
git_log is sha date author: subject, max 200; git_show peels tags to the commit. Failures
name a state (not a git repository, unknown revision, path not tracked, no upstream,
push rejected) and return { error } as structured content.
git_commit {subject, why?, changes?, paths, push?=true}:
pathsis required; the repo root in any spelling,..segments, pathspec magic (:/) and flags are rejected. Ordinary commits usegit commit -- <paths>, so they contain exactly those files and leave any other staged path in the index. During a realMERGE_HEAD, the tool stages the named paths then requires every changed index path to be named and every conflict to be resolved. Only then it commits the complete approved merge without pathspecs, preserving both parents, signing and hooks. Approval checks cover the entire index even from a subdirectory withdiff.relative=true; configured relative hook paths still resolve from the worktree root. Every hook in the configured hooks directory (e.g.post-index-change) still runs during a merge commit. Onlypre-commit,prepare-commit-msgandcommit-msgalways start the checking runtime.post-commit,reference-transactionand the hooks present at approval are proxied too, and each starts the runtime only if its real hook exists when Git calls it. A hook created mid-commit under any other name is not proxied, so it does not run. The shims probe the startup runtime by running it; if it is gone or no longer loads (e.g. a package upgrade), they fall back to a workingnodeonPATH, and otherwise fail naming the stale path. Absolute paths are matched after resolving symlinks in their parent directory, so/varand/private/varspellings agree and an escaping symlink is rejected. A rejected merge leaves the named paths staged andMERGE_HEADin place. Only a "not a git repository" answer from the merge probe falls through to an ordinary commit'sstage: "add"; any other probe failure (timeout, abort, dubious ownership, missing cwd) fails atstage: "validate". A hook path that is a directory behaves as in plain Git: a blocking hook such aspre-commitrefuses the commit, apost-commitone only prints the error. A rename needs both the old and the new path; a deletion (unstaged or already staged) is named like any other path. Nothing to commit is its own state- The subject must be a capitalized imperative, <= 72 chars, no trailing period, no
conventional-commit prefix, no em or en dash. An
area:prefix is fine - Message is
subject, optionalwhy,Changes:bullets, thenCo-Authored-By: Claude <noreply@anthropic.com>, passed on stdin with-F - - Never
--no-verify,--amendor--no-gpg-sign. Hook output is relayed on failure, andfiles were modified by this hookis flagged as "re-stage and call again". Merge hooks are also checked for newly staged unapproved paths before Git can write the merge. Nothing retries - Push is
git push <remote> HEADwhere<remote>isbranch.<n>.pushRemote, elseremote.pushDefault, elsebranch.<n>.remote, else the only remote (with-u). Several remotes and none configured fails closed atstage: "push"; it never defaults toorigin. Abranch.<n>.remoteof.(local tracking) is not a push remote and counts as unconfigured and ambiguous. Only an unset config key (exit 1) is tolerated, and all three keys are read eagerly, so an unreadable one blocks the push even when a higher-precedence key is set; a broken config orgit remotefails closed with git's stderr.git push <remote> HEADpushes to the same-named branch on<remote>. A push failure returnsstage: "push"with the sha so the caller fixes the push instead of committing twice.signedis true for%G?inG,U,X,Y
Bash guard (tool_call on bash, always on): blocks --no-verify (and -n on commit, where
it means --no-verify; push -n is a dry run and passes), plain --force / -f / +ref
pushes including clustered -fu (not --force-with-lease), and --no-gpg-sign or
-c commit.gpgsign=false. Quoted strings are ignored and git must be the command word of its
segment or substitution, so echo 'git push --force' passes and $(git commit -n) does not.
Known limits, by design (Plan mode is the policy, this is a seatbelt): /usr/bin/git, sudo git,
command git, xargs git, and bash -c '...' bodies are not inspected.
git worktrees
git_worktree_list is annotated read-only (Plan mode admits it); add, remove and prune are
not. All run the real git with the same env and flags as the other git tools, take cwd and
timeout_s (default 60), and return { error } on failure with a named state in the text.
Mutations (add, remove, prune) take two locks keyed on the git COMMON dir: withLock
in-process, then withFileLock across processes, so concurrent pi panes cannot race on
.git/worktrees either. The file lock is an atomic mkdir of <common dir>/pi-dev-tools-worktree.lock
holding owner.json {pid, startedAt, token}, always released in finally (token-checked, never
throws). Only a lock whose owner pid is dead is reclaimed (plus an ownerless directory older than 2s);
there is NO age-based reclaim, a live pid is never broken. Reclaimers serialize behind a short-lived
pi-dev-tools-worktree.lock.reclaim guard directory and re-verify the same token and a dead pid inside
it. The guard records its owner with an immutable <pid>.<token> filename. Only a confirmed dead
guard owner is reclaimed, never a live owner based on age. Release/reclaim unlink only the token-owned
filename, then remove the empty guard directory, never a replacement owner's contents. Empty or
malformed guards (including a crash before owner publication) require manual inspection; bounded
lock-timeout errors name the guard path. Residual risk: PID reuse. A recycled pid makes a stale lock
look live; waiters then fail with
lock-timeout naming the pid, and a human can remove the lock directory. If owner.json cannot be
written the directory is removed and the call fails with lock-failed. Waiting is bounded at 15s,
then the call fails with lock-timeout naming the holder pid. list takes no lock. list and
prune text is capped like every other tool (truncation notice, full text spilled to a temp
file); structured content stays complete.
git_worktree_list: parsesgit worktree list --porcelain -zintopath,head,branch(short name),detached,bare,main(first entry),locked/lockReason,prunable/prunableReason. Text is one line per worktreegit_worktree_add {branch, base?, path?}: default path is<main worktree>-<slug>next to the main worktree, where slug is the branch lowercased with anything outside[a-z0-9._-]->-. A missing branch is created with-bfrombase(default HEAD); an existing branch is checked out,baseis refused for it, and a branch checked out in another worktree is refused with that path (branch checked out elsewhere). Also refused: invalid branch name, unknownbase, existing non-emptypath.branchandbasemay not start with-and go after--end-of-optionsgit_worktree_remove {path, force?}: refuses the main worktree, the session cwd (orcwd) and any parent of it (cwd is inside), a locked worktree even withforce, and a dirty one (modified or untracked) unlessforce. A worktree whose directory is gone points at prune. The branch is always keptgit_worktree_prune {dry_run?}:git worktree prune --verbose; reports{name, reason}per record,dry_runchanges nothing
Preflight checks (branch exists, base resolves, path state) separate "no" from "could not tell":
a timeout, abort, spawn failure or unexpected exit is reported as such, never as a missing
branch or bad revision. An unreadable target path is path unreadable (EACCES); a path removed
mid-check counts as free. If the final HEAD lookup fails after the worktree was created, the
error says head-unreadable and that the worktree exists.
States: branch checked out elsewhere, branch exists, path exists, path unreadable,
dirty worktree, locked worktree, main worktree, lock-timeout, lock-failed, head-unreadable, plus the shared not a git repository, unknown revision.
The Bash guard does not steer raw git worktree ...; it only blocks hook-skipping and force
pushes, as for every other git command.
gh
Eight read-only GitHub tools over the user's own gh, annotated readOnlyHint: true (and
openWorldHint: true: they reach the network) so Plan mode admits them. They are in the preset's read-only
agents; see the preset README for who gets which.
gh_issue_view {number, comments?},gh_pr_view {number, comments?, reviews?, files?}: one--jsonobject.ghanswers--jsonwith a single GraphQL query, so these spare the shared REST core limitgh_issue_list,gh_pr_list {state?, label?, author?, search?, base?, limit? <= 100}:--jsonlistsgh_pr_diff {number, files_only?}: the unified diff, or only the changed file namesgh_pr_checks {number}: the check JSON, read once. Pending checks (exit 8) and failing checks (exit 1 with the check JSON on stdout and no recognised error on stderr) are results. Any other exit 1 (404, 403/429, auth, network, "no checks reported") is a failure with its named state. Never pollgh_run_view {run_id, job?, log_failed?}: run JSON with jobs, or the failed-step log. Never pollgh_api {path, method?}: one GET of a REST path such asrepos/OWNER/REPO/pulls/1/comments?per_page=50; an unexpectedrepofield is ignored
Every tool takes cwd, timeout_s (default 60, max 300) and, except gh_api, repo (OWNER/REPO,
default: the repo of cwd).
No mutation path, by construction:
- No tool accepts a subcommand or raw argv. Each builds argv from a fixed read subcommand, and the single
gh()runner re-checks the final argv against an allowlist (issue|pr view|list,pr diff|checks,run view, andapi --method GET -- <path>) and a flag allowlist before spawning.pr merge,issue close,run rerun,--web,-f/--inputand every other command or flag are refused without runninggh gh_apiacceptsmethodonly to refuse it: anything butGET(POST, PATCH, PUT, DELETE) is an error. The path is validated: no host or scheme, no..or//, no leading-, no placeholders, nographql(it is POST only). Free-text filters (label,search,author,base) travel as--flag=value, so a value that looks like a flag stays inertghis spawned withGH_PROMPT_DISABLED,NO_COLOR,GH_PAGER=catandGH_DEBUG/DEBUGunset (debug logging would echo request headers). The token stays withgh; GitHub token shapes (ghp_,github_pat_, ...),Bearervalues and the literalGH_TOKEN/GITHUB_TOKENare blanked from output, the spill file and errors
Output is capped like every other tool (50 KiB / 2000 lines; the rest spills to a temp file). structuredContent
is { output, truncated, fullOutputPath? }, the same bounded text, not the unbounded stream.
Failures are fixed text: <tool>: not found | not authenticated | forbidden | rate limited | gh not installed | failed (exit N),
plus an excerpt of stderr that is capped at 200 characters, control-escaped and token-redacted, never raw bytes.
gh not installed means an ENOENT that names the gh binary with a working directory that exists; a missing
cwd or an EACCES is <tool>: could not start: <escaped spawn error>. Nothing retries. On rate limited the tool asks
gh api rate_limit once (that endpoint does not count against the limit) and appends the core/graphql reset
time and remaining/limit; wait for it. On forbidden (a 403 can be permissions, SAML or scope) it asks the same
once but appends the note only when a resource shows remaining 0. The hint costs one extra gh call, only on
those two states. SDK callers can inject the binary with
createDevTools({ gh: { ghBin } }).
ssh
ssh_exec {host, command, cwd?, timeout?=30} runs the user's own ssh with
-T -a -x -o BatchMode=yes -o ConnectTimeout=8 -o ClearAllForwardings=yes -o RequestTTY=no -- <host> 'exec sh -s', so the per-host ForwardAgent/ForwardX11 in ~/.ssh/config is
overridden and nothing can prompt.
hostmust match^[A-Za-z0-9][A-Za-z0-9._-]*$and be a concreteHostalias in~/.ssh/config(Includes followed, wildcards and!entries skipped). Option injection is impossible by construction and the--keeps it that way- The command travels on stdin: written to a remote
mktempfile through a quoted heredoc with a per-call random delimiter, run assh "$tmp" </dev/nullinside( ... )(so acatorreadin the command cannot eat the wrapper), then aprintf '\n__PI_RC=%d'sentinel. A trap removes the temp file even when the local ssh dies first. Inside the command$0is the temp path and there are no positional arguments. No remote argv quoting, no command inps, multi-line scripts and heredocs work, anexit Nends the command rather than the shell, and unbalanced quotes or parentheses stay inside the file (sh exits 2 with a syntax error) - States:
ok,command-failed(remote exit, including 255; NOT a tool error,grepexiting 1 is normal),cwd-missing(cdfailed: marker plus exit 97, so neither a command exiting 97 nor one printing the marker can fake it),ssh-failed(no sentinel: connection failure or a remote withoutmktemp),timeout,aborted. A timeout or abort kills the local ssh only; the remote command may keep running - Output and the spill file are redacted for
Bearer ...,token|secret|password|api_keystyle assignments in any case or quoting, and JWT signatures. Count-like keys (TOKEN_COUNT=) are over-redacted on purpose - No ControlMaster: measured steady-state gain was ~70ms per call, not worth stale sockets
- No
stdinparameter (the plan had one): the script already owns stdin, a heredoc incommandcovers the need, and Plan mode's gate refuses the key anyway - Plan mode: the
pi-plan-modefork explicitly admitsssh_execand re-validates{host, command}againstsafeSubcommands.sshand the remote reviewed policy, sorm,cd, redirects and pipes to interpreters are blocked there.ssh_execremains mutating metadata because outside Plan mode it runs whatever it is given, likebash; annotations and Plan policy are not an OS sandbox
ssh_pull {host, remote_path, local_path, overwrite?} and ssh_push {host, local_path, remote_path, overwrite?} use scp -O -q with the same options and refuse to overwrite unless
asked (ssh_push probes the remote path with test -e first; a small race remains between probe
and copy). Legacy scp hands remote_path to the remote shell, so it is restricted to
[A-Za-z0-9._/+@%:=,-]: no spaces, quotes, ~ or metacharacters. Both tools are mutating
metadata: a successful ssh_pull creates or overwrites its local destination, and ssh_push
writes the remote destination. Failures are named: missing,
permission denied, connection failed.
~/.ssh/config parsing follows OpenSSH: relative Include paths resolve against ~/.ssh, not
the including file; Host=x, quoted names, trailing comments and CRLF are handled. An Include
follows only glob matches and is skipped when its glob fails, as OpenSSH's glob(3) does. SDK
callers can pass readKnownHosts(path, { homeDir }) to expand nested ~/ Includes against an
injected home.
py
All five run uv run --frozen <tool> from the nearest pyproject.toml above cwd (the walk
stops at a .git boundary, so a stray ~/pyproject.toml cannot capture a repo), so the
project's pinned ruff/ty/pytest apply and uv.lock is never rewritten as a side effect (plain
uv run re-locks when pyproject.toml drifted). uv's own failures (no lockfile, tool not in
the environment) are reported as such, not as findings. Calls on one project are serialized
through the shared lock; a waiting call says so. NO_COLOR and UV_NO_PROGRESS are set.
Every positional the model supplies (paths, targets, select, packages) must be a plain
value and goes after --; -k/-m travel as -k=EXPR.
py_lint {paths?, fix?, select?, limit?=50}:ruff check --output-format concise;fixadds--fix --ignore-noqa(the Makefile gate's form) and reportsfixed. States:clean,findings(exit 1), tool error (exit 2). Onepath:line:col CODE [fixable] messageper finding; lines the parser does not recognise are kept underunparsedinstead of droppedpy_format {paths?, mode: check|diff|apply}:ruff format --diffforcheck(file list) anddiff(plus the capped diff), write mode forapply. Statesclean,would-reformat,reformattedpy_typecheck {paths?, limit?}:ty check --output-format concise, parsed asfile:line:col severity[rule] messagepy_test {targets?, k?, markers?, maxfail?=5, last_failed?, coverage?}:pytest --verbosity=-1 --tb=short -p no:cacheprovider --maxfail=N(--verbosity=-1is absolute, so a projectaddopts = "-q"cannot hide the summary;--lfre-enables the cache plugin;coverageadds--cov=src --cov-report=term-missing). Exit codes map topassed,failed,interrupted(2, collection error),usage-error(4),no-tests(5, not an error). Only failures are listed, from the short summary, with the failure block below them;stoppedEarlysays the run hit--maxfail. There is noextra_args: verbatim flags such as--basetempor-pwould let the model aim writes or load plugins, and Plan mode admits this toolpy_uv {action: sync|lock|add|remove, packages?, group?, dev?, all_extras?=true, all_groups?=true, locked?}:syncdefaults to--all-extras --all-groups(the Makefile uses--all-extras; groups are added so dev tools are present too);lockedfails loudly on a stale lock
Annotations: py_typecheck and py_test are read-only and admitted in Plan mode, though
py_test runs conftest.py and test code, and coverage/last_failed write .coverage and
.pytest_cache. py_lint and py_format carry a rewriting mode, so they are not (known cost:
no lint or format check in Plan mode; splitting the fix modes into their own tool would lift
it); py_uv reaches the network. All five are deferred by default (found via search_tools),
per the always-active budget.
cargo
All nine run from the outermost Cargo.toml with [workspace] above cwd (else the nearest
manifest), default to --all-features, accept package (-p) and toolchain (rustup run),
set CARGO_TERM_COLOR=never, and serialize per workspace through the shared lock (keyed on
the workspace root, not the target dir); cargo's Blocking waiting for file lock line and
Compiling progress are relayed as updates. Every bare value the model supplies (package,
features, bin, ...) must be a plain identifier-ish token; crates for cargo_add may
also carry version requirements (serde@^1); filters only need to not start with -.
A relative CARGO_TARGET_DIR resolves against the workspace root. Criterion lookups honor
that environment variable, but do not consult build.target-dir from .cargo/config.toml.
Compile diagnostics (cargo_check, cargo_clippy, cargo_build, cargo_doc) come from
--message-format=json-diagnostic-short: keyed on reason, errors and warnings only, deduped
on (level, code, primary span, message) because cargo emits one copy per target, with the
~900-char code.explanation dropped and the first suggested_replacement shown. One
file:line:col: level[code]: message per finding, errors first, capped by limit. States
clean, warnings (exit 0 but counted), errors. A non-zero exit with no compiler errors
(manifest error, missing toolchain) is a tool failure with cargo's stderr.
cargo_check {all_targets?=true}mirrorsmake checkcargo_clippy {pedantic?=true, fix?, deny_warnings?}mirrorsmake lint(--all-targets --all-features -- -W clippy::pedantic);fixadds--fix --allow-dirty --allow-stagedcargo_fmt {check?=true}:cargo fmt --all -- --check --color never(rustfmt colours even when piped);Diff in <file>:<line>:blocks give the file listcargo_test {filter?, no_fail_fast?=true, doc?=true, retries?, nocapture?}:cargo nextest runwith api-dev-toolsprofile layered UNDER the repo's own nextest config via--tool-config-file(repo retries, slow timeouts and groups still apply), junit written to an absolute path in a per-call temporary directory, removed after the run. Report lookup is independent ofCARGO_TARGET_DIR, Cargo'sbuild.target-dirand nextest's[store].dir(nextest's store does not follow Cargo's target directory). A repo override of thepi-dev-toolsprofile's junit path is reported as missing output.<failure>and<error>both count, including nextest's self-closing ones with no message or body (a timeout or a silent nonzero exit); flaky retries do not. Failure reasons use the decodedmessageattribute, falling back to decodedtypeonly whenmessageis absent, so nextest's timeouts and silent exits still have a reason. Explicit empty messages remain empty. Thencargo test --doc --no-fail-fast, skipped (and said so) when afilteris set. A filterset expression (any of( ) | & !or a leadingnot) goes to-E, a bare string is a substring match. nextest's exits map topassed,failed(100),no-tests(4),compile-error(101). Passing tests are never listed; a doctest failure flipspassedtofailedcargo_build {bin?, example?, release?}returns the executables fromcompiler-artifactcargo_run {bin?, example?, args?, stdin?, release?}: stdin closed unless given, output capped; a non-zero exit isnonzero-exit, not a tool error, and only cargo's owncould not compilecounts ascompile-error(a program may printerror:and exit 101)cargo_doc:--no-depswithRUSTDOCFLAGS=-D warnings, like the docs gatecargo_bench {bench?, filter?, save_baseline?, baseline?}: reads criterion'snew/estimates.json(ns) andchange/estimates.json(fraction) written since the run started; baseline flags imply--benchesbecause libtest harnesses reject themcargo_add {crates, dev?, build?, features?, optional?, dry_run?}reports addedname@versionvalues; inspect the manifest separately for its diff
Annotations: cargo_check, cargo_test, cargo_doc are read-only and admitted in Plan mode:
they make no direct edits, but run build.rs, proc macros and tests, which write target/.
cargo_add reaches the network; cargo_clippy and cargo_fmt have a rewriting mode, and
cargo_build, cargo_run and cargo_bench exist to produce or run binaries and baselines.
All nine are deferred (found via search_tools).
Development
External tool implementations are not part of this package's coverage denominator.
# From the monorepo root:
make install-owned
make check-ts WORKSPACES="tests/lib packages/dev-tools" # biome, tsc, coverage on Node and Bun
The session fixtures use the canonical @nredd/pi-test-lib/harness and its resource loader,
built from the public Pi root SDK and pi-ai/compat, not the fork's /testing export.
They exercise the same real session on the locked fork release and stock Pi 1.5.2.
For stock-host verification, copy the test workspaces into a disposable dependency tree,
install matching stock @earendil-works/pi-* packages and the SDK's typebox version
(1.3.27 for Pi 1.5.2), then run the same checks. Do not change shipped pins or the lockfile.
The interactive test host elsewhere in the monorepo remains fork-only; this does not establish
stock compatibility for every package or interactive internals.
Before a tag, run the monorepo gates and the matching stack checks described in the root README.
Layout
src/core/shared runner, output bounding, lock, result shapingsrc/<group>/one module per tool group, registered fromsrc/index.tstests/<group>/vitest,tests/fixtures/<group>/recorded real tool outputtests/scenarios/the extension inside a realAgentSession(@nredd/pi-test-lib/harness): faux model tool calls, pi's validation,tool_callhooks, the realbashtool and result serialization. Run under Vitest on both Node and Bun
Changelog fragments
Add changes/<issue>.<category>.md instead of editing the shared Unreleased block.
Use the one-line fragment grammar, including
its matching issue link. From the repository root, make check-changelog-fragments validates
all enrolled packages; make fold-changelog explicitly folds them without releasing.
See the release contract.
The #932 migration preserves 1 historical bullet: 1 exact bullet moves to a fragment
and 0 remain in CHANGELOG.md. The formerly ungrouped layout change uses changed.
Historical attribution and released sections are unchanged; no issue IDs are invented.