@khanglvm/relay 0.20.2 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/docs/AGENT.md +56 -83
  3. package/docs/SETUP.md +3 -2
  4. package/package.json +12 -5
  5. package/skills/relay/SKILL.md +45 -145
  6. package/src/cli/agent-topics.js +84 -0
  7. package/src/cli/config.js +26 -2
  8. package/src/cli/index.js +3 -5
  9. package/src/cli/mcp.js +4 -2
  10. package/src/cli/skill.js +21 -22
  11. package/src/mcp/boards.js +173 -0
  12. package/src/mcp/config.js +20 -0
  13. package/src/mcp/constants.js +31 -0
  14. package/src/mcp/index.js +5 -0
  15. package/src/mcp/page.js +59 -0
  16. package/src/mcp/schemas.js +42 -0
  17. package/src/mcp/serve.js +116 -0
  18. package/src/mcp/server.js +23 -0
  19. package/src/mcp/store.js +35 -0
  20. package/src/mcp/token.js +31 -0
  21. package/src/mcp/tools.js +171 -0
  22. package/src/mcp-ui/board/block-ctx.js +22 -0
  23. package/src/mcp-ui/board/bridge.js +12 -2
  24. package/src/mcp-ui/board/core.js +2 -0
  25. package/src/mcp-ui/board/lifecycle.js +47 -9
  26. package/src/mcp-ui/board/render.js +36 -44
  27. package/src/mcp-ui/board/vendors.js +56 -11
  28. package/src/spec/blocks/chart.js +8 -4
  29. package/src/spec/constants.js +19 -0
  30. package/src/spec/index.js +1 -0
  31. package/src/spec/lookup.js +78 -0
  32. package/src/spec/normalize.js +9 -4
  33. package/src/spec/ready.js +15 -1
  34. package/src/ui/manifest.js +1 -1
  35. package/types/cli/agent-topics.d.ts +46 -0
  36. package/types/mcp/boards.d.ts +168 -0
  37. package/types/{mcp.d.ts → mcp/config.d.ts} +1 -8
  38. package/types/mcp/constants.d.ts +21 -0
  39. package/types/mcp/index.d.ts +4 -0
  40. package/types/mcp/page.d.ts +27 -0
  41. package/types/mcp/schemas.d.ts +46 -0
  42. package/types/mcp/serve.d.ts +16 -0
  43. package/types/mcp/server.d.ts +4 -0
  44. package/types/mcp/store.d.ts +52 -0
  45. package/types/mcp/token.d.ts +5 -0
  46. package/types/mcp/tools.d.ts +17 -0
  47. package/types/server/result.d.ts +10 -0
  48. package/types/server/sanitize.d.ts +6 -0
  49. package/types/spec/blocks/chart.d.ts +1 -1
  50. package/types/spec/constants.d.ts +14 -0
  51. package/types/spec/index.d.ts +1 -0
  52. package/types/spec/lookup.d.ts +57 -0
  53. package/types/spec/ready.d.ts +2 -0
  54. package/src/mcp.js +0 -483
package/README.md CHANGED
@@ -13,7 +13,7 @@ It works with agents such as Claude Code and Codex.
13
13
 
14
14
  ## Install and try it
15
15
 
16
- Requires Node.js 18.3 or newer.
16
+ Requires Node.js 20 or newer.
17
17
 
