@xberg-io/tree-sitter-language-pack 1.29.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- This file is auto-generated by alef — DO NOT EDIT. -->
2
- <!-- alef:hash:dbfd4df0a3e6544ff74b02c05b392292c36d90f2f7356b7ffbc193e10018fc12 -->
2
+ <!-- alef:hash:d18073f3ab5aea4732d5fc5d3f3f65b7664aee34ad73f88d70abd2044c92da6e -->
3
3
  <!-- To regenerate: alef readme -->
4
4
  <!-- To verify freshness: alef verify -->
5
5
 
@@ -41,7 +41,7 @@
41
41
  alt="Java"
42
42
  />
43
43
  </a>
44
- <a href="https://pkg.go.dev/github.com/xberg-io/tree-sitter-language-pack/packages/go">
44
+ <a href="https://pkg.go.dev/github.com/xberg-io/tree-sitter-language-pack/packages/go/v2">
45
45
  <img
46
46
  src="https://img.shields.io/github/v/tag/xberg-io/tree-sitter-language-pack?label=Go&color=007ec6"
47
47
  alt="Go"
@@ -100,7 +100,7 @@
100
100
  </a>
101
101
  </div>
102
102
 
103
- Pre-compiled tree-sitter grammars for 371 programming languages with TypeScript types.
103
+ Pre-compiled tree-sitter grammars for 426 programming languages with TypeScript types.
104
104
 
105
105
  ## What This Package Provides
106
106
 
@@ -149,7 +149,7 @@ void main();
149
149
 
150
150
  ## Features
151
151
 
152
- - **371 languages** — pre-compiled tree-sitter grammars covering every major programming language and many minor ones.
152
+ - **426 languages** — pre-compiled tree-sitter grammars covering every major programming language and many minor ones.
153
153
  - **On-demand download + cache** — parsers fetched at first use; subsequent runs hit the local cache.
154
154
  - **Code intelligence** — extract functions, classes, imports, exports, symbols, docstrings, and diagnostics with one API.
155
155
  - **Syntax-aware chunking** — semantic chunks for RAG/LLM pipelines.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef — DO NOT EDIT.
2
- // alef:hash:4c7d955d7536f3dbee7a6d650aa8326ef549680020bb8783390fef09d6724a65
2
+ // alef:hash:dfa2ec46e353ed6072df696783d48f51116b03f9eece4a8eab37653eaf6f9b21
3
3
  // To regenerate: alef generate
4
4
  // To verify freshness: alef verify
5
5
  /* eslint-disable */
@@ -7,57 +7,6 @@ import type { Language } from "tree-sitter";
7
7
 
8
8
  export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
9
9
 
10
- /**
11
- * List all available language names (sorted, deduplicated, includes aliases).
12
- *
13
- * Returns names of both statically compiled and dynamically loadable languages,
14
- * plus any configured aliases.
15
- */
16
- export declare function availableLanguages(): Array<string>;
17
-
18
- /**
19
- * Return the effective cache directory path.
20
- *
21
- * This is `{base}/tree-sitter-language-pack/v{version}/libs/`, where `{base}` is
22
- * either the custom BASE directory set via `configure` / `init`
23
- * (`PackConfig.cache_dir`) or the platform default cache directory — both are
24
- * suffixed identically, so a custom `cache_dir` is never used as the final libs
25
- * path. The default resolves to `~/.cache/tree-sitter-language-pack/v{version}/libs/`
26
- * on a typical Unix system.
27
- * @throws Returns an error if no cache directory can be resolved: `version` is somehow
28
- * invalid, or (with no custom `cache_dir` configured) the platform reports none
29
- * and `TREE_SITTER_LANGUAGE_PACK_CACHE_DIR` is unset. This crate no longer falls
30
- * back to the temporary directory for the latter case — see #101 H2.
31
- */
32
- export declare function cacheDir(): string;
33
-
34
- /**
35
- * Delete all cached parser shared libraries.
36
- *
37
- * Resets the cache registration so the next call to `get_language` or
38
- * a download function will re-register the (now empty) cache directory.
39
- * @throws Returns an error if the cache directory cannot be removed.
40
- */
41
- export declare function cleanCache(): void;
42
-
43
- /**
44
- * Apply download configuration without downloading anything.
45
- *
46
- * Use this to set a custom cache directory before the first call to
47
- * `get_language` or any download function. Changing the cache dir
48
- * after languages have been registered has no effect on already-loaded
49
- * languages.
50
- *
51
- * `PackConfig.cache_dir` is a BASE directory, not the final libs path: this
52
- * crate appends `tree-sitter-language-pack/v{version}/libs` to it, the same
53
- * suffix applied to the platform default cache directory. In the example below,
54
- * files actually land under `/tmp/my-parsers/tree-sitter-language-pack/v{version}/libs/`,
55
- * never directly in `/tmp/my-parsers/`. Call `cache_dir` to read back the
56
- * resolved, fully-suffixed path.
57
- * @throws Returns an error if the lock cannot be acquired.
58
- */
59
- export declare function configure(config?: PackConfig | undefined | null): void;
60
-
61
10
  /**
62
11
  * Detect language name from a file path or extension.
63
12
  *
@@ -102,62 +51,6 @@ export declare function detectLanguageFromExtension(ext: string): string | null;
102
51
  */
103
52
  export declare function detectLanguageFromPath(path: string): string | null;
104
53
 
