zerg-ztc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/README.md +361 -0
  2. package/dist/App.d.ts +4 -0
  3. package/dist/App.d.ts.map +1 -0
  4. package/dist/App.js +499 -0
  5. package/dist/App.js.map +1 -0
  6. package/dist/agent/agent.d.ts +54 -0
  7. package/dist/agent/agent.d.ts.map +1 -0
  8. package/dist/agent/agent.js +347 -0
  9. package/dist/agent/agent.js.map +1 -0
  10. package/dist/agent/backends/anthropic.d.ts +13 -0
  11. package/dist/agent/backends/anthropic.d.ts.map +1 -0
  12. package/dist/agent/backends/anthropic.js +54 -0
  13. package/dist/agent/backends/anthropic.js.map +1 -0
  14. package/dist/agent/backends/gemini.d.ts +13 -0
  15. package/dist/agent/backends/gemini.d.ts.map +1 -0
  16. package/dist/agent/backends/gemini.js +71 -0
  17. package/dist/agent/backends/gemini.js.map +1 -0
  18. package/dist/agent/backends/inception.d.ts +12 -0
  19. package/dist/agent/backends/inception.d.ts.map +1 -0
  20. package/dist/agent/backends/inception.js +15 -0
  21. package/dist/agent/backends/inception.js.map +1 -0
  22. package/dist/agent/backends/index.d.ts +7 -0
  23. package/dist/agent/backends/index.d.ts.map +1 -0
  24. package/dist/agent/backends/index.js +6 -0
  25. package/dist/agent/backends/index.js.map +1 -0
  26. package/dist/agent/backends/openai.d.ts +12 -0
  27. package/dist/agent/backends/openai.d.ts.map +1 -0
  28. package/dist/agent/backends/openai.js +15 -0
  29. package/dist/agent/backends/openai.js.map +1 -0
  30. package/dist/agent/backends/openai_compatible.d.ts +17 -0
  31. package/dist/agent/backends/openai_compatible.d.ts.map +1 -0
  32. package/dist/agent/backends/openai_compatible.js +95 -0
  33. package/dist/agent/backends/openai_compatible.js.map +1 -0
  34. package/dist/agent/backends/types.d.ts +49 -0
  35. package/dist/agent/backends/types.d.ts.map +1 -0
  36. package/dist/agent/backends/types.js +2 -0
  37. package/dist/agent/backends/types.js.map +1 -0
  38. package/dist/agent/commands/clipboard.d.ts +3 -0
  39. package/dist/agent/commands/clipboard.d.ts.map +1 -0
  40. package/dist/agent/commands/clipboard.js +72 -0
  41. package/dist/agent/commands/clipboard.js.map +1 -0
  42. package/dist/agent/commands/config.d.ts +3 -0
  43. package/dist/agent/commands/config.d.ts.map +1 -0
  44. package/dist/agent/commands/config.js +120 -0
  45. package/dist/agent/commands/config.js.map +1 -0
  46. package/dist/agent/commands/debug.d.ts +3 -0
  47. package/dist/agent/commands/debug.d.ts.map +1 -0
  48. package/dist/agent/commands/debug.js +23 -0
  49. package/dist/agent/commands/debug.js.map +1 -0
  50. package/dist/agent/commands/emulation.d.ts +3 -0
  51. package/dist/agent/commands/emulation.d.ts.map +1 -0
  52. package/dist/agent/commands/emulation.js +78 -0
  53. package/dist/agent/commands/emulation.js.map +1 -0
  54. package/dist/agent/commands/execution.d.ts +3 -0
  55. package/dist/agent/commands/execution.d.ts.map +1 -0
  56. package/dist/agent/commands/execution.js +8 -0
  57. package/dist/agent/commands/execution.js.map +1 -0
  58. package/dist/agent/commands/help.d.ts +3 -0
  59. package/dist/agent/commands/help.d.ts.map +1 -0
  60. package/dist/agent/commands/help.js +19 -0
  61. package/dist/agent/commands/help.js.map +1 -0
  62. package/dist/agent/commands/history.d.ts +3 -0
  63. package/dist/agent/commands/history.d.ts.map +1 -0
  64. package/dist/agent/commands/history.js +12 -0
  65. package/dist/agent/commands/history.js.map +1 -0
  66. package/dist/agent/commands/index.d.ts +4 -0
  67. package/dist/agent/commands/index.d.ts.map +1 -0
  68. package/dist/agent/commands/index.js +19 -0
  69. package/dist/agent/commands/index.js.map +1 -0
  70. package/dist/agent/commands/model.d.ts +3 -0
  71. package/dist/agent/commands/model.d.ts.map +1 -0
  72. package/dist/agent/commands/model.js +10 -0
  73. package/dist/agent/commands/model.js.map +1 -0
  74. package/dist/agent/commands/models.d.ts +3 -0
  75. package/dist/agent/commands/models.d.ts.map +1 -0
  76. package/dist/agent/commands/models.js +110 -0
  77. package/dist/agent/commands/models.js.map +1 -0
  78. package/dist/agent/commands/permissions.d.ts +3 -0
  79. package/dist/agent/commands/permissions.d.ts.map +1 -0
  80. package/dist/agent/commands/permissions.js +58 -0
  81. package/dist/agent/commands/permissions.js.map +1 -0
  82. package/dist/agent/commands/retry.d.ts +3 -0
  83. package/dist/agent/commands/retry.d.ts.map +1 -0
  84. package/dist/agent/commands/retry.js +8 -0
  85. package/dist/agent/commands/retry.js.map +1 -0
  86. package/dist/agent/commands/shell.d.ts +4 -0
  87. package/dist/agent/commands/shell.d.ts.map +1 -0
  88. package/dist/agent/commands/shell.js +66 -0
  89. package/dist/agent/commands/shell.js.map +1 -0
  90. package/dist/agent/commands/skills.d.ts +3 -0
  91. package/dist/agent/commands/skills.d.ts.map +1 -0
  92. package/dist/agent/commands/skills.js +50 -0
  93. package/dist/agent/commands/skills.js.map +1 -0
  94. package/dist/agent/commands/status.d.ts +3 -0
  95. package/dist/agent/commands/status.d.ts.map +1 -0
  96. package/dist/agent/commands/status.js +18 -0
  97. package/dist/agent/commands/status.js.map +1 -0
  98. package/dist/agent/commands/types.d.ts +70 -0
  99. package/dist/agent/commands/types.d.ts.map +1 -0
  100. package/dist/agent/commands/types.js +2 -0
  101. package/dist/agent/commands/types.js.map +1 -0
  102. package/dist/agent/factory.d.ts +13 -0
  103. package/dist/agent/factory.d.ts.map +1 -0
  104. package/dist/agent/factory.js +46 -0
  105. package/dist/agent/factory.js.map +1 -0
  106. package/dist/agent/index.d.ts +14 -0
  107. package/dist/agent/index.d.ts.map +1 -0
  108. package/dist/agent/index.js +10 -0
  109. package/dist/agent/index.js.map +1 -0
  110. package/dist/agent/runtime/capabilities.d.ts +7 -0
  111. package/dist/agent/runtime/capabilities.d.ts.map +1 -0
  112. package/dist/agent/runtime/capabilities.js +8 -0
  113. package/dist/agent/runtime/capabilities.js.map +1 -0
  114. package/dist/agent/runtime/memory.d.ts +13 -0
  115. package/dist/agent/runtime/memory.d.ts.map +1 -0
  116. package/dist/agent/runtime/memory.js +13 -0
  117. package/dist/agent/runtime/memory.js.map +1 -0
  118. package/dist/agent/runtime/policy.d.ts +22 -0
  119. package/dist/agent/runtime/policy.d.ts.map +1 -0
  120. package/dist/agent/runtime/policy.js +29 -0
  121. package/dist/agent/runtime/policy.js.map +1 -0
  122. package/dist/agent/runtime/session.d.ts +11 -0
  123. package/dist/agent/runtime/session.d.ts.map +1 -0
  124. package/dist/agent/runtime/session.js +10 -0
  125. package/dist/agent/runtime/session.js.map +1 -0
  126. package/dist/agent/runtime/tracing.d.ts +13 -0
  127. package/dist/agent/runtime/tracing.d.ts.map +1 -0
  128. package/dist/agent/runtime/tracing.js +6 -0
  129. package/dist/agent/runtime/tracing.js.map +1 -0
  130. package/dist/agent/tools/file.d.ts +5 -0
  131. package/dist/agent/tools/file.d.ts.map +1 -0
  132. package/dist/agent/tools/file.js +162 -0
  133. package/dist/agent/tools/file.js.map +1 -0
  134. package/dist/agent/tools/index.d.ts +13 -0
  135. package/dist/agent/tools/index.d.ts.map +1 -0
  136. package/dist/agent/tools/index.js +34 -0
  137. package/dist/agent/tools/index.js.map +1 -0
  138. package/dist/agent/tools/search.d.ts +3 -0
  139. package/dist/agent/tools/search.d.ts.map +1 -0
  140. package/dist/agent/tools/search.js +124 -0
  141. package/dist/agent/tools/search.js.map +1 -0
  142. package/dist/agent/tools/shell.d.ts +3 -0
  143. package/dist/agent/tools/shell.d.ts.map +1 -0
  144. package/dist/agent/tools/shell.js +60 -0
  145. package/dist/agent/tools/shell.js.map +1 -0
  146. package/dist/agent/tools/skills.d.ts +3 -0
  147. package/dist/agent/tools/skills.d.ts.map +1 -0
  148. package/dist/agent/tools/skills.js +27 -0
  149. package/dist/agent/tools/skills.js.map +1 -0
  150. package/dist/agent/tools/types.d.ts +8 -0
  151. package/dist/agent/tools/types.d.ts.map +1 -0
  152. package/dist/agent/tools/types.js +2 -0
  153. package/dist/agent/tools/types.js.map +1 -0
  154. package/dist/agent/tools/zerg.d.ts +3 -0
  155. package/dist/agent/tools/zerg.d.ts.map +1 -0
  156. package/dist/agent/tools/zerg.js +47 -0
  157. package/dist/agent/tools/zerg.js.map +1 -0
  158. package/dist/cli.d.ts +3 -0
  159. package/dist/cli.d.ts.map +1 -0
  160. package/dist/cli.js +75 -0
  161. package/dist/cli.js.map +1 -0
  162. package/dist/components/FullScreen.d.ts +28 -0
  163. package/dist/components/FullScreen.d.ts.map +1 -0
  164. package/dist/components/FullScreen.js +40 -0
  165. package/dist/components/FullScreen.js.map +1 -0
  166. package/dist/components/Header.d.ts +10 -0
  167. package/dist/components/Header.d.ts.map +1 -0
  168. package/dist/components/Header.js +14 -0
  169. package/dist/components/Header.js.map +1 -0
  170. package/dist/components/InputArea.d.ts +24 -0
  171. package/dist/components/InputArea.d.ts.map +1 -0
  172. package/dist/components/InputArea.js +476 -0
  173. package/dist/components/InputArea.js.map +1 -0
  174. package/dist/components/MessageList.d.ts +12 -0
  175. package/dist/components/MessageList.d.ts.map +1 -0
  176. package/dist/components/MessageList.js +9 -0
  177. package/dist/components/MessageList.js.map +1 -0
  178. package/dist/components/StatusBar.d.ts +18 -0
  179. package/dist/components/StatusBar.d.ts.map +1 -0
  180. package/dist/components/StatusBar.js +21 -0
  181. package/dist/components/StatusBar.js.map +1 -0
  182. package/dist/components/index.d.ts +6 -0
  183. package/dist/components/index.d.ts.map +1 -0
  184. package/dist/components/index.js +7 -0
  185. package/dist/components/index.js.map +1 -0
  186. package/dist/config/types.d.ts +12 -0
  187. package/dist/config/types.d.ts.map +1 -0
  188. package/dist/config/types.js +2 -0
  189. package/dist/config/types.js.map +1 -0
  190. package/dist/config.d.ts +28 -0
  191. package/dist/config.d.ts.map +1 -0
  192. package/dist/config.js +155 -0
  193. package/dist/config.js.map +1 -0
  194. package/dist/debug/logger.d.ts +2 -0
  195. package/dist/debug/logger.d.ts.map +1 -0
  196. package/dist/debug/logger.js +15 -0
  197. package/dist/debug/logger.js.map +1 -0
  198. package/dist/emulation/catalog.d.ts +4 -0
  199. package/dist/emulation/catalog.d.ts.map +1 -0
  200. package/dist/emulation/catalog.js +68 -0
  201. package/dist/emulation/catalog.js.map +1 -0
  202. package/dist/emulation/trace_style.d.ts +3 -0
  203. package/dist/emulation/trace_style.d.ts.map +1 -0
  204. package/dist/emulation/trace_style.js +10 -0
  205. package/dist/emulation/trace_style.js.map +1 -0
  206. package/dist/emulation/types.d.ts +8 -0
  207. package/dist/emulation/types.d.ts.map +1 -0
  208. package/dist/emulation/types.js +2 -0
  209. package/dist/emulation/types.js.map +1 -0
  210. package/dist/skills/index.d.ts +5 -0
  211. package/dist/skills/index.d.ts.map +1 -0
  212. package/dist/skills/index.js +36 -0
  213. package/dist/skills/index.js.map +1 -0
  214. package/dist/skills/loader.d.ts +3 -0
  215. package/dist/skills/loader.d.ts.map +1 -0
  216. package/dist/skills/loader.js +137 -0
  217. package/dist/skills/loader.js.map +1 -0
  218. package/dist/skills/registry.d.ts +3 -0
  219. package/dist/skills/registry.d.ts.map +1 -0
  220. package/dist/skills/registry.js +5 -0
  221. package/dist/skills/registry.js.map +1 -0
  222. package/dist/skills/types.d.ts +11 -0
  223. package/dist/skills/types.d.ts.map +1 -0
  224. package/dist/skills/types.js +2 -0
  225. package/dist/skills/types.js.map +1 -0
  226. package/dist/types.d.ts +93 -0
  227. package/dist/types.d.ts.map +1 -0
  228. package/dist/types.js +5 -0
  229. package/dist/types.js.map +1 -0
  230. package/dist/ui/core/factory.d.ts +4 -0
  231. package/dist/ui/core/factory.d.ts.map +1 -0
  232. package/dist/ui/core/factory.js +7 -0
  233. package/dist/ui/core/factory.js.map +1 -0
  234. package/dist/ui/core/index.d.ts +5 -0
  235. package/dist/ui/core/index.d.ts.map +1 -0
  236. package/dist/ui/core/index.js +4 -0
  237. package/dist/ui/core/index.js.map +1 -0
  238. package/dist/ui/core/input.d.ts +22 -0
  239. package/dist/ui/core/input.d.ts.map +1 -0
  240. package/dist/ui/core/input.js +15 -0
  241. package/dist/ui/core/input.js.map +1 -0
  242. package/dist/ui/core/input_segments.d.ts +19 -0
  243. package/dist/ui/core/input_segments.d.ts.map +1 -0
  244. package/dist/ui/core/input_segments.js +367 -0
  245. package/dist/ui/core/input_segments.js.map +1 -0
  246. package/dist/ui/core/input_state.d.ts +24 -0
  247. package/dist/ui/core/input_state.d.ts.map +1 -0
  248. package/dist/ui/core/input_state.js +2 -0
  249. package/dist/ui/core/input_state.js.map +1 -0
  250. package/dist/ui/core/layout_yoga.d.ts +11 -0
  251. package/dist/ui/core/layout_yoga.d.ts.map +1 -0
  252. package/dist/ui/core/layout_yoga.js +102 -0
  253. package/dist/ui/core/layout_yoga.js.map +1 -0
  254. package/dist/ui/core/style.d.ts +3 -0
  255. package/dist/ui/core/style.d.ts.map +1 -0
  256. package/dist/ui/core/style.js +37 -0
  257. package/dist/ui/core/style.js.map +1 -0
  258. package/dist/ui/core/types.d.ts +50 -0
  259. package/dist/ui/core/types.d.ts.map +1 -0
  260. package/dist/ui/core/types.js +2 -0
  261. package/dist/ui/core/types.js.map +1 -0
  262. package/dist/ui/ink/index.d.ts +2 -0
  263. package/dist/ui/ink/index.d.ts.map +1 -0
  264. package/dist/ui/ink/index.js +2 -0
  265. package/dist/ui/ink/index.js.map +1 -0
  266. package/dist/ui/ink/render.d.ts +6 -0
  267. package/dist/ui/ink/render.d.ts.map +1 -0
  268. package/dist/ui/ink/render.js +14 -0
  269. package/dist/ui/ink/render.js.map +1 -0
  270. package/dist/ui/views/app.d.ts +28 -0
  271. package/dist/ui/views/app.d.ts.map +1 -0
  272. package/dist/ui/views/app.js +59 -0
  273. package/dist/ui/views/app.js.map +1 -0
  274. package/dist/ui/views/header.d.ts +11 -0
  275. package/dist/ui/views/header.d.ts.map +1 -0
  276. package/dist/ui/views/header.js +28 -0
  277. package/dist/ui/views/header.js.map +1 -0
  278. package/dist/ui/views/input_area.d.ts +45 -0
  279. package/dist/ui/views/input_area.d.ts.map +1 -0
  280. package/dist/ui/views/input_area.js +183 -0
  281. package/dist/ui/views/input_area.js.map +1 -0
  282. package/dist/ui/views/message_list.d.ts +12 -0
  283. package/dist/ui/views/message_list.d.ts.map +1 -0
  284. package/dist/ui/views/message_list.js +381 -0
  285. package/dist/ui/views/message_list.js.map +1 -0
  286. package/dist/ui/views/status_bar.d.ts +18 -0
  287. package/dist/ui/views/status_bar.d.ts.map +1 -0
  288. package/dist/ui/views/status_bar.js +72 -0
  289. package/dist/ui/views/status_bar.js.map +1 -0
  290. package/dist/ui/vue/index.d.ts +5 -0
  291. package/dist/ui/vue/index.d.ts.map +1 -0
  292. package/dist/ui/vue/index.js +50 -0
  293. package/dist/ui/vue/index.js.map +1 -0
  294. package/dist/utils/clipboard.d.ts +2 -0
  295. package/dist/utils/clipboard.d.ts.map +1 -0
  296. package/dist/utils/clipboard.js +39 -0
  297. package/dist/utils/clipboard.js.map +1 -0
  298. package/dist/utils/clipboard_image.d.ts +2 -0
  299. package/dist/utils/clipboard_image.d.ts.map +1 -0
  300. package/dist/utils/clipboard_image.js +37 -0
  301. package/dist/utils/clipboard_image.js.map +1 -0
  302. package/dist/utils/diff.d.ts +2 -0
  303. package/dist/utils/diff.d.ts.map +1 -0
  304. package/dist/utils/diff.js +49 -0
  305. package/dist/utils/diff.js.map +1 -0
  306. package/dist/utils/image_preview.d.ts +2 -0
  307. package/dist/utils/image_preview.d.ts.map +1 -0
  308. package/dist/utils/image_preview.js +37 -0
  309. package/dist/utils/image_preview.js.map +1 -0
  310. package/dist/utils/models.d.ts +8 -0
  311. package/dist/utils/models.d.ts.map +1 -0
  312. package/dist/utils/models.js +85 -0
  313. package/dist/utils/models.js.map +1 -0
  314. package/dist/utils/shell.d.ts +4 -0
  315. package/dist/utils/shell.d.ts.map +1 -0
  316. package/dist/utils/shell.js +57 -0
  317. package/dist/utils/shell.js.map +1 -0
  318. package/dist/utils/tool_summary.d.ts +3 -0
  319. package/dist/utils/tool_summary.d.ts.map +1 -0
  320. package/dist/utils/tool_summary.js +54 -0
  321. package/dist/utils/tool_summary.js.map +1 -0
  322. package/dist/utils/tool_trace.d.ts +9 -0
  323. package/dist/utils/tool_trace.d.ts.map +1 -0
  324. package/dist/utils/tool_trace.js +183 -0
  325. package/dist/utils/tool_trace.js.map +1 -0
  326. package/package.json +41 -0
  327. package/src/App.tsx +576 -0
  328. package/src/agent/agent.ts +407 -0
  329. package/src/agent/backends/anthropic.ts +76 -0
  330. package/src/agent/backends/gemini.ts +107 -0
  331. package/src/agent/backends/inception.ts +23 -0
  332. package/src/agent/backends/index.ts +16 -0
  333. package/src/agent/backends/openai.ts +23 -0
  334. package/src/agent/backends/openai_compatible.ts +131 -0
  335. package/src/agent/backends/types.ts +59 -0
  336. package/src/agent/commands/clipboard.ts +77 -0
  337. package/src/agent/commands/config.ts +130 -0
  338. package/src/agent/commands/debug.ts +23 -0
  339. package/src/agent/commands/emulation.ts +80 -0
  340. package/src/agent/commands/execution.ts +9 -0
  341. package/src/agent/commands/help.ts +20 -0
  342. package/src/agent/commands/history.ts +13 -0
  343. package/src/agent/commands/index.ts +40 -0
  344. package/src/agent/commands/model.ts +11 -0
  345. package/src/agent/commands/models.ts +116 -0
  346. package/src/agent/commands/permissions.ts +64 -0
  347. package/src/agent/commands/retry.ts +9 -0
  348. package/src/agent/commands/shell.ts +68 -0
  349. package/src/agent/commands/skills.ts +54 -0
  350. package/src/agent/commands/status.ts +19 -0
  351. package/src/agent/commands/types.ts +78 -0
  352. package/src/agent/factory.ts +60 -0
  353. package/src/agent/index.ts +20 -0
  354. package/src/agent/runtime/capabilities.ts +6 -0
  355. package/src/agent/runtime/memory.ts +23 -0
  356. package/src/agent/runtime/policy.ts +48 -0
  357. package/src/agent/runtime/session.ts +18 -0
  358. package/src/agent/runtime/tracing.ts +23 -0
  359. package/src/agent/tools/file.ts +173 -0
  360. package/src/agent/tools/index.ts +46 -0
  361. package/src/agent/tools/search.ts +137 -0
  362. package/src/agent/tools/shell.ts +65 -0
  363. package/src/agent/tools/skills.ts +28 -0
  364. package/src/agent/tools/types.ts +10 -0
  365. package/src/agent/tools/zerg.ts +50 -0
  366. package/src/cli.tsx +80 -0
  367. package/src/components/FullScreen.tsx +73 -0
  368. package/src/components/Header.tsx +27 -0
  369. package/src/components/InputArea.tsx +551 -0
  370. package/src/components/MessageList.tsx +25 -0
  371. package/src/components/StatusBar.tsx +49 -0
  372. package/src/components/index.tsx +6 -0
  373. package/src/config/types.ts +11 -0
  374. package/src/config.ts +178 -0
  375. package/src/debug/logger.ts +14 -0
  376. package/src/emulation/README.md +24 -0
  377. package/src/emulation/catalog.ts +82 -0
  378. package/src/emulation/trace_style.ts +8 -0
  379. package/src/emulation/types.ts +7 -0
  380. package/src/skills/index.ts +36 -0
  381. package/src/skills/loader.ts +135 -0
  382. package/src/skills/registry.ts +6 -0
  383. package/src/skills/types.ts +10 -0
  384. package/src/types.ts +83 -0
  385. package/src/ui/README.md +44 -0
  386. package/src/ui/core/factory.ts +9 -0
  387. package/src/ui/core/index.ts +4 -0
  388. package/src/ui/core/input.ts +38 -0
  389. package/src/ui/core/input_segments.ts +375 -0
  390. package/src/ui/core/input_state.ts +17 -0
  391. package/src/ui/core/layout_yoga.ts +122 -0
  392. package/src/ui/core/style.ts +38 -0
  393. package/src/ui/core/types.ts +53 -0
  394. package/src/ui/ink/index.tsx +1 -0
  395. package/src/ui/ink/render.tsx +49 -0
  396. package/src/ui/views/app.ts +99 -0
  397. package/src/ui/views/header.ts +42 -0
  398. package/src/ui/views/input_area.ts +244 -0
  399. package/src/ui/views/message_list.ts +427 -0
  400. package/src/ui/views/status_bar.ts +104 -0
  401. package/src/ui/vue/index.ts +53 -0
  402. package/src/utils/clipboard.ts +39 -0
  403. package/src/utils/clipboard_image.ts +40 -0
  404. package/src/utils/diff.ts +52 -0
  405. package/src/utils/image_preview.ts +36 -0
  406. package/src/utils/models.ts +98 -0
  407. package/src/utils/shell.ts +63 -0
  408. package/src/utils/tool_summary.ts +56 -0
  409. package/src/utils/tool_trace.ts +206 -0
  410. package/tsconfig.json +22 -0
  411. package/vite.config.ts +363 -0
