@oh-my-pi/pi-natives 17.3.7 → 17.4.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/native/index.d.ts CHANGED
@@ -279,7 +279,7 @@ export declare function __ompInstallTokioRuntime(): void
279
279
  * `packages/natives/native/index.js` (which derives the name from
280
280
  * `package.json#version`).
281
281
  */
282
- export declare function __piNativesV17_3_7(): void
282
+ export declare function __piNativesV17_4_0(): void
283
283
 
284
284
  /**
285
285
  * Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
@@ -630,15 +630,17 @@ export declare function cosineSimilarityPairs(vectors: Float64Array, count: numb
630
630
  * Count tokens in `input`.
631
631
  *
632
632
  * `input` may be a single string or an array of strings; an array returns
633
- * the sum across all elements (encoded in parallel via rayon when the global
634
- * pool is available). Always returns a single token total — use this for any
633
+ * the sum across all elements (counted in parallel when the global rayon pool
634
+ * is available). Always returns a single token total — use this for any
635
635
  * aggregate budget question without paying a per-element napi crossing.
636
636
  *
637
- * Uses ordinary encoding (no special-token handling), which is the right
638
- * choice for measuring user/model content rather than wire-protocol tokens.
639
- * Defaults to `o200k_base`; pass `Cl100kBase` for older `OpenAI` models.
637
+ * Measures user/model content, not wire-protocol tokens: BPE encodings
638
+ * use ordinary encoding (no special-token handling) and the Claude
639
+ * encodings count message content without the fixed per-message frame.
640
+ * Defaults to `o200k_base`; pass a `Claude*` encoding for exact Claude
641
+ * counts, or the matching family encoding for Qwen/DeepSeek/Kimi/GLM.
640
642
  */
641
- export declare function countTokens(input: string | Array<string>, encoding?: Encoding | undefined | null): number
643
+ export declare function countTokens(input: string | string[], encoding?: Encoding | undefined | null): number
642
644
 
