cc-pets 2.4.0 → 2.6.0-beta.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 (111) hide show
  1. package/CC_BRIDGE.md +93 -14
  2. package/CC_BRIDGE.zh-CN.md +71 -11
  3. package/CHANGELOG.md +55 -0
  4. package/CHANGELOG.zh-CN.md +56 -1
  5. package/CONTRIBUTING.md +1 -1
  6. package/CONTRIBUTING.zh-CN.md +1 -1
  7. package/PROVIDER_PROTOCOL.md +5 -1
  8. package/PROVIDER_PROTOCOL.zh-CN.md +4 -1
  9. package/README.md +116 -34
  10. package/README.zh-CN.md +99 -35
  11. package/Resources/AgentIcons/antigravity.icns +0 -0
  12. package/Resources/zh-Hans.lproj/Localizable.strings +99 -26
  13. package/Sources/CCPets/App/CCPetsAppDelegate+AgentEvents.m +51 -4
  14. package/Sources/CCPets/App/CCPetsAppDelegate+AgentStatus.m +120 -17
  15. package/Sources/CCPets/App/CCPetsAppDelegate+Bridge.m +24 -11
  16. package/Sources/CCPets/App/CCPetsAppDelegate+MenuBar.m +86 -0
  17. package/Sources/CCPets/App/CCPetsAppDelegate+Private.h +24 -1
  18. package/Sources/CCPets/App/CCPetsAppDelegate+Profiles.m +21 -11
  19. package/Sources/CCPets/App/CCPetsAppDelegate+Quota.m +33 -17
  20. package/Sources/CCPets/App/CCPetsAppDelegate+Settings.m +43 -7
  21. package/Sources/CCPets/App/CCPetsAppDelegate+Speech.m +7 -4
  22. package/Sources/CCPets/App/CCPetsAppDelegate+Update.m +7 -4
  23. package/Sources/CCPets/App/CCPetsAppDelegate+Workbench.m +24 -22
  24. package/Sources/CCPets/App/CCPetsAppDelegate.h +10 -0
  25. package/Sources/CCPets/App/CCPetsAppDelegate.m +18 -8
  26. package/Sources/CCPets/App/CCPetsVersion.h +4 -0
  27. package/Sources/CCPets/App/CCPetsVersion.m +34 -0
  28. package/Sources/CCPets/App/main.m +11 -0
  29. package/Sources/CCPets/Bridge/CCPetsBridge.m +41 -17
  30. package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.h +4 -0
  31. package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.m +119 -0
  32. package/Sources/CCPets/Bridge/CCPetsBridgeCLI.h +3 -1
  33. package/Sources/CCPets/Bridge/CCPetsBridgeCLI.m +272 -50
  34. package/Sources/CCPets/Bridge/CCPetsBridgeCore.h +12 -3
  35. package/Sources/CCPets/Bridge/CCPetsBridgeCore.m +341 -95
  36. package/Sources/CCPets/Bridge/CCPetsBridgeSetup.h +0 -2
  37. package/Sources/CCPets/Bridge/CCPetsBridgeSetup.m +227 -95
  38. package/Sources/CCPets/Bridge/CCPetsBridgeStore.h +35 -5
  39. package/Sources/CCPets/Bridge/CCPetsBridgeStore.m +310 -42
  40. package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.h +12 -0
  41. package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.m +105 -0
  42. package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.h +17 -0
  43. package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.m +462 -0
  44. package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.h +5 -0
  45. package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.m +180 -0
  46. package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.h +3 -0
  47. package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.m +463 -0
  48. package/Sources/CCPets/Integrations/CCPetsEvents.h +5 -0
  49. package/Sources/CCPets/Integrations/CCPetsEvents.m +68 -12
  50. package/Sources/CCPets/Integrations/CCPetsIntegrations.h +1 -1
  51. package/Sources/CCPets/Integrations/CCPetsIntegrations.m +38 -8
  52. package/Sources/CCPets/Integrations/CCPetsLaunchPreflight.m +15 -5
  53. package/Sources/CCPets/Integrations/CCPetsProfiles.h +2 -1
  54. package/Sources/CCPets/Integrations/CCPetsProfiles.m +112 -81
  55. package/Sources/CCPets/Integrations/CCPetsTerminalFocus.h +11 -1
  56. package/Sources/CCPets/Integrations/CCPetsTerminalFocus.m +217 -45
  57. package/Sources/CCPets/Pet/CCPetsPhrasesEditor.m +7 -0
  58. package/Sources/CCPets/Pet/CCPetsPreviews.m +16 -8
  59. package/Sources/CCPets/Pet/PetView+Menu.m +64 -5
  60. package/Sources/CCPets/Pet/PetView.h +7 -0
  61. package/Sources/CCPets/Pet/PetView.m +12 -1
  62. package/Sources/CCPets/Support/CCPetsDoctor.m +126 -37
  63. package/Sources/CCPets/Support/CCPetsPaths.h +5 -0
  64. package/Sources/CCPets/Support/CCPetsPaths.m +15 -0
  65. package/Sources/CCPets/Support/CCPetsPreferences.h +14 -1
  66. package/Sources/CCPets/Support/CCPetsPreferences.m +36 -0
  67. package/Sources/CCPets/UI/CCPetsMenuBarIcon.h +16 -0
  68. package/Sources/CCPets/UI/CCPetsMenuBarIcon.m +70 -0
  69. package/Sources/CCPets/UI/CCPetsMenuBarPanel.h +18 -0
  70. package/Sources/CCPets/UI/CCPetsMenuBarPanel.m +533 -0
  71. package/Sources/CCPets/UI/CCPetsMenuBarSummary.h +51 -0
  72. package/Sources/CCPets/UI/CCPetsMenuBarSummary.m +98 -0
  73. package/Sources/CCPets/UI/CCPetsSettingsPage.h +7 -1
  74. package/Sources/CCPets/UI/CCPetsSettingsPage.m +205 -8
  75. package/Sources/CCPets/UI/CCPetsStatusItem.h +28 -0
  76. package/Sources/CCPets/UI/CCPetsStatusItem.m +147 -0
  77. package/Sources/CCPets/UI/CCPetsUIStyle.m +3 -1
  78. package/Sources/CCPets/UI/CCPetsUsagePage.h +4 -3
  79. package/Sources/CCPets/UI/CCPetsUsagePage.m +69 -43
  80. package/Sources/CCPets/UI/CCPetsUsageStore.m +11 -1
  81. package/Sources/CCPets/UI/CCPetsWorkbenchPages.m +6 -4
  82. package/Sources/CCPets/Usage/CCPetsAntigravityQuota.m +115 -0
  83. package/Sources/CCPets/Usage/CCPetsNormalizedUsage.h +5 -0
  84. package/Sources/CCPets/Usage/CCPetsNormalizedUsage.m +43 -0
  85. package/Sources/CCPets/Usage/CCPetsProviderRegistry+Testing.h +13 -0
  86. package/Sources/CCPets/Usage/CCPetsProviderRegistry.h +25 -0
  87. package/Sources/CCPets/Usage/CCPetsProviderRegistry.m +94 -0
  88. package/Sources/CCPets/Usage/CCPetsQuotaHistory.h +1 -1
  89. package/Sources/CCPets/Usage/CCPetsQuotaHistory.m +11 -8
  90. package/Sources/CCPets/Usage/CCPetsUsage+Internal.h +2 -0
  91. package/Sources/CCPets/Usage/CCPetsUsage+Models.m +206 -14
  92. package/Sources/CCPets/Usage/CCPetsUsage+TokenTotals.m +4 -4
  93. package/Sources/CCPets/Usage/CCPetsUsage.h +7 -2
  94. package/Sources/CCPets/Usage/CCPetsUsageMode.h +2 -0
  95. package/Sources/CCPets/Usage/CCPetsUsageMode.m +29 -4
  96. package/Sources/CCPets/Usage/CCPetsUsageMonitor.h +4 -4
  97. package/Sources/CCPets/Usage/CCPetsUsageMonitor.m +90 -7
  98. package/Sources/CCPets/Usage/QuotaDashboardView+CompactRow.m +81 -0
  99. package/Sources/CCPets/Usage/QuotaDashboardView+Primitives.m +5 -8
  100. package/Sources/CCPets/Usage/QuotaDashboardView+Private.h +26 -4
  101. package/Sources/CCPets/Usage/QuotaDashboardView+Rendering.m +99 -99
  102. package/Sources/CCPets/Usage/QuotaDashboardView.h +9 -10
  103. package/Sources/CCPets/Usage/QuotaDashboardView.m +232 -79
  104. package/THIRD_PARTY_NOTICES.md +5 -4
  105. package/THIRD_PARTY_NOTICES.zh-CN.md +6 -5
  106. package/bin/agy-with-pet +82 -0
  107. package/bin/cc-pets +1 -1
  108. package/bin/claude-with-pet +15 -0
  109. package/bin/codex-with-pet +17 -2
  110. package/package.json +5 -3
  111. package/scripts/install-shell-integration.sh +5 -0
