snow-ai 0.6.5 → 0.6.6

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
@@ -548354,6 +548354,10 @@ var init_toolDisplayConfig = __esm({
548354
548354
  });
548355
548355
 
548356
548356
  // dist/utils/core/contextCompressor.js
548357
+ var contextCompressor_exports = {};
548358
+ __export(contextCompressor_exports, {
548359
+ compressContext: () => compressContext
548360
+ });
548357
548361
  function findPreserveStartIndex(messages) {
548358
548362
  if (messages.length === 0) {
548359
548363
  return 0;
@@ -548463,6 +548467,45 @@ function cleanOrphanedToolCalls(messages) {
548463
548467
  console.log(`[contextCompressor:cleanOrphanedToolCalls] Removed ${indicesToRemove.length} orphaned messages from compression input`);
548464
548468
  }
548465
548469
  }
548470
+ function formatMessageForTranscript(msg) {
548471
+ var _a21, _b14;
548472
+ if (msg.role === "tool") {
548473
+ return null;
548474
+ }
548475
+ const parts = [];
548476
+ const roleLabel = msg.role === "user" ? "[User]" : "[Assistant]";
548477
+ if (msg.role === "assistant" && msg.tool_calls && msg.tool_calls.length > 0) {
548478
+ if (msg.content) {
548479
+ parts.push(`${roleLabel}
548480
+ ${msg.content}`);
548481
+ } else {
548482
+ parts.push(roleLabel);
548483
+ }
548484
+ for (const tc of msg.tool_calls) {
548485
+ const funcName = ((_a21 = tc.function) == null ? void 0 : _a21.name) || "unknown";
548486
+ const args2 = ((_b14 = tc.function) == null ? void 0 : _b14.arguments) || "{}";
548487
+ parts.push(` -> Tool Call: ${funcName}(${args2})`);
548488
+ }
548489
+ return parts.join("\n");
548490
+ }
548491
+ if (msg.content) {
548492
+ parts.push(`${roleLabel}
548493
+ ${msg.content}`);
548494
+ }
548495
+ if (msg.thinking) {
548496
+ parts.push(`[Thinking]
548497
+ ${msg.thinking}`);
548498
+ }
548499
+ if (msg.reasoning) {
548500
+ parts.push(`[Reasoning]
548501
+ ${msg.reasoning}`);
548502
+ }
548503
+ if (msg.reasoning_content) {
548504
+ parts.push(`[Reasoning]
548505
+ ${msg.reasoning_content}`);
548506
+ }
548507
+ return parts.length > 0 ? parts.join("\n") : null;
548508
+ }
548466
548509
  function prepareMessagesForCompression(conversationMessages, customSystemPrompt) {
548467
548510
  const messages = [];
548468
548511
  if (customSystemPrompt) {
@@ -548473,31 +548516,23 @@ function prepareMessagesForCompression(conversationMessages, customSystemPrompt)
548473
548516
  content: getSystemPromptForMode(false, false)
548474
548517
  });
548475
548518
  }
