codepet 1.0.11 → 1.0.12

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 +15 -9
  2. package/package.json +1 -1
package/bin/codepet.js CHANGED
@@ -482,17 +482,23 @@ 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 窗口显示彩色像素画拍立得
487
+ const script = path.join(__dirname, '..', 'scripts', 'polaroid.py').replace(/\\/g, '\\\\');
488
+ const psCmd = `${PYTHON} \\"${script}\\" ${pet.character} ${scene} 40 2>$null; Read-Host`;
489
+ execSync(`start powershell -NoProfile -Command "${psCmd}"`, { shell: true, stdio: 'ignore' });
485
490
  } 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 });
491
+ // Linux: 尝试终端弹窗
492
+ const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
493
+ if (process.env.DISPLAY) {
494
+ try {
495
+ execSync(`gnome-terminal -- bash -c '${PYTHON} "${script}" ${pet.character} ${scene} 40; read' 2>/dev/null &`, { shell: true, stdio: 'ignore' });
496
+ } catch {
497
+ try { execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' }); } catch {}
494
498
  }
495
- } catch {}
499
+ } else {
500
+ try { execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' }); } catch {}
501
+ }
496
502
  }
497
503
  }
498
504
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codepet",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "在编程软件里养电子宠物 — 支持 Claude Code / Codex / Cursor / VS Code 等 10+ 平台",
5
5
  "main": "core/index.js",
6
6
  "bin": {