Phi Rust extension SDK (ext/rust)
Rust is a first-class language for Phi extensions — on par with the Go SDK
in ext/go. Same PXB wire protocol on stdin/stdout, same host
features (LLM tools, slash commands, intercepts, event subscriptions, confirm
dialogs), byte-for-byte interop, and the same install flow (phi.yaml + a
binary under ~/.phi/extensions/<name>/). This crate is the zero-dependency
Rust authoring side: no JSON, no reflection, no runtime deps.
Wire compatibility with the Go SDK is pinned byte-for-byte by golden tests
against ext/go/pxb/testdata/*.bin (tests/pxb_test.rs).
Layout
| Path | Role |
|---|---|
src/pxb/ |
Wire protocol: frames (codec), tagged fields (fields), message codecs (msg), types/events (types) |
src/phi/ |
Author SDK: Extension, Tool, Command, Context, Schema |
examples/ |
Runnable extensions: hello (commands, intercepts, subscribe), full (tool, confirm, submit) |
tests/ |
Golden byte-compat + end-to-end fake-host tests |
Authoring
The crate publishes to crates.io; release tags are ext/rust/vX.Y.Z. Until
the first publish, depend on it from the repo (main); after a release, use
the published version:
[]
# pre-release: tracks the latest main
= { = "https://github.com/pulseaiclub/phi", = "main" }
# release: published crate version (tagged ext/rust/vX.Y.Z)
# phi-ext = "0.1.0"
use ;
Command handlers get a phi::Context for host interaction:
notify, set_status, submit, send_user_message, confirm,
confirm_opts.
Build and install (a phi.yaml manifest must live next to the binary):
Reload in the TUI: Ctrl+K → extensions → reload.
PXB codec numbers (vs Go / JSON lines) live in the root
README. Re-run the probe with
cargo run --release --example bench.
Development
The run loop is single-threaded; the borrow checker replaces the Go SDK's
mutexes (handlers get &mut state and cannot alias the registry).