slicejs-cli 4.5.0 → 4.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.
Files changed (48) hide show
  1. package/client.js +162 -83
  2. package/commands/Print.js +158 -164
  3. package/commands/build/build.js +27 -1
  4. package/commands/buildProduction/buildProduction.js +42 -71
  5. package/commands/bundle/bundle.js +65 -60
  6. package/commands/docs/agents.js +260 -0
  7. package/commands/docs/events.js +365 -0
  8. package/commands/docs/index.js +123 -0
  9. package/commands/doctor/doctor.js +43 -9
  10. package/commands/export/checkExport.js +163 -0
  11. package/commands/export/clientRedirects.js +72 -0
  12. package/commands/export/copyDist.js +180 -0
  13. package/commands/export/export.js +236 -0
  14. package/commands/export/files.js +33 -0
  15. package/commands/export/hosts/cloudflare.js +48 -0
  16. package/commands/export/hosts/github.js +31 -0
  17. package/commands/export/hosts/index.js +69 -0
  18. package/commands/export/hosts/netlify.js +42 -0
  19. package/commands/export/hosts/nginx.js +73 -0
  20. package/commands/export/hosts/none.js +23 -0
  21. package/commands/export/hosts/s3.js +24 -0
  22. package/commands/export/hosts/shared.js +62 -0
  23. package/commands/export/hosts/vercel.js +69 -0
  24. package/commands/export/outDir.js +91 -0
  25. package/commands/export/prerender.js +121 -0
  26. package/commands/getComponent/getComponent.js +39 -34
  27. package/commands/init/init.js +32 -22
  28. package/commands/lint/lint.js +2 -2
  29. package/commands/lint/types.js +1 -1
  30. package/commands/listComponents/listComponents.js +205 -172
  31. package/commands/seo/check.js +1 -1
  32. package/commands/seo/images.js +1 -1
  33. package/commands/seo/sitemap.js +1 -1
  34. package/commands/setup/lint.js +1 -1
  35. package/commands/skill/skill.js +2 -2
  36. package/commands/startServer/startServer.js +60 -21
  37. package/commands/startServer/watchServer.js +3 -3
  38. package/commands/translator/check.js +1 -1
  39. package/commands/translator/init.js +1 -1
  40. package/commands/typecheck/typecheck.js +2 -2
  41. package/commands/types/types.js +22 -3
  42. package/commands/utils/VersionChecker.js +14 -14
  43. package/commands/utils/bundling/BundleGenerator.js +45 -27
  44. package/commands/utils/bundling/DependencyAnalyzer.js +38 -17
  45. package/commands/utils/componentCatalog.js +120 -0
  46. package/commands/utils/publicEnv.js +74 -0
  47. package/commands/utils/updateManager.js +12 -12
  48. package/package.json +22 -23
@@ -0,0 +1,69 @@
1
+ // commands/export/hosts/vercel.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { readJsonIfExists, securityHeaderObjects } from './shared.js';
5
+
6
+ export default {
7
+ id: 'vercel',
8
+ // Vercel checks the filesystem before applying rewrites, so `/(.*)` does not
9
+ // shadow assets.
10
+ spaMode: 'rewrite',
11
+ clientRedirectPages: false,
12
+ ruleFiles: ['vercel.json'],
13
+
14
+ async write({ outDir, redirects, spa }) {
15
+ const securityHeaders = securityHeaderObjects();
16
+ const noStoreHeaders = [
17
+ ...securityHeaders,
18
+ { key: 'Cache-Control', value: 'no-store' }
19
+ ];
20
+ const vercel = {
21
+ headers: [
22
+ { source: '/(.*)', headers: securityHeaders },
23
+ { source: '/bundles/(.*)', headers: noStoreHeaders },
24
+ { source: '/slice-env.json', headers: noStoreHeaders },
25
+ { source: '/slice-env.generated.js', headers: noStoreHeaders }
26
+ ]
27
+ };
28
+
29
+ if (spa) {
30
+ vercel.rewrites = [{ source: '/(.*)', destination: '/index.html' }];
31
+ }
32
+ if (redirects.length) {
33
+ // `permanent` maps to 308/307; preserve the SEO status with `statusCode`.
34
+ vercel.redirects = redirects.map(({ from, to, status }) => ({
35
+ source: from,
36
+ destination: to,
37
+ statusCode: status
38
+ }));
39
+ }
40
+
41
+ await fs.writeFile(
42
+ path.join(outDir, 'vercel.json'),
43
+ `${JSON.stringify(vercel, null, 2)}\n`,
44
+ 'utf8'
45
+ );
46
+ return ['vercel.json'];
47
+ },
48
+
49
+ async check({ outDir, explicitHost }) {
50
+ const issues = [];
51
+ const warnings = [];
52
+ const file = path.join(outDir, 'vercel.json');
53
+ const hasVercel = await fs.pathExists(file);
54
+
55
+ if (hasVercel && !await readJsonIfExists(file)) {
56
+ issues.push('vercel.json is not valid JSON.');
57
+ }
58
+ if (explicitHost && !hasVercel) {
59
+ issues.push('Vercel export is missing vercel.json.');
60
+ }
61
+ return { issues, warnings };
62
+ },
63
+
64
+ async spaFallback({ outDir }) {
65
+ const vercel = await readJsonIfExists(path.join(outDir, 'vercel.json'));
66
+ const rewrites = Array.isArray(vercel?.rewrites) ? vercel.rewrites : [];
67
+ return rewrites.some((rewrite) => rewrite?.destination === '/index.html');
68
+ }
69
+ };
@@ -0,0 +1,91 @@
1
+ // commands/export/outDir.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+
5
+ const PROTECTED_OUT_DIRS = new Set([
6
+ 'src',
7
+ 'dist',
8
+ 'api',
9
+ 'node_modules',
10
+ '.git',
11
+ 'public',
12
+ 'locales',
13
+ 'components',
14
+ 'app',
15
+ 'bundles',
16
+ 'slice'
17
+ ]);
18
+
19
+ function isInside(parent, child) {
20
+ const relative = path.relative(parent, child);
21
+ return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
22
+ }
23
+
24
+ async function nearestExistingAncestor(target) {
25
+ let current = target;
26
+ while (!await fs.pathExists(current)) {
27
+ const parent = path.dirname(current);
28
+ if (parent === current) return current;
29
+ current = parent;
30
+ }
31
+ return current;
32
+ }
33
+
34
+ /**
35
+ * `slice export --out` runs `fs.remove()` on the target. Validate it before any
36
+ * write, so a typo like `--out .` or `--out src` cannot delete the project.
37
+ */
38
+ export async function resolveSafeOutDir(projectRoot, outOption) {
39
+ const requested = outOption == null || outOption === '' ? 'dist-static' : String(outOption);
40
+ const outDir = path.resolve(projectRoot, requested);
41
+ const relative = path.relative(projectRoot, outDir);
42
+
43
+ if (relative === '') {
44
+ throw new Error('Refusing to export into the project root. Use a dedicated folder such as dist-static.');
45
+ }
46
+ if (relative.startsWith('..') || path.isAbsolute(relative)) {
47
+ throw new Error(`Refusing to export outside the project: ${outDir}`);
48
+ }
49
+ if (isInside(outDir, projectRoot)) {
50
+ throw new Error(`Refusing to export into an ancestor of the project: ${outDir}`);
51
+ }
52
+
53
+ const topLevel = relative.split(path.sep)[0];
54
+ if (PROTECTED_OUT_DIRS.has(topLevel.toLowerCase())) {
55
+ throw new Error(
56
+ `Refusing to export into ${topLevel}/: it holds source, build or runtime files. Use a dedicated folder such as dist-static.`
57
+ );
58
+ }
59
+
60
+ if (await fs.pathExists(outDir)) {
61
+ const stat = await fs.lstat(outDir);
62
+ if (stat.isSymbolicLink() || !stat.isDirectory()) {
63
+ throw new Error(`Refusing to overwrite ${outDir}: the output path is not a directory.`);
64
+ }
65
+
66
+ // Existing folders are only overwritten when they look like a previous
67
+ // export. This protects `docs/`, `tests/`, `.github/` and any other real
68
+ // project folder from a mistyped `--out`.
69
+ const markers = await Promise.all([
70
+ fs.pathExists(path.join(outDir, 'index.html')),
71
+ fs.pathExists(path.join(outDir, 'bundles', 'bundle.config.json')),
72
+ fs.pathExists(path.join(outDir, 'slice-env.json'))
73
+ ]);
74
+ if (!markers.some(Boolean)) {
75
+ throw new Error(
76
+ `Refusing to overwrite ${outDir}: it exists but does not look like a previous export. Remove it or choose a new --out folder.`
77
+ );
78
+ }
79
+ }
80
+
81
+ // A parent folder can be a symlink that points outside the project even when
82
+ // the textual path is inside it. Resolve the nearest existing ancestor before
83
+ // allowing `fs.remove()` to run.
84
+ const realProject = await fs.realpath(projectRoot);
85
+ const realExisting = await fs.realpath(await nearestExistingAncestor(outDir));
86
+ if (!isInside(realProject, realExisting)) {
87
+ throw new Error(`Refusing to export through a symlink that leaves the project: ${outDir}`);
88
+ }
89
+
90
+ return outDir;
91
+ }
@@ -0,0 +1,121 @@
1
+ // commands/export/prerender.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+
5
+ export const PARAM_ROUTE = /\$\{[^}]+\}/;
6
+
7
+ /**
8
+ * `slice export` needs a framework new enough to expose prepareSeo's
9
+ * pages/notFound/redirects and expandPatternPaths. Import lazily so a CLI
10
+ * installed with an older framework still runs every other command.
11
+ */
12
+ async function loadExportFramework() {
13
+ let serverModule;
14
+ let seoModule;
15
+ try {
16
+ serverModule = await import('slicejs-web-framework/api/framework/server.js');
17
+ seoModule = await import('slicejs-web-framework/api/framework/seo.js');
18
+ } catch (error) {
19
+ throw new Error(
20
+ `slice export needs a slicejs-web-framework with prepareSeo pages/notFound/redirects and expandPatternPaths. Update it with "npm install slicejs-web-framework@latest". ${error.message}`
21
+ );
22
+ }
23
+
24
+ const prepareSeo = serverModule?.prepareSeo;
25
+ const expandPatternPaths = seoModule?.expandPatternPaths;
26
+ if (typeof prepareSeo !== 'function' || typeof expandPatternPaths !== 'function') {
27
+ throw new Error(
28
+ 'The installed slicejs-web-framework is too old for slice export: prepareSeo must expose pages/notFound/redirects and seo.js must export expandPatternPaths. Update it with "npm install slicejs-web-framework@latest".'
29
+ );
30
+ }
31
+
32
+ return { prepareSeo, expandPatternPaths };
33
+ }
34
+
35
+ async function findSeoManifest(projectRoot, distDir, options) {
36
+ const candidates = [];
37
+ if (options.seo) candidates.push(options.seo);
38
+ candidates.push(
39
+ 'seo.json',
40
+ 'src/public/seo.json',
41
+ 'src/seo.json',
42
+ path.join(distDir, 'public', 'seo.json'),
43
+ path.join(distDir, 'seo.json')
44
+ );
45
+ for (const candidate of candidates) {
46
+ const full = path.isAbsolute(candidate) ? candidate : path.resolve(projectRoot, candidate);
47
+ if (await fs.pathExists(full)) return full;
48
+ }
49
+ return null;
50
+ }
51
+
52
+ async function findImagesManifest(projectRoot, distDir, options) {
53
+ const candidates = [];
54
+ if (options.images) candidates.push(options.images);
55
+ candidates.push(
56
+ 'src/public/og/manifest.json',
57
+ path.join(distDir, 'public', 'og', 'manifest.json')
58
+ );
59
+ for (const candidate of candidates) {
60
+ const full = path.isAbsolute(candidate) ? candidate : path.resolve(projectRoot, candidate);
61
+ if (await fs.pathExists(full)) return full;
62
+ }
63
+ return null;
64
+ }
65
+
66
+ export async function buildPrerender(projectRoot, distDir, options) {
67
+ if (options.prerender === false) return null;
68
+
69
+ const seoFile = await findSeoManifest(projectRoot, distDir, options);
70
+ if (!seoFile) return null;
71
+
72
+ const imagesFile = await findImagesManifest(projectRoot, distDir, options);
73
+ const { prepareSeo, expandPatternPaths } = await loadExportFramework();
74
+ const seo = await prepareSeo({
75
+ projectRoot,
76
+ mode: 'production',
77
+ port: options.port ? Number(options.port) : undefined,
78
+ seo: {
79
+ manifest: seoFile,
80
+ ...(options.origin ? { origin: options.origin } : {}),
81
+ ...(imagesFile ? { images: imagesFile } : {})
82
+ }
83
+ });
84
+ if (!seo) return null;
85
+
86
+ if (!(seo.pages instanceof Map) || !(seo.notFound instanceof Map) || !Array.isArray(seo.redirects)) {
87
+ throw new Error(
88
+ 'prepareSeo() from the installed slicejs-web-framework did not return pages/notFound/redirects. Update it with "npm install slicejs-web-framework@latest".'
89
+ );
90
+ }
91
+
92
+ // A `${param}` route cannot be enumerated unless it opts in with sitemap.paths.
93
+ const pages = new Map(seo.pages);
94
+ const locales = seo.translator?.enabled ? seo.translator.locales : [null];
95
+ let patternsSkipped = 0;
96
+
97
+ for (const route of seo.routes) {
98
+ if (!PARAM_ROUTE.test(route.path)) continue;
99
+ const values = seo.manifest.routes?.[route.path]?.sitemap?.paths;
100
+ const concretePaths = expandPatternPaths(route.path, values);
101
+ if (concretePaths.length === 0) {
102
+ patternsSkipped += 1;
103
+ continue;
104
+ }
105
+ for (const concrete of concretePaths) {
106
+ for (const locale of locales) {
107
+ const url = seo.translator?.enabled ? seo.translator.localize(concrete, locale) : concrete;
108
+ if (pages.has(url)) continue;
109
+ const result = seo.resolve(url);
110
+ if (result.status === 200 && result.page) pages.set(url, result.page);
111
+ }
112
+ }
113
+ }
114
+
115
+ return {
116
+ seo,
117
+ pages,
118
+ patternsSkipped,
119
+ localeCount: seo.translator?.enabled ? seo.translator.locales.length : 0
120
+ };
121
+ }
@@ -14,6 +14,23 @@ import ora from "ora";
14
14
  const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs-components/master/src/Components';
