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