18
18
  ```sh
19
19
  npm i -g @khanglvm/relay
@@ -80,7 +80,7 @@ default. The details are in the [agent guide](docs/AGENT.md).
80
80
 
81
81
  - [Setup and MCP Apps](docs/SETUP.md): agent configuration, in-chat boards, sharing, and updates.
82
82
  - [A2UI widgets](docs/A2UI.md): the `a2ui` block, also available as `rly a2ui`.
83
- - [Agent guide](docs/AGENT.md): board examples, block types, and JSON schemas; also available as `rly agent`.
83
+ - [Agent guide](docs/AGENT.md): board examples, block types, and JSON schemas; also available as `rly agent`, with `rly agent <topic>` for one part and `rly schema <type>` for one block or question type.
84
84
  - `rly help` lists commands. `rly upgrade` updates the CLI and skill.
85
85
  - [Changelog](CHANGELOG.md) · [MIT license](LICENSE)
86
86
 
package/docs/AGENT.md CHANGED
@@ -4,8 +4,11 @@ Use Relay to present files, visuals, substantial plans, diffs, and related user
4
4
  questions. Choose purpose-built blocks so users can inspect the content and
5
5
  leave precise feedback. Keep short answers and progress updates in chat.
6
6
  Respect the user’s existing authorization; boards do not add approval gates.
7
+ If your host app has its own way to ask the user or show results (native question cards, forms, pickers), use that for those. Use Relay for what the host can't show: line comments on a diff, Mermaid or Graphviz diagrams, element comments on an HTML prototype, rich multi-block review boards.
7
8
  For a concise workflow, read the bundled skill (`rly skill path`). This guide is
8
- a reference for fields and less common operations.
9
+ a reference for fields and less common operations. Load one part with
10
+ `rly agent <topic>` (`questions`, `blocks`, `annotate`, `lifecycle`, `sharing`,
11
+ `mcp`, `a2ui`), and one block or question type with `rly schema <type>`.
9
12
 
10
13
  Use `rly show --file spec.json --display-only` when no response is needed. Use
11
14
  `rly ask --file spec.json --detach` and a waiter for answers or comments.
@@ -37,6 +40,23 @@ Everything machine-relevant is on **stdout as JSON**; human-facing logs go to
37
40
  stderr. Exit codes: `0` submitted/acknowledged · `2` timeout · `3` cancelled ·
38
41
  `4` usage error · `5` not found.
39
42
 
43
+ ## Block and question shapes (copy, then adapt)
44
+ ```jsonc
45
+ {"type":"chart","kind":"bar","title":"Deploys vs incidents","labels":["W1","W2"],"series":[{"label":"Deploys","data":[12,19]},{"label":"Incidents","data":[1,0]}]} // kind: bar|line|pie|doughnut|radar|scatter
46
+ {"type":"kpi","items":[{"label":"Deploys","value":"67","delta":"+12%","dir":"up"}]}
47
+ {"type":"table","columns":[{"key":"name","label":"Name"}],"rows":[{"name":"x"}],"sortable":true}
48
+ {"type":"image","src":"/abs/a.png","alt":"A","pins":true} // users can also drag a region to comment
49
+ {"type":"compare","before":"/abs/a.png","after":"/abs/b.png"} // draggable divider
50
+ {"type":"diff","diffFile":"/abs/change.diff"} {"type":"code","codeFile":"/abs/app.js"} {"type":"markdown","mdFile":"/abs/PLAN.md"}
51
+ {"type":"mermaid","code":"graph TD; A-->B","editable":true} // edits come back in blockEdits
52
+ {"type":"a2ui","title":"Checks","express":"$/runs = [{title: \"Build\", trailing: \"ok\", tone: \"ok\"}]\nroot = Card(\"Checks\", [List($/runs), Button(\"Retry\", action=Event(\"retry\", {}))])"} // buttons and live status: use a2ui, not html
53
+ {"id":"signoff","type":"checklist","label":"Sign off each area","options":["login","billing"]} // pass/fail/N-A per item: one checklist, not many yes/no
54
+ {"id":"rank","type":"rank","label":"Priorities","options":["speed","a11y"]} {"id":"split","type":"allocate","label":"Budget","total":100,"options":["type","space"]}
55
+ {"id":"c","type":"single","label":"Scheme?","options":[{"value":"warm","label":"Warm","blocks":[{"type":"html","html":"<div style='height:100%;background:#c2674b'></div>","height":140}]}]} // a visual per option
56
+ {"id":"s","type":"scale","label":"Rate","min":1,"max":5} {"id":"col","type":"color","label":"Brand color"} {"id":"ship","type":"yesno","label":"Ship?"}
57
+ ```
58
+ Buttons inside a2ui do not replace a question. Their clicks return in `blockEdits`.
59
+
40
60
  ## Two execution patterns
41
61
 
42
62
  **1. Blocking (simplest).** The command blocks until the user submits, then
@@ -94,90 +114,44 @@ without Wi-Fi sharing, give it a link setting. `rly ask`, `rly show`, `rly view`
94
114
  and `rly diff` accept:
95
115
 
96
116
  ```sh
97
- rly ask --file spec.json --detach --devlink # publish through devlink
98
117
  rly ask --file spec.json --detach --public-url 'https://boards.example.com:{port}'
