@xberg-io/tree-sitter-language-pack 1.28.1 → 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:46317da62f751125dc0fe8a38f0b201bbf35ec47554bd8f9f2d7037855eb38e3
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,13 +84,12 @@ 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
 
@@ -209,16 +101,6 @@ export declare function getLanguage(name: string): Language;
209
101
  */
210
102
  export declare function getLocalsQuery(language: string): string | null;
211
103
 
212
- /**
213
- * Get a `Parser` pre-configured for the given language.
214
- *
215
- * This is a convenience function that calls `get_language` and configures
216
- * a new parser in one step.
217
- * @throws Returns `Error.LanguageNotFound` if the language is not recognized, or
218
- * `Error.ParserSetup` if the language cannot be applied to the parser.
219
- */
220
- export declare function getParser(name: string): Parser;
221
-
222
104
  /**
223
105
  * Get the tags query for a language, if bundled.
224
106
  *
@@ -227,24 +109,6 @@ export declare function getParser(name: string): Parser;
227
109
  */
228
110
  export declare function getTagsQuery(language: string): string | null;
229
111
 
230
- /**
231
- * Check if a language is available by name or alias.
232
- *
233
- * Returns `true` if the language can be loaded (statically compiled,
234
- * dynamically available, or a known alias for one of these).
235
- */
236
- export declare function hasLanguage(name: string): boolean;
237
-
238
- /**
239
- * Initialize the language pack with the given configuration.
240
- *
241
- * Applies any custom cache directory, then downloads all languages and groups
242
- * specified in the config. This is the recommended entry point when you want
243
- * to pre-warm the cache before use.
244
- * @throws Returns an error if configuration cannot be applied or if downloads fail.
245
- */
246
- export declare function init(config?: PackConfig | undefined | null): void;
247
-
248
112
  /** A byte range — start (inclusive) to end (exclusive). */
