- Replaced the napi-cli/cargo-zigbuild/cargo-xwin/sccache build path with Bazel: rules_rust + crate_universe over Cargo.lock, hermetic zig cc toolchains (linux-gnu pinned to glibc 2.17, linux-musl), host Xcode for darwin, and a repo-local hermetic clang-cl + llvm-ml + xwin toolchain for windows-msvc (bazel/toolchains/msvc). - All eight shipped addons build as //:natives-<target> via the release transition in bazel/defs.bzl (opt, thin LTO, cgu=16, stripped, canonical .node naming); scripts/bazel-natives.ts is the single driver for local dev and CI. - Rust validation moved to bazel test + clippy aspects (strict workspace policy for opted-in crates, default lints elsewhere, mirroring cargo semantics) and the rustfmt aspect; cargo stays as the dev-iteration surface, with brush-core/brush-builtins promoted to workspace members and excluded from cargo dev tasks to keep their historical scope. - CI caches through an in-cluster bazel-remote action cache (TLS + basic auth, cluster-internal only); GitHub-hosted runners never touch the infrastructure and use an actions/cache-backed disk cache instead. - Deleted the hand-rolled caching machinery: ci-target-cache, ci-native-artifact-cache, ci-build-native, native-source-hash, find-native-artifacts, restore-linux-native, native-prewarm workflow, ensure-* toolchain actions, and all sccache/Swatinem wiring. - Warm native rebuilds drop from ~20 minutes to seconds; a cold client with a warm remote cache rebuilds the linux x64 pair in ~2.5 minutes.
@oh-my-pi/pi-natives
Native Rust functionality via N-API.
What's Inside
- Grep: Regex-based search powered by ripgrep's engine with native file walking and matching
- Find: Glob-based file/directory discovery with gitignore support (pure TypeScript via
globPaths) - SIXEL: Terminal image encoding for SIXEL-capable terminals (decode, resize, encode in one pass)
- Audio: Cross-platform low-latency microphone capture and gapless speaker playback
- WebRTC: Native Opus media, SDP offer/answer negotiation, and data-channel events for live sessions
General-purpose image processing (decode/resize/encode for files and buffers)
lives in Bun.Image on the JS side; this
crate only ships the SIXEL encoder because no built-in equivalent exists for
that terminal protocol.
Usage
import { grep, find, encodeSixel } from "@oh-my-pi/pi-natives";
// Grep for a pattern
const results = await grep({
pattern: "TODO",
path: "/path/to/project",
glob: "*.ts",
context: 2,
});
// Find files
const files = await find({
pattern: "*.rs",
path: "/path/to/project",
fileType: "file",
});
// SIXEL encode for a terminal cell box (px)
const sequence = encodeSixel(pngBytes, widthPx, heightPx);
Building
# Build native addon from workspace root (requires Rust)
bun run build
# Type check
bun run check
Architecture
@oh-my-pi/pi-natives publishes a small core package plus generated
platform-specific optional dependency packages:
crates/pi-natives/ # Rust source (workspace member)
src/lib.rs # N-API exports
src/sixel.rs # SIXEL terminal-image encoding
Cargo.toml # Rust dependencies
native/ # Core loader files and local/CI native build outputs
index.js # Public native export surface
loader-state.js # Platform, ISA variant, and addon resolution
embedded-addon.js # Standalone binary embed stub/generated metadata
pi_natives.<platform>-<arch>-modern.node # x64 modern ISA (local/CI artifact)
pi_natives.<platform>-<arch>-baseline.node # x64 baseline ISA (local/CI artifact)
pi_natives.<platform>-<arch>.node # non-x64 build artifact
npm/<platform>-<arch>/ # Generated at publish time, not committed
package.json # @oh-my-pi/pi-natives-<platform>-<arch>
*.node # Only that platform's addon binary or x64 ISA variants
The published core package contains only the JS loader, declarations, README,
and package.json. Release publishing generates one leaf package per supported
os/cpu pair and injects those leaves into the core manifest as pinned
optionalDependencies, so package managers install only the host platform's
native addon. x64 leaves include every built ISA variant, and the loader keeps
choosing between baseline and modern at runtime.