mesurer-solid 0.1.8-beta.0 → 0.1.8-beta.2

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.
@@ -2,9 +2,9 @@
2
2
 
3
3
  Mesurer's agent integration is the rendered page itself. The coding agent reads `window.__MESURER__` through the browser control it already has, consumes human visual intent, edits normal application source, and verifies the real Live result.
4
4
 
5
- The normal agent workflow requires no Mesurer MCP server, localhost daemon, Send-to-agent callback, or harness-specific transport. The optional `codex()` plugin is a separate human convenience path for explicitly sending Context feedback to Codex threads that a local Codex process or the user has registered with the loopback companion; it does not replace the browser-state contract described here.
5
+ The normal agent workflow requires no Mesurer MCP server, localhost daemon, Send-to-agent callback, or browser-tool-specific transport. The optional `codex()` plugin is a separate human convenience path for explicitly sending Context feedback to Codex threads that a local Codex process or the user has registered with the loopback companion; it does not replace the browser-state contract described here.
6
6
 
7
- ## Install the Agent Skill
7
+ ## Install the agent skill
8
8
 
9
9
  ```bash
10
10
  npx --yes --package=mesurer-solid mesurer-skill install
@@ -18,9 +18,20 @@ The installer writes a self-contained skill and injection artifact:
18
18
  .agents/skills/mesurer-ui/
19
19
  ├── SKILL.md
20
20
  └── assets/
21
- └── inject-script.js
21
+ ├── inject-script.js
22
+ ├── codex-connect.mjs
23
+ ├── codex-lifecycle.mjs
24
+ └── codex-bridge.mjs
22
25
  ```
23
26
 
27
+ ## Know the available capabilities
28
+
29
+ The base inspector includes Select, X-ray, Rulers, Typography, Guides, Distance, and Settings. Native Color Picker appears only when the browser exposes a working `EyeDropper`.
30
+
31
+ First-party plugins add Context, Arrange, Screenshot, and optional Codex delivery. The complete public map, including the low-level inspection methods and plugin host, is in [Capabilities](../../docs/CAPABILITIES.md).
32
+
33
+ For normal coding-agent work, use `window.__MESURER__`. Use `window.__MESURER_INSTANCE__` only when the task requires mounted-instance or plugin-host operations.
34
+
24
35
  ## Reuse a live instance
25
36
 
26
37
  Before injecting anything, check whether Mesurer is already connected:
@@ -48,9 +59,9 @@ Do not replace a live instance while consuming human review state.
48
59
 
49
60
  ## Inject only when absent
50
61
 
51
- Use the browser, Electron, WebView, Playwright, CDP, or other evaluation channel the harness already owns. With the installed skill, evaluate `.agents/skills/mesurer-ui/assets/inject-script.js`. With the npm package installed, read `mesurer-solid/inject-script`.
62
+ Use the browser, Electron, WebView, Playwright, CDP, or other evaluation channel the browser controller already provides. With the installed skill, evaluate `.agents/skills/mesurer-ui/assets/inject-script.js`. With the npm package installed, read `mesurer-solid/inject-script`.
52
63
 
53
- Do not mutate application source or create another browser connection merely to get Mesurer into a page the harness can already evaluate.
64
+ Do not mutate application source or create another browser connection merely to get Mesurer into a page the browser controller can already evaluate.
54
65
 
55
66
  The optional human Screenshot plugin remains disabled during normal agent injection unless configured before first injection:
56
67
 
@@ -60,7 +71,7 @@ window.__MESURER_CONFIG__ = { screenshot: true }
60
71
 
61
72
  ## Inventory human intent
62
73
 
63
- For a broad request such as “check Mesurer,” collect all relevant state before editing source:
74
+ For a broad request such as "check Mesurer," collect all relevant state before editing source:
64
75
 
