gsd-pi 2.10.0 → 2.10.2

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.
Files changed (157) hide show
  1. package/node_modules/@gsd/native/dist/ast/index.d.ts +4 -0
  2. package/node_modules/@gsd/native/dist/ast/index.js +7 -0
  3. package/node_modules/@gsd/native/dist/ast/types.d.ts +69 -0
  4. package/node_modules/@gsd/native/dist/ast/types.js +1 -0
  5. package/node_modules/@gsd/native/{src/clipboard/index.ts → dist/clipboard/index.d.ts} +3 -15
  6. package/node_modules/@gsd/native/dist/clipboard/index.js +33 -0
  7. package/node_modules/@gsd/native/dist/clipboard/types.d.ts +7 -0
  8. package/node_modules/@gsd/native/dist/clipboard/types.js +1 -0
  9. package/node_modules/@gsd/native/dist/diff/index.d.ts +33 -0
  10. package/node_modules/@gsd/native/dist/diff/index.js +38 -0
  11. package/node_modules/@gsd/native/dist/diff/types.d.ts +23 -0
  12. package/node_modules/@gsd/native/dist/diff/types.js +1 -0
  13. package/node_modules/@gsd/native/{src/fd/index.ts → dist/fd/index.d.ts} +2 -12
  14. package/node_modules/@gsd/native/dist/fd/index.js +26 -0
  15. package/node_modules/@gsd/native/dist/fd/types.d.ts +29 -0
  16. package/node_modules/@gsd/native/dist/fd/types.js +1 -0
  17. package/node_modules/@gsd/native/{src/glob/index.ts → dist/glob/index.d.ts} +3 -19
  18. package/node_modules/@gsd/native/dist/glob/index.js +31 -0
  19. package/node_modules/@gsd/native/dist/glob/types.d.ts +50 -0
  20. package/node_modules/@gsd/native/dist/glob/types.js +1 -0
  21. package/node_modules/@gsd/native/dist/grep/index.d.ts +20 -0
  22. package/node_modules/@gsd/native/dist/grep/index.js +23 -0
  23. package/node_modules/@gsd/native/dist/grep/types.d.ts +99 -0
  24. package/node_modules/@gsd/native/dist/grep/types.js +1 -0
  25. package/node_modules/@gsd/native/dist/gsd-parser/index.d.ts +45 -0
  26. package/node_modules/@gsd/native/dist/gsd-parser/index.js +54 -0
  27. package/node_modules/@gsd/native/dist/gsd-parser/types.d.ts +55 -0
  28. package/node_modules/@gsd/native/dist/gsd-parser/types.js +7 -0
  29. package/node_modules/@gsd/native/{src/highlight/index.ts → dist/highlight/index.d.ts} +3 -19
  30. package/node_modules/@gsd/native/dist/highlight/index.js +33 -0
  31. package/node_modules/@gsd/native/dist/highlight/types.d.ts +25 -0
  32. package/node_modules/@gsd/native/dist/highlight/types.js +1 -0
  33. package/node_modules/@gsd/native/{src/html/index.ts → dist/html/index.d.ts} +1 -10
  34. package/node_modules/@gsd/native/dist/html/index.js +16 -0
  35. package/node_modules/@gsd/native/dist/html/types.d.ts +7 -0
  36. package/node_modules/@gsd/native/dist/html/types.js +1 -0
  37. package/node_modules/@gsd/native/{src/image/index.ts → dist/image/index.d.ts} +1 -14
  38. package/node_modules/@gsd/native/dist/image/index.js +18 -0
  39. package/node_modules/@gsd/native/dist/image/types.d.ts +35 -0
  40. package/node_modules/@gsd/native/dist/image/types.js +26 -0
  41. package/node_modules/@gsd/native/{src/index.ts → dist/index.d.ts} +12 -60
  42. package/node_modules/@gsd/native/dist/index.js +28 -0
  43. package/node_modules/@gsd/native/dist/native.d.ts +44 -0
  44. package/node_modules/@gsd/native/dist/native.js +34 -0
  45. package/node_modules/@gsd/native/dist/ps/index.d.ts +38 -0
  46. package/node_modules/@gsd/native/{src/ps/index.ts → dist/ps/index.js} +8 -13
  47. package/node_modules/@gsd/native/{src/ps/types.ts → dist/ps/types.d.ts} +2 -2
  48. package/node_modules/@gsd/native/dist/ps/types.js +1 -0
  49. package/node_modules/@gsd/native/{src/text/index.ts → dist/text/index.d.ts} +6 -76
  50. package/node_modules/@gsd/native/dist/text/index.js +66 -0
  51. package/node_modules/@gsd/native/dist/text/types.d.ts +27 -0
  52. package/node_modules/@gsd/native/dist/text/types.js +10 -0
  53. package/node_modules/@gsd/native/{src/ttsr/index.ts → dist/ttsr/index.d.ts} +3 -15
  54. package/node_modules/@gsd/native/dist/ttsr/index.js +32 -0
  55. package/node_modules/@gsd/native/{src/ttsr/types.ts → dist/ttsr/types.d.ts} +4 -5
  56. package/node_modules/@gsd/native/dist/ttsr/types.js +1 -0
  57. package/node_modules/@gsd/native/package.json +24 -23
  58. package/node_modules/@gsd/pi-coding-agent/dist/core/tools/edit-diff.d.ts +11 -5
  59. package/node_modules/@gsd/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -1
  60. package/node_modules/@gsd/pi-coding-agent/dist/core/tools/edit-diff.js +19 -142
  61. package/node_modules/@gsd/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -1
  62. package/node_modules/@gsd/pi-coding-agent/src/core/tools/edit-diff.ts +23 -157
  63. package/package.json +4 -2
  64. package/packages/native/dist/ast/index.d.ts +4 -0
  65. package/packages/native/dist/ast/index.js +7 -0
  66. package/packages/native/dist/ast/types.d.ts +69 -0
  67. package/packages/native/dist/ast/types.js +1 -0
  68. package/packages/native/dist/clipboard/index.d.ts +28 -0
  69. package/packages/native/dist/clipboard/index.js +33 -0
  70. package/packages/native/dist/clipboard/types.d.ts +7 -0
  71. package/packages/native/dist/clipboard/types.js +1 -0
  72. package/packages/native/dist/diff/index.d.ts +33 -0
  73. package/packages/native/dist/diff/index.js +38 -0
  74. package/packages/native/dist/diff/types.d.ts +23 -0
  75. package/packages/native/dist/diff/types.js +1 -0
  76. package/packages/native/dist/fd/index.d.ts +25 -0
  77. package/packages/native/dist/fd/index.js +26 -0
  78. package/packages/native/dist/fd/types.d.ts +29 -0
  79. package/packages/native/dist/fd/types.js +1 -0
  80. package/packages/native/dist/glob/index.d.ts +28 -0
  81. package/packages/native/dist/glob/index.js +31 -0
  82. package/packages/native/dist/glob/types.d.ts +50 -0
  83. package/packages/native/dist/glob/types.js +1 -0
  84. package/packages/native/dist/grep/index.d.ts +20 -0
  85. package/packages/native/dist/grep/index.js +23 -0
  86. package/packages/native/dist/grep/types.d.ts +99 -0
  87. package/packages/native/dist/grep/types.js +1 -0
  88. package/packages/native/dist/gsd-parser/index.d.ts +45 -0
  89. package/packages/native/dist/gsd-parser/index.js +54 -0
  90. package/packages/native/dist/gsd-parser/types.d.ts +55 -0
  91. package/packages/native/dist/gsd-parser/types.js +7 -0
  92. package/packages/native/dist/highlight/index.d.ts +28 -0
  93. package/packages/native/dist/highlight/index.js +33 -0
  94. package/packages/native/dist/highlight/types.d.ts +25 -0
  95. package/packages/native/dist/highlight/types.js +1 -0
  96. package/packages/native/dist/html/index.d.ts +15 -0
  97. package/packages/native/dist/html/index.js +16 -0
  98. package/packages/native/dist/html/types.d.ts +7 -0
  99. package/packages/native/dist/html/types.js +1 -0
  100. package/packages/native/dist/image/index.d.ts +15 -0
  101. package/packages/native/dist/image/index.js +18 -0
  102. package/packages/native/dist/image/types.d.ts +35 -0
  103. package/packages/native/dist/image/types.js +26 -0
  104. package/packages/native/dist/index.d.ts +40 -0
  105. package/packages/native/dist/index.js +28 -0
  106. package/packages/native/dist/native.d.ts +44 -0
  107. package/packages/native/dist/native.js +34 -0
  108. package/packages/native/dist/ps/index.d.ts +38 -0
  109. package/packages/native/dist/ps/index.js +47 -0
  110. package/packages/native/dist/ps/types.d.ts +5 -0
  111. package/packages/native/dist/ps/types.js +1 -0
  112. package/packages/native/dist/text/index.d.ts +55 -0
  113. package/packages/native/dist/text/index.js +66 -0
  114. package/packages/native/dist/text/types.d.ts +27 -0
  115. package/packages/native/dist/text/types.js +10 -0
  116. package/packages/native/dist/ttsr/index.d.ts +27 -0
  117. package/packages/native/dist/ttsr/index.js +32 -0
  118. package/packages/native/dist/ttsr/types.d.ts +9 -0
  119. package/packages/native/dist/ttsr/types.js +1 -0
  120. package/packages/native/package.json +24 -23
  121. package/packages/native/src/__tests__/diff.test.mjs +189 -0
  122. package/packages/native/src/__tests__/ttsr.test.mjs +135 -0
  123. package/packages/native/src/diff/index.ts +61 -0
  124. package/packages/native/src/diff/types.ts +24 -0
  125. package/packages/native/src/gsd-parser/index.ts +98 -0
  126. package/packages/native/src/gsd-parser/types.ts +62 -0
  127. package/packages/native/src/index.ts +23 -0
  128. package/packages/native/src/native.ts +8 -0
  129. package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts +11 -5
  130. package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -1
  131. package/packages/pi-coding-agent/dist/core/tools/edit-diff.js +19 -142
  132. package/packages/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -1
  133. package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +23 -157
  134. package/src/resources/extensions/gsd/files.ts +9 -0
  135. package/src/resources/extensions/gsd/native-parser-bridge.ts +135 -0
  136. package/src/resources/extensions/ttsr/ttsr-manager.ts +86 -0
  137. package/node_modules/@gsd/native/src/__tests__/clipboard.test.mjs +0 -79
  138. package/node_modules/@gsd/native/src/__tests__/fd.test.mjs +0 -164
  139. package/node_modules/@gsd/native/src/__tests__/glob.test.mjs +0 -237
  140. package/node_modules/@gsd/native/src/__tests__/grep.test.mjs +0 -162
  141. package/node_modules/@gsd/native/src/__tests__/highlight.test.mjs +0 -156
  142. package/node_modules/@gsd/native/src/__tests__/html.test.mjs +0 -98
  143. package/node_modules/@gsd/native/src/__tests__/image.test.mjs +0 -137
  144. package/node_modules/@gsd/native/src/__tests__/ps.test.mjs +0 -109
  145. package/node_modules/@gsd/native/src/__tests__/text.test.mjs +0 -262
  146. package/node_modules/@gsd/native/src/ast/index.ts +0 -12
  147. package/node_modules/@gsd/native/src/ast/types.ts +0 -75
  148. package/node_modules/@gsd/native/src/clipboard/types.ts +0 -7
  149. package/node_modules/@gsd/native/src/fd/types.ts +0 -31
  150. package/node_modules/@gsd/native/src/glob/types.ts +0 -53
  151. package/node_modules/@gsd/native/src/grep/index.ts +0 -48
  152. package/node_modules/@gsd/native/src/grep/types.ts +0 -105
  153. package/node_modules/@gsd/native/src/highlight/types.ts +0 -25
  154. package/node_modules/@gsd/native/src/html/types.ts +0 -7
  155. package/node_modules/@gsd/native/src/image/types.ts +0 -41
  156. package/node_modules/@gsd/native/src/native.ts +0 -94
  157. package/node_modules/@gsd/native/src/text/types.ts +0 -29
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Syntect-based syntax highlighting via N-API.
3
+ *
4
+ * Provides ANSI-colored output for code blocks using semantic scope matching
5
+ * across 11 token categories.
6
+ */
7
+ import { native } from "../native.js";
8
+ /**
9
+ * Highlight source code and return ANSI-colored output.
10
+ *
11
+ * @param code - The source code to highlight
12
+ * @param lang - Language identifier (e.g., "rust", "typescript", "python"), or null for plain text
13
+ * @param colors - Theme colors as ANSI escape sequences
14
+ * @returns Highlighted code with ANSI color codes
15
+ */
16
+ export function highlightCode(code, lang, colors) {
17
+ return native.highlightCode(code, lang, colors);
18
+ }
19
+ /**
20
+ * Check if a language is supported for highlighting.
21
+ *
22
+ * Returns true if the language has either direct syntect support or a
23
+ * fallback alias mapping.
24
+ */
25
+ export function supportsLanguage(lang) {
26
+ return native.supportsLanguage(lang);
27
+ }
28
+ /**
29
+ * Get list of all supported language names from syntect's default syntax set.
30
+ */
31
+ export function getSupportedLanguages() {
32
+ return native.getSupportedLanguages();
33
+ }
@@ -0,0 +1,25 @@
1
+ /** Theme colors for syntax highlighting as ANSI escape sequences. */
2
+ export interface HighlightColors {
3
+ /** ANSI color for comments. */
4
+ comment: string;
5
+ /** ANSI color for keywords. */
6
+ keyword: string;
7
+ /** ANSI color for function names. */
8
+ function: string;
9
+ /** ANSI color for variables and identifiers. */
10
+ variable: string;
11
+ /** ANSI color for string literals. */
12
+ string: string;
13
+ /** ANSI color for numeric literals. */
14
+ number: string;
15
+ /** ANSI color for type identifiers. */
16
+ type: string;
17
+ /** ANSI color for operators. */
18
+ operator: string;
19
+ /** ANSI color for punctuation tokens. */
20
+ punctuation: string;
21
+ /** ANSI color for diff inserted lines. */
22
+ inserted?: string;
23
+ /** ANSI color for diff deleted lines. */
24
+ deleted?: string;
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * HTML to Markdown conversion via native Rust bindings.
3
+ *
4
+ * Uses `html-to-markdown-rs` under the hood for high-performance
5
+ * conversion with optional content cleaning (stripping nav, forms, etc.).
6
+ */
7
+ import type { HtmlToMarkdownOptions } from "./types.js";
8
+ export type { HtmlToMarkdownOptions };
9
+ /**
10
+ * Convert an HTML string to Markdown.
11
+ *
12
+ * When `cleanContent` is true, boilerplate elements (nav, forms, headers,
13
+ * footers) are stripped before conversion.
14
+ */
15
+ export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * HTML to Markdown conversion via native Rust bindings.
3
+ *
4
+ * Uses `html-to-markdown-rs` under the hood for high-performance
5
+ * conversion with optional content cleaning (stripping nav, forms, etc.).
6
+ */
7
+ import { native } from "../native.js";
8
+ /**
9
+ * Convert an HTML string to Markdown.
10
+ *
11
+ * When `cleanContent` is true, boilerplate elements (nav, forms, headers,
12
+ * footers) are stripped before conversion.
13
+ */
14
+ export function htmlToMarkdown(html, options) {
15
+ return native.htmlToMarkdown(html, options ?? {});
16
+ }
@@ -0,0 +1,7 @@
1
+ /** Options for HTML to Markdown conversion. */
2
+ export interface HtmlToMarkdownOptions {
3
+ /** Remove navigation elements, forms, headers, footers. */
4
+ cleanContent?: boolean;
5
+ /** Skip images during conversion. */
6
+ skipImages?: boolean;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Native image processing module using N-API.
3
+ *
4
+ * High-performance image decode/encode/resize backed by the Rust `image` crate.
5
+ */
6
+ import type { NativeImageHandle } from "./types.js";
7
+ import { ImageFormat, SamplingFilter } from "./types.js";
8
+ export { ImageFormat, SamplingFilter };
9
+ export type { NativeImageHandle };
10
+ /**
11
+ * Decode image bytes (PNG, JPEG, WebP, GIF) into a NativeImage handle.
12
+ *
13
+ * Format is auto-detected from the byte content.
14
+ */
15
+ export declare function parseImage(bytes: Uint8Array): Promise<NativeImageHandle>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Native image processing module using N-API.
3
+ *
4
+ * High-performance image decode/encode/resize backed by the Rust `image` crate.
5
+ */
6
+ import { native } from "../native.js";
7
+ import { ImageFormat, SamplingFilter } from "./types.js";
8
+ export { ImageFormat, SamplingFilter };
9
+ const NativeImageClass = native
10
+ .NativeImage;
11
+ /**
12
+ * Decode image bytes (PNG, JPEG, WebP, GIF) into a NativeImage handle.
13
+ *
14
+ * Format is auto-detected from the byte content.
15
+ */
16
+ export function parseImage(bytes) {
17
+ return NativeImageClass.parse(bytes);
18
+ }
@@ -0,0 +1,35 @@
1
+ /** Sampling filter for resize operations. */
2
+ export declare enum SamplingFilter {
3
+ /** Nearest-neighbor sampling (fast, low quality). */
4
+ Nearest = 1,
5
+ /** Triangle filter (linear interpolation). */
6
+ Triangle = 2,
7
+ /** Catmull-Rom filter with sharper edges. */
8
+ CatmullRom = 3,
9
+ /** Gaussian filter for smoother results. */
10
+ Gaussian = 4,
11
+ /** Lanczos3 filter for high-quality downscaling. */
12
+ Lanczos3 = 5
13
+ }
14
+ /** Output image format for encoding. */
15
+ export declare enum ImageFormat {
16
+ /** PNG (lossless, quality ignored). */
17
+ PNG = 0,
18
+ /** JPEG (lossy, quality 0-100). */
19
+ JPEG = 1,
20
+ /** WebP (lossless, quality ignored). */
21
+ WebP = 2,
22
+ /** GIF (quality ignored). */
23
+ GIF = 3
24
+ }
25
+ /** Native image handle returned from parse(). */
26
+ export interface NativeImageHandle {
27
+ /** Image width in pixels. */
28
+ readonly width: number;
29
+ /** Image height in pixels. */
30
+ readonly height: number;
31
+ /** Encode to bytes in the specified format. Returns a Promise. */
32
+ encode(format: number, quality: number): Promise<number[]>;
33
+ /** Resize to the specified dimensions. Returns a new NativeImage Promise. */
34
+ resize(width: number, height: number, filter: SamplingFilter): Promise<NativeImageHandle>;
35
+ }
@@ -0,0 +1,26 @@
1
+ /** Sampling filter for resize operations. */
2
+ export var SamplingFilter;
3
+ (function (SamplingFilter) {
4
+ /** Nearest-neighbor sampling (fast, low quality). */
5
+ SamplingFilter[SamplingFilter["Nearest"] = 1] = "Nearest";
6
+ /** Triangle filter (linear interpolation). */
7
+ SamplingFilter[SamplingFilter["Triangle"] = 2] = "Triangle";
8
+ /** Catmull-Rom filter with sharper edges. */
9
+ SamplingFilter[SamplingFilter["CatmullRom"] = 3] = "CatmullRom";
10
+ /** Gaussian filter for smoother results. */
11
+ SamplingFilter[SamplingFilter["Gaussian"] = 4] = "Gaussian";
12
+ /** Lanczos3 filter for high-quality downscaling. */
13
+ SamplingFilter[SamplingFilter["Lanczos3"] = 5] = "Lanczos3";
14
+ })(SamplingFilter || (SamplingFilter = {}));
15
+ /** Output image format for encoding. */
16
+ export var ImageFormat;
17
+ (function (ImageFormat) {
18
+ /** PNG (lossless, quality ignored). */
19
+ ImageFormat[ImageFormat["PNG"] = 0] = "PNG";
20
+ /** JPEG (lossy, quality 0-100). */
21
+ ImageFormat[ImageFormat["JPEG"] = 1] = "JPEG";
22
+ /** WebP (lossless, quality ignored). */
23
+ ImageFormat[ImageFormat["WebP"] = 2] = "WebP";
24
+ /** GIF (quality ignored). */
25
+ ImageFormat[ImageFormat["GIF"] = 3] = "GIF";
26
+ })(ImageFormat || (ImageFormat = {}));
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @gsd/native — High-performance Rust modules exposed via N-API.
3
+ *
4
+ * Modules:
5
+ * - clipboard: native clipboard access (text + image)
6
+ * - grep: ripgrep-backed regex search (content + filesystem)
7
+ * - ps: cross-platform process tree management
8
+ * - glob: gitignore-respecting filesystem discovery with scan caching
9
+ * - highlight: syntect-based syntax highlighting
10
+ * - html: HTML to Markdown conversion
11
+ * - text: ANSI-aware text measurement and slicing
12
+ * - fd: fuzzy file path discovery
13
+ * - image: decode, encode, and resize images
14
+ for autocomplete and @-mention resolution
15
+ */
16
+ export { copyToClipboard, readTextFromClipboard, readImageFromClipboard, } from "./clipboard/index.js";
17
+ export type { ClipboardImage } from "./clipboard/index.js";
18
+ export { highlightCode, supportsLanguage, getSupportedLanguages, } from "./highlight/index.js";
19
+ export type { HighlightColors } from "./highlight/index.js";
20
+ export { searchContent, grep } from "./grep/index.js";
21
+ export type { ContextLine, GrepMatch, GrepOptions, GrepResult, SearchMatch, SearchOptions, SearchResult, } from "./grep/index.js";
22
+ export { killTree, listDescendants, processGroupId, killProcessGroup, } from "./ps/index.js";
23
+ export { glob, invalidateFsScanCache } from "./glob/index.js";
24
+ export type { FileType, GlobMatch, GlobOptions, GlobResult, } from "./glob/index.js";
25
+ export { astGrep, astEdit } from "./ast/index.js";
26
+ export type { AstFindMatch, AstFindOptions, AstFindResult, AstReplaceChange, AstReplaceFileChange, AstReplaceOptions, AstReplaceResult, } from "./ast/index.js";
27
+ export { htmlToMarkdown } from "./html/index.js";
28
+ export type { HtmlToMarkdownOptions } from "./html/index.js";
29
+ export { wrapTextWithAnsi, truncateToWidth, sliceWithWidth, extractSegments, sanitizeText, visibleWidth, EllipsisKind, } from "./text/index.js";
30
+ export type { SliceResult, ExtractSegmentsResult } from "./text/index.js";
31
+ export { normalizeForFuzzyMatch, fuzzyFindText, generateDiff, } from "./diff/index.js";
32
+ export type { FuzzyMatchResult, DiffResult } from "./diff/index.js";
33
+ export { fuzzyFind } from "./fd/index.js";
34
+ export type { FuzzyFindMatch, FuzzyFindOptions, FuzzyFindResult, } from "./fd/index.js";
35
+ export { parseImage, ImageFormat, SamplingFilter } from "./image/index.js";
36
+ export type { NativeImageHandle } from "./image/index.js";
37
+ export { ttsrCompileRules, ttsrCheckBuffer, ttsrFreeRules } from "./ttsr/index.js";
38
+ export type { TtsrHandle, TtsrRuleInput } from "./ttsr/index.js";
39
+ export { parseFrontmatter, extractSection as nativeExtractSection, extractAllSections, batchParseGsdFiles, parseRoadmapFile, } from "./gsd-parser/index.js";
40
+ export type { BatchParseResult, FrontmatterResult, NativeBoundaryMapEntry, NativeRoadmap, NativeRoadmapSlice, ParsedGsdFile, SectionResult, } from "./gsd-parser/index.js";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @gsd/native — High-performance Rust modules exposed via N-API.
3
+ *
4
+ * Modules:
5
+ * - clipboard: native clipboard access (text + image)
6
+ * - grep: ripgrep-backed regex search (content + filesystem)
7
+ * - ps: cross-platform process tree management
8
+ * - glob: gitignore-respecting filesystem discovery with scan caching
9
+ * - highlight: syntect-based syntax highlighting
10
+ * - html: HTML to Markdown conversion
11
+ * - text: ANSI-aware text measurement and slicing
12
+ * - fd: fuzzy file path discovery
13
+ * - image: decode, encode, and resize images
14
+ for autocomplete and @-mention resolution
15
+ */
16
+ export { copyToClipboard, readTextFromClipboard, readImageFromClipboard, } from "./clipboard/index.js";
17
+ export { highlightCode, supportsLanguage, getSupportedLanguages, } from "./highlight/index.js";
18
+ export { searchContent, grep } from "./grep/index.js";
19
+ export { killTree, listDescendants, processGroupId, killProcessGroup, } from "./ps/index.js";
20
+ export { glob, invalidateFsScanCache } from "./glob/index.js";
21
+ export { astGrep, astEdit } from "./ast/index.js";
22
+ export { htmlToMarkdown } from "./html/index.js";
23
+ export { wrapTextWithAnsi, truncateToWidth, sliceWithWidth, extractSegments, sanitizeText, visibleWidth, EllipsisKind, } from "./text/index.js";
24
+ export { normalizeForFuzzyMatch, fuzzyFindText, generateDiff, } from "./diff/index.js";
25
+ export { fuzzyFind } from "./fd/index.js";
26
+ export { parseImage, ImageFormat, SamplingFilter } from "./image/index.js";
27
+ export { ttsrCompileRules, ttsrCheckBuffer, ttsrFreeRules } from "./ttsr/index.js";
28
+ export { parseFrontmatter, extractSection as nativeExtractSection, extractAllSections, batchParseGsdFiles, parseRoadmapFile, } from "./gsd-parser/index.js";
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Native addon loader.
3
+ *
4
+ * Locates and loads the compiled Rust N-API addon (`.node` file).
5
+ * Tries platform-tagged release builds first, then falls back to dev builds.
6
+ */
7
+ export declare const native: {
8
+ search: (content: Buffer | Uint8Array, options: unknown) => unknown;
9
+ grep: (options: unknown) => unknown;
10
+ killTree: (pid: number, signal: number) => number;
11
+ listDescendants: (pid: number) => number[];
12
+ processGroupId: (pid: number) => number | null;
13
+ killProcessGroup: (pgid: number, signal: number) => boolean;
14
+ glob: (options: unknown, onMatch?: ((match: unknown) => void) | undefined | null) => Promise<unknown>;
15
+ invalidateFsScanCache: (path?: string) => void;
16
+ highlightCode: (code: string, lang: string | null, colors: unknown) => unknown;
17
+ supportsLanguage: (lang: string) => unknown;
18
+ getSupportedLanguages: () => unknown;
19
+ copyToClipboard: (text: string) => void;
20
+ readTextFromClipboard: () => string | null;
21
+ readImageFromClipboard: () => Promise<unknown>;
22
+ astGrep: (options: unknown) => unknown;
23
+ astEdit: (options: unknown) => unknown;
24
+ htmlToMarkdown: (html: string, options: unknown) => unknown;
25
+ wrapTextWithAnsi: (text: string, width: number, tabWidth?: number) => string[];
26
+ truncateToWidth: (text: string, maxWidth: number, ellipsisKind: number, pad: boolean, tabWidth?: number) => string;
27
+ sliceWithWidth: (line: string, startCol: number, length: number, strict: boolean, tabWidth?: number) => unknown;
28
+ extractSegments: (line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean, tabWidth?: number) => unknown;
29
+ sanitizeText: (text: string) => string;
30
+ visibleWidth: (text: string, tabWidth?: number) => number;
31
+ fuzzyFind: (options: unknown) => unknown;
32
+ normalizeForFuzzyMatch: (text: string) => string;
33
+ fuzzyFindText: (content: string, oldText: string) => unknown;
34
+ generateDiff: (oldContent: string, newContent: string, contextLines?: number) => unknown;
35
+ NativeImage: unknown;
36
+ ttsrCompileRules: (rules: unknown[]) => number;
37
+ ttsrCheckBuffer: (handle: number, buffer: string) => string[];
38
+ ttsrFreeRules: (handle: number) => void;
39
+ parseFrontmatter: (content: string) => unknown;
40
+ extractSection: (content: string, heading: string, level?: number) => unknown;
41
+ extractAllSections: (content: string, level?: number) => string;
42
+ batchParseGsdFiles: (directory: string) => unknown;
43
+ parseRoadmapFile: (content: string) => unknown;
44
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Native addon loader.
3
+ *
4
+ * Locates and loads the compiled Rust N-API addon (`.node` file).
5
+ * Tries platform-tagged release builds first, then falls back to dev builds.
6
+ */
7
+ import { createRequire } from "node:module";
8
+ import * as path from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+ const require = createRequire(import.meta.url);
12
+ const addonDir = path.resolve(__dirname, "..", "..", "..", "native", "addon");
13
+ const platformTag = `${process.platform}-${process.arch}`;
14
+ const candidates = [
15
+ path.join(addonDir, `gsd_engine.${platformTag}.node`),
16
+ path.join(addonDir, "gsd_engine.dev.node"),
17
+ ];
18
+ function loadNative() {
19
+ const errors = [];
20
+ for (const candidate of candidates) {
21
+ try {
22
+ return require(candidate);
23
+ }
24
+ catch (err) {
25
+ const message = err instanceof Error ? err.message : String(err);
26
+ errors.push(`${candidate}: ${message}`);
27
+ }
28
+ }
29
+ const details = errors.map((e) => ` - ${e}`).join("\n");
30
+ throw new Error(`Failed to load gsd_engine native addon for ${platformTag}.\n\n` +
31
+ `Tried:\n${details}\n\n` +
32
+ `Build with: npm run build:native -w @gsd/native`);
33
+ }
34
+ export const native = loadNative();
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Cross-platform process tree management via N-API.
3
+ *
4
+ * Provides efficient process tree enumeration and termination
5
+ * using platform-native APIs (libproc on macOS, /proc on Linux,
6
+ * Toolhelp32 on Windows).
7
+ */
8
+ /**
9
+ * Kill a process tree (the process and all its descendants).
10
+ *
11
+ * Kills children first (bottom-up) to prevent orphan re-parenting issues.
12
+ * @param pid - Root process ID
13
+ * @param signal - Signal to send (e.g. 9 for SIGKILL, 15 for SIGTERM). Ignored on Windows.
14
+ * @returns Number of processes successfully killed.
15
+ */
16
+ export declare function killTree(pid: number, signal: number): number;
17
+ /**
18
+ * List all descendant PIDs of a process.
19
+ *
20
+ * @param pid - Parent process ID
21
+ * @returns Array of descendant PIDs (empty if no children or process doesn't exist).
22
+ */
23
+ export declare function listDescendants(pid: number): number[];
24
+ /**
25
+ * Get the process group ID for a process.
26
+ *
27
+ * @param pid - Process ID
28
+ * @returns Process group ID, or null if the process doesn't exist or on Windows.
29
+ */
30
+ export declare function processGroupId(pid: number): number | null;
31
+ /**
32
+ * Kill an entire process group.
33
+ *
34
+ * @param pgid - Process group ID
35
+ * @param signal - Signal to send
36
+ * @returns true if the signal was delivered, false on failure or Windows.
37
+ */
38
+ export declare function killProcessGroup(pgid: number, signal: number): boolean;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Cross-platform process tree management via N-API.
3
+ *
4
+ * Provides efficient process tree enumeration and termination
5
+ * using platform-native APIs (libproc on macOS, /proc on Linux,
6
+ * Toolhelp32 on Windows).
7
+ */
8
+ import { native } from "../native.js";
9
+ /**
10
+ * Kill a process tree (the process and all its descendants).
11
+ *
12
+ * Kills children first (bottom-up) to prevent orphan re-parenting issues.
13
+ * @param pid - Root process ID
14
+ * @param signal - Signal to send (e.g. 9 for SIGKILL, 15 for SIGTERM). Ignored on Windows.
15
+ * @returns Number of processes successfully killed.
16
+ */
17
+ export function killTree(pid, signal) {
18
+ return native.killTree(pid, signal);
19
+ }
20
+ /**
21
+ * List all descendant PIDs of a process.
22
+ *
23
+ * @param pid - Parent process ID
24
+ * @returns Array of descendant PIDs (empty if no children or process doesn't exist).
25
+ */
26
+ export function listDescendants(pid) {
27
+ return native.listDescendants(pid);
28
+ }
29
+ /**
30
+ * Get the process group ID for a process.
31
+ *
32
+ * @param pid - Process ID
33
+ * @returns Process group ID, or null if the process doesn't exist or on Windows.
34
+ */
35
+ export function processGroupId(pid) {
36
+ return native.processGroupId(pid);
37
+ }
38
+ /**
39
+ * Kill an entire process group.
40
+ *
41
+ * @param pgid - Process group ID
42
+ * @param signal - Signal to send
43
+ * @returns true if the signal was delivered, false on failure or Windows.
44
+ */
45
+ export function killProcessGroup(pgid, signal) {
46
+ return native.killProcessGroup(pgid, signal);
47
+ }
@@ -0,0 +1,5 @@
1
+ /** Result of a process tree kill operation. */
2
+ export interface KillTreeResult {
3
+ /** Number of processes successfully killed. */
4
+ killed: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ /**
2
+ * ANSI-aware text measurement and slicing.
3
+ *
4
+ * High-performance UTF-16 native implementation with ASCII fast-paths,
5
+ * single-pass ANSI scanning, and proper Unicode grapheme cluster support.
6
+ */
7
+ import type { ExtractSegmentsResult, SliceResult } from "./types.js";
8
+ export type { ExtractSegmentsResult, SliceResult };
9
+ export { EllipsisKind } from "./types.js";
10
+ /**
11
+ * Word-wrap text to a visible width, preserving ANSI escape codes across
12
+ * line breaks.
13
+ *
14
+ * Active SGR codes (colors, bold, etc.) are carried to continuation lines.
15
+ * Underline and strikethrough are reset at line ends and restored on the
16
+ * next line.
17
+ */
18
+ export declare function wrapTextWithAnsi(text: string, width: number, tabWidth?: number): string[];
19
+ /**
20
+ * Truncate text to a visible width with an optional ellipsis.
21
+ *
22
+ * @param text Input string (may contain ANSI codes).
23
+ * @param maxWidth Maximum visible width in terminal cells.
24
+ * @param ellipsisKind 0 = "\u2026", 1 = "...", 2 = none.
25
+ * @param pad When true, pad with spaces to exactly `maxWidth`.
26
+ * @param tabWidth Tab stop width (default 3, range 1-16).
27
+ */
28
+ export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind: number, pad: boolean, tabWidth?: number): string;
29
+ /**
30
+ * Slice a range of visible columns from a line.
31
+ *
32
+ * Counts terminal cells (skipping ANSI escapes). When `strict` is true,
33
+ * wide characters that would exceed the range are excluded.
34
+ */
35
+ export declare function sliceWithWidth(line: string, startCol: number, length: number, strict: boolean, tabWidth?: number): SliceResult;
36
+ /**
37
+ * Extract the before/after segments around an overlay region.
38
+ *
39
+ * ANSI state is tracked so the `after` segment renders correctly even when
40
+ * the overlay truncates styled text.
41
+ */
42
+ export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean, tabWidth?: number): ExtractSegmentsResult;
43
+ /**
44
+ * Strip ANSI escape sequences, remove control characters and lone
45
+ * surrogates, and normalize line endings (CR removed).
46
+ *
47
+ * Returns the original string when no changes are needed (zero-copy).
48
+ */
49
+ export declare function sanitizeText(text: string): string;
50
+ /**
51
+ * Calculate visible width of text excluding ANSI escape sequences.
52
+ *
53
+ * Tabs count as `tabWidth` cells (default 3).
54
+ */
55
+ export declare function visibleWidth(text: string, tabWidth?: number): number;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ANSI-aware text measurement and slicing.
3
+ *
4
+ * High-performance UTF-16 native implementation with ASCII fast-paths,
5
+ * single-pass ANSI scanning, and proper Unicode grapheme cluster support.
6
+ */
7
+ import { native } from "../native.js";
8
+ export { EllipsisKind } from "./types.js";
9
+ /**
10
+ * Word-wrap text to a visible width, preserving ANSI escape codes across
11
+ * line breaks.
12
+ *
13
+ * Active SGR codes (colors, bold, etc.) are carried to continuation lines.
14
+ * Underline and strikethrough are reset at line ends and restored on the
15
+ * next line.
16
+ */
17
+ export function wrapTextWithAnsi(text, width, tabWidth) {
18
+ return native.wrapTextWithAnsi(text, width, tabWidth);
19
+ }
20
+ /**
21
+ * Truncate text to a visible width with an optional ellipsis.
22
+ *
23
+ * @param text Input string (may contain ANSI codes).
24
+ * @param maxWidth Maximum visible width in terminal cells.
25
+ * @param ellipsisKind 0 = "\u2026", 1 = "...", 2 = none.
26
+ * @param pad When true, pad with spaces to exactly `maxWidth`.
27
+ * @param tabWidth Tab stop width (default 3, range 1-16).
28
+ */
29
+ export function truncateToWidth(text, maxWidth, ellipsisKind, pad, tabWidth) {
30
+ return native.truncateToWidth(text, maxWidth, ellipsisKind, pad, tabWidth);
31
+ }
32
+ /**
33
+ * Slice a range of visible columns from a line.
34
+ *
35
+ * Counts terminal cells (skipping ANSI escapes). When `strict` is true,
36
+ * wide characters that would exceed the range are excluded.
37
+ */
38
+ export function sliceWithWidth(line, startCol, length, strict, tabWidth) {
39
+ return native.sliceWithWidth(line, startCol, length, strict, tabWidth);
40
+ }
41
+ /**
42
+ * Extract the before/after segments around an overlay region.
43
+ *
44
+ * ANSI state is tracked so the `after` segment renders correctly even when
45
+ * the overlay truncates styled text.
46
+ */
47
+ export function extractSegments(line, beforeEnd, afterStart, afterLen, strictAfter, tabWidth) {
48
+ return native.extractSegments(line, beforeEnd, afterStart, afterLen, strictAfter, tabWidth);
49
+ }
50
+ /**
51
+ * Strip ANSI escape sequences, remove control characters and lone
52
+ * surrogates, and normalize line endings (CR removed).
53
+ *
54
+ * Returns the original string when no changes are needed (zero-copy).
55
+ */
56
+ export function sanitizeText(text) {
57
+ return native.sanitizeText(text);
58
+ }
59
+ /**
60
+ * Calculate visible width of text excluding ANSI escape sequences.
61
+ *
62
+ * Tabs count as `tabWidth` cells (default 3).
63
+ */
64
+ export function visibleWidth(text, tabWidth) {
65
+ return native.visibleWidth(text, tabWidth);
66
+ }
@@ -0,0 +1,27 @@
1
+ /** Result of slicing a line by visible column range. */
2
+ export interface SliceResult {
3
+ /** The extracted text (may include ANSI codes). */
4
+ text: string;
5
+ /** Visible width of the extracted slice in terminal cells. */
6
+ width: number;
7
+ }
8
+ /** Result of extracting before/after segments around an overlay. */
9
+ export interface ExtractSegmentsResult {
10
+ /** Text content before the overlay region. */
11
+ before: string;
12
+ /** Visible width of the `before` segment. */
13
+ beforeWidth: number;
14
+ /** Text content after the overlay region. */
15
+ after: string;
16
+ /** Visible width of the `after` segment. */
17
+ afterWidth: number;
18
+ }
19
+ /** Ellipsis style for truncation. */
20
+ export declare enum EllipsisKind {
21
+ /** Unicode ellipsis character: \u2026 (width 1) */
22
+ Unicode = 0,
23
+ /** ASCII ellipsis: "..." (width 3) */
24
+ Ascii = 1,
25
+ /** No ellipsis (hard truncate) */
26
+ None = 2
27
+ }
@@ -0,0 +1,10 @@
1
+ /** Ellipsis style for truncation. */
2
+ export var EllipsisKind;
3
+ (function (EllipsisKind) {
4
+ /** Unicode ellipsis character: \u2026 (width 1) */
5
+ EllipsisKind[EllipsisKind["Unicode"] = 0] = "Unicode";
6
+ /** ASCII ellipsis: "..." (width 3) */
7
+ EllipsisKind[EllipsisKind["Ascii"] = 1] = "Ascii";
8
+ /** No ellipsis (hard truncate) */
9
+ EllipsisKind[EllipsisKind["None"] = 2] = "None";
10
+ })(EllipsisKind || (EllipsisKind = {}));
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Native TTSR regex engine.
3
+ *
4
+ * Pre-compiles all rule condition patterns into a single Rust RegexSet for
5
+ * O(1)-style matching per buffer check, replacing per-rule JS regex iteration.
6
+ */
7
+ import type { TtsrHandle, TtsrRuleInput } from "./types.js";
8
+ export type { TtsrHandle, TtsrRuleInput };
9
+ /**
10
+ * Compile TTSR rules into an optimized native regex engine.
11
+ *
12
+ * Returns an opaque handle for use with `ttsrCheckBuffer` and `ttsrFreeRules`.
13
+ */
14
+ export declare function ttsrCompileRules(rules: TtsrRuleInput[]): TtsrHandle;
15
+ /**
16
+ * Check a buffer against compiled TTSR rules.
17
+ *
18
+ * Returns an array of unique rule names whose conditions matched.
19
+ * All patterns are tested in a single pass via Rust's RegexSet.
20
+ */
21
+ export declare function ttsrCheckBuffer(handle: TtsrHandle, buffer: string): string[];
22
+ /**
23
+ * Free a compiled TTSR rule set, releasing native memory.
24
+ *
25
+ * Call when rules are no longer needed (e.g., session end).
26
+ */
27
+ export declare function ttsrFreeRules(handle: TtsrHandle): void;