15
15
  const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/slicejs-components/master/src/Components/components.js';
16
16
 
17
+ function wrapNames(names, indent = ' ') {
18
+ const width = Math.max(40, (process.stdout.columns || 80) - indent.length);
19
+ const lines = [];
20
+ let current = '';
21
+ for (const name of names) {
22
+ const next = current ? `${current}, ${name}` : name;
23
+ if (next.length > width && current) {
24
+ lines.push(current);
25
+ current = name;
26
+ } else {
27
+ current = next;
28
+ }
29
+ }
30
+ if (current) lines.push(current);
31
+ return lines.map((line) => `${indent}${line}`);
32
+ }
33
+
17
34
  /**
18
35
  * Loads configuration from sliceConfig.json
19
36
  * @returns {object} - Configuration object
@@ -140,7 +157,7 @@ filterOfficialComponents(allComponents) {
140
157
 
141
158
  return JSON.parse(match[1]);
142
159
  } catch (error) {
143
- Print.warning(`⚠️ Could not read the local component registry at: ${componentsPath}`);
160
+ Print.warning(`Could not read the local component registry at ${componentsPath}`);
144
161
  return {};
145
162
  }
146
163
  }
@@ -378,8 +395,8 @@ filterOfficialComponents(allComponents) {
378
395
  await this.updateLocalRegistrySafe(componentName, category);
379
396
 
380
397
  Print.success(`${componentName} installed successfully from official repository!`);
381
- console.log(`📁 Location: ${[folderSuffix, categoryPath, componentName].join('/').replace(/\/+/g, '/')}/`);
382
- console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
398
+ console.log(`Location: ${[folderSuffix, categoryPath, componentName].join('/').replace(/\/+/g, '/')}/`);
399
+ console.log(`Files: ${downloadedFiles.join(', ')}`);
383
400
 
384
401
  // Resolve and install what this component pulls in: other components via
385
402
  // slice.build('X') or relative imports, and helper .js modules it imports.
@@ -570,10 +587,10 @@ filterOfficialComponents(allComponents) {
570
587
  }
571
588
 
572
589
  Print.newLine();
573
- Print.subtitle(`Found ${updatableComponents.length} updatable Visual components:`);
590
+ Print.subtitle(`Found ${updatableComponents.length} updatable Visual components`);
574
591
  Print.newLine();
575
592
  updatableComponents.forEach(comp => {
576
- console.log(`🎨 ${comp.name} (${comp.category})`);
593
+ console.log(` ${comp.name} (${comp.category})`);
577
594
  });
578
595
 
579
596
  if (!force) {
@@ -603,7 +620,7 @@ filterOfficialComponents(allComponents) {
603
620
  const totalFailed = results.filter(r => !r.success).length;
604
621
 
605
622
  Print.newLine();
606
- Print.title('Visual Components Sync Summary');
623
+ Print.title('Sync summary');
607
624
  Print.success(`Visual components updated: ${totalSuccessful}`);
608
625
 
609
626
  if (totalFailed > 0) {
@@ -625,40 +642,28 @@ filterOfficialComponents(allComponents) {
625
642
 
626
643
  displayAvailableComponents() {
627
644
  if (!this.componentsRegistry) {
628
- Print.error('❌ Could not load component registry');
645
+ Print.error('Could not load component registry');
629
646
  return;
630
647
  }
631
648
 
632
- console.log('\n📚 Available components in the official Slice.js repository:\n');
633
-
634
649
  const visualComponents = this.getAvailableComponents('Visual');
635
650
  const serviceComponents = this.getAvailableComponents('Service');
651
+ const visualNames = Object.keys(visualComponents).sort((a, b) => a.localeCompare(b));
652
+ const serviceNames = Object.keys(serviceComponents).sort((a, b) => a.localeCompare(b));
636
653
 
637
- // Only show names without descriptions
638
- Print.info('🎨 Visual Components (UI):');
639
- Object.keys(visualComponents).forEach(name => {
640
- const files = visualComponents[name].files;
641
- const fileIcons = files.map(file => {
642
- if (file.endsWith('.js')) return '📜';
643
- if (file.endsWith('.html')) return '🌐';
644
- if (file.endsWith('.css')) return '🎨';
645
- return '📄';
646
- }).join(' ');
647
- console.log(` • ${name} ${fileIcons}`);
648
- });
649
-
650
- Print.info('\n⚙️ Service Components (Logic):');
651
- Object.keys(serviceComponents).forEach(name => {
652
- console.log(` • ${name} 📜`);
653
- });
654
-
654
+ Print.title('Available components');
655
+ Print.subtitle(`Visual (${visualNames.length})`);
656
+ for (const line of wrapNames(visualNames)) console.log(line);
655
657
  Print.newLine();
656
- Print.info(`Total: ${Object.keys(visualComponents).length} Visual + ${Object.keys(serviceComponents).length} Service components`);
658
+ Print.subtitle(`Service (${serviceNames.length})`);
659
+ for (const line of wrapNames(serviceNames)) console.log(line);
657
660
 
658
- console.log(`\n💡 Usage examples:`);
659
- console.log(`slice get Button Card Input # Install Visual components`);
660
- console.log(`slice get FetchManager --service # Install Service component`);
661
- console.log(`slice sync # Sync Visual components`);
661
+ Print.newLine();
662
+ Print.info(`Total: ${visualNames.length} Visual + ${serviceNames.length} Service components`);
663
+ Print.subtitle('Usage examples');
664
+ Print.commandExample('Install Visual components', 'slice get Button Card Input');
665
+ Print.commandExample('Install a Service component', 'slice get FetchManager --service');
666
+ Print.commandExample('Sync Visual components', 'slice sync');
662
667
  }
663
668
 
664
669
  async interactiveInstall() {
@@ -668,8 +673,8 @@ filterOfficialComponents(allComponents) {
668
673
  name: 'componentType',
669
674
  message: 'Select the type of component to install from the repository:',
670
675
  choices: [
671
- { name: '🎨 Visual Components (UI)', value: 'Visual' },
672
- { name: '⚙️ Service Components (Logic)', value: 'Service' }
676
+ { name: 'Visual components (UI)', value: 'Visual' },
677
+ { name: 'Service components (logic)', value: 'Service' }
673
678
  ]
674
679
  }
675
680
  ]);
@@ -3,6 +3,7 @@ import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import ora from 'ora';
5
5
  import Print from '../Print.js';
6
+ import { generateDocs } from '../docs/index.js';
6
7
  import { getProjectRoot, getApiPath, getSrcPath, getPath } from '../utils/PathHelper.js';
7
8
  import { execSync } from 'child_process';
8
9
  import {
@@ -104,6 +105,9 @@ node_modules/
104
105
  # Production build output (slice build)
105
106
  dist/
106
107
 
108
+ # Static export output (slice export)
109
+ dist-static/
110
+
107
111
  # Local environment overrides
108
112
  .env
109
113
  .env.*
@@ -241,7 +245,7 @@ export default async function initializeProject(options = {}) {
241
245
  fwSpinner.warn('Install did not run; using the slicejs-web-framework already in this project');
242
246
  } else {
243
247
  fwSpinner.fail('Failed to install slicejs-web-framework');
244
- Print.error('slice init:', err.message);
248
+ Print.error(`slice init: ${err.message}`);
245
249
  const retry = installCommand(packageManager, latestVersion ? `slicejs-web-framework@${latestVersion}` : 'slicejs-web-framework');
246
250
  Print.info(`Retry with: ${retry}`);
247
251
  return;
@@ -283,8 +287,8 @@ export default async function initializeProject(options = {}) {
283
287
  if (fs.existsSync(path.join(destinationApi, 'index.js'))) throw new Error(`api/index.js already exists: ${path.join(destinationApi, 'index.js')}`);
284
288
  if (fs.existsSync(destinationSrc)) throw new Error(`The "src" directory already exists: ${destinationSrc}`);
285
289
  } catch (error) {
286
- Print.error('Validating destination directories:', error.message);
287
- console.error(error.stack);
290
+ Print.error(`Validating destination directories: ${error.message}`);
291
+ Print.stack(error);
288
292
  return;
289
293
  }
290
294
 
@@ -299,7 +303,7 @@ export default async function initializeProject(options = {}) {
299
303
  } catch (error) {
300
304
  apiSpinner.fail('Error creating api/index.js');
301
305
  Print.error(error.message);
302
- console.error(error.stack);
306
+ Print.stack(error);
303
307
  return;
304
308
  }
305
309
 
@@ -351,7 +355,7 @@ export default async function initializeProject(options = {}) {
351
355
  } catch (error) {
352
356
  srcSpinner.fail('Error creating source structure');
353
357
  Print.error(error.message);
354
- console.error(error.stack);
358
+ Print.stack(error);
355
359
  return;
356
360
  }
357
361
 
@@ -484,38 +488,44 @@ export default async function initializeProject(options = {}) {
484
488
  }
485
489
 
486
490
  await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2), 'utf8');
487
- pkgSpinner.succeed('Package scripts configured successfully');
488
-
489
- Print.title('New recommended commands:');
490
- console.log(` ${packageManager} run dev - Start development server`);
491
- console.log(` ${packageManager} run get - Install components`);
492
- console.log(` ${packageManager} run browse - Browse components`);
491
+ pkgSpinner.succeed('Package scripts configured');
493
492
  } catch (error) {
494
493
  pkgSpinner.fail('Failed to configure npm scripts');
495
494
  Print.error(error.message);
496
- console.error(error.stack);
495
+ Print.stack(error);
496
+ }
497
+
498
+ // 5. SEED THE AGENT DOCUMENTATION
499
+ const docsSpinner = ora('Documenting the project for agents...').start();
500
+ try {
501
+ await generateDocs({ projectRoot, target: 'all' });
502
+ docsSpinner.succeed('AGENTS.md, category guides, types and event docs created');
503
+ } catch (error) {
504
+ docsSpinner.warn('Project created, but the agent docs could not be generated');
505
+ Print.error(`Documentation error: ${error.message}`);
497
506
  }
498
507
 
499
508
  const projectName = path.basename(process.cwd());
500
509
 
501
510
  const failedCount = [...visualResults, ...serviceResults].filter(r => !r.success).length;
502
511
  if (failedCount > 0) {
503
- Print.warning(`${failedCount} component(s) failed to install — run "${packageManager} run get -- <name>" to retry`);
512
+ const suffix = failedCount === 1 ? '' : 's';
513
+ Print.warning(`${failedCount} component${suffix} failed to install. Retry with "${packageManager} run get -- <name>".`);
504
514
  }
505
515
 
506
- Print.success(`Project initialized successfully in "${projectName}/"`);
516
+ Print.success(`Project initialized in ${projectName}/`);
507
517
  Print.newLine();
508
- Print.title('Next steps:');
518
+ Print.title('Next steps');
509
519
  console.log(` cd ${projectName}`);
510
- console.log(` ${packageManager} run dev - Start development server`);
511
- console.log(` ${packageManager} run browse - View available components`);
512
- console.log(` ${packageManager} run get -- Button - Install specific components`);
513
- console.log(` ${packageManager} run sync - Update all components to latest versions`);
514
- console.log(` slice setup lint --with-types - ESLint, type checking and the generated types`);
520
+ console.log(` ${packageManager} run dev Start the development server`);
521
+ console.log(` ${packageManager} run browse Browse registry components`);
522
+ console.log(` ${packageManager} run get -- Button Add a component`);
523
+ console.log(` ${packageManager} run sync Update installed components`);
524
+ console.log(' npx slicejs-cli setup lint --with-types ESLint, type checking and generated types');
515
525
 
516
526
  } catch (error) {
517
- Print.error('Unexpected error initializing project:', error.message);
518
- console.error(error.stack);
527
+ Print.error(`Unexpected error initializing project: ${error.message}`);
528
+ Print.stack(error);
519
529
  }
520
530
  }
521
531
 
@@ -36,7 +36,7 @@ export default async function lintCommand(options = {}, projectRoot) {
36
36
  const types = await runTypeRefresh(projectRoot, options);
37
37
  if (types) reportTypesRefresh(types, projectRoot);
38
38
  } catch (error) {
39
- Print.error('Could not refresh the generated types:', error.message);
39
+ Print.error(`Could not refresh the generated types: ${error.message}`);
40
40
  process.exitCode = 1;
41
41
  }
42
42
  }
@@ -61,7 +61,7 @@ export default async function lintCommand(options = {}, projectRoot) {
61
61
  });
62
62
 
63
63
  if (result.error) {
64
- Print.error('Could not run ESLint:', result.error.message);
64
+ Print.error(`Could not run ESLint: ${result.error.message}`);
65
65
  process.exitCode = 1;
66
66
  return false;
67
67
  }
@@ -77,7 +77,7 @@ export function reportTypesRefresh(types, projectRoot) {
77
77
  Print.info('Using tsconfig.json; the generated declarations are not added to it.');
78
78
  break;
79
79
  case 'editor_config_error':
80
- Print.warning('Could not update jsconfig.json:', types.jsconfigError || 'unknown error');
80
+ Print.warning(`Could not update jsconfig.json: ${types.jsconfigError || 'unknown error'}`);
81
81
  break;
82
82
  default:
83
83
  break;