mirror of
https://github.com/rmyndharis/antigravity-skills.git
synced 2026-09-19 02:19:16 +08:00
feat: add installed and update commands to CLI
This commit is contained in:
+92
-3
@@ -45,7 +45,7 @@ program
|
||||
.option('-a, --all', 'Install ALL skills')
|
||||
.action(async (skillName, options) => {
|
||||
const targetDir = options.global ? GLOBAL_SKILLS_DIR : LOCAL_SKILLS_DIR;
|
||||
|
||||
|
||||
if (!skillName && !options.all) {
|
||||
console.error(chalk.red('Error: Please specify a skill name or use --all'));
|
||||
process.exit(1);
|
||||
@@ -55,7 +55,7 @@ program
|
||||
await fs.ensureDir(targetDir);
|
||||
console.log(chalk.gray(`Target directory: ${targetDir}`));
|
||||
|
||||
const skillsToInstall = options.all
|
||||
const skillsToInstall = options.all
|
||||
? (await fs.readdir(SKILLS_SOURCE_DIR)).filter(f => !f.startsWith('.'))
|
||||
: [skillName];
|
||||
|
||||
@@ -71,7 +71,7 @@ program
|
||||
await fs.copy(sourcePath, destPath, { overwrite: true });
|
||||
console.log(`${chalk.green('✔ Installed:')} ${skill}`);
|
||||
}
|
||||
|
||||
|
||||
console.log(chalk.bold.green('\nInstallation complete!'));
|
||||
console.log('Restart your agent session to see changes.');
|
||||
|
||||
@@ -81,4 +81,93 @@ program
|
||||
}
|
||||
});
|
||||
|
||||
program
|
||||
.command('installed')
|
||||
.description('List skills installed in your workspace')
|
||||
.option('-g, --global', 'List globally installed skills')
|
||||
.action(async (options) => {
|
||||
const targetDir = options.global ? GLOBAL_SKILLS_DIR : LOCAL_SKILLS_DIR;
|
||||
|
||||
try {
|
||||
if (!await fs.pathExists(targetDir)) {
|
||||
console.log(chalk.yellow(`No skills directory found at: ${targetDir}`));
|
||||
return;
|
||||
}
|
||||
|
||||
const installedSkills = await fs.readdir(targetDir);
|
||||
const filteredSkills = installedSkills.filter(f => !f.startsWith('.'));
|
||||
|
||||
if (filteredSkills.length === 0) {
|
||||
console.log(chalk.yellow('No skills installed.'));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(chalk.bold(`\nInstalled Skills (${options.global ? 'Global' : 'Local'}):\n`));
|
||||
filteredSkills.forEach(skill => {
|
||||
console.log(`- ${chalk.green(skill)}`);
|
||||
});
|
||||
console.log(chalk.gray(`\nLocation: ${targetDir}`));
|
||||
|
||||
} catch (err) {
|
||||
console.error(chalk.red('Error listing installed skills:'), err.message);
|
||||
}
|
||||
});
|
||||
|
||||
program
|
||||
.command('update [skillName]')
|
||||
.description('Update installed skills from the vault')
|
||||
.option('-g, --global', 'Update globally installed skills')
|
||||
.action(async (skillName, options) => {
|
||||
const targetDir = options.global ? GLOBAL_SKILLS_DIR : LOCAL_SKILLS_DIR;
|
||||
|
||||
try {
|
||||
if (!await fs.pathExists(targetDir)) {
|
||||
console.error(chalk.red(`No installation found at: ${targetDir}`));
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine what to update
|
||||
let skillsToUpdate = [];
|
||||
if (skillName) {
|
||||
// Update specific skill if it exists
|
||||
if (await fs.pathExists(path.join(targetDir, skillName))) {
|
||||
skillsToUpdate.push(skillName);
|
||||
} else {
|
||||
console.error(chalk.red(`Skill '${skillName}' is not installed.`));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Update ALL installed skills
|
||||
const installed = await fs.readdir(targetDir);
|
||||
skillsToUpdate = installed.filter(f => !f.startsWith('.'));
|
||||
}
|
||||
|
||||
if (skillsToUpdate.length === 0) {
|
||||
console.log(chalk.yellow('No skills to update.'));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(chalk.bold(`Updating ${skillsToUpdate.length} skills...\n`));
|
||||
|
||||
for (const skill of skillsToUpdate) {
|
||||
const sourcePath = path.join(SKILLS_SOURCE_DIR, skill);
|
||||
const destPath = path.join(targetDir, skill);
|
||||
|
||||
if (!await fs.pathExists(sourcePath)) {
|
||||
console.warn(chalk.yellow(`⚠ Warning: Skill '${skill}' no longer exists in vault. Skipping.`));
|
||||
continue;
|
||||
}
|
||||
|
||||
await fs.copy(sourcePath, destPath, { overwrite: true });
|
||||
console.log(`${chalk.green('✔ Updated:')} ${skill}`);
|
||||
}
|
||||
|
||||
console.log(chalk.bold.green('\nUpdate complete!'));
|
||||
|
||||
} catch (err) {
|
||||
console.error(chalk.red('Update failed:'), err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
Reference in New Issue
Block a user