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
@@ -1,5 +1,6 @@
1
1
  // Agent 状态卡、会话列表、审批与卡住提醒、终端回跳、系统通知。
2
2
  #import "CCPetsAppDelegate+Private.h"
3
+ #import "CCPetsBridgeStore.h"
3
4
 
4
5
  @implementation AppDelegate (AgentStatus)
5
6
  - (void)sendNotificationWithTitle:(NSString *)title body:(NSString *)body {
@@ -189,7 +190,7 @@
189
190
  - (void)updateStatusBubbleExpanded:(BOOL)expanded {
190
191
  self.statusBubbleExpanded = expanded;
191
192
  CCPetsPrefSetBool(StatusBubbleExpandedKey, expanded);
192
- if (self.statusBubbleExpanded && self.hasAgentStatus) {
193
+ if (self.statusBubbleExpanded && self.hasAgentStatus && [self petVisible]) {
193
194
  [self positionAgentStatus];
194
195
  [self.statusPanel orderFrontRegardless];
195
196
  } else {
@@ -205,7 +206,7 @@
205
206
  if (![state isEqualToString:@"completed"] && ![state isEqualToString:@"failed"]) return NO;
206
207
  NSString *event = [record[@"event"] isKindOfClass:NSString.class] ? record[@"event"] : @"";
207
208
  return [event isEqualToString:@"SubagentStop"] || [event isEqualToString:@"PostToolUse"] ||
208
- [event isEqualToString:@"TaskCompleted"];
209
+ [event isEqualToString:@"TaskCompleted"] || [event isEqualToString:@"ApprovalResolved"];
209
210
  }
210
211
  // 标题优先显示账号名;身份比较使用 profileId 和会话身份,不按显示名合并终端。
211
212
  - (NSString *)statusPresentationNameForRecord:(NSDictionary *)record {
@@ -216,7 +217,7 @@
216
217
  }
217
218
  - (NSString *)statusIdentityForRecord:(NSDictionary *)record {
218
219
  NSString *provider = SanitizedShortString(record[@"provider"], 32);
219
- NSString *profileID = SanitizedShortString(record[@"profileId"], 128);
220
+ NSString *profileID = NormalizedAgentProfileID(record[@"profileId"]);
220
221
  NSString *session = SanitizedShortString(record[@"session"], 128);
221
222
  NSDictionary *terminal = [record[@"terminal"] isKindOfClass:NSDictionary.class] ? record[@"terminal"] : nil;
222
223
  NSString *terminalID = SanitizedShortString(terminal[@"ideTerminal"], 64);
@@ -226,15 +227,33 @@
226
227
  return [NSString stringWithFormat:@"%@|%@|%@", provider ?: @"", profileID ?: @"", identity ?: @""];
227
228
  }
228
229
  - (void)noteStatusIdentityForRecord:(NSDictionary *)record {
230
+ self.lastStatusRecord = record;
229
231
  self.lastStatusAgentProvider = SanitizedShortString(record[@"provider"], 32);
230
232
  self.lastStatusIdentity = [self statusIdentityForRecord:record];
233
+ // Bridge 注册表是定时刷新的:新会话的头一两条事件可能还对不上名字,先显示目录名,
234
+ // 下一条事件自然补成"目录名.动物"。
235
+ NSDictionary *bridge = [self bridgeSessionEntryForRecord:record];
236
+ NSString *cwd = SanitizedWorkingDirectory(record[@"cwd"]);
237
+ if (cwd.length == 0) cwd = SanitizedWorkingDirectory(bridge[@"cwd"]);
238
+ self.lastStatusSessionLabel = StatusSessionLabel(CCBridgeSessionShortName(bridge), cwd);
239
+ NSMutableArray<NSString *> *lines = [NSMutableArray array];
240
+ NSString *name = [bridge[@"name"] isKindOfClass:NSString.class] ? bridge[@"name"] : @"";
241
+ [lines addObject:name.length > 0 ? name : [self statusPresentationNameForRecord:record]];
242
+ if (cwd.length > 0) [lines addObject:cwd.stringByAbbreviatingWithTildeInPath];
243
+ [lines addObject:L(@"Go back to the Agent's terminal")];
244
+ self.lastStatusSessionTooltip = [lines componentsJoinedByString:@"\n"];
231
245
  }
232
246
  - (void)applyStatusPresentationForState:(NSString *)state provider:(NSString *)provider
233
247
  tool:(NSString *)tool {
234
248
  self.lastStatusState = state;
235
249
  self.lastStatusProvider = provider;
250
+ // 标题优先显示会话标签:多个会话同时在跑时,"Claude"分不出是哪一个,目录名.动物可以。
251
+ // 是哪家 Agent、完整路径放进悬停提示。
236
252
  self.statusTitleLabel.stringValue = [NSString stringWithFormat:@"%@ · %@",
237
- provider, [self statusTextForState:state tool:tool]];
253
+ self.lastStatusSessionLabel.length > 0 ? self.lastStatusSessionLabel : provider,
254
+ [self statusTextForState:state tool:tool]];
255
+ self.statusClickButton.toolTip = self.lastStatusSessionTooltip.length > 0
256
+ ? self.lastStatusSessionTooltip : L(@"Go back to the Agent's terminal");
238
257
  self.statusDetailLabel.stringValue = [self statusDetailForState:state tool:tool];
239
258
  // 上一句碎碎念借走的副行已经被新状态覆盖,取消那次归还,否则它会把旧文案写回来。
240
259
  [NSObject cancelPreviousPerformRequestsWithTarget:self
@@ -251,7 +270,7 @@
251
270
  [self layoutApprovalBadge];
252
271
  [self positionAgentStatus];
253
272
  [self notePetCardChanged];
254
- if (self.statusBubbleExpanded) {
273
+ if (self.statusBubbleExpanded && [self petVisible]) {
255
274
  [self.statusPanel orderFrontRegardless];
256
275
  // 卡片一出现就收掉独立气泡:两者都是宠物在说话,同时挂着就是重影。
257
276
  // 更新气泡也一样让开:agent 有新动静时状态卡优先,更新入口还有角标和菜单。
@@ -307,7 +326,7 @@
307
326
  self.hasAgentStatus = YES;
308
327
  [self noteStatusIdentityForRecord:record];
309
328
  [self applyStatusPresentationForState:state provider:presentationName tool:tool];
310
- [self.panel orderFrontRegardless];
329
+ if ([self petVisible]) [self.panel orderFrontRegardless];
311
330
  [self performSelector:@selector(hideAgentStatus)
312
331
  withObject:nil afterDelay:AgentStatusInactivityInterval];
313
332
  if ([state isEqualToString:@"starting"]) {
@@ -331,7 +350,8 @@
331
350
  NSTimeInterval cutoff = NSDate.date.timeIntervalSince1970 - PendingApprovalTTL;
332
351
  for (NSString *key in self.pendingApprovalRecords.allKeys) {
333
352
  NSDictionary *record = self.pendingApprovalRecords[key];
334
- if ([record[@"timestamp"] doubleValue] < cutoff) {
353
+ BOOL desktop = [record[@"provider"] isEqual:@"Codex"] && IsCodexDesktopFocusTarget(record[@"terminal"]);
354
+ if ([record[@"timestamp"] doubleValue] < cutoff || (desktop && ![self isAgentSessionRecordLive:record])) {
335
355
  [self.pendingApprovalRecords removeObjectForKey:key];
336
356
  }
337
357
  }
@@ -356,8 +376,12 @@
356
376
  NSString *tool = [record[@"tool"] isKindOfClass:NSString.class] ? record[@"tool"] : @"";
357
377
  NSString *animationEvent = [state isEqualToString:@"auto_review"]
358
378
  ? @"AutoReviewRequest" : event;
359
- [self.petView handleAgentEvent:animationEvent tool:tool
360
- failed:[record[@"failed"] boolValue]];
379
+ if ([event isEqual:@"ApprovalResolved"]) {
380
+ if ([state isEqual:@"idle"]) [self.petView resetAgentToIdle];
381
+ else [self.petView handleAgentEvent:@"UserPromptSubmit" tool:@"" failed:NO];
382
+ } else {
383
+ [self.petView handleAgentEvent:animationEvent tool:tool failed:[record[@"failed"] boolValue]];
384
+ }
361
385
  [self showAgentStatusForRecord:record notify:shouldNotify];
362
386
  // 说话是事件流的新消费者,不改变事件生产。冷启动重放已被 processAgentEventData
363
387
  // 的 recentOnly + 5 秒 cutoff 挡住,再加上预算制和冷却,最坏也只多说一句。
@@ -365,7 +389,7 @@
365
389
  }
366
390
  - (NSString *)agentSessionKeyForRecord:(NSDictionary *)record {
367
391
  NSString *provider = SanitizedShortString(record[@"provider"], 32);
368
- NSString *profileID = SanitizedShortString(record[@"profileId"], 128);
392
+ NSString *profileID = NormalizedAgentProfileID(record[@"profileId"]);
369
393
  NSString *identity = profileID.length > 0 ? [NSString stringWithFormat:@"%@|%@", provider, profileID] : provider;
370
394
  NSDictionary *terminal = [record[@"terminal"] isKindOfClass:NSDictionary.class]
371
395
  ? record[@"terminal"] : nil;
@@ -383,21 +407,76 @@
383
407
  ? record[@"terminal"] : nil;
384
408
  return OnlineAgentSessionKey(record[@"provider"], record[@"profileId"], terminal[@"tty"]);
385
409
  }
410
+ - (NSNumber *)desktopSessionPersistenceForRecord:(NSDictionary *)record {
411
+ if (![record[@"provider"] isEqual:@"Codex"] || !IsCodexDesktopFocusTarget(record[@"terminal"])) return nil;
412
+ if ([record[@"transient"] boolValue]) return @NO;
413
+ // 新会话的路径可能先于索引落盘;明确提供转录路径时不因索引延迟而丢掉首条事件。
414
+ if ([record[@"transcriptPath"] isKindOfClass:NSString.class] && [record[@"transcriptPath"] length] > 0) return @YES;
415
+ NSString *home = [record[@"codexHome"] isKindOfClass:NSString.class] ? record[@"codexHome"] : nil;
416
+ NSString *profile = NormalizedAgentProfileID(record[@"profileId"]);
417
+ if (home.length == 0 && profile.length > 0) home = CCPetsProfileWithID(profile)[@"home"];
418
+ if (home.length == 0 && profile.length == 0) home = DefaultCodexHomeDirectory();
419
+ return CodexPersistentThreadStatus(SanitizedShortString(record[@"session"], 128), home);
420
+ }
421
+
422
+ - (void)finishAgentSessionPresentation:(NSDictionary *)record {
423
+ NSString *session = SanitizedShortString(record[@"session"], 128);
424
+ if (!self.hasAgentStatus || session.length == 0 ||
425
+ ![self.lastStatusRecord[@"session"] isEqual:session] ||
426
+ ![self.lastStatusRecord[@"provider"] isEqual:record[@"provider"]]) return;
427
+ // 内部记录已删除后,屏幕也必须同步切换,不能把已结束会话的“思考”留到超时。
428
+ NSDictionary *replacement = nil;
429
+ for (NSDictionary *candidate in self.agentSessionRecords.allValues) {
430
+ if (![self isAgentSessionRecordLive:candidate]) continue;
431
+ if (!replacement || [candidate[@"timestamp"] doubleValue] > [replacement[@"timestamp"] doubleValue]) {
432
+ replacement = candidate;
433
+ }
434
+ }
435
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideAgentStatus) object:nil];
436
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(enterIdleStatus) object:nil];
437
+ if (replacement) {
438
+ if ([replacement[@"state"] isEqual:@"idle"]) {
439
+ [self.petView resetAgentToIdle];
440
+ } else {
441
+ [self.petView handleAgentEvent:replacement[@"event"] tool:replacement[@"tool"]
442
+ failed:[replacement[@"failed"] boolValue]];
443
+ }
444
+ [self showAgentStatusForRecord:replacement notify:NO];
445
+ } else {
446
+ [self.petView resetAgentToIdle];
447
+ [self hideAgentStatus];
448
+ self.lastStatusRecord = nil;
449
+ self.lastTerminalFocusTarget = nil;
450
+ }
451
+ }
386
452
  // 在线判定优先用包装脚本写出的 pid 文件:它给出精确的退出信号,会话一关列表就更新。
387
453
  // 但直接跑 claude / codex(或终端窗口早于 shim 安装就已打开)的会话根本没有 pid 文件,
388
454
  // 只按 pid 文件判定会把它们当场判死,列表里永远看不到——哪怕它们的 Hook 正在正常发事件。
389
- // 这类会话退回活跃度宽限:最近一次事件在静默窗口内就算在线。某个 provider 一旦出现过
390
- // pid 文件,说明包装脚本对它生效,继续按精确信号判定,不被宽限盖住。
455
+ // 桌面会话按应用实例判断;未经过包装器的终端退回活跃度宽限。
456
+ // 只能用精确的账号 + tty 判断某个包装器是否已退出,不能用整个 provider 排除其他会话。
391
457
  - (BOOL)isAgentSessionRecordLive:(NSDictionary *)record {
458
+ if ([record[@"event"] isEqual:@"SessionEnd"]) return NO;
459
+ NSDictionary *terminal = [record[@"terminal"] isKindOfClass:NSDictionary.class]
460
+ ? record[@"terminal"] : nil;
461
+ if ([record[@"provider"] isEqual:@"Codex"] && IsCodexDesktopFocusTarget(terminal)) {
462
+ if ([record[@"transient"] boolValue]) return NO;
463
+ if (![record[@"desktopPersistent"] boolValue]) {
464
+ // 无法证明是真实聊天的旧事件只给短暂宽限,不能靠宿主进程永久保活。
465
+ return NSDate.date.timeIntervalSince1970 - [record[@"timestamp"] doubleValue]
466
+ < AgentStatusInactivityInterval;
467
+ }
468
+ return CodexDesktopFocusTargetIsLive(terminal, [record[@"timestamp"] doubleValue]);
469
+ }
470
+ // Antigravity App 没有 pid 文件:App 退出即下线,在运行时按 Bridge 会话或活跃度判断。
471
+ if ([record[@"provider"] isEqual:CCBridgeAntigravityAppProvider] && !AntigravityDesktopApplicationIsRunning()) return NO;
392
472
  NSString *onlineKey = [self onlineAgentSessionKeyForRecord:record];
393
473
  if (onlineKey.length > 0 && [self.liveAgentSessionKeys containsObject:onlineKey]) return YES;
394
474
  // 老版本包装脚本的 pid 文件不带账号,只能按 provider + tty 认领。
395
- NSDictionary *terminal = [record[@"terminal"] isKindOfClass:NSDictionary.class]
396
- ? record[@"terminal"] : nil;
397
475
  NSString *unscopedKey = OnlineAgentSessionKey(record[@"provider"], nil, terminal[@"tty"]);
398
476
  if (unscopedKey.length > 0 && [self.liveAgentSessionKeys containsObject:unscopedKey]) return YES;
399
- NSString *provider = SanitizedShortString(record[@"provider"], 32);
400
- if (provider.length > 0 && [self.liveClientProviders containsObject:provider]) return NO;
477
+ if ([self.managedAgentSessionKeys containsObject:[self statusIdentityForRecord:record]]) return NO;
478
+ if (IsAntigravitySessionRecord(record) && CCBridgeEnabled() &&
479
+ CCBridgeSessionLive(CCBridgeReadSession(record[@"session"]))) return YES;
401
480
  return NSDate.date.timeIntervalSince1970 - [record[@"timestamp"] doubleValue]
402
481
  < AgentStatusInactivityInterval;
403
482
  }
@@ -418,8 +497,32 @@
418
497
  SanitizedShortString(terminal[@"bundleID"], 128), tty];
419
498
  }
420
499
  - (void)trackAgentSessionRecord:(NSDictionary *)record {
500
+ if ([record[@"event"] isEqual:@"SessionEnd"]) {
501
+ // 结束事件可能拿不到终端,用稳定的会话身份清理;不能清掉同账号的其他聊天。
502
+ NSString *session = SanitizedShortString(record[@"session"], 128);
503
+ if (session.length == 0) return;
504
+ for (NSString *existingKey in self.agentSessionRecords.allKeys) {
505
+ NSDictionary *existing = self.agentSessionRecords[existingKey];
506
+ if ([existing[@"session"] isEqual:session] && [existing[@"provider"] isEqual:record[@"provider"]]) {
507
+ [self.agentSessionRecords removeObjectForKey:existingKey];
508
+ [self notePetCardChanged];
509
+ }
510
+ }
511
+ return;
512
+ }
421
513
  NSString *key = [self agentSessionKeyForRecord:record];
422
514
  if (key.length == 0) return;
515
+ NSDictionary *previous = self.agentSessionRecords[key];
516
+ if ([[self statusIdentityForRecord:previous] isEqual:[self statusIdentityForRecord:record]] &&
517
+ [self isTrailingRecord:record afterState:previous[@"state"]]) return;
518
+ NSString *onlineKey = [self onlineAgentSessionKeyForRecord:record];
519
+ NSDictionary *terminal = [record[@"terminal"] isKindOfClass:NSDictionary.class] ? record[@"terminal"] : nil;
520
+ NSString *legacyKey = OnlineAgentSessionKey(record[@"provider"], nil, terminal[@"tty"]);
521
+ if ((onlineKey && [self.liveAgentSessionKeys containsObject:onlineKey]) ||
522
+ (legacyKey && [self.liveAgentSessionKeys containsObject:legacyKey])) {
523
+ if (!self.managedAgentSessionKeys) self.managedAgentSessionKeys = [NSMutableSet set];
524
+ [self.managedAgentSessionKeys addObject:[self statusIdentityForRecord:record]];
525
+ }
423
526
  if (!self.agentSessionRecords) self.agentSessionRecords = [NSMutableDictionary dictionary];
424
527
  // 一个终端前台同时只跑一个客户端。同一终端里新起的会话(可能换了账号)说明之前那个
425
528
  // 已经退出;它退出时不会补发结束事件,不在这里清掉就会在列表里留一行"正在启动"。
@@ -527,7 +630,7 @@
527
630
  [self applyStatusPresentationForState:state
528
631
  provider:[self statusPresentationNameForRecord:record]
529
632
  tool:[record[@"tool"] isKindOfClass:NSString.class] ? record[@"tool"] : @""];
530
- [self.panel orderFrontRegardless];
633
+ if ([self petVisible]) [self.panel orderFrontRegardless];
531
634
  [self performSelector:@selector(hideAgentStatus) withObject:nil
532
635
  afterDelay:AgentStatusInactivityInterval];
533
636
  }
@@ -1,5 +1,6 @@
1
1
  // CC Bridge 开关、消息角标与菜单。
2
2
  #import "CCPetsAppDelegate+Private.h"
3
+ #import "CCPetsBridgeStore.h"
3
4
 
4
5
  @implementation AppDelegate (Bridge)
5
6
  // 菜单开关 → cc-pets bridge enable / disable / configure。逻辑全在 CLI 里,桌宠只负责调用,
@@ -70,10 +71,13 @@
70
71
  if (sender.action == @selector(toggleBridgeEnabled:)) return CCBridgeEnabled();
71
72
  if (sender.action == @selector(toggleBridgeWake:)) return [options[@"wake"] boolValue];
72
73
  if (sender.action == @selector(toggleBridgeEditGuard:)) return [options[@"editGuard"] boolValue];
74
+ if (sender.action == @selector(toggleBridgeTabTitle:)) return [options[@"tabTitle"] boolValue];
73
75
  if (sender.action == @selector(toggleBridgeApproval:)) {
74
76
  NSSet *tools = [NSSet setWithArray:CCBridgeToolGroup([self bridgeApprovalGroupForTag:sender.tag])];
77
+ BOOL hasAntigravity = CCPetsProfilesForProvider(CCPetsProfileProviderAntigravity).count > 0;
75
78
  return tools.count > 0 && [tools isSubsetOfSet:[NSSet setWithArray:options[@"codexApprove"]]] &&
76
- [tools isSubsetOfSet:[NSSet setWithArray:options[@"claudeAllow"]]];
79
+ [tools isSubsetOfSet:[NSSet setWithArray:options[@"claudeAllow"]]] &&
80
+ (!hasAntigravity || [tools isSubsetOfSet:[NSSet setWithArray:options[@"antigravityAllow"]]]);
77
81
  }
78
82
  return NO;
79
83
  }
@@ -98,7 +102,7 @@
98
102
  ? L(@"Enabled. Running Codex sessions need a restart and must be trusted in /hooks; Claude sessions get the cc-bridge tools after a restart.")
99
103
  : L(@"Disabled. The related hooks and MCP registrations were removed.")];
