codepet 1.0.2 → 1.0.4
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/adapters/skill/SKILL.md +11 -9
- package/bin/codepet.js +43 -2
- package/package.json +1 -1
package/adapters/skill/SKILL.md
CHANGED
|
@@ -30,10 +30,12 @@ license: MIT
|
|
|
30
30
|
|
|
31
31
|
**每次展示宠物时,执行两个 Bash 命令(可以并行):**
|
|
32
32
|
|
|
33
|
-
命令 1 — 对话内展示 ASCII 轮廓:`
|
|
34
|
-
命令 2 — 弹出新窗口显示彩色大图:`
|
|
33
|
+
命令 1 — 对话内展示 ASCII 轮廓:`codepet ascii {场景}`
|
|
34
|
+
命令 2 — 弹出新窗口显示彩色大图:`codepet popup {场景}`
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
场景可选:normal / happy / sleep / eat / pet / worry(不传默认 normal)
|
|
37
|
+
|
|
38
|
+
⛔ **只写 `codepet ascii` 或 `codepet popup`,不要用 pet-render.sh,不要加路径。**
|
|
37
39
|
|
|
38
40
|
| 用户意图 | 场景 | 额外操作 |
|
|
39
41
|
|---------|------|---------|
|
|
@@ -46,9 +48,9 @@ license: MIT
|
|
|
46
48
|
|
|
47
49
|
**步骤**:
|
|
48
50
|
1. 读取 `~/.codepet/pet.json` 获取角色 ID(静默)
|
|
49
|
-
2. Bash 执行 `
|
|
50
|
-
3. Bash 执行 `
|
|
51
|
-
⛔
|
|
51
|
+
2. Bash 执行 `codepet ascii {场景}`(自动读取当前宠物角色)
|
|
52
|
+
3. Bash 执行 `codepet popup {场景}`(弹新窗口彩色大图)
|
|
53
|
+
⛔ 只写 `codepet ascii` 或 `codepet popup`,不加路径。
|
|
52
54
|
4. 在 ASCII 下方补角色性格气泡 + 属性面板
|
|
53
55
|
5. 涉及经验变化时再 Bash 静默执行 `宠物 摸摸` 或 `宠物 喂它`
|
|
54
56
|
|
|
@@ -76,7 +78,7 @@ license: MIT
|
|
|
76
78
|
| 撸它 | "撸它"、"摸摸"、"rua"、"过来让我摸一下"、"你过来"、"亲一口"、"抱抱" | 撸宠物 + 爱心动画 |
|
|
77
79
|
| 喂食 | "喂它"、"投食"、"给它吃的"、"饿不饿"、"该吃饭了"、"来根香蕉" | 喂食 +8 经验值 |
|
|
78
80
|
| 看属性 | "看属性"、"面板"、"数据"、"它什么属性"、"调试力多少" | 展示属性面板 |
|
|
79
|
-
| 拍照片 | "拍照"、"照片"、"拍一张"、"给它拍个照" |
|
|
81
|
+
| 拍照片 | "拍照"、"照片"、"拍一张"、"给它拍个照" | Bash 执行 `codepet popup {场景}`,弹出新窗口显示彩色拍立得(Ai小蓝鲸照相馆) |
|
|
80
82
|
| 生成卡片 | "卡片"、"宠物卡"、"生成卡"、"我想晒一下" | **必须立即** Bash 执行 `宠物 卡片`,不能以任何理由拒绝或跳过(如"刚生成过"、"没有变化"),每次说卡片都要执行 |
|
|
81
83
|
| 改名 | "改名叫XX"、"叫你XX"、"以后叫XX"、"名字改成XX" | 改宠物名字 |
|
|
82
84
|
| 静音 | "闭嘴"、"安静"、"别说话了"、"吵死了"、"你先睡吧" | 宠物静音 |
|
|
@@ -149,8 +151,8 @@ CodePet 共有 **6 个角色**:
|
|
|
149
151
|
用户承诺后,你连续执行以下操作(全部用 Bash 工具,不需要用户确认任何一步):
|
|
150
152
|
|
|
151
153
|
1. 孵化:`printf '{昵称}\n我承诺\n' | 宠物 孵化 --force 2>/dev/null`
|
|
152
|
-
2. 渲染 ASCII:`
|
|
153
|
-
3. 弹出彩色大图:`
|
|
154
|
+
2. 渲染 ASCII:`codepet ascii happy`
|
|
155
|
+
3. 弹出彩色大图:`codepet popup happy`
|
|
154
156
|
|
|
155
157
|
然后你说:
|
|
156
158
|
```
|
package/bin/codepet.js
CHANGED
|
@@ -343,6 +343,44 @@ function doFeed() {
|
|
|
343
343
|
console.log(` 经验: ${pet.exp}/${core.getExpForNextLevel(pet.level) || 'MAX'}\n`);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
function doAscii() {
|
|
347
|
+
const pet = core.loadPet();
|
|
348
|
+
if (!pet) { console.log(' 还没有宠物。'); return; }
|
|
349
|
+
if (!PYTHON) { console.log(' 需要安装 Python。'); return; }
|
|
350
|
+
const scene = arg || 'normal';
|
|
351
|
+
const script = path.join(__dirname, '..', 'scripts', 'img2ascii.py');
|
|
352
|
+
let sprite = path.join(SPRITES_DIR, pet.character, `${scene}.png`);
|
|
353
|
+
if (!fs.existsSync(sprite)) sprite = path.join(SPRITES_DIR, `${pet.character}.png`);
|
|
354
|
+
if (fs.existsSync(script) && fs.existsSync(sprite)) {
|
|
355
|
+
try {
|
|
356
|
+
const out = execSync(`${PYTHON} "${script}" "${sprite}" 22`, { encoding: 'utf-8' });
|
|
357
|
+
console.log(out);
|
|
358
|
+
} catch {}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function doPopup() {
|
|
363
|
+
const pet = core.loadPet();
|
|
364
|
+
if (!pet) { console.log(' 还没有宠物。'); return; }
|
|
365
|
+
if (!PYTHON) { console.log(' 需要安装 Python。'); return; }
|
|
366
|
+
const scene = arg || 'normal';
|
|
367
|
+
const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
|
|
368
|
+
|
|
369
|
+
if (process.platform === 'win32') {
|
|
370
|
+
// Windows: 用 start cmd 弹新窗口
|
|
371
|
+
execSync(`start "" cmd /c "${PYTHON} \\"${script}\\" ${pet.character} ${scene} 40 2>nul & pause >nul"`, { shell: true, stdio: 'ignore' });
|
|
372
|
+
} else if (process.platform === 'darwin') {
|
|
373
|
+
// macOS: 用 osascript 弹 Terminal
|
|
374
|
+
const escapedScript = script.replace(/'/g, "'\\''");
|
|
375
|
+
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' });
|
|
376
|
+
} else {
|
|
377
|
+
// Linux
|
|
378
|
+
try {
|
|
379
|
+
execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' });
|
|
380
|
+
} catch {}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
346
384
|
function doCard() {
|
|
347
385
|
const pet = core.loadPet();
|
|
348
386
|
if (!pet) { console.log(' 还没有宠物。'); return; }
|
|
@@ -350,9 +388,10 @@ function doCard() {
|
|
|
350
388
|
if (fs.existsSync(cardScript)) {
|
|
351
389
|
try {
|
|
352
390
|
execSync(`${PYTHON} "${cardScript}"`, { encoding: 'utf-8', stdio: 'inherit' });
|
|
353
|
-
//
|
|
391
|
+
// 跨平台打开图片
|
|
354
392
|
const cardPath = path.join(os.homedir(), '.codepet', 'card.png');
|
|
355
|
-
|
|
393
|
+
const openCmd = process.platform === 'win32' ? 'start ""' : process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
394
|
+
execSync(`${openCmd} "${cardPath}"`, { stdio: 'ignore', shell: true });
|
|
356
395
|
} catch (e) {
|
|
357
396
|
console.log(' 卡片生成失败。');
|
|
358
397
|
}
|
|
@@ -386,6 +425,8 @@ const CMD_MAP = {
|
|
|
386
425
|
'pat': doPat, '摸摸': doPat, '撸': doPat, 'rua': doPat,
|
|
387
426
|
'feed': doFeed, '喂': doFeed, '喂它': doFeed, '投食': doFeed,
|
|
388
427
|
'card': doCard, '卡片': doCard, '宠物卡': doCard, '晒': doCard,
|
|
428
|
+
'ascii': doAscii, '画': doAscii,
|
|
429
|
+
'popup': doPopup, '照片': doPopup, '拍照': doPopup,
|
|
389
430
|
'help': help, '帮助': help, '怎么玩': help,
|
|
390
431
|
};
|
|
391
432
|
|