65
76
  ```js
66
77
  const capabilities = window.__MESURER__.capabilities().capabilities
@@ -99,6 +110,31 @@ const textEditIntents = await Promise.all(
99
110
 
100
111
  Treat annotation notes, Arrange Desired geometry, and text/style Desired state as intent. Treat selection, measurements, distances, geometry, and computed styles as rendered evidence.
101
112
 
113
+ ## Agent API reference
114
+
115
+ Use the high-level Context and saved-intent methods for normal UI work. The lower-level methods are useful when you need a direct element lookup, point lookup, plugin command, or one combined state snapshot.
116
+
117
+ | Method | Use it for |
118
+ | --- | --- |
119
+ | `ready()` | Wait for Mesurer to finish loading. |
120
+ | `describe()` | Read loaded plugins and their tools, settings, overlays, state, commands, hooks, and services. |
121
+ | `inspect(selector, index?)` | Inspect one matching rendered element. |
122
+ | `inspectAll(selector, limit?)` | Inspect several matches without changing selection. |
123
+ | `at(x, y)` | Inspect the page element at viewport coordinates. |
124
+ | `distance(a, b)` | Measure two selector targets. |
125
+ | `viewport()` | Read viewport/document dimensions, scrolling, device pixel ratio, and overflow. |
126
+ | `feedback(selectors?)` | Read viewport data, inspected elements, plugin description, and plugin state together. |
127
+ | `command(id, args?)` | Execute a registered Mesurer command. |
128
+ | `state()` | Read plugin state. |
129
+ | `stable(frames?)` | Wait for fonts and rendering before measuring again. |
130
+ | `textEdits()` / `textEdit(id)` | Read saved direct-text and typography intent. |
131
+
132
+ Context adds `capabilities()`, `context()`, `contextText()`, `select()`, `annotations()`, `review()`, `capturePlan()`, `prepareCapture()`, and `finishCapture()`.
133
+
134
+ Arrange adds `arrangements()`, `arrange()`, `showArrange()`, `arrangeCapturePlan()`, and `reviewArrange()`.
135
+
136
+ Use `capabilities().capabilities` before calling optional Context, Arrange, or text-edit paths. The complete public list is in [Capabilities](../../docs/CAPABILITIES.md).
137
+
102
138
  ## Select exact targets
103
139
 
104
140
  Do not overwrite a meaningful human selection until its context has been retained. When there is no relevant human selection and the exact targets are known:
@@ -149,9 +185,9 @@ Native editing stays native. Mesurer does not intercept form controls or descend
149
185
 
150
186
  The editing UI exposes direct B/I/U, Font, Size, Weight, rendered-page colors, custom color, and a separate Text/H1/H2/H3 semantic preset popup. Missing heading levels are not invented.
151
187
 
152
- If Typography was already explicitly selected, the direct-edit session suppresses the older hover/pinned Typography surface so the field has one live card. The normal surface returns when editing ends.
188
+ If Typography was already explicitly selected, the direct-edit session suppresses the older hover/pinned Typography UI so the field has one live card. The normal Typography UI returns when editing ends.
153
189
 
154
- Direct edit also owns the field's visible selection lane. The duplicate ordinary selected border is paint-suppressed, the selected dimensions pill remains available, and the Typography card stays source-relative without reacting to ordinary pointer movement. The selection-adjacent Add Note button is intentionally hidden during the active edit and returns afterward. Existing saved annotation state remains available throughout.
190
+ Direct edit also owns the field's visible selection lane. The duplicate ordinary selected border is paint-suppressed, the selected dimensions pill remains available, and the Typography card stays source-relative without reacting to ordinary pointer movement. The selection-adjacent Add Note button is hidden only during the active edit and returns afterward. Existing saved annotation state remains available throughout.
155
191
 
156
192
  Read durable intent through:
157
193
 
@@ -176,6 +212,12 @@ A saved annotation carries target-bound intent and an immutable baseline:
176
212
  const context = await window.__MESURER__.context({ annotation: annotationId })
177
213
  ```
178
214
 
215
+ Saved annotation UI is source-linked presentation, not the durable state itself. Saved annotations survive a same-tab reload and conservatively rebind through their stored selector/fingerprint identity; ambiguous targets remain unresolved rather than attaching to a different element. Add Note, its composer, saved markers and panels, and the ownership edge move with their target through window and nested scrolling. A saved panel keeps its target-relative page point and may leave the viewport with its source. Several notes on one target keep separate nearby markers, and Add Note remains available while an existing note is open.
216
+
217
+ Do not infer that an annotation disappeared because its card or marker is currently offscreen. Read `annotations()` and annotation-scoped `context()` instead. When a note is highlighted, the temporary ownership emphasis uses one exact target boundary rather than a second fill, glow, or rounded frame.
218
+
219
+ Context cards are Mesurer inspector UI. Live Select hover and selection evidence must paint underneath the composer and saved panels, including when the outer Mesurer host is in the browser top layer. Agents should treat the cards as interaction boundaries rather than attempting to select page content through them.
220
+
179
221
  After source changes:
