All plugins

echarts-in-chat

Render a chart inline in the Hermes Desktop transcript: the model emits ::echarts{labels=... values=...} and the plugin mounts an interactive SVG chart (dataZoom slider, click-to-filter legend, resize-aware, 280-560px height clamp) in the plugin SDK's transcript-directive slot. Disclosure — no network calls, no shell commands, no stored credentials, no environment variables, no background processes, and nothing read or written outside the message it renders; the chart is drawn locally as inline SVG with no third-party libraries.

Tommy00748Desktopv2.1.0Updated 1 month ago

About

Render a chart inline in the Hermes Desktop transcript: the model emits ::echarts{labels=... values=...} and the plugin mounts an interactive SVG chart (dataZoom slider, click-to-filter legend, resize-aware, 280-560px height clamp) in the plugin SDK's transcript-directive slot. Disclosure — no network calls, no shell commands, no stored credentials, no environment variables, no background processes, and nothing read or written outside the message it renders; the chart is drawn locally as inline SVG with no third-party libraries.

echarts-in-chat

Render a chart inline in a Hermes Desktop assistant message — zoomable,
legend-filterable, resize-aware — through the official
Desktop Plugin SDK
transcript-directive slot.

A plugin registers a named directive with TRANSCRIPT_DIRECTIVE_AREA; the model
addresses it by emitting a paragraph of the form ::echarts{...}, and the host
mounts this plugin's React component in its place. The plugin never touches the
app's markup, never injects a script, and loads no remote code.

Install

This repository is a Hermes unified package (plugin.yaml plus a
desktop/plugin.js entry point).

Install from GitHub:

hermes plugins install Tommy00748/hermes-plugin-echarts-in-chat

Or clone it manually into the plugin package root:

git clone https://github.com/Tommy00748/hermes-plugin-echarts-in-chat \
  ~/.hermes/plugins/echarts-in-chat

Then enable it in Desktop → Capabilities → Plugins (or ⌘K → Reload
desktop plugins
) and restart the app if the message stream does not pick it up.

Usage

In an assistant message, emit a directive paragraph:

::echarts{labels="Mon,Tue,Wed,Thu,Fri" values="120,200,150,80,70" type="bar" title="Weekly sales"}

Multi-series (bar and line can be mixed):

::echarts{labels="Mon,Tue,Wed,Thu,Fri" series="Sales:bar:120,200,150,80,70;Cost:line:60,90,70,40,35"}

Pie / donut with a taller chart (pie charts do not support zoom):

::echarts{labels="Direct,Search,Social,Email" values="420,310,180,90" type="pie" height="420"}

Compact syntax — integer ranges (a..b) and whitespace-separated numbers:

::echarts{labels="1..12" values="1 4 9 16 25 36 49 64 81 100 121 144" type="line" title="Squares"}

Directive attributes

AttributeMeaning
labelscategory names (x axis, or pie slice names); comma- or whitespace-separated
valuesnumbers — single series; comma- or whitespace-separated
namesingle-series name (used with values; default Value, or 数值 in Chinese)
seriesname:type:v1,v2,... entries separated by ; — multi series
typedefault series type for entries without one: bar | line | pie
titleoptional chart title
heightoptional pixel height, clamped to 280–560 (default 400)
zoom"true" / "false" — the dataZoom slider for bar/line charts (default: on when > 10 categories; no slider for 2 or fewer)

The host's directive grammar does not allow { or } inside the attribute
body, so a raw ECharts option JSON cannot be passed; the values are given as
plain attribute lists instead.

Compact data syntax

  • Ranges — any token of the form a..b expands to every integer from a to
    b, inclusive, ascending or descending. Works in values, in a series body,
    and in labels (labels="1..12"). A range longer than 1000 points is not
    expanded: numeric data produces an error; labels skip the range and record a
    parser warning.
  • Whitespace separators — numbers accept commas or whitespace
    interchangeably ("1,2,3" ≡ "1 2 3"). For labels, whitespace is a
    separator only when there is no comma, so a comma-separated list may still
    contain multi-word labels (labels="New York, Los Angeles").
  • Fully backward compatible: the original labels="Mon,Tue" values="1,2" and
    series="Sales:bar:1,2;Cost:line:3,4" spellings are unchanged.

Language

Plugin-generated text defaults to English. The widget reads
navigator.language: zh and Chinese language tags such as zh-CN and zh-TW
use the shared Chinese (zh, Simplified Chinese wording) string table.
Missing or unrecognized locales, including environments without navigator,
use English. A missing Chinese translation falls back to the English text for
that key. This does not use the Hermes app's language setting.

This applies to validation errors and parser warnings, the streaming placeholder,
copy-button states, tooltips/readouts, both chart accessibility labels, generated
series names (Value / Series 1, or 数值 / 系列 1), and empty states.
User-provided category labels, chart titles, series names, and raw directives are
not translated.

Errors (no blank charts)