249
113
  export interface ByteRange {
250
114
  /** Inclusive start byte offset. */
@@ -504,7 +368,7 @@ export declare class DownloadManager {
504
368
  * Derived from the on-disk cache filenames, one canonical name per file, plus
505
369
  * every alias that resolves to it (via `aliases_for`) — so
506
370
  * this list agrees with the user-facing
507
- * `LanguageRegistry.available_languages`
371
+ * `Pack.available_languages`
508
372
  * about which names are "available"; both report `"shell"` once `bash` is
509
373
  * cached, for example. A previous version reported canonical names only,
510
374
  * which could never agree with `available_languages()`. See #107.
@@ -564,6 +428,32 @@ export declare enum ExportKind {
564
428
  ReExport = "ReExport",
565
429
  }
566
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
+
567
457
  /** Aggregate metrics for a source file. */
568
458
  export interface FileMetrics {
569
459
  /** Total number of lines (including blank and comment lines). */
@@ -584,6 +474,49 @@ export interface FileMetrics {
584
474
  readonly maxDepth?: number
585
475
  }
586
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
+
587
520
  /** An import statement extracted from source code. */
588
521
  export interface ImportInfo {
589
522
  /** The module or path being imported from. */
@@ -646,87 +579,6 @@ export interface InputEdit {
646
579
  readonly newEndPosition: Point
647
580
  }
648
581
 
649
- /**
650
- * Thread-safe registry of tree-sitter language parsers.
651
- *
652
- * Manages both statically compiled and dynamically loaded language grammars.
653
- * Use `LanguageRegistry.new()` for the default registry, or access the
654
- * global instance via the module-level convenience functions
655
- * (`get_language`, `available_languages`, etc.).
656
- */
657
- export declare class LanguageRegistry {
658
- /**
659
- * Create a new registry populated with all statically compiled languages.
660
- *
661
- * When the `dynamic-loading` feature is enabled, the registry also knows
662
- * about dynamically loadable grammars and will load them on demand.
663
- */
664
- static new(): LanguageRegistry
665
- /**
666
- * List all available language names, sorted and deduplicated.
667
- *
668
- * Includes statically compiled languages, dynamically loadable languages
669
- * (if the `dynamic-loading` feature is enabled), and all configured aliases.
670
- */
671
- availableLanguages(): Array<string>
672
- /**
673
- * Check whether this language can be parsed right now, without downloading.
674
- *
675
- * Resolves aliases, then answers from exactly the lookup
676
- * `get_language` performs: the statically compiled
677
- * table, the already-loaded dynamic grammars, and the parser shared
678
- * libraries present in the primary and extra (download-cache) library
679
- * directories. It never performs network I/O.
680
- *
681
- * A previous implementation consulted only the statically compiled table.
682
- * That table is empty in every build that does not set `TSLP_LANGUAGES`,
683
- * so the function answered `false` for languages this registry parses
684
- * perfectly well.
685
- *
686
- * Contrast `has_language`, which is also `true` for a
687
- * grammar that is merely *known to the manifest* and would have to be
688
- * downloaded first. The pair distinguishes "we can parse it offline, now"
689
- * from "we recognise the name".
690
- *
691
- * The first `true` answer for a dynamic grammar loads its shared library:
692
- * loading is the only way to know the grammar is usable, since a truncated
693
- * or wrong-architecture library exists on disk but cannot parse. Loads are
694
- * cached process-wide, so repeat calls are cheap.
695
- */
696
- hasParser(name: string): boolean
697
- /**
698
- * Check whether a language is available by name or alias.
699
- *
700
- * Returns `true` if the language can be loaded, either from the static
701
- * table or from a dynamic library on disk.
702
- *
703
- * Every branch is one more way to answer `true`, so they are ordered
704
- * cheapest-first and the filesystem is only consulted once every in-memory
705
- * source has said no. Probing the loaded-grammar map and the manifest ahead
706
- * of the `stat` calls is what keeps this off the syscall path for the
707
- * languages a process actually uses.
708
- */
709
- hasLanguage(name: string): boolean
710
- /**
711
- * Return the total number of available languages (including aliases).
712
- *
713
- * Counts the same set `available_languages`
714
- * lists, without materialising or sorting it.
715
- */
716
- languageCount(): number
717
- /**
718
- * Parse source code and extract file intelligence based on config in a single pass.
719
- * @throws Returns `Error.InvalidRange` if the config is invalid (see
720
- * `ProcessConfig.validate`) or if the source
721
- * exceeds the configured
722
- * `max_source_bytes`;
723
- * `Error.LanguageNotFound` if the language is unknown; or
724
- * `Error.ParseFailed` if parsing produces no tree.
725
- */
726
- process(source: string, config?: ProcessConfig | undefined | null): ProcessResult
727
- static default(): LanguageRegistry
728
- }
729
-
730
582
  /**
731
583
  * A single syntax node within a `Tree`.
732
584
  *
@@ -787,11 +639,129 @@ export declare class Node {
787
639
  walk(): TreeCursor
788
640
  }
789
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
+
790
760
  /**
791
761
  * Configuration for the tree-sitter language pack.
792
762
  *
793
- * Controls cache directory and which languages to pre-download.
794
- * 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,
795
765
  * or passed as a dict/object from language bindings.
796
766
  */
797
767
  export interface PackConfig {
@@ -813,18 +783,21 @@ export interface PackConfig {
813
783
  */
814
784
  readonly cacheDir?: string
815
785
  /**
816
- * Languages to pre-download on init.
786
+ * Languages a caller can pre-download with `Pack.prefetch`.
817
787
  *
818
- * 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.
819
791
  */
820
792
  readonly languages?: Array<string>
821
793
  /**
822
- * Language groups to pre-download.
794
+ * Language groups a caller can pre-download with
795
+ * `Pack.download_group`.
823
796
  *
824
797
  * Group names come from the remote manifest, so the valid set is not fixed
825
798
  * by this crate; the published manifest currently defines only `"all"`.
826
- * Call `manifest_groups` to enumerate them.
827
- * An unknown name makes `init` fail.
799
+ * Call `Pack.manifest_groups` to enumerate
800
+ * them. An unknown name makes `download_group` fail.
828
801
  */
829
802
  readonly groups?: Array<string>
830
803
  }
@@ -863,8 +836,10 @@ export declare class Parser {
863
836
  /**
864
837
  * Configure the parser to use the language identified by name (e.g. `"python"`).
865
838
  *
866
- * Resolves the language through the global registry — auto-downloading
867
- * 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.
868
843
  * @throws Returns `Error.LanguageNotFound` if the language is not recognized,
869
844
  * or `Error.ParserSetup` if the language ABI is incompatible.
870
845
  */
@@ -932,28 +907,18 @@ export interface Point {
932
907
  readonly column: number
933
908
  }
934
909
 
935
- /**
936
- * Configuration for the `process()` function.
937
- *
938
- * Controls which analysis features are enabled and whether chunking is performed.
939
- */
910
+ /** Configuration for `process`. */
940
911
  export interface ProcessConfig {
941
912
  /** Language name (required). */
942
913
  readonly language?: string
943
- /** Extract structural items (functions, classes, etc.). Default: true. */
944
- readonly structure?: boolean
945
- /** Extract import statements. Default: true. */
946
- readonly imports?: boolean
947
- /** Extract export statements. Default: true. */
948
- readonly exports?: boolean
949
- /** Extract comments. Default: false. */
950
- readonly comments?: boolean
951
- /** Extract docstrings. Default: false. */
952
- readonly docstrings?: boolean
953
- /** Extract symbol definitions. Default: false. */
954
- readonly symbols?: boolean
955
- /** Include parse diagnostics. Default: false. */
956
- 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>
957
922
  /**
958
923
  * Maximum chunk size in bytes. `None` disables chunking.
959
924
  *
@@ -963,17 +928,6 @@ export interface ProcessConfig {
963
928
  * whole source; use `None` to mean "do not chunk".
964
929
  */
965
930
  readonly chunkMaxSize?: number
966
- /**
967
- * Extract hierarchical key/value data tree from data-format files. Default: false.
968
- *
969
- * When `true`, `ProcessResult.data` is populated
970
- * with a `DataNode` tree for supported languages: JSON, YAML,
971
- * TOML, `.properties`, HCL/HOCON, INI, editorconfig, KDL, CUE, CSV, PSV, PO,
972
- * nginx config, Caddy config, XML, and DTD.
973
- *
974
- * For languages outside this set the field is left as `None`.
975
- */
976
- readonly dataExtraction?: boolean
977
931
  /**
978
932
  * Reject source longer than this many bytes instead of parsing it.
979
933
  * Default: `None` (unbounded).
@@ -1006,19 +960,20 @@ export interface ProcessConfig {
1006
960
  *
1007
961
  * Contains metrics, structural analysis, imports/exports, comments,
1008
962
  * docstrings, symbols, diagnostics, and optionally chunked code segments.
1009
- * Fields are populated based on the `ProcessConfig` flags.
963
+ * Fields are populated based on the `Feature` values in
964
+ * `features`.
1010
965
  *
1011
966
  * # Fields
1012
967
  *
1013
968
  * - `language` - The language used for parsing
1014
969
  * - `metrics` - Always computed: line counts, byte sizes, error counts
1015
- * - `structure` - Functions, classes, structs (when `config.structure = true`)
1016
- * - `imports` - Import statements (when `config.imports = true`)
1017
- * - `exports` - Export statements (when `config.exports = true`)
1018
- * - `comments` - Comments (when `config.comments = true`)
1019
- * - `docstrings` - Docstrings (when `config.docstrings = true`)
1020
- * - `symbols` - Symbol definitions (when `config.symbols = true`)
1021
- * - `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`)
1022
977
  * - `chunks` - Chunked code segments (when `config.chunk_max_size` is set)
1023
978
  */
1024
979
  export interface ProcessResult {
@@ -1253,63 +1208,61 @@ export declare class TreeCursor {
1253
1208
  }
1254
1209
 
1255
1210
  /**
1256
- * Return the number of available languages.
1211
+ * Return the embedded grammar identity for a language.
1257
1212
  *
1258
- * Includes statically compiled languages, dynamically loadable languages,
1259
- * 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.
1260
1218
  */
1261
- 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>;
1262
1223
 
1263
1224
  /**
1264
1225
  * Return the names of every language group the remote manifest defines, sorted.
1265
1226
  *
1266
- * Group names are manifest data, not a compile-time constant of this crate, so
1267
- * this is the only reliable way to learn what `download_group` and
1268
- * `PackConfig.groups` accept. The published manifest currently defines just
1269
- * `"all"`.
1227
+ * Delegates to a default `Pack`; use `Pack.manifest_groups` to respect a
1228
+ * custom cache directory.
1270
1229
  * @throws Returns `Error.Download` if the manifest cannot be fetched.
1271
1230
  */
1272
1231
  export declare function manifestGroups(): Array<string>;
1273
1232
 
1274
1233
  /**
1275
- * Return all language names available in the remote manifest (371).
1234
+ * Return all language names available in the remote manifest (426).
1276
1235
  *
1277
- * Fetches (and caches) the remote manifest to discover the full list of
1278
- * downloadable languages. Use `downloaded_languages` to list what is
1279
- * already cached locally.
1236
+ * Delegates to a default `Pack`; use `Pack.manifest_languages` to respect a
1237
+ * custom cache directory.
1280
1238
  * @throws Returns an error if the manifest cannot be fetched.
1281
1239
  */
1282
1240
  export declare function manifestLanguages(): Array<string>;
1283
1241
 
1284
1242
  /**
1285
- * Prefetch grammars: download any not already loadable from disk, then load every
1286
- * requested language into the process registry so a subsequent hot loop only parses.
1243
+ * Build a `Pack` from an explicit `PackConfig`.
1287
1244
  *
1288
- * Unlike `download()`, this does not trust in-memory availability — it downloads
1289
- * whenever a grammar is not actually loadable from disk (fixing the case where a
1290
- * known-but-not-downloaded grammar is reported present), then resolves and caches
1291
- * every requested language. Call it once, up front, before a parallel workload.
1292
- * @throws Returns `Error.Download` if a required grammar cannot be fetched, or
1293
- * `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.
1294
1250
  */
1295
- export declare function prefetch(languages: Array<string>): void;
1251
+ export declare function packWithConfig(config?: PackConfig | undefined | null): Pack;
1296
1252
 
1297
1253
  /**
1298
- * Process source code and extract file intelligence using the global registry.
1254
+ * Process source code with a default `Pack`.
1299
1255
  *
1300
- * Parses the source with tree-sitter and extracts metrics, structure, imports,
1301
- * exports, comments, docstrings, symbols, diagnostics, and/or chunks based on
1302
- * the flags set in `ProcessConfig`.
1303
- * @throws Returns `Error.InvalidRange` if the config carries a zero-valued limit or
1304
- * the source exceeds `ProcessConfig.max_source_bytes`,
1305
- * `Error.ParseTimeout` if the parse exceeds
1306
- * `ProcessConfig.parse_timeout_ms`, `Error.LanguageNotFound` if the
1307
- * 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.
1308
1261
  */
1309
1262
  export declare function process(source: string, config?: ProcessConfig | undefined | null): ProcessResult;
1310
1263
 
1311
1264
  /** The error a binding call throws for `Error`. */
1312
1265
  export interface ThrownError extends Error {
1313
- kind: "LanguageNotFound" | "DynamicLoad" | "NullLanguagePointer" | "ParserSetup" | "LockPoisoned" | "Config" | "ParseFailed" | "ParseTimeout" | "QueryError" | "InvalidRange" | "Download" | "ChecksumMismatch" | "CacheLock" | "Unknown"
1266
+ kind: "LanguageNotFound" | "DynamicLoad" | "NullLanguagePointer" | "ParserSetup" | "LockPoisoned" | "Config" | "ParseFailed" | "ParseTimeout" | "QueryError" | "InvalidRange" | "Download" | "ChecksumMismatch" | "CacheLock" | "AcquisitionTimeout" | "CacheMiss" | "UntrustedBundle" | "UntrustedLibrary" | "Unknown"
1314
1267
  errorCode: number
1315
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:3c195c58900cbcbebad357df3c3152b5c6da421696e61d0dfc14d2b06d4e06b7
2
+ // alef:hash:310c956e208f28e2ab62112b8c6aa5ac5253a4813c6f6d51fb537602b998d24b
3
3
  import binding from "./index.js";
4
4
 
5
5
  export const CommentKind = binding.CommentKind;
@@ -7,47 +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
36
  export const getLocalsQuery = binding.getLocalsQuery;
43
- export const getParser = binding.getParser;
44
37
  export const getTagsQuery = binding.getTagsQuery;
45
- export const hasLanguage = binding.hasLanguage;
46
- export const init = binding.init;
47
- export const languageCount = binding.languageCount;
38
+ export const languageSource = binding.languageSource;
39
+ export const languageSources = binding.languageSources;
48
40
  export const manifestGroups = binding.manifestGroups;
49
41
  export const manifestLanguages = binding.manifestLanguages;
50
- export const prefetch = binding.prefetch;
42
+ export const packWithConfig = binding.packWithConfig;
51
43
  export const process = binding.process;
52
44
  export const processConfigAll = binding.processConfigAll;
53
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.28.1",
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.28.1",
39
- "@xberg-io/tree-sitter-language-pack-darwin-x64": "1.28.1",
40
- "@xberg-io/tree-sitter-language-pack-linux-arm64-gnu": "1.28.1",
41
- "@xberg-io/tree-sitter-language-pack-linux-arm64-musl": "1.28.1",
42
- "@xberg-io/tree-sitter-language-pack-linux-x64-gnu": "1.28.1",
43
- "@xberg-io/tree-sitter-language-pack-linux-x64-musl": "1.28.1",
44
- "@xberg-io/tree-sitter-language-pack-win32-arm64-msvc": "1.28.1",
45
- "@xberg-io/tree-sitter-language-pack-win32-x64-msvc": "1.28.1"
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