100
104
  }
101
- // 一个分组同时作用于 Codex 免审批与 Claude 免确认:菜单上只有一组开关,两边保持一致。
105
+ // 菜单上的一个分组同时更新已集成 Agent 各自的工具权限。
102
106
  - (void)toggleBridgeApproval:(NSButton *)sender {
103
107
  NSArray<NSString *> *tools = CCBridgeToolGroup([self bridgeApprovalGroupForTag:sender.tag]);
104
108
  if (tools.count == 0) return;
@@ -109,10 +113,13 @@
109
113
  if (allow) [next addObjectsFromArray:tools]; else [next removeObjectsInArray:tools];
110
114
  return [next.array componentsJoinedByString:@","];
111
115
  };
112
- [self runBridgeCommand:@[@"configure",
116
+ NSMutableArray *command = [@[@"configure",
113
117
  [@"--codex-approve=" stringByAppendingString:apply(options[@"codexApprove"])],
114
- [@"--claude-allow=" stringByAppendingString:apply(options[@"claudeAllow"])]]
115
- sender:sender successMessage:nil];
118
+ [@"--claude-allow=" stringByAppendingString:apply(options[@"claudeAllow"])]] mutableCopy];
119
+ if (CCPetsProfilesForProvider(CCPetsProfileProviderAntigravity).count > 0) {
120
+ [command addObject:[@"--agy-allow=" stringByAppendingString:apply(options[@"antigravityAllow"])]];
121
+ }
122
+ [self runBridgeCommand:command sender:sender successMessage:nil];
116
123
  }
