@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
@@ -11,15 +11,29 @@ export type CompleteToolNames = keyof CompleteToolSet;
11
11
  export declare function initTools({ workspace, }: {
12
12
  workspace: WorkspaceContext;
13
13
  }): Promise<{
14
+ readonly ApplyPatch: {
15
+ toolDef: {
16
+ description: string;
17
+ inputSchema: import("zod").ZodObject<{
18
+ patchText: import("zod").ZodString;
19
+ }, import("zod/v4/core").$strip>;
20
+ };
21
+ display({ patchText }: {
22
+ patchText: string;
23
+ }): string;
24
+ execute({ patchText }: {
25
+ patchText: string;
26
+ }, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
27
+ };
14
28
  readonly Edit: {
15
29
  toolDef: {
16
30
  description: string;
17
31
  inputSchema: import("zod").ZodObject<{
18
32
  path: import("zod").ZodString;
19
- edits: import("zod").ZodArray<import("zod").ZodObject<{
33
+ edits: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodArray<import("zod").ZodObject<{
20
34
  oldText: import("zod").ZodString;
21
35
  newText: import("zod").ZodString;
22
- }, import("zod/v4/core").$strip>>;
36
+ }, import("zod/v4/core").$strip>>>;
23
37
  }, import("zod/v4/core").$strip>;
24
38
  };
25
39
  display({ path, edits }: {
@@ -112,7 +126,6 @@ export declare function initTools({ workspace, }: {
112
126
  }>>>;
113
127
  startLine: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
114
128
  lineCount: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
115
- maxBytes: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
116
129
  }, import("zod/v4/core").$strip>;
117
130
  };
118
131
  display({ path: providedPath, startLine, lineCount }: {
@@ -120,26 +133,24 @@ export declare function initTools({ workspace, }: {
120
133
  encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | null;
121
134
  startLine: number | null;
122
135
  lineCount: number | null;
123
- maxBytes: number | null;
124
136
  }): string;
125
- execute({ path: providedPath, encoding, startLine, lineCount, maxBytes, }: {
137
+ execute({ path: providedPath, encoding, startLine, lineCount, }: {
126
138
  path: string;
127
139
  encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex" | null;
128
140
  startLine: number | null;
129
141
  lineCount: number | null;
130
- maxBytes: number | null;
131
142
  }, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
132
143
  };
133
144
  readonly Glob: {
134
145
  toolDef: {
135
146
  description: string;
136
147
  inputSchema: import("zod").ZodObject<{
137
- patterns: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
138
- path: import("zod").ZodString;
148
+ patterns: import("zod").ZodPipe<import("zod").ZodTransform<{}, unknown>, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
149
+ path: import("zod").ZodPipe<import("zod").ZodTransform<{}, unknown>, import("zod").ZodString>;
139
150
  gitignore: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
140
151
  recursive: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
141
152
  expandDirectories: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
142
- ignoreFiles: import("zod").ZodNullable<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
153
+ ignoreFiles: import("zod").ZodPipe<import("zod").ZodTransform<{} | null | undefined, unknown>, import("zod").ZodNullable<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>>;
143
154
  cwd: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedString<unknown>>>;
144
155
  maxResults: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
145
156
  }, import("zod/v4/core").$strip>;
@@ -252,5 +263,99 @@ export declare function initTools({ workspace, }: {
252
263
  path?: string | undefined;
253
264
  }, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
254
265
  };
266
+ readonly Skill: {
267
+ toolDef: {
268
+ description: string;
269
+ inputSchema: import("zod").ZodObject<{
270
+ skill: import("zod").ZodString;
271
+ args: import("zod").ZodOptional<import("zod").ZodString>;
272
+ }, import("zod/v4/core").$strip>;
273
+ };
274
+ display({ skill: skillName }: {
275
+ skill: string;
276
+ args?: string | undefined;
277
+ }): string;
278
+ execute({ skill: skillName, args }: {
279
+ skill: string;
280
+ args?: string | undefined;
281
+ }, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
282
+ };
283
+ readonly Agent: {
284
+ toolDef: {
285
+ description: string;
286
+ inputSchema: import("zod").ZodObject<{
287
+ prompt: import("zod").ZodString;
288
+ type: import("zod").ZodString;
289
+ timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
290
+ }, import("zod/v4/core").$strip>;
291
+ };
292
+ display: ({ prompt, type }: import("zod").infer<import("zod").ZodObject<{
293
+ prompt: import("zod").ZodString;
294
+ type: import("zod").ZodString;
295
+ timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
296
+ }, import("zod/v4/core").$strip>>) => string;
297
+ execute: ({ prompt, type, timeout }: import("zod").infer<import("zod").ZodObject<{
298
+ prompt: import("zod").ZodString;
299
+ type: import("zod").ZodString;
300
+ timeout: import("zod").ZodOptional<import("zod").ZodNumber>;
301
+ }, import("zod/v4/core").$strip>>, { abortSignal }: import("./types.ts").ToolExecutionOptions) => Promise<string>;
302
+ };
303
+ readonly WebSearch: {
304
+ toolDef: {
305
+ description: string;
306
+ inputSchema: import("zod").ZodObject<{
307
+ query: import("zod").ZodString;
308
+ numResults: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
309
+ timeout: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
310
+ provider: import("zod").ZodOptional<import("zod").ZodEnum<{
311
+ exa: "exa";
312
+ duckduckgo: "duckduckgo";
313
+ }>>;
314
+ }, import("zod/v4/core").$strip>;
315
+ };
316
+ display({ query }: {
317
+ query: string;
318
+ numResults?: number | null | undefined;
319
+ timeout?: number | null | undefined;
320
+ provider?: "exa" | "duckduckgo" | undefined;
321
+ }): string;
322
+ execute(options: {
323
+ query: string;
324
+ numResults?: number | null | undefined;
325
+ timeout?: number | null | undefined;
326
+ provider?: "exa" | "duckduckgo" | undefined;
327
+ }, executionOptions: import("./types.ts").ToolExecutionOptions): Promise<string>;
328
+ };
329
+ readonly WebFetch: {
330
+ toolDef: {
331
+ description: string;
332
+ inputSchema: import("zod").ZodObject<{
333
+ url: import("zod").ZodString;
334
+ output: import("zod").ZodDefault<import("zod").ZodEnum<{
335
+ markdown: "markdown";
336
+ text: "text";
337
+ html: "html";
338
+ json: "json";
339
+ }>>;
340
+ jina: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
341
+ timeout: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
342
+ headers: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodTransform<string | null, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
343
+ }, import("zod/v4/core").$strip>;
344
+ };
345
+ display({ url }: {
346
+ url: string;
347
+ output: "markdown" | "text" | "html" | "json";
348
+ jina?: boolean | null | undefined;
349
+ timeout?: number | null | undefined;
350
+ headers?: boolean | null | undefined;
351
+ }): string;
352
+ execute(options: {
353
+ url: string;
354
+ output: "markdown" | "text" | "html" | "json";
355
+ jina?: boolean | null | undefined;
356
+ timeout?: number | null | undefined;
357
+ headers?: boolean | null | undefined;
358
+ }, executionOptions: import("./types.ts").ToolExecutionOptions): Promise<string>;
359
+ };
255
360
  }>;
256
361
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAepD,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,eAAe,CACvE,OAAO,SAAS,CACjB,CAAC,CAAC,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,IAAI,CAC5D,OAAO,EACP,MAAM,CACP;CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC;AAEtD,wBAAsB,SAAS,CAAC,EAC9B,SAAS,GACV,EAAE;IACD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAoBpD,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,eAAe,CACvE,OAAO,SAAS,CACjB,CAAC,CAAC,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,IAAI,CAC5D,OAAO,EACP,MAAM,CACP;CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC;AAEtD,wBAAsB,SAAS,CAAC,EAC9B,SAAS,GACV,EAAE;IACD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EA"}
@@ -1,3 +1,6 @@
1
+ import { config } from "../config/index.js";
2
+ import { AgentTool, createAgentTools } from "./agent.js";
3
+ import { ApplyPatchTool, createApplyPatchTool } from "./apply-patch.js";
1
4
  import { BashTool, createBashTool } from "./bash.js";
2
5
  import { createDirectoryTreeTool, DirectoryTreeTool, } from "./directory-tree.js";
3
6
  import { loadDynamicTools } from "./dynamic-tool-loader.js";
@@ -7,40 +10,48 @@ import { createGrepTool, GrepTool } from "./grep.js";
7
10
  import { createLsTool, LsTool } from "./ls.js";
8
11
  import { createReadFileTool, ReadFileTool } from "./read-file.js";
9
12
  import { createSaveFileTool, SaveFileTool } from "./save-file.js";
13
+ import { createSkillTool, SkillTool } from "./skill.js";
10
14
  import { createThinkTool, ThinkTool } from "./think.js";
15
+ import { createWebFetchTool, WebFetchTool } from "./web-fetch.js";
16
+ import { createWebSearchTool, WebSearchTool } from "./web-search.js";
11
17
  export async function initTools({ workspace, }) {
12
- const readFileTool = await createReadFileTool({
13
- workingDir: workspace.primaryDir,
14
- allowedDirs: workspace.allowedDirs,
15
- });
16
- const editFileTool = await createEditFileTool({
17
- workingDir: workspace.primaryDir,
18
- allowedDirs: workspace.allowedDirs,
19
- });
20
- const saveFileTool = await createSaveFileTool({
21
- workingDir: workspace.primaryDir,
22
- allowedDirs: workspace.allowedDirs,
23
- });
24
- const directoryTreeTool = await createDirectoryTreeTool({
25
- workingDir: workspace.primaryDir,
26
- allowedDirs: workspace.allowedDirs,
27
- });
18
+ const readFileTool = await createReadFileTool({ workspace });
19
+ const editFileTool = await createEditFileTool({ workspace });
20
+ const saveFileTool = await createSaveFileTool({ workspace });
21
+ const directoryTreeTool = await createDirectoryTreeTool({ workspace });
28
22
  const globTool = createGlobTool();
29
23
  const grepTool = createGrepTool();
30
24
  const thinkTool = createThinkTool();
31
- const lsTool = await createLsTool({
32
- workingDir: workspace.primaryDir,
33
- allowedDirs: workspace.allowedDirs,
34
- });
35
- const bashTool = await createBashTool({
36
- baseDir: workspace.primaryDir,
37
- allowedDirs: workspace.allowedDirs,
38
- });
25
+ const lsTool = await createLsTool({ workspace });
26
+ const projectConfig = await config.getConfig();
27
+ const bashTool = await createBashTool({ workspace, env: projectConfig.env });
28
+ const skillTool = await createSkillTool();
29
+ const agentTool = await createAgentTools({ workspace });
30
+ const webSearchTool = await createWebSearchTool();
31
+ const webFetchTool = await createWebFetchTool();
32
+ const applyPatchTool = await createApplyPatchTool({ workspace });
39
33
  const dynamicTools = await loadDynamicTools({
40
34
  baseDir: workspace.primaryDir,
35
+ existingToolNames: [
36
+ ApplyPatchTool.name,
37
+ EditFileTool.name,
38
+ BashTool.name,
39
+ SaveFileTool.name,
40
+ ReadFileTool.name,
41
+ GlobTool.name,
42
+ GrepTool.name,
43
+ DirectoryTreeTool.name,
44
+ ThinkTool.name,
45
+ LsTool.name,
46
+ SkillTool.name,
47
+ AgentTool.name,
48
+ WebSearchTool.name,
49
+ WebFetchTool.name,
50
+ ],
41
51
  });
42
52
  // Build tools object for AI SDK
43
53
  const tools = {
54
+ [ApplyPatchTool.name]: applyPatchTool,
44
55
  [EditFileTool.name]: editFileTool,
45
56
  [BashTool.name]: bashTool,
46
57
  [SaveFileTool.name]: saveFileTool,
@@ -50,6 +61,10 @@ export async function initTools({ workspace, }) {
50
61
  [DirectoryTreeTool.name]: directoryTreeTool,
51
62
  [ThinkTool.name]: thinkTool,
52
63
  [LsTool.name]: lsTool,
64
+ [SkillTool.name]: skillTool,
65
+ [AgentTool.name]: agentTool,
66
+ [WebSearchTool.name]: webSearchTool,
67
+ [WebFetchTool.name]: webFetchTool,
53
68
  // Add dynamic tools - they already have toolDef structure
54
69
  ...Object.fromEntries(Object.entries(dynamicTools).map(([name, toolObj]) => [name, toolObj])),
55
70
  };
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { WorkspaceContext } from "../index.ts";
2
3
  import type { ToolExecutionOptions } from "./types.ts";
3
4
  export declare const LsTool: {
4
5
  name: "LS";
@@ -9,8 +10,7 @@ declare const inputSchema: z.ZodObject<{
9
10
  }, z.core.$strip>;
10
11
  type LsInputSchema = z.infer<typeof inputSchema>;
11
12
  export declare const createLsTool: (options: {
12
- workingDir: string;
13
- allowedDirs?: string[];
13
+ workspace: WorkspaceContext;
14
14
  }) => Promise<{
15
15
  toolDef: {
16
16
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,QAAA,MAAM,WAAW;;;iBAQf,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAIjD,eAAO,MAAM,YAAY,GAAU,SAAS;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;2CAS0C,aAAa;2CAMnB,aAAa,mBAC3B,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA6DrB,CAAC"}
1
+ {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,QAAA,MAAM,WAAW;;;iBAQf,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAIjD,eAAO,MAAM,YAAY,GAAU,SAAS;IAC1C,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;2CAU0C,aAAa;2CAOnB,aAAa,mBAC3B,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA6DrB,CAAC"}
package/dist/tools/ls.js CHANGED
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
  import { z } from "zod";
4
4
  import style from "../terminal/style.js";
5
5
  import { isDirectory } from "../utils/filesystem/operations.js";
6
+ import { toDisplayPath } from "../utils/filesystem/path-display.js";
6
7
  import { validatePath } from "../utils/filesystem/security.js";
7
8
  import { convertNullString } from "../utils/zod.js";
8
9
  export const LsTool = {
@@ -19,17 +20,18 @@ const inputSchema = z.object({
19
20
  });
20
21
  const DEFAULT_ENTRY_LIMIT = 500;
21
22
  export const createLsTool = async (options) => {
22
- const { workingDir, allowedDirs } = options;
23
- const allowedDirectory = allowedDirs ?? [workingDir];
23
+ const { primaryDir, allowedDirs } = options.workspace;
24
+ const allowedDirectory = allowedDirs ?? [primaryDir];
24
25
  return {
25
26
  toolDef: {
26
- description: `List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Includes dotfiles. Output is limited to ${DEFAULT_ENTRY_LIMIT} entries by default. Use the limit parameter to adjust.`,
27
+ description: "List files in a single directory. Fast and simple - use this when you need a quick flat list of files in one directory. For recursive tree views, use DirectoryTree instead.",
27
28
  inputSchema,
28
29
  },
29
30
  display({ path: providedPath, limit }) {
30
31
  const dirPath = providedPath ?? ".";
31
32
  const effectiveLimit = limit ?? 500;
32
- return `\n> Listing ${style.cyan(dirPath)} (limit: ${effectiveLimit})`;
33
+ const displayPath = toDisplayPath(dirPath);
34
+ return `${style.cyan(displayPath)} (limit: ${effectiveLimit})`;
33
35
  },
34
36
  async execute({ path: providedPath, limit }, { abortSignal }) {
35
37
  if (abortSignal?.aborted) {
@@ -37,7 +39,7 @@ export const createLsTool = async (options) => {
37
39
  }
38
40
  const dirPath = providedPath ?? ".";
39
41
  const effectiveLimit = limit ?? DEFAULT_ENTRY_LIMIT;
40
- const resolvedPath = await validatePath(path.resolve(workingDir, dirPath), allowedDirectory, { requireExistence: true, abortSignal });
42
+ const resolvedPath = await validatePath(path.resolve(primaryDir, dirPath), allowedDirectory, { requireExistence: true, abortSignal });
41
43
  if (abortSignal?.aborted) {
42
44
  throw new Error("Directory listing aborted before validation");
43
45
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { WorkspaceContext } from "../index.ts";
2
3
  import type { ToolExecutionOptions } from "./types.ts";
3
4
  export declare const ReadFileTool: {
4
5
  name: "Read";
@@ -20,12 +21,10 @@ declare const inputSchema: z.ZodObject<{
20
21
  }>>>;
21
22
  startLine: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
22
23
  lineCount: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
23
- maxBytes: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
24
24
  }, z.core.$strip>;
25
25
  type ReadFileInputSchema = z.infer<typeof inputSchema>;
26
- export declare const createReadFileTool: ({ workingDir, allowedDirs, }: {
27
- workingDir: string;
28
- allowedDirs?: string[];
26
+ export declare const createReadFileTool: (options: {
27
+ workspace: WorkspaceContext;
29
28
  }) => Promise<{
30
29
  toolDef: {
31
30
  description: string;
@@ -46,11 +45,10 @@ export declare const createReadFileTool: ({ workingDir, allowedDirs, }: {
46
45
  }>>>;
47
46
  startLine: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
48
47
  lineCount: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
49
- maxBytes: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
50
48
  }, z.core.$strip>;
51
49
  };
52
50
  display({ path: providedPath, startLine, lineCount }: ReadFileInputSchema): string;
53
- execute({ path: providedPath, encoding, startLine, lineCount, maxBytes, }: ReadFileInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
51
+ execute({ path: providedPath, encoding, startLine, lineCount, }: ReadFileInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
54
52
  }>;
55
53
  export {};
56
54
  //# sourceMappingURL=read-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;iBAuBf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAU,8BAGtC;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;;;0DAOyD,mBAAmB;+EAUpE,mBAAmB,mBACL,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAqDrB,CAAC"}
1
+ {"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAsBvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;iBAkBf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAU,SAAS;IAChD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;0DAOyD,mBAAmB;qEAUpE,mBAAmB,mBACL,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAsBrB,CAAC"}
@@ -1,12 +1,28 @@
1
1
  import fs from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { createInterface } from "node:readline/promises";
2
5
  import { isNumber } from "@travisennis/stdlib/typeguards";
3
6
  import { z } from "zod";
4
7
  import style from "../terminal/style.js";
5
- import { joinWorkingDir, validatePath } from "../utils/filesystem/security.js";
8
+ import { toDisplayPath } from "../utils/filesystem/path-display.js";
6
9
  import { convertNullString } from "../utils/zod.js";
7
10
  import { fileEncodingSchema } from "./types.js";
8
- // default limit in bytes
9
- const DEFAULT_BYTE_LIMIT = 80 * 1024;
11
+ // hardcoded limit in bytes (50KB) - not configurable by the agent
12
+ const BYTE_LIMIT = 50 * 1024;
13
+ // Resolve a path for reading, expanding ~ and handling relative paths
14
+ function resolveReadPath(providedPath, workingDir) {
15
+ // Expand ~ to home directory
16
+ let resolved = providedPath;
17
+ if (resolved.startsWith("~/") || resolved === "~") {
18
+ resolved = path.join(os.homedir(), resolved.slice(1));
19
+ }
20
+ // If not absolute, join with working directory
21
+ if (!path.isAbsolute(resolved)) {
22
+ resolved = path.join(workingDir, resolved);
23
+ }
24
+ return path.normalize(resolved);
25
+ }
10
26
  export const ReadFileTool = {
11
27
  name: "Read",
12
28
  };
@@ -22,53 +38,82 @@ const inputSchema = z.object({
22
38
  lineCount: z
23
39
  .preprocess((val) => convertNullString(val), z.coerce.number().nullable())
24
40
  .describe("Maximum number of lines to read. Required but nullable. Pass null to get all lines."),
25
- maxBytes: z
26
- .preprocess((val) => convertNullString(val), z.coerce.number().nullable())
27
- .describe("Maximum number of bytes to read. Set to 0 for no limit. (Default: 80KB)"),
28
41
  });
29
- export const createReadFileTool = async ({ workingDir, allowedDirs, }) => {
30
- const allowedDirectory = allowedDirs ?? [workingDir];
42
+ export const createReadFileTool = async (options) => {
43
+ const { primaryDir } = options.workspace;
31
44
  return {
32
45
  toolDef: {
33
- description: `Read the complete contents of a file from the file system unless startLine and lineCount are given to read a file selection. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Only works within allowed directories. Automatically limits file size to prevent overwhelming output. Default limit is ${DEFAULT_BYTE_LIMIT} bytes (${DEFAULT_BYTE_LIMIT / 1024}KB). Use maxBytes parameter to override this limit.`,
46
+ description: "Read the contents of a file.",
34
47
  inputSchema,
35
48
  },
36
49
  display({ path: providedPath, startLine, lineCount }) {
37
- return `\n> ${style.cyan(providedPath)}${startLine ? style.cyan(`:${startLine}`) : ""}${lineCount ? style.cyan(`:${lineCount}`) : ""}`;
50
+ const displayPath = toDisplayPath(providedPath);
51
+ return `${style.cyan(displayPath)}${startLine ? style.cyan(`:${startLine}`) : ""}${lineCount ? style.cyan(`:${lineCount}`) : ""}`;
38
52
  },
39
- async execute({ path: providedPath, encoding, startLine, lineCount, maxBytes, }, { abortSignal }) {
53
+ async execute({ path: providedPath, encoding, startLine, lineCount, }, { abortSignal }) {
40
54
  if (abortSignal?.aborted) {
41
55
  throw new Error("File reading aborted");
42
56
  }
43
- const filePath = await validatePath(joinWorkingDir(providedPath, workingDir), allowedDirectory, { abortSignal });
44
- if (abortSignal?.aborted) {
45
- throw new Error("File reading aborted before file read");
46
- }
47
- let file = await fs.readFile(filePath, {
48
- encoding: encoding ?? "utf-8",
49
- });
50
- if (isNumber(startLine) || isNumber(lineCount)) {
51
- const lines = file.split("\n");
52
- const totalLines = lines.length;
53
- const startIndex = (startLine ?? 1) - 1;
54
- const count = lineCount ?? totalLines - startIndex;
55
- if (startIndex < 0 || startIndex >= totalLines) {
56
- throw new Error(`startLine ${startLine} is out of bounds for file with ${totalLines} lines.`);
57
- }
58
- const endIndex = Math.min(startIndex + count, totalLines);
59
- file = lines.slice(startIndex, endIndex).join("\n");
60
- }
61
- const effectiveMaxBytes = maxBytes ?? DEFAULT_BYTE_LIMIT;
62
- if (effectiveMaxBytes !== null &&
63
- effectiveMaxBytes !== undefined &&
64
- effectiveMaxBytes > 0) {
65
- const buffer = Buffer.from(file, encoding ?? "utf-8");
66
- if (buffer.byteLength > effectiveMaxBytes) {
67
- const truncatedBuffer = buffer.subarray(0, effectiveMaxBytes);
68
- file = truncatedBuffer.toString(encoding ?? "utf-8");
69
- }
70
- }
57
+ const filePath = resolveReadPath(providedPath, primaryDir);
58
+ const effectiveEncoding = encoding ?? "utf-8";
59
+ const file = await readFileContent(filePath, effectiveEncoding, startLine, lineCount, abortSignal);
60
+ validateByteLimit(file, effectiveEncoding, BYTE_LIMIT);
71
61
  return file;
72
62
  },
73
63
  };
74
64
  };
65
+ // Read file content either line-by-line or as a whole
66
+ async function readFileContent(filePath, encoding, startLine, lineCount, abortSignal) {
67
+ const useLineBasedRead = isNumber(startLine) || isNumber(lineCount);
68
+ if (useLineBasedRead) {
69
+ return readFileLines(filePath, startLine, lineCount, abortSignal);
70
+ }
71
+ if (abortSignal?.aborted) {
72
+ throw new Error("File reading aborted before file read");
73
+ }
74
+ return fs.readFile(filePath, { encoding });
75
+ }
76
+ // Read specific lines from a file using streaming
77
+ async function readFileLines(filePath, startLine, lineCount, abortSignal) {
78
+ const fileStream = await fs.open(filePath, "r");
79
+ const rl = createInterface({
80
+ input: fileStream.createReadStream(),
81
+ crlfDelay: Number.POSITIVE_INFINITY,
82
+ });
83
+ const lines = [];
84
+ const startIndex = (startLine ?? 1) - 1;
85
+ const count = lineCount ?? Number.POSITIVE_INFINITY;
86
+ let currentIndex = 0;
87
+ for await (const line of rl) {
88
+ if (currentIndex >= startIndex && currentIndex < startIndex + count) {
89
+ lines.push(line);
90
+ }
91
+ currentIndex++;
92
+ if (currentIndex >= startIndex + count) {
93
+ break;
94
+ }
95
+ if (abortSignal?.aborted) {
96
+ rl.close();
97
+ await fileStream.close();
98
+ throw new Error("File reading aborted");
99
+ }
100
+ }
101
+ rl.close();
102
+ await fileStream.close();
103
+ if (startIndex >= currentIndex) {
104
+ throw new Error(`startLine ${startLine} is out of bounds for file with ${currentIndex} lines.`);
105
+ }
106
+ return lines.join("\n");
107
+ }
108
+ // Validate that file content doesn't exceed byte limit
109
+ function validateByteLimit(file, encoding, maxBytes) {
110
+ const byteLength = Buffer.byteLength(file, encoding);
111
+ if (byteLength > maxBytes) {
112
+ const fileSizeKb = (byteLength / 1024).toFixed(1);
113
+ const limitKb = (maxBytes / 1024).toFixed(0);
114
+ throw new Error(`File (${fileSizeKb}KB) exceeds the ${limitKb}KB read limit. To read this file, use one of these options:\n` +
115
+ "• Use startLine and lineCount to read specific portions (e.g., startLine: 1, lineCount: 100)\n" +
116
+ "• Use the Grep tool to search for specific content\n" +
117
+ `• Use the Bash tool with 'tail' or 'head' commands`);
118
+ }
119
+ }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { WorkspaceContext } from "../index.ts";
2
3
  import { type ToolExecutionOptions } from "./types.ts";
3
4
  export declare const SaveFileTool: {
4
5
  name: "Write";
@@ -21,9 +22,8 @@ declare const inputSchema: z.ZodObject<{
21
22
  }>>;
22
23
  }, z.core.$strip>;
23
24
  type SaveFileInputSchema = z.infer<typeof inputSchema>;
24
- export declare const createSaveFileTool: ({ workingDir, allowedDirs, }: {
25
- workingDir: string;
26
- allowedDirs?: string[];
25
+ export declare const createSaveFileTool: (options: {
26
+ workspace: WorkspaceContext;
27
27
  }) => Promise<{
28
28
  toolDef: {
29
29
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"save-file.d.ts","sourceRoot":"","sources":["../../source/tools/save-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAU,8BAGtC;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;sBAYqB,mBAAmB;mDAII,mBAAmB,mBACzC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAqDrB,CAAC"}
1
+ {"version":3,"file":"save-file.d.ts","sourceRoot":"","sources":["../../source/tools/save-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AA8BvD,eAAO,MAAM,kBAAkB,GAAU,SAAS;IAChD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;sBAUqB,mBAAmB;mDAKI,mBAAmB,mBACzC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA8BrB,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { z } from "zod";
4
- import { config } from "../config.js";
4
+ import { config } from "../config/index.js";
5
5
  import { clearProjectStatusCache } from "../repl/project-status.js";
6
6
  import style from "../terminal/style.js";
7
+ import { toDisplayPath } from "../utils/filesystem/path-display.js";
7
8
  import { joinWorkingDir, validateFileNotReadOnly, validatePath, } from "../utils/filesystem/security.js";
8
9
  import { fileEncodingSchema } from "./types.js";
9
10
  export const SaveFileTool = {
@@ -16,46 +17,50 @@ const inputSchema = z.object({
16
17
  .describe('Encoding format for saving the file. Use "utf-8" as default for text files')
17
18
  .default("utf-8"),
18
19
  });
19
- export const createSaveFileTool = async ({ workingDir, allowedDirs, }) => {
20
- const allowedDirectory = allowedDirs ?? [workingDir];
20
+ async function checkFileNotReadOnly(filePath, projectConfig, primaryDir) {
21
+ try {
22
+ await fs.stat(filePath);
23
+ validateFileNotReadOnly(filePath, projectConfig, primaryDir);
24
+ }
25
+ catch (error) {
26
+ if (error.code !== "ENOENT") {
27
+ throw error;
28
+ }
29
+ }
30
+ }
31
+ async function ensurePathIsFile(filePath) {
32
+ try {
33
+ const stat = await fs.stat(filePath);
34
+ if (stat.isDirectory()) {
35
+ throw new Error(`Cannot save file - path is a directory: ${filePath}`);
36
+ }
37
+ }
38
+ catch (error) {
39
+ if (error.code !== "ENOENT") {
40
+ throw error;
41
+ }
42
+ }
43
+ }
44
+ export const createSaveFileTool = async (options) => {
45
+ const { primaryDir, allowedDirs } = options.workspace;
46
+ const allowedDirectory = allowedDirs ?? [primaryDir];
47
+ const projectConfig = await config.getConfig();
21
48
  return {
22
49
  toolDef: {
23
- description: "Create a new file or completely overwrite an existing file with new content. " +
24
- "Automatically creates all missing parent directories. " +
25
- "Use with caution as it will overwrite existing files without warning. " +
26
- "Handles text content with proper encoding. Only works within allowed directories.",
50
+ description: "Create or overwrite a file with new content.",
27
51
  inputSchema,
28
52
  },
29
53
  display({ path }) {
30
- return `\n> ${style.cyan(path)}`;
54
+ const displayPath = toDisplayPath(path);
55
+ return `${style.cyan(displayPath)}`;
31
56
  },
32
57
  async execute({ path: userPath, content, encoding }, { abortSignal }) {
33
58
  if (abortSignal?.aborted) {
34
59
  throw new Error("File saving aborted");
35
60
  }
36
- const filePath = await validatePath(joinWorkingDir(userPath, workingDir), allowedDirectory, { requireExistence: false, abortSignal });
37
- try {
38
- await fs.stat(filePath);
39
- const projectConfig = await config.getConfig();
40
- validateFileNotReadOnly(filePath, projectConfig, workingDir);
41
- }
42
- catch (error) {
43
- if (error.code !== "ENOENT") {
44
- throw error;
45
- }
46
- }
47
- try {
48
- const stat = await fs.stat(filePath);
49
- if (stat.isDirectory()) {
50
- throw new Error(`Cannot save file - path is a directory: ${filePath}`);
51
- }
52
- }
53
- catch (error) {
54
- if (error instanceof Error &&
55
- error.message.includes("is a directory")) {
56
- throw error;
57
- }
58
- }
61
+ const filePath = await validatePath(joinWorkingDir(userPath, primaryDir), allowedDirectory, { requireExistence: false, abortSignal });
62
+ await checkFileNotReadOnly(filePath, projectConfig, primaryDir);
63
+ await ensurePathIsFile(filePath);
59
64
  if (abortSignal?.aborted) {
60
65
  throw new Error("File saving aborted before writing");
61
66
  }