180
222
 
181
223
  ```js
@@ -187,13 +229,13 @@ const review = await window.__MESURER__.review(annotationId)
187
229
 
188
230
  ## Screenshots
189
231
 
190
- For ordinary coding-agent evidence, the outer harness owns screenshot bytes while Mesurer prepares capture presentation:
232
+ For ordinary coding-agent evidence, the browser controller owns screenshot bytes while Mesurer prepares capture presentation:
191
233
 
192
234
  ```js
193
235
  const plan = await window.__MESURER__.capturePlan({ annotation: annotationId })
194
236
  await window.__MESURER__.prepareCapture()
195
237
  try {
196
- // harness screenshot
238
+ // browser-controller screenshot
197
239
  } finally {
198
240
  await window.__MESURER__.finishCapture()
199
241
  }
@@ -203,11 +245,19 @@ The optional human `screenshot()` plugin from `mesurer-solid/plugins` is a separ
203
245
 
204
246
  ## Optional human-to-Codex delivery
205
247
 
206
- A source-mounted page may opt into `codex()` from `mesurer-solid/plugins` alongside `context()`. This is not an agent integration requirement and does not add a generic send capability to `window.__MESURER__`.
248
+ A page can mount `codex()` next to `context()` for explicit human-triggered delivery. This is optional and does not add a generic send method to `window.__MESURER__`.
249
+
250
+ For local Codex projects, the trusted `SessionStart` connector starts or reuses the packaged loopback companion and registers the current session with its project directory. Browser code cannot register arbitrary sessions or start the local process.
251
+
252
+ Delivery uses Codex's native durable queue. Mesurer queues once and keeps the queued-submission id. Desktop delivery opens the existing `codex://threads/<threadId>` destination and lets Codex's queue watcher run the item when the thread can accept it. CLI/TUI sessions use the same queued item and may resume a cold `notLoaded` thread through the shared daemon. Mesurer never calls `turn/steer`, never deletes and resends an existing queue item during recovery, and does not use the Desktop app-tools pipe as a second delivery path.
253
+
254
+ The browser plugin connects lazily on the first Queue to Codex or thread-picker action. Page affinity and an explicit destination override persist per tab. If several registered threads are visible and the page has no saved destination, the user must choose one.
255
+
256
+ The typed `codex:v1` service exposes `health()`, `listThreads()`, `useThread(thread)`, `delivery(deliveryId)`, and `send({ thread })`. Queue submission is single-flight. A matched completed turn may remove only the annotation ids sent with that delivery; interrupted, failed, ambiguous, or unreadable work keeps them.
207
257
 
208
- When the current Codex thread starts `mesurer-codex`, the companion reads Codex's `CODEX_THREAD_ID`, registers that thread, and makes it the default destination. That means a Codex session that starts or uses Mesurer can route later human Context feedback back to the same thread without copying an id by hand. A normal shell may still select the initial session explicitly with `mesurer-codex --thread <SESSION>`.
258
+ Mesurer does not create new Codex threads. Create or open the thread in Codex and let `SessionStart` register it. Turn completion is transport lifecycle, not proof that the requested UI result is correct.
209
259
 
210
- A different or newly-created Codex thread can join an already-running bridge with `mesurer-codex --register-current`. Registration is accepted only from a local process without a browser Origin. The bridge keeps previously registered threads; the `codex:v1` service can inspect them with `health()`, switch the default with `useThread(thread)`, or send one message to another registered destination with `send({ thread })`. Mesurer does not create or resume Codex threads itself. See [Send Context feedback to Codex](../../docs/CODEX.md).
260
+ See [Queue Context feedback to Codex](../../docs/CODEX.md) for setup, routing, recovery, privacy, and failure behavior.
211
261
 
212
262
  ## Revalidate after source edits
213
263
 
@@ -231,4 +281,4 @@ Do not clear human history merely to expose Live state, and do not reinject just
231
281
 