99
- rly config link devlink # make it the default (also: auto, off, or a URL)
118
+ rly ask --file spec.json --detach --link-command 'my-link-tool {port}'
119
+ rly config link command:'my-link-tool {port}' # make it the default (also: off, or a URL)
100
120
  ```
101
121
 
102
- - `--devlink` runs `devlink --json internal PORT`, requires a private https URL
103
- back, and prints it as the board `url` (with a collaborator token). It stops
104
- with an error if `devlink` is missing or fails. Relay finds it through
105
- `RLY_DEVLINK_BIN`, then `PATH`, then `~/.local/bin/devlink`.
106
- - `auto` does the same when `devlink` is installed and keeps the board local when
107
- it is not. `off` (the default) never publishes.
108
122
  - `--public-url` takes any https URL that reaches the board's port, such as a
109
- reverse proxy or tunnel you run. `{port}` becomes the board port. Loopback
110
- hosts are refused. `RLY_PUBLIC_URL` and `RLY_LINK` set the same from the
111
- environment; `--no-devlink` turns it off for one run.
112
- - Precedence: `--no-devlink`, `--devlink`, `--public-url`, `RLY_PUBLIC_URL`,
113
- `RLY_LINK`, `rly config link`, then off.
123
+ reverse proxy you run. `{port}` becomes the board port. Loopback hosts are
124
+ refused. `RLY_PUBLIC_URL` and `RLY_LINK` set the same from the environment.
125
+ - `--link-command CMD` (or `RLY_LINK_COMMAND`) runs any command that takes the
126
+ board's port ({port} in the command, or appended) and prints an https URL,
127
+ either as plain text or as JSON with a `url` field. `RLY_LINK_RELEASE_COMMAND`
128
+ runs when the board closes, so the provider can remove its route.
129
+ - Precedence: `--link-command`, `--public-url`, `RLY_LINK_COMMAND`,
130
+ `RLY_PUBLIC_URL`, `RLY_LINK`, `rly config link`, then off.
114
131
  - Answers return as usual: `rly wait <id>` and `rly result <id>`.
115
- - When the board closes, Relay removes the devlink route again.
116
132
 
117
133
  Report the printed URL to the user and never a `localhost`, `127.0.0.1` or
118
- `0.0.0.0` address. A published board is reachable by whoever can reach the
119
- link, and devlink's gateway makes every request look local to the board, so the
120
- token in the URL and the network behind the link (Tailscale for devlink) are the
121
- access control. Use `rly share <id> --revoke --all` to cut access.
122
-
123
- ## Inline mode — relay as an MCP App (Claude & Codex apps)
124
-
125
- Everything above is the **CLI** surface (you run `rly` in a terminal and read
126
- JSON from stdout). relay is **also** an MCP App (SEP-1865): when a host registers
127
- `rly mcp` (see `rly mcp config` / `rly mcp install --target claude|codex`), you
128
- get two tools that render the board **inline in the conversation** instead of a
129
- browser tab. `rly mcp` speaks the MCP **stdio** transport, so it pairs with a
130
- **local desktop** host — Claude Desktop and Codex today.
131
-
132
- - **`relay_ask`** — collect decisions/feedback with real form controls.
133
- - **`relay_show`** — present a plan, diagram, diff, table, or prototype.
134
-
135
- **Web / mobile / remote hosts** can't reach a stdio subprocess, so for those run
136
- the **Streamable HTTP** transport: `rly mcp --http [--port N]` serves the same
137
- tools at `/mcp`. relay needs **only its own CLI** for this — no tunnel tool, no
138
- extra infra. Because relay is **stateless** (answers go iframe→host→model, never
139
- back to the server), **one deployed instance serves everyone**, so deploy it once
140
- on any address the app can reach and register that URL as a custom connector:
141
-
142
- - **Free MCP hosts** — the repo's `Dockerfile` runs relay with zero config on
143
- **mcpdeploy.dev**, **mcphosting.io**, **Render / Railway / Fly**, or **Glama**;
144
- the platform's `$PORT` is honored automatically. Set `RLY_MCP_TOKEN` for a
145
- bearer-protected endpoint.
146
- - **Smithery** (largest MCP marketplace) — publish the deployed URL with
147
- `smithery mcp publish <url> -n @you/relay` for discovery + an OAuth gateway, or
148
- distribute relay as a stdio bundle clients run locally.
149
- - **Tunnel (optional, dev only)** — `cloudflared`/`tailscale` is *only* for
150
- exposing a NAT'd laptop; it's never required and not a relay dependency.
151
-
152
- A hosted instance can't see your local files (so `codeFile`/local-image blocks
153
- won't resolve there — pass URLs or inline content); run it on your own machine if
154
- you need local-file access.
155
-
156
- Progressive rendering: if the host streams the tool call as you write it, the
157
- board renders valid blocks/questions incrementally (a "Composing…" preview) and
158
- finalizes when your call completes — so the user sees it build, not a blank wait.
159
-
160
- Both take **the exact same board spec** documented below (the tool `inputSchema`
161
- *is* this spec). Call the tool with your spec; the host shows the board, the user
162
- fills it in, and their answers come back to you (answers, per-question notes,
163
- comment) as a user-message turn, with structured context synced when the host
164
- supports it — read them just as you would the CLI's result JSON. There is **no
165
- `--detach`/`rly wait` dance, no stdout parsing, and no timeout** in this mode.
166
- `relay_ask` stays live until the user submits and the host delivers the result;
167
- `relay_show` is display-only by default and the agent continues immediately.
168
-
169
- **Near-full parity with the browser board.** Local `codeFile` / `htmlFile` /
170
- `diffFile` and local **image** files work inline too — the server inlines them
171
- (images as data URIs) while normalizing your spec, so the sandboxed board needs
172
- no file access. **Element-level annotations work inline** — the user can comment
173
- on chart points, diagram nodes, table cells, images and text selections, returned
174
- in `annotations` just like the CLI. The board also adopts the host's **theme,
175
- fonts and colors** and uses the host's **full-screen** control. The only
176
- inline-mode gaps vs. the browser board: **local video files** (use a
177
- YouTube/Vimeo/`https` URL instead — those play) and commenting on elements
178
- *inside* a custom-HTML mockup (every other annotation target works). Everything
179
- else — questions plus markdown/code/diff/table/chart/mermaid/graphviz/plantuml/
180
- image/palette/html — renders identically.
134
+ `0.0.0.0` address. Whoever can reach the link can reach the board, so the token
135
+ in the URL and the network behind the link are the access control. Use
136
+ `rly share <id> --revoke --all` to cut access.
137
+
138
+ ## Inline mode: relay as an MCP App (Claude and Codex apps)
139
+
140
+ Everything outside this section is the CLI surface: you run `rly` and read JSON from stdout. Relay is also an MCP App server (SEP-1865). A host that registers `rly mcp` (see `rly mcp config` and `rly mcp install --target claude|codex`) renders the board inline in the conversation instead of a browser tab.
141
+
142
+ Tools:
143
+ - `relay_board`: takes the spec this guide describes. A spec with `questions` collects answers; one without is display-only. The result is a short summary with the `boardId`, never the spec.
144
+ - `relay_result {boardId, wait_seconds}`: the answers, notes, comment, annotations and blockEdits, or the draft while the person is still filling the board in. `wait_seconds` blocks until they submit, up to 600. A timeout is not an answer: call it again.
145
+ - `relay_help {topic}` or `relay_help {schema}`: a part of this guide, or the exact fields of one block or question type.
146
+ - `relay_ask` and `relay_show`: the old names, kept as aliases for one more minor version. Use `relay_board`.
147
+
148
+ The flow: call `relay_board`, tell the person the board is on screen, and carry on or wait. When they submit, the host posts a one-line message naming the board. Read the answers with `relay_result`. Do not ask the same questions again in chat.
149
+
150
+ `rly mcp` speaks stdio to a local desktop host. `rly mcp --http [--port N] [--token SECRET] [--allow-origin ORIGIN]` serves Streamable HTTP at `/mcp` for hosts that connect over a network; `RLY_MCP_TOKEN` sets the bearer token. Boards are stored in the relay home of the machine that runs the server, so `codeFile` and local images resolve there and nowhere else. To add the tools to a server you already run, call `registerRelay(server, {store, assetUrl, linkUrl})` from `@khanglvm/relay/mcp`.
151
+
152
+ If the host streams the tool call as you write it, the board renders valid blocks and questions as they arrive and finishes when your call completes.
153
+
154
+ Inline boards match the browser board. The server inlines `codeFile`, `htmlFile`, `diffFile` and local images (as data URIs) while it normalizes the spec, so the sandboxed board needs no file access. Element comments work on chart points, diagram nodes, table cells, images and text selections, and come back in `annotations`. The board adopts the host's theme, fonts, colors and full-screen control. Two gaps remain: local video files (use a YouTube, Vimeo or https URL) and comments on elements inside a custom HTML mockup.
181
155
 
182
156
  ## Creating boards
183
157
 
@@ -204,9 +178,8 @@ rly show --file spec.json --display-only
204
178
  ```
