codepet 1.0.13 → 1.0.15

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/bin/codepet.js CHANGED
@@ -486,7 +486,7 @@ function doPopup() {
486
486
  // Windows: 弹新 PowerShell 窗口,自动开启 ANSI 彩色支持
487
487
  const script = path.join(__dirname, '..', 'scripts', 'polaroid.py').replace(/\\/g, '/');
488
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 '按回车关闭'`;
489
+ const psCmd = `${enableAnsi} ${PYTHON} '${script}' ${pet.character} ${scene} 40 2>$null; Read-Host`;
490
490
  execSync(`start powershell -NoProfile -Command "${psCmd}"`, { shell: true, stdio: 'ignore' });
491
491
  } else {
492
492
  // Linux: 尝试终端弹窗
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codepet",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "在编程软件里养电子宠物 — 支持 Claude Code / Codex / Cursor / VS Code 等 10+ 平台",
5
5
  "main": "core/index.js",
6
6
  "bin": {
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env python3
2
2
  """
3
3
  将图片转为终端像素画(半块字符 ▀▄█ + RGB 真彩色)
4
+
5
+ Windows ANSI 支持自动开启。
4
6
  用法:
5
7
  python3 img2terminal.py <图片路径> [宽度] [--no-bg]
6
8
  python3 img2terminal.py crop <图片路径> <x> <y> <w> <h> [终端宽度]
@@ -9,6 +11,15 @@
9
11
  import sys
10
12
  from PIL import Image
11
13
 
14
+ # Windows: 强制开启 ANSI 彩色支持
15
+ if sys.platform == 'win32':
16
+ try:
17
+ import ctypes
18
+ kernel32 = ctypes.windll.kernel32
19
+ kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
20
+ except:
21
+ pass
22
+
12
23
  UPPER_HALF = "▀"
13
24
  LOWER_HALF = "▄"
14
25
  FULL_BLOCK = "█"
@@ -3,6 +3,16 @@
3
3
 
4
4
  import sys, os, json, time, re, wcwidth
5
5
 
6
+ # Windows: 强制开启 ANSI 彩色支持
7
+ if sys.platform == 'win32':
8
+ try:
9
+ import ctypes
10
+ kernel32 = ctypes.windll.kernel32
11
+ # ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING
12
+ kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
13
+ except:
14
+ pass
15
+
6
16
  SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
7
17
  sys.path.insert(0, SCRIPT_DIR)
8
18
  from img2terminal import render_image