cc-pets 2.1.1 → 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 (74) hide show
  1. package/CC_BRIDGE.md +5 -0
  2. package/CC_BRIDGE.zh-CN.md +4 -0
  3. package/CHANGELOG.md +40 -1
  4. package/CHANGELOG.zh-CN.md +40 -1
  5. package/CONTRIBUTING.md +54 -0
  6. package/CONTRIBUTING.zh-CN.md +45 -0
  7. package/README.md +57 -14
  8. package/README.zh-CN.md +56 -14
  9. package/Resources/Info.plist +3 -1
  10. package/Resources/en.lproj/InfoPlist.strings +1 -0
  11. package/Resources/phrases.default.en.txt +182 -0
  12. package/Resources/zh-Hans.lproj/InfoPlist.strings +1 -0
  13. package/Resources/zh-Hans.lproj/Localizable.strings +332 -0
  14. package/Sources/CCPets/CCPetsAppDelegate+AgentEvents.m +215 -0
  15. package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +660 -0
  16. package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +299 -0
  17. package/Sources/CCPets/CCPetsAppDelegate+Pets.m +185 -0
  18. package/Sources/CCPets/CCPetsAppDelegate+Private.h +325 -0
  19. package/Sources/CCPets/CCPetsAppDelegate+Quota.m +216 -0
  20. package/Sources/CCPets/CCPetsAppDelegate+Settings.m +226 -0
  21. package/Sources/CCPets/CCPetsAppDelegate+Speech.m +392 -0
  22. package/Sources/CCPets/CCPetsAppDelegate+Update.m +459 -0
  23. package/Sources/CCPets/CCPetsAppDelegate.h +13 -14
  24. package/Sources/CCPets/CCPetsAppDelegate.m +68 -2466
  25. package/Sources/CCPets/CCPetsCleanup.h +4 -0
  26. package/Sources/CCPets/CCPetsCleanup.m +41 -7
  27. package/Sources/CCPets/CCPetsEvents.m +4 -3
  28. package/Sources/CCPets/CCPetsL10n.h +55 -0
  29. package/Sources/CCPets/CCPetsL10n.m +219 -0
  30. package/Sources/CCPets/CCPetsPaths.h +0 -1
  31. package/Sources/CCPets/CCPetsPaths.m +0 -1
  32. package/Sources/CCPets/CCPetsPhrases.h +7 -1
  33. package/Sources/CCPets/CCPetsPhrases.m +86 -31
  34. package/Sources/CCPets/CCPetsPhrasesEditor.m +62 -64
  35. package/Sources/CCPets/CCPetsPreviews.m +7 -6
  36. package/Sources/CCPets/CCPetsUsage.h +0 -1
  37. package/Sources/CCPets/CCPetsUsage.m +0 -3
  38. package/Sources/CCPets/CCPetsVersion.h +10 -0
  39. package/Sources/CCPets/CCPetsVersion.m +92 -2
  40. package/Sources/CCPets/MenuToggleSwitch.m +3 -2
  41. package/Sources/CCPets/PetView.h +2 -0
  42. package/Sources/CCPets/PetView.m +115 -74
  43. package/Sources/CCPets/QuotaDashboardView.m +122 -88
  44. package/Sources/CCPets/main.m +16 -1
  45. package/bin/cc-pets +25 -20
  46. package/bin/claude-with-pet +2 -1
  47. package/bin/codex-with-pet +2 -1
  48. package/package.json +5 -3
  49. package/scripts/bridge/cli.mjs +47 -39
  50. package/scripts/bridge/core.mjs +28 -27
  51. package/scripts/bridge/hook.mjs +7 -6
  52. package/scripts/bridge/install.mjs +42 -19
  53. package/scripts/bridge/mcp-server.mjs +79 -71
  54. package/scripts/bridge/options.mjs +7 -6
  55. package/scripts/bridge/process.mjs +22 -0
  56. package/scripts/bridge/reservations.mjs +6 -5
  57. package/scripts/bridge/store.mjs +10 -9
  58. package/scripts/build.sh +24 -5
  59. package/scripts/check-l10n.mjs +168 -0
  60. package/scripts/configure-updater.mjs +4 -3
  61. package/scripts/doctor.mjs +470 -0
  62. package/scripts/i18n.mjs +122 -0
  63. package/scripts/i18n.zsh +66 -0
  64. package/scripts/install-app.sh +3 -2
  65. package/scripts/install-claude-hooks.mjs +22 -27
  66. package/scripts/install-codex-hooks.mjs +10 -15
  67. package/scripts/install-shell-integration.sh +6 -5
  68. package/scripts/integration-markers.mjs +51 -0
  69. package/scripts/locales/zh-Hans.json +366 -0
  70. package/scripts/pet-store.mjs +47 -45
  71. package/scripts/uninstall-app.sh +4 -3
  72. package/scripts/uninstall-integrations.mjs +24 -51
  73. package/scripts/uninstall-shell-integration.sh +8 -7
  74. /package/Resources/{phrases.default.txt → phrases.default.zh-Hans.txt} +0 -0
@@ -1,4 +1,5 @@
1
1
  #import "QuotaDashboardView.h"
2
+ #import "CCPetsL10n.h"
2
3
 
3
4
  const CGFloat QuotaLogicalWidth = 760;
4
5
  const CGFloat QuotaLogicalHeight = 590;
@@ -77,7 +78,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
77
78
  }
78
79
  - (NSRect)logicalSummaryRect {
79
80
  return NSMakeRect(20, [self logicalHeight] - QuotaHeaderHeight - QuotaSummaryHeight,
80
- QuotaLogicalWidth - 40, QuotaSummaryHeight);
81
+ QuotaLogicalWidth - 40, QuotaSummaryHeight + 1 / QuotaScale);
81
82
  }
82
83
  // 刷新时间挪去了右上角,这一版块整宽留给两个统计格,各占一半。
