fix(cli): add --skill alias and fix agent detection

- Add --skill as alias for --skills option (install command)
- Fix sync command to always detect agent instead of using default 'universal'
- Auto-install npm dependencies for skills with package.json
This commit is contained in:
Rohit Ghumare
2026-02-02 12:07:41 +00:00
parent 8496e3c63c
commit 3565daa7f1
2 changed files with 28 additions and 9 deletions
+23 -3
View File
@@ -1,5 +1,9 @@
import { existsSync, mkdirSync, cpSync, rmSync, symlinkSync } from 'node:fs';
import { join } from 'node:path';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
import { Command, Option } from 'clipanion';
import { detectProvider, isLocalPath, getProvider, evaluateSkillDirectory } from '@skillkit/core';
import type { SkillMetadata, GitProvider, AgentType } from '@skillkit/core';
@@ -42,7 +46,8 @@ export class InstallCommand extends Command {
['Install from GitHub', '$0 install owner/repo'],
['Install from GitLab', '$0 install gitlab:owner/repo'],
['Install from Bitbucket', '$0 install bitbucket:owner/repo'],
['Install specific skills (CI/CD)', '$0 install owner/repo --skills=pdf,xlsx'],
['Install specific skill', '$0 install owner/repo --skill=pdf'],
['Install multiple skills (CI/CD)', '$0 install owner/repo --skills=pdf,xlsx'],
['Install all skills non-interactively', '$0 install owner/repo --all'],
['Install from local path', '$0 install ./my-skills'],
['Install globally', '$0 install owner/repo --global'],
@@ -53,7 +58,7 @@ export class InstallCommand extends Command {
source = Option.String({ required: true });
skills = Option.String('--skills,-s', {
skills = Option.String('--skills,--skill,-s', {
description: 'Comma-separated list of skills to install (non-interactive)',
});
@@ -143,7 +148,7 @@ export class InstallCommand extends Command {
}
console.log('');
console.log(colors.muted(`Total: ${discoveredSkills.length} skill(s)`));
console.log(colors.muted('To install: skillkit install <source> --skills=skill1,skill2'));
console.log(colors.muted('To install: skillkit install <source> --skill=name'));
}
const cleanupPath = result.tempRoot || result.path;
@@ -334,6 +339,21 @@ export class InstallCommand extends Command {
if (isSymlinkMode && primaryPath === null) {
primaryPath = targetPath;
}
// Auto-install npm dependencies if package.json exists
const packageJsonPath = join(targetPath, 'package.json');
if (existsSync(packageJsonPath)) {
s.stop(`Installed ${skillName} to ${adapter.name}`);
s.start(`Installing npm dependencies for ${skillName}...`);
try {
await execFileAsync('npm', ['install', '--production'], { cwd: targetPath });
s.stop(`Installed dependencies for ${skillName}`);
} catch (npmErr) {
s.stop(colors.warning(`Dependencies failed for ${skillName}`));
console.log(colors.muted('Run manually: npm install in ' + targetPath));
}
s.start(`Finishing ${skillName} installation...`);
}
}
const metadata: SkillMetadata = {
+5 -6
View File
@@ -1,7 +1,7 @@
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
import { dirname } from 'node:path';
import { Command, Option } from 'clipanion';
import { loadConfig, findAllSkills } from '@skillkit/core';
import { findAllSkills } from '@skillkit/core';
import type { AgentType } from '@skillkit/core';
import { getAdapter, detectAgent, getAllAdapters } from '@skillkit/agents';
import { getSearchDirs, getAgentConfigPath } from '../helpers.js';
@@ -67,10 +67,9 @@ export class SyncCommand extends Command {
if (this.agent) {
agentType = this.agent as AgentType;
} else if (isInteractive) {
// Let user select agent
// Let user select agent - always detect, don't rely on default config
s.start('Detecting agent...');
const config = loadConfig();
const detected = config.agent || (await detectAgent());
const detected = await detectAgent();
s.stop(`Detected: ${formatAgent(detected)}`);
const allAgents = getAllAdapters().map(a => a.type);
@@ -92,8 +91,8 @@ export class SyncCommand extends Command {
agentType = agentResult as AgentType;
} else {
const config = loadConfig();
agentType = config.agent || (await detectAgent());
// Non-interactive: always detect, don't rely on default config
agentType = await detectAgent();
}
const adapter = getAdapter(agentType);