232
282
  A meaningful Mesurer call should affect the work. If exact geometry is available, use it instead of estimating pixels from a screenshot. If the user already encoded intent in Arrange, text editing, annotations, or selection, consume it before asking them to repeat it.
233
283
 
234
- The repository's packaged [`mesurer-ui` skill](./skills/mesurer-ui/SKILL.md) carries the operational version of this contract for coding agents. [Browser and agent integration](../../docs/BROWSER_HARNESS.md) documents the outer harness boundary.
284
+ The repository's packaged [`mesurer-ui` skill](./skills/mesurer-ui/SKILL.md) carries the operational version of this contract for coding agents. [Browser and agent integration](../../docs/BROWSER_HARNESS.md) documents the browser-control boundary.
package/README.md CHANGED
@@ -64,13 +64,14 @@ For explicit plugin composition, `mesurer-solid/plugins` also exports `select`,
64
64
 
65
65
  | Entry | Purpose |
66
66
  | --- | --- |
67
- | `mesurer-solid` | Mount API, public domain types, and agent surface |
67
+ | `mesurer-solid` | Mount API, public domain types, and agent API |
68
68
  | `mesurer-solid/plugins` | All first-party plugin factories and plugin-specific contracts |
69
69
  | `mesurer-solid/core` | Lower-level framework-neutral public contracts |
70
70
  | `mesurer-solid/inject` | Programmatic browser injection |
71
71
  | `mesurer-solid/inject-script` | Built classic injection artifact |
72
72
  | `mesurer-skill` | Install the portable coding-agent skill |
73
73
  | `mesurer-codex` | Run the optional loopback Codex queue companion |
74
+ | `mesurer-codex-connect` | Start or reuse the matching Codex companion and register the current Codex session |
74
75
 
75
76
  ## Features
76
77
 
@@ -81,6 +82,7 @@ For explicit plugin composition, `mesurer-solid/plugins` also exports `select`,
81
82
  - Arrange selected UI into a Desired position without changing source.
82
83
  - Capture visible-tab regions through the optional Screenshot plugin.
83
84
  - Read selection, measurements, guides, annotations, layout, styles, and saved human intent through Context and agent APIs.
85
+ - Keep saved annotations across same-tab reloads and conservatively rebind them to their original DOM targets; markers, cards, and ownership evidence stay attached through scrolling, repeated-note markers stay local, Add Note remains available while a note is open, and cards/composers occlude Select hover and selection chrome.
84
86
  - Extend the runtime with tools, settings, overlays, commands, hooks, state, and services.
85
87
  - Compact the toolbar to active controls without changing tool state or order.
86
88
 
@@ -94,7 +96,7 @@ Mesurer previews text, styles, and Arrange transforms only while it still owns t
94
96
 
95
97
  ## Shortcuts
96
98
 
97
- Global shortcuts are enabled by default. Turn them off from **Settings → General → Shortcuts** or pass `shortcutsEnabled: false` to `mountMesurer()`. Toolbar controls, editor-local keys, and Escape/cancel behavior remain available.
99
+ Global shortcuts are enabled by default. Turn them off from **Settings > General > Shortcuts** or pass `shortcutsEnabled: false` to `mountMesurer()`. Toolbar controls, editor-local keys, and Escape/cancel behavior remain available.
98
100
 
99
101
  | Shortcut | Action |
100
102
  | --- | --- |
@@ -118,7 +120,7 @@ Plugin shortcuts are active only when their plugin is mounted and enabled.
118
120
 
119
121
  ## Agent integration
120
122
 
121
- Enable `agent: true` to expose rendered state through the mounted API and `window.__MESURER__`.
123
+ Enable `agent: true` to expose the full browser agent object through `mesurer.agent` and `window.__MESURER__`. The mounted instance also mirrors the high-level Context, Arrange, and text-intent methods.
122
124
 
