@lattices/cli 0.4.14 → 0.6.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 (181) hide show
  1. package/README.md +5 -7
  2. package/apps/mac/Info.plist +4 -4
  3. package/apps/mac/Lattices.app/Contents/Info.plist +4 -12
  4. package/apps/mac/Lattices.app/Contents/MacOS/Lattices +0 -0
  5. package/bin/lattices-app.ts +110 -17
  6. package/bin/lattices-build +125 -0
  7. package/bin/lattices-dev +89 -16
  8. package/bin/lattices.ts +977 -16
  9. package/docs/agents.md +81 -4
  10. package/docs/ai-chat-ux-review.md +416 -0
  11. package/docs/api.md +135 -3
  12. package/docs/app.md +30 -8
  13. package/docs/config.md +4 -0
  14. package/docs/mouse-gestures.md +60 -1
  15. package/docs/proposals/LAT-004-interactive-overlay-actors.md +1 -1
  16. package/docs/proposals/LAT-005-action-runtime-product-spine.md +914 -0
  17. package/docs/proposals/LAT-006-mira-in-lattices.md +553 -0
  18. package/docs/proposals/LAT-007-unified-app-shell.md +128 -0
  19. package/docs/reference/dewey.config.ts +2 -2
  20. package/docs/release.md +171 -0
  21. package/docs/repo-structure.md +5 -5
  22. package/docs/voice.md +11 -27
  23. package/package.json +11 -10
  24. package/apps/mac/Package.swift +0 -27
  25. package/apps/mac/Sources/AppShell/App.swift +0 -26
  26. package/apps/mac/Sources/AppShell/AppActivationCoordinator.swift +0 -27
  27. package/apps/mac/Sources/AppShell/AppDelegate.swift +0 -189
  28. package/apps/mac/Sources/AppShell/AppServicesBootstrap.swift +0 -25
  29. package/apps/mac/Sources/AppShell/AppShellView.swift +0 -171
  30. package/apps/mac/Sources/AppShell/AppUpdater.swift +0 -305
  31. package/apps/mac/Sources/AppShell/CliActionLauncher.swift +0 -50
  32. package/apps/mac/Sources/AppShell/HomeDashboardView.swift +0 -133
  33. package/apps/mac/Sources/AppShell/HotkeyBootstrap.swift +0 -87
  34. package/apps/mac/Sources/AppShell/KeyRecorderView.swift +0 -210
  35. package/apps/mac/Sources/AppShell/LatticesRuntime.swift +0 -104
  36. package/apps/mac/Sources/AppShell/MainView.swift +0 -847
  37. package/apps/mac/Sources/AppShell/MainWindow.swift +0 -83
  38. package/apps/mac/Sources/AppShell/MenuBarController.swift +0 -177
  39. package/apps/mac/Sources/AppShell/OnboardingView.swift +0 -483
  40. package/apps/mac/Sources/AppShell/PermissionsAssistantView.swift +0 -366
  41. package/apps/mac/Sources/AppShell/PermissionsAssistantWindow.swift +0 -70
  42. package/apps/mac/Sources/AppShell/Preferences.swift +0 -297
  43. package/apps/mac/Sources/AppShell/SettingsView.swift +0 -3163
  44. package/apps/mac/Sources/AppShell/SettingsWindow.swift +0 -34
  45. package/apps/mac/Sources/AppShell/WorkspaceInspectorPresenter.swift +0 -13
  46. package/apps/mac/Sources/Core/Actions/HotkeyManager.swift +0 -256
  47. package/apps/mac/Sources/Core/Actions/HotkeyStore.swift +0 -399
  48. package/apps/mac/Sources/Core/Actions/IntentEngine.swift +0 -988
  49. package/apps/mac/Sources/Core/Actions/IntentSchema.swift +0 -94
  50. package/apps/mac/Sources/Core/Actions/Intents/CreateLayerIntent.swift +0 -54
  51. package/apps/mac/Sources/Core/Actions/Intents/DistributeIntent.swift +0 -56
  52. package/apps/mac/Sources/Core/Actions/Intents/FocusIntent.swift +0 -69
  53. package/apps/mac/Sources/Core/Actions/Intents/HelpIntent.swift +0 -41
  54. package/apps/mac/Sources/Core/Actions/Intents/KillIntent.swift +0 -47
  55. package/apps/mac/Sources/Core/Actions/Intents/LatticeIntent.swift +0 -53
  56. package/apps/mac/Sources/Core/Actions/Intents/LaunchIntent.swift +0 -67
  57. package/apps/mac/Sources/Core/Actions/Intents/ListSessionsIntent.swift +0 -32
  58. package/apps/mac/Sources/Core/Actions/Intents/ListWindowsIntent.swift +0 -30
  59. package/apps/mac/Sources/Core/Actions/Intents/ScanIntent.swift +0 -52
  60. package/apps/mac/Sources/Core/Actions/Intents/SearchIntent.swift +0 -190
  61. package/apps/mac/Sources/Core/Actions/Intents/SwitchLayerIntent.swift +0 -50
  62. package/apps/mac/Sources/Core/Actions/Intents/TileIntent.swift +0 -61
  63. package/apps/mac/Sources/Core/Actions/PaletteCommand.swift +0 -439
  64. package/apps/mac/Sources/Core/Actions/VoiceIntentResolver.swift +0 -713
  65. package/apps/mac/Sources/Core/Companion/CompanionActivityLog.swift +0 -70
  66. package/apps/mac/Sources/Core/Companion/CompanionKeyboardController.swift +0 -141
  67. package/apps/mac/Sources/Core/Companion/LatticesCompanionBridgeServer.swift +0 -454
  68. package/apps/mac/Sources/Core/Companion/LatticesCompanionCockpit.swift +0 -555
  69. package/apps/mac/Sources/Core/Companion/LatticesCompanionSecurityCoordinator.swift +0 -629
  70. package/apps/mac/Sources/Core/Companion/LatticesCompanionTrackpadController.swift +0 -204
  71. package/apps/mac/Sources/Core/Companion/LatticesDeckHost.swift +0 -1463
  72. package/apps/mac/Sources/Core/Daemon/DaemonProtocol.swift +0 -114
  73. package/apps/mac/Sources/Core/Daemon/DaemonServer.swift +0 -427
  74. package/apps/mac/Sources/Core/Daemon/LatticesApi.swift +0 -2965
  75. package/apps/mac/Sources/Core/Desktop/AccessibilityTextExtractor.swift +0 -111
  76. package/apps/mac/Sources/Core/Desktop/AppTypeClassifier.swift +0 -106
  77. package/apps/mac/Sources/Core/Desktop/DesktopModel.swift +0 -331
  78. package/apps/mac/Sources/Core/Desktop/DesktopModelTypes.swift +0 -73
  79. package/apps/mac/Sources/Core/Desktop/InventoryManager.swift +0 -35
  80. package/apps/mac/Sources/Core/Desktop/InventoryPath.swift +0 -43
  81. package/apps/mac/Sources/Core/Desktop/MouseFinder.swift +0 -527
  82. package/apps/mac/Sources/Core/Desktop/OcrModel.swift +0 -467
  83. package/apps/mac/Sources/Core/Desktop/OcrStore.swift +0 -329
  84. package/apps/mac/Sources/Core/Desktop/PlacementSpec.swift +0 -195
  85. package/apps/mac/Sources/Core/Desktop/SessionWindowLocator.swift +0 -139
  86. package/apps/mac/Sources/Core/Desktop/TilePickerView.swift +0 -209
  87. package/apps/mac/Sources/Core/Desktop/WindowCapture.swift +0 -33
  88. package/apps/mac/Sources/Core/Desktop/WindowDragSnapController.swift +0 -429
  89. package/apps/mac/Sources/Core/Desktop/WindowPreviewCard.swift +0 -100
  90. package/apps/mac/Sources/Core/Desktop/WindowPreviewStore.swift +0 -112
  91. package/apps/mac/Sources/Core/Desktop/WindowSelectionStore.swift +0 -76
  92. package/apps/mac/Sources/Core/Desktop/WindowTiler.swift +0 -2222
  93. package/apps/mac/Sources/Core/Input/EventTapBreaker.swift +0 -124
  94. package/apps/mac/Sources/Core/Input/EventTapThread.swift +0 -54
  95. package/apps/mac/Sources/Core/Input/InputCaptureResetCenter.swift +0 -20
  96. package/apps/mac/Sources/Core/Input/KeyboardRemapConfig.swift +0 -69
  97. package/apps/mac/Sources/Core/Input/KeyboardRemapController.swift +0 -346
  98. package/apps/mac/Sources/Core/Input/KeyboardRemapStore.swift +0 -141
  99. package/apps/mac/Sources/Core/Input/MouseGestureConfig.swift +0 -499
  100. package/apps/mac/Sources/Core/Input/MouseGestureController.swift +0 -2583
  101. package/apps/mac/Sources/Core/Input/MouseInputDeviceStore.swift +0 -98
  102. package/apps/mac/Sources/Core/Input/MouseInputEventViewer.swift +0 -272
  103. package/apps/mac/Sources/Core/Input/MouseShortcutStore.swift +0 -170
  104. package/apps/mac/Sources/Core/Input/SecureEventInputMonitor.swift +0 -39
  105. package/apps/mac/Sources/Core/Input/ShapeRecognizer.swift +0 -624
  106. package/apps/mac/Sources/Core/Input/TapBudgetMeter.swift +0 -56
  107. package/apps/mac/Sources/Core/Overlays/AppWindowShell.swift +0 -63
  108. package/apps/mac/Sources/Core/Overlays/CommandMode/CommandModeState.swift +0 -1566
  109. package/apps/mac/Sources/Core/Overlays/CommandMode/CommandModeView.swift +0 -1927
  110. package/apps/mac/Sources/Core/Overlays/CommandMode/CommandModeWindow.swift +0 -196
  111. package/apps/mac/Sources/Core/Overlays/CommandPalette/CommandPaletteView.swift +0 -307
  112. package/apps/mac/Sources/Core/Overlays/CommandPalette/CommandPaletteWindow.swift +0 -67
  113. package/apps/mac/Sources/Core/Overlays/HUD/CheatSheetHUD.swift +0 -576
  114. package/apps/mac/Sources/Core/Overlays/HUD/HUDBottomBar.swift +0 -279
  115. package/apps/mac/Sources/Core/Overlays/HUD/HUDController.swift +0 -1158
  116. package/apps/mac/Sources/Core/Overlays/HUD/HUDLeftBar.swift +0 -849
  117. package/apps/mac/Sources/Core/Overlays/HUD/HUDMinimap.swift +0 -179
  118. package/apps/mac/Sources/Core/Overlays/HUD/HUDRightBar.swift +0 -596
  119. package/apps/mac/Sources/Core/Overlays/HUD/HUDState.swift +0 -367
  120. package/apps/mac/Sources/Core/Overlays/HUD/HUDTopBar.swift +0 -243
  121. package/apps/mac/Sources/Core/Overlays/HUD/LauncherHUD.swift +0 -334
  122. package/apps/mac/Sources/Core/Overlays/HUD/LayerBezel.swift +0 -203
  123. package/apps/mac/Sources/Core/Overlays/OmniSearch/OmniSearchState.swift +0 -280
  124. package/apps/mac/Sources/Core/Overlays/OmniSearch/OmniSearchView.swift +0 -422
  125. package/apps/mac/Sources/Core/Overlays/OmniSearch/OmniSearchWindow.swift +0 -94
  126. package/apps/mac/Sources/Core/Overlays/OverlayPanelShell.swift +0 -241
  127. package/apps/mac/Sources/Core/Overlays/ScreenMap/ScreenMapState.swift +0 -3135
  128. package/apps/mac/Sources/Core/Overlays/ScreenMap/ScreenMapView.swift +0 -3977
  129. package/apps/mac/Sources/Core/Overlays/ScreenMap/ScreenMapWindowController.swift +0 -119
  130. package/apps/mac/Sources/Core/Overlays/ScreenOverlayCanvasController.swift +0 -1217
  131. package/apps/mac/Sources/Core/Overlays/Voice/VoiceCommandWindow.swift +0 -1575
  132. package/apps/mac/Sources/Core/Pi/PiAuthNextStepCard.swift +0 -148
  133. package/apps/mac/Sources/Core/Pi/PiAuthPromptCard.swift +0 -90
  134. package/apps/mac/Sources/Core/Pi/PiChatDock.swift +0 -564
  135. package/apps/mac/Sources/Core/Pi/PiChatSession.swift +0 -1948
  136. package/apps/mac/Sources/Core/Pi/PiInstallCallout.swift +0 -86
  137. package/apps/mac/Sources/Core/Pi/PiProviderSetupCallout.swift +0 -99
  138. package/apps/mac/Sources/Core/Pi/PiWorkspaceView.swift +0 -510
  139. package/apps/mac/Sources/Core/System/Capability.swift +0 -79
  140. package/apps/mac/Sources/Core/System/DiagnosticLog.swift +0 -373
  141. package/apps/mac/Sources/Core/System/EventBus.swift +0 -31
  142. package/apps/mac/Sources/Core/System/PermissionChecker.swift +0 -224
  143. package/apps/mac/Sources/Core/System/ProcessModel.swift +0 -199
  144. package/apps/mac/Sources/Core/System/ProcessQuery.swift +0 -151
  145. package/apps/mac/Sources/Core/System/SystemTelemetryMonitor.swift +0 -273
  146. package/apps/mac/Sources/Core/Voice/AdvisorLearningStore.swift +0 -90
  147. package/apps/mac/Sources/Core/Voice/AgentSession.swift +0 -377
  148. package/apps/mac/Sources/Core/Voice/AudioProvider.swift +0 -555
  149. package/apps/mac/Sources/Core/Voice/HandsOffSession.swift +0 -839
  150. package/apps/mac/Sources/Core/Voice/VoiceChatView.swift +0 -192
  151. package/apps/mac/Sources/Core/Voice/VoxClient.swift +0 -454
  152. package/apps/mac/Sources/Core/Workspace/Project.swift +0 -28
  153. package/apps/mac/Sources/Core/Workspace/ProjectScanner.swift +0 -141
  154. package/apps/mac/Sources/Core/Workspace/SessionLayerStore.swift +0 -285
  155. package/apps/mac/Sources/Core/Workspace/SessionManager.swift +0 -75
  156. package/apps/mac/Sources/Core/Workspace/Terminal/Terminal.swift +0 -259
  157. package/apps/mac/Sources/Core/Workspace/Terminal/TerminalQuery.swift +0 -156
  158. package/apps/mac/Sources/Core/Workspace/Terminal/TerminalSynthesizer.swift +0 -200
  159. package/apps/mac/Sources/Core/Workspace/Tmux/TmuxModel.swift +0 -60
  160. package/apps/mac/Sources/Core/Workspace/Tmux/TmuxQuery.swift +0 -105
  161. package/apps/mac/Sources/Core/Workspace/WorkspaceManager.swift +0 -1027
  162. package/apps/mac/Sources/UI/ActionRow.swift +0 -78
  163. package/apps/mac/Sources/UI/OrphanRow.swift +0 -129
  164. package/apps/mac/Sources/UI/ProjectRow.swift +0 -368
  165. package/apps/mac/Sources/UI/TabGroupRow.swift +0 -178
  166. package/apps/mac/Sources/UI/Theme.swift +0 -164
  167. package/apps/mac/Tests/StageDragTests.swift +0 -333
  168. package/apps/mac/Tests/StageJoinTests.swift +0 -313
  169. package/apps/mac/Tests/StageManagerTests.swift +0 -280
  170. package/apps/mac/Tests/StageTileTests.swift +0 -353
  171. package/swift/Package.swift +0 -20
  172. package/swift/Sources/DeckKit/DeckAction.swift +0 -51
  173. package/swift/Sources/DeckKit/DeckBridgeSecurity.swift +0 -152
  174. package/swift/Sources/DeckKit/DeckCockpit.swift +0 -82
  175. package/swift/Sources/DeckKit/DeckHost.swift +0 -7
  176. package/swift/Sources/DeckKit/DeckManifest.swift +0 -145
  177. package/swift/Sources/DeckKit/DeckRuntimeSnapshot.swift +0 -533
  178. package/swift/Sources/DeckKit/DeckTrackpad.swift +0 -63
  179. package/swift/Sources/DeckKit/DeckValue.swift +0 -93
  180. package/swift/Sources/DeckKit/DeckVoiceError.swift +0 -88
  181. package/swift/Tests/DeckKitTests/DeckKitTests.swift +0 -286