205
179
 
206
180
  `--display-only` automatically detaches the browser board. In MCP App mode,
207
- `relay_show` is display-only by default; set `responseRequired:true` only when
208
- the user really needs to acknowledge or leave feedback. `relay_ask` remains the
209
- response-bearing tool.
181
+ `relay_board` with no `questions` is display-only; set `responseRequired:true` only
182
+ when the user really needs to acknowledge or leave feedback.
210
183
 
211
184
  Read a markdown file (no questions; library-free renderer; submit reads "Done"):
212
185
 
@@ -771,8 +744,8 @@ file write alone starts a new model turn.
771
744
 
772
745
  | Client/surface | Recommended Relay return path |
773
746
  |---|---|
774
- | MCP App (`relay_ask`) | No CLI wait. The inline board stays live and sends `ui/message` on submit, which starts the user-return turn. |
775
- | MCP App (`relay_show`) | Display-only by default. Present it and continue immediately; no acknowledgement is requested. |
747
+ | MCP App (`relay_board` with questions) | No CLI wait. The board stays live; on submit the host posts a one-line message and `relay_result` returns the answers. |
748
+ | MCP App (`relay_board`, display-only) | Present it and continue immediately; no acknowledgement is requested. |
776
749
  | Claude Code | Run `rly wait <id> --timeout 0` as a [background Bash task](https://docs.anthropic.com/en/docs/claude-code/interactive-mode#background-bash-commands); retain its task id/output rather than opening a second board. |
777
750
  | Gemini CLI | Run the waiter in the background and set [`tools.shell.backgroundCompletionBehavior` to `"inject"`](https://geminicli.com/docs/reference/configuration/) so completion is returned to the agent; `"notify"` only informs the chat UI. |
778
751
  | Codex | Keep one foreground waiter. Codex background terminals use explicit `write_stdin` polling (the [poll window defaults to five minutes](https://developers.openai.com/codex/config-reference)); the process can outlive each poll, but no portable browser-submit API wakes a stopped turn. |
package/docs/SETUP.md CHANGED
@@ -37,10 +37,11 @@ rly mcp install --target codex
37
37
 
38
38
  The first command configures Claude Code; the others write Claude Desktop
39
39
  and Codex config respectively. Use `rly mcp config` to print config snippets.
40
- The server exposes `relay_ask` for feedback and `relay_show` for display.
40
+ The server exposes `relay_board` to show a board, `relay_result` to read the answers and `relay_help` for exact field shapes. `relay_ask` and `relay_show` remain as aliases of `relay_board` for one more minor version.
41
41
 
42
42
  For remote clients, `rly mcp --http` serves Streamable HTTP. Run `rly help`
43
- for host, port, token, and origin flags. The repo includes a `Dockerfile`.
43
+ for host, port, token, and origin flags. Boards live in the relay home of the
44
+ machine that runs the server. The repo includes a `Dockerfile`.
44
45
  See the [agent guide](AGENT.md) for board schemas, transport details,
45
46
  and host requirements.
46
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanglvm/relay",
3
- "version": "0.20.2",
3
+ "version": "0.21.0",
4
4
  "description": "Question boards with rich blocks (markdown, charts, mermaid, tables, code, diffs, video, sandboxed HTML), clickable local file-links, and element-level annotations for AI coding agents (Claude Code, Codex, \u2026): ask users structured questions, present interactive visuals, collect inline comments, read answers as JSON \u2014 in a local browser board OR rendered INLINE inside the Claude & Codex apps as an MCP App (SEP-1865).",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -45,7 +45,7 @@
45
45
  "LICENSE"
46
46
  ],
47
47
  "engines": {
48
- "node": ">=18.3"
48
+ "node": ">=20"
49
49
  },
50
50
  "scripts": {
51
51
  "check": "tsc -p tsconfig.json",
@@ -58,6 +58,7 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@biomejs/biome": "^2.6.8",
61
+ "@modelcontextprotocol/client": "^2.4.0",
61
62
  "@types/node": "^20.19.43",
62
63
  "typescript": "^7.0.2"
63
64
  },
@@ -75,12 +76,18 @@
75
76
  "default": "./src/a2ui/compile.js"
76
77
  },
77
78
  "./mcp": {
78
- "types": "./types/mcp.d.ts",
79
- "default": "./src/mcp.js"
79
+ "types": "./types/mcp/index.d.ts",
80
+ "default": "./src/mcp/index.js"
80
81
  },
81
82
  "./schema.json": "./schema/spec.v1.json",
82
83
  "./package.json": "./package.json"
83
84
  },
84
85
  "main": "./src/index.js",
85
- "types": "./types/index.d.ts"
86
+ "types": "./types/index.d.ts",
87
+ "dependencies": {
88
+ "@modelcontextprotocol/ext-apps": "^2.0.4",
89
+ "@modelcontextprotocol/node": "^2.1.2",
90
+ "@modelcontextprotocol/server": "^2.4.0",
91
+ "zod": "^4.6.7"
92
+ }
86
93
  }
