@within-7/minto 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/dist/commands/agents/AgentsCommand.js +2342 -0
  2. package/dist/commands/agents/AgentsCommand.js.map +7 -0
  3. package/dist/commands/agents/constants.js +58 -0
  4. package/dist/commands/agents/constants.js.map +7 -0
  5. package/dist/commands/agents/index.js +37 -0
  6. package/dist/commands/agents/index.js.map +7 -0
  7. package/dist/commands/agents/types.js +10 -0
  8. package/dist/commands/agents/types.js.map +7 -0
  9. package/dist/commands/agents/utils/fileOperations.js +185 -0
  10. package/dist/commands/agents/utils/fileOperations.js.map +7 -0
  11. package/dist/commands/agents/utils/index.js +21 -0
  12. package/dist/commands/agents/utils/index.js.map +7 -0
  13. package/dist/commands/bug.js +2 -2
  14. package/dist/commands/bug.js.map +2 -2
  15. package/dist/commands/compact.js +5 -5
  16. package/dist/commands/compact.js.map +2 -2
  17. package/dist/commands/ctx_viz.js +55 -22
  18. package/dist/commands/ctx_viz.js.map +2 -2
  19. package/dist/commands/mcp-interactive.js +11 -11
  20. package/dist/commands/mcp-interactive.js.map +2 -2
  21. package/dist/commands/model.js +94 -32
  22. package/dist/commands/model.js.map +3 -3
  23. package/dist/commands/plugin/AddMarketplaceForm.js +49 -21
  24. package/dist/commands/plugin/AddMarketplaceForm.js.map +2 -2
  25. package/dist/commands/plugin/ConfirmDialog.js +38 -26
  26. package/dist/commands/plugin/ConfirmDialog.js.map +2 -2
  27. package/dist/commands/plugin/InstalledPluginsByMarketplace.js +24 -8
  28. package/dist/commands/plugin/InstalledPluginsByMarketplace.js.map +2 -2
  29. package/dist/commands/plugin/InstalledPluginsManager.js +3 -1
  30. package/dist/commands/plugin/InstalledPluginsManager.js.map +2 -2
  31. package/dist/commands/plugin/MainMenu.js +16 -7
  32. package/dist/commands/plugin/MainMenu.js.map +2 -2
  33. package/dist/commands/plugin/MarketplaceManager.js +84 -39
  34. package/dist/commands/plugin/MarketplaceManager.js.map +2 -2
  35. package/dist/commands/plugin/MarketplaceSelector.js +7 -3
  36. package/dist/commands/plugin/MarketplaceSelector.js.map +2 -2
  37. package/dist/commands/plugin/PlaceholderScreen.js +16 -2
  38. package/dist/commands/plugin/PlaceholderScreen.js.map +2 -2
  39. package/dist/commands/plugin/PluginBrowser.js +4 -2
  40. package/dist/commands/plugin/PluginBrowser.js.map +2 -2
  41. package/dist/commands/plugin/PluginDetailsInstall.js +12 -6
  42. package/dist/commands/plugin/PluginDetailsInstall.js.map +2 -2
  43. package/dist/commands/plugin/PluginDetailsManage.js +14 -5
  44. package/dist/commands/plugin/PluginDetailsManage.js.map +2 -2
  45. package/dist/commands/plugin/example-usage.js.map +2 -2
  46. package/dist/commands/plugin/utils.js.map +2 -2
  47. package/dist/commands/plugin.js +226 -46
  48. package/dist/commands/plugin.js.map +2 -2
  49. package/dist/commands/refreshCommands.js +6 -3
  50. package/dist/commands/refreshCommands.js.map +2 -2
  51. package/dist/commands/resume.js +2 -1
  52. package/dist/commands/resume.js.map +2 -2
  53. package/dist/commands/setup.js +19 -5
  54. package/dist/commands/setup.js.map +2 -2
  55. package/dist/commands/terminalSetup.js +2 -2
  56. package/dist/commands/terminalSetup.js.map +1 -1
  57. package/dist/commands.js +14 -30
  58. package/dist/commands.js.map +2 -2
  59. package/dist/components/AskUserQuestionDialog/AskUserQuestionDialog.js.map +2 -2
  60. package/dist/components/AskUserQuestionDialog/QuestionView.js +10 -1
  61. package/dist/components/AskUserQuestionDialog/QuestionView.js.map +2 -2
  62. package/dist/components/BackgroundTasksPanel.js +5 -1
  63. package/dist/components/BackgroundTasksPanel.js.map +2 -2
  64. package/dist/components/Config.js +17 -4
  65. package/dist/components/Config.js.map +2 -2
  66. package/dist/components/ConsoleOAuthFlow.js.map +2 -2
  67. package/dist/components/CustomSelect/select-option.js +4 -1
  68. package/dist/components/CustomSelect/select-option.js.map +2 -2
  69. package/dist/components/Help.js +6 -8
  70. package/dist/components/Help.js.map +2 -2
  71. package/dist/components/Logo.js +1 -1
  72. package/dist/components/Logo.js.map +2 -2
  73. package/dist/components/ModelListManager.js.map +2 -2
  74. package/dist/components/ModelSelector/ModelSelector.js +2030 -0
  75. package/dist/components/ModelSelector/ModelSelector.js.map +7 -0
  76. package/dist/components/ModelSelector/ScreenContainer.js +27 -0
  77. package/dist/components/ModelSelector/ScreenContainer.js.map +7 -0
  78. package/dist/components/ModelSelector/constants.js +37 -0
  79. package/dist/components/ModelSelector/constants.js.map +7 -0
  80. package/dist/components/ModelSelector/hooks/index.js +5 -0
  81. package/dist/components/ModelSelector/hooks/index.js.map +7 -0
  82. package/dist/components/ModelSelector/hooks/useEscapeNavigation.js +21 -0
  83. package/dist/components/ModelSelector/hooks/useEscapeNavigation.js.map +7 -0
  84. package/dist/components/ModelSelector/index.js +17 -0
  85. package/dist/components/ModelSelector/index.js.map +7 -0
  86. package/dist/components/ModelSelector/types.js +1 -0
  87. package/dist/components/ModelSelector/types.js.map +7 -0
  88. package/dist/components/PressEnterToContinue.js +1 -1
  89. package/dist/components/PressEnterToContinue.js.map +2 -2
  90. package/dist/components/ProjectOnboarding.js +1 -1
  91. package/dist/components/ProjectOnboarding.js.map +2 -2
  92. package/dist/components/PromptInput.js +88 -37
  93. package/dist/components/PromptInput.js.map +2 -2
  94. package/dist/components/QuitSummary.js +17 -10
  95. package/dist/components/QuitSummary.js.map +2 -2
  96. package/dist/components/SentryErrorBoundary.js.map +2 -2
  97. package/dist/components/StreamingBashOutput.js.map +2 -2
  98. package/dist/components/StructuredDiff.js.map +2 -2
  99. package/dist/components/SubagentProgress.js.map +2 -2
  100. package/dist/components/TaskCard.js.map +2 -2
  101. package/dist/components/TextInput.js.map +1 -1
  102. package/dist/components/TodoItem.js.map +1 -1
  103. package/dist/components/binary-feedback/BinaryFeedbackOption.js +1 -3
  104. package/dist/components/binary-feedback/BinaryFeedbackOption.js.map +2 -2
  105. package/dist/components/messages/AssistantLocalCommandOutputMessage.js.map +1 -1
  106. package/dist/components/messages/AssistantToolUseMessage.js +3 -1
  107. package/dist/components/messages/AssistantToolUseMessage.js.map +2 -2
  108. package/dist/components/messages/TaskProgressMessage.js.map +2 -2
  109. package/dist/components/messages/TaskToolMessage.js.map +2 -2
  110. package/dist/components/messages/UserToolResultMessage/utils.js.map +2 -2
  111. package/dist/components/permissions/FileEditPermissionRequest/FileEditToolDiff.js.map +2 -2
  112. package/dist/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.js.map +2 -2
  113. package/dist/components/permissions/hooks.js.map +2 -2
  114. package/dist/constants/modelCapabilities.js +1 -1
  115. package/dist/constants/modelCapabilities.js.map +2 -2
  116. package/dist/constants/prompts.js.map +1 -1
  117. package/dist/constants/timing.js +34 -0
  118. package/dist/constants/timing.js.map +7 -0
  119. package/dist/entrypoints/cli.js +128 -33
  120. package/dist/entrypoints/cli.js.map +3 -3
  121. package/dist/entrypoints/mcp.js +13 -18
  122. package/dist/entrypoints/mcp.js.map +2 -2
  123. package/dist/hooks/useCanUseTool.js.map +2 -2
  124. package/dist/hooks/useCancelRequest.js.map +1 -1
  125. package/dist/hooks/useHistorySearch.js.map +2 -2
  126. package/dist/hooks/useLogStartupTime.js.map +2 -2
  127. package/dist/hooks/usePermissionRequestLogging.js.map +2 -2
  128. package/dist/hooks/useTextInput.js.map +1 -1
  129. package/dist/hooks/useUnifiedCompletion.js +493 -394
  130. package/dist/hooks/useUnifiedCompletion.js.map +2 -2
  131. package/dist/index.js.map +2 -2
  132. package/dist/permissions.js +4 -7
  133. package/dist/permissions.js.map +2 -2
  134. package/dist/query.js +6 -1
  135. package/dist/query.js.map +2 -2
  136. package/dist/screens/REPL.js +72 -36
  137. package/dist/screens/REPL.js.map +2 -2
  138. package/dist/screens/ResumeConversation.js +2 -1
  139. package/dist/screens/ResumeConversation.js.map +2 -2
  140. package/dist/services/adapters/base.js.map +2 -2
  141. package/dist/services/adapters/chatCompletions.js.map +2 -2
  142. package/dist/services/adapters/responsesAPI.js +3 -1
  143. package/dist/services/adapters/responsesAPI.js.map +2 -2
  144. package/dist/services/claude.js +327 -328
  145. package/dist/services/claude.js.map +2 -2
  146. package/dist/services/customCommands.js +6 -1
  147. package/dist/services/customCommands.js.map +2 -2
  148. package/dist/services/fileFreshness.js.map +2 -2
  149. package/dist/services/gpt5ConnectionTest.js +20 -7
  150. package/dist/services/gpt5ConnectionTest.js.map +2 -2
  151. package/dist/services/hookExecutor.js +6 -12
  152. package/dist/services/hookExecutor.js.map +2 -2
  153. package/dist/services/mcpClient.js +29 -2
  154. package/dist/services/mcpClient.js.map +2 -2
  155. package/dist/services/mentionProcessor.js +23 -10
  156. package/dist/services/mentionProcessor.js.map +2 -2
  157. package/dist/services/modelAdapterFactory.js.map +2 -2
  158. package/dist/services/oauth.js.map +2 -2
  159. package/dist/services/openai.js +109 -72
  160. package/dist/services/openai.js.map +3 -3
  161. package/dist/services/responseStateManager.js.map +2 -2
  162. package/dist/services/systemReminder.js.map +2 -2
  163. package/dist/tools/ArchitectTool/ArchitectTool.js.map +1 -1
  164. package/dist/tools/AskExpertModelTool/AskExpertModelTool.js +14 -8
  165. package/dist/tools/AskExpertModelTool/AskExpertModelTool.js.map +2 -2
  166. package/dist/tools/BashOutputTool/BashOutputTool.js.map +2 -2
  167. package/dist/tools/BashTool/BashTool.js.map +2 -2
  168. package/dist/tools/FileReadTool/FileReadTool.js.map +1 -1
  169. package/dist/tools/FileWriteTool/FileWriteTool.js.map +2 -2
  170. package/dist/tools/GrepTool/GrepTool.js +1 -4
  171. package/dist/tools/GrepTool/GrepTool.js.map +2 -2
  172. package/dist/tools/MultiEditTool/MultiEditTool.js +4 -1
  173. package/dist/tools/MultiEditTool/MultiEditTool.js.map +2 -2
  174. package/dist/tools/NotebookReadTool/NotebookReadTool.js +3 -1
  175. package/dist/tools/NotebookReadTool/NotebookReadTool.js.map +2 -2
  176. package/dist/tools/SkillTool/SkillTool.js +12 -6
  177. package/dist/tools/SkillTool/SkillTool.js.map +2 -2
  178. package/dist/tools/TaskTool/TaskTool.js +14 -5
  179. package/dist/tools/TaskTool/TaskTool.js.map +2 -2
  180. package/dist/tools/TaskTool/prompt.js.map +2 -2
  181. package/dist/tools/ThinkTool/ThinkTool.js +6 -1
  182. package/dist/tools/ThinkTool/ThinkTool.js.map +2 -2
  183. package/dist/tools/TodoWriteTool/TodoWriteTool.js +23 -3
  184. package/dist/tools/TodoWriteTool/TodoWriteTool.js.map +2 -2
  185. package/dist/tools/URLFetcherTool/URLFetcherTool.js +2 -2
  186. package/dist/tools/URLFetcherTool/URLFetcherTool.js.map +2 -2
  187. package/dist/tools/URLFetcherTool/cache.js +6 -3
  188. package/dist/tools/URLFetcherTool/cache.js.map +2 -2
  189. package/dist/tools/URLFetcherTool/htmlToMarkdown.js +3 -1
  190. package/dist/tools/URLFetcherTool/htmlToMarkdown.js.map +2 -2
  191. package/dist/tools/WebSearchTool/WebSearchTool.js.map +2 -2
  192. package/dist/tools/WebSearchTool/prompt.js.map +2 -2
  193. package/dist/tools/WebSearchTool/searchProviders.js +15 -6
  194. package/dist/tools/WebSearchTool/searchProviders.js.map +2 -2
  195. package/dist/tools.js +4 -1
  196. package/dist/tools.js.map +2 -2
  197. package/dist/types/core.js +1 -0
  198. package/dist/types/core.js.map +7 -0
  199. package/dist/types/hooks.js +1 -4
  200. package/dist/types/hooks.js.map +2 -2
  201. package/dist/types/marketplace.js +8 -2
  202. package/dist/types/marketplace.js.map +2 -2
  203. package/dist/types/plugin.js +9 -6
  204. package/dist/types/plugin.js.map +2 -2
  205. package/dist/utils/BackgroundShellManager.js +76 -10
  206. package/dist/utils/BackgroundShellManager.js.map +2 -2
  207. package/dist/utils/PersistentShell.js +7 -2
  208. package/dist/utils/PersistentShell.js.map +2 -2
  209. package/dist/utils/advancedFuzzyMatcher.js +4 -1
  210. package/dist/utils/advancedFuzzyMatcher.js.map +2 -2
  211. package/dist/utils/agentLoader.js +69 -35
  212. package/dist/utils/agentLoader.js.map +2 -2
  213. package/dist/utils/agentStorage.js.map +2 -2
  214. package/dist/utils/async.js +163 -0
  215. package/dist/utils/async.js.map +7 -0
  216. package/dist/utils/autoUpdater.js +8 -2
  217. package/dist/utils/autoUpdater.js.map +2 -2
  218. package/dist/utils/commands.js +23 -11
  219. package/dist/utils/commands.js.map +2 -2
  220. package/dist/utils/commonUnixCommands.js +3 -1
  221. package/dist/utils/commonUnixCommands.js.map +2 -2
  222. package/dist/utils/compressionMode.js.map +2 -2
  223. package/dist/utils/config.js +30 -14
  224. package/dist/utils/config.js.map +2 -2
  225. package/dist/utils/debugLogger.js.map +2 -2
  226. package/dist/utils/env.js.map +2 -2
  227. package/dist/utils/envConfig.js +82 -0
  228. package/dist/utils/envConfig.js.map +7 -0
  229. package/dist/utils/errorHandling.js +89 -0
  230. package/dist/utils/errorHandling.js.map +7 -0
  231. package/dist/utils/expertChatStorage.js.map +2 -2
  232. package/dist/utils/fuzzyMatcher.js +13 -7
  233. package/dist/utils/fuzzyMatcher.js.map +2 -2
  234. package/dist/utils/hookManager.js +14 -4
  235. package/dist/utils/hookManager.js.map +2 -2
  236. package/dist/utils/log.js.map +2 -2
  237. package/dist/utils/marketplaceManager.js +44 -9
  238. package/dist/utils/marketplaceManager.js.map +2 -2
  239. package/dist/utils/messageContextManager.js.map +1 -1
  240. package/dist/utils/messages.js +6 -3
  241. package/dist/utils/messages.js.map +2 -2
  242. package/dist/utils/model.js +3 -1
  243. package/dist/utils/model.js.map +2 -2
  244. package/dist/utils/pluginInstaller.js +3 -15
  245. package/dist/utils/pluginInstaller.js.map +2 -2
  246. package/dist/utils/pluginLoader.js +41 -13
  247. package/dist/utils/pluginLoader.js.map +2 -2
  248. package/dist/utils/pluginRegistry.js.map +2 -2
  249. package/dist/utils/pluginValidator.js +71 -49
  250. package/dist/utils/pluginValidator.js.map +2 -2
  251. package/dist/utils/ptyCompat.js.map +2 -2
  252. package/dist/utils/roundConverter.js.map +2 -2
  253. package/dist/utils/secureFile.js +43 -14
  254. package/dist/utils/secureFile.js.map +2 -2
  255. package/dist/utils/sessionState.js.map +2 -2
  256. package/dist/utils/skillLoader.js.map +2 -2
  257. package/dist/utils/teamConfig.js +7 -4
  258. package/dist/utils/teamConfig.js.map +2 -2
  259. package/dist/utils/theme.js.map +2 -2
  260. package/dist/utils/thinking.js.map +2 -2
  261. package/dist/utils/unaryLogging.js.map +2 -2
  262. package/dist/version.js +2 -2
  263. package/dist/version.js.map +1 -1
  264. package/package.json +5 -5
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/constants/prompts.ts"],
4
- "sourcesContent": ["import { env } from '@utils/env'\nimport { getIsGit } from '@utils/git'\nimport {\n INTERRUPT_MESSAGE,\n INTERRUPT_MESSAGE_FOR_TOOL_USE,\n} from '@utils/messages'\nimport { getCwd } from '@utils/state'\nimport { PRODUCT_NAME, PROJECT_FILE, PRODUCT_COMMAND } from './product'\nimport { BashTool } from '@tools/BashTool/BashTool'\nimport { MACRO } from './macros'\n\n// // Security policy constant matching reference implementation \n// export const SECURITY_POLICY =\n// 'IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation.'\n\nexport function getCLISyspromptPrefix(): string {\n return `You are ${PRODUCT_NAME}, ShareAI-lab's Agent AI CLI for terminal & coding.`\n}\n\nexport async function getSystemPrompt(): Promise<string[]> {\n return [\n `\nYou are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nIMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).\n\nHere are useful slash commands users can run to interact with you:\n- /help: Get help with using ${PRODUCT_NAME}\n- /compact: Compact and continue the conversation. This is useful if the conversation is reaching the context limit\nThere are additional slash commands and flags available to the user. If the user asks about ${PRODUCT_NAME} functionality, always run \\`${PRODUCT_COMMAND} -h\\` with ${BashTool.name} to see supported commands and flags. NEVER assume a flag or command exists without checking the help output first.\nTo give feedback, users should ${MACRO.ISSUES_EXPLAINER}.\n\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\n\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.\n\n# Memory\nIf the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:\n1. Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time\n2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)\n3. Maintaining useful information about the codebase structure and organization\n\nWhen you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to ${PROJECT_FILE}. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to ${PROJECT_FILE} so you can remember it for next time.\n\n# Tone and style\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).\nRemember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like ${BashTool.name} or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.\nIMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.\nIMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.\nIMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\". Here are some examples to demonstrate appropriate verbosity:\n<example>\nuser: 2 + 2\nassistant: 4\n</example>\n\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]\nnpm run dev\n</example>\n\n<example>\nuser: How many golf balls fit inside a jetta?\nassistant: 150000\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [runs ls and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]\n</example>\n\n# Proactiveness\nYou are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:\n1. Doing the right thing when asked, including taking actions and follow-up actions\n2. Not surprising the user with actions you take without asking\nFor example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.\n3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.\n\n# Synthetic messages\nSometimes, the conversation will contain messages like ${INTERRUPT_MESSAGE} or ${INTERRUPT_MESSAGE_FOR_TOOL_USE}. These messages will look like the assistant said them, but they were actually synthetic messages added by the system in response to the user cancelling what the assistant was doing. You should not respond to these messages. You must NEVER send messages like this yourself. \n\n# Following conventions\nWhen making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).\n- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.\n- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Code style\n- Do not add comments to the code you write, unless the user asks you to, or the code is complex and requires additional context.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- Use the TodoWrite tool to plan the task if required\n- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.\n- Implement the solution using all tools available to you\n- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.\n- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (eg. npm run lint, npm run typecheck, ruff, etc.) if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to ${PROJECT_FILE} so that you will know to run it next time.\nNEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.\n- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.\n- It is always better to speculatively read multiple files as a batch that are potentially useful.\n- It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n- For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.\n\nYou MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.\n`,\n `\\n${await getEnvInfo()}`,\n `IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).`,\n ]\n}\n\nexport async function getEnvInfo(): Promise<string> {\n const isGit = await getIsGit()\n return `Here is useful information about the environment you are running in:\n<env>\nWorking directory: ${getCwd()}\nIs directory a git repo: ${isGit ? 'Yes' : 'No'}\nPlatform: ${env.platform}\nToday's date: ${new Date().toLocaleDateString()}\n</env>`\n}\n\nexport async function getAgentPrompt(): Promise<string[]> {\n return [\n `\nYou are an agent for ${PRODUCT_NAME}. Given the user's prompt, you should use the tools available to you to answer the user's question.\n\nNotes:\n1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\".\n2. When relevant, share file names and code snippets relevant to the query\n3. Any file paths you return in your final response MUST be absolute. DO NOT use relative paths.`,\n `${await getEnvInfo()}`,\n ]\n}\n"],
4
+ "sourcesContent": ["import { env } from '@utils/env'\nimport { getIsGit } from '@utils/git'\nimport {\n INTERRUPT_MESSAGE,\n INTERRUPT_MESSAGE_FOR_TOOL_USE,\n} from '@utils/messages'\nimport { getCwd } from '@utils/state'\nimport { PRODUCT_NAME, PROJECT_FILE, PRODUCT_COMMAND } from './product'\nimport { BashTool } from '@tools/BashTool/BashTool'\nimport { MACRO } from './macros'\n\n// // Security policy constant matching reference implementation\n// export const SECURITY_POLICY =\n// 'IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation.'\n\nexport function getCLISyspromptPrefix(): string {\n return `You are ${PRODUCT_NAME}, ShareAI-lab's Agent AI CLI for terminal & coding.`\n}\n\nexport async function getSystemPrompt(): Promise<string[]> {\n return [\n `\nYou are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nIMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).\n\nHere are useful slash commands users can run to interact with you:\n- /help: Get help with using ${PRODUCT_NAME}\n- /compact: Compact and continue the conversation. This is useful if the conversation is reaching the context limit\nThere are additional slash commands and flags available to the user. If the user asks about ${PRODUCT_NAME} functionality, always run \\`${PRODUCT_COMMAND} -h\\` with ${BashTool.name} to see supported commands and flags. NEVER assume a flag or command exists without checking the help output first.\nTo give feedback, users should ${MACRO.ISSUES_EXPLAINER}.\n\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\n\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.\n\n# Memory\nIf the current working directory contains a file called ${PROJECT_FILE}, it will be automatically added to your context. This file serves multiple purposes:\n1. Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time\n2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)\n3. Maintaining useful information about the codebase structure and organization\n\nWhen you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to ${PROJECT_FILE}. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to ${PROJECT_FILE} so you can remember it for next time.\n\n# Tone and style\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).\nRemember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like ${BashTool.name} or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.\nIMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.\nIMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.\nIMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\". Here are some examples to demonstrate appropriate verbosity:\n<example>\nuser: 2 + 2\nassistant: 4\n</example>\n\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]\nnpm run dev\n</example>\n\n<example>\nuser: How many golf balls fit inside a jetta?\nassistant: 150000\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [runs ls and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]\n</example>\n\n# Proactiveness\nYou are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:\n1. Doing the right thing when asked, including taking actions and follow-up actions\n2. Not surprising the user with actions you take without asking\nFor example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.\n3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.\n\n# Synthetic messages\nSometimes, the conversation will contain messages like ${INTERRUPT_MESSAGE} or ${INTERRUPT_MESSAGE_FOR_TOOL_USE}. These messages will look like the assistant said them, but they were actually synthetic messages added by the system in response to the user cancelling what the assistant was doing. You should not respond to these messages. You must NEVER send messages like this yourself. \n\n# Following conventions\nWhen making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).\n- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.\n- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Code style\n- Do not add comments to the code you write, unless the user asks you to, or the code is complex and requires additional context.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- Use the TodoWrite tool to plan the task if required\n- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.\n- Implement the solution using all tools available to you\n- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.\n- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (eg. npm run lint, npm run typecheck, ruff, etc.) if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to ${PROJECT_FILE} so that you will know to run it next time.\nNEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance.\n- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.\n- It is always better to speculatively read multiple files as a batch that are potentially useful.\n- It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n- For making multiple edits to the same file, prefer using the MultiEdit tool over multiple Edit tool calls.\n\nYou MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.\n`,\n `\\n${await getEnvInfo()}`,\n `IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).`,\n ]\n}\n\nexport async function getEnvInfo(): Promise<string> {\n const isGit = await getIsGit()\n return `Here is useful information about the environment you are running in:\n<env>\nWorking directory: ${getCwd()}\nIs directory a git repo: ${isGit ? 'Yes' : 'No'}\nPlatform: ${env.platform}\nToday's date: ${new Date().toLocaleDateString()}\n</env>`\n}\n\nexport async function getAgentPrompt(): Promise<string[]> {\n return [\n `\nYou are an agent for ${PRODUCT_NAME}. Given the user's prompt, you should use the tools available to you to answer the user's question.\n\nNotes:\n1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\".\n2. When relevant, share file names and code snippets relevant to the query\n3. Any file paths you return in your final response MUST be absolute. DO NOT use relative paths.`,\n `${await getEnvInfo()}`,\n ]\n}\n"],
5
5
  "mappings": "AAAA,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,cAAc,cAAc,uBAAuB;AAC5D,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAMf,SAAS,wBAAgC;AAC9C,SAAO,WAAW,YAAY;AAChC;AAEA,eAAsB,kBAAqC;AACzD,SAAO;AAAA,IACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAO2B,YAAY;AAAA;AAAA,8FAEmD,YAAY,gCAAgC,eAAe,cAAc,SAAS,IAAI;AAAA,iCACnJ,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0DASG,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,+IAKyE,YAAY,8HAA8H,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,qKAKhI,SAAS,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yDAwDzH,iBAAiB,OAAO,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4VAkB6O,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAepW;AAAA,EAAK,MAAM,WAAW,CAAC;AAAA,IACvB;AAAA;AAAA,EAEF;AACF;AAEA,eAAsB,aAA8B;AAClD,QAAM,QAAQ,MAAM,SAAS;AAC7B,SAAO;AAAA;AAAA,qBAEY,OAAO,CAAC;AAAA,2BACF,QAAQ,QAAQ,IAAI;AAAA,YACnC,IAAI,QAAQ;AAAA,iBACR,oBAAI,KAAK,GAAE,mBAAmB,CAAC;AAAA;AAE/C;AAEA,eAAsB,iBAAoC;AACxD,SAAO;AAAA,IACL;AAAA,uBACmB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAM/B,GAAG,MAAM,WAAW,CAAC;AAAA,EACvB;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,34 @@
