jonsoc 1.1.43

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 (420) hide show
  1. package/AGENTS.md +27 -0
  2. package/Dockerfile +18 -0
  3. package/PUBLISHING_GUIDE.md +151 -0
  4. package/README.md +58 -0
  5. package/bin/jonsoc +279 -0
  6. package/bunfig.toml +7 -0
  7. package/package.json +147 -0
  8. package/package.json.placeholder +11 -0
  9. package/parsers-config.ts +253 -0
  10. package/script/build.ts +115 -0
  11. package/script/publish-registries.ts +197 -0
  12. package/script/publish.ts +110 -0
  13. package/script/schema.ts +47 -0
  14. package/script/seed-e2e.ts +50 -0
  15. package/src/acp/README.md +164 -0
  16. package/src/acp/agent.ts +1437 -0
  17. package/src/acp/session.ts +105 -0
  18. package/src/acp/types.ts +22 -0
  19. package/src/agent/agent.ts +347 -0
  20. package/src/agent/generate.txt +75 -0
  21. package/src/agent/prompt/compaction.txt +12 -0
  22. package/src/agent/prompt/explore.txt +18 -0
  23. package/src/agent/prompt/summary.txt +11 -0
  24. package/src/agent/prompt/title.txt +44 -0
  25. package/src/auth/index.ts +73 -0
  26. package/src/brand/index.ts +73 -0
  27. package/src/bun/index.ts +139 -0
  28. package/src/bus/bus-event.ts +43 -0
  29. package/src/bus/global.ts +10 -0
  30. package/src/bus/index.ts +105 -0
  31. package/src/cli/bootstrap.ts +17 -0
  32. package/src/cli/cmd/acp.ts +69 -0
  33. package/src/cli/cmd/agent.ts +257 -0
  34. package/src/cli/cmd/auth.ts +405 -0
  35. package/src/cli/cmd/cmd.ts +7 -0
  36. package/src/cli/cmd/debug/agent.ts +166 -0
  37. package/src/cli/cmd/debug/config.ts +16 -0
  38. package/src/cli/cmd/debug/file.ts +97 -0
  39. package/src/cli/cmd/debug/index.ts +48 -0
  40. package/src/cli/cmd/debug/lsp.ts +52 -0
  41. package/src/cli/cmd/debug/ripgrep.ts +87 -0
  42. package/src/cli/cmd/debug/scrap.ts +16 -0
  43. package/src/cli/cmd/debug/skill.ts +16 -0
  44. package/src/cli/cmd/debug/snapshot.ts +52 -0
  45. package/src/cli/cmd/export.ts +88 -0
  46. package/src/cli/cmd/generate.ts +38 -0
  47. package/src/cli/cmd/github.ts +1548 -0
  48. package/src/cli/cmd/import.ts +99 -0
  49. package/src/cli/cmd/mcp.ts +765 -0
  50. package/src/cli/cmd/models.ts +77 -0
  51. package/src/cli/cmd/pr.ts +112 -0
  52. package/src/cli/cmd/run.ts +395 -0
  53. package/src/cli/cmd/serve.ts +20 -0
  54. package/src/cli/cmd/session.ts +135 -0
  55. package/src/cli/cmd/stats.ts +402 -0
  56. package/src/cli/cmd/tui/app.tsx +923 -0
  57. package/src/cli/cmd/tui/attach.ts +39 -0
  58. package/src/cli/cmd/tui/component/border.tsx +21 -0
  59. package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
  60. package/src/cli/cmd/tui/component/dialog-command.tsx +162 -0
  61. package/src/cli/cmd/tui/component/dialog-error-log.tsx +155 -0
  62. package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
  63. package/src/cli/cmd/tui/component/dialog-model.tsx +234 -0
  64. package/src/cli/cmd/tui/component/dialog-provider.tsx +256 -0
  65. package/src/cli/cmd/tui/component/dialog-session-list.tsx +114 -0
  66. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
  67. package/src/cli/cmd/tui/component/dialog-stash.tsx +87 -0
  68. package/src/cli/cmd/tui/component/dialog-status.tsx +164 -0
  69. package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
  70. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +50 -0
  71. package/src/cli/cmd/tui/component/dynamic-layout.tsx +86 -0
  72. package/src/cli/cmd/tui/component/inspector-overlay.tsx +247 -0
  73. package/src/cli/cmd/tui/component/logo.tsx +88 -0
  74. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +653 -0
  75. package/src/cli/cmd/tui/component/prompt/frecency.tsx +89 -0
  76. package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
  77. package/src/cli/cmd/tui/component/prompt/index.tsx +1347 -0
  78. package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
  79. package/src/cli/cmd/tui/component/textarea-keybindings.ts +73 -0
  80. package/src/cli/cmd/tui/component/tips.tsx +153 -0
  81. package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
  82. package/src/cli/cmd/tui/context/args.tsx +14 -0
  83. package/src/cli/cmd/tui/context/directory.ts +13 -0
  84. package/src/cli/cmd/tui/context/error-log.tsx +56 -0
  85. package/src/cli/cmd/tui/context/exit.tsx +26 -0
  86. package/src/cli/cmd/tui/context/helper.tsx +25 -0
  87. package/src/cli/cmd/tui/context/inspector.tsx +57 -0
  88. package/src/cli/cmd/tui/context/keybind.tsx +108 -0
  89. package/src/cli/cmd/tui/context/kv.tsx +53 -0
  90. package/src/cli/cmd/tui/context/layout.tsx +240 -0
  91. package/src/cli/cmd/tui/context/local.tsx +402 -0
  92. package/src/cli/cmd/tui/context/prompt.tsx +18 -0
  93. package/src/cli/cmd/tui/context/route.tsx +51 -0
  94. package/src/cli/cmd/tui/context/sdk.tsx +94 -0
  95. package/src/cli/cmd/tui/context/sync.tsx +449 -0
  96. package/src/cli/cmd/tui/context/theme/aura.json +69 -0
  97. package/src/cli/cmd/tui/context/theme/ayu.json +80 -0
  98. package/src/cli/cmd/tui/context/theme/carbonfox.json +248 -0
  99. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +233 -0
  100. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +233 -0
  101. package/src/cli/cmd/tui/context/theme/catppuccin.json +112 -0
  102. package/src/cli/cmd/tui/context/theme/cobalt2.json +228 -0
  103. package/src/cli/cmd/tui/context/theme/cursor.json +249 -0
  104. package/src/cli/cmd/tui/context/theme/dracula.json +219 -0
  105. package/src/cli/cmd/tui/context/theme/everforest.json +241 -0
  106. package/src/cli/cmd/tui/context/theme/flexoki.json +237 -0
  107. package/src/cli/cmd/tui/context/theme/github.json +233 -0
  108. package/src/cli/cmd/tui/context/theme/gruvbox.json +242 -0
  109. package/src/cli/cmd/tui/context/theme/jonsoc.json +245 -0
  110. package/src/cli/cmd/tui/context/theme/kanagawa.json +77 -0
  111. package/src/cli/cmd/tui/context/theme/lucent-orng.json +237 -0
  112. package/src/cli/cmd/tui/context/theme/material.json +235 -0
  113. package/src/cli/cmd/tui/context/theme/matrix.json +77 -0
  114. package/src/cli/cmd/tui/context/theme/mercury.json +252 -0
  115. package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
  116. package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
  117. package/src/cli/cmd/tui/context/theme/nord.json +223 -0
  118. package/src/cli/cmd/tui/context/theme/one-dark.json +84 -0
  119. package/src/cli/cmd/tui/context/theme/orng.json +249 -0
  120. package/src/cli/cmd/tui/context/theme/osaka-jade.json +93 -0
  121. package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
  122. package/src/cli/cmd/tui/context/theme/rosepine.json +234 -0
  123. package/src/cli/cmd/tui/context/theme/solarized.json +223 -0
  124. package/src/cli/cmd/tui/context/theme/synthwave84.json +226 -0
  125. package/src/cli/cmd/tui/context/theme/tokyonight.json +243 -0
  126. package/src/cli/cmd/tui/context/theme/vercel.json +245 -0
  127. package/src/cli/cmd/tui/context/theme/vesper.json +218 -0
  128. package/src/cli/cmd/tui/context/theme/zenburn.json +223 -0
  129. package/src/cli/cmd/tui/context/theme.tsx +1153 -0
  130. package/src/cli/cmd/tui/event.ts +48 -0
  131. package/src/cli/cmd/tui/hooks/use-command-registry.tsx +184 -0
  132. package/src/cli/cmd/tui/routes/home.tsx +198 -0
  133. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +64 -0
  134. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +109 -0
  135. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +26 -0
  136. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +47 -0
  137. package/src/cli/cmd/tui/routes/session/footer.tsx +91 -0
  138. package/src/cli/cmd/tui/routes/session/git-commit.tsx +59 -0
  139. package/src/cli/cmd/tui/routes/session/git-history.tsx +122 -0
  140. package/src/cli/cmd/tui/routes/session/header.tsx +185 -0
  141. package/src/cli/cmd/tui/routes/session/index.tsx +2363 -0
  142. package/src/cli/cmd/tui/routes/session/navigator-ui.tsx +214 -0
  143. package/src/cli/cmd/tui/routes/session/navigator.tsx +1124 -0
  144. package/src/cli/cmd/tui/routes/session/panel-explorer.tsx +553 -0
  145. package/src/cli/cmd/tui/routes/session/panel-viewer.tsx +386 -0
  146. package/src/cli/cmd/tui/routes/session/permission.tsx +501 -0
  147. package/src/cli/cmd/tui/routes/session/question.tsx +507 -0
  148. package/src/cli/cmd/tui/routes/session/sidebar.tsx +365 -0
  149. package/src/cli/cmd/tui/routes/session/vcs-diff-viewer.tsx +37 -0
  150. package/src/cli/cmd/tui/routes/ui-settings.tsx +449 -0
  151. package/src/cli/cmd/tui/thread.ts +172 -0
  152. package/src/cli/cmd/tui/ui/dialog-alert.tsx +90 -0
  153. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +83 -0
  154. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +204 -0
  155. package/src/cli/cmd/tui/ui/dialog-help.tsx +38 -0
  156. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +77 -0
  157. package/src/cli/cmd/tui/ui/dialog-select.tsx +384 -0
  158. package/src/cli/cmd/tui/ui/dialog.tsx +170 -0
  159. package/src/cli/cmd/tui/ui/link.tsx +28 -0
  160. package/src/cli/cmd/tui/ui/spinner.ts +375 -0
  161. package/src/cli/cmd/tui/ui/toast.tsx +100 -0
  162. package/src/cli/cmd/tui/util/clipboard.ts +255 -0
  163. package/src/cli/cmd/tui/util/editor.ts +32 -0
  164. package/src/cli/cmd/tui/util/signal.ts +7 -0
  165. package/src/cli/cmd/tui/util/terminal.ts +114 -0
  166. package/src/cli/cmd/tui/util/transcript.ts +98 -0
  167. package/src/cli/cmd/tui/worker.ts +152 -0
  168. package/src/cli/cmd/uninstall.ts +362 -0
  169. package/src/cli/cmd/upgrade.ts +73 -0
  170. package/src/cli/cmd/web.ts +81 -0
  171. package/src/cli/error.ts +57 -0
  172. package/src/cli/network.ts +53 -0
  173. package/src/cli/ui.ts +119 -0
  174. package/src/cli/upgrade.ts +25 -0
  175. package/src/command/index.ts +131 -0
  176. package/src/command/template/initialize.txt +10 -0
  177. package/src/command/template/review.txt +99 -0
  178. package/src/config/config.ts +1404 -0
  179. package/src/config/markdown.ts +93 -0
  180. package/src/env/index.ts +26 -0
  181. package/src/file/ignore.ts +83 -0
  182. package/src/file/index.ts +432 -0
  183. package/src/file/ripgrep.ts +407 -0
  184. package/src/file/time.ts +69 -0
  185. package/src/file/watcher.ts +127 -0
  186. package/src/flag/flag.ts +80 -0
  187. package/src/format/formatter.ts +357 -0
  188. package/src/format/index.ts +137 -0
  189. package/src/global/index.ts +58 -0
  190. package/src/id/id.ts +83 -0
  191. package/src/ide/index.ts +76 -0
  192. package/src/index.ts +208 -0
  193. package/src/installation/index.ts +258 -0
  194. package/src/lsp/client.ts +252 -0
  195. package/src/lsp/index.ts +485 -0
  196. package/src/lsp/language.ts +119 -0
  197. package/src/lsp/server.ts +2046 -0
  198. package/src/mcp/auth.ts +135 -0
  199. package/src/mcp/index.ts +934 -0
  200. package/src/mcp/oauth-callback.ts +200 -0
  201. package/src/mcp/oauth-provider.ts +155 -0
  202. package/src/patch/index.ts +680 -0
  203. package/src/permission/arity.ts +163 -0
  204. package/src/permission/index.ts +210 -0
  205. package/src/permission/next.ts +280 -0
  206. package/src/plugin/codex.ts +500 -0
  207. package/src/plugin/copilot.ts +283 -0
  208. package/src/plugin/index.ts +135 -0
  209. package/src/project/bootstrap.ts +35 -0
  210. package/src/project/instance.ts +91 -0
  211. package/src/project/project.ts +371 -0
  212. package/src/project/state.ts +66 -0
  213. package/src/project/vcs.ts +151 -0
  214. package/src/provider/auth.ts +147 -0
  215. package/src/provider/models-macro.ts +14 -0
  216. package/src/provider/models.ts +114 -0
  217. package/src/provider/provider.ts +1220 -0
  218. package/src/provider/sdk/openai-compatible/src/README.md +5 -0
  219. package/src/provider/sdk/openai-compatible/src/index.ts +2 -0
  220. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +100 -0
  221. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +303 -0
  222. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +22 -0
  223. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +18 -0
  224. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +22 -0
  225. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +207 -0
  226. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +1732 -0
  227. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +177 -0
  228. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +1 -0
  229. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +88 -0
  230. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +128 -0
  231. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +115 -0
  232. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +65 -0
  233. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +104 -0
  234. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +103 -0
  235. package/src/provider/transform.ts +742 -0
  236. package/src/pty/index.ts +241 -0
  237. package/src/question/index.ts +176 -0
  238. package/src/scheduler/index.ts +61 -0
  239. package/src/server/error.ts +36 -0
  240. package/src/server/event.ts +7 -0
  241. package/src/server/mdns.ts +59 -0
  242. package/src/server/routes/config.ts +92 -0
  243. package/src/server/routes/experimental.ts +208 -0
  244. package/src/server/routes/file.ts +227 -0
  245. package/src/server/routes/global.ts +135 -0
  246. package/src/server/routes/mcp.ts +225 -0
  247. package/src/server/routes/permission.ts +68 -0
  248. package/src/server/routes/project.ts +82 -0
  249. package/src/server/routes/provider.ts +165 -0
  250. package/src/server/routes/pty.ts +169 -0
  251. package/src/server/routes/question.ts +98 -0
  252. package/src/server/routes/session.ts +939 -0
  253. package/src/server/routes/tui.ts +379 -0
  254. package/src/server/server.ts +663 -0
  255. package/src/session/compaction.ts +225 -0
  256. package/src/session/index.ts +498 -0
  257. package/src/session/llm.ts +288 -0
  258. package/src/session/message-v2.ts +740 -0
  259. package/src/session/message.ts +189 -0
  260. package/src/session/processor.ts +406 -0
  261. package/src/session/prompt/anthropic-20250930.txt +168 -0
  262. package/src/session/prompt/anthropic.txt +172 -0
  263. package/src/session/prompt/anthropic_spoof.txt +1 -0
  264. package/src/session/prompt/beast.txt +149 -0
  265. package/src/session/prompt/build-switch.txt +5 -0
  266. package/src/session/prompt/codex_header.txt +81 -0
  267. package/src/session/prompt/copilot-gpt-5.txt +145 -0
  268. package/src/session/prompt/gemini.txt +157 -0
  269. package/src/session/prompt/max-steps.txt +16 -0
  270. package/src/session/prompt/plan-reminder-anthropic.txt +67 -0
  271. package/src/session/prompt/plan.txt +26 -0
  272. package/src/session/prompt/qwen.txt +111 -0
  273. package/src/session/prompt.ts +1815 -0
  274. package/src/session/retry.ts +90 -0
  275. package/src/session/revert.ts +121 -0
  276. package/src/session/status.ts +76 -0
  277. package/src/session/summary.ts +150 -0
  278. package/src/session/system.ts +156 -0
  279. package/src/session/todo.ts +37 -0
  280. package/src/share/share-next.ts +204 -0
  281. package/src/share/share.ts +95 -0
  282. package/src/shell/shell.ts +67 -0
  283. package/src/skill/index.ts +1 -0
  284. package/src/skill/skill.ts +135 -0
  285. package/src/snapshot/index.ts +236 -0
  286. package/src/storage/storage.ts +227 -0
  287. package/src/tool/apply_patch.ts +279 -0
  288. package/src/tool/apply_patch.txt +33 -0
  289. package/src/tool/bash.ts +258 -0
  290. package/src/tool/bash.txt +115 -0
  291. package/src/tool/batch.ts +175 -0
  292. package/src/tool/batch.txt +24 -0
  293. package/src/tool/codesearch.ts +132 -0
  294. package/src/tool/codesearch.txt +12 -0
  295. package/src/tool/edit.ts +645 -0
  296. package/src/tool/edit.txt +10 -0
  297. package/src/tool/external-directory.ts +32 -0
  298. package/src/tool/glob.ts +77 -0
  299. package/src/tool/glob.txt +6 -0
  300. package/src/tool/grep.ts +154 -0
  301. package/src/tool/grep.txt +8 -0
  302. package/src/tool/invalid.ts +17 -0
  303. package/src/tool/ls.ts +121 -0
  304. package/src/tool/ls.txt +1 -0
  305. package/src/tool/lsp.ts +96 -0
  306. package/src/tool/lsp.txt +19 -0
  307. package/src/tool/multiedit.ts +46 -0
  308. package/src/tool/multiedit.txt +41 -0
  309. package/src/tool/plan-enter.txt +14 -0
  310. package/src/tool/plan-exit.txt +13 -0
  311. package/src/tool/plan.ts +130 -0
  312. package/src/tool/question.ts +33 -0
  313. package/src/tool/question.txt +10 -0
  314. package/src/tool/read.ts +202 -0
  315. package/src/tool/read.txt +12 -0
  316. package/src/tool/registry.ts +162 -0
  317. package/src/tool/skill.ts +82 -0
  318. package/src/tool/task.ts +188 -0
  319. package/src/tool/task.txt +60 -0
  320. package/src/tool/todo.ts +53 -0
  321. package/src/tool/todoread.txt +14 -0
  322. package/src/tool/todowrite.txt +167 -0
  323. package/src/tool/tool.ts +88 -0
  324. package/src/tool/truncation.ts +106 -0
  325. package/src/tool/webfetch.ts +182 -0
  326. package/src/tool/webfetch.txt +13 -0
  327. package/src/tool/websearch.ts +150 -0
  328. package/src/tool/websearch.txt +14 -0
  329. package/src/tool/write.ts +80 -0
  330. package/src/tool/write.txt +8 -0
  331. package/src/util/archive.ts +16 -0
  332. package/src/util/color.ts +19 -0
  333. package/src/util/context.ts +25 -0
  334. package/src/util/defer.ts +12 -0
  335. package/src/util/eventloop.ts +20 -0
  336. package/src/util/filesystem.ts +93 -0
  337. package/src/util/fn.ts +11 -0
  338. package/src/util/format.ts +20 -0
  339. package/src/util/iife.ts +3 -0
  340. package/src/util/keybind.ts +103 -0
  341. package/src/util/lazy.ts +18 -0
  342. package/src/util/locale.ts +81 -0
  343. package/src/util/lock.ts +98 -0
  344. package/src/util/log.ts +180 -0
  345. package/src/util/queue.ts +32 -0
  346. package/src/util/rpc.ts +66 -0
  347. package/src/util/scrap.ts +10 -0
  348. package/src/util/signal.ts +12 -0
  349. package/src/util/timeout.ts +14 -0
  350. package/src/util/token.ts +7 -0
  351. package/src/util/wildcard.ts +56 -0
  352. package/src/worktree/index.ts +524 -0
  353. package/sst-env.d.ts +9 -0
  354. package/test/acp/agent-interface.test.ts +51 -0
  355. package/test/acp/event-subscription.test.ts +436 -0
  356. package/test/agent/agent.test.ts +638 -0
  357. package/test/bun.test.ts +53 -0
  358. package/test/cli/cmd/tui/fileref.test.ts +30 -0
  359. package/test/cli/github-action.test.ts +129 -0
  360. package/test/cli/github-remote.test.ts +80 -0
  361. package/test/cli/tui/navigator_logic.test.ts +99 -0
  362. package/test/cli/tui/transcript.test.ts +297 -0
  363. package/test/cli/ui.test.ts +80 -0
  364. package/test/config/agent-color.test.ts +66 -0
  365. package/test/config/config.test.ts +1613 -0
  366. package/test/config/fixtures/empty-frontmatter.md +4 -0
  367. package/test/config/fixtures/frontmatter.md +28 -0
  368. package/test/config/fixtures/no-frontmatter.md +1 -0
  369. package/test/config/markdown.test.ts +192 -0
  370. package/test/file/ignore.test.ts +10 -0
  371. package/test/file/path-traversal.test.ts +198 -0
  372. package/test/fixture/fixture.ts +45 -0
  373. package/test/fixture/lsp/fake-lsp-server.js +77 -0
  374. package/test/ide/ide.test.ts +82 -0
  375. package/test/keybind.test.ts +421 -0
  376. package/test/lsp/client.test.ts +95 -0
  377. package/test/mcp/headers.test.ts +153 -0
  378. package/test/mcp/oauth-browser.test.ts +261 -0
  379. package/test/patch/patch.test.ts +348 -0
  380. package/test/permission/arity.test.ts +33 -0
  381. package/test/permission/next.test.ts +690 -0
  382. package/test/permission-task.test.ts +319 -0
  383. package/test/plugin/codex.test.ts +123 -0
  384. package/test/preload.ts +67 -0
  385. package/test/project/project.test.ts +120 -0
  386. package/test/provider/amazon-bedrock.test.ts +268 -0
  387. package/test/provider/gitlab-duo.test.ts +286 -0
  388. package/test/provider/provider.test.ts +2149 -0
  389. package/test/provider/transform.test.ts +1631 -0
  390. package/test/question/question.test.ts +300 -0
  391. package/test/scheduler.test.ts +73 -0
  392. package/test/server/session-list.test.ts +39 -0
  393. package/test/server/session-select.test.ts +78 -0
  394. package/test/session/compaction.test.ts +293 -0
  395. package/test/session/llm.test.ts +90 -0
  396. package/test/session/message-v2.test.ts +786 -0
  397. package/test/session/retry.test.ts +131 -0
  398. package/test/session/revert-compact.test.ts +285 -0
  399. package/test/session/session.test.ts +71 -0
  400. package/test/skill/skill.test.ts +185 -0
  401. package/test/snapshot/snapshot.test.ts +939 -0
  402. package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
  403. package/test/tool/apply_patch.test.ts +499 -0
  404. package/test/tool/bash.test.ts +320 -0
  405. package/test/tool/external-directory.test.ts +126 -0
  406. package/test/tool/fixtures/large-image.png +0 -0
  407. package/test/tool/fixtures/models-api.json +33453 -0
  408. package/test/tool/grep.test.ts +109 -0
  409. package/test/tool/question.test.ts +105 -0
  410. package/test/tool/read.test.ts +332 -0
  411. package/test/tool/registry.test.ts +76 -0
  412. package/test/tool/truncation.test.ts +159 -0
  413. package/test/util/filesystem.test.ts +39 -0
  414. package/test/util/format.test.ts +59 -0
  415. package/test/util/iife.test.ts +36 -0
  416. package/test/util/lazy.test.ts +50 -0
  417. package/test/util/lock.test.ts +72 -0
  418. package/test/util/timeout.test.ts +21 -0
  419. package/test/util/wildcard.test.ts +75 -0
  420. package/tsconfig.json +16 -0
