cc-pets 2.0.0 → 2.0.3

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 (37) hide show
  1. package/CHANGELOG.md +73 -30
  2. package/CHANGELOG.zh-CN.md +90 -0
  3. package/CONTRIBUTING.md +18 -15
  4. package/CONTRIBUTING.zh-CN.md +22 -0
  5. package/LICENSE +1 -1
  6. package/PROVIDER_PROTOCOL.md +50 -41
  7. package/PROVIDER_PROTOCOL.zh-CN.md +58 -0
  8. package/README.md +240 -502
  9. package/README.zh-CN.md +617 -0
  10. package/Resources/Info.plist +2 -0
  11. package/Resources/phrases.default.txt +48 -49
  12. package/SECURITY.md +13 -10
  13. package/SECURITY.zh-CN.md +18 -0
  14. package/Sources/CCPets/CCPetsAppDelegate.h +12 -0
  15. package/Sources/CCPets/CCPetsAppDelegate.m +400 -37
  16. package/Sources/CCPets/CCPetsCodexRateLimits.h +13 -0
  17. package/Sources/CCPets/CCPetsCodexRateLimits.m +383 -0
  18. package/Sources/CCPets/CCPetsEvents.m +7 -2
  19. package/Sources/CCPets/CCPetsPaths.h +4 -0
  20. package/Sources/CCPets/CCPetsPaths.m +6 -0
  21. package/Sources/CCPets/CCPetsPhrases.h +1 -24
  22. package/Sources/CCPets/CCPetsPhrases.m +1 -82
  23. package/Sources/CCPets/CCPetsPhrasesEditor.m +0 -28
  24. package/Sources/CCPets/CCPetsQuotaHistory.m +12 -5
  25. package/Sources/CCPets/CCPetsTerminalFocus.h +11 -0
  26. package/Sources/CCPets/CCPetsTerminalFocus.m +150 -0
  27. package/Sources/CCPets/CCPetsUsage.m +135 -14
  28. package/Sources/CCPets/CCPetsUsageMonitor.m +41 -3
  29. package/Sources/CCPets/PetView.m +19 -11
  30. package/Sources/CCPets/QuotaDashboardView.m +38 -16
  31. package/Sources/CCPets/main.m +5 -0
  32. package/THIRD_PARTY_NOTICES.md +13 -7
  33. package/THIRD_PARTY_NOTICES.zh-CN.md +12 -0
  34. package/bin/claude-with-pet +8 -2
  35. package/bin/codex-with-pet +8 -3
  36. package/package.json +14 -5
  37. package/scripts/pet-store.mjs +1 -1
@@ -7,6 +7,7 @@
7
7
  #import "CCPetsUsage.h"
8
8
  #import "CCPetsVersion.h"
9
9
  #import "CCPetsCleanup.h"
10
+ #import "CCPetsTerminalFocus.h"
10
11
  #import <sys/file.h>
11
12
  #import <sys/stat.h>
12
13
  #import <fcntl.h>
@@ -37,6 +38,10 @@ int main(int argc, const char *argv[]) {
37
38
  return RestartAfterPID(pid, appPath, managed);
38
39
  }
39
40
  if (argc > 1 && strcmp(argv[1], "--hook") == 0) return RecordHookEvent();
41
+ if (argc > 1 && strcmp(argv[1], "--frontmost-bundle-id") == 0) {
42
+ puts(FrontmostApplicationBundleIdentifier().UTF8String);
43
+ return EXIT_SUCCESS;
44
+ }
40
45
  if (argc > 1 && (strcmp(argv[1], "--provider-event") == 0 ||
41
46
  strcmp(argv[1], "provider-event") == 0)) return RecordProviderEvent();
42
47
  if (argc > 1 && strcmp(argv[1], "--claude-usage") == 0) return RecordClaudeUsage();
@@ -1,11 +1,17 @@
1
- # 第三方声明
1
+ # Third-Party Notices
2
2
 