@@ -0,0 +1,98 @@
1
+ #import "CCPetsMenuBarSummary.h"
2
+ #import <math.h>
3
+
4
+ const NSInteger CCPetsMenuBarWarningPercent = 20;
5
+ const NSInteger CCPetsMenuBarCriticalPercent = 10;
6
+
7
+ NSInteger CCPetsMenuBarLowestFiveHourRemaining(NSArray<NSDictionary *> *quotas) {
8
+ NSInteger lowest = -1;
9
+ for (NSDictionary *quota in quotas) {
10
+ if (![quota isKindOfClass:NSDictionary.class] || [quota[@"apiMode"] boolValue]) continue;
11
+ NSInteger remaining;
12
+ if ([quota[@"state"] isEqual:@"limited"]) {
13
+ remaining = 0;
14
+ } else if ([quota[@"fiveRemaining"] isKindOfClass:NSNumber.class]) {
15
+ double value = [quota[@"fiveRemaining"] doubleValue];
16
+ if (!isfinite(value)) continue;
17
+ // 向下取整:剩 19.6% 时显示 20% 却不变色,会让人以为阈值没生效。
18
+ remaining = (NSInteger)floor(fmax(0, fmin(100, value)));
19
+ } else {
20
+ continue;
21
+ }
22
+ if (lowest < 0 || remaining < lowest) lowest = remaining;
23
+ }
24
+ return lowest;
25
+ }
26
+
27
+ CCPetsMenuBarLevel CCPetsMenuBarLevelForRemaining(NSInteger remaining) {
28
+ if (remaining < 0) return CCPetsMenuBarLevelNormal;
29
+ if (remaining <= CCPetsMenuBarCriticalPercent) return CCPetsMenuBarLevelCritical;
30
+ if (remaining <= CCPetsMenuBarWarningPercent) return CCPetsMenuBarLevelWarning;
31
+ return CCPetsMenuBarLevelNormal;
32
+ }
33
+
34
+ NSDictionary *CCPetsMenuBarTitleParts(NSArray<NSDictionary *> *quotas, NSUInteger approvals, BOOL showPercent) {
35
+ NSInteger remaining = CCPetsMenuBarLowestFiveHourRemaining(quotas);
36
+ CCPetsMenuBarLevel level = CCPetsMenuBarLevelForRemaining(remaining);
37
+ NSMutableDictionary *parts = [NSMutableDictionary dictionaryWithObject:@(level) forKey:@"level"];
38
+ if (remaining >= 0 && showPercent) {
39
+ parts[@"percent"] = [NSString stringWithFormat:@"%ld%%", (long)remaining];
40
+ }
41
+ if (approvals > 0) parts[@"approvals"] = [NSString stringWithFormat:@"%lu", (unsigned long)approvals];
42
+ return parts;
43
+ }
44
+
45
+ NSArray<NSDictionary *> *CCPetsMenuBarOrderedQuotas(NSArray<NSDictionary *> *quotas) {
46
+ NSMutableArray<NSDictionary *> *subscription = [NSMutableArray array];
47
+ NSMutableArray<NSDictionary *> *api = [NSMutableArray array];
48
+ for (NSDictionary *quota in quotas) {
49
+ if (![quota isKindOfClass:NSDictionary.class]) continue;
50
+ [([quota[@"apiMode"] boolValue] ? api : subscription) addObject:quota];
51
+ }
52
+ return [subscription arrayByAddingObjectsFromArray:api];
53
+ }
54
+
55
+ CCPetsMenuBarIconTone CCPetsMenuBarIconToneForState(NSString *state) {
56
+ if (![state isKindOfClass:NSString.class] || state.length == 0 || [state isEqualToString:@"idle"]) {
57
+ return CCPetsMenuBarIconToneNone;
58
+ }
59
+ if ([state isEqualToString:@"completed"] || [state isEqualToString:@"tool_completed"]) {
60
+ return CCPetsMenuBarIconToneCompleted;
61
+ }
62
+ if ([state isEqualToString:@"failed"] || [state isEqualToString:@"tool_failed"]) {
63
+ return CCPetsMenuBarIconToneFailed;
64
+ }
65
+ if ([state isEqualToString:@"approval"] || [state isEqualToString:@"notification"]) {
66
+ return CCPetsMenuBarIconToneAttention;
67
+ }
68
+ return CCPetsMenuBarIconToneWorking;
69
+ }
70
+
71
+ NSString *CCPetsMenuBarApprovalSessionID(NSArray<NSDictionary *> *sessions) {
72
+ for (NSDictionary *session in sessions) {
73
+ if (![session isKindOfClass:NSDictionary.class] || ![session[@"state"] isEqual:@"approval"]) continue;
74
+ NSString *sessionID = [session[@"id"] isKindOfClass:NSString.class] ? session[@"id"] : nil;
75
+ NSString *terminal = [session[@"terminal"] isKindOfClass:NSString.class] ? session[@"terminal"] : nil;
76
+ if (sessionID.length > 0 && terminal.length > 0) return sessionID;
77
+ }
78
+ return nil;
79
+ }
80
+
81
+ NSNumber *CCPetsMenuBarTodayTokens(NSArray<NSDictionary *> *quotas) {
82
+ BOOL found = NO;
83
+ unsigned long long total = 0;
84
+ NSArray<NSString *> *tokenSources = @[@"tokenUsage", @"appTokenUsage"];
85
+ for (NSDictionary *quota in quotas) {
86
+ if (![quota isKindOfClass:NSDictionary.class]) continue;
87
+ NSDictionary *usage = [quota[@"usage"] isKindOfClass:NSDictionary.class] ? quota[@"usage"] : nil;
88
+ for (NSString *source in tokenSources) {
89
+ NSDictionary *tokens = [usage[source] isKindOfClass:NSDictionary.class] ? usage[source] : nil;
90
+ NSDictionary *today = [tokens[@"today"] isKindOfClass:NSDictionary.class] ? tokens[@"today"] : nil;
91
+ NSNumber *value = [today[@"total_tokens"] isKindOfClass:NSNumber.class] ? today[@"total_tokens"] : nil;
92
+ if (!value || !isfinite(value.doubleValue) || value.doubleValue < 0) continue;
93
+ found = YES;
94
+ total += value.unsignedLongLongValue;
95
+ }
96
+ }
97
+ return found ? @(total) : nil;
98
+ }
@@ -12,6 +12,8 @@
12
12
  - (void)updateSystemMetric:(NSString *)key enabled:(BOOL)enabled;
