plugsuits 1.0.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 (560) hide show
  1. package/cli.js +3 -0
  2. package/dist/agent-reasoning-default.test.d.ts +2 -0
  3. package/dist/agent-reasoning-default.test.d.ts.map +1 -0
  4. package/dist/agent-reasoning-default.test.js +38 -0
  5. package/dist/agent-reasoning-default.test.js.map +1 -0
  6. package/dist/agent.d.ts +61 -0
  7. package/dist/agent.d.ts.map +1 -0
  8. package/dist/agent.js +308 -0
  9. package/dist/agent.js.map +1 -0
  10. package/dist/agent.test.d.ts +2 -0
  11. package/dist/agent.test.d.ts.map +1 -0
  12. package/dist/agent.test.js +38 -0
  13. package/dist/agent.test.js.map +1 -0
  14. package/dist/cli-args.d.ts +15 -0
  15. package/dist/cli-args.d.ts.map +1 -0
  16. package/dist/cli-args.js +63 -0
  17. package/dist/cli-args.js.map +1 -0
  18. package/dist/cli-args.test.d.ts +2 -0
  19. package/dist/cli-args.test.d.ts.map +1 -0
  20. package/dist/cli-args.test.js +105 -0
  21. package/dist/cli-args.test.js.map +1 -0
  22. package/dist/commands/aliases-and-tool-fallback.test.d.ts +2 -0
  23. package/dist/commands/aliases-and-tool-fallback.test.d.ts.map +1 -0
  24. package/dist/commands/aliases-and-tool-fallback.test.js +132 -0
  25. package/dist/commands/aliases-and-tool-fallback.test.js.map +1 -0
  26. package/dist/commands/clear.d.ts +3 -0
  27. package/dist/commands/clear.d.ts.map +1 -0
  28. package/dist/commands/clear.js +12 -0
  29. package/dist/commands/clear.js.map +1 -0
  30. package/dist/commands/factories/create-toggle-command.d.ts +13 -0
  31. package/dist/commands/factories/create-toggle-command.d.ts.map +1 -0
  32. package/dist/commands/factories/create-toggle-command.js +38 -0
  33. package/dist/commands/factories/create-toggle-command.js.map +1 -0
  34. package/dist/commands/help.d.ts +3 -0
  35. package/dist/commands/help.d.ts.map +1 -0
  36. package/dist/commands/help.js +23 -0
  37. package/dist/commands/help.js.map +1 -0
  38. package/dist/commands/index.d.ts +18 -0
  39. package/dist/commands/index.d.ts.map +1 -0
  40. package/dist/commands/index.js +82 -0
  41. package/dist/commands/index.js.map +1 -0
  42. package/dist/commands/model.d.ts +15 -0
  43. package/dist/commands/model.d.ts.map +1 -0
  44. package/dist/commands/model.js +100 -0
  45. package/dist/commands/model.js.map +1 -0
  46. package/dist/commands/reasoning-mode.d.ts +3 -0
  47. package/dist/commands/reasoning-mode.d.ts.map +1 -0
  48. package/dist/commands/reasoning-mode.js +47 -0
  49. package/dist/commands/reasoning-mode.js.map +1 -0
  50. package/dist/commands/render.d.ts +19 -0
  51. package/dist/commands/render.d.ts.map +1 -0
  52. package/dist/commands/render.js +140 -0
  53. package/dist/commands/render.js.map +1 -0
  54. package/dist/commands/render.test.d.ts +2 -0
  55. package/dist/commands/render.test.d.ts.map +1 -0
  56. package/dist/commands/render.test.js +36 -0
  57. package/dist/commands/render.test.js.map +1 -0
  58. package/dist/commands/tool-fallback.d.ts +3 -0
  59. package/dist/commands/tool-fallback.d.ts.map +1 -0
  60. package/dist/commands/tool-fallback.js +38 -0
  61. package/dist/commands/tool-fallback.js.map +1 -0
  62. package/dist/commands/translate.d.ts +3 -0
  63. package/dist/commands/translate.d.ts.map +1 -0
  64. package/dist/commands/translate.js +12 -0
  65. package/dist/commands/translate.js.map +1 -0
  66. package/dist/commands/translate.test.d.ts +2 -0
  67. package/dist/commands/translate.test.d.ts.map +1 -0
  68. package/dist/commands/translate.test.js +49 -0
  69. package/dist/commands/translate.test.js.map +1 -0
  70. package/dist/commands/types.d.ts +17 -0
  71. package/dist/commands/types.d.ts.map +1 -0
  72. package/dist/commands/types.js +2 -0
  73. package/dist/commands/types.js.map +1 -0
  74. package/dist/context/environment-context.d.ts +2 -0
  75. package/dist/context/environment-context.d.ts.map +1 -0
  76. package/dist/context/environment-context.js +11 -0
  77. package/dist/context/environment-context.js.map +1 -0
  78. package/dist/context/paths.d.ts +3 -0
  79. package/dist/context/paths.d.ts.map +1 -0
  80. package/dist/context/paths.js +3 -0
  81. package/dist/context/paths.js.map +1 -0
  82. package/dist/context/session.d.ts +4 -0
  83. package/dist/context/session.d.ts.map +1 -0
  84. package/dist/context/session.js +16 -0
  85. package/dist/context/session.js.map +1 -0
  86. package/dist/context/skill-command-prefix.d.ts +4 -0
  87. package/dist/context/skill-command-prefix.d.ts.map +1 -0
  88. package/dist/context/skill-command-prefix.js +15 -0
  89. package/dist/context/skill-command-prefix.js.map +1 -0
  90. package/dist/context/skills-integration.test.d.ts +2 -0
  91. package/dist/context/skills-integration.test.d.ts.map +1 -0
  92. package/dist/context/skills-integration.test.js +87 -0
  93. package/dist/context/skills-integration.test.js.map +1 -0
  94. package/dist/context/skills.d.ts +18 -0
  95. package/dist/context/skills.d.ts.map +1 -0
  96. package/dist/context/skills.js +431 -0
  97. package/dist/context/skills.js.map +1 -0
  98. package/dist/context/skills.test.d.ts +2 -0
  99. package/dist/context/skills.test.d.ts.map +1 -0
  100. package/dist/context/skills.test.js +20 -0
  101. package/dist/context/skills.test.js.map +1 -0
  102. package/dist/context/system-prompt.d.ts +2 -0
  103. package/dist/context/system-prompt.d.ts.map +1 -0
  104. package/dist/context/system-prompt.js +100 -0
  105. package/dist/context/system-prompt.js.map +1 -0
  106. package/dist/context/translation-integration.test.d.ts +2 -0
  107. package/dist/context/translation-integration.test.d.ts.map +1 -0
  108. package/dist/context/translation-integration.test.js +138 -0
  109. package/dist/context/translation-integration.test.js.map +1 -0
  110. package/dist/context/translation.d.ts +21 -0
  111. package/dist/context/translation.d.ts.map +1 -0
  112. package/dist/context/translation.js +82 -0
  113. package/dist/context/translation.js.map +1 -0
  114. package/dist/context/translation.test.d.ts +2 -0
  115. package/dist/context/translation.test.d.ts.map +1 -0
  116. package/dist/context/translation.test.js +129 -0
  117. package/dist/context/translation.test.js.map +1 -0
  118. package/dist/entrypoints/cli-input-rendering.test.d.ts +2 -0
  119. package/dist/entrypoints/cli-input-rendering.test.d.ts.map +1 -0
  120. package/dist/entrypoints/cli-input-rendering.test.js +192 -0
  121. package/dist/entrypoints/cli-input-rendering.test.js.map +1 -0
  122. package/dist/entrypoints/cli.d.ts +3 -0
  123. package/dist/entrypoints/cli.d.ts.map +1 -0
  124. package/dist/entrypoints/cli.js +1268 -0
  125. package/dist/entrypoints/cli.js.map +1 -0
  126. package/dist/entrypoints/headless-agent-config.d.ts +21 -0
  127. package/dist/entrypoints/headless-agent-config.d.ts.map +1 -0
  128. package/dist/entrypoints/headless-agent-config.js +15 -0
  129. package/dist/entrypoints/headless-agent-config.js.map +1 -0
  130. package/dist/entrypoints/headless-agent-config.test.d.ts +2 -0
  131. package/dist/entrypoints/headless-agent-config.test.d.ts.map +1 -0
  132. package/dist/entrypoints/headless-agent-config.test.js +63 -0
  133. package/dist/entrypoints/headless-agent-config.test.js.map +1 -0
  134. package/dist/entrypoints/headless.d.ts +3 -0
  135. package/dist/entrypoints/headless.d.ts.map +1 -0
  136. package/dist/entrypoints/headless.js +396 -0
  137. package/dist/entrypoints/headless.js.map +1 -0
  138. package/dist/env.d.ts +8 -0
  139. package/dist/env.d.ts.map +1 -0
  140. package/dist/env.js +14 -0
  141. package/dist/env.js.map +1 -0
  142. package/dist/friendli-models.d.ts +21 -0
  143. package/dist/friendli-models.d.ts.map +1 -0
  144. package/dist/friendli-models.js +57 -0
  145. package/dist/friendli-models.js.map +1 -0
  146. package/dist/friendli-reasoning.d.ts +10 -0
  147. package/dist/friendli-reasoning.d.ts.map +1 -0
  148. package/dist/friendli-reasoning.js +181 -0
  149. package/dist/friendli-reasoning.js.map +1 -0
  150. package/dist/friendli-reasoning.test.d.ts +2 -0
  151. package/dist/friendli-reasoning.test.d.ts.map +1 -0
  152. package/dist/friendli-reasoning.test.js +77 -0
  153. package/dist/friendli-reasoning.test.js.map +1 -0
  154. package/dist/index.d.ts +3 -0
  155. package/dist/index.d.ts.map +1 -0
  156. package/dist/index.js +3 -0
  157. package/dist/index.js.map +1 -0
  158. package/dist/interaction/colors.d.ts +22 -0
  159. package/dist/interaction/colors.d.ts.map +1 -0
  160. package/dist/interaction/colors.js +24 -0
  161. package/dist/interaction/colors.js.map +1 -0
  162. package/dist/interaction/pi-tui-stream-renderer.d.ts +19 -0
  163. package/dist/interaction/pi-tui-stream-renderer.d.ts.map +1 -0
  164. package/dist/interaction/pi-tui-stream-renderer.js +1509 -0
  165. package/dist/interaction/pi-tui-stream-renderer.js.map +1 -0
  166. package/dist/interaction/pi-tui-stream-renderer.test.d.ts +2 -0
  167. package/dist/interaction/pi-tui-stream-renderer.test.d.ts.map +1 -0
  168. package/dist/interaction/pi-tui-stream-renderer.test.js +1314 -0
  169. package/dist/interaction/pi-tui-stream-renderer.test.js.map +1 -0
  170. package/dist/interaction/spinner.d.ts +13 -0
  171. package/dist/interaction/spinner.d.ts.map +1 -0
  172. package/dist/interaction/spinner.js +51 -0
  173. package/dist/interaction/spinner.js.map +1 -0
  174. package/dist/middleware/index.d.ts +7 -0
  175. package/dist/middleware/index.d.ts.map +1 -0
  176. package/dist/middleware/index.js +15 -0
  177. package/dist/middleware/index.js.map +1 -0
  178. package/dist/middleware/todo-continuation.d.ts +11 -0
  179. package/dist/middleware/todo-continuation.d.ts.map +1 -0
  180. package/dist/middleware/todo-continuation.js +103 -0
  181. package/dist/middleware/todo-continuation.js.map +1 -0
  182. package/dist/middleware/trim-leading-newlines.d.ts +3 -0
  183. package/dist/middleware/trim-leading-newlines.d.ts.map +1 -0
  184. package/dist/middleware/trim-leading-newlines.js +49 -0
  185. package/dist/middleware/trim-leading-newlines.js.map +1 -0
  186. package/dist/reasoning-mode.d.ts +5 -0
  187. package/dist/reasoning-mode.d.ts.map +1 -0
  188. package/dist/reasoning-mode.js +30 -0
  189. package/dist/reasoning-mode.js.map +1 -0
  190. package/dist/reasoning-mode.test.d.ts +2 -0
  191. package/dist/reasoning-mode.test.d.ts.map +1 -0
  192. package/dist/reasoning-mode.test.js +22 -0
  193. package/dist/reasoning-mode.test.js.map +1 -0
  194. package/dist/tool-fallback-mode.d.ts +6 -0
  195. package/dist/tool-fallback-mode.d.ts.map +1 -0
  196. package/dist/tool-fallback-mode.js +25 -0
  197. package/dist/tool-fallback-mode.js.map +1 -0
  198. package/dist/tools/execute/shell-execute.d.ts +17 -0
  199. package/dist/tools/execute/shell-execute.d.ts.map +1 -0
  200. package/dist/tools/execute/shell-execute.js +55 -0
  201. package/dist/tools/execute/shell-execute.js.map +1 -0
  202. package/dist/tools/execute/shell-execute.test.d.ts +2 -0
  203. package/dist/tools/execute/shell-execute.test.d.ts.map +1 -0
  204. package/dist/tools/execute/shell-execute.test.js +86 -0
  205. package/dist/tools/execute/shell-execute.test.js.map +1 -0
  206. package/dist/tools/execute/shell-interact.d.ts +10 -0
  207. package/dist/tools/execute/shell-interact.d.ts.map +1 -0
  208. package/dist/tools/execute/shell-interact.js +122 -0
  209. package/dist/tools/execute/shell-interact.js.map +1 -0
  210. package/dist/tools/execute/shell-interact.test.d.ts +2 -0
  211. package/dist/tools/execute/shell-interact.test.d.ts.map +1 -0
  212. package/dist/tools/execute/shell-interact.test.js +175 -0
  213. package/dist/tools/execute/shell-interact.test.js.map +1 -0
  214. package/dist/tools/explore/glob.d.ts +15 -0
  215. package/dist/tools/explore/glob.d.ts.map +1 -0
  216. package/dist/tools/explore/glob.js +107 -0
  217. package/dist/tools/explore/glob.js.map +1 -0
  218. package/dist/tools/explore/glob.test.d.ts +2 -0
  219. package/dist/tools/explore/glob.test.d.ts.map +1 -0
  220. package/dist/tools/explore/glob.test.js +183 -0
  221. package/dist/tools/explore/glob.test.js.map +1 -0
  222. package/dist/tools/explore/grep.d.ts +27 -0
  223. package/dist/tools/explore/grep.d.ts.map +1 -0
  224. package/dist/tools/explore/grep.js +203 -0
  225. package/dist/tools/explore/grep.js.map +1 -0
  226. package/dist/tools/explore/grep.test.d.ts +2 -0
  227. package/dist/tools/explore/grep.test.d.ts.map +1 -0
  228. package/dist/tools/explore/grep.test.js +132 -0
  229. package/dist/tools/explore/grep.test.js.map +1 -0
  230. package/dist/tools/explore/read-file.d.ts +23 -0
  231. package/dist/tools/explore/read-file.d.ts.map +1 -0
  232. package/dist/tools/explore/read-file.js +84 -0
  233. package/dist/tools/explore/read-file.js.map +1 -0
  234. package/dist/tools/explore/read-file.test.d.ts +2 -0
  235. package/dist/tools/explore/read-file.test.d.ts.map +1 -0
  236. package/dist/tools/explore/read-file.test.js +278 -0
  237. package/dist/tools/explore/read-file.test.js.map +1 -0
  238. package/dist/tools/index.d.ts +71 -0
  239. package/dist/tools/index.d.ts.map +1 -0
  240. package/dist/tools/index.js +26 -0
  241. package/dist/tools/index.js.map +1 -0
  242. package/dist/tools/modify/delete-file.d.ts +19 -0
  243. package/dist/tools/modify/delete-file.d.ts.map +1 -0
  244. package/dist/tools/modify/delete-file.js +71 -0
  245. package/dist/tools/modify/delete-file.js.map +1 -0
  246. package/dist/tools/modify/delete-file.test.d.ts +2 -0
  247. package/dist/tools/modify/delete-file.test.d.ts.map +1 -0
  248. package/dist/tools/modify/delete-file.test.js +136 -0
  249. package/dist/tools/modify/delete-file.test.js.map +1 -0
  250. package/dist/tools/modify/edit-file-diagnostics.d.ts +17 -0
  251. package/dist/tools/modify/edit-file-diagnostics.d.ts.map +1 -0
  252. package/dist/tools/modify/edit-file-diagnostics.js +157 -0
  253. package/dist/tools/modify/edit-file-diagnostics.js.map +1 -0
  254. package/dist/tools/modify/edit-file-repair.d.ts +13 -0
  255. package/dist/tools/modify/edit-file-repair.d.ts.map +1 -0
  256. package/dist/tools/modify/edit-file-repair.js +135 -0
  257. package/dist/tools/modify/edit-file-repair.js.map +1 -0
  258. package/dist/tools/modify/edit-file-stress.test.d.ts +2 -0
  259. package/dist/tools/modify/edit-file-stress.test.d.ts.map +1 -0
  260. package/dist/tools/modify/edit-file-stress.test.js +163 -0
  261. package/dist/tools/modify/edit-file-stress.test.js.map +1 -0
  262. package/dist/tools/modify/edit-file-validation.d.ts +9 -0
  263. package/dist/tools/modify/edit-file-validation.d.ts.map +1 -0
  264. package/dist/tools/modify/edit-file-validation.js +86 -0
  265. package/dist/tools/modify/edit-file-validation.js.map +1 -0
  266. package/dist/tools/modify/edit-file-whitespace.test.d.ts +2 -0
  267. package/dist/tools/modify/edit-file-whitespace.test.d.ts.map +1 -0
  268. package/dist/tools/modify/edit-file-whitespace.test.js +90 -0
  269. package/dist/tools/modify/edit-file-whitespace.test.js.map +1 -0
  270. package/dist/tools/modify/edit-file.d.ts +33 -0
  271. package/dist/tools/modify/edit-file.d.ts.map +1 -0
  272. package/dist/tools/modify/edit-file.js +177 -0
  273. package/dist/tools/modify/edit-file.js.map +1 -0
  274. package/dist/tools/modify/edit-file.test.d.ts +2 -0
  275. package/dist/tools/modify/edit-file.test.d.ts.map +1 -0
  276. package/dist/tools/modify/edit-file.test.js +948 -0
  277. package/dist/tools/modify/edit-file.test.js.map +1 -0
  278. package/dist/tools/modify/write-file.d.ts +17 -0
  279. package/dist/tools/modify/write-file.d.ts.map +1 -0
  280. package/dist/tools/modify/write-file.js +39 -0
  281. package/dist/tools/modify/write-file.js.map +1 -0
  282. package/dist/tools/modify/write-file.test.d.ts +2 -0
  283. package/dist/tools/modify/write-file.test.d.ts.map +1 -0
  284. package/dist/tools/modify/write-file.test.js +168 -0
  285. package/dist/tools/modify/write-file.test.js.map +1 -0
  286. package/dist/tools/planning/load-skill.d.ts +13 -0
  287. package/dist/tools/planning/load-skill.d.ts.map +1 -0
  288. package/dist/tools/planning/load-skill.js +101 -0
  289. package/dist/tools/planning/load-skill.js.map +1 -0
  290. package/dist/tools/planning/load-skill.test.d.ts +2 -0
  291. package/dist/tools/planning/load-skill.test.d.ts.map +1 -0
  292. package/dist/tools/planning/load-skill.test.js +37 -0
  293. package/dist/tools/planning/load-skill.test.js.map +1 -0
  294. package/dist/tools/planning/todo-write.d.ts +49 -0
  295. package/dist/tools/planning/todo-write.d.ts.map +1 -0
  296. package/dist/tools/planning/todo-write.js +118 -0
  297. package/dist/tools/planning/todo-write.js.map +1 -0
  298. package/dist/tools/planning/todo-write.test.d.ts +2 -0
  299. package/dist/tools/planning/todo-write.test.d.ts.map +1 -0
  300. package/dist/tools/planning/todo-write.test.js +82 -0
  301. package/dist/tools/planning/todo-write.test.js.map +1 -0
  302. package/dist/tools/utils/execute/format-utils.d.ts +4 -0
  303. package/dist/tools/utils/execute/format-utils.d.ts.map +1 -0
  304. package/dist/tools/utils/execute/format-utils.js +31 -0
  305. package/dist/tools/utils/execute/format-utils.js.map +1 -0
  306. package/dist/tools/utils/execute/format-utils.test.d.ts +2 -0
  307. package/dist/tools/utils/execute/format-utils.test.d.ts.map +1 -0
  308. package/dist/tools/utils/execute/format-utils.test.js +40 -0
  309. package/dist/tools/utils/execute/format-utils.test.js.map +1 -0
  310. package/dist/tools/utils/execute/noninteractive-wrapper.d.ts +12 -0
  311. package/dist/tools/utils/execute/noninteractive-wrapper.d.ts.map +1 -0
  312. package/dist/tools/utils/execute/noninteractive-wrapper.js +269 -0
  313. package/dist/tools/utils/execute/noninteractive-wrapper.js.map +1 -0
  314. package/dist/tools/utils/execute/noninteractive-wrapper.test.d.ts +2 -0
  315. package/dist/tools/utils/execute/noninteractive-wrapper.test.d.ts.map +1 -0
  316. package/dist/tools/utils/execute/noninteractive-wrapper.test.js +233 -0
  317. package/dist/tools/utils/execute/noninteractive-wrapper.test.js.map +1 -0
  318. package/dist/tools/utils/execute/output-handler.d.ts +14 -0
  319. package/dist/tools/utils/execute/output-handler.d.ts.map +1 -0
  320. package/dist/tools/utils/execute/output-handler.js +71 -0
  321. package/dist/tools/utils/execute/output-handler.js.map +1 -0
  322. package/dist/tools/utils/execute/output-handler.test.d.ts +2 -0
  323. package/dist/tools/utils/execute/output-handler.test.d.ts.map +1 -0
  324. package/dist/tools/utils/execute/output-handler.test.js +58 -0
  325. package/dist/tools/utils/execute/output-handler.test.js.map +1 -0
  326. package/dist/tools/utils/execute/process-manager.d.ts +17 -0
  327. package/dist/tools/utils/execute/process-manager.d.ts.map +1 -0
  328. package/dist/tools/utils/execute/process-manager.js +229 -0
  329. package/dist/tools/utils/execute/process-manager.js.map +1 -0
  330. package/dist/tools/utils/execute/process-manager.test.d.ts +2 -0
  331. package/dist/tools/utils/execute/process-manager.test.d.ts.map +1 -0
  332. package/dist/tools/utils/execute/process-manager.test.js +139 -0
  333. package/dist/tools/utils/execute/process-manager.test.js.map +1 -0
  334. package/dist/tools/utils/execute/shell-detection.d.ts +3 -0
  335. package/dist/tools/utils/execute/shell-detection.d.ts.map +1 -0
  336. package/dist/tools/utils/execute/shell-detection.js +56 -0
  337. package/dist/tools/utils/execute/shell-detection.js.map +1 -0
  338. package/dist/tools/utils/execute/shell-detection.test.d.ts +2 -0
  339. package/dist/tools/utils/execute/shell-detection.test.d.ts.map +1 -0
  340. package/dist/tools/utils/execute/shell-detection.test.js +86 -0
  341. package/dist/tools/utils/execute/shell-detection.test.js.map +1 -0
  342. package/dist/tools/utils/hashline/autocorrect-replacement-lines.d.ts +5 -0
  343. package/dist/tools/utils/hashline/autocorrect-replacement-lines.d.ts.map +1 -0
  344. package/dist/tools/utils/hashline/autocorrect-replacement-lines.js +113 -0
  345. package/dist/tools/utils/hashline/autocorrect-replacement-lines.js.map +1 -0
  346. package/dist/tools/utils/hashline/constants.d.ts +5 -0
  347. package/dist/tools/utils/hashline/constants.d.ts.map +1 -0
  348. package/dist/tools/utils/hashline/constants.js +11 -0
  349. package/dist/tools/utils/hashline/constants.js.map +1 -0
  350. package/dist/tools/utils/hashline/diff-utils.d.ts +7 -0
  351. package/dist/tools/utils/hashline/diff-utils.d.ts.map +1 -0
  352. package/dist/tools/utils/hashline/diff-utils.js +50 -0
  353. package/dist/tools/utils/hashline/diff-utils.js.map +1 -0
  354. package/dist/tools/utils/hashline/diff-utils.test.d.ts +2 -0
  355. package/dist/tools/utils/hashline/diff-utils.test.d.ts.map +1 -0
  356. package/dist/tools/utils/hashline/diff-utils.test.js +46 -0
  357. package/dist/tools/utils/hashline/diff-utils.test.js.map +1 -0
  358. package/dist/tools/utils/hashline/edit-deduplication.d.ts +6 -0
  359. package/dist/tools/utils/hashline/edit-deduplication.d.ts.map +1 -0
  360. package/dist/tools/utils/hashline/edit-deduplication.js +32 -0
  361. package/dist/tools/utils/hashline/edit-deduplication.js.map +1 -0
  362. package/dist/tools/utils/hashline/edit-operation-primitives.d.ts +11 -0
  363. package/dist/tools/utils/hashline/edit-operation-primitives.d.ts.map +1 -0
  364. package/dist/tools/utils/hashline/edit-operation-primitives.js +93 -0
  365. package/dist/tools/utils/hashline/edit-operation-primitives.js.map +1 -0
  366. package/dist/tools/utils/hashline/edit-operations.d.ts +9 -0
  367. package/dist/tools/utils/hashline/edit-operations.d.ts.map +1 -0
  368. package/dist/tools/utils/hashline/edit-operations.js +101 -0
  369. package/dist/tools/utils/hashline/edit-operations.js.map +1 -0
  370. package/dist/tools/utils/hashline/edit-operations.test.d.ts +2 -0
  371. package/dist/tools/utils/hashline/edit-operations.test.d.ts.map +1 -0
  372. package/dist/tools/utils/hashline/edit-operations.test.js +135 -0
  373. package/dist/tools/utils/hashline/edit-operations.test.js.map +1 -0
  374. package/dist/tools/utils/hashline/edit-ordering.d.ts +5 -0
  375. package/dist/tools/utils/hashline/edit-ordering.d.ts.map +1 -0
  376. package/dist/tools/utils/hashline/edit-ordering.js +54 -0
  377. package/dist/tools/utils/hashline/edit-ordering.js.map +1 -0
  378. package/dist/tools/utils/hashline/edit-text-normalization.d.ts +9 -0
  379. package/dist/tools/utils/hashline/edit-text-normalization.d.ts.map +1 -0
  380. package/dist/tools/utils/hashline/edit-text-normalization.js +135 -0
  381. package/dist/tools/utils/hashline/edit-text-normalization.js.map +1 -0
  382. package/dist/tools/utils/hashline/file-text-canonicalization.d.ts +8 -0
  383. package/dist/tools/utils/hashline/file-text-canonicalization.d.ts.map +1 -0
  384. package/dist/tools/utils/hashline/file-text-canonicalization.js +42 -0
  385. package/dist/tools/utils/hashline/file-text-canonicalization.js.map +1 -0
  386. package/dist/tools/utils/hashline/hash-computation.d.ts +14 -0
  387. package/dist/tools/utils/hashline/hash-computation.d.ts.map +1 -0
  388. package/dist/tools/utils/hashline/hash-computation.js +158 -0
  389. package/dist/tools/utils/hashline/hash-computation.js.map +1 -0
  390. package/dist/tools/utils/hashline/hash-computation.test.d.ts +2 -0
  391. package/dist/tools/utils/hashline/hash-computation.test.d.ts.map +1 -0
  392. package/dist/tools/utils/hashline/hash-computation.test.js +63 -0
  393. package/dist/tools/utils/hashline/hash-computation.test.js.map +1 -0
  394. package/dist/tools/utils/hashline/hashline-chunk-formatter.d.ts +11 -0
  395. package/dist/tools/utils/hashline/hashline-chunk-formatter.d.ts.map +1 -0
  396. package/dist/tools/utils/hashline/hashline-chunk-formatter.js +41 -0
  397. package/dist/tools/utils/hashline/hashline-chunk-formatter.js.map +1 -0
  398. package/dist/tools/utils/hashline/hashline-edit-diff.d.ts +2 -0
  399. package/dist/tools/utils/hashline/hashline-edit-diff.d.ts.map +1 -0
  400. package/dist/tools/utils/hashline/hashline-edit-diff.js +27 -0
  401. package/dist/tools/utils/hashline/hashline-edit-diff.js.map +1 -0
  402. package/dist/tools/utils/hashline/index.d.ts +14 -0
  403. package/dist/tools/utils/hashline/index.d.ts.map +1 -0
  404. package/dist/tools/utils/hashline/index.js +11 -0
  405. package/dist/tools/utils/hashline/index.js.map +1 -0
  406. package/dist/tools/utils/hashline/merge-expansion.d.ts +4 -0
  407. package/dist/tools/utils/hashline/merge-expansion.d.ts.map +1 -0
  408. package/dist/tools/utils/hashline/merge-expansion.js +105 -0
  409. package/dist/tools/utils/hashline/merge-expansion.js.map +1 -0
  410. package/dist/tools/utils/hashline/normalize-edits.d.ts +11 -0
  411. package/dist/tools/utils/hashline/normalize-edits.d.ts.map +1 -0
  412. package/dist/tools/utils/hashline/normalize-edits.js +81 -0
  413. package/dist/tools/utils/hashline/normalize-edits.js.map +1 -0
  414. package/dist/tools/utils/hashline/types.d.ts +18 -0
  415. package/dist/tools/utils/hashline/types.d.ts.map +1 -0
  416. package/dist/tools/utils/hashline/types.js +2 -0
  417. package/dist/tools/utils/hashline/types.js.map +1 -0
  418. package/dist/tools/utils/hashline/validation.d.ts +19 -0
  419. package/dist/tools/utils/hashline/validation.d.ts.map +1 -0
  420. package/dist/tools/utils/hashline/validation.js +161 -0
  421. package/dist/tools/utils/hashline/validation.js.map +1 -0
  422. package/dist/tools/utils/hashline/validation.test.d.ts +2 -0
  423. package/dist/tools/utils/hashline/validation.test.d.ts.map +1 -0
  424. package/dist/tools/utils/hashline/validation.test.js +86 -0
  425. package/dist/tools/utils/hashline/validation.test.js.map +1 -0
  426. package/dist/tools/utils/safety-utils.d.ts +66 -0
  427. package/dist/tools/utils/safety-utils.d.ts.map +1 -0
  428. package/dist/tools/utils/safety-utils.js +681 -0
  429. package/dist/tools/utils/safety-utils.js.map +1 -0
  430. package/dist/utils/tools-manager.d.ts +16 -0
  431. package/dist/utils/tools-manager.d.ts.map +1 -0
  432. package/dist/utils/tools-manager.js +257 -0
  433. package/dist/utils/tools-manager.js.map +1 -0
  434. package/package.json +49 -0
  435. package/src/AGENTS.md +52 -0
  436. package/src/agent-reasoning-default.test.ts +48 -0
  437. package/src/agent.test.ts +49 -0
  438. package/src/agent.ts +455 -0
  439. package/src/cli-args.test.ts +152 -0
  440. package/src/cli-args.ts +90 -0
  441. package/src/commands/aliases-and-tool-fallback.test.ts +172 -0
  442. package/src/commands/clear.ts +14 -0
  443. package/src/commands/factories/create-toggle-command.ts +68 -0
  444. package/src/commands/help.ts +30 -0
  445. package/src/commands/index.ts +125 -0
  446. package/src/commands/model.ts +146 -0
  447. package/src/commands/reasoning-mode.ts +55 -0
  448. package/src/commands/render.test.ts +47 -0
  449. package/src/commands/render.ts +205 -0
  450. package/src/commands/tool-fallback.ts +47 -0
  451. package/src/commands/translate.test.ts +62 -0
  452. package/src/commands/translate.ts +14 -0
  453. package/src/commands/types.ts +18 -0
  454. package/src/context/environment-context.ts +11 -0
  455. package/src/context/paths.ts +2 -0
  456. package/src/context/session.ts +18 -0
  457. package/src/context/skill-command-prefix.ts +18 -0
  458. package/src/context/skills-integration.test.ts +113 -0
  459. package/src/context/skills.test.ts +25 -0
  460. package/src/context/skills.ts +566 -0
  461. package/src/context/system-prompt.ts +100 -0
  462. package/src/context/translation-integration.test.ts +194 -0
  463. package/src/context/translation.test.ts +186 -0
  464. package/src/context/translation.ts +122 -0
  465. package/src/entrypoints/AGENTS.md +33 -0
  466. package/src/entrypoints/cli-input-rendering.test.ts +236 -0
  467. package/src/entrypoints/cli.ts +1845 -0
  468. package/src/entrypoints/headless-agent-config.test.ts +82 -0
  469. package/src/entrypoints/headless-agent-config.ts +42 -0
  470. package/src/entrypoints/headless.ts +622 -0
  471. package/src/env.ts +14 -0
  472. package/src/friendli-models.ts +81 -0
  473. package/src/friendli-reasoning.test.ts +147 -0
  474. package/src/friendli-reasoning.ts +280 -0
  475. package/src/index.ts +3 -0
  476. package/src/interaction/colors.ts +24 -0
  477. package/src/interaction/pi-tui-stream-renderer.test.ts +1471 -0
  478. package/src/interaction/pi-tui-stream-renderer.ts +2150 -0
  479. package/src/interaction/spinner.ts +61 -0
  480. package/src/middleware/index.ts +32 -0
  481. package/src/middleware/todo-continuation.ts +128 -0
  482. package/src/middleware/trim-leading-newlines.ts +66 -0
  483. package/src/reasoning-mode.test.ts +24 -0
  484. package/src/reasoning-mode.ts +40 -0
  485. package/src/skills/example/SKILL.md +44 -0
  486. package/src/skills/example/references/api.md +37 -0
  487. package/src/skills/example/scripts/setup.sh +13 -0
  488. package/src/skills/git-workflow.md +405 -0
  489. package/src/tool-fallback-mode.ts +34 -0
  490. package/src/tools/AGENTS.md +44 -0
  491. package/src/tools/execute/shell-execute.test.ts +114 -0
  492. package/src/tools/execute/shell-execute.ts +74 -0
  493. package/src/tools/execute/shell-execute.txt +27 -0
  494. package/src/tools/execute/shell-interact.test.ts +236 -0
  495. package/src/tools/execute/shell-interact.ts +151 -0
  496. package/src/tools/execute/shell-interact.txt +15 -0
  497. package/src/tools/explore/glob-files.txt +8 -0
  498. package/src/tools/explore/glob.test.ts +217 -0
  499. package/src/tools/explore/glob.ts +137 -0
  500. package/src/tools/explore/grep-files.txt +12 -0
  501. package/src/tools/explore/grep.test.ts +183 -0
  502. package/src/tools/explore/grep.ts +266 -0
  503. package/src/tools/explore/read-file.test.ts +355 -0
  504. package/src/tools/explore/read-file.ts +102 -0
  505. package/src/tools/explore/read-file.txt +24 -0
  506. package/src/tools/index.ts +29 -0
  507. package/src/tools/modify/AGENTS.md +38 -0
  508. package/src/tools/modify/delete-file.test.ts +200 -0
  509. package/src/tools/modify/delete-file.ts +95 -0
  510. package/src/tools/modify/delete-file.txt +9 -0
  511. package/src/tools/modify/edit-file-diagnostics.ts +210 -0
  512. package/src/tools/modify/edit-file-repair.ts +183 -0
  513. package/src/tools/modify/edit-file-stress.test.ts +200 -0
  514. package/src/tools/modify/edit-file-validation.ts +134 -0
  515. package/src/tools/modify/edit-file-whitespace.test.ts +117 -0
  516. package/src/tools/modify/edit-file.test.ts +1231 -0
  517. package/src/tools/modify/edit-file.ts +252 -0
  518. package/src/tools/modify/edit-file.txt +73 -0
  519. package/src/tools/modify/write-file.test.ts +240 -0
  520. package/src/tools/modify/write-file.ts +56 -0
  521. package/src/tools/modify/write-file.txt +9 -0
  522. package/src/tools/planning/load-skill.test.ts +48 -0
  523. package/src/tools/planning/load-skill.ts +136 -0
  524. package/src/tools/planning/load-skill.txt +6 -0
  525. package/src/tools/planning/todo-write.test.ts +91 -0
  526. package/src/tools/planning/todo-write.ts +141 -0
  527. package/src/tools/planning/todo-write.txt +7 -0
  528. package/src/tools/utils/execute/format-utils.test.ts +53 -0
  529. package/src/tools/utils/execute/format-utils.ts +37 -0
  530. package/src/tools/utils/execute/noninteractive-wrapper.test.ts +306 -0
  531. package/src/tools/utils/execute/noninteractive-wrapper.ts +314 -0
  532. package/src/tools/utils/execute/output-handler.test.ts +72 -0
  533. package/src/tools/utils/execute/output-handler.ts +101 -0
  534. package/src/tools/utils/execute/process-manager.test.ts +175 -0
  535. package/src/tools/utils/execute/process-manager.ts +310 -0
  536. package/src/tools/utils/execute/shell-detection.test.ts +112 -0
  537. package/src/tools/utils/execute/shell-detection.ts +72 -0
  538. package/src/tools/utils/hashline/autocorrect-replacement-lines.ts +159 -0
  539. package/src/tools/utils/hashline/constants.ts +13 -0
  540. package/src/tools/utils/hashline/diff-utils.test.ts +61 -0
  541. package/src/tools/utils/hashline/diff-utils.ts +64 -0
  542. package/src/tools/utils/hashline/edit-deduplication.ts +40 -0
  543. package/src/tools/utils/hashline/edit-operation-primitives.ts +149 -0
  544. package/src/tools/utils/hashline/edit-operations.test.ts +154 -0
  545. package/src/tools/utils/hashline/edit-operations.ts +132 -0
  546. package/src/tools/utils/hashline/edit-ordering.ts +60 -0
  547. package/src/tools/utils/hashline/edit-text-normalization.ts +180 -0
  548. package/src/tools/utils/hashline/file-text-canonicalization.ts +58 -0
  549. package/src/tools/utils/hashline/hash-computation.test.ts +82 -0
  550. package/src/tools/utils/hashline/hash-computation.ts +199 -0
  551. package/src/tools/utils/hashline/hashline-chunk-formatter.ts +61 -0
  552. package/src/tools/utils/hashline/hashline-edit-diff.ts +35 -0
  553. package/src/tools/utils/hashline/index.ts +55 -0
  554. package/src/tools/utils/hashline/merge-expansion.ts +120 -0
  555. package/src/tools/utils/hashline/normalize-edits.ts +127 -0
  556. package/src/tools/utils/hashline/types.ts +20 -0
  557. package/src/tools/utils/hashline/validation.test.ts +109 -0
  558. package/src/tools/utils/hashline/validation.ts +212 -0
  559. package/src/tools/utils/safety-utils.ts +938 -0
  560. package/src/utils/tools-manager.ts +353 -0
