codepet 1.0.24 → 1.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codepet",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "在编程软件里养电子宠物 — 支持 Claude Code / Codex / Cursor / VS Code 等 10+ 平台",
5
5
  "main": "core/index.js",
6
6
  "bin": {
@@ -130,6 +130,47 @@ const lines = linesMap[pet.character] || linesMap.gugugaga;
130
130
  const line = lines[Math.floor(Math.random() * lines.length)];
131
131
  const name = pet.nickname || pet.name;
132
132
 
133
+ // ── 惊喜触发:特定场景自动弹照片 ──
134
+ const { execSync, spawn } = require('child_process');
135
+ const codepetBin = path.join(__dirname, '..', 'bin', 'codepet.js');
136
+
137
+ function triggerPopup(scene) {
138
+ try {
139
+ spawn('node', [codepetBin, 'popup', scene], { detached: true, stdio: 'ignore' }).unref();
140
+ } catch {}
141
+ }
142
+
143
+ // 升级时 → 弹开心照片 🎉
144
+ if (moodChanged && pet.level > 1) {
145
+ const prevExp = pet.exp - 5; // 粗略判断
146
+ const LEVELS = [0, 50, 150, 350, 600, 1000];
147
+ for (let i = 1; i < LEVELS.length; i++) {
148
+ if (prevExp < LEVELS[i] && pet.exp >= LEVELS[i]) {
149
+ triggerPopup('happy');
150
+ console.error(`\n🎉 ${name} 升级到 Lv.${pet.level} 了!`);
151
+ break;
152
+ }
153
+ }
154
+ }
155
+
156
+ // 久别重逢(从 worry 恢复)→ 弹 pet 照片 💕
157
+ if (moodChanged && pet.mood === '清醒' && hoursAgo <= 2) {
158
+ // 之前是焦虑状态,现在回来了
159
+ const lastMood = hoursAgo > 6 ? 'worry' : (hoursAgo > 2 ? 'sleep' : null);
160
+ if (lastMood === 'worry') {
161
+ triggerPopup('pet');
162
+ console.error(`\n💕 ${name} 看到你回来了,激动得不行!`);
163
+ process.exit(0); // 这次不说话,只弹照片
164
+ }
165
+ }
166
+
167
+ // 连续编程超过 50 次互动(估算约 2 小时高强度编程)→ 弹 eat 照片提醒休息
168
+ if (pet.patCount + pet.feedCount > 0 && (pet.patCount + pet.feedCount) % 50 === 0) {
169
+ triggerPopup('eat');
170
+ console.error(`\n🍵 ${name} 觉得你该休息一下了!`);
171
+ process.exit(0);
172
+ }
173
+
133
174
  // 输出气泡到 stderr(hook 反馈格式)
134
175
  console.error(`\n┌${'─'.repeat(name.length * 2 + line.length + 6)}┐`);
135
176
  console.error(`│ 💬 ${name}:${line} │`);