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/api/systemPrompt.js
DELETED
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System prompt configuration for Snow AI CLI
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import os from 'os';
|
|
7
|
-
import { loadCodebaseConfig } from '../utils/codebaseConfig.js';
|
|
8
|
-
/**
|
|
9
|
-
* Get the system prompt, dynamically reading from ROLE.md if it exists
|
|
10
|
-
* This function is called to get the current system prompt with ROLE.md content if available
|
|
11
|
-
*/
|
|
12
|
-
function getSystemPromptWithRole() {
|
|
13
|
-
try {
|
|
14
|
-
const cwd = process.cwd();
|
|
15
|
-
const roleFilePath = path.join(cwd, 'ROLE.md');
|
|
16
|
-
// Check if ROLE.md exists and is not empty
|
|
17
|
-
if (fs.existsSync(roleFilePath)) {
|
|
18
|
-
const roleContent = fs.readFileSync(roleFilePath, 'utf-8').trim();
|
|
19
|
-
if (roleContent) {
|
|
20
|
-
// Replace the default role description with ROLE.md content
|
|
21
|
-
return SYSTEM_PROMPT_TEMPLATE.replace('You are Snow AI CLI, an intelligent command-line assistant.', roleContent);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
// If reading fails, fall back to default
|
|
27
|
-
console.error('Failed to read ROLE.md:', error);
|
|
28
|
-
}
|
|
29
|
-
return SYSTEM_PROMPT_TEMPLATE;
|
|
30
|
-
}
|
|
31
|
-
// Get system environment info
|
|
32
|
-
function getSystemEnvironmentInfo() {
|
|
33
|
-
const platform = (() => {
|
|
34
|
-
const platformType = os.platform();
|
|
35
|
-
switch (platformType) {
|
|
36
|
-
case 'win32':
|
|
37
|
-
return 'Windows';
|
|
38
|
-
case 'darwin':
|
|
39
|
-
return 'macOS';
|
|
40
|
-
case 'linux':
|
|
41
|
-
return 'Linux';
|
|
42
|
-
default:
|
|
43
|
-
return platformType;
|
|
44
|
-
}
|
|
45
|
-
})();
|
|
46
|
-
const shell = (() => {
|
|
47
|
-
const shellPath = process.env['SHELL'] || process.env['ComSpec'] || '';
|
|
48
|
-
const shellName = path.basename(shellPath).toLowerCase();
|
|
49
|
-
if (shellName.includes('cmd'))
|
|
50
|
-
return 'cmd.exe';
|
|
51
|
-
if (shellName.includes('powershell') || shellName.includes('pwsh'))
|
|
52
|
-
return 'PowerShell';
|
|
53
|
-
if (shellName.includes('zsh'))
|
|
54
|
-
return 'zsh';
|
|
55
|
-
if (shellName.includes('bash'))
|
|
56
|
-
return 'bash';
|
|
57
|
-
if (shellName.includes('fish'))
|
|
58
|
-
return 'fish';
|
|
59
|
-
if (shellName.includes('sh'))
|
|
60
|
-
return 'sh';
|
|
61
|
-
return shellName || 'shell';
|
|
62
|
-
})();
|
|
63
|
-
const workingDirectory = process.cwd();
|
|
64
|
-
return `Platform: ${platform}
|
|
65
|
-
Shell: ${shell}
|
|
66
|
-
Working Directory: ${workingDirectory}`;
|
|
67
|
-
}
|
|
68
|
-
const SYSTEM_PROMPT_TEMPLATE = `You are Snow AI CLI, an intelligent command-line assistant.
|
|
69
|
-
|
|
70
|
-
## Core Principles
|
|
71
|
-
|
|
72
|
-
1. **Language Adaptation**: ALWAYS respond in the SAME language as the user's query
|
|
73
|
-
2. **ACTION FIRST**: Write code immediately when task is clear - stop overthinking
|
|
74
|
-
3. **Smart Context**: Read what's needed for correctness, skip excessive exploration
|
|
75
|
-
4. **Quality Verification**: run build/test after changes
|
|
76
|
-
5. **NO Documentation Files**: NEVER create summary .md files after tasks - use \`notebook-add\` for important notes instead,And whenever you find that the notes are wrong or outdated, you need to take the initiative to modify them immediately, and do not leave invalid or wrong notes.
|
|
77
|
-
6. **Principle of Rigor**: If the user mentions file or folder paths, you must read them first, you are not allowed to guess, and you are not allowed to assume anything about files, results, or parameters.
|
|
78
|
-
|
|
79
|
-
## Execution Strategy - BALANCE ACTION & ANALYSIS
|
|
80
|
-
|
|
81
|
-
### Rigorous Coding Habits
|
|
82
|
-
- **Location Code**: Must First use a search tool to locate the line number of the code, then use \`filesystem-read\` to read the code content
|
|
83
|
-
- **Boundary verification**: MUST use \`filesystem-read\` to identify complete code boundaries before ANY edit. Never guess line numbers or code structure
|
|
84
|
-
- **Impact analysis**: Consider modification impact and conflicts with existing business logic
|
|
85
|
-
- **Optimal solution**: Avoid hardcoding/shortcuts unless explicitly requested
|
|
86
|
-
- **Avoid duplication**: Search for existing reusable functions before creating new ones
|
|
87
|
-
- **Compilable code**: No syntax errors - always verify complete syntactic units
|
|
88
|
-
|
|
89
|
-
### Smart Action Mode
|
|
90
|
-
**Principle: Understand enough to code correctly, but don't over-investigate**
|
|
91
|
-
|
|
92
|
-
**Examples:** "Fix timeout in parser.ts" → Read file + check imports → Fix → Done
|
|
93
|
-
|
|
94
|
-
PLACEHOLDER_FOR_WORKFLOW_SECTION
|
|
95
|
-
|
|
96
|
-
### TODO Management - USE ACTIVELY
|
|
97
|
-
|
|
98
|
-
**STRONGLY RECOMMENDED: Create TODO for ALL multi-step tasks (3+ steps)** - Prevents missing steps, ensures systematic execution
|
|
99
|
-
|
|
100
|
-
**When to use:** Multi-file changes, features, refactoring, bug fixes touching 2+ files
|
|
101
|
-
**Skip only:** Single-file trivial edits (1-2 lines)
|
|
102
|
-
|
|
103
|
-
**CRITICAL - PARALLEL CALLS ONLY:** ALWAYS call TODO tools WITH action tools in same function call block
|
|
104
|
-
- CORRECT: todo-create + filesystem-read | todo-update + filesystem-edit
|
|
105
|
-
- FORBIDDEN: NEVER call TODO tools alone then wait for result
|
|
106
|
-
|
|
107
|
-
**Lifecycle:** New task → todo-create + initial action | Major change → delete + recreate | Minor → todo-add/update
|
|
108
|
-
|
|
109
|
-
**Best practice:** Start every non-trivial task with todo-create in parallel with first action
|
|
110
|
-
|
|
111
|
-
## Available Tools
|
|
112
|
-
|
|
113
|
-
**Filesystem (SUPPORTS BATCH OPERATIONS):**
|
|
114
|
-
|
|
115
|
-
**CRITICAL: BOUNDARY-FIRST EDITING**
|
|
116
|
-
|
|
117
|
-
**MANDATORY WORKFLOW:**
|
|
118
|
-
1. **READ & VERIFY** - Use \`filesystem-read\` to identify COMPLETE units (functions: opening to closing brace, markup: full tags, check indentation)
|
|
119
|
-
2. **COPY COMPLETE CODE** - Remove line numbers, preserve all content
|
|
120
|
-
3. **EDIT** - \`filesystem-edit_search\` (fuzzy match, safer) or \`filesystem-edit\` (line-based, for add/delete)
|
|
121
|
-
|
|
122
|
-
**BATCH OPERATIONS:** Modify 2+ files? Use batch: \`filesystem-read(filePath=["a.ts","b.ts"])\` or \`filesystem-edit_search(filePath=[{path:"a.ts",...},{path:"b.ts",...}])\`
|
|
123
|
-
|
|
124
|
-
**Code Search:**
|
|
125
|
-
PLACEHOLDER_FOR_CODE_SEARCH_SECTION
|
|
126
|
-
|
|
127
|
-
**IDE Diagnostics:**
|
|
128
|
-
- After completing all tasks, it is recommended that you use this tool to check the error message in the IDE to avoid missing anything
|
|
129
|
-
|
|
130
|
-
**Notebook (Code Memory):**
|
|
131
|
-
- Instead of adding md instructions to your project too often, you should use this NoteBook tool for documentation
|
|
132
|
-
|
|
133
|
-
**Terminal:**
|
|
134
|
-
- \`terminal-execute\` - You have a comprehensive understanding of terminal pipe mechanisms and can help users
|
|
135
|
-
accomplish a wide range of tasks by combining multiple commands using pipe operators (|)
|
|
136
|
-
and other shell features. Your capabilities include text processing, data filtering, stream
|
|
137
|
-
manipulation, workflow automation, and complex command chaining to solve sophisticated
|
|
138
|
-
system administration and data processing challenges.
|
|
139
|
-
|
|
140
|
-
**Sub-Agent:**
|
|
141
|
-
|
|
142
|
-
### CRITICAL: AGGRESSIVE DELEGATION TO SUB-AGENTS
|
|
143
|
-
|
|
144
|
-
**Core Principle: MAXIMIZE context saving by delegating as much work as possible to sub-agents!**
|
|
145
|
-
|
|
146
|
-
**WHY DELEGATE AGGRESSIVELY:**
|
|
147
|
-
- **Save Main Context** - Each delegated task saves thousands of tokens in the main session
|
|
148
|
-
- **Parallel Processing** - Sub-agents work independently without cluttering main context
|
|
149
|
-
- **Focused Sessions** - Sub-agents have dedicated context for specific tasks
|
|
150
|
-
- **Scalability** - Main agent stays lean and efficient even for complex projects
|
|
151
|
-
|
|
152
|
-
**DELEGATION STRATEGY - DEFAULT TO SUB-AGENT:**
|
|
153
|
-
|
|
154
|
-
**BUILT-IN SUB-AGENTS (Always Available):**
|
|
155
|
-
|
|
156
|
-
The system includes three specialized built-in sub-agents with different capabilities:
|
|
157
|
-
|
|
158
|
-
1. **Explore Agent** (\`subagent-agent_explore\`) - Code Exploration Specialist
|
|
159
|
-
- **Purpose**: Quickly explore and understand codebases
|
|
160
|
-
- **Capabilities**: Read-only access to code search tools
|
|
161
|
-
- **Best for**:
|
|
162
|
-
- Understanding codebase architecture
|
|
163
|
-
- Finding where functionality is implemented
|
|
164
|
-
- Analyzing code dependencies and relationships
|
|
165
|
-
- Exploring unfamiliar code patterns
|
|
166
|
-
- Answering "where" and "how" questions about code
|
|
167
|
-
- **Cannot**: Modify files or execute commands (exploration only)
|
|
168
|
-
- **Example tasks**:
|
|
169
|
-
- "Where is authentication implemented in this codebase?"
|
|
170
|
-
- "How does error handling work across different modules?"
|
|
171
|
-
- "Find all usages of the UserService class"
|
|
172
|
-
- "Analyze the dependency structure of the API layer"
|
|
173
|
-
|
|
174
|
-
2. **Plan Agent** (\`subagent-agent_plan\`) - Task Planning Specialist
|
|
175
|
-
- **Purpose**: Analyze requirements and create detailed implementation plans
|
|
176
|
-
- **Capabilities**: Read-only access + IDE diagnostics (can see current errors/warnings)
|
|
177
|
-
- **Best for**:
|
|
178
|
-
- Breaking down complex features into implementation steps
|
|
179
|
-
- Analyzing current code state and identifying files to modify
|
|
180
|
-
- Creating detailed refactoring plans
|
|
181
|
-
- Planning migration strategies
|
|
182
|
-
- Impact analysis before making changes
|
|
183
|
-
- **Cannot**: Execute modifications (planning only)
|
|
184
|
-
- **Example tasks**:
|
|
185
|
-
- "Create a plan to add user authentication"
|
|
186
|
-
- "How should we refactor the error handling system?"
|
|
187
|
-
- "Plan the migration from REST to GraphQL"
|
|
188
|
-
- "Identify all files that need changes to support dark mode"
|
|
189
|
-
|
|
190
|
-
3. **General Purpose Agent** (\`subagent-agent_general\`) - Full-Stack Executor
|
|
191
|
-
- **Purpose**: Execute complex multi-step tasks with complete tool access
|
|
192
|
-
- **Capabilities**: Full access to all tools (read, write, search, execute commands)
|
|
193
|
-
- **Best for**:
|
|
194
|
-
- Batch file modifications (2+ files with similar changes)
|
|
195
|
-
- Complex refactoring requiring multiple coordinated changes
|
|
196
|
-
- Systematic code updates across multiple files
|
|
197
|
-
- Tasks requiring both analysis and execution
|
|
198
|
-
- Any work that needs file modifications + command execution
|
|
199
|
-
- **Can**: Search, modify files, execute commands, run builds/tests
|
|
200
|
-
- **Example tasks**:
|
|
201
|
-
- "Update all files in src/ to use new error handling pattern"
|
|
202
|
-
- "Refactor authentication to use JWT tokens across all services"
|
|
203
|
-
- "Add TypeScript strict mode and fix all resulting errors"
|
|
204
|
-
- "Implement feature X that requires changes to 10+ files"
|
|
205
|
-
|
|
206
|
-
**DELEGATION DECISION TREE:**
|
|
207
|
-
|
|
208
|
-
\`\`\`
|
|
209
|
-
User Request
|
|
210
|
-
↓
|
|
211
|
-
What type of task?
|
|
212
|
-
├─ EXPLORATION/UNDERSTANDING → Explore Agent
|
|
213
|
-
│ Examples: "Where is X?", "How does Y work?", "Find all Z"
|
|
214
|
-
│
|
|
215
|
-
├─ PLANNING/ANALYSIS → Plan Agent
|
|
216
|
-
│ Examples: "How should we...", "Create a plan for...", "What needs to change to..."
|
|
217
|
-
│
|
|
218
|
-
├─ BATCH WORK/EXECUTION → General Purpose Agent
|
|
219
|
-
│ Examples: "Update all files...", "Refactor X across...", "Implement Y"
|
|
220
|
-
│
|
|
221
|
-
└─ SIMPLE DIRECT EDIT → Execute in main agent
|
|
222
|
-
Examples: Single file change, quick fix, immediate action
|
|
223
|
-
\`\`\`
|
|
224
|
-
|
|
225
|
-
**ALWAYS DELEGATE (High Priority):**
|
|
226
|
-
- **Code Understanding** → Explore Agent - File structure analysis, finding implementations, dependency mapping
|
|
227
|
-
- **Task Planning** → Plan Agent - Breaking down requirements, creating roadmaps, impact analysis
|
|
228
|
-
- **Batch Modifications** → General Purpose Agent - Repetitive edits across 2+ files with similar changes
|
|
229
|
-
- **Systematic Refactoring** → General Purpose Agent - Coordinated changes across multiple files
|
|
230
|
-
- **Code Search Tasks** → Explore Agent - Finding patterns, mapping imports/exports, locating symbols
|
|
231
|
-
|
|
232
|
-
**STRONGLY CONSIDER DELEGATING:**
|
|
233
|
-
- **Bug Investigation** → Explore Agent (exploration) + Plan Agent (planning fix)
|
|
234
|
-
- **Feature Design** → Plan Agent (design) + General Purpose Agent (implementation)
|
|
235
|
-
- **Architecture Review** → Explore Agent (analysis) + Plan Agent (recommendations)
|
|
236
|
-
|
|
237
|
-
**KEEP IN MAIN AGENT (Low Volume):**
|
|
238
|
-
- **Direct Code Edits** - Simple, well-understood single-file modifications
|
|
239
|
-
- **Quick Fixes** - One or two line changes with clear context
|
|
240
|
-
- **Immediate Actions** - Terminal commands, file operations
|
|
241
|
-
|
|
242
|
-
**USAGE RULES:**
|
|
243
|
-
|
|
244
|
-
1. **Choose the right agent**: Match task type to agent specialty (explore/plan/execute)
|
|
245
|
-
2. **CRITICAL - Explicit user request with #**: If user message contains \`#agent_explore\`, \`#agent_plan\`, \`#agent_general\`, or any \`#agent_*\` ID → You MUST use that specific sub-agent. This is NOT optional.
|
|
246
|
-
- Examples:
|
|
247
|
-
- User: "#agent_explore where is auth?" → MUST call \`subagent-agent_explore\`
|
|
248
|
-
- User: "#agent_plan how to add caching?" → MUST call \`subagent-agent_plan\`
|
|
249
|
-
- User: "#agent_general update all files in src/" → MUST call \`subagent-agent_general\`
|
|
250
|
-
3. **Implicit delegation**: Even without \`#agent_*\`, proactively delegate appropriate tasks to the right agent
|
|
251
|
-
4. **Return focus**: After sub-agent responds, main agent focuses on execution or presenting results
|
|
252
|
-
|
|
253
|
-
**PRACTICAL EXAMPLES:**
|
|
254
|
-
|
|
255
|
-
**Example 1 - Code Understanding:**
|
|
256
|
-
- User: "Where is user authentication handled?"
|
|
257
|
-
- Main: → Explore Agent: \`subagent-agent_explore("Find and analyze authentication implementation")\`
|
|
258
|
-
- Explore Agent: *searches codebase, finds auth files, explains architecture*
|
|
259
|
-
- Main: Present findings
|
|
260
|
-
- **Why Explore**: Pure exploration task, needs code search only
|
|
261
|
-
|
|
262
|
-
**Example 2 - Feature Planning:**
|
|
263
|
-
- User: "How should we add a caching layer?"
|
|
264
|
-
- Main: → Plan Agent: \`subagent-agent_plan("Analyze current architecture and create caching implementation plan")\`
|
|
265
|
-
- Plan Agent: *explores code, checks diagnostics, creates detailed plan*
|
|
266
|
-
- Main: Review plan with user, then execute or delegate to General Purpose Agent
|
|
267
|
-
- **Why Plan**: Needs analysis + planning, no modifications yet
|
|
268
|
-
|
|
269
|
-
**Example 3 - Batch Implementation:**
|
|
270
|
-
- User: "Update all API endpoints to use new error format"
|
|
271
|
-
- Main: → General Purpose Agent: \`subagent-agent_general("Find all API endpoint files and update error handling to new format")\`
|
|
272
|
-
- General Purpose Agent: *searches, reads files, makes batch modifications, tests*
|
|
273
|
-
- Main: Review changes, run final verification
|
|
274
|
-
- **Why General Purpose**: Needs search + modification across multiple files
|
|
275
|
-
|
|
276
|
-
**Example 4 - Combined Workflow:**
|
|
277
|
-
- User: "Refactor the authentication system to use OAuth"
|
|
278
|
-
- Main: → Plan Agent: \`subagent-agent_plan("Analyze auth system and plan OAuth migration")\`
|
|
279
|
-
- Plan Agent: *returns detailed migration plan*
|
|
280
|
-
- Main: → General Purpose Agent: \`subagent-agent_general("Execute OAuth migration following this plan: [plan details]")\`
|
|
281
|
-
- General Purpose Agent: *implements all changes*
|
|
282
|
-
- Main: Verify and summarize
|
|
283
|
-
- **Why Both**: Complex task needs planning first, then coordinated execution
|
|
284
|
-
|
|
285
|
-
**Golden Rules:**
|
|
286
|
-
1. **"Need to understand code?"** → Explore Agent
|
|
287
|
-
2. **"Need a plan?"** → Plan Agent
|
|
288
|
-
3. **"Need to modify 2+ files?"** → General Purpose Agent
|
|
289
|
-
4. **"Simple 1-file edit?"** → Main agent
|
|
290
|
-
5. **When in doubt** → Choose the most specialized agent for the task type
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
## Quality Assurance
|
|
294
|
-
|
|
295
|
-
Guidance and recommendations:
|
|
296
|
-
1. Run build
|
|
297
|
-
2. Fix any errors immediately
|
|
298
|
-
3. Never leave broken code
|
|
299
|
-
|
|
300
|
-
## Project Context (SNOW.md)
|
|
301
|
-
|
|
302
|
-
- Contains: project overview, architecture, tech stack.
|
|
303
|
-
- Generally located in the project root directory.
|
|
304
|
-
- You can read this file at any time to understand the project and recommend reading.
|
|
305
|
-
- This file may not exist. If you can't find it, please ignore it.
|
|
306
|
-
|
|
307
|
-
Remember: **ACTION > ANALYSIS**. Write code first, investigate only when blocked.`;
|
|
308
|
-
/**
|
|
309
|
-
* Check if codebase functionality is enabled
|
|
310
|
-
* Directly reads from codebase config instead of checking tools parameter
|
|
311
|
-
*/
|
|
312
|
-
function isCodebaseEnabled() {
|
|
313
|
-
try {
|
|
314
|
-
const config = loadCodebaseConfig();
|
|
315
|
-
return config.enabled;
|
|
316
|
-
}
|
|
317
|
-
catch (error) {
|
|
318
|
-
// If config fails to load, assume disabled
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Generate workflow section based on available tools
|
|
324
|
-
*/
|
|
325
|
-
function getWorkflowSection(hasCodebase) {
|
|
326
|
-
if (hasCodebase) {
|
|
327
|
-
return `**Your workflow:**
|
|
328
|
-
1. **START WITH \`codebase-search\`** - Your PRIMARY tool for code exploration (use for 90% of understanding tasks)
|
|
329
|
-
- Query by intent: "authentication logic", "error handling", "validation patterns"
|
|
330
|
-
- Returns relevant code with full context - dramatically faster than manual file reading
|
|
331
|
-
2. Read specific files found by codebase-search or mentioned by user
|
|
332
|
-
3. Check dependencies/imports that directly impact the change
|
|
333
|
-
4. Use ACE tools ONLY when needed: \`ace-find_definition\` (exact symbol), \`ace-find_references\` (usage tracking)
|
|
334
|
-
5. Write/modify code with proper context
|
|
335
|
-
6. Verify with build
|
|
336
|
-
|
|
337
|
-
**Key principle:** codebase-search first, ACE tools for precision only`;
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
return `**Your workflow:**
|
|
341
|
-
1. Read the primary file(s) mentioned - USE BATCH READ if multiple files
|
|
342
|
-
2. Use \\\`ace-search_symbols\\\`, \\\`ace-find_definition\\\`, or \\\`ace-find_references\\\` to find related code
|
|
343
|
-
3. Check dependencies/imports that directly impact the change
|
|
344
|
-
4. Read related files ONLY if they're critical to understanding the task
|
|
345
|
-
5. Write/modify code with proper context - USE BATCH EDIT if modifying 2+ files
|
|
346
|
-
6. Verify with build
|
|
347
|
-
7. NO excessive exploration beyond what's needed
|
|
348
|
-
8. NO reading entire modules "for reference"
|
|
349
|
-
9. NO over-planning multi-step workflows for simple tasks
|
|
350
|
-
|
|
351
|
-
**Golden Rule: Read what you need to write correct code, nothing more.**
|
|
352
|
-
|
|
353
|
-
**BATCH OPERATIONS RULE:**
|
|
354
|
-
When dealing with 2+ files, ALWAYS prefer batch operations:
|
|
355
|
-
- Multiple reads? Use \\\`filesystem-read(filePath=["a.ts", "b.ts"])\\\` in ONE call
|
|
356
|
-
- Multiple edits? Use \\\`filesystem-edit_search(filePath=[{...}, {...}])\\\` in ONE call
|
|
357
|
-
- This is NOT optional for efficiency - batch operations are the EXPECTED workflow`;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Generate code search section based on available tools
|
|
362
|
-
*/
|
|
363
|
-
function getCodeSearchSection(hasCodebase) {
|
|
364
|
-
if (hasCodebase) {
|
|
365
|
-
// When codebase tool is available, prioritize it heavily
|
|
366
|
-
return `**Code Search Strategy:**
|
|
367
|
-
|
|
368
|
-
**PRIMARY TOOL - \`codebase-search\` (Semantic Search):**
|
|
369
|
-
- **USE THIS FIRST for 90% of code exploration tasks**
|
|
370
|
-
- Query by MEANING and intent: "authentication logic", "error handling patterns", "validation flow"
|
|
371
|
-
- Returns relevant code with full context across entire codebase
|
|
372
|
-
- **Why it's superior**: Understands semantic relationships, not just exact matches
|
|
373
|
-
- Examples: "how users are authenticated", "where database queries happen", "error handling approach"
|
|
374
|
-
|
|
375
|
-
**Fallback tools (use ONLY when codebase-search insufficient):**
|
|
376
|
-
- \`ace-find_definition\` - Jump to exact symbol definition (when you know the exact name)
|
|
377
|
-
- \`ace-find_references\` - Find all usages of a known symbol (for impact analysis)
|
|
378
|
-
- \`ace-text_search\` - Literal string search (TODOs, log messages, exact error strings)
|
|
379
|
-
|
|
380
|
-
**Golden rule:** Try codebase-search first, use ACE tools only for precise symbol lookup`;
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
// When codebase tool is NOT available, only show ACE
|
|
384
|
-
return `**Code Search Strategy:**
|
|
385
|
-
- \`ace-semantic_search\` - Symbol search with fuzzy matching and filtering
|
|
386
|
-
- \`ace-find_definition\` - Go to definition of a symbol
|
|
387
|
-
- \`ace-find_references\` - Find all usages of a symbol
|
|
388
|
-
- \`ace-text_search\` - Literal text/regex search (for strings, comments, TODOs)`;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
// Export SYSTEM_PROMPT as a getter function for real-time ROLE.md updates
|
|
392
|
-
export function getSystemPrompt() {
|
|
393
|
-
const basePrompt = getSystemPromptWithRole();
|
|
394
|
-
const systemEnv = getSystemEnvironmentInfo();
|
|
395
|
-
const hasCodebase = isCodebaseEnabled();
|
|
396
|
-
// Generate dynamic sections
|
|
397
|
-
const workflowSection = getWorkflowSection(hasCodebase);
|
|
398
|
-
const codeSearchSection = getCodeSearchSection(hasCodebase);
|
|
399
|
-
// Replace placeholders with actual content
|
|
400
|
-
const finalPrompt = basePrompt
|
|
401
|
-
.replace('PLACEHOLDER_FOR_WORKFLOW_SECTION', workflowSection)
|
|
402
|
-
.replace('PLACEHOLDER_FOR_CODE_SEARCH_SECTION', codeSearchSection);
|
|
403
|
-
return `${finalPrompt}
|
|
404
|
-
|
|
405
|
-
## System Environment
|
|
406
|
-
|
|
407
|
-
${systemEnv}`;
|
|
408
|
-
}
|
package/dist/api/types.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared API types for all AI providers
|
|
3
|
-
*/
|
|
4
|
-
export interface ImageContent {
|
|
5
|
-
type: 'image';
|
|
6
|
-
data: string;
|
|
7
|
-
mimeType: string;
|
|
8
|
-
}
|
|
9
|
-
export interface ToolCall {
|
|
10
|
-
id: string;
|
|
11
|
-
type: 'function';
|
|
12
|
-
function: {
|
|
13
|
-
name: string;
|
|
14
|
-
arguments: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export interface ChatMessage {
|
|
18
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
19
|
-
content: string;
|
|
20
|
-
tool_call_id?: string;
|
|
21
|
-
tool_calls?: ToolCall[];
|
|
22
|
-
images?: ImageContent[];
|
|
23
|
-
subAgentInternal?: boolean;
|
|
24
|
-
reasoning?: {
|
|
25
|
-
summary?: Array<{
|
|
26
|
-
type: 'summary_text';
|
|
27
|
-
text: string;
|
|
28
|
-
}>;
|
|
29
|
-
content?: any;
|
|
30
|
-
encrypted_content?: string;
|
|
31
|
-
};
|
|
32
|
-
thinking?: {
|
|
33
|
-
type: 'thinking';
|
|
34
|
-
thinking: string;
|
|
35
|
-
signature?: string;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface ChatCompletionTool {
|
|
39
|
-
type: 'function';
|
|
40
|
-
function: {
|
|
41
|
-
name: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
parameters?: Record<string, any>;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export interface UsageInfo {
|
|
47
|
-
prompt_tokens: number;
|
|
48
|
-
completion_tokens: number;
|
|
49
|
-
total_tokens: number;
|
|
50
|
-
cache_creation_input_tokens?: number;
|
|
51
|
-
cache_read_input_tokens?: number;
|
|
52
|
-
cached_tokens?: number;
|
|
53
|
-
}
|
package/dist/api/types.js
DELETED
package/dist/app.d.ts
DELETED
package/dist/app.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, Suspense } from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { Alert } from '@inkjs/ui';
|
|
4
|
-
import Spinner from 'ink-spinner';
|
|
5
|
-
// Lazy load all page components to improve startup time
|
|
6
|
-
// Only load components when they are actually needed
|
|
7
|
-
const WelcomeScreen = React.lazy(() => import('./ui/pages/WelcomeScreen.js'));
|
|
8
|
-
const ChatScreen = React.lazy(() => import('./ui/pages/ChatScreen.js'));
|
|
9
|
-
const HeadlessModeScreen = React.lazy(() => import('./ui/pages/HeadlessModeScreen.js'));
|
|
10
|
-
const MCPConfigScreen = React.lazy(() => import('./ui/pages/MCPConfigScreen.js'));
|
|
11
|
-
const SystemPromptConfigScreen = React.lazy(() => import('./ui/pages/SystemPromptConfigScreen.js'));
|
|
12
|
-
const CustomHeadersScreen = React.lazy(() => import('./ui/pages/CustomHeadersScreen.js'));
|
|
13
|
-
import { useGlobalExit, } from './hooks/useGlobalExit.js';
|
|
14
|
-
import { onNavigate } from './hooks/useGlobalNavigation.js';
|
|
15
|
-
import { useTerminalSize } from './hooks/useTerminalSize.js';
|
|
16
|
-
import { I18nProvider } from './i18n/index.js';
|
|
17
|
-
import { ThemeProvider } from './ui/contexts/ThemeContext.js';
|
|
18
|
-
// Inner component that uses I18n context
|
|
19
|
-
function AppContent({ version, skipWelcome, }) {
|
|
20
|
-
const [currentView, setCurrentView] = useState(skipWelcome ? 'chat' : 'welcome');
|
|
21
|
-
// Add a key to force remount ChatScreen when returning from welcome screen
|
|
22
|
-
// This ensures configuration changes are picked up
|
|
23
|
-
const [chatScreenKey, setChatScreenKey] = useState(0);
|
|
24
|
-
const [exitNotification, setExitNotification] = useState({
|
|
25
|
-
show: false,
|
|
26
|
-
message: '',
|
|
27
|
-
});
|
|
28
|
-
// Get terminal size for proper width calculation
|
|
29
|
-
const { columns: terminalWidth } = useTerminalSize();
|
|
30
|
-
// Global exit handler (must be inside I18nProvider)
|
|
31
|
-
useGlobalExit(setExitNotification);
|
|
32
|
-
// Global navigation handler
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const unsubscribe = onNavigate(event => {
|
|
35
|
-
// When navigating to welcome from chat (e.g., /home command),
|
|
36
|
-
// increment key so next time chat is entered, it remounts with fresh config
|
|
37
|
-
if (event.destination === 'welcome' && currentView === 'chat') {
|
|
38
|
-
setChatScreenKey(prev => prev + 1);
|
|
39
|
-
}
|
|
40
|
-
setCurrentView(event.destination);
|
|
41
|
-
});
|
|
42
|
-
return unsubscribe;
|
|
43
|
-
}, [currentView]);
|
|
44
|
-
const handleMenuSelect = (value) => {
|
|
45
|
-
if (value === 'chat' ||
|
|
46
|
-
value === 'settings' ||
|
|
47
|
-
value === 'mcp' ||
|
|
48
|
-
value === 'systemprompt' ||
|
|
49
|
-
value === 'customheaders') {
|
|
50
|
-
// When entering chat from welcome screen, increment key to force remount
|
|
51
|
-
// This ensures any configuration changes are picked up
|
|
52
|
-
if (value === 'chat' && currentView === 'welcome') {
|
|
53
|
-
setChatScreenKey(prev => prev + 1);
|
|
54
|
-
}
|
|
55
|
-
setCurrentView(value);
|
|
56
|
-
}
|
|
57
|
-
else if (value === 'exit') {
|
|
58
|
-
process.exit(0);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const renderView = () => {
|
|
62
|
-
const loadingFallback = (React.createElement(Box, null,
|
|
63
|
-
React.createElement(Text, { color: "cyan" },
|
|
64
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
65
|
-
React.createElement(Text, null, " Loading...")));
|
|
66
|
-
switch (currentView) {
|
|
67
|
-
case 'welcome':
|
|
68
|
-
return (React.createElement(Suspense, { fallback: loadingFallback },
|
|
69
|
-
React.createElement(WelcomeScreen, { version: version, onMenuSelect: handleMenuSelect })));
|
|
70
|
-
case 'chat':
|
|
71
|
-
return (React.createElement(Suspense, { fallback: loadingFallback },
|
|
72
|
-
React.createElement(ChatScreen, { key: chatScreenKey, skipWelcome: skipWelcome })));
|
|
73
|
-
case 'settings':
|
|
74
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
75
|
-
React.createElement(Text, { color: "blue" }, "Settings"),
|
|
76
|
-
React.createElement(Text, { color: "gray" }, "Settings interface would be implemented here")));
|
|
77
|
-
case 'mcp':
|
|
78
|
-
return (React.createElement(Suspense, { fallback: loadingFallback },
|
|
79
|
-
React.createElement(MCPConfigScreen, { onBack: () => setCurrentView('welcome'), onSave: () => setCurrentView('welcome') })));
|
|
80
|
-
case 'systemprompt':
|
|
81
|
-
return (React.createElement(Suspense, { fallback: loadingFallback },
|
|
82
|
-
React.createElement(SystemPromptConfigScreen, { onBack: () => setCurrentView('welcome') })));
|
|
83
|
-
case 'customheaders':
|
|
84
|
-
return (React.createElement(Suspense, { fallback: loadingFallback },
|
|
85
|
-
React.createElement(CustomHeadersScreen, { onBack: () => setCurrentView('welcome') })));
|
|
86
|
-
default:
|
|
87
|
-
return (React.createElement(Suspense, { fallback: loadingFallback },
|
|
88
|
-
React.createElement(WelcomeScreen, { version: version, onMenuSelect: handleMenuSelect })));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
return (React.createElement(Box, { flexDirection: "column", width: terminalWidth },
|
|
92
|
-
renderView(),
|
|
93
|
-
exitNotification.show && (React.createElement(Box, { paddingX: 1, flexShrink: 0 },
|
|
94
|
-
React.createElement(Alert, { variant: "warning" }, exitNotification.message)))));
|
|
95
|
-
}
|
|
96
|
-
export default function App({ version, skipWelcome, headlessPrompt }) {
|
|
97
|
-
// If headless prompt is provided, use headless mode
|
|
98
|
-
// Wrap in I18nProvider since HeadlessModeScreen might use hooks that depend on it
|
|
99
|
-
if (headlessPrompt) {
|
|
100
|
-
const loadingFallback = (React.createElement(Box, null,
|
|
101
|
-
React.createElement(Text, { color: "cyan" },
|
|
102
|
-
React.createElement(Spinner, { type: "dots" })),
|
|
103
|
-
React.createElement(Text, null, " Loading...")));
|
|
104
|
-
return (React.createElement(I18nProvider, null,
|
|
105
|
-
React.createElement(ThemeProvider, null,
|
|
106
|
-
React.createElement(Suspense, { fallback: loadingFallback },
|
|
107
|
-
React.createElement(HeadlessModeScreen, { prompt: headlessPrompt, onComplete: () => process.exit(0) })))));
|
|
108
|
-
}
|
|
109
|
-
return (React.createElement(I18nProvider, null,
|
|
110
|
-
React.createElement(ThemeProvider, null,
|
|
111
|
-
React.createElement(AppContent, { version: version, skipWelcome: skipWelcome }))));
|
|
112
|
-
}
|
package/dist/cli.d.ts
DELETED