117
124
  - (void)toggleBridgeWake:(NSButton *)sender {
118
125
  [self runBridgeCommand:@[@"configure",
@@ -123,6 +130,11 @@
123
130
  [self targetBridgeStateForSwitch:sender] ? @"--edit-guard=on" : @"--edit-guard=off"]
124
131
  sender:sender successMessage:nil];
125
132
  }
133
+ - (void)toggleBridgeTabTitle:(NSButton *)sender {
134
+ [self runBridgeCommand:@[@"configure",
135
+ [self targetBridgeStateForSwitch:sender] ? @"--tab-title=on" : @"--tab-title=off"]
136
+ sender:sender successMessage:nil];
137
+ }
126
138
  - (void)toggleBridgeBadge:(NSButton *)sender {
127
139
  BOOL enabled = !CCPetsPrefBool(BridgeBadgeEnabledKey);
128
140
  [self updateBridgeBadgeEnabled:enabled];
@@ -206,9 +218,9 @@
206
218
  if (![NSUserDefaults.standardUserDefaults boolForKey:BridgeNotificationKey]) return;
207
219
  NSDictionary *latest = fresh.firstObject;
208
220
  NSString *body = fresh.count == 1
209
- ? [NSString stringWithFormat:@"%@ → %@", latest[@"from"], latest[@"to"]]
210
- : [NSString stringWithFormat:L(@"%1$@ → %2$@ and %3$lu more"), latest[@"from"], latest[@"to"],
211
- (unsigned long)fresh.count];
221
+ ? [NSString stringWithFormat:@"%@ → %@", CCBridgeSessionDisplayName(latest[@"fromIdentity"]), CCBridgeSessionDisplayName(latest[@"toIdentity"])]
222
+ : [NSString stringWithFormat:L(@"%1$@ → %2$@ and %3$lu more"), CCBridgeSessionDisplayName(latest[@"fromIdentity"]), CCBridgeSessionDisplayName(latest[@"toIdentity"]),
223
+ (unsigned long)fresh.count - 1];
212
224
  [self sendNotificationWithTitle:L(@"New CC Bridge Message") body:body];
213
225
  }
