scip-query 0.3.4 → 0.4.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.
Files changed (154) hide show
  1. package/README.md +2 -26
  2. package/dist/{chunk-FYYOWQXK.js → chunk-2F2WH5WQ.js} +19 -36
  3. package/dist/{chunk-C7H5WBTJ.js → chunk-2UISVZGQ.js} +2 -2
  4. package/dist/{chunk-HLKAFWWJ.js → chunk-4ZT7UGWW.js} +56 -91
  5. package/dist/chunk-5AJJGPZE.js +60 -0
  6. package/dist/chunk-5RKYZSQ6.js +75 -0
  7. package/dist/chunk-7YBLWIXY.js +115 -0
  8. package/dist/{chunk-O7Q7FDUJ.js → chunk-A4GWYETB.js} +2 -2
  9. package/dist/{chunk-CHDJXYBG.js → chunk-A5BGEBM7.js} +2 -2
  10. package/dist/{chunk-KKCHYLVI.js → chunk-A7YY7IDA.js} +2 -2
  11. package/dist/chunk-AS7N27JK.js +115 -0
  12. package/dist/{chunk-F7XU27LU.js → chunk-CQRYLK33.js} +26 -2
  13. package/dist/{chunk-NFS5W3PP.js → chunk-CQUNEJYM.js} +2 -2
  14. package/dist/chunk-D4I3ZMN5.js +38 -0
  15. package/dist/{chunk-J3JSOSUO.js → chunk-E7J7Q7UW.js} +2 -2
  16. package/dist/{chunk-GEXE2T6I.js → chunk-EOHPASDV.js} +22 -14
  17. package/dist/chunk-FVH3Y44U.js +1 -0
  18. package/dist/chunk-GIBETK3W.js +37 -0
  19. package/dist/{chunk-SMDCNPMK.js → chunk-H3FPW5YN.js} +2 -2
  20. package/dist/{chunk-GJDHTTR2.js → chunk-HNURMDF4.js} +32 -17
  21. package/dist/{chunk-7KIMF5PV.js → chunk-HRDPUTIQ.js} +2 -2
  22. package/dist/{chunk-OIDHN6GD.js → chunk-I2JM34UV.js} +146 -5
  23. package/dist/{chunk-EPWLXXBL.js → chunk-IV6NZ426.js} +27 -29
  24. package/dist/{chunk-VT4JBH6L.js → chunk-KDCQJTYW.js} +2 -2
  25. package/dist/{chunk-5OMVSV6E.js → chunk-LOVDB4C6.js} +2 -2
  26. package/dist/chunk-MA3B3IUT.js +75 -0
  27. package/dist/{chunk-26DOJ63W.js → chunk-N2LH3M2P.js} +13 -2
  28. package/dist/chunk-NWCJWA36.js +162 -0
  29. package/dist/{chunk-NG5F43OU.js → chunk-P3VCDYMJ.js} +70 -1
  30. package/dist/{chunk-P3E6L7KW.js → chunk-P42KQKJZ.js} +83 -3
  31. package/dist/{chunk-YDBXNPYU.js → chunk-PGHN5UTM.js} +2 -2
  32. package/dist/{chunk-UGQKAVCD.js → chunk-QCYR4S6T.js} +2 -2
  33. package/dist/chunk-QGCEAVJD.js +2529 -0
  34. package/dist/{chunk-KBOQX573.js → chunk-RIEA5DOB.js} +19 -2
  35. package/dist/{chunk-VIYSWZCO.js → chunk-SL674KAW.js} +31 -3
  36. package/dist/chunk-SRELHCMG.js +110 -0
  37. package/dist/chunk-UTRKBUCB.js +87 -0
  38. package/dist/{chunk-HJZUSUPU.js → chunk-VCOJRQPP.js} +5 -5
  39. package/dist/chunk-VISMEWYP.js +34 -0
  40. package/dist/{chunk-LFJQVJYJ.js → chunk-VU7FDTWV.js} +2 -2
  41. package/dist/{chunk-HLUS2HEB.js → chunk-VUBLUTMU.js} +5 -4
  42. package/dist/{chunk-WGAD3GNR.js → chunk-WNPF2I25.js} +5 -5
  43. package/dist/{chunk-YY4QGUQ5.js → chunk-X3J4VPWM.js} +2 -2
  44. package/dist/{chunk-GSH2FPKV.js → chunk-XH56HXLC.js} +2 -2
  45. package/dist/{chunk-DH7G3DDV.js → chunk-ZU2AQQB5.js} +2 -2
  46. package/dist/cli.js +2722 -1036
  47. package/dist/{db-ShvwGDKf.d.ts → db-C4rPbKkI.d.ts} +7 -14
  48. package/dist/index.d.ts +4 -5
  49. package/dist/index.js +378 -149
  50. package/dist/postinstall.js +9 -3
  51. package/dist/queries/affected.d.ts +1 -1
  52. package/dist/queries/affected.js +2 -2
  53. package/dist/queries/bottlenecks.d.ts +1 -1
  54. package/dist/queries/bottlenecks.js +2 -1
  55. package/dist/queries/by-kind.d.ts +1 -1
  56. package/dist/queries/by-kind.js +2 -1
  57. package/dist/queries/call-graph.d.ts +1 -1
  58. package/dist/queries/call-graph.js +2 -2
  59. package/dist/queries/change-surface.d.ts +1 -1
  60. package/dist/queries/change-surface.js +2 -2
  61. package/dist/queries/code.d.ts +1 -1
  62. package/dist/queries/code.js +2 -2
  63. package/dist/queries/complexity-hotspots.d.ts +1 -1
  64. package/dist/queries/complexity-hotspots.js +2 -2
  65. package/dist/queries/complexity.d.ts +1 -1
  66. package/dist/queries/complexity.js +2 -2
  67. package/dist/queries/convergence.d.ts +1 -1
  68. package/dist/queries/convergence.js +2 -2
  69. package/dist/queries/coupling.d.ts +1 -1
  70. package/dist/queries/coupling.js +2 -2
  71. package/dist/queries/cycles.d.ts +1 -1
  72. package/dist/queries/cycles.js +2 -2
  73. package/dist/queries/dataflow.d.ts +1 -1
  74. package/dist/queries/dataflow.js +2 -2
  75. package/dist/queries/dead.d.ts +1 -1
  76. package/dist/queries/dead.js +3 -3
  77. package/dist/queries/deep-chains.d.ts +1 -1
  78. package/dist/queries/deep-chains.js +2 -2
  79. package/dist/queries/deps.d.ts +1 -1
  80. package/dist/queries/deps.js +2 -2
  81. package/dist/queries/diff-impact.d.ts +1 -1
  82. package/dist/queries/drift.d.ts +1 -1
  83. package/dist/queries/drift.js +2 -2
  84. package/dist/queries/extract-candidates.d.ts +1 -1
  85. package/dist/queries/extract-candidates.js +2 -2
  86. package/dist/queries/fan.d.ts +1 -1
  87. package/dist/queries/fan.js +2 -2
  88. package/dist/queries/files.d.ts +1 -1
  89. package/dist/queries/health.d.ts +1 -1
  90. package/dist/queries/health.js +13 -13
  91. package/dist/queries/hierarchy.d.ts +1 -1
  92. package/dist/queries/hierarchy.js +2 -2
  93. package/dist/queries/hotspots.d.ts +1 -1
  94. package/dist/queries/hotspots.js +2 -1
  95. package/dist/queries/imports.d.ts +1 -1
  96. package/dist/queries/imports.js +2 -2
  97. package/dist/queries/index.d.ts +1 -2
  98. package/dist/queries/index.js +49 -53
  99. package/dist/queries/isolated.d.ts +3 -4
  100. package/dist/queries/isolated.js +3 -3
  101. package/dist/queries/members.d.ts +1 -1
  102. package/dist/queries/members.js +2 -2
  103. package/dist/queries/methods.d.ts +1 -1
  104. package/dist/queries/methods.js +2 -1
  105. package/dist/queries/outline.d.ts +1 -1
  106. package/dist/queries/outline.js +2 -2
  107. package/dist/queries/passthrough-candidates.d.ts +1 -1
  108. package/dist/queries/passthrough-candidates.js +2 -2
  109. package/dist/queries/redundant-reexports.d.ts +1 -1
  110. package/dist/queries/redundant-reexports.js +3 -3
  111. package/dist/queries/refs.d.ts +1 -1
  112. package/dist/queries/refs.js +2 -2
  113. package/dist/queries/similar-chains.d.ts +1 -1
  114. package/dist/queries/similar-chains.js +2 -2
  115. package/dist/queries/similar-files.d.ts +1 -1
  116. package/dist/queries/similar-files.js +2 -2
  117. package/dist/queries/similar-signatures.d.ts +5 -3
  118. package/dist/queries/similar-signatures.js +2 -1
  119. package/dist/queries/similar.d.ts +1 -1
  120. package/dist/queries/similar.js +2 -2
  121. package/dist/queries/slice.d.ts +1 -1
  122. package/dist/queries/slice.js +2 -2
  123. package/dist/queries/stale-abstractions.d.ts +1 -1
  124. package/dist/queries/stale-abstractions.js +2 -2
  125. package/dist/queries/stats.d.ts +1 -1
  126. package/dist/queries/surface.d.ts +1 -1
  127. package/dist/queries/surface.js +2 -2
  128. package/dist/queries/symbols.d.ts +1 -1
  129. package/dist/queries/symbols.js +2 -2
  130. package/dist/queries/system.d.ts +1 -1
  131. package/dist/queries/system.js +2 -2
  132. package/dist/queries/trace.d.ts +1 -1
  133. package/dist/queries/trace.js +2 -2
  134. package/dist/queries/wrapper-candidates.d.ts +1 -1
  135. package/dist/queries/wrapper-candidates.js +2 -2
  136. package/dist/reindex-worker.js +213 -62
  137. package/package.json +1 -1
  138. package/skills/scip-language-playbook/SKILL.md +371 -0
  139. package/dist/chunk-2UELLEBI.js +0 -1
  140. package/dist/chunk-4JCSOF2O.js +0 -97
  141. package/dist/chunk-AXQKUYKF.js +0 -1442
  142. package/dist/chunk-CPVAQJEC.js +0 -46
  143. package/dist/chunk-EOROMIFO.js +0 -41
  144. package/dist/chunk-GU2H5QRN.js +0 -28
  145. package/dist/chunk-LQJUPXQY.js +0 -109
  146. package/dist/chunk-MPGIHELS.js +0 -39
  147. package/dist/chunk-P4WO3BBW.js +0 -64
  148. package/dist/chunk-TOIEB3LG.js +0 -78
  149. package/dist/chunk-UQEQ6AHX.js +0 -60
  150. package/dist/chunk-VJJKSGIX.js +0 -121
  151. package/dist/chunk-YZ6L7GFO.js +0 -73
  152. package/dist/chunk-ZEUCXQBN.js +0 -71
  153. package/dist/queries/doc-coverage.d.ts +0 -14
  154. package/dist/queries/doc-coverage.js +0 -8
