Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): 灵动岛新增 Cindy/黑猫/Erika 三个角色皮肤 (#709)
aj0928963048ff3ce6
diff --git a/apps/desktop/native/agent-island/AGENTS.md b/apps/desktop/native/agent-island/AGENTS.mdnew file mode 100644index 0000000000..b92d63a0ee--- /dev/null+++ b/apps/desktop/native/agent-island/AGENTS.md@@ -0,0 +1,65 @@+# 灵动岛原生 helper:角色(mascot)开发说明++本目录是 macOS 灵动岛的 SwiftUI helper(`macos-agent-island-helper.swift`,单文件、+顶层脚本模式)与其素材。产品运行时由 `src/main/agent-island/MacAgentIslandNativeHost.ts`+以子进程方式拉起,通过 stdin/stdout 逐行 JSON 通信。++## 角色动画预览(开发调试)++```bash+pnpm --filter desktop preview:island-mascots+```++会用 `swiftc` 编译本目录的 helper,并以命令行参数 `--mascot-preview` 启动一个+独立预览窗口:**行 = 角色,列 = 动画状态**,可切 Dark / Light / 两种模式同屏、切换真实+渲染尺寸档位、放大倍数、暂停动画、从头播放。关窗即退出进程。++尺寸档位给的是产品里的**真实值**,取自 helper 内 `AgentIslandMascotView` / `RunningMascotIcon`+的各个调用点(grep `AgentIslandMascotView(` 可一次看全):16pt(收起 pill)、18pt(紧凑行与+`RunningMascotIcon`)、20pt(展开态)、40pt(设置页「图标皮肤」列表的角色本体,renderer 侧+`h-10 w-10`,见 `AgentIslandSection.tsx`;那套 UI 是 React/CSS 重画的,档位只作同尺寸参照)。+默认 20pt 且 1:1 显示 —— 角色在灵动岛里本来就只有 20pt 上下,+放大档位只做 `scaleEffect` 视觉缩放、不改渲染尺寸,所以放大后看到的几何比例仍是真实的。+调角色参数时**不要**靠放大后的观感下结论,最终一定要回到 1× 看。++这条分支只创建普通窗口,不读 stdin、不创建刘海面板,因此不会干扰正在运行的 Cindy。++另有一个更早的单状态 harness:`XDT_AGENT_ISLAND_DEBUG=idle|completion|interaction`+(见 `AgentIslandDebugHarness`),用来在真实刘海面板里看整块 UI,与角色预览互补。+日志开关是 `XDT_AGENT_ISLAND_DEBUG_LOGS=1`。++## 新增一个角色++角色 = 一张身体 PNG + 一组眼睛几何参数 + 一套配色,**动画时间线是所有角色共享的**+(`SpriteMascotView`:`idle` / `working` / `waitingApproval` / `completed`),新增角色+不需要写动画代码。++1. `mascots/<skin>.png` —— 128×128 透明底(`whitesnow` 是 134×134 的历史例外,不要照抄)+2. `macos-agent-island-helper.swift`+ - 顶部加 `<skin>MascotFileName` 常量+ - `AgentIslandAssets` 加 `<skin>MascotImage`+ - `SpriteMascotConfig` 加 `static let <skin>`(眼睛坐标按素材实际眼位量)+ - `AgentIslandMascotCatalog.skins` 加 id,`spriteConfig(for:)` 加 case+3. `src/shared/agentIsland.ts` —— `AgentIslandMascotSkin` 类型 + `AGENT_ISLAND_MASCOT_SKINS`+4. 设置页 —— `src/renderer/assets/agent-island-<skin>.png` 预览图,以及+ `AgentIslandSection.tsx` 里的 `MASCOT_PREVIEW_URLS` / `MASCOT_PREVIEW_CONFIGS`+5. 角色名文案走 i18n,先查 `i18n/GLOSSARY.md`++角色清单的单一真源是 `AgentIslandMascotCatalog.skins`(Swift 侧)与+`AGENT_ISLAND_MASCOT_SKINS`(TS 侧),两处必须一致;预览网格从前者派生,所以加完+第 2 步就能在预览窗口里看到新角色的全部状态。++## 本文件的两个 SwiftUI 陷阱++单文件顶层脚本(`main.swift` 语义)下踩过的坑,改这个文件时注意:++1. **`@State` 的内联默认值不可靠**,会退化成零值(`false` / `0`)。现有视图之所以正常,+ 是因为它们的期望初值恰好就是零值,或在 `onAppear` 里显式重置。需要非零初值时,把状态+ 放到 `ObservableObject` 的 `init` 里显式赋值(见 `AgentIslandMascotPreviewModel`)。+2. **控件初值会被吞掉**。`Slider` 首帧会把绑定值写回下界(`CGFloat`/`Double` 都复现),+ `Picker` 会写回首项。预览工具条因此改成自绘的 `AgentIslandPreviewChoice`(Button ++ 自管高亮,显示与 model 必然一致)。+ 遗留未解:换成自绘按钮后,`AgentIslandMascotPreviewModel.init` 里 `zoom = 3` 仍然只生效+ 为 `1`(=档位首项),而同一个 init 里的 `appearance` / `mascotSize` / `animationsActive`+ 初值都正常。根因未查明,当前把 `zoom` 默认值取成首项 `1` 规避(1× 也正是我们想要的默认+ 真实尺寸)。若以后要给这类档位设非首项默认值,先验证初值有没有被改写。diff --git a/apps/desktop/native/agent-island/macos-agent-island-helper.swift b/apps/desktop/native/agent-island/macos-agent-island-helper.swiftindex 47e60a0ad4..125fe50d81 100644--- a/apps/desktop/native/agent-island/macos-agent-island-helper.swift+++ b/apps/desktop/native/agent-island/macos-agent-island-helper.swift@@ -742,6 +742,111 @@ struct SpriteMascotConfig {eyeRyOpen: 0.98,eyeRyClosedAdd: 0.08)++ // 以下三个角色的参数来源(2026-07-27):眼睛几何由「带眼睛版」与「无眼睛版」素材做像素+ // diff 得到 bbox 再换算到 16 单位坐标;眼睛/感叹号/完成徽章的颜色直接取自设计给的色板。+ // 眼睛形状(Rx/Ry/闭眼增量)按设计要求复用 tarara,只有位置和颜色按各自素材实测。++ /// 眼睛:深棕 #6B3D32,形状复用 tarara。+ static let cindy = SpriteMascotConfig(+ image: AgentIslandAssets.cindyMascotImage.map { Image(nsImage: $0) },+ fallbackColor: Color(red: 0.251, green: 0.255, blue: 0.322),+ alertColor: Color(red: 0.875, green: 0.180, blue: 0.153),+ completionBadgeColor: Color(red: 0.404, green: 0.463, blue: 0.941),+ eyeColor: Color(red: 0.420, green: 0.239, blue: 0.196),+ approvalGlowColor: Color(red: 0.875, green: 0.180, blue: 0.153),+ keyboardBaseColor: Color(red: 0.149, green: 0.169, blue: 0.271),+ keyboardKeyColor: Color(red: 0.404, green: 0.463, blue: 0.941),+ bodyScale: 1.0,+ eyeLeftX: 6.71,+ eyeRightX: 9.30,+ eyeY: 9.50,+ eyeRxBase: 0.585,+ eyeRxClosedAdd: 0.55,+ eyeRyMin: 0.40,+ eyeRyOpen: 0.98,+ eyeRyClosedAdd: 0.08+ )++ /// 眼睛:黄色 #FDCF45,形状复用 tarara(与 chaku 同一套)。+ /// 位置不用带眼版素材的实测值(6.25/9.75/9.50):那版素材的眼睛只有 0.76 宽,换成 tarara+ /// 的 1.17 宽眼型后同样间距会显挤、重心偏低,所以外移到间距 4.10 并上提到 9.05。+ static let blackcat = SpriteMascotConfig(+ image: AgentIslandAssets.blackcatMascotImage.map { Image(nsImage: $0) },+ fallbackColor: Color(red: 0.169, green: 0.196, blue: 0.220),+ alertColor: Color(red: 0.875, green: 0.180, blue: 0.153),+ completionBadgeColor: Color(red: 0.404, green: 0.463, blue: 0.941),+ eyeColor: Color(red: 0.992, green: 0.812, blue: 0.271),+ approvalGlowColor: Color(red: 0.875, green: 0.180, blue: 0.153),+ keyboardBaseColor: Color(red: 0.122, green: 0.141, blue: 0.161),+ keyboardKeyColor: Color(red: 0.404, green: 0.463, blue: 0.941),+ bodyScale: 1.0,+ eyeLeftX: 5.95,+ eyeRightX: 10.05,+ eyeY: 9.05,+ eyeRxBase: 0.585,+ eyeRxClosedAdd: 0.55,+ eyeRyMin: 0.40,+ eyeRyOpen: 0.98,+ eyeRyClosedAdd: 0.08+ )++ /// 眼睛:棕 #875D42,形状复用 tarara;眼位比 cindy 更低。+ static let erika = SpriteMascotConfig(+ image: AgentIslandAssets.erikaMascotImage.map { Image(nsImage: $0) },+ fallbackColor: Color(red: 0.329, green: 0.302, blue: 0.337),+ alertColor: Color(red: 0.953, green: 0.796, blue: 0.314),+ completionBadgeColor: Color(red: 0.353, green: 0.612, blue: 0.667),+ eyeColor: Color(red: 0.529, green: 0.365, blue: 0.259),+ approvalGlowColor: Color(red: 0.953, green: 0.796, blue: 0.314),+ keyboardBaseColor: Color(red: 0.200, green: 0.278, blue: 0.302),+ keyboardKeyColor: Color(red: 0.353, green: 0.612, blue: 0.667),+ bodyScale: 1.0,+ eyeLeftX: 6.84,+ eyeRightX: 9.16,+ eyeY: 10.75,+ eyeRxBase: 0.585,+ eyeRxClosedAdd: 0.55,+ eyeRyMin: 0.40,+ eyeRyOpen: 0.98,+ eyeRyClosedAdd: 0.08+ )+}++/// 灵动岛角色清单与查表:新增角色时只改这里(加 `skins` 条目 + `spriteConfig` 分支),+/// 运行时渲染和 `preview:island-mascots` 预览网格都会自动覆盖新角色。+/// `skins` 必须与 `src/shared/agentIsland.ts` 的 `AGENT_ISLAND_MASCOT_SKINS` 保持一致。+enum AgentIslandMascotCatalog {+ /// 顺序与 `src/shared/agentIsland.ts` 的 `AGENT_ISLAND_MASCOT_SKINS` 一致+ /// (也就是设置页列表的展示顺序),预览网格同样按这个顺序铺。+ static let skins: [String] = [+ "cindy",+ "blackcat",+ "pululu",+ "tarara",+ "boli",+ "whitesnow",+ "annie",+ "chaku",+ "muffin",+ "erika",+ ]++ /// PNG 贴图角色的渲染参数;返回 nil 表示该皮肤走矢量绘制(pululu)。+ static func spriteConfig(for skin: String) -> SpriteMascotConfig? {+ switch skin {+ case "tarara": return .tarara+ case "boli": return .boli+ case "whitesnow": return .whitesnow+ case "annie": return .annie+ case "chaku": return .chaku+ case "muffin": return .muffin+ case "cindy": return .cindy+ case "blackcat": return .blackcat+ case "erika": return .erika+ default: return nil+ }+ }}/// Runtime mascot renderer for PNG-backed skins with shared animation timing.@@ -1482,12 +1587,10 @@ struct AgentIslandDisplayState: Codable {}var displayMascotSkin: String {- switch mascotSkin {- case "tarara", "boli", "whitesnow", "annie", "chaku", "muffin":- return mascotSkin ?? defaultAgentIslandMascotSkin- default:+ guard let skin = mascotSkin, AgentIslandMascotCatalog.skins.contains(skin) else {return defaultAgentIslandMascotSkin}+ return skin}}@@ -1582,6 +1685,9 @@ private let whitesnowMascotFileName = "whitesnow.png"private let annieMascotFileName = "annie.png"private let chakuMascotFileName = "chaku.png"private let muffinMascotFileName = "muffin.png"+private let cindyMascotFileName = "cindy.png"+private let blackcatMascotFileName = "blackcat.png"+private let erikaMascotFileName = "erika.png"private let defaultAgentIslandMascotSkin = "pululu"// Keep these mono Agent identity marks aligned with renderer ClaudeMark/CodexMark.// The native copies remain template images so Agent Island can apply status colors.@@ -1671,6 +1777,18 @@ private enum AgentIslandAssets {mascotImage(fileName: muffinMascotFileName, size: NSSize(width: 128, height: 128))}()+ static let cindyMascotImage: NSImage? = {+ mascotImage(fileName: cindyMascotFileName, size: NSSize(width: 128, height: 128))+ }()++ static let blackcatMascotImage: NSImage? = {+ mascotImage(fileName: blackcatMascotFileName, size: NSSize(width: 128, height: 128))+ }()++ static let erikaMascotImage: NSImage? = {+ mascotImage(fileName: erikaMascotFileName, size: NSSize(width: 128, height: 128))+ }()+private static func runningAgentGifCandidateURLs() -> [URL] {var urls: [URL] = []let environment = ProcessInfo.processInfo.environment@@ -4041,20 +4159,9 @@ struct AgentIslandMascotView: View {let size: CGFloatvar body: some View {- switch skin {- case "tarara":- SpriteMascotView(size: size, state: state, config: .tarara)- case "boli":- SpriteMascotView(size: size, state: state, config: .boli)- case "whitesnow":- SpriteMascotView(size: size, state: state, config: .whitesnow)- case "annie":- SpriteMascotView(size: size, state: state, config: .annie)- case "chaku":- SpriteMascotView(size: size, state: state, config: .chaku)- case "muffin":- SpriteMascotView(size: size, state: state, config: .muffin)- default:+ if let config = AgentIslandMascotCatalog.spriteConfig(for: skin) {+ SpriteMascotView(size: size, state: state, config: config)+ } else {PululuMascotView(size: size, state: state)}}@@ -6217,11 +6324,324 @@ enum AgentIslandDebugHarness {}}+// MARK: - 角色预览网格(开发调试用,不参与产品运行路径)++private let agentIslandMascotPreviewStates: [(state: AgentIslandMascotAnimationState, label: String)] = [+ (.idle, "idle"),+ (.working, "working"),+ (.waitingApproval, "waitingApproval"),+ (.completed, "completed"),+]++private enum AgentIslandMascotPreviewAppearance: String, CaseIterable, Identifiable {+ case dark+ case light+ case both++ var id: String { rawValue }++ var title: String {+ switch self {+ case .dark: return "Dark"+ case .light: return "Light"+ case .both: return "两种模式"+ }+ }+}++/// 预览窗口的启动开关(命令行参数,不走环境变量:见 AgentIslandMascotPreview 的说明)。+private let agentIslandMascotPreviewFlag = "--mascot-preview"++private let agentIslandMascotPreviewZooms: [Double] = [1, 2, 3, 4, 6, 8]++/// 角色在产品里的真实渲染尺寸:+/// 16pt 收起 pill、18pt 紧凑行、20pt 展开态(灵动岛原生,本文件的调用点);+/// 40pt 是设置页「图标皮肤」列表里的角色本体尺寸(renderer 的 `h-10 w-10`,+/// 见 AgentIslandSection.tsx `MascotPreviewImage` / `SpriteMascotPreview`)。+/// 设置页那套是 React/CSS 重画的,这里只作同尺寸参照,用来核对放大后的形态。+private let agentIslandMascotRealSizes: [(size: Double, label: String)] = [+ (16, "16 收起"),+ (18, "18 紧凑"),+ (20, "20 展开"),+ (40, "40 设置页"),+]++/// 单个「角色 × 状态」格子。底板只是预览用的对比背景,不代表产品视觉规范。+/// `size` 始终是产品真实渲染尺寸,`zoom` 只做视觉放大(几何比例不变),便于肉眼看清细节。+private struct AgentIslandMascotPreviewCell: View {+ let skin: String+ let state: AgentIslandMascotAnimationState+ let label: String+ let size: CGFloat+ let zoom: CGFloat+ let isDark: Bool++ private var boxSide: CGFloat { size * zoom + 24 }++ var body: some View {+ VStack(spacing: 6) {+ ZStack {+ RoundedRectangle(cornerRadius: 12, style: .continuous)+ .fill(isDark ? Color(white: 0.06) : Color(white: 0.97))+ RoundedRectangle(cornerRadius: 12, style: .continuous)+ .strokeBorder(isDark ? Color(white: 1.0, opacity: 0.10) : Color(white: 0.0, opacity: 0.10))+ AgentIslandMascotView(skin: skin, state: state, size: size)+ .scaleEffect(zoom)+ }+ .frame(width: boxSide, height: boxSide)+ Text(label)+ .font(.system(size: 10, weight: .medium, design: .monospaced))+ .foregroundStyle(.secondary)+ }+ }+}++/// 一整块网格:行 = 角色(取自 `AgentIslandMascotCatalog.skins`),列 = 动画状态。+private struct AgentIslandMascotPreviewGrid: View {+ let size: CGFloat+ let zoom: CGFloat+ let isDark: Bool++ var body: some View {+ VStack(alignment: .leading, spacing: 18) {+ ForEach(AgentIslandMascotCatalog.skins, id: \.self) { skin in+ HStack(alignment: .top, spacing: 16) {+ VStack(alignment: .leading, spacing: 2) {+ Text(skin)+ .font(.system(size: 12, weight: .semibold, design: .monospaced))+ Text(AgentIslandMascotCatalog.spriteConfig(for: skin) == nil ? "vector" : "sprite")+ .font(.system(size: 9))+ .foregroundStyle(.tertiary)+ }+ .frame(width: 96, alignment: .leading)+ .padding(.top, max(0, size * zoom / 2 - 8))++ ForEach(agentIslandMascotPreviewStates, id: \.label) { entry in+ AgentIslandMascotPreviewCell(+ skin: skin,+ state: entry.state,+ label: entry.label,+ size: size,+ zoom: zoom,+ isDark: isDark+ )+ }+ }+ }+ }+ }+}++/// 预览控件状态。本文件是顶层脚本(main.swift)模式,`@State` 的内联默认值在这里不可靠+/// (会退化成零值),所以初值统一放到这个 model 的 init 里显式赋。+/// 另外这里的控件一律用 `Picker` 而不是 `Slider`:`Slider` 在本文件里出现过首帧把绑定值+/// 写回下界(初值丢失),宽度受限时尤其容易触发。+private final class AgentIslandMascotPreviewModel: ObservableObject {+ @Published var appearance: AgentIslandMascotPreviewAppearance+ @Published var mascotSize: Double+ @Published var zoom: Double+ @Published var animationsActive: Bool+ @Published var animationEpoch: Int++ init() {+ appearance = .dark+ // 默认 = 灵动岛展开态真实尺寸 1:1,看细节再点放大档位,避免预览失真。+ mascotSize = 20+ zoom = 1+ animationsActive = true+ animationEpoch = 0+ }++ /// 首帧过后重新压一遍默认值。init 里的初值会被首帧布局改写(本文件的老毛病,+ /// 现有视图同样靠 onAppear 重置来兜),这里补一刀保证工具条选中态与实际一致。+ func applyDefaults() {+ appearance = .dark+ mascotSize = 20+ zoom = 1+ animationsActive = true+ }+}++/// 自绘档位选择器。系统 `Picker` / `Slider` / `Toggle` 在本文件里会把绑定值改写成首项或+/// 下界(初值丢失),这里改成 Button + 自管高亮,显示与 model 必然一致。+private struct AgentIslandPreviewChoice<Value: Equatable>: View {+ let options: [(value: Value, label: String)]+ @Binding var selection: Value++ var body: some View {+ HStack(spacing: 4) {+ ForEach(Array(options.indices), id: \.self) { index in+ let option = options[index]+ let isActive = option.value == selection+ Button {+ selection = option.value+ } label: {+ Text(option.label)+ .font(.system(size: 11, weight: isActive ? .semibold : .regular))+ .lineLimit(1)+ .fixedSize(horizontal: true, vertical: false)+ .padding(.horizontal, 8)+ .padding(.vertical, 3)+ .background(+ RoundedRectangle(cornerRadius: 6, style: .continuous)+ .fill(isActive ? Color.accentColor.opacity(0.24) : Color.primary.opacity(0.06))+ )+ }+ .buttonStyle(.plain)+ }+ }+ }+}++private struct AgentIslandMascotPreviewView: View {+ @ObservedObject var model: AgentIslandMascotPreviewModel++ private var appearance: AgentIslandMascotPreviewAppearance { model.appearance }+ private var mascotSize: CGFloat { CGFloat(model.mascotSize) }++ var body: some View {+ VStack(spacing: 0) {+ toolbar+ Divider()+ ScrollView([.vertical, .horizontal]) {+ VStack(alignment: .leading, spacing: 28) {+ switch appearance {+ case .dark:+ grid(isDark: true)+ case .light:+ grid(isDark: false)+ case .both:+ labeledGrid(title: "Dark", isDark: true)+ labeledGrid(title: "Light", isDark: false)+ }+ }+ .padding(24)+ }+ }+ .frame(minWidth: 720, minHeight: 480)+ .onAppear {+ model.applyDefaults()+ }+ }++ private var toolbar: some View {+ HStack(spacing: 14) {+ AgentIslandPreviewChoice(+ options: AgentIslandMascotPreviewAppearance.allCases.map { ($0, $0.title) },+ selection: $model.appearance+ )++ HStack(spacing: 6) {+ Text("真实尺寸")+ .font(.system(size: 11))+ .foregroundStyle(.secondary)+ AgentIslandPreviewChoice(+ options: agentIslandMascotRealSizes.map { ($0.size, $0.label) },+ selection: $model.mascotSize+ )+ }++ HStack(spacing: 6) {+ Text("放大")+ .font(.system(size: 11))+ .foregroundStyle(.secondary)+ AgentIslandPreviewChoice(+ options: agentIslandMascotPreviewZooms.map { ($0, "\(Int($0))×") },+ selection: $model.zoom+ )+ }++ AgentIslandPreviewChoice(+ options: [(true, "播放"), (false, "暂停")],+ selection: $model.animationsActive+ )++ Button("从头播放") {+ model.animationEpoch += 1+ }+ .font(.system(size: 11))++ Spacer()++ Text(+ "\(AgentIslandMascotCatalog.skins.count) 角色 × \(agentIslandMascotPreviewStates.count) 状态 · 渲染 \(Int(model.mascotSize))pt"+ )+ .font(.system(size: 11, design: .monospaced))+ .foregroundStyle(.secondary)+ }+ .padding(.horizontal, 20)+ .padding(.vertical, 12)+ }++ private func grid(isDark: Bool) -> some View {+ AgentIslandMascotPreviewGrid(size: mascotSize, zoom: CGFloat(model.zoom), isDark: isDark)+ .agentIslandMascotAnimationsActive(model.animationsActive)+ .agentIslandMascotAnimationEpoch(model.animationEpoch)+ }++ private func labeledGrid(title: String, isDark: Bool) -> some View {+ VStack(alignment: .leading, spacing: 12) {+ Text(title)+ .font(.system(size: 12, weight: .bold, design: .monospaced))+ .foregroundStyle(.secondary)+ grid(isDark: isDark)+ }+ }+}++/// 由命令行参数 `--mascot-preview` 触发的独立预览窗口。+/// 刻意**不用环境变量**做开关:主进程 spawn helper 时会继承 `process.env`+/// (见 MacAgentIslandNativeHost.ts),用户环境里若意外设置了该变量,产品 helper 会进+/// 预览分支、不 emit ready,被主进程判定超时反复重启。而 spawn 传的 argv 是空数组,+/// 命令行参数不存在这条泄漏路径。+/// 走这条分支时 helper 不读 stdin、不创建刘海面板,只当一个纯本地预览器。+private enum AgentIslandMascotPreview {+ static var isEnabled: Bool {+ CommandLine.arguments.dropFirst().contains(agentIslandMascotPreviewFlag)+ }++ private static var window: NSWindow?+ private static var closeObserver: NSObjectProtocol?+ private static var model: AgentIslandMascotPreviewModel?++ static func present() {+ let previewModel = AgentIslandMascotPreviewModel()+ model = previewModel+ let panel = NSWindow(+ contentRect: NSRect(x: 0, y: 0, width: 1120, height: 780),+ styleMask: [.titled, .closable, .miniaturizable, .resizable],+ backing: .buffered,+ defer: false+ )+ panel.title = "Agent Island — 角色动画预览"+ panel.contentView = NSHostingView(rootView: AgentIslandMascotPreviewView(model: previewModel))+ panel.center()+ panel.isReleasedWhenClosed = false+ // 预览时常要跟设计稿、素材目录来回对照,置顶省得反复找窗口。+ panel.level = .floating+ window = panel+ closeObserver = NotificationCenter.default.addObserver(+ forName: NSWindow.willCloseNotification,+ object: panel,+ queue: .main+ ) { _ in+ NSApp.terminate(nil)+ }+ NSApp.setActivationPolicy(.regular)+ panel.makeKeyAndOrderFront(nil)+ NSApp.activate(ignoringOtherApps: true)+ }+}+final class AgentIslandAppDelegate: NSObject, NSApplicationDelegate {private let controllerManager = AgentIslandDisplayControllerManager()private let decoder = JSONDecoder()func applicationDidFinishLaunching(_ notification: Notification) {+ if AgentIslandMascotPreview.isEnabled {+ AgentIslandMascotPreview.present()+ return+ }controllerManager.publishScreenMetrics()emitJson(["type": "ready"])if let update = AgentIslandDebugHarness.makeUpdate() {diff --git a/apps/desktop/native/agent-island/mascots/blackcat.png b/apps/desktop/native/agent-island/mascots/blackcat.pngnew file mode 100644index 0000000000..f5654638e5Binary files /dev/null and b/apps/desktop/native/agent-island/mascots/blackcat.png differdiff --git a/apps/desktop/native/agent-island/mascots/cindy.png b/apps/desktop/native/agent-island/mascots/cindy.pngnew file mode 100644index 0000000000..27bb15911cBinary files /dev/null and b/apps/desktop/native/agent-island/mascots/cindy.png differdiff --git a/apps/desktop/native/agent-island/mascots/erika.png b/apps/desktop/native/agent-island/mascots/erika.pngnew file mode 100644index 0000000000..187b2b9099Binary files /dev/null and b/apps/desktop/native/agent-island/mascots/erika.png differdiff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex ce5bb8600d..4cceabc031 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -37,6 +37,7 @@"test:migration-replay": "node ../../scripts/ensure-deps.mjs && node ../../scripts/ensure-dev-runtime-assets.mjs && vitest run src/main/localDb/__tests__/migrationReplay.test.ts","test:watch": "vitest","preview:oauth-pages": "tsx scripts/preview-oauth-pages.ts",+ "preview:island-mascots": "node scripts/preview-island-mascots.mjs","export:login-callback-template": "tsx scripts/export-login-callback-template.ts"},"author": {diff --git a/apps/desktop/scripts/preview-island-mascots.mjs b/apps/desktop/scripts/preview-island-mascots.mjsnew file mode 100644index 0000000000..d13795d526--- /dev/null+++ b/apps/desktop/scripts/preview-island-mascots.mjs@@ -0,0 +1,76 @@+#!/usr/bin/env node+// 编译并启动灵动岛角色动画预览窗口:+// pnpm --filter desktop preview:island-mascots+// 窗口里按「角色 × 动画状态」铺网格, 角色列表取自 helper 里的+// AgentIslandMascotCatalog.skins, 新增角色后无需改本脚本。+import { spawn, spawnSync } from 'node:child_process';+import { existsSync, mkdirSync } from 'node:fs';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const HERE = path.dirname(fileURLToPath(import.meta.url));+const DESKTOP_DIR = path.resolve(HERE, '..');+const ASSET_DIR = path.join(DESKTOP_DIR, 'native', 'agent-island');+const SOURCE = path.join(ASSET_DIR, 'macos-agent-island-helper.swift');++if (process.platform !== 'darwin') {+ console.error('[island-preview] 灵动岛 helper 只在 macOS 上可编译运行。');+ process.exit(1);+}++if (!existsSync(SOURCE)) {+ console.error(`[island-preview] 找不到源码: ${SOURCE}`);+ process.exit(1);+}++const outDir = path.join(tmpdir(), 'xdt-agent-island-preview');+mkdirSync(outDir, { recursive: true });+const binary = path.join(outDir, 'xdt-macos-agent-island-mascot-preview');++// 与 build.sh 一致: 即使 xcode-select 指向 CLT, 也优先用 Xcode 工具链。+const env = { ...process.env };+if (existsSync('/Applications/Xcode.app/Contents/Developer')) {+ env.DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer';+}++console.log('[island-preview] 编译 helper...');+const build = spawnSync('swiftc', [SOURCE, '-O', '-o', binary], {+ stdio: 'inherit',+ env,+});+if (build.error) {+ console.error(`[island-preview] 无法执行 swiftc: ${build.error.message}`);+ process.exit(1);+}+if (build.status !== 0) {+ console.error('[island-preview] 编译失败, 见上方 swiftc 输出。');+ process.exit(build.status ?? 1);+}++console.log('[island-preview] 启动预览窗口 (关窗即退出)...');+// 预览模式走命令行参数而不是环境变量:主进程 spawn helper 时会继承 process.env,+// 用环境变量当开关会让「用户 shell 里恰好设了它」污染产品运行路径。+const child = spawn(binary, ['--mascot-preview'], {+ stdio: 'inherit',+ env: {+ ...env,+ XDT_AGENT_ISLAND_ASSET_DIR: ASSET_DIR,+ },+});+child.on('error', (error) => {+ console.error(`[island-preview] 无法启动预览进程: ${error.message}`);+ process.exit(1);+});++// Ctrl-C / kill 时把信号转发给预览窗口,否则子进程会留在后台。+const FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];+for (const signal of FORWARDED_SIGNALS) {+ process.on(signal, () => {+ if (!child.killed) child.kill(signal);+ });+}++child.on('exit', (code, signal) => {+ process.exit(signal ? 1 : (code ?? 0));+});diff --git a/apps/desktop/src/renderer/assets/agent-island-blackcat.png b/apps/desktop/src/renderer/assets/agent-island-blackcat.pngnew file mode 100644index 0000000000..f5654638e5Binary files /dev/null and b/apps/desktop/src/renderer/assets/agent-island-blackcat.png differdiff --git a/apps/desktop/src/renderer/assets/agent-island-cindy.png b/apps/desktop/src/renderer/assets/agent-island-cindy.pngnew file mode 100644index 0000000000..27bb15911cBinary files /dev/null and b/apps/desktop/src/renderer/assets/agent-island-cindy.png differdiff --git a/apps/desktop/src/renderer/assets/agent-island-erika.png b/apps/desktop/src/renderer/assets/agent-island-erika.pngnew file mode 100644index 0000000000..187b2b9099Binary files /dev/null and b/apps/desktop/src/renderer/assets/agent-island-erika.png differdiff --git a/apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx b/apps/desktop/src/renderer/components/settings/AgentIslandSection.tsxindex 2ae34a7bcc..9c4f2fc827 100644--- a/apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx+++ b/apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx@@ -24,8 +24,11 @@ import { toast } from '@/lib/toast';import { cn } from '@/lib/utils';import { useAgentIslandSettings } from '@/hooks/useAgentIslandSettings';import anniePreviewUrl from '@/assets/agent-island-annie.png?url';+import blackcatPreviewUrl from '@/assets/agent-island-blackcat.png?url';import boliPreviewUrl from '@/assets/agent-island-boli.png?url';import chakuPreviewUrl from '@/assets/agent-island-chaku.png?url';+import cindyPreviewUrl from '@/assets/agent-island-cindy.png?url';+import erikaPreviewUrl from '@/assets/agent-island-erika.png?url';import muffinPreviewUrl from '@/assets/agent-island-muffin.png?url';import pululuPreviewUrl from '@/assets/agent-island-pululu.svg?url';import tararaPreviewUrl from '@/assets/agent-island-tarara.png?url';@@ -44,6 +47,9 @@ import {import { DefaultOverrideControls } from './DefaultOverrideControls';const MASCOT_PREVIEW_URLS: Record<AgentIslandMascotSkin, string> = {+ cindy: cindyPreviewUrl,+ blackcat: blackcatPreviewUrl,+ erika: erikaPreviewUrl,pululu: pululuPreviewUrl,tarara: tararaPreviewUrl,boli: boliPreviewUrl,@@ -64,7 +70,39 @@ const MASCOT_PREVIEW_VIEWBOX_SIZE = 16;const MASCOT_KEY_BORDER_RADIUS = `${(0.12 / 1.8) * 100}% / ${(0.12 / 0.7) * 100}%`;const MASCOT_KEY_RECTS = Array.from({ length: 12 }, (_, index) => index);+// 眼睛几何与配色必须与原生侧 SpriteMascotConfig 保持一致+// (native/agent-island/macos-agent-island-helper.swift),否则设置页预览和灵动岛实际渲染会不一样。const MASCOT_PREVIEW_CONFIGS: Record<Exclude<AgentIslandMascotSkin, 'pululu'>, MascotPreviewConfig> = {+ cindy: {+ keyboardBase: 'rgb(38 43 69)',+ keyboardKey: 'rgb(103 118 240)',+ eyeColor: 'rgb(107 61 50)',+ eyeLeftX: 6.71,+ eyeRightX: 9.3,+ eyeY: 9.5,+ eyeRx: 0.585,+ eyeRy: 0.98,+ },+ blackcat: {+ keyboardBase: 'rgb(31 36 41)',+ keyboardKey: 'rgb(103 118 240)',+ eyeColor: 'rgb(253 207 69)',+ eyeLeftX: 5.95,+ eyeRightX: 10.05,+ eyeY: 9.05,+ eyeRx: 0.585,+ eyeRy: 0.98,+ },+ erika: {+ keyboardBase: 'rgb(51 71 77)',+ keyboardKey: 'rgb(90 156 170)',+ eyeColor: 'rgb(135 93 66)',+ eyeLeftX: 6.84,+ eyeRightX: 9.16,+ eyeY: 10.75,+ eyeRx: 0.585,+ eyeRy: 0.98,+ },tarara: {keyboardBase: '#00615c',keyboardKey: '#00d9c5',@@ -128,15 +166,10 @@ const MASCOT_PREVIEW_CONFIGS: Record<Exclude<AgentIslandMascotSkin, 'pululu'>, M},};-const DEFAULT_MASCOT_ANIMATION_STEPS: MascotAnimationSteps = {- pululu: 0,- tarara: 1,- boli: 2,- whitesnow: 3,- annie: 0,- chaku: 1,- muffin: 2,-};+/** 让各角色的预览动画错峰起步(按皮肤顺序轮转到不同动画模式),新增皮肤自动纳入。 */+const DEFAULT_MASCOT_ANIMATION_STEPS: MascotAnimationSteps = Object.fromEntries(+ AGENT_ISLAND_MASCOT_SKINS.map((skin, index) => [skin, index % MASCOT_ANIMATION_MODES.length]),+) as MascotAnimationSteps;interface MascotPreviewConfig {keyboardBase: string;@@ -644,15 +677,9 @@ function advanceMascotAnimationStep(}function advanceAllMascotAnimationSteps(current: MascotAnimationSteps): MascotAnimationSteps {- return {- pululu: current.pululu + 1,- tarara: current.tarara + 1,- boli: current.boli + 1,- whitesnow: current.whitesnow + 1,- annie: current.annie + 1,- chaku: current.chaku + 1,- muffin: current.muffin + 1,- };+ return Object.fromEntries(+ AGENT_ISLAND_MASCOT_SKINS.map((skin) => [skin, current[skin] + 1]),+ ) as MascotAnimationSteps;}function displayTargetToOptionValue(target: AgentIslandDisplayTarget): string {diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex d1503536b6..0179d9c43d 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -502,6 +502,14 @@"soundPreviewAria": "Preview {{event}} sound","skinAnimationAria": "Switch {{skin}} animation preview","skins": {+ "cindy": {+ "name": "Cindy",+ "description": "Cindy herself, keeping an eye on every run."+ },+ "blackcat": {+ "name": "Black Cat",+ "description": "A composed black cat whose yellow eyes stay sharp against the dark notch."+ },"pululu": {"name": "Pululu","description": "TapFamily's calm little guardian: round-headed, sincere, and ready to steady messy tasks."@@ -529,6 +537,10 @@"muffin": {"name": "Muffin","description": "A soft blue-gray companion that keeps running tasks feeling light and playful."+ },+ "erika": {+ "name": "Erika",+ "description": "Erika with her crescent hairpin — warm brown eyes, quietly focused on long runs."}},"soundEvents": {diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 6c19e7ca56..7a12d46239 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -502,6 +502,14 @@"soundPreviewAria": "{{event}} のサウンドをプレビュー","skinAnimationAria": "{{skin}} のプレビューアニメーションを切り替え","skins": {+ "cindy": {+ "name": "Cindy",+ "description": "Cindy 本人。実行中のタスクをしっかり見守ります。"+ },+ "blackcat": {+ "name": "黒猫",+ "description": "落ち着いた黒猫。暗いノッチの中でも黄色い瞳がよく目立ちます。"+ },"pululu": {"name": "Pululu","description": "TapFamily の落ち着いた守り役。丸い頭とまっすぐな優しさで、荒れがちなタスクも支えます。"@@ -529,6 +537,10 @@"muffin": {"name": "Muffin","description": "やわらかなブルーグレーの相棒。実行中のタスクを軽やかで親しみやすく見せます。"+ },+ "erika": {+ "name": "Erika",+ "description": "三日月の髪飾りをつけた Erika。温かみのある茶色の瞳で、長いタスクに静かに寄り添います。"}},"soundEvents": {diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex f8cf1cd302..005850b50b 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -502,6 +502,14 @@"soundPreviewAria": "{{event}} 사운드 미리 듣기","skinAnimationAria": "{{skin}} 미리보기 애니메이션 전환","skins": {+ "cindy": {+ "name": "Cindy",+ "description": "Cindy 본인. 실행 중인 작업을 지켜봅니다."+ },+ "blackcat": {+ "name": "검은 고양이",+ "description": "차분한 검은 고양이. 어두운 노치 속에서도 노란 눈이 또렷합니다."+ },"pululu": {"name": "Pululu","description": "TapFamily의 차분한 수호 담당. 동그란 머리와 진심 어린 태도로 어수선한 작업도 지켜줍니다."@@ -529,6 +537,10 @@"muffin": {"name": "Muffin","description": "부드러운 블루 그레이 분위기의 동료. 실행 중인 작업을 더 가볍고 친근하게 보여줍니다."+ },+ "erika": {+ "name": "Erika",+ "description": "초승달 머리 장식을 한 Erika. 따뜻한 갈색 눈으로 긴 작업을 조용히 함께합니다."}},"soundEvents": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex f90d3f8991..0a9254f189 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -502,6 +502,14 @@"soundPreviewAria": "预览{{event}}音效","skinAnimationAria": "切换{{skin}}的预览动画","skins": {+ "cindy": {+ "name": "Cindy",+ "description": "Cindy 本人出镜,陪你盯着每一次运行。"+ },+ "blackcat": {+ "name": "黑猫",+ "description": "沉稳的黑猫,黄色眼睛在暗色刘海里格外醒目,适合长时间盯任务。"+ },"pululu": {"name": "噗噜噜","description": "TapFamily 里的理性守护担当:圆脑袋负责挡雨,也负责把跑偏的任务稳住。"@@ -529,6 +537,10 @@"muffin": {"name": "麦芬","description": "新来的麦芬角色,带着柔和的蓝灰色调,让运行中的任务更轻巧可爱。"+ },+ "erika": {+ "name": "Erika",+ "description": "戴月牙发饰的 Erika,暖棕色眼神安静又专注,适合陪长任务慢慢跑。"}},"soundEvents": {diff --git a/apps/desktop/src/shared/agentIsland.ts b/apps/desktop/src/shared/agentIsland.tsindex bff30c8b1f..b5a092c3d1 100644--- a/apps/desktop/src/shared/agentIsland.ts+++ b/apps/desktop/src/shared/agentIsland.ts@@ -63,13 +63,16 @@ export type AgentIslandDisplaySurface = 'collapsed' | 'sessionList' | 'interactiexport type AgentIslandLayoutMode = 'compact' | 'normal';export type AgentIslandPillStatus = 'idle' | AgentIslandSessionPhase;export type AgentIslandMascotSkin =+ | 'cindy'+ | 'blackcat'| 'pululu'| 'tarara'| 'boli'| 'whitesnow'| 'annie'| 'chaku'- | 'muffin';+ | 'muffin'+ | 'erika';export type AgentIslandSoundEvent = 'start' | 'attention' | 'complete' | 'error' | 'select';export type AgentIslandDisplayTarget =| { mode: 'all' }@@ -121,7 +124,10 @@ export interface AgentIslandDisplayOption {};}+/** 顺序即设置页「图标皮肤」列表的展示顺序。 */export const AGENT_ISLAND_MASCOT_SKINS: readonly AgentIslandMascotSkin[] = [+ 'cindy',+ 'blackcat','pululu','tarara','boli',@@ -129,6 +135,7 @@ export const AGENT_ISLAND_MASCOT_SKINS: readonly AgentIslandMascotSkin[] = ['annie','chaku','muffin',+ 'erika',] as const;export const AGENT_ISLAND_SOUND_EVENTS: readonly AgentIslandSoundEvent[] = [diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.mdindex 8fdc64e55a..8b5c7faf3f 100644--- a/i18n/GLOSSARY.md+++ b/i18n/GLOSSARY.md@@ -144,6 +144,14 @@OAuth 2.0 Device Authorization Grant 中由用户在另一设备验证页输入的一次性代码。当前先采用各语言直译,作为待产品裁决术语登记,避免后续界面出现“设备代码/配对码/认证码”等多套说法。+### Black Cat++灵动岛角色皮肤名(设置页「图标皮肤」列表)。角色本体是黑猫形象,四语先采用直译并登记为待讨论,避免后续界面出现「ブラックキャット / 블랙캣」等音译与直译混用。++### Erika++灵动岛角色皮肤名(设置页「图标皮肤」列表)。角色专名,四语统一保留拉丁原词,不做音译(避免「艾莉卡 / エリカ / 에리카」多套写法)。+### Region badge桌面登录页标题旁的品牌红胶囊(DESIGN.md §16.3),指徽标这个 UI 元素本身。徽标上的标签值另立条目(region-code-cn / region-code-dev)——本条 en 为 Region badge、各语言译文均非英文原词,caseStandardFor 天然返回 null,所以本条约束不到标签值,也无需写 checkCase。作为待产品裁决术语登记:尚未拍板是否改为可译文案(如「中国大陆版 / Mainland China」),先登记以免后续界面自造“国内版/中国版/开发版”等多套说法。diff --git a/i18n/glossary.json b/i18n/glossary.jsonindex 4a49c4c938..116606c4fd 100644--- a/i18n/glossary.json+++ b/i18n/glossary.json@@ -98,11 +98,27 @@},"forbidden": {"zh-CN": [- { "text": "中国版", "whenEn": "CN" },- { "text": "国内版", "whenEn": "CN" }+ {+ "text": "中国版",+ "whenEn": "CN"+ },+ {+ "text": "国内版",+ "whenEn": "CN"+ }],- "ja": [{ "text": "中国版", "whenEn": "CN" }],- "ko": [{ "text": "중국판", "whenEn": "CN" }]+ "ja": [+ {+ "text": "中国版",+ "whenEn": "CN"+ }+ ],+ "ko": [+ {+ "text": "중국판",+ "whenEn": "CN"+ }+ ]},"note": "中国大陆版登录页区域徽标上的标签值(DESIGN.md §16.3)。四语同值、**不翻译**——它是区域代号不是可译文案,所以把 en 原样写进各语言 translations(同 Agent 条目的做法),这让 caseStandardFor 生效、guard 能挡住 cn/Cn 之类的大小写漂移。forbidden 用条件形态(whenEn=CN)补另一半:大小写规则挡不住“被整体译走”,条件形态又能把拦截精确限定在英文源为 CN 的 key 上,不误伤别处正当的“国内”“中国版”表述。列的是最可能的自造说法,不求穷举。status 取 proposed 与 region-badge 一致:产品尚未拍板是否改用可译文案,改判后本条应随之作废而非沿用。2026-07-28 起同一代号也用于 submit_github_issue 的提交确认卡片与 issue 正文(`issueAgent.confirm.regionCodeCn`),口径与徽标完全一致:global 不标。"},@@ -116,9 +132,24 @@"ko": "Dev"},"forbidden": {- "zh-CN": [{ "text": "开发版", "whenEn": "Dev" }],- "ja": [{ "text": "開発版", "whenEn": "Dev" }],- "ko": [{ "text": "개발판", "whenEn": "Dev" }]+ "zh-CN": [+ {+ "text": "开发版",+ "whenEn": "Dev"+ }+ ],+ "ja": [+ {+ "text": "開発版",+ "whenEn": "Dev"+ }+ ],+ "ko": [+ {+ "text": "개발판",+ "whenEn": "Dev"+ }+ ]},"exempt": ["desktop:settings.about.debugLogDescription",@@ -438,6 +469,28 @@"desktop:scheduler.editor.script.capabilityDescs.jira_read"]},+ {+ "id": "mascot-black-cat",+ "status": "proposed",+ "en": "Black Cat",+ "translations": {+ "zh-CN": "黑猫",+ "ja": "黒猫",+ "ko": "검은 고양이"+ },+ "note": "灵动岛角色皮肤名(设置页「图标皮肤」列表)。角色本体是黑猫形象,四语先采用直译并登记为待讨论,避免后续界面出现「ブラックキャット / 블랙캣」等音译与直译混用。"+ },+ {+ "id": "mascot-erika",+ "status": "proposed",+ "en": "Erika",+ "translations": {+ "zh-CN": "Erika",+ "ja": "Erika",+ "ko": "Erika"+ },+ "note": "灵动岛角色皮肤名(设置页「图标皮肤」列表)。角色专名,四语统一保留拉丁原词,不做音译(避免「艾莉卡 / エリカ / 에리카」多套写法)。"+ },{"id": "plugin","status": "decided",diff --git a/scripts/hardcoded-color-exemptions.json b/scripts/hardcoded-color-exemptions.jsonindex 143e1cd2ac..5d3e3154cd 100644--- a/scripts/hardcoded-color-exemptions.json+++ b/scripts/hardcoded-color-exemptions.json@@ -213,5 +213,15 @@"glob": "apps/mobile/src/auth/__tests__/loginConsent.test.ts","reason": "consent 双态色板守卫单测(token 期望 hex/rgba,同 tokenRegistry.test.ts 先例)","owner": "login-consent"+ },+ {+ "glob": "apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx",+ "reason": "灵动岛 mascot 预览的角色素材固有色(眼色/键盘条):与原生 SpriteMascotConfig 一一对应的素材参数,不是界面语义色;改用 token 会与原生渲染脱钩",+ "owner": "agent-island"+ },+ {+ "glob": "apps/desktop/native/agent-island/macos-agent-island-helper.swift",+ "reason": "原生 helper 注释里引用的角色素材固有色 hex(便于与设计素材对照);渲染值本身是 Color(red:green:blue:),不经过 renderer token 体系",+ "owner": "agent-island"}]