@arach/lattices 0.2.0 → 0.6.1

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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +172 -86
  3. package/apps/mac/Info.plist +43 -0
  4. package/apps/mac/Lattices.app/Contents/Info.plist +43 -0
  5. package/apps/mac/Lattices.app/Contents/MacOS/Lattices +0 -0
  6. package/apps/mac/Lattices.app/Contents/Resources/AppIcon.icns +0 -0
  7. package/apps/mac/Lattices.app/Contents/Resources/docs/assistant-knowledge.md +130 -0
  8. package/apps/mac/Lattices.app/Contents/Resources/tap.wav +0 -0
  9. package/apps/mac/Lattices.app/Contents/_CodeSignature/CodeResources +150 -0
  10. package/apps/mac/Lattices.entitlements +21 -0
  11. package/apps/mac/Resources/Pets/assistant-spark/pet.json +62 -0
  12. package/apps/mac/Resources/Pets/assistant-spark/spritesheet.webp +0 -0
  13. package/apps/mac/Resources/Pets/scout-ranger/pet.json +6 -0
  14. package/apps/mac/Resources/Pets/scout-ranger/spritesheet.webp +0 -0
  15. package/apps/mac/Resources/tap.wav +0 -0
  16. package/assets/AppIcon.icns +0 -0
  17. package/bin/assistant-intelligence.ts +912 -0
  18. package/bin/cli/capture.ts +252 -0
  19. package/bin/cli/daemon.ts +22 -0
  20. package/bin/cli/helpers.ts +105 -0
  21. package/bin/cli/layer.ts +178 -0
  22. package/bin/cli/runs.ts +43 -0
  23. package/bin/cli/search.ts +141 -0
  24. package/bin/cli/session.ts +32 -0
  25. package/bin/client.ts +17 -0
  26. package/bin/cua.ts +26 -0
  27. package/bin/{daemon-client.js → daemon-client.ts} +49 -30
  28. package/bin/handsoff-infer.ts +96 -0
  29. package/bin/handsoff-worker.ts +531 -0
  30. package/bin/infer.ts +424 -0
  31. package/bin/keychain.ts +75 -0
  32. package/bin/lattices-app.ts +655 -0
  33. package/bin/lattices-build +125 -0
  34. package/bin/lattices-build-env.ts +77 -0
  35. package/bin/lattices-dev +362 -0
  36. package/bin/lattices.ts +3260 -0
  37. package/bin/project-twin.ts +645 -0
  38. package/docs/agent-execution-plan.md +562 -0
  39. package/docs/agent-layer-guide.md +207 -0
  40. package/docs/agents.md +233 -0
  41. package/docs/ai-chat-ux-review.md +416 -0
  42. package/docs/api.md +1041 -47
  43. package/docs/app.md +96 -13
  44. package/docs/assistant-knowledge.md +130 -0
  45. package/docs/companion-deck.md +209 -0
  46. package/docs/component-extraction-roadmap.md +392 -0
  47. package/docs/concepts.md +13 -12
  48. package/docs/config.md +83 -10
  49. package/docs/gesture-customization-proposal.md +520 -0
  50. package/docs/handsoff-test-scenarios.md +84 -0
  51. package/docs/hyperspace-grid-snappiness.md +210 -0
  52. package/docs/layers.md +176 -28
  53. package/docs/mouse-gestures.md +244 -0
  54. package/docs/ocr.md +21 -9
  55. package/docs/overview.md +42 -23
  56. package/docs/presentation-execution-review.md +491 -0
  57. package/docs/prompts/hands-off-system.md +382 -0
  58. package/docs/prompts/hands-off-turn.md +30 -0
  59. package/docs/prompts/voice-advisor.md +31 -0
  60. package/docs/prompts/voice-fallback.md +23 -0
  61. package/docs/proposals/LAT-001-gesture-visual-customization.md +522 -0
  62. package/docs/proposals/LAT-002-shared-overlay-canvas.md +353 -0
  63. package/docs/proposals/LAT-003-menu-bar-controller-architecture.md +291 -0
  64. package/docs/proposals/LAT-004-interactive-overlay-actors.md +534 -0
  65. package/docs/proposals/LAT-005-action-runtime-product-spine.md +914 -0
  66. package/docs/proposals/LAT-006-followup-gaps.md +103 -0
  67. package/docs/proposals/LAT-006-runs-and-capture-in-lattices.md +566 -0
  68. package/docs/proposals/LAT-007-unified-app-shell.md +128 -0
  69. package/docs/quickstart.md +8 -12
  70. package/docs/reference/dewey.config.ts +74 -0
  71. package/docs/reference/install-agent.md +79 -0
  72. package/docs/release.md +172 -0
  73. package/docs/repo-structure.md +100 -0
  74. package/docs/terminal-kit.md +87 -0
  75. package/docs/tiling-reference.md +224 -0
  76. package/docs/twins.md +138 -0
  77. package/docs/voice-command-protocol.md +278 -0
  78. package/docs/voice-error-model.md +73 -0
  79. package/docs/voice.md +221 -0
  80. package/package.json +69 -16
  81. package/packages/npm/sdk/cua.d.mts +1 -0
  82. package/packages/npm/sdk/cua.d.ts +188 -0
  83. package/packages/npm/sdk/cua.mjs +376 -0
  84. package/app/Lattices.app/Contents/Info.plist +0 -24
  85. package/app/Package.swift +0 -13
  86. package/app/Sources/ActionRow.swift +0 -61
  87. package/app/Sources/App.swift +0 -10
  88. package/app/Sources/AppDelegate.swift +0 -234
  89. package/app/Sources/AppShellView.swift +0 -62
  90. package/app/Sources/AppTypeClassifier.swift +0 -70
  91. package/app/Sources/AppWindowShell.swift +0 -63
  92. package/app/Sources/CheatSheetHUD.swift +0 -332
  93. package/app/Sources/CommandModeState.swift +0 -1362
  94. package/app/Sources/CommandModeView.swift +0 -1405
  95. package/app/Sources/CommandModeWindow.swift +0 -192
  96. package/app/Sources/CommandPaletteView.swift +0 -307
  97. package/app/Sources/CommandPaletteWindow.swift +0 -134
  98. package/app/Sources/DaemonProtocol.swift +0 -101
  99. package/app/Sources/DaemonServer.swift +0 -414
  100. package/app/Sources/DesktopModel.swift +0 -121
  101. package/app/Sources/DesktopModelTypes.swift +0 -71
  102. package/app/Sources/DiagnosticLog.swift +0 -271
  103. package/app/Sources/EventBus.swift +0 -30
  104. package/app/Sources/HotkeyManager.swift +0 -250
  105. package/app/Sources/HotkeyStore.swift +0 -338
  106. package/app/Sources/InventoryManager.swift +0 -35
  107. package/app/Sources/InventoryPath.swift +0 -43
  108. package/app/Sources/KeyRecorderView.swift +0 -210
  109. package/app/Sources/LatticesApi.swift +0 -1125
  110. package/app/Sources/MainView.swift +0 -467
  111. package/app/Sources/MainWindow.swift +0 -83
  112. package/app/Sources/OcrModel.swift +0 -309
  113. package/app/Sources/OcrStore.swift +0 -295
  114. package/app/Sources/OmniSearchState.swift +0 -283
  115. package/app/Sources/OmniSearchView.swift +0 -288
  116. package/app/Sources/OmniSearchWindow.swift +0 -105
  117. package/app/Sources/OrphanRow.swift +0 -129
  118. package/app/Sources/PaletteCommand.swift +0 -419
  119. package/app/Sources/PermissionChecker.swift +0 -125
  120. package/app/Sources/Preferences.swift +0 -92
  121. package/app/Sources/ProcessModel.swift +0 -199
  122. package/app/Sources/ProcessQuery.swift +0 -151
  123. package/app/Sources/Project.swift +0 -28
  124. package/app/Sources/ProjectRow.swift +0 -368
  125. package/app/Sources/ProjectScanner.swift +0 -121
  126. package/app/Sources/ScreenMapState.swift +0 -2387
  127. package/app/Sources/ScreenMapView.swift +0 -2820
  128. package/app/Sources/ScreenMapWindowController.swift +0 -89
  129. package/app/Sources/SessionManager.swift +0 -72
  130. package/app/Sources/SettingsView.swift +0 -1053
  131. package/app/Sources/SettingsWindow.swift +0 -20
  132. package/app/Sources/TabGroupRow.swift +0 -178
  133. package/app/Sources/Terminal.swift +0 -259
  134. package/app/Sources/TerminalQuery.swift +0 -156
  135. package/app/Sources/TerminalSynthesizer.swift +0 -200
  136. package/app/Sources/Theme.swift +0 -163
  137. package/app/Sources/TilePickerView.swift +0 -209
  138. package/app/Sources/TmuxModel.swift +0 -53
  139. package/app/Sources/TmuxQuery.swift +0 -81
  140. package/app/Sources/WindowTiler.swift +0 -1755
  141. package/app/Sources/WorkspaceManager.swift +0 -434
  142. package/bin/lattices-app.js +0 -221
  143. package/bin/lattices.js +0 -1418
