cc-pets 2.1.2 → 2.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 +17 -0
- package/CHANGELOG.zh-CN.md +17 -0
- package/CONTRIBUTING.md +54 -0
- package/CONTRIBUTING.zh-CN.md +45 -0
- package/README.md +31 -26
- package/README.zh-CN.md +22 -16
- package/Resources/Info.plist +3 -1
- package/Resources/en.lproj/InfoPlist.strings +1 -0
- package/Resources/phrases.default.en.txt +182 -0
- package/Resources/zh-Hans.lproj/InfoPlist.strings +1 -0
- package/Resources/zh-Hans.lproj/Localizable.strings +332 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +28 -28
- package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +16 -14
- package/Sources/CCPets/CCPetsAppDelegate+Pets.m +7 -9
- package/Sources/CCPets/CCPetsAppDelegate+Private.h +3 -0
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +25 -4
- package/Sources/CCPets/CCPetsAppDelegate+Speech.m +1 -1
- package/Sources/CCPets/CCPetsAppDelegate+Update.m +36 -35
- package/Sources/CCPets/CCPetsAppDelegate.m +20 -14
- package/Sources/CCPets/CCPetsCleanup.m +9 -6
- package/Sources/CCPets/CCPetsEvents.m +4 -3
- package/Sources/CCPets/CCPetsL10n.h +55 -0
- package/Sources/CCPets/CCPetsL10n.m +219 -0
- package/Sources/CCPets/CCPetsPhrases.h +7 -1
- package/Sources/CCPets/CCPetsPhrases.m +86 -31
- package/Sources/CCPets/CCPetsPhrasesEditor.m +62 -64
- package/Sources/CCPets/CCPetsPreviews.m +7 -6
- package/Sources/CCPets/CCPetsVersion.h +7 -4
- package/Sources/CCPets/CCPetsVersion.m +14 -6
- package/Sources/CCPets/MenuToggleSwitch.m +3 -2
- package/Sources/CCPets/PetView.m +103 -74
- package/Sources/CCPets/QuotaDashboardView.m +122 -85
- package/Sources/CCPets/main.m +3 -1
- package/bin/cc-pets +21 -22
- package/bin/claude-with-pet +2 -1
- package/bin/codex-with-pet +2 -1
- package/package.json +3 -2
- package/scripts/bridge/cli.mjs +39 -38
- package/scripts/bridge/core.mjs +27 -26
- package/scripts/bridge/hook.mjs +7 -6
- package/scripts/bridge/install.mjs +24 -23
- package/scripts/bridge/mcp-server.mjs +79 -71
- package/scripts/bridge/options.mjs +7 -6
- package/scripts/bridge/reservations.mjs +6 -5
- package/scripts/bridge/store.mjs +10 -9
- package/scripts/build.sh +24 -5
- package/scripts/check-l10n.mjs +168 -0
- package/scripts/configure-updater.mjs +4 -3
- package/scripts/doctor.mjs +93 -79
- package/scripts/i18n.mjs +122 -0
- package/scripts/i18n.zsh +66 -0
- package/scripts/install-app.sh +3 -2
- package/scripts/install-claude-hooks.mjs +10 -9
- package/scripts/install-codex-hooks.mjs +7 -6
- package/scripts/install-shell-integration.sh +6 -5
- package/scripts/locales/zh-Hans.json +366 -0
- package/scripts/pet-store.mjs +45 -44
- package/scripts/uninstall-app.sh +4 -3
- package/scripts/uninstall-integrations.mjs +8 -7
- package/scripts/uninstall-shell-integration.sh +8 -7
- /package/Resources/{phrases.default.txt → phrases.default.zh-Hans.txt} +0 -0
package/scripts/i18n.mjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Node 端(cc-pets 子命令、hook、CC Bridge)的多语言,和 App 端 CCPetsL10n 同一套约定:
|
|
2
|
+
// 源码里写英文原文,它就是 scripts/locales/<语言>.json 的 key;英文直接原样输出。
|
|
3
|
+
// 参数用 {name} 占位,第二个参数传 { name: 值 }。
|
|
4
|
+
//
|
|
5
|
+
// 支持哪些语言不写在代码里:英文之外,scripts/locales 下有 <语言>.json 的就算支持。
|
|
6
|
+
//
|
|
7
|
+
// 语言的来源依次是:
|
|
8
|
+
// 1. CC_PETS_LANGUAGE(en / zh-Hans / zh…,测试和临时切换用)
|
|
9
|
+
// 2. ~/.cc-pets/language(可用 CC_PETS_HOME 覆盖):桌宠把右键菜单里选定的语言写在这里,
|
|
10
|
+
// 这样终端里的输出和桌宠界面是同一种语言
|
|
11
|
+
// 3. LC_ALL / LC_MESSAGES / LANG,再退到 Intl 的默认 locale
|
|
12
|
+
// 都匹配不上时用英文。匹配规则同 App:先比完整标识或前缀(zh-Hans-CN → zh-Hans),
|
|
13
|
+
// 再只比主语言(zh_CN → zh-Hans、ja_JP → ja)。
|
|
14
|
+
//
|
|
15
|
+
// zsh 脚本通过命令行入口用同一套表:node i18n.mjs <英文原文> [name=value …],见 i18n.zsh。
|
|
16
|
+
import fs from "node:fs";
|
|
17
|
+
import os from "node:os";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
|
|
21
|
+
export const SOURCE_LANGUAGE = "en";
|
|
22
|
+
const localesDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), "locales");
|
|
23
|
+
|
|
24
|
+
let cachedSupported;
|
|
25
|
+
export function supportedLanguages() {
|
|
26
|
+
if (cachedSupported) return cachedSupported;
|
|
27
|
+
let found = [];
|
|
28
|
+
try {
|
|
29
|
+
found = fs.readdirSync(localesDirectory)
|
|
30
|
+
.filter((name) => name.endsWith(".json"))
|
|
31
|
+
.map((name) => name.slice(0, -".json".length))
|
|
32
|
+
.filter((language) => language !== SOURCE_LANGUAGE)
|
|
33
|
+
.sort();
|
|
34
|
+
} catch {
|
|
35
|
+
found = [];
|
|
36
|
+
}
|
|
37
|
+
cachedSupported = [SOURCE_LANGUAGE, ...found];
|
|
38
|
+
return cachedSupported;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// zh_CN.UTF-8 → zh-cn
|
|
42
|
+
function normalizedTag(value) {
|
|
43
|
+
return String(value || "").trim().toLowerCase().replace(/_/g, "-").split(".")[0];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function matchLanguage(value, supported = supportedLanguages()) {
|
|
47
|
+
const tag = normalizedTag(value);
|
|
48
|
+
if (!tag || tag === "c" || tag === "posix") return "";
|
|
49
|
+
const exact = supported.find((language) => {
|
|
50
|
+
const lower = language.toLowerCase();
|
|
51
|
+
return tag === lower || tag.startsWith(`${lower}-`);
|
|
52
|
+
});
|
|
53
|
+
if (exact) return exact;
|
|
54
|
+
const base = tag.split("-")[0];
|
|
55
|
+
return supported.find((language) => language.toLowerCase().split("-")[0] === base) || "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function languageFromFile() {
|
|
59
|
+
const home = process.env.CC_PETS_HOME || path.join(os.homedir(), ".cc-pets");
|
|
60
|
+
try {
|
|
61
|
+
return matchLanguage(fs.readFileSync(path.join(home, "language"), "utf8"));
|
|
62
|
+
} catch {
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function languageFromEnvironment() {
|
|
68
|
+
for (const name of ["LC_ALL", "LC_MESSAGES", "LANG"]) {
|
|
69
|
+
const language = matchLanguage(process.env[name]);
|
|
70
|
+
if (language) return language;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return matchLanguage(Intl.DateTimeFormat().resolvedOptions().locale);
|
|
74
|
+
} catch {
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let cachedLanguage;
|
|
80
|
+
export function currentLanguage() {
|
|
81
|
+
if (cachedLanguage) return cachedLanguage;
|
|
82
|
+
cachedLanguage = matchLanguage(process.env.CC_PETS_LANGUAGE) || languageFromFile() ||
|
|
83
|
+
languageFromEnvironment() || SOURCE_LANGUAGE;
|
|
84
|
+
return cachedLanguage;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const tables = new Map();
|
|
88
|
+
function table(language) {
|
|
89
|
+
if (!tables.has(language)) {
|
|
90
|
+
try {
|
|
91
|
+
tables.set(language, JSON.parse(fs.readFileSync(path.join(localesDirectory, `${language}.json`), "utf8")));
|
|
92
|
+
} catch {
|
|
93
|
+
tables.set(language, {});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return tables.get(language);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function interpolate(text, values) {
|
|
100
|
+
if (!values) return text;
|
|
101
|
+
return text.replace(/\{([A-Za-z][A-Za-z0-9]*)\}/g, (match, name) =>
|
|
102
|
+
Object.prototype.hasOwnProperty.call(values, name) ? String(values[name]) : match);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function translate(language, text, values) {
|
|
106
|
+
const translated = language === SOURCE_LANGUAGE ? text : (table(language)[text] || text);
|
|
107
|
+
return interpolate(translated, values);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function t(text, values) {
|
|
111
|
+
return translate(currentLanguage(), text, values);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// node i18n.mjs <英文原文> [name=value …]
|
|
115
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
116
|
+
const [text = "", ...pairs] = process.argv.slice(2);
|
|
117
|
+
const values = Object.fromEntries(pairs.map((pair) => {
|
|
118
|
+
const index = pair.indexOf("=");
|
|
119
|
+
return index < 0 ? [pair, ""] : [pair.slice(0, index), pair.slice(index + 1)];
|
|
120
|
+
}));
|
|
121
|
+
process.stdout.write(`${t(text, values)}\n`);
|
|
122
|
+
}
|
package/scripts/i18n.zsh
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# zsh 脚本的多语言,和 scripts/i18n.mjs 共用 scripts/locales/<语言>.json 与同一套判定规则:
|
|
2
|
+
# CC_PETS_LANGUAGE → ~/.cc-pets/language(桌宠菜单里选的语言)→ LC_ALL / LC_MESSAGES / LANG → 英文。
|
|
3
|
+
#
|
|
4
|
+
# print "$(cc_pets_t "Built: {path}" path="${BUILD_DIR}/cc-pets")"
|
|
5
|
+
#
|
|
6
|
+
# 第一个参数是英文原文(也是表的 key),必须是字面量,scripts/check-l10n.mjs 会把它和表对上;
|
|
7
|
+
# 变量一律走 {name} 占位,不能直接写进原文,否则 key 每次都不一样,永远查不到。
|
|
8
|
+
# 英文直接在 zsh 里替换占位符;其他语言交给 node 查表。没有 node(比如正在报"找不到 Node.js")
|
|
9
|
+
# 时退回英文,总比什么都不说好。
|
|
10
|
+
|
|
11
|
+
typeset -g _CC_PETS_I18N_DIR="${${(%):-%x}:A:h}"
|
|
12
|
+
|
|
13
|
+
# 支持的语言:英文加上 locales 下的每个 <语言>.json。
|
|
14
|
+
_cc_pets_languages() {
|
|
15
|
+
print -r -- en "${_CC_PETS_I18N_DIR}"/locales/*.json(N:t:r)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
# 把 zh_CN.UTF-8、zh-Hans-CN 这类写法匹配到支持的语言上;匹配不上输出空。
|
|
19
|
+
_cc_pets_match_language() {
|
|
20
|
+
local tag="${${1:l}//_/-}" language
|
|
21
|
+
tag="${tag%%.*}"
|
|
22
|
+
[[ -z "${tag}" || "${tag}" == c || "${tag}" == posix ]] && return 0
|
|
23
|
+
local -a languages=(${=$(_cc_pets_languages)})
|
|
24
|
+
for language in "${languages[@]}"; do
|
|
25
|
+
if [[ "${tag}" == "${language:l}" || "${tag}" == "${language:l}"-* ]]; then
|
|
26
|
+
print -r -- "${language}"
|
|
27
|
+
return 0
|
|
28
|
+
fi
|
|
29
|
+
done
|
|
30
|
+
for language in "${languages[@]}"; do
|
|
31
|
+
if [[ "${tag%%-*}" == "${${language:l}%%-*}" ]]; then
|
|
32
|
+
print -r -- "${language}"
|
|
33
|
+
return 0
|
|
34
|
+
fi
|
|
35
|
+
done
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
cc_pets_language() {
|
|
39
|
+
local match="" value name
|
|
40
|
+
local language_file="${CC_PETS_HOME:-${HOME}/.cc-pets}/language"
|
|
41
|
+
match="$(_cc_pets_match_language "${CC_PETS_LANGUAGE:-}")"
|
|
42
|
+
if [[ -z "${match}" && -r "${language_file}" ]]; then
|
|
43
|
+
value="$(<"${language_file}")"
|
|
44
|
+
match="$(_cc_pets_match_language "${value}")"
|
|
45
|
+
fi
|
|
46
|
+
if [[ -z "${match}" ]]; then
|
|
47
|
+
for name in LC_ALL LC_MESSAGES LANG; do
|
|
48
|
+
match="$(_cc_pets_match_language "${(P)name:-}")"
|
|
49
|
+
[[ -n "${match}" ]] && break
|
|
50
|
+
done
|
|
51
|
+
fi
|
|
52
|
+
print -r -- "${match:-en}"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
cc_pets_t() {
|
|
56
|
+
local text="$1" pair language
|
|
57
|
+
shift
|
|
58
|
+
language="$(cc_pets_language)"
|
|
59
|
+
if [[ "${language}" != en ]] && (( $+commands[node] )); then
|
|
60
|
+
CC_PETS_LANGUAGE="${language}" node "${_CC_PETS_I18N_DIR}/i18n.mjs" "${text}" "$@" && return 0
|
|
61
|
+
fi
|
|
62
|
+
for pair in "$@"; do
|
|
63
|
+
text="${text//"{${pair%%=*}}"/${pair#*=}}"
|
|
64
|
+
done
|
|
65
|
+
print -r -- "${text}"
|
|
66
|
+
}
|
package/scripts/install-app.sh
CHANGED
|
@@ -3,6 +3,7 @@ set -eu
|
|
|
3
3
|
|
|
4
4
|
SCRIPT_DIR="${0:A:h}"
|
|
5
5
|
PROJECT_DIR="${SCRIPT_DIR:h}"
|
|
6
|
+
source "${PROJECT_DIR}/scripts/i18n.zsh"
|
|
6
7
|
SOURCE_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
|
|
7
8
|
APPLICATIONS_DIR="${CC_PETS_APPLICATIONS_DIR:-${HOME}/Applications}"
|
|
8
9
|
TARGET_APP="${APPLICATIONS_DIR}/CC Pets.app"
|
|
@@ -29,8 +30,8 @@ if ! mv "${STAGING_APP}" "${TARGET_APP}"; then
|
|
|
29
30
|
if [[ -e "${BACKUP_APP}" ]]; then
|
|
30
31
|
mv "${BACKUP_APP}" "${TARGET_APP}"
|
|
31
32
|
fi
|
|
32
|
-
print -u2 "
|
|
33
|
+
print -u2 "$(cc_pets_t "Failed to install CC Pets.app; the existing app was kept.")"
|
|
33
34
|
exit 1
|
|
34
35
|
fi
|
|
35
36
|
|
|
36
|
-
print "
|
|
37
|
+
print "$(cc_pets_t "App installed: {targetApp}" targetApp="${TARGET_APP}")"
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
STATUS_LINE_END_MARKER, STATUS_LINE_MARKER, STATUS_LINE_START_MARKER,
|
|
11
11
|
isManagedHookCommand, isManagedStatusLine
|
|
12
12
|
} from "./integration-markers.mjs";
|
|
13
|
+
import { t } from "./i18n.mjs";
|
|
13
14
|
|
|
14
15
|
const binary = process.argv[2];
|
|
15
16
|
if (!binary) {
|
|
16
|
-
console.error("
|
|
17
|
+
console.error(t("Usage: install-claude-hooks.mjs /absolute/path/to/cc-pets"));
|
|
17
18
|
process.exit(2);
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -21,8 +22,8 @@ if (!binary) {
|
|
|
21
22
|
// ~/.claude/statusline-command.sh 并把 settings.json 的 statusLine 指过去,
|
|
22
23
|
// 对还没装 Claude 的用户等于提前替他决定了状态栏。exit 0 的理由见 install-codex-hooks.mjs。
|
|
23
24
|
if (!detectClaudeCLI()) {
|
|
24
|
-
console.log("
|
|
25
|
-
console.log("
|
|
25
|
+
console.log(t("Claude Code CLI not detected; skipping Claude hooks and status line setup."));
|
|
26
|
+
console.log(t("If you install Claude Code later, run cc-pets install to set it up."));
|
|
26
27
|
process.exit(0);
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -141,7 +142,7 @@ if (fs.existsSync(settingsPath)) {
|
|
|
141
142
|
try {
|
|
142
143
|
config = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
143
144
|
} catch (error) {
|
|
144
|
-
console.error(
|
|
145
|
+
console.error(t("Can't parse {settingsPath}: {message}", { settingsPath, message: error.message }));
|
|
145
146
|
process.exit(1);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
@@ -236,17 +237,17 @@ if (!statusLineInstalled && originalStatusLineCommand && fs.existsSync(statusLin
|
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
if (!statusLineInstalled && !statusLineWrapped) {
|
|
239
|
-
console.warn(
|
|
240
|
-
console.warn("Claude
|
|
240
|
+
console.warn(t("Claude status line not hooked up: {command}", { command: originalStatusLineCommand || t("(not configured)") }));
|
|
241
|
+
console.warn(t("Claude hooks still work, but the pet can't show Claude quota % (token usage is unaffected)."));
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
const temporaryPath = `${settingsPath}.cc-pets.tmp`;
|
|
244
245
|
fs.writeFileSync(temporaryPath, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
245
246
|
fs.renameSync(temporaryPath, settingsPath);
|
|
246
247
|
fs.chmodSync(settingsPath, 0o600);
|
|
247
|
-
console.log(
|
|
248
|
+
console.log(t("Claude Code hooks installed in {settingsPath}", { settingsPath }));
|
|
248
249
|
if (statusLineInstalled) {
|
|
249
|
-
console.log("Claude
|
|
250
|
+
console.log(t("Claude quota tracking added to your existing status line. The pet shows quota after the first API response."));
|
|
250
251
|
} else if (statusLineWrapped) {
|
|
251
|
-
console.log("Claude
|
|
252
|
+
console.log(t("Claude quota tracking added to the status line through a wrapper; your original command still runs. The pet shows quota after the first API response."));
|
|
252
253
|
}
|
|
@@ -5,10 +5,11 @@ import os from "node:os";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { detectCodexCLI } from "./detect-cli.mjs";
|
|
7
7
|
import { CODEX_HOOK, LEGACY_CODEX_HOOK, isManagedHookCommand } from "./integration-markers.mjs";
|
|
8
|
+
import { t } from "./i18n.mjs";
|
|
8
9
|
|
|
9
10
|
const binary = process.argv[2];
|
|
10
11
|
if (!binary) {
|
|
11
|
-
console.error("
|
|
12
|
+
console.error(t("Usage: install-codex-hooks.mjs /absolute/path/to/cc-pets"));
|
|
12
13
|
process.exit(2);
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,8 +17,8 @@ if (!binary) {
|
|
|
16
17
|
// 这里非零退出会把后面的 Claude Hooks、更新器、shim 和 .zshrc 全部带停,
|
|
17
18
|
// 用户会拿到一个装了一半的状态。
|
|
18
19
|
if (!detectCodexCLI()) {
|
|
19
|
-
console.log("
|
|
20
|
-
console.log("
|
|
20
|
+
console.log(t("Codex CLI not detected; skipping Codex hooks."));
|
|
21
|
+
console.log(t("If you install Codex later, run cc-pets install to set it up."));
|
|
21
22
|
process.exit(0);
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -44,7 +45,7 @@ if (fs.existsSync(hooksPath)) {
|
|
|
44
45
|
try {
|
|
45
46
|
config = JSON.parse(fs.readFileSync(hooksPath, "utf8"));
|
|
46
47
|
} catch (error) {
|
|
47
|
-
console.error(
|
|
48
|
+
console.error(t("Can't parse {hooksPath}: {message}", { hooksPath, message: error.message }));
|
|
48
49
|
process.exit(1);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -73,5 +74,5 @@ const temporaryPath = `${hooksPath}.cc-pets.tmp`;
|
|
|
73
74
|
fs.writeFileSync(temporaryPath, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
74
75
|
fs.renameSync(temporaryPath, hooksPath);
|
|
75
76
|
fs.chmodSync(hooksPath, 0o600);
|
|
76
|
-
console.log(
|
|
77
|
-
console.log("
|
|
77
|
+
console.log(t("Codex agent hooks installed in {hooksPath}", { hooksPath }));
|
|
78
|
+
console.log(t("Next time you start Codex, run /hooks and trust the CC Pets hooks."));
|
|
@@ -3,6 +3,7 @@ set -eu
|
|
|
3
3
|
|
|
4
4
|
SCRIPT_DIR="${0:A:h}"
|
|
5
5
|
PROJECT_DIR="${SCRIPT_DIR:h}"
|
|
6
|
+
source "${PROJECT_DIR}/scripts/i18n.zsh"
|
|
6
7
|
LAUNCHER="${PROJECT_DIR}/bin/codex-with-pet"
|
|
7
8
|
CLAUDE_LAUNCHER="${PROJECT_DIR}/bin/claude-with-pet"
|
|
8
9
|
SHELL_RC="${ZDOTDIR:-${HOME}}/.zshrc"
|
|
@@ -15,7 +16,7 @@ if [[ -z "${NODE_EXECUTABLE}" || ! -x "${NODE_EXECUTABLE}" ]]; then
|
|
|
15
16
|
NODE_EXECUTABLE="$(command -v node || true)"
|
|
16
17
|
fi
|
|
17
18
|
if [[ -z "${NODE_EXECUTABLE}" || ! -x "${NODE_EXECUTABLE}" ]]; then
|
|
18
|
-
print -u2 "
|
|
19
|
+
print -u2 "$(cc_pets_t "Install failed: no executable Node.js found.")"
|
|
19
20
|
exit 1
|
|
20
21
|
fi
|
|
21
22
|
export PATH="${NODE_EXECUTABLE:h}:${PATH:-/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
@@ -29,7 +30,7 @@ export PATH="${NODE_EXECUTABLE:h}:${PATH:-/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
|
29
30
|
"${NODE_EXECUTABLE}" "${PROJECT_DIR}/scripts/configure-updater.mjs"
|
|
30
31
|
# CC Bridge 默认关闭;用户开启过的话,包路径可能随升级变化,按原选项重写一遍集成。
|
|
31
32
|
"${NODE_EXECUTABLE}" "${PROJECT_DIR}/scripts/bridge/cli.mjs" refresh || \
|
|
32
|
-
print -u2 "CC Bridge
|
|
33
|
+
print -u2 "$(cc_pets_t "Failed to refresh the CC Bridge integration; retry later with cc-pets bridge enable.")"
|
|
33
34
|
|
|
34
35
|
PET_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
|
|
35
36
|
PET_APP_EXECUTABLE="${PET_APP}/Contents/MacOS/cc-pets"
|
|
@@ -53,7 +54,7 @@ if (( PET_WAS_RUNNING )); then
|
|
|
53
54
|
sleep 0.1
|
|
54
55
|
done
|
|
55
56
|
open -g "${INSTALLED_PET_APP}" --args --managed
|
|
56
|
-
print "
|
|
57
|
+
print "$(cc_pets_t "Restarted the running pet so the new version takes effect now.")"
|
|
57
58
|
fi
|
|
58
59
|
|
|
59
60
|
# 早期版本用 alias 接管 codex / claude。alias 名区分大小写,而 macOS 文件系统默认不区分:
|
|
@@ -77,5 +78,5 @@ if ! grep -Fq "${SHIM_START_MARKER}" "${SHELL_RC}" 2>/dev/null; then
|
|
|
77
78
|
} >> "${SHELL_RC}"
|
|
78
79
|
fi
|
|
79
80
|
|
|
80
|
-
print "
|
|
81
|
-
print "
|
|
81
|
+
print "$(cc_pets_t "Installed. CC Pets was added to {installedPetApp}. Run source {shellRc}; after that, running codex or claude (in any capitalization) starts the pet automatically." installedPetApp="${(q)INSTALLED_PET_APP}" shellRc="${(q)SHELL_RC}")"
|
|
82
|
+
print "$(cc_pets_t "After the first launch, run /hooks and trust the CC Pets hooks to enable Agent animations.")"
|