@bloxystudios/bloxycode 1.0.2 → 1.0.5

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 (345) hide show
  1. package/bin/bloxycode +11 -8
  2. package/package.json +16 -143
  3. package/postinstall.mjs +129 -0
  4. package/LICENSE +0 -21
  5. package/README.md +0 -286
  6. package/src/acp/README.md +0 -164
  7. package/src/acp/agent.ts +0 -1437
  8. package/src/acp/session.ts +0 -105
  9. package/src/acp/types.ts +0 -22
  10. package/src/agent/agent.ts +0 -356
  11. package/src/agent/generate.txt +0 -75
  12. package/src/agent/prompt/bloxy.txt +0 -46
  13. package/src/agent/prompt/compaction.txt +0 -12
  14. package/src/agent/prompt/explore.txt +0 -18
  15. package/src/agent/prompt/summary.txt +0 -11
  16. package/src/agent/prompt/title.txt +0 -44
  17. package/src/auth/index.ts +0 -73
  18. package/src/bloxy/event.ts +0 -41
  19. package/src/bloxy/index.ts +0 -5
  20. package/src/bloxy/parser.ts +0 -263
  21. package/src/bloxy/prompt.ts +0 -121
  22. package/src/bloxy/runner.ts +0 -193
  23. package/src/bloxy/state.ts +0 -246
  24. package/src/bun/index.ts +0 -134
  25. package/src/bus/bus-event.ts +0 -43
  26. package/src/bus/global.ts +0 -10
  27. package/src/bus/index.ts +0 -105
  28. package/src/cli/bootstrap.ts +0 -17
  29. package/src/cli/cmd/acp.ts +0 -69
  30. package/src/cli/cmd/agent.ts +0 -257
  31. package/src/cli/cmd/auth.ts +0 -400
  32. package/src/cli/cmd/cmd.ts +0 -7
  33. package/src/cli/cmd/debug/agent.ts +0 -167
  34. package/src/cli/cmd/debug/config.ts +0 -16
  35. package/src/cli/cmd/debug/file.ts +0 -97
  36. package/src/cli/cmd/debug/index.ts +0 -48
  37. package/src/cli/cmd/debug/lsp.ts +0 -52
  38. package/src/cli/cmd/debug/ripgrep.ts +0 -87
  39. package/src/cli/cmd/debug/scrap.ts +0 -16
  40. package/src/cli/cmd/debug/skill.ts +0 -16
  41. package/src/cli/cmd/debug/snapshot.ts +0 -52
  42. package/src/cli/cmd/export.ts +0 -88
  43. package/src/cli/cmd/generate.ts +0 -38
  44. package/src/cli/cmd/github.ts +0 -1548
  45. package/src/cli/cmd/import.ts +0 -98
  46. package/src/cli/cmd/mcp.ts +0 -755
  47. package/src/cli/cmd/models.ts +0 -77
  48. package/src/cli/cmd/pr.ts +0 -112
  49. package/src/cli/cmd/run.ts +0 -395
  50. package/src/cli/cmd/serve.ts +0 -20
  51. package/src/cli/cmd/session.ts +0 -135
  52. package/src/cli/cmd/stats.ts +0 -402
  53. package/src/cli/cmd/tui/app.tsx +0 -771
  54. package/src/cli/cmd/tui/attach.ts +0 -39
  55. package/src/cli/cmd/tui/component/border.tsx +0 -21
  56. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  57. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -148
  58. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  59. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -234
  60. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -256
  61. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -114
  62. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  63. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -87
  64. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -164
  65. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  66. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  67. package/src/cli/cmd/tui/component/logo.tsx +0 -102
  68. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -653
  69. package/src/cli/cmd/tui/component/prompt/frecency.tsx +0 -89
  70. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  71. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1138
  72. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  73. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  74. package/src/cli/cmd/tui/component/tips.tsx +0 -153
  75. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  76. package/src/cli/cmd/tui/context/args.tsx +0 -14
  77. package/src/cli/cmd/tui/context/directory.ts +0 -13
  78. package/src/cli/cmd/tui/context/exit.tsx +0 -23
  79. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  80. package/src/cli/cmd/tui/context/keybind.tsx +0 -101
  81. package/src/cli/cmd/tui/context/kv.tsx +0 -52
  82. package/src/cli/cmd/tui/context/local.tsx +0 -402
  83. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  84. package/src/cli/cmd/tui/context/route.tsx +0 -46
  85. package/src/cli/cmd/tui/context/sdk.tsx +0 -94
  86. package/src/cli/cmd/tui/context/sync.tsx +0 -470
  87. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  88. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  89. package/src/cli/cmd/tui/context/theme/bloxycode.json +0 -245
  90. package/src/cli/cmd/tui/context/theme/carbonfox.json +0 -248
  91. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  92. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  93. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  94. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  95. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  96. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  97. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  98. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  99. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  100. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -242
  101. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  102. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -237
  103. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  104. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  105. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  106. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  107. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  108. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  109. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  110. package/src/cli/cmd/tui/context/theme/orng.json +0 -249
  111. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  112. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  113. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  114. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  115. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  116. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  117. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  118. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  119. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  120. package/src/cli/cmd/tui/context/theme.tsx +0 -1152
  121. package/src/cli/cmd/tui/event.ts +0 -48
  122. package/src/cli/cmd/tui/routes/home.tsx +0 -140
  123. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
  124. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
  125. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  126. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  127. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -91
  128. package/src/cli/cmd/tui/routes/session/header.tsx +0 -142
  129. package/src/cli/cmd/tui/routes/session/index.tsx +0 -2048
  130. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -508
  131. package/src/cli/cmd/tui/routes/session/question.tsx +0 -453
  132. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -313
  133. package/src/cli/cmd/tui/thread.ts +0 -165
  134. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -57
  135. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
  136. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
  137. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
  138. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
  139. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -385
  140. package/src/cli/cmd/tui/ui/dialog.tsx +0 -167
  141. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  142. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  143. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  144. package/src/cli/cmd/tui/util/clipboard.ts +0 -160
  145. package/src/cli/cmd/tui/util/editor.ts +0 -32
  146. package/src/cli/cmd/tui/util/signal.ts +0 -7
  147. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  148. package/src/cli/cmd/tui/util/transcript.ts +0 -98
  149. package/src/cli/cmd/tui/worker.ts +0 -152
  150. package/src/cli/cmd/uninstall.ts +0 -357
  151. package/src/cli/cmd/upgrade.ts +0 -73
  152. package/src/cli/cmd/web.ts +0 -81
  153. package/src/cli/error.ts +0 -57
  154. package/src/cli/network.ts +0 -53
  155. package/src/cli/ui.ts +0 -86
  156. package/src/cli/upgrade.ts +0 -25
  157. package/src/command/index.ts +0 -173
  158. package/src/command/template/bloxy-resume.txt +0 -15
  159. package/src/command/template/bloxy-status.txt +0 -25
  160. package/src/command/template/bloxy-validate.txt +0 -22
  161. package/src/command/template/bloxy.txt +0 -14
  162. package/src/command/template/initialize.txt +0 -10
  163. package/src/command/template/review.txt +0 -99
  164. package/src/config/config.ts +0 -1367
  165. package/src/config/markdown.ts +0 -93
  166. package/src/env/index.ts +0 -26
  167. package/src/file/ignore.ts +0 -83
  168. package/src/file/index.ts +0 -415
  169. package/src/file/ripgrep.ts +0 -407
  170. package/src/file/time.ts +0 -69
  171. package/src/file/watcher.ts +0 -127
  172. package/src/flag/flag.ts +0 -79
  173. package/src/format/formatter.ts +0 -357
  174. package/src/format/index.ts +0 -137
  175. package/src/global/index.ts +0 -55
  176. package/src/id/id.ts +0 -83
  177. package/src/ide/index.ts +0 -76
  178. package/src/index.ts +0 -159
  179. package/src/installation/index.ts +0 -246
  180. package/src/lsp/client.ts +0 -252
  181. package/src/lsp/index.ts +0 -485
  182. package/src/lsp/language.ts +0 -119
  183. package/src/lsp/server.ts +0 -2046
  184. package/src/mcp/auth.ts +0 -135
  185. package/src/mcp/index.ts +0 -934
  186. package/src/mcp/oauth-callback.ts +0 -200
  187. package/src/mcp/oauth-provider.ts +0 -154
  188. package/src/patch/index.ts +0 -680
  189. package/src/permission/arity.ts +0 -163
  190. package/src/permission/index.ts +0 -210
  191. package/src/permission/next.ts +0 -280
  192. package/src/plugin/antigravity.ts +0 -378
  193. package/src/plugin/codex.ts +0 -506
  194. package/src/plugin/copilot.ts +0 -298
  195. package/src/plugin/index.ts +0 -136
  196. package/src/project/bootstrap.ts +0 -35
  197. package/src/project/instance.ts +0 -91
  198. package/src/project/project.ts +0 -371
  199. package/src/project/state.ts +0 -66
  200. package/src/project/vcs.ts +0 -76
  201. package/src/provider/auth.ts +0 -147
  202. package/src/provider/models-snapshot.ts +0 -2
  203. package/src/provider/models.ts +0 -133
  204. package/src/provider/provider.ts +0 -1241
  205. package/src/provider/sdk/openai-compatible/src/README.md +0 -5
  206. package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
  207. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
  208. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
  209. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -22
  210. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
  211. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
  212. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
  213. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1732
  214. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
  215. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
  216. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
  217. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
  218. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
  219. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
  220. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
  221. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
  222. package/src/provider/transform.ts +0 -741
  223. package/src/pty/index.ts +0 -241
  224. package/src/question/index.ts +0 -171
  225. package/src/scheduler/index.ts +0 -61
  226. package/src/server/error.ts +0 -36
  227. package/src/server/event.ts +0 -7
  228. package/src/server/mdns.ts +0 -59
  229. package/src/server/routes/config.ts +0 -92
  230. package/src/server/routes/experimental.ts +0 -208
  231. package/src/server/routes/file.ts +0 -197
  232. package/src/server/routes/global.ts +0 -135
  233. package/src/server/routes/mcp.ts +0 -225
  234. package/src/server/routes/permission.ts +0 -68
  235. package/src/server/routes/project.ts +0 -82
  236. package/src/server/routes/provider.ts +0 -165
  237. package/src/server/routes/pty.ts +0 -169
  238. package/src/server/routes/question.ts +0 -98
  239. package/src/server/routes/session.ts +0 -939
  240. package/src/server/routes/tui.ts +0 -379
  241. package/src/server/server.ts +0 -604
  242. package/src/session/compaction.ts +0 -225
  243. package/src/session/fallback.ts +0 -246
  244. package/src/session/index.ts +0 -498
  245. package/src/session/instruction.ts +0 -164
  246. package/src/session/llm.ts +0 -298
  247. package/src/session/message-v2.ts +0 -747
  248. package/src/session/message.ts +0 -189
  249. package/src/session/processor.ts +0 -450
  250. package/src/session/prompt/anthropic-20250930.txt +0 -166
  251. package/src/session/prompt/anthropic.txt +0 -105
  252. package/src/session/prompt/beast.txt +0 -147
  253. package/src/session/prompt/build-switch.txt +0 -5
  254. package/src/session/prompt/codex_header.txt +0 -79
  255. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  256. package/src/session/prompt/gemini.txt +0 -155
  257. package/src/session/prompt/max-steps.txt +0 -16
  258. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  259. package/src/session/prompt/plan.txt +0 -26
  260. package/src/session/prompt/qwen.txt +0 -109
  261. package/src/session/prompt.ts +0 -1822
  262. package/src/session/retry.ts +0 -99
  263. package/src/session/revert.ts +0 -121
  264. package/src/session/status.ts +0 -100
  265. package/src/session/summary.ts +0 -217
  266. package/src/session/system.ts +0 -52
  267. package/src/session/todo.ts +0 -37
  268. package/src/share/share-next.ts +0 -200
  269. package/src/share/share.ts +0 -92
  270. package/src/shell/shell.ts +0 -67
  271. package/src/skill/index.ts +0 -1
  272. package/src/skill/skill.ts +0 -135
  273. package/src/snapshot/index.ts +0 -236
  274. package/src/storage/storage.ts +0 -227
  275. package/src/tool/apply_patch.ts +0 -281
  276. package/src/tool/apply_patch.txt +0 -33
  277. package/src/tool/bash.ts +0 -258
  278. package/src/tool/bash.txt +0 -115
  279. package/src/tool/batch.ts +0 -175
  280. package/src/tool/batch.txt +0 -24
  281. package/src/tool/bloxy-control.ts +0 -123
  282. package/src/tool/bloxy-control.txt +0 -13
  283. package/src/tool/codesearch.ts +0 -132
  284. package/src/tool/codesearch.txt +0 -12
  285. package/src/tool/edit.ts +0 -655
  286. package/src/tool/edit.txt +0 -10
  287. package/src/tool/external-directory.ts +0 -32
  288. package/src/tool/glob.ts +0 -77
  289. package/src/tool/glob.txt +0 -6
  290. package/src/tool/grep.ts +0 -154
  291. package/src/tool/grep.txt +0 -8
  292. package/src/tool/invalid.ts +0 -17
  293. package/src/tool/ls.ts +0 -121
  294. package/src/tool/ls.txt +0 -1
  295. package/src/tool/lsp.ts +0 -96
  296. package/src/tool/lsp.txt +0 -19
  297. package/src/tool/multiedit.ts +0 -46
  298. package/src/tool/multiedit.txt +0 -41
  299. package/src/tool/plan-enter.txt +0 -14
  300. package/src/tool/plan-exit.txt +0 -13
  301. package/src/tool/plan.ts +0 -130
  302. package/src/tool/question.ts +0 -33
  303. package/src/tool/question.txt +0 -10
  304. package/src/tool/read.ts +0 -211
  305. package/src/tool/read.txt +0 -12
  306. package/src/tool/registry.ts +0 -161
  307. package/src/tool/skill.ts +0 -82
  308. package/src/tool/task.ts +0 -191
  309. package/src/tool/task.txt +0 -60
  310. package/src/tool/todo.ts +0 -53
  311. package/src/tool/todoread.txt +0 -14
  312. package/src/tool/todowrite.txt +0 -167
  313. package/src/tool/tool.ts +0 -89
  314. package/src/tool/truncation.ts +0 -106
  315. package/src/tool/webfetch.ts +0 -188
  316. package/src/tool/webfetch.txt +0 -13
  317. package/src/tool/websearch.ts +0 -150
  318. package/src/tool/websearch.txt +0 -14
  319. package/src/tool/write.ts +0 -85
  320. package/src/tool/write.txt +0 -8
  321. package/src/util/archive.ts +0 -16
  322. package/src/util/binary.ts +0 -41
  323. package/src/util/color.ts +0 -19
  324. package/src/util/context.ts +0 -25
  325. package/src/util/defer.ts +0 -12
  326. package/src/util/error.ts +0 -54
  327. package/src/util/eventloop.ts +0 -20
  328. package/src/util/filesystem.ts +0 -93
  329. package/src/util/fn.ts +0 -11
  330. package/src/util/format.ts +0 -20
  331. package/src/util/iife.ts +0 -3
  332. package/src/util/keybind.ts +0 -103
  333. package/src/util/lazy.ts +0 -23
  334. package/src/util/locale.ts +0 -81
  335. package/src/util/lock.ts +0 -98
  336. package/src/util/log.ts +0 -180
  337. package/src/util/queue.ts +0 -32
  338. package/src/util/rpc.ts +0 -66
  339. package/src/util/scrap.ts +0 -10
  340. package/src/util/signal.ts +0 -12
  341. package/src/util/slug.ts +0 -74
  342. package/src/util/timeout.ts +0 -14
  343. package/src/util/token.ts +0 -7
  344. package/src/util/wildcard.ts +0 -56
  345. package/src/worktree/index.ts +0 -549
