@colbymchenry/codegraph-darwin-x64 1.3.1 → 1.4.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 (86) hide show
  1. package/lib/dist/bin/codegraph.js +45 -4
  2. package/lib/dist/bin/codegraph.js.map +1 -1
  3. package/lib/dist/bin/command-supervision.d.ts +38 -1
  4. package/lib/dist/bin/command-supervision.d.ts.map +1 -1
  5. package/lib/dist/bin/command-supervision.js +8 -2
  6. package/lib/dist/bin/command-supervision.js.map +1 -1
  7. package/lib/dist/db/index.d.ts +47 -0
  8. package/lib/dist/db/index.d.ts.map +1 -1
  9. package/lib/dist/db/index.js +114 -12
  10. package/lib/dist/db/index.js.map +1 -1
  11. package/lib/dist/db/migrations.d.ts +1 -1
  12. package/lib/dist/db/migrations.d.ts.map +1 -1
  13. package/lib/dist/db/migrations.js +31 -1
  14. package/lib/dist/db/migrations.js.map +1 -1
  15. package/lib/dist/db/queries.d.ts +40 -3
  16. package/lib/dist/db/queries.d.ts.map +1 -1
  17. package/lib/dist/db/queries.js +114 -7
  18. package/lib/dist/db/queries.js.map +1 -1
  19. package/lib/dist/db/schema.sql +13 -1
  20. package/lib/dist/db/wal-valve.d.ts +106 -0
  21. package/lib/dist/db/wal-valve.d.ts.map +1 -0
  22. package/lib/dist/db/wal-valve.js +208 -0
  23. package/lib/dist/db/wal-valve.js.map +1 -0
  24. package/lib/dist/extraction/grammars.d.ts +16 -1
  25. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  26. package/lib/dist/extraction/grammars.js +85 -43
  27. package/lib/dist/extraction/grammars.js.map +1 -1
  28. package/lib/dist/extraction/index.d.ts +1 -1
  29. package/lib/dist/extraction/index.d.ts.map +1 -1
  30. package/lib/dist/extraction/index.js +97 -10
  31. package/lib/dist/extraction/index.js.map +1 -1
  32. package/lib/dist/extraction/parse-pool.d.ts +27 -1
  33. package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
  34. package/lib/dist/extraction/parse-pool.js +75 -7
  35. package/lib/dist/extraction/parse-pool.js.map +1 -1
  36. package/lib/dist/extraction/parse-worker.js +9 -2
  37. package/lib/dist/extraction/parse-worker.js.map +1 -1
  38. package/lib/dist/index.d.ts +5 -4
  39. package/lib/dist/index.d.ts.map +1 -1
  40. package/lib/dist/index.js +94 -8
  41. package/lib/dist/index.js.map +1 -1
  42. package/lib/dist/installer/index.d.ts +42 -0
  43. package/lib/dist/installer/index.d.ts.map +1 -1
  44. package/lib/dist/installer/index.js +94 -1
  45. package/lib/dist/installer/index.js.map +1 -1
  46. package/lib/dist/mcp/index.d.ts.map +1 -1
  47. package/lib/dist/mcp/index.js +8 -0
  48. package/lib/dist/mcp/index.js.map +1 -1
  49. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -1
  50. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  51. package/lib/dist/mcp/liveness-watchdog.js +73 -13
  52. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  53. package/lib/dist/mcp/proxy.js +1 -1
  54. package/lib/dist/mcp/proxy.js.map +1 -1
  55. package/lib/dist/mcp/session.d.ts +14 -0
  56. package/lib/dist/mcp/session.d.ts.map +1 -1
  57. package/lib/dist/mcp/session.js +22 -1
  58. package/lib/dist/mcp/session.js.map +1 -1
  59. package/lib/dist/mcp/tools.d.ts.map +1 -1
  60. package/lib/dist/mcp/tools.js +49 -1
  61. package/lib/dist/mcp/tools.js.map +1 -1
  62. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  63. package/lib/dist/resolution/callback-synthesizer.js +59 -8
  64. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  65. package/lib/dist/resolution/index.d.ts +10 -0
  66. package/lib/dist/resolution/index.d.ts.map +1 -1
  67. package/lib/dist/resolution/index.js +95 -22
  68. package/lib/dist/resolution/index.js.map +1 -1
  69. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  70. package/lib/dist/resolution/name-matcher.js +130 -1
  71. package/lib/dist/resolution/name-matcher.js.map +1 -1
  72. package/lib/dist/upgrade/index.d.ts +32 -0
  73. package/lib/dist/upgrade/index.d.ts.map +1 -1
  74. package/lib/dist/upgrade/index.js +162 -14
  75. package/lib/dist/upgrade/index.js.map +1 -1
  76. package/lib/dist/upgrade/remove-binary.d.ts +87 -0
  77. package/lib/dist/upgrade/remove-binary.d.ts.map +1 -0
  78. package/lib/dist/upgrade/remove-binary.js +289 -0
  79. package/lib/dist/upgrade/remove-binary.js.map +1 -0
  80. package/lib/dist/upgrade/update-check.d.ts +92 -0
  81. package/lib/dist/upgrade/update-check.d.ts.map +1 -0
  82. package/lib/dist/upgrade/update-check.js +258 -0
  83. package/lib/dist/upgrade/update-check.js.map +1 -0
  84. package/lib/node_modules/.package-lock.json +1 -1
  85. package/lib/package.json +1 -1
  86. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"callback-synthesizer.d.ts","sourceRoot":"","sources":["../../src/resolution/callback-synthesizer.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqyGjD;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJ5G"}
