openhorse 0.1.5

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 (587) hide show
  1. package/README.md +460 -0
  2. package/bin/openhorse +56 -0
  3. package/dist/agents/coder.d.ts +12 -0
  4. package/dist/agents/coder.d.ts.map +1 -0
  5. package/dist/agents/coder.js +48 -0
  6. package/dist/agents/coder.js.map +1 -0
  7. package/dist/agents/leader.d.ts +12 -0
  8. package/dist/agents/leader.d.ts.map +1 -0
  9. package/dist/agents/leader.js +49 -0
  10. package/dist/agents/leader.js.map +1 -0
  11. package/dist/agents/router.d.ts +59 -0
  12. package/dist/agents/router.d.ts.map +1 -0
  13. package/dist/agents/router.js +193 -0
  14. package/dist/agents/router.js.map +1 -0
  15. package/dist/cli-ink.d.ts +7 -0
  16. package/dist/cli-ink.d.ts.map +1 -0
  17. package/dist/cli-ink.js +135 -0
  18. package/dist/cli-ink.js.map +1 -0
  19. package/dist/cli.d.ts +7 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +638 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/commands/index.d.ts +12 -0
  24. package/dist/commands/index.d.ts.map +1 -0
  25. package/dist/commands/index.js +1095 -0
  26. package/dist/commands/index.js.map +1 -0
  27. package/dist/commands/parser.d.ts +26 -0
  28. package/dist/commands/parser.d.ts.map +1 -0
  29. package/dist/commands/parser.js +61 -0
  30. package/dist/commands/parser.js.map +1 -0
  31. package/dist/commands/types.d.ts +61 -0
  32. package/dist/commands/types.d.ts.map +1 -0
  33. package/dist/commands/types.js +32 -0
  34. package/dist/commands/types.js.map +1 -0
  35. package/dist/core/agent.d.ts +66 -0
  36. package/dist/core/agent.d.ts.map +1 -0
  37. package/dist/core/agent.js +55 -0
  38. package/dist/core/agent.js.map +1 -0
  39. package/dist/core/brain.d.ts +41 -0
  40. package/dist/core/brain.d.ts.map +1 -0
  41. package/dist/core/brain.js +92 -0
  42. package/dist/core/brain.js.map +1 -0
  43. package/dist/core/cost-tracker.d.ts +107 -0
  44. package/dist/core/cost-tracker.d.ts.map +1 -0
  45. package/dist/core/cost-tracker.js +199 -0
  46. package/dist/core/cost-tracker.js.map +1 -0
  47. package/dist/core/strategy-tracker.d.ts +61 -0
  48. package/dist/core/strategy-tracker.d.ts.map +1 -0
  49. package/dist/core/strategy-tracker.js +124 -0
  50. package/dist/core/strategy-tracker.js.map +1 -0
  51. package/dist/framework/index.d.ts +20 -0
  52. package/dist/framework/index.d.ts.map +1 -0
  53. package/dist/framework/index.js +29 -0
  54. package/dist/framework/index.js.map +1 -0
  55. package/dist/framework/prompt.d.ts +40 -0
  56. package/dist/framework/prompt.d.ts.map +1 -0
  57. package/dist/framework/prompt.js +112 -0
  58. package/dist/framework/prompt.js.map +1 -0
  59. package/dist/framework/query.d.ts +86 -0
  60. package/dist/framework/query.d.ts.map +1 -0
  61. package/dist/framework/query.js +177 -0
  62. package/dist/framework/query.js.map +1 -0
  63. package/dist/framework/store.d.ts +64 -0
  64. package/dist/framework/store.d.ts.map +1 -0
  65. package/dist/framework/store.js +78 -0
  66. package/dist/framework/store.js.map +1 -0
  67. package/dist/framework/tool-state.d.ts +22 -0
  68. package/dist/framework/tool-state.d.ts.map +1 -0
  69. package/dist/framework/tool-state.js +40 -0
  70. package/dist/framework/tool-state.js.map +1 -0
  71. package/dist/framework/tool.d.ts +88 -0
  72. package/dist/framework/tool.d.ts.map +1 -0
  73. package/dist/framework/tool.js +60 -0
  74. package/dist/framework/tool.js.map +1 -0
  75. package/dist/harness/harness.d.ts +96 -0
  76. package/dist/harness/harness.d.ts.map +1 -0
  77. package/dist/harness/harness.js +224 -0
  78. package/dist/harness/harness.js.map +1 -0
  79. package/dist/harness/safety.d.ts +89 -0
  80. package/dist/harness/safety.d.ts.map +1 -0
  81. package/dist/harness/safety.js +178 -0
  82. package/dist/harness/safety.js.map +1 -0
  83. package/dist/index.d.ts +30 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +57 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/init.d.ts +178 -0
  88. package/dist/init.d.ts.map +1 -0
  89. package/dist/init.js +473 -0
  90. package/dist/init.js.map +1 -0
  91. package/dist/ink/bidi.d.ts +16 -0
  92. package/dist/ink/bidi.d.ts.map +1 -0
  93. package/dist/ink/bidi.js +124 -0
  94. package/dist/ink/bidi.js.map +1 -0
  95. package/dist/ink/clearTerminal.d.ts +14 -0
  96. package/dist/ink/clearTerminal.d.ts.map +1 -0
  97. package/dist/ink/clearTerminal.js +63 -0
  98. package/dist/ink/clearTerminal.js.map +1 -0
  99. package/dist/ink/colorize.d.ts +17 -0
  100. package/dist/ink/colorize.d.ts.map +1 -0
  101. package/dist/ink/colorize.js +208 -0
  102. package/dist/ink/colorize.js.map +1 -0
  103. package/dist/ink/components/App.d.ts +73 -0
  104. package/dist/ink/components/App.d.ts.map +1 -0
  105. package/dist/ink/components/App.js +646 -0
  106. package/dist/ink/components/App.js.map +1 -0
  107. package/dist/ink/components/AppContext.d.ts +12 -0
  108. package/dist/ink/components/AppContext.d.ts.map +1 -0
  109. package/dist/ink/components/AppContext.js +14 -0
  110. package/dist/ink/components/AppContext.js.map +1 -0
  111. package/dist/ink/components/Box.d.ts +44 -0
  112. package/dist/ink/components/Box.d.ts.map +1 -0
  113. package/dist/ink/components/Box.js +191 -0
  114. package/dist/ink/components/Box.js.map +1 -0
  115. package/dist/ink/components/ClockContext.d.ts +9 -0
  116. package/dist/ink/components/ClockContext.d.ts.map +1 -0
  117. package/dist/ink/components/ClockContext.js +146 -0
  118. package/dist/ink/components/ClockContext.js.map +1 -0
  119. package/dist/ink/components/CursorDeclarationContext.d.ts +23 -0
  120. package/dist/ink/components/CursorDeclarationContext.d.ts.map +1 -0
  121. package/dist/ink/components/CursorDeclarationContext.js +6 -0
  122. package/dist/ink/components/CursorDeclarationContext.js.map +1 -0
  123. package/dist/ink/components/ErrorOverview.d.ts +6 -0
  124. package/dist/ink/components/ErrorOverview.d.ts.map +1 -0
  125. package/dist/ink/components/ErrorOverview.js +27 -0
  126. package/dist/ink/components/ErrorOverview.js.map +1 -0
  127. package/dist/ink/components/Newline.d.ts +13 -0
  128. package/dist/ink/components/Newline.d.ts.map +1 -0
  129. package/dist/ink/components/Newline.js +36 -0
  130. package/dist/ink/components/Newline.js.map +1 -0
  131. package/dist/ink/components/NoSelect.d.ts +20 -0
  132. package/dist/ink/components/NoSelect.d.ts.map +1 -0
  133. package/dist/ink/components/NoSelect.js +63 -0
  134. package/dist/ink/components/NoSelect.js.map +1 -0
  135. package/dist/ink/components/RawAnsi.d.ts +17 -0
  136. package/dist/ink/components/RawAnsi.d.ts.map +1 -0
  137. package/dist/ink/components/RawAnsi.js +52 -0
  138. package/dist/ink/components/RawAnsi.js.map +1 -0
  139. package/dist/ink/components/Spacer.d.ts +6 -0
  140. package/dist/ink/components/Spacer.d.ts.map +1 -0
  141. package/dist/ink/components/Spacer.js +26 -0
  142. package/dist/ink/components/Spacer.js.map +1 -0
  143. package/dist/ink/components/StdinContext.d.ts +28 -0
  144. package/dist/ink/components/StdinContext.d.ts.map +1 -0
  145. package/dist/ink/components/StdinContext.js +19 -0
  146. package/dist/ink/components/StdinContext.js.map +1 -0
  147. package/dist/ink/components/TerminalFocusContext.d.ts +10 -0
  148. package/dist/ink/components/TerminalFocusContext.d.ts.map +1 -0
  149. package/dist/ink/components/TerminalFocusContext.js +81 -0
  150. package/dist/ink/components/TerminalFocusContext.js.map +1 -0
  151. package/dist/ink/components/TerminalSizeContext.d.ts +6 -0
  152. package/dist/ink/components/TerminalSizeContext.d.ts.map +1 -0
  153. package/dist/ink/components/TerminalSizeContext.js +6 -0
  154. package/dist/ink/components/TerminalSizeContext.js.map +1 -0
  155. package/dist/ink/components/Text.d.ts +56 -0
  156. package/dist/ink/components/Text.d.ts.map +1 -0
  157. package/dist/ink/components/Text.js +201 -0
  158. package/dist/ink/components/Text.js.map +1 -0
  159. package/dist/ink/constants.d.ts +2 -0
  160. package/dist/ink/constants.d.ts.map +1 -0
  161. package/dist/ink/constants.js +6 -0
  162. package/dist/ink/constants.js.map +1 -0
  163. package/dist/ink/devtools.d.ts +3 -0
  164. package/dist/ink/devtools.d.ts.map +1 -0
  165. package/dist/ink/devtools.js +5 -0
  166. package/dist/ink/devtools.js.map +1 -0
  167. package/dist/ink/dom.d.ts +77 -0
  168. package/dist/ink/dom.d.ts.map +1 -0
  169. package/dist/ink/dom.js +322 -0
  170. package/dist/ink/dom.js.map +1 -0
  171. package/dist/ink/events/click-event.d.ts +32 -0
  172. package/dist/ink/events/click-event.d.ts.map +1 -0
  173. package/dist/ink/events/click-event.js +30 -0
  174. package/dist/ink/events/click-event.js.map +1 -0
  175. package/dist/ink/events/dispatcher.d.ts +41 -0
  176. package/dist/ink/events/dispatcher.d.ts.map +1 -0
  177. package/dist/ink/events/dispatcher.js +181 -0
  178. package/dist/ink/events/dispatcher.js.map +1 -0
  179. package/dist/ink/events/emitter.d.ts +6 -0
  180. package/dist/ink/events/emitter.d.ts.map +1 -0
  181. package/dist/ink/events/emitter.js +36 -0
  182. package/dist/ink/events/emitter.js.map +1 -0
  183. package/dist/ink/events/event-handlers.d.ts +47 -0
  184. package/dist/ink/events/event-handlers.d.ts.map +1 -0
  185. package/dist/ink/events/event-handlers.js +34 -0
  186. package/dist/ink/events/event-handlers.js.map +1 -0
  187. package/dist/ink/events/event.d.ts +6 -0
  188. package/dist/ink/events/event.d.ts.map +1 -0
  189. package/dist/ink/events/event.js +16 -0
  190. package/dist/ink/events/event.js.map +1 -0
  191. package/dist/ink/events/focus-event.d.ts +14 -0
  192. package/dist/ink/events/focus-event.d.ts.map +1 -0
  193. package/dist/ink/events/focus-event.js +20 -0
  194. package/dist/ink/events/focus-event.js.map +1 -0
  195. package/dist/ink/events/input-event.d.ts +31 -0
  196. package/dist/ink/events/input-event.d.ts.map +1 -0
  197. package/dist/ink/events/input-event.js +163 -0
  198. package/dist/ink/events/input-event.js.map +1 -0
  199. package/dist/ink/events/keyboard-event.d.ts +20 -0
  200. package/dist/ink/events/keyboard-event.d.ts.map +1 -0
  201. package/dist/ink/events/keyboard-event.js +44 -0
  202. package/dist/ink/events/keyboard-event.js.map +1 -0
  203. package/dist/ink/events/terminal-event.d.ts +55 -0
  204. package/dist/ink/events/terminal-event.d.ts.map +1 -0
  205. package/dist/ink/events/terminal-event.js +79 -0
  206. package/dist/ink/events/terminal-event.js.map +1 -0
  207. package/dist/ink/events/terminal-focus-event.d.ts +14 -0
  208. package/dist/ink/events/terminal-focus-event.d.ts.map +1 -0
  209. package/dist/ink/events/terminal-focus-event.js +19 -0
  210. package/dist/ink/events/terminal-focus-event.js.map +1 -0
  211. package/dist/ink/focus.d.ts +44 -0
  212. package/dist/ink/focus.d.ts.map +1 -0
  213. package/dist/ink/focus.js +164 -0
  214. package/dist/ink/focus.js.map +1 -0
  215. package/dist/ink/frame.d.ts +95 -0
  216. package/dist/ink/frame.d.ts.map +1 -0
  217. package/dist/ink/frame.js +35 -0
  218. package/dist/ink/frame.js.map +1 -0
  219. package/dist/ink/get-max-width.d.ts +18 -0
  220. package/dist/ink/get-max-width.d.ts.map +1 -0
  221. package/dist/ink/get-max-width.js +26 -0
  222. package/dist/ink/get-max-width.js.map +1 -0
  223. package/dist/ink/hit-test.d.ts +34 -0
  224. package/dist/ink/hit-test.d.ts.map +1 -0
  225. package/dist/ink/hit-test.js +119 -0
  226. package/dist/ink/hit-test.js.map +1 -0
  227. package/dist/ink/hooks/use-animation-frame.d.ts +27 -0
  228. package/dist/ink/hooks/use-animation-frame.d.ts.map +1 -0
  229. package/dist/ink/hooks/use-animation-frame.js +52 -0
  230. package/dist/ink/hooks/use-animation-frame.js.map +1 -0
  231. package/dist/ink/hooks/use-app.d.ts +6 -0
  232. package/dist/ink/hooks/use-app.d.ts.map +1 -0
  233. package/dist/ink/hooks/use-app.js +13 -0
  234. package/dist/ink/hooks/use-app.js.map +1 -0
  235. package/dist/ink/hooks/use-declared-cursor.d.ts +27 -0
  236. package/dist/ink/hooks/use-declared-cursor.d.ts.map +1 -0
  237. package/dist/ink/hooks/use-declared-cursor.js +67 -0
  238. package/dist/ink/hooks/use-declared-cursor.js.map +1 -0
  239. package/dist/ink/hooks/use-input.d.ts +38 -0
  240. package/dist/ink/hooks/use-input.d.ts.map +1 -0
  241. package/dist/ink/hooks/use-input.js +86 -0
  242. package/dist/ink/hooks/use-input.js.map +1 -0
  243. package/dist/ink/hooks/use-interval.d.ts +19 -0
  244. package/dist/ink/hooks/use-interval.d.ts.map +1 -0
  245. package/dist/ink/hooks/use-interval.js +59 -0
  246. package/dist/ink/hooks/use-interval.js.map +1 -0
  247. package/dist/ink/hooks/use-search-highlight.d.ts +31 -0
  248. package/dist/ink/hooks/use-search-highlight.d.ts.map +1 -0
  249. package/dist/ink/hooks/use-search-highlight.js +39 -0
  250. package/dist/ink/hooks/use-search-highlight.js.map +1 -0
  251. package/dist/ink/hooks/use-selection.d.ts +40 -0
  252. package/dist/ink/hooks/use-selection.d.ts.map +1 -0
  253. package/dist/ink/hooks/use-selection.js +68 -0
  254. package/dist/ink/hooks/use-selection.js.map +1 -0
  255. package/dist/ink/hooks/use-stdin.d.ts +6 -0
  256. package/dist/ink/hooks/use-stdin.d.ts.map +1 -0
  257. package/dist/ink/hooks/use-stdin.js +13 -0
  258. package/dist/ink/hooks/use-stdin.js.map +1 -0
  259. package/dist/ink/hooks/use-tab-status.d.ts +14 -0
  260. package/dist/ink/hooks/use-tab-status.d.ts.map +1 -0
  261. package/dist/ink/hooks/use-tab-status.js +61 -0
  262. package/dist/ink/hooks/use-tab-status.js.map +1 -0
  263. package/dist/ink/hooks/use-terminal-focus.d.ts +11 -0
  264. package/dist/ink/hooks/use-terminal-focus.d.ts.map +1 -0
  265. package/dist/ink/hooks/use-terminal-focus.js +22 -0
  266. package/dist/ink/hooks/use-terminal-focus.js.map +1 -0
  267. package/dist/ink/hooks/use-terminal-title.d.ts +13 -0
  268. package/dist/ink/hooks/use-terminal-title.d.ts.map +1 -0
  269. package/dist/ink/hooks/use-terminal-title.js +36 -0
  270. package/dist/ink/hooks/use-terminal-title.js.map +1 -0
  271. package/dist/ink/hooks/use-terminal-viewport.d.ts +30 -0
  272. package/dist/ink/hooks/use-terminal-viewport.d.ts.map +1 -0
  273. package/dist/ink/hooks/use-terminal-viewport.js +81 -0
  274. package/dist/ink/hooks/use-terminal-viewport.js.map +1 -0
  275. package/dist/ink/index.d.ts +54 -0
  276. package/dist/ink/index.d.ts.map +1 -0
  277. package/dist/ink/index.js +111 -0
  278. package/dist/ink/index.js.map +1 -0
  279. package/dist/ink/ink.d.ts +371 -0
  280. package/dist/ink/ink.d.ts.map +1 -0
  281. package/dist/ink/ink.js +1686 -0
  282. package/dist/ink/ink.js.map +1 -0
  283. package/dist/ink/instances.d.ts +4 -0
  284. package/dist/ink/instances.d.ts.map +1 -0
  285. package/dist/ink/instances.js +10 -0
  286. package/dist/ink/instances.js.map +1 -0
  287. package/dist/ink/line-width-cache.d.ts +2 -0
  288. package/dist/ink/line-width-cache.d.ts.map +1 -0
  289. package/dist/ink/line-width-cache.js +23 -0
  290. package/dist/ink/line-width-cache.js.map +1 -0
  291. package/dist/ink/log-update.d.ts +18 -0
  292. package/dist/ink/log-update.d.ts.map +1 -0
  293. package/dist/ink/log-update.js +637 -0
  294. package/dist/ink/log-update.js.map +1 -0
  295. package/dist/ink/measure-element.d.ts +17 -0
  296. package/dist/ink/measure-element.d.ts.map +1 -0
  297. package/dist/ink/measure-element.js +11 -0
  298. package/dist/ink/measure-element.js.map +1 -0
  299. package/dist/ink/measure-text.d.ts +7 -0
  300. package/dist/ink/measure-text.d.ts.map +1 -0
  301. package/dist/ink/measure-text.js +38 -0
  302. package/dist/ink/measure-text.js.map +1 -0
  303. package/dist/ink/node-cache.d.ts +21 -0
  304. package/dist/ink/node-cache.d.ts.map +1 -0
  305. package/dist/ink/node-cache.js +36 -0
  306. package/dist/ink/node-cache.js.map +1 -0
  307. package/dist/ink/optimizer.d.ts +16 -0
  308. package/dist/ink/optimizer.d.ts.map +1 -0
  309. package/dist/ink/optimizer.js +85 -0
  310. package/dist/ink/optimizer.js.map +1 -0
  311. package/dist/ink/output.d.ts +120 -0
  312. package/dist/ink/output.d.ts.map +1 -0
  313. package/dist/ink/output.js +559 -0
  314. package/dist/ink/output.js.map +1 -0
  315. package/dist/ink/parse-keypress.d.ts +112 -0
  316. package/dist/ink/parse-keypress.d.ts.map +1 -0
  317. package/dist/ink/parse-keypress.js +719 -0
  318. package/dist/ink/parse-keypress.js.map +1 -0
  319. package/dist/ink/parse-keypress.test.d.ts +2 -0
  320. package/dist/ink/parse-keypress.test.d.ts.map +1 -0
  321. package/dist/ink/parse-keypress.test.js +37 -0
  322. package/dist/ink/parse-keypress.test.js.map +1 -0
  323. package/dist/ink/reconciler.d.ts +12 -0
  324. package/dist/ink/reconciler.d.ts.map +1 -0
  325. package/dist/ink/reconciler.js +456 -0
  326. package/dist/ink/reconciler.js.map +1 -0
  327. package/dist/ink/render-border.d.ts +25 -0
  328. package/dist/ink/render-border.d.ts.map +1 -0
  329. package/dist/ink/render-border.js +141 -0
  330. package/dist/ink/render-border.js.map +1 -0
  331. package/dist/ink/render-node-to-output.d.ts +46 -0
  332. package/dist/ink/render-node-to-output.d.ts.map +1 -0
  333. package/dist/ink/render-node-to-output.js +1257 -0
  334. package/dist/ink/render-node-to-output.js.map +1 -0
  335. package/dist/ink/render-to-screen.d.ts +47 -0
  336. package/dist/ink/render-to-screen.d.ts.map +1 -0
  337. package/dist/ink/render-to-screen.js +213 -0
  338. package/dist/ink/render-to-screen.js.map +1 -0
  339. package/dist/ink/renderer.d.ts +15 -0
  340. package/dist/ink/renderer.d.ts.map +1 -0
  341. package/dist/ink/renderer.js +169 -0
  342. package/dist/ink/renderer.js.map +1 -0
  343. package/dist/ink/root.d.ts +75 -0
  344. package/dist/ink/root.d.ts.map +1 -0
  345. package/dist/ink/root.js +89 -0
  346. package/dist/ink/root.js.map +1 -0
  347. package/dist/ink/screen.d.ts +270 -0
  348. package/dist/ink/screen.d.ts.map +1 -0
  349. package/dist/ink/screen.js +1194 -0
  350. package/dist/ink/screen.js.map +1 -0
  351. package/dist/ink/searchHighlight.d.ts +21 -0
  352. package/dist/ink/searchHighlight.d.ts.map +1 -0
  353. package/dist/ink/searchHighlight.js +82 -0
  354. package/dist/ink/searchHighlight.js.map +1 -0
  355. package/dist/ink/selection.d.ts +230 -0
  356. package/dist/ink/selection.d.ts.map +1 -0
  357. package/dist/ink/selection.js +814 -0
  358. package/dist/ink/selection.js.map +1 -0
  359. package/dist/ink/squash-text-nodes.d.ts +23 -0
  360. package/dist/ink/squash-text-nodes.d.ts.map +1 -0
  361. package/dist/ink/squash-text-nodes.js +60 -0
  362. package/dist/ink/squash-text-nodes.js.map +1 -0
  363. package/dist/ink/stringWidth.d.ts +2 -0
  364. package/dist/ink/stringWidth.d.ts.map +1 -0
  365. package/dist/ink/stringWidth.js +207 -0
  366. package/dist/ink/stringWidth.js.map +1 -0
  367. package/dist/ink/styles.d.ts +307 -0
  368. package/dist/ink/styles.d.ts.map +1 -0
  369. package/dist/ink/styles.js +302 -0
  370. package/dist/ink/styles.js.map +1 -0
  371. package/dist/ink/supports-hyperlinks.d.ts +14 -0
  372. package/dist/ink/supports-hyperlinks.d.ts.map +1 -0
  373. package/dist/ink/supports-hyperlinks.js +48 -0
  374. package/dist/ink/supports-hyperlinks.js.map +1 -0
  375. package/dist/ink/tabstops.d.ts +2 -0
  376. package/dist/ink/tabstops.d.ts.map +1 -0
  377. package/dist/ink/tabstops.js +43 -0
  378. package/dist/ink/tabstops.js.map +1 -0
  379. package/dist/ink/terminal-focus-state.d.ts +7 -0
  380. package/dist/ink/terminal-focus-state.d.ts.map +1 -0
  381. package/dist/ink/terminal-focus-state.js +43 -0
  382. package/dist/ink/terminal-focus-state.js.map +1 -0
  383. package/dist/ink/terminal-querier.d.ts +130 -0
  384. package/dist/ink/terminal-querier.d.ts.map +1 -0
  385. package/dist/ink/terminal-querier.js +184 -0
  386. package/dist/ink/terminal-querier.js.map +1 -0
  387. package/dist/ink/terminal.d.ts +56 -0
  388. package/dist/ink/terminal.d.ts.map +1 -0
  389. package/dist/ink/terminal.js +249 -0
  390. package/dist/ink/terminal.js.map +1 -0
  391. package/dist/ink/termio/csi.d.ts +166 -0
  392. package/dist/ink/termio/csi.d.ts.map +1 -0
  393. package/dist/ink/termio/csi.js +285 -0
  394. package/dist/ink/termio/csi.js.map +1 -0
  395. package/dist/ink/termio/dec.d.ts +38 -0
  396. package/dist/ink/termio/dec.d.ts.map +1 -0
  397. package/dist/ink/termio/dec.js +59 -0
  398. package/dist/ink/termio/dec.js.map +1 -0
  399. package/dist/ink/termio.d.ts +25 -0
  400. package/dist/ink/termio.d.ts.map +1 -0
  401. package/dist/ink/termio.js +32 -0
  402. package/dist/ink/termio.js.map +1 -0
  403. package/dist/ink/useTerminalNotification.d.ts +27 -0
  404. package/dist/ink/useTerminalNotification.d.ts.map +1 -0
  405. package/dist/ink/useTerminalNotification.js +62 -0
  406. package/dist/ink/useTerminalNotification.js.map +1 -0
  407. package/dist/ink/warn.d.ts +2 -0
  408. package/dist/ink/warn.d.ts.map +1 -0
  409. package/dist/ink/warn.js +14 -0
  410. package/dist/ink/warn.js.map +1 -0
  411. package/dist/ink/widest-line.d.ts +2 -0
  412. package/dist/ink/widest-line.d.ts.map +1 -0
  413. package/dist/ink/widest-line.js +18 -0
  414. package/dist/ink/widest-line.js.map +1 -0
  415. package/dist/ink/wrap-text.d.ts +3 -0
  416. package/dist/ink/wrap-text.d.ts.map +1 -0
  417. package/dist/ink/wrap-text.js +61 -0
  418. package/dist/ink/wrap-text.js.map +1 -0
  419. package/dist/ink/wrapAnsi.d.ts +8 -0
  420. package/dist/ink/wrapAnsi.d.ts.map +1 -0
  421. package/dist/ink/wrapAnsi.js +13 -0
  422. package/dist/ink/wrapAnsi.js.map +1 -0
  423. package/dist/memory/embeddings.d.ts +33 -0
  424. package/dist/memory/embeddings.d.ts.map +1 -0
  425. package/dist/memory/embeddings.js +123 -0
  426. package/dist/memory/embeddings.js.map +1 -0
  427. package/dist/memory/index.d.ts +14 -0
  428. package/dist/memory/index.d.ts.map +1 -0
  429. package/dist/memory/index.js +31 -0
  430. package/dist/memory/index.js.map +1 -0
  431. package/dist/memory/prompts.d.ts +12 -0
  432. package/dist/memory/prompts.d.ts.map +1 -0
  433. package/dist/memory/prompts.js +117 -0
  434. package/dist/memory/prompts.js.map +1 -0
  435. package/dist/memory/semantic-search.d.ts +45 -0
  436. package/dist/memory/semantic-search.d.ts.map +1 -0
  437. package/dist/memory/semantic-search.js +112 -0
  438. package/dist/memory/semantic-search.js.map +1 -0
  439. package/dist/memory/storage.d.ts +79 -0
  440. package/dist/memory/storage.d.ts.map +1 -0
  441. package/dist/memory/storage.js +285 -0
  442. package/dist/memory/storage.js.map +1 -0
  443. package/dist/memory/store.d.ts +103 -0
  444. package/dist/memory/store.d.ts.map +1 -0
  445. package/dist/memory/store.js +226 -0
  446. package/dist/memory/store.js.map +1 -0
  447. package/dist/memory/types.d.ts +40 -0
  448. package/dist/memory/types.d.ts.map +1 -0
  449. package/dist/memory/types.js +71 -0
  450. package/dist/memory/types.js.map +1 -0
  451. package/dist/memory/validation.d.ts +28 -0
  452. package/dist/memory/validation.d.ts.map +1 -0
  453. package/dist/memory/validation.js +147 -0
  454. package/dist/memory/validation.js.map +1 -0
  455. package/dist/memory/vector-store.d.ts +49 -0
  456. package/dist/memory/vector-store.d.ts.map +1 -0
  457. package/dist/memory/vector-store.js +259 -0
  458. package/dist/memory/vector-store.js.map +1 -0
  459. package/dist/screens/REPL.d.ts +21 -0
  460. package/dist/screens/REPL.d.ts.map +1 -0
  461. package/dist/screens/REPL.js +139 -0
  462. package/dist/screens/REPL.js.map +1 -0
  463. package/dist/services/agent-runner.d.ts +68 -0
  464. package/dist/services/agent-runner.d.ts.map +1 -0
  465. package/dist/services/agent-runner.js +186 -0
  466. package/dist/services/agent-runner.js.map +1 -0
  467. package/dist/services/atomic-write.d.ts +12 -0
  468. package/dist/services/atomic-write.d.ts.map +1 -0
  469. package/dist/services/atomic-write.js +27 -0
  470. package/dist/services/atomic-write.js.map +1 -0
  471. package/dist/services/config-dir.d.ts +55 -0
  472. package/dist/services/config-dir.d.ts.map +1 -0
  473. package/dist/services/config-dir.js +136 -0
  474. package/dist/services/config-dir.js.map +1 -0
  475. package/dist/services/config.d.ts +54 -0
  476. package/dist/services/config.d.ts.map +1 -0
  477. package/dist/services/config.js +98 -0
  478. package/dist/services/config.js.map +1 -0
  479. package/dist/services/file-glob.d.ts +26 -0
  480. package/dist/services/file-glob.d.ts.map +1 -0
  481. package/dist/services/file-glob.js +134 -0
  482. package/dist/services/file-glob.js.map +1 -0
  483. package/dist/services/global-config.d.ts +109 -0
  484. package/dist/services/global-config.d.ts.map +1 -0
  485. package/dist/services/global-config.js +211 -0
  486. package/dist/services/global-config.js.map +1 -0
  487. package/dist/services/llm.d.ts +139 -0
  488. package/dist/services/llm.d.ts.map +1 -0
  489. package/dist/services/llm.js +376 -0
  490. package/dist/services/llm.js.map +1 -0
  491. package/dist/services/memory.d.ts +39 -0
  492. package/dist/services/memory.d.ts.map +1 -0
  493. package/dist/services/memory.js +88 -0
  494. package/dist/services/memory.js.map +1 -0
  495. package/dist/services/session-storage.d.ts +136 -0
  496. package/dist/services/session-storage.d.ts.map +1 -0
  497. package/dist/services/session-storage.js +304 -0
  498. package/dist/services/session-storage.js.map +1 -0
  499. package/dist/services/task-manager.d.ts +154 -0
  500. package/dist/services/task-manager.d.ts.map +1 -0
  501. package/dist/services/task-manager.js +288 -0
  502. package/dist/services/task-manager.js.map +1 -0
  503. package/dist/services/yaml-config.d.ts +57 -0
  504. package/dist/services/yaml-config.d.ts.map +1 -0
  505. package/dist/services/yaml-config.js +176 -0
  506. package/dist/services/yaml-config.js.map +1 -0
  507. package/dist/skills/discovery.d.ts +22 -0
  508. package/dist/skills/discovery.d.ts.map +1 -0
  509. package/dist/skills/discovery.js +75 -0
  510. package/dist/skills/discovery.js.map +1 -0
  511. package/dist/skills/index.d.ts +10 -0
  512. package/dist/skills/index.d.ts.map +1 -0
  513. package/dist/skills/index.js +26 -0
  514. package/dist/skills/index.js.map +1 -0
  515. package/dist/skills/loader.d.ts +48 -0
  516. package/dist/skills/loader.d.ts.map +1 -0
  517. package/dist/skills/loader.js +231 -0
  518. package/dist/skills/loader.js.map +1 -0
  519. package/dist/skills/registry.d.ts +37 -0
  520. package/dist/skills/registry.d.ts.map +1 -0
  521. package/dist/skills/registry.js +134 -0
  522. package/dist/skills/registry.js.map +1 -0
  523. package/dist/skills/types.d.ts +89 -0
  524. package/dist/skills/types.d.ts.map +1 -0
  525. package/dist/skills/types.js +24 -0
  526. package/dist/skills/types.js.map +1 -0
  527. package/dist/tools/bash_security.d.ts +64 -0
  528. package/dist/tools/bash_security.d.ts.map +1 -0
  529. package/dist/tools/bash_security.js +291 -0
  530. package/dist/tools/bash_security.js.map +1 -0
  531. package/dist/tools/index.d.ts +23 -0
  532. package/dist/tools/index.d.ts.map +1 -0
  533. package/dist/tools/index.js +965 -0
  534. package/dist/tools/index.js.map +1 -0
  535. package/dist/tools/mcp.d.ts +72 -0
  536. package/dist/tools/mcp.d.ts.map +1 -0
  537. package/dist/tools/mcp.js +422 -0
  538. package/dist/tools/mcp.js.map +1 -0
  539. package/dist/tools/plan.d.ts +18 -0
  540. package/dist/tools/plan.d.ts.map +1 -0
  541. package/dist/tools/plan.js +75 -0
  542. package/dist/tools/plan.js.map +1 -0
  543. package/dist/tools/todo.d.ts +18 -0
  544. package/dist/tools/todo.d.ts.map +1 -0
  545. package/dist/tools/todo.js +153 -0
  546. package/dist/tools/todo.js.map +1 -0
  547. package/dist/tools/web.d.ts +13 -0
  548. package/dist/tools/web.d.ts.map +1 -0
  549. package/dist/tools/web.js +377 -0
  550. package/dist/tools/web.js.map +1 -0
  551. package/dist/ui/box.d.ts +56 -0
  552. package/dist/ui/box.d.ts.map +1 -0
  553. package/dist/ui/box.js +241 -0
  554. package/dist/ui/box.js.map +1 -0
  555. package/dist/ui/command-panel.d.ts +55 -0
  556. package/dist/ui/command-panel.d.ts.map +1 -0
  557. package/dist/ui/command-panel.js +212 -0
  558. package/dist/ui/command-panel.js.map +1 -0
  559. package/dist/ui/file-completion.d.ts +62 -0
  560. package/dist/ui/file-completion.d.ts.map +1 -0
  561. package/dist/ui/file-completion.js +209 -0
  562. package/dist/ui/file-completion.js.map +1 -0
  563. package/dist/ui/markdown.d.ts +12 -0
  564. package/dist/ui/markdown.d.ts.map +1 -0
  565. package/dist/ui/markdown.js +215 -0
  566. package/dist/ui/markdown.js.map +1 -0
  567. package/dist/ui/multiline-input.d.ts +47 -0
  568. package/dist/ui/multiline-input.d.ts.map +1 -0
  569. package/dist/ui/multiline-input.js +94 -0
  570. package/dist/ui/multiline-input.js.map +1 -0
  571. package/dist/ui/status-bar.d.ts +33 -0
  572. package/dist/ui/status-bar.d.ts.map +1 -0
  573. package/dist/ui/status-bar.js +96 -0
  574. package/dist/ui/status-bar.js.map +1 -0
  575. package/dist/ui/stream-markdown.d.ts +35 -0
  576. package/dist/ui/stream-markdown.d.ts.map +1 -0
  577. package/dist/ui/stream-markdown.js +138 -0
  578. package/dist/ui/stream-markdown.js.map +1 -0
  579. package/dist/ui/suggestions.d.ts +35 -0
  580. package/dist/ui/suggestions.d.ts.map +1 -0
  581. package/dist/ui/suggestions.js +118 -0
  582. package/dist/ui/suggestions.js.map +1 -0
  583. package/dist/ui/tool-preview.d.ts +34 -0
  584. package/dist/ui/tool-preview.d.ts.map +1 -0
  585. package/dist/ui/tool-preview.js +128 -0
  586. package/dist/ui/tool-preview.js.map +1 -0
  587. package/package.json +93 -0
