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,46 +0,0 @@
1
- import {
2
- cleanSignature
3
- } from "./chunk-4TYLS5XX.js";
4
- import {
5
- resolveIndexedPaths
6
- } from "./chunk-AXQKUYKF.js";
7
- import {
8
- shortenSymbol
9
- } from "./chunk-QIXNAB5K.js";
10
-
11
- // src/queries/symbols.ts
12
- function symbols(db, filePattern) {
13
- const resolvedPaths = resolveIndexedPaths(db, filePattern);
14
- if (resolvedPaths.length === 0) {
15
- return [];
16
- }
17
- const placeholders = resolvedPaths.map(() => "?").join(", ");
18
- const rows = db.all(
19
- `SELECT
20
- der.start_line,
21
- der.end_line,
22
- REPLACE(SUBSTR(gs.documentation, INSTR(gs.documentation, '|') + 1), char(10), ' ') AS sig,
23
- gs.symbol,
24
- d.relative_path
25
- FROM defn_enclosing_ranges der
26
- JOIN global_symbols gs ON der.symbol_id = gs.id
27
- JOIN documents d ON der.document_id = d.id
28
- WHERE d.relative_path IN (${placeholders})
29
- AND ${db.localSymbolPredicate}
30
- ${db.symbolNoise}
31
- ORDER BY d.relative_path, der.start_line`,
32
- ...resolvedPaths
33
- );
34
- return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
35
- startLine: r.start_line,
36
- endLine: r.end_line,
37
- symbol: r.symbol,
38
- shortName: shortenSymbol(r.symbol),
39
- signature: cleanSignature(r.sig)
40
- }));
41
- }
42
-
43
- export {
44
- symbols
45
- };
46
- //# sourceMappingURL=chunk-CPVAQJEC.js.map
@@ -1,41 +0,0 @@
1
- import {
2
- resolveIndexedPaths
3
- } from "./chunk-AXQKUYKF.js";
4
- import {
5
- shortenSymbol
6
- } from "./chunk-QIXNAB5K.js";
7
-
8
- // src/queries/surface.ts
9
- function surface(db, modulePattern) {
10
- const matchedPaths = resolveIndexedPaths(db, modulePattern);
11
- if (matchedPaths.length === 0) {
12
- return [];
13
- }
14
- const placeholders = matchedPaths.map(() => "?").join(", ");
15
- const rows = db.all(
16
- `SELECT DISTINCT d1.relative_path, gs.symbol
17
- FROM mentions m
18
- JOIN chunks c ON m.chunk_id = c.id
19
- JOIN documents d1 ON c.document_id = d1.id
20
- JOIN global_symbols gs ON m.symbol_id = gs.id
21
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
22
- JOIN documents d2 ON der.document_id = d2.id
23
- WHERE d2.relative_path IN (${placeholders})
24
- AND d1.relative_path NOT IN (${placeholders})
25
- AND ${db.localSymbolPredicate}
26
- AND m.role != 1
27
- ORDER BY d1.relative_path`,
28
- ...matchedPaths,
29
- ...matchedPaths
30
- );
31
- return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
32
- consumer: r.relative_path,
33
- symbol: r.symbol,
34
- shortName: shortenSymbol(r.symbol)
35
- }));
36
- }
37
-
38
- export {
39
- surface
40
- };
41
- //# sourceMappingURL=chunk-EOROMIFO.js.map
@@ -1,28 +0,0 @@
1
- import {
2
- leafName
3
- } from "./chunk-QIXNAB5K.js";
4
-
5
- // src/queries/methods.ts
6
- function methods(db, className) {
7
- const rows = db.all(
8
- `SELECT der.start_line, der.end_line, gs.symbol
9
- FROM global_symbols gs
10
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
11
- WHERE gs.symbol LIKE ?
12
- AND ${db.localSymbolPredicate}
13
- AND gs.symbol LIKE '%().%'
14
- ${db.symbolNoise}
15
- ORDER BY der.start_line`,
16
- `%${className}#%`
17
- );
18
- return rows.map((r) => ({
19
- startLine: r.start_line,
20
- endLine: r.end_line,
21
- name: leafName(r.symbol)
22
- }));
23
- }
24
-
25
- export {
26
- methods
27
- };
28
- //# sourceMappingURL=chunk-GU2H5QRN.js.map
@@ -1,109 +0,0 @@
1
- import {
2
- getInactiveBarrelPaths,
3
- isEntrySurface
4
- } from "./chunk-YY4QGUQ5.js";
5
- import {
6
- TEST_SUPPORT_PATH_PATTERNS,
7
- testFileExclusionSql
8
- } from "./chunk-AXQKUYKF.js";
9
- import {
10
- shortenSymbol
11
- } from "./chunk-QIXNAB5K.js";
12
-
13
- // src/queries/dead.ts
14
- function dead(db, opts = {}) {
15
- const {
16
- scope,
17
- minLoc = 1,
18
- includeTests = false,
19
- skipBarrels = false,
20
- includeMembers = false
21
- } = opts;
22
- const params = [minLoc];
23
- let testFileExclusions = "";
24
- let memberExclusion = "";
25
- let barrelExclusions = "";
26
- if (scope) {
27
- params.push(`%${scope}%`);
28
- }
29
- if (!includeTests) {
30
- testFileExclusions = `
31
- AND ${testFileExclusionSql("d", TEST_SUPPORT_PATH_PATTERNS)}
32
- `;
33
- }
34
- if (!includeMembers) {
35
- memberExclusion = `AND gs.symbol NOT LIKE '%#%'`;
36
- }
37
- if (skipBarrels) {
38
- const inactiveBarrelPaths = getInactiveBarrelPaths(db);
39
- if (inactiveBarrelPaths.length > 0) {
40
- barrelExclusions = `AND ref_d.relative_path NOT IN (${inactiveBarrelPaths.map(() => "?").join(", ")})`;
41
- params.push(...inactiveBarrelPaths);
42
- }
43
- }
44
- const sql = `
45
- SELECT
46
- d.relative_path,
47
- der.start_line,
48
- der.end_line,
49
- (der.end_line - der.start_line + 1) AS loc,
50
- gs.symbol,
51
- (SELECT COUNT(*) FROM mentions m2
52
- JOIN chunks c2 ON m2.chunk_id = c2.id
53
- WHERE m2.symbol_id = gs.id AND m2.role != 1 AND c2.document_id = d.id
54
- ) AS same_file_refs
55
- FROM global_symbols gs
56
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
57
- JOIN documents d ON der.document_id = d.id
58
- WHERE 1 = 1
59
- ${db.pathExclusionsFor("d")}
60
- ${db.symbolNoiseFor("gs")}
61
- AND (der.end_line - der.start_line + 1) >= ?
62
- ${scope ? "AND d.relative_path LIKE ?" : ""}
63
- ${testFileExclusions}
64
- ${memberExclusion}
65
- AND NOT EXISTS (
66
- SELECT 1
67
- FROM mentions ref_m
68
- JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
69
- JOIN documents ref_d ON ref_c.document_id = ref_d.id
70
- WHERE ref_m.symbol_id = gs.id
71
- AND ref_m.role != 1
72
- AND ref_d.id != d.id
73
- ${barrelExclusions}
74
- )
75
- ORDER BY (der.end_line - der.start_line + 1) DESC, d.relative_path, der.start_line
76
- `;
77
- const rows = db.all(sql, ...params);
78
- let deadCodeCount = 0;
79
- let fileInternalCount = 0;
80
- let totalLoc = 0;
81
- const symbols = rows.filter((r) => !db.isIgnored(r.relative_path)).filter((r) => !isEntrySurface(db, r.relative_path)).map((r) => {
82
- const kind = r.same_file_refs === 0 ? "dead-code" : "file-internal";
83
- if (kind === "dead-code") deadCodeCount++;
84
- else fileInternalCount++;
85
- totalLoc += r.loc;
86
- return {
87
- relativePath: r.relative_path,
88
- startLine: r.start_line,
89
- endLine: r.end_line,
90
- loc: r.loc,
91
- symbol: r.symbol,
92
- shortName: shortenSymbol(r.symbol),
93
- sameFileRefs: r.same_file_refs,
94
- kind
95
- };
96
- });
97
- return {
98
- symbols,
99
- totalCount: symbols.length,
100
- deadCodeCount,
101
- fileInternalCount,
102
- totalLoc
103
- };
104
- }
105
-
106
- export {
107
- dead
108
- };
109
- //# sourceMappingURL=chunk-LQJUPXQY.js.map
@@ -1,39 +0,0 @@
1
- import {
2
- findFirstSymbolMatch,
3
- getSourceReferenceSites
4
- } from "./chunk-AXQKUYKF.js";
5
-
6
- // src/queries/refs.ts
7
- function refs(db, symbolPattern) {
8
- const match = findFirstSymbolMatch(db, symbolPattern);
9
- if (match) {
10
- const sourceSites = getSourceReferenceSites(db, match).filter((site) => !db.isIgnored(site.file)).map((site) => ({
11
- relativePath: site.file,
12
- line: site.line
13
- }));
14
- if (sourceSites.length > 0) {
15
- return sourceSites;
16
- }
17
- }
18
- const rows = db.all(
19
- `SELECT DISTINCT d.relative_path, c.start_line
20
- FROM mentions m
21
- JOIN chunks c ON m.chunk_id = c.id
22
- JOIN documents d ON c.document_id = d.id
23
- JOIN global_symbols gs ON m.symbol_id = gs.id
24
- WHERE m.symbol_id = ?
25
- AND ${db.localSymbolPredicate}
26
- AND m.role != 1
27
- ORDER BY d.relative_path, c.start_line`,
28
- match?.symbolId ?? -1
29
- );
30
- return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
31
- relativePath: r.relative_path,
32
- line: r.start_line
33
- }));
34
- }
35
-
36
- export {
37
- refs
38
- };
39
- //# sourceMappingURL=chunk-MPGIHELS.js.map
@@ -1,64 +0,0 @@
1
- import {
2
- testFileExclusionSql
3
- } from "./chunk-AXQKUYKF.js";
4
- import {
5
- shortenSymbol
6
- } from "./chunk-QIXNAB5K.js";
7
-
8
- // src/queries/stale-abstractions.ts
9
- function staleAbstractions(db, opts) {
10
- const { scope, minLoc = 3, limit = 30 } = opts ?? {};
11
- const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
12
- const rows = db.all(
13
- `SELECT * FROM (
14
- SELECT
15
- gs.symbol,
16
- d.relative_path AS file,
17
- der.start_line,
18
- der.end_line,
19
- (der.end_line - der.start_line + 1) AS loc,
20
- (SELECT COUNT(DISTINCT ref_c.document_id)
21
- FROM mentions ref_m
22
- JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
23
- WHERE ref_m.symbol_id = gs.id
24
- AND ref_m.role != 1
25
- AND ref_c.document_id != der.document_id
26
- ) AS consumers
27
- FROM global_symbols gs
28
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
29
- JOIN documents d ON der.document_id = d.id
30
- WHERE 1 = 1
31
- ${db.pathExclusionsFor("d")}
32
- AND ${testFileExclusionSql("d")}
33
- ${db.symbolNoiseFor("gs")}
34
- -- Top-level type symbols: ends with # but does not contain nested #
35
- AND gs.symbol LIKE '%#'
36
- AND gs.symbol NOT LIKE '%#%#%'
37
- AND (der.end_line - der.start_line + 1) >= ?
38
- ${scopeFilter}
39
- ) WHERE consumers <= 1
40
- ORDER BY loc DESC
41
- LIMIT ?`,
42
- minLoc,
43
- limit
44
- );
45
- return rows.filter((r) => !db.isIgnored(r.file)).filter((r) => {
46
- const basename = r.file.split("/").pop() ?? "";
47
- const isTypeFile = basename.includes("types") || r.file.includes("/types/");
48
- if (isTypeFile && r.consumers > 0) return false;
49
- return true;
50
- }).map((r) => ({
51
- symbol: r.symbol,
52
- shortName: shortenSymbol(r.symbol),
53
- file: r.file,
54
- startLine: r.start_line,
55
- endLine: r.end_line,
56
- loc: r.loc,
57
- consumers: r.consumers
58
- }));
59
- }
60
-
61
- export {
62
- staleAbstractions
63
- };
64
- //# sourceMappingURL=chunk-P4WO3BBW.js.map
@@ -1,78 +0,0 @@
1
- import {
2
- shortenSymbol
3
- } from "./chunk-QIXNAB5K.js";
4
-
5
- // src/queries/similar-signatures.ts
6
- function similarSignatures(db, opts = {}) {
7
- const { scope, minLoc = 1, limit } = opts;
8
- const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
9
- const rows = db.all(
10
- `SELECT
11
- gs.symbol,
12
- d.relative_path,
13
- der.start_line,
14
- der.end_line,
15
- (der.end_line - der.start_line + 1) AS loc,
16
- REPLACE(SUBSTR(gs.documentation, INSTR(gs.documentation, '|') + 1), char(10), ' ') AS sig
17
- FROM global_symbols gs
18
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
19
- JOIN documents d ON der.document_id = d.id
20
- WHERE gs.documentation IS NOT NULL
21
- AND gs.documentation != ''
22
- AND INSTR(gs.documentation, '|') > 0
23
- AND (der.end_line - der.start_line + 1) >= ?
24
- ${db.pathExclusionsFor("d")}
25
- ${db.symbolNoiseFor("gs")}
26
- ${scopeFilter}
27
- ORDER BY d.relative_path, der.start_line`,
28
- minLoc
29
- );
30
- const sigGroups = /* @__PURE__ */ new Map();
31
- for (const row of rows) {
32
- if (db.isIgnored(row.relative_path)) continue;
33
- const normalized = normalizeSignature(row.sig);
34
- if (!normalized) continue;
35
- const entry = {
36
- symbol: row.symbol,
37
- shortName: shortenSymbol(row.symbol),
38
- file: row.relative_path,
39
- startLine: row.start_line,
40
- endLine: row.end_line,
41
- loc: row.loc
42
- };
43
- const existing = sigGroups.get(normalized);
44
- if (existing) {
45
- existing.push(entry);
46
- } else {
47
- sigGroups.set(normalized, [entry]);
48
- }
49
- }
50
- const results = [];
51
- for (const [signature, functions] of sigGroups) {
52
- if (functions.length < 2) continue;
53
- results.push({ signature, functions });
54
- }
55
- results.sort((a, b) => {
56
- const sizeDiff = b.functions.length - a.functions.length;
57
- if (sizeDiff !== 0) return sizeDiff;
58
- const locA = a.functions.reduce((sum, f) => sum + f.loc, 0);
59
- const locB = b.functions.reduce((sum, f) => sum + f.loc, 0);
60
- return locB - locA;
61
- });
62
- return limit ? results.slice(0, limit) : results;
63
- }
64
- function normalizeSignature(raw) {
65
- if (!raw || !raw.trim()) return null;
66
- let sig = raw.replace(/^```\w*\s*/, "").replace(/\s*```$/, "").replace(/^\(method\)\s*/, "").replace(/^\(property\)\s*/, "").replace(/^\(function\)\s*/, "").replace(/^\(class\)\s*/, "").replace(/^\(interface\)\s*/, "").replace(/^\(enum\)\s*/, "").replace(/^\(type alias\)\s*/, "").replace(/^\(const\)\s*/, "").replace(/^\(var\)\s*/, "").trim();
67
- const parenIdx = sig.indexOf("(");
68
- if (parenIdx === -1) return null;
69
- sig = sig.slice(parenIdx);
70
- sig = sig.replace(/\s+/g, "").toLowerCase();
71
- if (sig.length < 3) return null;
72
- return sig;
73
- }
74
-
75
- export {
76
- similarSignatures
77
- };
78
- //# sourceMappingURL=chunk-TOIEB3LG.js.map
@@ -1,60 +0,0 @@
1
- import {
2
- isEntrySurface
3
- } from "./chunk-YY4QGUQ5.js";
4
- import {
5
- testFileExclusionSql
6
- } from "./chunk-AXQKUYKF.js";
7
- import {
8
- shortenSymbol
9
- } from "./chunk-QIXNAB5K.js";
10
-
11
- // src/queries/isolated.ts
12
- function isolated(db, opts = {}) {
13
- const { scope, minLoc = 3 } = opts;
14
- const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
15
- const rows = db.all(
16
- `SELECT
17
- gs.symbol,
18
- d.relative_path,
19
- der.start_line,
20
- der.end_line,
21
- (der.end_line - der.start_line + 1) AS loc
22
- FROM global_symbols gs
23
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
24
- JOIN documents d ON der.document_id = d.id
25
- WHERE 1 = 1
26
- ${db.pathExclusionsFor("d")}
27
- AND ${testFileExclusionSql("d")}
28
- ${db.symbolNoiseFor("gs")}
29
- AND gs.symbol NOT LIKE '%#%'
30
- AND (der.end_line - der.start_line + 1) >= ?
31
- ${scopeFilter}
32
- -- No cross-file references TO this symbol
33
- AND NOT EXISTS (
34
- SELECT 1 FROM mentions m
35
- JOIN chunks c ON m.chunk_id = c.id
36
- WHERE m.symbol_id = gs.id AND m.role != 1 AND c.document_id != d.id
37
- )
38
- -- No same-file references either
39
- AND NOT EXISTS (
40
- SELECT 1 FROM mentions m
41
- JOIN chunks c ON m.chunk_id = c.id
42
- WHERE m.symbol_id = gs.id AND m.role != 1 AND c.document_id = d.id
43
- )
44
- ORDER BY loc DESC, d.relative_path`,
45
- minLoc
46
- );
47
- return rows.filter((r) => !db.isIgnored(r.relative_path)).filter((r) => !isEntrySurface(db, r.relative_path)).map((r) => ({
48
- symbol: r.symbol,
49
- shortName: shortenSymbol(r.symbol),
50
- relativePath: r.relative_path,
51
- startLine: r.start_line,
52
- endLine: r.end_line,
53
- loc: r.loc
54
- }));
55
- }
56
-
57
- export {
58
- isolated
59
- };
60
- //# sourceMappingURL=chunk-UQEQ6AHX.js.map
@@ -1,121 +0,0 @@
1
- import {
2
- findExactSymbolMatch,
3
- findFirstSymbolMatch,
4
- getSourceReferenceSites
5
- } from "./chunk-AXQKUYKF.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 sourceSites = getSourceReferenceSites(db, target).filter((site) => !db.isIgnored(site.file)).filter((site) => !scope || site.file.includes(scope));
50
- if (sourceSites.length > 0) {
51
- const rows2 = [];
52
- const seen = /* @__PURE__ */ new Set();
53
- for (const site of sourceSites) {
54
- if (!site.enclosingSymbol || site.enclosingSymbol === target.symbol) {
55
- const key2 = `${site.file}|(top-level)`;
56
- if (seen.has(key2)) continue;
57
- seen.add(key2);
58
- rows2.push({
59
- symbolId: null,
60
- symbol: site.file,
61
- shortName: "(top-level)",
62
- file: site.file,
63
- symbolMatch: null
64
- });
65
- continue;
66
- }
67
- const enclosing = findExactSymbolMatch(db, site.enclosingSymbol);
68
- if (!enclosing || enclosing.symbolId === target.symbolId || db.isIgnored(enclosing.relativePath)) {
69
- continue;
70
- }
71
- const key = `${enclosing.symbolId}|${enclosing.relativePath}`;
72
- if (seen.has(key)) continue;
73
- seen.add(key);
74
- rows2.push({
75
- symbolId: enclosing.symbolId,
76
- symbol: enclosing.symbol,
77
- shortName: shortenSymbol(enclosing.symbol),
78
- file: enclosing.relativePath,
79
- symbolMatch: enclosing
80
- });
81
- }
82
- return rows2;
83
- }
84
- const rows = db.all(
85
- `SELECT DISTINCT
86
- enc_gs.id AS symbol_id,
87
- enc_gs.symbol AS symbol,
88
- enc_d.relative_path AS relative_path
89
- FROM mentions m
90
- JOIN chunks c ON m.chunk_id = c.id
91
- JOIN documents ref_d ON c.document_id = ref_d.id
92
- JOIN defn_enclosing_ranges enc_der
93
- ON enc_der.document_id = ref_d.id
94
- AND c.start_line >= enc_der.start_line
95
- AND c.end_line <= enc_der.end_line
96
- JOIN global_symbols enc_gs ON enc_der.symbol_id = enc_gs.id
97
- JOIN documents enc_d ON enc_der.document_id = enc_d.id
98
- WHERE m.symbol_id = ?
99
- AND m.role != 1
100
- AND enc_gs.id != ?
101
- ${db.symbolNoiseFor("enc_gs")}
102
- ${db.pathExclusionsFor("enc_d")}
103
- ${scope ? `AND enc_d.relative_path LIKE '%${scope}%'` : ""}
104
- ORDER BY enc_d.relative_path
105
- LIMIT 1`,
106
- target.symbolId,
107
- target.symbolId
108
- );
109
- return rows.filter((row) => !db.isIgnored(row.relative_path)).map((row) => ({
110
- symbolId: row.symbol_id,
111
- symbol: row.symbol,
112
- shortName: shortenSymbol(row.symbol),
113
- file: row.relative_path,
114
- symbolMatch: findExactSymbolMatch(db, row.symbol)
115
- }));
116
- }
117
-
118
- export {
119
- affected
120
- };
121
- //# sourceMappingURL=chunk-VJJKSGIX.js.map
@@ -1,73 +0,0 @@
1
- import {
2
- shortenSymbol
3
- } from "./chunk-QIXNAB5K.js";
4
-
5
- // src/queries/doc-coverage.ts
6
- function docCoverage(db, opts = {}) {
7
- const { scope, minLoc = 3, limit = 50 } = opts;
8
- const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
9
- const totalRow = db.get(
10
- `SELECT COUNT(*) AS c
11
- FROM global_symbols gs
12
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
13
- JOIN documents d ON der.document_id = d.id
14
- WHERE 1 = 1
15
- ${db.pathExclusionsFor("d")}
16
- ${db.symbolNoiseFor("gs")}
17
- AND gs.symbol NOT LIKE '%#%'
18
- AND (der.end_line - der.start_line + 1) >= ?
19
- ${scopeFilter}`,
20
- minLoc
21
- );
22
- const docRow = db.get(
23
- `SELECT COUNT(*) AS c
24
- FROM global_symbols gs
25
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
26
- JOIN documents d ON der.document_id = d.id
27
- WHERE 1 = 1
28
- ${db.pathExclusionsFor("d")}
29
- ${db.symbolNoiseFor("gs")}
30
- AND gs.symbol NOT LIKE '%#%'
31
- AND (der.end_line - der.start_line + 1) >= ?
32
- AND gs.documentation IS NOT NULL
33
- AND gs.documentation != ''
34
- ${scopeFilter}`,
35
- minLoc
36
- );
37
- const total = totalRow?.c ?? 0;
38
- const documented = docRow?.c ?? 0;
39
- const undocRows = db.all(
40
- `SELECT gs.symbol, d.relative_path, der.start_line
41
- FROM global_symbols gs
42
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
43
- JOIN documents d ON der.document_id = d.id
44
- WHERE 1 = 1
45
- ${db.pathExclusionsFor("d")}
46
- ${db.symbolNoiseFor("gs")}
47
- AND gs.symbol NOT LIKE '%#%'
48
- AND (der.end_line - der.start_line + 1) >= ?
49
- AND (gs.documentation IS NULL OR gs.documentation = '')
50
- ${scopeFilter}
51
- ORDER BY d.relative_path, der.start_line
52
- LIMIT ?`,
53
- minLoc,
54
- limit
55
- );
56
- return {
57
- totalSymbols: total,
58
- documented,
59
- undocumented: total - documented,
60
- coveragePercent: total > 0 ? Math.round(documented / total * 100) : 0,
61
- undocumentedSymbols: undocRows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
62
- symbol: r.symbol,
63
- shortName: shortenSymbol(r.symbol),
64
- relativePath: r.relative_path,
65
- startLine: r.start_line
66
- }))
67
- };
68
- }
69
-
70
- export {
71
- docCoverage
72
- };
73
- //# sourceMappingURL=chunk-YZ6L7GFO.js.map