3
- CC Pets 发布包不捆绑 PetDex 下载的角色素材。内置的 `默认.webp` 是专为本项目创建的
4
- 原创默认素材,与任何现有动漫、游戏或商业吉祥物无关,并与项目代码一同按 MIT License 分发。
3
+ English | [简体中文](./THIRD_PARTY_NOTICES.zh-CN.md)
5
4
 
6
- 程序会在运行时尝试读取用户本机已安装的 Codex/ChatGPT 和 Claude 应用图标,仅用于界面识别;
7
- 这些图标不会复制进仓库或 npm 发布包,其商标和版权归各自权利人所有。
5
+ The CC Pets distribution does not bundle character assets downloaded from PetDex.
6
+ The built-in `默认.webp` is an original default asset created for this project. It
7
+ is unrelated to any existing anime, game, or commercial mascot and is distributed
8
+ with the project code under the MIT License.
8
9
 
9
- 用户通过 PetDex 或其他来源安装的素材由用户自行管理,不属于本项目发布内容。使用和再分发
10
- 此类素材时,请遵守对应作者、平台和权利人的许可证及使用条款。
10
+ At runtime, the app may read locally installed Codex/ChatGPT and Claude application
11
+ icons for interface identification. Those icons are not copied into this repository
12
+ or the npm package. Their trademarks and copyrights belong to their respective
13
+ owners.
11
14
 
15
+ Assets installed by users from PetDex or other sources are managed by those users
16
+ and are not part of this project distribution. Follow the applicable author,
17
+ platform, and rights-holder licenses and terms when using or redistributing them.
@@ -0,0 +1,12 @@
1
+ # 第三方声明
2
+
3
+ [English](./THIRD_PARTY_NOTICES.md) | 简体中文
4
+
5
+ CC Pets 发布包不捆绑 PetDex 下载的角色素材。内置的 `默认.webp` 是专为本项目创建的
6
+ 原创默认素材,与任何现有动漫、游戏或商业吉祥物无关,并与项目代码一同按 MIT License 分发。
7
+
8
+ 程序会在运行时尝试读取用户本机已安装的 Codex/ChatGPT 和 Claude 应用图标,仅用于界面识别;
9
+ 这些图标不会复制进仓库或 npm 发布包,其商标和版权归各自权利人所有。
10
+
11
+ 用户通过 PetDex 或其他来源安装的素材由用户自行管理,不属于本项目发布内容。使用和再分发
12
+ 此类素材时,请遵守对应作者、平台和权利人的许可证及使用条款。
@@ -41,9 +41,15 @@ if [[ -d "${INSTALLED_APP}" ]]; then
41
41
  PET_APP="${INSTALLED_APP}"
42
42
  fi
43
43
 
44
+ # 固定 Agent 所在终端;后续所有 Hook 都会继承,用户中途切换应用也不会改错目标。
45
+ export CC_PETS_TERMINAL_TTY="${TTY:-}"
46
+ export CC_PETS_TERMINAL_PROGRAM="${TERM_PROGRAM:-}"
47
+ export CC_PETS_TERMINAL_SESSION="${TERM_SESSION_ID:-${ITERM_SESSION_ID:-}}"
48
+ export CC_PETS_TERMINAL_BUNDLE_ID="$("${PET_BIN}" --frontmost-bundle-id 2>/dev/null || true)"
49
+
44
50
  mkdir -p "${CLIENT_DIR}"
45
- # 写入 provider 名,桌宠据此判断“这一家的客户端是否还活着”。见 codex-with-pet 同处注释。
46
- print -r -- 'Claude' > "${CLIENT_FILE}"
51
+ # 第一行记录 provider,第二行记录 TTY;桌宠据此判断具体 Agent 会话是否仍在线。
52
+ printf '%s\n%s\n' 'Claude' "${CC_PETS_TERMINAL_TTY:t}" > "${CLIENT_FILE}"
47
53
 
48
54
  print -rn -- '{"schemaVersion":1,"provider":"Claude","state":"starting"}' | \
49
55
  "${PET_BIN}" --provider-event >/dev/null 2>&1 || true
@@ -39,10 +39,15 @@ if [[ -d "${INSTALLED_APP}" ]]; then
39
39
  PET_APP="${INSTALLED_APP}"
