snow-ai 0.5.12 → 0.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle/cli.mjs CHANGED
@@ -446229,7 +446229,9 @@ function useKeyboardInput(options3) {
446229
446229
  executeCommand(selectedCommand.name).then((result2) => {
446230
446230
  commandUsageManager.recordUsage(selectedCommand.name);
446231
446231
  if (onCommand) {
446232
- onCommand(selectedCommand.name, result2);
446232
+ Promise.resolve(onCommand(selectedCommand.name, result2)).catch((error) => {
446233
+ console.error("Command execution error:", error);
446234
+ });
446233
446235
  }
446234
446236
  });
446235
446237
  buffer.setText("");
@@ -446281,7 +446283,9 @@ function useKeyboardInput(options3) {
446281
446283
  executeCommand(commandName, commandArgs).then((result2) => {
446282
446284
  commandUsageManager.recordUsage(commandName);
446283
446285
  if (onCommand) {
446284
- onCommand(commandName, result2);
446286
+ Promise.resolve(onCommand(commandName, result2)).catch((error) => {
446287
+ console.error("Command execution error:", error);
446288
+ });
446285
446289
  }
446286
446290
  });
446287
446291
  buffer.setText("");
@@ -528783,33 +528787,46 @@ async function executeContextCompression(sessionId) {
528783
528787
  };
528784
528788
  }
528785
528789
  const newSessionMessages = [];
528786
- newSessionMessages.push({
528787
- role: "user",
528788
- content: `[Context Summary from Previous Conversation]
528790
+ let finalContent = `[Context Summary from Previous Conversation]
528789
528791
 
528790
- ${compressionResult.summary}`,
528791
- timestamp: Date.now()
528792
- });
528792
+ ${compressionResult.summary}`;
528793
528793
  if (compressionResult.preservedMessages && compressionResult.preservedMessages.length > 0) {
528794
+ finalContent += "\n\n---\n\n[Last Interaction - Preserved for Continuity]\n\n";
528794
528795
  for (const msg of compressionResult.preservedMessages) {
528795
- newSessionMessages.push({
528796
- role: msg.role,
528797
- content: msg.content,
528798
- timestamp: Date.now(),
528799
- ...msg.tool_call_id !== void 0 && {
528800
- tool_call_id: msg.tool_call_id
528801
- },
528802
- ...msg.tool_calls !== void 0 && { tool_calls: msg.tool_calls },
528803
- ...msg.images !== void 0 && { images: msg.images },
528804
- ...msg.reasoning !== void 0 && { reasoning: msg.reasoning },
528805
- ...msg.thinking !== void 0 && { thinking: msg.thinking },
528806
- // 保留 thinking 字段(Anthropic Extended Thinking)
528807
- ...msg.subAgentInternal !== void 0 && {
528808
- subAgentInternal: msg.subAgentInternal
528796
+ if (msg.role === "user") {
528797
+ finalContent += `**User:**
528798
+ ${msg.content}
528799
+
528800
+ `;
528801
+ } else if (msg.role === "assistant") {
528802
+ finalContent += `**Assistant:**
528803
+ ${msg.content}`;
528804
+ if (msg.tool_calls && msg.tool_calls.length > 0) {
528805
+ finalContent += "\n\n**[Tool Calls Initiated]:**\n```json\n";
528806
+ finalContent += JSON.stringify(msg.tool_calls, null, 2);
528807
+ finalContent += "\n```\n\n";
528808
+ } else {
528809
+ finalContent += "\n\n";
528809
528810
  }
528810
- });
528811
+ } else if (msg.role === "tool") {
528812
+ finalContent += `**[Tool Result - ${msg.tool_call_id}]:**
528813
+ `;
528814
+ try {
528815
+ const parsed = JSON.parse(msg.content);
528816
+ finalContent += "```json\n" + JSON.stringify(parsed, null, 2) + "\n```\n\n";
528817
+ } catch {
528818
+ finalContent += `${msg.content}
528819
+
528820
+ `;
528821
+ }
528822
+ }
528811
528823
  }
528812
528824
  }
528825
+ newSessionMessages.push({
528826
+ role: "user",
528827
+ content: finalContent,
528828
+ timestamp: Date.now()
528829
+ });
528813
528830
  const compressedSession = await sessionManager.createNewSession(false);
528814
528831
  compressedSession.messages = newSessionMessages;
528815
528832
  compressedSession.messageCount = newSessionMessages.length;
@@ -528864,6 +528881,7 @@ function useCommandHandler(options3) {
528864
528881
  const { stdout } = use_stdout_default();
528865
528882
  const handleCommandExecution = (0, import_react121.useCallback)(async (commandName, result2) => {
528866
528883
  if (commandName === "compact" && result2.success && result2.action === "compact") {
528884
+ console.log("[Compact] Starting compression, setting isCompressing=true");
528867
528885
  options3.setIsCompressing(true);
528868
528886
  options3.setCompressionError(null);
528869
528887
  try {
@@ -528871,16 +528889,19 @@ function useCommandHandler(options3) {
528871
528889
  if (!currentSession) {
528872
528890
  throw new Error("No active session to compress");
528873
528891
  }
528892
+ console.log("[Compact] Executing compression for session:", currentSession.id);
528874
528893
  const compressionResult = await executeContextCompression(currentSession.id);
528875
528894
  if (!compressionResult) {
528876
528895
  throw new Error("Compression failed");
528877
528896
  }
528897
+ console.log("[Compact] Compression completed successfully");
528878
528898
  options3.clearSavedMessages();
528879
528899
  options3.setMessages(compressionResult.uiMessages);
528880
528900
  options3.setRemountKey((prev) => prev + 1);
528881
528901
  options3.setContextUsage(compressionResult.usage);
528882
528902
  } catch (error) {
528883
528903
  const errorMsg = error instanceof Error ? error.message : "Unknown compression error";
528904
+ console.error("[Compact] Compression error:", errorMsg);
528884
528905
  options3.setCompressionError(errorMsg);
528885
528906
  const errorMessage = {
528886
528907
  role: "assistant",
@@ -528891,6 +528912,7 @@ ${errorMsg}`,
528891
528912
  };
528892
528913
  options3.setMessages((prev) => [...prev, errorMessage]);
528893
528914
  } finally {
528915
+ console.log("[Compact] Setting isCompressing=false");
528894
528916
  options3.setIsCompressing(false);
528895
528917
  }
528896
528918
  return;
@@ -530619,27 +530641,27 @@ var init_promptOptimizeAgent = __esm({
530619
530641
  return `${msg.role}: ${content}`;
530620
530642
  }).join("\n");
530621
530643
  }
530622
- const optimizationPrompt = `You are a prompt optimization assistant. Your task is to improve user prompts for better AI understanding while maintaining HIGH FIDELITY to the original content.
530644
+ const optimizationPrompt = `I want you to help me optimize this prompt so the AI can better understand my intent while maintaining HIGH FIDELITY to the original content.
530623
530645
 
530624
- User's original prompt:
530646
+ Here's my original prompt:
530625
530647
  ${userPrompt}${contextSummary}
530626
530648
 
530627
- Your optimization goals (in priority order):
530628
- 1. **HIGH FIDELITY REQUIREMENT**: Preserve ALL important information, details, and requirements from the user's original prompt - DO NOT lose or omit any critical content
530629
- 2. Preserve the EXACT SAME LANGUAGE as the user (if Chinese, stay Chinese; if English, stay English)
530630
- 3. Keep the core intent and meaning unchanged
530631
- 4. Make the prompt clearer and more specific ONLY if vague - if already clear, keep it as-is
530632
- 5. Add relevant context if the user is asking follow-up questions
530633
- 6. Break down complex requests into clear requirements without losing details
530649
+ I want you to follow these optimization goals (in priority order):
530650
+ 1. **HIGH FIDELITY REQUIREMENT**: Preserve ALL important information, details, and requirements from my original prompt - DO NOT lose or omit any critical content
530651
+ 2. Preserve the EXACT SAME LANGUAGE I'm using (if I wrote in Chinese, keep it Chinese; if English, keep it English)
530652
+ 3. Keep my core intent and meaning unchanged
530653
+ 4. Make my prompt clearer and more specific ONLY if it's vague - if it's already clear, keep it as-is
530654
+ 5. Add relevant context if I'm asking follow-up questions
530655
+ 6. Break down my complex requests into clear requirements without losing details
530634
530656
  7. Keep the tone natural and conversational
530635
- 8. DO NOT add unnecessary formality or change the user's communication style
530636
- 9. If the prompt is already clear and specific, return it as-is
530657
+ 8. DO NOT add unnecessary formality or change my communication style
530658
+ 9. If my prompt is already clear and specific, return it as-is
530637
530659
 
530638
530660
  CRITICAL RULES:
530639
- - NEVER remove important details, specific requirements, file paths, code snippets, or technical specifications
530640
- - NEVER simplify the prompt if it means losing user-provided information
530641
- - When in doubt, prefer preserving the original over optimizing
530642
- - The goal is CLARITY, not BREVITY - keep all important content
530661
+ - NEVER remove important details, specific requirements, file paths, code snippets, or technical specifications I provided
530662
+ - NEVER simplify my prompt if it means losing information I gave you
530663
+ - When in doubt, prefer preserving my original content over optimizing
530664
+ - The goal is CLARITY, not BREVITY - keep all my important content
530643
530665
 
530644
530666
  IMPORTANT: Output ONLY the optimized prompt text. No explanations, no meta-commentary, no JSON format. Just the optimized prompt itself.`;
530645
530667
  const messages = [
@@ -535806,7 +535828,7 @@ You can now edit these files to customize your skill.`,
535806
535828
  )
535807
535829
  ),
535808
535830
  snapshotState.pendingRollback && import_react128.default.createElement(FileRollbackConfirmation, { fileCount: snapshotState.pendingRollback.fileCount, filePaths: snapshotState.pendingRollback.filePaths || [], onConfirm: handleRollbackConfirm }),
535809
- !pendingToolConfirmation && !pendingUserQuestion && !bashSensitiveCommand && !isCompressing && !(panelState.showSessionPanel || panelState.showMcpPanel || panelState.showUsagePanel || panelState.showHelpPanel || panelState.showCustomCommandConfig || panelState.showSkillsCreation || panelState.showWorkingDirPanel || showPermissionsPanel) && !snapshotState.pendingRollback && import_react128.default.createElement(ChatFooter, { onSubmit: handleMessageSubmit, onCommand: handleCommandExecution, onHistorySelect: handleHistorySelect, onSwitchProfile: handleSwitchProfile, handleProfileSelect, handleHistorySelect, disabled: !!pendingToolConfirmation || !!bashSensitiveCommand || isExecutingTerminalCommand, isProcessing: streamingState.isStreaming || isSaving || bashMode.state.isExecuting, chatHistory: messages, yoloMode, setYoloMode, planMode, setPlanMode, vulnerabilityHuntingMode, setVulnerabilityHuntingMode, contextUsage: streamingState.contextUsage ? {
535831
+ !pendingToolConfirmation && !pendingUserQuestion && !bashSensitiveCommand && !(panelState.showSessionPanel || panelState.showMcpPanel || panelState.showUsagePanel || panelState.showHelpPanel || panelState.showCustomCommandConfig || panelState.showSkillsCreation || panelState.showWorkingDirPanel || showPermissionsPanel) && !snapshotState.pendingRollback && import_react128.default.createElement(ChatFooter, { onSubmit: handleMessageSubmit, onCommand: handleCommandExecution, onHistorySelect: handleHistorySelect, onSwitchProfile: handleSwitchProfile, handleProfileSelect, handleHistorySelect, disabled: !!pendingToolConfirmation || !!bashSensitiveCommand || isExecutingTerminalCommand || isCompressing, isProcessing: streamingState.isStreaming || isSaving || bashMode.state.isExecuting || isCompressing, chatHistory: messages, yoloMode, setYoloMode, planMode, setPlanMode, vulnerabilityHuntingMode, setVulnerabilityHuntingMode, contextUsage: streamingState.contextUsage ? {
535810
535832
  inputTokens: streamingState.contextUsage.prompt_tokens,
535811
535833
  maxContextTokens: getOpenAiConfig().maxContextTokens || 4e3,
535812
535834
  cacheCreationTokens: streamingState.contextUsage.cache_creation_input_tokens,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {