Skip to content

Latest commit

 

History

History
347 lines (275 loc) · 16.4 KB

reference.md

File metadata and controls

347 lines (275 loc) · 16.4 KB

Lux Reference

Every command, slash command, MCP tool, and element kind, for when you know what you want. Most of the time you just ask your agent or use the Clients menu; the user guide explains that and how Lux works.

Set Up and Check Lux

Slash Shell What it does
/lux lux status Shows whether Lux is on for this checkout and whether the window is running.
/lux enable [local|project] lux enable [--scope local|project] Turns Lux on for this checkout (local, the default) or for everyone in the repository (project), and grants its permission rules.
/lux disable [local|project] lux disable [--scope local|project] Turns Lux off in that scope.
/lux y, /lux n --- Turns your own display preference on or off. Changes nothing for the repository and starts or stops no service.
--- lux doctor Checks the installation: Python, the window packages, fonts, and the Claude Code plugin. Exits 0 only when every check passes.
--- lux install, lux uninstall Installs or removes the Claude Code plugin.
--- lux version Prints the version.
More enable and disable options
Shell What it does
lux enable --refresh Replaces the Lux guide deposited in the checkout with the current one.
lux disable --scope project --opt-out Records that the repository opts out of Lux for everyone.
lux enable --scope project --clear-opt-out Removes that opt-out.

Ask for a View

Describe what you want in plain words. The agent gathers the data, lays it out, and sends it to Lux.

Slash What it does
/lux:scene.beads Shows the repository's issue board: a table you can search and filter, with the selected issue's details below. lux beads [--all] shows the same board from a shell, with no agent.
/lux:scene.dashboard <request> Builds charts and a summary table, for example /lux:scene.dashboard test results for the last five CI runs.
/lux:scene.data-explorer <request> Builds a table you can search and filter, with a detail panel, for example /lux:scene.data-explorer the largest files in this repo.

You can also just ask: "show that as a chart in Lux" works without a slash command.

See What Is on Screen

Slash Shell What it does
/lux:scene.ls lux scene ls Lists the scenes and frames the background service holds.
/lux:scene.inspect <scene> lux scene inspect <scene> [--geometry] Shows the element tree of a scene; with --geometry (or want_geometry=true), also where each element was painted.
/lux:display.screenshot lux display screenshot Captures the window's next frame to a PNG and prints its path on the window's machine.
/lux:event.ls [count] lux event ls [--count <n>] Lists recent clicks and value changes (default 50).
/lux:error.ls [count] lux error ls [--count <n>] Lists recent errors and warnings (default 20).
/lux:menu.ls lux menu ls Lists the menu bar and its items.
/lux:session.ls lux session ls Lists the sessions connected to the background service.
/lux:display.info lux display info Shows the window's backend, size, frame rate, process, and uptime.
/lux:ping lux ping Measures the round trip to the window.
--- lux display perf Shows frame times, slow frames, and frames per second for the last minute.
More display readings
Shell What it does
lux display theme Shows the active theme and the available ones. You choose the theme from the window's menu.
lux display window Shows the window settings: opacity, font scale, decoration, idle frame rate.
lux display state Shows the widget and frame state the window holds for your scenes.
lux display link Shows whether a window is connected and, if not, how much the background service is holding for it.
lux display mode [on|off] --repo <path> Shows or sets whether Lux display mode is on for a project.
lux session inspect <connection> Shows one session, by the connection ID lux session ls prints.

Clean Up

Slash Shell What it does
/lux:scene.clear <scene> lux scene clear <scene> Removes one of your scenes and empties its frame. Refused for a scene you do not own.
/lux:scene.clear-all lux scene clear-all Removes every scene you own.
/lux:frame.remove <frame> lux frame remove <frame> Removes one of your frames and all of its scenes.

In the window, the close button (×) on a frame ends its content, and the collapse triangle minimizes it.

Run the Services

Each machine runs a background service (luxd). A machine that shows the window also runs the window service, and the terminal service runs shells. The installer sets up the background service and the window. Each service is registered with launchd on macOS or systemd on Linux, starts at login, and restarts after a crash.

