# Splanc — instructions for AI agents

Splanc lights are LED fixtures whose every LED has a measured 3-D position (in
metres). Each fixture is driven by a small player on the local network that runs
**effects**: tiny shader-like programs evaluated per LED, per frame, with named
knobs (**uniforms**) you can set or glide. You can drive every fixture in a
house from here: change the mood, write a new effect, preview it, deploy it.

You need: Node.js >= 20 and a machine on the same LAN as the lights.

## Fastest path: the CLI

```sh
npx -y https://splanc.io/agent/splanc-agent.tgz list-players          # what's here: names, rooms, firmware
npx -y https://splanc.io/agent/splanc-agent.tgz skill                 # the full how-to (read it before writing effects)
npx -y https://splanc.io/agent/splanc-agent.tgz list-uniforms         # the running effect's knobs, on every player
npx -y https://splanc.io/agent/splanc-agent.tgz ramp-uniforms warmth=0.8 --seconds 20     # a smooth, watchable change
npx -y https://splanc.io/agent/splanc-agent.tgz preview-effect --file calm.fx --out /tmp/p # render on the real maps (PNGs)
npx -y https://splanc.io/agent/splanc-agent.tgz deploy-effect calm --file calm.fx         # budget-checked, then deployed
npx -y https://splanc.io/agent/splanc-agent.tgz save-keypoint dusk                        # keep the current look by name
npx -y https://splanc.io/agent/splanc-agent.tgz recall-keypoint dusk --seconds 10         # glide back to it later
```

