@vaclav-synacek/pi-coding-agent-termux 0.45.7

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 (478) hide show
  1. package/CHANGELOG.md +1961 -0
  2. package/README.md +1392 -0
  3. package/dist/cli/args.d.ts +42 -0
  4. package/dist/cli/args.d.ts.map +1 -0
  5. package/dist/cli/args.js +248 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/file-processor.d.ts +15 -0
  8. package/dist/cli/file-processor.d.ts.map +1 -0
  9. package/dist/cli/file-processor.js +79 -0
  10. package/dist/cli/file-processor.js.map +1 -0
  11. package/dist/cli/list-models.d.ts +9 -0
  12. package/dist/cli/list-models.d.ts.map +1 -0
  13. package/dist/cli/list-models.js +92 -0
  14. package/dist/cli/list-models.js.map +1 -0
  15. package/dist/cli/session-picker.d.ts +9 -0
  16. package/dist/cli/session-picker.d.ts.map +1 -0
  17. package/dist/cli/session-picker.js +32 -0
  18. package/dist/cli/session-picker.js.map +1 -0
  19. package/dist/cli.d.ts +3 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +10 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/config.d.ts +61 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +141 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/core/agent-session.d.ts +523 -0
  28. package/dist/core/agent-session.d.ts.map +1 -0
  29. package/dist/core/agent-session.js +1795 -0
  30. package/dist/core/agent-session.js.map +1 -0
  31. package/dist/core/auth-storage.d.ts +112 -0
  32. package/dist/core/auth-storage.d.ts.map +1 -0
  33. package/dist/core/auth-storage.js +297 -0
  34. package/dist/core/auth-storage.js.map +1 -0
  35. package/dist/core/bash-executor.d.ts +47 -0
  36. package/dist/core/bash-executor.d.ts.map +1 -0
  37. package/dist/core/bash-executor.js +211 -0
  38. package/dist/core/bash-executor.js.map +1 -0
  39. package/dist/core/compaction/branch-summarization.d.ts +84 -0
  40. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  41. package/dist/core/compaction/branch-summarization.js +235 -0
  42. package/dist/core/compaction/branch-summarization.js.map +1 -0
  43. package/dist/core/compaction/compaction.d.ts +110 -0
  44. package/dist/core/compaction/compaction.d.ts.map +1 -0
  45. package/dist/core/compaction/compaction.js +559 -0
  46. package/dist/core/compaction/compaction.js.map +1 -0
  47. package/dist/core/compaction/index.d.ts +7 -0
  48. package/dist/core/compaction/index.d.ts.map +1 -0
  49. package/dist/core/compaction/index.js +7 -0
  50. package/dist/core/compaction/index.js.map +1 -0
  51. package/dist/core/compaction/utils.d.ts +35 -0
  52. package/dist/core/compaction/utils.d.ts.map +1 -0
  53. package/dist/core/compaction/utils.js +138 -0
  54. package/dist/core/compaction/utils.js.map +1 -0
  55. package/dist/core/event-bus.d.ts +9 -0
  56. package/dist/core/event-bus.d.ts.map +1 -0
  57. package/dist/core/event-bus.js +25 -0
  58. package/dist/core/event-bus.js.map +1 -0
  59. package/dist/core/exec.d.ts +29 -0
  60. package/dist/core/exec.d.ts.map +1 -0
  61. package/dist/core/exec.js +71 -0
  62. package/dist/core/exec.js.map +1 -0
  63. package/dist/core/export-html/index.d.ts +17 -0
  64. package/dist/core/export-html/index.d.ts.map +1 -0
  65. package/dist/core/export-html/index.js +193 -0
  66. package/dist/core/export-html/index.js.map +1 -0
  67. package/dist/core/export-html/template.css +910 -0
  68. package/dist/core/export-html/template.html +54 -0
  69. package/dist/core/export-html/template.js +1329 -0
  70. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  71. package/dist/core/export-html/vendor/marked.min.js +6 -0
  72. package/dist/core/extensions/index.d.ts +10 -0
  73. package/dist/core/extensions/index.d.ts.map +1 -0
  74. package/dist/core/extensions/index.js +9 -0
  75. package/dist/core/extensions/index.js.map +1 -0
  76. package/dist/core/extensions/loader.d.ts +25 -0
  77. package/dist/core/extensions/loader.d.ts.map +1 -0
  78. package/dist/core/extensions/loader.js +383 -0
  79. package/dist/core/extensions/loader.js.map +1 -0
  80. package/dist/core/extensions/runner.d.ts +89 -0
  81. package/dist/core/extensions/runner.d.ts.map +1 -0
  82. package/dist/core/extensions/runner.js +406 -0
  83. package/dist/core/extensions/runner.js.map +1 -0
  84. package/dist/core/extensions/types.d.ts +654 -0
  85. package/dist/core/extensions/types.d.ts.map +1 -0
  86. package/dist/core/extensions/types.js +32 -0
  87. package/dist/core/extensions/types.js.map +1 -0
  88. package/dist/core/extensions/wrapper.d.ts +27 -0
  89. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  90. package/dist/core/extensions/wrapper.js +102 -0
  91. package/dist/core/extensions/wrapper.js.map +1 -0
  92. package/dist/core/footer-data-provider.d.ts +25 -0
  93. package/dist/core/footer-data-provider.d.ts.map +1 -0
  94. package/dist/core/footer-data-provider.js +121 -0
  95. package/dist/core/footer-data-provider.js.map +1 -0
  96. package/dist/core/index.d.ts +9 -0
  97. package/dist/core/index.d.ts.map +1 -0
  98. package/dist/core/index.js +9 -0
  99. package/dist/core/index.js.map +1 -0
  100. package/dist/core/keybindings.d.ts +59 -0
  101. package/dist/core/keybindings.d.ts.map +1 -0
  102. package/dist/core/keybindings.js +151 -0
  103. package/dist/core/keybindings.js.map +1 -0
  104. package/dist/core/messages.d.ts +77 -0
  105. package/dist/core/messages.d.ts.map +1 -0
  106. package/dist/core/messages.js +123 -0
  107. package/dist/core/messages.js.map +1 -0
  108. package/dist/core/model-registry.d.ts +57 -0
  109. package/dist/core/model-registry.d.ts.map +1 -0
  110. package/dist/core/model-registry.js +314 -0
  111. package/dist/core/model-registry.js.map +1 -0
  112. package/dist/core/model-resolver.d.ts +76 -0
  113. package/dist/core/model-resolver.d.ts.map +1 -0
  114. package/dist/core/model-resolver.js +308 -0
  115. package/dist/core/model-resolver.js.map +1 -0
  116. package/dist/core/prompt-templates.d.ts +40 -0
  117. package/dist/core/prompt-templates.d.ts.map +1 -0
  118. package/dist/core/prompt-templates.js +197 -0
  119. package/dist/core/prompt-templates.js.map +1 -0
  120. package/dist/core/sdk.d.ts +181 -0
  121. package/dist/core/sdk.d.ts.map +1 -0
  122. package/dist/core/sdk.js +466 -0
  123. package/dist/core/sdk.js.map +1 -0
  124. package/dist/core/session-manager.d.ts +313 -0
  125. package/dist/core/session-manager.d.ts.map +1 -0
  126. package/dist/core/session-manager.js +996 -0
  127. package/dist/core/session-manager.js.map +1 -0
  128. package/dist/core/settings-manager.d.ts +138 -0
  129. package/dist/core/settings-manager.d.ts.map +1 -0
  130. package/dist/core/settings-manager.js +327 -0
  131. package/dist/core/settings-manager.js.map +1 -0
  132. package/dist/core/skills.d.ts +50 -0
  133. package/dist/core/skills.d.ts.map +1 -0
  134. package/dist/core/skills.js +338 -0
  135. package/dist/core/skills.js.map +1 -0
  136. package/dist/core/system-prompt.d.ts +48 -0
  137. package/dist/core/system-prompt.d.ts.map +1 -0
  138. package/dist/core/system-prompt.js +224 -0
  139. package/dist/core/system-prompt.js.map +1 -0
  140. package/dist/core/timings.d.ts +7 -0
  141. package/dist/core/timings.d.ts.map +1 -0
  142. package/dist/core/timings.js +25 -0
  143. package/dist/core/timings.js.map +1 -0
  144. package/dist/core/tools/bash.d.ts +42 -0
  145. package/dist/core/tools/bash.d.ts.map +1 -0
  146. package/dist/core/tools/bash.js +223 -0
  147. package/dist/core/tools/bash.js.map +1 -0
  148. package/dist/core/tools/edit-diff.d.ts +33 -0
  149. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  150. package/dist/core/tools/edit-diff.js +171 -0
  151. package/dist/core/tools/edit-diff.js.map +1 -0
  152. package/dist/core/tools/edit.d.ts +37 -0
  153. package/dist/core/tools/edit.d.ts.map +1 -0
  154. package/dist/core/tools/edit.js +143 -0
  155. package/dist/core/tools/edit.js.map +1 -0
  156. package/dist/core/tools/find.d.ts +37 -0
  157. package/dist/core/tools/find.d.ts.map +1 -0
  158. package/dist/core/tools/find.js +206 -0
  159. package/dist/core/tools/find.js.map +1 -0
  160. package/dist/core/tools/grep.d.ts +43 -0
  161. package/dist/core/tools/grep.d.ts.map +1 -0
  162. package/dist/core/tools/grep.js +239 -0
  163. package/dist/core/tools/grep.js.map +1 -0
  164. package/dist/core/tools/index.d.ts +70 -0
  165. package/dist/core/tools/index.d.ts.map +1 -0
  166. package/dist/core/tools/index.js +56 -0
  167. package/dist/core/tools/index.js.map +1 -0
  168. package/dist/core/tools/ls.d.ts +38 -0
  169. package/dist/core/tools/ls.d.ts.map +1 -0
  170. package/dist/core/tools/ls.js +118 -0
  171. package/dist/core/tools/ls.js.map +1 -0
  172. package/dist/core/tools/path-utils.d.ts +8 -0
  173. package/dist/core/tools/path-utils.d.ts.map +1 -0
  174. package/dist/core/tools/path-utils.js +53 -0
  175. package/dist/core/tools/path-utils.js.map +1 -0
  176. package/dist/core/tools/read.d.ts +37 -0
  177. package/dist/core/tools/read.d.ts.map +1 -0
  178. package/dist/core/tools/read.js +165 -0
  179. package/dist/core/tools/read.js.map +1 -0
  180. package/dist/core/tools/truncate.d.ts +70 -0
  181. package/dist/core/tools/truncate.d.ts.map +1 -0
  182. package/dist/core/tools/truncate.js +205 -0
  183. package/dist/core/tools/truncate.js.map +1 -0
  184. package/dist/core/tools/write.d.ts +27 -0
  185. package/dist/core/tools/write.d.ts.map +1 -0
  186. package/dist/core/tools/write.js +78 -0
  187. package/dist/core/tools/write.js.map +1 -0
  188. package/dist/index.d.ts +19 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +35 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/main.d.ts +8 -0
  193. package/dist/main.d.ts.map +1 -0
  194. package/dist/main.js +354 -0
  195. package/dist/main.js.map +1 -0
  196. package/dist/migrations.d.ts +33 -0
  197. package/dist/migrations.d.ts.map +1 -0
  198. package/dist/migrations.js +261 -0
  199. package/dist/migrations.js.map +1 -0
  200. package/dist/modes/index.d.ts +9 -0
  201. package/dist/modes/index.d.ts.map +1 -0
  202. package/dist/modes/index.js +8 -0
  203. package/dist/modes/index.js.map +1 -0
  204. package/dist/modes/interactive/components/armin.d.ts +34 -0
  205. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  206. package/dist/modes/interactive/components/armin.js +333 -0
  207. package/dist/modes/interactive/components/armin.js.map +1 -0
  208. package/dist/modes/interactive/components/assistant-message.d.ts +15 -0
  209. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  210. package/dist/modes/interactive/components/assistant-message.js +89 -0
  211. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  212. package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
  213. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  214. package/dist/modes/interactive/components/bash-execution.js +161 -0
  215. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  216. package/dist/modes/interactive/components/bordered-loader.d.ts +12 -0
  217. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  218. package/dist/modes/interactive/components/bordered-loader.js +30 -0
  219. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  220. package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
  221. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  222. package/dist/modes/interactive/components/branch-summary-message.js +39 -0
  223. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  224. package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
  225. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  226. package/dist/modes/interactive/components/compaction-summary-message.js +40 -0
  227. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  228. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  229. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  230. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  231. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  232. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  233. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  234. package/dist/modes/interactive/components/custom-editor.js +69 -0
  235. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  236. package/dist/modes/interactive/components/custom-message.d.ts +19 -0
  237. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  238. package/dist/modes/interactive/components/custom-message.js +84 -0
  239. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  240. package/dist/modes/interactive/components/diff.d.ts +12 -0
  241. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  242. package/dist/modes/interactive/components/diff.js +133 -0
  243. package/dist/modes/interactive/components/diff.js.map +1 -0
  244. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  245. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  246. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  247. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  248. package/dist/modes/interactive/components/extension-editor.d.ts +15 -0
  249. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  250. package/dist/modes/interactive/components/extension-editor.js +96 -0
  251. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  252. package/dist/modes/interactive/components/extension-input.d.ts +20 -0
  253. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  254. package/dist/modes/interactive/components/extension-input.js +51 -0
  255. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  256. package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
  257. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  258. package/dist/modes/interactive/components/extension-selector.js +73 -0
  259. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  260. package/dist/modes/interactive/components/footer.d.ts +26 -0
  261. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  262. package/dist/modes/interactive/components/footer.js +207 -0
  263. package/dist/modes/interactive/components/footer.js.map +1 -0
  264. package/dist/modes/interactive/components/index.d.ts +29 -0
  265. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  266. package/dist/modes/interactive/components/index.js +30 -0
  267. package/dist/modes/interactive/components/index.js.map +1 -0
  268. package/dist/modes/interactive/components/login-dialog.d.ts +39 -0
  269. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  270. package/dist/modes/interactive/components/login-dialog.js +135 -0
  271. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  272. package/dist/modes/interactive/components/model-selector.d.ts +35 -0
  273. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  274. package/dist/modes/interactive/components/model-selector.js +211 -0
  275. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  276. package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
  277. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  278. package/dist/modes/interactive/components/oauth-selector.js +98 -0
  279. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  280. package/dist/modes/interactive/components/scoped-models-selector.d.ts +46 -0
  281. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  282. package/dist/modes/interactive/components/scoped-models-selector.js +258 -0
  283. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  284. package/dist/modes/interactive/components/session-selector.d.ts +44 -0
  285. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  286. package/dist/modes/interactive/components/session-selector.js +311 -0
  287. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  288. package/dist/modes/interactive/components/settings-selector.d.ts +43 -0
  289. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  290. package/dist/modes/interactive/components/settings-selector.js +219 -0
  291. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  292. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  293. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  294. package/dist/modes/interactive/components/show-images-selector.js +35 -0
  295. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  296. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  297. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  298. package/dist/modes/interactive/components/theme-selector.js +46 -0
  299. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  300. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  301. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  302. package/dist/modes/interactive/components/thinking-selector.js +47 -0
  303. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  304. package/dist/modes/interactive/components/tool-execution.d.ts +70 -0
  305. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  306. package/dist/modes/interactive/components/tool-execution.js +606 -0
  307. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  308. package/dist/modes/interactive/components/tree-selector.d.ts +52 -0
  309. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  310. package/dist/modes/interactive/components/tree-selector.js +745 -0
  311. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  312. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  313. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  314. package/dist/modes/interactive/components/user-message-selector.js +113 -0
  315. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  316. package/dist/modes/interactive/components/user-message.d.ts +8 -0
  317. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  318. package/dist/modes/interactive/components/user-message.js +16 -0
  319. package/dist/modes/interactive/components/user-message.js.map +1 -0
  320. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  321. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  322. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  323. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  324. package/dist/modes/interactive/interactive-mode.d.ts +261 -0
  325. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  326. package/dist/modes/interactive/interactive-mode.js +3194 -0
  327. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  328. package/dist/modes/interactive/theme/dark.json +85 -0
  329. package/dist/modes/interactive/theme/light.json +84 -0
  330. package/dist/modes/interactive/theme/theme-schema.json +308 -0
  331. package/dist/modes/interactive/theme/theme.d.ts +71 -0
  332. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  333. package/dist/modes/interactive/theme/theme.js +893 -0
  334. package/dist/modes/interactive/theme/theme.js.map +1 -0
  335. package/dist/modes/print-mode.d.ts +28 -0
  336. package/dist/modes/print-mode.d.ts.map +1 -0
  337. package/dist/modes/print-mode.js +140 -0
  338. package/dist/modes/print-mode.js.map +1 -0
  339. package/dist/modes/rpc/rpc-client.d.ts +209 -0
  340. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  341. package/dist/modes/rpc/rpc-client.js +392 -0
  342. package/dist/modes/rpc/rpc-client.js.map +1 -0
  343. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  344. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  345. package/dist/modes/rpc/rpc-mode.js +486 -0
  346. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  347. package/dist/modes/rpc/rpc-types.d.ts +372 -0
  348. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  349. package/dist/modes/rpc/rpc-types.js +8 -0
  350. package/dist/modes/rpc/rpc-types.js.map +1 -0
  351. package/dist/utils/changelog.d.ts +21 -0
  352. package/dist/utils/changelog.d.ts.map +1 -0
  353. package/dist/utils/changelog.js +87 -0
  354. package/dist/utils/changelog.js.map +1 -0
  355. package/dist/utils/clipboard-image.d.ts +11 -0
  356. package/dist/utils/clipboard-image.d.ts.map +1 -0
  357. package/dist/utils/clipboard-image.js +129 -0
  358. package/dist/utils/clipboard-image.js.map +1 -0
  359. package/dist/utils/clipboard.d.ts +2 -0
  360. package/dist/utils/clipboard.d.ts.map +1 -0
  361. package/dist/utils/clipboard.js +73 -0
  362. package/dist/utils/clipboard.js.map +1 -0
  363. package/dist/utils/image-convert.d.ts +9 -0
  364. package/dist/utils/image-convert.d.ts.map +1 -0
  365. package/dist/utils/image-convert.js +31 -0
  366. package/dist/utils/image-convert.js.map +1 -0
  367. package/dist/utils/image-resize.d.ts +36 -0
  368. package/dist/utils/image-resize.d.ts.map +1 -0
  369. package/dist/utils/image-resize.js +188 -0
  370. package/dist/utils/image-resize.js.map +1 -0
  371. package/dist/utils/mime.d.ts +2 -0
  372. package/dist/utils/mime.d.ts.map +1 -0
  373. package/dist/utils/mime.js +26 -0
  374. package/dist/utils/mime.js.map +1 -0
  375. package/dist/utils/shell.d.ts +26 -0
  376. package/dist/utils/shell.d.ts.map +1 -0
  377. package/dist/utils/shell.js +151 -0
  378. package/dist/utils/shell.js.map +1 -0
  379. package/dist/utils/tools-manager.d.ts +3 -0
  380. package/dist/utils/tools-manager.d.ts.map +1 -0
  381. package/dist/utils/tools-manager.js +187 -0
  382. package/dist/utils/tools-manager.js.map +1 -0
  383. package/dist/utils/vips.d.ts +11 -0
  384. package/dist/utils/vips.d.ts.map +1 -0
  385. package/dist/utils/vips.js +35 -0
  386. package/dist/utils/vips.js.map +1 -0
  387. package/docs/compaction.md +388 -0
  388. package/docs/extensions.md +1524 -0
  389. package/docs/rpc.md +1046 -0
  390. package/docs/sdk.md +1024 -0
  391. package/docs/session.md +255 -0
  392. package/docs/skills.md +317 -0
  393. package/docs/theme.md +617 -0
  394. package/docs/tree.md +201 -0
  395. package/docs/tui.md +797 -0
  396. package/examples/README.md +24 -0
  397. package/examples/extensions/README.md +168 -0
  398. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  399. package/examples/extensions/chalk-logger.ts +26 -0
  400. package/examples/extensions/claude-rules.ts +86 -0
  401. package/examples/extensions/confirm-destructive.ts +59 -0
  402. package/examples/extensions/custom-compaction.ts +114 -0
  403. package/examples/extensions/custom-footer.ts +64 -0
  404. package/examples/extensions/custom-header.ts +72 -0
  405. package/examples/extensions/dirty-repo-guard.ts +56 -0
  406. package/examples/extensions/doom-overlay/README.md +46 -0
  407. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  408. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  409. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  410. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  411. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  412. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  413. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  414. package/examples/extensions/doom-overlay/index.ts +74 -0
  415. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  416. package/examples/extensions/file-trigger.ts +41 -0
  417. package/examples/extensions/git-checkpoint.ts +53 -0
  418. package/examples/extensions/handoff.ts +150 -0
  419. package/examples/extensions/hello.ts +25 -0
  420. package/examples/extensions/interactive-shell.ts +196 -0
  421. package/examples/extensions/mac-system-theme.ts +47 -0
  422. package/examples/extensions/modal-editor.ts +85 -0
  423. package/examples/extensions/model-status.ts +31 -0
  424. package/examples/extensions/notify.ts +25 -0
  425. package/examples/extensions/overlay-qa-tests.ts +881 -0
  426. package/examples/extensions/overlay-test.ts +145 -0
  427. package/examples/extensions/permission-gate.ts +34 -0
  428. package/examples/extensions/pirate.ts +47 -0
  429. package/examples/extensions/plan-mode/README.md +65 -0
  430. package/examples/extensions/plan-mode/index.ts +340 -0
  431. package/examples/extensions/plan-mode/utils.ts +168 -0
  432. package/examples/extensions/preset.ts +398 -0
  433. package/examples/extensions/protected-paths.ts +30 -0
  434. package/examples/extensions/qna.ts +119 -0
  435. package/examples/extensions/question.ts +277 -0
  436. package/examples/extensions/questionnaire.ts +427 -0
  437. package/examples/extensions/rainbow-editor.ts +95 -0
  438. package/examples/extensions/sandbox/index.ts +318 -0
  439. package/examples/extensions/sandbox/package-lock.json +92 -0
  440. package/examples/extensions/sandbox/package.json +19 -0
  441. package/examples/extensions/send-user-message.ts +97 -0
  442. package/examples/extensions/shutdown-command.ts +63 -0
  443. package/examples/extensions/snake.ts +343 -0
  444. package/examples/extensions/ssh.ts +220 -0
  445. package/examples/extensions/status-line.ts +40 -0
  446. package/examples/extensions/subagent/README.md +172 -0
  447. package/examples/extensions/subagent/agents/planner.md +37 -0
  448. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  449. package/examples/extensions/subagent/agents/scout.md +50 -0
  450. package/examples/extensions/subagent/agents/worker.md +24 -0
  451. package/examples/extensions/subagent/agents.ts +156 -0
  452. package/examples/extensions/subagent/index.ts +963 -0
  453. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  454. package/examples/extensions/subagent/prompts/implement.md +10 -0
  455. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  456. package/examples/extensions/summarize.ts +195 -0
  457. package/examples/extensions/timed-confirm.ts +70 -0
  458. package/examples/extensions/todo.ts +299 -0
  459. package/examples/extensions/tool-override.ts +143 -0
  460. package/examples/extensions/tools.ts +146 -0
  461. package/examples/extensions/truncated-tool.ts +192 -0
  462. package/examples/extensions/with-deps/index.ts +36 -0
  463. package/examples/extensions/with-deps/package-lock.json +31 -0
  464. package/examples/extensions/with-deps/package.json +22 -0
  465. package/examples/sdk/01-minimal.ts +22 -0
  466. package/examples/sdk/02-custom-model.ts +49 -0
  467. package/examples/sdk/03-custom-prompt.ts +44 -0
  468. package/examples/sdk/04-skills.ts +47 -0
  469. package/examples/sdk/05-tools.ts +56 -0
  470. package/examples/sdk/06-extensions.ts +79 -0
  471. package/examples/sdk/07-context-files.ts +36 -0
  472. package/examples/sdk/08-prompt-templates.ts +42 -0
  473. package/examples/sdk/09-api-keys-and-oauth.ts +55 -0
  474. package/examples/sdk/10-settings.ts +38 -0
  475. package/examples/sdk/11-sessions.ts +48 -0
  476. package/examples/sdk/12-full-control.ts +72 -0
  477. package/examples/sdk/README.md +150 -0
  478. package/package.json +88 -0