1
+ const TIMING = {
2
+ // Network and API timeouts
3
+ CONNECTION_TIMEOUT_MS: 5e3,
4
+ HTTP_TIMEOUT_MS: 3e4,
5
+ SHUTDOWN_TIMEOUT_MS: 3e3,
6
+ CONTEXT_FETCH_TIMEOUT_MS: 3e3,
7
+ ENV_CHECK_TIMEOUT_MS: 1e3,
8
+ // Retry configuration
9
+ BASE_DELAY_MS: 500,
10
+ MAX_RETRIES: 3,
11
+ MAX_DELAY_MS: 32e3,
12
+ MAX_SERVER_DELAY_MS: 6e4,
13
+ // UI notification timeouts
14
+ NOTIFICATION_SHORT_MS: 1e3,
15
+ NOTIFICATION_MEDIUM_MS: 2e3,
16
+ NOTIFICATION_LONG_MS: 3e3,
17
+ NOTIFICATION_VERY_LONG_MS: 5e3,
18
+ NOTIFICATION_THRESHOLD_MS: 6e3,
19
+ // User interaction
20
+ DOUBLE_PRESS_TIMEOUT_MS: 1e3,
21
+ HOTKEY_MESSAGE_TIMEOUT_MS: 2e3,
22
+ // Background operations
23
+ BACKGROUND_POLL_INTERVAL_MS: 1e3,
24
+ API_TEST_DELAY_MS: 1e3,
25
+ // Debug and logging
26
+ LOG_DEDUPE_WINDOW_MS: 5e3,
27
+ // Cleanup and maintenance
28
+ THIRTY_DAYS_MS: 30 * 24 * 60 * 60 * 1e3,
29
+ FILE_TOLERANCE_MS: 100
30
+ };
31
+ export {
32
+ TIMING
33
+ };
34
+ //# sourceMappingURL=timing.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/constants/timing.ts"],
4
+ "sourcesContent": ["/**\n * Centralized timing constants for consistent timeout and delay values.\n * Consolidates magic numbers scattered across the codebase.\n */\n\nexport const TIMING = {\n // Network and API timeouts\n CONNECTION_TIMEOUT_MS: 5000,\n HTTP_TIMEOUT_MS: 30000,\n SHUTDOWN_TIMEOUT_MS: 3000,\n CONTEXT_FETCH_TIMEOUT_MS: 3000,\n ENV_CHECK_TIMEOUT_MS: 1000,\n\n // Retry configuration\n BASE_DELAY_MS: 500,\n MAX_RETRIES: 3,\n MAX_DELAY_MS: 32000,\n MAX_SERVER_DELAY_MS: 60000,\n\n // UI notification timeouts\n NOTIFICATION_SHORT_MS: 1000,\n NOTIFICATION_MEDIUM_MS: 2000,\n NOTIFICATION_LONG_MS: 3000,\n NOTIFICATION_VERY_LONG_MS: 5000,\n NOTIFICATION_THRESHOLD_MS: 6000,\n\n // User interaction\n DOUBLE_PRESS_TIMEOUT_MS: 1000,\n HOTKEY_MESSAGE_TIMEOUT_MS: 2000,\n\n // Background operations\n BACKGROUND_POLL_INTERVAL_MS: 1000,\n API_TEST_DELAY_MS: 1000,\n\n // Debug and logging\n LOG_DEDUPE_WINDOW_MS: 5000,\n\n // Cleanup and maintenance\n THIRTY_DAYS_MS: 30 * 24 * 60 * 60 * 1000,\n FILE_TOLERANCE_MS: 100,\n} as const\n\nexport type TimingKey = keyof typeof TIMING\n"],
5
+ "mappings": "AAKO,MAAM,SAAS;AAAA;AAAA,EAEpB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,sBAAsB;AAAA;AAAA,EAGtB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,cAAc;AAAA,EACd,qBAAqB;AAAA;AAAA,EAGrB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA,EAC3B,2BAA2B;AAAA;AAAA,EAG3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA;AAAA,EAG3B,6BAA6B;AAAA,EAC7B,mBAAmB;AAAA;AAAA,EAGnB,sBAAsB;AAAA;AAAA,EAGtB,gBAAgB,KAAK,KAAK,KAAK,KAAK;AAAA,EACpC,mBAAmB;AACrB;",
6
+ "names": []
7
+ }
@@ -24,10 +24,7 @@ Object.keys(dontcare);
24
24
  import React from "react";
