@surething/cockpit 1.0.272 → 1.0.273

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 (674) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +5 -4
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/cockpit-build.json +1 -1
  5. package/.next-prod/prerender-manifest.json +3 -3
  6. package/.next-prod/routes-manifest.json +6 -0
  7. package/.next-prod/server/app/_global-error/page.js +2 -2
  8. package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
  9. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next-prod/server/app/_global-error.html +1 -1
  11. package/.next-prod/server/app/_global-error.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next-prod/server/app/_not-found/page.js +1 -1
  16. package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next-prod/server/app/_not-found.html +2 -2
  19. package/.next-prod/server/app/_not-found.rsc +3 -3
  20. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
  21. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
  22. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next-prod/server/app/api/agent/test/route.js +1 -1
  25. package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
  26. package/.next-prod/server/app/api/bash/route.js +1 -1
  27. package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
  28. package/.next-prod/server/app/api/chat/codex/route.js +1 -1
  29. package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
  30. package/.next-prod/server/app/api/chat/deepseek/route.js +1 -1
  31. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
  32. package/.next-prod/server/app/api/chat/glm/route.js +1 -1
  33. package/.next-prod/server/app/api/chat/glm/route.js.nft.json +1 -1
  34. package/.next-prod/server/app/api/chat/kimi/route.js +1 -1
  35. package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
  36. package/.next-prod/server/app/api/chat/ollama/route.js +1 -1
  37. package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
  38. package/.next-prod/server/app/api/chat/route.js +1 -1
  39. package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
  40. package/.next-prod/server/app/api/chat/stop/route.js +1 -1
  41. package/.next-prod/server/app/api/chat/stop/route.js.nft.json +1 -1
  42. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  43. package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
  44. package/.next-prod/server/app/api/commands/route.js +1 -1
  45. package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
  46. package/.next-prod/server/app/api/comments/route.js +1 -1
  47. package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
  48. package/.next-prod/server/app/api/db/columns/route.js +1 -1
  49. package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
  50. package/.next-prod/server/app/api/db/connect/route.js +2 -2
  51. package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
  52. package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
  53. package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
  54. package/.next-prod/server/app/api/db/export/route.js +1 -1
  55. package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
  56. package/.next-prod/server/app/api/db/query/route.js +1 -1
  57. package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
  58. package/.next-prod/server/app/api/db/schemas/route.js +2 -2
  59. package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
  60. package/.next-prod/server/app/api/deepseek/balance/route.js +1 -1
  61. package/.next-prod/server/app/api/deepseek/balance/route.js.nft.json +1 -1
  62. package/.next-prod/server/app/api/deepseek/credentials/route.js +1 -1
  63. package/.next-prod/server/app/api/deepseek/credentials/route.js.nft.json +1 -1
  64. package/.next-prod/server/app/api/deepseek/models/route.js +1 -1
  65. package/.next-prod/server/app/api/deepseek/models/route.js.nft.json +1 -1
  66. package/.next-prod/server/app/api/dev/spans/route.js +1 -1
  67. package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
  68. package/.next-prod/server/app/api/extension/version/route.js +1 -1
  69. package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
  70. package/.next-prod/server/app/api/file/route.js +1 -1
  71. package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
  72. package/.next-prod/server/app/api/files/blame/route.js +1 -1
  73. package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
  74. package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
  75. package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
  76. package/.next-prod/server/app/api/files/copy/route.js +1 -1
  77. package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
  78. package/.next-prod/server/app/api/files/delete/route.js +1 -1
  79. package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
  80. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  81. package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
  82. package/.next-prod/server/app/api/files/index/route.js +1 -1
  83. package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
  84. package/.next-prod/server/app/api/files/init/route.js +1 -1
  85. package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
  86. package/.next-prod/server/app/api/files/paste/route.js +1 -1
  87. package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
  88. package/.next-prod/server/app/api/files/read/route.js +1 -1
  89. package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
  90. package/.next-prod/server/app/api/files/readdir/route.js +1 -1
  91. package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
  92. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  93. package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
  94. package/.next-prod/server/app/api/files/save/route.js +1 -1
  95. package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
  96. package/.next-prod/server/app/api/files/search/route.js +1 -1
  97. package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
  98. package/.next-prod/server/app/api/files/stat/route.js +1 -1
  99. package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
  100. package/.next-prod/server/app/api/files/text/route.js +1 -1
  101. package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
  102. package/.next-prod/server/app/api/git/blob/route.js +1 -1
  103. package/.next-prod/server/app/api/git/blob/route.js.nft.json +1 -1
  104. package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
  105. package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
  106. package/.next-prod/server/app/api/git/branches/route.js +1 -1
  107. package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
  108. package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
  109. package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
  110. package/.next-prod/server/app/api/git/commits/route.js +1 -1
  111. package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
  112. package/.next-prod/server/app/api/git/current-branch/route.js +1 -1
  113. package/.next-prod/server/app/api/git/current-branch/route.js.nft.json +1 -1
  114. package/.next-prod/server/app/api/git/diff/route.js +1 -1
  115. package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
  116. package/.next-prod/server/app/api/git/discard/route.js +1 -1
  117. package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
  118. package/.next-prod/server/app/api/git/stage/route.js +1 -1
  119. package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
  120. package/.next-prod/server/app/api/git/status/route.js +1 -1
  121. package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
  122. package/.next-prod/server/app/api/git/unstage/route.js +1 -1
  123. package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
  124. package/.next-prod/server/app/api/git/worktree/route.js +1 -1
  125. package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
  126. package/.next-prod/server/app/api/glm/credentials/route.js +1 -1
  127. package/.next-prod/server/app/api/glm/credentials/route.js.nft.json +1 -1
  128. package/.next-prod/server/app/api/glm/models/route.js +1 -1
  129. package/.next-prod/server/app/api/glm/models/route.js.nft.json +1 -1
  130. package/.next-prod/server/app/api/glm/usage/route.js +1 -1
  131. package/.next-prod/server/app/api/glm/usage/route.js.nft.json +1 -1
  132. package/.next-prod/server/app/api/global-state/route.js +1 -1
  133. package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
  134. package/.next-prod/server/app/api/health/route.js +1 -1
  135. package/.next-prod/server/app/api/health/route.js.nft.json +1 -1
  136. package/.next-prod/server/app/api/html-apps/[id]/route.js +1 -1
  137. package/.next-prod/server/app/api/html-apps/[id]/route.js.nft.json +1 -1
  138. package/.next-prod/server/app/api/html-apps/route.js +1 -1
  139. package/.next-prod/server/app/api/html-apps/route.js.nft.json +1 -1
  140. package/.next-prod/server/app/api/kimi/credentials/route.js +1 -1
  141. package/.next-prod/server/app/api/kimi/credentials/route.js.nft.json +1 -1
  142. package/.next-prod/server/app/api/kimi/models/route.js +1 -1
  143. package/.next-prod/server/app/api/kimi/models/route.js.nft.json +1 -1
  144. package/.next-prod/server/app/api/kimi/usage/route.js +1 -1
  145. package/.next-prod/server/app/api/kimi/usage/route.js.nft.json +1 -1
  146. package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
  147. package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
  148. package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
  149. package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
  150. package/.next-prod/server/app/api/lsp/references/route.js +1 -1
  151. package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
  152. package/.next-prod/server/app/api/lsp/status/route.js +1 -1
  153. package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
  154. package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
  155. package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
  156. package/.next-prod/server/app/api/mysql/columns/route.js +2 -2
  157. package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
  158. package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
  159. package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
  160. package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
  161. package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
  162. package/.next-prod/server/app/api/mysql/export/route.js +1 -1
  163. package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
  164. package/.next-prod/server/app/api/mysql/query/route.js +1 -1
  165. package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
  166. package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
  167. package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
  168. package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
  169. package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
  170. package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
  171. package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
  172. package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
  173. package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
  174. package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
  175. package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
  176. package/.next-prod/server/app/api/note/route.js +1 -1
  177. package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
  178. package/.next-prod/server/app/api/ollama/config/route.js +1 -1
  179. package/.next-prod/server/app/api/ollama/config/route.js.nft.json +1 -1
  180. package/.next-prod/server/app/api/ollama/models/route.js +1 -1
  181. package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
  182. package/.next-prod/server/app/api/ollama/start/route.js +1 -1
  183. package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
  184. package/.next-prod/server/app/api/open-cursor/route.js +1 -1
  185. package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
  186. package/.next-prod/server/app/api/open-vscode/route.js +1 -1
  187. package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
  188. package/.next-prod/server/app/api/pick-folder/route.js +1 -1
  189. package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
  190. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  191. package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
  192. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  193. package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
  194. package/.next-prod/server/app/api/project-state/route.js +1 -1
  195. package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
  196. package/.next-prod/server/app/api/projectGraph/affected/route.js +1 -1
  197. package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
  198. package/.next-prod/server/app/api/projectGraph/callees/route.js +1 -1
  199. package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
  200. package/.next-prod/server/app/api/projectGraph/callers/route.js +1 -1
  201. package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
  202. package/.next-prod/server/app/api/projectGraph/coedit/route.js +1 -1
  203. package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
  204. package/.next-prod/server/app/api/projectGraph/context/route.js +1 -1
  205. package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
  206. package/.next-prod/server/app/api/projectGraph/file/route.js +1 -1
  207. package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
  208. package/.next-prod/server/app/api/projectGraph/file-functions/route.js +1 -1
  209. package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
  210. package/.next-prod/server/app/api/projectGraph/impact/route.js +1 -1
  211. package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
  212. package/.next-prod/server/app/api/projectGraph/related/route.js +1 -1
  213. package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
  214. package/.next-prod/server/app/api/projectGraph/risk/route.js +1 -1
  215. package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
  216. package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
  217. package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
  218. package/.next-prod/server/app/api/projects/route.js +1 -1
  219. package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
  220. package/.next-prod/server/app/api/prompts/config/route.js +1 -1
  221. package/.next-prod/server/app/api/prompts/config/route.js.nft.json +1 -1
  222. package/.next-prod/server/app/api/push/public-key/route.js +1 -1
  223. package/.next-prod/server/app/api/push/public-key/route.js.nft.json +1 -1
  224. package/.next-prod/server/app/api/push/subscribe/route.js +1 -1
  225. package/.next-prod/server/app/api/push/subscribe/route.js.nft.json +1 -1
  226. package/.next-prod/server/app/api/push/unsubscribe/route.js +1 -1
  227. package/.next-prod/server/app/api/push/unsubscribe/route.js.nft.json +1 -1
  228. package/.next-prod/server/app/api/redis/command/route.js +1 -1
  229. package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
  230. package/.next-prod/server/app/api/redis/connect/route.js +1 -1
  231. package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
  232. package/.next-prod/server/app/api/redis/delete/route.js +1 -1
  233. package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
  234. package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
  235. package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
  236. package/.next-prod/server/app/api/redis/get/route.js +1 -1
  237. package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
  238. package/.next-prod/server/app/api/redis/keys/route.js +1 -1
  239. package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
  240. package/.next-prod/server/app/api/redis/set/route.js +1 -1
  241. package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
  242. package/.next-prod/server/app/api/restart/route.js +1 -1
  243. package/.next-prod/server/app/api/restart/route.js.nft.json +1 -1
  244. package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
  245. package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
  246. package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
  247. package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
  248. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  249. package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
  250. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  251. package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
  252. package/.next-prod/server/app/api/review/order/route.js +1 -1
  253. package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
  254. package/.next-prod/server/app/api/review/route.js +1 -1
  255. package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
  256. package/.next-prod/server/app/api/review/share-info/route.js +1 -1
  257. package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
  258. package/.next-prod/server/app/api/review/users/route.js +1 -1
  259. package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
  260. package/.next-prod/server/app/api/scheduled-tasks/route.js +2 -2
  261. package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
  262. package/.next-prod/server/app/api/services/config/route.js +1 -1
  263. package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
  264. package/.next-prod/server/app/api/services/scripts/route.js +1 -1
  265. package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
  266. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  267. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
  268. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  269. package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
  270. package/.next-prod/server/app/api/session/user-messages/route.js +1 -0
  271. package/.next-prod/server/app/api/session/user-messages/route.js.nft.json +1 -0
  272. package/.next-prod/server/app/api/session/user-messages/route_client-reference-manifest.js +1 -0
  273. package/.next-prod/server/app/api/session-by-path/route.js +1 -3
  274. package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
  275. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  276. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
  277. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  278. package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
  279. package/.next-prod/server/app/api/sessions/route.js +1 -1
  280. package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
  281. package/.next-prod/server/app/api/settings/route.js +1 -1
  282. package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
  283. package/.next-prod/server/app/api/shutdown/route.js +1 -1
  284. package/.next-prod/server/app/api/shutdown/route.js.nft.json +1 -1
  285. package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
  286. package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
  287. package/.next-prod/server/app/api/skills/content/route.js +1 -1
  288. package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
  289. package/.next-prod/server/app/api/skills/route.js +1 -1
  290. package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
  291. package/.next-prod/server/app/api/snapshots/blob/route.js +1 -1
  292. package/.next-prod/server/app/api/snapshots/blob/route.js.nft.json +1 -1
  293. package/.next-prod/server/app/api/snapshots/diff/route.js +1 -1
  294. package/.next-prod/server/app/api/snapshots/diff/route.js.nft.json +1 -1
  295. package/.next-prod/server/app/api/snapshots/route.js +1 -1
  296. package/.next-prod/server/app/api/snapshots/route.js.nft.json +1 -1
  297. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  298. package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
  299. package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
  300. package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
  301. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  302. package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
  303. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  304. package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
  305. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  306. package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
  307. package/.next-prod/server/app/api/update/route.js +1 -1
  308. package/.next-prod/server/app/api/update/route.js.nft.json +1 -1
  309. package/.next-prod/server/app/api/update-state/route.js +1 -1
  310. package/.next-prod/server/app/api/update-state/route.js.nft.json +1 -1
  311. package/.next-prod/server/app/api/version/route.js +1 -1
  312. package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
  313. package/.next-prod/server/app/apps/[...path]/route.js +1 -1
  314. package/.next-prod/server/app/apps/[...path]/route.js.nft.json +1 -1
  315. package/.next-prod/server/app/favicon.ico/route.js +1 -1
  316. package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
  317. package/.next-prod/server/app/m/page.js +1 -1
  318. package/.next-prod/server/app/m/page.js.nft.json +1 -1
  319. package/.next-prod/server/app/m/page_client-reference-manifest.js +1 -1
  320. package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
  321. package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  322. package/.next-prod/server/app/page.js +1 -1
  323. package/.next-prod/server/app/page.js.nft.json +1 -1
  324. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  325. package/.next-prod/server/app/project/page.js +1 -1
  326. package/.next-prod/server/app/project/page.js.nft.json +1 -1
  327. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  328. package/.next-prod/server/app/review/[id]/page.js +1 -1
  329. package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
  330. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  331. package/.next-prod/server/app-paths-manifest.json +5 -4
  332. package/.next-prod/server/chunks/1237.js +1 -0
  333. package/.next-prod/server/chunks/4949.js +1 -1
  334. package/.next-prod/server/chunks/{5766.js → 5433.js} +4 -4
  335. package/.next-prod/server/chunks/5750.js +13 -13
  336. package/.next-prod/server/chunks/6548.js +1 -1
  337. package/.next-prod/server/chunks/8616.js +3 -0
  338. package/.next-prod/server/middleware-build-manifest.js +1 -1
  339. package/.next-prod/server/pages/404.html +2 -2
  340. package/.next-prod/server/pages/500.html +1 -1
  341. package/.next-prod/server/server-reference-manifest.json +1 -1
  342. package/.next-prod/static/chunks/5390-e2c2386e8288a254.js +32 -0
  343. package/.next-prod/static/chunks/7184-8b7ad4ccea8b15a3.js +17 -0
  344. package/.next-prod/static/chunks/{9200-2d063007a9a86cd2.js → 7570-ebe01cce6f28a79f.js} +2 -2
  345. package/.next-prod/static/chunks/9092-a942df8114966b59.js +716 -0
  346. package/.next-prod/static/chunks/app/_global-error/page-0bc5d188dc4650ab.js +1 -0
  347. package/.next-prod/static/chunks/app/api/agent/test/route-0bc5d188dc4650ab.js +1 -0
  348. package/.next-prod/static/chunks/app/api/bash/route-0bc5d188dc4650ab.js +1 -0
  349. package/.next-prod/static/chunks/app/api/chat/codex/route-0bc5d188dc4650ab.js +1 -0
  350. package/.next-prod/static/chunks/app/api/chat/deepseek/route-0bc5d188dc4650ab.js +1 -0
  351. package/.next-prod/static/chunks/app/api/chat/glm/route-0bc5d188dc4650ab.js +1 -0
  352. package/.next-prod/static/chunks/app/api/chat/kimi/route-0bc5d188dc4650ab.js +1 -0
  353. package/.next-prod/static/chunks/app/api/chat/ollama/route-0bc5d188dc4650ab.js +1 -0
  354. package/.next-prod/static/chunks/app/api/chat/route-0bc5d188dc4650ab.js +1 -0
  355. package/.next-prod/static/chunks/app/api/chat/stop/route-0bc5d188dc4650ab.js +1 -0
  356. package/.next-prod/static/chunks/app/api/claude-stats/route-0bc5d188dc4650ab.js +1 -0
  357. package/.next-prod/static/chunks/app/api/commands/route-0bc5d188dc4650ab.js +1 -0
  358. package/.next-prod/static/chunks/app/api/comments/route-0bc5d188dc4650ab.js +1 -0
  359. package/.next-prod/static/chunks/app/api/db/columns/route-0bc5d188dc4650ab.js +1 -0
  360. package/.next-prod/static/chunks/app/api/db/connect/route-0bc5d188dc4650ab.js +1 -0
  361. package/.next-prod/static/chunks/app/api/db/disconnect/route-0bc5d188dc4650ab.js +1 -0
  362. package/.next-prod/static/chunks/app/api/db/export/route-0bc5d188dc4650ab.js +1 -0
  363. package/.next-prod/static/chunks/app/api/db/query/route-0bc5d188dc4650ab.js +1 -0
  364. package/.next-prod/static/chunks/app/api/db/schemas/route-0bc5d188dc4650ab.js +1 -0
  365. package/.next-prod/static/chunks/app/api/deepseek/balance/route-0bc5d188dc4650ab.js +1 -0
  366. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-0bc5d188dc4650ab.js +1 -0
  367. package/.next-prod/static/chunks/app/api/deepseek/models/route-0bc5d188dc4650ab.js +1 -0
  368. package/.next-prod/static/chunks/app/api/dev/spans/route-0bc5d188dc4650ab.js +1 -0
  369. package/.next-prod/static/chunks/app/api/extension/version/route-0bc5d188dc4650ab.js +1 -0
  370. package/.next-prod/static/chunks/app/api/file/route-0bc5d188dc4650ab.js +1 -0
  371. package/.next-prod/static/chunks/app/api/files/blame/route-0bc5d188dc4650ab.js +1 -0
  372. package/.next-prod/static/chunks/app/api/files/clipboard/route-0bc5d188dc4650ab.js +1 -0
  373. package/.next-prod/static/chunks/app/api/files/copy/route-0bc5d188dc4650ab.js +1 -0
  374. package/.next-prod/static/chunks/app/api/files/delete/route-0bc5d188dc4650ab.js +1 -0
  375. package/.next-prod/static/chunks/app/api/files/expanded/route-0bc5d188dc4650ab.js +1 -0
  376. package/.next-prod/static/chunks/app/api/files/index/route-0bc5d188dc4650ab.js +1 -0
  377. package/.next-prod/static/chunks/app/api/files/init/route-0bc5d188dc4650ab.js +1 -0
  378. package/.next-prod/static/chunks/app/api/files/paste/route-0bc5d188dc4650ab.js +1 -0
  379. package/.next-prod/static/chunks/app/api/files/read/route-0bc5d188dc4650ab.js +1 -0
  380. package/.next-prod/static/chunks/app/api/files/readdir/route-0bc5d188dc4650ab.js +1 -0
  381. package/.next-prod/static/chunks/app/api/files/recent/route-0bc5d188dc4650ab.js +1 -0
  382. package/.next-prod/static/chunks/app/api/files/save/route-0bc5d188dc4650ab.js +1 -0
  383. package/.next-prod/static/chunks/app/api/files/search/route-0bc5d188dc4650ab.js +1 -0
  384. package/.next-prod/static/chunks/app/api/files/stat/route-0bc5d188dc4650ab.js +1 -0
  385. package/.next-prod/static/chunks/app/api/files/text/route-0bc5d188dc4650ab.js +1 -0
  386. package/.next-prod/static/chunks/app/api/git/blob/route-0bc5d188dc4650ab.js +1 -0
  387. package/.next-prod/static/chunks/app/api/git/branch-diff/route-0bc5d188dc4650ab.js +1 -0
  388. package/.next-prod/static/chunks/app/api/git/branches/route-0bc5d188dc4650ab.js +1 -0
  389. package/.next-prod/static/chunks/app/api/git/commit-diff/route-0bc5d188dc4650ab.js +1 -0
  390. package/.next-prod/static/chunks/app/api/git/commits/route-0bc5d188dc4650ab.js +1 -0
  391. package/.next-prod/static/chunks/app/api/git/current-branch/route-0bc5d188dc4650ab.js +1 -0
  392. package/.next-prod/static/chunks/app/api/git/diff/route-0bc5d188dc4650ab.js +1 -0
  393. package/.next-prod/static/chunks/app/api/git/discard/route-0bc5d188dc4650ab.js +1 -0
  394. package/.next-prod/static/chunks/app/api/git/stage/route-0bc5d188dc4650ab.js +1 -0
  395. package/.next-prod/static/chunks/app/api/git/status/route-0bc5d188dc4650ab.js +1 -0
  396. package/.next-prod/static/chunks/app/api/git/unstage/route-0bc5d188dc4650ab.js +1 -0
  397. package/.next-prod/static/chunks/app/api/git/worktree/route-0bc5d188dc4650ab.js +1 -0
  398. package/.next-prod/static/chunks/app/api/glm/credentials/route-0bc5d188dc4650ab.js +1 -0
  399. package/.next-prod/static/chunks/app/api/glm/models/route-0bc5d188dc4650ab.js +1 -0
  400. package/.next-prod/static/chunks/app/api/glm/usage/route-0bc5d188dc4650ab.js +1 -0
  401. package/.next-prod/static/chunks/app/api/global-state/route-0bc5d188dc4650ab.js +1 -0
  402. package/.next-prod/static/chunks/app/api/health/route-0bc5d188dc4650ab.js +1 -0
  403. package/.next-prod/static/chunks/app/api/html-apps/[id]/route-0bc5d188dc4650ab.js +1 -0
  404. package/.next-prod/static/chunks/app/api/html-apps/route-0bc5d188dc4650ab.js +1 -0
  405. package/.next-prod/static/chunks/app/api/kimi/credentials/route-0bc5d188dc4650ab.js +1 -0
  406. package/.next-prod/static/chunks/app/api/kimi/models/route-0bc5d188dc4650ab.js +1 -0
  407. package/.next-prod/static/chunks/app/api/kimi/usage/route-0bc5d188dc4650ab.js +1 -0
  408. package/.next-prod/static/chunks/app/api/lsp/definition/route-0bc5d188dc4650ab.js +1 -0
  409. package/.next-prod/static/chunks/app/api/lsp/hover/route-0bc5d188dc4650ab.js +1 -0
  410. package/.next-prod/static/chunks/app/api/lsp/references/route-0bc5d188dc4650ab.js +1 -0
  411. package/.next-prod/static/chunks/app/api/lsp/status/route-0bc5d188dc4650ab.js +1 -0
  412. package/.next-prod/static/chunks/app/api/lsp/warmup/route-0bc5d188dc4650ab.js +1 -0
  413. package/.next-prod/static/chunks/app/api/mysql/columns/route-0bc5d188dc4650ab.js +1 -0
  414. package/.next-prod/static/chunks/app/api/mysql/connect/route-0bc5d188dc4650ab.js +1 -0
  415. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-0bc5d188dc4650ab.js +1 -0
  416. package/.next-prod/static/chunks/app/api/mysql/export/route-0bc5d188dc4650ab.js +1 -0
  417. package/.next-prod/static/chunks/app/api/mysql/query/route-0bc5d188dc4650ab.js +1 -0
  418. package/.next-prod/static/chunks/app/api/mysql/schemas/route-0bc5d188dc4650ab.js +1 -0
  419. package/.next-prod/static/chunks/app/api/neo4j/connect/route-0bc5d188dc4650ab.js +1 -0
  420. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-0bc5d188dc4650ab.js +1 -0
  421. package/.next-prod/static/chunks/app/api/neo4j/query/route-0bc5d188dc4650ab.js +1 -0
  422. package/.next-prod/static/chunks/app/api/neo4j/schema/route-0bc5d188dc4650ab.js +1 -0
  423. package/.next-prod/static/chunks/app/api/note/route-0bc5d188dc4650ab.js +1 -0
  424. package/.next-prod/static/chunks/app/api/ollama/config/route-0bc5d188dc4650ab.js +1 -0
  425. package/.next-prod/static/chunks/app/api/ollama/models/route-0bc5d188dc4650ab.js +1 -0
  426. package/.next-prod/static/chunks/app/api/ollama/start/route-0bc5d188dc4650ab.js +1 -0
  427. package/.next-prod/static/chunks/app/api/open-cursor/route-0bc5d188dc4650ab.js +1 -0
  428. package/.next-prod/static/chunks/app/api/open-vscode/route-0bc5d188dc4650ab.js +1 -0
  429. package/.next-prod/static/chunks/app/api/pick-folder/route-0bc5d188dc4650ab.js +1 -0
  430. package/.next-prod/static/chunks/app/api/pinned-sessions/route-0bc5d188dc4650ab.js +1 -0
  431. package/.next-prod/static/chunks/app/api/project-settings/route-0bc5d188dc4650ab.js +1 -0
  432. package/.next-prod/static/chunks/app/api/project-state/route-0bc5d188dc4650ab.js +1 -0
  433. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-0bc5d188dc4650ab.js +1 -0
  434. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-0bc5d188dc4650ab.js +1 -0
  435. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-0bc5d188dc4650ab.js +1 -0
  436. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-0bc5d188dc4650ab.js +1 -0
  437. package/.next-prod/static/chunks/app/api/projectGraph/context/route-0bc5d188dc4650ab.js +1 -0
  438. package/.next-prod/static/chunks/app/api/projectGraph/file/route-0bc5d188dc4650ab.js +1 -0
  439. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-0bc5d188dc4650ab.js +1 -0
  440. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-0bc5d188dc4650ab.js +1 -0
  441. package/.next-prod/static/chunks/app/api/projectGraph/related/route-0bc5d188dc4650ab.js +1 -0
  442. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-0bc5d188dc4650ab.js +1 -0
  443. package/.next-prod/static/chunks/app/api/projectGraph/search/route-0bc5d188dc4650ab.js +1 -0
  444. package/.next-prod/static/chunks/app/api/projects/route-0bc5d188dc4650ab.js +1 -0
  445. package/.next-prod/static/chunks/app/api/prompts/config/route-0bc5d188dc4650ab.js +1 -0
  446. package/.next-prod/static/chunks/app/api/push/public-key/route-0bc5d188dc4650ab.js +1 -0
  447. package/.next-prod/static/chunks/app/api/push/subscribe/route-0bc5d188dc4650ab.js +1 -0
  448. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-0bc5d188dc4650ab.js +1 -0
  449. package/.next-prod/static/chunks/app/api/redis/command/route-0bc5d188dc4650ab.js +1 -0
  450. package/.next-prod/static/chunks/app/api/redis/connect/route-0bc5d188dc4650ab.js +1 -0
  451. package/.next-prod/static/chunks/app/api/redis/delete/route-0bc5d188dc4650ab.js +1 -0
  452. package/.next-prod/static/chunks/app/api/redis/disconnect/route-0bc5d188dc4650ab.js +1 -0
  453. package/.next-prod/static/chunks/app/api/redis/get/route-0bc5d188dc4650ab.js +1 -0
  454. package/.next-prod/static/chunks/app/api/redis/keys/route-0bc5d188dc4650ab.js +1 -0
  455. package/.next-prod/static/chunks/app/api/redis/set/route-0bc5d188dc4650ab.js +1 -0
  456. package/.next-prod/static/chunks/app/api/restart/route-0bc5d188dc4650ab.js +1 -0
  457. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-0bc5d188dc4650ab.js +1 -0
  458. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-0bc5d188dc4650ab.js +1 -0
  459. package/.next-prod/static/chunks/app/api/review/[id]/route-0bc5d188dc4650ab.js +1 -0
  460. package/.next-prod/static/chunks/app/api/review/identify/route-0bc5d188dc4650ab.js +1 -0
  461. package/.next-prod/static/chunks/app/api/review/order/route-0bc5d188dc4650ab.js +1 -0
  462. package/.next-prod/static/chunks/app/api/review/route-0bc5d188dc4650ab.js +1 -0
  463. package/.next-prod/static/chunks/app/api/review/share-info/route-0bc5d188dc4650ab.js +1 -0
  464. package/.next-prod/static/chunks/app/api/review/users/route-0bc5d188dc4650ab.js +1 -0
  465. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-0bc5d188dc4650ab.js +1 -0
  466. package/.next-prod/static/chunks/app/api/services/config/route-0bc5d188dc4650ab.js +1 -0
  467. package/.next-prod/static/chunks/app/api/services/scripts/route-0bc5d188dc4650ab.js +1 -0
  468. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-0bc5d188dc4650ab.js +1 -0
  469. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-0bc5d188dc4650ab.js +1 -0
  470. package/.next-prod/static/chunks/app/api/session/user-messages/route-0bc5d188dc4650ab.js +1 -0
  471. package/.next-prod/static/chunks/app/api/session-by-path/route-0bc5d188dc4650ab.js +1 -0
  472. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-0bc5d188dc4650ab.js +1 -0
  473. package/.next-prod/static/chunks/app/api/sessions/projects/route-0bc5d188dc4650ab.js +1 -0
  474. package/.next-prod/static/chunks/app/api/sessions/route-0bc5d188dc4650ab.js +1 -0
  475. package/.next-prod/static/chunks/app/api/settings/route-0bc5d188dc4650ab.js +1 -0
  476. package/.next-prod/static/chunks/app/api/shutdown/route-0bc5d188dc4650ab.js +1 -0
  477. package/.next-prod/static/chunks/app/api/skills/[id]/route-0bc5d188dc4650ab.js +1 -0
  478. package/.next-prod/static/chunks/app/api/skills/content/route-0bc5d188dc4650ab.js +1 -0
  479. package/.next-prod/static/chunks/app/api/skills/route-0bc5d188dc4650ab.js +1 -0
  480. package/.next-prod/static/chunks/app/api/snapshots/blob/route-0bc5d188dc4650ab.js +1 -0
  481. package/.next-prod/static/chunks/app/api/snapshots/diff/route-0bc5d188dc4650ab.js +1 -0
  482. package/.next-prod/static/chunks/app/api/snapshots/route-0bc5d188dc4650ab.js +1 -0
  483. package/.next-prod/static/chunks/app/api/terminal/aliases/route-0bc5d188dc4650ab.js +1 -0
  484. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-0bc5d188dc4650ab.js +1 -0
  485. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-0bc5d188dc4650ab.js +1 -0
  486. package/.next-prod/static/chunks/app/api/terminal/env/route-0bc5d188dc4650ab.js +1 -0
  487. package/.next-prod/static/chunks/app/api/terminal/history/route-0bc5d188dc4650ab.js +1 -0
  488. package/.next-prod/static/chunks/app/api/update/route-0bc5d188dc4650ab.js +1 -0
  489. package/.next-prod/static/chunks/app/api/update-state/route-0bc5d188dc4650ab.js +1 -0
  490. package/.next-prod/static/chunks/app/api/version/route-0bc5d188dc4650ab.js +1 -0
  491. package/.next-prod/static/chunks/app/apps/[...path]/route-0bc5d188dc4650ab.js +1 -0
  492. package/.next-prod/static/chunks/app/{layout-4d9685b25807b4c6.js → layout-915635f208cba4b3.js} +1 -1
  493. package/.next-prod/static/chunks/app/m/{page-af6600597536f9a9.js → page-8442a2605d0feb3f.js} +1 -1
  494. package/.next-prod/static/chunks/app/manifest.webmanifest/route-0bc5d188dc4650ab.js +1 -0
  495. package/.next-prod/static/chunks/app/{page-af99426a6c82e466.js → page-48dc2d6146301fd7.js} +1 -1
  496. package/.next-prod/static/chunks/app/project/{page-af99426a6c82e466.js → page-48dc2d6146301fd7.js} +1 -1
  497. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-0bc5d188dc4650ab.js +1 -0
  498. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-0bc5d188dc4650ab.js +1 -0
  499. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-0bc5d188dc4650ab.js +1 -0
  500. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-0bc5d188dc4650ab.js +1 -0
  501. package/.next-prod/static/css/ec2765469545dfce.css +1 -0
  502. package/.next-prod/static/qoIca6xp2OKAJtDEvMaXC/_buildManifest.js +1 -0
  503. package/.next-prod/trace +14 -14
  504. package/.next-prod/trace-build +1 -1
  505. package/.next-prod/types/app/api/session/user-messages/route.ts +353 -0
  506. package/.next-prod/types/routes.d.ts +2 -1
  507. package/.next-prod/types/validator.ts +9 -0
  508. package/dist/{cache-GIQJA4HL.mjs → cache-VBRI47HG.mjs} +28 -0
  509. package/dist/chunk-UG6WUXIQ.mjs +2907 -0
  510. package/dist/scheduledTasks.mjs +30 -4
  511. package/dist/wsServer.mjs +20 -2807
  512. package/package.json +1 -1
  513. package/public/html-lib/markdown.css +114 -70
  514. package/public/html-lib/markdown.js +12 -12
  515. package/public/tree-sitter/tree-sitter-lean.wasm +0 -0
  516. package/scripts/copy-tree-sitter-wasms.mjs +33 -3
  517. package/skills/cg/SKILL.md +140 -14
  518. package/.next-prod/server/chunks/2540.js +0 -1
  519. package/.next-prod/static/ZqxwSTxy2HJcALhnBemS7/_buildManifest.js +0 -1
  520. package/.next-prod/static/chunks/6024-31a42934bf55e9e9.js +0 -32
  521. package/.next-prod/static/chunks/7184-2a5621de437121a2.js +0 -17
  522. package/.next-prod/static/chunks/9092-f7267cbb4deb6fd5.js +0 -716
  523. package/.next-prod/static/chunks/app/_global-error/page-891e1a9c2b8144f7.js +0 -1
  524. package/.next-prod/static/chunks/app/api/agent/test/route-891e1a9c2b8144f7.js +0 -1
  525. package/.next-prod/static/chunks/app/api/bash/route-891e1a9c2b8144f7.js +0 -1
  526. package/.next-prod/static/chunks/app/api/chat/codex/route-891e1a9c2b8144f7.js +0 -1
  527. package/.next-prod/static/chunks/app/api/chat/deepseek/route-891e1a9c2b8144f7.js +0 -1
  528. package/.next-prod/static/chunks/app/api/chat/glm/route-891e1a9c2b8144f7.js +0 -1
  529. package/.next-prod/static/chunks/app/api/chat/kimi/route-891e1a9c2b8144f7.js +0 -1
  530. package/.next-prod/static/chunks/app/api/chat/ollama/route-891e1a9c2b8144f7.js +0 -1
  531. package/.next-prod/static/chunks/app/api/chat/route-891e1a9c2b8144f7.js +0 -1
  532. package/.next-prod/static/chunks/app/api/chat/stop/route-891e1a9c2b8144f7.js +0 -1
  533. package/.next-prod/static/chunks/app/api/claude-stats/route-891e1a9c2b8144f7.js +0 -1
  534. package/.next-prod/static/chunks/app/api/commands/route-891e1a9c2b8144f7.js +0 -1
  535. package/.next-prod/static/chunks/app/api/comments/route-891e1a9c2b8144f7.js +0 -1
  536. package/.next-prod/static/chunks/app/api/db/columns/route-891e1a9c2b8144f7.js +0 -1
  537. package/.next-prod/static/chunks/app/api/db/connect/route-891e1a9c2b8144f7.js +0 -1
  538. package/.next-prod/static/chunks/app/api/db/disconnect/route-891e1a9c2b8144f7.js +0 -1
  539. package/.next-prod/static/chunks/app/api/db/export/route-891e1a9c2b8144f7.js +0 -1
  540. package/.next-prod/static/chunks/app/api/db/query/route-891e1a9c2b8144f7.js +0 -1
  541. package/.next-prod/static/chunks/app/api/db/schemas/route-891e1a9c2b8144f7.js +0 -1
  542. package/.next-prod/static/chunks/app/api/deepseek/balance/route-891e1a9c2b8144f7.js +0 -1
  543. package/.next-prod/static/chunks/app/api/deepseek/credentials/route-891e1a9c2b8144f7.js +0 -1
  544. package/.next-prod/static/chunks/app/api/deepseek/models/route-891e1a9c2b8144f7.js +0 -1
  545. package/.next-prod/static/chunks/app/api/dev/spans/route-891e1a9c2b8144f7.js +0 -1
  546. package/.next-prod/static/chunks/app/api/extension/version/route-891e1a9c2b8144f7.js +0 -1
  547. package/.next-prod/static/chunks/app/api/file/route-891e1a9c2b8144f7.js +0 -1
  548. package/.next-prod/static/chunks/app/api/files/blame/route-891e1a9c2b8144f7.js +0 -1
  549. package/.next-prod/static/chunks/app/api/files/clipboard/route-891e1a9c2b8144f7.js +0 -1
  550. package/.next-prod/static/chunks/app/api/files/copy/route-891e1a9c2b8144f7.js +0 -1
  551. package/.next-prod/static/chunks/app/api/files/delete/route-891e1a9c2b8144f7.js +0 -1
  552. package/.next-prod/static/chunks/app/api/files/expanded/route-891e1a9c2b8144f7.js +0 -1
  553. package/.next-prod/static/chunks/app/api/files/index/route-891e1a9c2b8144f7.js +0 -1
  554. package/.next-prod/static/chunks/app/api/files/init/route-891e1a9c2b8144f7.js +0 -1
  555. package/.next-prod/static/chunks/app/api/files/paste/route-891e1a9c2b8144f7.js +0 -1
  556. package/.next-prod/static/chunks/app/api/files/read/route-891e1a9c2b8144f7.js +0 -1
  557. package/.next-prod/static/chunks/app/api/files/readdir/route-891e1a9c2b8144f7.js +0 -1
  558. package/.next-prod/static/chunks/app/api/files/recent/route-891e1a9c2b8144f7.js +0 -1
  559. package/.next-prod/static/chunks/app/api/files/save/route-891e1a9c2b8144f7.js +0 -1
  560. package/.next-prod/static/chunks/app/api/files/search/route-891e1a9c2b8144f7.js +0 -1
  561. package/.next-prod/static/chunks/app/api/files/stat/route-891e1a9c2b8144f7.js +0 -1
  562. package/.next-prod/static/chunks/app/api/files/text/route-891e1a9c2b8144f7.js +0 -1
  563. package/.next-prod/static/chunks/app/api/git/blob/route-891e1a9c2b8144f7.js +0 -1
  564. package/.next-prod/static/chunks/app/api/git/branch-diff/route-891e1a9c2b8144f7.js +0 -1
  565. package/.next-prod/static/chunks/app/api/git/branches/route-891e1a9c2b8144f7.js +0 -1
  566. package/.next-prod/static/chunks/app/api/git/commit-diff/route-891e1a9c2b8144f7.js +0 -1
  567. package/.next-prod/static/chunks/app/api/git/commits/route-891e1a9c2b8144f7.js +0 -1
  568. package/.next-prod/static/chunks/app/api/git/current-branch/route-891e1a9c2b8144f7.js +0 -1
  569. package/.next-prod/static/chunks/app/api/git/diff/route-891e1a9c2b8144f7.js +0 -1
  570. package/.next-prod/static/chunks/app/api/git/discard/route-891e1a9c2b8144f7.js +0 -1
  571. package/.next-prod/static/chunks/app/api/git/stage/route-891e1a9c2b8144f7.js +0 -1
  572. package/.next-prod/static/chunks/app/api/git/status/route-891e1a9c2b8144f7.js +0 -1
  573. package/.next-prod/static/chunks/app/api/git/unstage/route-891e1a9c2b8144f7.js +0 -1
  574. package/.next-prod/static/chunks/app/api/git/worktree/route-891e1a9c2b8144f7.js +0 -1
  575. package/.next-prod/static/chunks/app/api/glm/credentials/route-891e1a9c2b8144f7.js +0 -1
  576. package/.next-prod/static/chunks/app/api/glm/models/route-891e1a9c2b8144f7.js +0 -1
  577. package/.next-prod/static/chunks/app/api/glm/usage/route-891e1a9c2b8144f7.js +0 -1
  578. package/.next-prod/static/chunks/app/api/global-state/route-891e1a9c2b8144f7.js +0 -1
  579. package/.next-prod/static/chunks/app/api/health/route-891e1a9c2b8144f7.js +0 -1
  580. package/.next-prod/static/chunks/app/api/html-apps/[id]/route-891e1a9c2b8144f7.js +0 -1
  581. package/.next-prod/static/chunks/app/api/html-apps/route-891e1a9c2b8144f7.js +0 -1
  582. package/.next-prod/static/chunks/app/api/kimi/credentials/route-891e1a9c2b8144f7.js +0 -1
  583. package/.next-prod/static/chunks/app/api/kimi/models/route-891e1a9c2b8144f7.js +0 -1
  584. package/.next-prod/static/chunks/app/api/kimi/usage/route-891e1a9c2b8144f7.js +0 -1
  585. package/.next-prod/static/chunks/app/api/lsp/definition/route-891e1a9c2b8144f7.js +0 -1
  586. package/.next-prod/static/chunks/app/api/lsp/hover/route-891e1a9c2b8144f7.js +0 -1
  587. package/.next-prod/static/chunks/app/api/lsp/references/route-891e1a9c2b8144f7.js +0 -1
  588. package/.next-prod/static/chunks/app/api/lsp/status/route-891e1a9c2b8144f7.js +0 -1
  589. package/.next-prod/static/chunks/app/api/lsp/warmup/route-891e1a9c2b8144f7.js +0 -1
  590. package/.next-prod/static/chunks/app/api/mysql/columns/route-891e1a9c2b8144f7.js +0 -1
  591. package/.next-prod/static/chunks/app/api/mysql/connect/route-891e1a9c2b8144f7.js +0 -1
  592. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-891e1a9c2b8144f7.js +0 -1
  593. package/.next-prod/static/chunks/app/api/mysql/export/route-891e1a9c2b8144f7.js +0 -1
  594. package/.next-prod/static/chunks/app/api/mysql/query/route-891e1a9c2b8144f7.js +0 -1
  595. package/.next-prod/static/chunks/app/api/mysql/schemas/route-891e1a9c2b8144f7.js +0 -1
  596. package/.next-prod/static/chunks/app/api/neo4j/connect/route-891e1a9c2b8144f7.js +0 -1
  597. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-891e1a9c2b8144f7.js +0 -1
  598. package/.next-prod/static/chunks/app/api/neo4j/query/route-891e1a9c2b8144f7.js +0 -1
  599. package/.next-prod/static/chunks/app/api/neo4j/schema/route-891e1a9c2b8144f7.js +0 -1
  600. package/.next-prod/static/chunks/app/api/note/route-891e1a9c2b8144f7.js +0 -1
  601. package/.next-prod/static/chunks/app/api/ollama/config/route-891e1a9c2b8144f7.js +0 -1
  602. package/.next-prod/static/chunks/app/api/ollama/models/route-891e1a9c2b8144f7.js +0 -1
  603. package/.next-prod/static/chunks/app/api/ollama/start/route-891e1a9c2b8144f7.js +0 -1
  604. package/.next-prod/static/chunks/app/api/open-cursor/route-891e1a9c2b8144f7.js +0 -1
  605. package/.next-prod/static/chunks/app/api/open-vscode/route-891e1a9c2b8144f7.js +0 -1
  606. package/.next-prod/static/chunks/app/api/pick-folder/route-891e1a9c2b8144f7.js +0 -1
  607. package/.next-prod/static/chunks/app/api/pinned-sessions/route-891e1a9c2b8144f7.js +0 -1
  608. package/.next-prod/static/chunks/app/api/project-settings/route-891e1a9c2b8144f7.js +0 -1
  609. package/.next-prod/static/chunks/app/api/project-state/route-891e1a9c2b8144f7.js +0 -1
  610. package/.next-prod/static/chunks/app/api/projectGraph/affected/route-891e1a9c2b8144f7.js +0 -1
  611. package/.next-prod/static/chunks/app/api/projectGraph/callees/route-891e1a9c2b8144f7.js +0 -1
  612. package/.next-prod/static/chunks/app/api/projectGraph/callers/route-891e1a9c2b8144f7.js +0 -1
  613. package/.next-prod/static/chunks/app/api/projectGraph/coedit/route-891e1a9c2b8144f7.js +0 -1
  614. package/.next-prod/static/chunks/app/api/projectGraph/context/route-891e1a9c2b8144f7.js +0 -1
  615. package/.next-prod/static/chunks/app/api/projectGraph/file/route-891e1a9c2b8144f7.js +0 -1
  616. package/.next-prod/static/chunks/app/api/projectGraph/file-functions/route-891e1a9c2b8144f7.js +0 -1
  617. package/.next-prod/static/chunks/app/api/projectGraph/impact/route-891e1a9c2b8144f7.js +0 -1
  618. package/.next-prod/static/chunks/app/api/projectGraph/related/route-891e1a9c2b8144f7.js +0 -1
  619. package/.next-prod/static/chunks/app/api/projectGraph/risk/route-891e1a9c2b8144f7.js +0 -1
  620. package/.next-prod/static/chunks/app/api/projectGraph/search/route-891e1a9c2b8144f7.js +0 -1
  621. package/.next-prod/static/chunks/app/api/projects/route-891e1a9c2b8144f7.js +0 -1
  622. package/.next-prod/static/chunks/app/api/prompts/config/route-891e1a9c2b8144f7.js +0 -1
  623. package/.next-prod/static/chunks/app/api/push/public-key/route-891e1a9c2b8144f7.js +0 -1
  624. package/.next-prod/static/chunks/app/api/push/subscribe/route-891e1a9c2b8144f7.js +0 -1
  625. package/.next-prod/static/chunks/app/api/push/unsubscribe/route-891e1a9c2b8144f7.js +0 -1
  626. package/.next-prod/static/chunks/app/api/redis/command/route-891e1a9c2b8144f7.js +0 -1
  627. package/.next-prod/static/chunks/app/api/redis/connect/route-891e1a9c2b8144f7.js +0 -1
  628. package/.next-prod/static/chunks/app/api/redis/delete/route-891e1a9c2b8144f7.js +0 -1
  629. package/.next-prod/static/chunks/app/api/redis/disconnect/route-891e1a9c2b8144f7.js +0 -1
  630. package/.next-prod/static/chunks/app/api/redis/get/route-891e1a9c2b8144f7.js +0 -1
  631. package/.next-prod/static/chunks/app/api/redis/keys/route-891e1a9c2b8144f7.js +0 -1
  632. package/.next-prod/static/chunks/app/api/redis/set/route-891e1a9c2b8144f7.js +0 -1
  633. package/.next-prod/static/chunks/app/api/restart/route-891e1a9c2b8144f7.js +0 -1
  634. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-891e1a9c2b8144f7.js +0 -1
  635. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-891e1a9c2b8144f7.js +0 -1
  636. package/.next-prod/static/chunks/app/api/review/[id]/route-891e1a9c2b8144f7.js +0 -1
  637. package/.next-prod/static/chunks/app/api/review/identify/route-891e1a9c2b8144f7.js +0 -1
  638. package/.next-prod/static/chunks/app/api/review/order/route-891e1a9c2b8144f7.js +0 -1
  639. package/.next-prod/static/chunks/app/api/review/route-891e1a9c2b8144f7.js +0 -1
  640. package/.next-prod/static/chunks/app/api/review/share-info/route-891e1a9c2b8144f7.js +0 -1
  641. package/.next-prod/static/chunks/app/api/review/users/route-891e1a9c2b8144f7.js +0 -1
  642. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-891e1a9c2b8144f7.js +0 -1
  643. package/.next-prod/static/chunks/app/api/services/config/route-891e1a9c2b8144f7.js +0 -1
  644. package/.next-prod/static/chunks/app/api/services/scripts/route-891e1a9c2b8144f7.js +0 -1
  645. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-891e1a9c2b8144f7.js +0 -1
  646. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-891e1a9c2b8144f7.js +0 -1
  647. package/.next-prod/static/chunks/app/api/session-by-path/route-891e1a9c2b8144f7.js +0 -1
  648. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-891e1a9c2b8144f7.js +0 -1
  649. package/.next-prod/static/chunks/app/api/sessions/projects/route-891e1a9c2b8144f7.js +0 -1
  650. package/.next-prod/static/chunks/app/api/sessions/route-891e1a9c2b8144f7.js +0 -1
  651. package/.next-prod/static/chunks/app/api/settings/route-891e1a9c2b8144f7.js +0 -1
  652. package/.next-prod/static/chunks/app/api/shutdown/route-891e1a9c2b8144f7.js +0 -1
  653. package/.next-prod/static/chunks/app/api/skills/[id]/route-891e1a9c2b8144f7.js +0 -1
  654. package/.next-prod/static/chunks/app/api/skills/content/route-891e1a9c2b8144f7.js +0 -1
  655. package/.next-prod/static/chunks/app/api/skills/route-891e1a9c2b8144f7.js +0 -1
  656. package/.next-prod/static/chunks/app/api/snapshots/blob/route-891e1a9c2b8144f7.js +0 -1
  657. package/.next-prod/static/chunks/app/api/snapshots/diff/route-891e1a9c2b8144f7.js +0 -1
  658. package/.next-prod/static/chunks/app/api/snapshots/route-891e1a9c2b8144f7.js +0 -1
  659. package/.next-prod/static/chunks/app/api/terminal/aliases/route-891e1a9c2b8144f7.js +0 -1
  660. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-891e1a9c2b8144f7.js +0 -1
  661. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-891e1a9c2b8144f7.js +0 -1
  662. package/.next-prod/static/chunks/app/api/terminal/env/route-891e1a9c2b8144f7.js +0 -1
  663. package/.next-prod/static/chunks/app/api/terminal/history/route-891e1a9c2b8144f7.js +0 -1
  664. package/.next-prod/static/chunks/app/api/update/route-891e1a9c2b8144f7.js +0 -1
  665. package/.next-prod/static/chunks/app/api/update-state/route-891e1a9c2b8144f7.js +0 -1
  666. package/.next-prod/static/chunks/app/api/version/route-891e1a9c2b8144f7.js +0 -1
  667. package/.next-prod/static/chunks/app/apps/[...path]/route-891e1a9c2b8144f7.js +0 -1
  668. package/.next-prod/static/chunks/app/manifest.webmanifest/route-891e1a9c2b8144f7.js +0 -1
  669. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-891e1a9c2b8144f7.js +0 -1
  670. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-891e1a9c2b8144f7.js +0 -1
  671. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-891e1a9c2b8144f7.js +0 -1
  672. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-891e1a9c2b8144f7.js +0 -1
  673. package/.next-prod/static/css/ea27ccfe01ce807c.css +0 -1
  674. /package/.next-prod/static/{ZqxwSTxy2HJcALhnBemS7 → qoIca6xp2OKAJtDEvMaXC}/_ssgManifest.js +0 -0
