feat(pi-integration): add Pi coding agent extension with bashkit VFS#638
Merged
feat(pi-integration): add Pi coding agent extension with bashkit VFS#638
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/bashkit-pi/) that replaces built-in bash, read, write, and edit tools with bashkit virtual implementations using NAPI-RS bindingsBashclass for direct filesystem access without shell command overheadbefore_agent_starthook, with environment identity section to prevent host path leakageWhat changed
crates/bashkit-js/src/lib.rs— Add 5 VFS NAPI methods onBash:read_file,write_file,mkdir,exists,remove. These delegate directly tobash.fs()for zero-overhead VFS access from JS.crates/bashkit-js/wrapper.ts— Replace shell-based VFS helpers (cat,test -e, heredoc writes) onBashclass with native NAPI delegations. Keepls/globas shell-based convenience wrappers.examples/bashkit-pi/bashkit-extension.ts— Pi extension registering 4 tools (bash, read, write, edit) backed by a single bashkitBashinstance. 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, resetcargo test --all-features)Security review
Path::new()— no shell interpolation