13
13
  - (void)updateUsageDisplayMode:(NSString *)mode forKey:(NSString *)key;
14
14
  - (void)updateUsageDisplayMode:(NSString *)mode forProfileID:(NSString *)profileID;
15
+ - (NSArray<NSString *> *)quotaCardOrderForSettings;
16
+ - (void)updateQuotaCardOrder:(NSArray<NSString *> *)order;
15
17
  - (void)updateImportCodexPets:(BOOL)enabled;
16
18
  - (void)updatePanelTheme:(NSString *)theme;
17
19
  - (void)updateGlassDimLevel:(NSNumber *)level;
@@ -23,6 +25,8 @@
23
25
  - (void)updateNotification:(NSString *)key enabled:(BOOL)enabled
24
26
  completion:(void (^)(BOOL enabled))completion;
25
27
  - (void)updateBridgeBadgeEnabled:(BOOL)enabled;
28
+ - (void)updateDisplayMode:(NSString *)mode;
29
+ - (void)updateMenuBarShowsPercent:(BOOL)enabled;
26
30
  - (void)editPhrasesFile:(id)sender;
27
31
  // 按当前台词来源抽一句闲话,不说出来、不占碎碎念的预算和冷却。
28
32
  - (NSString *)sampleSpeechLine;
@@ -36,6 +40,7 @@
36
40
  - (BOOL)deletePetWithID:(NSString *)petID;
37
41
  - (void)addClaudeProfile:(id)sender;
38
42
  - (void)addCodexProfile:(id)sender;
43
+ - (void)addAntigravityProfile:(id)sender;
39
44
  - (void)repairAgentProfile:(NSMenuItem *)sender;
40
45
  - (void)renameAgentProfile:(NSMenuItem *)sender;
41
46
  - (void)relocateAgentProfile:(NSMenuItem *)sender;
@@ -59,6 +64,7 @@
59
64
  @interface CCPetsAlertsPage : CCPetsSettingsPageBase
60
65
  @end
61
66
 
62
- // 通用:语言、主窗口外观(跟随系统 / 浅色 / 深色)、浮层外观(主题、玻璃压暗)、悬停面板显示什么、数据文件夹。
67
+ // 通用:语言、主窗口外观(跟随系统 / 浅色 / 深色)、显示位置(桌宠 / 菜单栏)、浮层外观(主题、玻璃压暗)、
68
+ // 悬停面板显示什么、数据文件夹。
63
69
  @interface CCPetsGeneralPage : CCPetsSettingsPageBase
64
70
  @end
@@ -14,8 +14,10 @@
14
14
  #import "CCPetsPhrases.h"
15
15
  #import "CCPetsPreferences.h"
16
16
  #import "CCPetsProfiles.h"
17
+ #import "CCPetsProviderRegistry.h"
17
18
  #import "CCPetsUsageMode.h"
18
19
  #import "CCPetsUIStyle.h"
20
+ #import "CCPetsWorkbench.h"
19
21
  #import <QuartzCore/QuartzCore.h>
20
22
  #include <fcntl.h>
21
23
  #include <unistd.h>
@@ -341,17 +343,21 @@ static void RevealFolder(NSString *path) {
341
343
  __weak typeof(self) weakSelf = self;
342
344
  [self.form setAccessoryViews:@[
343
345
  [self smallButtonWithTitle:L(@"Add Claude Home…") action:^{ [weakSelf.actions addClaudeProfile:nil]; }],
344
- [self smallButtonWithTitle:L(@"Add Codex Home…") action:^{ [weakSelf.actions addCodexProfile:nil]; }]
346
+ [self smallButtonWithTitle:L(@"Add Codex Home…") action:^{ [weakSelf.actions addCodexProfile:nil]; }],
347
+ [self smallButtonWithTitle:L(@"Add Antigravity Home…") action:^{ [weakSelf.actions addAntigravityProfile:nil]; }]
345
348
  ]];
346
349
  self.entries = [self currentEntries];
347
350
  if (self.entries.count == 0) {
348
351
  [self.form addGroupWithTitle:nil rows:@[
349
352
  [CCPetsFormBuilder rowWithTitle:L(@"No Agent accounts detected")
350
- subtitle:L(@"Use the buttons above to add an existing Claude or Codex Home.") controls:@[]]
353
+ subtitle:L(@"Use the buttons above to add an existing Agent Home.") controls:@[]]
351
354
  ] footer:nil];
352
355
  return;
353
356
  }
