@astralkit/cli 4.7.1 → 4.7.3

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/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to the `@astralkit/cli` package.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.7.3] (2026-12-01)
9
+
10
+ ### Changed
11
+ - **`search` and `list` print one sentence per result.** Each result showed its whole description, a paragraph for most components, so fifty results ran to several screens. Now it is the first sentence, cut at 160 characters with an ellipsis when that sentence is longer. The full description is on the component's page at astralkit.com.
12
+
13
+ ## [4.7.2] (2026-11-30)
14
+
15
+ ### Fixed
16
+ - **`astralkit search` and `astralkit list` work again.** `search <anything>` stopped with "(components.value || []).map is not a function", and `list` (also with `--boosters` or `--workflows`) answered "No components found." Both read the registry's answer as a bare list; it is an object holding the list. `add` was not affected.
17
+ - When the registry holds more than it returns in one answer, the heading says so ("Showing 50 of 636 components available") instead of giving the number shown as the whole library.
18
+
8
19
  ## [4.7.1] (2026-11-30)
9
20
 
10
21
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astralkit/cli",
3
- "version": "4.7.1",
3
+ "version": "4.7.3",
4
4
  "description": "AstralKit CLI — Install and manage UI components in your project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import pc from 'picocolors';
2
2
  import * as p from '@clack/prompts';
3
3
  import { listComponents, listBoosters, listWorkflows } from '../lib/api.js';
4
- import { sanitizeForTerminal } from '../lib/validators.js';
4
+ import { sanitizeForTerminal, firstSentence } from '../lib/validators.js';
5
5
 
6
6
  // Server-supplied string passthrough protection — strips ANSI/control sequences
7
7
  // before printing. Prevents a malicious API from rewriting the terminal.
