Skip to content
WM KeyboardWM Keyboard
Accessibility

Running a plugin on your computer

wmpy run shows a plugin's panel in the terminal and wmpy preview shows it in a browser or an editor, both reloading as you save, with real requests and pretend phone features.

wmpy can run your plugin’s panel on your computer while you edit it in your own editor. wmpy run draws the panel in the terminal. wmpy preview draws it in a browser, with the web editor’s own renderer, and editors can show that page beside your code. Both run the interpreter the keyboard uses, with the keyboard’s limits, and both load the plugin again each time you save a file in its folder.

To install wmpy, see Install wmpy.

A computer is not a phone, so some host calls do the real thing and the rest get answers of the right shape. Every permission your plugin.json lists counts as allowed, as in the plugin editor.

CallsOn your computer
httpReal https requests, only to the hosts in plugin.json (and a server typed into a host setting). The keyboard’s limits apply: 60 requests a minute, 15 seconds, 1 MB replies, redirects checked again at each hop, no cookies
wm.storage, plugin.state(persist=True), wm.remindersReal, kept in .wmpy/ in the plugin folder
wm.secrets, secret settingsKept in .wmpy/secrets.json
plugin.settingsThe defaults in plugin.json, then what the plugin saved in .wmpy/settings.json, then --set
fieldA pretend text field you can see and edit
clipboardA pretend clipboard. It starts with “Text the user copied”
ui.toast, ui.dialogShown on the panel. You answer the dialog
plugin.every, plugin.after, then=Real timers and answers that arrive later, as on the phone
ai, location, files, scan, sensors, calendar, todoPretend answers, the same ones the web editor gives (Phone features)
notify, share, device, clock, keyboardWritten to the console: what the phone would have done
time.zoneOnly UTC. Answer other zones from a mock file

Each part of a run has the keyboard’s budget: 9 million steps and 3 seconds to load, 6 million and 2 seconds for an event, 1.2 million and half a second to draw. Time spent waiting for http does not count. A plugin that runs out is stopped with the same error the phone shows, and the console says which budget it was.

Add .wmpy/ to your .gitignore: it holds your test data, not the plugin.

--mock takes the same file wmpy test reads. An op in the file answers before anything else, real requests included. A list of routes answers only the calls it matches; any other request goes to the real host, with the usual checks.

mock.json
{
"location.get": {"lat": 51.5072, "lon": -0.1276, "accuracy": 15},
"ai.ask": {"text": "Two stops, then change at Bank."},
"http.request": [
{"when": {"url": "https://api.example.com/stops*"}, "reply": {"status": 200, "text": "[]"}}
]
}

A reply that is only {"error": {"kind", "message"}} raises that error, so you can try the unhappy paths by hand.

A setting starts at its default in plugin.json. What the plugin writes with plugin.settings.set is saved in .wmpy/settings.json and kept across runs. --set wins over both, and is read again on every reload:

Terminal window
wmpy run my-plugin/ --set units=imperial --set server=https://money.example.com

A host setting typed this way lets http reach that server, as it does on the phone. A server on your local network also needs network.local in the manifest. A secret given with --set stays in memory and is not saved.

Terminal window
wmpy run my-plugin/

The left of the terminal is the panel, 52 columns wide, about a phone’s width. --width changes it. On the right, or below in a narrow terminal, is a pane with five tabs. The status line at the bottom shows whether the last call worked and how many steps it used.

TabShows
Consoleprint() and wm.log lines, errors with their file, line and traceback, and what the host did (a toast, a field edit, a pretend answer)
EventsA line where you type an event as JSON and send it, the events this draw takes, and the ones you sent
StorageWhat the plugin saved. d deletes the key you pick
FieldThe pretend text field and the clipboard. You can type in the field
CallsEvery host call, where its answer came from (real, pretend, mock or refused), how long it took and what it returned
KeyDoes
Tab, Shift-TabNext and previous control
Up, DownThe control above or below
Left, RightMove a slider, change a dropdown
Enter, SpacePress the control. In a text box, Enter submits
hHold a holdable button, card or canvas
EscStop typing in a text box, so letters are keys again
PageUp, PageDownScroll the panel
Ctrl-O or F6Move between the panel and the pane
1 to 5, F1 to F5, [ and ]Pick a tab in the pane
r, Ctrl-RLoad the plugin again. Storage stays
?All the keys
q, Ctrl-CQuit

The mouse works too. Click a control to press it, scroll with the wheel, and drag on a canvas that takes drags. A multi-line box takes Enter as a new line and Ctrl-S to submit.

--locale bn runs the plugin as a phone set to Bengali would: plugin.locale is "bn", and an API 5 plugin’s text comes from locales/bn.json. --theme dark sets plugin.theme and plugin.dark, and --surface float or --surface action runs it as a floating window or a selection action would, as plugin.surface tells it. wmpy preview takes the same three.

A plugin folder can keep these, the mock and the settings in wmpy.toml, under [run], so a plain wmpy run uses them. An option on the command line wins.

A terminal draws with characters, so the panel shows what each widget is and does rather than how the keyboard dresses it. Charts and sparklines are drawn with ratatui’s own charts, and a canvas with braille dots. Pictures and QR codes are boxes that name what they hold. Dates are in UTC.

When you quit, the last error is printed again so it stays on screen.

Terminal window
wmpy preview my-plugin/

This starts a small web server on your computer and opens the page in your browser. The panel looks as it does in the web editor, which follows the keyboard’s own. Beside it are the same five tabs as in the terminal. Saving a file reloads the plugin and the page follows on its own.

OptionDoes
--port NListen on port N. With no port, wmpy picks a free one
--host127.0.0.1 (the default), localhost or ::1. The server never listens beyond your computer
--theme darkDark page, and plugin.dark is true
--locale TAG, --surfaceAs for wmpy run. A right-to-left language, such as Arabic or Urdu, draws the panel right to left
--no-openPrint the address and open no browser
--print-urlPrint one line of JSON, {"url": ..., "port": ...}, once the server listens, and open no browser. For editors and scripts
--mock, --set, --no-watchAs for wmpy run

The address ends in ?t= and a long random token. Every request needs it, so other websites open in your browser cannot reach the preview. The server also answers only to the names 127.0.0.1, localhost and [::1]. Keep the address to yourself while the preview runs; a new run makes a new token.

Two things can follow the address. &theme=dark or &theme=light sets the page’s look and tells the plugin. &embed=1 shows only the panel and a thin strip with the last console line or error, for a side view in an editor.

The editor extensions and the language server start wmpy preview --print-url and show the page in a VS Code webview or a JetBrains browser tab, with embed=1 and your editor’s theme, or open it in your browser. Any tool can do the same: run the command, read the first line, and open the URL.

wmpy runwmpy previewWeb editorPhone
Your own editorYesYesNoNo
Looks like the keyboardRoughlyLike the web editorLike the web editorExactly, in your theme
httpReal, to your hostsReal, to your hostsOnly sites that allow it (CORS)Real
Field and clipboardPretendPretendPretendReal
AI, location, files, sensorsPretend or mockPretend or mockPretendReal
Storage.wmpy/.wmpy/The browserThe keyboard
ReloadsOn saveOn saveAs you typeOn install

Check a plugin on the phone before you share it: only the keyboard shows the real field, your theme and the permission prompts.