cc-pets 0.1.1 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  本项目遵循语义化版本号。
4
4
 
5
- ## [Unreleased]
5
+ ## [0.2.0] - 2026-07-22
6
6
 
7
7
  - 项目和 npm 包更名为 CC Pets。
8
+ - 新版安装器会自动清理旧版 `codex-pet` Hooks、Claude status line 包装和 shell aliases。
8
9
  - 新增原创默认桌宠 ByteMochi,移除公开包中的第三方角色素材。
9
10
  - 新增 Codex CLI 与 Claude Code CLI 共存、Agent 动画和额度面板。
10
11
  - 新增 PetDex 外部素材动态扫描与桌宠切换。
11
- - 新增 `codex-pet uninstall`,可移除本项目 Hooks、恢复 Claude status line 并清理 shell aliases。
12
+ - 新增 `cc-pets uninstall`,可移除本项目 Hooks、恢复 Claude status line 并清理 shell aliases。
12
13
  - 构建支持 PNG、WebP 和空素材目录。
13
14
  - 补充隐私、安全、贡献和第三方素材说明。
14
15
 
15
16
  ## [0.1.0] - 2026-07-21
16
17
 
17
18
  - 首个可用版本。
18
-
package/README.md CHANGED
@@ -36,7 +36,7 @@ Agent 动画分别由 Codex Hooks 和 Claude Code Hooks 驱动。首次安装或
36
36
  Claude Code Hook 会合并到 `~/.claude/settings.json`,现有的 `env`、`model`、`statusLine`
37
37
  以及其他 Hooks 都会保留。Claude status line 会通过透明转发器继续执行原命令,同时将官方
38
38
  `rate_limits` 字段提供给桌宠。
39
- 执行 `codex-pet install` 会重新构建应用、安装或更新两套 Hooks,并配置 shell alias;如果旧版桌宠正在运行,
39
+ 执行 `cc-pets install` 会重新构建应用、安装或更新两套 Hooks,并配置 shell alias;如果旧版桌宠正在运行,
40
40
  安装器会自动重启桌宠,使新版本生效。
41
41
 
42
42
  ### 鼠标互动
@@ -91,7 +91,7 @@ Claude Code Hook 会合并到 `~/.claude/settings.json`,现有的 `env`、`mod
91
91
 
92
92
  ```bash
93
93
  npm install -g cc-pets
94
- codex-pet install
94
+ cc-pets install
95
95
  source ~/.zshrc
96
96
  codex
97
97
  # 或
@@ -104,17 +104,30 @@ claude
104
104
  git clone https://gitee.com/wangxinyusqn/cc-pets.git
105
105
  cd cc-pets
106
106
  npm install -g .
107
- codex-pet install
107
+ cc-pets install
108
108
  source ~/.zshrc
109
109
  codex
110
110
  # 或
111
111
  claude
112
112
  ```
113
113
 
114
- 两种方式都会安装 `codex-pet`、`codex-with-pet` 和 `claude-with-pet`。
115
- `codex-pet install` 是桌宠初始化命令:它会构建原生应用、安装两套 Agent Hooks,并向 `~/.zshrc` 追加带明确标记的
114
+ 两种方式都会安装 `cc-pets`、`codex-with-pet` 和 `claude-with-pet`。
115
+ `cc-pets install` 是桌宠初始化命令:它会构建原生应用、安装两套 Agent Hooks,并向 `~/.zshrc` 追加带明确标记的
116
116
  `codex` 与 `claude` alias,不会覆盖真实的 CLI 二进制。
117
117
 
118
+ ### 从旧版升级
119
+
120
+ 从使用 `codex-pet` 命令的旧版升级时,直接安装新版并重新执行初始化即可:
121
+
122
+ ```bash
123
+ npm install -g cc-pets@latest
124
+ cc-pets install
125
+ source ~/.zshrc
126
+ ```
127
+
128
+ 新版安装器会自动移除旧版 Hooks、恢复并重新接入 Claude status line,同时替换旧的 shell alias 标记,
129
+ 不需要先运行已经移除的 `codex-pet uninstall`。
130
+
118
131
  如果真实 Codex CLI 不在当前 `PATH`,可以显式指定:
119
132
 
120
133
  ```bash
@@ -134,22 +147,22 @@ export CLAUDE_REAL_BIN=/absolute/path/to/claude
134
147
 
