gitnexus 1.6.0 → 1.6.2-rc.1

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 (145) hide show
  1. package/README.md +73 -0
  2. package/dist/cli/analyze.js +50 -3
  3. package/dist/core/group/extractors/fs-utils.d.ts +10 -0
  4. package/dist/core/group/extractors/fs-utils.js +24 -0
  5. package/dist/core/group/extractors/grpc-extractor.d.ts +17 -8
  6. package/dist/core/group/extractors/grpc-extractor.js +328 -191
  7. package/dist/core/group/extractors/grpc-patterns/go.d.ts +2 -0
  8. package/dist/core/group/extractors/grpc-patterns/go.js +97 -0
  9. package/dist/core/group/extractors/grpc-patterns/index.d.ts +19 -0
  10. package/dist/core/group/extractors/grpc-patterns/index.js +46 -0
  11. package/dist/core/group/extractors/grpc-patterns/java.d.ts +2 -0
  12. package/dist/core/group/extractors/grpc-patterns/java.js +173 -0
  13. package/dist/core/group/extractors/grpc-patterns/node.d.ts +4 -0
  14. package/dist/core/group/extractors/grpc-patterns/node.js +290 -0
  15. package/dist/core/group/extractors/grpc-patterns/proto.d.ts +9 -0
  16. package/dist/core/group/extractors/grpc-patterns/proto.js +134 -0
  17. package/dist/core/group/extractors/grpc-patterns/python.d.ts +2 -0
  18. package/dist/core/group/extractors/grpc-patterns/python.js +67 -0
  19. package/dist/core/group/extractors/grpc-patterns/types.d.ts +50 -0
  20. package/dist/core/group/extractors/grpc-patterns/types.js +1 -0
  21. package/dist/core/group/extractors/http-patterns/go.d.ts +2 -0
  22. package/dist/core/group/extractors/http-patterns/go.js +215 -0
  23. package/dist/core/group/extractors/http-patterns/index.d.ts +17 -0
  24. package/dist/core/group/extractors/http-patterns/index.js +44 -0
  25. package/dist/core/group/extractors/http-patterns/java.d.ts +2 -0
  26. package/dist/core/group/extractors/http-patterns/java.js +253 -0
  27. package/dist/core/group/extractors/http-patterns/node.d.ts +4 -0
  28. package/dist/core/group/extractors/http-patterns/node.js +354 -0
  29. package/dist/core/group/extractors/http-patterns/php.d.ts +2 -0
  30. package/dist/core/group/extractors/http-patterns/php.js +70 -0
  31. package/dist/core/group/extractors/http-patterns/python.d.ts +2 -0
  32. package/dist/core/group/extractors/http-patterns/python.js +133 -0
  33. package/dist/core/group/extractors/http-patterns/types.d.ts +61 -0
  34. package/dist/core/group/extractors/http-patterns/types.js +1 -0
  35. package/dist/core/group/extractors/http-route-extractor.d.ts +10 -13
  36. package/dist/core/group/extractors/http-route-extractor.js +231 -238
  37. package/dist/core/group/extractors/manifest-extractor.d.ts +54 -0
  38. package/dist/core/group/extractors/manifest-extractor.js +277 -0
  39. package/dist/core/group/extractors/topic-extractor.d.ts +0 -1
  40. package/dist/core/group/extractors/topic-extractor.js +55 -192
  41. package/dist/core/group/extractors/topic-patterns/go.d.ts +2 -0
  42. package/dist/core/group/extractors/topic-patterns/go.js +120 -0
  43. package/dist/core/group/extractors/topic-patterns/index.d.ts +14 -0
  44. package/dist/core/group/extractors/topic-patterns/index.js +38 -0
  45. package/dist/core/group/extractors/topic-patterns/java.d.ts +2 -0
  46. package/dist/core/group/extractors/topic-patterns/java.js +80 -0
  47. package/dist/core/group/extractors/topic-patterns/node.d.ts +4 -0
  48. package/dist/core/group/extractors/topic-patterns/node.js +155 -0
  49. package/dist/core/group/extractors/topic-patterns/python.d.ts +2 -0
  50. package/dist/core/group/extractors/topic-patterns/python.js +116 -0
  51. package/dist/core/group/extractors/topic-patterns/types.d.ts +25 -0
  52. package/dist/core/group/extractors/topic-patterns/types.js +10 -0
  53. package/dist/core/group/extractors/tree-sitter-scanner.d.ts +113 -0
  54. package/dist/core/group/extractors/tree-sitter-scanner.js +94 -0
  55. package/dist/core/ingestion/binding-accumulator.d.ts +22 -17
  56. package/dist/core/ingestion/binding-accumulator.js +29 -25
  57. package/dist/core/ingestion/cobol-processor.d.ts +1 -1
  58. package/dist/core/ingestion/import-processor.js +1 -1
  59. package/dist/core/ingestion/language-config.js +1 -1
  60. package/dist/core/ingestion/language-provider.d.ts +32 -5
  61. package/dist/core/ingestion/languages/c-cpp.js +2 -2
  62. package/dist/core/ingestion/languages/dart.d.ts +1 -1
  63. package/dist/core/ingestion/languages/dart.js +2 -2
  64. package/dist/core/ingestion/languages/go.d.ts +1 -1
  65. package/dist/core/ingestion/languages/go.js +2 -2
  66. package/dist/core/ingestion/languages/ruby.js +16 -1
  67. package/dist/core/ingestion/languages/swift.d.ts +1 -1
  68. package/dist/core/ingestion/languages/swift.js +2 -2
  69. package/dist/core/ingestion/markdown-processor.d.ts +1 -1
  70. package/dist/core/ingestion/method-extractors/configs/jvm.js +1 -0
  71. package/dist/core/ingestion/method-extractors/configs/ruby.js +1 -0
  72. package/dist/core/ingestion/method-extractors/generic.d.ts +6 -0
  73. package/dist/core/ingestion/method-extractors/generic.js +48 -4
  74. package/dist/core/ingestion/method-types.d.ts +4 -0
  75. package/dist/core/ingestion/model/resolve.js +103 -48
  76. package/dist/core/ingestion/model/semantic-model.d.ts +1 -1
  77. package/dist/core/ingestion/model/semantic-model.js +1 -1
  78. package/dist/core/ingestion/model/symbol-table.d.ts +7 -7
  79. package/dist/core/ingestion/model/symbol-table.js +7 -7
  80. package/dist/core/ingestion/mro-processor.d.ts +1 -1
  81. package/dist/core/ingestion/mro-processor.js +1 -1
  82. package/dist/core/ingestion/parsing-processor.js +54 -42
  83. package/dist/core/ingestion/pipeline-phases/cobol.d.ts +16 -0
  84. package/dist/core/ingestion/pipeline-phases/cobol.js +45 -0
  85. package/dist/core/ingestion/pipeline-phases/communities.d.ts +16 -0
  86. package/dist/core/ingestion/pipeline-phases/communities.js +62 -0
  87. package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +17 -0
  88. package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +156 -0
  89. package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +37 -0
  90. package/dist/core/ingestion/pipeline-phases/cross-file.js +63 -0
  91. package/dist/core/ingestion/pipeline-phases/index.d.ts +21 -0
  92. package/dist/core/ingestion/pipeline-phases/index.js +22 -0
  93. package/dist/core/ingestion/pipeline-phases/markdown.d.ts +17 -0
  94. package/dist/core/ingestion/pipeline-phases/markdown.js +33 -0
  95. package/dist/core/ingestion/pipeline-phases/mro.d.ts +18 -0
  96. package/dist/core/ingestion/pipeline-phases/mro.js +36 -0
  97. package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +22 -0
  98. package/dist/core/ingestion/pipeline-phases/orm-extraction.js +92 -0
  99. package/dist/core/ingestion/pipeline-phases/orm.d.ts +15 -0
  100. package/dist/core/ingestion/pipeline-phases/orm.js +74 -0
  101. package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +47 -0
  102. package/dist/core/ingestion/pipeline-phases/parse-impl.js +437 -0
  103. package/dist/core/ingestion/pipeline-phases/parse.d.ts +49 -0
  104. package/dist/core/ingestion/pipeline-phases/parse.js +33 -0
  105. package/dist/core/ingestion/pipeline-phases/processes.d.ts +16 -0
  106. package/dist/core/ingestion/pipeline-phases/processes.js +143 -0
  107. package/dist/core/ingestion/pipeline-phases/routes.d.ts +21 -0
  108. package/dist/core/ingestion/pipeline-phases/routes.js +243 -0
  109. package/dist/core/ingestion/pipeline-phases/runner.d.ts +22 -0
  110. package/dist/core/ingestion/pipeline-phases/runner.js +203 -0
  111. package/dist/core/ingestion/pipeline-phases/scan.d.ts +21 -0
  112. package/dist/core/ingestion/pipeline-phases/scan.js +46 -0
  113. package/dist/core/ingestion/pipeline-phases/structure.d.ts +27 -0
  114. package/dist/core/ingestion/pipeline-phases/structure.js +35 -0
  115. package/dist/core/ingestion/pipeline-phases/tools.d.ts +20 -0
  116. package/dist/core/ingestion/pipeline-phases/tools.js +79 -0
  117. package/dist/core/ingestion/pipeline-phases/types.d.ts +79 -0
  118. package/dist/core/ingestion/pipeline-phases/types.js +37 -0
  119. package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +70 -0
  120. package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +312 -0
  121. package/dist/core/ingestion/pipeline.d.ts +16 -10
  122. package/dist/core/ingestion/pipeline.js +66 -1534
  123. package/dist/core/ingestion/process-processor.js +1 -1
  124. package/dist/core/ingestion/tree-sitter-queries.d.ts +2 -2
  125. package/dist/core/ingestion/tree-sitter-queries.js +69 -0
  126. package/dist/core/ingestion/utils/ast-helpers.d.ts +1 -3
  127. package/dist/core/ingestion/utils/ast-helpers.js +48 -21
  128. package/dist/core/ingestion/utils/env.d.ts +10 -0
  129. package/dist/core/ingestion/utils/env.js +10 -0
  130. package/dist/core/ingestion/utils/graph-sort.d.ts +58 -0
  131. package/dist/core/ingestion/utils/graph-sort.js +100 -0
  132. package/dist/core/ingestion/workers/parse-worker.js +12 -8
  133. package/dist/core/lbug/lbug-adapter.d.ts +28 -0
  134. package/dist/core/lbug/lbug-adapter.js +162 -57
  135. package/package.json +3 -3
  136. package/vendor/tree-sitter-proto/binding.gyp +30 -0
  137. package/vendor/tree-sitter-proto/bindings/node/binding.cc +20 -0
  138. package/vendor/tree-sitter-proto/bindings/node/index.d.ts +28 -0
  139. package/vendor/tree-sitter-proto/bindings/node/index.js +7 -0
  140. package/vendor/tree-sitter-proto/package.json +18 -0
  141. package/vendor/tree-sitter-proto/src/node-types.json +1145 -0
  142. package/vendor/tree-sitter-proto/src/parser.c +10149 -0
  143. package/vendor/tree-sitter-proto/src/tree_sitter/alloc.h +54 -0
  144. package/vendor/tree-sitter-proto/src/tree_sitter/array.h +291 -0
  145. package/vendor/tree-sitter-proto/src/tree_sitter/parser.h +266 -0
@@ -1,10 +1,126 @@
1
1
  import fs from 'fs/promises';
2
- import { createReadStream } from 'fs';
2
+ import { createReadStream, createWriteStream } from 'fs';
3
3
  import { createInterface } from 'readline';
4
4
  import path from 'path';
5
5
  import lbug from '@ladybugdb/core';
6
6
  import { NODE_TABLES, REL_TABLE_NAME, SCHEMA_QUERIES, EMBEDDING_TABLE_NAME, } from './schema.js';
7
7
  import { streamAllCSVsToDisk } from './csv-generator.js';
8
+ /**
9
+ * Split a relationship CSV into per-label-pair files on disk.
10
+ *
11
+ * Streams the CSV line-by-line, routing each relationship to a file named
12
+ * `rel_{fromLabel}_{toLabel}.csv`. Handles backpressure correctly: only one
13
+ * drain listener per stream at a time, and readline resumes only when ALL
14
+ * backpressured streams have drained.
15
+ *
16
+ * @param csvPath Path to the combined relationship CSV
17
+ * @param csvDir Directory to write per-pair CSV files
18
+ * @param validTables Set of valid node table names
19
+ * @param getNodeLabel Function to extract the label from a node ID
20
+ * @param wsFactory Optional WriteStream factory (defaults to fs.createWriteStream)
21
+ */
22
+ export const splitRelCsvByLabelPair = async (csvPath, csvDir, validTables, getNodeLabel, wsFactory = (p) => createWriteStream(p, 'utf-8')) => {
23
+ let relHeader = '';
24
+ const relsByPairMeta = new Map();
25
+ const pairWriteStreams = new Map();
26
+ let skippedRels = 0;
27
+ let totalValidRels = 0;
28
+ await new Promise((resolve, reject) => {
29
+ const inputStream = createReadStream(csvPath, 'utf-8');
30
+ const rl = createInterface({
31
+ input: inputStream,
32
+ crlfDelay: Infinity,
33
+ });
34
+ // Track which streams are already waiting for drain to prevent
35
+ // listener accumulation. rl.pause() is not synchronous — buffered
36
+ // line events continue firing after pause(), and without this guard
37
+ // each line targeting the same pairKey would add another drain listener.
38
+ const waitingForDrain = new Set();
39
+ let settled = false;
40
+ const cleanup = (err) => {
41
+ if (settled)
42
+ return;
43
+ settled = true;
44
+ try {
45
+ rl.close();
46
+ }
47
+ catch { }
48
+ try {
49
+ inputStream.destroy();
50
+ }
51
+ catch { }
52
+ for (const ws of pairWriteStreams.values()) {
53
+ try {
54
+ ws.destroy();
55
+ }
56
+ catch { }
57
+ }
58
+ reject(err);
59
+ };
60
+ let isFirst = true;
61
+ rl.on('line', (line) => {
62
+ if (isFirst) {
63
+ relHeader = line;
64
+ isFirst = false;
65
+ return;
66
+ }
67
+ if (!line.trim())
68
+ return;
69
+ const match = line.match(/"([^"]*)","([^"]*)"/);
70
+ if (!match) {
71
+ skippedRels++;
72
+ return;
73
+ }
74
+ const fromLabel = getNodeLabel(match[1]);
75
+ const toLabel = getNodeLabel(match[2]);
76
+ if (!validTables.has(fromLabel) || !validTables.has(toLabel)) {
77
+ skippedRels++;
78
+ return;
79
+ }
80
+ const pairKey = `${fromLabel}|${toLabel}`;
81
+ let ws = pairWriteStreams.get(pairKey);
82
+ if (!ws) {
83
+ const pairCsvPath = path.join(csvDir, `rel_${fromLabel}_${toLabel}.csv`);
84
+ ws = wsFactory(pairCsvPath);
85
+ // If any per-pair WriteStream errors (disk full, EMFILE, etc.),
86
+ // tear down everything and reject the Promise. Without this handler,
87
+ // a stream error while rl is paused waiting for drain would cause
88
+ // the drain callback to never fire and the Promise to hang forever.
89
+ ws.on('error', cleanup);
90
+ ws.write(relHeader + '\n');
91
+ pairWriteStreams.set(pairKey, ws);
92
+ relsByPairMeta.set(pairKey, { csvPath: pairCsvPath, rows: 0 });
93
+ }
94
+ const ok = ws.write(line + '\n');
95
+ relsByPairMeta.get(pairKey).rows++;
96
+ totalValidRels++;
97
+ // Handle backpressure: pause reading when the write buffer is full,
98
+ // resume when the stream drains. Prevents unbounded memory growth
99
+ // on repos with millions of relationships.
100
+ // Guard with waitingForDrain to ensure only one drain listener is
101
+ // registered per stream at a time — rl.pause() doesn't stop buffered
102
+ // line events immediately. Only resume when ALL streams have drained
103
+ // to avoid writing into still-full streams.
104
+ if (!ok && !waitingForDrain.has(pairKey)) {
105
+ waitingForDrain.add(pairKey);
106
+ rl.pause();
107
+ ws.once('drain', () => {
108
+ waitingForDrain.delete(pairKey);
109
+ if (waitingForDrain.size === 0)
110
+ rl.resume();
111
+ });
112
+ }
113
+ });
114
+ rl.on('close', () => {
115
+ if (!settled) {
116
+ settled = true;
117
+ resolve();
118
+ }
119
+ });
120
+ rl.on('error', cleanup);
121
+ });
122
+ return { relHeader, relsByPairMeta, pairWriteStreams, skippedRels, totalValidRels };
123
+ };
8
124
  let db = null;
9
125
  let conn = null;
10
126
  let currentDbPath = null;
@@ -215,64 +331,30 @@ export const loadGraphToLbug = async (graph, repoPath, storagePath, onProgress)
215
331
  }
216
332
  }
217
333
  // Bulk COPY relationships — split by FROM→TO label pair (LadybugDB requires it)
218
- // Stream-read the relation CSV line by line to avoid exceeding V8 max string length
219
- let relHeader = '';
220
- const relsByPair = new Map();
221
- let skippedRels = 0;
222
- let totalValidRels = 0;
223
- await new Promise((resolve, reject) => {
224
- const rl = createInterface({
225
- input: createReadStream(csvResult.relCsvPath, 'utf-8'),
226
- crlfDelay: Infinity,
227
- });
228
- let isFirst = true;
229
- rl.on('line', (line) => {
230
- if (isFirst) {
231
- relHeader = line;
232
- isFirst = false;
233
- return;
234
- }
235
- if (!line.trim())
236
- return;
237
- const match = line.match(/"([^"]*)","([^"]*)"/);
238
- if (!match) {
239
- skippedRels++;
240
- return;
241
- }
242
- const fromLabel = getNodeLabel(match[1]);
243
- const toLabel = getNodeLabel(match[2]);
244
- if (!validTables.has(fromLabel) || !validTables.has(toLabel)) {
245
- skippedRels++;
246
- return;
247
- }
248
- const pairKey = `${fromLabel}|${toLabel}`;
249
- let list = relsByPair.get(pairKey);
250
- if (!list) {
251
- list = [];
252
- relsByPair.set(pairKey, list);
253
- }
254
- list.push(line);
255
- totalValidRels++;
334
+ const { relHeader, relsByPairMeta, pairWriteStreams, skippedRels, totalValidRels } = await splitRelCsvByLabelPair(csvResult.relCsvPath, csvDir, validTables, getNodeLabel);
335
+ // Close all per-pair write streams before COPY
336
+ await Promise.all(Array.from(pairWriteStreams.values()).map((ws) => new Promise((resolve, reject) => {
337
+ const onError = (err) => reject(err);
338
+ ws.on('error', onError);
339
+ ws.end(() => {
340
+ ws.removeListener('error', onError);
341
+ resolve();
256
342
  });
257
- rl.on('close', resolve);
258
- rl.on('error', reject);
259
- });
343
+ })));
260
344
  const insertedRels = totalValidRels;
261
345
  const warnings = [];
262
346
  if (insertedRels > 0) {
263
- log(`Loading edges: ${insertedRels.toLocaleString()} across ${relsByPair.size} types`);
347
+ log(`Loading edges: ${insertedRels.toLocaleString()} across ${relsByPairMeta.size} types`);
264
348
  let pairIdx = 0;
265
349
  let failedPairEdges = 0;
266
- const failedPairLines = [];
267
- for (const [pairKey, lines] of relsByPair) {
350
+ const failedPairCsvPaths = new Set();
351
+ for (const [pairKey, { csvPath: pairCsvPath, rows }] of relsByPairMeta) {
268
352
  pairIdx++;
269
353
  const [fromLabel, toLabel] = pairKey.split('|');
270
- const pairCsvPath = path.join(csvDir, `rel_${fromLabel}_${toLabel}.csv`);
271
- await fs.writeFile(pairCsvPath, relHeader + '\n' + lines.join('\n'), 'utf-8');
272
354
  const normalizedPath = normalizeCopyPath(pairCsvPath);
273
355
  const copyQuery = `COPY ${REL_TABLE_NAME} FROM "${normalizedPath}" (from="${fromLabel}", to="${toLabel}", HEADER=true, ESCAPE='"', DELIM=',', QUOTE='"', PARALLEL=false, auto_detect=false)`;
274
- if (pairIdx % 5 === 0 || lines.length > 1000) {
275
- log(`Loading edges: ${pairIdx}/${relsByPair.size} types (${fromLabel} -> ${toLabel})`);
356
+ if (pairIdx % 5 === 0 || rows > 1000) {
357
+ log(`Loading edges: ${pairIdx}/${relsByPairMeta.size} types (${fromLabel} -> ${toLabel})`);
276
358
  }
277
359
  try {
278
360
  await conn.query(copyQuery);
@@ -284,19 +366,42 @@ export const loadGraphToLbug = async (graph, repoPath, storagePath, onProgress)
284
366
  }
285
367
  catch (retryErr) {
286
368
  const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
287
- warnings.push(`${fromLabel}->${toLabel} (${lines.length} edges): ${retryMsg.slice(0, 80)}`);
288
- failedPairEdges += lines.length;
289
- failedPairLines.push(...lines);
369
+ warnings.push(`${fromLabel}->${toLabel} (${rows} edges): ${retryMsg.slice(0, 80)}`);
370
+ failedPairEdges += rows;
371
+ failedPairCsvPaths.add(pairCsvPath);
290
372
  }
291
373
  }
292
- try {
293
- await fs.unlink(pairCsvPath);
374
+ // Only delete if not in failedPairCsvPaths (needed for fallback)
375
+ if (!failedPairCsvPaths.has(pairCsvPath)) {
376
+ try {
377
+ await fs.unlink(pairCsvPath);
378
+ }
379
+ catch { }
294
380
  }
295
- catch { }
296
381
  }
297
- if (failedPairLines.length > 0) {
382
+ if (failedPairCsvPaths.size > 0) {
298
383
  log(`Inserting ${failedPairEdges} edges individually (missing schema pairs)`);
299
- await fallbackRelationshipInserts([relHeader, ...failedPairLines], validTables, getNodeLabel);
384
+ // Read failed pair files and merge for fallback inserts
385
+ const allLines = [relHeader];
386
+ for (const failedPath of failedPairCsvPaths) {
387
+ try {
388
+ const content = await fs.readFile(failedPath, 'utf-8');
389
+ const lines = content.split('\n');
390
+ // Skip header line (first) and empty lines
391
+ for (let i = 1; i < lines.length; i++) {
392
+ if (lines[i].trim())
393
+ allLines.push(lines[i]);
394
+ }
395
+ }
396
+ catch { }
397
+ try {
398
+ await fs.unlink(failedPath);
399
+ }
400
+ catch { }
401
+ }
402
+ if (allLines.length > 1) {
403
+ await fallbackRelationshipInserts(allLines, validTables, getNodeLabel);
404
+ }
300
405
  }
301
406
  }
302
407
  // Cleanup all CSVs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.0",
3
+ "version": "1.6.2-rc.1",
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",
@@ -59,7 +59,6 @@
59
59
  "commander": "^12.0.0",
60
60
  "cors": "^2.8.5",
61
61
  "express": "^4.19.2",
62
- "gitnexus-shared": "file:../gitnexus-shared",
63
62
  "glob": "^11.0.0",
64
63
  "graphology": "^0.25.4",
65
64
  "graphology-indices": "^0.17.0",
@@ -85,8 +84,9 @@
85
84
  "uuid": "^13.0.0"
86
85
  },
87
86
  "optionalDependencies": {
88
- "tree-sitter-dart": "github:UserNobody14/tree-sitter-dart#80e23c07b64494f7e21090bb3450223ef0b192f4",
87
+ "tree-sitter-dart": "git+https://github.com/UserNobody14/tree-sitter-dart.git#80e23c07b64494f7e21090bb3450223ef0b192f4",
89
88
  "tree-sitter-kotlin": "^0.3.8",
89
+ "tree-sitter-proto": "file:./vendor/tree-sitter-proto",
90
90
  "tree-sitter-swift": "^0.6.0"
91
91
  },
92
92
  "devDependencies": {
@@ -0,0 +1,30 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_proto_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
+ # NOTE: if your language has an external scanner, add it here.
15
+ ],
16
+ "conditions": [
17
+ ["OS!='win'", {
18
+ "cflags_c": [
19
+ "-std=c11",
20
+ ],
21
+ }, { # OS == "win"
22
+ "cflags_c": [
23
+ "/std:c11",
24
+ "/utf-8",
25
+ ],
26
+ }],
27
+ ],
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,20 @@
1
+ #include <napi.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ extern "C" TSLanguage *tree_sitter_proto();
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, "proto");
14
+ auto language = Napi::External<TSLanguage>::New(env, tree_sitter_proto());
15
+ language.TypeTag(&LANGUAGE_TYPE_TAG);
16
+ exports["language"] = language;
17
+ return exports;
18
+ }
19
+
20
+ NODE_API_MODULE(tree_sitter_proto_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,7 @@
1
+ const root = require("path").join(__dirname, "..", "..");
2
+
3
+ module.exports = require("node-gyp-build")(root);
4
+
5
+ try {
6
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
7
+ } catch (_) {}
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "tree-sitter-proto",
3
+ "version": "0.4.1",
4
+ "description": "tree-sitter grammar for protobuf — ABI 14 build from coder3101/tree-sitter-proto latest grammar.js, compatible with tree-sitter 0.25",
5
+ "repository": "https://github.com/coder3101/tree-sitter-proto",
6
+ "license": "MIT",
7
+ "main": "bindings/node",
8
+ "scripts": {
9
+ "install": "node-gyp-build"
10
+ },
11
+ "peerDependencies": {
12
+ "tree-sitter": ">=0.21.0"
13
+ },
14
+ "dependencies": {
15
+ "node-addon-api": "^8.0.0",
16
+ "node-gyp-build": "^4.8.0"
17
+ }
18
+ }