123
125
  ```ts
124
126
  const workspace = await mesurer.context()
@@ -135,21 +137,9 @@ The skill preserves existing human state, reads Arrange/text/annotation intent b
135
137
 
136
138
  See [Agent integration](https://github.com/jhomra21/mesurer-solid/blob/main/packages/mesurer/AGENT_INTEGRATION.md).
137
139
 
138
- ### Optional Send to Codex
140
+ ### Optional Queue to Codex
139
141
 
140
- When Codex starts the loopback companion itself, `mesurer-codex` reads `CODEX_THREAD_ID`, so Mesurer feedback naturally routes back to that same Codex CLI/App thread:
141
-
142
- ```bash
143
- bunx mesurer-codex
144
- ```
145
-
146
- A normal shell can still choose the initial thread explicitly:
147
-
148
- ```bash
149
- bunx mesurer-codex --thread <SESSION>
150
- ```
151
-
152
- Mount the optional transport next to Context:
142
+ Mount `codex()` next to Context when a person should be able to queue the current review to Codex:
153
143
 
154
144
  ```ts
155
145
  import { mountMesurer } from "mesurer-solid"
@@ -160,27 +150,27 @@ mountMesurer({
160
150
  })
161
151
  ```
162
152
 
163
- A different or newly-created Codex thread can register itself with the running bridge and become the active target:
153
+ The trusted Codex `SessionStart` integration normally starts or reuses the local companion and registers the current thread. It can also be run directly:
164
154
 
165
155
  ```bash
166
- bunx mesurer-codex --register-current
156
+ bunx mesurer-codex-connect
167
157
  ```
168
158
 
169
- The bridge remembers registered threads. `codex:v1` exposes `health()`, `useThread(thread)`, and `send({ thread })` for switching or one-off routing among those registered destinations. Browser pages cannot register arbitrary Codex sessions themselves.
170
-
171
- This uses Codex's own queued-user-message command. It does not replace the normal browser-harness agent workflow, and it does not resume or take ownership of a target Codex thread.
159
+ **Queue to Codex** writes one item to Codex's native durable queue and tracks that delivery through Queued, Working, Finished, or Interrupted. It does not create threads or invoke Steer. A Mesurer page keeps its selected destination across a same-tab reload.
172
160
 
173
- See [Send Context feedback to Codex](https://github.com/jhomra21/mesurer-solid/blob/main/docs/CODEX.md).
161
+ Saved annotations included in a delivery are removed only after the exact matched turn completes. Interrupted, failed, or uncertain deliveries keep them. Set `codex({ clearCompletedAnnotations: false })` to retain completed notes.
174
162
 
163
+ See [Queue Context feedback to Codex](https://github.com/jhomra21/mesurer-solid/blob/main/docs/CODEX.md) for thread discovery, Desktop and CLI/TUI behavior, lifecycle recovery, permissions, and the typed `codex:v1` service.
175
164
  ## Documentation
176
165
 
166
+ - [Capabilities](https://github.com/jhomra21/mesurer-solid/blob/main/docs/CAPABILITIES.md)
177
167
  - [Getting started](https://github.com/jhomra21/mesurer-solid/blob/main/docs/GETTING_STARTED.md)
178
168
  - [Direct text editing and Typography](https://github.com/jhomra21/mesurer-solid/blob/main/docs/TEXT_EDITING.md)
179
169
  - [Arrange](https://github.com/jhomra21/mesurer-solid/blob/main/docs/ARRANGE.md)
180
170
  - [Screenshots](https://github.com/jhomra21/mesurer-solid/blob/main/docs/SCREENSHOTS.md)
181
171
  - [Context workflow](https://github.com/jhomra21/mesurer-solid/blob/main/docs/CONTEXT_WORKFLOW.md)
182
- - [Send Context feedback to Codex](https://github.com/jhomra21/mesurer-solid/blob/main/docs/CODEX.md)
183
- - [Browser harness](https://github.com/jhomra21/mesurer-solid/blob/main/docs/BROWSER_HARNESS.md)
172
+ - [Queue Context feedback to Codex](https://github.com/jhomra21/mesurer-solid/blob/main/docs/CODEX.md)
173
+ - [Browser and agent integration](https://github.com/jhomra21/mesurer-solid/blob/main/docs/BROWSER_HARNESS.md)
184
174
  - [Host isolation](https://github.com/jhomra21/mesurer-solid/blob/main/docs/HOST_ISOLATION.md)
185
175
  - [Trusted Types](https://github.com/jhomra21/mesurer-solid/blob/main/docs/TRUSTED_TYPES.md)
186
176