Every command prints JSON on stdout and its progress on stderr
(`connecting Kitchen (10.0.0.7)… / Kitchen: connected 850 ms`; `--quiet` turns
it off). Exit status: 0 on success, 1 on an error or when every targeted player
failed, 2 when only some did (the JSON names each player's error). Device
commands take `--players <name|room|all>` (default: the only player, or all
players when they form one room). `list-players` finds players by mDNS and a
sweep of the local /24s; if it finds none, pass `--host <ip>` (repeatable; with
hosts given there is no discovery wait). `npx -y https://splanc.io/agent/splanc-agent.tgz help` lists the commands
(keypoints: `list-`, `save-`, `get-`, `recall-`, `delete-keypoint`,
`blend-keypoints`); `npx -y https://splanc.io/agent/splanc-agent.tgz tools` the full tool surface.

## Fast calls

The hub remembers every player it reaches (`~/.config/splanc/hub.json`: host,
MAC, certificate), so after the first call it goes straight to them: no mDNS
wait, no sweep, no manifest round trip — one TLS handshake per player, which the
player's small chip takes ~0.7 s to do. `list-players` from the cache needs no
TLS at all. What's left is `npx` itself: it re-downloads the bundle on EVERY call
(0.4–2 s) and keeps running whichever version it cached first. For more than a
couple of calls, install once and call the binary:

```sh
npm i -g https://splanc.io/agent/splanc-agent.tgz     # once; re-run to update (or: --prefix ~/.local)
splanc-agent list-players
claude mcp add splanc -- splanc-agent
```

Fastest of all is one long-lived MCP server: its sessions stay open, so every
tool call after the first is a single round trip to the player.

## Long-lived: as an MCP server

```sh
claude mcp add splanc -- npx -y https://splanc.io/agent/splanc-agent.tgz
```

(Any MCP client: command `npx`, args `["-y", "https://splanc.io/agent/splanc-agent.tgz"]`, stdio; or
`splanc-agent` once installed.) Then read the `splanc://players` resource or call
`list_players`. Long tools (discovery, deploys, ramps) send
`notifications/progress` when the call carries a progress token, and log
messages otherwise.

## In the cloud (you can't reach the LAN)

Running in a hosted environment (claude.ai, ChatGPT, a cloud sandbox)? The CLI
above can't see the user's lights from there.

- If the user has added a Splanc connector, you already have the tools above as
  MCP tools, served by their bridge: start with `list_players`.
- If not, ask the user to set up a Splanc **bridge** on their network (the Pi
  image, or `npx -y https://splanc.io/agent/splanc-agent.tgz bridge --relay <relay url>` on any always-on computer
  there) and add `<relay url>/mcp` as a custom connector, signing in with the
  pairing code on the bridge's screen. Guide:
  https://github.com/fughilli/splanc/blob/main/docs/guides/cloud-agent.md
- A tool error saying the bridge is offline means the user's bridge isn't
  running or has no internet; say so rather than retrying in a loop.

## "Set the mood of the room" — the first-contact flow

1. `list_players`. One player: just go. Several and no rooms yet: tools target
   all of them; if the user talks about rooms, ask which is where
   (`identify_player` blinks one), then `set_room` / `set_fixture_pose`.
2. `list_uniforms`: most moods are a uniform change on what is already running —
   prefer `ramp_uniforms` over a new effect.
3. A new look: write an effect (skill: effect-language.md), `compile_effect`,
   `preview_effect` (several players: one room-frame image), `deploy_effect`
   (refuses an over-budget effect; puts the players on one clock), then
   `measure_effect` (with rollback_on_overrun). Swapping effects while people
   watch: `crossfade_to` fades into the new one (rollback_effect fades back).
4. Tell the user what changed and which knobs they can now ask for.

`plot_fixture` shows a fixture, or a room with its poses, in 3D (one PNG) when you
need to see the geometry.

When a fixture doesn't look like the preview: `compare_with_preview` replays the
device's exact frame on the host and says whether the engine, the inputs (map /
topology / LED order) or the output stage differs, with VM locals; `pause_fx`,
`step_fx`, `snapshot_fx` (with `led` for one LED's locals) test the hypothesis and
`resume_fx` ends it (it also auto-resumes).

## Rules

- You can't rewire, re-map or recalibrate fixtures — that's the Splanc app's job.
- Rename a player (`set_device_name`) only when the user asks, with `confirm`.
- There is no authentication on the LAN: anyone on it can drive the lights. Don't
  expose the hub beyond the user's machine; the bridge (`npx -y https://splanc.io/agent/splanc-agent.tgz bridge`) is the
  supported way to reach it from outside (paired agents only, through a relay).
- Firmware too old for a feature → say so and point the user at the app's update.
- Something in Splanc reproducibly broken (a crash, a tool failing on valid input, the
  preview and the fixture disagreeing)? Offer `file_bug`: it scrubs secrets, checks for
  duplicates and returns a pre-filled GitHub link; it files directly only when the user
  has read the report and agreed.

## Reference

- Skill: https://splanc.io/agent/skill/SKILL.md (also `npx -y https://splanc.io/agent/splanc-agent.tgz skill <file>`)
- [SKILL.md](https://splanc.io/agent/skill/SKILL.md)
- [effect-language.md](https://splanc.io/agent/skill/effect-language.md)
- [examples/height_gradient.fx](https://splanc.io/agent/skill/examples/height_gradient.fx)
- [examples/imu_tilt.fx](https://splanc.io/agent/skill/examples/imu_tilt.fx)
- [examples/noise_field.fx](https://splanc.io/agent/skill/examples/noise_field.fx)
- [examples/plane_slice.fx](https://splanc.io/agent/skill/examples/plane_slice.fx)
- [examples/plane_slice_pose.fx](https://splanc.io/agent/skill/examples/plane_slice_pose.fx)
- [examples/plasma_fixed.fx](https://splanc.io/agent/skill/examples/plasma_fixed.fx)
- [examples/rainbow_spin.fx](https://splanc.io/agent/skill/examples/rainbow_spin.fx)
- [examples/segment_pulses.fx](https://splanc.io/agent/skill/examples/segment_pulses.fx)
- [examples/solid_fill.fx](https://splanc.io/agent/skill/examples/solid_fill.fx)
- [examples/texture_sampler.fx](https://splanc.io/agent/skill/examples/texture_sampler.fx)
- [geometry.md](https://splanc.io/agent/skill/geometry.md)
- [uniforms-and-ui.md](https://splanc.io/agent/skill/uniforms-and-ui.md)
- Bundle: https://splanc.io/agent/splanc-agent.tgz — version 1.17.1 (firmware none..none); https://splanc.io/agent/latest.json
- MCP metadata: https://splanc.io/.well-known/mcp/server.json
- Source: https://github.com/fughilli/splanc (agent/)