@@ -1,3 +1,7 @@
1
+ import {
2
+ getAllDefinitions,
3
+ getCallerRowsForSymbol
4
+ } from "./chunk-QGCEAVJD.js";
1
5
  import {
2
6
  shortenSymbol
3
7
  } from "./chunk-QIXNAB5K.js";
@@ -27,16 +31,29 @@ function hotspots(db, opts = {}) {
27
31
  LIMIT ?`,
28
32
  limit
29
33
  );
30
- return rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
34
+ const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
31
35
  symbol: r.symbol,
32
36
  shortName: shortenSymbol(r.symbol),
33
37
  refCount: r.ref_count,
34
38
  fileCount: r.file_count,
35
39
  definedIn: r.defined_in
36
40
  }));
41
+ if (indexedResults.length > 0) {
42
+ return indexedResults;
43
+ }
44
+ return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
45
+ const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
46
+ return {
47
+ symbol: definition.symbol,
48
+ shortName: shortenSymbol(definition.symbol),
49
+ refCount: callerRows.length,
50
+ fileCount: new Set(callerRows.map((row) => row.file)).size,
51
+ definedIn: definition.relativePath
52
+ };
53
+ }).filter((row) => row.refCount > 0).sort((left, right) => right.refCount - left.refCount || right.fileCount - left.fileCount).slice(0, limit);
37
54
  }
38
55
 
39
56
  export {
40
57
  hotspots
41
58
  };
42
- //# sourceMappingURL=chunk-KBOQX573.js.map
59
+ //# sourceMappingURL=chunk-RIEA5DOB.js.map
@@ -1,6 +1,9 @@
1
1
  import {
2
+ getAllDefinitions,
3
+ getCalleeRowsForSymbol,
4
+ getCallerRowsForSymbol,
2
5
  testFileExclusionSql
3
- } from "./chunk-AXQKUYKF.js";
6
+ } from "./chunk-QGCEAVJD.js";
4
7
  import {
5
8
  shortenSymbol
6
9
  } from "./chunk-QIXNAB5K.js";
@@ -80,7 +83,7 @@ function complexityHotspots(db, opts) {
80
83
  minLoc,
81
84
  limit
82
85
  );
83
- return rows.filter((r) => !db.isIgnored(r.file)).map((r) => ({
86
+ const indexedResults = rows.filter((r) => !db.isIgnored(r.file)).map((r) => ({
84
87
  symbol: r.symbol,
85
88
  shortName: shortenSymbol(r.symbol),
86
89
  file: r.file,
@@ -94,9 +97,34 @@ function complexityHotspots(db, opts) {
94
97
  r.loc / 50 * (r.fan_in / 5) * Math.max(r.fan_out / 5, 1) * 100
95
98
  ) / 100
96
99
  }));
100
+ if (indexedResults.length > 0) {
101
+ return indexedResults;
102
+ }
103
+ return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
104
+ const loc = definition.endLine - definition.startLine + 1;
105
+ const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
106
+ const calleeRows = getCalleeRowsForSymbol(db, definition, { limit: 500 });
107
+ const fanIn = new Set(callerRows.map((row) => row.file)).size;
108
+ const fanOut = new Set(
109
+ calleeRows.filter((row) => row.file !== definition.relativePath).map((row) => `${row.symbol}|${row.file}`)
110
+ ).size;
111
+ const calleeCount = new Set(calleeRows.map((row) => `${row.symbol}|${row.file}`)).size;
112
+ return {
113
+ symbol: definition.symbol,
114
+ shortName: shortenSymbol(definition.symbol),
115
+ file: definition.relativePath,
116
+ startLine: definition.startLine,
117
+ endLine: definition.endLine,
118
+ loc,
119
+ fanIn,
120
+ fanOut,
121
+ calleeCount,
122
+ score: Math.round(loc / 50 * (fanIn / 5) * Math.max(fanOut / 5, 1) * 100) / 100
123
+ };
124
+ }).filter((row) => row.loc >= minLoc).sort((left, right) => right.score - left.score || right.loc - left.loc).slice(0, limit);
97
125
  }
98
126
 
99
127
  export {
100
128
  complexityHotspots
101
129
  };
102
- //# sourceMappingURL=chunk-VIYSWZCO.js.map
130
+ //# sourceMappingURL=chunk-SL674KAW.js.map
@@ -0,0 +1,110 @@
1
+ import {
2
+ getInactiveBarrelPaths,
3
+ isEntrySurface
4
+ } from "./chunk-X3J4VPWM.js";
5
+ import {
6
+ TEST_FILE_PATTERNS,
7
+ TEST_SUPPORT_PATH_PATTERNS,
8
+ getAllDefinitions
9
+ } from "./chunk-QGCEAVJD.js";
10
+ import {
11
+ isFunctionLikeSymbol,
12
+ isModuleLikeSymbol,
13
+ shortenSymbol
14
+ } from "./chunk-QIXNAB5K.js";
15
+
16
+ // src/queries/dead.ts
17
+ function dead(db, opts = {}) {
18
+ const {
19
+ scope,
20
+ minLoc = 1,
21
+ includeTests = false,
22
+ skipBarrels = false,
23
+ includeMembers = false
24
+ } = opts;
25
+ const inactiveBarrelPaths = skipBarrels ? new Set(getInactiveBarrelPaths(db)) : /* @__PURE__ */ new Set();
26
+ const referenceRows = db.all(
27
+ `SELECT
28
+ m.symbol_id,
29
+ d.relative_path,
30
+ COUNT(*) AS ref_count
31
+ FROM mentions m
32
+ JOIN chunks c ON m.chunk_id = c.id
33
+ JOIN documents d ON c.document_id = d.id
34
+ WHERE m.role != 1
35
+ ${db.pathExclusionsFor("d")}
36
+ GROUP BY m.symbol_id, d.relative_path`
37
+ );
38
+ const referencesBySymbol = /* @__PURE__ */ new Map();
39
+ for (const row of referenceRows) {
40
+ if (db.isIgnored(row.relative_path)) continue;
41
+ if (inactiveBarrelPaths.has(row.relative_path)) continue;
42
+ let refsForSymbol = referencesBySymbol.get(row.symbol_id);
43
+ if (!refsForSymbol) {
44
+ refsForSymbol = /* @__PURE__ */ new Map();
45
+ referencesBySymbol.set(row.symbol_id, refsForSymbol);
46
+ }
47
+ refsForSymbol.set(row.relative_path, row.ref_count);
48
+ }
49
+ const definitions = getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isModuleLikeSymbol(definition.symbol)).filter((definition) => looksValueLikeDefinition(definition.symbol)).filter((definition) => definition.isFunctionLike || !definition.enclosingSymbol || !looksValueLikeDefinition(definition.enclosingSymbol)).filter((definition) => includeTests || passesTestFileFilter(definition.relativePath)).filter((definition) => includeMembers || looksValueLikeDefinition(definition.symbol)).filter((definition) => definition.endLine - definition.startLine + 1 >= minLoc);
50
+ const rows = definitions.map((definition) => {
51
+ const refMap = referencesBySymbol.get(definition.symbolId) ?? /* @__PURE__ */ new Map();
52
+ const sameFileRefs = refMap.get(definition.relativePath) ?? 0;
53
+ let crossFileRefs = 0;
54
+ for (const [relativePath, count] of refMap) {
55
+ if (relativePath === definition.relativePath) continue;
56
+ crossFileRefs += count;
57
+ }
58
+ return {
59
+ relative_path: definition.relativePath,
60
+ start_line: definition.startLine,
61
+ end_line: definition.endLine,
62
+ loc: definition.endLine - definition.startLine + 1,
63
+ symbol: definition.symbol,
64
+ same_file_refs: sameFileRefs,
65
+ cross_file_refs: crossFileRefs
66
+ };
67
+ }).filter((row) => row.cross_file_refs === 0).sort((a, b) => b.loc - a.loc || a.relative_path.localeCompare(b.relative_path) || a.start_line - b.start_line);
68
+ let deadCodeCount = 0;
69
+ let fileInternalCount = 0;
70
+ let totalLoc = 0;
71
+ const symbols = rows.filter((r) => !db.isIgnored(r.relative_path)).filter((r) => !isEntrySurface(db, r.relative_path)).map((r) => {
72
+ const kind = r.same_file_refs === 0 ? "dead-code" : "file-internal";
73
+ if (kind === "dead-code") deadCodeCount++;
74
+ else fileInternalCount++;
75
+ totalLoc += r.loc;
76
+ return {
77
+ relativePath: r.relative_path,
78
+ startLine: r.start_line,
79
+ endLine: r.end_line,
80
+ loc: r.loc,
81
+ symbol: r.symbol,
82
+ shortName: shortenSymbol(r.symbol),
83
+ sameFileRefs: r.same_file_refs,
84
+ kind
85
+ };
86
+ });
87
+ return {
88
+ symbols,
89
+ totalCount: symbols.length,
90
+ deadCodeCount,
91
+ fileInternalCount,
92
+ totalLoc
93
+ };
94
+ }
95
+ function passesTestFileFilter(relativePath) {
96
+ const patterns = [.../* @__PURE__ */ new Set([...TEST_FILE_PATTERNS, ...TEST_SUPPORT_PATH_PATTERNS])];
97
+ return patterns.every((pattern) => !likeMatches(relativePath, pattern));
98
+ }
99
+ function likeMatches(value, pattern) {
100
+ const regex = new RegExp(`^${pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/%/g, ".*").replace(/_/g, ".")}$`);
101
+ return regex.test(value);
102
+ }
103
+ function looksValueLikeDefinition(rawSymbol) {
104
+ return isFunctionLikeSymbol(rawSymbol) || rawSymbol.endsWith("().") || rawSymbol.endsWith(".");
105
+ }
106
+
107
+ export {
108
+ dead
109
+ };
110
+ //# sourceMappingURL=chunk-SRELHCMG.js.map
@@ -0,0 +1,87 @@
1
+ import {
2
+ findExactSymbolMatch,
3
+ findFirstSymbolMatch,
4
+ getCallerRowsForSymbol
5
+ } from "./chunk-QGCEAVJD.js";
6
+ import {
7
+ shortenSymbol
8
+ } from "./chunk-QIXNAB5K.js";
9
+
10
+ // src/queries/affected.ts
11
+ function affected(db, symbolPattern, opts = {}) {
12
+ const { maxDepth = 5, scope } = opts;
13
+ const target = findFirstSymbolMatch(db, symbolPattern);
14
+ if (!target) return [];
15
+ const results = [];
16
+ const visited = /* @__PURE__ */ new Set([target.symbolId]);
17
+ const seenResults = /* @__PURE__ */ new Set();
18
+ let frontier = [target];
19
+ for (let depth = 1; depth <= maxDepth; depth++) {
20
+ if (frontier.length === 0) break;
21
+ const nextFrontier = [];
22
+ for (const current of frontier) {
23
+ for (const row of getDirectAffectedRows(db, current, scope)) {
24
+ const resultKey = `${row.file}|${row.shortName}`;
25
+ if (row.symbolId !== null) {
26
+ if (visited.has(row.symbolId)) continue;
27
+ visited.add(row.symbolId);
28
+ } else if (seenResults.has(resultKey)) {
29
+ continue;
30
+ }
31
+ seenResults.add(resultKey);
32
+ results.push({
33
+ symbol: row.symbol,
34
+ shortName: row.shortName,
35
+ file: row.file,
36
+ depth
37
+ });
38
+ if (row.symbolId !== null && row.symbolMatch) {
39
+ nextFrontier.push(row.symbolMatch);
40
+ }
41
+ }
42
+ }
43
+ frontier = nextFrontier;
44
+ }
45
+ results.sort((a, b) => a.depth - b.depth || a.file.localeCompare(b.file));
46
+ return results;
47
+ }
48
+ function getDirectAffectedRows(db, target, scope) {
49
+ const callerRows = getCallerRowsForSymbol(db, target, { limit: 500 }).filter((row) => !db.isIgnored(row.file)).filter((row) => !scope || row.file.includes(scope));
50
+ const results = [];
51
+ const seen = /* @__PURE__ */ new Set();
52
+ for (const row of callerRows) {
53
+ const match = findExactSymbolMatch(db, row.symbol);
54
+ if (!match) {
55
+ const key2 = `${row.file}|${row.symbol}`;
56
+ if (seen.has(key2)) continue;
57
+ seen.add(key2);
58
+ results.push({
59
+ symbolId: null,
60
+ symbol: row.symbol,
61
+ shortName: shortenSymbol(row.symbol),
62
+ file: row.file,
63
+ symbolMatch: null
64
+ });
65
+ continue;
66
+ }
67
+ if (match.symbolId === target.symbolId || db.isIgnored(match.relativePath)) {
68
+ continue;
69
+ }
70
+ const key = `${match.symbolId}|${match.relativePath}`;
71
+ if (seen.has(key)) continue;
72
+ seen.add(key);
73
+ results.push({
74
+ symbolId: match.symbolId,
75
+ symbol: match.symbol,
76
+ shortName: shortenSymbol(match.symbol),
77
+ file: match.relativePath,
78
+ symbolMatch: match
79
+ });
80
+ }
81
+ return results;
82
+ }
83
+
84
+ export {
85
+ affected
86
+ };
87
+ //# sourceMappingURL=chunk-UTRKBUCB.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  findFirstSymbolMatch,
3
3
  getCalleeRowsForSymbol
4
- } from "./chunk-AXQKUYKF.js";
4
+ } from "./chunk-QGCEAVJD.js";
5
5
  import {
6
6
  shortenSymbol
7
7
  } from "./chunk-QIXNAB5K.js";
@@ -37,11 +37,11 @@ function convergence(db, symbolPatternA, symbolPatternB) {
37
37
  } else if (shared.length === 0) {
38
38
  strategy = "These functions do not share any callees. They are not a callee-based consolidation candidate.";
39
39
  } else if (uniqueA.length === 0 && uniqueB.length === 0) {
40
- strategy = "These functions have identical callee sets. One can replace the other directly.";
40
+ strategy = "These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.";
41
41
  } else if (uniqueA.length === 0) {
42
- strategy = `A is a subset of B. A can be replaced by calling B (B does everything A does plus more).`;
42
+ strategy = `A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.`;
43
43
  } else if (uniqueB.length === 0) {
44
- strategy = `B is a subset of A. B can be replaced by calling A (A does everything B does plus more).`;
44
+ strategy = `B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.`;
45
45
  } else if (uniqueA.length <= 2 && uniqueB.length <= 2) {
46
46
  strategy = `Create a shared function with the ${shared.length} common callees. Pass the ${uniqueA.length + uniqueB.length} divergent callees as parameters or strategy callbacks.`;
47
47
  } else {
@@ -73,4 +73,4 @@ function convergence(db, symbolPatternA, symbolPatternB) {
73
73
  export {
74
74
  convergence
75
75
  };
76
- //# sourceMappingURL=chunk-HJZUSUPU.js.map
76
+ //# sourceMappingURL=chunk-VCOJRQPP.js.map
@@ -0,0 +1,34 @@
1
+ import {
2
+ isEntrySurface
3
+ } from "./chunk-X3J4VPWM.js";
4
+ import {
5
+ getAllDefinitions,
6
+ getCalleeRowsForSymbol,
7
+ getCallerRowsForSymbol
8
+ } from "./chunk-QGCEAVJD.js";
9
+ import {
10
+ shortenSymbol
11
+ } from "./chunk-QIXNAB5K.js";
12
+
13
+ // src/queries/isolated.ts
14
+ function isolated(db, opts = {}) {
15
+ const { scope, minLoc = 3 } = opts;
16
+ return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isEntrySurface(db, definition.relativePath)).filter((definition) => definition.isFunctionLike).map((definition) => ({
17
+ definition,
18
+ loc: definition.endLine - definition.startLine + 1
19
+ })).filter((entry) => entry.loc >= minLoc).filter((entry) => getCallerRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).filter((entry) => getCalleeRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).sort(
20
+ (left, right) => right.loc - left.loc || left.definition.relativePath.localeCompare(right.definition.relativePath) || left.definition.startLine - right.definition.startLine
21
+ ).map((entry) => ({
22
+ symbol: entry.definition.symbol,
23
+ shortName: shortenSymbol(entry.definition.symbol),
24
+ relativePath: entry.definition.relativePath,
25
+ startLine: entry.definition.startLine,
26
+ endLine: entry.definition.endLine,
27
+ loc: entry.loc
28
+ }));
29
+ }
30
+
31
+ export {
32
+ isolated
33
+ };
34
+ //# sourceMappingURL=chunk-VISMEWYP.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-QGCEAVJD.js";
4
4
 
5
5
  // src/queries/cycles.ts
6
6
  function cycles(db, opts = {}) {
@@ -58,4 +58,4 @@ function cycles(db, opts = {}) {
58
58
  export {
59
59
  cycles
60
60
  };
61
- //# sourceMappingURL=chunk-LFJQVJYJ.js.map
61
+ //# sourceMappingURL=chunk-VU7FDTWV.js.map
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-QGCEAVJD.js";
4
4
 
5
5
  // src/queries/similar-files.ts
6
6
  function similarFiles(db, opts = {}) {
7
- const { minSimilarity = 0.5, limit = 20, scope, minDeps = 3, filePattern } = opts;
7
+ const { minSimilarity = 0.5, limit = 20, scope, filePattern } = opts;
8
+ const minDeps = opts.minDeps ?? (filePattern ? 1 : 3);
8
9
  const profiles = buildFileProfiles(db, { scope, minDeps });
9
10
  const results = [];
10
11
  if (filePattern) {
@@ -53,7 +54,7 @@ function findUniversalDependencies(depMap) {
53
54
  }
54
55
  }
55
56
  for (const [dep, count] of depCounts) {
56
- if (count / fileCount > 0.5) {
57
+ if (count >= 6 && count / fileCount > 0.8) {
57
58
  universalDeps.add(dep);
58
59
  }
59
60
  }
@@ -89,4 +90,4 @@ function compareProfiles(a, b, minSimilarity) {
89
90
  export {
90
91
  similarFiles
91
92
  };
92
- //# sourceMappingURL=chunk-HLUS2HEB.js.map
93
+ //# sourceMappingURL=chunk-VUBLUTMU.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-QGCEAVJD.js";
4
4
 
5
5
  // src/queries/similar-chains.ts
6
6
  function similarChains(db, opts = {}) {
@@ -28,8 +28,8 @@ function similarChains(db, opts = {}) {
28
28
  tailFreq.set(chain[t], (tailFreq.get(chain[t]) ?? 0) + 1);
29
29
  }
30
30
  }
31
- const infraThreshold = rawChains.length * 0.4;
32
- const tailThreshold = rawChains.length * 0.3;
31
+ const infraThreshold = rawChains.length * 0.9;
32
+ const tailThreshold = rawChains.length * 0.8;
33
33
  const infraNodes = /* @__PURE__ */ new Set();
34
34
  for (const [node, freq] of nodeFreq) {
35
35
  if (freq > infraThreshold) infraNodes.add(node);
@@ -45,7 +45,7 @@ function similarChains(db, opts = {}) {
45
45
  const filteredChains = [];
46
46
  for (const chain of rawChains) {
47
47
  const filtered = chain.filter((n) => !infraNodes.has(n));
48
- if (filtered.length >= 3) {
48
+ if (filtered.length >= 2) {
49
49
  filteredChains.push({ original: chain, filtered });
50
50
  }
51
51
  }
@@ -210,4 +210,4 @@ function isSubChain(sub, full) {
210
210
  export {
211
211
  similarChains
212
212
  };
213
- //# sourceMappingURL=chunk-WGAD3GNR.js.map
213
+ //# sourceMappingURL=chunk-WNPF2I25.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-QGCEAVJD.js";
4
4
 
5
5
  // src/entry-surfaces.ts
6
6
  var liveBarrelCache = /* @__PURE__ */ new WeakMap();
@@ -81,4 +81,4 @@ export {
81
81
  isEntrySurface,
82
82
  getInactiveBarrelPaths
83
83
  };
84
- //# sourceMappingURL=chunk-YY4QGUQ5.js.map
84
+ //# sourceMappingURL=chunk-X3J4VPWM.js.map
@@ -2,7 +2,7 @@ import {
2
2
  findFirstSymbolMatch,
3
3
  getCalleeRowsForSymbol,
4
4
  getSourceReferenceSites
5
- } from "./chunk-AXQKUYKF.js";
5
+ } from "./chunk-QGCEAVJD.js";
6
6
  import {
7
7
  shortenSymbol
8
8
  } from "./chunk-QIXNAB5K.js";
@@ -84,4 +84,4 @@ function uniqueSymbolRows(rows) {
84
84
  export {
85
85
  dataflow
86
86
  };
87
- //# sourceMappingURL=chunk-GSH2FPKV.js.map
87
+ //# sourceMappingURL=chunk-XH56HXLC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-QGCEAVJD.js";
4
4
 
5
5
  // src/queries/deep-chains.ts
6
6
  function deepChains(db, opts = {}) {
@@ -41,4 +41,4 @@ function deepChains(db, opts = {}) {
41
41
  export {
42
42
  deepChains
43
43
  };
44
- //# sourceMappingURL=chunk-DH7G3DDV.js.map
44
+ //# sourceMappingURL=chunk-ZU2AQQB5.js.map