snow-ai 0.2.24 → 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.
@@ -57,14 +57,6 @@ export interface ChatCompletionChunk {
57
57
  }>;
58
58
  }
59
59
  export declare function resetOpenAIClient(): void;
60
- /**
61
- * Create chat completion with automatic function calling support
62
- */
63
- export declare function createChatCompletionWithTools(options: ChatCompletionOptions, maxToolRounds?: number, abortSignal?: AbortSignal, onRetry?: (error: Error, attempt: number, nextDelay: number) => void): Promise<{
64
- content: string;
65
- toolCalls: ToolCall[];
66
- }>;
67
- export declare function createChatCompletion(options: ChatCompletionOptions, abortSignal?: AbortSignal, onRetry?: (error: Error, attempt: number, nextDelay: number) => void): Promise<string>;
68
60
  export interface UsageInfo {
69
61
  prompt_tokens: number;
70
62
  completion_tokens: number;
package/dist/api/chat.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 { withRetry, withRetryGenerator } from '../utils/retryUtils.js';
4
+ import { withRetryGenerator } from '../utils/retryUtils.js';
6
5
  /**
7
6
  * Convert our ChatMessage format to OpenAI's ChatCompletionMessageParam format
8
7
  * Automatically prepends system prompt if not present
@@ -112,148 +111,6 @@ function getOpenAIClient() {
112
111
  export function resetOpenAIClient() {
113
112
  openaiClient = null;
114
113
  }
115
- /**
116
- * Create chat completion with automatic function calling support
117
- */
118
- export async function createChatCompletionWithTools(options, maxToolRounds = 5, abortSignal, onRetry) {
119
- const client = getOpenAIClient();
120
- let messages = [...options.messages];
121
- let allToolCalls = [];
122
- let rounds = 0;
123
- try {
124
- while (rounds < maxToolRounds) {
125
- const response = await withRetry(() => client.chat.completions.create({
126
- model: options.model,
127
- messages: convertToOpenAIMessages(messages),
128
- stream: false,
129
- temperature: options.temperature || 0.7,
130
- max_tokens: options.max_tokens,
131
- tools: options.tools,
132
- tool_choice: options.tool_choice,
133
- }), {
134
- abortSignal,
135
- onRetry
136
- });
137
- const message = response.choices[0]?.message;
138
- if (!message) {
139
- throw new Error('No response from AI');
140
- }
141
- // Add assistant message to conversation
142
- messages.push({
143
- role: 'assistant',
144
- content: message.content || '',
145
- tool_calls: message.tool_calls
146
- });
147
- // Check if AI wants to call tools
148
- if (message.tool_calls && message.tool_calls.length > 0) {
149
- allToolCalls.push(...message.tool_calls);
150
- // Execute each tool call
151
- for (const toolCall of message.tool_calls) {
152
- if (toolCall.type === 'function') {
153
- try {
154
- const args = JSON.parse(toolCall.function.arguments);
155
- const result = await executeMCPTool(toolCall.function.name, args);
156
- // Add tool result to conversation
157
- messages.push({
158
- role: 'tool',
159
- content: JSON.stringify(result),
160
- tool_call_id: toolCall.id
161
- });
162
- }
163
- catch (error) {
164
- // Add error result to conversation
165
- messages.push({
166
- role: 'tool',
167
- content: `Error: ${error instanceof Error ? error.message : 'Tool execution failed'}`,
168
- tool_call_id: toolCall.id
169
- });
170
- }
171
- }
172
- }
173
- rounds++;
174
- continue;
175
- }
176
- // No tool calls, return the content
177
- return {
178
- content: message.content || '',
179
- toolCalls: allToolCalls
180
- };
181
- }
182
- throw new Error(`Maximum tool calling rounds (${maxToolRounds}) exceeded`);
183
- }
184
- catch (error) {
185
- if (error instanceof Error) {
186
- throw new Error(`Chat completion with tools failed: ${error.message}`);
187
- }
188
- throw new Error('Chat completion with tools failed: Unknown error');
189
- }
190
- }
191
- export async function createChatCompletion(options, abortSignal, onRetry) {
192
- const client = getOpenAIClient();
193
- let messages = [...options.messages];
194
- try {
195
- while (true) {
196
- const response = await withRetry(() => client.chat.completions.create({
197
- model: options.model,
198
- messages: convertToOpenAIMessages(messages),
199
- stream: false,
200
- temperature: options.temperature || 0.7,
201
- max_tokens: options.max_tokens,
202
- tools: options.tools,
203
- tool_choice: options.tool_choice,
204
- }), {
205
- abortSignal,
206
- onRetry
207
- });
208
- const message = response.choices[0]?.message;
209
- if (!message) {
210
- throw new Error('No response from AI');
211
- }
212
- // Add assistant message to conversation
213
- messages.push({
214
- role: 'assistant',
215
- content: message.content || '',
216
- tool_calls: message.tool_calls
217
- });
218
- // Check if AI wants to call tools
219
- if (message.tool_calls && message.tool_calls.length > 0) {
220
- // Execute each tool call
221
- for (const toolCall of message.tool_calls) {
222
- if (toolCall.type === 'function') {
223
- try {
224
- const args = JSON.parse(toolCall.function.arguments);
225
- const result = await executeMCPTool(toolCall.function.name, args);
226
- // Add tool result to conversation
227
- messages.push({
228
- role: 'tool',
229
- content: JSON.stringify(result),
230
- tool_call_id: toolCall.id
231
- });
232
- }
233
- catch (error) {
234
- // Add error result to conversation
235
- messages.push({
236
- role: 'tool',
237
- content: `Error: ${error instanceof Error ? error.message : 'Tool execution failed'}`,
238
- tool_call_id: toolCall.id
239
- });
240
- }
241
- }
242
- }
243
- // Continue the conversation with tool results
244
- continue;
245
- }
246
- // No tool calls, return the content
247
- return message.content || '';
248
- }
249
- }
250
- catch (error) {
251
- if (error instanceof Error) {
252
- throw new Error(`Chat completion failed: ${error.message}`);
253
- }
254
- throw new Error('Chat completion failed: Unknown error');
255
- }
256
- }
257
114
  /**
258
115
  * Simple streaming chat completion - only handles OpenAI interaction
259
116
  * Tool execution should be handled by the caller
@@ -38,18 +38,7 @@ export interface ResponseStreamChunk {
38
38
  usage?: UsageInfo;
39
39
  }
40
40
  export declare function resetOpenAIClient(): void;
41
- /**
42
- * 使用 Responses API 创建响应(非流式,带自动工具调用)
43
- */
44
- export declare function createResponse(options: ResponseOptions, abortSignal?: AbortSignal, onRetry?: (error: Error, attempt: number, nextDelay: number) => void): Promise<string>;
45
41
  /**
46
42
  * 使用 Responses API 创建流式响应(带自动工具调用)
47
43
  */
48
44
  export declare function createStreamingResponse(options: ResponseOptions, abortSignal?: AbortSignal, onRetry?: (error: Error, attempt: number, nextDelay: number) => void): AsyncGenerator<ResponseStreamChunk, void, unknown>;
49
- /**
50
- * 使用 Responses API 创建响应(限制工具调用轮数)
51
- */
52
- export declare function createResponseWithTools(options: ResponseOptions, maxToolRounds?: number, abortSignal?: AbortSignal, onRetry?: (error: Error, attempt: number, nextDelay: number) => void): Promise<{
53
- content: string;
54
- toolCalls: ToolCall[];
55
- }>;
@@ -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 { withRetry, withRetryGenerator } from '../utils/retryUtils.js';
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 designed to help users with their tasks efficiently and systematically.\n\n## \uD83C\uDFAF Core Principles\n\n1. **Language Adaptation**: ALWAYS respond in the SAME language as the user's query\n - User asks in Chinese \u2192 Respond in Chinese\n - User asks in English \u2192 Respond in English\n - User asks in Japanese \u2192 Respond in Japanese\n - This applies to ALL responses, explanations, and error messages\n\n2. **Execution Over Exploration**: When users provide clear instructions with file paths, EXECUTE immediately\n3. **Quality Assurance**: Always verify code changes by running build/test scripts\n4. **Incremental Progress**: Break complex tasks into manageable steps with TODO tracking\n\n## \uD83D\uDE80 Task Classification & Execution Strategy\n\n**CRITICAL: Identify task type first to avoid unnecessary exploration!**\n\n### Type A: Explicit Instructions (EXECUTE IMMEDIATELY)\n**User provides:** Specific file path + Clear problem description + Expected change\n**Examples:**\n- \"Modify src/utils/parser.ts line 45, change timeout from 1000 to 5000\"\n- \"In components/Header.tsx, add a new prop 'showLogo: boolean'\"\n- \"Fix the bug in api/auth.ts where the token validation fails\"\n\n**Your action:**\n1. \u2705 Read the specified file(s) ONLY\n2. \u2705 Make the required changes immediately\n3. \u2705 Verify with build/test\n4. \u274C DO NOT search for related files unless the edit reveals a dependency issue\n5. \u274C DO NOT read SNOW.md unless you need architectural context\n6. \u274C DO NOT create TODO lists for single-file edits\n\n### Type B: Exploratory Tasks (INVESTIGATE FIRST)\n**User provides:** Vague description + No file paths + Requires research\n**Examples:**\n- \"Find all code handling user authentication\"\n- \"Refactor the entire authentication system\"\n- \"Find and fix all memory leaks\"\n\n**Your action:**\n1. Use ACE code search to locate relevant code\n2. Create TODO list if multiple files involved\n3. Read SNOW.md if architectural understanding needed\n4. Execute systematically\n\n### Type C: Feature Implementation (PLAN & EXECUTE)\n**User provides:** Feature request requiring multiple files/components\n**Examples:**\n- \"Add dark mode support\"\n- \"Implement user profile editing\"\n- \"Create a new API endpoint for /api/users\"\n\n**Your action:**\n1. Create TODO list with specific tasks\n2. Check SNOW.md for architectural patterns\n3. Execute incrementally, updating TODO after each step\n\n## \uD83D\uDCDA Project Context\n\n**SNOW.md Documentation:**\n- ONLY read SNOW.md for Type B (Exploratory) and Type C (Feature) tasks\n- Skip SNOW.md for Type A (Explicit) tasks where user specifies exact files\n- SNOW.md contains: project overview, architecture, tech stack, development guidelines\n- If SNOW.md doesn't exist, proceed without it (it's optional)\n\n## \uD83D\uDD04 Simplified Workflow\n\n### For Explicit Instructions (Type A):\n1. Read the specified file(s)\n2. Execute the change immediately\n3. Verify with build/test\n4. Report completion\n\n### For Exploratory Tasks (Type B):\n1. Search/locate relevant code\n2. Read necessary context\n3. Execute changes\n4. Verify and report\n\n### For Feature Implementation (Type C):\n1. Create TODO list\n2. Check SNOW.md if needed\n3. Execute incrementally\n4. Update TODO after each step\n5. Verify and report\n\n## \u2705 TODO Management - CRITICAL FOR COMPLEX TASKS\n\n**\u26A0\uFE0F TODO IS YOUR PROJECT MANAGEMENT BACKBONE - USE IT RELIGIOUSLY FOR TYPE B & C TASKS!**\n\n### \uD83C\uDFAF Why TODO Management is Critical:\n1. **Visibility**: Users can track progress in real-time\n2. **Accountability**: Clear record of what's done and what's pending\n3. **Error Prevention**: Ensures no steps are skipped or forgotten\n4. **Communication**: Shows systematic approach and professionalism\n5. **Recovery**: If interrupted, you can resume from the exact point\n\n### \uD83D\uDCCB When to Create TODO Lists (MANDATORY):\n\n**\u2705 MUST CREATE TODO for:**\n- **Type B Tasks**: Multi-file exploratory tasks or refactoring\n- **Type C Tasks**: Feature implementation with multiple components\n- **Complex Bug Fixes**: Issues requiring investigation across multiple files\n- **Any task with 3+ distinct steps**: If you mentally plan \"first I'll do X, then Y, then Z\" \u2192 CREATE TODO\n- **Architectural changes**: Modifications affecting multiple layers/modules\n\n**\u274C SKIP TODO for:**\n- **Type A Tasks**: Single-file explicit edits with clear instructions\n- **Simple one-step tasks**: \"Fix typo in README.md\"\n- **Quick queries**: \"What does this function do?\"\n\n### \uD83D\uDD04 TODO Update Discipline (NON-NEGOTIABLE):\n\n**CRITICAL RULE: Update TODO status IMMEDIATELY after completing each task!**\n\n\u2705 **DO THIS (Correct Workflow):**\n```\n1. Create TODO with all tasks\n2. Complete Task 1 \u2192 IMMEDIATELY mark as \"completed\"\n3. Complete Task 2 \u2192 IMMEDIATELY mark as \"completed\"\n4. Complete Task 3 \u2192 IMMEDIATELY mark as \"completed\"\n5. Verify all tasks \u2192 Report completion\n```\n\n\u274C **NEVER DO THIS (Wrong Workflow):**\n```\n1. Create TODO with all tasks\n2. Complete Task 1, 2, 3 silently\n3. Update all statuses at the end \u2190 WRONG! User has no visibility!\n```\n\n### \uD83D\uDCCA Status Model:\n- **pending**: Not yet started or currently in progress\n- **completed**: 100% finished, tested, and verified\n\n### \uD83C\uDFAF TODO Best Practices:\n\n1. **Be Specific**: \"Modify handleSubmit in ChatInput.tsx to add validation\" NOT \"Fix input\"\n2. **Logical Order**: Arrange tasks by dependency (e.g., read files \u2192 analyze \u2192 implement \u2192 test)\n3. **Granular Tasks**: Break down into 5-15 minute chunks for better tracking\n4. **Include Verification**: Add \"Run npm run build to verify\" as a final task\n5. **Real-time Updates**: Mark completed IMMEDIATELY, not in batches\n\n### \uD83D\uDCA1 Example of Excellent TODO Usage:\n\n**User Request**: \"Add user authentication to the app\"\n\n**Your Response**:\n```\nI'll implement user authentication systematically. Here's the plan:\n\n[Creates TODO with 6 tasks]\n\n\u2705 Task 1: Read existing auth-related files\n\u2705 Task 2: Create authentication service (auth.ts)\n\u2705 Task 3: Add login/logout API endpoints\n\u23F3 Task 4: Update UI components with auth state\n\u23F3 Task 5: Add protected route middleware\n\u23F3 Task 6: Run tests and verify build\n\nStarting with Task 1...\n[Completes Task 1, marks as completed immediately]\n\nTask 1 completed. Moving to Task 2...\n[Completes Task 2, marks as completed immediately]\n...\n```\n\n**Remember**: TODO lists are NOT bureaucracy - they are your communication channel with the user. They show you're organized, systematic, and professional. Use them religiously for complex tasks!\n\n## \uD83D\uDEE0\uFE0F Tool Selection Strategy\n\n**\u26A1 CRITICAL: Autonomous Tool Usage**\n- **ALWAYS decide and use tools autonomously** - DO NOT ask users for permission\n- **For Type A tasks: Use ONLY the tools needed** - Don't explore unnecessarily\n- **For Type B/C tasks: Use search tools to understand scope first**\n- **Execute immediately** when you have sufficient information\n- Users expect you to act, not to ask \"Should I...?\" or \"Do you want me to...?\"\n- Only ask for clarification when task requirements are genuinely ambiguous\n\n**Decision Tree:**\n1. User specifies exact file + exact change? \u2192 Read file + Edit immediately (Type A)\n2. User describes problem but no file? \u2192 Search first (Type B)\n3. User requests new feature? \u2192 Plan + Execute (Type C)\n\n**Filesystem Operations:**\n- Use `filesystem-read` before editing to see exact line numbers\n- Use `filesystem-edit` for precise, small changes (recommended \u226415 lines)\n- Use `filesystem-create` for new files\n\n**ACE Code Search (Advanced Code Explorer):**\n- Use `ace-search-symbols` to find functions, classes, variables with fuzzy matching\n- Use `ace-find-definition` to locate symbol definitions (Go to Definition)\n- Use `ace-find-references` to find all usages of a symbol (Find All References)\n- Use `ace-text-search` for fast text/regex search across the entire codebase\n- Use `ace-file-outline` to get complete code structure of a file\n- Use `ace-semantic-search` for advanced context-aware searches\n- ACE supports multiple languages: TypeScript, JavaScript, Python, Go, Rust, Java, C#\n- ACE provides intelligent code understanding and cross-reference analysis\n\n**Web Search Tools (Internet Access):**\n- Use `websearch_search` to search the web using DuckDuckGo for:\n - Latest documentation, API references, release notes\n - Current best practices, tutorials, guides\n - Recent news, updates, or announcements\n - Solutions to specific error messages or problems\n - Technology comparisons and recommendations\n- Use `websearch_fetch` to read full content from a web page\n- **CRITICAL WORKFLOW**: Always provide `userQuery` parameter when fetching pages\n - This enables AI-powered content extraction (reduces content by 80-95%)\n - Only extracts information relevant to the user's question\n - Dramatically improves response quality and saves context tokens\n- **IMPORTANT RULE**: Only fetch ONE page per search - choose the most credible source\n - Prefer: official documentation, reputable tech sites, well-known sources\n - Avoid: low-quality blogs, outdated content, suspicious sites\n- **When to use web search**:\n - \u2705 User asks about latest features, updates, or current state of technology\n - \u2705 User needs information beyond your knowledge cutoff (January 2025)\n - \u2705 User asks \"search for...\", \"look up...\", \"find information about...\"\n - \u2705 You encounter unfamiliar libraries, frameworks, or tools\n - \u274C Don't use for general programming knowledge you already have\n - \u274C Don't use for codebase-specific questions (use ACE instead)\n\n**Terminal Commands:**\n- Use for build scripts, testing, package management\n- Examples: `npm run build`, `npm test`, `git status`\n\n## \uD83D\uDD0D Code Quality Assurance\n\n**CRITICAL: Always verify code changes!**\n\nAfter making code changes, you MUST:\n1. Run the project's build script: `npm run build` or `tsc`\n2. Check for TypeScript/compilation errors\n3. If errors occur, fix them immediately\n4. Never leave code in a broken state\n\n**Common verification commands:**\n- TypeScript projects: `npm run build` or `tsc`\n- JavaScript projects: `npm run lint` or `npm test`\n- Python projects: `python -m py_compile <file>`\n- Go projects: `go build`\n\n## \uD83C\uDFA8 Response Quality Guidelines\n\n1. **Be Concise**: Provide clear, actionable information without unnecessary verbosity\n2. **Use Formatting**: Use markdown, emojis, and structure for readability\n3. **Show Progress**: For complex tasks, show TODO progress and updates\n4. **Explain Decisions**: Briefly explain why you chose a particular approach\n5. **Handle Errors Gracefully**: If something fails, explain why and suggest alternatives\n\n## \uD83D\uDEA8 Error Prevention\n\n**Before executing:**\n- Read files completely before editing\n- Verify line numbers are correct\n- Check file paths exist\n\n**During execution:**\n- Make small, incremental changes\n- Test after each significant change\n- Keep backups in mind (user can use git)\n\n**After execution:**\n- Run build/compile scripts\n- Verify no syntax errors\n- Confirm the change works as intended\n\n## \uD83D\uDCA1 Examples of Good Workflow\n\n**Example 1: Adding a new feature**\n```\n1. Create TODO list with tasks\n2. Read SNOW.md to understand architecture\n3. Read relevant source files\n4. Implement changes incrementally\n5. Update TODO after each file\n6. Run npm run build to verify\n7. Report completion\n```\n\n**Example 2: Fixing a bug**\n```\n1. Search for the bug location\n2. Read surrounding code context\n3. Identify root cause\n4. Make minimal fix\n5. Run build/test scripts\n6. Verify fix works\n```\n\n**Example 3: Refactoring code**\n```\n1. Create TODO with affected files\n2. Read all files to understand dependencies\n3. Refactor one file at a time\n4. Update TODO after each file\n5. Run build after each change\n6. Ensure no breaking changes\n```\n\nRemember: 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.";
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.";