cc-pets 2.5.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.
- package/CC_BRIDGE.md +47 -5
- package/CC_BRIDGE.zh-CN.md +42 -5
- package/CONTRIBUTING.md +1 -1
- package/CONTRIBUTING.zh-CN.md +1 -1
- package/README.md +48 -19
- package/README.zh-CN.md +46 -17
- package/Resources/AgentIcons/antigravity.icns +0 -0
- package/Resources/zh-Hans.lproj/Localizable.strings +64 -15
- package/Sources/CCPets/App/CCPetsAppDelegate+AgentEvents.m +7 -3
- package/Sources/CCPets/App/CCPetsAppDelegate+AgentStatus.m +11 -3
- package/Sources/CCPets/App/CCPetsAppDelegate+Bridge.m +16 -5
- package/Sources/CCPets/App/CCPetsAppDelegate+Private.h +11 -1
- package/Sources/CCPets/App/CCPetsAppDelegate+Profiles.m +21 -11
- package/Sources/CCPets/App/CCPetsAppDelegate+Quota.m +27 -16
- package/Sources/CCPets/App/CCPetsAppDelegate+Settings.m +43 -7
- package/Sources/CCPets/App/CCPetsAppDelegate+Speech.m +2 -1
- package/Sources/CCPets/App/CCPetsAppDelegate+Update.m +3 -3
- package/Sources/CCPets/App/CCPetsAppDelegate+Workbench.m +20 -22
- package/Sources/CCPets/App/CCPetsAppDelegate.m +14 -6
- package/Sources/CCPets/App/CCPetsVersion.h +4 -0
- package/Sources/CCPets/App/CCPetsVersion.m +34 -0
- package/Sources/CCPets/App/main.m +11 -0
- package/Sources/CCPets/Bridge/CCPetsBridge.m +7 -5
- package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.h +4 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeAntigravityApp.m +119 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeCLI.h +3 -1
- package/Sources/CCPets/Bridge/CCPetsBridgeCLI.m +172 -17
- package/Sources/CCPets/Bridge/CCPetsBridgeCore.m +25 -7
- package/Sources/CCPets/Bridge/CCPetsBridgeSetup.m +17 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeStore.h +7 -2
- package/Sources/CCPets/Bridge/CCPetsBridgeStore.m +92 -11
- package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.h +12 -0
- package/Sources/CCPets/Bridge/CCPetsBridgeTerminalTitle.m +105 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.h +17 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityConfig.m +462 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.h +5 -0
- package/Sources/CCPets/Integrations/CCPetsAntigravityEvents.m +180 -0
- package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.h +3 -0
- package/Sources/CCPets/Integrations/CCPetsBridgeTitleRelay.m +463 -0
- package/Sources/CCPets/Integrations/CCPetsIntegrations.h +1 -1
- package/Sources/CCPets/Integrations/CCPetsIntegrations.m +37 -7
- package/Sources/CCPets/Integrations/CCPetsLaunchPreflight.m +15 -5
- package/Sources/CCPets/Integrations/CCPetsProfiles.h +2 -1
- package/Sources/CCPets/Integrations/CCPetsProfiles.m +112 -81
- package/Sources/CCPets/Integrations/CCPetsTerminalFocus.h +5 -1
- package/Sources/CCPets/Integrations/CCPetsTerminalFocus.m +163 -40
- package/Sources/CCPets/Pet/CCPetsPreviews.m +16 -8
- package/Sources/CCPets/Pet/PetView+Menu.m +56 -5
- package/Sources/CCPets/Support/CCPetsDoctor.m +126 -37
- package/Sources/CCPets/Support/CCPetsPaths.h +5 -0
- package/Sources/CCPets/Support/CCPetsPaths.m +15 -0
- package/Sources/CCPets/Support/CCPetsPreferences.h +4 -1
- package/Sources/CCPets/Support/CCPetsPreferences.m +18 -0
- package/Sources/CCPets/UI/CCPetsMenuBarPanel.m +10 -5
- package/Sources/CCPets/UI/CCPetsMenuBarSummary.m +9 -6
- package/Sources/CCPets/UI/CCPetsSettingsPage.h +3 -0
- package/Sources/CCPets/UI/CCPetsSettingsPage.m +189 -8
- package/Sources/CCPets/UI/CCPetsUIStyle.m +3 -1
- package/Sources/CCPets/UI/CCPetsUsagePage.h +4 -3
- package/Sources/CCPets/UI/CCPetsUsagePage.m +69 -43
- package/Sources/CCPets/UI/CCPetsUsageStore.m +11 -1
- package/Sources/CCPets/UI/CCPetsWorkbenchPages.m +1 -1
- package/Sources/CCPets/Usage/CCPetsAntigravityQuota.m +115 -0
- package/Sources/CCPets/Usage/CCPetsNormalizedUsage.h +5 -0
- package/Sources/CCPets/Usage/CCPetsNormalizedUsage.m +43 -0
- package/Sources/CCPets/Usage/CCPetsProviderRegistry+Testing.h +13 -0
- package/Sources/CCPets/Usage/CCPetsProviderRegistry.h +25 -0
- package/Sources/CCPets/Usage/CCPetsProviderRegistry.m +94 -0
- package/Sources/CCPets/Usage/CCPetsQuotaHistory.h +1 -1
- package/Sources/CCPets/Usage/CCPetsQuotaHistory.m +11 -8
- package/Sources/CCPets/Usage/CCPetsUsage+Internal.h +2 -0
- package/Sources/CCPets/Usage/CCPetsUsage+Models.m +206 -14
- package/Sources/CCPets/Usage/CCPetsUsage+TokenTotals.m +4 -4
- package/Sources/CCPets/Usage/CCPetsUsage.h +7 -2
- package/Sources/CCPets/Usage/CCPetsUsageMode.h +2 -0
- package/Sources/CCPets/Usage/CCPetsUsageMode.m +29 -4
- package/Sources/CCPets/Usage/CCPetsUsageMonitor.h +4 -4
- package/Sources/CCPets/Usage/CCPetsUsageMonitor.m +90 -7
- package/Sources/CCPets/Usage/QuotaDashboardView+CompactRow.m +81 -0
- package/Sources/CCPets/Usage/QuotaDashboardView+Primitives.m +5 -8
- package/Sources/CCPets/Usage/QuotaDashboardView+Private.h +26 -4
- package/Sources/CCPets/Usage/QuotaDashboardView+Rendering.m +99 -99
- package/Sources/CCPets/Usage/QuotaDashboardView.h +9 -10
- package/Sources/CCPets/Usage/QuotaDashboardView.m +232 -79
- package/THIRD_PARTY_NOTICES.md +5 -4
- package/THIRD_PARTY_NOTICES.zh-CN.md +6 -5
- package/bin/agy-with-pet +82 -0
- package/bin/cc-pets +1 -1
- package/bin/claude-with-pet +15 -0
- package/bin/codex-with-pet +17 -2
- package/package.json +5 -3
- package/scripts/install-shell-integration.sh +5 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#import "CCPetsPreviews.h"
|
|
2
2
|
#import "CCPetsL10n.h"
|
|
3
3
|
#import "QuotaDashboardView.h"
|
|
4
|
+
#import "CCPetsProviderRegistry.h"
|
|
4
5
|
#import "MenuToggleSwitch.h"
|
|
5
6
|
#import "CCPetsUsage.h"
|
|
6
7
|
#import "PetView.h"
|
|
@@ -13,11 +14,16 @@ int RenderQuotaDashboard(NSString *path) {
|
|
|
13
14
|
QuotaLogicalWidth * QuotaScale, QuotaLogicalHeight * QuotaScale)];
|
|
14
15
|
// 本地视觉验收可用 CC_PETS_PREVIEW_API=1 渲染 API 用量态,不改用户偏好。
|
|
15
16
|
BOOL previewsAPIUsage = [NSProcessInfo.processInfo.environment[@"CC_PETS_PREVIEW_API"] boolValue];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
NSMutableDictionary *showsAPIUsageByProvider = [NSMutableDictionary dictionary];
|
|
18
|
+
NSMutableDictionary *logoByProvider = [NSMutableDictionary dictionary];
|
|
19
|
+
for (CCPetsProviderDescriptor *provider in CCPetsProviderDescriptors()) {
|
|
20
|
+
showsAPIUsageByProvider[provider.name] = @(previewsAPIUsage);
|
|
21
|
+
NSImage *logo = OfficialAppIcon(provider.logoBundleIdentifier, provider.logoResourceName);
|
|
22
|
+
if (logo) logoByProvider[provider.name] = logo;
|
|
23
|
+
}
|
|
24
|
+
view.showsAPIUsageByProvider = showsAPIUsageByProvider;
|
|
25
|
+
view.logoByProvider = logoByProvider;
|
|
26
|
+
NSDictionary *codexUsage = LatestUsage() ?: @{
|
|
21
27
|
@"fiveHour": @{@"used_percent": @34, @"resets_at": @([NSDate.date timeIntervalSince1970] + 7200)},
|
|
22
28
|
@"week": @{@"used_percent": @51, @"resets_at": @([NSDate.date timeIntervalSince1970] + 172800)},
|
|
23
29
|
@"tokenUsage": @{
|
|
@@ -28,7 +34,7 @@ int RenderQuotaDashboard(NSString *path) {
|
|
|
28
34
|
@"source": @"local"
|
|
29
35
|
}
|
|
30
36
|
};
|
|
31
|
-
|
|
37
|
+
NSDictionary *claudeUsage = LatestClaudeUsage() ?: @{
|
|
32
38
|
@"fiveHour": @{@"used_percentage": @23, @"resets_at": @([NSDate.date timeIntervalSince1970] + 3600)},
|
|
33
39
|
@"week": @{@"used_percentage": @41, @"resets_at": @([NSDate.date timeIntervalSince1970] + 86400)},
|
|
34
40
|
@"tokenUsage": @{
|
|
@@ -39,9 +45,10 @@ int RenderQuotaDashboard(NSString *path) {
|
|
|
39
45
|
@"source": @"local"
|
|
40
46
|
}
|
|
41
47
|
};
|
|
48
|
+
view.usageByProvider = @{@"Codex": codexUsage, @"Claude": claudeUsage};
|
|
42
49
|
NSTimeInterval now = NSDate.date.timeIntervalSince1970;
|
|
43
50
|
NSTimeInterval day = 24 * 60 * 60;
|
|
44
|
-
|
|
51
|
+
NSArray<NSDictionary *> *codexHistory = @[
|
|
45
52
|
@{@"timestamp": @(now - 6.5 * day), @"remaining": @88},
|
|
46
53
|
@{@"timestamp": @(now - 5.5 * day), @"remaining": @81},
|
|
47
54
|
@{@"timestamp": @(now - 4.5 * day), @"remaining": @75},
|
|
@@ -50,7 +57,7 @@ int RenderQuotaDashboard(NSString *path) {
|
|
|
50
57
|
@{@"timestamp": @(now - 1.5 * day), @"remaining": @55},
|
|
51
58
|
@{@"timestamp": @(now - 0.5 * day), @"remaining": @49}
|
|
52
59
|
];
|
|
53
|
-
|
|
60
|
+
NSArray<NSDictionary *> *claudeHistory = @[
|
|
54
61
|
@{@"timestamp": @(now - 6.5 * day), @"remaining": @92},
|
|
55
62
|
@{@"timestamp": @(now - 5.5 * day), @"remaining": @86},
|
|
56
63
|
@{@"timestamp": @(now - 4.5 * day), @"remaining": @78},
|
|
@@ -59,6 +66,7 @@ int RenderQuotaDashboard(NSString *path) {
|
|
|
59
66
|
@{@"timestamp": @(now - 1.5 * day), @"remaining": @58},
|
|
60
67
|
@{@"timestamp": @(now - 0.5 * day), @"remaining": @51}
|
|
61
68
|
];
|
|
69
|
+
view.historyByProvider = @{@"Codex": codexHistory, @"Claude": claudeHistory};
|
|
62
70
|
view.activeAgentCount = 1;
|
|
63
71
|
// 预览里刻意只让一家在线,好把"有额度数据但客户端已退出"的离线态也画出来。
|
|
64
72
|
view.liveProviders = [NSSet setWithObject:@"Claude"];
|
|
@@ -23,6 +23,20 @@ static const CGFloat PetMenuControlGap = 8.0;
|
|
|
23
23
|
static const NSInteger PetMenuCheckViewTag = 1001;
|
|
24
24
|
static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
25
25
|
|
|
26
|
+
// AppKit 单独创建菜单和玻璃背景窗口。只给父面板设置 Space 策略,背景仍可能留在普通桌面。
|
|
27
|
+
static void PetJoinMenuWindowsToSpaces(NSWindow *parent) {
|
|
28
|
+
for (NSWindow *child in parent.childWindows) {
|
|
29
|
+
NSWindowCollectionBehavior behavior = child.collectionBehavior;
|
|
30
|
+
behavior &= ~(NSWindowCollectionBehaviorMoveToActiveSpace | NSWindowCollectionBehaviorFullScreenNone |
|
|
31
|
+
NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorPrimary |
|
|
32
|
+
NSWindowCollectionBehaviorAuxiliary);
|
|
33
|
+
behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary |
|
|
34
|
+
NSWindowCollectionBehaviorCanJoinAllApplications;
|
|
35
|
+
if (child.collectionBehavior != behavior) child.collectionBehavior = behavior;
|
|
36
|
+
PetJoinMenuWindowsToSpaces(child);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
26
40
|
@implementation PetView (Menu)
|
|
27
41
|
- (void)selectPetFromButton:(NSButton *)sender {
|
|
28
42
|
NSString *petID = sender.identifier;
|
|
@@ -408,7 +422,7 @@ static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
|
408
422
|
action:action width:PetSubmenuRowWidth tag:tag];
|
|
409
423
|
((MenuHintRowView *)item.view).hint = toolTip;
|
|
410
424
|
}
|
|
411
|
-
//
|
|
425
|
+
// 一级子菜单放常用开关;免审批和只影响桌宠的提醒各收进二级菜单。
|
|
412
426
|
// 未开启时只留"启用"一行:其余开关此时都不生效,列出来只是占地方。开启是异步的,
|
|
413
427
|
// 菜单停留期间不会自己长出其余项,下次打开时按实际状态重建。
|
|
414
428
|
- (void)addBridgeMenuToMenu:(NSMenu *)menu {
|
|
@@ -420,7 +434,7 @@ static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
|
420
434
|
BOOL enabled = CCBridgeEnabled();
|
|
421
435
|
[self addBridgeSwitchToMenu:bridgeMenu title:L(@"Enable") checked:enabled
|
|
422
436
|
action:@selector(toggleBridgeEnabled:) tag:0
|
|
423
|
-
toolTip:L(@"Let local
|
|
437
|
+
toolTip:L(@"Let local Agent sessions exchange messages, wake supported sessions, and reserve files")];
|
|
424
438
|
if (!enabled) return;
|
|
425
439
|
|
|
426
440
|
// 状态放在"启用"行的第二行,省掉底部单独的状态行和分隔线。开关上移与标题对齐,
|
|
@@ -451,9 +465,12 @@ static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
|
451
465
|
[self addBridgeSwitchToMenu:bridgeMenu title:L(@"Edit guard") checked:[options[@"editGuard"] boolValue]
|
|
452
466
|
action:@selector(toggleBridgeEditGuard:) tag:0
|
|
453
467
|
toolTip:L(@"Pause once with an explanation when editing a file another session reserved; retrying goes through. Codex needs a session restart")];
|
|
468
|
+
[self addBridgeSwitchToMenu:bridgeMenu title:L(@"Tab nicknames") checked:[options[@"tabTitle"] boolValue]
|
|
469
|
+
action:@selector(toggleBridgeTabTitle:) tag:0
|
|
470
|
+
toolTip:L(@"Append CC Bridge nicknames to terminal tab titles. Restart CLI sessions after turning this on.")];
|
|
454
471
|
|
|
455
472
|
NSMenuItem *approvalItem = [bridgeMenu addItemWithTitle:L(@"Auto-approve") action:nil keyEquivalent:@""];
|
|
456
|
-
approvalItem.representedObject = L(@"Each group applies to
|
|
473
|
+
approvalItem.representedObject = L(@"Each group applies to the integrated Agents. Restart sessions to reload tool permissions");
|
|
457
474
|
NSMenu *approvalMenu = [NSMenu new];
|
|
458
475
|
NSArray<NSDictionary *> *groups = @[
|
|
459
476
|
@{@"title": L(@"Read"), @"group": @"view", @"tag": @1,
|
|
@@ -467,9 +484,12 @@ static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
|
467
484
|
];
|
|
468
485
|
NSSet *codex = [NSSet setWithArray:options[@"codexApprove"]];
|
|
469
486
|
NSSet *claude = [NSSet setWithArray:options[@"claudeAllow"]];
|
|
487
|
+
NSSet *agy = [NSSet setWithArray:options[@"antigravityAllow"]];
|
|
488
|
+
BOOL hasAntigravity = CCPetsProfilesForProvider(CCPetsProfileProviderAntigravity).count > 0;
|
|
470
489
|
for (NSDictionary *group in groups) {
|
|
471
490
|
NSSet *tools = [NSSet setWithArray:CCBridgeToolGroup(group[@"group"])];
|
|
472
|
-
BOOL checked = tools.count > 0 && [tools isSubsetOfSet:codex] && [tools isSubsetOfSet:claude]
|
|
491
|
+
BOOL checked = tools.count > 0 && [tools isSubsetOfSet:codex] && [tools isSubsetOfSet:claude] &&
|
|
492
|
+
(!hasAntigravity || [tools isSubsetOfSet:agy]);
|
|
473
493
|
[self addBridgeSwitchToMenu:approvalMenu title:group[@"title"] checked:checked
|
|
474
494
|
action:@selector(toggleBridgeApproval:) tag:[group[@"tag"] integerValue] toolTip:group[@"tip"]];
|
|
475
495
|
}
|
|
@@ -490,7 +510,32 @@ static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
|
490
510
|
}
|
|
491
511
|
|
|
492
512
|
- (void)rightMouseDown:(NSEvent *)event {
|
|
493
|
-
|
|
513
|
+
// 桌宠同时出现在多个 Space。用点击处的单独面板定位菜单,避免菜单跟随桌宠的原始桌面。
|
|
514
|
+
NSPoint click = [self.window convertPointToScreen:event.locationInWindow];
|
|
515
|
+
NSPanel *anchor = [[NSPanel alloc] initWithContentRect:NSMakeRect(click.x, click.y, 1, 1)
|
|
516
|
+
styleMask:NSWindowStyleMaskBorderless | NSWindowStyleMaskNonactivatingPanel
|
|
517
|
+
backing:NSBackingStoreBuffered defer:NO];
|
|
518
|
+
anchor.opaque = NO;
|
|
519
|
+
anchor.backgroundColor = NSColor.clearColor;
|
|
520
|
+
anchor.hasShadow = NO;
|
|
521
|
+
anchor.hidesOnDeactivate = NO;
|
|
522
|
+
anchor.level = self.window.level;
|
|
523
|
+
anchor.collectionBehavior = NSWindowCollectionBehaviorMoveToActiveSpace |
|
|
524
|
+
NSWindowCollectionBehaviorTransient | NSWindowCollectionBehaviorFullScreenAuxiliary |
|
|
525
|
+
NSWindowCollectionBehaviorCanJoinAllApplications;
|
|
526
|
+
[anchor orderFrontRegardless];
|
|
527
|
+
|
|
528
|
+
NSMenu *menu = [self buildContextMenu];
|
|
529
|
+
CFRunLoopObserverRef observer = CFRunLoopObserverCreateWithHandler(NULL, kCFRunLoopBeforeWaiting,
|
|
530
|
+
true, 0, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
|
|
531
|
+
PetJoinMenuWindowsToSpaces(anchor);
|
|
532
|
+
});
|
|
533
|
+
CFRunLoopAddObserver(CFRunLoopGetMain(), observer, kCFRunLoopCommonModes);
|
|
534
|
+
NSPoint location = [anchor.contentView convertPoint:[anchor convertPointFromScreen:click] fromView:nil];
|
|
535
|
+
[menu popUpMenuPositioningItem:nil atLocation:location inView:anchor.contentView];
|
|
536
|
+
CFRunLoopObserverInvalidate(observer);
|
|
537
|
+
CFRelease(observer);
|
|
538
|
+
[anchor orderOut:nil];
|
|
494
539
|
[self finishContextMenu];
|
|
495
540
|
}
|
|
496
541
|
// 菜单栏图标的右键菜单也是这一份,所以建菜单和收尾分开,不和 NSEvent 绑在一起。
|
|
@@ -534,6 +579,12 @@ static const NSInteger PetMenuDeleteButtonTag = 1002;
|
|
|
534
579
|
preferenceKey:key tag:codex ? 1 : 2 profile:profile];
|
|
535
580
|
}
|
|
536
581
|
}
|
|
582
|
+
for (NSDictionary *profile in CCPetsProfilesForProvider(CCPetsProfileProviderAntigravity)) {
|
|
583
|
+
NSString *name = CCPetsProfileIsOfficialDefault(profile) && ![profile[@"customName"] boolValue]
|
|
584
|
+
? @"Antigravity CLI" : [NSString stringWithFormat:@"Antigravity CLI · %@", profile[@"displayName"]];
|
|
585
|
+
[self addUsageModeControlToMenu:usageModeMenu provider:name preferenceKey:CCPetsUsageModePreferenceKey(profile)
|
|
586
|
+
tag:0 profile:profile];
|
|
587
|
+
}
|
|
537
588
|
usageModeItem.submenu = usageModeMenu;
|
|
538
589
|
NSMenuItem *themeItem = [menu addItemWithTitle:L(@"Panel Theme") action:nil keyEquivalent:@""];
|
|
539
590
|
NSMenu *themeMenu = [[NSMenu alloc] initWithTitle:L(@"Panel Theme")];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import "CCPetsL10n.h"
|
|
2
2
|
#import "CCPetsDoctor.h"
|
|
3
|
+
#import "CCPetsAntigravityConfig.h"
|
|
3
4
|
#import "CCPetsBridge.h"
|
|
4
5
|
#import "CCPetsBridgeSetup.h"
|
|
5
6
|
#import "CCPetsBridgeStore.h"
|
|
@@ -125,7 +126,17 @@ static NSDictionary *ReadJSONFile(NSString *file) {
|
|
|
125
126
|
|
|
126
127
|
#pragma mark - cc-pets paths
|
|
127
128
|
|
|
129
|
+
static NSString *ProfileHooksPath(NSDictionary *profile) {
|
|
130
|
+
NSString *provider = profile[@"provider"], *home = profile[@"home"];
|
|
131
|
+
if ([provider isEqualToString:CCPetsProfileProviderAntigravity]) {
|
|
132
|
+
return [home stringByAppendingPathComponent:@"config/hooks.json"];
|
|
133
|
+
}
|
|
134
|
+
return [home stringByAppendingPathComponent:
|
|
135
|
+
[provider isEqualToString:CCPetsProfileProviderClaude] ? @"settings.json" : @"hooks.json"];
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
static NSArray<NSDictionary *> *PathGroups(NSDictionary *native) {
|
|
139
|
+
NSString *agyHome = DefaultAntigravityConfigDirectory();
|
|
129
140
|
NSMutableArray *integrationItems = [NSMutableArray arrayWithArray:@[
|
|
130
141
|
@[PackageKind(), PackageDirectory()],
|
|
131
142
|
@[L(@"Installed app"), InstalledApp()],
|
|
@@ -134,13 +145,14 @@ static NSArray<NSDictionary *> *PathGroups(NSDictionary *native) {
|
|
|
134
145
|
stringByAppendingPathComponent:@"settings.json"]],
|
|
135
146
|
@[@"Codex Hooks", [[CCPetsHomeDirectory() stringByAppendingPathComponent:@".codex"]
|
|
136
147
|
stringByAppendingPathComponent:@"hooks.json"]],
|
|
148
|
+
@[L(@"Antigravity CLI hooks"), [agyHome stringByAppendingPathComponent:@"config/hooks.json"]],
|
|
149
|
+
@[L(@"Antigravity CLI MCP config"), [agyHome stringByAppendingPathComponent:@"config/mcp_config.json"]],
|
|
150
|
+
@[L(@"Antigravity CLI settings"), [agyHome stringByAppendingPathComponent:@"antigravity-cli/settings.json"]],
|
|
137
151
|
@[L(@"Shell config"), ShellRC()]
|
|
138
152
|
]];
|
|
139
153
|
for (NSDictionary *profile in CCPetsProfiles()) {
|
|
140
154
|
NSString *name = profile[@"displayName"] ?: profile[@"slug"] ?: profile[@"provider"];
|
|
141
|
-
|
|
142
|
-
[profile[@"provider"] isEqualToString:CCPetsProfileProviderClaude] ? @"settings.json" : @"hooks.json"];
|
|
143
|
-
[integrationItems addObject:@[[NSString stringWithFormat:L(@"Agent profile: %@"), name], file]];
|
|
155
|
+
[integrationItems addObject:@[[NSString stringWithFormat:L(@"Agent profile: %@"), name], ProfileHooksPath(profile)]];
|
|
144
156
|
}
|
|
145
157
|
return @[
|
|
146
158
|
@{@"title": L(@"Settings (removed by --purge)"), @"items": @[@[L(@"Preferences"), native[@"preferences"]]]},
|
|
@@ -149,7 +161,7 @@ static NSArray<NSDictionary *> *PathGroups(NSDictionary *native) {
|
|
|
149
161
|
@[L(@"Shared lines"), native[@"phrases"]],
|
|
150
162
|
@[L(@"Per-pet lines"), native[@"petPhrases"]],
|
|
151
163
|
@[L(@"CC Bridge switch"), [CCBridgeHomeDirectory() stringByAppendingPathComponent:@"bridge-enabled"]],
|
|
152
|
-
@[@"
|
|
164
|
+
@[L(@"Agent shims"), CCPetsShimDirectory()]
|
|
153
165
|
]},
|
|
154
166
|
@{@"title": L(@"App data (removed by --purge; clean only clears the token cache and update log)"), @"items": @[
|
|
155
167
|
@[L(@"App data directory"), native[@"applicationSupport"]],
|
|
@@ -278,6 +290,19 @@ static NSArray<NSDictionary *> *HookChecks(NSString *name, NSString *configFile,
|
|
|
278
290
|
return results;
|
|
279
291
|
}
|
|
280
292
|
|
|
293
|
+
static NSDictionary *AntigravityHookCheck(NSDictionary *profile) {
|
|
294
|
+
NSString *name = profile[@"displayName"] ?: @"Antigravity CLI";
|
|
295
|
+
NSString *path = ProfileHooksPath(profile);
|
|
296
|
+
NSDictionary *read = ReadJSONFile(path);
|
|
297
|
+
if ([read[@"error"] isEqualToString:@"invalid"] || (read[@"value"] && ![read[@"value"] isKindOfClass:NSDictionary.class])) {
|
|
298
|
+
return Result(@"fail", LF(L(@"Can't parse {name} config: {configFile}"),
|
|
299
|
+
(@{@"name": name, @"configFile": CCPetsTildePath(path)})), L(@"Fix that JSON file, then run cc-pets install"));
|
|
300
|
+
}
|
|
301
|
+
return CCPetsAntigravityPetHooksInstalled(profile)
|
|
302
|
+
? Result(@"ok", LF(L(@"{name} hooks installed"), @{@"name": name}), nil)
|
|
303
|
+
: Result(@"fail", LF(L(@"{name} hooks not installed"), @{@"name": name}), @"cc-pets install");
|
|
304
|
+
}
|
|
305
|
+
|
|
281
306
|
static NSDictionary *StatusLineCheckAtHome(NSString *home) {
|
|
282
307
|
NSDictionary *value = ReadJSONFile([home stringByAppendingPathComponent:@"settings.json"])[@"value"];
|
|
283
308
|
NSDictionary *statusLine = [value isKindOfClass:NSDictionary.class] && [value[@"statusLine"] isKindOfClass:NSDictionary.class]
|
|
@@ -308,7 +333,8 @@ static NSArray<NSDictionary *> *ShimChecks(BOOL inApp) {
|
|
|
308
333
|
|
|
309
334
|
NSString *shimDirectory = CCPetsShimDirectory();
|
|
310
335
|
NSMutableArray<NSString *> *broken = [NSMutableArray array];
|
|
311
|
-
|
|
336
|
+
NSArray<NSString *> *names = @[@"codex", @"claude", @"agy"];
|
|
337
|
+
for (NSString *name in names) {
|
|
312
338
|
NSString *link = [NSFileManager.defaultManager destinationOfSymbolicLinkAtPath:[shimDirectory stringByAppendingPathComponent:name] error:nil];
|
|
313
339
|
if (!link) {
|
|
314
340
|
[broken addObject:LF(L(@"{name} (missing)"), @{@"name": name})];
|
|
@@ -335,17 +361,17 @@ static NSArray<NSDictionary *> *ShimChecks(BOOL inApp) {
|
|
|
335
361
|
NSUInteger index = [entries indexOfObject:shimDirectory];
|
|
336
362
|
NSString *sourceHint = LF(L(@"source {shellRC}, or open a new terminal"), @{@"shellRC": CCPetsTildePath(shellRC)});
|
|
337
363
|
if (index == NSNotFound) {
|
|
338
|
-
[results addObject:Result(@"warn", L(@"This terminal's PATH lacks the shim directory, so
|
|
364
|
+
[results addObject:Result(@"warn", L(@"This terminal's PATH lacks the shim directory, so the Agent launchers won't start the pet"), sourceHint)];
|
|
339
365
|
} else if (index > 0) {
|
|
340
366
|
NSString *shadowing = nil;
|
|
341
367
|
for (NSString *entry in [entries subarrayWithRange:NSMakeRange(0, index)]) {
|
|
342
|
-
for (NSString *name in
|
|
368
|
+
for (NSString *name in names) {
|
|
343
369
|
if (!shadowing && [NSFileManager.defaultManager fileExistsAtPath:[entry stringByAppendingPathComponent:name]]) shadowing = entry;
|
|
344
370
|
}
|
|
345
371
|
}
|
|
346
372
|
[results addObject:shadowing
|
|
347
373
|
? Result(@"warn", LF(L(@"{shadowing} comes before the shim directory in PATH and bypasses the pet"), @{@"shadowing": CCPetsTildePath(shadowing)}), sourceHint)
|
|
348
|
-
: Result(@"ok", L(@"The shim directory comes before the real
|
|
374
|
+
: Result(@"ok", L(@"The shim directory comes before the real Agent binaries in PATH"), nil)];
|
|
349
375
|
} else {
|
|
350
376
|
[results addObject:Result(@"ok", L(@"The shim directory is first in PATH"), nil)];
|
|
351
377
|
}
|
|
@@ -355,7 +381,7 @@ static NSArray<NSDictionary *> *ShimChecks(BOOL inApp) {
|
|
|
355
381
|
// searchPath:主窗口传登录 shell 的 PATH,终端里传 nil 用自身 PATH。
|
|
356
382
|
static NSString *FindRealBinary(NSString *name, NSString *variable, NSString *searchPath) {
|
|
357
383
|
NSString *real = CCPetsFindRealExecutableInPath(name, variable, searchPath ?: CCPetsEnvironmentValue(@"PATH"));
|
|
358
|
-
return real && [NSFileManager.defaultManager
|
|
384
|
+
return real && [NSFileManager.defaultManager isExecutableFileAtPath:real] ? real : nil;
|
|
359
385
|
}
|
|
360
386
|
|
|
361
387
|
static NSDictionary *RealBinaryCheck(NSString *name, NSString *variable, NSString *searchPath, BOOL inApp) {
|
|
@@ -401,6 +427,8 @@ static NSArray<NSDictionary *> *DoctorSections(BOOL inApp) {
|
|
|
401
427
|
NSMutableArray<NSDictionary *> *sections = [NSMutableArray array];
|
|
402
428
|
BOOL claudeDetected = CCPetsClaudeCLIInstalled();
|
|
403
429
|
BOOL codexDetected = CCPetsCodexCLIInstalled();
|
|
430
|
+
BOOL agyDetected = CCPetsDirectoryExists([DefaultAntigravityConfigDirectory() stringByAppendingPathComponent:@"antigravity-cli"]) ||
|
|
431
|
+
CCPetsFindRealExecutable(@"agy", @"AGY_REAL_BIN") != nil;
|
|
404
432
|
NSString *packageVersion = PackageVersion();
|
|
405
433
|
|
|
406
434
|
NSMutableArray<NSDictionary *> *program = [NSMutableArray arrayWithObject:
|
|
@@ -432,19 +460,19 @@ static NSArray<NSDictionary *> *DoctorSections(BOOL inApp) {
|
|
|
432
460
|
for (NSDictionary *profile in registeredProfiles) {
|
|
433
461
|
NSString *provider = profile[@"provider"];
|
|
434
462
|
NSString *name = profile[@"displayName"] ?: profile[@"slug"] ?: provider;
|
|
435
|
-
NSString *file = [profile[@"home"] stringByAppendingPathComponent:
|
|
436
|
-
[provider isEqualToString:CCPetsProfileProviderClaude] ? @"settings.json" : @"hooks.json"];
|
|
437
463
|
NSUInteger bridgeHooks = 0;
|
|
438
|
-
NSMutableArray *checks
|
|
439
|
-
|
|
440
|
-
[
|
|
441
|
-
|
|
442
|
-
profileBridgeHooks[profile[@"id"]] = @(bridgeHooks);
|
|
443
|
-
if ([provider isEqualToString:CCPetsProfileProviderClaude]) {
|
|
444
|
-
[checks addObject:StatusLineCheckAtHome(profile[@"home"])];
|
|
464
|
+
NSMutableArray *checks;
|
|
465
|
+
if ([provider isEqualToString:CCPetsProfileProviderAntigravity]) {
|
|
466
|
+
checks = [NSMutableArray arrayWithObject:AntigravityHookCheck(profile)];
|
|
467
|
+
bridgeHooks = CCPetsAntigravityBridgeInstalled(profile);
|
|
445
468
|
} else {
|
|
446
|
-
|
|
469
|
+
BOOL claude = [provider isEqualToString:CCPetsProfileProviderClaude];
|
|
470
|
+
checks = [HookChecks(name, ProfileHooksPath(profile), claude ? CCPetsClaudeHookMarker : CCPetsCodexHookMarker,
|
|
471
|
+
claude ? CCPetsLegacyClaudeHookMarker : CCPetsLegacyCodexHookMarker, &bridgeHooks) mutableCopy];
|
|
472
|
+
if (claude) [checks addObject:StatusLineCheckAtHome(profile[@"home"])];
|
|
473
|
+
else [checks addObject:Result(@"info", L(@"Codex only runs CC Pets hooks after you trust them in /hooks (can't be checked automatically)"), nil)];
|
|
447
474
|
}
|
|
475
|
+
profileBridgeHooks[profile[@"id"]] = @(bridgeHooks);
|
|
448
476
|
for (NSUInteger index = 0; index < checks.count; index++) {
|
|
449
477
|
NSDictionary *check = checks[index];
|
|
450
478
|
if ([check[@"fix"] isEqualToString:@"cc-pets install"]) {
|
|
@@ -461,24 +489,41 @@ static NSArray<NSDictionary *> *DoctorSections(BOOL inApp) {
|
|
|
461
489
|
}
|
|
462
490
|
|
|
463
491
|
// Finder 拉起的主窗口只有 launchd 的最小 PATH,nvm / Homebrew 下的 CLI 都不在里面,改用登录 shell 的。
|
|
464
|
-
NSString *searchPath = inApp && (codexDetected || claudeDetected) ? CCPetsLoginShellPath() : nil;
|
|
492
|
+
NSString *searchPath = inApp && (codexDetected || claudeDetected || agyDetected) ? CCPetsLoginShellPath() : nil;
|
|
465
493
|
NSMutableArray *shell = [ShimChecks(inApp) mutableCopy];
|
|
466
494
|
if (codexDetected) [shell addObject:RealBinaryCheck(@"codex", @"CODEX_REAL_BIN", searchPath, inApp)];
|
|
467
495
|
if (claudeDetected) [shell addObject:RealBinaryCheck(@"claude", @"CLAUDE_REAL_BIN", searchPath, inApp)];
|
|
496
|
+
if (agyDetected) [shell addObject:RealBinaryCheck(@"agy", @"AGY_REAL_BIN", searchPath, inApp)];
|
|
468
497
|
[sections addObject:@{@"title": L(@"Shell integration"), @"results": shell}];
|
|
469
498
|
|
|
470
499
|
if (!CCBridgeEnabled()) {
|
|
471
500
|
[sections addObject:@{@"title": @"CC Bridge", @"results": @[Result(@"info", L(@"Off (optional; turn on with cc-pets bridge enable)"), nil)]}];
|
|
472
501
|
} else {
|
|
473
502
|
NSMutableArray *bridge = [NSMutableArray arrayWithObject:Result(@"ok", L(@"Enabled"), nil)];
|
|
503
|
+
BOOL agyAppEnabled = [CCBridgeOptions()[@"antigravityApp"] boolValue];
|
|
474
504
|
for (NSDictionary *profile in registeredProfiles) {
|
|
475
505
|
NSString *name = profile[@"displayName"] ?: profile[@"slug"] ?: profile[@"provider"];
|
|
506
|
+
BOOL antigravity = [profile[@"provider"] isEqualToString:CCPetsProfileProviderAntigravity];
|
|
507
|
+
NSString *installed = antigravity ? L(@"CC Bridge hooks and MCP installed in %@") : L(@"CC Bridge hooks installed in %@");
|
|
508
|
+
NSString *missing = antigravity ? L(@"CC Bridge hooks or MCP missing in %@") : L(@"CC Bridge hooks missing in %@");
|
|
476
509
|
NSDictionary *result = [profileBridgeHooks[profile[@"id"]] unsignedIntegerValue] > 0
|
|
477
|
-
? Result(@"ok", [NSString stringWithFormat:
|
|
478
|
-
: Result(@"warn", [NSString stringWithFormat:
|
|
510
|
+
? Result(@"ok", [NSString stringWithFormat:installed, name], nil)
|
|
511
|
+
: Result(@"warn", [NSString stringWithFormat:missing, name], @"cc-pets bridge enable");
|
|
479
512
|
NSMutableDictionary *check = [result mutableCopy];
|
|
480
513
|
check[@"profileID"] = profile[@"id"];
|
|
514
|
+
if (antigravity && [result[@"level"] isEqualToString:@"warn"] &&
|
|
515
|
+
[AntigravityHookCheck(profile)[@"level"] isEqualToString:@"ok"]) {
|
|
516
|
+
check[@"repairProfileID"] = profile[@"id"];
|
|
517
|
+
}
|
|
481
518
|
[bridge addObject:check];
|
|
519
|
+
if (antigravity && agyAppEnabled && CCPetsProfileIsOfficialDefault(profile)) {
|
|
520
|
+
BOOL installedSidecar = CCPetsAntigravityAppSidecarInstalled(profile);
|
|
521
|
+
NSMutableDictionary *sidecar = [Result(installedSidecar ? @"ok" : @"warn",
|
|
522
|
+
installedSidecar ? L(@"Antigravity App Sidecar configured") : L(@"Antigravity App Sidecar needs repair"),
|
|
523
|
+
installedSidecar ? nil : @"cc-pets bridge configure --agy-app=on") mutableCopy];
|
|
524
|
+
if (!installedSidecar) sidecar[@"repairProfileID"] = profile[@"id"];
|
|
525
|
+
[bridge addObject:sidecar];
|
|
526
|
+
}
|
|
482
527
|
}
|
|
483
528
|
if (codexDetected) {
|
|
484
529
|
if ([CCBridgeOptions()[@"wake"] boolValue]) {
|
|
@@ -498,6 +543,9 @@ static NSArray<NSDictionary *> *DoctorSections(BOOL inApp) {
|
|
|
498
543
|
}
|
|
499
544
|
}
|
|
500
545
|
}
|
|
546
|
+
if (agyDetected && [CCBridgeOptions()[@"wake"] boolValue]) {
|
|
547
|
+
[bridge addObject:Result(@"info", L(@"Antigravity CLI reads Bridge messages on its next model invocation."), nil)];
|
|
548
|
+
}
|
|
501
549
|
[sections addObject:@{@"title": @"CC Bridge", @"results": bridge}];
|
|
502
550
|
}
|
|
503
551
|
|
|
@@ -561,13 +609,29 @@ static int RepairProfile(NSString *profileID) {
|
|
|
561
609
|
return 1;
|
|
562
610
|
}
|
|
563
611
|
BOOL claude = [profile[@"provider"] isEqualToString:CCPetsProfileProviderClaude];
|
|
612
|
+
BOOL antigravity = [profile[@"provider"] isEqualToString:CCPetsProfileProviderAntigravity];
|
|
613
|
+
BOOL repairAntigravityBridge = antigravity && CCBridgeEnabled();
|
|
614
|
+
BOOL repairAntigravityApp = repairAntigravityBridge && CCPetsProfileIsOfficialDefault(profile) &&
|
|
615
|
+
[CCBridgeOptions()[@"antigravityApp"] boolValue];
|
|
564
616
|
NSArray<NSString *> *files = claude ? CCPetsClaudeIntegrationFilesAtHome(profile[@"home"])
|
|
565
|
-
: @[
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
617
|
+
: @[ProfileHooksPath(profile)];
|
|
618
|
+
if (antigravity) {
|
|
619
|
+
NSString *home = profile[@"home"];
|
|
620
|
+
files = [files arrayByAddingObject:[home stringByAppendingPathComponent:@"antigravity-cli/settings.json"]];
|
|
621
|
+
if (repairAntigravityBridge) files = [files arrayByAddingObject:[home stringByAppendingPathComponent:@"config/mcp_config.json"]];
|
|
622
|
+
if (repairAntigravityApp) files = [files arrayByAddingObjectsFromArray:@[
|
|
623
|
+
[home stringByAppendingPathComponent:@"config/config.json"],
|
|
624
|
+
[home stringByAppendingPathComponent:@"config/sidecars/cc-pets-bridge/sidecar.json"]
|
|
625
|
+
]];
|
|
626
|
+
}
|
|
627
|
+
for (NSString *path in antigravity ? files : @[files.firstObject]) {
|
|
628
|
+
NSString *parseError = nil;
|
|
629
|
+
id config = antigravity ? CCPetsReadAntigravityConfig(path, &parseError) : CCPetsReadConfig(path, &parseError);
|
|
630
|
+
if (parseError || (config && ![config isKindOfClass:CCPetsJSONObject.class])) {
|
|
631
|
+
CCPetsPrintLine(stderr, [NSString stringWithFormat:@"%@: %@", CCPetsTildePath(path),
|
|
632
|
+
parseError ?: L(@"The Agent configuration must be a JSON object.")]);
|
|
633
|
+
return 1;
|
|
634
|
+
}
|
|
571
635
|
}
|
|
572
636
|
NSString *backup = [[ApplicationSupportDirectory() stringByAppendingPathComponent:@"diagnostic-backups"]
|
|
573
637
|
stringByAppendingPathComponent:NSUUID.UUID.UUIDString];
|
|
@@ -606,16 +670,41 @@ static int RepairProfile(NSString *profileID) {
|
|
|
606
670
|
return 1;
|
|
607
671
|
}
|
|
608
672
|
CCPetsPrintLine(stdout, [NSString stringWithFormat:L(@"Configuration backup: %@"), CCPetsTildePath(backup)]);
|
|
609
|
-
int status = claude ? InstallClaudeHooksAtHome(binary, profile[@"home"])
|
|
610
|
-
: InstallCodexHooksAtHome(binary, profile[@"home"]);
|
|
611
|
-
if (status != 0) return status;
|
|
612
|
-
|
|
613
673
|
// 安装返回成功后重新读配置;未恢复的 Hooks / status line 不能清掉待修复状态。
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
674
|
+
NSMutableArray<NSDictionary *> *checks;
|
|
675
|
+
if (antigravity) {
|
|
676
|
+
@try {
|
|
677
|
+
NSArray *report = repairAntigravityBridge ? CCBridgeInstallForProfile(profile, CCBridgeOptions(), YES)
|
|
678
|
+
: CCPetsInstallAntigravityPetHooks(profile);
|
|
679
|
+
BOOL failed = NO;
|
|
680
|
+
for (NSString *line in report) {
|
|
681
|
+
BOOL errorLine = [line hasPrefix:@"ERROR: "];
|
|
682
|
+
CCPetsPrintLine(errorLine ? stderr : stdout, line);
|
|
683
|
+
failed |= errorLine;
|
|
684
|
+
}
|
|
685
|
+
if (failed) return 1;
|
|
686
|
+
} @catch (NSException *exception) {
|
|
687
|
+
CCPetsPrintLine(stderr, exception.reason ?: exception.name);
|
|
688
|
+
return 1;
|
|
689
|
+
}
|
|
690
|
+
checks = [NSMutableArray arrayWithObject:AntigravityHookCheck(profile)];
|
|
691
|
+
if (repairAntigravityBridge && !CCPetsAntigravityBridgeInstalled(profile)) {
|
|
692
|
+
[checks addObject:Result(@"fail", [NSString stringWithFormat:L(@"CC Bridge hooks or MCP missing in %@"),
|
|
693
|
+
profile[@"displayName"] ?: profileID], nil)];
|
|
694
|
+
}
|
|
695
|
+
if (repairAntigravityApp && !CCPetsAntigravityAppSidecarInstalled(profile)) {
|
|
696
|
+
[checks addObject:Result(@"fail", L(@"Antigravity App Sidecar needs repair"), nil)];
|
|
697
|
+
}
|
|
698
|
+
} else {
|
|
699
|
+
int status = claude ? InstallClaudeHooksAtHome(binary, profile[@"home"])
|
|
700
|
+
: InstallCodexHooksAtHome(binary, profile[@"home"]);
|
|
701
|
+
if (status != 0) return status;
|
|
702
|
+
NSUInteger bridgeHooks = 0;
|
|
703
|
+
checks = [HookChecks(profile[@"displayName"] ?: profileID, files.firstObject,
|
|
704
|
+
claude ? CCPetsClaudeHookMarker : CCPetsCodexHookMarker,
|
|
705
|
+
claude ? CCPetsLegacyClaudeHookMarker : CCPetsLegacyCodexHookMarker, &bridgeHooks) mutableCopy];
|
|
706
|
+
if (claude) [checks addObject:StatusLineCheckAtHome(profile[@"home"])];
|
|
707
|
+
}
|
|
619
708
|
for (NSDictionary *check in checks) {
|
|
620
709
|
if ([check[@"level"] isEqualToString:@"ok"]) continue;
|
|
621
710
|
CCPetsPrintLine(stderr, check[@"title"]);
|
|
@@ -20,6 +20,10 @@ NSString *DefaultClaudeConfigDirectory(void);
|
|
|
20
20
|
NSString *CurrentClaudeConfigDirectory(void);
|
|
21
21
|
// 桌宠端用:只看主账号的 Codex 目录,不受继承来的 CODEX_HOME 影响。
|
|
22
22
|
NSString *DefaultCodexHomeDirectory(void);
|
|
23
|
+
// Gemini 根目录,包含 Antigravity CLI 自己的 antigravity-cli/ 子目录。
|
|
24
|
+
NSString *DefaultAntigravityConfigDirectory(void);
|
|
25
|
+
// 桌面 App 固定使用官方 Gemini 根目录,不受 CLI 的目录覆盖影响。
|
|
26
|
+
NSString *DefaultAntigravityAppConfigDirectory(void);
|
|
23
27
|
NSString *ClaudeUsagePathForConfigDirectory(NSString *configDirectory);
|
|
24
28
|
// Token 会话摘要缓存的落盘位置,按 provider 与数据源目录分文件。
|
|
25
29
|
NSString *TokenSummaryCachePath(NSString *provider, NSString *sourceDirectory);
|
|
@@ -56,6 +60,7 @@ extern NSString *const SystemMemoryEnabledKey;
|
|
|
56
60
|
// 每个 Provider 独立保存额度卡展示模式,值为 "subscription" 或 "api"。
|
|
57
61
|
extern NSString *const CodexUsageDisplayModeKey;
|
|
58
62
|
extern NSString *const ClaudeUsageDisplayModeKey;
|
|
63
|
+
extern NSString *const AntigravityUsageDisplayModeKey;
|
|
59
64
|
// 曾经检测到过的 provider 集合。只增不减:探测有可能瞬时失败(配置目录被临时改名、
|
|
60
65
|
// 外置盘没挂上),而卡片突然消失比多显示一张空卡更像 bug。
|
|
61
66
|
extern NSString *const DetectedProvidersKey;
|
|
@@ -38,6 +38,20 @@ NSString *DefaultCodexHomeDirectory(void) {
|
|
|
38
38
|
return [NSHomeDirectory() stringByAppendingPathComponent:@".codex"];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
NSString *DefaultAntigravityConfigDirectory(void) {
|
|
42
|
+
NSString *override = NSProcessInfo.processInfo.environment[@"CC_PETS_ANTIGRAVITY_HOME"];
|
|
43
|
+
if (override.length > 0) return override.stringByStandardizingPath;
|
|
44
|
+
return DefaultAntigravityAppConfigDirectory();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 与账号登记(CCPetsProfiles 的官方 Home)一致地遵循 $HOME;NSHomeDirectory() 只看账户
|
|
48
|
+
// 记录,两边不一致时按目录查不到已登记的账号。
|
|
49
|
+
NSString *DefaultAntigravityAppConfigDirectory(void) {
|
|
50
|
+
NSString *home = NSProcessInfo.processInfo.environment[@"HOME"];
|
|
51
|
+
if (!home.isAbsolutePath) home = NSHomeDirectory();
|
|
52
|
+
return [home stringByAppendingPathComponent:@".gemini"];
|
|
53
|
+
}
|
|
54
|
+
|
|
41
55
|
// 额度是按账号的。一台机器上可以有多个配置目录(例如 ~/.claude 和 ~/.claude-nw),
|
|
42
56
|
// 各自是不同账号、不同额度周期。共用一个文件的话两边的 statusline 会互相覆盖,
|
|
43
57
|
// 面板就会把 A 账号的剩余百分比配上 B 账号的用量。因此按配置目录分文件。
|
|
@@ -235,6 +249,7 @@ NSString *const SystemTemperatureEnabledKey = @"CCPetsSystemTemperatureEnabled";
|
|
|
235
249
|
NSString *const SystemMemoryEnabledKey = @"CCPetsSystemMemoryEnabled";
|
|
236
250
|
NSString *const CodexUsageDisplayModeKey = @"CCPetsCodexUsageDisplayMode";
|
|
237
251
|
NSString *const ClaudeUsageDisplayModeKey = @"CCPetsClaudeUsageDisplayMode";
|
|
252
|
+
NSString *const AntigravityUsageDisplayModeKey = @"CCPetsAntigravityUsageDisplayMode";
|
|
238
253
|
NSString *const DetectedProvidersKey = @"CCPetsDetectedProviders";
|
|
239
254
|
const NSTimeInterval AgentStatusInactivityInterval = 60.0;
|
|
240
255
|
// 客户端进程已经消失、但状态气泡还停在它最后一条事件上时,多等这么久再清场。
|
|
@@ -25,6 +25,9 @@ extern NSString *const CCPetsDisplayModeBoth;
|
|
|
25
25
|
extern NSString *const CCPetsDisplayModeMenuBar;
|
|
26
26
|
// 菜单栏图标旁常驻显示最低的 5 小时剩余额度。默认关;低于 20% 时不论开关都会显示。
|
|
27
27
|
extern NSString *const CCPetsMenuBarShowsPercentKey;
|
|
28
|
+
// 悬停额度卡使用稳定的 Provider key 保存顺序,空数组表示自动排序。
|
|
29
|
+
extern NSString *const CCPetsQuotaCardOrderKey;
|
|
30
|
+
NSArray<NSString *> *CCPetsQuotaCardOrder(void);
|
|
28
31
|
// 规整后的显示位置:没写过或写了未知值都按仅桌宠处理。
|
|
29
32
|
NSString *CCPetsDisplayMode(void);
|
|
30
33
|
|
|
@@ -32,7 +35,7 @@ NSString *CCPetsDisplayMode(void);
|
|
|
32
35
|
BOOL CCPetsPrefBool(NSString *key);
|
|
33
36
|
void CCPetsPrefSetBool(NSString *key, BOOL value);
|
|
34
37
|
|
|
35
|
-
//
|
|
38
|
+
// 写字符串、数字或额度卡顺序。数值键会先钳到合法范围(宠物缩放、点击互动阈值与间隔);
|
|
36
39
|
// 规整后不合法(NaN 之类)时不写,返回 NO。value 为 nil 表示删除该键,交回默认值。
|
|
37
40
|
BOOL CCPetsPrefSetObject(NSString *key, id value);
|
|
38
41
|
|
|
@@ -16,6 +16,7 @@ NSString *const CCPetsDisplayModePet = @"pet";
|
|
|
16
16
|
NSString *const CCPetsDisplayModeBoth = @"both";
|
|
17
17
|
NSString *const CCPetsDisplayModeMenuBar = @"menubar";
|
|
18
18
|
NSString *const CCPetsMenuBarShowsPercentKey = @"CCPetsMenuBarShowsPercent";
|
|
19
|
+
NSString *const CCPetsQuotaCardOrderKey = @"CCPetsQuotaCardOrder";
|
|
19
20
|
|
|
20
21
|
static NSArray<NSString *> *DisplayModes(void) {
|
|
21
22
|
return @[CCPetsDisplayModePet, CCPetsDisplayModeBoth, CCPetsDisplayModeMenuBar];
|
|
@@ -27,6 +28,22 @@ NSString *CCPetsDisplayMode(void) {
|
|
|
27
28
|
? value : CCPetsDisplayModePet;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
static NSArray<NSString *> *NormalizedQuotaCardOrder(id value) {
|
|
32
|
+
if (![value isKindOfClass:NSArray.class]) return nil;
|
|
33
|
+
NSCharacterSet *invalid = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyz0123456789-"].invertedSet;
|
|
34
|
+
NSMutableOrderedSet<NSString *> *order = [NSMutableOrderedSet orderedSet];
|
|
35
|
+
for (id entry in value) {
|
|
36
|
+
if (![entry isKindOfClass:NSString.class]) continue;
|
|
37
|
+
NSString *key = [[entry stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet] lowercaseString];
|
|
38
|
+
if (key.length > 0 && [key rangeOfCharacterFromSet:invalid].location == NSNotFound) [order addObject:key];
|
|
39
|
+
}
|
|
40
|
+
return order.array;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
NSArray<NSString *> *CCPetsQuotaCardOrder(void) {
|
|
44
|
+
return NormalizedQuotaCardOrder([NSUserDefaults.standardUserDefaults objectForKey:CCPetsQuotaCardOrderKey]) ?: @[];
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
// 包装器运行的是裸二进制,默认 preferences domain 与 App bundle 不同。
|
|
31
48
|
// 启动保护的读取和写入统一走 CFPreferences 的同一个域、用户和主机。
|
|
32
49
|
// 不混用临时 suite 的写入与 standardUserDefaults 的快照回读,避免控件刷新后弹回关闭。
|
|
@@ -94,6 +111,7 @@ static NSNumber *ClampedNumber(id value, double minimum, double maximum) {
|
|
|
94
111
|
// 下限与右键菜单原先各 setter 里的钳制逐条对应,改这里等于改菜单行为。
|
|
95
112
|
id CCPetsPrefNormalizedValue(NSString *key, id value) {
|
|
96
113
|
if (value == nil) return nil;
|
|
114
|
+
if ([key isEqualToString:CCPetsQuotaCardOrderKey]) return NormalizedQuotaCardOrder(value);
|
|
97
115
|
if ([key isEqualToString:CCPetsPetScaleKey]) {
|
|
98
116
|
NSNumber *scale = ClampedNumber(value, CCPetsPetMinimumScale, CCPetsPetMaximumScale);
|
|
99
117
|
// 滑动条连续拖动会给出 0.8734 这种值,按百分比取整,免得 defaults 里存一串小数。
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import "CCPetsMenuBarSummary.h"
|
|
4
4
|
#import "CCPetsGlassView.h"
|
|
5
5
|
#import "CCPetsL10n.h"
|
|
6
|
+
#import "CCPetsProviderRegistry.h"
|
|
6
7
|
#import "CCPetsUsagePage.h"
|
|
7
8
|
|
|
8
9
|
static const CGFloat PanelWidth = 300;
|
|
@@ -18,11 +19,13 @@ static NSColor *PrimaryInk(void) { return [NSColor colorWithWhite:0.97 alpha:1];
|
|
|
18
19
|
static NSColor *SecondaryInk(void) { return [NSColor colorWithWhite:0.80 alpha:1]; }
|
|
19
20
|
static NSColor *TertiaryInk(void) { return [NSColor colorWithWhite:0.80 alpha:0.62]; }
|
|
20
21
|
|
|
21
|
-
//
|
|
22
|
+
// 与悬停面板共用品牌色,原生玻璃可选更亮的配色。
|
|
22
23
|
static NSColor *ProviderColor(NSString *provider, BOOL liquid) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
CCPetsProviderDescriptor *descriptor = CCPetsProviderForName(provider);
|
|
25
|
+
NSArray<NSNumber *> *channels = liquid ? descriptor.glassColorRGB : descriptor.standardColorRGB;
|
|
26
|
+
if (channels.count == 3) {
|
|
27
|
+
return [NSColor colorWithRed:channels[0].doubleValue green:channels[1].doubleValue
|
|
28
|
+
blue:channels[2].doubleValue alpha:1];
|
|
26
29
|
}
|
|
27
30
|
return [NSColor colorWithRed:0.30 green:0.82 blue:0.90 alpha:1];
|
|
28
31
|
}
|
|
@@ -410,7 +413,9 @@ static NSString *ResetText(id value) {
|
|
|
410
413
|
- (CCPetsMenuBarRow *)quotaRow:(NSDictionary *)quota {
|
|
411
414
|
NSString *provider = [quota[@"provider"] isKindOfClass:NSString.class] ? quota[@"provider"] : @"Agent";
|
|
412
415
|
NSString *profileName = [quota[@"profileName"] isKindOfClass:NSString.class] ? quota[@"profileName"] : nil;
|
|
413
|
-
NSString *
|
|
416
|
+
NSString *defaultProfileName = [provider isEqualToString:@"Antigravity"] ? @"gemini" : provider;
|
|
417
|
+
NSString *name = profileName.length > 0 && [profileName caseInsensitiveCompare:provider] != NSOrderedSame &&
|
|
418
|
+
[profileName caseInsensitiveCompare:defaultProfileName] != NSOrderedSame
|
|
414
419
|
? [NSString stringWithFormat:@"%@ · %@", provider, profileName] : provider;
|
|
415
420
|
BOOL api = [quota[@"apiMode"] boolValue];
|
|
416
421
|
BOOL limited = [quota[@"state"] isEqual:@"limited"];
|