@surreal-ui/cli 0.9.0 → 0.10.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 +21 -0
- package/README.md +9 -0
- package/dist/index.js +230 -62
- package/package.json +15 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pixerate
|
|
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
|
@@ -96,6 +96,15 @@ Compares your local component implementation against the upstream registry versi
|
|
|
96
96
|
npx @surreal-ui/cli diff <component> [options]
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
+
### `skills list` / `skills install`
|
|
100
|
+
|
|
101
|
+
Copies the agent skills that ship in `@surreal-ui/catalog` (`surreal-use` and `surreal-author`) into the project, so a coding agent (Claude Code, Cursor and others) finds them. It uses the project's own `@surreal-ui/catalog`, so the skills match the installed version; install that first. Run it again after upgrading: changed files are brought up to date and your own files are left alone.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx @surreal-ui/cli skills install # into .claude/skills
|
|
105
|
+
npx @surreal-ui/cli skills install --dir .agents/skills --skill surreal-use
|
|
106
|
+
```
|
|
107
|
+
|
|
99
108
|
---
|
|
100
109
|
|
|
101
110
|
## ⚙️ Environment Variables
|
package/dist/index.js
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
5
|
+
import pc6 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/add.ts
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import fs4 from "fs";
|
|
9
|
+
import path4 from "path";
|
|
10
10
|
import pc from "picocolors";
|
|
11
11
|
import prompts from "prompts";
|
|
12
12
|
|
|
13
13
|
// src/utils/registry.ts
|
|
14
|
-
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_REGISTRY_URL as PUBLIC_REGISTRY_URL
|
|
16
|
+
} from "@surreal-ui/catalog/registry";
|
|
17
|
+
var DEFAULT_REGISTRY_URL = process.env.SURREAL_REGISTRY_URL || PUBLIC_REGISTRY_URL;
|
|
15
18
|
async function fetchRegistryItem(options) {
|
|
16
19
|
const { componentId, aestheticId, framework = "svelte", registryUrl } = options;
|
|
17
20
|
if (registryUrl) {
|
|
@@ -28,24 +31,12 @@ async function fetchRegistryItem(options) {
|
|
|
28
31
|
} catch {
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
|
-
try {
|
|
32
|
-
const core = await import("@surreal-ui/core");
|
|
33
|
-
if (core?.RegistryService) {
|
|
34
|
-
const localItem = await core.RegistryService.getRegistryItem({
|
|
35
|
-
componentId,
|
|
36
|
-
aestheticId,
|
|
37
|
-
framework
|
|
38
|
-
});
|
|
39
|
-
if (localItem) return localItem;
|
|
40
|
-
}
|
|
41
|
-
} catch {
|
|
42
|
-
}
|
|
43
34
|
if (!registryUrl) {
|
|
44
35
|
try {
|
|
45
36
|
const url = aestheticId ? `${DEFAULT_REGISTRY_URL}/${aestheticId}/${componentId}.json?framework=${framework}` : `${DEFAULT_REGISTRY_URL}/${componentId}.json?framework=${framework}`;
|
|
46
37
|
const res = await fetch(url, {
|
|
47
38
|
headers: { Accept: "application/json" },
|
|
48
|
-
signal: AbortSignal.timeout(
|
|
39
|
+
signal: AbortSignal.timeout(5e3)
|
|
49
40
|
});
|
|
50
41
|
if (res.ok) {
|
|
51
42
|
return await res.json();
|
|
@@ -71,20 +62,12 @@ async function fetchRegistryIndex(options = {}) {
|
|
|
71
62
|
} catch {
|
|
72
63
|
}
|
|
73
64
|
}
|
|
74
|
-
try {
|
|
75
|
-
const core = await import("@surreal-ui/core");
|
|
76
|
-
if (core?.RegistryService) {
|
|
77
|
-
const localIndex = await core.RegistryService.getRegistryIndex(framework);
|
|
78
|
-
if (localIndex && localIndex.length > 0) return localIndex;
|
|
79
|
-
}
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
65
|
if (!registryUrl) {
|
|
83
66
|
try {
|
|
84
67
|
const url = `${DEFAULT_REGISTRY_URL}/index.json?framework=${framework}`;
|
|
85
68
|
const res = await fetch(url, {
|
|
86
69
|
headers: { Accept: "application/json" },
|
|
87
|
-
signal: AbortSignal.timeout(
|
|
70
|
+
signal: AbortSignal.timeout(5e3)
|
|
88
71
|
});
|
|
89
72
|
if (res.ok) {
|
|
90
73
|
return await res.json();
|
|
@@ -214,6 +197,77 @@ function installDependencies(dependencies, options = {}) {
|
|
|
214
197
|
execSync(command, { cwd, stdio: "inherit" });
|
|
215
198
|
}
|
|
216
199
|
|
|
200
|
+
// src/utils/catalog.ts
|
|
201
|
+
import fs3 from "fs";
|
|
202
|
+
import { createRequire } from "module";
|
|
203
|
+
import path3 from "path";
|
|
204
|
+
import {
|
|
205
|
+
AESTHETICS,
|
|
206
|
+
getAesthetic,
|
|
207
|
+
getComponent,
|
|
208
|
+
replacementFor
|
|
209
|
+
} from "@surreal-ui/catalog";
|
|
210
|
+
var SOURCE = {
|
|
211
|
+
react: { file: "react.tsx", ext: "tsx" },
|
|
212
|
+
svelte: { file: "svelte.svelte", ext: "svelte" },
|
|
213
|
+
webcomponent: { file: "element.ts", ext: "ts" }
|
|
214
|
+
};
|
|
215
|
+
function catalogDist() {
|
|
216
|
+
const require2 = createRequire(import.meta.url);
|
|
217
|
+
return path3.join(path3.dirname(require2.resolve("@surreal-ui/catalog/package.json")), "dist");
|
|
218
|
+
}
|
|
219
|
+
function resolveCatalogType(componentId) {
|
|
220
|
+
const direct = getComponent(componentId);
|
|
221
|
+
if (direct && !direct.implements) return { component: direct };
|
|
222
|
+
const pascal = componentId.replace(/(^|-)([a-z0-9])/g, (_, __, c) => c.toUpperCase());
|
|
223
|
+
const old = replacementFor(componentId) ?? replacementFor(pascal);
|
|
224
|
+
const component = old && getComponent(old.type);
|
|
225
|
+
return component ? { component, aesthetic: old.aesthetic } : void 0;
|
|
226
|
+
}
|
|
227
|
+
var CATALOG_AESTHETICS = AESTHETICS.map((a) => a.id);
|
|
228
|
+
function catalogItem(component, framework, aestheticId, dist = catalogDist()) {
|
|
229
|
+
const src = SOURCE[framework];
|
|
230
|
+
const dir = path3.join(dist, "sources", component.id);
|
|
231
|
+
const main = path3.join(dir, src.file);
|
|
232
|
+
if (!fs3.existsSync(main)) return null;
|
|
233
|
+
if (!getAesthetic(aestheticId))
|
|
234
|
+
throw new Error(
|
|
235
|
+
`Unknown aesthetic "${aestheticId}". Available: ${CATALOG_AESTHETICS.join(", ")}`
|
|
236
|
+
);
|
|
237
|
+
const code = fs3.readFileSync(main, "utf8");
|
|
238
|
+
const files = [
|
|
239
|
+
{ path: `${component.export}.${src.ext}`, content: code, type: "registry:ui" }
|
|
240
|
+
];
|
|
241
|
+
const style = path3.join(dir, "style.css");
|
|
242
|
+
if (fs3.existsSync(style))
|
|
243
|
+
files.push({
|
|
244
|
+
path: `${component.id}.css`,
|
|
245
|
+
content: fs3.readFileSync(style, "utf8"),
|
|
246
|
+
type: "registry:ui"
|
|
247
|
+
});
|
|
248
|
+
files.push({
|
|
249
|
+
path: `aesthetic-${aestheticId}.css`,
|
|
250
|
+
content: fs3.readFileSync(path3.join(dist, "aesthetics", `${aestheticId}.css`), "utf8"),
|
|
251
|
+
type: "registry:ui"
|
|
252
|
+
});
|
|
253
|
+
const dependencies = /from ['"]@surreal-ui\/catalog/.test(code) ? ["@surreal-ui/catalog"] : [];
|
|
254
|
+
return {
|
|
255
|
+
name: component.id,
|
|
256
|
+
type: "registry:ui",
|
|
257
|
+
title: component.name,
|
|
258
|
+
description: component.description,
|
|
259
|
+
dependencies,
|
|
260
|
+
files,
|
|
261
|
+
meta: {
|
|
262
|
+
aestheticId,
|
|
263
|
+
componentTypeId: component.id,
|
|
264
|
+
version: "",
|
|
265
|
+
framework,
|
|
266
|
+
symbolName: component.export
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
217
271
|
// src/commands/add.ts
|
|
218
272
|
async function addCommand(componentArg, options = {}) {
|
|
219
273
|
const cwd = options.cwd || process.cwd();
|
|
@@ -242,8 +296,27 @@ async function addCommand(componentArg, options = {}) {
|
|
|
242
296
|
}
|
|
243
297
|
componentId = response.component;
|
|
244
298
|
}
|
|
245
|
-
|
|
246
|
-
|
|
299
|
+
const catalogType = resolveCatalogType(componentArg?.trim() ?? componentId);
|
|
300
|
+
let aestheticId = options.aesthetic?.toLowerCase().trim() || catalogType?.aesthetic || projectConfig?.defaultAesthetic;
|
|
301
|
+
if (catalogType && !aestheticId) {
|
|
302
|
+
if (options.yes) aestheticId = "minimalist";
|
|
303
|
+
else {
|
|
304
|
+
const response = await prompts({
|
|
305
|
+
type: "select",
|
|
306
|
+
name: "aesthetic",
|
|
307
|
+
message: `Choose an aesthetic pack for ${catalogType.component.name}:`,
|
|
308
|
+
choices: CATALOG_AESTHETICS.map((a) => ({ title: a, value: a })),
|
|
309
|
+
initial: Math.max(0, CATALOG_AESTHETICS.indexOf("minimalist"))
|
|
310
|
+
});
|
|
311
|
+
if (!response.aesthetic) {
|
|
312
|
+
console.log(pc.yellow("Operation cancelled."));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
aestheticId = response.aesthetic;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const fromCatalog = catalogType ? catalogItem(catalogType.component, framework, aestheticId) : null;
|
|
319
|
+
if (!fromCatalog && !aestheticId && !options.yes) {
|
|
247
320
|
const index = await fetchRegistryIndex({ framework, registryUrl: options.registry });
|
|
248
321
|
const currentItem = index.find((item2) => item2.name === componentId);
|
|
249
322
|
const availableAesthetics = currentItem?.aesthetics || [
|
|
@@ -270,14 +343,13 @@ async function addCommand(componentArg, options = {}) {
|
|
|
270
343
|
aestheticId = availableAesthetics[0];
|
|
271
344
|
}
|
|
272
345
|
}
|
|
273
|
-
console.log(pc.cyan(`
|
|
274
|
-
Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`))
|
|
275
|
-
|
|
276
|
-
componentId,
|
|
346
|
+
const item = fromCatalog ?? (console.log(pc.cyan(`
|
|
347
|
+
Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`)), await fetchRegistryItem({
|
|
348
|
+
componentId: catalogType?.component.id ?? componentId,
|
|
277
349
|
aestheticId,
|
|
278
350
|
framework,
|
|
279
351
|
registryUrl: options.registry
|
|
280
|
-
});
|
|
352
|
+
}));
|
|
281
353
|
if (!item || !item.files || item.files.length === 0) {
|
|
282
354
|
console.error(
|
|
283
355
|
pc.red(
|
|
@@ -287,12 +359,12 @@ Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`));
|
|
|
287
359
|
process.exit(1);
|
|
288
360
|
}
|
|
289
361
|
const targetDir = options.path || getDefaultComponentsPath(framework, cwd);
|
|
290
|
-
const fullTargetDir =
|
|
362
|
+
const fullTargetDir = path4.resolve(cwd, targetDir);
|
|
291
363
|
for (const file of item.files) {
|
|
292
|
-
const fileName =
|
|
293
|
-
const destPath =
|
|
294
|
-
const relativeDest =
|
|
295
|
-
if (
|
|
364
|
+
const fileName = path4.basename(file.path);
|
|
365
|
+
const destPath = path4.join(fullTargetDir, fileName);
|
|
366
|
+
const relativeDest = path4.relative(cwd, destPath);
|
|
367
|
+
if (fs4.existsSync(destPath) && !options.overwrite && !options.yes) {
|
|
296
368
|
const { overwrite } = await prompts({
|
|
297
369
|
type: "confirm",
|
|
298
370
|
name: "overwrite",
|
|
@@ -304,8 +376,8 @@ Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`));
|
|
|
304
376
|
continue;
|
|
305
377
|
}
|
|
306
378
|
}
|
|
307
|
-
|
|
308
|
-
|
|
379
|
+
fs4.mkdirSync(path4.dirname(destPath), { recursive: true });
|
|
380
|
+
fs4.writeFileSync(destPath, file.content, "utf8");
|
|
309
381
|
console.log(pc.green(`\u2714 Created ${pc.bold(relativeDest)}`));
|
|
310
382
|
}
|
|
311
383
|
if (item.dependencies && item.dependencies.length > 0) {
|
|
@@ -317,8 +389,8 @@ Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`));
|
|
|
317
389
|
const missingDeps = item.dependencies.filter((dep) => !installed[dep]);
|
|
318
390
|
if (missingDeps.length > 0) {
|
|
319
391
|
const pm = detectPackageManager(cwd);
|
|
320
|
-
let install = Boolean(options.yes);
|
|
321
|
-
if (!options.yes) {
|
|
392
|
+
let install = options.install !== false && Boolean(options.yes);
|
|
393
|
+
if (options.install !== false && !options.yes) {
|
|
322
394
|
const res = await prompts({
|
|
323
395
|
type: "confirm",
|
|
324
396
|
name: "install",
|
|
@@ -350,17 +422,30 @@ Make sure to install required dependencies: ${pm} add ${missingDeps.join(" ")}`
|
|
|
350
422
|
}
|
|
351
423
|
}
|
|
352
424
|
const mainFile = item.files[0];
|
|
353
|
-
const symbolName = item.meta?.symbolName ||
|
|
354
|
-
const relPath =
|
|
425
|
+
const symbolName = item.meta?.symbolName || path4.basename(mainFile.path, path4.extname(mainFile.path));
|
|
426
|
+
const relPath = path4.relative(cwd, path4.join(fullTargetDir, path4.basename(mainFile.path)));
|
|
355
427
|
console.log(pc.bold(pc.green(`
|
|
356
428
|
\u2728 Successfully added ${symbolName}!`)));
|
|
357
429
|
console.log(pc.gray(`Import in your code:`));
|
|
358
430
|
if (framework === "svelte") {
|
|
359
431
|
const aliasPath = relPath.startsWith("src/lib/") ? relPath.replace(/^src\/lib\//, "$lib/") : `./${relPath}`;
|
|
360
432
|
console.log(pc.cyan(` import ${symbolName} from '${aliasPath}';
|
|
433
|
+
`));
|
|
434
|
+
} else if (fromCatalog && framework === "react") {
|
|
435
|
+
console.log(pc.cyan(` import { ${symbolName} } from './${relPath}';
|
|
436
|
+
`));
|
|
437
|
+
} else if (fromCatalog) {
|
|
438
|
+
console.log(pc.cyan(` import './${relPath}'; // defines <surreal-${item.name}>
|
|
361
439
|
`));
|
|
362
440
|
} else {
|
|
363
441
|
console.log(pc.cyan(` import ${symbolName} from './${relPath}';
|
|
442
|
+
`));
|
|
443
|
+
}
|
|
444
|
+
if (fromCatalog) {
|
|
445
|
+
console.log(pc.gray("Import the stylesheets once, and apply the pack to an ancestor:"));
|
|
446
|
+
for (const f of item.files.slice(1))
|
|
447
|
+
console.log(pc.cyan(` import './${path4.relative(cwd, path4.join(fullTargetDir, f.path))}';`));
|
|
448
|
+
console.log(pc.cyan(` <div data-aesthetic="${aestheticId}">\u2026</div>
|
|
364
449
|
`));
|
|
365
450
|
}
|
|
366
451
|
}
|
|
@@ -397,14 +482,14 @@ Add a component: ${pc2.cyan("npx surreal-ui add <component> --aesthetic <style>"
|
|
|
397
482
|
}
|
|
398
483
|
|
|
399
484
|
// src/commands/init.ts
|
|
400
|
-
import
|
|
401
|
-
import
|
|
485
|
+
import fs5 from "fs";
|
|
486
|
+
import path5 from "path";
|
|
402
487
|
import pc3 from "picocolors";
|
|
403
488
|
import prompts2 from "prompts";
|
|
404
489
|
async function initCommand(options = {}) {
|
|
405
490
|
const cwd = options.cwd || process.cwd();
|
|
406
|
-
const configPath =
|
|
407
|
-
if (
|
|
491
|
+
const configPath = path5.join(cwd, "surreal.json");
|
|
492
|
+
if (fs5.existsSync(configPath) && !options.yes) {
|
|
408
493
|
const { overwrite } = await prompts2({
|
|
409
494
|
type: "confirm",
|
|
410
495
|
name: "overwrite",
|
|
@@ -470,7 +555,7 @@ async function initCommand(options = {}) {
|
|
|
470
555
|
ui: componentsPath
|
|
471
556
|
}
|
|
472
557
|
};
|
|
473
|
-
|
|
558
|
+
fs5.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
474
559
|
console.log(pc3.bold(pc3.green(`
|
|
475
560
|
\u2714 Configuration saved to ${pc3.bold("surreal.json")}`)));
|
|
476
561
|
console.log(
|
|
@@ -480,8 +565,8 @@ async function initCommand(options = {}) {
|
|
|
480
565
|
}
|
|
481
566
|
|
|
482
567
|
// src/commands/diff.ts
|
|
483
|
-
import
|
|
484
|
-
import
|
|
568
|
+
import fs6 from "fs";
|
|
569
|
+
import path6 from "path";
|
|
485
570
|
import pc4 from "picocolors";
|
|
486
571
|
async function diffCommand(componentArg, options = {}) {
|
|
487
572
|
const cwd = options.cwd || process.cwd();
|
|
@@ -506,18 +591,18 @@ async function diffCommand(componentArg, options = {}) {
|
|
|
506
591
|
process.exit(1);
|
|
507
592
|
}
|
|
508
593
|
const targetDir = options.path || getDefaultComponentsPath(framework, cwd);
|
|
509
|
-
const fullTargetDir =
|
|
594
|
+
const fullTargetDir = path6.resolve(cwd, targetDir);
|
|
510
595
|
for (const file of item.files) {
|
|
511
|
-
const fileName =
|
|
512
|
-
const destPath =
|
|
513
|
-
if (!
|
|
596
|
+
const fileName = path6.basename(file.path);
|
|
597
|
+
const destPath = path6.join(fullTargetDir, fileName);
|
|
598
|
+
if (!fs6.existsSync(destPath)) {
|
|
514
599
|
console.log(
|
|
515
|
-
pc4.yellow(`Component file does not exist locally: ${
|
|
600
|
+
pc4.yellow(`Component file does not exist locally: ${path6.relative(cwd, destPath)}`)
|
|
516
601
|
);
|
|
517
602
|
console.log(pc4.gray(`Run 'npx surreal-ui add ${componentId}' to install it.`));
|
|
518
603
|
continue;
|
|
519
604
|
}
|
|
520
|
-
const localContent =
|
|
605
|
+
const localContent = fs6.readFileSync(destPath, "utf8");
|
|
521
606
|
if (localContent.trim() === file.content.trim()) {
|
|
522
607
|
console.log(
|
|
523
608
|
pc4.green(
|
|
@@ -539,18 +624,71 @@ async function diffCommand(componentArg, options = {}) {
|
|
|
539
624
|
}
|
|
540
625
|
}
|
|
541
626
|
|
|
627
|
+
// src/commands/skills.ts
|
|
628
|
+
import fs7 from "fs";
|
|
629
|
+
import path7 from "path";
|
|
630
|
+
import { pathToFileURL } from "url";
|
|
631
|
+
import pc5 from "picocolors";
|
|
632
|
+
function findCatalog(cwd) {
|
|
633
|
+
let dir = path7.resolve(cwd);
|
|
634
|
+
for (; ; ) {
|
|
635
|
+
const candidate = path7.join(dir, "node_modules", "@surreal-ui", "catalog");
|
|
636
|
+
if (fs7.existsSync(path7.join(candidate, "package.json"))) return fs7.realpathSync(candidate);
|
|
637
|
+
const parent = path7.dirname(dir);
|
|
638
|
+
if (parent === dir) return void 0;
|
|
639
|
+
dir = parent;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
async function loadCatalogNode(cwd) {
|
|
643
|
+
const catalog = findCatalog(cwd);
|
|
644
|
+
if (!catalog)
|
|
645
|
+
throw new Error(
|
|
646
|
+
"The skills ship in @surreal-ui/catalog, which this project does not have; install it first (npm install @surreal-ui/catalog)."
|
|
647
|
+
);
|
|
648
|
+
const entry = path7.join(catalog, "dist", "node.js");
|
|
649
|
+
if (!fs7.existsSync(entry))
|
|
650
|
+
throw new Error(
|
|
651
|
+
`${catalog} has no skills (dist/node.js); update it (npm install @surreal-ui/catalog@latest).`
|
|
652
|
+
);
|
|
653
|
+
return await import(pathToFileURL(entry).href);
|
|
654
|
+
}
|
|
655
|
+
async function skillsListCommand(options = {}) {
|
|
656
|
+
const { SURREAL_SKILLS, DEFAULT_SKILLS_DIR } = await loadCatalogNode(
|
|
657
|
+
options.cwd ?? process.cwd()
|
|
658
|
+
);
|
|
659
|
+
for (const s of SURREAL_SKILLS) console.log(` \u2022 ${pc5.bold(s.name)}: ${s.description}`);
|
|
660
|
+
console.log(
|
|
661
|
+
pc5.gray(
|
|
662
|
+
`
|
|
663
|
+
Copy them into this project with: surreal-ui skills install (into ${DEFAULT_SKILLS_DIR}; --dir for another folder)`
|
|
664
|
+
)
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
async function skillsInstallCommand(options = {}) {
|
|
668
|
+
const cwd = options.cwd ?? process.cwd();
|
|
669
|
+
const { installSkills } = await loadCatalogNode(cwd);
|
|
670
|
+
const result = installSkills({ cwd, dir: options.dir, skills: options.skill });
|
|
671
|
+
const count = (status) => result.files.filter((f) => f.status === status).length;
|
|
672
|
+
console.log(
|
|
673
|
+
pc5.green(
|
|
674
|
+
`Installed ${result.skills.join(" and ")} into ${result.dir}: ${count("added")} added, ${count("updated")} updated, ${count("unchanged")} unchanged.`
|
|
675
|
+
)
|
|
676
|
+
);
|
|
677
|
+
return result;
|
|
678
|
+
}
|
|
679
|
+
|
|
542
680
|
// src/index.ts
|
|
543
681
|
var program = new Command();
|
|
544
682
|
program.name("surreal-ui").description("Surreal UI CLI - Add multi-platform UI components directly to your codebase").version("0.5.4");
|
|
545
683
|
program.command("add [component]").description("Add a component to your project").option(
|
|
546
684
|
"-a, --aesthetic <style>",
|
|
547
685
|
"Aesthetic style (glassmorphism, neubrutalism, minimalist, shadcn)"
|
|
548
|
-
).option("-f, --framework <framework>", "Target framework (svelte, react, webcomponent)").option("-p, --path <path>", "Destination directory for components").option("-o, --overwrite", "Overwrite existing files without asking").option("-y, --yes", "Skip confirmation prompts").option("-r, --registry <url>", "Custom registry URL").action(async (component, options) => {
|
|
686
|
+
).option("-f, --framework <framework>", "Target framework (svelte, react, webcomponent)").option("-p, --path <path>", "Destination directory for components").option("-o, --overwrite", "Overwrite existing files without asking").option("-y, --yes", "Skip confirmation prompts").option("-r, --registry <url>", "Custom registry URL").option("--no-install", "Do not install missing dependencies; print the command instead").action(async (component, options) => {
|
|
549
687
|
try {
|
|
550
688
|
await addCommand(component, options);
|
|
551
689
|
process.exit(0);
|
|
552
690
|
} catch (err) {
|
|
553
|
-
console.error(
|
|
691
|
+
console.error(pc6.red(`
|
|
554
692
|
\u2716 Error: ${err.message}`));
|
|
555
693
|
process.exit(1);
|
|
556
694
|
}
|
|
@@ -560,7 +698,7 @@ program.command("list").description("List all available components in the regist
|
|
|
560
698
|
await listCommand(options);
|
|
561
699
|
process.exit(0);
|
|
562
700
|
} catch (err) {
|
|
563
|
-
console.error(
|
|
701
|
+
console.error(pc6.red(`
|
|
564
702
|
\u2716 Error: ${err.message}`));
|
|
565
703
|
process.exit(1);
|
|
566
704
|
}
|
|
@@ -570,7 +708,7 @@ program.command("init").description("Initialize surreal.json configuration in yo
|
|
|
570
708
|
await initCommand(options);
|
|
571
709
|
process.exit(0);
|
|
572
710
|
} catch (err) {
|
|
573
|
-
console.error(
|
|
711
|
+
console.error(pc6.red(`
|
|
574
712
|
\u2716 Error: ${err.message}`));
|
|
575
713
|
process.exit(1);
|
|
576
714
|
}
|
|
@@ -580,7 +718,37 @@ program.command("diff [component]").description("Compare local component file wi
|
|
|
580
718
|
await diffCommand(component, options);
|
|
581
719
|
process.exit(0);
|
|
582
720
|
} catch (err) {
|
|
583
|
-
console.error(
|
|
721
|
+
console.error(pc6.red(`
|
|
722
|
+
\u2716 Error: ${err.message}`));
|
|
723
|
+
process.exit(1);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
var skills = program.command("skills").description(
|
|
727
|
+
"The agent skills @surreal-ui/catalog ships, for coding agents (Claude Code, Cursor\u2026) using Surreal UI"
|
|
728
|
+
);
|
|
729
|
+
skills.command("list").description("List the skills and what each is for").action(async () => {
|
|
730
|
+
try {
|
|
731
|
+
await skillsListCommand();
|
|
732
|
+
process.exit(0);
|
|
733
|
+
} catch (err) {
|
|
734
|
+
console.error(pc6.red(`
|
|
735
|
+
\u2716 Error: ${err.message}`));
|
|
736
|
+
process.exit(1);
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
skills.command("install").description(
|
|
740
|
+
"Copy the skills from this project's @surreal-ui/catalog into the project, so a coding agent finds them (run it again after upgrading)"
|
|
741
|
+
).option("--dir <dir>", "Folder to copy them into, relative to here", ".claude/skills").option(
|
|
742
|
+
"--skill <name>",
|
|
743
|
+
"Only this skill (repeatable): surreal-use or surreal-author",
|
|
744
|
+
(value, previous) => [...previous, value],
|
|
745
|
+
[]
|
|
746
|
+
).action(async (options) => {
|
|
747
|
+
try {
|
|
748
|
+
await skillsInstallCommand(options);
|
|
749
|
+
process.exit(0);
|
|
750
|
+
} catch (err) {
|
|
751
|
+
console.error(pc6.red(`
|
|
584
752
|
\u2716 Error: ${err.message}`));
|
|
585
753
|
process.exit(1);
|
|
586
754
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surreal-ui/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Surreal UI CLI - Add multi-platform UI components directly to your codebase",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Pixerate",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Pixerate/surreal-ui.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://ui.pixerate.com",
|
|
5
13
|
"type": "module",
|
|
6
14
|
"main": "./dist/index.js",
|
|
7
15
|
"bin": {
|
|
@@ -12,20 +20,22 @@
|
|
|
12
20
|
"access": "public"
|
|
13
21
|
},
|
|
14
22
|
"files": [
|
|
15
|
-
"dist"
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
16
26
|
],
|
|
17
27
|
"dependencies": {
|
|
18
28
|
"commander": "^13.1.0",
|
|
19
29
|
"picocolors": "^1.1.1",
|
|
20
|
-
"prompts": "^2.4.2"
|
|
30
|
+
"prompts": "^2.4.2",
|
|
31
|
+
"@surreal-ui/catalog": "0.10.0"
|
|
21
32
|
},
|
|
22
33
|
"devDependencies": {
|
|
23
34
|
"@types/node": "^20.19.43",
|
|
24
35
|
"@types/prompts": "^2.4.9",
|
|
25
36
|
"tsup": "^8.0.2",
|
|
26
37
|
"tsx": "^4.23.15",
|
|
27
|
-
"typescript": "^5.5.0"
|
|
28
|
-
"@surreal-ui/core": "0.9.0"
|
|
38
|
+
"typescript": "^5.5.0"
|
|
29
39
|
},
|
|
30
40
|
"scripts": {
|
|
31
41
|
"build": "tsup",
|