cc-pets 2.2.1 → 2.4.0

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 (197) hide show
  1. package/CC_BRIDGE.md +24 -2
  2. package/CC_BRIDGE.zh-CN.md +19 -2
  3. package/CHANGELOG.md +111 -0
  4. package/CHANGELOG.zh-CN.md +111 -0
  5. package/CONTRIBUTING.md +35 -10
  6. package/CONTRIBUTING.zh-CN.md +28 -10
  7. package/README.md +212 -32
  8. package/README.zh-CN.md +167 -36
  9. package/Resources/AgentIcons/claude.png +0 -0
  10. package/Resources/AgentIcons/codex.icns +0 -0
  11. package/Resources/IDEPlugins/cc-pets-terminal.vsix +0 -0
  12. package/Resources/IDEPlugins/cc-pets-terminal.zip +0 -0
  13. package/Resources/zh-Hans.lproj/Localizable.strings +699 -20
  14. package/Sources/CCPets/{CCPetsAppDelegate+AgentEvents.m → App/CCPetsAppDelegate+AgentEvents.m} +15 -5
  15. package/Sources/CCPets/{CCPetsAppDelegate+AgentStatus.m → App/CCPetsAppDelegate+AgentStatus.m} +90 -25
  16. package/Sources/CCPets/{CCPetsAppDelegate+Bridge.m → App/CCPetsAppDelegate+Bridge.m} +35 -24
  17. package/Sources/CCPets/{CCPetsAppDelegate+Pets.m → App/CCPetsAppDelegate+Pets.m} +17 -3
  18. package/Sources/CCPets/{CCPetsAppDelegate+Private.h → App/CCPetsAppDelegate+Private.h} +71 -23
  19. package/Sources/CCPets/App/CCPetsAppDelegate+Profiles.m +238 -0
  20. package/Sources/CCPets/{CCPetsAppDelegate+Quota.m → App/CCPetsAppDelegate+Quota.m} +47 -32
  21. package/Sources/CCPets/{CCPetsAppDelegate+Settings.m → App/CCPetsAppDelegate+Settings.m} +87 -102
  22. package/Sources/CCPets/{CCPetsAppDelegate+Speech.m → App/CCPetsAppDelegate+Speech.m} +121 -51
  23. package/Sources/CCPets/App/CCPetsAppDelegate+Workbench.m +139 -0
  24. package/Sources/CCPets/{CCPetsAppDelegate.h → App/CCPetsAppDelegate.h} +17 -2
  25. package/Sources/CCPets/{CCPetsAppDelegate.m → App/CCPetsAppDelegate.m} +107 -11
  26. package/Sources/CCPets/App/CCPetsOpenCommand.h +13 -0
  27. package/Sources/CCPets/App/CCPetsOpenCommand.m +99 -0
  28. package/Sources/CCPets/{main.m → App/main.m} +74 -1
  29. package/Sources/CCPets/{CCPetsBridge.h → Bridge/CCPetsBridge.h} +17 -4
  30. package/Sources/CCPets/{CCPetsBridge.m → Bridge/CCPetsBridge.m} +43 -23
  31. package/Sources/CCPets/Bridge/CCPetsBridgeCLI.h +10 -0
  32. package/Sources/CCPets/Bridge/CCPetsBridgeCLI.m +832 -0
  33. package/Sources/CCPets/Bridge/CCPetsBridgeCore.h +59 -0
  34. package/Sources/CCPets/Bridge/CCPetsBridgeCore.m +576 -0
  35. package/Sources/CCPets/Bridge/CCPetsBridgeSetup.h +24 -0
  36. package/Sources/CCPets/Bridge/CCPetsBridgeSetup.m +507 -0
  37. package/Sources/CCPets/Bridge/CCPetsBridgeStore.h +106 -0
  38. package/Sources/CCPets/Bridge/CCPetsBridgeStore.m +897 -0
  39. package/Sources/CCPets/Integrations/CCPetsCLISupport.h +75 -0
  40. package/Sources/CCPets/Integrations/CCPetsCLISupport.m +342 -0
  41. package/Sources/CCPets/Integrations/CCPetsEvents.h +15 -0
  42. package/Sources/CCPets/{CCPetsEvents.m → Integrations/CCPetsEvents.m} +23 -0
  43. package/Sources/CCPets/Integrations/CCPetsIDEIntegration.h +21 -0
  44. package/Sources/CCPets/Integrations/CCPetsIDEIntegration.m +503 -0
  45. package/Sources/CCPets/Integrations/CCPetsIntegrations.h +51 -0
  46. package/Sources/CCPets/Integrations/CCPetsIntegrations.m +662 -0
  47. package/Sources/CCPets/Integrations/CCPetsLaunchPreflight.h +5 -0
  48. package/Sources/CCPets/Integrations/CCPetsLaunchPreflight.m +367 -0
  49. package/Sources/CCPets/Integrations/CCPetsProfiles.h +38 -0
  50. package/Sources/CCPets/Integrations/CCPetsProfiles.m +516 -0
  51. package/Sources/CCPets/{CCPetsTerminalFocus.h → Integrations/CCPetsTerminalFocus.h} +2 -1
  52. package/Sources/CCPets/{CCPetsTerminalFocus.m → Integrations/CCPetsTerminalFocus.m} +148 -36
  53. package/Sources/CCPets/Integrations/CCPetsTerminalIntegration.h +17 -0
  54. package/Sources/CCPets/Integrations/CCPetsTerminalIntegration.m +64 -0
  55. package/Sources/CCPets/Integrations/CCPetsVSCodeIntegration.h +23 -0
  56. package/Sources/CCPets/Integrations/CCPetsVSCodeIntegration.m +475 -0
  57. package/Sources/CCPets/Pet/CCPetsPetStore.h +12 -0
  58. package/Sources/CCPets/Pet/CCPetsPetStore.m +476 -0
  59. package/Sources/CCPets/{CCPetsPhrases.h → Pet/CCPetsPhrases.h} +11 -2
  60. package/Sources/CCPets/{CCPetsPhrases.m → Pet/CCPetsPhrases.m} +19 -2
  61. package/Sources/CCPets/{CCPetsPhrasesEditor.m → Pet/CCPetsPhrasesEditor.m} +4 -1
  62. package/Sources/CCPets/Pet/PetView+Interaction.m +207 -0
  63. package/Sources/CCPets/Pet/PetView+Menu.m +598 -0
  64. package/Sources/CCPets/Pet/PetView+MicroBehavior.m +234 -0
  65. package/Sources/CCPets/Pet/PetView+Private.h +81 -0
  66. package/Sources/CCPets/{PetView.h → Pet/PetView.h} +3 -5
  67. package/Sources/CCPets/Pet/PetView.m +635 -0
  68. package/Sources/CCPets/Support/CCPetsDoctor.h +25 -0
  69. package/Sources/CCPets/Support/CCPetsDoctor.m +646 -0
  70. package/Sources/CCPets/Support/CCPetsJSON.h +27 -0
  71. package/Sources/CCPets/Support/CCPetsJSON.m +397 -0
  72. package/Sources/CCPets/{CCPetsL10n.h → Support/CCPetsL10n.h} +3 -1
  73. package/Sources/CCPets/{CCPetsL10n.m → Support/CCPetsL10n.m} +30 -1
  74. package/Sources/CCPets/Support/CCPetsPreferences.h +33 -0
  75. package/Sources/CCPets/Support/CCPetsPreferences.m +117 -0
  76. package/Sources/CCPets/UI/CCPetsDiagnosticsPage.h +25 -0
  77. package/Sources/CCPets/UI/CCPetsDiagnosticsPage.m +440 -0
  78. package/Sources/CCPets/UI/CCPetsFormBuilder.h +44 -0
  79. package/Sources/CCPets/UI/CCPetsFormBuilder.m +279 -0
  80. package/Sources/CCPets/UI/CCPetsGlassView.h +57 -0
  81. package/Sources/CCPets/{CCPetsGlassView.m → UI/CCPetsGlassView.m} +60 -11
  82. package/Sources/CCPets/UI/CCPetsMainWindow.h +55 -0
  83. package/Sources/CCPets/UI/CCPetsMainWindow.m +730 -0
  84. package/Sources/CCPets/UI/CCPetsSettingsPage.h +64 -0
  85. package/Sources/CCPets/UI/CCPetsSettingsPage.m +1412 -0
  86. package/Sources/CCPets/UI/CCPetsUIStyle.h +135 -0
  87. package/Sources/CCPets/UI/CCPetsUIStyle.m +865 -0
  88. package/Sources/CCPets/UI/CCPetsUsageChartView.h +15 -0
  89. package/Sources/CCPets/UI/CCPetsUsageChartView.m +288 -0
  90. package/Sources/CCPets/UI/CCPetsUsagePage.h +32 -0
  91. package/Sources/CCPets/UI/CCPetsUsagePage.m +712 -0
  92. package/Sources/CCPets/UI/CCPetsUsageShared.h +53 -0
  93. package/Sources/CCPets/UI/CCPetsUsageStore.m +120 -0
  94. package/Sources/CCPets/UI/CCPetsUsageWidgets.h +30 -0
  95. package/Sources/CCPets/UI/CCPetsUsageWidgets.m +201 -0
  96. package/Sources/CCPets/UI/CCPetsWorkbench.h +40 -0
  97. package/Sources/CCPets/UI/CCPetsWorkbenchPages.h +13 -0
  98. package/Sources/CCPets/UI/CCPetsWorkbenchPages.m +783 -0
  99. package/Sources/CCPets/{MenuToggleSwitch.m → UI/MenuToggleSwitch.m} +1 -0
  100. package/Sources/CCPets/{CCPetsCodexRateLimits.h → Usage/CCPetsCodexRateLimits.h} +1 -0
  101. package/Sources/CCPets/{CCPetsCodexRateLimits.m → Usage/CCPetsCodexRateLimits.m} +10 -3
  102. package/Sources/CCPets/{CCPetsQuotaHistory.h → Usage/CCPetsQuotaHistory.h} +3 -0
  103. package/Sources/CCPets/{CCPetsQuotaHistory.m → Usage/CCPetsQuotaHistory.m} +58 -0
  104. package/Sources/CCPets/Usage/CCPetsUsage+ClaudeReader.m +436 -0
  105. package/Sources/CCPets/Usage/CCPetsUsage+CodexBackground.m +193 -0
  106. package/Sources/CCPets/Usage/CCPetsUsage+CodexReader.m +392 -0
  107. package/Sources/CCPets/Usage/CCPetsUsage+CodexSessions.m +484 -0
  108. package/Sources/CCPets/Usage/CCPetsUsage+Internal.h +97 -0
  109. package/Sources/CCPets/Usage/CCPetsUsage+Models.m +323 -0
  110. package/Sources/CCPets/Usage/CCPetsUsage+TokenTotals.m +655 -0
  111. package/Sources/CCPets/Usage/CCPetsUsage.h +58 -0
  112. package/Sources/CCPets/Usage/CCPetsUsage.m +225 -0
  113. package/Sources/CCPets/Usage/CCPetsUsageMode.h +10 -0
  114. package/Sources/CCPets/Usage/CCPetsUsageMode.m +163 -0
  115. package/Sources/CCPets/{CCPetsUsageMonitor.h → Usage/CCPetsUsageMonitor.h} +3 -0
  116. package/Sources/CCPets/{CCPetsUsageMonitor.m → Usage/CCPetsUsageMonitor.m} +174 -19
  117. package/Sources/CCPets/Usage/QuotaDashboardView+Primitives.m +328 -0
  118. package/Sources/CCPets/Usage/QuotaDashboardView+Private.h +103 -0
  119. package/Sources/CCPets/Usage/QuotaDashboardView+Rendering.m +598 -0
  120. package/Sources/CCPets/{QuotaDashboardView.h → Usage/QuotaDashboardView.h} +17 -0
  121. package/Sources/CCPets/Usage/QuotaDashboardView.m +713 -0
  122. package/THIRD_PARTY_NOTICES.md +8 -4
  123. package/THIRD_PARTY_NOTICES.zh-CN.md +6 -2
  124. package/bin/cc-pets +8 -6
  125. package/bin/claude-with-pet +12 -2
  126. package/bin/codex-with-pet +15 -5
  127. package/package.json +5 -1
  128. package/plugins/jetbrains/README.md +62 -0
  129. package/plugins/jetbrains/src/main/java/com/ccpets/terminal/TerminalBridge.java +379 -0
  130. package/plugins/jetbrains/src/main/java/com/ccpets/terminal/TerminalIdentity.java +24 -0
  131. package/plugins/jetbrains/src/main/java/com/ccpets/terminal/TerminalStartup.java +12 -0
  132. package/plugins/jetbrains/src/main/resources/META-INF/plugin.xml +23 -0
  133. package/plugins/jetbrains/src/main/resources/META-INF/pluginIcon.svg +380 -0
  134. package/plugins/vscode/README.md +63 -0
  135. package/plugins/vscode/extension.js +210 -0
  136. package/plugins/vscode/package.json +18 -0
  137. package/scripts/build-idea-plugin.sh +101 -0
  138. package/scripts/build-vscode-extension.sh +112 -0
  139. package/scripts/build.sh +31 -5
  140. package/scripts/compile-cached.zsh +133 -0
  141. package/scripts/i18n.zsh +9 -52
  142. package/scripts/install-app.sh +4 -0
  143. package/scripts/install-shell-integration.sh +17 -10
  144. package/scripts/uninstall-shell-integration.sh +6 -1
  145. package/Sources/CCPets/CCPetsEvents.h +0 -10
  146. package/Sources/CCPets/CCPetsGlassView.h +0 -31
  147. package/Sources/CCPets/CCPetsUsage.h +0 -36
  148. package/Sources/CCPets/CCPetsUsage.m +0 -2069
  149. package/Sources/CCPets/PetView.m +0 -1839
  150. package/Sources/CCPets/QuotaDashboardView.m +0 -1145
  151. package/scripts/bridge/cli.mjs +0 -237
  152. package/scripts/bridge/core.mjs +0 -228
  153. package/scripts/bridge/hook.mjs +0 -150
  154. package/scripts/bridge/install.mjs +0 -311
  155. package/scripts/bridge/mcp-server.mjs +0 -308
  156. package/scripts/bridge/options.mjs +0 -87
  157. package/scripts/bridge/process.mjs +0 -151
  158. package/scripts/bridge/reservations.mjs +0 -248
  159. package/scripts/bridge/store.mjs +0 -433
  160. package/scripts/bridge/watch.mjs +0 -69
  161. package/scripts/check-l10n.mjs +0 -168
  162. package/scripts/configure-updater.mjs +0 -43
  163. package/scripts/detect-cli.mjs +0 -68
  164. package/scripts/doctor.mjs +0 -470
  165. package/scripts/i18n.mjs +0 -122
  166. package/scripts/install-claude-hooks.mjs +0 -253
  167. package/scripts/install-codex-hooks.mjs +0 -78
  168. package/scripts/integration-markers.mjs +0 -51
  169. package/scripts/locales/zh-Hans.json +0 -366
  170. package/scripts/pet-store.mjs +0 -415
  171. package/scripts/uninstall-integrations.mjs +0 -205
  172. /package/Sources/CCPets/{CCPetsAppDelegate+Update.m → App/CCPetsAppDelegate+Update.m} +0 -0
  173. /package/Sources/CCPets/{CCPetsVersion.h → App/CCPetsVersion.h} +0 -0
  174. /package/Sources/CCPets/{CCPetsVersion.m → App/CCPetsVersion.m} +0 -0
  175. /package/Sources/CCPets/{CCPetsImageLoader.h → Pet/CCPetsImageLoader.h} +0 -0
  176. /package/Sources/CCPets/{CCPetsImageLoader.m → Pet/CCPetsImageLoader.m} +0 -0
  177. /package/Sources/CCPets/{CCPetsPetSize.h → Pet/CCPetsPetSize.h} +0 -0
  178. /package/Sources/CCPets/{CCPetsPetSize.m → Pet/CCPetsPetSize.m} +0 -0
  179. /package/Sources/CCPets/{CCPetsPhrasesEditor.h → Pet/CCPetsPhrasesEditor.h} +0 -0
  180. /package/Sources/CCPets/{CCPetsPreviews.h → Pet/CCPetsPreviews.h} +0 -0
  181. /package/Sources/CCPets/{CCPetsPreviews.m → Pet/CCPetsPreviews.m} +0 -0
  182. /package/Sources/CCPets/Resources/{/351/273/230/350/256/244.webp" → ByteMochi.webp} +0 -0
  183. /package/Sources/CCPets/{CCPetsCleanup.h → Support/CCPetsCleanup.h} +0 -0
  184. /package/Sources/CCPets/{CCPetsCleanup.m → Support/CCPetsCleanup.m} +0 -0
  185. /package/Sources/CCPets/{CCPetsPaths.h → Support/CCPetsPaths.h} +0 -0
  186. /package/Sources/CCPets/{CCPetsPaths.m → Support/CCPetsPaths.m} +0 -0
  187. /package/Sources/CCPets/{CCPetsSystemMonitor.h → Support/CCPetsSystemMonitor.h} +0 -0
  188. /package/Sources/CCPets/{CCPetsSystemMonitor.m → Support/CCPetsSystemMonitor.m} +0 -0
  189. /package/Sources/CCPets/{CCPetsGlassMenu.h → UI/CCPetsGlassMenu.h} +0 -0
  190. /package/Sources/CCPets/{CCPetsGlassMenu.m → UI/CCPetsGlassMenu.m} +0 -0
  191. /package/Sources/CCPets/{MenuChoiceRow.h → UI/MenuChoiceRow.h} +0 -0
  192. /package/Sources/CCPets/{MenuChoiceRow.m → UI/MenuChoiceRow.m} +0 -0
  193. /package/Sources/CCPets/{MenuHintView.h → UI/MenuHintView.h} +0 -0
  194. /package/Sources/CCPets/{MenuHintView.m → UI/MenuHintView.m} +0 -0
  195. /package/Sources/CCPets/{MenuPetSizeView.h → UI/MenuPetSizeView.h} +0 -0
  196. /package/Sources/CCPets/{MenuPetSizeView.m → UI/MenuPetSizeView.m} +0 -0
  197. /package/Sources/CCPets/{MenuToggleSwitch.h → UI/MenuToggleSwitch.h} +0 -0
package/CC_BRIDGE.md CHANGED
@@ -59,7 +59,7 @@ Claude picks up changes immediately; Codex needs a session restart (and re-trust
59
59
 
60
60
  Ask in plain language in any session:
61
61
 
62
- > List the other agent sessions on this Mac, then tell codex-my-app-1 that the endpoint is now POST /api/pets.
62
+ > List the other agent sessions on this Mac, then tell codex.my-app.otter that the endpoint is now POST /api/pets.
63
63
 
64
64
  The agent uses these MCP tools:
65
65
 
@@ -75,7 +75,10 @@ The agent uses these MCP tools:
75
75
 
76
76
  ### Session names
77
77
 
78
- Default names look like `<claude|codex>-<project-directory>-<n>`, for example `claude-my-app-1`.
78
+ Default names look like `<account>.<project-directory>.<animal>`, for example `claude.my-app.otter` or
79
+ `claude-x.my-app.panda`. The account part is the name shown on the Multi-Account page (`claude` / `codex` for the
80
+ default accounts), and the animal comes from a list of 100, so online sessions of the same account and project never
81
+ share a name. Names stay within 40 characters; long project directory names are truncated.
79
82
  When several terminals share a directory, give them memorable names:
80
83
 
81
84
  ```bash
@@ -242,3 +245,22 @@ tool through `~/.cc-pets/bridge-cli.json`, written on every `cc-pets install`; i
242
245
  10 minutes is paused to stop two agents from auto-replying to each other in a loop.
243
246
  - Pet status cards and notifications never show message bodies.
244
247
  - No background daemon: only hooks, the MCP server, and the watcher inside Claude sessions, all of which exit with the session.
248
+
249
+ ## Identity and delivery guarantees
250
+
251
+ Bridge validates `CODEX_THREAD_ID` / `CLAUDE_CODE_SESSION_ID` against the live session registry and the
252
+ current host process. Without a session ID, PID lookup is allowed only when it identifies exactly one
253
+ live session. Ambiguous shared hosts and stale explicit IDs fail closed for sending, renaming, reading
254
+ inboxes and managing reservations. CLI diagnostics can select a session explicitly with
255
+ `--from <session-name-or-full-session-id>`.
256
+
257
+ Claimed inbox messages remain on disk until the complete output has been flushed successfully.
258
+ A later hook, watcher or `check_inbox` recovers unconfirmed messages after a crash. A crash between
259
+ output and confirmation may deliver the same message ID again; the host provides no acknowledgement
260
+ protocol, so exactly-once delivery is not guaranteed. Codex queue delivery uses the recipient's Home.
261
+ Legacy records with an unknown Home fall back to the inbox until registration is refreshed by input
262
+ in that session.
263
+
264
+ Existing watchers recheck the enabled and auto-wake switches while polling. Disabling Bridge also
265
+ blocks CLI send, rename and inbox operations. Integration removal failures return a nonzero exit code;
266
+ the runtime remains disabled, and `disable` can be retried after resolving the reported errors.
@@ -48,13 +48,16 @@ cc-pets bridge configure --edit-guard=off # 关闭编辑前预留拦截
48
48
  | `--wake=on\|off` | 自动唤醒空闲会话,默认开。关闭后消息只进信箱,等对方下次收到你的输入时带入,可省 token |
49
49
  | `--edit-guard=on\|off` | 编辑他人预留的文件时暂停一次,默认开 |
50
50
 
51
+ 运行中的 watcher 会在轮询时检查关闭状态;关闭自动唤醒后不再主动取信,关闭 Bridge 后 CLI 也拒绝发送、改名和收件。
52
+ 卸载集成失败会返回非零退出码,运行时开关仍保持关闭,可排除错误后再次执行 `disable`。
53
+
51
54
  Claude 侧的改动会被热加载;Codex 侧(审批、hooks)需要重启 Codex 会话,hooks 变化后还要在 `/hooks` 中重新信任。
52
55
 
53
56
  ## 使用
54
57
 
55
58
  在任意一个会话里直接用自然语言:
56
59
 
57
- > 列出本机其他 Agent 会话,然后给 codex-my-app-1 发消息:接口改成了 POST /api/pets,你那边同步一下。
60
+ > 列出本机其他 Agent 会话,然后给 codex.my-app.otter 发消息:接口改成了 POST /api/pets,你那边同步一下。
58
61
 
59
62
  Agent 会调用这些 MCP 工具:
60
63
 
@@ -70,7 +73,9 @@ Agent 会调用这些 MCP 工具:
70
73
 
71
74
  ### 会话名
72
75
 
73
- 默认名字是 `<claude|codex>-<项目目录名>-<序号>`,例如 `claude-my-app-1`。同一目录开多个终端时,
76
+ 默认名字是 `<账号名>.<项目目录名>.<动物>`,例如 `claude.my-app.otter`、`claude-x.my-app.panda`。账号名取多账号页里的名称
77
+ (默认账号就是 `claude` / `codex`),动物从 100 个萌系动物里挑,同账号同项目的在线会话不会重名。总长度不超过 40 个字符,
78
+ 项目目录名过长时会截断。同一目录开多个终端时,
74
79
  可以给它们起好记的名字:
75
80
 
76
81
  ```bash
@@ -141,6 +146,13 @@ CC_BRIDGE_NAME=api codex
141
146
  - 开启 CC Bridge 之前就在运行的 Claude 会话能收消息,但没有这些工具,只能在 shell 里用 `cc-pets bridge send` 回复;重启一下最省事。
142
147
  - 留意桌宠:状态图标右下角出现蓝色数字,说明会话之间有往来;点开能看到谁发给了谁,点一下即跳到对应终端(见下文)。
143
148
 
149
+ ### 身份识别与共享宿主
150
+
151
+ Bridge 优先验证当前进程提供的 `CODEX_THREAD_ID` / `CLAUDE_CODE_SESSION_ID`,包括注册记录、
152
+ 在线状态和宿主是否一致。没有会话 ID 时,仅允许宿主 PID 唯一匹配一个在线会话。
153
+ 多个会话共享 PID 且缺少可靠 ID,或显式 ID 已失效时,会明确拒绝发送、改名、收件和文件预留等操作,
154
+ 不会按最近活跃时间猜测。CLI 排查时可用 `--from <会话名或完整会话 ID>` 显式指定身份。
155
+
144
156
  ## 文件预留
145
157
 
146
158
  多个 Agent 在同一个仓库里工作时,最怕两个会话同时改同一个文件。文件预留让 Agent 在开始较大的修改前
@@ -173,6 +185,11 @@ Claude Code 的 watcher 在会话启动和每轮结束时挂上,每次最多
173
185
 
174
186
  发送方只会收到"已送达队列 / 已放入信箱 / 无法投递"这类回执。送达不代表对方已读,也不代表对方同意。
175
187
 
188
+ 信箱消息认领后保留在 `claimed`,完整输出并刷新输出流成功后才确认。进程异常退出时,下一次
189
+ hook、watcher 或 `check_inbox` 会恢复未确认消息。在输出已到达宿主、确认尚未落盘的瞬间崩溃,
190
+ 恢复后可能重复投递同一个消息 ID;目前没有宿主确认协议,无法保证恰好一次送达。
191
+ 跨账号投递 Codex 使用接收方注册的 Home;旧记录无法确定 Home 时保留到信箱,等待该会话输入后刷新注册。
192
+
176
193
  ## 桌宠里的显示
177
194
 
178
195
  开启 CC Bridge 后,桌宠状态卡的圆形图标右下角会多一个消息角标(右上角的红色角标仍是待审批):
package/CHANGELOG.md CHANGED
@@ -7,6 +7,117 @@ truth for the version.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.4.0] - 2026-11-03
11
+
12
+ ### Diagnostics
13
+
14
+ - Distinguish local source packages, local npm packages and unknown local package locations in Diagnostics, copied reports and `cc-pets paths`. Local version mismatch warnings no longer imply that a version has been published on npm; published updates are checked separately.
15
+
16
+ ### Terminal jump and settings
17
+
18
+ - Add exact terminal selection for JetBrains 2026.2 / 2026.3 Reworked terminals through the bundled plugin, including terminals moved into editor tabs. Classic terminals, remote development and split subterminals are outside the supported scope. Ghostty 1.4+ selects tabs and splits by TTY; iTerm2 selects sessions by TTY. Automation permission is required for script-based terminal jumps.
19
+ - Put Panel Appearance first in Settings, with compact theme tiles and a live Liquid Glass dimming preview. Dimming is displayed as 0–100 while retaining the existing internal range; menu presets are 0/25/50/100. Combine terminal integration states in one card, group versions of the same JetBrains product and collapse lists longer than five rows.
20
+
21
+ ### Pet management
22
+
23
+ - Delete pets from the user's own folder directly on the Main menu's Pet page, using a hover button or context menu and a confirmation dialog. Built-in pets and the currently selected pet are protected. Refresh the picker when pets are added or removed through the CLI, Finder or the pet menu.
24
+
25
+ ### Token accounting
26
+
27
+ - Correct Codex cache-write double counting and migrate existing daily archives. Incrementally include background usage from local Codex SQLite logs, excluding sessions already represented by persisted transcripts. Background totals do not invent an input/output/cache breakdown.
28
+ - Keep individual chart series and colors for every model instead of folding models after the eighth into Other. Restore native tooltips for usage metrics.
29
+
30
+ ### VS Code terminal jump
31
+
32
+ - Add the CC Pets Terminal extension for VS Code 1.80+ and its forks (Cursor, Windsurf, VSCodium, …). Clicking an agent card selects the exact integrated terminal by TTY — in the panel, a split or the editor area — and brings its window forward by reopening that window's workspace, switching Spaces when needed. Forks are recognised by `product.json`, not a bundle ID list. Remote windows are not supported; without the extension the app is only brought forward, as before.
33
+ - Settings → Terminal Jump lists each VS Code family app with install, update, reload-needed and disabled states. Install runs the app's own command line tool on the bundled VSIX after confirmation, with a manual "Install from VSIX…" fallback. The VSIX is built reproducibly with macOS tools only (`scripts/build-vscode-extension.sh`).
34
+
35
+ ### Build reliability
36
+
37
+ - Replace cached and uncached executables atomically after signing and verification, including the App's executable. This fixes macOS signature-related termination after in-place overwrites that could break Hooks, CLI launch and tests. Builds now check CLI execution before reporting success; early test failures report their phase, location and exit status.
38
+
39
+ ### CC Bridge
40
+
41
+ - Validate explicit session IDs before PID lookup and reject ambiguous shared-host identities instead of selecting the most recently active session. This protects messaging, renaming, inbox access and file reservations.
42
+ - Retain claimed inbox messages until output is flushed successfully, recover unconfirmed messages after crashes, and prevent delivered receipts from reverting to pending. Recovery can repeat a message ID if a crash occurs between output and confirmation; exactly-once delivery is not guaranteed.
43
+ - Serialize session updates and renaming, use kernel-backed watcher locks, and preserve numeric suffixes when allocating duplicate 40-character session names.
44
+ - Recheck enabled and auto-wake settings in running watchers, reject CLI mutations while disabled, and report integration removal failures with a nonzero exit code while keeping the runtime disabled.
45
+ - Use the recipient's Codex Home for queue delivery, recognize literal bracketed file paths such as `[id]` in reservation checks, and preserve account and sender IDs for Bridge activity display.
46
+ - Shorten the cross-session message envelope to a source line, a one-line permission notice and a reply address that includes the sender's ref. MCP instructions now ask the receiving session to reply to the originating session with `send_message` when it needs clarification or finishes the request.
47
+
48
+ ### Launch protection
49
+
50
+ - Added an optional Shadowrocket launch check under **Main menu → Settings → Launch Protection** (off by default). Before registering a session or sending a starting event, wrappers verify the VPN connection and request each service's `/cdn-cgi/trace`. Mainland China (CN), Hong Kong (HK), unknown exits and failed requests block launch; successful checks show the exit IP and region.
51
+ - Claude defaults to `api.anthropic.com`; Codex selects `chatgpt.com` or `api.openai.com` from its `auth.json` login mode, checking both when unknown. Common user-level endpoint settings are supported; custom endpoints must return valid trace data, with no unrelated-domain fallback. Removed separate DNS / homepage HEAD probes. Requests send no account credentials, verify TLS, ignore `~/.curlrc` and do not follow redirects. See README for complex configuration, project override and cloud-provider limitations. Launches bypassing wrappers are not checked.
52
+ - Exit checks allow 8 seconds to connect and 15 seconds per request, with a 16-second process watchdog. Temporary transport failures and HTTP 502 / 503 / 504 retry once after 1 second. Failures report the timeout phase, attempt count and cumulative connection timings. Wrapper tests use a fresh preferences domain per run, keeping real VPN settings and network probes out of ordinary tests while preserving compile caching and phase timing.
53
+
54
+ ### Quota and interface
55
+
56
+ - Track low-quota speech independently for each subscription account at the 20%, 10% and 5% thresholds. Queue reminders during cooldown, identify the triggering account, skip the first sample and expired windows, and exclude API-usage accounts. General quota placeholders use the account with the least remaining quota.
57
+ - Apply the same Codex live-usage merge to default and custom Homes. Expire exhaustion markers from their original sampling time so repeated cache reads cannot extend their five-minute lifetime.
58
+ - Simplify the monthly token trend layout: show today's usage and recorded days on separate lines, with peak usage in a tooltip for the selected account.
59
+ - Normalize provider icon sizing and bundle fallback Claude and Codex icons for CLI-only installations. Include them in native builds and npm packages, and document their sources and separate ownership in the third-party notices.
60
+
61
+ ## [2.3.0] - 2026-10-21
62
+
63
+ ### Installation
64
+
65
+ - Everything CC Pets runs is now native: hook installation and removal, CC Bridge (hooks, watcher, MCP server and `cc-pets bridge`), `cc-pets doctor` / `paths`, `cc-pets pet` and the zsh scripts' translations. Node.js is only needed by npm to install and update the package, and CC Bridge hooks no longer start a Node process on every event.
66
+ - Rewritten `settings.json` / `hooks.json` keep their original key order and formatting, and numeric literals are preserved exactly (large integers no longer lose precision). Uninstalling no longer reformats a config file that had nothing of ours in it.
67
+ - `cc-pets install` re-registers CC Bridge with the native binary; after upgrading, restart running Codex sessions and trust the updated hooks in `/hooks`.
68
+
69
+ ### Multi-Account
70
+
71
+ - Official `~/.claude` and `~/.codex` Homes are detected and integrated automatically, while custom Homes are added explicitly from the Main menu's **Multi-Account** page. Folder names are preserved as account names unless the user renames them.
72
+ - Each provider now has an independent circular quota-card carousel with arrow, page-dot, drag, trackpad and keyboard navigation. Quota history, usage totals, live state and approval state follow the selected account.
73
+ - The Usage page can filter local token history by account and switches to a compact account menu when names or account counts no longer fit in the header.
74
+ - Pet Hooks, usage collection, CC Bridge hooks, permissions and MCP registration are scoped to each Home. Custom Homes added before CC Bridge is enabled are integrated automatically when it is enabled later.
75
+ - Claude and Codex launch wrappers attach the resolved account identity to startup and hook events, so status cards and speech bubbles use the exact account name from the first event.
76
+ - CC Bridge default session names are now `<account>.<project-directory>.<animal>` (for example `claude-x.my-app.otter`), so sessions from different accounts in the same project are easy to tell apart. Already registered sessions keep their names.
77
+ - Claude and Codex accounts now detect API or subscription authentication in the background. Accounts identified as API authentication are fixed to API usage; subscription accounts can still switch between plan quota and API usage. Unknown authentication keeps manual switching available, and missing quota data is not treated as evidence of API authentication. Detection does not retain keys or authentication command output.
78
+ - Account management moved from the **Agent Accounts** submenus (right-click menu and app menu) to a **Multi-Account** page in the Main menu, also reachable from the app menu and `cc-pets open accounts`. It lists Claude and Codex Homes with their paths and integration status (Integrated, Needs repair, Home unavailable); each row's **Manage…** menu offers Repair Integration and Rename, plus Relocate Home and Remove Integration for custom Homes. The status refreshes after account changes, CC Bridge being turned on or off, Diagnostics checks and repairs, and when you return to the app after changing things in a terminal.
79
+ - Usage Display pills in the right-click menu and Settings now apply to each registered account independently, inheriting the previous provider preference until customized. The Settings page updates when accounts are added, removed, renamed or relocated.
80
+
81
+ ### Main menu
82
+
83
+ - Added a regular app window. Open it from the right-click menu (**Main menu**), the app menu or `cc-pets open [page]` (pages: `overview`, `sessions`, `usage`, `pet`, `accounts`, `alerts`, `general`, `diagnostics`; `settings` still works and opens Pet). The Dock icon and menu bar appear only while it is open, and clicking the Dock icon brings a minimized window back; the window is created on open and released on close, and nothing runs while it is closed.
84
+ - The sidebar shows the current pet, animated, with its status, then **Workbench** (Overview, Sessions, Usage, Pet, Multi-Account) and **General** (Alerts, Settings); Diagnostics sits at the bottom with a badge when something needs fixing. The window has its own look: a teal accent, cards on a cool neutral background, status colors used only for status, in light and dark.
85
+ - **Overview** page: the pet and what it is doing, today's total usage with input, output, cached input and requests, a notice when diagnostics found problems, and compact cards for every registered Claude / Codex account, independent of the hover panel's carousel selection. Cards use the hover panel's data and refresh with usage and live-state changes. Plan mode shows 5-hour and weekly quota rings, reset times and weekly pace; API mode shows monthly calls and total tokens, with daily call averages and input/output tokens underneath. Cards form a two-column grid with equal heights across API and plan modes.
86
+ - **Sessions** page: Agent sessions online right now, sessions waiting for approval first, each with **Go to Terminal**; and CC Bridge messages waiting in an inbox or recently delivered. Only who sent what to whom is shown, never the message.
87
+ - **Usage** page: local Claude Code and Codex token usage for the last 7, 30 or 90 days. The same five-cell strip as the overview shows total usage (input + cache write + output + cached input), input, output, cached input with its hit rate, and requests for the chosen source and range. The daily chart stacks models in fixed colors (a color-blind-safe palette; models past the eighth fold into "Other") and switches between total, input, output, cached input and requests; click a model in the legend or the table to see only that model, and hover a bar for that day's per-model numbers and total. The columns are normalised so they never overlap (Codex cached tokens are subtracted from its input). Computed on a background queue from local session logs, with its own caches and a per-day archive that outlives Claude Code's transcript pruning. The hover panel's numbers and caches are unchanged. The first time after upgrading, session summaries are re-read once.
88
+ - **Pet**, **Alerts** and **Settings** pages: every pet setting, split into three short pages (Pet holds the pet picker, size, chatter, click reactions and Codex import; Alerts holds notifications, the status card and system status; Settings holds language, panel appearance and the pet sprites folder), plus finer controls such as click-reaction thresholds. All settings go through one preferences layer, so the desktop pet, the menu and the window stay in sync. Options that rewrite Claude Code / Codex configuration (enabling CC Bridge, auto-approve) remain in the right-click menu.
89
+ - The right-click menu is trimmed to the everyday items: Pets, Pet Size, Show Status Card, Usage Display, Panel Theme, CC Bridge, Help, Main menu and Quit. Import Codex Pets, Notifications, Click Reactions, System Status, Chatter and Language moved to the window's Pet, Alerts and Settings pages.
90
+ - In full screen or when zoomed to fill the screen, the sidebar is 10 pt wider, its content moves 5 pt right, and menu items get more room between icon and title (and between Chinese characters). In full screen the pet card no longer sits against the top edge of the screen.
91
+ - Glass dimming is now continuous (0–45%) with a slider on the Settings page; the right-click menu keeps its four presets and checks the closest one. The quota card scrim follows the value smoothly.
92
+ - The Main menu window has its own System Default / Light / Dark appearance setting, with teal control accents; the pet's panels keep their separate appearance preference.
93
+ - **Diagnostics** page: the same checks as `cc-pets doctor`, problems first with their fix commands and copy buttons, passing checks folded into one line, **Re-check** and **Copy Report**. Registered accounts' Hooks and Claude status line issues now offer **Auto-fix** and **Fix All**. Configuration and affected scripts are backed up before changes, with a manifest of original paths and permissions; checks run again automatically after repair, and the page shows backup locations and any failures. Other issues retain their manual commands. The PATH order check is shown as a hint to run `cc-pets doctor` in a terminal, because the pet's own PATH is not the terminal's.
94
+ - Added `cc-pets doctor --repair-profile <profile-id>` to repair a registered account's Hooks and Claude status line without reinstalling the app or changing shell configuration. Plain `cc-pets doctor` remains read-only.
95
+ - Added `cc-pets open [page]`. If the pet is running it asks it to open the window; otherwise it launches the app and opens the window. Terminals launching Claude Code or Codex never pop the window up.
96
+ - `cc-pets doctor` now also finds the npm package directory when run from the installed app, using a `package-dir` marker that `cc-pets install` leaves in the app data directory. Run `cc-pets install` once after upgrading.
97
+ - Behavior changes: ⌘Q in the lines editor now quits the pet (it did nothing before), and unsaved text in the editor is lost; speech bubbles no longer hide when the app loses focus, matching the pet and status card; chatter frequency accepts only `low`, `normal`, `high` and `chatty`, and any other stored value is normalized to `normal` when written (reading behaves as before).
98
+
99
+ ### Pets
100
+
101
+ - The built-in pet is now named **ByteMochi** (its file was `默认.webp`). Upgrading keeps it selected and moves its pet-specific lines from `builtin-默认.txt` to `builtin-ByteMochi.txt`; an existing `builtin-ByteMochi.txt` is never overwritten.
102
+
103
+ ### Fixes
104
+
105
+ - Fixed clipping in scaled status cards and speech bubbles, including the speech bubble's click bounds.
106
+ - Account-aware terminal focus is preserved, and starting a new session on the same terminal removes stale records left by the previous account instead of leaving a stuck Starting row.
107
+ - CLI messages now fill in placeholders containing underscores; `cc-pets bridge enable` previously printed `{MCP_NAME}` instead of `cc-bridge`.
108
+ - An account without quota data or history no longer falls back to another account's cached data in the hover panel or Overview.
109
+ - On Overview, **Check Diagnostics** now sits after the account name and only appears when that account actually has diagnostic warnings or failures; quota data that hasn't been collected yet no longer triggers it.
110
+ - Repairing, renaming, relocating or removing an account while another account is still being configured now says so, instead of silently doing nothing (Remove previously asked for confirmation and then did nothing).
111
+ - In `cc-pets doctor`, the section shown when no accounts are registered is now titled **Agent profiles** instead of the Main menu page name.
112
+ - Reinstalling or repairing an account now also replaces pet Hooks that point at the executable inside `CC Pets.app` (written when an account was repaired from the app). Previously they were not recognized as ours, so each repair added another copy and every event ran the pet hook several times. `cc-pets doctor` now reports such leftovers as stale; run `cc-pets profile repair --id <profile-id>` (or **Repair Integration** on the Multi-Account page) once to remove them.
113
+ - Adding or relocating an account now validates provider-specific Home files, preventing a Claude Home's `sessions/` directory from being mistaken for a Codex Home and receiving Codex configuration.
114
+ - Monthly token aggregation and its cache now follow each account's effective display mode, so switching an account to API usage refreshes the monthly data instead of reusing a shorter plan-mode window.
115
+ - Usage Display buttons in the right-click menu now align with a shared right margin across account names of different lengths; long names have tooltips, and API accounts' disabled pills have a distinct appearance.
116
+
117
+ ### Development
118
+
119
+ - Grouped native sources into module subdirectories and split the larger pet, usage and quota UI implementations. Build and test scripts discover sources and headers recursively; npm packaging checks cover the new layout.
120
+
10
121
  ## [2.2.1] - 2026-10-11
11
122
 
12
123
  ### Pet size and rendering
@@ -6,6 +6,117 @@
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.4.0] - 2026-11-03
10
+
11
+ ### 诊断
12
+
13
+ - 诊断页、复制报告与 `cc-pets paths` 区分本地源码包、本地 npm 包及无法确认来源的本地包。版本不一致提示明确比较本地安装,不再让人误以为对应版本已在 npm 发布;线上版本仍由更新检查单独查询。
14
+
15
+ ### 终端跳转与设置
16
+
17
+ - 通过随包插件精确选择 JetBrains 2026.2 / 2026.3 Reworked 终端,支持移入编辑器标签页的终端;Classic 终端、远程开发及分屏内子终端不在支持范围内。Ghostty 1.4+ 按 TTY 选择标签页和分屏,iTerm2 按 TTY 选择会话;通过脚本跳转的终端需要 Automation 权限。
18
+ - 设置页将面板外观置顶,缩小主题卡片,并提供 Liquid Glass 压暗实时预览。压暗显示为 0–100,内部范围保持不变,菜单预设调整为 0/25/50/100。终端集成状态合并到一张卡片,同一 JetBrains 产品的多个版本合并展示,超过五行时折叠。
19
+
20
+ ### 宠物管理
21
+
22
+ - 主菜单「宠物」页可通过悬停按钮或右键菜单删除用户素材目录内的宠物,删除前弹窗确认;内置宠物与当前选中的宠物受保护。通过 CLI、Finder 或桌宠菜单增删素材后,列表会刷新。
23
+
24
+ ### Token 统计
25
+
26
+ - 修复 Codex cache write 重复计数并迁移已有按日归档;从本机 Codex SQLite 日志增量补充后台用量,排除已由持久化会话记录覆盖的部分。后台用量仅计入总量,不推算 input/output/cache 明细。
27
+ - 每个模型保留独立图表序列与颜色,第八个之后不再合并为 Other;用量指标恢复原生 tooltip。
28
+
29
+ ### VS Code 终端跳转
30
+
31
+ - 新增 VS Code 1.80+ 及其分支(Cursor、Windsurf、VSCodium 等)的 CC Pets Terminal 扩展。点击 Agent 卡片时按 TTY 精确选中集成终端,面板、分屏和编辑器区均支持;通过重新打开该窗口的工作区把对应窗口前置,必要时切换桌面。分支按 `product.json` 识别,不维护 bundle ID 名单。远程窗口不支持;未安装扩展时仍只激活应用。
32
+ - 「设置 → 终端跳转」按应用列出 VS Code 家族,显示安装、更新、需要重新加载和已禁用等状态。确认后调用应用自带的命令行工具安装随包 VSIX,失败时可手动「从 VSIX 安装…」。VSIX 仅用 macOS 自带工具可复现构建(`scripts/build-vscode-extension.sh`)。
33
+
34
+ ### 构建可靠性
35
+
36
+ - 缓存与无缓存构建均在签名校验后原子替换可执行文件,覆盖裸 CLI 和 App 内的程序,修复原地覆盖导致 macOS 因签名问题终止进程、连带 Hook、CLI 启动和测试失败的问题。构建报告成功前检查 CLI 能否执行;测试提前失败时显示阶段、位置与退出码。
37
+
38
+ ### CC Bridge
39
+
40
+ - 优先验证显式会话 ID;按 PID 回退时遇到共享宿主的多个会话会拒绝操作,不再按最近活跃时间猜测身份,覆盖发消息、改名、收件和文件预留。
41
+ - 信箱消息在完整输出并刷新输出流成功前保留,异常退出后恢复未确认消息;已送达回执不会被迟到的更新覆盖为待投递。输出与确认之间崩溃时可能重复投递同一消息 ID,不保证恰好一次送达。
42
+ - 会话更新和改名串行化,watcher 改用内核锁;为重名的 40 字符会话名分配新名字时保留数字后缀,避免死循环。
43
+ - 运行中的 watcher 持续检查启用和自动唤醒开关;关闭后 CLI 拒绝修改操作;集成卸载失败返回非零退出码,运行时仍保持关闭。
44
+ - Codex 队列投递使用接收方的 Home;文件预留检查正确处理 `[id]` 等带方括号的真实路径;Bridge 活动展示保留账号和发送方会话 ID。
45
+ - 精简跨会话消息封装:只保留来源行、一行降权说明和带 ref 的回复地址;MCP 说明要求接收方在需要补充信息或任务完成时,用 `send_message` 回复来源会话。
46
+
47
+ ### 启动保护
48
+
49
+ - 新增可选的小火箭(Shadowrocket)启动检查,位于「主菜单 → 设置 → 启动保护」,默认关闭。包装器在登记会话、发送 starting 事件之前检查 VPN 连接状态,并分别请求服务的 `/cdn-cgi/trace`。中国大陆(CN)、香港(HK)、未知出口及请求失败均阻止启动;成功显示出口 IP 和地区。
50
+ - Claude 默认检查 `api.anthropic.com`;Codex 按 `auth.json` 的登录模式检查 `chatgpt.com` 或 `api.openai.com`,模式未知时检查两者。支持用户级常见端点配置;自定义地址必须返回有效 trace,不回退到无关域名。移除独立 DNS / 首页 HEAD 探测,不携带账号凭据、校验 TLS 证书、忽略 `~/.curlrc`、不跟随重定向。复杂配置、项目网络覆盖及云服务商的支持边界见 README;绕过包装器的启动不受保护。
51
+ - 出口检测调整为连接时限 8 秒、单次请求时限 15 秒、进程保护时限 16 秒;临时传输故障和 HTTP 502 / 503 / 504 间隔 1 秒重试一次。失败时显示超时阶段、尝试次数及连接累计耗时。包装器测试每轮使用独立偏好域,避免读取真实 VPN 设置并发起网络探测,保留编译缓存和阶段计时。
52
+
53
+ ### 额度与界面
54
+
55
+ - 低额度台词按订阅账号分别记录 20%、10%、5% 阈值,冷却时排队,播报注明触发账号;首次采样、过期额度和 API 用量账号不触发提醒。普通额度槽位使用剩余额度最低的账号。
56
+ - 默认和自定义 Home 统一合并 Codex 实时额度;耗尽标记按原始采样时间计算五分钟有效期,重复读取缓存不再延长有效期。
57
+ - 简化月度 Token 趋势排版,今日用量和记录天数分行显示,峰值移入当前所选账号的悬浮提示。
58
+ - 统一服务商图标的视觉尺寸;为仅安装 CLI 的环境随原生构建和 npm 包提供 Claude、Codex 备用图标,并在第三方声明中说明来源及独立版权归属。
59
+
60
+ ## [2.3.0] - 2026-10-21
61
+
62
+ ### 安装
63
+
64
+ - CC Pets 运行时的所有部分都改为原生实现:Hooks 的安装与卸载、CC Bridge(hooks、watcher、MCP server 与 `cc-pets bridge`)、`cc-pets doctor` / `paths`、`cc-pets pet`,以及 zsh 脚本的多语言。Node.js 只剩 npm 安装、升级时需要,CC Bridge 的 hook 也不再每次事件都拉起一个 Node 进程。
65
+ - 回写的 `settings.json` / `hooks.json` 保持原有键顺序与格式,数字按原文保留(大整数不再丢精度);卸载时,里面本来没有我们条目的配置文件不再被重新排版。
66
+ - `cc-pets install` 会用原生程序重新注册 CC Bridge;升级后需重启正在运行的 Codex 会话,并在 `/hooks` 中重新信任更新后的 hooks。
67
+
68
+ ### 多账号
69
+
70
+ - 官方 `~/.claude` 和 `~/.codex` Home 会自动发现并集成;自定义 Home 只能从主菜单的「多账号」页手动添加。除非用户主动重命名,否则文件夹名会原样作为账号名称。
71
+ - 每个 Provider 拥有独立的循环额度卡片轮播,支持箭头、页码圆点、拖动、触控板和键盘切换;额度历史、用量汇总、在线状态与审批状态跟随当前账号。
72
+ - 用量页支持按账号筛选本机 Token 历史;账号数量或名称长度超出页头空间时,会自动切换为紧凑的账号下拉菜单。
73
+ - Pet Hooks、用量采集、CC Bridge Hooks、权限与 MCP 注册均按 Home 隔离。先添加自定义 Home、以后再开启 CC Bridge 时,会自动补齐对应集成。
74
+ - Claude 与 Codex 启动包装器会从第一个事件开始携带解析后的账号身份,因此状态卡和气泡会直接显示准确的账号名称。
75
+ - CC Bridge 默认会话名改为 `<账号名>.<项目目录名>.<动物>`(如 `claude-x.my-app.otter`),多个账号开在同一项目里也能一眼分清;已注册的会话保留原名。
76
+ - Claude 和 Codex 账号会在后台识别 API 或订阅认证。明确识别为 API 的账号固定显示 API 用量;订阅账号仍可切换订阅额度与 API 用量。认证类型不明时保留手动切换,缺少额度数据不作为 API 认证的判断依据。检测不保存密钥或认证命令的输出。
77
+ - 账号管理从右键菜单和应用菜单里的「Agent 账户」子菜单移到主菜单新增的「多账号」页,也可从应用菜单或 `cc-pets open accounts` 打开。页面按 Claude / Codex 列出各 Home 的路径和集成状态(已集成、需要修复、Home 不可用);每行的「管理…」菜单提供修复集成、重命名,自定义 Home 另有重新定位 Home 和移除集成。账号变更、开关 CC Bridge、诊断检查与修复之后,以及在终端改动后回到 App 时,状态都会刷新。
78
+ - 右键菜单和「设置」中的用量展示胶囊改为按已登记账号独立设置;尚未单独设置的账号沿用原有平台偏好。新增、移除、重命名或重新定位账号后,设置页会同步更新。
79
+
80
+ ### 主菜单
81
+
82
+ - 新增普通 App 窗口。可从右键菜单(**主菜单**)、应用菜单或 `cc-pets open [page]` 打开(页面:`overview`、`sessions`、`usage`、`pet`、`accounts`、`alerts`、`general`、`diagnostics`;旧的 `settings` 仍可用,会打开「宠物」页)。Dock 图标和菜单栏只在窗口打开期间出现,窗口最小化后点 Dock 图标可以恢复;窗口打开时才创建、关闭即释放,关着的时候没有任何后台任务。
83
+ - 侧边栏顶部是会动的当前宠物和它的状态,下面分两组:**工作台**(概览、会话、用量、宠物、多账号)和**通用**(提醒、设置);诊断放在最底下,有问题要处理时带角标。窗口有自己的一套视觉:青色强调色、偏冷的中性底色上的卡片,状态色只用来表达状态,深浅色都适配。
84
+ - **概览**页:宠物和它此刻在做什么,今日总用量和输入、输出、缓存输入、请求数,诊断发现问题时的提醒,以及所有已登记 Claude / Codex 账号的简洁卡片,不再只展示悬停面板轮播中选中的账号。卡片与悬停面板使用同一份数据,用量和在线状态变化时同步刷新。订阅模式展示 5 小时和本周的剩余额度环、重置时间与本周节奏;API 模式展示本月调用和 Token 总量,并补充日均调用及输入/输出 Token。卡片按两列排列,API 与订阅卡片统一高度。
85
+ - **会话**页:此刻在线的 Agent 会话,等审批的置顶,每行可「跳到终端」;以及卡在信箱里待投递、最近送达的 CC Bridge 消息。只显示谁发给了谁,不显示正文。
86
+ - **用量**页:本机 Claude Code / Codex 最近 7、30、90 天的 Token 用量。顶部和概览同一套五格指标:所选来源和区间的总用量(输入 + 缓存写 + 输出 + 缓存输入)、输入、输出、缓存输入(附命中率)和请求数。每日柱状图按模型分色堆叠,颜色固定跟着模型走(色盲安全的色板,第 9 个模型起合并为「其他」),可以切换总用量 / 输入 / 输出 / 缓存输入 / 请求;点图例或表格里的模型只看它,鼠标移到柱子上看当天各模型的数值和合计。四栏统一成互不重叠的口径(Codex 的缓存命中已从它的输入里扣除)。在后台队列计算,数据来自本机会话日志,用自己的缓存和按日归档,Claude Code 清理旧转录后历史仍然保留。悬停面板的数字和缓存不受影响。升级后第一次会把会话摘要重读一遍。
87
+ - **宠物**、**提醒**、**设置**三页:桌宠的全部设置拆成三页(宠物页放选宠物、大小、碎碎念、点击互动和导入 Codex 素材;提醒页放系统通知、桌面状态卡和系统状态;设置页放语言、面板外观和素材目录),另有更细的项(比如连击阈值)。所有设置统一走同一层偏好读写,桌面上的宠物、右键菜单和窗口保持同步。会改写 Claude Code / Codex 配置的选项(启用 CC Bridge、免审批)仍留在右键菜单里。
88
+ - 右键菜单精简为最常用的几项:管理桌宠、宠物大小、显示消息气泡、用量展示模式、面板主题、CC Bridge、帮助、主菜单 和退出桌宠。导入 Codex 素材、系统通知、连击互动、系统状态、碎碎念和语言移到主菜单的宠物、提醒、设置页。
89
+ - 全屏或 zoom 铺满屏幕时,侧边栏加宽 10pt、内容右移 5pt,菜单项的图标与文字、中文字与字之间也更宽松;全屏时名片不再贴着屏幕顶边。
90
+ - 玻璃压暗改为 0–45% 连续可调,在「设置」页用滑块调;右键菜单仍是四档,勾选最接近当前值的一档。额度卡片的衬底跟着平滑变化。
91
+ - 主菜单可独立选择跟随系统、浅色或深色外观,控件统一使用青色强调色;桌宠面板继续使用各自的外观偏好。
92
+ - **诊断**页:和 `cc-pets doctor` 同一套检查,要处理的问题置顶并带修复命令和「复制命令」,正常项折叠成一行,另有「重新检查」和「复制报告」。已登记账号的 Hooks 和 Claude status line 问题新增「自动修复」与「全部修复」:修改前备份配置及相关脚本,通过清单记录原路径和权限,完成后自动重新检查,并在页面显示备份位置和失败原因。其他问题仍保留手动修复命令。PATH 顺序那一项在主菜单里只提示去终端运行 `cc-pets doctor`,因为桌宠进程自己的 PATH 不是终端的。
93
+ - 新增 `cc-pets doctor --repair-profile <profile-id>`,仅修复指定已登记账号的 Hooks 和 Claude status line,无需重装 App 或修改 shell 配置。普通 `cc-pets doctor` 仍保持只读。
94
+ - 新增 `cc-pets open [page]`:桌宠在运行时请它开窗,否则启动 App 并开窗。终端里启动 Claude Code / Codex 不会弹出主菜单。
95
+ - 在安装版 App 里运行时,`cc-pets doctor` 也能找到 npm 包目录了:靠 `cc-pets install` 在应用数据目录里留下的 `package-dir` 记号。升级后请运行一次 `cc-pets install`。
96
+ - 行为变化:台词编辑器在前台时 ⌘Q 现在会退出桌宠(以前没有反应),编辑器里未保存的内容会丢失;说话气泡不再随 App 失焦隐藏,与桌宠、状态卡一致;碎碎念频率只接受 `low` / `normal` / `high` / `chatty`,其他值写入时规整为 `normal`(读取效果不变)。
97
+
98
+ ### 宠物
99
+
100
+ - 内置宠物改名为 **ByteMochi**(原文件名 `默认.webp`)。升级后仍保持选中,为它写的专属台词会从 `builtin-默认.txt` 移到 `builtin-ByteMochi.txt`;已存在的 `builtin-ByteMochi.txt` 不会被覆盖。
101
+
102
+ ### 修复
103
+
104
+ - 修复宠物缩放后状态卡与说话气泡的裁剪,并同步说话气泡的点击区域。
105
+ - 保持多账号下的终端聚焦;同一终端启动新会话时会清理前一个账号遗留的记录,避免会话列表残留「正在启动」。
106
+ - CLI 文案中带下划线的占位符现在会被正确替换;此前 `cc-pets bridge enable` 输出的是 `{MCP_NAME}` 而不是 `cc-bridge`。
107
+ - 账号没有额度数据或历史时,悬停面板和概览不再借用其他账号的缓存。
108
+ - 概览中的「查看诊断」移至账号名称后,仅在该账号确实有诊断警告或失败项时显示;暂未采集到额度不再触发提示。
109
+ - 另一个账号仍在适配时,对账号执行修复、重命名、重新定位或移除会给出提示,不再静默无反应(此前移除会先弹确认,确认后却什么也不做)。
110
+ - `cc-pets doctor` 中没有已登记账号时的那一节,标题改为「Agent 配置」,不再沿用主菜单的页面名。
111
+ - 重装或修复账号时,指向 `CC Pets.app` 包内程序的宠物 Hooks(从 App 里修复账号时写入)现在也会被一并替换。此前它们不被识别为自家条目,每修复一次就多一份,每个事件都会重复运行好几次宠物 hook。`cc-pets doctor` 现在会把这类残留标为过期;运行一次 `cc-pets profile repair --id <profile-id>`(或在「多账号」页点「修复集成」)即可清掉。
112
+ - 添加或重新定位账号时,按 Provider 专属文件校验 Home,避免因 Claude Home 也有 `sessions/` 目录而将其误认作 Codex Home、写入 Codex 配置。
113
+ - 月度 Token 聚合及缓存改为跟随每个账号实际生效的展示模式;切换到 API 用量后重新汇总月度数据,不再复用订阅模式较短统计区间的数据。
114
+ - 右键菜单的用量展示按钮统一靠右对齐,不再受账号名称长度影响;长名称可悬停查看,API 账号禁用的胶囊按钮使用单独的视觉状态。
115
+
116
+ ### 开发
117
+
118
+ - 原生源码按模块拆入子目录,并拆分较大的宠物、用量和额度 UI 实现。构建与测试脚本递归发现源码和头文件,npm 打包检查覆盖新的目录结构。
119
+
9
120
  ## [2.2.1] - 2026-10-11