105
- /**
106
- * Download specific languages to the local cache.
107
- *
108
- * Returns the number of distinct languages available after the call. Already
109
- * compiled or cached languages are included in the count.
110
- *
111
- * Aliases are resolved before counting, so `["shell", "bash"]` names one
112
- * language and returns 1.
113
- * @throws Returns an error if any language is not available in the manifest or if
114
- * the download fails.
115
- */
116
- export declare function download(names: Array<string>): number;
117
-
118
- /**
119
- * Download all available languages from the remote manifest.
120
- *
121
- * Downloads the platform bundle and extracts every library it contains.
122
- * Languages that appear in the manifest but are absent from the bundle
123
- * (e.g. grammars that failed to compile at release time) are silently
124
- * skipped — they are not treated as an error.
125
- *
126
- * Returns the total number of languages now available (statically compiled
127
- * plus downloaded and cached).
128
- * @throws Returns an error if the manifest cannot be fetched or the bundle download fails.
129
- */
130
- export declare function downloadAll(): number;
131
-
132
- /**
133
- * Return languages that are already downloaded and cached locally.
134
- *
135
- * Does not perform any network requests. Returns an empty list if the
136
- * cache directory does not exist or cannot be read.
137
- */
138
- export declare function downloadedLanguages(): Array<string>;
139
-
140
- /**
141
- * Download every language in a named group.
142
- *
143
- * Groups are defined by the remote manifest, not by this crate, and let you
144
- * ensure a curated set of related grammars in one call instead of listing each
145
- * name to `download()`. Already-cached languages are skipped.
146
- *
147
- * Call `manifest_groups` to discover the group names the manifest actually
148
- * defines. The published manifest currently defines a single group, `"all"`;
149
- * earlier revisions of this documentation advertised `"web"`, `"data"`, and
150
- * `"systems"`, which the manifest has never contained, so every call following
151
- * that example failed. Do not hardcode a group name without checking.
152
- *
153
- * Returns the total number of languages now available (statically compiled
154
- * plus downloaded and cached).
155
- * @throws Returns `Error.Download` if the manifest cannot be fetched, if the group
156
- * is unknown — the message lists the groups the manifest defines — or if any
157
- * constituent language fails to download.
158
- */
159
- export declare function downloadGroup(name: string): number;
160
-
161
54
  /**
162
55
  * Get the folds query for a language, if bundled.
163
56
  *
@@ -191,56 +84,15 @@ export declare function getIndentsQuery(language: string): string | null;
191
84
  export declare function getInjectionsQuery(language: string): string | null;
192
85
 
193
86
  /**
194
- * Get a tree-sitter `Language` by name using the global registry.
87
+ * Get a tree-sitter `Language` by name using a default `Pack`.
195
88
  *
196
- * Resolves language aliases (e.g., `"shell"` maps to `"bash"`).
197
- * When the `download` feature is enabled (default), automatically downloads
198
- * the parser from GitHub releases if not found locally.
199
- * @throws Returns `Error.LanguageNotFound` if the language is not recognized,
200
- * or `Error.Download` if auto-download fails.
89
+ * A compatibility entry point required by the generated Python `Parser` capsule
90
+ * constructor. Prefer `Pack.language` when you own a configured pack; the
91
+ * WebAssembly target exposes only this free function.
92
+ * @throws Returns any error `Pack.language` can return.
201
93
  */
202
94
  export declare function getLanguage(name: string): Language;
203
95
 
204
- /**
205
- * Get a tree-sitter `Language` by name without any network access.
206
- *
207
- * Returns a statically compiled grammar, or a dynamic grammar whose shared
208
- * library is present right now. Anything else fails with `Error.CacheMiss`
209
- * and no request is made — the manifest is never fetched, not even to discover
210
- * a download URL.
211
- *
212
- * The on-disk cache is checked on every call, so a concurrent
213
- * `clean_cache` turns a later cache-only lookup into a miss instead of a
214
- * download. In builds without the `download` feature this behaves the same way
215
- * as `get_language` for locally available grammars, but reports a missing
216
- * grammar as `Error.CacheMiss`.
217
- * @throws Returns `Error.CacheMiss` when the grammar is known but not cached, or
218
- * `Error.LanguageNotFound` when the name is not recognised at all.
219
- */
220
- export declare function getLanguageCacheOnly(name: string): Language;
221
-
222
- /**
223
- * Get a tree-sitter `Language` by name with a wall-clock acquisition deadline.
224
- *
225
- * Behaves like `get_language` but bounds the complete acquisition by
226
- * `deadline_secs`: the in-process and cross-process cache-lock waits, DNS
227
- * resolution, redirects, the manifest request and the complete platform-bundle
228
- * download all draw from the same budget.
229
- *
230
- * When the budget is exhausted the call fails with
231
- * `Error.AcquisitionTimeout` and nothing partial is returned. With no
232
- * deadline, `get_language` keeps the historical 60-second network timeout,
233
- * which surfaces as `Error.Download`.
234
- *
235
- * In builds without the `download` feature there is no network step at all, so
236
- * the argument is validated and otherwise unused.
237
- * @throws Returns `Error.Config` when `deadline_secs` is not a positive finite
238
- * number, `Error.LanguageNotFound` for an unknown name,
239
- * `Error.AcquisitionTimeout` when the budget is exhausted, or
240
- * `Error.Download` for any other fetch failure.
241
- */
242
- export declare function getLanguageWithDeadline(name: string, deadlineSecs: number): Language;
243
-
244
96
  /**
245
97
  * Get the locals query for a language, if bundled.
246
98
  *
@@ -249,16 +101,6 @@ export declare function getLanguageWithDeadline(name: string, deadlineSecs: numb
249
101
  */
250
102
  export declare function getLocalsQuery(language: string): string | null;
251
103
 