@@ -0,0 +1,637 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogUpdate = void 0;
4
+ const ansi_tokenize_1 = require("@alcalzone/ansi-tokenize");
5
+ const debug_js_1 = require("../utils/debug.js");
6
+ const screen_js_1 = require("./screen.js");
7
+ const csi_js_1 = require("./termio/csi.js");
8
+ const osc_js_1 = require("./termio/osc.js");
9
+ const CARRIAGE_RETURN = { type: 'carriageReturn' };
10
+ const NEWLINE = { type: 'stdout', content: '\n' };
11
+ class LogUpdate {
12
+ constructor(options) {
13
+ this.options = options;
14
+ this.state = {
15
+ previousOutput: '',
16
+ };
17
+ }
18
+ renderPreviousOutput_DEPRECATED(prevFrame) {
19
+ if (!this.options.isTTY) {
20
+ // Non-TTY output is no longer supported (string output was removed)
21
+ return [NEWLINE];
22
+ }
23
+ return this.getRenderOpsForDone(prevFrame);
24
+ }
25
+ // Called when process resumes from suspension (SIGCONT) to prevent clobbering terminal content
26
+ reset() {
27
+ this.state.previousOutput = '';
28
+ }
29
+ renderFullFrame(frame) {
30
+ const { screen } = frame;
31
+ const lines = [];
32
+ let currentStyles = [];
33
+ let currentHyperlink = undefined;
34
+ for (let y = 0; y < screen.height; y++) {
35
+ let line = '';
36
+ for (let x = 0; x < screen.width; x++) {
37
+ const cell = (0, screen_js_1.cellAt)(screen, x, y);
38
+ if (cell && cell.width !== 2 /* CellWidth.SpacerTail */) {
39
+ // Handle hyperlink transitions
40
+ if (cell.hyperlink !== currentHyperlink) {
41
+ if (currentHyperlink !== undefined) {
42
+ line += osc_js_1.LINK_END;
43
+ }
44
+ if (cell.hyperlink !== undefined) {
45
+ line += (0, osc_js_1.link)(cell.hyperlink);
46
+ }
47
+ currentHyperlink = cell.hyperlink;
48
+ }
49
+ const cellStyles = this.options.stylePool.get(cell.styleId);
50
+ const styleDiff = (0, ansi_tokenize_1.diffAnsiCodes)(currentStyles, cellStyles);
51
+ if (styleDiff.length > 0) {
52
+ line += (0, ansi_tokenize_1.ansiCodesToString)(styleDiff);
53
+ currentStyles = cellStyles;
54
+ }
55
+ line += cell.char;
56
+ }
57
+ }
58
+ // Close any open hyperlink before resetting styles
59
+ if (currentHyperlink !== undefined) {
60
+ line += osc_js_1.LINK_END;
61
+ currentHyperlink = undefined;
62
+ }
63
+ // Reset styles at end of line so trimEnd doesn't leave dangling codes
64
+ const resetCodes = (0, ansi_tokenize_1.diffAnsiCodes)(currentStyles, []);
65
+ if (resetCodes.length > 0) {
66
+ line += (0, ansi_tokenize_1.ansiCodesToString)(resetCodes);
67
+ currentStyles = [];
68
+ }
69
+ lines.push(line.trimEnd());
70
+ }
71
+ if (lines.length === 0) {
72
+ return [];
73
+ }
74
+ return [{ type: 'stdout', content: lines.join('\n') }];
75
+ }
76
+ getRenderOpsForDone(prev) {
77
+ this.state.previousOutput = '';
78
+ if (!prev.cursor.visible) {
79
+ return [{ type: 'cursorShow' }];
80
+ }
81
+ return [];
82
+ }
83
+ render(prev, next, altScreen = false, decstbmSafe = true, rewriteMainScreen = false) {
84
+ if (!this.options.isTTY) {
85
+ return this.renderFullFrame(next);
86
+ }
87
+ const startTime = performance.now();
88
+ const stylePool = this.options.stylePool;
89
+ // Since we assume the cursor is at the bottom on the screen, we only need
90
+ // to clear when the viewport gets shorter (i.e. the cursor position drifts)
91
+ // or when it gets thinner (and text wraps). We _could_ figure out how to
92
+ // not reset here but that would involve predicting the current layout
93
+ // _after_ the viewport change which means calcuating text wrapping.
94
+ // Resizing is a rare enough event that it's not practically a big issue.
95
+ if (next.viewport.height < prev.viewport.height ||
96
+ (prev.viewport.width !== 0 && next.viewport.width !== prev.viewport.width)) {
97
+ return fullResetSequence_CAUSES_FLICKER(next, 'resize', stylePool);
98
+ }
99
+ if (!altScreen && rewriteMainScreen) {
100
+ const rewriteStartY = findMainScreenRewriteStart(prev.screen, next.screen);
101
+ if (rewriteStartY !== null) {
102
+ return rewriteMainScreenFrame(prev, next, stylePool, rewriteStartY);
103
+ }
104
+ }
105
+ // DECSTBM scroll optimization: when a ScrollBox's scrollTop changed,
106
+ // shift content with a hardware scroll (CSI top;bot r + CSI n S/T)
107
+ // instead of rewriting the whole scroll region. The shiftRows on
108
+ // prev.screen simulates the shift so the diff loop below naturally
109
+ // finds only the rows that scrolled IN as diffs. prev.screen is
110
+ // about to become backFrame (reused next render) so mutation is safe.
111
+ // CURSOR_HOME after RESET_SCROLL_REGION is defensive — DECSTBM reset
112
+ // homes cursor per spec but terminal implementations vary.
113
+ //
114
+ // decstbmSafe: caller passes false when the DECSTBM→diff sequence
115
+ // can't be made atomic (no DEC 2026 / BSU/ESU). Without atomicity the
116
+ // outer terminal renders the intermediate state — region scrolled,
117
+ // edge rows not yet painted — a visible vertical jump on every frame
118
+ // where scrollTop moves. Falling through to the diff loop writes all
119
+ // shifted rows: more bytes, no intermediate state. next.screen from
120
+ // render-node-to-output's blit+shift is correct either way.
121
+ let scrollPatch = [];
122
+ if (altScreen && next.scrollHint && decstbmSafe) {
123
+ const { top, bottom, delta } = next.scrollHint;
124
+ if (top >= 0 &&
125
+ bottom < prev.screen.height &&
126
+ bottom < next.screen.height) {
127
+ (0, screen_js_1.shiftRows)(prev.screen, top, bottom, delta);
128
+ scrollPatch = [
129
+ {
130
+ type: 'stdout',
131
+ content: (0, csi_js_1.setScrollRegion)(top + 1, bottom + 1) +
132
+ (delta > 0 ? (0, csi_js_1.scrollUp)(delta) : (0, csi_js_1.scrollDown)(-delta)) +
133
+ csi_js_1.RESET_SCROLL_REGION +
134
+ csi_js_1.CURSOR_HOME,
135
+ },
136
+ ];
137
+ }
138
+ }
139
+ // We have to use purely relative operations to manipulate the cursor since
140
+ // we don't know its starting point.
141
+ //
142
+ // When content height >= viewport height AND cursor is at the bottom,
143
+ // the cursor restore at the end of the previous frame caused terminal scroll.
144
+ // viewportY tells us how many rows are in scrollback from content overflow.
145
+ // Additionally, the cursor-restore scroll pushes 1 more row into scrollback.
146
+ // We need fullReset if any changes are to rows that are now in scrollback.
147
+ //
148
+ // This early full-reset check only applies in "steady state" (not growing).
149
+ // For growing, the viewportY calculation below (with cursorRestoreScroll)
150
+ // catches unreachable scrollback rows in the diff loop instead.
151
+ const cursorAtBottom = prev.cursor.y >= prev.screen.height;
152
+ const isGrowing = next.screen.height > prev.screen.height;
153
+ // When content fills the viewport exactly (height == viewport) and the
154
+ // cursor is at the bottom, the cursor-restore LF at the end of the
155
+ // previous frame scrolled 1 row into scrollback. Use >= to catch this.
156
+ const prevHadScrollback = cursorAtBottom && prev.screen.height >= prev.viewport.height;
157
+ const isShrinking = next.screen.height < prev.screen.height;
158
+ const nextFitsViewport = next.screen.height <= prev.viewport.height;
159
+ // When shrinking from above-viewport to at-or-below-viewport, content that
160
+ // was in scrollback should now be visible. Terminal clear operations can't
161
+ // bring scrollback content into view, so we need a full reset.
162
+ // Use <= (not <) because even when next height equals viewport height, the
163
+ // scrollback depth from the previous render differs from a fresh render.
164
+ if (prevHadScrollback && nextFitsViewport && isShrinking) {
165
+ (0, debug_js_1.logForDebugging)(`Full reset (shrink->below): prevHeight=${prev.screen.height}, nextHeight=${next.screen.height}, viewport=${prev.viewport.height}`);
166
+ return fullResetSequence_CAUSES_FLICKER(next, 'offscreen', stylePool);
167
+ }
168
+ if (prev.screen.height >= prev.viewport.height &&
169
+ prev.screen.height > 0 &&
170
+ cursorAtBottom &&
171
+ !isGrowing) {
172
+ // viewportY = rows in scrollback from content overflow
173
+ // +1 for the row pushed by cursor-restore scroll
174
+ const viewportY = prev.screen.height - prev.viewport.height;
175
+ const scrollbackRows = viewportY + 1;
176
+ let scrollbackChangeY = -1;
177
+ (0, screen_js_1.diffEach)(prev.screen, next.screen, (_x, y) => {
178
+ if (y < scrollbackRows) {
179
+ scrollbackChangeY = y;
180
+ return true; // early exit
181
+ }
182
+ });
183
+ if (scrollbackChangeY >= 0) {
184
+ const prevLine = readLine(prev.screen, scrollbackChangeY);
185
+ const nextLine = readLine(next.screen, scrollbackChangeY);
186
+ return fullResetSequence_CAUSES_FLICKER(next, 'offscreen', stylePool, {
187
+ triggerY: scrollbackChangeY,
188
+ prevLine,
189
+ nextLine,
190
+ });
191
+ }
192
+ }
193
+ const screen = new VirtualScreen(prev.cursor, next.viewport.width);
194
+ // Treat empty screen as height 1 to avoid spurious adjustments on first render
195
+ const heightDelta = Math.max(next.screen.height, 1) - Math.max(prev.screen.height, 1);
196
+ const shrinking = heightDelta < 0;
197
+ const growing = heightDelta > 0;
198
+ // Handle shrinking: clear lines from the bottom
199
+ if (shrinking) {
200
+ const linesToClear = prev.screen.height - next.screen.height;
201
+ // eraseLines only works within the viewport - it can't clear scrollback.
202
+ // If we need to clear more lines than fit in the viewport, some are in
203
+ // scrollback, so we need a full reset.
204
+ if (linesToClear > prev.viewport.height) {
205
+ return fullResetSequence_CAUSES_FLICKER(next, 'offscreen', this.options.stylePool);
206
+ }
207
+ // clear(N) moves cursor UP by N-1 lines and to column 0
208
+ // This puts us at line prev.screen.height - N = next.screen.height
209
+ // But we want to be at next.screen.height - 1 (bottom of new screen)
210
+ screen.txn(prev => [
211
+ [
212
+ { type: 'clear', count: linesToClear },
213
+ { type: 'cursorMove', x: 0, y: -1 },
214
+ ],
215
+ { dx: -prev.x, dy: -linesToClear },
216
+ ]);
217
+ }
218
+ // viewportY = number of rows in scrollback (not visible on terminal).
219
+ // For shrinking: use max(prev, next) because terminal clears don't scroll.
220
+ // For growing: use prev state because new rows haven't scrolled old ones yet.
221
+ // When prevHadScrollback, add 1 for the cursor-restore LF that scrolled
222
+ // an additional row out of view at the end of the previous frame. Without
223
+ // this, the diff loop treats that row as reachable — but the cursor clamps
224
+ // at viewport top, causing writes to land 1 row off and garbling the output.
225
+ const cursorRestoreScroll = prevHadScrollback ? 1 : 0;
226
+ const viewportY = growing
227
+ ? Math.max(0, prev.screen.height - prev.viewport.height + cursorRestoreScroll)
228
+ : Math.max(prev.screen.height, next.screen.height) -
229
+ next.viewport.height +
230
+ cursorRestoreScroll;
231
+ let currentStyleId = stylePool.none;
232
+ let currentHyperlink = undefined;
233
+ // First pass: render changes to existing rows (rows < prev.screen.height)
234
+ let needsFullReset = false;
235
+ let resetTriggerY = -1;
236
+ (0, screen_js_1.diffEach)(prev.screen, next.screen, (x, y, removed, added) => {
237
+ // Skip new rows - we'll render them directly after
238
+ if (growing && y >= prev.screen.height) {
239
+ return;
240
+ }
241
+ // Skip spacers during rendering because the terminal will automatically
242
+ // advance 2 columns when we write the wide character itself.
243
+ // SpacerTail: Second cell of a wide character
244
+ // SpacerHead: Marks line-end position where wide char wraps to next line
245
+ if (added &&
246
+ (added.width === 2 /* CellWidth.SpacerTail */ ||
247
+ added.width === 3 /* CellWidth.SpacerHead */)) {
248
+ return;
249
+ }
250
+ if (removed &&
251
+ (removed.width === 2 /* CellWidth.SpacerTail */ ||
252
+ removed.width === 3 /* CellWidth.SpacerHead */) &&
253
+ !added) {
254
+ return;
255
+ }
256
+ // Skip empty cells that don't need to overwrite existing content.
257
+ // This prevents writing trailing spaces that would cause unnecessary
258
+ // line wrapping at the edge of the screen.
259
+ // Uses isEmptyCellAt to check if both packed words are zero (empty cell).
260
+ if (added && (0, screen_js_1.isEmptyCellAt)(next.screen, x, y) && !removed) {
261
+ return;
262
+ }
263
+ // If the cell outside the viewport range has changed, we need to reset
264
+ // because we can't move the cursor there to draw.
265
+ if (y < viewportY) {
266
+ needsFullReset = true;
267
+ resetTriggerY = y;
268
+ return true; // early exit
269
+ }
270
+ moveCursorTo(screen, x, y);
271
+ if (added) {
272
+ const targetHyperlink = added.hyperlink;
273
+ currentHyperlink = transitionHyperlink(screen.diff, currentHyperlink, targetHyperlink);
274
+ const styleStr = stylePool.transition(currentStyleId, added.styleId);
275
+ if (writeCellWithStyleStr(screen, added, styleStr)) {
276
+ currentStyleId = added.styleId;
277
+ }
278
+ }
279
+ else if (removed) {
280
+ // Cell was removed - clear it with a space
281
+ // (This handles shrinking content)
282
+ // Reset any active styles/hyperlinks first to avoid leaking into cleared cells
283
+ const styleIdToReset = currentStyleId;
284
+ const hyperlinkToReset = currentHyperlink;
285
+ currentStyleId = stylePool.none;
286
+ currentHyperlink = undefined;
287
+ screen.txn(() => {
288
+ const patches = [];
289
+ transitionStyle(patches, stylePool, styleIdToReset, stylePool.none);
290
+ transitionHyperlink(patches, hyperlinkToReset, undefined);
291
+ patches.push({ type: 'stdout', content: ' ' });
292
+ return [patches, { dx: 1, dy: 0 }];
293
+ });
294
+ }
295
+ });
296
+ if (needsFullReset) {
297
+ return fullResetSequence_CAUSES_FLICKER(next, 'offscreen', stylePool, {
298
+ triggerY: resetTriggerY,
299
+ prevLine: readLine(prev.screen, resetTriggerY),
300
+ nextLine: readLine(next.screen, resetTriggerY),
301
+ });
302
+ }
303
+ // Reset styles before rendering new rows (they'll set their own styles)
304
+ currentStyleId = transitionStyle(screen.diff, stylePool, currentStyleId, stylePool.none);
305
+ currentHyperlink = transitionHyperlink(screen.diff, currentHyperlink, undefined);
306
+ // Handle growth: render new rows directly (they naturally scroll the terminal)
307
+ if (growing) {
308
+ renderFrameSlice(screen, next, prev.screen.height, next.screen.height, stylePool);
309
+ }
310
+ // Restore cursor. Skipped in alt-screen: the cursor is hidden, its
311
+ // position only matters as the starting point for the NEXT frame's
312
+ // relative moves, and in alt-screen the next frame always begins with
313
+ // CSI H (see ink.tsx onRender) which resets to (0,0) regardless. This
314
+ // saves a CR + cursorMove round-trip (~6-10 bytes) every frame.
315
+ //
316
+ // Main screen: if cursor needs to be past the last line of content
317
+ // (typical: cursor.y = screen.height), emit \n to create that line
318
+ // since cursor movement can't create new lines.
319
+ if (!altScreen) {
320
+ restoreMainScreenCursor(screen, next);
321
+ }
322
+ const elapsed = performance.now() - startTime;
323
+ if (elapsed > 50) {
324
+ const damage = next.screen.damage;
325
+ const damageInfo = damage
326
+ ? `${damage.width}x${damage.height} at (${damage.x},${damage.y})`
327
+ : 'none';
328
+ (0, debug_js_1.logForDebugging)(`Slow render: ${elapsed.toFixed(1)}ms, screen: ${next.screen.height}x${next.screen.width}, damage: ${damageInfo}, changes: ${screen.diff.length}`);
329
+ }
330
+ return scrollPatch.length > 0
331
+ ? [...scrollPatch, ...screen.diff]
332
+ : screen.diff;
333
+ }
334
+ }
335
+ exports.LogUpdate = LogUpdate;
336
+ function rewriteMainScreenFrame(prev, next, stylePool, startY) {
337
+ const diff = [];
338
+ const clearCount = prev.screen.height - startY;
339
+ if (clearCount > 0) {
340
+ const clearStartY = prev.screen.height - 1;
341
+ const clearCursor = new VirtualScreen(prev.cursor, next.viewport.width);
342
+ moveCursorTo(clearCursor, 0, clearStartY);
343
+ diff.push(...clearCursor.diff);
344
+ diff.push({ type: 'clear', count: clearCount });
345
+ }
346
+ const screen = new VirtualScreen(clearCount > 0 ? { x: 0, y: startY } : prev.cursor, next.viewport.width);
347
+ renderFrameSlice(screen, next, startY, next.screen.height, stylePool);
348
+ restoreMainScreenCursor(screen, next);
349
+ return [...diff, ...screen.diff];
350
+ }
351
+ const MAX_MAIN_SCREEN_REWRITE_ROWS = 6;
352
+ function findMainScreenRewriteStart(prev, next) {
353
+ const commonHeight = Math.min(prev.height, next.height);
354
+ let firstChangedY = commonHeight;
355
+ for (let y = 0; y < commonHeight; y += 1) {
356
+ if (!rowsEqual(prev, next, y)) {
357
+ firstChangedY = y;
358
+ break;
359
+ }
360
+ }
361
+ const rewriteRows = Math.max(prev.height, next.height) - firstChangedY;
362
+ if (rewriteRows <= 0) {
363
+ return null;
364
+ }
365
+ return rewriteRows <= MAX_MAIN_SCREEN_REWRITE_ROWS ? firstChangedY : null;
366
+ }
367
+ function rowsEqual(prev, next, y) {
368
+ if (prev.width !== next.width) {
369
+ return false;
370
+ }
371
+ if (prev.softWrap[y] !== next.softWrap[y]) {
372
+ return false;
373
+ }
374
+ const rowStart = y * prev.width;
375
+ const rowEnd = rowStart + prev.width;
376
+ for (let index = rowStart; index < rowEnd; index += 1) {
377
+ if (prev.cells64[index] !== next.cells64[index] ||
378
+ prev.noSelect[index] !== next.noSelect[index]) {
379
+ return false;
380
+ }
381
+ }
382
+ return true;
383
+ }
384
+ function transitionHyperlink(diff, current, target) {
385
+ if (current !== target) {
386
+ diff.push({ type: 'hyperlink', uri: target ?? '' });
387
+ return target;
388
+ }
389
+ return current;
390
+ }
391
+ function transitionStyle(diff, stylePool, currentId, targetId) {
392
+ const str = stylePool.transition(currentId, targetId);
393
+ if (str.length > 0) {
394
+ diff.push({ type: 'styleStr', str });
395
+ }
396
+ return targetId;
397
+ }
398
+ function readLine(screen, y) {
399
+ let line = '';
400
+ for (let x = 0; x < screen.width; x++) {
401
+ line += (0, screen_js_1.charInCellAt)(screen, x, y) ?? ' ';
402
+ }
403
+ return line.trimEnd();
404
+ }
405
+ function fullResetSequence_CAUSES_FLICKER(frame, reason, stylePool, debug) {
406
+ // After clearTerminal, cursor is at (0, 0)
407
+ const screen = new VirtualScreen({ x: 0, y: 0 }, frame.viewport.width);
408
+ renderFrame(screen, frame, stylePool);
409
+ return [{ type: 'clearTerminal', reason, debug }, ...screen.diff];
410
+ }
411
+ function renderFrame(screen, frame, stylePool) {
412
+ renderFrameSlice(screen, frame, 0, frame.screen.height, stylePool);
413
+ }
414
+ /**
415
+ * Render a slice of rows from the frame's screen.
416
+ * Each row is rendered followed by a newline. Cursor ends at (0, endY).
417
+ */
418
+ function renderFrameSlice(screen, frame, startY, endY, stylePool) {
419
+ let currentStyleId = stylePool.none;
420
+ let currentHyperlink = undefined;
421
+ // Track the styleId of the last rendered cell on this line (-1 if none).
422
+ // Passed to visibleCellAtIndex to enable fg-only space optimization.
423
+ let lastRenderedStyleId = -1;
424
+ const { width: screenWidth, cells, charPool, hyperlinkPool } = frame.screen;
425
+ let index = startY * screenWidth;
426
+ for (let y = startY; y < endY; y += 1) {
427
+ // Advance cursor to this row using LF (not CSI CUD / cursor-down).
428
+ // CSI CUD stops at the viewport bottom margin and cannot scroll,
429
+ // but LF scrolls the viewport to create new lines. Without this,
430
+ // when the cursor is at the viewport bottom, moveCursorTo's
431
+ // cursor-down silently fails, creating a permanent off-by-one
432
+ // between the virtual cursor and the real terminal cursor.
433
+ if (screen.cursor.y < y) {
434
+ const rowsToAdvance = y - screen.cursor.y;
435
+ screen.txn(prev => {
436
+ const patches = new Array(1 + rowsToAdvance);
437
+ patches[0] = CARRIAGE_RETURN;
438
+ for (let i = 0; i < rowsToAdvance; i++) {
439
+ patches[1 + i] = NEWLINE;
440
+ }
441
+ return [patches, { dx: -prev.x, dy: rowsToAdvance }];
442
+ });
443
+ }
444
+ // Reset at start of each line — no cell rendered yet
445
+ lastRenderedStyleId = -1;
446
+ for (let x = 0; x < screenWidth; x += 1, index += 1) {
447
+ // Skip spacers, unstyled empty cells, and fg-only styled spaces that
448
+ // match the last rendered style (since cursor-forward produces identical
449
+ // visual result). visibleCellAtIndex handles the optimization internally
450
+ // to avoid allocating Cell objects for skipped cells.
451
+ const cell = (0, screen_js_1.visibleCellAtIndex)(cells, charPool, hyperlinkPool, index, lastRenderedStyleId);
452
+ if (!cell) {
453
+ continue;
454
+ }
455
+ moveCursorTo(screen, x, y);
456
+ // Handle hyperlink
457
+ const targetHyperlink = cell.hyperlink;
458
+ currentHyperlink = transitionHyperlink(screen.diff, currentHyperlink, targetHyperlink);
459
+ // Style transition — cached string, zero allocations after warmup
460
+ const styleStr = stylePool.transition(currentStyleId, cell.styleId);
461
+ if (writeCellWithStyleStr(screen, cell, styleStr)) {
462
+ currentStyleId = cell.styleId;
463
+ lastRenderedStyleId = cell.styleId;
464
+ }
465
+ }
466
+ // Reset styles/hyperlinks before newline so background color doesn't
467
+ // bleed into the next line when the terminal scrolls. The old code
468
+ // reset implicitly by writing trailing unstyled spaces; now that we
469
+ // skip empty cells, we must reset explicitly.
470
+ currentStyleId = transitionStyle(screen.diff, stylePool, currentStyleId, stylePool.none);
471
+ currentHyperlink = transitionHyperlink(screen.diff, currentHyperlink, undefined);
472
+ // CR+LF at end of row — \r resets to column 0, \n moves to next line.
473
+ // Without \r, the terminal cursor stays at whatever column content ended
474
+ // (since we skip trailing spaces, this can be mid-row).
475
+ screen.txn(prev => [[CARRIAGE_RETURN, NEWLINE], { dx: -prev.x, dy: 1 }]);
476
+ }
477
+ // Reset any open style/hyperlink at end of slice
478
+ transitionStyle(screen.diff, stylePool, currentStyleId, stylePool.none);
479
+ transitionHyperlink(screen.diff, currentHyperlink, undefined);
480
+ return screen;
481
+ }
482
+ function restoreMainScreenCursor(screen, next) {
483
+ if (next.cursor.y >= next.screen.height) {
484
+ // Move to column 0 of current line, then emit newlines to reach target row
485
+ screen.txn(prev => {
486
+ const rowsToCreate = next.cursor.y - prev.y;
487
+ if (rowsToCreate > 0) {
488
+ // Use CR to resolve pending wrap (if any) without advancing
489
+ // to the next line, then LF to create each new row.
490
+ const patches = new Array(1 + rowsToCreate);
491
+ patches[0] = CARRIAGE_RETURN;
492
+ for (let i = 0; i < rowsToCreate; i++) {
493
+ patches[1 + i] = NEWLINE;
494
+ }
495
+ return [patches, { dx: -prev.x, dy: rowsToCreate }];
496
+ }
497
+ // At or past target row - need to move cursor to correct position
498
+ const dy = next.cursor.y - prev.y;
499
+ if (dy !== 0 || prev.x !== next.cursor.x) {
500
+ // Use CR to clear pending wrap (if any), then cursor move
501
+ const patches = [CARRIAGE_RETURN];
502
+ patches.push({ type: 'cursorMove', x: next.cursor.x, y: dy });
503
+ return [patches, { dx: next.cursor.x - prev.x, dy }];
504
+ }
505
+ return [[], { dx: 0, dy: 0 }];
506
+ });
507
+ return;
508
+ }
509
+ moveCursorTo(screen, next.cursor.x, next.cursor.y);
510
+ }
511
+ /**
512
+ * Write a cell with a pre-serialized style transition string (from
513
+ * StylePool.transition). Inlines the txn logic to avoid closure/tuple/delta
514
+ * allocations on every cell.
515
+ *
516
+ * Returns true if the cell was written, false if skipped (wide char at
517
+ * viewport edge). Callers MUST gate currentStyleId updates on this — when
518
+ * skipped, styleStr is never pushed and the terminal's style state is
519
+ * unchanged. Updating the virtual tracker anyway desyncs it from the
520
+ * terminal, and the next transition is computed from phantom state.
521
+ */
522
+ function writeCellWithStyleStr(screen, cell, styleStr) {
523
+ const cellWidth = cell.width === 1 /* CellWidth.Wide */ ? 2 : 1;
524
+ const px = screen.cursor.x;
525
+ const vw = screen.viewportWidth;
526
+ // Don't write wide chars that would cross the viewport edge.
527
+ // Single-codepoint chars (CJK) at vw-2 are safe; multi-codepoint
528
+ // graphemes (flags, ZWJ emoji) need stricter threshold.
529
+ if (cellWidth === 2 && px < vw) {
530
+ const threshold = cell.char.length > 2 ? vw : vw + 1;
531
+ if (px + 2 >= threshold) {
532
+ return false;
533
+ }
534
+ }
535
+ const diff = screen.diff;
536
+ if (styleStr.length > 0) {
537
+ diff.push({ type: 'styleStr', str: styleStr });
538
+ }
539
+ const needsCompensation = cellWidth === 2 && needsWidthCompensation(cell.char);
540
+ // On terminals with old wcwidth tables, a compensated emoji only advances
541
+ // the cursor 1 column, so the CHA below skips column x+1 without painting
542
+ // it. Write a styled space there first — on correct terminals the emoji
543
+ // glyph (width 2) overwrites it harmlessly; on old terminals it fills the
544
+ // gap with the emoji's background. Also clears any stale content at x+1.
545
+ // CHA is 1-based, so column px+1 (0-based) is CHA target px+2.
546
+ if (needsCompensation && px + 1 < vw) {
547
+ diff.push({ type: 'cursorTo', col: px + 2 });
548
+ diff.push({ type: 'stdout', content: ' ' });
549
+ diff.push({ type: 'cursorTo', col: px + 1 });
550
+ }
551
+ diff.push({ type: 'stdout', content: cell.char });
552
+ // Force terminal cursor to correct column after the emoji.
553
+ if (needsCompensation) {
554
+ diff.push({ type: 'cursorTo', col: px + cellWidth + 1 });
555
+ }
556
+ // Update cursor — mutate in place to avoid Point allocation
557
+ if (px >= vw) {
558
+ screen.cursor.x = cellWidth;
559
+ screen.cursor.y++;
560
+ }
561
+ else {
562
+ screen.cursor.x = px + cellWidth;
563
+ }
564
+ return true;
565
+ }
566
+ function moveCursorTo(screen, targetX, targetY) {
567
+ screen.txn(prev => {
568
+ const dx = targetX - prev.x;
569
+ const dy = targetY - prev.y;
570
+ const inPendingWrap = prev.x >= screen.viewportWidth;
571
+ // If we're in pending wrap state (cursor.x >= width), use CR
572
+ // to reset to column 0 on the current line without advancing
573
+ // to the next line, then issue the cursor movement.
574
+ if (inPendingWrap) {
575
+ return [
576
+ [CARRIAGE_RETURN, { type: 'cursorMove', x: targetX, y: dy }],
577
+ { dx, dy },
578
+ ];
579
+ }
580
+ // When moving to a different line, use carriage return (\r) to reset to
581
+ // column 0 first, then cursor move.
582
+ if (dy !== 0) {
583
+ return [
584
+ [CARRIAGE_RETURN, { type: 'cursorMove', x: targetX, y: dy }],
585
+ { dx, dy },
586
+ ];
587
+ }
588
+ // Standard same-line cursor move
589
+ return [[{ type: 'cursorMove', x: dx, y: dy }], { dx, dy }];
590
+ });
591
+ }
592
+ /**
593
+ * Identify emoji where the terminal's wcwidth may disagree with Unicode.
594
+ * On terminals with correct tables, the CHA we emit is a harmless no-op.
595
+ *
596
+ * Two categories:
597
+ * 1. Newer emoji (Unicode 12.0+) missing from terminal wcwidth tables.
598
+ * 2. Text-by-default emoji + VS16 (U+FE0F): the base codepoint is width 1
599
+ * in wcwidth, but VS16 triggers emoji presentation making it width 2.
600
+ * Examples: ⚔️ (U+2694), ☠️ (U+2620), ❤️ (U+2764).
601
+ */
602
+ function needsWidthCompensation(char) {
603
+ const cp = char.codePointAt(0);
604
+ if (cp === undefined)
605
+ return false;
606
+ // U+1FA70-U+1FAFF: Symbols and Pictographs Extended-A (Unicode 12.0-15.0)
607
+ // U+1FB00-U+1FBFF: Symbols for Legacy Computing (Unicode 13.0)
608
+ if ((cp >= 0x1fa70 && cp <= 0x1faff) || (cp >= 0x1fb00 && cp <= 0x1fbff)) {
609
+ return true;
610
+ }
611
+ // Text-by-default emoji with VS16: scan for U+FE0F in multi-codepoint
612
+ // graphemes. Single BMP chars (length 1) and surrogate pairs without VS16
613
+ // skip this check. VS16 (0xFE0F) can't collide with surrogates (0xD800-0xDFFF).
614
+ if (char.length >= 2) {
615
+ for (let i = 0; i < char.length; i++) {
616
+ if (char.charCodeAt(i) === 0xfe0f)
617
+ return true;
618
+ }
619
+ }
620
+ return false;
621
+ }
622
+ class VirtualScreen {
623
+ constructor(origin, viewportWidth) {
624
+ this.viewportWidth = viewportWidth;
625
+ this.diff = [];
626
+ this.cursor = { ...origin };
627
+ }
628
+ txn(fn) {
629
+ const [patches, next] = fn(this.cursor);
630
+ for (const patch of patches) {
631
+ this.diff.push(patch);
632
+ }
633
+ this.cursor.x += next.dx;
634
+ this.cursor.y += next.dy;
635
+ }
636
+ }
637
+ //# sourceMappingURL=log-update.js.map