643
645
  export interface DesktopCapabilities {
644
646
  backend: string
@@ -853,7 +855,23 @@ export declare enum Encoding {
853
855
  /** GPT-4o / o1 / GPT-5 (default). */
854
856
  O200kBase = 'O200kBase',
855
857
  /** GPT-3.5 / GPT-4 / older. */
856
- Cl100kBase = 'Cl100kBase'
858
+ Cl100kBase = 'Cl100kBase',
859
+ /** Claude 3 … Opus 4.6 (ctok v3 reconstruction). */
860
+ ClaudeV3 = 'ClaudeV3',
861
+ /** Claude Opus 4.7–4.9 (ctok v4.7 reconstruction). */
862
+ ClaudeV47 = 'ClaudeV47',
863
+ /** Claude Opus 5+ (ctok v5 reconstruction). */
864
+ ClaudeV5 = 'ClaudeV5',
865
+ /** Claude Sonnet/Fable 5+ (live-measured non-opus v5 frame). */
866
+ ClaudeV5Sonnet = 'ClaudeV5Sonnet',
867
+ /** Qwen 3.5 / 3.6 / 3.8 (248k vocabulary). */
868
+ Qwen3 = 'Qwen3',
869
+ /** `DeepSeek` V3 … V4 (identical base BPE). */
870
+ DeepSeekV3 = 'DeepSeekV3',
871
+ /** Kimi K2 … K3. */
872
+ KimiK2 = 'KimiK2',
873
+ /** GLM-5.x exact; GLM-4.x near-exact. */
874
+ Glm5 = 'Glm5'
857
875
  }
858
876
 
859
877
  /**
@@ -1533,6 +1551,26 @@ export interface MinimizerResult {
1533
1551
  */
1534
1552
  export declare function mmrRerankIndices(contents: Array<string>, scores: Float64Array, lambdaParam: number, topK: number): Uint32Array
1535
1553
 
1554
+ /**
1555
+ * Named-node chain containing `options.line`, innermost-first, excluding the
1556
+ * whole-file root.
1557
+ *
1558
+ * Single-line nodes beginning on the line (attributes, decorators) come
1559
+ * first, followed by every enclosing construct. ERROR/MISSING recovery nodes
1560
+ * are skipped. Returns `null` when the language is unrecognized, the line is
1561
+ * out of range / blank, or the source fails to parse entirely.
1562
+ */
1563
+ export declare function nodeChainAt(options: BlockRangeOptions): Array<NodeSpan> | null
1564
+
1565
+ export interface NodeSpan {
1566
+ /** 1-indexed inclusive first line of the node. */
1567
+ startLine: number
1568
+ /** 1-indexed inclusive last content line of the node. */
1569
+ endLine: number
1570
+ /** Tree-sitter grammar node kind (e.g. `attribute_item`, `function_item`). */
1571
+ kind: string
1572
+ }
1573
+
1536
1574
  /** Parsed Kitty keyboard protocol sequence result for a Kitty input sequence. */
1537
1575
  export interface ParsedKittyResult {
1538
1576
  /** Primary codepoint associated with the key. */
package/native/index.js CHANGED
@@ -29,7 +29,7 @@ export const Shell = nativeBindings.Shell;
29
29
 
30
30
  // functions
31
31
  export const __ompInstallTokioRuntime = nativeBindings.__ompInstallTokioRuntime;
32
- export const __piNativesV17_3_7 = nativeBindings.__piNativesV17_3_7;
32
+ export const __piNativesV17_4_0 = nativeBindings.__piNativesV17_4_0;
33
33
  export const astEdit = nativeBindings.astEdit;
34
34
  export const astGrep = nativeBindings.astGrep;
35
35
  export const astMatch = nativeBindings.astMatch;
@@ -67,6 +67,7 @@ export const matchesKey = nativeBindings.matchesKey;
67
67
  export const matchesKittySequence = nativeBindings.matchesKittySequence;
68
68
  export const matchesLegacySequence = nativeBindings.matchesLegacySequence;
69
69
  export const mmrRerankIndices = nativeBindings.mmrRerankIndices;
70
+ export const nodeChainAt = nativeBindings.nodeChainAt;
70
71
  export const parseKey = nativeBindings.parseKey;
71
72
  export const parseKittySequence = nativeBindings.parseKittySequence;
72
73
  export const pdfToMarkdown = nativeBindings.pdfToMarkdown;
@@ -101,6 +102,14 @@ export const Ellipsis = {
101
102
  export const Encoding = {
102
103
  O200kBase: "O200kBase",
103
104
  Cl100kBase: "Cl100kBase",
105
+ ClaudeV3: "ClaudeV3",
106
+ ClaudeV47: "ClaudeV47",
107
+ ClaudeV5: "ClaudeV5",
108
+ ClaudeV5Sonnet: "ClaudeV5Sonnet",
109
+ Qwen3: "Qwen3",
110
+ DeepSeekV3: "DeepSeekV3",
111
+ KimiK2: "KimiK2",
112
+ Glm5: "Glm5",
104
113
  };
105
114
  export const FileType = {
106
115
  File: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-natives",
3
- "version": "17.3.7",
3
+ "version": "17.4.0",
4
4
  "description": "Native Rust bindings for PDF conversion, audio, WebRTC, grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API",
5
5
  "type": "module",
6
6
  "homepage": "https://omp.sh",
@@ -40,11 +40,19 @@
40
40
  "gen:native": "bun scripts/embed-native.ts",
41
41
  "gen:native:reset": "bun scripts/embed-native.ts --reset",
42
42
  "gen:npm": "bun scripts/gen-npm-packages.ts",
43
- "bench": "bun bench/grep.ts"
43
+ "bench": "bun bench/grep.ts",
44
+ "bench:text": "bun bench/text.ts"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@napi-rs/cli": "3.7.2",
47
- "@types/bun": "^1.3.14"
48
+ "@types/bun": "^1.3.14",
49
+ "cli-truncate": "6.1.1",
50
+ "diff": "9.0.0",
51
+ "gpt-tokenizer": "4.0.0",
52
+ "mitata": "1.0.34",
53
+ "slice-ansi": "9.0.0",
54
+ "string-width": "8.2.2",
55
+ "wrap-ansi": "10.0.0"
48
56
  },
49
57
  "engines": {
50
58
  "bun": ">=1.3.14"
@@ -80,10 +88,10 @@
80
88
  }
81
89
  },
82
90
  "optionalDependencies": {
83
- "@oh-my-pi/pi-natives-linux-x64": "17.3.7",
84
- "@oh-my-pi/pi-natives-linux-arm64": "17.3.7",
85
- "@oh-my-pi/pi-natives-darwin-x64": "17.3.7",
86
- "@oh-my-pi/pi-natives-darwin-arm64": "17.3.7",
87
- "@oh-my-pi/pi-natives-win32-x64": "17.3.7"
91
+ "@oh-my-pi/pi-natives-linux-x64": "17.4.0",
92
+ "@oh-my-pi/pi-natives-linux-arm64": "17.4.0",
93
+ "@oh-my-pi/pi-natives-darwin-x64": "17.4.0",
94
+ "@oh-my-pi/pi-natives-darwin-arm64": "17.4.0",
95
+ "@oh-my-pi/pi-natives-win32-x64": "17.4.0"
88
96
  }
89
97
  }