You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feedback: too much 'why cool', not enough 'how to use'. Changes: (1) dropped the 'Built for the agent era' paragraph — redundant with 'Who it's for' above. (2) Rewrote usage sections with concrete before/after — Claude Code section now shows a real agent turn + the exact JSON returned. (3) Added a shell-script usage example with jq parsing. (4) Renamed 'Agent-native example' to a collapsible <details> block under the patterns table so the wall of JSONL is available but not in the scroll path. (5) Renamed 'Use cases' → 'Common patterns' — grounds the reader in what works, not abstract positioning.
Copy file name to clipboardExpand all lines: README.md
+61-50Lines changed: 61 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,84 +67,75 @@ macOS-only is a choice, not a gap. A Linux port (GTK + WebKit2) and a Windows po
67
67
68
68
---
69
69
70
-
## Built for the agent era
70
+
## Use it
71
71
72
-
The Opus 4.7 / Claude Code / MCP generation of tools is reasoning well enough that human-in-the-loop moments are common and consequential. Deploy approvals. Reviewer picks. Config forms. Diff acknowledgements. These deserve a real UI — not `[y/N]`.
72
+
### With Claude Code
73
73
74
-
`webview-cli` is how you give your agents that UI without bundling a browser.
74
+
Install the bundled skill once:
75
75
76
-
### With Claude Code (via the bundled skill)
76
+
```bash
77
+
ln -s "$(pwd)/skill"~/.claude/skills/webview # or use the installer flag
78
+
```
79
+
80
+
Then ask your agent anything that needs structured input from you. The skill handles the rest — generates A2UI, spawns the binary, parses the result, returns typed data. You never write JSONL by hand.
81
+
82
+
**Example: deploy approval.** Agent says:
83
+
84
+
> "I'm about to deploy `billing-webhook` to production. Should I proceed?"
85
+
86
+
The skill opens a native window with the change summary, a rollout radio (canary / full), a comment field, and Approve/Cancel. You click. The agent receives:
77
87
78
-
The installer drops a `/webview` skill into `~/.claude/skills/webview/`. Your agent just does:
88
+
```json
89
+
{"action": "approve", "data": {"rollout": "canary", "note": "Monitoring on standby"}}
90
+
```
79
91
80
-
> "I need approval before deploying. Show the user the change summary with an option to add a comment."
92
+
and continues. No terminal input. No context loss.
81
93
82
-
Claude Code routes through the skill, generates A2UI JSONL, invokes `webview-cli --a2ui`, parses the returned JSON, and continues with the result. You never touch JSONL by hand.
94
+
Other patterns the skill handles out of the box: single-select from agent-found options (PRs to review, branches to rebase), multi-field config forms, diff-and-acknowledge flows. Full skill docs: [`skill/SKILL.md`](skill/SKILL.md).
83
95
84
-
### With OpenAI's Codex CLI or Gemini CLI
96
+
### With OpenAI Codex CLI, Gemini CLI, or any subprocess-capable agent
85
97
86
-
Both are subprocess-capable. Any agent that can `spawn_subprocess` and read stdout can use webview-cli. Minimal wrapper in Python works for either:
98
+
The binary is protocol-agnostic. Anything that can `spawn_subprocess` and read stdout works:
# json.loads(result.stdout) has {"status", "data": {"action", "data": {...}}}
100
110
```
101
111
102
-
Protocol details in [`docs/protocol.md`](docs/protocol.md). A sharable Codex/Gemini tool definition is in [`examples/openai-codex-tool.md`](examples/openai-codex-tool.md).
103
-
104
-
### With shell scripts or MCP servers
105
-
106
-
`webview-cli` is a Unix tool. Stdin JSON in, stdout JSON out. Pipes work. Blocking semantics work. Exit codes work. Use it anywhere a subprocess can run.
107
-
108
-
---
112
+
A complete wrapper plus a Codex tool definition you can paste into your agent config: [`examples/openai-codex-tool.md`](examples/openai-codex-tool.md).
109
113
110
-
## Agent-native example
111
-
112
-
Here's what an agent approval flow looks like end-to-end. Your agent pipes this on stdin to `webview-cli --a2ui`:
{"surfaceUpdate":{"components":[{"id":"title","component":{"Text":{"usageHint":"h2","text":{"literalString":"Deploy billing-webhook to prod?"}}}}]}}
118
-
{"surfaceUpdate":{"components":[{"id":"diff","component":{"Text":{"usageHint":"body","text":{"literalString":"3 files · +47/-12 · CI green · MASS-683"}}}}]}}
@@ -153,9 +144,9 @@ Show the diff, context, and a comment field. One click, agent continues with a s
153
144
154
145
### Pick from options
155
146
156
-
Agent enumerates candidates (PRs, branches, customers, files). User picks one with radio buttons. Agent proceeds.
147
+
Agent enumerates candidates (PRs, branches, files). User picks one with radio buttons. Agent proceeds with the choice.
157
148
158
-
[`examples/multi-field-form.jsonl`](examples/)
149
+
[`examples/`](examples/)
159
150
160
151
</td>
161
152
</tr>
@@ -164,21 +155,41 @@ Agent enumerates candidates (PRs, branches, customers, files). User picks one wi
164
155
165
156
### Multi-field config
166
157
167
-
Text inputs + selects + checkboxes in one native form. Better than 6 terminal prompts in a row.
158
+
Text inputs + selects + checkboxes in one native form. Better than six `read -p` prompts in a row.
168
159
169
160
</td>
170
161
<tdwidth="50%"valign="top">
171
162
172
163
### Custom HTML via `agent://`
173
164
174
-
When A2UI's components aren't enough (charts, diffs, diagrams), pipe base64-encoded HTML on stdin. In-memory scheme handler serves it — no HTTP server.
165
+
When the A2UI catalog isn't enough — charts, diffs, diagrams — pipe base64-encoded HTML on stdin. In-memory scheme handler serves it, no HTTP server.
{"surfaceUpdate":{"components":[{"id":"title","component":{"Text":{"usageHint":"h2","text":{"literalString":"Deploy billing-webhook to prod?"}}}}]}}
180
+
{"surfaceUpdate":{"components":[{"id":"diff","component":{"Text":{"usageHint":"body","text":{"literalString":"3 files · +47/-12 · CI green · MASS-683"}}}}]}}
That's the whole approval UI above. One line per component, flat adjacency list, LLM-friendly to generate. The skill produces this from a short natural-language description of the UI.
0 commit comments