@oh-my-pi/pi-natives 17.0.7 → 17.0.8
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 +134 -1
- package/native/index.js +8 -1
- package/package.json +6 -6
package/native/index.d.ts
CHANGED
|
@@ -178,7 +178,7 @@ export declare function __ompInstallTokioRuntime(): void
|
|
|
178
178
|
* `packages/natives/native/index.js` (which derives the name from
|
|
179
179
|
* `package.json#version`).
|
|
180
180
|
*/
|
|
181
|
-
export declare function
|
|
181
|
+
export declare function __piNativesV17_0_8(): void
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
|
|
@@ -470,6 +470,17 @@ export interface ContextLine {
|
|
|
470
470
|
*/
|
|
471
471
|
export declare function copyToClipboard(text: string): void
|
|
472
472
|
|
|
473
|
+
/**
|
|
474
|
+
* All pairs `(i, j)` with `i < j` whose cosine similarity meets `threshold`.
|
|
475
|
+
*
|
|
476
|
+
* `vectors` is `count` vectors flattened row-major at `dim` `f64` elements
|
|
477
|
+
* per row (zero-padded, which matches the TS `?? 0` missing-element
|
|
478
|
+
* semantics), so the similarity is bit-identical to the TS pairwise loop in
|
|
479
|
+
* `clusterBySimilarity`. Returns pairs flattened as `[i0, j0, i1, j1, ...]`
|
|
480
|
+
* in the same `(i, j)` visit order as the TS nested loop.
|
|
481
|
+
*/
|
|
482
|
+
export declare function cosineSimilarityPairs(vectors: Float64Array, count: number, dim: number, threshold: number): Uint32Array
|
|
483
|
+
|
|
473
484
|
/**
|
|
474
485
|
* Count tokens in `input`.
|
|
475
486
|
*
|
|
@@ -490,6 +501,57 @@ export declare function countTokens(input: string | Array<string>, encoding?: En
|
|
|
490
501
|
*/
|
|
491
502
|
export declare function detectMacOSAppearance(): MacOSAppearance | null
|
|
492
503
|
|
|
504
|
+
/** One jsdiff change object: a run of added, removed, or common tokens. */
|
|
505
|
+
export interface DiffChange {
|
|
506
|
+
/** Joined token text for this run (lines keep their `
|
|
507
|
+
` terminators). */
|
|
508
|
+
value: string
|
|
509
|
+
/** Number of tokens in this run. */
|
|
510
|
+
count: number
|
|
511
|
+
/** True when this run exists only in the new text. */
|
|
512
|
+
added: boolean
|
|
513
|
+
/** True when this run exists only in the old text. */
|
|
514
|
+
removed: boolean
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Diff `oldText.split("
|
|
519
|
+
")` against `newText.split("
|
|
520
|
+
")` with jsdiff
|
|
521
|
+
* `diffArrays` semantics (exact code-unit equality, empty lines preserved),
|
|
522
|
+
* returning only run lengths.
|
|
523
|
+
*
|
|
524
|
+
* Callers that map line numbers — like hashline recovery — need the counts,
|
|
525
|
+
* not another copy of the text.
|
|
526
|
+
*/
|
|
527
|
+
export declare function diffLineRuns(oldText: string, newText: string): Array<DiffRun>
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Line diff with jsdiff `diffLines(oldText, newText)` semantics (default
|
|
531
|
+
* options). Change values keep line terminators, and common runs are joined
|
|
532
|
+
* from the new text.
|
|
533
|
+
*/
|
|
534
|
+
export declare function diffLines(oldText: string, newText: string): Array<DiffChange>
|
|
535
|
+
|
|
536
|
+
/** A change run without its token text, for callers that only need counts. */
|
|
537
|
+
export interface DiffRun {
|
|
538
|
+
/** Number of tokens in this run. */
|
|
539
|
+
count: number
|
|
540
|
+
/** True when this run exists only in the new text. */
|
|
541
|
+
added: boolean
|
|
542
|
+
/** True when this run exists only in the old text. */
|
|
543
|
+
removed: boolean
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Word diff with jsdiff `diffWords(oldText, newText)` semantics (default
|
|
548
|
+
* options).
|
|
549
|
+
*
|
|
550
|
+
* Tokens carry surrounding whitespace, equality ignores it, and the
|
|
551
|
+
* post-pass dedupes whitespace across change boundaries.
|
|
552
|
+
*/
|
|
553
|
+
export declare function diffWords(oldText: string, newText: string): Array<DiffChange>
|
|
554
|
+
|
|
493
555
|
/** Ellipsis strategy for [`truncate_to_width`]. */
|
|
494
556
|
export declare enum Ellipsis {
|
|
495
557
|
/** Use a single Unicode ellipsis character ("…"). */
|
|
@@ -1199,6 +1261,28 @@ export interface MinimizerResult {
|
|
|
1199
1261
|
outputBytes: number
|
|
1200
1262
|
}
|
|
1201
1263
|
|
|
1264
|
+
/**
|
|
1265
|
+
* MMR selection over pre-sorted candidates using Jaccard word similarity.
|
|
1266
|
+
*
|
|
1267
|
+
* `contents[i]` and `scores[i]` describe candidate `i`, already sorted by
|
|
1268
|
+
* relevance exactly as the TS `mmrRerank` sorts them (the JS stable sort
|
|
1269
|
+
* stays on the TS side so its tie and NaN semantics are preserved).
|
|
1270
|
+
* Replicates the TS selection loop exactly: candidate `0` is always taken
|
|
1271
|
+
* first; each round picks the remaining candidate maximizing
|
|
1272
|
+
* `lambda * score - (1 - lambda) * maxSimilarity(selected)` with strict
|
|
1273
|
+
* `>` comparisons, so ties keep the earliest remaining candidate — and a
|
|
1274
|
+
* round where every score is `NaN` picks the first remaining candidate,
|
|
1275
|
+
* matching the TS `bestIdx = 0` initialisation. Returns the selected
|
|
1276
|
+
* indices into the input order.
|
|
1277
|
+
*
|
|
1278
|
+
* Word tokenization matches `text.toLowerCase().split(/\s+/)` (ECMA `\s`,
|
|
1279
|
+
* Unicode default full case conversion). Known divergence: unpaired
|
|
1280
|
+
* surrogates arrive here as U+FFFD, while JS keeps the lone surrogate; both
|
|
1281
|
+
* tokenize to a single non-whitespace word so Jaccard counts still agree
|
|
1282
|
+
* unless a text mixes U+FFFD words with lone-surrogate words.
|
|
1283
|
+
*/
|
|
1284
|
+
export declare function mmrRerankIndices(contents: Array<string>, scores: Float64Array, lambdaParam: number, topK: number): Uint32Array
|
|
1285
|
+
|
|
1202
1286
|
/** Parsed Kitty keyboard protocol sequence result for a Kitty input sequence. */
|
|
1203
1287
|
export interface ParsedKittyResult {
|
|
1204
1288
|
/** Primary codepoint associated with the key. */
|
|
@@ -1227,6 +1311,23 @@ export declare function parseKey(data: string, kittyProtocolActive: boolean): st
|
|
|
1227
1311
|
*/
|
|
1228
1312
|
export declare function parseKittySequence(data: string): ParsedKittyResult | null
|
|
1229
1313
|
|
|
1314
|
+
/** One hunk of a unified diff, matching jsdiff `structuredPatch` hunks. */
|
|
1315
|
+
export interface PatchHunk {
|
|
1316
|
+
/** 1-based first line of the hunk in the old text. */
|
|
1317
|
+
oldStart: number
|
|
1318
|
+
/** Number of old-text lines covered by the hunk. */
|
|
1319
|
+
oldLines: number
|
|
1320
|
+
/** 1-based first line of the hunk in the new text. */
|
|
1321
|
+
newStart: number
|
|
1322
|
+
/** Number of new-text lines covered by the hunk. */
|
|
1323
|
+
newLines: number
|
|
1324
|
+
/**
|
|
1325
|
+
* Hunk body: `+`/`-`/` `-prefixed lines without trailing newlines, plus
|
|
1326
|
+
* `` markers where applicable.
|
|
1327
|
+
*/
|
|
1328
|
+
lines: Array<string>
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1230
1331
|
/** Current state of a process reference. */
|
|
1231
1332
|
export declare enum ProcessStatus {
|
|
1232
1333
|
/** The referenced process is still running. */
|
|
@@ -1530,6 +1631,13 @@ export interface SnapcompactRenderOptions {
|
|
|
1530
1631
|
*/
|
|
1531
1632
|
export declare function snapcompactSupportedChars(font: string, chars: string): string
|
|
1532
1633
|
|
|
1634
|
+
/**
|
|
1635
|
+
* Unified-diff hunks with jsdiff
|
|
1636
|
+
* `structuredPatch(_, _, oldText, newText, _, _, { context }).hunks`
|
|
1637
|
+
* semantics. `context` defaults to 4 like jsdiff.
|
|
1638
|
+
*/
|
|
1639
|
+
export declare function structuredPatchHunks(oldText: string, newText: string, context?: number | undefined | null): Array<PatchHunk>
|
|
1640
|
+
|
|
1533
1641
|
export declare function summarizeCode(options: SummaryOptions): SummaryResult
|
|
1534
1642
|
|
|
1535
1643
|
export interface SummaryOptions {
|
|
@@ -1593,6 +1701,31 @@ export declare function supportsLanguage(lang: string): boolean
|
|
|
1593
1701
|
*/
|
|
1594
1702
|
export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind: Ellipsis | undefined | null, pad: boolean | undefined | null, tabWidth: number): string
|
|
1595
1703
|
|
|
1704
|
+
/**
|
|
1705
|
+
* Score every row of a normalized `f32` matrix against `query` and return
|
|
1706
|
+
* the top `limit` rows.
|
|
1707
|
+
*
|
|
1708
|
+
* Mirrors the TS `searchExactVectorIndex` loop bit-exactly: the query is
|
|
1709
|
+
* normalized by the L2 norm of its *full* length, each row score sums
|
|
1710
|
+
* `matrix[row][col] * (query[col] / norm)` over
|
|
1711
|
+
* `min(query.len, dimensions)` columns in column order. Ranking matches the
|
|
1712
|
+
* TS stable sort: score descending, lower row index first on exact ties
|
|
1713
|
+
* (`-0.0` and `+0.0` compare equal). Callers are expected to enforce the TS
|
|
1714
|
+
* guards first (finite query with a positive norm, non-empty matrix).
|
|
1715
|
+
*/
|
|
1716
|
+
export declare function vectorIndexTopK(matrix: Float32Array, dimensions: number, query: Float64Array, limit: number): VectorTopK
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Top-k rows of a normalized vector matrix ranked by dot product with a
|
|
1720
|
+
* normalized query.
|
|
1721
|
+
*/
|
|
1722
|
+
export interface VectorTopK {
|
|
1723
|
+
/** Row indices of the selected hits, best score first. */
|
|
1724
|
+
indices: Uint32Array
|
|
1725
|
+
/** Scores aligned with `indices`. */
|
|
1726
|
+
scores: Float64Array
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1596
1729
|
/**
|
|
1597
1730
|
* Calculate visible width of text, excluding ANSI escape sequences.
|
|
1598
1731
|
*
|
package/native/index.js
CHANGED
|
@@ -24,14 +24,18 @@ export const Shell = nativeBindings.Shell;
|
|
|
24
24
|
|
|
25
25
|
// functions
|
|
26
26
|
export const __ompInstallTokioRuntime = nativeBindings.__ompInstallTokioRuntime;
|
|
27
|
-
export const
|
|
27
|
+
export const __piNativesV17_0_8 = nativeBindings.__piNativesV17_0_8;
|
|
28
28
|
export const astEdit = nativeBindings.astEdit;
|
|
29
29
|
export const astGrep = nativeBindings.astGrep;
|
|
30
30
|
export const astMatch = nativeBindings.astMatch;
|
|
31
31
|
export const blockRangeAt = nativeBindings.blockRangeAt;
|
|
32
32
|
export const copyToClipboard = nativeBindings.copyToClipboard;
|
|
33
|
+
export const cosineSimilarityPairs = nativeBindings.cosineSimilarityPairs;
|
|
33
34
|
export const countTokens = nativeBindings.countTokens;
|
|
34
35
|
export const detectMacOSAppearance = nativeBindings.detectMacOSAppearance;
|
|
36
|
+
export const diffLineRuns = nativeBindings.diffLineRuns;
|
|
37
|
+
export const diffLines = nativeBindings.diffLines;
|
|
38
|
+
export const diffWords = nativeBindings.diffWords;
|
|
35
39
|
export const enclosingBlockBoundaries = nativeBindings.enclosingBlockBoundaries;
|
|
36
40
|
export const encodeSixel = nativeBindings.encodeSixel;
|
|
37
41
|
export const executeShell = nativeBindings.executeShell;
|
|
@@ -56,6 +60,7 @@ export const listWorkspace = nativeBindings.listWorkspace;
|
|
|
56
60
|
export const matchesKey = nativeBindings.matchesKey;
|
|
57
61
|
export const matchesKittySequence = nativeBindings.matchesKittySequence;
|
|
58
62
|
export const matchesLegacySequence = nativeBindings.matchesLegacySequence;
|
|
63
|
+
export const mmrRerankIndices = nativeBindings.mmrRerankIndices;
|
|
59
64
|
export const parseKey = nativeBindings.parseKey;
|
|
60
65
|
export const parseKittySequence = nativeBindings.parseKittySequence;
|
|
61
66
|
export const readImageFromClipboard = nativeBindings.readImageFromClipboard;
|
|
@@ -64,9 +69,11 @@ export const search = nativeBindings.search;
|
|
|
64
69
|
export const setHangulCompatJamoWidthOverride = nativeBindings.setHangulCompatJamoWidthOverride;
|
|
65
70
|
export const sliceWithWidth = nativeBindings.sliceWithWidth;
|
|
66
71
|
export const snapcompactSupportedChars = nativeBindings.snapcompactSupportedChars;
|
|
72
|
+
export const structuredPatchHunks = nativeBindings.structuredPatchHunks;
|
|
67
73
|
export const summarizeCode = nativeBindings.summarizeCode;
|
|
68
74
|
export const supportsLanguage = nativeBindings.supportsLanguage;
|
|
69
75
|
export const truncateToWidth = nativeBindings.truncateToWidth;
|
|
76
|
+
export const vectorIndexTopK = nativeBindings.vectorIndexTopK;
|
|
70
77
|
export const visibleWidth = nativeBindings.visibleWidth;
|
|
71
78
|
export const wrapTextWithAnsi = nativeBindings.wrapTextWithAnsi;
|
|
72
79
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-natives",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.8",
|
|
4
4
|
"description": "Native Rust bindings for grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@oh-my-pi/pi-natives-linux-x64": "17.0.
|
|
71
|
-
"@oh-my-pi/pi-natives-linux-arm64": "17.0.
|
|
72
|
-
"@oh-my-pi/pi-natives-darwin-x64": "17.0.
|
|
73
|
-
"@oh-my-pi/pi-natives-darwin-arm64": "17.0.
|
|
74
|
-
"@oh-my-pi/pi-natives-win32-x64": "17.0.
|
|
70
|
+
"@oh-my-pi/pi-natives-linux-x64": "17.0.8",
|
|
71
|
+
"@oh-my-pi/pi-natives-linux-arm64": "17.0.8",
|
|
72
|
+
"@oh-my-pi/pi-natives-darwin-x64": "17.0.8",
|
|
73
|
+
"@oh-my-pi/pi-natives-darwin-arm64": "17.0.8",
|
|
74
|
+
"@oh-my-pi/pi-natives-win32-x64": "17.0.8"
|
|
75
75
|
}
|
|
76
76
|
}
|