252
- /**
253
- * Get a `Parser` pre-configured for the given language.
254
- *
255
- * This is a convenience function that calls `get_language` and configures
256
- * a new parser in one step.
257
- * @throws Returns `Error.LanguageNotFound` if the language is not recognized, or
258
- * `Error.ParserSetup` if the language cannot be applied to the parser.
259
- */
260
- export declare function getParser(name: string): Parser;
261
-
262
104
  /**
263
105
  * Get the tags query for a language, if bundled.
264
106
  *
@@ -267,24 +109,6 @@ export declare function getParser(name: string): Parser;
267
109
  */
268
110
  export declare function getTagsQuery(language: string): string | null;
269
111
 
270
- /**
271
- * Check if a language is available by name or alias.
272
- *
273
- * Returns `true` if the language can be loaded (statically compiled,
274
- * dynamically available, or a known alias for one of these).
275
- */
276
- export declare function hasLanguage(name: string): boolean;
277
-
278
- /**
279
- * Initialize the language pack with the given configuration.
280
- *
281
- * Applies any custom cache directory, then downloads all languages and groups
282
- * specified in the config. This is the recommended entry point when you want
283
- * to pre-warm the cache before use.
284
- * @throws Returns an error if configuration cannot be applied or if downloads fail.
285
- */
286
- export declare function init(config?: PackConfig | undefined | null): void;
287
-
288
112
  /** A byte range — start (inclusive) to end (exclusive). */