25
25
  import { ReadStream } from "tty";
26
26
  import { openSync } from "fs";
27
- import {
28
- validateRawModeSupport,
29
- requireRawModeOrExit
30
- } from "../utils/ptyCompat.js";
27
+ import { validateRawModeSupport, requireRawModeOrExit } from "../utils/ptyCompat.js";
31
28
  import { addToHistory } from "../history.js";
32
29
  import { getContext, setContext, removeContext } from "../context.js";
33
30
  import { Command } from "@commander-js/extra-typings";
@@ -50,7 +47,6 @@ import { cwd } from "process";
50
47
  import { dateToFilename, logError, parseLogFilename } from "../utils/log.js";
51
48
  import { initDebugLogger } from "../utils/debugLogger.js";
52
49
  import { Onboarding } from "../components/Onboarding.js";
53
- import { Doctor } from "../screens/Doctor.js";
54
50
  import { TrustDialog } from "../components/TrustDialog.js";
55
51
  import { checkHasTrustDialogAccepted } from "../utils/config.js";
56
52
  import { isDefaultSlowAndCapableModel } from "../utils/model.js";
@@ -74,11 +70,16 @@ import {
74
70
  parseEnvVars,
75
71
  removeMcpServer,
76
72
  getClients,
77
- ensureConfigScope
73
+ ensureConfigScope,
74
+ shutdownMCPClients
78
75
  } from "../services/mcpClient.js";
