a2ui-ask
You write a draft-07 JSON Schema that describes the questions. scripts/ask.py
serves it as a web form through the
schemaui engine, prints the URL,
waits for the user to finish, then echoes any submitted answer. By default,
schemaui keeps the question and answer together in the workspace records.
Contract
- Browser form, never a terminal prompt. Your process has no TTY, so a terminal UI renders nowhere and hangs.
- Say it before you block. The message that starts the form gives the user the URL, the time budget, and the answer path when one is printed.
- Wait for the submission. Save & Exit submits the current answer. Exit without saving returns the last answer explicitly saved in this session, or exits 130 if there was no save. After exit 0, read the answer from the printed file path or, for a stdout-only run, from the script output.
- Never abort the task over a form. On exit 130, ask in chat whether the user wants to continue and wait for their reply. The recommended answers are still unconfirmed. On exit 6, fix the schema or config and rerun. For any other non-zero exit, fall back to plain text.
- Ask only what only the user can decide. Check the code, git history and
"$(schemaui record-dir)/answers"first. Pass--config record:<topic>to prefill the last answer.
Steps
-
Draft the schema by the rules in Writing the schema. One form covers one cluster of related decisions: not one form per question, and not a serial interview in chat.
-
Run the script from the project you are working in. schemaui files the record under the workspace of the current directory, so call the script by its absolute path instead of
cd-ing into this skill. Use--output record:<topic>to name the record or--output record:<workspace>/<topic>for another project. With no explicit destination, the topic comes from the title or schema filename, falling back toquestion. Use--output -to receive the answer without saving a record.python3 <skill-dir>/scripts/ask.py --schema - --output record:deploy-config \ --title "Deployment config" --description "Decides the staging rollout" \ --timeout 600 <<'EOF' { "type": "object", "properties": { "…": {} }, "required": ["…"] } EOFWithout Python,
bash <skill-dir>/scripts/ask.shandpwsh <skill-dir>/scripts/ask.ps1take the same flags. On a remote or headless machine add--no-openand relaySCHEMAUI_LAN_URLor the forwarded URL. For sensitive answers bind--host 127.0.0.1and ask remote users to tunnel first (ssh -L 8787:localhost:8787 <host>). -
Relay
SCHEMAUI_URLand the deadline. When the script printsSCHEMAUI_ANSWER, give the user that path as well. The default time budget is 300 seconds. A timed-out form leaves the answer uncommitted. -
Read the answers after exit 0 from
SCHEMAUI_RESULTor stdout and cite field paths: "environment = staging,replicas = 3". When a field holds其他/other, the real answer is in its<field>_customsibling. Read a conditional field only when itsx-visible-whenrule holds: hiding a field does not remove its value.
Writing the schema
-
Recommend every answer, and make the recommendation stick. Put it in
defaultand list the key in the parent'srequired. From schemaui-cli 0.9.4 the form pre-fills defaults only for required fields: an optional field with adefaultrenders empty (a radio group shows nothing picked) and is missing from the answer file unless the user touches it. An object that holds recommended answers must be required too, all the way up. Leave optional only fields with no recommendation, such as_custominputs and free-form notes. -
Explain in the description, never in the label. Say why you recommend the default ("推荐 X:因为…") and what the answer changes downstream. A
(推荐)suffix on an option leaks into the answer file, because the label is the value. -
Write in the user's language: every
title,descriptionand option. -
Give every choice an escape hatch. Add
其他/otherto each enum, plus an optional<field>_customsibling that appears only when it is picked ("op": "contains"for a multi-select). The escape value is never the default:"delivery": { "type": "string", "enum": ["单个 HTML 文件", "其他"], "default": "单个 HTML 文件" }, "delivery_custom": { "type": "string", "title": "交付形式 · 自定义", "x-multiline": true, "x-visible-when": { "field": "delivery", "op": "equals", "value": "其他" } } -
Pick the control the value deserves, from the table below. Plain text boxes make the user translate in their head; a hint earns its place when it removes typing or rules out a wrong answer.
-
Show a figure when options differ in shape, such as topologies, rollout strategies or data models, so the user picks by recognising the picture. A three-option enum with one-word labels needs no diagram.
Control picker
| The answer is… | Schema |
| -------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| one of 2–4 short labels | enum + "x-control": "segmented" |
| one of a few options that need a full line | enum + "x-control": "radio" |
| one of many | enum (dropdown) |
| several of a set | {"type": "array", "items": {"enum": […]}, "uniqueItems": true} (checkbox list) |
| a yes/no that switches a mode | boolean (switch); one tick among several → "x-control": "checkbox" |
| a number on a scale | minimum + maximum + "x-control": "slider"; named stops → "x-slider-marks" |
| a window with two ends | array of two numbers, minItems/maxItems: 2, minimum/maximum on the array, "x-control": "range" |
| a colour | string + "x-control": "color" |
| a paragraph | string + "x-multiline": true |
| a diagram the user corrects | string + "x-control": "mermaid" (live preview) |
| a variant with its own settings | oneOf of titled objects |
| a group, a list of records, key/value pairs | nested object; array of objects; additionalProperties |
| something that only matters sometimes | "x-visible-when": {"field": "<sibling>", "op": "equals" \| "contains", "value": …} |
| context a sentence cannot carry | "x-content": {"type": "mermaid" \| "svg" \| "markdown", "source": "…"} on the field |
| options the user recognises by their picture | "x-options": [{"label", "description", "content"}, …], one entry per enum value, with radio or select |
Snippets for each row, figure rules and the example index: references/controls.md.
What the engine rejects
schemaui checks hints when it loads the schema. The script turns a rejection
into exit 6 and prints the engine's message, for example
`x-control: "slider"` on `/name` needs a number, but the property is a string.
The engine rejects:
- a control that does not fit the value, or an unknown control name;
x-optionswhose length differs from theenum, and option figures on asegmentedcontrol;- an
x-visible-whenrule naming a property that is not a sibling in the same object; - an
x-contentor option figure with an emptysource.
A slider or range missing a bound is not an error; it falls back to a plain input.
Exit codes
| Code | Meaning | Do |
| ---- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 0 | answer submitted | read the answer and continue |
| 3 | engine missing or too old | fall back to plain text. Offer bash scripts/install.sh or pwsh scripts/install.ps1 (--source gitee / -Source gitee if GitHub is blocked) |
| 4 | timed out, no answer saved | fall back to plain text, or rerun with a longer --timeout if the user wants the form |
| 5 | session or output failed | fall back to plain text |
| 6 | bad input: schema or config rejected/unreadable | fix it from the error message and rerun |
| 130 | user cancelled without submitting an answer | leave recommendations unconfirmed. Ask in chat whether to continue and wait for the reply |
Fallback: plain text
When the form cannot run, ask the same questions in one message, numbered, each
with its recommended answer, and ask for a structured reply. For a recorded
question, save the reply in "$(schemaui record-dir)/answers" as
<topic>-<YYYYMMDD-HHMMSS>.<format> using local time and the reply's format. If
the engine is unavailable, keep the reply in chat until the record directory can
be resolved. Honor an explicit file or stdout destination.
More
- references/controls.md: every control and figure surface with snippets, and which example to copy from.
- references/engine.md: the raw
schemaui webcommand, theming with--theme, and custom frontends. - install.md: every way to install the engine.
- skills/grill-with-docs/SKILL.md: interview discipline for open-ended designs. Use it only when the user has no grilling skill of their own.
MIT, see LICENSE.

Scan to join WeChat group