cc-pets 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/README.md +2 -1
- package/Resources/AppIcon.icns +0 -0
- package/Resources/Info.plist +2 -0
- package/package.json +2 -1
- package/scripts/build.sh +1 -0
- package/scripts/install-claude-hooks.mjs +15 -5
- package/scripts/install-codex-hooks.mjs +9 -3
- package/scripts/install-shell-integration.sh +1 -1
- package/scripts/uninstall-integrations.mjs +43 -12
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- 项目和 npm 包更名为 CC Pets。
|
|
8
8
|
- 新版安装器会自动清理旧版 `codex-pet` Hooks、Claude status line 包装和 shell aliases。
|
|
9
|
+
- 旧版迁移只匹配 CC Pets 的完整命令签名,避免误删复用相似标记的其他工具配置。
|
|
9
10
|
- 新增原创默认桌宠 ByteMochi,移除公开包中的第三方角色素材。
|
|
10
11
|
- 新增 Codex CLI 与 Claude Code CLI 共存、Agent 动画和额度面板。
|
|
11
12
|
- 新增 PetDex 外部素材动态扫描与桌宠切换。
|
package/README.md
CHANGED
|
@@ -126,7 +126,8 @@ source ~/.zshrc
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
新版安装器会自动移除旧版 Hooks、恢复并重新接入 Claude status line,同时替换旧的 shell alias 标记,
|
|
129
|
-
不需要先运行已经移除的 `codex-pet uninstall
|
|
129
|
+
不需要先运行已经移除的 `codex-pet uninstall`。迁移仅识别 CC Pets 的完整命令签名,不会按
|
|
130
|
+
`codex`、`claude` 或单个环境变量名称泛化删除其他工具配置。
|
|
130
131
|
|
|
131
132
|
如果真实 Codex CLI 不在当前 `PATH`,可以显式指定:
|
|
132
133
|
|
|
Binary file
|
package/Resources/Info.plist
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-pets",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A native macOS desktop pet for Codex CLI and Claude Code",
|
|
5
5
|
"author": "wangxinyusqn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"bin",
|
|
31
31
|
"scripts",
|
|
32
32
|
"Resources/Info.plist",
|
|
33
|
+
"Resources/AppIcon.icns",
|
|
33
34
|
"Sources/CCPets/main.m",
|
|
34
35
|
"Sources/CCPets/Resources",
|
|
35
36
|
"README.md",
|
package/scripts/build.sh
CHANGED
|
@@ -28,5 +28,6 @@ if (( ${#SPRITES[@]} > 0 )); then
|
|
|
28
28
|
fi
|
|
29
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
|
+
cp "${PROJECT_DIR}/Resources/AppIcon.icns" "${APP_RESOURCES_DIR}/AppIcon.icns"
|
|
31
32
|
print "构建完成: ${BUILD_DIR}/cc-pets"
|
|
32
33
|
print "应用完成: ${APP_DIR}"
|
|
@@ -15,8 +15,19 @@ const claudeHome = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".cl
|
|
|
15
15
|
const settingsPath = path.join(claudeHome, "settings.json");
|
|
16
16
|
const marker = "CC_PETS_CLAUDE_AGENT_HOOK=1";
|
|
17
17
|
const statusLineMarker = "CC_PETS_CLAUDE_STATUS_LINE=1";
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const managedHookSignatures = [
|
|
19
|
+
{ marker, executable: "cc-pets" },
|
|
20
|
+
{ marker: "CLAUDE_PET_AGENT_HOOK=1", executable: "codex-pet" }
|
|
21
|
+
];
|
|
22
|
+
const managedStatusLineMarkers = [statusLineMarker, "CLAUDE_PET_STATUS_LINE=1"];
|
|
23
|
+
const isManagedHookCommand = (value, signature) =>
|
|
24
|
+
typeof value === "string" &&
|
|
25
|
+
value.startsWith(`${signature.marker} `) &&
|
|
26
|
+
value.endsWith(`/.build/release/${signature.executable}' --hook`);
|
|
27
|
+
const isManagedStatusLine = (value, candidateMarker) =>
|
|
28
|
+
typeof value === "string" &&
|
|
29
|
+
value.startsWith(`${candidateMarker} `) &&
|
|
30
|
+
/\/bin\/claude-statusline-with-pet' '[A-Za-z0-9+/=]*'$/.test(value);
|
|
20
31
|
const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
|
|
21
32
|
const command = `${marker} ${shellQuote(path.resolve(binary))} --hook`;
|
|
22
33
|
const events = [
|
|
@@ -54,8 +65,7 @@ for (const [event, groups] of Object.entries(config.hooks)) {
|
|
|
54
65
|
config.hooks[event] = groups.flatMap((group) => {
|
|
55
66
|
if (!group || !Array.isArray(group.hooks)) return [group];
|
|
56
67
|
const handlers = group.hooks.filter((handler) => {
|
|
57
|
-
|
|
58
|
-
return ![marker, ...obsoleteHookMarkers].some((value) => handler.command.includes(value));
|
|
68
|
+
return !managedHookSignatures.some((signature) => isManagedHookCommand(handler?.command, signature));
|
|
59
69
|
});
|
|
60
70
|
return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
|
|
61
71
|
});
|
|
@@ -71,7 +81,7 @@ for (const event of events) {
|
|
|
71
81
|
let originalStatusLineCommand = "";
|
|
72
82
|
if (config.statusLine && typeof config.statusLine === "object" && !Array.isArray(config.statusLine)) {
|
|
73
83
|
const currentCommand = typeof config.statusLine.command === "string" ? config.statusLine.command : "";
|
|
74
|
-
if (
|
|
84
|
+
if (managedStatusLineMarkers.some((value) => isManagedStatusLine(currentCommand, value))) {
|
|
75
85
|
const match = currentCommand.match(/'([A-Za-z0-9+/=]*)'\s*$/);
|
|
76
86
|
if (match) originalStatusLineCommand = Buffer.from(match[1], "base64").toString("utf8");
|
|
77
87
|
} else {
|
|
@@ -13,7 +13,14 @@ if (!binary) {
|
|
|
13
13
|
const codexHome = process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
|
|
14
14
|
const hooksPath = path.join(codexHome, "hooks.json");
|
|
15
15
|
const marker = "CC_PETS_CODEX_AGENT_HOOK=1";
|
|
16
|
-
const
|
|
16
|
+
const managedSignatures = [
|
|
17
|
+
{ marker, executable: "cc-pets" },
|
|
18
|
+
{ marker: "CODEX_PET_AGENT_HOOK=1", executable: "codex-pet" }
|
|
19
|
+
];
|
|
20
|
+
const isManagedHookCommand = (value, signature) =>
|
|
21
|
+
typeof value === "string" &&
|
|
22
|
+
value.startsWith(`${signature.marker} `) &&
|
|
23
|
+
value.endsWith(`/.build/release/${signature.executable}' --hook`);
|
|
17
24
|
const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
|
|
18
25
|
const command = `${marker} ${shellQuote(path.resolve(binary))} --hook`;
|
|
19
26
|
const events = [
|
|
@@ -45,8 +52,7 @@ for (const [event, groups] of Object.entries(config.hooks)) {
|
|
|
45
52
|
config.hooks[event] = groups.flatMap((group) => {
|
|
46
53
|
if (!group || !Array.isArray(group.hooks)) return [group];
|
|
47
54
|
const handlers = group.hooks.filter((handler) => {
|
|
48
|
-
|
|
49
|
-
return ![marker, ...obsoleteMarkers].some((value) => handler.command.includes(value));
|
|
55
|
+
return !managedSignatures.some((signature) => isManagedHookCommand(handler?.command, signature));
|
|
50
56
|
});
|
|
51
57
|
return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
|
|
52
58
|
});
|
|
@@ -11,7 +11,7 @@ END_MARKER="# <<< cc-pets-codex <<<"
|
|
|
11
11
|
CLAUDE_START_MARKER="# >>> cc-pets-claude >>>"
|
|
12
12
|
CLAUDE_END_MARKER="# <<< cc-pets-claude <<<"
|
|
13
13
|
|
|
14
|
-
node "${PROJECT_DIR}/scripts/uninstall-integrations.mjs" "${SHELL_RC}"
|
|
14
|
+
node "${PROJECT_DIR}/scripts/uninstall-integrations.mjs" --prepare-install "${SHELL_RC}"
|
|
15
15
|
"${PROJECT_DIR}/scripts/build.sh"
|
|
16
16
|
node "${PROJECT_DIR}/scripts/install-codex-hooks.mjs" "${PROJECT_DIR}/.build/release/cc-pets"
|
|
17
17
|
node "${PROJECT_DIR}/scripts/install-claude-hooks.mjs" \
|
|
@@ -6,7 +6,27 @@ import path from "node:path";
|
|
|
6
6
|
|
|
7
7
|
const codexHome = process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
|
|
8
8
|
const claudeHome = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".claude");
|
|
9
|
-
const
|
|
9
|
+
const preparingInstall = process.argv[2] === "--prepare-install";
|
|
10
|
+
const shellRC = process.argv[preparingInstall ? 3 : 2];
|
|
11
|
+
|
|
12
|
+
const currentCodexHook = { marker: "CC_PETS_CODEX_AGENT_HOOK=1", executable: "cc-pets" };
|
|
13
|
+
const legacyCodexHook = { marker: "CODEX_PET_AGENT_HOOK=1", executable: "codex-pet" };
|
|
14
|
+
const currentClaudeHook = { marker: "CC_PETS_CLAUDE_AGENT_HOOK=1", executable: "cc-pets" };
|
|
15
|
+
const legacyClaudeHook = { marker: "CLAUDE_PET_AGENT_HOOK=1", executable: "codex-pet" };
|
|
16
|
+
const currentStatusLineMarker = "CC_PETS_CLAUDE_STATUS_LINE=1";
|
|
17
|
+
const legacyStatusLineMarker = "CLAUDE_PET_STATUS_LINE=1";
|
|
18
|
+
|
|
19
|
+
function isManagedHookCommand(value, signature) {
|
|
20
|
+
return typeof value === "string" &&
|
|
21
|
+
value.startsWith(`${signature.marker} `) &&
|
|
22
|
+
value.endsWith(`/.build/release/${signature.executable}' --hook`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isManagedStatusLine(value, marker) {
|
|
26
|
+
return typeof value === "string" &&
|
|
27
|
+
value.startsWith(`${marker} `) &&
|
|
28
|
+
/\/bin\/claude-statusline-with-pet' '[A-Za-z0-9+/=]*'$/.test(value);
|
|
29
|
+
}
|
|
10
30
|
|
|
11
31
|
function writeJSON(filePath, value) {
|
|
12
32
|
const temporaryPath = `${filePath}.cc-pets.tmp`;
|
|
@@ -22,10 +42,9 @@ function removeHookHandlers(config, markers) {
|
|
|
22
42
|
if (!Array.isArray(groups)) continue;
|
|
23
43
|
const filteredGroups = groups.flatMap((group) => {
|
|
24
44
|
if (!group || !Array.isArray(group.hooks)) return [group];
|
|
25
|
-
const handlers = group.hooks.filter((handler) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
45
|
+
const handlers = group.hooks.filter((handler) =>
|
|
46
|
+
!markers.some((signature) => isManagedHookCommand(handler?.command, signature))
|
|
47
|
+
);
|
|
29
48
|
if (handlers.length !== group.hooks.length) changed = true;
|
|
30
49
|
return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
|
|
31
50
|
});
|
|
@@ -53,15 +72,24 @@ function updateJSON(filePath, updater) {
|
|
|
53
72
|
}
|
|
54
73
|
|
|
55
74
|
const codexHooksPath = path.join(codexHome, "hooks.json");
|
|
75
|
+
const codexSignatures = preparingInstall
|
|
76
|
+
? [legacyCodexHook]
|
|
77
|
+
: [currentCodexHook, legacyCodexHook];
|
|
56
78
|
const codexChanged = updateJSON(codexHooksPath, (config) =>
|
|
57
|
-
removeHookHandlers(config,
|
|
79
|
+
removeHookHandlers(config, codexSignatures)
|
|
58
80
|
);
|
|
59
81
|
|
|
60
82
|
const claudeSettingsPath = path.join(claudeHome, "settings.json");
|
|
83
|
+
const claudeSignatures = preparingInstall
|
|
84
|
+
? [legacyClaudeHook]
|
|
85
|
+
: [currentClaudeHook, legacyClaudeHook];
|
|
86
|
+
const statusLineMarkers = preparingInstall
|
|
87
|
+
? [legacyStatusLineMarker]
|
|
88
|
+
: [currentStatusLineMarker, legacyStatusLineMarker];
|
|
61
89
|
const claudeChanged = updateJSON(claudeSettingsPath, (config) => {
|
|
62
|
-
let changed = removeHookHandlers(config,
|
|
90
|
+
let changed = removeHookHandlers(config, claudeSignatures);
|
|
63
91
|
const command = typeof config.statusLine?.command === "string" ? config.statusLine.command : "";
|
|
64
|
-
if (
|
|
92
|
+
if (statusLineMarkers.some((marker) => isManagedStatusLine(command, marker))) {
|
|
65
93
|
const match = command.match(/'([A-Za-z0-9+/=]*)'\s*$/);
|
|
66
94
|
const originalCommand = match ? Buffer.from(match[1], "base64").toString("utf8") : "";
|
|
67
95
|
if (originalCommand) config.statusLine = { ...config.statusLine, command: originalCommand };
|
|
@@ -100,7 +128,10 @@ if (shellRC && fs.existsSync(shellRC)) {
|
|
|
100
128
|
}
|
|
101
129
|
}
|
|
102
130
|
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
if (
|
|
131
|
+
const action = preparingInstall ? "已迁移" : "已移除";
|
|
132
|
+
if (codexChanged) console.log(`${action} ${codexHooksPath} 中的 CC Pets Hooks。`);
|
|
133
|
+
if (claudeChanged) console.log(`${action} ${claudeSettingsPath} 中的 CC Pets Hooks,并恢复原 status line。`);
|
|
134
|
+
if (shellChanged) console.log(`${action} ${shellRC} 中的 CC Pets aliases。`);
|
|
135
|
+
if (!codexChanged && !claudeChanged && !shellChanged && !preparingInstall) {
|
|
136
|
+
console.log("未发现需要移除的 CC Pets 集成。 ");
|
|
137
|
+
}
|