snow-ai 0.3.6 → 0.3.7
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/dist/agents/reviewAgent.d.ts +50 -0
- package/dist/agents/reviewAgent.js +264 -0
- package/dist/api/anthropic.js +104 -71
- package/dist/api/chat.d.ts +1 -1
- package/dist/api/chat.js +60 -41
- package/dist/api/gemini.js +97 -57
- package/dist/api/responses.d.ts +9 -1
- package/dist/api/responses.js +110 -70
- package/dist/api/systemPrompt.d.ts +1 -1
- package/dist/api/systemPrompt.js +36 -7
- package/dist/api/types.d.ts +8 -0
- package/dist/hooks/useCommandHandler.d.ts +1 -0
- package/dist/hooks/useCommandHandler.js +44 -1
- package/dist/hooks/useCommandPanel.js +13 -0
- package/dist/hooks/useConversation.d.ts +4 -1
- package/dist/hooks/useConversation.js +48 -6
- package/dist/hooks/useKeyboardInput.js +19 -0
- package/dist/hooks/useTerminalFocus.js +13 -3
- package/dist/mcp/aceCodeSearch.d.ts +2 -76
- package/dist/mcp/aceCodeSearch.js +31 -467
- package/dist/mcp/bash.d.ts +1 -8
- package/dist/mcp/bash.js +20 -40
- package/dist/mcp/filesystem.d.ts +3 -68
- package/dist/mcp/filesystem.js +32 -348
- package/dist/mcp/ideDiagnostics.js +2 -4
- package/dist/mcp/todo.d.ts +1 -17
- package/dist/mcp/todo.js +11 -15
- package/dist/mcp/types/aceCodeSearch.types.d.ts +92 -0
- package/dist/mcp/types/aceCodeSearch.types.js +4 -0
- package/dist/mcp/types/bash.types.d.ts +13 -0
- package/dist/mcp/types/bash.types.js +4 -0
- package/dist/mcp/types/filesystem.types.d.ts +44 -0
- package/dist/mcp/types/filesystem.types.js +4 -0
- package/dist/mcp/types/todo.types.d.ts +27 -0
- package/dist/mcp/types/todo.types.js +4 -0
- package/dist/mcp/types/websearch.types.d.ts +30 -0
- package/dist/mcp/types/websearch.types.js +4 -0
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.d.ts +34 -0
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.js +146 -0
- package/dist/mcp/utils/aceCodeSearch/language.utils.d.ts +14 -0
- package/dist/mcp/utils/aceCodeSearch/language.utils.js +99 -0
- package/dist/mcp/utils/aceCodeSearch/search.utils.d.ts +31 -0
- package/dist/mcp/utils/aceCodeSearch/search.utils.js +136 -0
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.d.ts +20 -0
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.js +141 -0
- package/dist/mcp/utils/bash/security.utils.d.ts +20 -0
- package/dist/mcp/utils/bash/security.utils.js +34 -0
- package/dist/mcp/utils/filesystem/code-analysis.utils.d.ts +18 -0
- package/dist/mcp/utils/filesystem/code-analysis.utils.js +165 -0
- package/dist/mcp/utils/filesystem/match-finder.utils.d.ts +16 -0
- package/dist/mcp/utils/filesystem/match-finder.utils.js +85 -0
- package/dist/mcp/utils/filesystem/similarity.utils.d.ts +22 -0
- package/dist/mcp/utils/filesystem/similarity.utils.js +75 -0
- package/dist/mcp/utils/todo/date.utils.d.ts +9 -0
- package/dist/mcp/utils/todo/date.utils.js +14 -0
- package/dist/mcp/utils/websearch/browser.utils.d.ts +8 -0
- package/dist/mcp/utils/websearch/browser.utils.js +58 -0
- package/dist/mcp/utils/websearch/text.utils.d.ts +16 -0
- package/dist/mcp/utils/websearch/text.utils.js +39 -0
- package/dist/mcp/websearch.d.ts +1 -31
- package/dist/mcp/websearch.js +21 -97
- package/dist/ui/components/ChatInput.d.ts +2 -1
- package/dist/ui/components/ChatInput.js +10 -3
- package/dist/ui/components/MarkdownRenderer.d.ts +1 -2
- package/dist/ui/components/MarkdownRenderer.js +16 -153
- package/dist/ui/components/MessageList.js +4 -4
- package/dist/ui/components/SessionListScreen.js +37 -17
- package/dist/ui/components/ToolResultPreview.js +6 -6
- package/dist/ui/components/UsagePanel.d.ts +2 -0
- package/dist/ui/components/UsagePanel.js +360 -0
- package/dist/ui/pages/ChatScreen.d.ts +4 -0
- package/dist/ui/pages/ChatScreen.js +70 -30
- package/dist/ui/pages/ConfigScreen.js +23 -19
- package/dist/ui/pages/HeadlessModeScreen.js +2 -4
- package/dist/ui/pages/SubAgentConfigScreen.js +17 -17
- package/dist/ui/pages/SystemPromptConfigScreen.js +7 -6
- package/dist/utils/commandExecutor.d.ts +3 -3
- package/dist/utils/commandExecutor.js +4 -4
- package/dist/utils/commands/home.d.ts +2 -0
- package/dist/utils/commands/home.js +12 -0
- package/dist/utils/commands/review.d.ts +2 -0
- package/dist/utils/commands/review.js +81 -0
- package/dist/utils/commands/role.d.ts +2 -0
- package/dist/utils/commands/role.js +37 -0
- package/dist/utils/commands/usage.d.ts +2 -0
- package/dist/utils/commands/usage.js +12 -0
- package/dist/utils/contextCompressor.js +99 -367
- package/dist/utils/fileUtils.js +3 -3
- package/dist/utils/mcpToolsManager.js +12 -12
- package/dist/utils/proxyUtils.d.ts +15 -0
- package/dist/utils/proxyUtils.js +50 -0
- package/dist/utils/retryUtils.d.ts +27 -0
- package/dist/utils/retryUtils.js +114 -2
- package/dist/utils/sessionManager.d.ts +2 -5
- package/dist/utils/sessionManager.js +16 -83
- package/dist/utils/terminal.js +4 -3
- package/dist/utils/usageLogger.d.ts +11 -0
- package/dist/utils/usageLogger.js +99 -0
- package/package.json +3 -7
- package/dist/agents/summaryAgent.d.ts +0 -31
- package/dist/agents/summaryAgent.js +0 -256
|
@@ -8,30 +8,30 @@ const toolCategories = [
|
|
|
8
8
|
{
|
|
9
9
|
name: 'Filesystem Tools',
|
|
10
10
|
tools: [
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
11
|
+
'filesystem-read',
|
|
12
|
+
'filesystem-create',
|
|
13
|
+
'filesystem-edit',
|
|
14
|
+
'filesystem-edit_search',
|
|
15
|
+
'filesystem-delete',
|
|
16
|
+
'filesystem-list',
|
|
17
17
|
],
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
name: 'ACE Code Search Tools',
|
|
21
21
|
tools: [
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
22
|
+
'ace-search_symbols',
|
|
23
|
+
'ace-find_definition',
|
|
24
|
+
'ace-find_references',
|
|
25
|
+
'ace-semantic_search',
|
|
26
|
+
'ace-text_search',
|
|
27
|
+
'ace-file_outline',
|
|
28
|
+
'ace-index_stats',
|
|
29
|
+
'ace-clear_cache',
|
|
30
30
|
],
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
name: 'Terminal Tools',
|
|
34
|
-
tools: ['
|
|
34
|
+
tools: ['terminal-execute'],
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
name: 'TODO Management Tools',
|
|
@@ -45,11 +45,11 @@ const toolCategories = [
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
name: 'Web Search Tools',
|
|
48
|
-
tools: ['
|
|
48
|
+
tools: ['websearch-search', 'websearch-fetch'],
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
name: 'IDE Diagnostics Tools',
|
|
52
|
-
tools: ['
|
|
52
|
+
tools: ['ide-get_diagnostics'],
|
|
53
53
|
},
|
|
54
54
|
];
|
|
55
55
|
export default function SubAgentConfigScreen({ onBack, onSave, inlineMode = false, agentId, }) {
|
|
@@ -4,7 +4,7 @@ import { spawn } from 'child_process';
|
|
|
4
4
|
import { writeFileSync, readFileSync, existsSync, mkdirSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { homedir, platform } from 'os';
|
|
7
|
-
import {
|
|
7
|
+
import { getSystemPrompt } from '../../api/systemPrompt.js';
|
|
8
8
|
const CONFIG_DIR = join(homedir(), '.snow');
|
|
9
9
|
const SYSTEM_PROMPT_FILE = join(CONFIG_DIR, 'system-prompt.txt');
|
|
10
10
|
function getSystemEditor() {
|
|
@@ -24,14 +24,14 @@ export default function SystemPromptConfigScreen({ onBack }) {
|
|
|
24
24
|
const openEditor = async () => {
|
|
25
25
|
ensureConfigDirectory();
|
|
26
26
|
// 读取系统提示词文件,如果不存在则使用默认系统提示词
|
|
27
|
-
let currentPrompt =
|
|
27
|
+
let currentPrompt = getSystemPrompt();
|
|
28
28
|
if (existsSync(SYSTEM_PROMPT_FILE)) {
|
|
29
29
|
try {
|
|
30
30
|
currentPrompt = readFileSync(SYSTEM_PROMPT_FILE, 'utf8');
|
|
31
31
|
}
|
|
32
32
|
catch {
|
|
33
33
|
// 读取失败,使用默认
|
|
34
|
-
currentPrompt =
|
|
34
|
+
currentPrompt = getSystemPrompt();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
// 写入临时文件供编辑
|
|
@@ -39,7 +39,7 @@ export default function SystemPromptConfigScreen({ onBack }) {
|
|
|
39
39
|
const editor = getSystemEditor();
|
|
40
40
|
exit();
|
|
41
41
|
const child = spawn(editor, [SYSTEM_PROMPT_FILE], {
|
|
42
|
-
stdio: 'inherit'
|
|
42
|
+
stdio: 'inherit',
|
|
43
43
|
});
|
|
44
44
|
child.on('close', () => {
|
|
45
45
|
// 读取编辑后的内容
|
|
@@ -47,7 +47,8 @@ export default function SystemPromptConfigScreen({ onBack }) {
|
|
|
47
47
|
try {
|
|
48
48
|
const editedContent = readFileSync(SYSTEM_PROMPT_FILE, 'utf8');
|
|
49
49
|
const trimmedContent = editedContent.trim();
|
|
50
|
-
if (trimmedContent === '' ||
|
|
50
|
+
if (trimmedContent === '' ||
|
|
51
|
+
trimmedContent === getSystemPrompt().trim()) {
|
|
51
52
|
// 内容为空或与默认相同,删除文件,使用默认提示词
|
|
52
53
|
try {
|
|
53
54
|
const fs = require('fs');
|
|
@@ -72,7 +73,7 @@ export default function SystemPromptConfigScreen({ onBack }) {
|
|
|
72
73
|
}
|
|
73
74
|
process.exit(0);
|
|
74
75
|
});
|
|
75
|
-
child.on('error',
|
|
76
|
+
child.on('error', error => {
|
|
76
77
|
console.error('Failed to open editor:', error.message);
|
|
77
78
|
process.exit(1);
|
|
78
79
|
});
|
|
@@ -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';
|
|
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,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 {};
|
|
@@ -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,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,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 {};
|