@@ -0,0 +1,207 @@
1
+ # Agent Guide: Generating Layers
2
+
3
+ How to create and manage Lattices workspace layers programmatically. This guide is for AI agents (Claude Code, etc.) that want to generate layers from high-level user descriptions.
4
+
5
+ ## Quick Reference
6
+
7
+ ```bash
8
+ # See what's on screen
9
+ lattices windows --json
10
+
11
+ # Create a layer with tiling
12
+ lattices layer create "Design" --json '[
13
+ {"app": "Figma", "tile": "left"},
14
+ {"app": "Google Chrome", "title": "Tailwind", "tile": "right"}
15
+ ]'
16
+
17
+ # Snapshot current windows as a layer
18
+ lattices layer snap "my-context"
19
+
20
+ # List / switch / delete session layers
21
+ lattices layer session
22
+ lattices layer session "Design"
23
+ lattices layer delete "Design"
24
+ lattices layer clear
25
+ ```
26
+
27
+ ## How It Works
28
+
29
+ There are two kinds of layers:
30
+
31
+ | Type | Storage | Requires restart? | How to create |
32
+ |------|---------|-------------------|---------------|
33
+ | **Config layers** | `~/.lattices/workspace.json` | Yes (or refresh) | Edit JSON file |
34
+ | **Session layers** | In-memory (daemon) | No | CLI or daemon API |
35
+
36
+ **Session layers are what you want.** They're created via TypeScript CLI commands, take effect immediately, and don't require restarting anything.
37
+
38
+ ## Step-by-Step: Generating a Layer
39
+
40
+ ### 1. Discover what's available
41
+
42
+ ```bash
43
+ lattices windows --json
44
+ ```
45
+
46
+ Returns an array of window objects:
47
+ ```json
48
+ [
49
+ {
50
+ "wid": 1234,
51
+ "app": "iTerm2",
52
+ "title": "lattices — zsh",
53
+ "latticesSession": "lattices-abc123",
54
+ "frame": { "x": 0, "y": 25, "w": 960, "h": 1050 },
55
+ "spaceIds": [1]
56
+ },
57
+ {
58
+ "wid": 5678,
59
+ "app": "Google Chrome",
60
+ "title": "GitHub - arach/lattices",
61
+ "frame": { "x": 960, "y": 25, "w": 960, "h": 1050 },
62
+ "spaceIds": [1]
63
+ }
64
+ ]
65
+ ```
66
+
67
+ Key fields for matching:
68
+ - `wid` — unique window ID (most precise)
69
+ - `app` — application name
70
+ - `title` — window title (use for disambiguation when multiple windows of same app)
71
+ - `latticesSession` — tmux session name (for terminal windows)
72
+
73
+ ### 2. Decide on a layout
74
+
75
+ Pick tile positions based on how many windows and what makes sense:
76
+
77
+ | Windows | Good layout | Tile values |
78
+ |---------|-------------|-------------|
79
+ | 2 | Side by side | `left`, `right` |
80
+ | 2 | Stacked | `top`, `bottom` |
81
+ | 3 | Main + sidebar | `left` (60%), `top-right`, `bottom-right` |
82
+ | 3 | Columns | `left-third`, `center-third`, `right-third` |
83
+ | 4 | Quadrants | `top-left`, `top-right`, `bottom-left`, `bottom-right` |
84
+ | 1 | Focused | `maximize` or `center` |
85
+
86
+ Full position reference:
87
+ - **Halves**: `left`, `right`, `top`, `bottom`
88
+ - **Quarters**: `top-left`, `top-right`, `bottom-left`, `bottom-right`
89
+ - **Thirds**: `left-third`, `center-third`, `right-third`
90
+ - **Sixths**: `top-left-third`, `top-center-third`, `top-right-third`, `bottom-left-third`, `bottom-center-third`, `bottom-right-third`
91
+ - **Fourths**: `first-fourth`, `second-fourth`, `third-fourth`, `last-fourth`
92
+ - **Special**: `maximize`, `center`
93
+ - **Custom grid**: `grid:CxR:C,R` (e.g. `grid:5x3:2,1`)
94
+
95
+ ### 3. Create the layer
96
+
97
+ **Option A: By window ID (most reliable)**
98
+ ```bash
99
+ lattices layer create "Coding" --json '[
100
+ {"wid": 1234, "tile": "left"},
101
+ {"wid": 5678, "tile": "right"}
102
+ ]'
103
+ ```
104
+
105
+ **Option B: By app name (survives window recreation)**
106
+ ```bash
107
+ lattices layer create "Research" --json '[
108
+ {"app": "Google Chrome", "title": "docs", "tile": "left"},
109
+ {"app": "Notes", "tile": "right"}
110
+ ]'
111
+ ```
112
+
113
+ **Option C: Simple wid list (no tiling)**
114
+ ```bash
115
+ lattices layer create "Focus" wid:1234 wid:5678
116
+ ```
117
+
118
+ **Option D: Snapshot everything visible**
119
+ ```bash
120
+ lattices layer snap "Current Context"
121
+ ```
122
+
123
+ ### 4. Switch between layers
124
+
125
+ ```bash
126
+ lattices layer session # list all session layers
127
+ lattices layer session "Coding" # switch to "Coding"
128
+ lattices layer session 0 # switch by index
129
+ ```
130
+
131
+ ## Daemon API (Advanced)
132
+
133
+ For finer control, use raw daemon calls:
134
+
135
+ ```bash
136
+ # Create layer with window IDs
137
+ lattices call session.layers.create '{"name":"Coding","windowIds":[1234,5678]}'
138
+
139
+ # Create layer with app references
140
+ lattices call session.layers.create '{"name":"Design","windows":[{"app":"Figma"},{"app":"Google Chrome","contentHint":"Tailwind"}]}'
141
+
142
+ # Tile a specific window
143
+ lattices call window.place '{"wid":1234,"placement":"left"}'
144
+
145
+ # Switch layer
146
+ lattices call session.layers.switch '{"name":"Coding"}'
147
+
148
+ # List session layers
149
+ lattices call session.layers.list
150
+
151
+ # Delete
152
+ lattices call session.layers.delete '{"name":"old-layer"}'
153
+ ```
154
+
155
+ ## Composing Layers from Intent
156
+
157
+ When a user says something high-level, here's how to think about it:
158
+
159
+ ### "Make me a coding layer"
160
+ 1. Find terminal windows (iTerm2, Terminal, Warp, etc.)
161
+ 2. Find browser windows with dev-related titles (GitHub, docs, localhost)
162
+ 3. Main editor/terminal on `left`, reference material on `right`
163
+
164
+ ### "Set up a design layer"
165
+ 1. Find design tools (Figma, Sketch, Adobe XD)
166
+ 2. Find browser windows with design references
167
+ 3. Design tool `left` (or `maximize`), references `right`
168
+
169
+ ### "Create a writing layer"
170
+ 1. Find text editors, notes apps (Notes, Obsidian, iA Writer, VS Code with .md)
171
+ 2. Find research/reference windows
172
+ 3. Writing app `left` or `center`, references `right`
173
+
174
+ ### "Give me a communication layer"
175
+ 1. Find messaging apps (Slack, Discord, Messages)
176
+ 2. Find email (Mail, Gmail in browser)
177
+ 3. Arrange by priority — primary tool `left`, secondary `right`
178
+
179
+ ### "Split my work into layers by project"
180
+ 1. Group windows by project (match on title keywords, session names, or app)
181
+ 2. Create one layer per project group
182
+ 3. Use the 3-window layout pattern: main `left`, support `top-right`, `bottom-right`
183
+
184
+ ## App Grouping Heuristics
185
+
186
+ When deciding which windows go together:
187
+
188
+ | Category | Common apps | Goes well with |
189
+ |----------|-------------|----------------|
190
+ | **Code** | iTerm2, Terminal, VS Code, Xcode | Chrome (docs/GitHub), Simulator |
191
+ | **Design** | Figma, Sketch, Pixelmator | Chrome (design systems), Preview |
192
+ | **Writing** | Notes, Obsidian, iA Writer | Chrome (research), Preview |
193
+ | **Communication** | Slack, Discord, Messages, Mail | Calendar, Notes |
194
+ | **Media** | Spotify, Music, Podcasts | (background, no tile needed) |
195
+ | **Reference** | Chrome, Safari, Preview, Finder | (depends on content) |
196
+
197
+ Browser windows are chameleons — use `title` matching to assign them to the right layer based on their content.
198
+
199
+ ## Tips
200
+
201
+ - Prefer `wid` when the windows are already open — it's unambiguous.
202
+ - Use `app` + `title` when you want the layer to survive window restarts.
203
+ - Don't put more than 4-5 windows in a single layer — it gets cramped.
204
+ - Background apps (music, etc.) usually don't need to be in any layer.
205
+ - The `snap` command is great for "save what I have now" scenarios.
206
+ - Session layers are ephemeral — they live until the daemon restarts. For permanent layers, edit `~/.lattices/workspace.json`.
207
+ - You can create multiple layers in sequence, then switch between them with `lattices layer session <name>`.
package/docs/agents.md ADDED
@@ -0,0 +1,233 @@
1
+ ---
2
+ title: Agent Guide
3
+ description: Canonical contracts for agents using docs URLs, CLI, voice, and the daemon API
4
+ order: 6
5
+ ---
6
+
7
+ Lattices exposes the same execution model through four surfaces:
8
+
9
+ - **Docs URLs** for discovery and citation
10
+ - **CLI** for shell-based agents
11
+ - **Daemon API** for typed programmatic control
12
+ - **Voice / hands-off / HUD** as clients of the same execution layer
13
+
14
+ The rule is simple: agents should learn the **canonical action model**
15
+ first, then choose the transport that fits the environment.
16
+
17
+ ## Canonical mutations
18
+
19
+ These are the preferred action identifiers:
20
+
21
+ | Action | Purpose | Preferred surface |
22
+ |--------|---------|-------------------|
23
+ | `window.place` | Place a window or session using a typed placement spec | `actions.execute` |
24
+ | `layer.activate` | Bring up a workspace layer with explicit activation mode | Daemon API |
25
+ | `space.optimize` | Rebalance a set of windows using an explicit scope and strategy | Daemon API |
26
+
27
+ Compatibility wrappers still exist:
28
+
29
+ | Legacy method | Canonical equivalent |
30
+ |---------------|----------------------|
31
+ | `window.place` | `actions.execute` with `type=window.place` |
32
+ | `window.tile` | `window.place` |
33
+ | `layer.switch` | `layer.activate` with `mode=launch` |
34
+ | `layout.distribute` | `space.optimize` with `scope=visible`, `strategy=balanced` |
35
+
36
+ ## Discoverability
37
+
38
+ Agents should use these paths in order:
39
+
40
+ 1. **API schema**: `lattices call api.schema`
41
+ 2. **Daemon reference**: [/docs/api](/docs/api)
42
+ 3. **Agent guide**: [/docs/agents](/docs/agents)
43
+ 4. **Voice model**: [/docs/voice](/docs/voice)
44
+ 5. **Concepts / config**: [/docs/concepts](/docs/concepts), [/docs/config](/docs/config)
45
+
46
+ Useful CLI discovery commands:
47
+
48
+ ```bash
49
+ lattices help
50
+ lattices call api.schema
51
+ lattices voice intents
52
+ ```
53
+
54
+ For window actions, resolve before mutating when target identity matters:
55
+
56
+ ```bash
57
+ lattices call window.resolve '{"target":{"kind":"session","session":"frontend-a1b2c3"},"placement":"left"}'
58
+ lattices call actions.execute '{"type":"window.place","target":{"kind":"session","session":"frontend-a1b2c3"},"args":{"placement":"left"},"dryRun":true}'
59
+ ```
60
+
61
+ `window.resolve` and `dryRun` return the resolved `wid`, app/title,
62
+ target resolution path, display, and planned frame without moving the
63
+ window.
64
+
65
+ Verified `window.place` receipts include `undoable: true` when Lattices
66
+ captured a concrete window id and previous frame. Agents can restore the
67
+ latest undoable placement, or an entire request batch, through:
68
+
69
+ ```bash
70
+ lattices call actions.undo '{}'
71
+ lattices call actions.undo '{"requestId":"req_..."}'
72
+ lattices call actions.undo '{"receiptId":"exec_...","dryRun":true}'
73
+ ```
74
+
75
+ Undo checks that the window is still where the original receipt left it
76
+ before restoring the previous frame. Pass `force:true` only when the
77
+ caller intentionally wants to override a later manual move.
78
+
79
+ ## Agent documentation artifacts
80
+
81
+ The site build emits agent-first files in addition to rendered pages.
82
+ Use these when an agent needs raw markdown, prompt text, or a compact
83
+ context bundle without scraping HTML.
84
+
85
+ | Need | URL |
86
+ |------|-----|
87
+ | Discovery manifest | `/agent/manifest.json` or `/docs.json` |
88
+ | Full docs with markdown bodies | `/agent/docs.json` or `/agent-docs.json` |
89
+ | Prompt registry | `/agent/prompts.json` or `/prompts.json` |
90
+ | Combined agent context | `/agent/context.md` or `/agent-context.md` |
91
+ | Combined raw docs | `/agent/bundles/all.md` or `/docs/all.md` |
92
+ | Core onboarding bundle | `/agent/bundles/core.md` |
93
+ | Daemon/API bundle | `/agent/bundles/daemon-api.md` |
94
+ | Voice and prompts bundle | `/agent/bundles/voice.md` |
95
+ | Install bundle | `/agent/bundles/install.md` |
96
+ | Raw markdown mirror | `/agent/raw/docs/<slug>.md` or `/docs/markdown/<slug>.md` |
97
+
98
+ Prompt files are mirrored at `/prompts/<id>.md` and
99
+ `/docs/prompts/<id>.md`. Nested docs keep path-safe slugs, for example
100
+ `docs/reference/install-agent.md` becomes
101
+ `/agent/raw/docs/reference/install-agent.md`.
102
+
103
+ Local scripts can import the same convenience functions used by the
104
+ build:
105
+
106
+ ```js
107
+ import {
108
+ collectMarkdownArtifacts,
109
+ getMarkdownDoc,
110
+ getPrompt,
111
+ buildAgentManifest,
112
+ buildPromptRegistry,
113
+ buildContextBundle,
114
+ writeAgentArtifacts,
115
+ } from './apps/site/scripts/agent-docs.mjs'
116
+ ```
117
+
118
+ Run `bun run docs:agent` to regenerate the static artifacts without
119
+ running the full site build.
120
+
121
+ ## Placement contract
122
+
123
+ At the boundary, placements may be strings for convenience.
124
+ Inside the daemon, the canonical contract is typed.
125
+
126
+ String shorthand:
127
+
128
+ ```json
129
+ { "placement": "top-right" }
130
+ { "placement": "grid:3x2:2,0" }
131
+ ```
132
+
133
+ Typed placement objects:
134
+
135
+ ```json
136
+ { "placement": { "kind": "tile", "value": "top-third" } }
137
+ { "placement": { "kind": "grid", "columns": 3, "rows": 2, "column": 2, "row": 0 } }
138
+ { "placement": { "kind": "fractions", "x": 0.5, "y": 0, "w": 0.5, "h": 1 } }
139
+ ```
140
+
141
+ This lets voice stay natural while the executor stays explicit.
142
+
143
+ ## Choosing a surface
144
+
145
+ Use the **daemon API** when you need:
146
+
147
+ - typed receipts and traces
148
+ - explicit targeting by `wid`, `session`, or `app`
149
+ - composition across layers, windows, and optimization
150
+
151
+ Use the **CLI** when you need:
152
+
153
+ - one-shot shell execution
154
+ - quick discovery from inside an agent terminal
155
+ - compatibility with environments that already have `lattices`
156
+
157
+ Use **docs URLs** when an agent needs:
158
+
159
+ - a citeable contract
160
+ - a stable page to open in a browser or pass to another agent
161
+ - quick onboarding without reading source
162
+
163
+ ## Examples
164
+
165
+ Node.js:
166
+
167
+ ```js
168
+ import { daemonCall } from '@lattices/cli'
169
+
170
+ await daemonCall('session.launch', { path: '/Users/you/dev/frontend' })
171
+ await daemonCall('window.resolve', {
172
+ target: { kind: 'session', session: 'frontend-a1b2c3' },
173
+ placement: 'left'
174
+ })
175
+ await daemonCall('actions.execute', {
176
+ type: 'window.place',
177
+ target: { kind: 'session', session: 'frontend-a1b2c3' },
178
+ args: { placement: { kind: 'tile', value: 'left' } }
179
+ })
180
+ await daemonCall('layer.activate', { name: 'review', mode: 'launch' })
181
+ await daemonCall('space.optimize', { scope: 'visible', strategy: 'balanced' })
182
+ ```
183
+
184
+ CLI:
185
+
186
+ ```bash
187
+ lattices call api.schema
188
+ lattices call window.resolve '{"target":{"kind":"session","session":"frontend-a1b2c3"},"placement":"left"}'
189
+ lattices call actions.execute '{"type":"window.place","target":{"kind":"frontmost"},"args":{"placement":"left"}}'
190
+ lattices call window.place '{"session":"frontend-a1b2c3","placement":"left"}'
191
+ lattices call layer.activate '{"name":"review","mode":"launch"}'
192
+ lattices call space.optimize '{"scope":"visible","strategy":"balanced"}'
193
+ ```
194
+
195
+ ## Receipts and traceability
196
+
197
+ Mutating daemon calls should return structured receipts when possible.
198
+ The important fields for agents are:
199
+
200
+ - resolved target
201
+ - resolved placement / scope / mode
202
+ - affected window IDs
203
+ - computed plan and applied mutations
204
+ - verification status
205
+ - trace entries explaining why the daemon chose that path
206
+
207
+ This is what keeps voice, hands-off, and scripted execution scrutable.
208
+
209
+ ## Voice and hands-off
210
+
211
+ Voice is not a separate execution system. It should compile into the
212
+ same canonical actions:
213
+
214
+ - "put Terminal in the upper third" → `window.place`
215
+ - "bring up review" → `layer.activate`
216
+ - "make this nice" → `space.optimize`
217
+
218
+ That keeps the interaction layer flexible while the executor stays
219
+ predictable.
220
+
221
+ ## Assistant intelligence boundary
222
+
223
+ Assistant planning lives in TypeScript where possible:
224
+
225
+ - `bin/assistant-intelligence.ts` owns the intent catalog, prompt assembly,
226
+ local rule planner, desktop snapshot formatting, and plan normalization.
227
+ - `bin/handsoff-worker.ts` and `bin/handsoff-infer.ts` call that module before
228
+ falling back to model inference.
229
+ - Swift should remain the macOS execution layer: hotkeys, windows, AX/CG,
230
+ SkyLight, panels, and visual feedback.
231
+
232
+ Use `lattices assistant plan <text> --json` to inspect the TS planner without
233
+ launching the app or mutating the desktop.