@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,106 @@
1
+ import { DISABLED_TASKS } from "@onpoint-dev-tools/crewcoder-tui-core/state/crew-tasks";
2
+ import { clampSidebarWidth, MIN_SIDEBAR_TERMINAL_WIDTH, sidebarWidth } from "./sidebar-model.js";
3
+ /** How often the open sidebar rereads the task store; the agent writes it from another process. */
4
+ export const TASK_POLL_MS = 1000;
5
+ /**
6
+ * Sidebar display state for one UI instance: open or closed, the dragged
7
+ * width, the crew task snapshot, and refreshing the git label after runs.
8
+ * Instance-local by design; nothing here is saved or shared.
9
+ */
10
+ export class SidebarController {
11
+ open = false;
12
+ /** Width set by dragging the divider; undefined uses the default for the terminal. */
13
+ preferredWidth;
14
+ /** Undefined when tasks cannot be read here (remote SSH workspaces). */
15
+ tasks;
16
+ /** Wired by cli.tsx for local workspaces; undefined leaves `state.gitLabel` as it is. */
17
+ gitLabelReader;
18
+ host;
19
+ readTasks;
20
+ timer;
21
+ taskSignature = "";
22
+ terminalWidth = Number.POSITIVE_INFINITY;
23
+ constructor(host, readTasks) {
24
+ this.host = host;
25
+ this.readTasks = readTasks;
26
+ this.tasks = readTasks ? DISABLED_TASKS : undefined;
27
+ }
28
+ /** Columns the sidebar takes in this terminal: 0 when closed or too narrow. */
29
+ columns(terminalWidth) {
30
+ this.terminalWidth = terminalWidth;
31
+ return this.open ? sidebarWidth(terminalWidth, this.preferredWidth) : 0;
32
+ }
33
+ /** True when the sidebar is open but the terminal is too narrow to show it. */
34
+ get hiddenByWidth() {
35
+ return this.open && this.terminalWidth < MIN_SIDEBAR_TERMINAL_WIDTH;
36
+ }
37
+ toggle() {
38
+ this.setOpen(!this.open);
39
+ }
40
+ setOpen(open) {
41
+ if (open === this.open)
42
+ return;
43
+ this.open = open;
44
+ if (open) {
45
+ void this.refreshTasks();
46
+ this.startPolling();
47
+ }
48
+ else {
49
+ this.stopPolling();
50
+ }
51
+ this.host.changed();
52
+ }
53
+ /** The divider was dragged; `width` is the sidebar's new width in columns. */
54
+ resize(width, terminalWidth) {
55
+ const next = clampSidebarWidth(width, terminalWidth);
56
+ if (next === this.preferredWidth)
57
+ return;
58
+ this.preferredWidth = next;
59
+ this.host.changed();
60
+ }
61
+ /** Reread the task store; renders only when something changed. Failures leave the last snapshot. */
62
+ async refreshTasks() {
63
+ if (!this.readTasks)
64
+ return;
65
+ let snapshot;
66
+ try {
67
+ snapshot = await this.readTasks(this.host.state.cwd);
68
+ }
69
+ catch {
70
+ return;
71
+ }
72
+ const signature = JSON.stringify(snapshot);
73
+ if (signature === this.taskSignature)
74
+ return;
75
+ this.taskSignature = signature;
76
+ this.tasks = snapshot;
77
+ this.host.changed();
78
+ }
79
+ /** After a run: the branch may have moved and the tree is likely dirty now. */
80
+ async refreshGitLabel() {
81
+ const reader = this.gitLabelReader;
82
+ if (!reader)
83
+ return;
84
+ const label = await reader(this.host.state.cwd).catch(() => this.host.state.gitLabel);
85
+ if (label === this.host.state.gitLabel)
86
+ return;
87
+ this.host.state.gitLabel = label;
88
+ this.host.changed();
89
+ }
90
+ dispose() {
91
+ this.stopPolling();
92
+ }
93
+ startPolling() {
94
+ if (this.timer || !this.readTasks)
95
+ return;
96
+ this.timer = setInterval(() => void this.refreshTasks(), TASK_POLL_MS);
97
+ this.timer.unref?.();
98
+ }
99
+ stopPolling() {
100
+ if (!this.timer)
101
+ return;
102
+ clearInterval(this.timer);
103
+ this.timer = undefined;
104
+ }
105
+ }
106
+ //# sourceMappingURL=sidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../src/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,wDAAwD,CAAC;AAE/G,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOjG,mGAAmG;AACnG,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AAOjC;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAC5B,IAAI,GAAG,KAAK,CAAC;IACb,sFAAsF;IACtF,cAAc,CAAqB;IACnC,wEAAwE;IACxE,KAAK,CAA+B;IACpC,yFAAyF;IACzF,cAAc,CAA6B;IAC1B,IAAI,CAAc;IAClB,SAAS,CAAoB;IACtC,KAAK,CAA6C;IAClD,aAAa,GAAG,EAAE,CAAC;IACnB,aAAa,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAEjD,YAAY,IAA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AS;YAAE,OAAO;QAC1C,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IACvB,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF","sourcesContent":["import { DISABLED_TASKS, type CrewTaskSnapshot } from \"@onpoint-dev-tools/crewcoder-tui-core/state/crew-tasks\";\nimport type { TuiState } from \"@onpoint-dev-tools/crewcoder-tui-core/state/tui-store\";\nimport { clampSidebarWidth, MIN_SIDEBAR_TERMINAL_WIDTH, sidebarWidth } from \"./sidebar-model.js\";\n\n/** Reads the crew task store for a workspace (tui-core `readCrewTaskSnapshot`). */\nexport type TaskReader = (cwd: string) => Promise<CrewTaskSnapshot>;\n/** `<branch>[*]` for a workspace (tui-core `readGitLabelAsync`). */\nexport type GitLabelReader = (cwd: string) => Promise<string | undefined>;\n\n/** How often the open sidebar rereads the task store; the agent writes it from another process. */\nexport const TASK_POLL_MS = 1000;\n\ntype SidebarHost = {\n readonly state: TuiState;\n changed(): void;\n};\n\n/**\n * Sidebar display state for one UI instance: open or closed, the dragged\n * width, the crew task snapshot, and refreshing the git label after runs.\n * Instance-local by design; nothing here is saved or shared.\n */\nexport class SidebarController {\n open = false;\n /** Width set by dragging the divider; undefined uses the default for the terminal. */\n preferredWidth: number | undefined;\n /** Undefined when tasks cannot be read here (remote SSH workspaces). */\n tasks: CrewTaskSnapshot | undefined;\n /** Wired by cli.tsx for local workspaces; undefined leaves `state.gitLabel` as it is. */\n gitLabelReader: GitLabelReader | undefined;\n private readonly host: SidebarHost;\n private readonly readTasks: TaskReader | null;\n private timer: ReturnType<typeof setInterval> | undefined;\n private taskSignature = \"\";\n private terminalWidth = Number.POSITIVE_INFINITY;\n\n constructor(host: SidebarHost, readTasks: TaskReader | null) {\n this.host = host;\n this.readTasks = readTasks;\n this.tasks = readTasks ? DISABLED_TASKS : undefined;\n }\n\n /** Columns the sidebar takes in this terminal: 0 when closed or too narrow. */\n columns(terminalWidth: number): number {\n this.terminalWidth = terminalWidth;\n return this.open ? sidebarWidth(terminalWidth, this.preferredWidth) : 0;\n }\n\n /** True when the sidebar is open but the terminal is too narrow to show it. */\n get hiddenByWidth(): boolean {\n return this.open && this.terminalWidth < MIN_SIDEBAR_TERMINAL_WIDTH;\n }\n\n toggle(): void {\n this.setOpen(!this.open);\n }\n\n setOpen(open: boolean): void {\n if (open === this.open) return;\n this.open = open;\n if (open) {\n void this.refreshTasks();\n this.startPolling();\n } else {\n this.stopPolling();\n }\n this.host.changed();\n }\n\n /** The divider was dragged; `width` is the sidebar's new width in columns. */\n resize(width: number, terminalWidth: number): void {\n const next = clampSidebarWidth(width, terminalWidth);\n if (next === this.preferredWidth) return;\n this.preferredWidth = next;\n this.host.changed();\n }\n\n /** Reread the task store; renders only when something changed. Failures leave the last snapshot. */\n async refreshTasks(): Promise<void> {\n if (!this.readTasks) return;\n let snapshot: CrewTaskSnapshot;\n try {\n snapshot = await this.readTasks(this.host.state.cwd);\n } catch {\n return;\n }\n const signature = JSON.stringify(snapshot);\n if (signature === this.taskSignature) return;\n this.taskSignature = signature;\n this.tasks = snapshot;\n this.host.changed();\n }\n\n /** After a run: the branch may have moved and the tree is likely dirty now. */\n async refreshGitLabel(): Promise<void> {\n const reader = this.gitLabelReader;\n if (!reader) return;\n const label = await reader(this.host.state.cwd).catch(() => this.host.state.gitLabel);\n if (label === this.host.state.gitLabel) return;\n this.host.state.gitLabel = label;\n this.host.changed();\n }\n\n dispose(): void {\n this.stopPolling();\n }\n\n private startPolling(): void {\n if (this.timer || !this.readTasks) return;\n this.timer = setInterval(() => void this.refreshTasks(), TASK_POLL_MS);\n this.timer.unref?.();\n }\n\n private stopPolling(): void {\n if (!this.timer) return;\n clearInterval(this.timer);\n this.timer = undefined;\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import type { TuiState } from "@onpoint-dev-tools/crewcoder-tui-core/state/tui-store";
2
+ import { type TuiUsageSummary } from "@onpoint-dev-tools/crewcoder-tui-core/state/usage";
3
+ /**
4
+ * The one-row status line under the composer, ported from the legacy UI:
5
+ * approval access, mode (or worker), provider/model (effort), and the
6
+ * session's name on the left; context usage and session cost pinned right.
7
+ */
8
+ export type StatusLine = {
9
+ access: "Review" | "Full Access";
10
+ /** Everything after the access label, already truncated to fit. */
11
+ left: string;
12
+ /** Context usage and cost (`β—” 12.4k/200k - 6% | 12.4k tokens | $0.03`); empty until the backend reports usage. */
13
+ right: string;
14
+ };
15
+ type StatusState = Pick<TuiState, "fullAccess" | "mode" | "worker" | "workerIdentityEnabled" | "provider" | "model" | "effort" | "usage" | "gitRepo" | "blocks">;
16
+ export declare function statusLine(state: StatusState, width: number): StatusLine;
17
+ /**
18
+ * What the session is about instead of its raw id: `<repo> Β· <chat name>`.
19
+ * The chat name is the first prompt, the same label `/sessions` lists it by
20
+ * (sessions have no separate title). Either part shows alone when the other is
21
+ * missing; `new session` before any prompt outside a repo.
22
+ */
23
+ export declare function sessionName(state: Pick<TuiState, "gitRepo" | "blocks">): string;
24
+ /** Context usage and cost, or nothing before the first usage report (no `?/?` placeholder). */
25
+ export declare function usageStatus(usage: TuiUsageSummary): string;
26
+ /** The context gauge glyph (`β—‹ β—” β—‘ β—• ●`) at the start of the usage text, if any, so it can be colored. */
27
+ export declare function splitGauge(right: string): {
28
+ gauge: string;
29
+ rest: string;
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=status-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-line.d.ts","sourceRoot":"","sources":["../src/status-line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AACtF,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAI9G;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,QAAQ,GAAG,aAAa,CAAC;IACjC,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,kHAAkH;IAClH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,uBAAuB,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;AAOjK,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAYxE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC,GAAG,MAAM,CAK/E;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAK1D;AAED,0GAA0G;AAC1G,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAGzE"}
@@ -0,0 +1,69 @@
1
+ import { formatContextStatus } from "@onpoint-dev-tools/crewcoder-tui-core/state/usage";
2
+ import stringWidth from "string-width";
3
+ import { normalize } from "./transcript.js";
4
+ const SEPARATOR = " Β· ";
5
+ const ELLIPSIS = "…";
6
+ /** Minimum cells between the left side and the usage. */
7
+ const GAP = 2;
8
+ export function statusLine(state, width) {
9
+ const access = state.fullAccess ? "Full Access" : "Review";
10
+ // Same rule as the legacy composer: a worker shows only while identity is on.
11
+ const mode = state.workerIdentityEnabled && state.worker ? `worker ${state.worker}` : state.mode;
12
+ // The session's name is last, so it is the first thing to shorten.
13
+ const details = [mode, `${state.provider}/${state.model} (${state.effort})`, sessionName(state)].join(SEPARATOR);
14
+ // Access is a safety state, so it always shows. Usage takes what is left
15
+ // after it (with a two-cell gap); the details give way first.
16
+ const right = clip(usageStatus(state.usage), width - cells(access) - GAP);
17
+ const leftRoom = width - cells(access) - (right ? cells(right) + GAP : 0) - cells(SEPARATOR);
18
+ const shown = clip(details, leftRoom);
19
+ return { access, left: shown ? `${SEPARATOR}${shown}` : "", right };
20
+ }
21
+ /**
22
+ * What the session is about instead of its raw id: `<repo> Β· <chat name>`.
23
+ * The chat name is the first prompt, the same label `/sessions` lists it by
24
+ * (sessions have no separate title). Either part shows alone when the other is
25
+ * missing; `new session` before any prompt outside a repo.
26
+ */
27
+ export function sessionName(state) {
28
+ // A crew worker's brief is not the user's prompt.
29
+ const first = state.blocks.find((block) => block.type === "user" && !block.worker);
30
+ const chat = first?.type === "user" ? normalize(first.text).replace(/\s+/g, " ").trim() : "";
31
+ return [state.gitRepo, chat].filter(Boolean).join(SEPARATOR) || "new session";
32
+ }
33
+ /** Context usage and cost, or nothing before the first usage report (no `?/?` placeholder). */
34
+ export function usageStatus(usage) {
35
+ // Token counts, not cost alone: formatContextStatus would print `?/?` placeholders without them.
36
+ const known = [usage.lastInputTokens, usage.totalTokens, usage.inputTokens].some((value) => typeof value === "number");
37
+ const budget = typeof usage.tokenBudget === "number" && usage.tokenBudget > 0;
38
+ return known || budget ? formatContextStatus(usage) : "";
39
+ }
40
+ /** The context gauge glyph (`β—‹ β—” β—‘ β—• ●`) at the start of the usage text, if any, so it can be colored. */
41
+ export function splitGauge(right) {
42
+ const first = [...right][0];
43
+ return first && GAUGE_GLYPHS.has(first) ? { gauge: first, rest: right.slice(first.length) } : { gauge: "", rest: right };
44
+ }
45
+ const GAUGE_GLYPHS = new Set(["β—‹", "β—”", "β—‘", "β—•", "●"]);
46
+ /** Cut `text` to at most `room` terminal cells, ending in `…` when cut. Wide characters (emoji, CJK) count as two. */
47
+ function clip(text, room) {
48
+ if (room <= 0)
49
+ return "";
50
+ if (cells(text) <= room)
51
+ return text;
52
+ const budget = room - cells(ELLIPSIS);
53
+ let out = "";
54
+ let used = 0;
55
+ for (const { segment } of GRAPHEMES.segment(text)) {
56
+ const width = cells(segment);
57
+ if (used + width > budget)
58
+ break;
59
+ out += segment;
60
+ used += width;
61
+ }
62
+ return `${out}${ELLIPSIS}`;
63
+ }
64
+ const GRAPHEMES = new Intl.Segmenter(undefined, { granularity: "grapheme" });
65
+ /** Terminal cells, so chat names with emoji or CJK never overflow the row. */
66
+ function cells(text) {
67
+ return stringWidth(text);
68
+ }
69
+ //# sourceMappingURL=status-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-line.js","sourceRoot":"","sources":["../src/status-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,mDAAmD,CAAC;AAC9G,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiB5C,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,yDAAyD;AACzD,MAAM,GAAG,GAAG,CAAC,CAAC;AAEd,MAAM,UAAU,UAAU,CAAC,KAAkB,EAAE,KAAa;IAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC3D,8EAA8E;IAC9E,MAAM,IAAI,GAAG,KAAK,CAAC,qBAAqB,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IACjG,mEAAmE;IACnE,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,EA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AAC,CAAC;IACtC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,IAAI,GAAG,KAAK,GAAG,MAAM;YAAE,MAAM;QACjC,GAAG,IAAI,OAAO,CAAC;QACf,IAAI,IAAI,KAAK,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,GAAG,GAAG,QAAQ,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E,8EAA8E;AAC9E,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { TuiState } from \"@onpoint-dev-tools/crewcoder-tui-core/state/tui-store\";\nimport { formatContextStatus, type TuiUsageSummary } from \"@onpoint-dev-tools/crewcoder-tui-core/state/usage\";\nimport stringWidth from \"string-width\";\nimport { normalize } from \"./transcript.js\";\n\n/**\n * The one-row status line under the composer, ported from the legacy UI:\n * approval access, mode (or worker), provider/model (effort), and the\n * session's name on the left; context usage and session cost pinned right.\n */\nexport type StatusLine = {\n access: \"Review\" | \"Full Access\";\n /** Everything after the access label, already truncated to fit. */\n left: string;\n /** Context usage and cost (`β—” 12.4k/200k - 6% | 12.4k tokens | $0.03`); empty until the backend reports usage. */\n right: string;\n};\n\ntype StatusState = Pick<TuiState, \"fullAccess\" | \"mode\" | \"worker\" | \"workerIdentityEnabled\" | \"provider\" | \"model\" | \"effort\" | \"usage\" | \"gitRepo\" | \"blocks\">;\n\nconst SEPARATOR = \" Β· \";\nconst ELLIPSIS = \"…\";\n/** Minimum cells between the left side and the usage. */\nconst GAP = 2;\n\nexport function statusLine(state: StatusState, width: number): StatusLine {\n const access = state.fullAccess ? \"Full Access\" : \"Review\";\n // Same rule as the legacy composer: a worker shows only while identity is on.\n const mode = state.workerIdentityEnabled && state.worker ? `worker ${state.worker}` : state.mode;\n // The session's name is last, so it is the first thing to shorten.\n const details = [mode, `${state.provider}/${state.model} (${state.effort})`, sessionName(state)].join(SEPARATOR);\n // Access is a safety state, so it always shows. Usage takes what is left\n // after it (with a two-cell gap); the details give way first.\n const right = clip(usageStatus(state.usage), width - cells(access) - GAP);\n const leftRoom = width - cells(access) - (right ? cells(right) + GAP : 0) - cells(SEPARATOR);\n const shown = clip(details, leftRoom);\n return { access, left: shown ? `${SEPARATOR}${shown}` : \"\", right };\n}\n\n/**\n * What the session is about instead of its raw id: `<repo> Β· <chat name>`.\n * The chat name is the first prompt, the same label `/sessions` lists it by\n * (sessions have no separate title). Either part shows alone when the other is\n * missing; `new session` before any prompt outside a repo.\n */\nexport function sessionName(state: Pick<TuiState, \"gitRepo\" | \"blocks\">): string {\n // A crew worker's brief is not the user's prompt.\n const first = state.blocks.find((block) => block.type === \"user\" && !block.worker);\n const chat = first?.type === \"user\" ? normalize(first.text).replace(/\\s+/g, \" \").trim() : \"\";\n return [state.gitRepo, chat].filter(Boolean).join(SEPARATOR) || \"new session\";\n}\n\n/** Context usage and cost, or nothing before the first usage report (no `?/?` placeholder). */\nexport function usageStatus(usage: TuiUsageSummary): string {\n // Token counts, not cost alone: formatContextStatus would print `?/?` placeholders without them.\n const known = [usage.lastInputTokens, usage.totalTokens, usage.inputTokens].some((value) => typeof value === \"number\");\n const budget = typeof usage.tokenBudget === \"number\" && usage.tokenBudget > 0;\n return known || budget ? formatContextStatus(usage) : \"\";\n}\n\n/** The context gauge glyph (`β—‹ β—” β—‘ β—• ●`) at the start of the usage text, if any, so it can be colored. */\nexport function splitGauge(right: string): { gauge: string; rest: string } {\n const first = [...right][0];\n return first && GAUGE_GLYPHS.has(first) ? { gauge: first, rest: right.slice(first.length) } : { gauge: \"\", rest: right };\n}\n\nconst GAUGE_GLYPHS: ReadonlySet<string> = new Set([\"β—‹\", \"β—”\", \"β—‘\", \"β—•\", \"●\"]);\n\n/** Cut `text` to at most `room` terminal cells, ending in `…` when cut. Wide characters (emoji, CJK) count as two. */\nfunction clip(text: string, room: number): string {\n if (room <= 0) return \"\";\n if (cells(text) <= room) return text;\n const budget = room - cells(ELLIPSIS);\n let out = \"\";\n let used = 0;\n for (const { segment } of GRAPHEMES.segment(text)) {\n const width = cells(segment);\n if (used + width > budget) break;\n out += segment;\n used += width;\n }\n return `${out}${ELLIPSIS}`;\n}\n\nconst GRAPHEMES = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/** Terminal cells, so chat names with emoji or CJK never overflow the row. */\nfunction cells(text: string): number {\n return stringWidth(text);\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The Tree-sitter filetype for a file path, or undefined when no bundled or
3
+ * OpenTUI parser covers it. Undefined means plain text: unknown languages
4
+ * never reach the worker.
5
+ */
6
+ export declare function codeFiletype(path: string | undefined, supported?: ReadonlySet<string>): string | undefined;
7
+ /**
8
+ * The filetype for a read tool's output. Output whose lines carry line-number
9
+ * prefixes is not source code to a parser, so it stays plain.
10
+ */
11
+ export declare function readOutputFiletype(path: string | undefined, output: string, supported?: ReadonlySet<string>): string | undefined;
12
+ //# sourceMappingURL=filetype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filetype.d.ts","sourceRoot":"","sources":["../../src/syntax/filetype.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,GAAE,WAAW,CAAC,MAAM,CAA0B,GAAG,MAAM,GAAG,SAAS,CAIlI;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAKhI"}
@@ -0,0 +1,28 @@
1
+ import { pathToFiletype } from "@opentui/core";
2
+ import { highlightedFiletypes } from "./grammars.js";
3
+ /**
4
+ * The Tree-sitter filetype for a file path, or undefined when no bundled or
5
+ * OpenTUI parser covers it. Undefined means plain text: unknown languages
6
+ * never reach the worker.
7
+ */
8
+ export function codeFiletype(path, supported = highlightedFiletypes()) {
9
+ if (!path)
10
+ return undefined;
11
+ const filetype = pathToFiletype(path);
12
+ return filetype && supported.has(filetype) ? filetype : undefined;
13
+ }
14
+ /** ` 1β†’code` (Claude Code's Read) or `1\tcode` (`cat -n`). */
15
+ const NUMBERED_LINE = /^\s*\d+(?:β†’|\t)/;
16
+ const SAMPLE_LINES = 5;
17
+ /**
18
+ * The filetype for a read tool's output. Output whose lines carry line-number
19
+ * prefixes is not source code to a parser, so it stays plain.
20
+ */
21
+ export function readOutputFiletype(path, output, supported) {
22
+ const filetype = codeFiletype(path, supported);
23
+ if (!filetype)
24
+ return undefined;
25
+ const sample = output.split("\n").filter((line) => line.trim() !== "").slice(0, SAMPLE_LINES);
26
+ return sample.length > 0 && sample.every((line) => NUMBERED_LINE.test(line)) ? undefined : filetype;
27
+ }
28
+ //# sourceMappingURL=filetype.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filetype.js","sourceRoot":"","sources":["../../src/syntax/filetype.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAwB,EAAE,YAAiC,oBAAoB,EAAE;IAC5G,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;AAED,kEAAkE;AAClE,MAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAwB,EAAE,MAAc,EAAE,SAA+B;IAC1G,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AACtG,CAAC","sourcesContent":["import { pathToFiletype } from \"@opentui/core\";\nimport { highlightedFiletypes } from \"./grammars.js\";\n\n/**\n * The Tree-sitter filetype for a file path, or undefined when no bundled or\n * OpenTUI parser covers it. Undefined means plain text: unknown languages\n * never reach the worker.\n */\nexport function codeFiletype(path: string | undefined, supported: ReadonlySet<string> = highlightedFiletypes()): string | undefined {\n if (!path) return undefined;\n const filetype = pathToFiletype(path);\n return filetype && supported.has(filetype) ? filetype : undefined;\n}\n\n/** ` 1β†’code` (Claude Code's Read) or `1\\tcode` (`cat -n`). */\nconst NUMBERED_LINE = /^\\s*\\d+(?:β†’|\\t)/;\nconst SAMPLE_LINES = 5;\n\n/**\n * The filetype for a read tool's output. Output whose lines carry line-number\n * prefixes is not source code to a parser, so it stays plain.\n */\nexport function readOutputFiletype(path: string | undefined, output: string, supported?: ReadonlySet<string>): string | undefined {\n const filetype = codeFiletype(path, supported);\n if (!filetype) return undefined;\n const sample = output.split(\"\\n\").filter((line) => line.trim() !== \"\").slice(0, SAMPLE_LINES);\n return sample.length > 0 && sample.every((line) => NUMBERED_LINE.test(line)) ? undefined : filetype;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import { type FiletypeParserOptions } from "@opentui/core";
2
+ /**
3
+ * Tree-sitter grammars bundled with this package (owner decision 2026-11-18:
4
+ * no runtime downloads). Each comes from the grammar's own npm package at an
5
+ * exact version: its `.wasm`, its `queries/highlights.scm` (written for that
6
+ * same grammar version), and its LICENSE, under `grammars/<filetype>/`.
7
+ * `scripts/update-grammars.mjs` reproduces the files from this list and
8
+ * `src/tests/grammars.test.ts` checks the hashes. Record changes in
9
+ * THIRD_PARTY_NOTICES.md.
10
+ */
11
+ export type BundledGrammar = {
12
+ /** OpenTUI filetype, as `pathToFiletype` / `infoStringToFiletype` name it. */
13
+ filetype: string;
14
+ /** npm package and exact version the files come from. */
15
+ source: {
16
+ package: string;
17
+ version: string;
18
+ };
19
+ wasm: string;
20
+ sha256: {
21
+ wasm: string;
22
+ highlights: string;
23
+ };
24
+ };
25
+ export declare const BUNDLED_GRAMMARS: readonly BundledGrammar[];
26
+ /** `grammars/` next to `src/` and `dist/`: both compile one level under the package root. */
27
+ export declare const GRAMMARS_DIR: string;
28
+ /**
29
+ * Parser options for the bundled grammars that are present, with absolute
30
+ * local paths (OpenTUI resolves relative paths against the process cwd and
31
+ * would fetch a URL with no integrity check). A missing grammar is skipped,
32
+ * so its filetype renders as plain text.
33
+ */
34
+ export declare function bundledParsers(dir?: string): FiletypeParserOptions[];
35
+ /**
36
+ * Adds the bundled grammars to OpenTUI's default parsers. Call once before the
37
+ * first highlight: the Tree-sitter client reads the list when its worker starts.
38
+ */
39
+ export declare function registerBundledGrammars(dir?: string): void;
40
+ /** Filetypes that highlight: OpenTUI's own plus the registered bundled grammars. */
41
+ export declare function highlightedFiletypes(): ReadonlySet<string>;
42
+ //# sourceMappingURL=grammars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammars.d.ts","sourceRoot":"","sources":["../../src/syntax/grammars.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EASrD,CAAC;AAKF,6FAA6F;AAC7F,eAAO,MAAM,YAAY,QAA6D,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAqB,GAAG,qBAAqB,EAAE,CAOlF;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,MAAqB,GAAG,IAAI,CAIxE;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,IAAI,WAAW,CAAC,MAAM,CAAC,CAE1D"}
@@ -0,0 +1,52 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { addDefaultParsers } from "@opentui/core";
5
+ export const BUNDLED_GRAMMARS = [
6
+ grammar("python", "tree-sitter-python", "0.25.0", "16108b50df4ee9a30168794252ab55e7c93bfc5765d7fa0aa3e335752c515f47", "a6708f209381618e2b398972c8f1ccd892f0c064eab35a2a3f911c3e22e79a7e"),
7
+ grammar("bash", "tree-sitter-bash", "0.25.1", "8292919c88a0f7d3fb31d0cd0253ca5a9531bc1ede82b0537f2c63dd8abe6a7a", "b74220d954f485b7626d2b2b61f37b522e12eb1830803e388e57dd797dc99f11"),
8
+ grammar("json", "tree-sitter-json", "0.24.8", "d2119fb98d5912719b13f9458574f8608d2d29dfbe45f6be1f860ea1fe2a2405", "0511524465b56aed122580792254e68b6abbbfde7119f1d02b135acbe278233f"),
9
+ grammar("rust", "tree-sitter-rust", "0.24.0", "f65f354215611fd94ad34134b3427eb3d58cbb745df7b6509ba722184db73d57", "0f0343107f14a7690157f51090a979eb8f8bfe4eada7c61763ddb4c54b1311d1"),
10
+ grammar("go", "tree-sitter-go", "0.25.0", "9504573f352b20be7f2f1911754d710622aedc15afff16d5ed8fb5645681aee7", "81182c986547eba7fa6316e82dfd621fb13b8fc89efac85432aee51a48ed0896"),
11
+ grammar("yaml", "@tree-sitter-grammars/tree-sitter-yaml", "0.7.1", "e752dc21c3591df9b45692fe417d101f45d1828c28c44d79005f4066dc7e4e91", "2fbfbbd5ca0928d0a7e09e59f8f2964b14a328a7ee0ce799270d9013dcce49a0"),
12
+ grammar("css", "tree-sitter-css", "0.25.0", "8a23977fe271357cce6f254ef88c9bebf3854602d8046605aef6a45c02135c59", "23f7948a3817a0d06d7120158c3bee4ec5b58daa77e524985a4738b364db17b2"),
13
+ grammar("html", "tree-sitter-html", "0.23.2", "c48fcd82c7ea8bf943180088ba7f28c48b2bb5287874179168bf9d31e394cf85", "1ebb3811a8cdc054385b847a3aac6fbf7079faefd5b3dfab5bbad256cd5afdcf")
14
+ ];
15
+ /** Filetypes OpenTUI 0.9.2 ships parsers for (`lib/tree-sitter/default-parsers`). */
16
+ const OPENTUI_FILETYPES = ["javascript", "javascriptreact", "typescript", "typescriptreact", "markdown", "zig"];
17
+ /** `grammars/` next to `src/` and `dist/`: both compile one level under the package root. */
18
+ export const GRAMMARS_DIR = fileURLToPath(new URL("../../grammars/", import.meta.url));
19
+ /**
20
+ * Parser options for the bundled grammars that are present, with absolute
21
+ * local paths (OpenTUI resolves relative paths against the process cwd and
22
+ * would fetch a URL with no integrity check). A missing grammar is skipped,
23
+ * so its filetype renders as plain text.
24
+ */
25
+ export function bundledParsers(dir = GRAMMARS_DIR) {
26
+ return BUNDLED_GRAMMARS.flatMap((entry) => {
27
+ const wasm = join(dir, entry.filetype, entry.wasm);
28
+ const highlights = join(dir, entry.filetype, "highlights.scm");
29
+ if (!existsSync(wasm) || !existsSync(highlights))
30
+ return [];
31
+ return [{ filetype: entry.filetype, wasm, queries: { highlights: [highlights] } }];
32
+ });
33
+ }
34
+ let registered;
35
+ /**
36
+ * Adds the bundled grammars to OpenTUI's default parsers. Call once before the
37
+ * first highlight: the Tree-sitter client reads the list when its worker starts.
38
+ */
39
+ export function registerBundledGrammars(dir = GRAMMARS_DIR) {
40
+ const parsers = bundledParsers(dir);
41
+ addDefaultParsers(parsers);
42
+ registered = new Set(parsers.map((parser) => parser.filetype));
43
+ }
44
+ /** Filetypes that highlight: OpenTUI's own plus the registered bundled grammars. */
45
+ export function highlightedFiletypes() {
46
+ return new Set([...OPENTUI_FILETYPES, ...(registered ?? [])]);
47
+ }
48
+ function grammar(filetype, pkg, version, wasmSha, highlightsSha) {
49
+ const name = pkg.split("/").pop() ?? pkg;
50
+ return { filetype, source: { package: pkg, version }, wasm: `${name}.wasm`, sha256: { wasm: wasmSha, highlights: highlightsSha } };
51
+ }
52
+ //# sourceMappingURL=grammars.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammars.js","sourceRoot":"","sources":["../../src/syntax/grammars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAA8B,MAAM,eAAe,CAAC;AAoB9E,MAAM,C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AE,CAAC;AACrI,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { addDefaultParsers, type FiletypeParserOptions } from \"@opentui/core\";\n\n/**\n * Tree-sitter grammars bundled with this package (owner decision 2026-11-18:\n * no runtime downloads). Each comes from the grammar's own npm package at an\n * exact version: its `.wasm`, its `queries/highlights.scm` (written for that\n * same grammar version), and its LICENSE, under `grammars/<filetype>/`.\n * `scripts/update-grammars.mjs` reproduces the files from this list and\n * `src/tests/grammars.test.ts` checks the hashes. Record changes in\n * THIRD_PARTY_NOTICES.md.\n */\nexport type BundledGrammar = {\n /** OpenTUI filetype, as `pathToFiletype` / `infoStringToFiletype` name it. */\n filetype: string;\n /** npm package and exact version the files come from. */\n source: { package: string; version: string };\n wasm: string;\n sha256: { wasm: string; highlights: string };\n};\n\nexport const BUNDLED_GRAMMARS: readonly BundledGrammar[] = [\n grammar(\"python\", \"tree-sitter-python\", \"0.25.0\", \"16108b50df4ee9a30168794252ab55e7c93bfc5765d7fa0aa3e335752c515f47\", \"a6708f209381618e2b398972c8f1ccd892f0c064eab35a2a3f911c3e22e79a7e\"),\n grammar(\"bash\", \"tree-sitter-bash\", \"0.25.1\", \"8292919c88a0f7d3fb31d0cd0253ca5a9531bc1ede82b0537f2c63dd8abe6a7a\", \"b74220d954f485b7626d2b2b61f37b522e12eb1830803e388e57dd797dc99f11\"),\n grammar(\"json\", \"tree-sitter-json\", \"0.24.8\", \"d2119fb98d5912719b13f9458574f8608d2d29dfbe45f6be1f860ea1fe2a2405\", \"0511524465b56aed122580792254e68b6abbbfde7119f1d02b135acbe278233f\"),\n grammar(\"rust\", \"tree-sitter-rust\", \"0.24.0\", \"f65f354215611fd94ad34134b3427eb3d58cbb745df7b6509ba722184db73d57\", \"0f0343107f14a7690157f51090a979eb8f8bfe4eada7c61763ddb4c54b1311d1\"),\n grammar(\"go\", \"tree-sitter-go\", \"0.25.0\", \"9504573f352b20be7f2f1911754d710622aedc15afff16d5ed8fb5645681aee7\", \"81182c986547eba7fa6316e82dfd621fb13b8fc89efac85432aee51a48ed0896\"),\n grammar(\"yaml\", \"@tree-sitter-grammars/tree-sitter-yaml\", \"0.7.1\", \"e752dc21c3591df9b45692fe417d101f45d1828c28c44d79005f4066dc7e4e91\", \"2fbfbbd5ca0928d0a7e09e59f8f2964b14a328a7ee0ce799270d9013dcce49a0\"),\n grammar(\"css\", \"tree-sitter-css\", \"0.25.0\", \"8a23977fe271357cce6f254ef88c9bebf3854602d8046605aef6a45c02135c59\", \"23f7948a3817a0d06d7120158c3bee4ec5b58daa77e524985a4738b364db17b2\"),\n grammar(\"html\", \"tree-sitter-html\", \"0.23.2\", \"c48fcd82c7ea8bf943180088ba7f28c48b2bb5287874179168bf9d31e394cf85\", \"1ebb3811a8cdc054385b847a3aac6fbf7079faefd5b3dfab5bbad256cd5afdcf\")\n];\n\n/** Filetypes OpenTUI 0.9.2 ships parsers for (`lib/tree-sitter/default-parsers`). */\nconst OPENTUI_FILETYPES = [\"javascript\", \"javascriptreact\", \"typescript\", \"typescriptreact\", \"markdown\", \"zig\"] as const;\n\n/** `grammars/` next to `src/` and `dist/`: both compile one level under the package root. */\nexport const GRAMMARS_DIR = fileURLToPath(new URL(\"../../grammars/\", import.meta.url));\n\n/**\n * Parser options for the bundled grammars that are present, with absolute\n * local paths (OpenTUI resolves relative paths against the process cwd and\n * would fetch a URL with no integrity check). A missing grammar is skipped,\n * so its filetype renders as plain text.\n */\nexport function bundledParsers(dir: string = GRAMMARS_DIR): FiletypeParserOptions[] {\n return BUNDLED_GRAMMARS.flatMap((entry) => {\n const wasm = join(dir, entry.filetype, entry.wasm);\n const highlights = join(dir, entry.filetype, \"highlights.scm\");\n if (!existsSync(wasm) || !existsSync(highlights)) return [];\n return [{ filetype: entry.filetype, wasm, queries: { highlights: [highlights] } }];\n });\n}\n\nlet registered: ReadonlySet<string> | undefined;\n\n/**\n * Adds the bundled grammars to OpenTUI's default parsers. Call once before the\n * first highlight: the Tree-sitter client reads the list when its worker starts.\n */\nexport function registerBundledGrammars(dir: string = GRAMMARS_DIR): void {\n const parsers = bundledParsers(dir);\n addDefaultParsers(parsers);\n registered = new Set(parsers.map((parser) => parser.filetype));\n}\n\n/** Filetypes that highlight: OpenTUI's own plus the registered bundled grammars. */\nexport function highlightedFiletypes(): ReadonlySet<string> {\n return new Set<string>([...OPENTUI_FILETYPES, ...(registered ?? [])]);\n}\n\nfunction grammar(filetype: string, pkg: string, version: string, wasmSha: string, highlightsSha: string): BundledGrammar {\n const name = pkg.split(\"/\").pop() ?? pkg;\n return { filetype, source: { package: pkg, version }, wasm: `${name}.wasm`, sha256: { wasm: wasmSha, highlights: highlightsSha } };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /** The JS index of the grapheme boundary at `offset` cells (clamped to the text). */
2
+ export declare function offsetToIndex(text: string, offset: number): number;
3
+ /** The cell offset of JS index `index` (rounded down to a grapheme boundary). */
4
+ export declare function indexToOffset(text: string, index: number): number;
5
+ //# sourceMappingURL=text-offset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-offset.d.ts","sourceRoot":"","sources":["../src/text-offset.ts"],"names":[],"mappings":"AAmBA,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOlE;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAOjE"}
@@ -0,0 +1,38 @@
1
+ import stringWidth from "string-width";
2
+ /**
3
+ * OpenTUI 0.9.2's `<textarea>` `cursorOffset` counts display cells, not
4
+ * UTF-16 units: `πŸ˜€` and `δΈ­` are 2, a combining accent 0, a newline 1, and a
5
+ * tab a fixed 2 (measured against the native edit buffer). These convert
6
+ * between that offset and a JS string index into `plainText`, so string
7
+ * slicing (the `@` token) lines up with the cursor.
8
+ */
9
+ const TAB_CELLS = 2;
10
+ const segmenter = new Intl.Segmenter();
11
+ function cells(grapheme) {
12
+ if (grapheme === "\n")
13
+ return 1;
14
+ if (grapheme === "\t")
15
+ return TAB_CELLS;
16
+ return stringWidth(grapheme);
17
+ }
18
+ /** The JS index of the grapheme boundary at `offset` cells (clamped to the text). */
19
+ export function offsetToIndex(text, offset) {
20
+ let seen = 0;
21
+ for (const { segment, index } of segmenter.segment(text)) {
22
+ if (seen >= offset)
23
+ return index;
24
+ seen += cells(segment);
25
+ }
26
+ return text.length;
27
+ }
28
+ /** The cell offset of JS index `index` (rounded down to a grapheme boundary). */
29
+ export function indexToOffset(text, index) {
30
+ let seen = 0;
31
+ for (const { segment, index: at } of segmenter.segment(text)) {
32
+ if (at + segment.length > index)
33
+ break;
34
+ seen += cells(segment);
35
+ }
36
+ return seen;
37
+ }
38
+ //# sourceMappingURL=text-offset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-offset.js","sourceRoot":"","sources":["../src/text-offset.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;AAEvC,SAAS,KAAK,CAAC,QAAgB;IAC7B,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAChC,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACxC,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,MAAc;IACxD,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzD,IAAI,IAAI,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QACjC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,KAAa;IACvD,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK;YAAE,MAAM;QACvC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import stringWidth from \"string-width\";\n\n/**\n * OpenTUI 0.9.2's `<textarea>` `cursorOffset` counts display cells, not\n * UTF-16 units: `πŸ˜€` and `δΈ­` are 2, a combining accent 0, a newline 1, and a\n * tab a fixed 2 (measured against the native edit buffer). These convert\n * between that offset and a JS string index into `plainText`, so string\n * slicing (the `@` token) lines up with the cursor.\n */\nconst TAB_CELLS = 2;\n\nconst segmenter = new Intl.Segmenter();\n\nfunction cells(grapheme: string): number {\n if (grapheme === \"\\n\") return 1;\n if (grapheme === \"\\t\") return TAB_CELLS;\n return stringWidth(grapheme);\n}\n\n/** The JS index of the grapheme boundary at `offset` cells (clamped to the text). */\nexport function offsetToIndex(text: string, offset: number): number {\n let seen = 0;\n for (const { segment, index } of segmenter.segment(text)) {\n if (seen >= offset) return index;\n seen += cells(segment);\n }\n return text.length;\n}\n\n/** The cell offset of JS index `index` (rounded down to a grapheme boundary). */\nexport function indexToOffset(text: string, index: number): number {\n let seen = 0;\n for (const { segment, index: at } of segmenter.segment(text)) {\n if (at + segment.length > index) break;\n seen += cells(segment);\n }\n return seen;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Word-wrap to `width` terminal cells (wide characters count twice); words
3
+ * longer than a row, such as paths, break between graphemes.
4
+ */
5
+ export declare function wrapCells(value: string, width: number): string[];
6
+ /**
7
+ * `wrapCells` for text that keeps its layout: each line's leading indent stays,
8
+ * and a list item's continuation rows hang under its text, not its marker.
9
+ * Blank lines stay. Each row is at most `width` cells.
10
+ */
11
+ export declare function wrapIndented(value: string, width: number): string[];
12
+ //# sourceMappingURL=text-wrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-wrap.d.ts","sourceRoot":"","sources":["../src/text-wrap.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBhE;AAKD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAWnE"}
@@ -0,0 +1,53 @@
1
+ import stringWidth from "string-width";
2
+ /** Word wrapping in terminal cells, shared by the sidebar and footer alerts. Pure. */
3
+ const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
4
+ /**
5
+ * Word-wrap to `width` terminal cells (wide characters count twice); words
6
+ * longer than a row, such as paths, break between graphemes.
7
+ */
8
+ export function wrapCells(value, width) {
9
+ const columns = Math.max(1, Math.floor(width));
10
+ const lines = [];
11
+ for (const logical of value.split("\n")) {
12
+ let line = "";
13
+ for (const word of logical.split(/\s+/).filter(Boolean)) {
14
+ if (line && stringWidth(line) + 1 + stringWidth(word) <= columns) {
15
+ line = `${line} ${word}`;
16
+ continue;
17
+ }
18
+ if (line)
19
+ lines.push(line);
20
+ line = "";
21
+ for (const { segment } of graphemes.segment(word)) {
22
+ if (line && stringWidth(line) + stringWidth(segment) > columns) {
23
+ lines.push(line);
24
+ line = "";
25
+ }
26
+ line += segment;
27
+ }
28
+ }
29
+ lines.push(line);
30
+ }
31
+ return lines;
32
+ }
33
+ /** Leading indent plus a list marker (`β€’ `, `- `, `* `, `1. `), if any. */
34
+ const HANGING_PREFIX = /^(\s*)((?:[β€’\-*]|\d+[.)])\s+)?/;
35
+ /**
36
+ * `wrapCells` for text that keeps its layout: each line's leading indent stays,
37
+ * and a list item's continuation rows hang under its text, not its marker.
38
+ * Blank lines stay. Each row is at most `width` cells.
39
+ */
40
+ export function wrapIndented(value, width) {
41
+ const columns = Math.max(1, Math.floor(width));
42
+ return value.split("\n").flatMap((line) => {
43
+ const prefix = HANGING_PREFIX.exec(line)?.[0] ?? "";
44
+ const hang = stringWidth(prefix);
45
+ // An indent that leaves no room to wrap into is dropped rather than overflowing.
46
+ if (hang >= columns)
47
+ return wrapCells(line.trim(), columns);
48
+ const rows = wrapCells(line.slice(prefix.length), columns - hang);
49
+ const pad = " ".repeat(hang);
50
+ return rows.map((row, index) => `${index === 0 ? prefix : pad}${row}`);
51
+ });
52
+ }
53
+ //# sourceMappingURL=text-wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-wrap.js","sourceRoot":"","sources":["../src/text-wrap.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,sFAAsF;AAEtF,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,KAAa;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,C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FAAiF;QACjF,IAAI,IAAI,IAAI,OAAO;YAAE,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;QAClE,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import stringWidth from \"string-width\";\n\n/** Word wrapping in terminal cells, shared by the sidebar and footer alerts. Pure. */\n\nconst graphemes = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/**\n * Word-wrap to `width` terminal cells (wide characters count twice); words\n * longer than a row, such as paths, break between graphemes.\n */\nexport function wrapCells(value: string, width: number): string[] {\n const columns = Math.max(1, Math.floor(width));\n const lines: string[] = [];\n for (const logical of value.split(\"\\n\")) {\n let line = \"\";\n for (const word of logical.split(/\\s+/).filter(Boolean)) {\n if (line && stringWidth(line) + 1 + stringWidth(word) <= columns) {\n line = `${line} ${word}`;\n continue;\n }\n if (line) lines.push(line);\n line = \"\";\n for (const { segment } of graphemes.segment(word)) {\n if (line && stringWidth(line) + stringWidth(segment) > columns) {\n lines.push(line);\n line = \"\";\n }\n line += segment;\n }\n }\n lines.push(line);\n }\n return lines;\n}\n\n/** Leading indent plus a list marker (`β€’ `, `- `, `* `, `1. `), if any. */\nconst HANGING_PREFIX = /^(\\s*)((?:[β€’\\-*]|\\d+[.)])\\s+)?/;\n\n/**\n * `wrapCells` for text that keeps its layout: each line's leading indent stays,\n * and a list item's continuation rows hang under its text, not its marker.\n * Blank lines stay. Each row is at most `width` cells.\n */\nexport function wrapIndented(value: string, width: number): string[] {\n const columns = Math.max(1, Math.floor(width));\n return value.split(\"\\n\").flatMap((line) => {\n const prefix = HANGING_PREFIX.exec(line)?.[0] ?? \"\";\n const hang = stringWidth(prefix);\n // An indent that leaves no room to wrap into is dropped rather than overflowing.\n if (hang >= columns) return wrapCells(line.trim(), columns);\n const rows = wrapCells(line.slice(prefix.length), columns - hang);\n const pad = \" \".repeat(hang);\n return rows.map((row, index) => `${index === 0 ? prefix : pad}${row}`);\n });\n}\n"]}