@@ -0,0 +1,606 @@
1
+ import * as os from "node:os";
2
+ import { Box, Container, getCapabilities, getImageDimensions, Image, imageFallback, Spacer, Text, } from "@mariozechner/pi-tui";
3
+ import stripAnsi from "strip-ansi";
4
+ import { computeEditDiff } from "../../../core/tools/edit-diff.js";
5
+ import { allTools } from "../../../core/tools/index.js";
6
+ import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "../../../core/tools/truncate.js";
7
+ import { convertToPng } from "../../../utils/image-convert.js";
8
+ import { sanitizeBinaryOutput } from "../../../utils/shell.js";
9
+ import { getLanguageFromPath, highlightCode, theme } from "../theme/theme.js";
10
+ import { renderDiff } from "./diff.js";
11
+ import { truncateToVisualLines } from "./visual-truncate.js";
12
+ // Preview line limit for bash when not expanded
13
+ const BASH_PREVIEW_LINES = 5;
14
+ /**
15
+ * Convert absolute path to tilde notation if it's in home directory
16
+ */
17
+ function shortenPath(path) {
18
+ const home = os.homedir();
19
+ if (path.startsWith(home)) {
20
+ return `~${path.slice(home.length)}`;
21
+ }
22
+ return path;
23
+ }
24
+ /**
25
+ * Replace tabs with spaces for consistent rendering
26
+ */
27
+ function replaceTabs(text) {
28
+ return text.replace(/\t/g, " ");
29
+ }
30
+ /**
31
+ * Component that renders a tool call with its result (updateable)
32
+ */
33
+ export class ToolExecutionComponent extends Container {
34
+ contentBox; // Used for custom tools and bash visual truncation
35
+ contentText; // For built-in tools (with its own padding/bg)
36
+ imageComponents = [];
37
+ imageSpacers = [];
38
+ toolName;
39
+ args;
40
+ expanded = false;
41
+ showImages;
42
+ isPartial = true;
43
+ toolDefinition;
44
+ ui;
45
+ cwd;
46
+ result;
47
+ // Cached edit diff preview (computed when args arrive, before tool executes)
48
+ editDiffPreview;
49
+ editDiffArgsKey; // Track which args the preview is for
50
+ // Cached converted images for Kitty protocol (which requires PNG), keyed by index
51
+ convertedImages = new Map();
52
+ constructor(toolName, args, options = {}, toolDefinition, ui, cwd = process.cwd()) {
53
+ super();
54
+ this.toolName = toolName;
55
+ this.args = args;
56
+ this.showImages = options.showImages ?? true;
57
+ this.toolDefinition = toolDefinition;
58
+ this.ui = ui;
59
+ this.cwd = cwd;
60
+ this.addChild(new Spacer(1));
61
+ // Always create both - contentBox for custom tools/bash, contentText for other built-ins
62
+ this.contentBox = new Box(1, 1, (text) => theme.bg("toolPendingBg", text));
63
+ this.contentText = new Text("", 1, 1, (text) => theme.bg("toolPendingBg", text));
64
+ // Use contentBox for bash (visual truncation) or custom tools with custom renderers
65
+ // Use contentText for built-in tools (including overrides without custom renderers)
66
+ if (toolName === "bash" || (toolDefinition && !this.shouldUseBuiltInRenderer())) {
67
+ this.addChild(this.contentBox);
68
+ }
69
+ else {
70
+ this.addChild(this.contentText);
71
+ }
72
+ this.updateDisplay();
73
+ }
74
+ /**
75
+ * Check if we should use built-in rendering for this tool.
76
+ * Returns true if the tool name is a built-in AND either there's no toolDefinition
77
+ * or the toolDefinition doesn't provide custom renderers.
78
+ */
79
+ shouldUseBuiltInRenderer() {
80
+ const isBuiltInName = this.toolName in allTools;
81
+ const hasCustomRenderers = this.toolDefinition?.renderCall || this.toolDefinition?.renderResult;
82
+ return isBuiltInName && !hasCustomRenderers;
83
+ }
84
+ updateArgs(args) {
85
+ this.args = args;
86
+ this.updateDisplay();
87
+ }
88
+ /**
89
+ * Signal that args are complete (tool is about to execute).
90
+ * This triggers diff computation for edit tool.
91
+ */
92
+ setArgsComplete() {
93
+ this.maybeComputeEditDiff();
94
+ }
95
+ /**
96
+ * Compute edit diff preview when we have complete args.
97
+ * This runs async and updates display when done.
98
+ */
99
+ maybeComputeEditDiff() {
100
+ if (this.toolName !== "edit")
101
+ return;
102
+ const path = this.args?.path;
103
+ const oldText = this.args?.oldText;
104
+ const newText = this.args?.newText;
105
+ // Need all three params to compute diff
106
+ if (!path || oldText === undefined || newText === undefined)
107
+ return;
108
+ // Create a key to track which args this computation is for
109
+ const argsKey = JSON.stringify({ path, oldText, newText });
110
+ // Skip if we already computed for these exact args
111
+ if (this.editDiffArgsKey === argsKey)
112
+ return;
113
+ this.editDiffArgsKey = argsKey;
114
+ // Compute diff async
115
+ computeEditDiff(path, oldText, newText, this.cwd).then((result) => {
116
+ // Only update if args haven't changed since we started
117
+ if (this.editDiffArgsKey === argsKey) {
118
+ this.editDiffPreview = result;
119
+ this.updateDisplay();
120
+ this.ui.requestRender();
121
+ }
122
+ });
123
+ }
124
+ updateResult(result, isPartial = false) {
125
+ this.result = result;
126
+ this.isPartial = isPartial;
127
+ this.updateDisplay();
128
+ // Convert non-PNG images to PNG for Kitty protocol (async)
129
+ this.maybeConvertImagesForKitty();
130
+ }
131
+ /**
132
+ * Convert non-PNG images to PNG for Kitty graphics protocol.
133
+ * Kitty requires PNG format (f=100), so JPEG/GIF/WebP won't display.
134
+ */
135
+ maybeConvertImagesForKitty() {
136
+ const caps = getCapabilities();
137
+ // Only needed for Kitty protocol
138
+ if (caps.images !== "kitty")
139
+ return;
140
+ if (!this.result)
141
+ return;
142
+ const imageBlocks = this.result.content?.filter((c) => c.type === "image") || [];
143
+ for (let i = 0; i < imageBlocks.length; i++) {
144
+ const img = imageBlocks[i];
145
+ if (!img.data || !img.mimeType)
146
+ continue;
147
+ // Skip if already PNG or already converted
148
+ if (img.mimeType === "image/png")
149
+ continue;
150
+ if (this.convertedImages.has(i))
151
+ continue;
152
+ // Convert async
153
+ const index = i;
154
+ convertToPng(img.data, img.mimeType).then((converted) => {
155
+ if (converted) {
156
+ this.convertedImages.set(index, converted);
157
+ this.updateDisplay();
158
+ this.ui.requestRender();
159
+ }
160
+ });
161
+ }
162
+ }
163
+ setExpanded(expanded) {
164
+ this.expanded = expanded;
165
+ this.updateDisplay();
166
+ }
167
+ setShowImages(show) {
168
+ this.showImages = show;
169
+ this.updateDisplay();
170
+ }
171
+ invalidate() {
172
+ super.invalidate();
173
+ this.updateDisplay();
174
+ }
175
+ updateDisplay() {
176
+ // Set background based on state
177
+ const bgFn = this.isPartial
178
+ ? (text) => theme.bg("toolPendingBg", text)
179
+ : this.result?.isError
180
+ ? (text) => theme.bg("toolErrorBg", text)
181
+ : (text) => theme.bg("toolSuccessBg", text);
182
+ // Use built-in rendering for built-in tools (or overrides without custom renderers)
183
+ if (this.shouldUseBuiltInRenderer()) {
184
+ if (this.toolName === "bash") {
185
+ // Bash uses Box with visual line truncation
186
+ this.contentBox.setBgFn(bgFn);
187
+ this.contentBox.clear();
188
+ this.renderBashContent();
189
+ }
190
+ else {
191
+ // Other built-in tools: use Text directly with caching
192
+ this.contentText.setCustomBgFn(bgFn);
193
+ this.contentText.setText(this.formatToolExecution());
194
+ }
195
+ }
196
+ else if (this.toolDefinition) {
197
+ // Custom tools use Box for flexible component rendering
198
+ this.contentBox.setBgFn(bgFn);
199
+ this.contentBox.clear();
200
+ // Render call component
201
+ if (this.toolDefinition.renderCall) {
202
+ try {
203
+ const callComponent = this.toolDefinition.renderCall(this.args, theme);
204
+ if (callComponent) {
205
+ this.contentBox.addChild(callComponent);
206
+ }
207
+ }
208
+ catch {
209
+ // Fall back to default on error
210
+ this.contentBox.addChild(new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0));
211
+ }
212
+ }
213
+ else {
214
+ // No custom renderCall, show tool name
215
+ this.contentBox.addChild(new Text(theme.fg("toolTitle", theme.bold(this.toolName)), 0, 0));
216
+ }
217
+ // Render result component if we have a result
218
+ if (this.result && this.toolDefinition.renderResult) {
219
+ try {
220
+ const resultComponent = this.toolDefinition.renderResult({ content: this.result.content, details: this.result.details }, { expanded: this.expanded, isPartial: this.isPartial }, theme);
221
+ if (resultComponent) {
222
+ this.contentBox.addChild(resultComponent);
223
+ }
224
+ }
225
+ catch {
226
+ // Fall back to showing raw output on error
227
+ const output = this.getTextOutput();
228
+ if (output) {
229
+ this.contentBox.addChild(new Text(theme.fg("toolOutput", output), 0, 0));
230
+ }
231
+ }
232
+ }
233
+ else if (this.result) {
234
+ // Has result but no custom renderResult
235
+ const output = this.getTextOutput();
236
+ if (output) {
237
+ this.contentBox.addChild(new Text(theme.fg("toolOutput", output), 0, 0));
238
+ }
239
+ }
240
+ }
241
+ // Handle images (same for both custom and built-in)
242
+ for (const img of this.imageComponents) {
243
+ this.removeChild(img);
244
+ }
245
+ this.imageComponents = [];
246
+ for (const spacer of this.imageSpacers) {
247
+ this.removeChild(spacer);
248
+ }
249
+ this.imageSpacers = [];
250
+ if (this.result) {
251
+ const imageBlocks = this.result.content?.filter((c) => c.type === "image") || [];
252
+ const caps = getCapabilities();
253
+ for (let i = 0; i < imageBlocks.length; i++) {
254
+ const img = imageBlocks[i];
255
+ if (caps.images && this.showImages && img.data && img.mimeType) {
256
+ // Use converted PNG for Kitty protocol if available
257
+ const converted = this.convertedImages.get(i);
258
+ const imageData = converted?.data ?? img.data;
259
+ const imageMimeType = converted?.mimeType ?? img.mimeType;
260
+ // For Kitty, skip non-PNG images that haven't been converted yet
261
+ if (caps.images === "kitty" && imageMimeType !== "image/png") {
262
+ continue;
263
+ }
264
+ const spacer = new Spacer(1);
265
+ this.addChild(spacer);
266
+ this.imageSpacers.push(spacer);
267
+ const imageComponent = new Image(imageData, imageMimeType, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: 60 });
268
+ this.imageComponents.push(imageComponent);
269
+ this.addChild(imageComponent);
270
+ }
271
+ }
272
+ }
273
+ }
274
+ /**
275
+ * Render bash content using visual line truncation (like bash-execution.ts)
276
+ */
277
+ renderBashContent() {
278
+ const command = this.args?.command || "";
279
+ // Header
280
+ this.contentBox.addChild(new Text(theme.fg("toolTitle", theme.bold(`$ ${command || theme.fg("toolOutput", "...")}`)), 0, 0));
281
+ if (this.result) {
282
+ const output = this.getTextOutput().trim();
283
+ if (output) {
284
+ // Style each line for the output
285
+ const styledOutput = output
286
+ .split("\n")
287
+ .map((line) => theme.fg("toolOutput", line))
288
+ .join("\n");
289
+ if (this.expanded) {
290
+ // Show all lines when expanded
291
+ this.contentBox.addChild(new Text(`\n${styledOutput}`, 0, 0));
292
+ }
293
+ else {
294
+ // Use visual line truncation when collapsed with width-aware caching
295
+ const textContent = `\n${styledOutput}`;
296
+ let cachedWidth;
297
+ let cachedLines;
298
+ let cachedSkipped;
299
+ this.contentBox.addChild({
300
+ render: (width) => {
301
+ if (cachedLines === undefined || cachedWidth !== width) {
302
+ const result = truncateToVisualLines(textContent, BASH_PREVIEW_LINES, width);
303
+ cachedLines = result.visualLines;
304
+ cachedSkipped = result.skippedCount;
305
+ cachedWidth = width;
306
+ }
307
+ return cachedSkipped && cachedSkipped > 0
308
+ ? ["", theme.fg("toolOutput", `... (${cachedSkipped} earlier lines)`), ...cachedLines]
309
+ : cachedLines;
310
+ },
311
+ invalidate: () => {
312
+ cachedWidth = undefined;
313
+ cachedLines = undefined;
314
+ cachedSkipped = undefined;
315
+ },
316
+ });
317
+ }
318
+ }
319
+ // Truncation warnings
320
+ const truncation = this.result.details?.truncation;
321
+ const fullOutputPath = this.result.details?.fullOutputPath;
322
+ if (truncation?.truncated || fullOutputPath) {
323
+ const warnings = [];
324
+ if (fullOutputPath) {
325
+ warnings.push(`Full output: ${fullOutputPath}`);
326
+ }
327
+ if (truncation?.truncated) {
328
+ if (truncation.truncatedBy === "lines") {
329
+ warnings.push(`Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`);
330
+ }
331
+ else {
332
+ warnings.push(`Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)`);
333
+ }
334
+ }
335
+ this.contentBox.addChild(new Text(`\n${theme.fg("warning", `[${warnings.join(". ")}]`)}`, 0, 0));
336
+ }
337
+ }
338
+ }
339
+ getTextOutput() {
340
+ if (!this.result)
341
+ return "";
342
+ const textBlocks = this.result.content?.filter((c) => c.type === "text") || [];
343
+ const imageBlocks = this.result.content?.filter((c) => c.type === "image") || [];
344
+ let output = textBlocks
345
+ .map((c) => {
346
+ // Use sanitizeBinaryOutput to handle binary data that crashes string-width
347
+ return sanitizeBinaryOutput(stripAnsi(c.text || "")).replace(/\r/g, "");
348
+ })
349
+ .join("\n");
350
+ const caps = getCapabilities();
351
+ if (imageBlocks.length > 0 && (!caps.images || !this.showImages)) {
352
+ const imageIndicators = imageBlocks
353
+ .map((img) => {
354
+ const dims = img.data ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;
355
+ return imageFallback(img.mimeType, dims);
356
+ })
357
+ .join("\n");
358
+ output = output ? `${output}\n${imageIndicators}` : imageIndicators;
359
+ }
360
+ return output;
361
+ }
362
+ formatToolExecution() {
363
+ let text = "";
364
+ if (this.toolName === "read") {
365
+ const path = shortenPath(this.args?.file_path || this.args?.path || "");
366
+ const offset = this.args?.offset;
367
+ const limit = this.args?.limit;
368
+ let pathDisplay = path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
369
+ if (offset !== undefined || limit !== undefined) {
370
+ const startLine = offset ?? 1;
371
+ const endLine = limit !== undefined ? startLine + limit - 1 : "";
372
+ pathDisplay += theme.fg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
373
+ }
374
+ text = `${theme.fg("toolTitle", theme.bold("read"))} ${pathDisplay}`;
375
+ if (this.result) {
376
+ const output = this.getTextOutput();
377
+ const rawPath = this.args?.file_path || this.args?.path || "";
378
+ const lang = getLanguageFromPath(rawPath);
379
+ const lines = lang ? highlightCode(replaceTabs(output), lang) : output.split("\n");
380
+ const maxLines = this.expanded ? lines.length : 10;
381
+ const displayLines = lines.slice(0, maxLines);
382
+ const remaining = lines.length - maxLines;
383
+ text +=
384
+ "\n\n" +
385
+ displayLines
386
+ .map((line) => (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line))))
387
+ .join("\n");
388
+ if (remaining > 0) {
389
+ text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
390
+ }
391
+ const truncation = this.result.details?.truncation;
392
+ if (truncation?.truncated) {
393
+ if (truncation.firstLineExceedsLimit) {
394
+ text +=
395
+ "\n" +
396
+ theme.fg("warning", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`);
397
+ }
398
+ else if (truncation.truncatedBy === "lines") {
399
+ text +=
400
+ "\n" +
401
+ theme.fg("warning", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`);
402
+ }
403
+ else {
404
+ text +=
405
+ "\n" +
406
+ theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`);
407
+ }
408
+ }
409
+ }
410
+ }
411
+ else if (this.toolName === "write") {
412
+ const rawPath = this.args?.file_path || this.args?.path || "";
413
+ const path = shortenPath(rawPath);
414
+ const fileContent = this.args?.content || "";
415
+ const lang = getLanguageFromPath(rawPath);
416
+ const lines = fileContent
417
+ ? lang
418
+ ? highlightCode(replaceTabs(fileContent), lang)
419
+ : fileContent.split("\n")
420
+ : [];
421
+ const totalLines = lines.length;
422
+ text =
423
+ theme.fg("toolTitle", theme.bold("write")) +
424
+ " " +
425
+ (path ? theme.fg("accent", path) : theme.fg("toolOutput", "..."));
426
+ if (fileContent) {
427
+ const maxLines = this.expanded ? lines.length : 10;
428
+ const displayLines = lines.slice(0, maxLines);
429
+ const remaining = lines.length - maxLines;
430
+ text +=
431
+ "\n\n" +
432
+ displayLines
433
+ .map((line) => (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line))))
434
+ .join("\n");
435
+ if (remaining > 0) {
436
+ text += theme.fg("toolOutput", `\n... (${remaining} more lines, ${totalLines} total)`);
437
+ }
438
+ }
439
+ }
440
+ else if (this.toolName === "edit") {
441
+ const rawPath = this.args?.file_path || this.args?.path || "";
442
+ const path = shortenPath(rawPath);
443
+ // Build path display, appending :line if we have diff info
444
+ let pathDisplay = path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
445
+ const firstChangedLine = (this.editDiffPreview && "firstChangedLine" in this.editDiffPreview
446
+ ? this.editDiffPreview.firstChangedLine
447
+ : undefined) ||
448
+ (this.result && !this.result.isError ? this.result.details?.firstChangedLine : undefined);
449
+ if (firstChangedLine) {
450
+ pathDisplay += theme.fg("warning", `:${firstChangedLine}`);
451
+ }
452
+ text = `${theme.fg("toolTitle", theme.bold("edit"))} ${pathDisplay}`;
453
+ if (this.result?.isError) {
454
+ // Show error from result
455
+ const errorText = this.getTextOutput();
456
+ if (errorText) {
457
+ text += `\n\n${theme.fg("error", errorText)}`;
458
+ }
459
+ }
460
+ else if (this.result?.details?.diff) {
461
+ // Tool executed successfully - use the diff from result
462
+ // This takes priority over editDiffPreview which may have a stale error
463
+ // due to race condition (async preview computed after file was modified)
464
+ text += `\n\n${renderDiff(this.result.details.diff, { filePath: rawPath })}`;
465
+ }
466
+ else if (this.editDiffPreview) {
467
+ // Use cached diff preview (before tool executes)
468
+ if ("error" in this.editDiffPreview) {
469
+ text += `\n\n${theme.fg("error", this.editDiffPreview.error)}`;
470
+ }
471
+ else if (this.editDiffPreview.diff) {
472
+ text += `\n\n${renderDiff(this.editDiffPreview.diff, { filePath: rawPath })}`;
473
+ }
474
+ }
475
+ }
476
+ else if (this.toolName === "ls") {
477
+ const path = shortenPath(this.args?.path || ".");
478
+ const limit = this.args?.limit;
479
+ text = `${theme.fg("toolTitle", theme.bold("ls"))} ${theme.fg("accent", path)}`;
480
+ if (limit !== undefined) {
481
+ text += theme.fg("toolOutput", ` (limit ${limit})`);
482
+ }
483
+ if (this.result) {
484
+ const output = this.getTextOutput().trim();
485
+ if (output) {
486
+ const lines = output.split("\n");
487
+ const maxLines = this.expanded ? lines.length : 20;
488
+ const displayLines = lines.slice(0, maxLines);
489
+ const remaining = lines.length - maxLines;
490
+ text += `\n\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
491
+ if (remaining > 0) {
492
+ text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
493
+ }
494
+ }
495
+ const entryLimit = this.result.details?.entryLimitReached;
496
+ const truncation = this.result.details?.truncation;
497
+ if (entryLimit || truncation?.truncated) {
498
+ const warnings = [];
499
+ if (entryLimit) {
500
+ warnings.push(`${entryLimit} entries limit`);
501
+ }
502
+ if (truncation?.truncated) {
503
+ warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
504
+ }
505
+ text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
506
+ }
507
+ }
508
+ }
509
+ else if (this.toolName === "find") {
510
+ const pattern = this.args?.pattern || "";
511
+ const path = shortenPath(this.args?.path || ".");
512
+ const limit = this.args?.limit;
513
+ text =
514
+ theme.fg("toolTitle", theme.bold("find")) +
515
+ " " +
516
+ theme.fg("accent", pattern) +
517
+ theme.fg("toolOutput", ` in ${path}`);
518
+ if (limit !== undefined) {
519
+ text += theme.fg("toolOutput", ` (limit ${limit})`);
520
+ }
521
+ if (this.result) {
522
+ const output = this.getTextOutput().trim();
523
+ if (output) {
524
+ const lines = output.split("\n");
525
+ const maxLines = this.expanded ? lines.length : 20;
526
+ const displayLines = lines.slice(0, maxLines);
527
+ const remaining = lines.length - maxLines;
528
+ text += `\n\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
529
+ if (remaining > 0) {
530
+ text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
531
+ }
532
+ }
533
+ const resultLimit = this.result.details?.resultLimitReached;
534
+ const truncation = this.result.details?.truncation;
535
+ if (resultLimit || truncation?.truncated) {
536
+ const warnings = [];
537
+ if (resultLimit) {
538
+ warnings.push(`${resultLimit} results limit`);
539
+ }
540
+ if (truncation?.truncated) {
541
+ warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
542
+ }
543
+ text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
544
+ }
545
+ }
546
+ }
547
+ else if (this.toolName === "grep") {
548
+ const pattern = this.args?.pattern || "";
549
+ const path = shortenPath(this.args?.path || ".");
550
+ const glob = this.args?.glob;
551
+ const limit = this.args?.limit;
552
+ text =
553
+ theme.fg("toolTitle", theme.bold("grep")) +
554
+ " " +
555
+ theme.fg("accent", `/${pattern}/`) +
556
+ theme.fg("toolOutput", ` in ${path}`);
557
+ if (glob) {
558
+ text += theme.fg("toolOutput", ` (${glob})`);
559
+ }
560
+ if (limit !== undefined) {
561
+ text += theme.fg("toolOutput", ` limit ${limit}`);
562
+ }
563
+ if (this.result) {
564
+ const output = this.getTextOutput().trim();
565
+ if (output) {
566
+ const lines = output.split("\n");
567
+ const maxLines = this.expanded ? lines.length : 15;
568
+ const displayLines = lines.slice(0, maxLines);
569
+ const remaining = lines.length - maxLines;
570
+ text += `\n\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
571
+ if (remaining > 0) {
572
+ text += theme.fg("toolOutput", `\n... (${remaining} more lines)`);
573
+ }
574
+ }
575
+ const matchLimit = this.result.details?.matchLimitReached;
576
+ const truncation = this.result.details?.truncation;
577
+ const linesTruncated = this.result.details?.linesTruncated;
578
+ if (matchLimit || truncation?.truncated || linesTruncated) {
579
+ const warnings = [];
580
+ if (matchLimit) {
581
+ warnings.push(`${matchLimit} matches limit`);
582
+ }
583
+ if (truncation?.truncated) {
584
+ warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
585
+ }
586
+ if (linesTruncated) {
587
+ warnings.push("some lines truncated");
588
+ }
589
+ text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
590
+ }
591
+ }
592
+ }
593
+ else {
594
+ // Generic tool (shouldn't reach here for custom tools)
595
+ text = theme.fg("toolTitle", theme.bold(this.toolName));
596
+ const content = JSON.stringify(this.args, null, 2);
597
+ text += `\n\n${content}`;
598
+ const output = this.getTextOutput();
599
+ if (output) {
600
+ text += `\n${output}`;
601
+ }
602
+ }
603
+ return text;
604
+ }
605
+ }
606
+ //# sourceMappingURL=tool-execution.js.map