@lattices/cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -9
- package/app/Package.swift +8 -1
- package/app/Sources/AdvisorLearningStore.swift +90 -0
- package/app/Sources/AgentSession.swift +377 -0
- package/app/Sources/AppDelegate.swift +44 -12
- package/app/Sources/AppShellView.swift +81 -8
- package/app/Sources/AudioProvider.swift +386 -0
- package/app/Sources/CheatSheetHUD.swift +261 -19
- package/app/Sources/DaemonProtocol.swift +13 -0
- package/app/Sources/DaemonServer.swift +8 -0
- package/app/Sources/DesktopModel.swift +164 -5
- package/app/Sources/DesktopModelTypes.swift +2 -0
- package/app/Sources/DiagnosticLog.swift +104 -2
- package/app/Sources/EventBus.swift +1 -0
- package/app/Sources/HUDBottomBar.swift +279 -0
- package/app/Sources/HUDController.swift +1158 -0
- package/app/Sources/HUDLeftBar.swift +849 -0
- package/app/Sources/HUDMinimap.swift +179 -0
- package/app/Sources/HUDRightBar.swift +774 -0
- package/app/Sources/HUDState.swift +367 -0
- package/app/Sources/HUDTopBar.swift +243 -0
- package/app/Sources/HandsOffSession.swift +733 -0
- package/app/Sources/HomeDashboardView.swift +125 -0
- package/app/Sources/HotkeyManager.swift +2 -0
- package/app/Sources/HotkeyStore.swift +45 -9
- package/app/Sources/IntentEngine.swift +925 -0
- package/app/Sources/Intents/CreateLayerIntent.swift +54 -0
- package/app/Sources/Intents/DistributeIntent.swift +56 -0
- package/app/Sources/Intents/FocusIntent.swift +69 -0
- package/app/Sources/Intents/HelpIntent.swift +41 -0
- package/app/Sources/Intents/KillIntent.swift +47 -0
- package/app/Sources/Intents/LatticeIntent.swift +78 -0
- package/app/Sources/Intents/LaunchIntent.swift +67 -0
- package/app/Sources/Intents/ListSessionsIntent.swift +32 -0
- package/app/Sources/Intents/ListWindowsIntent.swift +30 -0
- package/app/Sources/Intents/ScanIntent.swift +52 -0
- package/app/Sources/Intents/SearchIntent.swift +190 -0
- package/app/Sources/Intents/SwitchLayerIntent.swift +50 -0
- package/app/Sources/Intents/TileIntent.swift +61 -0
- package/app/Sources/LatticesApi.swift +1235 -30
- package/app/Sources/LauncherHUD.swift +348 -0
- package/app/Sources/MainView.swift +147 -44
- package/app/Sources/OcrModel.swift +34 -1
- package/app/Sources/OmniSearchState.swift +99 -102
- package/app/Sources/OnboardingView.swift +457 -0
- package/app/Sources/PermissionChecker.swift +2 -12
- package/app/Sources/PiChatDock.swift +454 -0
- package/app/Sources/PiChatSession.swift +815 -0
- package/app/Sources/PiWorkspaceView.swift +364 -0
- package/app/Sources/PlacementSpec.swift +195 -0
- package/app/Sources/Preferences.swift +59 -0
- package/app/Sources/ProjectScanner.swift +1 -1
- package/app/Sources/ScreenMapState.swift +701 -55
- package/app/Sources/ScreenMapView.swift +843 -103
- package/app/Sources/ScreenMapWindowController.swift +22 -0
- package/app/Sources/SessionLayerStore.swift +285 -0
- package/app/Sources/SessionManager.swift +4 -1
- package/app/Sources/SettingsView.swift +186 -3
- package/app/Sources/Theme.swift +9 -8
- package/app/Sources/TmuxModel.swift +7 -0
- package/app/Sources/TmuxQuery.swift +27 -3
- package/app/Sources/VoiceChatView.swift +192 -0
- package/app/Sources/VoiceCommandWindow.swift +1594 -0
- package/app/Sources/VoiceIntentResolver.swift +671 -0
- package/app/Sources/VoxClient.swift +454 -0
- package/app/Sources/WindowTiler.swift +348 -87
- package/app/Sources/WorkspaceManager.swift +127 -18
- package/bin/client.ts +16 -0
- package/bin/{daemon-client.js → daemon-client.ts} +49 -30
- package/bin/handsoff-infer.ts +280 -0
- package/bin/handsoff-worker.ts +731 -0
- package/bin/{lattices-app.js → lattices-app.ts} +67 -32
- package/bin/lattices-dev +160 -0
- package/bin/{lattices.js → lattices.ts} +600 -137
- package/bin/project-twin.ts +645 -0
- package/docs/agent-execution-plan.md +562 -0
- package/docs/agents.md +142 -0
- package/docs/api.md +153 -34
- package/docs/app.md +29 -1
- package/docs/config.md +5 -1
- package/docs/handsoff-test-scenarios.md +84 -0
- package/docs/layers.md +20 -20
- package/docs/ocr.md +14 -5
- package/docs/overview.md +5 -1
- package/docs/presentation-execution-review.md +491 -0
- package/docs/prompts/hands-off-system.md +374 -0
- package/docs/prompts/hands-off-turn.md +30 -0
- package/docs/prompts/voice-advisor.md +31 -0
- package/docs/prompts/voice-fallback.md +23 -0
- package/docs/tiling-reference.md +167 -0
- package/docs/twins.md +138 -0
- package/docs/voice-command-protocol.md +278 -0
- package/docs/voice.md +219 -0
- package/package.json +21 -10
- package/bin/client.js +0 -4
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct SearchIntent: LatticeIntent {
|
|
4
|
+
static let name = "search"
|
|
5
|
+
static let title = "Find windows by name, title, or content"
|
|
6
|
+
|
|
7
|
+
static let phrases = [
|
|
8
|
+
// Primary operator: find
|
|
9
|
+
"find {query}",
|
|
10
|
+
"find all {query}",
|
|
11
|
+
"find all the {query}",
|
|
12
|
+
// search
|
|
13
|
+
"search {query}",
|
|
14
|
+
"search for {query}",
|
|
15
|
+
"search for all {query}",
|
|
16
|
+
// look for
|
|
17
|
+
"look for {query}",
|
|
18
|
+
"look up {query}",
|
|
19
|
+
// where
|
|
20
|
+
"where is {query}",
|
|
21
|
+
"where's {query}",
|
|
22
|
+
"where does it say {query}",
|
|
23
|
+
"where did i see {query}",
|
|
24
|
+
// which / can you
|
|
25
|
+
"which window has {query}",
|
|
26
|
+
"which window shows {query}",
|
|
27
|
+
"can you find {query}",
|
|
28
|
+
"help me find {query}",
|
|
29
|
+
// locate
|
|
30
|
+
"locate {query}",
|
|
31
|
+
"locate all {query}",
|
|
32
|
+
// "open up all the X windows" = find, not launch
|
|
33
|
+
"open up all the {query} windows",
|
|
34
|
+
"open up all {query} windows",
|
|
35
|
+
"open all the {query} windows",
|
|
36
|
+
"open all {query} windows",
|
|
37
|
+
"show me all the {query} windows",
|
|
38
|
+
"show me all {query} windows",
|
|
39
|
+
"show all the {query} windows",
|
|
40
|
+
"show all {query} windows",
|
|
41
|
+
// "pull up" = find/focus
|
|
42
|
+
"pull up {query}",
|
|
43
|
+
"pull up all {query}",
|
|
44
|
+
"pull up everything with {query} in it",
|
|
45
|
+
"bring up all the {query}",
|
|
46
|
+
"bring up all {query}",
|
|
47
|
+
// show me (without "windows" suffix)
|
|
48
|
+
"show me all the {query}",
|
|
49
|
+
"show me all {query}",
|
|
50
|
+
"show me the {query}",
|
|
51
|
+
"show me {query}",
|
|
52
|
+
"show all the {query}",
|
|
53
|
+
"show all {query}",
|
|
54
|
+
// get
|
|
55
|
+
"get {query}",
|
|
56
|
+
"get all {query}",
|
|
57
|
+
"get all the {query}",
|
|
58
|
+
"get me {query}",
|
|
59
|
+
"get me all the {query}",
|
|
60
|
+
// give me
|
|
61
|
+
"give me all the {query}",
|
|
62
|
+
"give me all {query}",
|
|
63
|
+
"give me {query}",
|
|
64
|
+
// list
|
|
65
|
+
"list {query}",
|
|
66
|
+
"list all {query}",
|
|
67
|
+
"list all the {query}",
|
|
68
|
+
// Casual / natural
|
|
69
|
+
"where'd my {query} go",
|
|
70
|
+
"where'd {query} go",
|
|
71
|
+
"i lost my {query}",
|
|
72
|
+
"i lost {query}",
|
|
73
|
+
"where the hell is {query}",
|
|
74
|
+
"get {query} on screen",
|
|
75
|
+
"{query} windows",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
static let slots = [
|
|
79
|
+
SlotDef(name: "query", type: .string, required: true),
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
/// Expand natural-language terms into search-friendly queries.
|
|
83
|
+
/// e.g. "terminals" → ["terminals", "iterm", "terminal", "warp", "kitty", "alacritty"]
|
|
84
|
+
private static let synonyms: [String: [String]] = [
|
|
85
|
+
"terminals": ["iterm", "terminal", "warp", "kitty", "alacritty", "hyper"],
|
|
86
|
+
"terminal": ["iterm", "terminal", "warp", "kitty", "alacritty", "hyper"],
|
|
87
|
+
"browsers": ["safari", "chrome", "firefox", "arc", "brave", "edge"],
|
|
88
|
+
"browser": ["safari", "chrome", "firefox", "arc", "brave", "edge"],
|
|
89
|
+
"editors": ["code", "cursor", "xcode", "vim", "neovim", "zed", "sublime"],
|
|
90
|
+
"editor": ["code", "cursor", "xcode", "vim", "neovim", "zed", "sublime"],
|
|
91
|
+
"chat": ["slack", "discord", "messages", "telegram", "whatsapp"],
|
|
92
|
+
"music": ["spotify", "music", "apple music"],
|
|
93
|
+
"mail": ["mail", "gmail", "outlook", "spark"],
|
|
94
|
+
"notes": ["notes", "obsidian", "notion", "bear"],
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
/// Clean up a voice query: strip filler phrases, qualifiers, and noise.
|
|
98
|
+
private static func cleanQuery(_ raw: String) -> String {
|
|
99
|
+
var q = raw.lowercased().trimmingCharacters(in: .whitespaces)
|
|
100
|
+
|
|
101
|
+
// Strip trailing qualifiers ("and sort by ...", "sorted by ...", "ordered by ...")
|
|
102
|
+
for pattern in [" and sort", " and order", " sorted by", " ordered by",
|
|
103
|
+
" and filter", " and group", " and show", " and list",
|
|
104
|
+
" please", " for me"] {
|
|
105
|
+
if let range = q.range(of: pattern) {
|
|
106
|
+
q = String(q[q.startIndex..<range.lowerBound])
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Strip trailing "windows"/"apps"
|
|
111
|
+
for suffix in [" windows", " apps", " applications"] {
|
|
112
|
+
if q.hasSuffix(suffix) {
|
|
113
|
+
q = String(q.dropLast(suffix.count))
|
|
114
|
+
break
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return q.trimmingCharacters(in: .whitespaces)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
func perform(slots: [String: JSON]) throws -> JSON {
|
|
122
|
+
guard let rawQuery = slots["query"]?.stringValue, !rawQuery.isEmpty else {
|
|
123
|
+
throw IntentError.missingSlot("query")
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let queryLower = Self.cleanQuery(rawQuery)
|
|
127
|
+
guard !queryLower.isEmpty else {
|
|
128
|
+
throw IntentError.missingSlot("query")
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if queryLower != rawQuery.lowercased().trimmingCharacters(in: .whitespaces) {
|
|
132
|
+
DiagnosticLog.shared.info("search: cleaned '\(rawQuery)' → '\(queryLower)'")
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Check for synonym expansion (e.g. "terminals" → ["iterm", "terminal", ...])
|
|
136
|
+
if let expansions = Self.synonyms[queryLower] {
|
|
137
|
+
DiagnosticLog.shared.info("search: query='\(rawQuery)' → expanding to \(expansions)")
|
|
138
|
+
return try searchExpanded(queries: expansions)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
DiagnosticLog.shared.info("search: query='\(queryLower)'")
|
|
142
|
+
return try searchSingle(query: queryLower)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private func searchSingle(query: String) throws -> JSON {
|
|
146
|
+
// Quick first — title, app, session, OCR (instant)
|
|
147
|
+
let quick = try LatticesApi.shared.dispatch(
|
|
148
|
+
method: "lattices.search",
|
|
149
|
+
params: .object(["query": .string(query), "mode": .string("quick")])
|
|
150
|
+
)
|
|
151
|
+
if case .array(let items) = quick, !items.isEmpty {
|
|
152
|
+
DiagnosticLog.shared.info("search: \(items.count) results for '\(query)' (quick)")
|
|
153
|
+
return quick
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Escalate to complete — adds terminal cwd/processes + OCR
|
|
157
|
+
let result = try LatticesApi.shared.dispatch(
|
|
158
|
+
method: "lattices.search",
|
|
159
|
+
params: .object(["query": .string(query)])
|
|
160
|
+
)
|
|
161
|
+
if case .array(let items) = result {
|
|
162
|
+
DiagnosticLog.shared.info("search: \(items.count) results for '\(query)' (complete)")
|
|
163
|
+
}
|
|
164
|
+
return result
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// Search for multiple expanded queries and deduplicate by window ID.
|
|
168
|
+
private func searchExpanded(queries: [String]) throws -> JSON {
|
|
169
|
+
var seenWids: Set<Int> = []
|
|
170
|
+
var merged: [JSON] = []
|
|
171
|
+
|
|
172
|
+
for q in queries {
|
|
173
|
+
let result = try LatticesApi.shared.dispatch(
|
|
174
|
+
method: "lattices.search",
|
|
175
|
+
params: .object(["query": .string(q), "mode": .string("quick")])
|
|
176
|
+
)
|
|
177
|
+
if case .array(let items) = result {
|
|
178
|
+
for item in items {
|
|
179
|
+
if let wid = item["wid"]?.intValue, !seenWids.contains(wid) {
|
|
180
|
+
seenWids.insert(wid)
|
|
181
|
+
merged.append(item)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
DiagnosticLog.shared.info("search: \(merged.count) results from expanded search")
|
|
188
|
+
return .array(merged)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct SwitchLayerIntent: LatticeIntent {
|
|
4
|
+
static let name = "switch_layer"
|
|
5
|
+
static let title = "Switch to a workspace layer"
|
|
6
|
+
|
|
7
|
+
static let phrases = [
|
|
8
|
+
// Primary: layer
|
|
9
|
+
"layer {layer}",
|
|
10
|
+
// switch to
|
|
11
|
+
"switch to layer {layer}",
|
|
12
|
+
"switch to the {layer} layer",
|
|
13
|
+
"switch to {layer}",
|
|
14
|
+
// go to
|
|
15
|
+
"go to layer {layer}",
|
|
16
|
+
"go to the {layer} layer",
|
|
17
|
+
"go to {layer} layer",
|
|
18
|
+
// activate / change
|
|
19
|
+
"activate layer {layer}",
|
|
20
|
+
"activate the {layer} layer",
|
|
21
|
+
"change to layer {layer}",
|
|
22
|
+
"change layer to {layer}",
|
|
23
|
+
// numbered
|
|
24
|
+
"layer one",
|
|
25
|
+
"layer two",
|
|
26
|
+
"layer three",
|
|
27
|
+
"layer 1",
|
|
28
|
+
"layer 2",
|
|
29
|
+
"layer 3",
|
|
30
|
+
"first layer",
|
|
31
|
+
"second layer",
|
|
32
|
+
"third layer",
|
|
33
|
+
"next layer",
|
|
34
|
+
"previous layer",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
static let slots = [
|
|
38
|
+
SlotDef(name: "layer", type: .layer, required: true),
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
func perform(slots: [String: JSON]) throws -> JSON {
|
|
42
|
+
guard let layer = slots["layer"]?.stringValue else {
|
|
43
|
+
throw IntentError.missingSlot("layer")
|
|
44
|
+
}
|
|
45
|
+
return try LatticesApi.shared.dispatch(
|
|
46
|
+
method: "layer.switch",
|
|
47
|
+
params: .object(["name": .string(layer)])
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct TileIntent: LatticeIntent {
|
|
4
|
+
static let name = "tile_window"
|
|
5
|
+
static let title = "Tile a window to a screen position"
|
|
6
|
+
|
|
7
|
+
static let phrases = [
|
|
8
|
+
// Primary operator: tile
|
|
9
|
+
"tile {position}",
|
|
10
|
+
"tile it {position}",
|
|
11
|
+
"tile this {position}",
|
|
12
|
+
"tile the window {position}",
|
|
13
|
+
// snap
|
|
14
|
+
"snap {position}",
|
|
15
|
+
"snap it {position}",
|
|
16
|
+
"snap to the {position}",
|
|
17
|
+
"snap to {position}",
|
|
18
|
+
// move / put
|
|
19
|
+
"move to the {position}",
|
|
20
|
+
"move it to the {position}",
|
|
21
|
+
"move it {position}",
|
|
22
|
+
"move this to the {position}",
|
|
23
|
+
"move this over to the {position}",
|
|
24
|
+
"put it on the {position}",
|
|
25
|
+
"put this on the {position}",
|
|
26
|
+
"put it on the {position} side",
|
|
27
|
+
"put this on the {position} side",
|
|
28
|
+
"put it {position}",
|
|
29
|
+
"throw it {position}",
|
|
30
|
+
"throw it to the {position}",
|
|
31
|
+
"just put it on the {position}",
|
|
32
|
+
// Standalone position phrases
|
|
33
|
+
"{position} half",
|
|
34
|
+
"{position} side",
|
|
35
|
+
// maximize variants (no slot needed — position is the whole phrase)
|
|
36
|
+
"maximize",
|
|
37
|
+
"maximize it",
|
|
38
|
+
"make it full screen",
|
|
39
|
+
"full screen",
|
|
40
|
+
"go full screen",
|
|
41
|
+
"make it big",
|
|
42
|
+
"center it",
|
|
43
|
+
"center the window",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
static let slots = [
|
|
47
|
+
SlotDef(name: "position", type: .position, required: true, defaultValue: .string("center")),
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
func perform(slots: [String: JSON]) throws -> JSON {
|
|
51
|
+
let posName = slots["position"]?.stringValue ?? "center"
|
|
52
|
+
guard let placement = PlacementSpec(string: posName) else {
|
|
53
|
+
return .object(["ok": .bool(false), "reason": .string("Unknown position '\(posName)'")])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
DispatchQueue.main.async {
|
|
57
|
+
WindowTiler.tileFrontmostViaAX(to: placement)
|
|
58
|
+
}
|
|
59
|
+
return .object(["ok": .bool(true), "position": .string(posName)])
|
|
60
|
+
}
|
|
61
|
+
}
|