gitnexus 1.6.11 → 1.6.12-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/optional-grammars.d.ts +7 -8
  3. package/dist/cli/optional-grammars.js +9 -19
  4. package/dist/core/ingestion/languages/zig/query.js +7 -8
  5. package/dist/core/ingestion/workers/parse-worker.js +2 -5
  6. package/dist/core/tree-sitter/parser-loader.js +4 -12
  7. package/dist/core/tree-sitter/vendored-grammars.d.ts +1 -1
  8. package/dist/core/tree-sitter/vendored-grammars.js +2 -1
  9. package/package.json +1 -5
  10. package/scripts/build-tree-sitter-grammars.cjs +2 -1
  11. package/vendor/tree-sitter-zig/LICENSE +21 -0
  12. package/vendor/tree-sitter-zig/README.md +25 -0
  13. package/vendor/tree-sitter-zig/binding.gyp +29 -0
  14. package/vendor/tree-sitter-zig/bindings/node/binding.cc +20 -0
  15. package/vendor/tree-sitter-zig/bindings/node/index.d.ts +28 -0
  16. package/vendor/tree-sitter-zig/bindings/node/index.js +11 -0
  17. package/vendor/tree-sitter-zig/grammar.js +900 -0
  18. package/vendor/tree-sitter-zig/package.json +18 -0
  19. package/vendor/tree-sitter-zig/prebuilds/SHA256SUMS +6 -0
  20. package/vendor/tree-sitter-zig/prebuilds/darwin-arm64/tree-sitter-zig.node +0 -0
  21. package/vendor/tree-sitter-zig/prebuilds/darwin-x64/tree-sitter-zig.node +0 -0
  22. package/vendor/tree-sitter-zig/prebuilds/linux-arm64/tree-sitter-zig.node +0 -0
  23. package/vendor/tree-sitter-zig/prebuilds/linux-x64/tree-sitter-zig.node +0 -0
  24. package/vendor/tree-sitter-zig/prebuilds/win32-arm64/tree-sitter-zig.node +0 -0
  25. package/vendor/tree-sitter-zig/prebuilds/win32-x64/tree-sitter-zig.node +0 -0
  26. package/vendor/tree-sitter-zig/src/grammar.json +6570 -0
  27. package/vendor/tree-sitter-zig/src/node-types.json +3178 -0
  28. package/vendor/tree-sitter-zig/src/parser.c +169829 -0
  29. package/vendor/tree-sitter-zig/src/tree_sitter/alloc.h +54 -0
  30. package/vendor/tree-sitter-zig/src/tree_sitter/array.h +291 -0
  31. package/vendor/tree-sitter-zig/src/tree_sitter/parser.h +266 -0
package/README.md CHANGED
@@ -631,7 +631,7 @@ results until you re-run `gitnexus analyze --repair-fts` from a shell where the
631
631
 
632
632
  ### Installation fails with native module errors
633
633
 
634
- Some optional language grammars (Dart, Proto, Swift, Kotlin) require native compilation. If they fail, GitNexus still works — those languages will be skipped. To skip them intentionally (no C++ toolchain needed), set `GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1` before installing. Zig (`@tree-sitter-grammars/tree-sitter-zig`, an npm `optionalDependency`) behaves the same way: if its native binding fails to install, `.zig` files are skipped.
634
+ Some optional language grammars (Dart, Proto, Swift, Kotlin, Zig) ship vendored native prebuilds. If a prebuild is missing and a source build is not possible, GitNexus still works — those languages will be skipped. To skip them intentionally (no C++ toolchain needed), set `GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1` before installing.
635
635
 
636
636
  If `npm install -g gitnexus` fails on native modules:
637
637
 
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * Optional grammar availability check.
3
3
  *
