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
package/.env-sample DELETED
@@ -1,34 +0,0 @@
1
- # Copy to .env and pick ONE provider block below.
2
- # The agent uses the OpenAI-compatible chat-completions API, so any provider
3
- # exposing that surface works — only the three variables below change.
4
- #
5
- # OPENAI_API_KEY auth token for the provider (any non-empty string for local servers)
6
- # OPENAI_BASE_URL the provider's OpenAI-compatible endpoint (omit for openai.com)
7
- # OPENAI_MODEL model name, in the provider's naming scheme
8
-
9
- # --- OpenAI (default) -------------------------------------------------------
10
- OPENAI_API_KEY=sk-...
11
- # OPENAI_BASE_URL is not needed — defaults to https://api.openai.com/v1
12
- OPENAI_MODEL=gpt-5.1
13
-
14
- # --- OpenRouter (any model behind one key) ----------------------------------
15
- # OPENAI_API_KEY=sk-or-v1-...
16
- # OPENAI_BASE_URL=https://openrouter.ai/api/v1
17
- # OPENAI_MODEL=anthropic/claude-sonnet-4.5
18
- # OPENAI_MODEL=openai/gpt-5.1
19
- # OPENAI_MODEL=deepseek/deepseek-chat-v3.1
20
-
21
- # --- Ollama (local, free) ---------------------------------------------------
22
- # OPENAI_API_KEY=ollama
23
- # OPENAI_BASE_URL=http://localhost:11434/v1
24
- # OPENAI_MODEL=qwen2.5-coder:32b
25
-
26
- # --- LM Studio (local) ------------------------------------------------------
27
- # OPENAI_API_KEY=lm-studio
28
- # OPENAI_BASE_URL=http://localhost:1234/v1
29
- # OPENAI_MODEL=local-model
30
-
31
- # --- vLLM (self-hosted) -----------------------------------------------------
32
- # OPENAI_API_KEY=token-abc123
33
- # OPENAI_BASE_URL=http://localhost:8000/v1
34
- # OPENAI_MODEL=Qwen/Qwen2.5-Coder-32B-Instruct
@@ -1,55 +0,0 @@
1
- # Web visualisation
2
-
3
- Interactive viewer for the knowledge graph — pan/zoom, color-coded node and
4
- edge kinds with toggleable filters, symbol search, and a per-node detail panel
5
- showing every incoming/outgoing edge.
6
-
7
- **No server required.** The page (in [web/](web)) is fully static; only the
8
- Cytoscape.js library comes from a CDN (so you need internet, or vendor the
9
- file).
10
-
11
- ## Commands
12
-
13
- ```bash
14
- npm run build # embed ../../outputs/graph/*.jsonl into web/data/graph_data.js
15
- npm start # serve web/ on http://localhost:4173 (optional)
16
- npm run open # open web/index.html directly (file://, macOS)
17
- ```
18
-
19
- ## Loading data — pick one
20
-
21
- **A. Embed the data, then open the page** (works from `file://`, no server):
22
-
23
- ```bash
24
- # from the repo root, after `npm run extract -- . --semantic`
25
- cd contribs/web_visualisation
26
- npm run build
27
- npm run open
28
- ```
29
-
30
- `scripts/build-data.ts` reads `../../outputs/graph/{nodes,edges}.jsonl` by
31
- default; pass a different graph directory as the first argument
32
- (`npx tsx scripts/build-data.ts /path/to/graph`).
33
-
34
- **B. Drag & drop** — open `web/index.html` any way at all and drop
35
- `outputs/graph/nodes.jsonl` + `outputs/graph/edges.jsonl` onto the page.
36
-
37
- **C. Serve the repo root** — the page then auto-fetches
38
- `../../../outputs/graph/*.jsonl`:
39
-
40
- ```bash
41
- # from the repo root
42
- npx serve # or: python3 -m http.server
43
- # open http://localhost:3000/contribs/web_visualisation/web/
44
- ```
45
-
46
- ## Reading the graph
47
-
48
- - **Node size** scales with degree (how connected a symbol is).
49
- - **Edge colors**: red `CALLS`, green/teal type edges (`USES_TYPE`, `RETURNS`,
50
- `PARAM_TYPE`), yellow `READS`, violet heritage, gray structure
51
- (`CONTAINS`, `IMPORTS`).
52
- - Uncheck noisy kinds (`CONTAINS`, `IMPORTS`) to see the behavioral core;
53
- enable **hide isolated nodes** to drop whatever the filter disconnected.
54
- - Click a node to fade everything outside its neighborhood and list its edges
55
- in the sidebar — the links navigate the graph.
@@ -1,115 +0,0 @@
1
- * { box-sizing: border-box; }
2
-
3
- html, body {
4
- margin: 0;
5
- height: 100%;
6
- font: 13px/1.45 -apple-system, 'Segoe UI', Roboto, sans-serif;
7
- background: #0f172a;
8
- color: #cbd5e1;
9
- }
10
-
11
- body { display: flex; }
12
-
13
- #sidebar {
14
- width: 300px;
15
- flex: none;
16
- height: 100%;
17
- overflow-y: auto;
18
- padding: 14px;
19
- background: #111c33;
20
- border-right: 1px solid #1e293b;
21
- }
22
-
23
- #sidebar h1 { font-size: 15px; margin: 0 0 4px; color: #f1f5f9; }
24
- #sidebar h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin: 16px 0 6px; }
25
- #sidebar section { margin-top: 8px; }
26
-
27
- #status { font-size: 11px; color: #64748b; margin-bottom: 10px; }
28
-
29
- #search {
30
- width: 100%;
31
- padding: 6px 8px;
32
- border: 1px solid #334155;
33
- border-radius: 6px;
34
- background: #0f172a;
35
- color: #e2e8f0;
36
- }
37
- #search:focus { outline: none; border-color: #4f8cff; }
38
-
39
- #search-results { margin-top: 4px; }
40
- #search-results .hit {
41
- padding: 3px 6px;
42
- border-radius: 4px;
43
- cursor: pointer;
44
- font-size: 12px;
45
- white-space: nowrap;
46
- overflow: hidden;
47
- text-overflow: ellipsis;
48
- }
49
- #search-results .hit:hover { background: #1e293b; }
50
- #search-results .hit .loc { color: #64748b; font-size: 10px; }
51
-
52
- .legend label {
53
- display: flex;
54
- align-items: center;
55
- gap: 6px;
56
- padding: 1px 0;
57
- cursor: pointer;
58
- user-select: none;
59
- }
60
- .legend .swatch {
61
- width: 10px;
62
- height: 10px;
63
- border-radius: 3px;
64
- flex: none;
65
- }
66
- .legend .count { margin-left: auto; color: #64748b; font-size: 11px; }
67
-
68
- .row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
69
-
70
- select, button {
71
- background: #1e293b;
72
- color: #e2e8f0;
73
- border: 1px solid #334155;
74
- border-radius: 6px;
75
- padding: 4px 8px;
76
- font: inherit;
77
- cursor: pointer;
78
- }
79
- button:hover { background: #334155; }
80
- select { flex: 1; }
81
-
82
- #details-body { font-size: 12px; }
83
- #details-body .id { color: #64748b; font-size: 10px; word-break: break-all; }
84
- #details-body .kind-tag {
85
- display: inline-block;
86
- padding: 1px 6px;
87
- border-radius: 4px;
88
- font-size: 10px;
89
- color: #0f172a;
90
- font-weight: 600;
91
- }
92
- #details-body h3 { font-size: 11px; color: #64748b; margin: 10px 0 3px; }
93
- #details-body .edge-row { padding: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
94
- #details-body .edge-kind { color: #64748b; font-size: 10px; }
95
- #details-body a { color: #7db2ff; cursor: pointer; text-decoration: none; }
96
- #details-body a:hover { text-decoration: underline; }
97
-
98
- #cy { flex: 1; height: 100%; }
99
-
100
- #dropzone {
101
- position: fixed;
102
- inset: 0;
103
- display: flex;
104
- align-items: center;
105
- justify-content: center;
106
- font-size: 18px;
107
- color: #e2e8f0;
108
- background: rgba(15, 23, 42, .85);
109
- border: 3px dashed #4f8cff;
110
- pointer-events: none;
111
- opacity: 0;
112
- transition: opacity .15s;
113
- }
114
- #dropzone.active { opacity: 1; }
115
- #dropzone code { color: #7db2ff; }
@@ -1,2 +0,0 @@
1
- *
2
- !.gitignore
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>open_ts_optim_ai — knowledge graph</title>
7
- <link rel="stylesheet" href="./css/style.css">
8
- </head>
9
- <body>
10
- <aside id="sidebar">
11
- <h1>Knowledge graph</h1>
12
- <div id="status">no data loaded</div>
13
-
14
- <input id="search" type="search" placeholder="Search symbol or file… (Enter)" autocomplete="off">
15
- <div id="search-results"></div>
16
-
17
- <section>
18
- <h2>Node kinds</h2>
19
- <div id="node-kinds" class="legend"></div>
20
- </section>
21
-
22
- <section>
23
- <h2>Edge kinds</h2>
24
- <div id="edge-kinds" class="legend"></div>
25
- </section>
26
-
27
- <section>
28
- <h2>Options</h2>
29
- <label class="row"><input id="hide-isolated" type="checkbox"> hide isolated nodes</label>
30
- <div class="row">
31
- <select id="layout-select">
32
- <option value="cose">cose (force)</option>
33
- <option value="concentric">concentric (by degree)</option>
34
- <option value="breadthfirst">breadthfirst</option>
35
- <option value="circle">circle</option>
36
- <option value="grid">grid</option>
37
- </select>
38
- <button id="relayout">layout</button>
39
- </div>
40
- </section>
41
-
42
- <section id="details" class="empty">
43
- <h2>Selection</h2>
44
- <div id="details-body">click a node</div>
45
- </section>
46
- </aside>
47
-
48
- <main id="cy"></main>
49
-
50
- <div id="dropzone" class="hidden-overlay">
51
- <div>drop <code>nodes.jsonl</code> + <code>edges.jsonl</code> here</div>
52
- </div>
53
-
54
- <script src="./data/graph_data.js"></script>
55
- <script src="https://unpkg.com/cytoscape@3/dist/cytoscape.min.js"></script>
56
- <script src="./js/app.js"></script>
57
- </body>
58
- </html>
@@ -1,364 +0,0 @@
1
- 'use strict';
2
-
3
- const NODE_COLORS = {
4
- Module: '#4f8cff',
5
- Class: '#f59e0b',
6
- Interface: '#a78bfa',
7
- TypeAlias: '#34d399',
8
- Enum: '#f472b6',
9
- Function: '#fb923c',
10
- Method: '#facc15',
11
- Property: '#94a3b8',
12
- Parameter: '#64748b',
13
- Variable: '#2dd4bf',
14
- ExternalModule: '#6b7280',
15
- };
16
-
17
- const EDGE_COLORS = {
18
- CONTAINS: '#475569',
19
- IMPORTS: '#64748b',
20
- EXPORTS: '#64748b',
21
- CALLS: '#ef4444',
22
- INSTANTIATES: '#f97316',
23
- EXTENDS: '#8b5cf6',
24
- IMPLEMENTS: '#a78bfa',
25
- USES_TYPE: '#10b981',
26
- RETURNS: '#14b8a6',
27
- PARAM_TYPE: '#06b6d4',
28
- READS: '#eab308',
29
- WRITES: '#eab308',
30
- OVERRIDES: '#94a3b8',
31
- };
32
-
33
- const state = {
34
- nodes: [],
35
- edges: [],
36
- cy: undefined,
37
- hiddenNodeKinds: new Set(),
38
- hiddenEdgeKinds: new Set(),
39
- hideIsolated: false,
40
- droppedFiles: { nodes: undefined, edges: undefined },
41
- };
42
-
43
- const el = (id) => document.getElementById(id);
44
-
45
- /* ---------- data loading ---------- */
46
-
47
- function boot() {
48
- setupDropzone();
49
- el('hide-isolated').addEventListener('change', (event) => {
50
- state.hideIsolated = event.target.checked;
51
- applyFilters();
52
- });
53
- el('relayout').addEventListener('click', () => runLayout());
54
- el('search').addEventListener('input', () => renderSearchResults());
55
- el('search').addEventListener('keydown', (event) => {
56
- if (event.key === 'Enter') {
57
- const first = document.querySelector('#search-results .hit');
58
- if (first !== null) {
59
- first.click();
60
- }
61
- }
62
- });
63
-
64
- if (window.GRAPH_DATA !== undefined) {
65
- setData(window.GRAPH_DATA.nodes, window.GRAPH_DATA.edges, 'embedded graph_data.js');
66
- return;
67
- }
68
- if (location.protocol.startsWith('http') === true) {
69
- tryFetch();
70
- return;
71
- }
72
- el('status').textContent = 'no data — run `npm run build`, or drop the JSONL files here';
73
- }
74
-
75
- async function tryFetch() {
76
- try {
77
- const [nodesText, edgesText] = await Promise.all([
78
- fetch('../../../outputs/graph/nodes.jsonl').then((r) => r.ok === true ? r.text() : Promise.reject(new Error(String(r.status)))),
79
- fetch('../../../outputs/graph/edges.jsonl').then((r) => r.ok === true ? r.text() : Promise.reject(new Error(String(r.status)))),
80
- ]);
81
- setData(parseJsonl(nodesText), parseJsonl(edgesText), 'fetched ../../../outputs/graph/*.jsonl');
82
- } catch {
83
- el('status').textContent = 'no data — generate data/graph_data.js or drop the JSONL files here';
84
- }
85
- }
86
-
87
- function parseJsonl(text) {
88
- return text.split('\n').filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
89
- }
90
-
91
- function setupDropzone() {
92
- const zone = el('dropzone');
93
- window.addEventListener('dragover', (event) => {
94
- event.preventDefault();
95
- zone.classList.add('active');
96
- });
97
- window.addEventListener('dragleave', (event) => {
98
- if (event.relatedTarget === null) {
99
- zone.classList.remove('active');
100
- }
101
- });
102
- window.addEventListener('drop', async (event) => {
103
- event.preventDefault();
104
- zone.classList.remove('active');
105
- for (const file of event.dataTransfer.files) {
106
- const records = parseJsonl(await file.text());
107
- if (records.length === 0) {
108
- continue;
109
- }
110
- if (records[0].from !== undefined && records[0].to !== undefined) {
111
- state.droppedFiles.edges = records;
112
- } else {
113
- state.droppedFiles.nodes = records;
114
- }
115
- }
116
- if (state.droppedFiles.nodes !== undefined && state.droppedFiles.edges !== undefined) {
117
- setData(state.droppedFiles.nodes, state.droppedFiles.edges, 'dropped files');
118
- } else {
119
- el('status').textContent = 'got one file — drop the other one too';
120
- }
121
- });
122
- }
123
-
124
- /* ---------- graph construction ---------- */
125
-
126
- function setData(nodes, edges, sourceLabel) {
127
- state.nodes = nodes;
128
- state.edges = edges;
129
-
130
- const nodeIds = new Set(nodes.map((node) => node.id));
131
- const degree = new Map();
132
- for (const edge of edges) {
133
- degree.set(edge.from, (degree.get(edge.from) ?? 0) + 1);
134
- degree.set(edge.to, (degree.get(edge.to) ?? 0) + 1);
135
- }
136
-
137
- const elements = [
138
- ...nodes.map((node) => ({
139
- group: 'nodes',
140
- data: { id: node.id, name: node.name, kind: node.kind, filePath: node.filePath, startLine: node.range === undefined ? 0 : node.range.startLine, exported: node.exported === true, degree: degree.get(node.id) ?? 0 },
141
- })),
142
- ...edges
143
- .filter((edge) => nodeIds.has(edge.from) === true && nodeIds.has(edge.to) === true)
144
- .map((edge) => ({
145
- group: 'edges',
146
- data: { id: edge.id, source: edge.from, target: edge.to, kind: edge.kind },
147
- })),
148
- ];
149
-
150
- if (state.cy !== undefined) {
151
- state.cy.destroy();
152
- }
153
- state.cy = cytoscape({
154
- container: el('cy'),
155
- elements,
156
- style: cyStyle(),
157
- layout: { name: 'cose', animate: false, padding: 30 },
158
- });
159
- state.cy.on('tap', 'node', (event) => select(event.target));
160
- state.cy.on('tap', (event) => {
161
- if (event.target === state.cy) {
162
- clearSelection();
163
- }
164
- });
165
-
166
- buildLegends();
167
- applyFilters();
168
- el('status').textContent = `${sourceLabel} — ${nodes.length} nodes, ${edges.length} edges`;
169
- }
170
-
171
- function cyStyle() {
172
- return [
173
- {
174
- selector: 'node',
175
- style: {
176
- 'background-color': (node) => NODE_COLORS[node.data('kind')] ?? '#9ca3af',
177
- 'width': (node) => 8 + Math.sqrt(node.data('degree')) * 4,
178
- 'height': (node) => 8 + Math.sqrt(node.data('degree')) * 4,
179
- 'label': 'data(name)',
180
- 'color': '#cbd5e1',
181
- 'font-size': 8,
182
- 'min-zoomed-font-size': 7,
183
- 'text-valign': 'bottom',
184
- 'text-margin-y': 3,
185
- },
186
- },
187
- {
188
- selector: 'edge',
189
- style: {
190
- 'width': 1,
191
- 'line-color': (edge) => EDGE_COLORS[edge.data('kind')] ?? '#475569',
192
- 'target-arrow-color': (edge) => EDGE_COLORS[edge.data('kind')] ?? '#475569',
193
- 'target-arrow-shape': 'triangle',
194
- 'arrow-scale': 0.6,
195
- 'curve-style': 'bezier',
196
- 'opacity': 0.65,
197
- },
198
- },
199
- { selector: '.hidden', style: { display: 'none' } },
200
- { selector: '.faded', style: { opacity: 0.08, 'text-opacity': 0 } },
201
- { selector: 'node.sel', style: { 'border-width': 3, 'border-color': '#ffffff' } },
202
- ];
203
- }
204
-
205
- function runLayout() {
206
- const name = el('layout-select').value;
207
- const options = name === 'concentric'
208
- ? { name, concentric: (node) => node.degree(), levelWidth: () => 2, animate: false, padding: 30 }
209
- : { name, animate: false, padding: 30 };
210
- state.cy.elements(':visible').layout(options).run();
211
- }
212
-
213
- /* ---------- legends & filtering ---------- */
214
-
215
- function buildLegends() {
216
- const nodeCounts = countBy(state.nodes.map((node) => node.kind));
217
- const edgeCounts = countBy(state.edges.map((edge) => edge.kind));
218
- renderLegend(el('node-kinds'), nodeCounts, NODE_COLORS, state.hiddenNodeKinds);
219
- renderLegend(el('edge-kinds'), edgeCounts, EDGE_COLORS, state.hiddenEdgeKinds);
220
- }
221
-
222
- function renderLegend(container, counts, colors, hiddenSet) {
223
- container.innerHTML = '';
224
- for (const [kind, count] of counts) {
225
- const label = document.createElement('label');
226
- const checkbox = document.createElement('input');
227
- checkbox.type = 'checkbox';
228
- checkbox.checked = hiddenSet.has(kind) === false;
229
- checkbox.addEventListener('change', () => {
230
- if (checkbox.checked === true) {
231
- hiddenSet.delete(kind);
232
- } else {
233
- hiddenSet.add(kind);
234
- }
235
- applyFilters();
236
- });
237
- const swatch = document.createElement('span');
238
- swatch.className = 'swatch';
239
- swatch.style.background = colors[kind] ?? '#9ca3af';
240
- const text = document.createElement('span');
241
- text.textContent = kind;
242
- const countSpan = document.createElement('span');
243
- countSpan.className = 'count';
244
- countSpan.textContent = String(count);
245
- label.append(checkbox, swatch, text, countSpan);
246
- container.appendChild(label);
247
- }
248
- }
249
-
250
- function applyFilters() {
251
- const cy = state.cy;
252
- if (cy === undefined) {
253
- return;
254
- }
255
- cy.batch(() => {
256
- cy.nodes().forEach((node) => {
257
- node.toggleClass('hidden', state.hiddenNodeKinds.has(node.data('kind')) === true);
258
- });
259
- cy.edges().forEach((edge) => {
260
- edge.toggleClass('hidden', state.hiddenEdgeKinds.has(edge.data('kind')) === true);
261
- });
262
- if (state.hideIsolated === true) {
263
- cy.nodes().not('.hidden').forEach((node) => {
264
- const hasVisibleEdge = node.connectedEdges().some((edge) =>
265
- edge.hasClass('hidden') === false
266
- && edge.source().hasClass('hidden') === false
267
- && edge.target().hasClass('hidden') === false);
268
- if (hasVisibleEdge === false) {
269
- node.addClass('hidden');
270
- }
271
- });
272
- }
273
- });
274
- }
275
-
276
- function countBy(values) {
277
- const counts = new Map();
278
- for (const value of values) {
279
- counts.set(value, (counts.get(value) ?? 0) + 1);
280
- }
281
- return [...counts.entries()].sort((a, b) => b[1] - a[1]);
282
- }
283
-
284
- /* ---------- search ---------- */
285
-
286
- function renderSearchResults() {
287
- const query = el('search').value.trim().toLowerCase();
288
- const container = el('search-results');
289
- container.innerHTML = '';
290
- if (query.length < 2) {
291
- return;
292
- }
293
- const hits = state.nodes
294
- .filter((node) => node.name.toLowerCase().includes(query) === true || node.filePath.toLowerCase().includes(query) === true)
295
- .slice(0, 15);
296
- for (const hit of hits) {
297
- const row = document.createElement('div');
298
- row.className = 'hit';
299
- row.innerHTML = `${escapeHtml(hit.name)} <span class="loc">${escapeHtml(hit.kind)} · ${escapeHtml(hit.filePath)}</span>`;
300
- row.addEventListener('click', () => {
301
- const node = state.cy.getElementById(hit.id);
302
- if (node.length === 1) {
303
- select(node);
304
- state.cy.animate({ center: { eles: node }, zoom: 2 }, { duration: 350 });
305
- }
306
- });
307
- container.appendChild(row);
308
- }
309
- }
310
-
311
- /* ---------- selection & details ---------- */
312
-
313
- function select(node) {
314
- const cy = state.cy;
315
- cy.elements().addClass('faded').removeClass('sel');
316
- const hood = node.closedNeighborhood();
317
- hood.removeClass('faded');
318
- node.addClass('sel');
319
- renderDetails(node);
320
- }
321
-
322
- function clearSelection() {
323
- state.cy.elements().removeClass('faded sel');
324
- el('details-body').textContent = 'click a node';
325
- }
326
-
327
- function renderDetails(node) {
328
- const id = node.id();
329
- const color = NODE_COLORS[node.data('kind')] ?? '#9ca3af';
330
- const outgoing = state.edges.filter((edge) => edge.from === id);
331
- const incoming = state.edges.filter((edge) => edge.to === id);
332
- const nodeById = new Map(state.nodes.map((entry) => [entry.id, entry]));
333
-
334
- const renderEdgeRows = (edges, direction) => edges.map((edge) => {
335
- const otherId = direction === 'out' ? edge.to : edge.from;
336
- const other = nodeById.get(otherId);
337
- const name = other === undefined ? otherId : other.name;
338
- const arrow = direction === 'out' ? '→' : '←';
339
- return `<div class="edge-row"><span class="edge-kind">${escapeHtml(edge.kind)}</span> ${arrow} <a data-target="${escapeHtml(otherId)}">${escapeHtml(name)}</a></div>`;
340
- }).join('');
341
-
342
- el('details-body').innerHTML = `
343
- <div><span class="kind-tag" style="background:${color}">${escapeHtml(node.data('kind'))}</span> <strong>${escapeHtml(node.data('name'))}</strong></div>
344
- <div>${escapeHtml(node.data('filePath'))}${node.data('startLine') > 0 ? ':' + node.data('startLine') : ''}</div>
345
- <div class="id">${escapeHtml(id)}</div>
346
- <h3>outgoing (${outgoing.length})</h3>${renderEdgeRows(outgoing, 'out')}
347
- <h3>incoming (${incoming.length})</h3>${renderEdgeRows(incoming, 'in')}
348
- `;
349
- el('details-body').querySelectorAll('a[data-target]').forEach((link) => {
350
- link.addEventListener('click', () => {
351
- const target = state.cy.getElementById(link.dataset.target);
352
- if (target.length === 1) {
353
- select(target);
354
- state.cy.animate({ center: { eles: target } }, { duration: 300 });
355
- }
356
- });
357
- });
358
- }
359
-
360
- function escapeHtml(value) {
361
- return String(value).replace(/[&<>"']/g, (char) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[char]));
362
- }
363
-
364
- boot();
@@ -1,13 +0,0 @@
1
- import OpenAI from 'openai';
2
- import { GraphQuery } from '../query/graph-query.js';
3
- export declare const PROPOSE_TOOL_NAME = "propose_optimization";
4
- export declare const AGENT_TOOLS: OpenAI.Chat.Completions.ChatCompletionTool[];
5
- export declare class AgentTools {
6
- private readonly query;
7
- private readonly rootPath;
8
- constructor(query: GraphQuery, rootPath: string);
9
- dispatch(name: string, input: Record<string, unknown>): Promise<string>;
10
- private readFile;
11
- private static stringify;
12
- }
13
- //# sourceMappingURL=agent-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../src/agent/agent-tools.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAyGnE,CAAC;AAEF,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM;IAKzC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;YAqB/D,QAAQ;IAetB,OAAO,CAAC,MAAM,CAAC,SAAS;CAGxB"}