Bad data renders a readable error block in the chart's place, naming the
item that does not line up, with the raw directive kept selectable and copyable:

  • labels has 3 items, but values has 4 — single-series length mismatch
  • labels has 2 items, but series "Cost" has 3 — named-series length mismatch
  • "abc" in values is not a number — a token that does not parse
  • type "scatter" is invalid; use: bar, line, pie — illegal type
  • series entry 1 "oops" is missing data; expected "name:type:data" or "name:data" — malformed series entry
  • No data: provide values or series, e.g. ::echarts{labels="Mon,Tue" values="1,2"} — nothing to draw

While the message is still streaming and the directive is incomplete, a muted
"echarts: Reading chart data…" placeholder is shown instead of a red error.
The copy button reads "Copy original directive", then "Copied" on success or
"Copy failed; select the text manually" if clipboard access fails or is unavailable.
Chinese locales show the corresponding Chinese text, for example
labels 有 3 个,values 有 4 个 and "echarts:正在读取图表数据…".

Non-fatal parser warnings (such as an invalid height or skipped label range) are
localized too and returned in spec.warnings; they are not currently displayed
by the widget. With every series hidden, a bar/line chart shows "All series hidden";
a pie chart with no positive visible values shows "No data" (both localized).

Interactions

  • Zoom (dataZoom, bar/line only) — the slider under the plot: drag the window to pan,
    drag either handle to resize, or scroll the wheel over the plot. Defaults on
    for more than 10 categories; zoom="true" enables it with at least 3 categories.
    Pie charts do not show a zoom slider.
  • Legend filter — click a legend item to hide/show that series or slice.
  • Resize-aware — a ResizeObserver on the chart's own element re-lays the
    SVG out when the message column changes width.
  • Tooltip — hovering a category draws a crosshair and a highlight ring on
    every visible series, with a value bubble. Keyboard equivalent: focus the
    chart with Tab, then move with ← / → (↑ / ↓ also work), Home /
    End jump to the ends, Esc clears. Touch equivalent: tap a data point or
    slice. The active values are also written to a visible readout line and an
    aria-live region for screen readers.
  • Height override — height is clamped to 280–560px.
  • Multi-instance safe — every directive is its own React component with no
    shared global state, so two charts in one message can never interfere.

Development

node --test tests/*.test.mjs # parser + render-layer + locale tests (zero dependencies)
hermes plugins validate . --install-deps   # the catalog CI gate

The parser is pure and lives inside desktop/plugin.js on purpose: a Desktop
plugin may only import @hermes/plugin-sdk / react*, so it cannot import a
sibling module. The tests load the real source with its three imports rewritten
in a temp directory — see tests/load-plugin.mjs. Parser helpers take an optional
explicit locale (for example parseChartSpec(attrs, 'zh-CN')), defaulting to
English independently of browser globals. The widget resolves its browser locale
and passes it consistently to parsing and rendering. Tests cover English fallback,
Chinese variants, every parser error/warning, copy success/failure, accessible
readouts/labels, empty states, and preservation of user text. The render tests use
stubbed React hooks, not a full browser or Desktop integration test.

See UPGRADE-BACKLOG.md for the roadmap, the verified SDK
capability boundaries (file access, network, image export, code-block hooks,
other transcript slots), and how to run the next upgrade round.

Disclosure (what this plugin does to your machine)

  • Network calls. None. The chart is drawn locally as inline SVG. There is no
    CDN, no fetch, and no telemetry.
  • Reads/writes outside the plugin's own data. None. It renders only the
    directive it was handed; it does not read or modify the transcript, the app's
    stores, or any files.
  • Clipboard. The error block's copy control writes the directive text to the
    system clipboard via the browser clipboard API, and only on an explicit click.
  • Shell commands. None.
  • Background processes. None. While a chart is mounted it keeps a
    ResizeObserver on its own container and a wheel listener for zoom; both are
    removed when the component unmounts. There is no setInterval.
  • Stored credentials / env vars. None.

Why there is no ECharts and no ```echarts code fence

v1 of this plugin scanned the message stream with a document.body
MutationObserver, replaced matching <pre> blocks, and loaded ECharts from
jsDelivr with a <script> tag. Hermes catalog admission rule 8 refuses both of
those moves, and the Desktop runtime loader only resolves @hermes/plugin-sdk
and react* (a relative import of a vendored file cannot resolve against the
blob: module base), so an external chart library cannot be loaded at all.

The sanctioned way to put content in the message stream is the SDK's
transcript-directive slot — which is addressed by ::name{...}, not by a fenced
code block, and whose attribute grammar forbids {/}. This version therefore
draws the chart itself in SVG and is triggered by ::echarts{...}. It keeps the
behaviour the original demonstrated (zoom, legend filter, resize, height
override) but drops the ECharts library and the code-fence trigger; a
plugin-accessible fenced-code-block renderer hook would be needed to restore
that exact interface.

License

MIT — see LICENSE.

README from the reviewed commit 6825178; it updates when the author re-pins.

Developer Mode

Explore built-in Hermes toolsets and actions.

HermesAgent

Developer?

Create a Hermes extension for Desktop or agent workflows.

Developer Section