@travisennis/acai 0.0.9 → 0.0.11

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 (403) hide show
  1. package/README.md +51 -760
  2. package/bin/acai +52 -0
  3. package/dist/agent/index.d.ts +12 -2
  4. package/dist/agent/index.d.ts.map +1 -1
  5. package/dist/agent/index.js +380 -199
  6. package/dist/agent/sub-agent.d.ts +23 -0
  7. package/dist/agent/sub-agent.d.ts.map +1 -0
  8. package/dist/agent/sub-agent.js +109 -0
  9. package/dist/cli/index.d.ts +26 -0
  10. package/dist/cli/index.d.ts.map +1 -0
  11. package/dist/{cli.js → cli/index.js} +84 -77
  12. package/dist/{stdin.d.ts → cli/stdin.d.ts} +2 -1
  13. package/dist/cli/stdin.d.ts.map +1 -0
  14. package/dist/{stdin.js → cli/stdin.js} +11 -0
  15. package/dist/commands/copy/index.js +2 -2
  16. package/dist/commands/copy/utils.d.ts.map +1 -1
  17. package/dist/commands/copy/utils.js +15 -13
  18. package/dist/commands/generate-rules/index.d.ts +1 -1
  19. package/dist/commands/generate-rules/index.d.ts.map +1 -1
  20. package/dist/commands/generate-rules/index.js +16 -101
  21. package/dist/commands/generate-rules/service.d.ts +22 -0
  22. package/dist/commands/generate-rules/service.d.ts.map +1 -0
  23. package/dist/commands/generate-rules/service.js +103 -0
  24. package/dist/commands/handoff/index.js +2 -2
  25. package/dist/commands/health/index.js +1 -1
  26. package/dist/commands/health/utils.d.ts +3 -2
  27. package/dist/commands/health/utils.d.ts.map +1 -1
  28. package/dist/commands/health/utils.js +6 -0
  29. package/dist/commands/history/index.d.ts +1 -1
  30. package/dist/commands/history/index.d.ts.map +1 -1
  31. package/dist/commands/history/index.js +17 -18
  32. package/dist/commands/history/types.d.ts +38 -0
  33. package/dist/commands/history/types.d.ts.map +1 -1
  34. package/dist/commands/history/utils.d.ts.map +1 -1
  35. package/dist/commands/history/utils.js +63 -58
  36. package/dist/commands/init/index.d.ts.map +1 -1
  37. package/dist/commands/init/index.js +3 -8
  38. package/dist/commands/init-project/index.d.ts.map +1 -1
  39. package/dist/commands/init-project/index.js +3 -3
  40. package/dist/commands/init-project/utils.d.ts +2 -1
  41. package/dist/commands/init-project/utils.d.ts.map +1 -1
  42. package/dist/commands/init-project/utils.js +10 -2
  43. package/dist/commands/list-tools/index.d.ts.map +1 -1
  44. package/dist/commands/list-tools/index.js +7 -31
  45. package/dist/commands/manager.d.ts +2 -2
  46. package/dist/commands/manager.d.ts.map +1 -1
  47. package/dist/commands/manager.js +55 -33
  48. package/dist/commands/model/index.d.ts.map +1 -1
  49. package/dist/commands/model/index.js +20 -151
  50. package/dist/commands/model/model-panel.d.ts +4 -0
  51. package/dist/commands/model/model-panel.d.ts.map +1 -0
  52. package/dist/commands/model/model-panel.js +144 -0
  53. package/dist/commands/paste/index.d.ts.map +1 -1
  54. package/dist/commands/paste/index.js +59 -62
  55. package/dist/commands/paste/utils.d.ts.map +1 -1
  56. package/dist/commands/paste/utils.js +88 -58
  57. package/dist/commands/pickup/index.d.ts.map +1 -1
  58. package/dist/commands/pickup/index.js +6 -3
  59. package/dist/commands/pickup/utils.js +3 -3
  60. package/dist/commands/resources/index.d.ts.map +1 -1
  61. package/dist/commands/resources/index.js +33 -50
  62. package/dist/commands/review/index.d.ts.map +1 -1
  63. package/dist/commands/review/index.js +3 -117
  64. package/dist/commands/review/review-panel.d.ts +3 -0
  65. package/dist/commands/review/review-panel.d.ts.map +1 -0
  66. package/dist/commands/review/review-panel.js +186 -0
  67. package/dist/commands/review/utils.d.ts +15 -1
  68. package/dist/commands/review/utils.d.ts.map +1 -1
  69. package/dist/commands/review/utils.js +127 -68
  70. package/dist/commands/session/index.d.ts +1 -1
  71. package/dist/commands/session/index.d.ts.map +1 -1
  72. package/dist/commands/session/index.js +124 -135
  73. package/dist/commands/shell/index.d.ts.map +1 -1
  74. package/dist/commands/shell/index.js +16 -1
  75. package/dist/commands/types.d.ts +2 -2
  76. package/dist/commands/types.d.ts.map +1 -1
  77. package/dist/{config.d.ts → config/index.d.ts} +20 -9
  78. package/dist/config/index.d.ts.map +1 -0
  79. package/dist/{config.js → config/index.js} +43 -42
  80. package/dist/execution/index.d.ts.map +1 -1
  81. package/dist/execution/index.js +75 -55
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +148 -141
  85. package/dist/middleware/cache.d.ts.map +1 -1
  86. package/dist/middleware/cache.js +18 -36
  87. package/dist/models/ai-config.d.ts +1 -0
  88. package/dist/models/ai-config.d.ts.map +1 -1
  89. package/dist/models/ai-config.js +4 -3
  90. package/dist/models/anthropic-provider.d.ts +2 -5
  91. package/dist/models/anthropic-provider.d.ts.map +1 -1
  92. package/dist/models/anthropic-provider.js +3 -70
  93. package/dist/models/deepseek-provider.d.ts +1 -0
  94. package/dist/models/deepseek-provider.d.ts.map +1 -1
  95. package/dist/models/google-provider.d.ts +2 -3
  96. package/dist/models/google-provider.d.ts.map +1 -1
  97. package/dist/models/google-provider.js +0 -26
  98. package/dist/models/groq-provider.d.ts +1 -0
  99. package/dist/models/groq-provider.d.ts.map +1 -1
  100. package/dist/models/manager.d.ts +13 -2
  101. package/dist/models/manager.d.ts.map +1 -1
  102. package/dist/models/manager.js +20 -8
  103. package/dist/models/openai-provider.d.ts +2 -5
  104. package/dist/models/openai-provider.d.ts.map +1 -1
  105. package/dist/models/openai-provider.js +0 -52
  106. package/dist/models/opencode-go-provider.d.ts +25 -0
  107. package/dist/models/opencode-go-provider.d.ts.map +1 -0
  108. package/dist/models/opencode-go-provider.js +78 -0
  109. package/dist/models/opencode-zen-provider.d.ts +7 -3
  110. package/dist/models/opencode-zen-provider.d.ts.map +1 -1
  111. package/dist/models/opencode-zen-provider.js +49 -10
  112. package/dist/models/openrouter-provider.d.ts +27 -31
  113. package/dist/models/openrouter-provider.d.ts.map +1 -1
  114. package/dist/models/openrouter-provider.js +121 -180
  115. package/dist/models/providers.d.ts +3 -3
  116. package/dist/models/providers.d.ts.map +1 -1
  117. package/dist/models/providers.js +6 -0
  118. package/dist/models/xai-provider.d.ts +4 -3
  119. package/dist/models/xai-provider.d.ts.map +1 -1
  120. package/dist/models/xai-provider.js +18 -18
  121. package/dist/modes/manager.d.ts +24 -0
  122. package/dist/modes/manager.d.ts.map +1 -0
  123. package/dist/modes/manager.js +77 -0
  124. package/dist/modes/prompts.d.ts +2 -0
  125. package/dist/modes/prompts.d.ts.map +1 -0
  126. package/dist/modes/prompts.js +142 -0
  127. package/dist/prompts/mentions.d.ts +11 -0
  128. package/dist/prompts/mentions.d.ts.map +1 -0
  129. package/dist/{mentions.js → prompts/mentions.js} +55 -85
  130. package/dist/{prompts.d.ts → prompts/system-prompt.d.ts} +7 -2
  131. package/dist/prompts/system-prompt.d.ts.map +1 -0
  132. package/dist/{prompts.js → prompts/system-prompt.js} +31 -16
  133. package/dist/repl/index.d.ts +174 -0
  134. package/dist/repl/index.d.ts.map +1 -0
  135. package/dist/{repl-new.js → repl/index.js} +397 -76
  136. package/dist/repl/project-status.d.ts +1 -0
  137. package/dist/repl/project-status.d.ts.map +1 -1
  138. package/dist/repl/project-status.js +4 -1
  139. package/dist/sessions/manager.d.ts +92 -0
  140. package/dist/sessions/manager.d.ts.map +1 -1
  141. package/dist/sessions/manager.js +262 -9
  142. package/dist/sessions/summary.d.ts +4 -0
  143. package/dist/sessions/summary.d.ts.map +1 -0
  144. package/dist/sessions/summary.js +30 -0
  145. package/dist/skills/index.d.ts +29 -0
  146. package/dist/skills/index.d.ts.map +1 -0
  147. package/dist/skills/index.js +294 -0
  148. package/dist/subagents/index.d.ts +16 -0
  149. package/dist/subagents/index.d.ts.map +1 -0
  150. package/dist/subagents/index.js +231 -0
  151. package/dist/terminal/control.d.ts +1 -1
  152. package/dist/terminal/control.d.ts.map +1 -1
  153. package/dist/terminal/control.js +3 -3
  154. package/dist/terminal/east-asian-width.d.ts.map +1 -1
  155. package/dist/terminal/east-asian-width.js +404 -351
  156. package/dist/terminal/keys.d.ts +17 -0
  157. package/dist/terminal/keys.d.ts.map +1 -1
  158. package/dist/terminal/keys.js +37 -0
  159. package/dist/terminal/select-prompt.d.ts.map +1 -1
  160. package/dist/terminal/select-prompt.js +24 -12
  161. package/dist/terminal/string-width.d.ts.map +1 -1
  162. package/dist/terminal/string-width.js +25 -27
  163. package/dist/terminal/style.d.ts.map +1 -1
  164. package/dist/terminal/style.js +4 -7
  165. package/dist/terminal/supports-color.d.ts.map +1 -1
  166. package/dist/terminal/supports-color.js +41 -27
  167. package/dist/terminal/table/cell.d.ts +12 -0
  168. package/dist/terminal/table/cell.d.ts.map +1 -1
  169. package/dist/terminal/table/cell.js +40 -25
  170. package/dist/terminal/table/layout-manager.d.ts.map +1 -1
  171. package/dist/terminal/table/layout-manager.js +100 -68
  172. package/dist/terminal/table/utils.d.ts +1 -1
  173. package/dist/terminal/table/utils.d.ts.map +1 -1
  174. package/dist/terminal/table/utils.js +17 -10
  175. package/dist/terminal/wrap-ansi.d.ts.map +1 -1
  176. package/dist/terminal/wrap-ansi.js +174 -105
  177. package/dist/tokens/tracker.d.ts +1 -0
  178. package/dist/tokens/tracker.d.ts.map +1 -1
  179. package/dist/tokens/tracker.js +3 -0
  180. package/dist/tools/agent.d.ts +27 -0
  181. package/dist/tools/agent.d.ts.map +1 -0
  182. package/dist/tools/agent.js +81 -0
  183. package/dist/tools/apply-patch.d.ts +62 -0
  184. package/dist/tools/apply-patch.d.ts.map +1 -0
  185. package/dist/tools/apply-patch.js +377 -0
  186. package/dist/tools/bash.d.ts +4 -3
  187. package/dist/tools/bash.d.ts.map +1 -1
  188. package/dist/tools/bash.js +349 -141
  189. package/dist/tools/directory-tree.d.ts +3 -3
  190. package/dist/tools/directory-tree.d.ts.map +1 -1
  191. package/dist/tools/directory-tree.js +8 -5
  192. package/dist/tools/dynamic-tool-loader.d.ts +3 -6
  193. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  194. package/dist/tools/dynamic-tool-loader.js +20 -4
  195. package/dist/tools/edit-file.d.ts +7 -7
  196. package/dist/tools/edit-file.d.ts.map +1 -1
  197. package/dist/tools/edit-file.js +292 -85
  198. package/dist/tools/glob.d.ts +6 -6
  199. package/dist/tools/glob.d.ts.map +1 -1
  200. package/dist/tools/glob.js +110 -63
  201. package/dist/tools/grep.d.ts +15 -12
  202. package/dist/tools/grep.d.ts.map +1 -1
  203. package/dist/tools/grep.js +315 -193
  204. package/dist/tools/index.d.ts +114 -9
  205. package/dist/tools/index.d.ts.map +1 -1
  206. package/dist/tools/index.js +39 -24
  207. package/dist/tools/ls.d.ts +2 -2
  208. package/dist/tools/ls.d.ts.map +1 -1
  209. package/dist/tools/ls.js +7 -5
  210. package/dist/tools/read-file.d.ts +4 -6
  211. package/dist/tools/read-file.d.ts.map +1 -1
  212. package/dist/tools/read-file.js +84 -39
  213. package/dist/tools/save-file.d.ts +3 -3
  214. package/dist/tools/save-file.d.ts.map +1 -1
  215. package/dist/tools/save-file.js +36 -31
  216. package/dist/tools/skill.d.ts +23 -0
  217. package/dist/tools/skill.d.ts.map +1 -0
  218. package/dist/tools/skill.js +65 -0
  219. package/dist/tools/think.d.ts.map +1 -1
  220. package/dist/tools/think.js +2 -9
  221. package/dist/tools/utils.d.ts +2 -0
  222. package/dist/tools/utils.d.ts.map +1 -1
  223. package/dist/tools/utils.js +12 -0
  224. package/dist/tools/web-fetch.d.ts +50 -0
  225. package/dist/tools/web-fetch.d.ts.map +1 -0
  226. package/dist/tools/web-fetch.js +446 -0
  227. package/dist/tools/web-search.d.ts +44 -0
  228. package/dist/tools/web-search.d.ts.map +1 -0
  229. package/dist/tools/web-search.js +226 -0
  230. package/dist/tui/autocomplete/attachment-provider.d.ts +3 -6
  231. package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -1
  232. package/dist/tui/autocomplete/attachment-provider.js +25 -78
  233. package/dist/tui/autocomplete/base-provider.d.ts +1 -0
  234. package/dist/tui/autocomplete/base-provider.d.ts.map +1 -1
  235. package/dist/tui/autocomplete/combined-provider.d.ts +1 -4
  236. package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -1
  237. package/dist/tui/autocomplete/combined-provider.js +3 -17
  238. package/dist/tui/autocomplete/command-provider.d.ts +1 -0
  239. package/dist/tui/autocomplete/command-provider.d.ts.map +1 -1
  240. package/dist/tui/autocomplete/command-provider.js +3 -0
  241. package/dist/tui/autocomplete/file-search-provider.d.ts +2 -1
  242. package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -1
  243. package/dist/tui/autocomplete/file-search-provider.js +37 -17
  244. package/dist/tui/autocomplete/skill-provider.d.ts +17 -0
  245. package/dist/tui/autocomplete/skill-provider.d.ts.map +1 -0
  246. package/dist/tui/autocomplete/skill-provider.js +49 -0
  247. package/dist/tui/autocomplete/utils.d.ts +2 -1
  248. package/dist/tui/autocomplete/utils.d.ts.map +1 -1
  249. package/dist/tui/autocomplete/utils.js +25 -23
  250. package/dist/tui/autocomplete.d.ts +2 -2
  251. package/dist/tui/autocomplete.d.ts.map +1 -1
  252. package/dist/tui/autocomplete.js +3 -5
  253. package/dist/tui/components/assistant-message.d.ts.map +1 -1
  254. package/dist/tui/components/assistant-message.js +0 -4
  255. package/dist/tui/components/editor.d.ts +18 -3
  256. package/dist/tui/components/editor.d.ts.map +1 -1
  257. package/dist/tui/components/editor.js +211 -237
  258. package/dist/tui/components/footer.d.ts +6 -4
  259. package/dist/tui/components/footer.d.ts.map +1 -1
  260. package/dist/tui/components/footer.js +49 -25
  261. package/dist/tui/components/markdown.d.ts +10 -7
  262. package/dist/tui/components/markdown.d.ts.map +1 -1
  263. package/dist/tui/components/markdown.js +57 -39
  264. package/dist/tui/components/modal.d.ts.map +1 -1
  265. package/dist/tui/components/modal.js +35 -33
  266. package/dist/tui/components/notification.d.ts +13 -2
  267. package/dist/tui/components/notification.d.ts.map +1 -1
  268. package/dist/tui/components/notification.js +36 -2
  269. package/dist/tui/components/progress-bar.js +1 -1
  270. package/dist/tui/components/select-list.d.ts +1 -0
  271. package/dist/tui/components/select-list.d.ts.map +1 -1
  272. package/dist/tui/components/select-list.js +14 -11
  273. package/dist/tui/components/text.d.ts +16 -0
  274. package/dist/tui/components/text.d.ts.map +1 -1
  275. package/dist/tui/components/text.js +72 -57
  276. package/dist/tui/components/thinking-block.d.ts +9 -0
  277. package/dist/tui/components/thinking-block.d.ts.map +1 -1
  278. package/dist/tui/components/thinking-block.js +43 -11
  279. package/dist/tui/components/tool-execution.d.ts +5 -1
  280. package/dist/tui/components/tool-execution.d.ts.map +1 -1
  281. package/dist/tui/components/tool-execution.js +19 -10
  282. package/dist/tui/components/user-message.d.ts.map +1 -1
  283. package/dist/tui/components/user-message.js +0 -3
  284. package/dist/tui/components/welcome.d.ts +2 -1
  285. package/dist/tui/components/welcome.d.ts.map +1 -1
  286. package/dist/tui/components/welcome.js +2 -2
  287. package/dist/tui/editor-launcher.d.ts +3 -2
  288. package/dist/tui/editor-launcher.d.ts.map +1 -1
  289. package/dist/tui/index.d.ts +0 -1
  290. package/dist/tui/index.d.ts.map +1 -1
  291. package/dist/tui/terminal.d.ts.map +1 -1
  292. package/dist/tui/terminal.js +10 -2
  293. package/dist/tui/tui.d.ts +43 -0
  294. package/dist/tui/tui.d.ts.map +1 -1
  295. package/dist/tui/tui.js +166 -41
  296. package/dist/tui/utils.d.ts +1 -5
  297. package/dist/tui/utils.d.ts.map +1 -1
  298. package/dist/tui/utils.js +271 -44
  299. package/dist/utils/bash/parse.d.ts +19 -0
  300. package/dist/utils/bash/parse.d.ts.map +1 -0
  301. package/dist/utils/bash/parse.js +223 -0
  302. package/dist/utils/bash/quote.d.ts +6 -0
  303. package/dist/utils/bash/quote.d.ts.map +1 -0
  304. package/dist/utils/bash/quote.js +23 -0
  305. package/dist/utils/bash.d.ts.map +1 -1
  306. package/dist/utils/bash.js +211 -126
  307. package/dist/utils/command-protection.d.ts +28 -0
  308. package/dist/utils/command-protection.d.ts.map +1 -0
  309. package/dist/utils/command-protection.js +324 -0
  310. package/dist/utils/dedent.d.ts.map +1 -0
  311. package/dist/utils/env-expand.d.ts +2 -0
  312. package/dist/utils/env-expand.d.ts.map +1 -0
  313. package/dist/utils/env-expand.js +8 -0
  314. package/dist/utils/filesystem/path-display.d.ts +11 -0
  315. package/dist/utils/filesystem/path-display.d.ts.map +1 -0
  316. package/dist/utils/filesystem/path-display.js +32 -0
  317. package/dist/utils/filesystem/security.d.ts +2 -2
  318. package/dist/utils/filesystem/security.d.ts.map +1 -1
  319. package/dist/utils/filesystem/security.js +28 -30
  320. package/dist/utils/formatting.d.ts.map +1 -0
  321. package/dist/{formatting.js → utils/formatting.js} +1 -1
  322. package/dist/utils/git.d.ts +4 -0
  323. package/dist/utils/git.d.ts.map +1 -1
  324. package/dist/utils/git.js +30 -0
  325. package/dist/utils/glob.d.ts +1 -1
  326. package/dist/utils/glob.d.ts.map +1 -1
  327. package/dist/utils/logger.d.ts.map +1 -0
  328. package/dist/{logger.js → utils/logger.js} +1 -1
  329. package/dist/utils/parsing.d.ts.map +1 -0
  330. package/dist/utils/process.d.ts.map +1 -1
  331. package/dist/utils/process.js +90 -37
  332. package/dist/utils/templates.d.ts +2 -0
  333. package/dist/utils/templates.d.ts.map +1 -0
  334. package/dist/utils/templates.js +24 -0
  335. package/dist/utils/version.d.ts.map +1 -0
  336. package/dist/{version.js → utils/version.js} +1 -1
  337. package/package.json +35 -26
  338. package/dist/cli.d.ts +0 -23
  339. package/dist/cli.d.ts.map +0 -1
  340. package/dist/commands/add-directory/types.d.ts +0 -6
  341. package/dist/commands/add-directory/types.d.ts.map +0 -1
  342. package/dist/commands/add-directory/types.js +0 -1
  343. package/dist/commands/copy/types.d.ts +0 -3
  344. package/dist/commands/copy/types.d.ts.map +0 -1
  345. package/dist/commands/copy/types.js +0 -1
  346. package/dist/commands/exit/index.d.ts +0 -10
  347. package/dist/commands/exit/index.d.ts.map +0 -1
  348. package/dist/commands/exit/index.js +0 -21
  349. package/dist/commands/exit/types.d.ts +0 -8
  350. package/dist/commands/exit/types.d.ts.map +0 -1
  351. package/dist/commands/exit/types.js +0 -1
  352. package/dist/commands/exit/utils.d.ts +0 -2
  353. package/dist/commands/exit/utils.d.ts.map +0 -1
  354. package/dist/commands/exit/utils.js +0 -13
  355. package/dist/commands/prompt/index.d.ts +0 -5
  356. package/dist/commands/prompt/index.d.ts.map +0 -1
  357. package/dist/commands/prompt/index.js +0 -122
  358. package/dist/commands/prompt/types.d.ts +0 -15
  359. package/dist/commands/prompt/types.d.ts.map +0 -1
  360. package/dist/commands/prompt/types.js +0 -1
  361. package/dist/commands/prompt/utils.d.ts +0 -12
  362. package/dist/commands/prompt/utils.d.ts.map +0 -1
  363. package/dist/commands/prompt/utils.js +0 -107
  364. package/dist/commands/reset/index.d.ts +0 -3
  365. package/dist/commands/reset/index.d.ts.map +0 -1
  366. package/dist/commands/reset/index.js +0 -25
  367. package/dist/commands/reset/types.d.ts +0 -1
  368. package/dist/commands/reset/types.d.ts.map +0 -1
  369. package/dist/commands/reset/types.js +0 -3
  370. package/dist/commands/review/types.d.ts +0 -12
  371. package/dist/commands/review/types.d.ts.map +0 -1
  372. package/dist/commands/review/types.js +0 -1
  373. package/dist/commands/save/index.d.ts +0 -3
  374. package/dist/commands/save/index.d.ts.map +0 -1
  375. package/dist/commands/save/index.js +0 -19
  376. package/dist/config.d.ts.map +0 -1
  377. package/dist/dedent.d.ts.map +0 -1
  378. package/dist/formatting.d.ts.map +0 -1
  379. package/dist/logger.d.ts.map +0 -1
  380. package/dist/mentions.d.ts +0 -14
  381. package/dist/mentions.d.ts.map +0 -1
  382. package/dist/parsing.d.ts.map +0 -1
  383. package/dist/prompts.d.ts.map +0 -1
  384. package/dist/repl-new.d.ts +0 -65
  385. package/dist/repl-new.d.ts.map +0 -1
  386. package/dist/skills.d.ts +0 -16
  387. package/dist/skills.d.ts.map +0 -1
  388. package/dist/skills.js +0 -233
  389. package/dist/stdin.d.ts.map +0 -1
  390. package/dist/tui/autocomplete/path-provider.d.ts +0 -21
  391. package/dist/tui/autocomplete/path-provider.d.ts.map +0 -1
  392. package/dist/tui/autocomplete/path-provider.js +0 -164
  393. package/dist/utils/iterables.d.ts +0 -2
  394. package/dist/utils/iterables.d.ts.map +0 -1
  395. package/dist/utils/iterables.js +0 -6
  396. package/dist/version.d.ts.map +0 -1
  397. /package/dist/{dedent.d.ts → utils/dedent.d.ts} +0 -0
  398. /package/dist/{dedent.js → utils/dedent.js} +0 -0
  399. /package/dist/{formatting.d.ts → utils/formatting.d.ts} +0 -0
  400. /package/dist/{logger.d.ts → utils/logger.d.ts} +0 -0
  401. /package/dist/{parsing.d.ts → utils/parsing.d.ts} +0 -0
  402. /package/dist/{parsing.js → utils/parsing.js} +0 -0
  403. /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
