Skip to content

🎥 Make videos programmatically with React

create-video: Add recommended agent skills installation

Igor Samokhovets707f0d4f2a48
diff --git a/packages/create-video/src/ask-skills.ts b/packages/create-video/src/ask-skills.ts
index 53214bcb1b..85805d64d4 100644
--- a/packages/create-video/src/ask-skills.ts
+++ b/packages/create-video/src/ask-skills.ts
@@ -1,21 +1,33 @@
import {makeHyperlink} from './hyperlinks/make-link';
-import prompts from './prompts';
+import {selectAsync} from './prompts';
-export const askSkills = async () => {
+export type SkillsInstallation = 'recommended' | 'choose';
+
+export const askSkills = async (): Promise<SkillsInstallation | null> => {
const link = makeHyperlink({
text: 'agent skills',
url: 'https://remotion.dev/docs/ai/skills',
fallback: 'agent skills',
});
- const {answer} = await prompts({
- type: 'toggle',
- name: 'answer',
+ return (await selectAsync({
message: `Add ${link}?`,
- initial: true,
- active: 'Yes',
- inactive: 'No',
- });
-
- return answer as boolean;
+ initial: 0,
+ choices: [
+ {
+ title: 'Install all skills',
+ description: 'Bundled in remotion-best-practices (recommended)',
+ value: 'recommended',
+ },
+ {
+ title: 'Choose individual skills',
+ description: 'Select which skills to install',
+ value: 'choose',
+ },
+ {
+ title: 'Skip skill installation',
+ value: null,
+ },
+ ],
+ })) as SkillsInstallation | null;
};
diff --git a/packages/create-video/src/init.ts b/packages/create-video/src/init.ts
index d0d1984c05..b6e45f15e2 100644
--- a/packages/create-video/src/init.ts
+++ b/packages/create-video/src/init.ts
@@ -165,7 +165,7 @@ export const init = async () => {
: await askTailwind()
: false;
- const shouldInstallSkills = isYesFlagSelected() ? false : await askSkills();
+ const skillsInstallation = isYesFlagSelected() ? null : await askSkills();
const pkgManager = selectPackageManager();
const pkgManagerVersion = await getPackageManagerVersionOrNull(pkgManager);
@@ -208,8 +208,8 @@ export const init = async () => {
await getGitStatus(projectRoot);
}
- if (shouldInstallSkills) {
- await installSkills(projectRoot);
+ if (skillsInstallation !== null) {
+ await installSkills(projectRoot, skillsInstallation);
}
const relativeToCurrent = path.relative(process.cwd(), projectRoot);
diff --git a/packages/create-video/src/install-skills.ts b/packages/create-video/src/install-skills.ts
index 48ba43c0ef..86056311ba 100644
--- a/packages/create-video/src/install-skills.ts
+++ b/packages/create-video/src/install-skills.ts
@@ -1,21 +1,31 @@
import execa from 'execa';
+import type {SkillsInstallation} from './ask-skills';
import {Log} from './log';
-export const installSkills = async (projectRoot: string) => {
+export const installSkills = async (
+ projectRoot: string,
+ selection: SkillsInstallation,
+) => {
const command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
+ const args = [
+ '-y',
+ '--loglevel=error',
+ 'add',
+ 'remotion-dev/skills',
+ ...(selection === 'recommended'
+ ? ['--skill', 'remotion-best-practices', '--yes']
+ : []),
+ ];
try {
- await execa(
- command,
- ['-y', '--loglevel=error', '[email protected]', 'add', 'remotion-dev/skills'],
- {
- cwd: projectRoot,
- stdio: 'inherit',
- },
- );
+ await execa(command, args, {
+ cwd: projectRoot,
+ stdio: 'inherit',
+ });
} catch (e) {
Log.error('Error installing skills:', e);
Log.error('You can install them manually by running:');
- Log.error(' npx skills add remotion-dev/skills');
+ Log.error(` npx ${args.join(' ')}`);
}
};