<lse-intent> — Declarative Intents

A custom element that runs LSE (LokaScript Explicit Syntax) JSON through the hyperfixi runtime.
LSE is a language-agnostic protocol for expressing commands as data — built for LLMs and tools to emit, rather than for hand-writing. Skip the _= attribute and describe what you want as JSON: an action, its roles, and a trigger. The element validates the JSON, wires the trigger, and dispatches lse:validated / lse:executed / lse:error events along the way.
<lse-intent> lse-protocol custom element declarative llm-friendly

Live Demos

1. trigger="click" — toggle .active on a sidebar

Click the button. The element attaches its own listener; no _=, no onclick.

Couldn't wire the toggle — see event log.

2. JSON trigger.event sugar — add .highlighted

Same effect, no trigger attribute. The element reads the wire-format trigger.event field — the form an LLM would most naturally emit.

Couldn't wire the highlight — see event log.
Target box — gets .highlighted on click

3. Protocol validation — missing action

Valid JSON, but missing the required action field. The element fires lse:error and reveals its slot="error" child.

Protocol error: see event log for diagnostics.

Event log

All lse:* events bubble. Watch the lifecycle.

The Code

Toggle on click (Demo 1):

<lse-intent trigger="click"> <script type="application/lse+json"> { "action": "toggle", "roles": { "patient": { "type": "selector", "value": ".active" }, "destination": { "type": "selector", "value": "#sidebar" } } } </script> <button slot="trigger">Toggle Sidebar</button> </lse-intent>

JSON-sugar trigger (Demo 2):

<lse-intent> <script type="application/lse+json"> { "action": "add", "roles": { "patient": { "type": "selector", "value": ".highlighted" }, "destination": { "type": "selector", "value": "#target-box" } }, "trigger": { "event": "click" } } </script> <button slot="trigger">Highlight Box</button> </lse-intent>

Listening for lifecycle events:

document.addEventListener('lse:validated', e => { // e.detail.node, e.detail.diagnostics }); document.addEventListener('lse:executed', e => { // e.detail.node, e.detail.result, e.detail.results }); document.addEventListener('lse:error', e => { // e.detail.diagnostics — array of {severity, code, message} });

How it works:

Trigger modes:

Why this exists:

Try it yourself: