@voltui/agent 0.0.0-stage → 0.6.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) 2024 Volt UI Contributors
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 CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # @voltui/agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Connects your AI coding agent to the [Volt UI](https://voltui.dev) MCP server and
4
+ installs the Volt UI context it needs (skills, rules, snippets) into your project.
5
+
6
+ **The MCP server says what Volt contains; the skills teach your agent when and how to use it.**
7
+ Exact selectors, inputs and status come from the server (`find_components`, `get_component`,
8
+ `get_usage_example`); the skills are short playbooks that never copy that API.
9
+
10
+ ```bash
11
+ npx @voltui/agent # interactive
12
+ npx @voltui/agent claude # one agent
13
+ npx @voltui/agent cursor copilot # several
14
+ npx @voltui/agent --all --yes # every agent, no prompts
15
+ npx @voltui/agent doctor # check what is installed
16
+ ```
17
+
18
+ Requires Node 20 or newer. No dependencies.
19
+
20
+ ## What each agent gets
21
+
22
+ | Agent | Files written |
23
+ | ---------- | ------------------------------------------------------------------------------------------------------ |
24
+ | `claude` | `.mcp.json` (`http` transport), `.claude/skills/<skill>/SKILL.md` for each skill |
25
+ | `cursor` | `.cursor/mcp.json`, `.cursorrules` (a block) |
26
+ | `windsurf` | `.codeium/windsurf/mcp_config.json`, `.windsurfrules` (a block) |
27
+ | `copilot` | `.vscode/mcp.json`, `.github/copilot-instructions.md` (a block), `.vscode/volt-snippets.code-snippets` |
28
+ | `codex` | `.codex/config.toml` (a `# volt-ui:begin` block), `.agents/skills/<skill>/SKILL.md` |
29
+ | `gemini` | `.gemini/settings.json` (`httpUrl`), `GEMINI.md` (a block) |
30
+ | `opencode` | `opencode.json` (`mcp`, remote), `.agents/skills/<skill>/SKILL.md` |
31
+ | `vscode` | `.vscode/volt-snippets.code-snippets` |
32
+
33
+ ## The skills
34
+
35
+ | Skill | Responsibility |
36
+ | ----------------------------- | -------------------------------------------------------------------------------- |
37
+ | `volt-ui` | Entry point: Volt-first policy, MCP is the source of facts, routes to the rest |
38
+ | `volt-ui-adoption` | Reuse an existing atom before hand-building equivalent UI |
39
+ | `volt-ui-component-selection` | Which component for which responsibility (Button vs link, Dialog vs Drawer, …) |
40
+ | `volt-ui-forms` | Forms, validation, Combobox (local and server-backed), disabled vs aria-disabled |
41
+ | `volt-ui-overlays` | Dialog, Drawer, Popover, Tooltip, Dropdown Menu, Toast: choice, focus, dismissal |
42
+ | `volt-ui-styling` | Tokens, presets, the `class` contract: customise without rebuilding |
43
+ | `volt-ui-distribution` | Package vs copy-and-own, the CLI, matching selectors and imports |
44
+
45
+ Only Claude Code, Codex and OpenCode discover skills, so they get the full set. Cursor, Windsurf,
46
+ Copilot and Gemini CLI read a rules file: they get a short block holding the digest of each skill
47
+ instead of the playbooks themselves. Every skill and every digest comes from the same file.
48
+
49
+ Claude Desktop is not configured by files: add the server under Settings → Connectors.
50
+
51
+ ## It will not clobber your config
52
+
53
+ Running it again is safe, and `--dry-run` shows what would change first.
54
+
55
+ - **JSON configs** are merged: your other servers and keys stay. A file that is not valid JSON
56
+ (comments, trailing commas) is left untouched and the run fails with a message.
57
+ - **`.cursorrules`, `.windsurfrules`, `copilot-instructions.md`, `GEMINI.md`, `.codex/config.toml`** get one block between
58
+ `<!-- volt-ui:begin … -->` and `<!-- volt-ui:end -->`. Your own text outside it is never touched;
59
+ the block is replaced in place on re-runs, so upgrading the package updates it.
60
+ - **A `[mcp_servers.volt-ui]` table you wrote in `.codex/config.toml`** is left alone (`kept`); a
61
+ second copy would be invalid TOML.
62
+ - **Skill and snippets files** belong entirely to Volt UI and are rewritten. Skills you wrote yourself,
63
+ in other directories under `.claude/skills` or `.agents/skills`, are never touched.
64
+
65
+ ## Options
66
+
67
+ | Option | Meaning |
68
+ | ---------------------------------- | ------------------------------------------------------------- |
69
+ | `--all` | set up every agent |
70
+ | `--dir <path>` | project directory (default: the current directory) |
71
+ | `--url <url>` | MCP endpoint to write (default: `https://voltui.dev/api/mcp`) |
72
+ | `--dry-run` | print what would change, write nothing |
73
+ | `--uninstall` | remove what this installer wrote; your other config is kept |
74
+ | `-y`, `--yes` | never prompt; with no agent given, set up every agent |
75
+ | `-v`, `--version` / `-h`, `--help` | |
76
+
77
+ Without a terminal (CI, scripts) and without an agent or `--all`, it fails instead of waiting for input.
78
+
79
+ Exit codes: `0` ok · `1` failed (for example an unparseable config) · `2` bad usage.
80
+
81
+ ## Checking it: `doctor`
82
+
83
+ ```bash
84
+ npx @voltui/agent doctor # every agent that has files in this project
85
+ npx @voltui/agent doctor claude # one agent
86
+ npx @voltui/agent doctor --offline # files only, skip the network check
87
+ ```
88
+
89
+ For each file it reports `ok`, `outdated` (differs from what this version of the package would
90
+ write — re-run the installer to update it), `missing` or `invalid`, then sends the MCP endpoint an
91
+ `initialize` request the way a client does. It only reads. Exit `0` when everything is fine, `1`
92
+ when a problem was found.
93
+
94
+ ## Removing it
95
+
96
+ ```bash
97
+ npx @voltui/agent claude --uninstall
98
+ ```
99
+
100
+ ## Links
101
+
102
+ [Documentation](https://voltui.dev/docs/ai-mcp) ·
103
+ [Source](https://github.com/Andersseen/volt-ui/tree/main/cli/agent) · MIT
package/content.js ADDED
@@ -0,0 +1,265 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Content the @voltui/agent installer writes into a consumer project: the rules/instructions block
5
+ * for agents that do not load skills, and the VS Code snippets. The skills themselves are the files
6
+ * under ./skills (see ./skills.js); the rules block is built from them, never written separately.
7
+ *
8
+ * Single source for both the installer (setup-agent.js) and the hosted /api/mcp/setup endpoint, which
9
+ * reads a generated copy (`pnpm generate:mcp-content`). Edit here, never in the generated file.
10
+ */
11
+
12
+ const { routingBlock, loadSkills } = require('./skills');
13
+
14
+ const DEFAULT_MCP_URL = 'https://voltui.dev/api/mcp';
15
+
16
+ /** @param {string} MCP_URL endpoint written into the rules/instructions */
17
+ function buildContent(MCP_URL) {
18
+ // One block for every rules-file agent (Cursor, Copilot, Gemini, Windsurf): short, because the
19
+ // facts are in the MCP server and the playbooks are digests of the skills.
20
+ const RULES = routingBlock(MCP_URL);
21
+ const CURSOR_RULES = RULES;
22
+ const COPILOT_INSTRUCTIONS = RULES;
23
+ const WINDSURF_RULES = RULES;
24
+ const VOLT_UI_SKILLS = loadSkills();
25
+
26
+ const VSCODE_SNIPPETS = {
27
+ 'Volt UI Button': {
28
+ prefix: ['volt-button', 'ui-button'],
29
+ description: 'Volt UI Button component',
30
+ body: [
31
+ '<ui-button variant="${1|solid,outline,ghost,link,destructive|}" size="${2|md,sm,lg,icon|}">${3:Label}</ui-button>',
32
+ ],
33
+ },
34
+ 'Volt UI Card': {
35
+ prefix: ['volt-card', 'ui-card'],
36
+ description: 'Volt UI Card with full structure',
37
+ body: [
38
+ '<ui-card>',
39
+ ' <ui-card-header>',
40
+ ' <ui-card-title>${1:Title}</ui-card-title>',
41
+ ' <ui-card-description>${2:Description}</ui-card-description>',
42
+ ' </ui-card-header>',
43
+ ' <ui-card-content>',
44
+ ' ${3:<!-- Content -->}',
45
+ ' </ui-card-content>',
46
+ ' <ui-card-footer>',
47
+ ' <ui-button variant="outline">${4:Cancel}</ui-button>',
48
+ ' <ui-button>${5:Confirm}</ui-button>',
49
+ ' </ui-card-footer>',
50
+ '</ui-card>',
51
+ ],
52
+ },
53
+ 'Volt UI Form Field': {
54
+ prefix: ['volt-form-field', 'ui-form-field'],
55
+ description: 'Volt UI Form Field with input',
56
+ body: [
57
+ '<ui-form-field>',
58
+ ' <ui-label>${1:Label}</ui-label>',
59
+ ' <ui-input type="${2:text}" placeholder="${3:Enter value}" />',
60
+ ' <ui-hint>${4:Helper text}</ui-hint>',
61
+ '</ui-form-field>',
62
+ ],
63
+ },
64
+ 'Volt UI Tabs': {
65
+ prefix: ['volt-tabs', 'ui-tabs'],
66
+ description: 'Volt UI Tabs component',
67
+ body: [
68
+ '<ui-tabs [(value)]="${1:activeTab}">',
69
+ ' <ui-tabs-list>',
70
+ ' <ui-tabs-trigger value="${2:tab1}">${3:Tab 1}</ui-tabs-trigger>',
71
+ ' <ui-tabs-trigger value="${4:tab2}">${5:Tab 2}</ui-tabs-trigger>',
72
+ ' </ui-tabs-list>',
73
+ ' <ui-tabs-content value="${2:tab1}">${6:Content 1}</ui-tabs-content>',
74
+ ' <ui-tabs-content value="${4:tab2}">${7:Content 2}</ui-tabs-content>',
75
+ '</ui-tabs>',
76
+ ],
77
+ },
78
+ 'Volt UI Select': {
79
+ prefix: ['volt-select', 'ui-select'],
80
+ description: 'Volt UI Select dropdown',
81
+ body: [
82
+ '<ui-select placeholder="${1:Select option}">',
83
+ ' <ui-select-label>${2:Label}</ui-select-label>',
84
+ ' <ui-select-content>',
85
+ ' <ui-select-item value="${3:value1}">${4:Option 1}</ui-select-item>',
86
+ ' <ui-select-item value="${5:value2}">${6:Option 2}</ui-select-item>',
87
+ ' </ui-select-content>',
88
+ '</ui-select>',
89
+ ],
90
+ },
91
+ 'Volt UI Accordion': {
92
+ prefix: ['volt-accordion', 'ui-accordion'],
93
+ description: 'Volt UI Accordion',
94
+ body: [
95
+ '<ui-accordion type="${1|single,multiple|}" [collapsible]="true">',
96
+ ' <ui-accordion-item>',
97
+ ' <ui-accordion-trigger>${2:Question}</ui-accordion-trigger>',
98
+ ' <ui-accordion-content>${3:Answer}</ui-accordion-content>',
99
+ ' </ui-accordion-item>',
100
+ '</ui-accordion>',
101
+ ],
102
+ },
103
+ 'Volt UI Checkbox': {
104
+ prefix: ['volt-checkbox', 'ui-checkbox'],
105
+ description: 'Volt UI Checkbox',
106
+ body: ['<ui-checkbox [(checked)]="${1:checked}">${2:Label}</ui-checkbox>'],
107
+ },
108
+ 'Volt UI Switch': {
109
+ prefix: ['volt-switch', 'ui-switch'],
110
+ description: 'Volt UI Switch',
111
+ body: ['<ui-switch [(checked)]="${1:enabled}">${2:Label}</ui-switch>'],
112
+ },
113
+ 'Volt UI Radio': {
114
+ prefix: ['volt-radio', 'ui-radio'],
115
+ description: 'Volt UI Radio Group',
116
+ body: [
117
+ '<ui-radio-group [(value)]="${1:selectedValue}">',
118
+ ' <ui-radio-item value="${2:option1}">${3:Option 1}</ui-radio-item>',
119
+ ' <ui-radio-item value="${4:option2}">${5:Option 2}</ui-radio-item>',
120
+ '</ui-radio-group>',
121
+ ],
122
+ },
123
+ 'Volt UI Avatar': {
124
+ prefix: ['volt-avatar', 'ui-avatar'],
125
+ description: 'Volt UI Avatar',
126
+ body: [
127
+ '<ui-avatar>',
128
+ ' <img uiAvatarImage [src]="${1:url}" [alt]="${2:User}" />',
129
+ ' <ui-avatar-fallback>${3:JD}</ui-avatar-fallback>',
130
+ '</ui-avatar>',
131
+ ],
132
+ },
133
+ 'Volt UI Tooltip': {
134
+ prefix: ['volt-tooltip', 'ui-tooltip'],
135
+ description: 'Volt UI Tooltip',
136
+ body: [
137
+ '<button uiTooltip [uiTooltip]="tooltipTpl">${1:Hover me}</button>',
138
+ '<ng-template #tooltipTpl>',
139
+ ' <ui-tooltip-content>${2:Tooltip text}</ui-tooltip-content>',
140
+ '</ng-template>',
141
+ ],
142
+ },
143
+ 'Volt UI Badge': {
144
+ prefix: ['volt-badge', 'ui-badge'],
145
+ description: 'Volt UI Badge',
146
+ body: [
147
+ '<ui-badge variant="${1|default,secondary,outline,destructive|}">${2:Label}</ui-badge>',
148
+ ],
149
+ },
150
+ 'Volt UI Dialog': {
151
+ prefix: ['volt-dialog', 'ui-dialog'],
152
+ description: 'Volt UI Dialog',
153
+ body: [
154
+ '<button [uiDialog]="${1:dialogTpl}">${2:Open Dialog}</button>',
155
+ '<ng-template #${1:dialogTpl} let-close="close">',
156
+ ' <div uiDialogOverlay></div>',
157
+ ' <div uiDialogContent>',
158
+ ' <h2 uiDialogTitle>${3:Title}</h2>',
159
+ ' <p uiDialogDescription>${4:Description}</p>',
160
+ ' </div>',
161
+ '</ng-template>',
162
+ ],
163
+ },
164
+ 'Volt UI Popover': {
165
+ prefix: ['volt-popover', 'ui-popover'],
166
+ description: 'Volt UI Popover',
167
+ body: [
168
+ '<button uiPopover [uiPopover]="${1:popoverTpl}">${2:Open}</button>',
169
+ '<ng-template #${1:popoverTpl}>',
170
+ ' <ui-popover-content>${3:Content}</ui-popover-content>',
171
+ '</ng-template>',
172
+ ],
173
+ },
174
+ 'Volt UI Dropdown Menu': {
175
+ prefix: ['volt-dropdown-menu', 'ui-dropdown-menu'],
176
+ description: 'Volt UI Dropdown Menu',
177
+ body: [
178
+ '<button [uiDropdownMenu]="${1:menuTpl}">${2:Menu}</button>',
179
+ '<ng-template #${1:menuTpl}>',
180
+ ' <ui-dropdown-menu>',
181
+ ' <ui-dropdown-menu-item>${3:Item}</ui-dropdown-menu-item>',
182
+ ' </ui-dropdown-menu>',
183
+ '</ng-template>',
184
+ ],
185
+ },
186
+ 'Volt UI Slider': {
187
+ prefix: ['volt-slider', 'ui-slider'],
188
+ description: 'Volt UI Slider',
189
+ body: ['<ui-slider [min]="${1:0}" [max]="${2:100}" [(value)]="${3:value}" />'],
190
+ },
191
+ 'Volt UI Range Slider': {
192
+ prefix: ['volt-range-slider', 'ui-range-slider'],
193
+ description: 'Volt UI Range Slider',
194
+ body: [
195
+ '<ui-range-slider [min]="${1:0}" [max]="${2:100}" [(low)]="${3:low}" [(high)]="${4:high}" />',
196
+ ],
197
+ },
198
+ 'Volt UI Progress': {
199
+ prefix: ['volt-progress', 'ui-progress'],
200
+ description: 'Volt UI Progress',
201
+ body: [
202
+ '<ui-progress [value]="${1:60}" [max]="${2:100}">',
203
+ ' <ui-progress-label>${3:Loading}</ui-progress-label>',
204
+ ' <ui-progress-value>${1:60}%</ui-progress-value>',
205
+ '</ui-progress>',
206
+ ],
207
+ },
208
+ 'Volt UI Skeleton': {
209
+ prefix: ['volt-skeleton', 'ui-skeleton'],
210
+ description: 'Volt UI Skeleton',
211
+ body: [
212
+ '<ui-skeleton variant="${1|text,circle,rectangle|}" width="${2:120px}" height="${3:16px}" />',
213
+ ],
214
+ },
215
+ 'Volt UI Table': {
216
+ prefix: ['volt-table', 'ui-table'],
217
+ description: 'Volt UI Table',
218
+ body: [
219
+ '<ui-table>',
220
+ ' <ui-table-header>',
221
+ ' <ui-table-row>',
222
+ ' <ui-table-head>${1:Column}</ui-table-head>',
223
+ ' </ui-table-row>',
224
+ ' </ui-table-header>',
225
+ ' <ui-table-body>',
226
+ ' <ui-table-row>',
227
+ ' <ui-table-cell>${2:Cell}</ui-table-cell>',
228
+ ' </ui-table-row>',
229
+ ' </ui-table-body>',
230
+ '</ui-table>',
231
+ ],
232
+ },
233
+ 'Volt Theme Provider': {
234
+ prefix: ['volt-theme', 'provide-volt-theme'],
235
+ description: 'Provide Volt theme in app config',
236
+ body: [
237
+ "import { provideVoltTheme } from '@voltui/components';",
238
+ '',
239
+ 'providers: [',
240
+ ' provideVoltTheme({',
241
+ " color: '${1|volt,ember,sage,dusk,glacier|}',",
242
+ " style: '${2|sharp,soft,brutal,ghost,retro|}',",
243
+ ' dark: ${3|false,true|}',
244
+ ' })',
245
+ ']',
246
+ ],
247
+ },
248
+ 'Volt UI Import Button': {
249
+ prefix: ['import-ui-button'],
250
+ description: 'Import Volt UI Button',
251
+ body: ["import { UiButton } from './ui/button';"],
252
+ },
253
+ 'Volt UI Import Card': {
254
+ prefix: ['import-ui-card'],
255
+ description: 'Import Volt UI Card',
256
+ body: [
257
+ "import { UiCard, UiCardHeader, UiCardTitle, UiCardDescription, UiCardContent, UiCardFooter } from './ui/card';",
258
+ ],
259
+ },
260
+ };
261
+
262
+ return { CURSOR_RULES, COPILOT_INSTRUCTIONS, WINDSURF_RULES, VOLT_UI_SKILLS, VSCODE_SNIPPETS };
263
+ }
264
+
265
+ module.exports = { DEFAULT_MCP_URL, buildContent };