@aragon-agent/tui 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +21 -0
  3. package/README.md +81 -2
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.js +11 -0
  6. package/dist/input/control-sequences.d.ts +71 -0
  7. package/dist/input/control-sequences.js +222 -0
  8. package/dist/input/csiu-keys.d.ts +66 -0
  9. package/dist/input/csiu-keys.js +181 -0
  10. package/dist/input/cursor-report.d.ts +61 -0
  11. package/dist/input/cursor-report.js +97 -0
  12. package/dist/input/enter-sequences.d.ts +64 -0
  13. package/dist/input/enter-sequences.js +153 -0
  14. package/dist/input/interrupt-gesture.d.ts +18 -0
  15. package/dist/input/interrupt-gesture.js +19 -0
  16. package/dist/input/keyboard-enhancement.d.ts +42 -0
  17. package/dist/input/keyboard-enhancement.js +65 -0
  18. package/dist/input/keymap.d.ts +20 -0
  19. package/dist/input/keymap.js +99 -0
  20. package/dist/input/limits.d.ts +118 -0
  21. package/dist/input/limits.js +109 -0
  22. package/dist/input/mouse-events.d.ts +87 -0
  23. package/dist/input/mouse-events.js +212 -0
  24. package/dist/input/paste-parse.d.ts +83 -0
  25. package/dist/input/paste-parse.js +107 -0
  26. package/dist/input/pointer-router.d.ts +11 -0
  27. package/dist/input/pointer-router.js +14 -0
  28. package/dist/input/stdin-filter.d.ts +112 -0
  29. package/dist/input/stdin-filter.js +657 -0
  30. package/dist/input/win32-input-mode.d.ts +61 -0
  31. package/dist/input/win32-input-mode.js +269 -0
  32. package/dist/model/agent/agent-mode.d.ts +108 -0
  33. package/dist/model/agent/agent-mode.js +121 -0
  34. package/dist/model/agent/entry-limits.d.ts +65 -0
  35. package/dist/model/agent/entry-limits.js +133 -0
  36. package/dist/model/agent/governance-view.d.ts +40 -0
  37. package/dist/model/agent/governance-view.js +40 -0
  38. package/dist/model/agent/invocation-card.d.ts +77 -0
  39. package/dist/model/agent/invocation-card.js +169 -0
  40. package/dist/model/agent/model-probe-limits.d.ts +39 -0
  41. package/dist/model/agent/model-probe-limits.js +25 -0
  42. package/dist/model/agent/model-probe.d.ts +104 -0
  43. package/dist/model/agent/model-probe.js +391 -0
  44. package/dist/model/agent/queued-messages.d.ts +23 -0
  45. package/dist/model/agent/queued-messages.js +49 -0
  46. package/dist/model/agent/reducer.d.ts +857 -0
  47. package/dist/model/agent/reducer.js +1646 -0
  48. package/dist/model/agent/retry-view.d.ts +68 -0
  49. package/dist/model/agent/retry-view.js +95 -0
  50. package/dist/model/agent/usage.d.ts +47 -0
  51. package/dist/model/agent/usage.js +84 -0
  52. package/dist/model/compaction/limits.d.ts +61 -0
  53. package/dist/model/compaction/limits.js +64 -0
  54. package/dist/model/compaction/meter.d.ts +276 -0
  55. package/dist/model/compaction/meter.js +512 -0
  56. package/dist/model/compaction/pressure.d.ts +163 -0
  57. package/dist/model/compaction/pressure.js +199 -0
  58. package/dist/model/compaction/reason-text.d.ts +36 -0
  59. package/dist/model/compaction/reason-text.js +78 -0
  60. package/dist/model/compaction/types.d.ts +360 -0
  61. package/dist/model/compaction/types.js +22 -0
  62. package/dist/model/config/governance-config.d.ts +125 -0
  63. package/dist/model/config/governance-config.js +164 -0
  64. package/dist/model/config/kit-resolution.d.ts +93 -0
  65. package/dist/model/config/kit-resolution.js +226 -0
  66. package/dist/model/config/model-kits.d.ts +225 -0
  67. package/dist/model/config/model-kits.js +302 -0
  68. package/dist/model/config/model-profile-resolution.d.ts +28 -0
  69. package/dist/model/config/model-profile-resolution.js +88 -0
  70. package/dist/model/config/model-profiles.d.ts +103 -0
  71. package/dist/model/config/model-profiles.js +188 -0
  72. package/dist/model/config/model-settings-types.d.ts +71 -0
  73. package/dist/model/config/model-settings-types.js +18 -0
  74. package/dist/model/config/schema.d.ts +1645 -0
  75. package/dist/model/config/schema.js +1383 -0
  76. package/dist/model/fast/limits.d.ts +152 -0
  77. package/dist/model/fast/limits.js +152 -0
  78. package/dist/model/fast/resolve.d.ts +44 -0
  79. package/dist/model/fast/resolve.js +107 -0
  80. package/dist/model/fast/task-summary-types.d.ts +66 -0
  81. package/dist/model/fast/task-summary-types.js +17 -0
  82. package/dist/model/fast/types.d.ts +141 -0
  83. package/dist/model/fast/types.js +14 -0
  84. package/dist/model/governance/governed-dispatch.d.ts +19 -0
  85. package/dist/model/governance/governed-dispatch.js +17 -0
  86. package/dist/model/governance/limits.d.ts +107 -0
  87. package/dist/model/governance/limits.js +131 -0
  88. package/dist/model/governance/posture.d.ts +35 -0
  89. package/dist/model/governance/posture.js +59 -0
  90. package/dist/model/governance/rules/events-table.d.ts +46 -0
  91. package/dist/model/governance/rules/events-table.js +94 -0
  92. package/dist/model/governance/types.d.ts +661 -0
  93. package/dist/model/governance/types.js +27 -0
  94. package/dist/model/logging/levels.d.ts +40 -0
  95. package/dist/model/logging/levels.js +59 -0
  96. package/dist/model/logging/log-port.d.ts +38 -0
  97. package/dist/model/logging/log-port.js +41 -0
  98. package/dist/model/logging/secret-registry.d.ts +32 -0
  99. package/dist/model/logging/secret-registry.js +73 -0
  100. package/dist/model/proc/limits.d.ts +214 -0
  101. package/dist/model/proc/limits.js +221 -0
  102. package/dist/model/proc/progress.d.ts +47 -0
  103. package/dist/model/proc/progress.js +163 -0
  104. package/dist/model/proc/types.d.ts +269 -0
  105. package/dist/model/proc/types.js +15 -0
  106. package/dist/model/proc/wait-view.d.ts +65 -0
  107. package/dist/model/proc/wait-view.js +66 -0
  108. package/dist/model/prompts/copy.d.ts +89 -0
  109. package/dist/model/prompts/copy.js +131 -0
  110. package/dist/model/prompts/fill.d.ts +51 -0
  111. package/dist/model/prompts/fill.js +46 -0
  112. package/dist/model/prompts/limits.d.ts +53 -0
  113. package/dist/model/prompts/limits.js +53 -0
  114. package/dist/model/prompts/search.d.ts +58 -0
  115. package/dist/model/prompts/search.js +146 -0
  116. package/dist/model/prompts/types.d.ts +204 -0
  117. package/dist/model/prompts/types.js +13 -0
  118. package/dist/model/prompts/validate.d.ts +22 -0
  119. package/dist/model/prompts/validate.js +69 -0
  120. package/dist/model/team/activity.d.ts +67 -0
  121. package/dist/model/team/activity.js +130 -0
  122. package/dist/model/team/limits.d.ts +308 -0
  123. package/dist/model/team/limits.js +330 -0
  124. package/dist/model/team/model.d.ts +104 -0
  125. package/dist/model/team/model.js +150 -0
  126. package/dist/model/team/panel-rows.d.ts +48 -0
  127. package/dist/model/team/panel-rows.js +75 -0
  128. package/dist/model/team/timeline.d.ts +74 -0
  129. package/dist/model/team/timeline.js +101 -0
  130. package/dist/model/team/types.d.ts +354 -0
  131. package/dist/model/team/types.js +13 -0
  132. package/dist/model/todo/acceptance.d.ts +120 -0
  133. package/dist/model/todo/acceptance.js +399 -0
  134. package/dist/model/todo/follow-through.d.ts +138 -0
  135. package/dist/model/todo/follow-through.js +248 -0
  136. package/dist/model/todo/limits.d.ts +152 -0
  137. package/dist/model/todo/limits.js +152 -0
  138. package/dist/model/todo/panel-rows.d.ts +45 -0
  139. package/dist/model/todo/panel-rows.js +70 -0
  140. package/dist/model/todo/plan-sections.d.ts +60 -0
  141. package/dist/model/todo/plan-sections.js +108 -0
  142. package/dist/model/todo/row-window.d.ts +51 -0
  143. package/dist/model/todo/row-window.js +107 -0
  144. package/dist/model/todo/types.d.ts +124 -0
  145. package/dist/model/todo/types.js +12 -0
  146. package/dist/model/tools/human-input.d.ts +212 -0
  147. package/dist/model/tools/human-input.js +265 -0
  148. package/dist/model/tools/patch.d.ts +115 -0
  149. package/dist/model/tools/patch.js +453 -0
  150. package/dist/model/tools/terminal-output.d.ts +115 -0
  151. package/dist/model/tools/terminal-output.js +201 -0
  152. package/dist/model/tools/tool-output-store.d.ts +68 -0
  153. package/dist/model/tools/tool-output-store.js +102 -0
  154. package/dist/model/update/limits.d.ts +111 -0
  155. package/dist/model/update/limits.js +111 -0
  156. package/dist/model/update/semver.d.ts +89 -0
  157. package/dist/model/update/semver.js +295 -0
  158. package/dist/model/update/types.d.ts +169 -0
  159. package/dist/model/update/types.js +68 -0
  160. package/dist/testing/governance-fixtures.d.ts +13 -0
  161. package/dist/testing/governance-fixtures.js +98 -0
  162. package/dist/testing/mini-vt.d.ts +28 -0
  163. package/dist/testing/mini-vt.js +158 -0
  164. package/dist/testing/render-at-width.d.ts +16 -0
  165. package/dist/testing/render-at-width.js +57 -0
  166. package/dist/testing/terminal-harness.d.ts +15 -0
  167. package/dist/testing/terminal-harness.js +40 -0
  168. package/dist/testing/vt-screen.d.ts +28 -0
  169. package/dist/testing/vt-screen.js +139 -0
  170. package/dist/ui/ActivityLine.d.ts +26 -0
  171. package/dist/ui/ActivityLine.js +51 -0
  172. package/dist/ui/AutocompletePopup.d.ts +23 -0
  173. package/dist/ui/AutocompletePopup.js +17 -0
  174. package/dist/ui/BottomStatusRow.d.ts +10 -0
  175. package/dist/ui/BottomStatusRow.js +9 -0
  176. package/dist/ui/Composer.d.ts +115 -0
  177. package/dist/ui/Composer.js +64 -0
  178. package/dist/ui/GovernancePanel.d.ts +50 -0
  179. package/dist/ui/GovernancePanel.js +77 -0
  180. package/dist/ui/GovernanceRun.d.ts +18 -0
  181. package/dist/ui/GovernanceRun.js +11 -0
  182. package/dist/ui/Header.d.ts +48 -0
  183. package/dist/ui/Header.js +27 -0
  184. package/dist/ui/Logo.d.ts +32 -0
  185. package/dist/ui/Logo.js +65 -0
  186. package/dist/ui/Markdown.d.ts +29 -0
  187. package/dist/ui/Markdown.js +116 -0
  188. package/dist/ui/PromptCaret.d.ts +11 -0
  189. package/dist/ui/PromptCaret.js +31 -0
  190. package/dist/ui/PromptInput.d.ts +192 -0
  191. package/dist/ui/PromptInput.js +689 -0
  192. package/dist/ui/QueuePanel.d.ts +8 -0
  193. package/dist/ui/QueuePanel.js +9 -0
  194. package/dist/ui/QueueStatusRow.d.ts +24 -0
  195. package/dist/ui/QueueStatusRow.js +51 -0
  196. package/dist/ui/ScrollbackShell.d.ts +132 -0
  197. package/dist/ui/ScrollbackShell.js +26 -0
  198. package/dist/ui/SessionOpener.d.ts +30 -0
  199. package/dist/ui/SessionOpener.js +12 -0
  200. package/dist/ui/StatusBar.d.ts +130 -0
  201. package/dist/ui/StatusBar.js +61 -0
  202. package/dist/ui/TeamPanel.d.ts +76 -0
  203. package/dist/ui/TeamPanel.js +103 -0
  204. package/dist/ui/ToastStack.d.ts +8 -0
  205. package/dist/ui/ToastStack.js +31 -0
  206. package/dist/ui/TodoPanel.d.ts +52 -0
  207. package/dist/ui/TodoPanel.js +214 -0
  208. package/dist/ui/Transcript.d.ts +105 -0
  209. package/dist/ui/Transcript.js +258 -0
  210. package/dist/ui/UpdateLine.d.ts +44 -0
  211. package/dist/ui/UpdateLine.js +129 -0
  212. package/dist/ui/activity-phrases.d.ts +33 -0
  213. package/dist/ui/activity-phrases.js +50 -0
  214. package/dist/ui/capabilities.d.ts +27 -0
  215. package/dist/ui/capabilities.js +65 -0
  216. package/dist/ui/clipboard-task.d.ts +29 -0
  217. package/dist/ui/clipboard-task.js +66 -0
  218. package/dist/ui/clipboard.d.ts +31 -0
  219. package/dist/ui/clipboard.js +157 -0
  220. package/dist/ui/color-runtime.d.ts +5 -0
  221. package/dist/ui/color-runtime.js +29 -0
  222. package/dist/ui/composer-input.d.ts +38 -0
  223. package/dist/ui/composer-input.js +79 -0
  224. package/dist/ui/composer-limits.d.ts +30 -0
  225. package/dist/ui/composer-limits.js +45 -0
  226. package/dist/ui/composer-rows.d.ts +73 -0
  227. package/dist/ui/composer-rows.js +129 -0
  228. package/dist/ui/console-bridge.d.ts +19 -0
  229. package/dist/ui/console-bridge.js +52 -0
  230. package/dist/ui/density.d.ts +26 -0
  231. package/dist/ui/density.js +34 -0
  232. package/dist/ui/display-tab.d.ts +51 -0
  233. package/dist/ui/display-tab.js +82 -0
  234. package/dist/ui/editor-navigation.d.ts +55 -0
  235. package/dist/ui/editor-navigation.js +96 -0
  236. package/dist/ui/editor-reducer.d.ts +108 -0
  237. package/dist/ui/editor-reducer.js +187 -0
  238. package/dist/ui/enter-frames.d.ts +47 -0
  239. package/dist/ui/enter-frames.js +117 -0
  240. package/dist/ui/entries/AssistantEntry.d.ts +37 -0
  241. package/dist/ui/entries/AssistantEntry.js +43 -0
  242. package/dist/ui/entries/CompactionCard.d.ts +88 -0
  243. package/dist/ui/entries/CompactionCard.js +222 -0
  244. package/dist/ui/entries/DiffView.d.ts +61 -0
  245. package/dist/ui/entries/DiffView.js +103 -0
  246. package/dist/ui/entries/EntryFrame.d.ts +23 -0
  247. package/dist/ui/entries/EntryFrame.js +6 -0
  248. package/dist/ui/entries/FastCard.d.ts +53 -0
  249. package/dist/ui/entries/FastCard.js +105 -0
  250. package/dist/ui/entries/GovernanceCard.d.ts +30 -0
  251. package/dist/ui/entries/GovernanceCard.js +32 -0
  252. package/dist/ui/entries/InvocationCard.d.ts +20 -0
  253. package/dist/ui/entries/InvocationCard.js +32 -0
  254. package/dist/ui/entries/QueuedEntry.d.ts +27 -0
  255. package/dist/ui/entries/QueuedEntry.js +33 -0
  256. package/dist/ui/entries/RetryCard.d.ts +56 -0
  257. package/dist/ui/entries/RetryCard.js +60 -0
  258. package/dist/ui/entries/ServiceCard.d.ts +82 -0
  259. package/dist/ui/entries/ServiceCard.js +151 -0
  260. package/dist/ui/entries/TeamCard.d.ts +55 -0
  261. package/dist/ui/entries/TeamCard.js +94 -0
  262. package/dist/ui/entries/TodoCard.d.ts +54 -0
  263. package/dist/ui/entries/TodoCard.js +98 -0
  264. package/dist/ui/entries/ToolCard.d.ts +81 -0
  265. package/dist/ui/entries/ToolCard.js +169 -0
  266. package/dist/ui/entries/ToolPreview.d.ts +59 -0
  267. package/dist/ui/entries/ToolPreview.js +208 -0
  268. package/dist/ui/entries/UserEntry.d.ts +36 -0
  269. package/dist/ui/entries/UserEntry.js +57 -0
  270. package/dist/ui/entries/WaitCard.d.ts +37 -0
  271. package/dist/ui/entries/WaitCard.js +92 -0
  272. package/dist/ui/exit-snapshot.d.ts +43 -0
  273. package/dist/ui/exit-snapshot.js +26 -0
  274. package/dist/ui/frame-differ.d.ts +166 -0
  275. package/dist/ui/frame-differ.js +354 -0
  276. package/dist/ui/frame-observer.d.ts +17 -0
  277. package/dist/ui/frame-observer.js +94 -0
  278. package/dist/ui/frame-parser.d.ts +7 -0
  279. package/dist/ui/frame-parser.js +18 -0
  280. package/dist/ui/gauge.d.ts +39 -0
  281. package/dist/ui/gauge.js +55 -0
  282. package/dist/ui/glyphs.d.ts +178 -0
  283. package/dist/ui/glyphs.js +165 -0
  284. package/dist/ui/governance-copy.d.ts +69 -0
  285. package/dist/ui/governance-copy.js +104 -0
  286. package/dist/ui/governance-status.d.ts +145 -0
  287. package/dist/ui/governance-status.js +326 -0
  288. package/dist/ui/gradient.d.ts +11 -0
  289. package/dist/ui/gradient.js +50 -0
  290. package/dist/ui/ink-runtime.d.ts +4 -0
  291. package/dist/ui/ink-runtime.js +51 -0
  292. package/dist/ui/interaction-copy.d.ts +84 -0
  293. package/dist/ui/interaction-copy.js +41 -0
  294. package/dist/ui/interaction-hints.d.ts +44 -0
  295. package/dist/ui/interaction-hints.js +97 -0
  296. package/dist/ui/layout/AppShell.d.ts +17 -0
  297. package/dist/ui/layout/AppShell.js +6 -0
  298. package/dist/ui/layout/Gutter.d.ts +67 -0
  299. package/dist/ui/layout/Gutter.js +42 -0
  300. package/dist/ui/layout/MeasuredEntry.d.ts +21 -0
  301. package/dist/ui/layout/MeasuredEntry.js +30 -0
  302. package/dist/ui/layout/OverlayFrame.d.ts +73 -0
  303. package/dist/ui/layout/OverlayFrame.js +110 -0
  304. package/dist/ui/layout/ScrollIndicator.d.ts +32 -0
  305. package/dist/ui/layout/ScrollIndicator.js +22 -0
  306. package/dist/ui/layout/ScrollViewport.d.ts +40 -0
  307. package/dist/ui/layout/ScrollViewport.js +222 -0
  308. package/dist/ui/layout/agents-board.d.ts +102 -0
  309. package/dist/ui/layout/agents-board.js +389 -0
  310. package/dist/ui/layout/autocomplete.d.ts +18 -0
  311. package/dist/ui/layout/autocomplete.js +26 -0
  312. package/dist/ui/layout/budget.d.ts +43 -0
  313. package/dist/ui/layout/budget.js +52 -0
  314. package/dist/ui/layout/cells.d.ts +61 -0
  315. package/dist/ui/layout/cells.js +156 -0
  316. package/dist/ui/layout/document-layout.d.ts +13 -0
  317. package/dist/ui/layout/document-layout.js +10 -0
  318. package/dist/ui/layout/follow-state.d.ts +138 -0
  319. package/dist/ui/layout/follow-state.js +148 -0
  320. package/dist/ui/layout/frame.d.ts +36 -0
  321. package/dist/ui/layout/frame.js +39 -0
  322. package/dist/ui/layout/governance-board.d.ts +121 -0
  323. package/dist/ui/layout/governance-board.js +382 -0
  324. package/dist/ui/layout/governance-card.d.ts +53 -0
  325. package/dist/ui/layout/governance-card.js +134 -0
  326. package/dist/ui/layout/governance-chip.d.ts +38 -0
  327. package/dist/ui/layout/governance-chip.js +64 -0
  328. package/dist/ui/layout/governance-panel.d.ts +85 -0
  329. package/dist/ui/layout/governance-panel.js +358 -0
  330. package/dist/ui/layout/governance-roster.d.ts +65 -0
  331. package/dist/ui/layout/governance-roster.js +275 -0
  332. package/dist/ui/layout/header-hints.d.ts +90 -0
  333. package/dist/ui/layout/header-hints.js +110 -0
  334. package/dist/ui/layout/header-left.d.ts +115 -0
  335. package/dist/ui/layout/header-left.js +206 -0
  336. package/dist/ui/layout/invocation-card.d.ts +41 -0
  337. package/dist/ui/layout/invocation-card.js +91 -0
  338. package/dist/ui/layout/kit-chip.d.ts +50 -0
  339. package/dist/ui/layout/kit-chip.js +81 -0
  340. package/dist/ui/layout/overlay-window.d.ts +43 -0
  341. package/dist/ui/layout/overlay-window.js +51 -0
  342. package/dist/ui/layout/queue-layout.d.ts +19 -0
  343. package/dist/ui/layout/queue-layout.js +26 -0
  344. package/dist/ui/layout/rail.d.ts +7 -0
  345. package/dist/ui/layout/rail.js +16 -0
  346. package/dist/ui/layout/scroll-indicator.d.ts +27 -0
  347. package/dist/ui/layout/scroll-indicator.js +36 -0
  348. package/dist/ui/layout/scroll.d.ts +37 -0
  349. package/dist/ui/layout/scroll.js +99 -0
  350. package/dist/ui/layout/scrollbar-geometry.d.ts +17 -0
  351. package/dist/ui/layout/scrollbar-geometry.js +13 -0
  352. package/dist/ui/layout/session-chip.d.ts +52 -0
  353. package/dist/ui/layout/session-chip.js +64 -0
  354. package/dist/ui/layout/shortcut-panel-layout.d.ts +191 -0
  355. package/dist/ui/layout/shortcut-panel-layout.js +321 -0
  356. package/dist/ui/layout/status-detail-layout.d.ts +9 -0
  357. package/dist/ui/layout/status-detail-layout.js +79 -0
  358. package/dist/ui/layout/status-layout.d.ts +140 -0
  359. package/dist/ui/layout/status-layout.js +262 -0
  360. package/dist/ui/layout/task-summary-cell.d.ts +61 -0
  361. package/dist/ui/layout/task-summary-cell.js +65 -0
  362. package/dist/ui/layout/team-panel.d.ts +18 -0
  363. package/dist/ui/layout/team-panel.js +25 -0
  364. package/dist/ui/layout/team-row.d.ts +139 -0
  365. package/dist/ui/layout/team-row.js +246 -0
  366. package/dist/ui/layout/todo-layout.d.ts +62 -0
  367. package/dist/ui/layout/todo-layout.js +102 -0
  368. package/dist/ui/layout/useTerminalSize.d.ts +13 -0
  369. package/dist/ui/layout/useTerminalSize.js +50 -0
  370. package/dist/ui/layout/viewport-geometry.d.ts +29 -0
  371. package/dist/ui/layout/viewport-geometry.js +28 -0
  372. package/dist/ui/layout/virtual-window.d.ts +112 -0
  373. package/dist/ui/layout/virtual-window.js +494 -0
  374. package/dist/ui/layout/wait-bar.d.ts +34 -0
  375. package/dist/ui/layout/wait-bar.js +48 -0
  376. package/dist/ui/layout/wrap-rows.d.ts +26 -0
  377. package/dist/ui/layout/wrap-rows.js +88 -0
  378. package/dist/ui/live-clamp.d.ts +14 -0
  379. package/dist/ui/live-clamp.js +46 -0
  380. package/dist/ui/markdown-blocks.d.ts +107 -0
  381. package/dist/ui/markdown-blocks.js +240 -0
  382. package/dist/ui/overlays/AgentsBoardOverlay.d.ts +57 -0
  383. package/dist/ui/overlays/AgentsBoardOverlay.js +183 -0
  384. package/dist/ui/overlays/ConfirmDialog.d.ts +31 -0
  385. package/dist/ui/overlays/ConfirmDialog.js +44 -0
  386. package/dist/ui/overlays/GovernanceBoardOverlay.d.ts +41 -0
  387. package/dist/ui/overlays/GovernanceBoardOverlay.js +76 -0
  388. package/dist/ui/overlays/GovernanceSettingsPage.d.ts +48 -0
  389. package/dist/ui/overlays/GovernanceSettingsPage.js +93 -0
  390. package/dist/ui/overlays/HelpOverlay.d.ts +29 -0
  391. package/dist/ui/overlays/HelpOverlay.js +232 -0
  392. package/dist/ui/overlays/KitEditor.d.ts +23 -0
  393. package/dist/ui/overlays/KitEditor.js +101 -0
  394. package/dist/ui/overlays/KitManager.d.ts +23 -0
  395. package/dist/ui/overlays/KitManager.js +104 -0
  396. package/dist/ui/overlays/KitPicker.d.ts +49 -0
  397. package/dist/ui/overlays/KitPicker.js +58 -0
  398. package/dist/ui/overlays/ModelDiscoveryList.d.ts +23 -0
  399. package/dist/ui/overlays/ModelDiscoveryList.js +161 -0
  400. package/dist/ui/overlays/ModelPicker.d.ts +26 -0
  401. package/dist/ui/overlays/ModelPicker.js +63 -0
  402. package/dist/ui/overlays/ModelProfileEditor.d.ts +29 -0
  403. package/dist/ui/overlays/ModelProfileEditor.js +168 -0
  404. package/dist/ui/overlays/ModelProfilePicker.d.ts +48 -0
  405. package/dist/ui/overlays/ModelProfilePicker.js +231 -0
  406. package/dist/ui/overlays/PlanReviewOverlay.d.ts +51 -0
  407. package/dist/ui/overlays/PlanReviewOverlay.js +132 -0
  408. package/dist/ui/overlays/PromptEditorPage.d.ts +48 -0
  409. package/dist/ui/overlays/PromptEditorPage.js +227 -0
  410. package/dist/ui/overlays/PromptLibraryOverlay.d.ts +37 -0
  411. package/dist/ui/overlays/PromptLibraryOverlay.js +191 -0
  412. package/dist/ui/overlays/PromptPicker.d.ts +36 -0
  413. package/dist/ui/overlays/PromptPicker.js +129 -0
  414. package/dist/ui/overlays/PromptTextArea.d.ts +86 -0
  415. package/dist/ui/overlays/PromptTextArea.js +141 -0
  416. package/dist/ui/overlays/QuestionOverlay.d.ts +39 -0
  417. package/dist/ui/overlays/QuestionOverlay.js +258 -0
  418. package/dist/ui/overlays/QueueOverlay.d.ts +22 -0
  419. package/dist/ui/overlays/QueueOverlay.js +79 -0
  420. package/dist/ui/overlays/SettingsScreen.d.ts +228 -0
  421. package/dist/ui/overlays/SettingsScreen.js +1037 -0
  422. package/dist/ui/overlays/ShortcutPanel.d.ts +39 -0
  423. package/dist/ui/overlays/ShortcutPanel.js +106 -0
  424. package/dist/ui/overlays/TeamFanoutPage.d.ts +51 -0
  425. package/dist/ui/overlays/TeamFanoutPage.js +90 -0
  426. package/dist/ui/overlays/governance-settings.d.ts +79 -0
  427. package/dist/ui/overlays/governance-settings.js +140 -0
  428. package/dist/ui/overlays/kit-picker-state.d.ts +87 -0
  429. package/dist/ui/overlays/kit-picker-state.js +136 -0
  430. package/dist/ui/overlays/kit-settings-state.d.ts +129 -0
  431. package/dist/ui/overlays/kit-settings-state.js +268 -0
  432. package/dist/ui/overlays/model-probe-view.d.ts +128 -0
  433. package/dist/ui/overlays/model-probe-view.js +225 -0
  434. package/dist/ui/overlays/model-profile-state.d.ts +177 -0
  435. package/dist/ui/overlays/model-profile-state.js +301 -0
  436. package/dist/ui/overlays/prompt-library-state.d.ts +162 -0
  437. package/dist/ui/overlays/prompt-library-state.js +335 -0
  438. package/dist/ui/overlays/prompt-picker-state.d.ts +71 -0
  439. package/dist/ui/overlays/prompt-picker-state.js +98 -0
  440. package/dist/ui/overlays/team-fanout-state.d.ts +106 -0
  441. package/dist/ui/overlays/team-fanout-state.js +155 -0
  442. package/dist/ui/overlays/use-model-probe.d.ts +30 -0
  443. package/dist/ui/overlays/use-model-probe.js +109 -0
  444. package/dist/ui/palettes.d.ts +112 -0
  445. package/dist/ui/palettes.js +130 -0
  446. package/dist/ui/paste-frames.d.ts +91 -0
  447. package/dist/ui/paste-frames.js +117 -0
  448. package/dist/ui/paste-tokens.d.ts +90 -0
  449. package/dist/ui/paste-tokens.js +147 -0
  450. package/dist/ui/render-cache.d.ts +81 -0
  451. package/dist/ui/render-cache.js +196 -0
  452. package/dist/ui/render-governor.d.ts +54 -0
  453. package/dist/ui/render-governor.js +78 -0
  454. package/dist/ui/run-metrics.d.ts +23 -0
  455. package/dist/ui/run-metrics.js +27 -0
  456. package/dist/ui/run-status-row.d.ts +63 -0
  457. package/dist/ui/run-status-row.js +54 -0
  458. package/dist/ui/screen.d.ts +107 -0
  459. package/dist/ui/screen.js +234 -0
  460. package/dist/ui/scrollback/LiveTail.d.ts +115 -0
  461. package/dist/ui/scrollback/LiveTail.js +48 -0
  462. package/dist/ui/scrollback/band.d.ts +114 -0
  463. package/dist/ui/scrollback/band.js +143 -0
  464. package/dist/ui/scrollback/budget.d.ts +90 -0
  465. package/dist/ui/scrollback/budget.js +100 -0
  466. package/dist/ui/scrollback/canvas.d.ts +100 -0
  467. package/dist/ui/scrollback/canvas.js +114 -0
  468. package/dist/ui/scrollback/cursor-probe.d.ts +71 -0
  469. package/dist/ui/scrollback/cursor-probe.js +133 -0
  470. package/dist/ui/scrollback/drain.d.ts +32 -0
  471. package/dist/ui/scrollback/drain.js +64 -0
  472. package/dist/ui/scrollback/exit-summary.d.ts +23 -0
  473. package/dist/ui/scrollback/exit-summary.js +25 -0
  474. package/dist/ui/scrollback/limits.d.ts +98 -0
  475. package/dist/ui/scrollback/limits.js +98 -0
  476. package/dist/ui/scrollback/live-preview.d.ts +34 -0
  477. package/dist/ui/scrollback/live-preview.js +130 -0
  478. package/dist/ui/scrollback/overflow-print.d.ts +108 -0
  479. package/dist/ui/scrollback/overflow-print.js +120 -0
  480. package/dist/ui/scrollback/renderer.d.ts +48 -0
  481. package/dist/ui/scrollback/renderer.js +186 -0
  482. package/dist/ui/scrollback/scrollback-writer.d.ts +174 -0
  483. package/dist/ui/scrollback/scrollback-writer.js +648 -0
  484. package/dist/ui/scrollback/settled-boundary.d.ts +42 -0
  485. package/dist/ui/scrollback/settled-boundary.js +109 -0
  486. package/dist/ui/scrollback/tail-anchor.d.ts +71 -0
  487. package/dist/ui/scrollback/tail-anchor.js +79 -0
  488. package/dist/ui/scrollback/tail-window.d.ts +73 -0
  489. package/dist/ui/scrollback/tail-window.js +89 -0
  490. package/dist/ui/scrollback/use-scrollback-view.d.ts +139 -0
  491. package/dist/ui/scrollback/use-scrollback-view.js +601 -0
  492. package/dist/ui/scrollback/writer-shapes.d.ts +127 -0
  493. package/dist/ui/scrollback/writer-shapes.js +159 -0
  494. package/dist/ui/scrollbar-controller.d.ts +30 -0
  495. package/dist/ui/scrollbar-controller.js +124 -0
  496. package/dist/ui/selection/highlight.d.ts +39 -0
  497. package/dist/ui/selection/highlight.js +64 -0
  498. package/dist/ui/selection/screen-mirror.d.ts +24 -0
  499. package/dist/ui/selection/screen-mirror.js +35 -0
  500. package/dist/ui/selection/selection-controller.d.ts +104 -0
  501. package/dist/ui/selection/selection-controller.js +372 -0
  502. package/dist/ui/selection/selection.d.ts +90 -0
  503. package/dist/ui/selection/selection.js +223 -0
  504. package/dist/ui/shortcuts.d.ts +81 -0
  505. package/dist/ui/shortcuts.js +221 -0
  506. package/dist/ui/status-feedback.d.ts +35 -0
  507. package/dist/ui/status-feedback.js +38 -0
  508. package/dist/ui/stdout-frame-writer.d.ts +74 -0
  509. package/dist/ui/stdout-frame-writer.js +155 -0
  510. package/dist/ui/team-status.d.ts +166 -0
  511. package/dist/ui/team-status.js +252 -0
  512. package/dist/ui/terminal-plan.d.ts +52 -0
  513. package/dist/ui/terminal-plan.js +49 -0
  514. package/dist/ui/theme.d.ts +96 -0
  515. package/dist/ui/theme.js +130 -0
  516. package/dist/ui/transcript-text.d.ts +41 -0
  517. package/dist/ui/transcript-text.js +282 -0
  518. package/dist/ui/use-height-store.d.ts +31 -0
  519. package/dist/ui/use-height-store.js +76 -0
  520. package/dist/ui/use-render-governor.d.ts +39 -0
  521. package/dist/ui/use-render-governor.js +57 -0
  522. package/dist/ui/use-wheel-routing.d.ts +57 -0
  523. package/dist/ui/use-wheel-routing.js +152 -0
  524. package/dist/ui/win-vt-force.d.ts +136 -0
  525. package/dist/ui/win-vt-force.js +237 -0
  526. package/dist/ui/win-vt-input.d.ts +57 -0
  527. package/dist/ui/win-vt-input.js +62 -0
  528. package/package.json +86 -4
