diff --git a/README.md b/README.md index 04aef8ed..18d24da8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![npm downloads](https://img.shields.io/npm/dm/skillkit.svg)](https://www.npmjs.com/package/skillkit) [![GitHub Package](https://img.shields.io/badge/GitHub%20Package-@rohitg00/skillkit-blue?logo=github)](https://github.com/rohitg00/skillkit/pkgs/npm/skillkit) [![CI](https://github.com/rohitg00/skillkit/actions/workflows/ci.yml/badge.svg)](https://github.com/rohitg00/skillkit/actions/workflows/ci.yml) -[![Website](https://img.shields.io/badge/Website-skillkit-black)](https://rohitg00.github.io/skillkit/) +[![Website](https://img.shields.io/badge/Website-agenstskills.com-black)](https://agenstskills.com) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ## Supercharge Every AI Coding Agent @@ -32,6 +32,10 @@ npm install -g skillkit ## See It In Action + + +> **Note:** If the video doesn't play above, [watch it here](https://raw.githubusercontent.com/rohitg00/skillkit/main/docs/skillkit/public/skillkit-demo.mp4) + ```bash # Install a skill for ALL your agents at once skillkit install anthropics/skills --agent claude-code,cursor,windsurf @@ -46,8 +50,6 @@ skillkit recommend # > 85% match: nextjs-app-router ``` -![SkillKit Demo](https://raw.githubusercontent.com/rohitg00/skillkit/main/skillkit.gif) - ## Beautiful CLI Experience SkillKit features a polished, interactive CLI with visual feedback: diff --git a/apps/skillkit/src/cli.ts b/apps/skillkit/src/cli.ts index 8d97f8e3..e79cf147 100644 --- a/apps/skillkit/src/cli.ts +++ b/apps/skillkit/src/cli.ts @@ -47,6 +47,15 @@ import { AgentTranslateCommand, AgentSyncCommand, AgentValidateCommand, + // New commands (Phase 21) + CheckCommand, + FindCommand, + ManifestCommand, + ManifestInitCommand, + ManifestAddCommand, + ManifestRemoveCommand, + ManifestInstallCommand, + ManifestGenerateCommand, } from '@skillkit/cli'; const __filename = fileURLToPath(import.meta.url); @@ -108,4 +117,13 @@ cli.register(AgentTranslateCommand); cli.register(AgentSyncCommand); cli.register(AgentValidateCommand); +cli.register(CheckCommand); +cli.register(FindCommand); +cli.register(ManifestCommand); +cli.register(ManifestInitCommand); +cli.register(ManifestAddCommand); +cli.register(ManifestRemoveCommand); +cli.register(ManifestInstallCommand); +cli.register(ManifestGenerateCommand); + cli.runExit(process.argv.slice(2)); diff --git a/docs/skillkit/App.tsx b/docs/skillkit/App.tsx index 414993af..0f3d6496 100644 --- a/docs/skillkit/App.tsx +++ b/docs/skillkit/App.tsx @@ -5,6 +5,7 @@ import { Agents } from './components/Agents'; import { Footer } from './components/Footer'; import { SkillGenerator } from './components/SkillGenerator'; import { SkillSubmitForm } from './components/SkillSubmitForm'; +import { Commands } from './components/Commands'; const GITHUB_ICON = ( @@ -61,6 +62,7 @@ export default function App(): React.ReactElement { +
diff --git a/docs/skillkit/components/Commands.tsx b/docs/skillkit/components/Commands.tsx new file mode 100644 index 00000000..238f7db6 --- /dev/null +++ b/docs/skillkit/components/Commands.tsx @@ -0,0 +1,103 @@ +import React, { useState } from 'react'; + +interface CommandGroup { + name: string; + commands: Array<{ cmd: string; desc: string }>; +} + +const COMMAND_GROUPS: CommandGroup[] = [ + { + name: 'Core', + commands: [ + { cmd: 'install', desc: 'Install from GitHub/GitLab/local' }, + { cmd: 'sync', desc: 'Sync skills across agents' }, + { cmd: 'translate', desc: 'Convert between agent formats' }, + { cmd: 'update', desc: 'Update installed skills' }, + ], + }, + { + name: 'Discovery', + commands: [ + { cmd: 'find', desc: 'Search marketplace (15K+ skills)' }, + { cmd: 'recommend', desc: 'AI-powered suggestions' }, + { cmd: 'check', desc: 'Dry-run update check' }, + { cmd: 'list', desc: 'View installed skills' }, + ], + }, + { + name: 'Team', + commands: [ + { cmd: 'manifest init', desc: 'Create .skills file' }, + { cmd: 'manifest install', desc: 'Install from manifest' }, + { cmd: 'team share', desc: 'Share skills via Git' }, + { cmd: 'publish', desc: 'Submit to marketplace' }, + ], + }, + { + name: 'Advanced', + commands: [ + { cmd: 'ui', desc: 'Launch terminal UI' }, + { cmd: 'workflow run', desc: 'Execute skill pipelines' }, + { cmd: 'command generate', desc: 'Create /slash commands' }, + { cmd: 'cicd init', desc: 'Generate CI templates' }, + ], + }, +]; + +export function Commands(): React.ReactElement { + const [activeGroup, setActiveGroup] = useState(0); + const group = COMMAND_GROUPS[activeGroup]; + + return ( +
+
+
+

30+ Commands

+

+ Everything you need from the terminal. +

+
+ +
+ {COMMAND_GROUPS.map((g, i) => { + const isActive = i === activeGroup; + const buttonClass = isActive + ? 'border-white text-white bg-zinc-900' + : 'border-zinc-800 text-zinc-500 hover:border-zinc-600 hover:text-zinc-300'; + return ( + + ); + })} +
+ +
+
+ {group.commands.map((c) => ( +
+ $ + skillkit {c.cmd} + → + {c.desc} +
+ ))} +
+
+ +
+ + Run skillkit --help for all commands + +
+
+ + ); +} diff --git a/docs/skillkit/components/Features.tsx b/docs/skillkit/components/Features.tsx index 058d4f66..4a535490 100644 --- a/docs/skillkit/components/Features.tsx +++ b/docs/skillkit/components/Features.tsx @@ -9,7 +9,7 @@ interface Feature { const FEATURES: Feature[] = [ { title: 'Multi-Agent', - description: 'Write once, deploy to 17+ AI coding agents automatically.', + description: 'Deploy to 17 AI coding agents with one command.', icon: ( @@ -17,57 +17,58 @@ const FEATURES: Feature[] = [ ) }, { - title: 'Smart Discovery', - description: 'AI analyzes your stack and recommends skills.', + title: 'Terminal UI', + description: 'Beautiful interactive TUI for browsing & installing.', icon: ( - + ) }, { - title: 'Persistent Memory', - description: 'Save learnings as reusable skills.', + title: 'Plugins', + description: 'Extend with custom plugins & hooks.', icon: ( - + ) }, { - title: 'Team Sync', - description: 'Share skills via Git across your team.', + title: 'Manifest', + description: '.skills file for team-wide consistency.', icon: ( - + ) }, { - title: 'Testing', - description: 'Built-in framework for skill validation.', + title: 'CI/CD', + description: 'GitHub, GitLab, CircleCI templates included.', icon: ( - + ) }, { - title: 'Workflows', - description: 'Compose multi-step automated pipelines.', + title: 'Slash Commands', + description: 'Generate /commands for Claude, Cursor & more.', icon: ( - + ) } ]; const COMPARISONS = [ - ['Agents', '1', '17+'], + ['Agents', '1', '17'], ['Translation', 'Manual', 'Auto'], - ['Sharing', 'Copy/paste', 'Git sync'], - ['Discovery', 'Forums', 'AI-powered'], + ['Sharing', 'Copy/paste', '.skills manifest'], + ['Discovery', 'Forums', 'CLI + AI'], + ['CI/CD', 'Custom', 'Templates'], ] as const; export function Features(): React.ReactElement { @@ -82,15 +83,15 @@ export function Features(): React.ReactElement {

-
17+
+
17
Agents
-
1
-
Command
+
30+
+
Commands
-
∞
+
15K
Skills
diff --git a/docs/skillkit/components/Hero.tsx b/docs/skillkit/components/Hero.tsx index cb5fe73d..b16d141b 100644 --- a/docs/skillkit/components/Hero.tsx +++ b/docs/skillkit/components/Hero.tsx @@ -14,16 +14,17 @@ interface TerminalLine { } const TERMINAL_LINES: TerminalLine[] = [ - { type: 'cmd', text: 'skillkit init' }, - { type: 'out', text: '→ Next.js + TypeScript detected' }, + { type: 'cmd', text: 'skillkit find react' }, + { type: 'out', text: ' ■ react-patterns ★★★★★' }, + { type: 'out', text: ' ■ react-testing ★★★★☆' }, { type: 'cmd', text: 'skillkit install anthropics/skills' }, - { type: 'out', text: '→ Installed 3 skills' }, - { type: 'cmd', text: 'skillkit sync --all' }, - { type: 'out', text: ' .claude/skills/' }, - { type: 'out', text: ' .cursor/skills/' }, - { type: 'out', text: ' .windsurf/skills/' }, - { type: 'cmd', text: 'skillkit translate --to codex,copilot' }, - { type: 'out', text: '→ 2 formats generated' }, + { type: 'out', text: '→ 3 skills → 5 agents' }, + { type: 'cmd', text: 'skillkit ui' }, + { type: 'out', text: '→ Launching TUI...' }, + { type: 'cmd', text: 'skillkit check' }, + { type: 'out', text: ' ✓ All skills up to date' }, + { type: 'cmd', text: 'skillkit manifest install' }, + { type: 'out', text: '→ 12 skills from .skills' }, ]; const FADE_ANIMATION_STYLES = ` @@ -123,7 +124,7 @@ export function Hero(): React.ReactElement {
- v1.7.1 + v1.7.5

@@ -132,8 +133,8 @@ export function Hero(): React.ReactElement {

- Portable, reusable skills that work across Claude Code, Cursor, Codex, - Windsurf, GitHub Copilot, and 12 more agents. + One CLI to install, sync, and manage skills across Claude Code, Cursor, + Windsurf, Copilot, and 13 more agents. 15,000+ skills ready to use.

diff --git a/docs/skillkit/public/skillkit-demo.mp4 b/docs/skillkit/public/skillkit-demo.mp4 new file mode 100644 index 00000000..3214a6a5 Binary files /dev/null and b/docs/skillkit/public/skillkit-demo.mp4 differ diff --git a/packages/cli/src/commands/check.ts b/packages/cli/src/commands/check.ts new file mode 100644 index 00000000..85890d6a --- /dev/null +++ b/packages/cli/src/commands/check.ts @@ -0,0 +1,211 @@ +import { existsSync } from 'node:fs'; +import { join } from 'node:path'; +import { Command, Option } from 'clipanion'; +import { findAllSkills, findSkill, detectProvider, isLocalPath } from '@skillkit/core'; +import { getSearchDirs, loadSkillMetadata } from '../helpers.js'; +import { + colors, + symbols, + spinner, + step, + success, + warn, + header, +} from '../onboarding/index.js'; + +interface UpdateInfo { + name: string; + currentVersion?: string; + hasUpdate: boolean; + error?: string; +} + +export class CheckCommand extends Command { + static override paths = [['check']]; + + static override usage = Command.Usage({ + description: 'Check for available skill updates (dry-run)', + details: ` + Checks if installed skills have updates available from their sources. + Does not modify any files - just reports what would be updated. + `, + examples: [ + ['Check all skills for updates', '$0 check'], + ['Check specific skills', '$0 check pdf xlsx'], + ['Show detailed output', '$0 check --verbose'], + ], + }); + + skills = Option.Rest(); + + verbose = Option.Boolean('--verbose,-v', false, { + description: 'Show detailed information', + }); + + quiet = Option.Boolean('--quiet,-q', false, { + description: 'Minimal output', + }); + + async execute(): Promise { + const searchDirs = getSearchDirs(); + const s = spinner(); + + if (!this.quiet) { + header('Check Updates'); + } + + let skillsToCheck; + + if (this.skills.length > 0) { + const foundSkills = this.skills.map(name => ({ + name, + skill: findSkill(name, searchDirs), + })); + + skillsToCheck = foundSkills + .filter((s): s is { name: string; skill: NonNullable } => s.skill !== null) + .map(s => s.skill); + + const notFound = foundSkills.filter(s => s.skill === null).map(s => s.name); + if (notFound.length > 0) { + warn(`Skills not found: ${notFound.join(', ')}`); + } + } else { + skillsToCheck = findAllSkills(searchDirs); + } + + if (skillsToCheck.length === 0) { + warn('No skills to check'); + return 0; + } + + if (!this.quiet) { + step(`Checking ${skillsToCheck.length} skill(s) for updates...`); + console.log(''); + } + + const results: UpdateInfo[] = []; + let updatesAvailable = 0; + + for (const skill of skillsToCheck) { + const metadata = loadSkillMetadata(skill.path); + + if (!metadata) { + results.push({ + name: skill.name, + hasUpdate: false, + error: 'No metadata (reinstall needed)', + }); + continue; + } + + if (this.verbose) { + s.start(`Checking ${skill.name}...`); + } + + try { + if (isLocalPath(metadata.source)) { + const localPath = metadata.subpath + ? join(metadata.source, metadata.subpath) + : metadata.source; + + if (!existsSync(localPath)) { + results.push({ + name: skill.name, + hasUpdate: false, + error: 'Local source missing', + }); + if (this.verbose) s.stop(`${skill.name}: source missing`); + continue; + } + + const sourceSkillMd = join(localPath, 'SKILL.md'); + const installedSkillMd = join(skill.path, 'SKILL.md'); + + if (existsSync(sourceSkillMd) && existsSync(installedSkillMd)) { + const { statSync } = await import('node:fs'); + const sourceTime = statSync(sourceSkillMd).mtime; + const installedTime = statSync(installedSkillMd).mtime; + + if (sourceTime > installedTime) { + results.push({ name: skill.name, hasUpdate: true }); + updatesAvailable++; + if (this.verbose) s.stop(`${skill.name}: update available`); + } else { + results.push({ name: skill.name, hasUpdate: false }); + if (this.verbose) s.stop(`${skill.name}: up to date`); + } + } else { + results.push({ name: skill.name, hasUpdate: false }); + if (this.verbose) s.stop(`${skill.name}: up to date`); + } + } else { + const provider = detectProvider(metadata.source); + + if (!provider) { + results.push({ + name: skill.name, + hasUpdate: false, + error: 'Unknown provider', + }); + if (this.verbose) s.stop(`${skill.name}: unknown provider`); + continue; + } + + results.push({ + name: skill.name, + hasUpdate: false, + currentVersion: metadata.updatedAt || metadata.installedAt, + }); + if (this.verbose) s.stop(`${skill.name}: remote source (run update to sync)`); + } + } catch (err) { + results.push({ + name: skill.name, + hasUpdate: false, + error: err instanceof Error ? err.message : 'Check failed', + }); + if (this.verbose) s.stop(`${skill.name}: error`); + } + } + + console.log(''); + + const withUpdates = results.filter(r => r.hasUpdate); + const upToDate = results.filter(r => !r.hasUpdate && !r.error); + const withErrors = results.filter(r => r.error); + + if (withUpdates.length > 0) { + console.log(colors.primary('Updates available:')); + for (const r of withUpdates) { + console.log(` ${colors.success(symbols.arrowUp)} ${colors.primary(r.name)}`); + } + console.log(''); + } + + if (upToDate.length > 0 && this.verbose) { + console.log(colors.muted('Up to date:')); + for (const r of upToDate) { + console.log(` ${colors.muted(symbols.success)} ${colors.muted(r.name)}`); + } + console.log(''); + } + + if (withErrors.length > 0) { + console.log(colors.warning('Could not check:')); + for (const r of withErrors) { + console.log(` ${colors.warning(symbols.warning)} ${r.name}: ${colors.muted(r.error || 'unknown')}`); + } + console.log(''); + } + + if (updatesAvailable > 0) { + success(`${updatesAvailable} update(s) available`); + console.log(colors.muted('Run `skillkit update` to install updates')); + } else { + success('All skills are up to date'); + } + + return 0; + } +} diff --git a/packages/cli/src/commands/find.ts b/packages/cli/src/commands/find.ts new file mode 100644 index 00000000..6b143092 --- /dev/null +++ b/packages/cli/src/commands/find.ts @@ -0,0 +1,181 @@ +import { Command, Option } from 'clipanion'; +import { + colors, + symbols, + spinner, + step, + isCancel, + select, + header, +} from '../onboarding/index.js'; + +interface SkillResult { + name: string; + description?: string; + source: string; + repoName: string; +} + +import skillsData from '../../../../marketplace/skills.json' with { type: 'json' }; +import sourcesData from '../../../../marketplace/sources.json' with { type: 'json' }; + +export class FindCommand extends Command { + static override paths = [['find'], ['search']]; + + static override usage = Command.Usage({ + description: 'Search for skills in the marketplace', + details: ` + Quickly find and install skills from the marketplace. + Interactive mode lets you browse and install in one step. + `, + examples: [ + ['Interactive search', '$0 find'], + ['Search for specific skill', '$0 find pdf'], + ['Search with keyword', '$0 find "nextjs"'], + ['List top skills', '$0 find --top'], + ], + }); + + query = Option.String({ required: false }); + + top = Option.Boolean('--top,-t', false, { + description: 'Show top/featured skills', + }); + + limit = Option.String('--limit,-l', '10', { + description: 'Maximum results to show', + }); + + install = Option.Boolean('--install,-i', false, { + description: 'Prompt to install after finding', + }); + + quiet = Option.Boolean('--quiet,-q', false, { + description: 'Minimal output (just list skills)', + }); + + async execute(): Promise { + const s = spinner(); + const limit = parseInt(this.limit, 10) || 10; + + if (!this.quiet) { + header('Find Skills'); + } + + const allSkills: SkillResult[] = (skillsData.skills || []).map((skill: { name: string; description?: string; source?: string; repo?: string }) => ({ + name: skill.name, + description: skill.description, + source: skill.source || '', + repoName: skill.repo || skill.source?.split('/').pop() || '', + })); + + let results: SkillResult[]; + + if (this.top) { + const featured = sourcesData.sources + .filter((s: { official?: boolean }) => s.official) + .slice(0, 5); + + results = allSkills + .filter(skill => featured.some((f: { source: string }) => skill.source.includes(f.source))) + .slice(0, limit); + + if (!this.quiet) { + step('Showing featured skills'); + } + } else if (this.query) { + const query = this.query.toLowerCase(); + + s.start('Searching...'); + + results = allSkills.filter(skill => + skill.name.toLowerCase().includes(query) || + skill.description?.toLowerCase().includes(query) || + skill.source.toLowerCase().includes(query) || + skill.repoName.toLowerCase().includes(query) + ).slice(0, limit); + + s.stop(`Found ${results.length} skill(s)`); + } else { + if (!this.quiet) { + step('Enter a search term or browse featured skills'); + } + + const { text } = await import('../onboarding/prompts.js'); + + const searchResult = await text({ + message: 'Search skills', + placeholder: 'e.g., pdf, nextjs, testing', + }); + + if (isCancel(searchResult)) { + return 0; + } + + const query = (searchResult as string).toLowerCase(); + + if (query) { + s.start('Searching...'); + results = allSkills.filter(skill => + skill.name.toLowerCase().includes(query) || + skill.description?.toLowerCase().includes(query) || + skill.source.toLowerCase().includes(query) || + skill.repoName.toLowerCase().includes(query) + ).slice(0, limit); + s.stop(`Found ${results.length} skill(s)`); + } else { + results = allSkills.slice(0, limit); + } + } + + if (results.length === 0) { + console.log(colors.muted('No skills found matching your search')); + console.log(''); + console.log(colors.muted('Try:')); + console.log(colors.muted(' skillkit find --top # Show featured skills')); + console.log(colors.muted(' skillkit ui # Browse in TUI')); + return 0; + } + + console.log(''); + + for (const skill of results) { + const desc = skill.description + ? colors.muted(` - ${skill.description.slice(0, 50)}${skill.description.length > 50 ? '...' : ''}`) + : ''; + console.log(` ${colors.success(symbols.bullet)} ${colors.primary(skill.name)}${desc}`); + if (!this.quiet && skill.source) { + console.log(` ${colors.muted(skill.source)}`); + } + } + + console.log(''); + console.log(colors.muted(`Showing ${results.length} of ${allSkills.length} skills`)); + console.log(''); + + if (this.install || (!this.query && !this.top && process.stdin.isTTY)) { + const installResult = await select({ + message: 'Install a skill?', + options: [ + { value: 'none', label: 'No, just browsing' }, + ...results.slice(0, 5).map(skill => ({ + value: skill.source, + label: skill.name, + hint: skill.repoName, + })), + ], + initialValue: 'none', + }); + + if (!isCancel(installResult) && installResult !== 'none') { + console.log(''); + console.log(colors.cyan('To install, run:')); + console.log(` ${colors.bold(`skillkit install ${installResult}`)}`); + } + } else { + console.log(colors.muted('To install: skillkit install ')); + } + + return 0; + } +} diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 301b205e..59e58372 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -41,3 +41,14 @@ export { AgentSyncCommand, AgentValidateCommand, } from './agent.js'; + +export { CheckCommand } from './check.js'; +export { FindCommand } from './find.js'; +export { + ManifestCommand, + ManifestInitCommand, + ManifestAddCommand, + ManifestRemoveCommand, + ManifestInstallCommand, + ManifestGenerateCommand, +} from './manifest.js'; diff --git a/packages/cli/src/commands/install.ts b/packages/cli/src/commands/install.ts index 1f1e5f84..122b2657 100644 --- a/packages/cli/src/commands/install.ts +++ b/packages/cli/src/commands/install.ts @@ -14,7 +14,7 @@ import { getAgentIcon, isCancel, spinner, - agentMultiselect, + quickAgentSelect, skillMultiselect, selectInstallMethod, confirm, @@ -197,20 +197,15 @@ export class InstallCommand extends Command { // Explicitly specified agents targetAgents = this.agent as AgentType[]; } else if (isInteractive) { - // Interactive agent selection const allAgentTypes = getAllAdapters().map(a => a.type); - const detectedAgent = await detectAgent(); - - // Get last selected agents or use detected const lastAgents = getLastAgents(); - const initialAgents = lastAgents.length > 0 - ? lastAgents.filter(a => allAgentTypes.includes(a as AgentType)) - : [detectedAgent]; - const agentResult = await agentMultiselect({ - message: 'Install to which agents?', + step(`Detected ${allAgentTypes.length} agents`); + + const agentResult = await quickAgentSelect({ + message: 'Install to', agents: allAgentTypes, - initialValues: initialAgents, + lastSelected: lastAgents, }); if (isCancel(agentResult)) { @@ -218,7 +213,7 @@ export class InstallCommand extends Command { return 0; } - targetAgents = agentResult as AgentType[]; + targetAgents = (agentResult as { agents: string[] }).agents as AgentType[]; // Save selection for next time saveLastAgents(targetAgents); diff --git a/packages/cli/src/commands/manifest.ts b/packages/cli/src/commands/manifest.ts new file mode 100644 index 00000000..89083fbf --- /dev/null +++ b/packages/cli/src/commands/manifest.ts @@ -0,0 +1,325 @@ +import { Command, Option } from 'clipanion'; +import { + loadManifest, + saveManifest, + initManifest, + addToManifest, + removeFromManifest, + findManifestPath, + generateManifestFromInstalled, + findAllSkills, +} from '@skillkit/core'; +import { getSearchDirs, loadSkillMetadata } from '../helpers.js'; +import { + colors, + symbols, + spinner, + step, + success, + warn, + error, + header, + confirm, + isCancel, +} from '../onboarding/index.js'; + +export class ManifestCommand extends Command { + static override paths = [['manifest']]; + + static override usage = Command.Usage({ + description: 'Manage .skills manifest file', + details: ` + The .skills manifest file allows declarative skill management. + Commit this file to version control to share skill configurations. + `, + examples: [ + ['Show current manifest', '$0 manifest'], + ['Initialize manifest', '$0 manifest init'], + ['Add skill to manifest', '$0 manifest add owner/repo'], + ['Remove skill from manifest', '$0 manifest remove owner/repo'], + ['Install from manifest', '$0 manifest install'], + ['Generate from installed', '$0 manifest generate'], + ], + }); + + async execute(): Promise { + const manifestPath = findManifestPath(); + + if (!manifestPath) { + warn('No .skills manifest found'); + console.log(''); + console.log(colors.muted('Create one with:')); + console.log(` ${colors.cyan('skillkit manifest init')}`); + console.log(''); + console.log(colors.muted('Or generate from installed skills:')); + console.log(` ${colors.cyan('skillkit manifest generate')}`); + return 0; + } + + const manifest = loadManifest(manifestPath); + + if (!manifest) { + error('Failed to load manifest'); + return 1; + } + + header('.skills Manifest'); + console.log(colors.muted(`Path: ${manifestPath}`)); + console.log(''); + + if (manifest.skills.length === 0) { + console.log(colors.muted('No skills defined')); + } else { + console.log(colors.primary('Skills:')); + for (const skill of manifest.skills) { + const status = skill.enabled === false ? colors.muted('(disabled)') : ''; + console.log(` ${colors.success(symbols.bullet)} ${skill.source} ${status}`); + if (skill.skills) { + console.log(` ${colors.muted(`Skills: ${skill.skills.join(', ')}`)}`); + } + if (skill.agents) { + console.log(` ${colors.muted(`Agents: ${skill.agents.join(', ')}`)}`); + } + } + } + + console.log(''); + + if (manifest.agents) { + console.log(`${colors.muted('Default agents:')} ${manifest.agents.join(', ')}`); + } + + if (manifest.installMethod) { + console.log(`${colors.muted('Install method:')} ${manifest.installMethod}`); + } + + if (manifest.updatedAt) { + console.log(`${colors.muted('Updated:')} ${manifest.updatedAt}`); + } + + console.log(''); + console.log(colors.muted('Commands: init, add, remove, install, generate')); + + return 0; + } +} + +export class ManifestInitCommand extends Command { + static override paths = [['manifest', 'init']]; + + static override usage = Command.Usage({ + description: 'Initialize a new .skills manifest', + }); + + force = Option.Boolean('--force,-f', false, { + description: 'Overwrite existing manifest', + }); + + async execute(): Promise { + const existingPath = findManifestPath(); + + if (existingPath && !this.force) { + warn(`Manifest already exists: ${existingPath}`); + console.log(colors.muted('Use --force to overwrite')); + return 1; + } + + initManifest(); + success('Created .skills manifest'); + console.log(''); + console.log(colors.muted('Add skills with:')); + console.log(` ${colors.cyan('skillkit manifest add owner/repo')}`); + + return 0; + } +} + +export class ManifestAddCommand extends Command { + static override paths = [['manifest', 'add']]; + + static override usage = Command.Usage({ + description: 'Add a skill source to the manifest', + }); + + source = Option.String({ required: true }); + + skills = Option.String('--skills,-s', { + description: 'Specific skills to include (comma-separated)', + }); + + agents = Option.String('--agents,-a', { + description: 'Target agents (comma-separated)', + }); + + async execute(): Promise { + const options: { skills?: string[]; agents?: string[] } = {}; + + if (this.skills) { + options.skills = this.skills.split(',').map(s => s.trim()); + } + + if (this.agents) { + options.agents = this.agents.split(',').map(s => s.trim()); + } + + addToManifest(this.source, options); + success(`Added ${this.source} to manifest`); + + return 0; + } +} + +export class ManifestRemoveCommand extends Command { + static override paths = [['manifest', 'remove']]; + + static override usage = Command.Usage({ + description: 'Remove a skill source from the manifest', + }); + + source = Option.String({ required: true }); + + async execute(): Promise { + const result = removeFromManifest(this.source); + + if (!result) { + error('No manifest found'); + return 1; + } + + success(`Removed ${this.source} from manifest`); + + return 0; + } +} + +export class ManifestInstallCommand extends Command { + static override paths = [['manifest', 'install']]; + + static override usage = Command.Usage({ + description: 'Install all skills defined in the manifest', + }); + + yes = Option.Boolean('--yes,-y', false, { + description: 'Skip confirmation', + }); + + async execute(): Promise { + const manifest = loadManifest(); + + if (!manifest) { + error('No .skills manifest found'); + console.log(colors.muted('Create one with: skillkit manifest init')); + return 1; + } + + const enabledSkills = manifest.skills.filter(s => s.enabled !== false); + + if (enabledSkills.length === 0) { + warn('No skills to install'); + return 0; + } + + header('Install from Manifest'); + + console.log(`Installing ${enabledSkills.length} source(s):`); + for (const skill of enabledSkills) { + console.log(` ${colors.success(symbols.bullet)} ${skill.source}`); + } + console.log(''); + + if (!this.yes && process.stdin.isTTY) { + const confirmResult = await confirm({ + message: 'Proceed with installation?', + initialValue: true, + }); + + if (isCancel(confirmResult) || !confirmResult) { + return 0; + } + } + + const s = spinner(); + + for (const skill of enabledSkills) { + s.start(`Installing ${skill.source}...`); + + try { + const args = ['install', skill.source]; + + if (skill.skills) { + args.push('--skills', skill.skills.join(',')); + } + + if (skill.agents || manifest.agents) { + const agents = skill.agents || manifest.agents || []; + for (const agent of agents) { + args.push('--agent', agent); + } + } + + args.push('--yes'); + + const { execFileSync } = await import('node:child_process'); + execFileSync('skillkit', args, { + stdio: 'pipe', + encoding: 'utf-8', + }); + + s.stop(`Installed ${skill.source}`); + } catch (err) { + s.stop(colors.error(`Failed: ${skill.source}`)); + if (err instanceof Error) { + console.log(colors.muted(err.message)); + } + } + } + + success('Manifest installation complete'); + + return 0; + } +} + +export class ManifestGenerateCommand extends Command { + static override paths = [['manifest', 'generate']]; + + static override usage = Command.Usage({ + description: 'Generate manifest from currently installed skills', + }); + + output = Option.String('--output,-o', { + description: 'Output file path (default: .skills)', + }); + + async execute(): Promise { + const searchDirs = getSearchDirs(); + const installedSkills = findAllSkills(searchDirs); + + if (installedSkills.length === 0) { + warn('No installed skills found'); + return 0; + } + + step(`Found ${installedSkills.length} installed skill(s)`); + + const skillsWithMeta = installedSkills.map(skill => { + const metadata = loadSkillMetadata(skill.path); + return { + name: skill.name, + source: metadata?.source || '', + }; + }).filter(s => s.source); + + const manifest = generateManifestFromInstalled(skillsWithMeta); + + const outputPath = this.output || '.skills'; + saveManifest(manifest, outputPath); + + success(`Generated ${outputPath} with ${manifest.skills.length} source(s)`); + + console.log(''); + console.log(colors.muted('Commit this file to share skill configuration with your team.')); + + return 0; + } +} diff --git a/packages/cli/src/onboarding/index.ts b/packages/cli/src/onboarding/index.ts index 9b134286..a251092d 100644 --- a/packages/cli/src/onboarding/index.ts +++ b/packages/cli/src/onboarding/index.ts @@ -38,6 +38,7 @@ export { confirm, select, agentMultiselect, + quickAgentSelect, skillMultiselect, groupMultiselect, stepTrail, @@ -83,7 +84,7 @@ import { getLastAgents, } from './preferences.js'; -let VERSION = '1.7.5'; +let VERSION = '1.7.6'; let AGENT_COUNT = 17; export function setVersion(version: string): void { diff --git a/packages/cli/src/onboarding/prompts.ts b/packages/cli/src/onboarding/prompts.ts index de391fb4..bd49e377 100644 --- a/packages/cli/src/onboarding/prompts.ts +++ b/packages/cli/src/onboarding/prompts.ts @@ -113,6 +113,72 @@ export async function agentMultiselect(options: { }); } +export async function quickAgentSelect(options: { + message?: string; + agents: string[]; + lastSelected?: string[]; +}): Promise<{ agents: string[]; method: 'last' | 'all' | 'select' } | symbol> { + const { agents, lastSelected = [] } = options; + const hasLast = lastSelected.length > 0 && lastSelected.some(a => agents.includes(a)); + + const selectOptions: Array<{ value: string; label: string; hint?: string }> = []; + + if (hasLast) { + const validLast = lastSelected.filter(a => agents.includes(a)); + const agentList = validLast.slice(0, 3).map(formatAgent).join(', '); + const more = validLast.length > 3 ? ` +${validLast.length - 3}` : ''; + + selectOptions.push({ + value: 'last', + label: `Same as last time (Recommended)`, + hint: `${agentList}${more}`, + }); + } + + selectOptions.push({ + value: 'all', + label: 'All detected agents', + hint: `${agents.length} agent${agents.length !== 1 ? 's' : ''}`, + }); + + selectOptions.push({ + value: 'select', + label: 'Select specific agents', + hint: 'Choose manually', + }); + + const result = await clack.select({ + message: options.message || 'Install to', + options: selectOptions, + }); + + if (clack.isCancel(result)) { + return result; + } + + const method = result as 'last' | 'all' | 'select'; + + if (method === 'last') { + return { agents: lastSelected.filter(a => agents.includes(a)), method }; + } + + if (method === 'all') { + return { agents, method }; + } + + const selected = await agentMultiselect({ + message: 'Select agents', + agents, + initialValues: lastSelected.length > 0 ? lastSelected : agents, + }); + + if (clack.isCancel(selected)) { + return selected; + } + + return { agents: selected as string[], method }; +} + export interface SkillOption { name: string; description?: string; diff --git a/packages/cli/src/onboarding/theme.ts b/packages/cli/src/onboarding/theme.ts index ec5392d9..7d0f4762 100644 --- a/packages/cli/src/onboarding/theme.ts +++ b/packages/cli/src/onboarding/theme.ts @@ -48,6 +48,7 @@ export const symbols = { selected: '\u25cf', unselected: '\u25cb', pointer: '\u25b8', + bullet: '\u25cf', progressFull: '\u2588', progressEmpty: '\u2591', success: '\u2713', @@ -56,6 +57,8 @@ export const symbols = { info: '\u2139', arrowRight: '\u2192', arrowLeft: '\u2190', + arrowUp: '\u2191', + arrowDown: '\u2193', diamondOpen: '\u25c7', diamondFilled: '\u25c6', horizontalLine: '\u2500', diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index ba18da6e..9f82a9dd 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -73,5 +73,5 @@ export * from './audit/index.js'; // Custom Agents Support (Phase 19) export * from './agents/index.js'; -// Skill Translator (Phase 20 - Cross-Agent Skill Translation) export * from './skill-translator.js'; +export * from './manifest/index.js'; diff --git a/packages/core/src/manifest/index.ts b/packages/core/src/manifest/index.ts new file mode 100644 index 00000000..f636721e --- /dev/null +++ b/packages/core/src/manifest/index.ts @@ -0,0 +1,206 @@ +import { readFileSync, writeFileSync, existsSync } from 'node:fs'; +import { join, dirname } from 'node:path'; +import { parse as parseYaml, stringify as stringifyYaml } from 'yaml'; + +export interface SkillEntry { + source: string; + skills?: string[]; + agents?: string[]; + enabled?: boolean; +} + +export interface SkillsManifest { + version: number; + skills: SkillEntry[]; + agents?: string[]; + installMethod?: 'symlink' | 'copy'; + updatedAt?: string; +} + +const MANIFEST_FILENAMES = ['.skills', '.skills.yaml', '.skills.yml', 'skills.yaml']; + +export function findManifestPath(startDir: string = process.cwd()): string | null { + let dir = startDir; + + while (dir !== dirname(dir)) { + for (const filename of MANIFEST_FILENAMES) { + const manifestPath = join(dir, filename); + if (existsSync(manifestPath)) { + return manifestPath; + } + } + dir = dirname(dir); + } + + return null; +} + +export function loadManifest(manifestPath?: string): SkillsManifest | null { + const path = manifestPath || findManifestPath(); + + if (!path || !existsSync(path)) { + return null; + } + + try { + const content = readFileSync(path, 'utf-8'); + const parsed = parseYaml(content) as SkillsManifest; + + if (!parsed || typeof parsed !== 'object') { + return null; + } + + return { + version: parsed.version || 1, + skills: normalizeSkills(parsed.skills || []), + agents: parsed.agents, + installMethod: parsed.installMethod, + updatedAt: parsed.updatedAt, + }; + } catch { + return null; + } +} + +function normalizeSkills(skills: unknown[]): SkillEntry[] { + return skills.map(skill => { + if (typeof skill === 'string') { + const parts = skill.split('/'); + if (parts.length >= 3) { + return { + source: `${parts[0]}/${parts[1]}`, + skills: [parts.slice(2).join('/')], + enabled: true, + }; + } + return { source: skill, enabled: true }; + } + + if (typeof skill === 'object' && skill !== null) { + const entry = skill as Record; + return { + source: String(entry.source || ''), + skills: entry.skills as string[] | undefined, + agents: entry.agents as string[] | undefined, + enabled: entry.enabled !== false, + }; + } + + return { source: '', enabled: false }; + }).filter(s => s.source); +} + +export function saveManifest(manifest: SkillsManifest, manifestPath?: string): void { + const path = manifestPath || join(process.cwd(), '.skills'); + + const content = stringifyYaml({ + version: manifest.version || 1, + skills: manifest.skills.map(s => { + if (!s.skills && !s.agents && s.enabled !== false) { + return s.source; + } + return s; + }), + ...(manifest.agents && { agents: manifest.agents }), + ...(manifest.installMethod && { installMethod: manifest.installMethod }), + updatedAt: new Date().toISOString(), + }); + + writeFileSync(path, content, 'utf-8'); +} + +export function addToManifest( + source: string, + options?: { skills?: string[]; agents?: string[] }, + manifestPath?: string +): SkillsManifest { + const existing = loadManifest(manifestPath) || { + version: 1, + skills: [], + }; + + const existingIndex = existing.skills.findIndex(s => s.source === source); + + if (existingIndex >= 0) { + existing.skills[existingIndex] = { + ...existing.skills[existingIndex], + ...options, + enabled: true, + }; + } else { + existing.skills.push({ + source, + ...options, + enabled: true, + }); + } + + saveManifest(existing, manifestPath); + return existing; +} + +export function removeFromManifest(source: string, manifestPath?: string): SkillsManifest | null { + const existing = loadManifest(manifestPath); + + if (!existing) { + return null; + } + + existing.skills = existing.skills.filter(s => s.source !== source); + saveManifest(existing, manifestPath); + return existing; +} + +export function initManifest(options?: { + agents?: string[]; + installMethod?: 'symlink' | 'copy'; +}, manifestPath?: string): SkillsManifest { + const manifest: SkillsManifest = { + version: 1, + skills: [], + ...options, + updatedAt: new Date().toISOString(), + }; + + saveManifest(manifest, manifestPath); + return manifest; +} + +export function generateManifestFromInstalled( + installedSkills: Array<{ name: string; source: string; agents?: string[] }> +): SkillsManifest { + const skillsBySource = new Map }>(); + + for (const skill of installedSkills) { + if (!skill.source) continue; + + const existing = skillsBySource.get(skill.source); + if (existing) { + existing.skills.push(skill.name); + if (skill.agents) { + skill.agents.forEach(a => existing.agents.add(a)); + } + } else { + skillsBySource.set(skill.source, { + skills: [skill.name], + agents: new Set(skill.agents || []), + }); + } + } + + const skills: SkillEntry[] = []; + for (const [source, data] of skillsBySource) { + skills.push({ + source, + skills: data.skills.length > 0 ? data.skills : undefined, + agents: data.agents.size > 0 ? Array.from(data.agents) : undefined, + enabled: true, + }); + } + + return { + version: 1, + skills, + updatedAt: new Date().toISOString(), + }; +}