548519
+ const transcriptParts = [];
548476
548520
  for (const msg of conversationMessages) {
548477
- if (msg.role !== "system") {
548478
- const compressMsg = {
548479
- role: msg.role,
548480
- content: msg.content
548481
- };
548482
- if (msg.tool_calls) {
548483
- compressMsg.tool_calls = msg.tool_calls;
548484
- }
548485
- if (msg.tool_call_id) {
548486
- compressMsg.tool_call_id = msg.tool_call_id;
548487
- }
548488
- if (msg.reasoning) {
548489
- compressMsg.reasoning = msg.reasoning;
548490
- }
548491
- if (msg.thinking) {
548492
- compressMsg.thinking = msg.thinking;
548493
- }
548494
- if (msg.reasoning_content) {
548495
- compressMsg.reasoning_content = msg.reasoning_content;
548496
- }
548497
- messages.push(compressMsg);
548521
+ if (msg.role === "system") {
548522
+ continue;
548523
+ }
548524
+ const formatted = formatMessageForTranscript(msg);
548525
+ if (formatted) {
548526
+ transcriptParts.push(formatted);
548498
548527
  }
548499
548528
  }
548500
- cleanOrphanedToolCalls(messages);
548529
+ const conversationTranscript = transcriptParts.join("\n\n---\n\n");
548530
+ messages.push({
548531
+ role: "user",
548532
+ content: `## Conversation History to Compress
548533
+
548534
+ ${conversationTranscript}`
548535
+ });
548501
548536
  messages.push({
548502
548537
  role: "user",
548503
548538
  content: COMPRESSION_PROMPT
@@ -548725,57 +548760,59 @@ var init_contextCompressor = __esm({
548725
548760
  init_responses();
548726
548761
  init_gemini();
548727
548762
  init_anthropic();
548728
- COMPRESSION_PROMPT = `**YOUR ONLY TASK: Compress the conversation history into a structured summary. DO NOT ask questions, DO NOT seek clarification, DO NOT interact with users.**
548729
-
548730
- You are a context compression system. Your job is to extract and preserve all critical information from the conversation history, regardless of its length or complexity. Even for short or simple conversations, you MUST produce a comprehensive summary.
548731
-
548732
- Create a detailed summary following this structure:
548733
-
548734
- ## Current Task & Goals
548735
- - What is the main task or project being worked on?
548736
- - What are the specific objectives and desired outcomes?
548737
- - What is the current progress status?
548738
-
548739
- ## Technical Context
548740
- - Key technologies, frameworks, libraries, and tools being used
548741
- - Important file paths, function names, and code locations mentioned
548742
- - Architecture decisions and design patterns chosen
548743
- - Configuration settings and environment details
548744
-
548745
- ## Key Decisions & Approaches
548746
- - Important decisions made and their rationale
548747
- - Chosen approaches and methodologies
548748
- - Solutions to problems encountered
548749
- - Best practices or patterns agreed upon
548750
-
548751
- ## Completed Work
548752
- - What has been successfully implemented or resolved?
548753
- - Important code changes, fixes, or features added
548754
- - Test results or validation performed
548755
-
548756
- ## Pending & In-Progress Work
548757
- - What tasks are currently unfinished?
548758
- - Known issues or blockers that need addressing
548759
- - Next steps planned or discussed
548760
- - Open questions or areas needing clarification
548761
-
548762
- ## Critical Information
548763
- - Important data, values, IDs, or credentials referenced (sanitized)
548764
- - Error messages, warnings, or diagnostic information
548765
- - User preferences, requirements, or constraints
548766
- - Any other context essential for seamless continuation
548767
-
548768
- **CRITICAL RULES:**
548769
- 1. NEVER ask users for clarification - work with what you have
548770
- 2. NEVER say the context is too short - always summarize what exists
548771
- 3. NEVER refuse to compress - this is your only function
548772
- 4. Be specific with names, paths, and technical details
548773
- 5. Preserve exact terminology and technical vocabulary
548774
- 6. Include enough detail to continue work without confusion
548775
- 7. Use code snippets or examples where helpful
548776
- 8. Prioritize actionable information over general descriptions
548777
-
548778
- **EXECUTE THE COMPRESSION NOW - NO QUESTIONS, NO DELAYS.**`;
548763
+ COMPRESSION_PROMPT = `**TASK: Create a comprehensive handover document from the conversation history above.**
548764
+
548765
+ You are creating a technical handover document. Extract and preserve all critical information with rigorous detail and accuracy. This is NOT a task continuation prompt - this is archival documentation.
548766
+
548767
+ **OUTPUT FORMAT - Structured Handover Document:**
548768
+
548769
+ ## Project/Task Overview
548770
+ - Project or task being worked on
548771
+ - Objectives and expected outcomes
548772
+ - Current completion status
548773
+
548774
+ ## Technical Environment
548775
+ - Technologies, frameworks, libraries, and tools in use
548776
+ - **EXACT** file paths (full paths, not relative)
548777
+ - **EXACT** function names, class names, variable names
548778
+ - Architecture patterns and design decisions
548779
+ - Configuration details and environment specifics
548780
+
548781
+ ## Implementation Details
548782
+ - Technical decisions made and rationale
548783
+ - Chosen approaches and implementation methods
548784
+ - Solutions applied to specific problems
548785
+ - Code patterns and best practices used
548786
+ - **EXACT** code snippets where relevant (preserve syntax)
548787
+
548788
+ ## Work Completed
548789
+ - Features implemented (with file references)
548790
+ - Bugs fixed (with root cause analysis)
548791
+ - Code modifications made (with before/after context)
548792
+ - Test results and validation outcomes
548793
+
548794
+ ## Work In Progress
548795
+ - Incomplete tasks (with specific blocking reasons)
548796
+ - Known issues and their diagnostic details
548797
+ - Planned next steps (concrete, actionable)
548798
+ - Open questions requiring decisions
548799
+
548800
+ ## Critical Reference Data
548801
+ - Important IDs, keys, values (sanitize credentials)
548802
+ - Error messages and stack traces (exact wording)
548803
+ - User requirements and constraints (explicit details)
548804
+ - Edge cases and special handling requirements
548805
+
548806
+ **QUALITY REQUIREMENTS:**
548807
+ 1. Preserve EXACT technical terms - never paraphrase code/file names
548808
+ 2. Include FULL context - paths, versions, configurations
548809
+ 3. Maintain PRECISION - specific line numbers, exact error messages
548810
+ 4. NO assumptions - only document what was explicitly discussed
548811
+ 5. NO vague summaries - provide actionable, specific details
548812
+ 6. Use markdown code blocks for code snippets with language tags
548813
+ 7. Structure information hierarchically for easy scanning
548814
+
548815
+ **EXECUTE NOW - Output the handover document immediately.**`;
548779
548816
  }
548780
548817
  });
548781
548818
 
@@ -558605,6 +558642,10 @@ var init_sse_server = __esm({
558605
558642
  }));
558606
558643
  return;
558607
558644
  }
