@qwen-code/qwen-code 0.0.1 → 0.0.2

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 (424) hide show
  1. package/README.md +219 -41
  2. package/dist/.last_build +0 -0
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.js +20 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/package.json +79 -0
  7. package/dist/src/config/auth.d.ts +9 -0
  8. package/dist/src/config/auth.js +48 -0
  9. package/dist/src/config/auth.js.map +1 -0
  10. package/dist/src/config/config.d.ts +39 -0
  11. package/dist/src/config/config.js +318 -0
  12. package/dist/src/config/config.js.map +1 -0
  13. package/dist/src/config/extension.d.ts +21 -0
  14. package/dist/src/config/extension.js +109 -0
  15. package/dist/src/config/extension.js.map +1 -0
  16. package/dist/src/config/sandboxConfig.d.ts +13 -0
  17. package/dist/src/config/sandboxConfig.js +75 -0
  18. package/dist/src/config/sandboxConfig.js.map +1 -0
  19. package/dist/src/config/settings.d.ts +95 -0
  20. package/dist/src/config/settings.js +263 -0
  21. package/dist/src/config/settings.js.map +1 -0
  22. package/dist/src/gemini.d.ts +6 -0
  23. package/dist/src/gemini.js +256 -0
  24. package/dist/src/gemini.js.map +1 -0
  25. package/dist/src/generated/git-commit.d.ts +6 -0
  26. package/dist/src/generated/git-commit.js +9 -0
  27. package/dist/src/generated/git-commit.js.map +1 -0
  28. package/dist/src/nonInteractiveCli.d.ts +7 -0
  29. package/dist/src/nonInteractiveCli.js +191 -0
  30. package/dist/src/nonInteractiveCli.js.map +1 -0
  31. package/dist/src/services/CommandService.d.ts +13 -0
  32. package/dist/src/services/CommandService.js +38 -0
  33. package/dist/src/services/CommandService.js.map +1 -0
  34. package/dist/src/ui/App.d.ts +15 -0
  35. package/dist/src/ui/App.js +499 -0
  36. package/dist/src/ui/App.js.map +1 -0
  37. package/dist/src/ui/colors.d.ts +7 -0
  38. package/dist/src/ui/colors.js +48 -0
  39. package/dist/src/ui/colors.js.map +1 -0
  40. package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
  41. package/dist/src/ui/commands/aboutCommand.js +37 -0
  42. package/dist/src/ui/commands/aboutCommand.js.map +1 -0
  43. package/dist/src/ui/commands/authCommand.d.ts +7 -0
  44. package/dist/src/ui/commands/authCommand.js +14 -0
  45. package/dist/src/ui/commands/authCommand.js.map +1 -0
  46. package/dist/src/ui/commands/clearCommand.d.ts +7 -0
  47. package/dist/src/ui/commands/clearCommand.js +16 -0
  48. package/dist/src/ui/commands/clearCommand.js.map +1 -0
  49. package/dist/src/ui/commands/helpCommand.d.ts +7 -0
  50. package/dist/src/ui/commands/helpCommand.js +18 -0
  51. package/dist/src/ui/commands/helpCommand.js.map +1 -0
  52. package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
  53. package/dist/src/ui/commands/memoryCommand.js +81 -0
  54. package/dist/src/ui/commands/memoryCommand.js.map +1 -0
  55. package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
  56. package/dist/src/ui/commands/privacyCommand.js +14 -0
  57. package/dist/src/ui/commands/privacyCommand.js.map +1 -0
  58. package/dist/src/ui/commands/themeCommand.d.ts +7 -0
  59. package/dist/src/ui/commands/themeCommand.js +14 -0
  60. package/dist/src/ui/commands/themeCommand.js.map +1 -0
  61. package/dist/src/ui/commands/types.d.ts +64 -0
  62. package/dist/src/ui/commands/types.js +7 -0
  63. package/dist/src/ui/commands/types.js.map +1 -0
  64. package/dist/src/ui/components/AboutBox.d.ts +16 -0
  65. package/dist/src/ui/components/AboutBox.js +6 -0
  66. package/dist/src/ui/components/AboutBox.js.map +1 -0
  67. package/dist/src/ui/components/AsciiArt.d.ts +7 -0
  68. package/dist/src/ui/components/AsciiArt.js +22 -0
  69. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  70. package/dist/src/ui/components/AuthDialog.d.ts +15 -0
  71. package/dist/src/ui/components/AuthDialog.js +90 -0
  72. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  73. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  74. package/dist/src/ui/components/AuthInProgress.js +27 -0
  75. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  76. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  77. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  78. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  79. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  80. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  81. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  82. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +15 -0
  83. package/dist/src/ui/components/ContextSummaryDisplay.js +41 -0
  84. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  85. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  86. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  87. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  88. package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
  89. package/dist/src/ui/components/EditorSettingsDialog.js +73 -0
  90. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  91. package/dist/src/ui/components/Footer.d.ts +21 -0
  92. package/dist/src/ui/components/Footer.js +14 -0
  93. package/dist/src/ui/components/Footer.js.map +1 -0
  94. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  95. package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
  96. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  97. package/dist/src/ui/components/Header.d.ts +14 -0
  98. package/dist/src/ui/components/Header.js +20 -0
  99. package/dist/src/ui/components/Header.js.map +1 -0
  100. package/dist/src/ui/components/Help.d.ts +12 -0
  101. package/dist/src/ui/components/Help.js +10 -0
  102. package/dist/src/ui/components/Help.js.map +1 -0
  103. package/dist/src/ui/components/HistoryItemDisplay.d.ts +18 -0
  104. package/dist/src/ui/components/HistoryItemDisplay.js +17 -0
  105. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  106. package/dist/src/ui/components/InputPrompt.d.ts +25 -0
  107. package/dist/src/ui/components/InputPrompt.js +338 -0
  108. package/dist/src/ui/components/InputPrompt.js.map +1 -0
  109. package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
  110. package/dist/src/ui/components/LoadingIndicator.js +20 -0
  111. package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
  112. package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
  113. package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
  114. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  115. package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
  116. package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
  117. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
  118. package/dist/src/ui/components/OpenAIKeyPrompt.d.ts +12 -0
  119. package/dist/src/ui/components/OpenAIKeyPrompt.js +118 -0
  120. package/dist/src/ui/components/OpenAIKeyPrompt.js.map +1 -0
  121. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
  122. package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
  123. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  124. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  125. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  126. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  127. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  128. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  129. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  130. package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
  131. package/dist/src/ui/components/StatsDisplay.js +42 -0
  132. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  133. package/dist/src/ui/components/SuggestionsDisplay.d.ts +21 -0
  134. package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
  135. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  136. package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
  137. package/dist/src/ui/components/ThemeDialog.js +127 -0
  138. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  139. package/dist/src/ui/components/Tips.d.ts +12 -0
  140. package/dist/src/ui/components/Tips.js +8 -0
  141. package/dist/src/ui/components/Tips.js.map +1 -0
  142. package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
  143. package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
  144. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
  145. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  146. package/dist/src/ui/components/UpdateNotification.js +10 -0
  147. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  148. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  149. package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
  150. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  151. package/dist/src/ui/components/messages/DiffRenderer.d.ts +15 -0
  152. package/dist/src/ui/components/messages/DiffRenderer.js +212 -0
  153. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  154. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  155. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  156. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  157. package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
  158. package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
  159. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  160. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  161. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  162. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  163. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  164. package/dist/src/ui/components/messages/InfoMessage.js +9 -0
  165. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  166. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  167. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +111 -0
  168. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  169. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  170. package/dist/src/ui/components/messages/ToolGroupMessage.js +53 -0
  171. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  172. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  173. package/dist/src/ui/components/messages/ToolMessage.js +61 -0
  174. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  175. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  176. package/dist/src/ui/components/messages/UserMessage.js +9 -0
  177. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  178. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  179. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  180. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  181. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  182. package/dist/src/ui/components/shared/MaxSizedBox.js +384 -0
  183. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  184. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +44 -0
  185. package/dist/src/ui/components/shared/RadioButtonSelect.js +100 -0
  186. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  187. package/dist/src/ui/components/shared/text-buffer.d.ts +184 -0
  188. package/dist/src/ui/components/shared/text-buffer.js +1010 -0
  189. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  190. package/dist/src/ui/constants.d.ts +8 -0
  191. package/dist/src/ui/constants.js +12 -0
  192. package/dist/src/ui/constants.js.map +1 -0
  193. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  194. package/dist/src/ui/contexts/OverflowContext.js +43 -0
  195. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  196. package/dist/src/ui/contexts/SessionContext.d.ts +37 -0
  197. package/dist/src/ui/contexts/SessionContext.js +68 -0
  198. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  199. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  200. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  201. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  202. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  203. package/dist/src/ui/editors/editorSettingsManager.js +54 -0
  204. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  205. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  206. package/dist/src/ui/hooks/atCommandProcessor.js +310 -0
  207. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  208. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
  209. package/dist/src/ui/hooks/shellCommandProcessor.js +261 -0
  210. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  211. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +27 -0
  212. package/dist/src/ui/hooks/slashCommandProcessor.js +1042 -0
  213. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  214. package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
  215. package/dist/src/ui/hooks/useAuthCommand.js +64 -0
  216. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  217. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
  218. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
  219. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  220. package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
  221. package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
  222. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
  223. package/dist/src/ui/hooks/useCompletion.d.ts +21 -0
  224. package/dist/src/ui/hooks/useCompletion.js +375 -0
  225. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  226. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  227. package/dist/src/ui/hooks/useConsoleMessages.js +60 -0
  228. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  229. package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
  230. package/dist/src/ui/hooks/useEditorSettings.js +43 -0
  231. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  232. package/dist/src/ui/hooks/useGeminiStream.d.ts +23 -0
  233. package/dist/src/ui/hooks/useGeminiStream.js +579 -0
  234. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  235. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  236. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  237. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  238. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  239. package/dist/src/ui/hooks/useHistoryManager.js +72 -0
  240. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  241. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  242. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  243. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  244. package/dist/src/ui/hooks/useKeypress.d.ts +29 -0
  245. package/dist/src/ui/hooks/useKeypress.js +156 -0
  246. package/dist/src/ui/hooks/useKeypress.js.map +1 -0
  247. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  248. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  249. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  250. package/dist/src/ui/hooks/useLogger.d.ts +10 -0
  251. package/dist/src/ui/hooks/useLogger.js +29 -0
  252. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  253. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  254. package/dist/src/ui/hooks/usePhraseCycler.js +189 -0
  255. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  256. package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
  257. package/dist/src/ui/hooks/usePrivacySettings.js +115 -0
  258. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
  259. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  260. package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
  261. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  262. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  263. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  264. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  265. package/dist/src/ui/hooks/useShellHistory.d.ts +11 -0
  266. package/dist/src/ui/hooks/useShellHistory.js +89 -0
  267. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  268. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  269. package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
  270. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  271. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  272. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  273. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  274. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  275. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  276. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  277. package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
  278. package/dist/src/ui/hooks/useThemeCommand.js +78 -0
  279. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  280. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  281. package/dist/src/ui/hooks/useTimer.js +58 -0
  282. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  283. package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
  284. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +40 -0
  285. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
  286. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
  287. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +17 -0
  288. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
  289. package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
  290. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +17 -0
  291. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
  292. package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
  293. package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
  294. package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
  295. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  296. package/dist/src/ui/themes/ansi-light.js +139 -0
  297. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  298. package/dist/src/ui/themes/ansi.d.ts +7 -0
  299. package/dist/src/ui/themes/ansi.js +149 -0
  300. package/dist/src/ui/themes/ansi.js.map +1 -0
  301. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  302. package/dist/src/ui/themes/atom-one-dark.js +136 -0
  303. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  304. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  305. package/dist/src/ui/themes/ayu-light.js +128 -0
  306. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  307. package/dist/src/ui/themes/ayu.d.ts +7 -0
  308. package/dist/src/ui/themes/ayu.js +102 -0
  309. package/dist/src/ui/themes/ayu.js.map +1 -0
  310. package/dist/src/ui/themes/default-light.d.ts +7 -0
  311. package/dist/src/ui/themes/default-light.js +100 -0
  312. package/dist/src/ui/themes/default-light.js.map +1 -0
  313. package/dist/src/ui/themes/default.d.ts +7 -0
  314. package/dist/src/ui/themes/default.js +143 -0
  315. package/dist/src/ui/themes/default.js.map +1 -0
  316. package/dist/src/ui/themes/dracula.d.ts +7 -0
  317. package/dist/src/ui/themes/dracula.js +113 -0
  318. package/dist/src/ui/themes/dracula.js.map +1 -0
  319. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  320. package/dist/src/ui/themes/github-dark.js +136 -0
  321. package/dist/src/ui/themes/github-dark.js.map +1 -0
  322. package/dist/src/ui/themes/github-light.d.ts +7 -0
  323. package/dist/src/ui/themes/github-light.js +138 -0
  324. package/dist/src/ui/themes/github-light.js.map +1 -0
  325. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  326. package/dist/src/ui/themes/googlecode.js +135 -0
  327. package/dist/src/ui/themes/googlecode.js.map +1 -0
  328. package/dist/src/ui/themes/no-color.d.ts +7 -0
  329. package/dist/src/ui/themes/no-color.js +84 -0
  330. package/dist/src/ui/themes/no-color.js.map +1 -0
  331. package/dist/src/ui/themes/qwen-dark.d.ts +7 -0
  332. package/dist/src/ui/themes/qwen-dark.js +102 -0
  333. package/dist/src/ui/themes/qwen-dark.js.map +1 -0
  334. package/dist/src/ui/themes/qwen-light.d.ts +7 -0
  335. package/dist/src/ui/themes/qwen-light.js +128 -0
  336. package/dist/src/ui/themes/qwen-light.js.map +1 -0
  337. package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
  338. package/dist/src/ui/themes/shades-of-purple.js +302 -0
  339. package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
  340. package/dist/src/ui/themes/theme-manager.d.ts +33 -0
  341. package/dist/src/ui/themes/theme-manager.js +119 -0
  342. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  343. package/dist/src/ui/themes/theme.d.ts +67 -0
  344. package/dist/src/ui/themes/theme.js +304 -0
  345. package/dist/src/ui/themes/theme.js.map +1 -0
  346. package/dist/src/ui/themes/xcode.d.ts +7 -0
  347. package/dist/src/ui/themes/xcode.js +143 -0
  348. package/dist/src/ui/themes/xcode.js.map +1 -0
  349. package/dist/src/ui/types.d.ts +172 -0
  350. package/dist/src/ui/types.js +43 -0
  351. package/dist/src/ui/types.js.map +1 -0
  352. package/dist/src/ui/utils/CodeColorizer.d.ts +14 -0
  353. package/dist/src/ui/utils/CodeColorizer.js +97 -0
  354. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  355. package/dist/src/ui/utils/ConsolePatcher.d.ts +23 -0
  356. package/dist/src/ui/utils/ConsolePatcher.js +42 -0
  357. package/dist/src/ui/utils/ConsolePatcher.js.map +1 -0
  358. package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
  359. package/dist/src/ui/utils/InlineMarkdownRenderer.js +104 -0
  360. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
  361. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  362. package/dist/src/ui/utils/MarkdownDisplay.js +205 -0
  363. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  364. package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
  365. package/dist/src/ui/utils/TableRenderer.js +84 -0
  366. package/dist/src/ui/utils/TableRenderer.js.map +1 -0
  367. package/dist/src/ui/utils/clipboardUtils.d.ts +22 -0
  368. package/dist/src/ui/utils/clipboardUtils.js +127 -0
  369. package/dist/src/ui/utils/clipboardUtils.js.map +1 -0
  370. package/dist/src/ui/utils/commandUtils.d.ts +22 -0
  371. package/dist/src/ui/utils/commandUtils.js +25 -0
  372. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  373. package/dist/src/ui/utils/computeStats.d.ts +10 -0
  374. package/dist/src/ui/utils/computeStats.js +55 -0
  375. package/dist/src/ui/utils/computeStats.js.map +1 -0
  376. package/dist/src/ui/utils/displayUtils.d.ts +17 -0
  377. package/dist/src/ui/utils/displayUtils.js +24 -0
  378. package/dist/src/ui/utils/displayUtils.js.map +1 -0
  379. package/dist/src/ui/utils/errorParsing.d.ts +7 -0
  380. package/dist/src/ui/utils/errorParsing.js +90 -0
  381. package/dist/src/ui/utils/errorParsing.js.map +1 -0
  382. package/dist/src/ui/utils/formatters.d.ts +13 -0
  383. package/dist/src/ui/utils/formatters.js +56 -0
  384. package/dist/src/ui/utils/formatters.js.map +1 -0
  385. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  386. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  387. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  388. package/dist/src/ui/utils/textUtils.d.ts +22 -0
  389. package/dist/src/ui/utils/textUtils.js +58 -0
  390. package/dist/src/ui/utils/textUtils.js.map +1 -0
  391. package/dist/src/ui/utils/updateCheck.d.ts +6 -0
  392. package/dist/src/ui/utils/updateCheck.js +36 -0
  393. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  394. package/dist/src/utils/cleanup.d.ts +8 -0
  395. package/dist/src/utils/cleanup.js +34 -0
  396. package/dist/src/utils/cleanup.js.map +1 -0
  397. package/dist/src/utils/package.d.ts +12 -0
  398. package/dist/src/utils/package.js +24 -0
  399. package/dist/src/utils/package.js.map +1 -0
  400. package/dist/src/utils/readStdin.d.ts +6 -0
  401. package/dist/src/utils/readStdin.js +34 -0
  402. package/dist/src/utils/readStdin.js.map +1 -0
  403. package/dist/src/utils/sandbox.d.ts +7 -0
  404. package/dist/src/utils/sandbox.js +690 -0
  405. package/dist/src/utils/sandbox.js.map +1 -0
  406. package/dist/src/utils/startupWarnings.d.ts +6 -0
  407. package/dist/src/utils/startupWarnings.js +40 -0
  408. package/dist/src/utils/startupWarnings.js.map +1 -0
  409. package/dist/src/utils/userStartupWarnings.d.ts +6 -0
  410. package/dist/src/utils/userStartupWarnings.js +48 -0
  411. package/dist/src/utils/userStartupWarnings.js.map +1 -0
  412. package/dist/src/utils/version.d.ts +6 -0
  413. package/dist/src/utils/version.js +11 -0
  414. package/dist/src/utils/version.js.map +1 -0
  415. package/dist/tsconfig.tsbuildinfo +1 -0
  416. package/package.json +63 -69
  417. package/README.gemini.md +0 -162
  418. package/bundle/gemini.js +0 -291384
  419. /package/{bundle → dist/src/utils}/sandbox-macos-permissive-closed.sb +0 -0
  420. /package/{bundle → dist/src/utils}/sandbox-macos-permissive-open.sb +0 -0
  421. /package/{bundle → dist/src/utils}/sandbox-macos-permissive-proxied.sb +0 -0
  422. /package/{bundle → dist/src/utils}/sandbox-macos-restrictive-closed.sb +0 -0
  423. /package/{bundle → dist/src/utils}/sandbox-macos-restrictive-open.sb +0 -0
  424. /package/{bundle → dist/src/utils}/sandbox-macos-restrictive-proxied.sb +0 -0
