violet-cli
The violet binary: export, compare, CI setup, any command by name.
Agent-First Development: software built as commands that people and agents both call. Not AI that writes your code.
Preview, on npm
A design token engine.
Every change is a command.
Violet keeps a design system's tokens on one tree, where each theme stores only what it changes. 34 commands read and change that tree, and the CLI, the MCP server and your own code all call the same ones.
npm install --save-dev @lushly-dev/violet-cli@preview
violet call tokens.resolve -i '{"nodeId":"atlas-dark"}'registry.execute('tokens.resolve', { nodeId: 'atlas-dark' }, context)
tools/call { "name": "tokens.resolve", "arguments": { "nodeId": "atlas-dark" } }
The same answer Resolved 13 tokens for 'atlas-dark' through 2 ancestor(s)
Try itPick a line under the prompt, or type your own. The tree beside it is the store the prompt is talking to.
Pick a node to put a command for it on the prompt. To change this tree by hand, go to the design side.
Each command returns the same envelope. A success says what happened and what it touched. A failure names the problem and the next thing to try, so an agent carries on instead of stalling.
Both results were produced on this page, just now, by the tree above.
The engine needs zod and nothing else, and it knows nothing about AFD. The command layer sits on the engine. The command line and the server sit on the commands. Depend on the lowest layer that does your job.
The violet binary: export, compare, CI setup, any command by name.
The violet-mcp binary: an MCP server and a local REST API. Every
command is a tool except validate and doctor, which stay
in the CLI.
The command registry and 34 commands. Each takes
validated input and returns a CommandResult.
Storage, inheritance resolution, export to nine formats, rules and the CSS value validators.
The browser SDK: apply a node's tokens as custom properties and switch themes at runtime.
import { createMemoryDatabase, initializeCore, registry } from '@lushly-dev/violet-afd';
initializeCore();
const context = { db: createMemoryDatabase(), actor: 'build' };
await registry.execute('node.create', { name: 'base', type: 'root' }, context);
await registry.execute('token.add', { nodeId: 'base', tokenId: 'color.bg', value: '#FFFFFF' }, context);
const css = await registry.execute('export', { nodeId: 'base', format: 'css' }, context);
execute validates its
input and returns a result, so a build script and an agent get the same answers.
import { createMemoryDatabase, exportTokens, resolveTokens } from '@lushly-dev/violet-core';
const db = createMemoryDatabase(); // or SQLite, Postgres or Neon
const { tokens } = await resolveTokens(db, 'brand-dark', { filter: 'color.*' });
const { content } = await exportTokens(db, 'brand-dark', { format: 'css' });
// :root { --color-…: … }
TokenDomainError with the
same code, message and suggestion the matching command reports.
# tokens/vintage-dark.tokens.json: one node per file, in DTCG JSON
{
"$extensions": { "dev.lushly.violet": { "parent": "vintage", "type": "theme" } },
"color": { "$type": "color", "bg": { "$value": "#1A1612" }, "fg": { "$value": "{color.ink}" } }
}
# no database: read the tree from the files and write a theme
npx --no -- violet --from ./tokens export css vintage-dark \
--selector '[data-theme="vintage-dark"]' -o dist/vintage-dark.css
violet cicd setup writes the workflows that run
these steps on every pull request.
import { ThemeManager, VioletRuntime } from '@lushly-dev/violet-runtime';
import themes from './theme.json'; // { nodes: { 'brand-dark': [{ id, value }, ...] } }
const violet = new VioletRuntime({
nodeId: 'brand-dark',
source: { tokens: themes.nodes['brand-dark'] }, // preloaded: no token server
});
await violet.load(); // applies the tokens as custom properties
const manager = new ThemeManager(violet, {
themes: [
{ nodeId: 'brand-light', name: 'Light', source: { tokens: themes.nodes['brand-light'] } },
{ nodeId: 'brand-dark', name: 'Dark', source: { tokens: themes.nodes['brand-dark'] } },
],
defaultTheme: 'brand-dark',
});
manager.useSystemPreference('brand-light', 'brand-dark'); // a third theme covers high contrast
apiUrl instead of source and the runtime fetches and
caches them.
npm install @lushly-dev/violet-server@preview
npx violet-mcp # MCP over stdio
# or, from the command line you already have
npx --no -- violet mcp start
validate and doctor, which work
on the machine they run on, becomes an MCP tool with the same input schema and the
same result as the command line. An agent that can preview a change with
changes.impact can be asked to show its work before it writes.
Agents write tokens now, and a token ends up in a stylesheet. Before a page draws a
value, pass it through a validator. It returns a rebuilt, safe value or
null. It never hands the input back.
It is an allow-list, not a filter: what it doesn't recognise is refused, including
url(), var() and named colours. The functions live in
@lushly-dev/violet-core/css, which imports nothing, so a page can load them
alone.
~/.violet/violet.db.tokens-v* tag.violet cicd setup -n <node>
npm install --save-dev @lushly-dev/violet-cli@preview
npm install @lushly-dev/violet-core@preview @lushly-dev/violet-afd@preview zod
npm install @lushly-dev/violet-server@preview
Preview. All five packages are on npm at 0.3.0-preview.0, under
the preview tag, and share one version. SQLite needs the optional
better-sqlite3 package; memory and files need nothing native. The
hosted API, the web editor and the Figma plugin are not released yet.