snow-ai 0.4.16 → 0.4.17
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.
- package/bundle/cli.mjs +477445 -0
- package/bundle/sql-wasm.wasm +0 -0
- package/package.json +31 -26
- package/dist/agents/codebaseIndexAgent.d.ts +0 -102
- package/dist/agents/codebaseIndexAgent.js +0 -641
- package/dist/agents/codebaseReviewAgent.d.ts +0 -61
- package/dist/agents/codebaseReviewAgent.js +0 -301
- package/dist/agents/compactAgent.d.ts +0 -55
- package/dist/agents/compactAgent.js +0 -306
- package/dist/agents/promptOptimizeAgent.d.ts +0 -54
- package/dist/agents/promptOptimizeAgent.js +0 -268
- package/dist/agents/reviewAgent.d.ts +0 -50
- package/dist/agents/reviewAgent.js +0 -265
- package/dist/agents/summaryAgent.d.ts +0 -57
- package/dist/agents/summaryAgent.js +0 -260
- package/dist/api/anthropic.d.ts +0 -44
- package/dist/api/anthropic.js +0 -598
- package/dist/api/chat.d.ts +0 -73
- package/dist/api/chat.js +0 -386
- package/dist/api/embedding.d.ts +0 -34
- package/dist/api/embedding.js +0 -80
- package/dist/api/gemini.d.ts +0 -31
- package/dist/api/gemini.js +0 -445
- package/dist/api/models.d.ts +0 -15
- package/dist/api/models.js +0 -139
- package/dist/api/responses.d.ts +0 -38
- package/dist/api/responses.js +0 -515
- package/dist/api/systemPrompt.d.ts +0 -4
- package/dist/api/systemPrompt.js +0 -408
- package/dist/api/types.d.ts +0 -53
- package/dist/api/types.js +0 -4
- package/dist/app.d.ts +0 -8
- package/dist/app.js +0 -112
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -199
- package/dist/hooks/useAgentPicker.d.ts +0 -14
- package/dist/hooks/useAgentPicker.js +0 -119
- package/dist/hooks/useClipboard.d.ts +0 -4
- package/dist/hooks/useClipboard.js +0 -175
- package/dist/hooks/useCommandHandler.d.ts +0 -35
- package/dist/hooks/useCommandHandler.js +0 -346
- package/dist/hooks/useCommandPanel.d.ts +0 -17
- package/dist/hooks/useCommandPanel.js +0 -114
- package/dist/hooks/useConversation.d.ts +0 -49
- package/dist/hooks/useConversation.js +0 -1052
- package/dist/hooks/useFilePicker.d.ts +0 -18
- package/dist/hooks/useFilePicker.js +0 -224
- package/dist/hooks/useGlobalExit.d.ts +0 -5
- package/dist/hooks/useGlobalExit.js +0 -34
- package/dist/hooks/useGlobalNavigation.d.ts +0 -6
- package/dist/hooks/useGlobalNavigation.js +0 -17
- package/dist/hooks/useHistoryNavigation.d.ts +0 -35
- package/dist/hooks/useHistoryNavigation.js +0 -133
- package/dist/hooks/useInputBuffer.d.ts +0 -6
- package/dist/hooks/useInputBuffer.js +0 -45
- package/dist/hooks/useKeyboardInput.d.ts +0 -80
- package/dist/hooks/useKeyboardInput.js +0 -608
- package/dist/hooks/useSessionManagement.d.ts +0 -10
- package/dist/hooks/useSessionManagement.js +0 -43
- package/dist/hooks/useSessionSave.d.ts +0 -8
- package/dist/hooks/useSessionSave.js +0 -63
- package/dist/hooks/useSnapshotState.d.ts +0 -26
- package/dist/hooks/useSnapshotState.js +0 -28
- package/dist/hooks/useStreamingState.d.ts +0 -33
- package/dist/hooks/useStreamingState.js +0 -105
- package/dist/hooks/useTerminalFocus.d.ts +0 -28
- package/dist/hooks/useTerminalFocus.js +0 -87
- package/dist/hooks/useTerminalSize.d.ts +0 -4
- package/dist/hooks/useTerminalSize.js +0 -20
- package/dist/hooks/useTodoPicker.d.ts +0 -16
- package/dist/hooks/useTodoPicker.js +0 -94
- package/dist/hooks/useToolConfirmation.d.ts +0 -19
- package/dist/hooks/useToolConfirmation.js +0 -61
- package/dist/hooks/useVSCodeState.d.ts +0 -8
- package/dist/hooks/useVSCodeState.js +0 -81
- package/dist/i18n/I18nContext.d.ts +0 -14
- package/dist/i18n/I18nContext.js +0 -24
- package/dist/i18n/index.d.ts +0 -3
- package/dist/i18n/index.js +0 -2
- package/dist/i18n/lang/en.d.ts +0 -2
- package/dist/i18n/lang/en.js +0 -502
- package/dist/i18n/lang/es.d.ts +0 -2
- package/dist/i18n/lang/es.js +0 -502
- package/dist/i18n/lang/ja.d.ts +0 -2
- package/dist/i18n/lang/ja.js +0 -502
- package/dist/i18n/lang/ko.d.ts +0 -2
- package/dist/i18n/lang/ko.js +0 -502
- package/dist/i18n/lang/zh-TW.d.ts +0 -2
- package/dist/i18n/lang/zh-TW.js +0 -502
- package/dist/i18n/lang/zh.d.ts +0 -2
- package/dist/i18n/lang/zh.js +0 -502
- package/dist/i18n/translations.d.ts +0 -2
- package/dist/i18n/translations.js +0 -14
- package/dist/i18n/types.d.ts +0 -478
- package/dist/i18n/types.js +0 -1
- package/dist/mcp/aceCodeSearch.d.ts +0 -247
- package/dist/mcp/aceCodeSearch.js +0 -1058
- package/dist/mcp/bash.d.ts +0 -50
- package/dist/mcp/bash.js +0 -153
- package/dist/mcp/codebaseSearch.d.ts +0 -44
- package/dist/mcp/codebaseSearch.js +0 -275
- package/dist/mcp/filesystem.d.ts +0 -392
- package/dist/mcp/filesystem.js +0 -1445
- package/dist/mcp/ideDiagnostics.d.ts +0 -36
- package/dist/mcp/ideDiagnostics.js +0 -90
- package/dist/mcp/notebook.d.ts +0 -10
- package/dist/mcp/notebook.js +0 -367
- package/dist/mcp/subagent.d.ts +0 -37
- package/dist/mcp/subagent.js +0 -113
- package/dist/mcp/todo.d.ts +0 -46
- package/dist/mcp/todo.js +0 -511
- package/dist/mcp/types/aceCodeSearch.types.d.ts +0 -92
- package/dist/mcp/types/aceCodeSearch.types.js +0 -4
- package/dist/mcp/types/bash.types.d.ts +0 -13
- package/dist/mcp/types/bash.types.js +0 -4
- package/dist/mcp/types/filesystem.types.d.ts +0 -210
- package/dist/mcp/types/filesystem.types.js +0 -27
- package/dist/mcp/types/todo.types.d.ts +0 -27
- package/dist/mcp/types/todo.types.js +0 -4
- package/dist/mcp/types/websearch.types.d.ts +0 -30
- package/dist/mcp/types/websearch.types.js +0 -4
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.d.ts +0 -34
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.js +0 -146
- package/dist/mcp/utils/aceCodeSearch/language.utils.d.ts +0 -14
- package/dist/mcp/utils/aceCodeSearch/language.utils.js +0 -418
- package/dist/mcp/utils/aceCodeSearch/search.utils.d.ts +0 -31
- package/dist/mcp/utils/aceCodeSearch/search.utils.js +0 -136
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.d.ts +0 -20
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.js +0 -141
- package/dist/mcp/utils/bash/security.utils.d.ts +0 -20
- package/dist/mcp/utils/bash/security.utils.js +0 -34
- package/dist/mcp/utils/filesystem/batch-operations.utils.d.ts +0 -39
- package/dist/mcp/utils/filesystem/batch-operations.utils.js +0 -182
- package/dist/mcp/utils/filesystem/code-analysis.utils.d.ts +0 -18
- package/dist/mcp/utils/filesystem/code-analysis.utils.js +0 -165
- package/dist/mcp/utils/filesystem/match-finder.utils.d.ts +0 -16
- package/dist/mcp/utils/filesystem/match-finder.utils.js +0 -85
- package/dist/mcp/utils/filesystem/office-parser.utils.d.ts +0 -43
- package/dist/mcp/utils/filesystem/office-parser.utils.js +0 -163
- package/dist/mcp/utils/filesystem/path-fixer.utils.d.ts +0 -7
- package/dist/mcp/utils/filesystem/path-fixer.utils.js +0 -60
- package/dist/mcp/utils/filesystem/similarity.utils.d.ts +0 -22
- package/dist/mcp/utils/filesystem/similarity.utils.js +0 -75
- package/dist/mcp/utils/todo/date.utils.d.ts +0 -9
- package/dist/mcp/utils/todo/date.utils.js +0 -14
- package/dist/mcp/utils/websearch/browser.utils.d.ts +0 -8
- package/dist/mcp/utils/websearch/browser.utils.js +0 -58
- package/dist/mcp/utils/websearch/text.utils.d.ts +0 -16
- package/dist/mcp/utils/websearch/text.utils.js +0 -39
- package/dist/mcp/websearch.d.ts +0 -88
- package/dist/mcp/websearch.js +0 -375
- package/dist/test/logger-test.d.ts +0 -1
- package/dist/test/logger-test.js +0 -7
- package/dist/types/index.d.ts +0 -15
- package/dist/types/index.js +0 -1
- package/dist/ui/components/AgentPickerPanel.d.ts +0 -10
- package/dist/ui/components/AgentPickerPanel.js +0 -74
- package/dist/ui/components/ChatInput.d.ts +0 -46
- package/dist/ui/components/ChatInput.js +0 -384
- package/dist/ui/components/CommandPanel.d.ts +0 -15
- package/dist/ui/components/CommandPanel.js +0 -80
- package/dist/ui/components/DiffViewer.d.ts +0 -11
- package/dist/ui/components/DiffViewer.js +0 -178
- package/dist/ui/components/FileList.d.ts +0 -15
- package/dist/ui/components/FileList.js +0 -360
- package/dist/ui/components/FileRollbackConfirmation.d.ts +0 -8
- package/dist/ui/components/FileRollbackConfirmation.js +0 -108
- package/dist/ui/components/HelpPanel.d.ts +0 -2
- package/dist/ui/components/HelpPanel.js +0 -67
- package/dist/ui/components/MCPInfoPanel.d.ts +0 -2
- package/dist/ui/components/MCPInfoPanel.js +0 -108
- package/dist/ui/components/MCPInfoScreen.d.ts +0 -7
- package/dist/ui/components/MCPInfoScreen.js +0 -115
- package/dist/ui/components/MarkdownRenderer.d.ts +0 -6
- package/dist/ui/components/MarkdownRenderer.js +0 -70
- package/dist/ui/components/Menu.d.ts +0 -17
- package/dist/ui/components/Menu.js +0 -88
- package/dist/ui/components/MessageList.d.ts +0 -56
- package/dist/ui/components/MessageList.js +0 -97
- package/dist/ui/components/PendingMessages.d.ts +0 -13
- package/dist/ui/components/PendingMessages.js +0 -29
- package/dist/ui/components/PendingToolCalls.d.ts +0 -11
- package/dist/ui/components/PendingToolCalls.js +0 -35
- package/dist/ui/components/ScrollableSelectInput.d.ts +0 -29
- package/dist/ui/components/ScrollableSelectInput.js +0 -157
- package/dist/ui/components/SessionListPanel.d.ts +0 -7
- package/dist/ui/components/SessionListPanel.js +0 -175
- package/dist/ui/components/SessionListScreen.d.ts +0 -7
- package/dist/ui/components/SessionListScreen.js +0 -217
- package/dist/ui/components/SessionListScreenWrapper.d.ts +0 -7
- package/dist/ui/components/SessionListScreenWrapper.js +0 -14
- package/dist/ui/components/ShimmerText.d.ts +0 -9
- package/dist/ui/components/ShimmerText.js +0 -30
- package/dist/ui/components/TodoPickerPanel.d.ts +0 -14
- package/dist/ui/components/TodoPickerPanel.js +0 -119
- package/dist/ui/components/TodoTree.d.ts +0 -15
- package/dist/ui/components/TodoTree.js +0 -60
- package/dist/ui/components/ToolConfirmation.d.ts +0 -21
- package/dist/ui/components/ToolConfirmation.js +0 -204
- package/dist/ui/components/ToolResultPreview.d.ts +0 -13
- package/dist/ui/components/ToolResultPreview.js +0 -337
- package/dist/ui/components/UsagePanel.d.ts +0 -2
- package/dist/ui/components/UsagePanel.js +0 -394
- package/dist/ui/contexts/ThemeContext.d.ts +0 -13
- package/dist/ui/contexts/ThemeContext.js +0 -28
- package/dist/ui/pages/ChatScreen.d.ts +0 -6
- package/dist/ui/pages/ChatScreen.js +0 -1519
- package/dist/ui/pages/CodeBaseConfigScreen.d.ts +0 -8
- package/dist/ui/pages/CodeBaseConfigScreen.js +0 -350
- package/dist/ui/pages/ConfigScreen.d.ts +0 -8
- package/dist/ui/pages/ConfigScreen.js +0 -1101
- package/dist/ui/pages/CustomHeadersScreen.d.ts +0 -6
- package/dist/ui/pages/CustomHeadersScreen.js +0 -502
- package/dist/ui/pages/HeadlessModeScreen.d.ts +0 -7
- package/dist/ui/pages/HeadlessModeScreen.js +0 -381
- package/dist/ui/pages/LanguageSettingsScreen.d.ts +0 -7
- package/dist/ui/pages/LanguageSettingsScreen.js +0 -91
- package/dist/ui/pages/MCPConfigScreen.d.ts +0 -6
- package/dist/ui/pages/MCPConfigScreen.js +0 -55
- package/dist/ui/pages/ProxyConfigScreen.d.ts +0 -8
- package/dist/ui/pages/ProxyConfigScreen.js +0 -149
- package/dist/ui/pages/SensitiveCommandConfigScreen.d.ts +0 -7
- package/dist/ui/pages/SensitiveCommandConfigScreen.js +0 -271
- package/dist/ui/pages/SubAgentConfigScreen.d.ts +0 -9
- package/dist/ui/pages/SubAgentConfigScreen.js +0 -435
- package/dist/ui/pages/SubAgentListScreen.d.ts +0 -9
- package/dist/ui/pages/SubAgentListScreen.js +0 -131
- package/dist/ui/pages/SystemPromptConfigScreen.d.ts +0 -6
- package/dist/ui/pages/SystemPromptConfigScreen.js +0 -326
- package/dist/ui/pages/ThemeSettingsScreen.d.ts +0 -7
- package/dist/ui/pages/ThemeSettingsScreen.js +0 -106
- package/dist/ui/pages/WelcomeScreen.d.ts +0 -7
- package/dist/ui/pages/WelcomeScreen.js +0 -217
- package/dist/ui/themes/index.d.ts +0 -23
- package/dist/ui/themes/index.js +0 -140
- package/dist/utils/apiConfig.d.ts +0 -126
- package/dist/utils/apiConfig.js +0 -423
- package/dist/utils/autoCompress.d.ts +0 -15
- package/dist/utils/autoCompress.js +0 -24
- package/dist/utils/chatExporter.d.ts +0 -9
- package/dist/utils/chatExporter.js +0 -118
- package/dist/utils/checkpointManager.d.ts +0 -74
- package/dist/utils/checkpointManager.js +0 -181
- package/dist/utils/codebaseConfig.d.ts +0 -16
- package/dist/utils/codebaseConfig.js +0 -67
- package/dist/utils/codebaseDatabase.d.ts +0 -102
- package/dist/utils/codebaseDatabase.js +0 -333
- package/dist/utils/codebaseSearchEvents.d.ts +0 -16
- package/dist/utils/codebaseSearchEvents.js +0 -13
- package/dist/utils/commandExecutor.d.ts +0 -13
- package/dist/utils/commandExecutor.js +0 -26
- package/dist/utils/commands/agent.d.ts +0 -2
- package/dist/utils/commands/agent.js +0 -12
- package/dist/utils/commands/clear.d.ts +0 -2
- package/dist/utils/commands/clear.js +0 -12
- package/dist/utils/commands/compact.d.ts +0 -2
- package/dist/utils/commands/compact.js +0 -12
- package/dist/utils/commands/export.d.ts +0 -2
- package/dist/utils/commands/export.js +0 -12
- package/dist/utils/commands/help.d.ts +0 -2
- package/dist/utils/commands/help.js +0 -11
- package/dist/utils/commands/home.d.ts +0 -2
- package/dist/utils/commands/home.js +0 -34
- package/dist/utils/commands/ide.d.ts +0 -2
- package/dist/utils/commands/ide.js +0 -32
- package/dist/utils/commands/init.d.ts +0 -2
- package/dist/utils/commands/init.js +0 -93
- package/dist/utils/commands/mcp.d.ts +0 -2
- package/dist/utils/commands/mcp.js +0 -12
- package/dist/utils/commands/resume.d.ts +0 -2
- package/dist/utils/commands/resume.js +0 -12
- package/dist/utils/commands/review.d.ts +0 -2
- package/dist/utils/commands/review.js +0 -81
- package/dist/utils/commands/role.d.ts +0 -2
- package/dist/utils/commands/role.js +0 -37
- package/dist/utils/commands/todoPicker.d.ts +0 -2
- package/dist/utils/commands/todoPicker.js +0 -12
- package/dist/utils/commands/usage.d.ts +0 -2
- package/dist/utils/commands/usage.js +0 -12
- package/dist/utils/commands/yolo.d.ts +0 -2
- package/dist/utils/commands/yolo.js +0 -12
- package/dist/utils/configManager.d.ts +0 -45
- package/dist/utils/configManager.js +0 -303
- package/dist/utils/contextCompressor.d.ts +0 -16
- package/dist/utils/contextCompressor.js +0 -334
- package/dist/utils/devMode.d.ts +0 -13
- package/dist/utils/devMode.js +0 -54
- package/dist/utils/escapeHandler.d.ts +0 -79
- package/dist/utils/escapeHandler.js +0 -153
- package/dist/utils/fileDialog.d.ts +0 -9
- package/dist/utils/fileDialog.js +0 -74
- package/dist/utils/fileUtils.d.ts +0 -40
- package/dist/utils/fileUtils.js +0 -185
- package/dist/utils/historyManager.d.ts +0 -45
- package/dist/utils/historyManager.js +0 -159
- package/dist/utils/incrementalSnapshot.d.ts +0 -109
- package/dist/utils/incrementalSnapshot.js +0 -383
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -18
- package/dist/utils/languageConfig.d.ts +0 -21
- package/dist/utils/languageConfig.js +0 -61
- package/dist/utils/logger.d.ts +0 -37
- package/dist/utils/logger.js +0 -122
- package/dist/utils/mcpToolsManager.d.ts +0 -52
- package/dist/utils/mcpToolsManager.js +0 -878
- package/dist/utils/messageFormatter.d.ts +0 -12
- package/dist/utils/messageFormatter.js +0 -115
- package/dist/utils/notebookManager.d.ts +0 -59
- package/dist/utils/notebookManager.js +0 -213
- package/dist/utils/patch-highlight.d.ts +0 -5
- package/dist/utils/patch-highlight.js +0 -23
- package/dist/utils/processManager.d.ts +0 -27
- package/dist/utils/processManager.js +0 -75
- package/dist/utils/proxyUtils.d.ts +0 -15
- package/dist/utils/proxyUtils.js +0 -50
- package/dist/utils/resourceMonitor.d.ts +0 -65
- package/dist/utils/resourceMonitor.js +0 -175
- package/dist/utils/retryUtils.d.ts +0 -49
- package/dist/utils/retryUtils.js +0 -303
- package/dist/utils/sensitiveCommandManager.d.ts +0 -53
- package/dist/utils/sensitiveCommandManager.js +0 -308
- package/dist/utils/sessionConverter.d.ts +0 -7
- package/dist/utils/sessionConverter.js +0 -306
- package/dist/utils/sessionManager.d.ts +0 -53
- package/dist/utils/sessionManager.js +0 -371
- package/dist/utils/subAgentConfig.d.ts +0 -50
- package/dist/utils/subAgentConfig.js +0 -221
- package/dist/utils/subAgentExecutor.d.ts +0 -40
- package/dist/utils/subAgentExecutor.js +0 -434
- package/dist/utils/terminal.d.ts +0 -5
- package/dist/utils/terminal.js +0 -13
- package/dist/utils/textBuffer.d.ts +0 -99
- package/dist/utils/textBuffer.js +0 -547
- package/dist/utils/textUtils.d.ts +0 -37
- package/dist/utils/textUtils.js +0 -102
- package/dist/utils/themeConfig.d.ts +0 -21
- package/dist/utils/themeConfig.js +0 -61
- package/dist/utils/todoPreprocessor.d.ts +0 -5
- package/dist/utils/todoPreprocessor.js +0 -18
- package/dist/utils/todoScanner.d.ts +0 -8
- package/dist/utils/todoScanner.js +0 -148
- package/dist/utils/toolDisplayConfig.d.ts +0 -16
- package/dist/utils/toolDisplayConfig.js +0 -47
- package/dist/utils/toolExecutor.d.ts +0 -37
- package/dist/utils/toolExecutor.js +0 -224
- package/dist/utils/usageLogger.d.ts +0 -11
- package/dist/utils/usageLogger.js +0 -114
- package/dist/utils/vscodeConnection.d.ts +0 -76
- package/dist/utils/vscodeConnection.js +0 -430
- package/dist/utils/workspaceSnapshot.d.ts +0 -63
- package/dist/utils/workspaceSnapshot.js +0 -300
package/dist/cli.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Show loading indicator immediately before any imports
|
|
3
|
-
process.stdout.write('\x1b[?25l'); // Hide cursor
|
|
4
|
-
process.stdout.write('⠋ Loading...\r');
|
|
5
|
-
// Import only critical dependencies synchronously
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { render, Text, Box } from 'ink';
|
|
8
|
-
import Spinner from 'ink-spinner';
|
|
9
|
-
import meow from 'meow';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
|
-
// Load heavy dependencies asynchronously
|
|
12
|
-
async function loadDependencies() {
|
|
13
|
-
const [appModule, vscodeModule, resourceModule, configModule, processModule, devModeModule, childProcessModule, utilModule,] = await Promise.all([
|
|
14
|
-
import('./app.js'),
|
|
15
|
-
import('./utils/vscodeConnection.js'),
|
|
16
|
-
import('./utils/resourceMonitor.js'),
|
|
17
|
-
import('./utils/configManager.js'),
|
|
18
|
-
import('./utils/processManager.js'),
|
|
19
|
-
import('./utils/devMode.js'),
|
|
20
|
-
import('child_process'),
|
|
21
|
-
import('util'),
|
|
22
|
-
]);
|
|
23
|
-
return {
|
|
24
|
-
App: appModule.default,
|
|
25
|
-
vscodeConnection: vscodeModule.vscodeConnection,
|
|
26
|
-
resourceMonitor: resourceModule.resourceMonitor,
|
|
27
|
-
initializeProfiles: configModule.initializeProfiles,
|
|
28
|
-
processManager: processModule.processManager,
|
|
29
|
-
enableDevMode: devModeModule.enableDevMode,
|
|
30
|
-
getDevUserId: devModeModule.getDevUserId,
|
|
31
|
-
exec: childProcessModule.exec,
|
|
32
|
-
promisify: utilModule.promisify,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
let execAsync;
|
|
36
|
-
// Check for updates asynchronously
|
|
37
|
-
async function checkForUpdates(currentVersion) {
|
|
38
|
-
try {
|
|
39
|
-
const { stdout } = await execAsync('npm view snow-ai version --registry https://registry.npmjs.org', {
|
|
40
|
-
encoding: 'utf8',
|
|
41
|
-
});
|
|
42
|
-
const latestVersion = stdout.trim();
|
|
43
|
-
// Simple string comparison - force registry fetch ensures no cache issues
|
|
44
|
-
if (latestVersion && latestVersion !== currentVersion) {
|
|
45
|
-
console.log('\n🔔 Update available!');
|
|
46
|
-
console.log(` Current version: ${currentVersion}`);
|
|
47
|
-
console.log(` Latest version: ${latestVersion}`);
|
|
48
|
-
console.log(' Run "snow --update" to update\n');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
// Silently fail - don't interrupt user experience
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const cli = meow(`
|
|
56
|
-
Usage
|
|
57
|
-
$ snow
|
|
58
|
-
$ snow --ask "your prompt"
|
|
59
|
-
|
|
60
|
-
Options
|
|
61
|
-
--help Show help
|
|
62
|
-
--version Show version
|
|
63
|
-
--update Update to latest version
|
|
64
|
-
-c Skip welcome screen and resume last conversation
|
|
65
|
-
--ask Quick question mode (headless mode with single prompt)
|
|
66
|
-
--dev Enable developer mode with persistent userId for testing
|
|
67
|
-
`, {
|
|
68
|
-
importMeta: import.meta,
|
|
69
|
-
flags: {
|
|
70
|
-
update: {
|
|
71
|
-
type: 'boolean',
|
|
72
|
-
default: false,
|
|
73
|
-
},
|
|
74
|
-
c: {
|
|
75
|
-
type: 'boolean',
|
|
76
|
-
default: false,
|
|
77
|
-
},
|
|
78
|
-
ask: {
|
|
79
|
-
type: 'string',
|
|
80
|
-
},
|
|
81
|
-
dev: {
|
|
82
|
-
type: 'boolean',
|
|
83
|
-
default: false,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
// Handle update flag
|
|
88
|
-
if (cli.flags.update) {
|
|
89
|
-
console.log('🔄 Updating snow-ai to latest version...');
|
|
90
|
-
try {
|
|
91
|
-
execSync('npm install -g snow-ai@latest', { stdio: 'inherit' });
|
|
92
|
-
console.log('✅ Update completed successfully!');
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.error('❌ Update failed:', error instanceof Error ? error.message : error);
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// Dev mode and resource monitoring will be initialized in Startup component
|
|
101
|
-
// Startup component that shows loading spinner during update check
|
|
102
|
-
const Startup = ({ version, skipWelcome, headlessPrompt, isDevMode, }) => {
|
|
103
|
-
const [appReady, setAppReady] = React.useState(false);
|
|
104
|
-
const [AppComponent, setAppComponent] = React.useState(null);
|
|
105
|
-
React.useEffect(() => {
|
|
106
|
-
let mounted = true;
|
|
107
|
-
const init = async () => {
|
|
108
|
-
// Load all dependencies in parallel
|
|
109
|
-
const deps = await loadDependencies();
|
|
110
|
-
// Setup execAsync for checkForUpdates
|
|
111
|
-
execAsync = deps.promisify(deps.exec);
|
|
112
|
-
// Initialize profiles system
|
|
113
|
-
try {
|
|
114
|
-
deps.initializeProfiles();
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
console.error('Failed to initialize profiles:', error);
|
|
118
|
-
}
|
|
119
|
-
// Handle dev mode
|
|
120
|
-
if (isDevMode) {
|
|
121
|
-
deps.enableDevMode();
|
|
122
|
-
const userId = deps.getDevUserId();
|
|
123
|
-
console.log('🔧 Developer mode enabled');
|
|
124
|
-
console.log(`📝 Using persistent userId: ${userId}`);
|
|
125
|
-
console.log(`📂 Stored in: ~/.snow/dev-user-id\n`);
|
|
126
|
-
}
|
|
127
|
-
// Start resource monitoring in development/debug mode
|
|
128
|
-
if (process.env['NODE_ENV'] === 'development' || process.env['DEBUG']) {
|
|
129
|
-
deps.resourceMonitor.startMonitoring(30000);
|
|
130
|
-
setInterval(() => {
|
|
131
|
-
const { hasLeak, reasons } = deps.resourceMonitor.checkForLeaks();
|
|
132
|
-
if (hasLeak) {
|
|
133
|
-
console.error('⚠️ Potential memory leak detected:');
|
|
134
|
-
reasons.forEach((reason) => console.error(` - ${reason}`));
|
|
135
|
-
}
|
|
136
|
-
}, 5 * 60 * 1000);
|
|
137
|
-
}
|
|
138
|
-
// Store for cleanup
|
|
139
|
-
global.__deps = deps;
|
|
140
|
-
// Check for updates with timeout
|
|
141
|
-
const updateCheckPromise = version
|
|
142
|
-
? checkForUpdates(version)
|
|
143
|
-
: Promise.resolve();
|
|
144
|
-
// Race between update check and 3-second timeout
|
|
145
|
-
await Promise.race([
|
|
146
|
-
updateCheckPromise,
|
|
147
|
-
new Promise(resolve => setTimeout(resolve, 3000)),
|
|
148
|
-
]);
|
|
149
|
-
if (mounted) {
|
|
150
|
-
setAppComponent(() => deps.App);
|
|
151
|
-
setAppReady(true);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
init();
|
|
155
|
-
return () => {
|
|
156
|
-
mounted = false;
|
|
157
|
-
};
|
|
158
|
-
}, [version, isDevMode]);
|
|
159
|
-
if (!appReady || !AppComponent) {
|
|
160
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
161
|
-
React.createElement(Box, null,
|
|
162
|
-
React.createElement(Text, { color: "cyan" },
|
|
163
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
164
|
-
React.createElement(Text, null, " Loading..."))));
|
|
165
|
-
}
|
|
166
|
-
return (React.createElement(AppComponent, { version: version, skipWelcome: skipWelcome, headlessPrompt: headlessPrompt }));
|
|
167
|
-
};
|
|
168
|
-
// Disable bracketed paste mode on startup
|
|
169
|
-
process.stdout.write('\x1b[?2004l');
|
|
170
|
-
// Clear the early loading indicator and show cursor
|
|
171
|
-
process.stdout.write('\x1b[2K\r'); // Clear line
|
|
172
|
-
process.stdout.write('\x1b[?25h'); // Show cursor
|
|
173
|
-
// Re-enable on exit to avoid polluting parent shell
|
|
174
|
-
const cleanup = () => {
|
|
175
|
-
process.stdout.write('\x1b[?2004l');
|
|
176
|
-
// Cleanup loaded dependencies if available
|
|
177
|
-
const deps = global.__deps;
|
|
178
|
-
if (deps) {
|
|
179
|
-
// Kill all child processes first
|
|
180
|
-
deps.processManager.killAll();
|
|
181
|
-
// Stop resource monitoring
|
|
182
|
-
deps.resourceMonitor.stopMonitoring();
|
|
183
|
-
// Disconnect VSCode connection before exit
|
|
184
|
-
deps.vscodeConnection.stop();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
process.on('exit', cleanup);
|
|
188
|
-
process.on('SIGINT', () => {
|
|
189
|
-
cleanup();
|
|
190
|
-
process.exit(0);
|
|
191
|
-
});
|
|
192
|
-
process.on('SIGTERM', () => {
|
|
193
|
-
cleanup();
|
|
194
|
-
process.exit(0);
|
|
195
|
-
});
|
|
196
|
-
render(React.createElement(Startup, { version: cli.pkg.version, skipWelcome: cli.flags.c, headlessPrompt: cli.flags.ask, isDevMode: cli.flags.dev }), {
|
|
197
|
-
exitOnCtrlC: false,
|
|
198
|
-
patchConsole: true,
|
|
199
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TextBuffer } from '../utils/textBuffer.js';
|
|
2
|
-
import { type SubAgent } from '../utils/subAgentConfig.js';
|
|
3
|
-
export declare function useAgentPicker(buffer: TextBuffer, triggerUpdate: () => void): {
|
|
4
|
-
showAgentPicker: boolean;
|
|
5
|
-
setShowAgentPicker: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
6
|
-
agentSelectedIndex: number;
|
|
7
|
-
setAgentSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
8
|
-
agents: SubAgent[];
|
|
9
|
-
agentQuery: string;
|
|
10
|
-
hashSymbolPosition: number;
|
|
11
|
-
updateAgentPickerState: (_text: string, cursorPos: number) => void;
|
|
12
|
-
getFilteredAgents: () => SubAgent[];
|
|
13
|
-
handleAgentSelect: (agent: SubAgent) => void;
|
|
14
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { getSubAgents } from '../utils/subAgentConfig.js';
|
|
3
|
-
export function useAgentPicker(buffer, triggerUpdate) {
|
|
4
|
-
const [showAgentPicker, setShowAgentPicker] = useState(false);
|
|
5
|
-
const [agentSelectedIndex, setAgentSelectedIndex] = useState(0);
|
|
6
|
-
const [agents, setAgents] = useState([]);
|
|
7
|
-
const [agentQuery, setAgentQuery] = useState('');
|
|
8
|
-
const [hashSymbolPosition, setHashSymbolPosition] = useState(-1);
|
|
9
|
-
// Load agents when picker is shown
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (showAgentPicker) {
|
|
12
|
-
const loadedAgents = getSubAgents();
|
|
13
|
-
setAgents(loadedAgents);
|
|
14
|
-
setAgentSelectedIndex(0);
|
|
15
|
-
}
|
|
16
|
-
}, [showAgentPicker]);
|
|
17
|
-
// Update agent picker state based on # symbol
|
|
18
|
-
const updateAgentPickerState = useCallback((_text, cursorPos) => {
|
|
19
|
-
// Use display text (with placeholders) instead of full text (expanded)
|
|
20
|
-
const displayText = buffer.text;
|
|
21
|
-
// Find the last '#' symbol before the cursor
|
|
22
|
-
const beforeCursor = displayText.slice(0, cursorPos);
|
|
23
|
-
let position = -1;
|
|
24
|
-
let query = '';
|
|
25
|
-
// Search backwards from cursor to find #
|
|
26
|
-
for (let i = beforeCursor.length - 1; i >= 0; i--) {
|
|
27
|
-
if (beforeCursor[i] === '#') {
|
|
28
|
-
position = i;
|
|
29
|
-
const afterHash = beforeCursor.slice(i + 1);
|
|
30
|
-
// Only activate if no space/newline after #
|
|
31
|
-
if (!afterHash.includes(' ') && !afterHash.includes('\n')) {
|
|
32
|
-
query = afterHash;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// Has space after #, not valid
|
|
37
|
-
position = -1;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (position !== -1) {
|
|
43
|
-
// Found valid # context
|
|
44
|
-
if (!showAgentPicker ||
|
|
45
|
-
agentQuery !== query ||
|
|
46
|
-
hashSymbolPosition !== position) {
|
|
47
|
-
setShowAgentPicker(true);
|
|
48
|
-
setAgentQuery(query);
|
|
49
|
-
setHashSymbolPosition(position);
|
|
50
|
-
setAgentSelectedIndex(0);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// Hide agent picker if no valid # context found and it was triggered by #
|
|
55
|
-
if (showAgentPicker && hashSymbolPosition !== -1) {
|
|
56
|
-
setShowAgentPicker(false);
|
|
57
|
-
setHashSymbolPosition(-1);
|
|
58
|
-
setAgentQuery('');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}, [buffer, showAgentPicker, agentQuery, hashSymbolPosition]);
|
|
62
|
-
// Get filtered agents based on query
|
|
63
|
-
const getFilteredAgents = useCallback(() => {
|
|
64
|
-
if (!agentQuery) {
|
|
65
|
-
return agents;
|
|
66
|
-
}
|
|
67
|
-
const query = agentQuery.toLowerCase();
|
|
68
|
-
return agents.filter(agent => agent.id.toLowerCase().includes(query) ||
|
|
69
|
-
agent.name.toLowerCase().includes(query) ||
|
|
70
|
-
agent.description.toLowerCase().includes(query));
|
|
71
|
-
}, [agents, agentQuery]);
|
|
72
|
-
// Handle agent selection
|
|
73
|
-
const handleAgentSelect = useCallback((agent) => {
|
|
74
|
-
if (hashSymbolPosition !== -1) {
|
|
75
|
-
// Triggered by # symbol - replace inline
|
|
76
|
-
const displayText = buffer.text;
|
|
77
|
-
const cursorPos = buffer.getCursorPosition();
|
|
78
|
-
// Replace query with selected agent ID
|
|
79
|
-
const beforeHash = displayText.slice(0, hashSymbolPosition);
|
|
80
|
-
const afterCursor = displayText.slice(cursorPos);
|
|
81
|
-
// Construct the replacement: #agent_id
|
|
82
|
-
const newText = beforeHash + '#' + agent.id + ' ' + afterCursor;
|
|
83
|
-
// Set the new text and position cursor after the inserted agent ID + space
|
|
84
|
-
buffer.setText(newText);
|
|
85
|
-
// Calculate cursor position after the inserted text
|
|
86
|
-
// # length (1) + agent ID length + space (1)
|
|
87
|
-
const insertedLength = 1 + agent.id.length + 1;
|
|
88
|
-
const targetPos = hashSymbolPosition + insertedLength;
|
|
89
|
-
// Reset cursor to beginning, then move to correct position
|
|
90
|
-
for (let i = 0; i < targetPos; i++) {
|
|
91
|
-
if (i < buffer.text.length) {
|
|
92
|
-
buffer.moveRight();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
setHashSymbolPosition(-1);
|
|
96
|
-
setAgentQuery('');
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
// Triggered by command - clear buffer and insert
|
|
100
|
-
buffer.setText('');
|
|
101
|
-
buffer.insert(`#${agent.id} `);
|
|
102
|
-
}
|
|
103
|
-
setShowAgentPicker(false);
|
|
104
|
-
setAgentSelectedIndex(0);
|
|
105
|
-
triggerUpdate();
|
|
106
|
-
}, [hashSymbolPosition, buffer, triggerUpdate]);
|
|
107
|
-
return {
|
|
108
|
-
showAgentPicker,
|
|
109
|
-
setShowAgentPicker,
|
|
110
|
-
agentSelectedIndex,
|
|
111
|
-
setAgentSelectedIndex,
|
|
112
|
-
agents,
|
|
113
|
-
agentQuery,
|
|
114
|
-
hashSymbolPosition,
|
|
115
|
-
updateAgentPickerState,
|
|
116
|
-
getFilteredAgents,
|
|
117
|
-
handleAgentSelect,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { TextBuffer } from '../utils/textBuffer.js';
|
|
2
|
-
export declare function useClipboard(buffer: TextBuffer, updateCommandPanelState: (text: string) => void, updateFilePickerState: (text: string, cursorPos: number) => void, triggerUpdate: () => void): {
|
|
3
|
-
pasteFromClipboard: () => Promise<void>;
|
|
4
|
-
};
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
import { logger } from '../utils/logger.js';
|
|
4
|
-
export function useClipboard(buffer, updateCommandPanelState, updateFilePickerState, triggerUpdate) {
|
|
5
|
-
const pasteFromClipboard = useCallback(async () => {
|
|
6
|
-
try {
|
|
7
|
-
// Try to read image from clipboard
|
|
8
|
-
if (process.platform === 'win32') {
|
|
9
|
-
// Windows: Use PowerShell to read image from clipboard
|
|
10
|
-
try {
|
|
11
|
-
// Optimized PowerShell script with compression for large images
|
|
12
|
-
const psScript = 'Add-Type -AssemblyName System.Windows.Forms; ' +
|
|
13
|
-
'Add-Type -AssemblyName System.Drawing; ' +
|
|
14
|
-
'$clipboard = [System.Windows.Forms.Clipboard]::GetImage(); ' +
|
|
15
|
-
'if ($clipboard -ne $null) { ' +
|
|
16
|
-
'$ms = New-Object System.IO.MemoryStream; ' +
|
|
17
|
-
'$width = $clipboard.Width; ' +
|
|
18
|
-
'$height = $clipboard.Height; ' +
|
|
19
|
-
'$maxSize = 2048; ' +
|
|
20
|
-
'if ($width -gt $maxSize -or $height -gt $maxSize) { ' +
|
|
21
|
-
'$ratio = [Math]::Min($maxSize / $width, $maxSize / $height); ' +
|
|
22
|
-
'$newWidth = [int]($width * $ratio); ' +
|
|
23
|
-
'$newHeight = [int]($height * $ratio); ' +
|
|
24
|
-
'$resized = New-Object System.Drawing.Bitmap($newWidth, $newHeight); ' +
|
|
25
|
-
'$graphics = [System.Drawing.Graphics]::FromImage($resized); ' +
|
|
26
|
-
'$graphics.CompositingQuality = [System.Drawing.Drawing2D.CompositingQuality]::HighQuality; ' +
|
|
27
|
-
'$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic; ' +
|
|
28
|
-
'$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality; ' +
|
|
29
|
-
'$graphics.DrawImage($clipboard, 0, 0, $newWidth, $newHeight); ' +
|
|
30
|
-
'$resized.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png); ' +
|
|
31
|
-
'$graphics.Dispose(); ' +
|
|
32
|
-
'$resized.Dispose(); ' +
|
|
33
|
-
'} else { ' +
|
|
34
|
-
'$clipboard.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png); ' +
|
|
35
|
-
'}; ' +
|
|
36
|
-
'$bytes = $ms.ToArray(); ' +
|
|
37
|
-
'$ms.Close(); ' +
|
|
38
|
-
'[Convert]::ToBase64String($bytes); ' +
|
|
39
|
-
'}';
|
|
40
|
-
const base64Raw = execSync(`powershell -NoProfile -Command "${psScript}"`, {
|
|
41
|
-
encoding: 'utf-8',
|
|
42
|
-
timeout: 10000,
|
|
43
|
-
maxBuffer: 50 * 1024 * 1024, // 50MB buffer
|
|
44
|
-
});
|
|
45
|
-
// 高效清理:一次性移除所有空白字符
|
|
46
|
-
const base64 = base64Raw.replace(/\s/g, '');
|
|
47
|
-
if (base64 && base64.length > 100) {
|
|
48
|
-
// 直接传入 base64 数据,不需要 data URL 前缀
|
|
49
|
-
buffer.insertImage(base64, 'image/png');
|
|
50
|
-
const text = buffer.getFullText();
|
|
51
|
-
const cursorPos = buffer.getCursorPosition();
|
|
52
|
-
updateCommandPanelState(text);
|
|
53
|
-
updateFilePickerState(text, cursorPos);
|
|
54
|
-
triggerUpdate();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (imgError) {
|
|
59
|
-
// No image in clipboard or error, fall through to text
|
|
60
|
-
logger.error('Failed to read image from Windows clipboard:', imgError);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (process.platform === 'darwin') {
|
|
64
|
-
// macOS: Use osascript to read image from clipboard
|
|
65
|
-
try {
|
|
66
|
-
// First check if there's an image in clipboard
|
|
67
|
-
const checkScript = `osascript -e 'try
|
|
68
|
-
set imgData to the clipboard as «class PNGf»
|
|
69
|
-
return "hasImage"
|
|
70
|
-
on error
|
|
71
|
-
return "noImage"
|
|
72
|
-
end try'`;
|
|
73
|
-
const hasImage = execSync(checkScript, {
|
|
74
|
-
encoding: 'utf-8',
|
|
75
|
-
timeout: 2000,
|
|
76
|
-
}).trim();
|
|
77
|
-
if (hasImage === 'hasImage') {
|
|
78
|
-
// Save clipboard image to temporary file and read it
|
|
79
|
-
const tmpFile = `/tmp/snow_clipboard_${Date.now()}.png`;
|
|
80
|
-
const saveScript = `osascript -e 'set imgData to the clipboard as «class PNGf»' -e 'set fileRef to open for access POSIX file "${tmpFile}" with write permission' -e 'write imgData to fileRef' -e 'close access fileRef'`;
|
|
81
|
-
execSync(saveScript, {
|
|
82
|
-
encoding: 'utf-8',
|
|
83
|
-
timeout: 3000,
|
|
84
|
-
});
|
|
85
|
-
// Use sips to resize if needed, then convert to base64
|
|
86
|
-
// First check image size
|
|
87
|
-
const sizeCheck = execSync(`sips -g pixelWidth -g pixelHeight "${tmpFile}" | grep -E "pixelWidth|pixelHeight" | awk '{print $2}'`, {
|
|
88
|
-
encoding: 'utf-8',
|
|
89
|
-
timeout: 2000,
|
|
90
|
-
});
|
|
91
|
-
const [widthStr, heightStr] = sizeCheck.trim().split('\n');
|
|
92
|
-
const width = parseInt(widthStr || '0', 10);
|
|
93
|
-
const height = parseInt(heightStr || '0', 10);
|
|
94
|
-
const maxSize = 2048;
|
|
95
|
-
// Resize if too large
|
|
96
|
-
if (width > maxSize || height > maxSize) {
|
|
97
|
-
const ratio = Math.min(maxSize / width, maxSize / height);
|
|
98
|
-
const newWidth = Math.floor(width * ratio);
|
|
99
|
-
const newHeight = Math.floor(height * ratio);
|
|
100
|
-
execSync(`sips -z ${newHeight} ${newWidth} "${tmpFile}" --out "${tmpFile}"`, {
|
|
101
|
-
encoding: 'utf-8',
|
|
102
|
-
timeout: 5000,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
// Read the file as base64 with optimized buffer
|
|
106
|
-
const base64Raw = execSync(`base64 -i "${tmpFile}"`, {
|
|
107
|
-
encoding: 'utf-8',
|
|
108
|
-
timeout: 5000,
|
|
109
|
-
maxBuffer: 50 * 1024 * 1024, // 50MB buffer
|
|
110
|
-
});
|
|
111
|
-
// 高效清理:一次性移除所有空白字符
|
|
112
|
-
const base64 = base64Raw.replace(/\s/g, '');
|
|
113
|
-
// Clean up temp file
|
|
114
|
-
try {
|
|
115
|
-
execSync(`rm "${tmpFile}"`, { timeout: 1000 });
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
// Ignore cleanup errors
|
|
119
|
-
}
|
|
120
|
-
if (base64 && base64.length > 100) {
|
|
121
|
-
// 直接传入 base64 数据,不需要 data URL 前缀
|
|
122
|
-
buffer.insertImage(base64, 'image/png');
|
|
123
|
-
const text = buffer.getFullText();
|
|
124
|
-
const cursorPos = buffer.getCursorPosition();
|
|
125
|
-
updateCommandPanelState(text);
|
|
126
|
-
updateFilePickerState(text, cursorPos);
|
|
127
|
-
triggerUpdate();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (imgError) {
|
|
133
|
-
logger.error('Failed to read image from macOS clipboard:', imgError);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
// If no image, try to read text from clipboard
|
|
137
|
-
try {
|
|
138
|
-
let clipboardText = '';
|
|
139
|
-
if (process.platform === 'win32') {
|
|
140
|
-
clipboardText = execSync('powershell -Command "Get-Clipboard"', {
|
|
141
|
-
encoding: 'utf-8',
|
|
142
|
-
timeout: 2000,
|
|
143
|
-
}).trim();
|
|
144
|
-
}
|
|
145
|
-
else if (process.platform === 'darwin') {
|
|
146
|
-
clipboardText = execSync('pbpaste', {
|
|
147
|
-
encoding: 'utf-8',
|
|
148
|
-
timeout: 2000,
|
|
149
|
-
}).trim();
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
clipboardText = execSync('xclip -selection clipboard -o', {
|
|
153
|
-
encoding: 'utf-8',
|
|
154
|
-
timeout: 2000,
|
|
155
|
-
}).trim();
|
|
156
|
-
}
|
|
157
|
-
if (clipboardText) {
|
|
158
|
-
buffer.insert(clipboardText);
|
|
159
|
-
const fullText = buffer.getFullText();
|
|
160
|
-
const cursorPos = buffer.getCursorPosition();
|
|
161
|
-
updateCommandPanelState(fullText);
|
|
162
|
-
updateFilePickerState(fullText, cursorPos);
|
|
163
|
-
triggerUpdate();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (textError) {
|
|
167
|
-
logger.error('Failed to read text from clipboard:', textError);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
catch (error) {
|
|
171
|
-
logger.error('Failed to read from clipboard:', error);
|
|
172
|
-
}
|
|
173
|
-
}, [buffer, updateCommandPanelState, updateFilePickerState, triggerUpdate]);
|
|
174
|
-
return { pasteFromClipboard };
|
|
175
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Message } from '../ui/components/MessageList.js';
|
|
2
|
-
import type { UsageInfo } from '../api/chat.js';
|
|
3
|
-
/**
|
|
4
|
-
* 执行上下文压缩
|
|
5
|
-
* @returns 返回压缩后的UI消息列表和token使用信息,如果失败返回null
|
|
6
|
-
*/
|
|
7
|
-
export declare function executeContextCompression(): Promise<{
|
|
8
|
-
uiMessages: Message[];
|
|
9
|
-
usage: UsageInfo;
|
|
10
|
-
} | null>;
|
|
11
|
-
type CommandHandlerOptions = {
|
|
12
|
-
messages: Message[];
|
|
13
|
-
setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
14
|
-
setRemountKey: React.Dispatch<React.SetStateAction<number>>;
|
|
15
|
-
clearSavedMessages: () => void;
|
|
16
|
-
setIsCompressing: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
|
-
setCompressionError: React.Dispatch<React.SetStateAction<string | null>>;
|
|
18
|
-
setShowSessionPanel: React.Dispatch<React.SetStateAction<boolean>>;
|
|
19
|
-
setShowMcpInfo: React.Dispatch<React.SetStateAction<boolean>>;
|
|
20
|
-
setShowMcpPanel: React.Dispatch<React.SetStateAction<boolean>>;
|
|
21
|
-
setShowUsagePanel: React.Dispatch<React.SetStateAction<boolean>>;
|
|
22
|
-
setShowHelpPanel: React.Dispatch<React.SetStateAction<boolean>>;
|
|
23
|
-
setMcpPanelKey: React.Dispatch<React.SetStateAction<number>>;
|
|
24
|
-
setYoloMode: React.Dispatch<React.SetStateAction<boolean>>;
|
|
25
|
-
setContextUsage: React.Dispatch<React.SetStateAction<UsageInfo | null>>;
|
|
26
|
-
setVscodeConnectionStatus: React.Dispatch<React.SetStateAction<'disconnected' | 'connecting' | 'connected' | 'error'>>;
|
|
27
|
-
processMessage: (message: string, images?: Array<{
|
|
28
|
-
data: string;
|
|
29
|
-
mimeType: string;
|
|
30
|
-
}>, useBasicModel?: boolean, hideUserMessage?: boolean) => Promise<void>;
|
|
31
|
-
};
|
|
32
|
-
export declare function useCommandHandler(options: CommandHandlerOptions): {
|
|
33
|
-
handleCommandExecution: (commandName: string, result: any) => Promise<void>;
|
|
34
|
-
};
|
|
35
|
-
export {};
|