@@ -0,0 +1,1042 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { useCallback, useMemo, useEffect, useState } from 'react';
7
+ import open from 'open';
8
+ import process from 'node:process';
9
+ import { useStateAndRef } from './useStateAndRef.js';
10
+ import { GitService, Logger, MCPDiscoveryState, MCPServerStatus, getMCPDiscoveryState, getMCPServerStatus, } from '@qwen-code/qwen-code-core';
11
+ import { useSessionStats } from '../contexts/SessionContext.js';
12
+ import { MessageType, } from '../types.js';
13
+ import { promises as fs } from 'fs';
14
+ import path from 'path';
15
+ import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
16
+ import { formatDuration, formatMemoryUsage } from '../utils/formatters.js';
17
+ import { getCliVersion } from '../../utils/version.js';
18
+ import { CommandService } from '../../services/CommandService.js';
19
+ /**
20
+ * Hook to define and process slash commands (e.g., /help, /clear).
21
+ */
22
+ export const useSlashCommandProcessor = (config, settings, history, addItem, clearItems, loadHistory, refreshStatic, setShowHelp, onDebugMessage, openThemeDialog, openAuthDialog, openEditorDialog, toggleCorgiMode, showToolDescriptions = false, setQuittingMessages, openPrivacyNotice) => {
23
+ const session = useSessionStats();
24
+ const [commands, setCommands] = useState([]);
25
+ const gitService = useMemo(() => {
26
+ if (!config?.getProjectRoot()) {
27
+ return;
28
+ }
29
+ return new GitService(config.getProjectRoot());
30
+ }, [config]);
31
+ const logger = useMemo(() => {
32
+ const l = new Logger(config?.getSessionId() || '');
33
+ // The logger's initialize is async, but we can create the instance
34
+ // synchronously. Commands that use it will await its initialization.
35
+ return l;
36
+ }, [config]);
37
+ const [pendingCompressionItemRef, setPendingCompressionItem] = useStateAndRef(null);
38
+ const pendingHistoryItems = useMemo(() => {
39
+ const items = [];
40
+ if (pendingCompressionItemRef.current != null) {
41
+ items.push(pendingCompressionItemRef.current);
42
+ }
43
+ return items;
44
+ }, [pendingCompressionItemRef]);
45
+ const addMessage = useCallback((message) => {
46
+ // Convert Message to HistoryItemWithoutId
47
+ let historyItemContent;
48
+ if (message.type === MessageType.ABOUT) {
49
+ historyItemContent = {
50
+ type: 'about',
51
+ cliVersion: message.cliVersion,
52
+ osVersion: message.osVersion,
53
+ sandboxEnv: message.sandboxEnv,
54
+ modelVersion: message.modelVersion,
55
+ selectedAuthType: message.selectedAuthType,
56
+ gcpProject: message.gcpProject,
57
+ };
58
+ }
59
+ else if (message.type === MessageType.STATS) {
60
+ historyItemContent = {
61
+ type: 'stats',
62
+ duration: message.duration,
63
+ };
64
+ }
65
+ else if (message.type === MessageType.MODEL_STATS) {
66
+ historyItemContent = {
67
+ type: 'model_stats',
68
+ };
69
+ }
70
+ else if (message.type === MessageType.TOOL_STATS) {
71
+ historyItemContent = {
72
+ type: 'tool_stats',
73
+ };
74
+ }
75
+ else if (message.type === MessageType.QUIT) {
76
+ historyItemContent = {
77
+ type: 'quit',
78
+ duration: message.duration,
79
+ };
80
+ }
81
+ else if (message.type === MessageType.COMPRESSION) {
82
+ historyItemContent = {
83
+ type: 'compression',
84
+ compression: message.compression,
85
+ };
86
+ }
87
+ else {
88
+ historyItemContent = {
89
+ type: message.type,
90
+ text: message.content,
91
+ };
92
+ }
93
+ addItem(historyItemContent, message.timestamp.getTime());
94
+ }, [addItem]);
95
+ const commandContext = useMemo(() => ({
96
+ services: {
97
+ config,
98
+ settings,
99
+ git: gitService,
100
+ logger,
101
+ },
102
+ ui: {
103
+ addItem,
104
+ clear: () => {
105
+ clearItems();
106
+ console.clear();
107
+ refreshStatic();
108
+ },
109
+ setDebugMessage: onDebugMessage,
110
+ },
111
+ session: {
112
+ stats: session.stats,
113
+ resetSession: session.resetSession,
114
+ },
115
+ }), [
116
+ config,
117
+ settings,
118
+ gitService,
119
+ logger,
120
+ addItem,
121
+ clearItems,
122
+ refreshStatic,
123
+ session.stats,
124
+ session.resetSession,
125
+ onDebugMessage,
126
+ ]);
127
+ const commandService = useMemo(() => new CommandService(), []);
128
+ useEffect(() => {
129
+ const load = async () => {
130
+ await commandService.loadCommands();
131
+ setCommands(commandService.getCommands());
132
+ };
133
+ load();
134
+ }, [commandService]);
135
+ const savedChatTags = useCallback(async () => {
136
+ const geminiDir = config?.getProjectTempDir();
137
+ if (!geminiDir) {
138
+ return [];
139
+ }
140
+ try {
141
+ const files = await fs.readdir(geminiDir);
142
+ return files
143
+ .filter((file) => file.startsWith('checkpoint-') && file.endsWith('.json'))
144
+ .map((file) => file.replace('checkpoint-', '').replace('.json', ''));
145
+ }
146
+ catch (_err) {
147
+ return [];
148
+ }
149
+ }, [config]);
150
+ // Define legacy commands
151
+ // This list contains all commands that have NOT YET been migrated to the
152
+ // new system. As commands are migrated, they are removed from this list.
153
+ const legacyCommands = useMemo(() => {
154
+ const commands = [
155
+ // `/help` and `/clear` have been migrated and REMOVED from this list.
156
+ {
157
+ name: 'docs',
158
+ description: 'open full Qwen Code documentation in your browser',
159
+ action: async (_mainCommand, _subCommand, _args) => {
160
+ const docsUrl = 'https://github.com/QwenLM/Qwen3-Coder/blob/main/README.md';
161
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
162
+ addMessage({
163
+ type: MessageType.INFO,
164
+ content: `Please open the following URL in your browser to view the documentation:\n${docsUrl}`,
165
+ timestamp: new Date(),
166
+ });
167
+ }
168
+ else {
169
+ addMessage({
170
+ type: MessageType.INFO,
171
+ content: `Opening documentation in your browser: ${docsUrl}`,
172
+ timestamp: new Date(),
173
+ });
174
+ await open(docsUrl);
175
+ }
176
+ },
177
+ },
178
+ {
179
+ name: 'editor',
180
+ description: 'set external editor preference',
181
+ action: (_mainCommand, _subCommand, _args) => openEditorDialog(),
182
+ },
183
+ {
184
+ name: 'stats',
185
+ altName: 'usage',
186
+ description: 'check session stats. Usage: /stats [model|tools]',
187
+ action: (_mainCommand, subCommand, _args) => {
188
+ if (subCommand === 'model') {
189
+ addMessage({
190
+ type: MessageType.MODEL_STATS,
191
+ timestamp: new Date(),
192
+ });
193
+ return;
194
+ }
195
+ else if (subCommand === 'tools') {
196
+ addMessage({
197
+ type: MessageType.TOOL_STATS,
198
+ timestamp: new Date(),
199
+ });
200
+ return;
201
+ }
202
+ const now = new Date();
203
+ const { sessionStartTime } = session.stats;
204
+ const wallDuration = now.getTime() - sessionStartTime.getTime();
205
+ addMessage({
206
+ type: MessageType.STATS,
207
+ duration: formatDuration(wallDuration),
208
+ timestamp: new Date(),
209
+ });
210
+ },
211
+ },
212
+ {
213
+ name: 'mcp',
214
+ description: 'list configured MCP servers and tools',
215
+ action: async (_mainCommand, _subCommand, _args) => {
216
+ // Check if the _subCommand includes a specific flag to control description visibility
217
+ let useShowDescriptions = showToolDescriptions;
218
+ if (_subCommand === 'desc' || _subCommand === 'descriptions') {
219
+ useShowDescriptions = true;
220
+ }
221
+ else if (_subCommand === 'nodesc' ||
222
+ _subCommand === 'nodescriptions') {
223
+ useShowDescriptions = false;
224
+ }
225
+ else if (_args === 'desc' || _args === 'descriptions') {
226
+ useShowDescriptions = true;
227
+ }
228
+ else if (_args === 'nodesc' || _args === 'nodescriptions') {
229
+ useShowDescriptions = false;
230
+ }
231
+ // Check if the _subCommand includes a specific flag to show detailed tool schema
232
+ let useShowSchema = false;
233
+ if (_subCommand === 'schema' || _args === 'schema') {
234
+ useShowSchema = true;
235
+ }
236
+ const toolRegistry = await config?.getToolRegistry();
237
+ if (!toolRegistry) {
238
+ addMessage({
239
+ type: MessageType.ERROR,
240
+ content: 'Could not retrieve tool registry.',
241
+ timestamp: new Date(),
242
+ });
243
+ return;
244
+ }
245
+ const mcpServers = config?.getMcpServers() || {};
246
+ const serverNames = Object.keys(mcpServers);
247
+ if (serverNames.length === 0) {
248
+ const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
249
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
250
+ addMessage({
251
+ type: MessageType.INFO,
252
+ content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
253
+ timestamp: new Date(),
254
+ });
255
+ }
256
+ else {
257
+ addMessage({
258
+ type: MessageType.INFO,
259
+ content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
260
+ timestamp: new Date(),
261
+ });
262
+ await open(docsUrl);
263
+ }
264
+ return;
265
+ }
266
+ // Check if any servers are still connecting
267
+ const connectingServers = serverNames.filter((name) => getMCPServerStatus(name) === MCPServerStatus.CONNECTING);
268
+ const discoveryState = getMCPDiscoveryState();
269
+ let message = '';
270
+ // Add overall discovery status message if needed
271
+ if (discoveryState === MCPDiscoveryState.IN_PROGRESS ||
272
+ connectingServers.length > 0) {
273
+ message += `\u001b[33m⏳ MCP servers are starting up (${connectingServers.length} initializing)...\u001b[0m\n`;
274
+ message += `\u001b[90mNote: First startup may take longer. Tool availability will update automatically.\u001b[0m\n\n`;
275
+ }
276
+ message += 'Configured MCP servers:\n\n';
277
+ for (const serverName of serverNames) {
278
+ const serverTools = toolRegistry.getToolsByServer(serverName);
279
+ const status = getMCPServerStatus(serverName);
280
+ // Add status indicator with descriptive text
281
+ let statusIndicator = '';
282
+ let statusText = '';
283
+ switch (status) {
284
+ case MCPServerStatus.CONNECTED:
285
+ statusIndicator = '🟢';
286
+ statusText = 'Ready';
287
+ break;
288
+ case MCPServerStatus.CONNECTING:
289
+ statusIndicator = '🔄';
290
+ statusText = 'Starting... (first startup may take longer)';
291
+ break;
292
+ case MCPServerStatus.DISCONNECTED:
293
+ default:
294
+ statusIndicator = '🔴';
295
+ statusText = 'Disconnected';
296
+ break;
297
+ }
298
+ // Get server description if available
299
+ const server = mcpServers[serverName];
300
+ // Format server header with bold formatting and status
301
+ message += `${statusIndicator} \u001b[1m${serverName}\u001b[0m - ${statusText}`;
302
+ // Add tool count with conditional messaging
303
+ if (status === MCPServerStatus.CONNECTED) {
304
+ message += ` (${serverTools.length} tools)`;
305
+ }
306
+ else if (status === MCPServerStatus.CONNECTING) {
307
+ message += ` (tools will appear when ready)`;
308
+ }
309
+ else {
310
+ message += ` (${serverTools.length} tools cached)`;
311
+ }
312
+ // Add server description with proper handling of multi-line descriptions
313
+ if ((useShowDescriptions || useShowSchema) && server?.description) {
314
+ const greenColor = '\u001b[32m';
315
+ const resetColor = '\u001b[0m';
316
+ const descLines = server.description.trim().split('\n');
317
+ if (descLines) {
318
+ message += ':\n';
319
+ for (const descLine of descLines) {
320
+ message += ` ${greenColor}${descLine}${resetColor}\n`;
321
+ }
322
+ }
323
+ else {
324
+ message += '\n';
325
+ }
326
+ }
327
+ else {
328
+ message += '\n';
329
+ }
330
+ // Reset formatting after server entry
331
+ message += '\u001b[0m';
332
+ if (serverTools.length > 0) {
333
+ serverTools.forEach((tool) => {
334
+ if ((useShowDescriptions || useShowSchema) &&
335
+ tool.description) {
336
+ // Format tool name in cyan using simple ANSI cyan color
337
+ message += ` - \u001b[36m${tool.name}\u001b[0m`;
338
+ // Apply green color to the description text
339
+ const greenColor = '\u001b[32m';
340
+ const resetColor = '\u001b[0m';
341
+ // Handle multi-line descriptions by properly indenting and preserving formatting
342
+ const descLines = tool.description.trim().split('\n');
343
+ if (descLines) {
344
+ message += ':\n';
345
+ for (const descLine of descLines) {
346
+ message += ` ${greenColor}${descLine}${resetColor}\n`;
347
+ }
348
+ }
349
+ else {
350
+ message += '\n';
351
+ }
352
+ // Reset is handled inline with each line now
353
+ }
354
+ else {
355
+ // Use cyan color for the tool name even when not showing descriptions
356
+ message += ` - \u001b[36m${tool.name}\u001b[0m\n`;
357
+ }
358
+ if (useShowSchema) {
359
+ // Prefix the parameters in cyan
360
+ message += ` \u001b[36mParameters:\u001b[0m\n`;
361
+ // Apply green color to the parameter text
362
+ const greenColor = '\u001b[32m';
363
+ const resetColor = '\u001b[0m';
364
+ const paramsLines = JSON.stringify(tool.schema.parameters, null, 2)
365
+ .trim()
366
+ .split('\n');
367
+ if (paramsLines) {
368
+ for (const paramsLine of paramsLines) {
369
+ message += ` ${greenColor}${paramsLine}${resetColor}\n`;
370
+ }
371
+ }
372
+ }
373
+ });
374
+ }
375
+ else {
376
+ message += ' No tools available\n';
377
+ }
378
+ message += '\n';
379
+ }
380
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
381
+ message += '\u001b[0m';
382
+ addMessage({
383
+ type: MessageType.INFO,
384
+ content: message,
385
+ timestamp: new Date(),
386
+ });
387
+ },
388
+ },
389
+ {
390
+ name: 'extensions',
391
+ description: 'list active extensions',
392
+ action: async () => {
393
+ const activeExtensions = config?.getActiveExtensions();
394
+ if (!activeExtensions || activeExtensions.length === 0) {
395
+ addMessage({
396
+ type: MessageType.INFO,
397
+ content: 'No active extensions.',
398
+ timestamp: new Date(),
399
+ });
400
+ return;
401
+ }
402
+ let message = 'Active extensions:\n\n';
403
+ for (const ext of activeExtensions) {
404
+ message += ` - \u001b[36m${ext.name} (v${ext.version})\u001b[0m\n`;
405
+ }
406
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
407
+ message += '\u001b[0m';
408
+ addMessage({
409
+ type: MessageType.INFO,
410
+ content: message,
411
+ timestamp: new Date(),
412
+ });
413
+ },
414
+ },
415
+ {
416
+ name: 'tools',
417
+ description: 'list available Qwen Code tools',
418
+ action: async (_mainCommand, _subCommand, _args) => {
419
+ // Check if the _subCommand includes a specific flag to control description visibility
420
+ let useShowDescriptions = showToolDescriptions;
421
+ if (_subCommand === 'desc' || _subCommand === 'descriptions') {
422
+ useShowDescriptions = true;
423
+ }
424
+ else if (_subCommand === 'nodesc' ||
425
+ _subCommand === 'nodescriptions') {
426
+ useShowDescriptions = false;
427
+ }
428
+ else if (_args === 'desc' || _args === 'descriptions') {
429
+ useShowDescriptions = true;
430
+ }
431
+ else if (_args === 'nodesc' || _args === 'nodescriptions') {
432
+ useShowDescriptions = false;
433
+ }
434
+ const toolRegistry = await config?.getToolRegistry();
435
+ const tools = toolRegistry?.getAllTools();
436
+ if (!tools) {
437
+ addMessage({
438
+ type: MessageType.ERROR,
439
+ content: 'Could not retrieve tools.',
440
+ timestamp: new Date(),
441
+ });
442
+ return;
443
+ }
444
+ // Filter out MCP tools by checking if they have a serverName property
445
+ const geminiTools = tools.filter((tool) => !('serverName' in tool));
446
+ let message = 'Available Qwen Code tools:\n\n';
447
+ if (geminiTools.length > 0) {
448
+ geminiTools.forEach((tool) => {
449
+ if (useShowDescriptions && tool.description) {
450
+ // Format tool name in cyan using simple ANSI cyan color
451
+ message += ` - \u001b[36m${tool.displayName} (${tool.name})\u001b[0m:\n`;
452
+ // Apply green color to the description text
453
+ const greenColor = '\u001b[32m';
454
+ const resetColor = '\u001b[0m';
455
+ // Handle multi-line descriptions by properly indenting and preserving formatting
456
+ const descLines = tool.description.trim().split('\n');
457
+ // If there are multiple lines, add proper indentation for each line
458
+ if (descLines) {
459
+ for (const descLine of descLines) {
460
+ message += ` ${greenColor}${descLine}${resetColor}\n`;
461
+ }
462
+ }
463
+ }
464
+ else {
465
+ // Use cyan color for the tool name even when not showing descriptions
466
+ message += ` - \u001b[36m${tool.displayName}\u001b[0m\n`;
467
+ }
468
+ });
469
+ }
470
+ else {
471
+ message += ' No tools available\n';
472
+ }
473
+ message += '\n';
474
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
475
+ message += '\u001b[0m';
476
+ addMessage({
477
+ type: MessageType.INFO,
478
+ content: message,
479
+ timestamp: new Date(),
480
+ });
481
+ },
482
+ },
483
+ {
484
+ name: 'corgi',
485
+ action: (_mainCommand, _subCommand, _args) => {
486
+ toggleCorgiMode();
487
+ },
488
+ },
489
+ {
490
+ name: 'bug',
491
+ description: 'submit a bug report',
492
+ action: async (_mainCommand, _subCommand, args) => {
493
+ let bugDescription = _subCommand || '';
494
+ if (args) {
495
+ bugDescription += ` ${args}`;
496
+ }
497
+ bugDescription = bugDescription.trim();
498
+ const osVersion = `${process.platform} ${process.version}`;
499
+ let sandboxEnv = 'no sandbox';
500
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
501
+ sandboxEnv = process.env.SANDBOX.replace(/^gemini-(?:code-)?/, '');
502
+ }
503
+ else if (process.env.SANDBOX === 'sandbox-exec') {
504
+ sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
505
+ }
506
+ const modelVersion = config?.getModel() || 'Unknown';
507
+ const cliVersion = await getCliVersion();
508
+ const memoryUsage = formatMemoryUsage(process.memoryUsage().rss);
509
+ const info = `
510
+ * **CLI Version:** ${cliVersion}
511
+ * **Git Commit:** ${GIT_COMMIT_INFO}
512
+ * **Operating System:** ${osVersion}
513
+ * **Sandbox Environment:** ${sandboxEnv}
514
+ * **Model Version:** ${modelVersion}
515
+ * **Memory Usage:** ${memoryUsage}
516
+ `;
517
+ let bugReportUrl = 'https://github.com/QwenLM/Qwen-Code/issues/new?template=bug_report.yml&title={title}&info={info}';
518
+ const bugCommand = config?.getBugCommand();
519
+ if (bugCommand?.urlTemplate) {
520
+ bugReportUrl = bugCommand.urlTemplate;
521
+ }
522
+ bugReportUrl = bugReportUrl
523
+ .replace('{title}', encodeURIComponent(bugDescription))
524
+ .replace('{info}', encodeURIComponent(info));
525
+ addMessage({
526
+ type: MessageType.INFO,
527
+ content: `To submit your bug report, please open the following URL in your browser:\n${bugReportUrl}`,
528
+ timestamp: new Date(),
529
+ });
530
+ (async () => {
531
+ try {
532
+ await open(bugReportUrl);
533
+ }
534
+ catch (error) {
535
+ const errorMessage = error instanceof Error ? error.message : String(error);
536
+ addMessage({
537
+ type: MessageType.ERROR,
538
+ content: `Could not open URL in browser: ${errorMessage}`,
539
+ timestamp: new Date(),
540
+ });
541
+ }
542
+ })();
543
+ },
544
+ },
545
+ {
546
+ name: 'chat',
547
+ description: 'Manage conversation history. Usage: /chat <list|save|resume> <tag>',
548
+ action: async (_mainCommand, subCommand, args) => {
549
+ const tag = (args || '').trim();
550
+ const logger = new Logger(config?.getSessionId() || '');
551
+ await logger.initialize();
552
+ const chat = await config?.getGeminiClient()?.getChat();
553
+ if (!chat) {
554
+ addMessage({
555
+ type: MessageType.ERROR,
556
+ content: 'No chat client available for conversation status.',
557
+ timestamp: new Date(),
558
+ });
559
+ return;
560
+ }
561
+ if (!subCommand) {
562
+ addMessage({
563
+ type: MessageType.ERROR,
564
+ content: 'Missing command\nUsage: /chat <list|save|resume> <tag>',
565
+ timestamp: new Date(),
566
+ });
567
+ return;
568
+ }
569
+ switch (subCommand) {
570
+ case 'save': {
571
+ if (!tag) {
572
+ addMessage({
573
+ type: MessageType.ERROR,
574
+ content: 'Missing tag. Usage: /chat save <tag>',
575
+ timestamp: new Date(),
576
+ });
577
+ return;
578
+ }
579
+ const history = chat.getHistory();
580
+ if (history.length > 0) {
581
+ await logger.saveCheckpoint(chat?.getHistory() || [], tag);
582
+ addMessage({
583
+ type: MessageType.INFO,
584
+ content: `Conversation checkpoint saved with tag: ${tag}.`,
585
+ timestamp: new Date(),
586
+ });
587
+ }
588
+ else {
589
+ addMessage({
590
+ type: MessageType.INFO,
591
+ content: 'No conversation found to save.',
592
+ timestamp: new Date(),
593
+ });
594
+ }
595
+ return;
596
+ }
597
+ case 'resume':
598
+ case 'restore':
599
+ case 'load': {
600
+ if (!tag) {
601
+ addMessage({
602
+ type: MessageType.ERROR,
603
+ content: 'Missing tag. Usage: /chat resume <tag>',
604
+ timestamp: new Date(),
605
+ });
606
+ return;
607
+ }
608
+ const conversation = await logger.loadCheckpoint(tag);
609
+ if (conversation.length === 0) {
610
+ addMessage({
611
+ type: MessageType.INFO,
612
+ content: `No saved checkpoint found with tag: ${tag}.`,
613
+ timestamp: new Date(),
614
+ });
615
+ return;
616
+ }
617
+ clearItems();
618
+ chat.clearHistory();
619
+ const rolemap = {
620
+ user: MessageType.USER,
621
+ model: MessageType.GEMINI,
622
+ };
623
+ let hasSystemPrompt = false;
624
+ let i = 0;
625
+ for (const item of conversation) {
626
+ i += 1;
627
+ // Add each item to history regardless of whether we display
628
+ // it.
629
+ chat.addHistory(item);
630
+ const text = item.parts
631
+ ?.filter((m) => !!m.text)
632
+ .map((m) => m.text)
633
+ .join('') || '';
634
+ if (!text) {
635
+ // Parsing Part[] back to various non-text output not yet implemented.
636
+ continue;
637
+ }
638
+ if (i === 1 && text.match(/context for our chat/)) {
639
+ hasSystemPrompt = true;
640
+ }
641
+ if (i > 2 || !hasSystemPrompt) {
642
+ addItem({
643
+ type: (item.role && rolemap[item.role]) || MessageType.GEMINI,
644
+ text,
645
+ }, i);
646
+ }
647
+ }
648
+ console.clear();
649
+ refreshStatic();
650
+ return;
651
+ }
652
+ case 'list':
653
+ addMessage({
654
+ type: MessageType.INFO,
655
+ content: 'list of saved conversations: ' +
656
+ (await savedChatTags()).join(', '),
657
+ timestamp: new Date(),
658
+ });
659
+ return;
660
+ default:
661
+ addMessage({
662
+ type: MessageType.ERROR,
663
+ content: `Unknown /chat command: ${subCommand}. Available: list, save, resume`,
664
+ timestamp: new Date(),
665
+ });
666
+ return;
667
+ }
668
+ },
669
+ completion: async () => (await savedChatTags()).map((tag) => 'resume ' + tag),
670
+ },
671
+ {
672
+ name: 'quit',
673
+ altName: 'exit',
674
+ description: 'exit the cli',
675
+ action: async (mainCommand, _subCommand, _args) => {
676
+ const now = new Date();
677
+ const { sessionStartTime } = session.stats;
678
+ const wallDuration = now.getTime() - sessionStartTime.getTime();
679
+ setQuittingMessages([
680
+ {
681
+ type: 'user',
682
+ text: `/${mainCommand}`,
683
+ id: now.getTime() - 1,
684
+ },
685
+ {
686
+ type: 'quit',
687
+ duration: formatDuration(wallDuration),
688
+ id: now.getTime(),
689
+ },
690
+ ]);
691
+ setTimeout(() => {
692
+ process.exit(0);
693
+ }, 100);
694
+ },
695
+ },
696
+ {
697
+ name: 'compress',
698
+ altName: 'summarize',
699
+ description: 'Compresses the context by replacing it with a summary.',
700
+ action: async (_mainCommand, _subCommand, _args) => {
701
+ if (pendingCompressionItemRef.current !== null) {
702
+ addMessage({
703
+ type: MessageType.ERROR,
704
+ content: 'Already compressing, wait for previous request to complete',
705
+ timestamp: new Date(),
706
+ });
707
+ return;
708
+ }
709
+ setPendingCompressionItem({
710
+ type: MessageType.COMPRESSION,
711
+ compression: {
712
+ isPending: true,
713
+ originalTokenCount: null,
714
+ newTokenCount: null,
715
+ },
716
+ });
717
+ try {
718
+ const compressed = await config
719
+ .getGeminiClient()
720
+ // TODO: Set Prompt id for CompressChat from SlashCommandProcessor.
721
+ .tryCompressChat('Prompt Id not set', true);
722
+ if (compressed) {
723
+ addMessage({
724
+ type: MessageType.COMPRESSION,
725
+ compression: {
726
+ isPending: false,
727
+ originalTokenCount: compressed.originalTokenCount,
728
+ newTokenCount: compressed.newTokenCount,
729
+ },
730
+ timestamp: new Date(),
731
+ });
732
+ }
733
+ else {
734
+ addMessage({
735
+ type: MessageType.ERROR,
736
+ content: 'Failed to compress chat history.',
737
+ timestamp: new Date(),
738
+ });
739
+ }
740
+ }
741
+ catch (e) {
742
+ addMessage({
743
+ type: MessageType.ERROR,
744
+ content: `Failed to compress chat history: ${e instanceof Error ? e.message : String(e)}`,
745
+ timestamp: new Date(),
746
+ });
747
+ }
748
+ setPendingCompressionItem(null);
749
+ },
750
+ },
751
+ ];
752
+ if (config?.getCheckpointingEnabled()) {
753
+ commands.push({
754
+ name: 'restore',
755
+ description: 'restore a tool call. This will reset the conversation and file history to the state it was in when the tool call was suggested',
756
+ completion: async () => {
757
+ const checkpointDir = config?.getProjectTempDir()
758
+ ? path.join(config.getProjectTempDir(), 'checkpoints')
759
+ : undefined;
760
+ if (!checkpointDir) {
761
+ return [];
762
+ }
763
+ try {
764
+ const files = await fs.readdir(checkpointDir);
765
+ return files
766
+ .filter((file) => file.endsWith('.json'))
767
+ .map((file) => file.replace('.json', ''));
768
+ }
769
+ catch (_err) {
770
+ return [];
771
+ }
772
+ },
773
+ action: async (_mainCommand, subCommand, _args) => {
774
+ const checkpointDir = config?.getProjectTempDir()
775
+ ? path.join(config.getProjectTempDir(), 'checkpoints')
776
+ : undefined;
777
+ if (!checkpointDir) {
778
+ addMessage({
779
+ type: MessageType.ERROR,
780
+ content: 'Could not determine the .gemini directory path.',
781
+ timestamp: new Date(),
782
+ });
783
+ return;
784
+ }
785
+ try {
786
+ // Ensure the directory exists before trying to read it.
787
+ await fs.mkdir(checkpointDir, { recursive: true });
788
+ const files = await fs.readdir(checkpointDir);
789
+ const jsonFiles = files.filter((file) => file.endsWith('.json'));
790
+ if (!subCommand) {
791
+ if (jsonFiles.length === 0) {
792
+ addMessage({
793
+ type: MessageType.INFO,
794
+ content: 'No restorable tool calls found.',
795
+ timestamp: new Date(),
796
+ });
797
+ return;
798
+ }
799
+ const truncatedFiles = jsonFiles.map((file) => {
800
+ const components = file.split('.');
801
+ if (components.length <= 1) {
802
+ return file;
803
+ }
804
+ components.pop();
805
+ return components.join('.');
806
+ });
807
+ const fileList = truncatedFiles.join('\n');
808
+ addMessage({
809
+ type: MessageType.INFO,
810
+ content: `Available tool calls to restore:\n\n${fileList}`,
811
+ timestamp: new Date(),
812
+ });
813
+ return;
814
+ }
815
+ const selectedFile = subCommand.endsWith('.json')
816
+ ? subCommand
817
+ : `${subCommand}.json`;
818
+ if (!jsonFiles.includes(selectedFile)) {
819
+ addMessage({
820
+ type: MessageType.ERROR,
821
+ content: `File not found: ${selectedFile}`,
822
+ timestamp: new Date(),
823
+ });
824
+ return;
825
+ }
826
+ const filePath = path.join(checkpointDir, selectedFile);
827
+ const data = await fs.readFile(filePath, 'utf-8');
828
+ const toolCallData = JSON.parse(data);
829
+ if (toolCallData.history) {
830
+ loadHistory(toolCallData.history);
831
+ }
832
+ if (toolCallData.clientHistory) {
833
+ await config
834
+ ?.getGeminiClient()
835
+ ?.setHistory(toolCallData.clientHistory);
836
+ }
837
+ if (toolCallData.commitHash) {
838
+ await gitService?.restoreProjectFromSnapshot(toolCallData.commitHash);
839
+ addMessage({
840
+ type: MessageType.INFO,
841
+ content: `Restored project to the state before the tool call.`,
842
+ timestamp: new Date(),
843
+ });
844
+ }
845
+ return {
846
+ type: 'tool',
847
+ toolName: toolCallData.toolCall.name,
848
+ toolArgs: toolCallData.toolCall.args,
849
+ };
850
+ }
851
+ catch (error) {
852
+ addMessage({
853
+ type: MessageType.ERROR,
854
+ content: `Could not read restorable tool calls. This is the error: ${error}`,
855
+ timestamp: new Date(),
856
+ });
857
+ }
858
+ },
859
+ });
860
+ }
861
+ return commands;
862
+ }, [
863
+ addMessage,
864
+ openEditorDialog,
865
+ toggleCorgiMode,
866
+ savedChatTags,
867
+ config,
868
+ showToolDescriptions,
869
+ session,
870
+ gitService,
871
+ loadHistory,
872
+ addItem,
873
+ setQuittingMessages,
874
+ pendingCompressionItemRef,
875
+ setPendingCompressionItem,
876
+ clearItems,
877
+ refreshStatic,
878
+ ]);
879
+ const handleSlashCommand = useCallback(async (rawQuery) => {
880
+ if (typeof rawQuery !== 'string') {
881
+ return false;
882
+ }
883
+ const trimmed = rawQuery.trim();
884
+ if (!trimmed.startsWith('/') && !trimmed.startsWith('?')) {
885
+ return false;
886
+ }
887
+ const userMessageTimestamp = Date.now();
888
+ if (trimmed !== '/quit' && trimmed !== '/exit') {
889
+ addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp);
890
+ }
891
+ const parts = trimmed.substring(1).trim().split(/\s+/);
892
+ const commandPath = parts.filter((p) => p); // The parts of the command, e.g., ['memory', 'add']
893
+ // --- Start of New Tree Traversal Logic ---
894
+ let currentCommands = commands;
895
+ let commandToExecute;
896
+ let pathIndex = 0;
897
+ for (const part of commandPath) {
898
+ const foundCommand = currentCommands.find((cmd) => cmd.name === part || cmd.altName === part);
899
+ if (foundCommand) {
900
+ commandToExecute = foundCommand;
901
+ pathIndex++;
902
+ if (foundCommand.subCommands) {
903
+ currentCommands = foundCommand.subCommands;
904
+ }
905
+ else {
906
+ break;
907
+ }
908
+ }
909
+ else {
910
+ break;
911
+ }
912
+ }
913
+ if (commandToExecute) {
914
+ const args = parts.slice(pathIndex).join(' ');
915
+ if (commandToExecute.action) {
916
+ const result = await commandToExecute.action(commandContext, args);
917
+ if (result) {
918
+ switch (result.type) {
919
+ case 'tool':
920
+ return {
921
+ type: 'schedule_tool',
922
+ toolName: result.toolName,
923
+ toolArgs: result.toolArgs,
924
+ };
925
+ case 'message':
926
+ addItem({
927
+ type: result.messageType === 'error'
928
+ ? MessageType.ERROR
929
+ : MessageType.INFO,
930
+ text: result.content,
931
+ }, Date.now());
932
+ return { type: 'handled' };
933
+ case 'dialog':
934
+ switch (result.dialog) {
935
+ case 'help':
936
+ setShowHelp(true);
937
+ return { type: 'handled' };
938
+ case 'auth':
939
+ openAuthDialog();
940
+ return { type: 'handled' };
941
+ case 'theme':
942
+ openThemeDialog();
943
+ return { type: 'handled' };
944
+ case 'privacy':
945
+ openPrivacyNotice();
946
+ return { type: 'handled' };
947
+ default: {
948
+ const unhandled = result.dialog;
949
+ throw new Error(`Unhandled slash command result: ${unhandled}`);
950
+ }
951
+ }
952
+ default: {
953
+ const unhandled = result;
954
+ throw new Error(`Unhandled slash command result: ${unhandled}`);
955
+ }
956
+ }
957
+ }
958
+ return { type: 'handled' };
959
+ }
960
+ else if (commandToExecute.subCommands) {
961
+ const helpText = `Command '/${commandToExecute.name}' requires a subcommand. Available:\n${commandToExecute.subCommands
962
+ .map((sc) => ` - ${sc.name}: ${sc.description || ''}`)
963
+ .join('\n')}`;
964
+ addMessage({
965
+ type: MessageType.INFO,
966
+ content: helpText,
967
+ timestamp: new Date(),
968
+ });
969
+ return { type: 'handled' };
970
+ }
971
+ }
972
+ // --- End of New Tree Traversal Logic ---
973
+ // --- Legacy Fallback Logic (for commands not yet migrated) ---
974
+ const mainCommand = parts[0];
975
+ const subCommand = parts[1];
976
+ const legacyArgs = parts.slice(2).join(' ');
977
+ for (const cmd of legacyCommands) {
978
+ if (mainCommand === cmd.name || mainCommand === cmd.altName) {
979
+ const actionResult = await cmd.action(mainCommand, subCommand, legacyArgs);
980
+ if (actionResult?.type === 'tool') {
981
+ return {
982
+ type: 'schedule_tool',
983
+ toolName: actionResult.toolName,
984
+ toolArgs: actionResult.toolArgs,
985
+ };
986
+ }
987
+ if (actionResult?.type === 'message') {
988
+ addItem({
989
+ type: actionResult.messageType === 'error'
990
+ ? MessageType.ERROR
991
+ : MessageType.INFO,
992
+ text: actionResult.content,
993
+ }, Date.now());
994
+ }
995
+ return { type: 'handled' };
996
+ }
997
+ }
998
+ addMessage({
999
+ type: MessageType.ERROR,
1000
+ content: `Unknown command: ${trimmed}`,
1001
+ timestamp: new Date(),
1002
+ });
1003
+ return { type: 'handled' };
1004
+ }, [
1005
+ addItem,
1006
+ setShowHelp,
1007
+ openAuthDialog,
1008
+ commands,
1009
+ legacyCommands,
1010
+ commandContext,
1011
+ addMessage,
1012
+ openThemeDialog,
1013
+ openPrivacyNotice,
1014
+ ]);
1015
+ const allCommands = useMemo(() => {
1016
+ // Adapt legacy commands to the new SlashCommand interface
1017
+ const adaptedLegacyCommands = legacyCommands.map((legacyCmd) => ({
1018
+ name: legacyCmd.name,
1019
+ altName: legacyCmd.altName,
1020
+ description: legacyCmd.description,
1021
+ action: async (_context, args) => {
1022
+ const parts = args.split(/\s+/);
1023
+ const subCommand = parts[0] || undefined;
1024
+ const restOfArgs = parts.slice(1).join(' ') || undefined;
1025
+ return legacyCmd.action(legacyCmd.name, subCommand, restOfArgs);
1026
+ },
1027
+ completion: legacyCmd.completion
1028
+ ? async (_context, _partialArg) => legacyCmd.completion()
1029
+ : undefined,
1030
+ }));
1031
+ const newCommandNames = new Set(commands.map((c) => c.name));
1032
+ const filteredAdaptedLegacy = adaptedLegacyCommands.filter((c) => !newCommandNames.has(c.name));
1033
+ return [...commands, ...filteredAdaptedLegacy];
1034
+ }, [commands, legacyCommands]);
1035
+ return {
1036
+ handleSlashCommand,
1037
+ slashCommands: allCommands,
1038
+ pendingHistoryItems,
1039
+ commandContext,
1040
+ };
1041
+ };
1042
+ //# sourceMappingURL=slashCommandProcessor.js.map