Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

[CLI] fix: show compact template summary by default (#7152)

Joeya81135d6895a
diff --git a/.changeset/fix-template-compact-default.md b/.changeset/fix-template-compact-default.md
new file mode 100644
index 0000000000..dbb400959b
--- /dev/null
+++ b/.changeset/fix-template-compact-default.md
@@ -0,0 +1,12 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[fix] template: show a grouped summary by default instead of the full catalog
+@josephfarina
+
+Bare `astryx template` (no name, no `--list`) now shows templates grouped by category with counts — about 21 KB instead of the full 149 KB catalog. The full catalog with descriptions is still reachable via `astryx template --list`.
+
+JSON output is unchanged — `--json template` still returns the complete `template.list` response. This is a text-only rendering change under AST-017 FR11: the machine-readable response schema is the contract; text formatting is not.
+
+Trade-off: the grouped output still includes every template id (so `template <id>` works from a copy-paste), at the cost of ~21 KB. An even shorter summary (type + count only, no ids) would be ~500 bytes but would require a second step to discover any id. The current shape serves both human scanning and agent copy-paste without a round-trip.
diff --git a/packages/cli/clients/cli/commands/template.mjs b/packages/cli/clients/cli/commands/template.mjs
index b058d3ab76..a29ba1b1fc 100644
--- a/packages/cli/clients/cli/commands/template.mjs
+++ b/packages/cli/clients/cli/commands/template.mjs
@@ -111,6 +111,52 @@ export function registerTemplate(program) {
case 'template.list': {
const pages = result.data.filter(t => t.type === 'page');
const blocks = result.data.filter(t => t.type === 'block');
+
+ // Bare `template` (no --list, no name) shows a grouped summary so a
+ // no-context agent or terminal doesn't receive 150 KB of catalog. The
+ // full catalog stays reachable via `template --list`.
+ if (!options.list && !name) {
+ /** @param {import('../../../api/template/template.type.mjs').TemplateListEntry[]} items */
+ const grouped = items => {
+ /** @type {Map<string, string[]>} */
+ const groups = new Map();
+ for (const t of items) {
+ const cat = t.category || 'Other';
+ const list = groups.get(cat);
+ if (list) {
+ list.push(t.id);
+ } else {
+ groups.set(cat, [t.id]);
+ }
+ }
+ /** @type {string[]} */
+ const lines = [];
+ for (const [cat, ids] of groups) {
+ lines.push(`${cat}: ${ids.join(', ')}`);
+ }
+ return lines.join('\n');
+ };
+ emit(
+ section(`Page Templates (${pages.length})`),
+ pages.length > 0 && text(grouped(pages)),
+ section(`Block Templates (${blocks.length})`),
+ blocks.length > 0 && text(grouped(blocks)),
+ section('Usage'),
+ text(
+ [
+ `${run} template <id> Show full source`,
+ `${run} template <id> [target-path] Scaffold page or block`,
+ `${run} template <id> --skeleton Layout reference`,
+ `${run} template --list Full catalog with descriptions`,
+ `${run} template --list --type block List only blocks`,
+ `${run} template --list --package <pkg> List from one package`,
+ `${run} template --cdn CDN starter page, no build step`,
+ ].join('\n'),
+ ),
+ );
+ break;
+ }
+
// Project each entry to its JSON-mirroring fields; the WIP marker is
// folded into `name` (as before) and the package is shown only when it
// isn't the built-in core package.