@khanglvm/relay 0.16.1 → 0.17.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.
@@ -1,618 +1,147 @@
1
1
  ---
2
2
  name: relay
3
- description: "Collect user decisions & answers — choice, multi, yes-no, text, scale, rank, checklist, allocate, color — and present plans, data, code, git diffs/conflicts, designs, charts, tables, diagrams, images, PDFs, videos, HTML, palettes, typography, and file views on a browser or inline MCP board. Returns JSON answers/notes/comments/annotations/blockEdits on Submit. Use PROACTIVELY for 2+ questions, visual review, plans, metrics, tables, diffs, git pick/cherry-pick/conflict decisions, markdown files, or anything the terminal cannot render well. Use the most specific component instead of prose. Skip single yes/no."
3
+ description: "Present files, visuals, plans, diffs, and structured user decisions in a Relay browser or inline MCP board. Use for visual review, rich reports, or multiple related questions; use native chat for simple answers and single confirmations."
4
4
  ---
5
5
 
6
- # relay (`rly`)
6
+ # Relay (`rly`)
7
7
 
8
- CLI that opens a local web board for the user, blocks until they click
9
- **Submit**, and prints their answers plus element-level annotations as JSON to
10
- stdout. Works for any agent (Claude Code, Codex, …). Answers autosave in real
11
- time; the tab auto-closes after submit.
8
+ Choose the surface and component that lets the user understand or decide with
9
+ least effort. Use Relay for files, visuals, substantial plans, and related
10
+ questions. Keep ordinary progress updates and brief answers in chat. Follow the
11
+ user’s existing authorization; a board is not an extra approval requirement.
12
12
 
13
- If `rly` is not installed: `npm i -g @khanglvm/relay` or invoke via
14
- `npx -y @khanglvm/relay <command …>`.
13
+ ## Choose the operation
15
14
 
16
- **Inside the Claude or Codex app?** relay is also an MCP App: if the
17
- `relay_ask` / `relay_show` tools are available, call them with the same board
18
- spec (below) and the board renders **inline in the chat** — no terminal, no
19
- browser tab; the user's answers come straight back to you. Set it up once with
20
- `rly mcp install --target claude|codex` (or `rly mcp config`). Everything below
21
- describes the spec both surfaces share.
15
+ - **Show content without asking for feedback:** `rly show --file spec.json --display-only`.
16
+ Returns immediately; no Submit button or waiter is needed.
17
+ - **Collect answers or comments:** `rly ask --file spec.json --detach`, then wait
18
+ for that board’s result. Put related questions on one board.
19
+ - **Read a file:** `rly view report.md --display-only`; also accepts CSV/TSV/JSON
20
+ tables and PDF. Use a `code` block with `codeFile` for source code.
21
+ - **Show changes:** `rly diff`; `rly git pick`, `rly git cherry-pick --code`, and
22
+ `rly git conflict` collect commit/hunk choices. Apply only the user’s choices.
23
+ - **Continue an existing board:** identify it by URL/port/title with `rly list`
24
+ or `rly history`. Use `rly rescue <id>` for a disconnected tab (same port),
25
+ `rly reopen <id>` for a new tab with saved input, or `rly update <id> --file
26
+ spec.json` to change its content. `rly reuse` deliberately starts a blank run.
22
27
 
23
- **Full reference: run `rly agent` (complete guide) and `rly schema` (spec JSON
24
- Schema).** The essentials are below.
28
+ If Relay MCP tools are available in the current host, `relay_ask` collects input
29
+ inline and `relay_show` is display-only by default. Use the actual exposed tool
30
+ schema; setup details are in `rly mcp config`. Local file-link previews require
31
+ the **browser board** server. For inline MCP, embed file content using `mdFile`,
32
+ `codeFile`, or an image block instead.
25
33
 
26
- ## When to use rly vs your native question tool
34
+ ## Author a board
27
35
 
