@khanglvm/relay 0.20.2 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/AGENT.md +35 -23
- package/package.json +1 -1
- package/skills/relay/SKILL.md +44 -146
- package/src/cli/agent-topics.js +84 -0
- package/src/cli/config.js +26 -2
- package/src/cli/index.js +3 -5
- package/src/cli/skill.js +21 -22
- package/src/spec/blocks/chart.js +8 -4
- package/src/spec/constants.js +19 -0
- package/src/spec/index.js +1 -0
- package/src/spec/lookup.js +78 -0
- package/src/spec/normalize.js +9 -4
- package/src/spec/ready.js +15 -1
- package/types/spec/blocks/chart.d.ts +1 -1
- package/types/spec/constants.d.ts +14 -0
- package/types/spec/index.d.ts +1 -0
- package/types/spec/lookup.d.ts +57 -0
- package/types/spec/ready.d.ts +2 -0
package/README.md
CHANGED
|
@@ -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
|
@@ -5,7 +5,9 @@ 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
7
|
For a concise workflow, read the bundled skill (`rly skill path`). This guide is
|
|
8
|
-
a reference for fields and less common operations.
|
|
8
|
+
a reference for fields and less common operations. Load one part with
|
|
9
|
+
`rly agent <topic>` (`questions`, `blocks`, `annotate`, `lifecycle`, `sharing`,
|
|
10
|
+
`mcp`, `a2ui`), and one block or question type with `rly schema <type>`.
|
|
9
11
|
|
|
10
12
|
Use `rly show --file spec.json --display-only` when no response is needed. Use
|
|
11
13
|
`rly ask --file spec.json --detach` and a waiter for answers or comments.
|
|
@@ -37,6 +39,23 @@ Everything machine-relevant is on **stdout as JSON**; human-facing logs go to
|
|
|
37
39
|
stderr. Exit codes: `0` submitted/acknowledged · `2` timeout · `3` cancelled ·
|
|
38
40
|
`4` usage error · `5` not found.
|
|
39
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?"}
|
|
56
|
+
```
|
|
57
|
+
Buttons inside a2ui do not replace a question. Their clicks return in `blockEdits`.
|
|
58
|
+
|
|
40
59
|
## Two execution patterns
|
|
41
60
|
|
|
42
61
|
**1. Blocking (simplest).** The command blocks until the user submits, then
|
|
@@ -94,31 +113,26 @@ without Wi-Fi sharing, give it a link setting. `rly ask`, `rly show`, `rly view`
|
|
|
94
113
|
and `rly diff` accept:
|
|
95
114
|
|
|
96
115
|
```sh
|
|
97
|
-
rly ask --file spec.json --detach --devlink # publish through devlink
|
|
98
116
|
rly ask --file spec.json --detach --public-url 'https://boards.example.com:{port}'
|
|
99
|
-
rly
|
|
117
|
+
rly ask --file spec.json --detach --link-command 'my-link-tool {port}'
|
|
118
|
+
rly config link command:'my-link-tool {port}' # make it the default (also: off, or a URL)
|
|
100
119
|
```
|
|
101
120
|
|
|
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
121
|
- `--public-url` takes any https URL that reaches the board's port, such as a
|
|
109
|
-
reverse proxy
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
reverse proxy you run. `{port}` becomes the board port. Loopback hosts are
|
|
123
|
+
refused. `RLY_PUBLIC_URL` and `RLY_LINK` set the same from the environment.
|
|
124
|
+
- `--link-command CMD` (or `RLY_LINK_COMMAND`) runs any command that takes the
|
|
125
|
+
board's port ({port} in the command, or appended) and prints an https URL,
|
|
126
|
+
either as plain text or as JSON with a `url` field. `RLY_LINK_RELEASE_COMMAND`
|
|
127
|
+
runs when the board closes, so the provider can remove its route.
|
|
128
|
+
- Precedence: `--link-command`, `--public-url`, `RLY_LINK_COMMAND`,
|
|
129
|
+
`RLY_PUBLIC_URL`, `RLY_LINK`, `rly config link`, then off.
|
|
114
130
|
- Answers return as usual: `rly wait <id>` and `rly result <id>`.
|
|
115
|
-
- When the board closes, Relay removes the devlink route again.
|
|
116
131
|
|
|
117
132
|
Report the printed URL to the user and never a `localhost`, `127.0.0.1` or
|
|
118
|
-
`0.0.0.0` address.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
access control. Use `rly share <id> --revoke --all` to cut access.
|
|
133
|
+
`0.0.0.0` address. Whoever can reach the link can reach the board, so the token
|
|
134
|
+
in the URL and the network behind the link are the access control. Use
|
|
135
|
+
`rly share <id> --revoke --all` to cut access.
|
|
122
136
|
|
|
123
137
|
## Inline mode — relay as an MCP App (Claude & Codex apps)
|
|
124
138
|
|
|
@@ -134,8 +148,8 @@ browser tab. `rly mcp` speaks the MCP **stdio** transport, so it pairs with a
|
|
|
134
148
|
|
|
135
149
|
**Web / mobile / remote hosts** can't reach a stdio subprocess, so for those run
|
|
136
150
|
the **Streamable HTTP** transport: `rly mcp --http [--port N]` serves the same
|
|
137
|
-
tools at `/mcp`. relay needs **only its own CLI** for this
|
|
138
|
-
|
|
151
|
+
tools at `/mcp`. relay needs **only its own CLI** for this, with no extra
|
|
152
|
+
infrastructure. Because relay is **stateless** (answers go iframe→host→model, never
|
|
139
153
|
back to the server), **one deployed instance serves everyone**, so deploy it once
|
|
140
154
|
on any address the app can reach and register that URL as a custom connector:
|
|
141
155
|
|
|
@@ -146,8 +160,6 @@ on any address the app can reach and register that URL as a custom connector:
|
|
|
146
160
|
- **Smithery** (largest MCP marketplace) — publish the deployed URL with
|
|
147
161
|
`smithery mcp publish <url> -n @you/relay` for discovery + an OAuth gateway, or
|
|
148
162
|
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
163
|
|
|
152
164
|
A hosted instance can't see your local files (so `codeFile`/local-image blocks
|
|
153
165
|
won't resolve there — pass URLs or inline content); run it on your own machine if
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanglvm/relay",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.3",
|
|
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",
|
package/skills/relay/SKILL.md
CHANGED
|
@@ -1,166 +1,64 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: relay
|
|
3
|
-
description: "
|
|
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
|
-
|
|
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
|
-
##
|
|
10
|
+
## Workflow
|
|
11
|
+
1. Write a spec to a JSON file. Never pass big JSON in a shell argument.
|
|
12
|
+
2. `rly ask --file spec.json --detach` prints `{boardId,url}` at once. When no reply is needed: `rly show --file spec.json --display-only`.
|
|
13
|
+
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.
|
|
14
|
+
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.
|
|
14
15
|
|
|
15
|
-
|
|
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.
|
|
27
|
-
|
|
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.
|
|
16
|
+
If Relay MCP tools are connected, `relay_ask` (answers wanted) and `relay_show` (display only) take the same spec and the board renders inline. Embed file content with `mdFile`, `codeFile` or an image block, because inline boards cannot open local file links.
|
|
39
17
|
|
|
18
|
+
## Spec in one screen
|
|
40
19
|
```json
|
|
41
20
|
{
|
|
42
|
-
"title": "
|
|
21
|
+
"title": "Hero review",
|
|
22
|
+
"intro": "Pick one. Click or drag on an image to comment.",
|
|
43
23
|
"blocks": [
|
|
44
|
-
{"type": "markdown", "md": "
|
|
45
|
-
{"type": "
|
|
24
|
+
{"type": "markdown", "md": "Short context."},
|
|
25
|
+
{"type": "image", "src": "/abs/a.png", "alt": "A"}
|
|
46
26
|
],
|
|
47
27
|
"questions": [
|
|
48
|
-
{"id": "
|
|
49
|
-
"options": [{"value": "
|
|
50
|
-
|
|
51
|
-
{"id": "notes", "type": "textarea", "label": "What needs adjusting?", "required": false}
|
|
28
|
+
{"id": "pick", "type": "single", "label": "Which one?", "required": true,
|
|
29
|
+
"options": [{"value": "a", "label": "A", "description": "why"}, "B"]},
|
|
30
|
+
{"id": "notes", "type": "textarea", "label": "Anything else?"}
|
|
52
31
|
]
|
|
53
32
|
}
|
|
54
33
|
```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
34
|
+
- Question types: single multi yesno text textarea scale color rank checklist allocate.
|
|
35
|
+
- 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.
|
|
36
|
+
- Blocks go at the board root, on a question, or on an option (visual choices).
|
|
37
|
+
- Every id is stable and unique. `required:true` only for answers you cannot continue without.
|
|
38
|
+
- A board with `questions` collects answers. One without is display-only.
|
|
39
|
+
|
|
40
|
+
## Block and question shapes (copy, then adapt)
|
|
41
|
+
```jsonc
|
|
42
|
+
{"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
|
|
43
|
+
{"type":"kpi","items":[{"label":"Deploys","value":"67","delta":"+12%","dir":"up"}]}
|
|
44
|
+
{"type":"table","columns":[{"key":"name","label":"Name"}],"rows":[{"name":"x"}],"sortable":true}
|
|
45
|
+
{"type":"image","src":"/abs/a.png","alt":"A","pins":true} // users can also drag a region to comment
|
|
46
|
+
{"type":"compare","before":"/abs/a.png","after":"/abs/b.png"} // draggable divider
|
|
47
|
+
{"type":"diff","diffFile":"/abs/change.diff"} {"type":"code","codeFile":"/abs/app.js"} {"type":"markdown","mdFile":"/abs/PLAN.md"}
|
|
48
|
+
{"type":"mermaid","code":"graph TD; A-->B","editable":true} // edits come back in blockEdits
|
|
49
|
+
{"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
|
|
50
|
+
{"id":"signoff","type":"checklist","label":"Sign off each area","options":["login","billing"]} // pass/fail/N-A per item: one checklist, not many yes/no
|
|
51
|
+
{"id":"rank","type":"rank","label":"Priorities","options":["speed","a11y"]} {"id":"split","type":"allocate","label":"Budget","total":100,"options":["type","space"]}
|
|
52
|
+
{"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
|
|
53
|
+
{"id":"s","type":"scale","label":"Rate","min":1,"max":5} {"id":"col","type":"color","label":"Brand color"} {"id":"ship","type":"yesno","label":"Ship?"}
|
|
138
54
|
```
|
|
55
|
+
Buttons inside a2ui do not replace a question. Their clicks return in `blockEdits`.
|
|
139
56
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
57
|
+
## Other operations
|
|
58
|
+
- 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.
|
|
59
|
+
- 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.
|
|
60
|
+
- 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.
|
|
61
|
+
- In a markdown block, `[label](/abs/path/file.js:98)` opens that file in a modal on the browser board.
|
|
159
62
|
|
|
160
|
-
|
|
161
|
-
|
|
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.
|
|
63
|
+
## Need more? Load only the topic you need
|
|
64
|
+
`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
|
-
|
|
17
|
-
|
|
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
|
|
package/src/cli/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// The rly command router.
|
|
2
|
-
import { SPEC_SCHEMA } from '../spec/index.js';
|
|
3
2
|
import { CliError } from '../util.js';
|
|
4
3
|
import { cmdSkill, firstRunHint, skillFreshnessWarning } from './skill.js';
|
|
5
4
|
import { printHelp } from './help.js';
|
|
@@ -10,7 +9,7 @@ import { cmdHistory, cmdList, cmdOpen, cmdReopen, cmdRescue, cmdReuse, cmdRm, cm
|
|
|
10
9
|
import { cmdDiff, cmdGit } from './git.js';
|
|
11
10
|
import { cmdResult, cmdWait } from './wait.js';
|
|
12
11
|
import { cmdShare } from './share.js';
|
|
13
|
-
import { cmdA2ui, cmdAgent, cmdConfig, cmdServeInternal } from './config.js';
|
|
12
|
+
import { cmdA2ui, cmdAgent, cmdConfig, cmdSchema, cmdServeInternal } from './config.js';
|
|
14
13
|
import { cmdInstall } from './install.js';
|
|
15
14
|
import { cmdUpgrade } from './upgrade.js';
|
|
16
15
|
import { cmdMcp } from './mcp.js';
|
|
@@ -79,12 +78,11 @@ export async function main(argv) {
|
|
|
79
78
|
case 'self-update':
|
|
80
79
|
return await cmdUpgrade(parseArgs(rest));
|
|
81
80
|
case 'agent':
|
|
82
|
-
return cmdAgent();
|
|
81
|
+
return cmdAgent(rest[0]);
|
|
83
82
|
case 'a2ui':
|
|
84
83
|
return cmdA2ui();
|
|
85
84
|
case 'schema':
|
|
86
|
-
|
|
87
|
-
return 0;
|
|
85
|
+
return cmdSchema(rest[0]);
|
|
88
86
|
case 'mcp':
|
|
89
87
|
return await cmdMcp(rest);
|
|
90
88
|
case '__serve':
|
package/src/cli/skill.js
CHANGED
|
@@ -119,31 +119,30 @@ export function stampSkillVersion() {
|
|
|
119
119
|
// AGENTS.md, …). A skill is only a tier-1 hint that agents can ignore; these
|
|
120
120
|
// rules, appended to the instructions the agent always reads, enforce usage.
|
|
121
121
|
// Printed to stdout so `rly skill rules >> CLAUDE.md` is the whole install.
|
|
122
|
-
export const SKILL_RULES = `## relay
|
|
122
|
+
export const SKILL_RULES = `## relay: visual boards and structured feedback
|
|
123
123
|
|
|
124
|
-
- Use Relay for files, visuals, plans, diffs
|
|
125
|
-
|
|
124
|
+
- Use Relay for files, visuals, plans, diffs and several related questions. Keep brief
|
|
125
|
+
answers and progress updates in chat, and follow the authorization the user already gave.
|
|
126
126
|
- Show without feedback: \`rly show --file spec.json --display-only\` (no waiter).
|
|
127
127
|
Collect input: \`rly ask --file spec.json --detach\`, then keep
|
|
128
|
-
\`rly wait <boardId> --timeout 1800 --while-active --idle-grace 300\` in the
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
code
|
|
132
|
-
\`
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- Read answers, notes, comment, annotations
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
sharing permissions: \`rly agent\`. Load details only when needed.`;
|
|
128
|
+
\`rly wait <boardId> --timeout 1800 --while-active --idle-grace 300\` in the foreground.
|
|
129
|
+
A timeout is not an answer: read \`rly result <boardId>\` before continuing.
|
|
130
|
+
- Pick the most specific block: table, chart or kpi for data; image or compare for visuals;
|
|
131
|
+
code or diff for source; mermaid for flows; markdown for prose. Buttons and live status
|
|
132
|
+
are \`a2ui\`. Per-area sign-off is one \`checklist\` question. A visual choice puts
|
|
133
|
+
its picture in \`options[].blocks\`.
|
|
134
|
+
- Exact fields on demand: \`rly schema chart\` (any block or question type), \`rly agent <topic>\`
|
|
135
|
+
(questions, blocks, annotate, lifecycle, sharing, mcp, a2ui). \`rly view\`, \`rly diff\` and
|
|
136
|
+
\`rly git\` are shortcuts.
|
|
137
|
+
- A reader on another device needs an https url: \`--public-url 'https://host:{port}'\` or
|
|
138
|
+
\`--link-command CMD\` (a command that takes the port and prints the url); \`rly config link\`
|
|
139
|
+
saves it. Give the person the printed url, never a localhost one.
|
|
140
|
+
- Browser file links such as \`[source](/absolute/app.js:98)\` open in a modal. For inline MCP
|
|
141
|
+
boards and shared reviewers, embed file content as blocks instead.
|
|
142
|
+
- Reconnect a board by id with \`rly rescue\` or \`rly reopen\`, and change it with \`rly update\`.
|
|
143
|
+
- Read answers, notes, comment, annotations and blockEdits together. Use the returned
|
|
144
|
+
resultFile when stdout is cut short.
|
|
145
|
+
- The full skill is at \`rly skill path\`.`;
|
|
147
146
|
|
|
148
147
|
export function cmdSkill(rest) {
|
|
149
148
|
const sub = rest[0];
|
package/src/spec/blocks/chart.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
// The chart block.
|
|
2
2
|
import { CliError } from '../../util.js';
|
|
3
3
|
import { asStr, clampInt } from '../sources.js';
|
|
4
|
-
import { BLOCK_HEIGHT, CHART_KINDS } from '../constants.js';
|
|
4
|
+
import { BLOCK_HEIGHT, CHART_KINDS, CHART_KIND_FIELDS, CHART_SERIES_FIELDS } from '../constants.js';
|
|
5
|
+
|
|
6
|
+
// The first spelling of a field the agent used, so `chartType` or Chart.js's `datasets` work.
|
|
7
|
+
const firstDefined = (raw, names) => raw[names.find((n) => raw[n] !== undefined)];
|
|
5
8
|
|
|
6
9
|
// Normalizes one chart block. `id` is the already-assigned block id.
|
|
7
|
-
export function normalizeChartBlock(
|
|
10
|
+
export function normalizeChartBlock(raw, id, cwd, where, hasHeight) {
|
|
11
|
+
const rawBlock = { ...raw, kind: firstDefined(raw, CHART_KIND_FIELDS), series: firstDefined(raw, CHART_SERIES_FIELDS) };
|
|
8
12
|
const hasConfig = rawBlock.config && typeof rawBlock.config === 'object' && !Array.isArray(rawBlock.config);
|
|
9
13
|
const hasShorthand =
|
|
10
14
|
typeof rawBlock.kind === 'string' ||
|
|
11
15
|
Array.isArray(rawBlock.labels) ||
|
|
12
16
|
Array.isArray(rawBlock.series);
|
|
13
17
|
if (!hasConfig && !hasShorthand) {
|
|
14
|
-
throw new CliError(`${where}: chart needs "
|
|
18
|
+
throw new CliError(`${where}: a chart needs "kind" (${CHART_KINDS.join('|')}), "labels" and "series": [{"label","data":[...]}], or a full Chart.js "config". \`rly schema chart\` shows the fields.`);
|
|
15
19
|
}
|
|
16
20
|
const block = { id, type: 'chart' };
|
|
17
21
|
block.height = clampInt(rawBlock.height, BLOCK_HEIGHT.min, BLOCK_HEIGHT.max, 320);
|
|
@@ -21,7 +25,7 @@ export function normalizeChartBlock(rawBlock, id, cwd, where, hasHeight) {
|
|
|
21
25
|
}
|
|
22
26
|
// Shorthand form: validate kind/labels/series.
|
|
23
27
|
const kind = asStr(rawBlock.kind).trim().toLowerCase();
|
|
24
|
-
if (!kind) throw new CliError(`${where}:
|
|
28
|
+
if (!kind) throw new CliError(`${where}: add "kind": one of ${CHART_KINDS.join('|')}.`);
|
|
25
29
|
if (!CHART_KINDS.includes(kind)) {
|
|
26
30
|
throw new CliError(`${where}: unknown chart kind "${rawBlock.kind}". Valid: ${CHART_KINDS.join(', ')}.`);
|
|
27
31
|
}
|
package/src/spec/constants.js
CHANGED
|
@@ -33,6 +33,25 @@ export const ALIASES = {
|
|
|
33
33
|
points: 'allocate',
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
// Block type names agents reach for that mean one of ours. A chart kind used as
|
|
37
|
+
// the block type ({"type":"bar", labels, series}) is handled in normalizeBlock.
|
|
38
|
+
export const BLOCK_ALIASES = {
|
|
39
|
+
md: 'markdown',
|
|
40
|
+
img: 'image',
|
|
41
|
+
picture: 'image',
|
|
42
|
+
flowchart: 'mermaid',
|
|
43
|
+
diagram: 'mermaid',
|
|
44
|
+
stats: 'kpi',
|
|
45
|
+
metrics: 'kpi',
|
|
46
|
+
widget: 'a2ui',
|
|
47
|
+
patch: 'diff',
|
|
48
|
+
swatches: 'palette',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Chart field spellings that mean `kind` and `series` (Chart.js calls the second one `datasets`).
|
|
52
|
+
export const CHART_KIND_FIELDS = ['kind', 'chartType', 'chart_type'];
|
|
53
|
+
export const CHART_SERIES_FIELDS = ['series', 'datasets'];
|
|
54
|
+
|
|
36
55
|
export const HTML_HEIGHT = { min: 100, max: 2400, boardDefault: 400, questionDefault: 360 };
|
|
37
56
|
|
|
38
57
|
// Block heights clamp to the same window; defaults vary per block type.
|
package/src/spec/index.js
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// `rly schema <name>`: the exact fields of one block or question type, cut out of SPEC_SCHEMA.
|
|
2
|
+
import { BLOCK_TYPES, TYPES } from './constants.js';
|
|
3
|
+
import { SPEC_SCHEMA } from './schema.js';
|
|
4
|
+
|
|
5
|
+
const BLOCK_PROPS = SPEC_SCHEMA.properties.blocks.items.properties;
|
|
6
|
+
const QUESTION_PROPS = SPEC_SCHEMA.properties.questions.items.properties;
|
|
7
|
+
|
|
8
|
+
// Fields every block carries on top of its own.
|
|
9
|
+
const COMMON_BLOCK_FIELDS = ['type', 'ref', 'height'];
|
|
10
|
+
|
|
11
|
+
// Which BLOCK_PROPS entries each block type reads. A test checks that every
|
|
12
|
+
// property of the block schema belongs to at least one type, so a new field
|
|
13
|
+
// cannot be added to the schema without being listed here.
|
|
14
|
+
export const BLOCK_FIELDS = {
|
|
15
|
+
markdown: ['md', 'mdFile'],
|
|
16
|
+
mermaid: ['code', 'editable'],
|
|
17
|
+
graphviz: ['dot'],
|
|
18
|
+
plantuml: ['code', 'server'],
|
|
19
|
+
chart: ['kind', 'labels', 'series', 'config', 'title'],
|
|
20
|
+
table: ['columns', 'rows', 'rowsFile', 'sortable', 'filterable', 'exportable'],
|
|
21
|
+
code: ['code', 'codeFile', 'lang', 'filename'],
|
|
22
|
+
diff: ['diff', 'diffFile', 'view', 'review', 'reviewKind', 'commit', 'lang', 'filename'],
|
|
23
|
+
'git-conflict': ['content', 'text', 'file', 'path', 'lang', 'filename'],
|
|
24
|
+
video: ['src', 'alt', 'title'],
|
|
25
|
+
pdf: ['src', 'alt', 'title'],
|
|
26
|
+
html: ['html', 'htmlFile'],
|
|
27
|
+
image: ['src', 'alt', 'pins'],
|
|
28
|
+
palette: ['palettes', 'colors', 'name'],
|
|
29
|
+
kpi: ['items'],
|
|
30
|
+
typography: ['specimens'],
|
|
31
|
+
compare: ['before', 'after', 'beforeLabel', 'afterLabel'],
|
|
32
|
+
a2ui: ['express', 'components', 'dataModel', 'title'],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Fields every question carries on top of its own.
|
|
36
|
+
const COMMON_QUESTION_FIELDS = ['id', 'type', 'label', 'description', 'required', 'note', 'blocks'];
|
|
37
|
+
|
|
38
|
+
export const QUESTION_FIELDS = {
|
|
39
|
+
single: ['options', 'other', 'default'],
|
|
40
|
+
multi: ['options', 'other', 'default'],
|
|
41
|
+
yesno: ['default'],
|
|
42
|
+
text: ['placeholder', 'default'],
|
|
43
|
+
textarea: ['placeholder', 'default'],
|
|
44
|
+
scale: ['min', 'max', 'minLabel', 'maxLabel', 'default'],
|
|
45
|
+
color: ['presets', 'palette', 'default'],
|
|
46
|
+
rank: ['options', 'default'],
|
|
47
|
+
checklist: ['options', 'statuses', 'default'],
|
|
48
|
+
allocate: ['options', 'total', 'unit', 'default'],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function pick(props, names) {
|
|
52
|
+
return Object.fromEntries(names.filter((n) => props[n]).map((n) => [n, props[n]]));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The property names the schema defines for blocks and for questions. */
|
|
56
|
+
export function schemaFieldNames() {
|
|
57
|
+
return { block: Object.keys(BLOCK_PROPS), question: Object.keys(QUESTION_PROPS) };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The fields of one block or question type, or null when the name is neither.
|
|
62
|
+
* A name that is both (`code` is only a block; `color` only a question) never
|
|
63
|
+
* collides today; a block wins if one ever does.
|
|
64
|
+
*/
|
|
65
|
+
export function lookupSchema(name) {
|
|
66
|
+
const key = String(name).trim().toLowerCase();
|
|
67
|
+
if (BLOCK_TYPES.includes(key)) {
|
|
68
|
+
const fields = pick(BLOCK_PROPS, [...COMMON_BLOCK_FIELDS, ...(BLOCK_FIELDS[key] ?? [])]);
|
|
69
|
+
fields.type = { const: key };
|
|
70
|
+
return { kind: 'block', type: key, fields };
|
|
71
|
+
}
|
|
72
|
+
if (TYPES.includes(key)) {
|
|
73
|
+
const fields = pick(QUESTION_PROPS, [...COMMON_QUESTION_FIELDS, ...(QUESTION_FIELDS[key] ?? [])]);
|
|
74
|
+
fields.type = { const: key };
|
|
75
|
+
return { kind: 'question', type: key, required: ['label'], fields };
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
package/src/spec/normalize.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// the server and the MCP App read.
|
|
3
3
|
import { CliError } from '../util.js';
|
|
4
4
|
import { asStr, clampInt, readBlockHtml, readHtml } from './sources.js';
|
|
5
|
-
import { ALIASES, BLOCK_HEIGHT, BLOCK_TYPES, HTML_HEIGHT, TYPES } from './constants.js';
|
|
5
|
+
import { ALIASES, BLOCK_ALIASES, BLOCK_HEIGHT, BLOCK_TYPES, CHART_KINDS, HTML_HEIGHT, TYPES } from './constants.js';
|
|
6
6
|
import { BLOCK_NORMALIZERS } from './blocks/index.js';
|
|
7
7
|
|
|
8
8
|
// Normalizes one block object. `id` is the already-assigned block id.
|
|
@@ -13,8 +13,13 @@ function normalizeBlock(rawBlock, id, cwd, where) {
|
|
|
13
13
|
}
|
|
14
14
|
let type = asStr(rawBlock.type).trim().toLowerCase();
|
|
15
15
|
if (!type) throw new CliError(`${where}: missing "type". Valid: ${BLOCK_TYPES.join(', ')}.`);
|
|
16
|
+
if (CHART_KINDS.includes(type)) {
|
|
17
|
+
rawBlock = { ...rawBlock, kind: rawBlock.kind ?? type };
|
|
18
|
+
type = 'chart';
|
|
19
|
+
}
|
|
20
|
+
type = BLOCK_ALIASES[type] || type;
|
|
16
21
|
if (!BLOCK_TYPES.includes(type)) {
|
|
17
|
-
throw new CliError(`${where}: unknown block type "${rawBlock.type}".
|
|
22
|
+
throw new CliError(`${where}: unknown block type "${rawBlock.type}". Use one of: ${BLOCK_TYPES.join(', ')}. \`rly schema <type>\` shows its fields.`);
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
const hasHeight = rawBlock.height !== undefined && rawBlock.height !== null && rawBlock.height !== '';
|
|
@@ -159,7 +164,7 @@ export function normalizeSpec(raw, { cwd = process.cwd() } = {}) {
|
|
|
159
164
|
};
|
|
160
165
|
|
|
161
166
|
if (type === 'single' || type === 'multi' || type === 'rank' || type === 'checklist' || type === 'allocate') {
|
|
162
|
-
const opts = Array.isArray(rq.options) ? rq.options : [];
|
|
167
|
+
const opts = Array.isArray(rq.options) ? rq.options : Array.isArray(rq.choices) ? rq.choices : [];
|
|
163
168
|
q.options = opts.map((o, j) => {
|
|
164
169
|
if (typeof o === 'string' || typeof o === 'number') {
|
|
165
170
|
return { value: String(o), label: String(o) };
|
|
@@ -261,7 +266,7 @@ export function normalizeSpec(raw, { cwd = process.cwd() } = {}) {
|
|
|
261
266
|
throw new CliError('Spec needs "questions" and/or "blocks"/"html" — nothing to show.');
|
|
262
267
|
}
|
|
263
268
|
if (!spec.responseRequired && spec.questions.length) {
|
|
264
|
-
throw new CliError('responseRequired:false
|
|
269
|
+
throw new CliError('responseRequired:false makes a display-only board, which cannot hold questions. Remove "responseRequired" to collect answers, or remove "questions" to keep the board display-only.');
|
|
265
270
|
}
|
|
266
271
|
spec.submitLabel = asStr(raw.submitLabel).trim() || (spec.questions.length ? 'Submit' : 'Acknowledge');
|
|
267
272
|
return spec;
|
package/src/spec/ready.js
CHANGED
|
@@ -81,13 +81,27 @@ async function mermaidValidator() {
|
|
|
81
81
|
return mermaidValidatorPromise;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// Names of the errors JavaScript itself throws. The parser throws these when
|
|
85
|
+
// its sandbox lacks something (`X is not defined`, `Y is not a function`); a
|
|
86
|
+
// diagram with bad syntax makes it throw a plain Error carrying a parse message.
|
|
87
|
+
// The sandbox is another realm, so `instanceof` cannot tell them apart.
|
|
88
|
+
const ENVIRONMENT_ERROR_NAMES = new Set(['TypeError', 'ReferenceError', 'RangeError', 'EvalError']);
|
|
89
|
+
|
|
90
|
+
/** True when the error comes from the checker's own environment and says nothing about the diagram. */
|
|
91
|
+
export function isCheckerFailure(err) {
|
|
92
|
+
return Boolean(err) && ENVIRONMENT_ERROR_NAMES.has(err.name);
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
async function assertMermaidSyntax(code, where) {
|
|
85
96
|
const mermaid = await mermaidValidator();
|
|
86
97
|
try {
|
|
87
98
|
const parsed = mermaid.parse(code);
|
|
88
99
|
if (parsed && typeof parsed.then === 'function') await parsed;
|
|
89
100
|
} catch (err) {
|
|
90
|
-
|
|
101
|
+
if (isCheckerFailure(err)) {
|
|
102
|
+
throw new CliError(`${where}: internal error, the mermaid checker failed and did not check this diagram (${compactError(err)}). The diagram may be fine. Report this to the relay maintainers, or show the diagram as an image or a markdown code block meanwhile.`, 1);
|
|
103
|
+
}
|
|
104
|
+
throw new CliError(`${where}: invalid mermaid syntax. Fix the diagram source: ${compactError(err)}`);
|
|
91
105
|
}
|
|
92
106
|
}
|
|
93
107
|
|
|
@@ -29,6 +29,20 @@ export declare const ALIASES: {
|
|
|
29
29
|
distribute: string;
|
|
30
30
|
points: string;
|
|
31
31
|
};
|
|
32
|
+
export declare const BLOCK_ALIASES: {
|
|
33
|
+
md: string;
|
|
34
|
+
img: string;
|
|
35
|
+
picture: string;
|
|
36
|
+
flowchart: string;
|
|
37
|
+
diagram: string;
|
|
38
|
+
stats: string;
|
|
39
|
+
metrics: string;
|
|
40
|
+
widget: string;
|
|
41
|
+
patch: string;
|
|
42
|
+
swatches: string;
|
|
43
|
+
};
|
|
44
|
+
export declare const CHART_KIND_FIELDS: string[];
|
|
45
|
+
export declare const CHART_SERIES_FIELDS: string[];
|
|
32
46
|
export declare const HTML_HEIGHT: {
|
|
33
47
|
min: number;
|
|
34
48
|
max: number;
|
package/types/spec/index.d.ts
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const BLOCK_FIELDS: {
|
|
2
|
+
markdown: string[];
|
|
3
|
+
mermaid: string[];
|
|
4
|
+
graphviz: string[];
|
|
5
|
+
plantuml: string[];
|
|
6
|
+
chart: string[];
|
|
7
|
+
table: string[];
|
|
8
|
+
code: string[];
|
|
9
|
+
diff: string[];
|
|
10
|
+
'git-conflict': string[];
|
|
11
|
+
video: string[];
|
|
12
|
+
pdf: string[];
|
|
13
|
+
html: string[];
|
|
14
|
+
image: string[];
|
|
15
|
+
palette: string[];
|
|
16
|
+
kpi: string[];
|
|
17
|
+
typography: string[];
|
|
18
|
+
compare: string[];
|
|
19
|
+
a2ui: string[];
|
|
20
|
+
};
|
|
21
|
+
export declare const QUESTION_FIELDS: {
|
|
22
|
+
single: string[];
|
|
23
|
+
multi: string[];
|
|
24
|
+
yesno: string[];
|
|
25
|
+
text: string[];
|
|
26
|
+
textarea: string[];
|
|
27
|
+
scale: string[];
|
|
28
|
+
color: string[];
|
|
29
|
+
rank: string[];
|
|
30
|
+
checklist: string[];
|
|
31
|
+
allocate: string[];
|
|
32
|
+
};
|
|
33
|
+
/** The property names the schema defines for blocks and for questions. */
|
|
34
|
+
export declare function schemaFieldNames(): {
|
|
35
|
+
block: string[];
|
|
36
|
+
question: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The fields of one block or question type, or null when the name is neither.
|
|
40
|
+
* A name that is both (`code` is only a block; `color` only a question) never
|
|
41
|
+
* collides today; a block wins if one ever does.
|
|
42
|
+
*/
|
|
43
|
+
export declare function lookupSchema(name: any): {
|
|
44
|
+
kind: string;
|
|
45
|
+
type: string;
|
|
46
|
+
fields: {
|
|
47
|
+
[k: string]: any;
|
|
48
|
+
};
|
|
49
|
+
required?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
kind: string;
|
|
52
|
+
type: string;
|
|
53
|
+
required: string[];
|
|
54
|
+
fields: {
|
|
55
|
+
[k: string]: any;
|
|
56
|
+
};
|
|
57
|
+
};
|
package/types/spec/ready.d.ts
CHANGED