Design-system graph, token diff and design QA. DTCG 2025.10 tokens → snapshots, diffs, semver and rules. Runs locally, in CI or in the browser, with no server
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗Open-source tooling that keeps implementation within the bounds of the design spec.
dsgraph turns a design system into a graph — tokens, contexts (themes, modes), and later code and Figma — and answers questions about it: what changed between two versions, what breaks, which tokens produce a value. Everything runs locally, in CI or in the browser. There is no server and no account.
Status: 0.6 — tokens and the code that uses them: diff with impact on your code, upgrade checks, checks, CLI, GitHub Action, MCP server and Token Diff. APIs may still change before 1.0. See the changelog.
$root, type inheritance, curly and JSON Pointer references (including property-level), $extends, $deprecated, all types and composites, 14 color spaces, sets, modifiers and resolution order.strict: true turns them into errors.$themes.json and $metadata.json, older JSON with value and type, math, color modifiers, .value references; modes from $extensions.mode and mode files (Figma variable exports)..json — collections with modes become modifiers, references stay. The Figma plugin writes a file's variables and styles as DTCG 2025.10 files with a resolver, or as one file, on the same conversion.[data-theme], .dark and prefers-color-scheme, other media queries as modifiers, inferred types.dsgraph scan | check | diff over folders, files, npm packages, GitHub repositories and saved snapshots.apps/web): drop files or pick an npm package, filter by theme, copy Markdown, export an image to share.| Package | |
|---|---|
@dsgraph/schema | Types, JSON Schemas, canonical JSON and hashing |
@dsgraph/core | Parsing, resolution, values, snapshots, graph queries, diff, semver |
@dsgraph/sources | Virtual file systems: memory, npm (jsDelivr), GitHub, Node |
@dsgraph/adapters | Token-set and value/type JSON, CSS custom properties → tokens |
@dsgraph/rules | Rule engine, built-in rules, presets |
@dsgraph/report | Text, Markdown and JSON formatters |
@dsgraph/cli | CLI, the dsgraph command |
@dsgraph/mcp | MCP server: find the token for a value, read tokens, compare versions |
@dsgraph/action | GitHub Action, published to specsure/dsgraph-action and the Marketplace |
All packages are isomorphic except @dsgraph/sources/node and the CLI.
npx @dsgraph/cli diff npm:@acme/tokens@1 npm:@acme/tokens@2 --format markdown
npx @dsgraph/cli check ./tokens --strict
npx @dsgraph/cli diff npm:@acme/tokens@1 npm:@acme/tokens@2 --code ./src # what breaks in your styles
npx @dsgraph/cli upgrade-check @acme/tokens # before upgrading, in your project
import { DsGraph, diff, scan } from '@dsgraph/core'
import { NpmSource } from '@dsgraph/sources'
const base = DsGraph.from(await scan(new NpmSource('@acme/tokens', '1')))
const head = DsGraph.from(await scan(new NpmSource('@acme/tokens', '2')))
const changes = await diff(base, head)
console.log(changes.summary) // { counts: { added, removed, renamed, changed, … }, level: 'major', reasons: [...] }
head.value('color.text.primary', { theme: 'dark' })
head.chain('color.text.primary') // alias chain down to the literal
head.byValue(head.value('color.base.white')) // every token with that value
npm install
npm run build
npm test
npm run lint
npm run web:dev # the site with Token Diff at http://localhost:4321/tools/diff
Network tests (jsDelivr) are opt-in: DSGRAPH_NETWORK_TESTS=1 npm test.
MIT. The CLI and the MCP server also install @specsure/knowledge, a knowledge pack: data
that adds words dsgraph reads token names by (such as which words name a state). It has its own
license, not MIT, and may be used with dsgraph. The engine works without it:
DSGRAPH_KNOWLEDGE=off.