From 3565daa7f183366b3abe23206201d506ec577ea1 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Mon, 2 Feb 2026 12:07:41 +0000 Subject: [PATCH] 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 --- packages/cli/src/commands/install.ts | 26 +++++++++++++++++++++++--- packages/cli/src/commands/sync.ts | 11 +++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/commands/install.ts b/packages/cli/src/commands/install.ts index 97d823f4..29d86bc1 100644 --- a/packages/cli/src/commands/install.ts +++ b/packages/cli/src/commands/install.ts @@ -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 --skills=skill1,skill2')); + console.log(colors.muted('To install: skillkit install --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 = { diff --git a/packages/cli/src/commands/sync.ts b/packages/cli/src/commands/sync.ts index 3498082c..99d2a1ae 100644 --- a/packages/cli/src/commands/sync.ts +++ b/packages/cli/src/commands/sync.ts @@ -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);