cc-pets 2.2.0 → 2.3.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/CC_BRIDGE.md +5 -2
- package/CC_BRIDGE.zh-CN.md +4 -2
- package/CHANGELOG.md +85 -0
- package/CHANGELOG.zh-CN.md +85 -0
- package/CONTRIBUTING.md +28 -11
- package/CONTRIBUTING.zh-CN.md +23 -11
- package/README.md +127 -27
- package/README.zh-CN.md +104 -30
- package/Resources/zh-Hans.lproj/Localizable.strings +573 -17
- package/Sources/CCPets/{CCPetsAppDelegate+AgentEvents.m → App/CCPetsAppDelegate+AgentEvents.m} +15 -5
- package/Sources/CCPets/{CCPetsAppDelegate+AgentStatus.m → App/CCPetsAppDelegate+AgentStatus.m} +89 -31
- package/Sources/CCPets/{CCPetsAppDelegate+Bridge.m → App/CCPetsAppDelegate+Bridge.m} +35 -24
- package/Sources/CCPets/{CCPetsAppDelegate+Pets.m → App/CCPetsAppDelegate+Pets.m} +18 -4
- package/Sources/CCPets/{CCPetsAppDelegate+Private.h → App/CCPetsAppDelegate+Private.h} +90 -21
- package/Sources/CCPets/App/CCPetsAppDelegate+Profiles.m +238 -0
- package/Sources/CCPets/{CCPetsAppDelegate+Quota.m → App/CCPetsAppDelegate+Quota.m} +47 -32
- package/Sources/CCPets/App/CCPetsAppDelegate+Settings.m +269 -0
- package/Sources/CCPets/{CCPetsAppDelegate+Speech.m → App/CCPetsAppDelegate+Speech.m} +13 -7
- package/Sources/CCPets/{CCPetsAppDelegate+Update.m → App/CCPetsAppDelegate+Update.m} +71 -47
- package/Sources/CCPets/App/CCPetsAppDelegate+Workbench.m +139 -0
- package/Sources/CCPets/{CCPetsAppDelegate.h → App/CCPetsAppDelegate.h} +16 -2
- package/Sources/CCPets/{CCPetsAppDelegate.m → App/CCPetsAppDelegate.m} +110 -12
- package/Sources/CCPets/App/CCPetsOpenCommand.h +13 -0
- package/Sources/CCPets/App/CCPetsOpenCommand.m +99 -0
- package/Sources/CCPets/{main.m → App/main.m} +68 -1
- package/Sources/CCPets/{CCPetsBridge.h → Bridge/CCPetsBridge.h} +17 -4
- package/Sources/CCPets/{CCPetsBridge.m → Bridge/CCPetsBridge.m} +32 -17
- package/Sources/CCPets/Bridge/CCPetsBridgeCLI.h +10 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeCLI.m +792 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeCore.h +60 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeCore.m +558 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeSetup.h +24 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeSetup.m +501 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeStore.h +103 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeStore.m +779 -0
- package/Sources/CCPets/Integrations/CCPetsCLISupport.h +75 -0
- package/Sources/CCPets/Integrations/CCPetsCLISupport.m +342 -0
- package/Sources/CCPets/Integrations/CCPetsEvents.h +15 -0
- package/Sources/CCPets/{CCPetsEvents.m → Integrations/CCPetsEvents.m} +23 -0
- package/Sources/CCPets/Integrations/CCPetsIntegrations.h +51 -0
- package/Sources/CCPets/Integrations/CCPetsIntegrations.m +662 -0
- package/Sources/CCPets/Integrations/CCPetsProfiles.h +38 -0
- package/Sources/CCPets/Integrations/CCPetsProfiles.m +516 -0
- package/Sources/CCPets/{CCPetsTerminalFocus.m → Integrations/CCPetsTerminalFocus.m} +42 -12
- package/Sources/CCPets/Pet/CCPetsImageLoader.h +5 -0
- package/Sources/CCPets/{CCPetsImageLoader.m → Pet/CCPetsImageLoader.m} +10 -2
- package/Sources/CCPets/Pet/CCPetsPetSize.h +10 -0
- package/Sources/CCPets/Pet/CCPetsPetSize.m +21 -0
- package/Sources/CCPets/Pet/CCPetsPetStore.h +12 -0
- package/Sources/CCPets/Pet/CCPetsPetStore.m +476 -0
- package/Sources/CCPets/{CCPetsPhrases.h → Pet/CCPetsPhrases.h} +18 -2
- package/Sources/CCPets/{CCPetsPhrases.m → Pet/CCPetsPhrases.m} +53 -22
- package/Sources/CCPets/{CCPetsPhrasesEditor.m → Pet/CCPetsPhrasesEditor.m} +42 -2
- package/Sources/CCPets/Pet/PetView+Interaction.m +207 -0
- package/Sources/CCPets/Pet/PetView+Menu.m +598 -0
- package/Sources/CCPets/Pet/PetView+MicroBehavior.m +234 -0
- package/Sources/CCPets/Pet/PetView+Private.h +81 -0
- package/Sources/CCPets/{PetView.h → Pet/PetView.h} +3 -5
- package/Sources/CCPets/Pet/PetView.m +635 -0
- package/Sources/CCPets/Support/CCPetsDoctor.h +25 -0
- package/Sources/CCPets/Support/CCPetsDoctor.m +632 -0
- package/Sources/CCPets/Support/CCPetsJSON.h +27 -0
- package/Sources/CCPets/Support/CCPetsJSON.m +397 -0
- package/Sources/CCPets/{CCPetsL10n.h → Support/CCPetsL10n.h} +3 -1
- package/Sources/CCPets/{CCPetsL10n.m → Support/CCPetsL10n.m} +30 -1
- package/Sources/CCPets/Support/CCPetsPreferences.h +31 -0
- package/Sources/CCPets/Support/CCPetsPreferences.m +85 -0
- package/Sources/CCPets/UI/CCPetsDiagnosticsPage.h +25 -0
- package/Sources/CCPets/UI/CCPetsDiagnosticsPage.m +440 -0
- package/Sources/CCPets/UI/CCPetsFormBuilder.h +42 -0
- package/Sources/CCPets/UI/CCPetsFormBuilder.m +268 -0
- package/Sources/CCPets/{CCPetsGlassView.h → UI/CCPetsGlassView.h} +5 -1
- package/Sources/CCPets/{CCPetsGlassView.m → UI/CCPetsGlassView.m} +25 -7
- package/Sources/CCPets/UI/CCPetsMainWindow.h +55 -0
- package/Sources/CCPets/UI/CCPetsMainWindow.m +730 -0
- package/Sources/CCPets/UI/CCPetsSettingsPage.h +62 -0
- package/Sources/CCPets/UI/CCPetsSettingsPage.m +917 -0
- package/Sources/CCPets/UI/CCPetsUIStyle.h +132 -0
- package/Sources/CCPets/UI/CCPetsUIStyle.m +816 -0
- package/Sources/CCPets/UI/CCPetsUsageChartView.h +15 -0
- package/Sources/CCPets/UI/CCPetsUsageChartView.m +284 -0
- package/Sources/CCPets/UI/CCPetsUsagePage.h +32 -0
- package/Sources/CCPets/UI/CCPetsUsagePage.m +717 -0
- package/Sources/CCPets/UI/CCPetsUsageShared.h +53 -0
- package/Sources/CCPets/UI/CCPetsUsageStore.m +120 -0
- package/Sources/CCPets/UI/CCPetsUsageWidgets.h +30 -0
- package/Sources/CCPets/UI/CCPetsUsageWidgets.m +201 -0
- package/Sources/CCPets/UI/CCPetsWorkbench.h +40 -0
- package/Sources/CCPets/UI/CCPetsWorkbenchPages.h +13 -0
- package/Sources/CCPets/UI/CCPetsWorkbenchPages.m +783 -0
- package/Sources/CCPets/{MenuChoiceRow.m → UI/MenuChoiceRow.m} +3 -0
- package/Sources/CCPets/UI/MenuPetSizeView.h +5 -0
- package/Sources/CCPets/UI/MenuPetSizeView.m +73 -0
- package/Sources/CCPets/{MenuToggleSwitch.m → UI/MenuToggleSwitch.m} +1 -0
- package/Sources/CCPets/{CCPetsCodexRateLimits.h → Usage/CCPetsCodexRateLimits.h} +1 -0
- package/Sources/CCPets/{CCPetsCodexRateLimits.m → Usage/CCPetsCodexRateLimits.m} +10 -3
- package/Sources/CCPets/{CCPetsQuotaHistory.h → Usage/CCPetsQuotaHistory.h} +3 -0
- package/Sources/CCPets/{CCPetsQuotaHistory.m → Usage/CCPetsQuotaHistory.m} +58 -0
- package/Sources/CCPets/Usage/CCPetsUsage+ClaudeReader.m +436 -0
- package/Sources/CCPets/Usage/CCPetsUsage+CodexReader.m +392 -0
- package/Sources/CCPets/Usage/CCPetsUsage+CodexSessions.m +484 -0
- package/Sources/CCPets/Usage/CCPetsUsage+Internal.h +96 -0
- package/Sources/CCPets/Usage/CCPetsUsage+Models.m +285 -0
- package/Sources/CCPets/Usage/CCPetsUsage+TokenTotals.m +655 -0
- package/Sources/CCPets/Usage/CCPetsUsage.h +57 -0
- package/Sources/CCPets/Usage/CCPetsUsage.m +225 -0
- package/Sources/CCPets/Usage/CCPetsUsageMode.h +10 -0
- package/Sources/CCPets/Usage/CCPetsUsageMode.m +163 -0
- package/Sources/CCPets/{CCPetsUsageMonitor.h → Usage/CCPetsUsageMonitor.h} +3 -0
- package/Sources/CCPets/{CCPetsUsageMonitor.m → Usage/CCPetsUsageMonitor.m} +163 -6
- package/Sources/CCPets/Usage/QuotaDashboardView+Primitives.m +328 -0
- package/Sources/CCPets/Usage/QuotaDashboardView+Private.h +103 -0
- package/Sources/CCPets/Usage/QuotaDashboardView+Rendering.m +616 -0
- package/Sources/CCPets/{QuotaDashboardView.h → Usage/QuotaDashboardView.h} +17 -0
- package/Sources/CCPets/Usage/QuotaDashboardView.m +587 -0
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/THIRD_PARTY_NOTICES.zh-CN.md +1 -1
- package/bin/cc-pets +8 -6
- package/bin/claude-with-pet +10 -2
- package/bin/codex-with-pet +13 -5
- package/package.json +1 -1
- package/scripts/build.sh +7 -3
- package/scripts/i18n.zsh +9 -52
- package/scripts/install-app.sh +4 -0
- package/scripts/install-shell-integration.sh +17 -10
- package/scripts/uninstall-shell-integration.sh +6 -1
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +0 -226
- package/Sources/CCPets/CCPetsEvents.h +0 -10
- package/Sources/CCPets/CCPetsImageLoader.h +0 -4
- package/Sources/CCPets/CCPetsUsage.h +0 -36
- package/Sources/CCPets/CCPetsUsage.m +0 -2069
- package/Sources/CCPets/PetView.m +0 -1806
- package/Sources/CCPets/QuotaDashboardView.m +0 -1145
- package/scripts/bridge/cli.mjs +0 -237
- package/scripts/bridge/core.mjs +0 -228
- package/scripts/bridge/hook.mjs +0 -150
- package/scripts/bridge/install.mjs +0 -311
- package/scripts/bridge/mcp-server.mjs +0 -308
- package/scripts/bridge/options.mjs +0 -87
- package/scripts/bridge/process.mjs +0 -151
- package/scripts/bridge/reservations.mjs +0 -248
- package/scripts/bridge/store.mjs +0 -433
- package/scripts/bridge/watch.mjs +0 -69
- package/scripts/check-l10n.mjs +0 -168
- package/scripts/configure-updater.mjs +0 -43
- package/scripts/detect-cli.mjs +0 -68
- package/scripts/doctor.mjs +0 -470
- package/scripts/i18n.mjs +0 -122
- package/scripts/install-claude-hooks.mjs +0 -253
- package/scripts/install-codex-hooks.mjs +0 -78
- package/scripts/integration-markers.mjs +0 -51
- package/scripts/locales/zh-Hans.json +0 -366
- package/scripts/pet-store.mjs +0 -415
- package/scripts/uninstall-integrations.mjs +0 -205
- /package/Sources/CCPets/{CCPetsVersion.h → App/CCPetsVersion.h} +0 -0
- /package/Sources/CCPets/{CCPetsVersion.m → App/CCPetsVersion.m} +0 -0
- /package/Sources/CCPets/{CCPetsTerminalFocus.h → Integrations/CCPetsTerminalFocus.h} +0 -0
- /package/Sources/CCPets/{CCPetsPhrasesEditor.h → Pet/CCPetsPhrasesEditor.h} +0 -0
- /package/Sources/CCPets/{CCPetsPreviews.h → Pet/CCPetsPreviews.h} +0 -0
- /package/Sources/CCPets/{CCPetsPreviews.m → Pet/CCPetsPreviews.m} +0 -0
- /package/Sources/CCPets/Resources/{/351/273/230/350/256/244.webp" → ByteMochi.webp} +0 -0
- /package/Sources/CCPets/{CCPetsCleanup.h → Support/CCPetsCleanup.h} +0 -0
- /package/Sources/CCPets/{CCPetsCleanup.m → Support/CCPetsCleanup.m} +0 -0
- /package/Sources/CCPets/{CCPetsPaths.h → Support/CCPetsPaths.h} +0 -0
- /package/Sources/CCPets/{CCPetsPaths.m → Support/CCPetsPaths.m} +0 -0
- /package/Sources/CCPets/{CCPetsSystemMonitor.h → Support/CCPetsSystemMonitor.h} +0 -0
- /package/Sources/CCPets/{CCPetsSystemMonitor.m → Support/CCPetsSystemMonitor.m} +0 -0
- /package/Sources/CCPets/{CCPetsGlassMenu.h → UI/CCPetsGlassMenu.h} +0 -0
- /package/Sources/CCPets/{CCPetsGlassMenu.m → UI/CCPetsGlassMenu.m} +0 -0
- /package/Sources/CCPets/{MenuChoiceRow.h → UI/MenuChoiceRow.h} +0 -0
- /package/Sources/CCPets/{MenuHintView.h → UI/MenuHintView.h} +0 -0
- /package/Sources/CCPets/{MenuHintView.m → UI/MenuHintView.m} +0 -0
- /package/Sources/CCPets/{MenuToggleSwitch.h → UI/MenuToggleSwitch.h} +0 -0
package/bin/codex-with-pet
CHANGED
|
@@ -45,16 +45,24 @@ export CC_PETS_TERMINAL_TTY="${TTY:-}"
|
|
|
45
45
|
export CC_PETS_TERMINAL_PROGRAM="${TERM_PROGRAM:-}"
|
|
46
46
|
export CC_PETS_TERMINAL_SESSION="${TERM_SESSION_ID:-${ITERM_SESSION_ID:-}}"
|
|
47
47
|
export CC_PETS_TERMINAL_BUNDLE_ID="$("${PET_BIN}" --frontmost-bundle-id 2>/dev/null || true)"
|
|
48
|
+
# 从当前会话实际使用的 Home 解析已登记账号,让启动事件从第一帧就能归属到正确卡片。
|
|
49
|
+
CODEX_PROFILE_HOME="${CODEX_HOME:-${HOME}/.codex}"
|
|
50
|
+
CC_PETS_PROFILE_ID="$("${PET_BIN}" profile resolve --provider codex --home "${CODEX_PROFILE_HOME}" 2>/dev/null || true)"
|
|
51
|
+
if [[ -n "${CC_PETS_PROFILE_ID}" ]]; then
|
|
52
|
+
export CC_PETS_PROFILE_ID
|
|
53
|
+
CC_PETS_PROFILE_NAME="$("${PET_BIN}" profile resolve --provider codex --home "${CODEX_PROFILE_HOME}" --field name 2>/dev/null || true)"
|
|
54
|
+
[[ -n "${CC_PETS_PROFILE_NAME}" ]] && export CC_PETS_PROFILE_NAME
|
|
55
|
+
fi
|
|
48
56
|
|
|
49
57
|
mkdir -p "${CLIENT_DIR}"
|
|
50
|
-
#
|
|
51
|
-
printf '%s\n%s\n' 'Codex' "${CC_PETS_TERMINAL_TTY:t}" > "${CLIENT_FILE}"
|
|
58
|
+
# 依次记录 provider、TTY、profileId;旧版两行文件仍可按 provider 级在线兼容。
|
|
59
|
+
printf '%s\n%s\n%s\n' 'Codex' "${CC_PETS_TERMINAL_TTY:t}" "${CC_PETS_PROFILE_ID:-}" > "${CLIENT_FILE}"
|
|
52
60
|
|
|
53
61
|
# 新版 Codex 的 hook 由共享后台服务拉起,拿不到这里的终端环境;先登记,hook 再按会话配对。
|
|
54
62
|
"${PET_BIN}" --codex-launch >/dev/null 2>&1 || true
|
|
55
63
|
print -rn -- '{"schemaVersion":1,"provider":"Codex","state":"starting"}' | \
|
|
56
64
|
"${PET_BIN}" --provider-event >/dev/null 2>&1 || true
|
|
57
|
-
# 桌宠是常驻进程,会一直带着这里的环境。
|
|
58
|
-
#
|
|
59
|
-
env -u
|
|
65
|
+
# 桌宠是常驻进程,会一直带着这里的环境。CODEX_HOME 是会话级的,泄漏过去会让
|
|
66
|
+
# 桌宠里的通用 CLI 路径永久绑定到“第一个拉起它的账号”。
|
|
67
|
+
env -u CODEX_HOME open -g "${PET_APP}" --args --managed
|
|
60
68
|
exec "${REAL_CODEX}" "$@"
|
package/package.json
CHANGED
package/scripts/build.sh
CHANGED
|
@@ -10,7 +10,7 @@ APP_DIR="${BUILD_DIR}/CC Pets.app"
|
|
|
10
10
|
APP_MACOS_DIR="${APP_DIR}/Contents/MacOS"
|
|
11
11
|
APP_RESOURCES_DIR="${APP_DIR}/Contents/Resources"
|
|
12
12
|
RESOURCE_DIR="${CC_PETS_RESOURCE_DIR:-${PROJECT_DIR}/Sources/CCPets/Resources}"
|
|
13
|
-
PACKAGE_VERSION="$(
|
|
13
|
+
PACKAGE_VERSION="$(/usr/bin/plutil -extract version raw -o - "${PROJECT_DIR}/package.json")"
|
|
14
14
|
mkdir -p "${BUILD_DIR}" "${CACHE_DIR}" "${APP_MACOS_DIR}" "${APP_RESOURCES_DIR}"
|
|
15
15
|
|
|
16
16
|
# 之前没有任何优化和告警选项:默认等于 -O0,且第一次开启 -Wall -Wextra 就抓到了
|
|
@@ -21,7 +21,11 @@ if [[ "${CC_PETS_STRICT:-0}" == "1" ]]; then
|
|
|
21
21
|
WARNING_FLAGS+=(-Werror)
|
|
22
22
|
fi
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
# 源码按模块分子目录存放:递归收集 .m,并把每个含头文件的目录加进 -I,
|
|
25
|
+
# 这样 #import "CCPetsXxx.h" 不用写相对路径,文件挪目录也不用改这里。
|
|
26
|
+
SOURCES=("${PROJECT_DIR}"/Sources/CCPets/**/*.m(N))
|
|
27
|
+
HEADERS=("${PROJECT_DIR}"/Sources/CCPets/**/*.h(N))
|
|
28
|
+
INCLUDE_FLAGS=(-I${^${(u)HEADERS:h}})
|
|
25
29
|
if (( ${#SOURCES[@]} == 0 )); then
|
|
26
30
|
print -u2 "$(cc_pets_t "Build failed: no .m source files found in Sources/CCPets.")"
|
|
27
31
|
exit 1
|
|
@@ -34,7 +38,7 @@ CLANG_MODULE_CACHE_PATH="${CACHE_DIR}" clang \
|
|
|
34
38
|
-Os \
|
|
35
39
|
"${WARNING_FLAGS[@]}" \
|
|
36
40
|
"-DCC_PETS_VERSION=\"${PACKAGE_VERSION}\"" \
|
|
37
|
-
|
|
41
|
+
"${INCLUDE_FLAGS[@]}" \
|
|
38
42
|
-framework Cocoa \
|
|
39
43
|
-framework CoreServices \
|
|
40
44
|
-framework ImageIO \
|
package/scripts/i18n.zsh
CHANGED
|
@@ -1,63 +1,20 @@
|
|
|
1
|
-
# zsh 脚本的多语言,和
|
|
2
|
-
# CC_PETS_LANGUAGE → ~/.cc-pets/language(桌宠菜单里选的语言)→ LC_ALL / LC_MESSAGES / LANG → 英文。
|
|
1
|
+
# zsh 脚本的多语言,和 App 共用 Resources/<语言>.lproj/Localizable.strings:
|
|
3
2
|
#
|
|
4
3
|
# print "$(cc_pets_t "Built: {path}" path="${BUILD_DIR}/cc-pets")"
|
|
5
4
|
#
|
|
6
|
-
# 第一个参数是英文原文(也是表的 key),必须是字面量,
|
|
5
|
+
# 第一个参数是英文原文(也是表的 key),必须是字面量,tests/check-l10n.mjs 会把它和表对上;
|
|
7
6
|
# 变量一律走 {name} 占位,不能直接写进原文,否则 key 每次都不一样,永远查不到。
|
|
8
|
-
#
|
|
9
|
-
#
|
|
7
|
+
# 查表和选语言交给原生程序(cc-pets --localize),规则与其他命令行输出一致:
|
|
8
|
+
# CC_PETS_LANGUAGE → ~/.cc-pets/language(桌宠菜单里选的语言)→ LC_ALL / LC_MESSAGES / LANG → 系统。
|
|
9
|
+
# 原生程序还没构建出来时(首次安装、构建失败)退回英文,总比什么都不说好。
|
|
10
10
|
|
|
11
|
-
typeset -g
|
|
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
|
-
}
|
|
11
|
+
typeset -g _CC_PETS_BINARY="${${(%):-%x}:A:h:h}/.build/release/cc-pets"
|
|
54
12
|
|
|
55
13
|
cc_pets_t() {
|
|
56
|
-
local text="$1" pair
|
|
14
|
+
local text="$1" pair
|
|
57
15
|
shift
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
CC_PETS_LANGUAGE="${language}" node "${_CC_PETS_I18N_DIR}/i18n.mjs" "${text}" "$@" && return 0
|
|
16
|
+
if [[ -x "${_CC_PETS_BINARY}" ]]; then
|
|
17
|
+
"${_CC_PETS_BINARY}" --localize "${text}" "$@" && return 0
|
|
61
18
|
fi
|
|
62
19
|
for pair in "$@"; do
|
|
63
20
|
text="${text//"{${pair%%=*}}"/${pair#*=}}"
|
package/scripts/install-app.sh
CHANGED
|
@@ -34,4 +34,8 @@ if ! mv "${STAGING_APP}" "${TARGET_APP}"; then
|
|
|
34
34
|
exit 1
|
|
35
35
|
fi
|
|
36
36
|
|
|
37
|
+
# 装进去的 App 是拷贝,自己找不到 npm 包在哪;留个记号让诊断页能对上包的版本和 hook 路径。
|
|
38
|
+
APP_SUPPORT_DIR="${CC_PETS_APPLICATION_SUPPORT_DIR:-${HOME}/Library/Application Support/CC Pets}"
|
|
39
|
+
mkdir -p "${APP_SUPPORT_DIR}" && print -r -- "${PROJECT_DIR}" > "${APP_SUPPORT_DIR}/package-dir" || true
|
|
40
|
+
|
|
37
41
|
print "$(cc_pets_t "App installed: {targetApp}" targetApp="${TARGET_APP}")"
|
|
@@ -11,25 +11,31 @@ SHIM_DIR="${CC_PETS_SHIM_DIR:-${HOME}/.cc-pets/shims}"
|
|
|
11
11
|
SHIM_START_MARKER="# >>> cc-pets-shims >>>"
|
|
12
12
|
SHIM_END_MARKER="# <<< cc-pets-shims <<<"
|
|
13
13
|
|
|
14
|
+
# 安装本身不需要 Node。npm 装包时 node 所在目录(nvm 之类)里通常也有 claude / codex,
|
|
15
|
+
# 补进 PATH,下面探测 CLI、注册 MCP 才找得到它们。
|
|
14
16
|
NODE_EXECUTABLE="${npm_node_execpath:-}"
|
|
15
17
|
if [[ -z "${NODE_EXECUTABLE}" || ! -x "${NODE_EXECUTABLE}" ]]; then
|
|
16
18
|
NODE_EXECUTABLE="$(command -v node || true)"
|
|
17
19
|
fi
|
|
18
|
-
if [[ -
|
|
19
|
-
|
|
20
|
-
exit 1
|
|
20
|
+
if [[ -n "${NODE_EXECUTABLE}" && -x "${NODE_EXECUTABLE}" ]]; then
|
|
21
|
+
export PATH="${NODE_EXECUTABLE:h}:${PATH:-/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
21
22
|
fi
|
|
22
|
-
export PATH="${NODE_EXECUTABLE:h}:${PATH:-/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
23
23
|
|
|
24
|
-
"${NODE_EXECUTABLE}" "${PROJECT_DIR}/scripts/uninstall-integrations.mjs" --prepare-install "${SHELL_RC}"
|
|
25
24
|
"${PROJECT_DIR}/scripts/build.sh"
|
|
25
|
+
PET_BINARY="${PROJECT_DIR}/.build/release/cc-pets"
|
|
26
|
+
# 只迁移已经含 CC Pets 管理标记的默认 Home;不扫描或自动接管其他目录。
|
|
27
|
+
"${PET_BINARY}" profile migrate
|
|
28
|
+
# 官方默认 Home 保持旧版的自动集成行为;其他 Home 仍必须从菜单手动导入。
|
|
29
|
+
"${PET_BINARY}" profile ensure-defaults
|
|
30
|
+
# 先迁移改名前留下的旧条目和 alias 段落,当前版本的集成留给下面原位覆盖。
|
|
31
|
+
"${PET_BINARY}" --uninstall-integrations --prepare-install "${SHELL_RC}"
|
|
26
32
|
"${PROJECT_DIR}/scripts/install-app.sh"
|
|
27
|
-
|
|
28
|
-
"${
|
|
29
|
-
"$
|
|
30
|
-
"${
|
|
33
|
+
# 安装/升级适配官方默认 Home,并修复用户明确登记过的自定义 Home。
|
|
34
|
+
"${PET_BINARY}" profile repair-all || \
|
|
35
|
+
print -u2 "$(cc_pets_t "Some registered Agent profiles need repair; open Multi-Account in the Main menu and retry.")"
|
|
36
|
+
"${PET_BINARY}" --configure-updater
|
|
31
37
|
# CC Bridge 默认关闭;用户开启过的话,包路径可能随升级变化,按原选项重写一遍集成。
|
|
32
|
-
"${
|
|
38
|
+
"${PET_BINARY}" bridge refresh || \
|
|
33
39
|
print -u2 "$(cc_pets_t "Failed to refresh the CC Bridge integration; retry later with cc-pets bridge enable.")"
|
|
34
40
|
|
|
35
41
|
PET_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
|
|
@@ -79,4 +85,5 @@ if ! grep -Fq "${SHIM_START_MARKER}" "${SHELL_RC}" 2>/dev/null; then
|
|
|
79
85
|
fi
|
|
80
86
|
|
|
81
87
|
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}")"
|
|
88
|
+
print "$(cc_pets_t "Default Claude and Codex Homes were integrated automatically; add custom Homes from Multi-Account in the Main menu.")"
|
|
82
89
|
print "$(cc_pets_t "After the first launch, run /hooks and trust the CC Pets hooks to enable Agent animations.")"
|
|
@@ -53,7 +53,12 @@ if [[ "${CC_PETS_SKIP_APP_STOP:-0}" != "1" ]]; then
|
|
|
53
53
|
fi
|
|
54
54
|
fi
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
if [[ ! -x "${PET_BIN}" ]]; then
|
|
57
|
+
"${PROJECT_DIR}/scripts/build.sh" >/dev/null
|
|
58
|
+
fi
|
|
59
|
+
# CC Bridge 先拆:它的 hooks 和放行规则也在 settings.json / hooks.json 里。
|
|
60
|
+
"${PET_BIN}" bridge teardown
|
|
61
|
+
"${PET_BIN}" --uninstall-integrations "${SHELL_RC}"
|
|
57
62
|
|
|
58
63
|
if (( PURGE )); then
|
|
59
64
|
if [[ ! -x "${PET_BIN}" ]]; then
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// 右键菜单里的各项设置开关。
|
|
2
|
-
#import "CCPetsAppDelegate+Private.h"
|
|
3
|
-
|
|
4
|
-
@implementation AppDelegate (Settings)
|
|
5
|
-
- (NSString *)systemMetricKeyForTag:(NSInteger)tag {
|
|
6
|
-
if (tag == 1) return SystemCPUEnabledKey;
|
|
7
|
-
if (tag == 2) return SystemTemperatureEnabledKey;
|
|
8
|
-
if (tag == 3) return SystemMemoryEnabledKey;
|
|
9
|
-
return nil;
|
|
10
|
-
}
|
|
11
|
-
- (void)applySystemMetricPreferences {
|
|
12
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
13
|
-
self.quotaView.systemCPUEnabled = [defaults boolForKey:SystemCPUEnabledKey];
|
|
14
|
-
self.quotaView.systemTemperatureEnabled =
|
|
15
|
-
[defaults boolForKey:SystemTemperatureEnabledKey];
|
|
16
|
-
self.quotaView.systemMemoryEnabled = [defaults boolForKey:SystemMemoryEnabledKey];
|
|
17
|
-
self.quotaView.needsDisplay = YES;
|
|
18
|
-
}
|
|
19
|
-
- (void)applyUsageDisplayModePreferences {
|
|
20
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
21
|
-
self.quotaView.codexShowsAPIUsage =
|
|
22
|
-
[[defaults stringForKey:CodexUsageDisplayModeKey] isEqualToString:@"api"];
|
|
23
|
-
self.quotaView.claudeShowsAPIUsage =
|
|
24
|
-
[[defaults stringForKey:ClaudeUsageDisplayModeKey] isEqualToString:@"api"];
|
|
25
|
-
self.quotaView.needsDisplay = YES;
|
|
26
|
-
}
|
|
27
|
-
- (void)setUsageDisplayModeFromControl:(NSButton *)sender {
|
|
28
|
-
NSString *key = sender.tag == 1 ? CodexUsageDisplayModeKey
|
|
29
|
-
: (sender.tag == 2 ? ClaudeUsageDisplayModeKey : nil);
|
|
30
|
-
NSString *mode = sender.state == NSControlStateValueOn ? @"api" : @"subscription";
|
|
31
|
-
if (!key) return;
|
|
32
|
-
[NSUserDefaults.standardUserDefaults setObject:mode forKey:key];
|
|
33
|
-
[self applyUsageDisplayModePreferences];
|
|
34
|
-
// 展示模式决定了会话要回溯多远(订阅 8 天 / API 到上月月初),切换之后必须重新聚合,
|
|
35
|
-
// 否则刚打开 API 视图时手里只有一段按 8 天窗口扫出来的数据。
|
|
36
|
-
[self refreshUsage:nil];
|
|
37
|
-
}
|
|
38
|
-
- (void)toggleSystemMetric:(NSButton *)sender {
|
|
39
|
-
NSString *key = [self systemMetricKeyForTag:sender.tag];
|
|
40
|
-
if (!key) return;
|
|
41
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
42
|
-
BOOL enabled = ![defaults boolForKey:key];
|
|
43
|
-
[defaults setBool:enabled forKey:key];
|
|
44
|
-
sender.state = enabled ? NSControlStateValueOn : NSControlStateValueOff;
|
|
45
|
-
[self applySystemMetricPreferences];
|
|
46
|
-
[self updateSystemMetricsTimer];
|
|
47
|
-
}
|
|
48
|
-
// 开关打开时立刻导入一次,不用等下次启动——用户点开关就是想现在看到那些素材。
|
|
49
|
-
- (void)toggleImportCodexPets:(NSButton *)sender {
|
|
50
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
51
|
-
BOOL enabled = ![defaults boolForKey:ImportCodexPetsKey];
|
|
52
|
-
[defaults setBool:enabled forKey:ImportCodexPetsKey];
|
|
53
|
-
sender.state = enabled ? NSControlStateValueOn : NSControlStateValueOff;
|
|
54
|
-
if (!enabled) return;
|
|
55
|
-
NSUInteger imported = ImportCodexPets();
|
|
56
|
-
if (imported == 0) return;
|
|
57
|
-
[self invalidatePetOptionsCache];
|
|
58
|
-
[self showImportedCodexPetsAlert:imported];
|
|
59
|
-
}
|
|
60
|
-
- (void)showImportedCodexPetsAlert:(NSUInteger)imported {
|
|
61
|
-
[NSApp activateIgnoringOtherApps:YES];
|
|
62
|
-
NSAlert *alert = [NSAlert new];
|
|
63
|
-
alert.messageText = L(@"Codex Pets Imported");
|
|
64
|
-
[alert addButtonWithTitle:L(@"OK")];
|
|
65
|
-
[alert runModal];
|
|
66
|
-
}
|
|
67
|
-
- (NSString *)notificationKeyForTag:(NSInteger)tag {
|
|
68
|
-
if (tag == 1) return NotificationCompletionKey;
|
|
69
|
-
if (tag == 2) return NotificationFailureKey;
|
|
70
|
-
if (tag == 3) return NotificationApprovalKey;
|
|
71
|
-
if (tag == 4) return NotificationStallKey;
|
|
72
|
-
return nil;
|
|
73
|
-
}
|
|
74
|
-
// sender 是菜单里的 MenuChoiceRowView,勾选状态由它自己更新。
|
|
75
|
-
- (void)setPanelTheme:(MenuChoiceRowView *)sender {
|
|
76
|
-
NSString *theme = sender.representedObject;
|
|
77
|
-
if (![@[@"classic", @"liquid"] containsObject:theme]) return;
|
|
78
|
-
[NSUserDefaults.standardUserDefaults setObject:theme forKey:CCPetsPanelThemeKey];
|
|
79
|
-
[self.statusGlass applyTheme];
|
|
80
|
-
[self.speechGlass applyTheme];
|
|
81
|
-
[self.quotaGlass applyTheme];
|
|
82
|
-
[self.updateBadgeGlass applyTheme];
|
|
83
|
-
self.statusShadowView.hidden = self.statusGlass.usesLiquidGlass;
|
|
84
|
-
self.quotaView.usesLiquidGlass = self.quotaGlass.usesLiquidGlass;
|
|
85
|
-
self.quotaView.cardScrimAlpha = CCPetsGlassCardScrimAlpha();
|
|
86
|
-
self.quotaView.needsDisplay = YES;
|
|
87
|
-
[self applyBubbleTextStyle];
|
|
88
|
-
// quotaView 换了父视图,mouseExited 不一定会送达;切主题是在宠物右键菜单里点的,
|
|
89
|
-
// 鼠标此刻不在面板上,直接复位,免得面板一直当作"悬停中"不收起。
|
|
90
|
-
self.dashboardHovering = NO;
|
|
91
|
-
}
|
|
92
|
-
// 状态卡和说话气泡原来是浅色磨砂配深色字;换成原生清透玻璃后背景是任意壁纸加一层
|
|
93
|
-
// 压暗,深色字会看不见,改成白字加贴字形的投影,和额度面板一致。
|
|
94
|
-
- (void)applyBubbleTextStyle {
|
|
95
|
-
NSShadow *shadow = [NSShadow new];
|
|
96
|
-
shadow.shadowColor = [NSColor colorWithWhite:0 alpha:0.45];
|
|
97
|
-
shadow.shadowBlurRadius = 2;
|
|
98
|
-
shadow.shadowOffset = NSMakeSize(0, -0.5);
|
|
99
|
-
BOOL statusLiquid = self.statusGlass.usesLiquidGlass;
|
|
100
|
-
self.statusTitleLabel.textColor = statusLiquid ? [NSColor colorWithWhite:1 alpha:0.78]
|
|
101
|
-
: [NSColor colorWithWhite:0.42 alpha:0.90];
|
|
102
|
-
self.statusDetailLabel.textColor = statusLiquid ? [NSColor colorWithWhite:1 alpha:0.97]
|
|
103
|
-
: [NSColor colorWithWhite:0.12 alpha:0.96];
|
|
104
|
-
self.statusTitleLabel.shadow = statusLiquid ? shadow : nil;
|
|
105
|
-
self.statusDetailLabel.shadow = statusLiquid ? shadow : nil;
|
|
106
|
-
BOOL speechLiquid = self.speechGlass.usesLiquidGlass;
|
|
107
|
-
self.speechLabel.textColor = speechLiquid ? [NSColor colorWithWhite:1 alpha:0.97]
|
|
108
|
-
: [NSColor colorWithWhite:0.10 alpha:0.96];
|
|
109
|
-
self.speechLabel.shadow = speechLiquid ? shadow : nil;
|
|
110
|
-
[self applyUpdateBadgeStyle];
|
|
111
|
-
}
|
|
112
|
-
- (void)setGlassDimLevel:(MenuChoiceRowView *)sender {
|
|
113
|
-
NSNumber *level = sender.representedObject;
|
|
114
|
-
if (![CCPetsGlassDimLevels() containsObject:level]) return;
|
|
115
|
-
[NSUserDefaults.standardUserDefaults setObject:level forKey:CCPetsGlassDimKey];
|
|
116
|
-
[self.quotaGlass applyDimLevel];
|
|
117
|
-
[self.statusGlass applyDimLevel];
|
|
118
|
-
[self.speechGlass applyDimLevel];
|
|
119
|
-
[self.updateBadgeGlass applyDimLevel];
|
|
120
|
-
self.quotaView.cardScrimAlpha = CCPetsGlassCardScrimAlpha();
|
|
121
|
-
self.quotaView.needsDisplay = YES;
|
|
122
|
-
}
|
|
123
|
-
- (void)toggleSpeech:(NSButton *)sender {
|
|
124
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
125
|
-
id current = [defaults objectForKey:@"CCPetsSpeechEnabled"];
|
|
126
|
-
BOOL enabled = current == nil ? YES : [current boolValue];
|
|
127
|
-
[defaults setBool:!enabled forKey:@"CCPetsSpeechEnabled"];
|
|
128
|
-
sender.state = !enabled ? NSControlStateValueOn : NSControlStateValueOff;
|
|
129
|
-
// 更新提示不算碎碎念,关掉碎碎念时不收它。
|
|
130
|
-
if (enabled && !self.updateBubbleVisible) [self hideSpeechBubble];
|
|
131
|
-
}
|
|
132
|
-
- (void)togglePetInteraction:(NSButton *)sender {
|
|
133
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
134
|
-
BOOL enabled = ![defaults boolForKey:PetInteractionEnabledKey];
|
|
135
|
-
[defaults setBool:enabled forKey:PetInteractionEnabledKey];
|
|
136
|
-
sender.state = enabled ? NSControlStateValueOn : NSControlStateValueOff;
|
|
137
|
-
}
|
|
138
|
-
- (void)setPetInteractionHeartThreshold:(NSMenuItem *)sender {
|
|
139
|
-
NSNumber *value = [sender.representedObject isKindOfClass:NSNumber.class] ?
|
|
140
|
-
sender.representedObject : @3;
|
|
141
|
-
[NSUserDefaults.standardUserDefaults setInteger:MAX((NSInteger)2, value.integerValue)
|
|
142
|
-
forKey:PetInteractionHeartThresholdKey];
|
|
143
|
-
}
|
|
144
|
-
- (void)setPetInteractionAnnoyedThreshold:(NSMenuItem *)sender {
|
|
145
|
-
NSNumber *value = [sender.representedObject isKindOfClass:NSNumber.class] ?
|
|
146
|
-
sender.representedObject : @10;
|
|
147
|
-
NSInteger heart = MAX((NSInteger)2, [NSUserDefaults.standardUserDefaults
|
|
148
|
-
integerForKey:PetInteractionHeartThresholdKey]);
|
|
149
|
-
[NSUserDefaults.standardUserDefaults setInteger:MAX(heart + 1, value.integerValue)
|
|
150
|
-
forKey:PetInteractionAnnoyedThresholdKey];
|
|
151
|
-
}
|
|
152
|
-
- (void)setPetInteractionInterval:(NSMenuItem *)sender {
|
|
153
|
-
NSNumber *value = [sender.representedObject isKindOfClass:NSNumber.class] ?
|
|
154
|
-
sender.representedObject : @1.2;
|
|
155
|
-
[NSUserDefaults.standardUserDefaults setDouble:MAX(0.4, MIN(3.0, value.doubleValue))
|
|
156
|
-
forKey:PetInteractionIntervalKey];
|
|
157
|
-
}
|
|
158
|
-
// 频率档位。改完立刻生效——四道闸都是现读的,不缓存。
|
|
159
|
-
// 顺手把冷却清掉,否则刚调高档位还要等完上一档的冷却才见效,会让人以为没生效。
|
|
160
|
-
- (void)setSpeechFrequency:(NSMenuItem *)sender {
|
|
161
|
-
NSString *value = [sender.representedObject isKindOfClass:NSString.class] ?
|
|
162
|
-
sender.representedObject : PetSpeechFrequencyNormal;
|
|
163
|
-
[NSUserDefaults.standardUserDefaults setObject:value forKey:PetSpeechFrequencyKey];
|
|
164
|
-
self.speechCooldownUntil = 0;
|
|
165
|
-
self.lastIdleSpeechCheck = 0;
|
|
166
|
-
}
|
|
167
|
-
// 台词交给内置编辑器,不再 openURL: 丢给"文本编辑"。
|
|
168
|
-
//
|
|
169
|
-
// 换掉的理由是反馈:系统编辑器保存完什么都不会说,小节名拼错、句子超 30 字、槽位
|
|
170
|
-
// 写错名字全是静默失效,用户只知道"改了没用"。内置编辑器保存时校验并当场报出来,
|
|
171
|
-
// 还能"试说一句"直接听效果。
|
|
172
|
-
- (void)editPhrasesFile:(id)sender {
|
|
173
|
-
// 编辑器只管文本,不认识气泡;把"说出来"这一步作为回调注入。
|
|
174
|
-
__weak typeof(self) weakSelf = self;
|
|
175
|
-
[PetPhrasesEditorController setSpeakHandler:^(NSString *text) {
|
|
176
|
-
[weakSelf presentSpeechText:text];
|
|
177
|
-
}];
|
|
178
|
-
[PetPhrasesEditorController present];
|
|
179
|
-
}
|
|
180
|
-
- (void)toggleNotification:(NSButton *)sender {
|
|
181
|
-
NSString *key = [self notificationKeyForTag:sender.tag];
|
|
182
|
-
if (!key) return;
|
|
183
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
184
|
-
if ([defaults boolForKey:key]) {
|
|
185
|
-
[defaults setBool:NO forKey:key];
|
|
186
|
-
sender.state = NSControlStateValueOff;
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
[UNUserNotificationCenter.currentNotificationCenter
|
|
190
|
-
requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionSound
|
|
191
|
-
completionHandler:^(BOOL granted, NSError *error) {
|
|
192
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
193
|
-
if (granted) {
|
|
194
|
-
[defaults setBool:YES forKey:key];
|
|
195
|
-
sender.state = NSControlStateValueOn;
|
|
196
|
-
} else {
|
|
197
|
-
sender.state = NSControlStateValueOff;
|
|
198
|
-
NSString *message = error.localizedDescription ?:
|
|
199
|
-
L(@"Allow notifications in System Settings → Notifications → CC Pets, then try again.");
|
|
200
|
-
[self showAlertWithTitle:L(@"Can't Enable Notifications") message:message];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}];
|
|
204
|
-
}
|
|
205
|
-
// 菜单每次右键现建,切换后下次打开就是新语言;这里只刷新常驻的界面。
|
|
206
|
-
- (void)setLanguagePreferenceFromMenu:(NSMenuItem *)sender {
|
|
207
|
-
NSString *preference = [sender.representedObject isKindOfClass:NSString.class] ?
|
|
208
|
-
sender.representedObject : CCPetsLanguageSystem;
|
|
209
|
-
if ([preference isEqualToString:CCPetsLanguagePreference()]) return;
|
|
210
|
-
CCPetsSetLanguagePreference(preference);
|
|
211
|
-
}
|
|
212
|
-
- (void)languageDidChange:(NSNotification *)notification {
|
|
213
|
-
PetPhrasesAdoptLanguageDefaults();
|
|
214
|
-
NSApp.mainMenu = nil;
|
|
215
|
-
[self installEditMenu];
|
|
216
|
-
self.quotaView.needsDisplay = YES;
|
|
217
|
-
// 状态卡标题和副行都是按状态现算的,按最后的状态重排一遍。工具名没留,
|
|
218
|
-
// 工具态会暂时退成"正在使用工具",下一条事件就会补回来。
|
|
219
|
-
if (self.hasAgentStatus && self.lastStatusState.length > 0) {
|
|
220
|
-
[self applyStatusPresentationForState:self.lastStatusState
|
|
221
|
-
provider:self.lastStatusProvider ?: @"Agent" tool:@""];
|
|
222
|
-
}
|
|
223
|
-
// 正在显示的碎碎念是旧语言的,收起即可,下一句自然是新语言。更新提示由更新逻辑自己重排。
|
|
224
|
-
if (!self.updateBubbleVisible) [self hideSpeechBubble];
|
|
225
|
-
}
|
|
226
|
-
@end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
|
|
3
|
-
// Agent 事件的记录与状态归一化,同时是 --hook / --provider-event 两个子命令的实现。
|
|
4
|
-
NSString *SanitizedShortString(id value, NSUInteger maximumLength);
|
|
5
|
-
NSString *ProviderFromEnvironment(void);
|
|
6
|
-
NSString *NormalizedStateForEvent(NSString *event, BOOL failed);
|
|
7
|
-
BOOL AppendAgentEventRecord(NSDictionary *record);
|
|
8
|
-
BOOL HookValueIndicatesFailure(id value);
|
|
9
|
-
int RecordHookEvent(void);
|
|
10
|
-
int RecordProviderEvent(void);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
|
|
3
|
-
// Codex 与 Claude 的额度读取。
|
|
4
|
-
int RecordClaudeUsage(void);
|
|
5
|
-
NSDictionary *ClaudeRateLimits(void);
|
|
6
|
-
NSDictionary *LatestClaudeUsage(void);
|
|
7
|
-
NSDictionary *LatestUsage(void);
|
|
8
|
-
// 清掉 resets_at 已经翻篇(或不可能属于当前窗口)的额度窗口,缺 resets_at 的保留。
|
|
9
|
-
NSDictionary *UsageByRemovingExpiredQuotaWindows(NSDictionary *usage);
|
|
10
|
-
|
|
11
|
-
// 增量跟读 ~/.claude/projects 下的会话转录,按官方 5 小时 / 7 天窗口聚合本地 Token。
|
|
12
|
-
@interface ClaudeUsageReader : NSObject
|
|
13
|
-
@property NSURL *projectsURL;
|
|
14
|
-
// 只有常驻的桌宠进程写摘要缓存。--status / --hook 这类一次性命令照样读它(省下冷解析),
|
|
15
|
-
// 但绝不能写:它们按各自当时的窗口把缓存剪一遍再存回去,等于把桌宠攒下的月度条目清掉。
|
|
16
|
-
@property BOOL persistsCache;
|
|
17
|
-
- (NSDictionary *)refresh;
|
|
18
|
-
- (NSDictionary *)refreshWithFullAggregation;
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
// 增量跟读当前 Codex 会话文件:只在会话切换时做一次冷读,之后按偏移追读。
|
|
22
|
-
@interface CodexUsageReader : NSObject
|
|
23
|
-
@property NSURL *sessionsURL;
|
|
24
|
-
// 见 ClaudeUsageReader.persistsCache。
|
|
25
|
-
@property BOOL persistsCache;
|
|
26
|
-
@property NSURL *sessionURL;
|
|
27
|
-
@property NSDictionary *usage;
|
|
28
|
-
@property unsigned long long offset;
|
|
29
|
-
@property NSMutableData *partialLine;
|
|
30
|
-
@property NSTimeInterval lastFullDiscovery;
|
|
31
|
-
- (NSDictionary *)refresh;
|
|
32
|
-
- (NSDictionary *)refreshWithFullDiscovery;
|
|
33
|
-
// 一批 FSEvents 里可能有多个会话文件同时变更(并发会话)。谁的额度采样更晚要读过才知道,
|
|
34
|
-
// 不能取遍历到的最后一个,详见实现处注释。
|
|
35
|
-
- (NSDictionary *)refreshForSessionURLs:(NSArray<NSURL *> *)urls;
|
|
36
|
-
@end
|