135
148
  ```bash
136
149
  # 构建原生程序
137
- codex-pet build
150
+ cc-pets build
138
151
 
139
152
  # 独立启动桌宠;独立启动时不会随 CLI 自动退出
140
- codex-pet
153
+ cc-pets
141
154
 
142
155
  # 前台运行,便于调试
143
- codex-pet --foreground
156
+ cc-pets --foreground
144
157
 
145
158
  # 查看当前解析到的 Codex 额度
146
- codex-pet --status
159
+ cc-pets --status
147
160
 
148
161
  # 安装/更新 Hooks、shell alias,并让已运行桌宠加载新版本
149
- codex-pet install
162
+ cc-pets install
150
163
 
151
164
  # 安全移除 Hooks、恢复 Claude status line,并清理 shell alias
152
- codex-pet uninstall
165
+ cc-pets uninstall
153
166
 
154
167
  # 启动桌宠后进入 Codex CLI
155
168
  codex-with-pet
@@ -184,12 +197,12 @@ Claude.ai Pro/Max 订阅账号,并在会话完成首次 API 响应后出现;
184
197
 
185
198
  ```bash
186
199
  ./scripts/build.sh
187
- ./.build/release/codex-pet --status
200
+ ./.build/release/cc-pets --status
188
201
  ```
189
202
 
190
203
  ## 素材与版权
191
204
 
192
- 桌宠素材统一放在 `Sources/CodexPet/Resources/`,程序会自动收集其中的 `.webp` 和 `.png` 文件。
205
+ 桌宠素材统一放在 `Sources/CCPets/Resources/`,程序会自动收集其中的 `.webp` 和 `.png` 文件。
193
206
  素材需要使用 `1536×1872` 画布,按 `8×9` 网格切分为 `192×208` 单元格,并遵循相同的帧数和动作行协议。
194
207
  角色可能属于受版权保护的作品;公开
195
208
  发布本项目或 npm 包前,请确认已经获得素材的使用和分发授权,或替换为原创、可公开分发的素材。
@@ -211,14 +224,14 @@ npx petdex install <slug>
211
224
  - Claude 额度只从 Claude Code 传给本机 status line 的 `rate_limits` 字段读取。
212
225
  - Agent Hooks 只向当前用户的临时目录写入桌宠事件和额度缓存。
213
226
  - 项目不上传会话内容、额度、凭据或使用统计,也不包含遥测服务。
214
- - 右键“退出桌宠”或执行 `codex-pet uninstall` 后,不会继续运行后台守护进程。
227
+ - 右键“退出桌宠”或执行 `cc-pets uninstall` 后,不会继续运行后台守护进程。
215
228
 
216
229
  ## 卸载
217
230
 
218
231
  先在 npm 包仍然存在时移除集成:
219
232
 
220
233
  ```bash
221
- codex-pet uninstall
234
+ cc-pets uninstall
222
235
  source ~/.zshrc
223
236
  npm uninstall -g cc-pets