214
226
  // 蓝色 = 有新的跨会话消息送达;橙色 = 有消息卡在某个会话的信箱里(那个 Claude 会话长时间空闲、
@@ -283,7 +295,8 @@
283
295
  NSMenuItem *heading = [menu addItemWithTitle:L(@"CC Bridge Messages") action:nil keyEquivalent:@""];
284
296
  heading.enabled = NO;
285
297
  [pending enumerateKeysAndObjectsUsingBlock:^(NSString *session, NSNumber *count, BOOL *stop) {
286
- NSString *name = self.bridgeSessions[session][@"name"] ?: session;
298
+ NSString *name = CCBridgeSessionDisplayName(self.bridgeSessions[session]);
299
+ if (name.length == 0) name = session;
287
300
  NSString *title = [NSString stringWithFormat:count.unsignedLongValue != 1
288
301
  ? L(@"📬 %1$@ has %2$lu undelivered messages (say anything in that terminal to deliver)")
289
302
  : L(@"📬 %1$@ has %2$lu undelivered message (say anything in that terminal to deliver)"),
@@ -300,11 +313,11 @@
300
313
  dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle];
301
314
  BOOL unseen = [delivery[@"at"] doubleValue] > self.bridgeSeenAt;
302
315
  NSString *title = [NSString stringWithFormat:@"%@%@ → %@ · %@",
303
- unseen ? @"✉️ " : @"", delivery[@"from"], delivery[@"to"], time];
316
+ unseen ? @"✉️ " : @"", CCBridgeSessionDisplayName(delivery[@"fromIdentity"]), CCBridgeSessionDisplayName(delivery[@"toIdentity"]), time];
304
317
  NSMenuItem *item = [menu addItemWithTitle:title action:@selector(focusBridgeSession:) keyEquivalent:@""];
305
318
  item.target = self;
306
319
  item.representedObject = delivery[@"toSession"];
307
- item.toolTip = [NSString stringWithFormat:L(@"Jump to %@'s terminal"), delivery[@"to"]];
320
+ item.toolTip = [NSString stringWithFormat:L(@"Jump to %@'s terminal"), CCBridgeSessionDisplayName(delivery[@"toIdentity"])];
308
321
  }
