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.
- package/CC_BRIDGE.md +5 -0
- package/CC_BRIDGE.zh-CN.md +4 -0
- package/CHANGELOG.md +40 -1
- package/CHANGELOG.zh-CN.md +40 -1
- package/CONTRIBUTING.md +54 -0
- package/CONTRIBUTING.zh-CN.md +45 -0
- package/README.md +57 -14
- package/README.zh-CN.md +56 -14
- package/Resources/Info.plist +3 -1
- package/Resources/en.lproj/InfoPlist.strings +1 -0
- package/Resources/phrases.default.en.txt +182 -0
- package/Resources/zh-Hans.lproj/InfoPlist.strings +1 -0
- package/Resources/zh-Hans.lproj/Localizable.strings +332 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentEvents.m +215 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +660 -0
- package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +299 -0
- package/Sources/CCPets/CCPetsAppDelegate+Pets.m +185 -0
- package/Sources/CCPets/CCPetsAppDelegate+Private.h +325 -0
- package/Sources/CCPets/CCPetsAppDelegate+Quota.m +216 -0
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +226 -0
- package/Sources/CCPets/CCPetsAppDelegate+Speech.m +392 -0
- package/Sources/CCPets/CCPetsAppDelegate+Update.m +459 -0
- package/Sources/CCPets/CCPetsAppDelegate.h +13 -14
- package/Sources/CCPets/CCPetsAppDelegate.m +68 -2466
- package/Sources/CCPets/CCPetsCleanup.h +4 -0
- package/Sources/CCPets/CCPetsCleanup.m +41 -7
- package/Sources/CCPets/CCPetsEvents.m +4 -3
- package/Sources/CCPets/CCPetsL10n.h +55 -0
- package/Sources/CCPets/CCPetsL10n.m +219 -0
- package/Sources/CCPets/CCPetsPaths.h +0 -1
- package/Sources/CCPets/CCPetsPaths.m +0 -1
- package/Sources/CCPets/CCPetsPhrases.h +7 -1
- package/Sources/CCPets/CCPetsPhrases.m +86 -31
- package/Sources/CCPets/CCPetsPhrasesEditor.m +62 -64
- package/Sources/CCPets/CCPetsPreviews.m +7 -6
- package/Sources/CCPets/CCPetsUsage.h +0 -1
- package/Sources/CCPets/CCPetsUsage.m +0 -3
- package/Sources/CCPets/CCPetsVersion.h +10 -0
- package/Sources/CCPets/CCPetsVersion.m +92 -2
- package/Sources/CCPets/MenuToggleSwitch.m +3 -2
- package/Sources/CCPets/PetView.h +2 -0
- package/Sources/CCPets/PetView.m +115 -74
- package/Sources/CCPets/QuotaDashboardView.m +122 -88
- package/Sources/CCPets/main.m +16 -1
- package/bin/cc-pets +25 -20
- package/bin/claude-with-pet +2 -1
- package/bin/codex-with-pet +2 -1
- package/package.json +5 -3
- package/scripts/bridge/cli.mjs +47 -39
- package/scripts/bridge/core.mjs +28 -27
- package/scripts/bridge/hook.mjs +7 -6
- package/scripts/bridge/install.mjs +42 -19
- package/scripts/bridge/mcp-server.mjs +79 -71
- package/scripts/bridge/options.mjs +7 -6
- package/scripts/bridge/process.mjs +22 -0
- package/scripts/bridge/reservations.mjs +6 -5
- package/scripts/bridge/store.mjs +10 -9
- package/scripts/build.sh +24 -5
- package/scripts/check-l10n.mjs +168 -0
- package/scripts/configure-updater.mjs +4 -3
- package/scripts/doctor.mjs +470 -0
- package/scripts/i18n.mjs +122 -0
- package/scripts/i18n.zsh +66 -0
- package/scripts/install-app.sh +3 -2
- package/scripts/install-claude-hooks.mjs +22 -27
- package/scripts/install-codex-hooks.mjs +10 -15
- package/scripts/install-shell-integration.sh +6 -5
- package/scripts/integration-markers.mjs +51 -0
- package/scripts/locales/zh-Hans.json +366 -0
- package/scripts/pet-store.mjs +47 -45
- package/scripts/uninstall-app.sh +4 -3
- package/scripts/uninstall-integrations.mjs +24 -51
- package/scripts/uninstall-shell-integration.sh +8 -7
- /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": @"
|
|
125
|
+
return @{ @"text": L(@"vs last month: flat"), @"color": self.secondaryColor };
|
|
125
126
|
}
|
|
126
|
-
return @{ @"text": [NSString stringWithFormat
|
|
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
|
|
181
|
-
: [NSString stringWithFormat
|
|
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
|
|
286
|
-
if (age < 3600) return [NSString stringWithFormat
|
|
287
|
-
return [NSString stringWithFormat
|
|
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
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
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": @"
|
|
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
|
-
@[@"
|
|
524
|
-
@[@"
|
|
525
|
-
@[@"
|
|
526
|
-
@[@"
|
|
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 ? @"
|
|
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
|
-
[@"
|
|
678
|
+
[L(@"Calls this month") drawInRect:NSMakeRect(callX, NSMinY(card) + 114, 130, 20)
|
|
655
679
|
withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
|
|
656
|
-
[@"
|
|
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": @"
|
|
708
|
+
@{@"label": L(@"Input"), @"value": [self formattedTokenSplit:monthTokens ?: @{}
|
|
685
709
|
wantsOutput:NO], @"y": @(NSMinY(card) + 76)},
|
|
686
|
-
@{@"label": @"
|
|
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
|
-
[@"
|
|
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
|
|
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
|
-
[@"
|
|
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
|
|
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
|
|
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": @"
|
|
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": @"
|
|
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
|
|
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 ? @"
|
|
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
|
-
[@"
|
|
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": @"
|
|
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
|
|
874
|
+
? [NSString stringWithFormat:L(@"Max %.0f%%"), peak] : L(@"Max --");
|
|
851
875
|
NSString *currentText = currentUsed
|
|
852
|
-
? [NSString stringWithFormat
|
|
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
|
|
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
|
-
|
|
930
|
-
|
|
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(
|
|
961
|
+
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(agentIndicatorX, height - 88, 9, 9)] fill];
|
|
933
962
|
NSString *agentText = self.activeAgentCount > 0
|
|
934
|
-
? [NSString stringWithFormat
|
|
935
|
-
|
|
936
|
-
|
|
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
|
|
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
|
-
[@"
|
|
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
|
-
[@"
|
|
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
|
-
[@"
|
|
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
|
-
? @"ⓘ
|
|
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
|
-
? @"ⓘ
|
|
994
|
-
: @"ⓘ
|
|
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:
|
|
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
|
-
[@"
|
|
1131
|
+
[L(@"Input") drawInRect:NSMakeRect(inputX, labelY, 76, 16)
|
|
1098
1132
|
withAttributes:headerAttributes];
|
|
1099
|
-
[@"
|
|
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];
|
package/Sources/CCPets/main.m
CHANGED
|
@@ -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, "
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
cc-pets
|
|
17
|
-
cc-pets
|
|
18
|
-
cc-pets uninstall
|
|
19
|
-
cc-pets uninstall
|
|
20
|
-
cc-pets
|
|
21
|
-
cc-pets
|
|
22
|
-
cc-pets
|
|
23
|
-
cc-pets
|
|
24
|
-
cc-pets
|
|
25
|
-
cc-pets
|
|
26
|
-
cc-pets --
|
|
27
|
-
cc-pets --
|
|
28
|
-
cc-pets
|
|
29
|
-
cc-pets -
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 实际不生效。
|
package/bin/claude-with-pet
CHANGED
|
@@ -3,6 +3,7 @@ set -eu
|
|
|
3
3
|
|
|
4
4
|
SCRIPT_DIR="${0:A:h}"
|
|
5
5
|
PROJECT_DIR="${SCRIPT_DIR:h}"
|
|
6
|
+
source "${PROJECT_DIR}/scripts/i18n.zsh"
|
|
6
7
|
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 "
|
|
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
|
|