StarModel invitation
← Back to skills
extension
Category: Productivity & OfficeAPI key requirement unconfirmed

a2ui-ask

When the user must choose among options or fill in structured config, spawn a browser form (powered by schemaui Web UI, bound to 0.0.0.0), open the user's browser, and write the result to .schemaui/answers/. Never use a terminal/TUI prompt — the agent process has no TTY attachment. Trigger phrases: "give me a form", "ask me via form", "configure", "pick a deploy environment", "I need to choose", "a2ui", "给我个表单", "配置一下", "用表单问我", "问我几个问题".

personAuthor: Yunique001hubgithub

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

  1. Browser form, never a terminal prompt. Your process has no TTY, so a terminal UI renders nowhere and hangs.
  2. 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.
  3. 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.
  4. 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.
  5. 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

  1. 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.

  2. 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 to question. 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": ["…"] }
    EOF
    

    Without Python, bash <skill-dir>/scripts/ask.sh and pwsh <skill-dir>/scripts/ask.ps1 take the same flags. On a remote or headless machine add --no-open and relay SCHEMAUI_LAN_URL or the forwarded URL. For sensitive answers bind --host 127.0.0.1 and ask remote users to tunnel first (ssh -L 8787:localhost:8787 <host>).

  3. Relay SCHEMAUI_URL and the deadline. When the script prints SCHEMAUI_ANSWER, give the user that path as well. The default time budget is 300 seconds. A timed-out form leaves the answer uncommitted.

  4. Read the answers after exit 0 from SCHEMAUI_RESULT or stdout and cite field paths: "environment = staging, replicas = 3". When a field holds 其他/other, the real answer is in its <field>_custom sibling. Read a conditional field only when its x-visible-when rule holds: hiding a field does not remove its value.

Writing the schema

  • Recommend every answer, and make the recommendation stick. Put it in default and list the key in the parent's required. From schemaui-cli 0.9.4 the form pre-fills defaults only for required fields: an optional field with a default renders 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 _custom inputs 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, description and option.

  • Give every choice an escape hatch. Add 其他/other to each enum, plus an optional <field>_custom sibling 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-options whose length differs from the enum, and option figures on a segmented control;
  • an x-visible-when rule naming a property that is not a sibling in the same object;
  • an x-content or option figure with an empty source.

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

MIT, see LICENSE.