codepet 1.0.6 → 1.0.8

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 +11 -9
  2. package/package.json +1 -1
package/bin/codepet.js CHANGED
@@ -476,20 +476,22 @@ function doPopup() {
476
476
  if (!pet) { console.log(' 还没有宠物。'); return; }
477
477
  if (!PYTHON) { console.log(' 需要安装 Python。'); return; }
478
478
  const scene = arg || 'normal';
479
- const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
480
479
 
481
- if (process.platform === 'win32') {
482
- // Windows: start cmd 弹新窗口
483
- // /k keeps CMD open so user can see the polaroid; they close it manually
484
- execSync(`start "" cmd /k "${PYTHON} \\"${script}\\" ${pet.character} ${scene} 40 2>nul"`, { shell: true, stdio: 'ignore' });
485
- } else if (process.platform === 'darwin') {
486
- // macOS: 用 osascript 弹 Terminal
480
+ if (process.platform === 'darwin') {
481
+ // macOS: 弹新 Terminal 窗口显示彩色像素风拍立得
482
+ const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
487
483
  const escapedScript = script.replace(/'/g, "'\\''");
488
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' });
489
485
  } else {
490
- // Linux
486
+ // Windows / Linux: 生成 PNG 拍立得图片,用系统图片查看器打开
487
+ const script = path.join(__dirname, '..', 'scripts', 'polaroid_image.py');
491
488
  try {
492
- execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' });
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 });
494
+ }
493
495
  } catch {}
494
496
  }
495
497
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codepet",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "在编程软件里养电子宠物 — 支持 Claude Code / Codex / Cursor / VS Code 等 10+ 平台",
5
5
  "main": "core/index.js",
6
6
  "bin": {