scip-query 0.10.10 → 0.10.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 (279) hide show
  1. package/README.md +56 -35
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/chunk-2DOW7QCA.js +71 -0
  4. package/dist/chunk-2FMFF4RI.js +2 -0
  5. package/dist/{chunk-J7RWXLUL.js → chunk-2GLNBCHB.js} +2 -2
  6. package/dist/chunk-2UVCH7CQ.js +2 -0
  7. package/dist/{chunk-LM5SHAN4.js → chunk-3XSNW5XB.js} +2 -2
  8. package/dist/chunk-4ISHQ7UW.js +35 -0
  9. package/dist/{chunk-XXZXDXTD.js → chunk-5GXTUANY.js} +2 -2
  10. package/dist/{chunk-TL6QPNF5.js → chunk-5JHEN5VN.js} +2 -2
  11. package/dist/chunk-62ULXMQ7.js +18 -0
  12. package/dist/chunk-63CI3IXR.js +102 -0
  13. package/dist/{chunk-Z4I7BVIU.js → chunk-6BN3EHQE.js} +2 -2
  14. package/dist/chunk-7C6JBBE4.js +23 -0
  15. package/dist/chunk-7EK7OSWS.js +2 -0
  16. package/dist/chunk-7IWIMNHI.js +2 -0
  17. package/dist/chunk-7XTO4YXB.js +8 -0
  18. package/dist/{chunk-5NVUWIAN.js → chunk-A4UTLKHU.js} +2 -2
  19. package/dist/{chunk-FDEQIPPK.js → chunk-ANUEY5WV.js} +2 -2
  20. package/dist/chunk-AOWFUGDL.js +2 -0
  21. package/dist/chunk-AREANYIA.js +3 -0
  22. package/dist/{chunk-7UQWUVRG.js → chunk-AZBELWZQ.js} +2 -2
  23. package/dist/{chunk-WG6KRH5F.js → chunk-CXWCLVYL.js} +2 -2
  24. package/dist/chunk-CYHIKTJN.js +3 -0
  25. package/dist/{chunk-BVRS7RKQ.js → chunk-DDQONX6B.js} +2 -2
  26. package/dist/{chunk-736BLPHR.js → chunk-DFSEARAU.js} +2 -2
  27. package/dist/{chunk-UFX7EPBA.js → chunk-DQ6433ZG.js} +2 -2
  28. package/dist/chunk-DVFP6PZI.js +2 -0
  29. package/dist/chunk-E3ADDB43.js +2 -0
  30. package/dist/{chunk-YWOOQ4FF.js → chunk-ELC77ZDE.js} +1 -1
  31. package/dist/chunk-EOLGSSDR.js +2 -0
  32. package/dist/chunk-F6IXELII.js +20 -0
  33. package/dist/{chunk-QYB5P7GL.js → chunk-FMGVZBS2.js} +2 -2
  34. package/dist/{chunk-VOYOYC5T.js → chunk-FX6ULETZ.js} +2 -2
  35. package/dist/chunk-GG5LHT27.js +2 -0
  36. package/dist/chunk-GKB4JJDU.js +2 -0
  37. package/dist/chunk-H7JF2CKK.js +2 -0
  38. package/dist/chunk-HHOMJCP5.js +4 -0
  39. package/dist/chunk-HRDSU5FN.js +9 -0
  40. package/dist/{chunk-BZ53S4ZN.js → chunk-HWVYTJOV.js} +2 -2
  41. package/dist/chunk-JJ5SAWBT.js +2 -0
  42. package/dist/chunk-JNMLBL36.js +2 -0
  43. package/dist/chunk-JS6B76AQ.js +2 -0
  44. package/dist/{chunk-ZQO43G2T.js → chunk-KZ4MG5NY.js} +2 -2
  45. package/dist/{chunk-UQLFQLAF.js → chunk-L446VQYQ.js} +2 -2
  46. package/dist/{chunk-NZ4UDB5N.js → chunk-LDJUB7XW.js} +2 -2
  47. package/dist/{chunk-MMLZEGMS.js → chunk-LEHVP4DY.js} +2 -2
  48. package/dist/chunk-MNCQPMCH.js +2 -0
  49. package/dist/chunk-MYTUWXHK.js +4 -0
  50. package/dist/chunk-N25HPUOK.js +2 -0
  51. package/dist/chunk-NABVR6B7.js +2 -0
  52. package/dist/{chunk-PTQVNJ4Q.js → chunk-NBNEVLRC.js} +2 -2
  53. package/dist/chunk-NTSR6SRP.js +2 -0
  54. package/dist/{chunk-RYXW3KRC.js → chunk-OFXN2BCT.js} +2 -2
  55. package/dist/chunk-PWAK75BU.js +2 -0
  56. package/dist/chunk-Q5P7NOVM.js +2 -0
  57. package/dist/chunk-RGKRYO22.js +4 -0
  58. package/dist/chunk-RM2WQ75T.js +2 -0
  59. package/dist/chunk-ROGZXWN2.js +2 -0
  60. package/dist/chunk-RSSXKJ6J.js +38 -0
  61. package/dist/chunk-RUV5IY25.js +7 -0
  62. package/dist/chunk-RVGEZYMQ.js +2 -0
  63. package/dist/{chunk-IPQTC36U.js → chunk-RXINFVBN.js} +2 -2
  64. package/dist/{chunk-RXRLZFUL.js → chunk-S2MRVIJ5.js} +2 -2
  65. package/dist/chunk-SA3DPTHT.js +7 -0
  66. package/dist/chunk-SGTKURU6.js +52 -0
  67. package/dist/chunk-SQNHOOJ5.js +3 -0
  68. package/dist/chunk-T3AEVJBG.js +4 -0
  69. package/dist/{chunk-DQVKIG3D.js → chunk-T4N2ZRVY.js} +2 -2
  70. package/dist/{chunk-5VG7RKEF.js → chunk-TBCHRDAC.js} +2 -2
  71. package/dist/chunk-THB6AM3V.js +11 -0
  72. package/dist/chunk-ULHLDOD6.js +4 -0
  73. package/dist/chunk-UQ73QF5D.js +43 -0
  74. package/dist/chunk-UVPY3RUZ.js +2 -0
  75. package/dist/chunk-V5FGK3DZ.js +2 -0
  76. package/dist/{chunk-3DGD6NKW.js → chunk-VB2EZZPA.js} +2 -2
  77. package/dist/{chunk-56P7PDST.js → chunk-WTY5FERW.js} +2 -2
  78. package/dist/chunk-WUOB4DHH.js +6 -0
  79. package/dist/chunk-XHMVZFA6.js +2 -0
  80. package/dist/chunk-XRUGSM76.js +10 -0
  81. package/dist/{chunk-UYD7FJ3K.js → chunk-XUCZ3RQ5.js} +2 -2
  82. package/dist/chunk-YFQIKYOP.js +2 -0
  83. package/dist/chunk-Z2LDWIJV.js +5 -0
  84. package/dist/chunk-ZNWWVYQL.js +3 -0
  85. package/dist/{chunk-UDGXK2WA.js → chunk-ZUUNREKS.js} +2 -2
  86. package/dist/cli.js +277 -252
  87. package/dist/{config-types-BDIWAYzr.d.ts → config-types-dvHOz0zU.d.ts} +4 -1
  88. package/dist/{db-Djj3Nqrb.d.ts → db-rMZO5JFK.d.ts} +1 -1
  89. package/dist/{health-D5J42g4D.d.ts → health-CtTIGh6H.d.ts} +1 -1
  90. package/dist/index.d.ts +9 -5
  91. package/dist/index.js +2 -2
  92. package/dist/queries/affected.d.ts +2 -2
  93. package/dist/queries/affected.js +1 -1
  94. package/dist/queries/bottlenecks.d.ts +2 -2
  95. package/dist/queries/bottlenecks.js +1 -1
  96. package/dist/queries/by-kind.d.ts +2 -2
  97. package/dist/queries/by-kind.js +1 -1
  98. package/dist/queries/call-graph.d.ts +2 -2
  99. package/dist/queries/call-graph.js +1 -1
  100. package/dist/queries/change-surface.d.ts +2 -2
  101. package/dist/queries/change-surface.js +1 -1
  102. package/dist/queries/cleanup-plan.d.ts +2 -2
  103. package/dist/queries/cleanup-plan.js +1 -1
  104. package/dist/queries/co-change.d.ts +2 -2
  105. package/dist/queries/co-change.js +1 -1
  106. package/dist/queries/code.d.ts +2 -2
  107. package/dist/queries/code.js +1 -1
  108. package/dist/queries/complexity-hotspots.d.ts +2 -2
  109. package/dist/queries/complexity-hotspots.js +1 -1
  110. package/dist/queries/complexity.d.ts +2 -2
  111. package/dist/queries/complexity.js +1 -1
  112. package/dist/queries/convergence.d.ts +2 -2
  113. package/dist/queries/convergence.js +1 -1
  114. package/dist/queries/coupling.d.ts +2 -2
  115. package/dist/queries/coupling.js +1 -1
  116. package/dist/queries/cycles.d.ts +2 -2
  117. package/dist/queries/cycles.js +1 -1
  118. package/dist/queries/dataflow.d.ts +2 -2
  119. package/dist/queries/dataflow.js +1 -1
  120. package/dist/queries/dead.d.ts +2 -2
  121. package/dist/queries/dead.js +1 -1
  122. package/dist/queries/deep-chains.d.ts +2 -2
  123. package/dist/queries/deep-chains.js +1 -1
  124. package/dist/queries/deps.d.ts +2 -2
  125. package/dist/queries/deps.js +1 -1
  126. package/dist/queries/diff-gate.d.ts +2 -2
  127. package/dist/queries/diff-gate.js +1 -1
  128. package/dist/queries/diff-impact.d.ts +2 -2
  129. package/dist/queries/diff-impact.js +1 -1
  130. package/dist/queries/doc-drift.d.ts +2 -2
  131. package/dist/queries/doc-drift.js +1 -1
  132. package/dist/queries/drift.d.ts +2 -2
  133. package/dist/queries/drift.js +1 -1
  134. package/dist/queries/extract-candidates.d.ts +2 -2
  135. package/dist/queries/extract-candidates.js +1 -1
  136. package/dist/queries/fan.d.ts +2 -2
  137. package/dist/queries/fan.js +1 -1
  138. package/dist/queries/files.d.ts +2 -2
  139. package/dist/queries/health.d.ts +3 -3
  140. package/dist/queries/health.js +1 -1
  141. package/dist/queries/hierarchy.d.ts +2 -2
  142. package/dist/queries/hierarchy.js +1 -1
  143. package/dist/queries/hotspots.d.ts +2 -2
  144. package/dist/queries/hotspots.js +1 -1
  145. package/dist/queries/imports.d.ts +2 -2
  146. package/dist/queries/imports.js +1 -1
  147. package/dist/queries/incomplete-migration.d.ts +2 -2
  148. package/dist/queries/incomplete-migration.js +1 -1
  149. package/dist/queries/index.d.ts +4 -4
  150. package/dist/queries/index.js +1 -1
  151. package/dist/queries/isolated.d.ts +2 -2
  152. package/dist/queries/isolated.js +1 -1
  153. package/dist/queries/locality-candidates.d.ts +2 -2
  154. package/dist/queries/locality-candidates.js +1 -1
  155. package/dist/queries/members.d.ts +2 -2
  156. package/dist/queries/members.js +1 -1
  157. package/dist/queries/methods.d.ts +2 -2
  158. package/dist/queries/methods.js +1 -1
  159. package/dist/queries/outline.d.ts +2 -2
  160. package/dist/queries/outline.js +1 -1
  161. package/dist/queries/passthrough-candidates.d.ts +2 -2
  162. package/dist/queries/passthrough-candidates.js +1 -1
  163. package/dist/queries/plan-context.d.ts +2 -2
  164. package/dist/queries/plan-context.js +1 -1
  165. package/dist/queries/react-component-duplicates.d.ts +2 -2
  166. package/dist/queries/react-component-duplicates.js +1 -1
  167. package/dist/queries/react-hook-candidates.d.ts +2 -2
  168. package/dist/queries/react-hook-candidates.js +1 -1
  169. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  170. package/dist/queries/react-large-component-pressure.js +1 -1
  171. package/dist/queries/recent-duplicates.d.ts +2 -2
  172. package/dist/queries/recent-duplicates.js +1 -1
  173. package/dist/queries/redundant-reexports.d.ts +2 -2
  174. package/dist/queries/redundant-reexports.js +1 -1
  175. package/dist/queries/refs.d.ts +2 -2
  176. package/dist/queries/refs.js +1 -1
  177. package/dist/queries/self-audit.d.ts +7 -4
  178. package/dist/queries/self-audit.js +1 -1
  179. package/dist/queries/similar-chains.d.ts +2 -2
  180. package/dist/queries/similar-chains.js +1 -1
  181. package/dist/queries/similar-files.d.ts +2 -2
  182. package/dist/queries/similar-files.js +1 -1
  183. package/dist/queries/similar-signatures.d.ts +2 -2
  184. package/dist/queries/similar-signatures.js +1 -1
  185. package/dist/queries/similar.d.ts +55 -16
  186. package/dist/queries/similar.js +1 -1
  187. package/dist/queries/slice.d.ts +2 -2
  188. package/dist/queries/slice.js +1 -1
  189. package/dist/queries/stale-abstractions.d.ts +2 -2
  190. package/dist/queries/stale-abstractions.js +1 -1
  191. package/dist/queries/stats.d.ts +2 -2
  192. package/dist/queries/surface.d.ts +2 -2
  193. package/dist/queries/surface.js +1 -1
  194. package/dist/queries/symbols.d.ts +2 -2
  195. package/dist/queries/symbols.js +1 -1
  196. package/dist/queries/system.d.ts +2 -2
  197. package/dist/queries/system.js +1 -1
  198. package/dist/queries/trace.d.ts +2 -2
  199. package/dist/queries/trace.js +1 -1
  200. package/dist/queries/unused-imports.d.ts +2 -2
  201. package/dist/queries/unused-imports.js +1 -1
  202. package/dist/queries/unused-params.d.ts +2 -2
  203. package/dist/queries/unused-params.js +1 -1
  204. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  205. package/dist/queries/vue-component-duplicates.js +1 -1
  206. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  207. package/dist/queries/vue-composable-candidates.js +1 -1
  208. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  209. package/dist/queries/vue-large-view-pressure.js +1 -1
  210. package/dist/queries/wrapper-candidates.d.ts +2 -2
  211. package/dist/queries/wrapper-candidates.js +1 -1
  212. package/dist/reindex-worker.js +9 -9
  213. package/dist/reindex.d.ts +30 -4
  214. package/dist/reindex.js +19 -19
  215. package/dist/runtime.d.ts +4 -3
  216. package/dist/runtime.js +2 -2
  217. package/dist/{scip-cli-CnK9Va4O.d.ts → scip-cli-trnNvymv.d.ts} +1 -1
  218. package/docs/COMMAND_REFERENCE.md +2 -2
  219. package/docs/analyzer-inventory.md +8 -0
  220. package/docs/analyzer-validation-ledger.md +7 -0
  221. package/package.json +3 -1
  222. package/scripts/evidence-product-contract.mjs +197 -0
  223. package/skills/scip-hyper-optimization/SKILL.md +153 -24
  224. package/skills/scip-hyper-optimization/agents/openai.yaml +3 -3
  225. package/dist/chunk-2UYQLFVC.js +0 -2
  226. package/dist/chunk-2VM46FC5.js +0 -8
  227. package/dist/chunk-3Q77KKEY.js +0 -2
  228. package/dist/chunk-3VD3JMK2.js +0 -2
  229. package/dist/chunk-4KTOV4QN.js +0 -3
  230. package/dist/chunk-4N4WONI4.js +0 -102
  231. package/dist/chunk-65AU3HFZ.js +0 -2
  232. package/dist/chunk-6LNQOOTB.js +0 -2
  233. package/dist/chunk-72KY2ZFO.js +0 -2
  234. package/dist/chunk-7JRRXGVZ.js +0 -2
  235. package/dist/chunk-A536TEU4.js +0 -3
  236. package/dist/chunk-A6IDHNMC.js +0 -4
  237. package/dist/chunk-A6TANQNV.js +0 -2
  238. package/dist/chunk-AW2QHPLL.js +0 -4
  239. package/dist/chunk-BSN22NRK.js +0 -9
  240. package/dist/chunk-C5CTSJ6X.js +0 -6
  241. package/dist/chunk-CCKPYPDI.js +0 -35
  242. package/dist/chunk-CZ425R2B.js +0 -18
  243. package/dist/chunk-DS6QEB3G.js +0 -5
  244. package/dist/chunk-F6ICF7HL.js +0 -40
  245. package/dist/chunk-FAYI6KZ5.js +0 -2
  246. package/dist/chunk-FG4NT6VY.js +0 -2
  247. package/dist/chunk-FRPEPTYJ.js +0 -5
  248. package/dist/chunk-GBEYTDY5.js +0 -2
  249. package/dist/chunk-GRJY65YT.js +0 -2
  250. package/dist/chunk-HF25DFSC.js +0 -3
  251. package/dist/chunk-HHN2B5KA.js +0 -2
  252. package/dist/chunk-I46WR7MT.js +0 -10
  253. package/dist/chunk-JM72FNGA.js +0 -2
  254. package/dist/chunk-KX5PLFZ5.js +0 -3
  255. package/dist/chunk-LPL4MA6R.js +0 -2
  256. package/dist/chunk-LZHUWKGD.js +0 -2
  257. package/dist/chunk-OBGRLXWF.js +0 -3
  258. package/dist/chunk-P5RYBRIO.js +0 -4
  259. package/dist/chunk-PFOCOG57.js +0 -2
  260. package/dist/chunk-PKMZCDQD.js +0 -4
  261. package/dist/chunk-QPU7EXAW.js +0 -2
  262. package/dist/chunk-QVI3NR7E.js +0 -7
  263. package/dist/chunk-QX7LLCGB.js +0 -23
  264. package/dist/chunk-RVWSAMTT.js +0 -2
  265. package/dist/chunk-SGLLBSCV.js +0 -2
  266. package/dist/chunk-SULEXAHO.js +0 -38
  267. package/dist/chunk-TH2N6QHW.js +0 -2
  268. package/dist/chunk-UWYJDBDW.js +0 -2
  269. package/dist/chunk-VUKC6F77.js +0 -20
  270. package/dist/chunk-W2CBNBEL.js +0 -71
  271. package/dist/chunk-XIVO4SDZ.js +0 -2
  272. package/dist/chunk-XSNRACLV.js +0 -3
  273. package/dist/chunk-XUGQU7PM.js +0 -41
  274. package/dist/chunk-Y6E3JHC4.js +0 -2
  275. package/dist/chunk-YBEEVDJQ.js +0 -2
  276. package/dist/chunk-YGHUVQLR.js +0 -2
  277. package/dist/chunk-YWDVDAD7.js +0 -2
  278. package/dist/chunk-YZA6PPZL.js +0 -3
  279. package/dist/chunk-ZU6PROUY.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.10.10",