Background service (lux hub)
Shell What it does
lux hub install, uninstall Registers and starts luxd, or removes it.
lux hub start, stop Starts or stops luxd; stop keeps the registration.
lux hub restart Restarts luxd and returns once the new one answers.
lux hub status Shows whether luxd runs, its port, and its session count.
lux hub doctor [--fix] Finds old registrations and port conflicts; --fix repairs them.
Window (lux display)
Shell What it does
lux display install, uninstall Registers and starts the window, or removes it.
lux display start, stop Starts or stops the window; stop keeps the registration.
lux display restart Restarts the window and returns once the new one has answered the background service and stayed up for three seconds. Service lifecycle internals describe the checks.
lux display status Shows the window service state and process.
lux display doctor [--fix] Finds old registrations and port conflicts; --fix repairs them.
lux display serve Runs the window in the foreground instead of as a service.
Terminals (lux terminal)
Shell What it does
lux terminal install Registers and starts the terminal service, which adds New terminal to the menu.
lux terminal uninstall Stops the service, ending its shells, and removes it.
lux terminal restart Restarts the service, ending its shells.
lux terminal status Shows the service state without starting anything.

For Agents and Programs

Agents call MCP tools at luxd's endpoint, http://127.0.0.1:8430/mcp; the plugin connects Claude Code to it. Programs and scripts reach the same operations with lux commands or the Python library.

How lux commands take JSON and identity
  • A command that takes a body reads JSON from its last argument, from --from <file>, or from standard input.
  • --json prints the result as JSON. -v logs more, and -q prints nothing but JSON.
  • Commands that change something accept --kind, --name, --repo, and --agent (or --as kind=K,name=N,repo=R,agent=A). These set the caller's identity, which labels its frames and decides what it owns.
  • A failed command prints one error line and exits 1.

Show and Change Views

MCP tool Shell What it does
scene_show(scene_id, elements) lux scene show <scene> [<json>] Shows an element tree as a scene, replacing any scene with the same ID. Returns shown:<scene> once the background service holds it, before the window draws it.
scene_table(scene_id, columns, rows) lux scene table <scene> [<json>] Shows a searchable, filterable table with an optional detail panel.
scene_dashboard(scene_id, ...) lux scene dashboard <scene> [<json>] Shows charts and a summary table.
scene_update(scene_id, patches) lux scene update <scene> [<json>] Changes or removes elements by ID. If any patch fails, none is applied.
scene_clear(scene_id), scene_clear_all(), frame_remove(frame_id) see Clean Up Remove your scenes or frames.
scene_inspect(scene_id), scene_ls() see See What Is on Screen Read back what you showed.
list_frames() --- Lists the window's frames and whether each is on screen or minimized.
Frames: where a scene appears and how it ends

See Scenes, Frames, and Tabs for what these mean.

scene_show field What it sets
frame_id Which frame the scene goes in; a new ID opens a new frame.
frame_size The frame's initial size.
frame_flags ImGui window flags.
frame_layout Tabs or stacked scenes.
frame_ttl_seconds Removes the frame after this many seconds.
frame_lifetime detached (the default) or owned. An owned frame needs a connection holding a listener connection, and is refused as push_required without one.
frame_end_action What × does: hub_remove (the default) removes the content, owner also removes it and needs owned, and none draws no ×.

scene_table and scene_dashboard take the same settings in one frame object: frame_id, frame_title, lifetime, end_action. A frame's first show fixes its lifetime and end action; a later show that declares different ones is refused.

Menus, Clicks, and Topics

Clicks and topic events wait in a queue until the agent reads them, and only an applet can own a menu entry or a service; see Sessions, Applets, and the Clients Menu.

MCP tool Shell Slash What it does
menu_set(menus) lux menu set [<json>] /lux:menu.set <menus-json> Replaces your menus on the menu bar. An item with a frame_id raises that frame; an item without one sends a lux.menu event to topic_recv.
topic_subscribe(topic) --- /lux:topic.subscribe <topic> Subscribes this session to an app topic; events queue for it.
topic_unsubscribe(topic) --- /lux:topic.unsubscribe <topic> Stops the subscription.
topic_publish(topic, payload) --- /lux:topic.publish <topic> [<json>] Sends an event to every subscriber of the topic.
topic_recv() --- --- Takes the next queued event without waiting; returns event:<topic>:<payload> or none.
callback_register(callback_id, label) lux callback register <id> <label> --- Registers a menu entry your connection receives clicks on. Refused (push_required) without a listener connection, so a one-shot command is always refused.
callback_pending() --- /lux:callback.pending Shows clicks waiting for this session, without consuming them.
service_register(service) lux service register <service> --- Registers a service your connection serves. Refused without a listener connection.
service_ls() lux service ls --- Lists which hosts serve which services.
session_identify(kind, name, repo, agent) lux session identify --- Declares who this session is, so its frames are labeled.

Reading State

These tools return what the matching commands in See What Is on Screen print: display_info, display_theme_get, display_window_get, display_state_get, display_link_get, display_mode_get(repo), display_screenshot, event_ls(count), error_ls(count), session_ls, menu_ls, and ping.