@@ -129,6 +129,33 @@ export function insertCell(cell, row) {
129
129
  }
130
130
  row.splice(x, 0, cell);
131
131
  }
132
+ function findColSpan(table, startX, y, wMax) {
133
+ let colSpan = 1;
134
+ let x = startX;
135
+ // Increment x first, then check while loop (matches original logic)
136
+ x++;
137
+ while (x < wMax && !conflictExists(table, x, y)) {
138
+ colSpan++;
139
+ x++;
140
+ }
141
+ return colSpan;
142
+ }
143
+ function findRowSpan(table, x, y, colSpan, hMax) {
144
+ let rowSpan = 1;
145
+ let y2 = y + 1;
146
+ while (y2 < hMax && allBlank(table, y2, x, x + colSpan)) {
147
+ rowSpan++;
148
+ y2++;
149
+ }
150
+ return rowSpan;
151
+ }
152
+ function createAndInsertMissingCell(table, x, y, colSpan, rowSpan) {
153
+ const cell = new Cell({ content: "", colSpan, rowSpan });
154
+ cell.x = x;
155
+ cell.y = y;
156
+ debug.warn(`Missing cell at ${y}-${x}.`);
157
+ insertCell(cell, table[y]);
158
+ }
132
159
  export function fillInTable(table) {
133
160
  const hMax = maxHeight(table);
134
161
  const wMax = maxWidth(table);
@@ -136,23 +163,10 @@ export function fillInTable(table) {
136
163
  for (let y = 0; y < hMax; y++) {
137
164
  for (let x = 0; x < wMax; x++) {
138
165
  if (!conflictExists(table, x, y)) {
139
- const opts = { x: x, y: y, colSpan: 1, rowSpan: 1 };
140
- x++;
141
- while (x < wMax && !conflictExists(table, x, y)) {
142
- opts.colSpan++;
143
- x++;
144
- }
145
- let y2 = y + 1;
146
- while (y2 < hMax &&
147
- allBlank(table, y2, opts.x, opts.x + opts.colSpan)) {
148
- opts.rowSpan++;
149
- y2++;
150
- }
151
- const cell = new Cell({ ...opts, content: "" });
152
- cell.x = opts.x;
153
- cell.y = opts.y;
154
- debug.warn(`Missing cell at ${cell.y}-${cell.x}.`);
155
- insertCell(cell, table[y]);
166
+ const colSpan = findColSpan(table, x, y, wMax);
167
+ const rowSpan = findRowSpan(table, x, y, colSpan, hMax);
168
+ createAndInsertMissingCell(table, x, y, colSpan, rowSpan);
169
+ x += colSpan - 1;
156
170
  }
157
171
  }
158
172
  }
@@ -187,66 +201,84 @@ export function makeTableLayout(rows) {
187
201
  addColSpanCells(cellRows);
188
202
  return cellRows;
189
203
  }
190
- export function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
191
- return (vals, table) => {
192
- const result = [];
193
- const spanners = [];
194
- const auto = {};
195
- table.forEach((row) => {
196
- row.forEach((cell) => {
197
- if ((cell[colSpan] || 1) > 1) {
198
- spanners.push(cell);
199
- }
200
- else {
201
- const key = cell[x];
202
- if (key !== null) {
203
- result[key] = Math.max(result[key] || 0, cell[desiredWidth] || 0, forcedMin);
204
- }
204
+ /**
205
+ * Scans table rows and populates result array with cell widths and collects spanning cells.
206
+ */
207
+ function scanTableForWidths(colSpan, desiredWidth, x, forcedMin, table) {
208
+ const result = [];
209
+ const spanners = [];
210
+ const auto = {};
211
+ table.forEach((row) => {
212
+ row.forEach((cell) => {
213
+ if ((cell[colSpan] || 1) > 1) {
214
+ spanners.push(cell);
215
+ }
216
+ else {
217
+ const key = cell[x];
218
+ if (key !== null) {
219
+ result[key] = Math.max(result[key] || 0, cell[desiredWidth] || 0, forcedMin);
205
220
  }
206
- });
207
- });
208
- vals.forEach((val, index) => {
209
- if (typeof val === "number") {
210
- result[index] = val;
211
221
  }
212
222
  });
213
- // spanners.forEach(function(cell){
214
- for (let k = spanners.length - 1; k >= 0; k--) {
215
- const cell = spanners[k];
216
- const span = cell[colSpan];
217
- const col = cell[x];
218
- if (col === null)
219
- continue;
220
- let existingWidth = result[col];
221
- let editableCols = typeof vals[col] === "number" ? 0 : 1;
222
- if (typeof existingWidth === "number") {
223
- for (let i = 1; i < span; i++) {
224
- existingWidth += 1 + result[col + i];
225
- if (typeof vals[col + i] !== "number") {
226
- editableCols++;
227
- }
223
+ });
224
+ return { result, spanners, auto };
225
+ }
226
+ /**
227
+ * Applies forced values from vals array to result.
228
+ */
229
+ function applyForcedValues(vals, result) {
230
+ vals.forEach((val, index) => {
231
+ if (typeof val === "number") {
232
+ result[index] = val;
233
+ }
234
+ });
235
+ }
236
+ /**
237
+ * Processes spanning cells and distributes their widths across columns.
238
+ */
239
+ function processSpanners(colSpan, desiredWidth, x, spanners, result, auto, vals) {
240
+ for (let k = spanners.length - 1; k >= 0; k--) {
241
+ const cell = spanners[k];
242
+ const span = cell[colSpan];
243
+ const col = cell[x];
244
+ if (col === null)
245
+ continue;
246
+ let existingWidth = result[col];
247
+ let editableCols = typeof vals[col] === "number" ? 0 : 1;
248
+ if (typeof existingWidth === "number") {
249
+ for (let i = 1; i < span; i++) {
250
+ existingWidth += 1 + result[col + i];
251
+ if (typeof vals[col + i] !== "number") {
252
+ editableCols++;
228
253
  }
229
254
  }
230
- else {
231
- existingWidth =
232
- desiredWidth === "desiredWidth" ? cell.desiredWidth - 1 : 1;
233
- if (!auto[col] || auto[col] < existingWidth) {
234
- auto[col] = existingWidth;
235
- }
255
+ }
256
+ else {
257
+ existingWidth =
258
+ desiredWidth === "desiredWidth" ? cell.desiredWidth - 1 : 1;
259
+ if (!auto[col] || auto[col] < existingWidth) {
260
+ auto[col] = existingWidth;
236
261
  }
237
- if (cell[desiredWidth] > existingWidth) {
238
- let i = 0;
239
- while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
240
- if (typeof vals[col + i] !== "number") {
241
- const dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
242
- existingWidth += dif;
243
- result[col + i] += dif;
244
- editableCols--;
245
- }
246
- i++;
262
+ }
263
+ if (cell[desiredWidth] > existingWidth) {
264
+ let i = 0;
265
+ while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
266
+ if (typeof vals[col + i] !== "number") {
267
+ const dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
268
+ existingWidth += dif;
269
+ result[col + i] += dif;
270
+ editableCols--;
247
271
  }
272
+ i++;
248
273
  }
249
274
  }
275
+ }
276
+ }
277
+ export function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
278
+ return (vals, table) => {
279
+ const { result, spanners, auto } = scanTableForWidths(colSpan, desiredWidth, x, forcedMin, table);
280
+ applyForcedValues(vals, result);
281
+ processSpanners(colSpan, desiredWidth, x, spanners, result, auto, vals);
250
282
  Object.assign(vals, result, auto);
251
283
  for (let j = 0; j < vals.length; j++) {
252
284
  vals[j] = Math.max(forcedMin, vals[j] || 0);
@@ -59,5 +59,5 @@ export declare function colorizeLines(input: string[]): string[];
59
59
  * Credit: Matheus Sampaio https://github.com/matheussampaio
60
60
  */
61
61
  export declare function hyperlink(url: string, text: string): string;
62
- export type { CharName, HorizontalAlignment, VerticalAlignment, TableInstanceOptions, TableConstructorOptions, CellOptions, Cell, };
62
+ export type { Cell, CellOptions, CharName, HorizontalAlignment, TableConstructorOptions, TableInstanceOptions, VerticalAlignment, };
63
63
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/terminal/table/utils.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,GACT,KAAK,GACL,QAAQ,GACR,SAAS,GACT,UAAU,GACV,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,MAAM,GACN,SAAS,GACT,KAAK,GACL,QAAQ,GACR,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AE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,KAAK,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AAmBpC,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO1C;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,GAAG,CACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,mBAAmB,GACvB,MAAM,CAuBR;AA6KD,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAmBR;AAED,wBAAgB,cAAc,IAAI,oBAAoB,CAmCrD;AAED,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,EAC1C,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,CAOtB;AAsDD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,kBAAkB,UAAO,GACxB,MAAM,EAAE,CAQV;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAUvD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB3D;AAED,YAAY,EACV,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,GAClB,CAAC"}
@@ -55,27 +55,34 @@ addToCodeCache("italics", "3", "23");
55
55
  addToCodeCache("underline", "4", "24");
56
56
  addToCodeCache("inverse", "7", "27");
57
57
  addToCodeCache("strikethrough", "9", "29");
58
+ function isForegroundColor(code) {
59
+ return (code >= 30 && code <= 39) || (code >= 90 && code <= 97);
60
+ }
61
+ function isBackgroundColor(code) {
62
+ return (code >= 40 && code <= 49) || (code >= 100 && code <= 107);
63
+ }
64
+ function clearState(state) {
65
+ for (const i in state) {
66
+ /* istanbul ignore else */
67
+ if (Object.hasOwn(state, i)) {
68
+ delete state[i];
69
+ }
70
+ }
71
+ }
58
72
  function updateState(state, controlChars) {
59
73
  const controlCode = controlChars[1]
60
74
  ? Number.parseInt(controlChars[1].split(";")[0], 10)
61
75
  : 0;
62
- if ((controlCode >= 30 && controlCode <= 39) ||
63
- (controlCode >= 90 && controlCode <= 97)) {
76
+ if (isForegroundColor(controlCode)) {
64
77
  state.lastForegroundAdded = controlChars[0];
65
78
  return;
66
79
  }
67
- if ((controlCode >= 40 && controlCode <= 49) ||
68
- (controlCode >= 100 && controlCode <= 107)) {
80
+ if (isBackgroundColor(controlCode)) {
69
81
  state.lastBackgroundAdded = controlChars[0];
70
82
  return;
71
83
  }
72
84
  if (controlCode === 0) {
73
- for (const i in state) {
74
- /* istanbul ignore else */
75
- if (Object.hasOwn(state, i)) {
76
- delete state[i];
77
- }
78
- }
85
+ clearState(state);
79
86
  return;
80
87
  }
81
88
  const info = codeCache[controlChars[0]];
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/wrap-ansi.ts"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA6OD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAOR"}
1
+ {"version":3,"file":"wrap-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/wrap-ansi.ts"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA0XD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAOR"}
@@ -1,9 +1,9 @@
1
1
  import { ansiStyles } from "./ansi-styles.js";
2
2
  import stringWidth from "./string-width.js";
3
3
  import stripAnsi from "./strip-ansi.js";
4
- const ESCAPES = new Set(["\\u001B", "\\u009B"]);
4
+ const ESCAPES = new Set(["\u001B", "\u009B"]);
5
5
  const END_CODE = 39;
6
- const ANSI_ESCAPE_BELL = "\\u0007";
6
+ const ANSI_ESCAPE_BELL = "\u0007";
7
7
  const ANSI_CSI = "[";
8
8
  const ANSI_OSC = "]";
9
9
  const ANSI_SGR_TERMINATOR = "m";
@@ -13,6 +13,32 @@ const wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAP
13
13
  // Calculate the length of words split on ' ', ignoring
14
14
  // the extra characters added by ansi escape codes
15
15
  const wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
16
+ // Check if character starts an ANSI escape sequence
17
+ const isEscapeStart = (character) => ESCAPES.has(character);
18
+ // Check if this is the start of a hyperlink escape sequence
19
+ const isLinkEscapeStart = (characters, index) => {
20
+ const candidate = characters
21
+ .slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length)
22
+ .join("");
23
+ return candidate === ANSI_ESCAPE_LINK;
24
+ };
25
+ // Check if character ends an escape sequence
26
+ const isEscapeEnd = (character, isInsideLinkEscape) => {
27
+ if (isInsideLinkEscape) {
28
+ return character === ANSI_ESCAPE_BELL;
29
+ }
30
+ return character === ANSI_SGR_TERMINATOR;
31
+ };
32
+ // Handle final row edge case (ANSI-only rows)
33
+ const handleFinalRowEdgeCase = (rows, visible) => {
34
+ const lastRow = rows.at(-1);
35
+ if (!visible && lastRow && lastRow.length > 0 && rows.length > 1) {
36
+ const poppedRow = rows.pop();
37
+ if (poppedRow) {
38
+ rows[rows.length - 1] += poppedRow;
39
+ }
40
+ }
41
+ };
16
42
  // Wrap a long word across multiple rows
17
43
  // Ansi escape codes do not count towards length
18
44
  const wrapWord = (rows, word, columns) => {
@@ -29,22 +55,16 @@ const wrapWord = (rows, word, columns) => {
29
55
  rows.push(character);
30
56
  visible = 0;
31
57
  }
32
- if (ESCAPES.has(character)) {
58
+ // Handle escape sequence detection
59
+ if (isEscapeStart(character)) {
33
60
  isInsideEscape = true;
34
- const ansiEscapeLinkCandidate = characters
35
- .slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length)
36
- .join("");
37
- isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
61
+ isInsideLinkEscape = isLinkEscapeStart(characters, index);
38
62
  }
63
+ // Process escape sequence
39
64
  if (isInsideEscape) {
40
- if (isInsideLinkEscape) {
41
- if (character === ANSI_ESCAPE_BELL) {
42
- isInsideEscape = false;
43
- isInsideLinkEscape = false;
44
- }
45
- }
46
- else if (character === ANSI_SGR_TERMINATOR) {
65
+ if (isEscapeEnd(character, isInsideLinkEscape)) {
47
66
  isInsideEscape = false;
67
+ isInsideLinkEscape = false;
48
68
  }
49
69
  continue;
50
70
  }
@@ -54,15 +74,7 @@ const wrapWord = (rows, word, columns) => {
54
74
  visible = 0;
55
75
  }
56
76
  }
57
- // It's possible that the last row we copy over is only
58
- // ansi escape characters, handle this edge-case
59
- const lastRow = rows.at(-1);
60
- if (!visible && lastRow && lastRow.length > 0 && rows.length > 1) {
61
- const poppedRow = rows.pop();
62
- if (poppedRow) {
63
- rows[rows.length - 1] += poppedRow;
64
- }
65
- }
77
+ handleFinalRowEdgeCase(rows, visible);
66
78
  };
67
79
  // Trims spaces from a string ignoring invisible sequences
68
80
  const stringVisibleTrimSpacesRight = (string) => {
@@ -79,105 +91,162 @@ const stringVisibleTrimSpacesRight = (string) => {
79
91
  }
80
92
  return words.slice(0, last).join(" ") + words.slice(last).join("");
81
93
  };
82
- // The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode.
83
- //
84
- // 'hard' will never allow a string to take up more than columns characters.
85
- //
86
- // 'soft' allows long words to expand past the column length.
87
- const exec = (string, columns, options = {}) => {
88
- if (options.trim !== false && string.trim() === "") {
89
- return "";
94
+ /**
95
+ * Parses an ANSI escape sequence from preString starting at the given index.
96
+ * Returns the updated escapeCode and escapeUrl.
97
+ */
98
+ function parseEscapeSequence(preString, preStringIndex, currentEscapeCode, currentEscapeUrl) {
99
+ const match = new RegExp(`(?:\\\\${ANSI_CSI}(?<code>\\d+)m|\\\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex));
100
+ let newEscapeCode = currentEscapeCode;
101
+ let newEscapeUrl = currentEscapeUrl;
102
+ if (match?.groups) {
103
+ const { groups } = match;
104
+ if (groups["code"] !== undefined) {
105
+ const code = Number.parseFloat(groups["code"]);
106
+ newEscapeCode = code === END_CODE ? undefined : code;
107
+ }
108
+ else if (groups["uri"] !== undefined) {
109
+ newEscapeUrl = groups["uri"].length === 0 ? undefined : groups["uri"];
110
+ }
111
+ }
112
+ return { escapeCode: newEscapeCode, escapeUrl: newEscapeUrl };
113
+ }
114
+ /**
115
+ * Handles escape output when the next character is a newline.
116
+ */
117
+ function handleEscapeOnNextNewline(currentReturnValue, escapeCode, escapeUrl) {
118
+ const code = ansiStyles["codes"].get(Number(escapeCode));
119
+ let newReturnValue = currentReturnValue;
120
+ if (escapeUrl) {
121
+ newReturnValue += wrapAnsiHyperlink("");
90
122
  }
123
+ if (escapeCode && code) {
124
+ newReturnValue += wrapAnsiCode(code);
125
+ }
126
+ return newReturnValue;
127
+ }
128
+ /**
129
+ * Handles escape output when the current character is a newline.
130
+ */
131
+ function handleEscapeOnCurrentNewline(currentReturnValue, escapeCode, escapeUrl) {
132
+ const code = ansiStyles["codes"].get(Number(escapeCode));
133
+ let newReturnValue = currentReturnValue;
134
+ if (escapeCode && code) {
135
+ newReturnValue += wrapAnsiCode(escapeCode);
136
+ }
137
+ if (escapeUrl) {
138
+ newReturnValue += wrapAnsiHyperlink(escapeUrl);
139
+ }
140
+ return newReturnValue;
141
+ }
142
+ const processAnsiEscapes = (pre, preString) => {
91
143
  let returnValue = "";
92
144
  let escapeCode;
93
145
  let escapeUrl;
94
- const lengths = wordLengths(string);
95
- let rows = [""];
96
- for (const [index, word] of string.split(" ").entries()) {
97
- if (options.trim !== false) {
98
- rows[rows.length - 1] = rows.at(-1)?.trimStart() ?? "";
146
+ let preStringIndex = 0;
147
+ for (const [index, character] of pre.entries()) {
148
+ returnValue += character;
149
+ if (ESCAPES.has(character)) {
150
+ const parsed = parseEscapeSequence(preString, preStringIndex, escapeCode, escapeUrl);
151
+ escapeCode = parsed.escapeCode;
152
+ escapeUrl = parsed.escapeUrl;
99
153
  }
100
- let rowLength = stringWidth(rows.at(-1) ?? "");
101
- if (index !== 0) {
102
- if (rowLength >= columns &&
103
- (options.wordWrap === false || options.trim === false)) {
104
- // If we start with a new word but the current row length equals the length of the columns, add a new row
105
- rows.push("");
106
- rowLength = 0;
107
- }
108
- if (rowLength > 0 || options.trim === false) {
109
- rows[rows.length - 1] += " ";
110
- rowLength++;
111
- }
154
+ if (pre[index + 1] === "\n") {
155
+ returnValue = handleEscapeOnNextNewline(returnValue, escapeCode, escapeUrl);
112
156
  }
113
- // In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
114
- if (options.hard && lengths[index] > columns) {
115
- const remainingColumns = columns - rowLength;
116
- const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
117
- const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
118
- if (breaksStartingNextLine < breaksStartingThisLine) {
119
- rows.push("");
120
- }
157
+ else if (character === "\n") {
158
+ returnValue = handleEscapeOnCurrentNewline(returnValue, escapeCode, escapeUrl);
159
+ }
160
+ preStringIndex += character.length;
161
+ }
162
+ return returnValue;
163
+ };
164
+ // Determines if a new row should be started based on current row state
165
+ const shouldStartNewRow = (rowLength, columns, options) => rowLength >= columns &&
166
+ (options.wordWrap === false || options.trim === false);
167
+ // Adds a space between words if needed
168
+ const addWordSpacing = (rows, rowLength, options) => {
169
+ if (rowLength > 0 || options.trim === false) {
170
+ rows[rows.length - 1] += " ";
171
+ return rowLength + 1;
172
+ }
173
+ return rowLength;
174
+ };
175
+ // Handles hard wrap mode where words cannot exceed column width
176
+ const handleHardWrap = (rows, word, wordLength, rowLength, columns) => {
177
+ if (wordLength <= columns) {
178
+ return false;
179
+ }
180
+ const remainingColumns = columns - rowLength;
181
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
182
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
183
+ if (breaksStartingNextLine < breaksStartingThisLine) {
184
+ rows.push("");
185
+ }
186
+ wrapWord(rows, word, columns);
187
+ return true;
188
+ };
189
+ // Handles soft wrap mode for normal word wrapping
190
+ const handleSoftWrap = (rows, word, wordLength, rowLength, columns, options) => {
191
+ const totalLength = rowLength + wordLength;
192
+ if (totalLength > columns && rowLength > 0 && wordLength > 0) {
193
+ if (options.wordWrap === false && rowLength < columns) {
121
194
  wrapWord(rows, word, columns);
122
- continue;
195
+ return true;
123
196
  }
124
- if (rowLength + lengths[index] > columns &&
125
- rowLength > 0 &&
126
- lengths[index] > 0) {
127
- if (options.wordWrap === false && rowLength < columns) {
128
- wrapWord(rows, word, columns);
129
- continue;
130
- }
197
+ rows.push("");
198
+ }
199
+ if (totalLength > columns && options.wordWrap === false) {
200
+ wrapWord(rows, word, columns);
201
+ return true;
202
+ }
203
+ return false;
204
+ };
205
+ // Process a single word and update rows accordingly
206
+ const processWord = (rows, word, wordLength, index, columns, options) => {
207
+ if (options.trim !== false) {
208
+ rows[rows.length - 1] = rows.at(-1)?.trimStart() ?? "";
209
+ }
210
+ let rowLength = stringWidth(rows.at(-1) ?? "");
211
+ if (index !== 0) {
212
+ if (shouldStartNewRow(rowLength, columns, options)) {
131
213
  rows.push("");
214
+ rowLength = 0;
132
215
  }
133
- if (rowLength + lengths[index] > columns && options.wordWrap === false) {
134
- wrapWord(rows, word, columns);
135
- continue;
216
+ rowLength = addWordSpacing(rows, rowLength, options);
217
+ }
218
+ if (options.hard) {
219
+ if (handleHardWrap(rows, word, wordLength, rowLength, columns)) {
220
+ return -1;
136
221
  }
137
- rows[rows.length - 1] += word;
222
+ }
223
+ if (handleSoftWrap(rows, word, wordLength, rowLength, columns, options)) {
224
+ return -1;
225
+ }
226
+ rows[rows.length - 1] += word;
227
+ return stringWidth(rows.at(-1) ?? "");
228
+ };
229
+ // The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode.
230
+ //
231
+ // 'hard' will never allow a string to take up more than columns characters.
232
+ //
233
+ // 'soft' allows long words to expand past the column length.
234
+ const exec = (string, columns, options = {}) => {
235
+ if (options.trim !== false && string.trim() === "") {
236
+ return "";
237
+ }
238
+ const lengths = wordLengths(string);
239
+ const words = string.split(" ");
240
+ let rows = [""];
241
+ for (const [index, word] of words.entries()) {
242
+ processWord(rows, word, lengths[index], index, columns, options);
138
243
  }
139
244
  if (options.trim !== false) {
140
245
  rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
141
246
  }
142
247
  const preString = rows.join("\n");
143
248
  const pre = [...preString];
144
- // We need to keep a separate index as `String#slice()` works on Unicode code units, while `pre` is an array of codepoints.
145
- let preStringIndex = 0;
146
- for (const [index, character] of pre.entries()) {
147
- returnValue += character;
148
- if (ESCAPES.has(character)) {
149
- const match = new RegExp(`(?:\\\\${ANSI_CSI}(?<code>\\d+)m|\\\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex));
150
- if (match?.groups) {
151
- const { groups } = match;
152
- if (groups["code"] !== undefined) {
153
- const code = Number.parseFloat(groups["code"]);
154
- escapeCode = code === END_CODE ? undefined : code;
155
- }
156
- else if (groups["uri"] !== undefined) {
157
- escapeUrl = groups["uri"].length === 0 ? undefined : groups["uri"];
158
- }
159
- }
160
- }
161
- const code = ansiStyles["codes"].get(Number(escapeCode));
162
- if (pre[index + 1] === "\n") {
163
- if (escapeUrl) {
164
- returnValue += wrapAnsiHyperlink("");
165
- }
166
- if (escapeCode && code) {
167
- returnValue += wrapAnsiCode(code);
168
- }
169
- }
170
- else if (character === "\n") {
171
- if (escapeCode && code) {
172
- returnValue += wrapAnsiCode(escapeCode);
173
- }
174
- if (escapeUrl) {
175
- returnValue += wrapAnsiHyperlink(escapeUrl);
176
- }
177
- }
178
- preStringIndex += character.length;
179
- }
180
- return returnValue;
249
+ return processAnsiEscapes(pre, preString);
181
250
  };
182
251
  // For each newline, invoke the method separately
183
252
  export default function wrapAnsi(string, columns, options) {
@@ -9,6 +9,7 @@ export declare class TokenTracker extends EventEmitter<TokenTrackerEvents> {
9
9
  getTotalUsage(): LanguageModelUsage;
10
10
  getUsageByApp(app: string): LanguageModelUsage;
11
11
  getUsageBreakdown(): Record<string, number>;
12
+ reset(): void;
12
13
  printSummary(): void;
13
14
  }
14
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../source/tokens/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAO7C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC;CAC7B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAoB;IAElC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS;IAQ9D,aAAa,IAAI,kBAAkB;IA0CnC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IA0C9C,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY3C,YAAY;CAOb"}
1
+ {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../source/tokens/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAO7C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC;CAC7B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAoB;IAElC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS;IAQ9D,aAAa,IAAI,kBAAkB;IA0CnC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IA0C9C,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY3C,KAAK;IAIL,YAAY;CAOb"}
@@ -85,6 +85,9 @@ export class TokenTracker extends EventEmitter {
85
85
  return acc;
86
86
  }, {});
87
87
  }
88
+ reset() {
89
+ this.usages = [];
90
+ }
88
91
  printSummary() {
89
92
  const breakdown = this.getUsageBreakdown();
90
93
  console.info("Token Usage Summary:", {
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ import type { WorkspaceContext } from "../index.ts";
3
+ import type { ToolExecutionOptions } from "./types.ts";
4
+ export declare const AgentTool: {
5
+ name: "Agent";
6
+ };
7
+ declare const inputSchema: z.ZodObject<{
8
+ prompt: z.ZodString;
9
+ type: z.ZodString;
10
+ timeout: z.ZodOptional<z.ZodNumber>;
11
+ }, z.core.$strip>;
12
+ export declare const createAgentTools: (options: {
13
+ workspace: WorkspaceContext;
14
+ }) => Promise<{
15
+ toolDef: {
16
+ description: string;
17
+ inputSchema: z.ZodObject<{
18
+ prompt: z.ZodString;
19
+ type: z.ZodString;
20
+ timeout: z.ZodOptional<z.ZodNumber>;
21
+ }, z.core.$strip>;
22
+ };
23
+ display: ({ prompt, type }: z.infer<typeof inputSchema>) => string;
24
+ execute: ({ prompt, type, timeout }: z.infer<typeof inputSchema>, { abortSignal }: ToolExecutionOptions) => Promise<string>;
25
+ }>;
26
+ export {};
27
+ //# sourceMappingURL=agent.d.ts.map