snow-ai 0.3.6 → 0.3.8

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 (127) hide show
  1. package/dist/agents/compactAgent.js +7 -3
  2. package/dist/agents/reviewAgent.d.ts +50 -0
  3. package/dist/agents/reviewAgent.js +264 -0
  4. package/dist/agents/summaryAgent.d.ts +34 -8
  5. package/dist/agents/summaryAgent.js +167 -164
  6. package/dist/api/anthropic.d.ts +1 -0
  7. package/dist/api/anthropic.js +118 -78
  8. package/dist/api/chat.d.ts +2 -1
  9. package/dist/api/chat.js +82 -52
  10. package/dist/api/gemini.d.ts +1 -0
  11. package/dist/api/gemini.js +110 -64
  12. package/dist/api/responses.d.ts +10 -1
  13. package/dist/api/responses.js +127 -79
  14. package/dist/api/systemPrompt.d.ts +1 -1
  15. package/dist/api/systemPrompt.js +36 -7
  16. package/dist/api/types.d.ts +8 -0
  17. package/dist/app.js +15 -2
  18. package/dist/hooks/useCommandHandler.d.ts +1 -0
  19. package/dist/hooks/useCommandHandler.js +102 -1
  20. package/dist/hooks/useCommandPanel.d.ts +2 -1
  21. package/dist/hooks/useCommandPanel.js +19 -1
  22. package/dist/hooks/useConversation.d.ts +4 -1
  23. package/dist/hooks/useConversation.js +91 -29
  24. package/dist/hooks/useKeyboardInput.js +19 -0
  25. package/dist/hooks/useSnapshotState.d.ts +2 -0
  26. package/dist/hooks/useTerminalFocus.js +13 -3
  27. package/dist/mcp/aceCodeSearch.d.ts +2 -76
  28. package/dist/mcp/aceCodeSearch.js +31 -467
  29. package/dist/mcp/bash.d.ts +1 -8
  30. package/dist/mcp/bash.js +20 -40
  31. package/dist/mcp/filesystem.d.ts +131 -111
  32. package/dist/mcp/filesystem.js +212 -375
  33. package/dist/mcp/ideDiagnostics.js +2 -4
  34. package/dist/mcp/todo.d.ts +1 -17
  35. package/dist/mcp/todo.js +11 -15
  36. package/dist/mcp/types/aceCodeSearch.types.d.ts +92 -0
  37. package/dist/mcp/types/aceCodeSearch.types.js +4 -0
  38. package/dist/mcp/types/bash.types.d.ts +13 -0
  39. package/dist/mcp/types/bash.types.js +4 -0
  40. package/dist/mcp/types/filesystem.types.d.ts +135 -0
  41. package/dist/mcp/types/filesystem.types.js +4 -0
  42. package/dist/mcp/types/todo.types.d.ts +27 -0
  43. package/dist/mcp/types/todo.types.js +4 -0
  44. package/dist/mcp/types/websearch.types.d.ts +30 -0
  45. package/dist/mcp/types/websearch.types.js +4 -0
  46. package/dist/mcp/utils/aceCodeSearch/filesystem.utils.d.ts +34 -0
  47. package/dist/mcp/utils/aceCodeSearch/filesystem.utils.js +146 -0
  48. package/dist/mcp/utils/aceCodeSearch/language.utils.d.ts +14 -0
  49. package/dist/mcp/utils/aceCodeSearch/language.utils.js +99 -0
  50. package/dist/mcp/utils/aceCodeSearch/search.utils.d.ts +31 -0
  51. package/dist/mcp/utils/aceCodeSearch/search.utils.js +136 -0
  52. package/dist/mcp/utils/aceCodeSearch/symbol.utils.d.ts +20 -0
  53. package/dist/mcp/utils/aceCodeSearch/symbol.utils.js +141 -0
  54. package/dist/mcp/utils/bash/security.utils.d.ts +20 -0
  55. package/dist/mcp/utils/bash/security.utils.js +34 -0
  56. package/dist/mcp/utils/filesystem/batch-operations.utils.d.ts +39 -0
  57. package/dist/mcp/utils/filesystem/batch-operations.utils.js +182 -0
  58. package/dist/mcp/utils/filesystem/code-analysis.utils.d.ts +18 -0
  59. package/dist/mcp/utils/filesystem/code-analysis.utils.js +165 -0
  60. package/dist/mcp/utils/filesystem/match-finder.utils.d.ts +16 -0
  61. package/dist/mcp/utils/filesystem/match-finder.utils.js +85 -0
  62. package/dist/mcp/utils/filesystem/similarity.utils.d.ts +22 -0
  63. package/dist/mcp/utils/filesystem/similarity.utils.js +75 -0
  64. package/dist/mcp/utils/todo/date.utils.d.ts +9 -0
  65. package/dist/mcp/utils/todo/date.utils.js +14 -0
  66. package/dist/mcp/utils/websearch/browser.utils.d.ts +8 -0
  67. package/dist/mcp/utils/websearch/browser.utils.js +58 -0
  68. package/dist/mcp/utils/websearch/text.utils.d.ts +16 -0
  69. package/dist/mcp/utils/websearch/text.utils.js +39 -0
  70. package/dist/mcp/websearch.d.ts +1 -31
  71. package/dist/mcp/websearch.js +21 -97
  72. package/dist/ui/components/ChatInput.d.ts +3 -1
  73. package/dist/ui/components/ChatInput.js +12 -5
  74. package/dist/ui/components/CommandPanel.d.ts +2 -1
  75. package/dist/ui/components/CommandPanel.js +18 -3
  76. package/dist/ui/components/MarkdownRenderer.d.ts +1 -2
  77. package/dist/ui/components/MarkdownRenderer.js +25 -153
  78. package/dist/ui/components/MessageList.js +5 -5
  79. package/dist/ui/components/PendingMessages.js +1 -1
  80. package/dist/ui/components/PendingToolCalls.d.ts +11 -0
  81. package/dist/ui/components/PendingToolCalls.js +35 -0
  82. package/dist/ui/components/SessionListScreen.js +37 -17
  83. package/dist/ui/components/ToolResultPreview.d.ts +1 -1
  84. package/dist/ui/components/ToolResultPreview.js +119 -155
  85. package/dist/ui/components/UsagePanel.d.ts +2 -0
  86. package/dist/ui/components/UsagePanel.js +360 -0
  87. package/dist/ui/pages/ChatScreen.d.ts +5 -0
  88. package/dist/ui/pages/ChatScreen.js +164 -85
  89. package/dist/ui/pages/ConfigScreen.js +23 -19
  90. package/dist/ui/pages/HeadlessModeScreen.js +2 -4
  91. package/dist/ui/pages/SubAgentConfigScreen.js +17 -17
  92. package/dist/ui/pages/SystemPromptConfigScreen.js +7 -6
  93. package/dist/utils/chatExporter.d.ts +9 -0
  94. package/dist/utils/chatExporter.js +126 -0
  95. package/dist/utils/commandExecutor.d.ts +3 -3
  96. package/dist/utils/commandExecutor.js +4 -4
  97. package/dist/utils/commands/export.d.ts +2 -0
  98. package/dist/utils/commands/export.js +12 -0
  99. package/dist/utils/commands/home.d.ts +2 -0
  100. package/dist/utils/commands/home.js +12 -0
  101. package/dist/utils/commands/init.js +3 -3
  102. package/dist/utils/commands/review.d.ts +2 -0
  103. package/dist/utils/commands/review.js +81 -0
  104. package/dist/utils/commands/role.d.ts +2 -0
  105. package/dist/utils/commands/role.js +37 -0
  106. package/dist/utils/commands/usage.d.ts +2 -0
  107. package/dist/utils/commands/usage.js +12 -0
  108. package/dist/utils/contextCompressor.js +99 -367
  109. package/dist/utils/fileDialog.d.ts +9 -0
  110. package/dist/utils/fileDialog.js +74 -0
  111. package/dist/utils/incrementalSnapshot.d.ts +7 -0
  112. package/dist/utils/incrementalSnapshot.js +35 -0
  113. package/dist/utils/mcpToolsManager.js +12 -12
  114. package/dist/utils/messageFormatter.js +89 -6
  115. package/dist/utils/proxyUtils.d.ts +15 -0
  116. package/dist/utils/proxyUtils.js +50 -0
  117. package/dist/utils/retryUtils.d.ts +27 -0
  118. package/dist/utils/retryUtils.js +114 -2
  119. package/dist/utils/sessionConverter.js +11 -0
  120. package/dist/utils/sessionManager.d.ts +7 -5
  121. package/dist/utils/sessionManager.js +60 -82
  122. package/dist/utils/terminal.js +4 -3
  123. package/dist/utils/toolDisplayConfig.d.ts +16 -0
  124. package/dist/utils/toolDisplayConfig.js +42 -0
  125. package/dist/utils/usageLogger.d.ts +11 -0
  126. package/dist/utils/usageLogger.js +99 -0
  127. package/package.json +3 -7