40
40
  fi
41
41
 
42
+ # Hook 的 stdin 是 JSON 管道,完成时再调用 tty 已经拿不到原始终端;必须在 exec 前固定。
43
+ export CC_PETS_TERMINAL_TTY="${TTY:-}"
44
+ export CC_PETS_TERMINAL_PROGRAM="${TERM_PROGRAM:-}"
45
+ export CC_PETS_TERMINAL_SESSION="${TERM_SESSION_ID:-${ITERM_SESSION_ID:-}}"
46
+ export CC_PETS_TERMINAL_BUNDLE_ID="$("${PET_BIN}" --frontmost-bundle-id 2>/dev/null || true)"
47
+
42
48
  mkdir -p "${CLIENT_DIR}"
43
- # 写入 provider 名,桌宠据此判断“这一家的客户端是否还活着”。只 touch 空文件的话,
44
- # Codex 全部退出后桌宠分不清剩下的客户端是谁,状态气泡会一直停在最后一条事件上。
45
- print -r -- 'Codex' > "${CLIENT_FILE}"
49
+ # 第一行记录 provider,第二行记录 TTY;桌宠据此判断具体 Agent 会话是否仍在线。
50
+ printf '%s\n%s\n' 'Codex' "${CC_PETS_TERMINAL_TTY:t}" > "${CLIENT_FILE}"
46
51
 
47
52
  print -rn -- '{"schemaVersion":1,"provider":"Codex","state":"starting"}' | \
48
53
  "${PET_BIN}" --provider-event >/dev/null 2>&1 || true
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "cc-pets",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "A native macOS desktop pet for Codex CLI and Claude Code",
5
- "author": "UniverseWang",
5
+ "author": {
6
+ "name": "Sunnyshiny",
7
+ "url": "https://github.com/Sunnyshinnny776"
8
+ },
6
9
  "license": "MIT",
7
10
  "repository": {
8
11
  "type": "git",
9
- "url": "git+https://github.com/wangxinyu-sqn/cc-pets.git"
12
+ "url": "git+https://github.com/Sunnyshinnny776/cc-pets.git"
10
13
  },
11
- "homepage": "https://github.com/wangxinyu-sqn/cc-pets",
14
+ "homepage": "https://github.com/Sunnyshinnny776/cc-pets",
12
15
  "bugs": {
13
- "url": "https://github.com/wangxinyu-sqn/cc-pets/issues"
16
+ "url": "https://github.com/Sunnyshinnny776/cc-pets/issues"
14
17
  },
15
18
  "keywords": [
16
19
  "codex",
@@ -34,11 +37,17 @@
34
37
  "Resources/phrases.default.txt",
35
38
  "Sources/CCPets",
36
39
  "README.md",
40
+ "README.zh-CN.md",
37
41
  "PROVIDER_PROTOCOL.md",
42
+ "PROVIDER_PROTOCOL.zh-CN.md",
38
43
  "CHANGELOG.md",
44
+ "CHANGELOG.zh-CN.md",
39
45
  "CONTRIBUTING.md",
46
+ "CONTRIBUTING.zh-CN.md",
40
47
  "SECURITY.md",
48
+ "SECURITY.zh-CN.md",
41
49
  "THIRD_PARTY_NOTICES.md",
50
+ "THIRD_PARTY_NOTICES.zh-CN.md",
42
51
  "LICENSE"
43
52
  ],
44
53
  "bin": {
@@ -36,7 +36,7 @@ const USER_AGENT = (() => {
36
36
  } catch {
37
37
  // 版本读不到不该让下载失败,退回占位版本号即可。
38
38
  }
39
- return `cc-pets/${version} (+https://github.com/wangxinyu-sqn/cc-pets)`;
39
+ return `cc-pets/${version} (+https://github.com/Sunnyshinnny776/cc-pets)`;
40
40
  })();
41
41
 
42
42
  // 不能 add、只会出现在已装素材里的来源。桌宠的"导入 Codex 素材"开关会写 source: "codex"。