@onpoint-dev-tools/crewcoder-opentui 0.0.0-stage → 0.1.0

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 (325) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +262 -2
  3. package/THIRD_PARTY_NOTICES.md +51 -0
  4. package/dist/App.d.ts +16 -0
  5. package/dist/App.d.ts.map +1 -0
  6. package/dist/App.js +428 -0
  7. package/dist/App.js.map +1 -0
  8. package/dist/Root.d.ts +11 -0
  9. package/dist/Root.d.ts.map +1 -0
  10. package/dist/Root.js +13 -0
  11. package/dist/Root.js.map +1 -0
  12. package/dist/alert-model.d.ts +31 -0
  13. package/dist/alert-model.d.ts.map +1 -0
  14. package/dist/alert-model.js +34 -0
  15. package/dist/alert-model.js.map +1 -0
  16. package/dist/args.d.ts +13 -0
  17. package/dist/args.d.ts.map +1 -0
  18. package/dist/args.js +63 -0
  19. package/dist/args.js.map +1 -0
  20. package/dist/attachments.d.ts +29 -0
  21. package/dist/attachments.d.ts.map +1 -0
  22. package/dist/attachments.js +38 -0
  23. package/dist/attachments.js.map +1 -0
  24. package/dist/block-panels.d.ts +43 -0
  25. package/dist/block-panels.d.ts.map +1 -0
  26. package/dist/block-panels.js +210 -0
  27. package/dist/block-panels.js.map +1 -0
  28. package/dist/cli.d.ts +3 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +138 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/command-format.d.ts +18 -0
  33. package/dist/command-format.d.ts.map +1 -0
  34. package/dist/command-format.js +66 -0
  35. package/dist/command-format.js.map +1 -0
  36. package/dist/command-runner.d.ts +128 -0
  37. package/dist/command-runner.d.ts.map +1 -0
  38. package/dist/command-runner.js +571 -0
  39. package/dist/command-runner.js.map +1 -0
  40. package/dist/commands.d.ts +47 -0
  41. package/dist/commands.d.ts.map +1 -0
  42. package/dist/commands.js +108 -0
  43. package/dist/commands.js.map +1 -0
  44. package/dist/components/AttachmentRow.d.ts +11 -0
  45. package/dist/components/AttachmentRow.d.ts.map +1 -0
  46. package/dist/components/AttachmentRow.js +17 -0
  47. package/dist/components/AttachmentRow.js.map +1 -0
  48. package/dist/components/Composer.d.ts +23 -0
  49. package/dist/components/Composer.d.ts.map +1 -0
  50. package/dist/components/Composer.js +45 -0
  51. package/dist/components/Composer.js.map +1 -0
  52. package/dist/components/ExtensionQuestion.d.ts +18 -0
  53. package/dist/components/ExtensionQuestion.d.ts.map +1 -0
  54. package/dist/components/ExtensionQuestion.js +45 -0
  55. package/dist/components/ExtensionQuestion.js.map +1 -0
  56. package/dist/components/GoalForm.d.ts +18 -0
  57. package/dist/components/GoalForm.d.ts.map +1 -0
  58. package/dist/components/GoalForm.js +26 -0
  59. package/dist/components/GoalForm.js.map +1 -0
  60. package/dist/components/Home.d.ts +21 -0
  61. package/dist/components/Home.d.ts.map +1 -0
  62. package/dist/components/Home.js +48 -0
  63. package/dist/components/Home.js.map +1 -0
  64. package/dist/components/MentionList.d.ts +14 -0
  65. package/dist/components/MentionList.d.ts.map +1 -0
  66. package/dist/components/MentionList.js +24 -0
  67. package/dist/components/MentionList.js.map +1 -0
  68. package/dist/components/SearchBar.d.ts +19 -0
  69. package/dist/components/SearchBar.d.ts.map +1 -0
  70. package/dist/components/SearchBar.js +28 -0
  71. package/dist/components/SearchBar.js.map +1 -0
  72. package/dist/components/Sidebar.d.ts +19 -0
  73. package/dist/components/Sidebar.d.ts.map +1 -0
  74. package/dist/components/Sidebar.js +35 -0
  75. package/dist/components/Sidebar.js.map +1 -0
  76. package/dist/components/SummaryEditor.d.ts +16 -0
  77. package/dist/components/SummaryEditor.d.ts.map +1 -0
  78. package/dist/components/SummaryEditor.js +21 -0
  79. package/dist/components/SummaryEditor.js.map +1 -0
  80. package/dist/components/Transcript.d.ts +37 -0
  81. package/dist/components/Transcript.d.ts.map +1 -0
  82. package/dist/components/Transcript.js +314 -0
  83. package/dist/components/Transcript.js.map +1 -0
  84. package/dist/components/ui/alert.d.ts +9 -0
  85. package/dist/components/ui/alert.d.ts.map +1 -0
  86. package/dist/components/ui/alert.js +18 -0
  87. package/dist/components/ui/alert.js.map +1 -0
  88. package/dist/components/ui/command-palette.d.ts +15 -0
  89. package/dist/components/ui/command-palette.d.ts.map +1 -0
  90. package/dist/components/ui/command-palette.js +14 -0
  91. package/dist/components/ui/command-palette.js.map +1 -0
  92. package/dist/components/ui/confirm.d.ts +12 -0
  93. package/dist/components/ui/confirm.d.ts.map +1 -0
  94. package/dist/components/ui/confirm.js +16 -0
  95. package/dist/components/ui/confirm.js.map +1 -0
  96. package/dist/components/ui/select.d.ts +11 -0
  97. package/dist/components/ui/select.d.ts.map +1 -0
  98. package/dist/components/ui/select.js +29 -0
  99. package/dist/components/ui/select.js.map +1 -0
  100. package/dist/components/ui/spinner.d.ts +14 -0
  101. package/dist/components/ui/spinner.d.ts.map +1 -0
  102. package/dist/components/ui/spinner.js +17 -0
  103. package/dist/components/ui/spinner.js.map +1 -0
  104. package/dist/components/ui/tool-approval.d.ts +14 -0
  105. package/dist/components/ui/tool-approval.d.ts.map +1 -0
  106. package/dist/components/ui/tool-approval.js +37 -0
  107. package/dist/components/ui/tool-approval.js.map +1 -0
  108. package/dist/components/ui/tool-call.d.ts +12 -0
  109. package/dist/components/ui/tool-call.d.ts.map +1 -0
  110. package/dist/components/ui/tool-call.js +69 -0
  111. package/dist/components/ui/tool-call.js.map +1 -0
  112. package/dist/components/ui/types.d.ts +82 -0
  113. package/dist/components/ui/types.d.ts.map +1 -0
  114. package/dist/components/ui/types.js +2 -0
  115. package/dist/components/ui/types.js.map +1 -0
  116. package/dist/crewcoder-cli.d.ts +51 -0
  117. package/dist/crewcoder-cli.d.ts.map +1 -0
  118. package/dist/crewcoder-cli.js +26 -0
  119. package/dist/crewcoder-cli.js.map +1 -0
  120. package/dist/diff-anchors.d.ts +14 -0
  121. package/dist/diff-anchors.d.ts.map +1 -0
  122. package/dist/diff-anchors.js +43 -0
  123. package/dist/diff-anchors.js.map +1 -0
  124. package/dist/footer-layout.d.ts +49 -0
  125. package/dist/footer-layout.d.ts.map +1 -0
  126. package/dist/footer-layout.js +79 -0
  127. package/dist/footer-layout.js.map +1 -0
  128. package/dist/glyphs.d.ts +32 -0
  129. package/dist/glyphs.d.ts.map +1 -0
  130. package/dist/glyphs.js +35 -0
  131. package/dist/glyphs.js.map +1 -0
  132. package/dist/goal-form.d.ts +47 -0
  133. package/dist/goal-form.d.ts.map +1 -0
  134. package/dist/goal-form.js +59 -0
  135. package/dist/goal-form.js.map +1 -0
  136. package/dist/hooks/use-animation.d.ts +6 -0
  137. package/dist/hooks/use-animation.d.ts.map +1 -0
  138. package/dist/hooks/use-animation.js +52 -0
  139. package/dist/hooks/use-animation.js.map +1 -0
  140. package/dist/hooks/use-app-colors.d.ts +6 -0
  141. package/dist/hooks/use-app-colors.d.ts.map +1 -0
  142. package/dist/hooks/use-app-colors.js +6 -0
  143. package/dist/hooks/use-app-colors.js.map +1 -0
  144. package/dist/hooks/use-glyph-set.d.ts +8 -0
  145. package/dist/hooks/use-glyph-set.d.ts.map +1 -0
  146. package/dist/hooks/use-glyph-set.js +22 -0
  147. package/dist/hooks/use-glyph-set.js.map +1 -0
  148. package/dist/hooks/use-motion.d.ts +6 -0
  149. package/dist/hooks/use-motion.d.ts.map +1 -0
  150. package/dist/hooks/use-motion.js +8 -0
  151. package/dist/hooks/use-motion.js.map +1 -0
  152. package/dist/hooks/use-terminal-focus.d.ts +16 -0
  153. package/dist/hooks/use-terminal-focus.d.ts.map +1 -0
  154. package/dist/hooks/use-terminal-focus.js +30 -0
  155. package/dist/hooks/use-terminal-focus.js.map +1 -0
  156. package/dist/hooks/use-theme.d.ts +6 -0
  157. package/dist/hooks/use-theme.d.ts.map +1 -0
  158. package/dist/hooks/use-theme.js +11 -0
  159. package/dist/hooks/use-theme.js.map +1 -0
  160. package/dist/hunk.d.ts +27 -0
  161. package/dist/hunk.d.ts.map +1 -0
  162. package/dist/hunk.js +43 -0
  163. package/dist/hunk.js.map +1 -0
  164. package/dist/image-view.d.ts +33 -0
  165. package/dist/image-view.d.ts.map +1 -0
  166. package/dist/image-view.js +51 -0
  167. package/dist/image-view.js.map +1 -0
  168. package/dist/keybindings.d.ts +28 -0
  169. package/dist/keybindings.d.ts.map +1 -0
  170. package/dist/keybindings.js +105 -0
  171. package/dist/keybindings.js.map +1 -0
  172. package/dist/lib/terminal-themes/default.d.ts +3 -0
  173. package/dist/lib/terminal-themes/default.d.ts.map +1 -0
  174. package/dist/lib/terminal-themes/default.js +49 -0
  175. package/dist/lib/terminal-themes/default.js.map +1 -0
  176. package/dist/logo-pulse.d.ts +23 -0
  177. package/dist/logo-pulse.d.ts.map +1 -0
  178. package/dist/logo-pulse.js +30 -0
  179. package/dist/logo-pulse.js.map +1 -0
  180. package/dist/markdown-style.d.ts +47 -0
  181. package/dist/markdown-style.d.ts.map +1 -0
  182. package/dist/markdown-style.js +138 -0
  183. package/dist/markdown-style.js.map +1 -0
  184. package/dist/mentions.d.ts +57 -0
  185. package/dist/mentions.d.ts.map +1 -0
  186. package/dist/mentions.js +109 -0
  187. package/dist/mentions.js.map +1 -0
  188. package/dist/palette-model.d.ts +42 -0
  189. package/dist/palette-model.d.ts.map +1 -0
  190. package/dist/palette-model.js +77 -0
  191. package/dist/palette-model.js.map +1 -0
  192. package/dist/path-suggestions.d.ts +50 -0
  193. package/dist/path-suggestions.d.ts.map +1 -0
  194. package/dist/path-suggestions.js +99 -0
  195. package/dist/path-suggestions.js.map +1 -0
  196. package/dist/picker-flows.d.ts +78 -0
  197. package/dist/picker-flows.d.ts.map +1 -0
  198. package/dist/picker-flows.js +444 -0
  199. package/dist/picker-flows.js.map +1 -0
  200. package/dist/pickers.d.ts +34 -0
  201. package/dist/pickers.d.ts.map +1 -0
  202. package/dist/pickers.js +136 -0
  203. package/dist/pickers.js.map +1 -0
  204. package/dist/prompt-history.d.ts +32 -0
  205. package/dist/prompt-history.d.ts.map +1 -0
  206. package/dist/prompt-history.js +40 -0
  207. package/dist/prompt-history.js.map +1 -0
  208. package/dist/providers/app-theme-provider.d.ts +12 -0
  209. package/dist/providers/app-theme-provider.d.ts.map +1 -0
  210. package/dist/providers/app-theme-provider.js +14 -0
  211. package/dist/providers/app-theme-provider.js.map +1 -0
  212. package/dist/providers/theme-provider.d.ts +10 -0
  213. package/dist/providers/theme-provider.d.ts.map +1 -0
  214. package/dist/providers/theme-provider.js +57 -0
  215. package/dist/providers/theme-provider.js.map +1 -0
  216. package/dist/question-model.d.ts +71 -0
  217. package/dist/question-model.d.ts.map +1 -0
  218. package/dist/question-model.js +176 -0
  219. package/dist/question-model.js.map +1 -0
  220. package/dist/search-controller.d.ts +46 -0
  221. package/dist/search-controller.d.ts.map +1 -0
  222. package/dist/search-controller.js +89 -0
  223. package/dist/search-controller.js.map +1 -0
  224. package/dist/search-jump.d.ts +27 -0
  225. package/dist/search-jump.d.ts.map +1 -0
  226. package/dist/search-jump.js +65 -0
  227. package/dist/search-jump.js.map +1 -0
  228. package/dist/session-controller.d.ts +268 -0
  229. package/dist/session-controller.d.ts.map +1 -0
  230. package/dist/session-controller.js +941 -0
  231. package/dist/session-controller.js.map +1 -0
  232. package/dist/sidebar-model.d.ts +45 -0
  233. package/dist/sidebar-model.d.ts.map +1 -0
  234. package/dist/sidebar-model.js +223 -0
  235. package/dist/sidebar-model.js.map +1 -0
  236. package/dist/sidebar.d.ts +49 -0
  237. package/dist/sidebar.d.ts.map +1 -0
  238. package/dist/sidebar.js +106 -0
  239. package/dist/sidebar.js.map +1 -0
  240. package/dist/status-line.d.ts +32 -0
  241. package/dist/status-line.d.ts.map +1 -0
  242. package/dist/status-line.js +69 -0
  243. package/dist/status-line.js.map +1 -0
  244. package/dist/syntax/filetype.d.ts +12 -0
  245. package/dist/syntax/filetype.d.ts.map +1 -0
  246. package/dist/syntax/filetype.js +28 -0
  247. package/dist/syntax/filetype.js.map +1 -0
  248. package/dist/syntax/grammars.d.ts +42 -0
  249. package/dist/syntax/grammars.d.ts.map +1 -0
  250. package/dist/syntax/grammars.js +52 -0
  251. package/dist/syntax/grammars.js.map +1 -0
  252. package/dist/text-offset.d.ts +5 -0
  253. package/dist/text-offset.d.ts.map +1 -0
  254. package/dist/text-offset.js +38 -0
  255. package/dist/text-offset.js.map +1 -0
  256. package/dist/text-wrap.d.ts +12 -0
  257. package/dist/text-wrap.d.ts.map +1 -0
  258. package/dist/text-wrap.js +53 -0
  259. package/dist/text-wrap.js.map +1 -0
  260. package/dist/theme-controller.d.ts +77 -0
  261. package/dist/theme-controller.d.ts.map +1 -0
  262. package/dist/theme-controller.js +178 -0
  263. package/dist/theme-controller.js.map +1 -0
  264. package/dist/theme.d.ts +51 -0
  265. package/dist/theme.d.ts.map +1 -0
  266. package/dist/theme.js +86 -0
  267. package/dist/theme.js.map +1 -0
  268. package/dist/tmux-check.d.ts +35 -0
  269. package/dist/tmux-check.d.ts.map +1 -0
  270. package/dist/tmux-check.js +66 -0
  271. package/dist/tmux-check.js.map +1 -0
  272. package/dist/tmux.d.ts +69 -0
  273. package/dist/tmux.d.ts.map +1 -0
  274. package/dist/tmux.js +135 -0
  275. package/dist/tmux.js.map +1 -0
  276. package/dist/tool-diff.d.ts +51 -0
  277. package/dist/tool-diff.d.ts.map +1 -0
  278. package/dist/tool-diff.js +158 -0
  279. package/dist/tool-diff.js.map +1 -0
  280. package/dist/tool-presentation.d.ts +46 -0
  281. package/dist/tool-presentation.d.ts.map +1 -0
  282. package/dist/tool-presentation.js +148 -0
  283. package/dist/tool-presentation.js.map +1 -0
  284. package/dist/tool-renderer-view.d.ts +14 -0
  285. package/dist/tool-renderer-view.d.ts.map +1 -0
  286. package/dist/tool-renderer-view.js +10 -0
  287. package/dist/tool-renderer-view.js.map +1 -0
  288. package/dist/transcript-search.d.ts +54 -0
  289. package/dist/transcript-search.d.ts.map +1 -0
  290. package/dist/transcript-search.js +160 -0
  291. package/dist/transcript-search.js.map +1 -0
  292. package/dist/transcript.d.ts +59 -0
  293. package/dist/transcript.d.ts.map +1 -0
  294. package/dist/transcript.js +123 -0
  295. package/dist/transcript.js.map +1 -0
  296. package/dist/workflow-tools.d.ts +42 -0
  297. package/dist/workflow-tools.d.ts.map +1 -0
  298. package/dist/workflow-tools.js +89 -0
  299. package/dist/workflow-tools.js.map +1 -0
  300. package/examples/themes/ember.json +75 -0
  301. package/grammars/bash/LICENSE +21 -0
  302. package/grammars/bash/highlights.scm +56 -0
  303. package/grammars/bash/tree-sitter-bash.wasm +0 -0
  304. package/grammars/css/LICENSE +21 -0
  305. package/grammars/css/highlights.scm +76 -0
  306. package/grammars/css/tree-sitter-css.wasm +0 -0
  307. package/grammars/go/LICENSE +21 -0
  308. package/grammars/go/highlights.scm +123 -0
  309. package/grammars/go/tree-sitter-go.wasm +0 -0
  310. package/grammars/html/LICENSE +21 -0
  311. package/grammars/html/highlights.scm +13 -0
  312. package/grammars/html/tree-sitter-html.wasm +0 -0
  313. package/grammars/json/LICENSE +21 -0
  314. package/grammars/json/highlights.scm +16 -0
  315. package/grammars/json/tree-sitter-json.wasm +0 -0
  316. package/grammars/python/LICENSE +21 -0
  317. package/grammars/python/highlights.scm +137 -0
  318. package/grammars/python/tree-sitter-python.wasm +0 -0
  319. package/grammars/rust/LICENSE +21 -0
  320. package/grammars/rust/highlights.scm +161 -0
  321. package/grammars/rust/tree-sitter-rust.wasm +0 -0
  322. package/grammars/yaml/LICENSE +20 -0
  323. package/grammars/yaml/highlights.scm +79 -0
  324. package/grammars/yaml/tree-sitter-yaml.wasm +0 -0
  325. package/package.json +56 -5
