mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-20 12:23:29 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85d9eee7e9 | ||
|
|
d14b57c651 | ||
|
|
4a6003ec46 | ||
|
|
6d36a4a3f7 | ||
|
|
0c5eb93891 | ||
|
|
2432410f79 | ||
|
|
4e3e2b3145 | ||
|
|
82e4a2ae62 | ||
|
|
ff5b3f7b4b | ||
|
|
15134cebbb | ||
|
|
6d01413a68 | ||
|
|
a9d6727ca5 | ||
|
|
2078be9eb4 | ||
|
|
44da0f8592 | ||
|
|
4089e5a0be | ||
|
|
c564d32ea9 | ||
|
|
4f65aecbc9 | ||
|
|
c1ba42d616 | ||
|
|
c8172097be | ||
|
|
80e41e517c | ||
|
|
26ea7e9002 | ||
|
|
1b5722a8c0 | ||
|
|
0210556634 | ||
|
|
570ae26cd5 | ||
|
|
413519d486 | ||
|
|
eadbaff07e | ||
|
|
10e8c389e3 | ||
|
|
94c77707c4 | ||
|
|
821fd1b495 | ||
|
|
288427d9b3 |
@@ -0,0 +1,89 @@
|
||||
name: Skill Submission
|
||||
description: Submit a new skill to the SkillKit marketplace
|
||||
title: "[Skill Submission] "
|
||||
labels: ["skill-submission"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Submit Your Skill to SkillKit Marketplace
|
||||
|
||||
Thanks for contributing! Please fill out the details below.
|
||||
|
||||
**Tip:** You can also use our [web form](https://rohitg00.github.io/skillkit/) to submit skills.
|
||||
|
||||
- type: input
|
||||
id: skill-name
|
||||
attributes:
|
||||
label: Skill Name
|
||||
description: A descriptive name for your skill
|
||||
placeholder: e.g., React Best Practices
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: What does this skill teach AI agents?
|
||||
placeholder: A brief description of your skill...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: repo-owner
|
||||
attributes:
|
||||
label: GitHub Owner
|
||||
description: The owner of the repository (username or organization)
|
||||
placeholder: e.g., your-username
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: repo-name
|
||||
attributes:
|
||||
label: Repository Name
|
||||
description: The name of the repository containing the skill
|
||||
placeholder: e.g., my-agent-skills
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: skill-path
|
||||
attributes:
|
||||
label: Skill Path
|
||||
description: Path to SKILL.md in the repository
|
||||
placeholder: skills/my-skill/SKILL.md
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: tags
|
||||
attributes:
|
||||
label: Tags
|
||||
description: Comma-separated tags for categorization
|
||||
placeholder: react, typescript, frontend
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: author-github
|
||||
attributes:
|
||||
label: Author GitHub Username
|
||||
description: Your GitHub username
|
||||
placeholder: your-username
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
description: Please confirm the following
|
||||
options:
|
||||
- label: Repository is public
|
||||
required: true
|
||||
- label: SKILL.md follows the agentskills.io standard format
|
||||
required: true
|
||||
- label: Skill has been tested with at least one AI agent
|
||||
required: false
|
||||
@@ -0,0 +1,180 @@
|
||||
name: Process Skill Submission
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: process-submission-${{ github.event.issue.number }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
process-submission:
|
||||
if: github.event.label.name == 'approved'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Parse Issue and Update skills.json
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
|
||||
const issue = context.payload.issue;
|
||||
const body = issue.body;
|
||||
|
||||
// Parse issue body for skill details
|
||||
const parseField = (label) => {
|
||||
const regex = new RegExp(`\\*\\*${label}:\\*\\*\\s*(.+?)(?:\\n|$)`, 'i');
|
||||
const match = body.match(regex);
|
||||
return match ? match[1].trim() : '';
|
||||
};
|
||||
|
||||
const parseCheckbox = (text) => {
|
||||
const regex = new RegExp(`- \\[(x|X)\\]\\s*${text}`, 'i');
|
||||
return regex.test(body);
|
||||
};
|
||||
|
||||
// Extract fields from form-based issue
|
||||
let skillName, description, repoOwner, repoName, skillPath, tags, authorGithub;
|
||||
|
||||
if (body.includes('### Skill Name')) {
|
||||
// YAML form format
|
||||
const sections = body.split('###').filter(s => s.trim());
|
||||
for (const section of sections) {
|
||||
const lines = section.trim().split('\n');
|
||||
const header = lines[0].trim().toLowerCase();
|
||||
const value = lines.slice(1).join('\n').trim();
|
||||
|
||||
if (header.includes('skill name')) skillName = value;
|
||||
if (header.includes('description')) description = value;
|
||||
if (header.includes('github owner')) repoOwner = value;
|
||||
if (header.includes('repository name')) repoName = value;
|
||||
if (header.includes('skill path')) skillPath = value;
|
||||
if (header.includes('tags')) tags = value;
|
||||
if (header.includes('author github')) authorGithub = value;
|
||||
}
|
||||
} else {
|
||||
// Markdown format from web form
|
||||
skillName = parseField('Name');
|
||||
description = parseField('Description');
|
||||
repoOwner = parseField('Owner');
|
||||
repoName = parseField('Repo');
|
||||
skillPath = parseField('Skill Path');
|
||||
tags = parseField('Tags');
|
||||
const authorField = parseField('Author') || '';
|
||||
authorGithub = authorField.replace(/^@/, '').trim();
|
||||
}
|
||||
|
||||
if (!skillName || !repoOwner || !repoName) {
|
||||
console.log('Missing required fields');
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: '❌ Could not parse skill details. Missing required fields (name, owner, or repo).'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate skill ID
|
||||
const skillSlug = skillName.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
||||
const skillId = `${repoOwner}/${repoName}/${skillSlug}`;
|
||||
|
||||
// Read current skills.json
|
||||
const skillsPath = 'marketplace/skills.json';
|
||||
const skillsData = JSON.parse(fs.readFileSync(skillsPath, 'utf-8'));
|
||||
|
||||
// Check for duplicates
|
||||
if (skillsData.skills.some(s => s.id === skillId)) {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: `⚠️ Skill with ID \`${skillId}\` already exists in the marketplace.`
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse and validate tags
|
||||
const filteredTags = tags
|
||||
? tags.split(',').map(t => t.trim().toLowerCase()).filter(t => t.length > 0)
|
||||
: [];
|
||||
|
||||
if (filteredTags.length === 0) {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: '❌ At least one tag is required. Please add tags to your submission.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Add new skill
|
||||
const newSkill = {
|
||||
id: skillId,
|
||||
name: skillName,
|
||||
description: description || '',
|
||||
source: `${repoOwner}/${repoName}`,
|
||||
tags: filteredTags,
|
||||
author: authorGithub
|
||||
};
|
||||
|
||||
skillsData.skills.push(newSkill);
|
||||
skillsData.updatedAt = new Date().toISOString().split('T')[0];
|
||||
|
||||
// Write updated skills.json
|
||||
fs.writeFileSync(skillsPath, JSON.stringify(skillsData, null, 2) + '\n');
|
||||
|
||||
// Also update docs copy
|
||||
const docsCopyPath = 'docs/skillkit/data/skills.json';
|
||||
fs.writeFileSync(docsCopyPath, JSON.stringify(skillsData, null, 2) + '\n');
|
||||
|
||||
// Also update core copy
|
||||
const coreCopyPath = 'packages/core/src/marketplace/data/skills.json';
|
||||
fs.writeFileSync(coreCopyPath, JSON.stringify(skillsData, null, 2) + '\n');
|
||||
|
||||
console.log(`Added skill: ${skillId}`);
|
||||
|
||||
// Set output for commit
|
||||
core.setOutput('skill_name', skillName);
|
||||
core.setOutput('skill_id', skillId);
|
||||
|
||||
- name: Commit Changes
|
||||
run: |
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add marketplace/skills.json docs/skillkit/data/skills.json packages/core/src/marketplace/data/skills.json
|
||||
git commit -m "feat(marketplace): add skill from #${{ github.event.issue.number }}"
|
||||
git push
|
||||
|
||||
- name: Close Issue with Comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.issue.number,
|
||||
body: `✅ **Skill added to marketplace!**\n\nYour skill has been added and will be available in the next release.\n\nThank you for contributing to SkillKit! 🎉`
|
||||
});
|
||||
|
||||
await github.rest.issues.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.issue.number,
|
||||
state: 'closed'
|
||||
});
|
||||
@@ -1,36 +1,35 @@
|
||||
# SkillKit
|
||||
<div align="center">
|
||||
|
||||
```
|
||||
██ SKILLKIT
|
||||
```
|
||||
</div>
|
||||
|
||||
**Universal Skills for AI Coding Agents**
|
||||
|
||||
[](https://www.npmjs.com/package/skillkit)
|
||||
[](https://www.npmjs.com/package/skillkit)
|
||||
[](https://github.com/rohitg00/skillkit/actions/workflows/ci.yml)
|
||||
[](https://rohitg00.github.io/skillkit/)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
## One CLI. 17 AI Agents. Zero Lock-in.
|
||||
## Supercharge Every AI Coding Agent
|
||||
|
||||
**Write skills once, use everywhere.** SkillKit is the universal platform that lets your AI coding skills work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more agents.
|
||||
**Give your AI agents new abilities with portable, reusable skills.** Install from a curated marketplace, create your own, and use them across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more agents.
|
||||
|
||||
> **What are AI Agent Skills?** Skills are instruction files that teach AI coding agents how to handle specific tasks - like processing PDFs, following React best practices, or enforcing security patterns. Think of them as plugins for your AI assistant.
|
||||
|
||||
```bash
|
||||
npm install -g skillkit
|
||||
```
|
||||
|
||||
## What's New in v1.6.0
|
||||
## Why SkillKit?
|
||||
|
||||
- **Methodology Framework**: 5 ready-to-use development frameworks (Agile, TDD, DevOps, Security-First, Documentation-First) with 13 specialized skills
|
||||
- **Hooks System**: Event-driven skill triggers - auto-activate on git commits, file changes, builds, tests, deployments
|
||||
- **Agent Orchestration**: Multi-agent team coordination with leader/teammate roles and task assignment
|
||||
- **Plan System**: Structured plan creation with validation and execution - parse, validate, and execute development plans
|
||||
- **Slash Commands**: Generate agent-native commands from natural language for all 17 AI agents
|
||||
- **Enhanced TUI**: New Methodology (o) and Plan (n) screens with improved navigation
|
||||
**The problem:** You've built amazing skills for Claude Code. Now you want to try Cursor. Or your team uses different agents. Each agent has different formats and directories. Without SkillKit, you either rewrite everything, lock yourself into one agent, or give up on skills entirely.
|
||||
|
||||
## The Problem
|
||||
**The solution:** SkillKit translates skills between all 17 agents automatically. Write once, use everywhere.
|
||||
|
||||
You've built amazing skills for Claude Code. Now you want to try Cursor. Or your team uses different agents. Your options:
|
||||
|
||||
1. **Rewrite everything** - each agent has different formats, directories, and conventions
|
||||
2. **Pick one agent** - lock yourself in, miss out on innovations
|
||||
3. **Give up on skills** - lose the productivity gains
|
||||
|
||||
## The Solution
|
||||
## See It In Action
|
||||
|
||||
```bash
|
||||
# Install a skill for ALL your agents at once
|
||||
@@ -96,6 +95,12 @@ skillkit translate --all --to windsurf
|
||||
|
||||
# Preview translation without writing
|
||||
skillkit translate my-skill --to codex --dry-run
|
||||
|
||||
# Batch translate from a custom source directory
|
||||
skillkit agent translate --source ./my-skills --to cursor
|
||||
|
||||
# Recursively translate nested agent directories
|
||||
skillkit agent translate --source ./kubernetes-skills --to cursor --recursive
|
||||
```
|
||||
|
||||
**Supported Agents:** Claude Code, Cursor, Codex, Gemini CLI, OpenCode, Antigravity, Amp, Clawdbot, Droid, GitHub Copilot, Goose, Kilo, Kiro, Roo, Trae, Windsurf, Universal
|
||||
@@ -273,6 +278,21 @@ skillkit context init # Initialize project context
|
||||
skillkit context sync # Sync context to agents
|
||||
```
|
||||
|
||||
### Custom AI Sub-Agents
|
||||
|
||||
```bash
|
||||
skillkit agent list # List all installed agents
|
||||
skillkit agent show <name> # Show agent details
|
||||
skillkit agent create <name> # Create a new agent
|
||||
skillkit agent translate # Translate agents between formats
|
||||
--source ./path # Source directory or file
|
||||
--to cursor # Target agent format
|
||||
--recursive # Scan subdirectories recursively
|
||||
--dry-run # Preview without writing
|
||||
skillkit agent sync # Sync agents to target AI agent
|
||||
skillkit agent validate # Validate agent definitions
|
||||
```
|
||||
|
||||
### Memory System
|
||||
|
||||
```bash
|
||||
@@ -421,16 +441,6 @@ disabledSkills:
|
||||
- deprecated-skill
|
||||
```
|
||||
|
||||
## Why SkillKit Exists
|
||||
|
||||
AI coding agents are amazing, but the ecosystem is fragmented:
|
||||
- **Skills don't transfer** between agents
|
||||
- **Knowledge dies** when sessions end
|
||||
- **No standard** for skill quality or testing
|
||||
- **Manual discovery** of useful skills
|
||||
|
||||
SkillKit solves these problems with a universal platform that works across all major AI coding agents.
|
||||
|
||||
## License
|
||||
|
||||
Apache License 2.0 - see [LICENSE](LICENSE) for details.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "skillkit",
|
||||
"version": "1.6.1",
|
||||
"description": "Universal skills loader for AI coding agents - supports Claude Code, Codex, Cursor, Antigravity, OpenCode, Gemini CLI and more",
|
||||
"version": "1.7.1",
|
||||
"description": "Supercharge AI coding agents with portable skills. Install, translate, and share skills across Claude Code, Cursor, Codex, Copilot & 13 more",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"skillkit": "./dist/cli.js",
|
||||
@@ -53,10 +53,10 @@
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "^1.6.0",
|
||||
"@skillkit/agents": "^1.6.0",
|
||||
"@skillkit/cli": "^1.6.0",
|
||||
"@skillkit/tui": "^1.6.0",
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@skillkit/cli": "workspace:*",
|
||||
"@skillkit/tui": "workspace:*",
|
||||
"clipanion": "^4.0.0-rc.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -39,6 +39,14 @@ import {
|
||||
CommandCmd,
|
||||
AICommand,
|
||||
AuditCommand,
|
||||
PublishCommand,
|
||||
AgentCommand,
|
||||
AgentListCommand,
|
||||
AgentShowCommand,
|
||||
AgentCreateCommand,
|
||||
AgentTranslateCommand,
|
||||
AgentSyncCommand,
|
||||
AgentValidateCommand,
|
||||
} from '@skillkit/cli';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
@@ -91,5 +99,13 @@ cli.register(PlanCommand);
|
||||
cli.register(CommandCmd);
|
||||
cli.register(AICommand);
|
||||
cli.register(AuditCommand);
|
||||
cli.register(PublishCommand);
|
||||
cli.register(AgentCommand);
|
||||
cli.register(AgentListCommand);
|
||||
cli.register(AgentShowCommand);
|
||||
cli.register(AgentCreateCommand);
|
||||
cli.register(AgentTranslateCommand);
|
||||
cli.register(AgentSyncCommand);
|
||||
cli.register(AgentValidateCommand);
|
||||
|
||||
cli.runExit(process.argv.slice(2));
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,74 @@
|
||||
import React from 'react';
|
||||
import { Hero } from './components/Hero';
|
||||
import { Features } from './components/Features';
|
||||
import { Agents } from './components/Agents';
|
||||
import { Footer } from './components/Footer';
|
||||
import { SkillGenerator } from './components/SkillGenerator';
|
||||
import { SkillSubmitForm } from './components/SkillSubmitForm';
|
||||
|
||||
const GITHUB_ICON = (
|
||||
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path fillRule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clipRule="evenodd" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
function scrollToTop(e: React.MouseEvent): void {
|
||||
e.preventDefault();
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
|
||||
export default function App(): React.ReactElement {
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-zinc-100 font-sans selection:bg-white selection:text-black">
|
||||
<nav className="fixed top-0 left-0 right-0 z-50 border-b border-zinc-800 bg-background/90 backdrop-blur-md">
|
||||
<div className="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex h-14 items-center justify-between">
|
||||
<a href="#" onClick={scrollToTop} className="flex items-center gap-2 cursor-pointer">
|
||||
<div className="w-4 h-4 bg-white"></div>
|
||||
<span className="text-base font-bold tracking-tight text-white font-mono">SKILLKIT</span>
|
||||
</a>
|
||||
<div className="flex items-center gap-2 sm:gap-4">
|
||||
<a
|
||||
href="https://github.com/rohitg00/skillkit"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="text-zinc-400 hover:text-white transition-colors p-2"
|
||||
aria-label="GitHub"
|
||||
>
|
||||
{GITHUB_ICON}
|
||||
</a>
|
||||
<div className="hidden sm:flex items-center bg-zinc-900 border border-zinc-800 px-3 py-1.5">
|
||||
<span className="text-zinc-500 mr-2 text-xs">$</span>
|
||||
<code className="text-zinc-300 text-xs font-mono">npx skillkit@latest</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main className="pt-14">
|
||||
<Hero />
|
||||
<Agents />
|
||||
<Features />
|
||||
|
||||
<section id="skills" className="py-12 border-b border-zinc-800">
|
||||
<SkillGenerator />
|
||||
</section>
|
||||
|
||||
<section id="submit" className="py-12 border-b border-zinc-800 bg-surface">
|
||||
<div className="mx-auto max-w-5xl px-4 sm:px-6 lg:px-8">
|
||||
<div className="text-center mb-8">
|
||||
<h2 className="text-2xl font-bold text-white mb-2 font-mono">Submit Your Skill</h2>
|
||||
<p className="text-zinc-400 font-mono text-sm">
|
||||
Share your AI agent skills with the community.
|
||||
</p>
|
||||
</div>
|
||||
<SkillSubmitForm />
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
# SkillKit Documentation Website
|
||||
|
||||
Landing page for SkillKit - the universal CLI for managing AI agent skills.
|
||||
|
||||
**Live site:** https://rohitg00.github.io/skillkit/
|
||||
|
||||
## Development
|
||||
|
||||
**Prerequisites:** Node.js 20+
|
||||
|
||||
1. Install dependencies:
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
2. (Optional) Set `GEMINI_API_KEY` in `.env.local` for the skill generator feature
|
||||
|
||||
3. Run locally:
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
4. Build for production:
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
The site is automatically deployed to GitHub Pages when changes are pushed to the `main` branch.
|
||||
|
||||
The deployment workflow is defined in `.github/workflows/deploy-docs.yml`.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- React 19
|
||||
- Vite
|
||||
- Tailwind CSS (via CDN)
|
||||
- TypeScript
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,53 @@
|
||||
import React from 'react';
|
||||
|
||||
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
|
||||
fullWidth?: boolean;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
const BASE_STYLES = "inline-flex items-center justify-center px-6 py-3 text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-black disabled:opacity-50 font-mono tracking-tight";
|
||||
|
||||
const VARIANT_STYLES = {
|
||||
primary: "bg-white text-black hover:bg-zinc-200 border border-white",
|
||||
secondary: "bg-zinc-900 text-zinc-100 hover:bg-zinc-800 border border-zinc-800",
|
||||
outline: "bg-transparent text-zinc-300 border border-zinc-700 hover:border-zinc-500 hover:text-white",
|
||||
ghost: "bg-transparent text-zinc-400 hover:text-white hover:bg-zinc-900"
|
||||
} as const;
|
||||
|
||||
export function Button({
|
||||
children,
|
||||
variant = 'primary',
|
||||
className = '',
|
||||
fullWidth = false,
|
||||
isLoading = false,
|
||||
disabled,
|
||||
...props
|
||||
}: ButtonProps): React.ReactElement {
|
||||
const widthClass = fullWidth ? 'w-full' : '';
|
||||
|
||||
const classes = [
|
||||
BASE_STYLES,
|
||||
VARIANT_STYLES[variant],
|
||||
widthClass,
|
||||
className,
|
||||
].filter(Boolean).join(' ');
|
||||
|
||||
return (
|
||||
<button
|
||||
className={classes}
|
||||
disabled={disabled || isLoading}
|
||||
{...props}
|
||||
>
|
||||
{isLoading ? (
|
||||
<>
|
||||
<svg className="animate-spin -ml-1 mr-2 h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
PROCESSING
|
||||
</>
|
||||
) : children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
|
||||
interface CardProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
noPadding?: boolean;
|
||||
onClick?: () => void;
|
||||
onDragOver?: (e: React.DragEvent) => void;
|
||||
onDragLeave?: (e: React.DragEvent) => void;
|
||||
onDrop?: (e: React.DragEvent) => void;
|
||||
}
|
||||
|
||||
export function Card({
|
||||
children,
|
||||
className = '',
|
||||
noPadding = false,
|
||||
onClick,
|
||||
onDragOver,
|
||||
onDragLeave,
|
||||
onDrop
|
||||
}: CardProps): React.ReactElement {
|
||||
const paddingClass = noPadding ? '' : 'p-6';
|
||||
const clickableClass = onClick ? 'cursor-pointer' : '';
|
||||
|
||||
function handleKeyDown(e: React.KeyboardEvent): void {
|
||||
if (!onClick) return;
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
if (e.key === ' ') {
|
||||
e.preventDefault();
|
||||
}
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`relative bg-black border border-zinc-800 transition-colors duration-300 ${paddingClass} ${clickableClass} ${className}`}
|
||||
onClick={onClick}
|
||||
role={onClick ? 'button' : undefined}
|
||||
tabIndex={onClick ? 0 : undefined}
|
||||
onKeyDown={onClick ? handleKeyDown : undefined}
|
||||
onDragOver={onDragOver}
|
||||
onDragLeave={onDragLeave}
|
||||
onDrop={onDrop}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
import React from 'react';
|
||||
|
||||
interface Feature {
|
||||
title: string;
|
||||
description: string;
|
||||
icon: React.ReactNode;
|
||||
}
|
||||
|
||||
const FEATURES: Feature[] = [
|
||||
{
|
||||
title: 'Multi-Agent',
|
||||
description: 'Write once, deploy to 17+ AI coding agents automatically.',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
|
||||
</svg>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Smart Discovery',
|
||||
description: 'AI analyzes your stack and recommends skills.',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
||||
</svg>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Persistent Memory',
|
||||
description: 'Save learnings as reusable skills.',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />
|
||||
</svg>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Team Sync',
|
||||
description: 'Share skills via Git across your team.',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
|
||||
</svg>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Testing',
|
||||
description: 'Built-in framework for skill validation.',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Workflows',
|
||||
description: 'Compose multi-step automated pipelines.',
|
||||
icon: (
|
||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M13 10V3L4 14h7v7l9-11h-7z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
const COMPARISONS = [
|
||||
['Agents', '1', '17+'],
|
||||
['Translation', 'Manual', 'Auto'],
|
||||
['Sharing', 'Copy/paste', 'Git sync'],
|
||||
['Discovery', 'Forums', 'AI-powered'],
|
||||
] as const;
|
||||
|
||||
export function Features(): React.ReactElement {
|
||||
return (
|
||||
<section id="features" className="py-12 border-b border-zinc-800 bg-surface">
|
||||
<div className="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-5 gap-6 lg:gap-8 mb-10 max-w-5xl mx-auto">
|
||||
<div className="lg:col-span-2">
|
||||
<h2 className="text-xl font-bold text-white mb-2 font-mono">Why SkillKit?</h2>
|
||||
<p className="text-zinc-500 font-mono text-sm mb-6">
|
||||
Universal bridge for AI coding agents.
|
||||
</p>
|
||||
<div className="flex gap-6 sm:gap-8">
|
||||
<div>
|
||||
<div className="text-2xl sm:text-3xl font-bold text-white font-mono">17+</div>
|
||||
<div className="text-zinc-600 text-[10px] sm:text-xs font-mono">Agents</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl sm:text-3xl font-bold text-white font-mono">1</div>
|
||||
<div className="text-zinc-600 text-[10px] sm:text-xs font-mono">Command</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl sm:text-3xl font-bold text-white font-mono">∞</div>
|
||||
<div className="text-zinc-600 text-[10px] sm:text-xs font-mono">Skills</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="lg:col-span-3 border border-zinc-800 bg-black/50 p-4 font-mono text-xs backdrop-blur-sm">
|
||||
<div className="grid grid-cols-3 gap-2 border-b border-zinc-800 pb-2 mb-3 text-zinc-500 uppercase tracking-wider text-[10px]">
|
||||
<div>Feature</div>
|
||||
<div className="text-center">Without</div>
|
||||
<div className="text-right">SkillKit</div>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
{COMPARISONS.map(([feature, without, withSkillKit], index) => (
|
||||
<div
|
||||
key={feature}
|
||||
className="grid grid-cols-3 gap-2 items-center py-1.5 hover:bg-zinc-900/50 transition-colors -mx-2 px-2 rounded"
|
||||
style={{ animationDelay: `${index * 100}ms` }}
|
||||
>
|
||||
<div className="text-zinc-300">{feature}</div>
|
||||
<div className="text-center text-zinc-600">{without}</div>
|
||||
<div className="text-right text-white font-medium">{withSkillKit}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 xs:grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3 max-w-5xl mx-auto">
|
||||
{FEATURES.map((feature, index) => (
|
||||
<div
|
||||
key={feature.title}
|
||||
className="group relative p-4 border border-zinc-800 bg-zinc-900/30 hover:bg-zinc-900/80 hover:border-zinc-700 transition-all duration-300 cursor-default"
|
||||
style={{ animationDelay: `${index * 50}ms` }}
|
||||
>
|
||||
<div className="absolute inset-0 bg-gradient-to-b from-zinc-800/0 to-zinc-800/20 opacity-0 group-hover:opacity-100 transition-opacity"></div>
|
||||
<div className="relative">
|
||||
<div className="text-zinc-500 group-hover:text-white transition-colors mb-2">
|
||||
{feature.icon}
|
||||
</div>
|
||||
<h4 className="text-xs font-bold text-white mb-1 font-mono">{feature.title}</h4>
|
||||
<p className="text-zinc-600 text-[10px] leading-relaxed font-mono group-hover:text-zinc-400 transition-colors">
|
||||
{feature.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
|
||||
const GITHUB_ICON = (
|
||||
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path fillRule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clipRule="evenodd" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export function Footer(): React.ReactElement {
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
return (
|
||||
<footer className="border-t border-border py-6 bg-black">
|
||||
<div className="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8 flex flex-col sm:flex-row justify-between items-center gap-3">
|
||||
<div className="flex flex-col sm:flex-row items-center gap-2 sm:gap-4 text-center sm:text-left">
|
||||
<p className="text-zinc-500 text-xs font-mono">
|
||||
© {currentYear} SKILLKIT
|
||||
</p>
|
||||
<span className="hidden sm:inline text-zinc-700">•</span>
|
||||
<a
|
||||
href="https://agentskills.io"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="text-zinc-600 hover:text-zinc-400 text-xs font-mono transition-colors"
|
||||
>
|
||||
Agent Skills standard
|
||||
</a>
|
||||
</div>
|
||||
<a
|
||||
href="https://github.com/rohitg00/skillkit"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label="SkillKit on GitHub"
|
||||
className="text-zinc-500 hover:text-white transition-colors"
|
||||
>
|
||||
{GITHUB_ICON}
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Button } from './Button';
|
||||
|
||||
const ASCII_LOGO = `███████╗██╗ ██╗██╗██╗ ██╗ ██╗ ██╗██╗████████╗
|
||||
██╔════╝██║ ██╔╝██║██║ ██║ ██║ ██╔╝██║╚══██╔══╝
|
||||
███████╗█████╔╝ ██║██║ ██║ █████╔╝ ██║ ██║
|
||||
╚════██║██╔═██╗ ██║██║ ██║ ██╔═██╗ ██║ ██║
|
||||
███████║██║ ██╗██║███████╗███████╗██║ ██╗██║ ██║
|
||||
╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝`;
|
||||
|
||||
interface TerminalLine {
|
||||
type: 'cmd' | 'out';
|
||||
text: string;
|
||||
}
|
||||
|
||||
const TERMINAL_LINES: TerminalLine[] = [
|
||||
{ type: 'cmd', text: 'skillkit init' },
|
||||
{ type: 'out', text: '→ Next.js + TypeScript detected' },
|
||||
{ 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' },
|
||||
];
|
||||
|
||||
const FADE_ANIMATION_STYLES = `
|
||||
@keyframes fade-in {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
.animate-fade-in {
|
||||
animation: fade-in 0.6s ease-out forwards;
|
||||
}
|
||||
.animate-fade-in-delay {
|
||||
animation: fade-in 0.6s ease-out 0.2s forwards;
|
||||
opacity: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
const CHECK_ICON = (
|
||||
<svg className="w-4 h-4 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
const COPY_ICON = (
|
||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export function Hero(): React.ReactElement {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [visibleLines, setVisibleLines] = useState(0);
|
||||
const [typingIndex, setTypingIndex] = useState(0);
|
||||
const [currentText, setCurrentText] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (visibleLines >= TERMINAL_LINES.length) {
|
||||
const resetTimer = setTimeout(() => {
|
||||
setVisibleLines(0);
|
||||
setTypingIndex(0);
|
||||
setCurrentText('');
|
||||
}, 3000);
|
||||
return () => clearTimeout(resetTimer);
|
||||
}
|
||||
|
||||
const line = TERMINAL_LINES[visibleLines];
|
||||
if (line.type === 'cmd') {
|
||||
if (typingIndex < line.text.length) {
|
||||
const timer = setTimeout(() => {
|
||||
setCurrentText(line.text.slice(0, typingIndex + 1));
|
||||
setTypingIndex(typingIndex + 1);
|
||||
}, 40);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
setVisibleLines(visibleLines + 1);
|
||||
setTypingIndex(0);
|
||||
setCurrentText('');
|
||||
}, 200);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
setVisibleLines(visibleLines + 1);
|
||||
}, 150);
|
||||
return () => clearTimeout(timer);
|
||||
}, [visibleLines, typingIndex]);
|
||||
|
||||
async function copyInstall(): Promise<void> {
|
||||
try {
|
||||
await navigator.clipboard.writeText('npx skillkit@latest');
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
} catch {
|
||||
// Clipboard API failed, silently ignore
|
||||
}
|
||||
}
|
||||
|
||||
function openGitHub(): void {
|
||||
window.open('https://github.com/rohitg00/skillkit', '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
const isTyping = visibleLines < TERMINAL_LINES.length && TERMINAL_LINES[visibleLines].type === 'cmd';
|
||||
const isComplete = visibleLines >= TERMINAL_LINES.length;
|
||||
|
||||
return (
|
||||
<div className="relative border-b border-zinc-800 overflow-hidden">
|
||||
<div className="absolute inset-0 bg-gradient-to-b from-zinc-900/50 to-transparent pointer-events-none"></div>
|
||||
|
||||
<div className="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8 pt-8 pb-10 relative">
|
||||
<div className="max-w-5xl mx-auto">
|
||||
<div className="hidden lg:block mb-6 overflow-hidden">
|
||||
<pre className="text-zinc-800 text-[8px] leading-none font-mono select-none animate-pulse">
|
||||
{ASCII_LOGO}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-8 items-start">
|
||||
<div className="animate-fade-in">
|
||||
<div className="inline-flex items-center space-x-2 border border-zinc-800 bg-zinc-900/50 px-2 py-0.5 mb-3 backdrop-blur-sm">
|
||||
<span className="flex h-1.5 w-1.5 bg-white rounded-full"></span>
|
||||
<span className="text-xs font-mono text-zinc-400">v1.7.0</span>
|
||||
</div>
|
||||
|
||||
<h1 className="text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight text-white mb-3 font-mono">
|
||||
Universal Skills for<br />
|
||||
<span className="text-zinc-500">AI Coding Agents</span>
|
||||
</h1>
|
||||
|
||||
<p className="text-sm text-zinc-400 mb-5 max-w-lg font-mono leading-relaxed">
|
||||
Portable, reusable skills that work across Claude Code, Cursor, Codex,
|
||||
Windsurf, GitHub Copilot, and 12 more agents.
|
||||
</p>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3 mb-4">
|
||||
<button
|
||||
onClick={copyInstall}
|
||||
className="inline-flex items-center bg-black border border-zinc-700 px-3 py-2 hover:border-zinc-500 transition-colors"
|
||||
>
|
||||
<span className="text-zinc-500 mr-2 select-none">$</span>
|
||||
<span className="font-mono text-zinc-100 text-sm">npx skillkit@latest</span>
|
||||
<span className="ml-2 text-zinc-500 hover:text-white transition-colors flex items-center gap-1">
|
||||
{copied ? (
|
||||
<>
|
||||
{CHECK_ICON}
|
||||
<span className="text-xs text-green-400">Copied!</span>
|
||||
</>
|
||||
) : (
|
||||
COPY_ICON
|
||||
)}
|
||||
</span>
|
||||
</button>
|
||||
<Button variant="outline" onClick={openGitHub}>
|
||||
GITHUB
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="hidden lg:block relative animate-fade-in-delay w-full lg:max-w-[420px]">
|
||||
<div className="absolute -inset-1 bg-gradient-to-r from-zinc-800 via-zinc-700 to-zinc-800 rounded-lg opacity-20 blur-lg"></div>
|
||||
<div className="relative border border-zinc-800 bg-black rounded-lg overflow-hidden">
|
||||
<div className="flex items-center gap-1.5 px-3 py-2 border-b border-zinc-800 bg-zinc-900/50">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-zinc-700"></div>
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-zinc-700"></div>
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-zinc-700"></div>
|
||||
<span className="ml-2 text-zinc-500 text-xs font-mono">skillkit</span>
|
||||
</div>
|
||||
<div className="p-4 font-mono text-xs min-h-[200px] max-h-[280px]">
|
||||
{TERMINAL_LINES.slice(0, visibleLines).map((line, index) => (
|
||||
<div key={index} className="mb-1">
|
||||
{line.type === 'cmd' ? (
|
||||
<div className="flex items-center">
|
||||
<span className="text-zinc-600 mr-2">$</span>
|
||||
<span className="text-zinc-100">{line.text}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="pl-4 text-zinc-500">
|
||||
<span className="text-zinc-400">{line.text.slice(0, 1)}</span>
|
||||
{line.text.slice(1)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{isTyping && (
|
||||
<div className="flex items-center">
|
||||
<span className="text-zinc-600 mr-2">$</span>
|
||||
<span className="text-zinc-100">{currentText}</span>
|
||||
<span className="w-2 h-4 bg-zinc-400 ml-0.5 animate-pulse"></span>
|
||||
</div>
|
||||
)}
|
||||
{isComplete && (
|
||||
<div className="flex items-center mt-1">
|
||||
<span className="text-zinc-600 mr-2">$</span>
|
||||
<span className="w-2 h-4 bg-zinc-600 animate-pulse"></span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>{FADE_ANIMATION_STYLES}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,650 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { Button } from './Button';
|
||||
import { Card } from './Card';
|
||||
import { generateAgentSkill } from '../services/geminiService';
|
||||
import { searchSkills, IndexedSkill } from '../data/skills-index';
|
||||
import { AgentSkill, LoadingState } from '../types';
|
||||
|
||||
interface PriorityBadgeProps {
|
||||
priority: string;
|
||||
}
|
||||
|
||||
type ViewMode = 'search' | 'marketplace' | 'generated' | 'content';
|
||||
|
||||
const PRIORITY_COLORS = {
|
||||
must: 'bg-red-900/50 text-red-300 border-red-800',
|
||||
should: 'bg-yellow-900/50 text-yellow-300 border-yellow-800',
|
||||
may: 'bg-blue-900/50 text-blue-300 border-blue-800',
|
||||
} as const;
|
||||
|
||||
function PriorityBadge({ priority }: PriorityBadgeProps): React.ReactElement {
|
||||
const colorClass = PRIORITY_COLORS[priority as keyof typeof PRIORITY_COLORS] || PRIORITY_COLORS.may;
|
||||
return (
|
||||
<span className={`text-xs px-2 py-0.5 border font-mono uppercase ${colorClass}`}>
|
||||
{priority}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function generateSkillMd(skill: AgentSkill): string {
|
||||
const frontmatter = `---
|
||||
name: "${skill.name}"
|
||||
description: "${skill.description}"
|
||||
version: "${skill.version}"
|
||||
tags: [${skill.tags.map(t => `"${t}"`).join(', ')}]
|
||||
${skill.filePatterns?.length ? `globs: [${skill.filePatterns.map(p => `"${p}"`).join(', ')}]` : ''}
|
||||
---`;
|
||||
|
||||
const principlesSection = skill.principles.map(p =>
|
||||
`### ${p.priority.toUpperCase()}: ${p.title}\n\n${p.description}`
|
||||
).join('\n\n');
|
||||
|
||||
const patternsSection = skill.patterns.map(p =>
|
||||
`### ${p.name}\n\n${p.description}\n\n\`\`\`${p.language || 'typescript'}\n${p.example}\n\`\`\``
|
||||
).join('\n\n');
|
||||
|
||||
const antiPatternsSection = skill.antiPatterns.map(ap => {
|
||||
let content = `### ${ap.name}\n\n${ap.description}`;
|
||||
if (ap.badExample) {
|
||||
content += `\n\n**Bad:**\n\`\`\`typescript\n${ap.badExample}\n\`\`\``;
|
||||
}
|
||||
if (ap.goodExample) {
|
||||
content += `\n\n**Good:**\n\`\`\`typescript\n${ap.goodExample}\n\`\`\``;
|
||||
}
|
||||
return content;
|
||||
}).join('\n\n');
|
||||
|
||||
const content = `# ${skill.title}
|
||||
|
||||
${skill.description}
|
||||
|
||||
## When to Apply
|
||||
|
||||
${skill.applicability}
|
||||
|
||||
${skill.filePatterns?.length ? `**File patterns:** ${skill.filePatterns.map(p => `\`${p}\``).join(', ')}` : ''}
|
||||
|
||||
## Principles
|
||||
|
||||
${principlesSection}
|
||||
|
||||
## Patterns
|
||||
|
||||
${patternsSection}
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
${antiPatternsSection}
|
||||
|
||||
${skill.references?.length ? `## References\n\n${skill.references.map(r => `- ${r}`).join('\n')}` : ''}
|
||||
`;
|
||||
|
||||
return `${frontmatter}\n\n${content}`;
|
||||
}
|
||||
|
||||
function downloadContent(content: string, filename: string): void {
|
||||
const blob = new Blob([content], { type: 'text/markdown' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
// localStorage cache for AI-generated skills
|
||||
const CACHE_KEY = 'skillkit_ai_cache';
|
||||
const CACHE_VERSION = 1;
|
||||
const MAX_CACHE_ENTRIES = 50;
|
||||
const CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
||||
|
||||
interface CachedSkill {
|
||||
skill: AgentSkill;
|
||||
query: string;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
interface SkillCache {
|
||||
version: number;
|
||||
skills: Record<string, CachedSkill>;
|
||||
}
|
||||
|
||||
function normalizeQuery(query: string): string {
|
||||
return query.toLowerCase().trim().replace(/\s+/g, ' ');
|
||||
}
|
||||
|
||||
function getSkillCache(): SkillCache {
|
||||
try {
|
||||
const cached = localStorage.getItem(CACHE_KEY);
|
||||
if (cached) {
|
||||
const parsed = JSON.parse(cached) as SkillCache;
|
||||
if (parsed.version === CACHE_VERSION) {
|
||||
// Prune expired entries
|
||||
const now = Date.now();
|
||||
let mutated = false;
|
||||
for (const [key, value] of Object.entries(parsed.skills)) {
|
||||
if (!value?.timestamp || now - value.timestamp >= CACHE_TTL_MS) {
|
||||
delete parsed.skills[key];
|
||||
mutated = true;
|
||||
}
|
||||
}
|
||||
if (mutated) {
|
||||
localStorage.setItem(CACHE_KEY, JSON.stringify(parsed));
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore parse errors
|
||||
}
|
||||
return { version: CACHE_VERSION, skills: {} };
|
||||
}
|
||||
|
||||
function getCachedSkill(query: string): AgentSkill | null {
|
||||
const cache = getSkillCache();
|
||||
const key = normalizeQuery(query);
|
||||
const cached = cache.skills[key];
|
||||
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
||||
return cached.skill;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function setCachedSkill(query: string, skill: AgentSkill): void {
|
||||
try {
|
||||
const cache = getSkillCache();
|
||||
const key = normalizeQuery(query);
|
||||
cache.skills[key] = {
|
||||
skill,
|
||||
query: key,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
// Enforce max entries limit
|
||||
const entries = Object.entries(cache.skills);
|
||||
if (entries.length > MAX_CACHE_ENTRIES) {
|
||||
entries
|
||||
.sort((a, b) => a[1].timestamp - b[1].timestamp)
|
||||
.slice(0, entries.length - MAX_CACHE_ENTRIES)
|
||||
.forEach(([k]) => delete cache.skills[k]);
|
||||
}
|
||||
localStorage.setItem(CACHE_KEY, JSON.stringify(cache));
|
||||
} catch {
|
||||
// Ignore storage errors (quota exceeded, etc.)
|
||||
}
|
||||
}
|
||||
|
||||
export function SkillGenerator(): React.ReactElement {
|
||||
const [input, setInput] = useState('');
|
||||
const [status, setStatus] = useState<LoadingState>(LoadingState.IDLE);
|
||||
const [viewMode, setViewMode] = useState<ViewMode>('search');
|
||||
|
||||
const [marketplaceResults, setMarketplaceResults] = useState<IndexedSkill[]>([]);
|
||||
const [selectedSkill, setSelectedSkill] = useState<IndexedSkill | null>(null);
|
||||
const [skillContent, setSkillContent] = useState<string | null>(null);
|
||||
const [generatedSkill, setGeneratedSkill] = useState<AgentSkill | null>(null);
|
||||
const [isFromCache, setIsFromCache] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState<'principles' | 'patterns' | 'antipatterns'>('principles');
|
||||
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
function handleSearch(e: React.FormEvent): void {
|
||||
e.preventDefault();
|
||||
if (!input.trim()) return;
|
||||
|
||||
setError(null);
|
||||
setSelectedSkill(null);
|
||||
setSkillContent(null);
|
||||
setGeneratedSkill(null);
|
||||
|
||||
const results = searchSkills(input);
|
||||
setMarketplaceResults(results);
|
||||
setViewMode(results.length > 0 ? 'marketplace' : 'search');
|
||||
setStatus(LoadingState.SUCCESS);
|
||||
}
|
||||
|
||||
async function handleViewSkill(skill: IndexedSkill): Promise<void> {
|
||||
setSelectedSkill(skill);
|
||||
setSkillContent(null);
|
||||
setViewMode('content');
|
||||
|
||||
if (skill.rawUrl) {
|
||||
setStatus(LoadingState.LOADING);
|
||||
try {
|
||||
const response = await fetch(skill.rawUrl);
|
||||
if (response.ok) {
|
||||
const content = await response.text();
|
||||
setSkillContent(content);
|
||||
}
|
||||
} catch {
|
||||
// Silently handle fetch errors
|
||||
}
|
||||
setStatus(LoadingState.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleGenerateWithAI(): Promise<void> {
|
||||
setError(null);
|
||||
|
||||
// Check cache first
|
||||
const cached = getCachedSkill(input);
|
||||
if (cached) {
|
||||
setGeneratedSkill(cached);
|
||||
setIsFromCache(true);
|
||||
setViewMode('generated');
|
||||
setStatus(LoadingState.SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus(LoadingState.LOADING);
|
||||
setIsFromCache(false);
|
||||
|
||||
try {
|
||||
const result = await generateAgentSkill(input);
|
||||
setGeneratedSkill(result);
|
||||
setCachedSkill(input, result); // Cache the result
|
||||
setViewMode('generated');
|
||||
setStatus(LoadingState.SUCCESS);
|
||||
} catch {
|
||||
setError("Failed to generate skill. Please try again.");
|
||||
setStatus(LoadingState.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
function submitToMarketplace(): void {
|
||||
if (!generatedSkill) return;
|
||||
|
||||
const slug = generatedSkill.name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
||||
const skillContent = generateSkillMd(generatedSkill);
|
||||
|
||||
const body = `## 📤 AI-Generated Skill: ${generatedSkill.title}
|
||||
|
||||
### Skill Details
|
||||
- **Name:** ${generatedSkill.name}
|
||||
- **Description:** ${generatedSkill.description}
|
||||
- **Tags:** ${generatedSkill.tags.join(', ')}
|
||||
- **Version:** ${generatedSkill.version}
|
||||
|
||||
### SKILL.md Content
|
||||
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
|
||||
\`\`\`markdown
|
||||
${skillContent.slice(0, 4000)}${skillContent.length > 4000 ? '\n...(truncated)' : ''}
|
||||
\`\`\`
|
||||
|
||||
</details>
|
||||
|
||||
### Checklist for Maintainer
|
||||
- [ ] Review skill content for quality
|
||||
- [ ] Add to \`marketplace/skills.json\`
|
||||
|
||||
---
|
||||
**Generated via:** AI Skill Generator
|
||||
**Search query:** "${input}"`;
|
||||
|
||||
const title = encodeURIComponent(`[AI Skill] ${generatedSkill.title}`);
|
||||
const encodedBody = encodeURIComponent(body);
|
||||
const url = `https://github.com/rohitg00/skillkit/issues/new?title=${title}&body=${encodedBody}&labels=ai-generated,skill-submission`;
|
||||
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
function handleBack(): void {
|
||||
switch (viewMode) {
|
||||
case 'content':
|
||||
setViewMode('marketplace');
|
||||
setSelectedSkill(null);
|
||||
setSkillContent(null);
|
||||
break;
|
||||
case 'generated':
|
||||
setViewMode(marketplaceResults.length > 0 ? 'marketplace' : 'search');
|
||||
setGeneratedSkill(null);
|
||||
break;
|
||||
default:
|
||||
setViewMode('search');
|
||||
setMarketplaceResults([]);
|
||||
}
|
||||
}
|
||||
|
||||
function downloadSkillMd(): void {
|
||||
if (skillContent) {
|
||||
downloadContent(skillContent, 'SKILL.md');
|
||||
}
|
||||
}
|
||||
|
||||
function downloadGeneratedSkillMd(): void {
|
||||
if (generatedSkill) {
|
||||
downloadContent(generateSkillMd(generatedSkill), 'SKILL.md');
|
||||
}
|
||||
}
|
||||
|
||||
// Focus input only after user interaction, not on initial page load
|
||||
useEffect(() => {
|
||||
if (status === LoadingState.SUCCESS && inputRef.current) {
|
||||
inputRef.current.focus({ preventScroll: true });
|
||||
}
|
||||
}, [status]);
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-5xl px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div className="mb-6">
|
||||
<h2 className="text-xl font-bold text-white mb-1 font-sans">Skill Finder</h2>
|
||||
<p className="text-zinc-400 font-mono text-xs">
|
||||
Search the marketplace or generate new skills with AI.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSearch} className="mb-6">
|
||||
<div className="flex flex-col sm:flex-row gap-3">
|
||||
<input
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
placeholder="e.g., React hooks, TypeScript, Next.js..."
|
||||
className="flex-1 bg-surface border border-zinc-700 text-white px-4 py-3 focus:ring-2 focus:ring-white focus:border-transparent outline-none font-mono text-sm placeholder-zinc-600"
|
||||
disabled={status === LoadingState.LOADING}
|
||||
/>
|
||||
<Button type="submit" isLoading={status === LoadingState.LOADING} className="sm:w-auto w-full">
|
||||
SEARCH
|
||||
</Button>
|
||||
</div>
|
||||
{error && <p className="mt-2 text-red-400 font-mono text-xs">{error}</p>}
|
||||
</form>
|
||||
|
||||
{viewMode !== 'search' && status !== LoadingState.LOADING && (
|
||||
<button
|
||||
onClick={handleBack}
|
||||
className="mb-6 text-zinc-400 hover:text-white font-mono text-sm flex items-center gap-2 transition-colors"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
Back
|
||||
</button>
|
||||
)}
|
||||
|
||||
{viewMode === 'marketplace' && status === LoadingState.SUCCESS && (
|
||||
<div className="animate-fade-in-up">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h3 className="text-lg font-mono text-zinc-300">
|
||||
Found {marketplaceResults.length} skill{marketplaceResults.length !== 1 ? 's' : ''} in marketplace
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 mb-8">
|
||||
{marketplaceResults.map((skill) => (
|
||||
<Card
|
||||
key={skill.id}
|
||||
className="hover:border-zinc-500 cursor-pointer transition-all"
|
||||
onClick={() => handleViewSkill(skill)}
|
||||
>
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<h4 className="text-lg font-semibold text-white mb-1">{skill.name}</h4>
|
||||
<p className="text-zinc-400 text-sm mb-2">{skill.description || 'No description'}</p>
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-500 font-mono">
|
||||
<span>{skill.source}</span>
|
||||
</div>
|
||||
</div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 text-zinc-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
{skill.tags.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1 mt-3">
|
||||
{skill.tags.slice(0, 5).map((tag, idx) => (
|
||||
<span key={idx} className="text-xs bg-zinc-900 text-zinc-500 px-2 py-0.5 border border-zinc-800">
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="border-t border-zinc-800 pt-6">
|
||||
<p className="text-zinc-500 font-mono text-sm mb-4">
|
||||
Don't see what you need? Generate a custom skill with AI.
|
||||
</p>
|
||||
<Button onClick={handleGenerateWithAI} isLoading={status === LoadingState.LOADING}>
|
||||
GENERATE WITH AI
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{viewMode === 'search' && status === LoadingState.SUCCESS && marketplaceResults.length === 0 && input && (
|
||||
<div className="animate-fade-in-up text-center py-4">
|
||||
<div className="text-zinc-500 font-mono text-sm mb-4">
|
||||
No skills found for "{input}" in the marketplace.
|
||||
</div>
|
||||
<Button onClick={handleGenerateWithAI}>
|
||||
GENERATE WITH AI
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{viewMode === 'content' && selectedSkill && (
|
||||
<div className="animate-fade-in-up">
|
||||
<div className="flex items-start justify-between mb-6 border-b border-zinc-800 pb-6">
|
||||
<div>
|
||||
<h3 className="text-2xl font-bold text-white mb-2">{selectedSkill.name}</h3>
|
||||
<p className="text-zinc-400 font-mono text-sm mb-2">{selectedSkill.description}</p>
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-500 font-mono">
|
||||
<span>{selectedSkill.source}</span>
|
||||
{selectedSkill.sourceUrl && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<a href={selectedSkill.sourceUrl} target="_blank" rel="noreferrer" className="hover:text-white">
|
||||
View on GitHub
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{skillContent && (
|
||||
<button
|
||||
onClick={downloadSkillMd}
|
||||
className="flex items-center gap-2 bg-white text-black px-4 py-2 font-mono text-sm hover:bg-zinc-200 transition-colors shrink-0 ml-4"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
||||
</svg>
|
||||
DOWNLOAD
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{status === LoadingState.LOADING ? (
|
||||
<div className="text-zinc-500 font-mono text-sm">Loading content...</div>
|
||||
) : skillContent ? (
|
||||
<pre className="bg-zinc-950 border border-zinc-800 p-6 overflow-x-auto text-sm max-h-[600px] overflow-y-auto">
|
||||
<code className="text-zinc-300 font-mono whitespace-pre-wrap">{skillContent}</code>
|
||||
</pre>
|
||||
) : (
|
||||
<div className="bg-zinc-950 border border-zinc-800 p-6">
|
||||
<p className="text-zinc-400 font-mono text-sm mb-4">
|
||||
Skill content not available for direct preview.
|
||||
</p>
|
||||
<a
|
||||
href={selectedSkill.sourceUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-2 bg-zinc-800 text-white px-4 py-2 font-mono text-sm hover:bg-zinc-700 transition-colors"
|
||||
>
|
||||
View on GitHub
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="mt-6 pt-6 border-t border-zinc-800">
|
||||
<p className="text-zinc-500 font-mono text-sm mb-3">Install with SkillKit:</p>
|
||||
<pre className="bg-zinc-950 border border-zinc-800 p-4 text-sm overflow-x-auto">
|
||||
<code className="text-zinc-300 font-mono text-xs sm:text-sm whitespace-nowrap">
|
||||
npx skillkit install {selectedSkill.id.split('/').slice(0, 2).join('/')}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{viewMode === 'generated' && generatedSkill && (
|
||||
<div className="animate-fade-in-up">
|
||||
<div className="flex items-start justify-between mb-8 border-b border-zinc-800 pb-6">
|
||||
<div className="flex-1">
|
||||
<div className="flex flex-wrap items-center gap-2 mb-2">
|
||||
<h3 className="text-xl sm:text-2xl font-bold text-white">{generatedSkill.title}</h3>
|
||||
<span className="text-xs font-mono text-zinc-500 bg-zinc-900 px-2 py-1 border border-zinc-800">
|
||||
v{generatedSkill.version}
|
||||
</span>
|
||||
<span className="text-xs font-mono text-purple-400 bg-purple-900/30 px-2 py-1 border border-purple-800/50">
|
||||
AI Generated
|
||||
</span>
|
||||
{isFromCache && (
|
||||
<span className="text-xs font-mono text-green-400 bg-green-900/30 px-2 py-1 border border-green-800/50">
|
||||
Cached
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-zinc-400 font-mono text-sm mb-4">{generatedSkill.description}</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{generatedSkill.tags.map((tag, idx) => (
|
||||
<span key={idx} className="text-xs bg-zinc-900 text-zinc-400 px-2 py-1 border border-zinc-800">
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col sm:flex-row gap-2 shrink-0 ml-4">
|
||||
<button
|
||||
onClick={downloadGeneratedSkillMd}
|
||||
className="flex items-center justify-center gap-2 bg-white text-black px-4 py-2 font-mono text-sm hover:bg-zinc-200 transition-colors"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
||||
</svg>
|
||||
DOWNLOAD
|
||||
</button>
|
||||
<button
|
||||
onClick={submitToMarketplace}
|
||||
className="flex items-center justify-center gap-2 bg-purple-600 text-white px-4 py-2 font-mono text-sm hover:bg-purple-500 transition-colors"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
|
||||
</svg>
|
||||
SUBMIT
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="mb-6">
|
||||
<h4 className="text-sm font-mono text-zinc-500 uppercase tracking-wider mb-2">When to Apply</h4>
|
||||
<p className="text-zinc-300">{generatedSkill.applicability}</p>
|
||||
{generatedSkill.filePatterns && generatedSkill.filePatterns.length > 0 && (
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
{generatedSkill.filePatterns.map((pattern, idx) => (
|
||||
<code key={idx} className="text-xs bg-zinc-900 text-zinc-300 px-2 py-1 border border-zinc-800">
|
||||
{pattern}
|
||||
</code>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<div className="flex border-b border-zinc-800 mb-6">
|
||||
{(['principles', 'patterns', 'antipatterns'] as const).map((tab) => (
|
||||
<button
|
||||
key={tab}
|
||||
onClick={() => setActiveTab(tab)}
|
||||
className={`px-6 py-3 font-mono text-sm uppercase tracking-wider transition-colors ${
|
||||
activeTab === tab
|
||||
? 'text-white border-b-2 border-white -mb-px'
|
||||
: 'text-zinc-500 hover:text-zinc-300'
|
||||
}`}
|
||||
>
|
||||
{tab === 'antipatterns' ? 'Anti-Patterns' : tab}
|
||||
<span className="ml-2 text-xs text-zinc-600">
|
||||
({tab === 'principles' ? generatedSkill.principles.length : tab === 'patterns' ? generatedSkill.patterns.length : generatedSkill.antiPatterns.length})
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
{activeTab === 'principles' && generatedSkill.principles.map((principle, idx) => (
|
||||
<Card key={idx} className="hover:border-zinc-600 transition-colors">
|
||||
<div className="flex items-start justify-between gap-4 mb-2">
|
||||
<h4 className="text-lg font-semibold text-white">{principle.title}</h4>
|
||||
<PriorityBadge priority={principle.priority} />
|
||||
</div>
|
||||
<p className="text-zinc-400 leading-relaxed">{principle.description}</p>
|
||||
</Card>
|
||||
))}
|
||||
|
||||
{activeTab === 'patterns' && generatedSkill.patterns.map((pattern, idx) => (
|
||||
<Card key={idx} className="hover:border-zinc-600 transition-colors">
|
||||
<h4 className="text-lg font-semibold text-white mb-2">{pattern.name}</h4>
|
||||
<p className="text-zinc-400 mb-4">{pattern.description}</p>
|
||||
<pre className="bg-zinc-950 border border-zinc-800 p-4 overflow-x-auto text-sm">
|
||||
<code className="text-zinc-300 font-mono">{pattern.example}</code>
|
||||
</pre>
|
||||
</Card>
|
||||
))}
|
||||
|
||||
{activeTab === 'antipatterns' && generatedSkill.antiPatterns.map((ap, idx) => (
|
||||
<Card key={idx} className="hover:border-zinc-600 transition-colors border-red-900/30">
|
||||
<h4 className="text-lg font-semibold text-white mb-2">{ap.name}</h4>
|
||||
<p className="text-zinc-400 mb-4">{ap.description}</p>
|
||||
{ap.badExample && (
|
||||
<div className="mb-4">
|
||||
<div className="text-xs font-mono text-red-400 mb-1 uppercase">Bad</div>
|
||||
<pre className="bg-red-950/20 border border-red-900/30 p-4 overflow-x-auto text-sm">
|
||||
<code className="text-red-300 font-mono">{ap.badExample}</code>
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
{ap.goodExample && (
|
||||
<div>
|
||||
<div className="text-xs font-mono text-zinc-300 mb-1 uppercase">Good</div>
|
||||
<pre className="bg-zinc-900/50 border border-zinc-700 p-4 overflow-x-auto text-sm">
|
||||
<code className="text-zinc-200 font-mono">{ap.goodExample}</code>
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{generatedSkill.references && generatedSkill.references.length > 0 && (
|
||||
<div className="mt-8 pt-6 border-t border-zinc-800">
|
||||
<h4 className="text-sm font-mono text-zinc-500 uppercase tracking-wider mb-3">References</h4>
|
||||
<ul className="space-y-1">
|
||||
{generatedSkill.references.map((ref, idx) => (
|
||||
<li key={idx}>
|
||||
<a
|
||||
href={ref}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="text-zinc-400 hover:text-white font-mono text-sm transition-colors"
|
||||
>
|
||||
{ref}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,551 @@
|
||||
import React, { useState, useCallback } from 'react';
|
||||
import { Card } from './Card';
|
||||
|
||||
type Mode = 'upload' | 'import';
|
||||
|
||||
interface SkillFormData {
|
||||
slug: string;
|
||||
displayName: string;
|
||||
description: string;
|
||||
version: string;
|
||||
tags: string;
|
||||
repoOwner: string;
|
||||
repoName: string;
|
||||
skillPath: string;
|
||||
authorGithub: string;
|
||||
skillContent: string;
|
||||
}
|
||||
|
||||
const INITIAL_FORM: SkillFormData = {
|
||||
slug: '',
|
||||
displayName: '',
|
||||
description: '',
|
||||
version: '1.0.0',
|
||||
tags: '',
|
||||
repoOwner: '',
|
||||
repoName: '',
|
||||
skillPath: '',
|
||||
authorGithub: '',
|
||||
skillContent: '',
|
||||
};
|
||||
|
||||
const TAG_SUGGESTIONS = [
|
||||
'react', 'typescript', 'nextjs', 'python', 'rust', 'go',
|
||||
'testing', 'api', 'database', 'devops', 'security', 'mobile',
|
||||
] as const;
|
||||
|
||||
const GITHUB_ICON = (
|
||||
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path fillRule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clipRule="evenodd" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export function SkillSubmitForm(): React.ReactElement {
|
||||
const [mode, setMode] = useState<Mode>('import');
|
||||
const [form, setForm] = useState<SkillFormData>(INITIAL_FORM);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [fileName, setFileName] = useState<string | null>(null);
|
||||
const [githubUrl, setGithubUrl] = useState('');
|
||||
const [isDetecting, setIsDetecting] = useState(false);
|
||||
const [detectError, setDetectError] = useState<string | null>(null);
|
||||
|
||||
function updateField(field: keyof SkillFormData, value: string): void {
|
||||
setForm(prev => {
|
||||
const updated = { ...prev, [field]: value };
|
||||
if (field === 'displayName' && !prev.slug) {
|
||||
updated.slug = value.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
||||
}
|
||||
return updated;
|
||||
});
|
||||
}
|
||||
|
||||
function addTag(tag: string): void {
|
||||
const currentTags = form.tags.split(',').map(t => t.trim()).filter(Boolean);
|
||||
if (!currentTags.includes(tag)) {
|
||||
updateField('tags', [...currentTags, tag].join(', '));
|
||||
}
|
||||
}
|
||||
|
||||
function parseSkillContent(content: string): void {
|
||||
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
||||
if (frontmatterMatch) {
|
||||
const fm = frontmatterMatch[1];
|
||||
const nameMatch = fm.match(/name:\s*["']?([^"'\n]+)["']?/);
|
||||
const descMatch = fm.match(/description:\s*["']?([^"'\n]+)["']?/);
|
||||
const tagsMatch = fm.match(/tags:\s*\[([^\]]+)\]/);
|
||||
const versionMatch = fm.match(/version:\s*["']?([^"'\n]+)["']?/);
|
||||
|
||||
if (nameMatch) updateField('displayName', nameMatch[1].trim());
|
||||
if (descMatch) updateField('description', descMatch[1].trim());
|
||||
if (versionMatch) updateField('version', versionMatch[1].trim());
|
||||
if (tagsMatch) {
|
||||
const tags = tagsMatch[1].replace(/["']/g, '').split(',').map(t => t.trim()).join(', ');
|
||||
updateField('tags', tags);
|
||||
}
|
||||
}
|
||||
updateField('skillContent', content);
|
||||
}
|
||||
|
||||
async function handleDetect(): Promise<void> {
|
||||
if (!githubUrl) return;
|
||||
|
||||
setIsDetecting(true);
|
||||
setDetectError(null);
|
||||
|
||||
try {
|
||||
const urlMatch = githubUrl.match(/github\.com\/([^\/]+)\/([^\/]+)(?:\/(?:tree|blob)\/[^\/]+\/(.+))?/);
|
||||
|
||||
if (!urlMatch) {
|
||||
throw new Error('Invalid GitHub URL');
|
||||
}
|
||||
|
||||
const [, owner, repo, path = ''] = urlMatch;
|
||||
|
||||
const apiUrl = `https://api.github.com/repos/${owner}/${repo}`;
|
||||
const response = await fetch(apiUrl);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Repository not found or not public');
|
||||
}
|
||||
|
||||
const repoData = await response.json();
|
||||
|
||||
updateField('repoOwner', owner);
|
||||
updateField('repoName', repo);
|
||||
updateField('authorGithub', owner);
|
||||
updateField('displayName', repoData.name.replace(/-/g, ' ').replace(/\b\w/g, (c: string) => c.toUpperCase()));
|
||||
updateField('description', repoData.description || '');
|
||||
|
||||
const slug = path ? path.split('/').filter(Boolean).pop() || repo : repo;
|
||||
updateField('slug', slug.toLowerCase().replace(/[^a-z0-9-]/g, '-'));
|
||||
|
||||
if (repoData.topics && repoData.topics.length > 0) {
|
||||
updateField('tags', repoData.topics.slice(0, 5).join(', '));
|
||||
} else {
|
||||
const inferredTags: string[] = [];
|
||||
const nameLC = (repo + ' ' + (repoData.description || '')).toLowerCase();
|
||||
if (nameLC.includes('react')) inferredTags.push('react');
|
||||
if (nameLC.includes('typescript') || nameLC.includes('ts')) inferredTags.push('typescript');
|
||||
if (nameLC.includes('python')) inferredTags.push('python');
|
||||
if (nameLC.includes('skill')) inferredTags.push('skills');
|
||||
if (inferredTags.length > 0) {
|
||||
updateField('tags', inferredTags.join(', '));
|
||||
}
|
||||
}
|
||||
|
||||
updateField('skillContent', `[Linked from GitHub: ${owner}/${repo}]`);
|
||||
updateField('skillPath', path || '/');
|
||||
|
||||
} catch (err) {
|
||||
setDetectError(err instanceof Error ? err.message : 'Detection failed');
|
||||
} finally {
|
||||
setIsDetecting(false);
|
||||
}
|
||||
}
|
||||
|
||||
const handleDragOver = useCallback(function(e: React.DragEvent): void {
|
||||
e.preventDefault();
|
||||
setIsDragging(true);
|
||||
}, []);
|
||||
|
||||
const handleDragLeave = useCallback(function(e: React.DragEvent): void {
|
||||
e.preventDefault();
|
||||
setIsDragging(false);
|
||||
}, []);
|
||||
|
||||
const processMarkdownFile = useCallback(function(file: File): void {
|
||||
setFileName(file.name);
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event) => {
|
||||
parseSkillContent(event.target?.result as string);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}, []);
|
||||
|
||||
const handleDrop = useCallback(function(e: React.DragEvent): void {
|
||||
e.preventDefault();
|
||||
setIsDragging(false);
|
||||
|
||||
const files = Array.from(e.dataTransfer.files);
|
||||
const mdFile = files.find(f => f.name.endsWith('.md'));
|
||||
|
||||
if (mdFile) {
|
||||
processMarkdownFile(mdFile);
|
||||
}
|
||||
}, [processMarkdownFile]);
|
||||
|
||||
function handleFileSelect(e: React.ChangeEvent<HTMLInputElement>): void {
|
||||
const file = e.target.files?.[0];
|
||||
if (file && file.name.endsWith('.md')) {
|
||||
processMarkdownFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
const validation = {
|
||||
slug: !form.slug ? 'Slug is required.' : null,
|
||||
displayName: !form.displayName ? 'Display name is required.' : null,
|
||||
content: mode === 'upload' && !form.skillContent ? 'Upload a SKILL.md file.' : null,
|
||||
repo: mode === 'import' && (!form.repoOwner || !form.repoName) ? 'Click Detect to import repo.' : null,
|
||||
tags: !form.tags ? 'Add at least one tag.' : null,
|
||||
};
|
||||
|
||||
const isImported = mode === 'import' && form.repoOwner && form.repoName;
|
||||
const errors = Object.values(validation).filter(Boolean);
|
||||
const isValid = errors.length === 0;
|
||||
const tagsArray = form.tags.split(',').map(t => t.trim()).filter(Boolean);
|
||||
|
||||
function generateIssueUrl(): string {
|
||||
const skillId = form.repoOwner && form.repoName
|
||||
? `${form.repoOwner}/${form.repoName}/${form.slug}`
|
||||
: `community/${form.authorGithub || 'anonymous'}/${form.slug}`;
|
||||
|
||||
const jsonEntry = JSON.stringify({
|
||||
id: skillId,
|
||||
name: form.displayName,
|
||||
description: form.description || '',
|
||||
source: `${form.repoOwner}/${form.repoName}`,
|
||||
tags: tagsArray,
|
||||
author: form.authorGithub || form.repoOwner
|
||||
}, null, 2);
|
||||
|
||||
const title = isImported
|
||||
? encodeURIComponent(`[Import] ${form.repoOwner}/${form.repoName}`)
|
||||
: encodeURIComponent(`[Skill] ${form.displayName}`);
|
||||
|
||||
const bodyContent = isImported
|
||||
? `## 📦 Import Request: ${form.repoOwner}/${form.repoName}
|
||||
|
||||
### Repository
|
||||
🔗 https://github.com/${form.repoOwner}/${form.repoName}
|
||||
|
||||
### Add to \`marketplace/skills.json\`
|
||||
|
||||
\`\`\`json
|
||||
${jsonEntry}
|
||||
\`\`\`
|
||||
|
||||
### Checklist for Maintainer
|
||||
- [ ] Verify repository is public
|
||||
- [ ] Add JSON entry to \`marketplace/skills.json\`
|
||||
|
||||
---
|
||||
**Submitted by:** @${form.authorGithub || 'anonymous'}
|
||||
**Owner:** @${form.repoOwner} (retains all rights)`
|
||||
: `## 📤 Skill Upload: ${form.displayName}
|
||||
|
||||
### Add to \`marketplace/skills.json\`
|
||||
|
||||
\`\`\`json
|
||||
${jsonEntry}
|
||||
\`\`\`
|
||||
|
||||
### SKILL.md Content
|
||||
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
|
||||
\`\`\`markdown
|
||||
${form.skillContent.slice(0, 4000)}${form.skillContent.length > 4000 ? '\n...(truncated)' : ''}
|
||||
\`\`\`
|
||||
|
||||
</details>
|
||||
|
||||
### Checklist for Maintainer
|
||||
- [ ] Review SKILL.md content
|
||||
- [ ] Add JSON entry to \`marketplace/skills.json\`
|
||||
|
||||
---
|
||||
**Author:** @${form.authorGithub || 'anonymous'}`;
|
||||
|
||||
const body = encodeURIComponent(bodyContent);
|
||||
const labels = isImported ? 'skill-import' : 'skill-submission';
|
||||
return `https://github.com/rohitg00/skillkit/issues/new?title=${title}&body=${body}&labels=${labels}`;
|
||||
}
|
||||
|
||||
function handleSubmitClick(e: React.MouseEvent): void {
|
||||
e.preventDefault();
|
||||
if (isValid) {
|
||||
const url = generateIssueUrl();
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex border-b border-zinc-800">
|
||||
<button
|
||||
onClick={() => setMode('import')}
|
||||
className={`px-6 py-3 font-mono text-sm transition-colors ${
|
||||
mode === 'import'
|
||||
? 'text-white border-b-2 border-white -mb-px'
|
||||
: 'text-zinc-500 hover:text-zinc-300'
|
||||
}`}
|
||||
>
|
||||
Import from GitHub
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setMode('upload')}
|
||||
className={`px-6 py-3 font-mono text-sm transition-colors ${
|
||||
mode === 'upload'
|
||||
? 'text-white border-b-2 border-white -mb-px'
|
||||
: 'text-zinc-500 hover:text-zinc-300'
|
||||
}`}
|
||||
>
|
||||
Upload File
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="space-y-6">
|
||||
{mode === 'import' && (
|
||||
<Card>
|
||||
<div className="flex items-center justify-between mb-1">
|
||||
<label className="text-sm text-zinc-400">GitHub URL</label>
|
||||
<span className="text-xs text-zinc-600">Repo, tree path, or blob</span>
|
||||
</div>
|
||||
<div className="flex gap-3 mt-2">
|
||||
<input
|
||||
type="text"
|
||||
value={githubUrl}
|
||||
onChange={(e) => setGithubUrl(e.target.value)}
|
||||
placeholder="https://github.com/owner/repo"
|
||||
className="flex-1 bg-zinc-900 border border-zinc-700 text-white px-4 py-2.5 font-mono text-sm focus:ring-1 focus:ring-white focus:border-white outline-none placeholder-zinc-600"
|
||||
/>
|
||||
<button
|
||||
onClick={handleDetect}
|
||||
disabled={isDetecting || !githubUrl}
|
||||
className={`px-5 py-2.5 font-mono text-sm transition-colors ${
|
||||
isDetecting || !githubUrl
|
||||
? 'bg-zinc-800 text-zinc-600 cursor-not-allowed'
|
||||
: 'bg-white text-black hover:bg-zinc-200'
|
||||
}`}
|
||||
>
|
||||
{isDetecting ? 'Detecting...' : 'Detect'}
|
||||
</button>
|
||||
</div>
|
||||
{detectError && (
|
||||
<p className="text-red-400 text-xs mt-2 font-mono">{detectError}</p>
|
||||
)}
|
||||
{isImported && (
|
||||
<p className="text-zinc-300 text-xs mt-2 font-mono flex items-center gap-1">
|
||||
<svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
Repository detected - {form.repoOwner}/{form.repoName}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-zinc-600 text-xs mt-3">
|
||||
Public repos only. We link to the original - owner retains all rights.
|
||||
</p>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{mode === 'upload' && (
|
||||
<Card
|
||||
className={`transition-colors ${isDragging ? 'border-white bg-zinc-900' : ''}`}
|
||||
onDragOver={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
>
|
||||
<div className="text-center py-6">
|
||||
<div className="mb-3">
|
||||
<svg className="w-8 h-8 mx-auto text-zinc-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-zinc-400 text-sm mb-1">
|
||||
{fileName ? (
|
||||
<span className="text-white">{fileName}</span>
|
||||
) : (
|
||||
'Drop SKILL.md here'
|
||||
)}
|
||||
</p>
|
||||
<p className="text-zinc-600 text-xs mb-3">or</p>
|
||||
<label className="inline-block cursor-pointer">
|
||||
<span className="bg-zinc-800 hover:bg-zinc-700 text-white px-4 py-2 text-sm font-mono transition-colors">
|
||||
Choose file
|
||||
</span>
|
||||
<input
|
||||
type="file"
|
||||
accept=".md"
|
||||
onChange={handleFileSelect}
|
||||
className="hidden"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<Card>
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm text-zinc-400 mb-1.5">Slug</label>
|
||||
<input
|
||||
type="text"
|
||||
value={form.slug}
|
||||
onChange={(e) => updateField('slug', e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ''))}
|
||||
placeholder="my-skill"
|
||||
className="w-full bg-zinc-900 border border-zinc-700 text-white px-3 py-2 font-mono text-sm focus:ring-1 focus:ring-white focus:border-white outline-none placeholder-zinc-600"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm text-zinc-400 mb-1.5">Display name</label>
|
||||
<input
|
||||
type="text"
|
||||
value={form.displayName}
|
||||
onChange={(e) => updateField('displayName', e.target.value)}
|
||||
placeholder="My Skill"
|
||||
className="w-full bg-zinc-900 border border-zinc-700 text-white px-3 py-2 font-mono text-sm focus:ring-1 focus:ring-white focus:border-white outline-none placeholder-zinc-600"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm text-zinc-400 mb-1.5">Version</label>
|
||||
<input
|
||||
type="text"
|
||||
value={form.version}
|
||||
onChange={(e) => updateField('version', e.target.value)}
|
||||
placeholder="1.0.0"
|
||||
className="w-full bg-zinc-900 border border-zinc-700 text-white px-3 py-2 font-mono text-sm focus:ring-1 focus:ring-white focus:border-white outline-none placeholder-zinc-600"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm text-zinc-400 mb-1.5">Tags</label>
|
||||
<input
|
||||
type="text"
|
||||
value={form.tags}
|
||||
onChange={(e) => updateField('tags', e.target.value)}
|
||||
placeholder="react, typescript"
|
||||
className="w-full bg-zinc-900 border border-zinc-700 text-white px-3 py-2 font-mono text-sm focus:ring-1 focus:ring-white focus:border-white outline-none placeholder-zinc-600"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{TAG_SUGGESTIONS.map((tag) => (
|
||||
<button
|
||||
key={tag}
|
||||
type="button"
|
||||
onClick={() => addTag(tag)}
|
||||
className="text-xs text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 px-2 py-0.5 border border-zinc-800 transition-colors"
|
||||
>
|
||||
+{tag}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="space-y-6">
|
||||
<Card>
|
||||
<h4 className="text-sm text-zinc-400 mb-4">Preview</h4>
|
||||
<div className="bg-zinc-950 border border-zinc-800 p-4">
|
||||
<div className="flex items-start justify-between mb-3">
|
||||
<div>
|
||||
<h5 className="text-white font-semibold">
|
||||
{form.displayName || 'Skill Name'}
|
||||
</h5>
|
||||
<p className="text-zinc-500 text-sm mt-1">
|
||||
{form.description || 'No description'}
|
||||
</p>
|
||||
</div>
|
||||
<span className="text-xs font-mono text-zinc-600 bg-zinc-900 px-2 py-1">
|
||||
v{form.version}
|
||||
</span>
|
||||
</div>
|
||||
{(form.repoOwner || form.authorGithub) && (
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-600 font-mono mb-3">
|
||||
{form.repoOwner && form.repoName && <span>{form.repoOwner}/{form.repoName}</span>}
|
||||
{form.authorGithub && (
|
||||
<>
|
||||
{form.repoOwner && <span>•</span>}
|
||||
<span>@{form.authorGithub}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{tagsArray.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{tagsArray.map((tag, i) => (
|
||||
<span key={i} className="text-xs bg-zinc-900 text-zinc-500 px-2 py-0.5 border border-zinc-800">
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{isImported ? (
|
||||
<Card className="border-blue-900/50">
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
<div className="w-8 h-8 bg-blue-900/30 border border-blue-800 flex items-center justify-center">
|
||||
<svg className="w-4 h-4 text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-sm text-white font-medium">Linked Repository</h4>
|
||||
<p className="text-xs text-zinc-500">Skills hosted by @{form.repoOwner}</p>
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
href={`https://github.com/${form.repoOwner}/${form.repoName}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-blue-400 hover:text-blue-300 font-mono flex items-center gap-2"
|
||||
>
|
||||
github.com/{form.repoOwner}/{form.repoName}
|
||||
<svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
|
||||
</svg>
|
||||
</a>
|
||||
</Card>
|
||||
) : form.skillContent && !form.skillContent.startsWith('[Linked') ? (
|
||||
<Card>
|
||||
<h4 className="text-sm text-zinc-400 mb-3">SKILL.md</h4>
|
||||
<pre className="bg-zinc-950 border border-zinc-800 p-3 text-xs font-mono text-zinc-400 max-h-48 overflow-auto">
|
||||
{form.skillContent.slice(0, 1000)}
|
||||
{form.skillContent.length > 1000 && '\n...'}
|
||||
</pre>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{errors.length > 0 && (
|
||||
<div className="space-y-1 text-xs font-mono text-yellow-500">
|
||||
{errors.map((error, i) => (
|
||||
<div key={i} className="flex items-center gap-1">
|
||||
<span className="text-yellow-600">•</span> {error}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSubmitClick}
|
||||
disabled={!isValid}
|
||||
className={`flex items-center justify-center gap-3 w-full py-4 font-mono text-sm transition-all ${
|
||||
isValid
|
||||
? 'bg-white text-black hover:bg-zinc-200'
|
||||
: 'bg-zinc-800 text-zinc-600 cursor-not-allowed'
|
||||
}`}
|
||||
>
|
||||
{GITHUB_ICON}
|
||||
{isImported ? 'Import to marketplace' : 'Publish skill'}
|
||||
</button>
|
||||
|
||||
<p className="text-xs text-zinc-600 text-center font-mono">
|
||||
{isImported
|
||||
? 'Links to original repo → Owner retains rights'
|
||||
: 'Opens GitHub issue → We review → Added to marketplace'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import React from 'react';
|
||||
|
||||
interface TerminalProps {
|
||||
title?: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
interface CodeBlockProps {
|
||||
code: string;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
interface CommandProps {
|
||||
cmd: string;
|
||||
comment?: string;
|
||||
}
|
||||
|
||||
export function Terminal({ title = 'bash', children, className = '' }: TerminalProps): React.ReactElement {
|
||||
return (
|
||||
<div className={`rounded-lg overflow-hidden border border-zinc-800 bg-[#09090b] shadow-2xl ${className}`}>
|
||||
<div className="flex items-center justify-between px-4 py-2 border-b border-zinc-800 bg-zinc-900/50">
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-3 h-3 rounded-full bg-zinc-700"></div>
|
||||
<div className="w-3 h-3 rounded-full bg-zinc-700"></div>
|
||||
<div className="w-3 h-3 rounded-full bg-zinc-700"></div>
|
||||
</div>
|
||||
<div className="text-xs text-zinc-500 font-mono">{title}</div>
|
||||
<div className="w-10"></div>
|
||||
</div>
|
||||
<div className="p-4 font-mono text-sm overflow-x-auto">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CodeBlock({ code }: CodeBlockProps): React.ReactElement {
|
||||
return (
|
||||
<pre className="text-zinc-300 font-mono text-sm leading-relaxed whitespace-pre-wrap">
|
||||
{code}
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
|
||||
export function Command({ cmd, comment }: CommandProps): React.ReactElement {
|
||||
return (
|
||||
<div className="mb-2">
|
||||
<div className="flex text-zinc-100">
|
||||
<span className="text-zinc-500 mr-2">$</span>
|
||||
<span>{cmd}</span>
|
||||
</div>
|
||||
{comment && <div className="text-zinc-500 text-xs mt-1 ml-4"># {comment}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "SkillKit Marketplace",
|
||||
"description": "Schema for SkillKit marketplace skills index",
|
||||
"type": "object",
|
||||
"required": ["version", "skills"],
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "Schema version number"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "Last update date (YYYY-MM-DD)"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"description": "List of skills in the marketplace",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Skill"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Skill": {
|
||||
"type": "object",
|
||||
"required": ["id", "name", "source", "tags"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_-]+$",
|
||||
"description": "Unique identifier: owner/repo/skill-name"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"description": "Human-readable skill name"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 500,
|
||||
"description": "Brief description of the skill"
|
||||
},
|
||||
"source": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+$",
|
||||
"description": "GitHub repository: owner/repo"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$"
|
||||
},
|
||||
"minItems": 1,
|
||||
"maxItems": 10,
|
||||
"description": "Tags for categorization (lowercase, hyphenated)"
|
||||
},
|
||||
"author": {
|
||||
"type": "string",
|
||||
"description": "Skill author name or GitHub username"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
||||
"description": "Semantic version (e.g., 1.0.0)"
|
||||
},
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"claude-code",
|
||||
"cursor",
|
||||
"codex",
|
||||
"gemini-cli",
|
||||
"opencode",
|
||||
"antigravity",
|
||||
"amp",
|
||||
"clawdbot",
|
||||
"droid",
|
||||
"github-copilot",
|
||||
"goose",
|
||||
"kilo",
|
||||
"kiro-cli",
|
||||
"roo",
|
||||
"trae",
|
||||
"windsurf",
|
||||
"universal"
|
||||
]
|
||||
},
|
||||
"description": "Compatible AI agents (omit for universal compatibility)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Single source of truth: marketplace/skills.json
|
||||
import skillsData from '../../../marketplace/skills.json';
|
||||
|
||||
export interface IndexedSkill {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
source: string;
|
||||
sourceUrl: string;
|
||||
rawUrl: string;
|
||||
tags: string[];
|
||||
}
|
||||
|
||||
function buildSkillIndex(): IndexedSkill[] {
|
||||
return skillsData.skills.map(skill => {
|
||||
const sourceParts = skill.source?.split('/') || [];
|
||||
const owner = sourceParts[0] || 'unknown';
|
||||
const repo = sourceParts[1] || 'unknown';
|
||||
const skillSlug = skill.id.split('/').pop() || skill.name.toLowerCase().replace(/\s+/g, '-');
|
||||
|
||||
return {
|
||||
id: skill.id,
|
||||
name: skill.name,
|
||||
description: skill.description || '',
|
||||
source: skill.source || '',
|
||||
sourceUrl: owner !== 'unknown' ? `https://github.com/${skill.source}` : '',
|
||||
rawUrl: owner !== 'unknown' && repo !== 'unknown'
|
||||
? `https://raw.githubusercontent.com/${owner}/${repo}/main/skills/${skillSlug}/SKILL.md`
|
||||
: '',
|
||||
tags: skill.tags || [],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export const SKILLS_INDEX: IndexedSkill[] = buildSkillIndex();
|
||||
|
||||
export function searchSkills(query: string): IndexedSkill[] {
|
||||
const q = query.toLowerCase().trim();
|
||||
if (!q) return [];
|
||||
|
||||
return SKILLS_INDEX.filter(skill =>
|
||||
skill.name.toLowerCase().includes(q) ||
|
||||
skill.description.toLowerCase().includes(q) ||
|
||||
skill.tags.some(tag => tag.toLowerCase().includes(q))
|
||||
).slice(0, 20);
|
||||
}
|
||||
|
||||
export function getSkillsByTag(tag: string): IndexedSkill[] {
|
||||
return SKILLS_INDEX.filter(skill =>
|
||||
skill.tags.some(t => t.toLowerCase() === tag.toLowerCase())
|
||||
);
|
||||
}
|
||||
|
||||
export function getAllTags(): string[] {
|
||||
const tags = new Set<string>();
|
||||
SKILLS_INDEX.forEach(skill => skill.tags.forEach(tag => tags.add(tag)));
|
||||
return Array.from(tags).sort();
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>SkillKit - Universal Skills for AI Coding Agents</title>
|
||||
<meta name="description" content="Portable, reusable skills that work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more AI coding agents.">
|
||||
|
||||
<!-- Open Graph -->
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://skillkit.dev/">
|
||||
<meta property="og:title" content="SkillKit - Universal Skills for AI Coding Agents">
|
||||
<meta property="og:description" content="Portable, reusable skills that work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more AI coding agents.">
|
||||
<meta property="og:image" content="/og-image.png">
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:title" content="SkillKit - Universal Skills for AI Coding Agents">
|
||||
<meta name="twitter:description" content="Portable, reusable skills that work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more AI coding agents.">
|
||||
<meta name="twitter:image" content="/og-image.png">
|
||||
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
screens: {
|
||||
'xs': '475px',
|
||||
'sm': '640px',
|
||||
'md': '768px',
|
||||
'lg': '1024px',
|
||||
'xl': '1280px',
|
||||
'2xl': '1536px',
|
||||
},
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'sans-serif'],
|
||||
mono: ['JetBrains Mono', 'monospace'],
|
||||
},
|
||||
colors: {
|
||||
background: '#000000',
|
||||
surface: '#09090b',
|
||||
border: '#27272a',
|
||||
highlight: '#ffffff',
|
||||
},
|
||||
animation: {
|
||||
'cursor-blink': 'blink 1s step-end infinite',
|
||||
},
|
||||
keyframes: {
|
||||
blink: {
|
||||
'0%, 100%': { opacity: '1' },
|
||||
'50%': { opacity: '0' },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
background-color: #000000;
|
||||
color: #e4e4e7;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6, .font-mono {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
}
|
||||
::selection {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
background: #000000;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #27272a;
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #3f3f46;
|
||||
}
|
||||
|
||||
.terminal-scanline {
|
||||
background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.1));
|
||||
background-size: 100% 4px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
opacity: 0.1;
|
||||
}
|
||||
</style>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"react/": "https://esm.sh/react@^19.2.3/",
|
||||
"react": "https://esm.sh/react@^19.2.3",
|
||||
"@google/genai": "https://esm.sh/@google/genai@^1.38.0",
|
||||
"react-dom/": "https://esm.sh/react-dom@^19.2.3/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
|
||||
const rootElement = document.getElementById('root');
|
||||
if (!rootElement) {
|
||||
throw new Error("Could not find root element to mount to");
|
||||
}
|
||||
|
||||
const root = ReactDOM.createRoot(rootElement);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "SkillKit",
|
||||
"description": "Supercharge Every AI Coding Agent. Translate, manage, and sync skills across Claude, Cursor, Windsurf, and 17+ agents.",
|
||||
"requestFramePermissions": []
|
||||
}
|
||||
Generated
+2709
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "skillkit",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.3",
|
||||
"@google/genai": "^1.38.0",
|
||||
"react-dom": "^19.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.14.0",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"typescript": "~5.8.2",
|
||||
"vite": "^6.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>SkillKit</title>
|
||||
<script type="text/javascript">
|
||||
// Single Page Apps for GitHub Pages
|
||||
// MIT License
|
||||
// https://github.com/rafgraph/spa-github-pages
|
||||
var pathSegmentsToKeep = 1;
|
||||
var l = window.location;
|
||||
l.replace(
|
||||
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
|
||||
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
|
||||
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
|
||||
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
|
||||
l.hash
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 437 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
||||
<rect width="32" height="32" fill="#000000"/>
|
||||
<rect x="8" y="8" width="16" height="16" fill="#ffffff"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 176 B |
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
@@ -0,0 +1,124 @@
|
||||
import { GoogleGenAI, Type, Schema } from "@google/genai";
|
||||
import { AgentSkill } from "../types";
|
||||
|
||||
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY });
|
||||
|
||||
const agentSkillSchema: Schema = {
|
||||
type: Type.OBJECT,
|
||||
properties: {
|
||||
name: { type: Type.STRING, description: "Skill name in slug format (e.g., 'react-best-practices')" },
|
||||
title: { type: Type.STRING, description: "Human readable title" },
|
||||
description: { type: Type.STRING, description: "Brief description of what this skill teaches AI agents" },
|
||||
version: { type: Type.STRING, description: "Semantic version (e.g., '1.0.0')" },
|
||||
tags: {
|
||||
type: Type.ARRAY,
|
||||
items: { type: Type.STRING },
|
||||
description: "Tags for categorization"
|
||||
},
|
||||
applicability: { type: Type.STRING, description: "When the AI agent should apply this skill (e.g., 'Apply when working with React components')" },
|
||||
principles: {
|
||||
type: Type.ARRAY,
|
||||
items: {
|
||||
type: Type.OBJECT,
|
||||
properties: {
|
||||
title: { type: Type.STRING },
|
||||
description: { type: Type.STRING, description: "Detailed instruction for the AI agent" },
|
||||
priority: { type: Type.STRING, description: "must, should, or may" }
|
||||
},
|
||||
required: ["title", "description", "priority"]
|
||||
},
|
||||
description: "Core principles and guidelines (5-8 items)"
|
||||
},
|
||||
patterns: {
|
||||
type: Type.ARRAY,
|
||||
items: {
|
||||
type: Type.OBJECT,
|
||||
properties: {
|
||||
name: { type: Type.STRING },
|
||||
description: { type: Type.STRING },
|
||||
example: { type: Type.STRING, description: "Code example demonstrating the pattern" },
|
||||
language: { type: Type.STRING, description: "Programming language for syntax highlighting" }
|
||||
},
|
||||
required: ["name", "description", "example"]
|
||||
},
|
||||
description: "Code patterns with examples (3-5 items)"
|
||||
},
|
||||
antiPatterns: {
|
||||
type: Type.ARRAY,
|
||||
items: {
|
||||
type: Type.OBJECT,
|
||||
properties: {
|
||||
name: { type: Type.STRING },
|
||||
description: { type: Type.STRING },
|
||||
badExample: { type: Type.STRING, description: "Code showing what NOT to do" },
|
||||
goodExample: { type: Type.STRING, description: "Code showing the correct approach" }
|
||||
},
|
||||
required: ["name", "description"]
|
||||
},
|
||||
description: "Anti-patterns to avoid (2-4 items)"
|
||||
},
|
||||
filePatterns: {
|
||||
type: Type.ARRAY,
|
||||
items: { type: Type.STRING },
|
||||
description: "Glob patterns for files this skill applies to (e.g., '*.tsx', 'src/components/**')"
|
||||
},
|
||||
references: {
|
||||
type: Type.ARRAY,
|
||||
items: { type: Type.STRING },
|
||||
description: "Links to official documentation or resources"
|
||||
}
|
||||
},
|
||||
required: ["name", "title", "description", "version", "tags", "applicability", "principles", "patterns", "antiPatterns"]
|
||||
};
|
||||
|
||||
export const generateAgentSkill = async (topic: string): Promise<AgentSkill> => {
|
||||
const sanitizedTopic = topic?.trim().slice(0, 500) || '';
|
||||
if (!sanitizedTopic) {
|
||||
throw new Error("Topic is required");
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await ai.models.generateContent({
|
||||
model: "gemini-2.0-flash",
|
||||
contents: `Create a comprehensive AI coding agent skill for: "${sanitizedTopic}"
|
||||
|
||||
This skill will be used by AI coding assistants (like Claude Code, Cursor, GitHub Copilot) to provide better code suggestions and follow best practices.
|
||||
|
||||
The skill should include:
|
||||
1. Clear principles that tell the AI WHAT to do and WHEN
|
||||
2. Code patterns with REAL, WORKING examples (not pseudocode)
|
||||
3. Anti-patterns showing common mistakes and how to fix them
|
||||
4. Specific file patterns where this skill applies
|
||||
|
||||
Make the instructions actionable and specific. The AI agent should be able to directly apply these guidelines when writing code.
|
||||
|
||||
Focus on practical, production-ready patterns used in modern development.`,
|
||||
config: {
|
||||
responseMimeType: "application/json",
|
||||
responseSchema: agentSkillSchema,
|
||||
systemInstruction: `You are an expert software architect creating AI agent skills.
|
||||
Your skills are used by AI coding assistants to write better code.
|
||||
|
||||
Guidelines:
|
||||
- Write instructions as commands to the AI (e.g., "Always use...", "Never...", "Prefer...")
|
||||
- Include REAL code examples, not pseudocode
|
||||
- Be specific and actionable
|
||||
- Focus on modern best practices (2024+)
|
||||
- Include edge cases and error handling patterns
|
||||
- Make principles enforceable and testable`
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.text) {
|
||||
throw new Error("No response from Gemini.");
|
||||
}
|
||||
|
||||
const data = JSON.parse(response.text) as AgentSkill;
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Gemini API Error:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const generateLearningPath: (topic: string) => Promise<AgentSkill> = generateAgentSkill;
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"module": "ESNext",
|
||||
"lib": [
|
||||
"ES2022",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"moduleResolution": "bundler",
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"allowJs": true,
|
||||
"jsx": "react-jsx",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./*"
|
||||
]
|
||||
},
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
export interface LearningStep {
|
||||
title: string;
|
||||
description: string;
|
||||
duration: string;
|
||||
keyConcepts: string[];
|
||||
}
|
||||
|
||||
export interface LearningPath {
|
||||
skill: string;
|
||||
description: string;
|
||||
steps: LearningStep[];
|
||||
}
|
||||
|
||||
export interface GenerateSkillResponse {
|
||||
learningPath: LearningPath;
|
||||
}
|
||||
|
||||
export enum LoadingState {
|
||||
IDLE = 'IDLE',
|
||||
LOADING = 'LOADING',
|
||||
SUCCESS = 'SUCCESS',
|
||||
ERROR = 'ERROR'
|
||||
}
|
||||
|
||||
export interface AgentSkill {
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
version: string;
|
||||
tags: string[];
|
||||
applicability: string;
|
||||
principles: SkillPrinciple[];
|
||||
patterns: SkillPattern[];
|
||||
antiPatterns: SkillAntiPattern[];
|
||||
filePatterns?: string[];
|
||||
references?: string[];
|
||||
}
|
||||
|
||||
export interface SkillPrinciple {
|
||||
title: string;
|
||||
description: string;
|
||||
priority: 'must' | 'should' | 'may';
|
||||
}
|
||||
|
||||
export interface SkillPattern {
|
||||
name: string;
|
||||
description: string;
|
||||
example: string;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
export interface SkillAntiPattern {
|
||||
name: string;
|
||||
description: string;
|
||||
badExample?: string;
|
||||
goodExample?: string;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"buildCommand": "npm run build",
|
||||
"outputDirectory": "dist",
|
||||
"installCommand": "npm install",
|
||||
"framework": "vite"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import path from 'path';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, '.', '');
|
||||
return {
|
||||
base: '/',
|
||||
server: {
|
||||
port: 3000,
|
||||
host: '0.0.0.0',
|
||||
},
|
||||
plugins: [react()],
|
||||
define: {
|
||||
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
|
||||
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, '.'),
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,761 @@
|
||||
/**
|
||||
* E2E Tests: Skill Translator
|
||||
*
|
||||
* End-to-end tests for cross-agent skill translation.
|
||||
* Tests the complete workflow of parsing, translating, and writing skills.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
||||
import {
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
readTestFile,
|
||||
} from './helpers/cli-runner.js';
|
||||
import {
|
||||
parseSkillToCanonical,
|
||||
parseSkillContentToCanonical,
|
||||
translateSkillToAgent,
|
||||
translateSkillToAll,
|
||||
writeTranslatedSkill,
|
||||
generateSkillsConfig,
|
||||
getAgentSkillsDir,
|
||||
getAgentConfigFile,
|
||||
AGENT_SKILL_FORMATS,
|
||||
type CrossAgentSkill,
|
||||
} from '@skillkit/core';
|
||||
|
||||
// All 17 supported agents
|
||||
const SUPPORTED_AGENTS = [
|
||||
'claude-code',
|
||||
'cursor',
|
||||
'codex',
|
||||
'gemini-cli',
|
||||
'opencode',
|
||||
'antigravity',
|
||||
'amp',
|
||||
'clawdbot',
|
||||
'droid',
|
||||
'github-copilot',
|
||||
'goose',
|
||||
'kilo',
|
||||
'kiro-cli',
|
||||
'roo',
|
||||
'trae',
|
||||
'windsurf',
|
||||
'universal',
|
||||
] as const;
|
||||
|
||||
describe('E2E: Skill Translator - Parsing', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir('skillkit-translator-');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('parseSkillToCanonical', () => {
|
||||
it('should parse a complete SKILL.md with all frontmatter fields', () => {
|
||||
const skillDir = join(testDir, 'complete-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: complete-skill
|
||||
description: A comprehensive skill for E2E testing
|
||||
version: "2.0.0"
|
||||
author: SkillKit Team
|
||||
tags:
|
||||
- testing
|
||||
- e2e
|
||||
- comprehensive
|
||||
allowed-tools: Read, Write, Bash(npm:*)
|
||||
---
|
||||
# Complete Skill
|
||||
|
||||
This skill tests all parsing capabilities.
|
||||
|
||||
## Features
|
||||
|
||||
- Full frontmatter parsing
|
||||
- Content extraction
|
||||
- Agent-specific field handling
|
||||
|
||||
## Usage
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read complete-skill
|
||||
\`\`\`
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.name).toBe('complete-skill');
|
||||
expect(result?.description).toBe('A comprehensive skill for E2E testing');
|
||||
expect(result?.version).toBe('2.0.0');
|
||||
expect(result?.author).toBe('SkillKit Team');
|
||||
expect(result?.tags).toEqual(['testing', 'e2e', 'comprehensive']);
|
||||
expect(result?.allowedTools).toEqual(['Read', 'Write', 'Bash(npm:*)']);
|
||||
expect(result?.content).toContain('# Complete Skill');
|
||||
expect(result?.content).toContain('## Features');
|
||||
});
|
||||
|
||||
it('should handle SKILL.md with minimal frontmatter', () => {
|
||||
const skillDir = join(testDir, 'minimal-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: minimal-skill
|
||||
description: Just the basics
|
||||
---
|
||||
# Minimal Skill
|
||||
|
||||
Simple content.
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.name).toBe('minimal-skill');
|
||||
expect(result?.description).toBe('Just the basics');
|
||||
expect(result?.version).toBeUndefined();
|
||||
expect(result?.author).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should extract description from content when not in frontmatter', () => {
|
||||
const skillDir = join(testDir, 'no-desc-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: no-desc-skill
|
||||
---
|
||||
This is the first paragraph which should become the description automatically.
|
||||
|
||||
## More Content
|
||||
|
||||
Additional content here.
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.description).toContain('This is the first paragraph');
|
||||
});
|
||||
|
||||
it('should handle SKILL.md without any frontmatter', () => {
|
||||
const skillDir = join(testDir, 'no-frontmatter');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `# No Frontmatter Skill
|
||||
|
||||
This skill has no YAML frontmatter at all.
|
||||
|
||||
## Usage
|
||||
|
||||
Just use it directly.
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
// Name should be derived from directory
|
||||
expect(result?.name).toBe('no-frontmatter');
|
||||
expect(result?.content).toContain('# No Frontmatter Skill');
|
||||
});
|
||||
|
||||
it('should return null for non-existent skill directory', () => {
|
||||
const result = parseSkillToCanonical(join(testDir, 'does-not-exist'));
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for directory without SKILL.md', () => {
|
||||
const emptyDir = join(testDir, 'empty-dir');
|
||||
mkdirSync(emptyDir, { recursive: true });
|
||||
writeFileSync(join(emptyDir, 'README.md'), '# Not a skill');
|
||||
|
||||
const result = parseSkillToCanonical(emptyDir);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseSkillContentToCanonical', () => {
|
||||
it('should parse content with Claude Code specific fields', () => {
|
||||
const content = `---
|
||||
name: claude-specific
|
||||
description: Skill with Claude Code specific fields
|
||||
model: opus
|
||||
context: fork
|
||||
disable-model-invocation: true
|
||||
---
|
||||
# Claude Specific Skill
|
||||
|
||||
Use with Claude Code for best results.
|
||||
`;
|
||||
|
||||
const result = parseSkillContentToCanonical(content, '/path/to/skill', 'claude-code');
|
||||
|
||||
expect(result?.name).toBe('claude-specific');
|
||||
expect(result?.agentFields?.model).toBe('opus');
|
||||
expect(result?.agentFields?.context).toBe('fork');
|
||||
expect(result?.agentFields?.['disable-model-invocation']).toBe(true);
|
||||
expect(result?.sourceAgent).toBe('claude-code');
|
||||
});
|
||||
|
||||
it('should parse content with Cursor specific fields', () => {
|
||||
const content = `---
|
||||
name: cursor-specific
|
||||
description: Skill with Cursor specific fields
|
||||
globs: "**/*.ts"
|
||||
alwaysApply: true
|
||||
---
|
||||
# Cursor Specific Skill
|
||||
|
||||
Optimized for Cursor.
|
||||
`;
|
||||
|
||||
const result = parseSkillContentToCanonical(content, '/path/to/skill', 'cursor');
|
||||
|
||||
expect(result?.name).toBe('cursor-specific');
|
||||
expect(result?.agentFields?.globs).toBe('**/*.ts');
|
||||
expect(result?.agentFields?.alwaysApply).toBe(true);
|
||||
expect(result?.sourceAgent).toBe('cursor');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Skill Translator - Translation', () => {
|
||||
let testDir: string;
|
||||
let testSkill: CrossAgentSkill;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir('skillkit-translate-');
|
||||
testSkill = {
|
||||
name: 'translation-test',
|
||||
description: 'A skill designed for testing cross-agent translation',
|
||||
content: `# Translation Test Skill
|
||||
|
||||
This skill is used to verify that translation works correctly across all supported agents.
|
||||
|
||||
## Features
|
||||
|
||||
- Cross-agent compatibility
|
||||
- Frontmatter preservation
|
||||
- Content integrity
|
||||
|
||||
## Usage
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read translation-test
|
||||
\`\`\`
|
||||
`,
|
||||
frontmatter: {
|
||||
name: 'translation-test',
|
||||
description: 'A skill designed for testing cross-agent translation',
|
||||
version: '1.0.0',
|
||||
author: 'SkillKit E2E Tests',
|
||||
tags: ['testing', 'translation'],
|
||||
},
|
||||
sourcePath: join(testDir, 'translation-test'),
|
||||
sourceAgent: 'claude-code',
|
||||
version: '1.0.0',
|
||||
author: 'SkillKit E2E Tests',
|
||||
tags: ['testing', 'translation'],
|
||||
allowedTools: ['Read', 'Write', 'Bash'],
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('translateSkillToAgent', () => {
|
||||
it.each(SUPPORTED_AGENTS)('should translate skill to %s format', (agent) => {
|
||||
const result = translateSkillToAgent(testSkill, agent);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.targetAgent).toBe(agent);
|
||||
expect(result.content).toBeTruthy();
|
||||
expect(result.content).toContain('translation-test');
|
||||
expect(typeof result.filename).toBe('string');
|
||||
});
|
||||
|
||||
it('should preserve skill name and description across translations', () => {
|
||||
for (const agent of SUPPORTED_AGENTS) {
|
||||
const result = translateSkillToAgent(testSkill, agent);
|
||||
expect(result.content).toContain('translation-test');
|
||||
}
|
||||
});
|
||||
|
||||
it('should add translation metadata when requested', () => {
|
||||
const result = translateSkillToAgent(testSkill, 'cursor', { addMetadata: true });
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.content).toContain('_translated-from: claude-code');
|
||||
expect(result.content).toContain('_translated-at:');
|
||||
});
|
||||
|
||||
it('should not add metadata by default', () => {
|
||||
const result = translateSkillToAgent(testSkill, 'cursor');
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.content).not.toContain('_translated-from');
|
||||
});
|
||||
|
||||
it('should preserve Claude Code specific fields when translating back to Claude Code', () => {
|
||||
const claudeSkill: CrossAgentSkill = {
|
||||
...testSkill,
|
||||
agentFields: {
|
||||
model: 'opus',
|
||||
context: 'fork',
|
||||
'disable-model-invocation': true,
|
||||
},
|
||||
};
|
||||
|
||||
const result = translateSkillToAgent(claudeSkill, 'claude-code');
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.content).toContain('model: opus');
|
||||
expect(result.content).toContain('context: fork');
|
||||
expect(result.content).toContain('disable-model-invocation: true');
|
||||
});
|
||||
|
||||
it('should report incompatible features when translating hooks to non-Claude agents', () => {
|
||||
const skillWithHooks: CrossAgentSkill = {
|
||||
...testSkill,
|
||||
agentFields: {
|
||||
hooks: [{ type: 'PreToolUse', command: 'echo test' }],
|
||||
},
|
||||
};
|
||||
|
||||
const result = translateSkillToAgent(skillWithHooks, 'cursor');
|
||||
|
||||
expect(result.incompatible).toContain('hooks (only supported in Claude Code)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('translateSkillToAll', () => {
|
||||
it('should translate skill to all agents except source', () => {
|
||||
const skillDir = join(testDir, 'all-agents-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: all-agents
|
||||
description: Skill for all agents testing
|
||||
version: "1.0.0"
|
||||
---
|
||||
# All Agents Skill
|
||||
|
||||
Universal skill content.
|
||||
`);
|
||||
|
||||
const results = translateSkillToAll(skillDir, 'claude-code');
|
||||
|
||||
// Should have translations for all agents except source
|
||||
expect(results.size).toBe(SUPPORTED_AGENTS.length - 1);
|
||||
expect(results.has('claude-code')).toBe(false);
|
||||
|
||||
for (const agent of SUPPORTED_AGENTS) {
|
||||
if (agent !== 'claude-code') {
|
||||
expect(results.has(agent)).toBe(true);
|
||||
const result = results.get(agent);
|
||||
expect(result?.success).toBe(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should return empty map for non-existent skill', () => {
|
||||
const results = translateSkillToAll(join(testDir, 'non-existent'));
|
||||
expect(results.size).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Skill Translator - Writing', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir('skillkit-write-');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('writeTranslatedSkill', () => {
|
||||
it('should write translated skill to correct location', () => {
|
||||
const translationResult = {
|
||||
success: true,
|
||||
content: `---
|
||||
name: written-skill
|
||||
description: A skill that was written to disk
|
||||
---
|
||||
# Written Skill
|
||||
|
||||
Content here.
|
||||
`,
|
||||
filename: 'SKILL.md',
|
||||
targetDir: 'written-skill',
|
||||
warnings: [],
|
||||
incompatible: [],
|
||||
targetAgent: 'claude-code' as const,
|
||||
};
|
||||
|
||||
const writeResult = writeTranslatedSkill(translationResult, testDir);
|
||||
|
||||
expect(writeResult.success).toBe(true);
|
||||
expect(existsSync(writeResult.path)).toBe(true);
|
||||
|
||||
const writtenContent = readFileSync(writeResult.path, 'utf-8');
|
||||
expect(writtenContent).toContain('name: written-skill');
|
||||
expect(writtenContent).toContain('# Written Skill');
|
||||
});
|
||||
|
||||
it('should create nested directories as needed', () => {
|
||||
const translationResult = {
|
||||
success: true,
|
||||
content: '---\nname: nested\n---\n# Content',
|
||||
filename: 'SKILL.md',
|
||||
targetDir: '.cursor/skills/deeply/nested/skill',
|
||||
warnings: [],
|
||||
incompatible: [],
|
||||
targetAgent: 'cursor' as const,
|
||||
};
|
||||
|
||||
const writeResult = writeTranslatedSkill(translationResult, testDir);
|
||||
|
||||
expect(writeResult.success).toBe(true);
|
||||
expect(existsSync(join(testDir, '.cursor/skills/deeply/nested/skill/SKILL.md'))).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle failed translation results gracefully', () => {
|
||||
const failedResult = {
|
||||
success: false,
|
||||
content: '',
|
||||
filename: 'SKILL.md',
|
||||
targetDir: 'failed-skill',
|
||||
warnings: ['Translation failed'],
|
||||
incompatible: [],
|
||||
targetAgent: 'cursor' as const,
|
||||
};
|
||||
|
||||
const writeResult = writeTranslatedSkill(failedResult, testDir);
|
||||
|
||||
expect(writeResult.success).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Skill Translator - Config Generation', () => {
|
||||
const testSkills = [
|
||||
{ name: 'skill-alpha', description: 'First test skill', path: '/skills/alpha', location: 'project' as const, enabled: true },
|
||||
{ name: 'skill-beta', description: 'Second test skill', path: '/skills/beta', location: 'project' as const, enabled: true },
|
||||
{ name: 'skill-gamma', description: 'Third test skill', path: '/skills/gamma', location: 'global' as const, enabled: true },
|
||||
{ name: 'skill-disabled', description: 'Disabled skill', path: '/skills/disabled', location: 'project' as const, enabled: false },
|
||||
];
|
||||
|
||||
describe('generateSkillsConfig', () => {
|
||||
it('should generate XML config for Claude Code', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'claude-code');
|
||||
|
||||
expect(config).toContain('<skills_system');
|
||||
expect(config).toContain('<name>skill-alpha</name>');
|
||||
expect(config).toContain('<name>skill-beta</name>');
|
||||
expect(config).toContain('<name>skill-gamma</name>');
|
||||
expect(config).not.toContain('skill-disabled');
|
||||
expect(config).toContain('<description>First test skill</description>');
|
||||
expect(config).toContain('skillkit read');
|
||||
});
|
||||
|
||||
it('should generate MDC config for Cursor', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'cursor');
|
||||
|
||||
expect(config).toContain('---');
|
||||
expect(config).toContain('description:');
|
||||
expect(config).toContain('globs:');
|
||||
expect(config).toContain('alwaysApply: true');
|
||||
expect(config).toContain('**skill-alpha**');
|
||||
expect(config).toContain('**skill-beta**');
|
||||
expect(config).not.toContain('skill-disabled');
|
||||
});
|
||||
|
||||
it('should generate Markdown table config for Codex', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'codex');
|
||||
|
||||
expect(config).toContain('| Skill | Description | Command |');
|
||||
expect(config).toContain('| skill-alpha |');
|
||||
expect(config).toContain('| skill-beta |');
|
||||
expect(config).toContain('First test skill');
|
||||
expect(config).not.toContain('skill-disabled');
|
||||
});
|
||||
|
||||
it('should generate JSON config for Gemini CLI', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'gemini-cli');
|
||||
|
||||
expect(config).toContain('```json');
|
||||
expect(config).toContain('"name": "skill-alpha"');
|
||||
expect(config).toContain('"name": "skill-beta"');
|
||||
expect(config).toContain('"description": "First test skill"');
|
||||
expect(config).not.toContain('skill-disabled');
|
||||
});
|
||||
|
||||
it('should generate Markdown config for Windsurf', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'windsurf');
|
||||
|
||||
expect(config).toContain('### skill-alpha');
|
||||
expect(config).toContain('### skill-beta');
|
||||
expect(config).toContain('**Invoke:**');
|
||||
expect(config).toContain('`skillkit read skill-alpha`');
|
||||
expect(config).not.toContain('skill-disabled');
|
||||
});
|
||||
|
||||
it('should generate XML config for Roo', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'roo');
|
||||
|
||||
expect(config).toContain('<skills_system');
|
||||
expect(config).toContain('<name>skill-alpha</name>');
|
||||
});
|
||||
|
||||
it('should generate Markdown config for Trae', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'trae');
|
||||
|
||||
expect(config).toContain('### skill-alpha');
|
||||
expect(config).toContain('### skill-beta');
|
||||
});
|
||||
|
||||
it('should generate Markdown config for GitHub Copilot', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'github-copilot');
|
||||
|
||||
expect(config).toContain('### skill-alpha');
|
||||
expect(config).toContain('### skill-beta');
|
||||
});
|
||||
|
||||
it('should return empty string when no skills are enabled', () => {
|
||||
const disabledOnlySkills = [
|
||||
{ name: 'disabled-1', description: 'Disabled', path: '/d1', location: 'project' as const, enabled: false },
|
||||
{ name: 'disabled-2', description: 'Also disabled', path: '/d2', location: 'project' as const, enabled: false },
|
||||
];
|
||||
|
||||
const config = generateSkillsConfig(disabledOnlySkills, 'claude-code');
|
||||
expect(config).toBe('');
|
||||
});
|
||||
|
||||
it('should exclude disabled skills from all agent configs', () => {
|
||||
for (const agent of SUPPORTED_AGENTS) {
|
||||
const config = generateSkillsConfig(testSkills, agent);
|
||||
expect(config).not.toContain('skill-disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Skill Translator - Utility Functions', () => {
|
||||
describe('getAgentSkillsDir', () => {
|
||||
it.each(SUPPORTED_AGENTS)('should return valid skills directory for %s', (agent) => {
|
||||
const dir = getAgentSkillsDir(agent);
|
||||
expect(typeof dir).toBe('string');
|
||||
expect(dir.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should return correct paths for major agents', () => {
|
||||
expect(getAgentSkillsDir('claude-code')).toBe('.claude/skills');
|
||||
expect(getAgentSkillsDir('cursor')).toBe('.cursor/skills');
|
||||
expect(getAgentSkillsDir('windsurf')).toBe('.windsurf/skills');
|
||||
expect(getAgentSkillsDir('github-copilot')).toBe('.github/skills');
|
||||
expect(getAgentSkillsDir('codex')).toBe('.codex/skills');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAgentConfigFile', () => {
|
||||
it.each(SUPPORTED_AGENTS)('should return valid config file for %s', (agent) => {
|
||||
const file = getAgentConfigFile(agent);
|
||||
expect(typeof file).toBe('string');
|
||||
expect(file.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should return correct config files for major agents', () => {
|
||||
expect(getAgentConfigFile('claude-code')).toBe('CLAUDE.md');
|
||||
expect(getAgentConfigFile('cursor')).toBe('.cursor/rules/skills.mdc');
|
||||
expect(getAgentConfigFile('windsurf')).toBe('.windsurf/rules/skills.md');
|
||||
expect(getAgentConfigFile('github-copilot')).toBe('.github/copilot-instructions.md');
|
||||
});
|
||||
});
|
||||
|
||||
describe('AGENT_SKILL_FORMATS', () => {
|
||||
it('should have configuration for all supported agents', () => {
|
||||
for (const agent of SUPPORTED_AGENTS) {
|
||||
expect(AGENT_SKILL_FORMATS[agent]).toBeDefined();
|
||||
expect(AGENT_SKILL_FORMATS[agent].skillsDir).toBeTruthy();
|
||||
expect(AGENT_SKILL_FORMATS[agent].configFile).toBeTruthy();
|
||||
expect(AGENT_SKILL_FORMATS[agent].invokeCommand).toBe('skillkit read');
|
||||
}
|
||||
});
|
||||
|
||||
it('should have correct config formats for each agent', () => {
|
||||
expect(AGENT_SKILL_FORMATS['claude-code'].configFormat).toBe('xml');
|
||||
expect(AGENT_SKILL_FORMATS.cursor.configFormat).toBe('mdc');
|
||||
expect(AGENT_SKILL_FORMATS.windsurf.configFormat).toBe('markdown');
|
||||
expect(AGENT_SKILL_FORMATS.codex.configFormat).toBe('markdown-table');
|
||||
expect(AGENT_SKILL_FORMATS['gemini-cli'].configFormat).toBe('json');
|
||||
expect(AGENT_SKILL_FORMATS['github-copilot'].configFormat).toBe('markdown');
|
||||
expect(AGENT_SKILL_FORMATS.trae.configFormat).toBe('markdown');
|
||||
expect(AGENT_SKILL_FORMATS.roo.configFormat).toBe('xml');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Skill Translator - Complete Workflow', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir('skillkit-workflow-');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
it('should complete full translation workflow from Claude Code to all agents', () => {
|
||||
// Create a Claude Code skill
|
||||
const skillDir = join(testDir, 'workflow-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: workflow-skill
|
||||
description: Complete workflow test skill
|
||||
version: "1.0.0"
|
||||
author: E2E Test Suite
|
||||
tags:
|
||||
- workflow
|
||||
- testing
|
||||
allowed-tools: Read, Write
|
||||
---
|
||||
# Workflow Test Skill
|
||||
|
||||
This skill tests the complete translation workflow.
|
||||
|
||||
## Instructions
|
||||
|
||||
1. Parse the SKILL.md file
|
||||
2. Translate to target agent format
|
||||
3. Write the translated skill
|
||||
4. Generate config
|
||||
|
||||
## Usage
|
||||
|
||||
Use \`skillkit read workflow-skill\` to load this skill.
|
||||
`);
|
||||
|
||||
// Step 1: Parse to canonical format
|
||||
const canonicalSkill = parseSkillToCanonical(skillDir);
|
||||
expect(canonicalSkill).not.toBeNull();
|
||||
expect(canonicalSkill?.name).toBe('workflow-skill');
|
||||
|
||||
// Step 2: Translate to all agents
|
||||
const translations = translateSkillToAll(skillDir, 'claude-code');
|
||||
expect(translations.size).toBeGreaterThan(0);
|
||||
|
||||
// Step 3: Verify translations for key agents
|
||||
const cursorTranslation = translations.get('cursor');
|
||||
expect(cursorTranslation?.success).toBe(true);
|
||||
expect(cursorTranslation?.content).toContain('workflow-skill');
|
||||
|
||||
const windsurfTranslation = translations.get('windsurf');
|
||||
expect(windsurfTranslation?.success).toBe(true);
|
||||
expect(windsurfTranslation?.content).toContain('workflow-skill');
|
||||
|
||||
const copilotTranslation = translations.get('github-copilot');
|
||||
expect(copilotTranslation?.success).toBe(true);
|
||||
expect(copilotTranslation?.content).toContain('workflow-skill');
|
||||
|
||||
// Step 4: Write a translation to disk
|
||||
const outputDir = join(testDir, 'output');
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
|
||||
if (cursorTranslation) {
|
||||
const writeResult = writeTranslatedSkill(cursorTranslation, outputDir);
|
||||
expect(writeResult.success).toBe(true);
|
||||
expect(existsSync(writeResult.path)).toBe(true);
|
||||
}
|
||||
|
||||
// Step 5: Generate config for installed skills
|
||||
const installedSkills = [
|
||||
{ name: 'workflow-skill', description: 'Complete workflow test skill', path: skillDir, location: 'project' as const, enabled: true },
|
||||
];
|
||||
|
||||
const claudeConfig = generateSkillsConfig(installedSkills, 'claude-code');
|
||||
expect(claudeConfig).toContain('<name>workflow-skill</name>');
|
||||
|
||||
const cursorConfig = generateSkillsConfig(installedSkills, 'cursor');
|
||||
expect(cursorConfig).toContain('**workflow-skill**');
|
||||
});
|
||||
|
||||
it('should handle skill with agent-specific features during translation', () => {
|
||||
// Create a CrossAgentSkill directly with hooks in agentFields
|
||||
// This is more reliable than parsing from YAML
|
||||
const skillWithHooks: CrossAgentSkill = {
|
||||
name: 'agent-specific',
|
||||
description: 'Skill with agent-specific features',
|
||||
content: '# Agent Specific Skill\n\nThis skill has Claude Code specific features.',
|
||||
frontmatter: { name: 'agent-specific', description: 'Skill with agent-specific features' },
|
||||
sourcePath: join(testDir, 'agent-specific'),
|
||||
sourceAgent: 'claude-code',
|
||||
agentFields: {
|
||||
model: 'opus',
|
||||
context: 'fork',
|
||||
hooks: [
|
||||
{ type: 'PreToolUse', command: 'echo "Before tool use"' },
|
||||
{ type: 'PostToolUse', command: 'echo "After tool use"' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
// Translate to Claude Code (should preserve features)
|
||||
const claudeResult = translateSkillToAgent(skillWithHooks, 'claude-code');
|
||||
expect(claudeResult.success).toBe(true);
|
||||
expect(claudeResult.incompatible).toHaveLength(0);
|
||||
|
||||
// Translate to Cursor (should report incompatible features)
|
||||
const cursorResult = translateSkillToAgent(skillWithHooks, 'cursor');
|
||||
expect(cursorResult.success).toBe(true);
|
||||
// Hooks are not supported in Cursor
|
||||
expect(cursorResult.incompatible.some(i => i.includes('hooks'))).toBe(true);
|
||||
});
|
||||
|
||||
it('should maintain content integrity across multiple translations', () => {
|
||||
const originalContent = `## Important Section
|
||||
|
||||
This content must be preserved exactly.
|
||||
|
||||
\`\`\`typescript
|
||||
const important = "code";
|
||||
console.log(important);
|
||||
\`\`\`
|
||||
|
||||
### Subsection
|
||||
|
||||
- Bullet point 1
|
||||
- Bullet point 2
|
||||
- Bullet point 3
|
||||
`;
|
||||
|
||||
const skillDir = join(testDir, 'content-integrity');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: content-integrity
|
||||
description: Tests content preservation
|
||||
---
|
||||
${originalContent}`);
|
||||
|
||||
const canonicalSkill = parseSkillToCanonical(skillDir);
|
||||
expect(canonicalSkill).not.toBeNull();
|
||||
|
||||
// Verify content is preserved in translations
|
||||
for (const agent of ['cursor', 'windsurf', 'github-copilot', 'codex'] as const) {
|
||||
const result = translateSkillToAgent(canonicalSkill!, agent);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.content).toContain('## Important Section');
|
||||
expect(result.content).toContain('const important = "code"');
|
||||
expect(result.content).toContain('- Bullet point 1');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
@@ -19,4 +20,10 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@skillkit/core': resolve(__dirname, '../packages/core/src/index.ts'),
|
||||
'@skillkit/agents': resolve(__dirname, '../packages/agents/src/index.ts'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# Contributing Skills to SkillKit Marketplace
|
||||
|
||||
## How to Add Your Skill
|
||||
|
||||
1. Fork this repository
|
||||
2. Add your skill to `marketplace/skills.json`
|
||||
3. Submit a Pull Request
|
||||
|
||||
## Skill Format
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "your-username/your-repo/skill-name",
|
||||
"name": "Your Skill Name",
|
||||
"description": "Brief description of what the skill does",
|
||||
"source": "your-username/your-repo",
|
||||
"tags": ["tag1", "tag2"]
|
||||
}
|
||||
```
|
||||
|
||||
## Field Reference
|
||||
|
||||
| Field | Required | Description |
|
||||
|-------|----------|-------------|
|
||||
| `id` | Yes | Unique identifier: `owner/repo/skill-name` |
|
||||
| `name` | Yes | Human-readable name (max 100 chars) |
|
||||
| `description` | No | Brief description (max 500 chars) |
|
||||
| `source` | Yes | GitHub repository: `owner/repo` |
|
||||
| `tags` | Yes | 1-10 lowercase tags for categorization |
|
||||
| `author` | No | Your name or GitHub username |
|
||||
| `version` | No | Semantic version (e.g., `1.0.0`) |
|
||||
| `agents` | No | Compatible agents (omit for universal) |
|
||||
|
||||
## Skill Repository Structure
|
||||
|
||||
Your skill repository should contain a `SKILL.md` file:
|
||||
|
||||
```text
|
||||
your-repo/
|
||||
├── skills/
|
||||
│ └── skill-name/
|
||||
│ └── SKILL.md
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## SKILL.md Format
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: "skill-name"
|
||||
description: "What this skill does"
|
||||
version: "1.0.0"
|
||||
tags: ["tag1", "tag2"]
|
||||
globs: ["**/*.tsx", "**/*.ts"]
|
||||
---
|
||||
|
||||
# Skill Title
|
||||
|
||||
Instructions for AI agents...
|
||||
|
||||
## Principles
|
||||
|
||||
- Principle 1
|
||||
- Principle 2
|
||||
|
||||
## Patterns
|
||||
|
||||
### Pattern Name
|
||||
|
||||
Description and examples...
|
||||
```
|
||||
|
||||
## Guidelines
|
||||
|
||||
- **Be specific**: Skills should focus on one topic
|
||||
- **Include examples**: Code examples help AI agents understand patterns
|
||||
- **Test your skill**: Verify it works with at least one agent
|
||||
- **Keep it updated**: Maintain compatibility with latest agent versions
|
||||
|
||||
## Supported Agents
|
||||
|
||||
Skills can target specific agents or be universal:
|
||||
|
||||
- `claude-code` - Anthropic Claude Code
|
||||
- `cursor` - Cursor IDE
|
||||
- `codex` - OpenAI Codex CLI
|
||||
- `gemini-cli` - Google Gemini CLI
|
||||
- `windsurf` - Codeium Windsurf
|
||||
- `github-copilot` - GitHub Copilot
|
||||
- `universal` - All agents
|
||||
|
||||
## Questions?
|
||||
|
||||
Open an issue or join our Discord community.
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "SkillKit Marketplace",
|
||||
"description": "Schema for SkillKit marketplace skills index",
|
||||
"type": "object",
|
||||
"required": ["version", "skills"],
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "Schema version number"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "Last update date (YYYY-MM-DD)"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"description": "List of skills in the marketplace",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Skill"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Skill": {
|
||||
"type": "object",
|
||||
"required": ["id", "name", "source", "tags"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_-]+$",
|
||||
"description": "Unique identifier: owner/repo/skill-name"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"description": "Human-readable skill name"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 500,
|
||||
"description": "Brief description of the skill"
|
||||
},
|
||||
"source": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+$",
|
||||
"description": "GitHub repository: owner/repo"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$"
|
||||
},
|
||||
"minItems": 1,
|
||||
"maxItems": 10,
|
||||
"description": "Tags for categorization (lowercase, hyphenated)"
|
||||
},
|
||||
"author": {
|
||||
"type": "string",
|
||||
"description": "Skill author name or GitHub username"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
||||
"description": "Semantic version (e.g., 1.0.0)"
|
||||
},
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"claude-code",
|
||||
"cursor",
|
||||
"codex",
|
||||
"gemini-cli",
|
||||
"opencode",
|
||||
"antigravity",
|
||||
"amp",
|
||||
"clawdbot",
|
||||
"droid",
|
||||
"github-copilot",
|
||||
"goose",
|
||||
"kilo",
|
||||
"kiro-cli",
|
||||
"roo",
|
||||
"trae",
|
||||
"windsurf",
|
||||
"universal"
|
||||
]
|
||||
},
|
||||
"description": "Compatible AI agents (omit for universal compatibility)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+125561
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "SkillKit Sources",
|
||||
"description": "Schema for curated skill repository sources",
|
||||
"type": "object",
|
||||
"required": ["version", "sources"],
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"description": "Schema reference"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "Schema version"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "Last update date"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "Description of this file"
|
||||
},
|
||||
"sources": {
|
||||
"type": "array",
|
||||
"description": "List of curated skill sources",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["source", "name"],
|
||||
"properties": {
|
||||
"source": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$",
|
||||
"description": "GitHub owner/repo format"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Display name for the source"
|
||||
},
|
||||
"official": {
|
||||
"type": "boolean",
|
||||
"description": "Whether this is an official source"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"$schema": "./sources-schema.json",
|
||||
"version": 1,
|
||||
"updatedAt": "2026-01-26",
|
||||
"description": "Curated skill repository sources - THE SINGLE SOURCE OF TRUTH",
|
||||
"sources": [
|
||||
{ "source": "anthropics/skills", "name": "Anthropic Official", "official": true },
|
||||
{ "source": "vercel-labs/agent-skills", "name": "Vercel Labs", "official": true },
|
||||
{ "source": "expo/skills", "name": "Expo / React Native", "official": true },
|
||||
{ "source": "remotion-dev/skills", "name": "Remotion Video", "official": true },
|
||||
{ "source": "supabase/agent-skills", "name": "Supabase", "official": true },
|
||||
{ "source": "stripe/ai", "name": "Stripe Payments", "official": true },
|
||||
{ "source": "ComposioHQ/awesome-claude-skills", "name": "Composio Awesome" },
|
||||
{ "source": "travisvn/awesome-claude-skills", "name": "Travis Awesome" },
|
||||
{ "source": "mhattingpete/claude-skills-marketplace", "name": "Skills Marketplace" },
|
||||
{ "source": "coreyhaines31/marketingskills", "name": "Marketing Skills" },
|
||||
{ "source": "obra/superpowers", "name": "Superpowers TDD" },
|
||||
{ "source": "softaworks/agent-toolkit", "name": "Softaworks Toolkit" },
|
||||
{ "source": "wshobson/agents", "name": "Dev Patterns" },
|
||||
{ "source": "langgenius/dify", "name": "Dify Frontend" },
|
||||
{ "source": "trailofbits/skills", "name": "Trail of Bits Security" },
|
||||
{ "source": "better-auth/skills", "name": "Better Auth" },
|
||||
{ "source": "onmax/nuxt-skills", "name": "Nuxt / Vue" },
|
||||
{ "source": "hyf0/vue-skills", "name": "Vue Best Practices" },
|
||||
{ "source": "jezweb/claude-skills", "name": "Cloudflare / TanStack" },
|
||||
{ "source": "elysiajs/skills", "name": "ElysiaJS / Bun" },
|
||||
{ "source": "kadajett/agent-nestjs-skills", "name": "NestJS" },
|
||||
{ "source": "callstackincubator/agent-skills", "name": "React Native" },
|
||||
{ "source": "cloudai-x/threejs-skills", "name": "Three.js" },
|
||||
{ "source": "emalorenzo/three-agent-skills", "name": "Three.js Advanced" },
|
||||
{ "source": "dimillian/skills", "name": "SwiftUI iOS" },
|
||||
{ "source": "waynesutton/convexskills", "name": "Convex Backend" },
|
||||
{ "source": "kepano/obsidian-skills", "name": "Obsidian Notes" },
|
||||
{ "source": "jimliu/baoyu-skills", "name": "Baoyu Tools" },
|
||||
{ "source": "giuseppe-trisciuoglio/developer-kit", "name": "Shadcn / Radix" },
|
||||
{ "source": "openrouterteam/agent-skills", "name": "OpenRouter SDK" },
|
||||
{ "source": "intellectronica/agent-skills", "name": "Context7" }
|
||||
]
|
||||
}
|
||||
Generated
+109
-1823
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "skillkit-monorepo",
|
||||
"version": "1.6.1",
|
||||
"version": "1.7.1",
|
||||
"private": true,
|
||||
"description": "Universal skills loader for AI coding agents - Monorepo",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "turbo run build",
|
||||
"dev": "turbo run dev",
|
||||
"ui": "pnpm --filter skillkit exec bun skillkit ui",
|
||||
"test": "turbo run test",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
@@ -53,5 +54,6 @@
|
||||
"turbo": "^2.3.4",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
}
|
||||
},
|
||||
"pnpm": {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/agents",
|
||||
"version": "1.6.1",
|
||||
"version": "1.7.1",
|
||||
"description": "Agent adapters for SkillKit - supports 17+ AI coding agents",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
@@ -21,7 +21,7 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "^1.6.0",
|
||||
"@skillkit/core": "workspace:*",
|
||||
"minimatch": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('ClawdbotAdapter', () => {
|
||||
});
|
||||
|
||||
it('should have correct skillsDir', () => {
|
||||
expect(adapter.skillsDir).toBe('skills');
|
||||
expect(adapter.skillsDir).toBe('.clawdbot/skills');
|
||||
});
|
||||
|
||||
it('should have correct configFile', () => {
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.amp;
|
||||
|
||||
export class AmpAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'amp';
|
||||
readonly name = 'Amp';
|
||||
readonly skillsDir = '.agents/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -66,9 +69,9 @@ ${skillsXml}
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectAgents = join(process.cwd(), '.agents');
|
||||
const globalAgents = join(homedir(), '.config', 'agents');
|
||||
const projectAmp = join(process.cwd(), '.amp');
|
||||
const globalAmp = join(homedir(), '.amp');
|
||||
|
||||
return existsSync(projectAgents) || existsSync(globalAgents);
|
||||
return existsSync(projectAmp) || existsSync(globalAmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@ import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.antigravity;
|
||||
|
||||
export class AntigravityAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'antigravity';
|
||||
readonly name = 'Antigravity';
|
||||
readonly skillsDir = '.antigravity/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG['claude-code'];
|
||||
|
||||
export class ClaudeCodeAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'claude-code';
|
||||
readonly name = 'Claude Code';
|
||||
readonly skillsDir = '.claude/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.clawdbot;
|
||||
|
||||
export class ClawdbotAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'clawdbot';
|
||||
readonly name = 'Clawdbot';
|
||||
readonly skillsDir = 'skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -3,12 +3,15 @@ import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.codex;
|
||||
|
||||
export class CodexAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'codex';
|
||||
readonly name = 'OpenAI Codex CLI';
|
||||
readonly skillsDir = '.codex/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.cursor;
|
||||
|
||||
export class CursorAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'cursor';
|
||||
readonly name = 'Cursor';
|
||||
readonly skillsDir = '.cursor/skills';
|
||||
readonly configFile = '.cursorrules';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -23,7 +27,12 @@ export class CursorAdapter implements AgentAdapter {
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
||||
|
||||
return `# Skills System
|
||||
return `---
|
||||
description: SkillKit skills integration - provides specialized capabilities and domain knowledge
|
||||
globs: "**/*"
|
||||
alwaysApply: true
|
||||
---
|
||||
# Skills System
|
||||
|
||||
You have access to specialized skills that can help complete tasks. Use the skillkit CLI to load skill instructions when needed.
|
||||
|
||||
@@ -63,9 +72,14 @@ ${skillsXml}
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const cursorRules = join(process.cwd(), '.cursorrules');
|
||||
const cursorDir = join(process.cwd(), '.cursor');
|
||||
const cursorRulesDir = join(process.cwd(), '.cursor', 'rules');
|
||||
// Legacy .cursorrules file (deprecated but still supported)
|
||||
const cursorRulesFile = join(process.cwd(), '.cursorrules');
|
||||
// Global Cursor config
|
||||
const globalCursor = join(homedir(), '.cursor');
|
||||
|
||||
return existsSync(cursorRules) || existsSync(cursorDir);
|
||||
return existsSync(cursorDir) || existsSync(cursorRulesDir) ||
|
||||
existsSync(cursorRulesFile) || existsSync(globalCursor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.droid;
|
||||
|
||||
export class DroidAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'droid';
|
||||
readonly name = 'Droid (Factory)';
|
||||
readonly skillsDir = '.factory/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -3,12 +3,15 @@ import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG['gemini-cli'];
|
||||
|
||||
export class GeminiCliAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'gemini-cli';
|
||||
readonly name = 'Gemini CLI';
|
||||
readonly skillsDir = '.gemini/skills';
|
||||
readonly configFile = 'GEMINI.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -64,7 +67,7 @@ ${JSON.stringify(skillsJson, null, 2)}
|
||||
}
|
||||
|
||||
if (skillNames.length === 0) {
|
||||
const headerRegex = /^### ([a-z0-9-]+)$/gm;
|
||||
const headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
|
||||
@@ -2,14 +2,16 @@ import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG['github-copilot'];
|
||||
|
||||
export class GitHubCopilotAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'github-copilot';
|
||||
readonly name = 'GitHub Copilot';
|
||||
readonly skillsDir = '.github/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -18,43 +20,38 @@ export class GitHubCopilotAdapter implements AgentAdapter {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`skillkit read ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
return `<skills_system priority="1">
|
||||
return `# Skills System
|
||||
|
||||
You have access to specialized skills that can help complete tasks.
|
||||
Skills provide domain-specific knowledge and step-by-step instructions.
|
||||
|
||||
## Available Skills
|
||||
|
||||
<!-- SKILLS_TABLE_START -->
|
||||
<usage>
|
||||
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
|
||||
${skillsList}
|
||||
|
||||
How to use skills:
|
||||
- Invoke: \`skillkit read <skill-name>\` or \`npx skillkit read <skill-name>\`
|
||||
- The skill content will load with detailed instructions on how to complete the task
|
||||
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
|
||||
## How to Use Skills
|
||||
|
||||
Usage notes:
|
||||
- Only use skills listed in <available_skills> below
|
||||
- Do not invoke a skill that is already loaded in your context
|
||||
- Each skill invocation is stateless
|
||||
</usage>
|
||||
When a task matches a skill's description, load it using the terminal:
|
||||
|
||||
<available_skills>
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
${skillsXml}
|
||||
|
||||
</available_skills>
|
||||
<!-- SKILLS_TABLE_END -->
|
||||
|
||||
</skills_system>`;
|
||||
The skill content will load with detailed instructions.
|
||||
Each skill is self-contained with its own resources.
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
const headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
@@ -66,9 +63,11 @@ ${skillsXml}
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectGithub = join(process.cwd(), '.github', 'skills');
|
||||
const copilotInstructions = join(process.cwd(), '.github', 'copilot-instructions.md');
|
||||
const githubInstructions = join(process.cwd(), '.github', 'instructions');
|
||||
const globalCopilot = join(homedir(), '.copilot');
|
||||
|
||||
return existsSync(projectGithub) || existsSync(globalCopilot);
|
||||
return existsSync(copilotInstructions) ||
|
||||
existsSync(githubInstructions) || existsSync(globalCopilot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.goose;
|
||||
|
||||
export class GooseAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'goose';
|
||||
readonly name = 'Goose';
|
||||
readonly skillsDir = '.goose/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -99,10 +99,5 @@ export async function detectAgent(): Promise<AgentType> {
|
||||
return 'universal';
|
||||
}
|
||||
|
||||
export function getSkillsDir(type: AgentType): string {
|
||||
return adapters[type].skillsDir;
|
||||
}
|
||||
|
||||
export function getConfigFile(type: AgentType): string {
|
||||
return adapters[type].configFile;
|
||||
}
|
||||
// getSkillsDir and getConfigFile are now re-exported from @skillkit/core above
|
||||
// This ensures a single source of truth for agent configurations
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.kilo;
|
||||
|
||||
export class KiloAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'kilo';
|
||||
readonly name = 'Kilo Code';
|
||||
readonly skillsDir = '.kilocode/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -68,7 +71,8 @@ ${skillsXml}
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectKilo = join(process.cwd(), '.kilocode');
|
||||
const globalKilo = join(homedir(), '.kilocode');
|
||||
const kiloModes = join(process.cwd(), '.kilocode', 'modes');
|
||||
|
||||
return existsSync(projectKilo) || existsSync(globalKilo);
|
||||
return existsSync(projectKilo) || existsSync(globalKilo) || existsSync(kiloModes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG['kiro-cli'];
|
||||
|
||||
export class KiroCliAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'kiro-cli';
|
||||
readonly name = 'Kiro CLI';
|
||||
readonly skillsDir = '.kiro/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.opencode;
|
||||
|
||||
export class OpenCodeAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'opencode';
|
||||
readonly name = 'OpenCode';
|
||||
readonly skillsDir = '.opencode/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -60,8 +63,10 @@ This loads the skill's instructions into context.
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const opencodeDir = join(process.cwd(), '.opencode');
|
||||
const globalOpencode = join(homedir(), '.opencode');
|
||||
const globalOpencode = join(homedir(), '.config', 'opencode');
|
||||
const opencodeJson = join(process.cwd(), 'opencode.json');
|
||||
|
||||
return existsSync(opencodeDir) || existsSync(globalOpencode);
|
||||
return existsSync(opencodeDir) || existsSync(globalOpencode) ||
|
||||
existsSync(opencodeJson);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.roo;
|
||||
|
||||
export class RooAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'roo';
|
||||
readonly name = 'Roo Code';
|
||||
readonly skillsDir = '.roo/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -68,7 +71,8 @@ ${skillsXml}
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectRoo = join(process.cwd(), '.roo');
|
||||
const globalRoo = join(homedir(), '.roo');
|
||||
const rooModes = join(process.cwd(), '.roo', 'modes');
|
||||
|
||||
return existsSync(projectRoo) || existsSync(globalRoo);
|
||||
return existsSync(projectRoo) || existsSync(globalRoo) || existsSync(rooModes);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-27
@@ -2,14 +2,16 @@ import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.trae;
|
||||
|
||||
export class TraeAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'trae';
|
||||
readonly name = 'Trae';
|
||||
readonly skillsDir = '.trae/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -18,43 +20,42 @@ export class TraeAdapter implements AgentAdapter {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`skillkit read ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
return `<skills_system priority="1">
|
||||
return `---
|
||||
alwaysApply: true
|
||||
description: SkillKit skills integration for Trae
|
||||
globs: ["**/*"]
|
||||
---
|
||||
# Skills System
|
||||
|
||||
You have access to specialized skills that can help complete tasks.
|
||||
When a task matches a skill's description, load it using the skillkit CLI.
|
||||
|
||||
## Available Skills
|
||||
|
||||
<!-- SKILLS_TABLE_START -->
|
||||
<usage>
|
||||
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
|
||||
${skillsList}
|
||||
|
||||
How to use skills:
|
||||
- Invoke: \`skillkit read <skill-name>\` or \`npx skillkit read <skill-name>\`
|
||||
- The skill content will load with detailed instructions on how to complete the task
|
||||
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
|
||||
## How to Use Skills
|
||||
|
||||
Usage notes:
|
||||
- Only use skills listed in <available_skills> below
|
||||
- Do not invoke a skill that is already loaded in your context
|
||||
- Each skill invocation is stateless
|
||||
</usage>
|
||||
When a task matches a skill's description, load it:
|
||||
|
||||
<available_skills>
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
${skillsXml}
|
||||
|
||||
</available_skills>
|
||||
<!-- SKILLS_TABLE_END -->
|
||||
|
||||
</skills_system>`;
|
||||
Skills provide detailed instructions for completing complex tasks.
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
const headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
@@ -67,8 +68,9 @@ ${skillsXml}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectTrae = join(process.cwd(), '.trae');
|
||||
const traeRulesDir = join(process.cwd(), '.trae', 'rules');
|
||||
const globalTrae = join(homedir(), '.trae');
|
||||
|
||||
return existsSync(projectTrae) || existsSync(globalTrae);
|
||||
return existsSync(projectTrae) || existsSync(traeRulesDir) || existsSync(globalTrae);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@ import { join } from 'node:path';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.universal;
|
||||
|
||||
export class UniversalAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'universal';
|
||||
readonly name = 'Universal (Any Agent)';
|
||||
readonly skillsDir = '.agent/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
@@ -2,14 +2,16 @@ import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import { createSkillXml } from './base.js';
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
import { AGENT_CONFIG } from '@skillkit/core';
|
||||
|
||||
const config = AGENT_CONFIG.windsurf;
|
||||
|
||||
export class WindsurfAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'windsurf';
|
||||
readonly name = 'Windsurf';
|
||||
readonly skillsDir = '.windsurf/skills';
|
||||
readonly configFile = 'AGENTS.md';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
@@ -18,43 +20,42 @@ export class WindsurfAdapter implements AgentAdapter {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`skillkit read ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
return `<skills_system priority="1">
|
||||
return `---
|
||||
name: "skillkit-skills"
|
||||
mode: "model-decision"
|
||||
---
|
||||
# Skills System
|
||||
|
||||
You have access to specialized skills that can help complete tasks.
|
||||
When a task matches a skill's description, load it using the skillkit CLI.
|
||||
|
||||
## Available Skills
|
||||
|
||||
<!-- SKILLS_TABLE_START -->
|
||||
<usage>
|
||||
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
|
||||
${skillsList}
|
||||
|
||||
How to use skills:
|
||||
- Invoke: \`skillkit read <skill-name>\` or \`npx skillkit read <skill-name>\`
|
||||
- The skill content will load with detailed instructions on how to complete the task
|
||||
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
|
||||
## How to Use Skills
|
||||
|
||||
Usage notes:
|
||||
- Only use skills listed in <available_skills> below
|
||||
- Do not invoke a skill that is already loaded in your context
|
||||
- Each skill invocation is stateless
|
||||
</usage>
|
||||
When a task matches a skill's description, load it:
|
||||
|
||||
<available_skills>
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
${skillsXml}
|
||||
|
||||
</available_skills>
|
||||
<!-- SKILLS_TABLE_END -->
|
||||
|
||||
</skills_system>`;
|
||||
Skills provide detailed instructions for completing complex tasks.
|
||||
Each skill is self-contained with its own resources.
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
const headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
@@ -67,8 +68,10 @@ ${skillsXml}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectWindsurf = join(process.cwd(), '.windsurf');
|
||||
const projectRulesDir = join(process.cwd(), '.windsurf', 'rules');
|
||||
const globalWindsurf = join(homedir(), '.codeium', 'windsurf');
|
||||
|
||||
return existsSync(projectWindsurf) || existsSync(globalWindsurf);
|
||||
return existsSync(projectWindsurf) || existsSync(projectRulesDir) ||
|
||||
existsSync(globalWindsurf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/cli",
|
||||
"version": "1.6.1",
|
||||
"version": "1.7.1",
|
||||
"description": "CLI commands for SkillKit",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
@@ -21,9 +21,9 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "^1.6.0",
|
||||
"@skillkit/agents": "^1.6.0",
|
||||
"@skillkit/tui": "^1.6.0",
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@skillkit/tui": "workspace:*",
|
||||
"chalk": "^5.3.0",
|
||||
"clipanion": "^4.0.0-rc.4",
|
||||
"got": "^14.4.1",
|
||||
|
||||
@@ -0,0 +1,631 @@
|
||||
/**
|
||||
* Agent Command
|
||||
*
|
||||
* Manage custom AI sub-agents (e.g., .claude/agents/*.md)
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import {
|
||||
findAllAgents,
|
||||
findAgent,
|
||||
discoverAgents,
|
||||
discoverAgentsFromPath,
|
||||
validateAgent,
|
||||
translateAgent,
|
||||
getAgentTargetDirectory,
|
||||
type CustomAgent,
|
||||
type AgentType,
|
||||
} from '@skillkit/core';
|
||||
// Agent discovery uses root directories, not skill directories
|
||||
|
||||
export class AgentCommand extends Command {
|
||||
static override paths = [['agent']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Manage custom AI sub-agents',
|
||||
details: `
|
||||
This command manages custom AI sub-agents that can be used with
|
||||
Claude Code, Cursor, and other AI coding agents.
|
||||
|
||||
Agents are specialized personas (like architects, testers, reviewers)
|
||||
that can be invoked with @mentions or the --agent flag.
|
||||
|
||||
Sub-commands:
|
||||
agent list - List all installed agents
|
||||
agent show - Show agent details
|
||||
agent create - Create a new agent
|
||||
agent translate - Translate agents between formats
|
||||
agent sync - Sync agents to target AI agent
|
||||
agent validate - Validate agent definitions
|
||||
`,
|
||||
examples: [
|
||||
['List all agents', '$0 agent list'],
|
||||
['Show agent details', '$0 agent show architect'],
|
||||
['Create new agent', '$0 agent create security-reviewer'],
|
||||
['Translate to Cursor format', '$0 agent translate --to cursor'],
|
||||
['Sync agents', '$0 agent sync --agent claude-code'],
|
||||
],
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
console.log(chalk.cyan('Agent management commands:\n'));
|
||||
console.log(' agent list List all installed agents');
|
||||
console.log(' agent show <name> Show agent details');
|
||||
console.log(' agent create <name> Create a new agent');
|
||||
console.log(' agent translate Translate agents between formats');
|
||||
console.log(' agent sync Sync agents to target AI agent');
|
||||
console.log(' agent validate [path] Validate agent definitions');
|
||||
console.log();
|
||||
console.log(chalk.dim('Run `skillkit agent <subcommand> --help` for more info'));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AgentListCommand extends Command {
|
||||
static override paths = [['agent', 'list'], ['agent', 'ls']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'List all installed agents',
|
||||
examples: [
|
||||
['List all agents', '$0 agent list'],
|
||||
['Show JSON output', '$0 agent list --json'],
|
||||
['Show only project agents', '$0 agent list --project'],
|
||||
],
|
||||
});
|
||||
|
||||
json = Option.Boolean('--json,-j', false, {
|
||||
description: 'Output as JSON',
|
||||
});
|
||||
|
||||
project = Option.Boolean('--project,-p', false, {
|
||||
description: 'Show only project agents',
|
||||
});
|
||||
|
||||
global = Option.Boolean('--global,-g', false, {
|
||||
description: 'Show only global agents',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const searchDirs = [process.cwd()];
|
||||
let agents = findAllAgents(searchDirs);
|
||||
|
||||
if (this.project) {
|
||||
agents = agents.filter((a: CustomAgent) => a.location === 'project');
|
||||
} else if (this.global) {
|
||||
agents = agents.filter((a: CustomAgent) => a.location === 'global');
|
||||
}
|
||||
|
||||
agents.sort((a: CustomAgent, b: CustomAgent) => {
|
||||
if (a.location !== b.location) {
|
||||
return a.location === 'project' ? -1 : 1;
|
||||
}
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
if (this.json) {
|
||||
console.log(JSON.stringify(agents.map((a: CustomAgent) => ({
|
||||
name: a.name,
|
||||
description: a.description,
|
||||
path: a.path,
|
||||
location: a.location,
|
||||
enabled: a.enabled,
|
||||
model: a.frontmatter.model,
|
||||
permissionMode: a.frontmatter.permissionMode,
|
||||
})), null, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (agents.length === 0) {
|
||||
console.log(chalk.yellow('No agents found'));
|
||||
console.log(chalk.dim('Create an agent with: skillkit agent create <name>'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(`Installed agents (${agents.length}):\n`));
|
||||
|
||||
const projectAgents = agents.filter((a: CustomAgent) => a.location === 'project');
|
||||
const globalAgents = agents.filter((a: CustomAgent) => a.location === 'global');
|
||||
|
||||
if (projectAgents.length > 0) {
|
||||
console.log(chalk.blue('Project agents:'));
|
||||
for (const agent of projectAgents) {
|
||||
printAgent(agent);
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
|
||||
if (globalAgents.length > 0) {
|
||||
console.log(chalk.dim('Global agents:'));
|
||||
for (const agent of globalAgents) {
|
||||
printAgent(agent);
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
|
||||
console.log(
|
||||
chalk.dim(`${projectAgents.length} project, ${globalAgents.length} global`)
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AgentShowCommand extends Command {
|
||||
static override paths = [['agent', 'show'], ['agent', 'info']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Show details for a specific agent',
|
||||
examples: [
|
||||
['Show agent details', '$0 agent show architect'],
|
||||
],
|
||||
});
|
||||
|
||||
name = Option.String({ required: true });
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const searchDirs = [process.cwd()];
|
||||
const agent = findAgent(this.name, searchDirs);
|
||||
|
||||
if (!agent) {
|
||||
console.log(chalk.red(`Agent not found: ${this.name}`));
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(`Agent: ${agent.name}\n`));
|
||||
console.log(`${chalk.dim('Description:')} ${agent.description}`);
|
||||
console.log(`${chalk.dim('Location:')} ${agent.location} (${agent.path})`);
|
||||
console.log(`${chalk.dim('Enabled:')} ${agent.enabled ? chalk.green('yes') : chalk.red('no')}`);
|
||||
|
||||
const fm = agent.frontmatter;
|
||||
if (fm.model) {
|
||||
console.log(`${chalk.dim('Model:')} ${fm.model}`);
|
||||
}
|
||||
if (fm.permissionMode) {
|
||||
console.log(`${chalk.dim('Permission Mode:')} ${fm.permissionMode}`);
|
||||
}
|
||||
if (fm.context) {
|
||||
console.log(`${chalk.dim('Context:')} ${fm.context}`);
|
||||
}
|
||||
if (fm.disallowedTools && fm.disallowedTools.length > 0) {
|
||||
console.log(`${chalk.dim('Disallowed Tools:')} ${fm.disallowedTools.join(', ')}`);
|
||||
}
|
||||
if (fm.skills && fm.skills.length > 0) {
|
||||
console.log(`${chalk.dim('Skills:')} ${fm.skills.join(', ')}`);
|
||||
}
|
||||
if (fm.hooks && fm.hooks.length > 0) {
|
||||
console.log(`${chalk.dim('Hooks:')} ${fm.hooks.length} defined`);
|
||||
}
|
||||
if (fm.tags && fm.tags.length > 0) {
|
||||
console.log(`${chalk.dim('Tags:')} ${fm.tags.join(', ')}`);
|
||||
}
|
||||
if (fm.author) {
|
||||
console.log(`${chalk.dim('Author:')} ${fm.author}`);
|
||||
}
|
||||
if (fm.version) {
|
||||
console.log(`${chalk.dim('Version:')} ${fm.version}`);
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log(chalk.dim('Content preview:'));
|
||||
console.log(chalk.dim('─'.repeat(40)));
|
||||
const preview = agent.content.slice(0, 500);
|
||||
console.log(preview + (agent.content.length > 500 ? '\n...' : ''));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AgentCreateCommand extends Command {
|
||||
static override paths = [['agent', 'create'], ['agent', 'new']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Create a new agent',
|
||||
examples: [
|
||||
['Create an agent', '$0 agent create security-reviewer'],
|
||||
['Create with model', '$0 agent create architect --model opus'],
|
||||
['Create globally', '$0 agent create my-agent --global'],
|
||||
],
|
||||
});
|
||||
|
||||
name = Option.String({ required: true });
|
||||
|
||||
model = Option.String('--model,-m', {
|
||||
description: 'Model to use (opus, sonnet, haiku)',
|
||||
});
|
||||
|
||||
description = Option.String('--description,-d', {
|
||||
description: 'Agent description',
|
||||
});
|
||||
|
||||
global = Option.Boolean('--global,-g', false, {
|
||||
description: 'Create in global agents directory',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
// Validate agent name format
|
||||
const namePattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
||||
if (!namePattern.test(this.name)) {
|
||||
console.log(chalk.red('Invalid agent name: must be lowercase alphanumeric with hyphens'));
|
||||
console.log(chalk.dim('Examples: my-agent, code-reviewer, security-expert'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Determine target directory
|
||||
let targetDir: string;
|
||||
if (this.global) {
|
||||
targetDir = join(homedir(), '.claude', 'agents');
|
||||
} else {
|
||||
targetDir = join(process.cwd(), '.claude', 'agents');
|
||||
}
|
||||
|
||||
// Create directory if needed
|
||||
if (!existsSync(targetDir)) {
|
||||
mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Check if agent already exists
|
||||
const agentPath = join(targetDir, `${this.name}.md`);
|
||||
if (existsSync(agentPath)) {
|
||||
console.log(chalk.red(`Agent already exists: ${agentPath}`));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Generate content
|
||||
const description = this.description || `${this.name} agent`;
|
||||
const content = generateAgentTemplate(this.name, description, this.model);
|
||||
|
||||
// Write file
|
||||
writeFileSync(agentPath, content);
|
||||
|
||||
console.log(chalk.green(`Created agent: ${agentPath}`));
|
||||
console.log();
|
||||
console.log(chalk.dim('Edit the file to customize the agent system prompt.'));
|
||||
console.log(chalk.dim(`Invoke with: @${this.name}`));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AgentTranslateCommand extends Command {
|
||||
static override paths = [['agent', 'translate']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Translate agents between AI coding agent formats',
|
||||
details: `
|
||||
Translates agent definitions between different AI coding agent formats.
|
||||
Supports recursive translation for directories with multiple agents.
|
||||
|
||||
Use --source to specify a custom source directory with agents.
|
||||
Use --recursive to scan all subdirectories for agents.
|
||||
`,
|
||||
examples: [
|
||||
['Translate all to Cursor', '$0 agent translate --to cursor'],
|
||||
['Translate specific agent', '$0 agent translate architect --to cursor'],
|
||||
['Translate from source directory', '$0 agent translate --source ./my-agents --to cursor'],
|
||||
['Recursive translation', '$0 agent translate --source ./skills --to cursor --recursive'],
|
||||
['Dry run', '$0 agent translate --to cursor --dry-run'],
|
||||
],
|
||||
});
|
||||
|
||||
name = Option.String({ required: false });
|
||||
|
||||
to = Option.String('--to,-t', {
|
||||
description: 'Target AI agent (claude-code, cursor, codex, etc.)',
|
||||
required: true,
|
||||
});
|
||||
|
||||
source = Option.String('--source,-s', {
|
||||
description: 'Source directory or file to translate from',
|
||||
});
|
||||
|
||||
output = Option.String('--output,-o', {
|
||||
description: 'Output directory',
|
||||
});
|
||||
|
||||
dryRun = Option.Boolean('--dry-run,-n', false, {
|
||||
description: 'Show what would be done without writing files',
|
||||
});
|
||||
|
||||
all = Option.Boolean('--all,-a', false, {
|
||||
description: 'Translate all agents',
|
||||
});
|
||||
|
||||
recursive = Option.Boolean('--recursive,-r', false, {
|
||||
description: 'Recursively scan directories for agents',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const searchDirs = [process.cwd()];
|
||||
const targetAgent = this.to as AgentType;
|
||||
|
||||
// Get agents to translate
|
||||
let agents: CustomAgent[];
|
||||
|
||||
if (this.source) {
|
||||
// Translate from custom source path
|
||||
const sourcePath = this.source.startsWith('/')
|
||||
? this.source
|
||||
: join(process.cwd(), this.source);
|
||||
|
||||
if (!existsSync(sourcePath)) {
|
||||
console.log(chalk.red(`Source path not found: ${sourcePath}`));
|
||||
return 1;
|
||||
}
|
||||
|
||||
agents = discoverAgentsFromPath(sourcePath, this.recursive);
|
||||
|
||||
if (agents.length === 0) {
|
||||
console.log(chalk.yellow(`No agents found in: ${sourcePath}`));
|
||||
if (!this.recursive) {
|
||||
console.log(chalk.dim('Tip: Use --recursive to scan subdirectories'));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} else if (this.name) {
|
||||
const agent = findAgent(this.name, searchDirs);
|
||||
if (!agent) {
|
||||
console.log(chalk.red(`Agent not found: ${this.name}`));
|
||||
return 1;
|
||||
}
|
||||
agents = [agent];
|
||||
} else if (this.all) {
|
||||
agents = findAllAgents(searchDirs);
|
||||
} else {
|
||||
agents = discoverAgents(process.cwd());
|
||||
}
|
||||
|
||||
if (agents.length === 0) {
|
||||
console.log(chalk.yellow('No agents found to translate'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Determine output directory
|
||||
const outputDir = this.output || getAgentTargetDirectory(process.cwd(), targetAgent);
|
||||
|
||||
console.log(chalk.cyan(`Translating ${agents.length} agent(s) to ${targetAgent} format...\n`));
|
||||
|
||||
let successCount = 0;
|
||||
let errorCount = 0;
|
||||
|
||||
for (const agent of agents) {
|
||||
try {
|
||||
const result = translateAgent(agent, targetAgent, { addMetadata: true });
|
||||
|
||||
if (!result.success) {
|
||||
console.log(chalk.red(`✗ ${agent.name}: Translation failed`));
|
||||
errorCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const outputPath = join(outputDir, result.filename);
|
||||
|
||||
if (this.dryRun) {
|
||||
console.log(chalk.blue(`Would write: ${outputPath}`));
|
||||
if (result.warnings.length > 0) {
|
||||
for (const warning of result.warnings) {
|
||||
console.log(chalk.yellow(` ⚠ ${warning}`));
|
||||
}
|
||||
}
|
||||
if (result.incompatible.length > 0) {
|
||||
for (const incompat of result.incompatible) {
|
||||
console.log(chalk.dim(` ○ ${incompat}`));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Create directory if needed
|
||||
if (!existsSync(outputDir)) {
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
writeFileSync(outputPath, result.content);
|
||||
console.log(chalk.green(`✓ ${agent.name} → ${outputPath}`));
|
||||
}
|
||||
|
||||
successCount++;
|
||||
} catch (error) {
|
||||
console.log(chalk.red(`✗ ${agent.name}: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log();
|
||||
if (this.dryRun) {
|
||||
console.log(chalk.dim(`Would translate ${successCount} agent(s)`));
|
||||
} else {
|
||||
console.log(chalk.dim(`Translated ${successCount} agent(s)${errorCount > 0 ? `, ${errorCount} failed` : ''}`));
|
||||
}
|
||||
|
||||
return errorCount > 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AgentSyncCommand extends Command {
|
||||
static override paths = [['agent', 'sync']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Sync agents to target AI coding agent',
|
||||
examples: [
|
||||
['Sync to Claude Code', '$0 agent sync --agent claude-code'],
|
||||
['Sync to multiple agents', '$0 agent sync --agent claude-code,cursor'],
|
||||
],
|
||||
});
|
||||
|
||||
agent = Option.String('--agent,-a', {
|
||||
description: 'Target AI agent(s) (comma-separated)',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const searchDirs = [process.cwd()];
|
||||
const agents = findAllAgents(searchDirs);
|
||||
|
||||
if (agents.length === 0) {
|
||||
console.log(chalk.yellow('No agents found to sync'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
const targetAgents = this.agent
|
||||
? this.agent.split(',').map(a => a.trim() as AgentType)
|
||||
: ['claude-code' as AgentType];
|
||||
|
||||
console.log(chalk.cyan(`Syncing ${agents.length} agent(s)...\n`));
|
||||
|
||||
for (const targetAgent of targetAgents) {
|
||||
const outputDir = getAgentTargetDirectory(process.cwd(), targetAgent);
|
||||
|
||||
console.log(chalk.blue(`→ ${targetAgent} (${outputDir})`));
|
||||
|
||||
if (!existsSync(outputDir)) {
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
|
||||
for (const agent of agents) {
|
||||
const result = translateAgent(agent, targetAgent);
|
||||
if (result.success) {
|
||||
const outputPath = join(outputDir, result.filename);
|
||||
writeFileSync(outputPath, result.content);
|
||||
console.log(chalk.green(` ✓ ${agent.name}`));
|
||||
} else {
|
||||
console.log(chalk.red(` ✗ ${agent.name}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log(chalk.dim('Sync complete'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AgentValidateCommand extends Command {
|
||||
static override paths = [['agent', 'validate']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Validate agent definitions',
|
||||
examples: [
|
||||
['Validate specific agent', '$0 agent validate ./my-agent.md'],
|
||||
['Validate all agents', '$0 agent validate --all'],
|
||||
],
|
||||
});
|
||||
|
||||
agentPath = Option.String({ required: false });
|
||||
|
||||
all = Option.Boolean('--all,-a', false, {
|
||||
description: 'Validate all discovered agents',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
let hasErrors = false;
|
||||
|
||||
if (this.agentPath) {
|
||||
// Validate specific path
|
||||
const result = validateAgent(this.agentPath);
|
||||
printValidationResult(this.agentPath, result);
|
||||
hasErrors = !result.valid;
|
||||
} else if (this.all) {
|
||||
// Validate all agents
|
||||
const searchDirs = [process.cwd()];
|
||||
const agents = findAllAgents(searchDirs);
|
||||
|
||||
if (agents.length === 0) {
|
||||
console.log(chalk.yellow('No agents found'));
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(`Validating ${agents.length} agent(s)...\n`));
|
||||
|
||||
for (const agent of agents) {
|
||||
const result = validateAgent(agent.path);
|
||||
printValidationResult(agent.name, result);
|
||||
if (!result.valid) hasErrors = true;
|
||||
}
|
||||
} else {
|
||||
console.log(chalk.yellow('Specify a path or use --all to validate all agents'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return hasErrors ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
function printAgent(agent: CustomAgent): void {
|
||||
const status = agent.enabled ? chalk.green('✓') : chalk.red('○');
|
||||
const name = agent.enabled ? agent.name : chalk.dim(agent.name);
|
||||
const model = agent.frontmatter.model ? chalk.blue(`[${agent.frontmatter.model}]`) : '';
|
||||
const desc = chalk.dim(truncate(agent.description, 40));
|
||||
|
||||
console.log(` ${status} ${name} ${model}`);
|
||||
if (agent.description) {
|
||||
console.log(` ${desc}`);
|
||||
}
|
||||
}
|
||||
|
||||
function printValidationResult(
|
||||
name: string,
|
||||
result: { valid: boolean; errors: string[]; warnings: string[] }
|
||||
): void {
|
||||
if (result.valid) {
|
||||
console.log(chalk.green(`✓ ${name}`));
|
||||
for (const warning of result.warnings) {
|
||||
console.log(chalk.yellow(` ⚠ ${warning}`));
|
||||
}
|
||||
} else {
|
||||
console.log(chalk.red(`✗ ${name}`));
|
||||
for (const error of result.errors) {
|
||||
console.log(chalk.red(` • ${error}`));
|
||||
}
|
||||
for (const warning of result.warnings) {
|
||||
console.log(chalk.yellow(` ⚠ ${warning}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function truncate(str: string, maxLen: number): string {
|
||||
if (str.length <= maxLen) return str;
|
||||
return str.slice(0, maxLen - 3) + '...';
|
||||
}
|
||||
|
||||
function generateAgentTemplate(name: string, description: string, model?: string): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('---');
|
||||
lines.push(`name: ${name}`);
|
||||
lines.push(`description: ${description}`);
|
||||
if (model) {
|
||||
lines.push(`model: ${model}`);
|
||||
}
|
||||
lines.push('# permissionMode: default');
|
||||
lines.push('# disallowedTools: []');
|
||||
lines.push('# skills: []');
|
||||
lines.push('# context: fork');
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
lines.push(`# ${formatAgentName(name)}`);
|
||||
lines.push('');
|
||||
lines.push('You are a specialized AI assistant.');
|
||||
lines.push('');
|
||||
lines.push('## Responsibilities');
|
||||
lines.push('');
|
||||
lines.push('- TODO: Define what this agent is responsible for');
|
||||
lines.push('- TODO: Add specific tasks and behaviors');
|
||||
lines.push('');
|
||||
lines.push('## Guidelines');
|
||||
lines.push('');
|
||||
lines.push('- TODO: Add guidelines for how this agent should behave');
|
||||
lines.push('- TODO: Define any constraints or preferences');
|
||||
lines.push('');
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function formatAgentName(name: string): string {
|
||||
return name
|
||||
.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
}
|
||||
@@ -31,3 +31,13 @@ export { PlanCommand } from './plan.js';
|
||||
export { CommandCmd } from './command.js';
|
||||
export { AICommand } from './ai.js';
|
||||
export { AuditCommand } from './audit.js';
|
||||
export { PublishCommand } from './publish.js';
|
||||
export {
|
||||
AgentCommand,
|
||||
AgentListCommand,
|
||||
AgentShowCommand,
|
||||
AgentCreateCommand,
|
||||
AgentTranslateCommand,
|
||||
AgentSyncCommand,
|
||||
AgentValidateCommand,
|
||||
} from './agent.js';
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { createInterface } from 'node:readline';
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
@@ -69,6 +72,9 @@ export class InitCommand extends Command {
|
||||
console.log(chalk.dim(' 2. Sync config: skillkit sync'));
|
||||
console.log(chalk.dim(' 3. Use skills: skillkit read <skill-name>'));
|
||||
|
||||
// Check if SKILL.md exists and offer to publish
|
||||
await this.checkAndPromptPublish();
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Initialization failed'));
|
||||
@@ -76,4 +82,47 @@ export class InitCommand extends Command {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private async checkAndPromptPublish(): Promise<void> {
|
||||
// Skip in non-interactive environments (CI, piped input, etc.)
|
||||
if (!process.stdin.isTTY) return;
|
||||
|
||||
const skillMdLocations = [
|
||||
join(process.cwd(), 'SKILL.md'),
|
||||
join(process.cwd(), 'skills', 'SKILL.md'),
|
||||
join(process.cwd(), '.claude', 'skills', 'SKILL.md'),
|
||||
join(process.cwd(), '.cursor', 'skills', 'SKILL.md'),
|
||||
];
|
||||
|
||||
const foundSkillMd = skillMdLocations.find(loc => existsSync(loc));
|
||||
if (!foundSkillMd) return;
|
||||
|
||||
console.log();
|
||||
console.log(chalk.yellow('Found SKILL.md in your project!'));
|
||||
console.log(chalk.dim('Would you like to publish it to the SkillKit marketplace?'));
|
||||
console.log();
|
||||
|
||||
const answer = await this.prompt('Publish skill? [y/N]: ');
|
||||
|
||||
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
||||
console.log();
|
||||
console.log(chalk.cyan('To publish your skill, run:'));
|
||||
console.log(chalk.white(` skillkit publish ${foundSkillMd}`));
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
|
||||
private prompt(question: string): Promise<string> {
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
rl.question(question, answer => {
|
||||
rl.close();
|
||||
resolve(answer.trim());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join, basename, dirname } from 'node:path';
|
||||
import { execSync } from 'node:child_process';
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
|
||||
interface SkillFrontmatter {
|
||||
name?: string;
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export class PublishCommand extends Command {
|
||||
static override paths = [['publish']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Publish your skill to the SkillKit marketplace',
|
||||
examples: [
|
||||
['Publish skill from current directory', '$0 publish'],
|
||||
['Publish skill from specific path', '$0 publish ./my-skill'],
|
||||
['Publish with custom name', '$0 publish --name my-awesome-skill'],
|
||||
],
|
||||
});
|
||||
|
||||
skillPath = Option.String({ required: false, name: 'path' });
|
||||
|
||||
name = Option.String('--name,-n', {
|
||||
description: 'Custom skill name (default: parsed from SKILL.md)',
|
||||
});
|
||||
|
||||
dryRun = Option.Boolean('--dry-run', false, {
|
||||
description: 'Show what would be published without actually publishing',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const skillPath = this.skillPath || process.cwd();
|
||||
const skillMdPath = this.findSkillMd(skillPath);
|
||||
|
||||
if (!skillMdPath) {
|
||||
console.error(chalk.red('No SKILL.md found'));
|
||||
console.error(chalk.dim('Run this command from a directory containing SKILL.md'));
|
||||
console.error(chalk.dim('Or specify the path: skillkit publish ./path/to/skill'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan('Publishing skill to SkillKit marketplace...\n'));
|
||||
|
||||
// Parse SKILL.md
|
||||
const content = readFileSync(skillMdPath, 'utf-8');
|
||||
const frontmatter = this.parseFrontmatter(content);
|
||||
const skillName = this.name || frontmatter.name || basename(dirname(skillMdPath));
|
||||
|
||||
// Get git repo info
|
||||
const repoInfo = this.getRepoInfo(dirname(skillMdPath));
|
||||
if (!repoInfo) {
|
||||
console.error(chalk.red('Not a git repository or no remote configured'));
|
||||
console.error(chalk.dim('Your skill must be in a git repository with a GitHub remote'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Build skill entry
|
||||
const skillSlug = this.slugify(skillName);
|
||||
if (!skillSlug) {
|
||||
console.error(chalk.red('Skill name produces an empty slug.'));
|
||||
console.error(chalk.dim('Please pass --name with letters or numbers.'));
|
||||
return 1;
|
||||
}
|
||||
const skillEntry = {
|
||||
id: `${repoInfo.owner}/${repoInfo.repo}/${skillSlug}`,
|
||||
name: this.formatName(skillName),
|
||||
description: frontmatter.description || `Best practices and patterns for ${this.formatName(skillName)}`,
|
||||
source: `${repoInfo.owner}/${repoInfo.repo}`,
|
||||
tags: frontmatter.tags || this.inferTags(skillName, frontmatter.description || ''),
|
||||
};
|
||||
|
||||
console.log(chalk.white('Skill details:'));
|
||||
console.log(chalk.dim(` ID: ${skillEntry.id}`));
|
||||
console.log(chalk.dim(` Name: ${skillEntry.name}`));
|
||||
console.log(chalk.dim(` Description: ${skillEntry.description}`));
|
||||
console.log(chalk.dim(` Source: ${skillEntry.source}`));
|
||||
console.log(chalk.dim(` Tags: ${skillEntry.tags.join(', ')}`));
|
||||
console.log();
|
||||
|
||||
if (this.dryRun) {
|
||||
console.log(chalk.yellow('Dry run - not publishing'));
|
||||
console.log(chalk.dim('JSON entry that would be added:'));
|
||||
console.log(JSON.stringify(skillEntry, null, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create GitHub issue to add skill
|
||||
const issueBody = this.createIssueBody(skillEntry);
|
||||
const issueTitle = encodeURIComponent(`[Publish] ${skillEntry.name}`);
|
||||
const issueBodyEncoded = encodeURIComponent(issueBody);
|
||||
const issueUrl = `https://github.com/rohitg00/skillkit/issues/new?title=${issueTitle}&body=${issueBodyEncoded}&labels=skill-submission,publish`;
|
||||
|
||||
console.log(chalk.green('Opening GitHub to submit your skill...\n'));
|
||||
|
||||
try {
|
||||
// Try to open the URL
|
||||
const openCmd =
|
||||
process.platform === 'darwin'
|
||||
? `open "${issueUrl}"`
|
||||
: process.platform === 'win32'
|
||||
? `cmd /c start "" "${issueUrl}"`
|
||||
: `xdg-open "${issueUrl}"`;
|
||||
execSync(openCmd, { stdio: 'ignore' });
|
||||
|
||||
console.log(chalk.green('GitHub issue page opened!'));
|
||||
console.log(chalk.dim('Review and submit the issue to publish your skill.'));
|
||||
} catch {
|
||||
console.log(chalk.yellow('Could not open browser automatically.'));
|
||||
console.log(chalk.dim('Please open this URL manually:\n'));
|
||||
console.log(chalk.cyan(issueUrl));
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log(chalk.cyan('Next steps:'));
|
||||
console.log(chalk.dim(' 1. Review the skill details in the GitHub issue'));
|
||||
console.log(chalk.dim(' 2. Submit the issue'));
|
||||
console.log(chalk.dim(' 3. A maintainer will review and add your skill'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private findSkillMd(basePath: string): string | null {
|
||||
// Check if path is directly to SKILL.md
|
||||
if (basePath.endsWith('SKILL.md') && existsSync(basePath)) {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
// Check if SKILL.md exists in the directory
|
||||
const direct = join(basePath, 'SKILL.md');
|
||||
if (existsSync(direct)) {
|
||||
return direct;
|
||||
}
|
||||
|
||||
// Check common skill locations
|
||||
const locations = [
|
||||
join(basePath, 'skills', 'SKILL.md'),
|
||||
join(basePath, '.claude', 'skills', 'SKILL.md'),
|
||||
join(basePath, '.cursor', 'skills', 'SKILL.md'),
|
||||
];
|
||||
|
||||
for (const loc of locations) {
|
||||
if (existsSync(loc)) {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private parseFrontmatter(content: string): SkillFrontmatter {
|
||||
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
||||
if (!match) return {};
|
||||
|
||||
const frontmatter: SkillFrontmatter = {};
|
||||
const lines = match[1].split(/\r?\n/);
|
||||
let inTagsList = false;
|
||||
|
||||
for (const line of lines) {
|
||||
// Handle multiline tags list
|
||||
if (inTagsList) {
|
||||
const tagMatch = line.match(/^\s*-\s*(.+)$/);
|
||||
if (tagMatch) {
|
||||
frontmatter.tags ??= [];
|
||||
frontmatter.tags.push(tagMatch[1].trim().replace(/^["']|["']$/g, ''));
|
||||
continue;
|
||||
}
|
||||
if (line.trim() === '') continue;
|
||||
inTagsList = false;
|
||||
}
|
||||
|
||||
const colonIdx = line.indexOf(':');
|
||||
if (colonIdx === -1) continue;
|
||||
|
||||
const key = line.slice(0, colonIdx).trim();
|
||||
const value = line.slice(colonIdx + 1).trim();
|
||||
|
||||
switch (key) {
|
||||
case 'name':
|
||||
frontmatter.name = value.replace(/^["']|["']$/g, '');
|
||||
break;
|
||||
case 'description':
|
||||
frontmatter.description = value.replace(/^["']|["']$/g, '');
|
||||
break;
|
||||
case 'version':
|
||||
frontmatter.version = value.replace(/^["']|["']$/g, '');
|
||||
break;
|
||||
case 'tags':
|
||||
// Parse YAML array: [tag1, tag2] or multiline list
|
||||
if (value.startsWith('[')) {
|
||||
frontmatter.tags = value
|
||||
.slice(1, -1)
|
||||
.split(',')
|
||||
.map(t => t.trim().replace(/^["']|["']$/g, ''))
|
||||
.filter(t => t.length > 0);
|
||||
} else if (value === '') {
|
||||
inTagsList = true;
|
||||
frontmatter.tags = [];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return frontmatter;
|
||||
}
|
||||
|
||||
private slugify(name: string): string {
|
||||
return name
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '');
|
||||
}
|
||||
|
||||
private getRepoInfo(dir: string): { owner: string; repo: string } | null {
|
||||
try {
|
||||
const remote = execSync('git remote get-url origin', {
|
||||
cwd: dir,
|
||||
encoding: 'utf-8',
|
||||
stdio: ['pipe', 'pipe', 'ignore'],
|
||||
}).trim();
|
||||
|
||||
// Parse GitHub URL: git@github.com:owner/repo.git or https://github.com/owner/repo.git
|
||||
const match = remote.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?$/);
|
||||
if (match) {
|
||||
return { owner: match[1], repo: match[2] };
|
||||
}
|
||||
} catch {
|
||||
// Not a git repo or no remote
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private formatName(name: string): string {
|
||||
return name
|
||||
.split(/[-_]/)
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
private inferTags(name: string, description: string): string[] {
|
||||
const tags: string[] = [];
|
||||
const text = `${name} ${description}`.toLowerCase();
|
||||
|
||||
const tagMap: Record<string, string[]> = {
|
||||
react: ['react', 'jsx', 'tsx'],
|
||||
typescript: ['typescript', 'ts'],
|
||||
nextjs: ['next', 'nextjs'],
|
||||
testing: ['test', 'jest', 'vitest'],
|
||||
mobile: ['mobile', 'react-native', 'expo'],
|
||||
backend: ['backend', 'api', 'server'],
|
||||
database: ['database', 'postgres', 'mysql', 'supabase'],
|
||||
frontend: ['frontend', 'ui', 'design'],
|
||||
devops: ['devops', 'ci', 'cd', 'docker'],
|
||||
};
|
||||
|
||||
for (const [tag, keywords] of Object.entries(tagMap)) {
|
||||
if (keywords.some(k => text.includes(k))) {
|
||||
tags.push(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return tags.length > 0 ? tags : ['general'];
|
||||
}
|
||||
|
||||
private createIssueBody(
|
||||
skill: { id: string; name: string; description: string; source: string; tags: string[] }
|
||||
): string {
|
||||
return `## Publish Skill Request
|
||||
|
||||
### Skill Details
|
||||
- **ID:** \`${skill.id}\`
|
||||
- **Name:** ${skill.name}
|
||||
- **Description:** ${skill.description}
|
||||
- **Source:** [${skill.source}](https://github.com/${skill.source})
|
||||
- **Tags:** ${skill.tags.map(t => `\`${t}\``).join(', ')}
|
||||
|
||||
### JSON Entry
|
||||
\`\`\`json
|
||||
${JSON.stringify(skill, null, 2)}
|
||||
\`\`\`
|
||||
|
||||
### Checklist
|
||||
- [ ] SKILL.md follows the standard format
|
||||
- [ ] Skill is publicly accessible on GitHub
|
||||
- [ ] Description accurately describes the skill
|
||||
- [ ] Tags are appropriate
|
||||
|
||||
---
|
||||
Submitted via \`skillkit publish\``;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,26 @@
|
||||
import { Command } from 'clipanion';
|
||||
|
||||
/**
|
||||
* UI Command - Launch the SkillKit TUI
|
||||
* Uses the unified OpenTUI-based interface
|
||||
*/
|
||||
export class UICommand extends Command {
|
||||
static override paths = [['ui'], ['tui']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Launch the interactive TUI (Terminal User Interface)',
|
||||
details: `
|
||||
Launches the SkillKit TUI with a beautiful monochromatic design.
|
||||
|
||||
Features:
|
||||
- Browse and discover skills from the marketplace
|
||||
- Manage installed skills across 17+ AI coding agents
|
||||
- Sync skills between agents
|
||||
- AI-powered recommendations
|
||||
- Team collaboration
|
||||
|
||||
Requires Bun runtime (>=1.2.0) for optimal performance.
|
||||
`,
|
||||
examples: [
|
||||
['Open interactive TUI', '$0 ui'],
|
||||
['Alias for TUI', '$0 tui'],
|
||||
@@ -12,8 +28,20 @@ export class UICommand extends Command {
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const { startTUI } = await import('@skillkit/tui');
|
||||
await startTUI();
|
||||
return 0;
|
||||
try {
|
||||
const { startTUI } = await import('@skillkit/tui');
|
||||
await startTUI();
|
||||
return 0;
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
console.error('Error launching TUI:', err.message);
|
||||
console.error('');
|
||||
console.error('Make sure you are running with Bun (>=1.2.0):');
|
||||
console.error(' bun skillkit ui');
|
||||
console.error('');
|
||||
console.error('Install Bun from: https://bun.sh');
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/core",
|
||||
"version": "1.6.1",
|
||||
"version": "1.7.1",
|
||||
"description": "Core functionality for SkillKit - skill discovery, parsing, and translation",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { mkdirSync, writeFileSync, rmSync, existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import {
|
||||
AGENT_SKILL_FORMATS,
|
||||
parseSkillToCanonical,
|
||||
parseSkillContentToCanonical,
|
||||
translateSkillToAgent,
|
||||
translateSkillToAll,
|
||||
writeTranslatedSkill,
|
||||
generateSkillsConfig,
|
||||
getAgentSkillsDir,
|
||||
getAgentConfigFile,
|
||||
supportsAutoDiscovery,
|
||||
getAllSkillsDirs,
|
||||
getGlobalSkillsDir,
|
||||
type CrossAgentSkill,
|
||||
type SkillTranslationOptions,
|
||||
} from '../skill-translator.js';
|
||||
|
||||
describe('Skill Translator', () => {
|
||||
let tempDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
tempDir = join(tmpdir(), `skillkit-test-${Date.now()}`);
|
||||
mkdirSync(tempDir, { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (existsSync(tempDir)) {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
describe('AGENT_SKILL_FORMATS', () => {
|
||||
it('should have configurations for all supported agents', () => {
|
||||
const expectedAgents = [
|
||||
'claude-code', 'cursor', 'codex', 'gemini-cli', 'opencode',
|
||||
'antigravity', 'amp', 'clawdbot', 'droid', 'github-copilot',
|
||||
'goose', 'kilo', 'kiro-cli', 'roo', 'trae', 'windsurf', 'universal',
|
||||
];
|
||||
|
||||
for (const agent of expectedAgents) {
|
||||
expect(AGENT_SKILL_FORMATS[agent as keyof typeof AGENT_SKILL_FORMATS]).toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('should have valid skillsDir for each agent', () => {
|
||||
for (const [agent, format] of Object.entries(AGENT_SKILL_FORMATS)) {
|
||||
expect(format.skillsDir).toBeTruthy();
|
||||
expect(typeof format.skillsDir).toBe('string');
|
||||
}
|
||||
});
|
||||
|
||||
it('should have valid configFile for each agent', () => {
|
||||
for (const [agent, format] of Object.entries(AGENT_SKILL_FORMATS)) {
|
||||
expect(format.configFile).toBeTruthy();
|
||||
expect(typeof format.configFile).toBe('string');
|
||||
}
|
||||
});
|
||||
|
||||
it('should have correct Cursor MDC format', () => {
|
||||
const cursor = AGENT_SKILL_FORMATS.cursor;
|
||||
expect(cursor.skillsDir).toBe('.cursor/skills');
|
||||
expect(cursor.configFile).toBe('.cursor/rules/skills.mdc');
|
||||
expect(cursor.configFormat).toBe('mdc');
|
||||
});
|
||||
|
||||
it('should have correct Windsurf format', () => {
|
||||
const windsurf = AGENT_SKILL_FORMATS.windsurf;
|
||||
expect(windsurf.skillsDir).toBe('.windsurf/skills');
|
||||
expect(windsurf.configFile).toBe('.windsurf/rules/skills.md');
|
||||
expect(windsurf.configFormat).toBe('markdown');
|
||||
expect(windsurf.globalSkillsDir).toBe('~/.codeium/windsurf/skills');
|
||||
});
|
||||
|
||||
it('should have correct GitHub Copilot format', () => {
|
||||
const copilot = AGENT_SKILL_FORMATS['github-copilot'];
|
||||
expect(copilot.skillsDir).toBe('.github/skills');
|
||||
expect(copilot.configFile).toBe('.github/copilot-instructions.md');
|
||||
expect(copilot.configFormat).toBe('markdown');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseSkillToCanonical', () => {
|
||||
it('should parse a valid SKILL.md file', () => {
|
||||
const skillDir = join(tempDir, 'test-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: test-skill
|
||||
description: A test skill for unit testing
|
||||
version: "1.0.0"
|
||||
author: Test Author
|
||||
tags:
|
||||
- testing
|
||||
- unit-test
|
||||
---
|
||||
# Test Skill
|
||||
|
||||
This is a test skill for unit testing purposes.
|
||||
|
||||
## Usage
|
||||
|
||||
Use this skill when you need to test something.
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.name).toBe('test-skill');
|
||||
expect(result?.description).toBe('A test skill for unit testing');
|
||||
expect(result?.version).toBe('1.0.0');
|
||||
expect(result?.author).toBe('Test Author');
|
||||
expect(result?.tags).toEqual(['testing', 'unit-test']);
|
||||
expect(result?.content).toContain('# Test Skill');
|
||||
});
|
||||
|
||||
it('should return null for non-existent skill', () => {
|
||||
const result = parseSkillToCanonical(join(tempDir, 'non-existent'));
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('should handle SKILL.md without frontmatter', () => {
|
||||
const skillDir = join(tempDir, 'no-frontmatter-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `# Simple Skill
|
||||
|
||||
Just some content without frontmatter.
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
expect(result).not.toBeNull();
|
||||
// Without frontmatter, name is derived from directory name
|
||||
expect(result?.name).toBe('no-frontmatter-skill');
|
||||
});
|
||||
|
||||
it('should extract allowed-tools from frontmatter', () => {
|
||||
const skillDir = join(tempDir, 'tools-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: tools-skill
|
||||
description: Skill with allowed tools
|
||||
allowed-tools: Read, Write, Bash
|
||||
---
|
||||
Content here.
|
||||
`);
|
||||
|
||||
const result = parseSkillToCanonical(skillDir);
|
||||
expect(result?.allowedTools).toEqual(['Read', 'Write', 'Bash']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseSkillContentToCanonical', () => {
|
||||
it('should parse skill content with full frontmatter', () => {
|
||||
const content = `---
|
||||
name: content-skill
|
||||
description: Parsed from content
|
||||
model: opus
|
||||
context: fork
|
||||
disable-model-invocation: true
|
||||
---
|
||||
# Content Skill
|
||||
|
||||
Instructions here.
|
||||
`;
|
||||
|
||||
const result = parseSkillContentToCanonical(content, '/path/to/skill', 'claude-code');
|
||||
expect(result?.name).toBe('content-skill');
|
||||
expect(result?.description).toBe('Parsed from content');
|
||||
expect(result?.agentFields?.['model']).toBe('opus');
|
||||
expect(result?.agentFields?.['context']).toBe('fork');
|
||||
expect(result?.agentFields?.['disable-model-invocation']).toBe(true);
|
||||
expect(result?.sourceAgent).toBe('claude-code');
|
||||
});
|
||||
|
||||
it('should extract description from content when not in frontmatter', () => {
|
||||
const content = `---
|
||||
name: no-desc
|
||||
---
|
||||
This is a longer paragraph that should be used as the description when none is provided in frontmatter.
|
||||
|
||||
## More Content
|
||||
`;
|
||||
|
||||
const result = parseSkillContentToCanonical(content, '/path/to/skill');
|
||||
expect(result?.description).toContain('This is a longer paragraph');
|
||||
});
|
||||
});
|
||||
|
||||
describe('translateSkillToAgent', () => {
|
||||
const testSkill: CrossAgentSkill = {
|
||||
name: 'translate-test',
|
||||
description: 'A skill to test translation',
|
||||
content: '# Translate Test\n\nTest content for translation.',
|
||||
frontmatter: { name: 'translate-test', description: 'A skill to test translation' },
|
||||
sourcePath: '/test/path',
|
||||
sourceAgent: 'claude-code',
|
||||
version: '1.0.0',
|
||||
author: 'Test',
|
||||
tags: ['test'],
|
||||
};
|
||||
|
||||
it('should translate to Claude Code format', () => {
|
||||
const result = translateSkillToAgent(testSkill, 'claude-code');
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.content).toContain('name: translate-test');
|
||||
expect(result.content).toContain('description: A skill to test translation');
|
||||
expect(result.targetAgent).toBe('claude-code');
|
||||
});
|
||||
|
||||
it('should translate to Cursor format', () => {
|
||||
const result = translateSkillToAgent(testSkill, 'cursor');
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.content).toContain('name: translate-test');
|
||||
expect(result.targetAgent).toBe('cursor');
|
||||
});
|
||||
|
||||
it('should translate to Windsurf format', () => {
|
||||
const result = translateSkillToAgent(testSkill, 'windsurf');
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.targetAgent).toBe('windsurf');
|
||||
});
|
||||
|
||||
it('should include translation metadata when requested', () => {
|
||||
const options: SkillTranslationOptions = { addMetadata: true };
|
||||
const result = translateSkillToAgent(testSkill, 'cursor', options);
|
||||
expect(result.content).toContain('_translated-from: claude-code');
|
||||
expect(result.content).toContain('_translated-at:');
|
||||
});
|
||||
|
||||
it('should preserve agent-specific fields for Claude Code', () => {
|
||||
const skillWithFields: CrossAgentSkill = {
|
||||
...testSkill,
|
||||
agentFields: {
|
||||
model: 'opus',
|
||||
context: 'fork',
|
||||
'disable-model-invocation': true,
|
||||
},
|
||||
};
|
||||
|
||||
const result = translateSkillToAgent(skillWithFields, 'claude-code');
|
||||
expect(result.content).toContain('model: opus');
|
||||
expect(result.content).toContain('context: fork');
|
||||
expect(result.content).toContain('disable-model-invocation: true');
|
||||
});
|
||||
|
||||
it('should report incompatible features', () => {
|
||||
const skillWithHooks: CrossAgentSkill = {
|
||||
...testSkill,
|
||||
agentFields: {
|
||||
hooks: [{ type: 'PreToolUse', command: 'echo test' }],
|
||||
},
|
||||
};
|
||||
|
||||
const result = translateSkillToAgent(skillWithHooks, 'cursor');
|
||||
expect(result.incompatible).toContain('hooks (only supported in Claude Code)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('translateSkillToAll', () => {
|
||||
it('should translate skill to all supported agents', () => {
|
||||
const skillDir = join(tempDir, 'all-agents-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), `---
|
||||
name: all-agents
|
||||
description: Skill for all agents
|
||||
---
|
||||
# All Agents Skill
|
||||
`);
|
||||
|
||||
const results = translateSkillToAll(skillDir, 'claude-code');
|
||||
expect(results.size).toBeGreaterThan(0);
|
||||
|
||||
// Should not include source agent
|
||||
expect(results.has('claude-code')).toBe(false);
|
||||
|
||||
// Should include other agents
|
||||
expect(results.has('cursor')).toBe(true);
|
||||
expect(results.has('windsurf')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return empty map for non-existent skill', () => {
|
||||
const results = translateSkillToAll(join(tempDir, 'non-existent'));
|
||||
expect(results.size).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeTranslatedSkill', () => {
|
||||
it('should write translated skill to disk', () => {
|
||||
const result = {
|
||||
success: true,
|
||||
content: '---\nname: written-skill\n---\n# Content',
|
||||
filename: 'SKILL.md',
|
||||
targetDir: 'test-skill',
|
||||
warnings: [],
|
||||
incompatible: [],
|
||||
targetAgent: 'claude-code' as const,
|
||||
};
|
||||
|
||||
const writeResult = writeTranslatedSkill(result, tempDir);
|
||||
expect(writeResult.success).toBe(true);
|
||||
expect(existsSync(writeResult.path)).toBe(true);
|
||||
});
|
||||
|
||||
it('should create nested directories', () => {
|
||||
const result = {
|
||||
success: true,
|
||||
content: '---\nname: nested\n---\n# Content',
|
||||
filename: 'SKILL.md',
|
||||
targetDir: '.cursor/skills/nested-skill',
|
||||
warnings: [],
|
||||
incompatible: [],
|
||||
targetAgent: 'cursor' as const,
|
||||
};
|
||||
|
||||
const writeResult = writeTranslatedSkill(result, tempDir);
|
||||
expect(writeResult.success).toBe(true);
|
||||
expect(existsSync(join(tempDir, '.cursor/skills/nested-skill/SKILL.md'))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateSkillsConfig', () => {
|
||||
const testSkills = [
|
||||
{ name: 'skill-one', description: 'First skill', path: '/path/one', location: 'project' as const, enabled: true },
|
||||
{ name: 'skill-two', description: 'Second skill', path: '/path/two', location: 'project' as const, enabled: true },
|
||||
{ name: 'disabled-skill', description: 'Disabled', path: '/path/disabled', location: 'project' as const, enabled: false },
|
||||
];
|
||||
|
||||
it('should generate XML config for Claude Code', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'claude-code');
|
||||
expect(config).toContain('<skills_system');
|
||||
expect(config).toContain('<name>skill-one</name>');
|
||||
expect(config).toContain('<name>skill-two</name>');
|
||||
expect(config).not.toContain('disabled-skill');
|
||||
});
|
||||
|
||||
it('should generate MDC config for Cursor', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'cursor');
|
||||
expect(config).toContain('---');
|
||||
expect(config).toContain('description:');
|
||||
expect(config).toContain('globs:');
|
||||
expect(config).toContain('alwaysApply: true');
|
||||
expect(config).toContain('**skill-one**');
|
||||
expect(config).toContain('**skill-two**');
|
||||
});
|
||||
|
||||
it('should generate Markdown table config for Codex', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'codex');
|
||||
expect(config).toContain('| Skill | Description | Command |');
|
||||
expect(config).toContain('| skill-one |');
|
||||
expect(config).toContain('| skill-two |');
|
||||
});
|
||||
|
||||
it('should generate JSON config for Gemini CLI', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'gemini-cli');
|
||||
expect(config).toContain('```json');
|
||||
expect(config).toContain('"name": "skill-one"');
|
||||
expect(config).toContain('"name": "skill-two"');
|
||||
});
|
||||
|
||||
it('should generate Markdown config for Windsurf', () => {
|
||||
const config = generateSkillsConfig(testSkills, 'windsurf');
|
||||
expect(config).toContain('### skill-one');
|
||||
expect(config).toContain('### skill-two');
|
||||
expect(config).toContain('**Invoke:**');
|
||||
});
|
||||
|
||||
it('should return empty string for no enabled skills', () => {
|
||||
const disabledSkills = [
|
||||
{ name: 'disabled', description: 'Disabled', path: '/path', location: 'project' as const, enabled: false },
|
||||
];
|
||||
const config = generateSkillsConfig(disabledSkills, 'claude-code');
|
||||
expect(config).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('utility functions', () => {
|
||||
it('getAgentSkillsDir should return correct path', () => {
|
||||
expect(getAgentSkillsDir('claude-code')).toBe('.claude/skills');
|
||||
expect(getAgentSkillsDir('cursor')).toBe('.cursor/skills');
|
||||
expect(getAgentSkillsDir('windsurf')).toBe('.windsurf/skills');
|
||||
});
|
||||
|
||||
it('getAgentConfigFile should return correct path', () => {
|
||||
expect(getAgentConfigFile('claude-code')).toBe('CLAUDE.md');
|
||||
expect(getAgentConfigFile('cursor')).toBe('.cursor/rules/skills.mdc');
|
||||
expect(getAgentConfigFile('github-copilot')).toBe('.github/copilot-instructions.md');
|
||||
});
|
||||
|
||||
it('supportsAutoDiscovery should return true for all major agents', () => {
|
||||
expect(supportsAutoDiscovery('claude-code')).toBe(true);
|
||||
expect(supportsAutoDiscovery('cursor')).toBe(true);
|
||||
expect(supportsAutoDiscovery('windsurf')).toBe(true);
|
||||
});
|
||||
|
||||
it('getAllSkillsDirs should include alternative directories', () => {
|
||||
const cursorDirs = getAllSkillsDirs('cursor');
|
||||
expect(cursorDirs).toContain('.cursor/skills');
|
||||
expect(cursorDirs).toContain('.cursor/commands');
|
||||
|
||||
const windsurfDirs = getAllSkillsDirs('windsurf');
|
||||
expect(windsurfDirs).toContain('.windsurf/skills');
|
||||
expect(windsurfDirs).toContain('.windsurf/workflows');
|
||||
});
|
||||
|
||||
it('getGlobalSkillsDir should return correct global path', () => {
|
||||
expect(getGlobalSkillsDir('claude-code')).toBe('~/.claude/skills');
|
||||
expect(getGlobalSkillsDir('windsurf')).toBe('~/.codeium/windsurf/skills');
|
||||
expect(getGlobalSkillsDir('opencode')).toBe('~/.config/opencode/skills');
|
||||
expect(getGlobalSkillsDir('roo')).toBe('~/.roo/skills');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Agent Adapter Integration', () => {
|
||||
it('should have matching config formats between AGENT_SKILL_FORMATS and expected values', () => {
|
||||
// Verify that the 2026 updates are consistent
|
||||
expect(AGENT_SKILL_FORMATS.cursor.configFormat).toBe('mdc');
|
||||
expect(AGENT_SKILL_FORMATS.windsurf.configFormat).toBe('markdown');
|
||||
expect(AGENT_SKILL_FORMATS['github-copilot'].configFormat).toBe('markdown');
|
||||
expect(AGENT_SKILL_FORMATS.trae.configFormat).toBe('markdown');
|
||||
expect(AGENT_SKILL_FORMATS['claude-code'].configFormat).toBe('xml');
|
||||
expect(AGENT_SKILL_FORMATS.codex.configFormat).toBe('markdown-table');
|
||||
expect(AGENT_SKILL_FORMATS['gemini-cli'].configFormat).toBe('json');
|
||||
});
|
||||
|
||||
it('should have valid invoke commands', () => {
|
||||
for (const format of Object.values(AGENT_SKILL_FORMATS)) {
|
||||
expect(format.invokeCommand).toBe('skillkit read');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,269 @@
|
||||
/**
|
||||
* Centralized Agent Configuration
|
||||
*
|
||||
* Single source of truth for all AI coding agent configurations.
|
||||
* All modules should import from here instead of defining their own values.
|
||||
*/
|
||||
|
||||
import type { AgentType } from './types.js';
|
||||
|
||||
/**
|
||||
* Agent configuration for skills and config files
|
||||
*/
|
||||
export interface AgentDirectoryConfig {
|
||||
/** Primary skills directory path */
|
||||
skillsDir: string;
|
||||
/** Config file that references skills */
|
||||
configFile: string;
|
||||
/** Alternative skills directories */
|
||||
altSkillsDirs?: string[];
|
||||
/** Global skills directory */
|
||||
globalSkillsDir?: string;
|
||||
/** Config format: xml, markdown, mdc, json, markdown-table */
|
||||
configFormat: 'xml' | 'markdown' | 'mdc' | 'json' | 'markdown-table';
|
||||
/** Whether agent uses YAML frontmatter in SKILL.md */
|
||||
usesFrontmatter: boolean;
|
||||
/** Agent-specific frontmatter fields */
|
||||
frontmatterFields?: string[];
|
||||
/** Whether agent supports skill auto-discovery */
|
||||
supportsAutoDiscovery: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Centralized agent configurations
|
||||
*
|
||||
* This is the ONLY source of truth for agent paths and formats.
|
||||
* Do not define these values elsewhere.
|
||||
*/
|
||||
export const AGENT_CONFIG: Record<AgentType, AgentDirectoryConfig> = {
|
||||
// Claude Code - all Claude products use the same format
|
||||
'claude-code': {
|
||||
skillsDir: '.claude/skills',
|
||||
configFile: 'CLAUDE.md',
|
||||
globalSkillsDir: '~/.claude/skills',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
frontmatterFields: [
|
||||
'name', 'description', 'allowed-tools', 'model', 'context',
|
||||
'agent', 'disable-model-invocation', 'user-invocable', 'argument-hint',
|
||||
],
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Cursor - uses MDC format in .cursor/rules/
|
||||
cursor: {
|
||||
skillsDir: '.cursor/skills',
|
||||
configFile: '.cursor/rules/skills.mdc',
|
||||
altSkillsDirs: ['.cursor/commands'],
|
||||
globalSkillsDir: '~/.cursor/skills',
|
||||
configFormat: 'mdc',
|
||||
usesFrontmatter: true,
|
||||
frontmatterFields: ['description', 'globs', 'alwaysApply'],
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Codex (OpenAI)
|
||||
codex: {
|
||||
skillsDir: '.codex/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
globalSkillsDir: '~/.codex/skills',
|
||||
configFormat: 'markdown-table',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Gemini CLI
|
||||
'gemini-cli': {
|
||||
skillsDir: '.gemini/skills',
|
||||
configFile: 'GEMINI.md',
|
||||
globalSkillsDir: '~/.gemini/skills',
|
||||
configFormat: 'json',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// OpenCode
|
||||
opencode: {
|
||||
skillsDir: '.opencode/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
altSkillsDirs: ['.opencode/agent'],
|
||||
globalSkillsDir: '~/.config/opencode/skills',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Antigravity
|
||||
antigravity: {
|
||||
skillsDir: '.antigravity/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Amp - uses .amp/ directory
|
||||
amp: {
|
||||
skillsDir: '.amp/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Clawdbot
|
||||
clawdbot: {
|
||||
skillsDir: '.clawdbot/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
altSkillsDirs: ['skills'],
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Droid (Factory)
|
||||
droid: {
|
||||
skillsDir: '.factory/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// GitHub Copilot
|
||||
'github-copilot': {
|
||||
skillsDir: '.github/skills',
|
||||
configFile: '.github/copilot-instructions.md',
|
||||
altSkillsDirs: ['.github/instructions'],
|
||||
configFormat: 'markdown',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Goose
|
||||
goose: {
|
||||
skillsDir: '.goose/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
globalSkillsDir: '~/.goose/skills',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Kilo
|
||||
kilo: {
|
||||
skillsDir: '.kilocode/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
altSkillsDirs: ['.kilocode/modes'],
|
||||
globalSkillsDir: '~/.kilocode/skills',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Kiro CLI
|
||||
'kiro-cli': {
|
||||
skillsDir: '.kiro/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
globalSkillsDir: '~/.kiro/skills',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Roo Code
|
||||
roo: {
|
||||
skillsDir: '.roo/skills',
|
||||
configFile: 'AGENTS.md',
|
||||
altSkillsDirs: ['.roo/modes'],
|
||||
globalSkillsDir: '~/.roo/skills',
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Trae
|
||||
trae: {
|
||||
skillsDir: '.trae/skills',
|
||||
configFile: '.trae/rules/project_rules.md',
|
||||
altSkillsDirs: ['.trae/agent'],
|
||||
configFormat: 'markdown',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Windsurf
|
||||
windsurf: {
|
||||
skillsDir: '.windsurf/skills',
|
||||
configFile: '.windsurf/rules/skills.md',
|
||||
altSkillsDirs: ['.windsurf/workflows'],
|
||||
globalSkillsDir: '~/.codeium/windsurf/skills',
|
||||
configFormat: 'markdown',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
|
||||
// Universal - works with any agent
|
||||
universal: {
|
||||
skillsDir: 'skills',
|
||||
configFile: 'AGENTS.md',
|
||||
altSkillsDirs: ['.agent/skills', '.agents/skills'],
|
||||
configFormat: 'xml',
|
||||
usesFrontmatter: true,
|
||||
supportsAutoDiscovery: true,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Get agent configuration
|
||||
*/
|
||||
export function getAgentDirectoryConfig(agent: AgentType): AgentDirectoryConfig {
|
||||
return AGENT_CONFIG[agent];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get skills directory for an agent
|
||||
*/
|
||||
export function getSkillsDir(agent: AgentType): string {
|
||||
return AGENT_CONFIG[agent].skillsDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get config file for an agent
|
||||
*/
|
||||
export function getConfigFile(agent: AgentType): string {
|
||||
return AGENT_CONFIG[agent].configFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all skills directories for an agent (including alternatives)
|
||||
*/
|
||||
export function getAllSkillsDirs(agent: AgentType): string[] {
|
||||
const config = AGENT_CONFIG[agent];
|
||||
const dirs = [config.skillsDir];
|
||||
if (config.altSkillsDirs) {
|
||||
dirs.push(...config.altSkillsDirs);
|
||||
}
|
||||
return dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global skills directory for an agent
|
||||
*/
|
||||
export function getGlobalSkillsDir(agent: AgentType): string | undefined {
|
||||
return AGENT_CONFIG[agent].globalSkillsDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if agent supports auto-discovery
|
||||
*/
|
||||
export function supportsAutoDiscovery(agent: AgentType): boolean {
|
||||
return AGENT_CONFIG[agent].supportsAutoDiscovery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get config format for an agent
|
||||
*/
|
||||
export function getConfigFormat(agent: AgentType): AgentDirectoryConfig['configFormat'] {
|
||||
return AGENT_CONFIG[agent].configFormat;
|
||||
}
|
||||
@@ -0,0 +1,556 @@
|
||||
/**
|
||||
* Agent Discovery Tests
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { mkdirSync, writeFileSync, rmSync, existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import {
|
||||
discoverAgents,
|
||||
discoverAgentsForAgent,
|
||||
discoverAgentsRecursive,
|
||||
discoverAgentsFromPath,
|
||||
findAllAgents,
|
||||
findAgent,
|
||||
getAgentsDirectory,
|
||||
agentExists,
|
||||
getAgentStats,
|
||||
} from '../discovery.js';
|
||||
|
||||
describe('Agent Discovery', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
// Create a temporary test directory
|
||||
testDir = join(tmpdir(), `agent-test-${Date.now()}`);
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Clean up
|
||||
if (existsSync(testDir)) {
|
||||
rmSync(testDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
describe('discoverAgents', () => {
|
||||
it('should discover agents in .claude/agents directory', () => {
|
||||
const agentsDir = join(testDir, '.claude', 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'test-agent.md'),
|
||||
`---
|
||||
name: test-agent
|
||||
description: A test agent
|
||||
---
|
||||
|
||||
Agent content here.`
|
||||
);
|
||||
|
||||
const agents = discoverAgents(testDir);
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('test-agent');
|
||||
expect(agents[0].description).toBe('A test agent');
|
||||
expect(agents[0].location).toBe('project');
|
||||
});
|
||||
|
||||
it('should discover multiple agents', () => {
|
||||
const agentsDir = join(testDir, '.claude', 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'agent-one.md'),
|
||||
`---
|
||||
name: agent-one
|
||||
description: First agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'agent-two.md'),
|
||||
`---
|
||||
name: agent-two
|
||||
description: Second agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgents(testDir);
|
||||
|
||||
expect(agents).toHaveLength(2);
|
||||
const names = agents.map((a) => a.name);
|
||||
expect(names).toContain('agent-one');
|
||||
expect(names).toContain('agent-two');
|
||||
});
|
||||
|
||||
it('should return empty array when no agents directory exists', () => {
|
||||
const agents = discoverAgents(testDir);
|
||||
expect(agents).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should discover agents in alternative directories', () => {
|
||||
const agentsDir = join(testDir, 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'my-agent.md'),
|
||||
`---
|
||||
name: my-agent
|
||||
description: An agent in universal location
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgents(testDir);
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('my-agent');
|
||||
});
|
||||
});
|
||||
|
||||
describe('discoverAgentsForAgent', () => {
|
||||
it('should discover agents for specific AI agent type', () => {
|
||||
const claudeAgentsDir = join(testDir, '.claude', 'agents');
|
||||
const cursorAgentsDir = join(testDir, '.cursor', 'agents');
|
||||
mkdirSync(claudeAgentsDir, { recursive: true });
|
||||
mkdirSync(cursorAgentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(claudeAgentsDir, 'claude-agent.md'),
|
||||
`---
|
||||
name: claude-agent
|
||||
description: Claude specific
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(cursorAgentsDir, 'cursor-agent.md'),
|
||||
`---
|
||||
name: cursor-agent
|
||||
description: Cursor specific
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const claudeAgents = discoverAgentsForAgent(testDir, 'claude-code');
|
||||
expect(claudeAgents).toHaveLength(1);
|
||||
expect(claudeAgents[0].name).toBe('claude-agent');
|
||||
|
||||
const cursorAgents = discoverAgentsForAgent(testDir, 'cursor');
|
||||
expect(cursorAgents).toHaveLength(1);
|
||||
expect(cursorAgents[0].name).toBe('cursor-agent');
|
||||
});
|
||||
});
|
||||
|
||||
describe('findAllAgents', () => {
|
||||
it('should find agents in multiple search directories', () => {
|
||||
const dir1 = join(testDir, 'project1');
|
||||
const dir2 = join(testDir, 'project2');
|
||||
mkdirSync(join(dir1, '.claude', 'agents'), { recursive: true });
|
||||
mkdirSync(join(dir2, '.claude', 'agents'), { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(dir1, '.claude', 'agents', 'agent-a.md'),
|
||||
`---
|
||||
name: agent-a
|
||||
description: Agent A
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(dir2, '.claude', 'agents', 'agent-b.md'),
|
||||
`---
|
||||
name: agent-b
|
||||
description: Agent B
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = findAllAgents([dir1, dir2]);
|
||||
|
||||
expect(agents).toHaveLength(2);
|
||||
const names = agents.map((a) => a.name);
|
||||
expect(names).toContain('agent-a');
|
||||
expect(names).toContain('agent-b');
|
||||
});
|
||||
|
||||
it('should deduplicate agents by name', () => {
|
||||
const dir1 = join(testDir, 'project1');
|
||||
const dir2 = join(testDir, 'project2');
|
||||
mkdirSync(join(dir1, '.claude', 'agents'), { recursive: true });
|
||||
mkdirSync(join(dir2, '.claude', 'agents'), { recursive: true });
|
||||
|
||||
// Same agent name in both directories
|
||||
writeFileSync(
|
||||
join(dir1, '.claude', 'agents', 'shared-agent.md'),
|
||||
`---
|
||||
name: shared-agent
|
||||
description: Shared agent (dir1)
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(dir2, '.claude', 'agents', 'shared-agent.md'),
|
||||
`---
|
||||
name: shared-agent
|
||||
description: Shared agent (dir2)
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = findAllAgents([dir1, dir2]);
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('shared-agent');
|
||||
});
|
||||
});
|
||||
|
||||
describe('findAgent', () => {
|
||||
it('should find a specific agent by name', () => {
|
||||
const agentsDir = join(testDir, '.claude', 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'target-agent.md'),
|
||||
`---
|
||||
name: target-agent
|
||||
description: The target agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'other-agent.md'),
|
||||
`---
|
||||
name: other-agent
|
||||
description: Another agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agent = findAgent('target-agent', [testDir]);
|
||||
|
||||
expect(agent).not.toBeNull();
|
||||
expect(agent?.name).toBe('target-agent');
|
||||
expect(agent?.description).toBe('The target agent');
|
||||
});
|
||||
|
||||
it('should return null when agent not found', () => {
|
||||
const agentsDir = join(testDir, '.claude', 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
const agent = findAgent('non-existent', [testDir]);
|
||||
|
||||
expect(agent).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAgentsDirectory', () => {
|
||||
it('should return correct directory for different agent types', () => {
|
||||
expect(getAgentsDirectory(testDir, 'claude-code')).toBe(join(testDir, '.claude', 'agents'));
|
||||
expect(getAgentsDirectory(testDir, 'cursor')).toBe(join(testDir, '.cursor', 'agents'));
|
||||
expect(getAgentsDirectory(testDir, 'universal')).toBe(join(testDir, 'agents'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('agentExists', () => {
|
||||
it('should return true when agent exists', () => {
|
||||
const agentsDir = join(testDir, '.claude', 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'existing-agent.md'),
|
||||
`---
|
||||
name: existing-agent
|
||||
description: Exists
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
expect(agentExists('existing-agent', [testDir])).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when agent does not exist', () => {
|
||||
expect(agentExists('non-existent', [testDir])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAgentStats', () => {
|
||||
it('should return correct stats', () => {
|
||||
const agentsDir = join(testDir, '.claude', 'agents');
|
||||
mkdirSync(agentsDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'agent-one.md'),
|
||||
`---
|
||||
name: agent-one
|
||||
description: First
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(agentsDir, 'agent-two.md'),
|
||||
`---
|
||||
name: agent-two
|
||||
description: Second
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const stats = getAgentStats([testDir]);
|
||||
|
||||
expect(stats.total).toBe(2);
|
||||
expect(stats.project).toBe(2);
|
||||
expect(stats.global).toBe(0);
|
||||
expect(stats.enabled).toBe(2);
|
||||
expect(stats.disabled).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('discoverAgentsRecursive', () => {
|
||||
it('should discover agents in nested directories', () => {
|
||||
// Create nested structure like kubernetes-skills/claude-code/k8s-autoscaling
|
||||
const rootDir = join(testDir, 'skills');
|
||||
mkdirSync(join(rootDir, 'k8s-autoscaling'), { recursive: true });
|
||||
mkdirSync(join(rootDir, 'k8s-security'), { recursive: true });
|
||||
mkdirSync(join(rootDir, 'k8s-deploy'), { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'k8s-autoscaling', 'AGENT.md'),
|
||||
`---
|
||||
name: k8s-autoscaling
|
||||
description: Kubernetes autoscaling agent
|
||||
---
|
||||
Autoscaling content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'k8s-security', 'AGENT.md'),
|
||||
`---
|
||||
name: k8s-security
|
||||
description: Kubernetes security agent
|
||||
---
|
||||
Security content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'k8s-deploy', 'AGENT.md'),
|
||||
`---
|
||||
name: k8s-deploy
|
||||
description: Kubernetes deployment agent
|
||||
---
|
||||
Deploy content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsRecursive(rootDir);
|
||||
|
||||
expect(agents).toHaveLength(3);
|
||||
const names = agents.map((a) => a.name);
|
||||
expect(names).toContain('k8s-autoscaling');
|
||||
expect(names).toContain('k8s-security');
|
||||
expect(names).toContain('k8s-deploy');
|
||||
});
|
||||
|
||||
it('should discover deeply nested agents', () => {
|
||||
const rootDir = join(testDir, 'deep-skills');
|
||||
mkdirSync(join(rootDir, 'category1', 'subcategory', 'agent-deep'), { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'category1', 'subcategory', 'agent-deep', 'AGENT.md'),
|
||||
`---
|
||||
name: agent-deep
|
||||
description: Deeply nested agent
|
||||
---
|
||||
Deep content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsRecursive(rootDir);
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('agent-deep');
|
||||
});
|
||||
|
||||
it('should discover agents as markdown files', () => {
|
||||
const rootDir = join(testDir, 'md-skills');
|
||||
mkdirSync(join(rootDir, 'subdir'), { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'top-level-agent.md'),
|
||||
`---
|
||||
name: top-level-agent
|
||||
description: Top level agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'subdir', 'nested-agent.md'),
|
||||
`---
|
||||
name: nested-agent
|
||||
description: Nested agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsRecursive(rootDir);
|
||||
|
||||
expect(agents).toHaveLength(2);
|
||||
const names = agents.map((a) => a.name);
|
||||
expect(names).toContain('top-level-agent');
|
||||
expect(names).toContain('nested-agent');
|
||||
});
|
||||
|
||||
it('should skip hidden directories except standard agent paths', () => {
|
||||
const rootDir = join(testDir, 'hidden-test');
|
||||
mkdirSync(join(rootDir, '.hidden', 'agents'), { recursive: true });
|
||||
mkdirSync(join(rootDir, '.claude', 'agents'), { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, '.hidden', 'agents', 'hidden-agent.md'),
|
||||
`---
|
||||
name: hidden-agent
|
||||
description: Should be skipped
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, '.claude', 'agents', 'claude-agent.md'),
|
||||
`---
|
||||
name: claude-agent
|
||||
description: Should be found
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsRecursive(rootDir);
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('claude-agent');
|
||||
});
|
||||
|
||||
it('should return empty array for non-existent directory', () => {
|
||||
const agents = discoverAgentsRecursive(join(testDir, 'non-existent'));
|
||||
expect(agents).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('discoverAgentsFromPath', () => {
|
||||
it('should discover agent from single file', () => {
|
||||
mkdirSync(testDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(testDir, 'single-agent.md'),
|
||||
`---
|
||||
name: single-agent
|
||||
description: A single agent file
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsFromPath(join(testDir, 'single-agent.md'));
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('single-agent');
|
||||
});
|
||||
|
||||
it('should discover agents from directory without recursive flag', () => {
|
||||
const rootDir = join(testDir, 'flat-dir');
|
||||
mkdirSync(rootDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'agent-a.md'),
|
||||
`---
|
||||
name: agent-a
|
||||
description: Agent A
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'agent-b.md'),
|
||||
`---
|
||||
name: agent-b
|
||||
description: Agent B
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsFromPath(rootDir, false);
|
||||
|
||||
expect(agents).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should discover agents from directory with recursive flag', () => {
|
||||
const rootDir = join(testDir, 'nested-dir');
|
||||
mkdirSync(join(rootDir, 'subdir'), { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'agent-top.md'),
|
||||
`---
|
||||
name: agent-top
|
||||
description: Top agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'subdir', 'agent-nested.md'),
|
||||
`---
|
||||
name: agent-nested
|
||||
description: Nested agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agentsNonRecursive = discoverAgentsFromPath(rootDir, false);
|
||||
expect(agentsNonRecursive).toHaveLength(1);
|
||||
expect(agentsNonRecursive[0].name).toBe('agent-top');
|
||||
|
||||
const agentsRecursive = discoverAgentsFromPath(rootDir, true);
|
||||
expect(agentsRecursive).toHaveLength(2);
|
||||
const names = agentsRecursive.map((a) => a.name);
|
||||
expect(names).toContain('agent-top');
|
||||
expect(names).toContain('agent-nested');
|
||||
});
|
||||
|
||||
it('should handle agent directory with AGENT.md', () => {
|
||||
const agentDir = join(testDir, 'agent-dir');
|
||||
mkdirSync(agentDir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(agentDir, 'AGENT.md'),
|
||||
`---
|
||||
name: agent-dir
|
||||
description: Directory-based agent
|
||||
---
|
||||
Content.`
|
||||
);
|
||||
|
||||
const agents = discoverAgentsFromPath(agentDir);
|
||||
|
||||
expect(agents).toHaveLength(1);
|
||||
expect(agents[0].name).toBe('agent-dir');
|
||||
});
|
||||
|
||||
it('should return empty array for non-existent path', () => {
|
||||
const agents = discoverAgentsFromPath(join(testDir, 'non-existent'));
|
||||
expect(agents).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should return empty array for non-markdown file', () => {
|
||||
writeFileSync(join(testDir, 'not-agent.txt'), 'Not an agent');
|
||||
|
||||
const agents = discoverAgentsFromPath(join(testDir, 'not-agent.txt'));
|
||||
expect(agents).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* Agent Parser Tests
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
extractAgentFrontmatter,
|
||||
extractAgentContent,
|
||||
toCanonicalAgent,
|
||||
fromCanonicalAgent,
|
||||
validateAgent,
|
||||
} from '../parser.js';
|
||||
import type { CustomAgent, CanonicalAgent, AgentFrontmatter } from '../types.js';
|
||||
|
||||
describe('Agent Parser', () => {
|
||||
describe('extractAgentFrontmatter', () => {
|
||||
it('should extract valid YAML frontmatter', () => {
|
||||
const content = `---
|
||||
name: test-agent
|
||||
description: A test agent
|
||||
model: opus
|
||||
---
|
||||
|
||||
Agent content here.`;
|
||||
|
||||
const frontmatter = extractAgentFrontmatter(content);
|
||||
expect(frontmatter).not.toBeNull();
|
||||
expect(frontmatter?.name).toBe('test-agent');
|
||||
expect(frontmatter?.description).toBe('A test agent');
|
||||
expect(frontmatter?.model).toBe('opus');
|
||||
});
|
||||
|
||||
it('should return null for content without frontmatter', () => {
|
||||
const content = 'Just some content without frontmatter.';
|
||||
const frontmatter = extractAgentFrontmatter(content);
|
||||
expect(frontmatter).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for invalid YAML', () => {
|
||||
const content = `---
|
||||
name: test-agent
|
||||
invalid: yaml: structure: [broken
|
||||
---
|
||||
|
||||
Content here.`;
|
||||
|
||||
const frontmatter = extractAgentFrontmatter(content);
|
||||
expect(frontmatter).toBeNull();
|
||||
});
|
||||
|
||||
it('should extract complex frontmatter with arrays', () => {
|
||||
const content = `---
|
||||
name: security-reviewer
|
||||
description: Reviews code for security issues
|
||||
disallowedTools:
|
||||
- Bash
|
||||
- Write
|
||||
skills:
|
||||
- code-review
|
||||
- security
|
||||
---
|
||||
|
||||
Content here.`;
|
||||
|
||||
const frontmatter = extractAgentFrontmatter(content);
|
||||
expect(frontmatter?.name).toBe('security-reviewer');
|
||||
expect(frontmatter?.disallowedTools).toEqual(['Bash', 'Write']);
|
||||
expect(frontmatter?.skills).toEqual(['code-review', 'security']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('extractAgentContent', () => {
|
||||
it('should extract content after frontmatter', () => {
|
||||
const content = `---
|
||||
name: test-agent
|
||||
description: A test agent
|
||||
---
|
||||
|
||||
# Agent Instructions
|
||||
|
||||
This is the main content.`;
|
||||
|
||||
const extracted = extractAgentContent(content);
|
||||
expect(extracted).toBe('# Agent Instructions\n\nThis is the main content.');
|
||||
});
|
||||
|
||||
it('should return full content if no frontmatter', () => {
|
||||
const content = 'Just content without frontmatter.';
|
||||
const extracted = extractAgentContent(content);
|
||||
expect(extracted).toBe('Just content without frontmatter.');
|
||||
});
|
||||
|
||||
it('should handle empty content after frontmatter', () => {
|
||||
const content = `---
|
||||
name: test-agent
|
||||
description: Empty agent
|
||||
---`;
|
||||
|
||||
const extracted = extractAgentContent(content);
|
||||
expect(extracted).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('toCanonicalAgent', () => {
|
||||
it('should convert CustomAgent to CanonicalAgent', () => {
|
||||
const agent: CustomAgent = {
|
||||
name: 'test-agent',
|
||||
description: 'A test agent',
|
||||
path: '/path/to/agent.md',
|
||||
location: 'project',
|
||||
frontmatter: {
|
||||
name: 'test-agent',
|
||||
description: 'A test agent',
|
||||
model: 'opus',
|
||||
permissionMode: 'default',
|
||||
disallowedTools: ['Bash'],
|
||||
skills: ['testing'],
|
||||
} as AgentFrontmatter,
|
||||
content: 'Agent instructions here.',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
const canonical = toCanonicalAgent(agent);
|
||||
|
||||
expect(canonical.name).toBe('test-agent');
|
||||
expect(canonical.description).toBe('A test agent');
|
||||
expect(canonical.model).toBe('opus');
|
||||
expect(canonical.permissionMode).toBe('default');
|
||||
expect(canonical.disallowedTools).toEqual(['Bash']);
|
||||
expect(canonical.skills).toEqual(['testing']);
|
||||
expect(canonical.content).toBe('Agent instructions here.');
|
||||
expect(canonical.sourceFormat).toBe('claude-agent');
|
||||
});
|
||||
|
||||
it('should handle string allowedTools', () => {
|
||||
const agent: CustomAgent = {
|
||||
name: 'test-agent',
|
||||
description: 'Test',
|
||||
path: '/path',
|
||||
location: 'project',
|
||||
frontmatter: {
|
||||
name: 'test-agent',
|
||||
description: 'Test',
|
||||
allowedTools: 'Read, Glob, Grep',
|
||||
} as unknown as AgentFrontmatter,
|
||||
content: 'Content',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
const canonical = toCanonicalAgent(agent);
|
||||
expect(canonical.allowedTools).toEqual(['Read', 'Glob', 'Grep']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromCanonicalAgent', () => {
|
||||
it('should generate markdown from CanonicalAgent', () => {
|
||||
const canonical: CanonicalAgent = {
|
||||
name: 'test-agent',
|
||||
description: 'A test agent',
|
||||
model: 'opus',
|
||||
content: '# Test Agent\n\nInstructions here.',
|
||||
sourceFormat: 'claude-agent',
|
||||
};
|
||||
|
||||
const markdown = fromCanonicalAgent(canonical);
|
||||
|
||||
expect(markdown).toContain('---');
|
||||
expect(markdown).toContain('name: test-agent');
|
||||
expect(markdown).toContain('description: A test agent');
|
||||
expect(markdown).toContain('model: opus');
|
||||
expect(markdown).toContain('# Test Agent');
|
||||
});
|
||||
|
||||
it('should include optional fields when present', () => {
|
||||
const canonical: CanonicalAgent = {
|
||||
name: 'security-agent',
|
||||
description: 'Security reviewer',
|
||||
permissionMode: 'plan',
|
||||
disallowedTools: ['Bash', 'Write'],
|
||||
allowedTools: ['Read', 'Glob'],
|
||||
skills: ['security', 'review'],
|
||||
tags: ['security', 'code-review'],
|
||||
version: '1.0.0',
|
||||
author: 'test',
|
||||
content: 'Content here.',
|
||||
sourceFormat: 'claude-agent',
|
||||
};
|
||||
|
||||
const markdown = fromCanonicalAgent(canonical);
|
||||
|
||||
expect(markdown).toContain('permissionMode: plan');
|
||||
expect(markdown).toContain('disallowedTools:');
|
||||
expect(markdown).toContain(' - Bash');
|
||||
expect(markdown).toContain('allowed-tools:');
|
||||
expect(markdown).toContain('skills:');
|
||||
expect(markdown).toContain('tags: [security, code-review]');
|
||||
expect(markdown).toContain('version: "1.0.0"');
|
||||
expect(markdown).toContain('author: test');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* Agent Translator Tests
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
translateAgent,
|
||||
translateCanonicalAgent,
|
||||
getAgentFilename,
|
||||
getAgentTargetDirectory,
|
||||
isAgentCompatible,
|
||||
} from '../translator.js';
|
||||
import type { CustomAgent, CanonicalAgent, AgentFrontmatter } from '../types.js';
|
||||
|
||||
describe('Agent Translator', () => {
|
||||
describe('translateAgent', () => {
|
||||
it('should translate agent to claude-code format', () => {
|
||||
const agent: CustomAgent = {
|
||||
name: 'test-agent',
|
||||
description: 'A test agent',
|
||||
path: '/path/to/agent.md',
|
||||
location: 'project',
|
||||
frontmatter: {
|
||||
name: 'test-agent',
|
||||
description: 'A test agent',
|
||||
model: 'opus',
|
||||
} as AgentFrontmatter,
|
||||
content: 'Agent instructions here.',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
const result = translateAgent(agent, 'claude-code');
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.targetAgent).toBe('claude-code');
|
||||
expect(result.targetFormat).toBe('claude-agent');
|
||||
expect(result.content).toContain('name: test-agent');
|
||||
expect(result.content).toContain('model: opus');
|
||||
});
|
||||
|
||||
it('should translate agent to cursor format', () => {
|
||||
const agent: CustomAgent = {
|
||||
name: 'reviewer',
|
||||
description: 'Code reviewer',
|
||||
path: '/path/to/agent.md',
|
||||
location: 'project',
|
||||
frontmatter: {
|
||||
name: 'reviewer',
|
||||
description: 'Code reviewer',
|
||||
} as AgentFrontmatter,
|
||||
content: 'Review code carefully.',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
const result = translateAgent(agent, 'cursor');
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.targetAgent).toBe('cursor');
|
||||
expect(result.targetFormat).toBe('cursor-agent');
|
||||
expect(result.filename).toBe('reviewer.md');
|
||||
});
|
||||
|
||||
it('should add warnings for hooks in cursor format', () => {
|
||||
const agent: CustomAgent = {
|
||||
name: 'hooked-agent',
|
||||
description: 'Agent with hooks',
|
||||
path: '/path/to/agent.md',
|
||||
location: 'project',
|
||||
frontmatter: {
|
||||
name: 'hooked-agent',
|
||||
description: 'Agent with hooks',
|
||||
hooks: [
|
||||
{ type: 'PreToolUse', command: 'echo test' },
|
||||
],
|
||||
} as AgentFrontmatter,
|
||||
content: 'Content here.',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
const result = translateAgent(agent, 'cursor');
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.warnings).toContain('Hooks may require manual adjustment for Cursor');
|
||||
});
|
||||
|
||||
it('should add incompatible features for universal format', () => {
|
||||
const agent: CustomAgent = {
|
||||
name: 'complex-agent',
|
||||
description: 'Complex agent',
|
||||
path: '/path/to/agent.md',
|
||||
location: 'project',
|
||||
frontmatter: {
|
||||
name: 'complex-agent',
|
||||
description: 'Complex agent',
|
||||
permissionMode: 'plan',
|
||||
hooks: [
|
||||
{ type: 'SessionStart', command: 'echo start' },
|
||||
],
|
||||
} as AgentFrontmatter,
|
||||
content: 'Content here.',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
const result = translateAgent(agent, 'universal');
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.incompatible).toContain('hooks (not supported in universal format)');
|
||||
expect(result.incompatible).toContain('permissionMode (not supported in universal format)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('translateCanonicalAgent', () => {
|
||||
it('should translate canonical agent to different formats', () => {
|
||||
const canonical: CanonicalAgent = {
|
||||
name: 'test-agent',
|
||||
description: 'Test agent',
|
||||
model: 'sonnet',
|
||||
content: 'Agent content.',
|
||||
sourceFormat: 'claude-agent',
|
||||
};
|
||||
|
||||
const claudeResult = translateCanonicalAgent(canonical, 'claude-code');
|
||||
expect(claudeResult.success).toBe(true);
|
||||
expect(claudeResult.content).toContain('name: test-agent');
|
||||
|
||||
const cursorResult = translateCanonicalAgent(canonical, 'cursor');
|
||||
expect(cursorResult.success).toBe(true);
|
||||
expect(cursorResult.content).toContain('name: test-agent');
|
||||
|
||||
const universalResult = translateCanonicalAgent(canonical, 'universal');
|
||||
expect(universalResult.success).toBe(true);
|
||||
expect(universalResult.content).toContain('name: test-agent');
|
||||
});
|
||||
|
||||
it('should include metadata when option is set', () => {
|
||||
const canonical: CanonicalAgent = {
|
||||
name: 'test-agent',
|
||||
description: 'Test agent',
|
||||
content: 'Content.',
|
||||
sourceFormat: 'claude-agent',
|
||||
sourceAgent: 'cursor',
|
||||
};
|
||||
|
||||
const result = translateCanonicalAgent(canonical, 'claude-code', { addMetadata: true });
|
||||
|
||||
expect(result.content).toContain('# Translated by SkillKit from cursor');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAgentFilename', () => {
|
||||
it('should return correct filename for different agents', () => {
|
||||
expect(getAgentFilename('test-agent', 'claude-code')).toBe('test-agent.md');
|
||||
expect(getAgentFilename('reviewer', 'cursor')).toBe('reviewer.md');
|
||||
expect(getAgentFilename('my-agent', 'universal')).toBe('my-agent.md');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAgentTargetDirectory', () => {
|
||||
it('should return correct target directory', () => {
|
||||
const rootDir = '/home/user/project';
|
||||
|
||||
expect(getAgentTargetDirectory(rootDir, 'claude-code')).toBe('/home/user/project/.claude/agents');
|
||||
expect(getAgentTargetDirectory(rootDir, 'cursor')).toBe('/home/user/project/.cursor/agents');
|
||||
expect(getAgentTargetDirectory(rootDir, 'universal')).toBe('/home/user/project/agents');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isAgentCompatible', () => {
|
||||
it('should return compatible for same format', () => {
|
||||
const result = isAgentCompatible('claude-agent', 'claude-agent');
|
||||
expect(result.compatible).toBe(true);
|
||||
expect(result.warnings).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should return compatible for claude-agent target', () => {
|
||||
const result = isAgentCompatible('cursor-agent', 'claude-agent');
|
||||
expect(result.compatible).toBe(true);
|
||||
});
|
||||
|
||||
it('should add warnings for universal target from claude-agent', () => {
|
||||
const result = isAgentCompatible('claude-agent', 'universal');
|
||||
expect(result.compatible).toBe(true);
|
||||
expect(result.warnings.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should add warnings for cursor target from claude-agent', () => {
|
||||
const result = isAgentCompatible('claude-agent', 'cursor-agent');
|
||||
expect(result.compatible).toBe(true);
|
||||
expect(result.warnings.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,383 @@
|
||||
/**
|
||||
* Agent Discovery
|
||||
*
|
||||
* Discovers custom agent definitions across all supported locations.
|
||||
*/
|
||||
|
||||
import { existsSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join, extname } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import {
|
||||
ALL_AGENT_DISCOVERY_PATHS,
|
||||
AGENT_DISCOVERY_PATHS,
|
||||
type CustomAgent,
|
||||
type AgentLocation,
|
||||
} from './types.js';
|
||||
import { parseAgentFile, parseAgentDir } from './parser.js';
|
||||
import type { AgentType } from '../types.js';
|
||||
|
||||
/**
|
||||
* Discover agents in a specific directory
|
||||
*/
|
||||
function discoverAgentsInDir(
|
||||
dir: string,
|
||||
location: AgentLocation
|
||||
): CustomAgent[] {
|
||||
const agents: CustomAgent[] = [];
|
||||
|
||||
if (!existsSync(dir)) {
|
||||
return agents;
|
||||
}
|
||||
|
||||
try {
|
||||
const entries = readdirSync(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const entryPath = join(dir, entry.name);
|
||||
|
||||
if (entry.isFile() && extname(entry.name) === '.md') {
|
||||
// Parse markdown file directly
|
||||
const agent = parseAgentFile(entryPath, location);
|
||||
if (agent) {
|
||||
agents.push(agent);
|
||||
}
|
||||
} else if (entry.isDirectory()) {
|
||||
// Parse directory with AGENT.md inside
|
||||
const agent = parseAgentDir(entryPath, location);
|
||||
if (agent) {
|
||||
agents.push(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors (permission denied, etc.)
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover all agents in a project directory
|
||||
*/
|
||||
export function discoverAgents(rootDir: string): CustomAgent[] {
|
||||
const agents: CustomAgent[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
// Search all standard paths
|
||||
for (const searchPath of ALL_AGENT_DISCOVERY_PATHS) {
|
||||
const fullPath = join(rootDir, searchPath);
|
||||
if (existsSync(fullPath)) {
|
||||
for (const agent of discoverAgentsInDir(fullPath, 'project')) {
|
||||
if (!seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover agents for a specific AI coding agent
|
||||
*/
|
||||
export function discoverAgentsForAgent(
|
||||
rootDir: string,
|
||||
agentType: AgentType
|
||||
): CustomAgent[] {
|
||||
const agents: CustomAgent[] = [];
|
||||
const seen = new Set<string>();
|
||||
const paths = AGENT_DISCOVERY_PATHS[agentType] || [];
|
||||
|
||||
for (const searchPath of paths) {
|
||||
const fullPath = join(rootDir, searchPath);
|
||||
if (existsSync(fullPath)) {
|
||||
for (const agent of discoverAgentsInDir(fullPath, 'project')) {
|
||||
if (!seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover global agents (in ~/.claude/agents, etc.)
|
||||
*/
|
||||
export function discoverGlobalAgents(): CustomAgent[] {
|
||||
const agents: CustomAgent[] = [];
|
||||
const seen = new Set<string>();
|
||||
const home = homedir();
|
||||
|
||||
// Global agent paths
|
||||
const globalPaths = [
|
||||
join(home, '.claude', 'agents'),
|
||||
join(home, '.skillkit', 'agents'),
|
||||
join(home, '.config', 'skillkit', 'agents'),
|
||||
];
|
||||
|
||||
for (const searchPath of globalPaths) {
|
||||
if (existsSync(searchPath)) {
|
||||
for (const agent of discoverAgentsInDir(searchPath, 'global')) {
|
||||
if (!seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all agents (project + global)
|
||||
*/
|
||||
export function findAllAgents(searchDirs: string[]): CustomAgent[] {
|
||||
const agents: CustomAgent[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
// Search provided directories
|
||||
for (const dir of searchDirs) {
|
||||
if (!existsSync(dir)) continue;
|
||||
|
||||
const discovered = discoverAgents(dir);
|
||||
for (const agent of discovered) {
|
||||
if (!seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add global agents
|
||||
for (const agent of discoverGlobalAgents()) {
|
||||
if (!seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
}
|
||||
}
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a specific agent by name
|
||||
*/
|
||||
export function findAgent(
|
||||
name: string,
|
||||
searchDirs: string[]
|
||||
): CustomAgent | null {
|
||||
// Search in provided directories first
|
||||
for (const dir of searchDirs) {
|
||||
if (!existsSync(dir)) continue;
|
||||
|
||||
// Check all discovery paths
|
||||
for (const searchPath of ALL_AGENT_DISCOVERY_PATHS) {
|
||||
const agentsDir = join(dir, searchPath);
|
||||
if (!existsSync(agentsDir)) continue;
|
||||
|
||||
// Try as file
|
||||
const agentFile = join(agentsDir, `${name}.md`);
|
||||
if (existsSync(agentFile)) {
|
||||
return parseAgentFile(agentFile, 'project');
|
||||
}
|
||||
|
||||
// Try as directory
|
||||
const agentDir = join(agentsDir, name);
|
||||
if (existsSync(agentDir) && statSync(agentDir).isDirectory()) {
|
||||
return parseAgentDir(agentDir, 'project');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check global agents
|
||||
const home = homedir();
|
||||
const globalPaths = [
|
||||
join(home, '.claude', 'agents'),
|
||||
join(home, '.skillkit', 'agents'),
|
||||
];
|
||||
|
||||
for (const agentsDir of globalPaths) {
|
||||
if (!existsSync(agentsDir)) continue;
|
||||
|
||||
const agentFile = join(agentsDir, `${name}.md`);
|
||||
if (existsSync(agentFile)) {
|
||||
return parseAgentFile(agentFile, 'global');
|
||||
}
|
||||
|
||||
const agentDir = join(agentsDir, name);
|
||||
if (existsSync(agentDir) && statSync(agentDir).isDirectory()) {
|
||||
return parseAgentDir(agentDir, 'global');
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the agents directory for a specific AI coding agent
|
||||
*/
|
||||
export function getAgentsDirectory(
|
||||
rootDir: string,
|
||||
agentType: AgentType
|
||||
): string {
|
||||
const paths = AGENT_DISCOVERY_PATHS[agentType];
|
||||
if (paths && paths.length > 0) {
|
||||
return join(rootDir, paths[0]);
|
||||
}
|
||||
return join(rootDir, 'agents');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an agent exists
|
||||
*/
|
||||
export function agentExists(
|
||||
name: string,
|
||||
searchDirs: string[]
|
||||
): boolean {
|
||||
return findAgent(name, searchDirs) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent count statistics
|
||||
*/
|
||||
export function getAgentStats(searchDirs: string[]): {
|
||||
total: number;
|
||||
project: number;
|
||||
global: number;
|
||||
enabled: number;
|
||||
disabled: number;
|
||||
} {
|
||||
const allAgents = findAllAgents(searchDirs);
|
||||
|
||||
return {
|
||||
total: allAgents.length,
|
||||
project: allAgents.filter(a => a.location === 'project').length,
|
||||
global: allAgents.filter(a => a.location === 'global').length,
|
||||
enabled: allAgents.filter(a => a.enabled).length,
|
||||
disabled: allAgents.filter(a => !a.enabled).length,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively discover all agents in a directory tree
|
||||
* This finds agents at any depth, useful for batch translation
|
||||
*/
|
||||
export function discoverAgentsRecursive(
|
||||
rootDir: string,
|
||||
location: AgentLocation = 'project'
|
||||
): CustomAgent[] {
|
||||
const agents: CustomAgent[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
if (!existsSync(rootDir)) {
|
||||
return agents;
|
||||
}
|
||||
|
||||
function scanDirectory(dir: string): void {
|
||||
try {
|
||||
const entries = readdirSync(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const entryPath = join(dir, entry.name);
|
||||
|
||||
if (entry.isFile() && extname(entry.name) === '.md') {
|
||||
// Parse markdown file directly
|
||||
const agent = parseAgentFile(entryPath, location);
|
||||
if (agent && !seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
}
|
||||
} else if (entry.isDirectory()) {
|
||||
// Skip hidden directories except standard agent paths
|
||||
if (entry.name.startsWith('.') && !entry.name.startsWith('.claude') &&
|
||||
!entry.name.startsWith('.cursor') && !entry.name.startsWith('.codex')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to parse as agent directory first
|
||||
const agent = parseAgentDir(entryPath, location);
|
||||
if (agent && !seen.has(agent.name)) {
|
||||
seen.add(agent.name);
|
||||
agents.push(agent);
|
||||
} else {
|
||||
// If not an agent directory, recurse into it
|
||||
scanDirectory(entryPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors (permission denied, etc.)
|
||||
}
|
||||
}
|
||||
|
||||
scanDirectory(rootDir);
|
||||
return agents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover agents from a custom source path
|
||||
* Handles both file paths and directories
|
||||
*/
|
||||
export function discoverAgentsFromPath(
|
||||
sourcePath: string,
|
||||
recursive: boolean = false,
|
||||
location: AgentLocation = 'project'
|
||||
): CustomAgent[] {
|
||||
if (!existsSync(sourcePath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const stats = statSync(sourcePath);
|
||||
|
||||
// Single file
|
||||
if (stats.isFile()) {
|
||||
if (extname(sourcePath) === '.md') {
|
||||
const agent = parseAgentFile(sourcePath, location);
|
||||
return agent ? [agent] : [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// Directory
|
||||
if (stats.isDirectory()) {
|
||||
if (recursive) {
|
||||
return discoverAgentsRecursive(sourcePath, location);
|
||||
}
|
||||
|
||||
// Non-recursive: only check immediate directory
|
||||
// First try as agent directory
|
||||
const agent = parseAgentDir(sourcePath, location);
|
||||
if (agent) {
|
||||
return [agent];
|
||||
}
|
||||
|
||||
// Otherwise scan directory contents (one level)
|
||||
const agents: CustomAgent[] = [];
|
||||
try {
|
||||
const entries = readdirSync(sourcePath, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const entryPath = join(sourcePath, entry.name);
|
||||
|
||||
if (entry.isFile() && extname(entry.name) === '.md') {
|
||||
const a = parseAgentFile(entryPath, location);
|
||||
if (a) agents.push(a);
|
||||
} else if (entry.isDirectory()) {
|
||||
const a = parseAgentDir(entryPath, location);
|
||||
if (a) agents.push(a);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore errors
|
||||
}
|
||||
return agents;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Agent Module
|
||||
*
|
||||
* Custom AI sub-agent management for SkillKit.
|
||||
* Supports discovery, parsing, and translation of agents
|
||||
* between different AI coding agent formats.
|
||||
*/
|
||||
|
||||
// Types
|
||||
export {
|
||||
AgentPermissionMode,
|
||||
AgentHook,
|
||||
AgentFrontmatter,
|
||||
AgentLocation,
|
||||
AgentMetadata,
|
||||
AGENT_DISCOVERY_PATHS,
|
||||
ALL_AGENT_DISCOVERY_PATHS,
|
||||
CUSTOM_AGENT_FORMAT_MAP,
|
||||
type CustomAgent,
|
||||
type CanonicalAgent,
|
||||
type AgentFormatCategory,
|
||||
type AgentTranslationResult,
|
||||
type AgentTranslationOptions,
|
||||
} from './types.js';
|
||||
|
||||
// Parser
|
||||
export {
|
||||
extractAgentFrontmatter,
|
||||
extractAgentContent,
|
||||
parseAgentFile,
|
||||
parseAgentDir,
|
||||
loadAgentMetadata,
|
||||
toCanonicalAgent,
|
||||
fromCanonicalAgent,
|
||||
readAgentContent,
|
||||
validateAgent,
|
||||
} from './parser.js';
|
||||
|
||||
// Discovery
|
||||
export {
|
||||
discoverAgents,
|
||||
discoverAgentsForAgent,
|
||||
discoverGlobalAgents,
|
||||
discoverAgentsRecursive,
|
||||
discoverAgentsFromPath,
|
||||
findAllAgents,
|
||||
findAgent,
|
||||
getAgentsDirectory,
|
||||
agentExists,
|
||||
getAgentStats,
|
||||
} from './discovery.js';
|
||||
|
||||
// Translator
|
||||
export {
|
||||
translateAgent,
|
||||
translateCanonicalAgent,
|
||||
translateAgentContent,
|
||||
translateAgents,
|
||||
getAgentFilename,
|
||||
getAgentTargetDirectory,
|
||||
isAgentCompatible,
|
||||
} from './translator.js';
|
||||
@@ -0,0 +1,418 @@
|
||||
/**
|
||||
* Agent Parser
|
||||
*
|
||||
* Parses agent definition files (e.g., .claude/agents/*.md)
|
||||
*/
|
||||
|
||||
import { existsSync, readFileSync, statSync } from 'node:fs';
|
||||
import { join, basename, extname } from 'node:path';
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
import {
|
||||
AgentFrontmatter,
|
||||
AgentMetadata,
|
||||
type CustomAgent,
|
||||
type AgentLocation,
|
||||
type CanonicalAgent,
|
||||
type AgentFormatCategory,
|
||||
} from './types.js';
|
||||
import type { AgentType } from '../types.js';
|
||||
|
||||
/**
|
||||
* Extract YAML frontmatter from markdown content
|
||||
*/
|
||||
export function extractAgentFrontmatter(content: string): Record<string, unknown> | null {
|
||||
const match = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
||||
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return parseYaml(match[1]) as Record<string, unknown>;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract content after frontmatter
|
||||
*/
|
||||
export function extractAgentContent(content: string): string {
|
||||
const withoutFrontmatter = content.replace(/^---\s*\n[\s\S]*?\n---\s*\n?/, '');
|
||||
return withoutFrontmatter.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an agent file (.md)
|
||||
*/
|
||||
export function parseAgentFile(
|
||||
filePath: string,
|
||||
location: AgentLocation = 'project'
|
||||
): CustomAgent | null {
|
||||
if (!existsSync(filePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Only parse .md files
|
||||
if (extname(filePath) !== '.md') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(filePath, 'utf-8');
|
||||
const rawFrontmatter = extractAgentFrontmatter(content);
|
||||
const agentContent = extractAgentContent(content);
|
||||
|
||||
// If no frontmatter, use filename as name
|
||||
if (!rawFrontmatter) {
|
||||
const name = basename(filePath, '.md');
|
||||
return {
|
||||
name,
|
||||
description: 'No description available',
|
||||
path: filePath,
|
||||
location,
|
||||
frontmatter: {
|
||||
name,
|
||||
description: 'No description available',
|
||||
},
|
||||
content: agentContent,
|
||||
enabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Parse frontmatter with validation
|
||||
const parsed = AgentFrontmatter.safeParse(rawFrontmatter);
|
||||
|
||||
if (!parsed.success) {
|
||||
// Fallback to basic parsing
|
||||
const name = (rawFrontmatter.name as string) || basename(filePath, '.md');
|
||||
return {
|
||||
name,
|
||||
description: (rawFrontmatter.description as string) || 'No description available',
|
||||
path: filePath,
|
||||
location,
|
||||
frontmatter: {
|
||||
name,
|
||||
description: (rawFrontmatter.description as string) || 'No description available',
|
||||
...rawFrontmatter,
|
||||
} as AgentFrontmatter,
|
||||
content: agentContent,
|
||||
enabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Load metadata if exists
|
||||
const metadataPath = filePath.replace(/\.md$/, '.skillkit-agent.json');
|
||||
const metadata = loadAgentMetadata(metadataPath);
|
||||
|
||||
return {
|
||||
name: parsed.data.name,
|
||||
description: parsed.data.description,
|
||||
path: filePath,
|
||||
location,
|
||||
frontmatter: parsed.data,
|
||||
content: agentContent,
|
||||
metadata: metadata ?? undefined,
|
||||
enabled: metadata?.enabled ?? true,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an agent from a directory (containing AGENT.md)
|
||||
*/
|
||||
export function parseAgentDir(
|
||||
dirPath: string,
|
||||
location: AgentLocation = 'project'
|
||||
): CustomAgent | null {
|
||||
const agentMdPath = join(dirPath, 'AGENT.md');
|
||||
|
||||
if (existsSync(agentMdPath)) {
|
||||
const agent = parseAgentFile(agentMdPath, location);
|
||||
if (agent) {
|
||||
// Update path to directory
|
||||
agent.path = dirPath;
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
|
||||
// Try index.md
|
||||
const indexMdPath = join(dirPath, 'index.md');
|
||||
if (existsSync(indexMdPath)) {
|
||||
const agent = parseAgentFile(indexMdPath, location);
|
||||
if (agent) {
|
||||
agent.path = dirPath;
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load agent metadata from JSON file
|
||||
*/
|
||||
export function loadAgentMetadata(metadataPath: string): AgentMetadata | null {
|
||||
if (!existsSync(metadataPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(metadataPath, 'utf-8');
|
||||
const data = JSON.parse(content);
|
||||
const parsed = AgentMetadata.safeParse(data);
|
||||
|
||||
return parsed.success ? parsed.data : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert parsed agent to canonical format for translation
|
||||
*/
|
||||
export function toCanonicalAgent(
|
||||
agent: CustomAgent,
|
||||
sourceAgent?: AgentType
|
||||
): CanonicalAgent {
|
||||
const fm = agent.frontmatter;
|
||||
|
||||
// Handle allowed-tools (can be string or array)
|
||||
let allowedTools: string[] | undefined;
|
||||
if (fm.allowedTools) {
|
||||
if (typeof fm.allowedTools === 'string') {
|
||||
// Parse YAML-style list
|
||||
allowedTools = fm.allowedTools.split(/[,\n]/).map(t => t.trim()).filter(Boolean);
|
||||
} else {
|
||||
allowedTools = fm.allowedTools;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name: agent.name,
|
||||
description: agent.description,
|
||||
model: fm.model,
|
||||
permissionMode: fm.permissionMode,
|
||||
disallowedTools: fm.disallowedTools,
|
||||
allowedTools,
|
||||
hooks: fm.hooks,
|
||||
skills: fm.skills,
|
||||
context: fm.context,
|
||||
version: fm.version,
|
||||
author: fm.author,
|
||||
tags: fm.tags,
|
||||
userInvocable: fm['user-invocable'],
|
||||
argumentHint: fm['argument-hint'],
|
||||
content: agent.content,
|
||||
sourceFormat: 'claude-agent',
|
||||
sourceAgent,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate agent markdown from canonical format
|
||||
*/
|
||||
export function fromCanonicalAgent(
|
||||
canonical: CanonicalAgent,
|
||||
_targetFormat: AgentFormatCategory = 'claude-agent'
|
||||
): string {
|
||||
// Note: _targetFormat reserved for format-specific output in future
|
||||
const lines: string[] = [];
|
||||
|
||||
// Generate frontmatter
|
||||
lines.push('---');
|
||||
lines.push(`name: ${canonical.name}`);
|
||||
lines.push(`description: ${canonical.description}`);
|
||||
|
||||
if (canonical.model) {
|
||||
lines.push(`model: ${canonical.model}`);
|
||||
}
|
||||
|
||||
if (canonical.permissionMode) {
|
||||
lines.push(`permissionMode: ${canonical.permissionMode}`);
|
||||
}
|
||||
|
||||
if (canonical.disallowedTools && canonical.disallowedTools.length > 0) {
|
||||
lines.push('disallowedTools:');
|
||||
for (const tool of canonical.disallowedTools) {
|
||||
lines.push(` - ${tool}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.allowedTools && canonical.allowedTools.length > 0) {
|
||||
lines.push('allowed-tools:');
|
||||
for (const tool of canonical.allowedTools) {
|
||||
lines.push(` - ${tool}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.hooks && canonical.hooks.length > 0) {
|
||||
lines.push('hooks:');
|
||||
for (const hook of canonical.hooks) {
|
||||
lines.push(` - type: ${hook.type}`);
|
||||
lines.push(` command: ${hook.command}`);
|
||||
if (hook.timeout) lines.push(` timeout: ${hook.timeout}`);
|
||||
if (hook.once) lines.push(` once: ${hook.once}`);
|
||||
if (hook.matcher) lines.push(` matcher: ${hook.matcher}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.skills && canonical.skills.length > 0) {
|
||||
lines.push('skills:');
|
||||
for (const skill of canonical.skills) {
|
||||
lines.push(` - ${skill}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.context) {
|
||||
lines.push(`context: ${canonical.context}`);
|
||||
}
|
||||
|
||||
if (canonical.version) {
|
||||
lines.push(`version: "${canonical.version}"`);
|
||||
}
|
||||
|
||||
if (canonical.author) {
|
||||
lines.push(`author: ${canonical.author}`);
|
||||
}
|
||||
|
||||
if (canonical.tags && canonical.tags.length > 0) {
|
||||
lines.push(`tags: [${canonical.tags.join(', ')}]`);
|
||||
}
|
||||
|
||||
if (canonical.userInvocable !== undefined) {
|
||||
lines.push(`user-invocable: ${canonical.userInvocable}`);
|
||||
}
|
||||
|
||||
if (canonical.argumentHint) {
|
||||
lines.push(`argument-hint: "${canonical.argumentHint}"`);
|
||||
}
|
||||
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
|
||||
// Add content
|
||||
lines.push(canonical.content);
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Read raw agent content
|
||||
*/
|
||||
export function readAgentContent(agentPath: string): string | null {
|
||||
// If it's a file
|
||||
if (existsSync(agentPath) && extname(agentPath) === '.md') {
|
||||
try {
|
||||
return readFileSync(agentPath, 'utf-8');
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// If it's a directory
|
||||
const agentMdPath = join(agentPath, 'AGENT.md');
|
||||
if (existsSync(agentMdPath)) {
|
||||
try {
|
||||
return readFileSync(agentMdPath, 'utf-8');
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Try index.md
|
||||
const indexMdPath = join(agentPath, 'index.md');
|
||||
if (existsSync(indexMdPath)) {
|
||||
try {
|
||||
return readFileSync(indexMdPath, 'utf-8');
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate an agent file
|
||||
*/
|
||||
export function validateAgent(
|
||||
agentPath: string
|
||||
): { valid: boolean; errors: string[]; warnings: string[] } {
|
||||
const errors: string[] = [];
|
||||
const warnings: string[] = [];
|
||||
|
||||
// Check file exists
|
||||
let filePath = agentPath;
|
||||
if (!existsSync(agentPath)) {
|
||||
errors.push(`Agent file not found: ${agentPath}`);
|
||||
return { valid: false, errors, warnings };
|
||||
}
|
||||
|
||||
// If directory, look for AGENT.md
|
||||
const stats = statSync(agentPath);
|
||||
if (stats.isDirectory()) {
|
||||
const agentMd = join(agentPath, 'AGENT.md');
|
||||
const indexMd = join(agentPath, 'index.md');
|
||||
if (existsSync(agentMd)) {
|
||||
filePath = agentMd;
|
||||
} else if (existsSync(indexMd)) {
|
||||
filePath = indexMd;
|
||||
} else {
|
||||
errors.push('Directory must contain AGENT.md or index.md');
|
||||
return { valid: false, errors, warnings };
|
||||
}
|
||||
}
|
||||
|
||||
// Read content
|
||||
let content: string;
|
||||
try {
|
||||
content = readFileSync(filePath, 'utf-8');
|
||||
} catch {
|
||||
errors.push(`Cannot read file: ${filePath}`);
|
||||
return { valid: false, errors, warnings };
|
||||
}
|
||||
|
||||
// Check frontmatter
|
||||
const frontmatter = extractAgentFrontmatter(content);
|
||||
if (!frontmatter) {
|
||||
errors.push('Missing YAML frontmatter');
|
||||
return { valid: false, errors, warnings };
|
||||
}
|
||||
|
||||
// Validate frontmatter
|
||||
const parsed = AgentFrontmatter.safeParse(frontmatter);
|
||||
if (!parsed.success) {
|
||||
for (const issue of parsed.error.issues) {
|
||||
errors.push(`${issue.path.join('.') || 'frontmatter'}: ${issue.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Warnings
|
||||
if (parsed.success) {
|
||||
const data = parsed.data;
|
||||
const fileName = basename(filePath, '.md');
|
||||
|
||||
if (data.name !== fileName && fileName !== 'AGENT' && fileName !== 'index') {
|
||||
warnings.push(`name "${data.name}" does not match filename "${fileName}"`);
|
||||
}
|
||||
|
||||
if (data.description && data.description.length < 20) {
|
||||
warnings.push('description is short; consider adding more detail');
|
||||
}
|
||||
|
||||
if (data.permissionMode === 'full-auto' || data.permissionMode === 'bypassPermissions') {
|
||||
warnings.push(`permissionMode "${data.permissionMode}" is potentially dangerous`);
|
||||
}
|
||||
}
|
||||
|
||||
// Check content
|
||||
const agentContent = extractAgentContent(content);
|
||||
if (agentContent.length < 50) {
|
||||
warnings.push('Agent system prompt is very short');
|
||||
}
|
||||
|
||||
return { valid: errors.length === 0, errors, warnings };
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
/**
|
||||
* Agent Translator
|
||||
*
|
||||
* Translates agent definitions between different AI coding agent formats.
|
||||
*/
|
||||
|
||||
import {
|
||||
type CanonicalAgent,
|
||||
type AgentFormatCategory,
|
||||
type AgentTranslationResult,
|
||||
type AgentTranslationOptions,
|
||||
type CustomAgent,
|
||||
CUSTOM_AGENT_FORMAT_MAP,
|
||||
AGENT_DISCOVERY_PATHS,
|
||||
AgentFrontmatter,
|
||||
} from './types.js';
|
||||
import {
|
||||
toCanonicalAgent,
|
||||
fromCanonicalAgent,
|
||||
extractAgentFrontmatter,
|
||||
extractAgentContent,
|
||||
} from './parser.js';
|
||||
import type { AgentType } from '../types.js';
|
||||
import { join } from 'node:path';
|
||||
|
||||
/**
|
||||
* Translate an agent to a target AI coding agent format
|
||||
*/
|
||||
export function translateAgent(
|
||||
agent: CustomAgent,
|
||||
targetAgent: AgentType,
|
||||
options?: AgentTranslationOptions
|
||||
): AgentTranslationResult {
|
||||
const canonical = toCanonicalAgent(agent);
|
||||
return translateCanonicalAgent(canonical, targetAgent, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a canonical agent to a target format
|
||||
*/
|
||||
export function translateCanonicalAgent(
|
||||
canonical: CanonicalAgent,
|
||||
targetAgent: AgentType,
|
||||
options?: AgentTranslationOptions
|
||||
): AgentTranslationResult {
|
||||
const targetFormat = CUSTOM_AGENT_FORMAT_MAP[targetAgent];
|
||||
const warnings: string[] = [];
|
||||
const incompatible: string[] = [];
|
||||
|
||||
// Track incompatible features
|
||||
if (targetFormat === 'universal') {
|
||||
// Universal format has limited support
|
||||
if (canonical.hooks && canonical.hooks.length > 0) {
|
||||
incompatible.push('hooks (not supported in universal format)');
|
||||
}
|
||||
if (canonical.permissionMode) {
|
||||
incompatible.push('permissionMode (not supported in universal format)');
|
||||
}
|
||||
}
|
||||
|
||||
if (targetFormat === 'cursor-agent') {
|
||||
// Cursor may have different hook syntax
|
||||
if (canonical.hooks && canonical.hooks.length > 0) {
|
||||
warnings.push('Hooks may require manual adjustment for Cursor');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate content based on target format
|
||||
let content: string;
|
||||
|
||||
switch (targetFormat) {
|
||||
case 'claude-agent':
|
||||
content = generateClaudeAgent(canonical, options);
|
||||
break;
|
||||
case 'cursor-agent':
|
||||
content = generateCursorAgent(canonical, options);
|
||||
break;
|
||||
case 'universal':
|
||||
content = generateUniversalAgent(canonical, options);
|
||||
break;
|
||||
default:
|
||||
content = fromCanonicalAgent(canonical, targetFormat);
|
||||
}
|
||||
|
||||
// Determine filename
|
||||
const filename = options?.outputFilename || getAgentFilename(canonical.name, targetAgent);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
content,
|
||||
filename,
|
||||
warnings,
|
||||
incompatible,
|
||||
targetFormat,
|
||||
targetAgent,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate agent content directly
|
||||
*/
|
||||
export function translateAgentContent(
|
||||
content: string,
|
||||
_sourceAgent: AgentType,
|
||||
targetAgent: AgentType,
|
||||
options?: AgentTranslationOptions
|
||||
): AgentTranslationResult {
|
||||
// Note: _sourceAgent reserved for future format-specific parsing
|
||||
const agent = parseAgentFromContent(content);
|
||||
|
||||
if (!agent) {
|
||||
return {
|
||||
success: false,
|
||||
content: '',
|
||||
filename: '',
|
||||
warnings: ['Failed to parse agent content'],
|
||||
incompatible: [],
|
||||
targetFormat: CUSTOM_AGENT_FORMAT_MAP[targetAgent],
|
||||
targetAgent,
|
||||
};
|
||||
}
|
||||
|
||||
return translateAgent(agent, targetAgent, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse agent from raw content
|
||||
*/
|
||||
function parseAgentFromContent(content: string): CustomAgent | null {
|
||||
const rawFrontmatter = extractAgentFrontmatter(content);
|
||||
const agentContent = extractAgentContent(content);
|
||||
|
||||
if (!rawFrontmatter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parsed = AgentFrontmatter.safeParse(rawFrontmatter);
|
||||
const frontmatter = parsed.success ? parsed.data : {
|
||||
name: (rawFrontmatter.name as string) || 'unnamed-agent',
|
||||
description: (rawFrontmatter.description as string) || 'No description',
|
||||
...rawFrontmatter,
|
||||
};
|
||||
|
||||
return {
|
||||
name: frontmatter.name,
|
||||
description: frontmatter.description,
|
||||
path: '',
|
||||
location: 'project',
|
||||
frontmatter,
|
||||
content: agentContent,
|
||||
enabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Claude Code agent format
|
||||
*/
|
||||
function generateClaudeAgent(
|
||||
canonical: CanonicalAgent,
|
||||
options?: AgentTranslationOptions
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Frontmatter
|
||||
lines.push('---');
|
||||
lines.push(`name: ${canonical.name}`);
|
||||
lines.push(`description: ${escapeYamlString(canonical.description)}`);
|
||||
|
||||
if (canonical.model) {
|
||||
lines.push(`model: ${canonical.model}`);
|
||||
}
|
||||
|
||||
if (canonical.permissionMode) {
|
||||
lines.push(`permissionMode: ${canonical.permissionMode}`);
|
||||
}
|
||||
|
||||
if (canonical.disallowedTools && canonical.disallowedTools.length > 0) {
|
||||
lines.push('disallowedTools:');
|
||||
for (const tool of canonical.disallowedTools) {
|
||||
lines.push(` - ${tool}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.allowedTools && canonical.allowedTools.length > 0) {
|
||||
lines.push('allowed-tools:');
|
||||
for (const tool of canonical.allowedTools) {
|
||||
lines.push(` - ${tool}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.hooks && canonical.hooks.length > 0) {
|
||||
lines.push('hooks:');
|
||||
for (const hook of canonical.hooks) {
|
||||
lines.push(` - type: ${hook.type}`);
|
||||
lines.push(` command: "${escapeYamlString(hook.command)}"`);
|
||||
if (hook.timeout) lines.push(` timeout: ${hook.timeout}`);
|
||||
if (hook.once) lines.push(` once: true`);
|
||||
if (hook.matcher) lines.push(` matcher: "${hook.matcher}"`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.skills && canonical.skills.length > 0) {
|
||||
lines.push('skills:');
|
||||
for (const skill of canonical.skills) {
|
||||
lines.push(` - ${skill}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (canonical.context) {
|
||||
lines.push(`context: ${canonical.context}`);
|
||||
}
|
||||
|
||||
if (canonical.version) {
|
||||
lines.push(`version: "${canonical.version}"`);
|
||||
}
|
||||
|
||||
if (canonical.author) {
|
||||
lines.push(`author: ${canonical.author}`);
|
||||
}
|
||||
|
||||
if (canonical.tags && canonical.tags.length > 0) {
|
||||
lines.push(`tags: [${canonical.tags.join(', ')}]`);
|
||||
}
|
||||
|
||||
if (canonical.userInvocable !== undefined) {
|
||||
lines.push(`user-invocable: ${canonical.userInvocable}`);
|
||||
}
|
||||
|
||||
if (canonical.argumentHint) {
|
||||
lines.push(`argument-hint: "${escapeYamlString(canonical.argumentHint)}"`);
|
||||
}
|
||||
|
||||
if (options?.addMetadata) {
|
||||
lines.push(`# Translated by SkillKit from ${canonical.sourceAgent || 'unknown'}`);
|
||||
}
|
||||
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
|
||||
// Content
|
||||
lines.push(canonical.content);
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Cursor agent format
|
||||
*/
|
||||
function generateCursorAgent(
|
||||
canonical: CanonicalAgent,
|
||||
options?: AgentTranslationOptions
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Cursor uses .mdc format for rules, but agents might be markdown
|
||||
lines.push('---');
|
||||
lines.push(`name: ${canonical.name}`);
|
||||
lines.push(`description: ${escapeYamlString(canonical.description)}`);
|
||||
|
||||
if (canonical.model) {
|
||||
lines.push(`model: ${canonical.model}`);
|
||||
}
|
||||
|
||||
// Cursor-specific: may use different permission syntax
|
||||
if (canonical.allowedTools && canonical.allowedTools.length > 0) {
|
||||
lines.push(`tools: [${canonical.allowedTools.join(', ')}]`);
|
||||
}
|
||||
|
||||
if (canonical.version) {
|
||||
lines.push(`version: "${canonical.version}"`);
|
||||
}
|
||||
|
||||
if (canonical.tags && canonical.tags.length > 0) {
|
||||
lines.push(`tags: [${canonical.tags.join(', ')}]`);
|
||||
}
|
||||
|
||||
if (options?.addMetadata) {
|
||||
lines.push(`# Translated by SkillKit from ${canonical.sourceAgent || 'unknown'}`);
|
||||
}
|
||||
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
|
||||
// Content
|
||||
lines.push(canonical.content);
|
||||
|
||||
// Add note about incompatible features
|
||||
if (canonical.hooks && canonical.hooks.length > 0) {
|
||||
lines.push('');
|
||||
lines.push('<!-- Note: Hooks from original agent may need manual configuration -->');
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate universal agent format
|
||||
*/
|
||||
function generateUniversalAgent(
|
||||
canonical: CanonicalAgent,
|
||||
options?: AgentTranslationOptions
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Universal format: simplified, portable
|
||||
lines.push('---');
|
||||
lines.push(`name: ${canonical.name}`);
|
||||
lines.push(`description: ${escapeYamlString(canonical.description)}`);
|
||||
|
||||
if (canonical.model) {
|
||||
lines.push(`model: ${canonical.model}`);
|
||||
}
|
||||
|
||||
if (canonical.version) {
|
||||
lines.push(`version: "${canonical.version}"`);
|
||||
}
|
||||
|
||||
if (canonical.author) {
|
||||
lines.push(`author: ${canonical.author}`);
|
||||
}
|
||||
|
||||
if (canonical.tags && canonical.tags.length > 0) {
|
||||
lines.push(`tags: [${canonical.tags.join(', ')}]`);
|
||||
}
|
||||
|
||||
if (options?.addMetadata) {
|
||||
lines.push(`# Translated by SkillKit`);
|
||||
if (canonical.sourceAgent) {
|
||||
lines.push(`# Original format: ${canonical.sourceAgent}`);
|
||||
}
|
||||
}
|
||||
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
|
||||
// Content
|
||||
lines.push(`# ${canonical.name}`);
|
||||
lines.push('');
|
||||
lines.push(canonical.content);
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expected filename for an agent
|
||||
*/
|
||||
export function getAgentFilename(
|
||||
agentName: string,
|
||||
targetAgent: AgentType
|
||||
): string {
|
||||
const format = CUSTOM_AGENT_FORMAT_MAP[targetAgent];
|
||||
|
||||
switch (format) {
|
||||
case 'cursor-agent':
|
||||
return `${agentName}.md`; // Or .mdc if Cursor uses that for agents
|
||||
default:
|
||||
return `${agentName}.md`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target directory for an agent
|
||||
*/
|
||||
export function getAgentTargetDirectory(
|
||||
rootDir: string,
|
||||
targetAgent: AgentType
|
||||
): string {
|
||||
const paths = AGENT_DISCOVERY_PATHS[targetAgent];
|
||||
if (paths && paths.length > 0) {
|
||||
return join(rootDir, paths[0]);
|
||||
}
|
||||
return join(rootDir, 'agents');
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape special characters in YAML strings
|
||||
*/
|
||||
function escapeYamlString(str: string): string {
|
||||
if (/[:\{\}\[\],&*#?|\-<>=!%@`]/.test(str) || str.includes('\n')) {
|
||||
return `"${str.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate multiple agents
|
||||
*/
|
||||
export function translateAgents(
|
||||
agents: CustomAgent[],
|
||||
targetAgent: AgentType,
|
||||
options?: AgentTranslationOptions
|
||||
): AgentTranslationResult[] {
|
||||
return agents.map(agent => translateAgent(agent, targetAgent, options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if agent format is compatible with target
|
||||
*/
|
||||
export function isAgentCompatible(
|
||||
sourceFormat: AgentFormatCategory,
|
||||
targetFormat: AgentFormatCategory
|
||||
): { compatible: boolean; warnings: string[] } {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (sourceFormat === targetFormat) {
|
||||
return { compatible: true, warnings };
|
||||
}
|
||||
|
||||
// All formats can translate to claude-agent (most feature-rich)
|
||||
if (targetFormat === 'claude-agent') {
|
||||
return { compatible: true, warnings };
|
||||
}
|
||||
|
||||
// Universal format loses some features
|
||||
if (targetFormat === 'universal') {
|
||||
if (sourceFormat === 'claude-agent') {
|
||||
warnings.push('Hooks, permissionMode, and disallowedTools will be lost');
|
||||
}
|
||||
return { compatible: true, warnings };
|
||||
}
|
||||
|
||||
// Cursor format has partial support
|
||||
if (targetFormat === 'cursor-agent') {
|
||||
if (sourceFormat === 'claude-agent') {
|
||||
warnings.push('Some Claude-specific features may not translate perfectly');
|
||||
}
|
||||
return { compatible: true, warnings };
|
||||
}
|
||||
|
||||
return { compatible: true, warnings };
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* Agent Types
|
||||
*
|
||||
* Types for custom AI sub-agents (e.g., .claude/agents/*.md)
|
||||
* Based on Claude Code's agent specification.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import type { AgentType } from '../types.js';
|
||||
|
||||
/**
|
||||
* Agent permission modes
|
||||
*/
|
||||
export const AgentPermissionMode = z.enum([
|
||||
'default', // Normal permission prompts
|
||||
'plan', // Plan mode - ask before executing
|
||||
'auto-edit', // Auto-accept edits
|
||||
'full-auto', // Auto-accept everything (dangerous)
|
||||
'bypassPermissions', // Skip all permission checks
|
||||
]);
|
||||
export type AgentPermissionMode = z.infer<typeof AgentPermissionMode>;
|
||||
|
||||
/**
|
||||
* Agent hook definition
|
||||
*/
|
||||
export const AgentHook = z.object({
|
||||
/** Hook event type */
|
||||
type: z.enum([
|
||||
'PreToolUse',
|
||||
'PostToolUse',
|
||||
'Stop',
|
||||
'SubagentStop',
|
||||
'SessionStart',
|
||||
'SessionEnd',
|
||||
]),
|
||||
/** Command to run */
|
||||
command: z.string(),
|
||||
/** Timeout in milliseconds */
|
||||
timeout: z.number().optional(),
|
||||
/** Run only once */
|
||||
once: z.boolean().optional(),
|
||||
/** Tool matcher (for PreToolUse/PostToolUse) */
|
||||
matcher: z.string().optional(),
|
||||
});
|
||||
export type AgentHook = z.infer<typeof AgentHook>;
|
||||
|
||||
/**
|
||||
* Agent frontmatter schema
|
||||
*/
|
||||
export const AgentFrontmatter = z.object({
|
||||
/** Agent name (kebab-case) */
|
||||
name: z.string()
|
||||
.min(1)
|
||||
.max(64)
|
||||
.regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, 'Agent name must be lowercase alphanumeric with hyphens'),
|
||||
/** Description of what this agent does */
|
||||
description: z.string().min(1).max(1024),
|
||||
/** Model to use (e.g., 'opus', 'sonnet', 'haiku') */
|
||||
model: z.string().optional(),
|
||||
/** Permission mode for this agent */
|
||||
permissionMode: AgentPermissionMode.optional(),
|
||||
/** Tools this agent cannot use */
|
||||
disallowedTools: z.array(z.string()).optional(),
|
||||
/** Allowed tools for this agent */
|
||||
allowedTools: z.union([
|
||||
z.array(z.string()),
|
||||
z.string(), // YAML-style list in frontmatter
|
||||
]).optional(),
|
||||
/** Agent-scoped hooks */
|
||||
hooks: z.array(AgentHook).optional(),
|
||||
/** Skills to auto-load for this agent */
|
||||
skills: z.array(z.string()).optional(),
|
||||
/** Run in forked sub-agent context */
|
||||
context: z.enum(['fork', 'inline']).optional(),
|
||||
/** Version */
|
||||
version: z.string().optional(),
|
||||
/** Author */
|
||||
author: z.string().optional(),
|
||||
/** Tags for categorization */
|
||||
tags: z.array(z.string()).optional(),
|
||||
/** Whether agent is user-invocable via @mention */
|
||||
'user-invocable': z.boolean().optional(),
|
||||
/** Argument hint for agent invocation */
|
||||
'argument-hint': z.string().optional(),
|
||||
});
|
||||
export type AgentFrontmatter = z.infer<typeof AgentFrontmatter>;
|
||||
|
||||
/**
|
||||
* Agent location (project or global)
|
||||
*/
|
||||
export const AgentLocation = z.enum(['project', 'global']);
|
||||
export type AgentLocation = z.infer<typeof AgentLocation>;
|
||||
|
||||
/**
|
||||
* Agent metadata (stored in .skillkit-agent.json)
|
||||
*/
|
||||
export const AgentMetadata = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
source: z.string(),
|
||||
sourceType: z.enum(['github', 'gitlab', 'bitbucket', 'local']),
|
||||
subpath: z.string().optional(),
|
||||
installedAt: z.string().datetime(),
|
||||
updatedAt: z.string().datetime().optional(),
|
||||
enabled: z.boolean().default(true),
|
||||
version: z.string().optional(),
|
||||
checksum: z.string().optional(),
|
||||
});
|
||||
export type AgentMetadata = z.infer<typeof AgentMetadata>;
|
||||
|
||||
/**
|
||||
* Parsed agent definition
|
||||
*/
|
||||
export interface CustomAgent {
|
||||
/** Agent name */
|
||||
name: string;
|
||||
/** Description */
|
||||
description: string;
|
||||
/** Path to agent directory or file */
|
||||
path: string;
|
||||
/** Project or global location */
|
||||
location: AgentLocation;
|
||||
/** Full frontmatter */
|
||||
frontmatter: AgentFrontmatter;
|
||||
/** Agent content (system prompt) */
|
||||
content: string;
|
||||
/** Metadata if installed via skillkit */
|
||||
metadata?: AgentMetadata;
|
||||
/** Whether agent is enabled */
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonical agent for translation
|
||||
*/
|
||||
export interface CanonicalAgent {
|
||||
/** Agent name */
|
||||
name: string;
|
||||
/** Description */
|
||||
description: string;
|
||||
/** Model to use */
|
||||
model?: string;
|
||||
/** Permission mode */
|
||||
permissionMode?: AgentPermissionMode;
|
||||
/** Disallowed tools */
|
||||
disallowedTools?: string[];
|
||||
/** Allowed tools */
|
||||
allowedTools?: string[];
|
||||
/** Agent-scoped hooks */
|
||||
hooks?: AgentHook[];
|
||||
/** Skills to load */
|
||||
skills?: string[];
|
||||
/** Execution context */
|
||||
context?: 'fork' | 'inline';
|
||||
/** Version */
|
||||
version?: string;
|
||||
/** Author */
|
||||
author?: string;
|
||||
/** Tags */
|
||||
tags?: string[];
|
||||
/** User invocable */
|
||||
userInvocable?: boolean;
|
||||
/** Argument hint */
|
||||
argumentHint?: string;
|
||||
/** Main content (system prompt) */
|
||||
content: string;
|
||||
/** Source format */
|
||||
sourceFormat: AgentFormatCategory;
|
||||
/** Source agent type */
|
||||
sourceAgent?: AgentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent format categories
|
||||
*/
|
||||
export type AgentFormatCategory =
|
||||
| 'claude-agent' // Claude Code .claude/agents/*.md
|
||||
| 'cursor-agent' // Cursor agent format (if different)
|
||||
| 'universal'; // Universal agent format
|
||||
|
||||
/**
|
||||
* Agent translation result
|
||||
*/
|
||||
export interface AgentTranslationResult {
|
||||
/** Whether translation succeeded */
|
||||
success: boolean;
|
||||
/** Translated content */
|
||||
content: string;
|
||||
/** Output filename */
|
||||
filename: string;
|
||||
/** Warnings during translation */
|
||||
warnings: string[];
|
||||
/** Features that couldn't be translated */
|
||||
incompatible: string[];
|
||||
/** Target format */
|
||||
targetFormat: AgentFormatCategory;
|
||||
/** Target agent type */
|
||||
targetAgent: AgentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent translation options
|
||||
*/
|
||||
export interface AgentTranslationOptions {
|
||||
/** Preserve original comments */
|
||||
preserveComments?: boolean;
|
||||
/** Add translation metadata */
|
||||
addMetadata?: boolean;
|
||||
/** Custom output filename */
|
||||
outputFilename?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent discovery paths per AI coding agent (2026 updated)
|
||||
*/
|
||||
export const AGENT_DISCOVERY_PATHS: Record<AgentType, string[]> = {
|
||||
'claude-code': ['.claude/agents'],
|
||||
'cursor': ['.cursor/agents', '.cursor/commands'],
|
||||
'codex': ['.codex/agents'],
|
||||
'gemini-cli': ['.gemini/agents'],
|
||||
'opencode': ['.opencode/agents', '.opencode/agent'],
|
||||
'antigravity': ['.antigravity/agents'],
|
||||
'amp': ['.amp/agents'],
|
||||
'clawdbot': ['.clawdbot/agents', 'agents'],
|
||||
'droid': ['.factory/agents'],
|
||||
'github-copilot': ['.github/agents', '.github/instructions', '.github/custom-agents'],
|
||||
'goose': ['.goose/agents'],
|
||||
'kilo': ['.kilocode/agents', '.kilocode/modes'],
|
||||
'kiro-cli': ['.kiro/agents'],
|
||||
'roo': ['.roo/agents', '.roo/modes'],
|
||||
'trae': ['.trae/agents', '.trae/agent'],
|
||||
'windsurf': ['.windsurf/agents', '.windsurf/workflows'],
|
||||
'universal': ['agents', '.agents'],
|
||||
};
|
||||
|
||||
/**
|
||||
* All agent discovery paths (union of all agent paths) - 2026 updated
|
||||
*/
|
||||
export const ALL_AGENT_DISCOVERY_PATHS = [
|
||||
'agents',
|
||||
'.agents',
|
||||
'.claude/agents',
|
||||
'.cursor/agents',
|
||||
'.cursor/commands',
|
||||
'.codex/agents',
|
||||
'.gemini/agents',
|
||||
'.opencode/agents',
|
||||
'.opencode/agent',
|
||||
'.antigravity/agents',
|
||||
'.amp/agents',
|
||||
'.clawdbot/agents',
|
||||
'.factory/agents',
|
||||
'.github/agents',
|
||||
'.github/instructions',
|
||||
'.github/custom-agents',
|
||||
'.goose/agents',
|
||||
'.kilocode/agents',
|
||||
'.kilocode/modes',
|
||||
'.kiro/agents',
|
||||
'.roo/agents',
|
||||
'.roo/modes',
|
||||
'.trae/agents',
|
||||
'.trae/agent',
|
||||
'.windsurf/agents',
|
||||
'.windsurf/workflows',
|
||||
];
|
||||
|
||||
/**
|
||||
* Agent format mapping (which agents use which format)
|
||||
*/
|
||||
export const CUSTOM_AGENT_FORMAT_MAP: Record<AgentType, AgentFormatCategory> = {
|
||||
'claude-code': 'claude-agent',
|
||||
'cursor': 'cursor-agent',
|
||||
'codex': 'claude-agent',
|
||||
'gemini-cli': 'claude-agent',
|
||||
'opencode': 'claude-agent',
|
||||
'antigravity': 'claude-agent',
|
||||
'amp': 'claude-agent',
|
||||
'clawdbot': 'claude-agent',
|
||||
'droid': 'claude-agent',
|
||||
'github-copilot': 'universal',
|
||||
'goose': 'claude-agent',
|
||||
'kilo': 'claude-agent',
|
||||
'kiro-cli': 'claude-agent',
|
||||
'roo': 'claude-agent',
|
||||
'trae': 'claude-agent',
|
||||
'windsurf': 'universal',
|
||||
'universal': 'universal',
|
||||
};
|
||||
@@ -5,6 +5,7 @@ import type { ContextSyncOptions } from './types.js';
|
||||
import { ContextManager } from './manager.js';
|
||||
import { translateSkillFile } from '../translator/index.js';
|
||||
import { findAllSkills } from '../skills.js';
|
||||
import { AGENT_CONFIG } from '../agent-config.js';
|
||||
|
||||
/**
|
||||
* Result of a sync operation
|
||||
@@ -29,29 +30,6 @@ export interface SyncReport {
|
||||
results: SyncResult[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent directory configuration
|
||||
*/
|
||||
const AGENT_DIRS: Record<AgentType, { skillsDir: string; configFile: string }> = {
|
||||
'claude-code': { skillsDir: '.claude/skills', configFile: 'AGENTS.md' },
|
||||
'cursor': { skillsDir: '.cursor/skills', configFile: '.cursorrules' },
|
||||
'codex': { skillsDir: '.codex/skills', configFile: 'AGENTS.md' },
|
||||
'gemini-cli': { skillsDir: '.gemini/skills', configFile: 'GEMINI.md' },
|
||||
'opencode': { skillsDir: '.opencode/skills', configFile: 'AGENTS.md' },
|
||||
'antigravity': { skillsDir: '.antigravity/skills', configFile: 'AGENTS.md' },
|
||||
'amp': { skillsDir: '.agents/skills', configFile: 'AGENTS.md' },
|
||||
'clawdbot': { skillsDir: 'skills', configFile: 'AGENTS.md' },
|
||||
'droid': { skillsDir: '.factory/skills', configFile: 'AGENTS.md' },
|
||||
'github-copilot': { skillsDir: '.github/skills', configFile: 'AGENTS.md' },
|
||||
'goose': { skillsDir: '.goose/skills', configFile: 'AGENTS.md' },
|
||||
'kilo': { skillsDir: '.kilocode/skills', configFile: 'AGENTS.md' },
|
||||
'kiro-cli': { skillsDir: '.kiro/skills', configFile: 'AGENTS.md' },
|
||||
'roo': { skillsDir: '.roo/skills', configFile: 'AGENTS.md' },
|
||||
'trae': { skillsDir: '.trae/skills', configFile: 'AGENTS.md' },
|
||||
'windsurf': { skillsDir: '.windsurf/skills', configFile: 'AGENTS.md' },
|
||||
'universal': { skillsDir: '.agent/skills', configFile: 'AGENTS.md' },
|
||||
};
|
||||
|
||||
/**
|
||||
* Context Sync
|
||||
*
|
||||
@@ -73,7 +51,7 @@ export class ContextSync {
|
||||
detectAgents(): AgentType[] {
|
||||
const detected: AgentType[] = [];
|
||||
|
||||
for (const [agent, config] of Object.entries(AGENT_DIRS)) {
|
||||
for (const [agent, config] of Object.entries(AGENT_CONFIG)) {
|
||||
const skillsPath = join(this.projectPath, config.skillsDir);
|
||||
const configPath = join(this.projectPath, config.configFile);
|
||||
|
||||
@@ -171,7 +149,7 @@ export class ContextSync {
|
||||
const sourceSkills = skills || this.getSourceSkills();
|
||||
|
||||
// Get target directory
|
||||
const agentConfig = AGENT_DIRS[agent];
|
||||
const agentConfig = AGENT_CONFIG[agent];
|
||||
if (!agentConfig) {
|
||||
result.success = false;
|
||||
result.errors.push(`Unknown agent: ${agent}`);
|
||||
@@ -297,8 +275,8 @@ export class ContextSync {
|
||||
// Search directories based on primary agent or common locations
|
||||
const searchDirs: string[] = [];
|
||||
|
||||
if (primaryAgent && AGENT_DIRS[primaryAgent]) {
|
||||
searchDirs.push(join(this.projectPath, AGENT_DIRS[primaryAgent].skillsDir));
|
||||
if (primaryAgent && AGENT_CONFIG[primaryAgent]) {
|
||||
searchDirs.push(join(this.projectPath, AGENT_CONFIG[primaryAgent].skillsDir));
|
||||
}
|
||||
|
||||
// Add common skill locations
|
||||
@@ -327,7 +305,7 @@ export class ContextSync {
|
||||
checkStatus(): Record<AgentType, { hasSkills: boolean; skillCount: number; skills: string[] }> {
|
||||
const status: Record<string, { hasSkills: boolean; skillCount: number; skills: string[] }> = {};
|
||||
|
||||
for (const [agent, config] of Object.entries(AGENT_DIRS)) {
|
||||
for (const [agent, config] of Object.entries(AGENT_CONFIG)) {
|
||||
const skillsPath = join(this.projectPath, config.skillsDir);
|
||||
const skills: string[] = [];
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Types
|
||||
export * from './types.js';
|
||||
|
||||
// Centralized Agent Configuration (single source of truth)
|
||||
export * from './agent-config.js';
|
||||
|
||||
// Skills discovery and parsing
|
||||
export * from './skills.js';
|
||||
|
||||
@@ -66,3 +69,9 @@ export * from './ai/index.js';
|
||||
|
||||
// Audit Logging (Phase 18)
|
||||
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';
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "SkillKit Marketplace",
|
||||
"description": "Schema for SkillKit marketplace skills index",
|
||||
"type": "object",
|
||||
"required": ["version", "skills"],
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "Schema version number"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "Last update date (YYYY-MM-DD)"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"description": "List of skills in the marketplace",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Skill"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Skill": {
|
||||
"type": "object",
|
||||
"required": ["id", "name", "source", "tags"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_-]+$",
|
||||
"description": "Unique identifier: owner/repo/skill-name"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"description": "Human-readable skill name"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 500,
|
||||
"description": "Brief description of the skill"
|
||||
},
|
||||
"source": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+$",
|
||||
"description": "GitHub repository: owner/repo"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$"
|
||||
},
|
||||
"minItems": 1,
|
||||
"maxItems": 10,
|
||||
"description": "Tags for categorization (lowercase, hyphenated)"
|
||||
},
|
||||
"author": {
|
||||
"type": "string",
|
||||
"description": "Skill author name or GitHub username"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
||||
"description": "Semantic version (e.g., 1.0.0)"
|
||||
},
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"claude-code",
|
||||
"cursor",
|
||||
"codex",
|
||||
"gemini-cli",
|
||||
"opencode",
|
||||
"antigravity",
|
||||
"amp",
|
||||
"clawdbot",
|
||||
"droid",
|
||||
"github-copilot",
|
||||
"goose",
|
||||
"kilo",
|
||||
"kiro-cli",
|
||||
"roo",
|
||||
"trae",
|
||||
"windsurf",
|
||||
"universal"
|
||||
]
|
||||
},
|
||||
"description": "Compatible AI agents (omit for universal compatibility)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,26 +121,23 @@ export interface MarketplaceConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default skill sources
|
||||
* Default skill sources - loaded from marketplace/sources.json (single source of truth)
|
||||
*/
|
||||
export const DEFAULT_SKILL_SOURCES: SkillSource[] = [
|
||||
{
|
||||
owner: 'composioHQ',
|
||||
repo: 'awesome-claude-code-skills',
|
||||
name: 'Composio Curated',
|
||||
description: 'Curated collection of Claude Code skills',
|
||||
official: false,
|
||||
branch: 'main',
|
||||
},
|
||||
{
|
||||
owner: 'anthropics',
|
||||
repo: 'courses',
|
||||
name: 'Anthropic Official',
|
||||
description: 'Official Anthropic courses and skills',
|
||||
official: true,
|
||||
branch: 'master',
|
||||
},
|
||||
];
|
||||
import sourcesData from '../../../../marketplace/sources.json' with { type: 'json' };
|
||||
|
||||
export const DEFAULT_SKILL_SOURCES: SkillSource[] = sourcesData.sources.map(
|
||||
(s: { source: string; name: string; official?: boolean }) => {
|
||||
const [owner, repo] = s.source.split('/');
|
||||
return {
|
||||
owner,
|
||||
repo,
|
||||
name: s.name,
|
||||
description: `Skills from ${s.name}`,
|
||||
official: s.official || false,
|
||||
branch: 'main',
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Cache file name
|
||||
|
||||
@@ -128,8 +128,8 @@ export async function buildSkillIndex(
|
||||
onProgress?.('No skills fetched, using sample index...');
|
||||
allSkills.push(...getSampleSkills());
|
||||
sources.push({
|
||||
name: 'skillkit-samples',
|
||||
url: 'https://github.com/skillkit/samples',
|
||||
name: 'built-in',
|
||||
url: 'https://github.com/rohitg00/skillkit',
|
||||
lastFetched: new Date().toISOString(),
|
||||
skillCount: allSkills.length,
|
||||
});
|
||||
@@ -198,7 +198,7 @@ function getSampleSkills(): SkillSummary[] {
|
||||
{
|
||||
name: 'react-best-practices',
|
||||
description: 'Modern React patterns including Server Components, hooks best practices, and performance optimization',
|
||||
source: 'skillkit/samples',
|
||||
source: 'built-in',
|
||||
tags: ['react', 'frontend', 'typescript', 'nextjs', 'performance'],
|
||||
compatibility: {
|
||||
frameworks: ['react', 'nextjs'],
|
||||
@@ -213,7 +213,7 @@ function getSampleSkills(): SkillSummary[] {
|
||||
{
|
||||
name: 'tailwind-patterns',
|
||||
description: 'Tailwind CSS utility patterns, responsive design, and component styling best practices',
|
||||
source: 'skillkit/samples',
|
||||
source: 'built-in',
|
||||
tags: ['tailwind', 'css', 'styling', 'frontend', 'responsive'],
|
||||
compatibility: {
|
||||
frameworks: [],
|
||||
@@ -228,7 +228,7 @@ function getSampleSkills(): SkillSummary[] {
|
||||
{
|
||||
name: 'typescript-strict-patterns',
|
||||
description: 'TypeScript strict mode patterns, type safety, and advanced type utilities',
|
||||
source: 'skillkit/samples',
|
||||
source: 'built-in',
|
||||
tags: ['typescript', 'types', 'safety', 'patterns'],
|
||||
compatibility: {
|
||||
frameworks: [],
|
||||
@@ -243,7 +243,7 @@ function getSampleSkills(): SkillSummary[] {
|
||||
{
|
||||
name: 'security-best-practices',
|
||||
description: 'Security patterns for web applications including XSS prevention, CSRF, and secure headers',
|
||||
source: 'skillkit/samples',
|
||||
source: 'built-in',
|
||||
tags: ['security', 'xss', 'csrf', 'headers', 'owasp'],
|
||||
compatibility: {
|
||||
frameworks: [],
|
||||
@@ -258,7 +258,7 @@ function getSampleSkills(): SkillSummary[] {
|
||||
{
|
||||
name: 'testing-patterns',
|
||||
description: 'Testing patterns with Vitest/Jest including mocking, assertions, and test organization',
|
||||
source: 'skillkit/samples',
|
||||
source: 'built-in',
|
||||
tags: ['vitest', 'jest', 'testing', 'typescript', 'mocking', 'tdd'],
|
||||
compatibility: {
|
||||
frameworks: [],
|
||||
|
||||
@@ -0,0 +1,692 @@
|
||||
/**
|
||||
* Skill Translator
|
||||
*
|
||||
* Translates SKILL.md files between different AI coding agent formats.
|
||||
* This is the core functionality for SkillKit's cross-agent skill ecosystem.
|
||||
*/
|
||||
|
||||
import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { join, basename, dirname, resolve, relative, isAbsolute } from 'node:path';
|
||||
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
||||
import type { AgentType, Skill } from './types.js';
|
||||
import {
|
||||
AGENT_CONFIG,
|
||||
type AgentDirectoryConfig,
|
||||
getSkillsDir,
|
||||
getConfigFile,
|
||||
getAllSkillsDirs as getAgentAllSkillsDirs,
|
||||
getGlobalSkillsDir as getAgentGlobalSkillsDir,
|
||||
supportsAutoDiscovery as agentSupportsAutoDiscovery,
|
||||
} from './agent-config.js';
|
||||
|
||||
/**
|
||||
* Extended skill format for translation (includes invokeCommand)
|
||||
*/
|
||||
export interface AgentSkillFormat extends AgentDirectoryConfig {
|
||||
invokeCommand: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent-specific skill format configurations
|
||||
* Extends AGENT_CONFIG with invokeCommand for all agents
|
||||
*/
|
||||
export const AGENT_SKILL_FORMATS: Record<AgentType, AgentSkillFormat> = Object.fromEntries(
|
||||
Object.entries(AGENT_CONFIG).map(([agent, config]) => [
|
||||
agent,
|
||||
{ ...config, invokeCommand: 'skillkit read' },
|
||||
])
|
||||
) as Record<AgentType, AgentSkillFormat>;
|
||||
|
||||
/**
|
||||
* Canonical skill representation for cross-agent translation
|
||||
*/
|
||||
export interface CrossAgentSkill {
|
||||
name: string;
|
||||
description: string;
|
||||
content: string;
|
||||
frontmatter: Record<string, unknown>;
|
||||
sourcePath: string;
|
||||
sourceAgent?: AgentType;
|
||||
version?: string;
|
||||
author?: string;
|
||||
tags?: string[];
|
||||
allowedTools?: string[];
|
||||
/** Agent-specific fields preserved during translation */
|
||||
agentFields?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skill translation result
|
||||
*/
|
||||
export interface SkillTranslationResult {
|
||||
success: boolean;
|
||||
content: string;
|
||||
filename: string;
|
||||
targetDir: string;
|
||||
warnings: string[];
|
||||
incompatible: string[];
|
||||
targetAgent: AgentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skill translation options
|
||||
*/
|
||||
export interface SkillTranslationOptions {
|
||||
/** Preserve original comments and formatting */
|
||||
preserveComments?: boolean;
|
||||
/** Add translation metadata comment */
|
||||
addMetadata?: boolean;
|
||||
/** Custom output filename */
|
||||
outputFilename?: string;
|
||||
/** Overwrite existing files */
|
||||
overwrite?: boolean;
|
||||
/** Write to disk */
|
||||
write?: boolean;
|
||||
/** Output directory override */
|
||||
outputDir?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a SKILL.md file into canonical format
|
||||
*/
|
||||
export function parseSkillToCanonical(
|
||||
skillPath: string,
|
||||
sourceAgent?: AgentType
|
||||
): CrossAgentSkill | null {
|
||||
const skillMdPath = skillPath.endsWith('SKILL.md')
|
||||
? skillPath
|
||||
: join(skillPath, 'SKILL.md');
|
||||
|
||||
if (!existsSync(skillMdPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(skillMdPath, 'utf-8');
|
||||
return parseSkillContentToCanonical(content, skillPath, sourceAgent);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse skill content string into canonical format
|
||||
*/
|
||||
export function parseSkillContentToCanonical(
|
||||
content: string,
|
||||
sourcePath: string,
|
||||
sourceAgent?: AgentType
|
||||
): CrossAgentSkill | null {
|
||||
const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
||||
|
||||
let frontmatter: Record<string, unknown> = {};
|
||||
let bodyContent = content;
|
||||
|
||||
if (frontmatterMatch) {
|
||||
try {
|
||||
frontmatter = parseYaml(frontmatterMatch[1]) as Record<string, unknown>;
|
||||
bodyContent = content.slice(frontmatterMatch[0].length).trim();
|
||||
} catch {
|
||||
// Continue without frontmatter
|
||||
}
|
||||
}
|
||||
|
||||
// If sourcePath is a directory (skill folder), use its basename
|
||||
// If sourcePath is a file (SKILL.md), use the parent directory's basename
|
||||
const name = (frontmatter.name as string) || basename(sourcePath.endsWith('.md') ? dirname(sourcePath) : sourcePath);
|
||||
const description = (frontmatter.description as string) || extractDescriptionFromContent(bodyContent);
|
||||
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
content: bodyContent,
|
||||
frontmatter,
|
||||
sourcePath,
|
||||
sourceAgent,
|
||||
version: frontmatter.version as string | undefined,
|
||||
author: frontmatter.author as string | undefined,
|
||||
tags: frontmatter.tags as string[] | undefined,
|
||||
allowedTools: parseAllowedTools(frontmatter['allowed-tools']),
|
||||
agentFields: extractAgentSpecificFields(frontmatter, sourceAgent),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract description from markdown content if not in frontmatter
|
||||
*/
|
||||
function extractDescriptionFromContent(content: string): string {
|
||||
// Try to find first paragraph or first heading
|
||||
const lines = content.split('\n').filter(line => line.trim());
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
// Skip headings
|
||||
if (trimmed.startsWith('#')) continue;
|
||||
// Skip code blocks
|
||||
if (trimmed.startsWith('```')) continue;
|
||||
// Return first substantive line
|
||||
if (trimmed.length > 10) {
|
||||
return trimmed.slice(0, 200) + (trimmed.length > 200 ? '...' : '');
|
||||
}
|
||||
}
|
||||
|
||||
return 'No description available';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse allowed-tools field (can be string or array)
|
||||
*/
|
||||
function parseAllowedTools(value: unknown): string[] | undefined {
|
||||
if (!value) return undefined;
|
||||
if (Array.isArray(value)) return value;
|
||||
if (typeof value === 'string') {
|
||||
return value.split(',').map(t => t.trim()).filter(Boolean);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract agent-specific fields from frontmatter
|
||||
*/
|
||||
function extractAgentSpecificFields(
|
||||
frontmatter: Record<string, unknown>,
|
||||
_sourceAgent?: AgentType
|
||||
): Record<string, unknown> {
|
||||
const agentFields: Record<string, unknown> = {};
|
||||
|
||||
// Preserve special fields that might be agent-specific
|
||||
const specialFields = [
|
||||
'disable-model-invocation',
|
||||
'user-invocable',
|
||||
'argument-hint',
|
||||
'model',
|
||||
'context',
|
||||
'agent',
|
||||
'globs',
|
||||
'alwaysApply',
|
||||
'applyTo',
|
||||
'mode',
|
||||
'hooks',
|
||||
'permissionMode',
|
||||
];
|
||||
|
||||
for (const field of specialFields) {
|
||||
if (field in frontmatter) {
|
||||
agentFields[field] = frontmatter[field];
|
||||
}
|
||||
}
|
||||
|
||||
return agentFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a cross-agent skill to target agent format
|
||||
*/
|
||||
export function translateSkillToAgent(
|
||||
canonical: CrossAgentSkill,
|
||||
targetAgent: AgentType,
|
||||
options?: SkillTranslationOptions
|
||||
): SkillTranslationResult {
|
||||
const format = AGENT_SKILL_FORMATS[targetAgent];
|
||||
const warnings: string[] = [];
|
||||
const incompatible: string[] = [];
|
||||
|
||||
// Check for incompatible features
|
||||
if (canonical.agentFields?.['hooks'] && targetAgent !== 'claude-code') {
|
||||
incompatible.push('hooks (only supported in Claude Code)');
|
||||
}
|
||||
|
||||
if (canonical.agentFields?.['permissionMode'] && !['claude-code', 'roo'].includes(targetAgent)) {
|
||||
warnings.push('permissionMode may not be fully supported');
|
||||
}
|
||||
|
||||
// Generate SKILL.md content for target agent
|
||||
const content = generateSkillContent(canonical, targetAgent, format, options);
|
||||
|
||||
// Determine output filename and directory
|
||||
const filename = options?.outputFilename || 'SKILL.md';
|
||||
const targetDir = options?.outputDir || join(format.skillsDir, canonical.name);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
content,
|
||||
filename,
|
||||
targetDir,
|
||||
warnings,
|
||||
incompatible,
|
||||
targetAgent,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate SKILL.md content for target agent
|
||||
*/
|
||||
function generateSkillContent(
|
||||
canonical: CrossAgentSkill,
|
||||
targetAgent: AgentType,
|
||||
format: AgentSkillFormat,
|
||||
options?: SkillTranslationOptions
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Build frontmatter
|
||||
const frontmatter: Record<string, unknown> = {
|
||||
name: canonical.name,
|
||||
description: canonical.description,
|
||||
};
|
||||
|
||||
// Add version and author if present
|
||||
if (canonical.version) {
|
||||
frontmatter.version = canonical.version;
|
||||
}
|
||||
if (canonical.author) {
|
||||
frontmatter.author = canonical.author;
|
||||
}
|
||||
if (canonical.tags && canonical.tags.length > 0) {
|
||||
frontmatter.tags = canonical.tags;
|
||||
}
|
||||
|
||||
// Add allowed-tools if present
|
||||
if (canonical.allowedTools && canonical.allowedTools.length > 0) {
|
||||
frontmatter['allowed-tools'] = canonical.allowedTools.join(', ');
|
||||
}
|
||||
|
||||
// Add agent-specific fields based on target
|
||||
addAgentSpecificFields(frontmatter, canonical, targetAgent, format);
|
||||
|
||||
// Add translation metadata if requested
|
||||
if (options?.addMetadata && canonical.sourceAgent) {
|
||||
frontmatter['_translated-from'] = canonical.sourceAgent;
|
||||
frontmatter['_translated-at'] = new Date().toISOString();
|
||||
}
|
||||
|
||||
// Generate YAML frontmatter
|
||||
lines.push('---');
|
||||
lines.push(stringifyYaml(frontmatter).trim());
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
|
||||
// Add content
|
||||
lines.push(canonical.content);
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add agent-specific fields to frontmatter
|
||||
*/
|
||||
function addAgentSpecificFields(
|
||||
frontmatter: Record<string, unknown>,
|
||||
canonical: CrossAgentSkill,
|
||||
targetAgent: AgentType,
|
||||
_format: AgentSkillFormat
|
||||
): void {
|
||||
// Claude Code specific
|
||||
if (targetAgent === 'claude-code') {
|
||||
if ('model' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.model = canonical.agentFields!['model'];
|
||||
}
|
||||
if ('context' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.context = canonical.agentFields!['context'];
|
||||
}
|
||||
if ('agent' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.agent = canonical.agentFields!['agent'];
|
||||
}
|
||||
if ('disable-model-invocation' in (canonical.agentFields ?? {})) {
|
||||
frontmatter['disable-model-invocation'] = canonical.agentFields!['disable-model-invocation'];
|
||||
}
|
||||
if ('user-invocable' in (canonical.agentFields ?? {})) {
|
||||
frontmatter['user-invocable'] = canonical.agentFields!['user-invocable'];
|
||||
}
|
||||
if ('argument-hint' in (canonical.agentFields ?? {})) {
|
||||
frontmatter['argument-hint'] = canonical.agentFields!['argument-hint'];
|
||||
}
|
||||
if ('hooks' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.hooks = canonical.agentFields!['hooks'];
|
||||
}
|
||||
if ('permissionMode' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.permissionMode = canonical.agentFields!['permissionMode'];
|
||||
}
|
||||
}
|
||||
|
||||
// Cursor/Trae/Windsurf specific (MDC-style)
|
||||
if (['cursor', 'trae', 'windsurf'].includes(targetAgent)) {
|
||||
if ('globs' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.globs = canonical.agentFields!['globs'];
|
||||
}
|
||||
if ('alwaysApply' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.alwaysApply = canonical.agentFields!['alwaysApply'];
|
||||
}
|
||||
if (targetAgent === 'windsurf' && 'mode' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.mode = canonical.agentFields!['mode'];
|
||||
}
|
||||
}
|
||||
|
||||
// GitHub Copilot specific
|
||||
if (targetAgent === 'github-copilot') {
|
||||
if ('applyTo' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.applyTo = canonical.agentFields!['applyTo'];
|
||||
}
|
||||
}
|
||||
|
||||
// Roo specific
|
||||
if (targetAgent === 'roo') {
|
||||
if ('disable-model-invocation' in (canonical.agentFields ?? {})) {
|
||||
frontmatter['disable-model-invocation'] = canonical.agentFields!['disable-model-invocation'];
|
||||
}
|
||||
if ('user-invocable' in (canonical.agentFields ?? {})) {
|
||||
frontmatter['user-invocable'] = canonical.agentFields!['user-invocable'];
|
||||
}
|
||||
if ('permissionMode' in (canonical.agentFields ?? {})) {
|
||||
frontmatter.permissionMode = canonical.agentFields!['permissionMode'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a skill file to multiple target agents
|
||||
*/
|
||||
export function translateSkillToAll(
|
||||
skillPath: string,
|
||||
sourceAgent?: AgentType,
|
||||
options?: SkillTranslationOptions
|
||||
): Map<AgentType, SkillTranslationResult> {
|
||||
const canonical = parseSkillToCanonical(skillPath, sourceAgent);
|
||||
if (!canonical) {
|
||||
return new Map();
|
||||
}
|
||||
|
||||
const results = new Map<AgentType, SkillTranslationResult>();
|
||||
const agents: AgentType[] = [
|
||||
'claude-code', 'cursor', 'codex', 'gemini-cli', 'opencode',
|
||||
'antigravity', 'amp', 'clawdbot', 'droid', 'github-copilot',
|
||||
'goose', 'kilo', 'kiro-cli', 'roo', 'trae', 'windsurf', 'universal',
|
||||
];
|
||||
|
||||
for (const agent of agents) {
|
||||
if (agent !== sourceAgent) {
|
||||
results.set(agent, translateSkillToAgent(canonical, agent, options));
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write translated skill to disk
|
||||
*/
|
||||
export function writeTranslatedSkill(
|
||||
result: SkillTranslationResult,
|
||||
rootDir: string,
|
||||
options?: { overwrite?: boolean }
|
||||
): { success: boolean; path: string; error?: string; skipped?: boolean } {
|
||||
// Don't write if translation failed
|
||||
if (!result.success) {
|
||||
return {
|
||||
success: false,
|
||||
path: '',
|
||||
error: 'Translation failed',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const rootPath = resolve(rootDir);
|
||||
const filePath = resolve(rootDir, result.targetDir, result.filename);
|
||||
const targetPath = dirname(filePath);
|
||||
|
||||
// Guard against path traversal
|
||||
const relPath = relative(rootPath, filePath);
|
||||
if (relPath.startsWith('..') || isAbsolute(relPath)) {
|
||||
return {
|
||||
success: false,
|
||||
path: filePath,
|
||||
error: 'Resolved output path escapes rootDir',
|
||||
};
|
||||
}
|
||||
|
||||
// Check if file exists and overwrite is disabled
|
||||
if (existsSync(filePath) && options?.overwrite === false) {
|
||||
return {
|
||||
success: false,
|
||||
path: filePath,
|
||||
error: 'File exists and overwrite=false',
|
||||
skipped: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Create directory if needed
|
||||
if (!existsSync(targetPath)) {
|
||||
mkdirSync(targetPath, { recursive: true });
|
||||
}
|
||||
|
||||
writeFileSync(filePath, result.content, 'utf-8');
|
||||
|
||||
return { success: true, path: filePath };
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
path: '',
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate config file content that references skills
|
||||
* This generates the agent-specific config format (AGENTS.md, .cursorrules, etc.)
|
||||
*/
|
||||
export function generateSkillsConfig(
|
||||
skills: Skill[],
|
||||
targetAgent: AgentType
|
||||
): string {
|
||||
const format = AGENT_SKILL_FORMATS[targetAgent];
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch (format.configFormat) {
|
||||
case 'xml':
|
||||
return generateXmlConfig(enabledSkills, format);
|
||||
case 'mdc':
|
||||
return generateMdcConfig(enabledSkills, format);
|
||||
case 'markdown-table':
|
||||
return generateMarkdownTableConfig(enabledSkills, format);
|
||||
case 'json':
|
||||
return generateJsonConfig(enabledSkills, format);
|
||||
case 'markdown':
|
||||
return generateMarkdownConfig(enabledSkills, format);
|
||||
default:
|
||||
return generateMarkdownConfig(enabledSkills, format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate XML-style config (Claude Code, OpenCode, etc.)
|
||||
*/
|
||||
function generateXmlConfig(skills: Skill[], format: AgentSkillFormat): string {
|
||||
const skillsXml = skills.map(s => `<skill>
|
||||
<name>${escapeXml(s.name)}</name>
|
||||
<description>${escapeXml(s.description)}</description>
|
||||
<location>${escapeXml(s.path)}</location>
|
||||
</skill>`).join('\n\n');
|
||||
|
||||
return `<skills_system priority="1">
|
||||
|
||||
## Available Skills
|
||||
|
||||
<!-- SKILLS_TABLE_START -->
|
||||
<usage>
|
||||
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
|
||||
|
||||
How to use skills:
|
||||
- Invoke: \`${format.invokeCommand} <skill-name>\` or \`npx ${format.invokeCommand} <skill-name>\`
|
||||
- The skill content will load with detailed instructions on how to complete the task
|
||||
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
|
||||
|
||||
Usage notes:
|
||||
- Only use skills listed in <available_skills> below
|
||||
- Do not invoke a skill that is already loaded in your context
|
||||
- Each skill invocation is stateless
|
||||
</usage>
|
||||
|
||||
<available_skills>
|
||||
|
||||
${skillsXml}
|
||||
|
||||
</available_skills>
|
||||
<!-- SKILLS_TABLE_END -->
|
||||
|
||||
</skills_system>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate MDC-style config (Cursor)
|
||||
*/
|
||||
function generateMdcConfig(skills: Skill[], format: AgentSkillFormat): string {
|
||||
const skillsList = skills
|
||||
.map(s => `- **${s.name}**: ${s.description}`)
|
||||
.join('\n');
|
||||
|
||||
const skillsXml = skills.map(s => `<skill>
|
||||
<name>${escapeXml(s.name)}</name>
|
||||
<description>${escapeXml(s.description)}</description>
|
||||
<location>${escapeXml(s.path)}</location>
|
||||
</skill>`).join('\n\n');
|
||||
|
||||
return `---
|
||||
description: SkillKit skills integration - provides specialized capabilities and domain knowledge
|
||||
globs: "**/*"
|
||||
alwaysApply: true
|
||||
---
|
||||
# Skills System
|
||||
|
||||
You have access to specialized skills that can help complete tasks. Use the skillkit CLI to load skill instructions when needed.
|
||||
|
||||
## Available Skills
|
||||
|
||||
${skillsList}
|
||||
|
||||
## How to Use Skills
|
||||
|
||||
When a task matches a skill's description, load it with:
|
||||
\`\`\`bash
|
||||
${format.invokeCommand} <skill-name>
|
||||
\`\`\`
|
||||
|
||||
The skill will provide detailed instructions for completing the task.
|
||||
|
||||
<!-- SKILLS_DATA_START -->
|
||||
${skillsXml}
|
||||
<!-- SKILLS_DATA_END -->
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Markdown table config (Codex)
|
||||
*/
|
||||
function generateMarkdownTableConfig(skills: Skill[], format: AgentSkillFormat): string {
|
||||
const skillsList = skills
|
||||
.map(s => `| ${s.name} | ${s.description} | \`${format.invokeCommand} ${s.name}\` |`)
|
||||
.join('\n');
|
||||
|
||||
return `# Skills
|
||||
|
||||
You have access to specialized skills for completing complex tasks.
|
||||
|
||||
| Skill | Description | Command |
|
||||
|-------|-------------|---------|
|
||||
${skillsList}
|
||||
|
||||
## Usage
|
||||
|
||||
When a task matches a skill's capability, run the command to load detailed instructions:
|
||||
|
||||
\`\`\`bash
|
||||
${format.invokeCommand} <skill-name>
|
||||
\`\`\`
|
||||
|
||||
Skills are loaded on-demand to keep context clean. Only load skills when relevant to the current task.
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate JSON config (Gemini CLI)
|
||||
*/
|
||||
function generateJsonConfig(skills: Skill[], format: AgentSkillFormat): string {
|
||||
const skillsJson = skills.map(s => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
invoke: `${format.invokeCommand} ${s.name}`,
|
||||
location: s.path,
|
||||
}));
|
||||
|
||||
return `# Skills Configuration
|
||||
|
||||
You have access to specialized skills that extend your capabilities.
|
||||
|
||||
## Available Skills
|
||||
|
||||
${skills.map(s => `### ${s.name}\n${s.description}\n\nInvoke: \`${format.invokeCommand} ${s.name}\``).join('\n\n')}
|
||||
|
||||
## Skills Data
|
||||
|
||||
\`\`\`json
|
||||
${JSON.stringify(skillsJson, null, 2)}
|
||||
\`\`\`
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
1. When a task matches a skill's description, load it using the invoke command
|
||||
2. Skills provide step-by-step instructions for complex tasks
|
||||
3. Each skill is self-contained with its own resources
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Markdown config (Windsurf, Trae, GitHub Copilot)
|
||||
*/
|
||||
function generateMarkdownConfig(skills: Skill[], format: AgentSkillFormat): string {
|
||||
const skillsList = skills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`${format.invokeCommand} ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
return `# Skills System
|
||||
|
||||
You have access to specialized skills that can help complete tasks.
|
||||
|
||||
## Available Skills
|
||||
|
||||
${skillsList}
|
||||
|
||||
## How to Use Skills
|
||||
|
||||
When a task matches a skill's description, load it:
|
||||
|
||||
\`\`\`bash
|
||||
${format.invokeCommand} <skill-name>
|
||||
\`\`\`
|
||||
|
||||
Skills provide detailed instructions for completing complex tasks.
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape XML special characters
|
||||
*/
|
||||
function escapeXml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
// Re-export utility functions from centralized config with legacy names for backwards compatibility
|
||||
export const getAgentSkillsDir = getSkillsDir;
|
||||
export const getAgentConfigFile = getConfigFile;
|
||||
export { agentSupportsAutoDiscovery as supportsAutoDiscovery };
|
||||
export { getAgentAllSkillsDirs as getAllSkillsDirs };
|
||||
export { getAgentGlobalSkillsDir as getGlobalSkillsDir };
|
||||
+78
-163
@@ -5,216 +5,131 @@
|
||||
|
||||
**Interactive terminal UI for SkillKit** - browse, install, translate, and manage skills visually in your terminal.
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Bun runtime** (>=1.2.0) - Required for OpenTUI rendering
|
||||
- Terminal with 80x24 minimum (120x40 recommended)
|
||||
|
||||
Install Bun: https://bun.sh
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @skillkit/tui
|
||||
# or
|
||||
npm install -g skillkit # includes TUI
|
||||
npm install -g skillkit
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
skillkit ui
|
||||
# or just
|
||||
skillkit
|
||||
# Launch TUI with Bun
|
||||
bun skillkit ui
|
||||
|
||||
# Or via pnpm in monorepo
|
||||
pnpm ui
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- **Browse Skills**: Explore 33+ skill repositories with search and filtering
|
||||
- **Smart Recommendations**: See project-aware skill suggestions with match scores
|
||||
- **Cross-Agent Translation**: Convert skills between any of 17 agent formats
|
||||
- **Context Management**: View detected stack and sync to all agents
|
||||
- **Multi-Agent Install**: Install skills to multiple agents at once
|
||||
- **Responsive Design**: Adapts to any terminal size
|
||||
|
||||
## Screens
|
||||
|
||||
### Home (h)
|
||||
Overview of your project and quick actions. Shows detected agents, installed skills count, and navigation hints.
|
||||
|
||||
### Marketplace (m)
|
||||
Browse curated skill marketplace:
|
||||
- Search across 33+ repositories
|
||||
- Filter by tags and categories
|
||||
- View popularity metrics
|
||||
- Install with one key
|
||||
|
||||
### Browse (b)
|
||||
Explore available skills from curated repositories:
|
||||
- Search skills with `/`
|
||||
- Filter by tags
|
||||
- View skill details
|
||||
- One-key installation
|
||||
|
||||
### Workflow (w)
|
||||
Manage and execute workflows:
|
||||
- List available workflows
|
||||
- View workflow steps
|
||||
- Execute workflows
|
||||
- Monitor progress
|
||||
|
||||
### Execute (x)
|
||||
Execute skills with checkpoints:
|
||||
- Task-based execution
|
||||
- Decision and review checkpoints
|
||||
- Dry-run mode
|
||||
- Git integration
|
||||
|
||||
### Team (a)
|
||||
Team collaboration management:
|
||||
- Create and share skill bundles
|
||||
- Import team bundles
|
||||
- Sync with remote registry
|
||||
- Manage team members
|
||||
|
||||
### Plugins (p)
|
||||
Plugin system management:
|
||||
- List installed plugins
|
||||
- Install new plugins
|
||||
- Enable/disable plugins
|
||||
- View plugin details
|
||||
|
||||
### Methodology (o)
|
||||
Development methodologies:
|
||||
- Browse 5 methodologies (Agile, TDD, DevOps, Design Thinking, Feature Flags)
|
||||
- View methodology skills
|
||||
- Apply to project
|
||||
- Track adoption
|
||||
|
||||
### Plan (n)
|
||||
Structured plan system:
|
||||
- Parse plan files
|
||||
- Validate plan structure
|
||||
- Execute plans step-by-step
|
||||
- Track progress
|
||||
|
||||
### Recommend (r)
|
||||
AI-powered skill suggestions based on your project:
|
||||
- Analyzes your package.json, configs, and file structure
|
||||
- Shows match percentage for each skill
|
||||
- Explains why skills are recommended
|
||||
- Filter by minimum score
|
||||
|
||||
### Translate (t)
|
||||
Convert skills between agent formats:
|
||||
- Select source skill
|
||||
- Choose target agent(s)
|
||||
- Preview translation
|
||||
- Apply with confirmation
|
||||
|
||||
### Context (c)
|
||||
View and manage project context:
|
||||
- Detected languages and frameworks
|
||||
- Found testing tools and databases
|
||||
- Installed agents
|
||||
- Sync context to all agents
|
||||
|
||||
### Memory (e)
|
||||
Session memory system:
|
||||
- View learnings
|
||||
- Search past sessions
|
||||
- Compress observations
|
||||
- Export as skills
|
||||
|
||||
### Installed (i)
|
||||
Manage your installed skills:
|
||||
- View all installed skills
|
||||
- Enable/disable skills
|
||||
- Remove skills
|
||||
- Update from source
|
||||
|
||||
### Sync (s)
|
||||
Sync skills across agents:
|
||||
- Select target agents
|
||||
- Preview changes
|
||||
- Apply sync
|
||||
|
||||
### Settings (,)
|
||||
Configure SkillKit:
|
||||
- Default agent
|
||||
- Auto-sync settings
|
||||
- Skill directories
|
||||
- **Monochromatic Design** - Clean B&W theme with colored accents
|
||||
- **Animated UI** - Smooth entrance animations and transitions
|
||||
- **Browse Skills** - Explore skill repositories with search and filtering
|
||||
- **Smart Recommendations** - AI-powered skill suggestions with match scores
|
||||
- **Cross-Agent Translation** - Convert skills between 17+ agent formats
|
||||
- **Team Collaboration** - Share and sync skills across teams
|
||||
- **Responsive Design** - Adapts to any terminal size
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
| Key | Action |
|
||||
### Navigation
|
||||
| Key | Screen |
|
||||
|-----|--------|
|
||||
| `h` | Home screen |
|
||||
| `m` | Marketplace |
|
||||
| `h` | Home |
|
||||
| `b` | Browse skills |
|
||||
| `m` | Marketplace |
|
||||
| `r` | Recommendations |
|
||||
| `i` | Installed skills |
|
||||
| `s` | Sync settings |
|
||||
|
||||
### Actions
|
||||
| Key | Screen |
|
||||
|-----|--------|
|
||||
| `t` | Translate skills |
|
||||
| `w` | Workflows |
|
||||
| `x` | Execute |
|
||||
| `a` | Team collaboration |
|
||||
| `n` | Plan |
|
||||
| `y` | History |
|
||||
|
||||
### Team & Config
|
||||
| Key | Screen |
|
||||
|-----|--------|
|
||||
| `a` | Team |
|
||||
| `c` | Context |
|
||||
| `e` | Memory |
|
||||
| `p` | Plugins |
|
||||
| `o` | Methodology |
|
||||
| `n` | Plan system |
|
||||
| `r` | Recommendations |
|
||||
| `t` | Translate skills |
|
||||
| `c` | Context management |
|
||||
| `e` | Memory/Learnings |
|
||||
| `i` | Installed skills |
|
||||
| `s` | Sync skills |
|
||||
| `,` | Settings |
|
||||
| `↑/↓` | Navigate lists |
|
||||
| `Enter` | Select / Confirm |
|
||||
| `/` | Search |
|
||||
| `Tab` | Switch focus |
|
||||
| `Esc` | Go back |
|
||||
| `?` | Help |
|
||||
|
||||
### Global
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `/` | Help screen |
|
||||
| `esc` | Go back / Home |
|
||||
| `q` | Quit |
|
||||
| `j/k` | Navigate lists |
|
||||
| `enter` | Select item |
|
||||
|
||||
## Screens Overview
|
||||
|
||||
- **Home** - Dashboard with stats, detected agents, and features
|
||||
- **Browse** - Search and explore skill repositories
|
||||
- **Marketplace** - Curated skill marketplace with popularity metrics
|
||||
- **Recommend** - AI-powered suggestions based on your project
|
||||
- **Installed** - Manage installed skills (enable/disable/remove)
|
||||
- **Sync** - Sync skills across multiple agents
|
||||
- **Translate** - Convert skills between agent formats
|
||||
- **Workflow** - Manage and execute automation workflows
|
||||
- **Execute** - Run skills with checkpoints
|
||||
- **Plan** - Structured plan creation and execution
|
||||
- **Team** - Share skills and bundles with team members
|
||||
- **Context** - View detected stack and project context
|
||||
- **Memory** - Session memory and learnings
|
||||
- **Plugins** - Plugin management
|
||||
- **Methodology** - Development methodology frameworks
|
||||
- **Settings** - Configure SkillKit preferences
|
||||
|
||||
## Programmatic Usage
|
||||
|
||||
```typescript
|
||||
import { startTUI, TUIOptions } from '@skillkit/tui';
|
||||
import { startTUI } from '@skillkit/tui';
|
||||
|
||||
// Launch with defaults
|
||||
await startTUI();
|
||||
|
||||
// Launch with options
|
||||
await startTUI({
|
||||
projectPath: './my-project',
|
||||
initialScreen: 'browse',
|
||||
theme: 'dark',
|
||||
});
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
Built with:
|
||||
- **Ink** - React for CLIs
|
||||
- **OpenTUI** - High-performance terminal UI framework
|
||||
- **React** - Component architecture
|
||||
- **@skillkit/core** - Core functionality
|
||||
|
||||
```
|
||||
src/
|
||||
├── app.tsx # Main app component
|
||||
├── index.tsx # Entry point and startTUI
|
||||
├── App.tsx # Main app component
|
||||
├── screens/ # Screen components
|
||||
│ ├── Home.tsx
|
||||
│ ├── Browse.tsx
|
||||
│ ├── Recommend.tsx
|
||||
│ ├── Translate.tsx
|
||||
│ ├── Context.tsx
|
||||
│ ├── Help.tsx
|
||||
│ └── ...
|
||||
├── components/ # Reusable UI components
|
||||
│ ├── SkillCard.tsx
|
||||
│ ├── AgentSelector.tsx
|
||||
│ ├── Sidebar.tsx
|
||||
│ ├── Splash.tsx
|
||||
│ └── ...
|
||||
└── hooks/ # React hooks
|
||||
├── useSkills.ts
|
||||
├── useContext.ts
|
||||
└── ...
|
||||
├── state/ # State types and navigation
|
||||
├── theme/ # Colors and symbols
|
||||
└── utils/ # Helper functions
|
||||
```
|
||||
|
||||
## Terminal Requirements
|
||||
|
||||
- Minimum: 80x24 characters
|
||||
- Recommended: 120x40 characters
|
||||
- Supports: True Color, 256 colors, basic ANSI
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation: https://github.com/rohitg00/skillkit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@skillkit/tui",
|
||||
"version": "1.6.1",
|
||||
"description": "Terminal UI for SkillKit",
|
||||
"version": "2.0.0",
|
||||
"description": "Unified Terminal UI for SkillKit - Built on OpenTUI",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -21,24 +21,21 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "^1.6.0",
|
||||
"@skillkit/agents": "^1.6.0",
|
||||
"chalk": "^5.3.0",
|
||||
"ink": "^5.0.1",
|
||||
"ink-select-input": "^6.0.0",
|
||||
"ink-spinner": "^5.0.0",
|
||||
"ink-text-input": "^6.0.0",
|
||||
"react": "^18.3.1"
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@opentui/core": "^0.1.75",
|
||||
"@opentui/react": "^0.1.75",
|
||||
"react": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react": "^19.0.0",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
"bun": ">=1.2.0"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
||||
+87
-81
@@ -1,105 +1,111 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, Text, useInput, useApp, useStdout } from 'ink';
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, NAV_KEYS } from './state/types.js';
|
||||
import { Sidebar } from './components/Sidebar.js';
|
||||
import { Home } from './screens/Home.js';
|
||||
import { Browse } from './screens/Browse.js';
|
||||
import { Installed } from './screens/Installed.js';
|
||||
import { Sync } from './screens/Sync.js';
|
||||
import { Settings } from './screens/Settings.js';
|
||||
import { Recommend } from './screens/Recommend.js';
|
||||
import { Translate } from './screens/Translate.js';
|
||||
import { Context } from './screens/Context.js';
|
||||
import { Workflow } from './screens/Workflow.js';
|
||||
import { Execute } from './screens/Execute.js';
|
||||
import { History } from './screens/History.js';
|
||||
import { Marketplace } from './screens/Marketplace.js';
|
||||
import { Memory } from './screens/Memory.js';
|
||||
import { Team } from './screens/Team.js';
|
||||
import { Plugins } from './screens/Plugins.js';
|
||||
import { Methodology } from './screens/Methodology.js';
|
||||
import { Plan } from './screens/Plan.js';
|
||||
import { Splash } from './components/Splash.js';
|
||||
import {
|
||||
Home, Browse, Installed, Marketplace, Settings, Recommend,
|
||||
Translate, Context, Memory, Team, Plugins, Methodology,
|
||||
Plan, Workflow, Execute, History, Sync, Help,
|
||||
} from './screens/index.js';
|
||||
|
||||
export type Screen = 'home' | 'browse' | 'installed' | 'sync' | 'settings' | 'recommend' | 'translate' | 'context' | 'workflow' | 'execute' | 'history' | 'marketplace' | 'memory' | 'team' | 'plugins' | 'methodology' | 'plan';
|
||||
interface AppProps {
|
||||
onExit?: (code?: number) => void;
|
||||
}
|
||||
|
||||
export function App() {
|
||||
export function App({ onExit }: AppProps = {}) {
|
||||
const [showSplash, setShowSplash] = useState(true);
|
||||
const [screen, setScreen] = useState<Screen>('home');
|
||||
const { exit } = useApp();
|
||||
const { stdout } = useStdout();
|
||||
const [dimensions, setDimensions] = useState({
|
||||
cols: process.stdout.columns || 80,
|
||||
rows: process.stdout.rows || 24,
|
||||
});
|
||||
|
||||
const cols = stdout?.columns || 80;
|
||||
const rows = stdout?.rows || 24;
|
||||
const showSidebar = cols >= 70;
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setDimensions({
|
||||
cols: process.stdout.columns || 80,
|
||||
rows: process.stdout.rows || 24,
|
||||
});
|
||||
};
|
||||
process.stdout.on('resize', handleResize);
|
||||
return () => { process.stdout.off('resize', handleResize); };
|
||||
}, []);
|
||||
|
||||
const NAV_KEYS: Record<string, Screen> = {
|
||||
h: 'home',
|
||||
m: 'marketplace',
|
||||
b: 'browse',
|
||||
w: 'workflow',
|
||||
x: 'execute',
|
||||
y: 'history',
|
||||
r: 'recommend',
|
||||
t: 'translate',
|
||||
c: 'context',
|
||||
e: 'memory',
|
||||
i: 'installed',
|
||||
s: 'sync',
|
||||
a: 'team',
|
||||
p: 'plugins',
|
||||
o: 'methodology',
|
||||
n: 'plan',
|
||||
',': 'settings',
|
||||
};
|
||||
const { cols, rows } = dimensions;
|
||||
const showSidebar = cols >= 60;
|
||||
|
||||
useInput((input, key) => {
|
||||
if (input === 'q') {
|
||||
exit();
|
||||
const handleNavigate = useCallback((newScreen: Screen) => {
|
||||
setScreen(newScreen);
|
||||
}, []);
|
||||
|
||||
const handleSplashComplete = useCallback(() => {
|
||||
setShowSplash(false);
|
||||
}, []);
|
||||
|
||||
useKeyboard((key: { name?: string; ctrl?: boolean }) => {
|
||||
if (showSplash) {
|
||||
setShowSplash(false);
|
||||
return;
|
||||
}
|
||||
if (key.escape) {
|
||||
setScreen('home');
|
||||
|
||||
if (key.name === 'q' || (key.ctrl && key.name === 'c')) {
|
||||
onExit ? onExit(0) : process.exit(0);
|
||||
return;
|
||||
}
|
||||
const targetScreen = NAV_KEYS[input];
|
||||
|
||||
const targetScreen = NAV_KEYS[key.name || ''];
|
||||
if (targetScreen) {
|
||||
setScreen(targetScreen);
|
||||
}
|
||||
|
||||
if (key.name === 'escape' && screen !== 'home') {
|
||||
setScreen('home');
|
||||
}
|
||||
});
|
||||
|
||||
if (showSplash) {
|
||||
return <Splash onComplete={handleSplashComplete} duration={3000} />;
|
||||
}
|
||||
|
||||
const screenProps = {
|
||||
onNavigate: handleNavigate,
|
||||
cols: cols - (showSidebar ? 20 : 0),
|
||||
rows,
|
||||
};
|
||||
|
||||
const renderScreen = () => {
|
||||
switch (screen) {
|
||||
case 'home': return <Home onNavigate={setScreen} cols={cols} rows={rows} />;
|
||||
case 'browse': return <Browse cols={cols} rows={rows} />;
|
||||
case 'installed': return <Installed cols={cols} rows={rows} />;
|
||||
case 'sync': return <Sync cols={cols} rows={rows} />;
|
||||
case 'settings': return <Settings cols={cols} rows={rows} />;
|
||||
case 'recommend': return <Recommend cols={cols} rows={rows} />;
|
||||
case 'translate': return <Translate cols={cols} rows={rows} />;
|
||||
case 'context': return <Context cols={cols} rows={rows} />;
|
||||
case 'workflow': return <Workflow cols={cols} rows={rows} />;
|
||||
case 'execute': return <Execute cols={cols} rows={rows} />;
|
||||
case 'history': return <History cols={cols} rows={rows} />;
|
||||
case 'marketplace': return <Marketplace cols={cols} rows={rows} />;
|
||||
case 'memory': return <Memory cols={cols} rows={rows} />;
|
||||
case 'team': return <Team cols={cols} rows={rows} />;
|
||||
case 'plugins': return <Plugins cols={cols} rows={rows} />;
|
||||
case 'methodology': return <Methodology cols={cols} rows={rows} />;
|
||||
case 'plan': return <Plan cols={cols} rows={rows} />;
|
||||
case 'home': return <Home {...screenProps} />;
|
||||
case 'browse': return <Browse {...screenProps} />;
|
||||
case 'installed': return <Installed {...screenProps} />;
|
||||
case 'marketplace': return <Marketplace {...screenProps} />;
|
||||
case 'settings': return <Settings {...screenProps} />;
|
||||
case 'recommend': return <Recommend {...screenProps} />;
|
||||
case 'translate': return <Translate {...screenProps} />;
|
||||
case 'context': return <Context {...screenProps} />;
|
||||
case 'memory': return <Memory {...screenProps} />;
|
||||
case 'team': return <Team {...screenProps} />;
|
||||
case 'plugins': return <Plugins {...screenProps} />;
|
||||
case 'methodology': return <Methodology {...screenProps} />;
|
||||
case 'plan': return <Plan {...screenProps} />;
|
||||
case 'workflow': return <Workflow {...screenProps} />;
|
||||
case 'execute': return <Execute {...screenProps} />;
|
||||
case 'history': return <History {...screenProps} />;
|
||||
case 'sync': return <Sync {...screenProps} />;
|
||||
case 'help': return <Help {...screenProps} />;
|
||||
default: return <Home {...screenProps} />;
|
||||
}
|
||||
};
|
||||
|
||||
const contentHeight = rows - 2;
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" height={rows}>
|
||||
<Box flexDirection="row" height={contentHeight}>
|
||||
{showSidebar && <Sidebar screen={screen} onNavigate={setScreen} />}
|
||||
<Box flexDirection="column" flexGrow={1} marginLeft={1}>
|
||||
{renderScreen()}
|
||||
</Box>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text dimColor>h Home m Market b Browse w Wflow x Exec a Team p Plug o Meth n Plan r Rec t Trans c Ctx e Mem i Inst s Sync q Quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<box flexDirection="row" height={rows}>
|
||||
{showSidebar && <Sidebar screen={screen} onNavigate={handleNavigate} />}
|
||||
<box flexDirection="column" flexGrow={1} marginLeft={showSidebar ? 1 : 0} paddingRight={1}>
|
||||
{renderScreen()}
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export { type Screen };
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('TUI Components', () => {
|
||||
describe('exports', () => {
|
||||
it('should export App component', async () => {
|
||||
const { App } = await import('../App.js');
|
||||
expect(App).toBeDefined();
|
||||
expect(typeof App).toBe('function');
|
||||
});
|
||||
|
||||
it('should export theme configuration', async () => {
|
||||
const { colors, symbols } = await import('../theme.js');
|
||||
expect(colors).toBeDefined();
|
||||
expect(symbols).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export all screens', async () => {
|
||||
const screens = await import('../screens/index.js');
|
||||
expect(screens.Home).toBeDefined();
|
||||
expect(screens.Browse).toBeDefined();
|
||||
expect(screens.Installed).toBeDefined();
|
||||
expect(screens.Sync).toBeDefined();
|
||||
expect(screens.Settings).toBeDefined();
|
||||
expect(screens.Recommend).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export all hooks', async () => {
|
||||
const hooks = await import('../hooks/index.js');
|
||||
expect(hooks.useSkills).toBeDefined();
|
||||
expect(hooks.useMarketplace).toBeDefined();
|
||||
expect(hooks.useKeyboard).toBeDefined();
|
||||
expect(hooks.useRecommend).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
NAV_KEYS,
|
||||
SIDEBAR_NAV,
|
||||
STATUS_BAR_SHORTCUTS,
|
||||
type Screen,
|
||||
type SkillItem,
|
||||
} from '../state/types.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols, AGENT_LOGOS } from '../theme/symbols.js';
|
||||
import { getVersion, getSearchDirs, getInstallDir } from '../utils/helpers.js';
|
||||
|
||||
describe('@skillkit/tui', () => {
|
||||
describe('state/types', () => {
|
||||
it('should export NAV_KEYS with all screens', () => {
|
||||
expect(NAV_KEYS).toBeDefined();
|
||||
expect(NAV_KEYS.h).toBe('home');
|
||||
expect(NAV_KEYS.b).toBe('browse');
|
||||
expect(NAV_KEYS.m).toBe('marketplace');
|
||||
expect(NAV_KEYS['/']).toBe('help');
|
||||
expect(NAV_KEYS.q).toBeUndefined(); // q is quit, not a screen
|
||||
});
|
||||
|
||||
it('should export SIDEBAR_NAV with sections', () => {
|
||||
expect(SIDEBAR_NAV).toBeDefined();
|
||||
expect(Array.isArray(SIDEBAR_NAV)).toBe(true);
|
||||
expect(SIDEBAR_NAV.length).toBeGreaterThan(0);
|
||||
|
||||
const sections = SIDEBAR_NAV.map(s => s.section);
|
||||
expect(sections).toContain('Discover');
|
||||
expect(sections).toContain('Manage');
|
||||
expect(sections).toContain('Execute');
|
||||
});
|
||||
|
||||
it('should export STATUS_BAR_SHORTCUTS', () => {
|
||||
expect(STATUS_BAR_SHORTCUTS).toBeDefined();
|
||||
expect(STATUS_BAR_SHORTCUTS).toContain('browse');
|
||||
expect(STATUS_BAR_SHORTCUTS).toContain('help');
|
||||
expect(STATUS_BAR_SHORTCUTS).toContain('quit');
|
||||
});
|
||||
});
|
||||
|
||||
describe('theme/colors', () => {
|
||||
it('should export terminalColors', () => {
|
||||
expect(terminalColors).toBeDefined();
|
||||
expect(terminalColors.text).toBeDefined();
|
||||
expect(terminalColors.textMuted).toBeDefined();
|
||||
expect(terminalColors.accent).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('theme/symbols', () => {
|
||||
it('should export symbols', () => {
|
||||
expect(symbols).toBeDefined();
|
||||
expect(symbols.brandIcon).toBeDefined();
|
||||
expect(symbols.pointer).toBeDefined();
|
||||
expect(symbols.horizontalLine).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export AGENT_LOGOS', () => {
|
||||
expect(AGENT_LOGOS).toBeDefined();
|
||||
expect(AGENT_LOGOS['claude-code']).toBeDefined();
|
||||
expect(AGENT_LOGOS['claude-code'].name).toBe('Claude Code');
|
||||
});
|
||||
});
|
||||
|
||||
describe('utils/helpers', () => {
|
||||
it('should return version string', () => {
|
||||
const version = getVersion();
|
||||
expect(typeof version).toBe('string');
|
||||
expect(version.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should return search directories', () => {
|
||||
const dirs = getSearchDirs();
|
||||
expect(Array.isArray(dirs)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return install directory', () => {
|
||||
const dir = getInstallDir();
|
||||
expect(typeof dir).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* AgentGrid Component
|
||||
* Displays monochromatic agent logos in a grid layout
|
||||
*/
|
||||
import { AGENT_LOGOS, type AgentLogo } from '../theme/symbols.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface AgentGridProps {
|
||||
/** Maximum number of agents to display */
|
||||
maxVisible?: number;
|
||||
/** Show status indicators for detected agents */
|
||||
showStatus?: boolean;
|
||||
/** Agent types that are detected/active */
|
||||
detectedAgents?: string[];
|
||||
/** Number of columns in the grid */
|
||||
columns?: number;
|
||||
}
|
||||
|
||||
export function AgentGrid({
|
||||
maxVisible = 12,
|
||||
showStatus = true,
|
||||
detectedAgents = [],
|
||||
columns = 4,
|
||||
}: AgentGridProps) {
|
||||
const safeColumns = Math.max(1, columns);
|
||||
const allAgents = Object.entries(AGENT_LOGOS);
|
||||
const visibleAgents = allAgents.slice(0, maxVisible);
|
||||
const hiddenCount = allAgents.length - maxVisible;
|
||||
|
||||
const rows: [string, AgentLogo][][] = [];
|
||||
for (let i = 0; i < visibleAgents.length; i += safeColumns) {
|
||||
rows.push(visibleAgents.slice(i, i + safeColumns));
|
||||
}
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Works with</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
{rows.map((row, rowIndex) => (
|
||||
<box key={`row-${rowIndex}`} flexDirection="row">
|
||||
{row.map(([agentType, agent]) => {
|
||||
const isDetected = detectedAgents.includes(agentType);
|
||||
const statusIcon = showStatus ? (isDetected ? '●' : '○') : '';
|
||||
const fg = isDetected ? terminalColors.accent : terminalColors.text;
|
||||
|
||||
return (
|
||||
<box key={agentType} width={18}>
|
||||
<text fg={fg}>
|
||||
{agent.icon} {agent.name}
|
||||
{showStatus && (
|
||||
<span fg={isDetected ? terminalColors.success : terminalColors.textMuted}>
|
||||
{' '}{statusIcon}
|
||||
</span>
|
||||
)}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
{hiddenCount > 0 && (
|
||||
<text fg={terminalColors.textMuted}>+{hiddenCount} more agents</text>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* FeatureList Component
|
||||
* Colored feature keywords with descriptions
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface Feature {
|
||||
key: string;
|
||||
label: string;
|
||||
description: string;
|
||||
color: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
const FEATURES: Feature[] = [
|
||||
{ key: 'sync', label: 'Sync', color: 'sync', description: 'share skills across all your coding agents' },
|
||||
{ key: 'browse', label: 'Browse', color: 'browse', description: 'discover skills from the marketplace' },
|
||||
{ key: 'recommend', label: 'Recommend', color: 'recommend', description: 'AI-powered skill suggestions for your project' },
|
||||
{ key: 'translate', label: 'Translate', color: 'translate', description: 'convert skills between agent formats' },
|
||||
{ key: 'workflow', label: 'Workflow', color: 'workflow', description: 'automate skill execution chains' },
|
||||
{ key: 'team', label: 'Team', color: 'team', description: 'collaborate with your development team' },
|
||||
];
|
||||
|
||||
interface FeatureListProps {
|
||||
features?: Feature[];
|
||||
}
|
||||
|
||||
export function FeatureList({ features = FEATURES }: FeatureListProps) {
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}><b>Features</b></text>
|
||||
<text> </text>
|
||||
{features.map((feat) => (
|
||||
<box key={feat.key} flexDirection="row">
|
||||
<text fg={terminalColors[feat.color]}>
|
||||
<b>{' '}{feat.label.padEnd(12)}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.description}</text>
|
||||
</box>
|
||||
))}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export { FEATURES, type Feature };
|
||||
@@ -1,30 +1,35 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
/**
|
||||
* Header Component
|
||||
* Screen header with title and optional badge/count
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface HeaderProps {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
count?: number;
|
||||
badge?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export function Header({ title, subtitle, count }: HeaderProps) {
|
||||
export function Header({ title, subtitle, count, badge, icon }: HeaderProps) {
|
||||
return (
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
<Box justifyContent="space-between">
|
||||
<Text color={colors.primary} bold>
|
||||
{title.toUpperCase()}
|
||||
</Text>
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row" gap={2}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{icon && `${icon} `}{title}</b>
|
||||
</text>
|
||||
{count !== undefined && (
|
||||
<Text color={colors.secondaryDim}>
|
||||
{symbols.star} {count}
|
||||
</Text>
|
||||
<text fg={terminalColors.textMuted}>({count})</text>
|
||||
)}
|
||||
</Box>
|
||||
{badge && (
|
||||
<text fg={terminalColors.accent}>[{badge}]</text>
|
||||
)}
|
||||
</box>
|
||||
{subtitle && (
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
{subtitle}
|
||||
</Text>
|
||||
<text fg={terminalColors.textSecondary}>{subtitle}</text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* ProgressBar Component
|
||||
* Animated progress bar display
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface ProgressBarProps {
|
||||
progress: number; // 0-100
|
||||
width?: number;
|
||||
showPercentage?: boolean;
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
export function ProgressBar({
|
||||
progress,
|
||||
width = 20,
|
||||
showPercentage = true,
|
||||
color = 'accent',
|
||||
}: ProgressBarProps) {
|
||||
const clampedProgress = Math.max(0, Math.min(100, progress));
|
||||
const filledWidth = Math.round((clampedProgress / 100) * width);
|
||||
const emptyWidth = width - filledWidth;
|
||||
|
||||
const filled = symbols.progressFilled.repeat(filledWidth);
|
||||
const empty = symbols.progressEmpty.repeat(emptyWidth);
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text>
|
||||
<span fg={terminalColors[color]}>{filled}</span>
|
||||
<span fg={terminalColors.textMuted}>{empty}</span>
|
||||
</text>
|
||||
{showPercentage && (
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{Math.round(clampedProgress)}%
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,40 +1,29 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import TextInput from 'ink-text-input';
|
||||
import { colors } from '../theme.js';
|
||||
/**
|
||||
* SearchInput Component
|
||||
* Rounded search input with icon
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface SearchInputProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
placeholder?: string;
|
||||
isFocused?: boolean;
|
||||
focused?: boolean;
|
||||
onChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export function SearchInput({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = 'Search skills...',
|
||||
isFocused = false,
|
||||
placeholder = 'Search...',
|
||||
focused = false,
|
||||
}: SearchInputProps) {
|
||||
const display = value || placeholder;
|
||||
const textColor = value ? terminalColors.text : terminalColors.textMuted;
|
||||
|
||||
return (
|
||||
<Box
|
||||
borderStyle="single"
|
||||
borderColor={isFocused ? colors.primary : colors.borderDim}
|
||||
paddingX={1}
|
||||
>
|
||||
<Text color={colors.secondaryDim}>/ </Text>
|
||||
{isFocused ? (
|
||||
<TextInput
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
) : (
|
||||
<Text color={value ? colors.secondary : colors.secondaryDim}>
|
||||
{value || placeholder}
|
||||
</Text>
|
||||
)}
|
||||
<Box flexGrow={1} />
|
||||
<Text color={colors.secondaryDim}>/</Text>
|
||||
</Box>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>⌕ </text>
|
||||
<text fg={textColor}>{display}</text>
|
||||
{focused && <text fg={terminalColors.accent}>▏</text>}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,100 +1,44 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import type { Screen } from '../App.js';
|
||||
import { type Screen, SIDEBAR_NAV } from '../state/types.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
interface SidebarProps {
|
||||
screen: Screen;
|
||||
onNavigate: (screen: Screen) => void;
|
||||
isCompact?: boolean;
|
||||
}
|
||||
|
||||
const NAV: { id: Screen; label: string; key: string }[] = [
|
||||
// Discovery
|
||||
{ id: 'home', label: 'Home', key: 'h' },
|
||||
{ id: 'marketplace', label: 'Marketplace', key: 'm' },
|
||||
{ id: 'browse', label: 'Browse', key: 'b' },
|
||||
// Execution
|
||||
{ id: 'workflow', label: 'Workflows', key: 'w' },
|
||||
{ id: 'execute', label: 'Execute', key: 'x' },
|
||||
{ id: 'history', label: 'History', key: 'y' },
|
||||
// Collaboration
|
||||
{ id: 'team', label: 'Team', key: 'a' },
|
||||
{ id: 'plugins', label: 'Plugins', key: 'p' },
|
||||
// Methodology
|
||||
{ id: 'methodology', label: 'Methodology', key: 'o' },
|
||||
{ id: 'plan', label: 'Plans', key: 'n' },
|
||||
// Tools
|
||||
{ id: 'recommend', label: 'Recommend', key: 'r' },
|
||||
{ id: 'translate', label: 'Translate', key: 't' },
|
||||
{ id: 'context', label: 'Context', key: 'c' },
|
||||
{ id: 'memory', label: 'Memory', key: 'e' },
|
||||
// Management
|
||||
{ id: 'installed', label: 'Installed', key: 'i' },
|
||||
{ id: 'sync', label: 'Sync', key: 's' },
|
||||
{ id: 'settings', label: 'Config', key: ',' },
|
||||
];
|
||||
|
||||
export function Sidebar({ screen }: SidebarProps) {
|
||||
const version = getVersion();
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" width={14} borderStyle="single" paddingX={1}>
|
||||
<Text bold color={colors.primary}>SkillKit</Text>
|
||||
<box flexDirection="column" width={18} paddingRight={1}>
|
||||
<text fg={terminalColors.accent}>
|
||||
<b>{symbols.brandIcon} skillkit</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>v{version}</text>
|
||||
<text> </text>
|
||||
|
||||
{/* Discovery (0-2) */}
|
||||
{NAV.slice(0, 3).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
{SIDEBAR_NAV.map(({ section, items }, idx) => (
|
||||
<box key={section} flexDirection="column">
|
||||
{idx > 0 && <text> </text>}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<i>{section}</i>
|
||||
</text>
|
||||
{items.map((item) => {
|
||||
const active = screen === item.screen;
|
||||
return (
|
||||
<text key={item.key} fg={active ? terminalColors.accent : terminalColors.text}>
|
||||
{active ? <b>{symbols.pointer} {item.label}</b> : <>{symbols.pointerInactive} {item.label}</>}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Execution (3-5) */}
|
||||
{NAV.slice(3, 6).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Collaboration (6-7) */}
|
||||
{NAV.slice(6, 8).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Methodology (8-9) */}
|
||||
{NAV.slice(8, 10).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Tools (10-13) */}
|
||||
{NAV.slice(10, 14).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Management (14-16) */}
|
||||
{NAV.slice(14).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Box flexGrow={1} />
|
||||
|
||||
<Text dimColor>? Help</Text>
|
||||
<Text dimColor>q Quit</Text>
|
||||
</Box>
|
||||
<box flexGrow={1} />
|
||||
<text fg={terminalColors.textMuted}>{symbols.horizontalLine.repeat(14)}</text>
|
||||
<text fg={terminalColors.textMuted}>/ help q quit</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,103 +1,78 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
|
||||
export interface SkillItem {
|
||||
name: string;
|
||||
description?: string;
|
||||
source?: string;
|
||||
installs?: number;
|
||||
enabled?: boolean;
|
||||
}
|
||||
/**
|
||||
* SkillList Component
|
||||
* Paginated list of skills with selection
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
import { calculatePagination, type PaginationResult } from '../utils/list.js';
|
||||
import type { SkillItem } from '../state/types.js';
|
||||
|
||||
interface SkillListProps {
|
||||
skills: SkillItem[];
|
||||
selectedIndex: number;
|
||||
showInstalls?: boolean;
|
||||
showRank?: boolean;
|
||||
showSource?: boolean;
|
||||
maxVisible?: number;
|
||||
}
|
||||
|
||||
function formatInstalls(count: number): string {
|
||||
if (count >= 1000) {
|
||||
return `${(count / 1000).toFixed(1)}K`;
|
||||
}
|
||||
return String(count);
|
||||
onSelect?: (skill: SkillItem) => void;
|
||||
}
|
||||
|
||||
export function SkillList({
|
||||
skills,
|
||||
selectedIndex,
|
||||
showInstalls = false,
|
||||
showRank = false,
|
||||
showSource = true,
|
||||
maxVisible = 10,
|
||||
onSelect,
|
||||
}: SkillListProps) {
|
||||
if (skills.length === 0) {
|
||||
return (
|
||||
<Box>
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
No skills found
|
||||
</Text>
|
||||
</Box>
|
||||
<text fg={terminalColors.textMuted}>No skills found</text>
|
||||
);
|
||||
}
|
||||
|
||||
const startIndex = Math.max(0, selectedIndex - Math.floor(maxVisible / 2));
|
||||
const visibleSkills = skills.slice(startIndex, startIndex + maxVisible);
|
||||
const actualStartIndex = startIndex;
|
||||
const pagination = calculatePagination(skills.length, selectedIndex, maxVisible);
|
||||
const visibleSkills = skills.slice(pagination.start, pagination.end);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{showRank && (
|
||||
<Box marginBottom={1}>
|
||||
<Text color={colors.secondaryDim}>
|
||||
{' # SKILL'}
|
||||
{showSource && ' SOURCE'}
|
||||
{showInstalls && ' INSTALLS'}
|
||||
</Text>
|
||||
</Box>
|
||||
<box flexDirection="column">
|
||||
{/* Items above indicator */}
|
||||
{pagination.itemsAbove > 0 && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowUp} {pagination.itemsAbove} more above
|
||||
</text>
|
||||
)}
|
||||
|
||||
{/* Skill list */}
|
||||
{visibleSkills.map((skill, idx) => {
|
||||
const realIndex = actualStartIndex + idx;
|
||||
const isSelected = realIndex === selectedIndex;
|
||||
const skillName = skill.name.padEnd(28).slice(0, 28);
|
||||
const sourceName = skill.source ? skill.source.slice(0, 25) : '';
|
||||
const actualIndex = pagination.start + idx;
|
||||
const isSelected = actualIndex === selectedIndex;
|
||||
const pointer = isSelected ? symbols.pointer : symbols.pointerInactive;
|
||||
const fg = isSelected ? terminalColors.accent : terminalColors.text;
|
||||
const statusIcon = skill.enabled ? symbols.active : symbols.pending;
|
||||
const statusColor = skill.enabled
|
||||
? terminalColors.success
|
||||
: terminalColors.textMuted;
|
||||
|
||||
return (
|
||||
<Box key={`${skill.source}-${skill.name}`}>
|
||||
<Text
|
||||
color={isSelected ? colors.primary : colors.secondary}
|
||||
bold={isSelected}
|
||||
inverse={isSelected}
|
||||
>
|
||||
{isSelected ? symbols.pointer : ' '}
|
||||
{showRank ? String(realIndex + 1).padStart(2, ' ') : ''}
|
||||
{' '}
|
||||
{skillName}
|
||||
</Text>
|
||||
{showSource && (
|
||||
<Text color={colors.secondaryDim} dimColor={!isSelected}>
|
||||
{' '}{sourceName}
|
||||
</Text>
|
||||
<box key={skill.name} flexDirection="row">
|
||||
<text fg={fg}>
|
||||
{isSelected ? <b>{pointer} {skill.name}</b> : <>{pointer} {skill.name}</>}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{statusIcon}
|
||||
</text>
|
||||
{skill.description && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}- {skill.description.slice(0, 40)}
|
||||
{skill.description.length > 40 ? '...' : ''}
|
||||
</text>
|
||||
)}
|
||||
{showInstalls && skill.installs !== undefined && (
|
||||
<Text color={colors.secondaryDim}>
|
||||
{formatInstalls(skill.installs).padStart(8)}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
|
||||
{skills.length > maxVisible && (
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
Showing {startIndex + 1}-{Math.min(startIndex + maxVisible, skills.length)} of {skills.length}
|
||||
</Text>
|
||||
</Box>
|
||||
{/* Items below indicator */}
|
||||
{pagination.itemsBelow > 0 && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowDown} {pagination.itemsBelow} more below
|
||||
</text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Spinner Component
|
||||
* Loading indicator with animated frames
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface SpinnerProps {
|
||||
label?: string;
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
export function Spinner({ label, color = 'accent' }: SpinnerProps) {
|
||||
const [frame, setFrame] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setFrame((f) => (f + 1) % symbols.spinner.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text fg={terminalColors[color]}>{symbols.spinner[frame]}</text>
|
||||
{label && <text fg={terminalColors.text}>{label}</text>}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* Splash Component
|
||||
* Cinematic ASCII art intro with elegant animations
|
||||
* Premium terminal experience
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
// Premium ASCII art logo - clean geometric design
|
||||
const LOGO_FRAMES = [
|
||||
// Frame 1 - Dots appear
|
||||
[
|
||||
' ',
|
||||
' · · · · · · · · · · · · · · · ',
|
||||
' ',
|
||||
],
|
||||
// Frame 2 - Lines form
|
||||
[
|
||||
' ',
|
||||
' ━━━ ━ ━ ━ ━ ━ ━ ━ ━━━ ',
|
||||
' ',
|
||||
],
|
||||
// Frame 3 - Structure emerges
|
||||
[
|
||||
' ┌──┐ ┬ ┌─ ┬ ┬ ┬ ┬ ┌─ ┬ ┌─┐ ',
|
||||
' └──┐ │ │ │ │ │ │ │ │ │ ',
|
||||
' └──┘ ┴ └─ ┴ ┴─┘ ┴─┘ ┴ └─ ┴ ┴ ',
|
||||
],
|
||||
// Frame 4 - Bold letters
|
||||
[
|
||||
' ╔═╗ ╦╔═ ╦ ╦ ╦ ╦╔═ ╦╔╦╗ ',
|
||||
' ╚═╗ ╠╩╗ ║ ║ ║ ╠╩╗ ║ ║ ',
|
||||
' ╚═╝ ╩ ╩ ╩ ╩═╝ ╩═╝ ╩ ╩ ╩ ╩ ',
|
||||
],
|
||||
// Frame 5 - Final premium logo
|
||||
[
|
||||
' ███████╗██╗ ██╗██╗██╗ ██╗ ██╗ ██╗██╗████████╗',
|
||||
' ██╔════╝██║ ██╔╝██║██║ ██║ ██║ ██╔╝██║╚══██╔══╝',
|
||||
' ███████╗█████╔╝ ██║██║ ██║ █████╔╝ ██║ ██║ ',
|
||||
' ╚════██║██╔═██╗ ██║██║ ██║ ██╔═██╗ ██║ ██║ ',
|
||||
' ███████║██║ ██╗██║███████╗███████╗██║ ██╗██║ ██║ ',
|
||||
' ╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ',
|
||||
],
|
||||
];
|
||||
|
||||
// Compact logo for smaller terminals
|
||||
const LOGO_SMALL = [
|
||||
' ╔═╗╦╔═╦╦ ╦ ╦╔═╦╔╦╗ ',
|
||||
' ╚═╗╠╩╗║║ ║ ╠╩╗║ ║ ',
|
||||
' ╚═╝╩ ╩╩╩═╝╩═╝╩ ╩╩ ╩ ',
|
||||
];
|
||||
|
||||
// Elegant spinner frames
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
// Progress bar characters
|
||||
const PROGRESS = {
|
||||
empty: '░',
|
||||
filled: '█',
|
||||
head: '▓',
|
||||
};
|
||||
|
||||
// Loading phases with elegant messaging
|
||||
const PHASES = [
|
||||
{ message: 'Initializing', detail: 'skill engine' },
|
||||
{ message: 'Connecting', detail: 'agent network' },
|
||||
{ message: 'Loading', detail: 'skill manifests' },
|
||||
{ message: 'Syncing', detail: 'configurations' },
|
||||
{ message: 'Ready', detail: '' },
|
||||
];
|
||||
|
||||
interface SplashProps {
|
||||
onComplete: () => void;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export function Splash({ onComplete, duration = 3500 }: SplashProps) {
|
||||
const [frame, setFrame] = useState(0);
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [phase, setPhase] = useState(0);
|
||||
const [fadeIn, setFadeIn] = useState(0);
|
||||
const [particles, setParticles] = useState<string[]>([]);
|
||||
|
||||
// Cache version to avoid repeated sync file I/O on every render
|
||||
const version = useMemo(() => getVersion(), []);
|
||||
const cols = process.stdout.columns || 80;
|
||||
const rows = process.stdout.rows || 24;
|
||||
const useSmallLogo = cols < 70;
|
||||
const currentLogo = useSmallLogo ? LOGO_SMALL : (LOGO_FRAMES[Math.min(frame, 4)] || LOGO_FRAMES[4]);
|
||||
const maxWidth = Math.max(...currentLogo.map(l => l.length));
|
||||
|
||||
// Generate ambient particles - returns fresh randomized string each call
|
||||
const generateParticles = useCallback(() => {
|
||||
const chars = ['·', '∙', '•', '○', '◦', '◌', '◍', '◎'];
|
||||
return Array(cols).fill(0).map(() =>
|
||||
Math.random() > 0.97 ? chars[Math.floor(Math.random() * chars.length)] : ' '
|
||||
).join('');
|
||||
}, [cols]);
|
||||
|
||||
// Logo reveal animation
|
||||
useEffect(() => {
|
||||
if (frame >= 4) return;
|
||||
const timer = setTimeout(() => setFrame(f => f + 1), 200);
|
||||
return () => clearTimeout(timer);
|
||||
}, [frame]);
|
||||
|
||||
// Fade in effect
|
||||
useEffect(() => {
|
||||
if (fadeIn >= 10) return;
|
||||
const timer = setTimeout(() => setFadeIn(f => f + 1), 50);
|
||||
return () => clearTimeout(timer);
|
||||
}, [fadeIn]);
|
||||
|
||||
// Progress animation
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setProgress(p => {
|
||||
const newProgress = p + (Math.random() * 3 + 1);
|
||||
if (newProgress >= 100) {
|
||||
clearInterval(interval);
|
||||
return 100;
|
||||
}
|
||||
return newProgress;
|
||||
});
|
||||
}, 50);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
// Phase progression
|
||||
useEffect(() => {
|
||||
const phaseProgress = progress / 20;
|
||||
setPhase(Math.min(Math.floor(phaseProgress), PHASES.length - 1));
|
||||
}, [progress]);
|
||||
|
||||
// Spinner animation
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
// Particle animation
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setParticles(prev => {
|
||||
const newParticles = [...prev];
|
||||
if (newParticles.length > 3) newParticles.shift();
|
||||
newParticles.push(generateParticles());
|
||||
return newParticles;
|
||||
});
|
||||
}, 150);
|
||||
return () => clearInterval(interval);
|
||||
}, [generateParticles]);
|
||||
|
||||
// Auto-complete
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(onComplete, duration);
|
||||
return () => clearTimeout(timer);
|
||||
}, [onComplete, duration]);
|
||||
|
||||
const pad = ' '.repeat(Math.max(0, Math.floor((cols - maxWidth) / 2)));
|
||||
const progressWidth = Math.max(1, Math.min(40, cols - 20));
|
||||
const progressPad = ' '.repeat(Math.max(0, Math.floor((cols - progressWidth) / 2)));
|
||||
|
||||
const filledWidth = Math.min(Math.floor((progress / 100) * progressWidth), progressWidth);
|
||||
const emptyWidth = Math.max(0, progressWidth - filledWidth - 1);
|
||||
const progressBar = PROGRESS.filled.repeat(filledWidth) +
|
||||
(filledWidth < progressWidth ? PROGRESS.head : '') +
|
||||
PROGRESS.empty.repeat(emptyWidth);
|
||||
|
||||
const currentPhase = PHASES[phase];
|
||||
|
||||
return (
|
||||
<box flexDirection="column" height={rows}>
|
||||
{/* Top ambient particles */}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{particles[0] || ''}
|
||||
</text>
|
||||
|
||||
{/* Spacer */}
|
||||
<box flexGrow={1} />
|
||||
|
||||
{/* Logo */}
|
||||
<box flexDirection="column" alignItems="center">
|
||||
{currentLogo.map((line, idx) => (
|
||||
<text key={idx} fg={frame >= 4 ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{frame >= 4 ? <b>{pad}{line}</b> : <>{pad}{line}</>}
|
||||
</text>
|
||||
))}
|
||||
</box>
|
||||
|
||||
{/* Tagline with fade-in */}
|
||||
<text> </text>
|
||||
{fadeIn > 3 && (
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{pad}{' '}universal skills for ai coding agents
|
||||
</text>
|
||||
)}
|
||||
|
||||
{/* Version badge */}
|
||||
{fadeIn > 5 && (
|
||||
<>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{pad}{' '}v{version}
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Spacer */}
|
||||
<text> </text>
|
||||
<text> </text>
|
||||
|
||||
{/* Progress section */}
|
||||
{fadeIn > 7 && (
|
||||
<box flexDirection="column" alignItems="center">
|
||||
{/* Status line */}
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>
|
||||
{progressPad}{SPINNER[spinnerFrame]}{' '}
|
||||
</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{currentPhase.message}</b>
|
||||
</text>
|
||||
{currentPhase.detail && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{currentPhase.detail}
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
|
||||
{/* Progress bar */}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>{progressPad}[</text>
|
||||
<text fg={terminalColors.accent}>{progressBar}</text>
|
||||
<text fg={terminalColors.textMuted}>]</text>
|
||||
<text fg={terminalColors.textSecondary}>{' '}{Math.floor(progress)}%</text>
|
||||
</box>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Spacer */}
|
||||
<box flexGrow={1} />
|
||||
|
||||
{/* Bottom hint */}
|
||||
<box flexDirection="column" alignItems="center">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{progressPad}{' '}press any key to skip
|
||||
</text>
|
||||
<text> </text>
|
||||
{/* Bottom particles */}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{particles[1] || ''}
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user