@@ -0,0 +1,1314 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { Container } from "@mariozechner/pi-tui";
3
+ import { computeLineHash } from "../tools/utils/hashline";
4
+ import { renderFullStreamWithPiTui, } from "./pi-tui-stream-renderer";
5
+ const LARGE_BLANK_GAP_REGEX = /\n[ \t]*\n[ \t]*\n[ \t]*\n/;
6
+ const EXECUTING_SPINNER_TEXT_REGEX = /[-\\|/] Executing\.\./;
7
+ const tagGrepLine = (path, lineNumber, content) => {
8
+ return `${path}:${lineNumber}#${computeLineHash(lineNumber, content)}|${content}`;
9
+ };
10
+ const tagReadLine = (lineNumber, content) => {
11
+ return `${lineNumber}#${computeLineHash(lineNumber, content)}|${content}`;
12
+ };
13
+ const markdownTheme = {
14
+ heading: (text) => text,
15
+ link: (text) => text,
16
+ linkUrl: (text) => text,
17
+ code: (text) => text,
18
+ codeBlock: (text) => text,
19
+ codeBlockBorder: (text) => text,
20
+ quote: (text) => text,
21
+ quoteBorder: (text) => text,
22
+ hr: (text) => text,
23
+ listBullet: (text) => text,
24
+ bold: (text) => text,
25
+ italic: (text) => text,
26
+ strikethrough: (text) => text,
27
+ underline: (text) => text,
28
+ };
29
+ const renderParts = async (parts, overrides = {}) => {
30
+ const chatContainer = new Container();
31
+ let renderCalls = 0;
32
+ const snapshots = [];
33
+ const options = {
34
+ chatContainer,
35
+ markdownTheme,
36
+ onFirstVisiblePart: overrides.onFirstVisiblePart,
37
+ ui: {
38
+ requestRender: () => {
39
+ renderCalls += 1;
40
+ snapshots.push(chatContainer.render(120).join("\n"));
41
+ },
42
+ },
43
+ showReasoning: true,
44
+ showSteps: false,
45
+ showFinishReason: false,
46
+ showToolResults: true,
47
+ showRawToolIo: overrides.showRawToolIo,
48
+ showSources: false,
49
+ showFiles: false,
50
+ };
51
+ async function* stream() {
52
+ for (const part of parts) {
53
+ await Promise.resolve();
54
+ yield part;
55
+ }
56
+ }
57
+ await renderFullStreamWithPiTui(stream(), options);
58
+ const output = chatContainer.render(120).join("\n");
59
+ return { output, renderCalls, snapshots };
60
+ };
61
+ describe("renderFullStreamWithPiTui", () => {
62
+ it("calls onFirstVisiblePart exactly once", async () => {
63
+ let calls = 0;
64
+ await renderParts([
65
+ { type: "start" },
66
+ { type: "text-start", id: "text_1" },
67
+ { type: "text-delta", id: "text_1", text: "Hello" },
68
+ { type: "text-delta", id: "text_1", text: " world" },
69
+ { type: "text-end", id: "text_1" },
70
+ ], {
71
+ onFirstVisiblePart: () => {
72
+ calls += 1;
73
+ },
74
+ });
75
+ expect(calls).toBe(1);
76
+ });
77
+ it("does not call onFirstVisiblePart for ignored-only stream", async () => {
78
+ let calls = 0;
79
+ await renderParts([
80
+ { type: "start" },
81
+ { type: "text-end", id: "text_1" },
82
+ { type: "reasoning-end", id: "reason_1" },
83
+ { type: "abort" },
84
+ ], {
85
+ onFirstVisiblePart: () => {
86
+ calls += 1;
87
+ },
88
+ });
89
+ expect(calls).toBe(0);
90
+ });
91
+ it("streams markdown text into assistant view", async () => {
92
+ const { output, renderCalls } = await renderParts([
93
+ { type: "text-start", id: "text_1" },
94
+ { type: "text-delta", id: "text_1", text: "Hello" },
95
+ { type: "text-delta", id: "text_1", text: " world" },
96
+ { type: "text-end", id: "text_1" },
97
+ ]);
98
+ expect(output).toContain("Hello world");
99
+ expect(renderCalls).toBeGreaterThan(0);
100
+ });
101
+ it("preserves stream order between reasoning and text blocks", async () => {
102
+ const { output } = await renderParts([
103
+ { type: "reasoning-start", id: "reason_1" },
104
+ { type: "reasoning-delta", id: "reason_1", text: "First thought" },
105
+ { type: "reasoning-end", id: "reason_1" },
106
+ { type: "text-start", id: "text_2" },
107
+ { type: "text-delta", id: "text_2", text: "Final answer" },
108
+ { type: "text-end", id: "text_2" },
109
+ ]);
110
+ const reasoningIndex = output.indexOf("First thought");
111
+ const textIndex = output.indexOf("Final answer");
112
+ expect(reasoningIndex).toBeGreaterThan(-1);
113
+ expect(textIndex).toBeGreaterThan(-1);
114
+ expect(reasoningIndex).toBeLessThan(textIndex);
115
+ });
116
+ it("applies Pi-like muted italic styling to reasoning text", async () => {
117
+ const { output } = await renderParts([
118
+ { type: "reasoning-start", id: "reason_2" },
119
+ { type: "reasoning-delta", id: "reason_2", text: "styled reasoning" },
120
+ { type: "reasoning-end", id: "reason_2" },
121
+ ]);
122
+ expect(output).toContain("styled reasoning");
123
+ expect(output).toContain("\x1b[2m\x1b[3m\x1b[90m");
124
+ });
125
+ it("removes leading newlines from reasoning display", async () => {
126
+ const { output } = await renderParts([
127
+ { type: "reasoning-start", id: "reason_trim" },
128
+ {
129
+ type: "reasoning-delta",
130
+ id: "reason_trim",
131
+ text: "\n\nreasoning without top blank lines",
132
+ },
133
+ { type: "reasoning-end", id: "reason_trim" },
134
+ ]);
135
+ expect(output).toContain("reasoning without top blank lines");
136
+ expect(output).not.toContain("\x1b[2m\x1b[3m\x1b[90m\n");
137
+ });
138
+ it("avoids large gap between tool output and following reasoning", async () => {
139
+ const { output } = await renderParts([
140
+ {
141
+ type: "tool-call",
142
+ toolCallId: "call_gap",
143
+ toolName: "bash",
144
+ input: {
145
+ command: "pwd",
146
+ },
147
+ },
148
+ {
149
+ type: "tool-result",
150
+ toolCallId: "call_gap",
151
+ toolName: "bash",
152
+ input: {
153
+ command: "pwd",
154
+ },
155
+ output: "tool output line\n\n\n",
156
+ },
157
+ { type: "reasoning-start", id: "reason_gap" },
158
+ {
159
+ type: "reasoning-delta",
160
+ id: "reason_gap",
161
+ text: "After tool output",
162
+ },
163
+ { type: "reasoning-end", id: "reason_gap" },
164
+ ]);
165
+ const plain = output;
166
+ const start = plain.indexOf("tool output line");
167
+ const end = plain.indexOf("After tool output");
168
+ expect(start).toBeGreaterThan(-1);
169
+ expect(end).toBeGreaterThan(start);
170
+ const between = plain.slice(start, end);
171
+ expect(between).not.toMatch(LARGE_BLANK_GAP_REGEX);
172
+ const lines = plain.split("\n");
173
+ const reasoningLineIndex = lines.findIndex((line) => line.includes("After tool output"));
174
+ expect(reasoningLineIndex).toBeGreaterThan(-1);
175
+ let previousNonEmptyLineIndex = -1;
176
+ for (let i = reasoningLineIndex - 1; i >= 0; i -= 1) {
177
+ if (lines[i].trim().length > 0) {
178
+ previousNonEmptyLineIndex = i;
179
+ break;
180
+ }
181
+ }
182
+ expect(previousNonEmptyLineIndex).toBeGreaterThan(-1);
183
+ expect(reasoningLineIndex).toBe(previousNonEmptyLineIndex + 1);
184
+ });
185
+ it("renders live diff preview for edit_file tool input", async () => {
186
+ const { output } = await renderParts([
187
+ {
188
+ type: "tool-input-start",
189
+ id: "call_edit",
190
+ toolName: "edit_file",
191
+ },
192
+ {
193
+ type: "tool-input-delta",
194
+ id: "call_edit",
195
+ delta: '{"path":"src/demo.ts","old_str":"const value = 1;","new_str":"const value = 2;"}',
196
+ },
197
+ { type: "tool-input-end", id: "call_edit" },
198
+ {
199
+ type: "tool-call",
200
+ toolCallId: "call_edit",
201
+ toolName: "edit_file",
202
+ input: {
203
+ path: "src/demo.ts",
204
+ old_str: "const value = 1;",
205
+ new_str: "const value = 2;",
206
+ },
207
+ },
208
+ ]);
209
+ expect(output).toContain("Live diff preview");
210
+ expect(output).toContain("-const value = 1;");
211
+ expect(output).toContain("+const value = 2;");
212
+ });
213
+ it("renders read_file output as structured markdown", async () => {
214
+ const readOutput = [
215
+ "OK - read file",
216
+ "path: src/demo.ts",
217
+ "bytes: 48",
218
+ "last_modified: 2026-01-19T03:33:57.520Z",
219
+ "lines: 5 (returned: 4)",
220
+ "range: L2-L5",
221
+ "truncated: true",
222
+ "",
223
+ "======== demo.ts L2-L5 ========",
224
+ " 2 | const value = 2;",
225
+ " 3 | export { value };",
226
+ " 4 | ```md",
227
+ " 5 | ![Image 1](./img.png)",
228
+ "======== end ========",
229
+ ].join("\n");
230
+ const { output } = await renderParts([
231
+ {
232
+ type: "tool-call",
233
+ toolCallId: "call_read",
234
+ toolName: "read_file",
235
+ input: {
236
+ path: "src/demo.ts",
237
+ },
238
+ },
239
+ {
240
+ type: "tool-result",
241
+ toolCallId: "call_read",
242
+ toolName: "read_file",
243
+ input: {
244
+ path: "src/demo.ts",
245
+ },
246
+ output: readOutput,
247
+ },
248
+ ]);
249
+ expect(output).toContain("Read src/demo.ts L2-L5");
250
+ expect(output).toContain("2 | ");
251
+ expect(output).toContain("const value = 2;");
252
+ expect(output).toContain("![Image 1](./img.png)");
253
+ expect(output).toContain("... (1 more line, truncated)");
254
+ expect(output).not.toContain("4 | ```md");
255
+ expect(output).not.toContain("```md");
256
+ expect(output).not.toContain("Tool read_file");
257
+ expect(output).not.toContain("Output");
258
+ expect(output).not.toContain("OK - read file");
259
+ });
260
+ it("normalizes split hashline read line fragments", async () => {
261
+ const lineContent = "const value = 2;";
262
+ const lineTag = tagReadLine(2, lineContent).split("|")[0];
263
+ const readOutput = [
264
+ "OK - read file",
265
+ "path: src/demo.ts",
266
+ "bytes: 48",
267
+ "last_modified: 2026-01-19T03:33:57.520Z",
268
+ "lines: 5 (returned: 1)",
269
+ "range: L2-L2",
270
+ "truncated: false",
271
+ "",
272
+ "======== demo.ts L2-L2 ========",
273
+ ` ${lineTag}`,
274
+ "|",
275
+ lineContent,
276
+ "======== end ========",
277
+ ].join("\n");
278
+ const { output } = await renderParts([
279
+ {
280
+ type: "tool-call",
281
+ toolCallId: "call_read_split",
282
+ toolName: "read_file",
283
+ input: {
284
+ path: "src/demo.ts",
285
+ },
286
+ },
287
+ {
288
+ type: "tool-result",
289
+ toolCallId: "call_read_split",
290
+ toolName: "read_file",
291
+ input: {
292
+ path: "src/demo.ts",
293
+ },
294
+ output: readOutput,
295
+ },
296
+ ]);
297
+ expect(output).toContain(tagReadLine(2, lineContent));
298
+ expect(output).not.toContain(` ${lineTag}\n|\n${lineContent}`);
299
+ });
300
+ it("preserves intentionally empty hashline lines", async () => {
301
+ const headingLine = "# Code Editing Agent";
302
+ const paragraphLine = "A code-editing agent built with Vercel AI SDK.";
303
+ const readOutput = [
304
+ "OK - read file",
305
+ "path: README.md",
306
+ "bytes: 120",
307
+ "last_modified: 2026-02-23T01:00:00.000Z",
308
+ "lines: 3 (returned: 3)",
309
+ "range: L1-L3",
310
+ "truncated: false",
311
+ "",
312
+ "======== README.md L1-L3 ========",
313
+ tagReadLine(1, headingLine),
314
+ tagReadLine(2, ""),
315
+ tagReadLine(3, paragraphLine),
316
+ "======== end ========",
317
+ ].join("\n");
318
+ const { output } = await renderParts([
319
+ {
320
+ type: "tool-call",
321
+ toolCallId: "call_read_empty_line",
322
+ toolName: "read_file",
323
+ input: {
324
+ path: "README.md",
325
+ },
326
+ },
327
+ {
328
+ type: "tool-result",
329
+ toolCallId: "call_read_empty_line",
330
+ toolName: "read_file",
331
+ input: {
332
+ path: "README.md",
333
+ },
334
+ output: readOutput,
335
+ },
336
+ ]);
337
+ expect(output).toContain(tagReadLine(2, ""));
338
+ expect(output).toContain(tagReadLine(3, paragraphLine));
339
+ expect(output).not.toContain(`${tagReadLine(2, "")}${tagReadLine(3, paragraphLine)}`);
340
+ });
341
+ it("omits read_file content after 10 lines", async () => {
342
+ const numberedLines = Array.from({ length: 12 }, (_, index) => {
343
+ const lineNumber = index + 1;
344
+ return `${lineNumber.toString().padStart(4, " ")} | line ${lineNumber}`;
345
+ });
346
+ const readOutput = [
347
+ "OK - read file",
348
+ "path: src/long.txt",
349
+ "bytes: 120",
350
+ "last_modified: 2026-02-23T01:00:00.000Z",
351
+ "lines: 12 (returned: 12)",
352
+ "range: L1-L12",
353
+ "truncated: false",
354
+ "",
355
+ "======== long.txt L1-L12 ========",
356
+ ...numberedLines,
357
+ "======== end ========",
358
+ ].join("\n");
359
+ const { output } = await renderParts([
360
+ {
361
+ type: "tool-call",
362
+ toolCallId: "call_long",
363
+ toolName: "read_file",
364
+ input: {
365
+ path: "src/long.txt",
366
+ },
367
+ },
368
+ {
369
+ type: "tool-result",
370
+ toolCallId: "call_long",
371
+ toolName: "read_file",
372
+ input: {
373
+ path: "src/long.txt",
374
+ },
375
+ output: readOutput,
376
+ },
377
+ ]);
378
+ expect(output).toContain("Read src/long.txt L1-L12");
379
+ expect(output).toContain("10 | line 10");
380
+ expect(output).not.toContain("11 | line 11");
381
+ expect(output).toContain("... (2 more lines)");
382
+ });
383
+ it("truncates long read_file lines instead of wrapping", async () => {
384
+ const longTail = "X".repeat(180);
385
+ const readOutput = [
386
+ "OK - read file",
387
+ "path: src/wrap.txt",
388
+ "bytes: 999",
389
+ "last_modified: 2026-02-23T01:00:00.000Z",
390
+ "lines: 1 (returned: 1)",
391
+ "range: L1-L1",
392
+ "truncated: false",
393
+ "",
394
+ "======== wrap.txt L1-L1 ========",
395
+ ` 1 | prefix ${longTail}`,
396
+ "======== end ========",
397
+ ].join("\n");
398
+ const { output } = await renderParts([
399
+ {
400
+ type: "tool-call",
401
+ toolCallId: "call_wrap",
402
+ toolName: "read_file",
403
+ input: {
404
+ path: "src/wrap.txt",
405
+ },
406
+ },
407
+ {
408
+ type: "tool-result",
409
+ toolCallId: "call_wrap",
410
+ toolName: "read_file",
411
+ input: {
412
+ path: "src/wrap.txt",
413
+ },
414
+ output: readOutput,
415
+ },
416
+ ]);
417
+ expect(output).toContain("Read src/wrap.txt L1-L1");
418
+ expect(output).toContain("1 | prefix");
419
+ expect(output).not.toContain(longTail);
420
+ });
421
+ it("does not duplicate tool call blocks when input was streamed", async () => {
422
+ const { output } = await renderParts([
423
+ {
424
+ type: "tool-input-start",
425
+ id: "call_1",
426
+ toolName: "write_file",
427
+ },
428
+ {
429
+ type: "tool-input-delta",
430
+ id: "call_1",
431
+ delta: '{"path":"src/file.ts","content":"hello"}',
432
+ },
433
+ { type: "tool-input-end", id: "call_1" },
434
+ {
435
+ type: "tool-call",
436
+ toolCallId: "call_1",
437
+ toolName: "write_file",
438
+ input: {
439
+ path: "src/file.ts",
440
+ content: "hello",
441
+ },
442
+ },
443
+ ]);
444
+ expect(output).toContain("Write src/file.ts");
445
+ expect((output.match(/Write src\/file\.ts/g) ?? []).length).toBe(1);
446
+ });
447
+ it("supports toolCallId and inputTextDelta aliases", async () => {
448
+ const { output } = await renderParts([
449
+ {
450
+ type: "tool-input-start",
451
+ toolCallId: "call_3",
452
+ toolName: "write_file",
453
+ },
454
+ {
455
+ type: "tool-input-delta",
456
+ toolCallId: "call_3",
457
+ inputTextDelta: '{"path":"src/big.ts","content":"chunk"}',
458
+ },
459
+ {
460
+ type: "tool-input-end",
461
+ toolCallId: "call_3",
462
+ },
463
+ {
464
+ type: "tool-call",
465
+ toolCallId: "call_3",
466
+ toolName: "write_file",
467
+ input: {
468
+ path: "src/big.ts",
469
+ content: "chunk",
470
+ },
471
+ },
472
+ ]);
473
+ expect(output).toContain("Write src/big.ts");
474
+ });
475
+ it("streams full write_file content without preview truncation", async () => {
476
+ const contentLines = Array.from({ length: 12 }, (_, index) => `line ${index + 1}`);
477
+ const streamedContent = contentLines.join("\n");
478
+ const escapedContent = contentLines.join("\\n");
479
+ const { output } = await renderParts([
480
+ {
481
+ type: "tool-input-start",
482
+ id: "call_write_stream_full",
483
+ toolName: "write_file",
484
+ },
485
+ {
486
+ type: "tool-input-delta",
487
+ id: "call_write_stream_full",
488
+ delta: `{"path":"src/full-stream.ts","content":"${escapedContent}`,
489
+ },
490
+ {
491
+ type: "tool-input-delta",
492
+ id: "call_write_stream_full",
493
+ delta: '"}',
494
+ },
495
+ { type: "tool-input-end", id: "call_write_stream_full" },
496
+ {
497
+ type: "tool-call",
498
+ toolCallId: "call_write_stream_full",
499
+ toolName: "write_file",
500
+ input: {
501
+ path: "src/full-stream.ts",
502
+ content: streamedContent,
503
+ },
504
+ },
505
+ {
506
+ type: "tool-result",
507
+ toolCallId: "call_write_stream_full",
508
+ toolName: "write_file",
509
+ input: {
510
+ path: "src/full-stream.ts",
511
+ content: streamedContent,
512
+ },
513
+ output: "OK - created full-stream.ts\nbytes: 84, lines: 12",
514
+ },
515
+ ]);
516
+ expect(output).toContain("Write src/full-stream.ts");
517
+ expect(output).toContain("line 1");
518
+ expect(output).toContain("line 12");
519
+ expect(output).not.toContain("OK - created full-stream.ts");
520
+ expect(output).not.toContain("... (");
521
+ });
522
+ it("falls back to write result metadata for empty write_file content", async () => {
523
+ const { output } = await renderParts([
524
+ {
525
+ type: "tool-call",
526
+ toolCallId: "call_write_empty",
527
+ toolName: "write_file",
528
+ input: {
529
+ path: "src/empty.ts",
530
+ content: "",
531
+ },
532
+ },
533
+ {
534
+ type: "tool-result",
535
+ toolCallId: "call_write_empty",
536
+ toolName: "write_file",
537
+ input: {
538
+ path: "src/empty.ts",
539
+ content: "",
540
+ },
541
+ output: "OK - created empty.ts\nbytes: 0, lines: 1",
542
+ },
543
+ ]);
544
+ expect(output).toContain("Write src/empty.ts");
545
+ expect(output).toContain("OK - created empty.ts");
546
+ });
547
+ it("truncates very large write_file previews to keep rendering bounded", async () => {
548
+ const contentLines = Array.from({ length: 210 }, (_, index) => `line ${index + 1}`);
549
+ const streamedContent = contentLines.join("\n");
550
+ const { output } = await renderParts([
551
+ {
552
+ type: "tool-call",
553
+ toolCallId: "call_write_huge",
554
+ toolName: "write_file",
555
+ input: {
556
+ path: "src/huge.ts",
557
+ content: streamedContent,
558
+ },
559
+ },
560
+ {
561
+ type: "tool-result",
562
+ toolCallId: "call_write_huge",
563
+ toolName: "write_file",
564
+ input: {
565
+ path: "src/huge.ts",
566
+ content: streamedContent,
567
+ },
568
+ output: "OK - created huge.ts\nbytes: 2048, lines: 210",
569
+ },
570
+ ]);
571
+ expect(output).toContain("Write src/huge.ts");
572
+ expect(output).toContain("line 1");
573
+ expect(output).toContain("line 200");
574
+ expect(output).toContain("... (10 more lines)");
575
+ expect(output).not.toContain("line 210");
576
+ });
577
+ it("streams read_file pretty header from partial tool-input-delta", async () => {
578
+ const { output } = await renderParts([
579
+ {
580
+ type: "tool-input-start",
581
+ id: "call_stream_read",
582
+ toolName: "read_file",
583
+ },
584
+ {
585
+ type: "tool-input-delta",
586
+ id: "call_stream_read",
587
+ delta: '{"path":"src/streamed.ts"',
588
+ },
589
+ ]);
590
+ expect(output).toContain("Read src/streamed.ts");
591
+ expect(output).toContain("Executing..");
592
+ expect(EXECUTING_SPINNER_TEXT_REGEX.test(output)).toBe(true);
593
+ expect(output).not.toContain("\x1b[100m");
594
+ expect(output).not.toContain("Tool read_file");
595
+ });
596
+ it("suppresses transient empty-object raw flicker during streamed tool input", async () => {
597
+ const { output, snapshots } = await renderParts([
598
+ {
599
+ type: "tool-input-start",
600
+ id: "call_stream_flicker",
601
+ toolName: "read_file",
602
+ },
603
+ {
604
+ type: "tool-input-delta",
605
+ id: "call_stream_flicker",
606
+ delta: '{"p',
607
+ },
608
+ {
609
+ type: "tool-input-delta",
610
+ id: "call_stream_flicker",
611
+ delta: 'ath":"src/no-flicker.ts"',
612
+ },
613
+ ]);
614
+ expect(output).toContain("Read src/no-flicker.ts");
615
+ expect(output).toContain("Executing..");
616
+ expect(output).not.toContain("Tool read_file");
617
+ expect(snapshots.some((frame) => frame.includes("{}"))).toBe(false);
618
+ });
619
+ it("preserves requestRender this-context for pending spinner updates", async () => {
620
+ const chatContainer = new Container();
621
+ const renderTracker = {
622
+ renderCalls: 0,
623
+ doRender() {
624
+ this.renderCalls += 1;
625
+ },
626
+ requestRender() {
627
+ this.doRender();
628
+ },
629
+ };
630
+ async function* stream() {
631
+ yield {
632
+ type: "tool-input-start",
633
+ id: "call_bound_request_render",
634
+ toolName: "read_file",
635
+ };
636
+ yield {
637
+ type: "tool-input-delta",
638
+ id: "call_bound_request_render",
639
+ delta: '{"path":"src/bound-context.ts"',
640
+ };
641
+ await new Promise((resolve) => setTimeout(resolve, 180));
642
+ }
643
+ await renderFullStreamWithPiTui(stream(), {
644
+ chatContainer,
645
+ markdownTheme,
646
+ ui: renderTracker,
647
+ showReasoning: true,
648
+ showSteps: false,
649
+ showFinishReason: false,
650
+ showToolResults: true,
651
+ showRawToolIo: false,
652
+ showSources: false,
653
+ showFiles: false,
654
+ });
655
+ const output = chatContainer.render(120).join("\n");
656
+ expect(output).toContain("Read src/bound-context.ts");
657
+ expect(output).toContain("Executing..");
658
+ expect(renderTracker.renderCalls).toBeGreaterThan(2);
659
+ });
660
+ it("streams shell_execute pretty header from partial tool-input-delta", async () => {
661
+ const { output } = await renderParts([
662
+ {
663
+ type: "tool-input-start",
664
+ id: "call_stream_shell",
665
+ toolName: "shell_execute",
666
+ },
667
+ {
668
+ type: "tool-input-delta",
669
+ id: "call_stream_shell",
670
+ delta: '{"command":"echo streamed"',
671
+ },
672
+ ]);
673
+ expect(output).toContain("Shell echo streamed");
674
+ expect(output).toContain("Executing..");
675
+ expect(EXECUTING_SPINNER_TEXT_REGEX.test(output)).toBe(true);
676
+ expect(output).not.toContain("Tool shell_execute");
677
+ });
678
+ it("waits to render non-raw tool input until tool name is known", async () => {
679
+ const { output } = await renderParts([
680
+ {
681
+ type: "tool-input-delta",
682
+ id: "call_late_name",
683
+ delta: '{"path":"src/late-name.ts"}',
684
+ },
685
+ {
686
+ type: "tool-input-start",
687
+ id: "call_late_name",
688
+ toolName: "read_file",
689
+ },
690
+ ]);
691
+ expect(output).toContain("Read src/late-name.ts");
692
+ expect(output).toContain("Executing..");
693
+ expect(output).not.toContain("Tool tool");
694
+ });
695
+ it("does not render tool block on input-start before deltas in non-raw mode", async () => {
696
+ const { output } = await renderParts([
697
+ {
698
+ type: "tool-input-start",
699
+ id: "call_start_only",
700
+ toolName: "read_file",
701
+ },
702
+ ]);
703
+ expect(output).toBe("");
704
+ });
705
+ it("keeps unknown-name tool input visible in raw debug mode", async () => {
706
+ const { output } = await renderParts([
707
+ {
708
+ type: "tool-input-delta",
709
+ id: "call_unknown_raw",
710
+ delta: '{"path":"src/raw-mode.ts"}',
711
+ },
712
+ ], { showRawToolIo: true });
713
+ expect(output).toContain("Tool tool");
714
+ expect(output).toContain("src/raw-mode.ts");
715
+ });
716
+ it("keeps reasoning visible after tool blocks in stream order", async () => {
717
+ const { output } = await renderParts([
718
+ { type: "reasoning-start", id: "reason_before" },
719
+ { type: "reasoning-delta", id: "reason_before", text: "Before tool" },
720
+ { type: "reasoning-end", id: "reason_before" },
721
+ {
722
+ type: "tool-input-start",
723
+ id: "call_reason",
724
+ toolName: "bash",
725
+ },
726
+ {
727
+ type: "tool-input-delta",
728
+ id: "call_reason",
729
+ delta: '{"command":"ls"}',
730
+ },
731
+ { type: "tool-input-end", id: "call_reason" },
732
+ {
733
+ type: "tool-call",
734
+ toolCallId: "call_reason",
735
+ toolName: "bash",
736
+ input: {
737
+ command: "ls",
738
+ },
739
+ },
740
+ { type: "reasoning-start", id: "reason_after" },
741
+ { type: "reasoning-delta", id: "reason_after", text: "After tool" },
742
+ { type: "reasoning-end", id: "reason_after" },
743
+ ]);
744
+ const beforeIndex = output.indexOf("Before tool");
745
+ const toolIndex = output.indexOf("Shell ls");
746
+ const afterIndex = output.indexOf("After tool");
747
+ expect(beforeIndex).toBeGreaterThan(-1);
748
+ expect(toolIndex).toBeGreaterThan(-1);
749
+ expect(afterIndex).toBeGreaterThan(-1);
750
+ expect(beforeIndex).toBeLessThan(toolIndex);
751
+ expect(toolIndex).toBeLessThan(afterIndex);
752
+ });
753
+ it("keeps reasoning visible between two tool calls", async () => {
754
+ const { output } = await renderParts([
755
+ {
756
+ type: "tool-input-start",
757
+ id: "call_a",
758
+ toolName: "bash",
759
+ },
760
+ {
761
+ type: "tool-input-delta",
762
+ id: "call_a",
763
+ delta: '{"command":"pwd"}',
764
+ },
765
+ { type: "tool-input-end", id: "call_a" },
766
+ {
767
+ type: "tool-call",
768
+ toolCallId: "call_a",
769
+ toolName: "bash",
770
+ input: {
771
+ command: "pwd",
772
+ },
773
+ },
774
+ { type: "reasoning-start", id: "reason_mid" },
775
+ { type: "reasoning-delta", id: "reason_mid", text: "Between tools" },
776
+ { type: "reasoning-end", id: "reason_mid" },
777
+ {
778
+ type: "tool-input-start",
779
+ id: "call_b",
780
+ toolName: "bash",
781
+ },
782
+ {
783
+ type: "tool-input-delta",
784
+ id: "call_b",
785
+ delta: '{"command":"ls"}',
786
+ },
787
+ { type: "tool-input-end", id: "call_b" },
788
+ {
789
+ type: "tool-call",
790
+ toolCallId: "call_b",
791
+ toolName: "bash",
792
+ input: {
793
+ command: "ls",
794
+ },
795
+ },
796
+ ]);
797
+ const firstToolIndex = output.indexOf("Shell pwd");
798
+ const reasoningIndex = output.indexOf("Between tools");
799
+ const secondToolIndex = output.indexOf("Shell ls");
800
+ expect(firstToolIndex).toBeGreaterThan(-1);
801
+ expect(reasoningIndex).toBeGreaterThan(-1);
802
+ expect(secondToolIndex).toBeGreaterThan(-1);
803
+ expect(firstToolIndex).toBeLessThan(reasoningIndex);
804
+ expect(reasoningIndex).toBeLessThan(secondToolIndex);
805
+ });
806
+ it("keeps reasoning visible across unknown stream parts", async () => {
807
+ const { output } = await renderParts([
808
+ { type: "reasoning-start", id: "reason_unknown_before" },
809
+ {
810
+ type: "reasoning-delta",
811
+ id: "reason_unknown_before",
812
+ text: "Before unknown",
813
+ },
814
+ { type: "reasoning-end", id: "reason_unknown_before" },
815
+ {
816
+ type: "unknown-x",
817
+ payload: "mystery",
818
+ },
819
+ { type: "reasoning-start", id: "reason_unknown_after" },
820
+ {
821
+ type: "reasoning-delta",
822
+ id: "reason_unknown_after",
823
+ text: "After unknown",
824
+ },
825
+ { type: "reasoning-end", id: "reason_unknown_after" },
826
+ ]);
827
+ const beforeIndex = output.indexOf("Before unknown");
828
+ const unknownIndex = output.indexOf("[unknown part]");
829
+ const afterIndex = output.indexOf("After unknown");
830
+ expect(beforeIndex).toBeGreaterThan(-1);
831
+ expect(unknownIndex).toBeGreaterThan(-1);
832
+ expect(afterIndex).toBeGreaterThan(-1);
833
+ expect(beforeIndex).toBeLessThan(unknownIndex);
834
+ expect(unknownIndex).toBeLessThan(afterIndex);
835
+ });
836
+ it("renders glob_files output as structured markdown", async () => {
837
+ const globOutput = [
838
+ "OK - glob",
839
+ 'pattern: "src/**/*.ts"',
840
+ "path: /project",
841
+ "respect_git_ignore: true",
842
+ "file_count: 12",
843
+ "truncated: false",
844
+ "sorted_by: mtime desc",
845
+ "",
846
+ "======== glob results ========",
847
+ "/project/file1.ts",
848
+ "/project/file2.ts",
849
+ "/project/file3.ts",
850
+ "/project/file4.ts",
851
+ "/project/file5.ts",
852
+ "/project/file6.ts",
853
+ "/project/file7.ts",
854
+ "/project/file8.ts",
855
+ "/project/file9.ts",
856
+ "/project/file10.ts",
857
+ "/project/file11.ts",
858
+ "/project/file12.ts",
859
+ "======== end ========",
860
+ ].join("\n");
861
+ const { output } = await renderParts([
862
+ {
863
+ type: "tool-call",
864
+ toolCallId: "call_glob",
865
+ toolName: "glob_files",
866
+ input: {
867
+ pattern: "src/**/*.ts",
868
+ },
869
+ },
870
+ {
871
+ type: "tool-result",
872
+ toolCallId: "call_glob",
873
+ toolName: "glob_files",
874
+ input: {
875
+ pattern: "src/**/*.ts",
876
+ },
877
+ output: globOutput,
878
+ },
879
+ ]);
880
+ expect(output).toContain("Glob src/**/*.ts");
881
+ expect(output).toContain("/project/file1.ts");
882
+ expect(output).toContain("... (2 more lines)");
883
+ expect(output).not.toContain("Tool glob_files");
884
+ expect(output).not.toContain("Output");
885
+ });
886
+ it("renders glob_files no-match output in glob mode", async () => {
887
+ const globOutput = [
888
+ "OK - glob (no matches)",
889
+ 'pattern: "*.xyz"',
890
+ "path: /project",
891
+ "respect_git_ignore: true",
892
+ "file_count: 0",
893
+ "truncated: false",
894
+ "sorted_by: mtime desc",
895
+ "",
896
+ "======== glob results ========",
897
+ "(no matches)",
898
+ "======== end ========",
899
+ ].join("\n");
900
+ const { output } = await renderParts([
901
+ {
902
+ type: "tool-call",
903
+ toolCallId: "call_glob_empty",
904
+ toolName: "glob_files",
905
+ input: {
906
+ pattern: "*.xyz",
907
+ },
908
+ },
909
+ {
910
+ type: "tool-result",
911
+ toolCallId: "call_glob_empty",
912
+ toolName: "glob_files",
913
+ input: {
914
+ pattern: "*.xyz",
915
+ },
916
+ output: globOutput,
917
+ },
918
+ ]);
919
+ expect(output).toContain("Glob *.xyz");
920
+ expect(output).toContain("(no matches)");
921
+ expect(output).not.toContain("Tool glob_files");
922
+ expect(output).not.toContain("Output");
923
+ });
924
+ it("shows truncated marker for glob files when model truncates", async () => {
925
+ const globOutput = [
926
+ "OK - glob",
927
+ 'pattern: "src/**/*.ts"',
928
+ "path: /project",
929
+ "respect_git_ignore: true",
930
+ "file_count: 12",
931
+ "truncated: true",
932
+ "sorted_by: mtime desc",
933
+ "",
934
+ "======== glob results ========",
935
+ "/project/file1.ts",
936
+ "/project/file2.ts",
937
+ "/project/file3.ts",
938
+ "/project/file4.ts",
939
+ "/project/file5.ts",
940
+ "/project/file6.ts",
941
+ "/project/file7.ts",
942
+ "/project/file8.ts",
943
+ "/project/file9.ts",
944
+ "/project/file10.ts",
945
+ "/project/file11.ts",
946
+ "/project/file12.ts",
947
+ "======== end ========",
948
+ ].join("\n");
949
+ const { output } = await renderParts([
950
+ {
951
+ type: "tool-call",
952
+ toolCallId: "call_glob_truncated",
953
+ toolName: "glob_files",
954
+ input: {
955
+ pattern: "src/**/*.ts",
956
+ },
957
+ },
958
+ {
959
+ type: "tool-result",
960
+ toolCallId: "call_glob_truncated",
961
+ toolName: "glob_files",
962
+ input: {
963
+ pattern: "src/**/*.ts",
964
+ },
965
+ output: globOutput,
966
+ },
967
+ ]);
968
+ expect(output).toContain("... (2 more lines, truncated)");
969
+ expect(output).not.toContain("file_count (");
970
+ expect(output).not.toContain("path: ");
971
+ });
972
+ it("renders grep_files output as structured markdown", async () => {
973
+ const grepOutput = [
974
+ "OK - grep",
975
+ 'pattern: "foo"',
976
+ "path: /project",
977
+ "include: *.ts",
978
+ "case_sensitive: false",
979
+ "fixed_strings: false",
980
+ "match_count: 12",
981
+ "truncated: false",
982
+ "",
983
+ "======== grep results ========",
984
+ tagGrepLine("/project/a.ts", 1, "const foo = 1;"),
985
+ tagGrepLine("/project/b.ts", 2, "const foo = 2;"),
986
+ tagGrepLine("/project/c.ts", 3, "const foo = 3;"),
987
+ tagGrepLine("/project/d.ts", 4, "const foo = 4;"),
988
+ tagGrepLine("/project/e.ts", 5, "const foo = 5;"),
989
+ tagGrepLine("/project/f.ts", 6, "const foo = 6;"),
990
+ tagGrepLine("/project/g.ts", 7, "const foo = 7;"),
991
+ tagGrepLine("/project/h.ts", 8, "const foo = 8;"),
992
+ tagGrepLine("/project/i.ts", 9, "const foo = 9;"),
993
+ tagGrepLine("/project/j.ts", 10, "const foo = 10;"),
994
+ tagGrepLine("/project/k.ts", 11, "const foo = 11;"),
995
+ tagGrepLine("/project/l.ts", 12, "const foo = 12;"),
996
+ "======== end ========",
997
+ ].join("\n");
998
+ const { output } = await renderParts([
999
+ {
1000
+ type: "tool-call",
1001
+ toolCallId: "call_grep",
1002
+ toolName: "grep_files",
1003
+ input: {
1004
+ pattern: "foo",
1005
+ },
1006
+ },
1007
+ {
1008
+ type: "tool-result",
1009
+ toolCallId: "call_grep",
1010
+ toolName: "grep_files",
1011
+ input: {
1012
+ pattern: "foo",
1013
+ },
1014
+ output: grepOutput,
1015
+ },
1016
+ ]);
1017
+ expect(output).toContain("Grep foo");
1018
+ expect(output).toContain(tagGrepLine("/project/a.ts", 1, "const foo = 1;"));
1019
+ expect(output).toContain("... (2 more lines)");
1020
+ expect(output).not.toContain("Tool grep_files");
1021
+ expect(output).not.toContain("Output");
1022
+ });
1023
+ it("renders grep_files no-match output in grep mode", async () => {
1024
+ const grepOutput = [
1025
+ "OK - grep (no matches)",
1026
+ 'pattern: "foo"',
1027
+ "path: /project",
1028
+ "include: *.ts",
1029
+ "case_sensitive: false",
1030
+ "fixed_strings: false",
1031
+ "match_count: 0",
1032
+ "truncated: false",
1033
+ "",
1034
+ "======== grep results ========",
1035
+ "(no matches)",
1036
+ "======== end ========",
1037
+ ].join("\n");
1038
+ const { output } = await renderParts([
1039
+ {
1040
+ type: "tool-call",
1041
+ toolCallId: "call_grep_empty",
1042
+ toolName: "grep_files",
1043
+ input: {
1044
+ pattern: "foo",
1045
+ },
1046
+ },
1047
+ {
1048
+ type: "tool-result",
1049
+ toolCallId: "call_grep_empty",
1050
+ toolName: "grep_files",
1051
+ input: {
1052
+ pattern: "foo",
1053
+ },
1054
+ output: grepOutput,
1055
+ },
1056
+ ]);
1057
+ expect(output).toContain("Grep foo");
1058
+ expect(output).toContain("(no matches)");
1059
+ expect(output).not.toContain("Tool grep_files");
1060
+ expect(output).not.toContain("Output");
1061
+ });
1062
+ it("shows truncated marker for grep files when model truncates", async () => {
1063
+ const grepOutput = [
1064
+ "OK - grep",
1065
+ 'pattern: "foo"',
1066
+ "path: /project",
1067
+ "include: *.ts",
1068
+ "case_sensitive: false",
1069
+ "fixed_strings: false",
1070
+ "match_count: 40",
1071
+ "truncated: true",
1072
+ "",
1073
+ "======== grep results ========",
1074
+ tagGrepLine("/project/a.ts", 1, "const foo = 1;"),
1075
+ tagGrepLine("/project/b.ts", 2, "const foo = 2;"),
1076
+ tagGrepLine("/project/c.ts", 3, "const foo = 3;"),
1077
+ tagGrepLine("/project/d.ts", 4, "const foo = 4;"),
1078
+ tagGrepLine("/project/e.ts", 5, "const foo = 5;"),
1079
+ tagGrepLine("/project/f.ts", 6, "const foo = 6;"),
1080
+ tagGrepLine("/project/g.ts", 7, "const foo = 7;"),
1081
+ tagGrepLine("/project/h.ts", 8, "const foo = 8;"),
1082
+ tagGrepLine("/project/i.ts", 9, "const foo = 9;"),
1083
+ tagGrepLine("/project/j.ts", 10, "const foo = 10;"),
1084
+ tagGrepLine("/project/k.ts", 11, "const foo = 11;"),
1085
+ tagGrepLine("/project/l.ts", 12, "const foo = 12;"),
1086
+ "======== end ========",
1087
+ ].join("\n");
1088
+ const { output } = await renderParts([
1089
+ {
1090
+ type: "tool-call",
1091
+ toolCallId: "call_grep_truncated",
1092
+ toolName: "grep_files",
1093
+ input: {
1094
+ pattern: "foo",
1095
+ },
1096
+ },
1097
+ {
1098
+ type: "tool-result",
1099
+ toolCallId: "call_grep_truncated",
1100
+ toolName: "grep_files",
1101
+ input: {
1102
+ pattern: "foo",
1103
+ },
1104
+ output: grepOutput,
1105
+ },
1106
+ ]);
1107
+ expect(output).toContain("... (30 more lines, truncated)");
1108
+ expect(output).toContain("match_count (40)");
1109
+ expect(output).toContain("truncated: true");
1110
+ });
1111
+ it("renders read/glob/grep tool IO in raw mode when enabled", async () => {
1112
+ const cases = [
1113
+ {
1114
+ toolCallId: "call_read_raw",
1115
+ toolName: "read_file",
1116
+ input: { path: "src/demo.ts" },
1117
+ output: [
1118
+ "OK - read file",
1119
+ "path: src/demo.ts",
1120
+ "bytes: 12",
1121
+ "last_modified: 2026-02-23T01:00:00.000Z",
1122
+ "lines: 1 (returned: 1)",
1123
+ "range: L1-L1",
1124
+ "truncated: false",
1125
+ "",
1126
+ "======== demo.ts L1-L1 ========",
1127
+ " 1 | const x = 1;",
1128
+ "======== end ========",
1129
+ ].join("\n"),
1130
+ prettyHeading: "Read src/demo.ts",
1131
+ },
1132
+ {
1133
+ toolCallId: "call_glob_raw",
1134
+ toolName: "glob_files",
1135
+ input: { pattern: "src/**/*.ts" },
1136
+ output: [
1137
+ "OK - glob",
1138
+ 'pattern: "src/**/*.ts"',
1139
+ "path: /project",
1140
+ "respect_git_ignore: true",
1141
+ "file_count: 1",
1142
+ "truncated: false",
1143
+ "sorted_by: mtime desc",
1144
+ "",
1145
+ "======== glob results ========",
1146
+ "/project/file1.ts",
1147
+ "======== end ========",
1148
+ ].join("\n"),
1149
+ prettyHeading: "Glob src/**/*.ts",
1150
+ },
1151
+ {
1152
+ toolCallId: "call_grep_raw",
1153
+ toolName: "grep_files",
1154
+ input: { pattern: "foo" },
1155
+ output: [
1156
+ "OK - grep",
1157
+ 'pattern: "foo"',
1158
+ "path: /project",
1159
+ "include: *.ts",
1160
+ "case_sensitive: false",
1161
+ "fixed_strings: false",
1162
+ "match_count: 1",
1163
+ "truncated: false",
1164
+ "",
1165
+ "======== grep results ========",
1166
+ tagGrepLine("/project/file1.ts", 1, "const foo = 1;"),
1167
+ "======== end ========",
1168
+ ].join("\n"),
1169
+ prettyHeading: "Grep foo",
1170
+ },
1171
+ ];
1172
+ for (const testCase of cases) {
1173
+ const { output } = await renderParts([
1174
+ {
1175
+ type: "tool-call",
1176
+ toolCallId: testCase.toolCallId,
1177
+ toolName: testCase.toolName,
1178
+ input: testCase.input,
1179
+ },
1180
+ {
1181
+ type: "tool-result",
1182
+ toolCallId: testCase.toolCallId,
1183
+ toolName: testCase.toolName,
1184
+ input: testCase.input,
1185
+ output: testCase.output,
1186
+ },
1187
+ ], { showRawToolIo: true });
1188
+ expect(output).toContain(`Tool ${testCase.toolName}`);
1189
+ expect(output).toContain("Input");
1190
+ expect(output).toContain("Output");
1191
+ expect(output).toContain(testCase.output.split("\n")[0]);
1192
+ expect(output).not.toContain(testCase.prettyHeading);
1193
+ }
1194
+ });
1195
+ it("hides call id in raw shell headers", async () => {
1196
+ const { output } = await renderParts([
1197
+ {
1198
+ type: "tool-call",
1199
+ toolCallId: "call_shell_raw",
1200
+ toolName: "bash",
1201
+ input: {
1202
+ command: "pwd",
1203
+ },
1204
+ },
1205
+ ], { showRawToolIo: true });
1206
+ expect(output).toContain("Tool bash");
1207
+ expect(output).not.toContain("call_shell_raw");
1208
+ });
1209
+ it("renders dedicated pretty wrappers for all other tools", async () => {
1210
+ const cases = [
1211
+ {
1212
+ toolCallId: "call_shell_pretty",
1213
+ toolName: "shell_execute",
1214
+ input: {
1215
+ command: "echo hello",
1216
+ workdir: "/tmp",
1217
+ timeout_ms: 1000,
1218
+ },
1219
+ output: {
1220
+ exit_code: 0,
1221
+ output: "hello",
1222
+ },
1223
+ expectedHeading: "Shell echo hello",
1224
+ },
1225
+ {
1226
+ toolCallId: "call_interact_pretty",
1227
+ toolName: "shell_interact",
1228
+ input: {
1229
+ keystrokes: "<Enter>",
1230
+ },
1231
+ output: {
1232
+ success: true,
1233
+ output: "sent",
1234
+ },
1235
+ expectedHeading: "Interact <Enter>",
1236
+ },
1237
+ {
1238
+ toolCallId: "call_write_pretty",
1239
+ toolName: "write_file",
1240
+ input: {
1241
+ path: "src/new.ts",
1242
+ content: "const x = 1;",
1243
+ },
1244
+ output: "OK - created new.ts\nbytes: 12, lines: 1",
1245
+ expectedHeading: "Write src/new.ts",
1246
+ },
1247
+ {
1248
+ toolCallId: "call_edit_pretty",
1249
+ toolName: "edit_file",
1250
+ input: {
1251
+ path: "src/demo.ts",
1252
+ edits: [{ op: "replace", pos: "2#AB", lines: ["const x = 2;"] }],
1253
+ },
1254
+ output: "Updated src/demo.ts",
1255
+ expectedHeading: "Edit src/demo.ts",
1256
+ },
1257
+ {
1258
+ toolCallId: "call_delete_pretty",
1259
+ toolName: "delete_file",
1260
+ input: {
1261
+ path: "src/old.ts",
1262
+ },
1263
+ output: "OK - deleted file: old.ts\npath: src/old.ts",
1264
+ expectedHeading: "Delete src/old.ts",
1265
+ },
1266
+ {
1267
+ toolCallId: "call_skill_pretty",
1268
+ toolName: "load_skill",
1269
+ input: {
1270
+ skillName: "git-workflow",
1271
+ },
1272
+ output: "# Skill Loaded: git-workflow [Project]",
1273
+ expectedHeading: "Skill git-workflow",
1274
+ },
1275
+ {
1276
+ toolCallId: "call_todo_pretty",
1277
+ toolName: "todo_write",
1278
+ input: {
1279
+ todos: [
1280
+ { id: "1", content: "A", status: "pending", priority: "high" },
1281
+ {
1282
+ id: "2",
1283
+ content: "B",
1284
+ status: "completed",
1285
+ priority: "medium",
1286
+ },
1287
+ ],
1288
+ },
1289
+ output: "OK - updated todo list\ntotal: 2 tasks",
1290
+ expectedHeading: "Todo 2 tasks",
1291
+ },
1292
+ ];
1293
+ for (const testCase of cases) {
1294
+ const { output } = await renderParts([
1295
+ {
1296
+ type: "tool-call",
1297
+ toolCallId: testCase.toolCallId,
1298
+ toolName: testCase.toolName,
1299
+ input: testCase.input,
1300
+ },
1301
+ {
1302
+ type: "tool-result",
1303
+ toolCallId: testCase.toolCallId,
1304
+ toolName: testCase.toolName,
1305
+ input: testCase.input,
1306
+ output: testCase.output,
1307
+ },
1308
+ ]);
1309
+ expect(output).toContain(testCase.expectedHeading);
1310
+ expect(output).not.toContain(`Tool ${testCase.toolName}`);
1311
+ }
1312
+ });
1313
+ });
1314
+ //# sourceMappingURL=pi-tui-stream-renderer.test.js.map