@@ -1,166 +1,66 @@
1
1
  ---
2
2
  name: relay
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."
3
+ description: "Show the user files, visuals, diffs, plans, charts or a set of related questions on a Relay board and collect their answers and comments. Use when a decision needs visuals or several linked questions; simple one-off questions stay in chat."
4
4
  ---
5
5
 
6
6
  # Relay (`rly`)
7
7
 
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.
8
+ Put content in front of the person and read what they decide. Keep short answers and progress updates in chat. A board adds no approval step of its own; follow the authorization the user already gave.
12
9
 
13
- ## Choose the operation
10
+ If your host app has its own way to ask the user or show results (native question cards, forms, pickers), use that for those. Use Relay for what the host can't show: line comments on a diff, Mermaid or Graphviz diagrams, element comments on an HTML prototype, rich multi-block review boards.
14
11
 
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.
12
+ ## Workflow
13
+ 1. Write a spec to a JSON file. Never pass big JSON in a shell argument.
14
+ 2. `rly ask --file spec.json --detach` prints `{boardId,url}` at once. When no reply is needed: `rly show --file spec.json --display-only`.
15
+ 3. Give the person the url. To get the result: `rly wait <boardId> --timeout 1800 --while-active --idle-grace 300` (blocks until submit) or `rly result <boardId>` (now). A timeout is not an answer: run `rly result` before you decide.
16
+ 4. Read `answers`, `notes`, `comment`, `annotations` and `blockEdits` together; any of them can qualify an answer. When stdout is cut short, read the `resultFile` it names.
27
17
 
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.
33
-
34
- ## Author a board
35
-
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.
18
+ If Relay MCP tools are connected, call `relay_board` with the same spec (questions make it collect answers, none make it display-only) and the board renders inline. Read the answers with `relay_result {boardId, wait_seconds}`; `relay_help` gives exact fields. Embed file content with `mdFile`, `codeFile` or an image block, because inline boards cannot open local file links.
39
19
 
20
+ ## Spec in one screen
40
21
  ```json
41
22
  {
42
- "title": "Implementation review",
23
+ "title": "Hero review",
24
+ "intro": "Pick one. Click or drag on an image to comment.",
43
25
  "blocks": [
44
- {"type": "markdown", "md": "Review the [source](/absolute/path/app.js:98)."},
45
- {"type": "code", "codeFile": "/absolute/path/app.js", "ref": "source"}
26
+ {"type": "markdown", "md": "Short context."},
27
+ {"type": "image", "src": "/abs/a.png", "alt": "A"}
46
28
  ],
47
29
  "questions": [
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}
30
+ {"id": "pick", "type": "single", "label": "Which one?", "required": true,
31
+ "options": [{"value": "a", "label": "A", "description": "why"}, "B"]},
32
+ {"id": "notes", "type": "textarea", "label": "Anything else?"}
52
33
  ]
53
34
  }
54
35
  ```
