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.
Files changed (61) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/CHANGELOG.zh-CN.md +17 -0
  3. package/CONTRIBUTING.md +54 -0
  4. package/CONTRIBUTING.zh-CN.md +45 -0
  5. package/README.md +31 -26
  6. package/README.zh-CN.md +22 -16
  7. package/Resources/Info.plist +3 -1
  8. package/Resources/en.lproj/InfoPlist.strings +1 -0
  9. package/Resources/phrases.default.en.txt +182 -0
  10. package/Resources/zh-Hans.lproj/InfoPlist.strings +1 -0
  11. package/Resources/zh-Hans.lproj/Localizable.strings +332 -0
  12. package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +28 -28
  13. package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +16 -14
  14. package/Sources/CCPets/CCPetsAppDelegate+Pets.m +7 -9
  15. package/Sources/CCPets/CCPetsAppDelegate+Private.h +3 -0
  16. package/Sources/CCPets/CCPetsAppDelegate+Settings.m +25 -4
  17. package/Sources/CCPets/CCPetsAppDelegate+Speech.m +1 -1
  18. package/Sources/CCPets/CCPetsAppDelegate+Update.m +36 -35
  19. package/Sources/CCPets/CCPetsAppDelegate.m +20 -14
  20. package/Sources/CCPets/CCPetsCleanup.m +9 -6
  21. package/Sources/CCPets/CCPetsEvents.m +4 -3
  22. package/Sources/CCPets/CCPetsL10n.h +55 -0
  23. package/Sources/CCPets/CCPetsL10n.m +219 -0
  24. package/Sources/CCPets/CCPetsPhrases.h +7 -1
  25. package/Sources/CCPets/CCPetsPhrases.m +86 -31
  26. package/Sources/CCPets/CCPetsPhrasesEditor.m +62 -64
  27. package/Sources/CCPets/CCPetsPreviews.m +7 -6
  28. package/Sources/CCPets/CCPetsVersion.h +7 -4
  29. package/Sources/CCPets/CCPetsVersion.m +14 -6
  30. package/Sources/CCPets/MenuToggleSwitch.m +3 -2
  31. package/Sources/CCPets/PetView.m +103 -74
  32. package/Sources/CCPets/QuotaDashboardView.m +122 -85
  33. package/Sources/CCPets/main.m +3 -1
  34. package/bin/cc-pets +21 -22
  35. package/bin/claude-with-pet +2 -1
  36. package/bin/codex-with-pet +2 -1
  37. package/package.json +3 -2
  38. package/scripts/bridge/cli.mjs +39 -38
  39. package/scripts/bridge/core.mjs +27 -26
  40. package/scripts/bridge/hook.mjs +7 -6
  41. package/scripts/bridge/install.mjs +24 -23
  42. package/scripts/bridge/mcp-server.mjs +79 -71
  43. package/scripts/bridge/options.mjs +7 -6
  44. package/scripts/bridge/reservations.mjs +6 -5
  45. package/scripts/bridge/store.mjs +10 -9
  46. package/scripts/build.sh +24 -5
  47. package/scripts/check-l10n.mjs +168 -0
  48. package/scripts/configure-updater.mjs +4 -3
  49. package/scripts/doctor.mjs +93 -79
  50. package/scripts/i18n.mjs +122 -0
  51. package/scripts/i18n.zsh +66 -0
  52. package/scripts/install-app.sh +3 -2
  53. package/scripts/install-claude-hooks.mjs +10 -9
  54. package/scripts/install-codex-hooks.mjs +7 -6
  55. package/scripts/install-shell-integration.sh +6 -5
  56. package/scripts/locales/zh-Hans.json +366 -0
  57. package/scripts/pet-store.mjs +45 -44
  58. package/scripts/uninstall-app.sh +4 -3
  59. package/scripts/uninstall-integrations.mjs +8 -7
  60. package/scripts/uninstall-shell-integration.sh +8 -7
  61. /package/Resources/{phrases.default.txt → phrases.default.zh-Hans.txt} +0 -0
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env node
2
+ // 多语言自检。源码里写英文原文,它就是各语言表的 key:
3
+ // - App:L(@"…")(见 Sources/CCPets/CCPetsL10n.h)↔ Resources/<语言>.lproj/Localizable.strings
4
+ // - CLI:Node 的 t("…")(见 scripts/i18n.mjs)和 zsh 的 cc_pets_t "…"(见 scripts/i18n.zsh)
5
+ // ↔ scripts/locales/<语言>.json
6
+ // 改了英文原文却忘了改表,那种语言的界面就会漏出英文,而且不报任何错。这里把每种语言的表
7
+ // 都和源码逐条对上(有几张表就查几张,加语言不用改这里):
8
+ // - 缺翻译:代码里有、表里没有 → 失败
9
+ // - 多余:表里有、代码里已经没有 → 失败(多半是英文原文改过了,旧 key 成了孤儿)
10
+ // - 占位符对不上:%@ / %ld / {name} 的个数或名字不一致 → 失败
11
+ // - App 表缺元信息(语言名、Release 段落标题)→ 失败
12
+ // - App 和 CLI 支持的语言不一致 → 失败
13
+ //
14
+ // node scripts/check-l10n.mjs 检查,有问题时退出码 1
15
+ // node scripts/check-l10n.mjs --missing <语言> 只把这种语言缺的 key 按 JSON 打出来,方便补表
16
+ import fs from "node:fs";
17
+ import path from "node:path";
18
+ import { execFileSync } from "node:child_process";
19
+ import { fileURLToPath } from "node:url";
20
+
21
+ const projectDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
22
+ const sourceDir = path.join(projectDir, "Sources", "CCPets");
23
+ const resourcesDir = path.join(projectDir, "Resources");
24
+ const localesDir = path.join(projectDir, "scripts", "locales");
25
+ // 与 CCPetsL10n.h 里的 CCPetsLanguageNameKey / CCPetsReleaseNotesSectionKey 一致。
26
+ const APP_META_KEYS = ["Language Name", "Release Notes Section"];
27
+ const SKIPPED_SCRIPTS = new Set(["check-l10n.mjs", "i18n.mjs", "i18n.zsh"]);
28
+
29
+ function unescapeC(text) {
30
+ return text.replace(/\\(["\\nt])/g, (_, ch) => ({ n: "\n", t: "\t" })[ch] ?? ch);
31
+ }
32
+
33
+ function lineOf(text, index) {
34
+ return text.slice(0, index).split("\n").length;
35
+ }
36
+
37
+ // L(@"a" "b" @"c") 这类跨行拼接也算一个 key。
38
+ function objcKeys() {
39
+ const keys = new Map();
40
+ const call = /\bL\(\s*((?:@?"(?:[^"\\]|\\.)*"\s*)+)\)/g;
41
+ const piece = /@?"((?:[^"\\]|\\.)*)"/g;
42
+ for (const name of fs.readdirSync(sourceDir).filter((file) => file.endsWith(".m")).sort()) {
43
+ const text = fs.readFileSync(path.join(sourceDir, name), "utf8");
44
+ for (const match of text.matchAll(call)) {
45
+ const key = [...match[1].matchAll(piece)].map((part) => unescapeC(part[1])).join("");
46
+ if (!keys.has(key)) keys.set(key, `${name}:${lineOf(text, match.index)}`);
47
+ }
48
+ }
49
+ return keys;
50
+ }
51
+
52
+ function walk(dir) {
53
+ return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
54
+ const full = path.join(dir, entry.name);
55
+ if (entry.isDirectory()) return entry.name === "locales" ? [] : walk(full);
56
+ return [full];
57
+ });
58
+ }
59
+
60
+ // Node 端只认 t("…") / t('…') / t(`…`)(模板串里不许有 ${}),第一个参数必须是字面量。
61
+ // zsh 端只认 cc_pets_t "…",第一个参数必须是不含变量的双引号字面量。
62
+ function cliKeys() {
63
+ const keys = new Map();
64
+ const nodeCall = /\bt\(\s*("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\$]|\\.)*`)/g;
65
+ const zshCall = /\bcc_pets_t\s+"((?:[^"\\$`]|\\.)*)"/g;
66
+ const files = [...walk(path.join(projectDir, "scripts")), ...walk(path.join(projectDir, "bin"))]
67
+ .filter((file) => !SKIPPED_SCRIPTS.has(path.basename(file)))
68
+ .sort();
69
+ for (const file of files) {
70
+ const text = fs.readFileSync(file, "utf8");
71
+ const relative = path.relative(projectDir, file);
72
+ const node = /\.(mjs|js)$/.test(file);
73
+ for (const match of text.matchAll(node ? nodeCall : zshCall)) {
74
+ const key = node
75
+ ? unescapeC(match[1].slice(1, -1).replace(/\\'/g, "'").replace(/\\`/g, "`"))
76
+ : match[1].replace(/\\(["\\$`])/g, "$1");
77
+ if (!keys.has(key)) keys.set(key, `${relative}:${lineOf(text, match.index)}`);
78
+ }
79
+ }
80
+ return keys;
81
+ }
82
+
83
+ function readStrings(file) {
84
+ return JSON.parse(execFileSync("/usr/bin/plutil", ["-convert", "json", "-o", "-", file], {
85
+ encoding: "utf8"
86
+ }));
87
+ }
88
+
89
+ // %1$@ 和 %@ 视为同一个占位符,只比较类型的多重集合;{name} 比较名字的集合。
90
+ function placeholders(text) {
91
+ const printf = [...text.matchAll(/%(?:\d+\$)?(?:[-+ #0]*\d*(?:\.\d+)?)(l{0,2}[dufsx@]|%)/g)]
92
+ .map((match) => match[1]).filter((type) => type !== "%").sort();
93
+ const slots = [...text.matchAll(/\{([A-Za-z][A-Za-z0-9]*)\}/g)].map((match) => match[1]).sort();
94
+ return JSON.stringify([printf, [...new Set(slots)]]);
95
+ }
96
+
97
+ function check(label, keys, table, metaKeys = []) {
98
+ const problems = [];
99
+ const missing = {};
100
+ for (const key of metaKeys) {
101
+ if (!String(table[key] ?? "").trim()) problems.push(`${label} 缺元信息: ${JSON.stringify(key)}`);
102
+ }
103
+ for (const [key, where] of keys) {
104
+ if (!(key in table)) {
105
+ problems.push(`${label} 缺翻译 (${where}): ${JSON.stringify(key)}`);
106
+ missing[key] = "";
107
+ } else if (placeholders(key) !== placeholders(table[key])) {
108
+ problems.push(`${label} 占位符不一致 (${where}): ${JSON.stringify(key)} → ${JSON.stringify(table[key])}`);
109
+ }
110
+ }
111
+ for (const key of Object.keys(table)) {
112
+ if (!keys.has(key) && !metaKeys.includes(key)) problems.push(`${label} 多余的条目: ${JSON.stringify(key)}`);
113
+ }
114
+ return { problems, missing };
115
+ }
116
+
117
+ const appLanguages = fs.readdirSync(resourcesDir)
118
+ .filter((entry) => entry.endsWith(".lproj"))
119
+ .filter((entry) => fs.existsSync(path.join(resourcesDir, entry, "Localizable.strings")))
120
+ .map((entry) => entry.slice(0, -".lproj".length))
121
+ .sort();
122
+ const cliLanguages = fs.readdirSync(localesDir)
123
+ .filter((entry) => entry.endsWith(".json"))
124
+ .map((entry) => entry.slice(0, -".json".length))
125
+ .sort();
126
+
127
+ const appKeys = objcKeys();
128
+ const scriptKeys = cliKeys();
129
+ const results = {};
130
+ for (const language of appLanguages) {
131
+ results[`App ${language}`] = check(`App ${language}`, appKeys,
132
+ readStrings(path.join(resourcesDir, `${language}.lproj`, "Localizable.strings")), APP_META_KEYS);
133
+ }
134
+ for (const language of cliLanguages) {
135
+ results[`CLI ${language}`] = check(`CLI ${language}`, scriptKeys,
136
+ JSON.parse(fs.readFileSync(path.join(localesDir, `${language}.json`), "utf8")));
137
+ }
138
+
139
+ const missingIndex = process.argv.indexOf("--missing");
140
+ if (missingIndex >= 0) {
141
+ const language = process.argv[missingIndex + 1];
142
+ if (!language) {
143
+ console.error("用法: check-l10n.mjs --missing <语言>");
144
+ process.exit(2);
145
+ }
146
+ // 还没建表的新语言:缺的就是全部 key。
147
+ const all = (keys) => Object.fromEntries([...keys.keys()].map((key) => [key, ""]));
148
+ const app = results[`App ${language}`]?.missing ?? all(appKeys);
149
+ const cli = results[`CLI ${language}`]?.missing ?? all(scriptKeys);
150
+ process.stdout.write(`${JSON.stringify({ app, cli }, null, 2)}\n`);
151
+ process.exit(0);
152
+ }
153
+
154
+ const problems = [];
155
+ // App 和 CLI 支持的语言要一致,否则切到某种语言后桌宠和终端各说各的。
156
+ for (const language of appLanguages) {
157
+ if (!cliLanguages.includes(language)) problems.push(`缺 scripts/locales/${language}.json(App 已支持 ${language})`);
158
+ }
159
+ for (const language of cliLanguages) {
160
+ if (!appLanguages.includes(language)) problems.push(`缺 Resources/${language}.lproj/Localizable.strings(CLI 已支持 ${language})`);
161
+ }
162
+ for (const result of Object.values(results)) problems.push(...result.problems);
163
+ if (problems.length > 0) {
164
+ for (const problem of problems) console.error(problem);
165
+ console.error(`\n共 ${problems.length} 处多语言问题。`);
166
+ process.exit(1);
167
+ }
168
+ console.log(`多语言检查通过(en 为源语言,另有 ${appLanguages.join("、")})。`);
@@ -3,12 +3,13 @@
3
3
  import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
+ import { t } from "./i18n.mjs";
6
7
 
7
8
  const nodeCandidate = process.env.npm_node_execpath || process.execPath;
8
9
  const npmCandidate = process.env.npm_execpath;
9
10
 
10
11
  if (!nodeCandidate || !npmCandidate) {
11
- console.warn("未记录自动更新配置:npm 没有提供 node/npm-cli 路径。");
12
+ console.warn(t("Auto-update config not saved: npm didn't provide the node/npm-cli paths."));
12
13
  process.exit(0);
13
14
  }
14
15
 
@@ -18,12 +19,12 @@ try {
18
19
  nodePath = fs.realpathSync(nodeCandidate);
19
20
  npmCliPath = fs.realpathSync(npmCandidate);
20
21
  } catch {
21
- console.warn("未记录自动更新配置:node/npm-cli 路径不存在。");
22
+ console.warn(t("Auto-update config not saved: the node/npm-cli paths don't exist."));
22
23
  process.exit(0);
23
24
  }
24
25
 
25
26
  if (!path.isAbsolute(nodePath) || !path.isAbsolute(npmCliPath)) {
26
- console.warn("未记录自动更新配置:node/npm-cli 路径不是绝对路径。");
27
+ console.warn(t("Auto-update config not saved: the node/npm-cli paths aren't absolute."));
27
28
  process.exit(0);
28
29
  }
29
30
 
@@ -21,6 +21,7 @@ import { HOOK_MARKER, describeCodexQueue } from "./bridge/install.mjs";
21
21
  import { currentOptions } from "./bridge/options.mjs";
22
22
  import { probeCodexQueue, resolveRealExecutable } from "./bridge/process.mjs";
23
23
  import { bridgeDirectory, bridgeHomeDirectory, isBridgeEnabled } from "./bridge/store.mjs";
24
+ import { t } from "./i18n.mjs";
24
25
 
25
26
  const projectDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
26
27
  const petBinary = path.join(projectDir, ".build/release/cc-pets");
@@ -69,7 +70,7 @@ const sizeOf = (target) => {
69
70
  };
70
71
 
71
72
  const formatSize = (bytes) => {
72
- if (bytes === null) return "不存在";
73
+ if (bytes === null) return t("missing");
73
74
  if (bytes < 1024) return `${bytes} B`;
74
75
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
75
76
  return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
@@ -94,51 +95,51 @@ const pathGroups = (native) => {
94
95
  const ccPetsHome = bridgeHomeDirectory();
95
96
  const groups = [
96
97
  {
97
- title: "设置(--purge 会删除)",
98
- items: native ? [["偏好设置", native.preferences]] : []
98
+ title: t("Settings (removed by --purge)"),
99
+ items: native ? [[t("Preferences"), native.preferences]] : []
99
100
  },
100
101
  {
101
- title: "用户内容(clean 与 --purge 都保留)",
102
+ title: t("Your content (kept by both clean and --purge)"),
102
103
  items: [
103
104
  ...(native ? [
104
- ["桌宠素材", native.pets],
105
- ["通用台词", native.phrases],
106
- ["宠物专属台词", native.petPhrases]
105
+ [t("Pet sprites"), native.pets],
106
+ [t("Shared lines"), native.phrases],
107
+ [t("Per-pet lines"), native.petPhrases]
107
108
  ] : []),
108
- ["CC Bridge 开关", path.join(ccPetsHome, "bridge-enabled")],
109
+ [t("CC Bridge switch"), path.join(ccPetsHome, "bridge-enabled")],
109
110
  ["codex / claude shim", shimDirectory]
110
111
  ]
111
112
  },
112
113
  {
113
- title: "应用数据(--purge 会删除;clean 只清其中的 Token 缓存与更新日志)",
114
+ title: t("App data (removed by --purge; clean only clears the token cache and update log)"),
114
115
  items: native ? [
115
- ["应用数据目录", native.applicationSupport],
116
- ["额度历史", native.quotaHistory],
117
- ["自动更新配置", path.join(native.applicationSupport, "updater.json")]
116
+ [t("App data directory"), native.applicationSupport],
117
+ [t("Quota history"), native.quotaHistory],
118
+ [t("Auto-update config"), path.join(native.applicationSupport, "updater.json")]
118
119
  ] : []
119
120
  },
120
121
  {
121
- title: "缓存与运行时状态(clean 会清理,丢失不影响使用)",
122
+ title: t("Caches and runtime state (cleared by clean; safe to lose)"),
122
123
  items: [
123
124
  ...(native ? [
124
- ["素材清单缓存", native.petStoreCache],
125
- ["Agent 事件流", native.agentEvents],
126
- ["Claude 额度快照", native.claudeUsage],
127
- ["Codex 实时额度", native.codexLiveUsage],
128
- ["Codex 启动记录", native.codexLaunches],
129
- ["在线客户端记录", native.clients]
125
+ [t("Pet store manifest cache"), native.petStoreCache],
126
+ [t("Agent event stream"), native.agentEvents],
127
+ [t("Claude quota snapshot"), native.claudeUsage],
128
+ [t("Codex live quota"), native.codexLiveUsage],
129
+ [t("Codex launch records"), native.codexLaunches],
130
+ [t("Online client records"), native.clients]
130
131
  ] : []),
131
- ["CC Bridge 状态目录", bridgeDirectory()]
132
+ [t("CC Bridge state directory"), bridgeDirectory()]
132
133
  ]
133
134
  },
134
135
  {
135
- title: "程序与集成",
136
+ title: t("Program and integrations"),
136
137
  items: [
137
- ["npm 包", projectDir],
138
- ["已安装的 App", installedApp],
139
- ["Claude Code 配置", path.join(claudeHome, "settings.json")],
138
+ [t("npm package"), projectDir],
139
+ [t("Installed app"), installedApp],
140
+ [t("Claude Code settings"), path.join(claudeHome, "settings.json")],
140
141
  ["Codex Hooks", path.join(codexHome, "hooks.json")],
141
- ["Shell 配置", shellRC]
142
+ [t("Shell config"), shellRC]
142
143
  ]
143
144
  }
144
145
  ];
@@ -161,7 +162,8 @@ const printPaths = (asJson) => {
161
162
  return 0;
162
163
  }
163
164
  if (!native) {
164
- console.log("⚠️ 原生程序未构建或无法运行,桌宠自身的数据路径无法确定;执行 cc-pets install 后重试。\n");
165
+ console.log(t(`⚠️ The native binary isn't built or can't run, so the pet's own data paths are unknown; run cc-pets install and try again.
166
+ `));
165
167
  }
166
168
  const width = Math.max(...groups.flatMap((group) => group.items.map(([label]) => displayWidth(label))));
167
169
  groups.forEach((group, index) => {
@@ -208,24 +210,32 @@ const hookChecks = (name, configFile, signature, legacySignature) => {
208
210
  const hooks = inspectHooks(configFile, signature, legacySignature);
209
211
  if (hooks.error) {
210
212
  return {
211
- results: [{ level: "fail", title: `${name} 配置无法解析:${tilde(configFile)}`, fix: "修正该 JSON 文件后执行 cc-pets install" }],
213
+ results: [{ level: "fail", title: t("Can't parse {name} config: {configFile}", { name, configFile: tilde(configFile) }), fix: t("Fix that JSON file, then run cc-pets install") }],
212
214
  bridgeHooks: 0
213
215
  };
214
216
  }
215
217
  const results = [];
216
218
  if (hooks.total === 0) {
217
- results.push({ level: "fail", title: `${name} Hooks 未安装`, fix: "cc-pets install" });
219
+ results.push({ level: "fail", title: t("{name} hooks not installed", { name }), fix: "cc-pets install" });
218
220
  } else if (hooks.stale > 0) {
219
221
  results.push({
220
222
  level: "warn",
221
- title: `${name} Hooks 中有 ${hooks.stale} 条指向其他位置的 cc-pets(包被移动或重装过)`,
223
+ title: hooks.stale !== 1
224
+ ? t("{stale} {name} hooks point to cc-pets elsewhere (the package was moved or reinstalled)", { name, stale: hooks.stale })
225
+ : t("{stale} {name} hook points to cc-pets elsewhere (the package was moved or reinstalled)", { name, stale: hooks.stale }),
222
226
  fix: "cc-pets install"
223
227
  });
224
228
  } else {
225
- results.push({ level: "ok", title: `${name} Hooks 已安装(${hooks.total} 个事件)` });
229
+ results.push({ level: "ok", title: t("{name} hooks installed ({total} events)", { name, total: hooks.total }) });
226
230
  }
227
231
  if (hooks.legacy > 0) {
228
- results.push({ level: "warn", title: `${name} 配置里残留 ${hooks.legacy} 条旧版 codex-pet Hooks`, fix: "cc-pets install" });
232
+ results.push({
233
+ level: "warn",
234
+ title: hooks.legacy !== 1
235
+ ? t("{name} config still has {legacy} old codex-pet hooks", { name, legacy: hooks.legacy })
236
+ : t("{name} config still has {legacy} old codex-pet hook", { name, legacy: hooks.legacy }),
237
+ fix: "cc-pets install"
238
+ });
229
239
  }
230
240
  return { results, bridgeHooks: hooks.bridge };
231
241
  };
@@ -234,7 +244,7 @@ const statusLineCheck = () => {
234
244
  const { value } = readJson(path.join(claudeHome, "settings.json"));
235
245
  const command = typeof value?.statusLine?.command === "string" ? value.statusLine.command : "";
236
246
  if (isManagedStatusLine(command, STATUS_LINE_MARKER)) {
237
- return { level: "ok", title: "Claude status line 已通过包装器接入额度采集" };
247
+ return { level: "ok", title: t("Claude status line feeds quota data through the wrapper") };
238
248
  }
239
249
  const script = resolveStatusLineScript(command);
240
250
  let content = "";
@@ -245,12 +255,12 @@ const statusLineCheck = () => {
245
255
  }
246
256
  if (content.includes(STATUS_LINE_START_MARKER)) {
247
257
  return content.includes(`'${petBinary}'`)
248
- ? { level: "ok", title: `Claude status line 已接入额度采集(${tilde(script)})` }
249
- : { level: "warn", title: "Claude status line 里的额度采集指向其他位置的 cc-pets", fix: "cc-pets install" };
258
+ ? { level: "ok", title: t("Claude status line feeds quota data ({script})", { script: tilde(script) }) }
259
+ : { level: "warn", title: t("The quota hook in the Claude status line points to cc-pets elsewhere"), fix: "cc-pets install" };
250
260
  }
251
261
  return {
252
262
  level: "warn",
253
- title: command ? "Claude status line 未接入额度采集,桌宠拿不到 Claude 额度百分比" : "未配置 Claude status line,桌宠拿不到 Claude 额度百分比",
263
+ title: command ? t("Claude status line doesn't feed quota data, so the pet can't show Claude quota %") : t("No Claude status line configured, so the pet can't show Claude quota %"),
254
264
  fix: "cc-pets install"
255
265
  };
256
266
  };
@@ -264,8 +274,8 @@ const shimChecks = () => {
264
274
  rc = "";
265
275
  }
266
276
  results.push(rc.includes(SHIM_START_MARKER)
267
- ? { level: "ok", title: `${tilde(shellRC)} 已加入 shim 目录` }
268
- : { level: "fail", title: `${tilde(shellRC)} 中没有 CC Pets 的 shim 配置`, fix: "cc-pets install" });
277
+ ? { level: "ok", title: t("{shellRC} adds the shim directory", { shellRC: tilde(shellRC) }) }
278
+ : { level: "fail", title: t("{shellRC} has no CC Pets shim setup", { shellRC: tilde(shellRC) }), fix: "cc-pets install" });
269
279
 
270
280
  const broken = [];
271
281
  for (const name of ["codex", "claude"]) {
@@ -274,27 +284,27 @@ const shimChecks = () => {
274
284
  try {
275
285
  link = fs.readlinkSync(shim);
276
286
  } catch {
277
- broken.push(`${name}(缺失)`);
287
+ broken.push(t("{name} (missing)", { name }));
278
288
  continue;
279
289
  }
280
- if (!fs.existsSync(path.resolve(shimDirectory, link))) broken.push(`${name}(指向的文件不存在)`);
290
+ if (!fs.existsSync(path.resolve(shimDirectory, link))) broken.push(t("{name} (target doesn't exist)", { name }));
281
291
  }
282
292
  results.push(broken.length === 0
283
- ? { level: "ok", title: `shim 完整:${tilde(shimDirectory)}` }
284
- : { level: "warn", title: `shim 异常:${broken.join("、")}`, fix: "cc-pets install" });
293
+ ? { level: "ok", title: t("Shims complete: {shimDirectory}", { shimDirectory: tilde(shimDirectory) }) }
294
+ : { level: "warn", title: t("Shim problems: {broken}", { broken: broken.join(t(", ")) }), fix: "cc-pets install" });
285
295
 
286
296
  const entries = (process.env.PATH || "").split(path.delimiter).filter(Boolean).map((entry) => path.resolve(entry));
287
297
  const index = entries.indexOf(shimDirectory);
288
298
  if (index < 0) {
289
- results.push({ level: "warn", title: "当前终端的 PATH 里没有 shim 目录,直接敲 codex / claude 不会拉起桌宠", fix: `source ${tilde(shellRC)},或新开一个终端` });
299
+ results.push({ level: "warn", title: t("This terminal's PATH lacks the shim directory, so typing codex / claude won't start the pet"), fix: t("source {shellRC}, or open a new terminal", { shellRC: tilde(shellRC) }) });
290
300
  } else if (index > 0) {
291
301
  const shadowing = entries.slice(0, index).find((entry) =>
292
302
  ["codex", "claude"].some((name) => fs.existsSync(path.join(entry, name))));
293
303
  results.push(shadowing
294
- ? { level: "warn", title: `PATH 中 ${tilde(shadowing)} 排在 shim 目录之前,会绕过桌宠`, fix: `source ${tilde(shellRC)},或新开一个终端` }
295
- : { level: "ok", title: "PATH 中 shim 目录优先于真实的 codex / claude" });
304
+ ? { level: "warn", title: t("{shadowing} comes before the shim directory in PATH and bypasses the pet", { shadowing: tilde(shadowing) }), fix: t("source {shellRC}, or open a new terminal", { shellRC: tilde(shellRC) }) }
305
+ : { level: "ok", title: t("The shim directory comes before the real codex / claude in PATH") });
296
306
  } else {
297
- results.push({ level: "ok", title: "PATH 中 shim 目录排在最前" });
307
+ results.push({ level: "ok", title: t("The shim directory is first in PATH") });
298
308
  }
299
309
  return results;
300
310
  };
@@ -302,8 +312,8 @@ const shimChecks = () => {
302
312
  const realBinaryCheck = (name, variable) => {
303
313
  const real = resolveRealExecutable(name, variable);
304
314
  return real && fs.existsSync(real)
305
- ? { level: "ok", title: `找到真实的 ${name}:${tilde(real)}` }
306
- : { level: "warn", title: `PATH 中找不到真实的 ${name},shim 无法转发`, fix: `export ${variable}=/absolute/path/to/${name}` };
315
+ ? { level: "ok", title: t("Found the real {name}: {real}", { name, real: tilde(real) }) }
316
+ : { level: "warn", title: t("The real {name} isn't in PATH, so the shim can't forward to it", { name }), fix: `export ${variable}=/absolute/path/to/${name}` };
307
317
  };
308
318
 
309
319
  const updaterCheck = (native) => {
@@ -311,19 +321,19 @@ const updaterCheck = (native) => {
311
321
  const file = path.join(native.applicationSupport, "updater.json");
312
322
  const { value, error } = readJson(file);
313
323
  if (error) {
314
- return { level: "warn", title: "自动更新未配置,应用内无法一键更新", fix: "npm install -g cc-pets@latest --allow-scripts=cc-pets" };
324
+ return { level: "warn", title: t("Auto-update isn't configured, so in-app updates won't work"), fix: "npm install -g cc-pets@latest --allow-scripts=cc-pets" };
315
325
  }
316
326
  const missing = ["nodePath", "npmCliPath"].filter((key) => !value?.[key] || !fs.existsSync(value[key]));
317
327
  return missing.length === 0
318
- ? { level: "ok", title: "自动更新配置有效" }
319
- : { level: "warn", title: `自动更新记录的 ${missing.join("、")} 已不存在(换过 Node 版本?)`, fix: "npm install -g cc-pets@latest --allow-scripts=cc-pets" };
328
+ ? { level: "ok", title: t("Auto-update config is valid") }
329
+ : { level: "warn", title: t("The {missing} recorded for auto-update no longer exist (changed Node versions?)", { missing: missing.join(t(", ")) }), fix: "npm install -g cc-pets@latest --allow-scripts=cc-pets" };
320
330
  };
321
331
 
322
332
  const formatAge = (milliseconds) => {
323
333
  const minutes = Math.round(milliseconds / 60_000);
324
- if (minutes < 60) return `${minutes} 分钟前`;
334
+ if (minutes < 60) return t("{minutes} min ago", { minutes });
325
335
  const hours = Math.round(minutes / 60);
326
- return hours < 48 ? `${hours} 小时前` : `${Math.round(hours / 24)} 天前`;
336
+ return hours < 48 ? t("{hours} h ago", { hours }) : t("{days} days ago", { days: Math.round(hours / 24) });
327
337
  };
328
338
 
329
339
  const runDoctor = () => {
@@ -336,29 +346,29 @@ const runDoctor = () => {
336
346
  const program = [
337
347
  nodeMajor >= 18
338
348
  ? { level: "ok", title: `Node.js ${process.versions.node}` }
339
- : { level: "fail", title: `Node.js ${process.versions.node} 过旧,需要 18 或更高版本` },
340
- { level: "info", title: `npm 包 ${packageVersion}:${tilde(projectDir)}` }
349
+ : { level: "fail", title: t("Node.js {node} is too old; 18 or later is required", { node: process.versions.node }) },
350
+ { level: "info", title: t("npm package {packageVersion}: {projectDir}", { packageVersion, projectDir: tilde(projectDir) }) }
341
351
  ];
342
352
  const binaryVersion = fs.existsSync(petBinary) ? (run(petBinary, ["--version"]) || "").trim().replace(/^cc-pets\s+/, "") : null;
343
353
  if (!binaryVersion) {
344
- program.push({ level: "fail", title: "原生程序未构建或无法运行", fix: "cc-pets install" });
354
+ program.push({ level: "fail", title: t("Native binary isn't built or can't run"), fix: "cc-pets install" });
345
355
  } else if (binaryVersion !== packageVersion) {
346
- program.push({ level: "warn", title: `原生程序版本 ${binaryVersion} 与 npm 包 ${packageVersion} 不一致`, fix: "cc-pets install" });
356
+ program.push({ level: "warn", title: t("Native binary {binaryVersion} doesn't match npm package {packageVersion}", { binaryVersion, packageVersion }), fix: "cc-pets install" });
347
357
  } else {
348
- program.push({ level: "ok", title: `原生程序 ${binaryVersion}` });
358
+ program.push({ level: "ok", title: t("Native binary {binaryVersion}", { binaryVersion }) });
349
359
  }
350
360
  const appVersion = versionOfApp(installedApp);
351
361
  if (!appVersion) {
352
- program.push({ level: "warn", title: `未找到已安装的 App:${tilde(installedApp)}`, fix: "cc-pets install" });
362
+ program.push({ level: "warn", title: t("Installed app not found: {installedApp}", { installedApp: tilde(installedApp) }), fix: "cc-pets install" });
353
363
  } else if (appVersion !== packageVersion) {
354
- program.push({ level: "warn", title: `已安装的 App 版本 ${appVersion} 与 npm 包 ${packageVersion} 不一致`, fix: "cc-pets install" });
364
+ program.push({ level: "warn", title: t("Installed app {appVersion} doesn't match npm package {packageVersion}", { appVersion, packageVersion }), fix: "cc-pets install" });
355
365
  } else {
356
- program.push({ level: "ok", title: `已安装的 App ${appVersion}` });
366
+ program.push({ level: "ok", title: t("Installed app {appVersion}", { appVersion }) });
357
367
  }
358
- if (native) program.push({ level: "info", title: native.running ? "桌宠正在运行" : "桌宠未运行" });
368
+ if (native) program.push({ level: "info", title: native.running ? t("The pet is running") : t("The pet isn't running") });
359
369
  const updater = updaterCheck(native);
360
370
  if (updater) program.push(updater);
361
- sections.push({ title: "程序", results: program });
371
+ sections.push({ title: t("Program"), results: program });
362
372
 
363
373
  let claudeBridgeHooks = 0;
364
374
  if (claudeDetected) {
@@ -373,12 +383,12 @@ const runDoctor = () => {
373
383
  modified = null;
374
384
  }
375
385
  claude.push(modified
376
- ? { level: "info", title: `Claude 额度快照更新于 ${formatAge(Date.now() - modified)}` }
377
- : { level: "info", title: "暂无 Claude 额度快照(Claude Code 首次收到 API 响应后生成)" });
386
+ ? { level: "info", title: t("Claude quota snapshot updated {age}", { age: formatAge(Date.now() - modified) }) }
387
+ : { level: "info", title: t("No Claude quota snapshot yet (created after Claude Code's first API response)") });
378
388
  }
379
389
  sections.push({ title: "Claude Code", results: claude });
380
390
  } else {
381
- sections.push({ title: "Claude Code", results: [{ level: "info", title: "未检测到 Claude Code CLI,跳过" }] });
391
+ sections.push({ title: "Claude Code", results: [{ level: "info", title: t("Claude Code CLI not detected, skipped") }] });
382
392
  }
383
393
 
384
394
  let codexBridgeHooks = 0;
@@ -389,15 +399,15 @@ const runDoctor = () => {
389
399
  title: "Codex",
390
400
  results: [
391
401
  ...results,
392
- { level: "info", title: "Codex 需要在 /hooks 中信任 CC Pets Hooks 后才会触发(无法自动检测)" }
402
+ { level: "info", title: t("Codex only runs CC Pets hooks after you trust them in /hooks (can't be checked automatically)") }
393
403
  ]
394
404
  });
395
405
  } else {
396
- sections.push({ title: "Codex", results: [{ level: "info", title: "未检测到 Codex CLI,跳过" }] });
406
+ sections.push({ title: "Codex", results: [{ level: "info", title: t("Codex CLI not detected, skipped") }] });
397
407
  }
398
408
 
399
409
  sections.push({
400
- title: "Shell 集成",
410
+ title: t("Shell integration"),
401
411
  results: [
402
412
  ...shimChecks(),
403
413
  ...(codexDetected ? [realBinaryCheck("codex", "CODEX_REAL_BIN")] : []),
@@ -406,29 +416,29 @@ const runDoctor = () => {
406
416
  });
407
417
 
408
418
  if (!isBridgeEnabled()) {
409
- sections.push({ title: "CC Bridge", results: [{ level: "info", title: "未开启(可选功能,cc-pets bridge enable 开启)" }] });
419
+ sections.push({ title: "CC Bridge", results: [{ level: "info", title: t("Off (optional; turn on with cc-pets bridge enable)") }] });
410
420
  } else {
411
- const bridge = [{ level: "ok", title: "已开启" }];
421
+ const bridge = [{ level: "ok", title: t("Enabled") }];
412
422
  if (claudeDetected) {
413
423
  bridge.push(claudeBridgeHooks > 0
414
- ? { level: "ok", title: "Claude Code 中的 CC Bridge Hooks 已安装" }
415
- : { level: "warn", title: "Claude Code 中缺少 CC Bridge Hooks", fix: "cc-pets bridge enable" });
424
+ ? { level: "ok", title: t("CC Bridge hooks installed in Claude Code") }
425
+ : { level: "warn", title: t("CC Bridge hooks missing in Claude Code"), fix: "cc-pets bridge enable" });
416
426
  }
417
427
  if (codexDetected) {
418
428
  bridge.push(codexBridgeHooks > 0
419
- ? { level: "ok", title: "Codex 中的 CC Bridge Hooks 已安装" }
420
- : { level: "warn", title: "Codex 中缺少 CC Bridge Hooks", fix: "cc-pets bridge enable" });
429
+ ? { level: "ok", title: t("CC Bridge hooks installed in Codex") }
430
+ : { level: "warn", title: t("CC Bridge hooks missing in Codex"), fix: "cc-pets bridge enable" });
421
431
  if (currentOptions().wake) {
422
432
  const notice = describeCodexQueue(probeCodexQueue());
423
433
  bridge.push(notice
424
434
  ? { level: "warn", title: notice }
425
- : { level: "ok", title: "Codex 支持 codex queue,可自动唤醒" });
435
+ : { level: "ok", title: t("Codex supports codex queue, so it can be woken automatically") });
426
436
  }
427
437
  }
428
438
  sections.push({ title: "CC Bridge", results: bridge });
429
439
  }
430
440
 
431
- console.log(`CC Pets 诊断(npm 包 ${packageVersion},${os.platform()} ${os.release()})`);
441
+ console.log(t("CC Pets diagnostics (npm package {packageVersion}, {platform} {release})", { packageVersion, platform: os.platform(), release: os.release() }));
432
442
  const counts = { ok: 0, warn: 0, fail: 0, info: 0 };
433
443
  for (const section of sections) {
434
444
  console.log(`\n${section.title}`);
@@ -438,8 +448,12 @@ const runDoctor = () => {
438
448
  if (result.fix) console.log(` → ${result.fix}`);
439
449
  }
440
450
  }
441
- console.log(`\n结果:${counts.ok} 项正常,${counts.warn} 项警告,${counts.fail} 项错误。`);
442
- if (counts.fail + counts.warn > 0) console.log("多数问题执行 cc-pets install 即可修复;数据位置见 cc-pets paths。");
451
+ const warnings = counts.warn !== 1
452
+ ? t("{count} warnings", { count: counts.warn }) : t("{count} warning", { count: counts.warn });
453
+ const errors = counts.fail !== 1
454
+ ? t("{count} errors", { count: counts.fail }) : t("{count} error", { count: counts.fail });
455
+ console.log(t("\nResult: {ok} OK, {warnings}, {errors}.", { ok: counts.ok, warnings, errors }));
456
+ if (counts.fail + counts.warn > 0) console.log(t("Most problems are fixed by cc-pets install; see cc-pets paths for data locations."));
443
457
  return counts.fail > 0 ? 1 : 0;
444
458
  };
445
459
 
@@ -451,6 +465,6 @@ if (command === "paths") {
451
465
  } else if (command === "doctor") {
452
466
  process.exitCode = runDoctor();
453
467
  } else {
454
- console.error("用法: doctor.mjs paths [--json] | doctor");
468
+ console.error(t("Usage: doctor.mjs paths [--json] | doctor"));
455
469
  process.exitCode = 2;
456
470
  }