magpie-digital-pet 0.0.0-stage → 0.6.1

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 (48) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +39 -0
  3. package/README.md +285 -2
  4. package/README.md.bak-20261102-054110 +272 -0
  5. package/cli/pet-cli.mjs +215 -0
  6. package/index.mjs +107 -0
  7. package/lib/digimon-attributes.json +652 -0
  8. package/lib/monster-frames.json +1 -0
  9. package/lib/pet.adapter.mjs +614 -0
  10. package/lib/pet.adapter.mjs.bak-20261102-054110 +441 -0
  11. package/lib/pet.care-rules.mjs +406 -0
  12. package/lib/pet.care-store.mjs +864 -0
  13. package/lib/pet.care-store.mjs.bak-20261102-054110 +663 -0
  14. package/lib/pet.frames.mjs +61 -0
  15. package/lib/pet.middleware.mjs +13 -0
  16. package/lib/pet.server.mjs +1683 -0
  17. package/lib/pet.server.mjs.bak-20261102-054110 +1093 -0
  18. package/lib/pet.watcher.mjs +202 -0
  19. package/lib/sprite-map.json +640 -0
  20. package/package.json +73 -4
  21. package/page/app.css +3030 -0
  22. package/page/app.css.bak-20261102-054110 +739 -0
  23. package/page/app.html +332 -0
  24. package/page/app.html.bak-20261102-054110 +272 -0
  25. package/page/app.js +4387 -0
  26. package/page/app.js.bak-20261102-054110 +1451 -0
  27. package/page/backgrounds/castle.webp +0 -0
  28. package/page/backgrounds/coast.webp +0 -0
  29. package/page/backgrounds/factory.webp +0 -0
  30. package/page/backgrounds/forest.webp +0 -0
  31. package/page/backgrounds/gear.webp +0 -0
  32. package/page/backgrounds/meadow.webp +0 -0
  33. package/page/backgrounds/night.webp +0 -0
  34. package/page/backgrounds/ocean.webp +0 -0
  35. package/page/backgrounds/sakura.webp +0 -0
  36. package/page/backgrounds/snow.webp +0 -0
  37. package/page/backgrounds/sunset.webp +0 -0
  38. package/page/backgrounds/terminal.webp +0 -0
  39. package/page/backgrounds/tunnel.webp +0 -0
  40. package/page/backgrounds/village.webp +0 -0
  41. package/page/backgrounds/void.webp +0 -0
  42. package/page/boot.js +56 -0
  43. package/page/cover.png +0 -0
  44. package/page/icon.svg +6 -0
  45. package/page/index.html +24 -0
  46. package/ui/panel.html +99 -0
  47. package/ui/panel.html.bak-20261108-inline-csp +149 -0
  48. package/ui/panel.js +49 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or Object
