codepet 1.0.11 → 1.0.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.
Files changed (2) hide show
  1. package/bin/codepet.js +16 -9
  2. package/package.json +1 -1
package/bin/codepet.js CHANGED
@@ -482,17 +482,24 @@ function doPopup() {
482
482
  const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
483
483
  const escapedScript = script.replace(/'/g, "'\\''");
484
484
  execSync(`osascript -e 'tell application "Terminal" to do script "export HISTFILE=/dev/null && export BASH_SILENCE_DEPRECATION_WARNING=1 && export PS1=\\\"\\\" && clear && ${PYTHON} \\\"${escapedScript}\\\" ${pet.character} ${scene} 40 2>/dev/null && printf \\\"\\\\033[?25l\\\" && cat > /dev/null"' -e 'tell application "Terminal" to activate' &`, { shell: true, stdio: 'ignore' });
485
+ } else if (process.platform === 'win32') {
486
+ // Windows: 弹新 PowerShell 窗口,自动开启 ANSI 彩色支持
487
+ const script = path.join(__dirname, '..', 'scripts', 'polaroid.py').replace(/\\/g, '/');
488
+ const enableAnsi = `[Console]::OutputEncoding=[Text.Encoding]::UTF8; $Host.UI.RawUI.WindowTitle='📸 Ai小蓝鲸照相馆'; Set-ItemProperty HKCU:\\\\Console VirtualTerminalLevel -Type DWORD -Value 1 -ErrorAction SilentlyContinue;`;
489
+ const psCmd = `${enableAnsi} ${PYTHON} '${script}' ${pet.character} ${scene} 40 2>$null; Read-Host '按回车关闭'`;
490
+ execSync(`start powershell -NoProfile -Command "${psCmd}"`, { shell: true, stdio: 'ignore' });
485
491
  } else {
486
- // Windows / Linux: 生成 PNG 拍立得图片,用系统图片查看器打开
487
- const script = path.join(__dirname, '..', 'scripts', 'polaroid_image.py');
488
- try {
489
- execSync(`${PYTHON} "${script}" ${pet.character} ${scene}`, { encoding: 'utf-8', stdio: 'inherit' });
490
- const photoPath = path.join(os.homedir(), '.codepet', 'photo.png');
491
- if (fs.existsSync(photoPath)) {
492
- const openCmd = process.platform === 'win32' ? 'start ""' : process.platform === 'darwin' ? 'open' : 'xdg-open';
493
- execSync(`${openCmd} "${photoPath}"`, { stdio: 'ignore', shell: true });
492
+ // Linux: 尝试终端弹窗
493
+ const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
494
+ if (process.env.DISPLAY) {
495
+ try {
496
+ execSync(`gnome-terminal -- bash -c '${PYTHON} "${script}" ${pet.character} ${scene} 40; read' 2>/dev/null &`, { shell: true, stdio: 'ignore' });
497
+ } catch {
498
+ try { execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' }); } catch {}
494
499
  }
495
- } catch {}
500
+ } else {
501
+ try { execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' }); } catch {}
502
+ }
496
503
  }
497
504
  }
498
505
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codepet",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "在编程软件里养电子宠物 — 支持 Claude Code / Codex / Cursor / VS Code 等 10+ 平台",
5
5
  "main": "core/index.js",
6
6
  "bin": {