snow-ai 0.2.23 → 0.2.25
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/compactAgent.d.ts +55 -0
- package/dist/agents/compactAgent.js +301 -0
- package/dist/api/chat.d.ts +0 -8
- package/dist/api/chat.js +1 -144
- package/dist/api/responses.d.ts +0 -11
- package/dist/api/responses.js +1 -189
- package/dist/api/systemPrompt.d.ts +1 -1
- package/dist/api/systemPrompt.js +80 -206
- package/dist/app.d.ts +2 -1
- package/dist/app.js +11 -13
- package/dist/cli.js +23 -3
- package/dist/hooks/useConversation.js +51 -7
- package/dist/hooks/useGlobalNavigation.d.ts +1 -1
- package/dist/hooks/useKeyboardInput.js +14 -8
- package/dist/mcp/filesystem.d.ts +49 -6
- package/dist/mcp/filesystem.js +243 -86
- package/dist/mcp/websearch.d.ts +118 -0
- package/dist/mcp/websearch.js +451 -0
- package/dist/ui/components/ToolResultPreview.js +60 -1
- package/dist/ui/pages/ChatScreen.d.ts +4 -2
- package/dist/ui/pages/ChatScreen.js +62 -14
- package/dist/ui/pages/{ApiConfigScreen.d.ts → ConfigScreen.d.ts} +1 -1
- package/dist/ui/pages/ConfigScreen.js +549 -0
- package/dist/ui/pages/{ModelConfigScreen.d.ts → ProxyConfigScreen.d.ts} +1 -1
- package/dist/ui/pages/ProxyConfigScreen.js +143 -0
- package/dist/ui/pages/WelcomeScreen.js +15 -15
- package/dist/utils/apiConfig.d.ts +8 -2
- package/dist/utils/apiConfig.js +21 -0
- package/dist/utils/commandExecutor.d.ts +1 -1
- package/dist/utils/contextCompressor.js +363 -49
- package/dist/utils/mcpToolsManager.d.ts +1 -1
- package/dist/utils/mcpToolsManager.js +106 -6
- package/dist/utils/resourceMonitor.d.ts +65 -0
- package/dist/utils/resourceMonitor.js +175 -0
- package/dist/utils/retryUtils.js +6 -0
- package/dist/utils/sessionManager.d.ts +1 -0
- package/dist/utils/sessionManager.js +10 -0
- package/dist/utils/textBuffer.js +7 -2
- package/dist/utils/toolExecutor.d.ts +2 -2
- package/dist/utils/toolExecutor.js +4 -4
- package/package.json +5 -1
- package/dist/ui/pages/ApiConfigScreen.js +0 -161
- package/dist/ui/pages/ModelConfigScreen.js +0 -467
package/dist/api/responses.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
2
|
import { getOpenAiConfig, getCustomSystemPrompt, getCustomHeaders } from '../utils/apiConfig.js';
|
|
3
|
-
import { executeMCPTool } from '../utils/mcpToolsManager.js';
|
|
4
3
|
import { SYSTEM_PROMPT } from './systemPrompt.js';
|
|
5
|
-
import {
|
|
4
|
+
import { withRetryGenerator } from '../utils/retryUtils.js';
|
|
6
5
|
/**
|
|
7
6
|
* 确保 schema 符合 Responses API 的要求:
|
|
8
7
|
* 1. additionalProperties: false
|
|
@@ -75,19 +74,6 @@ function getOpenAIClient() {
|
|
|
75
74
|
export function resetOpenAIClient() {
|
|
76
75
|
openaiClient = null;
|
|
77
76
|
}
|
|
78
|
-
/**
|
|
79
|
-
* 转换消息格式为 Responses API 的 input 格式
|
|
80
|
-
* Responses API 的 input 格式:
|
|
81
|
-
* 1. 支持 user, assistant 角色消息,使用 type: "message" 包裹
|
|
82
|
-
* 2. 工具调用在 assistant 中表示为 function_call 类型的 item
|
|
83
|
-
* 3. 工具结果使用 function_call_output 类型
|
|
84
|
-
*
|
|
85
|
-
* 注意:Responses API 使用 instructions 字段代替 system 消息
|
|
86
|
-
* 优化:使用 type: "message" 包裹以提高缓存命中率
|
|
87
|
-
* Logic:
|
|
88
|
-
* 1. If custom system prompt exists: use custom as instructions, prepend default as first user message
|
|
89
|
-
* 2. If no custom system prompt: use default as instructions
|
|
90
|
-
*/
|
|
91
77
|
function convertToResponseInput(messages) {
|
|
92
78
|
const customSystemPrompt = getCustomSystemPrompt();
|
|
93
79
|
const result = [];
|
|
@@ -191,92 +177,6 @@ function convertToResponseInput(messages) {
|
|
|
191
177
|
}
|
|
192
178
|
return { input: result, systemInstructions };
|
|
193
179
|
}
|
|
194
|
-
/**
|
|
195
|
-
* 使用 Responses API 创建响应(非流式,带自动工具调用)
|
|
196
|
-
*/
|
|
197
|
-
export async function createResponse(options, abortSignal, onRetry) {
|
|
198
|
-
const client = getOpenAIClient();
|
|
199
|
-
let messages = [...options.messages];
|
|
200
|
-
// 提取系统提示词和转换后的消息
|
|
201
|
-
const { input: convertedInput, systemInstructions } = convertToResponseInput(messages);
|
|
202
|
-
try {
|
|
203
|
-
// 使用 Responses API
|
|
204
|
-
while (true) {
|
|
205
|
-
const requestPayload = {
|
|
206
|
-
model: options.model,
|
|
207
|
-
instructions: systemInstructions,
|
|
208
|
-
input: convertedInput,
|
|
209
|
-
tools: convertToolsForResponses(options.tools),
|
|
210
|
-
tool_choice: options.tool_choice,
|
|
211
|
-
reasoning: options.reasoning || { summary: 'auto', effort: 'high' },
|
|
212
|
-
store: options.store ?? false,
|
|
213
|
-
include: options.include || ['reasoning.encrypted_content'],
|
|
214
|
-
prompt_cache_key: options.prompt_cache_key,
|
|
215
|
-
};
|
|
216
|
-
const response = await withRetry(() => client.responses.create(requestPayload), {
|
|
217
|
-
abortSignal,
|
|
218
|
-
onRetry
|
|
219
|
-
});
|
|
220
|
-
// 提取响应 - Responses API 返回 output 数组
|
|
221
|
-
const output = response.output;
|
|
222
|
-
if (!output || output.length === 0) {
|
|
223
|
-
throw new Error('No output from AI');
|
|
224
|
-
}
|
|
225
|
-
// 获取最后一条消息(通常是 assistant 的响应)
|
|
226
|
-
const lastMessage = output[output.length - 1];
|
|
227
|
-
// 添加 assistant 消息到对话
|
|
228
|
-
messages.push({
|
|
229
|
-
role: 'assistant',
|
|
230
|
-
content: lastMessage.content || '',
|
|
231
|
-
tool_calls: lastMessage.tool_calls
|
|
232
|
-
});
|
|
233
|
-
// 检查是否有工具调用
|
|
234
|
-
if (lastMessage.tool_calls && lastMessage.tool_calls.length > 0) {
|
|
235
|
-
// 执行每个工具调用
|
|
236
|
-
for (const toolCall of lastMessage.tool_calls) {
|
|
237
|
-
if (toolCall.type === 'function') {
|
|
238
|
-
try {
|
|
239
|
-
const args = JSON.parse(toolCall.function.arguments);
|
|
240
|
-
const result = await executeMCPTool(toolCall.function.name, args);
|
|
241
|
-
// 添加工具结果到对话
|
|
242
|
-
messages.push({
|
|
243
|
-
role: 'tool',
|
|
244
|
-
content: JSON.stringify(result),
|
|
245
|
-
tool_call_id: toolCall.id
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
// 添加错误结果到对话
|
|
250
|
-
messages.push({
|
|
251
|
-
role: 'tool',
|
|
252
|
-
content: `Error: ${error instanceof Error ? error.message : 'Tool execution failed'}`,
|
|
253
|
-
tool_call_id: toolCall.id
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
// 继续对话获取工具结果后的响应
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
// 没有工具调用,返回内容
|
|
262
|
-
return lastMessage.content || '';
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
catch (error) {
|
|
266
|
-
if (error instanceof Error) {
|
|
267
|
-
// 检查是否是 API 网关不支持 Responses API
|
|
268
|
-
if (error.message.includes('Panic detected') ||
|
|
269
|
-
error.message.includes('nil pointer') ||
|
|
270
|
-
error.message.includes('404') ||
|
|
271
|
-
error.message.includes('not found')) {
|
|
272
|
-
throw new Error('Response creation failed: Your API endpoint does not support the Responses API. ' +
|
|
273
|
-
'Please switch to "Chat Completions" method in API settings, or use an OpenAI-compatible endpoint that supports Responses API.');
|
|
274
|
-
}
|
|
275
|
-
throw new Error(`Response creation failed: ${error.message}`);
|
|
276
|
-
}
|
|
277
|
-
throw new Error('Response creation failed: Unknown error');
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
180
|
/**
|
|
281
181
|
* 使用 Responses API 创建流式响应(带自动工具调用)
|
|
282
182
|
*/
|
|
@@ -461,91 +361,3 @@ export async function* createStreamingResponse(options, abortSignal, onRetry) {
|
|
|
461
361
|
onRetry
|
|
462
362
|
});
|
|
463
363
|
}
|
|
464
|
-
/**
|
|
465
|
-
* 使用 Responses API 创建响应(限制工具调用轮数)
|
|
466
|
-
*/
|
|
467
|
-
export async function createResponseWithTools(options, maxToolRounds = 5, abortSignal, onRetry) {
|
|
468
|
-
const client = getOpenAIClient();
|
|
469
|
-
let messages = [...options.messages];
|
|
470
|
-
let allToolCalls = [];
|
|
471
|
-
let rounds = 0;
|
|
472
|
-
// 提取系统提示词和转换后的消息
|
|
473
|
-
const { input: convertedInput, systemInstructions } = convertToResponseInput(messages);
|
|
474
|
-
try {
|
|
475
|
-
while (rounds < maxToolRounds) {
|
|
476
|
-
const requestPayload = {
|
|
477
|
-
model: options.model,
|
|
478
|
-
instructions: systemInstructions,
|
|
479
|
-
input: convertedInput,
|
|
480
|
-
tools: convertToolsForResponses(options.tools),
|
|
481
|
-
tool_choice: options.tool_choice,
|
|
482
|
-
reasoning: options.reasoning || { summary: 'auto', effort: 'high' },
|
|
483
|
-
store: options.store ?? false,
|
|
484
|
-
include: options.include || ['reasoning.encrypted_content'],
|
|
485
|
-
prompt_cache_key: options.prompt_cache_key,
|
|
486
|
-
};
|
|
487
|
-
const response = await withRetry(() => client.responses.create(requestPayload), {
|
|
488
|
-
abortSignal,
|
|
489
|
-
onRetry
|
|
490
|
-
});
|
|
491
|
-
const output = response.output;
|
|
492
|
-
if (!output || output.length === 0) {
|
|
493
|
-
throw new Error('No output from AI');
|
|
494
|
-
}
|
|
495
|
-
const lastMessage = output[output.length - 1];
|
|
496
|
-
// 添加 assistant 消息
|
|
497
|
-
messages.push({
|
|
498
|
-
role: 'assistant',
|
|
499
|
-
content: lastMessage.content || '',
|
|
500
|
-
tool_calls: lastMessage.tool_calls
|
|
501
|
-
});
|
|
502
|
-
// 检查工具调用
|
|
503
|
-
if (lastMessage.tool_calls && lastMessage.tool_calls.length > 0) {
|
|
504
|
-
allToolCalls.push(...lastMessage.tool_calls);
|
|
505
|
-
// 执行工具调用
|
|
506
|
-
for (const toolCall of lastMessage.tool_calls) {
|
|
507
|
-
if (toolCall.type === 'function') {
|
|
508
|
-
try {
|
|
509
|
-
const args = JSON.parse(toolCall.function.arguments);
|
|
510
|
-
const result = await executeMCPTool(toolCall.function.name, args);
|
|
511
|
-
messages.push({
|
|
512
|
-
role: 'tool',
|
|
513
|
-
content: JSON.stringify(result),
|
|
514
|
-
tool_call_id: toolCall.id
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
catch (error) {
|
|
518
|
-
messages.push({
|
|
519
|
-
role: 'tool',
|
|
520
|
-
content: `Error: ${error instanceof Error ? error.message : 'Tool execution failed'}`,
|
|
521
|
-
tool_call_id: toolCall.id
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
rounds++;
|
|
527
|
-
continue;
|
|
528
|
-
}
|
|
529
|
-
// 没有工具调用,返回结果
|
|
530
|
-
return {
|
|
531
|
-
content: lastMessage.content || '',
|
|
532
|
-
toolCalls: allToolCalls
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
throw new Error(`Maximum tool calling rounds (${maxToolRounds}) exceeded`);
|
|
536
|
-
}
|
|
537
|
-
catch (error) {
|
|
538
|
-
if (error instanceof Error) {
|
|
539
|
-
// 检查是否是 API 网关不支持 Responses API
|
|
540
|
-
if (error.message.includes('Panic detected') ||
|
|
541
|
-
error.message.includes('nil pointer') ||
|
|
542
|
-
error.message.includes('404') ||
|
|
543
|
-
error.message.includes('not found')) {
|
|
544
|
-
throw new Error('Response creation with tools failed: Your API endpoint does not support the Responses API. ' +
|
|
545
|
-
'Please switch to "Chat Completions" method in API settings.');
|
|
546
|
-
}
|
|
547
|
-
throw new Error(`Response creation with tools failed: ${error.message}`);
|
|
548
|
-
}
|
|
549
|
-
throw new Error('Response creation with tools failed: Unknown error');
|
|
550
|
-
}
|
|
551
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* System prompt configuration for Snow AI CLI
|
|
3
3
|
*/
|
|
4
|
-
export declare const SYSTEM_PROMPT = "You are Snow AI CLI, an intelligent command-line assistant
|
|
4
|
+
export declare const SYSTEM_PROMPT = "You are Snow AI CLI, an intelligent command-line assistant. Your PRIMARY mission: WRITE CODE, not investigate endlessly.\n\n## \uD83C\uDFAF Core Principles\n\n1. **Language Adaptation**: ALWAYS respond in the SAME language as the user's query\n2. **ACTION FIRST**: Write code immediately when task is clear - stop overthinking\n3. **Smart Context**: Read what's needed for correctness, skip excessive exploration\n4. **Quality Verification**: Run build/test after changes\n\n## \uD83D\uDE80 Execution Strategy - BALANCE ACTION & ANALYSIS\n\n### \u26A1 Smart Action Mode\n**Principle: Understand enough to code correctly, but don't over-investigate**\n\n**Examples:**\n- \"Fix timeout in parser.ts\" \u2192 Read file + check imports if needed \u2192 Fix \u2192 Done\n- \"Add validation to form\" \u2192 Read form component + related validation utils \u2192 Add code \u2192 Done\n- \"Refactor error handling\" \u2192 Read error handler + callers \u2192 Refactor \u2192 Done\n\n**Your workflow:**\n1. Read the primary file(s) mentioned\n2. Check dependencies/imports that directly impact the change\n3. Read related files ONLY if they're critical to understanding the task\n4. Write/modify code with proper context\n5. Verify with build\n6. \u274C NO excessive exploration beyond what's needed\n7. \u274C NO reading entire modules \"for reference\"\n8. \u274C NO over-planning multi-step workflows for simple tasks\n\n**Golden Rule: Read what you need to write correct code, nothing more.**\n\n### \uD83D\uDCCB TODO Lists - When to Use\n\n**\u2705 CREATE TODO ONLY WHEN:**\n- Task involves 5+ files across different modules\n- Large feature spanning multiple components\n- Complex refactoring affecting architecture\n\n**\u274C DON'T CREATE TODO FOR:**\n- Simple fixes (1-3 files)\n- Adding a function/component\n- Typical bug fixes\n- Anything you can complete in <10 minutes\n\n**TODO = Action List, NOT Investigation Plan**\n- \u2705 \"Create AuthService with login/logout methods\"\n- \u2705 \"Add validation to UserForm component\"\n- \u2705 \"Update API routes to use new auth middleware\"\n- \u274C \"Read authentication files\"\n- \u274C \"Analyze current implementation\"\n- \u274C \"Investigate error handling patterns\"\n\n**CRITICAL: Update TODO status IMMEDIATELY after completing each task!**\n\n## \uD83D\uDEE0\uFE0F Available Tools\n\n**Filesystem:**\n- `filesystem-read` - Read files before editing\n- `filesystem-edit` - Modify existing files\n- `filesystem-create` - Create new files\n\n**Code Search (ACE):**\n- `ace-search-symbols` - Find functions/classes/variables\n- `ace-find-definition` - Go to definition\n- `ace-find-references` - Find all usages\n- `ace-text-search` - Fast text/regex search\n\n**Web Search:**\n- `websearch_search` - Search web for latest docs/solutions\n- `websearch_fetch` - Read web page content (always provide userQuery)\n\n**Terminal:**\n- Use for: `npm run build`, `npm test`, `git status`\n\n## \uD83D\uDD0D Quality Assurance\n\nAfter code changes:\n1. Run build: `npm run build` or `tsc`\n2. Fix any errors immediately\n3. Never leave broken code\n\n## \uD83D\uDCDA Project Context (SNOW.md)\n\n- Read ONLY when implementing large features or unfamiliar architecture\n- Skip for simple tasks where you understand the structure\n- Contains: project overview, architecture, tech stack\n\nRemember: **ACTION > ANALYSIS**. Write code first, investigate only when blocked.";
|
package/dist/api/systemPrompt.js
CHANGED
|
@@ -1,217 +1,91 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* System prompt configuration for Snow AI CLI
|
|
3
3
|
*/
|
|
4
|
-
export const SYSTEM_PROMPT = `You are Snow AI CLI, an intelligent command-line assistant
|
|
4
|
+
export const SYSTEM_PROMPT = `You are Snow AI CLI, an intelligent command-line assistant. Your PRIMARY mission: WRITE CODE, not investigate endlessly.
|
|
5
5
|
|
|
6
6
|
## 🎯 Core Principles
|
|
7
7
|
|
|
8
8
|
1. **Language Adaptation**: ALWAYS respond in the SAME language as the user's query
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- This applies to ALL responses, explanations, and error messages
|
|
9
|
+
2. **ACTION FIRST**: Write code immediately when task is clear - stop overthinking
|
|
10
|
+
3. **Smart Context**: Read what's needed for correctness, skip excessive exploration
|
|
11
|
+
4. **Quality Verification**: Run build/test after changes
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
3. **Quality Assurance**: Always verify code changes by running build/test scripts
|
|
16
|
-
4. **Incremental Progress**: Break complex tasks into manageable steps with TODO tracking
|
|
13
|
+
## 🚀 Execution Strategy - BALANCE ACTION & ANALYSIS
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
### ⚡ Smart Action Mode
|
|
16
|
+
**Principle: Understand enough to code correctly, but don't over-investigate**
|
|
19
17
|
|
|
20
|
-
**CRITICAL: Identify task type first to avoid unnecessary exploration!**
|
|
21
|
-
|
|
22
|
-
### Type A: Explicit Instructions (EXECUTE IMMEDIATELY)
|
|
23
|
-
**User provides:** Specific file path + Clear problem description + Expected change
|
|
24
|
-
**Examples:**
|
|
25
|
-
- "Modify src/utils/parser.ts line 45, change timeout from 1000 to 5000"
|
|
26
|
-
- "In components/Header.tsx, add a new prop 'showLogo: boolean'"
|
|
27
|
-
- "Fix the bug in api/auth.ts where the token validation fails"
|
|
28
|
-
|
|
29
|
-
**Your action:**
|
|
30
|
-
1. ✅ Read the specified file(s) ONLY
|
|
31
|
-
2. ✅ Make the required changes immediately
|
|
32
|
-
3. ✅ Verify with build/test
|
|
33
|
-
4. ❌ DO NOT search for related files unless the edit reveals a dependency issue
|
|
34
|
-
5. ❌ DO NOT read SNOW.md unless you need architectural context
|
|
35
|
-
6. ❌ DO NOT create TODO lists for single-file edits
|
|
36
|
-
|
|
37
|
-
### Type B: Exploratory Tasks (INVESTIGATE FIRST)
|
|
38
|
-
**User provides:** Vague description + No file paths + Requires research
|
|
39
|
-
**Examples:**
|
|
40
|
-
- "Find all code handling user authentication"
|
|
41
|
-
- "Refactor the entire authentication system"
|
|
42
|
-
- "Find and fix all memory leaks"
|
|
43
|
-
|
|
44
|
-
**Your action:**
|
|
45
|
-
1. Use ACE code search to locate relevant code
|
|
46
|
-
2. Create TODO list if multiple files involved
|
|
47
|
-
3. Read SNOW.md if architectural understanding needed
|
|
48
|
-
4. Execute systematically
|
|
49
|
-
|
|
50
|
-
### Type C: Feature Implementation (PLAN & EXECUTE)
|
|
51
|
-
**User provides:** Feature request requiring multiple files/components
|
|
52
18
|
**Examples:**
|
|
53
|
-
- "
|
|
54
|
-
- "
|
|
55
|
-
- "
|
|
56
|
-
|
|
57
|
-
**Your
|
|
58
|
-
1.
|
|
59
|
-
2. Check
|
|
60
|
-
3.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
|
|
99
|
-
**
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
|
|
105
|
-
**
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
- Use \`filesystem-edit\` for precise, small changes (recommended ≤15 lines)
|
|
127
|
-
- Use \`filesystem-create\` for new files
|
|
128
|
-
|
|
129
|
-
**ACE Code Search (Advanced Code Explorer):**
|
|
130
|
-
- Use \`ace-search-symbols\` to find functions, classes, variables with fuzzy matching
|
|
131
|
-
- Use \`ace-find-definition\` to locate symbol definitions (Go to Definition)
|
|
132
|
-
- Use \`ace-find-references\` to find all usages of a symbol (Find All References)
|
|
133
|
-
- Use \`ace-text-search\` for fast text/regex search across the entire codebase
|
|
134
|
-
- Use \`ace-file-outline\` to get complete code structure of a file
|
|
135
|
-
- Use \`ace-semantic-search\` for advanced context-aware searches
|
|
136
|
-
- ACE supports multiple languages: TypeScript, JavaScript, Python, Go, Rust, Java, C#
|
|
137
|
-
- ACE provides intelligent code understanding and cross-reference analysis
|
|
138
|
-
|
|
139
|
-
**Terminal Commands:**
|
|
140
|
-
- Use for build scripts, testing, package management
|
|
141
|
-
- Examples: \`npm run build\`, \`npm test\`, \`git status\`
|
|
142
|
-
|
|
143
|
-
## 🔍 Code Quality Assurance
|
|
144
|
-
|
|
145
|
-
**CRITICAL: Always verify code changes!**
|
|
146
|
-
|
|
147
|
-
After making code changes, you MUST:
|
|
148
|
-
1. Run the project's build script: \`npm run build\` or \`tsc\`
|
|
149
|
-
2. Check for TypeScript/compilation errors
|
|
150
|
-
3. If errors occur, fix them immediately
|
|
151
|
-
4. Never leave code in a broken state
|
|
152
|
-
|
|
153
|
-
**Common verification commands:**
|
|
154
|
-
- TypeScript projects: \`npm run build\` or \`tsc\`
|
|
155
|
-
- JavaScript projects: \`npm run lint\` or \`npm test\`
|
|
156
|
-
- Python projects: \`python -m py_compile <file>\`
|
|
157
|
-
- Go projects: \`go build\`
|
|
158
|
-
|
|
159
|
-
## 🎨 Response Quality Guidelines
|
|
160
|
-
|
|
161
|
-
1. **Be Concise**: Provide clear, actionable information without unnecessary verbosity
|
|
162
|
-
2. **Use Formatting**: Use markdown, emojis, and structure for readability
|
|
163
|
-
3. **Show Progress**: For complex tasks, show TODO progress and updates
|
|
164
|
-
4. **Explain Decisions**: Briefly explain why you chose a particular approach
|
|
165
|
-
5. **Handle Errors Gracefully**: If something fails, explain why and suggest alternatives
|
|
166
|
-
|
|
167
|
-
## 🚨 Error Prevention
|
|
168
|
-
|
|
169
|
-
**Before executing:**
|
|
170
|
-
- Read files completely before editing
|
|
171
|
-
- Verify line numbers are correct
|
|
172
|
-
- Check file paths exist
|
|
173
|
-
|
|
174
|
-
**During execution:**
|
|
175
|
-
- Make small, incremental changes
|
|
176
|
-
- Test after each significant change
|
|
177
|
-
- Keep backups in mind (user can use git)
|
|
178
|
-
|
|
179
|
-
**After execution:**
|
|
180
|
-
- Run build/compile scripts
|
|
181
|
-
- Verify no syntax errors
|
|
182
|
-
- Confirm the change works as intended
|
|
183
|
-
|
|
184
|
-
## 💡 Examples of Good Workflow
|
|
185
|
-
|
|
186
|
-
**Example 1: Adding a new feature**
|
|
187
|
-
\`\`\`
|
|
188
|
-
1. Create TODO list with tasks
|
|
189
|
-
2. Read SNOW.md to understand architecture
|
|
190
|
-
3. Read relevant source files
|
|
191
|
-
4. Implement changes incrementally
|
|
192
|
-
5. Update TODO after each file
|
|
193
|
-
6. Run npm run build to verify
|
|
194
|
-
7. Report completion
|
|
195
|
-
\`\`\`
|
|
196
|
-
|
|
197
|
-
**Example 2: Fixing a bug**
|
|
198
|
-
\`\`\`
|
|
199
|
-
1. Search for the bug location
|
|
200
|
-
2. Read surrounding code context
|
|
201
|
-
3. Identify root cause
|
|
202
|
-
4. Make minimal fix
|
|
203
|
-
5. Run build/test scripts
|
|
204
|
-
6. Verify fix works
|
|
205
|
-
\`\`\`
|
|
206
|
-
|
|
207
|
-
**Example 3: Refactoring code**
|
|
208
|
-
\`\`\`
|
|
209
|
-
1. Create TODO with affected files
|
|
210
|
-
2. Read all files to understand dependencies
|
|
211
|
-
3. Refactor one file at a time
|
|
212
|
-
4. Update TODO after each file
|
|
213
|
-
5. Run build after each change
|
|
214
|
-
6. Ensure no breaking changes
|
|
215
|
-
\`\`\`
|
|
216
|
-
|
|
217
|
-
Remember: Your goal is to be a reliable, systematic, and quality-focused assistant. Always prioritize correctness over speed, and maintain clear communication with the user in their preferred language.`;
|
|
19
|
+
- "Fix timeout in parser.ts" → Read file + check imports if needed → Fix → Done
|
|
20
|
+
- "Add validation to form" → Read form component + related validation utils → Add code → Done
|
|
21
|
+
- "Refactor error handling" → Read error handler + callers → Refactor → Done
|
|
22
|
+
|
|
23
|
+
**Your workflow:**
|
|
24
|
+
1. Read the primary file(s) mentioned
|
|
25
|
+
2. Check dependencies/imports that directly impact the change
|
|
26
|
+
3. Read related files ONLY if they're critical to understanding the task
|
|
27
|
+
4. Write/modify code with proper context
|
|
28
|
+
5. Verify with build
|
|
29
|
+
6. ❌ NO excessive exploration beyond what's needed
|
|
30
|
+
7. ❌ NO reading entire modules "for reference"
|
|
31
|
+
8. ❌ NO over-planning multi-step workflows for simple tasks
|
|
32
|
+
|
|
33
|
+
**Golden Rule: Read what you need to write correct code, nothing more.**
|
|
34
|
+
|
|
35
|
+
### 📋 TODO Lists - When to Use
|
|
36
|
+
|
|
37
|
+
**✅ CREATE TODO ONLY WHEN:**
|
|
38
|
+
- Task involves 5+ files across different modules
|
|
39
|
+
- Large feature spanning multiple components
|
|
40
|
+
- Complex refactoring affecting architecture
|
|
41
|
+
|
|
42
|
+
**❌ DON'T CREATE TODO FOR:**
|
|
43
|
+
- Simple fixes (1-3 files)
|
|
44
|
+
- Adding a function/component
|
|
45
|
+
- Typical bug fixes
|
|
46
|
+
- Anything you can complete in <10 minutes
|
|
47
|
+
|
|
48
|
+
**TODO = Action List, NOT Investigation Plan**
|
|
49
|
+
- ✅ "Create AuthService with login/logout methods"
|
|
50
|
+
- ✅ "Add validation to UserForm component"
|
|
51
|
+
- ✅ "Update API routes to use new auth middleware"
|
|
52
|
+
- ❌ "Read authentication files"
|
|
53
|
+
- ❌ "Analyze current implementation"
|
|
54
|
+
- ❌ "Investigate error handling patterns"
|
|
55
|
+
|
|
56
|
+
**CRITICAL: Update TODO status IMMEDIATELY after completing each task!**
|
|
57
|
+
|
|
58
|
+
## 🛠️ Available Tools
|
|
59
|
+
|
|
60
|
+
**Filesystem:**
|
|
61
|
+
- \`filesystem-read\` - Read files before editing
|
|
62
|
+
- \`filesystem-edit\` - Modify existing files
|
|
63
|
+
- \`filesystem-create\` - Create new files
|
|
64
|
+
|
|
65
|
+
**Code Search (ACE):**
|
|
66
|
+
- \`ace-search-symbols\` - Find functions/classes/variables
|
|
67
|
+
- \`ace-find-definition\` - Go to definition
|
|
68
|
+
- \`ace-find-references\` - Find all usages
|
|
69
|
+
- \`ace-text-search\` - Fast text/regex search
|
|
70
|
+
|
|
71
|
+
**Web Search:**
|
|
72
|
+
- \`websearch_search\` - Search web for latest docs/solutions
|
|
73
|
+
- \`websearch_fetch\` - Read web page content (always provide userQuery)
|
|
74
|
+
|
|
75
|
+
**Terminal:**
|
|
76
|
+
- Use for: \`npm run build\`, \`npm test\`, \`git status\`
|
|
77
|
+
|
|
78
|
+
## 🔍 Quality Assurance
|
|
79
|
+
|
|
80
|
+
After code changes:
|
|
81
|
+
1. Run build: \`npm run build\` or \`tsc\`
|
|
82
|
+
2. Fix any errors immediately
|
|
83
|
+
3. Never leave broken code
|
|
84
|
+
|
|
85
|
+
## 📚 Project Context (SNOW.md)
|
|
86
|
+
|
|
87
|
+
- Read ONLY when implementing large features or unfamiliar architecture
|
|
88
|
+
- Skip for simple tasks where you understand the structure
|
|
89
|
+
- Contains: project overview, architecture, tech stack
|
|
90
|
+
|
|
91
|
+
Remember: **ACTION > ANALYSIS**. Write code first, investigate only when blocked.`;
|
package/dist/app.d.ts
CHANGED
package/dist/app.js
CHANGED
|
@@ -2,20 +2,18 @@ import React, { useState, useEffect } from 'react';
|
|
|
2
2
|
import { Box, Text } from 'ink';
|
|
3
3
|
import { Alert } from '@inkjs/ui';
|
|
4
4
|
import WelcomeScreen from './ui/pages/WelcomeScreen.js';
|
|
5
|
-
import ApiConfigScreen from './ui/pages/ApiConfigScreen.js';
|
|
6
|
-
import ModelConfigScreen from './ui/pages/ModelConfigScreen.js';
|
|
7
5
|
import MCPConfigScreen from './ui/pages/MCPConfigScreen.js';
|
|
8
6
|
import SystemPromptConfigScreen from './ui/pages/SystemPromptConfigScreen.js';
|
|
9
7
|
import CustomHeadersScreen from './ui/pages/CustomHeadersScreen.js';
|
|
10
8
|
import ChatScreen from './ui/pages/ChatScreen.js';
|
|
11
|
-
import { useGlobalExit } from './hooks/useGlobalExit.js';
|
|
9
|
+
import { useGlobalExit, } from './hooks/useGlobalExit.js';
|
|
12
10
|
import { onNavigate } from './hooks/useGlobalNavigation.js';
|
|
13
11
|
import { useTerminalSize } from './hooks/useTerminalSize.js';
|
|
14
|
-
export default function App({ version }) {
|
|
15
|
-
const [currentView, setCurrentView] = useState('welcome');
|
|
12
|
+
export default function App({ version, skipWelcome }) {
|
|
13
|
+
const [currentView, setCurrentView] = useState(skipWelcome ? 'chat' : 'welcome');
|
|
16
14
|
const [exitNotification, setExitNotification] = useState({
|
|
17
15
|
show: false,
|
|
18
|
-
message: ''
|
|
16
|
+
message: '',
|
|
19
17
|
});
|
|
20
18
|
// Get terminal size for proper width calculation
|
|
21
19
|
const { columns: terminalWidth } = useTerminalSize();
|
|
@@ -23,13 +21,17 @@ export default function App({ version }) {
|
|
|
23
21
|
useGlobalExit(setExitNotification);
|
|
24
22
|
// Global navigation handler
|
|
25
23
|
useEffect(() => {
|
|
26
|
-
const unsubscribe = onNavigate(
|
|
24
|
+
const unsubscribe = onNavigate(event => {
|
|
27
25
|
setCurrentView(event.destination);
|
|
28
26
|
});
|
|
29
27
|
return unsubscribe;
|
|
30
28
|
}, []);
|
|
31
29
|
const handleMenuSelect = (value) => {
|
|
32
|
-
if (value === 'chat' ||
|
|
30
|
+
if (value === 'chat' ||
|
|
31
|
+
value === 'settings' ||
|
|
32
|
+
value === 'mcp' ||
|
|
33
|
+
value === 'systemprompt' ||
|
|
34
|
+
value === 'customheaders') {
|
|
33
35
|
setCurrentView(value);
|
|
34
36
|
}
|
|
35
37
|
else if (value === 'exit') {
|
|
@@ -41,15 +43,11 @@ export default function App({ version }) {
|
|
|
41
43
|
case 'welcome':
|
|
42
44
|
return (React.createElement(WelcomeScreen, { version: version, onMenuSelect: handleMenuSelect }));
|
|
43
45
|
case 'chat':
|
|
44
|
-
return
|
|
46
|
+
return React.createElement(ChatScreen, { skipWelcome: skipWelcome });
|
|
45
47
|
case 'settings':
|
|
46
48
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
47
49
|
React.createElement(Text, { color: "blue" }, "Settings"),
|
|
48
50
|
React.createElement(Text, { color: "gray" }, "Settings interface would be implemented here")));
|
|
49
|
-
case 'config':
|
|
50
|
-
return (React.createElement(ApiConfigScreen, { onBack: () => setCurrentView('welcome'), onSave: () => setCurrentView('welcome') }));
|
|
51
|
-
case 'models':
|
|
52
|
-
return (React.createElement(ModelConfigScreen, { onBack: () => setCurrentView('welcome'), onSave: () => setCurrentView('welcome') }));
|
|
53
51
|
case 'mcp':
|
|
54
52
|
return (React.createElement(MCPConfigScreen, { onBack: () => setCurrentView('welcome'), onSave: () => setCurrentView('welcome') }));
|
|
55
53
|
case 'systemprompt':
|