@fivetu53/soul-chat 1.0.2 → 1.0.5

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.
Files changed (2) hide show
  1. package/bin/index.js +29 -7
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import readline from 'readline';
4
4
  import { execSync } from 'child_process';
5
5
  import fs from 'fs';
6
+ import os from 'os';
6
7
  import { Marked } from 'marked';
7
8
  import { markedTerminal } from 'marked-terminal';
8
9
  import { loadConfig, saveConfig, getConfigPath } from './config.js';
@@ -98,7 +99,6 @@ const showCursor = () => process.stdout.write('\x1b[?25h');
98
99
 
99
100
  // 获取剪贴板图片 (跨平台)
100
101
  function getClipboardImage() {
101
- const os = require('os');
102
102
  const tmpDir = os.tmpdir();
103
103
  const tmpFile = process.platform === 'win32'
104
104
  ? `${tmpDir}\\soul_clipboard.png`
@@ -121,8 +121,17 @@ end try`;
121
121
  if (result !== 'ok') return null;
122
122
  } else if (process.platform === 'win32') {
123
123
  // Windows: 用 PowerShell 导出剪贴板图片
124
- const ps = `Add-Type -AssemblyName System.Windows.Forms; $img = [System.Windows.Forms.Clipboard]::GetImage(); if ($img) { $img.Save('${tmpFile.replace(/\\/g, '\\\\')}'); 'ok' } else { 'no' }`;
125
- const result = execSync(`powershell -Command "${ps}"`, { encoding: 'utf8', windowsHide: true }).trim();
124
+ // 使用单引号包裹路径,避免转义问题
125
+ const psScript = `
126
+ Add-Type -AssemblyName System.Windows.Forms
127
+ $img = [System.Windows.Forms.Clipboard]::GetImage()
128
+ if ($img) {
129
+ $img.Save('${tmpFile.replace(/\\/g, '/')}', [System.Drawing.Imaging.ImageFormat]::Png)
130
+ Write-Output 'ok'
131
+ } else {
132
+ Write-Output 'no'
133
+ }`;
134
+ const result = execSync(`powershell -NoProfile -ExecutionPolicy Bypass -Command "${psScript.replace(/"/g, '\\"').replace(/\n/g, ' ')}"`, { encoding: 'utf8', windowsHide: true }).trim();
126
135
  if (result !== 'ok') return null;
127
136
  } else {
128
137
  return null;
@@ -1029,12 +1038,25 @@ async function main() {
1029
1038
  // 处理命令行参数
1030
1039
  const args = process.argv.slice(2);
1031
1040
  if (args[0] === 'update') {
1032
- console.log('\n 正在更新 Soul Chat...\n');
1041
+ const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
1042
+ const currentVersion = pkg.version;
1043
+ console.log(`\n 当前版本: v${currentVersion}`);
1044
+ console.log(' 检查更新中...\n');
1045
+
1033
1046
  try {
1034
- execSync('npm update -g @fivetu53/soul-chat', { stdio: 'inherit' });
1035
- console.log('\n 更新完成!\n');
1047
+ const latestVersion = execSync('npm view @fivetu53/soul-chat version --registry https://registry.npmmirror.com', { encoding: 'utf8' }).trim();
1048
+
1049
+ if (latestVersion === currentVersion) {
1050
+ console.log(' ✓ 已是最新版本\n');
1051
+ process.exit(0);
1052
+ }
1053
+
1054
+ console.log(` 发现新版本: v${latestVersion}`);
1055
+ console.log(' 正在更新...\n');
1056
+ execSync('npm update -g @fivetu53/soul-chat --registry https://registry.npmmirror.com', { stdio: 'inherit' });
1057
+ console.log('\n ✓ 更新完成!\n');
1036
1058
  } catch (err) {
1037
- console.log('\n 更新失败,请手动运行: npm update -g @fivetu53/soul-chat\n');
1059
+ console.log(' 更新失败,请手动运行: npm update -g @fivetu53/soul-chat\n');
1038
1060
  }
1039
1061
  process.exit(0);
1040
1062
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fivetu53/soul-chat",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "Soul Chat - 智能 AI 伴侣命令行客户端",
5
5
  "type": "module",
6
6
  "bin": {