1
+ {"version":3,"file":"callback-synthesizer.d.ts","sourceRoot":"","sources":["../../src/resolution/callback-synthesizer.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAo1GjD;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJ5G"}
@@ -40,6 +40,15 @@ const CC_DISPATCH_RE = /(\w+)\.forEach\s*\{\s*(?:\$0|it)\s*\(/g;
40
40
  const CC_APPEND_WRITE_RE = /(\w+)\.write\s*\{\s*\$0(?:\.(\w+))?\.(?:append|add|push|insert)\s*\(/g;
41
41
  const CC_APPEND_DIRECT_RE = /(\w+)\.(?:append|add|push|insert)\s*\(/g;
42
42
  const CC_FANOUT_CAP = 8; // skip a field name with more dispatchers/registrars than this (too generic to pair confidently)
43
+ // The dispatcher gate — `{ $0( ` / `{ it( ` element-invocation — is Swift/Kotlin
44
+ // trailing-closure syntax, so ONLY those languages can ever contribute a
45
+ // dispatcher, and a cross-language registrar pairing (a JS `.push(` against a
46
+ // Swift dispatcher's field name) would be a wrong edge, not a missed one.
47
+ // Gating both sides here isn't just precision: `.push(`/`.add(` is everywhere
48
+ // in JS/PHP, so an ungated scan slices + regexes nearly every function on repos
49
+ // where the pass cannot emit a single edge — on a 12k-file PHP/JS app that was
50
+ // 20+ minutes of the "Resolving refs" tail and a #850 watchdog kill (#1235).
51
+ const CC_LANGUAGES = new Set(['swift', 'kotlin']);
43
52
  function kebabToPascal(s) {
44
53
  return s.split('-').map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join('');
45
54
  }
@@ -75,6 +84,35 @@ function sliceLines(content, startLine, endLine) {
75
84
  return null;
76
85
  return content.split('\n').slice(startLine - 1, endLine).join('\n');
77
86
  }
87
+ /**
88
+ * Per-match line resolver over `src`, 1-based at `baseLine`. The inline
89
+ * `src.slice(0, idx).split('\n').length` idiom is O(source-length) PER MATCH,
90
+ * which goes quadratic on a match-dense source (a generated function full of
91
+ * `.push(` calls re-scanned tens of thousands of times was most of the #1235
92
+ * indexing wedge). Builds the newline index once — lazily, since most sources
93
+ * never produce a match — then answers each call with a binary search.
94
+ */
95
+ function makeLineAt(src, baseLine) {
96
+ let nl = null;
97
+ return (idx) => {
98
+ if (!nl) {
99
+ nl = [];
100
+ for (let i = src.indexOf('\n'); i !== -1; i = src.indexOf('\n', i + 1))
101
+ nl.push(i);
102
+ }
103
+ // Count newlines strictly before idx.
104
+ let lo = 0;
105
+ let hi = nl.length;
106
+ while (lo < hi) {
107
+ const mid = (lo + hi) >> 1;
108
+ if (nl[mid] < idx)
109
+ lo = mid + 1;
110
+ else
111
+ hi = mid;
112
+ }
113
+ return baseLine + lo;
114
+ };
115
+ }
78
116
  function registrarField(src) {
79
117
  const m = src.match(/this\.(\w+)\.(?:add|push|set)\(/);
80
118
  return m ? m[1] : null;
@@ -212,13 +250,18 @@ async function closureCollectionEdges(queries, ctx, onYield) {
212
250
  arr.push({ node, line: absLine });
213
251
  registrars.set(field, arr);
214
252
  };
215
- // Slices EVERY method/function's source (no cheap name-gate), so on a repo
216
- // with a huge file this is the heaviest synthesis pass — yield mid-scan so it
217
- // can't wedge the #850 watchdog on its own (#1091).
253
+ // Slices EVERY Swift/Kotlin method/function's source (no cheap name-gate), so
254
+ // on a repo with a huge file this is the heaviest synthesis pass — yield
255
+ // mid-scan (and mid-match-loop below: a single generated function dense with
256
+ // matches must not starve the watchdog either) so it can't wedge the #850
257
+ // watchdog on its own (#1091, #1235).
218
258
  let scanned = 0;
259
+ let matchTick = 0;
219
260
  for (const m of methodAndFunctionNodes(queries)) {
220
261
  if ((++scanned & 127) === 0)
221
262
  await onYield();
263
+ if (!CC_LANGUAGES.has(m.language))
264
+ continue;
222
265
  const content = ctx.readFile(m.filePath);
223
266
  const src = content && sliceLines(content, m.startLine, m.endLine);
224
267
  if (!src)
@@ -227,11 +270,13 @@ async function closureCollectionEdges(queries, ctx, onYield) {
227
270
  const hasAppend = src.includes('.append(') || src.includes('.add(') || src.includes('.push(') || src.includes('.insert(');
228
271
  if (!hasForEach && !hasAppend)
229
272
  continue;
230
- const lineAt = (idx) => (m.startLine ?? 1) + src.slice(0, idx).split('\n').length - 1;
273
+ const lineAt = makeLineAt(src, m.startLine ?? 1);
231
274
  if (hasForEach) {
232
275
  CC_DISPATCH_RE.lastIndex = 0;
233
276
  let d;
234
277
  while ((d = CC_DISPATCH_RE.exec(src))) {
278
+ if ((++matchTick & 255) === 0)
279
+ await onYield();
235
280
  const arr = dispatchers.get(d[1]) ?? [];
236
281
  if (!arr.some((n) => n.node.id === m.id))
237
282
  arr.push({ node: m, line: lineAt(d.index) });
@@ -241,12 +286,18 @@ async function closureCollectionEdges(queries, ctx, onYield) {
241
286
  if (hasAppend) {
242
287
  CC_APPEND_WRITE_RE.lastIndex = 0;
243
288
  let w;
244
- while ((w = CC_APPEND_WRITE_RE.exec(src)))
289
+ while ((w = CC_APPEND_WRITE_RE.exec(src))) {
290
+ if ((++matchTick & 255) === 0)
291
+ await onYield();
245
292
  addReg(w[2] || w[1], m, lineAt(w.index)); // nested `$0.streams` else the `.write` receiver
293
+ }
246
294
  CC_APPEND_DIRECT_RE.lastIndex = 0;
247
295
  let a;
248
- while ((a = CC_APPEND_DIRECT_RE.exec(src)))
296
+ while ((a = CC_APPEND_DIRECT_RE.exec(src))) {
297
+ if ((++matchTick & 255) === 0)
298
+ await onYield();
249
299
  addReg(a[1], m, lineAt(a.index));
300
+ }
250
301
  }
251
302
  }
252
303
  const edges = [];
@@ -293,7 +344,7 @@ async function eventEmitterEdges(ctx, onYield) {
293
344
  if (!hasEmit && !hasOn)
294
345
  continue;
295
346
  const nodesInFile = ctx.getNodesInFile(file);
296
- const lineOf = (idx) => content.slice(0, idx).split('\n').length;
347
+ const lineOf = makeLineAt(content, 1);
297
348
  if (hasEmit) {
298
349
  EMIT_RE.lastIndex = 0;
299
350
  let m;
@@ -1434,7 +1485,7 @@ async function rnEventEdges(ctx, onYield) {
1434
1485
  if (!content)
1435
1486
  continue;
1436
1487
  const nodesInFile = ctx.getNodesInFile(file);
1437
- const lineOf = (idx) => content.slice(0, idx).split('\n').length;
1488
+ const lineOf = makeLineAt(content, 1);
1438
1489
  const addDispatcher = (event, line) => {
1439
1490
  const disp = enclosingFn(nodesInFile, line);
1440
1491
  if (!disp)