@@ -0,0 +1,227 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The prompt editor page (quick-prompt-library §4.4 / D-11).
4
+ *
5
+ * ASCII ONLY - `src/ui/**` is inside `glyphs.test.ts::inScope`. Labels and the footer
6
+ * are English like every other overlay; every sentence that explains a REFUSAL comes
7
+ * from `prompts/copy.ts`.
8
+ *
9
+ * SELF-MANAGED `OverlayFrame`, not the controlled one. The two modes are a
10
+ * discriminated union (`children?: undefined`), and this page lays out a multi-row
11
+ * body field that owns its own scrolling: handing it over as `rows` would mean the
12
+ * frame counts a body's lines as rows and windows them again (P2-2).
13
+ *
14
+ * TWO WAYS TO SAVE, AND THE SECOND ONE IS NOT DECORATION. `Ctrl+S` is the fast path,
15
+ * and it is a byte a terminal can eat (XON/XOFF) - so `Tab` to the `Save` row and
16
+ * `Enter` must do exactly the same thing. That is what keeps "I cannot save" from
17
+ * being a bug a whole class of terminals can reproduce.
18
+ */
19
+ import { useEffect, useState } from 'react';
20
+ import { Box, Text, useInput } from 'ink';
21
+ import { pickGlyphs } from '../glyphs.js';
22
+ import { stripPasteFrames } from '../paste-frames.js';
23
+ import { stripEnterFrames } from '../enter-frames.js';
24
+ import { stepGrapheme } from '../editor-navigation.js';
25
+ import { OverlayFrame, overlayBodyRows } from '../layout/OverlayFrame.js';
26
+ import { promptErrorCopy } from '../../model/prompts/copy.js';
27
+ import { PROMPT_EDITOR_FIELDS, fieldIndex, } from './prompt-library-state.js';
28
+ import { EMPTY_TEXT_AREA, PromptTextArea, promptTextAreaReducer, } from './PromptTextArea.js';
29
+ /** Columns the field labels occupy. Fixed, so the values line up. */
30
+ const LABEL_CELLS = 10;
31
+ /** Body rows the page reserves for chrome when the frame is generous. */
32
+ const MIN_BODY_ROWS = 3;
33
+ /** Text fields of the page, in the order Tab visits them. */
34
+ function nextField(at, delta) {
35
+ const count = PROMPT_EDITOR_FIELDS.length;
36
+ return (at + delta + count) % count;
37
+ }
38
+ /**
39
+ * Which deletion key was pressed, if any.
40
+ *
41
+ * `key.delete` IS TREATED AS BACKSPACE, and the reason is measured rather than assumed:
42
+ * ink's parser reports the `0x7f` byte - which is what the BACKSPACE KEY sends on every
43
+ * terminal this product runs on - as `name: 'delete'`, and it hands the component an
44
+ * EMPTY `input` for both it and `ESC [ 3 ~`. The two are therefore indistinguishable at
45
+ * this layer, and the safe reading is the one the keyboard actually produces: backward.
46
+ * A forward-delete binding that fired on Backspace would delete the character the user
47
+ * was not looking at, and there is no undo in this field.
48
+ */
49
+ function deletionKind(_input, key) {
50
+ return key.backspace === true || key.delete === true ? 'backspace' : null;
51
+ }
52
+ /**
53
+ * The page.
54
+ *
55
+ * The draft lives in the parent (the reducer owns it, so `Save` and `Esc` can see the
56
+ * same text); this component owns only what no other surface needs: which row has
57
+ * focus, and where each single-line field's caret sits.
58
+ */
59
+ export function PromptEditorPage(props) {
60
+ const { state, cols, maxRows, theme, caps } = props;
61
+ const draft = state.draft;
62
+ const glyphs = pickGlyphs(caps);
63
+ const [focus, setFocus] = useState(0);
64
+ // THE CARET STARTS AT THE END OF EACH FIELD, which is where a user expects to append:
65
+ // starting at 0 would put every typed character in FRONT of the prefilled text, so an
66
+ // edit to `Clean code review` would read `FixClean code review`.
67
+ const [cursors, setCursors] = useState(() => ({
68
+ title: draft.title.length,
69
+ description: draft.description.length,
70
+ tags: draft.tags.length,
71
+ }));
72
+ const [content, setContent] = useState({
73
+ ...EMPTY_TEXT_AREA,
74
+ buffer: draft.content,
75
+ cursor: draft.content.length,
76
+ });
77
+ const field = PROMPT_EDITOR_FIELDS[Math.min(focus, PROMPT_EDITOR_FIELDS.length - 1)];
78
+ const bodyRows = Math.max(MIN_BODY_ROWS, overlayBodyRows(maxRows, cols) - 5);
79
+ const fieldCols = Math.max(8, cols - LABEL_CELLS - 6);
80
+ // A REFUSAL OWNS THE FOCUS (D-12): the store already names the row that failed, so the
81
+ // caret is moved there instead of leaving the user to read an error in a footer and
82
+ // work out which of four fields it is about. Keyed on `state.error`, so it fires once
83
+ // per distinct refusal rather than on every render.
84
+ useEffect(() => {
85
+ if (state.error === null)
86
+ return;
87
+ setFocus(fieldIndex(state.errorField));
88
+ }, [state.error, state.errorField]);
89
+ const editSingle = (name, text, key, deletion) => {
90
+ const value = draft[name];
91
+ const cursor = Math.min(cursors[name], value.length);
92
+ if (key.leftArrow || key.rightArrow) {
93
+ setCursors({
94
+ ...cursors,
95
+ [name]: stepGrapheme(value, cursor, key.leftArrow ? 'left' : 'right'),
96
+ });
97
+ return;
98
+ }
99
+ if (deletion === 'backspace') {
100
+ if (cursor <= 0)
101
+ return;
102
+ const from = stepGrapheme(value, cursor, 'left');
103
+ props.onDraft({ [name]: value.slice(0, from) + value.slice(cursor) });
104
+ setCursors({ ...cursors, [name]: from });
105
+ return;
106
+ }
107
+ if (text.length === 0)
108
+ return;
109
+ const next = value.slice(0, cursor) + text + value.slice(cursor);
110
+ props.onDraft({ [name]: next });
111
+ setCursors({ ...cursors, [name]: cursor + text.length });
112
+ };
113
+ const applyContent = (action) => {
114
+ const current = { ...content, buffer: draft.content };
115
+ const next = promptTextAreaReducer(current, action);
116
+ // COMPARED ON THE FIELDS, not on object identity: the reducer echoes its input object
117
+ // back for a no-op move, and that object is rebuilt on every keystroke - so an
118
+ // identity check would both hide the no-op and trigger a render for it.
119
+ if (next.buffer !== current.buffer || next.cursor !== current.cursor)
120
+ setContent(next);
121
+ if (next.buffer !== draft.content)
122
+ props.onDraft({ content: next.buffer });
123
+ };
124
+ useInput((input, key) => {
125
+ if (props.isActive === false)
126
+ return;
127
+ // BEFORE EVERYTHING: a refused save and a dirty Esc are both two-step states, and
128
+ // the accelerator that resolves them must not be swallowed by the text handling
129
+ // below. `Ctrl+S` is the same precedent `SettingsScreen.tsx` set.
130
+ if (key.ctrl && (input === 's' || input === 'S')) {
131
+ props.onSave();
132
+ return;
133
+ }
134
+ if (key.escape) {
135
+ props.onEsc();
136
+ return;
137
+ }
138
+ if (key.tab) {
139
+ setFocus(nextField(focus, key.shift ? -1 : 1));
140
+ return;
141
+ }
142
+ const clean = stripPasteFrames(stripEnterFrames(input));
143
+ if (field === 'save') {
144
+ if (key.return)
145
+ props.onSave();
146
+ return;
147
+ }
148
+ if (field === 'cancel') {
149
+ if (key.return)
150
+ props.onCancel();
151
+ return;
152
+ }
153
+ if (field === 'content') {
154
+ if (key.upArrow) {
155
+ applyContent({ type: 'up', cols: fieldCols });
156
+ return;
157
+ }
158
+ if (key.downArrow) {
159
+ applyContent({ type: 'down', cols: fieldCols });
160
+ return;
161
+ }
162
+ if (key.return || clean.includes('\n')) {
163
+ applyContent({ type: 'newline' });
164
+ return;
165
+ }
166
+ const contentDeletion = deletionKind(input, key);
167
+ if (contentDeletion !== null) {
168
+ applyContent({ type: contentDeletion });
169
+ return;
170
+ }
171
+ if (key.leftArrow) {
172
+ applyContent({ type: 'left' });
173
+ return;
174
+ }
175
+ if (key.rightArrow) {
176
+ applyContent({ type: 'right' });
177
+ return;
178
+ }
179
+ if (key.ctrl || key.meta)
180
+ return;
181
+ if (clean.length > 0)
182
+ applyContent({ type: 'insert', text: clean });
183
+ return;
184
+ }
185
+ // Single-line fields: Enter advances rather than saving, because there is nothing
186
+ // for a newline to mean in a one-line field.
187
+ if (key.return) {
188
+ setFocus(nextField(focus, 1));
189
+ return;
190
+ }
191
+ if (key.upArrow) {
192
+ setFocus(nextField(focus, -1));
193
+ return;
194
+ }
195
+ if (key.downArrow) {
196
+ setFocus(nextField(focus, 1));
197
+ return;
198
+ }
199
+ if (key.ctrl || key.meta)
200
+ return;
201
+ editSingle(field, clean, key, deletionKind(input, key));
202
+ });
203
+ /** One text field, or an action row. The caret marks the focused one. */
204
+ const row = (name) => {
205
+ const focused = field === name;
206
+ const caret = focused ? glyphs.caret : ' ';
207
+ if (name === 'save' || name === 'cancel') {
208
+ const label = name === 'save' ? 'Save' : 'Cancel';
209
+ return (_jsx(Text, { wrap: "truncate", color: focused ? theme.accent : theme.muted, children: `${caret} [ ${label} ]` }, name));
210
+ }
211
+ const label = name === 'title' ? 'Title' : name === 'content' ? 'Body'
212
+ : name === 'description' ? 'Note' : 'Tags';
213
+ const value = draft[name];
214
+ if (name === 'content') {
215
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { wrap: "truncate", color: focused ? theme.accent : theme.muted, children: `${caret} ${label.padEnd(LABEL_CELLS)}` }), _jsx(Box, { flexDirection: "column", paddingLeft: 2, children: _jsx(PromptTextArea, { state: { ...content, buffer: draft.content }, cols: fieldCols, rows: bodyRows, focused: focused, theme: theme, caps: caps, ...(props.reducedMotion === undefined ? {} : { reducedMotion: props.reducedMotion }) }) })] }, name));
216
+ }
217
+ const shown = value.length === 0 ? '(empty)' : value;
218
+ return (_jsx(Text, { wrap: "truncate", color: focused ? theme.accent : theme.muted, children: `${caret} ${label.padEnd(LABEL_CELLS)}${shown}` }, name));
219
+ };
220
+ const title = state.error === null
221
+ ? (draft.id === null ? 'New prompt' : 'Edit prompt')
222
+ : promptErrorCopy(state.error);
223
+ const hint = state.escArmed
224
+ ? 'Esc again discards the draft | Tab next field'
225
+ : 'Tab next field | Enter next line | Ctrl+S save | Esc close';
226
+ return (_jsxs(OverlayFrame, { title: title, hint: hint, maxRows: maxRows, cols: cols, theme: theme, caps: caps, children: [_jsxs(Text, { wrap: "truncate", color: theme.muted, children: [_jsx(Text, { color: draft.favorite ? theme.toolDone : theme.muted, children: draft.favorite ? '[fav] ' : ' ' }), `${[...draft.content].length} chars`] }), _jsx(Box, { flexDirection: "column", children: PROMPT_EDITOR_FIELDS.map((name) => row(name)) })] }));
227
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The prompt manager: `Ctrl+P` (quick-prompt-library §4.4 / §6.4).
3
+ *
4
+ * ASCII ONLY - `src/ui/**` is inside `glyphs.test.ts::inScope`.
5
+ *
6
+ * A LIST PLUS A DETAIL BLOCK, the `KitPicker` idiom (F-17): three columns of prompt
7
+ * metadata never fit on a 72-column terminal, and the detail block is how this
8
+ * package already shows everything that does not fit in a row.
9
+ *
10
+ * THE OVERLAY OWNS NO DATA. Every mutation goes out through `onMutate`, and the new
11
+ * snapshot comes back through `library`. An overlay that patched its own copy would
12
+ * show a prompt the disk does not have (I-6), and the first time that happened the
13
+ * user would find out at the next launch.
14
+ */
15
+ import React from 'react';
16
+ import type { Theme } from '../theme.js';
17
+ import type { TermCapabilities } from '../capabilities.js';
18
+ import type { PromptLibrary, PromptLibraryIntent, PromptLibraryMutation, PromptMutationResult } from '../../model/prompts/types.js';
19
+ export interface PromptLibraryOverlayProps {
20
+ isActive: boolean;
21
+ library: PromptLibrary;
22
+ /** D-21's one-shot hand-off; consumed at most once (I-8). */
23
+ intent?: PromptLibraryIntent;
24
+ cols: number;
25
+ maxRows: number;
26
+ scrollOffset: number;
27
+ onScrollClamp?: (offset: number) => void;
28
+ theme: Theme;
29
+ caps: TermCapabilities;
30
+ reducedMotion?: boolean;
31
+ /** The store, reached through `App` so this component stays a view. */
32
+ onMutate: (action: PromptLibraryMutation) => PromptMutationResult;
33
+ /** One-shot feedback (save, delete, write failure) for `App`'s toast channel. */
34
+ onNotice?: (level: 'info' | 'warn' | 'error', text: string) => void;
35
+ onClose: () => void;
36
+ }
37
+ export declare function PromptLibraryOverlay(props: PromptLibraryOverlayProps): React.ReactElement;
@@ -0,0 +1,191 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * The prompt manager: `Ctrl+P` (quick-prompt-library §4.4 / §6.4).
4
+ *
5
+ * ASCII ONLY - `src/ui/**` is inside `glyphs.test.ts::inScope`.
6
+ *
7
+ * A LIST PLUS A DETAIL BLOCK, the `KitPicker` idiom (F-17): three columns of prompt
8
+ * metadata never fit on a 72-column terminal, and the detail block is how this
9
+ * package already shows everything that does not fit in a row.
10
+ *
11
+ * THE OVERLAY OWNS NO DATA. Every mutation goes out through `onMutate`, and the new
12
+ * snapshot comes back through `library`. An overlay that patched its own copy would
13
+ * show a prompt the disk does not have (I-6), and the first time that happened the
14
+ * user would find out at the next launch.
15
+ */
16
+ import { useEffect, useReducer, useRef } from 'react';
17
+ import { Text, useInput } from 'ink';
18
+ import { pickGlyphs } from '../glyphs.js';
19
+ import { OverlayFrame } from '../layout/OverlayFrame.js';
20
+ import { clipProfileText, useProfileScroll } from './ModelProfilePicker.js';
21
+ import { promptDeletedCopy, promptErrorCopy, promptSavedCopy, PROMPT_EMPTY_BODY_COPY, PROMPT_EMPTY_TITLE_COPY } from '../../model/prompts/copy.js';
22
+ import { INITIAL_PROMPT_LIBRARY_STATE, deleteDetail, finishPromptEditor, libraryDetail, libraryHint, libraryRows, promptLibraryReducer, } from './prompt-library-state.js';
23
+ import { PromptEditorPage } from './PromptEditorPage.js';
24
+ /** The reducer takes the library as a third argument, so it is bound per dispatch. */
25
+ function reduce(state, dispatched) {
26
+ return promptLibraryReducer(state, dispatched.action, dispatched.library);
27
+ }
28
+ export function PromptLibraryOverlay(props) {
29
+ const { library, cols, theme, caps } = props;
30
+ const glyphs = pickGlyphs(caps);
31
+ const [state, rawDispatch] = useReducer(reduce, INITIAL_PROMPT_LIBRARY_STATE);
32
+ const dispatch = (action) => rawDispatch({ action, library });
33
+ const rows = libraryRows(library);
34
+ const count = rows.length;
35
+ const cursor = count === 0 ? 0 : Math.min(state.index, count - 1);
36
+ const focused = rows[cursor];
37
+ const offset = useProfileScroll(props, cursor);
38
+ /**
39
+ * CONSUME THE INTENT EXACTLY ONCE (I-8).
40
+ *
41
+ * A `useRef`, not state: the ref is written before the dispatch is processed, so a
42
+ * StrictMode double-invoke of this effect sees `nonce <= consumed` and does nothing.
43
+ * State would be one render behind and would open the editor twice.
44
+ */
45
+ const consumed = useRef(0);
46
+ const intent = props.intent;
47
+ useEffect(() => {
48
+ if (!intent || intent.nonce <= consumed.current)
49
+ return;
50
+ consumed.current = intent.nonce;
51
+ dispatch({ type: 'init', entry: intent.entry, library, nonce: intent.nonce });
52
+ }, [intent]);
53
+ /** One mutation, its refusal routed to the same two channels every time. */
54
+ const mutate = (action) => {
55
+ const result = props.onMutate(action);
56
+ if (!result.ok)
57
+ props.onNotice?.('warn', promptErrorCopy(result.code));
58
+ return result;
59
+ };
60
+ const save = () => {
61
+ const verdict = finishPromptEditor(state.draft);
62
+ if (!verdict.ok) {
63
+ dispatch({ type: 'failed', code: verdict.code, field: verdict.field });
64
+ props.onNotice?.('warn', promptErrorCopy(verdict.code));
65
+ return;
66
+ }
67
+ const draft = state.draft;
68
+ const result = draft.id === null
69
+ ? mutate({ kind: 'create', draft })
70
+ : mutate({ kind: 'update', id: draft.id, draft });
71
+ if (!result.ok) {
72
+ // THE PAGE DOES NOT CLOSE AND THE DRAFT IS NOT TOUCHED (D-12): the editor is
73
+ // where the user has invested the most, so a refusal must cost nothing.
74
+ dispatch({ type: 'failed', code: result.code });
75
+ return;
76
+ }
77
+ dispatch({ type: 'commit', id: result.id ?? draft.id });
78
+ props.onNotice?.('info', promptSavedCopy(draft.title.trim()));
79
+ };
80
+ const confirmDelete = () => {
81
+ const id = state.pendingDeleteId;
82
+ if (!id) {
83
+ dispatch({ type: 'cancelled' });
84
+ return;
85
+ }
86
+ const title = library.prompts.find((prompt) => prompt.id === id)?.title ?? '';
87
+ const result = mutate({ kind: 'delete', id });
88
+ dispatch({ type: 'cancelled' });
89
+ // `promptDeletedCopy`, not `promptSavedCopy`: the two sentences are one word apart
90
+ // and the wrong one tells the user their prompt still exists.
91
+ if (result.ok)
92
+ props.onNotice?.('info', promptDeletedCopy(title));
93
+ };
94
+ useInput((input, key) => {
95
+ if (props.isActive === false)
96
+ return;
97
+ // THE EDITOR PAGE OWNS EVERY KEY WHILE IT IS OPEN, Esc INCLUDED. Two `useInput`
98
+ // hooks are live at once (this one and the page's), so handling Esc in both would
99
+ // dispatch `esc` TWICE for one keypress: the first arms the discard and the second
100
+ // executes it, which silently throws away a drafted body on a single Esc. The page
101
+ // already reports Esc through `onEsc`, so this branch must stay silent.
102
+ if (state.page === 'editor')
103
+ return;
104
+ if (state.page === 'delete') {
105
+ if (key.escape || input === 'n' || input === 'N') {
106
+ dispatch({ type: 'cancelled' });
107
+ return;
108
+ }
109
+ if (key.return || input === 'y' || input === 'Y')
110
+ confirmDelete();
111
+ return;
112
+ }
113
+ // --- list page ---------------------------------------------------------
114
+ if (key.escape) {
115
+ props.onClose();
116
+ return;
117
+ }
118
+ // THE RAW SEQUENCE **AND** THE PARSED CHORD (D-23, corrected by measurement).
119
+ // Ink 5's `parse-keypress` recognises `\x1b[1;5A`, reports it as
120
+ // `ctrl + upArrow`, and hands the component an EMPTY `input` - so the sequence
121
+ // comparison alone would be a dead branch on this runtime, and the chord
122
+ // comparison alone would miss a host that passes the raw bytes through. Either
123
+ // shape reorders; `\x1b[A` (modifier lost) matches neither and only moves focus.
124
+ const reorderUp = input === '\x1b[1;5A' || (key.ctrl && key.upArrow);
125
+ const reorderDown = input === '\x1b[1;5B' || (key.ctrl && key.downArrow);
126
+ if (reorderUp || reorderDown) {
127
+ if (!focused)
128
+ return;
129
+ const result = mutate({ kind: 'move', id: focused.id, delta: reorderUp ? -1 : 1 });
130
+ if (result.ok)
131
+ dispatch({ type: 'list', focusId: focused.id });
132
+ return;
133
+ }
134
+ if (key.upArrow || (key.tab && key.shift)) {
135
+ dispatch({ type: 'focus', index: count === 0 ? 0 : (cursor - 1 + count) % count });
136
+ return;
137
+ }
138
+ if (key.downArrow) {
139
+ dispatch({ type: 'focus', index: count === 0 ? 0 : (cursor + 1) % count });
140
+ return;
141
+ }
142
+ if (key.return) {
143
+ if (focused)
144
+ dispatch({ type: 'edit', id: focused.id, library });
145
+ return;
146
+ }
147
+ if (key.ctrl || key.meta)
148
+ return;
149
+ if (input === 'a') {
150
+ dispatch({ type: 'create' });
151
+ return;
152
+ }
153
+ if (input === 'd' && focused) {
154
+ dispatch({ type: 'delete', id: focused.id });
155
+ return;
156
+ }
157
+ if (input === 'f' && focused) {
158
+ const prompt = library.prompts.find((entry) => entry.id === focused.id);
159
+ mutate({ kind: 'favorite', id: focused.id, favorite: prompt?.favorite !== true });
160
+ dispatch({ type: 'list', focusId: focused.id });
161
+ }
162
+ });
163
+ if (state.page === 'editor') {
164
+ return (_jsx(PromptEditorPage, { isActive: props.isActive, state: state, cols: cols, maxRows: props.maxRows, theme: theme, caps: caps, ...(props.reducedMotion === undefined ? {} : { reducedMotion: props.reducedMotion }), onDraft: (patch) => dispatch({ type: 'draft', patch }), onSave: save, onEsc: () => dispatch({ type: 'esc' }), onCancel: () => dispatch({ type: 'cancelled' }) }));
165
+ }
166
+ const body = [];
167
+ if (state.page === 'delete') {
168
+ for (const [at, line] of deleteDetail(library, state.pendingDeleteId).entries()) {
169
+ body.push(_jsx(Text, { wrap: "truncate", color: at === 0 ? theme.accent : theme.muted, children: clipProfileText(line, cols - 8) }, `del-${at}`));
170
+ }
171
+ return (_jsx(OverlayFrame, { title: "Delete prompt", hint: libraryHint(state, count), rows: body, scrollOffset: 0, maxRows: props.maxRows, cols: cols, theme: theme, caps: caps }));
172
+ }
173
+ for (const [at, row] of rows.entries()) {
174
+ const isCursor = at === cursor;
175
+ body.push(_jsx(Text, { wrap: "truncate", color: isCursor ? theme.accent : theme.muted, children: `${isCursor ? glyphs.caret : ' '} ${clipProfileText(row.label, cols - 8)}` }, row.id));
176
+ }
177
+ if (count === 0) {
178
+ // TWO ROWS, NOT AN EMPTY SCREEN (§9.7): an empty list that says nothing reads as a
179
+ // broken panel, and the key that fixes it (`a`) is not otherwise discoverable. The
180
+ // sentences come from `prompts/copy.ts` so this state and the picker's own empty
181
+ // state cannot drift into two wordings of the same advice.
182
+ body.push(_jsx(Text, { wrap: "truncate", color: theme.muted, children: clipProfileText(PROMPT_EMPTY_TITLE_COPY, cols - 8) }, "empty-title"));
183
+ body.push(_jsx(Text, { wrap: "truncate", color: theme.muted, children: clipProfileText(PROMPT_EMPTY_BODY_COPY, cols - 8) }, "empty-body"));
184
+ }
185
+ // THE DETAIL BLOCK DESCRIBES THE FOCUSED ROW ONLY, and it is last so a narrow
186
+ // terminal clips the description rather than the list.
187
+ for (const [at, line] of libraryDetail(focused, library, cols).entries()) {
188
+ body.push(_jsx(Text, { wrap: "truncate", color: theme.muted, children: clipProfileText(` ${line}`, cols - 8) }, `detail-${at}`));
189
+ }
190
+ return (_jsx(OverlayFrame, { title: `Prompts${count > 0 ? ` (${count})` : ''}`, hint: libraryHint(state, count), rows: body, scrollOffset: offset, onScrollClamp: props.onScrollClamp, maxRows: props.maxRows, cols: cols, theme: theme, caps: caps }));
191
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The prompt picker: `/prompts` (quick-prompt-library §4.5).
3
+ *
4
+ * ASCII ONLY - `src/ui/**` is inside `glyphs.test.ts::inScope`.
5
+ *
6
+ * THE QUERY BOX IS THE LIST. There is no separate search field and no `/` mode: the
7
+ * picker exists for one keystroke-to-answer gesture, and an extra mode to enter is an
8
+ * extra thing that can be wrong about which component owns the next key.
9
+ *
10
+ * `Ctrl+Enter` IS RECOGNISED BY ITS BYTES, NOT BY `key.ctrl && key.return`. The stdin
11
+ * filter normalises every modified Enter (`\x1b[13;5u`, the win32 record, `\x1b[13;2u`)
12
+ * into `ENTER_NEWLINE_FRAME` before Ink sees it (enter-sequences.ts), so the parsed
13
+ * chord never occurs - a branch written that way is dead code that LOOKS implemented
14
+ * (R-11). On a terminal without keyboard enhancement the chord degrades to a plain
15
+ * `Enter`, which fills without sending; the footer therefore names `Enter fill` first.
16
+ */
17
+ import React from 'react';
18
+ import type { Theme } from '../theme.js';
19
+ import type { TermCapabilities } from '../capabilities.js';
20
+ import type { PromptLibrary, PromptLibraryEntry } from '../../model/prompts/types.js';
21
+ export interface PromptPickerProps {
22
+ isActive: boolean;
23
+ library: PromptLibrary;
24
+ cols: number;
25
+ maxRows: number;
26
+ scrollOffset: number;
27
+ onScrollClamp?: (offset: number) => void;
28
+ theme: Theme;
29
+ caps: TermCapabilities;
30
+ /** `submit` is true only for `Ctrl+Enter` (see `SUBMIT_FRAMES`). */
31
+ onFill: (id: string, submit: boolean) => void;
32
+ /** `Tab` / `a`: hand over to the manager without leaving the overlay stack. */
33
+ onManage: (entry: PromptLibraryEntry) => void;
34
+ onClose: () => void;
35
+ }
36
+ export declare function PromptPicker(props: PromptPickerProps): React.ReactElement;
@@ -0,0 +1,129 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * The prompt picker: `/prompts` (quick-prompt-library §4.5).
4
+ *
5
+ * ASCII ONLY - `src/ui/**` is inside `glyphs.test.ts::inScope`.
6
+ *
7
+ * THE QUERY BOX IS THE LIST. There is no separate search field and no `/` mode: the
8
+ * picker exists for one keystroke-to-answer gesture, and an extra mode to enter is an
9
+ * extra thing that can be wrong about which component owns the next key.
10
+ *
11
+ * `Ctrl+Enter` IS RECOGNISED BY ITS BYTES, NOT BY `key.ctrl && key.return`. The stdin
12
+ * filter normalises every modified Enter (`\x1b[13;5u`, the win32 record, `\x1b[13;2u`)
13
+ * into `ENTER_NEWLINE_FRAME` before Ink sees it (enter-sequences.ts), so the parsed
14
+ * chord never occurs - a branch written that way is dead code that LOOKS implemented
15
+ * (R-11). On a terminal without keyboard enhancement the chord degrades to a plain
16
+ * `Enter`, which fills without sending; the footer therefore names `Enter fill` first.
17
+ */
18
+ import { useState } from 'react';
19
+ import { Text, useInput } from 'ink';
20
+ import { pickGlyphs } from '../glyphs.js';
21
+ import { OverlayFrame } from '../layout/OverlayFrame.js';
22
+ import { ENTER_NEWLINE_FRAME } from '../../input/limits.js';
23
+ import { PROMPT_PICKER_LIMITS } from '../../model/prompts/limits.js';
24
+ import { nextView } from '../../model/prompts/search.js';
25
+ import { stripPasteFrames } from '../paste-frames.js';
26
+ import { stripEnterFrames } from '../enter-frames.js';
27
+ import { clipProfileText, useProfileScroll } from './ModelProfilePicker.js';
28
+ import { pickerDetail, pickerDigitTarget, pickerHint, pickerRows, } from './prompt-picker-state.js';
29
+ /** Every modified Enter the stdin filter folds into its frame, plus the raw CSI-u. */
30
+ const SUBMIT_FRAMES = [ENTER_NEWLINE_FRAME, '\x1b[13;5u'];
31
+ export function PromptPicker(props) {
32
+ const { library, cols, theme, caps } = props;
33
+ const glyphs = pickGlyphs(caps);
34
+ const [query, setQuery] = useState('');
35
+ const [view, setView] = useState('manual');
36
+ // THE FOCUS IS AN ID, NOT AN INDEX (D-9's cost, paid here): both filtering and
37
+ // `Ctrl+S` can reorder the list under the cursor, and an index would silently point
38
+ // at a different prompt after either.
39
+ const [focusId, setFocusId] = useState(null);
40
+ const rows = pickerRows({ library, query, view });
41
+ const found = rows.findIndex((row) => row.id === focusId);
42
+ const cursor = rows.length === 0 ? 0 : Math.max(0, Math.min(found, rows.length - 1));
43
+ const focused = rows[cursor];
44
+ const offset = useProfileScroll(props, cursor);
45
+ const empty = library.prompts.length === 0;
46
+ const fill = (id, submit) => {
47
+ if (!id)
48
+ return;
49
+ props.onFill(id, submit);
50
+ };
51
+ useInput((input, key) => {
52
+ if (props.isActive === false)
53
+ return;
54
+ if (key.escape) {
55
+ props.onClose();
56
+ return;
57
+ }
58
+ // BEFORE `key.return`: the frame arrives with `return` false, so this branch must
59
+ // not be reachable only through the plain-Enter path.
60
+ if (SUBMIT_FRAMES.includes(input)) {
61
+ fill(focused?.id, true);
62
+ return;
63
+ }
64
+ if (key.return) {
65
+ fill(focused?.id, false);
66
+ return;
67
+ }
68
+ if (key.ctrl && (input === 's' || input === 'S')) {
69
+ setView(nextView(view));
70
+ return;
71
+ }
72
+ if (key.upArrow) {
73
+ if (rows.length === 0)
74
+ return;
75
+ setFocusId(rows[(cursor - 1 + rows.length) % rows.length].id);
76
+ return;
77
+ }
78
+ if (key.downArrow) {
79
+ if (rows.length === 0)
80
+ return;
81
+ setFocusId(rows[(cursor + 1) % rows.length].id);
82
+ return;
83
+ }
84
+ if (key.tab) {
85
+ // ONE OVERLAY STACK, NOT TWO (AC-23): the picker hands the manager an intent and
86
+ // closes, and an empty library lands straight in the editor because there is
87
+ // nothing for a list page to show.
88
+ props.onManage(empty ? { kind: 'create' } : { kind: 'list' });
89
+ return;
90
+ }
91
+ if (key.backspace || key.delete) {
92
+ setQuery((value) => [...value].slice(0, -1).join(''));
93
+ return;
94
+ }
95
+ if (key.ctrl || key.meta)
96
+ return;
97
+ const clean = stripPasteFrames(stripEnterFrames(input));
98
+ if (clean.length === 0)
99
+ return;
100
+ if (query.length === 0) {
101
+ // `1`-`9` PICK A ROW (AC-21). Only while the query is empty: otherwise the digit
102
+ // is the first character of what the user is searching for.
103
+ if (input === 'a' && empty) {
104
+ props.onManage({ kind: 'create' });
105
+ return;
106
+ }
107
+ const target = pickerDigitTarget(rows, input);
108
+ if (target !== null) {
109
+ fill(target, false);
110
+ return;
111
+ }
112
+ }
113
+ setQuery((value) => (value + clean).slice(0, PROMPT_PICKER_LIMITS.queryMaxChars));
114
+ setFocusId(null);
115
+ });
116
+ const body = [
117
+ _jsx(Text, { wrap: "truncate", color: theme.primary, children: `${glyphs.caret} ${query.length > 0 ? query : '(type to filter)'}` }, "query"),
118
+ ];
119
+ for (const [at, row] of rows.entries()) {
120
+ const isCursor = at === cursor;
121
+ const marks = `${row.favorite ? ' [fav]' : ''}${row.tags.length > 0 ? ` #${row.tags[0]}` : ''}`;
122
+ body.push(_jsx(Text, { wrap: "truncate", color: isCursor ? theme.accent : theme.muted, children: `${isCursor ? glyphs.caret : ' '} ${row.index}. `
123
+ + clipProfileText(`${row.title}${marks}`, cols - 12) }, row.id));
124
+ }
125
+ for (const [at, line] of pickerDetail(focused, library).entries()) {
126
+ body.push(_jsx(Text, { wrap: "truncate", color: theme.muted, children: clipProfileText(` ${line}`, cols - 8) }, `detail-${at}`));
127
+ }
128
+ return (_jsx(OverlayFrame, { title: `Pick a prompt (${rows.length}/${library.prompts.length})`, hint: pickerHint({ count: rows.length, query, view }), rows: body, scrollOffset: offset, onScrollClamp: props.onScrollClamp, maxRows: props.maxRows, cols: cols, theme: theme, caps: caps }));
129
+ }