@@ -0,0 +1,77 @@
1
+ import { type CrewCoderTheme } from "@onpoint-dev-tools/crewcoder-tui-core/theme/crewcoder-theme";
2
+ import type { PaletteCommand } from "./palette-model.js";
3
+ import { type AppTheme } from "./theme.js";
4
+ /** Where the picked theme is remembered between launches. */
5
+ export type ThemeStore = {
6
+ read(): string | undefined;
7
+ write(selector: string): void;
8
+ };
9
+ /** Where the startup theme came from; `flag` and `env` outrank a saved pick. */
10
+ export type ThemeSource = "flag" | "env" | "saved" | "default";
11
+ export type ThemeDirs = {
12
+ /** `$CREWCODER_HOME/themes`: the user's own themes. */
13
+ themes: string;
14
+ /** Themes shipped with the package (`examples/themes`). */
15
+ examples: string;
16
+ };
17
+ export declare const DEFAULT_THEME = "slate";
18
+ /** The package's `examples/themes`, from `src/` and from `dist/` alike. */
19
+ export declare const EXAMPLE_THEMES_DIR: string;
20
+ export declare function defaultThemeDirs(): ThemeDirs;
21
+ /** `$CREWCODER_HOME/opentui.json` (`{ "theme": "<name>" }`); other keys are kept on write. */
22
+ export declare function fileThemeStore(file?: string): ThemeStore;
23
+ export type StartupTheme = {
24
+ theme: CrewCoderTheme;
25
+ selector: string;
26
+ source: ThemeSource;
27
+ /** A saved theme that no longer loads: startup falls back to slate and says why. */
28
+ warning?: string;
29
+ };
30
+ /**
31
+ * `--theme`, then `CREWCODER_THEME`, then the saved pick, then slate. A bad
32
+ * flag or variable is a startup error (the user asked for it just now); a bad
33
+ * saved theme (file deleted or edited since) falls back with a warning.
34
+ */
35
+ export declare function resolveStartupTheme(flag: string | undefined, env: string | undefined, store: ThemeStore, dirs: ThemeDirs): StartupTheme;
36
+ export type ThemeHost = {
37
+ changed(): void;
38
+ };
39
+ /**
40
+ * The active theme and the `/theme` picker: list every theme, preview the
41
+ * highlighted one, apply and remember a pick. Unconfigured (tests, before
42
+ * `cli.tsx` runs) it shows slate, lists only built-ins, and saves nothing.
43
+ */
44
+ export declare class ThemeController {
45
+ private readonly host;
46
+ private store;
47
+ private dirs;
48
+ private source;
49
+ /** The applied theme: what Esc returns to after a preview. */
50
+ private applied;
51
+ private previewing;
52
+ /** Options from the last `items()` call, so previews do not reload files per keystroke. */
53
+ private options;
54
+ /** Called when the visible theme changes (the renderer background); wired by cli.tsx. */
55
+ onChange: ((theme: AppTheme) => void) | undefined;
56
+ constructor(host: ThemeHost);
57
+ configure(startup: StartupTheme, store: ThemeStore, dirs: ThemeDirs): void;
58
+ /** The theme on screen: a preview while the picker browses, else the applied one. */
59
+ get current(): AppTheme;
60
+ get selector(): string;
61
+ /** Built-ins, then the user's themes, then shipped examples; broken files say why. */
62
+ items(): PaletteCommand[];
63
+ /** Show the highlighted theme without applying it; unusable entries keep the screen as is. */
64
+ preview(id: string | undefined): void;
65
+ /** Esc: back to the applied theme. */
66
+ endPreview(): void;
67
+ /**
68
+ * Apply and remember a theme by name or path (picker Enter, `/theme <name>`).
69
+ * Returns the alert text; throws a readable error when it cannot be loaded.
70
+ */
71
+ apply(id: string): {
72
+ title: string;
73
+ body?: string;
74
+ };
75
+ private emit;
76
+ }
77
+ //# sourceMappingURL=theme-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-controller.d.ts","sourceRoot":"","sources":["../src/theme-controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,6DAA6D,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtE,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,IAAI,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG;IACtB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,aAAa,UAAU,CAAC;AAErC,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,QAAiE,CAAC;AAEjG,wBAAgB,gBAAgB,IAAI,SAAS,CAE5C;AAED,8FAA8F;AAC9F,wBAAgB,cAAc,CAA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IAAI,IAAI;IAMlB;;;OAGG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAoBnD,OAAO,CAAC,IAAI;CAIb"}
@@ -0,0 +1,178 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { builtinTheme, defaultThemesDir, listThemeFiles, loadCrewCoderTheme, slateCrewCoderTheme } from "@onpoint-dev-tools/crewcoder-tui-core/theme/crewcoder-theme";
6
+ import { errorMessage } from "./crewcoder-cli.js";
7
+ import { slateAppTheme, toAppTheme } from "./theme.js";
8
+ export const DEFAULT_THEME = "slate";
9
+ /** The package's `examples/themes`, from `src/` and from `dist/` alike. */
10
+ export const EXAMPLE_THEMES_DIR = fileURLToPath(new URL("../examples/themes/", import.meta.url));
11
+ export function defaultThemeDirs() {
12
+ return { themes: defaultThemesDir(), examples: EXAMPLE_THEMES_DIR };
13
+ }
14
+ /** `$CREWCODER_HOME/opentui.json` (`{ "theme": "<name>" }`); other keys are kept on write. */
15
+ export function fileThemeStore(file = path.join(process.env.CREWCODER_HOME?.trim() || path.join(os.homedir(), ".crewcoder"), "opentui.json")) {
16
+ const readSettings = () => {
17
+ try {
18
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
19
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
20
+ }
21
+ catch {
22
+ return {};
23
+ }
24
+ };
25
+ return {
26
+ read: () => {
27
+ const theme = readSettings().theme;
28
+ return typeof theme === "string" && theme.trim() ? theme.trim() : undefined;
29
+ },
30
+ write: (selector) => {
31
+ fs.mkdirSync(path.dirname(file), { recursive: true });
32
+ const temp = `${file}.${process.pid}.tmp`;
33
+ fs.writeFileSync(temp, `${JSON.stringify({ ...readSettings(), theme: selector }, null, 2)}\n`);
34
+ fs.renameSync(temp, file);
35
+ }
36
+ };
37
+ }
38
+ /**
39
+ * `--theme`, then `CREWCODER_THEME`, then the saved pick, then slate. A bad
40
+ * flag or variable is a startup error (the user asked for it just now); a bad
41
+ * saved theme (file deleted or edited since) falls back with a warning.
42
+ */
43
+ export function resolveStartupTheme(flag, env, store, dirs) {
44
+ const load = (selector) => loadCrewCoderTheme(selector, { themesDir: dirs.themes, extraDirs: [dirs.examples] });
45
+ const explicit = flag?.trim() ? { selector: flag.trim(), source: "flag" } : env?.trim() ? { selector: env.trim(), source: "env" } : undefined;
46
+ if (explicit)
47
+ return { theme: load(explicit.selector), ...explicit };
48
+ const saved = store.read();
49
+ if (!saved)
50
+ return { theme: slateCrewCoderTheme, selector: DEFAULT_THEME, source: "default" };
51
+ try {
52
+ return { theme: load(saved), selector: saved, source: "saved" };
53
+ }
54
+ catch (error) {
55
+ return { theme: slateCrewCoderTheme, selector: DEFAULT_THEME, source: "default", warning: `Saved theme "${saved}" could not be loaded, using slate: ${errorMessage(error)}` };
56
+ }
57
+ }
58
+ const BUILTINS = [
59
+ ["slate", "Minimal slate (default)"],
60
+ ["dark", "Gotham, the legacy UI's default (alias: crewcoder)"],
61
+ ["light", "Light teal on pale grey-green"]
62
+ ];
63
+ /** `crewcoder` is the same theme as `dark`. */
64
+ const canonical = (selector) => (selector === "crewcoder" ? "dark" : selector);
65
+ /**
66
+ * The active theme and the `/theme` picker: list every theme, preview the
67
+ * highlighted one, apply and remember a pick. Unconfigured (tests, before
68
+ * `cli.tsx` runs) it shows slate, lists only built-ins, and saves nothing.
69
+ */
70
+ export class ThemeController {
71
+ host;
72
+ store;
73
+ dirs;
74
+ source = "default";
75
+ /** The applied theme: what Esc returns to after a preview. */
76
+ applied = { theme: slateAppTheme, selector: DEFAULT_THEME };
77
+ previewing;
78
+ /** Options from the last `items()` call, so previews do not reload files per keystroke. */
79
+ options = new Map();
80
+ /** Called when the visible theme changes (the renderer background); wired by cli.tsx. */
81
+ onChange;
82
+ constructor(host) {
83
+ this.host = host;
84
+ }
85
+ configure(startup, store, dirs) {
86
+ this.store = store;
87
+ this.dirs = dirs;
88
+ this.source = startup.source;
89
+ this.applied = { theme: toAppTheme(startup.theme), selector: canonical(startup.selector) };
90
+ this.previewing = undefined;
91
+ }
92
+ /** The theme on screen: a preview while the picker browses, else the applied one. */
93
+ get current() {
94
+ return (this.previewing ?? this.applied).theme;
95
+ }
96
+ get selector() {
97
+ return this.applied.selector;
98
+ }
99
+ /** Built-ins, then the user's themes, then shipped examples; broken files say why. */
100
+ items() {
101
+ const examples = this.dirs?.examples;
102
+ // The palette shows groups in first-item order: the user's own themes before examples.
103
+ const files = (this.dirs ? listThemeFiles([this.dirs.themes, this.dirs.examples]) : [])
104
+ .sort((a, b) => Number(a.dir === examples) - Number(b.dir === examples));
105
+ const options = [
106
+ ...BUILTINS.map(([name, description]) => ({ id: name, label: name, description, group: "Built-in", theme: builtinTheme(name) })),
107
+ ...files.map((file) => ({
108
+ id: file.name,
109
+ label: file.name,
110
+ description: file.error ? `Unusable: ${file.error}` : file.theme?.name && file.theme.name !== file.name ? file.theme.name : undefined,
111
+ group: file.dir === examples ? "Examples" : `Your themes (${this.dirs ? shortHome(this.dirs.themes) : ""})`,
112
+ ...(file.theme ? { theme: file.theme } : {}),
113
+ ...(file.error ? { error: file.error } : {})
114
+ }))
115
+ ];
116
+ // A theme given as a path (`--theme ./mine.json`) is not in any directory; keep it pickable.
117
+ if (!options.some((option) => option.id === this.applied.selector)) {
118
+ options.unshift({ id: this.applied.selector, label: path.basename(this.applied.selector), description: this.applied.selector, group: "Current" });
119
+ }
120
+ this.options = new Map(options.map((option) => [option.id, option]));
121
+ return options.map(({ theme: _theme, error: _error, ...item }) => ({ ...item, current: item.id === this.applied.selector }));
122
+ }
123
+ /** Show the highlighted theme without applying it; unusable entries keep the screen as is. */
124
+ preview(id) {
125
+ if (id === undefined)
126
+ return;
127
+ const option = this.options.get(id);
128
+ const next = id === this.applied.selector ? undefined : option?.theme ? { theme: toAppTheme(option.theme), selector: id } : this.previewing;
129
+ if (next === this.previewing)
130
+ return;
131
+ this.previewing = next;
132
+ this.emit();
133
+ }
134
+ /** Esc: back to the applied theme. */
135
+ endPreview() {
136
+ if (!this.previewing)
137
+ return;
138
+ this.previewing = undefined;
139
+ this.emit();
140
+ }
141
+ /**
142
+ * Apply and remember a theme by name or path (picker Enter, `/theme <name>`).
143
+ * Returns the alert text; throws a readable error when it cannot be loaded.
144
+ */
145
+ apply(id) {
146
+ const selector = canonical(id.trim());
147
+ const cached = this.options.get(selector);
148
+ if (cached?.error)
149
+ throw new Error(cached.error);
150
+ const theme = cached?.theme ?? loadCrewCoderTheme(selector, { themesDir: this.dirs?.themes, extraDirs: this.dirs ? [this.dirs.examples] : [] });
151
+ this.applied = { theme: toAppTheme(theme), selector };
152
+ this.previewing = undefined;
153
+ this.emit();
154
+ let body;
155
+ try {
156
+ this.store?.write(selector);
157
+ }
158
+ catch (error) {
159
+ return { title: `Theme: ${selector}`, body: `Applied for this session, but it could not be saved: ${errorMessage(error)}` };
160
+ }
161
+ if (this.source === "flag")
162
+ body = "Saved, but --theme picks the theme while it is passed.";
163
+ else if (this.source === "env")
164
+ body = "Saved, but CREWCODER_THEME picks the theme while it is set.";
165
+ else if (this.store)
166
+ body = "Saved for next launch.";
167
+ return { title: `Theme: ${selector}`, ...(body ? { body } : {}) };
168
+ }
169
+ emit() {
170
+ this.onChange?.(this.current);
171
+ this.host.changed();
172
+ }
173
+ }
174
+ function shortHome(dir) {
175
+ const home = os.homedir();
176
+ return dir === home || dir.startsWith(`${home}${path.sep}`) ? `~${dir.slice(home.length)}` : dir;
177
+ }
178
+ //# sourceMappingURL=theme-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-controller.js","sourceRoot":"","sources":["../src/theme-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EA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,EAAE,CAAC;YACf,OAAO,EAAE,KAAK,EAAE,UAAU,QAAQ,EAAE,EAAE,IAAI,EAAE,wDAAwD,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;QAC9H,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE,IAAI,GAAG,wDAAwD,CAAC;aACvF,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK;YAAE,IAAI,GAAG,6DAA6D,CAAC;aAChG,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,GAAG,wBAAwB,CAAC;QACrD,OAAO,EAAE,KAAK,EAAE,UAAU,QAAQ,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACpE,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;CACF;AAED,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AACnG,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n builtinTheme,\n defaultThemesDir,\n listThemeFiles,\n loadCrewCoderTheme,\n slateCrewCoderTheme,\n type CrewCoderTheme\n} from \"@onpoint-dev-tools/crewcoder-tui-core/theme/crewcoder-theme\";\nimport { errorMessage } from \"./crewcoder-cli.js\";\nimport type { PaletteCommand } from \"./palette-model.js\";\nimport { slateAppTheme, toAppTheme, type AppTheme } from \"./theme.js\";\n\n/** Where the picked theme is remembered between launches. */\nexport type ThemeStore = {\n read(): string | undefined;\n write(selector: string): void;\n};\n\n/** Where the startup theme came from; `flag` and `env` outrank a saved pick. */\nexport type ThemeSource = \"flag\" | \"env\" | \"saved\" | \"default\";\n\nexport type ThemeDirs = {\n /** `$CREWCODER_HOME/themes`: the user's own themes. */\n themes: string;\n /** Themes shipped with the package (`examples/themes`). */\n examples: string;\n};\n\nexport const DEFAULT_THEME = \"slate\";\n\n/** The package's `examples/themes`, from `src/` and from `dist/` alike. */\nexport const EXAMPLE_THEMES_DIR = fileURLToPath(new URL(\"../examples/themes/\", import.meta.url));\n\nexport function defaultThemeDirs(): ThemeDirs {\n return { themes: defaultThemesDir(), examples: EXAMPLE_THEMES_DIR };\n}\n\n/** `$CREWCODER_HOME/opentui.json` (`{ \"theme\": \"<name>\" }`); other keys are kept on write. */\nexport function fileThemeStore(file = path.join(process.env.CREWCODER_HOME?.trim() || path.join(os.homedir(), \".crewcoder\"), \"opentui.json\")): ThemeStore {\n const readSettings = (): Record<string, unknown> => {\n try {\n const parsed: unknown = JSON.parse(fs.readFileSync(file, \"utf8\"));\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : {};\n } catch {\n return {};\n }\n };\n return {\n read: () => {\n const theme = readSettings().theme;\n return typeof theme === \"string\" && theme.trim() ? theme.trim() : undefined;\n },\n write: (selector) => {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n const temp = `${file}.${process.pid}.tmp`;\n fs.writeFileSync(temp, `${JSON.stringify({ ...readSettings(), theme: selector }, null, 2)}\\n`);\n fs.renameSync(temp, file);\n }\n };\n}\n\nexport type StartupTheme = {\n theme: CrewCoderTheme;\n selector: string;\n source: ThemeSource;\n /** A saved theme that no longer loads: startup falls back to slate and says why. */\n warning?: string;\n};\n\n/**\n * `--theme`, then `CREWCODER_THEME`, then the saved pick, then slate. A bad\n * flag or variable is a startup error (the user asked for it just now); a bad\n * saved theme (file deleted or edited since) falls back with a warning.\n */\nexport function resolveStartupTheme(flag: string | undefined, env: string | undefined, store: ThemeStore, dirs: ThemeDirs): StartupTheme {\n const load = (selector: string): CrewCoderTheme => loadCrewCoderTheme(selector, { themesDir: dirs.themes, extraDirs: [dirs.examples] });\n const explicit = flag?.trim() ? { selector: flag.trim(), source: \"flag\" as const } : env?.trim() ? { selector: env.trim(), source: \"env\" as const } : undefined;\n if (explicit) return { theme: load(explicit.selector), ...explicit };\n const saved = store.read();\n if (!saved) return { theme: slateCrewCoderTheme, selector: DEFAULT_THEME, source: \"default\" };\n try {\n return { theme: load(saved), selector: saved, source: \"saved\" };\n } catch (error) {\n return { theme: slateCrewCoderTheme, selector: DEFAULT_THEME, source: \"default\", warning: `Saved theme \"${saved}\" could not be loaded, using slate: ${errorMessage(error)}` };\n }\n}\n\nconst BUILTINS: ReadonlyArray<readonly [string, string]> = [\n [\"slate\", \"Minimal slate (default)\"],\n [\"dark\", \"Gotham, the legacy UI's default (alias: crewcoder)\"],\n [\"light\", \"Light teal on pale grey-green\"]\n];\n\n/** `crewcoder` is the same theme as `dark`. */\nconst canonical = (selector: string): string => (selector === \"crewcoder\" ? \"dark\" : selector);\n\ntype ThemeOption = PaletteCommand & { theme?: CrewCoderTheme; error?: string };\n\nexport type ThemeHost = {\n changed(): void;\n};\n\n/**\n * The active theme and the `/theme` picker: list every theme, preview the\n * highlighted one, apply and remember a pick. Unconfigured (tests, before\n * `cli.tsx` runs) it shows slate, lists only built-ins, and saves nothing.\n */\nexport class ThemeController {\n private readonly host: ThemeHost;\n private store: ThemeStore | undefined;\n private dirs: ThemeDirs | undefined;\n private source: ThemeSource = \"default\";\n /** The applied theme: what Esc returns to after a preview. */\n private applied: { theme: AppTheme; selector: string } = { theme: slateAppTheme, selector: DEFAULT_THEME };\n private previewing: { theme: AppTheme; selector: string } | undefined;\n /** Options from the last `items()` call, so previews do not reload files per keystroke. */\n private options = new Map<string, ThemeOption>();\n /** Called when the visible theme changes (the renderer background); wired by cli.tsx. */\n onChange: ((theme: AppTheme) => void) | undefined;\n\n constructor(host: ThemeHost) {\n this.host = host;\n }\n\n configure(startup: StartupTheme, store: ThemeStore, dirs: ThemeDirs): void {\n this.store = store;\n this.dirs = dirs;\n this.source = startup.source;\n this.applied = { theme: toAppTheme(startup.theme), selector: canonical(startup.selector) };\n this.previewing = undefined;\n }\n\n /** The theme on screen: a preview while the picker browses, else the applied one. */\n get current(): AppTheme {\n return (this.previewing ?? this.applied).theme;\n }\n\n get selector(): string {\n return this.applied.selector;\n }\n\n /** Built-ins, then the user's themes, then shipped examples; broken files say why. */\n items(): PaletteCommand[] {\n const examples = this.dirs?.examples;\n // The palette shows groups in first-item order: the user's own themes before examples.\n const files = (this.dirs ? listThemeFiles([this.dirs.themes, this.dirs.examples]) : [])\n .sort((a, b) => Number(a.dir === examples) - Number(b.dir === examples));\n const options: ThemeOption[] = [\n ...BUILTINS.map(([name, description]) => ({ id: name, label: name, description, group: \"Built-in\", theme: builtinTheme(name) })),\n ...files.map((file) => ({\n id: file.name,\n label: file.name,\n description: file.error ? `Unusable: ${file.error}` : file.theme?.name && file.theme.name !== file.name ? file.theme.name : undefined,\n group: file.dir === examples ? \"Examples\" : `Your themes (${this.dirs ? shortHome(this.dirs.themes) : \"\"})`,\n ...(file.theme ? { theme: file.theme } : {}),\n ...(file.error ? { error: file.error } : {})\n }))\n ];\n // A theme given as a path (`--theme ./mine.json`) is not in any directory; keep it pickable.\n if (!options.some((option) => option.id === this.applied.selector)) {\n options.unshift({ id: this.applied.selector, label: path.basename(this.applied.selector), description: this.applied.selector, group: \"Current\" });\n }\n this.options = new Map(options.map((option) => [option.id, option]));\n return options.map(({ theme: _theme, error: _error, ...item }) => ({ ...item, current: item.id === this.applied.selector }));\n }\n\n /** Show the highlighted theme without applying it; unusable entries keep the screen as is. */\n preview(id: string | undefined): void {\n if (id === undefined) return;\n const option = this.options.get(id);\n const next = id === this.applied.selector ? undefined : option?.theme ? { theme: toAppTheme(option.theme), selector: id } : this.previewing;\n if (next === this.previewing) return;\n this.previewing = next;\n this.emit();\n }\n\n /** Esc: back to the applied theme. */\n endPreview(): void {\n if (!this.previewing) return;\n this.previewing = undefined;\n this.emit();\n }\n\n /**\n * Apply and remember a theme by name or path (picker Enter, `/theme <name>`).\n * Returns the alert text; throws a readable error when it cannot be loaded.\n */\n apply(id: string): { title: string; body?: string } {\n const selector = canonical(id.trim());\n const cached = this.options.get(selector);\n if (cached?.error) throw new Error(cached.error);\n const theme = cached?.theme ?? loadCrewCoderTheme(selector, { themesDir: this.dirs?.themes, extraDirs: this.dirs ? [this.dirs.examples] : [] });\n this.applied = { theme: toAppTheme(theme), selector };\n this.previewing = undefined;\n this.emit();\n let body: string | undefined;\n try {\n this.store?.write(selector);\n } catch (error) {\n return { title: `Theme: ${selector}`, body: `Applied for this session, but it could not be saved: ${errorMessage(error)}` };\n }\n if (this.source === \"flag\") body = \"Saved, but --theme picks the theme while it is passed.\";\n else if (this.source === \"env\") body = \"Saved, but CREWCODER_THEME picks the theme while it is set.\";\n else if (this.store) body = \"Saved for next launch.\";\n return { title: `Theme: ${selector}`, ...(body ? { body } : {}) };\n }\n\n private emit(): void {\n this.onChange?.(this.current);\n this.host.changed();\n }\n}\n\nfunction shortHome(dir: string): string {\n const home = os.homedir();\n return dir === home || dir.startsWith(`${home}${path.sep}`) ? `~${dir.slice(home.length)}` : dir;\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { type CrewCoderTheme, type MarkdownColors, type SyntaxColors } from "@onpoint-dev-tools/crewcoder-tui-core/theme/crewcoder-theme";
2
+ import type { Theme } from "./components/ui/types.js";
3
+ import type { TranscriptTone } from "./transcript.js";
4
+ /** Inline diff row and gutter colors. */
5
+ export type DiffColors = {
6
+ addedBg: string;
7
+ removedBg: string;
8
+ addedLineNumberBg: string;
9
+ removedLineNumberBg: string;
10
+ lineNumberBg: string;
11
+ };
12
+ /**
13
+ * The two ends of the welcome-logo pulse (`logo-pulse.ts`): legacy breathes from
14
+ * the accent at half brightness up to the glow color.
15
+ */
16
+ export type LogoColors = {
17
+ /** Trough color. */
18
+ dim: string;
19
+ /** Peak color; also the static color when motion is reduced. */
20
+ bright: string;
21
+ };
22
+ /** How dim the trough gets, as a fraction of the accent color (legacy value). */
23
+ export declare const LOGO_PULSE_FLOOR = 0.5;
24
+ /**
25
+ * Everything the UI colors with: termcn component tokens (`ui`, through
26
+ * `ThemeProvider`) plus the diff, Tree-sitter, and markdown element colors
27
+ * termcn has no tokens for (through `AppColorsContext`).
28
+ */
29
+ export type AppTheme = {
30
+ ui: Theme;
31
+ diff: DiffColors;
32
+ syntax: SyntaxColors;
33
+ markdown: MarkdownColors;
34
+ logo: LogoColors;
35
+ };
36
+ /**
37
+ * Map a shared CrewCoder theme (the legacy token set used by theme JSON files)
38
+ * onto termcn tokens, so one file looks the same in both UIs. Text drawn on a
39
+ * colored chip uses the theme background.
40
+ */
41
+ export declare function toAppTheme(crew: CrewCoderTheme): AppTheme;
42
+ /** `from` moved `amount` (0..1) of the way to `to`; both `#rrggbb`. */
43
+ export declare function mixHex(from: string, to: string, amount: number): string;
44
+ /** The default palette (minimal slate). */
45
+ export declare const slateAppTheme: AppTheme;
46
+ /** Slate termcn tokens, for components and tests that only need `ui`. */
47
+ export declare const slateTheme: Theme;
48
+ export declare function toneColor(theme: Theme, tone: TranscriptTone): string;
49
+ /** Reasoning text is muted; everything else uses the body color. */
50
+ export declare function bodyColor(theme: Theme, tone: TranscriptTone): string;
51
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAC/J,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0B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1,86 @@
1
+ import { slateCrewCoderTheme } from "@onpoint-dev-tools/crewcoder-tui-core/theme/crewcoder-theme";
2
+ import { defaultTheme } from "./lib/terminal-themes/default.js";
3
+ /** How dim the trough gets, as a fraction of the accent color (legacy value). */
4
+ export const LOGO_PULSE_FLOOR = 0.5;
5
+ /**
6
+ * Map a shared CrewCoder theme (the legacy token set used by theme JSON files)
7
+ * onto termcn tokens, so one file looks the same in both UIs. Text drawn on a
8
+ * colored chip uses the theme background.
9
+ */
10
+ export function toAppTheme(crew) {
11
+ const onColor = crew.background;
12
+ const ui = {
13
+ ...defaultTheme,
14
+ name: crew.name,
15
+ border: { color: crew.border, focusColor: crew.borderStrong, style: "rounded" },
16
+ colors: {
17
+ background: crew.background,
18
+ foreground: crew.text,
19
+ primary: crew.primary,
20
+ primaryForeground: onColor,
21
+ secondary: crew.panelAlt,
22
+ secondaryForeground: crew.text,
23
+ accent: crew.accent,
24
+ accentForeground: onColor,
25
+ success: crew.success,
26
+ successForeground: onColor,
27
+ warning: crew.warning,
28
+ warningForeground: onColor,
29
+ error: crew.danger,
30
+ errorForeground: onColor,
31
+ // The legacy token set has no info color; links and hints use primary.
32
+ info: crew.primary,
33
+ infoForeground: onColor,
34
+ muted: crew.panel,
35
+ mutedForeground: crew.muted,
36
+ border: crew.border,
37
+ focusRing: crew.borderStrong,
38
+ selection: crew.selectedBg,
39
+ selectionForeground: crew.text
40
+ }
41
+ };
42
+ return {
43
+ ui,
44
+ diff: {
45
+ addedBg: crew.diffAddBg,
46
+ removedBg: crew.diffDelBg,
47
+ // Gutters are the row tint lifted slightly toward the text color.
48
+ addedLineNumberBg: mixHex(crew.diffAddBg, crew.text, GUTTER_LIFT),
49
+ removedLineNumberBg: mixHex(crew.diffDelBg, crew.text, GUTTER_LIFT),
50
+ lineNumberBg: crew.backgroundAlt
51
+ },
52
+ syntax: crew.syntax,
53
+ markdown: crew.markdown,
54
+ logo: { dim: mixHex(crew.accent, "#000000", 1 - LOGO_PULSE_FLOOR), bright: crew.glow }
55
+ };
56
+ }
57
+ const GUTTER_LIFT = 0.03;
58
+ /** `from` moved `amount` (0..1) of the way to `to`; both `#rrggbb`. */
59
+ export function mixHex(from, to, amount) {
60
+ const channel = (hex, index) => Number.parseInt(hex.slice(1 + index * 2, 3 + index * 2), 16);
61
+ return `#${[0, 1, 2].map((index) => {
62
+ const value = Math.round(channel(from, index) + (channel(to, index) - channel(from, index)) * amount);
63
+ return value.toString(16).padStart(2, "0");
64
+ }).join("")}`;
65
+ }
66
+ /** The default palette (minimal slate). */
67
+ export const slateAppTheme = toAppTheme(slateCrewCoderTheme);
68
+ /** Slate termcn tokens, for components and tests that only need `ui`. */
69
+ export const slateTheme = slateAppTheme.ui;
70
+ export function toneColor(theme, tone) {
71
+ switch (tone) {
72
+ case "user": return theme.colors.primary;
73
+ case "assistant": return theme.colors.success;
74
+ case "thinking": return theme.colors.mutedForeground;
75
+ case "tool": return theme.colors.info;
76
+ case "approval": return theme.colors.warning;
77
+ case "error": return theme.colors.error;
78
+ case "system":
79
+ case "muted": return theme.colors.mutedForeground;
80
+ }
81
+ }
82
+ /** Reasoning text is muted; everything else uses the body color. */
83
+ export function bodyColor(theme, tone) {
84
+ return tone === "thinking" ? theme.colors.mutedForeground : theme.colors.foreground;
85
+ }
86
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA+D,MAAM,6DAA6D,CAAC;AAE/J,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAuBhE,iFAAiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAepC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;IAChC,MAAM,EAAE,GAAU;QAChB,GAAG,YAAY;QACf,IAAI,EAA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UAAU,GAAU,aAAa,CAAC,EAAE,CAAC;AAElD,MAAM,UAAU,SAAS,CAAC,KAAY,EAAE,IAAoB;IAC1D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QACzC,KAAK,WAAW,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QAC9C,KAAK,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC;QACrD,KAAK,MAAM,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QACtC,KAAK,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7C,KAAK,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACxC,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC;IACpD,CAAC;AACH,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,SAAS,CAAC,KAAY,EAAE,IAAoB;IAC1D,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;AACtF,CAAC","sourcesContent":["import { slateCrewCoderTheme, type CrewCoderTheme, type MarkdownColors, type SyntaxColors } from \"@onpoint-dev-tools/crewcoder-tui-core/theme/crewcoder-theme\";\nimport type { Theme } from \"./components/ui/types.js\";\nimport { defaultTheme } from \"./lib/terminal-themes/default.js\";\nimport type { TranscriptTone } from \"./transcript.js\";\n\n/** Inline diff row and gutter colors. */\nexport type DiffColors = {\n addedBg: string;\n removedBg: string;\n addedLineNumberBg: string;\n removedLineNumberBg: string;\n lineNumberBg: string;\n};\n\n/**\n * The two ends of the welcome-logo pulse (`logo-pulse.ts`): legacy breathes from\n * the accent at half brightness up to the glow color.\n */\nexport type LogoColors = {\n /** Trough color. */\n dim: string;\n /** Peak color; also the static color when motion is reduced. */\n bright: string;\n};\n\n/** How dim the trough gets, as a fraction of the accent color (legacy value). */\nexport const LOGO_PULSE_FLOOR = 0.5;\n\n/**\n * Everything the UI colors with: termcn component tokens (`ui`, through\n * `ThemeProvider`) plus the diff, Tree-sitter, and markdown element colors\n * termcn has no tokens for (through `AppColorsContext`).\n */\nexport type AppTheme = {\n ui: Theme;\n diff: DiffColors;\n syntax: SyntaxColors;\n markdown: MarkdownColors;\n logo: LogoColors;\n};\n\n/**\n * Map a shared CrewCoder theme (the legacy token set used by theme JSON files)\n * onto termcn tokens, so one file looks the same in both UIs. Text drawn on a\n * colored chip uses the theme background.\n */\nexport function toAppTheme(crew: CrewCoderTheme): AppTheme {\n const onColor = crew.background;\n const ui: Theme = {\n ...defaultTheme,\n name: crew.name,\n border: { color: crew.border, focusColor: crew.borderStrong, style: \"rounded\" },\n colors: {\n background: crew.background,\n foreground: crew.text,\n primary: crew.primary,\n primaryForeground: onColor,\n secondary: crew.panelAlt,\n secondaryForeground: crew.text,\n accent: crew.accent,\n accentForeground: onColor,\n success: crew.success,\n successForeground: onColor,\n warning: crew.warning,\n warningForeground: onColor,\n error: crew.danger,\n errorForeground: onColor,\n // The legacy token set has no info color; links and hints use primary.\n info: crew.primary,\n infoForeground: onColor,\n muted: crew.panel,\n mutedForeground: crew.muted,\n border: crew.border,\n focusRing: crew.borderStrong,\n selection: crew.selectedBg,\n selectionForeground: crew.text\n }\n };\n return {\n ui,\n diff: {\n addedBg: crew.diffAddBg,\n removedBg: crew.diffDelBg,\n // Gutters are the row tint lifted slightly toward the text color.\n addedLineNumberBg: mixHex(crew.diffAddBg, crew.text, GUTTER_LIFT),\n removedLineNumberBg: mixHex(crew.diffDelBg, crew.text, GUTTER_LIFT),\n lineNumberBg: crew.backgroundAlt\n },\n syntax: crew.syntax,\n markdown: crew.markdown,\n logo: { dim: mixHex(crew.accent, \"#000000\", 1 - LOGO_PULSE_FLOOR), bright: crew.glow }\n };\n}\n\nconst GUTTER_LIFT = 0.03;\n\n/** `from` moved `amount` (0..1) of the way to `to`; both `#rrggbb`. */\nexport function mixHex(from: string, to: string, amount: number): string {\n const channel = (hex: string, index: number): number => Number.parseInt(hex.slice(1 + index * 2, 3 + index * 2), 16);\n return `#${[0, 1, 2].map((index) => {\n const value = Math.round(channel(from, index) + (channel(to, index) - channel(from, index)) * amount);\n return value.toString(16).padStart(2, \"0\");\n }).join(\"\")}`;\n}\n\n/** The default palette (minimal slate). */\nexport const slateAppTheme: AppTheme = toAppTheme(slateCrewCoderTheme);\n/** Slate termcn tokens, for components and tests that only need `ui`. */\nexport const slateTheme: Theme = slateAppTheme.ui;\n\nexport function toneColor(theme: Theme, tone: TranscriptTone): string {\n switch (tone) {\n case \"user\": return theme.colors.primary;\n case \"assistant\": return theme.colors.success;\n case \"thinking\": return theme.colors.mutedForeground;\n case \"tool\": return theme.colors.info;\n case \"approval\": return theme.colors.warning;\n case \"error\": return theme.colors.error;\n case \"system\":\n case \"muted\": return theme.colors.mutedForeground;\n }\n}\n\n/** Reasoning text is muted; everything else uses the body color. */\nexport function bodyColor(theme: Theme, tone: TranscriptTone): string {\n return tone === \"thinking\" ? theme.colors.mutedForeground : theme.colors.foreground;\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import type { FooterAlert } from "./alert-model.js";
2
+ /**
3
+ * tmux settings OpenTUI needs, checked against a real attached client
4
+ * (`docs/TMUX.md`). With tmux's defaults:
5
+ *
6
+ * - `set-clipboard external` drops clipboard writes from programs, so a mouse
7
+ * selection never reaches the system clipboard.
8
+ * - `extended-keys off` delivers Shift+Enter as plain Enter, which sends the message.
9
+ * - `focus-events off` hides focus changes, so the focus gate cannot tell when
10
+ * this pane is in the background.
11
+ * - Without the `RGB` terminal feature tmux reduces 24-bit theme colors to 256.
12
+ */
13
+ export type TmuxSettings = {
14
+ setClipboard?: string;
15
+ extendedKeys?: string;
16
+ focusEvents?: string;
17
+ /** `#{client_termfeatures}` of the attached client, e.g. `bpaste,clipboard,RGB,title`. */
18
+ clientFeatures?: string;
19
+ };
20
+ export type TmuxIssue = {
21
+ effect: string;
22
+ fix: string;
23
+ };
24
+ /** Silence the startup hint: `CREWCODER_TUI_TMUX_HINT=0`. */
25
+ export declare const TMUX_HINT_ENV = "CREWCODER_TUI_TMUX_HINT";
26
+ export declare function tmuxIssues(settings: TmuxSettings): TmuxIssue[];
27
+ /** One startup alert listing what is missing and the tmux.conf lines that fix it. */
28
+ export declare function tmuxSettingsAlert(issues: readonly TmuxIssue[]): FooterAlert | undefined;
29
+ /** What a mouse copy really did: tmux without `set-clipboard on` drops it silently. */
30
+ export declare function copyAlert(characters: number, setClipboard: string | undefined): FooterAlert;
31
+ /** A tmux option: server scope first (where tmux keeps these), then global session scope. */
32
+ export declare function readTmuxOption(name: string): string | undefined;
33
+ /** The settings above, or undefined outside tmux. Called at startup (a few quick queries). */
34
+ export declare function readTmuxSettings(env?: NodeJS.ProcessEnv): TmuxSettings | undefined;
35
+ //# sourceMappingURL=tmux-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tmux-check.d.ts","sourceRoot":"","sources":["../src/tmux-check.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,6DAA6D;AAC7D,eAAO,MAAM,aAAa,4BAA4B,CAAC;AAEvD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAAE,CAe9D;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,WAAW,GAAG,SAAS,CAcvF;AAED,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAK3F;AAQD,6FAA6F;AAC7F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,YAAY,GAAG,SAAS,CAU/F"}
@@ -0,0 +1,66 @@
1
+ import { spawnSync } from "node:child_process";
2
+ /** Silence the startup hint: `CREWCODER_TUI_TMUX_HINT=0`. */
3
+ export const TMUX_HINT_ENV = "CREWCODER_TUI_TMUX_HINT";
4
+ export function tmuxIssues(settings) {
5
+ const issues = [];
6
+ if (settings.setClipboard !== undefined && settings.setClipboard !== "on") {
7
+ issues.push({ effect: "Mouse-select copy never reaches your clipboard", fix: "set -g set-clipboard on" });
8
+ }
9
+ if (settings.extendedKeys === "off") {
10
+ issues.push({ effect: "Shift+Enter sends instead of adding a line (Ctrl+J still adds one)", fix: "set -g extended-keys on" });
11
+ }
12
+ if (settings.focusEvents === "off") {
13
+ issues.push({ effect: "CrewCoder cannot tell when this pane is in the background", fix: "set -g focus-events on" });
14
+ }
15
+ if (settings.clientFeatures !== undefined && !settings.clientFeatures.split(",").includes("RGB")) {
16
+ issues.push({ effect: "Theme colors are reduced to 256 colors", fix: "set -as terminal-features ',xterm*:RGB' (then reattach)" });
17
+ }
18
+ return issues;
19
+ }
20
+ /** One startup alert listing what is missing and the tmux.conf lines that fix it. */
21
+ export function tmuxSettingsAlert(issues) {
22
+ if (!issues.length)
23
+ return undefined;
24
+ return {
25
+ variant: "warning",
26
+ title: `tmux: ${issues.length} setting${issues.length === 1 ? "" : "s"} missing for CrewCoder`,
27
+ body: [
28
+ ...issues.map((issue) => `• ${issue.effect}`),
29
+ "",
30
+ "Add to ~/.tmux.conf, then run: tmux source-file ~/.tmux.conf",
31
+ ...issues.map((issue) => ` ${issue.fix}`),
32
+ "",
33
+ `Hide this with ${TMUX_HINT_ENV}=0.`
34
+ ].join("\n")
35
+ };
36
+ }
37
+ /** What a mouse copy really did: tmux without `set-clipboard on` drops it silently. */
38
+ export function copyAlert(characters, setClipboard) {
39
+ if (setClipboard !== undefined && setClipboard !== "on") {
40
+ return { variant: "warning", title: "Not copied: tmux blocks clipboard writes from programs", body: "Add `set -g set-clipboard on` to ~/.tmux.conf, or Shift+drag to use the terminal's own selection." };
41
+ }
42
+ return { variant: "info", title: `Copied ${characters} characters` };
43
+ }
44
+ /** Run a tmux query; undefined when it fails (no tmux, not attached, old version). */
45
+ function tmux(args) {
46
+ const result = spawnSync("tmux", args, { encoding: "utf8", timeout: 1_000 });
47
+ return result.status === 0 && !result.error ? result.stdout.trim() : undefined;
48
+ }
49
+ /** A tmux option: server scope first (where tmux keeps these), then global session scope. */
50
+ export function readTmuxOption(name) {
51
+ return tmux(["show-options", "-sqv", name]) || tmux(["show-options", "-gqv", name]) || undefined;
52
+ }
53
+ /** The settings above, or undefined outside tmux. Called at startup (a few quick queries). */
54
+ export function readTmuxSettings(env = process.env) {
55
+ if (!env.TMUX)
56
+ return undefined;
57
+ const pane = env.TMUX_PANE;
58
+ return {
59
+ setClipboard: readTmuxOption("set-clipboard"),
60
+ extendedKeys: readTmuxOption("extended-keys"),
61
+ focusEvents: readTmuxOption("focus-events"),
62
+ // Empty with no client attached (a detached session): unknown, not "no RGB".
63
+ clientFeatures: tmux(["display-message", "-p", ...(pane ? ["-t", pane] : []), "#{client_termfeatures}"]) || undefined
64
+ };
65
+ }
66
+ //# sourceMappingURL=tmux-check.js.map
@@ -0,0 +1 @@
1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IAAY;IACzC,OAAO,IAAI,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,SAAS,CAAC;AACnG,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,gBAAgB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACnE,IAAI,CAAC,GAAG,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC;IAC3B,OAAO;QACL,YAAY,EAAE,cAAc,CAAC,eAAe,CAAC;QAC7C,YAAY,EAAE,cAAc,CAAC,eAAe,CAAC;QAC7C,WAAW,EAAE,cAAc,CAAC,cAAc,CAAC;QAC3C,6EAA6E;QAC7E,cAAc,EAAE,IAAI,CAAC,CAAC,iBAAiB,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,wBAAwB,CAAC,CAAC,IAAI,SAAS;KACtH,CAAC;AACJ,CAAC","sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport type { FooterAlert } from \"./alert-model.js\";\n\n/**\n * tmux settings OpenTUI needs, checked against a real attached client\n * (`docs/TMUX.md`). With tmux's defaults:\n *\n * - `set-clipboard external` drops clipboard writes from programs, so a mouse\n * selection never reaches the system clipboard.\n * - `extended-keys off` delivers Shift+Enter as plain Enter, which sends the message.\n * - `focus-events off` hides focus changes, so the focus gate cannot tell when\n * this pane is in the background.\n * - Without the `RGB` terminal feature tmux reduces 24-bit theme colors to 256.\n */\nexport type TmuxSettings = {\n setClipboard?: string;\n extendedKeys?: string;\n focusEvents?: string;\n /** `#{client_termfeatures}` of the attached client, e.g. `bpaste,clipboard,RGB,title`. */\n clientFeatures?: string;\n};\n\nexport type TmuxIssue = { effect: string; fix: string };\n\n/** Silence the startup hint: `CREWCODER_TUI_TMUX_HINT=0`. */\nexport const TMUX_HINT_ENV = \"CREWCODER_TUI_TMUX_HINT\";\n\nexport function tmuxIssues(settings: TmuxSettings): TmuxIssue[] {\n const issues: TmuxIssue[] = [];\n if (settings.setClipboard !== undefined && settings.setClipboard !== \"on\") {\n issues.push({ effect: \"Mouse-select copy never reaches your clipboard\", fix: \"set -g set-clipboard on\" });\n }\n if (settings.extendedKeys === \"off\") {\n issues.push({ effect: \"Shift+Enter sends instead of adding a line (Ctrl+J still adds one)\", fix: \"set -g extended-keys on\" });\n }\n if (settings.focusEvents === \"off\") {\n issues.push({ effect: \"CrewCoder cannot tell when this pane is in the background\", fix: \"set -g focus-events on\" });\n }\n if (settings.clientFeatures !== undefined && !settings.clientFeatures.split(\",\").includes(\"RGB\")) {\n issues.push({ effect: \"Theme colors are reduced to 256 colors\", fix: \"set -as terminal-features ',xterm*:RGB' (then reattach)\" });\n }\n return issues;\n}\n\n/** One startup alert listing what is missing and the tmux.conf lines that fix it. */\nexport function tmuxSettingsAlert(issues: readonly TmuxIssue[]): FooterAlert | undefined {\n if (!issues.length) return undefined;\n return {\n variant: \"warning\",\n title: `tmux: ${issues.length} setting${issues.length === 1 ? \"\" : \"s\"} missing for CrewCoder`,\n body: [\n ...issues.map((issue) => `• ${issue.effect}`),\n \"\",\n \"Add to ~/.tmux.conf, then run: tmux source-file ~/.tmux.conf\",\n ...issues.map((issue) => ` ${issue.fix}`),\n \"\",\n `Hide this with ${TMUX_HINT_ENV}=0.`\n ].join(\"\\n\")\n };\n}\n\n/** What a mouse copy really did: tmux without `set-clipboard on` drops it silently. */\nexport function copyAlert(characters: number, setClipboard: string | undefined): FooterAlert {\n if (setClipboard !== undefined && setClipboard !== \"on\") {\n return { variant: \"warning\", title: \"Not copied: tmux blocks clipboard writes from programs\", body: \"Add `set -g set-clipboard on` to ~/.tmux.conf, or Shift+drag to use the terminal's own selection.\" };\n }\n return { variant: \"info\", title: `Copied ${characters} characters` };\n}\n\n/** Run a tmux query; undefined when it fails (no tmux, not attached, old version). */\nfunction tmux(args: readonly string[]): string | undefined {\n const result = spawnSync(\"tmux\", args, { encoding: \"utf8\", timeout: 1_000 });\n return result.status === 0 && !result.error ? result.stdout.trim() : undefined;\n}\n\n/** A tmux option: server scope first (where tmux keeps these), then global session scope. */\nexport function readTmuxOption(name: string): string | undefined {\n return tmux([\"show-options\", \"-sqv\", name]) || tmux([\"show-options\", \"-gqv\", name]) || undefined;\n}\n\n/** The settings above, or undefined outside tmux. Called at startup (a few quick queries). */\nexport function readTmuxSettings(env: NodeJS.ProcessEnv = process.env): TmuxSettings | undefined {\n if (!env.TMUX) return undefined;\n const pane = env.TMUX_PANE;\n return {\n setClipboard: readTmuxOption(\"set-clipboard\"),\n extendedKeys: readTmuxOption(\"extended-keys\"),\n focusEvents: readTmuxOption(\"focus-events\"),\n // Empty with no client attached (a detached session): unknown, not \"no RGB\".\n clientFeatures: tmux([\"display-message\", \"-p\", ...(pane ? [\"-t\", pane] : []), \"#{client_termfeatures}\"]) || undefined\n };\n}\n"]}