@bloxystudios/bloxycode 1.0.2 → 1.0.4

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
@@ -1,771 +0,0 @@
1
- import { render, useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
2
- import { Clipboard } from "@tui/util/clipboard"
3
- import { TextAttributes } from "@opentui/core"
4
- import { RouteProvider, useRoute } from "@tui/context/route"
5
- import { Switch, Match, createEffect, untrack, ErrorBoundary, createSignal, onMount, batch, Show, on } from "solid-js"
6
- import { Installation } from "@/installation"
7
- import { Flag } from "@/flag/flag"
8
- import { DialogProvider, useDialog } from "@tui/ui/dialog"
9
- import { DialogProvider as DialogProviderList } from "@tui/component/dialog-provider"
10
- import { SDKProvider, useSDK } from "@tui/context/sdk"
11
- import { SyncProvider, useSync } from "@tui/context/sync"
12
- import { LocalProvider, useLocal } from "@tui/context/local"
13
- import { DialogModel, useConnected } from "@tui/component/dialog-model"
14
- import { DialogMcp } from "@tui/component/dialog-mcp"
15
- import { DialogStatus } from "@tui/component/dialog-status"
16
- import { DialogThemeList } from "@tui/component/dialog-theme-list"
17
- import { DialogHelp } from "./ui/dialog-help"
18
- import { CommandProvider, useCommandDialog } from "@tui/component/dialog-command"
19
- import { DialogAgent } from "@tui/component/dialog-agent"
20
- import { DialogSessionList } from "@tui/component/dialog-session-list"
21
- import { KeybindProvider } from "@tui/context/keybind"
22
- import { ThemeProvider, useTheme } from "@tui/context/theme"
23
- import { Home } from "@tui/routes/home"
24
- import { Session } from "@tui/routes/session"
25
- import { PromptHistoryProvider } from "./component/prompt/history"
26
- import { FrecencyProvider } from "./component/prompt/frecency"
27
- import { PromptStashProvider } from "./component/prompt/stash"
28
- import { DialogAlert } from "./ui/dialog-alert"
29
- import { ToastProvider, useToast } from "./ui/toast"
30
- import { ExitProvider, useExit } from "./context/exit"
31
- import { Session as SessionApi } from "@/session"
32
- import { TuiEvent } from "./event"
33
- import { KVProvider, useKV } from "./context/kv"
34
- import { Provider } from "@/provider/provider"
35
- import { ArgsProvider, useArgs, type Args } from "./context/args"
36
- import open from "open"
37
- import { writeHeapSnapshot } from "v8"
38
- import { PromptRefProvider, usePromptRef } from "./context/prompt"
39
-
40
- async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
41
- // can't set raw mode if not a TTY
42
- if (!process.stdin.isTTY) return "dark"
43
-
44
- return new Promise((resolve) => {
45
- let timeout: NodeJS.Timeout
46
-
47
- const cleanup = () => {
48
- process.stdin.setRawMode(false)
49
- process.stdin.removeListener("data", handler)
50
- clearTimeout(timeout)
51
- }
52
-
53
- const handler = (data: Buffer) => {
54
- const str = data.toString()
55
- const match = str.match(/\x1b]11;([^\x07\x1b]+)/)
56
- if (match) {
57
- cleanup()
58
- const color = match[1]
59
- // Parse RGB values from color string
60
- // Formats: rgb:RR/GG/BB or #RRGGBB or rgb(R,G,B)
61
- let r = 0,
62
- g = 0,
63
- b = 0
64
-
65
- if (color.startsWith("rgb:")) {
66
- const parts = color.substring(4).split("/")
67
- r = parseInt(parts[0], 16) >> 8 // Convert 16-bit to 8-bit
68
- g = parseInt(parts[1], 16) >> 8 // Convert 16-bit to 8-bit
69
- b = parseInt(parts[2], 16) >> 8 // Convert 16-bit to 8-bit
70
- } else if (color.startsWith("#")) {
71
- r = parseInt(color.substring(1, 3), 16)
72
- g = parseInt(color.substring(3, 5), 16)
73
- b = parseInt(color.substring(5, 7), 16)
74
- } else if (color.startsWith("rgb(")) {
75
- const parts = color.substring(4, color.length - 1).split(",")
76
- r = parseInt(parts[0])
77
- g = parseInt(parts[1])
78
- b = parseInt(parts[2])
79
- }
80
-
81
- // Calculate luminance using relative luminance formula
82
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
83
-
84
- // Determine if dark or light based on luminance threshold
85
- resolve(luminance > 0.5 ? "light" : "dark")
86
- }
87
- }
88
-
89
- process.stdin.setRawMode(true)
90
- process.stdin.on("data", handler)
91
- process.stdout.write("\x1b]11;?\x07")
92
-
93
- timeout = setTimeout(() => {
94
- cleanup()
95
- resolve("dark")
96
- }, 1000)
97
- })
98
- }
99
-
100
- import type { EventSource } from "./context/sdk"
101
-
102
- export function tui(input: {
103
- url: string
104
- args: Args
105
- directory?: string
106
- fetch?: typeof fetch
107
- events?: EventSource
108
- onExit?: () => Promise<void>
109
- }) {
110
- // promise to prevent immediate exit
111
- return new Promise<void>(async (resolve) => {
112
- const mode = await getTerminalBackgroundColor()
113
- const onExit = async () => {
114
- await input.onExit?.()
115
- resolve()
116
- }
117
-
118
- render(
119
- () => {
120
- return (
121
- <ErrorBoundary
122
- fallback={(error, reset) => <ErrorComponent error={error} reset={reset} onExit={onExit} mode={mode} />}
123
- >
124
- <ArgsProvider {...input.args}>
125
- <ExitProvider onExit={onExit}>
126
- <KVProvider>
127
- <ToastProvider>
128
- <RouteProvider>
129
- <SDKProvider
130
- url={input.url}
131
- directory={input.directory}
132
- fetch={input.fetch}
133
- events={input.events}
134
- >
135
- <SyncProvider>
136
- <ThemeProvider mode={mode}>
137
- <LocalProvider>
138
- <KeybindProvider>
139
- <PromptStashProvider>
140
- <DialogProvider>
141
- <CommandProvider>
142
- <FrecencyProvider>
143
- <PromptHistoryProvider>
144
- <PromptRefProvider>
145
- <App />
146
- </PromptRefProvider>
147
- </PromptHistoryProvider>
148
- </FrecencyProvider>
149
- </CommandProvider>
150
- </DialogProvider>
151
- </PromptStashProvider>
152
- </KeybindProvider>
153
- </LocalProvider>
154
- </ThemeProvider>
155
- </SyncProvider>
156
- </SDKProvider>
157
- </RouteProvider>
158
- </ToastProvider>
159
- </KVProvider>
160
- </ExitProvider>
161
- </ArgsProvider>
162
- </ErrorBoundary>
163
- )
164
- },
165
- {
166
- targetFps: 60,
167
- gatherStats: false,
168
- exitOnCtrlC: false,
169
- useKittyKeyboard: {},
170
- consoleOptions: {
171
- keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
172
- onCopySelection: (text) => {
173
- Clipboard.copy(text).catch((error) => {
174
- console.error(`Failed to copy console selection to clipboard: ${error}`)
175
- })
176
- },
177
- },
178
- },
179
- )
180
- })
181
- }
182
-
183
- function App() {
184
- const route = useRoute()
185
- const dimensions = useTerminalDimensions()
186
- const renderer = useRenderer()
187
- renderer.disableStdoutInterception()
188
- const dialog = useDialog()
189
- const local = useLocal()
190
- const kv = useKV()
191
- const command = useCommandDialog()
192
- const sdk = useSDK()
193
- const toast = useToast()
194
- const { theme, mode, setMode } = useTheme()
195
- const sync = useSync()
196
- const exit = useExit()
197
- const promptRef = usePromptRef()
198
-
199
- // Wire up console copy-to-clipboard via opentui's onCopySelection callback
200
- renderer.console.onCopySelection = async (text: string) => {
201
- if (!text || text.length === 0) return
202
-
203
- await Clipboard.copy(text)
204
- .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
205
- .catch(toast.error)
206
- renderer.clearSelection()
207
- }
208
- const [terminalTitleEnabled, setTerminalTitleEnabled] = createSignal(kv.get("terminal_title_enabled", true))
209
-
210
- createEffect(() => {
211
- console.log(JSON.stringify(route.data))
212
- })
213
-
214
- // Update terminal window title based on current route and session
215
- createEffect(() => {
216
- if (!terminalTitleEnabled() || Flag.BLOXYCODE_DISABLE_TERMINAL_TITLE) return
217
-
218
- if (route.data.type === "home") {
219
- renderer.setTerminalTitle("BloxyCode")
220
- return
221
- }
222
-
223
- if (route.data.type === "session") {
224
- const session = sync.session.get(route.data.sessionID)
225
- if (!session || SessionApi.isDefaultTitle(session.title)) {
226
- renderer.setTerminalTitle("BloxyCode")
227
- return
228
- }
229
-
230
- // Truncate title to 40 chars max
231
- const title = session.title.length > 40 ? session.title.slice(0, 37) + "..." : session.title
232
- renderer.setTerminalTitle(`OC | ${title}`)
233
- }
234
- })
235
-
236
- const args = useArgs()
237
- onMount(() => {
238
- batch(() => {
239
- if (args.agent) local.agent.set(args.agent)
240
- if (args.model) {
241
- const { providerID, modelID } = Provider.parseModel(args.model)
242
- if (!providerID || !modelID)
243
- return toast.show({
244
- variant: "warning",
245
- message: `Invalid model format: ${args.model}`,
246
- duration: 3000,
247
- })
248
- local.model.set({ providerID, modelID }, { recent: true })
249
- }
250
- if (args.sessionID) {
251
- route.navigate({
252
- type: "session",
253
- sessionID: args.sessionID,
254
- })
255
- }
256
- })
257
- })
258
-
259
- let continued = false
260
- createEffect(() => {
261
- // When using -c, session list is loaded in blocking phase, so we can navigate at "partial"
262
- if (continued || sync.status === "loading" || !args.continue) return
263
- const match = sync.data.session
264
- .toSorted((a, b) => b.time.updated - a.time.updated)
265
- .find((x) => x.parentID === undefined)?.id
266
- if (match) {
267
- continued = true
268
- route.navigate({ type: "session", sessionID: match })
269
- }
270
- })
271
-
272
- createEffect(
273
- on(
274
- () => sync.status === "complete" && sync.data.provider.length === 0,
275
- (isEmpty, wasEmpty) => {
276
- // only trigger when we transition into an empty-provider state
277
- if (!isEmpty || wasEmpty) return
278
- dialog.replace(() => <DialogProviderList />)
279
- },
280
- ),
281
- )
282
-
283
- const connected = useConnected()
284
- command.register(() => [
285
- {
286
- title: "Switch session",
287
- value: "session.list",
288
- keybind: "session_list",
289
- category: "Session",
290
- suggested: sync.data.session.length > 0,
291
- slash: {
292
- name: "sessions",
293
- aliases: ["resume", "continue"],
294
- },
295
- onSelect: () => {
296
- dialog.replace(() => <DialogSessionList />)
297
- },
298
- },
299
- {
300
- title: "New session",
301
- suggested: route.data.type === "session",
302
- value: "session.new",
303
- keybind: "session_new",
304
- category: "Session",
305
- slash: {
306
- name: "new",
307
- aliases: ["clear"],
308
- },
309
- onSelect: () => {
310
- const current = promptRef.current
311
- // Don't require focus - if there's any text, preserve it
312
- const currentPrompt = current?.current?.input ? current.current : undefined
313
- route.navigate({
314
- type: "home",
315
- initialPrompt: currentPrompt,
316
- })
317
- dialog.clear()
318
- },
319
- },
320
- {
321
- title: "Switch model",
322
- value: "model.list",
323
- keybind: "model_list",
324
- suggested: true,
325
- category: "Agent",
326
- slash: {
327
- name: "models",
328
- },
329
- onSelect: () => {
330
- dialog.replace(() => <DialogModel />)
331
- },
332
- },
333
- {
334
- title: "Model cycle",
335
- value: "model.cycle_recent",
336
- keybind: "model_cycle_recent",
337
- category: "Agent",
338
- hidden: true,
339
- onSelect: () => {
340
- local.model.cycle(1)
341
- },
342
- },
343
- {
344
- title: "Model cycle reverse",
345
- value: "model.cycle_recent_reverse",
346
- keybind: "model_cycle_recent_reverse",
347
- category: "Agent",
348
- hidden: true,
349
- onSelect: () => {
350
- local.model.cycle(-1)
351
- },
352
- },
353
- {
354
- title: "Favorite cycle",
355
- value: "model.cycle_favorite",
356
- keybind: "model_cycle_favorite",
357
- category: "Agent",
358
- hidden: true,
359
- onSelect: () => {
360
- local.model.cycleFavorite(1)
361
- },
362
- },
363
- {
364
- title: "Favorite cycle reverse",
365
- value: "model.cycle_favorite_reverse",
366
- keybind: "model_cycle_favorite_reverse",
367
- category: "Agent",
368
- hidden: true,
369
- onSelect: () => {
370
- local.model.cycleFavorite(-1)
371
- },
372
- },
373
- {
374
- title: "Switch agent",
375
- value: "agent.list",
376
- keybind: "agent_list",
377
- category: "Agent",
378
- slash: {
379
- name: "agents",
380
- },
381
- onSelect: () => {
382
- dialog.replace(() => <DialogAgent />)
383
- },
384
- },
385
- {
386
- title: "Toggle MCPs",
387
- value: "mcp.list",
388
- category: "Agent",
389
- slash: {
390
- name: "mcps",
391
- },
392
- onSelect: () => {
393
- dialog.replace(() => <DialogMcp />)
394
- },
395
- },
396
- {
397
- title: "Agent cycle",
398
- value: "agent.cycle",
399
- keybind: "agent_cycle",
400
- category: "Agent",
401
- hidden: true,
402
- onSelect: () => {
403
- local.agent.move(1)
404
- },
405
- },
406
- {
407
- title: "Variant cycle",
408
- value: "variant.cycle",
409
- keybind: "variant_cycle",
410
- category: "Agent",
411
- hidden: true,
412
- onSelect: () => {
413
- local.model.variant.cycle()
414
- },
415
- },
416
- {
417
- title: "Agent cycle reverse",
418
- value: "agent.cycle.reverse",
419
- keybind: "agent_cycle_reverse",
420
- category: "Agent",
421
- hidden: true,
422
- onSelect: () => {
423
- local.agent.move(-1)
424
- },
425
- },
426
- {
427
- title: "Connect provider",
428
- value: "provider.connect",
429
- suggested: !connected(),
430
- slash: {
431
- name: "connect",
432
- },
433
- onSelect: () => {
434
- dialog.replace(() => <DialogProviderList />)
435
- },
436
- category: "Provider",
437
- },
438
- {
439
- title: "View status",
440
- keybind: "status_view",
441
- value: "opencode.status",
442
- slash: {
443
- name: "status",
444
- },
445
- onSelect: () => {
446
- dialog.replace(() => <DialogStatus />)
447
- },
448
- category: "System",
449
- },
450
- {
451
- title: "Switch theme",
452
- value: "theme.switch",
453
- keybind: "theme_list",
454
- slash: {
455
- name: "themes",
456
- },
457
- onSelect: () => {
458
- dialog.replace(() => <DialogThemeList />)
459
- },
460
- category: "System",
461
- },
462
- {
463
- title: "Toggle appearance",
464
- value: "theme.switch_mode",
465
- onSelect: (dialog) => {
466
- setMode(mode() === "dark" ? "light" : "dark")
467
- dialog.clear()
468
- },
469
- category: "System",
470
- },
471
- {
472
- title: "Help",
473
- value: "help.show",
474
- slash: {
475
- name: "help",
476
- },
477
- onSelect: () => {
478
- dialog.replace(() => <DialogHelp />)
479
- },
480
- category: "System",
481
- },
482
- {
483
- title: "Open docs",
484
- value: "docs.open",
485
- onSelect: () => {
486
- open("https://opencode.ai/docs").catch(() => {})
487
- dialog.clear()
488
- },
489
- category: "System",
490
- },
491
- {
492
- title: "Exit the app",
493
- value: "app.exit",
494
- slash: {
495
- name: "exit",
496
- aliases: ["quit", "q"],
497
- },
498
- onSelect: () => exit(),
499
- category: "System",
500
- },
501
- {
502
- title: "Toggle debug panel",
503
- category: "System",
504
- value: "app.debug",
505
- onSelect: (dialog) => {
506
- renderer.toggleDebugOverlay()
507
- dialog.clear()
508
- },
509
- },
510
- {
511
- title: "Toggle console",
512
- category: "System",
513
- value: "app.console",
514
- onSelect: (dialog) => {
515
- renderer.console.toggle()
516
- dialog.clear()
517
- },
518
- },
519
- {
520
- title: "Write heap snapshot",
521
- category: "System",
522
- value: "app.heap_snapshot",
523
- onSelect: (dialog) => {
524
- const path = writeHeapSnapshot()
525
- toast.show({
526
- variant: "info",
527
- message: `Heap snapshot written to ${path}`,
528
- duration: 5000,
529
- })
530
- dialog.clear()
531
- },
532
- },
533
- {
534
- title: "Suspend terminal",
535
- value: "terminal.suspend",
536
- keybind: "terminal_suspend",
537
- category: "System",
538
- hidden: true,
539
- onSelect: () => {
540
- process.once("SIGCONT", () => {
541
- renderer.resume()
542
- })
543
-
544
- renderer.suspend()
545
- // pid=0 means send the signal to all processes in the process group
546
- process.kill(0, "SIGTSTP")
547
- },
548
- },
549
- {
550
- title: terminalTitleEnabled() ? "Disable terminal title" : "Enable terminal title",
551
- value: "terminal.title.toggle",
552
- keybind: "terminal_title_toggle",
553
- category: "System",
554
- onSelect: (dialog) => {
555
- setTerminalTitleEnabled((prev) => {
556
- const next = !prev
557
- kv.set("terminal_title_enabled", next)
558
- if (!next) renderer.setTerminalTitle("")
559
- return next
560
- })
561
- dialog.clear()
562
- },
563
- },
564
- {
565
- title: kv.get("animations_enabled", true) ? "Disable animations" : "Enable animations",
566
- value: "app.toggle.animations",
567
- category: "System",
568
- onSelect: (dialog) => {
569
- kv.set("animations_enabled", !kv.get("animations_enabled", true))
570
- dialog.clear()
571
- },
572
- },
573
- {
574
- title: kv.get("diff_wrap_mode", "word") === "word" ? "Disable diff wrapping" : "Enable diff wrapping",
575
- value: "app.toggle.diffwrap",
576
- category: "System",
577
- onSelect: (dialog) => {
578
- const current = kv.get("diff_wrap_mode", "word")
579
- kv.set("diff_wrap_mode", current === "word" ? "none" : "word")
580
- dialog.clear()
581
- },
582
- },
583
- ])
584
-
585
- createEffect(() => {
586
- const currentModel = local.model.current()
587
- if (!currentModel) return
588
- if (currentModel.providerID === "openrouter" && !kv.get("openrouter_warning", false)) {
589
- untrack(() => {
590
- DialogAlert.show(
591
- dialog,
592
- "Warning",
593
- "While openrouter is a convenient way to access LLMs your request will often be routed to subpar providers that do not work well in our testing.\n\nFor reliable access to models check out BloxyCode Zen\nhttps://opencode.ai/zen",
594
- ).then(() => kv.set("openrouter_warning", true))
595
- })
596
- }
597
- })
598
-
599
- sdk.event.on(TuiEvent.CommandExecute.type, (evt) => {
600
- command.trigger(evt.properties.command)
601
- })
602
-
603
- sdk.event.on(TuiEvent.ToastShow.type, (evt) => {
604
- toast.show({
605
- title: evt.properties.title,
606
- message: evt.properties.message,
607
- variant: evt.properties.variant,
608
- duration: evt.properties.duration,
609
- })
610
- })
611
-
612
- sdk.event.on(TuiEvent.SessionSelect.type, (evt) => {
613
- route.navigate({
614
- type: "session",
615
- sessionID: evt.properties.sessionID,
616
- })
617
- })
618
-
619
- sdk.event.on(SessionApi.Event.Deleted.type, (evt) => {
620
- if (route.data.type === "session" && route.data.sessionID === evt.properties.info.id) {
621
- route.navigate({ type: "home" })
622
- toast.show({
623
- variant: "info",
624
- message: "The current session was deleted",
625
- })
626
- }
627
- })
628
-
629
- sdk.event.on(SessionApi.Event.Error.type, (evt) => {
630
- const error = evt.properties.error
631
- if (error && typeof error === "object" && error.name === "MessageAbortedError") return
632
- const message = (() => {
633
- if (!error) return "An error occurred"
634
-
635
- if (typeof error === "object") {
636
- const data = error.data
637
- if ("message" in data && typeof data.message === "string") {
638
- return data.message
639
- }
640
- }
641
- return String(error)
642
- })()
643
-
644
- toast.show({
645
- variant: "error",
646
- message,
647
- duration: 5000,
648
- })
649
- })
650
-
651
- sdk.event.on(Installation.Event.UpdateAvailable.type, (evt) => {
652
- toast.show({
653
- variant: "info",
654
- title: "Update Available",
655
- message: `BloxyCode v${evt.properties.version} is available. Run 'bloxycode upgrade' to update manually.`,
656
- duration: 10000,
657
- })
658
- })
659
-
660
- return (
661
- <box
662
- width={dimensions().width}
663
- height={dimensions().height}
664
- backgroundColor={theme.background}
665
- onMouseUp={async () => {
666
- if (Flag.BLOXYCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) {
667
- renderer.clearSelection()
668
- return
669
- }
670
- const text = renderer.getSelection()?.getSelectedText()
671
- if (text && text.length > 0) {
672
- await Clipboard.copy(text)
673
- .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
674
- .catch(toast.error)
675
- renderer.clearSelection()
676
- }
677
- }}
678
- >
679
- <Switch>
680
- <Match when={route.data.type === "home"}>
681
- <Home />
682
- </Match>
683
- <Match when={route.data.type === "session"}>
684
- <Session />
685
- </Match>
686
- </Switch>
687
- </box>
688
- )
689
- }
690
-
691
- function ErrorComponent(props: {
692
- error: Error
693
- reset: () => void
694
- onExit: () => Promise<void>
695
- mode?: "dark" | "light"
696
- }) {
697
- const term = useTerminalDimensions()
698
- const renderer = useRenderer()
699
-
700
- const handleExit = async () => {
701
- renderer.setTerminalTitle("")
702
- renderer.destroy()
703
- props.onExit()
704
- }
705
-
706
- useKeyboard((evt) => {
707
- if (evt.ctrl && evt.name === "c") {
708
- handleExit()
709
- }
710
- })
711
- const [copied, setCopied] = createSignal(false)
712
-
713
- const issueURL = new URL("https://github.com/bloxystudios/bloxycode/issues/new?template=bug-report.yml")
714
-
715
- // Choose safe fallback colors per mode since theme context may not be available
716
- const isLight = props.mode === "light"
717
- const colors = {
718
- bg: isLight ? "#ffffff" : "#0a0a0a",
719
- text: isLight ? "#1a1a1a" : "#eeeeee",
720
- muted: isLight ? "#8a8a8a" : "#808080",
721
- primary: isLight ? "#3b7dd8" : "#fab283",
722
- }
723
-
724
- if (props.error.message) {
725
- issueURL.searchParams.set("title", `opentui: fatal: ${props.error.message}`)
726
- }
727
-
728
- if (props.error.stack) {
729
- issueURL.searchParams.set(
730
- "description",
731
- "```\n" + props.error.stack.substring(0, 6000 - issueURL.toString().length) + "...\n```",
732
- )
733
- }
734
-
735
- issueURL.searchParams.set("opencode-version", Installation.VERSION)
736
-
737
- const copyIssueURL = () => {
738
- Clipboard.copy(issueURL.toString()).then(() => {
739
- setCopied(true)
740
- })
741
- }
742
-
743
- return (
744
- <box flexDirection="column" gap={1} backgroundColor={colors.bg}>
745
- <box flexDirection="row" gap={1} alignItems="center">
746
- <text attributes={TextAttributes.BOLD} fg={colors.text}>
747
- Please report an issue.
748
- </text>
749
- <box onMouseUp={copyIssueURL} backgroundColor={colors.primary} padding={1}>
750
- <text attributes={TextAttributes.BOLD} fg={colors.bg}>
751
- Copy issue URL (exception info pre-filled)
752
- </text>
753
- </box>
754
- {copied() && <text fg={colors.muted}>Successfully copied</text>}
755
- </box>
756
- <box flexDirection="row" gap={2} alignItems="center">
757
- <text fg={colors.text}>A fatal error occurred!</text>
758
- <box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
759
- <text fg={colors.bg}>Reset TUI</text>
760
- </box>
761
- <box onMouseUp={handleExit} backgroundColor={colors.primary} padding={1}>
762
- <text fg={colors.bg}>Exit</text>
763
- </box>
764
- </box>
765
- <scrollbox height={Math.floor(term().height * 0.7)}>
766
- <text fg={colors.muted}>{props.error.stack}</text>
767
- </scrollbox>
768
- <text fg={colors.text}>{props.error.message}</text>
769
- </box>
770
- )
771
- }