55
-
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.
59
-
60
- | Content | Component |
61
- |---|---|
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
- | Live status, quick actions, small forms | `a2ui` (grammar: `rly a2ui`) |
70
- | Custom interactive content | sandboxed `html` |
71
-
72
- | Answer shape | Question type |
73
- |---|---|
74
- | One / several choices | `single`, `multi` |
75
- | Binary / rating / color | `yesno`, `scale`, `color` |
76
- | Free text | `text`, `textarea` |
77
- | Priorities / budget / sign-off | `rank`, `allocate`, `checklist` |
78
-
79
- Any block can have `"ref":"source"`; `[View source](#ref:source)` opens its viewer
80
- from another part of the board. `mermaid` with `editable:true` returns user edits
81
- in `blockEdits`. For image feedback, primary drag selects a region/crop;
82
- Space-drag or middle-drag pans. A compare divider moves only by its handle.
83
- `pins:true` adds image point comments.
84
-
85
- ## Open a board on the user's other devices
86
-
87
- When the user reads on a phone or another Mac, and `devlink` is installed, add
88
- `--devlink` to `rly ask|show|view|diff` (or set it once with
89
- `rly config link devlink`). The command prints a private https URL; give the user
90
- that URL and never a localhost one. Without `devlink`, `--public-url
91
- 'https://host:{port}'` takes any https URL that reaches the board. Answers still
92
- come back through `rly wait` and `rly result`.
93
-
94
- ## A2UI widgets
95
-
96
- An `a2ui` block is a small live widget for state and quick actions: a status list,
97
- numbers, a progress bar, buttons, a short form. Write it as A2UI Express in the
98
- `express` field; run `rly a2ui` for the grammar and every component. Clicks and
99
- input values return in `result.blockEdits[blockId]` as `{type:"a2ui", data,
100
- events:[{name, context, at}]}`. A widget is never a substitute for a question you
101
- need answered; use `single`, `yesno` or `text` for that.
102
-
103
- ## File references that open in a modal
104
-
105
- In the intro or a markdown block, use `[label](/absolute/path/file.js:98)`.
106
- Absolute paths are most reliable across authoring directories. `./`, `../`,
107
- `~/`, `file://` URLs, bare paths, and backtick paths are also recognized. Encode
108
- spaces in file URLs, for example `[report](file:///tmp/My%20Report.md)`.
109
-
110
- - `:line`, `:line:column`, and `#Lstart-Lend` select source lines. Columns are
111
- accepted; highlighting is by line.
112
- - UTF-8 source/config/log files have numbered, highlighted source previews.
113
- Markdown renders as a document; CSV/TSV as a table; HTML as a sandboxed static
114
- page. These views also offer a Source button.
115
- - Images, PDF, and browser-compatible audio/video render within the modal.
116
- Playback depends on the browser’s codec support.
117
- - Text previews are limited to 1 MiB and 20,000 lines. Missing files show an
118
- error; binary/oversized files and directories offer **Open in app**.
119
- - Only local paths explicitly referenced by the board are accessible. Links
120
- discovered inside a preview do not grant access to more files. References
121
- read the current disk content; use content blocks for a captured snapshot or
122
- for annotations. Preview modals do not collect annotations.
123
- - Owner and collaborator browser sessions can preview/open local references.
124
- Read-only and reviewer shares cannot; embed needed content as blocks for them.
125
-
126
- After a CLI upgrade, running boards retain their previous server/UI snapshot.
127
- For a board that needs the new viewer, preserve its saved input and reconnect
128
- that same board with the updated CLI; do not replace it with a new board ID.
129
-
130
- ## Wait and read feedback
131
-
132
- For a response-bearing browser board, retain the returned board ID and keep a
133
- foreground waiter running in Codex:
134
-
135
- ```sh
136
- rly ask --file spec.json --detach
137
- rly wait <boardId> --timeout 1800 --while-active --idle-grace 300
36
+ - Question types: single multi yesno text textarea scale color rank checklist allocate.
37
+ - Blocks: markdown(md|mdFile) code(codeFile) diff(diffFile) image compare chart table kpi mermaid graphviz html palette video pdf a2ui. Local files: pass absolute paths.
38
+ - Blocks go at the board root, on a question, or on an option (visual choices).
39
+ - Every id is stable and unique. `required:true` only for answers you cannot continue without.
40
+ - A board with `questions` collects answers. One without is display-only.
41
+
42
+ ## Block and question shapes (copy, then adapt)
43
+ ```jsonc
44
+ {"type":"chart","kind":"bar","title":"Deploys vs incidents","labels":["W1","W2"],"series":[{"label":"Deploys","data":[12,19]},{"label":"Incidents","data":[1,0]}]} // kind: bar|line|pie|doughnut|radar|scatter
45
+ {"type":"kpi","items":[{"label":"Deploys","value":"67","delta":"+12%","dir":"up"}]}
46
+ {"type":"table","columns":[{"key":"name","label":"Name"}],"rows":[{"name":"x"}],"sortable":true}
47
+ {"type":"image","src":"/abs/a.png","alt":"A","pins":true} // users can also drag a region to comment
48
+ {"type":"compare","before":"/abs/a.png","after":"/abs/b.png"} // draggable divider
49
+ {"type":"diff","diffFile":"/abs/change.diff"} {"type":"code","codeFile":"/abs/app.js"} {"type":"markdown","mdFile":"/abs/PLAN.md"}
50
+ {"type":"mermaid","code":"graph TD; A-->B","editable":true} // edits come back in blockEdits
51
+ {"type":"a2ui","title":"Checks","express":"$/runs = [{title: \"Build\", trailing: \"ok\", tone: \"ok\"}]\nroot = Card(\"Checks\", [List($/runs), Button(\"Retry\", action=Event(\"retry\", {}))])"} // buttons and live status: use a2ui, not html
52
+ {"id":"signoff","type":"checklist","label":"Sign off each area","options":["login","billing"]} // pass/fail/N-A per item: one checklist, not many yes/no
53
+ {"id":"rank","type":"rank","label":"Priorities","options":["speed","a11y"]} {"id":"split","type":"allocate","label":"Budget","total":100,"options":["type","space"]}
54
+ {"id":"c","type":"single","label":"Scheme?","options":[{"value":"warm","label":"Warm","blocks":[{"type":"html","html":"<div style='height:100%;background:#c2674b'></div>","height":140}]}]} // a visual per option
55
+ {"id":"s","type":"scale","label":"Rate","min":1,"max":5} {"id":"col","type":"color","label":"Brand color"} {"id":"ship","type":"yesno","label":"Ship?"}
138
56
  ```
57
+ Buttons inside a2ui do not replace a question. Their clicks return in `blockEdits`.
139
58
 
140
- Keep the process/session handle if the shell tool yields. Resume that process
141
- until it exits; use the host’s background-completion mechanism only when it is
142
- available. If the wait times out, run `rly result <boardId>` before deciding
143
- whether another wait is needed. A timeout is not an answer. Detached boards
144
- remain available on the same port until submitted or explicitly stopped.
145
- `--timeout 0` disables the Relay deadline; the default is one day.
146
-
147
- Read **answers, notes, comment, annotations, and blockEdits** together. Notes and
148
- annotations can qualify a selected answer. On timeout/cancel, these may be under
149
- `draft`; treat them as unfinished feedback. Reviewer submissions are side
150
- reviews and never finalize the owner’s board.
151
-
152
- For large results, use the returned `resultFile` to read the complete JSON.
153
- Avoid truncating stdout with `head`/`tail`; inspect every feedback channel before
154
- acting. To reply to annotations, write
155
- `[{"annotationId":"a1","text":"Updated the example."}]` to a file and run
156
- `rly reopen <id> --replies replies.json`.
157
-
158
- ## Details on demand
59
+ ## Other operations
60
+ - Read a file or show a change: `rly view report.md --display-only`, `rly diff`. `rly git pick` and `rly git conflict` collect commit and hunk choices; apply only what the user chose.
61
+ - Continue a board: find it with `rly list` or `rly history`. `rly rescue <id>` reconnects a dropped tab, `rly reopen <id>` serves saved input again, `rly update <id> --file spec.json` changes a running board. Keep its id.
62
+ - A reader on a phone or another computer needs an https url. Pass `--public-url 'https://host:{port}'`, or `--link-command CMD` for any command that takes the port and prints an https URL. `rly config link` saves the choice. Give the person the printed url, never a localhost one.
63
+ - In a markdown block, `[label](/abs/path/file.js:98)` opens that file in a modal on the browser board.
159
64
 
160
- - `rly agent`: full guide, HTML/diagram editing, sharing roles, annotations,
161
- result shapes, and lifecycle recipes.
162
- - `rly schema`: authoritative board fields; `rly <command> --help` for CLI flags.
163
- - `examples/`: ready-to-adapt board specs for visual options, diagrams, and color.
164
- - `rly share <id> --role review|collab|read`: activate sharing only when requested;
165
- `--revoke` disables the selected role. Keep share tokens out of reports/logs.
166
- - `rly upgrade --force`: update CLI/skill while running boards keep their snapshot.
65
+ ## Need more? Load only the topic you need
66
+ `rly agent` lists topics: `questions`, `blocks`, `annotate`, `lifecycle`, `sharing`, `mcp`, `a2ui`. For example `rly agent blocks` before an unusual block. `rly schema chart` or `rly schema checklist` prints the exact fields of one block or question type, and `rly schema` prints them all.
@@ -0,0 +1,84 @@
1
+ // `rly agent <topic>`: prints one part of docs/AGENT.md (or docs/A2UI.md) so an agent loads only what it needs.
2
+ import { CliError } from '../util.js';
3
+
4
+ // Topic -> the H2 headings of docs/AGENT.md it prints, matched by prefix.
5
+ // A unit test checks that every H2 of the guide belongs to exactly one topic.
6
+ export const AGENT_TOPICS = {
7
+ questions: {
8
+ summary: 'creating boards, the spec fields, question types and answer shapes',
9
+ headings: ['Creating boards', 'Board spec (JSON)'],
10
+ },
11
+ blocks: {
12
+ summary: 'every block shape, option visuals, local file links, sizing, custom html',
13
+ headings: ['Block and question shapes', 'Blocks', 'Custom HTML sizing contract'],
14
+ },
15
+ annotate: {
16
+ summary: 'element comments on images, charts and html; reading annotations; replying; editable diagrams',
17
+ headings: ['Annotations', 'Editable diagrams'],
18
+ },
19
+ lifecycle: {
20
+ summary: 'reading results, wait and result, timeouts, presence, update, reopen, rescue',
21
+ headings: ['Two execution patterns', 'Presence', 'Waiting and push-wake', 'Managing boards', 'Live board mutation', 'Tips for agents'],
22
+ preamble: true,
23
+ },
24
+ sharing: {
25
+ summary: 'opening a board on another device: share links, public url, link provider',
26
+ headings: ['Same-Wi-Fi sharing', 'A private URL for other devices'],
27
+ },
28
+ mcp: {
29
+ summary: 'relay as an MCP server: inline boards, tools, hosting',
30
+ headings: ['Inline mode'],
31
+ },
32
+ a2ui: {
33
+ summary: 'A2UI widget grammar: live status, numbers, buttons',
34
+ file: 'A2UI.md',
35
+ },
36
+ };
37
+
38
+ /** Splits a markdown guide into its text before the first H2 and its H2 sections. Headings inside code fences are text. */
39
+ export function splitSections(md) {
40
+ const sections = [];
41
+ let preamble = [];
42
+ let current = null;
43
+ let fence = false;
44
+ for (const line of md.split('\n')) {
45
+ if (/^\s*(```|~~~)/.test(line)) fence = !fence;
46
+ const heading = !fence && /^## (.+)$/.exec(line);
47
+ if (heading) {
48
+ current = { title: heading[1].trim(), lines: [line] };
49
+ sections.push(current);
50
+ } else if (current) {
51
+ current.lines.push(line);
52
+ } else {
53
+ preamble.push(line);
54
+ }
55
+ }
56
+ return {
57
+ preamble: preamble.join('\n').trim(),
58
+ sections: sections.map((s) => ({ title: s.title, text: s.lines.join('\n').trim() })),
59
+ };
60
+ }
61
+
62
+ /** The topic list `rly agent` prints for an unknown topic. */
63
+ export function topicIndex() {
64
+ const rows = Object.entries(AGENT_TOPICS).map(([name, t]) => ` ${name.padEnd(10)} ${t.summary}`);
65
+ return ['rly agent <topic> prints one part of the guide:', ...rows, ' all the whole guide (same as `rly agent`)'].join('\n');
66
+ }
67
+
68
+ /**
69
+ * The text of one topic. `readDoc(file)` returns a docs/ file as text; the
70
+ * caller owns the filesystem so this stays testable.
71
+ */
72
+ export function renderAgentTopic(topic, readDoc) {
73
+ const def = AGENT_TOPICS[topic];
74
+ if (!def) throw new CliError(`unknown agent topic "${topic}".\n${topicIndex()}`, 4);
75
+ if (def.file) return readDoc(def.file);
76
+ const { preamble, sections } = splitSections(readDoc('AGENT.md'));
77
+ const parts = def.preamble ? [preamble] : [];
78
+ for (const prefix of def.headings) {
79
+ const hits = sections.filter((s) => s.title.startsWith(prefix));
80
+ if (!hits.length) throw new CliError(`agent topic "${topic}": the guide has no section "${prefix}".`, 1);
81
+ parts.push(...hits.map((s) => s.text));
82
+ }
83
+ return parts.join('\n\n');
84
+ }
package/src/cli/config.js CHANGED
@@ -2,10 +2,13 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { loadConfig, parseLinkValue, saveConfig, serializeLink } from '../link.js';
5
+ import { BLOCK_TYPES, SPEC_SCHEMA, TYPES } from '../spec/index.js';
6
+ import { lookupSchema } from '../spec/lookup.js';
5
7
  import { runBoard } from '../server/index.js';