309
322
  }
310
323
  @end
@@ -0,0 +1,86 @@
1
+ // 显示位置:仅桌宠 / 桌宠 + 菜单栏 / 仅菜单栏。
2
+ //
3
+ // 「仅菜单栏」只关掉桌面上看得见的东西:桌宠窗口、状态卡、说话气泡、悬停面板和更新气泡。
4
+ // 事件读取、会话记录、额度采集、系统通知照常运行,菜单栏图标和主窗口都靠它们。
5
+ // 浮层各自的显示入口在 petVisible 为 NO 时直接不弹,不在这里逐个追着关。
6
+ #import "CCPetsAppDelegate+Private.h"
7
+
8
+ @implementation AppDelegate (MenuBar)
9
+
10
+ - (BOOL)petVisible {
11
+ return ![CCPetsDisplayMode() isEqualToString:CCPetsDisplayModeMenuBar];
12
+ }
13
+
14
+ - (BOOL)menuBarVisible {
15
+ return ![CCPetsDisplayMode() isEqualToString:CCPetsDisplayModePet];
16
+ }
17
+
18
+ - (void)updateDisplayMode:(NSString *)mode {
19
+ if (CCPetsPrefSetObject(CCPetsDisplayModeKey, mode)) [self applyDisplayMode];
20
+ }
21
+
22
+ // 菜单栏图标自己监听设置变更,改完数字当场刷新。
23
+ - (void)updateMenuBarShowsPercent:(BOOL)enabled {
24
+ CCPetsPrefSetBool(CCPetsMenuBarShowsPercentKey, enabled);
25
+ }
26
+
27
+ - (void)applyDisplayMode {
28
+ if ([self menuBarVisible] && !self.statusItemController) {
29
+ [self installStatusItem];
30
+ } else if (![self menuBarVisible] && self.statusItemController) {
31
+ [self.statusItemController invalidate];
32
+ self.statusItemController = nil;
33
+ }
34
+ if ([self petVisible]) [self showPetWindows];
35
+ else [self hidePetWindows];
36
+ [self.statusItemController refresh];
37
+ }
38
+
39
+ - (void)installStatusItem {
40
+ CCPetsStatusItemController *controller = [[CCPetsStatusItemController alloc] initWithSource:(id)self];
41
+ __weak typeof(self) weakSelf = self;
42
+ controller.petVisibleProvider = ^BOOL { return [weakSelf petVisible]; };
43
+ controller.stateColorProvider = ^NSColor *(NSString *state) { return [weakSelf statusColorForState:state]; };
44
+ // 菜单栏图标只在「桌宠 + 菜单栏」和「仅菜单栏」下存在,勾选项就在这两者之间切换。
45
+ controller.togglePetVisible = ^{
46
+ [weakSelf updateDisplayMode:[weakSelf petVisible] ? CCPetsDisplayModeMenuBar : CCPetsDisplayModeBoth];
47
+ };
48
+ controller.pendingUpdateVersionProvider = ^NSString * {
49
+ return weakSelf.updating ? nil : weakSelf.pendingUpdateVersion;
50
+ };
51
+ controller.showPendingUpdate = ^{ [weakSelf showPendingUpdate:nil]; };
52
+ // 右键和桌宠右键同一份菜单:启用 CC Bridge、免审批这些只在那里,仅菜单栏时不能没有入口。
53
+ controller.contextMenuProvider = ^NSMenu * { return [weakSelf.petView buildContextMenu]; };
54
+ controller.contextMenuFinished = ^{ [weakSelf.petView finishContextMenu]; };
55
+ self.statusItemController = controller;
56
+ }
57
+
58
+ - (void)showPetWindows {
59
+ [self.panel orderFrontRegardless];
60
+ [self.petView setAnimationSuspended:NO];
61
+ // 状态卡按原来的偏好还原;没有活跃会话时 updateStatusBubbleExpanded: 自己会保持隐藏。
62
+ [self updateStatusBubbleExpanded:self.statusBubbleExpanded];
63
+ [self refreshUpdateBadge];
64
+ }
65
+
66
+ - (void)hidePetWindows {
67
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
68
+ selector:@selector(hideQuotaDashboardIfNeeded) object:nil];
69
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
70
+ selector:@selector(hideSpeechBubble) object:nil];
71
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
72
+ selector:@selector(restoreStatusDetail) object:nil];
73
+ self.pocketHovering = NO;
74
+ self.dashboardHovering = NO;
75
+ self.updateBubbleVisible = NO;
76
+ self.updateBubbleSuppressedStatus = NO;
77
+ [self.quotaPanel orderOut:nil];
78
+ [self.speechPanel orderOut:nil];
79
+ [self.statusPanel orderOut:nil];
80
+ [CCPetsGlassMenu dismiss];
81
+ [self.panel orderOut:nil];
82
+ // 看不见的宠物不必逐帧动画,和屏幕睡眠走同一个开关。
83
+ [self.petView setAnimationSuspended:YES];
84
+ }
85
+
86
+ @end
@@ -18,8 +18,10 @@
18
18
  #import "MenuChoiceRow.h"