3
+ "version": "0.10.12",
4
4
  "description": "Evidence and verification for AI coding agents: map code, reuse concepts, finish migrations, and gate diffs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,6 +14,7 @@
14
14
  "docs/assets/**/*",
15
15
  "docs/*.md",
16
16
  "scripts/build-scip-windows.mjs",
17
+ "scripts/evidence-product-contract.mjs",
17
18
  "skills/**/SKILL.md",
18
19
  "skills/**/agents/*.yaml",
19
20
  "vendor/scip/**/*"
@@ -291,6 +292,7 @@
291
292
  "typecheck": "tsc --noEmit",
292
293
  "lint": "npm run format:check && eslint src tests tsup.config.ts",
293
294
  "build:scip-windows": "node scripts/build-scip-windows.mjs",
295
+ "bench:evidence-products": "node scripts/evidence-product-contract.mjs",
294
296
  "calibrate": "node scripts/accuracy-calibration.mjs",
295
297
  "docs:commands": "vite-node scripts/render-command-reference.ts --write",
296
298
  "prepublishOnly": "npm run build && npm run build:scip-windows",
@@ -0,0 +1,197 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { createHash } from 'node:crypto';
4
+ import { existsSync, mkdirSync, rmSync, statSync, appendFileSync } from 'node:fs';
5
+ import { dirname, join, resolve } from 'node:path';
6
+ import { performance } from 'node:perf_hooks';
7
+
8
+ const DEFAULT_COMMANDS = [
9
+ ['dead', '--json'],
10
+ ['doc-drift', '--json'],
11
+ ['recent-duplicates', '--json'],
12
+ ['similar', '--json', '--full'],
13
+ ['health', '--json', '--full'],
14
+ ];
15
+
16
+ const args = parseArgs(process.argv.slice(2));
17
+ const projectRoot = process.cwd();
18
+ const cliPath = resolve(projectRoot, 'dist/cli.js');
19
+ const date = new Date().toISOString().slice(0, 10);
20
+ const runHistoryPath = resolve(projectRoot, args.out ?? `docs/benchmarks/runs/${date}-evidence-products.jsonl`);
21
+ const profilePath = resolve(
22
+ projectRoot,
23
+ args.profileOut ?? `docs/benchmarks/runs/${date}-evidence-products.profile.jsonl`,
24
+ );
25
+ const commands = args.commands.length > 0 ? args.commands : DEFAULT_COMMANDS;
26
+
27
+ mkdirSync(dirname(runHistoryPath), { recursive: true });
28
+ mkdirSync(dirname(profilePath), { recursive: true });
29
+
30
+ const status = runCli(['status', '--json'], { profile: false });
31
+ if (status.exitCode !== 0) {
32
+ process.stderr.write(status.stderr.toString());
33
+ process.exit(status.exitCode ?? 1);
34
+ }
35
+
36
+ const statusJson = JSON.parse(status.stdout.toString());
37
+ const dbPath = statusJson.result?.dbPath;
38
+ if (typeof dbPath !== 'string') {
39
+ throw new Error('status --json did not include result.dbPath');
40
+ }
41
+
42
+ const evidencePath = join(dirname(dbPath), 'evidence.db');
43
+ if (!args.noClear) clearEvidence(evidencePath);
44
+
45
+ const runId = new Date().toISOString();
46
+ const records = [];
47
+ for (let iteration = 1; iteration <= args.coldIterations; iteration += 1) {
48
+ for (const command of commands) {
49
+ records.push(recordCommand({ runId, phase: 'cold-fill', iteration, command, evidencePath }));
50
+ }
51
+ }
52
+ for (let iteration = 1; iteration <= args.warmIterations; iteration += 1) {
53
+ for (const command of commands) {
54
+ records.push(recordCommand({ runId, phase: 'warm-hit', iteration, command, evidencePath }));
55
+ }
56
+ }
57
+
58
+ const failed = records.filter((record) => record.exitCode !== 0 || record.signal || record.error);
59
+ const summary = {
60
+ runId,
61
+ runHistoryPath,
62
+ profilePath,
63
+ evidencePath,
64
+ commands: commands.map((command) => command.join(' ')),
65
+ coldIterations: args.coldIterations,
66
+ warmIterations: args.warmIterations,
67
+ failed: failed.length,
68
+ records: records.map(
69
+ ({ phase, iteration, command, durationMs, exitCode, stdoutBytes, stderrBytes, evidenceBytes }) => ({
70
+ phase,
71
+ iteration,
72
+ command,
73
+ durationMs,
74
+ exitCode,
75
+ stdoutBytes,
76
+ stderrBytes,
77
+ evidenceBytes,
78
+ }),
79
+ ),
80
+ };
81
+
82
+ process.stdout.write(`${JSON.stringify(summary, null, 2)}\n`);
83
+ if (failed.length > 0) process.exit(1);
84
+
85
+ function recordCommand({ runId, phase, iteration, command, evidencePath }) {
86
+ const result = runCli(command, { profile: true });
87
+ const record = {
88
+ timestamp: new Date().toISOString(),
89
+ runId,
90
+ target: 'evidence-products',
91
+ phase,
92
+ iteration,
93
+ command: `scip-query ${command.join(' ')}`,
94
+ durationMs: result.durationMs,
95
+ exitCode: result.exitCode,
96
+ signal: result.signal,
97
+ error: result.error?.message,
98
+ stdoutBytes: result.stdout.length,
99
+ stderrBytes: result.stderr.length,
100
+ stdoutSha256: sha256(result.stdout),
101
+ evidenceBytes: fileSize(evidencePath),
102
+ profilePath,
103
+ };
104
+ appendFileSync(runHistoryPath, `${JSON.stringify(record)}\n`);
105
+ return record;
106
+ }
107
+
108
+ function runCli(command, opts) {
109
+ const started = performance.now();
110
+ const result = spawnSync(process.execPath, [cliPath, ...command], {
111
+ cwd: projectRoot,
112
+ env: opts.profile
113
+ ? {
114
+ ...process.env,
115
+ SCIP_QUERY_PROFILE: '1',
116
+ SCIP_QUERY_PROFILE_COMMAND: `scip-query ${command.join(' ')}`,
117
+ SCIP_QUERY_PROFILE_OUT: profilePath,
118
+ }
119
+ : process.env,
120
+ encoding: 'buffer',
121
+ maxBuffer: 100 * 1024 * 1024,
122
+ });
123
+ return {
124
+ durationMs: Math.round(performance.now() - started),
125
+ exitCode: result.status,
126
+ signal: result.signal,
127
+ error: result.error,
128
+ stdout: result.stdout ?? Buffer.alloc(0),
129
+ stderr: result.stderr ?? Buffer.alloc(0),
130
+ };
131
+ }
132
+
133
+ function clearEvidence(evidencePath) {
134
+ for (const path of [evidencePath, `${evidencePath}-wal`, `${evidencePath}-shm`]) {
135
+ if (existsSync(path)) rmSync(path, { force: true });
136
+ }
137
+ }
138
+
139
+ function fileSize(path) {
140
+ try {
141
+ return statSync(path).size;
142
+ } catch {
143
+ return 0;
144
+ }
145
+ }
146
+
147
+ function sha256(buffer) {
148
+ return createHash('sha256').update(buffer).digest('hex');
149
+ }
150
+
151
+ function parseArgs(argv) {
152
+ const parsed = {
153
+ coldIterations: 1,
154
+ warmIterations: 2,
155
+ commands: [],
156
+ noClear: false,
157
+ out: undefined,
158
+ profileOut: undefined,
159
+ };
160
+ for (let index = 0; index < argv.length; index += 1) {
161
+ const arg = argv[index];
162
+ if (arg === '--cold-iterations') {
163
+ parsed.coldIterations = positiveInteger(argv[++index], '--cold-iterations');
164
+ } else if (arg === '--warm-iterations') {
165
+ parsed.warmIterations = positiveInteger(argv[++index], '--warm-iterations');
166
+ } else if (arg === '--command') {
167
+ const value = argv[++index];
168
+ if (!value) throw new Error('--command requires a value');
169
+ parsed.commands.push(splitCommand(value));
170
+ } else if (arg === '--out') {
171
+ parsed.out = argv[++index];
172
+ if (!parsed.out) throw new Error('--out requires a value');
173
+ } else if (arg === '--profile-out') {
174
+ parsed.profileOut = argv[++index];
175
+ if (!parsed.profileOut) throw new Error('--profile-out requires a value');
176
+ } else if (arg === '--no-clear') {
177
+ parsed.noClear = true;
178
+ } else {
179
+ throw new Error(`unknown option: ${arg}`);
180
+ }
181
+ }
182
+ return parsed;
183
+ }
184
+
185
+ function positiveInteger(value, flag) {
186
+ const parsed = Number(value);
187
+ if (!Number.isInteger(parsed) || parsed < 0) throw new Error(`${flag} must be a non-negative integer`);
188
+ return parsed;
189
+ }
190
+
191
+ function splitCommand(value) {
192
+ return value
193
+ .trim()
194
+ .split(/\s+/)
195
+ .filter(Boolean)
196
+ .filter((part, index) => !(index === 0 && part === 'scip-query'));
197
+ }
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: scip-hyper-optimization
3
- description: Run scientific performance optimization campaigns with scip-query evidence, command ledgers, and benchmark corpora. Use when the user asks to hyper optimize, make commands blazing fast, speed up a CLI/tool/app, benchmark regressions, or compare targeted tuning against radically different implementations.
3
+ description: Run scientific performance optimization campaigns with scip-query evidence, hierarchical profiling, command ledgers, and benchmark corpora. Use when the user asks to hyper optimize, make commands blazing fast, speed up a CLI/tool/app, find bottlenecks, benchmark regressions, optimize cold or warm paths, or compare targeted tuning against radically different implementations.
4
4
  ---