package/dist/wsServer.mjs CHANGED
@@ -36,6 +36,10 @@ import {
36
36
  ValidationError,
37
37
  WSError
38
38
  } from "./chunk-4EU4KZIO.mjs";
39
+ import {
40
+ registerWatcherSubscriber,
41
+ subscribeBuildProgress
42
+ } from "./chunk-UG6WUXIQ.mjs";
39
43
  import "./chunk-7P6ASYW6.mjs";
40
44
 
41
45
  // src/lib/wsServer.ts
@@ -71,10 +75,10 @@ var fromWebSocket = (ws, proto) => Effect_exports.gen(function* () {
71
75
  ws.on("error", onError);
72
76
  return { onMessage, onClose, onError };
73
77
  }),
74
- (handlers2) => Effect_exports.sync(() => {
75
- ws.off("message", handlers2.onMessage);
76
- ws.off("close", handlers2.onClose);
77
- ws.off("error", handlers2.onError);
78
+ (handlers) => Effect_exports.sync(() => {
79
+ ws.off("message", handlers.onMessage);
80
+ ws.off("close", handlers.onClose);
81
+ ws.off("error", handlers.onError);
78
82
  })
79
83
  );
80
84
  const send = (msg) => Effect_exports.try({
@@ -423,33 +427,6 @@ var g_watch = globalThis;
423
427
  var fileWatcher = g_watch.__cockpitFileWatcher ?? (g_watch.__cockpitFileWatcher = new FileWatcherManager());
424
428
  var reviewWatcher = g_watch.__cockpitReviewWatcher ?? (g_watch.__cockpitReviewWatcher = new ReviewWatcher());
425
429
 
426
- // packages/feature/explorer/src/server/codeMap/projectGraph/buildProgress.ts
427
- var g = globalThis;
428
- var listeners = g.__cockpitGraphProgressListeners ?? (g.__cockpitGraphProgressListeners = /* @__PURE__ */ new Map());
429
- var lastFrame = g.__cockpitGraphProgressLastFrame ?? (g.__cockpitGraphProgressLastFrame = /* @__PURE__ */ new Map());
430
- var lastEmitAt = g.__cockpitGraphProgressLastEmitAt ?? (g.__cockpitGraphProgressLastEmitAt = /* @__PURE__ */ new Map());
431
- function subscribeBuildProgress(cwd, fn) {
432
- let set = listeners.get(cwd);
433
- if (!set) {
434
- set = /* @__PURE__ */ new Set();
435
- listeners.set(cwd, set);
436
- }
437
- set.add(fn);
438
- const snapshot = lastFrame.get(cwd);
439
- if (snapshot) {
440
- try {
441
- fn(snapshot);
442
- } catch {
443
- }
444
- }
445
- return () => {
446
- const s = listeners.get(cwd);
447
- if (!s) return;
448
- s.delete(fn);
449
- if (s.size === 0) listeners.delete(cwd);
450
- };
451
- }
452
-
453
430
  // src/lib/effect/fileWatchHandler.ts
454
431
  var HEARTBEAT = Schedule_exports.spaced("30 seconds");
455
432
  var fileEvents = (cwd) => Stream_exports.unwrapScoped(
@@ -1412,2788 +1389,24 @@ var runSessionStreamHandler = (ws, sessionId) => {
1412
1389
  });
1413
1390
  };
1414
1391
 
1415
- // packages/feature/explorer/src/server/codeMap/projectGraph/codeIndex.ts
1416
- import { promises as fs4 } from "fs";
1417
- import path6 from "path";
1418
- import { exec as exec2 } from "child_process";
1419
- import { promisify as promisify2 } from "util";
1420
-
1421
- // packages/feature/explorer/src/server/codeMap/projectGraph/buildGraph.ts
1422
- import { exec } from "child_process";
1423
- import { promises as fs } from "fs";
1424
- import path from "path";
1425
- import { promisify } from "util";
1426
-
1427
- // packages/feature/explorer/src/server/codeMap/handlers/registry.ts
1428
- var handlers = /* @__PURE__ */ new Map();
1429
- function registerHandler(handler) {
1430
- handlers.set(handler.grammarId, handler);
1431
- }
1432
-
1433
- // packages/feature/explorer/src/server/codeMap/projectGraph/buildGraph.ts
1434
- var execAsync = promisify(exec);
1435
- var RESOLUTION_EXT = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
1436
- var STRIPPABLE_EXT = [".js", ".jsx", ".mjs", ".cjs"];
1437
- function findFileForBase(baseAbs, cwd, fileSet) {
1438
- let baseRel = path.relative(cwd, baseAbs);
1439
- if (baseRel.startsWith("..")) return null;
1440
- for (const ext of STRIPPABLE_EXT) {
1441
- if (baseRel.endsWith(ext)) {
1442
- baseRel = baseRel.slice(0, -ext.length);
1443
- break;
1444
- }
1445
- }
1446
- if (fileSet.has(baseRel)) return baseRel;
1447
- for (const ext of RESOLUTION_EXT) {
1448
- const c = baseRel + ext;
1449
- if (fileSet.has(c)) return c;
1450
- }
1451
- for (const ext of RESOLUTION_EXT) {
1452
- const c = path.join(baseRel, "index" + ext);
1453
- if (fileSet.has(c)) return c;
1454
- }
1455
- return null;
1456
- }
1457
- function fileInScope(file, scope) {
1458
- return scope === "" || file === scope || file.startsWith(scope + "/");
1459
- }
1460
- async function loadWorkspaces(cwd, fileSet) {
1461
- const patterns = await readWorkspacePatterns(cwd);
1462
- if (patterns.length === 0) return /* @__PURE__ */ new Map();
1463
- let pkgJsonPaths = [];
1464
- try {
1465
- const { stdout } = await execAsync(
1466
- "git -c core.quotePath=false ls-files --cached --others --exclude-standard",
1467
- { cwd, maxBuffer: 50 * 1024 * 1024 }
1468
- );
1469
- pkgJsonPaths = stdout.split("\n").map((p) => p.trim()).filter((p) => p.endsWith("/package.json") && !p.includes("node_modules/"));
1470
- } catch {
1471
- return /* @__PURE__ */ new Map();
1472
- }
1473
- const matched = pkgJsonPaths.filter((p) => {
1474
- const dir = p.slice(0, -"/package.json".length);
1475
- return patterns.some((pat) => globMatchesDir(dir, pat));
1476
- });
1477
- const result = /* @__PURE__ */ new Map();
1478
- for (const rel of matched) {
1479
- let pkg;
1480
- try {
1481
- pkg = JSON.parse(await fs.readFile(path.join(cwd, rel), "utf8"));
1482
- } catch {
1483
- continue;
1484
- }
1485
- if (typeof pkg.name !== "string") continue;
1486
- const dir = path.dirname(rel);
1487
- const entryFile = resolveWorkspaceEntry(dir, pkg, fileSet);
1488
- result.set(pkg.name, { name: pkg.name, dir, entryFile });
1489
- }
1490
- return result;
1491
- }
1492
- async function readWorkspacePatterns(cwd) {
1493
- try {
1494
- const yaml = await fs.readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8");
1495
- return parsePnpmWorkspaces(yaml);
1496
- } catch {
1497
- }
1498
- try {
1499
- const pkg = JSON.parse(await fs.readFile(path.join(cwd, "package.json"), "utf8"));
1500
- const ws = pkg?.workspaces;
1501
- if (Array.isArray(ws)) return ws.filter((s) => typeof s === "string");
1502
- if (ws && Array.isArray(ws.packages)) {
1503
- return ws.packages.filter((s) => typeof s === "string");
1504
- }
1505
- } catch {
1506
- }
1507
- return [];
1508
- }
1509
- function parsePnpmWorkspaces(yaml) {
1510
- const out = [];
1511
- let inPackages = false;
1512
- for (const rawLine of yaml.split("\n")) {
1513
- const line = rawLine.replace(/#.*$/, "");
1514
- if (/^packages\s*:/.test(line)) {
1515
- inPackages = true;
1516
- continue;
1517
- }
1518
- if (!inPackages) continue;
1519
- const itemMatch = line.match(/^\s*-\s*['"]?([^'"#\s]+)['"]?\s*$/);
1520
- if (itemMatch) {
1521
- out.push(itemMatch[1]);
1522
- } else if (/^\S/.test(line)) {
1523
- inPackages = false;
1524
- }
1525
- }
1526
- return out;
1527
- }
1528
- function globMatchesDir(dir, pattern) {
1529
- const re = new RegExp(
1530
- "^" + pattern.replace(/\\/g, "/").replace(/[.+^${}()|[\]]/g, "\\$&").replace(/\*\*/g, "___DOUBLESTAR___").replace(/\*/g, "[^/]*").replace(/___DOUBLESTAR___/g, ".*") + "$"
1531
- );
1532
- return re.test(dir);
1533
- }
1534
- function resolveWorkspaceEntry(pkgDir, pkg, fileSet) {
1535
- const tryRelToPkg = (subpath) => {
1536
- const cleaned = subpath.replace(/^\.\//, "");
1537
- return findFileRelativeToProject(path.posix.join(pkgDir, cleaned), fileSet);
1538
- };
1539
- const exp = pkg.exports;
1540
- let exportEntry;
1541
- if (typeof exp === "string") {
1542
- exportEntry = exp;
1543
- } else if (exp && typeof exp === "object" && exp["."]) {
1544
- const dot = exp["."];
1545
- if (typeof dot === "string") exportEntry = dot;
1546
- else if (dot && typeof dot === "object") {
1547
- exportEntry = dot["types"] ?? dot["import"] ?? dot["default"] ?? dot["require"];
1548
- }
1549
- }
1550
- if (typeof exportEntry === "string") {
1551
- const r = tryRelToPkg(exportEntry);
1552
- if (r) return r;
1553
- }
1554
- if (typeof pkg.main === "string") {
1555
- const r = tryRelToPkg(pkg.main);
1556
- if (r) return r;
1557
- }
1558
- for (const conv of ["src/index.ts", "src/index.tsx", "index.ts", "index.tsx", "src/index.js", "index.js"]) {
1559
- if (fileSet.has(path.posix.join(pkgDir, conv))) {
1560
- return path.posix.join(pkgDir, conv);
1561
- }
1562
- }
1563
- return null;
1564
- }
1565
- function findFileRelativeToProject(baseRel, fileSet) {
1566
- if (baseRel.startsWith("..") || baseRel.startsWith("/")) return null;
1567
- for (const ext of STRIPPABLE_EXT) {
1568
- if (baseRel.endsWith(ext)) {
1569
- baseRel = baseRel.slice(0, -ext.length);
1570
- break;
1571
- }
1572
- }
1573
- if (fileSet.has(baseRel)) return baseRel;
1574
- for (const ext of RESOLUTION_EXT) {
1575
- const c = baseRel + ext;
1576
- if (fileSet.has(c)) return c;
1577
- }
1578
- for (const ext of RESOLUTION_EXT) {
1579
- const c = path.posix.join(baseRel, "index" + ext);
1580
- if (fileSet.has(c)) return c;
1581
- }
1582
- return null;
1583
- }
1584
- async function parseTsconfigAliases(filePath, cwd) {
1585
- const aliases = /* @__PURE__ */ new Map();
1586
- let json;
1587
- try {
1588
- const raw = await fs.readFile(filePath, "utf8");
1589
- const stripped = raw.replace(/^\s*\/\/.*$/gm, "");
1590
- json = JSON.parse(stripped);
1591
- } catch {
1592
- return aliases;
1593
- }
1594
- const baseUrl = json?.compilerOptions?.baseUrl ?? ".";
1595
- const pathsMap = json?.compilerOptions?.paths ?? {};
1596
- const absBase = path.resolve(path.dirname(filePath), baseUrl);
1597
- const relBase = path.relative(cwd, absBase) || ".";
1598
- for (const [key, vals] of Object.entries(pathsMap)) {
1599
- if (!Array.isArray(vals) || vals.length === 0) continue;
1600
- const cleanKey = key.replace(/\/\*$/, "");
1601
- const cleanVal = vals[0].replace(/\/\*$/, "");
1602
- aliases.set(cleanKey, path.join(relBase, cleanVal));
1603
- }
1604
- return aliases;
1605
- }
1606
- async function loadTsconfigs(cwd) {
1607
- const scopes = [];
1608
- let tsconfigPaths = [];
1609
- try {
1610
- const { stdout } = await execAsync(
1611
- "git -c core.quotePath=false ls-files --cached --others --exclude-standard",
1612
- { cwd, maxBuffer: 50 * 1024 * 1024 }
1613
- );
1614
- tsconfigPaths = stdout.split("\n").map((p) => p.trim()).filter((p) => /(^|\/)tsconfig[^/]*\.json$/.test(p) && !p.includes("node_modules/"));
1615
- } catch {
1616
- try {
1617
- await fs.access(path.join(cwd, "tsconfig.json"));
1618
- tsconfigPaths = ["tsconfig.json"];
1619
- } catch {
1620
- }
1621
- }
1622
- for (const rel of tsconfigPaths) {
1623
- const aliases = await parseTsconfigAliases(path.join(cwd, rel), cwd);
1624
- if (aliases.size === 0) continue;
1625
- const scope = path.dirname(rel);
1626
- scopes.push({
1627
- scope: scope === "." ? "" : scope,
1628
- aliases,
1629
- sortedAliases: sortAliasesByLength(aliases)
1630
- });
1631
- }
1632
- let root = scopes.find((s) => s.scope === "");
1633
- if (!root) {
1634
- const aliases = /* @__PURE__ */ new Map();
1635
- root = { scope: "", aliases, sortedAliases: [] };
1636
- scopes.push(root);
1637
- }
1638
- if (!root.aliases.has("@")) {
1639
- root.aliases.set("@", "./src");
1640
- root.sortedAliases = sortAliasesByLength(root.aliases);
1641
- }
1642
- return scopes.sort((a, b) => b.scope.length - a.scope.length);
1643
- }
1644
- function sortAliasesByLength(aliases) {
1645
- return [...aliases.entries()].sort(([a], [b]) => b.length - a.length);
1646
- }
1647
-
1648
- // packages/feature/explorer/src/server/codeMap/handlers/typescript.ts
1649
- import path2 from "path";
1650
-
1651
- // packages/feature/explorer/src/server/codeMap/extractSymbols.ts
1652
- function hashText(s) {
1653
- let h1 = 3735928559;
1654
- let h2 = 1103547991;
1655
- for (let i = 0; i < s.length; i++) {
1656
- const ch = s.charCodeAt(i);
1657
- h1 = Math.imul(h1 ^ ch, 2654435761);
1658
- h2 = Math.imul(h2 ^ ch, 1597334677);
1659
- }
1660
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
1661
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
1662
- return (4294967296 * (2097151 & h2) + (h1 >>> 0) >>> 0).toString(16);
1663
- }
1664
- function normalizeForHash(s) {
1665
- return s.replace(/\s+/g, " ").trim();
1666
- }
1667
- function qualify(parent, name) {
1668
- return parent ? `${parent}>${name}` : name;
1669
- }
1670
- function nameOf(node) {
1671
- const named = node.childForFieldName("name");
1672
- if (named) return named.text;
1673
- for (let i = 0; i < node.namedChildCount; i++) {
1674
- const c = node.namedChild(i);
1675
- if (c && (c.type === "identifier" || c.type === "type_identifier" || c.type === "property_identifier")) {
1676
- return c.text;
1677
- }
1678
- }
1679
- return "<anonymous>";
1680
- }
1681
- function makeSymbol(node, name, kind, parentQname, children = [], params) {
1682
- return {
1683
- qualifiedName: qualify(parentQname, name),
1684
- name,
1685
- kind,
1686
- // tree-sitter rows are 0-based; we expose 1-based for UI alignment.
1687
- startLine: node.startPosition.row + 1,
1688
- endLine: node.endPosition.row + 1,
1689
- contentHash: hashText(normalizeForHash(node.text)),
1690
- children,
1691
- params
1692
- };
1693
- }
1694
- function paramText(p) {
1695
- switch (p.type) {
1696
- case "required_parameter":
1697
- case "optional_parameter": {
1698
- const pat = p.childForFieldName("pattern");
1699
- return pat ? paramText(pat) : p.text;
1700
- }
1701
- case "assignment_pattern": {
1702
- const left = p.childForFieldName("left");
1703
- return left ? paramText(left) : p.text;
1704
- }
1705
- case "default_parameter":
1706
- case "typed_default_parameter": {
1707
- const name = p.childForFieldName("name");
1708
- return name ? name.text : p.text;
1709
- }
1710
- case "typed_parameter": {
1711
- for (let i = 0; i < p.namedChildCount; i++) {
1712
- const c = p.namedChild(i);
1713
- if (c?.type === "identifier") return c.text;
1714
- }
1715
- return p.text;
1716
- }
1717
- // Identifiers, splat patterns, destructuring patterns — text as-is.
1718
- default:
1719
- return p.text;
1720
- }
1721
- }
1722
- function extractParams(fnNode) {
1723
- const single = fnNode.childForFieldName("parameter");
1724
- if (single) return [single.text];
1725
- const params = fnNode.childForFieldName("parameters");
1726
- if (!params) return void 0;
1727
- const out = [];
1728
- for (let i = 0; i < params.namedChildCount; i++) {
1729
- const p = params.namedChild(i);
1730
- if (!p) continue;
1731
- out.push(paramText(p));
1732
- }
1733
- return out;
1734
- }
1735
- function extractClassMembers(body, parentQname) {
1736
- if (!body) return [];
1737
- const out = [];
1738
- for (let i = 0; i < body.namedChildCount; i++) {
1739
- const m = body.namedChild(i);
1740
- if (!m) continue;
1741
- if (m.type === "method_definition") {
1742
- out.push(
1743
- makeSymbol(m, nameOf(m), "method", parentQname, [], extractParams(m))
1744
- );
1745
- } else if (m.type === "public_field_definition") {
1746
- const value = m.childForFieldName("value");
1747
- if (value && (value.type === "arrow_function" || value.type === "function_expression")) {
1748
- out.push(
1749
- makeSymbol(m, nameOf(m), "method", parentQname, [], extractParams(value))
1750
- );
1751
- }
1752
- }
1753
- }
1754
- return out;
1755
- }
1756
- function extractFromLexical(decl, parentQname, _isExported) {
1757
- const out = [];
1758
- for (let i = 0; i < decl.namedChildCount; i++) {
1759
- const declarator = decl.namedChild(i);
1760
- if (!declarator || declarator.type !== "variable_declarator") continue;
1761
- const nameNode = declarator.childForFieldName("name");
1762
- const valueNode = declarator.childForFieldName("value");
1763
- if (!nameNode) continue;
1764
- const name = nameNode.text;
1765
- const isFn = valueNode && (valueNode.type === "arrow_function" || valueNode.type === "function_expression");
1766
- const params = isFn && valueNode ? extractParams(valueNode) : void 0;
1767
- out.push(
1768
- makeSymbol(
1769
- decl,
1770
- name,
1771
- isFn ? "function" : "const",
1772
- parentQname,
1773
- [],
1774
- params
1775
- )
1776
- );
1777
- if (valueNode && valueNode.type === "object" && !isFn) {
1778
- const childParent = parentQname ? `${parentQname}>${name}` : name;
1779
- for (let j = 0; j < valueNode.namedChildCount; j++) {
1780
- const prop = valueNode.namedChild(j);
1781
- if (!prop) continue;
1782
- if (prop.type === "pair") {
1783
- const keyNode = prop.childForFieldName("key");
1784
- const valNode = prop.childForFieldName("value");
1785
- if (!keyNode || !valNode) continue;
1786
- if (keyNode.type !== "property_identifier" && keyNode.type !== "identifier") {
1787
- continue;
1788
- }
1789
- if (valNode.type !== "arrow_function" && valNode.type !== "function_expression") {
1790
- continue;
1791
- }
1792
- out.push(
1793
- makeSymbol(
1794
- prop,
1795
- keyNode.text,
1796
- "method",
1797
- childParent,
1798
- [],
1799
- extractParams(valNode)
1800
- )
1801
- );
1802
- } else if (prop.type === "method_definition") {
1803
- const propName = nameOf(prop);
1804
- if (propName) {
1805
- out.push(
1806
- makeSymbol(prop, propName, "method", childParent, [], extractParams(prop))
1807
- );
1808
- }
1809
- }
1810
- }
1811
- }
1812
- }
1813
- return out;
1814
- }
1815
- function extractFromNode(node, parentQname, isExported = false) {
1816
- switch (node.type) {
1817
- case "export_statement":
1818
- case "export_default_declaration": {
1819
- const out = [];
1820
- for (let i = 0; i < node.namedChildCount; i++) {
1821
- const inner = node.namedChild(i);
1822
- if (inner) out.push(...extractFromNode(inner, parentQname, true));
1823
- }
1824
- return out;
1825
- }
1826
- case "function_declaration":
1827
- case "generator_function_declaration": {
1828
- return [
1829
- makeSymbol(node, nameOf(node), "function", parentQname, [], extractParams(node))
1830
- ];
1831
- }
1832
- case "class_declaration":
1833
- case "abstract_class_declaration": {
1834
- const className = nameOf(node);
1835
- const qname = qualify(parentQname, className);
1836
- const body = node.childForFieldName("body");
1837
- const members = extractClassMembers(body, qname);
1838
- return [makeSymbol(node, className, "class", parentQname, members)];
1839
- }
1840
- case "interface_declaration": {
1841
- return [makeSymbol(node, nameOf(node), "interface", parentQname)];
1842
- }
1843
- case "type_alias_declaration": {
1844
- return [makeSymbol(node, nameOf(node), "type", parentQname)];
1845
- }
1846
- case "enum_declaration": {
1847
- return [makeSymbol(node, nameOf(node), "enum", parentQname)];
1848
- }
1849
- case "lexical_declaration":
1850
- case "variable_declaration": {
1851
- return extractFromLexical(node, parentQname, isExported);
1852
- }
1853
- // ---- Python ------------------------------------------------------------
1854
- case "function_definition": {
1855
- return [
1856
- makeSymbol(node, nameOf(node), "function", parentQname, [], extractParams(node))
1857
- ];
1858
- }
1859
- case "class_definition": {
1860
- const className = nameOf(node);
1861
- const qname = qualify(parentQname, className);
1862
- const body = node.childForFieldName("body");
1863
- const members = extractPythonClassMembers(body, qname);
1864
- return [makeSymbol(node, className, "class", parentQname, members)];
1865
- }
1866
- case "decorated_definition": {
1867
- const inner = node.childForFieldName("definition");
1868
- if (!inner) return [];
1869
- const innerSymbols = extractFromNode(inner, parentQname, false);
1870
- return innerSymbols.map((s) => ({
1871
- ...s,
1872
- startLine: node.startPosition.row + 1,
1873
- // Re-hash from the decorated text so contentHash captures the
1874
- // decorator change too. The simplest form: hash the outer node.
1875
- contentHash: hashText(normalizeForHash(node.text))
1876
- }));
1877
- }
1878
- case "expression_statement": {
1879
- const out = [];
1880
- for (let i = 0; i < node.namedChildCount; i++) {
1881
- const c = node.namedChild(i);
1882
- if (c?.type === "assignment") {
1883
- const sym = extractPythonAssignment(node, c, parentQname);
1884
- if (sym) out.push(sym);
1885
- }
1886
- }
1887
- out.push(...extractFromCallStatement(node, parentQname));
1888
- return out;
1889
- }
1890
- default:
1891
- return [];
1892
- }
1893
- }
1894
- function extractFromCallStatement(node, parentQname) {
1895
- let call = null;
1896
- for (let i = 0; i < node.namedChildCount; i++) {
1897
- const c = node.namedChild(i);
1898
- if (!c) continue;
1899
- if (c.type === "call_expression") {
1900
- call = c;
1901
- break;
1902
- }
1903
- if (c.type === "await_expression") {
1904
- for (let j = 0; j < c.namedChildCount; j++) {
1905
- const inner = c.namedChild(j);
1906
- if (inner?.type === "call_expression") {
1907
- call = inner;
1908
- break;
1909
- }
1910
- }
1911
- break;
1912
- }
1913
- }
1914
- if (!call) return [];
1915
- const callee = call.childForFieldName("function");
1916
- const args = call.childForFieldName("arguments");
1917
- if (!callee || !args) return [];
1918
- let label = null;
1919
- const fnArgs = [];
1920
- for (let i = 0; i < args.namedChildCount; i++) {
1921
- const arg = args.namedChild(i);
1922
- if (!arg) continue;
1923
- if (label === null && (arg.type === "string" || arg.type === "template_string")) {
1924
- const t = arg.text;
1925
- label = t.length >= 2 && /^["'`]/.test(t) ? t.slice(1, -1) : t;
1926
- }
1927
- if (arg.type === "arrow_function" || arg.type === "function_expression") {
1928
- fnArgs.push(arg);
1929
- }
1930
- }
1931
- if (fnArgs.length === 0 || !label) return [];
1932
- const calleeName = leafCalleeName(callee);
1933
- const baseName = calleeName ? `${calleeName} ${label}` : label;
1934
- return fnArgs.map(
1935
- (fnArg, i) => makeSymbol(
1936
- fnArg,
1937
- fnArgs.length > 1 ? `${baseName} #${i + 1}` : baseName,
1938
- "function",
1939
- parentQname,
1940
- [],
1941
- extractParams(fnArg)
1942
- )
1943
- );
1944
- }
1945
- function extractPythonClassMembers(body, parentQname) {
1946
- if (!body) return [];
1947
- const out = [];
1948
- for (let i = 0; i < body.namedChildCount; i++) {
1949
- const m = body.namedChild(i);
1950
- if (!m) continue;
1951
- if (m.type === "function_definition") {
1952
- out.push(
1953
- makeSymbol(m, nameOf(m), "method", parentQname, [], extractParams(m))
1954
- );
1955
- } else if (m.type === "decorated_definition") {
1956
- const inner = m.childForFieldName("definition");
1957
- if (inner?.type === "function_definition") {
1958
- out.push({
1959
- ...makeSymbol(inner, nameOf(inner), "method", parentQname, [], extractParams(inner)),
1960
- startLine: m.startPosition.row + 1,
1961
- contentHash: hashText(normalizeForHash(m.text))
1962
- });
1963
- } else if (inner?.type === "class_definition") {
1964
- const innerName = nameOf(inner);
1965
- const innerQname = qualify(parentQname, innerName);
1966
- const innerBody = inner.childForFieldName("body");
1967
- const nested = extractPythonClassMembers(innerBody, innerQname);
1968
- out.push({
1969
- ...makeSymbol(inner, innerName, "class", parentQname, nested),
1970
- startLine: m.startPosition.row + 1,
1971
- contentHash: hashText(normalizeForHash(m.text))
1972
- });
1973
- }
1974
- } else if (m.type === "class_definition") {
1975
- const innerName = nameOf(m);
1976
- const innerQname = qualify(parentQname, innerName);
1977
- const innerBody = m.childForFieldName("body");
1978
- const nested = extractPythonClassMembers(innerBody, innerQname);
1979
- out.push(makeSymbol(m, innerName, "class", parentQname, nested));
1980
- }
1981
- }
1982
- return out;
1983
- }
1984
- function extractPythonAssignment(outer, assignment, parentQname) {
1985
- const lhs = assignment.childForFieldName("left");
1986
- if (!lhs || lhs.type !== "identifier") return null;
1987
- const name = lhs.text;
1988
- return {
1989
- qualifiedName: qualify(parentQname, name),
1990
- name,
1991
- kind: "const",
1992
- startLine: outer.startPosition.row + 1,
1993
- endLine: outer.endPosition.row + 1,
1994
- contentHash: hashText(normalizeForHash(outer.text)),
1995
- children: []
1996
- };
1997
- }
1998
- function leafCalleeName(node) {
1999
- if (node.type === "identifier") return node.text;
2000
- if (node.type === "member_expression") {
2001
- const prop = node.childForFieldName("property");
2002
- return prop?.text ?? "";
2003
- }
2004
- if (node.type === "call_expression") {
2005
- const fn = node.childForFieldName("function");
2006
- return fn ? leafCalleeName(fn) : "";
2007
- }
2008
- return "";
2009
- }
2010
- function extractImportHeader(rootNode) {
2011
- const headerNodes = [];
2012
- let firstLine = -1;
2013
- let lastLine = -1;
2014
- for (let i = 0; i < rootNode.namedChildCount; i++) {
2015
- const c = rootNode.namedChild(i);
2016
- if (!c) continue;
2017
- const isHeader = (
2018
- // JS/TS: `import X from 'y'`, `import 'y'`
2019
- c.type === "import_statement" || // JS/TS: `export { x } from './y'` (re-export with `source` field)
2020
- c.type === "export_statement" && c.childForFieldName("source") !== null || // Python: `from x import y` / `from .x import y`
2021
- c.type === "import_from_statement" || // Python: `import x` / `import x.y as z`
2022
- c.type === "future_import_statement"
2023
- );
2024
- if (isHeader) {
2025
- headerNodes.push(c);
2026
- if (firstLine < 0) firstLine = c.startPosition.row + 1;
2027
- lastLine = c.endPosition.row + 1;
2028
- } else if (firstLine >= 0) {
2029
- break;
2030
- }
2031
- }
2032
- if (firstLine < 0) return null;
2033
- const text = headerNodes.map((n) => n.text).join("\n");
2034
- return {
2035
- qualifiedName: "__imports__",
2036
- name: "imports",
2037
- kind: "unknown",
2038
- startLine: firstLine,
2039
- endLine: lastLine,
2040
- contentHash: hashText(normalizeForHash(text)),
2041
- children: []
2042
- };
2043
- }
2044
- function absorbLeadingComments(rootNode, symbols) {
2045
- const commentByEndLine = /* @__PURE__ */ new Map();
2046
- for (let i = 0; i < rootNode.namedChildCount; i++) {
2047
- const c = rootNode.namedChild(i);
2048
- if (!c || !c.type.endsWith("comment")) continue;
2049
- commentByEndLine.set(c.endPosition.row + 1, c);
2050
- }
2051
- if (commentByEndLine.size === 0) return;
2052
- const covered = /* @__PURE__ */ new Set();
2053
- for (const s of symbols) {
2054
- for (let i = s.startLine; i <= s.endLine; i++) covered.add(i);
2055
- }
2056
- for (const s of symbols) {
2057
- if (s.kind === "unknown") continue;
2058
- let start = s.startLine;
2059
- for (; ; ) {
2060
- const c = commentByEndLine.get(start - 1);
2061
- if (!c) break;
2062
- const cStart = c.startPosition.row + 1;
2063
- let blocked = false;
2064
- for (let i = cStart; i <= start - 1; i++) {
2065
- if (covered.has(i)) {
2066
- blocked = true;
2067
- break;
2068
- }
2069
- }
2070
- if (blocked) break;
2071
- start = cStart;
2072
- }
2073
- if (start === s.startLine) continue;
2074
- for (let i = start; i < s.startLine; i++) covered.add(i);
2075
- s.startLine = start;
2076
- }
2077
- }
2078
- function computeFillerBlocks(rootNode, existing) {
2079
- const source = rootNode.text;
2080
- const lines = source.split("\n");
2081
- const fileLineCount = lines.length;
2082
- if (fileLineCount === 0) return [];
2083
- const covered = new Uint8Array(fileLineCount + 2);
2084
- for (const s of existing) {
2085
- const lo = Math.max(1, s.startLine);
2086
- const hi = Math.min(fileLineCount, s.endLine);
2087
- for (let i = lo; i <= hi; i++) covered[i] = 1;
2088
- }
2089
- const fillers = [];
2090
- const flush = (start, end) => {
2091
- let hasContent = false;
2092
- for (let i = start; i <= end; i++) {
2093
- const ln = lines[i - 1];
2094
- if (ln && ln.trim().length > 0) {
2095
- hasContent = true;
2096
- break;
1392
+ // src/lib/codeIndexSync.ts
1393
+ var wired = false;
1394
+ function wireCodeIndexToFileWatcher() {
1395
+ if (wired) return;
1396
+ wired = true;
1397
+ registerWatcherSubscriber((cwd, onDirty) => {
1398
+ fileWatcher.subscribe(cwd, (events) => {
1399
+ if (events.some((e) => e.type === "file" || e.type === "git")) {
1400
+ onDirty();
2097
1401
  }
2098
- }
2099
- if (!hasContent) return;
2100
- const text = lines.slice(start - 1, end).join("\n");
2101
- fillers.push({
2102
- qualifiedName: `__code_${start}_${end}__`,
2103
- name: "code",
2104
- kind: "unknown",
2105
- startLine: start,
2106
- endLine: end,
2107
- contentHash: hashText(normalizeForHash(text)),
2108
- children: []
2109
1402
  });
2110
- };
2111
- let runStart = -1;
2112
- for (let i = 1; i <= fileLineCount; i++) {
2113
- if (!covered[i]) {
2114
- if (runStart < 0) runStart = i;
2115
- } else if (runStart >= 0) {
2116
- flush(runStart, i - 1);
2117
- runStart = -1;
2118
- }
2119
- }
2120
- if (runStart >= 0) flush(runStart, fileLineCount);
2121
- return fillers;
2122
- }
2123
- function extractSymbolsFromTree(rootNode) {
2124
- const out = [];
2125
- const header = extractImportHeader(rootNode);
2126
- if (header) out.push(header);
2127
- for (let i = 0; i < rootNode.namedChildCount; i++) {
2128
- const child = rootNode.namedChild(i);
2129
- if (child) out.push(...extractFromNode(child, void 0, false));
2130
- }
2131
- absorbLeadingComments(rootNode, out);
2132
- out.push(...computeFillerBlocks(rootNode, out));
2133
- dedupeQualifiedNames(out);
2134
- return out;
2135
- }
2136
- function dedupeQualifiedNames(syms) {
2137
- const seen = /* @__PURE__ */ new Map();
2138
- const walk = (arr) => {
2139
- for (const s of arr) {
2140
- const n = (seen.get(s.qualifiedName) ?? 0) + 1;
2141
- seen.set(s.qualifiedName, n);
2142
- if (n > 1) s.qualifiedName = `${s.qualifiedName}#${n}`;
2143
- walk(s.children);
2144
- }
2145
- };
2146
- walk(syms);
2147
- }
2148
-
2149
- // packages/feature/explorer/src/server/codeMap/extractCalls.ts
2150
- function extractRawCalls(root) {
2151
- const out = [];
2152
- function visit(node) {
2153
- if (node.type === "call_expression" || node.type === "call") {
2154
- const fn = node.childForFieldName("function");
2155
- const name = calleeLeafName(fn);
2156
- if (name) {
2157
- const receiverName = receiverRootName(fn);
2158
- out.push({
2159
- calleeName: name,
2160
- line: node.startPosition.row + 1,
2161
- ...receiverName ? { receiverName } : {}
2162
- });
2163
- }
2164
- } else if (node.type === "jsx_opening_element" || node.type === "jsx_self_closing_element") {
2165
- const nameNode = node.childForFieldName("name");
2166
- const name = jsxComponentName(nameNode);
2167
- if (name) out.push({ calleeName: name, line: node.startPosition.row + 1 });
2168
- }
2169
- for (let i = 0; i < node.childCount; i++) {
2170
- const c = node.child(i);
2171
- if (c) visit(c);
2172
- }
2173
- }
2174
- visit(root);
2175
- return out;
2176
- }
2177
- function receiverRootName(node) {
2178
- if (!node) return void 0;
2179
- if (node.type !== "member_expression" && node.type !== "attribute") {
2180
- return void 0;
2181
- }
2182
- let cur = node;
2183
- while (cur) {
2184
- if (cur.type === "identifier") return cur.text;
2185
- if (cur.type === "this" || cur.type === "super") return void 0;
2186
- if (cur.type === "member_expression" || cur.type === "attribute") {
2187
- cur = cur.childForFieldName("object");
2188
- continue;
2189
- }
2190
- return void 0;
2191
- }
2192
- return void 0;
2193
- }
2194
- function calleeLeafName(node) {
2195
- if (!node) return null;
2196
- if (node.type === "identifier" || node.type === "shorthand_property_identifier") {
2197
- return node.text;
2198
- }
2199
- if (node.type === "member_expression") {
2200
- const prop = node.childForFieldName("property");
2201
- return prop?.text ?? null;
2202
- }
2203
- if (node.type === "attribute") {
2204
- const prop = node.childForFieldName("attribute");
2205
- return prop?.text ?? null;
2206
- }
2207
- if (node.type === "call_expression" || node.type === "call") {
2208
- return calleeLeafName(node.childForFieldName("function"));
2209
- }
2210
- return null;
2211
- }
2212
- function jsxComponentName(node) {
2213
- if (!node) return null;
2214
- if (node.type === "identifier") {
2215
- return /^[A-Z]/.test(node.text) ? node.text : null;
2216
- }
2217
- if (node.type === "member_expression" || node.type === "jsx_member_expression") {
2218
- const obj = node.childForFieldName("object") ?? node.namedChild(0);
2219
- return jsxComponentName(obj);
2220
- }
2221
- return null;
2222
- }
2223
- function extractImportBindings(root) {
2224
- const out = [];
2225
- for (let i = 0; i < root.namedChildCount; i++) {
2226
- const n = root.namedChild(i);
2227
- if (!n) continue;
2228
- if (n.type === "import_statement") {
2229
- const src = n.childForFieldName("source");
2230
- if (src) {
2231
- extractJsTsBindings(n, src, out);
2232
- } else {
2233
- extractPythonImportBindings(n, out);
2234
- }
2235
- } else if (n.type === "import_from_statement") {
2236
- extractPythonFromBindings(n, out);
2237
- }
2238
- }
2239
- return out;
2240
- }
2241
- function extractJsTsBindings(n, src, out) {
2242
- const specifier = stripQuotes(src.text);
2243
- let clause = null;
2244
- for (let j = 0; j < n.namedChildCount; j++) {
2245
- const c = n.namedChild(j);
2246
- if (c?.type === "import_clause") {
2247
- clause = c;
2248
- break;
2249
- }
2250
- }
2251
- if (!clause) return;
2252
- for (let j = 0; j < clause.namedChildCount; j++) {
2253
- const c = clause.namedChild(j);
2254
- if (!c) continue;
2255
- if (c.type === "identifier") {
2256
- out.push({ specifier, importedName: "default", localName: c.text });
2257
- } else if (c.type === "namespace_import") {
2258
- const id = firstNamedChildOfType(c, "identifier");
2259
- if (id) out.push({ specifier, importedName: "*", localName: id.text });
2260
- } else if (c.type === "named_imports") {
2261
- for (let k = 0; k < c.namedChildCount; k++) {
2262
- const spec = c.namedChild(k);
2263
- if (!spec || spec.type !== "import_specifier") continue;
2264
- const nameNode = spec.childForFieldName("name");
2265
- const aliasNode = spec.childForFieldName("alias");
2266
- if (nameNode) {
2267
- out.push({
2268
- specifier,
2269
- importedName: nameNode.text,
2270
- localName: aliasNode?.text ?? nameNode.text
2271
- });
2272
- }
2273
- }
2274
- }
2275
- }
2276
- }
2277
- function extractPythonImportBindings(n, out) {
2278
- for (let i = 0; i < n.childCount; i++) {
2279
- const c = n.child(i);
2280
- if (!c || n.fieldNameForChild(i) !== "name") continue;
2281
- if (c.type === "dotted_name") {
2282
- const spec = c.text;
2283
- const local = spec.split(".")[0];
2284
- out.push({ specifier: spec, importedName: "*", localName: local });
2285
- } else if (c.type === "aliased_import") {
2286
- const name = c.childForFieldName("name");
2287
- const alias = c.childForFieldName("alias");
2288
- if (name?.type === "dotted_name" && alias) {
2289
- out.push({ specifier: name.text, importedName: "*", localName: alias.text });
2290
- }
2291
- }
2292
- }
2293
- }
2294
- function extractPythonFromBindings(n, out) {
2295
- const moduleNode = n.childForFieldName("module_name");
2296
- let specifier = "";
2297
- if (moduleNode) {
2298
- if (moduleNode.type === "dotted_name") {
2299
- specifier = moduleNode.text;
2300
- } else if (moduleNode.type === "relative_import") {
2301
- let dots = "";
2302
- let modulePath = "";
2303
- for (let i = 0; i < moduleNode.namedChildCount; i++) {
2304
- const c = moduleNode.namedChild(i);
2305
- if (!c) continue;
2306
- if (c.type === "import_prefix") dots = c.text;
2307
- else if (c.type === "dotted_name") modulePath = c.text;
2308
- }
2309
- specifier = dots + modulePath;
2310
- }
2311
- }
2312
- if (!specifier) return;
2313
- let sawWildcard = false;
2314
- for (let i = 0; i < n.childCount; i++) {
2315
- const c = n.child(i);
2316
- if (!c) continue;
2317
- const field = n.fieldNameForChild(i);
2318
- if (c.type === "wildcard_import") {
2319
- sawWildcard = true;
2320
- continue;
2321
- }
2322
- if (field !== "name") continue;
2323
- if (c.type === "dotted_name") {
2324
- const name = c.text;
2325
- out.push({ specifier, importedName: name, localName: name });
2326
- } else if (c.type === "aliased_import") {
2327
- const name = c.childForFieldName("name");
2328
- const alias = c.childForFieldName("alias");
2329
- if (name?.type === "dotted_name" && alias) {
2330
- out.push({
2331
- specifier,
2332
- importedName: name.text,
2333
- localName: alias.text
2334
- });
2335
- }
2336
- }
2337
- }
2338
- if (sawWildcard) {
2339
- out.push({ specifier, importedName: "*", localName: "*" });
2340
- }
2341
- }
2342
- function extractReexports(root) {
2343
- const out = [];
2344
- for (let i = 0; i < root.namedChildCount; i++) {
2345
- const n = root.namedChild(i);
2346
- if (!n || n.type !== "export_statement") continue;
2347
- const src = n.childForFieldName("source");
2348
- if (!src) continue;
2349
- const specifier = stripQuotes(src.text);
2350
- let clause = null;
2351
- for (let j = 0; j < n.namedChildCount; j++) {
2352
- const c = n.namedChild(j);
2353
- if (c?.type === "export_clause") {
2354
- clause = c;
2355
- break;
2356
- }
2357
- }
2358
- if (!clause) continue;
2359
- for (let k = 0; k < clause.namedChildCount; k++) {
2360
- const spec = clause.namedChild(k);
2361
- if (!spec || spec.type !== "export_specifier") continue;
2362
- const nameNode = spec.childForFieldName("name");
2363
- const aliasNode = spec.childForFieldName("alias");
2364
- if (!nameNode) continue;
2365
- const originalName = nameNode.text;
2366
- const exportedName = aliasNode?.text ?? originalName;
2367
- out.push({
2368
- localName: exportedName,
2369
- specifier,
2370
- importedName: originalName,
2371
- isReexport: true
2372
- });
2373
- }
2374
- }
2375
- return out;
2376
- }
2377
- function stripQuotes(s) {
2378
- if (s.length >= 2 && (s[0] === '"' || s[0] === "'") && s[s.length - 1] === s[0]) {
2379
- return s.slice(1, -1);
2380
- }
2381
- return s;
2382
- }
2383
- function firstNamedChildOfType(node, type) {
2384
- for (let i = 0; i < node.namedChildCount; i++) {
2385
- const c = node.namedChild(i);
2386
- if (c?.type === type) return c;
2387
- }
2388
- return null;
2389
- }
2390
-
2391
- // packages/feature/explorer/src/server/codeMap/projectGraph/extractImports.ts
2392
- function walkForJsTsImports(root) {
2393
- const out = [];
2394
- function readStringNode(stringNode) {
2395
- if (!stringNode || stringNode.type !== "string") return null;
2396
- for (let i = 0; i < stringNode.namedChildCount; i++) {
2397
- const c = stringNode.namedChild(i);
2398
- if (c && c.type === "string_fragment") return c.text;
2399
- }
2400
- return "";
2401
- }
2402
- function visit(node) {
2403
- switch (node.type) {
2404
- case "import_statement":
2405
- case "export_statement": {
2406
- const source = node.childForFieldName("source");
2407
- const spec = readStringNode(source);
2408
- if (spec) out.push(spec);
2409
- return;
2410
- }
2411
- case "call_expression": {
2412
- const fn = node.childForFieldName("function");
2413
- if (fn) {
2414
- const isDynamicImport = fn.type === "import";
2415
- const isRequire = fn.type === "identifier" && fn.text === "require";
2416
- if (isDynamicImport || isRequire) {
2417
- const args = node.childForFieldName("arguments");
2418
- if (args && args.namedChildCount > 0) {
2419
- const firstArg = args.namedChild(0);
2420
- const spec = readStringNode(firstArg);
2421
- if (spec) out.push(spec);
2422
- }
2423
- }
2424
- }
2425
- break;
2426
- }
2427
- }
2428
- for (let i = 0; i < node.namedChildCount; i++) {
2429
- const child = node.namedChild(i);
2430
- if (child) visit(child);
2431
- }
2432
- }
2433
- visit(root);
2434
- return out;
2435
- }
2436
- function walkForPythonImports(root) {
2437
- const out = [];
2438
- function visit(node) {
2439
- switch (node.type) {
2440
- case "import_statement": {
2441
- for (let i = 0; i < node.childCount; i++) {
2442
- const c = node.child(i);
2443
- if (!c || node.fieldNameForChild(i) !== "name") continue;
2444
- if (c.type === "dotted_name") {
2445
- out.push(c.text);
2446
- } else if (c.type === "aliased_import") {
2447
- const name = c.childForFieldName("name");
2448
- if (name?.type === "dotted_name") out.push(name.text);
2449
- }
2450
- }
2451
- return;
2452
- }
2453
- case "import_from_statement": {
2454
- const spec = readPythonModuleSpec(node);
2455
- if (spec) out.push(spec);
2456
- return;
2457
- }
2458
- }
2459
- for (let i = 0; i < node.namedChildCount; i++) {
2460
- const child = node.namedChild(i);
2461
- if (child) visit(child);
2462
- }
2463
- }
2464
- visit(root);
2465
- return out;
2466
- }
2467
- function readPythonModuleSpec(node) {
2468
- const moduleNode = node.childForFieldName("module_name");
2469
- if (!moduleNode) return "";
2470
- if (moduleNode.type === "dotted_name") return moduleNode.text;
2471
- if (moduleNode.type === "relative_import") {
2472
- let dots = "";
2473
- let modulePath = "";
2474
- for (let i = 0; i < moduleNode.namedChildCount; i++) {
2475
- const c = moduleNode.namedChild(i);
2476
- if (!c) continue;
2477
- if (c.type === "import_prefix") dots = c.text;
2478
- else if (c.type === "dotted_name") modulePath = c.text;
2479
- }
2480
- return dots + modulePath;
2481
- }
2482
- return "";
2483
- }
2484
- var WALKERS = {
2485
- typescript: walkForJsTsImports,
2486
- tsx: walkForJsTsImports,
2487
- javascript: walkForJsTsImports,
2488
- python: walkForPythonImports
2489
- };
2490
- function extractImportsFromTree(root, grammar) {
2491
- const walker = WALKERS[grammar];
2492
- if (!walker) return [];
2493
- return walker(root);
2494
- }
2495
-
2496
- // packages/feature/explorer/src/server/codeMap/handlers/typescript.ts
2497
- function isFunctionLikeKind(k) {
2498
- return k === "function" || k === "class" || k === "method";
2499
- }
2500
- var REEXPORT_MAX_DEPTH = 5;
2501
- function findExportedSymbol(file, name, depth, visited, allFiles) {
2502
- if (depth > REEXPORT_MAX_DEPTH) return null;
2503
- if (visited.has(file.path)) return null;
2504
- visited.add(file.path);
2505
- const candidates = file.symbolsByName.get(name);
2506
- if (candidates) {
2507
- let best = null;
2508
- for (const s of candidates) {
2509
- if (!isFunctionLikeKind(s.kind)) continue;
2510
- if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
2511
- best = s;
2512
- }
2513
- }
2514
- if (best) return best;
2515
- }
2516
- const reexp = file.reexportsByLocalName.get(name);
2517
- if (reexp) {
2518
- const nextPath = file.resolvedImports.get(reexp.specifier);
2519
- if (nextPath) {
2520
- const nextFile = allFiles.get(nextPath);
2521
- if (nextFile) {
2522
- const found = findExportedSymbol(
2523
- nextFile,
2524
- reexp.importedName,
2525
- depth + 1,
2526
- visited,
2527
- allFiles
2528
- );
2529
- if (found) return found;
2530
- }
2531
- }
2532
- }
2533
- return null;
2534
- }
2535
- function findReceiverMethod(file, receiverImportedName, methodName, depth, visited, allFiles) {
2536
- if (depth > REEXPORT_MAX_DEPTH) return null;
2537
- if (visited.has(file.path)) return null;
2538
- visited.add(file.path);
2539
- if (receiverImportedName !== "*") {
2540
- const nestedQname = `${receiverImportedName}>${methodName}`;
2541
- const nested = file.symbolsByQname.get(nestedQname);
2542
- if (nested && isFunctionLikeKind(nested.kind)) return nested;
2543
- }
2544
- if (receiverImportedName === "*") {
2545
- const top = file.symbolsByName.get(methodName);
2546
- if (top) {
2547
- let best = null;
2548
- for (const s of top) {
2549
- if (s.qualifiedName.includes(">")) continue;
2550
- if (!isFunctionLikeKind(s.kind)) continue;
2551
- if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
2552
- best = s;
2553
- }
2554
- }
2555
- if (best) return best;
2556
- }
2557
- }
2558
- const reexp = file.reexportsByLocalName.get(receiverImportedName);
2559
- if (reexp) {
2560
- const nextPath = file.resolvedImports.get(reexp.specifier);
2561
- if (nextPath) {
2562
- const nextFile = allFiles.get(nextPath);
2563
- if (nextFile) {
2564
- const found = findReceiverMethod(
2565
- nextFile,
2566
- reexp.importedName,
2567
- methodName,
2568
- depth + 1,
2569
- visited,
2570
- allFiles
2571
- );
2572
- if (found) return found;
2573
- }
2574
- }
2575
- }
2576
- return null;
2577
- }
2578
- function makeTsFamilyHandler(grammarId, extensions) {
2579
- return {
2580
- grammarId,
2581
- extensions,
2582
- extractSymbols(root, _source) {
2583
- return extractSymbolsFromTree(root);
2584
- },
2585
- extractImports(root) {
2586
- const specs = extractImportsFromTree(root, grammarId);
2587
- const baseBindings = extractImportBindings(root);
2588
- const reexportBindings = extractReexports(root);
2589
- return {
2590
- specs,
2591
- bindings: [...baseBindings, ...reexportBindings]
2592
- };
2593
- },
2594
- extractCallSites(root, _symbols) {
2595
- return extractRawCalls(root);
2596
- },
2597
- // ----------------------------------------------------------------
2598
- // Project context — loads tsconfig path aliases + workspace
2599
- // packages so resolveSpecifier can match aliased imports
2600
- // (`@/foo`, `@org/auth`) without re-reading filesystem on every
2601
- // resolve. Async because both loaders read JSON files.
2602
- // ----------------------------------------------------------------
2603
- async buildProjectContext(cwd, fileSet) {
2604
- const mutableFileSet = new Set(fileSet);
2605
- const tsconfigs = await loadTsconfigs(cwd);
2606
- const workspaces = await loadWorkspaces(cwd, mutableFileSet);
2607
- const sortedWsNames = [...workspaces.keys()].sort(
2608
- (a, b) => b.length - a.length
2609
- );
2610
- const ctx = {
2611
- cwd,
2612
- tsconfigs,
2613
- workspaces,
2614
- sortedWsNames,
2615
- owningScopesCache: /* @__PURE__ */ new Map()
2616
- };
2617
- return ctx;
2618
- },
2619
- resolveSpecifier(spec, fromFilePath, ctx, fileSet) {
2620
- const c = ctx;
2621
- const mutableFileSet = fileSet;
2622
- let owningScopes = c.owningScopesCache.get(fromFilePath);
2623
- if (!owningScopes) {
2624
- owningScopes = c.tsconfigs.filter(
2625
- (t) => fileInScope(fromFilePath, t.scope)
2626
- );
2627
- c.owningScopesCache.set(fromFilePath, owningScopes);
2628
- }
2629
- if (spec.startsWith("./") || spec.startsWith("../")) {
2630
- return findFileForBase(
2631
- path2.resolve(c.cwd, path2.dirname(fromFilePath), spec),
2632
- c.cwd,
2633
- mutableFileSet
2634
- );
2635
- }
2636
- if (spec.startsWith("/")) {
2637
- return findFileForBase(
2638
- path2.resolve(c.cwd, spec.slice(1)),
2639
- c.cwd,
2640
- mutableFileSet
2641
- );
2642
- }
2643
- for (const ts of owningScopes) {
2644
- const hit = ts.sortedAliases.find(
2645
- ([prefix2]) => spec === prefix2 || spec.startsWith(prefix2 + "/")
2646
- );
2647
- if (!hit) continue;
2648
- const [prefix, target] = hit;
2649
- const remainder = spec === prefix ? "" : spec.slice(prefix.length + 1);
2650
- const r = findFileForBase(
2651
- path2.resolve(c.cwd, target, remainder),
2652
- c.cwd,
2653
- mutableFileSet
2654
- );
2655
- if (r) return r;
2656
- }
2657
- for (const pkgName of c.sortedWsNames) {
2658
- if (spec !== pkgName && !spec.startsWith(pkgName + "/")) continue;
2659
- const ws = c.workspaces.get(pkgName);
2660
- if (spec === pkgName) return ws.entryFile;
2661
- const subpath = spec.slice(pkgName.length + 1);
2662
- return findFileRelativeToProject(
2663
- path2.posix.join(ws.dir, subpath),
2664
- mutableFileSet
2665
- ) ?? findFileRelativeToProject(
2666
- path2.posix.join(ws.dir, "src", subpath),
2667
- mutableFileSet
2668
- );
2669
- }
2670
- return null;
2671
- },
2672
- resolveCall(call, from, fromFile, allFiles, _ctx) {
2673
- if (call.receiverName) {
2674
- const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
2675
- if (!recvBinding) return [];
2676
- const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
2677
- if (!recvFilePath) return [];
2678
- const recvTarget = allFiles.get(recvFilePath);
2679
- if (!recvTarget) return [];
2680
- const sym2 = findReceiverMethod(
2681
- recvTarget,
2682
- recvBinding.importedName,
2683
- call.calleeName,
2684
- 0,
2685
- /* @__PURE__ */ new Set(),
2686
- allFiles
2687
- );
2688
- if (sym2) {
2689
- return [
2690
- {
2691
- kind: "symbol",
2692
- addr: { filePath: sym2.filePath, qualifiedName: sym2.qualifiedName }
2693
- }
2694
- ];
2695
- }
2696
- return [
2697
- {
2698
- kind: "method-unresolved",
2699
- receiverName: call.receiverName,
2700
- methodName: call.calleeName
2701
- }
2702
- ];
2703
- }
2704
- const localMatches = fromFile.symbolsByName.get(call.calleeName);
2705
- if (localMatches && localMatches.length > 0) {
2706
- const out = [];
2707
- for (const callee of localMatches) {
2708
- if (callee.qualifiedName === from.qualifiedName) continue;
2709
- if (!isFunctionLikeKind(callee.kind)) continue;
2710
- out.push({
2711
- kind: "symbol",
2712
- addr: {
2713
- filePath: callee.filePath,
2714
- qualifiedName: callee.qualifiedName
2715
- }
2716
- });
2717
- }
2718
- return out;
2719
- }
2720
- const binding = fromFile.bindingsByLocalName.get(call.calleeName);
2721
- if (!binding) return [];
2722
- const targetFile = fromFile.resolvedImports.get(binding.specifier);
2723
- if (!targetFile) {
2724
- return [
2725
- {
2726
- kind: "external",
2727
- name: binding.importedName,
2728
- packageSpec: binding.specifier
2729
- }
2730
- ];
2731
- }
2732
- const target = allFiles.get(targetFile);
2733
- if (!target) return [];
2734
- const sym = findExportedSymbol(
2735
- target,
2736
- binding.importedName,
2737
- 0,
2738
- /* @__PURE__ */ new Set(),
2739
- allFiles
2740
- );
2741
- if (!sym) return [];
2742
- return [
2743
- {
2744
- kind: "symbol",
2745
- addr: { filePath: sym.filePath, qualifiedName: sym.qualifiedName }
2746
- }
2747
- ];
2748
- },
2749
- moduleForFile(filePath, _ctx) {
2750
- return filePath;
2751
- }
2752
- };
2753
- }
2754
- var typescriptHandler = makeTsFamilyHandler("typescript", [".ts"]);
2755
- var tsxHandler = makeTsFamilyHandler("tsx", [".tsx", ".jsx"]);
2756
- var javascriptHandler = makeTsFamilyHandler("javascript", [
2757
- ".js",
2758
- ".mjs",
2759
- ".cjs"
2760
- ]);
2761
-
2762
- // packages/feature/explorer/src/server/codeMap/handlers/python.ts
2763
- import path3 from "path";
2764
- function isFunctionLikeKind2(k) {
2765
- return k === "function" || k === "class" || k === "method";
2766
- }
2767
- function findExportedSymbolPy(file, name) {
2768
- const candidates = file.symbolsByName.get(name);
2769
- if (!candidates) return null;
2770
- let best = null;
2771
- for (const s of candidates) {
2772
- if (!isFunctionLikeKind2(s.kind)) continue;
2773
- if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
2774
- best = s;
2775
- }
2776
- }
2777
- return best;
2778
- }
2779
- function findReceiverMethodPy(file, receiverImportedName, methodName) {
2780
- if (receiverImportedName !== "*") {
2781
- const nestedQname = `${receiverImportedName}>${methodName}`;
2782
- const nested = file.symbolsByQname.get(nestedQname);
2783
- if (nested && isFunctionLikeKind2(nested.kind)) return nested;
2784
- }
2785
- if (receiverImportedName === "*") {
2786
- const top = file.symbolsByName.get(methodName);
2787
- if (top) {
2788
- let best = null;
2789
- for (const s of top) {
2790
- if (s.qualifiedName.includes(">")) continue;
2791
- if (!isFunctionLikeKind2(s.kind)) continue;
2792
- if (!best || s.endLine - s.startLine > best.endLine - best.startLine) {
2793
- best = s;
2794
- }
2795
- }
2796
- if (best) return best;
2797
- }
2798
- }
2799
- return null;
2800
- }
2801
- function tryPythonPaths(baseDir, modulePath, fileSet) {
2802
- const sub = modulePath.replace(/\./g, "/");
2803
- const join2 = (...segs) => segs.filter((s) => s !== "" && s !== ".").join("/");
2804
- if (!sub) {
2805
- const init = join2(baseDir, "__init__.py");
2806
- if (fileSet.has(init)) return init;
2807
- return null;
2808
- }
2809
- const direct = join2(baseDir, sub + ".py");
2810
- if (fileSet.has(direct)) return direct;
2811
- const initFile = join2(baseDir, sub, "__init__.py");
2812
- if (fileSet.has(initFile)) return initFile;
2813
- return null;
2814
- }
2815
- var pythonHandler = {
2816
- grammarId: "python",
2817
- extensions: [".py", ".pyi"],
2818
- extractSymbols(root, _source) {
2819
- return extractSymbolsFromTree(root);
2820
- },
2821
- extractImports(root) {
2822
- const specs = extractImportsFromTree(root, "python");
2823
- const bindings = extractImportBindings(root);
2824
- return { specs, bindings };
2825
- },
2826
- extractCallSites(root, _symbols) {
2827
- return extractRawCalls(root);
2828
- },
2829
- buildProjectContext(cwd, fileSet) {
2830
- const pythonRoots = [cwd];
2831
- let hasSrcLayout = false;
2832
- if (fileSet.has("src/__init__.py")) {
2833
- hasSrcLayout = true;
2834
- } else {
2835
- for (const p of fileSet) {
2836
- if (p.startsWith("src/") && p.endsWith(".py")) {
2837
- hasSrcLayout = true;
2838
- break;
2839
- }
2840
- }
2841
- }
2842
- if (hasSrcLayout) pythonRoots.push(path3.join(cwd, "src"));
2843
- const ctx = { cwd, pythonRoots };
2844
- return ctx;
2845
- },
2846
- resolveSpecifier(spec, fromFilePath, ctx, fileSet) {
2847
- const c = ctx;
2848
- const dotMatch = /^(\.+)/.exec(spec);
2849
- if (dotMatch) {
2850
- const dots = dotMatch[1].length;
2851
- const rest = spec.slice(dots);
2852
- let baseDir = path3.dirname(fromFilePath);
2853
- for (let i = 1; i < dots; i++) baseDir = path3.dirname(baseDir);
2854
- return tryPythonPaths(baseDir || ".", rest, fileSet);
2855
- }
2856
- for (const root of c.pythonRoots) {
2857
- const rootRel = path3.relative(c.cwd, root) || ".";
2858
- const r = tryPythonPaths(rootRel, spec, fileSet);
2859
- if (r) return r;
2860
- }
2861
- return null;
2862
- },
2863
- resolveCall(call, from, fromFile, allFiles, _ctx) {
2864
- if (call.receiverName) {
2865
- const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
2866
- if (!recvBinding) return [];
2867
- const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
2868
- if (!recvFilePath) return [];
2869
- const recvTarget = allFiles.get(recvFilePath);
2870
- if (!recvTarget) return [];
2871
- const sym2 = findReceiverMethodPy(
2872
- recvTarget,
2873
- recvBinding.importedName,
2874
- call.calleeName
2875
- );
2876
- if (sym2) {
2877
- return [
2878
- {
2879
- kind: "symbol",
2880
- addr: { filePath: sym2.filePath, qualifiedName: sym2.qualifiedName }
2881
- }
2882
- ];
2883
- }
2884
- return [
2885
- {
2886
- kind: "method-unresolved",
2887
- receiverName: call.receiverName,
2888
- methodName: call.calleeName
2889
- }
2890
- ];
2891
- }
2892
- const localMatches = fromFile.symbolsByName.get(call.calleeName);
2893
- if (localMatches && localMatches.length > 0) {
2894
- const out = [];
2895
- for (const callee of localMatches) {
2896
- if (callee.qualifiedName === from.qualifiedName) continue;
2897
- if (!isFunctionLikeKind2(callee.kind)) continue;
2898
- out.push({
2899
- kind: "symbol",
2900
- addr: {
2901
- filePath: callee.filePath,
2902
- qualifiedName: callee.qualifiedName
2903
- }
2904
- });
2905
- }
2906
- return out;
2907
- }
2908
- const binding = fromFile.bindingsByLocalName.get(call.calleeName);
2909
- if (!binding) return [];
2910
- const targetFile = fromFile.resolvedImports.get(binding.specifier);
2911
- if (!targetFile) {
2912
- return [
2913
- {
2914
- kind: "external",
2915
- name: binding.importedName,
2916
- packageSpec: binding.specifier
2917
- }
2918
- ];
2919
- }
2920
- const target = allFiles.get(targetFile);
2921
- if (!target) return [];
2922
- const sym = findExportedSymbolPy(target, binding.importedName);
2923
- if (!sym) return [];
2924
- return [
2925
- {
2926
- kind: "symbol",
2927
- addr: { filePath: sym.filePath, qualifiedName: sym.qualifiedName }
2928
- }
2929
- ];
2930
- },
2931
- moduleForFile(filePath, _ctx) {
2932
- return filePath;
2933
- }
2934
- };
2935
-
2936
- // packages/feature/explorer/src/server/codeMap/handlers/go.ts
2937
- import { promises as fs2 } from "fs";
2938
- import path4 from "path";
2939
- function qualify2(parent, name) {
2940
- return parent ? `${parent}>${name}` : name;
2941
- }
2942
- function makeSymbol2(node, name, kind, parentQname, children = [], params) {
2943
- return {
2944
- qualifiedName: qualify2(parentQname, name),
2945
- name,
2946
- kind,
2947
- startLine: node.startPosition.row + 1,
2948
- endLine: node.endPosition.row + 1,
2949
- contentHash: hashText(normalizeForHash(node.text)),
2950
- children,
2951
- params
2952
- };
2953
- }
2954
- function extractGoParams(fnNode) {
2955
- const params = fnNode.childForFieldName("parameters");
2956
- if (!params) return void 0;
2957
- const out = [];
2958
- for (let i = 0; i < params.namedChildCount; i++) {
2959
- const p = params.namedChild(i);
2960
- if (!p) continue;
2961
- if (p.type === "parameter_declaration") {
2962
- const nameNode = p.childForFieldName("name");
2963
- if (!nameNode) {
2964
- out.push("_");
2965
- continue;
2966
- }
2967
- if (nameNode.type === "identifier") {
2968
- out.push(nameNode.text);
2969
- } else if (nameNode.type === "identifier_list") {
2970
- for (let j = 0; j < nameNode.namedChildCount; j++) {
2971
- const id = nameNode.namedChild(j);
2972
- if (id?.type === "identifier") out.push(id.text);
2973
- }
2974
- } else {
2975
- out.push(nameNode.text);
2976
- }
2977
- } else if (p.type === "variadic_parameter_declaration") {
2978
- const nameNode = p.childForFieldName("name");
2979
- if (nameNode?.type === "identifier") {
2980
- out.push(`...${nameNode.text}`);
2981
- } else {
2982
- out.push("...");
2983
- }
2984
- }
2985
- }
2986
- return out;
2987
- }
2988
- function extractReceiverTypeName(method) {
2989
- const receiver = method.childForFieldName("receiver");
2990
- if (!receiver) return null;
2991
- for (let i = 0; i < receiver.namedChildCount; i++) {
2992
- const p = receiver.namedChild(i);
2993
- if (p?.type !== "parameter_declaration") continue;
2994
- const t = p.childForFieldName("type");
2995
- if (!t) return null;
2996
- return readReceiverTypeIdentifier(t);
2997
- }
2998
- return null;
2999
- }
3000
- function readReceiverTypeIdentifier(t) {
3001
- if (t.type === "type_identifier") return t.text;
3002
- if (t.type === "pointer_type") {
3003
- for (let i = 0; i < t.namedChildCount; i++) {
3004
- const inner = t.namedChild(i);
3005
- if (inner) {
3006
- const r = readReceiverTypeIdentifier(inner);
3007
- if (r) return r;
3008
- }
3009
- }
3010
- return null;
3011
- }
3012
- if (t.type === "generic_type") {
3013
- const base = t.childForFieldName("type");
3014
- if (base) return readReceiverTypeIdentifier(base);
3015
- }
3016
- return null;
3017
- }
3018
- function extractTypeDeclaration(decl, parentQname) {
3019
- const out = [];
3020
- for (let i = 0; i < decl.namedChildCount; i++) {
3021
- const spec = decl.namedChild(i);
3022
- if (!spec) continue;
3023
- if (spec.type === "type_spec" || spec.type === "type_alias") {
3024
- const nameNode = spec.childForFieldName("name");
3025
- const typeNode = spec.childForFieldName("type");
3026
- if (!nameNode) continue;
3027
- const name = nameNode.text;
3028
- const kind = typeNode?.type === "interface_type" ? "interface" : "class";
3029
- out.push(makeSymbol2(spec, name, kind, parentQname));
3030
- }
3031
- }
3032
- return out;
3033
- }
3034
- function extractValueDeclaration(decl, parentQname) {
3035
- const out = [];
3036
- for (let i = 0; i < decl.namedChildCount; i++) {
3037
- const spec = decl.namedChild(i);
3038
- if (!spec) continue;
3039
- if (spec.type === "var_spec" || spec.type === "const_spec") {
3040
- const nameNode = spec.childForFieldName("name");
3041
- if (!nameNode) continue;
3042
- if (nameNode.type === "identifier_list") {
3043
- for (let j = 0; j < nameNode.namedChildCount; j++) {
3044
- const id = nameNode.namedChild(j);
3045
- if (id?.type === "identifier") {
3046
- out.push(makeSymbol2(spec, id.text, "const", parentQname));
3047
- }
3048
- }
3049
- } else if (nameNode.type === "identifier") {
3050
- out.push(makeSymbol2(spec, nameNode.text, "const", parentQname));
3051
- }
3052
- }
3053
- }
3054
- return out;
3055
- }
3056
- function extractGoImportHeader(rootNode) {
3057
- const headerNodes = [];
3058
- let firstLine = -1;
3059
- let lastLine = -1;
3060
- for (let i = 0; i < rootNode.namedChildCount; i++) {
3061
- const c = rootNode.namedChild(i);
3062
- if (!c) continue;
3063
- if (c.type === "import_declaration") {
3064
- headerNodes.push(c);
3065
- if (firstLine < 0) firstLine = c.startPosition.row + 1;
3066
- lastLine = c.endPosition.row + 1;
3067
- } else if (c.type === "package_clause") {
3068
- continue;
3069
- } else if (firstLine >= 0) {
3070
- break;
3071
- }
3072
- }
3073
- if (firstLine < 0) return null;
3074
- const text = headerNodes.map((n) => n.text).join("\n");
3075
- return {
3076
- qualifiedName: "__imports__",
3077
- name: "imports",
3078
- kind: "unknown",
3079
- startLine: firstLine,
3080
- endLine: lastLine,
3081
- contentHash: hashText(normalizeForHash(text)),
3082
- children: []
3083
- };
3084
- }
3085
- function extractTopLevel(rootNode) {
3086
- const symbols = [];
3087
- const pendingMethods = [];
3088
- for (let i = 0; i < rootNode.namedChildCount; i++) {
3089
- const node = rootNode.namedChild(i);
3090
- if (!node) continue;
3091
- switch (node.type) {
3092
- case "function_declaration": {
3093
- const nameNode = node.childForFieldName("name");
3094
- if (!nameNode) break;
3095
- symbols.push(
3096
- makeSymbol2(
3097
- node,
3098
- nameNode.text,
3099
- "function",
3100
- void 0,
3101
- [],
3102
- extractGoParams(node)
3103
- )
3104
- );
3105
- break;
3106
- }
3107
- case "method_declaration": {
3108
- const nameNode = node.childForFieldName("name");
3109
- if (!nameNode) break;
3110
- const recvType = extractReceiverTypeName(node);
3111
- const sym = makeSymbol2(
3112
- node,
3113
- nameNode.text,
3114
- "method",
3115
- recvType ?? void 0,
3116
- [],
3117
- extractGoParams(node)
3118
- );
3119
- if (recvType) {
3120
- pendingMethods.push({ receiverType: recvType, symbol: sym });
3121
- } else {
3122
- symbols.push(sym);
3123
- }
3124
- break;
3125
- }
3126
- case "type_declaration":
3127
- symbols.push(...extractTypeDeclaration(node, void 0));
3128
- break;
3129
- case "var_declaration":
3130
- case "const_declaration":
3131
- symbols.push(...extractValueDeclaration(node, void 0));
3132
- break;
3133
- }
3134
- }
3135
- return { symbols, pendingMethods };
3136
- }
3137
- function attachMethods(symbols, pending) {
3138
- if (pending.length === 0) return symbols;
3139
- const byName = /* @__PURE__ */ new Map();
3140
- for (const s of symbols) {
3141
- if (s.kind === "class" || s.kind === "interface") byName.set(s.name, s);
3142
- }
3143
- const orphans = [];
3144
- for (const m of pending) {
3145
- const host = byName.get(m.receiverType);
3146
- if (host) {
3147
- host.children = [...host.children, m.symbol];
3148
- } else {
3149
- orphans.push(m.symbol);
3150
- }
3151
- }
3152
- return [...symbols, ...orphans];
3153
- }
3154
- function stripQuotes2(s) {
3155
- if (s.length >= 2 && (s[0] === '"' || s[0] === "'" || s[0] === "`") && s[s.length - 1] === s[0]) {
3156
- return s.slice(1, -1);
3157
- }
3158
- return s;
3159
- }
3160
- function extractGoImports(rootNode) {
3161
- const specs = [];
3162
- const bindings = [];
3163
- function visit(node) {
3164
- if (node.type === "import_declaration") {
3165
- for (let i = 0; i < node.namedChildCount; i++) {
3166
- const c = node.namedChild(i);
3167
- if (!c) continue;
3168
- if (c.type === "import_spec") {
3169
- processSpec(c);
3170
- } else if (c.type === "import_spec_list") {
3171
- for (let j = 0; j < c.namedChildCount; j++) {
3172
- const sp = c.namedChild(j);
3173
- if (sp?.type === "import_spec") processSpec(sp);
3174
- }
3175
- }
3176
- }
3177
- return;
3178
- }
3179
- for (let i = 0; i < node.namedChildCount; i++) {
3180
- const child = node.namedChild(i);
3181
- if (child) visit(child);
3182
- }
3183
- }
3184
- function processSpec(spec) {
3185
- const pathNode = spec.childForFieldName("path");
3186
- if (!pathNode) return;
3187
- const specifier = stripQuotes2(pathNode.text);
3188
- if (!specifier) return;
3189
- specs.push(specifier);
3190
- const nameNode = spec.childForFieldName("name");
3191
- let localName;
3192
- if (nameNode) {
3193
- localName = nameNode.text;
3194
- } else {
3195
- const segs = specifier.split("/");
3196
- localName = segs[segs.length - 1] || specifier;
3197
- }
3198
- bindings.push({
3199
- specifier,
3200
- importedName: "*",
3201
- // Go imports a whole package, not specific names
3202
- localName
3203
- });
3204
- }
3205
- visit(rootNode);
3206
- return { specs, bindings };
3207
- }
3208
- function extractGoCallSites(rootNode) {
3209
- const out = [];
3210
- function visit(node) {
3211
- if (node.type === "call_expression") {
3212
- const fn = node.childForFieldName("function");
3213
- const name = calleeLeafName2(fn);
3214
- if (name) {
3215
- const receiverName = receiverRootName2(fn);
3216
- out.push({
3217
- calleeName: name,
3218
- line: node.startPosition.row + 1,
3219
- ...receiverName ? { receiverName } : {}
3220
- });
3221
- }
3222
- }
3223
- for (let i = 0; i < node.childCount; i++) {
3224
- const c = node.child(i);
3225
- if (c) visit(c);
3226
- }
3227
- }
3228
- visit(rootNode);
3229
- return out;
3230
- }
3231
- function calleeLeafName2(node) {
3232
- if (!node) return null;
3233
- if (node.type === "identifier") return node.text;
3234
- if (node.type === "selector_expression") {
3235
- const field = node.childForFieldName("field");
3236
- return field?.text ?? null;
3237
- }
3238
- if (node.type === "call_expression") {
3239
- return calleeLeafName2(node.childForFieldName("function"));
3240
- }
3241
- return null;
3242
- }
3243
- function receiverRootName2(node) {
3244
- if (!node || node.type !== "selector_expression") return void 0;
3245
- let cur = node;
3246
- while (cur) {
3247
- if (cur.type === "identifier") return cur.text;
3248
- if (cur.type === "selector_expression") {
3249
- cur = cur.childForFieldName("operand");
3250
- continue;
3251
- }
3252
- return void 0;
3253
- }
3254
- return void 0;
3255
- }
3256
- async function readModulePath(cwd) {
3257
- try {
3258
- const text = await fs2.readFile(path4.join(cwd, "go.mod"), "utf8");
3259
- const m = /^\s*module\s+(\S+)/m.exec(text);
3260
- return m ? m[1].trim() : null;
3261
- } catch {
3262
- return null;
3263
- }
3264
- }
3265
- function bucketGoFilesByDir(fileSet) {
3266
- const out = /* @__PURE__ */ new Map();
3267
- for (const f of fileSet) {
3268
- if (!f.endsWith(".go")) continue;
3269
- const dir = path4.dirname(f);
3270
- const list = out.get(dir);
3271
- if (list) list.push(f);
3272
- else out.set(dir, [f]);
3273
- }
3274
- return out;
3275
- }
3276
- var goHandler = {
3277
- grammarId: "go",
3278
- extensions: [".go"],
3279
- extractSymbols(rootNode, _source) {
3280
- const out = [];
3281
- const header = extractGoImportHeader(rootNode);
3282
- if (header) out.push(header);
3283
- const { symbols, pendingMethods } = extractTopLevel(rootNode);
3284
- out.push(...attachMethods(symbols, pendingMethods));
3285
- absorbLeadingComments(rootNode, out);
3286
- out.push(...computeFillerBlocks(rootNode, out));
3287
- return out;
3288
- },
3289
- extractImports(rootNode) {
3290
- return extractGoImports(rootNode);
3291
- },
3292
- extractCallSites(rootNode, _symbols) {
3293
- return extractGoCallSites(rootNode);
3294
- },
3295
- // -------- T3: call graph --------
3296
- async buildProjectContext(cwd, fileSet) {
3297
- const modulePath = await readModulePath(cwd);
3298
- const dirToGoFiles = bucketGoFilesByDir(fileSet);
3299
- const ctx = { cwd, modulePath, dirToGoFiles };
3300
- return ctx;
3301
- },
3302
- resolveSpecifier(spec, _fromFilePath, ctx, _fileSet) {
3303
- const c = ctx;
3304
- if (!c.modulePath) return null;
3305
- if (spec === c.modulePath) {
3306
- const files = c.dirToGoFiles.get(".");
3307
- return files?.[0] ?? null;
3308
- }
3309
- if (spec.startsWith(c.modulePath + "/")) {
3310
- const relDir = spec.slice(c.modulePath.length + 1);
3311
- const files = c.dirToGoFiles.get(relDir);
3312
- return files?.[0] ?? null;
3313
- }
3314
- return null;
3315
- },
3316
- resolveCall(call, from, fromFile, allFiles, ctx) {
3317
- const c = ctx;
3318
- const fromDir = path4.dirname(fromFile.path);
3319
- const samePackageFiles = c.dirToGoFiles.get(fromDir) ?? [fromFile.path];
3320
- if (call.receiverName) {
3321
- const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
3322
- if (recvBinding) {
3323
- const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
3324
- if (!recvFilePath) {
3325
- return [
3326
- {
3327
- kind: "external",
3328
- name: call.calleeName,
3329
- packageSpec: recvBinding.specifier
3330
- }
3331
- ];
3332
- }
3333
- const targetDir = path4.dirname(recvFilePath);
3334
- const dirFiles = c.dirToGoFiles.get(targetDir) ?? [];
3335
- for (const fp of dirFiles) {
3336
- const tf = allFiles.get(fp);
3337
- if (!tf) continue;
3338
- const candidates = tf.symbolsByName.get(call.calleeName);
3339
- if (!candidates) continue;
3340
- let sym;
3341
- for (const s of candidates) {
3342
- if (s.qualifiedName.includes(">")) continue;
3343
- if (!isCallableKind(s.kind)) continue;
3344
- sym = s;
3345
- break;
3346
- }
3347
- if (sym) {
3348
- return [
3349
- {
3350
- kind: "symbol",
3351
- addr: {
3352
- filePath: sym.filePath,
3353
- qualifiedName: sym.qualifiedName
3354
- }
3355
- }
3356
- ];
3357
- }
3358
- }
3359
- return [
3360
- {
3361
- kind: "external",
3362
- name: call.calleeName,
3363
- packageSpec: recvBinding.specifier
3364
- }
3365
- ];
3366
- }
3367
- const methodQname = `${call.receiverName}>${call.calleeName}`;
3368
- for (const fp of samePackageFiles) {
3369
- const tf = allFiles.get(fp);
3370
- if (!tf) continue;
3371
- const sym = tf.symbolsByQname.get(methodQname);
3372
- if (sym && isCallableKind(sym.kind)) {
3373
- return [
3374
- {
3375
- kind: "symbol",
3376
- addr: {
3377
- filePath: sym.filePath,
3378
- qualifiedName: sym.qualifiedName
3379
- }
3380
- }
3381
- ];
3382
- }
3383
- }
3384
- return [
3385
- {
3386
- kind: "method-unresolved",
3387
- receiverName: call.receiverName,
3388
- methodName: call.calleeName
3389
- }
3390
- ];
3391
- }
3392
- const out = [];
3393
- for (const fp of samePackageFiles) {
3394
- const tf = allFiles.get(fp);
3395
- if (!tf) continue;
3396
- const candidates = tf.symbolsByName.get(call.calleeName);
3397
- if (!candidates) continue;
3398
- for (const s of candidates) {
3399
- if (s.qualifiedName === from.qualifiedName) continue;
3400
- if (s.qualifiedName.includes(">")) continue;
3401
- if (!isCallableKind(s.kind)) continue;
3402
- out.push({
3403
- kind: "symbol",
3404
- addr: { filePath: s.filePath, qualifiedName: s.qualifiedName }
3405
- });
3406
- }
3407
- }
3408
- return out;
3409
- },
3410
- moduleForFile(filePath, ctx) {
3411
- const c = ctx;
3412
- const dir = path4.dirname(filePath);
3413
- if (!c?.modulePath) return dir;
3414
- return dir === "." ? c.modulePath : `${c.modulePath}/${dir}`;
3415
- }
3416
- };
3417
- function isCallableKind(k) {
3418
- return k === "function" || k === "class" || k === "method";
3419
- }
3420
-
3421
- // packages/feature/explorer/src/server/codeMap/handlers/rust.ts
3422
- import { promises as fs3 } from "fs";
3423
- import path5 from "path";
3424
- function qualify3(parent, name) {
3425
- return parent ? `${parent}>${name}` : name;
3426
- }
3427
- function makeSymbol3(node, name, kind, parentQname, children = [], params) {
3428
- return {
3429
- qualifiedName: qualify3(parentQname, name),
3430
- name,
3431
- kind,
3432
- startLine: node.startPosition.row + 1,
3433
- endLine: node.endPosition.row + 1,
3434
- contentHash: hashText(normalizeForHash(node.text)),
3435
- children,
3436
- params
3437
- };
3438
- }
3439
- function extractRustParams(fnNode) {
3440
- const params = fnNode.childForFieldName("parameters");
3441
- if (!params) return void 0;
3442
- const out = [];
3443
- for (let i = 0; i < params.namedChildCount; i++) {
3444
- const p = params.namedChild(i);
3445
- if (!p) continue;
3446
- if (p.type === "self_parameter") {
3447
- out.push(p.text);
3448
- } else if (p.type === "parameter") {
3449
- const pat = p.childForFieldName("pattern");
3450
- if (pat) {
3451
- out.push(pat.text);
3452
- } else {
3453
- out.push("_");
3454
- }
3455
- } else if (p.type === "variadic_parameter") {
3456
- out.push("...");
3457
- }
3458
- }
3459
- return out;
3460
- }
3461
- function readImplTargetType(implNode) {
3462
- const t = implNode.childForFieldName("type");
3463
- if (!t) return null;
3464
- return readRustTypeName(t);
3465
- }
3466
- function readRustTypeName(t) {
3467
- if (t.type === "type_identifier") return t.text;
3468
- if (t.type === "generic_type") {
3469
- const base = t.childForFieldName("type");
3470
- if (base) return readRustTypeName(base);
3471
- }
3472
- if (t.type === "reference_type") {
3473
- for (let i = 0; i < t.namedChildCount; i++) {
3474
- const inner = t.namedChild(i);
3475
- if (inner) {
3476
- const r = readRustTypeName(inner);
3477
- if (r) return r;
3478
- }
3479
- }
3480
- }
3481
- if (t.type === "scoped_type_identifier") {
3482
- const name = t.childForFieldName("name");
3483
- if (name?.type === "type_identifier") return name.text;
3484
- }
3485
- return null;
3486
- }
3487
- function extractImplMembers(impl, parentQname) {
3488
- const body = impl.childForFieldName("body");
3489
- if (!body) return [];
3490
- const out = [];
3491
- for (let i = 0; i < body.namedChildCount; i++) {
3492
- const m = body.namedChild(i);
3493
- if (!m) continue;
3494
- if (m.type === "function_item") {
3495
- const nameNode = m.childForFieldName("name");
3496
- if (!nameNode) continue;
3497
- out.push(
3498
- makeSymbol3(
3499
- m,
3500
- nameNode.text,
3501
- "method",
3502
- parentQname,
3503
- [],
3504
- extractRustParams(m)
3505
- )
3506
- );
3507
- } else if (m.type === "function_signature_item") {
3508
- const nameNode = m.childForFieldName("name");
3509
- if (!nameNode) continue;
3510
- out.push(
3511
- makeSymbol3(
3512
- m,
3513
- nameNode.text,
3514
- "method",
3515
- parentQname,
3516
- [],
3517
- extractRustParams(m)
3518
- )
3519
- );
3520
- }
3521
- }
3522
- return out;
3523
- }
3524
- function extractTraitMembers(trait, parentQname) {
3525
- const body = trait.childForFieldName("body");
3526
- if (!body) return [];
3527
- const out = [];
3528
- for (let i = 0; i < body.namedChildCount; i++) {
3529
- const m = body.namedChild(i);
3530
- if (!m) continue;
3531
- if (m.type === "function_item" || m.type === "function_signature_item") {
3532
- const nameNode = m.childForFieldName("name");
3533
- if (!nameNode) continue;
3534
- out.push(
3535
- makeSymbol3(
3536
- m,
3537
- nameNode.text,
3538
- "method",
3539
- parentQname,
3540
- [],
3541
- extractRustParams(m)
3542
- )
3543
- );
3544
- }
3545
- }
3546
- return out;
3547
- }
3548
- function extractRustImportHeader(rootNode) {
3549
- const headerNodes = [];
3550
- let firstLine = -1;
3551
- let lastLine = -1;
3552
- for (let i = 0; i < rootNode.namedChildCount; i++) {
3553
- const c = rootNode.namedChild(i);
3554
- if (!c) continue;
3555
- if (c.type === "use_declaration" || c.type === "extern_crate_declaration") {
3556
- headerNodes.push(c);
3557
- if (firstLine < 0) firstLine = c.startPosition.row + 1;
3558
- lastLine = c.endPosition.row + 1;
3559
- } else if (firstLine >= 0) {
3560
- break;
3561
- }
3562
- }
3563
- if (firstLine < 0) return null;
3564
- const text = headerNodes.map((n) => n.text).join("\n");
3565
- return {
3566
- qualifiedName: "__imports__",
3567
- name: "imports",
3568
- kind: "unknown",
3569
- startLine: firstLine,
3570
- endLine: lastLine,
3571
- contentHash: hashText(normalizeForHash(text)),
3572
- children: []
3573
- };
3574
- }
3575
- function extractTopLevel2(rootNode) {
3576
- const symbols = [];
3577
- const pendingImpls = [];
3578
- for (let i = 0; i < rootNode.namedChildCount; i++) {
3579
- const node = rootNode.namedChild(i);
3580
- if (!node) continue;
3581
- switch (node.type) {
3582
- case "function_item": {
3583
- const nameNode = node.childForFieldName("name");
3584
- if (!nameNode) break;
3585
- symbols.push(
3586
- makeSymbol3(
3587
- node,
3588
- nameNode.text,
3589
- "function",
3590
- void 0,
3591
- [],
3592
- extractRustParams(node)
3593
- )
3594
- );
3595
- break;
3596
- }
3597
- case "struct_item":
3598
- case "union_item": {
3599
- const nameNode = node.childForFieldName("name");
3600
- if (!nameNode) break;
3601
- symbols.push(makeSymbol3(node, nameNode.text, "class", void 0));
3602
- break;
3603
- }
3604
- case "enum_item": {
3605
- const nameNode = node.childForFieldName("name");
3606
- if (!nameNode) break;
3607
- symbols.push(makeSymbol3(node, nameNode.text, "enum", void 0));
3608
- break;
3609
- }
3610
- case "trait_item": {
3611
- const nameNode = node.childForFieldName("name");
3612
- if (!nameNode) break;
3613
- const qname = nameNode.text;
3614
- const members = extractTraitMembers(node, qname);
3615
- symbols.push(
3616
- makeSymbol3(node, nameNode.text, "interface", void 0, members)
3617
- );
3618
- break;
3619
- }
3620
- case "impl_item": {
3621
- const target = readImplTargetType(node);
3622
- if (!target) break;
3623
- const methods = extractImplMembers(node, target);
3624
- if (methods.length > 0) {
3625
- pendingImpls.push({ targetType: target, methods });
3626
- }
3627
- break;
3628
- }
3629
- case "const_item":
3630
- case "static_item": {
3631
- const nameNode = node.childForFieldName("name");
3632
- if (!nameNode) break;
3633
- symbols.push(makeSymbol3(node, nameNode.text, "const", void 0));
3634
- break;
3635
- }
3636
- case "type_item": {
3637
- const nameNode = node.childForFieldName("name");
3638
- if (!nameNode) break;
3639
- symbols.push(makeSymbol3(node, nameNode.text, "type", void 0));
3640
- break;
3641
- }
3642
- case "mod_item": {
3643
- const nameNode = node.childForFieldName("name");
3644
- const body = node.childForFieldName("body");
3645
- if (!nameNode || !body) {
3646
- break;
3647
- }
3648
- symbols.push(makeSymbol3(node, nameNode.text, "class", void 0));
3649
- break;
3650
- }
3651
- }
3652
- }
3653
- return { symbols, pendingImpls };
3654
- }
3655
- function attachImplMethods(symbols, pending) {
3656
- if (pending.length === 0) return symbols;
3657
- const byName = /* @__PURE__ */ new Map();
3658
- for (const s of symbols) {
3659
- if (s.kind === "class" || s.kind === "enum" || s.kind === "interface") {
3660
- byName.set(s.name, s);
3661
- }
3662
- }
3663
- const orphans = [];
3664
- for (const impl of pending) {
3665
- const host = byName.get(impl.targetType);
3666
- if (host) {
3667
- host.children = [...host.children, ...impl.methods];
3668
- } else {
3669
- orphans.push(...impl.methods);
3670
- }
3671
- }
3672
- return [...symbols, ...orphans];
3673
- }
3674
- function extractRustImports(rootNode) {
3675
- const specs = [];
3676
- const bindings = [];
3677
- function walkUse(useNode) {
3678
- for (let i = 0; i < useNode.namedChildCount; i++) {
3679
- const c = useNode.namedChild(i);
3680
- if (c) processUseTree(c, "");
3681
- }
3682
- }
3683
- function processUseTree(node, prefix) {
3684
- switch (node.type) {
3685
- case "use_as_clause": {
3686
- const pathNode = node.childForFieldName("path");
3687
- const aliasNode = node.childForFieldName("alias");
3688
- if (pathNode && aliasNode) {
3689
- const fullPath = joinPath(prefix, pathToString(pathNode));
3690
- specs.push(fullPath);
3691
- bindings.push({
3692
- specifier: fullPath,
3693
- importedName: leafOf(fullPath),
3694
- localName: aliasNode.text
3695
- });
3696
- }
3697
- break;
3698
- }
3699
- case "use_list": {
3700
- for (let i = 0; i < node.namedChildCount; i++) {
3701
- const inner = node.namedChild(i);
3702
- if (inner) processUseTree(inner, prefix);
3703
- }
3704
- break;
3705
- }
3706
- case "scoped_use_list": {
3707
- const pathNode = node.childForFieldName("path");
3708
- const listNode = node.childForFieldName("list");
3709
- const newPrefix = pathNode ? joinPath(prefix, pathToString(pathNode)) : prefix;
3710
- if (listNode) {
3711
- for (let i = 0; i < listNode.namedChildCount; i++) {
3712
- const inner = listNode.namedChild(i);
3713
- if (inner) processUseTree(inner, newPrefix);
3714
- }
3715
- }
3716
- break;
3717
- }
3718
- case "use_wildcard": {
3719
- const pathNode = node.childForFieldName("path");
3720
- const fullPath = pathNode ? joinPath(prefix, pathToString(pathNode)) : prefix;
3721
- if (fullPath) {
3722
- specs.push(fullPath);
3723
- bindings.push({
3724
- specifier: fullPath,
3725
- importedName: "*",
3726
- localName: "*"
3727
- });
3728
- }
3729
- break;
3730
- }
3731
- case "identifier":
3732
- case "self":
3733
- case "super":
3734
- case "crate":
3735
- case "scoped_identifier": {
3736
- const leaf = pathToString(node);
3737
- const fullPath = joinPath(prefix, leaf);
3738
- if (fullPath) {
3739
- specs.push(fullPath);
3740
- bindings.push({
3741
- specifier: fullPath,
3742
- importedName: leafOf(fullPath),
3743
- localName: leafOf(fullPath)
3744
- });
3745
- }
3746
- break;
3747
- }
3748
- }
3749
- }
3750
- function pathToString(node) {
3751
- if (node.type === "identifier" || node.type === "crate" || node.type === "self" || node.type === "super") {
3752
- return node.text;
3753
- }
3754
- if (node.type === "scoped_identifier") {
3755
- const path7 = node.childForFieldName("path");
3756
- const name = node.childForFieldName("name");
3757
- const left = path7 ? pathToString(path7) : "";
3758
- const right = name?.text ?? "";
3759
- return left ? `${left}::${right}` : right;
3760
- }
3761
- return node.text;
3762
- }
3763
- function joinPath(prefix, suffix) {
3764
- if (!prefix) return suffix;
3765
- if (!suffix) return prefix;
3766
- return `${prefix}::${suffix}`;
3767
- }
3768
- function leafOf(p) {
3769
- const parts = p.split("::");
3770
- return parts[parts.length - 1] ?? p;
3771
- }
3772
- function visit(node) {
3773
- if (node.type === "use_declaration") {
3774
- walkUse(node);
3775
- return;
3776
- }
3777
- if (node.type === "extern_crate_declaration") {
3778
- const nameNode = node.childForFieldName("name");
3779
- if (nameNode) {
3780
- specs.push(nameNode.text);
3781
- bindings.push({
3782
- specifier: nameNode.text,
3783
- importedName: "*",
3784
- localName: nameNode.text
3785
- });
3786
- }
3787
- return;
3788
- }
3789
- if (node.type === "mod_item") {
3790
- const body = node.childForFieldName("body");
3791
- const nameNode = node.childForFieldName("name");
3792
- if (!body && nameNode) {
3793
- specs.push(nameNode.text);
3794
- }
3795
- return;
3796
- }
3797
- for (let i = 0; i < node.namedChildCount; i++) {
3798
- const c = node.namedChild(i);
3799
- if (c) visit(c);
3800
- }
3801
- }
3802
- visit(rootNode);
3803
- return { specs, bindings };
3804
- }
3805
- function extractRustCallSites(rootNode) {
3806
- const out = [];
3807
- function visit(node) {
3808
- if (node.type === "call_expression") {
3809
- const fn = node.childForFieldName("function");
3810
- const name = calleeLeafName3(fn);
3811
- if (name) {
3812
- const receiverName = receiverRootName3(fn);
3813
- out.push({
3814
- calleeName: name,
3815
- line: node.startPosition.row + 1,
3816
- ...receiverName ? { receiverName } : {}
3817
- });
3818
- }
3819
- } else if (node.type === "method_call_expression") {
3820
- const methodNode = node.childForFieldName("method");
3821
- const receiverNode = node.childForFieldName("value");
3822
- if (methodNode) {
3823
- const receiverName = receiverNode?.type === "identifier" ? receiverNode.text : void 0;
3824
- out.push({
3825
- calleeName: methodNode.text,
3826
- line: node.startPosition.row + 1,
3827
- ...receiverName ? { receiverName } : {}
3828
- });
3829
- }
3830
- }
3831
- for (let i = 0; i < node.childCount; i++) {
3832
- const c = node.child(i);
3833
- if (c) visit(c);
3834
- }
3835
- }
3836
- visit(rootNode);
3837
- return out;
3838
- }
3839
- function calleeLeafName3(node) {
3840
- if (!node) return null;
3841
- if (node.type === "identifier") return node.text;
3842
- if (node.type === "scoped_identifier") {
3843
- const name = node.childForFieldName("name");
3844
- return name?.text ?? null;
3845
- }
3846
- if (node.type === "field_expression") {
3847
- const field = node.childForFieldName("field");
3848
- return field?.text ?? null;
3849
- }
3850
- return null;
3851
- }
3852
- function receiverRootName3(node) {
3853
- if (!node) return void 0;
3854
- if (node.type === "scoped_identifier") {
3855
- let cur = node;
3856
- while (cur) {
3857
- if (cur.type === "identifier") return cur.text;
3858
- if (cur.type === "scoped_identifier") {
3859
- cur = cur.childForFieldName("path");
3860
- continue;
3861
- }
3862
- break;
3863
- }
3864
- }
3865
- if (node.type === "field_expression") {
3866
- const value = node.childForFieldName("value");
3867
- if (value?.type === "identifier") return value.text;
3868
- }
3869
- return void 0;
3870
- }
3871
- function findRustEntryFiles(fileSet) {
3872
- const out = [];
3873
- for (const f of fileSet) {
3874
- if (f === "src/lib.rs" || f === "src/main.rs" || f.endsWith("/src/lib.rs") || f.endsWith("/src/main.rs") || /^src\/bin\/[^/]+\.rs$/.test(f) || /\/src\/bin\/[^/]+\.rs$/.test(f)) {
3875
- out.push(f);
3876
- }
3877
- }
3878
- return out;
3879
- }
3880
- function stripRustCommentsAndStrings(source) {
3881
- return source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").replace(/"(?:\\.|[^"\\\n])*"/g, '""');
3882
- }
3883
- function findFileModDeclarations(source) {
3884
- const cleaned = stripRustCommentsAndStrings(source);
3885
- const out = [];
3886
- const re = /\b(?:pub(?:\s*\([^)]*\))?\s+)?mod\s+(\w+)\s*;/g;
3887
- let m;
3888
- while ((m = re.exec(cleaned)) !== null) {
3889
- out.push(m[1]);
3890
- }
3891
- return out;
3892
- }
3893
- async function buildModTree(cwd, fileSet) {
3894
- const modTree = /* @__PURE__ */ new Map();
3895
- const fileToMod = /* @__PURE__ */ new Map();
3896
- const visited = /* @__PURE__ */ new Set();
3897
- async function walk(modPath, filePath) {
3898
- if (visited.has(filePath)) return;
3899
- visited.add(filePath);
3900
- modTree.set(modPath, filePath);
3901
- fileToMod.set(filePath, modPath);
3902
- let source;
3903
- try {
3904
- source = await fs3.readFile(path5.join(cwd, filePath), "utf8");
3905
- } catch {
3906
- return;
3907
- }
3908
- const childMods = findFileModDeclarations(source);
3909
- if (childMods.length === 0) return;
3910
- const dir = path5.dirname(filePath);
3911
- const baseName = path5.basename(filePath, ".rs");
3912
- const possibleSubdirs = baseName === "mod" || baseName === "lib" || baseName === "main" ? [dir] : [dir, path5.join(dir, baseName)];
3913
- for (const childMod of childMods) {
3914
- const childModPath = `${modPath}::${childMod}`;
3915
- let childFile = null;
3916
- for (const subdir of possibleSubdirs) {
3917
- const candidates = [
3918
- path5.join(subdir, `${childMod}.rs`),
3919
- path5.join(subdir, childMod, "mod.rs")
3920
- ];
3921
- for (const c of candidates) {
3922
- const normalised = c.startsWith("./") ? c.slice(2) : c;
3923
- if (fileSet.has(normalised)) {
3924
- childFile = normalised;
3925
- break;
3926
- }
3927
- }
3928
- if (childFile) break;
3929
- }
3930
- if (childFile) {
3931
- await walk(childModPath, childFile);
3932
- }
3933
- }
3934
- }
3935
- for (const entry of findRustEntryFiles(fileSet)) {
3936
- if (entry === "src/lib.rs" || entry === "src/main.rs") {
3937
- await walk("crate", entry);
3938
- } else if (entry.startsWith("src/bin/")) {
3939
- await walk("crate", entry);
3940
- } else {
3941
- const parts = entry.split("/");
3942
- const memberIdx = parts.indexOf("src");
3943
- if (memberIdx > 0) {
3944
- const memberName = parts[memberIdx - 1];
3945
- await walk(memberName, entry);
3946
- }
3947
- }
3948
- }
3949
- return { modTree, fileToMod };
3950
- }
3951
- function resolveModPath(spec, fromModPath) {
3952
- if (spec.startsWith("crate::")) return spec;
3953
- if (spec === "crate") return "crate";
3954
- if (spec.startsWith("self::")) {
3955
- return `${fromModPath}::${spec.slice("self::".length)}`;
3956
- }
3957
- if (spec === "self") return fromModPath;
3958
- if (spec.startsWith("super::")) {
3959
- let parent = fromModPath;
3960
- let rest = spec;
3961
- while (rest.startsWith("super::")) {
3962
- const lastSep = parent.lastIndexOf("::");
3963
- if (lastSep < 0) return null;
3964
- parent = parent.slice(0, lastSep);
3965
- rest = rest.slice("super::".length);
3966
- }
3967
- if (rest === "super") {
3968
- const lastSep = parent.lastIndexOf("::");
3969
- return lastSep < 0 ? null : parent.slice(0, lastSep);
3970
- }
3971
- return rest ? `${parent}::${rest}` : parent;
3972
- }
3973
- return null;
3974
- }
3975
- var rustHandler = {
3976
- grammarId: "rust",
3977
- extensions: [".rs"],
3978
- extractSymbols(rootNode, _source) {
3979
- const out = [];
3980
- const header = extractRustImportHeader(rootNode);
3981
- if (header) out.push(header);
3982
- const { symbols, pendingImpls } = extractTopLevel2(rootNode);
3983
- out.push(...attachImplMethods(symbols, pendingImpls));
3984
- absorbLeadingComments(rootNode, out);
3985
- out.push(...computeFillerBlocks(rootNode, out));
3986
- return out;
3987
- },
3988
- extractImports(rootNode) {
3989
- return extractRustImports(rootNode);
3990
- },
3991
- extractCallSites(rootNode, _symbols) {
3992
- return extractRustCallSites(rootNode);
3993
- },
3994
- // -------- T3: call graph --------
3995
- async buildProjectContext(cwd, fileSet) {
3996
- const { modTree, fileToMod } = await buildModTree(cwd, fileSet);
3997
- const ctx = { cwd, modTree, fileToMod };
3998
- return ctx;
3999
- },
4000
- resolveSpecifier(spec, fromFilePath, ctx, _fileSet) {
4001
- const c = ctx;
4002
- const fromMod = c.fileToMod.get(fromFilePath);
4003
- if (!fromMod) return null;
4004
- const resolved = resolveModPath(spec, fromMod);
4005
- if (!resolved) return null;
4006
- if (c.modTree.has(resolved)) return c.modTree.get(resolved);
4007
- const segs = resolved.split("::");
4008
- while (segs.length > 1) {
4009
- segs.pop();
4010
- const candidate = segs.join("::");
4011
- const file = c.modTree.get(candidate);
4012
- if (file) return file;
4013
- }
4014
- return null;
4015
- },
4016
- resolveCall(call, from, fromFile, allFiles, _ctx) {
4017
- if (call.receiverName) {
4018
- const recvBinding = fromFile.bindingsByLocalName.get(call.receiverName);
4019
- if (recvBinding) {
4020
- const recvFilePath = fromFile.resolvedImports.get(recvBinding.specifier);
4021
- if (!recvFilePath) {
4022
- return [
4023
- {
4024
- kind: "external",
4025
- name: call.calleeName,
4026
- packageSpec: recvBinding.specifier
4027
- }
4028
- ];
4029
- }
4030
- const targetFile2 = allFiles.get(recvFilePath);
4031
- if (!targetFile2) return [];
4032
- const candidates = targetFile2.symbolsByName.get(call.calleeName);
4033
- if (candidates) {
4034
- for (const s of candidates) {
4035
- if (s.qualifiedName.includes(">")) continue;
4036
- if (!isCallableKind2(s.kind)) continue;
4037
- return [
4038
- {
4039
- kind: "symbol",
4040
- addr: {
4041
- filePath: s.filePath,
4042
- qualifiedName: s.qualifiedName
4043
- }
4044
- }
4045
- ];
4046
- }
4047
- }
4048
- const nestedQname = `${recvBinding.importedName}>${call.calleeName}`;
4049
- const nested = targetFile2.symbolsByQname.get(nestedQname);
4050
- if (nested && isCallableKind2(nested.kind)) {
4051
- return [
4052
- {
4053
- kind: "symbol",
4054
- addr: {
4055
- filePath: nested.filePath,
4056
- qualifiedName: nested.qualifiedName
4057
- }
4058
- }
4059
- ];
4060
- }
4061
- return [
4062
- {
4063
- kind: "method-unresolved",
4064
- receiverName: call.receiverName,
4065
- methodName: call.calleeName
4066
- }
4067
- ];
4068
- }
4069
- const directMethod = `${call.receiverName}>${call.calleeName}`;
4070
- const directHit = fromFile.symbolsByQname.get(directMethod);
4071
- if (directHit) {
4072
- return [
4073
- {
4074
- kind: "symbol",
4075
- addr: {
4076
- filePath: directHit.filePath,
4077
- qualifiedName: directHit.qualifiedName
4078
- }
4079
- }
4080
- ];
4081
- }
4082
- const out = [];
4083
- const allSameName = fromFile.symbolsByName.get(call.calleeName);
4084
- if (allSameName) {
4085
- for (const s of allSameName) {
4086
- if (s.kind !== "method") continue;
4087
- out.push({
4088
- kind: "symbol",
4089
- addr: { filePath: s.filePath, qualifiedName: s.qualifiedName }
4090
- });
4091
- }
4092
- }
4093
- if (out.length > 0) return out;
4094
- return [
4095
- {
4096
- kind: "method-unresolved",
4097
- receiverName: call.receiverName,
4098
- methodName: call.calleeName
4099
- }
4100
- ];
4101
- }
4102
- const local = [];
4103
- const localCandidates = fromFile.symbolsByName.get(call.calleeName);
4104
- if (localCandidates) {
4105
- for (const s of localCandidates) {
4106
- if (s.qualifiedName === from.qualifiedName) continue;
4107
- if (s.qualifiedName.includes(">")) continue;
4108
- if (!isCallableKind2(s.kind)) continue;
4109
- local.push({
4110
- kind: "symbol",
4111
- addr: { filePath: s.filePath, qualifiedName: s.qualifiedName }
4112
- });
4113
- }
4114
- }
4115
- if (local.length > 0) return local;
4116
- const binding = fromFile.bindingsByLocalName.get(call.calleeName);
4117
- if (!binding) return [];
4118
- const targetFile = fromFile.resolvedImports.get(binding.specifier);
4119
- if (!targetFile) {
4120
- return [
4121
- {
4122
- kind: "external",
4123
- name: binding.importedName,
4124
- packageSpec: binding.specifier
4125
- }
4126
- ];
4127
- }
4128
- const target = allFiles.get(targetFile);
4129
- if (!target) return [];
4130
- const targetCandidates = target.symbolsByName.get(binding.importedName);
4131
- let sym;
4132
- if (targetCandidates) {
4133
- for (const s of targetCandidates) {
4134
- if (s.qualifiedName.includes(">")) continue;
4135
- if (!isCallableKind2(s.kind)) continue;
4136
- sym = s;
4137
- break;
4138
- }
4139
- }
4140
- if (!sym) return [];
4141
- return [
4142
- {
4143
- kind: "symbol",
4144
- addr: { filePath: sym.filePath, qualifiedName: sym.qualifiedName }
4145
- }
4146
- ];
4147
- },
4148
- moduleForFile(filePath, ctx) {
4149
- const c = ctx;
4150
- return c?.fileToMod.get(filePath) ?? path5.dirname(filePath);
4151
- }
4152
- };
4153
- function isCallableKind2(k) {
4154
- return k === "function" || k === "class" || k === "method";
4155
- }
4156
-
4157
- // packages/feature/explorer/src/server/codeMap/handlers/index.ts
4158
- registerHandler(typescriptHandler);
4159
- registerHandler(tsxHandler);
4160
- registerHandler(javascriptHandler);
4161
- registerHandler(pythonHandler);
4162
- registerHandler(goHandler);
4163
- registerHandler(rustHandler);
4164
-
4165
- // packages/feature/explorer/src/server/codeMap/projectGraph/codeIndex.ts
4166
- var dirtyCwds = /* @__PURE__ */ new Set();
4167
- var subscribedCwds = /* @__PURE__ */ new Set();
4168
- var watcherSubscriber = null;
4169
- function registerWatcherSubscriber(fn) {
4170
- watcherSubscriber = fn;
4171
- if (fn) {
4172
- for (const cwd of subscribedCwds) {
4173
- fn(cwd, () => dirtyCwds.add(cwd));
4174
- }
4175
- }
4176
- }
4177
- var execAsync2 = promisify2(exec2);
4178
-
4179
- // src/lib/codeIndexSync.ts
4180
- var wired = false;
4181
- function wireCodeIndexToFileWatcher() {
4182
- if (wired) return;
4183
- wired = true;
4184
- registerWatcherSubscriber((cwd, onDirty) => {
4185
- fileWatcher.subscribe(cwd, (events) => {
4186
- if (events.some((e) => e.type === "file" || e.type === "git")) {
4187
- onDirty();
4188
- }
4189
- });
4190
- });
1403
+ });
4191
1404
  }
4192
1405
 
4193
1406
  // src/lib/globalStateBroadcast.ts
4194
1407
  import { WebSocket } from "ws";
4195
- var g2 = globalThis;
4196
- var globalStateClients = g2.__cockpitGlobalStateClients ?? (g2.__cockpitGlobalStateClients = /* @__PURE__ */ new Set());
1408
+ var g = globalThis;
1409
+ var globalStateClients = g.__cockpitGlobalStateClients ?? (g.__cockpitGlobalStateClients = /* @__PURE__ */ new Set());
4197
1410
  function broadcastToGlobalState(msg) {
4198
1411
  const data = JSON.stringify(msg);
4199
1412
  for (const ws of globalStateClients) {