36
+ form, made available under the License, as indicated by a copyright
37
+ notice that is included in or attached to the work (an example is
38
+ provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Sergio Bugallo Enjamio
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,39 @@
1
+ NOTICE for magpie-digital-pet
2
+ =============================================
3
+
4
+ This package is a magpie page/plugin adapter. It does not bundle the upstream
5
+ engine itself; the engine is an external npm dependency:
6
+ @jcendal/opencode-digital-pet 0.18.0 (Apache License 2.0), by Jorge Cendal
7
+ (jcendal) and Sergio Bugallo (sbugallo). At runtime that package is installed
8
+ by the package manager; it is not vendored into this repository.
9
+
10
+ The sidebar page's pixel sprite frames (lib/monster-frames.json) are extracted
11
+ from that same Apache-2.0 upstream package's TUI bundle
12
+ (MONSTER_FRAME_DATA, jcendal/digital-pet 0.18.0) by tools/extract-frames.mjs,
13
+ and are redistributed here under the same Apache License 2.0. Sprites without
14
+ a catalog entry fall back to a deterministic procedural pixel blob.
15
+
16
+ The sidebar page additionally renders PNG sprite frames for 648 of the 650
17
+ catalog species (sprites/ directory, distributed with this repository)
18
+ sourced from sundeth/omnipet
19
+ (https://github.com/sundeth/omnipet): 497 species from its hi-def set
20
+ (monsters_hidef, 54x48 frames) and 151 from its base dot set (monsters,
21
+ 48x48 frames, used where omnipet ships no hi-def art). Kinds absent from
22
+ both sets (Moonmon, Sunmon) still fall back to the engine's text frames.
23
+ Licensed under Creative Commons Attribution-NonCommercial 4.0 International
24
+ (CC BY-NC 4.0),
25
+ © Anderson Porto 2025. The omnipet sprites are in turn derived from
26
+ Tortoiseshel's Full Color Digimon Dot Sprites
27
+ (https://withthewill.net/threads/22970-Full-Color-Digimon-Dot-Sprites).
28
+ Frame semantics (idle/walk/attack/happy/eat/sleep/injured) are decoded from
29
+ the omnipet sprite atlas convention. Species without a PNG mapping continue
30
+ to use the Apache-2.0 text frames or the procedural fallback.
31
+
32
+ The plugin's icon (magpie.icon in package.json, and page/cover.png) is a
33
+ derived crop of the official Agumon profile art published on digimon.net
34
+ (https://digimon.net/cimages/digimon/agumon.jpg), composed onto a gradient
35
+ background. Digimon and all associated characters are trademarks of Bandai
36
+ and Toei Animation; the art is not covered by this package's Apache-2.0
37
+ license and is included only as a small identifying icon.
38
+
39
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
package/README.md CHANGED
@@ -1,3 +1,286 @@
1
- # Temporary Holding Version
1
+ # magpie-digital-pet
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **非官方插件**:本插件由个人独立维护,与任何官方社区组织及其维护者无隶属、合作或背书关系,也未使用其 npm scope。
4
+
5
+ **让每一行 AI 对话,都在侧边栏养大一只会进化、会串门的 16-bit 数码兽。** —— 跑在 [magpie](https://github.com/yetone/magpie) 网关上的桌面电子宠物插件,带温暖复古羊皮纸侧边栏页面。
6
+
7
+ > 零额外 token 消耗 | 650 只高清像素图鉴 | 15 套 2.5D 动态栖息地(支持全屏互动与多宠客串)| 多叉进化树与闲置蛋召回 | 具名状态奖惩与 16-bit 动作特效
8
+
9
+ 统计**所有 magpie 记账的请求**(Claude Code、Codex、Pi、OpenCode、Gemini CLI……不管哪个 agent、是否流式),把 token 喂给当前出战宠物。失败请求不喂。
10
+
11
+ 引擎来自外部依赖 [@jcendal/opencode-digital-pet](https://github.com/jcendal/digital-pet) 0.18.0(Apache-2.0,见 NOTICE),本仓库不 vendored 上游代码、不打包图鉴数据。
12
+
13
+ **精灵图**:650 只图鉴里有 648 只使用 [sundeth/omnipet](https://github.com/sundeth/omnipet) 的 PNG 精灵帧(CC BY-NC 4.0,© Anderson Porto 2025,见 NOTICE)——497 只取它的高清帧(`monsters_hidef`,54×48),151 只上游只有点阵帧(`monsters`,48×48),一并移植以免再出现文字帧方块;Moonmon、Sunmon 上游两套都没有,只剩文字帧兜底。帧数据经 [@jcendal/digital-pet](https://github.com/jcendal/digital-pet) 间接参考了 [Tortoiseshel's Full Color Digimon Dot Sprites](https://withthewill.net/threads/22970-Full-Color-Digimon-Dot-Sprites)。精灵帧文件随仓库分发(`sprites/` 目录,约 43MB);仅可用于非商业用途,完整授权与署名见 NOTICE。
14
+
15
+ > **高清图失踪案(已破案)**:作者花了大力气把宠物捯饬成 16-bit 高清小可爱,却发现整个面板最养眼的核心素材一直在本地独自美丽——`.gitignore` 把 `sprites/` 拦得严严实实,9008 张 PNG 一张都没上车。于是 GitHub 用户喜提「复古马赛克限定版」,作者本人发现后也只能震惊、无奈并捂脸:合着最高清的部分,恰恰是最没上传成功的部分。现已全部补票入库;这次真的让高清宠物出门见人了。
16
+
17
+ **鼠标交互**(画布上):抚摸(按住来回划 → 心形粒子 + 亲密)、点击(跳跃)、悬停(注视微光 + 开心帧)、拖拽(拎起来晃 → 开心帧)、双击(转圈 → 走路帧)、快速划过(眩晕星星)。交互时 PNG 帧实时切换表情。
18
+
19
+ ## 界面
20
+
21
+ - **侧边栏页面**:magpie 窗口左侧导航里的「宠物」页 —— 首屏是宠物栖息地:像素宠物随状态活动,下方是五项状态条(饱食/心情/精力/清洁/亲密)与进化进度条。可以给当前搭档**起名**;标题栏右侧有快速「**出战**」和「**立即刷新**」两个按钮。整页玩法入口:**日常照顾**、三档**探险**、**每日目标**、**装饰收藏**、**图鉴与切换**、**进化树(含闲置蛋召回)**。
22
+ - **设置面板**:magpie → Settings → Plugins → Digital Pet(开关、缓存 token、补录、轮询间隔)
23
+ - **养成难度齿轮**(宠物页右上角):二级菜单六档(极速 ×0.1 / 简单 ×0.2 / 正常 ×0.5 / 普通 ×1 / 困难 ×2 / 漫长 ×5)。齿轮里的「**更多…**」是三级菜单,两项都带确认门槛:**作弊**(×0.01,填充速度是「极速」的 10 倍,点两下才切)和**全宠物获取**(整图鉴 650 只入背包 —— 点一下先问「是否选择获取全部宠物」,再点一下弹出「此举动不可逆」的确认框,框里的确认键要等 5 秒倒计时走完才按得下去)。难度只缩放喂进引擎的经验槽,统计里的 token 始终是真实用量。
24
+ - **CLI**:见下
25
+
26
+ ### 图鉴的四个筛选
27
+
28
+ | 筛选项 | 内容 |
29
+ |---|---|
30
+ | 只看背包 | 你现在持有的形态(每只伙伴一条;手上的蛋也算一件,显示为 `????`) |
31
+ | 查看已解锁 | 所有能点开看的形态:背包里持有的 + 进化史里走过的旧形态(旧形态标「曾持有 · 可展示」,能切出来看,不占背包) |
32
+ | 全部图鉴 | 650 只全列 |
33
+ | 只看未拥有 | 从没养过的,不给按钮 |
34
+
35
+ - 图鉴按**物种**合并:同一物种你持有多只(比如两颗蛋)只占一条,标题后挂 `×N`。
36
+ - 筛选右边有实时计数:`当前 N 张 · 可展示 M / 共 650 · 持有 K 只`。
37
+ - 背包只认**在役那只**和历代伙伴的当前形态;「显示这只」不会把别的物种算进背包。
38
+
39
+ ## 工作方式
40
+
41
+ ```
42
+ magpie 网关 ──记账──> /v1/magpie/usage/requests
43
+ │ 每 20s 轮询(route_id 幂等去重)
44
+ ▼
45
+ 本插件(magpie 的 Bun 宿主进程内)
46
+ │ 合成 message.updated 事件
47
+ ▼
48
+ digital-pet 引擎(原版)──> 用户目录存档(Windows: %APPDATA%\magpie-digital-pet\pet.db)
49
+ ▲
50
+ 侧边栏页面 <── 本地服务 127.0.0.1:3571(读同一库)
51
+ ```
52
+
53
+ 不走中间件(magpie 的中间件沙箱无 IO、没有定时器,读不了库也起不了服务),不解析响应体(magpie 已经替你把每个请求的 token 数好了,流式也准)。多个宿主进程同时跑 watcher 也安全:引擎按 route_id 去重,SQLite 走 WAL;页面服务固定端口,谁先绑谁服务,端口被短命宿主占着时后来者定期重试接管。
54
+
55
+ 页面右上角的 `↻` 会立刻触发一轮拉取(带并发保护,不会和定时那轮叠),不用等下一个 20 秒。
56
+
57
+ ## 插件行上的标签:为什么会看到「供应商」
58
+
59
+ 插件行上的标签是 magpie 自己算的,不是插件声明的。规则是:能确定它是中间件、请求 hook、Agent、工具或纯页面时挂对应标签;都不是时兜底挂「供应商」(前端就是 `|| "pv"`)。
60
+
61
+ 本插件有一个 `main` 入口(watcher 和 3571 的页面服务都靠它启动),magpie 的几个判定因此都不成立:
62
+
63
+ ```go
64
+ middlewareOnly = 有 magpie.middleware && 没有 main
65
+ gatewayOnly = 有 magpie.hooks && 没有 main
66
+ inMagpieOnly = 有 agent && 没有 main
67
+ ```
68
+
69
+ 三个都为假,兜底就落到「供应商」。**这不代表本插件注册了供应商**:
70
+
71
+ - `plugin list --json` 里它没有 `provides`;
72
+ - `plugin-providers.json` 里搜不到它;
73
+ - 模型列表里没有它,它不参与路由、不参与计费、看不到任何请求体。
74
+
75
+ 同一个兜底也发生在别处:magpie 自带的 Chat 页面(`page-chat`)同样有 `main`,它的行上也是「页面 · 供应商」。
76
+
77
+ 曾经声明过一个空的 `magpie.middleware` 来换「中间件」标签 —— 那个中间件什么都不做,等于假标签,已撤掉。要真挂「中间件」就得让代码跑进网关沙箱,而它没有 IO 和定时器,这个插件在那儿起不来。
78
+
79
+ 要去掉这个标签只有两条路:删掉 `main`(watcher 和页面服务就都起不来了,插件等于停摆),或者改 magpie 那条兜底规则。两条都不做,所以它一直在 —— 它只是个灰标签,不干活。
80
+
81
+ ## 玩法数值
82
+
83
+ ### 成长与阶段阈值
84
+
85
+ 阈值读的是引擎自己的 `opencode-digital-pet.json` 里的 `stageThresholds`(页面和 CLI 读同一份,**只读不写**)。没配就走引擎默认值。本机当前的值:
86
+
87
+ | 阶段 | 槽位(token) | 引擎默认 |
88
+ |---|---|---|
89
+ | egg | 5,000,000 | 5,000,000 |
90
+ | baby I | 5,000,000 | 10,000,000 |
91
+ | baby II | 10,000,000 | 20,000,000 |
92
+ | child | 20,000,000 | 40,000,000 |
93
+ | adult | 37,500,000 | 75,000,000 |
94
+ | perfect | 62,500,000 | 125,000,000 |
95
+ | ultimate | 100,000,000 | 200,000,000 |
96
+ | super ultimate | 150,000,000 | 300,000,000 |
97
+
98
+ - 到阈值那一瞬间,引擎把 `gauge` 截到阈值并开一场进化对决;**超出的部分会被截掉**。
99
+ - 待战期间新到的用量照记账,但**不进成长槽**,赢下对决才恢复。
100
+ - 蛋(stage 0)到阈值直接变成 baby I,**不经过对决、必定成功**。
101
+
102
+ ### 蛋与孵化
103
+
104
+ - 管理里「**获取新的蛋**」→ 再点一次确认 → 当前伙伴退役,拿到一颗未知的蛋。
105
+ - **唯一的门槛是「孵蛋条件计数器」**:把手上所有 baby II 及以上伙伴的阶段数字加起来(baby II 记 2、child 记 3、adult 记 4……),和上次领蛋时记下的快照比较,**变大了才给一颗**。
106
+ - 计数器只在伙伴**真的进化**(打赢相克试炼)时变大;把退役的成年伙伴反复设为出战不会刷新。
107
+ - 领完立刻快照,所以同一次进化只换一颗蛋,两次进化叠在一起也只算一颗(资格不累积)。
108
+ - 举例:1 只 baby II + 1 只 child → 2 + 3 = 5;只有把某只再往上推一级,才会变成可领状态。
109
+ - 还没有任何伙伴时(全新安装)直接给第一颗。
110
+ - 蛋在页面上是未知状态:名字、编号、阶段全是 `????`(图鉴里固定显示 `编号 0-0000 · stage 0 · 蛋`)。
111
+ - 蛋喂到 **500 万 token** 孵成 baby I。孵化时若引擎随机挑中的 baby 你**已经养过**,会换成第一只没养过的;整池都养过则保留随机结果。
112
+ - 可以在背包里同时持有多颗蛋;它们共用一个图鉴条目,标题挂 `×N`。
113
+ - **闲置蛋召回(进化树内操作)**:背包里多出来的未出战蛋(`0-001`)可以按目标阶段消耗 `stage` 颗闲置蛋(Baby I = 1 … Super Ultimate = 7),把**曾经持有过**的任意形态重新召回进背包(不顶替当前出战伙伴,正在孵化的出战蛋受保护不会被消耗)。召回 `stage ≥ 2` 的形态会同步抬高孵蛋计数快照,防止白嫖新蛋。
114
+
115
+ ### 进化树
116
+
117
+ - 右侧档案栏「**进化树**」标签页以当前选中数码兽为焦点,上下三段展示「可由谁进化而来 → 当前聚焦形态 → 可进化为哪些分支」,未解锁形态显示剪影,点击任意分支即可顺着 650 只数码兽的进化网络继续漫游,也支持从「图鉴与切换」卡片一键直达。
118
+
119
+ ### 相克试炼(进化对决)
120
+
121
+ | 属性 | 克制 |
122
+ |---|---|
123
+ | 疫苗 Vaccine | 病毒 Virus |
124
+ | 病毒 Virus | 数据 Data |
125
+ | 数据 Data | 疫苗 Vaccine |
126
+
127
+ - 到阈值时亮出对手属性,在三种属性里选一个:克制对手即进化。
128
+ - 选错:本阶段进度**退回 50%**,并记一次连败;**下一场必胜**。
129
+ - 属性数据取自 digimon.net 官方图鉴,`lib/digimon-attributes.json`(650 条;没有三角属性的按「无属性」处理,任选皆胜)。
130
+
131
+ ### 出战锁定
132
+
133
+ - 管理里「**设为出战**」=把正在看的那只设成吃经验的伙伴;标题栏右侧也有快捷按钮。
134
+ - 引擎只喂 `partner_team.principal` 且未退役的那只,所以换出战会把目标解除退役、原来那只退役。
135
+ - 「**恢复默认出战**」=清掉锁定,回到 generation 最小(第一只)伙伴出战。
136
+ - 图鉴的「显示这只」只换立绘和名字,**不改出战伙伴**;面板的 gen / 经验槽跟着展示的那只走。
137
+
138
+ ### 日常照顾
139
+
140
+ | 操作 | 冷却 | 效果 |
141
+ |---|---|---|
142
+ | 点心 snack | 连续 4 次后 10 分钟 | 饱食 +10、心情 +2 |
143
+ | 玩耍 play | 连续 3 次后 8 分钟 | 心情 +12、亲密 +2、精力 −10(需要精力 ≥ 20) |
144
+ | 清洁 clean | 10 分钟 | 清洁直接回 100;清洁度低于 50 时额外 +1 亲密 |
145
+ | 休息 rest | 15 分钟 | 精力 +25、饱食 −2 |
146
+ | 摸蛋 petEgg | 5 分钟 | 亲密 +2(仅蛋阶段可用) |
147
+ | 抚摸 pet | 3 分钟 | 亲密 +2、心情 +1(画布上按住来回划) |
148
+
149
+ 日常照顾标题右上角的「**重置次数**」消耗 **2 个数据碎片**,清空点心和玩耍的已用次数与冷却;其他照顾动作的冷却不受影响。按钮需要点两次:第一次只进入待确认状态,第二次才扣碎片。
150
+
151
+ 自然衰减(每小时):饱食 −2、心情 −1.5、清洁 −1,**精力 +3**;亲密不衰减。离线按真实时间结算,最多累计 24 小时。
152
+
153
+ ### 探险
154
+
155
+ | 档位 | 时长 | 数据碎片 | 亲密 | 消耗精力 |
156
+ |---|---|---|---|---|
157
+ | 短巡逻 patrol | 5 分钟 | **4** | **+3** | 10(需要精力 ≥ 15) |
158
+ | 数据原野 field | 15 分钟 | **10** | **+4** | 10(同上) |
159
+ | 深夜远征 night | 30 分钟 | **18** | **+5** | 10(同上) |
160
+
161
+ 一次只能进行一场探险;结算时随机附一句见闻,并计入「探险 1 次」的每日目标。
162
+
163
+ ### 每日目标(每天各能领一次)
164
+
165
+ | 目标 | 条件 | 奖励 |
166
+ |---|---|---|
167
+ | 照顾 | 当天照顾 2 次 | **4 碎片** |
168
+ | 探险 | 当天完成 1 次探险 | **6 碎片** |
169
+ | 投喂 | 当天自动吃掉 10 个请求 | **4 碎片** |
170
+
171
+ ### 数据碎片
172
+
173
+ - **每天最多赚 240 片**(探险 + 每日目标合计),北京时间 0 点按本地日期重置;花掉的碎片不占额度。
174
+ - 到顶后再结算探险,实发 0,提示里会写「今日碎片已达上限」。
175
+ - 页面「收藏与装饰」里显示 `数据碎片:N(今日 X / 240)`。
176
+
177
+ ### 装饰背景(十五套)
178
+
179
+ 名字是地名式的,不带「背景」后缀;`sunset` 这个 id 沿用历史数据,画面是遗迹。
180
+
181
+ | 背景 | 价格(碎片) |
182
+ |---|---|
183
+ | 阳光村落 village | 0(开局自带并装备) |
184
+ | 初始原野 meadow | 20 |
185
+ | 月见之丘 night | 50 |
186
+ | 齿轮草原 gear | 75 |
187
+ | 数据神殿 terminal | 80 |
188
+ | 网络之海 ocean | 120 |
189
+ | 黄昏海岸 coast | 140 |
190
+ | 失落遗迹 sunset | 160 |
191
+ | 永冬雪原 snow | 240 |
192
+ | 幽暗密林 forest | 280 |
193
+ | 悬浮隧道 tunnel | 300 |
194
+ | 樱之神社 sakura | 320 |
195
+ | 废弃工厂 factory | 360 |
196
+ | 星海尽头 void | 400 |
197
+ | 丑皇暗堡 castle | 520 |
198
+
199
+ 买入即永久解锁,换装免费;背景图在 `page/backgrounds/*.webp`。
200
+
201
+ ### 成就
202
+
203
+ `first-care`(第一次照顾)、`first-clean`(第一次清洁)、`first-expedition`(第一次探险)、`care-10`(累计照顾 10 次)、`fragments-100`(碎片达到 100)、`first-evolution`(第一次进化)。
204
+
205
+ ## 安装
206
+
207
+ ```sh
208
+ magpie plugin add C:\Users\<你>\.config\magpie\plugins\magpie-digital-pet
209
+ ```
210
+
211
+ 装好即开始记账喂食,侧边栏「宠物」页即开即用。命令行等效操作:
212
+
213
+ ```sh
214
+ cd %USERPROFILE%\.config\magpie\plugins\magpie-digital-pet
215
+ bun cli\pet-cli.mjs status # 当前进度、进化百分比(与侧边栏页同源),另附只读养成摘要:
216
+ # care / bond / fragments / expedition
217
+ bun cli\pet-cli.mjs spawn # 获取新的蛋(当前伙伴会退役)
218
+ bun cli\pet-cli.mjs events # 最近事件
219
+ bun cli\pet-cli.mjs partners # 养过的每一代
220
+ bun cli\pet-cli.mjs freeze # 暂停生长(用量照记,宠物不长)
221
+ bun cli\pet-cli.mjs unfreeze
222
+ bun cli\pet-cli.mjs set 4-001 # 开发者 cheat:把展示钉在某只上(此时不生长)
223
+ ```
224
+
225
+ CLI 只提供只读摘要;日常照顾、探险和装饰装备等写操作请用侧边栏「宠物」页。
226
+
227
+ ## 配置
228
+
229
+ | 选项 | 默认 | 说明 |
230
+ |---|---|---|
231
+ | `enabled` | `true` | 总开关 |
232
+ | `notifications` | `true` | 进化/孵化提示写进 magpie 插件日志 |
233
+ | `includeCacheTokens` | `false` | cache 命中是否计入。默认不计 |
234
+ | `backfill` | `false` | 补录 magpie 已记的 30 天用量(蛋立刻孵化)。改后需重载插件 |
235
+ | `pollSeconds` | `20` | 轮询间隔(15–3600s)。改后需重载插件 |
236
+ | `gatewayUrl` | `http://127.0.0.1:3425` | 网关地址 |
237
+ | `dbPath` | `%APPDATA%\magpie-digital-pet\pet.db`(Windows) | 个人存档路径;默认与插件代码目录分离,更新插件不会动存档。可显式覆盖 |
238
+ | `port` | `3571` | 侧边栏页面服务的本地端口 |
239
+
240
+ ## 数据
241
+
242
+ - 数据库:Windows 默认 `%APPDATA%\magpie-digital-pet\pet.db`(SQLite,WAL,与 CLI / 页面并发安全);其他平台为 `~/.config/magpie-digital-pet/pet.db`。首次启动会自动从旧版 `<插件目录>\data\pet.db` 迁移,旧文件保留作备份,不删除。
243
+ - 养成层新增表都以 `magpie_pet_` 前缀:`care_state` / `care_events` / `expeditions` / `inventory` / `daily` / `fragment_daily`(每日碎片收入)/ `achievements` / `names` / `battle_retries` / `pin`(出战锁定)/ `display_state`(展示覆盖)/ `dev_mode`。
244
+ - 轮询游标:存档同目录 `watcher-state.json`(删掉它 + 开 `backfill` 可重算历史)。
245
+ - 引擎自己的表(`partners` / `partner_events` / `usage_receipts` / `vpet_*`)语义不改。
246
+
247
+ ## 红线(与策划书一致)
248
+
249
+ - 不注入任何 agent 的上下文:不注册 hooks/MCP/skills,不写 agent 配置
250
+ - 不消耗 token:引擎零 LLM 调用,全部本地规则
251
+ - 不改请求:只读 magpie 的用量账本;只读引擎的 `opencode-digital-pet.json`(阈值显示),不写
252
+ - 侧边栏页面只绑 127.0.0.1,只服务 magpie 窗口跳来的页面
253
+ - fail-open:本插件任何异常都不影响网关
254
+
255
+ ## 测试
256
+
257
+ ```sh
258
+ bun tests/pet-frames.test.mjs # 像素帧提取与加载
259
+ bun tests/pet-care-rules.test.mjs # 照顾状态与主动操作规则
260
+ bun tests/pet-progression-rules.test.mjs # 探险、每日目标与成就规则
261
+ bun tests/pet-care-store.test.mjs # 养成 SQLite 存储(含每日碎片上限)
262
+ bun tests/pet-control-state.test.mjs # 控制状态自愈
263
+ bun tests/pet-hatch-pool.test.mjs # 蛋阶段与孵化池
264
+ bun tests/pet-server-care.test.mjs # 页面 API 与安全
265
+ bun tests/page-contract.test.mjs # 页面结构契约
266
+ bun tests/docs-contract.test.mjs # 文档与 CLI 摘要契约
267
+ bun tests/e2e-page.test.mjs # 真实存档副本端到端;浏览器段见下
268
+ bun tests/selftest.mjs # 26 项离线自检(假网关 + 临时库 + 页面服务 + 端口接管)
269
+ ```
270
+
271
+ 端到端测试的核心段始终运行;真实浏览器段只有显式提供本机 Playwright Core 与浏览器路径时才运行,并在临时目录保存截图:
272
+
273
+ ```sh
274
+ PET_E2E_PLAYWRIGHT="<playwright-core/index.mjs 绝对路径>" \
275
+ PET_E2E_EDGE="<msedge.exe 绝对路径>" \
276
+ PET_E2E_ARTIFACT_DIR="<截图输出目录>" \
277
+ bun tests/e2e-page.test.mjs
278
+ ```
279
+
280
+ ## 卸载
281
+
282
+ ```sh
283
+ magpie plugin rm magpie-digital-pet
284
+ ```
285
+
286
+ 个人数据留在用户目录(Windows 为 `%APPDATA%\magpie-digital-pet\`),与插件代码目录分开;想全删手动删除该目录即可。旧版插件目录下的 `data\` 只保留迁移前备份。