5
5
 
6
6
  # SCIP Hyper Optimization
7
+
7
8
  Use this skill to make a command, workflow, service, page, or tool as fast as
8
9
  feasibly possible without changing its observable result. Hyper optimization is
9
10
  a bounded campaign that improves runtime, memory use, or computational cost
@@ -12,9 +13,16 @@ benchmark and unchanged output.
12
13
 
13
14
  A measurement harness is the repeatable set of commands, fixtures, corpora,
14
15
  environment notes, and result documents used to decide whether performance
15
- changed. A command ledger is the living document for one target: what it
16
- returns, what code runs, where time is spent, what was tried, and what evidence
17
- accepted or rejected each idea.
16
+ changed. A run history is the durable time-series of those measurements: one
17
+ record per run, command, subprocess, or profiled stage, with enough metadata to
18
+ compare commits and draw charts later. A profile span is one named timed piece
19
+ of work inside the target process, such as input loading, cache reads, database
20
+ queries, graph traversal, rendering, or a child process. Hierarchical profiling
21
+ is using coarse spans to find the dominant stage, then recursively splitting
22
+ only that stage until the expensive operation is concrete enough to fix. A
23
+ command ledger is the living document for one target: what it returns, what code
24
+ runs, where time is spent, what was tried, and what evidence accepted or
25
+ rejected each idea.
18
26
 
19
27
  ## Rules
20
28
 
@@ -23,22 +31,43 @@ accepted or rejected each idea.
23
31
  `call-graph`, `code`, `dataflow`, `complexity`, `diff-impact`, `diff-gate`.
24
32
  3. Capture representative inputs, required output behavior, and correctness
25
33
  checks before editing.
26
- 4. Measure cold and warm paths when both matter; record exact commands, corpus,
27
- elapsed time, repetitions, and outliers.
28
- 5. Work both tracks: tune the current pipeline and evaluate radically different
34
+ 4. Record every benchmark in a machine-readable run history before and after
35
+ each optimization; Markdown summaries are secondary.
36
+ 5. Measure cold-index, cold-cache or evidence-fill, warm steady-state, and
37
+ repeated focused paths separately when they can diverge.
38
+ 6. Profile the target's internal chain before editing. A bare command duration
39
+ is enough to rank targets, not enough to choose a fix.
40
+ 7. Treat profiling as a search algorithm: place coarse spans first, split the
41
+ biggest span, and stop descending only when the slow operation is identifiable
42
+ as a specific repeated lookup, initialization, scan, traversal, subprocess,
43
+ serialization step, or wait.
44
+ 8. Attach counts to spans: files, rows, symbols, candidates, cache hits/misses,
45
+ subprocesses, bytes, edges, nodes, retries, and output rows. Time without
46
+ cardinality hides the cause.
47
+ 9. Work both tracks: tune the current pipeline and evaluate radically different
29
48
  algorithms or data models that preserve the same result.
