One Vocabulary Across Surfaces
Charton has four surfaces over one dialect: the Rust API, the JSON document, the
charton command line, and the Nushell plugin. The document is the
authority. It is what charton schema publishes, what render consumes, and
what the MCP server validates — so every name the other surfaces use comes from
it.
The goal is not feature parity. plot is deliberately smaller than a document,
and the plugin is deliberately larger than plot. The goal is that a name means
one thing everywhere: --size is the same channel, taking the same kind of
value, in charton plot, in charton point, and in encoding.size. A habit
learned in one place then composes in the others, and an agent moving between
MCP and a shell does not have to relearn the grammar.
The rules
1. A channel flag names a column
--x, --y, --y2, --color, --size, --shape, --text, --path-group
and --z take a column name in both front-ends, exactly as
encoding.<channel>.field does in a document.
| Surface | The size channel |
|---|---|
| Document | "encoding": {"size": {"field": "population"}} |
| CLI | charton plot cities.csv --size population |
| Nushell | open cities.csv | charton point --size population |
2. A fixed value is not spelled with a channel's name
Bare names belong to the channels, so a constant moves to the mark level —
which in the document is literally the mark object, and on the command line is
literally the --mark- prefix:
| Concept | Flag | Document | Layer record |
|---|---|---|---|
| Colour | --mark-color red | "mark": {"color": "red"} | style: {color: red} |
| Size | --mark-size 8 | "mark": {"size": 8} | style: {size: 8} |
| Opacity | --opacity 0.5 | "mark": {"opacity": 0.5} | style: {opacity: 0.5} |
| Band width | --mark-width 0.6 | — | style: {mark-width: 0.6} |
A constant that no channel wants keeps its own name: --opacity, --stroke,
--stroke-width. Those are plugin-only, because plot stays on the channels and
leaves styling to the document. A --layer record has the same two levels as the
document — bare keys are channels, style holds the constants — so moving a
chart between the three surfaces is a matter of re-indenting, not of translating.
3. Five short flags, the same five letters everywhere
-x, -y, -c (--color), -o (--output), -t (--title). Everything
else is long-only, in both front-ends and in every command, so a short letter can
be learned once and never means two things. charton-cli/src/cli.rs has a test
that fails on a sixth.
4. A value is spelled the way the schema spells it
Command names are hyphenated because that is the shell's spelling
(charton density-2d). A value is spelled the way the document spells it —
"mark": "density_2d", "pathGroup", "log" — because a value is data, and
the schema is the only description of data that is checked. --mark also accepts
the hyphenated form as a hidden alias, so a person who has seen both spellings is
never trapped by the difference.
The three tiers
A name present on one surface and absent on another is fine. Drift is only when one concept has two names, or two meanings.
| Tier | Examples | Rule |
|---|---|---|
| Shared | x, y, color, size, shape, text, path-group, title, output | Same name, same kind of value, in both front-ends |
| Document-only | theme, transform, layer, facet, encoding.x.scale, encoding.x.domain | plot does not expose it; a chart that needs it is written as a document |
| Host-only | --mark (a subcommand in Nushell), --emit-spec, --force; --raw, --inline, --inline-style, --no-inline, --force-inline | Belongs to the medium, not to the grammar |
The middle row is a decision, not a gap: plot exists so the common chart is one
line, and a flag for every capability would turn it into a second, worse
document. The third row is the same idea from the other side — writing to stdout,
drawing into a terminal, or emitting the document you just drew describes the
medium, not the chart. Where both front-ends can do one of those things they
use the same name and the same charton::terminal encoders, and where one cannot
the flag simply does not exist there.
Where the rule is enforced
charton-cli/src/cli.rs— the five-short-flag test, and the vocabulary in the module documentation.nu_plugin_charton/src/command.rs—--sizeand--shapeare columns,--mark-sizeand--mark-shapeare values, and a test pins both.- The document itself: the schema is generated from the Rust types and compared against the committed file, so a channel cannot be renamed in one place only.