cc-pets 2.1.0 → 2.1.1
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 +6 -6
- package/CC_BRIDGE.zh-CN.md +4 -4
- package/CHANGELOG.md +37 -1
- package/CHANGELOG.zh-CN.md +37 -1
- package/README.md +11 -1
- package/README.zh-CN.md +11 -2
- package/Sources/CCPets/CCPetsAppDelegate.h +4 -2
- package/Sources/CCPets/CCPetsAppDelegate.m +123 -51
- package/Sources/CCPets/CCPetsCleanup.m +3 -1
- package/Sources/CCPets/CCPetsCodexRateLimits.h +1 -0
- package/Sources/CCPets/CCPetsCodexRateLimits.m +7 -0
- package/Sources/CCPets/CCPetsEvents.m +1 -1
- package/Sources/CCPets/CCPetsGlassMenu.h +10 -0
- package/Sources/CCPets/CCPetsGlassMenu.m +196 -0
- package/Sources/CCPets/CCPetsGlassView.h +31 -0
- package/Sources/CCPets/CCPetsGlassView.m +246 -0
- package/Sources/CCPets/CCPetsPaths.h +7 -0
- package/Sources/CCPets/CCPetsPaths.m +14 -0
- package/Sources/CCPets/CCPetsTerminalFocus.h +15 -0
- package/Sources/CCPets/CCPetsTerminalFocus.m +306 -15
- package/Sources/CCPets/CCPetsUsage.h +2 -0
- package/Sources/CCPets/CCPetsUsage.m +69 -18
- package/Sources/CCPets/CCPetsUsageMonitor.m +43 -8
- package/Sources/CCPets/MenuChoiceRow.h +19 -0
- package/Sources/CCPets/MenuChoiceRow.m +96 -0
- package/Sources/CCPets/MenuHintView.h +15 -0
- package/Sources/CCPets/MenuHintView.m +128 -0
- package/Sources/CCPets/PetView.m +107 -51
- package/Sources/CCPets/QuotaDashboardView.h +3 -4
- package/Sources/CCPets/QuotaDashboardView.m +222 -143
- package/Sources/CCPets/main.m +16 -0
- package/bin/cc-pets +33 -1
- package/bin/codex-with-pet +2 -0
- package/package.json +1 -1
|
@@ -47,7 +47,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
47
47
|
- (instancetype)initWithFrame:(NSRect)frame {
|
|
48
48
|
if ((self = [super initWithFrame:frame])) {
|
|
49
49
|
NSTrackingArea *tracking = [[NSTrackingArea alloc] initWithRect:NSZeroRect
|
|
50
|
-
options:NSTrackingMouseEnteredAndExited |
|
|
50
|
+
options:NSTrackingMouseEnteredAndExited |
|
|
51
51
|
NSTrackingActiveAlways | NSTrackingInVisibleRect
|
|
52
52
|
owner:self userInfo:nil];
|
|
53
53
|
[self addTrackingArea:tracking];
|
|
@@ -57,13 +57,8 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
57
57
|
- (BOOL)acceptsFirstMouse:(NSEvent *)event { return YES; }
|
|
58
58
|
- (void)mouseEntered:(NSEvent *)event {
|
|
59
59
|
if (self.hoverChanged) self.hoverChanged(YES);
|
|
60
|
-
[self mouseMoved:event];
|
|
61
60
|
}
|
|
62
61
|
- (void)mouseExited:(NSEvent *)event {
|
|
63
|
-
self.refreshHovered = NO;
|
|
64
|
-
self.refreshPressed = NO;
|
|
65
|
-
[NSCursor.arrowCursor set];
|
|
66
|
-
self.needsDisplay = YES;
|
|
67
62
|
if (self.hoverChanged) self.hoverChanged(NO);
|
|
68
63
|
}
|
|
69
64
|
// detectedProviders 未赋值时按"两家都有"渲染。这是刻意的兜底:探测是 App 侧的额外信号,
|
|
@@ -80,12 +75,6 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
80
75
|
- (CGFloat)logicalHeight {
|
|
81
76
|
return QuotaLogicalHeightForProviderCount([self visibleProviders].count);
|
|
82
77
|
}
|
|
83
|
-
- (NSRect)logicalRefreshRect { return NSMakeRect(QuotaLogicalWidth - 54, [self logicalHeight] - 52, 34, 32); }
|
|
84
|
-
- (NSRect)refreshRect {
|
|
85
|
-
NSRect logical = [self logicalRefreshRect];
|
|
86
|
-
return NSMakeRect(logical.origin.x * QuotaScale, logical.origin.y * QuotaScale,
|
|
87
|
-
logical.size.width * QuotaScale, logical.size.height * QuotaScale);
|
|
88
|
-
}
|
|
89
78
|
- (NSRect)logicalSummaryRect {
|
|
90
79
|
return NSMakeRect(20, [self logicalHeight] - QuotaHeaderHeight - QuotaSummaryHeight,
|
|
91
80
|
QuotaLogicalWidth - 40, QuotaSummaryHeight);
|
|
@@ -98,40 +87,6 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
98
87
|
? NSMakeRect(NSMinX(summary) + index * width, NSMinY(summary), width, NSHeight(summary))
|
|
99
88
|
: NSZeroRect;
|
|
100
89
|
}
|
|
101
|
-
- (void)mouseMoved:(NSEvent *)event {
|
|
102
|
-
NSPoint point = [self convertPoint:event.locationInWindow fromView:nil];
|
|
103
|
-
BOOL hovering = NSPointInRect(point, [self refreshRect]);
|
|
104
|
-
if (hovering != self.refreshHovered) {
|
|
105
|
-
self.refreshHovered = hovering;
|
|
106
|
-
self.needsDisplay = YES;
|
|
107
|
-
}
|
|
108
|
-
if (hovering) [NSCursor.pointingHandCursor set];
|
|
109
|
-
else [NSCursor.arrowCursor set];
|
|
110
|
-
}
|
|
111
|
-
- (void)mouseDown:(NSEvent *)event {
|
|
112
|
-
NSPoint point = [self convertPoint:event.locationInWindow fromView:nil];
|
|
113
|
-
if (NSPointInRect(point, [self refreshRect])) {
|
|
114
|
-
self.refreshPressed = YES;
|
|
115
|
-
self.needsDisplay = YES;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
- (void)mouseUp:(NSEvent *)event {
|
|
119
|
-
NSPoint point = [self convertPoint:event.locationInWindow fromView:nil];
|
|
120
|
-
BOOL shouldRefresh = self.refreshPressed && NSPointInRect(point, [self refreshRect]);
|
|
121
|
-
self.refreshPressed = NO;
|
|
122
|
-
if (shouldRefresh) {
|
|
123
|
-
if (self.refreshRequested) self.refreshRequested();
|
|
124
|
-
self.refreshedUntil = NSDate.date.timeIntervalSince1970 + 1.2;
|
|
125
|
-
[[NSHapticFeedbackManager defaultPerformer] performFeedbackPattern:NSHapticFeedbackPatternAlignment
|
|
126
|
-
performanceTime:NSHapticFeedbackPerformanceTimeNow];
|
|
127
|
-
[self performSelector:@selector(clearRefreshConfirmation) withObject:nil afterDelay:1.2];
|
|
128
|
-
}
|
|
129
|
-
self.needsDisplay = YES;
|
|
130
|
-
}
|
|
131
|
-
- (void)clearRefreshConfirmation {
|
|
132
|
-
self.refreshedUntil = 0;
|
|
133
|
-
self.needsDisplay = YES;
|
|
134
|
-
}
|
|
135
90
|
- (NSDictionary *)quota:(NSDictionary *)usage key:(NSString *)key {
|
|
136
91
|
id value = usage[key];
|
|
137
92
|
return [value isKindOfClass:NSDictionary.class] ? value : nil;
|
|
@@ -219,9 +174,11 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
219
174
|
NSDateFormatter *formatter = [NSDateFormatter new];
|
|
220
175
|
formatter.locale = [NSLocale localeWithLocaleIdentifier:@"zh_CN"];
|
|
221
176
|
formatter.timeZone = NSTimeZone.localTimeZone;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
177
|
+
// 原生玻璃下字号更大,完整说明在单元格里放不下,只留起始日期。
|
|
178
|
+
formatter.dateFormat = self.usesLiquidGlass ? @"M/d" : @"yyyy-MM-dd";
|
|
179
|
+
NSString *date = [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:start.doubleValue]];
|
|
180
|
+
return self.usesLiquidGlass ? [NSString stringWithFormat:@"近 7 天累计用量(%@ 起)", date]
|
|
181
|
+
: [NSString stringWithFormat:@"近 7 天累计用量(%@ 至今·滚动记录)", date];
|
|
225
182
|
}
|
|
226
183
|
// 在线 = 这一家还有活着的客户端,和有没有额度数据无关:额度会一直缓存着,
|
|
227
184
|
// 拿它当在线信号会恒亮。身份不明的老客户端无法归属到某一家,保守地都算在线。
|
|
@@ -229,7 +186,15 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
229
186
|
return [self.liveProviders containsObject:name] || self.hasUnlabeledClient;
|
|
230
187
|
}
|
|
231
188
|
- (NSColor *)primaryColor { return [NSColor colorWithWhite:0.97 alpha:1]; }
|
|
232
|
-
- (NSColor *)secondaryColor {
|
|
189
|
+
- (NSColor *)secondaryColor {
|
|
190
|
+
// 没有深色底托着时,0.68 的灰在亮壁纸上会发虚。
|
|
191
|
+
return [NSColor colorWithWhite:self.usesLiquidGlass ? 0.84 : 0.68 alpha:1];
|
|
192
|
+
}
|
|
193
|
+
// 原生玻璃背后只有一层压暗,原来的紫在上面偏暗,提亮到和青色相近的明度。
|
|
194
|
+
- (NSColor *)claudeColor {
|
|
195
|
+
return self.usesLiquidGlass ? [NSColor colorWithRed:0.80 green:0.66 blue:1.00 alpha:1]
|
|
196
|
+
: [NSColor colorWithRed:0.66 green:0.43 blue:0.94 alpha:1];
|
|
197
|
+
}
|
|
233
198
|
- (NSColor *)accentColor { return [NSColor colorWithRed:0.30 green:0.82 blue:0.90 alpha:1]; }
|
|
234
199
|
// 有 Agent 在线才用绿色,否则整块转灰,避免"暂无 Agent 在线"配一个绿点。
|
|
235
200
|
- (NSColor *)agentStatusColor {
|
|
@@ -268,7 +233,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
268
233
|
NSString *label = metric[@"label"];
|
|
269
234
|
NSColor *color = metric[@"color"];
|
|
270
235
|
NSDictionary *attributes = @{NSFontAttributeName: font,
|
|
271
|
-
NSForegroundColorAttributeName: color};
|
|
236
|
+
NSForegroundColorAttributeName: [self textColor:color]};
|
|
272
237
|
NSImage *icon = [NSImage imageWithSystemSymbolName:metric[@"symbol"]
|
|
273
238
|
accessibilityDescription:label];
|
|
274
239
|
NSImageSymbolConfiguration *sizeConfiguration =
|
|
@@ -321,23 +286,90 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
321
286
|
if (age < 3600) return [NSString stringWithFormat:@"%.0f 分钟前", floor(age / 60)];
|
|
322
287
|
return [NSString stringWithFormat:@"%.0f 小时前", floor(age / 3600)];
|
|
323
288
|
}
|
|
289
|
+
// 原生玻璃下背景可以是任意壁纸,面板按 0.58 缩放后小字只有 6–7pt,细笔画很容易被
|
|
290
|
+
// 背后的纹理吃掉。所以 liquid 模式统一收紧文字:小字放大一点、加粗一级;灰字不低于
|
|
291
|
+
// 0.84;彩色字改成白字。
|
|
292
|
+
// 经典主题有深色实底托着,保持原样。
|
|
293
|
+
// 小字统一抬到逻辑 14(屏幕约 8.1pt),这是 440pt 宽面板在不改版式的前提下放得下的上限;
|
|
294
|
+
// 再往上要放大面板或删行。数字用等宽字形,跳动时不左右晃;汉字不受影响。
|
|
295
|
+
- (NSFont *)fontWithSize:(CGFloat)size weight:(NSFontWeight)weight {
|
|
296
|
+
if (!self.usesLiquidGlass) return [NSFont systemFontOfSize:size weight:weight];
|
|
297
|
+
if (size < 14) size = 14;
|
|
298
|
+
else if (size <= 16) size += 1;
|
|
299
|
+
if (weight < NSFontWeightMedium) weight = NSFontWeightMedium;
|
|
300
|
+
else if (weight < NSFontWeightSemibold) weight = NSFontWeightSemibold;
|
|
301
|
+
else if (weight < NSFontWeightBold) weight = NSFontWeightBold;
|
|
302
|
+
return [NSFont monospacedDigitSystemFontOfSize:size weight:weight];
|
|
303
|
+
}
|
|
304
|
+
// 局部衬底:只垫在卡片和汇总区下面,面板边缘和卡片间隙保持通透。衬底本身不能带
|
|
305
|
+
// 文字投影,否则卡片边缘会多一圈黑晕。
|
|
306
|
+
// 原生玻璃下在文字前画一个彩色小圆点,替代原来的彩色字;经典主题照旧画彩色字。
|
|
307
|
+
- (void)drawText:(NSString *)text inRect:(NSRect)rect size:(CGFloat)size
|
|
308
|
+
weight:(NSFontWeight)weight color:(NSColor *)color dotColor:(NSColor *)dotColor {
|
|
309
|
+
if (!self.usesLiquidGlass) {
|
|
310
|
+
[text drawInRect:rect withAttributes:[self textAttributesWithSize:size color:color weight:weight]];
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
NSMutableDictionary *attributes = [[self textAttributesWithSize:size color:color
|
|
314
|
+
weight:weight] mutableCopy];
|
|
315
|
+
NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
|
|
316
|
+
style.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
317
|
+
attributes[NSParagraphStyleAttributeName] = style;
|
|
318
|
+
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
|
+
NSRect textRect = rect;
|
|
329
|
+
textRect.origin.x += diameter + 6;
|
|
330
|
+
textRect.size.width -= diameter + 6;
|
|
331
|
+
[text drawInRect:textRect withAttributes:attributes];
|
|
332
|
+
}
|
|
333
|
+
// 风险提示:原生玻璃下是圆点 + 白字;经典主题照旧画彩色字。
|
|
334
|
+
- (void)drawTip:(NSString *)text inRect:(NSRect)rect color:(NSColor *)color {
|
|
335
|
+
[self drawText:text inRect:rect size:11 weight:NSFontWeightMedium color:color dotColor:color];
|
|
336
|
+
}
|
|
337
|
+
- (void)fillLiquidScrim:(NSBezierPath *)path {
|
|
338
|
+
[NSGraphicsContext saveGraphicsState];
|
|
339
|
+
[[NSShadow new] set];
|
|
340
|
+
[[NSColor colorWithWhite:0 alpha:self.cardScrimAlpha] setFill];
|
|
341
|
+
[path fill];
|
|
342
|
+
[NSGraphicsContext restoreGraphicsState];
|
|
343
|
+
}
|
|
344
|
+
- (NSColor *)textColor:(NSColor *)color {
|
|
345
|
+
if (!self.usesLiquidGlass) return color;
|
|
346
|
+
NSColor *rgb = [color colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
|
|
347
|
+
if (!rgb) return color;
|
|
348
|
+
CGFloat r, g, b, a;
|
|
349
|
+
[rgb getRed:&r green:&g blue:&b alpha:&a];
|
|
350
|
+
CGFloat saturation = MAX(r, MAX(g, b)) - MIN(r, MIN(g, b));
|
|
351
|
+
if (saturation < 0.05) return [NSColor colorWithWhite:MAX(MAX(r, MAX(g, b)), 0.84) alpha:a];
|
|
352
|
+
// 彩色字在任意亮度的背景上对比都不稳定,原生玻璃下文字一律用白色;颜色的语义改由
|
|
353
|
+
// 字前的小圆点、图标和曲线承担(见 drawText:inRect:size:weight:color:dotColor:)。
|
|
354
|
+
return [NSColor colorWithWhite:0.96 alpha:a];
|
|
355
|
+
}
|
|
324
356
|
- (NSDictionary *)textAttributesWithSize:(CGFloat)size color:(NSColor *)color weight:(NSFontWeight)weight {
|
|
325
|
-
return @{NSFontAttributeName: [
|
|
326
|
-
NSForegroundColorAttributeName: color};
|
|
357
|
+
return @{NSFontAttributeName: [self fontWithSize:size weight:weight],
|
|
358
|
+
NSForegroundColorAttributeName: [self textColor:color]};
|
|
327
359
|
}
|
|
328
360
|
- (NSDictionary *)rightAlignedTextAttributesWithSize:(CGFloat)size color:(NSColor *)color
|
|
329
361
|
weight:(NSFontWeight)weight {
|
|
330
362
|
NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
|
|
331
363
|
style.alignment = NSTextAlignmentRight;
|
|
332
|
-
return @{NSFontAttributeName: [
|
|
333
|
-
NSForegroundColorAttributeName: color,
|
|
364
|
+
return @{NSFontAttributeName: [self fontWithSize:size weight:weight],
|
|
365
|
+
NSForegroundColorAttributeName: [self textColor:color],
|
|
334
366
|
NSParagraphStyleAttributeName: style};
|
|
335
367
|
}
|
|
336
368
|
- (NSDictionary *)centeredTextAttributesWithSize:(CGFloat)size color:(NSColor *)color weight:(NSFontWeight)weight {
|
|
337
369
|
NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
|
|
338
370
|
style.alignment = NSTextAlignmentCenter;
|
|
339
|
-
return @{NSFontAttributeName: [
|
|
340
|
-
NSForegroundColorAttributeName: color,
|
|
371
|
+
return @{NSFontAttributeName: [self fontWithSize:size weight:weight],
|
|
372
|
+
NSForegroundColorAttributeName: [self textColor:color],
|
|
341
373
|
NSParagraphStyleAttributeName: style};
|
|
342
374
|
}
|
|
343
375
|
- (void)fillRoundedRect:(NSRect)rect radius:(CGFloat)radius color:(NSColor *)color {
|
|
@@ -560,11 +592,16 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
560
592
|
BOOL online = [self isProviderOnline:name];
|
|
561
593
|
|
|
562
594
|
NSBezierPath *cardPath = [NSBezierPath bezierPathWithRoundedRect:card xRadius:18 yRadius:18];
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
595
|
+
// 经典主题的浅色渐变放到玻璃上会变成磨砂;原生玻璃下改垫一层深色衬底托住文字。
|
|
596
|
+
if (self.usesLiquidGlass) {
|
|
597
|
+
[self fillLiquidScrim:cardPath];
|
|
598
|
+
} else {
|
|
599
|
+
NSGradient *cardGlass = [[NSGradient alloc]
|
|
600
|
+
initWithStartingColor:[NSColor colorWithWhite:1 alpha:0.085]
|
|
601
|
+
endingColor:[color colorWithAlphaComponent:0.025]];
|
|
602
|
+
[cardGlass drawInBezierPath:cardPath angle:-25];
|
|
603
|
+
}
|
|
604
|
+
[[NSColor colorWithWhite:1 alpha:self.usesLiquidGlass ? 0.10 : 0.18] setStroke];
|
|
568
605
|
cardPath.lineWidth = 1;
|
|
569
606
|
[cardPath stroke];
|
|
570
607
|
|
|
@@ -597,12 +634,19 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
597
634
|
: (!hasData ? @"等待数据" : (online ? @"● 在线" : @"离线"));
|
|
598
635
|
NSColor *statusColor = (!apiMode && exhausted) ? NSColor.systemOrangeColor
|
|
599
636
|
: (online && hasData ? NSColor.systemGreenColor : secondary);
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
637
|
+
if (self.usesLiquidGlass) {
|
|
638
|
+
// 原生玻璃下不画彩色底标签,状态色交给字前的圆点;文字里自带的"●"去掉,免得两个点。
|
|
639
|
+
NSString *plain = [statusText stringByReplacingOccurrencesOfString:@"● " withString:@""];
|
|
640
|
+
[self drawText:plain inRect:NSMakeRect(NSMinX(card) + 96, NSMinY(card) + 57, 120, 20)
|
|
641
|
+
size:11 weight:NSFontWeightMedium color:statusColor dotColor:statusColor];
|
|
642
|
+
} else {
|
|
643
|
+
NSDictionary *statusAttributes = [self textAttributesWithSize:11 color:statusColor
|
|
644
|
+
weight:NSFontWeightMedium];
|
|
645
|
+
CGFloat statusWidth = ceil([statusText sizeWithAttributes:statusAttributes].width) + 18;
|
|
646
|
+
NSRect status = NSMakeRect(NSMinX(card) + 94, NSMinY(card) + 55, statusWidth, 24);
|
|
647
|
+
[self fillRoundedRect:status radius:12 color:[statusColor colorWithAlphaComponent:0.13]];
|
|
648
|
+
[statusText drawInRect:NSInsetRect(status, 9, 4) withAttributes:statusAttributes];
|
|
649
|
+
}
|
|
606
650
|
|
|
607
651
|
if (apiMode) {
|
|
608
652
|
CGFloat callX = NSMinX(card) + 214;
|
|
@@ -655,26 +699,31 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
655
699
|
NSDictionary *requestComparison = [self comparisonForCurrent:
|
|
656
700
|
[monthComparable[@"request_count"] doubleValue]
|
|
657
701
|
previous:[previousMonthTokens[@"request_count"] doubleValue] color:color];
|
|
658
|
-
[requestComparison[@"text"]
|
|
659
|
-
|
|
660
|
-
|
|
702
|
+
[self drawText:requestComparison[@"text"] inRect:NSMakeRect(callX, NSMinY(card) + 22, 158, 18)
|
|
703
|
+
size:11 weight:NSFontWeightMedium color:requestComparison[@"color"]
|
|
704
|
+
dotColor:requestComparison[@"color"]];
|
|
661
705
|
NSDictionary *tokenComparison = [self comparisonForCurrent:
|
|
662
706
|
[monthComparable[@"total_tokens"] doubleValue]
|
|
663
707
|
previous:[previousMonthTokens[@"total_tokens"] doubleValue] color:color];
|
|
664
|
-
[tokenComparison[@"text"]
|
|
665
|
-
|
|
666
|
-
|
|
708
|
+
[self drawText:tokenComparison[@"text"] inRect:NSMakeRect(tokenX, NSMinY(card) + 22, 158, 18)
|
|
709
|
+
size:11 weight:NSFontWeightMedium color:tokenComparison[@"color"]
|
|
710
|
+
dotColor:tokenComparison[@"color"]];
|
|
667
711
|
|
|
668
712
|
CGFloat trendX = NSMinX(card) + 564;
|
|
669
713
|
// 「按日 Token」跟在标题后面,与标题同一行:它是标题的限定语,单独占一行既浪费
|
|
670
714
|
// 竖向空间,也把曲线和脚注挤得没法与左边两列对齐。
|
|
671
715
|
[@"本月趋势" drawInRect:NSMakeRect(trendX, NSMinY(card) + 114, 60, 20)
|
|
672
716
|
withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
717
|
+
if (self.usesLiquidGlass) {
|
|
718
|
+
[self drawText:@"按日 Token" inRect:NSMakeRect(trendX + 62, NSMinY(card) + 114, 96, 20)
|
|
719
|
+
size:11 weight:NSFontWeightSemibold color:color dotColor:color];
|
|
720
|
+
} else {
|
|
721
|
+
NSDictionary *pillAttributes = [self textAttributesWithSize:11 color:color
|
|
722
|
+
weight:NSFontWeightSemibold];
|
|
723
|
+
NSRect pill = NSMakeRect(trendX + 59, NSMinY(card) + 113, 76, 22);
|
|
724
|
+
[self fillRoundedRect:pill radius:11 color:[color colorWithAlphaComponent:0.14]];
|
|
725
|
+
[@"按日 Token" drawInRect:NSInsetRect(pill, 9, 3) withAttributes:pillAttributes];
|
|
726
|
+
}
|
|
678
727
|
NSRect curveRect = NSMakeRect(trendX, NSMinY(card) + 62, 135, 38);
|
|
679
728
|
[self drawMonthlyTokenCurve:monthDaily inRect:curveRect color:color];
|
|
680
729
|
double peak = 0;
|
|
@@ -744,10 +793,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
744
793
|
? window[@"rolling"] : [NSString stringWithFormat:@"重置时间 %@", resetValue];
|
|
745
794
|
[reset drawInRect:NSMakeRect(x, NSMinY(card) + 46, 150, 18)
|
|
746
795
|
withAttributes:[self textAttributesWithSize:11 color:secondary weight:NSFontWeightRegular]];
|
|
747
|
-
|
|
796
|
+
// 原生玻璃下字更大、前面还有圆点,这一栏放不下"Token"一词;脚注里已说明
|
|
797
|
+
// Token 即本机统计的已用量。
|
|
798
|
+
NSString *tokenText = [NSString stringWithFormat:
|
|
799
|
+
self.usesLiquidGlass ? @"已用 %@" : @"已用 Token %@",
|
|
748
800
|
[self formattedTokenCount:window[@"tokens"]]];
|
|
749
|
-
[tokenText
|
|
750
|
-
|
|
801
|
+
[self drawText:tokenText inRect:NSMakeRect(x, NSMinY(card) + 22, 150, 22) size:14
|
|
802
|
+
weight:NSFontWeightSemibold color:color dotColor:color];
|
|
751
803
|
}
|
|
752
804
|
|
|
753
805
|
CGFloat trendX = NSMinX(card) + 564;
|
|
@@ -776,14 +828,19 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
776
828
|
paceTip = @"官方额度受限,等待重置";
|
|
777
829
|
tipColor = NSColor.systemOrangeColor;
|
|
778
830
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
831
|
+
if (self.usesLiquidGlass) {
|
|
832
|
+
[self drawText:pace[@"label"] inRect:NSMakeRect(trendX + 62, NSMinY(card) + 114, 96, 20)
|
|
833
|
+
size:11 weight:NSFontWeightSemibold color:paceColor dotColor:paceColor];
|
|
834
|
+
} else {
|
|
835
|
+
NSDictionary *pillAttributes = [self textAttributesWithSize:11 color:paceColor
|
|
836
|
+
weight:NSFontWeightSemibold];
|
|
837
|
+
// 档位标签跟在标题后面。宽度仍按文字算:四个档位不一样长,最宽的"数据不足"到
|
|
838
|
+
// trendX + 131,列宽 145 放得下。
|
|
839
|
+
CGFloat pillWidth = ceil([pace[@"label"] sizeWithAttributes:pillAttributes].width) + 18;
|
|
840
|
+
NSRect pill = NSMakeRect(trendX + 59, NSMinY(card) + 113, pillWidth, 22);
|
|
841
|
+
[self fillRoundedRect:pill radius:11 color:[paceColor colorWithAlphaComponent:0.14]];
|
|
842
|
+
[pace[@"label"] drawInRect:NSInsetRect(pill, 9, 3) withAttributes:pillAttributes];
|
|
843
|
+
}
|
|
787
844
|
|
|
788
845
|
NSRect curveRect = NSMakeRect(trendX, NSMinY(card) + 62, 135, 38);
|
|
789
846
|
[self drawUsageCurve:points inRect:curveRect color:color];
|
|
@@ -799,8 +856,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
799
856
|
withAttributes:[self rightAlignedTextAttributesWithSize:10 color:secondary
|
|
800
857
|
weight:NSFontWeightRegular]];
|
|
801
858
|
// 与左边两列的"已用 Token"同一条基线(+22),也和 API 卡的脚注行对齐。
|
|
802
|
-
[paceTip
|
|
803
|
-
withAttributes:[self textAttributesWithSize:11 color:tipColor weight:NSFontWeightMedium]];
|
|
859
|
+
[self drawTip:paceTip inRect:NSMakeRect(trendX, NSMinY(card) + 22, 145, 18) color:tipColor];
|
|
804
860
|
}
|
|
805
861
|
- (void)drawRect:(NSRect)dirtyRect {
|
|
806
862
|
[NSGraphicsContext saveGraphicsState];
|
|
@@ -812,44 +868,65 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
812
868
|
NSRect logicalBounds = NSMakeRect(0, 0, QuotaLogicalWidth, height);
|
|
813
869
|
NSRect outer = NSInsetRect(logicalBounds, 1, 1);
|
|
814
870
|
NSBezierPath *background = [NSBezierPath bezierPathWithRoundedRect:outer xRadius:24 yRadius:24];
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
871
|
+
// 原生玻璃按 13pt 圆角裁切整个面板;底色也铺满到同一圆角,否则玻璃边缘和
|
|
872
|
+
// 底色之间会露出一圈细缝。
|
|
873
|
+
if (self.usesLiquidGlass) {
|
|
874
|
+
CGFloat radius = 13 / QuotaScale;
|
|
875
|
+
background = [NSBezierPath bezierPathWithRoundedRect:logicalBounds
|
|
876
|
+
xRadius:radius yRadius:radius];
|
|
877
|
+
}
|
|
878
|
+
// 原生玻璃不铺底色:任何一层深色都会把 Clear 玻璃压回磨砂感。
|
|
879
|
+
if (!self.usesLiquidGlass) {
|
|
880
|
+
NSGradient *gradient = [[NSGradient alloc]
|
|
881
|
+
initWithStartingColor:[NSColor colorWithRed:0.025 green:0.055 blue:0.095 alpha:0.88]
|
|
882
|
+
endingColor:[NSColor colorWithRed:0.07 green:0.12 blue:0.19 alpha:0.80]];
|
|
883
|
+
[gradient drawInBezierPath:background angle:-20];
|
|
884
|
+
}
|
|
819
885
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
886
|
+
// 原生玻璃自己绘制高光和边缘,不叠加经典主题的模拟反光。
|
|
887
|
+
if (!self.usesLiquidGlass) {
|
|
888
|
+
[NSGraphicsContext saveGraphicsState];
|
|
889
|
+
[background addClip];
|
|
890
|
+
NSGradient *topGlow = [[NSGradient alloc]
|
|
891
|
+
initWithStartingColor:[NSColor colorWithWhite:1 alpha:0.34]
|
|
892
|
+
endingColor:[NSColor colorWithWhite:1 alpha:0.0]];
|
|
893
|
+
// 两处光晕原本是按 H=590 定的绝对点。面板会变矮,改成跟着高度走:顶部光源始终悬在
|
|
894
|
+
// 面板上沿之外,冷色光晕落在内容区中段。
|
|
895
|
+
NSPoint topGlowCenter = NSMakePoint(700, height + 60);
|
|
896
|
+
[topGlow drawFromCenter:topGlowCenter radius:0
|
|
897
|
+
toCenter:topGlowCenter radius:250 options:0];
|
|
898
|
+
NSGradient *cyanGlow = [[NSGradient alloc]
|
|
899
|
+
initWithStartingColor:[NSColor colorWithRed:0.18 green:0.72 blue:1 alpha:0.11]
|
|
900
|
+
endingColor:[NSColor colorWithRed:0.18 green:0.88 blue:1 alpha:0.0]];
|
|
901
|
+
NSPoint cyanGlowCenter = NSMakePoint(660, height * 0.42);
|
|
902
|
+
[cyanGlow drawFromCenter:cyanGlowCenter radius:0
|
|
903
|
+
toCenter:cyanGlowCenter radius:260 options:0];
|
|
904
|
+
[NSGraphicsContext restoreGraphicsState];
|
|
837
905
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
906
|
+
[[NSColor colorWithWhite:1 alpha:0.34] setStroke];
|
|
907
|
+
background.lineWidth = 1.5;
|
|
908
|
+
[background stroke];
|
|
909
|
+
NSBezierPath *innerGlassBorder = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(outer, 2, 2)
|
|
910
|
+
xRadius:22 yRadius:22];
|
|
911
|
+
[[NSColor colorWithRed:0.58 green:0.82 blue:1 alpha:0.22] setStroke];
|
|
912
|
+
innerGlassBorder.lineWidth = 0.8;
|
|
913
|
+
[innerGlassBorder stroke];
|
|
914
|
+
}
|
|
915
|
+
// 玻璃底下可能是任意亮度的壁纸,除了玻璃背后的压暗层,再给白字加一层很淡的投影托底。
|
|
916
|
+
if (self.usesLiquidGlass) {
|
|
917
|
+
NSShadow *legibility = [NSShadow new];
|
|
918
|
+
legibility.shadowColor = [NSColor colorWithWhite:0 alpha:0.4];
|
|
919
|
+
legibility.shadowBlurRadius = 2;
|
|
920
|
+
legibility.shadowOffset = NSMakeSize(0, -0.5);
|
|
921
|
+
[legibility set];
|
|
922
|
+
}
|
|
846
923
|
NSColor *primary = self.primaryColor;
|
|
847
924
|
NSColor *secondary = self.secondaryColor;
|
|
848
925
|
NSColor *cyan = self.accentColor;
|
|
849
926
|
NSColor *agentColor = self.agentStatusColor;
|
|
850
927
|
[@"Agent Usage" drawInRect:NSMakeRect(28, height - 65, 260, 42)
|
|
851
928
|
withAttributes:[self textAttributesWithSize:30 color:primary weight:NSFontWeightBold]];
|
|
852
|
-
[@"实时状态与滚动用量" drawInRect:NSMakeRect(30, height - 94, 130, 22)
|
|
929
|
+
[@"实时状态与滚动用量" drawInRect:NSMakeRect(30, height - 94, self.usesLiquidGlass ? 142 : 130, 22)
|
|
853
930
|
withAttributes:[self textAttributesWithSize:14 color:secondary weight:NSFontWeightRegular]];
|
|
854
931
|
[agentColor setFill];
|
|
855
932
|
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(174, height - 88, 9, 9)] fill];
|
|
@@ -860,17 +937,10 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
860
937
|
withAttributes:[self textAttributesWithSize:14 color:agentColor weight:NSFontWeightMedium]];
|
|
861
938
|
[self drawSystemMetricsEndingAtX:QuotaLogicalWidth - 28 y:height - 95];
|
|
862
939
|
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
NSRect logicalRefreshRect = [self logicalRefreshRect];
|
|
866
|
-
NSRect refreshRect = self.refreshPressed ? NSInsetRect(logicalRefreshRect, 1.5, 1.5) : logicalRefreshRect;
|
|
867
|
-
[self fillRoundedRect:refreshRect radius:10 color:[NSColor colorWithWhite:1 alpha:buttonAlpha]];
|
|
868
|
-
[recentlyRefreshed ? @"✓" : @"↻" drawInRect:NSInsetRect(refreshRect, 8, 4)
|
|
869
|
-
withAttributes:[self textAttributesWithSize:19 color:[NSColor colorWithWhite:0.9 alpha:1] weight:NSFontWeightRegular]];
|
|
870
|
-
// 贴着刷新按钮左侧右对齐:它说明的正是这个按钮上次生效的时间,挨着放才不用再标一遍
|
|
871
|
-
// "数据刷新"是什么意思。放回汇总条里会挤掉一整格 Provider 数据。
|
|
940
|
+
// 用量由定时器自动刷新,面板不再提供手动刷新按钮;右上角只留上次刷新的时间,
|
|
941
|
+
// 与下一行的系统指标右边对齐。放回汇总条里会挤掉一整格 Provider 数据。
|
|
872
942
|
[[NSString stringWithFormat:@"数据刷新 %@", [self refreshAgeText]]
|
|
873
|
-
drawInRect:NSMakeRect(
|
|
943
|
+
drawInRect:NSMakeRect(QuotaLogicalWidth - 28 - 200, height - 45, 200, 18)
|
|
874
944
|
withAttributes:[self rightAlignedTextAttributesWithSize:11 color:secondary
|
|
875
945
|
weight:NSFontWeightRegular]];
|
|
876
946
|
|
|
@@ -882,7 +952,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
882
952
|
@"Codex": @{@"usage": self.codexUsage ?: @{}, @"usedKey": @"used_percent",
|
|
883
953
|
@"color": cyan},
|
|
884
954
|
@"Claude": @{@"usage": self.claudeUsage ?: @{}, @"usedKey": @"used_percentage",
|
|
885
|
-
@"color":
|
|
955
|
+
@"color": self.claudeColor}
|
|
886
956
|
};
|
|
887
957
|
// 卡片从汇总条下方依次向下排。少一家就少一张卡,脚注跟着上移;这里的分段账必须和
|
|
888
958
|
// QuotaLogicalHeightForProviderCount 完全一致,否则面板会多出或少掉一段空白。
|
|
@@ -919,11 +989,15 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
919
989
|
? @"ⓘ 桌宠与系统状态不受影响;额度卡只在检测到对应 CLI 时显示"
|
|
920
990
|
: (hasAPICard
|
|
921
991
|
? @"ⓘ API 用量 = 本机会话统计(输入含缓存读写);环比按上月相同时间进度计算"
|
|
922
|
-
:
|
|
992
|
+
: (self.usesLiquidGlass
|
|
993
|
+
? @"ⓘ 百分比 = 官方额度剩余;Token = 本机统计已用量(含缓存读写)"
|
|
994
|
+
: @"ⓘ 百分比 = 官方订阅额度的剩余比例;Token = 本机统计的已用量(输入含缓存读写),两者口径不同"));
|
|
923
995
|
// 最后一块的底边距面板底 QuotaFooterHeight:脚注与其留约 8pt,底部留白 16pt,
|
|
924
996
|
// 和顶部标题的留白大致对称。
|
|
925
997
|
[footer drawInRect:NSMakeRect(28, 16, 650, 20)
|
|
926
|
-
withAttributes:[self textAttributesWithSize:11
|
|
998
|
+
withAttributes:[self textAttributesWithSize:11
|
|
999
|
+
color:self.usesLiquidGlass ? self.secondaryColor : [NSColor colorWithWhite:0.58 alpha:1]
|
|
1000
|
+
weight:NSFontWeightRegular]];
|
|
927
1001
|
[NSGraphicsContext restoreGraphicsState];
|
|
928
1002
|
}
|
|
929
1003
|
|
|
@@ -935,9 +1009,13 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
935
1009
|
secondary:(NSColor *)secondary accent:(NSColor *)cyan {
|
|
936
1010
|
NSRect summary = [self logicalSummaryRect];
|
|
937
1011
|
NSBezierPath *summaryPath = [NSBezierPath bezierPathWithRoundedRect:summary xRadius:18 yRadius:18];
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1012
|
+
if (self.usesLiquidGlass) {
|
|
1013
|
+
[self fillLiquidScrim:summaryPath];
|
|
1014
|
+
} else {
|
|
1015
|
+
[[NSColor colorWithWhite:1 alpha:0.065] setFill];
|
|
1016
|
+
[summaryPath fill];
|
|
1017
|
+
}
|
|
1018
|
+
[[NSColor colorWithWhite:1 alpha:self.usesLiquidGlass ? 0.10 : 0.16] setStroke];
|
|
941
1019
|
[summaryPath stroke];
|
|
942
1020
|
|
|
943
1021
|
NSArray<NSDictionary *> *cells = @[
|
|
@@ -949,7 +1027,7 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
949
1027
|
NSDictionary *rowSpecs = @{
|
|
950
1028
|
@"Codex": @{@"usage": self.codexUsage ?: @{}, @"color": cyan},
|
|
951
1029
|
@"Claude": @{@"usage": self.claudeUsage ?: @{},
|
|
952
|
-
@"color":
|
|
1030
|
+
@"color": self.claudeColor}
|
|
953
1031
|
};
|
|
954
1032
|
// 两行版的槽位是写死的。只装了一家时改用居中的单行槽位,否则汇总条会空出半格,
|
|
955
1033
|
// 看着像数据没加载出来。
|
|
@@ -977,9 +1055,9 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
977
1055
|
CGFloat x = NSMinX([self logicalSummaryCellRectAtIndex:index]);
|
|
978
1056
|
const CGFloat inputX = x + 176;
|
|
979
1057
|
const CGFloat outputX = x + 276;
|
|
980
|
-
NSFont *headerFont = [
|
|
1058
|
+
NSFont *headerFont = [self fontWithSize:11 weight:NSFontWeightRegular];
|
|
981
1059
|
NSDictionary *headerAttributes = @{NSFontAttributeName: headerFont,
|
|
982
|
-
NSForegroundColorAttributeName: secondary};
|
|
1060
|
+
NSForegroundColorAttributeName: [self textColor:secondary]};
|
|
983
1061
|
NSImage *headerIcon = [NSImage imageWithSystemSymbolName:cell[@"headerSymbol"]
|
|
984
1062
|
accessibilityDescription:cell[@"label"]];
|
|
985
1063
|
NSImageSymbolConfiguration *headerIconConfiguration =
|
|
@@ -1009,9 +1087,10 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
1009
1087
|
CGFloat nameY = NSMinY(summary) + [row[@"nameY"] doubleValue];
|
|
1010
1088
|
CGFloat labelY = NSMinY(summary) + [row[@"labelY"] doubleValue];
|
|
1011
1089
|
CGFloat valueY = NSMinY(summary) + [row[@"valueY"] doubleValue];
|
|
1090
|
+
// 这是图标字形不是文字,原生玻璃下也保留颜色:它负责标出这一行是哪一家。
|
|
1012
1091
|
[cell[@"icon"] drawInRect:NSMakeRect(x + 20, iconY, 42, 42)
|
|
1013
|
-
withAttributes:[
|
|
1014
|
-
weight:NSFontWeightRegular]];
|
|
1092
|
+
withAttributes:@{NSFontAttributeName: [NSFont systemFontOfSize:30
|
|
1093
|
+
weight:NSFontWeightRegular], NSForegroundColorAttributeName: rowColor}];
|
|
1015
1094
|
[row[@"name"] drawInRect:NSMakeRect(x + 66, nameY, 76, 22)
|
|
1016
1095
|
withAttributes:[self textAttributesWithSize:14 color:rowColor
|
|
1017
1096
|
weight:NSFontWeightMedium]];
|
package/Sources/CCPets/main.m
CHANGED
|
@@ -45,6 +45,7 @@ int main(int argc, const char *argv[]) {
|
|
|
45
45
|
if (argc > 1 && (strcmp(argv[1], "--provider-event") == 0 ||
|
|
46
46
|
strcmp(argv[1], "provider-event") == 0)) return RecordProviderEvent();
|
|
47
47
|
if (argc > 1 && strcmp(argv[1], "--claude-usage") == 0) return RecordClaudeUsage();
|
|
48
|
+
if (argc > 1 && strcmp(argv[1], "--codex-launch") == 0) return RegisterCodexLaunch();
|
|
48
49
|
if (argc > 1 && strcmp(argv[1], "--clean") == 0) return CleanCCPetsData(NO);
|
|
49
50
|
if (argc > 1 && strcmp(argv[1], "--purge-data") == 0) return CleanCCPetsData(YES);
|
|
50
51
|
if (argc > 1 && strcmp(argv[1], "--history") == 0) {
|
|
@@ -84,6 +85,21 @@ int main(int argc, const char *argv[]) {
|
|
|
84
85
|
return EXIT_SUCCESS;
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
// 走到这里就要启动桌宠了。拼错的 `--xxx` 原先会被当成"启动":桌宠已在运行时静默退出,
|
|
89
|
+
// 否则在前台拉起一个桌宠占住终端,两种都让人看不出哪里错了。只拦双横线参数:
|
|
90
|
+
// 单横线的 -psn_* / -NS* / -Apple* 是系统和 Xcode 启动 App 时自己加的。
|
|
91
|
+
for (int index = 1; index < argc; index++) {
|
|
92
|
+
if (strncmp(argv[index], "--", 2) != 0) continue;
|
|
93
|
+
static const char *launchFlags[] = {"--managed", "--standalone", "--preview-dashboard"};
|
|
94
|
+
BOOL known = NO;
|
|
95
|
+
for (size_t flag = 0; flag < sizeof(launchFlags) / sizeof(launchFlags[0]); flag++) {
|
|
96
|
+
if (strcmp(argv[index], launchFlags[flag]) == 0) known = YES;
|
|
97
|
+
}
|
|
98
|
+
if (known) continue;
|
|
99
|
+
fprintf(stderr, "未知参数:%s\n运行 cc-pets --help 查看用法。\n", argv[index]);
|
|
100
|
+
return 2;
|
|
101
|
+
}
|
|
102
|
+
|
|
87
103
|
NSString *lockName = [NSString stringWithFormat:@"cc-pets-%u.lock", getuid()];
|
|
88
104
|
NSString *lockPath = [PetStateDirectory() stringByAppendingPathComponent:lockName];
|
|
89
105
|
int lock = open(lockPath.fileSystemRepresentation, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
package/bin/cc-pets
CHANGED
|
@@ -7,6 +7,36 @@ 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
9
|
|
|
10
|
+
# 只列面向用户的命令。--hook / --claude-usage / --provider-event / --render-* 等是
|
|
11
|
+
# hooks、statusline 和测试调用的内部入口,列出来只会让人误用。
|
|
12
|
+
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
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" || "${1:-}" == "help" ]]; then
|
|
36
|
+
print_usage
|
|
37
|
+
exit 0
|
|
38
|
+
fi
|
|
39
|
+
|
|
10
40
|
if [[ "${1:-}" == "install" ]]; then
|
|
11
41
|
exec "${PROJECT_DIR}/scripts/install-shell-integration.sh"
|
|
12
42
|
fi
|
|
@@ -22,7 +52,9 @@ if [[ "${1:-}" == "bridge" ]]; then
|
|
|
22
52
|
fi
|
|
23
53
|
|
|
24
54
|
if [[ "${1:-}" == "uninstall" ]]; then
|
|
25
|
-
|
|
55
|
+
shift
|
|
56
|
+
# --purge / --yes 要传下去;原先这里吞掉了参数,README 里的 uninstall --purge 实际不生效。
|
|
57
|
+
exec "${PROJECT_DIR}/scripts/uninstall-shell-integration.sh" "$@"
|
|
26
58
|
fi
|
|
27
59
|
|
|
28
60
|
if [[ "${1:-}" == "uninstall-app" ]]; then
|