Skip to content

Write HTML. Render video. Built for agents.

feat(cli): name-or-tag resolution for hyperframes add

Miguel Ángel20c1341cc8eb
diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts
index 9757f0cc61..77cfba770f 100644
--- a/packages/cli/src/commands/add.ts
+++ b/packages/cli/src/commands/add.ts
@@ -4,7 +4,8 @@ import type { Example } from "./_examples.js";
export const examples: Example[] = [
["Add a block to the current project", "hyperframes add claude-code-window"],
["Add a component effect", "hyperframes add shader-wipe"],
- ["Add all blocks with a tag", "hyperframes add --tag vfx"],
+ ["Add all HTML-in-Canvas blocks", "hyperframes add html-in-canvas"],
+ ["Add all caption blocks", "hyperframes add captions"],
["Target a specific project directory", "hyperframes add shader-wipe --dir ./my-video"],
["Skip the clipboard copy (CI/headless)", "hyperframes add shader-wipe --no-clipboard"],
];
@@ -174,13 +175,10 @@ export default defineCommand({
args: {
name: {
type: "positional",
- description: "Registry item name (e.g. claude-code-window, shader-wipe)",
- required: false,
- },
- tag: {
- type: "string",
- alias: "t",
- description: "Install all blocks matching a tag (e.g. --tag vfx, --tag captions)",
+ description:
+ "Registry item name or tag. Single items install directly (e.g. shader-wipe). " +
+ "If the name matches a tag instead, all blocks with that tag are installed (e.g. html-in-canvas, captions).",
+ required: true,
},
dir: {
type: "string",
@@ -199,11 +197,46 @@ export default defineCommand({
const projectDir = resolve(args.dir ?? process.cwd());
const json = args.json === true;
const skipClipboard = args["no-clipboard"] === true;
- const tag = args.tag?.trim();
const hasConfigBefore = existsSync(projectConfigPath(projectDir));
- // ── Tag-based bulk install ──────────────────────────────────────────
- if (tag) {
+ // Try single item first. If it fails, check if the name matches a tag.
+ try {
+ const result = await runAdd({ name: args.name, projectDir, skipClipboard });
+ const wroteConfig = !hasConfigBefore && existsSync(projectConfigPath(projectDir));
+
+ if (json) {
+ console.log(JSON.stringify(result));
+ return;
+ }
+
+ if (wroteConfig) {
+ console.log(c.dim(`Wrote default ${projectConfigPath(projectDir)}`));
+ }
+ console.log("");
+ console.log(`${c.success("✓")} Added ${c.accent(result.name)} (${result.type})`);
+ for (const file of result.written) {
+ console.log(` ${c.dim(relative(projectDir, file))}`);
+ }
+ if (result.snippet) {
+ console.log("");
+ console.log(c.dim("Include snippet:"));
+ console.log(` ${result.snippet}`);
+ console.log("");
+ console.log(
+ result.clipboardCopied
+ ? c.dim("Copied to clipboard — paste into your host composition.")
+ : c.dim("Paste the snippet above into your host composition."),
+ );
+ }
+ } catch (singleErr) {
+ // Not a single item — try as a tag for bulk install
+ if (!(singleErr instanceof AddError) || singleErr.code !== "unknown-item") {
+ const msg = singleErr instanceof Error ? singleErr.message : String(singleErr);
+ if (json) console.log(JSON.stringify({ ok: false, error: msg }));
+ else console.error(c.error(msg));
+ process.exit(1);
+ }
+
let config = loadProjectConfig(projectDir);
if (
!existsSync(projectConfigPath(projectDir)) &&
@@ -215,16 +248,13 @@ export default defineCommand({
let items: Awaited<ReturnType<typeof resolveItemsByTag>>;
try {
- items = await resolveItemsByTag(tag, { baseUrl: config.registry });
- } catch (err) {
- const msg = err instanceof Error ? err.message : String(err);
- if (json) console.log(JSON.stringify({ ok: false, error: msg }));
- else console.error(c.error(msg));
- process.exit(1);
+ items = await resolveItemsByTag(args.name, { baseUrl: config.registry });
+ } catch {
+ items = [];
}
if (items.length === 0) {
- const msg = `No blocks found with tag "${tag}".`;
+ const msg = singleErr instanceof Error ? singleErr.message : String(singleErr);
if (json) console.log(JSON.stringify({ ok: false, error: msg }));
else console.error(c.error(msg));
process.exit(1);
@@ -233,7 +263,7 @@ export default defineCommand({
if (!json) {
console.log("");
console.log(
- `${c.accent("◆")} Installing ${c.accent(String(items.length))} blocks tagged ${c.accent(tag)}`,
+ `${c.accent("◆")} Installing ${c.accent(String(items.length))} blocks tagged ${c.accent(args.name)}`,
);
}
@@ -249,56 +279,13 @@ export default defineCommand({
}
if (json) {
- console.log(JSON.stringify({ ok: true, tag, installed: results.map((r) => r.name) }));
- } else {
- console.log("");
- console.log(`${c.success("✓")} Installed ${results.length}/${items.length} blocks`);
- }
- return;
- }
-
- // ── Single item install ────────────────────────────────────────────
- if (!args.name) {
- console.error(c.error("Provide a block name or use --tag <tag> to install by tag."));
- process.exit(1);
- }
-
- try {
- const result = await runAdd({ name: args.name, projectDir, skipClipboard });
- const wroteConfig = !hasConfigBefore && existsSync(projectConfigPath(projectDir));
-
- if (json) {
- console.log(JSON.stringify(result));
- return;
- }
-
- if (wroteConfig) {
- console.log(c.dim(`Wrote default ${projectConfigPath(projectDir)}`));
- }
- console.log("");
- console.log(`${c.success("✓")} Added ${c.accent(result.name)} (${result.type})`);
- for (const file of result.written) {
- console.log(` ${c.dim(relative(projectDir, file))}`);
- }
- if (result.snippet) {
- console.log("");
- console.log(c.dim("Include snippet:"));
- console.log(` ${result.snippet}`);
- console.log("");
console.log(
- result.clipboardCopied
- ? c.dim("Copied to clipboard — paste into your host composition.")
- : c.dim("Paste the snippet above into your host composition."),
+ JSON.stringify({ ok: true, tag: args.name, installed: results.map((r) => r.name) }),
);
- }
- } catch (err) {
- const msg = err instanceof Error ? err.message : String(err);
- if (json) {
- console.log(JSON.stringify({ ok: false, error: msg }));
} else {
- console.error(c.error(msg));
+ console.log("");
+ console.log(`${c.success("✓")} Installed ${results.length}/${items.length} blocks`);
}
- process.exit(1);
}
},
});
diff --git a/registry/blocks/captions-bounce/registry-item.json b/registry/blocks/captions-bounce/registry-item.json
index 49ee66d11f..389cf2eaf6 100644
--- a/registry/blocks/captions-bounce/registry-item.json
+++ b/registry/blocks/captions-bounce/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 13,
"tags": [
- "html-in-canvas",
"captions",
"bounce"
],
diff --git a/registry/blocks/captions-cinematic/registry-item.json b/registry/blocks/captions-cinematic/registry-item.json
index 7b80a8dbdf..0b8d234f49 100644
--- a/registry/blocks/captions-cinematic/registry-item.json
+++ b/registry/blocks/captions-cinematic/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 13,
"tags": [
- "html-in-canvas",
"captions",
"cinematic"
],
diff --git a/registry/blocks/captions-karaoke/registry-item.json b/registry/blocks/captions-karaoke/registry-item.json
index 9301f8c8bc..621761bb2f 100644
--- a/registry/blocks/captions-karaoke/registry-item.json
+++ b/registry/blocks/captions-karaoke/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 13,
"tags": [
- "html-in-canvas",
"captions",
"karaoke"
],
diff --git a/registry/blocks/captions-minimal/registry-item.json b/registry/blocks/captions-minimal/registry-item.json
index 1828318f21..f775dfc2fc 100644
--- a/registry/blocks/captions-minimal/registry-item.json
+++ b/registry/blocks/captions-minimal/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 13,
"tags": [
- "html-in-canvas",
"captions",
"minimal"
],
diff --git a/registry/blocks/captions-slam/registry-item.json b/registry/blocks/captions-slam/registry-item.json
index c1bdf7af1d..3434409d30 100644
--- a/registry/blocks/captions-slam/registry-item.json
+++ b/registry/blocks/captions-slam/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 13,
"tags": [
- "html-in-canvas",
"captions",
"slam"
],
diff --git a/registry/blocks/vfx-iphone-device/registry-item.json b/registry/blocks/vfx-iphone-device/registry-item.json
index f191a9c98f..2fed8401f5 100644
--- a/registry/blocks/vfx-iphone-device/registry-item.json
+++ b/registry/blocks/vfx-iphone-device/registry-item.json
@@ -12,7 +12,6 @@
"duration": 15,
"tags": [
"html-in-canvas",
- "vfx",
"3d",
"device",
"iphone",
diff --git a/registry/blocks/vfx-liquid-background/registry-item.json b/registry/blocks/vfx-liquid-background/registry-item.json
index 4ed1a7a86d..c26bb1da1c 100644
--- a/registry/blocks/vfx-liquid-background/registry-item.json
+++ b/registry/blocks/vfx-liquid-background/registry-item.json
@@ -12,7 +12,6 @@
"duration": 12,
"tags": [
"html-in-canvas",
- "vfx",
"liquid",
"webgl",
"displacement",
diff --git a/registry/blocks/vfx-liquid-glass/registry-item.json b/registry/blocks/vfx-liquid-glass/registry-item.json
index 46bdd999f6..319b7cedda 100644
--- a/registry/blocks/vfx-liquid-glass/registry-item.json
+++ b/registry/blocks/vfx-liquid-glass/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 20,
"tags": [
- "vfx",
"html-in-canvas",
"webgl"
],
diff --git a/registry/blocks/vfx-magnetic/registry-item.json b/registry/blocks/vfx-magnetic/registry-item.json
index 965798d4d1..5ba13e1cc9 100644
--- a/registry/blocks/vfx-magnetic/registry-item.json
+++ b/registry/blocks/vfx-magnetic/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 15,
"tags": [
- "vfx",
"html-in-canvas",
"webgl"
],
diff --git a/registry/blocks/vfx-portal/registry-item.json b/registry/blocks/vfx-portal/registry-item.json
index 6273526c14..5ef89019ba 100644
--- a/registry/blocks/vfx-portal/registry-item.json
+++ b/registry/blocks/vfx-portal/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 10,
"tags": [
- "vfx",
"html-in-canvas",
"webgl"
],
diff --git a/registry/blocks/vfx-shatter/registry-item.json b/registry/blocks/vfx-shatter/registry-item.json
index dbf76ef1e1..67cb856951 100644
--- a/registry/blocks/vfx-shatter/registry-item.json
+++ b/registry/blocks/vfx-shatter/registry-item.json
@@ -11,7 +11,6 @@
},
"duration": 12,
"tags": [
- "vfx",
"html-in-canvas",
"webgl"
],
diff --git a/registry/blocks/vfx-text-cursor/registry-item.json b/registry/blocks/vfx-text-cursor/registry-item.json
index ed5ea9baf3..62d94ac488 100644
--- a/registry/blocks/vfx-text-cursor/registry-item.json
+++ b/registry/blocks/vfx-text-cursor/registry-item.json
@@ -12,7 +12,6 @@
"duration": 8,
"tags": [
"html-in-canvas",
- "vfx",
"text",
"shader",
"cursor",