19
19
  #import "CCPetsGlassMenu.h"
20
20
  #import "CCPetsBridge.h"
21
+ #import "CCPetsBridgeStore.h"
21
22
  #import "CCPetsProfiles.h"
22
23
  #import "MenuToggleSwitch.h"
24
+ #import "CCPetsStatusItem.h"
23
25
  #import <UserNotifications/UserNotifications.h>
24
26
  #import <signal.h>
25
27
  #import <sys/stat.h>
@@ -102,6 +104,11 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
102
104
  // 用控件自己的 fittingSize 量,不要用 sizeWithAttributes:。
103
105
  // NSTextField 的 cell 有一点内部留白,纯按字符串量出来的宽度会比控件真正需要的小几个点,
104
106
  // 结果就是明明算着"刚好够",显示出来最后一两个字变成省略号。
107
+ // Antigravity CLI 与 App 的会话都登记在 CC Bridge,存活判断可以共用 Bridge 会话表。
108
+ static inline BOOL IsAntigravitySessionRecord(NSDictionary *record) {
109
+ id provider = record[@"provider"];
110
+ return [provider isEqual:CCBridgeAntigravityProvider] || [provider isEqual:CCBridgeAntigravityAppProvider];
111
+ }
105
112
  static inline CGFloat PetMeasuredLabelWidth(NSTextField *label) {
106
113
  if (label.stringValue.length == 0) return 0;
107
114
  return ceil(label.fittingSize.width) + 2;
@@ -184,6 +191,8 @@ static inline void PetResizeBubblePanel(NSPanel *panel, NSSize logicalSize) {
184
191
  - (void)setUsageDisplayModeFromControl:(NSButton *)sender;
185
192
  - (void)applySystemMetricPreferences;
186
193
  - (void)applyUsageDisplayModePreferences;
194
+ - (NSArray<NSString *> *)quotaCardOrderForSettings;
195
+ - (void)updateQuotaCardOrder:(NSArray<NSString *> *)order;
187
196
  - (void)showImportedCodexPetsAlert:(NSUInteger)imported;
188
197
  - (void)setPanelTheme:(MenuChoiceRowView *)sender;
189
198
  - (void)applyBubbleTextStyle;
@@ -218,6 +227,9 @@ static inline void PetResizeBubblePanel(NSPanel *panel, NSSize logicalSize) {
218
227
  - (void)displayAgentRecord:(NSDictionary *)record notify:(BOOL)shouldNotify;
219
228
  - (NSString *)agentSessionKeyForRecord:(NSDictionary *)record;
220
229
  - (NSString *)onlineAgentSessionKeyForRecord:(NSDictionary *)record;
230
+ - (NSString *)statusIdentityForRecord:(NSDictionary *)record;
231
+ - (NSNumber *)desktopSessionPersistenceForRecord:(NSDictionary *)record;
232
+ - (void)finishAgentSessionPresentation:(NSDictionary *)record;
221
233
  - (BOOL)isAgentSessionRecordLive:(NSDictionary *)record;
222
234
  - (void)pruneOfflineAgentSessionRecords;
223
235
  - (void)trackAgentSessionRecord:(NSDictionary *)record;
@@ -250,6 +262,7 @@ static inline void PetResizeBubblePanel(NSPanel *panel, NSSize logicalSize) {
250
262
  - (void)toggleBridgeApproval:(NSButton *)sender;
251
263
  - (void)toggleBridgeWake:(NSButton *)sender;
252
264
  - (void)toggleBridgeEditGuard:(NSButton *)sender;
265
+ - (void)toggleBridgeTabTitle:(NSButton *)sender;
253
266
  - (void)toggleBridgeBadge:(NSButton *)sender;
254
267
  - (void)updateBridgeBadgeEnabled:(BOOL)enabled;
255
268
  - (void)toggleBridgeNotification:(NSButton *)sender;
@@ -264,10 +277,20 @@ static inline void PetResizeBubblePanel(NSPanel *panel, NSSize logicalSize) {
264
277
  pending:(NSDictionary<NSString *, NSNumber *> *)pending;
265
278
  @end
266
279
 
280
+ // 显示位置:桌宠窗口与菜单栏图标的显隐。「仅菜单栏」时桌宠和它的浮层(状态卡、气泡、
281
+ // 悬停面板)都不出现,状态机照常运行,供菜单栏和系统通知使用。
282
+ @interface AppDelegate (MenuBar)
283
+ - (BOOL)petVisible;
284
+ - (void)applyDisplayMode;
285
+ - (void)updateDisplayMode:(NSString *)mode;
286
+ - (void)updateMenuBarShowsPercent:(BOOL)enabled;
287
+ @end
288
+
267
289
  // 用户显式添加、修复或移除 Claude/Codex Home。
268
290
  @interface AppDelegate (Profiles)
269
291
  - (void)addClaudeProfile:(id)sender;
270
292
  - (void)addCodexProfile:(id)sender;
293
+ - (void)addAntigravityProfile:(id)sender;
271
294
  - (void)repairAgentProfile:(NSMenuItem *)sender;
272
295
  - (void)renameAgentProfile:(NSMenuItem *)sender;
273
296
  - (void)relocateAgentProfile:(NSMenuItem *)sender;
@@ -313,7 +336,7 @@ static inline void PetResizeBubblePanel(NSPanel *panel, NSSize logicalSize) {
313
336
  - (void)scheduleQuotaDashboardHide;
314
337
  - (void)hideQuotaDashboardIfNeeded;
315
338
  - (void)refreshUsage:(id)sender;
316
- - (void)applyCodexUsage:(NSDictionary *)codexUsage claudeUsage:(NSDictionary *)claudeUsage;
339
+ - (void)applyUsageByProvider:(NSDictionary<NSString *, NSDictionary *> *)usageByProvider;
317
340
  - (void)rescheduleUsageTimer;
318
341
  - (BOOL)shouldRefreshUsageForDashboard;
319
342
  - (BOOL)hasEnabledSystemMetric;
@@ -11,6 +11,10 @@
11
11
  [self chooseProfileHomeForProvider:CCPetsProfileProviderCodex];
12
12
  }
13
13
 
14
+ - (void)addAntigravityProfile:(id)sender {
15
+ [self chooseProfileHomeForProvider:CCPetsProfileProviderAntigravity];
16
+ }
17
+
14
18
  // 设置页的按钮在命令执行期间仍可点,被挡下时要告诉用户,不能悄悄什么都不做。
15
19
  - (BOOL)rejectWhileProfileCommandRunning {
16
20
  if (!self.profileCommandRunning) return NO;
@@ -20,6 +24,8 @@
20
24
 
21
25
  - (void)chooseProfileHomeForProvider:(NSString *)provider {
22
26
  if ([self rejectWhileProfileCommandRunning]) return;
27
+ BOOL antigravity = [provider isEqualToString:CCPetsProfileProviderAntigravity];
28
+ BOOL claude = [provider isEqualToString:CCPetsProfileProviderClaude];
23
29
  NSOpenPanel *panel = [NSOpenPanel openPanel];
24
30
  panel.canChooseDirectories = YES;
25
31
  panel.canChooseFiles = NO;
@@ -27,18 +33,18 @@
27
33
  panel.canCreateDirectories = NO;
28
34
  panel.showsHiddenFiles = YES;
29
35
  panel.prompt = L(@"Choose Home");
30
- panel.message = [provider isEqualToString:CCPetsProfileProviderClaude]
31
- ? L(@"Choose an existing Claude Home folder, such as ~/.claude-work.")
36
+ if (antigravity) panel.message = L(@"Choose a Gemini root folder containing the antigravity-cli directory.");
37
+ else panel.message = claude ? L(@"Choose an existing Claude Home folder, such as ~/.claude-work.")
32
38
  : L(@"Choose an existing Codex Home folder, such as ~/.codex-work.");
33
39
  panel.directoryURL = [NSURL fileURLWithPath:CCPetsHomeDirectory() isDirectory:YES];
34
40
  [NSApp activateIgnoringOtherApps:YES];
35
41
  if ([panel runModal] != NSModalResponseOK) return;
36
42
  NSString *home = panel.URL.path;
37
43
  if (!CCPetsProfileHomeMatchesProvider(provider, home)) {
38
- [self showAlertWithTitle:L(@"This folder doesn't look like an Agent Home")
39
- message:[provider isEqualToString:CCPetsProfileProviderClaude]
40
- ? L(@"Choose a folder containing Claude settings, state, or projects.")
41
- : L(@"Choose a folder containing Codex config, hooks, or sign-in state.")];
44
+ NSString *message = antigravity ? L(@"Choose a Gemini root folder containing the antigravity-cli directory.")
45
+ : (claude ? L(@"Choose a folder containing Claude settings, state, or projects.")
46
+ : L(@"Choose a folder containing Codex config, hooks, or sign-in state."));
47
+ [self showAlertWithTitle:L(@"This folder doesn't look like an Agent Home") message:message];
42
48
  return;
43
49
  }
44
50
  NSString *name = CCPetsProfileDefaultDisplayName(provider, home);
@@ -53,11 +59,12 @@
53
59
  if ([confirm runModal] != NSAlertFirstButtonReturn) return;
54
60
  // 首次名称只是 Home 文件夹名,不算用户自定义;这样以后重新定位 Home 时,
55
61
  // 未主动重命名的账号名称仍会跟随新的文件夹名。
62
+ NSString *completionMessage = antigravity ? L(@"The Antigravity CLI Home is integrated. Restart agy to load the updated hooks and tools.")
63
+ : (claude ? L(@"The Claude Home is integrated. Restart Claude to load newly registered MCP tools.")
64
+ : L(@"The Codex Home is integrated. Restart Codex, then trust the CC Pets hooks in /hooks."));
56
65
  [self runProfileCommand:@[@"add", @"--provider", provider, @"--home", home]
57
66
  title:[NSString stringWithFormat:L(@"Configuring %@"), name]
58
- completionMessage:[provider isEqualToString:CCPetsProfileProviderClaude]
59
- ? L(@"The Claude Home is integrated. Restart Claude to load newly registered MCP tools.")
60
- : L(@"The Codex Home is integrated. Restart Codex, then trust the CC Pets hooks in /hooks.")];
67
+ completionMessage:completionMessage];
61
68
  }
62
69
 
63
70
  - (void)repairAgentProfile:(NSMenuItem *)sender {
@@ -101,14 +108,17 @@
101
108
  panel.canCreateDirectories = NO;
102
109
  panel.showsHiddenFiles = YES;
103
110
  panel.prompt = L(@"Choose Home");
104
- panel.message = L(@"Choose the new location for this Agent Home.");
111
+ BOOL antigravity = [profile[@"provider"] isEqualToString:CCPetsProfileProviderAntigravity];
112
+ panel.message = antigravity ? L(@"Choose a Gemini root folder containing the antigravity-cli directory.")
113
+ : L(@"Choose the new location for this Agent Home.");
105
114
  panel.directoryURL = [NSURL fileURLWithPath:profile[@"home"] isDirectory:YES];
106
115
  [NSApp activateIgnoringOtherApps:YES];
107
116
  if ([panel runModal] != NSModalResponseOK) return;
108
117
  NSString *home = panel.URL.path;
109
118
  if (!CCPetsProfileHomeMatchesProvider(profile[@"provider"], home)) {
110
119
  [self showAlertWithTitle:L(@"This folder doesn't look like an Agent Home")
111
- message:L(@"Choose a folder containing the selected Agent's settings or state.")];
120
+ message:antigravity ? L(@"Choose a Gemini root folder containing the antigravity-cli directory.")
121
+ : L(@"Choose a folder containing the selected Agent's settings or state.")];
112
122
  return;
113
123
  }
114
124
  [self runProfileCommand:@[@"update", @"--id", profileID, @"--home", home]