Element Kinds

Category Kinds
Display text, button (arrow, small variants), image, separator
Interactive slider, checkbox, combo, input_text, input_number, radio, color_picker (alpha, picker modes)
Lists selectable, tree
Data table, plot, progress, spinner, markdown
Canvas draw (line, rect, circle, triangle, polyline, text, bezier)
Layout group, tab_bar, collapsing_header, window, modal, dialog (confirmation dialog whose buttons run handlers in the background service)

Every element with an id accepts an optional tooltip, shown on hover. Windows, tab bars, groups, and collapsing headers can hold any element, to any depth.

Example Tool Calls

Show text and a button
{"tool": "scene_show", "input": {
  "scene_id": "hello",
  "elements": [
    {"kind": "text", "id": "t1", "content": "Hello from the agent"},
    {"kind": "button", "id": "b1", "label": "Click me"}
  ]
}}

The call returns "shown:hello" as soon as the background service holds the scene. A click on the button runs its handler there; the agent does not poll. To see recent clicks:

{"tool": "event_ls", "input": {"count": 5}}

An element that declares "publish": ["my.topic"] publishes each user action on that topic: the kind of event, the scene and element, and the element's own fields, such as a table selection's row_ids and anchor. A session subscribed with topic_subscribe reads these with topic_recv. The full event shape is in the library guide.

Two windows: a slider and a chart
{"tool": "scene_show", "input": {
  "scene_id": "dash",
  "elements": [
    {"kind": "window", "id": "w1", "title": "Controls", "x": 10, "y": 10,
     "children": [
       {"kind": "slider", "id": "vol", "label": "Volume", "value": 50}
     ]},
    {"kind": "window", "id": "w2", "title": "Chart", "x": 320, "y": 10,
     "children": [
       {"kind": "plot", "id": "p1", "title": "Trend",
        "series": [{"label": "y", "type": "line",
          "x": [1,2,3,4], "y": [10,20,15,25]}]}
     ]}
  ]
}}
Change one element
{"tool": "scene_update", "input": {
  "scene_id": "dash",
  "patches": [
    {"id": "vol", "set": {"value": 75}}
  ]
}}

Command Grammar

The full grammar of the lux command

[x] is optional, a | b is a choice, and <x> is an operand.

command    ::= "lux" noun verb [global]
             | "lux" setup [global]

noun verb  ::= "scene"    ( "show" <scene> [body] | "table" <scene> [body]
                          | "dashboard" <scene> [body] | "update" <scene> [body]
                          | "clear" <scene> | "clear-all"
                          | "inspect" <scene> [ "--geometry" ] | "ls" )
             | "frame"    "remove" <frame>
             | "menu"     ( "set" [body] | "ls" )
             | "callback" "register" <id> <label>
             | "service"  ( "register" <service> | "ls" )
             | "session"  ( "ls" | "inspect" <connection> | "identify" )
             | "display"  ( "info" | "theme" | "window" | "state" | "perf"
                          | "link" | "screenshot"
                          | "mode" [ "on" | "off" ] "--repo" <path>
                          | lifecycle | "serve" )
             | "event"    "ls" [ "--count" <n> ]
             | "error"    "ls" [ "--count" <n> ]
             | "hub"      lifecycle
             | "terminal" ( "install" | "uninstall" | "restart" | "status" )

lifecycle  ::= "install" | "uninstall" | "start" | "stop" | "restart"
             | "status" | "doctor" [ "--fix" ]

setup      ::= "enable" [ "--scope" scope ] [ "--refresh" ] [ "--clear-opt-out" ]
             | "disable" [ "--scope" scope ] [ "--opt-out" ]
             | "status" | "doctor" | "install" | "uninstall" | "version"
             | "ping" [ "--timeout" <seconds> ]
             | "beads" [ "--all" ]

body       ::= <json> | "--from" <file>          ; or JSON on stdin
scope      ::= "local" | "project"
global     ::= [ "--json" ] [ "-v" | "-q" ] [ identity ]
identity   ::= [ "--as" "kind=K,name=N,repo=R,agent=A" ]
               [ "--kind" kind ] [ "--name" <name> ] [ "--repo" <path> ]
               [ "--agent" <handle> ]                ; on commands that change something
kind       ::= "cli" | "mcp-session" | "applet" | "app"

MCP tool   ::= noun "_" verb                ; e.g. scene_show, frame_remove
             | "display_" reading "_get"    ; e.g. display_theme_get
slash      ::= "/lux:" noun "." verb [operands]