snow-ai 0.7.30 → 0.7.31

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
@@ -568578,8 +568578,8 @@ var init_textBuffer = __esm({
568578
568578
  * 与 insertPastingIndicator 共用 tempPastingPlaceholder 字段,
568579
568579
  * 任意时刻只允许一个临时占位符存在。
568580
568580
  */
568581
- insertImageLoadingIndicator() {
568582
- if (this.tempPastingPlaceholder) {
568581
+ insertImageLoadingIndicator(isImagePaste) {
568582
+ if (!isImagePaste || this.tempPastingPlaceholder) {
568583
568583
  return;
568584
568584
  }
568585
568585
  this.tempPastingPlaceholder = `[image upload...]`;
@@ -570655,21 +570655,53 @@ import { exec as exec8 } from "child_process";
570655
570655
  import { promisify as promisify3 } from "util";
570656
570656
  function useClipboard(buffer, updateCommandPanelState, updateFilePickerState, triggerUpdate) {
570657
570657
  const pasteFromClipboard = (0, import_react99.useCallback)(async () => {
570658
- buffer.insertImageLoadingIndicator();
570659
- {
570658
+ let imageInserted = false;
570659
+ let imageLoadingIndicatorShown = false;
570660
+ const showImageLoadingIndicator = async () => {
570661
+ if (imageLoadingIndicatorShown) {
570662
+ return;
570663
+ }
570664
+ imageLoadingIndicatorShown = true;
570665
+ buffer.insertImageLoadingIndicator(true);
570660
570666
  const text2 = buffer.getFullText();
570661
570667
  const cursorPos = buffer.getCursorPosition();
570662
570668
  updateCommandPanelState(text2);
570663
570669
  updateFilePickerState(text2, cursorPos);
570664
- }
570665
- triggerUpdate();
570666
- await new Promise((resolve13) => setTimeout(resolve13, 0));
570667
- let imageInserted = false;
570670
+ triggerUpdate();
570671
+ await new Promise((resolve13) => setTimeout(resolve13, 0));
570672
+ };
570673
+ const insertClipboardText = (clipboardText) => {
570674
+ if (!clipboardText) {
570675
+ return false;
570676
+ }
570677
+ buffer.insert(clipboardText);
570678
+ const fullText = buffer.getFullText();
570679
+ const cursorPos = buffer.getCursorPosition();
570680
+ updateCommandPanelState(fullText);
570681
+ updateFilePickerState(fullText, cursorPos);
570682
+ triggerUpdate();
570683
+ return true;
570684
+ };
570668
570685
  try {
570669
570686
  const isWslEnv = process.platform === "linux" && isWSL();
570670
570687
  const psCmd = isWslEnv ? "powershell.exe" : "powershell";
570671
570688
  if (process.platform === "win32" || isWslEnv) {
570672
570689
  try {
570690
+ const probeScript = "Add-Type -AssemblyName System.Windows.Forms; $hasImage = [System.Windows.Forms.Clipboard]::ContainsImage(); $textBase64 = ''; if (-not $hasImage) { $text = [System.Windows.Forms.Clipboard]::GetText(); if ($null -eq $text) { $text = '' }; $textBase64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($text)); }; Write-Output $hasImage; Write-Output $textBase64";
570691
+ const encodedProbe = Buffer.from(probeScript, "utf16le").toString("base64");
570692
+ const { stdout: probeStdout } = await execAsync3(`${psCmd} -NoProfile -EncodedCommand ${encodedProbe}`, {
570693
+ encoding: "utf-8",
570694
+ timeout: 2e3,
570695
+ maxBuffer: 10 * 1024 * 1024
570696
+ });
570697
+ const [hasImageLine = "", ...textBase64Lines] = probeStdout.split(/\r?\n/);
570698
+ if (!/^true$/i.test(hasImageLine.trim())) {
570699
+ const textBase64 = textBase64Lines.join("").replace(/\s/g, "");
570700
+ const clipboardText = textBase64 ? Buffer.from(textBase64, "base64").toString("utf8") : "";
570701
+ insertClipboardText(clipboardText);
570702
+ return;
570703
+ }
570704
+ await showImageLoadingIndicator();
570673
570705
  const psScript = "Add-Type -AssemblyName System.Windows.Forms; Add-Type -AssemblyName System.Drawing; $clipboard = [System.Windows.Forms.Clipboard]::GetImage(); if ($clipboard -ne $null) { $ms = New-Object System.IO.MemoryStream; $width = $clipboard.Width; $height = $clipboard.Height; $maxSize = 2048; if ($width -gt $maxSize -or $height -gt $maxSize) { $ratio = [Math]::Min($maxSize / $width, $maxSize / $height); $newWidth = [int]($width * $ratio); $newHeight = [int]($height * $ratio); $resized = New-Object System.Drawing.Bitmap($newWidth, $newHeight); $graphics = [System.Drawing.Graphics]::FromImage($resized); $graphics.CompositingQuality = [System.Drawing.Drawing2D.CompositingQuality]::HighQuality; $graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic; $graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality; $graphics.DrawImage($clipboard, 0, 0, $newWidth, $newHeight); $resized.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png); $graphics.Dispose(); $resized.Dispose(); } else { $clipboard.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png); }; $bytes = $ms.ToArray(); $ms.Close(); [Convert]::ToBase64String($bytes); }";
570674
570706
  let base64Raw;
570675
570707
  if (isWslEnv) {
@@ -570716,6 +570748,7 @@ end try'`;
570716
570748
  });
570717
570749
  const hasImage = hasImageStdout.trim();
570718
570750
  if (hasImage === "hasImage") {
570751
+ await showImageLoadingIndicator();
570719
570752
  const tmpFile = `/tmp/snow_clipboard_${Date.now()}.png`;
570720
570753
  const saveScript = `osascript -e 'set imgData to the clipboard as \xABclass PNGf\xBB' -e 'set fileRef to open for access POSIX file "${tmpFile}" with write permission' -e 'write imgData to fileRef' -e 'close access fileRef'`;
570721
570754
  await execAsync3(saveScript, {
@@ -570769,11 +570802,14 @@ end try'`;
570769
570802
  try {
570770
570803
  let clipboardText = "";
570771
570804
  if (process.platform === "win32" || isWslEnv) {
570772
- const { stdout } = await execAsync3(`${psCmd} -NoProfile -Command "Get-Clipboard"`, {
570805
+ const textScript = "Add-Type -AssemblyName System.Windows.Forms; $text = [System.Windows.Forms.Clipboard]::GetText(); if ($null -eq $text) { $text = '' }; [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($text))";
570806
+ const encoded = Buffer.from(textScript, "utf16le").toString("base64");
570807
+ const { stdout } = await execAsync3(`${psCmd} -NoProfile -EncodedCommand ${encoded}`, {
570773
570808
  encoding: "utf-8",
570774
- timeout: 2e3
570809
+ timeout: 2e3,
570810
+ maxBuffer: 10 * 1024 * 1024
570775
570811
  });
570776
- clipboardText = stdout.trim();
570812
+ clipboardText = Buffer.from(stdout.replace(/\s/g, ""), "base64").toString("utf8");
570777
570813
  } else if (process.platform === "darwin") {
570778
570814
  const { stdout } = await execAsync3("pbpaste", {
570779
570815
  encoding: "utf-8",
@@ -570787,14 +570823,7 @@ end try'`;
570787
570823
  });
570788
570824
  clipboardText = stdout.trim();
570789
570825
  }
570790
- if (clipboardText) {
570791
- buffer.insert(clipboardText);
570792
- const fullText = buffer.getFullText();
570793
- const cursorPos = buffer.getCursorPosition();
570794
- updateCommandPanelState(fullText);
570795
- updateFilePickerState(fullText, cursorPos);
570796
- triggerUpdate();
570797
- }
570826
+ insertClipboardText(clipboardText);
570798
570827
  } catch (textError) {
570799
570828
  logger.error("Failed to read text from clipboard:", textError);
570800
570829
  }
@@ -610100,7 +610129,7 @@ var require_package3 = __commonJS({
610100
610129
  "package.json"(exports2, module2) {
610101
610130
  module2.exports = {
610102
610131
  name: "snow-ai",
610103
- version: "0.7.30",
610132
+ version: "0.7.31",
610104
610133
  description: "Agentic coding in your terminal",
610105
610134
  license: "MIT",
610106
610135
  bin: {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-ai",
3
- "version": "0.7.30",
3
+ "version": "0.7.31",
4
4
  "description": "Agentic coding in your terminal",
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.7.30",
3
+ "version": "0.7.31",
4
4
  "description": "Agentic coding in your terminal",
5
5
  "license": "MIT",
6
6
  "bin": {