ts-knowledge-graph 0.1.2 → 0.1.6

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 (335) hide show
  1. package/README.md +99 -41
  2. package/contribs/webview/README.md +83 -0
  3. package/contribs/webview/web/css/style.css +310 -0
  4. package/contribs/webview/web/index.html +109 -0
  5. package/contribs/webview/web/js/app.js +1249 -0
  6. package/contribs/webview/web/js_autogenerated/.gitignore +3 -0
  7. package/contribs/webview/web/js_autogenerated/kind_descriptions.js +39 -0
  8. package/contribs/webview/web/types/app_globals.d.ts +154 -0
  9. package/dist/benchmark/benchmark_stats.d.ts +41 -0
  10. package/dist/benchmark/benchmark_stats.d.ts.map +1 -0
  11. package/dist/benchmark/benchmark_stats.js +61 -0
  12. package/dist/benchmark/benchmark_stats.js.map +1 -0
  13. package/dist/benchmark/node_benchmark.d.ts +78 -0
  14. package/dist/benchmark/node_benchmark.d.ts.map +1 -0
  15. package/dist/benchmark/node_benchmark.js +112 -0
  16. package/dist/benchmark/node_benchmark.js.map +1 -0
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +16 -4
  19. package/dist/cli.js.map +1 -1
  20. package/dist/cluster/cluster_weights.d.ts +20 -0
  21. package/dist/cluster/cluster_weights.d.ts.map +1 -0
  22. package/dist/cluster/cluster_weights.js +32 -0
  23. package/dist/cluster/cluster_weights.js.map +1 -0
  24. package/dist/cluster/community_detector.d.ts +61 -0
  25. package/dist/cluster/community_detector.d.ts.map +1 -0
  26. package/dist/cluster/community_detector.js +120 -0
  27. package/dist/cluster/community_detector.js.map +1 -0
  28. package/dist/cluster/community_labeler.d.ts +84 -0
  29. package/dist/cluster/community_labeler.d.ts.map +1 -0
  30. package/dist/cluster/community_labeler.js +194 -0
  31. package/dist/cluster/community_labeler.js.map +1 -0
  32. package/dist/cluster/graph_clusterer.d.ts +47 -0
  33. package/dist/cluster/graph_clusterer.d.ts.map +1 -0
  34. package/dist/cluster/graph_clusterer.js +126 -0
  35. package/dist/cluster/graph_clusterer.js.map +1 -0
  36. package/dist/commands/benchmark_command.d.ts +11 -0
  37. package/dist/commands/benchmark_command.d.ts.map +1 -0
  38. package/dist/commands/benchmark_command.js +94 -0
  39. package/dist/commands/benchmark_command.js.map +1 -0
  40. package/dist/commands/blast_radius_command.d.ts.map +1 -1
  41. package/dist/commands/blast_radius_command.js +7 -6
  42. package/dist/commands/blast_radius_command.js.map +1 -1
  43. package/dist/commands/cluster_command.d.ts +7 -0
  44. package/dist/commands/cluster_command.d.ts.map +1 -0
  45. package/dist/commands/cluster_command.js +55 -0
  46. package/dist/commands/cluster_command.js.map +1 -0
  47. package/dist/commands/command_helpers.d.ts +9 -4
  48. package/dist/commands/command_helpers.d.ts.map +1 -1
  49. package/dist/commands/command_helpers.js +13 -8
  50. package/dist/commands/command_helpers.js.map +1 -1
  51. package/dist/commands/cost_command.d.ts +13 -0
  52. package/dist/commands/cost_command.d.ts.map +1 -0
  53. package/dist/commands/cost_command.js +139 -0
  54. package/dist/commands/cost_command.js.map +1 -0
  55. package/dist/commands/{load.d.ts → enrich_command.d.ts} +3 -2
  56. package/dist/commands/enrich_command.d.ts.map +1 -0
  57. package/dist/commands/enrich_command.js +64 -0
  58. package/dist/commands/enrich_command.js.map +1 -0
  59. package/dist/commands/extract_command.d.ts.map +1 -1
  60. package/dist/commands/extract_command.js +12 -6
  61. package/dist/commands/extract_command.js.map +1 -1
  62. package/dist/commands/hotspots_command.d.ts +7 -0
  63. package/dist/commands/hotspots_command.d.ts.map +1 -0
  64. package/dist/commands/hotspots_command.js +68 -0
  65. package/dist/commands/hotspots_command.js.map +1 -0
  66. package/dist/commands/install_command.d.ts +15 -6
  67. package/dist/commands/install_command.d.ts.map +1 -1
  68. package/dist/commands/install_command.js +62 -25
  69. package/dist/commands/install_command.js.map +1 -1
  70. package/dist/commands/load_command.d.ts.map +1 -1
  71. package/dist/commands/load_command.js +20 -13
  72. package/dist/commands/load_command.js.map +1 -1
  73. package/dist/commands/neighbors_command.d.ts.map +1 -1
  74. package/dist/commands/neighbors_command.js +6 -5
  75. package/dist/commands/neighbors_command.js.map +1 -1
  76. package/dist/commands/references_command.d.ts.map +1 -1
  77. package/dist/commands/references_command.js +6 -5
  78. package/dist/commands/references_command.js.map +1 -1
  79. package/dist/commands/report_command.d.ts +16 -0
  80. package/dist/commands/report_command.d.ts.map +1 -0
  81. package/dist/commands/report_command.js +115 -0
  82. package/dist/commands/report_command.js.map +1 -0
  83. package/dist/commands/verify_command.d.ts +8 -0
  84. package/dist/commands/verify_command.d.ts.map +1 -0
  85. package/dist/commands/verify_command.js +57 -0
  86. package/dist/commands/verify_command.js.map +1 -0
  87. package/dist/commands/web_command.d.ts +27 -0
  88. package/dist/commands/web_command.d.ts.map +1 -1
  89. package/dist/commands/web_command.js +109 -3
  90. package/dist/commands/web_command.js.map +1 -1
  91. package/dist/commands/webview_command.d.ts +36 -0
  92. package/dist/commands/webview_command.d.ts.map +1 -0
  93. package/dist/commands/webview_command.js +186 -0
  94. package/dist/commands/webview_command.js.map +1 -0
  95. package/dist/enrich/cpu_profile.d.ts +160 -0
  96. package/dist/enrich/cpu_profile.d.ts.map +1 -0
  97. package/dist/enrich/cpu_profile.js +185 -0
  98. package/dist/enrich/cpu_profile.js.map +1 -0
  99. package/dist/enrich/runtime_enricher.d.ts +64 -0
  100. package/dist/enrich/runtime_enricher.d.ts.map +1 -0
  101. package/dist/enrich/runtime_enricher.js +98 -0
  102. package/dist/enrich/runtime_enricher.js.map +1 -0
  103. package/dist/enrich/runtime_join.d.ts +124 -0
  104. package/dist/enrich/runtime_join.d.ts.map +1 -0
  105. package/dist/enrich/runtime_join.js +270 -0
  106. package/dist/enrich/runtime_join.js.map +1 -0
  107. package/dist/extract/api_extractor.d.ts +24 -0
  108. package/dist/extract/api_extractor.d.ts.map +1 -0
  109. package/dist/extract/api_extractor.js +71 -0
  110. package/dist/extract/api_extractor.js.map +1 -0
  111. package/dist/extract/config_extractor.d.ts +22 -0
  112. package/dist/extract/config_extractor.d.ts.map +1 -0
  113. package/dist/extract/config_extractor.js +61 -0
  114. package/dist/extract/config_extractor.js.map +1 -0
  115. package/dist/extract/endpoint_extractor.d.ts +36 -0
  116. package/dist/extract/endpoint_extractor.d.ts.map +1 -0
  117. package/dist/extract/endpoint_extractor.js +117 -0
  118. package/dist/extract/endpoint_extractor.js.map +1 -0
  119. package/dist/extract/git_source.d.ts +23 -0
  120. package/dist/extract/git_source.d.ts.map +1 -0
  121. package/dist/extract/git_source.js +75 -0
  122. package/dist/extract/git_source.js.map +1 -0
  123. package/dist/extract/graph_builder.d.ts +8 -0
  124. package/dist/extract/graph_builder.d.ts.map +1 -1
  125. package/dist/extract/graph_builder.js +23 -1
  126. package/dist/extract/graph_builder.js.map +1 -1
  127. package/dist/extract/node_id.d.ts +16 -0
  128. package/dist/extract/node_id.d.ts.map +1 -1
  129. package/dist/extract/node_id.js +22 -0
  130. package/dist/extract/node_id.js.map +1 -1
  131. package/dist/extract/scope_resolver.d.ts +22 -0
  132. package/dist/extract/scope_resolver.d.ts.map +1 -0
  133. package/dist/extract/scope_resolver.js +53 -0
  134. package/dist/extract/scope_resolver.js.map +1 -0
  135. package/dist/extract/semantic_extractor.d.ts +25 -0
  136. package/dist/extract/semantic_extractor.d.ts.map +1 -1
  137. package/dist/extract/semantic_extractor.js +96 -2
  138. package/dist/extract/semantic_extractor.js.map +1 -1
  139. package/dist/extract/structural_extractor.d.ts +6 -0
  140. package/dist/extract/structural_extractor.d.ts.map +1 -1
  141. package/dist/extract/structural_extractor.js +22 -12
  142. package/dist/extract/structural_extractor.js.map +1 -1
  143. package/dist/project_root.d.ts +7 -0
  144. package/dist/project_root.d.ts.map +1 -0
  145. package/dist/project_root.js +9 -0
  146. package/dist/project_root.js.map +1 -0
  147. package/dist/query/graph_query.d.ts +269 -0
  148. package/dist/query/graph_query.d.ts.map +1 -1
  149. package/dist/query/graph_query.js +585 -11
  150. package/dist/query/graph_query.js.map +1 -1
  151. package/dist/report/graph_report.d.ts +51 -0
  152. package/dist/report/graph_report.d.ts.map +1 -0
  153. package/dist/report/graph_report.js +312 -0
  154. package/dist/report/graph_report.js.map +1 -0
  155. package/dist/report/pdf_renderer.d.ts +22 -0
  156. package/dist/report/pdf_renderer.d.ts.map +1 -0
  157. package/dist/report/pdf_renderer.js +54 -0
  158. package/dist/report/pdf_renderer.js.map +1 -0
  159. package/dist/report/report_data.d.ts +128 -0
  160. package/dist/report/report_data.d.ts.map +1 -0
  161. package/dist/report/report_data.js +191 -0
  162. package/dist/report/report_data.js.map +1 -0
  163. package/dist/schema/edge.d.ts +40 -5
  164. package/dist/schema/edge.d.ts.map +1 -1
  165. package/dist/schema/edge.js +73 -0
  166. package/dist/schema/edge.js.map +1 -1
  167. package/dist/schema/node.d.ts +20 -5
  168. package/dist/schema/node.d.ts.map +1 -1
  169. package/dist/schema/node.js +36 -0
  170. package/dist/schema/node.js.map +1 -1
  171. package/dist/schema/runtime_manifest.d.ts +36 -0
  172. package/dist/schema/runtime_manifest.d.ts.map +1 -0
  173. package/dist/schema/runtime_manifest.js +23 -0
  174. package/dist/schema/runtime_manifest.js.map +1 -0
  175. package/dist/schema/source_manifest.d.ts +30 -0
  176. package/dist/schema/source_manifest.d.ts.map +1 -0
  177. package/dist/schema/source_manifest.js +21 -0
  178. package/dist/schema/source_manifest.js.map +1 -0
  179. package/dist/store/jsonl_reader.d.ts +4 -0
  180. package/dist/store/jsonl_reader.d.ts.map +1 -1
  181. package/dist/store/jsonl_reader.js +13 -1
  182. package/dist/store/jsonl_reader.js.map +1 -1
  183. package/dist/store/jsonl_store.d.ts +2 -1
  184. package/dist/store/jsonl_store.d.ts.map +1 -1
  185. package/dist/store/jsonl_store.js +4 -1
  186. package/dist/store/jsonl_store.js.map +1 -1
  187. package/dist/store/kuzu_store.d.ts +59 -0
  188. package/dist/store/kuzu_store.d.ts.map +1 -1
  189. package/dist/store/kuzu_store.js +124 -5
  190. package/dist/store/kuzu_store.js.map +1 -1
  191. package/dist/store/output_folder.d.ts +43 -0
  192. package/dist/store/output_folder.d.ts.map +1 -0
  193. package/dist/store/output_folder.js +61 -0
  194. package/dist/store/output_folder.js.map +1 -0
  195. package/dist/verify/project_verifier.d.ts +85 -0
  196. package/dist/verify/project_verifier.d.ts.map +1 -0
  197. package/dist/verify/project_verifier.js +138 -0
  198. package/dist/verify/project_verifier.js.map +1 -0
  199. package/dotclaude_folder/commands/code-graph-interview.md +123 -0
  200. package/dotclaude_folder/commands/code-graph-optimize.md +65 -0
  201. package/{skills/ts-knowledge-graph → dotclaude_folder/skills/code-graph-query}/SKILL.md +6 -6
  202. package/package.json +99 -10
  203. package/.env-sample +0 -34
  204. package/contribs/web_visualisation/README.md +0 -55
  205. package/contribs/web_visualisation/web/css/style.css +0 -115
  206. package/contribs/web_visualisation/web/data/.gitignore +0 -2
  207. package/contribs/web_visualisation/web/index.html +0 -58
  208. package/contribs/web_visualisation/web/js/app.js +0 -364
  209. package/dist/agent/agent-tools.d.ts +0 -13
  210. package/dist/agent/agent-tools.d.ts.map +0 -1
  211. package/dist/agent/agent-tools.js +0 -153
  212. package/dist/agent/agent-tools.js.map +0 -1
  213. package/dist/agent/agent_tools.d.ts +0 -13
  214. package/dist/agent/agent_tools.d.ts.map +0 -1
  215. package/dist/agent/agent_tools.js +0 -153
  216. package/dist/agent/agent_tools.js.map +0 -1
  217. package/dist/agent/code-editor.d.ts +0 -18
  218. package/dist/agent/code-editor.d.ts.map +0 -1
  219. package/dist/agent/code-editor.js +0 -43
  220. package/dist/agent/code-editor.js.map +0 -1
  221. package/dist/agent/code_editor.d.ts +0 -18
  222. package/dist/agent/code_editor.d.ts.map +0 -1
  223. package/dist/agent/code_editor.js +0 -43
  224. package/dist/agent/code_editor.js.map +0 -1
  225. package/dist/agent/optimizer-agent.d.ts +0 -30
  226. package/dist/agent/optimizer-agent.d.ts.map +0 -1
  227. package/dist/agent/optimizer-agent.js +0 -97
  228. package/dist/agent/optimizer-agent.js.map +0 -1
  229. package/dist/agent/optimizer_agent.d.ts +0 -30
  230. package/dist/agent/optimizer_agent.d.ts.map +0 -1
  231. package/dist/agent/optimizer_agent.js +0 -97
  232. package/dist/agent/optimizer_agent.js.map +0 -1
  233. package/dist/agent/verifier.d.ts +0 -9
  234. package/dist/agent/verifier.d.ts.map +0 -1
  235. package/dist/agent/verifier.js +0 -19
  236. package/dist/agent/verifier.js.map +0 -1
  237. package/dist/commands/blast-radius.d.ts +0 -5
  238. package/dist/commands/blast-radius.d.ts.map +0 -1
  239. package/dist/commands/blast-radius.js +0 -18
  240. package/dist/commands/blast-radius.js.map +0 -1
  241. package/dist/commands/blast_radius.d.ts +0 -5
  242. package/dist/commands/blast_radius.d.ts.map +0 -1
  243. package/dist/commands/blast_radius.js +0 -18
  244. package/dist/commands/blast_radius.js.map +0 -1
  245. package/dist/commands/calls.d.ts +0 -5
  246. package/dist/commands/calls.d.ts.map +0 -1
  247. package/dist/commands/calls.js +0 -7
  248. package/dist/commands/calls.js.map +0 -1
  249. package/dist/commands/command-helpers.d.ts +0 -15
  250. package/dist/commands/command-helpers.d.ts.map +0 -1
  251. package/dist/commands/command-helpers.js +0 -61
  252. package/dist/commands/command-helpers.js.map +0 -1
  253. package/dist/commands/dead-exports.d.ts +0 -5
  254. package/dist/commands/dead-exports.d.ts.map +0 -1
  255. package/dist/commands/dead-exports.js +0 -7
  256. package/dist/commands/dead-exports.js.map +0 -1
  257. package/dist/commands/dead_exports.d.ts +0 -5
  258. package/dist/commands/dead_exports.d.ts.map +0 -1
  259. package/dist/commands/dead_exports.js +0 -7
  260. package/dist/commands/dead_exports.js.map +0 -1
  261. package/dist/commands/extract.d.ts +0 -8
  262. package/dist/commands/extract.d.ts.map +0 -1
  263. package/dist/commands/extract.js +0 -49
  264. package/dist/commands/extract.js.map +0 -1
  265. package/dist/commands/find.d.ts +0 -5
  266. package/dist/commands/find.d.ts.map +0 -1
  267. package/dist/commands/find.js +0 -7
  268. package/dist/commands/find.js.map +0 -1
  269. package/dist/commands/load.d.ts.map +0 -1
  270. package/dist/commands/load.js +0 -28
  271. package/dist/commands/load.js.map +0 -1
  272. package/dist/commands/neighbors.d.ts +0 -5
  273. package/dist/commands/neighbors.d.ts.map +0 -1
  274. package/dist/commands/neighbors.js +0 -17
  275. package/dist/commands/neighbors.js.map +0 -1
  276. package/dist/commands/optimize.d.ts +0 -6
  277. package/dist/commands/optimize.d.ts.map +0 -1
  278. package/dist/commands/optimize.js +0 -59
  279. package/dist/commands/optimize.js.map +0 -1
  280. package/dist/commands/optimize_command.d.ts +0 -6
  281. package/dist/commands/optimize_command.d.ts.map +0 -1
  282. package/dist/commands/optimize_command.js +0 -59
  283. package/dist/commands/optimize_command.js.map +0 -1
  284. package/dist/commands/references.d.ts +0 -5
  285. package/dist/commands/references.d.ts.map +0 -1
  286. package/dist/commands/references.js +0 -17
  287. package/dist/commands/references.js.map +0 -1
  288. package/dist/commands/web.d.ts +0 -19
  289. package/dist/commands/web.d.ts.map +0 -1
  290. package/dist/commands/web.js +0 -120
  291. package/dist/commands/web.js.map +0 -1
  292. package/dist/commands/who-calls.d.ts +0 -5
  293. package/dist/commands/who-calls.d.ts.map +0 -1
  294. package/dist/commands/who-calls.js +0 -7
  295. package/dist/commands/who-calls.js.map +0 -1
  296. package/dist/commands/who_calls.d.ts +0 -5
  297. package/dist/commands/who_calls.d.ts.map +0 -1
  298. package/dist/commands/who_calls.js +0 -7
  299. package/dist/commands/who_calls.js.map +0 -1
  300. package/dist/extract/graph-builder.d.ts +0 -16
  301. package/dist/extract/graph-builder.d.ts.map +0 -1
  302. package/dist/extract/graph-builder.js +0 -39
  303. package/dist/extract/graph-builder.js.map +0 -1
  304. package/dist/extract/node-id.d.ts +0 -8
  305. package/dist/extract/node-id.d.ts.map +0 -1
  306. package/dist/extract/node-id.js +0 -22
  307. package/dist/extract/node-id.js.map +0 -1
  308. package/dist/extract/project-loader.d.ts +0 -5
  309. package/dist/extract/project-loader.d.ts.map +0 -1
  310. package/dist/extract/project-loader.js +0 -19
  311. package/dist/extract/project-loader.js.map +0 -1
  312. package/dist/extract/semantic-extractor.d.ts +0 -22
  313. package/dist/extract/semantic-extractor.d.ts.map +0 -1
  314. package/dist/extract/semantic-extractor.js +0 -254
  315. package/dist/extract/semantic-extractor.js.map +0 -1
  316. package/dist/extract/structural-extractor.d.ts +0 -18
  317. package/dist/extract/structural-extractor.d.ts.map +0 -1
  318. package/dist/extract/structural-extractor.js +0 -97
  319. package/dist/extract/structural-extractor.js.map +0 -1
  320. package/dist/query/graph-query.d.ts +0 -28
  321. package/dist/query/graph-query.d.ts.map +0 -1
  322. package/dist/query/graph-query.js +0 -93
  323. package/dist/query/graph-query.js.map +0 -1
  324. package/dist/store/jsonl-reader.d.ts +0 -11
  325. package/dist/store/jsonl-reader.d.ts.map +0 -1
  326. package/dist/store/jsonl-reader.js +0 -19
  327. package/dist/store/jsonl-reader.js.map +0 -1
  328. package/dist/store/jsonl-store.d.ts +0 -7
  329. package/dist/store/jsonl-store.d.ts.map +0 -1
  330. package/dist/store/jsonl-store.js +0 -13
  331. package/dist/store/jsonl-store.js.map +0 -1
  332. package/dist/store/kuzu-store.d.ts +0 -14
  333. package/dist/store/kuzu-store.d.ts.map +0 -1
  334. package/dist/store/kuzu-store.js +0 -52
  335. package/dist/store/kuzu-store.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ *
2
+ !.gitignore
3
+ !kind_descriptions.js
@@ -0,0 +1,39 @@
1
+ // @ts-nocheck
2
+ // Generated from src/schema by scripts/build-data.ts. Do not edit by hand.
3
+ window.KIND_DESCRIPTIONS = {
4
+ "nodes": {
5
+ "Module": "A source file in the codebase.",
6
+ "Class": "A class declaration.",
7
+ "Interface": "An interface declaration.",
8
+ "TypeAlias": "A type alias declaration.",
9
+ "Enum": "An enum declaration.",
10
+ "Function": "A standalone, module-level function.",
11
+ "Method": "A function that belongs to a class or interface.",
12
+ "Property": "A field declared on a class or interface.",
13
+ "Parameter": "A parameter of a function or method.",
14
+ "Variable": "A module- or block-level variable binding.",
15
+ "ExternalModule": "An imported third-party or Node.js module, recorded as one opaque node per import specifier.",
16
+ "ConfigFlag": "An environment-variable configuration flag, detected from process.env reads.",
17
+ "ExternalAPI": "An outbound HTTP host called through fetch(), with one node per host.",
18
+ "Endpoint": "An HTTP route registered by the app, such as app.get(\"/users\", handler)."
19
+ },
20
+ "edges": {
21
+ "CONTAINS": "Structural nesting: the source declares or encloses the target (a module contains a class, which contains a method).",
22
+ "IMPORTS": "The source module imports the target.",
23
+ "EXPORTS": "The source module exports the target symbol.",
24
+ "EXTENDS": "The source class or interface extends the target (inheritance).",
25
+ "IMPLEMENTS": "The source class implements the target interface.",
26
+ "USES_TYPE": "The source references the target in a type position.",
27
+ "RETURNS": "The target type appears in the source function or method return type.",
28
+ "PARAM_TYPE": "The target type appears in one of the source parameter types.",
29
+ "CALLS": "The source function or method calls the target.",
30
+ "INSTANTIATES": "The source constructs the target class with new.",
31
+ "OVERRIDES": "The source method overrides the base-class member it replaces.",
32
+ "READS": "The source reads the value of the target variable or property.",
33
+ "WRITES": "The source assigns to the target variable or property.",
34
+ "READS_CONFIG": "The source reads the target configuration flag (an environment variable).",
35
+ "CALLS_EXTERNAL": "The source makes an outbound HTTP call to the target external API.",
36
+ "HANDLES": "Links an HTTP endpoint to the function that handles it (route to handler).",
37
+ "CALLS_RUNTIME": "A call observed at runtime in a CPU profile: the source function or method was on the stack directly above the target. Captures dynamic dispatch that static CALLS cannot see."
38
+ }
39
+ };
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Ambient declarations for the static web viewer (`web/js/app.js`).
3
+ *
4
+ * The page ships as plain, build-free JavaScript and is type-checked in place
5
+ * with `// @ts-check`. This file gives that JavaScript precise types for the
6
+ * data it loads (the knowledge-graph JSONL records, mirrored from
7
+ * `src/schema`), and a deliberately loose surface for the Cytoscape.js library,
8
+ * which is loaded as a global from a CDN and has no bundled types here.
9
+ */
10
+
11
+ /* ---------- knowledge-graph data (mirrors src/schema) ---------- */
12
+
13
+ /** Source range of a symbol; mirrors `RangeSchema` in `src/schema/node.ts`. */
14
+ interface RawRange {
15
+ startLine: number;
16
+ startColumn: number;
17
+ endLine: number;
18
+ endColumn: number;
19
+ }
20
+
21
+ /** Per-node runtime metrics attached by `enrich`, read from `metadata.runtime`. */
22
+ interface NodeRuntime {
23
+ selfMs?: number;
24
+ samples?: number;
25
+ source?: string;
26
+ }
27
+
28
+ /** A graph node as serialised in `nodes.jsonl`; mirrors `GraphNodeSchema`. */
29
+ interface RawNode {
30
+ id: string;
31
+ kind: string;
32
+ name: string;
33
+ filePath: string;
34
+ range?: RawRange;
35
+ exported?: boolean;
36
+ metadata?: { runtime?: NodeRuntime | null; community?: number | null; communityLabel?: string | null; [key: string]: unknown } | null;
37
+ }
38
+
39
+ /** A graph edge as serialised in `edges.jsonl`; mirrors `GraphEdgeSchema`. */
40
+ interface RawEdge {
41
+ id: string;
42
+ kind: string;
43
+ from: string;
44
+ to: string;
45
+ metadata?: { count?: number; [key: string]: unknown } | null;
46
+ }
47
+
48
+ /** The embedded `window.GRAPH_DATA` payload written by `scripts/build-data.ts`. */
49
+ interface GraphData {
50
+ nodes: RawNode[];
51
+ edges: RawEdge[];
52
+ }
53
+
54
+ /** The `window.KIND_DESCRIPTIONS` payload: one-line help per node/edge kind. */
55
+ interface KindDescriptions {
56
+ nodes: Record<string, string>;
57
+ edges: Record<string, string>;
58
+ }
59
+
60
+ /** GitHub permalink descriptor; mirrors `GitHubSource` in `src/commands/webview_command.ts`. */
61
+ interface GitHubSource {
62
+ baseUrl: string;
63
+ commit: string;
64
+ prefix: string;
65
+ }
66
+
67
+ /** The `window.GRAPH_SOURCE` payload injected by the `web` command. */
68
+ interface GraphSource {
69
+ github?: GitHubSource;
70
+ }
71
+
72
+ /** The single mutable view-model the viewer threads through its render functions. */
73
+ interface AppState {
74
+ nodes: RawNode[];
75
+ edges: RawEdge[];
76
+ cy: CyCore | undefined;
77
+ hiddenNodeKinds: Set<string>;
78
+ hiddenEdgeKinds: Set<string>;
79
+ hiddenCommunities: Set<number>;
80
+ hideIsolated: boolean;
81
+ onlyMeasured: boolean;
82
+ droppedFiles: { nodes: RawNode[] | undefined; edges: RawEdge[] | undefined };
83
+ encoding: 'structural' | 'runtime' | 'community';
84
+ runtime: { maxSelfMs: number; measuredCount: number; totalSelfMs: number };
85
+ communities: [number, number][];
86
+ communityLabels: Map<number, string>;
87
+ }
88
+
89
+ /* ---------- Cytoscape.js (loaded as a CDN global, untyped) ---------- */
90
+
91
+ /**
92
+ * A Cytoscape collection or single element. Only the surface the viewer uses is
93
+ * declared. `data()` is intentionally `any`: it is Cytoscape's dynamic per-element
94
+ * bag and the one place this otherwise-strict file crosses an untyped boundary.
95
+ */
96
+ interface CyCollection {
97
+ length: number;
98
+ data(name?: string): any;
99
+ id(): string;
100
+ degree(): number;
101
+ closedNeighborhood(): CyCollection;
102
+ connectedEdges(): CyCollection;
103
+ source(): CyCollection;
104
+ target(): CyCollection;
105
+ addClass(names: string): CyCollection;
106
+ removeClass(names: string): CyCollection;
107
+ toggleClass(names: string, flag?: boolean): CyCollection;
108
+ hasClass(name: string): boolean;
109
+ not(selector: string): CyCollection;
110
+ forEach(each: (element: CyCollection, index: number) => void): void;
111
+ some(test: (element: CyCollection, index: number) => boolean): boolean;
112
+ layout(options: unknown): { run(): CyCollection };
113
+ }
114
+
115
+ /** A Cytoscape event; `target` is the element or core the event fired on. */
116
+ interface CyEvent {
117
+ target: any;
118
+ }
119
+
120
+ /** The Cytoscape core instance returned by the `cytoscape(...)` factory. */
121
+ interface CyCore {
122
+ destroy(): void;
123
+ on(events: string, handler: (event: CyEvent) => void): CyCore;
124
+ on(events: string, selector: string, handler: (event: CyEvent) => void): CyCore;
125
+ style(style?: unknown): CyCore;
126
+ elements(selector?: string): CyCollection;
127
+ nodes(selector?: string): CyCollection;
128
+ edges(selector?: string): CyCollection;
129
+ batch(callback: () => void): void;
130
+ getElementById(id: string): CyCollection;
131
+ animate(options: unknown, params?: unknown): CyCore;
132
+ }
133
+
134
+ interface CytoscapeOptions {
135
+ container?: HTMLElement | null;
136
+ elements?: unknown;
137
+ style?: unknown;
138
+ layout?: unknown;
139
+ }
140
+
141
+ declare function cytoscape(options?: CytoscapeOptions): CyCore;
142
+ declare namespace cytoscape {
143
+ /** Registers a Cytoscape extension (such as the fcose layout) loaded as a CDN global. */
144
+ function use(extension: unknown): void;
145
+ }
146
+
147
+ /* ---------- globals injected into the page ---------- */
148
+
149
+ interface Window {
150
+ GRAPH_DATA?: GraphData;
151
+ KIND_DESCRIPTIONS?: KindDescriptions;
152
+ GRAPH_SOURCE?: GraphSource | null;
153
+ cytoscapeFcose?: unknown;
154
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Pure statistics for the benchmark gate. Runtime measurement is noisy, so a
3
+ * single number lies: every benchmark reports the **median** of N runs plus the
4
+ * **spread**, and a baseline→after comparison is an advisory delta, never a
5
+ * deterministic guarantee. These helpers are deliberately side-effect-free so
6
+ * the variance handling is unit-tested directly, apart from any profiling.
7
+ */
8
+ /** A node's metric distribution over N runs: the headline median plus the spread that qualifies it. */
9
+ export type BenchmarkStatsSummary = {
10
+ runs: number;
11
+ median: number;
12
+ min: number;
13
+ max: number;
14
+ mean: number;
15
+ /** `max - min`: the observed spread, a coarse read on how noisy the measurement was. */
16
+ spread: number;
17
+ /** The raw per-run samples, in run order. */
18
+ values: number[];
19
+ };
20
+ /** A baseline→after comparison of two medians. Negative `absolute`/`percent` means the metric went down (faster / fewer). */
21
+ export type BenchmarkDelta = {
22
+ baselineMedian: number;
23
+ currentMedian: number;
24
+ /** `currentMedian - baselineMedian`. */
25
+ absolute: number;
26
+ /** `absolute / baselineMedian`, e.g. `-0.38` for a 38% reduction. `NaN` when the baseline median is 0. */
27
+ percent: number;
28
+ };
29
+ export declare class BenchmarkStats {
30
+ /** The median of a non-empty sample set (mean of the two middle values when the count is even). */
31
+ static median(values: number[]): number;
32
+ /** Reduce per-run samples to the median + spread summary. Throws on an empty set. */
33
+ static summarize(values: number[]): BenchmarkStatsSummary;
34
+ /** Compare a prior baseline median against the current median. `percent` is `NaN` when the baseline is 0. */
35
+ static delta(baselineMedian: number, currentMedian: number): BenchmarkDelta;
36
+ /** Format a fractional change as a signed percentage, e.g. `-0.38` → `"-38.0%"`; `NaN` → `"n/a"`. */
37
+ static formatPercent(percent: number): string;
38
+ /** A one-word read on a delta for a lower-is-better metric (time / samples), within a noise tolerance. */
39
+ static direction(delta: BenchmarkDelta, spread: number): 'improved' | 'regressed' | 'unchanged';
40
+ }
41
+ //# sourceMappingURL=benchmark_stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark_stats.d.ts","sourceRoot":"","sources":["../../src/benchmark/benchmark_stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uGAAuG;AACvG,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,6HAA6H;AAC7H,MAAM,MAAM,cAAc,GAAG;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,0GAA0G;IAC1G,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,cAAc;IAC1B,mGAAmG;IACnG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAYvC,qFAAqF;IACrF,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,qBAAqB;IAkBzD,6GAA6G;IAC7G,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,cAAc;IAM3E,qGAAqG;IACrG,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAQ7C,0GAA0G;IAC1G,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW;CAM/F"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Pure statistics for the benchmark gate. Runtime measurement is noisy, so a
3
+ * single number lies: every benchmark reports the **median** of N runs plus the
4
+ * **spread**, and a baseline→after comparison is an advisory delta, never a
5
+ * deterministic guarantee. These helpers are deliberately side-effect-free so
6
+ * the variance handling is unit-tested directly, apart from any profiling.
7
+ */
8
+ export class BenchmarkStats {
9
+ /** The median of a non-empty sample set (mean of the two middle values when the count is even). */
10
+ static median(values) {
11
+ if (values.length === 0) {
12
+ throw new Error('median of an empty sample set');
13
+ }
14
+ const sorted = [...values].sort((a, b) => a - b);
15
+ const mid = Math.floor(sorted.length / 2);
16
+ if (sorted.length % 2 === 1) {
17
+ return sorted[mid];
18
+ }
19
+ return (sorted[mid - 1] + sorted[mid]) / 2;
20
+ }
21
+ /** Reduce per-run samples to the median + spread summary. Throws on an empty set. */
22
+ static summarize(values) {
23
+ if (values.length === 0) {
24
+ throw new Error('cannot summarize a benchmark with no runs');
25
+ }
26
+ const min = Math.min(...values);
27
+ const max = Math.max(...values);
28
+ const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
29
+ return {
30
+ runs: values.length,
31
+ median: BenchmarkStats.median(values),
32
+ min,
33
+ max,
34
+ mean,
35
+ spread: max - min,
36
+ values: [...values],
37
+ };
38
+ }
39
+ /** Compare a prior baseline median against the current median. `percent` is `NaN` when the baseline is 0. */
40
+ static delta(baselineMedian, currentMedian) {
41
+ const absolute = currentMedian - baselineMedian;
42
+ const percent = baselineMedian === 0 ? Number.NaN : absolute / baselineMedian;
43
+ return { baselineMedian, currentMedian, absolute, percent };
44
+ }
45
+ /** Format a fractional change as a signed percentage, e.g. `-0.38` → `"-38.0%"`; `NaN` → `"n/a"`. */
46
+ static formatPercent(percent) {
47
+ if (Number.isNaN(percent) === true) {
48
+ return 'n/a';
49
+ }
50
+ const sign = percent > 0 ? '+' : '';
51
+ return `${sign}${(percent * 100).toFixed(1)}%`;
52
+ }
53
+ /** A one-word read on a delta for a lower-is-better metric (time / samples), within a noise tolerance. */
54
+ static direction(delta, spread) {
55
+ if (Math.abs(delta.absolute) <= spread) {
56
+ return 'unchanged';
57
+ }
58
+ return delta.absolute < 0 ? 'improved' : 'regressed';
59
+ }
60
+ }
61
+ //# sourceMappingURL=benchmark_stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark_stats.js","sourceRoot":"","sources":["../../src/benchmark/benchmark_stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,MAAM,OAAO,cAAc;IAC1B,mGAAmG;IACnG,MAAM,CAAC,MAAM,CAAC,MAAgB;QAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IA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AC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACpC,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAChD,CAAC;IAED,0GAA0G;IAC1G,MAAM,CAAC,SAAS,CAAC,KAAqB,EAAE,MAAc;QACrD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,MAAM,EAAE,CAAC;YACxC,OAAO,WAAW,CAAC;QACpB,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;IACtD,CAAC;CACD"}
@@ -0,0 +1,78 @@
1
+ import { GraphQuery } from '../query/graph_query.js';
2
+ import { KuzuStore } from '../store/kuzu_store.js';
3
+ import { BenchmarkDelta, BenchmarkStatsSummary } from './benchmark_stats.js';
4
+ /**
5
+ * The benchmark gate: measure one target node's runtime metric over a repeatable
6
+ * workload, **before and after** an edit, and report the delta. It reuses the
7
+ * existing machinery end to end — a V8 CPU profile feeds {@link RuntimeEnricher}
8
+ * (the same `enrich` path) and the metric is read back through
9
+ * {@link GraphQuery.costAttribution} (the `cost` query).
10
+ *
11
+ * Honesty about noise is baked in: a benchmark runs the workload N times and
12
+ * reports the **median + spread**, and a baseline comparison is labelled
13
+ * **advisory** — distinct from the hard pass/fail of the `verify` gate. The
14
+ * profiling step is injected ({@link ProfileRun}) so the read + statistics logic
15
+ * is unit-tested without actually profiling.
16
+ */
17
+ /** Which runtime metric to track. `self-time` is the node's own exclusive time; `inclusive-time` adds its callees. */
18
+ export type BenchmarkMetric = 'self-time' | 'inclusive-time' | 'samples';
19
+ export type BenchmarkTarget = {
20
+ id: string;
21
+ name: string;
22
+ kind: string;
23
+ filePath: string;
24
+ startLine: number;
25
+ };
26
+ export type BenchmarkReport = {
27
+ target: BenchmarkTarget;
28
+ metric: BenchmarkMetric;
29
+ unit: 'ms' | 'samples';
30
+ stats: BenchmarkStatsSummary;
31
+ /** Present only when a prior baseline median was supplied; always advisory. */
32
+ delta: BenchmarkDelta | null;
33
+ /** A human note stating the result is advisory and noisy, not a guarantee. */
34
+ advisory: string;
35
+ };
36
+ export type NodeBenchmarkOptions = {
37
+ /** Symbol name (or substring / kind) resolved against the current graph to pick the target node. */
38
+ target: string;
39
+ /** Default `self-time`. */
40
+ metric?: BenchmarkMetric;
41
+ /** Number of profiling runs. Default 5, clamped to [1, 50]. */
42
+ runs?: number;
43
+ /** A prior baseline median to compare the current median against (advisory delta). */
44
+ baselineMedian?: number;
45
+ };
46
+ /** Everything one real profiling run needs: the workload entry, the project root, and a scratch dir for `.cpuprofile`s. */
47
+ export type ProfileConfig = {
48
+ /** Path to a repeatable workload entry (a `.ts`/`.js` file) that exercises the target under load. */
49
+ workload: string;
50
+ /** Project root the profile's absolute frame paths resolve against (passed to `enrich`). */
51
+ root: string;
52
+ /** Scratch directory for the per-run `.cpuprofile`. */
53
+ profileDir: string;
54
+ };
55
+ /** One profiling run: leave a fresh `metadata.runtime` on the graph in the store. Injectable so tests skip profiling. */
56
+ export type ProfileRun = (run: number) => Promise<void>;
57
+ export declare class NodeBenchmark {
58
+ /**
59
+ * Profile the workload `runs` times, reading the target's metric after each,
60
+ * and return the median + spread (plus an advisory delta when a baseline is
61
+ * given). `profileRun` defaults to a real V8 profile + enrich; tests inject a
62
+ * fake that writes a known metric so this method's read/stats logic is covered
63
+ * without profiling.
64
+ */
65
+ static measure(store: KuzuStore, options: NodeBenchmarkOptions, profileRun: ProfileRun): Promise<BenchmarkReport>;
66
+ /** Resolve a target name to exactly one node in the current graph, or throw with guidance. */
67
+ static resolveTarget(query: GraphQuery, target: string): Promise<BenchmarkTarget>;
68
+ /** Read the target's current metric via the cost model (the `cost` query). */
69
+ static readMetric(query: GraphQuery, id: string, metric: BenchmarkMetric): Promise<number>;
70
+ /** A real profiling run: V8-profile the workload, then enrich the graph with the measured self time. */
71
+ static profileAndEnrich(store: KuzuStore, config: ProfileConfig): Promise<void>;
72
+ private static clampRuns;
73
+ private static buildAdvisory;
74
+ private static round;
75
+ private static runWorkload;
76
+ private static newestProfile;
77
+ }
78
+ //# sourceMappingURL=node_benchmark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node_benchmark.d.ts","sourceRoot":"","sources":["../../src/benchmark/node_benchmark.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAkB,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7F;;;;;;;;;;;;GAYG;AAEH,sHAAsH;AACtH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAEzE,MAAM,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,+EAA+E;IAC/E,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,oGAAoG;IACpG,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,2HAA2H;AAC3H,MAAM,MAAM,aAAa,GAAG;IAC3B,qGAAqG;IACrG,QAAQ,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,yHAAyH;AACzH,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAMxD,qBAAa,aAAa;IACzB;;;;;;OAMG;WACU,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;IAoBvH,8FAA8F;WACjF,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAcvF,8EAA8E;WACjE,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAShG,wGAAwG;WAC3F,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrF,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB,OAAO,CAAC,MAAM,CAAC,aAAa;IAS5B,OAAO,CAAC,MAAM,CAAC,KAAK;IAIpB,OAAO,CAAC,MAAM,CAAC,WAAW;mBAmBL,aAAa;CAclC"}
@@ -0,0 +1,112 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { mkdir, readdir, readFile, rm, stat } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { RuntimeEnricher } from '../enrich/runtime_enricher.js';
5
+ import { GraphQuery } from '../query/graph_query.js';
6
+ import { BenchmarkStats } from './benchmark_stats.js';
7
+ const DEFAULT_RUNS = 5;
8
+ const MIN_RUNS = 1;
9
+ const MAX_RUNS = 50;
10
+ export class NodeBenchmark {
11
+ /**
12
+ * Profile the workload `runs` times, reading the target's metric after each,
13
+ * and return the median + spread (plus an advisory delta when a baseline is
14
+ * given). `profileRun` defaults to a real V8 profile + enrich; tests inject a
15
+ * fake that writes a known metric so this method's read/stats logic is covered
16
+ * without profiling.
17
+ */
18
+ static async measure(store, options, profileRun) {
19
+ const query = new GraphQuery(store);
20
+ const target = await NodeBenchmark.resolveTarget(query, options.target);
21
+ const metric = options.metric ?? 'self-time';
22
+ const runs = NodeBenchmark.clampRuns(options.runs ?? DEFAULT_RUNS);
23
+ const values = [];
24
+ for (let run = 0; run < runs; run += 1) {
25
+ await profileRun(run);
26
+ values.push(await NodeBenchmark.readMetric(query, target.id, metric));
27
+ }
28
+ const stats = BenchmarkStats.summarize(values);
29
+ const delta = options.baselineMedian === undefined
30
+ ? null
31
+ : BenchmarkStats.delta(options.baselineMedian, stats.median);
32
+ const unit = metric === 'samples' ? 'samples' : 'ms';
33
+ return { target, metric, unit, stats, delta, advisory: NodeBenchmark.buildAdvisory(stats, unit) };
34
+ }
35
+ /** Resolve a target name to exactly one node in the current graph, or throw with guidance. */
36
+ static async resolveTarget(query, target) {
37
+ const matches = await query.find(target);
38
+ if (matches.length === 0) {
39
+ throw new Error(`no node matches "${target}" — resolve a symbol name with \`find\` first`);
40
+ }
41
+ const exact = matches.filter((match) => match.name === target);
42
+ const chosen = exact.length === 1 ? exact[0] : matches.length === 1 ? matches[0] : null;
43
+ if (chosen === null) {
44
+ const candidates = (exact.length > 0 ? exact : matches).slice(0, 8).map((match) => match.id).join(', ');
45
+ throw new Error(`"${target}" is ambiguous — narrow it to one of: ${candidates}`);
46
+ }
47
+ return { id: chosen.id, name: chosen.name, kind: chosen.kind, filePath: chosen.filePath, startLine: chosen.startLine };
48
+ }
49
+ /** Read the target's current metric via the cost model (the `cost` query). */
50
+ static async readMetric(query, id, metric) {
51
+ const by = metric === 'samples' ? 'samples' : 'self-time';
52
+ const attribution = await query.costAttribution(id, { by });
53
+ if (attribution.node === null) {
54
+ throw new Error(`target node ${id} is no longer in the graph — rebuild after the edit`);
55
+ }
56
+ return metric === 'inclusive-time' ? attribution.node.inclusiveCost : attribution.node.selfCost;
57
+ }
58
+ /** A real profiling run: V8-profile the workload, then enrich the graph with the measured self time. */
59
+ static async profileAndEnrich(store, config) {
60
+ await rm(config.profileDir, { recursive: true, force: true });
61
+ await mkdir(config.profileDir, { recursive: true });
62
+ const profilePath = await NodeBenchmark.runWorkload(config);
63
+ const profileText = await readFile(profilePath, 'utf8');
64
+ await RuntimeEnricher.enrich(store, profileText, { root: config.root });
65
+ }
66
+ static clampRuns(runs) {
67
+ if (Number.isFinite(runs) === false) {
68
+ return DEFAULT_RUNS;
69
+ }
70
+ return Math.min(MAX_RUNS, Math.max(MIN_RUNS, Math.floor(runs)));
71
+ }
72
+ static buildAdvisory(stats, unit) {
73
+ const spread = `${NodeBenchmark.round(stats.spread)} ${unit}`;
74
+ return (`Advisory — runtime measurement is noisy. This is the median of ${stats.runs} run(s) ` +
75
+ `(spread ${spread}), not a deterministic guarantee. Unlike the verify gate (hard pass/fail), ` +
76
+ `a benchmark delta is indicative, not proof.`);
77
+ }
78
+ static round(value) {
79
+ return Math.round(value * 1000) / 1000;
80
+ }
81
+ static runWorkload(config) {
82
+ return new Promise((resolvePromise, reject) => {
83
+ const args = ['--cpu-prof', '--cpu-prof-dir', config.profileDir, '--import', 'tsx', config.workload];
84
+ const child = spawn('node', args, { cwd: config.root, stdio: ['ignore', 'ignore', 'pipe'] });
85
+ let stderr = '';
86
+ child.stderr.on('data', (chunk) => {
87
+ stderr += chunk.toString();
88
+ });
89
+ child.on('error', reject);
90
+ child.on('close', (code) => {
91
+ if (code !== 0) {
92
+ reject(new Error(`workload "${config.workload}" exited with code ${code}\n${stderr.trim()}`));
93
+ return;
94
+ }
95
+ NodeBenchmark.newestProfile(config.profileDir).then(resolvePromise, reject);
96
+ });
97
+ });
98
+ }
99
+ static async newestProfile(profileDir) {
100
+ const entries = (await readdir(profileDir)).filter((name) => name.endsWith('.cpuprofile'));
101
+ if (entries.length === 0) {
102
+ throw new Error(`no .cpuprofile written to ${profileDir} — did the workload run under --cpu-prof?`);
103
+ }
104
+ const withMtime = await Promise.all(entries.map(async (name) => {
105
+ const path = join(profileDir, name);
106
+ return { path, mtimeMs: (await stat(path)).mtimeMs };
107
+ }));
108
+ withMtime.sort((a, b) => b.mtimeMs - a.mtimeMs);
109
+ return withMtime[0].path;
110
+ }
111
+ }
112
+ //# sourceMappingURL=node_benchmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node_benchmark.js","sourceRoot":"","sources":["../../src/benchmark/node_benchmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAc,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAkB,cAAc,EAAyB,MAAM,sBAAsB,CAAC;AA8D7F,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB,MAAM,OAAO,aAAa;IACzB;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAgB,EAAE,OAA6B,EAAE,UAAsB;QAC3F,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACx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1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAqBA,qBAAa,GAAG;IACf,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;CA2BhC"}
package/dist/cli.js CHANGED
@@ -1,16 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
+ import { BenchmarkCommand } from './commands/benchmark_command.js';
3
4
  import { BlastRadiusCommand } from './commands/blast_radius_command.js';
4
5
  import { CallsCommand } from './commands/calls_command.js';
6
+ import { ClusterCommand } from './commands/cluster_command.js';
7
+ import { CostCommand } from './commands/cost_command.js';
5
8
  import { DeadExportsCommand } from './commands/dead_exports_command.js';
9
+ import { EnrichCommand } from './commands/enrich_command.js';
6
10
  import { ExtractCommand } from './commands/extract_command.js';
7
11
  import { FindCommand } from './commands/find_command.js';
12
+ import { HotspotsCommand } from './commands/hotspots_command.js';
8
13
  import { InstallCommand } from './commands/install_command.js';
9
14
  import { LoadCommand } from './commands/load_command.js';
10
15
  import { NeighborsCommand } from './commands/neighbors_command.js';
11
- import { OptimizeCommand } from './commands/optimize_command.js';
12
16
  import { ReferencesCommand } from './commands/references_command.js';
13
- import { WebCommand } from './commands/web_command.js';
17
+ import { ReportCommand } from './commands/report_command.js';
18
+ import { VerifyCommand } from './commands/verify_command.js';
19
+ import { WebviewCommand } from './commands/webview_command.js';
14
20
  import { WhoCallsCommand } from './commands/who_calls_command.js';
15
21
  export class Cli {
16
22
  static run(argv) {
@@ -20,15 +26,21 @@ export class Cli {
20
26
  .description('Parse a TypeScript project into a knowledge graph and query it');
21
27
  ExtractCommand.register(program);
22
28
  LoadCommand.register(program);
29
+ EnrichCommand.register(program);
30
+ ClusterCommand.register(program);
23
31
  FindCommand.register(program);
24
32
  WhoCallsCommand.register(program);
25
33
  CallsCommand.register(program);
26
34
  DeadExportsCommand.register(program);
35
+ HotspotsCommand.register(program);
36
+ CostCommand.register(program);
37
+ VerifyCommand.register(program);
38
+ BenchmarkCommand.register(program);
27
39
  BlastRadiusCommand.register(program);
28
40
  NeighborsCommand.register(program);
29
41
  ReferencesCommand.register(program);
30
- OptimizeCommand.register(program);
31
- WebCommand.register(program);
42
+ ReportCommand.register(program);
43
+ WebviewCommand.register(program);
32
44
  InstallCommand.register(program);
33
45
  void program.parseAsync(argv);
34
46
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,OAAO,GAAG;IACf,MAAM,CAAC,GAAG,CAAC,IAAc;QACxB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,OAAO;aACL,IAAI,CAAC,oBAAoB,CAAC;aAC1B,WAAW,CAAC,gEAAgE,CAAC,CAAC;QAEhF,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC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,OAAO,CAAC,CAAC;QAChC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAChC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEjC,KAAK,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACD;AAED,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { EdgeKind } from '../schema/edge.js';
2
+ /**
3
+ * How strongly each edge kind pulls its two endpoints into the same community.
4
+ * The effective weight of an edge is this coefficient times the edge's
5
+ * `metadata.count` (how many times the relationship occurs in source). The
6
+ * exception is `CALLS_RUNTIME` — the runtime call graph from `enrich` — weighted
7
+ * by its normalized sample count instead, and given a slightly higher coefficient
8
+ * because an executed call is stronger evidence of coupling than a merely
9
+ * statically-possible one. It contributes only on an enriched graph; otherwise no
10
+ * such edges exist and it is a no-op.
11
+ *
12
+ * `IMPORTS` and `EXPORTS` are deliberately absent: they are module wiring, not
13
+ * coupling, the same reasoning {@link REFERENCE_EDGE_KINDS} uses. `CONTAINS`
14
+ * carries a low weight so same-file symbols lean together without overwhelming
15
+ * call structure; drop it for modules that may cross files freely. System-level
16
+ * kinds (`READS_CONFIG`, `CALLS_EXTERNAL`, `HANDLES`) are absent because their
17
+ * targets are synthesized nodes, not code symbols.
18
+ */
19
+ export declare const CLUSTER_EDGE_WEIGHTS: Partial<Record<EdgeKind, number>>;
20
+ //# sourceMappingURL=cluster_weights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster_weights.d.ts","sourceRoot":"","sources":["../../src/cluster/cluster_weights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAalE,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * How strongly each edge kind pulls its two endpoints into the same community.
3
+ * The effective weight of an edge is this coefficient times the edge's
4
+ * `metadata.count` (how many times the relationship occurs in source). The
5
+ * exception is `CALLS_RUNTIME` — the runtime call graph from `enrich` — weighted
6
+ * by its normalized sample count instead, and given a slightly higher coefficient
7
+ * because an executed call is stronger evidence of coupling than a merely
8
+ * statically-possible one. It contributes only on an enriched graph; otherwise no
9
+ * such edges exist and it is a no-op.
10
+ *
11
+ * `IMPORTS` and `EXPORTS` are deliberately absent: they are module wiring, not
12
+ * coupling, the same reasoning {@link REFERENCE_EDGE_KINDS} uses. `CONTAINS`
13
+ * carries a low weight so same-file symbols lean together without overwhelming
14
+ * call structure; drop it for modules that may cross files freely. System-level
15
+ * kinds (`READS_CONFIG`, `CALLS_EXTERNAL`, `HANDLES`) are absent because their
16
+ * targets are synthesized nodes, not code symbols.
17
+ */
18
+ export const CLUSTER_EDGE_WEIGHTS = {
19
+ CALLS: 3,
20
+ CALLS_RUNTIME: 4,
21
+ INSTANTIATES: 2,
22
+ EXTENDS: 2,
23
+ IMPLEMENTS: 2,
24
+ OVERRIDES: 1.5,
25
+ WRITES: 1.5,
26
+ READS: 1,
27
+ USES_TYPE: 1,
28
+ RETURNS: 1,
29
+ PARAM_TYPE: 1,
30
+ CONTAINS: 0.5,
31
+ };
32
+ //# sourceMappingURL=cluster_weights.js.map