@flashdsm/genome 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Itay Haephrati
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # @flashdsm/genome
2
+
3
+ Flash Genome: the local MCP server for a [Flash DSM](https://flashdsm.com) design system, over stdio.
4
+
5
+ Point it at a `design-tokens.json` and every MCP client - Cursor, Claude
6
+ Desktop, Claude Code - can read your real tokens and component specs instead of
7
+ guessing hex values. It also lints code against the system and proposes the
8
+ token you should have used. Deterministic tools, no LLM inside: the AI is on
9
+ the other end of the protocol.
10
+
11
+ Works standalone with any token file - a plain `design-tokens.json` next to
12
+ your project is enough.
13
+
14
+ ## Connect it to a Flash design system
15
+
16
+ Mint an MCP token in Flash under Connect, then in your repository:
17
+
18
+ ```bash
19
+ export FLASH_GENOME_TOKEN=flash_mcp_…
20
+ npx @flashdsm/genome link
21
+ ```
22
+
23
+ `link` asks the server which system the token belongs to and writes
24
+ `genome.config.json` next to your code: the system's id, its revision, and
25
+ where token files and agent context live. The token is never written to that
26
+ file - it is committed, and a token in it would be a token in the
27
+ repository's history.
28
+
29
+ ## Quick start
30
+
31
+ ```bash
32
+ npx @flashdsm/genome --tokens ./design-tokens.json
33
+ ```
34
+
35
+ Cursor (`.cursor/mcp.json`) or Claude Desktop (`claude_desktop_config.json`):
36
+
37
+ ```json
38
+ {
39
+ "mcpServers": {
40
+ "flash-ds": {
41
+ "command": "npx",
42
+ "args": ["@flashdsm/genome", "--tokens", "./design-tokens.json"]
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ With no flags it looks for `./genome.config.json`, then the older
49
+ `./flash-ds.config.json` (`tokenFile` / `componentsFile`), then `./design-tokens.json` with a sibling
50
+ `./components.json`, and finally falls back to a small bundled fixture so the
51
+ server always boots. It logs which file it resolved to stderr.
52
+
53
+ ## Keeping a repo in sync
54
+
55
+ Once linked:
56
+
57
+ | Tool | What it writes |
58
+ | --------------- | ------------------------------------------------------------------------------------ |
59
+ | `pull_from_web` | The token files and mirrors named by `genome.config.json`, plus `genome/genome.lock` |
60
+ | `sync_context` | `AGENTS.md` (once), the Cursor rule, and the Agent Skill |
61
+
62
+ Both are dry runs by default: they return a plan of what would be created,
63
+ updated or skipped, and write only when called again with `confirm: true`.
64
+ A second pull is all skips, lock included, whenever the revision, the file
65
+ list and their contents all still agree, so pulling to check never leaves a
66
+ diff behind.
67
+
68
+ ## Sending repo edits back
69
+
70
+ | Tool | What it does |
71
+ | -------------- | ----------------------------------------------------------------------------------------------------- |
72
+ | `detect_drift` | Read-only. Whether the repo's pulled files moved, whether Flash moved, and which token values changed |
73
+ | `push_to_web` | Proposes the changed token values to Flash as one change set, reviewed on the Sync page |
74
+
75
+ `push_to_web` reads the `design-tokens.json` the pull wrote, compares it
76
+ with the design system as it is now, and proposes value changes to tokens
77
+ Flash already has. Nothing is applied until someone with edit rights says
78
+ yes. A token added, deleted or re-aliased in the file is flagged rather than
79
+ sent: create, remove and re-point tokens in Flash, then pull.
80
+
81
+ It is a dry run without `confirm: true`, and it refuses to push while Flash
82
+ is ahead of `genome/genome.lock`, because a value left over from the last
83
+ pull would otherwise look like an edit and undo someone's change. Pull,
84
+ re-apply your edits, then push.
85
+
86
+ `AGENTS.md` is written once and then left alone however far it drifts: it is
87
+ where a team puts its own instructions. The Cursor rule is Genome's to keep
88
+ current, because a stale rule file is worse than none.
89
+
90
+ ## Asking the graph
91
+
92
+ With `FLASH_GENOME_TOKEN` set, these answer from the design system itself, with
93
+ the same walk and the same answers as the hosted server's tools of the same
94
+ name. No linked repo needed.
95
+
96
+ | Tool | Args | What it answers |
97
+ | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
98
+ | `get_impact` | `token` | What breaks if this token changes: tokens that resolve through it, and the components and modules that use any of them |
99
+ | `get_relations` | `token?` | A token's direct edges, or every alias edge, binding and module part |
100
+ | `list_modules` | - | Every module, its part count, components and bindings |
101
+ | `get_module` | `module` | One module, parts resolved to components |
102
+
103
+ ## Tools
104
+
105
+ | Tool | Args | Description |
106
+ | --------------------------- | ------------------- | ---------------------------------------------------------------- |
107
+ | `get_tokens` | `category?` | Read tokens from the local token file. Read-only |
108
+ | `list_components` | `category?` | List components from `components.json` |
109
+ | `get_component` | `name` | One component spec |
110
+ | `get_brand_dna` | - | Brand DNA from a sibling file or `tokens['dsm-brand-dna']` |
111
+ | `suggest_token` | `context` | Nearest-token suggestions for hex/px in a snippet. Deterministic |
112
+ | `apply_token_patch` | `patch`, `confirm?` | Upsert/remove tokens. Dry-run unless `confirm: true` |
113
+ | `generate_component_prompt` | `name` | Handoff prompt for a component plus its tokens |
114
+ | `check_violations` | `file` | Lint a source file for hardcoded colors / arbitrary Tailwind |
115
+ | `api_health` | - | `GET {api}/health` against a Flash DSM backend |
116
+ | `list_design_systems` | - | List your systems from a Flash DSM backend (needs a token) |
117
+
118
+ Writes are guarded: `apply_token_patch` is a dry-run unless you pass
119
+ `confirm: true`, so a curious agent cannot rewrite your tokens by accident.
120
+
121
+ ## CLI
122
+
123
+ ```bash
124
+ flash-genome --tokens ./design-tokens.json
125
+ flash-genome --config ./genome.config.json
126
+ flash-genome --tokens ./design-tokens.json --components ./components.json
127
+ ```
128
+
129
+ | Flag | Env | Default |
130
+ | ---------------- | ----------------------------------------------- | ------------------------------------------------------------- |
131
+ | `--tokens, -t` | - | resolved as above |
132
+ | `--components` | - | sibling `components.json` |
133
+ | `--config, -c` | - | `./genome.config.json` |
134
+ | `--api-url` | `FLASH_GENOME_API_URL`, then `FLASH_DS_API_URL` | this repo's `genome.config.json`, then `https://flashdsm.com` |
135
+ | `--token` | `FLASH_GENOME_TOKEN` | none, and `link` needs it |
136
+ | `--access-token` | `FLASH_DS_ACCESS_TOKEN` | none, deprecated |
137
+
138
+ `link` uses the MCP token. The deprecated web JWT is only still read by
139
+ `api_health` and `list_design_systems`; every other tool reads local files.
140
+ Against a backend on your own machine, pass
141
+ `--api-url http://localhost:8008`.
142
+
143
+ ## Hosted alternative
144
+
145
+ If your design system lives in Flash DSM, you may not need this package at all:
146
+ the app serves a remote MCP endpoint per design system
147
+ (`https://flashdsm.com/api/v1/mcp` with a `flash_mcp_*` token). This package is
148
+ the local-files variant for repos that vendor their tokens.
149
+
150
+ ## Development
151
+
152
+ Source lives in the [Flash DSM Maker](https://github.com/itay1313/Flash-DSM-Maker)
153
+ monorepo under `packages/genome`. `pnpm --filter @flashdsm/genome test`
154
+ runs the tests, `... build` bundles with tsup, `... smoke` checks the built
155
+ output against the fixtures.
156
+
157
+ MIT.