@@ -15,12 +15,15 @@ export async function listCommand(options) {
15
15
  const spinner = ora(`Fetching ${type}...`).start();
16
16
 
17
17
  try {
18
- let items;
19
18
  const filters = { framework: options.framework, pro: options.pro, free: options.free, category: options.category };
20
19
 
21
- if (options.boosters) items = await listBoosters(filters);
22
- else if (options.workflows) items = await listWorkflows(filters);
23
- else items = await listComponents(filters);
20
+ let res;
21
+ if (options.boosters) res = await listBoosters(filters);
22
+ else if (options.workflows) res = await listWorkflows(filters);
23
+ else res = await listComponents(filters);
24
+ // The API answers { components: [...], pagination, total } (or boosters / workflows). Older answers were a bare list.
25
+ const items = Array.isArray(res) ? res : res?.[type] || res?.data || [];
26
+ const total = res?.pagination?.total ?? items.length;
24
27
 
25
28
  spinner.stop();
26
29
 
@@ -30,13 +33,13 @@ export async function listCommand(options) {
30
33
  }
31
34
 
32
35
  console.log();
33
- console.log(pc.bold(` ${items.length} ${type} available\n`));
36
+ console.log(pc.bold(` ${total > items.length ? `Showing ${items.length} of ${total}` : items.length} ${type} available\n`));
34
37
 
35
38
  for (const item of items) {
36
39
  const proTag = item.is_pro ? pc.magenta(' [PRO]') : pc.green(' [FREE]');
37
40
  const fw = item.frameworks?.map(f => FRAMEWORK_LABELS[f] || f).join(', ') || '';
38
41
  console.log(` ${pc.cyan(s(item.slug || item.name))}${proTag}`);
39
- if (item.description) console.log(pc.gray(` ${s(item.description)}`));
42
+ if (item.description) console.log(pc.gray(` ${firstSentence(item.description)}`));
40
43
  if (fw) console.log(pc.gray(` Frameworks: ${s(fw)}`));
41
44
  console.log();
42
45
  }
@@ -1,12 +1,16 @@
1
1
  import pc from 'picocolors';
2
2
  import * as p from '@clack/prompts';
3
3
  import { listComponents, listBoosters, listWorkflows } from '../lib/api.js';
4
- import { sanitizeForTerminal } from '../lib/validators.js';
4
+ import { sanitizeForTerminal, firstSentence } from '../lib/validators.js';
5
5
 
6
6
  const s = (v) => sanitizeForTerminal(v || '');
7
7
 
8
8
  const FRAMEWORK_LABELS = { nextjs: 'Next.js', react: 'React', html: 'HTML' };
9
9
 
10
+ // The API answers { components: [...], pagination, total } (or boosters / workflows). Older answers were a bare list.
11
+ const itemsOf = (res, key) => (Array.isArray(res) ? res : res?.[key] || res?.data || []);
12
+ const totalOf = (res, shown) => res?.pagination?.total ?? shown;
13
+
10
14
  export async function searchCommand(query, options) {
11
15
  const ora = (await import('ora')).default;
12
16
  const spinner = ora(`Searching for "${pc.cyan(query)}"...`).start();
@@ -14,11 +18,16 @@ export async function searchCommand(query, options) {
14
18
  try {
15
19
  const filters = { search: query, framework: options.framework };
16
20
  let results = [];
21
+ let total = 0;
17
22
 
18
23
  if (options.boosters) {
19
- results = await listBoosters(filters);
24
+ const res = await listBoosters(filters);
25
+ results = itemsOf(res, 'boosters');
26
+ total = totalOf(res, results.length);
20
27
  } else if (options.workflows) {
21
- results = await listWorkflows(filters);
28
+ const res = await listWorkflows(filters);
29
+ results = itemsOf(res, 'workflows');
30
+ total = totalOf(res, results.length);
22
31
  } else {
23
32
  // Search all three in parallel
24
33
  const [components, boosters, workflows] = await Promise.allSettled([
@@ -26,9 +35,12 @@ export async function searchCommand(query, options) {
26
35
  listBoosters(filters),
27
36
  listWorkflows(filters),
28
37
  ]);
29
- if (components.status === 'fulfilled') results.push(...(components.value || []).map(i => ({ ...i, _type: 'component' })));
30
- if (boosters.status === 'fulfilled') results.push(...(boosters.value || []).map(i => ({ ...i, _type: 'booster' })));
31
- if (workflows.status === 'fulfilled') results.push(...(workflows.value || []).map(i => ({ ...i, _type: 'workflow' })));
38
+ for (const [settled, key, type] of [[components, 'components', 'component'], [boosters, 'boosters', 'booster'], [workflows, 'workflows', 'workflow']]) {
39
+ if (settled.status !== 'fulfilled') continue;
40
+ const items = itemsOf(settled.value, key);
41
+ results.push(...items.map(i => ({ ...i, _type: type })));
42
+ total += totalOf(settled.value, items.length);
43
+ }
32
44
  }
33
45
 
34
46
  spinner.stop();
@@ -39,14 +51,14 @@ export async function searchCommand(query, options) {
39
51
  }
40
52
 
41
53
  console.log();
42
- console.log(pc.bold(` ${results.length} result(s) for "${query}"\n`));
54
+ console.log(pc.bold(` ${total > results.length ? `Showing ${results.length} of ${total}` : results.length} result(s) for "${query}"\n`));
43
55
 
44
56
  for (const item of results) {
45
57
  const typeLabel = item._type ? pc.gray(` [${item._type}]`) : '';
46
58
  const proTag = item.is_pro ? pc.magenta(' [PRO]') : pc.green(' [FREE]');
47
59
  const fw = item.frameworks?.map(f => FRAMEWORK_LABELS[f] || f).join(', ') || '';
48
60
  console.log(` ${pc.cyan(s(item.slug || item.name))}${typeLabel}${proTag}`);
49
- if (item.description) console.log(pc.gray(` ${s(item.description)}`));
61
+ if (item.description) console.log(pc.gray(` ${firstSentence(item.description)}`));
50
62
  if (fw) console.log(pc.gray(` Frameworks: ${s(fw)}`));
51
63
  console.log();
52
64
  }
@@ -58,6 +58,28 @@ export function sanitizeForTerminal(str) {
58
58
  return str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '');
59
59
  }
60
60
 
61
+ /**
62
+ * The first sentence of a description, for one-line listings (`search`, `list`). A registry description runs to a
63
+ * paragraph: printed whole, fifty results fill the terminal many times over.
64
+ * A sentence ends at . ! or ? followed by a space and a capital, a digit or an opening mark, so "audit.log(",
65
+ * "Next.js" and "e.g. this" do not end one. A first sentence longer than `max` is cut at a word, with an ellipsis.
66
+ */
67
+ export function firstSentence(str, max = 160) {
68
+ const text = sanitizeForTerminal(str).replace(/\s+/g, ' ').trim();
69
+ if (!text) return '';
70
+ let sentence = text;
71
+ const end = /[.!?](?=\s+[A-Z0-9<`"'(\[])/g;
72
+ for (let hit = end.exec(text); hit; hit = end.exec(text)) {
73
+ const before = text.slice(0, hit.index);
74
+ if (/(?:\b(?:e\.g|i\.e|vs|etc|approx|incl)|\b[A-Z])$/.test(before)) continue; // an abbreviation or an initial
75
+ sentence = text.slice(0, hit.index + 1);
76
+ break;
77
+ }
78
+ if (sentence.length <= max) return sentence;
79
+ const cut = sentence.slice(0, max);
80
+ return `${cut.slice(0, Math.max(cut.lastIndexOf(' '), max - 30)).replace(/[\s,;:(\p{Pd}]+$/u, '')}…`;
81
+ }
82
+
61
83
  export function validateFramework(framework) {
62
84
  if (!framework) return true;
63
85
  if (VALID_FRAMEWORKS.includes(framework)) return true;