Skip to content

feat(pi-integration): add Pi coding agent extension with bashkit VFS#638

Merged
chaliy merged 11 commits intomainfrom
claude/pi-bashkit-integration-r47Vq
Mar 15, 2026
Merged

feat(pi-integration): add Pi coding agent extension with bashkit VFS#638
chaliy merged 11 commits intomainfrom
claude/pi-bashkit-integration-r47Vq

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 15, 2026

Summary

  • Add Pi coding agent extension (examples/bashkit-pi/) that replaces built-in bash, read, write, and edit tools with bashkit virtual implementations using NAPI-RS bindings
  • Expose VFS APIs (readFile, writeFile, mkdir, exists, remove) via NAPI on the Bash class for direct filesystem access without shell command overhead
  • Inject bashkit system prompt into LLM context via before_agent_start hook, with environment identity section to prevent host path leakage
  • Update implementation status spec with JavaScript bindings documentation

What changed

crates/bashkit-js/src/lib.rs — Add 5 VFS NAPI methods on Bash: read_file, write_file, mkdir, exists, remove. These delegate directly to bash.fs() for zero-overhead VFS access from JS.

crates/bashkit-js/wrapper.ts — Replace shell-based VFS helpers (cat, test -e, heredoc writes) on Bash class with native NAPI delegations. Keep ls/glob as shell-based convenience wrappers.

examples/bashkit-pi/bashkit-extension.ts — Pi extension registering 4 tools (bash, read, write, edit) backed by a single bashkit Bash instance. VFS and shell state stay in sync.

specs/009-implementation-status.md — Add Language Bindings section documenting JS/Node.js API surface and platform matrix.

Tests added/verified

  • crates/bashkit-js/__test__/vfs.spec.ts — 18 tests covering readFile/writeFile roundtrip, mkdir, exists, remove, VFS↔bash interop, reset
  • All Rust tests pass (cargo test --all-features)
  • Clippy clean, fmt clean
  • Smoke tested VFS APIs end-to-end from Node.js

Security review

  • VFS methods delegate to sandboxed filesystem — no host access possible
  • Native NAPI VFS methods eliminate shell metacharacter injection vectors present in old shell-based helpers
  • Path handling via Path::new() — no shell interpolation

chaliy added 11 commits March 15, 2026 01:47
…al bash

Pi extension that replaces the built-in bash tool with bashkit's virtual
bash interpreter and virtual filesystem. Commands execute in a sandboxed
in-memory environment with 100+ builtins, state persistence across calls.

Includes:
- bashkit-extension.ts: Pi extension registering virtual bash tool
- bashkit_server.py: Persistent Python process bridging pi to bashkit
- README.md: Setup and usage documentation
…ools

Replace Python bashkit_server with Rust pi_server binary. Now all four
pi tools (bash, read, write, edit) are backed by bashkit's virtual FS.

- pi_server.rs: JSON-line Rust server using bashkit directly
- bashkit-extension.ts: replaces all 4 pi tools with VFS-backed versions
- Move from pi-integration/ to examples/bashkit-pi/
…rocess

Replace pi_server.rs subprocess with direct @everruns/bashkit NAPI-RS
bindings loaded in-process. No Python, no subprocess — bashkit runs
natively in pi's Node.js process. All 4 pi tools (bash, read, write,
edit) backed by a single shared Bash instance and virtual filesystem.
…r, exists, remove)

Add direct filesystem methods to the Bash NAPI class so consumers
can read/write/mkdir/exists/remove without routing through bash
commands. Pi extension updated to use direct VFS for read/write/edit
tools — eliminates shell quoting and heredoc fragility.
…ts, remove)

19 tests covering direct VFS operations and VFS↔bash interop:
- readFile/writeFile roundtrip, overwrite, empty, missing file
- mkdir recursive and non-recursive, error on missing parent
- exists for files, directories, and missing paths
- remove file, recursive dir, missing path error
- bidirectional interop: bash sees VFS files and vice versa
- reset clears VFS state
…tart

Appends a detailed system prompt explaining the bashkit virtual
environment to the LLM: available builtins, what's NOT available
(python, pip, git, network), VFS semantics, and best practices.
Prevents wasted tool calls on unsupported commands.
… path leakage

PI injects runtime context (host working directory, project instructions)
into the system prompt. The model was leaking those host paths in responses.
Added explicit instructions telling the model to ignore host paths, use
only virtual filesystem paths rooted at /home/user, and never reference
runtime context details.
…icating bashkit prompt

Replace the hand-written 40-line system prompt with bashkit's generic
system prompt from BashTool.systemPrompt(), adding only PI-specific
additions (host path isolation, VFS tool descriptions). Also use
bashTool.description() for the bash tool registration.
The default 10,000 command limit is too low for scripts that process
many files (e.g. 100 files × ~5 fields × multiple commands = >10k).
@chaliy chaliy merged commit 80a84df into main Mar 15, 2026
16 checks passed
@chaliy chaliy deleted the claude/pi-bashkit-integration-r47Vq branch March 15, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant