@wrongstack/tools 1.0.10 → 1.0.12

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 (80) hide show
  1. package/dist/builtin.js +17 -17
  2. package/dist/{chunk-6I6RXQFG.js → chunk-2BCRQAIW.js} +9 -9
  3. package/dist/{chunk-XRNN44QY.js → chunk-2IRHFHZY.js} +235 -71
  4. package/dist/{chunk-5RBUYFRV.js → chunk-4IMNVQRB.js} +8 -2
  5. package/dist/{chunk-NEYUPZL6.js → chunk-6D3UIQMF.js} +651 -303
  6. package/dist/chunk-BJ5LXLKE.js +351 -0
  7. package/dist/{chunk-C6ZOXNXV.js → chunk-CSS42GRP.js} +2 -2
  8. package/dist/{chunk-SKRMUHTU.js → chunk-HSLDY55L.js} +41 -8
  9. package/dist/{chunk-ENE22I5W.js → chunk-K37AKCTN.js} +884 -362
  10. package/dist/{chunk-V25Q6TQ7.js → chunk-K3VX6V5P.js} +3 -3
  11. package/dist/chunk-OIFY4XNP.js +855 -0
  12. package/dist/{chunk-OUERRFEM.js → chunk-OMQDKZOT.js} +17 -8
  13. package/dist/{chunk-7GOE2ZTZ.js → chunk-OMWC2OGT.js} +2 -2
  14. package/dist/{chunk-IE4KDAOB.js → chunk-OYQE2UNT.js} +3 -3
  15. package/dist/chunk-R3HR3QI3.js +97 -0
  16. package/dist/{chunk-XPVYZ2S6.js → chunk-RYLMSGR5.js} +2 -2
  17. package/dist/{chunk-HYHE4VNA.js → chunk-UMOP3VGK.js} +79 -45
  18. package/dist/{chunk-FVSMTEO3.js → chunk-VMNWQI4V.js} +2 -2
  19. package/dist/{chunk-2UVAIS5O.js → chunk-YPSVPCIE.js} +2 -2
  20. package/dist/{chunk-PWZUHZP7.js → chunk-Z77XMU3U.js} +2 -2
  21. package/dist/codebase-index/ast-invariant-engine.d.ts +19 -2
  22. package/dist/codebase-index/atlas-projection.d.ts +19 -0
  23. package/dist/codebase-index/background-indexer.d.ts +14 -0
  24. package/dist/codebase-index/circuit-breaker.d.ts +7 -0
  25. package/dist/codebase-index/codebase-ast-replace-tool.d.ts +1 -1
  26. package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +6 -0
  27. package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -0
  28. package/dist/codebase-index/codebase-targeted-test-tool.d.ts +26 -0
  29. package/dist/codebase-index/dead-code-scan.d.ts +4 -0
  30. package/dist/codebase-index/go-parser.d.ts +23 -3
  31. package/dist/codebase-index/graph-rank-pass.d.ts +10 -0
  32. package/dist/codebase-index/graph-rank.d.ts +8 -0
  33. package/dist/codebase-index/index.d.ts +1 -1
  34. package/dist/codebase-index/index.js +9 -9
  35. package/dist/codebase-index/lsp-kind.d.ts +3 -1
  36. package/dist/codebase-index/module-resolver.d.ts +21 -1
  37. package/dist/codebase-index/parser-batch.d.ts +6 -8
  38. package/dist/codebase-index/parser-output.d.ts +5 -1
  39. package/dist/codebase-index/parser-worker-script.js +4 -4
  40. package/dist/codebase-index/project-server-framing.d.ts +1 -17
  41. package/dist/codebase-index/project-server-watcher.d.ts +6 -0
  42. package/dist/codebase-index/project-server.js +72 -26
  43. package/dist/codebase-index/py-parser.d.ts +4 -4
  44. package/dist/codebase-index/rs-parser.d.ts +7 -0
  45. package/dist/codebase-index/toolchain-scripts.d.ts +64 -0
  46. package/dist/codebase-index/tree-sitter/queries.d.ts +14 -0
  47. package/dist/codebase-index/tree-sitter/util.d.ts +6 -1
  48. package/dist/codebase-index/tree-sitter-parser.d.ts +7 -0
  49. package/dist/codebase-index/worker.js +23 -16
  50. package/dist/codebase-index/writer-refs.d.ts +17 -2
  51. package/dist/codebase-index/writer-search-helpers.d.ts +9 -0
  52. package/dist/codebase-index/writer.d.ts +20 -1
  53. package/dist/edit.js +8 -8
  54. package/dist/{generic-parser-N2PLGBC2.js → generic-parser-IVWLFKMR.js} +2 -2
  55. package/dist/go-parser-LWV3L5V7.js +197 -0
  56. package/dist/index.js +19 -19
  57. package/dist/json-parser-PERV2JHX.js +204 -0
  58. package/dist/pack.js +18 -18
  59. package/dist/parser-dispatch-ZSWCQB6M.js +14 -0
  60. package/dist/patch.js +8 -8
  61. package/dist/{py-parser-4PFZYAJ7.js → py-parser-B6D6RGH7.js} +4 -4
  62. package/dist/read.js +8 -8
  63. package/dist/replace.js +8 -8
  64. package/dist/rs-parser-L7SP4GWJ.js +182 -0
  65. package/dist/test.d.ts +1 -0
  66. package/dist/test.js +1 -1
  67. package/dist/tool-tier.js +19 -19
  68. package/dist/{tree-sitter-parser-GILYQLS4.js → tree-sitter-parser-KU6JF3ZC.js} +6 -4
  69. package/dist/{ts-parser-7W26YB26.js → ts-parser-PML6QIH7.js} +55 -23
  70. package/dist/typecheck.js +1 -1
  71. package/dist/write.js +8 -8
  72. package/dist/{yaml-parser-DFBC5FWH.js → yaml-parser-7BJN544B.js} +41 -6
  73. package/package.json +5 -5
  74. package/dist/chunk-4CE3RKEP.js +0 -390
  75. package/dist/chunk-KHUCKLOR.js +0 -899
  76. package/dist/chunk-ZKC5UNGD.js +0 -167
  77. package/dist/go-parser-Z4H6SR3R.js +0 -474
  78. package/dist/json-parser-IJD77VL4.js +0 -256
  79. package/dist/parser-dispatch-WG4DNBHH.js +0 -14
  80. package/dist/rs-parser-GIWPUA3T.js +0 -81
package/dist/builtin.js CHANGED
@@ -6,14 +6,14 @@ import {
6
6
  TIER2_TOOLS,
7
7
  TIER3_TOOLS,
8
8
  builtinTools
9
- } from "./chunk-6I6RXQFG.js";
9
+ } from "./chunk-2BCRQAIW.js";
10
10
  import "./chunk-BVHKBBGA.js";
11
- import "./chunk-ENE22I5W.js";
12
- import "./chunk-XRNN44QY.js";
11
+ import "./chunk-K37AKCTN.js";
12
+ import "./chunk-2IRHFHZY.js";
13
13
  import "./chunk-MRXWOOOR.js";
14
14
  import "./chunk-7V33PHT6.js";
15
15
  import "./chunk-OKZJJDOG.js";
16
- import "./chunk-OUERRFEM.js";
16
+ import "./chunk-OMQDKZOT.js";
17
17
  import "./chunk-ULI2J6TX.js";
18
18
  import "./chunk-YKSOSI2N.js";
19
19
  import "./chunk-DOAHONOS.js";
@@ -21,17 +21,17 @@ import "./chunk-C3WP6ZOT.js";
21
21
  import "./chunk-JPK2HHBK.js";
22
22
  import "./chunk-KS2OEZWV.js";
23
23
  import "./chunk-SPNXDTCJ.js";
24
- import "./chunk-2UVAIS5O.js";
24
+ import "./chunk-YPSVPCIE.js";
25
25
  import "./chunk-D6RQZMZS.js";
26
26
  import "./chunk-2OCAAFAT.js";
27
27
  import "./chunk-M4ZHHCCW.js";
28
28
  import "./chunk-KPDCKSN5.js";
29
29
  import "./chunk-4SUGLJLO.js";
30
- import "./chunk-5RBUYFRV.js";
30
+ import "./chunk-4IMNVQRB.js";
31
31
  import "./chunk-E7A4SLKR.js";
32
32
  import "./chunk-G7CYW5EP.js";
33
33
  import "./chunk-UVYRQKPZ.js";
34
- import "./chunk-C6ZOXNXV.js";
34
+ import "./chunk-CSS42GRP.js";
35
35
  import "./chunk-ON6ET5ER.js";
36
36
  import "./chunk-DLZCOEVG.js";
37
37
  import "./chunk-YJTXRH5Y.js";
@@ -50,17 +50,17 @@ import "./chunk-DBG7UQGK.js";
50
50
  import "./chunk-VMJY6FYJ.js";
51
51
  import "./chunk-YZECCW3F.js";
52
52
  import "./chunk-O2MHULBO.js";
53
- import "./chunk-IE4KDAOB.js";
54
- import "./chunk-PWZUHZP7.js";
55
- import "./chunk-7GOE2ZTZ.js";
53
+ import "./chunk-OYQE2UNT.js";
54
+ import "./chunk-Z77XMU3U.js";
55
+ import "./chunk-OMWC2OGT.js";
56
56
  import "./chunk-MSOAX3GC.js";
57
- import "./chunk-HYHE4VNA.js";
58
- import "./chunk-XPVYZ2S6.js";
59
- import "./chunk-NEYUPZL6.js";
60
- import "./chunk-KHUCKLOR.js";
61
- import "./chunk-4CE3RKEP.js";
62
- import "./chunk-SKRMUHTU.js";
63
- import "./chunk-ZKC5UNGD.js";
57
+ import "./chunk-UMOP3VGK.js";
58
+ import "./chunk-RYLMSGR5.js";
59
+ import "./chunk-6D3UIQMF.js";
60
+ import "./chunk-BJ5LXLKE.js";
61
+ import "./chunk-R3HR3QI3.js";
62
+ import "./chunk-HSLDY55L.js";
63
+ import "./chunk-OIFY4XNP.js";
64
64
  import "./chunk-YOHO4DVT.js";
65
65
  import "./chunk-XHSHNOAF.js";
66
66
  import "./chunk-XZLVJD56.js";
@@ -15,7 +15,7 @@ import {
15
15
  codebaseStatsTool,
16
16
  codebaseTargetedTestTool,
17
17
  deadCodeScanTool
18
- } from "./chunk-ENE22I5W.js";
18
+ } from "./chunk-K37AKCTN.js";
19
19
  import {
20
20
  designTool
21
21
  } from "./chunk-MRXWOOOR.js";
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-OKZJJDOG.js";
28
28
  import {
29
29
  testTool
30
- } from "./chunk-OUERRFEM.js";
30
+ } from "./chunk-OMQDKZOT.js";
31
31
  import {
32
32
  installTool
33
33
  } from "./chunk-ULI2J6TX.js";
@@ -51,7 +51,7 @@ import {
51
51
  } from "./chunk-SPNXDTCJ.js";
52
52
  import {
53
53
  patchTool
54
- } from "./chunk-2UVAIS5O.js";
54
+ } from "./chunk-YPSVPCIE.js";
55
55
  import {
56
56
  jsonTool
57
57
  } from "./chunk-D6RQZMZS.js";
@@ -69,7 +69,7 @@ import {
69
69
  } from "./chunk-4SUGLJLO.js";
70
70
  import {
71
71
  typecheckTool
72
- } from "./chunk-5RBUYFRV.js";
72
+ } from "./chunk-4IMNVQRB.js";
73
73
  import {
74
74
  languageInfoTool,
75
75
  languagePackageTool,
@@ -77,7 +77,7 @@ import {
77
77
  } from "./chunk-G7CYW5EP.js";
78
78
  import {
79
79
  replaceTool
80
- } from "./chunk-C6ZOXNXV.js";
80
+ } from "./chunk-CSS42GRP.js";
81
81
  import {
82
82
  globTool
83
83
  } from "./chunk-ON6ET5ER.js";
@@ -125,13 +125,13 @@ import {
125
125
  } from "./chunk-O2MHULBO.js";
126
126
  import {
127
127
  readTool
128
- } from "./chunk-IE4KDAOB.js";
128
+ } from "./chunk-OYQE2UNT.js";
129
129
  import {
130
130
  writeTool
131
- } from "./chunk-PWZUHZP7.js";
131
+ } from "./chunk-Z77XMU3U.js";
132
132
  import {
133
133
  editTool
134
- } from "./chunk-7GOE2ZTZ.js";
134
+ } from "./chunk-OMWC2OGT.js";
135
135
  import {
136
136
  resolvePowerShell
137
137
  } from "./chunk-XZLVJD56.js";
@@ -1623,4 +1623,4 @@ export {
1623
1623
  TIER3_TOOLS,
1624
1624
  builtinTools
1625
1625
  };
1626
- //# sourceMappingURL=chunk-6I6RXQFG.js.map
1626
+ //# sourceMappingURL=chunk-2BCRQAIW.js.map
@@ -5,6 +5,126 @@ import * as path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
7
  // src/codebase-index/tree-sitter/queries.ts