354
- for (NSString *provider in @[CCPetsProfileProviderClaude, CCPetsProfileProviderCodex]) {
357
+ NSArray<NSString *> *providers = @[CCPetsProfileProviderClaude, CCPetsProfileProviderCodex, CCPetsProfileProviderAntigravity];
358
+ NSDictionary<NSString *, NSString *> *titles = @{CCPetsProfileProviderClaude: @"Claude", CCPetsProfileProviderCodex: @"Codex",
359
+ CCPetsProfileProviderAntigravity: @"Antigravity CLI"};
360
+ for (NSString *provider in providers) {
355
361
  NSMutableArray<NSView *> *rows = [NSMutableArray array];
356
362
  for (NSDictionary *entry in self.entries) {
357
363
  NSDictionary *profile = entry[@"profile"];
@@ -366,8 +372,7 @@ static void RevealFolder(NSString *path) {
366
372
  row.toolTip = profile[@"home"];
367
373
  [rows addObject:row];
368
374
  }
369
- if (rows.count > 0) [self.form addGroupWithTitle:
370
- [provider isEqualToString:CCPetsProfileProviderClaude] ? @"Claude" : @"Codex" rows:rows footer:nil];
375
+ if (rows.count > 0) [self.form addGroupWithTitle:titles[provider] rows:rows footer:nil];
371
376
  }
372
377
  }
373
378
 
@@ -771,6 +776,151 @@ static const NSUInteger PetPickerColumns = 4;
771
776
 
772
777
  #pragma mark - 通用
773
778
 
779
+ static NSPasteboardType const QuotaCardDragType = @"com.universewang.cc-pets.quota-card";
780
+ static const CGFloat QuotaCardGripWidth = 16;
781
+ static const CGFloat QuotaCardGripHitWidth = 20;
782
+
783
+ @interface CCPetsQuotaOrderTable : NSTableView <NSTableViewDataSource, NSTableViewDelegate>
784
+ @property(nonatomic, copy) NSArray<NSString *> *providerKeys;
785
+ @property(nonatomic, copy) void (^orderChanged)(NSArray<NSString *> *);
786
+ @property(nonatomic, copy) NSString *draggedProviderKey;
787
+ @end
788
+
789
+ @implementation CCPetsQuotaOrderTable
790
+
791
+ - (instancetype)initWithFrame:(NSRect)frame {
792
+ if (!(self = [super initWithFrame:frame])) return nil;
793
+ self.headerView = nil;
794
+ self.style = NSTableViewStylePlain;
795
+ self.backgroundColor = NSColor.clearColor;
796
+ self.selectionHighlightStyle = NSTableViewSelectionHighlightStyleNone;
797
+ self.rowHeight = 26;
798
+ self.intercellSpacing = NSZeroSize;
799
+ self.columnAutoresizingStyle = NSTableViewUniformColumnAutoresizingStyle;
800
+ NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"provider"];
801
+ column.width = frame.size.width;
802
+ [self addTableColumn:column];
803
+ self.dataSource = self;
804
+ self.delegate = self;
805
+ [self registerForDraggedTypes:@[QuotaCardDragType]];
806
+ [self setDraggingSourceOperationMask:NSDragOperationMove forLocal:YES];
807
+ [self setDraggingSourceOperationMask:NSDragOperationNone forLocal:NO];
808
+ [self setAccessibilityLabel:L(@"Quota Card Order")];
809
+ return self;
810
+ }
811
+
812
+ - (void)setProviderKeys:(NSArray<NSString *> *)providerKeys {
813
+ if ([_providerKeys isEqualToArray:providerKeys]) return;
814
+ _providerKeys = [providerKeys copy];
815
+ [self reloadData];
816
+ }
817
+
818
+ - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
819
+ return (NSInteger)self.providerKeys.count;
820
+ }
821
+
822
+ - (NSView *)hitTest:(NSPoint)point {
823
+ // The icon and label are passive. The table owns the mouse-down that starts a drag.
824
+ return [super hitTest:point] ? self : nil;
825
+ }
826
+
827
+ - (NSRect)gripRectForRow:(NSInteger)row {
828
+ NSRect cell = [self frameOfCellAtColumn:0 row:row];
829
+ return NSMakeRect(NSMaxX(cell) - QuotaCardGripHitWidth, NSMinY(cell), QuotaCardGripHitWidth, NSHeight(cell));
830
+ }
831
+
832
+ - (void)resetCursorRects {
833
+ [super resetCursorRects];
834
+ if (self.providerKeys.count < 2) return;
835
+ for (NSInteger row = 0; row < (NSInteger)self.providerKeys.count; row++) {
836
+ [self addCursorRect:[self gripRectForRow:row] cursor:NSCursor.openHandCursor];
837
+ }
838
+ }
839
+
840
+ - (void)mouseDown:(NSEvent *)event {
841
+ self.draggedProviderKey = nil;
842
+ NSPoint point = [self convertPoint:event.locationInWindow fromView:nil];
843
+ NSInteger row = [self rowAtPoint:point];
844
+ if (row >= 0 && row < (NSInteger)self.providerKeys.count && NSPointInRect(point, [self gripRectForRow:row])) {
845
+ self.draggedProviderKey = self.providerKeys[(NSUInteger)row];
846
+ }
847
+ [super mouseDown:event];
848
+ }
849
+
850
+ - (void)mouseUp:(NSEvent *)event {
851
+ self.draggedProviderKey = nil;
852
+ [super mouseUp:event];
853
+ }
854
+
855
+ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)column row:(NSInteger)row {
856
+ NSString *key = self.providerKeys[(NSUInteger)row];
857
+ NSString *title = key;
858
+ for (CCPetsProviderDescriptor *provider in CCPetsProviderDescriptors()) {
859
+ if ([provider.key isEqualToString:key]) { title = provider.name; break; }
860
+ }
861
+ NSImage *icon = [NSImage imageWithSystemSymbolName:@"line.3.horizontal" accessibilityDescription:nil];
862
+ NSImageView *handle = [NSImageView imageViewWithImage:icon];
863
+ handle.contentTintColor = CCPetsSecondaryInkColor();
864
+ NSTextField *name = CCPetsLabel(title, 12, NSFontWeightRegular, CCPetsInkColor());
865
+ NSStackView *content = [NSStackView stackViewWithViews:@[name, handle]];
866
+ content.alignment = NSLayoutAttributeCenterY;
867
+ content.spacing = 8;
868
+ content.translatesAutoresizingMaskIntoConstraints = NO;
869
+ NSView *cell = [NSView new];
870
+ [cell addSubview:content];
871
+ [NSLayoutConstraint activateConstraints:@[
872
+ [handle.widthAnchor constraintEqualToConstant:QuotaCardGripWidth],
873
+ [content.trailingAnchor constraintEqualToAnchor:cell.trailingAnchor],
874
+ [content.leadingAnchor constraintGreaterThanOrEqualToAnchor:cell.leadingAnchor constant:4],
875
+ [content.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor]
876
+ ]];
877
+ return cell;
878
+ }
879
+
880
+ - (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row {
881
+ if (self.providerKeys.count < 2 || row < 0 || row >= (NSInteger)self.providerKeys.count) return nil;
882
+ NSString *key = self.providerKeys[(NSUInteger)row];
883
+ if (![key isEqualToString:self.draggedProviderKey]) return nil;
884
+ NSPasteboardItem *item = [NSPasteboardItem new];
885
+ [item setString:key forType:QuotaCardDragType];
886
+ return item;
887
+ }
888
+
889
+ - (void)tableView:(NSTableView *)tableView draggingSession:(NSDraggingSession *)session
890
+ endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation {
891
+ self.draggedProviderKey = nil;
892
+ }
893
+
894
+ - (NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info
895
+ proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation {
896
+ if (info.draggingSource != self || row < 0 || row > (NSInteger)self.providerKeys.count) return NSDragOperationNone;
897
+ if (operation == NSTableViewDropOn && row < (NSInteger)self.providerKeys.count) {
898
+ NSPoint location = [self convertPoint:info.draggingLocation fromView:nil];
899
+ if (location.y > NSMidY([self rectOfRow:row])) row++;
900
+ }
901
+ [self setDropRow:row dropOperation:NSTableViewDropAbove];
902
+ return NSDragOperationMove;
903
+ }
904
+
905
+ - (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row
906
+ dropOperation:(NSTableViewDropOperation)operation {
907
+ if (info.draggingSource != self || operation != NSTableViewDropAbove || row < 0 ||
908
+ row > (NSInteger)self.providerKeys.count) return NO;
909
+ NSString *key = [info.draggingPasteboard stringForType:QuotaCardDragType];
910
+ NSUInteger source = key ? [self.providerKeys indexOfObject:key] : NSNotFound;
911
+ if (source == NSNotFound) return NO;
912
+ NSUInteger destination = (NSUInteger)row;
913
+ if (destination > source) destination--;
914
+ if (destination == source) return YES;
915
+ NSMutableArray<NSString *> *order = [self.providerKeys mutableCopy];
916
+ [order removeObjectAtIndex:source];
917
+ [order insertObject:key atIndex:destination];
918
+ if (self.orderChanged) self.orderChanged(order);
919
+ return YES;
920
+ }
921
+
922
+ @end
923
+
774
924
  @interface CCPetsGeneralPage ()
775
925
  @property(nonatomic) CCPetsGlassView *glassPreview;
776
926
  @property(nonatomic, copy) NSArray<NSDictionary *> *usageProfiles;
@@ -789,6 +939,8 @@ static const NSUInteger PetPickerColumns = 4;
789
939
  [super loadView];
790
940
  [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(preferencesDidChange:)
791
941
  name:CCPetsProfilesDidChangeNotification object:nil];
942
+ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(preferencesDidChange:)
943
+ name:CCPetsWorkbenchQuotasDidChangeNotification object:nil];
792
944
  }
793
945
 
794
946
  - (void)viewWillAppear {
@@ -1095,9 +1247,33 @@ static NSString *TerminalJumpShortState(NSDictionary *item, BOOL vscode) {
1095
1247
  NSArray *registered = CCPetsProfilesForProvider(provider);
1096
1248
  [profiles addObjectsFromArray:registered.count > 0 ? registered : @[@{@"provider": provider}]];
1097
1249
  }
1250
+ [profiles addObjectsFromArray:CCPetsProfilesForProvider(CCPetsProfileProviderAntigravity)];
1098
1251
  return profiles.copy;
1099
1252
  }
1100
1253
 
1254
+ - (NSView *)quotaCardOrderRow {
1255
+ __weak typeof(self) weakSelf = self;
1256
+ CCPetsQuotaOrderTable *table = [[CCPetsQuotaOrderTable alloc] initWithFrame:NSMakeRect(0, 0, 150, 26)];
1257
+ table.autoresizingMask = NSViewWidthSizable;
1258
+ table.orderChanged = ^(NSArray<NSString *> *order) { [weakSelf.actions updateQuotaCardOrder:order]; };
1259
+
1260
+ NSScrollView *list = [NSScrollView new];
1261
+ list.drawsBackground = NO;
1262
+ list.hasVerticalScroller = NO;
1263
+ list.documentView = table;
1264
+ [list.widthAnchor constraintEqualToConstant:150].active = YES;
1265
+ NSLayoutConstraint *height = [list.heightAnchor constraintEqualToConstant:table.rowHeight];
1266
+ height.active = YES;
1267
+
1268
+ [self.reloaders addObject:^{
1269
+ table.providerKeys = [weakSelf.actions quotaCardOrderForSettings] ?: @[];
1270
+ height.constant = MAX(1, table.providerKeys.count) * table.rowHeight;
1271
+ [table setFrameSize:NSMakeSize(table.frame.size.width, height.constant)];
1272
+ }];
1273
+ return [CCPetsFormBuilder rowWithTitle:L(@"Quota Card Order")
1274
+ subtitle:L(@"Drag to reorder cards in the hover panel") controls:@[list]];
1275
+ }
1276
+
1101
1277
  - (void)reloadValues {
1102
1278
  if (![self.usageProfiles isEqualToArray:[self currentUsageProfiles]]) {
1103
1279
  // 新增、移除、改名或重新定位账号后重建行,同时释放旧控件的闭包。
@@ -1318,9 +1494,25 @@ static NSString *TerminalJumpShortState(NSDictionary *item, BOOL vscode) {
1318
1494
  subtitle:L(@"Only this window; the pet's panels follow Panel Appearance above") controls:@[appearance]],
1319
1495
  ] footer:nil];
1320
1496
 
1497
+ // 显示位置:桌宠、菜单栏图标或两者都要。仅菜单栏时状态卡、气泡和悬停面板都不出现。
1498
+ NSSegmentedControl *displayMode = [self segmentedWithOptions:@[
1499
+ @[L(@"Desktop Pet"), CCPetsDisplayModePet], @[L(@"Pet + Menu Bar"), CCPetsDisplayModeBoth],
1500
+ @[L(@"Menu Bar Only"), CCPetsDisplayModeMenuBar]]
1501
+ selected:^id { return CCPetsDisplayMode(); }
1502
+ action:^(NSString *value) { [weakSelf.actions updateDisplayMode:value]; }];
1503
+ [self.form addGroupWithTitle:L(@"Show In") rows:@[
1504
+ [CCPetsFormBuilder rowWithTitle:L(@"Display")
1505
+ subtitle:L(@"Menu bar only hides the pet, its status card, speech and hover panel; notifications still work")
1506
+ controls:@[displayMode]],
1507
+ [self switchRowWithTitle:L(@"Quota in Menu Bar")
1508
+ subtitle:L(@"Lowest 5-hour quota left; orange at 20% or below, red at 10%")
1509
+ key:CCPetsMenuBarShowsPercentKey
1510
+ apply:^(id<CCPetsSettingsActions> actions, BOOL enabled) { [actions updateMenuBarShowsPercent:enabled]; }],
1511
+ ] footer:nil];
1512
+
1321
1513
  [self.form addGroupWithTitle:L(@"Launch Protection") rows:@[
1322
1514
  [self switchRowWithTitle:@"Shadowrocket"
1323
- subtitle:L(@"Block Claude / Codex when Shadowrocket is disconnected or the exit is in an unsupported region")
1515
+ subtitle:L(@"Block Claude / Codex when Shadowrocket is disconnected or the exit is in an unsupported region. Antigravity only checks the connection.")
1324
1516
  key:CCPetsShadowrocketLaunchCheckKey
1325
1517
  apply:^(id<CCPetsSettingsActions> actions, BOOL enabled) {
1326
1518
  CCPetsPrefSetBool(CCPetsShadowrocketLaunchCheckKey, enabled);
@@ -1332,8 +1524,12 @@ static NSString *TerminalJumpShortState(NSDictionary *item, BOOL vscode) {
1332
1524
  NSMutableArray<NSView *> *panelRows = [NSMutableArray array];
1333
1525
  self.usageProfiles = [self currentUsageProfiles];
1334
1526
  for (NSDictionary *profile in self.usageProfiles) {
1335
- NSString *provider = [profile[@"provider"] isEqualToString:@"codex"] ? @"Codex" : @"Claude";
1527
+ NSString *provider = CCPetsProviderForProfileProvider(profile[@"provider"]).name ?: profile[@"provider"];
1336
1528
  NSString *name = profile[@"displayName"] ?: provider;
1529
+ if ([profile[@"provider"] isEqual:CCPetsProfileProviderAntigravity]) {
1530
+ name = CCPetsProfileIsOfficialDefault(profile) && ![profile[@"customName"] boolValue]
1531
+ ? @"Antigravity CLI" : [NSString stringWithFormat:@"Antigravity CLI · %@", name];
1532
+ }
1337
1533
  CCPetsPillButton *pill = [CCPetsPillButton new];
1338
1534
  [pill setAccessibilityLabel:[NSString stringWithFormat:L(@"%@ usage display"), name]];
1339
1535
  NSView *row = [CCPetsFormBuilder rowWithTitle:name subtitle:@" " controls:@[pill]];
@@ -1359,6 +1555,7 @@ static NSString *TerminalJumpShortState(NSDictionary *item, BOOL vscode) {
1359
1555
  }];
1360
1556
  [panelRows addObject:row];
1361
1557
  }
1558
+ [panelRows addObject:[self quotaCardOrderRow]];
1362
1559
  // 三项可以任意组合:用"可多选"的分段控件,一行放得下,也和上面的分段控件一个样子。
1363
1560
  NSArray<NSString *> *metricKeys = @[SystemCPUEnabledKey, SystemTemperatureEnabledKey, SystemMemoryEnabledKey];
1364
1561
  NSSegmentedControl *metrics = [NSSegmentedControl segmentedControlWithLabels:@[@"CPU", L(@"Temperature"), L(@"Memory")]
@@ -1376,7 +1573,7 @@ static NSString *TerminalJumpShortState(NSDictionary *item, BOOL vscode) {
1376
1573
  [metrics setSelected:CCPetsPrefBool(metricKeys[index]) forSegment:(NSInteger)index];
1377
1574
  }
1378
1575
  }];
1379
- [panelRows addObject:[CCPetsFormBuilder rowWithTitle:L(@"System Status") controls:@[metrics]]];
1576
+ [panelRows insertObject:[CCPetsFormBuilder rowWithTitle:L(@"System Status") controls:@[metrics]] atIndex:0];
1380
1577
  [self.form addGroupWithTitle:nil rows:panelRows footer:nil];
1381
1578
 
1382
1579
  // 终端跳转:一张卡片,行在 refreshIDEIntegration 拿到检测结果后填入。
@@ -0,0 +1,28 @@
1
+ #import <Cocoa/Cocoa.h>
2
+ #import "CCPetsMainWindow.h"
3
+ #import "CCPetsWorkbench.h"
4
+
5
+ // 菜单栏图标:左键弹出玻璃面板(宠物状态、会话、各账号额度、今日用量,见 CCPetsMenuBarPanel),
6
+ // 右键是和桌宠同一份右键菜单。
7
+ //
8
+ // 数据全部来自现有快照(workbenchSessions / workbenchQuotas / petCardSnapshot),这里不采集、
9
+ // 不起定时器:标题和开着的面板只在宠物名片、额度或设置变了的时候重算。
10
+ // 和主窗口各页一样只认协议,不 import AppDelegate 的私有头。
11
+ @interface CCPetsStatusItemController : NSObject
12
+ - (instancetype)initWithSource:(id<CCPetsWorkbenchSource, CCPetsPetCardSource>)source;
13
+ @property(nonatomic, weak, readonly) id<CCPetsWorkbenchSource, CCPetsPetCardSource> source;
14
+ // 会话状态对应的颜色,和状态卡图标同一套(AppDelegate 的 statusColorForState:)。
15
+ @property(nonatomic, copy) NSColor *(^stateColorProvider)(NSString *state);
16
+ // 右键菜单。由桌宠那边现建;菜单收起后调 contextMenuFinished 收拾预览浮窗和说明。
17
+ @property(nonatomic, copy) NSMenu *(^contextMenuProvider)(void);
18
+ @property(nonatomic, copy) void (^contextMenuFinished)(void);
19
+ // 「显示桌宠」勾选项:读当前状态、切换。
20
+ @property(nonatomic, copy) BOOL (^petVisibleProvider)(void);
21
+ @property(nonatomic, copy) void (^togglePetVisible)(void);
22
+ // 有可安装的新版本时返回版本号;「仅菜单栏」下没有更新气泡和角标,入口只剩面板底部。
23
+ @property(nonatomic, copy) NSString *(^pendingUpdateVersionProvider)(void);
24
+ @property(nonatomic, copy) void (^showPendingUpdate)(void);
25
+ - (void)refresh;
26
+ // 从菜单栏移除并停止监听。之后这个对象不再可用。
27
+ - (void)invalidate;
28
+ @end
@@ -0,0 +1,147 @@
1
+ #import "CCPetsStatusItem.h"
2
+ #import "CCPetsMenuBarSummary.h"
3
+ #import "CCPetsPreferences.h"
4
+ #import "CCPetsL10n.h"
5
+ #import "CCPetsMenuBarPanel.h"
6
+ #import "CCPetsMenuBarIcon.h"
7
+
8
+ static NSColor *LevelColor(CCPetsMenuBarLevel level) {
9
+ switch (level) {
10
+ case CCPetsMenuBarLevelCritical: return NSColor.systemRedColor;
11
+ case CCPetsMenuBarLevelWarning: return NSColor.systemOrangeColor;
12
+ default: return nil;
13
+ }
14
+ }
15
+
16
+ @interface CCPetsStatusItemController ()
17
+ @property(nonatomic, weak, readwrite) id<CCPetsWorkbenchSource, CCPetsPetCardSource> source;
18
+ @property(nonatomic) NSStatusItem *item;
19
+ @property(nonatomic) CCPetsMenuBarPanel *panel;
20
+ // 各色调的菜单栏图标(见 CCPetsMenuBarIcon),每种只生成一次。
21
+ @property(nonatomic) NSMutableDictionary<NSNumber *, NSImage *> *iconImages;
22
+ @end
23
+
24
+ @implementation CCPetsStatusItemController
25
+
26
+ - (instancetype)initWithSource:(id<CCPetsWorkbenchSource, CCPetsPetCardSource>)source {
27
+ if (!(self = [super init])) return nil;
28
+ _source = source;
29
+ _panel = [[CCPetsMenuBarPanel alloc] initWithOwner:self];
30
+ _item = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
31
+ _iconImages = [NSMutableDictionary dictionary];
32
+ _item.button.image = [self imageForTone:CCPetsMenuBarIconToneNone];
33
+ _item.button.toolTip = @"CC Pets";
34
+ _item.button.target = self;
35
+ _item.button.action = @selector(statusItemClicked:);
36
+ // 左右键松开都要回调,才能在 action 里分流两种菜单。和桌宠拖动无关(tests/test.sh 对拖动
37
+ // 实现的回归检查会拦 NSEventMask 常量的写法,所以这里按事件类型组掩码)。
38
+ [_item.button sendActionOn:NSEventMaskFromType(NSEventTypeLeftMouseUp) |
39
+ NSEventMaskFromType(NSEventTypeRightMouseUp)];
40
+ NSNotificationCenter *center = NSNotificationCenter.defaultCenter;
41
+ for (NSNotificationName name in @[CCPetsPetCardDidChangeNotification,
42
+ CCPetsWorkbenchQuotasDidChangeNotification,
43
+ CCPetsPreferencesDidChangeNotification,
44
+ CCPetsLanguageDidChangeNotification]) {
45
+ [center addObserver:self selector:@selector(sourceDidChange:) name:name object:nil];
46
+ }
47
+ [self refresh];
48
+ return self;
49
+ }
50
+
51
+ - (void)dealloc {
52
+ [NSNotificationCenter.defaultCenter removeObserver:self];
53
+ }
54
+
55
+ - (void)invalidate {
56
+ [NSNotificationCenter.defaultCenter removeObserver:self];
57
+ [self.panel dismiss];
58
+ if (self.item) [NSStatusBar.systemStatusBar removeStatusItem:self.item];
59
+ self.item = nil;
60
+ }
61
+
62
+ - (void)sourceDidChange:(NSNotification *)notification {
63
+ [self refresh];
64
+ }
65
+
66
+ - (void)refresh {
67
+ NSStatusBarButton *button = self.item.button;
68
+ if (!button) return;
69
+ NSDictionary *snapshot = [self.source petCardSnapshot];
70
+ NSUInteger approvals = [snapshot[@"approvals"] unsignedIntegerValue];
71
+ NSDictionary *parts = CCPetsMenuBarTitleParts([self.source workbenchQuotas], approvals,
72
+ CCPetsPrefBool(CCPetsMenuBarShowsPercentKey));
73
+ NSFont *font = [NSFont monospacedDigitSystemFontOfSize:NSFont.systemFontSize weight:NSFontWeightMedium];
74
+ NSMutableAttributedString *title = [NSMutableAttributedString new];
75
+ if (parts[@"percent"]) {
76
+ NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
77
+ NSColor *color = LevelColor([parts[@"level"] integerValue]);
78
+ if (color) attributes[NSForegroundColorAttributeName] = color;
79
+ [title appendAttributedString:[[NSAttributedString alloc]
80
+ initWithString:[@" " stringByAppendingString:parts[@"percent"]] attributes:attributes]];
81
+ }
82
+ if (parts[@"approvals"]) {
83
+ // U+FE0E 让 ⚠ 按文字字形绘制,颜色才跟得上前景色;否则会是一枚彩色 emoji。
84
+ [title appendAttributedString:[[NSAttributedString alloc]
85
+ initWithString:[NSString stringWithFormat:@" ⚠︎%@", parts[@"approvals"]]
86
+ attributes:@{NSFontAttributeName: font, NSForegroundColorAttributeName: NSColor.systemRedColor}]];
87
+ }
88
+ button.attributedTitle = title;
89
+ button.imagePosition = title.length > 0 ? NSImageLeft : NSImageOnly;
90
+ // 图标跟着状态卡走:同一条快照、同一套归类(工作中蓝、审批橙、完成绿、失败红),
91
+ // 状态卡回落待机时换回待机图。
92
+ NSString *state = [snapshot[@"state"] isKindOfClass:NSString.class] ? snapshot[@"state"] : nil;
93
+ CCPetsMenuBarIconTone tone = CCPetsMenuBarIconToneForState(state);
94
+ BOOL tinted = tone != CCPetsMenuBarIconToneNone;
95
+ button.image = [self imageForTone:tone];
96
+ NSMutableArray<NSString *> *description = [NSMutableArray arrayWithObject:@"CC Pets"];
97
+ if (tinted && [snapshot[@"status"] isKindOfClass:NSString.class]) [description addObject:snapshot[@"status"]];
98
+ if (parts[@"percent"]) [description addObject:parts[@"percent"]];
99
+ if (parts[@"approvals"]) {
100
+ [description addObject:[NSString stringWithFormat:L(@"%@ awaiting approval"), parts[@"approvals"]]];
101
+ }
102
+ [button setAccessibilityLabel:[description componentsJoinedByString:@", "]];
103
+ // 等审批时左键会直接跳转,提示里说清楚,免得用户以为面板打不开。
104
+ button.toolTip = approvals > 0 ? L(@"Click to jump to the session awaiting approval (⌥-click for the panel)") : @"CC Pets";
105
+ [self.panel reload];
106
+ }
107
+
108
+ - (NSImage *)imageForTone:(CCPetsMenuBarIconTone)tone {
109
+ NSImage *cached = self.iconImages[@(tone)];
110
+ if (cached) return cached;
111
+ NSImage *image = CCPetsMenuBarIconImage(tone);
112
+ self.iconImages[@(tone)] = image;
113
+ return image;
114
+ }
115
+
116
+ // 左右键共用一个 action。左键开关玻璃面板(有会话等审批时直接跳到那个终端);
117
+ // 右键临时挂上菜单交给按钮弹出,弹完摘掉——
118
+ // 一直挂着 item.menu 的话左键也会直接弹它。
119
+ - (void)statusItemClicked:(NSStatusBarButton *)sender {
120
+ NSEvent *event = NSApp.currentEvent;
121
+ BOOL secondary = event.type == NSEventTypeRightMouseUp ||
122
+ (event.modifierFlags & NSEventModifierFlagControl) != 0;
123
+ if (!secondary) {
124
+ if (self.panel.isShown) {
125
+ [self.panel dismiss];
126
+ return;
127
+ }
128
+ // 有会话在等审批:直接跳到那个终端,这是此刻唯一需要用户动手的事。按住 ⌥ 仍然打开面板。
129
+ BOOL option = (event.modifierFlags & NSEventModifierFlagOption) != 0;
130
+ NSString *approval = option ? nil : CCPetsMenuBarApprovalSessionID([self.source workbenchSessions]);
131
+ if (approval) {
132
+ [self.source focusWorkbenchSessionWithID:approval];
133
+ return;
134
+ }
135
+ [self.panel showBelowButton:sender];
136
+ return;
137
+ }
138
+ [self.panel dismiss];
139
+ NSMenu *menu = self.contextMenuProvider ? self.contextMenuProvider() : nil;
140
+ if (!menu) return;
141
+ self.item.menu = menu;
142
+ [sender performClick:nil];
143
+ self.item.menu = nil;
144
+ if (self.contextMenuFinished) self.contextMenuFinished();
145
+ }
146
+
147
+ @end
@@ -40,12 +40,14 @@ NSColor *CCPetsSelectionColor(void) { CACHED_COLOR(Dynamic(0x0e9db3, 0.13, 0x4fd
40
40
  NSColor *CCPetsRingTrackColor(void) { CACHED_COLOR(Dynamic(0xe3e7ee, 1, 0x343a42, 1)); }
41
41
 
42
42
  NSColor *CCPetsProviderColor(NSString *provider) {
43
- static NSColor *claude, *codex;
43
+ static NSColor *claude, *codex, *antigravity;
44
44
  static dispatch_once_t once;
45
45
  dispatch_once(&once, ^{
46
46
  claude = Dynamic(0xc8643b, 1, 0xe07a50, 1);
47
47
  codex = Dynamic(0x3d4655, 1, 0xb9c2cf, 1);
48
+ antigravity = Dynamic(0x286fcb, 1, 0x71adff, 1);
48
49
  });
50
+ if ([provider.lowercaseString isEqualToString:@"antigravity"]) return antigravity;
49
51
  return [provider.lowercaseString isEqualToString:@"claude"] ? claude : codex;
50
52
  }
51
53
 
@@ -1,6 +1,6 @@
1
1
  #import <Cocoa/Cocoa.h>
2
2
 
3
- // 主窗口的「用量」页:本机 Claude Code / Codex 的 Token 用量,按模型分色堆叠的每日柱状图 + 模型表。
3
+ // 主窗口的「用量」页:本机 Agent 的 Token 用量,按模型分色堆叠的每日柱状图 + 模型表。
4
4
  //
5
5
  // 数据来自 CCPetsModelUsage(本机会话日志,不联网),由 CCPetsUsageStore 在后台按最长的 90 天算一次,
6
6
  // 切换来源、区间、指标、模型都只在本地截取,不重算。页面显示期间每分钟问一次 loadIfStale,
@@ -11,11 +11,12 @@
11
11
  // 90 天的模型用量,用量页和概览页共用一份。数据层按请求的起点清理缓存,所以统一按最长窗口取,
12
12
  // 两页各取各的窗口会让较早的会话缓存被删了又重读。
13
13
  //
14
- // results:provider(claude / codex)-> CCPetsModelUsage 的返回值;还没算完时为 nil。
14
+ // results:provider -> CCPetsModelUsage 的返回值;还没算完时为 nil。
15
15
  extern NSNotificationName const CCPetsUsageStoreDidChangeNotification;
16
+ extern NSString *const CCPetsUsageProviderAntigravityApp;
16
17
  @interface CCPetsUsageStore : NSObject
17
18
  @property(class, nonatomic, readonly) NSDictionary<NSString *, NSDictionary *> *results;
18
- // profileId → 独立模型用量;providerResults 仍保留按 Provider 汇总,兼容概览页。
19
+ // profileId → 独立模型用量。Antigravity App 只提供 results 中的独立来源。
19
20
  @property(class, nonatomic, readonly) NSDictionary<NSString *, NSDictionary *> *profileResults;
20
21
  @property(class, nonatomic, readonly) BOOL loading;
21
22
  // 没算过、结果超过两分钟、或者跨过了午夜就重算;正在算时不重复发起。算完发 CCPetsUsageStoreDidChangeNotification。