@@ -0,0 +1,126 @@
1
+ import * as fs from 'fs/promises';
2
+ /**
3
+ * Format messages to plain text for export
4
+ */
5
+ export function formatMessagesAsText(messages) {
6
+ const lines = [];
7
+ const timestamp = new Date().toISOString();
8
+ // Add header
9
+ lines.push('=====================================');
10
+ lines.push('Snow AI - Chat Export');
11
+ lines.push(`Exported at: ${new Date(timestamp).toLocaleString()}`);
12
+ lines.push('=====================================');
13
+ lines.push('');
14
+ // Format each message
15
+ for (const message of messages) {
16
+ // Skip command messages
17
+ if (message.role === 'command') {
18
+ continue;
19
+ }
20
+ // Add role header
21
+ let roleLabel = '';
22
+ if (message.role === 'user') {
23
+ roleLabel = 'USER';
24
+ }
25
+ else if (message.role === 'assistant') {
26
+ roleLabel = 'ASSISTANT';
27
+ }
28
+ else if (message.role === 'subagent') {
29
+ roleLabel = 'SUBAGENT';
30
+ }
31
+ else {
32
+ roleLabel = 'UNKNOWN';
33
+ }
34
+ lines.push(`[${roleLabel}]`);
35
+ lines.push('-'.repeat(40));
36
+ // Add content (Message.content is always string based on the type definition)
37
+ lines.push(message.content);
38
+ // Add tool call information if present
39
+ if (message.toolCall) {
40
+ lines.push('');
41
+ lines.push(`[TOOL CALL: ${message.toolCall.name}]`);
42
+ try {
43
+ const argsStr = typeof message.toolCall.arguments === 'string'
44
+ ? message.toolCall.arguments
45
+ : JSON.stringify(message.toolCall.arguments, null, 2);
46
+ lines.push(argsStr);
47
+ }
48
+ catch {
49
+ lines.push(String(message.toolCall.arguments));
50
+ }
51
+ }
52
+ // Add tool display information if present
53
+ if (message.toolDisplay) {
54
+ lines.push('');
55
+ lines.push(`[TOOL: ${message.toolDisplay.toolName}]`);
56
+ for (const arg of message.toolDisplay.args) {
57
+ lines.push(` ${arg.key}: ${arg.value}`);
58
+ }
59
+ }
60
+ // Add tool result if present
61
+ if (message.toolResult) {
62
+ lines.push('');
63
+ lines.push('[TOOL RESULT]');
64
+ try {
65
+ const result = JSON.parse(message.toolResult);
66
+ lines.push(JSON.stringify(result, null, 2));
67
+ }
68
+ catch {
69
+ lines.push(message.toolResult);
70
+ }
71
+ }
72
+ // Add terminal result if present
73
+ if (message.terminalResult) {
74
+ lines.push('');
75
+ if (message.terminalResult.command) {
76
+ lines.push(`[COMMAND: ${message.terminalResult.command}]`);
77
+ }
78
+ if (message.terminalResult.stdout) {
79
+ lines.push('[STDOUT]');
80
+ lines.push(message.terminalResult.stdout);
81
+ }
82
+ if (message.terminalResult.stderr) {
83
+ lines.push('[STDERR]');
84
+ lines.push(message.terminalResult.stderr);
85
+ }
86
+ if (message.terminalResult.exitCode !== undefined) {
87
+ lines.push(`[EXIT CODE: ${message.terminalResult.exitCode}]`);
88
+ }
89
+ }
90
+ // Add images information if present
91
+ if (message.images && message.images.length > 0) {
92
+ lines.push('');
93
+ lines.push(`[${message.images.length} image(s) attached]`);
94
+ }
95
+ // Add system info if present
96
+ if (message.systemInfo) {
97
+ lines.push('');
98
+ lines.push('[SYSTEM INFO]');
99
+ lines.push(`Platform: ${message.systemInfo.platform}`);
100
+ lines.push(`Shell: ${message.systemInfo.shell}`);
101
+ lines.push(`Working Directory: ${message.systemInfo.workingDirectory}`);
102
+ }
103
+ // Add files information if present
104
+ if (message.files && message.files.length > 0) {
105
+ lines.push('');
106
+ lines.push(`[${message.files.length} file(s) referenced]`);
107
+ for (const file of message.files) {
108
+ lines.push(` - ${file.path}`);
109
+ }
110
+ }
111
+ lines.push('');
112
+ lines.push('');
113
+ }
114
+ // Add footer
115
+ lines.push('=====================================');
116
+ lines.push('End of Chat Export');
117
+ lines.push('=====================================');
118
+ return lines.join('\n');
119
+ }
120
+ /**
121
+ * Export messages to a file
122
+ */
123
+ export async function exportMessagesToFile(messages, filePath) {
124
+ const textContent = formatMessagesAsText(messages);
125
+ await fs.writeFile(filePath, textContent, 'utf-8');
126
+ }
@@ -1,13 +1,13 @@
1
1
  export interface CommandResult {
2
2
  success: boolean;
3
3
  message?: string;
4
- action?: 'clear' | 'resume' | 'info' | 'showMcpInfo' | 'toggleYolo' | 'initProject' | 'compact' | 'showSessionPanel' | 'showMcpPanel';
4
+ action?: 'clear' | 'resume' | 'info' | 'showMcpInfo' | 'toggleYolo' | 'initProject' | 'compact' | 'showSessionPanel' | 'showMcpPanel' | 'showUsagePanel' | 'home' | 'review' | 'exportChat';
5
5
  prompt?: string;
6
6
  alreadyConnected?: boolean;
7
7
  }
