@travisennis/acai 0.0.3 → 0.0.5

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 (316) hide show
  1. package/README.md +225 -6
  2. package/dist/api/exa/index.d.ts +177 -0
  3. package/dist/api/exa/index.d.ts.map +1 -0
  4. package/dist/api/exa/index.js +439 -0
  5. package/dist/cli.d.ts +3 -2
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/commands/application-log-command.d.ts +1 -0
  8. package/dist/commands/application-log-command.d.ts.map +1 -0
  9. package/dist/commands/application-log-command.js +5 -3
  10. package/dist/commands/clear-command.d.ts +1 -0
  11. package/dist/commands/clear-command.d.ts.map +1 -0
  12. package/dist/commands/clear-command.js +2 -3
  13. package/dist/commands/compact-command.d.ts +1 -0
  14. package/dist/commands/compact-command.d.ts.map +1 -0
  15. package/dist/commands/compact-command.js +1 -1
  16. package/dist/commands/copy-command.d.ts +1 -0
  17. package/dist/commands/copy-command.d.ts.map +1 -0
  18. package/dist/commands/copy-command.js +3 -2
  19. package/dist/commands/edit-command.d.ts +1 -0
  20. package/dist/commands/edit-command.d.ts.map +1 -0
  21. package/dist/commands/edit-command.js +7 -5
  22. package/dist/commands/edit-prompt-command.d.ts +2 -1
  23. package/dist/commands/edit-prompt-command.d.ts.map +1 -0
  24. package/dist/commands/edit-prompt-command.js +15 -7
  25. package/dist/commands/exit-command.d.ts +13 -2
  26. package/dist/commands/exit-command.d.ts.map +1 -0
  27. package/dist/commands/exit-command.js +14 -2
  28. package/dist/commands/files-command.d.ts +1 -0
  29. package/dist/commands/files-command.d.ts.map +1 -0
  30. package/dist/commands/files-command.js +9 -8
  31. package/dist/commands/generate-rules-command.d.ts +1 -0
  32. package/dist/commands/generate-rules-command.d.ts.map +1 -0
  33. package/dist/commands/generate-rules-command.js +4 -3
  34. package/dist/commands/health-command.d.ts +3 -1
  35. package/dist/commands/health-command.d.ts.map +1 -0
  36. package/dist/commands/health-command.js +42 -5
  37. package/dist/commands/help-command.d.ts +1 -0
  38. package/dist/commands/help-command.d.ts.map +1 -0
  39. package/dist/commands/help-command.js +2 -3
  40. package/dist/commands/init-command.d.ts +1 -0
  41. package/dist/commands/init-command.d.ts.map +1 -0
  42. package/dist/commands/init-command.js +1 -2
  43. package/dist/commands/last-log-command.d.ts +1 -0
  44. package/dist/commands/last-log-command.d.ts.map +1 -0
  45. package/dist/commands/last-log-command.js +12 -17
  46. package/dist/commands/list-tools-command.d.ts +3 -0
  47. package/dist/commands/list-tools-command.d.ts.map +1 -0
  48. package/dist/commands/list-tools-command.js +61 -0
  49. package/dist/commands/manager.d.ts +7 -2
  50. package/dist/commands/manager.d.ts.map +1 -0
  51. package/dist/commands/manager.js +43 -6
  52. package/dist/commands/model-command.d.ts +1 -0
  53. package/dist/commands/model-command.d.ts.map +1 -0
  54. package/dist/commands/model-command.js +5 -5
  55. package/dist/commands/paste-command.d.ts +1 -0
  56. package/dist/commands/paste-command.d.ts.map +1 -0
  57. package/dist/commands/paste-command.js +6 -5
  58. package/dist/commands/prompt-command.d.ts +2 -1
  59. package/dist/commands/prompt-command.d.ts.map +1 -0
  60. package/dist/commands/prompt-command.js +62 -8
  61. package/dist/commands/reset-command.d.ts +1 -0
  62. package/dist/commands/reset-command.d.ts.map +1 -0
  63. package/dist/commands/reset-command.js +1 -1
  64. package/dist/commands/rules-command.d.ts +1 -0
  65. package/dist/commands/rules-command.d.ts.map +1 -0
  66. package/dist/commands/rules-command.js +5 -3
  67. package/dist/commands/save-command.d.ts +1 -0
  68. package/dist/commands/save-command.d.ts.map +1 -0
  69. package/dist/commands/save-command.js +1 -1
  70. package/dist/commands/shell-command.d.ts +3 -0
  71. package/dist/commands/shell-command.d.ts.map +1 -0
  72. package/dist/commands/shell-command.js +60 -0
  73. package/dist/commands/types.d.ts +9 -6
  74. package/dist/commands/types.d.ts.map +1 -0
  75. package/dist/commands/usage-command.d.ts +1 -0
  76. package/dist/commands/usage-command.d.ts.map +1 -0
  77. package/dist/commands/usage-command.js +2 -3
  78. package/dist/config.d.ts +22 -34
  79. package/dist/config.d.ts.map +1 -0
  80. package/dist/config.js +61 -15
  81. package/dist/conversation-analyzer.d.ts +2 -1
  82. package/dist/conversation-analyzer.d.ts.map +1 -0
  83. package/dist/dedent.d.ts +1 -0
  84. package/dist/dedent.d.ts.map +1 -0
  85. package/dist/execution/index.d.ts +112 -0
  86. package/dist/execution/index.d.ts.map +1 -0
  87. package/dist/execution/index.js +432 -0
  88. package/dist/formatting.d.ts +2 -13
  89. package/dist/formatting.d.ts.map +1 -0
  90. package/dist/formatting.js +5 -64
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +14 -4
  94. package/dist/logger.d.ts +1 -0
  95. package/dist/logger.d.ts.map +1 -0
  96. package/dist/mentions.d.ts +4 -0
  97. package/dist/mentions.d.ts.map +1 -0
  98. package/dist/mentions.js +42 -10
  99. package/dist/messages.d.ts +8 -20
  100. package/dist/messages.d.ts.map +1 -0
  101. package/dist/messages.js +33 -53
  102. package/dist/middleware/audit-message.d.ts +1 -0
  103. package/dist/middleware/audit-message.d.ts.map +1 -0
  104. package/dist/middleware/index.d.ts +1 -0
  105. package/dist/middleware/index.d.ts.map +1 -0
  106. package/dist/middleware/rate-limit.d.ts +1 -0
  107. package/dist/middleware/rate-limit.d.ts.map +1 -0
  108. package/dist/models/ai-config.d.ts +1 -0
  109. package/dist/models/ai-config.d.ts.map +1 -0
  110. package/dist/models/anthropic-provider.d.ts +1 -0
  111. package/dist/models/anthropic-provider.d.ts.map +1 -0
  112. package/dist/models/deepseek-provider.d.ts +1 -0
  113. package/dist/models/deepseek-provider.d.ts.map +1 -0
  114. package/dist/models/google-provider.d.ts +1 -0
  115. package/dist/models/google-provider.d.ts.map +1 -0
  116. package/dist/models/groq-provider.d.ts +20 -0
  117. package/dist/models/groq-provider.d.ts.map +1 -0
  118. package/dist/models/groq-provider.js +31 -0
  119. package/dist/models/manager.d.ts +1 -0
  120. package/dist/models/manager.d.ts.map +1 -0
  121. package/dist/models/openai-provider.d.ts +2 -1
  122. package/dist/models/openai-provider.d.ts.map +1 -0
  123. package/dist/models/openrouter-provider.d.ts +31 -22
  124. package/dist/models/openrouter-provider.d.ts.map +1 -0
  125. package/dist/models/openrouter-provider.js +115 -1
  126. package/dist/models/providers.d.ts +4 -5
  127. package/dist/models/providers.d.ts.map +1 -0
  128. package/dist/models/providers.js +7 -3
  129. package/dist/models/xai-provider.d.ts +1 -0
  130. package/dist/models/xai-provider.d.ts.map +1 -0
  131. package/dist/parsing.d.ts +2 -1
  132. package/dist/parsing.d.ts.map +1 -0
  133. package/dist/prompts/manager.d.ts +14 -2
  134. package/dist/prompts/manager.d.ts.map +1 -0
  135. package/dist/prompts.d.ts +1 -0
  136. package/dist/prompts.d.ts.map +1 -0
  137. package/dist/prompts.js +17 -11
  138. package/dist/repl/display-tool-messages.d.ts +4 -0
  139. package/dist/repl/display-tool-messages.d.ts.map +1 -0
  140. package/dist/repl/display-tool-messages.js +55 -0
  141. package/dist/repl/display-tool-use.d.ts +14 -0
  142. package/dist/repl/display-tool-use.d.ts.map +1 -0
  143. package/dist/repl/display-tool-use.js +63 -0
  144. package/dist/repl/get-prompt-header.d.ts +8 -0
  145. package/dist/repl/get-prompt-header.d.ts.map +1 -0
  146. package/dist/repl/get-prompt-header.js +38 -0
  147. package/dist/repl/tool-call-repair.d.ts +4 -0
  148. package/dist/repl/tool-call-repair.d.ts.map +1 -0
  149. package/dist/repl/tool-call-repair.js +50 -0
  150. package/dist/repl-prompt.d.ts +1 -0
  151. package/dist/repl-prompt.d.ts.map +1 -0
  152. package/dist/repl.d.ts +8 -4
  153. package/dist/repl.d.ts.map +1 -0
  154. package/dist/repl.js +108 -252
  155. package/dist/terminal/ansi-styles.d.ts +77 -0
  156. package/dist/terminal/ansi-styles.d.ts.map +1 -0
  157. package/dist/terminal/ansi-styles.js +215 -0
  158. package/dist/terminal/checkbox-prompt.d.ts +36 -0
  159. package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
  160. package/dist/terminal/checkbox-prompt.js +362 -0
  161. package/dist/terminal/default-theme.d.ts +6 -0
  162. package/dist/terminal/default-theme.d.ts.map +1 -0
  163. package/dist/terminal/default-theme.js +182 -0
  164. package/dist/terminal/east-asian-width.d.ts +8 -0
  165. package/dist/terminal/east-asian-width.d.ts.map +1 -0
  166. package/dist/terminal/east-asian-width.js +409 -0
  167. package/dist/terminal/editor-prompt.d.ts +10 -0
  168. package/dist/terminal/editor-prompt.d.ts.map +1 -0
  169. package/dist/terminal/editor-prompt.js +61 -0
  170. package/dist/terminal/errors.d.ts +19 -0
  171. package/dist/terminal/errors.d.ts.map +1 -0
  172. package/dist/terminal/errors.js +37 -0
  173. package/dist/terminal/formatting.d.ts +1 -11
  174. package/dist/terminal/formatting.d.ts.map +1 -0
  175. package/dist/terminal/formatting.js +4 -20
  176. package/dist/terminal/highlight/index.d.ts +53 -0
  177. package/dist/terminal/highlight/index.d.ts.map +1 -0
  178. package/dist/terminal/highlight/index.js +90 -0
  179. package/dist/terminal/highlight/theme.d.ts +233 -0
  180. package/dist/terminal/highlight/theme.d.ts.map +1 -0
  181. package/dist/terminal/highlight/theme.js +83 -0
  182. package/dist/terminal/index.d.ts +16 -9
  183. package/dist/terminal/index.d.ts.map +1 -0
  184. package/dist/terminal/index.js +42 -126
  185. package/dist/terminal/input-prompt.d.ts +16 -0
  186. package/dist/terminal/input-prompt.d.ts.map +1 -0
  187. package/dist/terminal/input-prompt.js +181 -0
  188. package/dist/terminal/markdown-utils.d.ts +1 -0
  189. package/dist/terminal/markdown-utils.d.ts.map +1 -0
  190. package/dist/terminal/markdown.d.ts +1 -0
  191. package/dist/terminal/markdown.d.ts.map +1 -0
  192. package/dist/terminal/markdown.js +17 -12
  193. package/dist/terminal/search-prompt.d.ts +20 -0
  194. package/dist/terminal/search-prompt.d.ts.map +1 -0
  195. package/dist/terminal/search-prompt.js +279 -0
  196. package/dist/terminal/select-prompt.d.ts +26 -0
  197. package/dist/terminal/select-prompt.d.ts.map +1 -0
  198. package/dist/terminal/select-prompt.js +298 -0
  199. package/dist/terminal/string-width.d.ts +7 -0
  200. package/dist/terminal/string-width.d.ts.map +1 -0
  201. package/dist/terminal/string-width.js +61 -0
  202. package/dist/terminal/strip-ansi.d.ts +2 -0
  203. package/dist/terminal/strip-ansi.d.ts.map +1 -0
  204. package/dist/terminal/strip-ansi.js +20 -0
  205. package/dist/terminal/style.d.ts +191 -0
  206. package/dist/terminal/style.d.ts.map +1 -0
  207. package/dist/terminal/style.js +259 -0
  208. package/dist/terminal/supports-color.d.ts +1 -0
  209. package/dist/terminal/supports-color.d.ts.map +1 -0
  210. package/dist/terminal/supports-hyperlinks.d.ts +1 -3
  211. package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
  212. package/dist/terminal/supports-hyperlinks.js +1 -1
  213. package/dist/terminal/types.d.ts +1 -37
  214. package/dist/terminal/types.d.ts.map +1 -0
  215. package/dist/terminal/wrap-ansi.d.ts +8 -0
  216. package/dist/terminal/wrap-ansi.d.ts.map +1 -0
  217. package/dist/terminal/wrap-ansi.js +190 -0
  218. package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
  219. package/dist/tokens/counter.d.ts.map +1 -0
  220. package/dist/{token-utils.js → tokens/counter.js} +1 -1
  221. package/dist/tokens/manage-output.d.ts +34 -0
  222. package/dist/tokens/manage-output.d.ts.map +1 -0
  223. package/dist/tokens/manage-output.js +44 -0
  224. package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
  225. package/dist/tokens/tracker.d.ts.map +1 -0
  226. package/dist/tool-executor.d.ts +28 -0
  227. package/dist/tool-executor.d.ts.map +1 -0
  228. package/dist/tool-executor.js +74 -0
  229. package/dist/tools/agent.d.ts +3 -2
  230. package/dist/tools/agent.d.ts.map +1 -0
  231. package/dist/tools/agent.js +7 -4
  232. package/dist/tools/bash-utils.d.ts +7 -0
  233. package/dist/tools/bash-utils.d.ts.map +1 -0
  234. package/dist/tools/bash-utils.js +212 -0
  235. package/dist/tools/bash.d.ts +9 -7
  236. package/dist/tools/bash.d.ts.map +1 -0
  237. package/dist/tools/bash.js +95 -212
  238. package/dist/tools/code-interpreter.d.ts +1 -0
  239. package/dist/tools/code-interpreter.d.ts.map +1 -0
  240. package/dist/tools/code-interpreter.js +33 -8
  241. package/dist/tools/delete-file.d.ts +5 -3
  242. package/dist/tools/delete-file.d.ts.map +1 -0
  243. package/dist/tools/delete-file.js +47 -33
  244. package/dist/tools/directory-tree.d.ts +10 -1
  245. package/dist/tools/directory-tree.d.ts.map +1 -0
  246. package/dist/tools/directory-tree.js +91 -8
  247. package/dist/tools/dynamic-tool-loader.d.ts +12 -0
  248. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
  249. package/dist/tools/dynamic-tool-loader.js +280 -0
  250. package/dist/tools/dynamic-tool-parser.d.ts +20 -0
  251. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
  252. package/dist/tools/dynamic-tool-parser.js +21 -0
  253. package/dist/tools/edit-file.d.ts +10 -2
  254. package/dist/tools/edit-file.d.ts.map +1 -0
  255. package/dist/tools/edit-file.js +117 -40
  256. package/dist/tools/file-editing-utils.d.ts +2 -0
  257. package/dist/tools/file-editing-utils.d.ts.map +1 -0
  258. package/dist/tools/file-editing-utils.js +135 -0
  259. package/dist/tools/filesystem-utils.d.ts +6 -21
  260. package/dist/tools/filesystem-utils.d.ts.map +1 -0
  261. package/dist/tools/filesystem-utils.js +96 -148
  262. package/dist/tools/git-utils.d.ts +1 -0
  263. package/dist/tools/git-utils.d.ts.map +1 -0
  264. package/dist/tools/grep.d.ts +5 -3
  265. package/dist/tools/grep.d.ts.map +1 -0
  266. package/dist/tools/grep.js +67 -27
  267. package/dist/tools/index.d.ts +10 -14
  268. package/dist/tools/index.d.ts.map +1 -0
  269. package/dist/tools/index.js +33 -22
  270. package/dist/tools/move-file.d.ts +1 -0
  271. package/dist/tools/move-file.d.ts.map +1 -0
  272. package/dist/tools/move-file.js +12 -5
  273. package/dist/tools/read-file.d.ts +2 -1
  274. package/dist/tools/read-file.d.ts.map +1 -0
  275. package/dist/tools/read-file.js +13 -6
  276. package/dist/tools/read-multiple-files.d.ts +2 -1
  277. package/dist/tools/read-multiple-files.d.ts.map +1 -0
  278. package/dist/tools/read-multiple-files.js +90 -9
  279. package/dist/tools/save-file.d.ts +5 -3
  280. package/dist/tools/save-file.d.ts.map +1 -0
  281. package/dist/tools/save-file.js +64 -36
  282. package/dist/tools/think.d.ts +1 -0
  283. package/dist/tools/think.d.ts.map +1 -0
  284. package/dist/tools/think.js +5 -1
  285. package/dist/tools/types.d.ts +14 -1
  286. package/dist/tools/types.d.ts.map +1 -0
  287. package/dist/tools/web-fetch.d.ts +4 -2
  288. package/dist/tools/web-fetch.d.ts.map +1 -0
  289. package/dist/tools/web-fetch.js +2 -2
  290. package/dist/tools/web-search.d.ts +2 -1
  291. package/dist/tools/web-search.d.ts.map +1 -0
  292. package/dist/tools/web-search.js +46 -11
  293. package/dist/utils/filesystem.d.ts +23 -0
  294. package/dist/utils/filesystem.d.ts.map +1 -0
  295. package/dist/utils/filesystem.js +140 -0
  296. package/dist/utils/filetype-detection.d.ts +3 -0
  297. package/dist/utils/filetype-detection.d.ts.map +1 -0
  298. package/dist/utils/filetype-detection.js +112 -0
  299. package/dist/utils/glob.d.ts +52 -0
  300. package/dist/utils/glob.d.ts.map +1 -0
  301. package/dist/utils/glob.js +376 -0
  302. package/dist/utils/ignore.d.ts +104 -0
  303. package/dist/utils/ignore.d.ts.map +1 -0
  304. package/dist/utils/ignore.js +649 -0
  305. package/dist/utils/process.d.ts +10 -1
  306. package/dist/utils/process.d.ts.map +1 -0
  307. package/dist/utils/process.js +104 -5
  308. package/dist/utils/zod-utils.d.ts +4 -0
  309. package/dist/utils/zod-utils.d.ts.map +1 -0
  310. package/dist/utils/zod-utils.js +7 -0
  311. package/dist/version.d.ts +1 -0
  312. package/dist/version.d.ts.map +1 -0
  313. package/package.json +32 -30
  314. package/dist/tools/command-validation.d.ts +0 -12
  315. package/dist/tools/command-validation.js +0 -113
  316. /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