@@ -0,0 +1,1153 @@
1
+ import { SyntaxStyle, RGBA, type TerminalColors } from "@opentui/core"
2
+ import path from "path"
3
+ import { createEffect, createMemo, onMount } from "solid-js"
4
+ import { useSync } from "@tui/context/sync"
5
+ import { createSimpleContext } from "./helper"
6
+ import aura from "./theme/aura.json" with { type: "json" }
7
+ import ayu from "./theme/ayu.json" with { type: "json" }
8
+ import catppuccin from "./theme/catppuccin.json" with { type: "json" }
9
+ import catppuccinFrappe from "./theme/catppuccin-frappe.json" with { type: "json" }
10
+ import catppuccinMacchiato from "./theme/catppuccin-macchiato.json" with { type: "json" }
11
+ import cobalt2 from "./theme/cobalt2.json" with { type: "json" }
12
+ import cursor from "./theme/cursor.json" with { type: "json" }
13
+ import dracula from "./theme/dracula.json" with { type: "json" }
14
+ import everforest from "./theme/everforest.json" with { type: "json" }
15
+ import flexoki from "./theme/flexoki.json" with { type: "json" }
16
+ import github from "./theme/github.json" with { type: "json" }
17
+ import gruvbox from "./theme/gruvbox.json" with { type: "json" }
18
+ import kanagawa from "./theme/kanagawa.json" with { type: "json" }
19
+ import material from "./theme/material.json" with { type: "json" }
20
+ import matrix from "./theme/matrix.json" with { type: "json" }
21
+ import mercury from "./theme/mercury.json" with { type: "json" }
22
+ import monokai from "./theme/monokai.json" with { type: "json" }
23
+ import nightowl from "./theme/nightowl.json" with { type: "json" }
24
+ import nord from "./theme/nord.json" with { type: "json" }
25
+ import osakaJade from "./theme/osaka-jade.json" with { type: "json" }
26
+ import onedark from "./theme/one-dark.json" with { type: "json" }
27
+ import jonsoc from "./theme/jonsoc.json" with { type: "json" }
28
+ import orng from "./theme/orng.json" with { type: "json" }
29
+ import lucentOrng from "./theme/lucent-orng.json" with { type: "json" }
30
+ import palenight from "./theme/palenight.json" with { type: "json" }
31
+ import rosepine from "./theme/rosepine.json" with { type: "json" }
32
+ import solarized from "./theme/solarized.json" with { type: "json" }
33
+ import synthwave84 from "./theme/synthwave84.json" with { type: "json" }
34
+ import tokyonight from "./theme/tokyonight.json" with { type: "json" }
35
+ import vercel from "./theme/vercel.json" with { type: "json" }
36
+ import vesper from "./theme/vesper.json" with { type: "json" }
37
+ import zenburn from "./theme/zenburn.json" with { type: "json" }
38
+ import carbonfox from "./theme/carbonfox.json" with { type: "json" }
39
+ import { useKV } from "./kv"
40
+ import { useRenderer } from "@opentui/solid"
41
+ import { createStore, produce } from "solid-js/store"
42
+ import { Global } from "@/global"
43
+ import { Filesystem } from "@/util/filesystem"
44
+ import { useSDK } from "./sdk"
45
+
46
+ type ThemeColors = {
47
+ primary: RGBA
48
+ secondary: RGBA
49
+ accent: RGBA
50
+ error: RGBA
51
+ warning: RGBA
52
+ success: RGBA
53
+ info: RGBA
54
+ text: RGBA
55
+ textMuted: RGBA
56
+ selectedListItemText: RGBA
57
+ background: RGBA
58
+ backgroundPanel: RGBA
59
+ backgroundElement: RGBA
60
+ backgroundMenu: RGBA
61
+ border: RGBA
62
+ borderActive: RGBA
63
+ borderSubtle: RGBA
64
+ diffAdded: RGBA
65
+ diffRemoved: RGBA
66
+ diffContext: RGBA
67
+ diffHunkHeader: RGBA
68
+ diffHighlightAdded: RGBA
69
+ diffHighlightRemoved: RGBA
70
+ diffAddedBg: RGBA
71
+ diffRemovedBg: RGBA
72
+ diffContextBg: RGBA
73
+ diffLineNumber: RGBA
74
+ diffAddedLineNumberBg: RGBA
75
+ diffRemovedLineNumberBg: RGBA
76
+ markdownText: RGBA
77
+ markdownHeading: RGBA
78
+ markdownLink: RGBA
79
+ markdownLinkText: RGBA
80
+ markdownCode: RGBA
81
+ markdownBlockQuote: RGBA
82
+ markdownEmph: RGBA
83
+ markdownStrong: RGBA
84
+ markdownHorizontalRule: RGBA
85
+ markdownListItem: RGBA
86
+ markdownListEnumeration: RGBA
87
+ markdownImage: RGBA
88
+ markdownImageText: RGBA
89
+ markdownCodeBlock: RGBA
90
+ syntaxComment: RGBA
91
+ syntaxKeyword: RGBA
92
+ syntaxFunction: RGBA
93
+ syntaxVariable: RGBA
94
+ syntaxString: RGBA
95
+ syntaxNumber: RGBA
96
+ syntaxType: RGBA
97
+ syntaxOperator: RGBA
98
+ syntaxPunctuation: RGBA
99
+ }
100
+
101
+ type Theme = ThemeColors & {
102
+ _hasSelectedListItemText: boolean
103
+ thinkingOpacity: number
104
+ }
105
+
106
+ export function selectedForeground(theme: Theme, bg?: RGBA): RGBA {
107
+ // If theme explicitly defines selectedListItemText, use it
108
+ if (theme._hasSelectedListItemText) {
109
+ return theme.selectedListItemText
110
+ }
111
+
112
+ // For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary)
113
+ if (theme.background.a === 0) {
114
+ const targetColor = bg ?? theme.primary
115
+ const { r, g, b } = targetColor
116
+ const luminance = 0.299 * r + 0.587 * g + 0.114 * b
117
+ return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255)
118
+ }
119
+
120
+ // Fall back to background color
121
+ return theme.background
122
+ }
123
+
124
+ type HexColor = `#${string}`
125
+ type RefName = string
126
+ type Variant = {
127
+ dark: HexColor | RefName
128
+ light: HexColor | RefName
129
+ }
130
+ type ColorValue = HexColor | RefName | Variant | RGBA
131
+ type ThemeJson = {
132
+ $schema?: string
133
+ defs?: Record<string, HexColor | RefName>
134
+ theme: Omit<Record<keyof ThemeColors, ColorValue>, "selectedListItemText" | "backgroundMenu"> & {
135
+ selectedListItemText?: ColorValue
136
+ backgroundMenu?: ColorValue
137
+ thinkingOpacity?: number
138
+ }
139
+ }
140
+
141
+ export const DEFAULT_THEMES: Record<string, ThemeJson> = {
142
+ aura,
143
+ ayu,
144
+ catppuccin,
145
+ ["catppuccin-frappe"]: catppuccinFrappe,
146
+ ["catppuccin-macchiato"]: catppuccinMacchiato,
147
+ cobalt2,
148
+ cursor,
149
+ dracula,
150
+ everforest,
151
+ flexoki,
152
+ github,
153
+ gruvbox,
154
+ kanagawa,
155
+ material,
156
+ matrix,
157
+ mercury,
158
+ monokai,
159
+ nightowl,
160
+ nord,
161
+ ["one-dark"]: onedark,
162
+ ["osaka-jade"]: osakaJade,
163
+ jonsoc,
164
+ jonsoc: jonsoc,
165
+ orng,
166
+ ["lucent-orng"]: lucentOrng,
167
+ palenight,
168
+ rosepine,
169
+ solarized,
170
+ synthwave84,
171
+ tokyonight,
172
+ vesper,
173
+ vercel,
174
+ zenburn,
175
+ carbonfox,
176
+ }
177
+
178
+ function resolveTheme(theme: ThemeJson, mode: "dark" | "light") {
179
+ const defs = theme.defs ?? {}
180
+ function resolveColor(c: ColorValue): RGBA {
181
+ if (c instanceof RGBA) return c
182
+ if (typeof c === "string") {
183
+ if (c === "transparent" || c === "none") return RGBA.fromInts(0, 0, 0, 0)
184
+
185
+ if (c.startsWith("#")) return RGBA.fromHex(c)
186
+
187
+ if (defs[c] != null) {
188
+ return resolveColor(defs[c])
189
+ } else if (theme.theme[c as keyof ThemeColors] !== undefined) {
190
+ return resolveColor(theme.theme[c as keyof ThemeColors]!)
191
+ } else {
192
+ throw new Error(`Color reference "${c}" not found in defs or theme`)
193
+ }
194
+ }
195
+ if (typeof c === "number") {
196
+ return ansiToRgba(c)
197
+ }
198
+ return resolveColor(c[mode])
199
+ }
200
+
201
+ const resolved = Object.fromEntries(
202
+ Object.entries(theme.theme)
203
+ .filter(([key]) => key !== "selectedListItemText" && key !== "backgroundMenu" && key !== "thinkingOpacity")
204
+ .map(([key, value]) => {
205
+ return [key, resolveColor(value as ColorValue)]
206
+ }),
207
+ ) as Partial<ThemeColors>
208
+
209
+ // Handle selectedListItemText separately since it's optional
210
+ const hasSelectedListItemText = theme.theme.selectedListItemText !== undefined
211
+ if (hasSelectedListItemText) {
212
+ resolved.selectedListItemText = resolveColor(theme.theme.selectedListItemText!)
213
+ } else {
214
+ // Backward compatibility: if selectedListItemText is not defined, use background color
215
+ // This preserves the current behavior for all existing themes
216
+ resolved.selectedListItemText = resolved.background
217
+ }
218
+
219
+ // Handle backgroundMenu - optional with fallback to backgroundElement
220
+ if (theme.theme.backgroundMenu !== undefined) {
221
+ resolved.backgroundMenu = resolveColor(theme.theme.backgroundMenu)
222
+ } else {
223
+ resolved.backgroundMenu = resolved.backgroundElement
224
+ }
225
+
226
+ // Handle thinkingOpacity - optional with default of 0.6
227
+ const thinkingOpacity = theme.theme.thinkingOpacity ?? 0.6
228
+
229
+ return {
230
+ ...resolved,
231
+ _hasSelectedListItemText: hasSelectedListItemText,
232
+ thinkingOpacity,
233
+ } as Theme
234
+ }
235
+
236
+ function ansiToRgba(code: number): RGBA {
237
+ // Standard ANSI colors (0-15)
238
+ if (code < 16) {
239
+ const ansiColors = [
240
+ "#000000", // Black
241
+ "#800000", // Red
242
+ "#008000", // Green
243
+ "#808000", // Yellow
244
+ "#000080", // Blue
245
+ "#800080", // Magenta
246
+ "#008080", // Cyan
247
+ "#c0c0c0", // White
248
+ "#808080", // Bright Black
249
+ "#ff0000", // Bright Red
250
+ "#00ff00", // Bright Green
251
+ "#ffff00", // Bright Yellow
252
+ "#0000ff", // Bright Blue
253
+ "#ff00ff", // Bright Magenta
254
+ "#00ffff", // Bright Cyan
255
+ "#ffffff", // Bright White
256
+ ]
257
+ return RGBA.fromHex(ansiColors[code] ?? "#000000")
258
+ }
259
+
260
+ // 6x6x6 Color Cube (16-231)
261
+ if (code < 232) {
262
+ const index = code - 16
263
+ const b = index % 6
264
+ const g = Math.floor(index / 6) % 6
265
+ const r = Math.floor(index / 36)
266
+
267
+ const val = (x: number) => (x === 0 ? 0 : x * 40 + 55)
268
+ return RGBA.fromInts(val(r), val(g), val(b))
269
+ }
270
+
271
+ // Grayscale Ramp (232-255)
272
+ if (code < 256) {
273
+ const gray = (code - 232) * 10 + 8
274
+ return RGBA.fromInts(gray, gray, gray)
275
+ }
276
+
277
+ // Fallback for invalid codes
278
+ return RGBA.fromInts(0, 0, 0)
279
+ }
280
+
281
+ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
282
+ name: "Theme",
283
+ init: (props: { mode: "dark" | "light" }) => {
284
+ const sync = useSync()
285
+ const kv = useKV()
286
+ const [store, setStore] = createStore({
287
+ themes: DEFAULT_THEMES,
288
+ mode: kv.get("theme_mode", props.mode),
289
+ active: (sync.data.config.theme ?? kv.get("theme", "jonsoc")) as string,
290
+ ready: false,
291
+ })
292
+
293
+ createEffect(() => {
294
+ const theme = sync.data.config.theme
295
+ if (theme) setStore("active", theme)
296
+ })
297
+
298
+ function init() {
299
+ resolveSystemTheme()
300
+ getCustomThemes()
301
+ .then((custom) => {
302
+ setStore(
303
+ produce((draft) => {
304
+ Object.assign(draft.themes, custom)
305
+ }),
306
+ )
307
+ })
308
+ .catch(() => {
309
+ setStore("active", "jonsoc")
310
+ })
311
+ .finally(() => {
312
+ if (store.active !== "system") {
313
+ setStore("ready", true)
314
+ }
315
+ })
316
+ }
317
+
318
+ onMount(init)
319
+
320
+ function resolveSystemTheme() {
321
+ console.log("resolveSystemTheme")
322
+ renderer
323
+ .getPalette({
324
+ size: 16,
325
+ })
326
+ .then((colors) => {
327
+ console.log(colors.palette)
328
+ if (!colors.palette[0]) {
329
+ if (store.active === "system") {
330
+ setStore(
331
+ produce((draft) => {
332
+ draft.active = "jonsoc"
333
+ draft.ready = true
334
+ }),
335
+ )
336
+ }
337
+ return
338
+ }
339
+ setStore(
340
+ produce((draft) => {
341
+ draft.themes.system = generateSystem(colors, store.mode)
342
+ if (store.active === "system") {
343
+ draft.ready = true
344
+ }
345
+ }),
346
+ )
347
+ })
348
+ }
349
+
350
+ const renderer = useRenderer()
351
+ process.on("SIGUSR2", async () => {
352
+ renderer.clearPaletteCache()
353
+ init()
354
+ })
355
+
356
+ const values = createMemo(() => {
357
+ return resolveTheme(store.themes[store.active] ?? store.themes.jonsoc, store.mode)
358
+ })
359
+
360
+ const syntax = createMemo(() => generateSyntax(values()))
361
+ const subtleSyntax = createMemo(() => generateSubtleSyntax(values()))
362
+
363
+ return {
364
+ theme: new Proxy(values(), {
365
+ get(_target, prop) {
366
+ // @ts-expect-error
367
+ return values()[prop]
368
+ },
369
+ }),
370
+ get selected() {
371
+ return store.active
372
+ },
373
+ all() {
374
+ return store.themes
375
+ },
376
+ syntax,
377
+ subtleSyntax,
378
+ mode() {
379
+ return store.mode
380
+ },
381
+ setMode(mode: "dark" | "light") {
382
+ setStore("mode", mode)
383
+ kv.set("theme_mode", mode)
384
+ },
385
+ set(theme: string) {
386
+ setStore("active", theme)
387
+ kv.set("theme", theme)
388
+ },
389
+ get ready() {
390
+ return store.ready
391
+ },
392
+ }
393
+ },
394
+ })
395
+
396
+ const CUSTOM_THEME_GLOB = new Bun.Glob("themes/*.json")
397
+ async function getCustomThemes() {
398
+ const directories = [
399
+ Global.Path.config,
400
+ ...(await Array.fromAsync(
401
+ Filesystem.up({
402
+ targets: [".jonsoc", ".jonsoc"],
403
+ start: process.cwd(),
404
+ }),
405
+ )),
406
+ ]
407
+
408
+ const result: Record<string, ThemeJson> = {}
409
+ for (const dir of directories) {
410
+ for await (const item of CUSTOM_THEME_GLOB.scan({
411
+ absolute: true,
412
+ followSymlinks: true,
413
+ dot: true,
414
+ cwd: dir,
415
+ })) {
416
+ const name = path.basename(item, ".json")
417
+ result[name] = await Bun.file(item).json()
418
+ }
419
+ }
420
+ return result
421
+ }
422
+
423
+ export function tint(base: RGBA, overlay: RGBA, alpha: number): RGBA {
424
+ const r = base.r + (overlay.r - base.r) * alpha
425
+ const g = base.g + (overlay.g - base.g) * alpha
426
+ const b = base.b + (overlay.b - base.b) * alpha
427
+ return RGBA.fromInts(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255))
428
+ }
429
+
430
+ function generateSystem(colors: TerminalColors, mode: "dark" | "light"): ThemeJson {
431
+ const bg = RGBA.fromHex(colors.defaultBackground ?? colors.palette[0]!)
432
+ const fg = RGBA.fromHex(colors.defaultForeground ?? colors.palette[7]!)
433
+ const isDark = mode == "dark"
434
+
435
+ const col = (i: number) => {
436
+ const value = colors.palette[i]
437
+ if (value) return RGBA.fromHex(value)
438
+ return ansiToRgba(i)
439
+ }
440
+
441
+ // Generate gray scale based on terminal background
442
+ const grays = generateGrayScale(bg, isDark)
443
+ const textMuted = generateMutedTextColor(bg, isDark)
444
+
445
+ // ANSI color references
446
+ const ansiColors = {
447
+ black: col(0),
448
+ red: col(1),
449
+ green: col(2),
450
+ yellow: col(3),
451
+ blue: col(4),
452
+ magenta: col(5),
453
+ cyan: col(6),
454
+ white: col(7),
455
+ redBright: col(9),
456
+ greenBright: col(10),
457
+ }
458
+
459
+ const diffAlpha = isDark ? 0.22 : 0.14
460
+ const diffAddedBg = tint(bg, ansiColors.green, diffAlpha)
461
+ const diffRemovedBg = tint(bg, ansiColors.red, diffAlpha)
462
+ const diffAddedLineNumberBg = tint(grays[3], ansiColors.green, diffAlpha)
463
+ const diffRemovedLineNumberBg = tint(grays[3], ansiColors.red, diffAlpha)
464
+
465
+ return {
466
+ theme: {
467
+ // Primary colors using ANSI
468
+ primary: ansiColors.cyan,
469
+ secondary: ansiColors.magenta,
470
+ accent: ansiColors.cyan,
471
+
472
+ // Status colors using ANSI
473
+ error: ansiColors.red,
474
+ warning: ansiColors.yellow,
475
+ success: ansiColors.green,
476
+ info: ansiColors.cyan,
477
+
478
+ // Text colors
479
+ text: fg,
480
+ textMuted,
481
+ selectedListItemText: bg,
482
+
483
+ // Background colors
484
+ background: bg,
485
+ backgroundPanel: grays[2],
486
+ backgroundElement: grays[3],
487
+ backgroundMenu: grays[3],
488
+
489
+ // Border colors
490
+ borderSubtle: grays[6],
491
+ border: grays[7],
492
+ borderActive: grays[8],
493
+
494
+ // Diff colors
495
+ diffAdded: ansiColors.green,
496
+ diffRemoved: ansiColors.red,
497
+ diffContext: grays[7],
498
+ diffHunkHeader: grays[7],
499
+ diffHighlightAdded: ansiColors.greenBright,
500
+ diffHighlightRemoved: ansiColors.redBright,
501
+ diffAddedBg,
502
+ diffRemovedBg,
503
+ diffContextBg: grays[1],
504
+ diffLineNumber: grays[6],
505
+ diffAddedLineNumberBg,
506
+ diffRemovedLineNumberBg,
507
+
508
+ // Markdown colors
509
+ markdownText: fg,
510
+ markdownHeading: fg,
511
+ markdownLink: ansiColors.blue,
512
+ markdownLinkText: ansiColors.cyan,
513
+ markdownCode: ansiColors.green,
514
+ markdownBlockQuote: ansiColors.yellow,
515
+ markdownEmph: ansiColors.yellow,
516
+ markdownStrong: fg,
517
+ markdownHorizontalRule: grays[7],
518
+ markdownListItem: ansiColors.blue,
519
+ markdownListEnumeration: ansiColors.cyan,
520
+ markdownImage: ansiColors.blue,
521
+ markdownImageText: ansiColors.cyan,
522
+ markdownCodeBlock: fg,
523
+
524
+ // Syntax colors
525
+ syntaxComment: textMuted,
526
+ syntaxKeyword: ansiColors.magenta,
527
+ syntaxFunction: ansiColors.blue,
528
+ syntaxVariable: fg,
529
+ syntaxString: ansiColors.green,
530
+ syntaxNumber: ansiColors.yellow,
531
+ syntaxType: ansiColors.cyan,
532
+ syntaxOperator: ansiColors.cyan,
533
+ syntaxPunctuation: fg,
534
+ },
535
+ }
536
+ }
537
+
538
+ function generateGrayScale(bg: RGBA, isDark: boolean): Record<number, RGBA> {
539
+ const grays: Record<number, RGBA> = {}
540
+
541
+ // RGBA stores floats in range 0-1, convert to 0-255
542
+ const bgR = bg.r * 255
543
+ const bgG = bg.g * 255
544
+ const bgB = bg.b * 255
545
+
546
+ const luminance = 0.299 * bgR + 0.587 * bgG + 0.114 * bgB
547
+
548
+ for (let i = 1; i <= 12; i++) {
549
+ const factor = i / 12.0
550
+
551
+ let grayValue: number
552
+ let newR: number
553
+ let newG: number
554
+ let newB: number
555
+
556
+ if (isDark) {
557
+ if (luminance < 10) {
558
+ grayValue = Math.floor(factor * 0.4 * 255)
559
+ newR = grayValue
560
+ newG = grayValue
561
+ newB = grayValue
562
+ } else {
563
+ const newLum = luminance + (255 - luminance) * factor * 0.4
564
+
565
+ const ratio = newLum / luminance
566
+ newR = Math.min(bgR * ratio, 255)
567
+ newG = Math.min(bgG * ratio, 255)
568
+ newB = Math.min(bgB * ratio, 255)
569
+ }
570
+ } else {
571
+ if (luminance > 245) {
572
+ grayValue = Math.floor(255 - factor * 0.4 * 255)
573
+ newR = grayValue
574
+ newG = grayValue
575
+ newB = grayValue
576
+ } else {
577
+ const newLum = luminance * (1 - factor * 0.4)
578
+
579
+ const ratio = newLum / luminance
580
+ newR = Math.max(bgR * ratio, 0)
581
+ newG = Math.max(bgG * ratio, 0)
582
+ newB = Math.max(bgB * ratio, 0)
583
+ }
584
+ }
585
+
586
+ grays[i] = RGBA.fromInts(Math.floor(newR), Math.floor(newG), Math.floor(newB))
587
+ }
588
+
589
+ return grays
590
+ }
591
+
592
+ function generateMutedTextColor(bg: RGBA, isDark: boolean): RGBA {
593
+ // RGBA stores floats in range 0-1, convert to 0-255
594
+ const bgR = bg.r * 255
595
+ const bgG = bg.g * 255
596
+ const bgB = bg.b * 255
597
+
598
+ const bgLum = 0.299 * bgR + 0.587 * bgG + 0.114 * bgB
599
+
600
+ let grayValue: number
601
+
602
+ if (isDark) {
603
+ if (bgLum < 10) {
604
+ // Very dark/black background
605
+ grayValue = 180 // #b4b4b4
606
+ } else {
607
+ // Scale up for lighter dark backgrounds
608
+ grayValue = Math.min(Math.floor(160 + bgLum * 0.3), 200)
609
+ }
610
+ } else {
611
+ if (bgLum > 245) {
612
+ // Very light/white background
613
+ grayValue = 75 // #4b4b4b
614
+ } else {
615
+ // Scale down for darker light backgrounds
616
+ grayValue = Math.max(Math.floor(100 - (255 - bgLum) * 0.2), 60)
617
+ }
618
+ }
619
+
620
+ return RGBA.fromInts(grayValue, grayValue, grayValue)
621
+ }
622
+
623
+ function generateSyntax(theme: Theme) {
624
+ return SyntaxStyle.fromTheme(getSyntaxRules(theme))
625
+ }
626
+
627
+ function generateSubtleSyntax(theme: Theme) {
628
+ const rules = getSyntaxRules(theme)
629
+ return SyntaxStyle.fromTheme(
630
+ rules.map((rule) => {
631
+ if (rule.style.foreground) {
632
+ const fg = rule.style.foreground
633
+ return {
634
+ ...rule,
635
+ style: {
636
+ ...rule.style,
637
+ foreground: RGBA.fromInts(
638
+ Math.round(fg.r * 255),
639
+ Math.round(fg.g * 255),
640
+ Math.round(fg.b * 255),
641
+ Math.round(theme.thinkingOpacity * 255),
642
+ ),
643
+ },
644
+ }
645
+ }
646
+ return rule
647
+ }),
648
+ )
649
+ }
650
+
651
+ function getSyntaxRules(theme: Theme) {
652
+ return [
653
+ {
654
+ scope: ["default"],
655
+ style: {
656
+ foreground: theme.text,
657
+ },
658
+ },
659
+ {
660
+ scope: ["prompt"],
661
+ style: {
662
+ foreground: theme.accent,
663
+ },
664
+ },
665
+ {
666
+ scope: ["extmark.file"],
667
+ style: {
668
+ foreground: theme.warning,
669
+ bold: true,
670
+ },
671
+ },
672
+ {
673
+ scope: ["extmark.agent"],
674
+ style: {
675
+ foreground: theme.secondary,
676
+ bold: true,
677
+ },
678
+ },
679
+ {
680
+ scope: ["extmark.paste"],
681
+ style: {
682
+ foreground: theme.background,
683
+ background: theme.warning,
684
+ bold: true,
685
+ },
686
+ },
687
+ {
688
+ scope: ["comment"],
689
+ style: {
690
+ foreground: theme.syntaxComment,
691
+ italic: true,
692
+ },
693
+ },
694
+ {
695
+ scope: ["comment.documentation"],
696
+ style: {
697
+ foreground: theme.syntaxComment,
698
+ italic: true,
699
+ },
700
+ },
701
+ {
702
+ scope: ["string", "symbol"],
703
+ style: {
704
+ foreground: theme.syntaxString,
705
+ },
706
+ },
707
+ {
708
+ scope: ["number", "boolean"],
709
+ style: {
710
+ foreground: theme.syntaxNumber,
711
+ },
712
+ },
713
+ {
714
+ scope: ["character.special"],
715
+ style: {
716
+ foreground: theme.syntaxString,
717
+ },
718
+ },
719
+ {
720
+ scope: ["keyword.return", "keyword.conditional", "keyword.repeat", "keyword.coroutine"],
721
+ style: {
722
+ foreground: theme.syntaxKeyword,
723
+ italic: true,
724
+ },
725
+ },
726
+ {
727
+ scope: ["keyword.type"],
728
+ style: {
729
+ foreground: theme.syntaxType,
730
+ bold: true,
731
+ italic: true,
732
+ },
733
+ },
734
+ {
735
+ scope: ["keyword.function", "function.method"],
736
+ style: {
737
+ foreground: theme.syntaxFunction,
738
+ },
739
+ },
740
+ {
741
+ scope: ["keyword"],
742
+ style: {
743
+ foreground: theme.syntaxKeyword,
744
+ italic: true,
745
+ },
746
+ },
747
+ {
748
+ scope: ["keyword.import"],
749
+ style: {
750
+ foreground: theme.syntaxKeyword,
751
+ },
752
+ },
753
+ {
754
+ scope: ["operator", "keyword.operator", "punctuation.delimiter"],
755
+ style: {
756
+ foreground: theme.syntaxOperator,
757
+ },
758
+ },
759
+ {
760
+ scope: ["keyword.conditional.ternary"],
761
+ style: {
762
+ foreground: theme.syntaxOperator,
763
+ },
764
+ },
765
+ {
766
+ scope: ["variable", "variable.parameter", "function.method.call", "function.call"],
767
+ style: {
768
+ foreground: theme.syntaxVariable,
769
+ },
770
+ },
771
+ {
772
+ scope: ["variable.member", "function", "constructor"],
773
+ style: {
774
+ foreground: theme.syntaxFunction,
775
+ },
776
+ },
777
+ {
778
+ scope: ["type", "module"],
779
+ style: {
780
+ foreground: theme.syntaxType,
781
+ },
782
+ },
783
+ {
784
+ scope: ["constant"],
785
+ style: {
786
+ foreground: theme.syntaxNumber,
787
+ },
788
+ },
789
+ {
790
+ scope: ["property"],
791
+ style: {
792
+ foreground: theme.syntaxVariable,
793
+ },
794
+ },
795
+ {
796
+ scope: ["class"],
797
+ style: {
798
+ foreground: theme.syntaxType,
799
+ },
800
+ },
801
+ {
802
+ scope: ["parameter"],
803
+ style: {
804
+ foreground: theme.syntaxVariable,
805
+ },
806
+ },
807
+ {
808
+ scope: ["punctuation", "punctuation.bracket"],
809
+ style: {
810
+ foreground: theme.syntaxPunctuation,
811
+ },
812
+ },
813
+ {
814
+ scope: ["variable.builtin", "type.builtin", "function.builtin", "module.builtin", "constant.builtin"],
815
+ style: {
816
+ foreground: theme.error,
817
+ },
818
+ },
819
+ {
820
+ scope: ["variable.super"],
821
+ style: {
822
+ foreground: theme.error,
823
+ },
824
+ },
825
+ {
826
+ scope: ["string.escape", "string.regexp"],
827
+ style: {
828
+ foreground: theme.syntaxKeyword,
829
+ },
830
+ },
831
+ {
832
+ scope: ["keyword.directive"],
833
+ style: {
834
+ foreground: theme.syntaxKeyword,
835
+ italic: true,
836
+ },
837
+ },
838
+ {
839
+ scope: ["punctuation.special"],
840
+ style: {
841
+ foreground: theme.syntaxOperator,
842
+ },
843
+ },
844
+ {
845
+ scope: ["keyword.modifier"],
846
+ style: {
847
+ foreground: theme.syntaxKeyword,
848
+ italic: true,
849
+ },
850
+ },
851
+ {
852
+ scope: ["keyword.exception"],
853
+ style: {
854
+ foreground: theme.syntaxKeyword,
855
+ italic: true,
856
+ },
857
+ },
858
+ // Markdown specific styles
859
+ {
860
+ scope: ["markup.heading"],
861
+ style: {
862
+ foreground: theme.markdownHeading,
863
+ bold: true,
864
+ },
865
+ },
866
+ {
867
+ scope: ["markup.heading.1"],
868
+ style: {
869
+ foreground: theme.markdownHeading,
870
+ bold: true,
871
+ },
872
+ },
873
+ {
874
+ scope: ["markup.heading.2"],
875
+ style: {
876
+ foreground: theme.markdownHeading,
877
+ bold: true,
878
+ },
879
+ },
880
+ {
881
+ scope: ["markup.heading.3"],
882
+ style: {
883
+ foreground: theme.markdownHeading,
884
+ bold: true,
885
+ },
886
+ },
887
+ {
888
+ scope: ["markup.heading.4"],
889
+ style: {
890
+ foreground: theme.markdownHeading,
891
+ bold: true,
892
+ },
893
+ },
894
+ {
895
+ scope: ["markup.heading.5"],
896
+ style: {
897
+ foreground: theme.markdownHeading,
898
+ bold: true,
899
+ },
900
+ },
901
+ {
902
+ scope: ["markup.heading.6"],
903
+ style: {
904
+ foreground: theme.markdownHeading,
905
+ bold: true,
906
+ },
907
+ },
908
+ {
909
+ scope: ["markup.bold", "markup.strong"],
910
+ style: {
911
+ foreground: theme.markdownStrong,
912
+ bold: true,
913
+ },
914
+ },
915
+ {
916
+ scope: ["markup.italic"],
917
+ style: {
918
+ foreground: theme.markdownEmph,
919
+ italic: true,
920
+ },
921
+ },
922
+ {
923
+ scope: ["markup.list"],
924
+ style: {
925
+ foreground: theme.markdownListItem,
926
+ },
927
+ },
928
+ {
929
+ scope: ["markup.quote"],
930
+ style: {
931
+ foreground: theme.markdownBlockQuote,
932
+ italic: true,
933
+ },
934
+ },
935
+ {
936
+ scope: ["markup.raw", "markup.raw.block"],
937
+ style: {
938
+ foreground: theme.markdownCode,
939
+ },
940
+ },
941
+ {
942
+ scope: ["markup.raw.inline"],
943
+ style: {
944
+ foreground: theme.markdownCode,
945
+ background: theme.background,
946
+ },
947
+ },
948
+ {
949
+ scope: ["markup.link"],
950
+ style: {
951
+ foreground: theme.markdownLink,
952
+ underline: true,
953
+ },
954
+ },
955
+ {
956
+ scope: ["markup.link.label"],
957
+ style: {
958
+ foreground: theme.markdownLinkText,
959
+ underline: true,
960
+ },
961
+ },
962
+ {
963
+ scope: ["markup.link.url"],
964
+ style: {
965
+ foreground: theme.markdownLink,
966
+ underline: true,
967
+ },
968
+ },
969
+ {
970
+ scope: ["label"],
971
+ style: {
972
+ foreground: theme.markdownLinkText,
973
+ },
974
+ },
975
+ {
976
+ scope: ["spell", "nospell"],
977
+ style: {
978
+ foreground: theme.text,
979
+ },
980
+ },
981
+ {
982
+ scope: ["conceal"],
983
+ style: {
984
+ foreground: theme.textMuted,
985
+ },
986
+ },
987
+ // Additional common highlight groups
988
+ {
989
+ scope: ["string.special", "string.special.url"],
990
+ style: {
991
+ foreground: theme.markdownLink,
992
+ underline: true,
993
+ },
994
+ },
995
+ {
996
+ scope: ["character"],
997
+ style: {
998
+ foreground: theme.syntaxString,
999
+ },
1000
+ },
1001
+ {
1002
+ scope: ["float"],
1003
+ style: {
1004
+ foreground: theme.syntaxNumber,
1005
+ },
1006
+ },
1007
+ {
1008
+ scope: ["comment.error"],
1009
+ style: {
1010
+ foreground: theme.error,
1011
+ italic: true,
1012
+ bold: true,
1013
+ },
1014
+ },
1015
+ {
1016
+ scope: ["comment.warning"],
1017
+ style: {
1018
+ foreground: theme.warning,
1019
+ italic: true,
1020
+ bold: true,
1021
+ },
1022
+ },
1023
+ {
1024
+ scope: ["comment.todo", "comment.note"],
1025
+ style: {
1026
+ foreground: theme.info,
1027
+ italic: true,
1028
+ bold: true,
1029
+ },
1030
+ },
1031
+ {
1032
+ scope: ["namespace"],
1033
+ style: {
1034
+ foreground: theme.syntaxType,
1035
+ },
1036
+ },
1037
+ {
1038
+ scope: ["field"],
1039
+ style: {
1040
+ foreground: theme.syntaxVariable,
1041
+ },
1042
+ },
1043
+ {
1044
+ scope: ["type.definition"],
1045
+ style: {
1046
+ foreground: theme.syntaxType,
1047
+ bold: true,
1048
+ },
1049
+ },
1050
+ {
1051
+ scope: ["keyword.export"],
1052
+ style: {
1053
+ foreground: theme.syntaxKeyword,
1054
+ },
1055
+ },
1056
+ {
1057
+ scope: ["attribute", "annotation"],
1058
+ style: {
1059
+ foreground: theme.warning,
1060
+ },
1061
+ },
1062
+ {
1063
+ scope: ["tag"],
1064
+ style: {
1065
+ foreground: theme.error,
1066
+ },
1067
+ },
1068
+ {
1069
+ scope: ["tag.attribute"],
1070
+ style: {
1071
+ foreground: theme.syntaxKeyword,
1072
+ },
1073
+ },
1074
+ {
1075
+ scope: ["tag.delimiter"],
1076
+ style: {
1077
+ foreground: theme.syntaxOperator,
1078
+ },
1079
+ },
1080
+ {
1081
+ scope: ["markup.strikethrough"],
1082
+ style: {
1083
+ foreground: theme.textMuted,
1084
+ },
1085
+ },
1086
+ {
1087
+ scope: ["markup.underline"],
1088
+ style: {
1089
+ foreground: theme.text,
1090
+ underline: true,
1091
+ },
1092
+ },
1093
+ {
1094
+ scope: ["markup.list.checked"],
1095
+ style: {
1096
+ foreground: theme.success,
1097
+ },
1098
+ },
1099
+ {
1100
+ scope: ["markup.list.unchecked"],
1101
+ style: {
1102
+ foreground: theme.textMuted,
1103
+ },
1104
+ },
1105
+ {
1106
+ scope: ["diff.plus"],
1107
+ style: {
1108
+ foreground: theme.diffAdded,
1109
+ background: theme.diffAddedBg,
1110
+ },
1111
+ },
1112
+ {
1113
+ scope: ["diff.minus"],
1114
+ style: {
1115
+ foreground: theme.diffRemoved,
1116
+ background: theme.diffRemovedBg,
1117
+ },
1118
+ },
1119
+ {
1120
+ scope: ["diff.delta"],
1121
+ style: {
1122
+ foreground: theme.diffContext,
1123
+ background: theme.diffContextBg,
1124
+ },
1125
+ },
1126
+ {
1127
+ scope: ["error"],
1128
+ style: {
1129
+ foreground: theme.error,
1130
+ bold: true,
1131
+ },
1132
+ },
1133
+ {
1134
+ scope: ["warning"],
1135
+ style: {
1136
+ foreground: theme.warning,
1137
+ bold: true,
1138
+ },
1139
+ },
1140
+ {
1141
+ scope: ["info"],
1142
+ style: {
1143
+ foreground: theme.info,
1144
+ },
1145
+ },
1146
+ {
1147
+ scope: ["debug"],
1148
+ style: {
1149
+ foreground: theme.textMuted,
1150
+ },
1151
+ },
1152
+ ]
1153
+ }