558645
+ if (pathname === "/context/compress" && req.method === "POST") {
558646
+ this.handleContextCompress(req, res);
558647
+ return;
558648
+ }
558608
558649
  res.writeHead(404);
558609
558650
  res.end("Not Found");
558610
558651
  }
@@ -558802,6 +558843,93 @@ var init_sse_server = __esm({
558802
558843
  }
558803
558844
  })();
558804
558845
  }
558846
+ /**
558847
+ * 处理上下文压缩请求
558848
+ * POST /context/compress
558849
+ * Body: { messages: ChatMessage[] } 或 { sessionId: string }
558850
+ * Response: { success: true, result: CompressionResult } 或 { success: false, error: string }
558851
+ */
558852
+ handleContextCompress(req, res) {
558853
+ void (async () => {
558854
+ try {
558855
+ const { compressContext: compressContext2 } = await Promise.resolve().then(() => (init_contextCompressor(), contextCompressor_exports));
558856
+ const { sessionManager: sessionManager2 } = await Promise.resolve().then(() => (init_sessionManager(), sessionManager_exports));
558857
+ const body = await this.readJsonBody(req);
558858
+ let messages;
558859
+ if (body.messages && Array.isArray(body.messages)) {
558860
+ messages = body.messages;
558861
+ } else if (body.sessionId) {
558862
+ const session = await sessionManager2.loadSession(body.sessionId);
558863
+ if (!session) {
558864
+ res.writeHead(404, {
558865
+ "Content-Type": "application/json",
558866
+ "Access-Control-Allow-Origin": "*"
558867
+ });
558868
+ res.end(JSON.stringify({ success: false, error: "Session not found" }));
558869
+ return;
558870
+ }
558871
+ messages = session.messages || [];
558872
+ } else {
558873
+ res.writeHead(400, {
558874
+ "Content-Type": "application/json",
558875
+ "Access-Control-Allow-Origin": "*"
558876
+ });
558877
+ res.end(JSON.stringify({
558878
+ success: false,
558879
+ error: "Missing required field: messages or sessionId"
558880
+ }));
558881
+ return;
558882
+ }
558883
+ if (messages.length === 0) {
558884
+ res.writeHead(400, {
558885
+ "Content-Type": "application/json",
558886
+ "Access-Control-Allow-Origin": "*"
558887
+ });
558888
+ res.end(JSON.stringify({ success: false, error: "No messages to compress" }));
558889
+ return;
558890
+ }
558891
+ const result2 = await compressContext2(messages);
558892
+ if (result2 === null) {
558893
+ res.writeHead(200, {
558894
+ "Content-Type": "application/json",
558895
+ "Access-Control-Allow-Origin": "*"
558896
+ });
558897
+ res.end(JSON.stringify({
558898
+ success: true,
558899
+ result: null,
558900
+ message: "Compression skipped (no history to compress)"
558901
+ }));
558902
+ return;
558903
+ }
558904
+ if (result2.hookFailed) {
558905
+ res.writeHead(200, {
558906
+ "Content-Type": "application/json",
558907
+ "Access-Control-Allow-Origin": "*"
558908
+ });
558909
+ res.end(JSON.stringify({
558910
+ success: false,
558911
+ hookFailed: true,
558912
+ hookErrorDetails: result2.hookErrorDetails
558913
+ }));
558914
+ return;
558915
+ }
558916
+ res.writeHead(200, {
558917
+ "Content-Type": "application/json",
558918
+ "Access-Control-Allow-Origin": "*"
558919
+ });
558920
+ res.end(JSON.stringify({ success: true, result: result2 }));
558921
+ } catch (error) {
558922
+ res.writeHead(500, {
558923
+ "Content-Type": "application/json",
558924
+ "Access-Control-Allow-Origin": "*"
558925
+ });
558926
+ res.end(JSON.stringify({
558927
+ success: false,
558928
+ error: error instanceof Error ? error.message : "Unknown error"
558929
+ }));
558930
+ }
558931
+ })();
558932
+ }
558805
558933
  /**
558806
558934
  * 处理 SSE 连接
558807
558935
  */
@@ -559716,6 +559844,13 @@ var init_SSEServerStatus = __esm({
559716
559844
  port,
559717
559845
  "/session/:sessionId"
559718
559846
  ),
559847
+ import_react139.default.createElement(
559848
+ Text,
559849
+ { color: "blue" },
559850
+ " POST http://localhost:",
559851
+ port,
559852
+ "/context/compress"
559853
+ ),
559719
559854
  import_react139.default.createElement(
559720
559855
  Text,
559721
559856
  { color: "blue" },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
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.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "Intelligent Command Line Assistant powered by AI",
5
5
  "license": "MIT",
6
6
  "bin": {