83
84
  - (NSRect)logicalSummaryCellRectAtIndex:(NSUInteger)index {
@@ -116,14 +117,14 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
116
117
  - (NSDictionary *)comparisonForCurrent:(double)current previous:(double)previous
117
118
  color:(NSColor *)color {
118
119
  if (previous <= 0) {
119
- return @{ @"text": current > 0 ? @"较上月同期 新增" : @"较上月同期 持平",
120
+ return @{ @"text": current > 0 ? L(@"vs last month: new") : L(@"vs last month: flat"),
120
121
  @"color": current > 0 ? color : self.secondaryColor };
121
122
  }
122
123
  double change = (current - previous) * 100.0 / previous;
123
124
  if (fabs(change) < 0.05) {
124
- return @{ @"text": @"较上月同期 持平", @"color": self.secondaryColor };
125
+ return @{ @"text": L(@"vs last month: flat"), @"color": self.secondaryColor };
125
126
  }
126
- return @{ @"text": [NSString stringWithFormat:@"较上月同期 %@%.1f%%",
127
+ return @{ @"text": [NSString stringWithFormat:L(@"vs last month %@%.1f%%"),
127
128
  change > 0 ? @"↑" : @"↓", fabs(change)], @"color": color };
128
129
  }
129
130
  // 输入取 total - output,而不是把几个 input_* 字段加起来:两家的包含关系是相反的。
@@ -177,8 +178,8 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
177
178
  // 原生玻璃下字号更大,完整说明在单元格里放不下,只留起始日期。
178
179
  formatter.dateFormat = self.usesLiquidGlass ? @"M/d" : @"yyyy-MM-dd";
179
180
  NSString *date = [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:start.doubleValue]];
180
- return self.usesLiquidGlass ? [NSString stringWithFormat:@"近 7 天累计用量(%@ 起)", date]
181
- : [NSString stringWithFormat:@"近 7 天累计用量(%@ 至今·滚动记录)", date];
181
+ return self.usesLiquidGlass ? [NSString stringWithFormat:L(@"Last 7 days (since %@)"), date]
182
+ : [NSString stringWithFormat:L(@"Last 7 days (since %@, rolling)"), date];
182
183
  }
183
184
  // 在线 = 这一家还有活着的客户端,和有没有额度数据无关:额度会一直缓存着,
184
185
  // 拿它当在线信号会恒亮。身份不明的老客户端无法归属到某一家,保守地都算在线。
@@ -266,9 +267,6 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
266
267
  CGFloat width = ceil(statusLine.size.width);
267
268
  [statusLine drawInRect:NSMakeRect(rightEdge - width, y, width + 1, 20)];
268
269
  }
269
- - (NSString *)formattedTokenCountForUsage:(NSDictionary *)usage key:(NSString *)key {
270
- return [self formattedTokenCount:[self tokenTotals:usage key:key] ?: @{}];
271
- }
272
270
  - (NSString *)formattedTokenSplitForUsage:(NSDictionary *)usage key:(NSString *)key
273
271
  wantsOutput:(BOOL)wantsOutput {
274
272
  return [self formattedTokenSplit:[self tokenTotals:usage key:key] ?: @{}
@@ -279,12 +277,12 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
279
277
  return used ? @(fmax(0, fmin(100, used.doubleValue))) : nil;
280
278
  }
281
279
  - (NSString *)refreshAgeText {
282
- if (self.lastUpdatedAt <= 0) return @"等待数据";
280
+ if (self.lastUpdatedAt <= 0) return L(@"Waiting for data");
283
281
  NSTimeInterval age = fmax(0, NSDate.date.timeIntervalSince1970 - self.lastUpdatedAt);
284
- if (age < 5) return @"刚刚";
285
- if (age < 60) return [NSString stringWithFormat:@"%.0f 秒前", age];
286
- if (age < 3600) return [NSString stringWithFormat:@"%.0f 分钟前", floor(age / 60)];
287
- return [NSString stringWithFormat:@"%.0f 小时前", floor(age / 3600)];
282
+ if (age < 5) return L(@"just now");
283
+ if (age < 60) return [NSString stringWithFormat:L(@"%.0fs ago"), age];
284
+ if (age < 3600) return [NSString stringWithFormat:L(@"%.0fm ago"), floor(age / 60)];
285
+ return [NSString stringWithFormat:L(@"%.0fh ago"), floor(age / 3600)];
288
286
  }
289
287
  // 原生玻璃下背景可以是任意壁纸,面板按 0.58 缩放后小字只有 6–7pt,细笔画很容易被
290
288
  // 背后的纹理吃掉。所以 liquid 模式统一收紧文字:小字放大一点、加粗一级;灰字不低于
@@ -307,7 +305,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
307
305
  - (void)drawText:(NSString *)text inRect:(NSRect)rect size:(CGFloat)size
308
306
  weight:(NSFontWeight)weight color:(NSColor *)color dotColor:(NSColor *)dotColor {
309
307
  if (!self.usesLiquidGlass) {
310
- [text drawInRect:rect withAttributes:[self textAttributesWithSize:size color:color weight:weight]];
308
+ NSMutableDictionary *attributes = [[self textAttributesWithSize:size color:color
309
+ weight:weight] mutableCopy];
310
+ NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
311
+ style.lineBreakMode = NSLineBreakByTruncatingTail;
312
+ attributes[NSParagraphStyleAttributeName] = style;
313
+ [text drawInRect:rect withAttributes:[self attributes:attributes fittingText:text
314
+ inWidth:NSWidth(rect)]];
311
315
  return;
312
316
  }
313
317
  NSMutableDictionary *attributes = [[self textAttributesWithSize:size color:color
@@ -316,23 +320,43 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
316
320
  style.lineBreakMode = NSLineBreakByTruncatingTail;
317
321
  attributes[NSParagraphStyleAttributeName] = style;
318
322
  NSFont *font = attributes[NSFontAttributeName];
319
- CGFloat diameter = 9;
320
- // drawInRect: 从矩形顶部开始排版,圆点对齐到首行小写字母的中线。
321
- CGFloat baselineMid = NSMaxY(rect) - font.ascender + font.xHeight / 2.0;
322
- [NSGraphicsContext saveGraphicsState];
323
- [[NSShadow new] set];
324
- [dotColor setFill];
325
- [[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(NSMinX(rect), baselineMid - diameter / 2.0,
326
- diameter, diameter)] fill];
327
- [NSGraphicsContext restoreGraphicsState];
328
323
  NSRect textRect = rect;
329
- textRect.origin.x += diameter + 6;
330
- textRect.size.width -= diameter + 6;
331
- [text drawInRect:textRect withAttributes:attributes];
324
+ if (dotColor) {
325
+ CGFloat diameter = 9;
326
+ // drawInRect: 从矩形顶部开始排版,圆点对齐到首行小写字母的中线。
327
+ CGFloat baselineMid = NSMaxY(rect) - font.ascender + font.xHeight / 2.0;
328
+ [NSGraphicsContext saveGraphicsState];
329
+ [[NSShadow new] set];
330
+ [dotColor setFill];
331
+ [[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(NSMinX(rect), baselineMid - diameter / 2.0,
332
+ diameter, diameter)] fill];
333
+ [NSGraphicsContext restoreGraphicsState];
334
+ textRect.origin.x += diameter + 6;
335
+ textRect.size.width -= diameter + 6;
336
+ }
337
+ [text drawInRect:textRect withAttributes:[self attributes:attributes fittingText:text
338
+ inWidth:NSWidth(textRect)]];
339
+ }
340
+ // 译文长短差得多,固定宽度的格子迟早有放不下的语言。放不下时先把字号往下收,最多收 2pt
341
+ // (liquid 下即从 14 收到 12)——比截成"…"好认;还放不下才交给截断。放得下就原样返回,
342
+ // 中文和多数英文不受影响。
343
+ - (NSDictionary *)attributes:(NSDictionary *)attributes fittingText:(NSString *)text
344
+ inWidth:(CGFloat)width {
345
+ NSFont *font = attributes[NSFontAttributeName];
346
+ if (!font || text.length == 0 || [text sizeWithAttributes:attributes].width <= width) {
347
+ return attributes;
348
+ }
349
+ NSMutableDictionary *fitted = [attributes mutableCopy];
350
+ for (CGFloat size = font.pointSize - 0.5; size >= font.pointSize - 2; size -= 0.5) {
351
+ fitted[NSFontAttributeName] = [NSFont fontWithDescriptor:font.fontDescriptor size:size];
352
+ if ([text sizeWithAttributes:fitted].width <= width) break;
353
+ }
354
+ return fitted;
332
355
  }
333
- // 风险提示:原生玻璃下是圆点 + 白字;经典主题照旧画彩色字。
356
+ // 风险提示只保留文字,和 Max / Now 使用同一条左边界。
334
357
  - (void)drawTip:(NSString *)text inRect:(NSRect)rect color:(NSColor *)color {
335
- [self drawText:text inRect:rect size:11 weight:NSFontWeightMedium color:color dotColor:color];
358
+ if (text.length == 0) return;
359
+ [self drawText:text inRect:rect size:11 weight:NSFontWeightMedium color:color dotColor:nil];
336
360
  }
337
361
  - (void)fillLiquidScrim:(NSBezierPath *)path {
338
362
  [NSGraphicsContext saveGraphicsState];
@@ -491,7 +515,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
491
515
  - (NSDictionary *)paceStatusForQuota:(NSDictionary *)quota currentUsed:(NSNumber *)currentUsed
492
516
  color:(NSColor *)providerColor {
493
517
  if (!currentUsed) {
494
- return @{@"label": @"数据不足", @"tip": @"等待官方额度数据",
518
+ return @{@"label": L(@"Not enough data"), @"tip": L(@"Waiting for data"),
495
519
  @"color": self.secondaryColor};
496
520
  }
497
521
  NSNumber *reset = [quota[@"resets_at"] isKindOfClass:NSNumber.class]
@@ -520,10 +544,10 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
520
544
  // 四个档位从轻到重排成阶梯,后面的仲裁只在这上面挪档位,不再各写一套 label/tip/color。
521
545
  double remaining = 100.0 - currentUsed.doubleValue;
522
546
  NSArray<NSArray *> *ladder = @[
523
- @[@"充足", @"当前额度余量充足", NSColor.systemGreenColor],
524
- @[@"平稳", @"当前额度余量平稳", providerColor],
525
- @[@"需关注", @"建议关注额度余量", NSColor.systemOrangeColor],
526
- @[@"高风险", @"当前额度余量较低", NSColor.systemRedColor]
547
+ @[L(@"Plenty"), CCPetsLanguageIsSource() ? @"" : L(@"Plenty of quota left"), NSColor.systemGreenColor],
548
+ @[L(@"Steady"), CCPetsLanguageIsSource() ? @"" : L(@"Quota is holding steady"), providerColor],
549
+ @[L(@"Watch"), L(@"Watch usage"), NSColor.systemOrangeColor],
550
+ @[L(@"At risk"), L(@"Quota low"), NSColor.systemRedColor]
527
551
  ];
528
552
  NSUInteger baseRank = remaining >= 70 ? 0
529
553
  : (remaining >= 40 ? 1 : (remaining >= 15 ? 2 : 3));
@@ -534,13 +558,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
534
558
  if (!isnan(projectedRemaining)) {
535
559
  if (remaining <= 5 || projectedRemaining < 0) {
536
560
  projectedRank = 3;
537
- projectedTip = @"预计重置前额度用尽";
561
+ projectedTip = L(@"Runs out early");
538
562
  } else if (projectedRemaining < 10) {
539
563
  projectedRank = 2;
540
- projectedTip = @"建议减少高消耗任务";
564
+ projectedTip = L(@"Ease off a bit");
541
565
  } else if (projectedRemaining >= 30) {
542
566
  projectedRank = 0;
543
- projectedTip = @"按当前节奏额度充足";
567
+ projectedTip = L(@"Plenty to spare");
544
568
  }
545
569
  }
546
570
 
@@ -558,7 +582,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
558
582
 
559
583
  NSString *label = ladder[rank][0];
560
584
  NSString *tip = ladder[rank][1];
561
- if (demotedByFact) tip = @"消耗偏快,注意节奏";
585
+ if (demotedByFact) tip = L(@"Burning fast");
562
586
  else if (projectedRank >= 0 && rank == (NSUInteger)projectedRank) tip = projectedTip;
563
587
  return @{@"label": label, @"tip": tip, @"color": ladder[rank][2]};
564
588
  }
@@ -630,8 +654,8 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
630
654
  withAttributes:[self textAttributesWithSize:22 color:primary weight:NSFontWeightBold]];
631
655
  // 四态:额度被拒 → 额度受限(百分比仍是上次官方快照);没有任何额度数据 → 等待数据;
632
656
  // 有数据但客户端已退出 → 离线;两者都有 → 在线。
633
- NSString *statusText = (!apiMode && exhausted) ? @"额度受限"
634
- : (!hasData ? @"等待数据" : (online ? @"● 在线" : @"离线"));
657
+ NSString *statusText = (!apiMode && exhausted) ? L(@"Rate limited")
658
+ : (!hasData ? L(@"Waiting for data") : (online ? L(@"● Online") : L(@"Offline")));
635
659
  NSColor *statusColor = (!apiMode && exhausted) ? NSColor.systemOrangeColor
636
660
  : (online && hasData ? NSColor.systemGreenColor : secondary);
637
661
  if (self.usesLiquidGlass) {
@@ -651,12 +675,12 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
651
675
  if (apiMode) {
652
676
  CGFloat callX = NSMinX(card) + 214;
653
677
  CGFloat tokenX = NSMinX(card) + 394;
654
- [@"本月调用" drawInRect:NSMakeRect(callX, NSMinY(card) + 114, 130, 20)
678
+ [L(@"Calls this month") drawInRect:NSMakeRect(callX, NSMinY(card) + 114, 130, 20)
655
679
  withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
656
- [@"本月消耗" drawInRect:NSMakeRect(tokenX, NSMinY(card) + 114, 130, 20)
680
+ [L(@"Tokens this month") drawInRect:NSMakeRect(tokenX, NSMinY(card) + 114, 130, 20)
657
681
  withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
658
682
 
659
- NSString *requests = [NSString stringWithFormat:@"%@ 次",
683
+ NSString *requests = [NSString stringWithFormat:L(@"%@ calls"),
660
684
  [self formattedRequestCount:monthTokens ?: @{}]];
661
685
  [requests drawInRect:NSMakeRect(callX, NSMinY(card) + 75, 150, 34)
662
686
  withAttributes:[self textAttributesWithSize:24 color:primary weight:NSFontWeightBold]];
@@ -670,20 +694,20 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
670
694
  NSNumber *requestCount = [monthTokens[@"request_count"] isKindOfClass:NSNumber.class]
671
695
  ? monthTokens[@"request_count"] : nil;
672
696
  NSString *average = requestCount
673
- ? [NSString stringWithFormat:@"日均 %@ 次",
697
+ ? [NSString stringWithFormat:L(@"%@/day avg"),
674
698
  [NSNumberFormatter localizedStringFromNumber:
675
699
  @(llround(requestCount.doubleValue / elapsedDays))
676
700
  numberStyle:NSNumberFormatterDecimalStyle]]
677
- : @"日均 --";
701
+ : L(@"--/day avg");
678
702
  [average drawInRect:NSMakeRect(callX, NSMinY(card) + 48, 150, 20)
679
703
  withAttributes:[self textAttributesWithSize:12 color:secondary weight:NSFontWeightRegular]];
680
704
 
681
705
  // 这里不再重复"本月消耗"的合计:输入与输出各自的量级才是按量计费时要看的东西,
682
706
  // 合计随时可以由这两个数得到,而它原先占掉了最显眼的一行。
683
707
  NSArray<NSDictionary *> *splits = @[
684
- @{@"label": @"输入", @"value": [self formattedTokenSplit:monthTokens ?: @{}
708
+ @{@"label": L(@"Input"), @"value": [self formattedTokenSplit:monthTokens ?: @{}
685
709
  wantsOutput:NO], @"y": @(NSMinY(card) + 76)},
686
- @{@"label": @"输出", @"value": [self formattedTokenSplit:monthTokens ?: @{}
710
+ @{@"label": L(@"Output"), @"value": [self formattedTokenSplit:monthTokens ?: @{}
687
711
  wantsOutput:YES], @"y": @(NSMinY(card) + 48)}
688
712
  ];
689
713
  for (NSDictionary *split in splits) {
@@ -712,17 +736,17 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
712
736
  CGFloat trendX = NSMinX(card) + 564;
713
737
  // 「按日 Token」跟在标题后面,与标题同一行:它是标题的限定语,单独占一行既浪费
714
738
  // 竖向空间,也把曲线和脚注挤得没法与左边两列对齐。
715
- [@"本月趋势" drawInRect:NSMakeRect(trendX, NSMinY(card) + 114, 60, 20)
739
+ [L(@"Month") drawInRect:NSMakeRect(trendX, NSMinY(card) + 114, 60, 20)
716
740
  withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
717
741
  if (self.usesLiquidGlass) {
718
- [self drawText:@"按日 Token" inRect:NSMakeRect(trendX + 62, NSMinY(card) + 114, 96, 20)
742
+ [self drawText:L(@"Daily tokens") inRect:NSMakeRect(trendX + 62, NSMinY(card) + 114, 96, 20)
719
743
  size:11 weight:NSFontWeightSemibold color:color dotColor:color];
720
744
  } else {
721
745
  NSDictionary *pillAttributes = [self textAttributesWithSize:11 color:color
722
746
  weight:NSFontWeightSemibold];
723
747
  NSRect pill = NSMakeRect(trendX + 59, NSMinY(card) + 113, 76, 22);
724
748
  [self fillRoundedRect:pill radius:11 color:[color colorWithAlphaComponent:0.14]];
725
- [@"按日 Token" drawInRect:NSInsetRect(pill, 9, 3) withAttributes:pillAttributes];
749
+ [L(@"Daily tokens") drawInRect:NSInsetRect(pill, 9, 3) withAttributes:pillAttributes];
726
750
  }
727
751
  NSRect curveRect = NSMakeRect(trendX, NSMinY(card) + 62, 135, 38);
728
752
  [self drawMonthlyTokenCurve:monthDaily inRect:curveRect color:color];
@@ -736,17 +760,17 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
736
760
  todayTotals = totals;
737
761
  }
738
762
  NSString *peakText = recordedDays > 0
739
- ? [NSString stringWithFormat:@"峰值 %@", [self formattedTokenValue:peak]] : @"峰值 --";
763
+ ? [NSString stringWithFormat:L(@"Peak %@"), [self formattedTokenValue:peak]] : L(@"Peak --");
740
764
  NSString *todayText = todayTotals
741
- ? [NSString stringWithFormat:@"今日 %@",
742
- [self formattedTokenValue:[todayTotals[@"total_tokens"] doubleValue]]] : @"今日 --";
765
+ ? [NSString stringWithFormat:L(@"Today %@"),
766
+ [self formattedTokenValue:[todayTotals[@"total_tokens"] doubleValue]]] : L(@"Today --");
743
767
  [peakText drawInRect:NSMakeRect(trendX, NSMinY(card) + 42, 74, 16)
744
768
  withAttributes:[self textAttributesWithSize:10 color:secondary weight:NSFontWeightRegular]];
745
769
  [todayText drawInRect:NSMakeRect(trendX + 61, NSMinY(card) + 42, 74, 16)
746
770
  withAttributes:[self rightAlignedTextAttributesWithSize:10 color:secondary
747
771
  weight:NSFontWeightRegular]];
748
772
  // 与左边两列的"较上月同期"同一条基线(+22),三列脚注才在一条水平线上。
749
- [[NSString stringWithFormat:@"本月已记录 %lu / %lu 天",
773
+ [[NSString stringWithFormat:L(@"%lu / %lu days recorded"),
750
774
  (unsigned long)recordedDays, (unsigned long)monthDaily.count]
751
775
  drawInRect:NSMakeRect(trendX, NSMinY(card) + 22, 145, 18)
752
776
  withAttributes:[self textAttributesWithSize:11 color:color weight:NSFontWeightMedium]];
@@ -756,12 +780,12 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
756
780
  // 层级:官方剩余额度是订阅限额的权威值,占主位;本机 Token 是参考量,降一级并用
757
781
  // 强调色区分;重置时间最小。反过来会让最抢眼的数字恰好是最不该照着做决定的那个。
758
782
  NSArray<NSDictionary *> *windows = @[
759
- @{@"x": @(NSMinX(card) + 214), @"title": @"官方 5 小时窗口", @"quota": five ?: @{},
783
+ @{@"x": @(NSMinX(card) + 214), @"title": L(@"5h window"), @"quota": five ?: @{},
760
784
  @"tokens": fiveTokens ?: @{}, @"used": fiveUsed ?: NSNull.null,
761
- @"rolling": @"官方额度待刷新"},
762
- @{@"x": @(NSMinX(card) + 394), @"title": @"官方 7 天窗口", @"quota": week ?: @{},
785
+ @"rolling": L(@"Waiting for refresh")},
786
+ @{@"x": @(NSMinX(card) + 394), @"title": L(@"7d window"), @"quota": week ?: @{},
763
787
  @"tokens": weekTokens ?: @{}, @"used": weekUsed ?: NSNull.null,
764
- @"rolling": @"官方额度待刷新"}
788
+ @"rolling": L(@"Waiting for refresh")}
765
789
  ];
766
790
  for (NSDictionary *window in windows) {
767
791
  CGFloat x = [window[@"x"] doubleValue];
@@ -780,7 +804,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
780
804
  withAttributes:valueAttributes];
781
805
  // 没有数字可标时不给口径标签:"-- 剩余"看起来像一个真实的 0 值,而实际上是
782
806
  // 官方快照待刷新。下方的状态文字会说明它为何不可用。
783
- NSString *valueLabel = !used ? @"" : (exhausted ? @"快照" : @"剩余");
807
+ NSString *valueLabel = !used ? @"" : (exhausted ? L(@"Snapshot") : L(@"Left"));
784
808
  if (valueLabel.length > 0) {
785
809
  [valueLabel drawInRect:NSMakeRect(x + valueWidth + 7, NSMinY(card) + 78, 60, 20)
786
810
  withAttributes:[self textAttributesWithSize:12 color:secondary
@@ -790,13 +814,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
790
814
  // 说清楚这一行的口径,比留一个 `--` 让人以为是渲染坏了要好。
791
815
  NSString *resetValue = [self resetText:window[@"quota"]];
792
816
  NSString *reset = [resetValue isEqualToString:@"--"]
793
- ? window[@"rolling"] : [NSString stringWithFormat:@"重置时间 %@", resetValue];
817
+ ? window[@"rolling"] : [NSString stringWithFormat:L(@"Resets %@"), resetValue];
794
818
  [reset drawInRect:NSMakeRect(x, NSMinY(card) + 46, 150, 18)
795
819
  withAttributes:[self textAttributesWithSize:11 color:secondary weight:NSFontWeightRegular]];
796
820
  // 原生玻璃下字更大、前面还有圆点,这一栏放不下"Token"一词;脚注里已说明
797
821
  // Token 即本机统计的已用量。
798
822
  NSString *tokenText = [NSString stringWithFormat:
799
- self.usesLiquidGlass ? @"已用 %@" : @"已用 Token %@",
823
+ self.usesLiquidGlass ? L(@"Used %@") : L(@"Used tokens %@"),
800
824
  [self formattedTokenCount:window[@"tokens"]]];
801
825
  [self drawText:tokenText inRect:NSMakeRect(x, NSMinY(card) + 22, 150, 22) size:14
802
826
  weight:NSFontWeightSemibold color:color dotColor:color];
@@ -804,7 +828,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
804
828
 
805
829
  CGFloat trendX = NSMinX(card) + 564;
806
830
  // 与 API 卡同一套骨架:标题行带 pill、中间曲线、脚注和左边两列齐平。
807
- [@"使用趋势" drawInRect:NSMakeRect(trendX, NSMinY(card) + 114, 60, 20)
831
+ [L(@"Trend") drawInRect:NSMakeRect(trendX, NSMinY(card) + 114, 60, 20)
808
832
  withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
809
833
  NSArray<NSDictionary *> *history = [name isEqualToString:@"Codex"]
810
834
  ? self.codexHistory : self.claudeHistory;
@@ -816,7 +840,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
816
840
  // 矛盾。所以只有 7 天窗口自己确实没有百分比时才退回"待刷新"。
817
841
  BOOL weekUnknown = exhausted && currentUsed == nil;
818
842
  NSDictionary *pace = weekUnknown
819
- ? @{ @"label": @"待刷新", @"tip": @"等待官方额度刷新",
843
+ ? @{ @"label": L(@"Stale"), @"tip": L(@"Awaiting refresh"),
820
844
  @"color": NSColor.systemOrangeColor }
821
845
  : [self paceStatusForQuota:week currentUsed:currentUsed color:color];
822
846
  NSColor *paceColor = pace[@"color"];
@@ -825,7 +849,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
825
849
  NSString *paceTip = pace[@"tip"];
826
850
  NSColor *tipColor = paceColor;
827
851
  if (exhausted && !weekUnknown) {
828
- paceTip = @"官方额度受限,等待重置";
852
+ paceTip = L(@"Limited until reset");
829
853
  tipColor = NSColor.systemOrangeColor;
830
854
  }
831
855
  if (self.usesLiquidGlass) {
@@ -847,16 +871,17 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
847
871
  double peak = 0;
848
872
  for (NSDictionary *point in points) peak = fmax(peak, [point[@"used"] doubleValue]);
849
873
  NSString *peakText = points.count > 0
850
- ? [NSString stringWithFormat:@"最高 %.0f%%", peak] : @"最高 --";
874
+ ? [NSString stringWithFormat:L(@"Max %.0f%%"), peak] : L(@"Max --");
851
875
  NSString *currentText = currentUsed
852
- ? [NSString stringWithFormat:@"当前 %.0f%%", currentUsed.doubleValue] : @"当前 --";
853
- [peakText drawInRect:NSMakeRect(trendX, NSMinY(card) + 42, 72, 16)
876
+ ? [NSString stringWithFormat:L(@"Now %.0f%%"), currentUsed.doubleValue] : L(@"Now --");
877
+ [peakText drawInRect:NSMakeRect(trendX, NSMinY(card) + 42 - 2 / QuotaScale, 72, 16)
854
878
  withAttributes:[self textAttributesWithSize:10 color:secondary weight:NSFontWeightRegular]];
855
- [currentText drawInRect:NSMakeRect(trendX + 66, NSMinY(card) + 42, 69, 16)
879
+ [currentText drawInRect:NSMakeRect(trendX + 66, NSMinY(card) + 42 - 2 / QuotaScale, 69, 16)
856
880
  withAttributes:[self rightAlignedTextAttributesWithSize:10 color:secondary
857
881
  weight:NSFontWeightRegular]];
858
882
  // 与左边两列的"已用 Token"同一条基线(+22),也和 API 卡的脚注行对齐。
859
- [self drawTip:paceTip inRect:NSMakeRect(trendX, NSMinY(card) + 22, 145, 18) color:tipColor];
883
+ [self drawTip:paceTip inRect:NSMakeRect(trendX, NSMinY(card) + 22 - 2 / QuotaScale,
884
+ 145, 18) color:tipColor];
860
885
  }
861
886
  - (void)drawRect:(NSRect)dirtyRect {
862
887
  [NSGraphicsContext saveGraphicsState];
@@ -926,20 +951,25 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
926
951
  NSColor *agentColor = self.agentStatusColor;
927
952
  [@"Agent Usage" drawInRect:NSMakeRect(28, height - 65, 260, 42)
928
953
  withAttributes:[self textAttributesWithSize:30 color:primary weight:NSFontWeightBold]];
929
- [@"实时状态与滚动用量" drawInRect:NSMakeRect(30, height - 94, self.usesLiquidGlass ? 142 : 130, 22)
930
- withAttributes:[self textAttributesWithSize:14 color:secondary weight:NSFontWeightRegular]];
954
+ NSDictionary *liveStatusAttributes = [self textAttributesWithSize:14 color:secondary
955
+ weight:NSFontWeightRegular];
956
+ NSString *liveStatusText = L(@"Live status");
957
+ [liveStatusText drawInRect:NSMakeRect(30, height - 94, self.usesLiquidGlass ? 142 : 130, 22)
958
+ withAttributes:liveStatusAttributes];
959
+ CGFloat agentIndicatorX = 30 + [liveStatusText sizeWithAttributes:liveStatusAttributes].width + 12;
931
960
  [agentColor setFill];
932
- [[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(174, height - 88, 9, 9)] fill];
961
+ [[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(agentIndicatorX, height - 88, 9, 9)] fill];
933
962
  NSString *agentText = self.activeAgentCount > 0
934
- ? [NSString stringWithFormat:@"%ld 个 Agent 在线", (long)self.activeAgentCount]
935
- : @"暂无 Agent 在线";
936
- [agentText drawInRect:NSMakeRect(190, height - 95, 160, 22)
963
+ ? [NSString stringWithFormat:self.activeAgentCount != 1 ? L(@"%ld Agents online")
964
+ : L(@"%ld Agent online"), (long)self.activeAgentCount]
965
+ : L(@"No Agents online");
966
+ [agentText drawInRect:NSMakeRect(agentIndicatorX + 16, height - 95, 160, 22)
937
967
  withAttributes:[self textAttributesWithSize:14 color:agentColor weight:NSFontWeightMedium]];
938
968
  [self drawSystemMetricsEndingAtX:QuotaLogicalWidth - 28 y:height - 95];
939
969
 
940
970
  // 用量由定时器自动刷新,面板不再提供手动刷新按钮;右上角只留上次刷新的时间,
941
971
  // 与下一行的系统指标右边对齐。放回汇总条里会挤掉一整格 Provider 数据。
942
- [[NSString stringWithFormat:@"数据刷新 %@", [self refreshAgeText]]
972
+ [[NSString stringWithFormat:L(@"Updated %@"), [self refreshAgeText]]
943
973
  drawInRect:NSMakeRect(QuotaLogicalWidth - 28 - 200, height - 45, 200, 18)
944
974
  withAttributes:[self rightAlignedTextAttributesWithSize:11 color:secondary
945
975
  weight:NSFontWeightRegular]];
@@ -973,12 +1003,12 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
973
1003
  // 解决的是另一件事——Agent 动画,以及 Claude 额度(statusline 是它唯一的来源)。
974
1004
  // 把两者写成一句会让人以为不执行 install 卡片就不出现。
975
1005
  CGFloat noticeTop = height - QuotaHeaderHeight;
976
- [@"未检测到 Codex / Claude Code CLI" drawInRect:NSMakeRect(28, noticeTop - 30, 460, 26)
1006
+ [L(@"No Codex / Claude Code CLI detected") drawInRect:NSMakeRect(28, noticeTop - 30, 460, 26)
977
1007
  withAttributes:[self textAttributesWithSize:17 color:primary weight:NSFontWeightMedium]];
978
- [@"安装 Codex 或 Claude Code 后,额度卡会自动出现"
1008
+ [L(@"Quota cards appear once Codex or Claude Code is installed")
979
1009
  drawInRect:NSMakeRect(28, noticeTop - 52, 560, 20)
980
1010
  withAttributes:[self textAttributesWithSize:12 color:secondary weight:NSFontWeightRegular]];
981
- [@"重新执行 cc-pets install 可启用 Agent 动画与 Claude 额度采集"
1011
+ [L(@"Run cc-pets install again to enable Agent animations and Claude quota tracking")
982
1012
  drawInRect:NSMakeRect(28, noticeTop - 72, 560, 18)
983
1013
  withAttributes:[self textAttributesWithSize:11
984
1014
  color:[NSColor colorWithWhite:0.52 alpha:1] weight:NSFontWeightRegular]];
@@ -986,12 +1016,12 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
986
1016
  BOOL hasAPICard = ([visibleProviders containsObject:@"Codex"] && self.codexShowsAPIUsage) ||
987
1017
  ([visibleProviders containsObject:@"Claude"] && self.claudeShowsAPIUsage);
988
1018
  NSString *footer = visibleProviders.count == 0
989
- ? @"ⓘ 桌宠与系统状态不受影响;额度卡只在检测到对应 CLI 时显示"
1019
+ ? L(@"ⓘ The pet and system status still work; quota cards only show for detected CLIs")
990
1020
  : (hasAPICard
991
- ? @"ⓘ API 用量 = 本机会话统计(输入含缓存读写);环比按上月相同时间进度计算"
992
- : (self.usesLiquidGlass
993
- ? @"ⓘ 百分比 = 官方额度剩余;Token = 本机统计已用量(含缓存读写)"
994
- : @"ⓘ 百分比 = 官方订阅额度的剩余比例;Token = 本机统计的已用量(输入含缓存读写),两者口径不同"));
1021
+ ? L(@"ⓘ API usage = local session stats (input includes cache reads/writes); compared with the same point last month")
1022
+ : (self.usesLiquidGlass || CCPetsLanguageIsSource()
1023
+ ? L(@"ⓘ % = official quota left; tokens = local usage (incl. cache reads/writes)")
1024
+ : L(@"ⓘ % = share of official plan quota left; tokens = locally counted usage (input incl. cache reads/writes). They measure different things")));
995
1025
  // 最后一块的底边距面板底 QuotaFooterHeight:脚注与其留约 8pt,底部留白 16pt,
996
1026
  // 和顶部标题的留白大致对称。
997
1027
  [footer drawInRect:NSMakeRect(28, 16, 650, 20)
@@ -1020,7 +1050,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
1020
1050
 
1021
1051
  NSArray<NSDictionary *> *cells = @[
1022
1052
  @{@"icon": @"◔", @"headerSymbol": @"calendar", @"key": @"today",
1023
- @"label": @"今日用量"},
1053
+ @"label": L(@"Today")},
1024
1054
  @{@"icon": @"◉", @"headerSymbol": @"calendar.badge.clock", @"key": @"recentWeek",
1025
1055
  @"label": [self recentWeekUsageLabel]}
1026
1056
  ];
@@ -1058,6 +1088,9 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
1058
1088
  NSFont *headerFont = [self fontWithSize:11 weight:NSFontWeightRegular];
1059
1089
  NSDictionary *headerAttributes = @{NSFontAttributeName: headerFont,
1060
1090
  NSForegroundColorAttributeName: [self textColor:secondary]};
1091
+ NSDictionary *titleAttributes = @{NSFontAttributeName:
1092
+ [self fontWithSize:11 weight:NSFontWeightBold],
1093
+ NSForegroundColorAttributeName: [self textColor:secondary]};
1061
1094
  NSImage *headerIcon = [NSImage imageWithSystemSymbolName:cell[@"headerSymbol"]
1062
1095
  accessibilityDescription:cell[@"label"]];
1063
1096
  NSImageSymbolConfiguration *headerIconConfiguration =
@@ -1077,7 +1110,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
1077
1110
  [header appendAttributedString:[[NSAttributedString alloc]
1078
1111
  initWithString:@" " attributes:headerAttributes]];
1079
1112
  [header appendAttributedString:[[NSAttributedString alloc]
1080
- initWithString:cell[@"label"] attributes:headerAttributes]];
1113
+ initWithString:cell[@"label"] attributes:titleAttributes]];
1081
1114
  [header drawInRect:NSMakeRect(x + 24, NSMinY(summary) + 89,
1082
1115
  NSWidth([self logicalSummaryCellRectAtIndex:index]) - 48, 18)];
1083
1116
  for (NSDictionary *row in rows) {
@@ -1086,6 +1119,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
1086
1119
  CGFloat iconY = NSMinY(summary) + [row[@"iconY"] doubleValue];
1087
1120
  CGFloat nameY = NSMinY(summary) + [row[@"nameY"] doubleValue];
1088
1121
  CGFloat labelY = NSMinY(summary) + [row[@"labelY"] doubleValue];
1122
+ if (CCPetsLanguageIsSource()) labelY += 2 / QuotaScale;
1089
1123
  CGFloat valueY = NSMinY(summary) + [row[@"valueY"] doubleValue];
1090
1124
  // 这是图标字形不是文字,原生玻璃下也保留颜色:它负责标出这一行是哪一家。
1091
1125
  [cell[@"icon"] drawInRect:NSMakeRect(x + 20, iconY, 42, 42)
@@ -1094,9 +1128,9 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
1094
1128
  [row[@"name"] drawInRect:NSMakeRect(x + 66, nameY, 76, 22)
1095
1129
  withAttributes:[self textAttributesWithSize:14 color:rowColor
1096
1130
  weight:NSFontWeightMedium]];
1097
- [@"输入" drawInRect:NSMakeRect(inputX, labelY, 76, 16)
1131
+ [L(@"Input") drawInRect:NSMakeRect(inputX, labelY, 76, 16)
1098
1132
  withAttributes:headerAttributes];
1099
- [@"输出" drawInRect:NSMakeRect(outputX, labelY, 76, 16)
1133
+ [L(@"Output") drawInRect:NSMakeRect(outputX, labelY, 76, 16)
1100
1134
  withAttributes:headerAttributes];
1101
1135
  NSDictionary *valueAttributes = [self textAttributesWithSize:16 color:primary
1102
1136
  weight:NSFontWeightBold];
@@ -1,7 +1,9 @@
1
+ #import "CCPetsL10n.h"
1
2
  #import <Cocoa/Cocoa.h>
2
3
  #import "CCPetsAppDelegate.h"
3
4
  #import "CCPetsEvents.h"
4
5
  #import "CCPetsPaths.h"
6
+ #import "CCPetsPhrases.h"
5
7
  #import "CCPetsPreviews.h"
6
8
  #import "CCPetsQuotaHistory.h"
7
9
  #import "CCPetsUsage.h"
@@ -48,6 +50,18 @@ int main(int argc, const char *argv[]) {
48
50
  if (argc > 1 && strcmp(argv[1], "--codex-launch") == 0) return RegisterCodexLaunch();
49
51
  if (argc > 1 && strcmp(argv[1], "--clean") == 0) return CleanCCPetsData(NO);
50
52
  if (argc > 1 && strcmp(argv[1], "--purge-data") == 0) return CleanCCPetsData(YES);
53
+ if (argc > 1 && strcmp(argv[1], "--paths") == 0) {
54
+ NSMutableDictionary *paths = [CCPetsDataPaths() mutableCopy];
55
+ paths[@"phrases"] = PetPhrasesFilePath();
56
+ paths[@"petPhrases"] = PetPhrasesPetDirectory();
57
+ NSData *json = [NSJSONSerialization dataWithJSONObject:paths
58
+ options:NSJSONWritingPrettyPrinted | NSJSONWritingSortedKeys | NSJSONWritingWithoutEscapingSlashes
59
+ error:nil];
60
+ if (!json) return EXIT_FAILURE;
61
+ fwrite(json.bytes, 1, json.length, stdout);
62
+ fputc('\n', stdout);
63
+ return EXIT_SUCCESS;
64
+ }
51
65
  if (argc > 1 && strcmp(argv[1], "--history") == 0) {
52
66
  NSData *json = [NSJSONSerialization dataWithJSONObject:QuotaHistoryDocument()
53
67
  options:NSJSONWritingPrettyPrinted error:nil];
@@ -96,7 +110,8 @@ int main(int argc, const char *argv[]) {
96
110
  if (strcmp(argv[index], launchFlags[flag]) == 0) known = YES;
97
111
  }
98
112
  if (known) continue;
99
- fprintf(stderr, "未知参数:%s\n运行 cc-pets --help 查看用法。\n", argv[index]);
113
+ fprintf(stderr, "%s\n", [NSString stringWithFormat:L(@"Unknown argument: %@\nRun cc-pets --help for usage."),
114
+ @(argv[index])].UTF8String);
100
115
  return 2;
101
116
  }
102
117
 
package/bin/cc-pets CHANGED
@@ -6,30 +6,31 @@ PROJECT_DIR="${SCRIPT_DIR:h}"
6
6
  PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
7
7
  BUILD_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
8
8
  INSTALLED_APP="${CC_PETS_APPLICATIONS_DIR:-${HOME}/Applications}/CC Pets.app"
9
+ source "${PROJECT_DIR}/scripts/i18n.zsh"
9
10
 
10
11
  # 只列面向用户的命令。--hook / --claude-usage / --provider-event / --render-* 等是
11
12
  # hooks、statusline 和测试调用的内部入口,列出来只会让人误用。
12
13
  print_usage() {
13
- cat <<'USAGE'
14
- 用法:cc-pets [命令]
15
-
16
- cc-pets 启动桌宠(优先使用 ~/Applications 里安装的版本)
17
- cc-pets install 安装或修复 shell / Claude Code / Codex 集成
18
- cc-pets uninstall 移除集成并恢复 status line
19
- cc-pets uninstall --purge 同时删除 App 和全部本地数据(会先确认)
20
- cc-pets uninstall-app 只删除 ~/Applications/CC Pets.app
21
- cc-pets build 重新构建
22
- cc-pets clean 清理缓存(需先退出桌宠)
23
- cc-pets pet <命令> 管理桌宠素材,详见 cc-pets pet help
24
- cc-pets bridge <命令> CC Bridge 跨会话消息,详见 cc-pets bridge --help
25
- cc-pets --status 输出 Codex 当前额度
26
- cc-pets --history 输出额度历史(JSON)
27
- cc-pets --foreground 在前台运行桌宠(调试用)
28
- cc-pets -v, --version 显示版本
29
- cc-pets -h, --help 显示本帮助
30
-
31
- codex-with-pet / claude-with-pet 会在启动 CLI 的同时拉起桌宠。
32
- USAGE
14
+ print -r -- "$(cc_pets_t "Usage: cc-pets [command]
15
+
16
+ cc-pets Start the pet (prefers the copy installed in ~/Applications)
17
+ cc-pets install Install or repair the shell / Claude Code / Codex integrations
18
+ cc-pets uninstall Remove the integrations and restore the status line
19
+ cc-pets uninstall --purge Also delete the app, app data and preferences (asks first; keeps pets and lines in ~/.cc-pets)
20
+ cc-pets uninstall-app Only delete ~/Applications/CC Pets.app
21
+ cc-pets build Rebuild
22
+ cc-pets clean Clear caches (quit the pet first)
23
+ cc-pets doctor Check the installation and integrations, with suggested fixes
24
+ cc-pets paths [--json] List where settings, caches and data live, and their sizes
25
+ cc-pets pet <command> Manage pet sprites; see cc-pets pet help
26
+ cc-pets bridge <command> CC Bridge cross-session messaging; see cc-pets bridge --help
27
+ cc-pets --status Print the current Codex quota
28
+ cc-pets --history Print quota history (JSON)
29
+ cc-pets --foreground Run the pet in the foreground (for debugging)
30
+ cc-pets -v, --version Show the version
31
+ cc-pets -h, --help Show this help
32
+
33
+ codex-with-pet / claude-with-pet start the pet along with the CLI.")"
33
34
  }
34
35
 
35
36
  if [[ "${1:-}" == "--help" || "${1:-}" == "-h" || "${1:-}" == "help" ]]; then
@@ -51,6 +52,10 @@ if [[ "${1:-}" == "bridge" ]]; then
51
52
  exec node "${PROJECT_DIR}/scripts/bridge/cli.mjs" "$@"
52
53
  fi
53
54
 
55
+ if [[ "${1:-}" == "doctor" || "${1:-}" == "paths" ]]; then
56
+ exec node "${PROJECT_DIR}/scripts/doctor.mjs" "$@"
57
+ fi
58
+
54
59
  if [[ "${1:-}" == "uninstall" ]]; then
55
60
  shift
56
61
  # --purge / --yes 要传下去;原先这里吞掉了参数,README 里的 uninstall --purge 实际不生效。
@@ -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
  PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
7
8
  BUILD_APP="${PROJECT_DIR}/.build/release/CC Pets.app"
8
9
  INSTALLED_APP="${CC_PETS_APPLICATIONS_DIR:-${HOME}/Applications}/CC Pets.app"
@@ -28,7 +29,7 @@ if [[ -z "${REAL_CLAUDE}" ]]; then
28
29
  done
29
30
  fi
30
31
  if [[ -z "${REAL_CLAUDE}" || ! -x "${REAL_CLAUDE}" ]]; then
31
- print -u2 "未找到可执行的 Claude Code CLI。请先安装 claude,或通过 CLAUDE_REAL_BIN 指定真实路径。"
32
+ print -u2 "$(cc_pets_t "No executable Claude Code CLI found. Install claude, or set CLAUDE_REAL_BIN to its real path.")"
32
33
  exit 127
33
34
  fi
34
35