8
+ var NAME_LIKE_TYPES = /* @__PURE__ */ new Set([
9
+ "identifier",
10
+ "simple_identifier",
11
+ "type_identifier",
12
+ "field_identifier",
13
+ "name",
14
+ "constant"
15
+ ]);
16
+ function namedChildrenOf(node) {
17
+ const out = [];
18
+ for (let i = 0; i < node.namedChildCount; i++) {
19
+ const child = node.namedChild(i);
20
+ if (child) out.push(child);
21
+ }
22
+ return out;
23
+ }
24
+ function declaratorNames(node, declaratorTypes, containerTypes = /* @__PURE__ */ new Set()) {
25
+ const out = [];
26
+ const walk = (current, depth) => {
27
+ for (const child of namedChildrenOf(current)) {
28
+ if (declaratorTypes.has(child.type)) {
29
+ const id = child.childForFieldName("name") ?? namedChildrenOf(child).find((c) => NAME_LIKE_TYPES.has(c.type));
30
+ if (id) out.push(id.text);
31
+ } else if (depth < 2 && containerTypes.has(child.type)) {
32
+ walk(child, depth + 1);
33
+ }
34
+ }
35
+ };
36
+ walk(node, 0);
37
+ return out;
38
+ }
39
+ function cDeclaratorNames(node) {
40
+ const out = [];
41
+ for (const declarator of node.childrenForFieldName("declarator")) {
42
+ let current = declarator;
43
+ for (let depth = 0; current && depth < 16; depth++) {
44
+ if (current.type === "identifier") {
45
+ out.push(current.text);
46
+ break;
47
+ }
48
+ current = current.childForFieldName("declarator");
49
+ }
50
+ }
51
+ return out;
52
+ }
53
+ function cDeclaresFunction(node) {
54
+ for (const declarator of node.childrenForFieldName("declarator")) {
55
+ let current = declarator;
56
+ for (let depth = 0; current && depth < 16; depth++) {
57
+ if (current.type === "function_declarator") return true;
58
+ current = current.childForFieldName("declarator");
59
+ }
60
+ }
61
+ return false;
62
+ }
63
+ function cDeclarationKind(node) {
64
+ if (cDeclaresFunction(node)) return "function";
65
+ let parent = node.parent;
66
+ while (parent?.type.startsWith("preproc_")) parent = parent.parent;
67
+ return parent?.type === "translation_unit" ? "var" : null;
68
+ }
69
+ var C_SPECIFIER_TYPES = /* @__PURE__ */ new Set([
70
+ "struct_specifier",
71
+ "union_specifier",
72
+ "enum_specifier",
73
+ "class_specifier"
74
+ ]);
75
+ function cSpecifierKind(node, kind) {
76
+ if (!C_SPECIFIER_TYPES.has(node.type)) return kind;
77
+ return node.childForFieldName("body") ? kind : null;
78
+ }
79
+ function sameNode(a, b) {
80
+ return a !== null && a.startIndex === b.startIndex && a.endIndex === b.endIndex;
81
+ }
82
+ function rubyInsideClass(node) {
83
+ for (let parent = node.parent; parent; parent = parent.parent) {
84
+ if (parent.type === "class" || parent.type === "module" || parent.type === "singleton_class") {
85
+ return true;
86
+ }
87
+ if (parent.type === "method" || parent.type === "singleton_method") return false;
88
+ }
89
+ return false;
90
+ }
91
+ var ELIXIR_FUNCTION_DEFS = /* @__PURE__ */ new Set([
92
+ "def",
93
+ "defp",
94
+ "defmacro",
95
+ "defmacrop",
96
+ "defguard",
97
+ "defguardp",
98
+ "defdelegate"
99
+ ]);
100
+ var ELIXIR_MODULE_DEFS = /* @__PURE__ */ new Set(["defmodule", "defprotocol"]);
101
+ function elixirDefinition(node) {
102
+ if (node.type !== "call") return null;
103
+ const target = node.childForFieldName("target") ?? node.namedChild(0);
104
+ if (target?.type !== "identifier") return null;
105
+ const args = namedChildrenOf(node).find((child) => child.type === "arguments");
106
+ const head = args?.namedChild(0);
107
+ if (!head) return null;
108
+ if (ELIXIR_MODULE_DEFS.has(target.text)) {
109
+ return head.type === "alias" ? { kind: "namespace", name: head.text } : null;
110
+ }
111
+ if (!ELIXIR_FUNCTION_DEFS.has(target.text)) return null;
112
+ const name = elixirFunctionName(head, 0);
113
+ return name ? { kind: "function", name } : null;
114
+ }
115
+ function elixirFunctionName(head, depth) {
116
+ if (depth > 3) return null;
117
+ if (head.type === "identifier") return head.text;
118
+ if (head.type === "call") {
119
+ const target = head.childForFieldName("target") ?? head.namedChild(0);
120
+ return target?.type === "identifier" ? target.text : null;
121
+ }
122
+ if (head.type === "binary_operator") {
123
+ const left = head.childForFieldName("left") ?? head.namedChild(0);
124
+ return left ? elixirFunctionName(left, depth + 1) : null;
125
+ }
126
+ return null;
127
+ }
8
128
  function parseGroupedUse(text) {
9
129
  const open = text.indexOf("{");
10
130
  const close = text.lastIndexOf("}");
@@ -248,6 +368,8 @@ var LANG_QUERIES = {
248
368
  type_definition: "declarator",
249
369
  preproc_def: "name"
250
370
  },
371
+ resolveKind: (node, kind) => node.type === "declaration" ? cDeclarationKind(node) : cSpecifierKind(node, kind),
372
+ declaredNames: (node) => node.type === "declaration" && !cDeclaresFunction(node) ? cDeclaratorNames(node) : void 0,
251
373
  scopeNodes: /* @__PURE__ */ new Set([
252
374
  "translation_unit",
253
375
  "function_definition",
@@ -283,6 +405,7 @@ var LANG_QUERIES = {
283
405
  namespace_definition: "name",
284
406
  type_definition: "declarator"
285
407
  },
408
+ resolveKind: cSpecifierKind,
286
409
  scopeNodes: /* @__PURE__ */ new Set([
287
410
  "translation_unit",
288
411
  "function_definition",
@@ -308,8 +431,10 @@ var LANG_QUERIES = {
308
431
  annotation_type_declaration: "interface",
309
432
  method_declaration: "method",
310
433
  constructor_declaration: "method",
311
- field_declaration: "property"
434
+ field_declaration: "property",
435
+ constant_declaration: "const"
312
436
  },
437
+ declaredNames: (node) => node.type === "field_declaration" || node.type === "constant_declaration" ? declaratorNames(node, /* @__PURE__ */ new Set(["variable_declarator"])) : void 0,
313
438
  nameField: {
314
439
  class_declaration: "name",
315
440
  interface_declaration: "name",
@@ -320,12 +445,7 @@ var LANG_QUERIES = {
320
445
  constructor_declaration: "name"
321
446
  },
322
447
  // `field_declaration` has no single `name` field — it carries a list of
323
- // variable declarators. We emit one Symbol per node using the first
324
- // identifier-shaped named child (see `extractName` fallback in
325
- // `visitor.ts`). `int a, b, c;` therefore indexes only `a` — splitting
326
- // multi-declarator fields into separate Symbols is a separate refactor
327
- // that needs the visitor to know it has multiple names per node, and no
328
- // current test relies on it.
448
+ // variable declarators, each emitted as its own symbol (declaredNames).
329
449
  scopeNodes: /* @__PURE__ */ new Set([
330
450
  "program",
331
451
  "class_declaration",
@@ -369,14 +489,22 @@ var LANG_QUERIES = {
369
489
  field_declaration: "property",
370
490
  namespace_declaration: "namespace"
371
491
  },
372
- // Custom name extractor: take the full dotted name verbatim.
492
+ // Namespaces keep their full dotted name verbatim. Scoped to namespace
493
+ // nodes: applied to every declaration it named an interface member
494
+ // `System.Threading.Tasks.Task RunAsync();` after its RETURN TYPE.
373
495
  nameExtractor: (node) => {
496
+ if (node.type !== "namespace_declaration" && node.type !== "file_scoped_namespace_declaration") {
497
+ return null;
498
+ }
499
+ const named = node.childForFieldName("name");
500
+ if (named) return named.text;
374
501
  const inner = node.namedChild(0);
375
- if (inner && (inner.type === "qualified_name" || inner.type === "name")) {
502
+ if (inner && (inner.type === "qualified_name" || inner.type === "identifier")) {
376
503
  return inner.text;
377
504
  }
378
505
  return null;
379
506
  },
507
+ declaredNames: (node) => node.type === "field_declaration" ? declaratorNames(node, /* @__PURE__ */ new Set(["variable_declarator"]), /* @__PURE__ */ new Set(["variable_declaration"])) : void 0,
380
508
  scopeNodes: /* @__PURE__ */ new Set([
381
509
  "compilation_unit",
382
510
  "namespace_declaration",
@@ -417,6 +545,13 @@ var LANG_QUERIES = {
417
545
  enum_declaration: "name",
418
546
  namespace_definition: "name"
419
547
  },
548
+ // `namespace App\Models;` — the whole qualified name, not its first
549
+ // segment. The resolver binds `use App\Models\User` against it.
550
+ declaredNames: (node) => {
551
+ if (node.type !== "namespace_definition") return void 0;
552
+ const name = node.childForFieldName("name")?.text;
553
+ return name ? [name] : [];
554
+ },
420
555
  scopeNodes: /* @__PURE__ */ new Set([
421
556
  "program",
422
557
  "namespace_definition",
@@ -459,6 +594,15 @@ var LANG_QUERIES = {
459
594
  module: "name",
460
595
  constant: "name"
461
596
  },
597
+ resolveKind: (node, kind) => {
598
+ if (node.type === "constant") {
599
+ const parent = node.parent;
600
+ return parent?.type === "assignment" && sameNode(parent.childForFieldName("left"), node) ? "const" : null;
601
+ }
602
+ if (node.type === "method") return rubyInsideClass(node) ? "method" : "function";
603
+ return kind;
604
+ },
605
+ declaredNames: (node) => node.type === "constant" ? [node.text] : void 0,
462
606
  scopeNodes: /* @__PURE__ */ new Set(["program", "class", "module", "singleton_method", "method"]),
463
607
  refRules: {
464
608
  // `call` covers both `foo(...)` and `obj.foo(...)` — the extractor
@@ -477,7 +621,8 @@ var LANG_QUERIES = {
477
621
  actor_declaration: "class",
478
622
  extension_declaration: "class",
479
623
  initializer: "method",
480
- property_declaration: "property"
624
+ property_declaration: "property",
625
+ protocol_function_declaration: "method"
481
626
  },
482
627
  nameField: {
483
628
  function_declaration: "name",
@@ -528,6 +673,11 @@ var LANG_QUERIES = {
528
673
  property_declaration: "name",
529
674
  type_alias: "name"
530
675
  },
676
+ declaredNames: (node) => node.type === "property_declaration" ? declaratorNames(
677
+ node,
678
+ /* @__PURE__ */ new Set(["variable_declaration"]),
679
+ /* @__PURE__ */ new Set(["multi_variable_declaration"])
680
+ ) : void 0,
531
681
  scopeNodes: /* @__PURE__ */ new Set([
532
682
  "source_file",
533
683
  "class_declaration",
@@ -547,30 +697,17 @@ var LANG_QUERIES = {
547
697
  }
548
698
  },
549
699
  elixir: {
700
+ // Every Elixir definition is a `call` node (`def`, `defmodule`, …), and so
701
+ // is every ordinary call. The previous table indexed `defmodule` itself as
702
+ // a function named "defmodule", named each def after its whole argument
703
+ // text ("total(items), do: …"), and emitted a function symbol for every
704
+ // plain call in every body. elixirDefinition decides all three.
550
705
  declKinds: {
551
- // `def foo`, `defp foo`, `defmacro foo`, `macrop foo` all surface as
552
- // `call` nodes in the tree-sitter grammar — there is no
553
- // `function_definition`. The `nameExtractor` walks the call's
554
- // children to pick the right sibling identifier.
555
- call: "function",
556
- module: "namespace"
557
- },
558
- nameExtractor: (node) => {
559
- if (node.type === "module") {
560
- const aliasNode = node.childForFieldName("alias");
561
- return readFirstString(aliasNode) ?? null;
562
- }
563
- if (node.type !== "call") return null;
564
- const first = node.namedChild(0);
565
- if (!first) return null;
566
- const target = first.text;
567
- if (target !== "def" && target !== "defp" && target !== "defmacro" && target !== "defp_macro" && target !== "macrop" && target !== "defprotocol" && target !== "defguard" && target !== "defguardp") {
568
- return null;
569
- }
570
- const nameNode = node.namedChild(1);
571
- return nameNode?.text ?? null;
706
+ call: "function"
572
707
  },
573
- scopeNodes: /* @__PURE__ */ new Set(["source", "module"])
708
+ resolveKind: (node) => elixirDefinition(node)?.kind ?? null,
709
+ nameExtractor: (node) => elixirDefinition(node)?.name ?? null,
710
+ isScopeNode: (node) => elixirDefinition(node)?.kind === "namespace"
574
711
  },
575
712
  shell: {
576
713
  declKinds: {
@@ -583,14 +720,6 @@ var LANG_QUERIES = {
583
720
  function getQueries(lang) {
584
721
  return LANG_QUERIES[lang] ?? DEFAULT_QUERIES;
585
722
  }
586
- function readFirstString(node) {
587
- if (!node) return null;
588
- if (node.type === "string_literal" || node.type === "alias") {
589
- return node.text.replace(/^"|"$/g, "");
590
- }
591
- const child = node.namedChild(0);
592
- return child ? readFirstString(child) : null;
593
- }
594
723
 
595
724
  // src/codebase-index/tree-sitter/util.ts
596
725
  function lineColAt(offsets, index) {
@@ -602,7 +731,7 @@ function lineColAt(offsets, index) {
602
731
  else high = mid;
603
732
  }
604
733
  const lastNl = low > 0 ? offsets[low - 1] ?? -1 : -1;
605
- return { line: low + 1, col: index - lastNl };
734
+ return { line: low + 1, col: index - lastNl - 1 };
606
735
  }
607
736
  function newlineOffsets(content) {
608
737
  const offsets = [];
@@ -653,26 +782,33 @@ function visitTree(tree, content, file, lang, queries) {
653
782
  }
654
783
  function visit(node, depth) {
655
784
  if (symbols.length >= TREE_SITTER_MAX_SYMBOLS) return;
785
+ if (node.startIndex >= boundedContent.length) return;
656
786
  if (node.isMissing || node.isError) {
657
787
  } else {
658
- const kind = queries.declKinds[node.type];
788
+ const staticKind = queries.declKinds[node.type];
789
+ const kind = staticKind && queries.resolveKind ? queries.resolveKind(node, staticKind) : staticKind;
659
790
  if (kind) {
660
- const emitted = emitSymbol(
661
- node,
662
- kind,
663
- file,
664
- lang,
665
- scopeStack,
666
- boundedContent,
667
- nlOffsets,
668
- queries
669
- );
670
- if (emitted) symbols.push(emitted);
791
+ const names = queries.declaredNames?.(node);
792
+ for (const name of names ?? [void 0]) {
793
+ if (symbols.length >= TREE_SITTER_MAX_SYMBOLS) break;
794
+ const emitted = emitSymbol(
795
+ node,
796
+ kind,
797
+ file,
798
+ lang,
799
+ scopeStack,
800
+ boundedContent,
801
+ nlOffsets,
802
+ queries,
803
+ name
804
+ );
805
+ if (emitted) symbols.push(emitted);
806
+ }
671
807
  }
672
808
  const refRule = queries.refRules?.[node.type];
673
809
  if (refRule) emitRefsForNode(node, refRule);
674
810
  }
675
- const pushesScope = queries.scopeNodes?.has(node.type) ?? false;
811
+ const pushesScope = queries.isScopeNode ? queries.isScopeNode(node) : queries.scopeNodes?.has(node.type) ?? false;
676
812
  const pushIdx = pushesScope ? pushScope(scopeStack, node, queries) : -1;
677
813
  if (queries.skipNamedChildren) {
678
814
  if (pushIdx !== -1) scopeStack.pop();
@@ -706,8 +842,20 @@ var IDENTIFIER_NODE_TYPES = /* @__PURE__ */ new Set([
706
842
  "word",
707
843
  "variable_name",
708
844
  "constant",
709
- "sym"
845
+ "sym",
846
+ "namespace_identifier"
710
847
  ]);
848
+ function declaratorChainName(start) {
849
+ let current = start;
850
+ for (let depth = 0; current && depth < 16; depth++) {
851
+ if (IDENTIFIER_NODE_TYPES.has(current.type)) return current.text;
852
+ if (current.type === "destructor_name" || current.type === "operator_name") {
853
+ return current.text;
854
+ }
855
+ current = current.childForFieldName("declarator") ?? current.childForFieldName("name");
856
+ }
857
+ return null;
858
+ }
711
859
  function extractName(node, queries) {
712
860
  if (queries.nameExtractor) {
713
861
  const extracted = queries.nameExtractor(node);
@@ -716,10 +864,9 @@ function extractName(node, queries) {
716
864
  const fieldName = queries.nameField?.[node.type] ?? "name";
717
865
  const field = node.childForFieldName(fieldName);
718
866
  if (field) {
719
- if (IDENTIFIER_NODE_TYPES.has(field.type)) {
720
- return field.text;
721
- }
722
- const inner = field.childForFieldName("name") ?? field.namedChild(0);
867
+ const chained = declaratorChainName(field);
868
+ if (chained) return chained;
869
+ const inner = field.namedChild(0);
723
870
  if (inner && IDENTIFIER_NODE_TYPES.has(inner.type)) {
724
871
  return inner.text;
725
872
  }
@@ -732,8 +879,8 @@ function extractName(node, queries) {
732
879
  }
733
880
  return null;
734
881
  }
735
- function emitSymbol(node, kind, file, lang, scopeStack, content, nlOffsets, queries) {
736
- const name = extractName(node, queries);
882
+ function emitSymbol(node, kind, file, lang, scopeStack, content, nlOffsets, queries, nameOverride) {
883
+ const name = nameOverride ?? extractName(node, queries);
737
884
  if (!name) return null;
738
885
  const pos = node.startIndex;
739
886
  const { line, col } = lineColAt(nlOffsets, pos);
@@ -875,15 +1022,19 @@ async function parseSymbols(opts) {
875
1022
  const { Parser } = await getRuntime();
876
1023
  const cached = await loadLanguage(lang);
877
1024
  const parser = new Parser();
878
- parser.setLanguage(cached.Language);
879
- const tree = parser.parse(content);
880
- if (!tree) {
881
- return { file, lang, symbols: [], mtimeMs: Date.now() };
1025
+ let tree = null;
1026
+ try {
1027
+ parser.setLanguage(cached.Language);
1028
+ tree = parser.parse(content);
1029
+ if (!tree) {
1030
+ return { file, lang, symbols: [], mtimeMs: Date.now() };
1031
+ }
1032
+ const { symbols, refs } = visitTree(tree, content, file, lang, getQueries(lang));
1033
+ return { file, lang, symbols, refs, mtimeMs: Date.now() };
1034
+ } finally {
1035
+ tree?.delete();
1036
+ parser.delete();
882
1037
  }
883
- const { symbols, refs } = visitTree(tree, content, file, lang, getQueries(lang));
884
- parser.delete();
885
- tree.delete();
886
- return { file, lang, symbols, refs, mtimeMs: Date.now() };
887
1038
  } catch {
888
1039
  return { file, lang, symbols: [], mtimeMs: Date.now() };
889
1040
  }
@@ -931,12 +1082,25 @@ async function parseTreeSitterAst(opts) {
931
1082
  return null;
932
1083
  }
933
1084
  }
1085
+ function treeSitterDeclarationName(node) {
1086
+ const named = node.childForFieldName("name");
1087
+ if (named) return named.text;
1088
+ let declarator = node.childForFieldName("declarator");
1089
+ if (!declarator) return void 0;
1090
+ for (; ; ) {
1091
+ const inner = declarator.childForFieldName("declarator");
1092
+ if (!inner) break;
1093
+ declarator = inner;
1094
+ }
1095
+ return /identifier$/.test(declarator.type) ? declarator.text : void 0;
1096
+ }
934
1097
 
935
1098
  export {
936
1099
  getGrammarWasmPath,
937
1100
  parseSymbols,
938
1101
  loadTreeSitterLanguage,
939
1102
  __smokeRootType,
940
- parseTreeSitterAst
1103
+ parseTreeSitterAst,
1104
+ treeSitterDeclarationName
941
1105
  };
942
- //# sourceMappingURL=chunk-XRNN44QY.js.map
1106
+ //# sourceMappingURL=chunk-2IRHFHZY.js.map
@@ -78,11 +78,17 @@ var typecheckTool = {
78
78
  `typecheck: ${bridge.language} checker unavailable: ${run.error || run.output || "no detail"}`
79
79
  );
80
80
  }
81
+ if (run.status === "cancelled") signal.throwIfAborted();
82
+ if (run.exitCode === null) {
83
+ throw new Error(
84
+ `typecheck: ${bridge.language} checker did not finish (${run.status})${run.error ? `: ${run.error}` : ""}`
85
+ );
86
+ }
81
87
  yield {
82
88
  type: "final",
83
89
  output: {
84
90
  project: `${bridge.language} workspace`,
85
- exit_code: run.exitCode ?? 0,
91
+ exit_code: run.exitCode,
86
92
  errors: run.summary.errors,
87
93
  warnings: run.summary.warnings,
88
94
  output: normalizeCommandOutput(run.output || run.error || ""),
@@ -170,4 +176,4 @@ async function findTsConfig(cwd) {
170
176
  export {
171
177
  typecheckTool
172
178
  };
173
- //# sourceMappingURL=chunk-5RBUYFRV.js.map
179
+ //# sourceMappingURL=chunk-4IMNVQRB.js.map