@kreuzberg/tree-sitter-language-pack 1.6.2 → 1.8.0-rc.19

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/index.d.ts CHANGED
@@ -1,330 +1,1152 @@
1
- /* auto-generated by NAPI-RS */
1
+ // This file is auto-generated by alef — DO NOT EDIT.
2
+ // alef:hash:f6e4811199d464c199f48100178d92c2e39459da567fbbc1253fa08fa895a07c
3
+ // To regenerate: alef generate
4
+ // To verify freshness: alef verify --exit-code
5
+ // Issues & docs: https://github.com/kreuzberg-dev/alef
2
6
  /* eslint-disable */
3
7
 
4
- export declare class ExternalObject<T> {
5
- readonly "": {
6
- readonly "": unique symbol;
7
- [K: symbol]: T;
8
- };
9
- }
10
-
11
- /** Byte and line/column span within source code. */
12
- export interface Span {
13
- startByte: number;
14
- endByte: number;
15
- startRow: number;
16
- startCol: number;
17
- endRow: number;
18
- endCol: number;
19
- }
20
-
21
- /** Information about a single syntax tree node. */
22
- export interface NodeInfo {
23
- kind: string;
24
- isNamed: boolean;
25
- startByte: number;
26
- endByte: number;
27
- startRow: number;
28
- startCol: number;
29
- endRow: number;
30
- endCol: number;
31
- namedChildCount: number;
32
- isError: boolean;
33
- isMissing: boolean;
34
- }
8
+ /**
9
+ * List all available language names (sorted, deduplicated, includes aliases).
10
+ *
11
+ * Returns names of both statically compiled and dynamically loadable languages,
12
+ * plus any configured aliases.
13
+ *
14
+ * # Example
15
+ *
16
+ * ```no_run
17
+ * use tree_sitter_language_pack::available_languages;
18
+ *
19
+ * let langs = available_languages();
20
+ * for name in &langs {
21
+ * println!("{}", name);
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function availableLanguages(): Array<string>;
35
26
 
36
- /** Aggregate metrics for a source file. */
37
- export interface FileMetrics {
38
- totalLines: number;
39
- totalBytes: number;
40
- blankLines: number;
41
- commentLines: number;
42
- codeLines: number;
43
- errorCount: number;
27
+ /**
28
+ * Return the effective cache directory path.
29
+ *
30
+ * This is either the custom path set via [`configure`] / [`init`] or the
31
+ * default: `~/.cache/tree-sitter-language-pack/v{version}/libs/`.
32
+ *
33
+ * # Errors
34
+ *
35
+ * Returns an error if the system cache directory cannot be determined.
36
+ *
37
+ * # Example
38
+ *
39
+ * ```no_run
40
+ * use tree_sitter_language_pack::cache_dir;
41
+ *
42
+ * let dir = cache_dir().unwrap();
43
+ * println!("Cache directory: {}", dir.display());
44
+ * ```
45
+ */
46
+ export declare function cacheDir(): string;
47
+
48
+ /**
49
+ * Delete all cached parser shared libraries.
50
+ *
51
+ * Resets the cache registration so the next call to [`get_language`] or
52
+ * a download function will re-register the (now empty) cache directory.
53
+ *
54
+ * # Errors
55
+ *
56
+ * Returns an error if the cache directory cannot be removed.
57
+ *
58
+ * # Example
59
+ *
60
+ * ```no_run
61
+ * use tree_sitter_language_pack::clean_cache;
62
+ *
63
+ * clean_cache().unwrap();
64
+ * println!("Cache cleared");
65
+ * ```
66
+ */
67
+ export declare function cleanCache(): void;
68
+
69
+ /**
70
+ * Apply download configuration without downloading anything.
71
+ *
72
+ * Use this to set a custom cache directory before the first call to
73
+ * [`get_language`] or any download function. Changing the cache dir
74
+ * after languages have been registered has no effect on already-loaded
75
+ * languages.
76
+ *
77
+ * # Errors
78
+ *
79
+ * Returns an error if the lock cannot be acquired.
80
+ *
81
+ * # Example
82
+ *
83
+ * ```no_run
84
+ * use std::path::PathBuf;
85
+ * use tree_sitter_language_pack::{PackConfig, configure};
86
+ *
87
+ * let config = PackConfig {
88
+ * cache_dir: Some(PathBuf::from("/tmp/my-parsers")),
89
+ * languages: None,
90
+ * groups: None,
91
+ * };
92
+ * configure(&config).unwrap();
93
+ * ```
94
+ */
95
+ export declare function configure(config: JsPackConfig): void;
96
+
97
+ /**
98
+ * Detect language name from file content using the shebang line (`#!`).
99
+ *
100
+ * Inspects only the first line of `content`. If it begins with `#!`, the
101
+ * interpreter name is extracted and mapped to a language name.
102
+ *
103
+ * Handles common patterns:
104
+ * - `#!/usr/bin/env python3` → `"python"`
105
+ * - `#!/bin/bash` → `"bash"`
106
+ * - `#!/usr/bin/env node` → `"javascript"`
107
+ *
108
+ * The `-S` flag accepted by some `env` implementations is skipped automatically.
109
+ * Version suffixes (e.g. `python3.11`, `ruby3.2`) are stripped before matching.
110
+ *
111
+ * Returns `None` when content does not start with `#!`, the shebang is
112
+ * malformed, or the interpreter is not recognised.
113
+ *
114
+ * ```
115
+ * use tree_sitter_language_pack::detect_language_from_content;
116
+ * assert_eq!(detect_language_from_content("#!/usr/bin/env python3\npass"), Some("python"));
117
+ * assert_eq!(detect_language_from_content("#!/bin/bash\necho hi"), Some("bash"));
118
+ * assert_eq!(detect_language_from_content("no shebang here"), None);
119
+ * ```
120
+ */
121
+ export declare function detectLanguageFromContent(content: string): string | undefined | null;
122
+
123
+ /**
124
+ * Detect language name from a file extension (without leading dot).
125
+ *
126
+ * Returns `None` for unrecognized extensions. The match is case-insensitive.
127
+ *
128
+ * ```
129
+ * use tree_sitter_language_pack::detect_language_from_extension;
130
+ * assert_eq!(detect_language_from_extension("py"), Some("python"));
131
+ * assert_eq!(detect_language_from_extension("RS"), Some("rust"));
132
+ * assert_eq!(detect_language_from_extension("xyz"), None);
133
+ * ```
134
+ */
135
+ export declare function detectLanguageFromExtension(ext: string): string | undefined | null;
136
+
137
+ /**
138
+ * Detect language name from a file path.
139
+ *
140
+ * Extracts the file extension and looks it up. Returns `None` if the
141
+ * path has no extension or the extension is not recognized.
142
+ *
143
+ * ```
144
+ * use tree_sitter_language_pack::detect_language_from_path;
145
+ * assert_eq!(detect_language_from_path("src/main.rs"), Some("rust"));
146
+ * assert_eq!(detect_language_from_path("README.md"), Some("markdown"));
147
+ * assert_eq!(detect_language_from_path("Makefile"), None);
148
+ * ```
149
+ */
150
+ export declare function detectLanguageFromPath(path: string): string | undefined | null;
151
+
152
+ /**
153
+ * Download specific languages to the local cache.
154
+ *
155
+ * Returns the number of newly downloaded languages (languages that were
156
+ * already cached are not counted).
157
+ *
158
+ * # Errors
159
+ *
160
+ * Returns an error if any language is not available in the manifest or if
161
+ * the download fails.
162
+ *
163
+ * # Example
164
+ *
165
+ * ```no_run
166
+ * use tree_sitter_language_pack::download;
167
+ *
168
+ * let count = download(&["python", "rust", "typescript"]).unwrap();
169
+ * println!("Downloaded {} new languages", count);
170
+ * ```
171
+ */
172
+ export declare function download(names: Array<string>): number;
173
+
174
+ /**
175
+ * Download all available languages from the remote manifest.
176
+ *
177
+ * Returns the number of newly downloaded languages.
178
+ *
179
+ * # Errors
180
+ *
181
+ * Returns an error if the manifest cannot be fetched or a download fails.
182
+ *
183
+ * # Example
184
+ *
185
+ * ```no_run
186
+ * use tree_sitter_language_pack::download_all;
187
+ *
188
+ * let count = download_all().unwrap();
189
+ * println!("Downloaded {} languages", count);
190
+ * ```
191
+ */
192
+ export declare function downloadAll(): number;
193
+
194
+ /**
195
+ * Return languages that are already downloaded and cached locally.
196
+ *
197
+ * Does not perform any network requests. Returns an empty list if the
198
+ * cache directory does not exist or cannot be read.
199
+ *
200
+ * # Example
201
+ *
202
+ * ```no_run
203
+ * use tree_sitter_language_pack::downloaded_languages;
204
+ *
205
+ * let langs = downloaded_languages();
206
+ * println!("{} languages already cached", langs.len());
207
+ * ```
208
+ */
209
+ export declare function downloadedLanguages(): Array<string>;
210
+
211
+ /**
212
+ * Run extraction patterns against source code.
213
+ *
214
+ * Convenience wrapper around [`extract::extract`].
215
+ *
216
+ * # Errors
217
+ *
218
+ * Returns an error if the language is not found, parsing fails, or a query
219
+ * pattern is invalid.
220
+ *
221
+ * # Example
222
+ *
223
+ * ```no_run
224
+ * use ahash::AHashMap;
225
+ * use tree_sitter_language_pack::{ExtractionConfig, ExtractionPattern, CaptureOutput, extract_patterns};
226
+ *
227
+ * let mut patterns = AHashMap::new();
228
+ * patterns.insert("fns".to_string(), ExtractionPattern {
229
+ * query: "(function_definition name: (identifier) @fn_name)".to_string(),
230
+ * capture_output: CaptureOutput::default(),
231
+ * child_fields: Vec::new(),
232
+ * max_results: None,
233
+ * byte_range: None,
234
+ * });
235
+ * let config = ExtractionConfig { language: "python".to_string(), patterns };
236
+ * let result = extract_patterns("def hello(): pass", &config).unwrap();
237
+ * ```
238
+ */
239
+ export declare function extractPatterns(source: string, config: JsExtractionConfig): JsExtractionResult;
240
+
241
+ /**
242
+ * Find all nodes matching the given type name, returning their `NodeInfo`.
243
+ *
244
+ * Performs a depth-first traversal. Returns an empty vec if no matches.
245
+ */
246
+ export declare function findNodesByType(tree: JsTree, nodeType: string): Array<JsNodeInfo>;
247
+
248
+ /**
249
+ * Get the highlights query for a language, if bundled.
250
+ *
251
+ * Returns the contents of `highlights.scm` as a static string, or `None`
252
+ * if no highlights query is bundled for this language.
253
+ *
254
+ * # Example
255
+ *
256
+ * ```
257
+ * use tree_sitter_language_pack::get_highlights_query;
258
+ *
259
+ * // Returns Some(...) for languages with bundled queries
260
+ * let query = get_highlights_query("python");
261
+ * // Returns None for languages without bundled highlights queries
262
+ * let missing = get_highlights_query("nonexistent_lang");
263
+ * assert!(missing.is_none());
264
+ * ```
265
+ */
266
+ export declare function getHighlightsQuery(language: string): string | undefined | null;
267
+
268
+ /**
269
+ * Get the injections query for a language, if bundled.
270
+ *
271
+ * Returns the contents of `injections.scm` as a static string, or `None`
272
+ * if no injections query is bundled for this language.
273
+ *
274
+ * # Example
275
+ *
276
+ * ```
277
+ * use tree_sitter_language_pack::get_injections_query;
278
+ *
279
+ * let query = get_injections_query("markdown");
280
+ * // Returns None for languages without bundled injections queries
281
+ * let missing = get_injections_query("nonexistent_lang");
282
+ * assert!(missing.is_none());
283
+ * ```
284
+ */
285
+ export declare function getInjectionsQuery(language: string): string | undefined | null;
286
+
287
+ /**
288
+ * Get a tree-sitter [`Language`] by name using the global registry.
289
+ *
290
+ * Resolves language aliases (e.g., `"shell"` maps to `"bash"`).
291
+ * When the `download` feature is enabled (default), automatically downloads
292
+ * the parser from GitHub releases if not found locally.
293
+ *
294
+ * # Errors
295
+ *
296
+ * Returns [`Error::LanguageNotFound`] if the language is not recognized,
297
+ * or [`Error::Download`] if auto-download fails.
298
+ *
299
+ * # Example
300
+ *
301
+ * ```no_run
302
+ * use tree_sitter_language_pack::get_language;
303
+ *
304
+ * let lang = get_language("python").unwrap();
305
+ * // Use the Language with a tree-sitter Parser
306
+ * let mut parser = tree_sitter::Parser::new();
307
+ * parser.set_language(&lang).unwrap();
308
+ * let tree = parser.parse("x = 1", None).unwrap();
309
+ * assert_eq!(tree.root_node().kind(), "module");
310
+ * ```
311
+ */
312
+ export declare function getLanguage(name: string): JsLanguage;
313
+
314
+ /**
315
+ * Get the locals query for a language, if bundled.
316
+ *
317
+ * Returns the contents of `locals.scm` as a static string, or `None`
318
+ * if no locals query is bundled for this language.
319
+ *
320
+ * # Example
321
+ *
322
+ * ```
323
+ * use tree_sitter_language_pack::get_locals_query;
324
+ *
325
+ * let query = get_locals_query("python");
326
+ * // Returns None for languages without bundled locals queries
327
+ * let missing = get_locals_query("nonexistent_lang");
328
+ * assert!(missing.is_none());
329
+ * ```
330
+ */
331
+ export declare function getLocalsQuery(language: string): string | undefined | null;
332
+
333
+ /**
334
+ * Get a tree-sitter [`Parser`] pre-configured for the given language.
335
+ *
336
+ * This is a convenience function that calls [`get_language`] and configures
337
+ * a new parser in one step.
338
+ *
339
+ * # Errors
340
+ *
341
+ * Returns [`Error::LanguageNotFound`] if the language is not recognized, or
342
+ * [`Error::ParserSetup`] if the language cannot be applied to the parser.
343
+ *
344
+ * # Example
345
+ *
346
+ * ```no_run
347
+ * use tree_sitter_language_pack::get_parser;
348
+ *
349
+ * let mut parser = get_parser("rust").unwrap();
350
+ * let tree = parser.parse("fn main() {}", None).unwrap();
351
+ * assert!(!tree.root_node().has_error());
352
+ * ```
353
+ */
354
+ export declare function getParser(name: string): JsParser;
355
+
356
+ /**
357
+ * Check if a language is available by name or alias.
358
+ *
359
+ * Returns `true` if the language can be loaded (statically compiled,
360
+ * dynamically available, or a known alias for one of these).
361
+ *
362
+ * # Example
363
+ *
364
+ * ```no_run
365
+ * use tree_sitter_language_pack::has_language;
366
+ *
367
+ * assert!(has_language("python"));
368
+ * assert!(has_language("shell")); // alias for "bash"
369
+ * assert!(!has_language("nonexistent_language"));
370
+ * ```
371
+ */
372
+ export declare function hasLanguage(name: string): boolean;
373
+
374
+ /**
375
+ * Initialize the language pack with the given configuration.
376
+ *
377
+ * Applies any custom cache directory, then downloads all languages and groups
378
+ * specified in the config. This is the recommended entry point when you want
379
+ * to pre-warm the cache before use.
380
+ *
381
+ * # Errors
382
+ *
383
+ * Returns an error if configuration cannot be applied or if downloads fail.
384
+ *
385
+ * # Example
386
+ *
387
+ * ```no_run
388
+ * use tree_sitter_language_pack::{PackConfig, init};
389
+ *
390
+ * let config = PackConfig {
391
+ * cache_dir: None,
392
+ * languages: Some(vec!["python".to_string(), "rust".to_string()]),
393
+ * groups: None,
394
+ * };
395
+ * init(&config).unwrap();
396
+ * ```
397
+ */
398
+ export declare function init(config: JsPackConfig): void;
399
+
400
+ /** Controls what data is captured for each query match. */
401
+ export declare enum JsCaptureOutput {
402
+ /** Capture only the matched text. */
403
+ Text = "Text",
404
+ /** Capture only the `NodeInfo`. */
405
+ Node = "Node",
406
+ /** Capture both text and `NodeInfo` (default). */
407
+ Full = "Full",
44
408
  }
45
409
 
46
- /** A structural item (function, class, method, etc.) in source code. */
47
- export interface StructureItem {
48
- kind: string;
49
- name: string;
50
- span: Span;
51
- parent: string | null;
410
+ /** A single captured node within a match. */
411
+ export interface JsCaptureResult {
412
+ /** The capture name from the query (e.g., `"fn_name"`). */
413
+ name: string
414
+ /** The `NodeInfo` snapshot, present when `CaptureOutput` is `Node` or `Full`. */
415
+ node: JsNodeInfo
416
+ /** The matched source text, present when `CaptureOutput` is `Text` or `Full`. */
417
+ text: string
418
+ /** Values of requested child fields, keyed by field name. */
419
+ childFields: string
420
+ /** Byte offset where this capture starts in the source. */
421
+ startByte: number
52
422
  }
53
423
 
54
- /** An import statement extracted from source code. */
55
- export interface ImportInfo {
56
- module: string;
57
- names: string[];
58
- span: Span;
424
+ /** Metadata for a single chunk of source code. */
425
+ export interface JsChunkContext {
426
+ language: string
427
+ chunkIndex: number
428
+ totalChunks: number
429
+ nodeTypes: Array<string>
430
+ contextPath: Array<string>
431
+ symbolsDefined: Array<string>
432
+ comments: Array<JsCommentInfo>
433
+ docstrings: Array<JsDocstringInfo>
434
+ hasErrorNodes: boolean
59
435
  }
60
436
 
61
- /** An export statement extracted from source code. */
62
- export interface ExportInfo {
63
- name: string;
64
- kind: string;
65
- span: Span;
437
+ /** A chunk of source code with rich metadata. */
438
+ export interface JsCodeChunk {
439
+ content: string
440
+ startByte: number
441
+ endByte: number
442
+ startLine: number
443
+ endLine: number
444
+ metadata: JsChunkContext
66
445
  }
67
446
 
68
447
  /** A comment extracted from source code. */
69
- export interface CommentInfo {
70
- text: string;
71
- kind: string;
72
- span: Span;
73
- associatedNode: string | null;
448
+ export interface JsCommentInfo {
449
+ text: string
450
+ kind: JsCommentKind
451
+ span: JsSpan
452
+ associatedNode: string
453
+ }
454
+
455
+ /**
456
+ * The kind of a comment found in source code.
457
+ *
458
+ * Distinguishes between single-line comments, block (multi-line) comments,
459
+ * and documentation comments.
460
+ */
461
+ export declare enum JsCommentKind {
462
+ Line = "Line",
463
+ Block = "Block",
464
+ Doc = "Doc",
465
+ }
466
+
467
+ /** A diagnostic (syntax error, missing node, etc.) from parsing. */
468
+ export interface JsDiagnostic {
469
+ message: string
470
+ severity: JsDiagnosticSeverity
471
+ span: JsSpan
472
+ }
473
+
474
+ /**
475
+ * Severity level of a diagnostic produced during parsing.
476
+ *
477
+ * Used to classify parse errors, warnings, and informational messages
478
+ * found in the syntax tree.
479
+ */
480
+ export declare enum JsDiagnosticSeverity {
481
+ Error = "Error",
482
+ Warning = "Warning",
483
+ Info = "Info",
484
+ }
485
+
486
+ /** A section within a docstring (e.g., Args, Returns, Raises). */
487
+ export interface JsDocSection {
488
+ kind: string
489
+ name: string
490
+ description: string
491
+ }
492
+
493
+ /**
494
+ * The format of a docstring extracted from source code.
495
+ *
496
+ * Identifies the docstring convention used, which varies by language
497
+ * (e.g., Python triple-quoted strings, JSDoc, Rustdoc `///` comments).
498
+ */
499
+ export declare enum JsDocstringFormat {
500
+ PythonTripleQuote = "PythonTripleQuote",
501
+ JSDoc = "JSDoc",
502
+ Rustdoc = "Rustdoc",
503
+ GoDoc = "GoDoc",
504
+ JavaDoc = "JavaDoc",
505
+ Other = "Other",
74
506
  }
75
507
 
76
508
  /** A docstring extracted from source code. */
77
- export interface DocstringInfo {
78
- text: string;
79
- format: string;
80
- span: Span;
81
- associatedItem: string | null;
82
- sections: Array<Record<string, string>>;
509
+ export interface JsDocstringInfo {
510
+ text: string
511
+ format: JsDocstringFormat
512
+ span: JsSpan
513
+ associatedItem: string
514
+ parsedSections: Array<JsDocSection>
83
515
  }
84
516
 
85
- /** A symbol (variable, function, type, etc.) extracted from source code. */
86
- export interface SymbolInfo {
87
- name: string;
88
- kind: string;
89
- span: Span;
90
- typeAnnotation: string | null;
517
+ /** Manages downloading and caching of pre-built parser shared libraries. */
518
+ export declare class JsDownloadManager {
519
+ /** Create a new download manager for the given version. */
520
+ static new(version: string): JsDownloadManager
521
+ /** Create a download manager with a custom cache directory. */
522
+ static withCacheDir(version: string, cacheDir: string): JsDownloadManager
523
+ /** Default cache directory: `~/.cache/tree-sitter-language-pack/v{version}/libs/` */
524
+ static defaultCacheDir(version: string): string
525
+ /** Return the path to the libs cache directory. */
526
+ cacheDir(): string
527
+ /** List languages that are already downloaded and cached. */
528
+ installedLanguages(): Array<string>
529
+ /**
530
+ * Ensure the specified languages are available in the cache.
531
+ * Downloads the platform bundle if any requested languages are missing.
532
+ */
533
+ ensureLanguages(names: Array<string>): void
534
+ /** Ensure all languages in a named group are available. */
535
+ ensureGroup(group: string): void
536
+ /** Get the expected path for a language's shared library in the cache. */
537
+ libPath(name: string): string
538
+ /** Fetch the parser manifest from GitHub Releases. */
539
+ fetchManifest(): JsParserManifest
540
+ /** Remove all cached parser libraries. */
541
+ cleanCache(): void
91
542
  }
92
543
 
93
- /** A diagnostic (syntax error, missing node, etc.) from parsing. */
94
- export interface Diagnostic {
95
- message: string;
96
- severity: string;
97
- span: Span;
544
+ /** An export statement extracted from source code. */
545
+ export interface JsExportInfo {
546
+ name: string
547
+ kind: JsExportKind
548
+ span: JsSpan
98
549
  }
99
550
 
100
- /** Metadata for a single chunk of source code. */
101
- export interface ChunkContext {
102
- language: string;
103
- chunkIndex: number;
104
- totalChunks: number;
105
- startLine: number;
106
- endLine: number;
107
- nodeTypes: string[];
108
- symbolsDefined: string[];
109
- comments: string[];
110
- docstrings: string[];
111
- hasErrorNodes: boolean;
112
- contextPath: string[];
551
+ /**
552
+ * The kind of an export statement found in source code.
553
+ *
554
+ * Covers named exports, default exports, and re-exports from other modules.
555
+ */
556
+ export declare enum JsExportKind {
557
+ Named = "Named",
558
+ Default = "Default",
559
+ ReExport = "ReExport",
113
560
  }
114
561
 
115
- /** A chunk of source code with rich metadata. */
116
- export interface CodeChunk {
117
- content: string;
118
- startByte: number;
119
- endByte: number;
120
- metadata: ChunkContext;
562
+ /** Configuration for an extraction run against a single language. */
563
+ export interface JsExtractionConfig {
564
+ /** The language name (e.g., `"python"`). */
565
+ language: string
566
+ /** Named patterns to run. Keys become the keys in `ExtractionResult::results`. */
567
+ patterns: string
121
568
  }
122
569
 
123
- /** Complete analysis result from processing a source file. */
124
- export interface ProcessResult {
125
- language: string;
126
- metrics: FileMetrics;
127
- structure: StructureItem[];
128
- imports: ImportInfo[];
129
- exports: ExportInfo[];
130
- comments: CommentInfo[];
131
- docstrings: DocstringInfo[];
132
- symbols: SymbolInfo[];
133
- diagnostics: Diagnostic[];
134
- chunks: CodeChunk[];
570
+ /** Defines a single extraction pattern and its configuration. */
571
+ export interface JsExtractionPattern {
572
+ /** The tree-sitter query string (S-expression). */
573
+ query: string
574
+ /** What to include in each capture result. */
575
+ captureOutput: JsCaptureOutput
576
+ /**
577
+ * Field names to extract from child nodes of each capture.
578
+ * Maps a label to a tree-sitter field name used with `child_by_field_name`.
579
+ */
580
+ childFields: Array<string>
581
+ /** Maximum number of matches to return. `None` means unlimited. */
582
+ maxResults: number
583
+ /** Restrict matches to a byte range `(start, end)`. */
584
+ byteRange: Array<number>
135
585
  }
136
586
 
137
- /** A single query capture pairing a capture name with a node. */
138
- export interface QueryCapture {
139
- captureName: string;
140
- node: NodeInfo;
587
+ /** Complete extraction results for all patterns. */
588
+ export interface JsExtractionResult {
589
+ /** The language that was used. */
590
+ language: string
591
+ /** Results keyed by pattern name. */
592
+ results: string
141
593
  }
142
594
 
143
- /** A single pattern match from a tree-sitter query. */
144
- export interface QueryMatch {
145
- patternIndex: number;
146
- captures: QueryCapture[];
595
+ /** Aggregate metrics for a source file. */
596
+ export interface JsFileMetrics {
597
+ totalLines: number
598
+ codeLines: number
599
+ commentLines: number
600
+ blankLines: number
601
+ totalBytes: number
602
+ nodeCount: number
603
+ errorCount: number
604
+ maxDepth: number
147
605
  }
148
606
 
149
- /** Result of resolving a file-extension ambiguity. */
150
- export interface AmbiguityResult {
151
- assigned: string;
152
- alternatives: string[];
607
+ /** An import statement extracted from source code. */
608
+ export interface JsImportInfo {
609
+ source: string
610
+ items: Array<string>
611
+ alias: string
612
+ isWildcard: boolean
613
+ span: JsSpan
153
614
  }
154
615
 
155
- /** Returns an array of all available language names. */
156
- export declare function availableLanguages(): Array<string>;
616
+ export declare class JsLanguage {
617
+ }
618
+
619
+ export interface JsLanguageInfo {
620
+ group: string
621
+ size: number
622
+ }
157
623
 
158
624
  /**
159
- * Get the effective cache directory being used.
625
+ * Thread-safe registry of tree-sitter language parsers.
626
+ *
627
+ * Manages both statically compiled and dynamically loaded language grammars.
628
+ * Use [`LanguageRegistry::new()`] for the default registry, or access the
629
+ * global instance via the module-level convenience functions
630
+ * ([`crate::get_language`], [`crate::available_languages`], etc.).
631
+ *
632
+ * # Example
633
+ *
634
+ * ```no_run
635
+ * use tree_sitter_language_pack::{LanguageRegistry, ProcessConfig};
160
636
  *
161
- * Returns the path as a string. Throws an error if cache directory cannot be determined.
637
+ * let registry = LanguageRegistry::new();
638
+ * let langs = registry.available_languages();
639
+ * println!("Available: {:?}", langs);
640
+ *
641
+ * let config = ProcessConfig::new("python").all();
642
+ * let result = registry.process("def hello(): pass", &config).unwrap();
643
+ * println!("Structure: {:?}", result.structure);
644
+ * ```
162
645
  */
163
- export declare function cacheDir(): string;
646
+ export declare class JsLanguageRegistry {
647
+ /**
648
+ * Create a registry with a custom directory for dynamic libraries.
649
+ *
650
+ * Overrides the default build-time library directory. Useful when
651
+ * dynamic grammar shared libraries are stored in a non-standard location.
652
+ */
653
+ static withLibsDir(libsDir: string): JsLanguageRegistry
654
+ /**
655
+ * Add an additional directory to search for dynamic libraries.
656
+ *
657
+ * When [`get_language`](Self::get_language) cannot find a grammar in the
658
+ * primary library directory, it searches these extra directories in order.
659
+ * Typically used by the download system to register its cache directory.
660
+ *
661
+ * Takes `&self` (not `&mut self`) because `extra_lib_dirs` uses interior
662
+ * mutability via an `Arc<RwLock<...>>`, so the outer registry can remain
663
+ * immutable while the directory list is updated.
664
+ */
665
+ addExtraLibsDir(dir: string): void
666
+ /**
667
+ * Get a tree-sitter [`Language`] by name.
668
+ *
669
+ * Resolves aliases (e.g., `"shell"` -> `"bash"`, `"makefile"` -> `"make"`),
670
+ * then looks up the language in the static table. When the `dynamic-loading`
671
+ * feature is enabled, falls back to loading a shared library on demand.
672
+ *
673
+ * # Errors
674
+ *
675
+ * Returns [`Error::LanguageNotFound`] if the name (after alias resolution)
676
+ * does not match any known grammar.
677
+ */
678
+ getLanguage(name: string): JsLanguage
679
+ /**
680
+ * List all available language names, sorted and deduplicated.
681
+ *
682
+ * Includes statically compiled languages, dynamically loadable languages
683
+ * (if the `dynamic-loading` feature is enabled), and all configured aliases.
684
+ */
685
+ availableLanguages(): Array<string>
686
+ /**
687
+ * Check whether a language is available by name or alias.
688
+ *
689
+ * Returns `true` if the language can be loaded, either from the static
690
+ * table or from a dynamic library on disk.
691
+ */
692
+ hasLanguage(name: string): boolean
693
+ /** Return the total number of available languages (including aliases). */
694
+ languageCount(): number
695
+ /** Parse source code and extract file intelligence based on config in a single pass. */
696
+ process(source: string, config: JsProcessConfig): JsProcessResult
697
+ static default(): JsLanguageRegistry
698
+ }
699
+
700
+ /** A single query match containing one or more captures. */
701
+ export interface JsMatchResult {
702
+ /** The pattern index within the query that produced this match. */
703
+ patternIndex: number
704
+ /** The captures for this match. */
705
+ captures: Array<JsCaptureResult>
706
+ }
164
707
 
165
708
  /**
166
- * Delete all cached parser files.
709
+ * Lightweight snapshot of a tree-sitter node's properties.
167
710
  *
168
- * Throws an error if cache deletion fails.
711
+ * Contains only primitive types for easy cross-language serialization.
712
+ * This is an owned type that can be passed across FFI boundaries, unlike
713
+ * `tree_sitter::Node` which borrows from the tree.
169
714
  */
170
- export declare function cleanCache(): void;
715
+ export interface JsNodeInfo {
716
+ /** The grammar type name (e.g., "function_definition", "identifier"). */
717
+ kind: string
718
+ /** Whether this is a named node (vs anonymous like punctuation). */
719
+ isNamed: boolean
720
+ /** Start byte offset in source. */
721
+ startByte: number
722
+ /** End byte offset in source. */
723
+ endByte: number
724
+ /** Start row (zero-indexed). */
725
+ startRow: number
726
+ /** Start column (zero-indexed). */
727
+ startCol: number
728
+ /** End row (zero-indexed). */
729
+ endRow: number
730
+ /** End column (zero-indexed). */
731
+ endCol: number
732
+ /** Number of named children. */
733
+ namedChildCount: number
734
+ /** Whether this node is an ERROR node. */
735
+ isError: boolean
736
+ /** Whether this node is a MISSING node. */
737
+ isMissing: boolean
738
+ }
171
739
 
172
740
  /**
173
- * Configure the cache directory without downloading.
741
+ * Configuration for the tree-sitter language pack.
742
+ *
743
+ * Controls cache directory and which languages to pre-download.
744
+ * Can be loaded from a TOML file, constructed programmatically,
745
+ * or passed as a dict/object from language bindings.
174
746
  *
175
- * Throws an error if configuration fails.
747
+ * # Example
748
+ *
749
+ * ```no_run
750
+ * use tree_sitter_language_pack::PackConfig;
751
+ *
752
+ * let config = PackConfig {
753
+ * cache_dir: None,
754
+ * languages: Some(vec!["python".to_string(), "rust".to_string()]),
755
+ * groups: None,
756
+ * };
757
+ * ```
176
758
  */
177
- export declare function configure(config: JsPackConfig): void;
759
+ export interface JsPackConfig {
760
+ /**
761
+ * Override default cache directory.
762
+ *
763
+ * Default: `~/.cache/tree-sitter-language-pack/v{version}/libs/`
764
+ */
765
+ cacheDir: string
766
+ /**
767
+ * Languages to pre-download on init.
768
+ *
769
+ * Each entry is a language name (e.g. `"python"`, `"rust"`).
770
+ */
771
+ languages: Array<string>
772
+ /** Language groups to pre-download (e.g. `"web"`, `"systems"`, `"scripting"`). */
773
+ groups: Array<string>
774
+ }
775
+
776
+ export declare class JsParser {
777
+ }
778
+
779
+ /** Manifest describing available parser downloads for a specific version. */
780
+ export interface JsParserManifest {
781
+ version: string
782
+ platforms: Record<string, JsPlatformBundle>
783
+ languages: Record<string, JsLanguageInfo>
784
+ groups: Record<string, Array<string>>
785
+ }
786
+
787
+ /** Results for a single named pattern. */
788
+ export interface JsPatternResult {
789
+ /** The individual matches. */
790
+ matches: Array<JsMatchResult>
791
+ /** Total number of matches before `max_results` truncation. */
792
+ totalCount: number
793
+ }
794
+
795
+ /** Validation information for a single pattern. */
796
+ export interface JsPatternValidation {
797
+ /** Whether the pattern compiled successfully. */
798
+ valid: boolean
799
+ /** Names of captures defined in the query. */
800
+ captureNames: Array<string>
801
+ /** Number of patterns in the query. */
802
+ patternCount: number
803
+ /** Non-fatal warnings (e.g., unused captures). */
804
+ warnings: Array<string>
805
+ /** Fatal errors (e.g., query syntax errors). */
806
+ errors: Array<string>
807
+ }
808
+
809
+ export interface JsPlatformBundle {
810
+ url: string
811
+ sha256: string
812
+ size: number
813
+ }
178
814
 
179
815
  /**
180
- * Download specific languages by name.
816
+ * Configuration for the `process()` function.
817
+ *
818
+ * Controls which analysis features are enabled and whether chunking is performed.
819
+ *
820
+ * # Examples
181
821
  *
182
- * Returns the number of languages successfully downloaded.
183
- * Throws an error if download fails.
822
+ * ```
823
+ * use tree_sitter_language_pack::ProcessConfig;
824
+ *
825
+ * // Defaults: structure + imports + exports enabled
826
+ * let config = ProcessConfig::new("python");
827
+ *
828
+ * // With chunking
829
+ * let config = ProcessConfig::new("python").with_chunking(1000);
830
+ *
831
+ * // Everything enabled
832
+ * let config = ProcessConfig::new("python").all();
833
+ * ```
184
834
  */
185
- export declare function download(names: Array<string>): number;
835
+ export interface JsProcessConfig {
836
+ /** Language name (required). */
837
+ language: string
838
+ /** Extract structural items (functions, classes, etc.). Default: true. */
839
+ structure: boolean
840
+ /** Extract import statements. Default: true. */
841
+ imports: boolean
842
+ /** Extract export statements. Default: true. */
843
+ exports: boolean
844
+ /** Extract comments. Default: false. */
845
+ comments: boolean
846
+ /** Extract docstrings. Default: false. */
847
+ docstrings: boolean
848
+ /** Extract symbol definitions. Default: false. */
849
+ symbols: boolean
850
+ /** Include parse diagnostics. Default: false. */
851
+ diagnostics: boolean
852
+ /** Maximum chunk size in bytes. `None` disables chunking. */
853
+ chunkMaxSize: number
854
+ /**
855
+ * Custom extraction patterns to run against the parsed tree.
856
+ * Keys become the keys in `ProcessResult::extractions`.
857
+ */
858
+ extractions: string
859
+ }
186
860
 
187
861
  /**
188
- * Download all 170+ available languages from the remote manifest.
862
+ * Complete analysis result from processing a source file.
863
+ *
864
+ * Contains metrics, structural analysis, imports/exports, comments,
865
+ * docstrings, symbols, diagnostics, and optionally chunked code segments.
866
+ * Fields are populated based on the [`crate::ProcessConfig`] flags.
189
867
  *
190
- * Returns the number of languages successfully downloaded.
191
- * Throws an error if download fails.
868
+ * # Fields
869
+ *
870
+ * - `language` - The language used for parsing
871
+ * - `metrics` - Always computed: line counts, byte sizes, error counts
872
+ * - `structure` - Functions, classes, structs (when `config.structure = true`)
873
+ * - `imports` - Import statements (when `config.imports = true`)
874
+ * - `exports` - Export statements (when `config.exports = true`)
875
+ * - `comments` - Comments (when `config.comments = true`)
876
+ * - `docstrings` - Docstrings (when `config.docstrings = true`)
877
+ * - `symbols` - Symbol definitions (when `config.symbols = true`)
878
+ * - `diagnostics` - Parse errors (when `config.diagnostics = true`)
879
+ * - `chunks` - Chunked code segments (when `config.chunk_max_size` is set)
192
880
  */
193
- export declare function downloadAll(): number;
881
+ export interface JsProcessResult {
882
+ language: string
883
+ metrics: JsFileMetrics
884
+ structure: Array<JsStructureItem>
885
+ imports: Array<JsImportInfo>
886
+ exports: Array<JsExportInfo>
887
+ comments: Array<JsCommentInfo>
888
+ docstrings: Array<JsDocstringInfo>
889
+ symbols: Array<JsSymbolInfo>
890
+ diagnostics: Array<JsDiagnostic>
891
+ chunks: Array<JsCodeChunk>
892
+ /** Results of custom extraction patterns (when `config.extractions` is set). */
893
+ extractions: string
894
+ }
895
+
896
+ /** A single match from a tree-sitter query, with captured nodes. */
897
+ export interface JsQueryMatch {
898
+ /** The pattern index that matched (position in the query string). */
899
+ patternIndex: number
900
+ /** Captures: list of (capture_name, node_info) pairs. */
901
+ captures: Array<string>
902
+ }
194
903
 
195
904
  /**
196
- * Get all languages that have been downloaded and cached locally.
905
+ * Byte and line/column range in source code.
197
906
  *
198
- * Returns an array of language names currently in the cache.
907
+ * Represents both byte offsets (for slicing) and human-readable line/column
908
+ * positions (for display and diagnostics).
199
909
  */
200
- export declare function downloadedLanguages(): Array<string>;
910
+ export interface JsSpan {
911
+ startByte: number
912
+ endByte: number
913
+ startLine: number
914
+ startColumn: number
915
+ endLine: number
916
+ endColumn: number
917
+ }
918
+
919
+ /** A structural item (function, class, struct, etc.) in source code. */
920
+ export interface JsStructureItem {
921
+ kind: JsStructureKind
922
+ name: string
923
+ visibility: string
924
+ span: JsSpan
925
+ children: Array<JsStructureItem>
926
+ decorators: Array<string>
927
+ docComment: string
928
+ signature: string
929
+ bodySpan: JsSpan
930
+ }
201
931
 
202
932
  /**
203
- * Returns the raw TSLanguage pointer for interop with node-tree-sitter.
933
+ * The kind of structural item found in source code.
204
934
  *
205
- * Throws an error if the language is not found.
935
+ * Categorizes top-level and nested declarations such as functions, classes,
936
+ * structs, enums, traits, and more. Use [`Other`](StructureKind::Other) for
937
+ * language-specific constructs that do not fit a standard category.
206
938
  */
207
- export declare function getLanguagePtr(name: string): number;
939
+ export declare enum JsStructureKind {
940
+ Function = "Function",
941
+ Method = "Method",
942
+ Class = "Class",
943
+ Struct = "Struct",
944
+ Interface = "Interface",
945
+ Enum = "Enum",
946
+ Module = "Module",
947
+ Trait = "Trait",
948
+ Impl = "Impl",
949
+ Namespace = "Namespace",
950
+ Other = "Other",
951
+ }
208
952
 
209
- /** Checks whether a language with the given name is available. */
210
- export declare function hasLanguage(name: string): boolean;
953
+ /** A symbol (variable, function, type, etc.) extracted from source code. */
954
+ export interface JsSymbolInfo {
955
+ name: string
956
+ kind: JsSymbolKind
957
+ span: JsSpan
958
+ typeAnnotation: string
959
+ doc: string
960
+ }
211
961
 
212
962
  /**
213
- * Initialize download system with configuration and pre-download all specified languages.
963
+ * The kind of a symbol definition found in source code.
214
964
  *
215
- * Throws an error if configuration or download fails.
965
+ * Categorizes symbol definitions such as variables, constants, functions,
966
+ * classes, types, interfaces, enums, and modules.
216
967
  */
217
- export declare function init(config?: JsPackConfig | undefined | null): void;
968
+ export declare enum JsSymbolKind {
969
+ Variable = "Variable",
970
+ Constant = "Constant",
971
+ Function = "Function",
972
+ Class = "Class",
973
+ Type = "Type",
974
+ Interface = "Interface",
975
+ Enum = "Enum",
976
+ Module = "Module",
977
+ Other = "Other",
978
+ }
218
979
 
219
- /** Configuration for download and cache management. */
220
- export interface JsPackConfig {
221
- cacheDir?: string;
222
- languages?: Array<string>;
223
- groups?: Array<string>;
980
+ export declare class JsTree {
224
981
  }
225
982
 
226
- /** Configuration for the `process` function. */
227
- export interface JsProcessConfig {
228
- language: string;
229
- structure?: boolean;
230
- imports?: boolean;
231
- exports?: boolean;
232
- comments?: boolean;
233
- docstrings?: boolean;
234
- symbols?: boolean;
235
- diagnostics?: boolean;
236
- chunkMaxSize?: number;
237
- }
238
-
239
- /** Returns the number of available languages. */
240
- export declare function languageCount(): number;
983
+ /** Validation results for an entire extraction config. */
984
+ export interface JsValidationResult {
985
+ /** Whether all patterns are valid. */
986
+ valid: boolean
987
+ /** Per-pattern validation details. */
988
+ patterns: string
989
+ }
241
990
 
242
991
  /**
243
- * Get all available languages from the remote manifest.
992
+ * Return the number of available languages.
993
+ *
994
+ * Includes statically compiled languages, dynamically loadable languages,
995
+ * and aliases.
244
996
  *
245
- * Returns an array of language names. Throws an error if manifest fetch fails.
997
+ * # Example
998
+ *
999
+ * ```no_run
1000
+ * use tree_sitter_language_pack::language_count;
1001
+ *
1002
+ * let count = language_count();
1003
+ * println!("{} languages available", count);
1004
+ * ```
246
1005
  */
247
- export declare function manifestLanguages(): Array<string>;
1006
+ export declare function languageCount(): number;
248
1007
 
249
1008
  /**
250
- * Parse a source string using the named language and return an opaque tree handle.
1009
+ * Return all language names available in the remote manifest (305).
251
1010
  *
252
- * Throws an error if the language is not found or parsing fails.
1011
+ * Fetches (and caches) the remote manifest to discover the full list of
1012
+ * downloadable languages. Use [`downloaded_languages`] to list what is
1013
+ * already cached locally.
1014
+ *
1015
+ * # Errors
1016
+ *
1017
+ * Returns an error if the manifest cannot be fetched.
1018
+ *
1019
+ * # Example
1020
+ *
1021
+ * ```no_run
1022
+ * use tree_sitter_language_pack::manifest_languages;
1023
+ *
1024
+ * let langs = manifest_languages().unwrap();
1025
+ * println!("{} languages available for download", langs.len());
1026
+ * ```
253
1027
  */
254
- export declare function parseString(language: string, source: string): ExternalObject<Tree>;
1028
+ export declare function manifestLanguages(): Array<string>;
255
1029
 
256
1030
  /**
257
- * Process source code using a config and return a result object with metadata and chunks.
1031
+ * Get `NodeInfo` for all named children of the root node.
258
1032
  *
259
- * Accepts both camelCase and snake_case config keys (auto-normalized to snake_case).
260
- * Returns camelCase keys in the result for JavaScript convention.
1033
+ * Useful for understanding the top-level structure of a file
1034
+ * (e.g., list of function definitions, class declarations, imports).
261
1035
  */
262
- export declare function process(source: string, config: JsProcessConfig): ProcessResult;
263
-
264
- /** Check whether any node in the tree has the given type name. */
265
- export declare function treeContainsNodeType(tree: ExternalObject<Tree>, nodeType: string): boolean;
266
-
267
- /** Check whether the tree contains any ERROR or MISSING nodes. */
268
- export declare function treeHasErrorNodes(tree: ExternalObject<Tree>): boolean;
269
-
270
- /** Get the number of named children of the root node. */
271
- export declare function treeRootChildCount(tree: ExternalObject<Tree>): number;
272
-
273
- /** Get the type name of the root node. */
274
- export declare function treeRootNodeType(tree: ExternalObject<Tree>): string;
1036
+ export declare function namedChildrenInfo(tree: JsTree): Array<JsNodeInfo>;
275
1037
 
276
1038
  /**
277
- * Detect language from source content using heuristics.
1039
+ * Parse source code with the named language, returning the syntax tree.
1040
+ *
1041
+ * Uses the global registry to look up the language by name.
1042
+ * Caches parsers per-thread so repeated calls for the same language avoid
1043
+ * re-creating the parser.
278
1044
  *
279
- * Returns the detected language name, or null if detection fails.
1045
+ * # Examples
1046
+ *
1047
+ * ```no_run
1048
+ * let tree = tree_sitter_language_pack::parse_string("python", b"def hello(): pass").unwrap();
1049
+ * assert_eq!(tree.root_node().kind(), "module");
1050
+ * ```
280
1051
  */
281
- export declare function detectLanguageFromContent(content: string): string | null;
1052
+ export declare function parseString(language: string, source: Uint8Array): JsTree;
282
1053
 
283
1054
  /**
284
- * Detect language from a file path or extension.
1055
+ * Process source code and extract file intelligence using the global registry.
1056
+ *
1057
+ * Parses the source with tree-sitter and extracts metrics, structure, imports,
1058
+ * exports, comments, docstrings, symbols, diagnostics, and/or chunks based on
1059
+ * the flags set in [`ProcessConfig`].
1060
+ *
1061
+ * # Errors
1062
+ *
1063
+ * Returns an error if the language is not found or parsing fails.
1064
+ *
1065
+ * # Example
1066
+ *
1067
+ * ```no_run
1068
+ * use tree_sitter_language_pack::{ProcessConfig, process};
285
1069
  *
286
- * Returns the detected language name, or null if detection fails.
1070
+ * let config = ProcessConfig::new("python").all();
1071
+ * let result = process("def hello(): pass", &config).unwrap();
1072
+ * println!("Language: {}", result.language);
1073
+ * println!("Lines: {}", result.metrics.total_lines);
1074
+ * println!("Structures: {}", result.structure.len());
1075
+ * ```
287
1076
  */
288
- export declare function detectLanguage(path: string): string | null;
1077
+ export declare function process(source: string, config: JsProcessConfig): JsProcessResult;
1078
+
1079
+ /** Get a `NodeInfo` snapshot of the root node. */
1080
+ export declare function rootNodeInfo(tree: JsTree): JsNodeInfo;
289
1081
 
290
1082
  /**
291
- * Detect language from a bare file extension (without leading dot).
1083
+ * Execute a tree-sitter query pattern against a parsed tree.
1084
+ *
1085
+ * The `query_source` is an S-expression pattern like:
1086
+ * ```text
1087
+ * (function_definition name: (identifier) @name)
1088
+ * ```
1089
+ *
1090
+ * Returns all matches with their captured nodes.
1091
+ *
1092
+ * # Arguments
292
1093
  *
293
- * Returns the detected language name, or null if detection fails.
1094
+ * * `tree` - The parsed syntax tree to query.
1095
+ * * `language` - Language name (used to compile the query pattern).
1096
+ * * `query_source` - The tree-sitter query pattern string.
1097
+ * * `source` - The original source code bytes (needed for capture resolution).
1098
+ *
1099
+ * # Examples
1100
+ *
1101
+ * ```no_run
1102
+ * let tree = tree_sitter_language_pack::parse_string("python", b"def hello(): pass").unwrap();
1103
+ * let matches = tree_sitter_language_pack::run_query(
1104
+ * &tree,
1105
+ * "python",
1106
+ * "(function_definition name: (identifier) @fn_name)",
1107
+ * b"def hello(): pass",
1108
+ * ).unwrap();
1109
+ * assert!(!matches.is_empty());
1110
+ * ```
294
1111
  */
295
- export declare function detectLanguageFromExtension(ext: string): string | null;
1112
+ export declare function runQuery(tree: JsTree, language: string, querySource: string, source: Uint8Array): Array<JsQueryMatch>;
296
1113
 
297
1114
  /**
298
- * Detect language from a file path based on its extension.
1115
+ * Check whether any node in the tree matches the given type name.
299
1116
  *
300
- * Returns the detected language name, or null if detection fails.
1117
+ * Performs a depth-first traversal using `TreeCursor`.
301
1118
  */
302
- export declare function detectLanguageFromPath(path: string): string | null;
1119
+ export declare function treeContainsNodeType(tree: JsTree, nodeType: string): boolean;
303
1120
 
304
1121
  /**
305
- * Resolve ambiguity for a file extension that maps to multiple languages.
1122
+ * Count the number of ERROR and MISSING nodes in the tree.
306
1123
  *
307
- * Returns the assigned language and alternatives, or null if no ambiguity exists.
1124
+ * Returns 0 for a clean parse.
308
1125
  */
309
- export declare function extensionAmbiguity(ext: string): AmbiguityResult | null;
1126
+ export declare function treeErrorCount(tree: JsTree): number;
310
1127
 
311
1128
  /**
312
- * Get the highlights query string for a language.
1129
+ * Check whether the tree contains any ERROR or MISSING nodes.
313
1130
  *
314
- * Returns the query source, or null if no highlights query is available.
1131
+ * Useful for determining if the parse was clean or had syntax errors.
315
1132
  */
316
- export declare function getHighlightsQuery(language: string): string | null;
1133
+ export declare function treeHasErrorNodes(tree: JsTree): boolean;
317
1134
 
318
1135
  /**
319
- * Get the injections query string for a language.
1136
+ * Return the S-expression representation of the entire tree.
320
1137
  *
321
- * Returns the query source, or null if no injections query is available.
1138
+ * This is the standard tree-sitter debug format, useful for logging,
1139
+ * snapshot testing, and debugging grammars.
322
1140
  */
323
- export declare function getInjectionsQuery(language: string): string | null;
1141
+ export declare function treeToSexp(tree: JsTree): string;
324
1142
 
325
1143
  /**
326
- * Get the locals query string for a language.
1144
+ * Validate extraction patterns without running them.
1145
+ *
1146
+ * Convenience wrapper around [`extract::validate_extraction`].
1147
+ *
1148
+ * # Errors
327
1149
  *
328
- * Returns the query source, or null if no locals query is available.
1150
+ * Returns an error if the language cannot be loaded.
329
1151
  */
330
- export declare function getLocalsQuery(language: string): string | null;
1152
+ export declare function validateExtraction(config: JsExtractionConfig): JsValidationResult;