package/src/lsp/index.ts DELETED
@@ -1,485 +0,0 @@
1
- import { BusEvent } from "@/bus/bus-event"
2
- import { Bus } from "@/bus"
3
- import { Log } from "../util/log"
4
- import { LSPClient } from "./client"
5
- import path from "path"
6
- import { pathToFileURL } from "url"
7
- import { LSPServer } from "./server"
8
- import z from "zod"
9
- import { Config } from "../config/config"
10
- import { spawn } from "child_process"
11
- import { Instance } from "../project/instance"
12
- import { Flag } from "@/flag/flag"
13
-
14
- export namespace LSP {
15
- const log = Log.create({ service: "lsp" })
16
-
17
- export const Event = {
18
- Updated: BusEvent.define("lsp.updated", z.object({})),
19
- }
20
-
21
- export const Range = z
22
- .object({
23
- start: z.object({
24
- line: z.number(),
25
- character: z.number(),
26
- }),
27
- end: z.object({
28
- line: z.number(),
29
- character: z.number(),
30
- }),
31
- })
32
- .meta({
33
- ref: "Range",
34
- })
35
- export type Range = z.infer<typeof Range>
36
-
37
- export const Symbol = z
38
- .object({
39
- name: z.string(),
40
- kind: z.number(),
41
- location: z.object({
42
- uri: z.string(),
43
- range: Range,
44
- }),
45
- })
46
- .meta({
47
- ref: "Symbol",
48
- })
49
- export type Symbol = z.infer<typeof Symbol>
50
-
51
- export const DocumentSymbol = z
52
- .object({
53
- name: z.string(),
54
- detail: z.string().optional(),
55
- kind: z.number(),
56
- range: Range,
57
- selectionRange: Range,
58
- })
59
- .meta({
60
- ref: "DocumentSymbol",
61
- })
62
- export type DocumentSymbol = z.infer<typeof DocumentSymbol>
63
-
64
- const filterExperimentalServers = (servers: Record<string, LSPServer.Info>) => {
65
- if (Flag.BLOXYCODE_EXPERIMENTAL_LSP_TY) {
66
- // If experimental flag is enabled, disable pyright
67
- if (servers["pyright"]) {
68
- log.info("LSP server pyright is disabled because BLOXYCODE_EXPERIMENTAL_LSP_TY is enabled")
69
- delete servers["pyright"]
70
- }
71
- } else {
72
- // If experimental flag is disabled, disable ty
73
- if (servers["ty"]) {
74
- delete servers["ty"]
75
- }
76
- }
77
- }
78
-
79
- const state = Instance.state(
80
- async () => {
81
- const clients: LSPClient.Info[] = []
82
- const servers: Record<string, LSPServer.Info> = {}
83
- const cfg = await Config.get()
84
-
85
- if (cfg.lsp === false) {
86
- log.info("all LSPs are disabled")
87
- return {
88
- broken: new Set<string>(),
89
- servers,
90
- clients,
91
- spawning: new Map<string, Promise<LSPClient.Info | undefined>>(),
92
- }
93
- }
94
-
95
- for (const server of Object.values(LSPServer)) {
96
- servers[server.id] = server
97
- }
98
-
99
- filterExperimentalServers(servers)
100
-
101
- for (const [name, item] of Object.entries(cfg.lsp ?? {})) {
102
- const existing = servers[name]
103
- if (item.disabled) {
104
- log.info(`LSP server ${name} is disabled`)
105
- delete servers[name]
106
- continue
107
- }
108
- servers[name] = {
109
- ...existing,
110
- id: name,
111
- root: existing?.root ?? (async () => Instance.directory),
112
- extensions: item.extensions ?? existing?.extensions ?? [],
113
- spawn: async (root) => {
114
- return {
115
- process: spawn(item.command[0], item.command.slice(1), {
116
- cwd: root,
117
- env: {
118
- ...process.env,
119
- ...item.env,
120
- },
121
- }),
122
- initialization: item.initialization,
123
- }
124
- },
125
- }
126
- }
127
-
128
- log.info("enabled LSP servers", {
129
- serverIds: Object.values(servers)
130
- .map((server) => server.id)
131
- .join(", "),
132
- })
133
-
134
- return {
135
- broken: new Set<string>(),
136
- servers,
137
- clients,
138
- spawning: new Map<string, Promise<LSPClient.Info | undefined>>(),
139
- }
140
- },
141
- async (state) => {
142
- await Promise.all(state.clients.map((client) => client.shutdown()))
143
- },
144
- )
145
-
146
- export async function init() {
147
- return state()
148
- }
149
-
150
- export const Status = z
151
- .object({
152
- id: z.string(),
153
- name: z.string(),
154
- root: z.string(),
155
- status: z.union([z.literal("connected"), z.literal("error")]),
156
- })
157
- .meta({
158
- ref: "LSPStatus",
159
- })
160
- export type Status = z.infer<typeof Status>
161
-
162
- export async function status() {
163
- return state().then((x) => {
164
- const result: Status[] = []
165
- for (const client of x.clients) {
166
- result.push({
167
- id: client.serverID,
168
- name: x.servers[client.serverID].id,
169
- root: path.relative(Instance.directory, client.root),
170
- status: "connected",
171
- })
172
- }
173
- return result
174
- })
175
- }
176
-
177
- async function getClients(file: string) {
178
- const s = await state()
179
- const extension = path.parse(file).ext || file
180
- const result: LSPClient.Info[] = []
181
-
182
- async function schedule(server: LSPServer.Info, root: string, key: string) {
183
- const handle = await server
184
- .spawn(root)
185
- .then((value) => {
186
- if (!value) s.broken.add(key)
187
- return value
188
- })
189
- .catch((err) => {
190
- s.broken.add(key)
191
- log.error(`Failed to spawn LSP server ${server.id}`, { error: err })
192
- return undefined
193
- })
194
-
195
- if (!handle) return undefined
196
- log.info("spawned lsp server", { serverID: server.id })
197
-
198
- const client = await LSPClient.create({
199
- serverID: server.id,
200
- server: handle,
201
- root,
202
- }).catch((err) => {
203
- s.broken.add(key)
204
- handle.process.kill()
205
- log.error(`Failed to initialize LSP client ${server.id}`, { error: err })
206
- return undefined
207
- })
208
-
209
- if (!client) {
210
- handle.process.kill()
211
- return undefined
212
- }
213
-
214
- const existing = s.clients.find((x) => x.root === root && x.serverID === server.id)
215
- if (existing) {
216
- handle.process.kill()
217
- return existing
218
- }
219
-
220
- s.clients.push(client)
221
- return client
222
- }
223
-
224
- for (const server of Object.values(s.servers)) {
225
- if (server.extensions.length && !server.extensions.includes(extension)) continue
226
-
227
- const root = await server.root(file)
228
- if (!root) continue
229
- if (s.broken.has(root + server.id)) continue
230
-
231
- const match = s.clients.find((x) => x.root === root && x.serverID === server.id)
232
- if (match) {
233
- result.push(match)
234
- continue
235
- }
236
-
237
- const inflight = s.spawning.get(root + server.id)
238
- if (inflight) {
239
- const client = await inflight
240
- if (!client) continue
241
- result.push(client)
242
- continue
243
- }
244
-
245
- const task = schedule(server, root, root + server.id)
246
- s.spawning.set(root + server.id, task)
247
-
248
- task.finally(() => {
249
- if (s.spawning.get(root + server.id) === task) {
250
- s.spawning.delete(root + server.id)
251
- }
252
- })
253
-
254
- const client = await task
255
- if (!client) continue
256
-
257
- result.push(client)
258
- Bus.publish(Event.Updated, {})
259
- }
260
-
261
- return result
262
- }
263
-
264
- export async function hasClients(file: string) {
265
- const s = await state()
266
- const extension = path.parse(file).ext || file
267
- for (const server of Object.values(s.servers)) {
268
- if (server.extensions.length && !server.extensions.includes(extension)) continue
269
- const root = await server.root(file)
270
- if (!root) continue
271
- if (s.broken.has(root + server.id)) continue
272
- return true
273
- }
274
- return false
275
- }
276
-
277
- export async function touchFile(input: string, waitForDiagnostics?: boolean) {
278
- log.info("touching file", { file: input })
279
- const clients = await getClients(input)
280
- await Promise.all(
281
- clients.map(async (client) => {
282
- const wait = waitForDiagnostics ? client.waitForDiagnostics({ path: input }) : Promise.resolve()
283
- await client.notify.open({ path: input })
284
- return wait
285
- }),
286
- ).catch((err) => {
287
- log.error("failed to touch file", { err, file: input })
288
- })
289
- }
290
-
291
- export async function diagnostics() {
292
- const results: Record<string, LSPClient.Diagnostic[]> = {}
293
- for (const result of await runAll(async (client) => client.diagnostics)) {
294
- for (const [path, diagnostics] of result.entries()) {
295
- const arr = results[path] || []
296
- arr.push(...diagnostics)
297
- results[path] = arr
298
- }
299
- }
300
- return results
301
- }
302
-
303
- export async function hover(input: { file: string; line: number; character: number }) {
304
- return run(input.file, (client) => {
305
- return client.connection
306
- .sendRequest("textDocument/hover", {
307
- textDocument: {
308
- uri: pathToFileURL(input.file).href,
309
- },
310
- position: {
311
- line: input.line,
312
- character: input.character,
313
- },
314
- })
315
- .catch(() => null)
316
- })
317
- }
318
-
319
- enum SymbolKind {
320
- File = 1,
321
- Module = 2,
322
- Namespace = 3,
323
- Package = 4,
324
- Class = 5,
325
- Method = 6,
326
- Property = 7,
327
- Field = 8,
328
- Constructor = 9,
329
- Enum = 10,
330
- Interface = 11,
331
- Function = 12,
332
- Variable = 13,
333
- Constant = 14,
334
- String = 15,
335
- Number = 16,
336
- Boolean = 17,
337
- Array = 18,
338
- Object = 19,
339
- Key = 20,
340
- Null = 21,
341
- EnumMember = 22,
342
- Struct = 23,
343
- Event = 24,
344
- Operator = 25,
345
- TypeParameter = 26,
346
- }
347
-
348
- const kinds = [
349
- SymbolKind.Class,
350
- SymbolKind.Function,
351
- SymbolKind.Method,
352
- SymbolKind.Interface,
353
- SymbolKind.Variable,
354
- SymbolKind.Constant,
355
- SymbolKind.Struct,
356
- SymbolKind.Enum,
357
- ]
358
-
359
- export async function workspaceSymbol(query: string) {
360
- return runAll((client) =>
361
- client.connection
362
- .sendRequest("workspace/symbol", {
363
- query,
364
- })
365
- .then((result: any) => result.filter((x: LSP.Symbol) => kinds.includes(x.kind)))
366
- .then((result: any) => result.slice(0, 10))
367
- .catch(() => []),
368
- ).then((result) => result.flat() as LSP.Symbol[])
369
- }
370
-
371
- export async function documentSymbol(uri: string) {
372
- const file = new URL(uri).pathname
373
- return run(file, (client) =>
374
- client.connection
375
- .sendRequest("textDocument/documentSymbol", {
376
- textDocument: {
377
- uri,
378
- },
379
- })
380
- .catch(() => []),
381
- )
382
- .then((result) => result.flat() as (LSP.DocumentSymbol | LSP.Symbol)[])
383
- .then((result) => result.filter(Boolean))
384
- }
385
-
386
- export async function definition(input: { file: string; line: number; character: number }) {
387
- return run(input.file, (client) =>
388
- client.connection
389
- .sendRequest("textDocument/definition", {
390
- textDocument: { uri: pathToFileURL(input.file).href },
391
- position: { line: input.line, character: input.character },
392
- })
393
- .catch(() => null),
394
- ).then((result) => result.flat().filter(Boolean))
395
- }
396
-
397
- export async function references(input: { file: string; line: number; character: number }) {
398
- return run(input.file, (client) =>
399
- client.connection
400
- .sendRequest("textDocument/references", {
401
- textDocument: { uri: pathToFileURL(input.file).href },
402
- position: { line: input.line, character: input.character },
403
- context: { includeDeclaration: true },
404
- })
405
- .catch(() => []),
406
- ).then((result) => result.flat().filter(Boolean))
407
- }
408
-
409
- export async function implementation(input: { file: string; line: number; character: number }) {
410
- return run(input.file, (client) =>
411
- client.connection
412
- .sendRequest("textDocument/implementation", {
413
- textDocument: { uri: pathToFileURL(input.file).href },
414
- position: { line: input.line, character: input.character },
415
- })
416
- .catch(() => null),
417
- ).then((result) => result.flat().filter(Boolean))
418
- }
419
-
420
- export async function prepareCallHierarchy(input: { file: string; line: number; character: number }) {
421
- return run(input.file, (client) =>
422
- client.connection
423
- .sendRequest("textDocument/prepareCallHierarchy", {
424
- textDocument: { uri: pathToFileURL(input.file).href },
425
- position: { line: input.line, character: input.character },
426
- })
427
- .catch(() => []),
428
- ).then((result) => result.flat().filter(Boolean))
429
- }
430
-
431
- export async function incomingCalls(input: { file: string; line: number; character: number }) {
432
- return run(input.file, async (client) => {
433
- const items = (await client.connection
434
- .sendRequest("textDocument/prepareCallHierarchy", {
435
- textDocument: { uri: pathToFileURL(input.file).href },
436
- position: { line: input.line, character: input.character },
437
- })
438
- .catch(() => [])) as any[]
439
- if (!items?.length) return []
440
- return client.connection.sendRequest("callHierarchy/incomingCalls", { item: items[0] }).catch(() => [])
441
- }).then((result) => result.flat().filter(Boolean))
442
- }
443
-
444
- export async function outgoingCalls(input: { file: string; line: number; character: number }) {
445
- return run(input.file, async (client) => {
446
- const items = (await client.connection
447
- .sendRequest("textDocument/prepareCallHierarchy", {
448
- textDocument: { uri: pathToFileURL(input.file).href },
449
- position: { line: input.line, character: input.character },
450
- })
451
- .catch(() => [])) as any[]
452
- if (!items?.length) return []
453
- return client.connection.sendRequest("callHierarchy/outgoingCalls", { item: items[0] }).catch(() => [])
454
- }).then((result) => result.flat().filter(Boolean))
455
- }
456
-
457
- async function runAll<T>(input: (client: LSPClient.Info) => Promise<T>): Promise<T[]> {
458
- const clients = await state().then((x) => x.clients)
459
- const tasks = clients.map((x) => input(x))
460
- return Promise.all(tasks)
461
- }
462
-
463
- async function run<T>(file: string, input: (client: LSPClient.Info) => Promise<T>): Promise<T[]> {
464
- const clients = await getClients(file)
465
- const tasks = clients.map((x) => input(x))
466
- return Promise.all(tasks)
467
- }
468
-
469
- export namespace Diagnostic {
470
- export function pretty(diagnostic: LSPClient.Diagnostic) {
471
- const severityMap = {
472
- 1: "ERROR",
473
- 2: "WARN",
474
- 3: "INFO",
475
- 4: "HINT",
476
- }
477
-
478
- const severity = severityMap[diagnostic.severity || 1]
479
- const line = diagnostic.range.start.line + 1
480
- const col = diagnostic.range.start.character + 1
481
-
482
- return `${severity} [${line}:${col}] ${diagnostic.message}`
483
- }
484
- }
485
- }
@@ -1,119 +0,0 @@
1
- export const LANGUAGE_EXTENSIONS: Record<string, string> = {
2
- ".abap": "abap",
3
- ".bat": "bat",
4
- ".bib": "bibtex",
5
- ".bibtex": "bibtex",
6
- ".clj": "clojure",
7
- ".cljs": "clojure",
8
- ".cljc": "clojure",
9
- ".edn": "clojure",
10
- ".coffee": "coffeescript",
11
- ".c": "c",
12
- ".cpp": "cpp",
13
- ".cxx": "cpp",
14
- ".cc": "cpp",
15
- ".c++": "cpp",
16
- ".cs": "csharp",
17
- ".css": "css",
18
- ".d": "d",
19
- ".pas": "pascal",
20
- ".pascal": "pascal",
21
- ".diff": "diff",
22
- ".patch": "diff",
23
- ".dart": "dart",
24
- ".dockerfile": "dockerfile",
25
- ".ex": "elixir",
26
- ".exs": "elixir",
27
- ".erl": "erlang",
28
- ".ets": "typescript",
29
- ".hrl": "erlang",
30
- ".fs": "fsharp",
31
- ".fsi": "fsharp",
32
- ".fsx": "fsharp",
33
- ".fsscript": "fsharp",
34
- ".gitcommit": "git-commit",
35
- ".gitrebase": "git-rebase",
36
- ".go": "go",
37
- ".groovy": "groovy",
38
- ".gleam": "gleam",
39
- ".hbs": "handlebars",
40
- ".handlebars": "handlebars",
41
- ".hs": "haskell",
42
- ".lhs": "haskell",
43
- ".html": "html",
44
- ".htm": "html",
45
- ".ini": "ini",
46
- ".java": "java",
47
- ".js": "javascript",
48
- ".kt": "kotlin",
49
- ".kts": "kotlin",
50
- ".jsx": "javascriptreact",
51
- ".json": "json",
52
- ".tex": "latex",
53
- ".latex": "latex",
54
- ".less": "less",
55
- ".lua": "lua",
56
- ".makefile": "makefile",
57
- makefile: "makefile",
58
- ".md": "markdown",
59
- ".markdown": "markdown",
60
- ".m": "objective-c",
61
- ".mm": "objective-cpp",
62
- ".pl": "perl",
63
- ".pm": "perl",
64
- ".pm6": "perl6",
65
- ".php": "php",
66
- ".ps1": "powershell",
67
- ".psm1": "powershell",
68
- ".pug": "jade",
69
- ".jade": "jade",
70
- ".py": "python",
71
- ".r": "r",
72
- ".cshtml": "razor",
73
- ".razor": "razor",
74
- ".rb": "ruby",
75
- ".rake": "ruby",
76
- ".gemspec": "ruby",
77
- ".ru": "ruby",
78
- ".erb": "erb",
79
- ".html.erb": "erb",
80
- ".js.erb": "erb",
81
- ".css.erb": "erb",
82
- ".json.erb": "erb",
83
- ".rs": "rust",
84
- ".scss": "scss",
85
- ".sass": "sass",
86
- ".scala": "scala",
87
- ".shader": "shaderlab",
88
- ".sh": "shellscript",
89
- ".bash": "shellscript",
90
- ".zsh": "shellscript",
91
- ".ksh": "shellscript",
92
- ".sql": "sql",
93
- ".svelte": "svelte",
94
- ".swift": "swift",
95
- ".ts": "typescript",
96
- ".tsx": "typescriptreact",
97
- ".mts": "typescript",
98
- ".cts": "typescript",
99
- ".mtsx": "typescriptreact",
100
- ".ctsx": "typescriptreact",
101
- ".xml": "xml",
102
- ".xsl": "xsl",
103
- ".yaml": "yaml",
104
- ".yml": "yaml",
105
- ".mjs": "javascript",
106
- ".cjs": "javascript",
107
- ".vue": "vue",
108
- ".zig": "zig",
109
- ".zon": "zig",
110
- ".astro": "astro",
111
- ".ml": "ocaml",
112
- ".mli": "ocaml",
113
- ".tf": "terraform",
114
- ".tfvars": "terraform-vars",
115
- ".hcl": "hcl",
116
- ".nix": "nix",
117
- ".typ": "typst",
118
- ".typc": "typst",
119
- } as const