@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/installer.js ADDED
@@ -0,0 +1,632 @@
1
+ /**
2
+ * Volt UI agent setup (@voltui/agent)
3
+ *
4
+ * Configures AI agents to use the Volt UI MCP server and writes the Volt UI context files
5
+ * (skill, rules, snippets) into a project.
6
+ *
7
+ * Usage:
8
+ * npx @voltui/agent interactive
9
+ * npx @voltui/agent claude one agent
10
+ * npx @voltui/agent cursor copilot several agents
11
+ * npx @voltui/agent --all --yes every agent, no prompts
12
+ * npx @voltui/agent claude --dry-run show what would be written
13
+ * npx @voltui/agent claude --uninstall remove what the installer wrote
14
+ *
15
+ * Run `npx @voltui/agent --help` for every flag.
16
+ *
17
+ * Re-running is safe: JSON configs are merged, files shared with the user (rules, instructions) get
18
+ * a delimited block that is replaced in place, and files the installer owns are rewritten.
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+ const readline = require('readline');
26
+ const { DEFAULT_MCP_URL, buildContent } = require('./content');
27
+
28
+ const VERSION = require('./package.json').version;
29
+
30
+ const BLOCK_START =
31
+ '<!-- volt-ui:begin (managed by @voltui/agent — edits inside are overwritten) -->';
32
+ const BLOCK_END = '<!-- volt-ui:end -->';
33
+
34
+ // A block lives inside a file the user also edits, so its markers must be a comment in that file's
35
+ // own syntax: HTML for Markdown rules files, `#` for TOML.
36
+ const MARKERS = {
37
+ html: { start: BLOCK_START, end: BLOCK_END },
38
+ hash: {
39
+ start: '# volt-ui:begin (managed by @voltui/agent — edits inside are overwritten)',
40
+ end: '# volt-ui:end',
41
+ },
42
+ };
43
+ const markersOf = spec => MARKERS[spec.style ?? 'html'];
44
+
45
+ // ---------------------------------------------------------------------------
46
+ // Agent plans
47
+ //
48
+ // An agent is a list of files. `kind` decides how an existing file is treated:
49
+ // json merged into the existing JSON (the user's other keys survive)
50
+ // block a delimited block inside a file the user also edits (`style`: html | hash comment markers)
51
+ // owned a file that is entirely Volt's (rewritten each run, deleted on uninstall)
52
+ // ---------------------------------------------------------------------------
53
+
54
+ function buildAgents(mcpUrl) {
55
+ const { CURSOR_RULES, COPILOT_INSTRUCTIONS, WINDSURF_RULES, VOLT_UI_SKILLS, VSCODE_SNIPPETS } =
56
+ buildContent(mcpUrl);
57
+ // One owned file per skill, in the directory the agent scans: .claude/skills/<name>/ or
58
+ // .agents/skills/<name>/. The skills are the full playbooks; agents that cannot load them get
59
+ // the same digests in a rules block instead.
60
+ const skillFiles = dir =>
61
+ Object.entries(VOLT_UI_SKILLS).map(([name, content]) => ({
62
+ path: `${dir}/${name}/SKILL.md`,
63
+ kind: 'owned',
64
+ content,
65
+ }));
66
+ // Cursor / Windsurf accept a bare `url` entry; Claude Code's `.mcp.json` and VS Code's
67
+ // `.vscode/mcp.json` use the `http` transport type.
68
+ const urlEntry = { type: 'url', url: mcpUrl };
69
+ const httpEntry = { type: 'http', url: mcpUrl };
70
+ const snippets = {
71
+ path: '.vscode/volt-snippets.code-snippets',
72
+ kind: 'owned',
73
+ content: JSON.stringify(VSCODE_SNIPPETS, null, 2) + '\n',
74
+ };
75
+
76
+ return {
77
+ claude: {
78
+ label: 'Claude Code',
79
+ files: [
80
+ {
81
+ path: '.mcp.json',
82
+ kind: 'json',
83
+ content: { mcpServers: { 'volt-ui': httpEntry } },
84
+ owns: ['mcpServers', 'volt-ui'],
85
+ },
86
+ ...skillFiles('.claude/skills'),
87
+ ],
88
+ notes: [
89
+ 'Restart Claude Code for the MCP server and skills to load.',
90
+ 'Claude Desktop: remote MCP servers are added via Settings -> Connectors, not by editing claude_desktop_config.json.',
91
+ ],
92
+ },
93
+ cursor: {
94
+ label: 'Cursor',
95
+ files: [
96
+ {
97
+ path: '.cursor/mcp.json',
98
+ kind: 'json',
99
+ content: { mcpServers: { 'volt-ui': urlEntry } },
100
+ owns: ['mcpServers', 'volt-ui'],
101
+ },
102
+ { path: '.cursorrules', kind: 'block', content: CURSOR_RULES },
103
+ ],
104
+ notes: [
105
+ 'Restart Cursor for MCP changes to take effect.',
106
+ 'Cursor reads a rules file, not skills: .cursorrules carries the digests of the Volt skills.',
107
+ ],
108
+ },
109
+ windsurf: {
110
+ label: 'Windsurf',
111
+ files: [
112
+ {
113
+ path: '.codeium/windsurf/mcp_config.json',
114
+ kind: 'json',
115
+ content: { mcpServers: { 'volt-ui': urlEntry } },
116
+ owns: ['mcpServers', 'volt-ui'],
117
+ },
118
+ { path: '.windsurfrules', kind: 'block', content: WINDSURF_RULES },
119
+ ],
120
+ notes: [
121
+ 'Restart Windsurf for MCP changes to take effect.',
122
+ 'Windsurf reads a rules file, not skills: .windsurfrules carries the digests of the Volt skills.',
123
+ ],
124
+ },
125
+ copilot: {
126
+ label: 'GitHub Copilot (VS Code)',
127
+ files: [
128
+ {
129
+ path: '.vscode/mcp.json',
130
+ kind: 'json',
131
+ content: { servers: { 'volt-ui': httpEntry } },
132
+ owns: ['servers', 'volt-ui'],
133
+ },
134
+ { path: '.github/copilot-instructions.md', kind: 'block', content: COPILOT_INSTRUCTIONS },
135
+ snippets,
136
+ ],
137
+ notes: [
138
+ 'Reload the VS Code window; start the volt-ui server from the MCP view if prompted.',
139
+ 'The instructions file gives Copilot Chat context even where MCP is unavailable.',
140
+ ],
141
+ },
142
+ codex: {
143
+ label: 'OpenAI Codex',
144
+ files: [
145
+ {
146
+ path: '.codex/config.toml',
147
+ kind: 'block',
148
+ style: 'hash',
149
+ content: `[mcp_servers.volt-ui]\nurl = "${mcpUrl}"`,
150
+ unlessPresent: /^\s*\[mcp_servers\.(?:"volt-ui"|volt-ui)\]/m,
151
+ },
152
+ ...skillFiles('.agents/skills'),
153
+ ],
154
+ notes: [
155
+ 'Codex reads .codex/config.toml only for projects you have marked as trusted.',
156
+ 'Restart Codex for the MCP server and skills to load.',
157
+ ],
158
+ },
159
+ gemini: {
160
+ label: 'Gemini CLI',
161
+ files: [
162
+ {
163
+ path: '.gemini/settings.json',
164
+ kind: 'json',
165
+ content: { mcpServers: { 'volt-ui': { httpUrl: mcpUrl } } },
166
+ owns: ['mcpServers', 'volt-ui'],
167
+ },
168
+ { path: 'GEMINI.md', kind: 'block', content: COPILOT_INSTRUCTIONS },
169
+ ],
170
+ notes: [
171
+ 'Restart Gemini CLI; `/mcp` lists the connected servers.',
172
+ 'GEMINI.md carries the digests of the Volt skills (Gemini CLI is given a rules block, not skills).',
173
+ ],
174
+ },
175
+ opencode: {
176
+ label: 'OpenCode',
177
+ files: [
178
+ {
179
+ path: 'opencode.json',
180
+ kind: 'json',
181
+ content: {
182
+ $schema: 'https://opencode.ai/config.json',
183
+ mcp: { 'volt-ui': { type: 'remote', url: mcpUrl, enabled: true } },
184
+ },
185
+ owns: ['mcp', 'volt-ui'],
186
+ },
187
+ ...skillFiles('.agents/skills'),
188
+ ],
189
+ notes: ['Restart OpenCode for the MCP server and skills to load.'],
190
+ },
191
+ vscode: {
192
+ label: 'VS Code (snippets)',
193
+ files: [snippets],
194
+ notes: [
195
+ 'Type "volt-button", "volt-card", etc. and press Tab to expand.',
196
+ 'Reload the VS Code window to activate snippets.',
197
+ ],
198
+ },
199
+ };
200
+ }
201
+
202
+ // ---------------------------------------------------------------------------
203
+ // File operations — each returns a short status string and honours `dryRun`
204
+ // ---------------------------------------------------------------------------
205
+
206
+ function readIfExists(file) {
207
+ try {
208
+ return fs.readFileSync(file, 'utf-8');
209
+ } catch (err) {
210
+ if (err.code === 'ENOENT') return null;
211
+ throw err;
212
+ }
213
+ }
214
+
215
+ function write(file, text, dryRun) {
216
+ if (dryRun) return;
217
+ fs.mkdirSync(path.dirname(file), { recursive: true });
218
+ fs.writeFileSync(file, text);
219
+ }
220
+
221
+ function deepMerge(target, source) {
222
+ const out = { ...target };
223
+ for (const [key, value] of Object.entries(source)) {
224
+ const current = out[key];
225
+ out[key] =
226
+ value &&
227
+ typeof value === 'object' &&
228
+ !Array.isArray(value) &&
229
+ current &&
230
+ typeof current === 'object'
231
+ ? deepMerge(current, value)
232
+ : value;
233
+ }
234
+ return out;
235
+ }
236
+
237
+ function parseJsonStrict(file, text) {
238
+ try {
239
+ return JSON.parse(text);
240
+ } catch {
241
+ // A config the user wrote by hand (comments, trailing commas) must never be overwritten.
242
+ throw new Error(
243
+ `${file} is not valid JSON, so it was left untouched. Fix or remove it, then re-run.`
244
+ );
245
+ }
246
+ }
247
+
248
+ function wrapBlock(content, { start, end }) {
249
+ return `${start}\n${content.trim()}\n${end}\n`;
250
+ }
251
+
252
+ function blockPattern({ start, end }) {
253
+ const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
254
+ return new RegExp(`${esc(start)}[\\s\\S]*?${esc(end)}\\n?`);
255
+ }
256
+
257
+ function install(file, spec, dryRun) {
258
+ const existing = readIfExists(file);
259
+
260
+ if (spec.kind === 'json') {
261
+ const merged =
262
+ existing === null ? spec.content : deepMerge(parseJsonStrict(file, existing), spec.content);
263
+ const next = JSON.stringify(merged, null, 2) + '\n';
264
+ if (existing === next) return 'unchanged';
265
+ write(file, next, dryRun);
266
+ return existing === null ? 'created' : 'updated';
267
+ }
268
+
269
+ if (spec.kind === 'block') {
270
+ const markers = markersOf(spec);
271
+ const block = wrapBlock(spec.content, markers);
272
+ let next;
273
+ if (existing === null) next = block;
274
+ else if (blockPattern(markers).test(existing)) {
275
+ next = existing.replace(blockPattern(markers), () => block);
276
+ } else if (spec.unlessPresent?.test(existing)) {
277
+ // The user already configures this by hand; a second copy would be a duplicate TOML table.
278
+ return 'kept';
279
+ } else next = existing.replace(/\s*$/, '\n\n') + block;
280
+ if (existing === next) return 'unchanged';
281
+ write(file, next, dryRun);
282
+ return existing === null ? 'created' : 'updated';
283
+ }
284
+
285
+ // owned
286
+ if (existing === spec.content) return 'unchanged';
287
+ write(file, spec.content, dryRun);
288
+ return existing === null ? 'created' : 'updated';
289
+ }
290
+
291
+ function uninstall(file, spec, dryRun) {
292
+ const existing = readIfExists(file);
293
+ if (existing === null) return 'absent';
294
+
295
+ if (spec.kind === 'json') {
296
+ const json = parseJsonStrict(file, existing);
297
+ const [group, key] = spec.owns;
298
+ if (!json[group] || !(key in json[group])) return 'absent';
299
+ delete json[group][key];
300
+ if (!Object.keys(json[group]).length) delete json[group];
301
+ if (!dryRun) {
302
+ // A lone `$schema` is what this installer wrote into a file it created; nothing of the user's.
303
+ const left = Object.keys(json).filter(k => k !== '$schema');
304
+ if (left.length) write(file, JSON.stringify(json, null, 2) + '\n', false);
305
+ else fs.rmSync(file);
306
+ }
307
+ return 'removed';
308
+ }
309
+
310
+ if (spec.kind === 'block') {
311
+ const markers = markersOf(spec);
312
+ if (!blockPattern(markers).test(existing)) return 'absent';
313
+ const next = existing
314
+ .replace(blockPattern(markers), '')
315
+ .replace(/\n{3,}/g, '\n\n')
316
+ .trim();
317
+ if (!dryRun) {
318
+ if (next) write(file, next + '\n', false);
319
+ else fs.rmSync(file);
320
+ }
321
+ return 'removed';
322
+ }
323
+
324
+ if (!dryRun) fs.rmSync(file);
325
+ return 'removed';
326
+ }
327
+
328
+ // ---------------------------------------------------------------------------
329
+ // Arguments
330
+ // ---------------------------------------------------------------------------
331
+
332
+ const HELP = `Volt UI agent setup (@voltui/agent ${VERSION})
333
+
334
+ Usage: npx @voltui/agent [agent...] [options]
335
+ npx @voltui/agent doctor [agent...] [options]
336
+
337
+ Agents: claude, cursor, windsurf, copilot, codex, gemini, opencode, vscode
338
+ With no agent and no --all, you are asked which to set up.
339
+
340
+ doctor checks what is installed: files up to date, and the MCP endpoint answering.
341
+ With no agent it checks every agent that has files in the project.
342
+
343
+ Options:
344
+ --all set up every agent
345
+ --dir <path> project directory (default: current directory)
346
+ --url <url> MCP endpoint to write (default: ${DEFAULT_MCP_URL})
347
+ --dry-run print what would change, write nothing
348
+ --offline doctor: skip the MCP endpoint check
349
+ --uninstall remove what this installer wrote (your other config is kept)
350
+ -y, --yes never prompt; with no agent given, set up every agent
351
+ -v, --version print the version
352
+ -h, --help print this help
353
+
354
+ Exit codes: 0 ok · 1 failed (doctor: a problem was found) · 2 bad usage`;
355
+
356
+ class UsageError extends Error {}
357
+
358
+ function parseArgs(argv, agentKeys) {
359
+ const opts = {
360
+ command: 'setup',
361
+ offline: false,
362
+ agents: [],
363
+ all: false,
364
+ dir: null,
365
+ url: DEFAULT_MCP_URL,
366
+ dryRun: false,
367
+ uninstall: false,
368
+ yes: false,
369
+ help: false,
370
+ version: false,
371
+ };
372
+ const value = (i, flag) => {
373
+ if (i + 1 >= argv.length || argv[i + 1].startsWith('-')) {
374
+ throw new UsageError(`${flag} needs a value.`);
375
+ }
376
+ return argv[i + 1];
377
+ };
378
+
379
+ for (let i = 0; i < argv.length; i++) {
380
+ const arg = argv[i];
381
+ const eq = arg.startsWith('--') ? arg.indexOf('=') : -1;
382
+ const flag = eq === -1 ? arg : arg.slice(0, eq);
383
+ const inline = eq === -1 ? null : arg.slice(eq + 1);
384
+ const next = name => {
385
+ if (inline !== null) return inline;
386
+ const v = value(i, name);
387
+ i++;
388
+ return v;
389
+ };
390
+
391
+ if (flag === '--all') opts.all = true;
392
+ else if (flag === '--dry-run') opts.dryRun = true;
393
+ else if (flag === '--uninstall') opts.uninstall = true;
394
+ else if (flag === '--offline') opts.offline = true;
395
+ else if (flag === '-y' || flag === '--yes') opts.yes = true;
396
+ else if (flag === '-h' || flag === '--help') opts.help = true;
397
+ else if (flag === '-v' || flag === '--version') opts.version = true;
398
+ else if (flag === '--dir') opts.dir = next('--dir');
399
+ else if (flag === '--url') opts.url = next('--url');
400
+ else if (arg.startsWith('-')) throw new UsageError(`Unknown option: ${arg}`);
401
+ else if (arg === 'doctor' && opts.command === 'setup' && !opts.agents.length)
402
+ opts.command = 'doctor';
403
+ else if (agentKeys.includes(arg)) opts.agents.push(arg);
404
+ else throw new UsageError(`Unknown agent: ${arg}. Available: ${agentKeys.join(', ')}.`);
405
+ }
406
+
407
+ if (opts.all && opts.agents.length) {
408
+ throw new UsageError('Pass either agent names or --all, not both.');
409
+ }
410
+ try {
411
+ const u = new URL(opts.url);
412
+ if (u.protocol !== 'https:' && u.protocol !== 'http:') throw new Error();
413
+ } catch {
414
+ throw new UsageError(`--url must be an http(s) URL, got: ${opts.url}`);
415
+ }
416
+ if (opts.command === 'doctor' && (opts.uninstall || opts.dryRun)) {
417
+ throw new UsageError('doctor only reads; --uninstall and --dry-run do not apply to it.');
418
+ }
419
+ opts.agents = [...new Set(opts.agents)];
420
+ return opts;
421
+ }
422
+
423
+ // ---------------------------------------------------------------------------
424
+ // Interactive prompts
425
+ // ---------------------------------------------------------------------------
426
+
427
+ const ask = (rl, question) => new Promise(resolve => rl.question(question, resolve));
428
+
429
+ async function promptAgents(rl, agents, out) {
430
+ const keys = Object.keys(agents);
431
+ out.log('\nAvailable agents:\n');
432
+ keys.forEach((key, i) => out.log(` ${i + 1}. ${agents[key].label} (${key})`));
433
+ out.log(' a. All of the above\n');
434
+
435
+ const answer = (
436
+ await ask(rl, `Select agent(s) [1-${keys.length}, comma-separated, or "a" for all]: `)
437
+ )
438
+ .trim()
439
+ .toLowerCase();
440
+ if (!answer || answer === 'a' || answer === 'all') return keys;
441
+
442
+ const picked = answer.split(/[,\s]+/).map(token => {
443
+ const n = parseInt(token, 10);
444
+ if (n >= 1 && n <= keys.length) return keys[n - 1];
445
+ if (agents[token]) return token;
446
+ throw new UsageError(`Not an agent: "${token}".`);
447
+ });
448
+ return [...new Set(picked)];
449
+ }
450
+
451
+ // ---------------------------------------------------------------------------
452
+ // doctor
453
+ // ---------------------------------------------------------------------------
454
+
455
+ const FILE_STATE = {
456
+ unchanged: 'ok',
457
+ kept: 'ok (your own entry)',
458
+ updated: 'outdated',
459
+ created: 'missing',
460
+ };
461
+
462
+ /** Ask the endpoint for an MCP `initialize`, the way a real client does. */
463
+ async function pingEndpoint(url, fetchImpl) {
464
+ const response = await fetchImpl(url, {
465
+ method: 'POST',
466
+ headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
467
+ body: JSON.stringify({
468
+ jsonrpc: '2.0',
469
+ id: 1,
470
+ method: 'initialize',
471
+ params: {
472
+ protocolVersion: '2025-03-26',
473
+ capabilities: {},
474
+ clientInfo: { name: '@voltui/agent doctor', version: VERSION },
475
+ },
476
+ }),
477
+ signal: AbortSignal.timeout(10_000),
478
+ });
479
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
480
+ const json = await response.json();
481
+ const server = json?.result?.serverInfo;
482
+ if (!server) throw new Error(json?.error?.message ?? 'not an MCP initialize response');
483
+ return `${server.name} ${server.version}`;
484
+ }
485
+
486
+ async function doctor({ agents, selected, projectDir, opts, out, fetchImpl }) {
487
+ out.log(`Checking: ${projectDir}`);
488
+ let problems = 0;
489
+
490
+ const keys = selected.length
491
+ ? selected
492
+ : Object.keys(agents).filter(key =>
493
+ agents[key].files.some(spec => fs.existsSync(path.join(projectDir, spec.path)))
494
+ );
495
+ if (!keys.length) {
496
+ out.log('\nNo Volt UI agent files found here. Set one up with: npx @voltui/agent <agent>');
497
+ return 1;
498
+ }
499
+
500
+ for (const key of keys) {
501
+ out.log(`\n${agents[key].label}`);
502
+ for (const spec of agents[key].files) {
503
+ let state;
504
+ try {
505
+ state = FILE_STATE[install(path.join(projectDir, spec.path), spec, true)];
506
+ } catch (err) {
507
+ state = `invalid — ${err.message}`;
508
+ }
509
+ if (!state.startsWith('ok')) problems++;
510
+ out.log(` ${state.padEnd(10)} ${spec.path}`);
511
+ }
512
+ }
513
+
514
+ if (!opts.offline) {
515
+ out.log(`\nMCP endpoint: ${opts.url}`);
516
+ try {
517
+ out.log(` ok ${await pingEndpoint(opts.url, fetchImpl)}`);
518
+ } catch (err) {
519
+ problems++;
520
+ out.log(` failed ${err.message}`);
521
+ }
522
+ }
523
+
524
+ if (problems) {
525
+ out.log(`\n${problems} problem(s). Re-run \`npx @voltui/agent <agent>\` to repair the files.`);
526
+ return 1;
527
+ }
528
+ out.log('\nAll good.');
529
+ return 0;
530
+ }
531
+
532
+ // ---------------------------------------------------------------------------
533
+ // Entry point
534
+ // ---------------------------------------------------------------------------
535
+
536
+ /**
537
+ * @param {string[]} argv arguments after the program name
538
+ * @param {{ cwd?: string, stdin?: NodeJS.ReadableStream, stdout?: NodeJS.WritableStream, isTTY?: boolean }} [env] injectable for tests
539
+ * @returns {Promise<number>} the exit code
540
+ */
541
+ async function run(argv, env = {}) {
542
+ const cwd = env.cwd ?? process.cwd();
543
+ const out = { log: msg => console.log(msg) };
544
+ const isTTY = env.isTTY ?? Boolean(process.stdin.isTTY);
545
+
546
+ try {
547
+ const baseAgents = buildAgents(DEFAULT_MCP_URL);
548
+ const opts = parseArgs(argv, Object.keys(baseAgents));
549
+
550
+ if (opts.help || opts.version) {
551
+ out.log(opts.help ? HELP : VERSION);
552
+ return 0;
553
+ }
554
+
555
+ const agents = buildAgents(opts.url);
556
+ let selected = opts.all ? Object.keys(agents) : opts.agents;
557
+ let projectDir = opts.dir ? path.resolve(cwd, opts.dir) : cwd;
558
+
559
+ if (opts.command === 'doctor') {
560
+ if (!fs.existsSync(projectDir) || !fs.statSync(projectDir).isDirectory()) {
561
+ throw new UsageError(`Project directory does not exist: ${projectDir}`);
562
+ }
563
+ return await doctor({
564
+ agents,
565
+ selected,
566
+ projectDir,
567
+ opts,
568
+ out,
569
+ fetchImpl: env.fetch ?? fetch,
570
+ });
571
+ }
572
+
573
+ if (!selected.length) {
574
+ if (opts.yes) selected = Object.keys(agents);
575
+ else if (!isTTY) {
576
+ throw new UsageError('No agent given and no terminal to ask on. Pass an agent or --all.');
577
+ } else {
578
+ const rl = readline.createInterface({
579
+ input: env.stdin ?? process.stdin,
580
+ output: env.stdout ?? process.stdout,
581
+ });
582
+ try {
583
+ selected = await promptAgents(rl, agents, out);
584
+ if (!opts.dir) {
585
+ const dir = (await ask(rl, `\nProject directory [${projectDir}]: `)).trim();
586
+ if (dir) projectDir = path.resolve(cwd, dir);
587
+ }
588
+ } finally {
589
+ rl.close();
590
+ }
591
+ }
592
+ }
593
+
594
+ if (!fs.existsSync(projectDir) || !fs.statSync(projectDir).isDirectory()) {
595
+ throw new UsageError(`Project directory does not exist: ${projectDir}`);
596
+ }
597
+
598
+ const verb = opts.uninstall ? 'Removing from' : 'Setting up';
599
+ out.log(`${verb}: ${projectDir}${opts.dryRun ? ' (dry run — nothing is written)' : ''}`);
600
+ if (!opts.uninstall) out.log(`MCP endpoint: ${opts.url}`);
601
+
602
+ for (const key of selected) {
603
+ const agent = agents[key];
604
+ out.log(`\n${agent.label}`);
605
+ for (const spec of agent.files) {
606
+ const file = path.join(projectDir, spec.path);
607
+ const status = opts.uninstall
608
+ ? uninstall(file, spec, opts.dryRun)
609
+ : install(file, spec, opts.dryRun);
610
+ out.log(` ${status.padEnd(9)} ${spec.path}`);
611
+ }
612
+ if (!opts.uninstall) agent.notes.forEach(note => out.log(` → ${note}`));
613
+ }
614
+
615
+ if (!opts.uninstall && !opts.dryRun) {
616
+ out.log('\nDone. Next steps:');
617
+ out.log(' npx @voltui/cli init scaffold the ui/ folder');
618
+ out.log(' npx @voltui/cli add button add a component');
619
+ out.log(' npx @voltui/cli list list every component');
620
+ }
621
+ return 0;
622
+ } catch (err) {
623
+ if (err instanceof UsageError) {
624
+ console.error(`Error: ${err.message}\n\nRun with --help for usage.`);
625
+ return 2;
626
+ }
627
+ console.error(`Error: ${err.message}`);
628
+ return 1;
629
+ }
630
+ }
631
+
632
+ module.exports = { run, buildAgents, parseArgs, BLOCK_START, BLOCK_END };
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@voltui/agent",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.6.0",
4
+ "description": "Set up Volt UI for AI coding agents: the MCP server, single-responsibility skills and rules for Claude Code, Codex, OpenCode, Cursor, Windsurf, Gemini CLI and GitHub Copilot",
5
+ "homepage": "https://voltui.dev/docs/ai-mcp",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Andersseen/volt-ui.git",
9
+ "directory": "cli/agent"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/Andersseen/volt-ui/issues"
13
+ },
14
+ "bin": {
15
+ "volt-ui-agent": "setup-agent.js"
16
+ },
17
+ "files": [
18
+ "setup-agent.js",
19
+ "installer.js",
20
+ "content.js",
21
+ "skills.js",
22
+ "skills",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "keywords": [
27
+ "mcp",
28
+ "model-context-protocol",
29
+ "angular",
30
+ "volt-ui",
31
+ "claude",
32
+ "cursor",
33
+ "windsurf",
34
+ "copilot",
35
+ "ai",
36
+ "skills",
37
+ "agent",
38
+ "angular-components"
39
+ ],
40
+ "license": "MIT",
41
+ "engines": {
42
+ "node": ">=20"
43
+ }
44
+ }
package/setup-agent.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ /** Entry point of `npx @voltui/agent`. The installer itself lives in installer.js. */
4
+
5
+ 'use strict';
6
+
7
+ require('./installer')
8
+ .run(process.argv.slice(2))
9
+ .then(code => process.exit(code));