@prometheus-ai/natives 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -0
- package/native/embedded-addon.js +31 -0
- package/native/index.d.ts +1405 -0
- package/native/index.js +124 -0
- package/native/loader-state.d.ts +65 -0
- package/native/loader-state.js +598 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @prometheus-ai/natives
|
|
2
|
+
|
|
3
|
+
Native Rust functionality via N-API.
|
|
4
|
+
|
|
5
|
+
## What's Inside
|
|
6
|
+
|
|
7
|
+
- **Grep**: Regex-based search powered by ripgrep's engine with native file walking and matching
|
|
8
|
+
- **Find**: Glob-based file/directory discovery with gitignore support (pure TypeScript via `globPaths`)
|
|
9
|
+
- **SIXEL**: Terminal image encoding for SIXEL-capable terminals (decode, resize, encode in one pass)
|
|
10
|
+
|
|
11
|
+
General-purpose image processing (decode/resize/encode for files and buffers)
|
|
12
|
+
lives in [`Bun.Image`](https://bun.com/docs/runtime/image) on the JS side; this
|
|
13
|
+
crate only ships the SIXEL encoder because no built-in equivalent exists for
|
|
14
|
+
that terminal protocol.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { grep, find, encodeSixel } from "@prometheus-ai/natives";
|
|
20
|
+
|
|
21
|
+
// Grep for a pattern
|
|
22
|
+
const results = await grep({
|
|
23
|
+
pattern: "TODO",
|
|
24
|
+
path: "/path/to/project",
|
|
25
|
+
glob: "*.ts",
|
|
26
|
+
context: 2,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Find files
|
|
30
|
+
const files = await find({
|
|
31
|
+
pattern: "*.rs",
|
|
32
|
+
path: "/path/to/project",
|
|
33
|
+
fileType: "file",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// SIXEL encode for a terminal cell box (px)
|
|
37
|
+
const sequence = encodeSixel(pngBytes, widthPx, heightPx);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Building
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Build native addon from workspace root (requires Rust)
|
|
44
|
+
bun run build
|
|
45
|
+
|
|
46
|
+
# Type check
|
|
47
|
+
bun run check
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Architecture
|
|
51
|
+
|
|
52
|
+
`@prometheus-ai/natives` publishes a small core package plus generated
|
|
53
|
+
platform-specific optional dependency packages:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
crates/prometheus-natives/ # Rust source (workspace member)
|
|
57
|
+
src/lib.rs # N-API exports
|
|
58
|
+
src/sixel.rs # SIXEL terminal-image encoding
|
|
59
|
+
Cargo.toml # Rust dependencies
|
|
60
|
+
native/ # Core loader files and local/CI native build outputs
|
|
61
|
+
index.js # Public native export surface
|
|
62
|
+
loader-state.js # Platform, ISA variant, and addon resolution
|
|
63
|
+
embedded-addon.js # Standalone binary embed stub/generated metadata
|
|
64
|
+
prometheus_natives.<platform>-<arch>-modern.node # x64 modern ISA (local/CI artifact)
|
|
65
|
+
prometheus_natives.<platform>-<arch>-baseline.node # x64 baseline ISA (local/CI artifact)
|
|
66
|
+
prometheus_natives.<platform>-<arch>.node # non-x64 build artifact
|
|
67
|
+
npm/<platform>-<arch>/ # Generated at publish time, not committed
|
|
68
|
+
package.json # @prometheus-ai/natives-<platform>-<arch>
|
|
69
|
+
*.node # Only that platform's addon binary or x64 ISA variants
|
|
70
|
+
src/ # TypeScript wrappers and generated declarations source
|
|
71
|
+
native.ts
|
|
72
|
+
index.ts
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The published core package contains only the JS loader, declarations, README,
|
|
76
|
+
and `package.json`. Release publishing generates one leaf package per supported
|
|
77
|
+
`os`/`cpu` pair and injects those leaves into the core manifest as pinned
|
|
78
|
+
`optionalDependencies`, so package managers install only the host platform's
|
|
79
|
+
native addon. x64 leaves include every built ISA variant, and the loader keeps
|
|
80
|
+
choosing between `baseline` and `modern` at runtime.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
// AUTOGENERATED FILE -- DO NOT EDIT DIRECTLY
|
|
3
|
+
// See scripts/embed-native.ts
|
|
4
|
+
|
|
5
|
+
/** @typedef {"modern" | "baseline" | "default"} EmbeddedAddonVariant */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} EmbeddedAddonFile
|
|
9
|
+
* @property {EmbeddedAddonVariant} variant
|
|
10
|
+
* @property {string} filename
|
|
11
|
+
* @property {number} size
|
|
12
|
+
* @property {string=} filePath
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} EmbeddedAddonArchive
|
|
17
|
+
* @property {"tar.gz"} format
|
|
18
|
+
* @property {string} filename
|
|
19
|
+
* @property {string} filePath
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} EmbeddedAddon
|
|
24
|
+
* @property {string} platformTag
|
|
25
|
+
* @property {string} version
|
|
26
|
+
* @property {EmbeddedAddonFile[]} files
|
|
27
|
+
* @property {EmbeddedAddonArchive=} archive
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** @type {EmbeddedAddon|null} */
|
|
31
|
+
export const embeddedAddon = null;
|