8
8
  export interface CommandHandler {
9
- execute: () => Promise<CommandResult> | CommandResult;
9
+ execute: (args?: string) => Promise<CommandResult> | CommandResult;
10
10
  }
11
11
  export declare function registerCommand(name: string, handler: CommandHandler): void;
12
- export declare function executeCommand(commandName: string): Promise<CommandResult>;
12
+ export declare function executeCommand(commandName: string, args?: string): Promise<CommandResult>;
13
13
  export declare function getAvailableCommands(): string[];
@@ -2,22 +2,22 @@ const commandHandlers = {};
2
2
  export function registerCommand(name, handler) {
3
3
  commandHandlers[name] = handler;
4
4
  }
5
- export async function executeCommand(commandName) {
5
+ export async function executeCommand(commandName, args) {
6
6
  const handler = commandHandlers[commandName];
7
7
  if (!handler) {
8
8
  return {
9
9
  success: false,
10
- message: `Unknown command: ${commandName}`
10
+ message: `Unknown command: ${commandName}`,
11
11
  };
12
12
  }
13
13
  try {
14
- const result = await handler.execute();
14
+ const result = await handler.execute(args);
15
15
  return result;
16
16
  }
17
17
  catch (error) {
18
18
  return {
19
19
  success: false,
20
- message: error instanceof Error ? error.message : 'Command execution failed'
20
+ message: error instanceof Error ? error.message : 'Command execution failed',
21
21
  };
22
22
  }
23
23
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { registerCommand } from '../commandExecutor.js';
2
+ // Export command handler - exports chat conversation to text file
3
+ registerCommand('export', {
4
+ execute: () => {
5
+ return {
6
+ success: true,
7
+ action: 'exportChat',
8
+ message: 'Exporting conversation...'
9
+ };
10
+ }
11
+ });
12
+ export default {};
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { registerCommand } from '../commandExecutor.js';
2
+ // Home command handler - returns to welcome screen
3
+ registerCommand('home', {
4
+ execute: () => {
5
+ return {
6
+ success: true,
7
+ action: 'home',
8
+ message: 'Returning to welcome screen'
9
+ };
10
+ }
11
+ });
12
+ export default {};
@@ -83,11 +83,11 @@ License information (check package.json or LICENSE file)
83
83
  - Be thorough but concise - focus on essential information
84
84
  - If SNOW.md already exists, read it first and UPDATE it rather than replace
85
85
  - Format with proper Markdown syntax
86
- - After generating content, use filesystem-write or filesystem-create to save SNOW.md in the project root
86
+ - After generating content, use filesystem-create to save SNOW.md in the project root
87
87
  - Confirm completion with a brief summary
88
88
 
89
- Begin your analysis now. Use every tool at your disposal to understand this project completely.`
89
+ Begin your analysis now. Use every tool at your disposal to understand this project completely.`,
90
90
  };
91
- }
91
+ },
92
92
  });