30
- 6. Keep only changes that improve real workloads without reducing accuracy,
31
- diagnostics, safety checks, or supported inputs.
49
+ 10. Keep only changes that improve real workloads without reducing accuracy,
50
+ diagnostics, safety checks, or supported inputs.
51
+
52
+ ## Phase 0: Target And Measurement Harness
32
53
 
33
- ## Phase 0: Measurement Harness
34
54
  If the target repository is not already a reliable scip-query workspace, invoke
35
55
  `scip-query-setup` first. Do not run setup-ci in this workflow.
36
56
 
37
- Create or update a benchmark note before code changes. Prefer the repo's
38
- existing convention; otherwise use
39
- `docs/benchmarks/YYYY-MM-DD-<target>-baseline.md`. Include target, machine/date
57
+ Choose the optimization target explicitly. Use user-reported pain, production
58
+ telemetry, benchmark ranking, regression data, cost, frequency, or risk to
59
+ justify why this target comes first. Do not optimize the slowest thing by habit
60
+ if another path dominates real user time or compute spend.
61
+
62
+ Create or update a benchmark note and a run-history store before code changes.
63
+ Prefer the repo's existing convention; otherwise use
64
+ `docs/benchmarks/YYYY-MM-DD-<target>-baseline.md` and
65
+ `docs/benchmarks/runs/YYYY-MM-DD-<target>.jsonl`. Include target, machine/date
40
66
  context, corpus or fixture list, cold/warm/correctness commands, baseline
41
- timings, output-contract evidence, and slowest stages.
67
+ timings, output-contract evidence, and slowest stages. Append a structured run
68
+ record for each measurement with at least timestamp, commit/version, target,
69
+ corpus, scenario, command, duration, exit status, output hash or size, and
70
+ notes for outliers.
42
71
 
43
72
  Choose the measurement mechanism from the target's real workload. For app
44
73
  paths, use the app's benchmark, test, route smoke, build, profiler, load test,
@@ -51,13 +80,20 @@ scip-query bench --json
51
80
  scip-query bench --json --cold-index --include-heavy --timeout-ms 600000
52
81
  ```
53
82
 
83
+ For long benchmark matrices, prefer progress output or incremental JSONL writes
84
+ so the current command, subprocess, elapsed time, and completed measurements are
85
+ visible while the run is still active and useful if interrupted.
86
+
54
87
  ## Phase 1: Command Ledger
88
+
55
89
  Create one ledger per target:
56
90
  `docs/benchmarks/YYYY-MM-DD-<target>-ledger.md`. Include Output Contract,
57
- Current Pipeline, Measurements, Current-Pipeline Optimizations, Alternative
58
- Designs, and Decisions.
91
+ Target Selection, Current Pipeline, Run History Location, Profile Spans,
92
+ Bottleneck Candidates, Measurements, Current-Pipeline Optimizations,
93
+ Alternative Designs, and Decisions.
59
94
 
60
95
  ## Phase 2: Trace Current Behavior
96
+
61
97
  Trace the target end to end and write the actual path into the ledger:
62
98
 
63
99
  ```bash
@@ -72,26 +108,119 @@ scip-query complexity <hot-symbol>
72
108
  scip-query change-surface <touched-file> --json --full
73
109
  ```
74
110
 
75
- Record input parsing, lookups, database queries, graph traversal, source scans,
76
- semantic calls, cache reads/writes, rendering, and verification.
111
+ Record the chain reaction from entry point to result: input parsing, option
112
+ resolution, subprocesses, lookups, database queries, graph traversal, source
113
+ scans, semantic calls, cache reads/writes, rendering, output serialization, and
114
+ verification. The trace should be concrete enough that each major step can be
115
+ timed as a profile span.
116
+
117
+ Before adding spans, use the trace to predict span boundaries. Good first spans
118
+ usually match the target's real pipeline nouns: load inputs, compute candidates,
119
+ read cache, compute misses, write cache, build graph, score, render, serialize,
120
+ and child process. Use `call-graph` to find nested helpers inside the slow
121
+ stage, `dataflow` to follow the expensive object or cache key, `refs` to learn
122
+ whether a suspected fix affects other paths, and `complexity` to avoid spending
123
+ the first profiling pass on low-risk glue.
124
+
125
+ ## Phase 3: Profile The Timed Chain
126
+
127
+ Before editing, produce a stage profile for the selected target. Prefer existing
128
+ runtime profilers, tracing systems, structured logs, or benchmark hooks. If none
129
+ exist, add temporary or permanent instrumentation that names timed spans without
130
+ changing observable output. For CLIs and build tools, include child processes
131
+ and worker tasks; for services, include request handlers, database calls,
132
+ network calls, queue jobs, cache hits/misses, rendering, and serialization.
133
+
134
+ Use this discovery ladder:
135
+
136
+ 1. Measure the target unprofiled so the user-facing baseline is real.
137
+ 2. Measure it profiled once. If profiled and unprofiled times are close, the
138
+ profiler is diagnostic overhead, not the bottleneck. If profiling dominates,
139
+ fix the harness before trusting fine spans.
140
+ 3. Measure distinct states separately: cold index, cold derived-cache/evidence
141
+ fill, warm cache hit, repeated focused run, and production-like mixed state.
142
+ 4. Add coarse spans that cover the whole chain. If span time does not explain
143
+ wall time, look for uninstrumented child processes, async waits, I/O, process
144
+ startup, or profiler gaps.
145
+ 5. Pick the largest span by wall time multiplied by real workload frequency.
146
+ Split only that span into child spans.
147
+ 6. Repeat until a fixable operation appears: a repeated singleton creation, a
148
+ per-item lookup, a broad scan, a wrapper traversal, a cache miss storm, a
149
+ subprocess startup, a serialization step, or a wait.
150
+ 7. Add cardinality metadata to every split: count of rows/files/symbols/nodes,
151
+ cache hits/misses, bytes, output rows, and skipped items.
152
+ 8. Record the before profile in the ledger before touching code.
153
+
154
+ Write profile records to the run history with parent/child span names when
155
+ possible. Separate wall time from CPU time when the tools allow it. Mark cache
156
+ state explicitly: cold index, cold evidence/cache fill, warm cache hit, repeated
157
+ focused run, or production-like mixed state.
158
+
159
+ ## Phase 4: Diagnose And Find Speedups
160
+
161
+ Classify the dominant span before choosing a fix:
162
+
163
+ | Profile shape | Likely cause | First fixes to test |
164
+ | ----------------------------------------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
165
+ | Cold path huge, warm path fast | Derived evidence/cache fill, expensive initialization, or cache invalidation | Persist the derived result, reuse compatible cache versions, batch cache fills, hoist initialization |
166
+ | Warm path still slow | Cache scan, query shape, deserialization, reshaping, rendering, or output size | Narrow query, add indexes, store compact payloads, stream or avoid repeated object shaping |
167
+ | Same expensive setup repeated across many files/items | Singleton/client/checker/session/project built inside a loop | Preload required inputs, create once after inputs are stable, cache per project/process |
168
+ | Many medium-cost per-item operations | N+1 lookups, scalar provider calls, repeated source reads | Batch by provider/file/key, load rows in bulk, group work by locality |
169
+ | Traversal span grows with AST/source nodes | Wrapper allocation or broad source scan | Use lower-level APIs, prefilter by exact names only when output identity proves equivalence, index reusable facts |
170
+ | Database time dominates | Broad scan, missing index, many statements, repeated prepares | Push filters into SQL, batch queries, cache prepared statements, add measured indexes |
171
+ | Child process or startup dominates | Too many subprocesses or cold tool startup | Reuse workers, batch commands, keep warm daemons, collapse process boundaries |
172
+ | Serialization/output dominates | Large JSON, repeated formatting, full materialization | Stream, summarize, avoid duplicate fields, or add an explicit compact mode |
77
173
 
78
- ## Phase 3: Find Speedups
79
174
  For the current pipeline, look for repeated work, broad scans, N+1 lookups,
80
175
  uncached pure work, avoidable source or semantic reads, large arrays, late
81
- filters, batchable per-file work, and safe parallelism.
176
+ filters, batchable per-file work, excessive subprocess startup, serialization
177
+ cost, cache invalidation churn, and safe parallelism. Prioritize by measured
178
+ span cost multiplied by real workload frequency; do not chase a large cold-only
179
+ span if the stated purpose depends on warm interactive latency.
180
+
181
+ Favor fixes in this order when they preserve output:
182
+
183
+ 1. Remove accidental repetition: hoist, memoize, reuse, or preload.
184
+ 2. Batch scalar work by provider, file, database key, network endpoint, or
185
+ process.
186
+ 3. Move stable derived work from the hot path into an index/cache with a clear
187
+ invalidation key.
188
+ 4. Replace broad scans with indexed lookups or candidate-first retrieval.
189
+ 5. Replace high-overhead wrapper APIs with lower-level APIs only after output
190
+ identity checks prove equivalence.
191
+ 6. Add pruning only when it is mathematically equivalent or output-identity
192
+ checks across representative corpora prove no observable change.
82
193
 
83
194
  For alternative designs, restate the output contract first. Ask whether SQLite
84
195
  can answer directly, an index/cache/precomputed table can move work out of the
85
196
  hot path, batch queries can replace loops, a cheap pruning stage can precede
86
197
  exact work, or workers can run independent phases safely.
87
198
 
88
- ## Phase 4: Implement and Verify
199
+ ## Phase 5: Implement And Verify
200
+
89
201
  Make the smallest reversible change that tests one performance hypothesis.
90
- Update the ledger with hypothesis, changed files/symbols, before/after timings,
91
- output comparison, tests, and gates.
202
+ Update the ledger and run history with hypothesis, changed files/symbols,
203
+ before/after timings, profile-span deltas, output comparison, tests, and gates.
204
+
205
+ After each candidate fix, run the smallest valid before/after matrix for the
206
+ target scenario: unprofiled control, profiled profile, output hash or semantic
207
+ identity check, and representative correctness tests. If a faster change alters
208
+ the output contract, reject or revert it unless the user explicitly approved a
209
+ behavior change.
92
210
 
93
211
  Run the narrow correctness check, benchmark cases, `scip-query diff-impact
