@travisennis/acai 0.0.5 → 0.0.6

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 (311) hide show
  1. package/README.md +4 -2
  2. package/dist/agent/index.d.ts +119 -0
  3. package/dist/agent/index.d.ts.map +1 -0
  4. package/dist/agent/index.js +406 -0
  5. package/dist/agent/manual-loop.d.ts +41 -0
  6. package/dist/agent/manual-loop.d.ts.map +1 -0
  7. package/dist/agent/manual-loop.js +278 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +27 -33
  11. package/dist/commands/add-directory-command.d.ts +3 -0
  12. package/dist/commands/add-directory-command.d.ts.map +1 -0
  13. package/dist/commands/add-directory-command.js +85 -0
  14. package/dist/commands/application-log-command.d.ts.map +1 -1
  15. package/dist/commands/application-log-command.js +34 -0
  16. package/dist/commands/clear-command.d.ts.map +1 -1
  17. package/dist/commands/clear-command.js +8 -0
  18. package/dist/commands/compact-command.d.ts.map +1 -1
  19. package/dist/commands/compact-command.js +15 -2
  20. package/dist/commands/context-command.d.ts +3 -0
  21. package/dist/commands/context-command.d.ts.map +1 -0
  22. package/dist/commands/context-command.js +183 -0
  23. package/dist/commands/copy-command.d.ts.map +1 -1
  24. package/dist/commands/copy-command.js +28 -0
  25. package/dist/commands/edit-command.d.ts.map +1 -1
  26. package/dist/commands/edit-command.js +33 -0
  27. package/dist/commands/edit-prompt-command.d.ts.map +1 -1
  28. package/dist/commands/edit-prompt-command.js +28 -0
  29. package/dist/commands/exit-command.d.ts.map +1 -1
  30. package/dist/commands/exit-command.js +20 -0
  31. package/dist/commands/files-command.d.ts.map +1 -1
  32. package/dist/commands/files-command.js +57 -0
  33. package/dist/commands/generate-rules-command.d.ts.map +1 -1
  34. package/dist/commands/generate-rules-command.js +311 -1
  35. package/dist/commands/handoff-command.d.ts +3 -0
  36. package/dist/commands/handoff-command.d.ts.map +1 -0
  37. package/dist/commands/handoff-command.js +202 -0
  38. package/dist/commands/health-command.d.ts.map +1 -1
  39. package/dist/commands/health-command.js +119 -2
  40. package/dist/commands/help-command.d.ts.map +1 -1
  41. package/dist/commands/help-command.js +28 -0
  42. package/dist/commands/history-command.d.ts +3 -0
  43. package/dist/commands/history-command.d.ts.map +1 -0
  44. package/dist/commands/history-command.js +534 -0
  45. package/dist/commands/init-command.d.ts +1 -1
  46. package/dist/commands/init-command.d.ts.map +1 -1
  47. package/dist/commands/init-command.js +55 -18
  48. package/dist/commands/last-log-command.d.ts.map +1 -1
  49. package/dist/commands/last-log-command.js +27 -0
  50. package/dist/commands/list-directories-command.d.ts +3 -0
  51. package/dist/commands/list-directories-command.d.ts.map +1 -0
  52. package/dist/commands/list-directories-command.js +48 -0
  53. package/dist/commands/list-tools-command.d.ts.map +1 -1
  54. package/dist/commands/list-tools-command.js +66 -3
  55. package/dist/commands/manager.d.ts +15 -3
  56. package/dist/commands/manager.d.ts.map +1 -1
  57. package/dist/commands/manager.js +86 -26
  58. package/dist/commands/model-command.d.ts +22 -0
  59. package/dist/commands/model-command.d.ts.map +1 -1
  60. package/dist/commands/model-command.js +256 -0
  61. package/dist/commands/paste-command.d.ts.map +1 -1
  62. package/dist/commands/paste-command.js +92 -0
  63. package/dist/commands/pickup-command.d.ts +3 -0
  64. package/dist/commands/pickup-command.d.ts.map +1 -0
  65. package/dist/commands/pickup-command.js +161 -0
  66. package/dist/commands/prompt-command.d.ts +1 -1
  67. package/dist/commands/prompt-command.d.ts.map +1 -1
  68. package/dist/commands/prompt-command.js +117 -2
  69. package/dist/commands/remove-directory-command.d.ts +3 -0
  70. package/dist/commands/remove-directory-command.d.ts.map +1 -0
  71. package/dist/commands/remove-directory-command.js +87 -0
  72. package/dist/commands/reset-command.d.ts +1 -1
  73. package/dist/commands/reset-command.d.ts.map +1 -1
  74. package/dist/commands/reset-command.js +13 -2
  75. package/dist/commands/rules-command.d.ts.map +1 -1
  76. package/dist/commands/rules-command.js +65 -0
  77. package/dist/commands/save-command.d.ts.map +1 -1
  78. package/dist/commands/save-command.js +12 -0
  79. package/dist/commands/shell-command.d.ts.map +1 -1
  80. package/dist/commands/shell-command.js +68 -0
  81. package/dist/commands/types.d.ts +9 -4
  82. package/dist/commands/types.d.ts.map +1 -1
  83. package/dist/commands/usage-command.d.ts.map +1 -1
  84. package/dist/commands/usage-command.js +22 -0
  85. package/dist/config.d.ts +6 -7
  86. package/dist/config.d.ts.map +1 -1
  87. package/dist/config.js +23 -29
  88. package/dist/formatting.d.ts +108 -0
  89. package/dist/formatting.d.ts.map +1 -1
  90. package/dist/formatting.js +147 -0
  91. package/dist/index.d.ts +7 -2
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +140 -38
  94. package/dist/logger.d.ts.map +1 -1
  95. package/dist/logger.js +47 -18
  96. package/dist/mentions.d.ts +2 -1
  97. package/dist/mentions.d.ts.map +1 -1
  98. package/dist/mentions.js +16 -1
  99. package/dist/messages.d.ts +8 -0
  100. package/dist/messages.d.ts.map +1 -1
  101. package/dist/messages.js +56 -19
  102. package/dist/middleware/cache.d.ts +3 -0
  103. package/dist/middleware/cache.d.ts.map +1 -0
  104. package/dist/middleware/cache.js +53 -0
  105. package/dist/middleware/index.d.ts +1 -0
  106. package/dist/middleware/index.d.ts.map +1 -1
  107. package/dist/middleware/index.js +1 -0
  108. package/dist/models/ai-config.d.ts +4 -2
  109. package/dist/models/ai-config.d.ts.map +1 -1
  110. package/dist/models/ai-config.js +12 -2
  111. package/dist/models/anthropic-provider.d.ts.map +1 -1
  112. package/dist/models/anthropic-provider.js +3 -60
  113. package/dist/models/manager.d.ts +2 -1
  114. package/dist/models/manager.d.ts.map +1 -1
  115. package/dist/models/manager.js +26 -2
  116. package/dist/models/openrouter-provider.d.ts +7 -14
  117. package/dist/models/openrouter-provider.d.ts.map +1 -1
  118. package/dist/models/openrouter-provider.js +114 -169
  119. package/dist/models/providers.d.ts +1 -1
  120. package/dist/models/providers.d.ts.map +1 -1
  121. package/dist/prompts.d.ts +1 -0
  122. package/dist/prompts.d.ts.map +1 -1
  123. package/dist/prompts.js +53 -4
  124. package/dist/repl/display-tool-messages.d.ts +1 -1
  125. package/dist/repl/display-tool-messages.d.ts.map +1 -1
  126. package/dist/repl/display-tool-messages.js +47 -44
  127. package/dist/repl/get-prompt-header.d.ts.map +1 -1
  128. package/dist/repl/get-prompt-header.js +1 -30
  129. package/dist/repl/project-status-line.d.ts +2 -0
  130. package/dist/repl/project-status-line.d.ts.map +1 -0
  131. package/dist/repl/project-status-line.js +31 -0
  132. package/dist/repl/prompt.d.ts +21 -0
  133. package/dist/repl/prompt.d.ts.map +1 -0
  134. package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
  135. package/dist/repl/tool-call-repair.d.ts.map +1 -1
  136. package/dist/repl/tool-call-repair.js +8 -4
  137. package/dist/repl-new.d.ts +53 -0
  138. package/dist/repl-new.d.ts.map +1 -0
  139. package/dist/repl-new.js +374 -0
  140. package/dist/repl.d.ts +3 -5
  141. package/dist/repl.d.ts.map +1 -1
  142. package/dist/repl.js +74 -166
  143. package/dist/terminal/checkbox-prompt.d.ts.map +1 -1
  144. package/dist/terminal/checkbox-prompt.js +10 -4
  145. package/dist/terminal/index.d.ts +7 -0
  146. package/dist/terminal/index.d.ts.map +1 -1
  147. package/dist/terminal/index.js +94 -0
  148. package/dist/terminal/input-prompt.d.ts +2 -1
  149. package/dist/terminal/input-prompt.d.ts.map +1 -1
  150. package/dist/terminal/markdown.js +3 -0
  151. package/dist/terminal/search-prompt.d.ts.map +1 -1
  152. package/dist/terminal/search-prompt.js +11 -10
  153. package/dist/terminal/select-prompt.d.ts +2 -2
  154. package/dist/terminal/select-prompt.d.ts.map +1 -1
  155. package/dist/terminal/select-prompt.js +47 -39
  156. package/dist/tokens/threshold.d.ts +35 -0
  157. package/dist/tokens/threshold.d.ts.map +1 -0
  158. package/dist/tokens/threshold.js +85 -0
  159. package/dist/tools/advanced-edit-file.d.ts +69 -0
  160. package/dist/tools/advanced-edit-file.d.ts.map +1 -0
  161. package/dist/tools/advanced-edit-file.js +281 -0
  162. package/dist/tools/agent.d.ts +16 -5
  163. package/dist/tools/agent.d.ts.map +1 -1
  164. package/dist/tools/agent.js +71 -58
  165. package/dist/tools/bash-utils.d.ts +1 -1
  166. package/dist/tools/bash-utils.d.ts.map +1 -1
  167. package/dist/tools/bash-utils.js +14 -6
  168. package/dist/tools/bash.d.ts +21 -12
  169. package/dist/tools/bash.d.ts.map +1 -1
  170. package/dist/tools/bash.js +88 -135
  171. package/dist/tools/code-interpreter.d.ts +21 -9
  172. package/dist/tools/code-interpreter.d.ts.map +1 -1
  173. package/dist/tools/code-interpreter.js +138 -137
  174. package/dist/tools/delete-file.d.ts +17 -10
  175. package/dist/tools/delete-file.d.ts.map +1 -1
  176. package/dist/tools/delete-file.js +51 -95
  177. package/dist/tools/directory-tree.d.ts +17 -6
  178. package/dist/tools/directory-tree.d.ts.map +1 -1
  179. package/dist/tools/directory-tree.js +47 -49
  180. package/dist/tools/dynamic-tool-loader.d.ts +18 -8
  181. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  182. package/dist/tools/dynamic-tool-loader.js +121 -129
  183. package/dist/tools/dynamic-tool-parser.d.ts +1 -0
  184. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
  185. package/dist/tools/dynamic-tool-parser.js +1 -0
  186. package/dist/tools/edit-file.d.ts +35 -15
  187. package/dist/tools/edit-file.d.ts.map +1 -1
  188. package/dist/tools/edit-file.js +112 -112
  189. package/dist/tools/filesystem-utils.d.ts +2 -1
  190. package/dist/tools/filesystem-utils.d.ts.map +1 -1
  191. package/dist/tools/filesystem-utils.js +31 -17
  192. package/dist/tools/glob.d.ts +36 -0
  193. package/dist/tools/glob.d.ts.map +1 -0
  194. package/dist/tools/glob.js +143 -0
  195. package/dist/tools/grep.d.ts +73 -12
  196. package/dist/tools/grep.d.ts.map +1 -1
  197. package/dist/tools/grep.js +413 -168
  198. package/dist/tools/index.d.ts +204 -124
  199. package/dist/tools/index.d.ts.map +1 -1
  200. package/dist/tools/index.js +242 -135
  201. package/dist/tools/llm-edit-fixer.d.ts +25 -0
  202. package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
  203. package/dist/tools/llm-edit-fixer.js +150 -0
  204. package/dist/tools/move-file.d.ts +19 -7
  205. package/dist/tools/move-file.d.ts.map +1 -1
  206. package/dist/tools/move-file.js +40 -33
  207. package/dist/tools/read-file.d.ts +47 -9
  208. package/dist/tools/read-file.d.ts.map +1 -1
  209. package/dist/tools/read-file.js +74 -69
  210. package/dist/tools/read-multiple-files.d.ts +17 -6
  211. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  212. package/dist/tools/read-multiple-files.js +76 -73
  213. package/dist/tools/save-file.d.ts +45 -12
  214. package/dist/tools/save-file.d.ts.map +1 -1
  215. package/dist/tools/save-file.js +58 -101
  216. package/dist/tools/think.d.ts +15 -7
  217. package/dist/tools/think.d.ts.map +1 -1
  218. package/dist/tools/think.js +30 -22
  219. package/dist/tools/types.d.ts +4 -10
  220. package/dist/tools/types.d.ts.map +1 -1
  221. package/dist/tools/types.js +9 -0
  222. package/dist/tools/utils.d.ts +14 -0
  223. package/dist/tools/utils.d.ts.map +1 -0
  224. package/dist/tools/utils.js +16 -0
  225. package/dist/tools/web-fetch.d.ts +11 -4
  226. package/dist/tools/web-fetch.d.ts.map +1 -1
  227. package/dist/tools/web-fetch.js +39 -38
  228. package/dist/tools/web-search.d.ts +15 -6
  229. package/dist/tools/web-search.d.ts.map +1 -1
  230. package/dist/tools/web-search.js +50 -32
  231. package/dist/tui/autocomplete.d.ts +44 -0
  232. package/dist/tui/autocomplete.d.ts.map +1 -0
  233. package/dist/tui/autocomplete.js +466 -0
  234. package/dist/tui/components/assistant-message.d.ts +18 -0
  235. package/dist/tui/components/assistant-message.d.ts.map +1 -0
  236. package/dist/tui/components/assistant-message.js +29 -0
  237. package/dist/tui/components/editor.d.ts +51 -0
  238. package/dist/tui/components/editor.d.ts.map +1 -0
  239. package/dist/tui/components/editor.js +758 -0
  240. package/dist/tui/components/footer.d.ts +24 -0
  241. package/dist/tui/components/footer.d.ts.map +1 -0
  242. package/dist/tui/components/footer.js +197 -0
  243. package/dist/tui/components/input.d.ts +14 -0
  244. package/dist/tui/components/input.d.ts.map +1 -0
  245. package/dist/tui/components/input.js +122 -0
  246. package/dist/tui/components/loader.d.ts +19 -0
  247. package/dist/tui/components/loader.d.ts.map +1 -0
  248. package/dist/tui/components/loader.js +45 -0
  249. package/dist/tui/components/markdown.d.ts +103 -0
  250. package/dist/tui/components/markdown.d.ts.map +1 -0
  251. package/dist/tui/components/markdown.js +533 -0
  252. package/dist/tui/components/modal.d.ts +40 -0
  253. package/dist/tui/components/modal.d.ts.map +1 -0
  254. package/dist/tui/components/modal.js +292 -0
  255. package/dist/tui/components/prompt-status.d.ts +16 -0
  256. package/dist/tui/components/prompt-status.d.ts.map +1 -0
  257. package/dist/tui/components/prompt-status.js +21 -0
  258. package/dist/tui/components/select-list.d.ts +22 -0
  259. package/dist/tui/components/select-list.d.ts.map +1 -0
  260. package/dist/tui/components/select-list.js +143 -0
  261. package/dist/tui/components/spacer.d.ts +16 -0
  262. package/dist/tui/components/spacer.d.ts.map +1 -0
  263. package/dist/tui/components/spacer.js +27 -0
  264. package/dist/tui/components/text.d.ts +26 -0
  265. package/dist/tui/components/text.d.ts.map +1 -0
  266. package/dist/tui/components/text.js +143 -0
  267. package/dist/tui/components/thinking-block.d.ts +14 -0
  268. package/dist/tui/components/thinking-block.d.ts.map +1 -0
  269. package/dist/tui/components/thinking-block.js +30 -0
  270. package/dist/tui/components/tool-execution.d.ts +17 -0
  271. package/dist/tui/components/tool-execution.d.ts.map +1 -0
  272. package/dist/tui/components/tool-execution.js +153 -0
  273. package/dist/tui/components/user-message.d.ts +9 -0
  274. package/dist/tui/components/user-message.d.ts.map +1 -0
  275. package/dist/tui/components/user-message.js +21 -0
  276. package/dist/tui/components/welcome.d.ts +6 -0
  277. package/dist/tui/components/welcome.d.ts.map +1 -0
  278. package/dist/tui/components/welcome.js +30 -0
  279. package/dist/tui/index.d.ts +14 -0
  280. package/dist/tui/index.d.ts.map +1 -0
  281. package/dist/tui/index.js +18 -0
  282. package/dist/tui/terminal.d.ts +37 -0
  283. package/dist/tui/terminal.d.ts.map +1 -0
  284. package/dist/tui/terminal.js +104 -0
  285. package/dist/tui/tui.d.ts +67 -0
  286. package/dist/tui/tui.d.ts.map +1 -0
  287. package/dist/tui/tui.js +184 -0
  288. package/dist/tui/utils.d.ts +19 -0
  289. package/dist/tui/utils.d.ts.map +1 -0
  290. package/dist/tui/utils.js +31 -0
  291. package/dist/utils/generators.d.ts +3 -0
  292. package/dist/utils/generators.d.ts.map +1 -0
  293. package/dist/utils/generators.js +25 -0
  294. package/dist/utils/iterables.d.ts +2 -0
  295. package/dist/utils/iterables.d.ts.map +1 -0
  296. package/dist/utils/iterables.js +6 -0
  297. package/package.json +16 -16
  298. package/dist/conversation-analyzer.d.ts +0 -11
  299. package/dist/conversation-analyzer.d.ts.map +0 -1
  300. package/dist/conversation-analyzer.js +0 -88
  301. package/dist/repl-prompt.d.ts +0 -15
  302. package/dist/repl-prompt.d.ts.map +0 -1
  303. package/dist/tokens/manage-output.d.ts +0 -34
  304. package/dist/tokens/manage-output.d.ts.map +0 -1
  305. package/dist/tokens/manage-output.js +0 -44
  306. package/dist/tool-executor.d.ts +0 -28
  307. package/dist/tool-executor.d.ts.map +0 -1
  308. package/dist/tool-executor.js +0 -74
  309. package/dist/tools/file-editing-utils.d.ts +0 -2
  310. package/dist/tools/file-editing-utils.d.ts.map +0 -1
  311. package/dist/tools/file-editing-utils.js +0 -135
package/dist/config.js CHANGED
@@ -11,25 +11,22 @@ const ProjectConfigSchema = z.object({
11
11
  path: z.string(),
12
12
  })
13
13
  .optional(),
14
+ loop: z
15
+ .object({
16
+ maxIterations: z.number().default(90),
17
+ parallelTools: z.boolean().default(true),
18
+ maxDurationMs: z.number().default(0),
19
+ })
20
+ .optional()
21
+ .default({
22
+ maxIterations: 90,
23
+ parallelTools: true,
24
+ maxDurationMs: 0,
25
+ }),
14
26
  tools: z
15
27
  .object({
16
28
  maxTokens: z.number().default(30000),
17
- bash: z
18
- .object({
19
- allowPipes: z.boolean().default(true),
20
- allowChaining: z.boolean().default(true),
21
- allowRedirection: z.boolean().default(true),
22
- maxSegments: z.number().default(6),
23
- maxOutputBytes: z.number().default(2_000_000),
24
- })
25
- .optional()
26
- .default({
27
- allowPipes: true,
28
- allowChaining: true,
29
- allowRedirection: true,
30
- maxSegments: 6,
31
- maxOutputBytes: 2_000_000,
32
- }),
29
+ maxResults: z.number().default(30),
33
30
  dynamicTools: z
34
31
  .object({
35
32
  enabled: z.boolean().default(true),
@@ -44,13 +41,7 @@ const ProjectConfigSchema = z.object({
44
41
  .optional()
45
42
  .default({
46
43
  maxTokens: 30000,
47
- bash: {
48
- allowPipes: true,
49
- allowChaining: true,
50
- allowRedirection: true,
51
- maxSegments: 6,
52
- maxOutputBytes: 2_000_000,
53
- },
44
+ maxResults: 30,
54
45
  dynamicTools: {
55
46
  enabled: true,
56
47
  maxTools: 10,
@@ -213,14 +204,17 @@ export class ConfigManager {
213
204
  logs: {
214
205
  path: path.join(this.app.getPath(), "logs", "current.log"),
215
206
  },
207
+ loop: {
208
+ maxIterations: 90,
209
+ parallelTools: true,
210
+ maxDurationMs: 0,
211
+ },
216
212
  tools: {
217
213
  maxTokens: 30000,
218
- bash: {
219
- allowPipes: true,
220
- allowChaining: true,
221
- allowRedirection: true,
222
- maxSegments: 6,
223
- maxOutputBytes: 2_000_000,
214
+ maxResults: 30,
215
+ dynamicTools: {
216
+ enabled: true,
217
+ maxTools: 10,
224
218
  },
225
219
  },
226
220
  notify: true,
@@ -1,6 +1,114 @@
1
+ /**
2
+ * Formatting utilities for various content types including files, URLs, code blocks, and memory usage.
3
+ * Provides consistent formatting across different output formats (XML, Markdown, Bracket).
4
+ *
5
+ * @module formatting
6
+ */
7
+ /**
8
+ * Supported formatting types for content output.
9
+ */
1
10
  export type FormatType = "xml" | "markdown" | "bracket";
11
+ /**
12
+ * Formats file content with metadata in the specified format.
13
+ *
14
+ * @param file - The file path or name
15
+ * @param content - The file content to format
16
+ * @param format - The output format type
17
+ * @returns Formatted file content with metadata
18
+ * @throws {Error} When an unsupported format is provided
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * formatFile("example.ts", "const x = 1;", "markdown")
23
+ * // Returns: "## File: example.ts\n``` typescript\nconst x = 1;\n```"
24
+ * ```
25
+ */
2
26
  export declare function formatFile(file: string, content: string, format: FormatType): string;
27
+ /**
28
+ * Formats URL content with metadata in the specified format.
29
+ *
30
+ * @param siteUrl - The URL to format
31
+ * @param content - The URL content to format
32
+ * @param format - The output format type
33
+ * @returns Formatted URL content with metadata
34
+ * @throws {Error} When an unsupported format is provided
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * formatUrl("https://example.com", "<html>...</html>", "xml")
39
+ * // Returns: "<webpage>\n<url>https://example.com</url>\n<content>\n<html>...</html>\n</content>\n</webpage>"
40
+ * ```
41
+ */
3
42
  export declare function formatUrl(siteUrl: string, content: string, format: FormatType): string;
43
+ /**
44
+ * Formats content as a code block with appropriate language identifier.
45
+ *
46
+ * @param file - The file path used to determine the code block language
47
+ * @param content - The code content to format
48
+ * @returns Formatted code block with language identifier
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * formatCodeBlock("example.js", "console.log('hello');")
53
+ * // Returns: "``` javascript\nconsole.log('hello');\n```"
54
+ * ```
55
+ */
4
56
  export declare function formatCodeBlock(file: string, content: string): string;
57
+ /**
58
+ * Formats generic content blocks with a name in the specified format.
59
+ *
60
+ * @param content - The block content to format
61
+ * @param blockName - The name/title of the block
62
+ * @param format - The output format type
63
+ * @returns Formatted block content with name
64
+ * @throws {Error} When an unsupported format is provided
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * formatBlock("Some content", "Custom Block", "markdown")
69
+ * // Returns: "## Custom Block\n```\nSome content\n```"
70
+ * ```
71
+ */
5
72
  export declare function formatBlock(content: string, blockName: string, format: FormatType): string;
73
+ /**
74
+ * Capitalizes the first character of a string.
75
+ *
76
+ * @param str - The string to capitalize
77
+ * @returns The string with first character capitalized
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * capitalize("hello") // Returns: "Hello"
82
+ * ```
83
+ */
84
+ export declare const capitalize: (str: string) => string;
85
+ /**
86
+ * Formats memory usage in bytes into human-readable units (KB, MB, GB).
87
+ *
88
+ * @param bytes - Memory usage in bytes
89
+ * @returns Formatted memory usage string
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * formatMemoryUsage(1024) // Returns: "1.0 KB"
94
+ * formatMemoryUsage(1048576) // Returns: "1.0 MB"
95
+ * formatMemoryUsage(1073741824) // Returns: "1.00 GB"
96
+ * ```
97
+ */
98
+ export declare const formatMemoryUsage: (bytes: number) => string;
99
+ /**
100
+ * Formats a duration in milliseconds into a concise, human-readable string.
101
+ * Omits any time units that are zero.
102
+ *
103
+ * @param milliseconds - The duration in milliseconds
104
+ * @returns A formatted string representing the duration
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * formatDuration(3661000) // Returns: "1h 1m 1s"
109
+ * formatDuration(500) // Returns: "500ms"
110
+ * formatDuration(1500) // Returns: "1.5s"
111
+ * ```
112
+ */
113
+ export declare const formatDuration: (milliseconds: number) => string;
6
114
  //# sourceMappingURL=formatting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../source/formatting.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;AAExD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GACjB,MAAM,CAaR;AAED,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GACjB,MAAM,CAWR;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIrE;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,GACjB,MAAM,CAWR"}
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../source/formatting.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;AAExD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GACjB,MAAM,CAaR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GACjB,MAAM,CAWR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIrE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,GACjB,MAAM,CAWR;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MACG,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MASjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,KAAG,MAuCrD,CAAC"}
@@ -1,6 +1,27 @@
1
+ /**
2
+ * Formatting utilities for various content types including files, URLs, code blocks, and memory usage.
3
+ * Provides consistent formatting across different output formats (XML, Markdown, Bracket).
4
+ *
5
+ * @module formatting
6
+ */
1
7
  import path from "node:path";
2
8
  import { getCodeblockFromFilePath } from "./utils/filetype-detection.js";
3
9
  const MD_TRIPLE_QUOTE = "```";
10
+ /**
11
+ * Formats file content with metadata in the specified format.
12
+ *
13
+ * @param file - The file path or name
14
+ * @param content - The file content to format
15
+ * @param format - The output format type
16
+ * @returns Formatted file content with metadata
17
+ * @throws {Error} When an unsupported format is provided
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * formatFile("example.ts", "const x = 1;", "markdown")
22
+ * // Returns: "## File: example.ts\n``` typescript\nconst x = 1;\n```"
23
+ * ```
24
+ */
4
25
  export function formatFile(file, content, format) {
5
26
  const codeBlockName = getCodeblockFromFilePath(file) || path.extname(file).slice(1);
6
27
  switch (format) {
@@ -14,6 +35,21 @@ export function formatFile(file, content, format) {
14
35
  throw new Error(`Unsupported format: ${format}`);
15
36
  }
16
37
  }
38
+ /**
39
+ * Formats URL content with metadata in the specified format.
40
+ *
41
+ * @param siteUrl - The URL to format
42
+ * @param content - The URL content to format
43
+ * @param format - The output format type
44
+ * @returns Formatted URL content with metadata
45
+ * @throws {Error} When an unsupported format is provided
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * formatUrl("https://example.com", "<html>...</html>", "xml")
50
+ * // Returns: "<webpage>\n<url>https://example.com</url>\n<content>\n<html>...</html>\n</content>\n</webpage>"
51
+ * ```
52
+ */
17
53
  export function formatUrl(siteUrl, content, format) {
18
54
  switch (format) {
19
55
  case "xml":
@@ -26,10 +62,38 @@ export function formatUrl(siteUrl, content, format) {
26
62
  throw new Error(`Unsupported format: ${format}`);
27
63
  }
28
64
  }
65
+ /**
66
+ * Formats content as a code block with appropriate language identifier.
67
+ *
68
+ * @param file - The file path used to determine the code block language
69
+ * @param content - The code content to format
70
+ * @returns Formatted code block with language identifier
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * formatCodeBlock("example.js", "console.log('hello');")
75
+ * // Returns: "``` javascript\nconsole.log('hello');\n```"
76
+ * ```
77
+ */
29
78
  export function formatCodeBlock(file, content) {
30
79
  const codeBlockName = getCodeblockFromFilePath(file) || path.extname(file).slice(1);
31
80
  return `${MD_TRIPLE_QUOTE} ${codeBlockName}\n${content}\n${MD_TRIPLE_QUOTE}`;
32
81
  }
82
+ /**
83
+ * Formats generic content blocks with a name in the specified format.
84
+ *
85
+ * @param content - The block content to format
86
+ * @param blockName - The name/title of the block
87
+ * @param format - The output format type
88
+ * @returns Formatted block content with name
89
+ * @throws {Error} When an unsupported format is provided
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * formatBlock("Some content", "Custom Block", "markdown")
94
+ * // Returns: "## Custom Block\n```\nSome content\n```"
95
+ * ```
96
+ */
33
97
  export function formatBlock(content, blockName, format) {
34
98
  switch (format) {
35
99
  case "xml":
@@ -42,3 +106,86 @@ export function formatBlock(content, blockName, format) {
42
106
  throw new Error(`Unsupported format: ${format}`);
43
107
  }
44
108
  }
109
+ /**
110
+ * Capitalizes the first character of a string.
111
+ *
112
+ * @param str - The string to capitalize
113
+ * @returns The string with first character capitalized
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * capitalize("hello") // Returns: "Hello"
118
+ * ```
119
+ */
120
+ export const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
121
+ /**
122
+ * Formats memory usage in bytes into human-readable units (KB, MB, GB).
123
+ *
124
+ * @param bytes - Memory usage in bytes
125
+ * @returns Formatted memory usage string
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * formatMemoryUsage(1024) // Returns: "1.0 KB"
130
+ * formatMemoryUsage(1048576) // Returns: "1.0 MB"
131
+ * formatMemoryUsage(1073741824) // Returns: "1.00 GB"
132
+ * ```
133
+ */
134
+ export const formatMemoryUsage = (bytes) => {
135
+ const gb = bytes / (1024 * 1024 * 1024);
136
+ if (bytes < 1024 * 1024) {
137
+ return `${(bytes / 1024).toFixed(1)} KB`;
138
+ }
139
+ if (bytes < 1024 * 1024 * 1024) {
140
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
141
+ }
142
+ return `${gb.toFixed(2)} GB`;
143
+ };
144
+ /**
145
+ * Formats a duration in milliseconds into a concise, human-readable string.
146
+ * Omits any time units that are zero.
147
+ *
148
+ * @param milliseconds - The duration in milliseconds
149
+ * @returns A formatted string representing the duration
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * formatDuration(3661000) // Returns: "1h 1m 1s"
154
+ * formatDuration(500) // Returns: "500ms"
155
+ * formatDuration(1500) // Returns: "1.5s"
156
+ * ```
157
+ */
158
+ export const formatDuration = (milliseconds) => {
159
+ if (milliseconds <= 0) {
160
+ return "0s";
161
+ }
162
+ if (milliseconds < 1000) {
163
+ return `${Math.round(milliseconds)}ms`;
164
+ }
165
+ const totalSeconds = milliseconds / 1000;
166
+ if (totalSeconds < 60) {
167
+ return `${totalSeconds.toFixed(1)}s`;
168
+ }
169
+ const hours = Math.floor(totalSeconds / 3600);
170
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
171
+ const seconds = Math.floor(totalSeconds % 60);
172
+ const parts = [];
173
+ if (hours > 0) {
174
+ parts.push(`${hours}h`);
175
+ }
176
+ if (minutes > 0) {
177
+ parts.push(`${minutes}m`);
178
+ }
179
+ if (seconds > 0) {
180
+ parts.push(`${seconds}s`);
181
+ }
182
+ // If all parts are zero (e.g., exactly 1 hour), return the largest unit.
183
+ if (parts.length === 0) {
184
+ if (hours > 0)
185
+ return `${hours}h`;
186
+ if (minutes > 0)
187
+ return `${minutes}m`;
188
+ return `${seconds}s`;
189
+ }
190
+ return parts.join(" ");
191
+ };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  #!/usr/bin/env node
2
+ export interface WorkspaceContext {
3
+ primaryDir: string;
4
+ allowedDirs: string[];
5
+ }
6
+ export declare function createWorkspaceContext(addDirArgs?: string[]): WorkspaceContext;
2
7
  declare const flags: {
3
8
  model?: string | undefined;
4
9
  prompt?: string | undefined;
5
- oneshot: boolean;
6
10
  continue: boolean;
7
11
  resume: boolean;
8
- autoAcceptAll: boolean;
12
+ "add-dir"?: string[] | undefined;
13
+ "new-repl"?: boolean | undefined;
9
14
  help?: boolean | undefined;
10
15
  version?: boolean | undefined;
11
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAwDA,QAAA,MAAM,KAAK;;;;;;;;;CAAgB,CAAC;AAG5B;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE9C;AAED,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAyBA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAGD,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,MAAM,EAAO,GACxB,gBAAgB,CAalB;AAqCD,QAAA,MAAM,KAAK;;;;;;;;;CAAgB,CAAC;AAM5B;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE9C;AAED,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC"}