@neurocode-ai/tui 1.18.8

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 (241) hide show
  1. package/bunfig.toml +4 -0
  2. package/package.json +72 -0
  3. package/src/app.tsx +1134 -0
  4. package/src/attention.ts +260 -0
  5. package/src/audio.d.ts +9 -0
  6. package/src/audio.ts +53 -0
  7. package/src/clipboard.ts +124 -0
  8. package/src/component/bg-pulse-render.ts +436 -0
  9. package/src/component/bg-pulse.tsx +99 -0
  10. package/src/component/command-palette.tsx +79 -0
  11. package/src/component/dialog-agent.tsx +31 -0
  12. package/src/component/dialog-console-org.tsx +135 -0
  13. package/src/component/dialog-debug.tsx +90 -0
  14. package/src/component/dialog-mcp.tsx +85 -0
  15. package/src/component/dialog-model.tsx +197 -0
  16. package/src/component/dialog-move-session.tsx +353 -0
  17. package/src/component/dialog-provider.tsx +469 -0
  18. package/src/component/dialog-retry-action.tsx +160 -0
  19. package/src/component/dialog-session-delete-failed.tsx +99 -0
  20. package/src/component/dialog-session-list.tsx +364 -0
  21. package/src/component/dialog-session-rename.tsx +31 -0
  22. package/src/component/dialog-skill.tsx +70 -0
  23. package/src/component/dialog-stash.tsx +87 -0
  24. package/src/component/dialog-status.tsx +168 -0
  25. package/src/component/dialog-tag.tsx +47 -0
  26. package/src/component/dialog-theme-list.tsx +50 -0
  27. package/src/component/dialog-variant.tsx +39 -0
  28. package/src/component/dialog-workspace-create.tsx +308 -0
  29. package/src/component/dialog-workspace-file-changes.tsx +144 -0
  30. package/src/component/dialog-workspace-list.tsx +112 -0
  31. package/src/component/dialog-workspace-unavailable.tsx +69 -0
  32. package/src/component/error-component.tsx +240 -0
  33. package/src/component/logo.tsx +61 -0
  34. package/src/component/plugin-route-missing.tsx +14 -0
  35. package/src/component/prompt/autocomplete.tsx +781 -0
  36. package/src/component/prompt/cwd.ts +0 -0
  37. package/src/component/prompt/frecency.tsx +1 -0
  38. package/src/component/prompt/history.tsx +1 -0
  39. package/src/component/prompt/index.tsx +1713 -0
  40. package/src/component/prompt/local-attachment.ts +48 -0
  41. package/src/component/prompt/move.tsx +205 -0
  42. package/src/component/prompt/stash.tsx +1 -0
  43. package/src/component/prompt/workspace.tsx +137 -0
  44. package/src/component/register-spinner.ts +6 -0
  45. package/src/component/spinner.tsx +26 -0
  46. package/src/component/startup-loading.tsx +63 -0
  47. package/src/component/todo-item.tsx +32 -0
  48. package/src/component/use-connected.tsx +12 -0
  49. package/src/component/workspace-label.tsx +19 -0
  50. package/src/config/index.tsx +129 -0
  51. package/src/config/keybind.ts +471 -0
  52. package/src/context/args.tsx +16 -0
  53. package/src/context/clipboard.tsx +18 -0
  54. package/src/context/data.tsx +569 -0
  55. package/src/context/directory.ts +17 -0
  56. package/src/context/editor.ts +408 -0
  57. package/src/context/epilogue.tsx +6 -0
  58. package/src/context/event.ts +36 -0
  59. package/src/context/exit.tsx +8 -0
  60. package/src/context/helper.tsx +26 -0
  61. package/src/context/kv.tsx +66 -0
  62. package/src/context/local.tsx +542 -0
  63. package/src/context/location.tsx +14 -0
  64. package/src/context/path-format.tsx +24 -0
  65. package/src/context/permission.tsx +26 -0
  66. package/src/context/project.tsx +115 -0
  67. package/src/context/prompt.tsx +18 -0
  68. package/src/context/route.tsx +60 -0
  69. package/src/context/runtime.tsx +62 -0
  70. package/src/context/sdk.tsx +151 -0
  71. package/src/context/sync.tsx +666 -0
  72. package/src/context/theme.tsx +332 -0
  73. package/src/context/thinking.ts +67 -0
  74. package/src/editor-zed.ts +286 -0
  75. package/src/editor.ts +101 -0
  76. package/src/feature-plugins/builtins.ts +36 -0
  77. package/src/feature-plugins/home/footer.tsx +100 -0
  78. package/src/feature-plugins/home/tips-view.tsx +287 -0
  79. package/src/feature-plugins/home/tips.tsx +59 -0
  80. package/src/feature-plugins/sidebar/context.tsx +65 -0
  81. package/src/feature-plugins/sidebar/files.tsx +70 -0
  82. package/src/feature-plugins/sidebar/footer.tsx +98 -0
  83. package/src/feature-plugins/sidebar/lsp.tsx +65 -0
  84. package/src/feature-plugins/sidebar/mcp.tsx +97 -0
  85. package/src/feature-plugins/sidebar/todo.tsx +49 -0
  86. package/src/feature-plugins/system/diff-viewer-file-tree-utils.ts +232 -0
  87. package/src/feature-plugins/system/diff-viewer-file-tree.tsx +162 -0
  88. package/src/feature-plugins/system/diff-viewer-ui.tsx +103 -0
  89. package/src/feature-plugins/system/diff-viewer.tsx +1077 -0
  90. package/src/feature-plugins/system/notifications.ts +94 -0
  91. package/src/feature-plugins/system/plugins.tsx +269 -0
  92. package/src/feature-plugins/system/which-key.tsx +608 -0
  93. package/src/index.tsx +1 -0
  94. package/src/keymap.tsx +290 -0
  95. package/src/logo.ts +11 -0
  96. package/src/parsers-config.ts +386 -0
  97. package/src/plugin/adapters.tsx +355 -0
  98. package/src/plugin/api.ts +52 -0
  99. package/src/plugin/command-shim.ts +109 -0
  100. package/src/plugin/runtime.tsx +81 -0
  101. package/src/plugin/slots.tsx +65 -0
  102. package/src/prompt/display.ts +48 -0
  103. package/src/prompt/frecency.tsx +80 -0
  104. package/src/prompt/history.tsx +111 -0
  105. package/src/prompt/part.ts +29 -0
  106. package/src/prompt/stash.tsx +89 -0
  107. package/src/prompt/traits.ts +29 -0
  108. package/src/routes/home/session-destination.tsx +41 -0
  109. package/src/routes/home.tsx +95 -0
  110. package/src/routes/session/dialog-fork-from-timeline.tsx +76 -0
  111. package/src/routes/session/dialog-message.tsx +109 -0
  112. package/src/routes/session/dialog-subagent.tsx +26 -0
  113. package/src/routes/session/dialog-timeline.tsx +47 -0
  114. package/src/routes/session/footer.tsx +91 -0
  115. package/src/routes/session/index.tsx +2710 -0
  116. package/src/routes/session/permission.tsx +718 -0
  117. package/src/routes/session/question.tsx +514 -0
  118. package/src/routes/session/sidebar.tsx +103 -0
  119. package/src/routes/session/subagent-footer.tsx +132 -0
  120. package/src/runtime.tsx +9 -0
  121. package/src/terminal-win32.ts +130 -0
  122. package/src/theme/assets/aura.json +69 -0
  123. package/src/theme/assets/ayu.json +80 -0
  124. package/src/theme/assets/carbonfox.json +248 -0
  125. package/src/theme/assets/catppuccin-frappe.json +230 -0
  126. package/src/theme/assets/catppuccin-macchiato.json +230 -0
  127. package/src/theme/assets/catppuccin.json +112 -0
  128. package/src/theme/assets/cobalt2.json +225 -0
  129. package/src/theme/assets/cursor.json +249 -0
  130. package/src/theme/assets/dracula.json +219 -0
  131. package/src/theme/assets/everforest.json +241 -0
  132. package/src/theme/assets/flexoki.json +237 -0
  133. package/src/theme/assets/github.json +233 -0
  134. package/src/theme/assets/gruvbox.json +242 -0
  135. package/src/theme/assets/kanagawa.json +77 -0
  136. package/src/theme/assets/lucent-orng.json +234 -0
  137. package/src/theme/assets/material.json +235 -0
  138. package/src/theme/assets/matrix.json +77 -0
  139. package/src/theme/assets/mercury.json +252 -0
  140. package/src/theme/assets/monokai.json +221 -0
  141. package/src/theme/assets/nightowl.json +221 -0
  142. package/src/theme/assets/nord.json +223 -0
  143. package/src/theme/assets/one-dark.json +84 -0
  144. package/src/theme/assets/opencode.json +245 -0
  145. package/src/theme/assets/orng.json +249 -0
  146. package/src/theme/assets/osaka-jade.json +93 -0
  147. package/src/theme/assets/palenight.json +222 -0
  148. package/src/theme/assets/rosepine.json +234 -0
  149. package/src/theme/assets/solarized.json +223 -0
  150. package/src/theme/assets/synthwave84.json +226 -0
  151. package/src/theme/assets/tokyonight.json +243 -0
  152. package/src/theme/assets/vercel.json +245 -0
  153. package/src/theme/assets/vesper.json +218 -0
  154. package/src/theme/assets/zenburn.json +223 -0
  155. package/src/theme/index.ts +1089 -0
  156. package/src/ui/border.ts +21 -0
  157. package/src/ui/dialog-alert.tsx +66 -0
  158. package/src/ui/dialog-confirm.tsx +108 -0
  159. package/src/ui/dialog-export-options.tsx +217 -0
  160. package/src/ui/dialog-help.tsx +40 -0
  161. package/src/ui/dialog-prompt.tsx +126 -0
  162. package/src/ui/dialog-select.tsx +790 -0
  163. package/src/ui/dialog.tsx +231 -0
  164. package/src/ui/link.tsx +34 -0
  165. package/src/ui/spinner.ts +368 -0
  166. package/src/ui/toast.tsx +102 -0
  167. package/src/util/collapse-tool-output.ts +19 -0
  168. package/src/util/error.ts +182 -0
  169. package/src/util/filetype.ts +130 -0
  170. package/src/util/format.ts +20 -0
  171. package/src/util/layout.ts +25 -0
  172. package/src/util/locale.ts +86 -0
  173. package/src/util/model.ts +28 -0
  174. package/src/util/path.ts +12 -0
  175. package/src/util/persistence.ts +33 -0
  176. package/src/util/presentation.ts +38 -0
  177. package/src/util/provider-origin.ts +7 -0
  178. package/src/util/record.ts +3 -0
  179. package/src/util/renderer.ts +7 -0
  180. package/src/util/revert-diff.ts +18 -0
  181. package/src/util/scroll.ts +27 -0
  182. package/src/util/selection.ts +79 -0
  183. package/src/util/session.ts +3 -0
  184. package/src/util/signal.ts +51 -0
  185. package/src/util/system.ts +20 -0
  186. package/src/util/tool-display.ts +13 -0
  187. package/src/util/transcript.ts +112 -0
  188. package/sst-env.d.ts +10 -0
  189. package/test/app-lifecycle.test.tsx +128 -0
  190. package/test/cli/cmd/tui/dialog-workspace-create.test.ts +28 -0
  191. package/test/cli/cmd/tui/model-options.test.ts +32 -0
  192. package/test/cli/cmd/tui/notifications.test.ts +267 -0
  193. package/test/cli/cmd/tui/provider-options.test.ts +41 -0
  194. package/test/cli/cmd/tui/sync-fixture.tsx +70 -0
  195. package/test/cli/cmd/tui/sync-live-hydration.test.tsx +262 -0
  196. package/test/cli/cmd/tui/sync-undefined-messages.test.tsx +43 -0
  197. package/test/cli/cmd/tui/sync.test.tsx +65 -0
  198. package/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +92 -0
  199. package/test/cli/tui/data.test.tsx +486 -0
  200. package/test/cli/tui/dialog-prompt.test.tsx +147 -0
  201. package/test/cli/tui/diff-viewer-file-tree.test.tsx +200 -0
  202. package/test/cli/tui/diff-viewer.test.tsx +268 -0
  203. package/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +351 -0
  204. package/test/cli/tui/prompt-submit-race.test.ts +98 -0
  205. package/test/cli/tui/thinking.test.ts +36 -0
  206. package/test/cli/tui/use-event.test.tsx +148 -0
  207. package/test/clipboard.test.ts +19 -0
  208. package/test/component/dialog-session-list.test.ts +46 -0
  209. package/test/config.test.tsx +127 -0
  210. package/test/context/local.test.ts +22 -0
  211. package/test/editor.test.ts +32 -0
  212. package/test/feature-plugins/diff-viewer-file-tree-utils.test.ts +323 -0
  213. package/test/fixture/fixture.ts +13 -0
  214. package/test/fixture/tui-environment.tsx +32 -0
  215. package/test/fixture/tui-plugin.ts +36 -0
  216. package/test/fixture/tui-runtime.ts +12 -0
  217. package/test/fixture/tui-sdk.ts +109 -0
  218. package/test/index.test.tsx +6 -0
  219. package/test/keymap.test.tsx +141 -0
  220. package/test/plugin/runtime.test.ts +50 -0
  221. package/test/plugin/slots.test.tsx +38 -0
  222. package/test/prompt/display.test.ts +33 -0
  223. package/test/prompt/history.test.ts +39 -0
  224. package/test/prompt/jsonl.test.ts +24 -0
  225. package/test/prompt/local-attachment.test.ts +43 -0
  226. package/test/prompt/part.test.ts +53 -0
  227. package/test/prompt/persistence.test.ts +23 -0
  228. package/test/prompt/traits.test.ts +25 -0
  229. package/test/runtime.test.tsx +37 -0
  230. package/test/theme.test.ts +81 -0
  231. package/test/util/error.test.ts +49 -0
  232. package/test/util/filetype.test.ts +16 -0
  233. package/test/util/format.test.ts +59 -0
  234. package/test/util/model.test.ts +9 -0
  235. package/test/util/presentation.test.ts +8 -0
  236. package/test/util/renderer.test.ts +30 -0
  237. package/test/util/revert-diff.test.ts +35 -0
  238. package/test/util/session.test.ts +10 -0
  239. package/test/util/tool-display.test.ts +40 -0
  240. package/test/util/transcript.test.ts +421 -0
  241. package/tsconfig.json +10 -0