10
121
 
11
122
  ### 宠物大小与渲染
package/CONTRIBUTING.md CHANGED
@@ -13,6 +13,28 @@ Thank you for contributing to CC Pets. Before submitting a change:
13
13
  For a substantial feature, open a GitHub Issue before sending a Pull Request so the
14
14
  scope can be agreed on first.
15
15
 
16
+ ## Build and test cache
17
+
18
+ `npm run build` and `npm test` share object files and linked binaries under
19
+ `.build/clang-cache/cc-pets`. Changes to sources, project headers, compiler flags,
20
+ the toolchain, or SDK invalidate the cache; temporary output paths do not.
21
+ Empty-resource builds, normal builds, and installation checks still refresh resources
22
+ and signatures. Every test runs each time; passing results are never cached.
23
+ Logs show compilation progress, compiled/reused counts, test phases, and elapsed time.
24
+ Executables are staged on the destination filesystem, ad-hoc signed and verified, then
25
+ atomically renamed into place. This also applies when the cache is disabled; executable
26
+ files must not be overwritten in place on macOS. Builds check that the resulting CLI can
27
+ run `--version`, and early test failures report their phase, location, and exit status.
28
+
29
+ The test runner assigns a fresh `CC_PETS_PREFERENCES_DOMAIN` on every run. Changing
30
+ `HOME` alone does not isolate macOS `CFPreferences`. Launch protection defaults to off
31
+ in this domain, so wrapper and shim tests do not depend on your VPN or live exit probes.
32
+
33
+ Use `CC_PETS_NO_BUILD_CACHE=1 npm run build` or `CC_PETS_NO_BUILD_CACHE=1 npm test`
34
+ to bypass the cache and compile with the original clang command. This does not read
35
+ or write this cache. The existing `cc-pets clean` command removes these artifacts
36
+ along with the application's other caches.
37
+
16
38
  ## Branch and release policy