28
- **The core principle — match the surface to the content.** You run inside a
29
- terminal, an IDE side-panel (VS Code / JetBrains / Cursor), or a plain-text chat.
30
- None of those can actually render a markdown file, an image, a chart, a table, a
31
- diagram, or a diff — they degrade to walls of monospace text, or can't show it at
32
- all (a terminal can't draw a PNG). relay opens a real browser board that renders it
33
- properly and reads the user's reply back as JSON. **So whenever what you're about to
34
- output would read better than monospace — or is a file/visual the user should look
35
- at — show it in a relay board instead of printing it.**
36
-
37
- | Situation | Use |
38
- |---|---|
39
- | One trivial confirmation ("proceed?") | native tool |
40
- | Show an image / screenshot / mockup / rendered output | **rly** (`image` block — the terminal can't display pixels) |
41
- | 2+ questions, or options that need descriptions | **rly** |
42
- | Choice is easier to make visually (layouts, designs, diagrams) | **rly** (blocks per question) |
43
- | Each OPTION has its own visual (design variants, screenshots, charts) | **rly** (blocks per option) |
44
- | Show metrics / trends / data comparisons | **rly** (chart + table blocks) |
45
- | Present a prototype / demo an idea | **rly show** — never hand-roll an HTML file + server |
46
- | Gather requirements / plan approval / feedback round | **rly** |
47
- | Architecture or flow that benefits from a diagram | **rly** (mermaid block) |
48
- | "Show me the diff" / git diff / code changes / before-after | **rly** (`diff` block — run `git diff`, render it; never dump it in the terminal) |
49
- | Pick/cherry-pick commits or resolve conflict files | **rly git** (`rly git pick`, `rly git cherry-pick --code`, `rly git conflict`) |
50
- | A demo, screen recording or walkthrough | **rly** (`video` block) |
51
- | Point the user at a file to open (log, capture, report) | **rly** (a clickable local file-link in markdown) |
52
- | Let the user read a markdown file (README, plan, report) | **rly view file.md** (or a `markdown` block with `mdFile`) — never dump the file into the terminal |
53
- | Plan-mode clarifying question (Claude Code / Codex) | **rly** (not AskUserQuestion / the native ask tool) |
54
- | Something you can decide yourself from context | neither — just decide |
55
-
56
- This holds **in plan mode** too: route every clarifying or decision question
57
- through relay — the native `AskUserQuestion` / ask-user tool is **not** a
58
- substitute, even though plan-mode guidance suggests it. Reserve the harness's
59
- `ExitPlanMode` strictly for the final plan-approval gate (it's a mode
60
- transition, not a question).
61
-
62
- Once the user has answered one board in a session, prefer boards for later
63
- question rounds too — they've shown they engage with them. Batch related
64
- questions into ONE board rather than opening several in a row.
65
-
66
- ## The full toolbox — reach for the MOST SPECIFIC component
67
-
68
- relay ships a purpose-built component for most kinds of content. **Before you
69
- build a board, scan this list and pick the most specific component that fits — do
70
- NOT fall back to a plain `markdown`/prose block (or the terminal) when a dedicated
71
- one renders it better.** A KPI belongs in `kpi`, a before/after in `compare`, a
72
- priority call in a `rank` question — not in paragraphs. Unsure which exists? Run
73
- `rly agent` (full guide) and `rly schema` (every field).
74
-
75
- **Blocks** — add under `"blocks": [...]` at the board, a question, or an option:
76
-
77
- | Block | Reach for it when you have… |
78
- |---|---|
79
- | `table` | tabular data — sortable, per-cell comments; `rowsFile` (.csv/.json), `filterable`, `exportable` |
80
- | `chart` | numbers / trends / comparisons (bar·line·pie·doughnut·radar·scatter) |
81
- | `kpi` | headline metrics — big-number cards with ↑/↓/flat deltas (no chart needed) |
82
- | `mermaid` | flows, sequences, state machines, architecture (set `editable:true` to co-edit) |
83
- | `graphviz` | precise dependency / call graphs |
84
- | `plantuml` | UML (sequence / class / component) |
85
- | `code` | source / config / command output — highlighted, line numbers, hover-a-line to comment |
86
- | `diff` | code changes — colored unified/split, multi-file (`rly diff` builds the whole board) |
87
- | `git-conflict` | conflict-marker files — side-by-side ours/theirs/base with hunk choices; returns resolved content in `result.blockEdits[blockId]` |
88
- | `image` | screenshots / mockups / renders — drag → area crop; Space-drag/middle-button → pan; `pins:true` → point comments |
89
- | `compare` | a before/after pair — draggable divider; area comments retain the selected side |
90
- | `video` | a demo / screen recording / walkthrough |
91
- | `pdf` | a quote / report / exported document that should render inline |
92
- | `palette` | color schemes — swatch cards, hover-hex, click-to-copy |
93
- | `typography` | type choices — specimens at given size/weight/font |
94
- | `html` | anything bespoke — custom widgets, pixel-perfect mockups |
95
- | `markdown` | prose / context ONLY (not data, metrics, or visuals — those have their own block) |
96
-
97
- Any block also takes `"ref":"name"` → a question can link to it with
98
- `[label](#ref:name)` and it opens **in a full-screen modal**, so the user views the
99
- data without scrolling back up.
100
-
101
- **Question types** — pick by the shape of the answer you need:
102
-
103
- | Type | Reach for it when you need… | Answer JSON |
104
- |---|---|---|
105
- | `single` | one choice (radio; "Other" + a note are on by default) | `"value"` |
106
- | `multi` | several choices | `["a","b"]` |
107
- | `rank` | a **priority order** over options (roadmap, triage) | `["b","a","c"]` |
108
- | `allocate` | a **budget split** across options (tradeoffs, %, points) | `{opt: number}` |
109
- | `checklist` | **per-item sign-off / QA** (Pass·Fail·N·A, or custom) | `{opt: status}` |
110
- | `scale` | a rating on a 1–N scale | number |
111
- | `yesno` | a binary decision | `"yes"`/`"no"` |
112
- | `color` | a color pick — native picker + presets, or a `palette` of labeled swatch cards (each commentable); any CSS color system | color string |
113
- | `text` / `textarea` | short / long free text | string |
114
-
115
- **By who you're serving** (don't make a business user read a wall of prose):
116
-
117
- - **Business / PM / exec** → `kpi` + `chart` + `table` for the numbers; `rank` to
118
- prioritize, `allocate` for tradeoffs, `checklist` for sign-off, `scale` for confidence.
119
- - **Designer** → `image` (+`pins` for point feedback), `compare` (before/after),
120
- `palette`, `typography`; put a visual INSIDE each option so they pick by looking.
121
- - **Engineer** → `diff` (`rly diff`), `code` (line-comments), `mermaid`/`graphviz`
122
- for architecture, editable mermaid to co-design.
123
- - **Data / analyst** → `table` with `rowsFile`/`filterable`/`exportable`
124
- (`rly view data.csv`), `chart` for the shape of it.
125
-
126
- ## Choose a pattern
127
-
128
- **DEFAULT: detached.** Most agent shell tools kill long-running commands, and a
129
- blocking `rly ask` that gets killed cancels the board. Always prefer:
130
-
131
- ```sh
132
- rly ask --file spec.json --detach # returns {"boardId":"b-…","url":…} immediately
133
- rly wait b-xxxxx --timeout 86400 # default: one day; 0 = no Relay deadline
134
- # (on exit 2 "wait-timeout" just run wait again)
135
- rly result b-xxxxx # non-blocking peek (includes live draft)
136
- ```
137
-
138
- Detached boards are durable: their own timeout hands the agent a `timeout`
139
- result but keeps the same URL/port serving until Submit or `rly stop`. Do not
140
- create a new board just because a wait timed out.
141
-
142
- For long waits prefer presence-aware waiting over a huge --timeout:
143
-
144
- ```sh
145
- rly wait b-xxxxx --timeout 86400 --while-active --idle-grace 3600
146
- # keeps extending while the user is demonstrably viewing/typing on the board;
147
- # returns wait-timeout promptly once they are idle/gone (presence included)
148
- rly result b-xxxxx # while open also shows presence {visible, focused, secondsSinceActivity}
149
- ```
150
-
151
- Push-wake instead of polling: add --on-result '<shell cmd>' to ask/show/reopen
152
- (or --notify-cmd on wait) - the command runs the moment the board finishes,
153
- with the full result JSON on stdin and RLY_BOARD_ID/RLY_STATUS/RLY_URL in env.
154
-
155
- **Codex browser-board pattern.** Codex does not have a normal, user-facing
156
- "wake this agent turn from a browser submit" command. If the Codex turn stops
157
- waiting, a later board submit can leave the user needing to prompt manually.
158
- So in Codex, keep the waiter in the foreground until the user submits:
159
-
160
- ```sh
161
- rly ask --file spec.json --detach
162
- rly wait b-xxxxx --timeout 86400 --while-active --idle-grace 3600
163
- ```
164
-
165
- If `rly wait` exits with `wait-timeout`, immediately run `rly result <boardId>`.
166
- If it is still open and the user may continue, run `rly wait` again. Do not use
167
- `--on-result` as the primary Codex return path; it can write files or hit
168
- webhooks, but normal Codex CLI sessions do not expose a portable inbound API
169
- that wakes the current agent turn.
170
-
171
- Blocking mode (`rly ask --file spec.json --timeout 86400`, no `--detach`) is fine
172
- ONLY when your shell tool has no execution time limit.
173
-
174
- Relay defaults board and waiter deadlines to one day; use `--timeout 0` when the
175
- client can safely own an indefinite process. Choose the return path by host:
176
-
177
- - Inline MCP `relay_ask`: no CLI wait; its `ui/message` submission wakes the
178
- return turn. Inline `relay_show` is display-only by default and does not wait.
179
- - Claude Code: background `rly wait <id> --timeout 0` as a background Bash task.
180
- - Gemini CLI: background the waiter and use
181
- `tools.shell.backgroundCompletionBehavior: "inject"`.
182
- - Codex: keep one foreground waiter; background terminals require explicit
183
- polling and do not expose a portable browser-submit wake API.
184
- - OpenCode/Pi: keep it foreground unless a background-task extension is
185
- explicitly installed (Pi core has no background Bash).
186
-
187
- Use `--on-result`/`--notify-cmd` only when the surrounding harness exposes a real
188
- webhook, file watcher, or inbound wake path.
189
-
190
- To present without asking for any response, use
191
- `rly show --file spec.json --display-only` (equivalent to
192
- `"responseRequired":false`). It returns immediately and shows no note,
193
- comments, or Submit/Acknowledge action.
194
-
195
- Useful flags: `--no-open` (don't auto-open the browser — for tests/CI; real
196
- users need the tab, so omit it normally) · `--title` · `--timeout <sec>`.
197
-
198
- Exit codes: 0 submitted · 2 timeout · 3 cancelled · 5 not found. On
199
- timeout/cancel the result still contains the autosaved `draft` of partial
200
- answers and any annotations written so far.
201
-
202
- ## Same-Wi-Fi sharing
203
-
204
- Browser boards are local-owner only by default. A phone/tablet/other laptop on
205
- the same Wi-Fi gets a locked page until sharing is explicitly activated. The
206
- owner can click the topbar **Share** icon, or an agent can manage the same links
207
- with `rly share`:
208
-
209
- ```sh
210
- rly share b-xxxxx # list active share roles
211
- rly share b-xxxxx --role review # activate a reviewer link
212
- rly share b-xxxxx --role collab # activate a collaborator link
213
- rly share b-xxxxx --role read # activate a read-only link
214
- rly share b-xxxxx --role review --revoke # revoke one role
215
- rly share b-xxxxx --revoke --all # revoke all active share links
216
- ```
217
-
218
- Use `review` for independent feedback. Each reviewer browser gets an isolated
219
- draft and can answer, comment, and submit a **reference-only side review**. That
220
- submission never finishes the board or wakes/completes the waiting agent; the
221
- owner (or owner-authorized collaborator) must still provide the final answer.
222
- When the owner asks for current reviewer input, run `rly result <id>` and inspect
223
- `sideReviews.submissions` plus `sideReviews.drafts`; both are explicitly marked
224
- reference-only. Use `read` for a view-only link with no answers, comments, block
225
- edits, local-file opening, or submit. Use `collab` only when the user explicitly
226
- wants that device to act as the owner: collaborators can edit answers, comment,
227
- open allowed local file links, and final-submit. Shared viewers refresh from the
228
- relevant live draft when another viewer in the same role/session saves.
229
- Active share links are durable too: they keep the same token across a same-port
230
- `rly reopen`/`rly rescue` until `rly share --revoke` disables them.
231
-
232
- ## Minimal spec
36
+ Write valid JSON to a file; avoid embedding large specs in shell arguments.
37
+ Use `rly schema` for exact fields and `rly agent` for detailed recipes, sharing,
38
+ HTML/annotation APIs, and less common components. Load those only as needed.
233
39
 
234
40
  ```json
235
41
  {
236
- "title": "Pick the approach",
237
- "intro": "Context for the user. Hover chart points or select text to leave comments.",
42
+ "title": "Implementation review",
43
+ "blocks": [
44
+ {"type": "markdown", "md": "Review the [source](/absolute/path/app.js:98)."},
45
+ {"type": "code", "codeFile": "/absolute/path/app.js", "ref": "source"}
46
+ ],
238
47
  "questions": [
239
- { "id": "approach", "type": "single", "label": "Which one?", "required": true,
240
- "options": [{ "value": "a", "label": "A", "description": "fast" }, "B"], "other": true },
241
- { "id": "parts", "type": "multi", "label": "Include?", "options": ["api", "ui"], "note": true },
242
- { "id": "ship", "type": "yesno", "label": "Ship now?" },
243
- { "id": "why", "type": "textarea", "label": "Reasoning?" },
244
- { "id": "conf", "type": "scale", "label": "Confidence", "min": 1, "max": 5,
245
- "minLabel": "low", "maxLabel": "high" }
48
+ {"id": "approach", "type": "single", "label": "Which approach?",
49
+ "options": [{"value": "small", "label": "Small change", "description": "Keep the current interface."},
50
+ {"value": "replace", "label": "Replace", "description": "Introduce the new interface."}]},
51
+ {"id": "notes", "type": "textarea", "label": "What needs adjusting?", "required": false}
246
52
  ]
247
53
  }
248
54
  ```
249
55
 
250
- Types: `single`, `multi`, `yesno`, `text`, `textarea`, `scale`, `color`
251
- (native picker + hex; optional `"presets":["#…"]` or a `"palette"` of labeled,
252
- commentable swatch cards — any CSS color system), `rank`, `checklist`, `allocate`.
253
- Users may submit with unanswered questions (returned in `skipped`) unless
254
- `"allowPartial": false` or per-question `"required": true`.
255
-
256
- ```jsonc
257
- { "id": "brand", "type": "color", "label": "Pick a brand color",
258
- "palette": [{ "value": "#c2674b", "label": "Terracotta" }, { "value": "rgb(77,138,102)", "label": "Forest" }, "rebeccapurple"] }
259
- // clicking a swatch = the answer; hover a swatch to comment on that specific color.
260
- ```
261
-
262
- The optional per-question note box (`result.notes[id]`) defaults ON for the
263
- **decision types** — `single`, `rank`, `checklist`, `allocate` — so the user can
264
- qualify a pick; `"note": false` hides it, `"note": true` adds it to other types.
265
-
266
- `rank` — the user drags (or uses ↑/↓) to order the `options` by priority; the
267
- answer is the **ordered array of option values**, highest first. Needs ≥2
268
- options; always returns a value (an untouched rank submits the authored order),
269
- so it's never `skipped`. Use for roadmap/feature prioritization instead of a
270
- single pick. Options take `description` and per-option `blocks` like single/multi.
271
-
272
- ```json
273
- { "id": "roadmap", "type": "rank", "label": "Order these by priority",
274
- "options": [{ "value": "diff", "label": "rly diff", "description": "git diff → board" }, "rank type", "image pins"] }
275
- ```
276
-
277
- `checklist` — each `option` gets a per-item status (default **Pass / Fail / N·A**;
278
- override with `"statuses"`). Answer is a map `{optionValue: statusValue}`. For QA
279
- passes and sign-off gates.
280
-
281
- ```json
282
- { "id": "qa", "type": "checklist", "label": "Release sign-off", "options": ["login","search","checkout"] }
283
- ```
284
-
285
- `allocate` — the user distributes a budget (`"total"`, default 100) across the
286
- `options` with sliders + a live running-total bar. Answer is a map
287
- `{optionValue: number}`. Captures intensity/tradeoffs, not just a pick.
288
-
289
- ```json
290
- { "id": "spend", "type": "allocate", "label": "Split the quarter", "total": 100, "unit": "pts",
291
- "options": ["features","tech debt","infra"] }
292
- ```
293
-
294
- Set `"note": true` on a question to add a small optional free-text field under
295
- it — use when the user may want to qualify their choice. Returned as
296
- `result.notes[questionId]`. `single` (radio) questions include this note by
297
- default (so a pick can carry a comment); set `"note": false` to hide it.
298
-
299
- Quick one-liners without a spec file:
300
-
301
- ```sh
302
- rly ask -q "Deploy now?::yesno" -q "!Env::single::dev,staging,prod" # "!" = required
303
- ```
304
-
305
- ## Blocks cheat-sheet
306
-
307
- Add `"blocks": [...]` to the root, to any question, or to any OPTION of a
308
- single/multi question.
309
-
310
- ```jsonc
311
- { "type": "markdown", "md": "## Section\n**prose**" }
312
- { "type": "markdown", "mdFile": "README.md" } // render a local .md file (no lib)
313
- { "type": "mermaid", "code": "graph TD; A-->B", "height": 400 }
314
- { "type": "graphviz", "dot": "digraph { a -> b }", "height": 300 }
315
- { "type": "plantuml", "code": "@startuml\nA->B\n@enduml", "height": 300 }
316
- { "type": "plantuml", "code": "...", "server": "https://plantuml.example.com" }
317
- { "type": "chart", "kind": "bar", "title": "...",
318
- "labels": ["Jan","Feb"], "series": [{"label":"x","data":[1,2]}], "height": 320 }
319
- { "type": "chart", "config": { /* full Chart.js v4 config */ }, "height": 300 }
320
- { "type": "table", "columns": ["A","B"], "rows": [["x","y"]], "sortable": true }
321
- // ^ use a `table` block for tabular data — sortable + per-cell comments.
322
- // (markdown blocks render GFM pipe tables too, but those are display-only.)
323
- { "type": "table", "rowsFile": "data.csv", "filterable": true, "exportable": true }
324
- // ^ load rows from a local .csv/.tsv/.json; filterable = live filter box,
325
- // exportable = CSV download. (`rly view data.csv` does all of this for you.)
326
- { "type": "kpi", "title": "This quarter", "items": [
327
- { "label": "Revenue", "value": "$1.2M", "delta": "12%", "dir": "up" },
328
- { "label": "Churn", "value": "2.1%", "delta": "0.4pp", "dir": "down", "sub": "lower=better" } ] }
329
- // ^ big-number metric cards with up/down/flat-tinted deltas — no chart needed.
330
- { "type": "typography", "font": "Georgia, serif", "specimens": [
331
- { "label": "Display", "size": "40px", "weight": "600", "text": "Ship faster" },
332
- { "label": "Body", "size": "16px", "text": "The quick brown fox…" } ] }
333
- // ^ type specimens at given size/weight/font — react to type like a palette.
334
- { "type": "compare", "before": "v1.png", "after": "v2.png", "beforeLabel": "Old", "afterLabel": "New" }
335
- // ^ before/after images with a draggable divider (redesign / before-after fix).
336
- { "type": "code", "lang": "js", "code": "const x = 1;", "filename": "demo.js" }
337
- { "type": "code", "codeFile": "src/server.js" } // load text from a local file
338
- { "type": "diff", "lang": "js", "filename": "src/auth.js", "view": "split",
339
- "diff": "@@ -1,3 +1,3 @@\n ctx\n-old line\n+new line\n ctx" }
340
- // ^ a unified / `git diff` text rendered as a colored, line-numbered comparison
341
- // (no git needed — just paste the diff). "view":"split" = side-by-side; the
342
- // viewer also has a live Unified⇄Split toggle. "diffFile" loads it from a file.
343
- { "type": "git-conflict", "file": "src/app.js" }
344
- { "type": "git-conflict", "filename": "app.js", "content": "<<<<<<< HEAD\nours\n=======\ntheirs\n>>>>>>> feature\n" }
345
- // ^ conflict markers rendered as a resolver: choose ours/theirs/both/custom per
346
- // hunk. User choices + full resolved content return in result.blockEdits[blockId].
347
- { "type": "video", "src": "https://youtu.be/dQw4w9WgXcQ", "title": "Demo walkthrough" }
348
- { "type": "video", "src": "recordings/demo.mp4", "title": "Local capture", "height": 360 }
349
- // ^ YouTube/Vimeo URL embeds a player; an http(s) media URL or a local video
350
- // file (mp4/webm/ogv/mov/mkv/m4v) plays inline (local files stream, not embedded).
351
- { "type": "pdf", "src": "reports/quote.pdf", "title": "Quote", "height": 900 }
352
- // ^ local .pdf files and http(s) PDF URLs render inline; local files stream, not embedded.
353
- { "type": "html", "html": "<p>hi</p>", "height": 360 }
354
- { "type": "html", "htmlFile": "viz.html", "height": 400 }
355
- { "type": "image", "src": "screenshot.png" } // local file, URL, or data URI
356
- { "type": "image", "src": "https://…/mock.png", "alt": "Mockup B", "height": 220 }
357
- // ^ `height` only sets the COMPACT inline preview — every image keeps a full-
358
- // screen + zoom (⌘/Ctrl+wheel or −/+, up to 8× native) + drag-to-pan viewer,
359
- // so detail is always reachable regardless of height. Local images embed up
360
- // to 8 MB; for a huge/high-detail image pass an http(s) URL (streamed, no cap).
361
- { "type": "palette", "palettes": [{ "name":"Brand", "colors":["#3B8EA5","#6DBAD1","#1E6278"], "featured": true }] }
362
- // ^ color palettes as swatch cards: hover=hex, click=copy. Shorthand {"type":"palette","colors":[…]}; pair with a `color` question.
363
- ```
364
-
365
- ### View a markdown file quickly
56
+ Use stable question IDs and descriptive option values. Questions and individual
57
+ options can carry their own `blocks`; put each design variant inside its option.
58
+ Use `required:true` only for answers necessary to continue.
366
59
 
367
- To let the user *read* a `.md` file (README, a plan you wrote, a generated
368
- report), don't paste it into the terminal — render it:
369
-
370
- ```sh
371
- rly view PLAN.md # one file → board titled "PLAN.md", "Done" button
372
- rly view README.md CHANGELOG.md # several files, each with a filename heading
373
- rly view docs/spec.md --detach # detached like ask/show; then `rly wait <id>`
374
- ```
375
-
376
- `rly view` is sugar over `rly show` with `markdown` blocks (`mdFile`). The
377
- built-in renderer is library-free and covers headings, lists, `**/_` emphasis,
378
- code, quotes, GFM pipe tables, remote/data images, and click-to-open local
379
- links. To mix a file into a larger board, use a `markdown` block with
380
- `"mdFile"` alongside questions or other blocks.
381
-
382
- ### Visual options — show each choice, don't describe it
383
-
384
- When the options themselves are visual (design variants, layouts, color
385
- schemes, chart styles, architecture alternatives, screenshots), put a compact
386
- block INSIDE each option so the user compares by looking, not by reading and
387
- guessing:
388
-
389
- ```jsonc
390
- { "id": "layout", "type": "single", "label": "Which landing layout?",
391
- "options": [
392
- { "value": "hero", "label": "Hero", "description": "big banner",
393
- "blocks": [{ "type": "image", "src": "hero.png", "height": 180 }] },
394
- { "value": "split", "label": "Split", "description": "text + visual",
395
- "blocks": [{ "type": "html", "html": "<div style='display:flex'>…</div>", "height": 180 }] }
396
- ] }
397
- ```
398
-
399
- Any block type works per option. Keep option visuals compact (`height`
400
- ~140–260) — they sit inside the option card. Clicking a visual never toggles
401
- the option (and stays annotatable); the label row selects. Use per-option
402
- blocks whenever a question's choices have visual/example context; skip them
403
- for plainly textual options.
404
-
405
- Chart.js, Mermaid, and Graphviz are **vendored and lazy-loaded** — the package
406
- has no npm runtime dependencies, but these browser assets are bundled for rich
407
- blocks. PlantUML uses the public plantuml.com server by default;
408
- pass `"server"` for a self-hosted instance. Legacy `"html"` / `"htmlFile"` /
409
- `"htmlHeight"` on root or questions are still accepted and normalised automatically.
410
-
411
- ### Local file links — clickable, open in the default app
412
-
413
- Write a local path in any markdown (the `intro` or a `markdown` block) — `~/clip.mp4`,
414
- `./src/app.ts`, `/abs/report.pdf`, a `file://` URL, or a backtick-wrapped path — and it
415
- renders as a click-to-open link that opens the file in the user's OS default app
416
- (editor, video player, viewer …); `[label](~/path)` works too. Only paths you actually
417
- wrote on the board can be opened (same-origin + allowlist guarded). Surface a real
418
- clickable path instead of telling the user to paste it into a terminal.
419
-
420
- ### Connect a question to a visual shown above (reference modal)
421
-
422
- When a board has visuals up top and questions below, the user loses the link
423
- between them. Give any block a stable `"ref"` name, then reference it from a
424
- markdown link — clicking it opens that visual in a full-screen modal **in place**,
425
- no scrolling:
426
-
427
- ```jsonc
428
- { "type": "chart", "ref": "velocity", "kind": "line", "labels": [...], "series": [...] }
429
- // then in the intro, a markdown block, or a question's own markdown block:
430
- { "type": "markdown", "md": "Decide from the [📈 Velocity](#ref:velocity) chart above." }
431
- ```
432
-
433
- `[label](#ref:name)` opens the block named `name`; `[label](#block:b2)` opens by
434
- id. Use it so every question that depends on data points right at it.
435
-
436
- ### Pin comments on a mockup (image coordinates)
437
-
438
- Add `"pins": true` to an `image` block: the user clicks any point on the image to
439
- drop a comment anchored to that exact spot (Figma-style), returned as an
440
- `{kind:"image-point", x, y}` annotation. Ideal for design/mockup review.
441
-
442
- ### Comment on an exact image area (local crop)
443
-
444
- Every interactive `image` and `compare` block accepts direct primary drag for the
445
- desired rectangle; **Area** remains as a discoverable one-shot lock. Image pan is
446
- Space-drag or middle-button drag, and a comparison divider moves only from its
447
- handle. The provisional zone remains while the user writes, and a saved zone
448
- exposes a comment icon/count plus add/edit/delete threads; deleting its last
449
- comment removes the zone. Relay returns an `image-region` target with normalized
450
- `x`, `y`, `w`, and `h`; browser boards also save the selected pixels beside the
451
- board and return `target.crop.path`, which the agent should open with its image
452
- viewer. Comparison targets include `side:"before"|"after"`, and the crop comes
453
- from that source image rather than the composited slider view.
454
-
455
- ### Show a git diff in one step — `rly diff`
456
-
457
- `rly diff [git args…]` runs `git diff` and opens the result as a diff board —
458
- sugar for the "show me the diff" flow. Git args/flags pass straight through; a
459
- multi-file diff renders with a per-file header + a jump bar.
460
-
461
- ```sh
462
- rly diff --detach # working-tree diff
463
- rly diff --staged --split # staged changes, side-by-side
464
- rly diff HEAD~1 HEAD -- src/ # a commit's diff, scoped to a path
465
- ```
466
-
467
- `code` blocks also support **line-anchored comments**: hover a line number to
468
- comment on that exact line (returned as `{kind:"code-line", line}`).
469
-
470
- ## Annotations
471
-
472
- Users can hover chart points, diagram nodes (mermaid + graphviz), table cells,
473
- any element of a custom-HTML block, or select text in markdown to leave inline
474
- comments. Custom HTML is hover-commentable automatically — to scope/label what's
475
- annotatable, mark elements with `data-relay-annotate="Label"` (any signal turns
476
- the auto-pick off); opt a block out with `data-relay-annotate="off"`. Always
477
- mention annotation in the board intro.
478
-
479
- `result.annotations` is an array of:
480
-
481
- ```json
482
- {
483
- "id": "a1",
484
- "questionId": "q-id or null",
485
- "blockId": "b2",
486
- "target": { "kind": "chart-element | mermaid-node | graphviz-node | table-cell | text | html-element | image | image-point | image-region | code-line", "..." },
487
- "text": "user comment",
488
- "author": "user",
489
- "createdAt": "ISO",
490
- "replies": [{ "author": "agent", "text": "acknowledged", "createdAt": "ISO" }]
491
- }
492
- ```
493
-
494
- Read annotations before generating your next output — a comment on a specific
495
- data point often carries sharper signal than a checkbox answer.
496
-
497
- ## Reading the result — four feedback channels
498
-
499
- A result is more than `answers`. **Always read all four** — never act on
500
- `answers` alone; the user's real intent often lives in the others:
501
-
502
- | field | what it is |
60
+ | Content | Component |
503
61
  |---|---|
504
- | `answers` | per-question values `{ questionId: value }` (skipped ones absent, listed in `skipped`) |
505
- | `notes` | **per-question free-text notes** `{ questionId: "text" }` — the note box under a question. **Always present (`{}` when empty)**; iterate it every time. `single` (radio) questions show this box by default, so it's a very common place for the user's reasoning — and easy to miss. |
506
- | `comment` | one board-level free-text note ("Anything else?") |
507
- | `annotations` | element-level inline comments (array; see below) |
508
-
509
- A `notes[questionId]`, a `comment`, or an `annotation` can qualify or override
510
- the matching `answers` value (e.g. `answers.approach = "a"` but
511
- `notes.approach = "actually B"` → the user means B). Reconcile them before
512
- generating output. The same channels appear under `draft` on timeout/cancel.
513
-
514
- **Don't let your shell truncate the result.** A board with several annotations
515
- prints a large JSON blob, and most agent shell tools cap stdout — so you silently
516
- get only the first few annotations and miss the rest. Two rules:
517
-
518
- - **Never pipe `rly wait`/`rly result` through `head`/`tail`/`sed`** (or any
519
- output cap). That's exactly how annotations get dropped.
520
- - The full result is **always written to a file**, surfaced as the FIRST field
521
- of the output: `"resultFile": "~/.relay/boards/<id>.result.json"`. If the
522
- output looks cut off (or to be safe on any board with annotations), **read
523
- that file with your file tool** instead of trusting stdout — it's the complete,
524
- untruncated payload.
525
-
526
- ### Reply to annotations (agent → user conversation)
527
-
528
- ```sh
529
- # 1. Read result from a previous board
530
- rly result <id> # or rly wait <id>
531
-
532
- # 2. Build replies file
533
- # replies.json: [{"annotationId":"a1","text":"Good catch — fixed."}]
534
-
535
- # 3. Reopen as a conversation
536
- rly reopen <id> --replies replies.json
537
- ```
538
-
539
- Unknown annotation IDs cause an error listing valid IDs (exit 4).
540
-
541
- ## Recipes
542
-
543
- **Plan approval** — board-level `markdown` block rendering the plan, one `yesno`
544
- "Approve this plan?", one `multi` "Which parts should change?" (`"note": true`),
545
- one `textarea` for concerns.
546
-
547
- **Requirements gathering** — one board with: `single` for the core approach
548
- (options with `description`s + `"other": true`), `multi` for scope, `scale` for
549
- urgency, `textarea` for constraints.
550
-
551
- **A/B design review** — `single` question where EACH option carries its own
552
- `html`/`image` block rendering that variant (see Visual options above); `scale`
553
- for confidence; `textarea` for what's missing from both.
554
-
555
- **Show a git diff / code changes** — when the user says "show me the diff" /
556
- "show me git diff" / "review these changes": capture `git diff` (or `git diff
557
- <ref>`, `git show <sha>`) and present it in a `diff` block — set `"view":
558
- "split"` for side-by-side — instead of dumping it in the terminal. Pair it with
559
- a `yesno` "Apply these changes?" and a `textarea` for feedback; users can select
560
- diff text to comment on a specific line. For a brand-new file prefer a `code` block; for a
561
- recorded walkthrough of the change add a `video` block.
562
-
563
- **Metrics review** — board-level `chart` block (bar or line) showing the key
564
- numbers, followed by a `table` block for the raw data; at least one question
565
- asking what to act on. In the intro, tell the user they can click chart points
566
- and table cells to comment on specific values.
567
-
568
- ## Diagram co-editing (user edits your diagram)
569
-
570
- Add "editable": true to a mermaid block: the user gets an Edit button with
571
- live-preview source editing. Their version comes back as
572
- result.blockEdits["<blockId>"] - diff it against your original to see what
573
- they changed. Recipe: propose an architecture as an editable mermaid block +
574
- one yesno "Does this match your mental model?" + a textarea for notes.
575
-
576
- ## Reuse & management
577
-
578
- `rly history` (saved boards) · `rly spec <id>` (print spec to modify) ·
579
- `rly reuse <id>` (re-run blank) · `rly reopen <id>` (re-open with saved
580
- answers prefilled) · `rly reopen <id> --replies file.json` (add agent replies) ·
581
- `rly rescue <id>` (re-serve a dropped board on its ORIGINAL port) ·
582
- `rly list` / `rly open` / `rly stop <id>` · `rly rm <id>`.
583
- Multiple boards can run concurrently. Detached boards keep serving past timeout;
584
- use `rly stop` when you actually want to close one.
585
-
586
- ### Continue a board — reconnect, NEVER recreate it
587
-
588
- When the user refers to a board that already exists — a URL/port ("the board on
589
- `127.0.0.1:59926`"), "the board from yesterday", "reopen it", "it disconnected"
590
- — do **NOT** run `rly ask`/`rly show`. A fresh board lands on a **new port**,
591
- **strands the user's open tab** on the dead one, and **loses their comments**.
592
- Find the real board and reconnect it:
593
-
594
- 1. **Identify it** — `rly list` (running) and `rly history` (saved) print each
595
- board's id, title, and url/port. Match by what the user said (port, title).
596
- 2. **Tab still open but "connection lost"** (server died / machine slept) →
597
- `rly rescue <id>`. Re-serves on the SAME port so that tab reconnects on its
598
- own and re-flushes any comments it buffered — no new tab, no lost input.
599
- 3. **Want a fresh tab** with prior answers prefilled → `rly reopen <id>` (also
600
- reuses the board's last port, so an old tab still reconnects).
601
- 4. `rly reuse <id>` is the ONLY "make a new board from this one" path — use it
602
- solely for a deliberately blank re-run, never to "continue" or "reconnect".
603
-
604
- Rule of thumb: **an existing board is reconnected (`rescue`/`reopen`), never
605
- re-asked.** Only call `rly ask`/`rly show` for a genuinely new question.
606
-
607
- ### Live mutation — `rly update`
608
-
609
- Push a new spec to a running board. The page reloads and prefills answers from the
610
- autosaved draft — answers survive, the user sees a toast "Board updated by the agent".
62
+ | Prose / documents | `markdown` with `md` or `mdFile` |
63
+ | Source / changes | `code` with `codeFile`; `diff` with `diffFile`; `git-conflict` |
64
+ | Data / headline metrics | `table` with `rowsFile`, `chart`, `kpi` |
65
+ | Flows / dependencies / UML | `mermaid`, `graphviz`, `plantuml` |
66
+ | Mockups / before-after | `image`, `compare` |
67
+ | Media / reports | `video`, `pdf` |
68
+ | Design choices | `palette`, `typography` |
69
+ | Custom interactive content | sandboxed `html` |
70
+
71
+ | Answer shape | Question type |
72
+ |---|---|
73
+ | One / several choices | `single`, `multi` |
74
+ | Binary / rating / color | `yesno`, `scale`, `color` |
75
+ | Free text | `text`, `textarea` |
76
+ | Priorities / budget / sign-off | `rank`, `allocate`, `checklist` |
77
+
78
+ Any block can have `"ref":"source"`; `[View source](#ref:source)` opens its viewer
79
+ from another part of the board. `mermaid` with `editable:true` returns user edits
80
+ in `blockEdits`. For image feedback, primary drag selects a region/crop;
81
+ Space-drag or middle-drag pans. A compare divider moves only by its handle.
82
+ `pins:true` adds image point comments.
83
+
84
+ ## File references that open in a modal
85
+
86
+ In the intro or a markdown block, use `[label](/absolute/path/file.js:98)`.
87
+ Absolute paths are most reliable across authoring directories. `./`, `../`,
88
+ `~/`, `file://` URLs, bare paths, and backtick paths are also recognized. Encode
89
+ spaces in file URLs, for example `[report](file:///tmp/My%20Report.md)`.
90
+
91
+ - `:line`, `:line:column`, and `#Lstart-Lend` select source lines. Columns are
92
+ accepted; highlighting is by line.
93
+ - UTF-8 source/config/log files have numbered, highlighted source previews.
94
+ Markdown renders as a document; CSV/TSV as a table; HTML as a sandboxed static
95
+ page. These views also offer a Source button.
96
+ - Images, PDF, and browser-compatible audio/video render within the modal.
97
+ Playback depends on the browser’s codec support.
98
+ - Text previews are limited to 1 MiB and 20,000 lines. Missing files show an
99
+ error; binary/oversized files and directories offer **Open in app**.
100
+ - Only local paths explicitly referenced by the board are accessible. Links
101
+ discovered inside a preview do not grant access to more files. References
102
+ read the current disk content; use content blocks for a captured snapshot or
103
+ for annotations. Preview modals do not collect annotations.
104
+ - Owner and collaborator browser sessions can preview/open local references.
105
+ Read-only and reviewer shares cannot; embed needed content as blocks for them.
106
+
107
+ After a CLI upgrade, running boards retain their previous server/UI snapshot.
108
+ For a board that needs the new viewer, preserve its saved input and reconnect
109
+ that same board with the updated CLI; do not replace it with a new board ID.
110
+
111
+ ## Wait and read feedback
112
+
113
+ For a response-bearing browser board, retain the returned board ID and keep a
114
+ foreground waiter running in Codex:
611
115
 
612
116
  ```sh
613
- rly update <boardId> --file new-spec.json # replace spec
614
- rly update <boardId> --title T --intro I # patch fields
615
- rly update <boardId> -q "!Priority::single::p0,p1" # append question
616
- ```
617
-
618
- Batch your changes into one call — the page reloads for the user on each update.
117
+ rly ask --file spec.json --detach
118
+ rly wait <boardId> --timeout 1800 --while-active --idle-grace 300
119
+ ```
120
+
121
+ Keep the process/session handle if the shell tool yields. Resume that process
122
+ until it exits; use the host’s background-completion mechanism only when it is
123
+ available. If the wait times out, run `rly result <boardId>` before deciding
124
+ whether another wait is needed. A timeout is not an answer. Detached boards
125
+ remain available on the same port until submitted or explicitly stopped.
126
+ `--timeout 0` disables the Relay deadline; the default is one day.
127
+
128
+ Read **answers, notes, comment, annotations, and blockEdits** together. Notes and
129
+ annotations can qualify a selected answer. On timeout/cancel, these may be under
130
+ `draft`; treat them as unfinished feedback. Reviewer submissions are side
131
+ reviews and never finalize the owner’s board.
132
+
133
+ For large results, use the returned `resultFile` to read the complete JSON.
134
+ Avoid truncating stdout with `head`/`tail`; inspect every feedback channel before
135
+ acting. To reply to annotations, write
136
+ `[{"annotationId":"a1","text":"Updated the example."}]` to a file and run
137
+ `rly reopen <id> --replies replies.json`.
138
+
139
+ ## Details on demand
140
+
141
+ - `rly agent`: full guide, HTML/diagram editing, sharing roles, annotations,
142
+ result shapes, and lifecycle recipes.
143
+ - `rly schema`: authoritative board fields; `rly <command> --help` for CLI flags.
144
+ - `examples/`: ready-to-adapt board specs for visual options, diagrams, and color.
145
+ - `rly share <id> --role review|collab|read`: activate sharing only when requested;
146
+ `--revoke` disables the selected role. Keep share tokens out of reports/logs.
147
+ - `rly upgrade --force`: update CLI/skill while running boards keep their snapshot.