289
113
  export interface ByteRange {
290
114
  /** Inclusive start byte offset. */
@@ -544,7 +368,7 @@ export declare class DownloadManager {
544
368
  * Derived from the on-disk cache filenames, one canonical name per file, plus
545
369
  * every alias that resolves to it (via `aliases_for`) — so
546
370
  * this list agrees with the user-facing
547
- * `LanguageRegistry.available_languages`
371
+ * `Pack.available_languages`
548
372
  * about which names are "available"; both report `"shell"` once `bash` is
549
373
  * cached, for example. A previous version reported canonical names only,
550
374
  * which could never agree with `available_languages()`. See #107.
@@ -604,6 +428,32 @@ export declare enum ExportKind {
604
428
  ReExport = "ReExport",
605
429
  }
606
430
 
431
+ /**
432
+ * One analysis feature the `process` pipeline can extract.
433
+ *
434
+ * A `ProcessConfig` carries the enabled set in `ProcessConfig.features`.
435
+ * The default set is `Feature.DEFAULT`: `Feature.Structure`,
436
+ * `Feature.Imports`, and `Feature.Exports`.
437
+ */
438
+ export declare enum Feature {
439
+ /** Structural items: functions, classes, structs, and so on. */
440
+ Structure = "structure",
441
+ /** Import statements. */
442
+ Imports = "imports",
443
+ /** Export statements. */
444
+ Exports = "exports",
445
+ /** Comments. */
446
+ Comments = "comments",
447
+ /** Docstrings and doc comments. */
448
+ Docstrings = "docstrings",
449
+ /** Symbol definitions. */
450
+ Symbols = "symbols",
451
+ /** Parse diagnostics. */
452
+ Diagnostics = "diagnostics",
453
+ /** Hierarchical key/value data extraction for data-format files. */
454
+ DataExtraction = "data_extraction",
455
+ }
456
+
607
457
  /** Aggregate metrics for a source file. */
608
458
  export interface FileMetrics {
609
459
  /** Total number of lines (including blank and comment lines). */
@@ -624,6 +474,49 @@ export interface FileMetrics {
624
474
  readonly maxDepth?: number
625
475
  }
626
476
 
477
+ /**
478
+ * A language's grammar identity, safe to use as a cache key component.
479
+ *
480
+ * `source_hash` changes when the compiled grammar source, its patch set, or the
481
+ * generator's `parser.c` output changes. `queries_hash` changes independently
482
+ * when the bundled queries change. Neither changes with the pack version or the
483
+ * tree-sitter runtime version.
484
+ */
485
+ export interface GrammarSource {
486
+ /** Canonical language name this identity belongs to. */
487
+ readonly language: string
488
+ /**
489
+ * Stable id of the grammar build unit, shared by languages compiled from the
490
+ * same source and patch set.
491
+ */
492
+ readonly grammarId: string
493
+ /**
494
+ * `blake3:<64 hex>` over the compiled source after patches.
495
+ *
496
+ * Changes when the compiled bytes change: a source edit, a patch that changes
497
+ * them, or a generator update. A patch-file edit that leaves the compiled
498
+ * bytes unchanged changes `Self.grammar_id` but not this value.
499
+ */
500
+ readonly sourceHash: string
501
+ /**
502
+ * `blake3:<64 hex>` over the effective query set.
503
+ *
504
+ * Changes when a bundled or overlay query changes, independently of the
505
+ * parser source.
506
+ */
507
+ readonly queriesHash: string
508
+ /** Upstream repository, absent for a local grammar. */
509
+ readonly repo?: string
510
+ /** Upstream commit, absent for a local grammar. */
511
+ readonly rev?: string
512
+ /** Subdirectory inside the upstream repository, when the grammar lives in one. */
513
+ readonly directory?: string
514
+ /** SPDX license identifier. */
515
+ readonly license?: string
516
+ /** Parser ABI version the vendored source declares. */
517
+ readonly abiVersion?: number
518
+ }
519
+
627
520
  /** An import statement extracted from source code. */
628
521
  export interface ImportInfo {
629
522
  /** The module or path being imported from. */
@@ -686,87 +579,6 @@ export interface InputEdit {
686
579
  readonly newEndPosition: Point
687
580
  }
688
581
 
689
- /**
690
- * Thread-safe registry of tree-sitter language parsers.
691
- *
692
- * Manages both statically compiled and dynamically loaded language grammars.
693
- * Use `LanguageRegistry.new()` for the default registry, or access the
694
- * global instance via the module-level convenience functions
695
- * (`get_language`, `available_languages`, etc.).
696
- */
697
- export declare class LanguageRegistry {
698
- /**
699
- * Create a new registry populated with all statically compiled languages.
700
- *
701
- * When the `dynamic-loading` feature is enabled, the registry also knows
702
- * about dynamically loadable grammars and will load them on demand.
703
- */
704
- static new(): LanguageRegistry
705
- /**
706
- * List all available language names, sorted and deduplicated.
707
- *
708
- * Includes statically compiled languages, dynamically loadable languages
709
- * (if the `dynamic-loading` feature is enabled), and all configured aliases.
710
- */
711
- availableLanguages(): Array<string>
712
- /**
713
- * Check whether this language can be parsed right now, without downloading.
714
- *
715
- * Resolves aliases, then answers from exactly the lookup
716
- * `get_language` performs: the statically compiled
717
- * table, the already-loaded dynamic grammars, and the parser shared
718
- * libraries present in the primary and extra (download-cache) library
719
- * directories. It never performs network I/O.
720
- *
721
- * A previous implementation consulted only the statically compiled table.
722
- * That table is empty in every build that does not set `TSLP_LANGUAGES`,
723
- * so the function answered `false` for languages this registry parses
724
- * perfectly well.
725
- *
726
- * Contrast `has_language`, which is also `true` for a
727
- * grammar that is merely *known to the manifest* and would have to be
728
- * downloaded first. The pair distinguishes "we can parse it offline, now"
729
- * from "we recognise the name".
730
- *
731
- * The first `true` answer for a dynamic grammar loads its shared library:
732
- * loading is the only way to know the grammar is usable, since a truncated
733
- * or wrong-architecture library exists on disk but cannot parse. Loads are
734
- * cached process-wide, so repeat calls are cheap.
735
- */
736
- hasParser(name: string): boolean
737
- /**
738
- * Check whether a language is available by name or alias.
739
- *
740
- * Returns `true` if the language can be loaded, either from the static
741
- * table or from a dynamic library on disk.
742
- *
743
- * Every branch is one more way to answer `true`, so they are ordered
744
- * cheapest-first and the filesystem is only consulted once every in-memory
745
- * source has said no. Probing the loaded-grammar map and the manifest ahead
746
- * of the `stat` calls is what keeps this off the syscall path for the
747
- * languages a process actually uses.
748
- */
749
- hasLanguage(name: string): boolean
750
- /**
751
- * Return the total number of available languages (including aliases).
752
- *
753
- * Counts the same set `available_languages`
754
- * lists, without materialising or sorting it.
755
- */
756
- languageCount(): number
757
- /**
758
- * Parse source code and extract file intelligence based on config in a single pass.
759
- * @throws Returns `Error.InvalidRange` if the config is invalid (see
760
- * `ProcessConfig.validate`) or if the source
761
- * exceeds the configured
762
- * `max_source_bytes`;
763
- * `Error.LanguageNotFound` if the language is unknown; or
764
- * `Error.ParseFailed` if parsing produces no tree.
765
- */
766
- process(source: string, config?: ProcessConfig | undefined | null): ProcessResult
767
- static default(): LanguageRegistry
768
- }
769
-
770
582
  /**
771
583
  * A single syntax node within a `Tree`.
772
584
  *
@@ -827,11 +639,129 @@ export declare class Node {
827
639
  walk(): TreeCursor
828
640
  }
829
641
 
642
+ /**
643
+ * An explicit handle to a configured language pack.
644
+ *
645
+ * Construct one with `Pack.new` for defaults, `Pack.with_config` to apply
646
+ * an explicit configuration, or `Pack.discover` to read `language-pack.toml`
647
+ * from the filesystem. Every method takes `&self`; a `Pack` is `Send + Sync` and
648
+ * may be shared across threads.
649
+ */
650
+ export declare class Pack {
651
+ /**
652
+ * Create a pack with the default configuration and cache directory.
653
+ *
654
+ * No language is downloaded until a method that needs it is called.
655
+ */
656
+ static new(): Pack
657
+ /**
658
+ * Discover `language-pack.toml` and build a pack from it.
659
+ *
660
+ * Searches the current directory and its parents, then the platform config
661
+ * directory. Returns `Ok(None)` when no candidate file exists. A candidate
662
+ * that exists but cannot be parsed is reported as an error rather than being
663
+ * silently ignored.
664
+ * @throws Returns an error if a discovered file is unreadable or malformed, or if the
665
+ * resulting configuration cannot be applied.
666
+ */
667
+ static discover(): Pack | null
668
+ /** A copy of the configuration this pack was built with. */
669
+ configuration(): PackConfig
670
+ /**
671
+ * Get a `Parser` pre-configured for the given language.
672
+ * @throws Returns any error `Pack.language` can return, or `Error.ParserSetup`
673
+ * when the language cannot be applied to a parser.
674
+ */
675
+ parser(name: string): Parser
676
+ /**
677
+ * Process source code and extract file intelligence using this pack.
678
+ * @throws Returns `Error.InvalidRange` for a zero-valued limit or source larger
679
+ * than `ProcessConfig.max_source_bytes`, `Error.ParseTimeout` when the
680
+ * parse exceeds `ProcessConfig.parse_timeout_ms`, `Error.LanguageNotFound`
681
+ * for an unknown language, or `Error.ParseFailed` when parsing yields no tree.
682
+ */
683
+ process(source: string, config?: ProcessConfig | undefined | null): ProcessResult
684
+ /** List all available language names (sorted, deduplicated, includes aliases). */
685
+ availableLanguages(): Array<string>
686
+ /**
687
+ * Return languages already downloaded and cached locally for this pack.
688
+ *
689
+ * Performs no network requests. Without the `download` feature there is no
690
+ * managed cache, so the result is empty.
691
+ */
692
+ downloadedLanguages(): Array<string>
693
+ /** Check whether this language can be parsed right now, without downloading. */
694
+ hasParser(name: string): boolean
695
+ /** Check whether a language is known by name or alias. */
696
+ hasLanguage(name: string): boolean
697
+ /** Return the number of available languages, including aliases. */
698
+ languageCount(): number
699
+ /**
700
+ * Return the effective cache directory for this pack.
701
+ * @throws Returns an error when no cache directory can be resolved; without the
702
+ * `download` feature there is no managed cache directory to report.
703
+ */
704
+ cacheDir(): string
705
+ /**
706
+ * Download specific languages to this pack's cache.
707
+ *
708
+ * Returns the number of distinct languages requested after alias resolution.
709
+ * Already compiled or cached languages are included in that count.
710
+ * @throws Returns an error if a language is not in the manifest or a download fails.
711
+ */
712
+ download(names: Array<string>): number
713
+ /**
714
+ * Prefetch grammars: download anything not already loadable, then load every
715
+ * requested language into this pack so a later hot loop only parses.
716
+ * @throws Returns `Error.Download` when a required grammar cannot be fetched, or
717
+ * `Error.LanguageNotFound` for an unknown name.
718
+ */
719
+ prefetch(languages: Array<string>): void
720
+ /**
721
+ * Download all available languages from the remote manifest.
722
+ *
723
+ * Returns the total number of languages now available.
724
+ * @throws Returns an error if the manifest or bundle cannot be fetched.
725
+ */
726
+ downloadAll(): number
727
+ /**
728
+ * Download every language in a named manifest group.
729
+ *
730
+ * Returns the total number of languages now available.
731
+ * @throws Returns `Error.Download` if the manifest cannot be fetched or the group
732
+ * is unknown, or if a constituent language fails to download.
733
+ */
734
+ downloadGroup(name: string): number
735
+ /**
736
+ * Return all language names available in the remote manifest.
737
+ * @throws Returns an error if the manifest cannot be fetched.
738
+ */
739
+ manifestLanguages(): Array<string>
740
+ /**
741
+ * Return the names of every language group the remote manifest defines, sorted.
742
+ * @throws Returns `Error.Download` if the manifest cannot be fetched.
743
+ */
744
+ manifestGroups(): Array<string>
745
+ /**
746
+ * Delete every cached parser shared library belonging to this pack's cache.
747
+ * @throws Returns an error if the cache directory cannot be removed.
748
+ */
749
+ cleanCache(): void
750
+ /**
751
+ * Return the embedded grammar identity for a language.
752
+ * @throws Returns `Error.LanguageNotFound` for an unknown name.
753
+ */
754
+ languageSource(name: string): GrammarSource
755
+ /** Return the embedded grammar identity for every known language, sorted by name. */
756
+ languageSources(): Array<GrammarSource>
757
+ static default(): Pack
758
+ }
759
+
830
760
  /**
831
761
  * Configuration for the tree-sitter language pack.
832
762
  *
833
- * Controls cache directory and which languages to pre-download.
834
- * Can be loaded from a TOML file, constructed programmatically,
763
+ * Controls the cache directory and the language/group lists a caller or the CLI
764
+ * can pre-download. Can be loaded from a TOML file, constructed programmatically,
835
765
  * or passed as a dict/object from language bindings.
836
766
  */
837
767
  export interface PackConfig {
@@ -853,18 +783,21 @@ export interface PackConfig {
853
783
  */
854
784
  readonly cacheDir?: string
855
785
  /**
856
- * Languages to pre-download on init.
786
+ * Languages a caller can pre-download with `Pack.prefetch`.
857
787
  *
858
- * Each entry is a language name (e.g. `"python"`, `"rust"`).
788
+ * Each entry is a language name (e.g. `"python"`, `"rust"`). Building a pack
789
+ * from this configuration stores the list; it does not download anything until
790
+ * `prefetch` or `download` is called.
859
791
  */
860
792
  readonly languages?: Array<string>
861
793
  /**
862
- * Language groups to pre-download.
794
+ * Language groups a caller can pre-download with
795
+ * `Pack.download_group`.
863
796
  *
864
797
  * Group names come from the remote manifest, so the valid set is not fixed
865
798
  * by this crate; the published manifest currently defines only `"all"`.
866
- * Call `manifest_groups` to enumerate them.
867
- * An unknown name makes `init` fail.
799
+ * Call `Pack.manifest_groups` to enumerate
800
+ * them. An unknown name makes `download_group` fail.
868
801
  */
869
802
  readonly groups?: Array<string>
870
803
  }
@@ -903,8 +836,10 @@ export declare class Parser {
903
836
  /**
904
837
  * Configure the parser to use the language identified by name (e.g. `"python"`).
905
838
  *
906
- * Resolves the language through the global registry — auto-downloading
907
- * if necessary, when the `download` feature is enabled.
839
+ * This convenience method builds a default `Pack` and resolves the
840
+ * language through it — auto-downloading if necessary when the `download`
841
+ * feature is enabled. Prefer `parser` when you already own a
842
+ * configured pack.
908
843
  * @throws Returns `Error.LanguageNotFound` if the language is not recognized,
909
844
  * or `Error.ParserSetup` if the language ABI is incompatible.
910
845
  */
@@ -972,28 +907,18 @@ export interface Point {
972
907
  readonly column: number
973
908
  }
974
909
 
975
- /**
976
- * Configuration for the `process()` function.
977
- *
978
- * Controls which analysis features are enabled and whether chunking is performed.
979
- */
910
+ /** Configuration for `process`. */
980
911
  export interface ProcessConfig {
981
912
  /** Language name (required). */
982
913
  readonly language?: string
983
- /** Extract structural items (functions, classes, etc.). Default: true. */
984
- readonly structure?: boolean
985
- /** Extract import statements. Default: true. */
986
- readonly imports?: boolean
987
- /** Extract export statements. Default: true. */
988
- readonly exports?: boolean
989
- /** Extract comments. Default: false. */
990
- readonly comments?: boolean
991
- /** Extract docstrings. Default: false. */
992
- readonly docstrings?: boolean
993
- /** Extract symbol definitions. Default: false. */
994
- readonly symbols?: boolean
995
- /** Include parse diagnostics. Default: false. */
996
- readonly diagnostics?: boolean
914
+ /**
915
+ * Analysis features to extract.
916
+ *
917
+ * `None` (the default) uses `Feature.DEFAULT`: structure, imports, and exports.
918
+ * `Some(vec![])` disables every feature, which is what `ProcessConfig.minimal`
919
+ * produces. `Some(vec![...])` enables exactly the listed features.
920
+ */
921
+ readonly features?: Array<Feature>
997
922
  /**
998
923
  * Maximum chunk size in bytes. `None` disables chunking.
999
924
  *
@@ -1003,17 +928,6 @@ export interface ProcessConfig {
1003
928
  * whole source; use `None` to mean "do not chunk".
1004
929
  */
1005
930
  readonly chunkMaxSize?: number
1006
- /**
1007
- * Extract hierarchical key/value data tree from data-format files. Default: false.
1008
- *
1009
- * When `true`, `ProcessResult.data` is populated
1010
- * with a `DataNode` tree for supported languages: JSON, YAML,
1011
- * TOML, `.properties`, HCL/HOCON, INI, editorconfig, KDL, CUE, CSV, PSV, PO,
1012
- * nginx config, Caddy config, XML, and DTD.
1013
- *
1014
- * For languages outside this set the field is left as `None`.
1015
- */
1016
- readonly dataExtraction?: boolean
1017
931
  /**
1018
932
  * Reject source longer than this many bytes instead of parsing it.
1019
933
  * Default: `None` (unbounded).
@@ -1046,19 +960,20 @@ export interface ProcessConfig {
1046
960
  *
1047
961
  * Contains metrics, structural analysis, imports/exports, comments,
1048
962
  * docstrings, symbols, diagnostics, and optionally chunked code segments.
1049
- * Fields are populated based on the `ProcessConfig` flags.
963
+ * Fields are populated based on the `Feature` values in
964
+ * `features`.
1050
965
  *
1051
966
  * # Fields
1052
967
  *
1053
968
  * - `language` - The language used for parsing
1054
969
  * - `metrics` - Always computed: line counts, byte sizes, error counts
1055
- * - `structure` - Functions, classes, structs (when `config.structure = true`)
1056
- * - `imports` - Import statements (when `config.imports = true`)
1057
- * - `exports` - Export statements (when `config.exports = true`)
1058
- * - `comments` - Comments (when `config.comments = true`)
1059
- * - `docstrings` - Docstrings (when `config.docstrings = true`)
1060
- * - `symbols` - Symbol definitions (when `config.symbols = true`)
1061
- * - `diagnostics` - Parse errors (when `config.diagnostics = true`)
970
+ * - `structure` - Functions, classes, structs (with `Structure`)
971
+ * - `imports` - Import statements (with `Imports`)
972
+ * - `exports` - Export statements (with `Exports`)
973
+ * - `comments` - Comments (with `Comments`)
974
+ * - `docstrings` - Docstrings (with `Docstrings`)
975
+ * - `symbols` - Symbol definitions (with `Symbols`)
976
+ * - `diagnostics` - Parse errors (with `Diagnostics`)
1062
977
  * - `chunks` - Chunked code segments (when `config.chunk_max_size` is set)
1063
978
  */
1064
979
  export interface ProcessResult {
@@ -1293,63 +1208,61 @@ export declare class TreeCursor {
1293
1208
  }
1294
1209
 
1295
1210
  /**
1296
- * Return the number of available languages.
1211
+ * Return the embedded grammar identity for a language.
1297
1212
  *
1298
- * Includes statically compiled languages, dynamically loadable languages,
1299
- * and aliases.
1213
+ * The value is generated from `sources/grammars.lock.json` at build time, so it
1214
+ * is identical for a downloaded grammar and one served from cache, and costs
1215
+ * nothing at lookup. Use it as the grammar component of a cache key for syntax
1216
+ * trees, chunks or embeddings.
1217
+ * @throws Returns `Error.LanguageNotFound` for an unknown name.
1300
1218
  */
1301
- export declare function languageCount(): number;
1219
+ export declare function languageSource(name: string): GrammarSource;
1220
+
1221
+ /** Return the embedded grammar identity for every known language, sorted by name. */
1222
+ export declare function languageSources(): Array<GrammarSource>;
1302
1223
 
1303
1224
  /**
1304
1225
  * Return the names of every language group the remote manifest defines, sorted.
1305
1226
  *
1306
- * Group names are manifest data, not a compile-time constant of this crate, so
1307
- * this is the only reliable way to learn what `download_group` and
1308
- * `PackConfig.groups` accept. The published manifest currently defines just
1309
- * `"all"`.
1227
+ * Delegates to a default `Pack`; use `Pack.manifest_groups` to respect a
1228
+ * custom cache directory.
1310
1229
  * @throws Returns `Error.Download` if the manifest cannot be fetched.
1311
1230
  */
1312
1231
  export declare function manifestGroups(): Array<string>;
1313
1232
 
1314
1233
  /**
1315
- * Return all language names available in the remote manifest (371).
1234
+ * Return all language names available in the remote manifest (426).
1316
1235
  *
1317
- * Fetches (and caches) the remote manifest to discover the full list of
1318
- * downloadable languages. Use `downloaded_languages` to list what is
1319
- * already cached locally.
1236
+ * Delegates to a default `Pack`; use `Pack.manifest_languages` to respect a
1237
+ * custom cache directory.
1320
1238
  * @throws Returns an error if the manifest cannot be fetched.
1321
1239
  */
1322
1240
  export declare function manifestLanguages(): Array<string>;
1323
1241
 
1324
1242
  /**
1325
- * Prefetch grammars: download any not already loadable from disk, then load every
1326
- * requested language into the process registry so a subsequent hot loop only parses.
1243
+ * Build a `Pack` from an explicit `PackConfig`.
1327
1244
  *
1328
- * Unlike `download()`, this does not trust in-memory availability — it downloads
1329
- * whenever a grammar is not actually loadable from disk (fixing the case where a
1330
- * known-but-not-downloaded grammar is reported present), then resolves and caches
1331
- * every requested language. Call it once, up front, before a parallel workload.
1332
- * @throws Returns `Error.Download` if a required grammar cannot be fetched, or
1333
- * `Error.LanguageNotFound` if a requested name is unknown.
1245
+ * Bindings expose this as a free factory because alef cannot generate a delegatable
1246
+ * constructor that takes a DTO parameter and returns the pack handle. Rust callers
1247
+ * may use `Pack.with_config` directly.
1248
+ * @throws Returns an error when the configured cache directory cannot be resolved or an
1249
+ * existing directory is not safely owned by this user.
1334
1250
  */
1335
- export declare function prefetch(languages: Array<string>): void;
1251
+ export declare function packWithConfig(config?: PackConfig | undefined | null): Pack;
1336
1252
 
1337
1253
  /**
1338
- * Process source code and extract file intelligence using the global registry.
1254
+ * Process source code with a default `Pack`.
1339
1255
  *
1340
- * Parses the source with tree-sitter and extracts metrics, structure, imports,
1341
- * exports, comments, docstrings, symbols, diagnostics, and/or chunks based on
1342
- * the flags set in `ProcessConfig`.
1343
- * @throws Returns `Error.InvalidRange` if the config carries a zero-valued limit or
1344
- * the source exceeds `ProcessConfig.max_source_bytes`,
1345
- * `Error.ParseTimeout` if the parse exceeds
1346
- * `ProcessConfig.parse_timeout_ms`, `Error.LanguageNotFound` if the
1347
- * language is unknown, or `Error.ParseFailed` if parsing yields no tree.
1256
+ * A compatibility entry point for the generated e2e harness and for callers that
1257
+ * do not need an explicit pack. It constructs a default `Pack` per call; prefer
1258
+ * `Pack.process` when you own a configured pack. Every other operation now
1259
+ * requires a `Pack`. The WebAssembly target exposes only this free function.
1260
+ * @throws Returns any error `Pack.process` can return.
1348
1261
  */
1349
1262
  export declare function process(source: string, config?: ProcessConfig | undefined | null): ProcessResult;
1350
1263
 
1351
1264
  /** The error a binding call throws for `Error`. */
1352
1265
  export interface ThrownError extends Error {
1353
- kind: "LanguageNotFound" | "DynamicLoad" | "NullLanguagePointer" | "ParserSetup" | "LockPoisoned" | "Config" | "ParseFailed" | "ParseTimeout" | "QueryError" | "InvalidRange" | "Download" | "ChecksumMismatch" | "CacheLock" | "AcquisitionTimeout" | "CacheMiss" | "Unknown"
1266
+ kind: "LanguageNotFound" | "DynamicLoad" | "NullLanguagePointer" | "ParserSetup" | "LockPoisoned" | "Config" | "ParseFailed" | "ParseTimeout" | "QueryError" | "InvalidRange" | "Download" | "ChecksumMismatch" | "CacheLock" | "AcquisitionTimeout" | "CacheMiss" | "UntrustedBundle" | "UntrustedLibrary" | "Unknown"
1354
1267
  errorCode: number
1355
1268
  }
package/index.js CHANGED
@@ -68,7 +68,6 @@ const tryLoadBinding = () => {
68
68
  "./ts-pack-core-node.linux-arm64-musl.node",
69
69
  "@xberg-io/tree-sitter-language-pack-linux-arm64-musl",
70
70
  ],
71
- ["darwin", "x64", null, "./ts-pack-core-node.darwin-x64.node", "@xberg-io/tree-sitter-language-pack-darwin-x64"],
72
71
  [
73
72
  "darwin",
74
73
  "arm64",
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // DO NOT EDIT - auto-generated by alef
2
- // alef:hash:d5510802e606885e74c75a3efc9c588faf546d2badeeda9ab7528d41bb6004bd
2
+ // alef:hash:310c956e208f28e2ab62112b8c6aa5ac5253a4813c6f6d51fb537602b998d24b
3
3
  import binding from "./index.js";
4
4
 
5
5
  export const CommentKind = binding.CommentKind;
@@ -7,49 +7,39 @@ export const DataNodeKind = binding.DataNodeKind;
7
7
  export const DiagnosticSeverity = binding.DiagnosticSeverity;
8
8
  export const DownloadManager = binding.DownloadManager;
9
9
  export const ExportKind = binding.ExportKind;
10
+ export const Feature = binding.Feature;
10
11
  export const JsCommentKind = binding.JsCommentKind;
11
12
  export const JsDataNodeKind = binding.JsDataNodeKind;
12
13
  export const JsDiagnosticSeverity = binding.JsDiagnosticSeverity;
13
14
  export const JsDownloadManager = binding.JsDownloadManager;
14
15
  export const JsExportKind = binding.JsExportKind;
15
- export const JsLanguageRegistry = binding.JsLanguageRegistry;
16
+ export const JsFeature = binding.JsFeature;
16
17
  export const JsNode = binding.JsNode;
18
+ export const JsPack = binding.JsPack;
17
19
  export const JsParser = binding.JsParser;
18
20
  export const JsTree = binding.JsTree;
19
21
  export const JsTreeCursor = binding.JsTreeCursor;
20
- export const LanguageRegistry = binding.LanguageRegistry;
21
22
  export const Node = binding.Node;
23
+ export const Pack = binding.Pack;
22
24
  export const Parser = binding.Parser;
23
25
  export const Tree = binding.Tree;
24
26
  export const TreeCursor = binding.TreeCursor;
25
- export const availableLanguages = binding.availableLanguages;
26
- export const cacheDir = binding.cacheDir;
27
- export const cleanCache = binding.cleanCache;
28
- export const configure = binding.configure;
29
27
  export const detectLanguage = binding.detectLanguage;
30
28
  export const detectLanguageFromContent = binding.detectLanguageFromContent;
31
29
  export const detectLanguageFromExtension = binding.detectLanguageFromExtension;
32
30
  export const detectLanguageFromPath = binding.detectLanguageFromPath;
33
- export const download = binding.download;
34
- export const downloadAll = binding.downloadAll;
35
- export const downloadGroup = binding.downloadGroup;
36
- export const downloadedLanguages = binding.downloadedLanguages;
37
31
  export const getFoldsQuery = binding.getFoldsQuery;
38
32
  export const getHighlightsQuery = binding.getHighlightsQuery;
39
33
  export const getIndentsQuery = binding.getIndentsQuery;
40
34
  export const getInjectionsQuery = binding.getInjectionsQuery;
41
35
  export const getLanguage = binding.getLanguage;
42
- export const getLanguageCacheOnly = binding.getLanguageCacheOnly;
43
- export const getLanguageWithDeadline = binding.getLanguageWithDeadline;
44
36
  export const getLocalsQuery = binding.getLocalsQuery;
45
- export const getParser = binding.getParser;
46
37
  export const getTagsQuery = binding.getTagsQuery;
47
- export const hasLanguage = binding.hasLanguage;
48
- export const init = binding.init;
49
- export const languageCount = binding.languageCount;
38
+ export const languageSource = binding.languageSource;
39
+ export const languageSources = binding.languageSources;
50
40
  export const manifestGroups = binding.manifestGroups;
51
41
  export const manifestLanguages = binding.manifestLanguages;
52
- export const prefetch = binding.prefetch;
42
+ export const packWithConfig = binding.packWithConfig;
53
43
  export const process = binding.process;
54
44
  export const processConfigAll = binding.processConfigAll;
55
45
  export const processConfigDefault = binding.processConfigDefault;
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  }
11
11
  ],
12
12
  "name": "@xberg-io/tree-sitter-language-pack",
13
- "version": "1.29.0",
14
- "description": "Pre-compiled tree-sitter grammars for 371 programming languages",
13
+ "version": "2.0.0",
14
+ "description": "Pre-compiled tree-sitter grammars for 426 programming languages",
15
15
  "license": "MIT",
16
16
  "repository": {
17
17
  "type": "git",
@@ -35,14 +35,13 @@
35
35
  "*.node"
36
36
  ],
37
37
  "optionalDependencies": {
38
- "@xberg-io/tree-sitter-language-pack-darwin-arm64": "1.29.0",
39
- "@xberg-io/tree-sitter-language-pack-darwin-x64": "1.29.0",
40
- "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu": "1.29.0",
41
- "@xberg-io/tree-sitter-language-pack-linux-arm64-musl": "1.29.0",
42
- "@xberg-io/tree-sitter-language-pack-linux-x64-gnu": "1.29.0",
43
- "@xberg-io/tree-sitter-language-pack-linux-x64-musl": "1.29.0",
44
- "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc": "1.29.0",
45
- "@xberg-io/tree-sitter-language-pack-win32-x64-msvc": "1.29.0"
38
+ "@xberg-io/tree-sitter-language-pack-darwin-arm64": "2.0.0",
39
+ "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu": "2.0.0",
40
+ "@xberg-io/tree-sitter-language-pack-linux-arm64-musl": "2.0.0",
41
+ "@xberg-io/tree-sitter-language-pack-linux-x64-gnu": "2.0.0",
42
+ "@xberg-io/tree-sitter-language-pack-linux-x64-musl": "2.0.0",
43
+ "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc": "2.0.0",
44
+ "@xberg-io/tree-sitter-language-pack-win32-x64-msvc": "2.0.0"
46
45
  },
47
46
  "napi": {
48
47
  "packageName": "@xberg-io/tree-sitter-language-pack",
@@ -52,7 +51,6 @@
52
51
  "aarch64-unknown-linux-gnu",
53
52
  "x86_64-unknown-linux-musl",
54
53
  "aarch64-unknown-linux-musl",
55
- "x86_64-apple-darwin",
56
54
  "aarch64-apple-darwin",
57
55
  "x86_64-pc-windows-msvc",
58
56
  "aarch64-pc-windows-msvc"
Binary file
Binary file