94
212
  --json`, and `scip-query diff-gate --json`; reindex first if freshness is not
95
213
  proven. Also run postchecks matching the change type. End with starting time,
96
214
  final time, percentage change, accepted changes, rejected ideas, remaining
97
- bottlenecks, and the next target.
215
+ bottlenecks, and the next target. If results conflict, keep the change only when
216
+ the target scenario and output contract justify it; otherwise revert and record
217
+ the rejected hypothesis.
218
+
219
+ ## Phase 6: Report And Visualize
220
+
221
+ End every optimization round with a compact scoreboard generated from the run
222
+ history, not hand-copied memory. At minimum, show starting value, current value,
223
+ delta, scenario, corpus, commit/version, and output identity evidence. When the
224
+ history has enough rows, produce a trend table or chart for the target command
225
+ or workflow. Keep Markdown readable for humans, but treat the structured
226
+ history as the source of truth.
@@ -1,4 +1,4 @@
1
1
  interface:
2
- display_name: "SCIP Hyper Optimization"
3
- short_description: "Scientific benchmark-driven optimization"
4
- default_prompt: "Use $scip-hyper-optimization to set up objective benchmarks, trace the target end to end, and optimize it without changing output."
2
+ display_name: 'SCIP Hyper Optimization'
3
+ short_description: 'Hierarchical profiling-driven optimization'
4
+ default_prompt: 'Use $scip-hyper-optimization to choose an optimization target, capture output identity, measure cold and warm controls, profile the dominant span hierarchically, then optimize without changing behavior.'
@@ -1,2 +0,0 @@
1
- import{a}from"./chunk-GBEYTDY5.js";import{a as i}from"./chunk-PTQVNJ4Q.js";import{c as s,e as o,k as m}from"./chunk-JM72FNGA.js";function L(t,l){let r=i(t,l);return r?new a(t).definitionsForFile(r.relativePath).filter(e=>e.symbol!==r.symbol).filter(e=>m(r.symbol,e.symbol)).sort((e,n)=>e.startLine-n.startLine||e.endLine-n.endLine).map(e=>({symbol:e.symbol,shortName:s(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:o(e.symbol)??"unknown"})):[]}export{L as a};
2
- //# sourceMappingURL=chunk-2UYQLFVC.js.map
@@ -1,8 +0,0 @@
1
- import{f as H,i as O}from"./chunk-FRPEPTYJ.js";import{d as D}from"./chunk-YWOOQ4FF.js";import{b as _,d as T,h as E,i as L}from"./chunk-DQVKIG3D.js";import{a as w}from"./chunk-GBEYTDY5.js";import{c as C,d as F}from"./chunk-JM72FNGA.js";var V=5;function re(e,t={}){let{base:a="HEAD",minContainment:o=.7,minCallees:r=3,minSiteCoverage:n=.4,maxHelpers:c=Number.POSITIVE_INFINITY,limit:m=20,scanLimit:g}=t,f=t.semantic!==!1,s=t.diffPlan??T(e,{base:a}),l={available:s.note!==_,base:a,changedFiles:s.changedFiles,helpersChecked:0,skipped:[],findings:[]};if(!l.available||s.changedFiles.length===0)return l;let x=new w(e),k=new Set(s.changedFiles),$=new Map(s.renamedFiles.map(i=>[i.to,i.from])),z=t.baseContentAt??E(e.config.projectRoot,a,L(s)),h=X(x,k,$,z);if(h.length===0)return l;let R=h.slice(0,c);h.length>c&&(l.note=`helper scoring capped at ${c} of ${h.length} new symbols`);let j=x.calleeMap(R,{semantic:f}),q=R.map(i=>({def:i,callees:O((j.get(i.symbolId)??[]).map(p=>p.symbol))})),M,B=()=>(M??=H(e,{minCallees:Math.min(3,r),scanLimit:g,semantic:f}),M);for(let{def:i,callees:p}of q){let d=C(i.symbol);if(p.size<r){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let P=B(),N=W(p,P);if(N===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let b=Y(e,i.symbolId);if(b.length===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}l.helpersChecked+=1;let I=G({candidateIndex:P,changed:k,helperCallees:p,helperFile:i.relativePath,helperSymbol:i.symbol,minContainment:o,minSiteCoverage:n,migratedFiles:b});I.length!==0&&(I.sort((u,S)=>A(S.migrationScope)-A(u.migrationScope)||S.containment-u.containment||S.siteCoverage-u.siteCoverage||u.file.localeCompare(S.file)),l.findings.push({helperSymbol:i.symbol,helperShortName:d,helperFile:i.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:N,migratedFiles:b.sort(),leftovers:I.slice(0,V)}))}return l.findings.sort((i,p)=>(p.leftovers[0]?.containment??0)-(i.leftovers[0]?.containment??0)||i.helperFile.localeCompare(p.helperFile)),l.findings=l.findings.slice(0,m),l}function G(e){let t=[],a=J(e.helperSymbol,e.helperFile,e.migratedFiles),o=new Set;for(let r of e.helperCallees)for(let n of e.candidateIndex.candidateIndexesByCallee.get(r)??[])o.add(n);for(let r of o){let n=e.candidateIndex.corpus[r];if(n.symbol===e.helperSymbol||e.changed.has(n.file)||n.callees.has(e.helperSymbol))continue;let c=D(e.helperCallees,n.callees);if(c<e.minContainment)continue;let m=[...e.helperCallees].filter(s=>n.callees.has(s)),g=n.callees.size===0?0:m.length/n.callees.size;if(g<e.minSiteCoverage||!m.some(s=>(e.candidateIndex.docFreq.get(s)??0)<=e.candidateIndex.ubiquityThreshold))continue;let f=K(a,n.symbol,n.file);t.push({symbol:n.symbol,shortName:C(n.symbol),file:n.file,...f,containment:c,siteCoverage:g,uniqueSiteCalleeCount:Math.max(0,n.callees.size-m.length),sharedCallees:m.map(C).sort()})}return t}function A(e){return e==="same-scope"?2:e==="unknown"?1:0}function J(e,t,a){let o=new Set([...y(t),...v(F(e))]);for(let r of a)for(let n of y(r))o.add(n);return o}function K(e,t,a){let o=new Set([...y(a),...v(F(t))]);if(e.size===0||o.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...o].filter(n=>e.has(n)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var U=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function y(e){return v(e.replace(/\.[^.]+$/,""))}function v(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!U.has(t))}function W(e,t){let a=0;for(let o of e)(t.docFreq.get(o)??0)<=t.ubiquityThreshold&&(a+=1);return a}function X(e,t,a,o){return e.productionCallableDefinitions({requireFunctionLikeSymbol:!0}).filter(r=>{if(!t.has(r.relativePath))return!1;let n=a.get(r.relativePath)??r.relativePath,c=o(n);return c===null||!new RegExp(`\\b${Z(r.leaf)}\\b`).test(c)})}function Y(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents ref_d ON c.document_id = ref_d.id
5
- WHERE m.symbol_id = ?
6
- AND m.role != 1
7
- ${e.pathExclusionsFor("ref_d")}`,t).map(o=>o.relative_path)}function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{re as a};
8
- //# sourceMappingURL=chunk-2VM46FC5.js.map
@@ -1,2 +0,0 @@
1
- import{b as Q}from"./chunk-B75HZHUP.js";import{a as v}from"./chunk-GBEYTDY5.js";import{b as H,e as U,f as z,g as K}from"./chunk-C5CTSJ6X.js";import{a as X}from"./chunk-UQLFQLAF.js";import{c as Z,d as J,e as q,f as C,l as G}from"./chunk-F6ICF7HL.js";import{e as $}from"./chunk-4KTOV4QN.js";import{b as T}from"./chunk-P5RYBRIO.js";import{h as V,n as x}from"./chunk-4N4WONI4.js";import{c as A,f as M,g as O,h as j,i as B,j as W}from"./chunk-JM72FNGA.js";import{a as k,d as E}from"./chunk-HF25DFSC.js";import{a as _}from"./chunk-DS6QEB3G.js";import{b as P,d as N,e as F}from"./chunk-XUGQU7PM.js";import{a as h}from"./chunk-64MNV6AB.js";import{b as S}from"./chunk-7S5E7KWT.js";var g=new WeakMap;function ee(e,t){let n=k(t);if(!(n==="rust"||n==="typescript"||n==="tsx"||n==="javascript"))return[];let r=_(e,t);if(!r)return[];let o=P(e,t,r),s=N(e,"definition-exclusions",t,o);if(s){let a=he(s);if(a)return a}let u=n==="rust"?De(e,t):_e(e,t);return F(e,"definition-exclusions",t,o,JSON.stringify(u)),u}function he(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(xe)?null:t}catch{return null}}function xe(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.startLine!="number"||!Number.isFinite(t.startLine)||typeof t.endLine!="number"||!Number.isFinite(t.endLine)||typeof t.reason!="string"?!1:t.containerName===void 0||typeof t.containerName=="string"}var te=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]),Re=/\b(?:describe|it|test|fdescribe|fit|xdescribe|xit|beforeEach|afterEach|beforeAll|afterAll|before|after|suite|bench|benchmark)\s*\(/,Se=/\b(?:export\s+)?(?:async\s+)?function\s+use[A-Z][A-Za-z0-9_$]*\b|\b(?:const|let|var)\s+use[A-Z][A-Za-z0-9_$]*\s*(?::[^=;]+)?=\s*(?:async\s*)?(?:function\b|(?:<[^=;{]+>\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>)/;function _e(e,t){let n=_(e,t);if(!n||!Ee(n))return[];let i=E(e,t);if(!i)return[];let r=g.get(i);if(r)return r;let o=!1,s=i.rootNode;for(let a of s.namedChildren){if(a.type!=="expression_statement")continue;let l=a.namedChild(0);if(!l||l.type!=="call_expression")continue;let c=l.namedChild(0);if(!c)continue;let f=c.type==="member_expression"?c.namedChild(c.namedChildCount-1)?.text:c.text;if(f&&te.has(f)){o=!0;break}}let u=[];o&&u.push({startLine:0,endLine:s.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"});for(let a of s.namedChildren){let l=null,c=null;if(a.type==="function_declaration")l=a.namedChild(0)?.text??null,c=a;else if(a.type==="export_statement"){let f=a.namedChild(0);f?.type==="function_declaration"&&(l=f.namedChild(0)?.text??null,c=f)}else if(a.type==="lexical_declaration"){let f=a.namedChild(0);if(f?.type==="variable_declarator"){let m=f.namedChild(0)?.text,b=f.namedChild(1);m&&(b?.type==="arrow_function"||b?.type==="function_expression")&&(l=m,c=f)}}l&&/^use[A-Z]/.test(l)&&c&&u.push({startLine:c.startPosition.row,endLine:c.endPosition.row,reason:"React custom hook (use*)"})}return u.push(...ne(i,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),g.set(i,u),u}function Ee(e){if(e.includes("scip-query"))return!0;let t=!1;for(let n of te)if(e.includes(n)){t=!0;break}return t&&Re.test(e)?!0:e.includes("use")&&Se.test(e)}var Ce=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function ve(e){return Ce.test(e)}function ne(e,t,n){let i=[],r=o=>{if(t.has(o.type)&&o.parent){let u=o.parent.children,a=-1;for(let l=0;l<u.length;l+=1)if(u[l].startIndex===o.startIndex&&u[l].type===o.type){a=l;break}if(a>0)for(let l=a-1;l>=0;l-=1){let c=u[l];if(n.has(c.type)){if(ve(c.text)){i.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(c.type==="attribute_item"||c.type==="inner_attribute_item"))break}}for(let s of o.namedChildren)r(s)};return r(e.rootNode),i}function De(e,t){let n=E(e,t);if(!n)return[];let i=g.get(n);if(i)return i;let r=[],o=Le(n);return o?(g.set(n,o),o):(re(n.rootNode,r,!1,!1),r.push(...ne(n,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),r.push(...Ae(n.rootNode)),g.set(n,r),r)}function Le(e){return Me(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)"}]:null}function re(e,t,n,i){let r=n,o=i;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(o=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),e.type==="function_item"||e.type==="function_signature_item"?we(e,t,n,i):i&&Te(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?Ie(e,t,n):e.type==="mod_item"&&D(e).some(s=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(s))&&(r=!0);for(let s of e.namedChildren)re(s,t,r,o)}function we(e,t,n,i){let r=D(e),o=null;i?o="trait impl method (dynamic dispatch)":n&&(o="inside #[cfg(test)] mod");for(let s of r){let u=Ne(s);if(u){o=u;break}if(ie(s)){o="#[allow(dead_code)]";break}}o&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:o})}function Ie(e,t,n){let i=D(e),r=e.namedChildren.find(o=>o.type==="type_identifier")?.text;i.some(ke)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:r}),i.some(ie)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:r}),n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:r})}function D(e){let t=e.parent;if(!t)return[];let n=t.children,i=-1;for(let o=0;o<n.length;o+=1)if(n[o].startIndex===e.startIndex&&n[o].type===e.type){i=o;break}if(i<=0)return[];let r=[];for(let o=i-1;o>=0;o-=1){let s=n[o];if(s.type==="attribute_item"||s.type==="inner_attribute_item")r.push(s.text);else{if(s.type==="line_comment"||s.type==="block_comment")continue;break}}return r}var Pe=[{re:/#\[\s*tauri::command\b/,reason:"#[tauri::command]"},{re:/#\[\s*command\b/,reason:"#[command]"},{re:/#\[\s*test\b/,reason:"#[test]"},{re:/#\[\s*bench\b/,reason:"#[bench]"},{re:/#\[\s*tokio::test\b/,reason:"#[tokio::test]"},{re:/#\[\s*async_std::test\b/,reason:"#[async_std::test]"},{re:/#\[\s*wasm_bindgen\b/,reason:"#[wasm_bindgen]"},{re:/#\[\s*no_mangle\b/,reason:"#[no_mangle]"},{re:/#\[\s*napi\b/,reason:"#[napi]"},{re:/#\[\s*pyfunction\b/,reason:"#[pyfunction]"},{re:/#\[\s*pymethod\b/,reason:"#[pymethod]"},{re:/#\[\s*pyo3\b/,reason:"#[pyo3]"},{re:/#\[\s*cfg\s*\(\s*test\s*\)/,reason:"#[cfg(test)]"},{re:/#\[\s*doc\s*\(\s*hidden\s*\)/,reason:"#[doc(hidden)]"}];function Ne(e){return Pe.find(({re:t})=>t.test(e))?.reason??null}var Fe=[/\bSerialize\b/,/\bDeserialize\b/,/\bFromRow\b/,/\bsqlx::FromRow\b/,/\bDeriveEntityModel\b/,/\bIntoSchema\b/,/\bToSchema\b/,/\bDeriveValueType\b/,/\bError\b/,/\bthiserror::Error\b/];function ke(e){return/#\[\s*derive\s*\(/.test(e)?Fe.some(t=>t.test(e)):!1}function ie(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function Te(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function Ae(e){let t=je(e);if(t.size===0)return[];let n=[];for(let i of e.descendantsOfType("mod_item")){let r=i.childForFieldName("name")?.text;r&&t.has(r)&&n.push({startLine:i.startPosition.row,endLine:i.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:r})}return n}function Me(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let n=e.namedChild(t);if(!n||n.type!=="line_comment"&&n.type!=="block_comment")break;if(/@generated\b/.test(n.text)||/This file is .*generated\b/i.test(n.text)||/Code generated by/i.test(n.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(n.text)||/openapi-generator/i.test(n.text)&&/Generated by/i.test(n.text))return!0}return!1}var Oe=/^#!?\[\s*serde\s*\(/,Y=/\bwith\s*=\s*"([^"]+)"/g;function je(e){let t=new Set;for(let n of e.descendantsOfType("attribute_item")){if(!Oe.test(n.text))continue;Y.lastIndex=0;let i;for(;(i=Y.exec(n.text))!==null;){let r=i[1],o=r.split("::").pop()??r;o&&t.add(o)}}return t}function oe(e){let t=new Map,n=i=>{let r=t.get(i);if(r)return r;let o=ee(e,i);return r={ranges:o.map(s=>({startLine:s.startLine,endLine:s.endLine})),containers:new Set(o.map(s=>s.containerName).filter(s=>!!s))},t.set(i,r),r};return(i,r,o,s)=>{let u=n(i);for(let a of u.ranges)if(r>=a.startLine&&r<=a.endLine)return!0;if(s&&u.containers.has(s))return!0;for(let a of x(o))if(u.containers.has(a))return!0;return!1}}function ct(e,t={}){S(e,{groups:t.semanticProvider===!0?["whole-project","semantic-provider"]:["whole-project"]})}function se(e,t,n={}){S(e,{groups:n.definitions===!0?["source-file","definition-catalog"]:["source-file"],file:t.replace(/\\/g,"/")})}function ce(e,t){return t.isIgnoredPath(e.relativePath)?p("ignored-file"):j(e.symbol)?p("module-like-symbol"):ae(e.symbol)?!e.isFunctionLike&&e.enclosingSymbol&&ae(e.enclosingSymbol)?p("nested-non-callable-value"):!t.includeTests&&!L(e.relativePath)?p("test-file"):!t.includeTests&&t.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName)?p("excluded-file-region"):B(e.symbol)?p("rust-trait-impl-member"):W(e.symbol)?p("rust-test-module"):!t.includeMembers&&!Be(e)?p("member"):e.endLine-e.startLine+1<t.minLoc?p("below-min-loc"):{accepted:!0}:p("non-value-symbol")}function L(e){return H(e)!=="test"}function p(e){return{accepted:!1,rejectionReason:e}}function ae(e){return O(e)||e.endsWith("().")||e.endsWith(".")}function Be(e){return M(e.symbol)||x(e.symbol).length===0}function le(){return new Map}function ue(e,t,n){let i=new Map;for(let r of Z(e,n))e.isIgnored(r.relative_path)||t.has(r.relative_path)||R(i,r.symbol_id,r.relative_path,r.ref_count,"scip-mention");return i}function fe(e,t,n){let i=new Set;for(let r of J(e,t))e.isIgnored(r.relative_path)||n.has(r.relative_path)||i.add(r.symbol_id);return i}function w(e,t){let n=e.get(t);if(!n)return!1;for(let i of n.values())if(i.occurrences>0)return!0;return!1}function I(e,t,n){let i=e.get(t);if(!i)return!1;for(let[r,o]of i)if(r!==n&&o.occurrences>0)return!0;return!1}function de(e){return e?.occurrences??0}function R(e,t,n,i,r="source-fallback"){if(i<=0)return;let o=pe(e,t,n);o.occurrences+=i,o.sources.add(r)}function me(e,t,n,i,r){if(i<=0)return;let o=pe(e,t,n);o.occurrences=Math.max(i,o.occurrences),o.sources.add(r)}function pe(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));let r=i.get(n);return r||(r={occurrences:0,sources:new Set},i.set(n,r)),r}var We=3e3,He=1e3;function Ft(e,t={}){let{scope:n,minLoc:i=1,includeTests:r=!1,skipBarrels:o=!1,includeMembers:s=!1,deadCodeOnly:u=!1,scanLimit:a,semantic:l=!0}=t,c=Q(Ue(e,{scope:n,minLoc:i,includeTests:r,includeMembers:s}),a),f=o?new Set(U(e)):new Set,m=u?le():ue(e,f,c.map(d=>d.symbolId)),b=u?fe(e,c.map(d=>d.symbolId),f):new Set,y=u?c.filter(d=>!b.has(d.symbolId)):c.filter(d=>!I(m,d.symbolId,d.relativePath));u?Je(e,y,m,f):Ze(e,y,m,f);let ye=u?y.filter(d=>!w(m,d.symbolId)):y.filter(d=>!I(m,d.symbolId,d.relativePath));Qe(e,ye,m,{includeTests:r,inactiveBarrelPaths:f,includeSemantic:!u&&l});let ge=u?y.filter(d=>!w(m,d.symbolId)):c;return Ve(e,ze(ge,m))}function Ue(e,t){let n=oe(e),i=[];for(let r of V(e,t.scope))ce(r,{minLoc:t.minLoc,includeTests:t.includeTests,includeMembers:t.includeMembers,isIgnoredPath:s=>e.isIgnored(s),isExcludedRegion:n}).accepted&&i.push(r);return i}function ze(e,t){return e.map(n=>Ke(n,t)).filter(n=>n.cross_file_refs===0).sort((n,i)=>i.loc-n.loc||n.relative_path.localeCompare(i.relative_path)||n.start_line-i.start_line)}function Ke(e,t){let n=t.get(e.symbolId)??new Map,i=de(n.get(e.relativePath)),r=0;for(let[o,s]of n)o!==e.relativePath&&(r+=s.occurrences);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,same_file_refs:i,cross_file_refs:r}}function Ve(e,t){let n=[],i=0,r=0,o=0;for(let s of t){if(e.isIgnored(s.relative_path)||z(e,s.relative_path)||K(e,s.symbol,s.relative_path))continue;let u=s.same_file_refs===0?"dead-code":"file-internal";u==="dead-code"?i++:r++,o+=s.loc,n.push({relativePath:s.relative_path,startLine:s.start_line,endLine:s.end_line,loc:s.loc,symbol:s.symbol,shortName:A(s.symbol),sameFileRefs:s.same_file_refs,kind:u})}return{symbols:n,counts:{total:n.length,deadCode:i,fileInternal:r,loc:o},totalCount:n.length,deadCodeCount:i,fileInternalCount:r,totalLoc:o}}function Ze(e,t,n,i){if(t.length===0)return;let r=new v(e),o=new Set(t.map(a=>a.symbolId)),s=new Set(t.map(a=>a.leaf).filter(Boolean)),u=new Set(r.sourceFiles());for(let a of h(e))u.add(a);r.scanSourceReferences({paths:u,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:s,skipPath:a=>i.has(a)},a=>{o.has(a.target.symbolId)&&(Ge(e,a)||R(n,a.target.symbolId,a.sourceFile,Xe(a),"source-fallback"))})}function Je(e,t,n,i){if(t.length===0)return;let r=new v(e),o=qe(t),s=new Set(r.sourceFiles());for(let c of h(e))s.add(c);let u=new Set(o.keys()),a=new Map,l=c=>{let f=a.get(c);return f||(f=G(e,c),a.set(c,f)),f};r.scanSourceReferences({paths:s,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:u,skipPath:c=>i.has(c),resolveTargets:({sourceFile:c,name:f,kind:m})=>{let b=o.get(f);return b?$e(c,f,b,l(c),{permissive:m!=="cross-language-dispatch"}):[]},afterPath:c=>{a.delete(c),se(e,c)}},c=>{let f=c.kind==="identifier"&&c.sourceFile===c.target.relativePath?Math.max(0,c.occurrences-1):c.occurrences;c.kind==="identifier"&&be(e,{sourceFile:c.sourceFile,name:c.name,target:c.target,occurrences:f})||R(n,c.target.symbolId,c.sourceFile,f,"source-fallback")})}function qe(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let i=t.get(n.leaf)??[];i.push(n),t.set(n.leaf,i)}return t}function $e(e,t,n,i,r){let o=n.filter(a=>a.relativePath===e);if(o.length>0)return o;if(!r.permissive&&n.length===1)return[...n];let s=i.get(t);if(s)for(let a of s){let l=n.filter(c=>C(a,c.relativePath));if(l.length>0)return l}let u=new Set;for(let a of i.values())for(let l of a)u.add(l);for(let a of u){let l=n.filter(c=>C(a,c.relativePath));if(l.length>0&&l.length===n.length)return l}return r.permissive?[...n]:[]}function Ge(e,t){return t.kind==="cross-language-dispatch"&&t.target.relativePath===t.sourceFile?!0:t.kind==="identifier"&&be(e,t)}function Xe(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function be(e,t){return t.occurrences>1?!1:T(e,t.sourceFile).some(n=>n.used||n.sourcePath!==t.target.relativePath?!1:n.importedName===t.name||n.localName===t.name)}function Qe(e,t,n,i){let r=i.includeSemantic!==!1,o=r&&t.length>=We&&h(e).length>=He,s=(a,l)=>{l===a.relativePath||e.isIgnored(l)||i.inactiveBarrelPaths.has(l)||!i.includeTests&&!L(l)||me(n,a.symbolId,l,1,"caller-map")};if(o)Ye(e,t,s);else for(let a of t){let l=X(e,a,{semantic:r});if(l.length!==0)for(let c of l)s(a,c.file)}if(!o)return;let u=$(e,t);for(let a of t){let l=u.get(a.symbolId);if(l)for(let c of l)s(a,c)}}function Ye(e,t,n){let i=new Map(t.map(r=>[r.symbolId,r]));for(let r of q(e,[...i.keys()])){let o=i.get(r.symbol_id);o&&n(o,r.relative_path)}}export{ct as a,Ft as b};
2
- //# sourceMappingURL=chunk-3Q77KKEY.js.map
@@ -1,2 +0,0 @@
1
- function o(e){let f=[];if(e.filePattern){let l=e.profiles.find(r=>r.file.includes(e.filePattern));if(!l)return[];for(let r of e.profiles){if(r.file===l.file||e.focusFiles&&!e.focusFiles.has(l.file)&&!e.focusFiles.has(r.file))continue;let i=e.compare(l,r);i&&f.push(i)}}else{if(e.focusFiles?.size===0)return[];let l=e.focusFiles?e.profiles.map((i,n)=>e.focusFiles.has(i.file)?n:-1).filter(i=>i>=0):[],r=typeof e.overrunFactor=="number"&&Number.isFinite(e.limit)?e.limit*e.overrunFactor:Number.POSITIVE_INFINITY;for(let i=0;i<e.profiles.length;i+=1){let n=e.profiles[i];if(e.focusFiles&&!e.focusFiles.has(n.file))for(let s of l){if(s<=i)continue;let t=e.compare(n,e.profiles[s]);t&&f.push(t)}else for(let s=i+1;s<e.profiles.length;s+=1){let t=e.compare(n,e.profiles[s]);t&&f.push(t)}if(f.length>r)break}}return f.sort(e.sort??((l,r)=>r.similarity-l.similarity)),f.slice(0,e.limit)}export{o as a};
2
- //# sourceMappingURL=chunk-3VD3JMK2.js.map
@@ -1,3 +0,0 @@
1
- import{l as T}from"./chunk-OBGRLXWF.js";import{f as g}from"./chunk-4N4WONI4.js";import{d as h}from"./chunk-JM72FNGA.js";import{c as B,g as _,i as V}from"./chunk-XUGQU7PM.js";import{a as k}from"./chunk-64MNV6AB.js";import{a as W,c as $}from"./chunk-7S5E7KWT.js";function p(r,e,t){if(r.has(e))return r.get(e);let n=t();return r.set(e,n),n}import J from"path";function de(r,e){return r.getReferences().map(t=>{let n=t.getNode();return Y(n,e)})}function me(r){let e=r;return typeof e.findReferences=="function"?e.findReferences():[]}function z(r,e,t,n){let i=[];for(let o of me(r))for(let s of de(o,n))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||i.push(s);for(let o of t)i.push(o);return M(i)}function K(r,e,t,n){let i=[],o=t?.getStart();for(let s of r.getReferences()){let a=s.getNode();S(n,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||i.push({location:Y(a,n),node:a}))}return i}function Y(r,e){let t=r.getSourceFile(),n=t.getLineAndColumnAtPos(r.getStart());return{file:S(e,t.getFilePath())??t.getBaseName(),line:n.line-1,column:n.column-1}}function X(r,e,t){let n=r.getSourceFile(),i=y(n,r),o=r.getText(),s=new RegExp(`\\b${ge(o)}\\b`,"g"),a=n.getFullText().split(`
2
- `),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let u=a[l]??"";s.lastIndex=0;let d;for(;(d=s.exec(u))!==null;)c.push({file:e,line:l,column:d.index})}return M(c.filter(l=>S(t,J.join(t,l.file))===e))}function R(r){for(let e=r;e;e=e.getParent()){let t=e.getKindName();if(t.includes("Type")||t==="InterfaceDeclaration"||t==="TypeAliasDeclaration")return!0;if(t==="CallExpression"||t==="NewExpression"||t==="ExpressionStatement")return!1}return!1}function y(r,e){return r.getLineAndColumnAtPos(e.getStart()).line-1}function M(r){let e=new Set,t=[];for(let n of r){let i=`${n.file}:${n.line}:${n.column}`;e.has(i)||(e.add(i),t.push(n))}return t}function S(r,e){let t=J.relative(r||process.cwd(),e).replace(/\\/g,"/");return!t||t.startsWith("..")?null:t}function ge(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(r,e,t,n){let i=ye(e,n);return i.size===0?new Map:he(r,t,i)}function ye(r,e){let t=new Map;for(let n of g(r,e)){let i=h(n.symbol)??n.leaf;if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push(n)}return t}function he(r,e,t){let n=new Map,i=new Map;return e.forEachDescendant(o=>{for(let s of Se(r,o)){let a=t.get(s);if(!a)continue;let c=y(e,o);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let u=Math.abs(c-l.startLine),d=i.get(l.symbolId);d!==void 0&&d<=u||(i.set(l.symbolId,u),n.set(l.symbolId,o))}}}),n}function Se(r,e){let t=[],n=i=>{i&&!t.includes(i)&&t.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();n(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();n(i)}return r.Node.isIdentifier(e)&&n(e.getText()),t}var xe=$("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function H(r,e,t,n){let i=Z(r,e),o=G(i.get(n)??[],t);if(o)return o;let s=[];for(let a of i.values())for(let c of a)((c.leaf||h(c.symbol)||"").includes(n)||c.symbol.includes(n))&&s.push(c);return G(s,t)}function Q(r,e){let t=new Map;for(let[n,i]of Z(r,e)){let o=i[0];o&&t.set(n,o)}return t}function Z(r,e){return xe.get(r,e,()=>{let t=new Map;for(let n of g(r,e)){let i=n.leaf||h(n.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push({...n,leaf:i})}for(let n of t.values())n.sort((i,o)=>i.startLine-o.startLine||i.endLine-o.endLine||i.symbolId-o.symbolId);return t})}function G(r,e){let t=null,n=Number.POSITIVE_INFINITY;for(let i of r){let o=Math.abs(i.startLine-e);(o<n||o===n&&t&&i.startLine<t.startLine)&&(t=i,n=o)}return t}import Ie from"path";var x=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function I(r){let e=r.toLowerCase();return x.some(t=>e.endsWith(t))}function ee(r,e){let t=new Map,n=i=>I(i)?p(t,i,()=>{let o=Ie.join(r.config.projectRoot,i);for(let{project:s}of e){let a=s.getSourceFile(o)??s.addSourceFileAtPathIfExists(o)??null;if(a)return{project:s,sourceFile:a}}return null}):null;return{sourceFile:i=>n(i)?.sourceFile??null,sourceFileMatch:n,indexedTypeScriptLikeDocuments:()=>k(r,{extensions:x})}}import m from"path";import{existsSync as F,readdirSync as be,readFileSync as te}from"fs";function ne(r){let e=m.join(r,"package.json");if(!F(e))return[];let t;try{t=JSON.parse(te(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>De(r,i)).flatMap(i=>Ne(r,i))}function De(r,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=m.join(r,e);return F(m.join(s,"package.json"))?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=m.join(r,n||".");if(!F(o))return[];try{return be(o).map(s=>m.join(o,s,i)).filter(s=>F(m.join(s,"package.json")))}catch{return[]}}function Ne(r,e){try{let t=JSON.parse(te(m.join(e,"package.json"),"utf8"));if(!t.name)return[];let n=m.relative(r,e).replace(/\\/g,"/");return[{name:t.name,rootRelative:n,sourceRootRelative:`${n}/src`}]}catch{return[]}}function re(r,e){for(let t of r)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function ie(r){return[`${r.sourceRootRelative}/index.ts`,`${r.sourceRootRelative}/index.tsx`,`${r.sourceRootRelative}/index.mts`,`${r.sourceRootRelative}/index.cts`]}import{existsSync as b,readFileSync as ke,readdirSync as Me,statSync as Fe}from"fs";import f from"path";var E=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function j(r,e){let n=e?f.dirname(f.join(r,e)):r,i=f.resolve(r);for(;n.startsWith(i);){for(let s of E){let a=f.join(n,s);if(b(a))return a}let o=f.dirname(n);if(o===n)break;n=o}for(let o of E){let s=f.join(r,o);if(b(s))return s}return null}function oe(r){let e=r.config.projectRoot,t=new Set(ve(e,r.config.semantic?.typescript?.tsconfigs)),n=k(r,{includeIgnored:!1,extensions:x});for(let i of n){let o=j(e,i);o&&t.add(f.resolve(o))}if(t.size===0){let i=j(e);i&&t.add(f.resolve(i))}return[...t].filter(i=>!se(e,i)).sort((i,o)=>i.localeCompare(o))}function ve(r,e=[]){let t=new Set;for(let n of e){let i=f.isAbsolute(n)?n:f.join(r,n);b(i)&&t.add(f.resolve(i))}for(let n of Pe(r))for(let i of E){let o=f.join(n,i);b(o)&&t.add(f.resolve(o))}if(t.size===0){let n=j(r);n&&t.add(f.resolve(n))}return[...t].filter(n=>!se(r,n)).sort((n,i)=>n.localeCompare(i))}function Pe(r){let e=f.join(r,"package.json");if(!b(e))return[];let t;try{t=JSON.parse(ke(e,"utf8"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>Te(r,i))}function Te(r,e){if(!e||e.startsWith("!")||e.includes("node_modules"))return[];if(!e.includes("*")){let s=f.join(r,e);return C(s)?[s]:[]}let t=e.indexOf("*"),n=e.slice(0,t).replace(/\/$/,""),i=e.slice(t+1).replace(/^\//,""),o=f.join(r,n||".");return C(o)?Me(o).map(s=>f.join(o,s,i)).filter(C):[]}function C(r){try{return Fe(r).isDirectory()}catch{return!1}}function se(r,e){let t=f.relative(r,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}import{createRequire as Re}from"module";var Ce=Re(import.meta.url),D;function ae(){if(D!==void 0)return D;try{D=Ce("ts-morph")}catch{D=null}return D}function ce(r,e){return e.map(t=>({tsconfigPath:t,project:new r.Project({tsConfigFilePath:t,skipFileDependencyResolution:!1})}))}function v(r,e,t){return{language:"typescript",availability:()=>({available:!1,reason:r,tsconfigPath:e,tsconfigPaths:t}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function pe(r,e){let t=ae();if(!t)return v("ts-morph is not installed");let n=oe(r);if(n.length===0)return v("no tsconfig found");try{let i=ce(t,n);return new w(r,t,i)}catch(i){return v(i instanceof Error?i.message:String(i),n[0],n)}}var w=class{constructor(e,t,n){this.db=e;this.tsMorph=t;this.projects=n;this.workspacePackages=ne(e.config.projectRoot),this.sourceFiles=ee(e,n)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return p(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let n=[];for(let i of t.getImportDeclarations())for(let o of this.importUsageForDeclaration(e,i))n.push(o);return n})}referencesFor(e){return p(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e),n=this.packageImportReferencesForDefinition(e);return t?z(t,e,n,this.db.config.projectRoot):n})}calleesFor(e){return p(this.calleesCache,e.symbolId,()=>p(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}signatureFor(e){return p(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let n=t.getType().getCallSignatures()[0];if(!n)return null;let i=n.getParameters().map(s=>{let a=s.getDeclarations()[0],c=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return fe(c)}),o=n.getReturnType().getText(t);return`(${i.join(",")})=>${fe(o)}`})}importUsageForDeclaration(e,t){let n=T(this.db,e,t.getModuleSpecifierValue()),i=le(t);return t.getImportClause()?.isTypeOnly()?i.map(o=>Ee(e,n,o)):i.map(o=>this.valueImportUsageForEntry(e,n,o))}valueImportUsageForEntry(e,t,n){let i=n.identifier?n.identifier.findReferences():[],o=[];for(let l of i)for(let u of K(l,e,n.identifier,this.db.config.projectRoot))o.push(u);let s=o.some(l=>!R(l.node)),a=o.some(l=>R(l.node)),c=n.isTypeOnly;return{importer:e,sourcePath:t,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:c,isUsed:c||o.length>0,isTypeUsed:c||a,isValueUsed:s,references:o.map(l=>l.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let n of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,n);for(let[n,i]of e)e.set(n,M(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,n){if(this.db.isIgnored(n))return;let i=this.sourceFiles.sourceFileMatch(n);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,n,o)}addPackageImportReferencesForDeclaration(e,t,n,i){let o=re(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of le(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let l=X(a.identifier,n,this.db.config.projectRoot);l.length>0&&Le(e,c,l)}}packageExports(){if(this.packageExportIndex)return this.packageExportIndex;let e=new Map;for(let t of this.workspacePackages){let n=new Map;for(let i of ie(t))this.collectPackageExports(t,i,n,new Set);n.size>0&&e.set(t.name,n)}return this.packageExportIndex=e,e}collectPackageExports(e,t,n,i){if(i.has(t))return;i.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?T(this.db,t,a):t;if(!c||!c.startsWith(`${e.sourceRootRelative}/`))continue;let l=s.getNamedExports();if(l.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,n,i);continue}for(let u of l){let d=u.getNameNode().getText(),O=u.getAliasNode()?.getText()??d,U=this.indexedDefinitionByLeaf(c,d);if(!U)continue;let N=n.get(O);N||(N=new Set,n.set(O,N)),N.add(U.symbolId)}}}indexedDefinitionByLeaf(e,t){return p(this.indexedDefinitionLeafCache,e,()=>Q(this.db,e)).get(t)??null}nodeForDefinition(e){return p(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return p(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?q(this.tsMorph,this.db,t,e):new Map})}definitionFromSymbol(e){let t=e.getDeclarations();for(let n of t){let i=n.getSourceFile(),o=S(this.db.config.projectRoot,i.getFilePath());if(!o||this.db.isIgnored(o))continue;let s=y(i,n),a=H(this.db,o,s,e.getName());if(a)return{symbol:a.symbol,file:a.relativePath,line:a.startLine}}return null}calleeMapForFile(e){let t=this.sourceFiles.sourceFile(e);if(!t)return new Map;let n=g(this.db,e).sort((o,s)=>o.startLine-s.startLine||s.endLine-o.endLine);if(n.length===0)return new Map;let i=new Map;t.forEachDescendant(o=>{if(!this.tsMorph.Node.isCallExpression(o)&&!this.tsMorph.Node.isNewExpression(o))return;let s=this.semanticCalleeForCallNode(t,n,o);s&&je(i,s.callerId,s.target)});for(let[o,s]of i)i.set(o,Ae(s));return i}semanticCalleeForCallNode(e,t,n){let i=we(t,y(e,n));if(!i)return null;let o=n.getExpression(),s=o.getSymbol()??o.getType().getSymbol(),a=s?this.definitionFromSymbol(s):null;return a?{callerId:i.symbolId,target:{symbol:a.symbol,file:a.file,line:a.line}}:null}};function le(r){let e=[],t=r.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:r.getImportClause()?.isTypeOnly()??!1});let n=r.getNamespaceImport();n&&e.push({identifier:n,importedName:"*",localName:n.getText(),kind:"namespace",isTypeOnly:r.getImportClause()?.isTypeOnly()??!1});for(let i of r.getNamedImports()){let o=i.getNameNode(),a=i.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(r.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Ee(r,e,t){return{importer:r,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function je(r,e,t){let n=r.get(e);n||(n=[],r.set(e,n)),n.push(t)}function we(r,e){let t=null;for(let n of r)e<n.startLine||e>n.endLine||(!t||n.startLine>=t.startLine)&&(t=n);return t}function Le(r,e,t){for(let n of e){let i=r.get(n)??[];i.push(...t),r.set(n,i)}}function Ae(r){let e=new Set,t=[];for(let n of r){let i=`${n.symbol}|${n.file}|${n.line}`;e.has(i)||(e.add(i),t.push(n))}return t}function fe(r){return r.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}var L=new WeakMap;W({name:"semantic-provider",groups:["semantic-provider"],clearAll:r=>L.delete(r)});function A(r,e){let t=`${r.config.projectRoot}:typescript-workspace`,n=L.get(r);n||(n=new Map,L.set(r,n));let i=n.get(t);if(i)return i;let o=pe(r,e);return n.set(t,o),o}function Tt(r,e){let t=P(r,e);return t?t.importUsage(e):[]}function ue(r,e){let t=P(r,e.relativePath);return t?t.referencesFor(e):[]}function Rt(r,e){let t=new Map,n=B(r),i=[];for(let o of e){let s=Oe(r,o,n,i);for(let a of s){if(a.file===o.relativePath||r.isIgnored(a.file))continue;let c=t.get(o.symbolId);c||(c=new Set,t.set(o.symbolId,c)),c.add(a.file)}}return i.length>0&&A(r).availability().available&&V(r,i),t}function Oe(r,e,t,n){if(!t||!I(e.relativePath))return ue(r,e);let i=_(r,e.relativePath,e.symbol,t);if(i!==null){let s=Ue(i);if(s)return s}let o=ue(r,e);return n.push({relativePath:e.relativePath,symbol:e.symbol,projectFingerprint:t,payload:JSON.stringify(o)}),o}function Ue(r){try{return JSON.parse(r)}catch{return null}}function Ct(r,e){let t=new Map;for(let n of e){let i=P(r,n.relativePath);if(!i)continue;let o=i.calleesFor(n);o.length>0&&t.set(n.symbolId,o)}return t}function Et(r,e){let t=P(r,e.relativePath);return t?t.signatureFor(e):null}function P(r,e){if(!I(e))return null;let t=A(r,e);return t.availability().available?t:null}export{I as a,A as b,Tt as c,ue as d,Rt as e,Ct as f,Et as g};
3
- //# sourceMappingURL=chunk-4KTOV4QN.js.map