224
237
  ```
@@ -5,19 +5,19 @@
5
5
  <key>CFBundleDisplayName</key>
6
6
  <string>CC Pets</string>
7
7
  <key>CFBundleExecutable</key>
8
- <string>codex-pet</string>
8
+ <string>cc-pets</string>
9
9
  <key>CFBundleIdentifier</key>
10
- <string>com.universewang.codex-pet</string>
10
+ <string>com.universewang.cc-pets</string>
11
11
  <key>CFBundleInfoDictionaryVersion</key>
12
12
  <string>6.0</string>
13
13
  <key>CFBundleName</key>
14
- <string>CodexPet</string>
14
+ <string>CC Pets</string>
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>APPL</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>0.1.0</string>
18
+ <string>0.2.0</string>
19
19
  <key>CFBundleVersion</key>
20
- <string>1</string>
20
+ <string>2</string>
21
21
  <key>LSMinimumSystemVersion</key>
22
22
  <string>13.0</string>
23
23
  <key>LSUIElement</key>
@@ -4,18 +4,18 @@
4
4
  #import <signal.h>
5
5
 
6
6
  static NSString *PetStateDirectory(void) {
7
- NSString *override = NSProcessInfo.processInfo.environment[@"CODEX_PET_STATE_DIR"];
7
+ NSString *override = NSProcessInfo.processInfo.environment[@"CC_PETS_STATE_DIR"];
8
8
  if (override.length > 0) return override.stringByStandardizingPath;
9
9
  return NSTemporaryDirectory();
10
10
  }
11
11
 
12
12
  static NSString *AgentEventPath(void) {
13
- NSString *name = [NSString stringWithFormat:@"codex-pet-%u-agent-events.ndjson", getuid()];
13
+ NSString *name = [NSString stringWithFormat:@"cc-pets-%u-agent-events.ndjson", getuid()];
14
14
  return [PetStateDirectory() stringByAppendingPathComponent:name];
15
15
  }
16
16
 
17
17
  static NSString *ClaudeUsagePath(void) {
18
- NSString *name = [NSString stringWithFormat:@"codex-pet-%u-claude-usage.json", getuid()];
18
+ NSString *name = [NSString stringWithFormat:@"cc-pets-%u-claude-usage.json", getuid()];
19
19
  return [PetStateDirectory() stringByAppendingPathComponent:name];
20
20
  }
21
21
 
@@ -831,7 +831,17 @@ static int RenderQuotaDashboard(NSString *path) {
831
831
  [NSApp terminate:nil];
832
832
  return;
833
833
  }
834
- NSString *selected = [NSUserDefaults.standardUserDefaults stringForKey:@"CodexPetSelectedSprite"];
834
+ NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
835
+ NSString *selected = [defaults stringForKey:@"CCPetsSelectedSprite"];
836
+ if (selected.length == 0) {
837
+ NSDictionary *legacyDefaults = [defaults persistentDomainForName:@"com.universewang.codex-pet"];
838
+ NSString *legacySelected = [legacyDefaults[@"CodexPetSelectedSprite"] isKindOfClass:NSString.class]
839
+ ? legacyDefaults[@"CodexPetSelectedSprite"] : nil;
840
+ if (legacySelected.length > 0) {
841
+ selected = legacySelected;
842
+ [defaults setObject:selected forKey:@"CCPetsSelectedSprite"];
843
+ }
844
+ }
835
845
  if (selected.length > 0 && ![selected containsString:@":"]) selected = [@"builtin:" stringByAppendingString:selected];
836
846
  NSDictionary *selectedOption = [self petOptionWithID:selected inOptions:petOptions] ?: petOptions.firstObject;
837
847
  selected = selectedOption[@"id"];
@@ -962,7 +972,7 @@ static int RenderQuotaDashboard(NSString *path) {
962
972
  NSImage *image = [[NSImage alloc] initWithContentsOfFile:option[@"path"]];
963
973
  if (!image) return;
964
974
  [self.petView applySheet:image petID:petID];
965
- [NSUserDefaults.standardUserDefaults setObject:petID forKey:@"CodexPetSelectedSprite"];
975
+ [NSUserDefaults.standardUserDefaults setObject:petID forKey:@"CCPetsSelectedSprite"];
966
976
  }
967
977
  - (void)prepareAgentEventReader {
968
978
  NSString *path = AgentEventPath();
@@ -1012,7 +1022,7 @@ static int RenderQuotaDashboard(NSString *path) {
1012
1022
  [self processAgentEventData:data ignoreFirstPartial:NO recentOnly:NO];
1013
1023
  }
1014
1024
  - (void)refreshClientLifecycle:(id)sender {
1015
- NSString *clientName = [NSString stringWithFormat:@"codex-pet-%u-clients", getuid()];
1025
+ NSString *clientName = [NSString stringWithFormat:@"cc-pets-%u-clients", getuid()];
1016
1026
  NSString *clientDirectory = [PetStateDirectory() stringByAppendingPathComponent:clientName];
1017
1027
  NSArray<NSString *> *entries = [NSFileManager.defaultManager contentsOfDirectoryAtPath:clientDirectory error:nil] ?: @[];
1018
1028
  NSInteger liveClients = 0;
@@ -1057,7 +1067,7 @@ int main(int argc, const char *argv[]) {
1057
1067
  return EXIT_SUCCESS;
1058
1068
  }
1059
1069
 
1060
- NSString *lockName = [NSString stringWithFormat:@"codex-pet-%u.lock", getuid()];
1070
+ NSString *lockName = [NSString stringWithFormat:@"cc-pets-%u.lock", getuid()];
1061
1071
  NSString *lockPath = [PetStateDirectory() stringByAppendingPathComponent:lockName];
1062
1072
  int lock = open(lockPath.fileSystemRepresentation, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
1063
1073
  if (lock < 0 || flock(lock, LOCK_EX | LOCK_NB) != 0) return EXIT_SUCCESS;
@@ -3,8 +3,8 @@ set -eu
3
3
 
4
4
  SCRIPT_DIR="${0:A:h}"
5
5
  PROJECT_DIR="${SCRIPT_DIR:h}"
6
- PET_BIN="${PROJECT_DIR}/.build/release/codex-pet"
7
- PET_APP="${PROJECT_DIR}/.build/release/CodexPet.app"
6
+ PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
7
+ PET_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
8
8
 
9
9
  if [[ "${1:-}" == "install" ]]; then
10
10
  exec "${PROJECT_DIR}/scripts/install-shell-integration.sh"
@@ -3,7 +3,7 @@ set -u
3
3
 
4
4
  SCRIPT_DIR="${0:A:h}"
5
5
  PROJECT_DIR="${SCRIPT_DIR:h}"
6
- PET_BIN="${PROJECT_DIR}/.build/release/codex-pet"
6
+ PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
7
7
  ORIGINAL_COMMAND_BASE64="${1:-}"
8
8
  INPUT="$(cat)"
9
9
 
@@ -3,10 +3,10 @@ set -eu
3
3
 
4
4
  SCRIPT_DIR="${0:A:h}"
5
5
  PROJECT_DIR="${SCRIPT_DIR:h}"
6
- PET_BIN="${PROJECT_DIR}/.build/release/codex-pet"
7
- PET_APP="${PROJECT_DIR}/.build/release/CodexPet.app"
6
+ PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
7
+ PET_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
8
8
  REAL_CLAUDE="${CLAUDE_REAL_BIN:-}"
9
- CLIENT_DIR="${${TMPDIR:-/tmp/}%/}/codex-pet-$(id -u)-clients"
9
+ CLIENT_DIR="${${TMPDIR:-/tmp/}%/}/cc-pets-$(id -u)-clients"
10
10
  CLIENT_FILE="${CLIENT_DIR}/$$"
11
11
 
12
12
  if [[ -z "${REAL_CLAUDE}" ]]; then
@@ -3,10 +3,10 @@ set -eu
3
3
 
4
4
  SCRIPT_DIR="${0:A:h}"
5
5
  PROJECT_DIR="${SCRIPT_DIR:h}"
6
- PET_BIN="${PROJECT_DIR}/.build/release/codex-pet"
7
- PET_APP="${PROJECT_DIR}/.build/release/CodexPet.app"
6
+ PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
7
+ PET_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
8
8
  REAL_CODEX="${CODEX_REAL_BIN:-}"
9
- CLIENT_DIR="${${TMPDIR:-/tmp/}%/}/codex-pet-$(id -u)-clients"
9
+ CLIENT_DIR="${${TMPDIR:-/tmp/}%/}/cc-pets-$(id -u)-clients"
10
10
  CLIENT_FILE="${CLIENT_DIR}/$$"
11
11
 
12
12
  if [[ -z "${REAL_CODEX}" ]]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-pets",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A native macOS desktop pet for Codex CLI and Claude Code",
5
5
  "author": "wangxinyusqn",
6
6
  "license": "MIT",
@@ -30,8 +30,8 @@
30
30
  "bin",
31
31
  "scripts",
32
32
  "Resources/Info.plist",
33
- "Sources/CodexPet/main.m",
34
- "Sources/CodexPet/Resources",
33
+ "Sources/CCPets/main.m",
34
+ "Sources/CCPets/Resources",
35
35
  "README.md",
36
36
  "CHANGELOG.md",
37
37
  "CONTRIBUTING.md",
@@ -40,7 +40,7 @@
40
40
  "LICENSE"
41
41
  ],
42
42
  "bin": {
43
- "codex-pet": "bin/codex-pet",
43
+ "cc-pets": "bin/cc-pets",
44
44
  "codex-with-pet": "bin/codex-with-pet",
45
45
  "claude-with-pet": "bin/claude-with-pet"
46
46
  },
package/scripts/build.sh CHANGED
@@ -5,10 +5,10 @@ SCRIPT_DIR="${0:A:h}"
5
5
  PROJECT_DIR="${SCRIPT_DIR:h}"
6
6
  BUILD_DIR="${PROJECT_DIR}/.build/release"
7
7
  CACHE_DIR="${PROJECT_DIR}/.build/clang-cache"
8
- APP_DIR="${BUILD_DIR}/CodexPet.app"
8
+ APP_DIR="${BUILD_DIR}/CC Pets.app"
9
9
  APP_MACOS_DIR="${APP_DIR}/Contents/MacOS"
10
10
  APP_RESOURCES_DIR="${APP_DIR}/Contents/Resources"
11
- RESOURCE_DIR="${PET_RESOURCE_DIR:-${PROJECT_DIR}/Sources/CodexPet/Resources}"
11
+ RESOURCE_DIR="${CC_PETS_RESOURCE_DIR:-${PROJECT_DIR}/Sources/CCPets/Resources}"
12
12
  mkdir -p "${BUILD_DIR}" "${CACHE_DIR}" "${APP_MACOS_DIR}" "${APP_RESOURCES_DIR}"
13
13
 
14
14
  CLANG_MODULE_CACHE_PATH="${CACHE_DIR}" clang \
@@ -16,8 +16,8 @@ CLANG_MODULE_CACHE_PATH="${CACHE_DIR}" clang \
16
16
  -fmodules-cache-path="${CACHE_DIR}" \
17
17
  -mmacosx-version-min=13.0 \
18
18
  -framework Cocoa \
19
- "${PROJECT_DIR}/Sources/CodexPet/main.m" \
20
- -o "${BUILD_DIR}/codex-pet"
19
+ "${PROJECT_DIR}/Sources/CCPets/main.m" \
20
+ -o "${BUILD_DIR}/cc-pets"
21
21
 
22
22
  find "${BUILD_DIR}" -maxdepth 1 -type f \( -name '*.webp' -o -name '*.png' \) -delete
23
23
  find "${APP_MACOS_DIR}" -maxdepth 1 -type f \( -name '*.webp' -o -name '*.png' \) -delete
@@ -26,7 +26,7 @@ if (( ${#SPRITES[@]} > 0 )); then
26
26
  cp "${SPRITES[@]}" "${BUILD_DIR}/"
27
27
  cp "${SPRITES[@]}" "${APP_MACOS_DIR}/"
28
28
  fi
29
- cp "${BUILD_DIR}/codex-pet" "${APP_MACOS_DIR}/codex-pet"
29
+ cp "${BUILD_DIR}/cc-pets" "${APP_MACOS_DIR}/cc-pets"
30
30
  cp "${PROJECT_DIR}/Resources/Info.plist" "${APP_DIR}/Contents/Info.plist"
31
- print "构建完成: ${BUILD_DIR}/codex-pet"
31
+ print "构建完成: ${BUILD_DIR}/cc-pets"
32
32
  print "应用完成: ${APP_DIR}"
@@ -7,14 +7,16 @@ import path from "node:path";
7
7
  const binary = process.argv[2];
8
8
  const statusLineProxy = process.argv[3];
9
9
  if (!binary || !statusLineProxy) {
10
- console.error("用法: install-claude-hooks.mjs /absolute/path/to/codex-pet /absolute/path/to/claude-statusline-with-pet");
10
+ console.error("用法: install-claude-hooks.mjs /absolute/path/to/cc-pets /absolute/path/to/claude-statusline-with-pet");
11
11
  process.exit(2);
12
12
  }
13
13
 
14
14
  const claudeHome = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".claude");
15
15
  const settingsPath = path.join(claudeHome, "settings.json");
16
- const marker = "CLAUDE_PET_AGENT_HOOK=1";
17
- const statusLineMarker = "CLAUDE_PET_STATUS_LINE=1";
16
+ const marker = "CC_PETS_CLAUDE_AGENT_HOOK=1";
17
+ const statusLineMarker = "CC_PETS_CLAUDE_STATUS_LINE=1";
18
+ const obsoleteHookMarkers = ["CLAUDE_PET_AGENT_HOOK=1"];
19
+ const obsoleteStatusLineMarkers = ["CLAUDE_PET_STATUS_LINE=1"];
18
20
  const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
19
21
  const command = `${marker} ${shellQuote(path.resolve(binary))} --hook`;
20
22
  const events = [
@@ -51,9 +53,10 @@ for (const [event, groups] of Object.entries(config.hooks)) {
51
53
  if (!Array.isArray(groups)) continue;
52
54
  config.hooks[event] = groups.flatMap((group) => {
53
55
  if (!group || !Array.isArray(group.hooks)) return [group];
54
- const handlers = group.hooks.filter((handler) =>
55
- typeof handler?.command !== "string" || !handler.command.includes(marker)
56
- );
56
+ const handlers = group.hooks.filter((handler) => {
57
+ if (typeof handler?.command !== "string") return true;
58
+ return ![marker, ...obsoleteHookMarkers].some((value) => handler.command.includes(value));
59
+ });
57
60
  return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
58
61
  });
59
62
  }
@@ -68,7 +71,7 @@ for (const event of events) {
68
71
  let originalStatusLineCommand = "";
69
72
  if (config.statusLine && typeof config.statusLine === "object" && !Array.isArray(config.statusLine)) {
70
73
  const currentCommand = typeof config.statusLine.command === "string" ? config.statusLine.command : "";
71
- if (currentCommand.includes(statusLineMarker)) {
74
+ if ([statusLineMarker, ...obsoleteStatusLineMarkers].some((value) => currentCommand.includes(value))) {
72
75
  const match = currentCommand.match(/'([A-Za-z0-9+/=]*)'\s*$/);
73
76
  if (match) originalStatusLineCommand = Buffer.from(match[1], "base64").toString("utf8");
74
77
  } else {
@@ -84,7 +87,7 @@ config.statusLine = {
84
87
  command: `${statusLineMarker} ${shellQuote(path.resolve(statusLineProxy))} ${shellQuote(encodedOriginal)}`
85
88
  };
86
89
 
87
- const temporaryPath = `${settingsPath}.codex-pet.tmp`;
90
+ const temporaryPath = `${settingsPath}.cc-pets.tmp`;
88
91
  fs.writeFileSync(temporaryPath, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
89
92
  fs.renameSync(temporaryPath, settingsPath);
90
93
  fs.chmodSync(settingsPath, 0o600);
@@ -6,13 +6,14 @@ import path from "node:path";
6
6
 
7
7
  const binary = process.argv[2];
8
8
  if (!binary) {
9
- console.error("用法: install-codex-hooks.mjs /absolute/path/to/codex-pet");
9
+ console.error("用法: install-codex-hooks.mjs /absolute/path/to/cc-pets");
10
10
  process.exit(2);
11
11
  }
12
12
 
13
13
  const codexHome = process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
14
14
  const hooksPath = path.join(codexHome, "hooks.json");
15
- const marker = "CODEX_PET_AGENT_HOOK=1";
15
+ const marker = "CC_PETS_CODEX_AGENT_HOOK=1";
16
+ const obsoleteMarkers = ["CODEX_PET_AGENT_HOOK=1"];
16
17
  const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
17
18
  const command = `${marker} ${shellQuote(path.resolve(binary))} --hook`;
18
19
  const events = [
@@ -43,9 +44,10 @@ for (const [event, groups] of Object.entries(config.hooks)) {
43
44
  if (!Array.isArray(groups)) continue;
44
45
  config.hooks[event] = groups.flatMap((group) => {
45
46
  if (!group || !Array.isArray(group.hooks)) return [group];
46
- const handlers = group.hooks.filter((handler) =>
47
- typeof handler?.command !== "string" || !handler.command.includes(marker)
48
- );
47
+ const handlers = group.hooks.filter((handler) => {
48
+ if (typeof handler?.command !== "string") return true;
49
+ return ![marker, ...obsoleteMarkers].some((value) => handler.command.includes(value));
50
+ });
49
51
  return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
50
52
  });
51
53
  }
@@ -57,7 +59,7 @@ for (const event of events) {
57
59
  });
58
60
  }
59
61
 
60
- const temporaryPath = `${hooksPath}.codex-pet.tmp`;
62
+ const temporaryPath = `${hooksPath}.cc-pets.tmp`;
61
63
  fs.writeFileSync(temporaryPath, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
62
64
  fs.renameSync(temporaryPath, hooksPath);
63
65
  fs.chmodSync(hooksPath, 0o600);
@@ -6,23 +6,34 @@ PROJECT_DIR="${SCRIPT_DIR:h}"
6
6
  LAUNCHER="${PROJECT_DIR}/bin/codex-with-pet"
7
7
  CLAUDE_LAUNCHER="${PROJECT_DIR}/bin/claude-with-pet"
8
8
  SHELL_RC="${ZDOTDIR:-${HOME}}/.zshrc"
9
- START_MARKER="# >>> codex-pet >>>"
10
- END_MARKER="# <<< codex-pet <<<"
11
- CLAUDE_START_MARKER="# >>> claude-pet >>>"
12
- CLAUDE_END_MARKER="# <<< claude-pet <<<"
9
+ START_MARKER="# >>> cc-pets-codex >>>"
10
+ END_MARKER="# <<< cc-pets-codex <<<"
11
+ CLAUDE_START_MARKER="# >>> cc-pets-claude >>>"
12
+ CLAUDE_END_MARKER="# <<< cc-pets-claude <<<"
13
13
 
14
+ node "${PROJECT_DIR}/scripts/uninstall-integrations.mjs" "${SHELL_RC}"
14
15
  "${PROJECT_DIR}/scripts/build.sh"
15
- node "${PROJECT_DIR}/scripts/install-codex-hooks.mjs" "${PROJECT_DIR}/.build/release/codex-pet"
16
+ node "${PROJECT_DIR}/scripts/install-codex-hooks.mjs" "${PROJECT_DIR}/.build/release/cc-pets"
16
17
  node "${PROJECT_DIR}/scripts/install-claude-hooks.mjs" \
17
- "${PROJECT_DIR}/.build/release/codex-pet" \
18
+ "${PROJECT_DIR}/.build/release/cc-pets" \
18
19
  "${PROJECT_DIR}/bin/claude-statusline-with-pet"
19
20
 
20
- PET_APP="${PROJECT_DIR}/.build/release/CodexPet.app"
21
- PET_APP_EXECUTABLE="${PET_APP}/Contents/MacOS/codex-pet"
22
- if pgrep -f "${PET_APP_EXECUTABLE}" >/dev/null 2>&1; then
23
- pkill -f "${PET_APP_EXECUTABLE}" || true
21
+ PET_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
22
+ PET_APP_EXECUTABLE="${PET_APP}/Contents/MacOS/cc-pets"
23
+ LEGACY_PET_APP_EXECUTABLE="${PROJECT_DIR}/.build/release/CodexPet.app/Contents/MacOS/codex-pet"
24
+ PET_WAS_RUNNING=0
25
+ for executable in "${PET_APP_EXECUTABLE}" "${LEGACY_PET_APP_EXECUTABLE}"; do
26
+ if pgrep -f "${executable}" >/dev/null 2>&1; then
27
+ pkill -f "${executable}" || true
28
+ PET_WAS_RUNNING=1
29
+ fi
30
+ done
31
+ if (( PET_WAS_RUNNING )); then
24
32
  for _ in {1..30}; do
25
- pgrep -f "${PET_APP_EXECUTABLE}" >/dev/null 2>&1 || break
33
+ if ! pgrep -f "${PET_APP_EXECUTABLE}" >/dev/null 2>&1 && \
34
+ ! pgrep -f "${LEGACY_PET_APP_EXECUTABLE}" >/dev/null 2>&1; then
35
+ break
36
+ fi
26
37
  sleep 0.1
27
38
  done
28
39
  open -g "${PET_APP}" --args --managed
@@ -15,16 +15,17 @@ function writeJSON(filePath, value) {
15
15
  fs.chmodSync(filePath, 0o600);
16
16
  }
17
17
 
18
- function removeHookHandlers(config, marker) {
18
+ function removeHookHandlers(config, markers) {
19
19
  if (!config?.hooks || typeof config.hooks !== "object" || Array.isArray(config.hooks)) return false;
20
20
  let changed = false;
21
21
  for (const [event, groups] of Object.entries(config.hooks)) {
22
22
  if (!Array.isArray(groups)) continue;
23
23
  const filteredGroups = groups.flatMap((group) => {
24
24
  if (!group || !Array.isArray(group.hooks)) return [group];
25
- const handlers = group.hooks.filter((handler) =>
26
- typeof handler?.command !== "string" || !handler.command.includes(marker)
27
- );
25
+ const handlers = group.hooks.filter((handler) => {
26
+ if (typeof handler?.command !== "string") return true;
27
+ return !markers.some((marker) => handler.command.includes(marker));
28
+ });
28
29
  if (handlers.length !== group.hooks.length) changed = true;
29
30
  return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
30
31
  });
@@ -53,14 +54,14 @@ function updateJSON(filePath, updater) {
53
54
 
54
55
  const codexHooksPath = path.join(codexHome, "hooks.json");
55
56
  const codexChanged = updateJSON(codexHooksPath, (config) =>
56
- removeHookHandlers(config, "CODEX_PET_AGENT_HOOK=1")
57
+ removeHookHandlers(config, ["CC_PETS_CODEX_AGENT_HOOK=1", "CODEX_PET_AGENT_HOOK=1"])
57
58
  );
58
59
 
59
60
  const claudeSettingsPath = path.join(claudeHome, "settings.json");
60
61
  const claudeChanged = updateJSON(claudeSettingsPath, (config) => {
61
- let changed = removeHookHandlers(config, "CLAUDE_PET_AGENT_HOOK=1");
62
+ let changed = removeHookHandlers(config, ["CC_PETS_CLAUDE_AGENT_HOOK=1", "CLAUDE_PET_AGENT_HOOK=1"]);
62
63
  const command = typeof config.statusLine?.command === "string" ? config.statusLine.command : "";
63
- if (command.includes("CLAUDE_PET_STATUS_LINE=1")) {
64
+ if (["CC_PETS_CLAUDE_STATUS_LINE=1", "CLAUDE_PET_STATUS_LINE=1"].some((marker) => command.includes(marker))) {
64
65
  const match = command.match(/'([A-Za-z0-9+/=]*)'\s*$/);
65
66
  const originalCommand = match ? Buffer.from(match[1], "base64").toString("utf8") : "";
66
67
  if (originalCommand) config.statusLine = { ...config.statusLine, command: originalCommand };
@@ -85,7 +86,9 @@ function removeMarkedBlock(text, startMarker, endMarker) {
85
86
  let shellChanged = false;
86
87
  if (shellRC && fs.existsSync(shellRC)) {
87
88
  const original = fs.readFileSync(shellRC, "utf8");
88
- let updated = removeMarkedBlock(original, "# >>> codex-pet >>>", "# <<< codex-pet <<<");
89
+ let updated = removeMarkedBlock(original, "# >>> cc-pets-codex >>>", "# <<< cc-pets-codex <<<");
90
+ updated = removeMarkedBlock(updated, "# >>> cc-pets-claude >>>", "# <<< cc-pets-claude <<<");
91
+ updated = removeMarkedBlock(updated, "# >>> codex-pet >>>", "# <<< codex-pet <<<");
89
92
  updated = removeMarkedBlock(updated, "# >>> claude-pet >>>", "# <<< claude-pet <<<");
90
93
  updated = updated.replace(/\n{3,}/g, "\n\n");
91
94
  if (updated !== original) {
@@ -4,12 +4,17 @@ set -eu
4
4
  SCRIPT_DIR="${0:A:h}"
5
5
  PROJECT_DIR="${SCRIPT_DIR:h}"
6
6
  SHELL_RC="${ZDOTDIR:-${HOME}}/.zshrc"
7
- PET_APP_EXECUTABLE="${PROJECT_DIR}/.build/release/CodexPet.app/Contents/MacOS/codex-pet"
7
+ PET_APP_EXECUTABLE="${PROJECT_DIR}/.build/release/CC Pets.app/Contents/MacOS/cc-pets"
8
+ LEGACY_PET_APP_EXECUTABLE="${PROJECT_DIR}/.build/release/CodexPet.app/Contents/MacOS/codex-pet"
8
9
 
9
10
  node "${PROJECT_DIR}/scripts/uninstall-integrations.mjs" "${SHELL_RC}"
10
11
 
11
- if [[ "${CODEX_PET_SKIP_APP_STOP:-0}" != "1" ]] && pgrep -f "${PET_APP_EXECUTABLE}" >/dev/null 2>&1; then
12
- pkill -f "${PET_APP_EXECUTABLE}" || true
12
+ if [[ "${CC_PETS_SKIP_APP_STOP:-0}" != "1" ]]; then
13
+ for executable in "${PET_APP_EXECUTABLE}" "${LEGACY_PET_APP_EXECUTABLE}"; do
14
+ if pgrep -f "${executable}" >/dev/null 2>&1; then
15
+ pkill -f "${executable}" || true
16
+ fi
17
+ done
13
18
  fi
14
19
 
15
20
  print "卸载集成完成。执行 source ${(q)SHELL_RC} 更新当前终端;如需删除 npm 包,再执行 npm uninstall -g cc-pets。"