--- name: beacon-lens-create description: Create, revise, debug or validate a Beacon lens, a single HTML file that renders one agent trace as a purpose-built view (a per-file review, a cost breakdown, a timeline of risky commands, a map of tool use) in a sandboxed tab of the local Beacon dashboard, fed once through window.beacon.getTrace(). Use when the user asks to "make a lens", "build a view of my traces", "visualize this session", wants a custom tab next to the full session in the Beacon dashboard, or when a lens fails to load, renders wrong, or needs checking before install. license: MIT compatibility: Requires the Beacon CLI (beacon) on PATH with endpoint capture installed, so there are traces to render. Reads only local state and makes no network calls. metadata: author: asymptote-labs homepage: https://docs.beacon.sh/concepts/lenses version: "0.1.0" --- # Beacon lens create A **lens** is one self-contained HTML file that renders one agent trace: the prompts, agent messages, tool calls, commands, file edits, approvals, token usage and threat-rule findings Beacon recorded for a session. The local dashboard (`beacon endpoint dashboard`) shows lenses as tabs on a session's page, next to **Full session**, and runs each one in a locked-down frame. You write the file, check it against the user's real sessions, and install it. Nothing is published anywhere: lenses live on this machine. ## Step 1: check that Beacon is available ```bash beacon version ``` If `beacon` is not found, tell the user that lenses need the Beacon CLI, point them to https://docs.beacon.sh/get-started/overview, and stop. Do not install it yourself. ## Step 2: decide what the lens shows Start from the user's description. If it is missing, or leaves a choice open that changes what the numbers mean (what counts as a "turn", a "failure", a "risky" command, which cost total), ask one focused question before building. Define each unit from this request, not from another lens, and label anything derived or estimated as such. ## Step 3: read the spec and the real data ```bash beacon lenses spec # the format, the data, the sandbox, the style tokens beacon lenses spec --example # a complete working lens to start from beacon lenses list # lens ids already in use beacon lenses data # exactly what getTrace() returns for the latest session beacon lenses data --session ``` Read the whole spec before writing anything. Then look at real data rather than guessing its shape from the spec: note which event `type`s the user's sessions carry, whether `file.diff`, `command.output` or `usage` is present, and whether `findings` exists. Design for those, and for sessions that lack them. The output contains whatever content the log retained (prompts, command output, diffs), so read it locally and do not paste large amounts back to the user. ## Step 4: write the file One HTML file. No build step, bundler or `package.json`. Write it in the user's project or a scratch directory, never directly in the lens store. ### Hard limits The dashboard enforces these; a lens that breaks them fails to install or fails to run. - **One file, at most 16 MiB**, with every script, style, image and font inline (`data:` URIs for images and fonts). Inlining a library is allowed but counts against the size and costs parse time on every open; prefer a few lines of your own. - **A manifest**, in exactly one element whose opening tag is spelled exactly `