@@ -4,14 +4,17 @@
4
4
  * Provides a user interface for interacting with Claude Code in the terminal.
5
5
  * Handles input/output, formatting, and display.
6
6
  */
7
- import chalk from "chalk";
8
7
  import Table from "cli-table3";
9
- import ora from "ora";
10
- import wrapAnsi from "wrap-ansi";
11
8
  import { logger } from "../logger.js";
12
9
  import { getPackageVersion } from "../version.js";
13
- import { clearTerminal, getTerminalSize, setTerminalTitle, stripAnsi, link as terminalLink, } from "./formatting.js";
10
+ import { clearTerminal, getTerminalSize, setTerminalTitle, link as terminalLink, } from "./formatting.js";
14
11
  import { applyMarkdown } from "./markdown.js";
12
+ import stripAnsi from "./strip-ansi.js";
13
+ import style from "./style.js";
14
+ import wrapAnsi from "./wrap-ansi.js";
15
+ export function getShell() {
16
+ return process.env["ZSH_VERSION"] ? "zsh" : process.env["SHELL"] || "bash";
17
+ }
15
18
  /**
16
19
  * Initialize the terminal interface
17
20
  */
@@ -42,7 +45,6 @@ export function initTerminal(config = {}) {
42
45
  */
43
46
  export class Terminal {
44
47
  config;
45
- activeSpinners = new Map();
46
48
  terminalWidth;
47
49
  terminalHeight;
48
50
  isInteractive;
@@ -93,17 +95,17 @@ export class Terminal {
93
95
  displayWelcome() {
94
96
  this.clear();
95
97
  const version = getPackageVersion();
96
- this.writeln(chalk.magenta(this.getLogo()));
98
+ this.writeln(style.magenta(this.getLogo()));
97
99
  this.lineBreak();
98
- this.writeln(chalk.magenta("Greetings! I am acai."));
99
- this.writeln(chalk.gray(` Version ${version}`));
100
+ this.writeln(style.magenta("Greetings! I am acai."));
101
+ this.writeln(style.gray(` Version ${version}`));
100
102
  this.lineBreak();
101
- this.writeln(chalk.white(` Type ${chalk.cyan("/help")} to see available commands.`));
102
- this.writeln(chalk.white(" You can ask acai to explain code, fix issues, or perform tasks."));
103
- this.writeln(chalk.white(` Example: "${chalk.italic("Please analyze this codebase and explain its structure.")}"`));
104
- this.writeln(chalk.dim(" Use Ctrl+C to interrupt acai and exit."));
103
+ this.writeln(style.white(` Type ${style.cyan("/help")} to see available commands.`));
104
+ this.writeln(style.white(" You can ask acai to explain code, fix issues, or perform tasks."));
105
+ this.writeln(style.white(` Example: "${style.italic("Please analyze this codebase and explain its structure.")}"`));
106
+ this.writeln(style.dim(" Use Ctrl+C to interrupt acai and exit."));
105
107
  this.lineBreak();
106
- this.writeln(chalk.yellow(`The current working directory is ${process.cwd()}`));
108
+ this.writeln(style.yellow(`The current working directory is ${process.cwd()}`));
107
109
  this.lineBreak();
108
110
  }
109
111
  /**
@@ -114,6 +116,20 @@ export class Terminal {
114
116
  clearTerminal();
115
117
  }
116
118
  }
119
+ /**
120
+ * Start progress indicator in terminal
121
+ * Sends terminal escape sequence to show progress animation
122
+ */
123
+ startProgress() {
124
+ process.stdout.write("\u001b]9;4;3;0\u0007");
125
+ }
126
+ /**
127
+ * Stop progress indicator in terminal
128
+ * Sends terminal escape sequence to hide progress animation
129
+ */
130
+ stopProgress() {
131
+ process.stdout.write("\u001b]9;4;0;0\u0007");
132
+ }
117
133
  /**
118
134
  * Display formatted content
119
135
  */
@@ -125,7 +141,7 @@ export class Terminal {
125
141
  */
126
142
  emphasize(message) {
127
143
  if (this.config.useColors) {
128
- this.writeln(chalk.cyan.bold(message));
144
+ this.writeln(style.cyan.bold(message));
129
145
  }
130
146
  else {
131
147
  this.writeln(message.toUpperCase());
@@ -136,7 +152,7 @@ export class Terminal {
136
152
  */
137
153
  info(message) {
138
154
  if (this.config.useColors) {
139
- this.writeln(chalk.blue(`ℹ ${message}`));
155
+ this.writeln(style.blue(`ℹ ${message}`));
140
156
  }
141
157
  else {
142
158
  this.writeln(`INFO: ${message}`);
@@ -147,7 +163,7 @@ export class Terminal {
147
163
  */
148
164
  success(message) {
149
165
  if (this.config.useColors) {
150
- this.writeln(chalk.green(`✓ ${message}`));
166
+ this.writeln(style.green(`✓ ${message}`));
151
167
  }
152
168
  else {
153
169
  this.writeln(`SUCCESS: ${message}`);
@@ -158,7 +174,7 @@ export class Terminal {
158
174
  */
159
175
  warn(message) {
160
176
  if (this.config.useColors) {
161
- this.writeln(chalk.yellow(`⚠ ${message}`));
177
+ this.writeln(style.yellow(`⚠ ${message}`));
162
178
  }
163
179
  else {
164
180
  this.writeln(`WARNING: ${message}`);
@@ -169,7 +185,7 @@ export class Terminal {
169
185
  */
170
186
  error(message) {
171
187
  if (this.config.useColors) {
172
- this.writeln(chalk.red(`✗ ${message}`));
188
+ this.writeln(style.red(`✗ ${message}`));
173
189
  }
174
190
  else {
175
191
  this.writeln(`ERROR: ${message}`);
@@ -205,10 +221,10 @@ export class Terminal {
205
221
  lineBreak() {
206
222
  this.writeln("");
207
223
  }
208
- header(header, chalkFn = chalk.green) {
224
+ header(header, styleFn = style.cyan) {
209
225
  const cols = this.terminalWidth > 0 ? this.terminalWidth : 80;
210
226
  const width = Math.max(0, cols - header.length - 4);
211
- this.writeln(chalkFn(`\n── ${header} ${"─".repeat(width)} `));
227
+ this.writeln(`${style.gray("\n── ")}${styleFn(header)} ${style.gray("─".repeat(width))}`);
212
228
  }
213
229
  async box(header, content) {
214
230
  const cols = this.terminalWidth > 0 ? this.terminalWidth : 80;
@@ -238,15 +254,15 @@ export class Terminal {
238
254
  // Write the box
239
255
  this.writeln(`${topBorder}\n${contentLines}\n${bottomBorder}`);
240
256
  }
241
- hr(chalkFn = chalk.gray) {
257
+ hr(styleFn = style.gray) {
242
258
  const cols = this.terminalWidth > 0 ? this.terminalWidth : 80;
243
- this.writeln(chalkFn(`${"─".repeat(Math.max(1, cols - 1))} `));
259
+ this.writeln(styleFn(`${"─".repeat(Math.max(1, cols - 1))} `));
244
260
  }
245
261
  /**
246
262
  * Create a clickable link in the terminal if supported
247
263
  */
248
264
  link(text, url) {
249
- return chalk.underline.blue(terminalLink(text, url));
265
+ return style.underline.blue(terminalLink(text, url));
250
266
  }
251
267
  /**
252
268
  * Display a table of data
@@ -310,106 +326,6 @@ export class Terminal {
310
326
  table.push(...normalizedData);
311
327
  this.writeln(table.toString());
312
328
  }
313
- /**
314
- * Create a spinner for showing progress
315
- */
316
- spinner(text, id = "default") {
317
- // Clean up existing spinner with the same ID
318
- if (this.activeSpinners.has(id)) {
319
- this.activeSpinners.get(id)?.stop();
320
- this.activeSpinners.delete(id);
321
- }
322
- // Create spinner only if progress indicators are enabled and terminal is interactive
323
- if (this.config.showProgressIndicators && this.isInteractive) {
324
- const spinner = ora({
325
- text,
326
- spinner: "dots",
327
- color: "cyan",
328
- }).start();
329
- const spinnerInstance = {
330
- id,
331
- update: (newText) => {
332
- spinner.text = newText;
333
- return spinnerInstance;
334
- },
335
- succeed: (text) => {
336
- spinner.succeed(text);
337
- this.activeSpinners.delete(id);
338
- return spinnerInstance;
339
- },
340
- fail: (text) => {
341
- spinner.fail(text);
342
- this.activeSpinners.delete(id);
343
- return spinnerInstance;
344
- },
345
- warn: (text) => {
346
- spinner.warn(text);
347
- this.activeSpinners.delete(id);
348
- return spinnerInstance;
349
- },
350
- info: (text) => {
351
- spinner.info(text);
352
- this.activeSpinners.delete(id);
353
- return spinnerInstance;
354
- },
355
- clear: () => {
356
- spinner.clear();
357
- this.activeSpinners.delete(id);
358
- return spinnerInstance;
359
- },
360
- stop: () => {
361
- spinner.stop();
362
- this.activeSpinners.delete(id);
363
- return spinnerInstance;
364
- },
365
- };
366
- this.activeSpinners.set(id, spinnerInstance);
367
- return spinnerInstance;
368
- }
369
- // Fallback for non-interactive terminals or when progress indicators are disabled
370
- console.info(text);
371
- // Return a dummy spinner
372
- const dummySpinner = {
373
- id,
374
- update: (newText) => {
375
- if (newText !== text) {
376
- console.info(newText);
377
- }
378
- return dummySpinner;
379
- },
380
- succeed: (text) => {
381
- if (text) {
382
- this.success(text);
383
- }
384
- return dummySpinner;
385
- },
386
- fail: (text) => {
387
- if (text) {
388
- this.error(text);
389
- }
390
- return dummySpinner;
391
- },
392
- warn: (text) => {
393
- if (text) {
394
- this.warn(text);
395
- }
396
- return dummySpinner;
397
- },
398
- info: (text) => {
399
- if (text) {
400
- this.info(text);
401
- }
402
- return dummySpinner;
403
- },
404
- clear: () => {
405
- return dummySpinner;
406
- },
407
- stop: () => {
408
- return dummySpinner;
409
- },
410
- };
411
- return dummySpinner;
412
- }
413
329
  /**
414
330
  * Displays a horizontal progress bar in the console.
415
331
  * @param current The current value.
@@ -439,9 +355,9 @@ export class Terminal {
439
355
  const filledWidth = Math.max(0, Math.min(progressBarMaxWidth, Math.floor(percentage * progressBarMaxWidth)));
440
356
  const emptyWidth = Math.max(0, progressBarMaxWidth - filledWidth);
441
357
  const a = filledWidth / progressBarMaxWidth > 0.5
442
- ? chalk.red("─")
443
- : chalk.yellow("─"); //"█"
444
- const b = chalk.gray("─"); // "░"
358
+ ? style.red("─")
359
+ : style.yellow("─"); //"█"
360
+ const b = style.gray("─"); // "░"
445
361
  const filledBar = a.repeat(filledWidth);
446
362
  const emptyBar = b.repeat(emptyWidth);
447
363
  // Use \r to move cursor to the beginning of the line for updates
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Standalone input prompt (inquirer-like)
4
+ * - TypeScript version
5
+ */
6
+ export interface InputOptions {
7
+ message?: string;
8
+ default?: string;
9
+ validate?: (input: string) => true | string;
10
+ required?: boolean;
11
+ minLength?: number;
12
+ maxLength?: number;
13
+ signal?: AbortSignal;
14
+ }
15
+ export declare function input({ message, default: defaultValue, validate, required, minLength, maxLength, signal, }?: InputOptions): Promise<string>;
16
+ //# sourceMappingURL=input-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-prompt.d.ts","sourceRoot":"","sources":["../../source/terminal/input-prompt.ts"],"names":[],"mappings":";AACA;;;GAGG;AAWH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AA4HD,wBAAsB,KAAK,CAAC,EAC1B,OAAuB,EACvB,OAAO,EAAE,YAAY,EACrB,QAAQ,EACR,QAAgB,EAChB,SAAS,EACT,SAAS,EACT,MAAM,GACP,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0DrC"}
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Standalone input prompt (inquirer-like)
4
+ * - TypeScript version
5
+ */
6
+ import * as readline from "node:readline";
7
+ import { isAbortError, isCancelError, PromptAbortError, PromptCancelError, } from "./errors.js";
8
+ import style from "./style.js";
9
+ /**
10
+ * Enhanced input validation with built-in and custom validation
11
+ */
12
+ function validateInput(input, options) {
13
+ const { validate, required, minLength, maxLength, default: defaultValue, } = options;
14
+ // Handle empty input
15
+ const trimmedInput = input.trim();
16
+ if (!trimmedInput && !defaultValue) {
17
+ if (required) {
18
+ return "Input is required";
19
+ }
20
+ return true; // Allow empty if not required
21
+ }
22
+ // Use default value if input is empty
23
+ const finalInput = trimmedInput || defaultValue || "";
24
+ // Length validations
25
+ if (minLength && finalInput.length < minLength) {
26
+ return `Input must be at least ${minLength} characters`;
27
+ }
28
+ if (maxLength && finalInput.length > maxLength) {
29
+ return `Input must be at most ${maxLength} characters`;
30
+ }
31
+ // Custom validation
32
+ if (validate) {
33
+ return validate(finalInput);
34
+ }
35
+ return true;
36
+ }
37
+ /**
38
+ * Create a managed readline interface with proper cleanup
39
+ */
40
+ function createReadlineInterface() {
41
+ const rl = readline.createInterface({
42
+ input: process.stdin,
43
+ output: process.stdout,
44
+ terminal: true,
45
+ });
46
+ let cleanedUp = false;
47
+ const cleanup = () => {
48
+ if (cleanedUp)
49
+ return;
50
+ cleanedUp = true;
51
+ rl.close();
52
+ };
53
+ return { rl, cleanup };
54
+ }
55
+ /**
56
+ * Non-blocking question wrapper using Promise
57
+ */
58
+ function askQuestion(rl, prompt) {
59
+ return new Promise((resolve) => {
60
+ rl.question(prompt, resolve);
61
+ });
62
+ }
63
+ /**
64
+ * Main prompt function with retry logic for validation
65
+ */
66
+ async function promptWithRetry(rl, prompt, options) {
67
+ const { validate, required, minLength, maxLength, default: defaultValue, } = options;
68
+ while (true) {
69
+ try {
70
+ const answer = await askQuestion(rl, prompt);
71
+ const validationResult = validateInput(answer, {
72
+ validate,
73
+ required,
74
+ minLength,
75
+ maxLength,
76
+ default: defaultValue,
77
+ });
78
+ if (validationResult === true) {
79
+ // Determine final answer
80
+ let finalAnswer = answer.trim();
81
+ if (!finalAnswer && defaultValue !== undefined) {
82
+ finalAnswer = defaultValue;
83
+ }
84
+ return finalAnswer;
85
+ }
86
+ // Show validation error and retry
87
+ console.log(style.red(validationResult));
88
+ }
89
+ catch (error) {
90
+ if (isAbortError(error) || isCancelError(error)) {
91
+ throw error;
92
+ }
93
+ // Handle other errors appropriately
94
+ throw new Error("Failed to read input", { cause: error });
95
+ }
96
+ }
97
+ }
98
+ export async function input({ message = "Enter value", default: defaultValue, validate, required = false, minLength, maxLength, signal, } = {}) {
99
+ if (!process.stdin.isTTY) {
100
+ throw new Error("TTY required");
101
+ }
102
+ const { rl, cleanup } = createReadlineInterface();
103
+ let cleanupCalled = false;
104
+ const ensureCleanup = () => {
105
+ if (!cleanupCalled) {
106
+ cleanupCalled = true;
107
+ cleanup();
108
+ }
109
+ };
110
+ try {
111
+ return await new Promise((resolve, reject) => {
112
+ const prompt = defaultValue
113
+ ? `${message} (${defaultValue}): `
114
+ : `${message}: `;
115
+ // Handle abort signal
116
+ if (signal) {
117
+ signal.addEventListener("abort", () => {
118
+ ensureCleanup();
119
+ reject(new PromptAbortError());
120
+ });
121
+ }
122
+ // Handle SIGINT (Ctrl+C)
123
+ rl.on("SIGINT", () => {
124
+ ensureCleanup();
125
+ reject(new PromptCancelError());
126
+ });
127
+ // Start the prompt process
128
+ promptWithRetry(rl, prompt, {
129
+ message,
130
+ default: defaultValue,
131
+ validate,
132
+ required,
133
+ minLength,
134
+ maxLength,
135
+ signal,
136
+ })
137
+ .then((result) => {
138
+ ensureCleanup();
139
+ resolve(result);
140
+ })
141
+ .catch((error) => {
142
+ ensureCleanup();
143
+ reject(error);
144
+ });
145
+ });
146
+ }
147
+ catch (error) {
148
+ ensureCleanup();
149
+ throw error;
150
+ }
151
+ }
152
+ // Quick test when run directly
153
+ if (import.meta.url === `file://${process.argv[1]}`) {
154
+ (async () => {
155
+ try {
156
+ const name = await input({
157
+ message: "What is your name",
158
+ default: "Anonymous",
159
+ validate: (txt) => (txt.length < 2 ? "Name too short" : true),
160
+ required: true,
161
+ minLength: 2,
162
+ });
163
+ console.log("Hello,", name);
164
+ process.exit(0);
165
+ }
166
+ catch (err) {
167
+ if (isCancelError(err)) {
168
+ console.error("Cancelled");
169
+ process.exit(2);
170
+ }
171
+ else if (isAbortError(err)) {
172
+ console.error("Aborted");
173
+ process.exit(3);
174
+ }
175
+ else {
176
+ console.error(err);
177
+ process.exit(1);
178
+ }
179
+ }
180
+ })();
181
+ }
@@ -1,2 +1,3 @@
1
1
  export declare function isMarkdown(input: string): boolean;
2
2
  export declare function getListNumber(listDepth: number, orderedListNumber: number): string;
3
+ //# sourceMappingURL=markdown-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-utils.d.ts","sourceRoot":"","sources":["../../source/terminal/markdown-utils.ts"],"names":[],"mappings":"AAWA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAejD;AA+CD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAYR"}
@@ -1 +1,2 @@
1
1
  export declare function applyMarkdown(content: string): string;
2
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../source/terminal/markdown.ts"],"names":[],"mappings":"AAcA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMrD"}
@@ -1,11 +1,12 @@
1
1
  import { EOL } from "node:os";
2
- import chalk from "chalk";
3
- import { highlight, supportsLanguage } from "cli-highlight";
4
2
  import Table from "cli-table3";
5
3
  import { marked } from "marked";
6
4
  import { logger } from "../logger.js";
5
+ import { DEFAULT_THEME } from "./default-theme.js";
7
6
  import { link as terminalLink } from "./formatting.js";
7
+ import { highlight, supportsLanguage } from "./highlight/index.js";
8
8
  import { getListNumber } from "./markdown-utils.js";
9
+ import style from "./style.js";
9
10
  function logError(msg) {
10
11
  logger.error(msg);
11
12
  }
@@ -19,36 +20,40 @@ export function applyMarkdown(content) {
19
20
  function format(token, listDepth = 0, orderedListNumber = null, parent = null) {
20
21
  switch (token.type) {
21
22
  case "blockquote":
22
- return chalk.dim.italic((token.tokens ?? [])
23
+ return style.dim.italic((token.tokens ?? [])
23
24
  .map((_) => format(_))
24
25
  .map((l) => ` ${l}`)
25
26
  .join(""));
26
27
  case "code": {
27
28
  if (token.lang && supportsLanguage(token.lang)) {
28
- return highlight(token.text, { language: token.lang }) + EOL;
29
+ return (highlight(token.text, {
30
+ language: token.lang,
31
+ theme: DEFAULT_THEME,
32
+ }) + EOL);
29
33
  }
30
34
  logError(`Language not supported while highlighting code, falling back to markdown: ${token.lang}`);
31
- return highlight(token.text, { language: "markdown" }) + EOL;
35
+ return (highlight(token.text, { language: "markdown", theme: DEFAULT_THEME }) +
36
+ EOL);
32
37
  }
33
38
  case "codespan":
34
39
  // inline code
35
- return chalk.blue(token.text);
40
+ return style.blue(token.text);
36
41
  case "em":
37
- return chalk.italic((token.tokens ?? []).map((_) => format(_)).join(""));
42
+ return style.italic((token.tokens ?? []).map((_) => format(_)).join(""));
38
43
  case "strong":
39
- return chalk.bold((token.tokens ?? []).map((_) => format(_)).join(""));
44
+ return style.bold((token.tokens ?? []).map((_) => format(_)).join(""));
40
45
  case "heading":
41
46
  switch (token.depth) {
42
47
  case 1: // h1
43
- return (chalk.bold.italic.underline((token.tokens ?? []).map((_) => format(_)).join("")) +
48
+ return (style.bold.italic.underline((token.tokens ?? []).map((_) => format(_)).join("")) +
44
49
  EOL +
45
50
  EOL);
46
51
  case 2: // h2
47
- return (chalk.bold((token.tokens ?? []).map((_) => format(_)).join("")) +
52
+ return (style.bold((token.tokens ?? []).map((_) => format(_)).join("")) +
48
53
  EOL +
49
54
  EOL);
50
55
  default: // h3+
51
- return (chalk.bold.dim((token.tokens ?? []).map((_) => format(_)).join("")) +
56
+ return (style.bold.dim((token.tokens ?? []).map((_) => format(_)).join("")) +
52
57
  EOL +
53
58
  EOL);
54
59
  }
@@ -102,7 +107,7 @@ function format(token, listDepth = 0, orderedListNumber = null, parent = null) {
102
107
  return `${table.toString()}\n`;
103
108
  }
104
109
  case "del": {
105
- return chalk.strikethrough(token.text);
110
+ return style.strikethrough(token.text);
106
111
  }
107
112
  default:
108
113
  return "";
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Standalone search prompt (inquirer-like)
4
+ * - TypeScript version
5
+ */
6
+ interface ChoiceObject<T = unknown> {
7
+ name: string;
8
+ value: T;
9
+ disabled?: boolean;
10
+ }
11
+ export type Choice<T = unknown> = string | ChoiceObject<T>;
12
+ export interface SearchOptions<T = unknown> {
13
+ message?: string;
14
+ source: (input: string) => Promise<Choice<T>[]>;
15
+ pageSize?: number;
16
+ signal?: AbortSignal;
17
+ }
18
+ export declare function search<T = unknown>({ message, source, pageSize, signal, }: SearchOptions<T>): Promise<T>;
19
+ export {};
20
+ //# sourceMappingURL=search-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-prompt.d.ts","sourceRoot":"","sources":["../../source/terminal/search-prompt.ts"],"names":[],"mappings":";AACA;;;GAGG;AAQH,UAAU,YAAY,CAAC,CAAC,GAAG,OAAO;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;AAQ3D,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AA8CD,wBAAsB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,EACxC,OAAkB,EAClB,MAAM,EACN,QAAY,EACZ,MAAM,GACP,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsO/B"}