cc-pets 2.1.1 → 2.1.2
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/CC_BRIDGE.md +5 -0
- package/CC_BRIDGE.zh-CN.md +4 -0
- package/CHANGELOG.md +23 -1
- package/CHANGELOG.zh-CN.md +23 -1
- package/README.md +50 -12
- package/README.zh-CN.md +49 -13
- package/Sources/CCPets/CCPetsAppDelegate+AgentEvents.m +215 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +660 -0
- package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +297 -0
- package/Sources/CCPets/CCPetsAppDelegate+Pets.m +187 -0
- package/Sources/CCPets/CCPetsAppDelegate+Private.h +322 -0
- package/Sources/CCPets/CCPetsAppDelegate+Quota.m +216 -0
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +205 -0
- package/Sources/CCPets/CCPetsAppDelegate+Speech.m +392 -0
- package/Sources/CCPets/CCPetsAppDelegate+Update.m +458 -0
- package/Sources/CCPets/CCPetsAppDelegate.h +13 -14
- package/Sources/CCPets/CCPetsAppDelegate.m +49 -2453
- package/Sources/CCPets/CCPetsCleanup.h +4 -0
- package/Sources/CCPets/CCPetsCleanup.m +32 -1
- package/Sources/CCPets/CCPetsPaths.h +0 -1
- package/Sources/CCPets/CCPetsPaths.m +0 -1
- package/Sources/CCPets/CCPetsUsage.h +0 -1
- package/Sources/CCPets/CCPetsUsage.m +0 -3
- package/Sources/CCPets/CCPetsVersion.h +7 -0
- package/Sources/CCPets/CCPetsVersion.m +82 -0
- package/Sources/CCPets/PetView.h +2 -0
- package/Sources/CCPets/PetView.m +16 -4
- package/Sources/CCPets/QuotaDashboardView.m +0 -3
- package/Sources/CCPets/main.m +13 -0
- package/bin/cc-pets +7 -1
- package/package.json +3 -2
- package/scripts/bridge/cli.mjs +9 -2
- package/scripts/bridge/core.mjs +1 -1
- package/scripts/bridge/install.mjs +23 -1
- package/scripts/bridge/process.mjs +22 -0
- package/scripts/doctor.mjs +456 -0
- package/scripts/install-claude-hooks.mjs +12 -18
- package/scripts/install-codex-hooks.mjs +3 -9
- package/scripts/integration-markers.mjs +51 -0
- package/scripts/pet-store.mjs +2 -1
- package/scripts/uninstall-integrations.mjs +16 -44
- package/scripts/uninstall-shell-integration.sh +3 -3
package/CC_BRIDGE.md
CHANGED
|
@@ -188,6 +188,11 @@ The Claude Code watcher arms at session start and at the end of every turn, and
|
|
|
188
188
|
inbox and are included with the user's next prompt; messages that arrive during that turn are
|
|
189
189
|
delivered when it ends.
|
|
190
190
|
|
|
191
|
+
Waking Codex requires a Codex version with the `codex queue` subcommand. `cc-pets bridge enable`,
|
|
192
|
+
`cc-pets bridge status`, and `cc-pets doctor` check the installed version. Without it, CC Bridge
|
|
193
|
+
still works: messages to Codex wait in its inbox until it calls `check_inbox` or the user's next
|
|
194
|
+
prompt brings them in.
|
|
195
|
+
|
|
191
196
|
Senders get receipts such as "queued", "in inbox", or "undeliverable". Delivery does not mean
|
|
192
197
|
the recipient has read or agreed to anything.
|
|
193
198
|
|
package/CC_BRIDGE.zh-CN.md
CHANGED
|
@@ -167,6 +167,10 @@ Claude Code 的 watcher 在会话启动和每轮结束时挂上,每次最多
|
|
|
167
167
|
如果 Claude 会话在这段空窗期里一直空闲,消息会留在信箱,等用户下次输入时一并带入;
|
|
168
168
|
那一轮进行中新到的消息,在该轮结束时投递。
|
|
169
169
|
|
|
170
|
+
自动唤醒 Codex 需要支持 `codex queue` 子命令的 Codex 版本。`cc-pets bridge enable`、
|
|
171
|
+
`cc-pets bridge status` 与 `cc-pets doctor` 会检测当前版本;不支持时 CC Bridge 仍可使用,
|
|
172
|
+
发给 Codex 的消息会先进信箱,由对方调用 `check_inbox` 或在下次输入时带入。
|
|
173
|
+
|
|
170
174
|
发送方只会收到"已送达队列 / 已放入信箱 / 无法投递"这类回执。送达不代表对方已读,也不代表对方同意。
|
|
171
175
|
|
|
172
176
|
## 桌宠里的显示
|
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,31 @@ English | [简体中文](./CHANGELOG.zh-CN.md)
|
|
|
5
5
|
This project follows Semantic Versioning. `package.json` is the single source of
|
|
6
6
|
truth for the version.
|
|
7
7
|
|
|
8
|
+
## [2.1.2] - 2026-10-04
|
|
9
|
+
|
|
10
|
+
Update prompts through the pet, `cc-pets doctor` and `cc-pets paths`, plus cleanup fixes.
|
|
11
|
+
|
|
12
|
+
### Updates
|
|
13
|
+
|
|
14
|
+
- Check npm for a newer version 5 seconds after launch, and again when a CLI reopens a running pet (at most once every 10 minutes); failed checks stay silent.
|
|
15
|
+
- Announce a new version with a clickable speech bubble that shows up to three highlights from the matching GitHub Release. The bubble waits while an agent is busy, and with chatter on, idle speech now and then reminds you until you choose **Later**.
|
|
16
|
+
- Added a glass "↑" badge on the pet as a lasting entry point, and while a new version is available the right-click menu shows **Update to x.y.z…** at the top level; the update dialog lists highlights and links to the full release notes, and **About CC Pets** uses the same dialog style.
|
|
17
|
+
- **Check for Updates…** and **About CC Pets** moved into a new **Help** submenu.
|
|
18
|
+
|
|
19
|
+
### CLI
|
|
20
|
+
|
|
21
|
+
- Added `cc-pets doctor`, a read-only check of the installation: Node.js, matching versions of the npm package, native binary and installed app, Claude Code and Codex hooks (including hooks that still point to a moved package), the Claude status line, shell shims and `PATH` order, the real CLI binaries, the updater config, and CC Bridge. Each problem comes with a fix, and the output shows the home directory as `~` so it can be pasted into an issue.
|
|
22
|
+
- Added `cc-pets paths [--json]`, which lists where settings, pet assets, phrases, caches and runtime state live, how large each is, and what `clean` and `--purge` remove.
|
|
23
|
+
- `cc-pets clean` now also removes the pet store manifest cache in `~/.cc-pets/cache`.
|
|
24
|
+
- `cc-pets uninstall --purge` keeps your pet assets and phrases in `~/.cc-pets`, as it always did; the help text, confirmation prompt and README now say so instead of promising to remove all local data.
|
|
25
|
+
|
|
26
|
+
### CC Bridge
|
|
27
|
+
|
|
28
|
+
- `cc-pets bridge enable`, `cc-pets bridge status` and `cc-pets doctor` check whether the installed Codex supports `codex queue`. Without it, CC Bridge still turns on and messages to Codex wait in its inbox; upgrading Codex enables wake-up without re-enabling CC Bridge.
|
|
29
|
+
|
|
8
30
|
## [2.1.1] - 2026-09-30
|
|
9
31
|
|
|
10
|
-
Liquid Glass panel theme
|
|
32
|
+
Feature release: the native Liquid Glass panel theme and multi-terminal jump-back, plus quota fixes.
|
|
11
33
|
|
|
12
34
|
### Panels and menus
|
|
13
35
|
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,9 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
本项目遵循语义化版本号。版本号以 `package.json` 为唯一来源。
|
|
6
6
|
|
|
7
|
+
## [2.1.2] - 2026-10-04
|
|
8
|
+
|
|
9
|
+
桌宠提示新版本,新增 `cc-pets doctor` 与 `cc-pets paths`,以及清理相关修复。
|
|
10
|
+
|
|
11
|
+
### 更新
|
|
12
|
+
|
|
13
|
+
- 启动 5 秒后到 npm 检查新版本,CLI 再次唤起已运行的桌宠时也会检查(最多每 10 分钟一次);检查失败不打扰。
|
|
14
|
+
- 发现新版本时桌宠弹出可点击的气泡,附上对应 GitHub Release 中最多三条要点。Agent 忙碌时气泡会等待;开启碎碎念时,空闲台词会不时提醒,直到选择「稍后」。
|
|
15
|
+
- 桌宠上新增玻璃「↑」角标作为常驻入口;有新版本时,右键菜单顶层临时出现「更新到 x.y.z…」。更新对话框列出要点并可打开完整说明,「关于 CC Pets」改用同样的对话框样式。
|
|
16
|
+
- 「检查更新…」与「关于 CC Pets」收进右键菜单新增的「帮助」子菜单。
|
|
17
|
+
|
|
18
|
+
### 命令行
|
|
19
|
+
|
|
20
|
+
- 新增 `cc-pets doctor`:只读检查安装状态,包括 Node.js、npm 包 / 原生程序 / 已安装 App 的版本是否一致、Claude Code 与 Codex Hooks(含包被移动后仍指向旧位置的 Hooks)、Claude status line、shell shim 与 `PATH` 顺序、真实 CLI、自动更新配置和 CC Bridge。每个问题都给出修复命令;home 目录显示为 `~`,输出可直接贴进 issue。
|
|
21
|
+
- 新增 `cc-pets paths [--json]`:列出偏好、桌宠素材、台词、缓存与运行时状态的存放位置和大小,并注明 `clean` 与 `--purge` 各自会删除哪些。
|
|
22
|
+
- `cc-pets clean` 现在也会清理 `~/.cc-pets/cache` 中的素材清单缓存。
|
|
23
|
+
- `cc-pets uninstall --purge` 一直会保留 `~/.cc-pets` 中的桌宠素材与台词;帮助、确认提示和 README 现已如实说明,不再写"删除全部本地数据"。
|
|
24
|
+
|
|
25
|
+
### CC Bridge
|
|
26
|
+
|
|
27
|
+
- `cc-pets bridge enable`、`cc-pets bridge status` 与 `cc-pets doctor` 会检测当前 Codex 是否支持 `codex queue`。不支持时 CC Bridge 仍可开启,发给 Codex 的消息先进信箱;升级 Codex 后即可自动唤醒,无需重新开启。
|
|
28
|
+
|
|
7
29
|
## [2.1.1] - 2026-09-30
|
|
8
30
|
|
|
9
|
-
Liquid Glass
|
|
31
|
+
功能版本:原生 Liquid Glass 面板主题与多终端跳转,以及额度修复。
|
|
10
32
|
|
|
11
33
|
### 面板与菜单
|
|
12
34
|
|
package/README.md
CHANGED
|
@@ -1,22 +1,52 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/images/cover.png" alt="CC Pets v2.1.1: Liquid Glass theme and multi-terminal jump-back">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# CC Pets
|
|
2
6
|
|
|
3
7
|
English | [简体中文](./README.zh-CN.md)
|
|
4
8
|
|
|
5
|
-
A native macOS desktop pet for Codex CLI and Claude Code CLI
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
A native macOS desktop pet for Codex CLI and Claude Code CLI that needs neither
|
|
10
|
+
desktop app. Launch CC Pets directly, or let it appear automatically when Codex CLI
|
|
11
|
+
or Claude Code CLI starts. It reads five-hour and weekly quota data from the official
|
|
12
|
+
Codex App Server interface and Claude Code's official status line input.
|
|
8
13
|
|
|
9
14
|
> The application UI and the screenshots below are currently in Simplified Chinese.
|
|
10
|
-
> English UI localization and English screenshots are planned for
|
|
15
|
+
> English UI localization and English screenshots are planned for a future release.
|
|
16
|
+
|
|
17
|
+
## What's new in v2.1.2
|
|
18
|
+
|
|
19
|
+
- **Update prompts from the pet** — CC Pets checks npm for a newer version shortly after
|
|
20
|
+
launch. When one is available, the pet shows a clickable speech bubble with up to three
|
|
21
|
+
highlights from the GitHub Release, and the bubble waits while an agent is busy. A glass
|
|
22
|
+
"↑" badge on the pet and an **Update to x.y.z…** item at the top of the right-click menu
|
|
23
|
+
open the update dialog. **Check for Updates…** and **About CC Pets** now live under a new
|
|
24
|
+
**Help** submenu.
|
|
25
|
+
- **`cc-pets doctor`** — read-only checks of versions, Claude Code and Codex hooks, the
|
|
26
|
+
status line, shims and `PATH`, the updater and CC Bridge, with a fix for each problem.
|
|
27
|
+
The output shows your home directory as `~`, so you can paste it into an issue.
|
|
28
|
+
- **`cc-pets paths`** — lists where settings, pet assets, phrases, caches and runtime
|
|
29
|
+
state live, how large each is, and what `clean` and `uninstall --purge` remove
|
|
30
|
+
(`--json` for machine-readable output).
|
|
31
|
+
- **Fixes** — `cc-pets clean` also clears the pet store manifest cache, and CC Bridge now
|
|
32
|
+
tells you when the installed Codex lacks `codex queue`, in which case messages to Codex
|
|
33
|
+
wait in its inbox.
|
|
34
|
+
|
|
35
|
+
See the [changelog](./CHANGELOG.md) for the full list.
|
|
11
36
|
|
|
12
37
|
## Screenshots
|
|
13
38
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="docs/images/liquid-glass-panel.png" width="80%" alt="Quota panel, speech bubble and pet in the Liquid Glass theme, current Simplified Chinese UI">
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img src="docs/images/liquid-glass-menu.png" width="80%" alt="Right-click menu with the Panel theme submenu, current Simplified Chinese UI">
|
|
45
|
+
</p>
|
|
17
46
|
|
|
18
47
|
## Features
|
|
19
48
|
|
|
49
|
+
- Offers Classic and native Liquid Glass panel themes on macOS 26 and later.
|
|
20
50
|
- Starts with Codex CLI or Claude Code CLI and closes after the last managed CLI exits.
|
|
21
51
|
- Shares one pet across multiple simultaneous Codex and Claude sessions.
|
|
22
52
|
- Shows five-hour and weekly remaining quota, reset times, local token totals, and seven-day trends.
|
|
@@ -27,6 +57,7 @@ sessions and Claude Code's official status line input.
|
|
|
27
57
|
- Lists up to eight recent online Agent terminal sessions from the status card icon.
|
|
28
58
|
- Badges the status icon with the number of sessions waiting for approval and pins those sessions to the top of the list.
|
|
29
59
|
- Speaks up when an Agent sits in approval or thinking longer than its threshold.
|
|
60
|
+
- Announces new versions through the pet with release highlights and updates from the right-click menu.
|
|
30
61
|
- Supports optional local quota history and macOS notifications.
|
|
31
62
|
- Supports third-party CLI agents through a provider event protocol.
|
|
32
63
|
- Includes editable global and per-pet speech.
|
|
@@ -125,6 +156,8 @@ cc-pets --version # Print the installed version.
|
|
|
125
156
|
cc-pets --status # Print parsed Codex quota data.
|
|
126
157
|
cc-pets --history # Print local quota history as JSON.
|
|
127
158
|
cc-pets clean # Remove rebuildable state and caches.
|
|
159
|
+
cc-pets doctor # Check the installation and integrations, with fixes.
|
|
160
|
+
cc-pets paths # List where settings, caches and data are stored.
|
|
128
161
|
|
|
129
162
|
cc-pets pet search otter # Search the configured asset source.
|
|
130
163
|
cc-pets pet add boba # Install an asset into CC Pets' own directory.
|
|
@@ -137,7 +170,7 @@ cc-pets bridge enable # CC Bridge (experimental, off by default); see
|
|
|
137
170
|
cc-pets bridge status # Show CC Bridge state and online sessions.
|
|
138
171
|
cc-pets bridge disable # Remove CC Bridge integrations.
|
|
139
172
|
cc-pets uninstall # Remove integrations and restore the status line.
|
|
140
|
-
cc-pets uninstall --purge # Also remove the app
|
|
173
|
+
cc-pets uninstall --purge # Also remove the app, app data and preferences after confirmation; keeps assets and phrases in ~/.cc-pets.
|
|
141
174
|
cc-pets uninstall-app # Remove only ~/Applications/CC Pets.app.
|
|
142
175
|
|
|
143
176
|
codex-with-pet # Start the pet and enter Codex CLI.
|
|
@@ -179,7 +212,7 @@ prompts, command text, file contents, or model output.
|
|
|
179
212
|
| Hover on either body side | Directional interaction animation |
|
|
180
213
|
| Click | Playful response animation |
|
|
181
214
|
| Drag left or right | Directional drag animation |
|
|
182
|
-
| Right-click | Pet, notification, update, and exit menu |
|
|
215
|
+
| Right-click | Pet, notification, Help (update check and About), and exit menu |
|
|
183
216
|
|
|
184
217
|
The **Panel theme** submenu offers **Classic** and **Liquid Glass**. Classic is the
|
|
185
218
|
default. Changes apply immediately to the quota panel, status card, and speech
|
|
@@ -211,8 +244,12 @@ add 16-direction mouse tracking while idle.
|
|
|
211
244
|
|
|
212
245
|
## Quota and local usage data
|
|
213
246
|
|
|
214
|
-
Codex quota data comes from
|
|
215
|
-
|
|
247
|
+
Codex quota data comes from the official Codex App Server interface. CC Pets starts
|
|
248
|
+
the installed Codex CLI as `codex app-server --stdio`, reads the current windows with
|
|
249
|
+
`account/rateLimits/read`, and follows `account/rateLimits/updated` notifications. The
|
|
250
|
+
server-side values replace the rate-limit snapshots recorded in local `token_count`
|
|
251
|
+
events under `~/.codex/sessions`; a local snapshot is used only when it is newer than
|
|
252
|
+
the last server value. A `window_minutes` value of `300` is the five-hour window and
|
|
216
253
|
`10080` is the weekly window. CC Pets displays remaining percentage and does not
|
|
217
254
|
substitute expired history when a current window is unavailable.
|
|
218
255
|
|
|
@@ -311,11 +348,12 @@ external assets.
|
|
|
311
348
|
|
|
312
349
|
## Privacy
|
|
313
350
|
|
|
314
|
-
-
|
|
351
|
+
- Codex quota is read through the official Codex App Server started from your installed Codex CLI with its existing sign-in; Claude quota comes from the status line input Claude Code passes locally. Token counts are read from local Codex and Claude Code files.
|
|
315
352
|
- Hooks write only redacted state events and quota cache files to the current user's temporary directory.
|
|
316
353
|
- Local quota history is disabled by default and retains seven days when enabled.
|
|
317
354
|
- Status cards and notifications show only provider, state, and redacted tool category.
|
|
318
355
|
- CC Pets contains no telemetry and uploads no conversations, quotas, credentials, or usage statistics.
|
|
356
|
+
- On launch, and when a CLI reopens the running pet, CC Pets asks the npm registry for the latest version (at most once every 10 minutes per run); only when a newer version exists does it read that version's release notes from the GitHub API. These requests carry no account or usage data.
|
|
319
357
|
- Exiting the pet or running `cc-pets uninstall` leaves no background daemon running.
|
|
320
358
|
- [CC Bridge](./CC_BRIDGE.md) is off by default. When enabled, messages between sessions are stored
|
|
321
359
|
in the current user's temporary directory (owner-only, 24-hour expiry); it is the only feature
|
package/README.zh-CN.md
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/images/cover.png" alt="CC Pets v2.1.1:Liquid Glass 主题与多终端回跳">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# CC Pets
|
|
2
6
|
|
|
3
7
|
[English](./README.md) | 简体中文
|
|
4
8
|
|
|
5
|
-
一个不依赖 Codex/Claude 桌面端的 macOS
|
|
6
|
-
|
|
9
|
+
一个不依赖 Codex/Claude 桌面端的 macOS 原生桌宠。直接启动桌面端,或启动 Codex CLI / Claude Code CLI 时自动出现,
|
|
10
|
+
并通过 Codex App Server 官方接口与 Claude Code 官方 status line 数据读取 5 小时额度、周额度和周重置时间。
|
|
7
11
|
|
|
8
|
-
##
|
|
12
|
+
## v2.1.2 新功能
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
- **桌宠提示新版本**:启动后不久自动到 npm 检查新版本。有新版本时,桌宠弹出可点击的气泡,附上
|
|
15
|
+
GitHub Release 中最多三条要点;Agent 忙碌时气泡会等待。桌宠上的玻璃「↑」角标和右键菜单顶层的
|
|
16
|
+
「更新到 x.y.z…」都能直接打开更新对话框。「检查更新…」与「关于 CC Pets」收进新的「帮助」子菜单。
|
|
17
|
+
- **`cc-pets doctor`**:只读检查版本、Claude Code 与 Codex Hooks、status line、shim 与 `PATH`、
|
|
18
|
+
自动更新和 CC Bridge,每个问题都附修复命令;home 目录显示为 `~`,输出可直接贴进 issue。
|
|
19
|
+
- **`cc-pets paths`**:列出偏好、桌宠素材、台词、缓存与运行时状态的位置和大小,并注明 `clean`
|
|
20
|
+
与 `uninstall --purge` 各自删除哪些(`--json` 输出机器可读格式)。
|
|
21
|
+
- **修复**:`cc-pets clean` 会一并清理素材清单缓存;当前 Codex 不支持 `codex queue` 时,CC Bridge
|
|
22
|
+
会明确提示,发给 Codex 的消息先进信箱。
|
|
23
|
+
|
|
24
|
+
完整改动见 [更新记录](./CHANGELOG.zh-CN.md)。
|
|
25
|
+
|
|
26
|
+
## 界面预览
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<img src="docs/images/liquid-glass-panel.png" width="80%" alt="Liquid Glass 主题下的额度面板、说话气泡与桌宠">
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="docs/images/liquid-glass-menu.png" width="80%" alt="右键菜单中的面板主题子菜单">
|
|
34
|
+
</p>
|
|
13
35
|
|
|
14
36
|
## 功能
|
|
15
37
|
|
|
38
|
+
- macOS 26 及以上可在经典与原生 Liquid Glass 两种面板主题之间切换
|
|
16
39
|
- 随 Codex CLI 或 Claude Code CLI 自动启动,无需打开对应桌面版
|
|
17
40
|
- 多个 Codex/Claude CLI 共用一个桌宠,最后一个 CLI 退出后桌宠自动关闭
|
|
18
41
|
- 鼠标悬停口袋时展开额度详情面板,用两张卡分别显示 Codex、Claude 的剩余 5 小时额度、周额度和精确到秒的周重置时间
|
|
@@ -20,7 +43,8 @@
|
|
|
20
43
|
- 支持待机、左右拖动、身体两侧感应、头部/脚部悬停和点击反馈动画
|
|
21
44
|
- 待机呼吸、随机小动作(11 行素材会转头看鼠标)、拖动时的水平滞后与落脚回弹
|
|
22
45
|
- 桌宠以自己的口吻播报 Agent 状态,闲着时还会自己碎碎念,台词和频率都可自定义
|
|
23
|
-
-
|
|
46
|
+
- 支持拖动桌宠位置,右键「帮助」中检查更新或查看关于;用量定时自动刷新
|
|
47
|
+
- 发现新版本时桌宠用气泡提醒并附上更新要点,点击即可打开更新对话框
|
|
24
48
|
- 响应 Codex 与 Claude Code Agent 的思考、工具调用、审批、子 Agent、完成和失败状态
|
|
25
49
|
- 在桌宠旁显示脱敏后的玻璃 Agent 状态卡片,可展开、折叠并显示活跃 CLI 会话数
|
|
26
50
|
- 点击任意 Hook 状态卡,可返回触发该事件的终端;直接启动、没走包装脚本的会话同样可以回跳
|
|
@@ -83,7 +107,7 @@ JetBrains IDE、Warp、WezTerm、Ghostty 等在不安装扩展的模式下仅激
|
|
|
83
107
|
| 按住并向右拖动 | 播放向右拖行动画,同时移动桌宠 |
|
|
84
108
|
| 按住并向左拖动 | 播放向左拖行动画,同时移动桌宠 |
|
|
85
109
|
| 鼠标移开或拖动结束 | 恢复默认待机动画 |
|
|
86
|
-
| 右键桌宠 |
|
|
110
|
+
| 右键桌宠 | 切换桌宠、设置历史/通知、在「帮助」中检查更新或查看关于、退出 |
|
|
87
111
|
|
|
88
112
|
右键菜单「面板主题」提供「经典」和「Liquid Glass」,默认使用经典样式。
|
|
89
113
|
选择后立即应用于额度面板、状态条和说话气泡,并在重启后保留。Liquid Glass 使用系统原生玻璃,
|
|
@@ -338,7 +362,8 @@ npm 的安装后脚本会自动构建原生应用、安装两套 Agent Hooks,
|
|
|
338
362
|
同时会将标准 macOS 应用安装到 `~/Applications/CC Pets.app`,可从 Finder 或 Launchpad 启动,
|
|
339
363
|
不需要管理员权限。npm 升级时会同步更新该应用。
|
|
340
364
|
|
|
341
|
-
|
|
365
|
+
桌宠启动后会自动检查新版本,发现后用气泡提醒;也可以右键桌宠并选择「帮助 → 检查更新…」;已发现新版本时,右键菜单顶层会直接出现「更新到 x.y.z…」。
|
|
366
|
+
应用会查询 npm Registry,发现新版本后请求确认,
|
|
342
367
|
随后在后台复用首次安装时记录的 Node.js/npm 完成升级;用户无需打开终端。升级会同步更新原生应用、
|
|
343
368
|
Codex/Claude Hooks 和 shell 集成,并自动重启正在运行的桌宠。自动更新不会请求管理员权限;如果原来的
|
|
344
369
|
全局 npm 目录不可写或 Node.js/npm 已被移动,应用会保留旧版本并显示更新日志和手动升级命令。
|
|
@@ -381,9 +406,15 @@ cc-pets --status
|
|
|
381
406
|
# 查看本机额度历史 JSON
|
|
382
407
|
cc-pets --history
|
|
383
408
|
|
|
384
|
-
#
|
|
409
|
+
# 清理可重建的临时状态、更新日志、素材清单缓存和构建缓存,保留历史、配置与偏好
|
|
385
410
|
cc-pets clean
|
|
386
411
|
|
|
412
|
+
# 检查安装、Hooks、status line、shim 与 CC Bridge 是否正常,并给出修复建议;输出已脱敏,可直接贴进 issue
|
|
413
|
+
cc-pets doctor
|
|
414
|
+
|
|
415
|
+
# 列出偏好、桌宠素材、台词、缓存与运行时状态的存放位置和大小(--json 输出机器可读格式)
|
|
416
|
+
cc-pets paths
|
|
417
|
+
|
|
387
418
|
# 管理 ~/.cc-pets/pets 里的桌宠素材,详见「素材与版权」
|
|
388
419
|
cc-pets pet search otter
|
|
389
420
|
cc-pets pet add boba
|
|
@@ -407,7 +438,7 @@ cc-pets --help
|
|
|
407
438
|
# 安全移除 Hooks、恢复 Claude status line,并清理 shell 集成
|
|
408
439
|
cc-pets uninstall
|
|
409
440
|
|
|
410
|
-
#
|
|
441
|
+
# 完整移除集成、应用、应用数据和偏好;执行前会再次确认。~/.cc-pets 下的桌宠素材与台词会保留
|
|
411
442
|
cc-pets uninstall --purge
|
|
412
443
|
|
|
413
444
|
# 仅删除 ~/Applications 中的 macOS 应用(不会删除 npm 包或 Hooks)
|
|
@@ -426,7 +457,11 @@ claude-with-pet
|
|
|
426
457
|
|
|
427
458
|
## 用量数据
|
|
428
459
|
|
|
429
|
-
Codex
|
|
460
|
+
Codex 额度来自 Codex App Server 官方接口:桌宠用本机已安装的 Codex CLI 启动
|
|
461
|
+
`codex app-server --stdio`,通过 `account/rateLimits/read` 读取当前额度窗口,并订阅
|
|
462
|
+
`account/rateLimits/updated` 推送。服务端返回的额度会覆盖 `~/.codex/sessions` 本地
|
|
463
|
+
`token_count` 事件里记录的额度快照;只有本地快照比最近一次服务端数据更新时才使用本地值。
|
|
464
|
+
本地 Token 统计仍来自 `token_count` 事件:
|
|
430
465
|
|
|
431
466
|
- `window_minutes = 300` 对应 5 小时额度
|
|
432
467
|
- `window_minutes = 10080` 对应周额度
|
|
@@ -598,12 +633,13 @@ PetDex 官方 CLI(`npx petdex install <slug>`)会把素材放在 `~/.petdex/
|
|
|
598
633
|
|
|
599
634
|
## 隐私
|
|
600
635
|
|
|
601
|
-
- Codex
|
|
636
|
+
- Codex 额度通过本机 Codex CLI 启动的官方 App Server 读取,沿用 Codex CLI 自身的登录状态;Codex Token 只从本机 `~/.codex/sessions` 读取(可用 `CC_PETS_CODEX_HOME` 覆盖)。
|
|
602
637
|
- Claude 额度只从 Claude Code 传给本机 status line 的 `rate_limits` 字段读取。
|
|
603
638
|
- Agent Hooks 只向当前用户的临时目录写入桌宠事件和额度缓存。
|
|
604
639
|
- 额度历史默认关闭;启用后只在本机保留最近 7 天的剩余比例快照。
|
|
605
640
|
- 状态气泡和通知只显示 Provider、状态及脱敏工具类别,不显示会话正文。
|
|
606
641
|
- 项目不上传会话内容、额度、凭据或使用统计,也不包含遥测服务。
|
|
642
|
+
- 桌宠启动时及 CLI 再次唤起桌宠时会向 npm Registry 查询最新版本号(同一次运行内最多每 10 分钟一次);仅在有新版本时再向 GitHub API 读取该版本的 Release 说明。请求不携带任何账号或使用数据。
|
|
607
643
|
- 右键“退出桌宠”或执行 `cc-pets uninstall` 后,不会继续运行后台守护进程。
|
|
608
644
|
- [CC Bridge](./CC_BRIDGE.zh-CN.md) 默认关闭;开启后,会话之间的消息正文会保存在当前用户的临时目录
|
|
609
645
|
(仅本人可读,24 小时过期),这是本项目唯一会保存正文的功能。
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// agent 事件流读取与客户端存活检测。
|
|
2
|
+
#import "CCPetsAppDelegate+Private.h"
|
|
3
|
+
|
|
4
|
+
// 客户端是否真的还在跑。只问 kill(pid, 0) 不够:关掉终端窗口只是销毁 pty,claude /
|
|
5
|
+
// codex(Node 进程)不一定跟着 SIGHUP 退出,会变成脱离控制终端的孤儿继续活着。那样
|
|
6
|
+
// pid 一直存在,会话就永久挂在"在线"上,最近会话列表里那条也永远不消失。
|
|
7
|
+
// 所以再看两件事:进程是否还有控制终端;以及它是不是仍然是 pid 文件里记的那个 TTY
|
|
8
|
+
// (pty 会被新开的窗口复用,光看"有 tty"挡不住换了主人的情况)。
|
|
9
|
+
// recordedTTY 为空是 1.0.2 及更早的老客户端,只能退回"有控制终端"这一条。
|
|
10
|
+
static BOOL ClientProcessAlive(pid_t pid, NSString *recordedTTY) {
|
|
11
|
+
if (pid <= 1) return NO;
|
|
12
|
+
struct kinfo_proc info;
|
|
13
|
+
size_t length = sizeof(info);
|
|
14
|
+
int name[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
|
|
15
|
+
if (sysctl(name, 4, &info, &length, NULL, 0) != 0 || length == 0) return NO;
|
|
16
|
+
if (info.kp_proc.p_stat == SZOMB) return NO;
|
|
17
|
+
dev_t device = info.kp_eproc.e_tdev;
|
|
18
|
+
if (device == NODEV) return NO;
|
|
19
|
+
if (recordedTTY.length == 0) return YES;
|
|
20
|
+
const char *current = devname(device, S_IFCHR);
|
|
21
|
+
if (!current) return NO;
|
|
22
|
+
return [recordedTTY isEqualToString:@(current).lastPathComponent];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@implementation AppDelegate (AgentEvents)
|
|
26
|
+
- (void)prepareAgentEventReader {
|
|
27
|
+
NSString *path = AgentEventPath();
|
|
28
|
+
NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:path error:nil];
|
|
29
|
+
unsigned long long size = [attributes[NSFileSize] unsignedLongLongValue];
|
|
30
|
+
if (self.agentEventReaderInitialized) {
|
|
31
|
+
if (size < self.agentEventOffset) {
|
|
32
|
+
self.agentEventOffset = 0;
|
|
33
|
+
[self.agentEventPartialLine setLength:0];
|
|
34
|
+
}
|
|
35
|
+
[self readNewAgentEvents];
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
self.agentEventReaderInitialized = YES;
|
|
39
|
+
self.agentEventOffset = size;
|
|
40
|
+
if (size > 0) {
|
|
41
|
+
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
|
|
42
|
+
unsigned long long start = size > 65536 ? size - 65536 : 0;
|
|
43
|
+
[handle seekToFileOffset:start];
|
|
44
|
+
NSData *recent = [handle readDataToEndOfFile];
|
|
45
|
+
[handle closeFile];
|
|
46
|
+
[self processAgentEventData:recent ignoreFirstPartial:start > 0 recentOnly:YES];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
- (void)consumeAgentEventData:(NSData *)data {
|
|
50
|
+
if (data.length == 0) return;
|
|
51
|
+
[self.agentEventPartialLine appendData:data];
|
|
52
|
+
const uint8_t *bytes = self.agentEventPartialLine.bytes;
|
|
53
|
+
NSUInteger lineStart = 0;
|
|
54
|
+
for (NSUInteger index = 0; index < self.agentEventPartialLine.length; index++) {
|
|
55
|
+
if (bytes[index] != '\n') continue;
|
|
56
|
+
NSData *lineData = [self.agentEventPartialLine subdataWithRange:NSMakeRange(lineStart, index - lineStart)];
|
|
57
|
+
[self processAgentEventData:lineData ignoreFirstPartial:NO recentOnly:NO];
|
|
58
|
+
lineStart = index + 1;
|
|
59
|
+
}
|
|
60
|
+
if (lineStart > 0) {
|
|
61
|
+
NSData *remainder = [self.agentEventPartialLine subdataWithRange:
|
|
62
|
+
NSMakeRange(lineStart, self.agentEventPartialLine.length - lineStart)];
|
|
63
|
+
self.agentEventPartialLine = [remainder mutableCopy];
|
|
64
|
+
}
|
|
65
|
+
if (self.agentEventPartialLine.length > 1024 * 1024) [self.agentEventPartialLine setLength:0];
|
|
66
|
+
}
|
|
67
|
+
- (void)processAgentEventData:(NSData *)data ignoreFirstPartial:(BOOL)ignoreFirstPartial recentOnly:(BOOL)recentOnly {
|
|
68
|
+
NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
69
|
+
if (!text) return;
|
|
70
|
+
NSArray<NSString *> *lines = [text componentsSeparatedByString:@"\n"];
|
|
71
|
+
NSTimeInterval cutoff = [NSDate.date timeIntervalSince1970] - 5;
|
|
72
|
+
for (NSUInteger index = 0; index < lines.count; index++) {
|
|
73
|
+
if (ignoreFirstPartial && index == 0) continue;
|
|
74
|
+
NSData *lineData = [lines[index] dataUsingEncoding:NSUTF8StringEncoding];
|
|
75
|
+
if (lineData.length == 0) continue;
|
|
76
|
+
NSDictionary *record = [NSJSONSerialization JSONObjectWithData:lineData options:0 error:nil];
|
|
77
|
+
if (![record isKindOfClass:NSDictionary.class]) continue;
|
|
78
|
+
if (recentOnly && [record[@"timestamp"] doubleValue] < cutoff) continue;
|
|
79
|
+
[self trackAgentSessionRecord:record];
|
|
80
|
+
NSString *event = record[@"event"];
|
|
81
|
+
NSString *state = [record[@"state"] isKindOfClass:NSString.class] ? record[@"state"] : @"";
|
|
82
|
+
if ([event isKindOfClass:NSString.class]) {
|
|
83
|
+
if (!self.pendingApprovalRecords) {
|
|
84
|
+
self.pendingApprovalRecords = [NSMutableDictionary dictionary];
|
|
85
|
+
}
|
|
86
|
+
[self prunePendingApprovalRecords];
|
|
87
|
+
NSString *approvalKey = [self approvalKeyForRecord:record];
|
|
88
|
+
BOOL manualApproval = [state isEqualToString:@"approval"];
|
|
89
|
+
if (manualApproval) {
|
|
90
|
+
self.pendingApprovalRecords[approvalKey] = record;
|
|
91
|
+
} else {
|
|
92
|
+
[self.pendingApprovalRecords removeObjectForKey:approvalKey];
|
|
93
|
+
}
|
|
94
|
+
[self prunePendingApprovalRecords];
|
|
95
|
+
// 多会话下不能让一个未处理的审批全局挡住其他 Agent 的所有 Hook。每条事件
|
|
96
|
+
// 都正常驱动气泡和动画;仍在等待的审批保留在多会话记录中供用户回跳。
|
|
97
|
+
[self displayAgentRecord:record notify:YES];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
[self refreshApprovalBadge];
|
|
101
|
+
}
|
|
102
|
+
- (void)readNewAgentEvents {
|
|
103
|
+
NSString *path = AgentEventPath();
|
|
104
|
+
NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:path error:nil];
|
|
105
|
+
unsigned long long size = [attributes[NSFileSize] unsignedLongLongValue];
|
|
106
|
+
if (size < self.agentEventOffset) self.agentEventOffset = 0;
|
|
107
|
+
if (size == self.agentEventOffset) return;
|
|
108
|
+
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
|
|
109
|
+
if (!handle) return;
|
|
110
|
+
unsigned long long start = self.agentEventOffset;
|
|
111
|
+
[handle seekToFileOffset:start];
|
|
112
|
+
NSData *data = [handle readDataToEndOfFile];
|
|
113
|
+
[handle closeFile];
|
|
114
|
+
self.agentEventOffset = start + data.length;
|
|
115
|
+
[self consumeAgentEventData:data];
|
|
116
|
+
}
|
|
117
|
+
- (void)startAgentEventReader {
|
|
118
|
+
if (self.agentEventSource) return;
|
|
119
|
+
NSString *path = AgentEventPath();
|
|
120
|
+
[NSFileManager.defaultManager createDirectoryAtPath:path.stringByDeletingLastPathComponent
|
|
121
|
+
withIntermediateDirectories:YES attributes:nil error:nil];
|
|
122
|
+
int creator = open(path.fileSystemRepresentation, O_CREAT | O_WRONLY | O_CLOEXEC, S_IRUSR | S_IWUSR);
|
|
123
|
+
if (creator >= 0) close(creator);
|
|
124
|
+
int descriptor = open(path.fileSystemRepresentation, O_EVTONLY | O_CLOEXEC);
|
|
125
|
+
if (descriptor < 0) return;
|
|
126
|
+
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, descriptor,
|
|
127
|
+
DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_DELETE |
|
|
128
|
+
DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE,
|
|
129
|
+
dispatch_get_main_queue());
|
|
130
|
+
if (!source) {
|
|
131
|
+
close(descriptor);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
self.agentEventSource = source;
|
|
135
|
+
__weak typeof(self) weakSelf = self;
|
|
136
|
+
dispatch_source_set_event_handler(source, ^{
|
|
137
|
+
typeof(self) strongSelf = weakSelf;
|
|
138
|
+
if (!strongSelf) return;
|
|
139
|
+
dispatch_source_t currentSource = strongSelf.agentEventSource;
|
|
140
|
+
if (!currentSource) return;
|
|
141
|
+
unsigned long flags = dispatch_source_get_data(currentSource);
|
|
142
|
+
[strongSelf readNewAgentEvents];
|
|
143
|
+
if (flags & (DISPATCH_VNODE_DELETE | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE)) {
|
|
144
|
+
strongSelf.agentEventSource = nil;
|
|
145
|
+
dispatch_source_cancel(currentSource);
|
|
146
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 100 * NSEC_PER_MSEC),
|
|
147
|
+
dispatch_get_main_queue(), ^{ [weakSelf startAgentEventReader]; });
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
dispatch_source_set_cancel_handler(source, ^{ close(descriptor); });
|
|
151
|
+
dispatch_resume(source);
|
|
152
|
+
[self prepareAgentEventReader];
|
|
153
|
+
}
|
|
154
|
+
- (void)ensureAgentEventReader:(id)sender {
|
|
155
|
+
if (!self.agentEventSource) [self startAgentEventReader];
|
|
156
|
+
}
|
|
157
|
+
- (void)refreshClientLifecycle:(id)sender {
|
|
158
|
+
[self considerIdleSpeech];
|
|
159
|
+
[self prunePendingApprovalRecords];
|
|
160
|
+
NSString *clientName = [NSString stringWithFormat:@"cc-pets-%u-clients", getuid()];
|
|
161
|
+
NSString *clientDirectory = [PetStateDirectory() stringByAppendingPathComponent:clientName];
|
|
162
|
+
NSArray<NSString *> *entries = [NSFileManager.defaultManager contentsOfDirectoryAtPath:clientDirectory error:nil] ?: @[];
|
|
163
|
+
NSInteger liveClients = 0;
|
|
164
|
+
NSMutableSet<NSString *> *providers = [NSMutableSet set];
|
|
165
|
+
NSMutableSet<NSString *> *sessionKeys = [NSMutableSet set];
|
|
166
|
+
BOOL unlabeled = NO;
|
|
167
|
+
for (NSString *entry in entries) {
|
|
168
|
+
pid_t pid = (pid_t)entry.intValue;
|
|
169
|
+
NSString *path = [clientDirectory stringByAppendingPathComponent:entry];
|
|
170
|
+
// 包装脚本会把 provider 名写进 pid 文件第一行、TTY 写进第二行。1.0.2 及更早
|
|
171
|
+
// 的版本只 touch 出空文件,升级后仍在运行的老客户端读出来是空的:这类当作
|
|
172
|
+
// “身份不明”,只要还有一个就不清场,避免把仍然活着的会话误判成已退出。
|
|
173
|
+
NSString *contents = [NSString stringWithContentsOfFile:path
|
|
174
|
+
encoding:NSUTF8StringEncoding error:nil] ?: @"";
|
|
175
|
+
NSArray<NSString *> *lines = [contents componentsSeparatedByCharactersInSet:
|
|
176
|
+
NSCharacterSet.newlineCharacterSet];
|
|
177
|
+
NSString *label = [lines.firstObject
|
|
178
|
+
stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
|
179
|
+
NSString *tty = lines.count > 1 ? [lines[1]
|
|
180
|
+
stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet] : @"";
|
|
181
|
+
if (!ClientProcessAlive(pid, tty)) {
|
|
182
|
+
[NSFileManager.defaultManager removeItemAtPath:path error:nil];
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
liveClients += 1;
|
|
186
|
+
if (label.length > 0 && label.length <= 32) [providers addObject:label];
|
|
187
|
+
else unlabeled = YES;
|
|
188
|
+
NSString *sessionKey = [self onlineAgentSessionKeyForProvider:label tty:tty];
|
|
189
|
+
if (sessionKey.length > 0) [sessionKeys addObject:sessionKey];
|
|
190
|
+
}
|
|
191
|
+
// 包装脚本启动的客户端有精确的退出信号:pid 文件被回收。这一段不该被为"直接跑
|
|
192
|
+
// claude / codex"准备的 60 秒活跃度宽限盖住,否则退出后还要挂满一分钟才转离线。
|
|
193
|
+
// 因此某一家的 pid 文件一旦从有变无,立刻丢掉它的活跃度记录;从来没有过 pid 文件
|
|
194
|
+
// 的(直接启动)不受影响,继续走宽限。
|
|
195
|
+
NSSet<NSString *> *previousProviders = self.liveClientProviders;
|
|
196
|
+
self.liveClientCount = liveClients;
|
|
197
|
+
self.liveClientProviders = providers;
|
|
198
|
+
self.liveAgentSessionKeys = sessionKeys;
|
|
199
|
+
self.hasUnlabeledClient = unlabeled;
|
|
200
|
+
[self pruneOfflineAgentSessionRecords];
|
|
201
|
+
for (NSString *provider in previousProviders) {
|
|
202
|
+
if (![providers containsObject:provider]) {
|
|
203
|
+
[self.providerActivityAt removeObjectForKey:provider];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
[self updateQuotaLiveState];
|
|
207
|
+
[self refreshDetectedProviders];
|
|
208
|
+
[self hideAgentStatusIfClientGone];
|
|
209
|
+
[self checkStalledAgentSessions];
|
|
210
|
+
[self refreshApprovalBadge];
|
|
211
|
+
// 启动模式在应用生命周期内保持不变。手动启动的桌宠即使后来检测到
|
|
212
|
+
// Codex/Claude 客户端,也不应被转成 CLI 托管模式并随客户端退出。
|
|
213
|
+
if (liveClients == 0 && self.managedByCLI) [NSApp terminate:nil];
|
|
214
|
+
}
|
|
215
|
+
@end
|