@@ -1,555 +0,0 @@
1
- import DeckKit
2
- import Foundation
3
-
4
- struct LatticesCompanionCockpitLayout: Codable, Equatable {
5
- struct Page: Codable, Equatable, Identifiable {
6
- var id: String
7
- var title: String
8
- var subtitle: String?
9
- var columns: Int
10
- var slotIDs: [String]
11
-
12
- init(
13
- id: String,
14
- title: String,
15
- subtitle: String? = nil,
16
- columns: Int = 4,
17
- slotIDs: [String]
18
- ) {
19
- self.id = id
20
- self.title = title
21
- self.subtitle = subtitle
22
- self.columns = columns
23
- self.slotIDs = slotIDs
24
- }
25
- }
26
-
27
- var pages: [Page]
28
- }
29
-
30
- enum LatticesCompanionShortcutCategory: String, CaseIterable, Identifiable {
31
- case voice
32
- case agent
33
- case system
34
- case switching
35
- case layout
36
- case mouse
37
- case dev
38
- case media
39
-
40
- var id: String { rawValue }
41
-
42
- var title: String {
43
- switch self {
44
- case .voice:
45
- return "Voice"
46
- case .agent:
47
- return "Agent"
48
- case .system:
49
- return "System"
50
- case .switching:
51
- return "Switching"
52
- case .layout:
53
- return "Layout"
54
- case .mouse:
55
- return "Mouse"
56
- case .dev:
57
- return "Dev"
58
- case .media:
59
- return "Media"
60
- }
61
- }
62
-
63
- var tintToken: String {
64
- switch self {
65
- case .voice:
66
- return "red"
67
- case .agent:
68
- return "violet"
69
- case .system:
70
- return "amber"
71
- case .switching, .layout:
72
- return "blue"
73
- case .mouse:
74
- return "teal"
75
- case .dev:
76
- return "green"
77
- case .media:
78
- return "pink"
79
- }
80
- }
81
- }
82
-
83
- struct LatticesCompanionShortcutDefinition: Identifiable {
84
- let id: String
85
- let title: String
86
- let subtitle: String?
87
- let iconSystemName: String
88
- let accentToken: String?
89
- let category: LatticesCompanionShortcutCategory
90
- let deckID: String? = nil
91
- }
92
-
93
- enum LatticesCompanionCockpitCatalog {
94
- private struct RenderedShortcut {
95
- var title: String
96
- var subtitle: String?
97
- var iconSystemName: String
98
- var accentToken: String?
99
- var deckID: String? = nil
100
- var categoryTint: String? = nil
101
- var actionID: String?
102
- var payload: [String: DeckValue]
103
- var isEnabled: Bool
104
- var isActive: Bool
105
- }
106
-
107
- static let slotCount = 16
108
-
109
- static let defaultLayout = LatticesCompanionCockpitLayout(
110
- pages: [
111
- .init(
112
- id: "command",
113
- title: "Command",
114
- subtitle: "Core voice, system, and workspace moves",
115
- columns: 4,
116
- slotIDs: [
117
- "voice-toggle", "voice-cancel", "key-escape", "key-enter",
118
- "switch-app-prev", "switch-app-next", "switch-window-prev", "switch-window-next",
119
- "layout-optimize", "mouse-find", "mouse-summon", "key-space",
120
- "place-left", "place-right", "place-center", "place-maximize"
121
- ]
122
- ),
123
- .init(
124
- id: "dev",
125
- title: "Dev",
126
- subtitle: "Terminal, agent, and edit shortcuts",
127
- columns: 4,
128
- slotIDs: [
129
- "key-copy", "key-paste", "key-undo", "key-shift-tab",
130
- "place-left", "place-right", "resize-wider", "resize-narrower",
131
- "switch-window-prev", "switch-window-next", "switch-app-prev", "switch-app-next",
132
- "layout-optimize", "mouse-find", "key-up", "key-down"
133
- ]
134
- ),
135
- .init(
136
- id: "media",
137
- title: "Media",
138
- subtitle: "Media-friendly window and keyboard controls",
139
- columns: 4,
140
- slotIDs: [
141
- "key-space", "key-escape", "key-left", "key-right",
142
- "place-center", "place-maximize", "resize-grow", "resize-shrink",
143
- "switch-app-prev", "switch-app-next", "mouse-summon", "mouse-find",
144
- "place-top-left", "place-top-right", "place-bottom-left", "place-bottom-right"
145
- ]
146
- ),
147
- .init(
148
- id: "windows",
149
- title: "Windows",
150
- subtitle: "Placement and resize macros for the frontmost window",
151
- columns: 4,
152
- slotIDs: [
153
- "place-top-left", "place-top-right", "place-bottom-left", "place-bottom-right",
154
- "place-left-third", "place-center-third", "place-right-third", "place-center",
155
- "resize-wider", "resize-narrower", "resize-taller", "resize-shorter",
156
- "resize-grow", "resize-shrink", "place-left", "place-right"
157
- ]
158
- ),
159
- .init(
160
- id: "voice",
161
- title: "Voice",
162
- subtitle: "Hands-off voice and transcript controls",
163
- columns: 4,
164
- slotIDs: [
165
- "voice-toggle", "voice-cancel", "key-escape", "key-enter",
166
- "layout-optimize", "switch-app-prev", "switch-app-next", "mouse-find",
167
- "place-left", "place-right", "place-center", "place-maximize",
168
- "key-copy", "key-paste", "key-undo", "key-space"
169
- ]
170
- ),
171
- ]
172
- )
173
-
174
- static let shortcuts: [LatticesCompanionShortcutDefinition] = [
175
- .init(id: "", title: "Empty", subtitle: "Leave this slot unused", iconSystemName: "square.dashed", accentToken: nil, category: .layout),
176
- .init(id: "voice-toggle", title: "Voice Toggle", subtitle: "Start or stop hands-off voice", iconSystemName: "waveform.badge.mic", accentToken: "voice", category: .voice),
177
- .init(id: "voice-cancel", title: "Voice Cancel", subtitle: "Cancel the current voice turn", iconSystemName: "xmark.circle.fill", accentToken: "rose", category: .voice),
178
- .init(id: "switch-app-prev", title: "Previous App", subtitle: "Focus the prior visible application", iconSystemName: "chevron.left.square.fill", accentToken: "switch", category: .switching),
179
- .init(id: "switch-app-next", title: "Next App", subtitle: "Focus the next visible application", iconSystemName: "chevron.right.square.fill", accentToken: "switch", category: .switching),
180
- .init(id: "switch-window-prev", title: "Previous Window", subtitle: "Step backward through visible windows", iconSystemName: "rectangle.on.rectangle.circle.fill", accentToken: "switch", category: .switching),
181
- .init(id: "switch-window-next", title: "Next Window", subtitle: "Step forward through visible windows", iconSystemName: "rectangle.on.rectangle.circle", accentToken: "switch", category: .switching),
182
- .init(id: "layout-optimize", title: "Optimize", subtitle: "Retile visible windows", iconSystemName: "rectangle.3.group.fill", accentToken: "layout", category: .layout),
183
- .init(id: "place-left", title: "Place Left", subtitle: "Snap the frontmost window left", iconSystemName: "rectangle.leadinghalf.filled", accentToken: "layout", category: .layout),
184
- .init(id: "place-right", title: "Place Right", subtitle: "Snap the frontmost window right", iconSystemName: "rectangle.trailinghalf.filled", accentToken: "layout", category: .layout),
185
- .init(id: "place-top-left", title: "Top Left", subtitle: "Move to the upper-left quarter", iconSystemName: "rectangle.inset.topleft.filled", accentToken: "layout", category: .layout),
186
- .init(id: "place-top-right", title: "Top Right", subtitle: "Move to the upper-right quarter", iconSystemName: "rectangle.inset.topright.filled", accentToken: "layout", category: .layout),
187
- .init(id: "place-bottom-left", title: "Bottom Left", subtitle: "Move to the lower-left quarter", iconSystemName: "rectangle.inset.bottomleft.filled", accentToken: "layout", category: .layout),
188
- .init(id: "place-bottom-right", title: "Bottom Right", subtitle: "Move to the lower-right quarter", iconSystemName: "rectangle.inset.bottomright.filled", accentToken: "layout", category: .layout),
189
- .init(id: "place-center", title: "Center", subtitle: "Center the frontmost window", iconSystemName: "plus.rectangle.on.rectangle", accentToken: "layout", category: .layout),
190
- .init(id: "place-maximize", title: "Maximize", subtitle: "Expand to the visible screen", iconSystemName: "macwindow", accentToken: "layout", category: .layout),
191
- .init(id: "place-left-third", title: "Left Third", subtitle: "Move into the left third", iconSystemName: "rectangle.leadingthird.inset.filled", accentToken: "layout", category: .layout),
192
- .init(id: "place-center-third", title: "Center Third", subtitle: "Move into the center third", iconSystemName: "rectangle.center.inset.filled", accentToken: "layout", category: .layout),
193
- .init(id: "place-right-third", title: "Right Third", subtitle: "Move into the right third", iconSystemName: "rectangle.trailingthird.inset.filled", accentToken: "layout", category: .layout),
194
- .init(id: "resize-wider", title: "Wider", subtitle: "Increase width", iconSystemName: "arrow.left.and.right.circle.fill", accentToken: "layout", category: .layout),
195
- .init(id: "resize-narrower", title: "Narrower", subtitle: "Reduce width", iconSystemName: "arrow.left.and.right.circle", accentToken: "layout", category: .layout),
196
- .init(id: "resize-taller", title: "Taller", subtitle: "Increase height", iconSystemName: "arrow.up.and.down.circle.fill", accentToken: "layout", category: .layout),
197
- .init(id: "resize-shorter", title: "Shorter", subtitle: "Reduce height", iconSystemName: "arrow.up.and.down.circle", accentToken: "layout", category: .layout),
198
- .init(id: "resize-grow", title: "Grow", subtitle: "Expand both dimensions", iconSystemName: "plus.rectangle.fill.on.rectangle.fill", accentToken: "layout", category: .layout),
199
- .init(id: "resize-shrink", title: "Shrink", subtitle: "Reduce both dimensions", iconSystemName: "minus.rectangle", accentToken: "layout", category: .layout),
200
- .init(id: "mouse-find", title: "Find Mouse", subtitle: "Pulse the current cursor position", iconSystemName: "scope", accentToken: "mouse", category: .mouse),
201
- .init(id: "mouse-summon", title: "Summon Mouse", subtitle: "Bring the cursor to center screen", iconSystemName: "dot.scope", accentToken: "mouse", category: .mouse),
202
- .init(id: "key-escape", title: "Escape", subtitle: "Send Escape", iconSystemName: "escape", accentToken: "system", category: .system),
203
- .init(id: "key-copy", title: "Copy", subtitle: "Send Command-C", iconSystemName: "doc.on.doc", accentToken: "system", category: .system),
204
- .init(id: "key-paste", title: "Paste", subtitle: "Send Command-V", iconSystemName: "doc.on.clipboard", accentToken: "system", category: .system),
205
- .init(id: "key-undo", title: "Undo", subtitle: "Send Command-Z", iconSystemName: "arrow.uturn.backward", accentToken: "system", category: .system),
206
- .init(id: "key-shift-tab", title: "Back Tab", subtitle: "Send Shift-Tab", iconSystemName: "arrowshape.turn.up.left", accentToken: "system", category: .system),
207
- .init(id: "key-space", title: "Space", subtitle: "Send Space", iconSystemName: "space", accentToken: "system", category: .system),
208
- .init(id: "key-enter", title: "Enter", subtitle: "Send Return", iconSystemName: "return", accentToken: "system", category: .system),
209
- .init(id: "key-left", title: "Left", subtitle: "Send Left Arrow", iconSystemName: "arrow.left", accentToken: "system", category: .system),
210
- .init(id: "key-right", title: "Right", subtitle: "Send Right Arrow", iconSystemName: "arrow.right", accentToken: "system", category: .system),
211
- .init(id: "key-up", title: "Up", subtitle: "Send Up Arrow", iconSystemName: "arrow.up", accentToken: "system", category: .system),
212
- .init(id: "key-down", title: "Down", subtitle: "Send Down Arrow", iconSystemName: "arrow.down", accentToken: "system", category: .system),
213
- ]
214
-
215
- static func definition(for shortcutID: String) -> LatticesCompanionShortcutDefinition? {
216
- shortcuts.first(where: { $0.id == shortcutID })
217
- }
218
-
219
- static func normalized(_ layout: LatticesCompanionCockpitLayout) -> LatticesCompanionCockpitLayout {
220
- let blueprintPages = defaultLayout.pages
221
- let existing = Dictionary(uniqueKeysWithValues: layout.pages.map { ($0.id, $0) })
222
-
223
- return LatticesCompanionCockpitLayout(
224
- pages: blueprintPages.map { blueprint in
225
- let current = existing[blueprint.id]
226
- let slots = normalizedSlots(current?.slotIDs ?? blueprint.slotIDs)
227
- return .init(
228
- id: blueprint.id,
229
- title: current?.title ?? blueprint.title,
230
- subtitle: current?.subtitle ?? blueprint.subtitle,
231
- columns: max(2, current?.columns ?? blueprint.columns),
232
- slotIDs: slots
233
- )
234
- }
235
- )
236
- }
237
-
238
- static func renderedState(
239
- layout: LatticesCompanionCockpitLayout,
240
- voice: DeckVoiceState?,
241
- desktop: DeckDesktopSummary?,
242
- layoutState: DeckLayoutState?
243
- ) -> DeckCockpitState {
244
- let normalizedLayout = normalized(layout)
245
- let focusName = layoutState?.frontmostWindow?.appName ?? desktop?.activeAppName ?? "Mac"
246
- let detail = desktop?.activeLayerName.map { "Layer: \($0)" } ?? "Quick controls for \(focusName)."
247
-
248
- return DeckCockpitState(
249
- title: focusName,
250
- detail: detail,
251
- pages: normalizedLayout.pages.map { page in
252
- DeckCockpitPage(
253
- id: page.id,
254
- title: page.title,
255
- subtitle: page.subtitle,
256
- columns: page.columns,
257
- tiles: page.slotIDs.enumerated().map { index, shortcutID in
258
- renderedTile(
259
- shortcutID: shortcutID,
260
- pageID: page.id,
261
- slotIndex: index,
262
- voice: voice,
263
- desktop: desktop,
264
- layoutState: layoutState
265
- )
266
- }
267
- )
268
- }
269
- )
270
- }
271
-
272
- private static func normalizedSlots(_ slots: [String]) -> [String] {
273
- let trimmed = Array(slots.prefix(slotCount))
274
- if trimmed.count == slotCount {
275
- return trimmed
276
- }
277
- return trimmed + Array(repeating: "", count: slotCount - trimmed.count)
278
- }
279
-
280
- private static func renderedTile(
281
- shortcutID: String,
282
- pageID: String,
283
- slotIndex: Int,
284
- voice: DeckVoiceState?,
285
- desktop: DeckDesktopSummary?,
286
- layoutState: DeckLayoutState?
287
- ) -> DeckCockpitTile {
288
- let rendered = renderedShortcut(
289
- for: shortcutID,
290
- voice: voice,
291
- desktop: desktop,
292
- layoutState: layoutState
293
- )
294
-
295
- return DeckCockpitTile(
296
- id: "\(pageID)-\(slotIndex)",
297
- shortcutID: shortcutID,
298
- title: rendered.title,
299
- subtitle: rendered.subtitle,
300
- iconSystemName: rendered.iconSystemName,
301
- accentToken: rendered.accentToken,
302
- deckID: rendered.deckID ?? pageID,
303
- categoryTint: rendered.categoryTint ?? definition(for: shortcutID)?.category.tintToken,
304
- actionID: rendered.actionID,
305
- payload: rendered.payload,
306
- isEnabled: rendered.isEnabled,
307
- isActive: rendered.isActive
308
- )
309
- }
310
-
311
- private static func renderedShortcut(
312
- for shortcutID: String,
313
- voice: DeckVoiceState?,
314
- desktop: DeckDesktopSummary?,
315
- layoutState: DeckLayoutState?
316
- ) -> RenderedShortcut {
317
- let frontmostWindow = layoutState?.frontmostWindow
318
- let activeAppName = desktop?.activeAppName ?? frontmostWindow?.appName
319
-
320
- if let keyShortcut = keyboardShortcut(for: shortcutID) {
321
- return keyShortcut
322
- }
323
-
324
- switch shortcutID {
325
- case "voice-toggle":
326
- let listening = voice?.phase == .listening
327
- return RenderedShortcut(
328
- title: listening ? "Stop Voice" : "Start Voice",
329
- subtitle: listening ? "Stop the current voice capture" : "Begin a hands-off voice turn",
330
- iconSystemName: listening ? "stop.fill" : "mic.fill",
331
- accentToken: "voice",
332
- actionID: "voice.toggle",
333
- payload: [:],
334
- isEnabled: true,
335
- isActive: listening
336
- )
337
-
338
- case "voice-cancel":
339
- return RenderedShortcut(
340
- title: "Cancel Voice",
341
- subtitle: "Dismiss the current voice turn",
342
- iconSystemName: "xmark.circle.fill",
343
- accentToken: "rose",
344
- actionID: "voice.cancel",
345
- payload: [:],
346
- isEnabled: true,
347
- isActive: false
348
- )
349
-
350
- case "switch-app-prev":
351
- return RenderedShortcut(
352
- title: "Prev App",
353
- subtitle: activeAppName.map { "Now: \($0)" } ?? "Focus the previous visible app",
354
- iconSystemName: "chevron.left.square.fill",
355
- accentToken: "switch",
356
- actionID: "switch.cycleApplication",
357
- payload: ["direction": .string("previous")],
358
- isEnabled: true,
359
- isActive: false
360
- )
361
-
362
- case "switch-app-next":
363
- return RenderedShortcut(
364
- title: "Next App",
365
- subtitle: activeAppName.map { "Now: \($0)" } ?? "Focus the next visible app",
366
- iconSystemName: "chevron.right.square.fill",
367
- accentToken: "switch",
368
- actionID: "switch.cycleApplication",
369
- payload: ["direction": .string("next")],
370
- isEnabled: true,
371
- isActive: false
372
- )
373
-
374
- case "switch-window-prev":
375
- return RenderedShortcut(
376
- title: "Prev Window",
377
- subtitle: frontmostWindow?.title ?? activeAppName ?? "Focus the previous visible window",
378
- iconSystemName: "rectangle.on.rectangle.circle.fill",
379
- accentToken: "switch",
380
- actionID: "switch.cycleWindow",
381
- payload: ["direction": .string("previous")],
382
- isEnabled: true,
383
- isActive: false
384
- )
385
-
386
- case "switch-window-next":
387
- return RenderedShortcut(
388
- title: "Next Window",
389
- subtitle: frontmostWindow?.title ?? activeAppName ?? "Focus the next visible window",
390
- iconSystemName: "rectangle.on.rectangle.circle",
391
- accentToken: "switch",
392
- actionID: "switch.cycleWindow",
393
- payload: ["direction": .string("next")],
394
- isEnabled: true,
395
- isActive: false
396
- )
397
-
398
- case "layout-optimize":
399
- return RenderedShortcut(
400
- title: "Optimize",
401
- subtitle: desktop?.activeLayerName ?? "Retile the visible workspace",
402
- iconSystemName: "rectangle.3.group.fill",
403
- accentToken: "layout",
404
- actionID: "layout.optimize",
405
- payload: [:],
406
- isEnabled: true,
407
- isActive: false
408
- )
409
-
410
- case "place-left":
411
- return placementShortcut(title: "Left", subtitle: "Snap left", icon: "rectangle.leadinghalf.filled", placement: "left")
412
- case "place-right":
413
- return placementShortcut(title: "Right", subtitle: "Snap right", icon: "rectangle.trailinghalf.filled", placement: "right")
414
- case "place-top-left":
415
- return placementShortcut(title: "Top Left", subtitle: "Upper-left quarter", icon: "rectangle.inset.topleft.filled", placement: "top-left")
416
- case "place-top-right":
417
- return placementShortcut(title: "Top Right", subtitle: "Upper-right quarter", icon: "rectangle.inset.topright.filled", placement: "top-right")
418
- case "place-bottom-left":
419
- return placementShortcut(title: "Bottom Left", subtitle: "Lower-left quarter", icon: "rectangle.inset.bottomleft.filled", placement: "bottom-left")
420
- case "place-bottom-right":
421
- return placementShortcut(title: "Bottom Right", subtitle: "Lower-right quarter", icon: "rectangle.inset.bottomright.filled", placement: "bottom-right")
422
- case "place-center":
423
- return placementShortcut(title: "Center", subtitle: "Center on screen", icon: "plus.rectangle.on.rectangle", placement: "center")
424
- case "place-maximize":
425
- return placementShortcut(title: "Maximize", subtitle: "Fill visible screen", icon: "macwindow", placement: "maximize")
426
- case "place-left-third":
427
- return placementShortcut(title: "Left Third", subtitle: "Left column", icon: "rectangle.leadingthird.inset.filled", placement: "left-third")
428
- case "place-center-third":
429
- return placementShortcut(title: "Center Third", subtitle: "Middle column", icon: "rectangle.center.inset.filled", placement: "center-third")
430
- case "place-right-third":
431
- return placementShortcut(title: "Right Third", subtitle: "Right column", icon: "rectangle.trailingthird.inset.filled", placement: "right-third")
432
-
433
- case "resize-wider":
434
- return resizeShortcut(title: "Wider", subtitle: "Increase width", icon: "arrow.left.and.right.circle.fill", dimension: "width", direction: "grow")
435
- case "resize-narrower":
436
- return resizeShortcut(title: "Narrower", subtitle: "Reduce width", icon: "arrow.left.and.right.circle", dimension: "width", direction: "shrink")
437
- case "resize-taller":
438
- return resizeShortcut(title: "Taller", subtitle: "Increase height", icon: "arrow.up.and.down.circle.fill", dimension: "height", direction: "grow")
439
- case "resize-shorter":
440
- return resizeShortcut(title: "Shorter", subtitle: "Reduce height", icon: "arrow.up.and.down.circle", dimension: "height", direction: "shrink")
441
- case "resize-grow":
442
- return resizeShortcut(title: "Grow", subtitle: "Expand both axes", icon: "plus.rectangle.fill.on.rectangle.fill", dimension: "both", direction: "grow")
443
- case "resize-shrink":
444
- return resizeShortcut(title: "Shrink", subtitle: "Reduce both axes", icon: "minus.rectangle", dimension: "both", direction: "shrink")
445
-
446
- case "mouse-find":
447
- return RenderedShortcut(
448
- title: "Find Mouse",
449
- subtitle: "Pulse the cursor position",
450
- iconSystemName: "scope",
451
- accentToken: "mouse",
452
- actionID: "mouse.find",
453
- payload: [:],
454
- isEnabled: true,
455
- isActive: false
456
- )
457
-
458
- case "mouse-summon":
459
- return RenderedShortcut(
460
- title: "Summon Mouse",
461
- subtitle: "Bring cursor to center",
462
- iconSystemName: "dot.scope",
463
- accentToken: "mouse",
464
- actionID: "mouse.summon",
465
- payload: [:],
466
- isEnabled: true,
467
- isActive: false
468
- )
469
-
470
- default:
471
- return RenderedShortcut(
472
- title: "Empty",
473
- subtitle: "Assign an action on the Mac",
474
- iconSystemName: "square.dashed",
475
- accentToken: nil,
476
- actionID: nil,
477
- payload: [:],
478
- isEnabled: false,
479
- isActive: false
480
- )
481
- }
482
- }
483
-
484
- private static func placementShortcut(
485
- title: String,
486
- subtitle: String,
487
- icon: String,
488
- placement: String
489
- ) -> RenderedShortcut {
490
- RenderedShortcut(
491
- title: title,
492
- subtitle: subtitle,
493
- iconSystemName: icon,
494
- accentToken: "layout",
495
- actionID: "layout.placeFrontmost",
496
- payload: ["placement": .string(placement)],
497
- isEnabled: true,
498
- isActive: false
499
- )
500
- }
501
-
502
- private static func resizeShortcut(
503
- title: String,
504
- subtitle: String,
505
- icon: String,
506
- dimension: String,
507
- direction: String
508
- ) -> RenderedShortcut {
509
- RenderedShortcut(
510
- title: title,
511
- subtitle: subtitle,
512
- iconSystemName: icon,
513
- accentToken: "layout",
514
- actionID: "layout.resizeFrontmost",
515
- payload: [
516
- "dimension": .string(dimension),
517
- "direction": .string(direction)
518
- ],
519
- isEnabled: true,
520
- isActive: false
521
- )
522
- }
523
-
524
- private static func keyboardShortcut(for shortcutID: String) -> RenderedShortcut? {
525
- let shortcuts: [String: (title: String, subtitle: String, icon: String, key: String, modifiers: [String])] = [
526
- "key-escape": ("Escape", "Send Escape", "escape", "escape", []),
527
- "key-copy": ("Copy", "Send Command-C", "doc.on.doc", "c", ["command"]),
528
- "key-paste": ("Paste", "Send Command-V", "doc.on.clipboard", "v", ["command"]),
529
- "key-undo": ("Undo", "Send Command-Z", "arrow.uturn.backward", "z", ["command"]),
530
- "key-shift-tab": ("Back Tab", "Send Shift-Tab", "arrowshape.turn.up.left", "tab", ["shift"]),
531
- "key-space": ("Space", "Send Space", "space", "space", []),
532
- "key-enter": ("Enter", "Send Return", "return", "enter", []),
533
- "key-left": ("Left", "Send Left Arrow", "arrow.left", "left", []),
534
- "key-right": ("Right", "Send Right Arrow", "arrow.right", "right", []),
535
- "key-up": ("Up", "Send Up Arrow", "arrow.up", "up", []),
536
- "key-down": ("Down", "Send Down Arrow", "arrow.down", "down", []),
537
- ]
538
-
539
- guard let shortcut = shortcuts[shortcutID] else { return nil }
540
- return RenderedShortcut(
541
- title: shortcut.title,
542
- subtitle: shortcut.subtitle,
543
- iconSystemName: shortcut.icon,
544
- accentToken: "system",
545
- categoryTint: LatticesCompanionShortcutCategory.system.tintToken,
546
- actionID: "keys.send",
547
- payload: [
548
- "key": .string(shortcut.key),
549
- "modifiers": .array(shortcut.modifiers.map { .string($0) })
550
- ],
551
- isEnabled: true,
552
- isActive: false
553
- )
554
- }
555
- }