4
- * tree-sitter-dart, -proto, -swift, and -kotlin are vendored under vendor/ and
5
- * loaded from there by absolute path (NEVER copied into node_modules — see
6
- * core/tree-sitter/vendored-grammars.ts / #2111). Each ships committed platform
7
- * prebuilds activated via node-gyp-build. All can be skipped via
8
- * GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1 (postinstall scripts), or can silently
9
- * soft-fail when no prebuild matches the host platform (and a source build was
10
- * unavailable / not attempted). tree-sitter-zig is the one npm-installed
11
- * optionalDependency in the list; its `probe` overrides the vendored load.
4
+ * tree-sitter-dart, -proto, -swift, -kotlin, and -zig are vendored under
5
+ * vendor/ and loaded from there by absolute path (NEVER copied into
6
+ * node_modules — see core/tree-sitter/vendored-grammars.ts / #2111). Each
7
+ * ships committed platform prebuilds activated via node-gyp-build. All can
8
+ * be skipped via GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1 (postinstall scripts), or
9
+ * can silently soft-fail when no prebuild matches the host platform (and a
10
+ * source build was unavailable / not attempted).
12
11
  *
13
12
  * Either path produces the same observable: the .node binding is absent
14
13
  * at runtime. This helper detects that condition and surfaces a single
@@ -1,26 +1,23 @@
1
1
  /**
2
2
  * Optional grammar availability check.
3
3
  *
4
- * tree-sitter-dart, -proto, -swift, and -kotlin are vendored under vendor/ and
5
- * loaded from there by absolute path (NEVER copied into node_modules — see
6
- * core/tree-sitter/vendored-grammars.ts / #2111). Each ships committed platform
7
- * prebuilds activated via node-gyp-build. All can be skipped via
8
- * GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1 (postinstall scripts), or can silently
9
- * soft-fail when no prebuild matches the host platform (and a source build was
10
- * unavailable / not attempted). tree-sitter-zig is the one npm-installed
11
- * optionalDependency in the list; its `probe` overrides the vendored load.
4
+ * tree-sitter-dart, -proto, -swift, -kotlin, and -zig are vendored under
5
+ * vendor/ and loaded from there by absolute path (NEVER copied into
6
+ * node_modules — see core/tree-sitter/vendored-grammars.ts / #2111). Each
7
+ * ships committed platform prebuilds activated via node-gyp-build. All can
8
+ * be skipped via GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1 (postinstall scripts), or
9
+ * can silently soft-fail when no prebuild matches the host platform (and a
10
+ * source build was unavailable / not attempted).
12
11
  *
13
12
  * Either path produces the same observable: the .node binding is absent
14
13
  * at runtime. This helper detects that condition and surfaces a single
15
14
  * stderr line per missing grammar so users learn why .dart/.proto/.swift/.kt/.zig
16
15
  * support is unavailable instead of silently getting a degraded index.
17
16
  */
18
- import { createRequire } from 'node:module';
19
17
  import { SupportedLanguages } from '../_shared/index.js';
20
18
  import { isGrammarRuntimeSkipped } from '../core/tree-sitter/parser-loader.js';
21
19
  import { requireVendoredGrammar } from '../core/tree-sitter/vendored-grammars.js';
22
20
  import { cliWarn } from './cli-message.js';
23
- const _require = createRequire(import.meta.url);
24
21
  const OPTIONAL_GRAMMARS = [
25
22
  {
26
23
  name: 'tree-sitter-dart',
@@ -43,11 +40,9 @@ const OPTIONAL_GRAMMARS = [
43
40
  },
44
41
  {
45
42
  name: 'tree-sitter-zig',
46
- pkg: '@tree-sitter-grammars/tree-sitter-zig',
43
+ pkg: 'tree-sitter-zig',
47
44
  extensions: ['.zig'],
48
45
  language: SupportedLanguages.Zig,
49
- // npm optionalDependency, not vendored — probe via plain require.
50
- probe: () => _require('@tree-sitter-grammars/tree-sitter-zig'),
51
46
  },
52
47
  ];
53
48
  /**
@@ -84,12 +79,7 @@ export function detectMissingOptionalGrammars() {
84
79
  continue;
85
80
  }
86
81
  try {
87
- if (g.probe !== undefined) {
88
- g.probe();
89
- }
90
- else {
91
- requireVendoredGrammar(g.pkg);
92
- }
82
+ requireVendoredGrammar(g.pkg);
93
83
  }
94
84
  catch (err) {
95
85
  const code = err?.code;
@@ -1,14 +1,13 @@
1
1
  import Parser from 'tree-sitter';
2
- import { createRequire } from 'node:module';
3
- const _require = createRequire(import.meta.url);
2
+ import { requireVendoredGrammar } from '../../../tree-sitter/vendored-grammars.js';
4
3
  /**
5
4
  * Zig scope-resolution query (RFC #909 Ring 3).
6
5
  *
7
- * The grammar is an optionalDependency (`@tree-sitter-grammars/tree-sitter-zig`),
8
- * so the language module is required lazily and `getZigParser` /
9
- * `getZigScopeQuery` throw only when actually invoked without the grammar
10
- * installed. That is safe: the parse pipeline filters `.zig` files through
11
- * `parser-loader.isLanguageAvailable` before any scope extraction runs.
6
+ * The grammar is vendored (`vendor/tree-sitter-zig`) and may be absent on a
7
+ * platform without a prebuild, so the language module is required lazily and
8
+ * `getZigParser` / `getZigScopeQuery` throw only when actually invoked without
9
+ * the grammar installed. That is safe: the parse pipeline filters `.zig` files
10
+ * through `parser-loader.isLanguageAvailable` before any scope extraction runs.
12
11
  *
13
12
  * Zig specifics encoded here:
14
13
  * - Containers (struct/enum/union/opaque) are anonymous nodes bound by the
@@ -409,7 +408,7 @@ const ZIG_SCOPE_QUERY = `
409
408
  let _parser = null;
410
409
  let _query = null;
411
410
  function getZigLanguage() {
412
- return _require('@tree-sitter-grammars/tree-sitter-zig');
411
+ return requireVendoredGrammar('tree-sitter-zig');
413
412
  }
414
413
  export function getZigParser() {
415
414
  if (_parser === null) {
@@ -1,5 +1,4 @@
1
1
  import { parentPort, threadId, workerData } from 'node:worker_threads';
2
- import { createRequire } from 'node:module';
3
2
  import { boundCallableStartPosition, localIdentity, nestedCallableQualifiedName, positionQualifiedCallableName, } from './callable-id.js';
4
3
  import Parser from 'tree-sitter';
5
4
  import JavaScript from 'tree-sitter-javascript';
@@ -34,7 +33,7 @@ import { mergeResult } from './result-merge.js';
34
33
  // `isLanguageAvailable` must re-introduce the gate here. (The cleaner end-state
35
34
  // — routing this table through `parser-loader.getLanguageGrammar` so there is
36
35
  // one loader — is the deferred Tier-1 consolidation.)
37
- // Swift/Dart/Kotlin/C are vendored grammars loaded from `vendor/` by absolute
36
+ // Swift/Dart/Kotlin/C/Zig are vendored grammars loaded from `vendor/` by absolute
38
37
  // path (NEVER copied into node_modules — see vendored-grammars.ts / #2111). Each
39
38
  // may be absent on a platform without a prebuild or a toolchain-less /
40
39
  // `--ignore-scripts` install, so every load is guarded so a missing binding
@@ -59,11 +58,9 @@ try {
59
58
  C = requireVendoredGrammar('tree-sitter-c');
60
59
  }
61
60
  catch { }
62
- // @tree-sitter-grammars/tree-sitter-zig is an optionalDependency — may not be installed
63
- const _require = createRequire(import.meta.url);
64
61
  let Zig = null;
65
62
  try {
66
- Zig = _require('@tree-sitter-grammars/tree-sitter-zig');
63
+ Zig = requireVendoredGrammar('tree-sitter-zig');
67
64
  }
68
65
  catch { }
69
66
  import { getLanguageFromFilename } from '../../../_shared/index.js';
@@ -112,21 +112,13 @@ const SOURCES = {
112
112
  'Likely cause: no prebuilt `.node` for this platform/architecture. ' +
113
113
  `See ${ISSUES_URL}/2107.`,
114
114
  },
115
- // Zig grammar declares peerOptional `tree-sitter@^0.22.1` but its native
116
- // binding is ABI-compatible with the bundled `tree-sitter@0.21.x` runtime
117
- // (verified by load-time smoke test). The peer-dep mismatch is suppressed
118
- // via the `overrides` block in package.json. Listed as `optional: true`
119
- // because the package is in `optionalDependencies` — users on platforms
120
- // without a prebuild may not have it — and `userSkippable` because it is
121
- // a genuinely-optional grammar: `GITNEXUS_SKIP_OPTIONAL_GRAMMARS` must be
122
- // able to disable it at analyze time like swift/dart/kotlin.
123
115
  [SupportedLanguages.Zig]: {
124
- load: () => _require('@tree-sitter-grammars/tree-sitter-zig'),
116
+ load: () => requireVendoredGrammar('tree-sitter-zig'),
125
117
  optional: true,
126
118
  userSkippable: true,
127
- unavailableNote: 'Zig parsing disabled: `@tree-sitter-grammars/tree-sitter-zig` is an ' +
128
- 'optionalDependency and is not installed (or its native binding failed ' +
129
- 'to load on this platform).',
119
+ unavailableNote: 'Zig parsing disabled: vendored `tree-sitter-zig` (under ' +
120
+ '`gitnexus/vendor/tree-sitter-zig`) failed to load. ' +
121
+ 'Likely cause: no prebuilt `.node` for this platform/architecture.',
130
122
  },
131
123
  };
132
124
  export const listGrammarSources = () => Object.entries(SOURCES).map(([key, source]) => ({
@@ -20,7 +20,7 @@ export declare const vendoredGrammarDir: (packageName: string) => string;
20
20
  /**
21
21
  * Load a vendored tree-sitter grammar by its absolute path under `vendor/`.
22
22
  *
23
- * GitNexus vendors five grammars (c/dart/proto/swift/kotlin) inside its own
23
+ * GitNexus vendors six grammars (c/dart/proto/swift/kotlin/zig) inside its own
24
24
  * package under `vendor/`, each shipping committed per-platform prebuilds. They
25
25
  * are deliberately NOT npm dependencies and must NEVER be copied into
26
26
  * `node_modules`: an undeclared package under `node_modules` is "extraneous" to
@@ -24,13 +24,14 @@ export const VENDORED_GRAMMAR_PACKAGES = new Set([
24
24
  'tree-sitter-proto',
25
25
  'tree-sitter-swift',
26
26
  'tree-sitter-kotlin',
27
+ 'tree-sitter-zig',
27
28
  ]);
28
29
  /** Absolute directory of a vendored grammar package under `vendor/`. */
29
30
  export const vendoredGrammarDir = (packageName) => path.join(VENDOR_ROOT, packageName);
30
31
  /**
31
32
  * Load a vendored tree-sitter grammar by its absolute path under `vendor/`.
32
33
  *
33
- * GitNexus vendors five grammars (c/dart/proto/swift/kotlin) inside its own
34
+ * GitNexus vendors six grammars (c/dart/proto/swift/kotlin/zig) inside its own
34
35
  * package under `vendor/`, each shipping committed per-platform prebuilds. They
35
36
  * are deliberately NOT npm dependencies and must NEVER be copied into
36
37
  * `node_modules`: an undeclared package under `node_modules` is "extraneous" to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.11",
3
+ "version": "1.6.12-rc.2",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",
@@ -99,7 +99,6 @@
99
99
  },
100
100
  "optionalDependencies": {
101
101
  "@huggingface/transformers": "^4.1.0",
102
- "@tree-sitter-grammars/tree-sitter-zig": "1.1.2",
103
102
  "onnxruntime-node": "^1.24.0"
104
103
  },
105
104
  "trustedDependencies": [
@@ -129,9 +128,6 @@
129
128
  "sharp": ">=0.35.0",
130
129
  "@huggingface/transformers": {
131
130
  "onnxruntime-node": "$onnxruntime-node"
132
- },
133
- "@tree-sitter-grammars/tree-sitter-zig": {
134
- "tree-sitter": "$tree-sitter"
135
131
  }
136
132
  },
137
133
  "engines": {
@@ -4,7 +4,7 @@
4
4
  * One registry-driven script replaces the former per-grammar
5
5
  * build-tree-sitter-<name>.cjs files (they were ~95% identical).
6
6
  *
7
- * The grammars (tree-sitter-c/dart/proto/swift/kotlin) are loaded from
7
+ * The grammars (tree-sitter-c/dart/proto/swift/kotlin/zig) are loaded from
8
8
  * `vendor/<name>/` by absolute path at runtime (see
9
9
  * src/core/tree-sitter/vendored-grammars.ts) and are NEVER copied into
10
10
  * node_modules — an undeclared package under node_modules is "extraneous" to
@@ -44,6 +44,7 @@ const GRAMMARS = {
44
44
  proto: { required: false, display: 'Proto', ext: '.proto' },
45
45
  swift: { required: false, display: 'Swift', ext: '.swift' },
46
46
  kotlin: { required: false, display: 'Kotlin', ext: '.kt/.kts' },
47
+ zig: { required: false, display: 'Zig', ext: '.zig' },
47
48
  };
48
49
 
49
50
  const skipOptional = process.env.GITNEXUS_SKIP_OPTIONAL_GRAMMARS === '1';
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Amaan Qureshi <amaanq12@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ ## GitNexus vendor notice
2
+
3
+ This directory is a GitNexus-managed vendored copy of
4
+ `@tree-sitter-grammars/tree-sitter-zig@1.1.2`. GitNexus keeps the top-level
5
+ `tree-sitter` dependency pinned to `0.21.1` until the broader parser runtime
6
+ upgrade is handled separately (#858). The upstream package declares
7
+ `peerOptional tree-sitter@^0.22.1`; that peer is ABI-compatible with 0.21.x
8
+ but npm still warns on `npm i -g gitnexus` because a published package's
9
+ `overrides` are ignored by dependents.
10
+
11
+ Unified with the Dart/Proto/Kotlin/Swift/C vendored grammars, this copy
12
+ vendors the grammar **source** — `binding.gyp`, `bindings/node/binding.cc`,
13
+ `src/parser.c` (ABI 14), and `src/tree_sitter/` — so
14
+ `gitnexus/scripts/build-tree-sitter-grammars.cjs` can source-build the native
15
+ binding on a toolchain host when no committed prebuild matches. The native
16
+ `prebuilds/` are loaded in place by `node-gyp-build`. Upstream's published
17
+ `linux-arm64` `.node` is a mispackaged x86-64 binary and is not shipped;
18
+ `.github/workflows/build-tree-sitter-prebuilds.yml` rebuilds all six tuples.
19
+
20
+ When updating this vendor package, replace it from the official
21
+ `@tree-sitter-grammars/tree-sitter-zig` npm release: refresh
22
+ `src/parser.c`/`src/tree_sitter/`/`binding.gyp`/`bindings/node/`, bump
23
+ `version` in `package.json` to retrigger the prebuild workflow, update the
24
+ `_vendoredBy` provenance, and verify the packed GitNexus tarball can both
25
+ load a committed prebuild and source-build `tree-sitter-zig`.
@@ -0,0 +1,29 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_zig_binding",
5
+ "dependencies": [
6
+ "<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
7
+ ],
8
+ "include_dirs": [
9
+ "src",
10
+ ],
11
+ "sources": [
12
+ "bindings/node/binding.cc",
13
+ "src/parser.c",
14
+ ],
15
+ "conditions": [
16
+ ["OS!='win'", {
17
+ "cflags_c": [
18
+ "-std=c11",
19
+ ],
20
+ }, { # OS == "win"
21
+ "cflags_c": [
22
+ "/std:c11",
23
+ "/utf-8",
24
+ ],
25
+ }],
26
+ ],
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,20 @@
1
+ #include <napi.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ extern "C" TSLanguage *tree_sitter_zig();
6
+
7
+ // "tree-sitter", "language" hashed with BLAKE2
8
+ const napi_type_tag LANGUAGE_TYPE_TAG = {
9
+ 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
10
+ };
11
+
12
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
13
+ exports["name"] = Napi::String::New(env, "zig");
14
+ auto language = Napi::External<TSLanguage>::New(env, tree_sitter_zig());
15
+ language.TypeTag(&LANGUAGE_TYPE_TAG);
16
+ exports["language"] = language;
17
+ return exports;
18
+ }
19
+
20
+ NODE_API_MODULE(tree_sitter_zig_binding, Init)
@@ -0,0 +1,28 @@
1
+ type BaseNode = {
2
+ type: string;
3
+ named: boolean;
4
+ };
5
+
6
+ type ChildNode = {
7
+ multiple: boolean;
8
+ required: boolean;
9
+ types: BaseNode[];
10
+ };
11
+
12
+ type NodeInfo =
13
+ | (BaseNode & {
14
+ subtypes: BaseNode[];
15
+ })
16
+ | (BaseNode & {
17
+ fields: { [name: string]: ChildNode };
18
+ children?: ChildNode;
19
+ });
20
+
21
+ type Language = {
22
+ name: string;
23
+ language: unknown;
24
+ nodeTypeInfo: NodeInfo[];
25
+ };
26
+
27
+ declare const language: Language;
28
+ export = language;
@@ -0,0 +1,11 @@
1
+ const root = require("path").join(__dirname, "..", "..");
2
+
3
+ module.exports =
4
+ typeof process.versions.bun === "string"
5
+ // Support `bun build --compile` by being statically analyzable enough to find the .node file at build-time
6
+ ? require(`../../prebuilds/${process.platform}-${process.arch}/tree-sitter-zig.node`)
7
+ : require("node-gyp-build")(root);
8
+
9
+ try {
10
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
11
+ } catch (_) {}