17
39
 
18
40
  Develop, test, and prepare preview releases on `publish`. Preview releases must be
@@ -21,7 +43,7 @@ Install preview builds explicitly; the automatic updater accepts stable versions
21
43
  `main` is reserved for stable releases, including the stable GitHub Release and tag.
22
44
  Complete implementation, documentation, screenshots, and validation on `publish`
23
45
  before submitting to `main`; repeat integration checks there before a stable release.
24
- The latest stable GitHub release is **v2.2.1**, covering pet size, speech sources, and menu fixes.
46
+ The latest stable GitHub release is **v2.3.0**, covering the Main menu, multiple accounts, token usage by model, and the native runtime.
25
47
  See [release status](docs/release-status.md) for validation and handoff details.
26
48
 
27
49
  ## Localization
@@ -29,14 +51,18 @@ See [release status](docs/release-status.md) for validation and handoff details.
29
51
  UI text is written in English in the source, and that text is the key into every
30
52
  other language's table:
31
53
 
32
- - Objective-C: wrap user-visible strings in `L(@"…")` (`Sources/CCPets/CCPetsL10n.h`).
33
- Use `%1$@` / `%2$@` when a translation needs a different argument order.
34
- - Node.js: use `t("…", { name })` from `scripts/i18n.mjs` with `{name}` placeholders.
35
- - zsh: use `cc_pets_t "…" name="$value"` from `scripts/i18n.zsh`. The text must be a
36
- literal; put variables in `{name}` placeholders, never directly in the text.
54
+ - Objective-C: wrap user-visible strings in `L(@"…")` (`Sources/CCPets/Support/CCPetsL10n.h`).
55
+ Use `%1$@` / `%2$@` when a translation needs a different argument order. Command-line
56
+ output can instead use `{name}` placeholders filled by `CCPetsInterpolate(L(@"…"), @{…})`.
57
+ - zsh: use `cc_pets_t "…" name="$value"` from `scripts/i18n.zsh`, which looks the text up
58
+ through the native `cc-pets --localize`. The text must be a literal; put variables in
59
+ `{name}` placeholders, never directly in the text.
60
+
61
+ The app, the command-line tools and the zsh scripts share one table per language:
62
+ `Resources/<language>.lproj/Localizable.strings`.
37
63
 