93
93
  export default {};
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,81 @@
1
+ import { registerCommand } from '../commandExecutor.js';
2
+ import { reviewAgent } from '../../agents/reviewAgent.js';
3
+ // Review command handler - review git changes
4
+ registerCommand('review', {
5
+ execute: async (args) => {
6
+ try {
7
+ // Check if git repository exists
8
+ const gitCheck = reviewAgent.checkGitRepository();
9
+ if (!gitCheck.isGitRepo) {
10
+ return {
11
+ success: false,
12
+ message: gitCheck.error || 'Not a git repository',
13
+ };
14
+ }
15
+ // Get git diff
16
+ const gitDiff = reviewAgent.getGitDiff(gitCheck.gitRoot);
17
+ if (gitDiff === 'No changes detected in the repository.') {
18
+ return {
19
+ success: false,
20
+ message: 'No changes detected. Please make some changes before running code review.',
21
+ };
22
+ }
23
+ // Parse additional message from args (format: [message])
24
+ let additionalMessage = '';
25
+ if (args) {
26
+ const match = args.match(/\[([^\]]+)\]/);
27
+ if (match && match[1]) {
28
+ additionalMessage = match[1].trim();
29
+ }
30
+ }
31
+ // Generate review prompt
32
+ let reviewPrompt = `You are a senior code reviewer. Please review the following git changes and provide feedback.
33
+
34
+ **Your task:**
35
+ 1. Identify potential bugs, security issues, or logic errors
36
+ 2. Suggest performance optimizations
37
+ 3. Point out code quality issues (readability, maintainability)
38
+ 4. Check for best practices violations
39
+ 5. Highlight any breaking changes or compatibility issues
40
+
41
+ **Important:**
42
+ - DO NOT modify the code yourself
43
+ - Focus on finding issues and suggesting improvements
44
+ - Ask the user if they want to fix any issues you find
45
+ - Be constructive and specific in your feedback
46
+ - Prioritize critical issues over minor style preferences`;
47
+ // Add additional message if provided
48
+ if (additionalMessage) {
49
+ reviewPrompt += `
50
+
51
+ **User's Additional Notes:**
52
+ ${additionalMessage}`;
53
+ }
54
+ reviewPrompt += `
55
+
56
+ **Git Changes:**
57
+
58
+ \`\`\`diff
59
+ ${gitDiff}
60
+ \`\`\`
61
+
62
+ Please provide your review in a clear, structured format.`;
63
+ // Return success with review action and prompt
64
+ return {
65
+ success: true,
66
+ action: 'review',
67
+ prompt: reviewPrompt,
68
+ message: 'Starting code review...',
69
+ };
70
+ }
71
+ catch (error) {
72
+ return {
73
+ success: false,
74
+ message: error instanceof Error
75
+ ? error.message
76
+ : 'Failed to start code review',
77
+ };
78
+ }
79
+ },
80
+ });
81
+ export default {};
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import { registerCommand } from '../commandExecutor.js';
2
+ import fs from 'fs/promises';
3
+ import path from 'path';
4
+ // Role command handler - create ROLE.md file in project root
5
+ registerCommand('role', {
6
+ execute: async () => {
7
+ try {
8
+ const cwd = process.cwd();
9
+ const roleFilePath = path.join(cwd, 'ROLE.md');
10
+ // Check if ROLE.md exists
11
+ let fileExists = false;
12
+ try {
13
+ await fs.access(roleFilePath);
14
+ fileExists = true;
15
+ }
16
+ catch {
17
+ // File doesn't exist, create it
18
+ await fs.writeFile(roleFilePath, '', 'utf-8');
19
+ }
20
+ return {
21
+ success: true,
22
+ message: fileExists
23
+ ? `ROLE.md already exists at: ${roleFilePath}`
24
+ : `Created ROLE.md at: ${roleFilePath}`,
25
+ };
26
+ }
27
+ catch (error) {
28
+ return {
29
+ success: false,
30
+ message: error instanceof Error
31
+ ? error.message
32
+ : 'Failed to handle ROLE.md file',
33
+ };
34
+ }
35
+ },
36
+ });
37
+ export default {};
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { registerCommand } from '../commandExecutor.js';
2
+ // Usage command handler - shows usage statistics panel
3
+ registerCommand('usage', {
4
+ execute: () => {
5
+ return {
6
+ success: true,
7
+ action: 'showUsagePanel',
8
+ message: 'Showing usage statistics'
9
+ };
10
+ }
11
+ });
12
+ export default {};