@@ -0,0 +1,375 @@
1
+ import { InputSegment, InputCursor, InputState } from './input_state.js';
2
+
3
+ export const PASTE_BADGE_THRESHOLD = 4;
4
+
5
+ export function normalizeSegments(segments: InputSegment[]): InputSegment[] {
6
+ const normalized: InputSegment[] = [];
7
+ for (const segment of segments) {
8
+ if (segment.type === 'text') {
9
+ if (segment.text.length === 0) continue;
10
+ const last = normalized[normalized.length - 1];
11
+ if (last && last.type === 'text') {
12
+ last.text += segment.text;
13
+ continue;
14
+ }
15
+ }
16
+ normalized.push({ ...segment });
17
+ }
18
+ return normalized;
19
+ }
20
+
21
+ export function clampCursor(segments: InputSegment[], cursor: InputCursor): InputCursor {
22
+ const maxIndex = segments.length;
23
+ let index = Math.max(0, Math.min(cursor.index, maxIndex));
24
+ let offset = cursor.offset;
25
+ if (index === segments.length) {
26
+ return { index, offset: 0 };
27
+ }
28
+ const segment = segments[index];
29
+ if (!segment) return { index, offset: 0 };
30
+ if (segment.type === 'text') {
31
+ offset = Math.max(0, Math.min(offset, segment.text.length));
32
+ return { index, offset };
33
+ }
34
+ return { index, offset: offset > 0 ? 1 : 0 };
35
+ }
36
+
37
+ export function insertText(state: InputState, text: string): InputState {
38
+ if (text.length === 0) return state;
39
+ const segments = [...state.segments];
40
+ const cursor = clampCursor(segments, state.cursor);
41
+
42
+ if (cursor.index === segments.length) {
43
+ const last = segments[segments.length - 1];
44
+ if (last && last.type === 'text') {
45
+ last.text += text;
46
+ } else {
47
+ segments.push({ type: 'text', text });
48
+ }
49
+ return {
50
+ ...state,
51
+ segments: normalizeSegments(segments),
52
+ cursor: { index: segments.length - 1, offset: (segments[segments.length - 1] as any).text.length }
53
+ };
54
+ }
55
+
56
+ const segment = segments[cursor.index];
57
+ if (segment.type === 'text') {
58
+ const before = segment.text.slice(0, cursor.offset);
59
+ const after = segment.text.slice(cursor.offset);
60
+ segment.text = before + text + after;
61
+ return {
62
+ ...state,
63
+ segments: normalizeSegments(segments),
64
+ cursor: { index: cursor.index, offset: cursor.offset + text.length }
65
+ };
66
+ }
67
+
68
+ const insertIndex = cursor.offset === 0 ? cursor.index : cursor.index + 1;
69
+ segments.splice(insertIndex, 0, { type: 'text', text });
70
+ return {
71
+ ...state,
72
+ segments: normalizeSegments(segments),
73
+ cursor: { index: insertIndex, offset: text.length }
74
+ };
75
+ }
76
+
77
+ export function insertSegment(state: InputState, segment: InputSegment): InputState {
78
+ const segments = [...state.segments];
79
+ const cursor = clampCursor(segments, state.cursor);
80
+ const insertIndex = cursor.index === segments.length
81
+ ? segments.length
82
+ : (cursor.offset === 0 ? cursor.index : cursor.index + 1);
83
+ segments.splice(insertIndex, 0, segment);
84
+ return {
85
+ ...state,
86
+ segments: normalizeSegments(segments),
87
+ cursor: { index: insertIndex, offset: segment.type === 'text' ? segment.text.length : 1 }
88
+ };
89
+ }
90
+
91
+ export function insertBadge(state: InputState, segment: InputSegment): InputState {
92
+ const next = insertSegment(state, segment);
93
+ return insertText(next, ' ');
94
+ }
95
+
96
+ export function backspace(state: InputState): InputState {
97
+ const segments = [...state.segments];
98
+ const cursor = clampCursor(segments, state.cursor);
99
+
100
+ if (cursor.index === segments.length) {
101
+ if (segments.length === 0) return state;
102
+ const last = segments[segments.length - 1];
103
+ if (last.type === 'text' && last.text.length > 0) {
104
+ last.text = last.text.slice(0, -1);
105
+ return {
106
+ ...state,
107
+ segments: normalizeSegments(segments),
108
+ cursor: { index: segments.length - 1, offset: last.text.length }
109
+ };
110
+ }
111
+ segments.pop();
112
+ return {
113
+ ...state,
114
+ segments: normalizeSegments(segments),
115
+ cursor: { index: Math.max(0, segments.length - 1), offset: 0 }
116
+ };
117
+ }
118
+
119
+ const segment = segments[cursor.index];
120
+ if (segment.type === 'text') {
121
+ if (cursor.offset > 0) {
122
+ segment.text = segment.text.slice(0, cursor.offset - 1) + segment.text.slice(cursor.offset);
123
+ return {
124
+ ...state,
125
+ segments: normalizeSegments(segments),
126
+ cursor: { index: cursor.index, offset: cursor.offset - 1 }
127
+ };
128
+ }
129
+ if (cursor.index === 0) return state;
130
+ const prev = segments[cursor.index - 1];
131
+ if (prev.type === 'text') {
132
+ const prevLen = prev.text.length;
133
+ prev.text += segment.text;
134
+ segments.splice(cursor.index, 1);
135
+ return {
136
+ ...state,
137
+ segments: normalizeSegments(segments),
138
+ cursor: { index: cursor.index - 1, offset: prevLen }
139
+ };
140
+ }
141
+ segments.splice(cursor.index - 1, 1);
142
+ return {
143
+ ...state,
144
+ segments: normalizeSegments(segments),
145
+ cursor: { index: cursor.index - 1, offset: 0 }
146
+ };
147
+ }
148
+
149
+ if (cursor.offset === 1) {
150
+ segments.splice(cursor.index, 1);
151
+ return {
152
+ ...state,
153
+ segments: normalizeSegments(segments),
154
+ cursor: { index: Math.max(0, cursor.index - 1), offset: 0 }
155
+ };
156
+ }
157
+
158
+ if (cursor.index === 0) return state;
159
+ const prev = segments[cursor.index - 1];
160
+ if (prev.type === 'text') {
161
+ const prevLen = prev.text.length;
162
+ prev.text = prev.text.slice(0, -1);
163
+ return {
164
+ ...state,
165
+ segments: normalizeSegments(segments),
166
+ cursor: { index: cursor.index - 1, offset: Math.max(0, prevLen - 1) }
167
+ };
168
+ }
169
+ segments.splice(cursor.index - 1, 1);
170
+ return {
171
+ ...state,
172
+ segments: normalizeSegments(segments),
173
+ cursor: { index: cursor.index - 1, offset: 0 }
174
+ };
175
+ }
176
+
177
+ export function deleteForward(state: InputState): InputState {
178
+ const segments = [...state.segments];
179
+ const cursor = clampCursor(segments, state.cursor);
180
+
181
+ if (cursor.index === segments.length) return state;
182
+
183
+ const segment = segments[cursor.index];
184
+ if (segment.type === 'text') {
185
+ if (cursor.offset < segment.text.length) {
186
+ segment.text = segment.text.slice(0, cursor.offset) + segment.text.slice(cursor.offset + 1);
187
+ return {
188
+ ...state,
189
+ segments: normalizeSegments(segments),
190
+ cursor
191
+ };
192
+ }
193
+ if (cursor.index + 1 >= segments.length) return state;
194
+ const next = segments[cursor.index + 1];
195
+ if (next.type === 'text') {
196
+ segment.text += next.text;
197
+ segments.splice(cursor.index + 1, 1);
198
+ return {
199
+ ...state,
200
+ segments: normalizeSegments(segments),
201
+ cursor
202
+ };
203
+ }
204
+ segments.splice(cursor.index + 1, 1);
205
+ return {
206
+ ...state,
207
+ segments: normalizeSegments(segments),
208
+ cursor
209
+ };
210
+ }
211
+
212
+ if (cursor.offset === 0) {
213
+ segments.splice(cursor.index, 1);
214
+ return {
215
+ ...state,
216
+ segments: normalizeSegments(segments),
217
+ cursor: { index: Math.min(cursor.index, segments.length), offset: 0 }
218
+ };
219
+ }
220
+
221
+ if (cursor.index + 1 >= segments.length) return state;
222
+ const next = segments[cursor.index + 1];
223
+ if (next.type === 'text') {
224
+ next.text = next.text.slice(1);
225
+ return {
226
+ ...state,
227
+ segments: normalizeSegments(segments),
228
+ cursor: { index: cursor.index + 1, offset: 0 }
229
+ };
230
+ }
231
+ segments.splice(cursor.index + 1, 1);
232
+ return {
233
+ ...state,
234
+ segments: normalizeSegments(segments),
235
+ cursor: { index: cursor.index + 1, offset: 0 }
236
+ };
237
+ }
238
+
239
+ export function moveLeft(state: InputState): InputState {
240
+ const segments = state.segments;
241
+ const cursor = clampCursor(segments, state.cursor);
242
+ if (cursor.index === segments.length) {
243
+ if (segments.length === 0) return state;
244
+ const last = segments[segments.length - 1];
245
+ if (last.type === 'text') {
246
+ return { ...state, cursor: { index: segments.length - 1, offset: last.text.length } };
247
+ }
248
+ return { ...state, cursor: { index: segments.length - 1, offset: 1 } };
249
+ }
250
+ const segment = segments[cursor.index];
251
+ if (segment.type === 'text') {
252
+ if (cursor.offset > 0) return { ...state, cursor: { index: cursor.index, offset: cursor.offset - 1 } };
253
+ } else if (cursor.offset === 1) {
254
+ return { ...state, cursor: { index: cursor.index, offset: 0 } };
255
+ }
256
+ if (cursor.index === 0) return state;
257
+ const prev = segments[cursor.index - 1];
258
+ if (prev.type === 'text') {
259
+ return { ...state, cursor: { index: cursor.index - 1, offset: prev.text.length } };
260
+ }
261
+ return { ...state, cursor: { index: cursor.index - 1, offset: 1 } };
262
+ }
263
+
264
+ export function moveRight(state: InputState): InputState {
265
+ const segments = state.segments;
266
+ const cursor = clampCursor(segments, state.cursor);
267
+ if (cursor.index === segments.length) return state;
268
+ const segment = segments[cursor.index];
269
+ if (segment.type === 'text') {
270
+ if (cursor.offset < segment.text.length) {
271
+ return { ...state, cursor: { index: cursor.index, offset: cursor.offset + 1 } };
272
+ }
273
+ } else if (cursor.offset === 0) {
274
+ return { ...state, cursor: { index: cursor.index, offset: 1 } };
275
+ }
276
+ if (cursor.index + 1 >= segments.length) {
277
+ return { ...state, cursor: { index: segments.length, offset: 0 } };
278
+ }
279
+ const next = segments[cursor.index + 1];
280
+ if (next.type === 'text') {
281
+ return { ...state, cursor: { index: cursor.index + 1, offset: 0 } };
282
+ }
283
+ return { ...state, cursor: { index: cursor.index + 1, offset: 0 } };
284
+ }
285
+
286
+ export function moveWordLeft(state: InputState): InputState {
287
+ const text = getPlainText(state.segments);
288
+ if (text.length === 0) return state;
289
+ const pos = Math.max(0, textCursorIndex(state.segments, state.cursor));
290
+ const before = text.slice(0, pos);
291
+ const match = before.match(/\S+\s*$/);
292
+ const nextPos = match ? pos - match[0].length : 0;
293
+ return { ...state, cursor: cursorFromTextIndex(state.segments, nextPos) };
294
+ }
295
+
296
+ export function moveWordRight(state: InputState): InputState {
297
+ const text = getPlainText(state.segments);
298
+ const pos = Math.max(0, textCursorIndex(state.segments, state.cursor));
299
+ const after = text.slice(pos);
300
+ const match = after.match(/^\s*\S+/);
301
+ const nextPos = match ? pos + match[0].length : text.length;
302
+ return { ...state, cursor: cursorFromTextIndex(state.segments, nextPos) };
303
+ }
304
+
305
+ export function textCursorIndex(segments: InputSegment[], cursor: InputCursor): number {
306
+ let index = 0;
307
+ for (let i = 0; i < segments.length; i += 1) {
308
+ const segment = segments[i];
309
+ if (i === cursor.index) {
310
+ if (segment.type === 'text') return index + cursor.offset;
311
+ return index;
312
+ }
313
+ if (segment.type === 'text') index += segment.text.length;
314
+ }
315
+ return index;
316
+ }
317
+
318
+ export function cursorFromTextIndex(segments: InputSegment[], pos: number): InputCursor {
319
+ let index = 0;
320
+ for (let i = 0; i < segments.length; i += 1) {
321
+ const segment = segments[i];
322
+ if (segment.type !== 'text') continue;
323
+ const next = index + segment.text.length;
324
+ if (pos <= next) {
325
+ return { index: i, offset: Math.max(0, pos - index) };
326
+ }
327
+ index = next;
328
+ }
329
+ return { index: segments.length, offset: 0 };
330
+ }
331
+
332
+ export function getPlainText(segments: InputSegment[]): string {
333
+ return segments.map(segment => {
334
+ switch (segment.type) {
335
+ case 'text':
336
+ return segment.text;
337
+ case 'paste':
338
+ return segment.text;
339
+ case 'file':
340
+ return segment.path;
341
+ case 'image':
342
+ return segment.path;
343
+ default:
344
+ return '';
345
+ }
346
+ }).join('');
347
+ }
348
+
349
+ export function serializeSegments(segments: InputSegment[]): string {
350
+ return segments.map(segment => {
351
+ switch (segment.type) {
352
+ case 'text':
353
+ return segment.text;
354
+ case 'paste': {
355
+ const lines = segment.text.split('\n').length;
356
+ return `\n[pasted ${lines} line${lines === 1 ? '' : 's'}]\n${segment.text}\n[/pasted]\n`;
357
+ }
358
+ case 'file':
359
+ return `\n[file ${segment.path}]\n`;
360
+ case 'image':
361
+ return `\n[image ${segment.path}]\n`;
362
+ default:
363
+ return '';
364
+ }
365
+ }).join('');
366
+ }
367
+
368
+ export function createEmptyState(): InputState {
369
+ return {
370
+ segments: [],
371
+ cursor: { index: 0, offset: 0 },
372
+ history: [],
373
+ historyIdx: -1
374
+ };
375
+ }
@@ -0,0 +1,17 @@
1
+ export type InputSegment =
2
+ | { type: 'text'; text: string }
3
+ | { type: 'paste'; text: string }
4
+ | { type: 'file'; path: string }
5
+ | { type: 'image'; path: string };
6
+
7
+ export interface InputCursor {
8
+ index: number;
9
+ offset: number;
10
+ }
11
+
12
+ export interface InputState {
13
+ segments: InputSegment[];
14
+ cursor: InputCursor;
15
+ history: string[];
16
+ historyIdx: number;
17
+ }
@@ -0,0 +1,122 @@
1
+ import Yoga, { Node } from 'yoga-layout';
2
+ import { LayoutNode, Style, TextNode } from './types.js';
3
+
4
+ export interface LayoutFrame {
5
+ node: LayoutNode;
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ children: LayoutFrame[];
11
+ }
12
+
13
+ function applyStyle(node: Node, style?: Style): void {
14
+ if (!style) return;
15
+
16
+ if (style.flexDirection) {
17
+ node.setFlexDirection(
18
+ style.flexDirection === 'row' ? Yoga.FLEX_DIRECTION_ROW : Yoga.FLEX_DIRECTION_COLUMN
19
+ );
20
+ }
21
+ if (style.flexGrow !== undefined) node.setFlexGrow(style.flexGrow);
22
+ if (style.flexShrink !== undefined) node.setFlexShrink(style.flexShrink);
23
+ if (style.width !== undefined) node.setWidth(style.width);
24
+ if (style.height !== undefined) node.setHeight(style.height);
25
+ if (style.alignItems) {
26
+ const map = {
27
+ 'flex-start': Yoga.ALIGN_FLEX_START,
28
+ 'center': Yoga.ALIGN_CENTER,
29
+ 'flex-end': Yoga.ALIGN_FLEX_END,
30
+ 'stretch': Yoga.ALIGN_STRETCH
31
+ } as const;
32
+ node.setAlignItems(map[style.alignItems]);
33
+ }
34
+ if (style.justifyContent) {
35
+ const map = {
36
+ 'flex-start': Yoga.JUSTIFY_FLEX_START,
37
+ 'center': Yoga.JUSTIFY_CENTER,
38
+ 'flex-end': Yoga.JUSTIFY_FLEX_END,
39
+ 'space-between': Yoga.JUSTIFY_SPACE_BETWEEN
40
+ } as const;
41
+ node.setJustifyContent(map[style.justifyContent]);
42
+ }
43
+
44
+ const paddingX = style.paddingX ?? style.padding ?? 0;
45
+ const paddingY = style.paddingY ?? style.padding ?? 0;
46
+ const marginX = style.marginX ?? style.margin ?? 0;
47
+ const marginY = style.marginY ?? style.margin ?? 0;
48
+
49
+ node.setPadding(Yoga.EDGE_LEFT, style.paddingLeft ?? paddingX);
50
+ node.setPadding(Yoga.EDGE_RIGHT, style.paddingRight ?? paddingX);
51
+ node.setPadding(Yoga.EDGE_TOP, style.paddingTop ?? paddingY);
52
+ node.setPadding(Yoga.EDGE_BOTTOM, style.paddingBottom ?? paddingY);
53
+
54
+ node.setMargin(Yoga.EDGE_LEFT, style.marginLeft ?? marginX);
55
+ node.setMargin(Yoga.EDGE_RIGHT, style.marginRight ?? marginX);
56
+ node.setMargin(Yoga.EDGE_TOP, style.marginTop ?? marginY);
57
+ node.setMargin(Yoga.EDGE_BOTTOM, style.marginBottom ?? marginY);
58
+ }
59
+
60
+ function measureText(node: TextNode, width?: number): { width: number; height: number } {
61
+ const text = node.text || '';
62
+ const wrap = node.style?.wrap ?? 'wrap';
63
+ if (!width || width <= 0) {
64
+ return { width: text.length, height: 1 };
65
+ }
66
+
67
+ if (wrap === 'truncate-end') {
68
+ return { width: Math.min(text.length, width), height: 1 };
69
+ }
70
+
71
+ const lines = Math.max(1, Math.ceil(text.length / width));
72
+ const lineWidth = Math.min(text.length, width);
73
+ return { width: lineWidth, height: lines };
74
+ }
75
+
76
+ function buildYogaTree(node: LayoutNode): Node {
77
+ const yogaNode = Yoga.Node.create();
78
+ applyStyle(yogaNode, node.type === 'box' ? node.style : undefined);
79
+
80
+ if (node.type === 'text') {
81
+ yogaNode.setMeasureFunc((width, widthMode) => {
82
+ const availableWidth = widthMode === Yoga.MEASURE_MODE_UNDEFINED ? undefined : width;
83
+ const measured = measureText(node, availableWidth);
84
+ return { width: measured.width, height: measured.height };
85
+ });
86
+ } else {
87
+ for (const child of node.children) {
88
+ yogaNode.insertChild(buildYogaTree(child), yogaNode.getChildCount());
89
+ }
90
+ }
91
+
92
+ return yogaNode;
93
+ }
94
+
95
+ function buildFrameTree(node: LayoutNode, yogaNode: Node): LayoutFrame {
96
+ const children: LayoutFrame[] = [];
97
+ if (node.type === 'box') {
98
+ for (let i = 0; i < node.children.length; i += 1) {
99
+ children.push(buildFrameTree(node.children[i], yogaNode.getChild(i)));
100
+ }
101
+ }
102
+
103
+ return {
104
+ node,
105
+ x: yogaNode.getComputedLeft(),
106
+ y: yogaNode.getComputedTop(),
107
+ width: yogaNode.getComputedWidth(),
108
+ height: yogaNode.getComputedHeight(),
109
+ children
110
+ };
111
+ }
112
+
113
+ export function computeLayout(root: LayoutNode, width: number, height: number): LayoutFrame {
114
+ const yogaRoot = buildYogaTree(root);
115
+ yogaRoot.setWidth(width);
116
+ yogaRoot.setHeight(height);
117
+ yogaRoot.calculateLayout(width, height, Yoga.DIRECTION_LTR);
118
+
119
+ const frame = buildFrameTree(root, yogaRoot);
120
+ yogaRoot.freeRecursive();
121
+ return frame;
122
+ }
@@ -0,0 +1,38 @@
1
+ import { Style } from './types.js';
2
+
3
+ export function toCssStyle(style?: Style): Record<string, string | number> {
4
+ if (!style) return {};
5
+
6
+ const paddingX = style.paddingX ?? style.padding ?? 0;
7
+ const paddingY = style.paddingY ?? style.padding ?? 0;
8
+ const marginX = style.marginX ?? style.margin ?? 0;
9
+ const marginY = style.marginY ?? style.margin ?? 0;
10
+
11
+ const css: Record<string, string | number> = {
12
+ display: 'flex',
13
+ flexDirection: style.flexDirection || 'column',
14
+ flexGrow: style.flexGrow ?? 0,
15
+ flexShrink: style.flexShrink ?? 0,
16
+ paddingLeft: style.paddingLeft ?? paddingX,
17
+ paddingRight: style.paddingRight ?? paddingX,
18
+ paddingTop: style.paddingTop ?? paddingY,
19
+ paddingBottom: style.paddingBottom ?? paddingY,
20
+ marginLeft: style.marginLeft ?? marginX,
21
+ marginRight: style.marginRight ?? marginX,
22
+ marginTop: style.marginTop ?? marginY,
23
+ marginBottom: style.marginBottom ?? marginY
24
+ };
25
+
26
+ if (style.alignItems) css.alignItems = style.alignItems;
27
+ if (style.justifyContent) css.justifyContent = style.justifyContent;
28
+
29
+ if (style.width !== undefined) css.width = style.width;
30
+ if (style.height !== undefined) css.height = style.height;
31
+ if (style.borderStyle) {
32
+ css.borderStyle = style.borderStyle;
33
+ css.borderWidth = 1;
34
+ css.borderColor = style.borderColor || 'currentColor';
35
+ }
36
+
37
+ return css;
38
+ }
@@ -0,0 +1,53 @@
1
+ export type LayoutNode = BoxNode | TextNode;
2
+
3
+ export interface Style {
4
+ flexDirection?: 'row' | 'column';
5
+ flexGrow?: number;
6
+ flexShrink?: number;
7
+ width?: number;
8
+ height?: number;
9
+ padding?: number;
10
+ paddingX?: number;
11
+ paddingY?: number;
12
+ paddingLeft?: number;
13
+ paddingRight?: number;
14
+ paddingTop?: number;
15
+ paddingBottom?: number;
16
+ margin?: number;
17
+ marginX?: number;
18
+ marginY?: number;
19
+ marginLeft?: number;
20
+ marginRight?: number;
21
+ marginTop?: number;
22
+ marginBottom?: number;
23
+ alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch';
24
+ justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between';
25
+ borderStyle?: string;
26
+ borderColor?: string;
27
+ }
28
+
29
+ export interface TextStyle {
30
+ color?: string;
31
+ dimColor?: boolean;
32
+ bold?: boolean;
33
+ inverse?: boolean;
34
+ wrap?: 'wrap' | 'truncate-end';
35
+ badge?: {
36
+ type: 'paste' | 'file' | 'image';
37
+ preview: string;
38
+ full: string;
39
+ path?: string;
40
+ };
41
+ }
42
+
43
+ export interface BoxNode {
44
+ type: 'box';
45
+ style?: Style;
46
+ children: LayoutNode[];
47
+ }
48
+
49
+ export interface TextNode {
50
+ type: 'text';
51
+ text: string;
52
+ style?: TextStyle;
53
+ }
@@ -0,0 +1 @@
1
+ export { InkNode } from './render.js';
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { Box, Text, type BoxProps } from 'ink';
3
+ import { LayoutNode, TextNode } from '../core/types.js';
4
+
5
+ function renderText(node: TextNode): React.ReactElement {
6
+ const style = node.style || {};
7
+ return (
8
+ <Text
9
+ color={style.color}
10
+ dimColor={style.dimColor}
11
+ bold={style.bold}
12
+ inverse={style.inverse}
13
+ wrap={style.wrap}
14
+ >
15
+ {node.text}
16
+ </Text>
17
+ );
18
+ }
19
+
20
+ export function InkNode({ node }: { node: LayoutNode }): React.ReactElement {
21
+ if (node.type === 'text') {
22
+ return renderText(node);
23
+ }
24
+
25
+ const style = node.style || {};
26
+ return (
27
+ <Box
28
+ flexDirection={style.flexDirection}
29
+ flexGrow={style.flexGrow}
30
+ flexShrink={style.flexShrink}
31
+ width={style.width}
32
+ height={style.height}
33
+ padding={style.padding}
34
+ paddingX={style.paddingX}
35
+ paddingY={style.paddingY}
36
+ margin={style.margin}
37
+ marginX={style.marginX}
38
+ marginY={style.marginY}
39
+ alignItems={style.alignItems}
40
+ justifyContent={style.justifyContent}
41
+ borderStyle={style.borderStyle as BoxProps['borderStyle']}
42
+ borderColor={style.borderColor}
43
+ >
44
+ {node.children.map((child, index) => (
45
+ <InkNode key={`${child.type}-${index}`} node={child} />
46
+ ))}
47
+ </Box>
48
+ );
49
+ }