79
76
  import { handleMcprcServerApprovals } from "../services/mcpServerApproval.js";
80
77
  import { cursorShow } from "ansi-escapes";
81
- import { getLatestVersion, assertMinVersion, getUpdateCommandSuggestions } from "../utils/autoUpdater.js";
78
+ import {
79
+ getLatestVersion,
80
+ assertMinVersion,
81
+ getUpdateCommandSuggestions
82
+ } from "../utils/autoUpdater.js";
82
83
  import { gt } from "semver";
83
84
  import { CACHE_PATHS } from "../utils/log.js";
84
85
  import { PersistentShell } from "../utils/PersistentShell.js";
@@ -102,7 +103,9 @@ async function showSetupScreens(safeMode, print, rawModeSupported) {
102
103
  const config = getGlobalConfig();
103
104
  if (!config.theme || !config.hasCompletedOnboarding) {
104
105
  if (rawModeSupported === false) {
105
- console.log("\u26A0\uFE0F Interactive onboarding is not supported in this terminal environment");
106
+ console.log(
107
+ "\u26A0\uFE0F Interactive onboarding is not supported in this terminal environment"
108
+ );
106
109
  console.log("\u2728 Auto-configuring with default settings...");
107
110
  console.log("");
108
111
  saveGlobalConfig({
@@ -113,7 +116,9 @@ async function showSetupScreens(safeMode, print, rawModeSupported) {
113
116
  lastOnboardingVersion: MACRO.VERSION
114
117
  });
115
118
  console.log("\u2705 Configuration completed automatically");
116
- console.log("\u{1F4A1} You can customize settings later with: minto config set -g <key> <value>");
119
+ console.log(
120
+ "\u{1F4A1} You can customize settings later with: minto config set -g <key> <value>"
121
+ );
117
122
  console.log("");
118
123
  return;
119
124
  }
@@ -222,7 +227,9 @@ if (process.env.NODE_ENV !== "test") {
222
227
  console.error(` Error: ${error.message}`);
223
228
  console.error("");
224
229
  console.error("This error typically occurs in:");
225
- console.error(" \u2022 Docker containers without proper TTY allocation (-it flags)");
230
+ console.error(
231
+ " \u2022 Docker containers without proper TTY allocation (-it flags)"
232
+ );
226
233
  console.error(" \u2022 VS Code integrated terminal (some configurations)");
227
234
  console.error(" \u2022 SSH sessions with incomplete TTY forwarding");
228
235
  console.error(" \u2022 Nested tmux/screen sessions");
@@ -253,7 +260,9 @@ async function main() {
253
260
  try {
254
261
  const repairResult = validateAndRepairAllGPT5Profiles();
255
262
  if (repairResult.repaired > 0) {
256
- console.log(`\u{1F527} Auto-repaired ${repairResult.repaired} GPT-5 model configurations`);
263
+ console.log(
264
+ `\u{1F527} Auto-repaired ${repairResult.repaired} GPT-5 model configurations`
265
+ );
257
266
  }
258
267
  } catch (repairError) {
259
268
  console.warn("\u26A0\uFE0F GPT-5 configuration validation failed:", repairError);
@@ -287,12 +296,16 @@ async function main() {
287
296
  renderContext.rawModeSupported = rawModeCheck.supported;
288
297
  renderContext.fallbackMode = !rawModeCheck.supported;
289
298
  if (!rawModeCheck.supported) {
290
- console.warn("\u26A0\uFE0F Interactive mode unavailable: terminal does not support raw mode");
299
+ console.warn(
300
+ "\u26A0\uFE0F Interactive mode unavailable: terminal does not support raw mode"
301
+ );
291
302
  console.warn(` Reason: ${rawModeCheck.reason}`);
292
303
  if (rawModeCheck.environmentHint) {
293
304
  console.warn(` Environment: ${rawModeCheck.environmentHint}`);
294
305
  }
295
- console.warn(" Note: Use --print for non-interactive mode or see error message if REPL fails");
306
+ console.warn(
307
+ " Note: Use --print for non-interactive mode or see error message if REPL fails"
308
+ );
296
309
  console.warn("");
297
310
  }
298
311
  await parseArgs(inputPrompt, renderContext, rawModeCheck.supported);
@@ -326,8 +339,25 @@ ${commandList}`
326
339
  "--safe",
327
340
  "Enable strict permission checking mode (default is permissive)",
328
341
  () => true
342
+ ).option(
343
+ "-n, --new",
344
+ "Start a new conversation (skip auto-resume)",
345
+ () => true
346
+ ).option(
347
+ "-r, --resume",
348
+ "Select a previous conversation to resume",
349
+ () => true
329
350
  ).action(
330
- async (prompt, { cwd: cwd2, debug, verbose, enableArchitect, print, safe }) => {
351
+ async (prompt, {
352
+ cwd: cwd2,
353
+ debug,
354
+ verbose,
355
+ enableArchitect,
356
+ print,
357
+ safe,
358
+ new: startNew,
359
+ resume: selectResume
360
+ }) => {
331
361
  await showSetupScreens(safe, print, rawModeSupported);
332
362
  await setup(cwd2, safe);
333
363
  assertMinVersion();
@@ -368,11 +398,63 @@ ${commandList}`
368
398
  }
369
399
  } catch {
370
400
  }
371
- return { version: null, commands: null };
401
+ return {
402
+ version: null,
403
+ commands: null
404
+ };
372
405
  })();
373
406
  if (renderContext?.fallbackMode) {
374
407
  requireRawModeOrExit(process.stdin, true);
375
408
  }
409
+ if (selectResume) {
410
+ const logs = await loadLogList(CACHE_PATHS.messages());
411
+ const context2 = {};
412
+ const { render } = await import("ink");
413
+ const { unmount } = render(
414
+ /* @__PURE__ */ React.createElement(
415
+ ResumeConversation,
416
+ {
417
+ context: context2,
418
+ commands,
419
+ logs,
420
+ tools,
421
+ verbose
422
+ }
423
+ ),
424
+ { ...renderContext, exitOnCtrlC: true }
425
+ );
426
+ context2.unmount = unmount;
427
+ return;
428
+ }
429
+ let messageLogName = dateToFilename(/* @__PURE__ */ new Date());
430
+ let initialMessages;
431
+ let initialForkNumber;
432
+ if (!startNew && !inputPrompt) {
433
+ try {
434
+ const logs = await loadLogList(CACHE_PATHS.messages());
435
+ for (const log of logs) {
436
+ try {
437
+ const loadedMessages = await loadMessagesFromLog(
438
+ log.fullPath,
439
+ tools
440
+ );
441
+ if (loadedMessages && loadedMessages.length > 0) {
442
+ initialMessages = loadedMessages;
443
+ messageLogName = log.date;
444
+ initialForkNumber = getNextAvailableLogForkNumber(
445
+ log.date,
446
+ log.forkNumber ?? 1,
447
+ 0
448
+ );
449
+ break;
450
+ }
451
+ } catch {
452
+ continue;
453
+ }
454
+ }
455
+ } catch {
456
+ }
457
+ }
376
458
  {
377
459
  const { render } = await import("ink");
378
460
  const { REPL } = await import("../screens/REPL.js");
@@ -383,7 +465,9 @@ ${commandList}`
383
465
  commands,
384
466
  debug,
385
467
  initialPrompt: inputPrompt,
386
- messageLogName: dateToFilename(/* @__PURE__ */ new Date()),
468
+ messageLogName,
469
+ initialForkNumber,
470
+ initialMessages,
387
471
  shouldShowPromptInput: true,
388
472
  verbose,
389
473
  tools,
@@ -424,7 +508,11 @@ ${commandList}`
424
508
  config.command("list").description("List all config values").option("-c, --cwd <cwd>", "The current working directory", String, cwd()).option("-g, --global", "Use global config", false).action(async ({ cwd: cwd2, global }) => {
425
509
  await setup(cwd2, false);
426
510
  console.log(
427
- JSON.stringify(global ? listConfigForCLI(true) : listConfigForCLI(false), null, 2)
511
+ JSON.stringify(
512
+ global ? listConfigForCLI(true) : listConfigForCLI(false),
513
+ null,
514
+ 2
515
+ )
428
516
  );
429
517
  process.exit(0);
430
518
  });
@@ -766,7 +854,9 @@ ${commandList}`
766
854
  function ClaudeDesktopImport() {
767
855
  const { useState } = reactModule;
768
856
  const [isFinished, setIsFinished] = useState(false);
769
- const [importResults, setImportResults] = useState([]);
857
+ const [importResults, setImportResults] = useState(
858
+ []
859
+ );
770
860
  const [isImporting, setIsImporting] = useState(false);
771
861
  const theme = getTheme();
772
862
  const importServers = async (selectedServers) => {
@@ -891,16 +981,6 @@ ${commandList}`
891
981
  resetMcpChoices();
892
982
  });
893
983
  }
894
- program.command("doctor").description(`Check the health of your ${PRODUCT_NAME} installation`).action(async () => {
895
- await new Promise((resolve) => {
896
- ;
897
- (async () => {
898
- const { render } = await import("ink");
899
- render(/* @__PURE__ */ React.createElement(Doctor, { onDone: () => resolve(), doctorMode: true }));
900
- })();
901
- });
902
- process.exit(0);
903
- });
904
984
  program.command("update").description("Show manual upgrade commands (no auto-install)").action(async () => {
905
985
  console.log(`Current version: ${MACRO.VERSION}`);
906
986
  console.log("Checking for updates...");
@@ -919,7 +999,9 @@ ${commandList}`
919
999
  console.log("\nRun one of the following commands to update:");
920
1000
  for (const c of cmds) console.log(` ${c}`);
921
1001
  if (process.platform !== "win32") {
922
- console.log('\nNote: you may need to prefix with "sudo" on macOS/Linux.');
1002
+ console.log(
1003
+ '\nNote: you may need to prefix with "sudo" on macOS/Linux.'
1004
+ );
923
1005
  }
924
1006
  process.exit(0);
925
1007
  });
@@ -1106,7 +1188,10 @@ process.on("exit", () => {
1106
1188
  resetCursor();
1107
1189
  PersistentShell.getInstance().close();
1108
1190
  });
1109
- function gracefulExit(code = 0) {
1191
+ let isShuttingDown = false;
1192
+ async function gracefulExit(code = 0) {
1193
+ if (isShuttingDown) return;
1194
+ isShuttingDown = true;
1110
1195
  try {
1111
1196
  resetCursor();
1112
1197
  } catch {
@@ -1115,11 +1200,21 @@ function gracefulExit(code = 0) {
1115
1200
  PersistentShell.getInstance().close();
1116
1201
  } catch {
1117
1202
  }
1203
+ try {
1204
+ await shutdownMCPClients();
1205
+ } catch {
1206
+ }
1118
1207
  process.exit(code);
1119
1208
  }
1120
- process.on("SIGINT", () => gracefulExit(0));
1121
- process.on("SIGTERM", () => gracefulExit(0));
1122
- process.on("SIGBREAK", () => gracefulExit(0));
1209
+ process.on("SIGINT", () => {
1210
+ gracefulExit(0);
1211
+ });
1212
+ process.on("SIGTERM", () => {
1213
+ gracefulExit(0);
1214
+ });
1215
+ process.on("SIGBREAK", () => {
1216
+ gracefulExit(0);
1217
+ });
1123
1218
  process.on("unhandledRejection", (err) => {
1124
1219
  console.error("Unhandled rejection:", err);
1125
1220
  gracefulExit(1);