38
64
  When you add or change an English string, update its key in every table.
39
- `node scripts/check-l10n.mjs` (also part of `npm test`) reports missing, stale and
65
+ `node tests/check-l10n.mjs` (also part of `npm test`) reports missing, stale and
40
66
  mismatched-placeholder entries for each language.
41
67
 
42
68
  ### Adding a language
@@ -50,11 +76,10 @@ Adding a language only adds files; no code changes are needed. For a language `x
50
76
  heading of that language's section in GitHub release notes; separate alternatives
51
77
  with `|`).
52
78
  2. `Resources/xx.lproj/InfoPlist.strings`: translate `NSAppleEventsUsageDescription`.
53
- 3. `scripts/locales/xx.json`: translate the CLI table, copied from `zh-Hans.json`.
54
- 4. Optional: `Resources/phrases.default.xx.txt` with default pet lines, translated from
79
+ 3. Optional: `Resources/phrases.default.xx.txt` with default pet lines, translated from
55
80
  `phrases.default.en.txt`. Without it the pet falls back to the English lines.
56
81
 
57
- `node scripts/check-l10n.mjs --missing xx` lists the keys still to translate. The app
82
+ `node tests/check-l10n.mjs --missing xx` lists the keys still to translate. The app
58
83
  discovers languages from the `.lproj` directories, `build.sh` writes
59
84
  `CFBundleLocalizations` from them, and `package.json` already includes them by pattern.
60
85
 
@@ -12,6 +12,23 @@
12
12
 
13
13
  建议先开一个 GitHub Issue 描述较大的功能改动,达成一致后再提交 Pull Request。
14
14
 
15
+ ## 构建与测试缓存
16
+
17
+ `npm run build` 与 `npm test` 共用 `.build/clang-cache/cc-pets` 下的目标文件和链接产物。
18
+ 源码、项目头文件、编译参数、工具链或 SDK 变化时自动失效;临时输出目录的变化不影响复用。
19
+ 空素材构建、正常构建和安装测试仍会更新资源与签名,所有测试每次都执行,不缓存通过结果。
20
+ 日志显示当前编译文件、编译/复用数量、测试阶段及耗时。
21
+ 可执行文件先在目标文件系统中暂存,完成临时签名与校验后再原子替换;关闭缓存时也使用此流程,
22
+ 避免在 macOS 上原地覆盖可执行文件。构建完成前确认 CLI 可以执行 `--version`,
23
+ 测试提前失败时输出所属阶段、代码位置与退出码。
24
+
25
+ 测试入口每轮设置全新的 `CC_PETS_PREFERENCES_DOMAIN`。仅修改 `HOME` 无法隔离 macOS
26
+ `CFPreferences`;独立偏好域中的启动保护默认关闭,包装器和 shim 测试不依赖本机 VPN 或真实出口探测。
27
+
28
+ 需要绕过缓存完整重编译时,使用 `CC_PETS_NO_BUILD_CACHE=1 npm run build`,
29
+ 或 `CC_PETS_NO_BUILD_CACHE=1 npm test`。该开关直接使用原始 clang 命令,不读写这份缓存。
30
+ 缓存位于现有构建缓存目录内,`cc-pets clean` 清理应用缓存时也会一并清理它。
31
+
15
32
  ## 分支与发布规则
16
33
 
17
34
  在 `publish` 完成开发、修改、测试和测试版本准备。测试版本必须在 GitHub 标记为
@@ -19,20 +36,22 @@ prerelease,并使用如 `2.2.1-rc.1` 的预发布版本号。`main` 仅负责
19
36
  GitHub Release 和 tag。提交到 `main` 前,代码、文档、截图与验证必须全部完成;
20
37
  在 `main` 完成集成验证后才能发布正式版本。
21
38
  测试版本需显式安装,自动更新器只接受正式版本号。
22
- 当前 GitHub 正式版本为 **v2.2.1**,包含宠物大小、台词来源与菜单修复。
39
+ 当前 GitHub 正式版本为 **v2.3.0**,包含主菜单、多账号、按模型统计 Token 用量与原生运行时。
23
40
  验证和交接状态见[发布状态](docs/release-status.md)。
24
41
 
25
42
  ## 多语言
26
43
 
27
44
  界面文案在源码里写英文原文,这段原文就是其他各语言表的 key:
28
45
 
29
- - Objective-C:用户可见的字符串包在 `L(@"…")` 里(见 `Sources/CCPets/CCPetsL10n.h`)。
30
- 译文需要调换参数顺序时用 `%1$@` / `%2$@`。
31
- - Node.js:用 `scripts/i18n.mjs` 的 `t("…", { name })`,参数写成 `{name}` 占位。
32
- - zsh:用 `scripts/i18n.zsh` 的 `cc_pets_t "…" name="$value"`。原文必须是字面量,
33
- 变量一律写成 `{name}` 占位,不能直接拼进原文。
46
+ - Objective-C:用户可见的字符串包在 `L(@"…")` 里(见 `Sources/CCPets/Support/CCPetsL10n.h`)。
47
+ 译文需要调换参数顺序时用 `%1$@` / `%2$@`;命令行输出也可以写 `{name}` 占位,
48
+ 用 `CCPetsInterpolate(L(@"…"), @{…})` 填参数。
49
+ - zsh:用 `scripts/i18n.zsh` 的 `cc_pets_t "…" name="$value"`,查表交给原生的
50
+ `cc-pets --localize`。原文必须是字面量,变量一律写成 `{name}` 占位,不能直接拼进原文。
51
+
52
+ App、命令行工具和 zsh 脚本共用每种语言的一张表:`Resources/<语言>.lproj/Localizable.strings`。
34
53
 
35
- 新增或修改英文原文时,要同步更新每张表里的 key。`node scripts/check-l10n.mjs`(`npm test`
54
+ 新增或修改英文原文时,要同步更新每张表里的 key。`node tests/check-l10n.mjs`(`npm test`
36
55
  也会跑)会逐个语言报出缺翻译、多余条目和占位符不一致。
37
56
 
38
57
  ### 新增一种语言
@@ -43,11 +62,10 @@ GitHub Release 和 tag。提交到 `main` 前,代码、文档、截图与验
43
62
  填好两条元信息:`"Language Name"`(「语言」菜单里显示的名字,用该语言自己的写法)和
44
63
  `"Release Notes Section"`(GitHub Release 说明里该语言段落的标题,多种写法用 `|` 隔开)。
45
64
  2. `Resources/xx.lproj/InfoPlist.strings`:翻译 `NSAppleEventsUsageDescription`。
46
- 3. `scripts/locales/xx.json`:复制 `zh-Hans.json`,翻译 CLI 文案。
47
- 4. 可选:`Resources/phrases.default.xx.txt`,从 `phrases.default.en.txt` 翻译默认台词;
65
+ 3. 可选:`Resources/phrases.default.xx.txt`,从 `phrases.default.en.txt` 翻译默认台词;
48
66
  没有的话桌宠退回英文台词。
49
67
 
50
- `node scripts/check-l10n.mjs --missing xx` 会列出还没翻译的 key。App 按 `.lproj` 目录发现语言,
68
+ `node tests/check-l10n.mjs --missing xx` 会列出还没翻译的 key。App 按 `.lproj` 目录发现语言,
51
69
  `build.sh` 据此生成 `CFBundleLocalizations`,`package.json` 已按通配符包含这些文件。
52
70
 
53
71
  ### GitHub Release 说明