Files
oh-my-pi/packages/natives
can1357 f1f6516056 refactor: reorganized exports and removed obsolete helper branches
- Removed export leakage by demoting many helper and const symbols to module-local scope.
- Renamed underscore-prefixed internals and cache fields, then updated related references and `satisfies never` checks.
- Deleted obsolete logic branches and helpers, including harmony-stream interruption flow and unused benchmark runtime helpers.
- Updated Biome config and manifests by broadening lint coverage and removing an unused `@napi-rs/cli` dev dependency.
- Adjusted tests and utilities to use renamed test helpers and remove redundant private test-only helpers/locals.
2026-05-14 04:36:19 +02:00
..
2026-05-13 13:21:59 +02:00
2026-05-13 13:21:59 +02:00
2026-05-13 13:21:59 +02:00

@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)

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

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/                  # Native addon binaries
  pi_natives.<platform>-<arch>-modern.node   # x64 modern ISA (AVX2)
  pi_natives.<platform>-<arch>-baseline.node # x64 baseline ISA
  pi_natives.<platform>-<arch>.node          # non-x64 build artifact
src/                     # TypeScript wrappers
  native.ts              # Native addon loader
  index.ts               # Public API