npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kaged/natives

v0.0.2

Published

Rust N-API bindings providing high-performance grep, glob, AST search, fd, workspace profiling, and fs-cache operations via native platform binaries

Downloads

248

Readme

影 @kaged/natives

shadow ops for your [filesystem]

Rust N-API bindings that give Node and Bun native-speed grep, glob, AST search, fuzzy find, workspace profiling, and fs-cache operations — shipped as prebuilt platform binaries.

npm license platforms


what it is

@kaged/natives is the native engine room of kaged. It wraps battle-tested Rust crates — grep-searcher, ignore, globset, ast-grep-core, inferno — behind a single typed N-API surface. One import, one loadNative(), and you get search primitives that run far closer to the metal than any JS reimplementation.

It was split out of the main kaged workspace because it has a different build chain (Rust + @napi-rs/cli) and a slower iteration cadence. It builds, tests, and publishes from GitHub Actions.

> 影 @kaged/natives
> grep ............... ripgrep-grade content search
> glob ............... gitignore-aware filesystem discovery
> ast ................ ast-grep find + structural rewrite
> fd ................. fuzzy path matching
> summary ........... structural source summaries
> workspace ......... bounded workspace scans
> prof .............. on-CPU work profiling + flamegraphs
> system nominal.

install

bun add @kaged/natives
# or
npm install @kaged/natives

The correct prebuilt binary is pulled in automatically for your platform. No Rust toolchain required to consume.


quick start

import { loadNative } from "@kaged/natives";

const native = loadNative();

// content search across the filesystem (ripgrep-grade)
const result = await native.grep({
  pattern: "loadNative",
  path: "./src",
  gitignore: true,
  context: 2,
});

console.log(result.totalMatches, "matches in", result.filesWithMatches, "files");

loadNative() resolves the platform binary once and caches it. It prefers a local dev build under native/, then falls back to the published per-platform package.


the surface

Every export is fully typed. loadNative() returns a NativeBindings object with the following methods.

grep — content search

// search a string / buffer in memory
native.search(content, { pattern, ignoreCase, context, mode });

// fast boolean test
native.hasMatch(content, pattern, ignoreCase, multiline);

// walk the filesystem, gitignore-aware, with optional streaming callback
await native.grep(
  { pattern, path, glob, gitignore: true, context: 2 },
  (err, match) => { /* streamed per match */ },
);

Output modes: content, count, filesWithMatches. Supports maxCount, offset, before/after context, column limits, multiline, AbortSignal, and timeoutMs.

glob — filesystem discovery

const { matches } = await native.glob({
  pattern: "**/*.ts",
  path: ".",
  gitignore: true,
  sortByMtime: true,
});

Returns entries with path, fileType, mtime, and size. Honors hidden-file rules, .gitignore, node_modules exclusion, and result caps.

ast — structural search & rewrite

// find by ast-grep pattern
const found = await native.astGrep({
  patterns: ["console.log($MSG)"],
  lang: "typescript",
  path: "./src",
  includeMeta: true,
});

// structural rewrite (dry-run by default)
const edit = await native.astEdit({
  rewrites: { "console.log($MSG)": "logger.debug($MSG)" },
  lang: "typescript",
  path: "./src",
  dryRun: true,
});

Match strictness spans cst · smart · ast · relaxed · signature · template. Replacement results carry per-change byte ranges and per-file counts.

fd — fuzzy path find

const { matches } = await native.fuzzyFind({
  query: "loadnat",
  path: ".",
  gitignore: true,
});

Returns scored path matches, directories flagged.

summary — structural source summaries

const summary = native.summarizeCode({ code, lang: "typescript" });

Returns kept / elided segments so large files can be condensed structurally rather than truncated blindly.

workspace — bounded scans

const ws = await native.listWorkspace({
  path: ".",
  maxDepth: 4,
  collectAgentsMd: true,
});

Depth-bounded directory listing with optional AGENTS.md collection.

prof — work profiling

const profile = native.getWorkProfile(30); // last 30s
// profile.folded, profile.summary, profile.svg (flamegraph)

fs-cache

native.invalidateFsScanCache();        // clear everything
native.invalidateFsScanCache("./src"); // scoped invalidation

supported platforms

| Platform | Triple | Status | |---|---|---| | Linux x64 | x86_64-unknown-linux-gnu | [LIVE] | | Linux arm64 | aarch64-unknown-linux-gnu | [LIVE] | | macOS x64 | x86_64-apple-darwin | [LIVE] | | macOS arm64 | aarch64-apple-darwin | [LIVE] |

Loading on an unsupported platform-arch throws a clear error rather than failing silently.


development

Requires the Rust toolchain (pinned via rust-toolchain.toml) and Bun.

bun install
bun run build       # release build → native/
bun run build:dev   # debug build
bun test
bun run typecheck
bun run format      # biome

The TypeScript types in src/types.ts are hand-written to mirror the #[napi] structs in crates/kaged-natives — there is no codegen step, so keep them in sync when Rust types change.


license

AGPL-3.0 © the kaged project

[kaged] · kaged.dev · sanctioned edge, sacred code