@@ -0,0 +1,132 @@
1
+ import { createMemo, createSignal, Show } from "solid-js"
2
+ import { useRouteData } from "../../context/route"
3
+ import { useSync } from "../../context/sync"
4
+ import { useTheme } from "../../context/theme"
5
+ import { SplitBorder } from "../../ui/border"
6
+ import type { AssistantMessage } from "@neurocode-ai/sdk/v2"
7
+ import { Locale } from "../../util/locale"
8
+ import { useTerminalDimensions } from "@opentui/solid"
9
+ import { useCommandShortcut, useNeurocodeKeymap } from "../../keymap"
10
+
11
+ export function SubagentFooter() {
12
+ const route = useRouteData("session")
13
+ const sync = useSync()
14
+ const messages = createMemo(() => sync.data.message[route.sessionID] ?? [])
15
+ const session = createMemo(() => sync.session.get(route.sessionID))
16
+
17
+ const subagentInfo = createMemo(() => {
18
+ const s = session()
19
+ if (!s) return { label: "Subagent", index: 0, total: 0 }
20
+ const agentMatch = s.title.match(/@(\w+) subagent/)
21
+ const label = agentMatch ? Locale.titlecase(agentMatch[1]) : "Subagent"
22
+
23
+ if (!s.parentID) return { label, index: 0, total: 0 }
24
+
25
+ const siblings = sync.data.session
26
+ .filter((x) => x.parentID === s.parentID)
27
+ .toSorted((a, b) => a.time.created - b.time.created)
28
+ const index = siblings.findIndex((x) => x.id === s.id)
29
+
30
+ return { label, index: index + 1, total: siblings.length }
31
+ })
32
+
33
+ const usage = createMemo(() => {
34
+ const msg = messages()
35
+ const last = msg.findLast((item): item is AssistantMessage => item.role === "assistant" && item.tokens.output > 0)
36
+ if (!last) return
37
+
38
+ const tokens =
39
+ last.tokens.input + last.tokens.output + last.tokens.reasoning + last.tokens.cache.read + last.tokens.cache.write
40
+ if (tokens <= 0) return
41
+
42
+ const model = sync.data.provider.find((item) => item.id === last.providerID)?.models[last.modelID]
43
+ const pct = model?.limit.context ? `${Math.round((tokens / model.limit.context) * 100)}%` : undefined
44
+ const cost = session()?.cost ?? 0
45
+
46
+ const money = new Intl.NumberFormat("en-US", {
47
+ style: "currency",
48
+ currency: "USD",
49
+ })
50
+
51
+ return {
52
+ context: pct ? `${Locale.number(tokens)} (${pct})` : Locale.number(tokens),
53
+ cost: cost > 0 ? money.format(cost) : undefined,
54
+ }
55
+ })
56
+
57
+ const { theme } = useTheme()
58
+ const keymap = useNeurocodeKeymap()
59
+ const parentShortcut = useCommandShortcut("session.parent")
60
+ const previousShortcut = useCommandShortcut("session.child.previous")
61
+ const nextShortcut = useCommandShortcut("session.child.next")
62
+ const [hover, setHover] = createSignal<"parent" | "prev" | "next" | null>(null)
63
+ useTerminalDimensions()
64
+
65
+ return (
66
+ <box flexShrink={0}>
67
+ <box
68
+ paddingTop={1}
69
+ paddingBottom={1}
70
+ paddingLeft={2}
71
+ paddingRight={1}
72
+ {...SplitBorder}
73
+ border={["left"]}
74
+ borderColor={theme.border}
75
+ flexShrink={0}
76
+ backgroundColor={theme.backgroundPanel}
77
+ >
78
+ <box flexDirection="row" justifyContent="space-between" gap={1}>
79
+ <box flexDirection="row" gap={1}>
80
+ <text fg={theme.text}>
81
+ <b>{subagentInfo().label}</b>
82
+ </text>
83
+ <Show when={subagentInfo().total > 0}>
84
+ <text style={{ fg: theme.textMuted }}>
85
+ ({subagentInfo().index} of {subagentInfo().total})
86
+ </text>
87
+ </Show>
88
+ <Show when={usage()}>
89
+ {(item) => (
90
+ <text fg={theme.textMuted} wrapMode="none">
91
+ {[item().context, item().cost].filter(Boolean).join(" · ")}
92
+ </text>
93
+ )}
94
+ </Show>
95
+ </box>
96
+ <box flexDirection="row" gap={2}>
97
+ <box
98
+ onMouseOver={() => setHover("parent")}
99
+ onMouseOut={() => setHover(null)}
100
+ onMouseUp={() => keymap.dispatchCommand("session.parent")}
101
+ backgroundColor={hover() === "parent" ? theme.backgroundElement : theme.backgroundPanel}
102
+ >
103
+ <text fg={theme.text}>
104
+ Parent <span style={{ fg: theme.textMuted }}>{parentShortcut()}</span>
105
+ </text>
106
+ </box>
107
+ <box
108
+ onMouseOver={() => setHover("prev")}
109
+ onMouseOut={() => setHover(null)}
110
+ onMouseUp={() => keymap.dispatchCommand("session.child.previous")}
111
+ backgroundColor={hover() === "prev" ? theme.backgroundElement : theme.backgroundPanel}
112
+ >
113
+ <text fg={theme.text}>
114
+ Prev <span style={{ fg: theme.textMuted }}>{previousShortcut()}</span>
115
+ </text>
116
+ </box>
117
+ <box
118
+ onMouseOver={() => setHover("next")}
119
+ onMouseOut={() => setHover(null)}
120
+ onMouseUp={() => keymap.dispatchCommand("session.child.next")}
121
+ backgroundColor={hover() === "next" ? theme.backgroundElement : theme.backgroundPanel}
122
+ >
123
+ <text fg={theme.text}>
124
+ Next <span style={{ fg: theme.textMuted }}>{nextShortcut()}</span>
125
+ </text>
126
+ </box>
127
+ </box>
128
+ </box>
129
+ </box>
130
+ </box>
131
+ )
132
+ }
@@ -0,0 +1,9 @@
1
+ import path from "path"
2
+
3
+ export function abbreviateHome(input: string, home: string) {
4
+ if (!home) return input
5
+ const relative = path.relative(home, input)
6
+ if (relative === "") return "~"
7
+ if (relative === ".." || relative.startsWith(".." + path.sep) || path.isAbsolute(relative)) return input
8
+ return "~" + path.sep + relative
9
+ }
@@ -0,0 +1,130 @@
1
+ import { dlopen, ptr } from "bun:ffi"
2
+ import type { ReadStream } from "node:tty"
3
+
4
+ const STD_INPUT_HANDLE = -10
5
+ const ENABLE_PROCESSED_INPUT = 0x0001
6
+
7
+ const kernel = () =>
8
+ dlopen("kernel32.dll", {
9
+ GetStdHandle: { args: ["i32"], returns: "ptr" },
10
+ GetConsoleMode: { args: ["ptr", "ptr"], returns: "i32" },
11
+ SetConsoleMode: { args: ["ptr", "u32"], returns: "i32" },
12
+ FlushConsoleInputBuffer: { args: ["ptr"], returns: "i32" },
13
+ })
14
+
15
+ let k32: ReturnType<typeof kernel> | undefined
16
+
17
+ function load() {
18
+ if (process.platform !== "win32") return false
19
+ try {
20
+ k32 ??= kernel()
21
+ return true
22
+ } catch {
23
+ return false
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Clear ENABLE_PROCESSED_INPUT on the console stdin handle.
29
+ */
30
+ export function win32DisableProcessedInput() {
31
+ if (process.platform !== "win32") return
32
+ if (!process.stdin.isTTY) return
33
+ if (!load()) return
34
+
35
+ const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
36
+ const buf = new Uint32Array(1)
37
+ if (k32!.symbols.GetConsoleMode(handle, ptr(buf)) === 0) return
38
+
39
+ const mode = buf[0]!
40
+ if ((mode & ENABLE_PROCESSED_INPUT) === 0) return
41
+ k32!.symbols.SetConsoleMode(handle, mode & ~ENABLE_PROCESSED_INPUT)
42
+ }
43
+
44
+ /**
45
+ * Discard any queued console input (mouse events, key presses, etc.).
46
+ */
47
+ export function win32FlushInputBuffer() {
48
+ if (process.platform !== "win32") return
49
+ if (!process.stdin.isTTY) return
50
+ if (!load()) return
51
+
52
+ const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
53
+ k32!.symbols.FlushConsoleInputBuffer(handle)
54
+ }
55
+
56
+ let unhook: (() => void) | undefined
57
+
58
+ /**
59
+ * Keep ENABLE_PROCESSED_INPUT disabled.
60
+ *
61
+ * On Windows, Ctrl+C becomes a CTRL_C_EVENT (instead of stdin input) when
62
+ * ENABLE_PROCESSED_INPUT is set. Various runtimes can re-apply console modes
63
+ * (sometimes on a later tick), and the flag is console-global, not per-process.
64
+ *
65
+ * We combine:
66
+ * - A `setRawMode(...)` hook to re-clear after known raw-mode toggles.
67
+ * - A low-frequency poll as a backstop for native/external mode changes.
68
+ */
69
+ export function win32InstallCtrlCGuard() {
70
+ if (process.platform !== "win32") return
71
+ if (!process.stdin.isTTY) return
72
+ if (!load()) return
73
+ if (unhook) return unhook
74
+
75
+ const stdin = process.stdin as ReadStream
76
+ const original = stdin.setRawMode
77
+
78
+ const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
79
+ const buf = new Uint32Array(1)
80
+
81
+ if (k32!.symbols.GetConsoleMode(handle, ptr(buf)) === 0) return
82
+ const initial = buf[0]!
83
+
84
+ const enforce = () => {
85
+ if (k32!.symbols.GetConsoleMode(handle, ptr(buf)) === 0) return
86
+ const mode = buf[0]!
87
+ if ((mode & ENABLE_PROCESSED_INPUT) === 0) return
88
+ k32!.symbols.SetConsoleMode(handle, mode & ~ENABLE_PROCESSED_INPUT)
89
+ }
90
+
91
+ // Some runtimes can re-apply console modes on the next tick; enforce twice.
92
+ const later = () => {
93
+ enforce()
94
+ setImmediate(enforce)
95
+ }
96
+
97
+ let wrapped: ReadStream["setRawMode"] | undefined
98
+
99
+ if (typeof original === "function") {
100
+ wrapped = (mode: boolean) => {
101
+ const result = original.call(stdin, mode)
102
+ later()
103
+ return result
104
+ }
105
+
106
+ stdin.setRawMode = wrapped
107
+ }
108
+
109
+ // Ensure it's cleared immediately too (covers any earlier mode changes).
110
+ later()
111
+
112
+ const interval = setInterval(enforce, 100)
113
+ interval.unref()
114
+
115
+ let done = false
116
+ unhook = () => {
117
+ if (done) return
118
+ done = true
119
+
120
+ clearInterval(interval)
121
+ if (wrapped && stdin.setRawMode === wrapped) {
122
+ stdin.setRawMode = original
123
+ }
124
+
125
+ k32!.symbols.SetConsoleMode(handle, initial)
126
+ unhook = undefined
127
+ }
128
+
129
+ return unhook
130
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "https://opencode.ai/theme.json",
3
+ "defs": {
4
+ "darkBg": "#0f0f0f",
5
+ "darkBgPanel": "#15141b",
6
+ "darkBorder": "#2d2d2d",
7
+ "darkFgMuted": "#6d6d6d",
8
+ "darkFg": "#edecee",
9
+ "purple": "#a277ff",
10
+ "pink": "#f694ff",
11
+ "blue": "#82e2ff",
12
+ "red": "#ff6767",
13
+ "orange": "#ffca85",
14
+ "cyan": "#61ffca",
15
+ "green": "#9dff65"
16
+ },
17
+ "theme": {
18
+ "primary": "purple",
19
+ "secondary": "pink",
20
+ "accent": "purple",
21
+ "error": "red",
22
+ "warning": "orange",
23
+ "success": "cyan",
24
+ "info": "purple",
25
+ "text": "darkFg",
26
+ "textMuted": "darkFgMuted",
27
+ "background": "darkBg",
28
+ "backgroundPanel": "darkBgPanel",
29
+ "backgroundElement": "darkBgPanel",
30
+ "border": "darkBorder",
31
+ "borderActive": "darkFgMuted",
32
+ "borderSubtle": "darkBorder",
33
+ "diffAdded": "cyan",
34
+ "diffRemoved": "red",
35
+ "diffContext": "darkFgMuted",
36
+ "diffHunkHeader": "darkFgMuted",
37
+ "diffHighlightAdded": "cyan",
38
+ "diffHighlightRemoved": "red",
39
+ "diffAddedBg": "#354933",
40
+ "diffRemovedBg": "#3f191a",
41
+ "diffContextBg": "darkBgPanel",
42
+ "diffLineNumber": "#898989",
43
+ "diffAddedLineNumberBg": "#162620",
44
+ "diffRemovedLineNumberBg": "#26161a",
45
+ "markdownText": "darkFg",
46
+ "markdownHeading": "purple",
47
+ "markdownLink": "pink",
48
+ "markdownLinkText": "purple",
49
+ "markdownCode": "cyan",
50
+ "markdownBlockQuote": "darkFgMuted",
51
+ "markdownEmph": "orange",
52
+ "markdownStrong": "purple",
53
+ "markdownHorizontalRule": "darkFgMuted",
54
+ "markdownListItem": "purple",
55
+ "markdownListEnumeration": "purple",
56
+ "markdownImage": "pink",
57
+ "markdownImageText": "purple",
58
+ "markdownCodeBlock": "darkFg",
59
+ "syntaxComment": "darkFgMuted",
60
+ "syntaxKeyword": "pink",
61
+ "syntaxFunction": "purple",
62
+ "syntaxVariable": "purple",
63
+ "syntaxString": "cyan",
64
+ "syntaxNumber": "green",
65
+ "syntaxType": "purple",
66
+ "syntaxOperator": "pink",
67
+ "syntaxPunctuation": "darkFg"
68
+ }
69
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "$schema": "https://opencode.ai/theme.json",
3
+ "defs": {
4
+ "darkBg": "#0B0E14",
5
+ "darkBgAlt": "#0D1017",
6
+ "darkLine": "#11151C",
7
+ "darkPanel": "#0F131A",
8
+ "darkFg": "#BFBDB6",
9
+ "darkFgMuted": "#565B66",
10
+ "darkGutter": "#6C7380",
11
+ "darkTag": "#39BAE6",
12
+ "darkFunc": "#FFB454",
13
+ "darkEntity": "#59C2FF",
14
+ "darkString": "#AAD94C",
15
+ "darkRegexp": "#95E6CB",
16
+ "darkMarkup": "#F07178",
17
+ "darkKeyword": "#FF8F40",
18
+ "darkSpecial": "#E6B673",
19
+ "darkComment": "#ACB6BF",
20
+ "darkConstant": "#D2A6FF",
21
+ "darkOperator": "#F29668",
22
+ "darkAdded": "#7FD962",
23
+ "darkRemoved": "#F26D78",
24
+ "darkAccent": "#E6B450",
25
+ "darkError": "#D95757",
26
+ "darkIndentActive": "#6C7380"
27
+ },
28
+ "theme": {
29
+ "primary": "darkEntity",
30
+ "secondary": "darkConstant",
31
+ "accent": "darkAccent",
32
+ "error": "darkError",
33
+ "warning": "darkSpecial",
34
+ "success": "darkAdded",
35
+ "info": "darkTag",
36
+ "text": "darkFg",
37
+ "textMuted": "darkFgMuted",
38
+ "background": "darkBg",
39
+ "backgroundPanel": "darkPanel",
40
+ "backgroundElement": "darkBgAlt",
41
+ "border": "darkGutter",
42
+ "borderActive": "darkIndentActive",
43
+ "borderSubtle": "darkLine",
44
+ "diffAdded": "darkAdded",
45
+ "diffRemoved": "darkRemoved",
46
+ "diffContext": "darkComment",
47
+ "diffHunkHeader": "darkComment",
48
+ "diffHighlightAdded": "darkString",
49
+ "diffHighlightRemoved": "darkMarkup",
50
+ "diffAddedBg": "#20303b",
51
+ "diffRemovedBg": "#37222c",
52
+ "diffContextBg": "darkPanel",
53
+ "diffLineNumber": "diffContext",
54
+ "diffAddedLineNumberBg": "#1b2b34",
55
+ "diffRemovedLineNumberBg": "#2d1f26",
56
+ "markdownText": "darkFg",
57
+ "markdownHeading": "darkConstant",
58
+ "markdownLink": "darkEntity",
59
+ "markdownLinkText": "darkTag",
60
+ "markdownCode": "darkString",
61
+ "markdownBlockQuote": "darkSpecial",
62
+ "markdownEmph": "darkSpecial",
63
+ "markdownStrong": "darkFunc",
64
+ "markdownHorizontalRule": "darkFgMuted",
65
+ "markdownListItem": "darkEntity",
66
+ "markdownListEnumeration": "darkTag",
67
+ "markdownImage": "darkEntity",
68
+ "markdownImageText": "darkTag",
69
+ "markdownCodeBlock": "darkFg",
70
+ "syntaxComment": "darkComment",
71
+ "syntaxKeyword": "darkKeyword",
72
+ "syntaxFunction": "darkFunc",
73
+ "syntaxVariable": "darkEntity",
74
+ "syntaxString": "darkString",
75
+ "syntaxNumber": "darkConstant",
76
+ "syntaxType": "darkSpecial",
77
+ "syntaxOperator": "darkOperator",
78
+ "syntaxPunctuation": "darkFg"
79
+ }
80
+ }
@@ -0,0 +1,248 @@
1
+ {
2
+ "$schema": "https://opencode.ai/theme.json",
3
+ "defs": {
4
+ "bg0": "#0d0d0d",
5
+ "bg1": "#161616",
6
+ "bg1a": "#1a1a1a",
7
+ "bg2": "#1e1e1e",
8
+ "bg3": "#262626",
9
+ "bg4": "#303030",
10
+ "fg0": "#ffffff",
11
+ "fg1": "#f2f4f8",
12
+ "fg2": "#a9afbc",
13
+ "fg3": "#7d848f",
14
+ "lbg0": "#ffffff",
15
+ "lbg1": "#f4f4f4",
16
+ "lbg2": "#e8e8e8",
17
+ "lbg3": "#dcdcdc",
18
+ "lfg0": "#000000",
19
+ "lfg1": "#161616",
20
+ "lfg2": "#525252",
21
+ "lfg3": "#6f6f6f",
22
+ "red": "#ee5396",
23
+ "green": "#25be6a",
24
+ "yellow": "#08bdba",
25
+ "blue": "#78a9ff",
26
+ "magenta": "#be95ff",
27
+ "cyan": "#33b1ff",
28
+ "white": "#dfdfe0",
29
+ "orange": "#3ddbd9",
30
+ "pink": "#ff7eb6",
31
+ "blueBright": "#8cb6ff",
32
+ "cyanBright": "#52c7ff",
33
+ "greenBright": "#46c880",
34
+ "redLight": "#9f1853",
35
+ "greenLight": "#198038",
36
+ "yellowLight": "#007d79",
37
+ "blueLight": "#0043ce",
38
+ "magentaLight": "#6929c4",
39
+ "cyanLight": "#0072c3",
40
+ "warning": "#f1c21b",
41
+ "diffGreen": "#50fa7b",
42
+ "diffRed": "#ff6b6b",
43
+ "diffGreenBg": "#0f2418",
44
+ "diffRedBg": "#2a1216"
45
+ },
46
+ "theme": {
47
+ "primary": {
48
+ "dark": "cyan",
49
+ "light": "blueLight"
50
+ },
51
+ "secondary": {
52
+ "dark": "blue",
53
+ "light": "blueLight"
54
+ },
55
+ "accent": {
56
+ "dark": "pink",
57
+ "light": "redLight"
58
+ },
59
+ "error": {
60
+ "dark": "red",
61
+ "light": "redLight"
62
+ },
63
+ "warning": {
64
+ "dark": "warning",
65
+ "light": "yellowLight"
66
+ },
67
+ "success": {
68
+ "dark": "green",
69
+ "light": "greenLight"
70
+ },
71
+ "info": {
72
+ "dark": "blue",
73
+ "light": "blueLight"
74
+ },
75
+ "text": {
76
+ "dark": "fg1",
77
+ "light": "lfg1"
78
+ },
79
+ "textMuted": {
80
+ "dark": "fg3",
81
+ "light": "lfg3"
82
+ },
83
+ "background": {
84
+ "dark": "bg1",
85
+ "light": "lbg0"
86
+ },
87
+ "backgroundPanel": {
88
+ "dark": "bg1a",
89
+ "light": "lbg1"
90
+ },
91
+ "backgroundElement": {
92
+ "dark": "bg2",
93
+ "light": "lbg1"
94
+ },
95
+ "border": {
96
+ "dark": "bg4",
97
+ "light": "lbg3"
98
+ },
99
+ "borderActive": {
100
+ "dark": "cyan",
101
+ "light": "blueLight"
102
+ },
103
+ "borderSubtle": {
104
+ "dark": "bg3",
105
+ "light": "lbg2"
106
+ },
107
+ "diffAdded": {
108
+ "dark": "diffGreen",
109
+ "light": "greenLight"
110
+ },
111
+ "diffRemoved": {
112
+ "dark": "diffRed",
113
+ "light": "redLight"
114
+ },
115
+ "diffContext": {
116
+ "dark": "fg3",
117
+ "light": "lfg3"
118
+ },
119
+ "diffHunkHeader": {
120
+ "dark": "blue",
121
+ "light": "blueLight"
122
+ },
123
+ "diffHighlightAdded": {
124
+ "dark": "#7dffaa",
125
+ "light": "greenLight"
126
+ },
127
+ "diffHighlightRemoved": {
128
+ "dark": "#ff9999",
129
+ "light": "redLight"
130
+ },
131
+ "diffAddedBg": {
132
+ "dark": "diffGreenBg",
133
+ "light": "#defbe6"
134
+ },
135
+ "diffRemovedBg": {
136
+ "dark": "diffRedBg",
137
+ "light": "#fff1f1"
138
+ },
139
+ "diffContextBg": {
140
+ "dark": "bg1",
141
+ "light": "lbg1"
142
+ },
143
+ "diffLineNumber": {
144
+ "dark": "#808792",
145
+ "light": "textMuted"
146
+ },
147
+ "diffAddedLineNumberBg": {
148
+ "dark": "diffGreenBg",
149
+ "light": "#defbe6"
150
+ },
151
+ "diffRemovedLineNumberBg": {
152
+ "dark": "diffRedBg",
153
+ "light": "#fff1f1"
154
+ },
155
+ "markdownText": {
156
+ "dark": "fg1",
157
+ "light": "lfg1"
158
+ },
159
+ "markdownHeading": {
160
+ "dark": "blueBright",
161
+ "light": "blueLight"
162
+ },
163
+ "markdownLink": {
164
+ "dark": "blue",
165
+ "light": "blueLight"
166
+ },
167
+ "markdownLinkText": {
168
+ "dark": "cyan",
169
+ "light": "cyanLight"
170
+ },
171
+ "markdownCode": {
172
+ "dark": "green",
173
+ "light": "greenLight"
174
+ },
175
+ "markdownBlockQuote": {
176
+ "dark": "fg3",
177
+ "light": "lfg3"
178
+ },
179
+ "markdownEmph": {
180
+ "dark": "magenta",
181
+ "light": "magentaLight"
182
+ },
183
+ "markdownStrong": {
184
+ "dark": "fg0",
185
+ "light": "lfg0"
186
+ },
187
+ "markdownHorizontalRule": {
188
+ "dark": "bg4",
189
+ "light": "lbg3"
190
+ },
191
+ "markdownListItem": {
192
+ "dark": "cyan",
193
+ "light": "cyanLight"
194
+ },
195
+ "markdownListEnumeration": {
196
+ "dark": "cyan",
197
+ "light": "cyanLight"
198
+ },
199
+ "markdownImage": {
200
+ "dark": "blue",
201
+ "light": "blueLight"
202
+ },
203
+ "markdownImageText": {
204
+ "dark": "cyan",
205
+ "light": "cyanLight"
206
+ },
207
+ "markdownCodeBlock": {
208
+ "dark": "fg2",
209
+ "light": "lfg2"
210
+ },
211
+ "syntaxComment": {
212
+ "dark": "fg3",
213
+ "light": "lfg3"
214
+ },
215
+ "syntaxKeyword": {
216
+ "dark": "magenta",
217
+ "light": "magentaLight"
218
+ },
219
+ "syntaxFunction": {
220
+ "dark": "blueBright",
221
+ "light": "blueLight"
222
+ },
223
+ "syntaxVariable": {
224
+ "dark": "white",
225
+ "light": "lfg1"
226
+ },
227
+ "syntaxString": {
228
+ "dark": "green",
229
+ "light": "greenLight"
230
+ },
231
+ "syntaxNumber": {
232
+ "dark": "orange",
233
+ "light": "yellowLight"
234
+ },
235
+ "syntaxType": {
236
+ "dark": "yellow",
237
+ "light": "yellowLight"
238
+ },
239
+ "syntaxOperator": {
240
+ "dark": "fg2",
241
+ "light": "lfg2"
242
+ },
243
+ "syntaxPunctuation": {
244
+ "dark": "fg2",
245
+ "light": "lfg1"
246
+ }
247
+ }
248
+ }