6
8
  import { HOME } from '../store.js';
7
9
  import { CliError } from '../util.js';
8
10
  import { DEFAULT_BOARD_TIMEOUT_SEC, PKG_ROOT } from './context.js';
11
+ import { renderAgentTopic } from './agent-topics.js';
9
12
  import { printJson } from './io.js';
10
13
 
11
14
  export function cmdA2ui() {
@@ -13,8 +16,29 @@ export function cmdA2ui() {
13
16
  return 0;
14
17
  }
15
18
 
16
- export function cmdAgent() {
17
- console.log(fs.readFileSync(path.join(PKG_ROOT, 'docs', 'AGENT.md'), 'utf8'));
19
+ const readDoc = (file) => fs.readFileSync(path.join(PKG_ROOT, 'docs', file), 'utf8');
20
+
21
+ // `rly agent` prints the whole guide; `rly agent <topic>` prints one part of it.
22
+ export function cmdAgent(topic) {
23
+ if (topic === undefined || topic === 'all') {
24
+ console.log(readDoc('AGENT.md'));
25
+ return 0;
26
+ }
27
+ console.log(renderAgentTopic(topic, readDoc));
28
+ return 0;
29
+ }
30
+
31
+ // `rly schema` prints the whole board schema; `rly schema <name>` prints one block or question type.
32
+ export function cmdSchema(name) {
33
+ if (name === undefined) {
34
+ console.log(JSON.stringify(SPEC_SCHEMA, null, 2));
35
+ return 0;
36
+ }
37
+ const found = lookupSchema(name);
38
+ if (!found) {
39
+ throw new CliError(`unknown block or question type "${name}". Blocks: ${BLOCK_TYPES.join(', ')}. Questions: ${TYPES.join(', ')}.`, 4);
40
+ }
41
+ console.log(JSON.stringify(found, null, 2));
18
42
  return 0;
19
43
  }
20
44