mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-19 02:13:58 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7aa566d9b5 | ||
|
|
803ff5692a | ||
|
|
f036104c6d | ||
|
|
257fe9fbb6 | ||
|
|
a5efe29a6c | ||
|
|
6916c09962 | ||
|
|
41da423306 | ||
|
|
c5e78b7f83 | ||
|
|
438bc2720a | ||
|
|
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 | ||
|
|
131bc122be | ||
|
|
e35cd0d0df | ||
|
|
287dfeac58 | ||
|
|
32914cb8dc | ||
|
|
04c4faff6a | ||
|
|
d8a6b4a700 | ||
|
|
0518ed40a3 | ||
|
|
91e7ab3450 | ||
|
|
d62fe0b761 | ||
|
|
1344d65b3d | ||
|
|
9688959361 | ||
|
|
7805a5fd4b | ||
|
|
b34177ca85 | ||
|
|
2fa62e6863 | ||
|
|
64b802a1e6 | ||
|
|
d3ffb79512 | ||
|
|
b008a46b8d | ||
|
|
ed90080786 | ||
|
|
b701bb5f47 | ||
|
|
1c4c9a794f | ||
|
|
cb37ebeca7 | ||
|
|
7053d1a2b2 | ||
|
|
1ea5ddd4c7 | ||
|
|
720532c020 | ||
|
|
bc12775e0e | ||
|
|
cd64f7f7d0 | ||
|
|
ca9af70f10 | ||
|
|
160d2b1534 | ||
|
|
4a632e9262 |
@@ -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
|
||||
@@ -7,6 +7,7 @@ on:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
# Unit tests run on all Node versions
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -17,20 +18,73 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Type check
|
||||
run: npm run typecheck
|
||||
run: pnpm typecheck
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
run: pnpm build
|
||||
|
||||
- name: Test
|
||||
run: npm test
|
||||
- name: Unit Tests
|
||||
run: pnpm test
|
||||
|
||||
# E2E tests run on latest Node only (to save CI time)
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test # Run after unit tests pass
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Use Node.js 22
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: E2E Tests
|
||||
run: pnpm test:e2e
|
||||
|
||||
- name: Upload E2E Test Results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-test-results
|
||||
path: |
|
||||
e2e/**/*.log
|
||||
/tmp/skillkit-e2e-*
|
||||
retention-days: 7
|
||||
|
||||
# Final status check for branch protection
|
||||
ci-success:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test, e2e]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Check all jobs passed
|
||||
run: |
|
||||
if [[ "${{ needs.test.result }}" != "success" ]] || [[ "${{ needs.e2e.result }}" != "success" ]]; then
|
||||
echo "One or more jobs failed"
|
||||
exit 1
|
||||
fi
|
||||
echo "All CI checks passed!"
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
name: Publish to npm
|
||||
name: Publish to npm and GitHub Packages
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
publish-npm:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
@@ -16,24 +16,27 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache: 'pnpm'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
run: pnpm build
|
||||
|
||||
- name: Test
|
||||
run: npm test
|
||||
run: pnpm test
|
||||
|
||||
- name: Publish to npm
|
||||
run: npm publish --provenance --access public
|
||||
- name: Publish packages to npm
|
||||
run: pnpm -r publish --access public --no-git-checks
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
@@ -41,3 +44,64 @@ jobs:
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
generate_release_notes: true
|
||||
|
||||
publish-github-packages:
|
||||
runs-on: ubuntu-latest
|
||||
needs: publish-npm
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Setup Node.js for GitHub Packages
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'pnpm'
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
scope: '@rohitg00'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Configure npm for GitHub Packages
|
||||
run: |
|
||||
echo "@rohitg00:registry=https://npm.pkg.github.com" >> .npmrc
|
||||
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
||||
|
||||
- name: Publish main skillkit package to GitHub Packages
|
||||
working-directory: apps/skillkit
|
||||
run: |
|
||||
# Create a temporary package.json with GitHub Packages scope and resolved dependencies
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const pkg = require('./package.json');
|
||||
|
||||
pkg.name = '@rohitg00/skillkit';
|
||||
pkg.publishConfig = { registry: 'https://npm.pkg.github.com' };
|
||||
|
||||
// Resolve workspace:* dependencies to actual versions
|
||||
for (const [dep, version] of Object.entries(pkg.dependencies || {})) {
|
||||
if (version.startsWith('workspace:')) {
|
||||
const depName = dep.replace('@skillkit/', '');
|
||||
const depPkgPath = path.join('..', '..', 'packages', depName, 'package.json');
|
||||
const depPkg = JSON.parse(fs.readFileSync(depPkgPath, 'utf8'));
|
||||
pkg.dependencies[dep] = depPkg.version;
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
||||
"
|
||||
npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
+9
-2
@@ -29,7 +29,6 @@ npm-debug.log*
|
||||
|
||||
# Package manager
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
|
||||
# Temporary files
|
||||
tmp/
|
||||
@@ -56,4 +55,12 @@ temp/
|
||||
.agent/
|
||||
|
||||
# SkillKit config
|
||||
skillkit.yaml
|
||||
skillkit.yaml
|
||||
.skillkit/
|
||||
|
||||
# Turbo cache
|
||||
.turbo/
|
||||
|
||||
# Project documentation (not for version control)
|
||||
CLAUDE.md
|
||||
prd.md
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
# Contributing to SkillKit
|
||||
|
||||
Thank you for your interest in contributing to SkillKit! This document provides guidelines and instructions for contributing.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js 18+
|
||||
- pnpm 8+ (recommended) or npm/yarn
|
||||
- Git
|
||||
|
||||
### Setting Up the Development Environment
|
||||
|
||||
1. **Fork the repository**
|
||||
|
||||
Click the "Fork" button on GitHub to create your own copy.
|
||||
|
||||
2. **Clone your fork**
|
||||
|
||||
```bash
|
||||
git clone https://github.com/YOUR_USERNAME/skillkit.git
|
||||
cd skillkit
|
||||
```
|
||||
|
||||
3. **Install dependencies**
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
4. **Build the project**
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
5. **Run tests**
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
6. **Link for local development**
|
||||
|
||||
```bash
|
||||
cd apps/skillkit
|
||||
pnpm link --global
|
||||
```
|
||||
|
||||
Now you can use `skillkit` command globally to test your changes.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
skillkit/
|
||||
├── apps/
|
||||
│ └── skillkit/ # Main CLI entry point
|
||||
├── packages/
|
||||
│ ├── core/ # @skillkit/core - Shared logic
|
||||
│ │ ├── discovery/ # Skill discovery
|
||||
│ │ ├── parser/ # SKILL.md parsing
|
||||
│ │ ├── translator/ # Cross-agent translation
|
||||
│ │ ├── context/ # Project context sync
|
||||
│ │ └── recommend/ # Recommendation engine
|
||||
│ ├── cli/ # @skillkit/cli - Commands
|
||||
│ ├── tui/ # @skillkit/tui - Terminal UI
|
||||
│ └── agents/ # @skillkit/agents - Agent adapters
|
||||
├── docs/ # Documentation
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Branch Naming
|
||||
|
||||
Use descriptive branch names:
|
||||
|
||||
- `feature/skill-translation` - New features
|
||||
- `fix/cursor-adapter-path` - Bug fixes
|
||||
- `docs/api-reference` - Documentation
|
||||
- `refactor/core-types` - Code refactoring
|
||||
|
||||
### Making Changes
|
||||
|
||||
1. **Create a new branch**
|
||||
|
||||
```bash
|
||||
git checkout -b feature/your-feature-name
|
||||
```
|
||||
|
||||
2. **Make your changes**
|
||||
|
||||
- Follow the existing code style
|
||||
- Add tests for new functionality
|
||||
- Update documentation as needed
|
||||
|
||||
3. **Run checks locally**
|
||||
|
||||
```bash
|
||||
# Build all packages
|
||||
pnpm build
|
||||
|
||||
# Run tests
|
||||
pnpm test
|
||||
|
||||
# Type check
|
||||
pnpm typecheck
|
||||
|
||||
# Lint (if configured)
|
||||
pnpm lint
|
||||
```
|
||||
|
||||
4. **Commit your changes**
|
||||
|
||||
Write clear, descriptive commit messages:
|
||||
|
||||
```bash
|
||||
git commit -m "feat: add skill translation for Windsurf agent"
|
||||
git commit -m "fix: resolve path resolution in Windows"
|
||||
git commit -m "docs: add API reference for RecommendationEngine"
|
||||
```
|
||||
|
||||
We follow [Conventional Commits](https://www.conventionalcommits.org/):
|
||||
- `feat:` - New features
|
||||
- `fix:` - Bug fixes
|
||||
- `docs:` - Documentation changes
|
||||
- `refactor:` - Code refactoring
|
||||
- `test:` - Adding or updating tests
|
||||
- `chore:` - Maintenance tasks
|
||||
|
||||
5. **Push your branch**
|
||||
|
||||
```bash
|
||||
git push origin feature/your-feature-name
|
||||
```
|
||||
|
||||
6. **Open a Pull Request**
|
||||
|
||||
- Provide a clear description of the changes
|
||||
- Reference any related issues
|
||||
- Ensure CI checks pass
|
||||
|
||||
## Types of Contributions
|
||||
|
||||
### Bug Reports
|
||||
|
||||
When reporting bugs, please include:
|
||||
|
||||
- SkillKit version (`skillkit --version`)
|
||||
- Node.js version (`node --version`)
|
||||
- Operating system
|
||||
- Steps to reproduce
|
||||
- Expected vs actual behavior
|
||||
- Relevant error messages or logs
|
||||
|
||||
### Feature Requests
|
||||
|
||||
For feature requests, please describe:
|
||||
|
||||
- The problem you're trying to solve
|
||||
- Your proposed solution
|
||||
- Alternative approaches you've considered
|
||||
- Any relevant examples or mockups
|
||||
|
||||
### Adding New Agent Support
|
||||
|
||||
To add support for a new AI coding agent:
|
||||
|
||||
1. **Create an adapter** in `packages/agents/src/adapters/`
|
||||
|
||||
```typescript
|
||||
// packages/agents/src/adapters/new-agent.ts
|
||||
import type { AgentAdapter, Skill } from '../types.js';
|
||||
|
||||
export const newAgentAdapter: AgentAdapter = {
|
||||
type: 'new-agent',
|
||||
name: 'New Agent',
|
||||
configFile: 'AGENTS.md',
|
||||
skillsDir: '.new-agent/skills/',
|
||||
globalSkillsDir: '~/.new-agent/skills/',
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
// Generate config content
|
||||
},
|
||||
|
||||
detectPresence(): boolean {
|
||||
// Check if agent is present
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
2. **Register the adapter** in `packages/agents/src/adapters/index.ts`
|
||||
|
||||
3. **Add translator support** in `packages/core/src/translator/` if the agent uses a unique format
|
||||
|
||||
4. **Add tests** for the new adapter
|
||||
|
||||
5. **Update documentation**
|
||||
|
||||
### Adding New Skills
|
||||
|
||||
If you want to contribute skills to the ecosystem:
|
||||
|
||||
1. Follow the [Agent Skills specification](https://agentskills.io/specification)
|
||||
2. Include a `SKILL.md` with proper frontmatter
|
||||
3. Test with multiple agents using `skillkit translate`
|
||||
4. Submit to the appropriate skill repository
|
||||
|
||||
## Code Style
|
||||
|
||||
### TypeScript
|
||||
|
||||
- Use TypeScript for all new code
|
||||
- Define explicit types for function parameters and return values
|
||||
- Use interfaces for object shapes
|
||||
- Prefer `const` over `let`
|
||||
|
||||
### File Organization
|
||||
|
||||
- One export per file when possible
|
||||
- Group related functionality in directories
|
||||
- Use `index.ts` files for clean exports
|
||||
|
||||
### Testing
|
||||
|
||||
- Write unit tests for new functionality
|
||||
- Use descriptive test names
|
||||
- Test edge cases and error conditions
|
||||
|
||||
```typescript
|
||||
describe('RecommendationEngine', () => {
|
||||
it('should score skills based on framework match', () => {
|
||||
// Test implementation
|
||||
});
|
||||
|
||||
it('should return empty array when no skills match', () => {
|
||||
// Test implementation
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Pull Request Guidelines
|
||||
|
||||
### Before Submitting
|
||||
|
||||
- [ ] Code builds without errors (`pnpm build`)
|
||||
- [ ] All tests pass (`pnpm test`)
|
||||
- [ ] New code has appropriate test coverage
|
||||
- [ ] Documentation is updated if needed
|
||||
- [ ] Commit messages follow conventions
|
||||
|
||||
### PR Description Template
|
||||
|
||||
```markdown
|
||||
## Summary
|
||||
|
||||
Brief description of the changes.
|
||||
|
||||
## Changes
|
||||
|
||||
- Change 1
|
||||
- Change 2
|
||||
|
||||
## Testing
|
||||
|
||||
How were these changes tested?
|
||||
|
||||
## Related Issues
|
||||
|
||||
Fixes #123
|
||||
```
|
||||
|
||||
### Review Process
|
||||
|
||||
1. A maintainer will review your PR
|
||||
2. Address any requested changes
|
||||
3. Once approved, the PR will be merged
|
||||
|
||||
## Release Process
|
||||
|
||||
Releases are managed by maintainers. The process includes:
|
||||
|
||||
1. Version bump in package.json files
|
||||
2. Changelog update
|
||||
3. Git tag creation
|
||||
4. npm publish
|
||||
|
||||
## Getting Help
|
||||
|
||||
- **GitHub Issues**: For bugs and feature requests
|
||||
- **Discussions**: For questions and ideas
|
||||
- **Documentation**: Check the README and docs/
|
||||
|
||||
## License
|
||||
|
||||
By contributing to SkillKit, you agree that your contributions will be licensed under the Apache License 2.0.
|
||||
|
||||
---
|
||||
|
||||
Thank you for contributing to SkillKit!
|
||||
@@ -1,21 +1,190 @@
|
||||
MIT License
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Copyright (c) 2026 Rohit Ghumare
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
1. Definitions.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to the Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2025 Rohit Ghumare
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -1,382 +1,452 @@
|
||||
# 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/pkgs/npm/skillkit)
|
||||
[](https://github.com/rohitg00/skillkit/actions/workflows/ci.yml)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://rohitg00.github.io/skillkit/)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
Universal skills loader for AI coding agents. Install, manage, and sync skills across your favorite AI tools.
|
||||
## Supercharge Every AI Coding Agent
|
||||
|
||||
Skills follow the [Agent Skills](https://agentskills.io) open format—a simple, portable standard for giving agents new capabilities and expertise.
|
||||
**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.
|
||||
|
||||

|
||||
|
||||
## Interactive TUI
|
||||
|
||||
Manage all your skills with a beautiful terminal interface:
|
||||
|
||||
```bash
|
||||
skillkit ui
|
||||
# or simply
|
||||
skillkit
|
||||
```
|
||||
|
||||

|
||||
|
||||
**Features:**
|
||||
- Browse 33+ skill repositories
|
||||
- Install skills with one keystroke
|
||||
- Multi-agent installation support
|
||||
- View installed skills
|
||||
- Sync across agents
|
||||
- Responsive design for all terminal sizes
|
||||
|
||||
**Navigation:**
|
||||
- `h` Home | `b` Browse | `l` List | `s` Sync | `,` Config
|
||||
- `↑↓` Navigate | `Enter` Select | `Esc` Back | `q` Quit
|
||||
- `m` Multi-agent selection | `r` Refresh/Back
|
||||
|
||||
### Compatible With
|
||||
|
||||
| Agent | Status |
|
||||
|-------|--------|
|
||||
| Claude Code | ✅ Native |
|
||||
| OpenAI Codex | ✅ Native |
|
||||
| Cursor | ✅ Native |
|
||||
| Gemini CLI | ✅ Native |
|
||||
| OpenCode | ✅ Native |
|
||||
| Antigravity | ✅ Native |
|
||||
| Amp | ✅ Native |
|
||||
| Clawdbot | ✅ Native |
|
||||
| Droid (Factory) | ✅ Native |
|
||||
| GitHub Copilot | ✅ Native |
|
||||
| Goose | ✅ Native |
|
||||
| Kilo Code | ✅ Native |
|
||||
| Kiro CLI | ✅ Native |
|
||||
| Roo Code | ✅ Native |
|
||||
| Trae | ✅ Native |
|
||||
| Windsurf | ✅ Native |
|
||||
| *Any markdown-config agent* | ✅ Universal |
|
||||
|
||||
## Features
|
||||
|
||||
- **Interactive TUI**: Beautiful terminal interface for managing skills
|
||||
- **Multi-Agent Support**: Works with 17+ AI coding agents out of the box
|
||||
- **Multi-Platform Git**: GitHub, GitLab, Bitbucket, and local paths
|
||||
- **CI/CD Friendly**: Non-interactive flags for automation (`--skills`, `--all`, `--yes`)
|
||||
- **Skill Toggle**: Enable/disable skills without removing them
|
||||
- **Type-Safe**: Built with TypeScript and Zod validation
|
||||
- **Zero Config**: Auto-detects your agent and configures appropriately
|
||||
|
||||
## Installation
|
||||
> **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
|
||||
# or
|
||||
npx skillkit <command>
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
## Why SkillKit?
|
||||
|
||||
**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 solution:** SkillKit translates skills between all 17 agents automatically. Write once, use everywhere.
|
||||
|
||||
## See It In Action
|
||||
|
||||
```bash
|
||||
# Launch interactive TUI
|
||||
skillkit ui
|
||||
# Install a skill for ALL your agents at once
|
||||
skillkit install anthropics/skills --agent claude-code,cursor,windsurf
|
||||
|
||||
# Initialize in your project (auto-detects agent)
|
||||
skillkit init
|
||||
# Or translate existing skills between any agents
|
||||
skillkit translate my-skill --from claude --to cursor,codex,copilot
|
||||
|
||||
# Install skills from GitHub
|
||||
skillkit install owner/repo
|
||||
|
||||
# Install from GitLab
|
||||
skillkit install gitlab:owner/repo
|
||||
|
||||
# Install specific skills (CI/CD friendly)
|
||||
skillkit install owner/repo --skills=pdf,xlsx,docx
|
||||
|
||||
# Create a new skill
|
||||
skillkit create my-skill
|
||||
|
||||
# Sync skills to your agent config
|
||||
skillkit sync
|
||||
|
||||
# Read a skill (for AI consumption)
|
||||
skillkit read pdf
|
||||
# Get smart recommendations based on your project
|
||||
skillkit recommend
|
||||
# > 92% match: vercel-react-best-practices
|
||||
# > 87% match: tailwind-v4-patterns
|
||||
# > 85% match: nextjs-app-router
|
||||
```
|
||||
|
||||
## Popular Skill Repositories
|
||||

|
||||
|
||||
Install skills from these community repositories:
|
||||
## Beautiful CLI Experience
|
||||
|
||||
SkillKit features a polished, interactive CLI with visual feedback:
|
||||
|
||||
```
|
||||
███████╗██╗ ██╗██╗██╗ ██╗ ██╗ ██╗██╗████████╗
|
||||
██╔════╝██║ ██╔╝██║██║ ██║ ██║ ██╔╝██║╚══██╔══╝
|
||||
███████╗█████╔╝ ██║██║ ██║ █████╔╝ ██║ ██║
|
||||
╚════██║██╔═██╗ ██║██║ ██║ ██╔═██╗ ██║ ██║
|
||||
███████║██║ ██╗██║███████╗███████╗██║ ██╗██║ ██║
|
||||
╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝
|
||||
```
|
||||
|
||||
- **Adaptive Logo** - Full ASCII art on wide terminals, compact on narrow
|
||||
- **Agent Icons** - Visual indicators: ⟁ Claude · ◫ Cursor · ◎ Codex · ✦ Gemini · ⬡ OpenCode
|
||||
- **Interactive Selection** - Multi-select skills and agents with visual feedback
|
||||
- **Progress Indicators** - Step trails, spinners, and progress bars
|
||||
- **Smart Defaults** - Remembers your last selected agents
|
||||
|
||||
## What Makes SkillKit Different
|
||||
|
||||
| Feature | Without SkillKit | With SkillKit |
|
||||
|---------|-----------------|---------------|
|
||||
| **Multi-Agent Support** | Manual rewrite for each agent | One command, all agents |
|
||||
| **Team Collaboration** | Email skills back and forth | Git-based bundles, remote sync |
|
||||
| **Skill Discovery** | Search GitHub manually | Smart recommendations for your stack |
|
||||
| **Format Translation** | Learn each agent's format | Automatic conversion (17 formats) |
|
||||
| **Context Sync** | Configure each agent separately | One config, synced everywhere |
|
||||
| **Session Memory** | Knowledge dies with each session | Persistent learning across agents |
|
||||
| **Skill Testing** | Hope it works | Test framework with assertions |
|
||||
|
||||
## 5-Minute Quick Start
|
||||
|
||||
```bash
|
||||
# Anthropic's official skill marketplace
|
||||
# 1. Install SkillKit globally
|
||||
npm install -g skillkit
|
||||
|
||||
# 2. Launch the interactive TUI (easiest way to start)
|
||||
skillkit
|
||||
|
||||
# Or use CLI commands directly:
|
||||
|
||||
# 3. Get personalized skill recommendations
|
||||
skillkit recommend
|
||||
|
||||
# 4. Install skills from the marketplace
|
||||
skillkit install anthropics/skills
|
||||
|
||||
# Vercel's React & Next.js best practices
|
||||
skillkit install vercel-labs/agent-skills/skills
|
||||
```
|
||||
|
||||
| Repository | Skills | Description |
|
||||
|------------|--------|-------------|
|
||||
| [anthropics/skills](https://github.com/anthropics/skills) | `pdf`, `xlsx`, `docx`, etc. | Official Claude Code skill marketplace |
|
||||
| [vercel-labs/agent-skills](https://github.com/vercel-labs/agent-skills) | `vercel-react-best-practices`, `web-design-guidelines` | React/Next.js optimization & UI review |
|
||||
|
||||
|
||||
## Commands
|
||||
|
||||
### `skillkit ui` / `skillkit`
|
||||
|
||||
Launch the interactive Terminal User Interface (TUI) for managing skills.
|
||||
|
||||
```bash
|
||||
skillkit ui # Explicit TUI launch
|
||||
skillkit # Launch TUI if no arguments provided
|
||||
```
|
||||
|
||||
**TUI Features:**
|
||||
- **Browse**: Discover skills from 33+ repositories
|
||||
- **List**: View all installed skills
|
||||
- **Sync**: Sync skills across multiple agents
|
||||
- **Settings**: Configure SkillKit preferences
|
||||
|
||||
**Keyboard Shortcuts:**
|
||||
- `h` - Home screen
|
||||
- `b` - Browse skills marketplace
|
||||
- `l` - List installed skills
|
||||
- `s` - Sync skills across agents
|
||||
- `,` - Settings
|
||||
- `↑↓` - Navigate lists
|
||||
- `Enter` - Select / Install
|
||||
- `m` - Multi-agent selection (when viewing skills)
|
||||
- `r` - Refresh / Go back
|
||||
- `Esc` - Return to home
|
||||
- `q` - Quit
|
||||
|
||||
### `skillkit install <source>`
|
||||
|
||||
Install skills from various sources.
|
||||
|
||||
```bash
|
||||
# GitHub (default)
|
||||
skillkit install owner/repo
|
||||
skillkit install https://github.com/owner/repo
|
||||
|
||||
# Install from a subdirectory
|
||||
skillkit install owner/repo/skills
|
||||
|
||||
# GitLab
|
||||
skillkit install gitlab:owner/repo
|
||||
skillkit install https://gitlab.com/owner/repo
|
||||
|
||||
# Bitbucket
|
||||
skillkit install bitbucket:owner/repo
|
||||
|
||||
# Local path
|
||||
skillkit install ./my-skills
|
||||
skillkit install ~/dev/skills
|
||||
|
||||
# Options
|
||||
--list # List available skills without installing
|
||||
--skills=pdf,xlsx # Install specific skills only (CI/CD)
|
||||
--all # Install all discovered skills
|
||||
--yes # Skip confirmation prompts
|
||||
--global # Install to global directory
|
||||
--force # Overwrite existing skills
|
||||
--provider=gitlab # Force specific provider
|
||||
--agent=cursor # Install to specific agent (can specify multiple)
|
||||
```
|
||||
|
||||
### `skillkit sync`
|
||||
|
||||
Sync installed skills to your agent's config file.
|
||||
|
||||
```bash
|
||||
# 5. Sync to your AI agent
|
||||
skillkit sync
|
||||
skillkit sync --agent cursor
|
||||
skillkit sync --output AGENTS.md
|
||||
skillkit sync --enabled-only
|
||||
```
|
||||
|
||||
### `skillkit read <skills>`
|
||||
## Core Features
|
||||
|
||||
Read skill content for AI agent consumption.
|
||||
### Cross-Agent Translation
|
||||
|
||||
Use any skill with any agent. SkillKit automatically converts between formats:
|
||||
|
||||
```bash
|
||||
skillkit read pdf
|
||||
skillkit read pdf,xlsx,docx # Multiple skills
|
||||
# Translate a Claude skill to Cursor format
|
||||
skillkit translate react-patterns --to cursor
|
||||
|
||||
# Translate all your skills to a new agent
|
||||
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
|
||||
```
|
||||
|
||||
### `skillkit list`
|
||||
**Supported Agents:** Claude Code, Cursor, Codex, Gemini CLI, OpenCode, Antigravity, Amp, Clawdbot, Droid, GitHub Copilot, Goose, Kilo, Kiro, Roo, Trae, Windsurf, Universal
|
||||
|
||||
List all installed skills.
|
||||
### Smart Recommendations
|
||||
|
||||
SkillKit analyzes your project and suggests the perfect skills:
|
||||
|
||||
```bash
|
||||
skillkit list
|
||||
skillkit list --enabled
|
||||
skillkit list --json
|
||||
skillkit recommend
|
||||
|
||||
# Project: my-app (Next.js + TypeScript + Tailwind)
|
||||
#
|
||||
# Recommended Skills:
|
||||
# 92% vercel-react-best-practices
|
||||
# 87% tailwind-v4-patterns
|
||||
# 85% nextjs-app-router
|
||||
# 78% typescript-strict-mode
|
||||
```
|
||||
|
||||
### `skillkit enable/disable <skills>`
|
||||
|
||||
Toggle skills on/off without removing them.
|
||||
Filter by task, category, or minimum score:
|
||||
|
||||
```bash
|
||||
skillkit enable pdf xlsx
|
||||
skillkit disable docx
|
||||
skillkit recommend --search "auth" # Task-based search
|
||||
skillkit recommend --category security # Category filter
|
||||
skillkit recommend --min-score 80 # Quality threshold
|
||||
```
|
||||
|
||||
### `skillkit update [skills]`
|
||||
### Session Memory System
|
||||
|
||||
Update skills from their original sources.
|
||||
Your AI agents learn, but that knowledge dies with the session. SkillKit captures learnings and makes them persistent:
|
||||
|
||||
```bash
|
||||
skillkit update # Update all
|
||||
skillkit update pdf xlsx # Update specific
|
||||
# Compress session observations into reusable learnings
|
||||
skillkit memory compress
|
||||
|
||||
# Search past learnings
|
||||
skillkit memory search "authentication patterns"
|
||||
|
||||
# Export a learning as a shareable skill
|
||||
skillkit memory export auth-insight --output auth-patterns.md
|
||||
|
||||
# Share memory across projects
|
||||
skillkit memory --global
|
||||
```
|
||||
|
||||
### `skillkit remove <skills>`
|
||||
### Skill Marketplace
|
||||
|
||||
Remove installed skills.
|
||||
Browse and install from curated skill repositories:
|
||||
|
||||
```bash
|
||||
skillkit remove pdf xlsx
|
||||
# Browse all available skills
|
||||
skillkit marketplace
|
||||
|
||||
# Search for specific skills
|
||||
skillkit marketplace search "react hooks"
|
||||
|
||||
# Filter by tags
|
||||
skillkit marketplace --tags typescript,testing
|
||||
|
||||
# Refresh the skill index
|
||||
skillkit marketplace refresh
|
||||
```
|
||||
|
||||
### `skillkit init`
|
||||
### Interactive TUI
|
||||
|
||||
Initialize skillkit in a project.
|
||||
Beautiful terminal interface for visual skill management:
|
||||
|
||||
```bash
|
||||
skillkit init
|
||||
skillkit init --agent cursor
|
||||
skillkit init --list # List supported agents
|
||||
skillkit ui
|
||||
# or just
|
||||
skillkit
|
||||
```
|
||||
|
||||
### `skillkit validate <path>`
|
||||
**Navigation:** `h` Home | `b` Browse | `r` Recommend | `t` Translate | `c` Context | `l` List | `s` Sync | `q` Quit
|
||||
|
||||
Validate skills against the [Agent Skills specification](https://agentskills.io/specification).
|
||||
### Skill Testing Framework
|
||||
|
||||
Test your skills with built-in assertions:
|
||||
|
||||
```bash
|
||||
skillkit validate ./my-skill # Validate single skill
|
||||
skillkit validate ./skills --all # Validate all skills in directory
|
||||
# Run all skill tests
|
||||
skillkit test
|
||||
|
||||
# Test specific skills
|
||||
skillkit test ./my-skill
|
||||
|
||||
# Run tests with specific tags
|
||||
skillkit test --tags unit,integration
|
||||
|
||||
# JSON output for CI
|
||||
skillkit test --json
|
||||
```
|
||||
|
||||
### `skillkit create <skill-name>`
|
||||
### Workflow Orchestration
|
||||
|
||||
Create a new skill with proper structure and template.
|
||||
Compose skills into multi-step workflows:
|
||||
|
||||
```bash
|
||||
skillkit create my-skill # Basic skill
|
||||
skillkit create my-skill --full # Include all directories (references, scripts, assets)
|
||||
skillkit create my-skill --scripts # Include scripts directory
|
||||
skillkit create my-skill --references # Include references directory
|
||||
skillkit create my-skill --assets # Include assets directory
|
||||
skillkit create my-skill --dir ./skills # Create in specific directory
|
||||
# List available workflows
|
||||
skillkit workflow list
|
||||
|
||||
# Run a workflow
|
||||
skillkit workflow run feature-development
|
||||
|
||||
# Create new workflow
|
||||
skillkit workflow create my-workflow
|
||||
```
|
||||
|
||||
## Supported Agents
|
||||
### CI/CD Integration
|
||||
|
||||
| Agent | Config File | Project Path | Global Path |
|
||||
|-------|-------------|--------------|-------------|
|
||||
| Claude Code | `AGENTS.md` | `.claude/skills/` | `~/.claude/skills/` |
|
||||
| Cursor | `.cursorrules` | `.cursor/skills/` | `~/.cursor/skills/` |
|
||||
| Codex | `AGENTS.md` | `.codex/skills/` | `~/.codex/skills/` |
|
||||
| Gemini CLI | `GEMINI.md` | `.gemini/skills/` | `~/.gemini/skills/` |
|
||||
| OpenCode | `AGENTS.md` | `.opencode/skills/` | `~/.config/opencode/skills/` |
|
||||
| Antigravity | `AGENTS.md` | `.antigravity/skills/` | `~/.gemini/antigravity/skills/` |
|
||||
| Amp | `AGENTS.md` | `.agents/skills/` | `~/.config/agents/skills/` |
|
||||
| Clawdbot | `AGENTS.md` | `skills/` | `~/.clawdbot/skills/` |
|
||||
| Droid (Factory) | `AGENTS.md` | `.factory/skills/` | `~/.factory/skills/` |
|
||||
| GitHub Copilot | `AGENTS.md` | `.github/skills/` | `~/.copilot/skills/` |
|
||||
| Goose | `AGENTS.md` | `.goose/skills/` | `~/.config/goose/skills/` |
|
||||
| Kilo Code | `AGENTS.md` | `.kilocode/skills/` | `~/.kilocode/skills/` |
|
||||
| Kiro CLI | `AGENTS.md` | `.kiro/skills/` | `~/.kiro/skills/` |
|
||||
| Roo Code | `AGENTS.md` | `.roo/skills/` | `~/.roo/skills/` |
|
||||
| Trae | `AGENTS.md` | `.trae/skills/` | `~/.trae/skills/` |
|
||||
| Windsurf | `AGENTS.md` | `.windsurf/skills/` | `~/.codeium/windsurf/skills/` |
|
||||
| Universal | `AGENTS.md` | `.agent/skills/` | `~/.agent/skills/` |
|
||||
Generate CI/CD templates for automated skill management:
|
||||
|
||||
```bash
|
||||
# GitHub Actions
|
||||
skillkit cicd github-action
|
||||
|
||||
# GitLab CI
|
||||
skillkit cicd gitlab-ci
|
||||
|
||||
# Pre-commit hooks
|
||||
skillkit cicd pre-commit
|
||||
```
|
||||
|
||||
## Supported Agents (17)
|
||||
|
||||
| Agent | Format | Skills Directory |
|
||||
|-------|--------|------------------|
|
||||
| Claude Code | SKILL.md | `.claude/skills/` |
|
||||
| Cursor | MDC (.mdc) | `.cursor/skills/` |
|
||||
| Codex | SKILL.md | `.codex/skills/` |
|
||||
| Gemini CLI | SKILL.md | `.gemini/skills/` |
|
||||
| OpenCode | SKILL.md | `.opencode/skills/` |
|
||||
| Antigravity | SKILL.md | `.antigravity/skills/` |
|
||||
| Amp | SKILL.md | `.amp/skills/` |
|
||||
| Clawdbot | SKILL.md | `skills/` or `~/.clawdbot/skills/` |
|
||||
| Droid (Factory) | SKILL.md | `.factory/skills/` |
|
||||
| GitHub Copilot | Markdown | `.github/skills/` |
|
||||
| Goose | SKILL.md | `.goose/skills/` |
|
||||
| Kilo Code | SKILL.md | `.kilocode/skills/` |
|
||||
| Kiro CLI | SKILL.md | `.kiro/skills/` |
|
||||
| Roo Code | SKILL.md | `.roo/skills/` |
|
||||
| Trae | SKILL.md | `.trae/skills/` |
|
||||
| Windsurf | Markdown | `.windsurf/skills/` |
|
||||
| Universal | SKILL.md | `skills/` |
|
||||
|
||||
## All Commands
|
||||
|
||||
### Skill Management
|
||||
|
||||
```bash
|
||||
skillkit install <source> # Install skills from GitHub/GitLab/Bitbucket/local
|
||||
skillkit remove <skills> # Remove installed skills
|
||||
skillkit update [skills] # Update skills from source
|
||||
skillkit list # List installed skills
|
||||
skillkit enable <skills> # Enable specific skills
|
||||
skillkit disable <skills> # Disable specific skills
|
||||
skillkit sync # Sync skills to agent config
|
||||
skillkit read <skills> # Read skill content for AI
|
||||
```
|
||||
|
||||
### Discovery & Recommendations
|
||||
|
||||
```bash
|
||||
skillkit recommend # Get smart recommendations
|
||||
skillkit marketplace # Browse skill marketplace
|
||||
skillkit marketplace search # Search marketplace
|
||||
```
|
||||
|
||||
### Translation & Context
|
||||
|
||||
```bash
|
||||
skillkit translate # Translate between formats
|
||||
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
|
||||
skillkit memory status # View memory status
|
||||
skillkit memory search # Search learnings
|
||||
skillkit memory compress # Compress observations
|
||||
skillkit memory export # Export as skill
|
||||
```
|
||||
|
||||
### Testing & Workflows
|
||||
|
||||
```bash
|
||||
skillkit test # Run skill tests
|
||||
skillkit workflow run # Execute workflow
|
||||
skillkit cicd # Generate CI/CD templates
|
||||
```
|
||||
|
||||
### Utilities
|
||||
|
||||
```bash
|
||||
skillkit init # Initialize in project
|
||||
skillkit validate # Validate skill format
|
||||
skillkit create # Create new skill
|
||||
```
|
||||
|
||||
## Creating Skills
|
||||
|
||||
Use `skillkit create <name>` to scaffold a new skill, or create manually:
|
||||
### Quick Start
|
||||
|
||||
A skill is a directory with a `SKILL.md` file:
|
||||
|
||||
```
|
||||
my-skill/
|
||||
├── SKILL.md # Required: Instructions for the AI
|
||||
├── references/ # Optional: Documentation
|
||||
├── scripts/ # Optional: Helper scripts
|
||||
└── assets/ # Optional: Templates, configs
|
||||
```bash
|
||||
skillkit create my-skill
|
||||
```
|
||||
|
||||
### SKILL.md Format
|
||||
### Manual Creation
|
||||
|
||||
Follows the [Agent Skills specification](https://agentskills.io/specification):
|
||||
Create a `SKILL.md` file following the [Agent Skills specification](https://agentskills.io/specification):
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: my-skill
|
||||
description: What this skill does and when to use it. Include trigger keywords.
|
||||
description: What this skill does and when to use it
|
||||
license: MIT
|
||||
compatibility: Requires Node.js 18+
|
||||
metadata:
|
||||
author: your-org
|
||||
author: your-name
|
||||
version: "1.0"
|
||||
---
|
||||
|
||||
# My Skill
|
||||
|
||||
Instructions for the AI agent on how to use this skill.
|
||||
Instructions for the AI agent.
|
||||
|
||||
## When to Use
|
||||
|
||||
- Scenario 1
|
||||
- Scenario 2
|
||||
|
||||
## Steps
|
||||
|
||||
1. First step
|
||||
2. Second step
|
||||
```
|
||||
|
||||
| Field | Required | Description |
|
||||
|-------|----------|-------------|
|
||||
| `name` | Yes | Lowercase alphanumeric with hyphens (max 64 chars) |
|
||||
| `description` | Yes | What it does and when to use it (max 1024 chars) |
|
||||
| `license` | No | License name or reference |
|
||||
| `compatibility` | No | Environment requirements |
|
||||
| `metadata` | No | Arbitrary key-value pairs |
|
||||
|
||||
## CI/CD Usage
|
||||
|
||||
```yaml
|
||||
# GitHub Actions example
|
||||
- name: Setup skills
|
||||
run: |
|
||||
npx skillkit install owner/skills --skills=lint,test,deploy --yes
|
||||
npx skillkit sync --yes
|
||||
```
|
||||
|
||||
## Programmatic API
|
||||
|
||||
```typescript
|
||||
import {
|
||||
// Skill discovery
|
||||
findAllSkills,
|
||||
discoverSkills,
|
||||
detectAgent,
|
||||
getAdapter,
|
||||
|
||||
// Translation
|
||||
translateSkill,
|
||||
translateSkillFile,
|
||||
|
||||
// Recommendations
|
||||
RecommendationEngine,
|
||||
analyzeProject,
|
||||
|
||||
// Context
|
||||
ContextManager,
|
||||
syncToAllAgents,
|
||||
|
||||
// Memory
|
||||
createMemoryCompressor,
|
||||
createMemoryInjector,
|
||||
LearningStore,
|
||||
|
||||
// Marketplace
|
||||
createMarketplaceAggregator,
|
||||
|
||||
// Testing
|
||||
SkillTestRunner,
|
||||
|
||||
// Workflows
|
||||
WorkflowOrchestrator,
|
||||
} from 'skillkit';
|
||||
|
||||
// Find all installed skills
|
||||
const skills = findAllSkills(searchDirs);
|
||||
// Example: Translate and install
|
||||
const skill = await translateSkill(skillContent, 'cursor');
|
||||
console.log(skill.content);
|
||||
|
||||
// Detect current agent
|
||||
const agent = await detectAgent();
|
||||
// Example: Get recommendations
|
||||
const engine = new RecommendationEngine();
|
||||
const profile = await analyzeProject('./my-project');
|
||||
const recs = engine.recommend(profile);
|
||||
```
|
||||
|
||||
// Generate config
|
||||
const adapter = getAdapter(agent);
|
||||
const config = adapter.generateConfig(skills);
|
||||
## Popular Skill Repositories
|
||||
|
||||
| Repository | Description |
|
||||
|------------|-------------|
|
||||
| [anthropics/skills](https://github.com/anthropics/skills) | Official Claude Code marketplace - PDF, XLSX, DOCX processing |
|
||||
| [vercel-labs/agent-skills](https://github.com/vercel-labs/agent-skills) | React/Next.js best practices, web design guidelines |
|
||||
|
||||
## Installation Options
|
||||
|
||||
```bash
|
||||
# npm (recommended)
|
||||
npm install -g skillkit
|
||||
|
||||
# pnpm
|
||||
pnpm add -g skillkit
|
||||
|
||||
# yarn
|
||||
yarn global add skillkit
|
||||
|
||||
# bun
|
||||
bun add -g skillkit
|
||||
|
||||
# npx (no install)
|
||||
npx skillkit <command>
|
||||
|
||||
# GitHub Packages (alternative registry)
|
||||
npm install -g @rohitg00/skillkit --registry=https://npm.pkg.github.com
|
||||
```
|
||||
|
||||
## Configuration
|
||||
@@ -396,12 +466,15 @@ disabledSkills:
|
||||
|
||||
## License
|
||||
|
||||
MIT License - see [LICENSE](LICENSE) for details.
|
||||
Apache License 2.0 - see [LICENSE](LICENSE) for details.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions welcome! Please read our contributing guidelines.
|
||||
Contributions welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md).
|
||||
|
||||
## Acknowledgments
|
||||
## Links
|
||||
|
||||
Implements the [Agent Skills](https://agentskills.io) open format, originally developed by Anthropic and adopted by leading AI development tools.
|
||||
- [Agent Skills Specification](https://agentskills.io/specification)
|
||||
- [GitHub Repository](https://github.com/rohitg00/skillkit)
|
||||
- [NPM Package](https://www.npmjs.com/package/skillkit)
|
||||
- [GitHub Package](https://github.com/rohitg00/skillkit/pkgs/npm/skillkit)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
version: 1
|
||||
project:
|
||||
name: skillkit
|
||||
description: Universal skills loader for AI coding agents - supports Claude Code, Codex, Cursor, Antigravity, OpenCode, Gemini CLI and more
|
||||
type: cli
|
||||
path: /Users/rohitghumare/skillkit/apps/skillkit
|
||||
stack:
|
||||
languages:
|
||||
- name: typescript
|
||||
version: 5.7.2
|
||||
confidence: 100
|
||||
source: tsconfig.json
|
||||
frameworks: []
|
||||
libraries: []
|
||||
styling: []
|
||||
testing:
|
||||
- name: vitest
|
||||
version: 2.1.8
|
||||
confidence: 100
|
||||
source: package.json
|
||||
databases: []
|
||||
tools: []
|
||||
runtime:
|
||||
- name: nodejs
|
||||
version: 18.0.0
|
||||
confidence: 100
|
||||
source: package.json
|
||||
patterns:
|
||||
apiStyle: rest
|
||||
testing: vitest
|
||||
skills:
|
||||
installed: []
|
||||
recommended: []
|
||||
excluded: []
|
||||
autoSync: true
|
||||
securityLevel: medium
|
||||
testingRequired: false
|
||||
agents:
|
||||
detected: []
|
||||
synced: []
|
||||
disabled: []
|
||||
createdAt: 2026-01-23T00:02:29.727Z
|
||||
updatedAt: 2026-01-23T00:02:29.728Z
|
||||
@@ -0,0 +1,201 @@
|
||||
# SkillKit
|
||||
|
||||
Universal skills manager for AI coding agents. Install, manage, and sync skills across 17+ AI agents including Claude Code, Cursor, Codex, Gemini CLI, and more.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install -g skillkit
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Initialize skillkit in your project
|
||||
skillkit init
|
||||
|
||||
# Install skills from GitHub
|
||||
skillkit install anthropics/skills
|
||||
|
||||
# Get recommendations for your stack
|
||||
skillkit recommend
|
||||
|
||||
# Launch interactive TUI
|
||||
skillkit ui
|
||||
```
|
||||
|
||||
## Core Features
|
||||
|
||||
### Cross-Agent Translation
|
||||
|
||||
```bash
|
||||
# Translate a Claude skill to Cursor format
|
||||
skillkit translate react-patterns --to cursor
|
||||
|
||||
# Translate all skills to multiple agents
|
||||
skillkit translate --all --to windsurf,codex
|
||||
|
||||
# Preview translation
|
||||
skillkit translate my-skill --to copilot --dry-run
|
||||
```
|
||||
|
||||
### Smart Recommendations
|
||||
|
||||
```bash
|
||||
# Get project-aware suggestions
|
||||
skillkit recommend
|
||||
|
||||
# Filter by task
|
||||
skillkit recommend --search "authentication"
|
||||
|
||||
# Quality threshold
|
||||
skillkit recommend --min-score 85
|
||||
```
|
||||
|
||||
### Team Collaboration
|
||||
|
||||
```bash
|
||||
# Initialize team
|
||||
skillkit team init --name "Engineering Team"
|
||||
|
||||
# Create skill bundle
|
||||
skillkit team bundle-create
|
||||
|
||||
# Share with team
|
||||
skillkit team share onboarding-bundle
|
||||
|
||||
# Sync with remote registry
|
||||
skillkit team sync
|
||||
```
|
||||
|
||||
### Plugin System
|
||||
|
||||
```bash
|
||||
# List installed plugins
|
||||
skillkit plugin list
|
||||
|
||||
# Install custom plugin
|
||||
skillkit plugin install @company/custom-translator
|
||||
|
||||
# View plugin info
|
||||
skillkit plugin info my-plugin
|
||||
```
|
||||
|
||||
### Development Methodologies
|
||||
|
||||
```bash
|
||||
# List available methodologies
|
||||
skillkit methodology list
|
||||
|
||||
# Load TDD methodology
|
||||
skillkit methodology load tdd
|
||||
|
||||
# Apply to project
|
||||
skillkit methodology apply agile
|
||||
```
|
||||
|
||||
### Plan System
|
||||
|
||||
```bash
|
||||
# Parse and validate plan
|
||||
skillkit plan parse ./implementation-plan.md
|
||||
skillkit plan validate ./plan.md
|
||||
|
||||
# Execute plan
|
||||
skillkit plan execute ./feature-plan.md
|
||||
|
||||
# Check status
|
||||
skillkit plan status
|
||||
```
|
||||
|
||||
### Hooks & Automation
|
||||
|
||||
```bash
|
||||
# List hooks
|
||||
skillkit hook list
|
||||
|
||||
# Register pre-commit hook
|
||||
skillkit hook register pre-commit
|
||||
|
||||
# Trigger manually
|
||||
skillkit hook trigger pre-commit
|
||||
```
|
||||
|
||||
### Workflow Orchestration
|
||||
|
||||
```bash
|
||||
# List workflows
|
||||
skillkit workflow list
|
||||
|
||||
# Run workflow
|
||||
skillkit workflow run feature-development
|
||||
|
||||
# Create new workflow
|
||||
skillkit workflow create deployment-flow
|
||||
```
|
||||
|
||||
### Session Memory
|
||||
|
||||
```bash
|
||||
# View learnings
|
||||
skillkit memory list
|
||||
|
||||
# Search past sessions
|
||||
skillkit memory search "error handling"
|
||||
|
||||
# Compress observations
|
||||
skillkit memory compress
|
||||
|
||||
# Export learning as skill
|
||||
skillkit memory export auth-insight --output auth-skill.md
|
||||
```
|
||||
|
||||
## Supported Agents (17)
|
||||
|
||||
Claude Code, Cursor, Codex, Gemini CLI, Windsurf, GitHub Copilot, OpenCode, Antigravity, Amp, Clawdbot, Droid, Goose, Kilo, Kiro, Roo, Trae, Universal
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Install and Sync
|
||||
|
||||
```bash
|
||||
# Install to multiple agents
|
||||
skillkit install anthropics/skills --agent claude-code,cursor
|
||||
|
||||
# Sync all skills to detected agents
|
||||
skillkit sync --all
|
||||
```
|
||||
|
||||
### Context Management
|
||||
|
||||
```bash
|
||||
# Initialize project context
|
||||
skillkit context init
|
||||
|
||||
# View detected stack
|
||||
skillkit context show
|
||||
|
||||
# Sync to all agents
|
||||
skillkit context sync --all
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run all skill tests
|
||||
skillkit test
|
||||
|
||||
# Test specific skills
|
||||
skillkit test ./my-skill --tags unit
|
||||
|
||||
# CI/CD integration
|
||||
skillkit cicd init
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation: https://github.com/rohitg00/skillkit
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "skillkit",
|
||||
"version": "1.7.4",
|
||||
"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",
|
||||
"sk": "./dist/cli.js"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"schemas"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"keywords": [
|
||||
"ai",
|
||||
"skills",
|
||||
"claude",
|
||||
"codex",
|
||||
"cursor",
|
||||
"gemini",
|
||||
"opencode",
|
||||
"antigravity",
|
||||
"agent",
|
||||
"coding-assistant",
|
||||
"skill-loader",
|
||||
"cli"
|
||||
],
|
||||
"author": "Rohit Ghumare",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rohitg00/skillkit.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/rohitg00/skillkit/issues"
|
||||
},
|
||||
"homepage": "https://github.com/rohitg00/skillkit#readme",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@skillkit/cli": "workspace:*",
|
||||
"@skillkit/tui": "workspace:*",
|
||||
"clipanion": "^4.0.0-rc.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
describe('SkillKit CLI', () => {
|
||||
describe('build artifacts', () => {
|
||||
it('should have cli entry point', () => {
|
||||
const distPath = join(__dirname, '../../dist/cli.js');
|
||||
expect(existsSync(distPath)).toBe(true);
|
||||
});
|
||||
|
||||
it('should have index entry point', () => {
|
||||
const distPath = join(__dirname, '../../dist/index.js');
|
||||
expect(existsSync(distPath)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('package.json', () => {
|
||||
it('should have correct bin configuration', async () => {
|
||||
const packageJsonPath = join(__dirname, '../../package.json');
|
||||
expect(existsSync(packageJsonPath)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env node
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { Cli, Builtins } from 'clipanion';
|
||||
import {
|
||||
InstallCommand,
|
||||
SyncCommand,
|
||||
ReadCommand,
|
||||
ListCommand,
|
||||
EnableCommand,
|
||||
DisableCommand,
|
||||
UpdateCommand,
|
||||
RemoveCommand,
|
||||
InitCommand,
|
||||
ValidateCommand,
|
||||
CreateCommand,
|
||||
UICommand,
|
||||
TranslateCommand,
|
||||
ContextCommand,
|
||||
RecommendCommand,
|
||||
StatusCommand,
|
||||
PauseCommand,
|
||||
ResumeCommand,
|
||||
WorkflowRunCommand,
|
||||
WorkflowListCommand,
|
||||
WorkflowCreateCommand,
|
||||
RunCommand,
|
||||
TestCommand,
|
||||
MarketplaceCommand,
|
||||
MemoryCommand,
|
||||
SettingsCommand,
|
||||
CICDCommand,
|
||||
TeamCommand,
|
||||
PluginCommand,
|
||||
MethodologyCommand,
|
||||
HookCommand,
|
||||
PlanCommand,
|
||||
CommandCmd,
|
||||
AICommand,
|
||||
AuditCommand,
|
||||
PublishCommand,
|
||||
AgentCommand,
|
||||
AgentListCommand,
|
||||
AgentShowCommand,
|
||||
AgentCreateCommand,
|
||||
AgentTranslateCommand,
|
||||
AgentSyncCommand,
|
||||
AgentValidateCommand,
|
||||
} from '@skillkit/cli';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const packageJsonPath = join(__dirname, '../package.json');
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
||||
const version = packageJson.version || '1.2.0';
|
||||
|
||||
const cli = new Cli({
|
||||
binaryLabel: 'skillkit',
|
||||
binaryName: 'skillkit',
|
||||
binaryVersion: version,
|
||||
});
|
||||
|
||||
cli.register(Builtins.HelpCommand);
|
||||
cli.register(Builtins.VersionCommand);
|
||||
|
||||
cli.register(InstallCommand);
|
||||
cli.register(SyncCommand);
|
||||
cli.register(ReadCommand);
|
||||
cli.register(ListCommand);
|
||||
cli.register(EnableCommand);
|
||||
cli.register(DisableCommand);
|
||||
cli.register(UpdateCommand);
|
||||
cli.register(RemoveCommand);
|
||||
cli.register(InitCommand);
|
||||
cli.register(ValidateCommand);
|
||||
cli.register(CreateCommand);
|
||||
cli.register(UICommand);
|
||||
cli.register(TranslateCommand);
|
||||
cli.register(ContextCommand);
|
||||
cli.register(RecommendCommand);
|
||||
cli.register(StatusCommand);
|
||||
cli.register(PauseCommand);
|
||||
cli.register(ResumeCommand);
|
||||
cli.register(WorkflowRunCommand);
|
||||
cli.register(WorkflowListCommand);
|
||||
cli.register(WorkflowCreateCommand);
|
||||
cli.register(RunCommand);
|
||||
cli.register(TestCommand);
|
||||
cli.register(MarketplaceCommand);
|
||||
cli.register(MemoryCommand);
|
||||
cli.register(SettingsCommand);
|
||||
cli.register(CICDCommand);
|
||||
cli.register(TeamCommand);
|
||||
cli.register(PluginCommand);
|
||||
cli.register(MethodologyCommand);
|
||||
cli.register(HookCommand);
|
||||
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,6 @@
|
||||
// Re-export all public APIs from packages
|
||||
export * from '@skillkit/core';
|
||||
export * from '@skillkit/agents';
|
||||
|
||||
// Re-export TUI entry point
|
||||
export { startTUI } from '@skillkit/tui';
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"composite": false
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/cli.ts', 'src/index.ts'],
|
||||
format: ['esm'],
|
||||
dts: true,
|
||||
splitting: false,
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
});
|
||||
@@ -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,85 @@
|
||||
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>
|
||||
);
|
||||
|
||||
const NPM_ICON = (
|
||||
<svg className="w-5 h-5" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M0 7.334v8h6.666v1.332H12v-1.332h12v-8H0zm6.666 6.664H5.334v-4H3.999v4H1.335V8.667h5.331v5.331zm4 0v1.336H8.001V8.667h5.334v5.332h-2.669v-.001zm12.001 0h-1.33v-4h-1.336v4h-1.335v-4h-1.33v4h-2.671V8.667h8.002v5.331zM10.665 10H12v2.667h-1.335V10z" />
|
||||
</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-5xl 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://www.npmjs.com/package/skillkit"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="text-zinc-400 hover:text-red-500 transition-colors p-2"
|
||||
aria-label="npm"
|
||||
>
|
||||
{NPM_ICON}
|
||||
</a>
|
||||
<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>
|
||||
</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-5xl 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">
|
||||
<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">
|
||||
{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-5xl 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,210 @@
|
||||
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-5xl px-4 sm:px-6 lg:px-8 pt-8 pb-10 relative">
|
||||
<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.1</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">
|
||||
<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>
|
||||
|
||||
<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,458 @@
|
||||
/**
|
||||
* E2E Tests: Commands, Settings, and Advanced Features
|
||||
*
|
||||
* Tests for: command generate/export/merge, settings, memory, audit, ai, cicd
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
describe('E2E: Slash Commands', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'commands-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
createTestSkill(join(testDir, 'skills'), 'command-skill', {
|
||||
description: 'A skill for testing slash command generation',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit command generate', () => {
|
||||
it('should generate slash commands from skills', async () => {
|
||||
const result = await runCli(['command', 'generate'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('command') ||
|
||||
output.includes('generate') ||
|
||||
output.includes('slash') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should generate commands for specific agent', async () => {
|
||||
const result = await runCli(['command', 'generate', '--agent', 'claude-code'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should generate from natural language prompt', async () => {
|
||||
const result = await runCli(
|
||||
['command', 'generate', '--prompt', 'Create a command to run tests'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit command export', () => {
|
||||
it('should export generated commands', async () => {
|
||||
// Generate first
|
||||
await runCli(['command', 'generate'], { cwd: testDir });
|
||||
|
||||
const outputPath = join(testDir, 'commands-export');
|
||||
const result = await runCli(['command', 'export', '--output', outputPath], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export in different formats', async () => {
|
||||
await runCli(['command', 'generate'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['command', 'export', '--format', 'json'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit command merge', () => {
|
||||
it('should merge multiple command files', async () => {
|
||||
// Create two command files
|
||||
mkdirSync(join(testDir, 'commands'), { recursive: true });
|
||||
writeFileSync(
|
||||
join(testDir, 'commands', 'cmd1.json'),
|
||||
JSON.stringify({ commands: [{ name: 'test1' }] }, null, 2)
|
||||
);
|
||||
writeFileSync(
|
||||
join(testDir, 'commands', 'cmd2.json'),
|
||||
JSON.stringify({ commands: [{ name: 'test2' }] }, null, 2)
|
||||
);
|
||||
|
||||
const result = await runCli(
|
||||
[
|
||||
'command',
|
||||
'merge',
|
||||
join(testDir, 'commands', 'cmd1.json'),
|
||||
join(testDir, 'commands', 'cmd2.json'),
|
||||
],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Settings Management', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'settings-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit settings', () => {
|
||||
it('should show current settings', async () => {
|
||||
const result = await runCli(['settings'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('setting') ||
|
||||
output.includes('config') ||
|
||||
output.includes('No') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should set a configuration value', async () => {
|
||||
const result = await runCli(['settings', '--set', 'defaultAgent=claude-code'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should get a specific setting', async () => {
|
||||
await runCli(['settings', '--set', 'testKey=testValue'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['settings', '--get', 'testKey'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should unset a configuration value', async () => {
|
||||
await runCli(['settings', '--set', 'removeKey=value'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['settings', '--unset', 'removeKey'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const result = await runCli(['settings', '--json'], { cwd: testDir });
|
||||
if (result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('should reset all settings', async () => {
|
||||
const result = await runCli(['settings', '--reset'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Memory System', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'memory-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit memory', () => {
|
||||
it('should show memory status', async () => {
|
||||
const result = await runCli(['memory'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('memory') ||
|
||||
output.includes('session') ||
|
||||
output.includes('No') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should store observation', async () => {
|
||||
const result = await runCli(['memory', 'store', '--observation', 'User prefers TypeScript'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should retrieve memories', async () => {
|
||||
await runCli(['memory', 'store', '--observation', 'Test observation for retrieval'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
|
||||
const result = await runCli(['memory', 'retrieve'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should clear memory', async () => {
|
||||
const result = await runCli(['memory', 'clear'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should compress memory', async () => {
|
||||
// Store some memories
|
||||
await runCli(['memory', 'store', '--observation', 'Observation 1'], { cwd: testDir });
|
||||
await runCli(['memory', 'store', '--observation', 'Observation 2'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['memory', 'compress'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const result = await runCli(['memory', '--json'], { cwd: testDir });
|
||||
if (result.stdout.trim().startsWith('{') || result.stdout.trim().startsWith('[')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Audit System', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'audit-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
createTestSkill(join(testDir, 'skills'), 'audit-skill', {
|
||||
description: 'A skill for testing audit logging',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit audit', () => {
|
||||
it('should show audit log', async () => {
|
||||
// Perform some actions to generate audit entries
|
||||
await runCli(['list'], { cwd: testDir });
|
||||
await runCli(['sync', '--agent', 'claude-code'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['audit'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('audit') ||
|
||||
output.includes('log') ||
|
||||
output.includes('No') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should filter audit by date range', async () => {
|
||||
const result = await runCli(['audit', '--since', '2024-01-01'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should filter audit by action type', async () => {
|
||||
const result = await runCli(['audit', '--action', 'sync'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export audit log', async () => {
|
||||
const outputPath = join(testDir, 'audit-export.json');
|
||||
const result = await runCli(['audit', '--export', outputPath], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should clear audit log', async () => {
|
||||
const result = await runCli(['audit', '--clear'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: AI Features', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'ai-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit ai', () => {
|
||||
it('should show AI status', async () => {
|
||||
const result = await runCli(['ai'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('ai') ||
|
||||
output.includes('API') ||
|
||||
output.includes('status') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should configure AI provider', async () => {
|
||||
const result = await runCli(['ai', 'configure', '--provider', 'openai'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should test AI connection', async () => {
|
||||
const result = await runCli(['ai', 'test'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: CI/CD Integration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'cicd-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, '.git'), { recursive: true });
|
||||
writeFileSync(join(testDir, '.git', 'config'), '[core]');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit cicd init', () => {
|
||||
it('should generate GitHub Actions workflow', async () => {
|
||||
const result = await runCli(['cicd', 'init', '--provider', 'github'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('cicd') ||
|
||||
output.includes('github') ||
|
||||
output.includes('workflow') ||
|
||||
output.includes('created') ||
|
||||
testFileExists(testDir, '.github', 'workflows') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should generate GitLab CI config', async () => {
|
||||
const result = await runCli(['cicd', 'init', '--provider', 'gitlab'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should generate CircleCI config', async () => {
|
||||
const result = await runCli(['cicd', 'init', '--provider', 'circleci'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should support --dry-run', async () => {
|
||||
const result = await runCli(['cicd', 'init', '--provider', 'github', '--dry-run'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle unknown provider gracefully', async () => {
|
||||
const result = await runCli(['cicd', 'init', '--provider', 'unknown-ci'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('unknown') ||
|
||||
output.includes('not supported') ||
|
||||
output.includes('error') ||
|
||||
!result.success ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Workflow Commands', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'workflow-test',
|
||||
version: '1.0.0',
|
||||
scripts: {
|
||||
test: 'echo "test passed"',
|
||||
build: 'echo "build completed"',
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit workflow-create', () => {
|
||||
it('should create a new workflow', async () => {
|
||||
const result = await runCli(['workflow-create', '--name', 'test-workflow'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should create workflow with steps', async () => {
|
||||
const result = await runCli(
|
||||
['workflow-create', '--name', 'stepped-workflow', '--steps', 'build,test,deploy'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit workflow-list', () => {
|
||||
it('should list available workflows', async () => {
|
||||
const result = await runCli(['workflow-list'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit workflow-run', () => {
|
||||
it('should run a workflow', async () => {
|
||||
await runCli(['workflow-create', '--name', 'runnable-workflow'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['workflow-run', 'runnable-workflow'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should run workflow with --dry-run', async () => {
|
||||
const result = await runCli(['workflow-run', 'test', '--dry-run'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* E2E Tests: Core CLI Commands
|
||||
*
|
||||
* Tests for: init, list, install, enable, disable, remove, update, sync, read, validate
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
createTestProject,
|
||||
readTestFile,
|
||||
testFileExists,
|
||||
writeTestFile,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
describe('E2E: Core CLI Commands', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit --version', () => {
|
||||
it('should display version number', async () => {
|
||||
const result = await runCli(['--version']);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.stdout).toMatch(/\d+\.\d+\.\d+/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit --help', () => {
|
||||
it('should display help information', async () => {
|
||||
const result = await runCli(['--help']);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.stdout).toContain('skillkit');
|
||||
});
|
||||
|
||||
it('should list available commands', async () => {
|
||||
const result = await runCli(['--help']);
|
||||
expect(result.stdout + result.stderr).toMatch(/init|list|install|sync/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit init', () => {
|
||||
it('should initialize skillkit in a new project', async () => {
|
||||
const result = await runCli(['init'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Check for concrete successful outcome - any of these directories
|
||||
const hasSkillsDir = testFileExists(testDir, 'skills');
|
||||
const hasSkillkitDir = testFileExists(testDir, '.skillkit');
|
||||
const hasClaudeSkills = testFileExists(testDir, '.claude/skills');
|
||||
const hasAgentSkills = testFileExists(testDir, '.agent/skills');
|
||||
const hasAnyDir = hasSkillsDir || hasSkillkitDir || hasClaudeSkills || hasAgentSkills;
|
||||
|
||||
// Either a directory was created OR the command completed successfully with output
|
||||
if (!hasAnyDir && result.exitCode !== 0) {
|
||||
// Fail with debugging info
|
||||
expect.fail(`Init failed. Exit code: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasAnyDir || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should create skills directory structure', async () => {
|
||||
const result = await runCli(['init'], { cwd: testDir });
|
||||
|
||||
// Verify expected structure actually exists - any of these directories
|
||||
const hasSkillsDir = testFileExists(testDir, 'skills');
|
||||
const hasSkillkitDir = testFileExists(testDir, '.skillkit');
|
||||
const hasClaudeSkills = testFileExists(testDir, '.claude/skills');
|
||||
const hasAgentSkills = testFileExists(testDir, '.agent/skills');
|
||||
const hasAnySkillDir = hasSkillsDir || hasSkillkitDir || hasClaudeSkills || hasAgentSkills;
|
||||
|
||||
// Strict assertion - init should create at least one directory
|
||||
if (!hasAnySkillDir) {
|
||||
const output = result.stdout + result.stderr;
|
||||
expect.fail(`Init did not create expected directories.\nExit code: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasAnySkillDir).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit list', () => {
|
||||
it('should list no skills in empty project', async () => {
|
||||
const result = await runCli(['list'], { cwd: testDir });
|
||||
// Should complete without error even if no skills
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should list discovered skills', async () => {
|
||||
// Create some test skills
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'my-skill');
|
||||
createTestSkill(skillsDir, 'another-skill');
|
||||
|
||||
const result = await runCli(['list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should find the skills or report none
|
||||
expect(output.includes('my-skill') || output.includes('skill') || output.includes('0')).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it('should support --json output format', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'json-test-skill');
|
||||
|
||||
const result = await runCli(['list', '--json'], { cwd: testDir });
|
||||
// If JSON format is supported, output should be parseable
|
||||
if (result.stdout.trim().startsWith('[') || result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit read', () => {
|
||||
it('should read skill content', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'readable-skill', {
|
||||
content: 'This skill has specific content for reading.',
|
||||
});
|
||||
|
||||
const result = await runCli(['read', 'readable-skill'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should either show the skill or report not found
|
||||
expect(
|
||||
output.includes('readable-skill') ||
|
||||
output.includes('specific content') ||
|
||||
output.includes('not found') ||
|
||||
output.includes('No skill')
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle non-existent skill gracefully', async () => {
|
||||
const result = await runCli(['read', 'nonexistent-skill'], { cwd: testDir });
|
||||
// Should not crash, may report error
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit validate', () => {
|
||||
it('should validate a correct skill', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
const skillPath = createTestSkill(skillsDir, 'valid-skill', {
|
||||
description: 'A properly formatted skill with sufficient description length for validation',
|
||||
});
|
||||
|
||||
const result = await runCli(['validate', skillPath], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(output.includes('valid') || output.includes('success') || result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should report errors for invalid skill', async () => {
|
||||
const skillDir = join(testDir, 'invalid-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
// Create skill without frontmatter
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), '# No Frontmatter\n\nJust content.');
|
||||
|
||||
const result = await runCli(['validate', skillDir], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should report validation issues
|
||||
expect(
|
||||
output.includes('error') ||
|
||||
output.includes('invalid') ||
|
||||
output.includes('missing') ||
|
||||
!result.success
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should validate skill with all Agent Skills spec fields', async () => {
|
||||
const skillDir = join(testDir, 'full-spec-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(skillDir, 'SKILL.md'),
|
||||
`---
|
||||
name: full-spec-skill
|
||||
description: A skill that uses all Agent Skills specification fields for complete validation testing
|
||||
license: MIT
|
||||
compatibility: Node.js 18+, requires npm
|
||||
allowed-tools: Bash(npm:*) Read Write Edit
|
||||
metadata:
|
||||
author: test-org
|
||||
version: "1.0.0"
|
||||
tags:
|
||||
- testing
|
||||
- e2e
|
||||
---
|
||||
|
||||
# Full Spec Skill
|
||||
|
||||
This skill uses all available frontmatter fields.
|
||||
`
|
||||
);
|
||||
|
||||
const result = await runCli(['validate', skillDir], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should complete validation - either valid or show specific validation messages
|
||||
expect(
|
||||
result.success ||
|
||||
output.includes('valid') ||
|
||||
output.includes('full-spec-skill') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit enable/disable', () => {
|
||||
it('should enable a skill', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'toggle-skill');
|
||||
|
||||
const result = await runCli(['enable', 'toggle-skill'], { cwd: testDir });
|
||||
// Command should complete
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should disable a skill', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'toggle-skill');
|
||||
|
||||
// First enable, then disable
|
||||
await runCli(['enable', 'toggle-skill'], { cwd: testDir });
|
||||
const result = await runCli(['disable', 'toggle-skill'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit sync', () => {
|
||||
it('should sync skills to agent config', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'sync-test-skill');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should attempt sync operation
|
||||
expect(
|
||||
output.includes('sync') ||
|
||||
output.includes('claude') ||
|
||||
output.includes('skill') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit status', () => {
|
||||
it('should show current skillkit status', async () => {
|
||||
const result = await runCli(['status'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should show some status information
|
||||
expect(
|
||||
output.includes('status') ||
|
||||
output.includes('skill') ||
|
||||
output.includes('agent') ||
|
||||
output.includes('No') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit remove', () => {
|
||||
it('should remove an installed skill', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'removable-skill');
|
||||
|
||||
// First ensure it exists
|
||||
expect(testFileExists(testDir, 'skills', 'removable-skill', 'SKILL.md')).toBe(true);
|
||||
|
||||
const result = await runCli(['remove', 'removable-skill'], { cwd: testDir });
|
||||
// Command should complete
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,285 @@
|
||||
/**
|
||||
* E2E Test CLI Runner
|
||||
* Executes skillkit CLI commands and captures output for testing
|
||||
*/
|
||||
|
||||
import { spawn, execFileSync } from 'node:child_process';
|
||||
import { join, resolve, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { mkdirSync, rmSync, existsSync, writeFileSync, readFileSync, mkdtempSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
// ESM-compatible __dirname equivalent
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
export interface CliResult {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
success: boolean;
|
||||
duration: number;
|
||||
}
|
||||
|
||||
export interface RunOptions {
|
||||
cwd?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
timeout?: number;
|
||||
input?: string;
|
||||
}
|
||||
|
||||
const ROOT_DIR = resolve(__dirname, '../..');
|
||||
const CLI_PATH = join(ROOT_DIR, 'apps/skillkit/dist/cli.js');
|
||||
|
||||
/**
|
||||
* Run a skillkit CLI command and capture the result
|
||||
*/
|
||||
export async function runCli(args: string[], options: RunOptions = {}): Promise<CliResult> {
|
||||
const startTime = Date.now();
|
||||
const cwd = options.cwd || ROOT_DIR;
|
||||
const timeout = options.timeout || 30000;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const child = spawn('node', [CLI_PATH, ...args], {
|
||||
cwd,
|
||||
env: { ...process.env, ...options.env, NO_COLOR: '1', FORCE_COLOR: '0' },
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
});
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
let killed = false;
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
killed = true;
|
||||
child.kill('SIGTERM');
|
||||
}, timeout);
|
||||
|
||||
child.stdout?.on('data', (data) => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
|
||||
child.stderr?.on('data', (data) => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
if (options.input) {
|
||||
child.stdin?.write(options.input);
|
||||
child.stdin?.end();
|
||||
}
|
||||
|
||||
child.on('close', (code) => {
|
||||
clearTimeout(timeoutId);
|
||||
const duration = Date.now() - startTime;
|
||||
const exitCode = killed ? -1 : (code ?? 1);
|
||||
resolve({
|
||||
stdout,
|
||||
stderr,
|
||||
exitCode,
|
||||
success: exitCode === 0,
|
||||
duration,
|
||||
});
|
||||
});
|
||||
|
||||
child.on('error', (err) => {
|
||||
clearTimeout(timeoutId);
|
||||
const duration = Date.now() - startTime;
|
||||
resolve({
|
||||
stdout,
|
||||
stderr: stderr + err.message,
|
||||
exitCode: 1,
|
||||
success: false,
|
||||
duration,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Run skillkit CLI synchronously (for simpler tests)
|
||||
* Uses execFileSync to avoid shell injection vulnerabilities
|
||||
*/
|
||||
export function runCliSync(args: string[], options: RunOptions = {}): CliResult {
|
||||
const startTime = Date.now();
|
||||
const cwd = options.cwd || ROOT_DIR;
|
||||
|
||||
try {
|
||||
const result = execFileSync('node', [CLI_PATH, ...args], {
|
||||
cwd,
|
||||
env: { ...process.env, ...options.env, NO_COLOR: '1', FORCE_COLOR: '0' },
|
||||
encoding: 'utf-8',
|
||||
timeout: options.timeout || 30000,
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
});
|
||||
|
||||
return {
|
||||
stdout: result,
|
||||
stderr: '',
|
||||
exitCode: 0,
|
||||
success: true,
|
||||
duration: Date.now() - startTime,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
stdout: error.stdout || '',
|
||||
stderr: error.stderr || error.message,
|
||||
exitCode: error.status || 1,
|
||||
success: false,
|
||||
duration: Date.now() - startTime,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a temporary test directory
|
||||
*/
|
||||
export function createTestDir(prefix = 'skillkit-e2e-'): string {
|
||||
return mkdtempSync(join(tmpdir(), prefix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up a test directory
|
||||
*/
|
||||
export function cleanupTestDir(dir: string): void {
|
||||
if (existsSync(dir)) {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test skill in a directory
|
||||
*/
|
||||
export function createTestSkill(
|
||||
dir: string,
|
||||
name: string,
|
||||
options: {
|
||||
description?: string;
|
||||
content?: string;
|
||||
additionalFrontmatter?: Record<string, unknown>;
|
||||
} = {}
|
||||
): string {
|
||||
const skillDir = join(dir, name);
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
|
||||
const frontmatter: Record<string, unknown> = {
|
||||
name,
|
||||
description: options.description || `Test skill: ${name} for E2E testing`,
|
||||
...options.additionalFrontmatter,
|
||||
};
|
||||
|
||||
const frontmatterStr = Object.entries(frontmatter)
|
||||
.map(([key, value]) => {
|
||||
if (typeof value === 'object') {
|
||||
return `${key}:\n${Object.entries(value as Record<string, unknown>)
|
||||
.map(([k, v]) => ` ${k}: ${JSON.stringify(v)}`)
|
||||
.join('\n')}`;
|
||||
}
|
||||
return `${key}: ${value}`;
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
const content = `---
|
||||
${frontmatterStr}
|
||||
---
|
||||
|
||||
# ${name}
|
||||
|
||||
${options.content || `This is a test skill named ${name}.`}
|
||||
`;
|
||||
|
||||
writeFileSync(join(skillDir, 'SKILL.md'), content);
|
||||
return skillDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test project with common setup
|
||||
*/
|
||||
export function createTestProject(options: {
|
||||
withSkills?: boolean;
|
||||
skillCount?: number;
|
||||
withGit?: boolean;
|
||||
projectType?: 'node' | 'python' | 'rust' | 'go';
|
||||
} = {}): { dir: string; cleanup: () => void } {
|
||||
const dir = createTestDir();
|
||||
|
||||
if (options.withGit) {
|
||||
mkdirSync(join(dir, '.git'), { recursive: true });
|
||||
writeFileSync(join(dir, '.git', 'config'), '[core]\n\trepositoryformatversion = 0');
|
||||
}
|
||||
|
||||
if (options.projectType === 'node') {
|
||||
writeFileSync(
|
||||
join(dir, 'package.json'),
|
||||
JSON.stringify({ name: 'test-project', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
} else if (options.projectType === 'python') {
|
||||
writeFileSync(join(dir, 'requirements.txt'), 'pytest>=7.0.0\n');
|
||||
} else if (options.projectType === 'rust') {
|
||||
writeFileSync(join(dir, 'Cargo.toml'), '[package]\nname = "test"\nversion = "0.1.0"');
|
||||
} else if (options.projectType === 'go') {
|
||||
writeFileSync(join(dir, 'go.mod'), 'module test\n\ngo 1.21');
|
||||
}
|
||||
|
||||
if (options.withSkills) {
|
||||
const skillsDir = join(dir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
// Use nullish coalescing to respect explicit 0
|
||||
const count = options.skillCount ?? 3;
|
||||
for (let i = 1; i <= count; i++) {
|
||||
createTestSkill(skillsDir, `test-skill-${i}`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
dir,
|
||||
cleanup: () => cleanupTestDir(dir),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Read file content from test directory
|
||||
*/
|
||||
export function readTestFile(dir: string, ...paths: string[]): string {
|
||||
return readFileSync(join(dir, ...paths), 'utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists in test directory
|
||||
*/
|
||||
export function testFileExists(dir: string, ...paths: string[]): boolean {
|
||||
return existsSync(join(dir, ...paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write file in test directory
|
||||
*/
|
||||
export function writeTestFile(dir: string, path: string, content: string): void {
|
||||
const fullPath = join(dir, path);
|
||||
mkdirSync(join(fullPath, '..'), { recursive: true });
|
||||
writeFileSync(fullPath, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert CLI output contains expected text
|
||||
*/
|
||||
export function assertContains(result: CliResult, expected: string, message?: string): void {
|
||||
const combined = result.stdout + result.stderr;
|
||||
if (!combined.includes(expected)) {
|
||||
throw new Error(
|
||||
message || `Expected output to contain "${expected}"\nActual output:\n${combined}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert CLI output matches regex
|
||||
*/
|
||||
export function assertMatches(result: CliResult, pattern: RegExp, message?: string): void {
|
||||
const combined = result.stdout + result.stderr;
|
||||
if (!pattern.test(combined)) {
|
||||
throw new Error(
|
||||
message || `Expected output to match ${pattern}\nActual output:\n${combined}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* E2E Test Helpers - Barrel Export
|
||||
*/
|
||||
|
||||
export * from './cli-runner.js';
|
||||
@@ -0,0 +1,400 @@
|
||||
/**
|
||||
* E2E Tests: Hooks System and Agent Orchestration
|
||||
*
|
||||
* Tests for: hook register/list/trigger/remove, orchestrator commands
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
// Available hook events
|
||||
const HOOK_EVENTS = [
|
||||
'pre-commit',
|
||||
'post-commit',
|
||||
'file-change',
|
||||
'build',
|
||||
'test',
|
||||
'deploy',
|
||||
] as const;
|
||||
|
||||
describe('E2E: Hooks System', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
// Create a git repo structure for commit hooks
|
||||
mkdirSync(join(testDir, '.git', 'hooks'), { recursive: true });
|
||||
writeFileSync(join(testDir, '.git', 'config'), '[core]\n\trepositoryformatversion = 0');
|
||||
// Create project files
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'hooks-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
// Create a skill that can be triggered
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
createTestSkill(join(testDir, 'skills'), 'hookable-skill', {
|
||||
description: 'A skill that can be triggered by hooks for E2E testing',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit hook register', () => {
|
||||
it('should register a pre-commit hook', async () => {
|
||||
const result = await runCli(
|
||||
['hook', 'register', '--event', 'pre-commit', '--skill', 'hookable-skill'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Must have meaningful output about the registration
|
||||
const hasRelevantOutput =
|
||||
output.includes('register') ||
|
||||
output.includes('hook') ||
|
||||
output.includes('pre-commit') ||
|
||||
output.includes('success');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Hook registration failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should register hooks for all event types', async () => {
|
||||
for (const event of HOOK_EVENTS) {
|
||||
const result = await runCli(
|
||||
['hook', 'register', '--event', event, '--skill', 'hookable-skill'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
// Fail explicitly on timeout (-1 exit code)
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
// Command should complete (exit code 0 or 1 for expected behavior)
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
}
|
||||
});
|
||||
|
||||
it('should register hook with custom name', async () => {
|
||||
const result = await runCli(
|
||||
[
|
||||
'hook',
|
||||
'register',
|
||||
'--event',
|
||||
'test',
|
||||
'--skill',
|
||||
'hookable-skill',
|
||||
'--name',
|
||||
'my-test-hook',
|
||||
],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
// Fail explicitly on timeout
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
// Command should complete successfully or with expected exit
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should register hook with condition', async () => {
|
||||
const result = await runCli(
|
||||
[
|
||||
'hook',
|
||||
'register',
|
||||
'--event',
|
||||
'file-change',
|
||||
'--skill',
|
||||
'hookable-skill',
|
||||
'--pattern',
|
||||
'*.ts',
|
||||
],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
// Fail explicitly on timeout
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should handle invalid event gracefully', async () => {
|
||||
const result = await runCli(
|
||||
['hook', 'register', '--event', 'invalid-event', '--skill', 'hookable-skill'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should either fail or show an error message
|
||||
const showsError =
|
||||
output.includes('invalid') ||
|
||||
output.includes('unknown') ||
|
||||
output.includes('error') ||
|
||||
!result.success;
|
||||
|
||||
expect(showsError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit hook list', () => {
|
||||
it('should list registered hooks', async () => {
|
||||
// Register a hook first
|
||||
await runCli(['hook', 'register', '--event', 'build', '--skill', 'hookable-skill'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
|
||||
const result = await runCli(['hook', 'list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show hooks or indicate none
|
||||
const hasRelevantOutput =
|
||||
output.includes('hook') ||
|
||||
output.includes('build') ||
|
||||
output.includes('hookable-skill') ||
|
||||
output.includes('No');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Hook list failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const result = await runCli(['hook', 'list', '--json'], { cwd: testDir });
|
||||
if (result.stdout.trim().startsWith('[') || result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('should filter by event type', async () => {
|
||||
await runCli(['hook', 'register', '--event', 'test', '--skill', 'hookable-skill'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
|
||||
const result = await runCli(['hook', 'list', '--event', 'test'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit hook trigger', () => {
|
||||
it('should trigger a hook manually', async () => {
|
||||
await runCli(['hook', 'register', '--event', 'test', '--skill', 'hookable-skill'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
|
||||
const result = await runCli(['hook', 'trigger', 'test'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Fail explicitly on timeout
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
|
||||
// Should show trigger-related output
|
||||
const hasRelevantOutput =
|
||||
output.includes('trigger') ||
|
||||
output.includes('test') ||
|
||||
output.includes('hook') ||
|
||||
output.includes('executed');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Hook trigger failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should trigger with --dry-run', async () => {
|
||||
await runCli(['hook', 'register', '--event', 'deploy', '--skill', 'hookable-skill'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
|
||||
const result = await runCli(['hook', 'trigger', 'deploy', '--dry-run'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should handle missing hook gracefully', async () => {
|
||||
const result = await runCli(['hook', 'trigger', 'nonexistent-event'], { cwd: testDir });
|
||||
// Fail explicitly on timeout, should complete without crashing
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit hook remove', () => {
|
||||
it('should remove a registered hook', async () => {
|
||||
// Register then remove
|
||||
await runCli(
|
||||
['hook', 'register', '--event', 'build', '--skill', 'hookable-skill', '--name', 'my-hook'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
|
||||
const result = await runCli(['hook', 'remove', 'my-hook'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show removal confirmation
|
||||
const hasRelevantOutput =
|
||||
output.includes('remove') ||
|
||||
output.includes('my-hook') ||
|
||||
output.includes('success');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Hook remove failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should remove all hooks for an event', async () => {
|
||||
await runCli(['hook', 'register', '--event', 'test', '--skill', 'hookable-skill'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
|
||||
const result = await runCli(['hook', 'remove', '--event', 'test', '--all'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Agent Orchestration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'orchestration-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
createTestSkill(join(testDir, 'skills'), 'orchestrated-skill', {
|
||||
description: 'A skill for testing multi-agent orchestration features',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('multi-agent sync', () => {
|
||||
it('should sync to multiple agents simultaneously', async () => {
|
||||
const result = await runCli(['sync', '--agents', 'claude-code,cursor,windsurf'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should sync to all supported agents', async () => {
|
||||
const result = await runCli(['sync', '--all-agents'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('team orchestration', () => {
|
||||
it('should configure team with leader and teammates', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(
|
||||
['team', 'init', '--leader', 'claude-code', '--teammates', 'cursor,windsurf'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should delegate tasks to team members', async () => {
|
||||
await runCli(['team', 'init', '--leader', 'claude-code'], { cwd: testDir });
|
||||
|
||||
// This tests the delegation feature if available
|
||||
const result = await runCli(['team', 'sync', '--delegate'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('workflow integration', () => {
|
||||
it('should trigger hooks during workflow execution', async () => {
|
||||
// Register a build hook
|
||||
await runCli(
|
||||
['hook', 'register', '--event', 'build', '--skill', 'orchestrated-skill'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
|
||||
// Run workflow that triggers build
|
||||
const result = await runCli(['workflow', 'run', 'build'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should chain multiple hooks in sequence', async () => {
|
||||
await runCli(['hook', 'register', '--event', 'test', '--skill', 'orchestrated-skill'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
await runCli(
|
||||
['hook', 'register', '--event', 'build', '--skill', 'orchestrated-skill', '--after', 'test'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
|
||||
const result = await runCli(['hook', 'trigger', 'test', '--chain'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Hook + Skill Integration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
mkdirSync(join(testDir, '.git', 'hooks'), { recursive: true });
|
||||
writeFileSync(join(testDir, '.git', 'config'), '[core]');
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
|
||||
// Create a skill with specific trigger configuration
|
||||
const skillDir = join(testDir, 'skills', 'auto-trigger-skill');
|
||||
mkdirSync(skillDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(skillDir, 'SKILL.md'),
|
||||
`---
|
||||
name: auto-trigger-skill
|
||||
description: A skill that auto-triggers on specific events for E2E testing
|
||||
triggers:
|
||||
- event: pre-commit
|
||||
- event: file-change
|
||||
pattern: "*.ts"
|
||||
---
|
||||
|
||||
# Auto-Trigger Skill
|
||||
|
||||
This skill automatically activates on:
|
||||
- Pre-commit hooks
|
||||
- TypeScript file changes
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
it('should auto-register hooks from skill metadata', async () => {
|
||||
const result = await runCli(['hook', 'auto-register'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should detect and apply skill triggers', async () => {
|
||||
const result = await runCli(['sync', '--with-hooks'], { cwd: testDir });
|
||||
expect(result.exitCode).not.toBe(-1);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,424 @@
|
||||
/**
|
||||
* E2E Tests: Methodology and Plan System
|
||||
*
|
||||
* Tests for: methodology list/load/apply/validate, plan create/validate/execute/list/status
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
writeTestFile,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
// Available methodology packs
|
||||
const METHODOLOGY_PACKS = [
|
||||
'agile',
|
||||
'tdd',
|
||||
'devops',
|
||||
'security-first',
|
||||
'documentation-first',
|
||||
] as const;
|
||||
|
||||
describe('E2E: Methodology Framework', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
// Create a basic project structure
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'test-project', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, 'src'), { recursive: true });
|
||||
writeFileSync(join(testDir, 'src', 'index.ts'), 'export const main = () => {};\n');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit methodology list', () => {
|
||||
it('should list available methodology packs', async () => {
|
||||
const result = await runCli(['methodology', 'list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Must complete successfully and show relevant output
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
// Should contain methodology-related content
|
||||
const hasRelevantOutput =
|
||||
output.includes('methodology') ||
|
||||
output.includes('agile') ||
|
||||
output.includes('tdd') ||
|
||||
output.includes('No');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Methodology list failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const result = await runCli(['methodology', 'list', '--json'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
if (result.stdout.trim().startsWith('[') || result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('should show methodology details with --verbose', async () => {
|
||||
const result = await runCli(['methodology', 'list', '--verbose'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit methodology install', () => {
|
||||
describe.each(METHODOLOGY_PACKS)('loading %s methodology', (pack) => {
|
||||
it(`should load ${pack} methodology pack`, async () => {
|
||||
const result = await runCli(['methodology', 'install', pack], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Command should complete
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
// Should have relevant output
|
||||
const hasRelevantOutput =
|
||||
output.includes(pack) ||
|
||||
output.includes('installed') ||
|
||||
output.includes('success') ||
|
||||
output.includes('methodology');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Load ${pack} failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle unknown methodology gracefully', async () => {
|
||||
const result = await runCli(['methodology', 'install', 'nonexistent-methodology'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show error or fail
|
||||
const showsError =
|
||||
output.includes('not found') ||
|
||||
output.includes('unknown') ||
|
||||
output.includes('error') ||
|
||||
!result.success;
|
||||
|
||||
expect(showsError).toBe(true);
|
||||
});
|
||||
|
||||
it('should load multiple methodologies', async () => {
|
||||
const result = await runCli(['methodology', 'install', 'tdd', 'security-first'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit methodology sync', () => {
|
||||
it('should sync installed methodology to project', async () => {
|
||||
// Install a methodology first
|
||||
await runCli(['methodology', 'install', 'tdd'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['methodology', 'sync'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('sync') ||
|
||||
output.includes('tdd') ||
|
||||
output.includes('skill') ||
|
||||
output.includes('success');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Sync methodology failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should sync specific methodology', async () => {
|
||||
const result = await runCli(['methodology', 'sync', 'agile'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit methodology info', () => {
|
||||
it('should show methodology information', async () => {
|
||||
await runCli(['methodology', 'install', 'tdd'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['methodology', 'info', 'tdd'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('info') ||
|
||||
output.includes('tdd') ||
|
||||
output.includes('methodology') ||
|
||||
output.includes('description');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Methodology info failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should show info for specific methodology', async () => {
|
||||
const result = await runCli(['methodology', 'info', 'security-first'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Plan System', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'plan-test-project', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, 'src'), { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit plan create', () => {
|
||||
it('should create a new plan', async () => {
|
||||
const result = await runCli(['plan', 'create', '--name', 'test-plan'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('plan') ||
|
||||
output.includes('test-plan') ||
|
||||
output.includes('created');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Plan create failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should create plan with description', async () => {
|
||||
const result = await runCli(
|
||||
['plan', 'create', '--name', 'described-plan', '--description', 'A test plan for E2E'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should create plan from template', async () => {
|
||||
const result = await runCli(
|
||||
['plan', 'create', '--name', 'template-plan', '--template', 'feature'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should create plan with steps', async () => {
|
||||
const result = await runCli(
|
||||
[
|
||||
'plan',
|
||||
'create',
|
||||
'--name',
|
||||
'stepped-plan',
|
||||
'--steps',
|
||||
'Step 1: Setup,Step 2: Implement,Step 3: Test',
|
||||
],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plan templates', () => {
|
||||
it('should list available plan templates', async () => {
|
||||
const result = await runCli(['plan', 'templates'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('template') ||
|
||||
output.includes('plan') ||
|
||||
output.includes('available') ||
|
||||
output.includes('No');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Plan templates failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const result = await runCli(['plan', 'templates', '--json'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
if (result.stdout.trim().startsWith('[') || result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plan validate', () => {
|
||||
it('should validate plan structure', async () => {
|
||||
// Create a plan
|
||||
await runCli(['plan', 'create', '--name', 'validate-plan'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plan', 'validate', 'validate-plan'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('valid') ||
|
||||
output.includes('validate') ||
|
||||
output.includes('plan');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Plan validate failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should report validation errors', async () => {
|
||||
// Create an invalid plan file manually
|
||||
const plansDir = join(testDir, '.skillkit', 'plans');
|
||||
mkdirSync(plansDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(plansDir, 'invalid-plan.json'),
|
||||
JSON.stringify({ name: 'invalid' }) // Missing required fields
|
||||
);
|
||||
|
||||
const result = await runCli(['plan', 'validate', 'invalid-plan'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plan generate', () => {
|
||||
it('should generate a plan from a template', async () => {
|
||||
const result = await runCli(['plan', 'generate', '--template', 'feature'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('generate') ||
|
||||
output.includes('plan') ||
|
||||
output.includes('template') ||
|
||||
output.includes('feature');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Plan generate failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plan execute', () => {
|
||||
it('should execute a plan', async () => {
|
||||
await runCli(['plan', 'create', '--name', 'exec-plan'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plan', 'execute', 'exec-plan'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('execute') ||
|
||||
output.includes('plan') ||
|
||||
output.includes('exec-plan') ||
|
||||
output.includes('running');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Plan execute failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should execute with --dry-run', async () => {
|
||||
await runCli(['plan', 'create', '--name', 'dry-run-plan'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plan', 'execute', 'dry-run-plan', '--dry-run'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should execute specific step', async () => {
|
||||
await runCli(
|
||||
['plan', 'create', '--name', 'step-plan', '--steps', 'Step1,Step2,Step3'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
|
||||
const result = await runCli(['plan', 'execute', 'step-plan', '--step', '1'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Methodology + Plan Integration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'integration-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
it('should create plan based on methodology', async () => {
|
||||
// Load TDD methodology
|
||||
await runCli(['methodology', 'install', 'tdd'], { cwd: testDir });
|
||||
|
||||
// Create plan using TDD approach
|
||||
const result = await runCli(
|
||||
['plan', 'create', '--name', 'tdd-feature-plan', '--methodology', 'tdd'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should validate plan against methodology constraints', async () => {
|
||||
await runCli(['methodology', 'install', 'security-first'], { cwd: testDir });
|
||||
await runCli(['plan', 'create', '--name', 'secure-plan'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plan', 'validate', 'secure-plan', '--methodology'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* E2E Tests: Onboarding UI
|
||||
*
|
||||
* Tests for the new @clack/prompts based CLI onboarding experience
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
describe('E2E: Onboarding UI', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit init --list', () => {
|
||||
it('should display agents with icons', async () => {
|
||||
const result = await runCli(['init', '--list']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show agent icons
|
||||
expect(output).toContain('Claude Code');
|
||||
expect(output).toContain('Cursor');
|
||||
expect(output).toContain('Codex');
|
||||
|
||||
// Should show Skills dir info
|
||||
expect(output).toContain('Skills dir');
|
||||
expect(output).toContain('Config');
|
||||
|
||||
// Should complete successfully
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should display all 17 agents', async () => {
|
||||
const result = await runCli(['init', '--list']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
const agents = [
|
||||
'Claude Code',
|
||||
'Cursor',
|
||||
'Codex',
|
||||
'Gemini',
|
||||
'OpenCode',
|
||||
'Copilot',
|
||||
'Windsurf',
|
||||
'Droid',
|
||||
'Goose',
|
||||
'Amp',
|
||||
'Kilo',
|
||||
'Kiro',
|
||||
'Roo',
|
||||
'Trae',
|
||||
'Antigravity',
|
||||
'Clawdbot',
|
||||
'Universal',
|
||||
];
|
||||
|
||||
for (const agent of agents) {
|
||||
expect(output.toLowerCase()).toContain(agent.toLowerCase());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit install --list', () => {
|
||||
it('should list skills with visual formatting', async () => {
|
||||
// Create a test repo-like structure
|
||||
const skillsDir = join(testDir, 'test-skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'skill-one');
|
||||
createTestSkill(skillsDir, 'skill-two');
|
||||
|
||||
const result = await runCli(['install', testDir, '--list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show skills found
|
||||
expect(output.toLowerCase()).toMatch(/skill|found|available/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit marketplace', () => {
|
||||
it('should display marketplace header', async () => {
|
||||
const result = await runCli(['marketplace', '--json']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// JSON output should contain marketplace data
|
||||
if (result.success) {
|
||||
try {
|
||||
const data = JSON.parse(result.stdout.trim().split('\n').pop() || '{}');
|
||||
expect(data).toHaveProperty('totalSkills');
|
||||
expect(data).toHaveProperty('sources');
|
||||
} catch {
|
||||
// Non-JSON output is also acceptable
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should show popular tags with progress bars', async () => {
|
||||
const result = await runCli(['marketplace', 'tags', '--json']);
|
||||
|
||||
if (result.success && result.stdout.trim().startsWith('[')) {
|
||||
const tags = JSON.parse(result.stdout);
|
||||
expect(Array.isArray(tags)).toBe(true);
|
||||
if (tags.length > 0) {
|
||||
expect(tags[0]).toHaveProperty('tag');
|
||||
expect(tags[0]).toHaveProperty('count');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit sync', () => {
|
||||
it('should sync with formatted output', async () => {
|
||||
// Create skills to sync
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'sync-skill-1');
|
||||
createTestSkill(skillsDir, 'sync-skill-2');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code', '-y'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show sync operation
|
||||
expect(output.toLowerCase()).toMatch(/sync|skill|claude/);
|
||||
});
|
||||
|
||||
it('should show skill status indicators', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'enabled-skill');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code', '-y'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should complete without error
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit recommend', () => {
|
||||
it('should show project analysis with spinner', async () => {
|
||||
// Create a node project
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'test-project', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
|
||||
const result = await runCli(['recommend', '--quiet'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show some output about recommendations or project
|
||||
expect(
|
||||
output.toLowerCase().includes('project') ||
|
||||
output.toLowerCase().includes('skill') ||
|
||||
output.toLowerCase().includes('recommend') ||
|
||||
output.toLowerCase().includes('index') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should format scores with progress bars', async () => {
|
||||
// Create a TypeScript project
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({
|
||||
name: 'test-project',
|
||||
dependencies: { typescript: '^5.0.0' },
|
||||
}, null, 2)
|
||||
);
|
||||
writeFileSync(join(testDir, 'tsconfig.json'), '{}');
|
||||
|
||||
const result = await runCli(['recommend', '--json'], { cwd: testDir });
|
||||
|
||||
if (result.success && result.stdout.includes('"recommendations"')) {
|
||||
const data = JSON.parse(result.stdout);
|
||||
expect(data).toHaveProperty('recommendations');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Non-interactive mode', () => {
|
||||
it('should work with --yes flag', async () => {
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'test-skill');
|
||||
|
||||
const result = await runCli(['sync', '--agent', 'claude-code', '-y'], { cwd: testDir });
|
||||
// Should complete without prompting
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should work with --quiet flag', async () => {
|
||||
const result = await runCli(['init', '--list', '-q']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should still show content but without extra formatting
|
||||
expect(output).toContain('Claude Code');
|
||||
});
|
||||
|
||||
it('should work with --json flag', async () => {
|
||||
const result = await runCli(['marketplace', '--json']);
|
||||
|
||||
// Should output valid JSON
|
||||
if (result.success) {
|
||||
const jsonLine = result.stdout.trim().split('\n').pop() || '';
|
||||
if (jsonLine.startsWith('{') || jsonLine.startsWith('[')) {
|
||||
expect(() => JSON.parse(jsonLine)).not.toThrow();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Error handling', () => {
|
||||
it('should show formatted errors', async () => {
|
||||
const result = await runCli(['install', 'nonexistent-source-12345']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should show some error message
|
||||
expect(
|
||||
output.toLowerCase().includes('error') ||
|
||||
output.toLowerCase().includes('fail') ||
|
||||
output.toLowerCase().includes('not found') ||
|
||||
!result.success
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle missing skills gracefully', async () => {
|
||||
const result = await runCli(['read', 'nonexistent-skill'], { cwd: testDir });
|
||||
// Should not crash
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Visual elements', () => {
|
||||
it('should use Unicode symbols in output', async () => {
|
||||
const result = await runCli(['init', '--list']);
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should contain Unicode agent icons (any of the defined icons)
|
||||
const unicodePatterns = [
|
||||
/[\u2500-\u257F]/, // Box drawing
|
||||
/[\u25A0-\u25FF]/, // Geometric shapes
|
||||
/[\u2700-\u27BF]/, // Dingbats
|
||||
];
|
||||
|
||||
const hasUnicode = unicodePatterns.some(pattern => pattern.test(output));
|
||||
// Unicode support depends on terminal, so just check it doesn't crash
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle narrow terminal gracefully', async () => {
|
||||
// Even with narrow output, should not crash
|
||||
const result = await runCli(['init', '--list'], {
|
||||
env: { COLUMNS: '40' },
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,397 @@
|
||||
/**
|
||||
* E2E Tests: Plugin System
|
||||
*
|
||||
* Tests for: plugin list/install/uninstall/enable/disable/info
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
testFileExists,
|
||||
writeTestFile,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
describe('E2E: Plugin System', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'plugin-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
// Create .skillkit directory for plugin storage
|
||||
mkdirSync(join(testDir, '.skillkit', 'plugins'), { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit plugin list', () => {
|
||||
it('should list installed plugins', async () => {
|
||||
const result = await runCli(['plugin', 'list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('plugin') ||
|
||||
output.includes('No') ||
|
||||
output.includes('installed') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const result = await runCli(['plugin', 'list', '--json'], { cwd: testDir });
|
||||
if (result.stdout.trim().startsWith('[') || result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('should show available plugins from marketplace', async () => {
|
||||
const result = await runCli(['plugin', 'list', '--available'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should filter enabled/disabled plugins', async () => {
|
||||
const result = await runCli(['plugin', 'list', '--enabled'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plugin install', () => {
|
||||
it('should install plugin from local path', async () => {
|
||||
// Create a mock plugin
|
||||
const pluginDir = join(testDir, 'my-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'my-plugin',
|
||||
version: '1.0.0',
|
||||
description: 'A test plugin for E2E testing',
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
writeFileSync(join(pluginDir, 'index.js'), 'module.exports = { init: () => {} };');
|
||||
|
||||
const result = await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('install') ||
|
||||
output.includes('my-plugin') ||
|
||||
output.includes('success') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should install plugin from npm-style name', async () => {
|
||||
// This may fail if plugin doesn't exist, but shouldn't crash
|
||||
const result = await runCli(['plugin', 'install', 'skillkit-plugin-example'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle non-existent plugin gracefully', async () => {
|
||||
const result = await runCli(['plugin', 'install', 'nonexistent-plugin-12345'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('not found') ||
|
||||
output.includes('error') ||
|
||||
output.includes('fail') ||
|
||||
!result.success ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should install with --force option', async () => {
|
||||
const pluginDir = join(testDir, 'force-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify({ name: 'force-plugin', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
|
||||
// Install twice with force
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
const result = await runCli(['plugin', 'install', pluginDir, '--force'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plugin uninstall', () => {
|
||||
it('should uninstall an installed plugin', async () => {
|
||||
// First install a plugin
|
||||
const pluginDir = join(testDir, 'uninstall-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify({ name: 'uninstall-plugin', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
|
||||
// Then uninstall
|
||||
const result = await runCli(['plugin', 'uninstall', 'uninstall-plugin'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('uninstall') ||
|
||||
output.includes('remove') ||
|
||||
output.includes('success') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle uninstalling non-installed plugin gracefully', async () => {
|
||||
const result = await runCli(['plugin', 'uninstall', 'not-installed-plugin'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plugin enable/disable', () => {
|
||||
beforeEach(async () => {
|
||||
// Install a test plugin
|
||||
const pluginDir = join(testDir, 'toggle-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify({ name: 'toggle-plugin', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
});
|
||||
|
||||
it('should enable a disabled plugin', async () => {
|
||||
// First disable
|
||||
await runCli(['plugin', 'disable', 'toggle-plugin'], { cwd: testDir });
|
||||
|
||||
// Then enable
|
||||
const result = await runCli(['plugin', 'enable', 'toggle-plugin'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('enable') ||
|
||||
output.includes('toggle-plugin') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should disable an enabled plugin', async () => {
|
||||
const result = await runCli(['plugin', 'disable', 'toggle-plugin'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('disable') ||
|
||||
output.includes('toggle-plugin') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit plugin info', () => {
|
||||
it('should show plugin information', async () => {
|
||||
// Install a plugin first
|
||||
const pluginDir = join(testDir, 'info-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'info-plugin',
|
||||
version: '2.0.0',
|
||||
description: 'A plugin with detailed info for testing',
|
||||
author: 'Test Author',
|
||||
homepage: 'https://example.com',
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plugin', 'info', 'info-plugin'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('info-plugin') ||
|
||||
output.includes('2.0.0') ||
|
||||
output.includes('info') ||
|
||||
output.includes('description') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle non-existent plugin info gracefully', async () => {
|
||||
const result = await runCli(['plugin', 'info', 'nonexistent-plugin'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
const pluginDir = join(testDir, 'json-info-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify({ name: 'json-info-plugin', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plugin', 'info', 'json-info-plugin', '--json'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
if (result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Plugin Integration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'plugin-integration', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
mkdirSync(join(testDir, '.skillkit', 'plugins'), { recursive: true });
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
it('should load plugin skills into skill list', async () => {
|
||||
// Create a plugin with skills
|
||||
const pluginDir = join(testDir, 'skills-plugin');
|
||||
mkdirSync(join(pluginDir, 'skills', 'plugin-skill'), { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'skills-plugin',
|
||||
version: '1.0.0',
|
||||
skills: ['skills/plugin-skill'],
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
writeFileSync(
|
||||
join(pluginDir, 'skills', 'plugin-skill', 'SKILL.md'),
|
||||
`---
|
||||
name: plugin-skill
|
||||
description: A skill provided by a plugin for E2E testing
|
||||
---
|
||||
|
||||
# Plugin Skill
|
||||
`
|
||||
);
|
||||
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
|
||||
// List should include plugin skill
|
||||
const result = await runCli(['list'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle plugin hooks', async () => {
|
||||
// Create a plugin with hooks
|
||||
const pluginDir = join(testDir, 'hooks-plugin');
|
||||
mkdirSync(pluginDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(pluginDir, 'plugin.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'hooks-plugin',
|
||||
version: '1.0.0',
|
||||
hooks: {
|
||||
'pre-sync': 'echo "pre-sync from plugin"',
|
||||
'post-sync': 'echo "post-sync from plugin"',
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
await runCli(['plugin', 'install', pluginDir], { cwd: testDir });
|
||||
|
||||
// Sync should trigger plugin hooks
|
||||
const result = await runCli(['sync', '--agent', 'claude-code'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should respect plugin priority order', async () => {
|
||||
// Create two plugins with different priorities
|
||||
const plugin1Dir = join(testDir, 'priority-plugin-1');
|
||||
const plugin2Dir = join(testDir, 'priority-plugin-2');
|
||||
|
||||
mkdirSync(plugin1Dir, { recursive: true });
|
||||
mkdirSync(plugin2Dir, { recursive: true });
|
||||
|
||||
writeFileSync(
|
||||
join(plugin1Dir, 'plugin.json'),
|
||||
JSON.stringify({ name: 'priority-plugin-1', version: '1.0.0', priority: 10 }, null, 2)
|
||||
);
|
||||
writeFileSync(
|
||||
join(plugin2Dir, 'plugin.json'),
|
||||
JSON.stringify({ name: 'priority-plugin-2', version: '1.0.0', priority: 20 }, null, 2)
|
||||
);
|
||||
|
||||
await runCli(['plugin', 'install', plugin1Dir], { cwd: testDir });
|
||||
await runCli(['plugin', 'install', plugin2Dir], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['plugin', 'list'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Marketplace Integration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'marketplace-test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit marketplace', () => {
|
||||
it('should list marketplace skills', async () => {
|
||||
const result = await runCli(['marketplace'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('marketplace') ||
|
||||
output.includes('skill') ||
|
||||
output.includes('available') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should search marketplace', async () => {
|
||||
const result = await runCli(['marketplace', '--search', 'typescript'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should filter by category', async () => {
|
||||
const result = await runCli(['marketplace', '--category', 'testing'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should show skill details', async () => {
|
||||
const result = await runCli(['marketplace', '--info', 'some-skill'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* E2E Tests: Team Collaboration Features
|
||||
*
|
||||
* Tests for: team init, team share, team import, team list, team sync, team remove, team bundle-*
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
writeTestFile,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
describe('E2E: Team Collaboration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
// Create base project structure
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
createTestSkill(join(testDir, 'skills'), 'team-skill-one', {
|
||||
description: 'First skill for team collaboration testing',
|
||||
});
|
||||
createTestSkill(join(testDir, 'skills'), 'team-skill-two', {
|
||||
description: 'Second skill for team collaboration testing',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit team init', () => {
|
||||
it('should initialize team configuration', async () => {
|
||||
const result = await runCli(['team', 'init'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Must complete successfully and show relevant output
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
// Should initialize team structure or report status
|
||||
const hasRelevantOutput =
|
||||
output.includes('team') ||
|
||||
output.includes('init') ||
|
||||
output.includes('created') ||
|
||||
testFileExists(testDir, '.skillkit/team.json') ||
|
||||
testFileExists(testDir, '.skillkit');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Team init failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should create team configuration file', async () => {
|
||||
const result = await runCli(
|
||||
['team', 'init', '--name', 'test-team', '--registry', 'local'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
|
||||
// Check for team config in various possible locations
|
||||
const hasTeamConfig =
|
||||
testFileExists(testDir, '.skillkit/team.json') ||
|
||||
testFileExists(testDir, '.skillkit/team.yaml') ||
|
||||
testFileExists(testDir, 'team.json') ||
|
||||
testFileExists(testDir, '.skillkit');
|
||||
|
||||
// Strict assertion - either created config or command succeeded
|
||||
if (!hasTeamConfig && result.exitCode !== 0) {
|
||||
const output = result.stdout + result.stderr;
|
||||
expect.fail(`Team init did not create config. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasTeamConfig || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept team name option', async () => {
|
||||
const result = await runCli(['team', 'init', '--name', 'test-team'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit team list', () => {
|
||||
it('should list team skills', async () => {
|
||||
// Initialize team first
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'list'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
// Should list skills or indicate none
|
||||
const hasRelevantOutput =
|
||||
output.includes('skill') ||
|
||||
output.includes('team') ||
|
||||
output.includes('No') ||
|
||||
output.includes('empty');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Team list failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
const result = await runCli(['team', 'list', '--json'], { cwd: testDir });
|
||||
|
||||
if (result.stdout.trim().startsWith('[') || result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit team share', () => {
|
||||
it('should share a skill with team', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'share', 'team-skill-one'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
// Should share skill or report status
|
||||
const hasRelevantOutput =
|
||||
output.includes('share') ||
|
||||
output.includes('team-skill-one') ||
|
||||
output.includes('success') ||
|
||||
output.includes('added');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Team share failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should share multiple skills', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'share', 'team-skill-one', 'team-skill-two'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should handle non-existent skill gracefully', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'share', 'nonexistent-skill'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
// Should report error or warning about missing skill
|
||||
const showsError =
|
||||
output.includes('not found') ||
|
||||
output.includes('error') ||
|
||||
output.includes('No') ||
|
||||
!result.success;
|
||||
|
||||
expect(showsError).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit team sync', () => {
|
||||
it('should sync team skills', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
await runCli(['team', 'share', 'team-skill-one'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'sync'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('sync') ||
|
||||
output.includes('team') ||
|
||||
output.includes('success');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Team sync failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
|
||||
it('should sync with specific agent', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'sync', '--agent', 'claude-code'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit team remove', () => {
|
||||
it('should remove a shared skill from team', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
await runCli(['team', 'share', 'team-skill-one'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(['team', 'remove', 'team-skill-one'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('remove') ||
|
||||
output.includes('team-skill-one') ||
|
||||
output.includes('success');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Team remove failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit team import', () => {
|
||||
it('should import skills from team bundle', async () => {
|
||||
// Create a mock team bundle
|
||||
const bundleDir = join(testDir, 'team-bundle');
|
||||
mkdirSync(bundleDir, { recursive: true });
|
||||
createTestSkill(bundleDir, 'imported-skill', {
|
||||
description: 'A skill to be imported from a team bundle file',
|
||||
});
|
||||
|
||||
const result = await runCli(['team', 'import', bundleDir], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
|
||||
const hasRelevantOutput =
|
||||
output.includes('import') ||
|
||||
output.includes('skill') ||
|
||||
output.includes('success');
|
||||
|
||||
if (!hasRelevantOutput && result.exitCode !== 0) {
|
||||
expect.fail(`Team import failed. Exit: ${result.exitCode}\nOutput: ${output}`);
|
||||
}
|
||||
|
||||
expect(hasRelevantOutput || result.exitCode === 0).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit team bundle-*', () => {
|
||||
it('should create team bundle (bundle-create)', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
await runCli(['team', 'share', 'team-skill-one'], { cwd: testDir });
|
||||
|
||||
const bundlePath = join(testDir, 'my-bundle.skillkit');
|
||||
const result = await runCli(['team', 'bundle-create', '--output', bundlePath], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should list bundle contents (bundle-list)', async () => {
|
||||
// Create a bundle first
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
await runCli(['team', 'share', 'team-skill-one'], { cwd: testDir });
|
||||
const bundlePath = join(testDir, 'test-bundle.skillkit');
|
||||
await runCli(['team', 'bundle-create', '--output', bundlePath], { cwd: testDir });
|
||||
|
||||
// Now list it
|
||||
const result = await runCli(['team', 'bundle-list', bundlePath], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should extract bundle (bundle-extract)', async () => {
|
||||
// Create bundle
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
await runCli(['team', 'share', 'team-skill-one'], { cwd: testDir });
|
||||
const bundlePath = join(testDir, 'extract-bundle.skillkit');
|
||||
await runCli(['team', 'bundle-create', '--output', bundlePath], { cwd: testDir });
|
||||
|
||||
// Extract to new location
|
||||
const extractDir = join(testDir, 'extracted');
|
||||
const result = await runCli(['team', 'bundle-extract', bundlePath, '--output', extractDir], {
|
||||
cwd: testDir,
|
||||
});
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Team Orchestration', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
mkdirSync(join(testDir, 'skills'), { recursive: true });
|
||||
createTestSkill(join(testDir, 'skills'), 'orchestration-skill', {
|
||||
description: 'A skill for testing multi-agent team orchestration features',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
it('should configure team roles', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
// Configure team with roles
|
||||
const result = await runCli(['team', 'init', '--role', 'leader:claude-code'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should support multi-agent configuration', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
const result = await runCli(
|
||||
['team', 'init', '--agents', 'claude-code,cursor,github-copilot'],
|
||||
{ cwd: testDir }
|
||||
);
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should handle team task delegation', async () => {
|
||||
await runCli(['team', 'init'], { cwd: testDir });
|
||||
|
||||
// This tests the orchestration task feature if available
|
||||
const result = await runCli(['team', 'sync', '--all-agents'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeLessThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,345 @@
|
||||
/**
|
||||
* E2E Tests: Skill Translation Commands
|
||||
*
|
||||
* Tests for: translate, context, recommend
|
||||
* Validates translation to all 17 supported agents
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { join } from 'node:path';
|
||||
import { mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
||||
import {
|
||||
runCli,
|
||||
createTestDir,
|
||||
cleanupTestDir,
|
||||
createTestSkill,
|
||||
testFileExists,
|
||||
} from './helpers/cli-runner.js';
|
||||
|
||||
// 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 Translation', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
// Create a skill for translation tests
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'translation-test', {
|
||||
description: 'A skill designed for testing translation across multiple AI coding agents',
|
||||
content: `## Usage
|
||||
|
||||
Run this command to test the skill:
|
||||
|
||||
\`\`\`bash
|
||||
npm test
|
||||
\`\`\`
|
||||
|
||||
## Features
|
||||
|
||||
- Feature A: Does something useful
|
||||
- Feature B: Does something else
|
||||
`,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
describe('skillkit translate', () => {
|
||||
it('should translate skill to claude-code format', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'claude-code'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should complete translation or show relevant output
|
||||
expect(
|
||||
output.includes('claude') ||
|
||||
output.includes('translate') ||
|
||||
output.includes('CLAUDE.md') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should translate skill to cursor format', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'cursor'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('cursor') ||
|
||||
output.includes('.cursorrules') ||
|
||||
output.includes('translate') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should translate skill to windsurf format', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'windsurf'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('windsurf') ||
|
||||
output.includes('.windsurfrules') ||
|
||||
output.includes('translate') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should translate skill to github-copilot format', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'github-copilot'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('copilot') ||
|
||||
output.includes('.github') ||
|
||||
output.includes('translate') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should support universal format for all agents', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'universal'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
// Test all agents can at least attempt translation
|
||||
describe.each(SUPPORTED_AGENTS)('translation to %s', (agent) => {
|
||||
it(`should handle translation to ${agent}`, async () => {
|
||||
const result = await runCli(['translate', '--agent', agent], { cwd: testDir });
|
||||
// Should not crash - either succeeds or reports error gracefully
|
||||
expect(result.exitCode).toBeDefined();
|
||||
expect(typeof result.stdout).toBe('string');
|
||||
expect(typeof result.stderr).toBe('string');
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle unknown agent gracefully', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'nonexistent-agent'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should report error about unknown agent
|
||||
expect(
|
||||
output.toLowerCase().includes('unknown') ||
|
||||
output.toLowerCase().includes('not supported') ||
|
||||
output.toLowerCase().includes('invalid') ||
|
||||
output.toLowerCase().includes('error') ||
|
||||
!result.success
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should translate with --output option', async () => {
|
||||
const outputPath = join(testDir, 'translated-output');
|
||||
mkdirSync(outputPath, { recursive: true });
|
||||
|
||||
const result = await runCli(['translate', '--agent', 'claude-code', '--output', outputPath], {
|
||||
cwd: testDir,
|
||||
});
|
||||
// Command should complete
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should translate with --dry-run option', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'cursor', '--dry-run'], {
|
||||
cwd: testDir,
|
||||
});
|
||||
const output = result.stdout + result.stderr;
|
||||
// Dry run should show what would be done without making changes
|
||||
expect(result.exitCode !== undefined || output.length > 0).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit context', () => {
|
||||
it('should detect project context', async () => {
|
||||
// Create a Node.js project
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'test-project',
|
||||
version: '1.0.0',
|
||||
dependencies: { express: '^4.18.0' },
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
const result = await runCli(['context'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should detect the project type
|
||||
expect(
|
||||
output.includes('node') ||
|
||||
output.includes('javascript') ||
|
||||
output.includes('typescript') ||
|
||||
output.includes('context') ||
|
||||
output.includes('project') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect Python project', async () => {
|
||||
// Create a Python project
|
||||
writeFileSync(join(testDir, 'requirements.txt'), 'flask>=2.0.0\npytest>=7.0.0\n');
|
||||
writeFileSync(join(testDir, 'main.py'), 'print("Hello")\n');
|
||||
|
||||
const result = await runCli(['context'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('python') || output.includes('context') || result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect Rust project', async () => {
|
||||
// Create a Rust project
|
||||
writeFileSync(
|
||||
join(testDir, 'Cargo.toml'),
|
||||
'[package]\nname = "test"\nversion = "0.1.0"\nedition = "2021"'
|
||||
);
|
||||
|
||||
const result = await runCli(['context'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('rust') || output.includes('context') || result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect Go project', async () => {
|
||||
// Create a Go project
|
||||
writeFileSync(join(testDir, 'go.mod'), 'module example.com/test\n\ngo 1.21');
|
||||
|
||||
const result = await runCli(['context'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
expect(
|
||||
output.includes('go') || output.includes('context') || result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should support --json output', async () => {
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
|
||||
const result = await runCli(['context', '--json'], { cwd: testDir });
|
||||
// If JSON is supported, should be parseable
|
||||
if (result.stdout.trim().startsWith('{')) {
|
||||
expect(() => JSON.parse(result.stdout)).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('skillkit recommend', () => {
|
||||
it('should recommend skills for a project', async () => {
|
||||
// Create a Node.js project with common patterns
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: 'web-app',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
express: '^4.18.0',
|
||||
typescript: '^5.0.0',
|
||||
jest: '^29.0.0',
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
const result = await runCli(['recommend'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Should provide recommendations or indicate none available
|
||||
expect(
|
||||
output.includes('recommend') ||
|
||||
output.includes('skill') ||
|
||||
output.includes('suggest') ||
|
||||
output.includes('No') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle empty project gracefully', async () => {
|
||||
const result = await runCli(['recommend'], { cwd: testDir });
|
||||
// Should not crash
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
|
||||
it('should support --limit option', async () => {
|
||||
writeFileSync(
|
||||
join(testDir, 'package.json'),
|
||||
JSON.stringify({ name: 'test', version: '1.0.0' }, null, 2)
|
||||
);
|
||||
|
||||
const result = await runCli(['recommend', '--limit', '5'], { cwd: testDir });
|
||||
expect(result.exitCode).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('E2E: Agent Config Generation', () => {
|
||||
let testDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
testDir = createTestDir();
|
||||
const skillsDir = join(testDir, 'skills');
|
||||
mkdirSync(skillsDir, { recursive: true });
|
||||
createTestSkill(skillsDir, 'config-test-skill', {
|
||||
description: 'A skill for testing agent configuration generation across all agents',
|
||||
additionalFrontmatter: {
|
||||
'allowed-tools': 'Bash(npm:*) Read Write Edit',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanupTestDir(testDir);
|
||||
});
|
||||
|
||||
it('should generate valid claude-code config (CLAUDE.md)', async () => {
|
||||
const result = await runCli(['sync', '--agent', 'claude-code'], { cwd: testDir });
|
||||
// Check if CLAUDE.md was created or would be created
|
||||
const claudeMdExists = testFileExists(testDir, 'CLAUDE.md');
|
||||
expect(result.exitCode !== undefined || claudeMdExists).toBe(true);
|
||||
});
|
||||
|
||||
it('should generate valid cursor config (.cursorrules)', async () => {
|
||||
const result = await runCli(['sync', '--agent', 'cursor'], { cwd: testDir });
|
||||
const cursorRulesExists = testFileExists(testDir, '.cursorrules');
|
||||
expect(result.exitCode !== undefined || cursorRulesExists).toBe(true);
|
||||
});
|
||||
|
||||
it('should generate valid windsurf config (.windsurfrules)', async () => {
|
||||
const result = await runCli(['sync', '--agent', 'windsurf'], { cwd: testDir });
|
||||
const windsurfRulesExists = testFileExists(testDir, '.windsurfrules');
|
||||
expect(result.exitCode !== undefined || windsurfRulesExists).toBe(true);
|
||||
});
|
||||
|
||||
it('should preserve allowed-tools in translation', async () => {
|
||||
const result = await runCli(['translate', '--agent', 'claude-code'], { cwd: testDir });
|
||||
const output = result.stdout + result.stderr;
|
||||
// Output or generated file should mention tools
|
||||
expect(
|
||||
output.includes('tool') ||
|
||||
output.includes('Bash') ||
|
||||
output.includes('permission') ||
|
||||
result.exitCode !== undefined
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": false,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"types": ["node", "vitest/globals"]
|
||||
},
|
||||
"include": ["**/*.ts"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
include: ['**/*.e2e.test.ts'],
|
||||
testTimeout: 60000, // E2E tests need more time
|
||||
hookTimeout: 30000,
|
||||
retry: 1, // Retry failed tests once for flaky network/fs operations
|
||||
sequence: {
|
||||
shuffle: false, // Run tests in order for debugging
|
||||
},
|
||||
pool: 'forks', // Use forks for better isolation
|
||||
poolOptions: {
|
||||
forks: {
|
||||
singleFork: false,
|
||||
isolate: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
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
+21
-42
@@ -1,33 +1,22 @@
|
||||
{
|
||||
"name": "skillkit",
|
||||
"version": "1.2.0",
|
||||
"description": "Universal skills loader for AI coding agents - supports Claude Code, Codex, Cursor, Antigravity, OpenCode, Gemini CLI and more",
|
||||
"name": "skillkit-monorepo",
|
||||
"version": "1.7.2",
|
||||
"private": true,
|
||||
"description": "Universal skills loader for AI coding agents - Monorepo",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"bin": {
|
||||
"skillkit": "./dist/cli.js",
|
||||
"sk": "./dist/cli.js"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"schemas"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"test": "vitest run",
|
||||
"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",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "eslint src --ext .ts",
|
||||
"prepublishOnly": "npm run typecheck && npm run build && npm run test"
|
||||
"test:e2e": "vitest run --config e2e/vitest.config.ts",
|
||||
"test:e2e:watch": "vitest --config e2e/vitest.config.ts",
|
||||
"test:all": "pnpm test && pnpm test:e2e",
|
||||
"typecheck": "turbo run typecheck",
|
||||
"lint": "turbo run lint",
|
||||
"clean": "rm -rf node_modules packages/*/node_modules apps/*/node_modules packages/*/dist apps/*/dist"
|
||||
},
|
||||
"keywords": [
|
||||
"ai",
|
||||
@@ -41,10 +30,11 @@
|
||||
"agent",
|
||||
"coding-assistant",
|
||||
"skill-loader",
|
||||
"cli"
|
||||
"cli",
|
||||
"monorepo"
|
||||
],
|
||||
"author": "Rohit Ghumare",
|
||||
"license": "MIT",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rohitg00/skillkit.git"
|
||||
@@ -56,25 +46,14 @@
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^5.3.0",
|
||||
"clipanion": "^4.0.0-rc.4",
|
||||
"got": "^14.4.1",
|
||||
"ink": "^5.0.1",
|
||||
"ink-select-input": "^6.0.0",
|
||||
"ink-spinner": "^5.0.0",
|
||||
"ink-text-input": "^6.0.0",
|
||||
"isomorphic-git": "^1.27.1",
|
||||
"ora": "^8.1.0",
|
||||
"react": "^18.3.1",
|
||||
"yaml": "^2.6.1",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
"packageManager": "pnpm@9.0.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/react": "^18.3.18",
|
||||
"tsup": "^8.3.5",
|
||||
"turbo": "^2.3.4",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
}
|
||||
},
|
||||
"pnpm": {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
# @skillkit/agents
|
||||
|
||||
[](https://www.npmjs.com/package/@skillkit/agents)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
**Agent adapters for SkillKit** - configuration and detection for 17 AI coding agents.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @skillkit/agents
|
||||
```
|
||||
|
||||
## Supported Agents (17)
|
||||
|
||||
| Agent | Config Format | Project Skills | Global Skills |
|
||||
|-------|--------------|----------------|---------------|
|
||||
| Claude Code | SKILL.md | `.claude/skills/` | `~/.claude/skills/` |
|
||||
| Cursor | MDC (.mdc) | `.cursor/skills/` | `~/.cursor/skills/` |
|
||||
| Codex | SKILL.md | `.codex/skills/` | `~/.codex/skills/` |
|
||||
| Gemini CLI | SKILL.md | `.gemini/skills/` | `~/.gemini/skills/` |
|
||||
| OpenCode | SKILL.md | `.opencode/skills/` | `~/.config/opencode/skills/` |
|
||||
| Antigravity | SKILL.md | `.antigravity/skills/` | `~/.gemini/antigravity/skills/` |
|
||||
| Amp | SKILL.md | `.agents/skills/` | `~/.config/agents/skills/` |
|
||||
| Clawdbot | SKILL.md | `skills/` | `~/.clawdbot/skills/` |
|
||||
| Droid (Factory) | SKILL.md | `.factory/skills/` | `~/.factory/skills/` |
|
||||
| GitHub Copilot | Markdown | `.github/skills/` | `~/.copilot/skills/` |
|
||||
| Goose | SKILL.md | `.goose/skills/` | `~/.config/goose/skills/` |
|
||||
| Kilo Code | SKILL.md | `.kilocode/skills/` | `~/.kilocode/skills/` |
|
||||
| Kiro CLI | SKILL.md | `.kiro/skills/` | `~/.kiro/skills/` |
|
||||
| Roo Code | SKILL.md | `.roo/skills/` | `~/.roo/skills/` |
|
||||
| Trae | SKILL.md | `.trae/skills/` | `~/.trae/skills/` |
|
||||
| Windsurf | Markdown | `.windsurf/skills/` | `~/.codeium/windsurf/skills/` |
|
||||
| Universal | SKILL.md | `skills/` | `~/.agent/skills/` |
|
||||
|
||||
## Usage
|
||||
|
||||
### Get Agent Adapter
|
||||
|
||||
```typescript
|
||||
import { getAdapter, AgentType } from '@skillkit/agents';
|
||||
|
||||
// Get adapter for specific agent
|
||||
const adapter = getAdapter('claude-code');
|
||||
|
||||
console.log(adapter.name); // 'claude-code'
|
||||
console.log(adapter.skillsDir); // '.claude/skills/'
|
||||
console.log(adapter.globalSkillsDir); // '~/.claude/skills/'
|
||||
console.log(adapter.configFile); // 'AGENTS.md'
|
||||
console.log(adapter.format); // 'skill-md'
|
||||
```
|
||||
|
||||
### Detect Installed Agents
|
||||
|
||||
```typescript
|
||||
import { detectAgent, detectAllAgents } from '@skillkit/agents';
|
||||
|
||||
// Detect primary agent in current directory
|
||||
const primary = await detectAgent();
|
||||
console.log(primary); // 'claude-code'
|
||||
|
||||
// Detect all installed agents
|
||||
const all = await detectAllAgents();
|
||||
console.log(all); // ['claude-code', 'cursor', 'windsurf']
|
||||
|
||||
// Detect in specific directory
|
||||
const agents = await detectAllAgents('./my-project');
|
||||
```
|
||||
|
||||
### List All Adapters
|
||||
|
||||
```typescript
|
||||
import { listAdapters, getAdapterNames } from '@skillkit/agents';
|
||||
|
||||
// Get all adapter configurations
|
||||
const adapters = listAdapters();
|
||||
adapters.forEach(adapter => {
|
||||
console.log(`${adapter.name}: ${adapter.skillsDir}`);
|
||||
});
|
||||
|
||||
// Get just the names
|
||||
const names = getAdapterNames();
|
||||
console.log(names); // ['claude-code', 'cursor', 'codex', ...]
|
||||
```
|
||||
|
||||
### Generate Agent Config
|
||||
|
||||
```typescript
|
||||
import { getAdapter } from '@skillkit/agents';
|
||||
import { findAllSkills } from '@skillkit/core';
|
||||
|
||||
const adapter = getAdapter('cursor');
|
||||
const skills = findAllSkills([adapter.skillsDir]);
|
||||
|
||||
// Generate config file content
|
||||
const config = adapter.generateConfig(skills);
|
||||
console.log(config);
|
||||
```
|
||||
|
||||
### Get Skills Directory
|
||||
|
||||
```typescript
|
||||
import { getAdapter } from '@skillkit/agents';
|
||||
import { homedir } from 'os';
|
||||
|
||||
const adapter = getAdapter('claude-code');
|
||||
|
||||
// Project-local skills directory
|
||||
const projectDir = adapter.skillsDir; // '.claude/skills/'
|
||||
|
||||
// Global skills directory
|
||||
const globalDir = adapter.globalSkillsDir.replace('~', homedir());
|
||||
// '/Users/you/.claude/skills/'
|
||||
```
|
||||
|
||||
## Adapter Interface
|
||||
|
||||
```typescript
|
||||
interface AgentAdapter {
|
||||
// Agent identifier
|
||||
name: AgentType;
|
||||
|
||||
// Display name
|
||||
displayName: string;
|
||||
|
||||
// Skill file format
|
||||
format: 'skill-md' | 'mdc' | 'markdown';
|
||||
|
||||
// Project skills directory (relative)
|
||||
skillsDir: string;
|
||||
|
||||
// Global skills directory (with ~)
|
||||
globalSkillsDir: string;
|
||||
|
||||
// Config file name
|
||||
configFile: string;
|
||||
|
||||
// Generate config from skills
|
||||
generateConfig(skills: Skill[]): string;
|
||||
|
||||
// Parse existing config
|
||||
parseConfig(content: string): Skill[];
|
||||
}
|
||||
```
|
||||
|
||||
## Agent Types
|
||||
|
||||
```typescript
|
||||
type AgentType =
|
||||
| 'claude-code'
|
||||
| 'cursor'
|
||||
| 'codex'
|
||||
| 'gemini-cli'
|
||||
| 'opencode'
|
||||
| 'antigravity'
|
||||
| 'amp'
|
||||
| 'clawdbot'
|
||||
| 'droid'
|
||||
| 'github-copilot'
|
||||
| 'goose'
|
||||
| 'kilo'
|
||||
| 'kiro-cli'
|
||||
| 'roo'
|
||||
| 'trae'
|
||||
| 'windsurf'
|
||||
| 'universal';
|
||||
```
|
||||
|
||||
## Format Details
|
||||
|
||||
### SKILL.md Format
|
||||
Used by most agents. YAML frontmatter + Markdown content:
|
||||
```markdown
|
||||
---
|
||||
name: my-skill
|
||||
description: What this skill does
|
||||
---
|
||||
# My Skill
|
||||
Instructions...
|
||||
```
|
||||
|
||||
### MDC Format (Cursor)
|
||||
Cursor-specific format with globs and alwaysApply:
|
||||
```
|
||||
---
|
||||
description: What this skill does
|
||||
globs: ["**/*.tsx"]
|
||||
alwaysApply: false
|
||||
---
|
||||
Instructions...
|
||||
```
|
||||
|
||||
### Markdown Format
|
||||
Plain markdown used by Windsurf and Copilot:
|
||||
```markdown
|
||||
# Skill Name
|
||||
Instructions for the agent...
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation: https://github.com/rohitg00/skillkit
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@skillkit/agents",
|
||||
"version": "1.7.4",
|
||||
"description": "Agent adapters for SkillKit - supports 17+ AI coding agents",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "workspace:*",
|
||||
"minimatch": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { getAllAdapters, getAdapter, detectAgent } from '../index.js';
|
||||
|
||||
describe('Agent Adapters', () => {
|
||||
describe('getAllAdapters', () => {
|
||||
it('should return all registered adapters', () => {
|
||||
const adapters = getAllAdapters();
|
||||
expect(adapters).toBeInstanceOf(Array);
|
||||
expect(adapters.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should include common agents', () => {
|
||||
const adapters = getAllAdapters();
|
||||
const types = adapters.map(a => a.type);
|
||||
|
||||
// Should include at least some well-known agents
|
||||
expect(types).toContain('claude-code');
|
||||
expect(types).toContain('cursor');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAdapter', () => {
|
||||
it('should return adapter for known agent type', () => {
|
||||
const adapter = getAdapter('claude-code');
|
||||
expect(adapter).toBeDefined();
|
||||
expect(adapter.type).toBe('claude-code');
|
||||
expect(adapter.name).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return undefined for unknown agent type', () => {
|
||||
const adapter = getAdapter('unknown-agent' as any);
|
||||
expect(adapter).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('detectAgent', () => {
|
||||
it('should return an agent type', async () => {
|
||||
const agent = await detectAgent();
|
||||
expect(typeof agent).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,412 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { ClawdbotAdapter } from '../clawdbot.js';
|
||||
import type { Skill } from '@skillkit/core';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
|
||||
// Mock filesystem functions
|
||||
vi.mock('node:fs', () => ({
|
||||
existsSync: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('ClawdbotAdapter', () => {
|
||||
let adapter: ClawdbotAdapter;
|
||||
const mockExistsSync = vi.mocked(existsSync);
|
||||
|
||||
beforeEach(() => {
|
||||
adapter = new ClawdbotAdapter();
|
||||
mockExistsSync.mockClear();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('configuration', () => {
|
||||
it('should have correct type', () => {
|
||||
expect(adapter.type).toBe('clawdbot');
|
||||
});
|
||||
|
||||
it('should have correct name', () => {
|
||||
expect(adapter.name).toBe('Clawdbot');
|
||||
});
|
||||
|
||||
it('should have correct skillsDir', () => {
|
||||
expect(adapter.skillsDir).toBe('.clawdbot/skills');
|
||||
});
|
||||
|
||||
it('should have correct configFile', () => {
|
||||
expect(adapter.configFile).toBe('AGENTS.md');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateConfig', () => {
|
||||
it('should return empty string for no enabled skills', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'test-skill',
|
||||
enabled: false,
|
||||
path: '/path/to/skill',
|
||||
content: '# Test',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
expect(config).toBe('');
|
||||
});
|
||||
|
||||
it('should generate config with enabled skills', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'test-skill',
|
||||
description: 'A test skill',
|
||||
enabled: true,
|
||||
path: '/path/to/skill',
|
||||
content: '# Test',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('<skills_system priority="1">');
|
||||
expect(config).toContain('## Available Skills');
|
||||
expect(config).toContain('<name>test-skill</name>');
|
||||
expect(config).toContain('<description>A test skill</description>');
|
||||
expect(config).toContain('skillkit read <skill-name>');
|
||||
});
|
||||
|
||||
it('should generate config with multiple skills', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'skill-1',
|
||||
description: 'First skill',
|
||||
enabled: true,
|
||||
path: '/path/to/skill1',
|
||||
content: '# Skill 1',
|
||||
},
|
||||
{
|
||||
name: 'skill-2',
|
||||
description: 'Second skill',
|
||||
enabled: true,
|
||||
path: '/path/to/skill2',
|
||||
content: '# Skill 2',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('<name>skill-1</name>');
|
||||
expect(config).toContain('<name>skill-2</name>');
|
||||
expect(config).toContain('<description>First skill</description>');
|
||||
expect(config).toContain('<description>Second skill</description>');
|
||||
});
|
||||
|
||||
it('should filter out disabled skills', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'enabled-skill',
|
||||
enabled: true,
|
||||
path: '/path/to/enabled',
|
||||
content: '# Enabled',
|
||||
},
|
||||
{
|
||||
name: 'disabled-skill',
|
||||
enabled: false,
|
||||
path: '/path/to/disabled',
|
||||
content: '# Disabled',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('enabled-skill');
|
||||
expect(config).not.toContain('disabled-skill');
|
||||
});
|
||||
|
||||
it('should include usage notes', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'test-skill',
|
||||
enabled: true,
|
||||
path: '/path/to/skill',
|
||||
content: '# Test',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('<usage>');
|
||||
expect(config).toContain('When users ask you to perform tasks');
|
||||
expect(config).toContain('How to use skills:');
|
||||
expect(config).toContain('- Invoke:');
|
||||
expect(config).toContain('Usage notes:');
|
||||
});
|
||||
|
||||
it('should include available_skills section', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'test-skill',
|
||||
enabled: true,
|
||||
path: '/path/to/skill',
|
||||
content: '# Test',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('<available_skills>');
|
||||
expect(config).toContain('</available_skills>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseConfig', () => {
|
||||
it('should parse skill names from config', () => {
|
||||
const config = `
|
||||
<skills_system>
|
||||
<available_skills>
|
||||
<skill>
|
||||
<name>skill-1</name>
|
||||
<description>Test skill 1</description>
|
||||
</skill>
|
||||
<skill>
|
||||
<name>skill-2</name>
|
||||
<description>Test skill 2</description>
|
||||
</skill>
|
||||
</available_skills>
|
||||
</skills_system>
|
||||
`;
|
||||
|
||||
const skillNames = adapter.parseConfig(config);
|
||||
|
||||
expect(skillNames).toEqual(['skill-1', 'skill-2']);
|
||||
});
|
||||
|
||||
it('should return empty array for no skills', () => {
|
||||
const config = '<skills_system></skills_system>';
|
||||
|
||||
const skillNames = adapter.parseConfig(config);
|
||||
|
||||
expect(skillNames).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle whitespace in skill names', () => {
|
||||
const config = `
|
||||
<skill>
|
||||
<name> skill-with-spaces </name>
|
||||
</skill>
|
||||
`;
|
||||
|
||||
const skillNames = adapter.parseConfig(config);
|
||||
|
||||
expect(skillNames).toEqual(['skill-with-spaces']);
|
||||
});
|
||||
|
||||
it('should handle multiple name tags', () => {
|
||||
const config = `
|
||||
<name>skill-1</name>
|
||||
<name>skill-2</name>
|
||||
<name>skill-3</name>
|
||||
`;
|
||||
|
||||
const skillNames = adapter.parseConfig(config);
|
||||
|
||||
expect(skillNames).toEqual(['skill-1', 'skill-2', 'skill-3']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getInvokeCommand', () => {
|
||||
it('should return correct invoke command', () => {
|
||||
const command = adapter.getInvokeCommand('test-skill');
|
||||
|
||||
expect(command).toBe('skillkit read test-skill');
|
||||
});
|
||||
|
||||
it('should work with skill names containing hyphens', () => {
|
||||
const command = adapter.getInvokeCommand('my-test-skill');
|
||||
|
||||
expect(command).toBe('skillkit read my-test-skill');
|
||||
});
|
||||
|
||||
it('should work with skill names containing underscores', () => {
|
||||
const command = adapter.getInvokeCommand('my_test_skill');
|
||||
|
||||
expect(command).toBe('skillkit read my_test_skill');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDetected', () => {
|
||||
it('should detect Clawdbot from workspace skills directory', async () => {
|
||||
mockExistsSync.mockImplementation((path) => {
|
||||
return path === join(process.cwd(), 'skills');
|
||||
});
|
||||
|
||||
const detected = await adapter.isDetected();
|
||||
|
||||
expect(detected).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect Clawdbot from global directory', async () => {
|
||||
mockExistsSync.mockImplementation((path) => {
|
||||
return path === join(homedir(), '.clawdbot');
|
||||
});
|
||||
|
||||
const detected = await adapter.isDetected();
|
||||
|
||||
expect(detected).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect Clawdbot from config file', async () => {
|
||||
mockExistsSync.mockImplementation((path) => {
|
||||
return path === join(process.cwd(), 'clawdbot.json');
|
||||
});
|
||||
|
||||
const detected = await adapter.isDetected();
|
||||
|
||||
expect(detected).toBe(true);
|
||||
});
|
||||
|
||||
it('should not detect Clawdbot when no indicators present', async () => {
|
||||
mockExistsSync.mockReturnValue(false);
|
||||
|
||||
const detected = await adapter.isDetected();
|
||||
|
||||
expect(detected).toBe(false);
|
||||
});
|
||||
|
||||
it('should detect when multiple indicators are present', async () => {
|
||||
mockExistsSync.mockReturnValue(true);
|
||||
|
||||
const detected = await adapter.isDetected();
|
||||
|
||||
expect(detected).toBe(true);
|
||||
});
|
||||
|
||||
it('should check all expected paths', async () => {
|
||||
mockExistsSync.mockReturnValue(false);
|
||||
|
||||
await adapter.isDetected();
|
||||
|
||||
expect(mockExistsSync).toHaveBeenCalledWith(join(process.cwd(), 'skills'));
|
||||
expect(mockExistsSync).toHaveBeenCalledWith(join(homedir(), '.clawdbot'));
|
||||
expect(mockExistsSync).toHaveBeenCalledWith(join(process.cwd(), 'clawdbot.json'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('integration', () => {
|
||||
it('should work end-to-end with typical workflow', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'react-patterns',
|
||||
description: 'React best practices',
|
||||
enabled: true,
|
||||
path: '/skills/react-patterns',
|
||||
content: '# React Patterns\n\nBest practices...',
|
||||
},
|
||||
{
|
||||
name: 'typescript-strict',
|
||||
description: 'TypeScript strict mode',
|
||||
enabled: true,
|
||||
path: '/skills/typescript-strict',
|
||||
content: '# TypeScript Strict\n\nUse strict mode...',
|
||||
},
|
||||
];
|
||||
|
||||
// Generate config
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
// Parse config
|
||||
const parsedSkills = adapter.parseConfig(config);
|
||||
|
||||
// Verify round-trip
|
||||
expect(parsedSkills).toEqual(['react-patterns', 'typescript-strict']);
|
||||
|
||||
// Get invoke commands
|
||||
const command1 = adapter.getInvokeCommand('react-patterns');
|
||||
const command2 = adapter.getInvokeCommand('typescript-strict');
|
||||
|
||||
expect(command1).toBe('skillkit read react-patterns');
|
||||
expect(command2).toBe('skillkit read typescript-strict');
|
||||
});
|
||||
|
||||
it('should preserve skill order during generation and parsing', () => {
|
||||
const skills: Skill[] = [
|
||||
{ name: 'a-skill', enabled: true, path: '/a', content: '' },
|
||||
{ name: 'z-skill', enabled: true, path: '/z', content: '' },
|
||||
{ name: 'm-skill', enabled: true, path: '/m', content: '' },
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
const parsed = adapter.parseConfig(config);
|
||||
|
||||
expect(parsed).toEqual(['a-skill', 'z-skill', 'm-skill']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('edge cases', () => {
|
||||
it('should handle empty skills array', () => {
|
||||
const config = adapter.generateConfig([]);
|
||||
expect(config).toBe('');
|
||||
});
|
||||
|
||||
it('should handle skills without descriptions', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'no-desc-skill',
|
||||
enabled: true,
|
||||
path: '/path',
|
||||
content: '# No description',
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('<name>no-desc-skill</name>');
|
||||
expect(config).toContain('<description></description>');
|
||||
});
|
||||
|
||||
it('should handle special characters in skill names', () => {
|
||||
const command = adapter.getInvokeCommand('skill-with-special_chars.123');
|
||||
|
||||
expect(command).toBe('skillkit read skill-with-special_chars.123');
|
||||
});
|
||||
|
||||
it('should handle empty config string during parsing', () => {
|
||||
const parsed = adapter.parseConfig('');
|
||||
|
||||
expect(parsed).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle malformed XML during parsing', () => {
|
||||
const config = '<name>skill-1<name>broken</name>';
|
||||
|
||||
const parsed = adapter.parseConfig(config);
|
||||
|
||||
// Should still extract valid names
|
||||
expect(parsed).toContain('broken');
|
||||
});
|
||||
});
|
||||
|
||||
describe('metadata handling', () => {
|
||||
it('should include skill metadata in generated config', () => {
|
||||
const skills: Skill[] = [
|
||||
{
|
||||
name: 'meta-skill',
|
||||
description: 'Has metadata',
|
||||
enabled: true,
|
||||
path: '/path',
|
||||
content: '# Meta',
|
||||
metadata: {
|
||||
version: '1.0.0',
|
||||
author: 'Test Author',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const config = adapter.generateConfig(skills);
|
||||
|
||||
expect(config).toContain('<name>meta-skill</name>');
|
||||
expect(config).toContain('<description>Has metadata</description>');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
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.amp;
|
||||
|
||||
export class AmpAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'amp';
|
||||
readonly name = 'Amp';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectAmp = join(process.cwd(), '.amp');
|
||||
const globalAmp = join(homedir(), '.amp');
|
||||
|
||||
return existsSync(projectAmp) || existsSync(globalAmp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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 = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsYaml = enabledSkills
|
||||
.map(s => ` - name: ${s.name}\n description: "${s.description}"\n invoke: skillkit read ${s.name}`)
|
||||
.join('\n');
|
||||
|
||||
return `# Antigravity Skills Configuration
|
||||
|
||||
<!-- skills:
|
||||
${skillsYaml}
|
||||
-->
|
||||
|
||||
## Available Skills
|
||||
|
||||
${enabledSkills.map(s => `### ${s.name}
|
||||
|
||||
${s.description}
|
||||
|
||||
**Usage:** \`skillkit read ${s.name}\`
|
||||
`).join('\n')}
|
||||
|
||||
## How Skills Work
|
||||
|
||||
1. Skills provide specialized knowledge for specific tasks
|
||||
2. Load a skill when the current task matches its description
|
||||
3. Skills are loaded on-demand to preserve context window
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
|
||||
const yamlMatch = content.match(/<!-- skills:\s*([\s\S]*?)-->/);
|
||||
if (yamlMatch) {
|
||||
const nameRegex = /name:\s*([a-z0-9-]+)/g;
|
||||
let match;
|
||||
while ((match = nameRegex.exec(yamlMatch[1])) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
if (skillNames.length === 0) {
|
||||
const headerRegex = /^### ([a-z0-9-]+)$/gm;
|
||||
let match;
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const agDir = join(process.cwd(), '.antigravity');
|
||||
const globalAg = join(homedir(), '.antigravity');
|
||||
|
||||
return existsSync(agDir) || existsSync(globalAg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Skill, AgentType } from '@skillkit/core';
|
||||
|
||||
export interface AgentAdapter {
|
||||
readonly type: AgentType;
|
||||
readonly name: string;
|
||||
readonly skillsDir: string;
|
||||
readonly configFile: string;
|
||||
|
||||
generateConfig(skills: Skill[]): string;
|
||||
parseConfig(content: string): string[];
|
||||
getInvokeCommand(skillName: string): string;
|
||||
isDetected(): Promise<boolean>;
|
||||
}
|
||||
|
||||
export function createSkillXml(skill: Skill): string {
|
||||
return `<skill>
|
||||
<name>${skill.name}</name>
|
||||
<description>${escapeXml(skill.description)}</description>
|
||||
<location>${skill.location}</location>
|
||||
</skill>`;
|
||||
}
|
||||
|
||||
export function escapeXml(text: string | undefined): string {
|
||||
if (!text) return '';
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
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['claude-code'];
|
||||
|
||||
export class ClaudeCodeAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'claude-code';
|
||||
readonly name = 'Claude Code';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectClaude = join(process.cwd(), '.claude');
|
||||
const globalClaude = join(homedir(), '.claude');
|
||||
const claudeMd = join(process.cwd(), 'CLAUDE.md');
|
||||
|
||||
return existsSync(projectClaude) || existsSync(globalClaude) || existsSync(claudeMd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
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.clawdbot;
|
||||
|
||||
export class ClawdbotAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'clawdbot';
|
||||
readonly name = 'Clawdbot';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectSkills = join(process.cwd(), 'skills');
|
||||
const globalClawdbot = join(homedir(), '.clawdbot');
|
||||
const clawdbotConfig = join(process.cwd(), 'clawdbot.json');
|
||||
|
||||
return existsSync(projectSkills) || existsSync(globalClawdbot) || existsSync(clawdbotConfig);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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 = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `| ${s.name} | ${s.description} | \`skillkit read ${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
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
Skills are loaded on-demand to keep context clean. Only load skills when relevant to the current task.
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const tableRegex = /^\|\s*([a-z0-9-]+)\s*\|/gm;
|
||||
let match;
|
||||
|
||||
while ((match = tableRegex.exec(content)) !== null) {
|
||||
const name = match[1].trim();
|
||||
if (name && name !== 'Skill' && name !== '-------') {
|
||||
skillNames.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const codexDir = join(process.cwd(), '.codex');
|
||||
const globalCodex = join(homedir(), '.codex');
|
||||
|
||||
return existsSync(codexDir) || existsSync(globalCodex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
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 = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `- **${s.name}**: ${s.description}`)
|
||||
.join('\n');
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
The skill will provide detailed instructions for completing the task.
|
||||
|
||||
<!-- SKILLS_DATA_START -->
|
||||
${skillsXml}
|
||||
<!-- SKILLS_DATA_END -->
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
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(cursorDir) || existsSync(cursorRulesDir) ||
|
||||
existsSync(cursorRulesFile) || existsSync(globalCursor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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.droid;
|
||||
|
||||
export class DroidAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'droid';
|
||||
readonly name = 'Droid (Factory)';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectFactory = join(process.cwd(), '.factory');
|
||||
const globalFactory = join(homedir(), '.factory');
|
||||
|
||||
return existsSync(projectFactory) || existsSync(globalFactory);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
/**
|
||||
* Agent Features Tests
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import {
|
||||
PermissionManager,
|
||||
createPermissionManager,
|
||||
isAllowed,
|
||||
isDenied,
|
||||
needsConfirmation,
|
||||
} from '../permissions.js';
|
||||
import {
|
||||
GlobMatcher,
|
||||
createGlobMatcher,
|
||||
matchPattern,
|
||||
parseGlobsFromMDC,
|
||||
fromCommonPatterns,
|
||||
COMMON_PATTERNS,
|
||||
} from '../globs.js';
|
||||
import {
|
||||
BootstrapManager,
|
||||
createBootstrapManager,
|
||||
createBootstrapSet,
|
||||
} from '../bootstrap.js';
|
||||
import {
|
||||
ModeManager,
|
||||
createModeManager,
|
||||
createDefaultModeManager,
|
||||
ALL_MODES,
|
||||
} from '../modes.js';
|
||||
import type { PermissionConfig, GlobConfig, ModeConfig } from '../types.js';
|
||||
|
||||
describe('PermissionManager', () => {
|
||||
let manager: PermissionManager;
|
||||
|
||||
beforeEach(() => {
|
||||
manager = createPermissionManager();
|
||||
});
|
||||
|
||||
describe('checkFileAccess', () => {
|
||||
it('should return default permission for unmatched files', () => {
|
||||
manager.setConfig({ default: 'ask' });
|
||||
expect(manager.checkFileAccess('some/file.ts')).toBe('ask');
|
||||
});
|
||||
|
||||
it('should match file patterns', () => {
|
||||
manager.setConfig({
|
||||
files: [
|
||||
{ pattern: '*.ts', level: 'allow' },
|
||||
{ pattern: 'secret/*', level: 'deny' },
|
||||
],
|
||||
default: 'ask',
|
||||
});
|
||||
|
||||
expect(manager.checkFileAccess('app.ts')).toBe('allow');
|
||||
expect(manager.checkFileAccess('secret/keys.json')).toBe('deny');
|
||||
expect(manager.checkFileAccess('random.json')).toBe('ask');
|
||||
});
|
||||
|
||||
it('should use first matching pattern', () => {
|
||||
manager.setConfig({
|
||||
files: [
|
||||
{ pattern: '*.ts', level: 'deny' },
|
||||
{ pattern: 'src/*.ts', level: 'allow' },
|
||||
],
|
||||
});
|
||||
|
||||
expect(manager.checkFileAccess('app.ts')).toBe('deny');
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkCommandAccess', () => {
|
||||
it('should check command patterns', () => {
|
||||
manager.setConfig({
|
||||
commands: [
|
||||
{ pattern: 'npm *', level: 'allow' },
|
||||
{ pattern: 'rm *', level: 'deny' },
|
||||
],
|
||||
default: 'ask',
|
||||
});
|
||||
|
||||
expect(manager.checkCommandAccess('npm install')).toBe('allow');
|
||||
expect(manager.checkCommandAccess('rm -rf /')).toBe('deny');
|
||||
expect(manager.checkCommandAccess('git status')).toBe('ask');
|
||||
});
|
||||
});
|
||||
|
||||
describe('addFilePattern', () => {
|
||||
it('should add file pattern', () => {
|
||||
manager.addFilePattern({ pattern: '*.js', level: 'allow' });
|
||||
|
||||
expect(manager.checkFileAccess('app.js')).toBe('allow');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateOpenCodeConfig', () => {
|
||||
it('should generate OpenCode-compatible config', () => {
|
||||
manager.setConfig({
|
||||
files: [{ pattern: 'src/*', level: 'allow' }],
|
||||
commands: [{ pattern: 'npm *', level: 'allow' }],
|
||||
default: 'ask',
|
||||
});
|
||||
|
||||
const config = manager.generateOpenCodeConfig();
|
||||
|
||||
expect(config).toContain('File Access');
|
||||
expect(config).toContain('allow: `src/*`');
|
||||
expect(config).toContain('Command Execution');
|
||||
expect(config).toContain('Default: ask');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateSkillMetadata', () => {
|
||||
it('should generate skill metadata', () => {
|
||||
manager.setConfig({
|
||||
files: [{ pattern: '*.ts', level: 'allow' }],
|
||||
default: 'deny',
|
||||
});
|
||||
|
||||
const metadata = manager.generateSkillMetadata();
|
||||
|
||||
expect(metadata.filePermissions).toHaveLength(1);
|
||||
expect(metadata.defaultPermission).toBe('deny');
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromMetadata', () => {
|
||||
it('should parse permissions from metadata', () => {
|
||||
const metadata = {
|
||||
filePermissions: [{ pattern: '*.ts', level: 'allow' }],
|
||||
defaultPermission: 'ask',
|
||||
};
|
||||
|
||||
const config = PermissionManager.fromMetadata(metadata);
|
||||
|
||||
expect(config.files).toHaveLength(1);
|
||||
expect(config.default).toBe('ask');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Permission helpers', () => {
|
||||
it('isAllowed should work correctly', () => {
|
||||
expect(isAllowed('allow')).toBe(true);
|
||||
expect(isAllowed('deny')).toBe(false);
|
||||
expect(isAllowed('ask')).toBe(false);
|
||||
});
|
||||
|
||||
it('isDenied should work correctly', () => {
|
||||
expect(isDenied('deny')).toBe(true);
|
||||
expect(isDenied('allow')).toBe(false);
|
||||
});
|
||||
|
||||
it('needsConfirmation should work correctly', () => {
|
||||
expect(needsConfirmation('ask')).toBe(true);
|
||||
expect(needsConfirmation('allow')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GlobMatcher', () => {
|
||||
let matcher: GlobMatcher;
|
||||
|
||||
describe('matches', () => {
|
||||
it('should match simple patterns', () => {
|
||||
matcher = createGlobMatcher({ include: ['*.ts'] });
|
||||
|
||||
expect(matcher.matches('app.ts')).toBe(true);
|
||||
expect(matcher.matches('app.js')).toBe(false);
|
||||
});
|
||||
|
||||
it('should match wildcard patterns', () => {
|
||||
matcher = createGlobMatcher({ include: ['src/**/*.ts'] });
|
||||
|
||||
expect(matcher.matches('src/app.ts')).toBe(true);
|
||||
expect(matcher.matches('src/components/Button.ts')).toBe(true);
|
||||
expect(matcher.matches('lib/app.ts')).toBe(false);
|
||||
});
|
||||
|
||||
it('should respect exclude patterns', () => {
|
||||
matcher = createGlobMatcher({
|
||||
include: ['**/*.ts'],
|
||||
exclude: ['**/*.test.ts'],
|
||||
});
|
||||
|
||||
expect(matcher.matches('app.ts')).toBe(true);
|
||||
expect(matcher.matches('app.test.ts')).toBe(false);
|
||||
});
|
||||
|
||||
it('should skip hidden files by default', () => {
|
||||
matcher = createGlobMatcher({ include: ['**/*'] });
|
||||
|
||||
expect(matcher.matches('.hidden/file.ts')).toBe(false);
|
||||
});
|
||||
|
||||
it('should match hidden files when enabled', () => {
|
||||
matcher = createGlobMatcher({
|
||||
include: ['**/*'],
|
||||
matchHidden: true,
|
||||
});
|
||||
|
||||
expect(matcher.matches('.hidden/file.ts')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('filter', () => {
|
||||
it('should filter file list', () => {
|
||||
matcher = createGlobMatcher({ include: ['*.ts'] });
|
||||
|
||||
const files = ['app.ts', 'app.js', 'index.ts'];
|
||||
const result = matcher.filter(files);
|
||||
|
||||
expect(result).toEqual(['app.ts', 'index.ts']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addInclude', () => {
|
||||
it('should add include pattern', () => {
|
||||
matcher = createGlobMatcher({ include: ['*.ts'] });
|
||||
matcher.addInclude('*.js');
|
||||
|
||||
expect(matcher.matches('app.js')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateCursorGlobs', () => {
|
||||
it('should generate Cursor-compatible globs', () => {
|
||||
matcher = createGlobMatcher({
|
||||
include: ['src/**/*.ts'],
|
||||
exclude: ['**/*.test.ts'],
|
||||
});
|
||||
|
||||
const globs = matcher.generateCursorGlobs();
|
||||
|
||||
expect(globs).toContain('src/**/*.ts');
|
||||
expect(globs).toContain('!**/*.test.ts');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('matchPattern', () => {
|
||||
it('should create matcher from single pattern', () => {
|
||||
const matcher = matchPattern('*.ts');
|
||||
|
||||
expect(matcher.matches('app.ts')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseGlobsFromMDC', () => {
|
||||
it('should parse globs from MDC content', () => {
|
||||
const content = `---
|
||||
globs: ["**/*.ts", "!**/*.test.ts"]
|
||||
---
|
||||
Content here`;
|
||||
|
||||
const config = parseGlobsFromMDC(content);
|
||||
|
||||
expect(config?.include).toContain('**/*.ts');
|
||||
expect(config?.exclude).toContain('**/*.test.ts');
|
||||
});
|
||||
|
||||
it('should return null for invalid content', () => {
|
||||
const result = parseGlobsFromMDC('no globs here');
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromCommonPatterns', () => {
|
||||
it('should create config from common patterns', () => {
|
||||
const config = fromCommonPatterns(['typescript', 'source'], ['nodeModules']);
|
||||
|
||||
expect(config.include).toContain('**/*.ts');
|
||||
expect(config.include).toContain('src/**/*');
|
||||
expect(config.exclude).toContain('**/node_modules/**');
|
||||
});
|
||||
});
|
||||
|
||||
describe('COMMON_PATTERNS', () => {
|
||||
it('should have expected patterns', () => {
|
||||
expect(COMMON_PATTERNS.typescript).toContain('**/*.ts');
|
||||
expect(COMMON_PATTERNS.tests).toContain('**/*.test.*');
|
||||
expect(COMMON_PATTERNS.nodeModules).toContain('**/node_modules/**');
|
||||
});
|
||||
});
|
||||
|
||||
describe('BootstrapManager', () => {
|
||||
let manager: BootstrapManager;
|
||||
|
||||
beforeEach(() => {
|
||||
manager = createBootstrapManager();
|
||||
});
|
||||
|
||||
describe('addFile/getFile', () => {
|
||||
it('should add and get files', () => {
|
||||
manager.addFile({
|
||||
type: 'agents',
|
||||
name: 'AGENTS.md',
|
||||
content: '# Agents',
|
||||
priority: 100,
|
||||
});
|
||||
|
||||
const file = manager.getFile('agents');
|
||||
|
||||
expect(file).toBeDefined();
|
||||
expect(file?.name).toBe('AGENTS.md');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFilesByPriority', () => {
|
||||
it('should return files sorted by priority', () => {
|
||||
manager.addFile({ type: 'tools', name: 'TOOLS.md', content: '', priority: 10 });
|
||||
manager.addFile({ type: 'agents', name: 'AGENTS.md', content: '', priority: 100 });
|
||||
manager.addFile({ type: 'soul', name: 'SOUL.md', content: '', priority: 50 });
|
||||
|
||||
const files = manager.getFilesByPriority();
|
||||
|
||||
expect(files[0].type).toBe('agents');
|
||||
expect(files[1].type).toBe('soul');
|
||||
expect(files[2].type).toBe('tools');
|
||||
});
|
||||
});
|
||||
|
||||
describe('createAgentsFile', () => {
|
||||
it('should create AGENTS.md', () => {
|
||||
manager.createAgentsFile([
|
||||
{
|
||||
name: 'Coder',
|
||||
description: 'A coding agent',
|
||||
capabilities: ['Write code', 'Debug'],
|
||||
},
|
||||
]);
|
||||
|
||||
const file = manager.getFile('agents');
|
||||
|
||||
expect(file).toBeDefined();
|
||||
expect(file?.content).toContain('# Agents');
|
||||
expect(file?.content).toContain('## Coder');
|
||||
expect(file?.content).toContain('Write code');
|
||||
});
|
||||
});
|
||||
|
||||
describe('createSoulFile', () => {
|
||||
it('should create SOUL.md', () => {
|
||||
manager.createSoulFile({
|
||||
personality: 'Helpful and precise',
|
||||
values: ['Accuracy', 'Efficiency'],
|
||||
});
|
||||
|
||||
const file = manager.getFile('soul');
|
||||
|
||||
expect(file).toBeDefined();
|
||||
expect(file?.content).toContain('Helpful and precise');
|
||||
expect(file?.content).toContain('Accuracy');
|
||||
});
|
||||
});
|
||||
|
||||
describe('createToolsFile', () => {
|
||||
it('should create TOOLS.md', () => {
|
||||
manager.createToolsFile([
|
||||
{
|
||||
name: 'read_file',
|
||||
description: 'Read a file',
|
||||
usage: 'read_file(path)',
|
||||
},
|
||||
]);
|
||||
|
||||
const file = manager.getFile('tools');
|
||||
|
||||
expect(file).toBeDefined();
|
||||
expect(file?.content).toContain('## read_file');
|
||||
expect(file?.content).toContain('read_file(path)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateCombinedContent', () => {
|
||||
it('should generate combined content', () => {
|
||||
manager.addFile({ type: 'agents', name: 'AGENTS.md', content: '# Agents', priority: 100 });
|
||||
manager.addFile({ type: 'soul', name: 'SOUL.md', content: '# Soul', priority: 50 });
|
||||
|
||||
const combined = manager.generateCombinedContent();
|
||||
|
||||
expect(combined).toContain('<!-- AGENTS.md -->');
|
||||
expect(combined).toContain('# Agents');
|
||||
expect(combined).toContain('<!-- SOUL.md -->');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('createBootstrapSet', () => {
|
||||
it('should create complete bootstrap set', () => {
|
||||
const manager = createBootstrapSet({
|
||||
agents: [{ name: 'Test Agent' }],
|
||||
soul: { personality: 'Friendly' },
|
||||
tools: [{ name: 'tool1' }],
|
||||
});
|
||||
|
||||
expect(manager.hasFile('agents')).toBe(true);
|
||||
expect(manager.hasFile('soul')).toBe(true);
|
||||
expect(manager.hasFile('tools')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ModeManager', () => {
|
||||
let manager: ModeManager;
|
||||
|
||||
beforeEach(() => {
|
||||
manager = createModeManager([
|
||||
{ mode: 'code', description: 'Coding mode', skills: ['tdd', 'debugging'] },
|
||||
{ mode: 'architect', description: 'Architecture mode', skills: ['planning'] },
|
||||
]);
|
||||
});
|
||||
|
||||
describe('addMode/getMode', () => {
|
||||
it('should add and get modes', () => {
|
||||
const mode = manager.getMode('code');
|
||||
|
||||
expect(mode).toBeDefined();
|
||||
expect(mode?.description).toBe('Coding mode');
|
||||
expect(mode?.skills).toContain('tdd');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAvailableModes', () => {
|
||||
it('should return available modes', () => {
|
||||
const modes = manager.getAvailableModes();
|
||||
|
||||
expect(modes).toContain('code');
|
||||
expect(modes).toContain('architect');
|
||||
});
|
||||
});
|
||||
|
||||
describe('setMode/getCurrentMode', () => {
|
||||
it('should set and get current mode', () => {
|
||||
manager.setMode('architect');
|
||||
|
||||
expect(manager.getCurrentMode()).toBe('architect');
|
||||
});
|
||||
|
||||
it('should throw for unconfigured mode', () => {
|
||||
expect(() => manager.setMode('debug')).toThrow('Mode not configured');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCurrentSkills', () => {
|
||||
it('should return skills for current mode', () => {
|
||||
manager.setMode('code');
|
||||
|
||||
const skills = manager.getCurrentSkills();
|
||||
|
||||
expect(skills).toContain('tdd');
|
||||
expect(skills).toContain('debugging');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSkillAvailable', () => {
|
||||
it('should check if skill is available', () => {
|
||||
manager.setMode('code');
|
||||
|
||||
expect(manager.isSkillAvailable('tdd')).toBe(true);
|
||||
expect(manager.isSkillAvailable('planning')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFileAllowed', () => {
|
||||
it('should return true when no patterns defined', () => {
|
||||
expect(manager.isFileAllowed('any/file.ts')).toBe(true);
|
||||
});
|
||||
|
||||
it('should check file patterns when defined', () => {
|
||||
manager.addMode({
|
||||
mode: 'restricted',
|
||||
description: 'Restricted mode',
|
||||
skills: [],
|
||||
allowedFiles: ['src/**/*'],
|
||||
});
|
||||
manager.setMode('restricted');
|
||||
|
||||
expect(manager.isFileAllowed('src/app.ts')).toBe(true);
|
||||
expect(manager.isFileAllowed('lib/util.ts')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addModeListener', () => {
|
||||
it('should notify listeners on mode change', () => {
|
||||
let notified = false;
|
||||
let newModeValue = '';
|
||||
|
||||
manager.addModeListener((newMode) => {
|
||||
notified = true;
|
||||
newModeValue = newMode;
|
||||
});
|
||||
|
||||
manager.setMode('architect');
|
||||
|
||||
expect(notified).toBe(true);
|
||||
expect(newModeValue).toBe('architect');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateRooConfig', () => {
|
||||
it('should generate Roo-compatible config', () => {
|
||||
const config = manager.generateRooConfig();
|
||||
|
||||
expect(config.defaultMode).toBe('code');
|
||||
expect(config.modes).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateModeDocumentation', () => {
|
||||
it('should generate mode documentation', () => {
|
||||
const docs = manager.generateModeDocumentation();
|
||||
|
||||
expect(docs).toContain('# Available Modes');
|
||||
expect(docs).toContain('## code');
|
||||
expect(docs).toContain('## architect');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('createDefaultModeManager', () => {
|
||||
it('should create manager with default modes', () => {
|
||||
const manager = createDefaultModeManager({
|
||||
code: ['tdd'],
|
||||
debug: ['debugging'],
|
||||
});
|
||||
|
||||
const modes = manager.getAvailableModes();
|
||||
|
||||
expect(modes.length).toBe(7); // All default modes
|
||||
expect(manager.getMode('code')?.skills).toContain('tdd');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ALL_MODES', () => {
|
||||
it('should contain all mode types', () => {
|
||||
expect(ALL_MODES).toContain('code');
|
||||
expect(ALL_MODES).toContain('architect');
|
||||
expect(ALL_MODES).toContain('debug');
|
||||
expect(ALL_MODES).toContain('test');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,434 @@
|
||||
/**
|
||||
* Bootstrap Files System
|
||||
*
|
||||
* Implements bootstrap file generation for agents that support them.
|
||||
*/
|
||||
|
||||
import type {
|
||||
BootstrapFile,
|
||||
BootstrapFileType,
|
||||
} from './types.js';
|
||||
|
||||
/**
|
||||
* Default bootstrap file names for each type
|
||||
*/
|
||||
const DEFAULT_FILE_NAMES: Record<BootstrapFileType, string> = {
|
||||
agents: 'AGENTS.md',
|
||||
soul: 'SOUL.md',
|
||||
tools: 'TOOLS.md',
|
||||
identity: 'IDENTITY.md',
|
||||
context: 'CONTEXT.md',
|
||||
brief: 'BRIEF.md',
|
||||
history: 'HISTORY.md',
|
||||
};
|
||||
|
||||
/**
|
||||
* BootstrapManager - Manage bootstrap files for agents
|
||||
*/
|
||||
export class BootstrapManager {
|
||||
private files: Map<BootstrapFileType, BootstrapFile> = new Map();
|
||||
|
||||
/**
|
||||
* Add a bootstrap file
|
||||
*/
|
||||
addFile(file: BootstrapFile): void {
|
||||
this.files.set(file.type, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a bootstrap file by type
|
||||
*/
|
||||
getFile(type: BootstrapFileType): BootstrapFile | undefined {
|
||||
return this.files.get(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all bootstrap files
|
||||
*/
|
||||
getAllFiles(): BootstrapFile[] {
|
||||
return Array.from(this.files.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get files sorted by priority
|
||||
*/
|
||||
getFilesByPriority(): BootstrapFile[] {
|
||||
return this.getAllFiles().sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a bootstrap file
|
||||
*/
|
||||
removeFile(type: BootstrapFileType): boolean {
|
||||
return this.files.delete(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file type exists
|
||||
*/
|
||||
hasFile(type: BootstrapFileType): boolean {
|
||||
return this.files.has(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create AGENTS.md file
|
||||
*/
|
||||
createAgentsFile(agents: AgentDefinition[]): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Agents');
|
||||
lines.push('');
|
||||
lines.push('This file defines the available agents and their capabilities.');
|
||||
lines.push('');
|
||||
|
||||
for (const agent of agents) {
|
||||
lines.push(`## ${agent.name}`);
|
||||
lines.push('');
|
||||
if (agent.description) {
|
||||
lines.push(agent.description);
|
||||
lines.push('');
|
||||
}
|
||||
if (agent.capabilities && agent.capabilities.length > 0) {
|
||||
lines.push('### Capabilities');
|
||||
lines.push('');
|
||||
for (const cap of agent.capabilities) {
|
||||
lines.push(`- ${cap}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
if (agent.constraints && agent.constraints.length > 0) {
|
||||
lines.push('### Constraints');
|
||||
lines.push('');
|
||||
for (const constraint of agent.constraints) {
|
||||
lines.push(`- ${constraint}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
}
|
||||
|
||||
this.addFile({
|
||||
type: 'agents',
|
||||
name: 'AGENTS.md',
|
||||
content: lines.join('\n'),
|
||||
priority: 100,
|
||||
required: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SOUL.md file
|
||||
*/
|
||||
createSoulFile(soul: SoulDefinition): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Soul');
|
||||
lines.push('');
|
||||
lines.push('This file defines the personality and behavior of the agent.');
|
||||
lines.push('');
|
||||
|
||||
if (soul.personality) {
|
||||
lines.push('## Personality');
|
||||
lines.push('');
|
||||
lines.push(soul.personality);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (soul.values && soul.values.length > 0) {
|
||||
lines.push('## Values');
|
||||
lines.push('');
|
||||
for (const value of soul.values) {
|
||||
lines.push(`- ${value}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (soul.communication) {
|
||||
lines.push('## Communication Style');
|
||||
lines.push('');
|
||||
lines.push(soul.communication);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (soul.rules && soul.rules.length > 0) {
|
||||
lines.push('## Rules');
|
||||
lines.push('');
|
||||
for (const rule of soul.rules) {
|
||||
lines.push(`- ${rule}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
this.addFile({
|
||||
type: 'soul',
|
||||
name: 'SOUL.md',
|
||||
content: lines.join('\n'),
|
||||
priority: 90,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create TOOLS.md file
|
||||
*/
|
||||
createToolsFile(tools: ToolDefinition[]): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Tools');
|
||||
lines.push('');
|
||||
lines.push('This file defines the available tools and their usage.');
|
||||
lines.push('');
|
||||
|
||||
for (const tool of tools) {
|
||||
lines.push(`## ${tool.name}`);
|
||||
lines.push('');
|
||||
if (tool.description) {
|
||||
lines.push(tool.description);
|
||||
lines.push('');
|
||||
}
|
||||
if (tool.usage) {
|
||||
lines.push('### Usage');
|
||||
lines.push('');
|
||||
lines.push('```');
|
||||
lines.push(tool.usage);
|
||||
lines.push('```');
|
||||
lines.push('');
|
||||
}
|
||||
if (tool.examples && tool.examples.length > 0) {
|
||||
lines.push('### Examples');
|
||||
lines.push('');
|
||||
for (const example of tool.examples) {
|
||||
lines.push(`- ${example}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
}
|
||||
|
||||
this.addFile({
|
||||
type: 'tools',
|
||||
name: 'TOOLS.md',
|
||||
content: lines.join('\n'),
|
||||
priority: 80,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create IDENTITY.md file
|
||||
*/
|
||||
createIdentityFile(identity: IdentityDefinition): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Identity');
|
||||
lines.push('');
|
||||
|
||||
if (identity.name) {
|
||||
lines.push(`**Name:** ${identity.name}`);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (identity.role) {
|
||||
lines.push(`**Role:** ${identity.role}`);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (identity.description) {
|
||||
lines.push('## Description');
|
||||
lines.push('');
|
||||
lines.push(identity.description);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (identity.expertise && identity.expertise.length > 0) {
|
||||
lines.push('## Expertise');
|
||||
lines.push('');
|
||||
for (const exp of identity.expertise) {
|
||||
lines.push(`- ${exp}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
this.addFile({
|
||||
type: 'identity',
|
||||
name: 'IDENTITY.md',
|
||||
content: lines.join('\n'),
|
||||
priority: 95,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CONTEXT.md file
|
||||
*/
|
||||
createContextFile(context: ContextDefinition): void {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Context');
|
||||
lines.push('');
|
||||
|
||||
if (context.project) {
|
||||
lines.push('## Project');
|
||||
lines.push('');
|
||||
lines.push(context.project);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (context.techStack && context.techStack.length > 0) {
|
||||
lines.push('## Tech Stack');
|
||||
lines.push('');
|
||||
for (const tech of context.techStack) {
|
||||
lines.push(`- ${tech}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (context.conventions && context.conventions.length > 0) {
|
||||
lines.push('## Conventions');
|
||||
lines.push('');
|
||||
for (const conv of context.conventions) {
|
||||
lines.push(`- ${conv}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (context.currentTask) {
|
||||
lines.push('## Current Task');
|
||||
lines.push('');
|
||||
lines.push(context.currentTask);
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
this.addFile({
|
||||
type: 'context',
|
||||
name: 'CONTEXT.md',
|
||||
content: lines.join('\n'),
|
||||
priority: 70,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate all files as a map
|
||||
*/
|
||||
generateFiles(): Map<string, string> {
|
||||
const files = new Map<string, string>();
|
||||
|
||||
for (const file of this.getFilesByPriority()) {
|
||||
files.set(file.name, file.content);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate combined content for agents without file support
|
||||
*/
|
||||
generateCombinedContent(): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const file of this.getFilesByPriority()) {
|
||||
lines.push(`<!-- ${file.name} -->`);
|
||||
lines.push('');
|
||||
lines.push(file.content);
|
||||
lines.push('');
|
||||
lines.push('---');
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default file name for a type
|
||||
*/
|
||||
static getDefaultFileName(type: BootstrapFileType): string {
|
||||
return DEFAULT_FILE_NAMES[type];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent definition for AGENTS.md
|
||||
*/
|
||||
export interface AgentDefinition {
|
||||
name: string;
|
||||
description?: string;
|
||||
capabilities?: string[];
|
||||
constraints?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Soul definition for SOUL.md
|
||||
*/
|
||||
export interface SoulDefinition {
|
||||
personality?: string;
|
||||
values?: string[];
|
||||
communication?: string;
|
||||
rules?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool definition for TOOLS.md
|
||||
*/
|
||||
export interface ToolDefinition {
|
||||
name: string;
|
||||
description?: string;
|
||||
usage?: string;
|
||||
examples?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Identity definition for IDENTITY.md
|
||||
*/
|
||||
export interface IdentityDefinition {
|
||||
name?: string;
|
||||
role?: string;
|
||||
description?: string;
|
||||
expertise?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Context definition for CONTEXT.md
|
||||
*/
|
||||
export interface ContextDefinition {
|
||||
project?: string;
|
||||
techStack?: string[];
|
||||
conventions?: string[];
|
||||
currentTask?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a BootstrapManager instance
|
||||
*/
|
||||
export function createBootstrapManager(): BootstrapManager {
|
||||
return new BootstrapManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a complete bootstrap set from definitions
|
||||
*/
|
||||
export function createBootstrapSet(options: {
|
||||
agents?: AgentDefinition[];
|
||||
soul?: SoulDefinition;
|
||||
tools?: ToolDefinition[];
|
||||
identity?: IdentityDefinition;
|
||||
context?: ContextDefinition;
|
||||
}): BootstrapManager {
|
||||
const manager = new BootstrapManager();
|
||||
|
||||
if (options.agents) {
|
||||
manager.createAgentsFile(options.agents);
|
||||
}
|
||||
|
||||
if (options.soul) {
|
||||
manager.createSoulFile(options.soul);
|
||||
}
|
||||
|
||||
if (options.tools) {
|
||||
manager.createToolsFile(options.tools);
|
||||
}
|
||||
|
||||
if (options.identity) {
|
||||
manager.createIdentityFile(options.identity);
|
||||
}
|
||||
|
||||
if (options.context) {
|
||||
manager.createContextFile(options.context);
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* Glob Pattern System
|
||||
*
|
||||
* Implements file pattern matching for file-scoped skills.
|
||||
*/
|
||||
|
||||
import { minimatch } from 'minimatch';
|
||||
import type { GlobConfig } from './types.js';
|
||||
|
||||
/**
|
||||
* GlobMatcher - Match files against glob patterns
|
||||
*/
|
||||
export class GlobMatcher {
|
||||
private config: GlobConfig;
|
||||
private includePatterns: RegExp[];
|
||||
private excludePatterns: RegExp[];
|
||||
|
||||
constructor(config: GlobConfig) {
|
||||
this.config = config;
|
||||
this.includePatterns = config.include.map((p) => this.patternToRegex(p));
|
||||
this.excludePatterns = (config.exclude || []).map((p) => this.patternToRegex(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file matches the glob patterns
|
||||
*/
|
||||
matches(filePath: string): boolean {
|
||||
// Normalize path separators
|
||||
const normalizedPath = filePath.replace(/\\/g, '/');
|
||||
|
||||
// Check if hidden file and skip if not matching hidden
|
||||
if (!this.config.matchHidden && this.isHiddenFile(normalizedPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check exclude patterns first
|
||||
for (const pattern of this.excludePatterns) {
|
||||
if (pattern.test(normalizedPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check include patterns
|
||||
for (const pattern of this.includePatterns) {
|
||||
if (pattern.test(normalizedPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a list of files
|
||||
*/
|
||||
filter(filePaths: string[]): string[] {
|
||||
return filePaths.filter((p) => this.matches(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all include patterns
|
||||
*/
|
||||
getIncludePatterns(): string[] {
|
||||
return [...this.config.include];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all exclude patterns
|
||||
*/
|
||||
getExcludePatterns(): string[] {
|
||||
return [...(this.config.exclude || [])];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an include pattern
|
||||
*/
|
||||
addInclude(pattern: string): void {
|
||||
this.config.include.push(pattern);
|
||||
this.includePatterns.push(this.patternToRegex(pattern));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an exclude pattern
|
||||
*/
|
||||
addExclude(pattern: string): void {
|
||||
if (!this.config.exclude) {
|
||||
this.config.exclude = [];
|
||||
}
|
||||
this.config.exclude.push(pattern);
|
||||
this.excludePatterns.push(this.patternToRegex(pattern));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert glob pattern to regex using minimatch
|
||||
*
|
||||
* Uses the battle-tested minimatch library to avoid ReDoS vulnerabilities
|
||||
* and ensure consistent glob matching behavior.
|
||||
*/
|
||||
private patternToRegex(pattern: string): RegExp {
|
||||
// Handle negation
|
||||
const isNegated = pattern.startsWith('!');
|
||||
const cleanPattern = isNegated ? pattern.slice(1) : pattern;
|
||||
|
||||
// Adjust pattern for directory matching
|
||||
let adjustedPattern = cleanPattern;
|
||||
if (this.config.matchDirectories && !cleanPattern.endsWith('/**')) {
|
||||
// Append /** to match directories and their contents
|
||||
adjustedPattern = cleanPattern.endsWith('/')
|
||||
? `${cleanPattern}**`
|
||||
: `${cleanPattern}/**`;
|
||||
}
|
||||
|
||||
// Use minimatch to create a safe regex
|
||||
// minimatch returns null if pattern is invalid, fallback to match-nothing regex
|
||||
const regex = minimatch.makeRe(adjustedPattern, { dot: this.config.matchHidden });
|
||||
|
||||
return regex || /(?!)/; // /(?!)/ is a regex that never matches anything
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file is hidden (starts with .)
|
||||
*/
|
||||
private isHiddenFile(path: string): boolean {
|
||||
const parts = path.split('/');
|
||||
return parts.some((part) => part.startsWith('.') && part !== '.' && part !== '..');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Cursor-compatible globs field
|
||||
*/
|
||||
generateCursorGlobs(): string[] {
|
||||
const globs: string[] = [...this.config.include];
|
||||
|
||||
// Add negated exclude patterns
|
||||
if (this.config.exclude) {
|
||||
for (const pattern of this.config.exclude) {
|
||||
globs.push(`!${pattern}`);
|
||||
}
|
||||
}
|
||||
|
||||
return globs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate MDC frontmatter
|
||||
*/
|
||||
generateMDCFrontmatter(): string {
|
||||
const globs = this.generateCursorGlobs();
|
||||
return `globs: ${JSON.stringify(globs)}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GlobMatcher instance
|
||||
*/
|
||||
export function createGlobMatcher(config: GlobConfig): GlobMatcher {
|
||||
return new GlobMatcher(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GlobMatcher from a single pattern
|
||||
*/
|
||||
export function matchPattern(pattern: string): GlobMatcher {
|
||||
return new GlobMatcher({ include: [pattern] });
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse glob patterns from Cursor MDC format
|
||||
*/
|
||||
export function parseGlobsFromMDC(content: string): GlobConfig | null {
|
||||
const match = content.match(/globs:\s*(\[.*?\])/s);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const patterns = JSON.parse(match[1]) as string[];
|
||||
const include: string[] = [];
|
||||
const exclude: string[] = [];
|
||||
|
||||
for (const pattern of patterns) {
|
||||
if (pattern.startsWith('!')) {
|
||||
exclude.push(pattern.slice(1));
|
||||
} else {
|
||||
include.push(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
return { include, exclude };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common glob patterns for different file types
|
||||
*/
|
||||
export const COMMON_PATTERNS = {
|
||||
/** All TypeScript files */
|
||||
typescript: ['**/*.ts', '**/*.tsx'],
|
||||
/** All JavaScript files */
|
||||
javascript: ['**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs'],
|
||||
/** All test files */
|
||||
tests: ['**/*.test.*', '**/*.spec.*', '**/__tests__/**'],
|
||||
/** All config files */
|
||||
configs: ['*.config.*', '*rc', '*rc.*', '*.json', '*.yaml', '*.yml'],
|
||||
/** All source files */
|
||||
source: ['src/**/*'],
|
||||
/** All documentation */
|
||||
docs: ['**/*.md', 'docs/**/*', 'README*'],
|
||||
/** Node modules (usually excluded) */
|
||||
nodeModules: ['**/node_modules/**'],
|
||||
/** Build outputs (usually excluded) */
|
||||
buildOutputs: ['**/dist/**', '**/build/**', '**/.next/**'],
|
||||
/** All files */
|
||||
all: ['**/*'],
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Create glob config from common pattern names
|
||||
*/
|
||||
export function fromCommonPatterns(
|
||||
includeNames: (keyof typeof COMMON_PATTERNS)[],
|
||||
excludeNames?: (keyof typeof COMMON_PATTERNS)[]
|
||||
): GlobConfig {
|
||||
const include: string[] = [];
|
||||
const exclude: string[] = [];
|
||||
|
||||
for (const name of includeNames) {
|
||||
include.push(...COMMON_PATTERNS[name]);
|
||||
}
|
||||
|
||||
if (excludeNames) {
|
||||
for (const name of excludeNames) {
|
||||
exclude.push(...COMMON_PATTERNS[name]);
|
||||
}
|
||||
}
|
||||
|
||||
return { include, exclude };
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Agent Features Module
|
||||
*
|
||||
* Enhanced agent-specific features including:
|
||||
* - Permissions system (OpenCode-style)
|
||||
* - Glob pattern matching (Cursor-style)
|
||||
* - Bootstrap files (Amp-style)
|
||||
* - Multi-mode support (Roo/Kilo-style)
|
||||
*/
|
||||
|
||||
export * from './types.js';
|
||||
export * from './permissions.js';
|
||||
export * from './globs.js';
|
||||
export * from './bootstrap.js';
|
||||
export * from './modes.js';
|
||||
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
* Multi-Mode System
|
||||
*
|
||||
* Implements multi-mode support for agents that support different operating modes.
|
||||
*/
|
||||
|
||||
import type { AgentMode, ModeConfig } from './types.js';
|
||||
import { GlobMatcher } from './globs.js';
|
||||
|
||||
/**
|
||||
* Default mode configurations
|
||||
*/
|
||||
const DEFAULT_MODES: Record<AgentMode, Omit<ModeConfig, 'skills'>> = {
|
||||
code: {
|
||||
mode: 'code',
|
||||
description: 'Code editing and implementation mode',
|
||||
promptPrefix: 'You are in code mode. Focus on writing and editing code.',
|
||||
},
|
||||
architect: {
|
||||
mode: 'architect',
|
||||
description: 'Architecture and planning mode',
|
||||
promptPrefix: 'You are in architect mode. Focus on system design and planning.',
|
||||
},
|
||||
ask: {
|
||||
mode: 'ask',
|
||||
description: 'Question and answer mode',
|
||||
promptPrefix: 'You are in ask mode. Focus on answering questions clearly.',
|
||||
},
|
||||
debug: {
|
||||
mode: 'debug',
|
||||
description: 'Debugging and troubleshooting mode',
|
||||
promptPrefix: 'You are in debug mode. Focus on finding and fixing issues.',
|
||||
},
|
||||
review: {
|
||||
mode: 'review',
|
||||
description: 'Code review mode',
|
||||
promptPrefix: 'You are in review mode. Focus on reviewing code quality.',
|
||||
},
|
||||
test: {
|
||||
mode: 'test',
|
||||
description: 'Testing mode',
|
||||
promptPrefix: 'You are in test mode. Focus on writing and running tests.',
|
||||
},
|
||||
docs: {
|
||||
mode: 'docs',
|
||||
description: 'Documentation mode',
|
||||
promptPrefix: 'You are in docs mode. Focus on writing documentation.',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* ModeManager - Manage agent operating modes
|
||||
*/
|
||||
export class ModeManager {
|
||||
private modes: Map<AgentMode, ModeConfig> = new Map();
|
||||
private currentMode: AgentMode = 'code';
|
||||
private modeListeners: Set<ModeChangeListener> = new Set();
|
||||
|
||||
constructor(modes?: ModeConfig[]) {
|
||||
if (modes) {
|
||||
for (const mode of modes) {
|
||||
this.addMode(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mode configuration
|
||||
*/
|
||||
addMode(config: ModeConfig): void {
|
||||
this.modes.set(config.mode, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a mode configuration
|
||||
*/
|
||||
getMode(mode: AgentMode): ModeConfig | undefined {
|
||||
return this.modes.get(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all mode configurations
|
||||
*/
|
||||
getAllModes(): ModeConfig[] {
|
||||
return Array.from(this.modes.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available mode names
|
||||
*/
|
||||
getAvailableModes(): AgentMode[] {
|
||||
return Array.from(this.modes.keys());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current mode
|
||||
*/
|
||||
setMode(mode: AgentMode): void {
|
||||
const config = this.modes.get(mode);
|
||||
if (!config) {
|
||||
throw new Error(`Mode not configured: ${mode}`);
|
||||
}
|
||||
|
||||
const previousMode = this.currentMode;
|
||||
this.currentMode = mode;
|
||||
|
||||
// Notify listeners
|
||||
for (const listener of this.modeListeners) {
|
||||
listener(mode, previousMode, config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current mode
|
||||
*/
|
||||
getCurrentMode(): AgentMode {
|
||||
return this.currentMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current mode configuration
|
||||
*/
|
||||
getCurrentModeConfig(): ModeConfig | undefined {
|
||||
return this.modes.get(this.currentMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get skills for current mode
|
||||
*/
|
||||
getCurrentSkills(): string[] {
|
||||
const config = this.getCurrentModeConfig();
|
||||
return config?.skills || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tools for current mode
|
||||
*/
|
||||
getCurrentTools(): string[] {
|
||||
const config = this.getCurrentModeConfig();
|
||||
return config?.tools || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a skill is available in current mode
|
||||
*/
|
||||
isSkillAvailable(skillName: string): boolean {
|
||||
const skills = this.getCurrentSkills();
|
||||
return skills.length === 0 || skills.includes(skillName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is allowed in current mode
|
||||
*/
|
||||
isFileAllowed(filePath: string): boolean {
|
||||
const config = this.getCurrentModeConfig();
|
||||
if (!config?.allowedFiles || config.allowedFiles.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const matcher = new GlobMatcher({ include: config.allowedFiles });
|
||||
return matcher.matches(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mode change listener
|
||||
*/
|
||||
addModeListener(listener: ModeChangeListener): void {
|
||||
this.modeListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove mode change listener
|
||||
*/
|
||||
removeModeListener(listener: ModeChangeListener): void {
|
||||
this.modeListeners.delete(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a mode from default configuration
|
||||
*/
|
||||
addDefaultMode(mode: AgentMode, skills: string[]): void {
|
||||
const defaultConfig = DEFAULT_MODES[mode];
|
||||
this.addMode({
|
||||
...defaultConfig,
|
||||
skills,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate mode-specific prompt prefix
|
||||
*/
|
||||
getPromptPrefix(): string {
|
||||
const config = this.getCurrentModeConfig();
|
||||
return config?.promptPrefix || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Roo-compatible mode configuration
|
||||
*/
|
||||
generateRooConfig(): Record<string, unknown> {
|
||||
const modes: Record<string, unknown> = {};
|
||||
|
||||
for (const config of this.modes.values()) {
|
||||
modes[config.mode] = {
|
||||
description: config.description,
|
||||
skills: config.skills,
|
||||
tools: config.tools,
|
||||
promptPrefix: config.promptPrefix,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
defaultMode: this.currentMode,
|
||||
modes,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate mode documentation
|
||||
*/
|
||||
generateModeDocumentation(): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Available Modes');
|
||||
lines.push('');
|
||||
|
||||
for (const config of this.modes.values()) {
|
||||
lines.push(`## ${config.mode}`);
|
||||
lines.push('');
|
||||
lines.push(config.description);
|
||||
lines.push('');
|
||||
|
||||
if (config.skills.length > 0) {
|
||||
lines.push('### Skills');
|
||||
lines.push('');
|
||||
for (const skill of config.skills) {
|
||||
lines.push(`- ${skill}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (config.tools && config.tools.length > 0) {
|
||||
lines.push('### Tools');
|
||||
lines.push('');
|
||||
for (const tool of config.tools) {
|
||||
lines.push(`- ${tool}`);
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mode change listener type
|
||||
*/
|
||||
export type ModeChangeListener = (
|
||||
newMode: AgentMode,
|
||||
previousMode: AgentMode,
|
||||
config: ModeConfig
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Create a ModeManager instance
|
||||
*/
|
||||
export function createModeManager(modes?: ModeConfig[]): ModeManager {
|
||||
return new ModeManager(modes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ModeManager with all default modes
|
||||
*/
|
||||
export function createDefaultModeManager(
|
||||
skillsPerMode: Partial<Record<AgentMode, string[]>>
|
||||
): ModeManager {
|
||||
const manager = new ModeManager();
|
||||
|
||||
for (const [mode, config] of Object.entries(DEFAULT_MODES)) {
|
||||
const skills = skillsPerMode[mode as AgentMode] || [];
|
||||
manager.addMode({
|
||||
...config,
|
||||
skills,
|
||||
});
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default configuration for a mode
|
||||
*/
|
||||
export function getDefaultModeConfig(mode: AgentMode): Omit<ModeConfig, 'skills'> {
|
||||
return DEFAULT_MODES[mode];
|
||||
}
|
||||
|
||||
/**
|
||||
* All available agent modes
|
||||
*/
|
||||
export const ALL_MODES: AgentMode[] = ['code', 'architect', 'ask', 'debug', 'review', 'test', 'docs'];
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* Permissions System
|
||||
*
|
||||
* Implements permission patterns for agent skill access control.
|
||||
*/
|
||||
|
||||
import { minimatch } from 'minimatch';
|
||||
import type {
|
||||
PermissionConfig,
|
||||
PermissionPattern,
|
||||
PermissionLevel,
|
||||
} from './types.js';
|
||||
|
||||
/**
|
||||
* PermissionManager - Manage skill permissions
|
||||
*/
|
||||
export class PermissionManager {
|
||||
private config: PermissionConfig;
|
||||
|
||||
constructor(config?: PermissionConfig) {
|
||||
this.config = config || { default: 'ask' };
|
||||
}
|
||||
|
||||
/**
|
||||
* Set permission configuration
|
||||
*/
|
||||
setConfig(config: PermissionConfig): void {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permission configuration
|
||||
*/
|
||||
getConfig(): PermissionConfig {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check file access permission
|
||||
*/
|
||||
checkFileAccess(path: string): PermissionLevel {
|
||||
return this.checkPattern(path, this.config.files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check command execution permission
|
||||
*/
|
||||
checkCommandAccess(command: string): PermissionLevel {
|
||||
return this.checkPattern(command, this.config.commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check network access permission
|
||||
*/
|
||||
checkNetworkAccess(url: string): PermissionLevel {
|
||||
return this.checkPattern(url, this.config.network);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check environment variable access
|
||||
*/
|
||||
checkEnvAccess(varName: string): PermissionLevel {
|
||||
return this.checkPattern(varName, this.config.env);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add file permission pattern
|
||||
*/
|
||||
addFilePattern(pattern: PermissionPattern): void {
|
||||
if (!this.config.files) {
|
||||
this.config.files = [];
|
||||
}
|
||||
this.config.files.push(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add command permission pattern
|
||||
*/
|
||||
addCommandPattern(pattern: PermissionPattern): void {
|
||||
if (!this.config.commands) {
|
||||
this.config.commands = [];
|
||||
}
|
||||
this.config.commands.push(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check pattern against permission list
|
||||
*/
|
||||
private checkPattern(
|
||||
value: string,
|
||||
patterns?: PermissionPattern[]
|
||||
): PermissionLevel {
|
||||
if (!patterns || patterns.length === 0) {
|
||||
return this.config.default || 'ask';
|
||||
}
|
||||
|
||||
// Check patterns in order (first match wins)
|
||||
for (const pattern of patterns) {
|
||||
if (this.matchPattern(value, pattern.pattern)) {
|
||||
return pattern.level;
|
||||
}
|
||||
}
|
||||
|
||||
return this.config.default || 'ask';
|
||||
}
|
||||
|
||||
/**
|
||||
* Match value against pattern (glob-style)
|
||||
*
|
||||
* Uses minimatch for safe glob matching, avoiding ReDoS vulnerabilities.
|
||||
*/
|
||||
private matchPattern(value: string, pattern: string): boolean {
|
||||
// Use minimatch for safe, battle-tested glob matching
|
||||
// nocase option ensures case-insensitive matching
|
||||
return minimatch(value, pattern, { nocase: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate OpenCode-compatible permission config
|
||||
*/
|
||||
generateOpenCodeConfig(): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push('# Permission Configuration');
|
||||
lines.push('');
|
||||
|
||||
if (this.config.files && this.config.files.length > 0) {
|
||||
lines.push('## File Access');
|
||||
lines.push('');
|
||||
for (const pattern of this.config.files) {
|
||||
lines.push(`- ${pattern.level}: \`${pattern.pattern}\``);
|
||||
if (pattern.reason) {
|
||||
lines.push(` - Reason: ${pattern.reason}`);
|
||||
}
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (this.config.commands && this.config.commands.length > 0) {
|
||||
lines.push('## Command Execution');
|
||||
lines.push('');
|
||||
for (const pattern of this.config.commands) {
|
||||
lines.push(`- ${pattern.level}: \`${pattern.pattern}\``);
|
||||
if (pattern.reason) {
|
||||
lines.push(` - Reason: ${pattern.reason}`);
|
||||
}
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
if (this.config.network && this.config.network.length > 0) {
|
||||
lines.push('## Network Access');
|
||||
lines.push('');
|
||||
for (const pattern of this.config.network) {
|
||||
lines.push(`- ${pattern.level}: \`${pattern.pattern}\``);
|
||||
if (pattern.reason) {
|
||||
lines.push(` - Reason: ${pattern.reason}`);
|
||||
}
|
||||
}
|
||||
lines.push('');
|
||||
}
|
||||
|
||||
lines.push(`Default: ${this.config.default || 'ask'}`);
|
||||
lines.push('');
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate SKILL.md metadata for permissions
|
||||
*/
|
||||
generateSkillMetadata(): Record<string, unknown> {
|
||||
const metadata: Record<string, unknown> = {};
|
||||
|
||||
if (this.config.files) {
|
||||
metadata.filePermissions = this.config.files.map((p) => ({
|
||||
pattern: p.pattern,
|
||||
level: p.level,
|
||||
}));
|
||||
}
|
||||
|
||||
if (this.config.commands) {
|
||||
metadata.commandPermissions = this.config.commands.map((p) => ({
|
||||
pattern: p.pattern,
|
||||
level: p.level,
|
||||
}));
|
||||
}
|
||||
|
||||
if (this.config.network) {
|
||||
metadata.networkPermissions = this.config.network.map((p) => ({
|
||||
pattern: p.pattern,
|
||||
level: p.level,
|
||||
}));
|
||||
}
|
||||
|
||||
if (this.config.default) {
|
||||
metadata.defaultPermission = this.config.default;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse permissions from SKILL.md metadata
|
||||
*/
|
||||
static fromMetadata(metadata: Record<string, unknown>): PermissionConfig {
|
||||
const config: PermissionConfig = {};
|
||||
|
||||
if (metadata.filePermissions && Array.isArray(metadata.filePermissions)) {
|
||||
config.files = metadata.filePermissions as PermissionPattern[];
|
||||
}
|
||||
|
||||
if (metadata.commandPermissions && Array.isArray(metadata.commandPermissions)) {
|
||||
config.commands = metadata.commandPermissions as PermissionPattern[];
|
||||
}
|
||||
|
||||
if (metadata.networkPermissions && Array.isArray(metadata.networkPermissions)) {
|
||||
config.network = metadata.networkPermissions as PermissionPattern[];
|
||||
}
|
||||
|
||||
if (metadata.defaultPermission) {
|
||||
config.default = metadata.defaultPermission as PermissionLevel;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge two permission configs
|
||||
*/
|
||||
static merge(base: PermissionConfig, override: PermissionConfig): PermissionConfig {
|
||||
return {
|
||||
files: [...(base.files || []), ...(override.files || [])],
|
||||
commands: [...(base.commands || []), ...(override.commands || [])],
|
||||
network: [...(base.network || []), ...(override.network || [])],
|
||||
env: [...(base.env || []), ...(override.env || [])],
|
||||
default: override.default || base.default,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a PermissionManager instance
|
||||
*/
|
||||
export function createPermissionManager(config?: PermissionConfig): PermissionManager {
|
||||
return new PermissionManager(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick permission check helpers
|
||||
*/
|
||||
export function isAllowed(level: PermissionLevel): boolean {
|
||||
return level === 'allow';
|
||||
}
|
||||
|
||||
export function isDenied(level: PermissionLevel): boolean {
|
||||
return level === 'deny';
|
||||
}
|
||||
|
||||
export function needsConfirmation(level: PermissionLevel): boolean {
|
||||
return level === 'ask';
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* Agent Features Types
|
||||
*
|
||||
* Type definitions for enhanced agent-specific features.
|
||||
*/
|
||||
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
|
||||
/**
|
||||
* Permission level for agent actions
|
||||
*/
|
||||
export type PermissionLevel = 'allow' | 'deny' | 'ask';
|
||||
|
||||
/**
|
||||
* Permission pattern for file/resource access
|
||||
*/
|
||||
export interface PermissionPattern {
|
||||
/** Pattern to match (glob or regex) */
|
||||
pattern: string;
|
||||
/** Permission level */
|
||||
level: PermissionLevel;
|
||||
/** Description of why this permission is needed */
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission configuration for skills
|
||||
*/
|
||||
export interface PermissionConfig {
|
||||
/** File access permissions */
|
||||
files?: PermissionPattern[];
|
||||
/** Command execution permissions */
|
||||
commands?: PermissionPattern[];
|
||||
/** Network access permissions */
|
||||
network?: PermissionPattern[];
|
||||
/** Environment variable access */
|
||||
env?: PermissionPattern[];
|
||||
/** Default permission level */
|
||||
default?: PermissionLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Glob pattern configuration for file-scoped skills
|
||||
*/
|
||||
export interface GlobConfig {
|
||||
/** Patterns to include */
|
||||
include: string[];
|
||||
/** Patterns to exclude */
|
||||
exclude?: string[];
|
||||
/** Whether to match directories */
|
||||
matchDirectories?: boolean;
|
||||
/** Whether to match hidden files */
|
||||
matchHidden?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap file types
|
||||
*/
|
||||
export type BootstrapFileType =
|
||||
| 'agents' // AGENTS.md - Agent definitions
|
||||
| 'soul' // SOUL.md - Personality and behavior
|
||||
| 'tools' // TOOLS.md - Available tools
|
||||
| 'identity' // IDENTITY.md - Agent identity
|
||||
| 'context' // CONTEXT.md - Context information
|
||||
| 'brief' // BRIEF.md - Project brief
|
||||
| 'history'; // HISTORY.md - Conversation history
|
||||
|
||||
/**
|
||||
* Bootstrap file configuration
|
||||
*/
|
||||
export interface BootstrapFile {
|
||||
/** File type */
|
||||
type: BootstrapFileType;
|
||||
/** File name */
|
||||
name: string;
|
||||
/** File content */
|
||||
content: string;
|
||||
/** Priority (higher = loaded first) */
|
||||
priority?: number;
|
||||
/** Whether file is required */
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent mode types
|
||||
*/
|
||||
export type AgentMode =
|
||||
| 'code' // Code editing mode
|
||||
| 'architect' // Architecture/planning mode
|
||||
| 'ask' // Question/answer mode
|
||||
| 'debug' // Debugging mode
|
||||
| 'review' // Code review mode
|
||||
| 'test' // Testing mode
|
||||
| 'docs'; // Documentation mode
|
||||
|
||||
/**
|
||||
* Mode configuration
|
||||
*/
|
||||
export interface ModeConfig {
|
||||
/** Mode name */
|
||||
mode: AgentMode;
|
||||
/** Mode description */
|
||||
description: string;
|
||||
/** Skills available in this mode */
|
||||
skills: string[];
|
||||
/** Tools available in this mode */
|
||||
tools?: string[];
|
||||
/** Default prompt prefix for this mode */
|
||||
promptPrefix?: string;
|
||||
/** Allowed file patterns in this mode */
|
||||
allowedFiles?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool whitelist configuration
|
||||
*/
|
||||
export interface ToolWhitelistConfig {
|
||||
/** Allowed tools */
|
||||
allowed: string[];
|
||||
/** Denied tools */
|
||||
denied?: string[];
|
||||
/** Mode for handling unlisted tools */
|
||||
unlisted?: 'allow' | 'deny' | 'ask';
|
||||
}
|
||||
|
||||
/**
|
||||
* Skill package configuration (for .skill bundles)
|
||||
*/
|
||||
export interface SkillPackageConfig {
|
||||
/** Package name */
|
||||
name: string;
|
||||
/** Package version */
|
||||
version: string;
|
||||
/** Package description */
|
||||
description?: string;
|
||||
/** Entry point skill */
|
||||
entryPoint: string;
|
||||
/** Included skill files */
|
||||
files: string[];
|
||||
/** Dependencies */
|
||||
dependencies?: string[];
|
||||
/** Metadata */
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent feature capabilities
|
||||
*/
|
||||
export interface AgentCapabilities {
|
||||
/** Supports permission system */
|
||||
permissions: boolean;
|
||||
/** Supports glob patterns */
|
||||
globs: boolean;
|
||||
/** Supports bootstrap files */
|
||||
bootstrapFiles: boolean;
|
||||
/** Supports multi-mode */
|
||||
multiMode: boolean;
|
||||
/** Supports tool whitelisting */
|
||||
toolWhitelist: boolean;
|
||||
/** Supports .skill packages */
|
||||
skillPackages: boolean;
|
||||
/** Supports hooks */
|
||||
hooks: boolean;
|
||||
/** Supports subagents */
|
||||
subagents: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agent feature set
|
||||
*/
|
||||
export interface AgentFeatures {
|
||||
/** Agent type */
|
||||
agent: AgentType;
|
||||
/** Agent capabilities */
|
||||
capabilities: AgentCapabilities;
|
||||
/** Permission configuration */
|
||||
permissions?: PermissionConfig;
|
||||
/** Glob configuration */
|
||||
globs?: GlobConfig;
|
||||
/** Bootstrap files */
|
||||
bootstrapFiles?: BootstrapFile[];
|
||||
/** Mode configurations */
|
||||
modes?: ModeConfig[];
|
||||
/** Tool whitelist */
|
||||
toolWhitelist?: ToolWhitelistConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature generation options
|
||||
*/
|
||||
export interface FeatureGenerationOptions {
|
||||
/** Target agent */
|
||||
agent: AgentType;
|
||||
/** Output directory */
|
||||
outputDir?: string;
|
||||
/** Include optional files */
|
||||
includeOptional?: boolean;
|
||||
/** Dry run (don't write files) */
|
||||
dryRun?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature validation result
|
||||
*/
|
||||
export interface FeatureValidationResult {
|
||||
/** Whether features are valid */
|
||||
valid: boolean;
|
||||
/** Validation errors */
|
||||
errors: string[];
|
||||
/** Validation warnings */
|
||||
warnings: string[];
|
||||
/** Agent capabilities used */
|
||||
usedCapabilities: (keyof AgentCapabilities)[];
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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 = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsJson = enabledSkills.map(s => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
invoke: `skillkit read ${s.name}`,
|
||||
location: s.location,
|
||||
}));
|
||||
|
||||
return `# Skills Configuration
|
||||
|
||||
You have access to specialized skills that extend your capabilities.
|
||||
|
||||
## Available Skills
|
||||
|
||||
${enabledSkills.map(s => `### ${s.name}\n${s.description}\n\nInvoke: \`skillkit read ${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
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
|
||||
const jsonMatch = content.match(/```json\s*([\s\S]*?)```/);
|
||||
if (jsonMatch) {
|
||||
try {
|
||||
const skills = JSON.parse(jsonMatch[1]);
|
||||
if (Array.isArray(skills)) {
|
||||
skills.forEach(s => {
|
||||
if (s.name) skillNames.push(s.name);
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// Ignore parse errors
|
||||
}
|
||||
}
|
||||
|
||||
if (skillNames.length === 0) {
|
||||
const headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const geminiMd = join(process.cwd(), 'GEMINI.md');
|
||||
const geminiDir = join(process.cwd(), '.gemini');
|
||||
const globalGemini = join(homedir(), '.gemini');
|
||||
|
||||
return existsSync(geminiMd) || existsSync(geminiDir) || existsSync(globalGemini);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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['github-copilot'];
|
||||
|
||||
export class GitHubCopilotAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'github-copilot';
|
||||
readonly name = 'GitHub Copilot';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`skillkit read ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
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
|
||||
|
||||
${skillsList}
|
||||
|
||||
## How to Use Skills
|
||||
|
||||
When a task matches a skill's description, load it using the terminal:
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
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 headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const copilotInstructions = join(process.cwd(), '.github', 'copilot-instructions.md');
|
||||
const githubInstructions = join(process.cwd(), '.github', 'instructions');
|
||||
const globalCopilot = join(homedir(), '.copilot');
|
||||
|
||||
return existsSync(copilotInstructions) ||
|
||||
existsSync(githubInstructions) || existsSync(globalCopilot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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.goose;
|
||||
|
||||
export class GooseAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'goose';
|
||||
readonly name = 'Goose';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectGoose = join(process.cwd(), '.goose');
|
||||
const globalGoose = join(homedir(), '.config', 'goose');
|
||||
|
||||
return existsSync(projectGoose) || existsSync(globalGoose);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { AgentAdapter } from './base.js';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
import { ClaudeCodeAdapter } from './claude-code.js';
|
||||
import { CursorAdapter } from './cursor.js';
|
||||
import { CodexAdapter } from './codex.js';
|
||||
import { GeminiCliAdapter } from './gemini-cli.js';
|
||||
import { OpenCodeAdapter } from './opencode.js';
|
||||
import { AntigravityAdapter } from './antigravity.js';
|
||||
import { AmpAdapter } from './amp.js';
|
||||
import { ClawdbotAdapter } from './clawdbot.js';
|
||||
import { DroidAdapter } from './droid.js';
|
||||
import { GitHubCopilotAdapter } from './github-copilot.js';
|
||||
import { GooseAdapter } from './goose.js';
|
||||
import { KiloAdapter } from './kilo.js';
|
||||
import { KiroCliAdapter } from './kiro-cli.js';
|
||||
import { RooAdapter } from './roo.js';
|
||||
import { TraeAdapter } from './trae.js';
|
||||
import { WindsurfAdapter } from './windsurf.js';
|
||||
import { UniversalAdapter } from './universal.js';
|
||||
|
||||
export * from './base.js';
|
||||
export * from './claude-code.js';
|
||||
export * from './cursor.js';
|
||||
export * from './codex.js';
|
||||
export * from './gemini-cli.js';
|
||||
export * from './opencode.js';
|
||||
export * from './antigravity.js';
|
||||
export * from './amp.js';
|
||||
export * from './clawdbot.js';
|
||||
export * from './droid.js';
|
||||
export * from './github-copilot.js';
|
||||
export * from './goose.js';
|
||||
export * from './kilo.js';
|
||||
export * from './kiro-cli.js';
|
||||
export * from './roo.js';
|
||||
export * from './trae.js';
|
||||
export * from './windsurf.js';
|
||||
export * from './universal.js';
|
||||
|
||||
// Agent features
|
||||
export * from './features/index.js';
|
||||
|
||||
const adapters: Record<AgentType, AgentAdapter> = {
|
||||
'claude-code': new ClaudeCodeAdapter(),
|
||||
cursor: new CursorAdapter(),
|
||||
codex: new CodexAdapter(),
|
||||
'gemini-cli': new GeminiCliAdapter(),
|
||||
opencode: new OpenCodeAdapter(),
|
||||
antigravity: new AntigravityAdapter(),
|
||||
amp: new AmpAdapter(),
|
||||
clawdbot: new ClawdbotAdapter(),
|
||||
droid: new DroidAdapter(),
|
||||
'github-copilot': new GitHubCopilotAdapter(),
|
||||
goose: new GooseAdapter(),
|
||||
kilo: new KiloAdapter(),
|
||||
'kiro-cli': new KiroCliAdapter(),
|
||||
roo: new RooAdapter(),
|
||||
trae: new TraeAdapter(),
|
||||
windsurf: new WindsurfAdapter(),
|
||||
universal: new UniversalAdapter(),
|
||||
};
|
||||
|
||||
export function getAdapter(type: AgentType): AgentAdapter {
|
||||
return adapters[type];
|
||||
}
|
||||
|
||||
export function getAllAdapters(): AgentAdapter[] {
|
||||
return Object.values(adapters);
|
||||
}
|
||||
|
||||
export async function detectAgent(): Promise<AgentType> {
|
||||
const checkOrder: AgentType[] = [
|
||||
'claude-code',
|
||||
'cursor',
|
||||
'codex',
|
||||
'gemini-cli',
|
||||
'opencode',
|
||||
'antigravity',
|
||||
'amp',
|
||||
'clawdbot',
|
||||
'droid',
|
||||
'github-copilot',
|
||||
'goose',
|
||||
'kilo',
|
||||
'kiro-cli',
|
||||
'roo',
|
||||
'trae',
|
||||
'windsurf',
|
||||
'universal',
|
||||
];
|
||||
|
||||
for (const type of checkOrder) {
|
||||
const adapter = adapters[type];
|
||||
if (await adapter.isDetected()) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return 'universal';
|
||||
}
|
||||
|
||||
// getSkillsDir and getConfigFile are now re-exported from @skillkit/core above
|
||||
// This ensures a single source of truth for agent configurations
|
||||
@@ -0,0 +1,78 @@
|
||||
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.kilo;
|
||||
|
||||
export class KiloAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'kilo';
|
||||
readonly name = 'Kilo Code';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
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) || existsSync(kiloModes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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['kiro-cli'];
|
||||
|
||||
export class KiroCliAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'kiro-cli';
|
||||
readonly name = 'Kiro CLI';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>
|
||||
|
||||
**Note for Kiro CLI users:** After installing skills, you need to manually add them to your custom agent's \`resources\` in \`.kiro/agents/<agent>.json\`:
|
||||
|
||||
\`\`\`json
|
||||
{
|
||||
"resources": [
|
||||
"skill://.kiro/skills/**/SKILL.md"
|
||||
]
|
||||
}
|
||||
\`\`\``;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const projectKiro = join(process.cwd(), '.kiro');
|
||||
const globalKiro = join(homedir(), '.kiro');
|
||||
|
||||
return existsSync(projectKiro) || existsSync(globalKiro);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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.opencode;
|
||||
|
||||
export class OpenCodeAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'opencode';
|
||||
readonly name = 'OpenCode';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
||||
|
||||
return `<!-- SKILLKIT_START -->
|
||||
# Skills
|
||||
|
||||
The following skills are available to help complete tasks:
|
||||
|
||||
<skills>
|
||||
${skillsXml}
|
||||
</skills>
|
||||
|
||||
## How to Use
|
||||
|
||||
When a task matches a skill's description:
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
This loads the skill's instructions into context.
|
||||
|
||||
<!-- SKILLKIT_END -->`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const opencodeDir = join(process.cwd(), '.opencode');
|
||||
const globalOpencode = join(homedir(), '.config', 'opencode');
|
||||
const opencodeJson = join(process.cwd(), 'opencode.json');
|
||||
|
||||
return existsSync(opencodeDir) || existsSync(globalOpencode) ||
|
||||
existsSync(opencodeJson);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
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.roo;
|
||||
|
||||
export class RooAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'roo';
|
||||
readonly name = 'Roo Code';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).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: \`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/)
|
||||
|
||||
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>`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
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) || existsSync(rooModes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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.trae;
|
||||
|
||||
export class TraeAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'trae';
|
||||
readonly name = 'Trae';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`skillkit read ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
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
|
||||
|
||||
${skillsList}
|
||||
|
||||
## How to Use Skills
|
||||
|
||||
When a task matches a skill's description, load it:
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
Skills provide detailed instructions for completing complex tasks.
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
const headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
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(traeRulesDir) || existsSync(globalTrae);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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 = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `- **${s.name}**: ${s.description}`)
|
||||
.join('\n');
|
||||
|
||||
return `# Skills System
|
||||
|
||||
<!-- SKILLKIT_SKILLS_START -->
|
||||
|
||||
## Available Skills
|
||||
|
||||
${skillsList}
|
||||
|
||||
## How to Use Skills
|
||||
|
||||
When a task matches one of the available skills, load it to get detailed instructions:
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
Or with npx:
|
||||
|
||||
\`\`\`bash
|
||||
npx skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
## Skills Data
|
||||
|
||||
<skills_system>
|
||||
<usage>
|
||||
Skills provide specialized capabilities and domain knowledge.
|
||||
- Invoke: \`skillkit read <skill-name>\`
|
||||
- Base directory provided in output for resolving resources
|
||||
- Only use skills listed below
|
||||
- Each invocation is stateless
|
||||
</usage>
|
||||
|
||||
<available_skills>
|
||||
|
||||
${skillsXml}
|
||||
|
||||
</available_skills>
|
||||
</skills_system>
|
||||
|
||||
<!-- SKILLKIT_SKILLS_END -->
|
||||
`;
|
||||
}
|
||||
|
||||
parseConfig(content: string): string[] {
|
||||
const skillNames: string[] = [];
|
||||
|
||||
const skillRegex = /<name>([^<]+)<\/name>/g;
|
||||
let match;
|
||||
while ((match = skillRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
if (skillNames.length === 0) {
|
||||
const listRegex = /^- \*\*([a-z0-9-]+)\*\*:/gm;
|
||||
while ((match = listRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
async isDetected(): Promise<boolean> {
|
||||
const agentDir = join(process.cwd(), '.agent');
|
||||
const agentsMd = join(process.cwd(), 'AGENTS.md');
|
||||
|
||||
return existsSync(agentDir) || existsSync(agentsMd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
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.windsurf;
|
||||
|
||||
export class WindsurfAdapter implements AgentAdapter {
|
||||
readonly type: AgentType = 'windsurf';
|
||||
readonly name = 'Windsurf';
|
||||
readonly skillsDir = config.skillsDir;
|
||||
readonly configFile = config.configFile;
|
||||
|
||||
generateConfig(skills: Skill[]): string {
|
||||
const enabledSkills = skills.filter(s => s.enabled);
|
||||
|
||||
if (enabledSkills.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const skillsList = enabledSkills
|
||||
.map(s => `### ${s.name}\n\n${s.description}\n\n**Invoke:** \`skillkit read ${s.name}\``)
|
||||
.join('\n\n');
|
||||
|
||||
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
|
||||
|
||||
${skillsList}
|
||||
|
||||
## How to Use Skills
|
||||
|
||||
When a task matches a skill's description, load it:
|
||||
|
||||
\`\`\`bash
|
||||
skillkit read <skill-name>
|
||||
\`\`\`
|
||||
|
||||
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 headerRegex = /^###\s+(.+?)\s*$/gm;
|
||||
let match;
|
||||
|
||||
while ((match = headerRegex.exec(content)) !== null) {
|
||||
skillNames.push(match[1].trim());
|
||||
}
|
||||
|
||||
return skillNames;
|
||||
}
|
||||
|
||||
getInvokeCommand(skillName: string): string {
|
||||
return `skillkit read ${skillName}`;
|
||||
}
|
||||
|
||||
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(projectRulesDir) ||
|
||||
existsSync(globalWindsurf);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"composite": false
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.ts'],
|
||||
format: ['esm'],
|
||||
target: 'node18',
|
||||
outDir: 'dist',
|
||||
clean: true,
|
||||
dts: true,
|
||||
sourcemap: true,
|
||||
splitting: false,
|
||||
skipNodeModulesBundle: true,
|
||||
platform: 'node',
|
||||
});
|
||||
@@ -0,0 +1,254 @@
|
||||
# @skillkit/cli
|
||||
|
||||
[](https://www.npmjs.com/package/@skillkit/cli)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
**Command-line interface for SkillKit** - install, manage, translate, and sync skills across 17 AI coding agents.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install -g @skillkit/cli
|
||||
# or
|
||||
npm install -g skillkit # includes CLI
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Get skill recommendations for your project
|
||||
skillkit recommend
|
||||
|
||||
# Install skills from GitHub
|
||||
skillkit install anthropics/skills
|
||||
|
||||
# Translate skills between agents
|
||||
skillkit translate my-skill --to cursor
|
||||
|
||||
# Launch interactive TUI
|
||||
skillkit ui
|
||||
```
|
||||
|
||||
## All Commands
|
||||
|
||||
### Skill Management
|
||||
|
||||
```bash
|
||||
skillkit install <source> # Install from GitHub/GitLab/Bitbucket/local
|
||||
skillkit remove <skills> # Remove installed skills
|
||||
skillkit update [skills] # Update skills from source
|
||||
skillkit list # List installed skills
|
||||
skillkit enable <skills> # Enable specific skills
|
||||
skillkit disable <skills> # Disable specific skills
|
||||
skillkit sync # Sync to agent config
|
||||
skillkit read <skills> # Read skill content
|
||||
```
|
||||
|
||||
### Discovery & Recommendations
|
||||
|
||||
```bash
|
||||
skillkit recommend # Project-based recommendations
|
||||
skillkit recommend --search "auth" # Task-based search
|
||||
skillkit recommend --category security # Filter by category
|
||||
skillkit recommend --min-score 80 # Quality threshold
|
||||
|
||||
skillkit marketplace # Browse skills
|
||||
skillkit marketplace search "react" # Search marketplace
|
||||
skillkit marketplace --tags typescript # Filter by tags
|
||||
skillkit marketplace refresh # Refresh index
|
||||
```
|
||||
|
||||
### Translation
|
||||
|
||||
```bash
|
||||
skillkit translate <skill> --to <agent> # Translate single skill
|
||||
skillkit translate --all --to cursor # Translate all skills
|
||||
skillkit translate skill --dry-run # Preview without writing
|
||||
```
|
||||
|
||||
### Context Management
|
||||
|
||||
```bash
|
||||
skillkit context init # Analyze project, create context
|
||||
skillkit context show # Display current context
|
||||
skillkit context sync --all # Sync to all detected agents
|
||||
skillkit context export # Export context file
|
||||
```
|
||||
|
||||
### Session Memory
|
||||
|
||||
```bash
|
||||
skillkit memory status # View memory status
|
||||
skillkit memory search "auth" # Search learnings
|
||||
skillkit memory list # List all learnings
|
||||
skillkit memory compress # Compress observations
|
||||
skillkit memory export <id> # Export as skill
|
||||
skillkit memory add # Add manual learning
|
||||
skillkit memory --global # Use global scope
|
||||
```
|
||||
|
||||
### Testing & Workflows
|
||||
|
||||
```bash
|
||||
skillkit test # Run all skill tests
|
||||
skillkit test ./my-skill # Test specific skill
|
||||
skillkit test --tags unit # Run tagged tests
|
||||
|
||||
skillkit workflow list # List workflows
|
||||
skillkit workflow run <name> # Execute workflow
|
||||
skillkit workflow create # Create new workflow
|
||||
|
||||
skillkit cicd github-action # Generate GitHub Actions
|
||||
skillkit cicd gitlab-ci # Generate GitLab CI
|
||||
skillkit cicd pre-commit # Generate pre-commit hook
|
||||
skillkit cicd init # Initialize CI/CD templates
|
||||
```
|
||||
|
||||
### Team Collaboration
|
||||
|
||||
```bash
|
||||
skillkit team init --name "Team" # Initialize team
|
||||
skillkit team share <bundle> # Share skill bundle
|
||||
skillkit team import <path> # Import bundle
|
||||
skillkit team list # List team bundles
|
||||
skillkit team sync # Sync with remote
|
||||
skillkit team remove <bundle> # Remove bundle
|
||||
skillkit team bundle-create # Create new bundle
|
||||
skillkit team bundle-export <id> # Export bundle
|
||||
skillkit team bundle-list # List all bundles
|
||||
```
|
||||
|
||||
### Plugin System
|
||||
|
||||
```bash
|
||||
skillkit plugin list # List installed plugins
|
||||
skillkit plugin install <name> # Install plugin
|
||||
skillkit plugin uninstall <name> # Uninstall plugin
|
||||
skillkit plugin enable <name> # Enable plugin
|
||||
skillkit plugin disable <name> # Disable plugin
|
||||
skillkit plugin info <name> # Plugin details
|
||||
```
|
||||
|
||||
### Methodologies & Plans
|
||||
|
||||
```bash
|
||||
skillkit methodology list # List methodologies
|
||||
skillkit methodology load <name> # Load methodology
|
||||
skillkit methodology apply <name> # Apply to project
|
||||
|
||||
skillkit plan parse <file> # Parse plan file
|
||||
skillkit plan validate <file> # Validate plan
|
||||
skillkit plan execute <file> # Execute plan
|
||||
skillkit plan status # Plan execution status
|
||||
```
|
||||
|
||||
### Hooks & Automation
|
||||
|
||||
```bash
|
||||
skillkit hook list # List registered hooks
|
||||
skillkit hook register <event> # Register new hook
|
||||
skillkit hook trigger <event> # Trigger hook manually
|
||||
skillkit hook enable <id> # Enable hook
|
||||
skillkit hook disable <id> # Disable hook
|
||||
```
|
||||
|
||||
### Agent Commands
|
||||
|
||||
```bash
|
||||
skillkit command generate <agent> # Generate agent-native commands
|
||||
skillkit command list <agent> # List available commands
|
||||
```
|
||||
|
||||
### Utilities
|
||||
|
||||
```bash
|
||||
skillkit init # Initialize in project
|
||||
skillkit init --agent cursor # Initialize for specific agent
|
||||
skillkit validate ./skill # Validate skill format
|
||||
skillkit create my-skill # Create new skill
|
||||
skillkit settings # View all settings
|
||||
skillkit settings --set key=value # Update setting
|
||||
```
|
||||
|
||||
## Install Options
|
||||
|
||||
```bash
|
||||
skillkit install owner/repo # GitHub repository
|
||||
skillkit install gitlab:owner/repo # GitLab repository
|
||||
skillkit install ./local/path # Local directory
|
||||
|
||||
# Options
|
||||
--list # List available skills without installing
|
||||
--skills=pdf,xlsx # Install specific skills
|
||||
--all # Install all discovered skills
|
||||
--yes # Skip confirmation prompts
|
||||
--global # Install globally
|
||||
--force # Overwrite existing
|
||||
--agent=cursor,windsurf # Install to specific agents
|
||||
```
|
||||
|
||||
## Programmatic Usage
|
||||
|
||||
```typescript
|
||||
import {
|
||||
installCommand,
|
||||
listCommand,
|
||||
syncCommand,
|
||||
translateCommand,
|
||||
recommendCommand,
|
||||
} from '@skillkit/cli';
|
||||
|
||||
// Install skills programmatically
|
||||
await installCommand('anthropics/skills', {
|
||||
agent: ['claude-code', 'cursor'],
|
||||
yes: true,
|
||||
});
|
||||
|
||||
// List installed skills
|
||||
const skills = await listCommand({ json: true });
|
||||
|
||||
// Sync to agent
|
||||
await syncCommand({ all: true });
|
||||
|
||||
// Translate skill
|
||||
await translateCommand('my-skill', {
|
||||
to: 'cursor',
|
||||
dryRun: false,
|
||||
});
|
||||
|
||||
// Get recommendations
|
||||
const recs = await recommendCommand({
|
||||
path: './my-project',
|
||||
minScore: 70,
|
||||
});
|
||||
```
|
||||
|
||||
## CI/CD Usage
|
||||
|
||||
```yaml
|
||||
# GitHub Actions example
|
||||
- name: Setup skills
|
||||
run: |
|
||||
npx skillkit install owner/skills --skills=lint,test --yes
|
||||
npx skillkit sync --yes
|
||||
```
|
||||
|
||||
## Supported Agents
|
||||
|
||||
| Agent | Format |
|
||||
|-------|--------|
|
||||
| Claude Code | SKILL.md |
|
||||
| Cursor | MDC (.mdc) |
|
||||
| Codex | SKILL.md |
|
||||
| Gemini CLI | SKILL.md |
|
||||
| Windsurf | Markdown |
|
||||
| GitHub Copilot | Markdown |
|
||||
| + 11 more | SKILL.md |
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation: https://github.com/rohitg00/skillkit
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "@skillkit/cli",
|
||||
"version": "1.7.4",
|
||||
"description": "CLI commands for SkillKit",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^0.11.0",
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@skillkit/tui": "workspace:*",
|
||||
"chalk": "^5.3.0",
|
||||
"clipanion": "^4.0.0-rc.4",
|
||||
"got": "^14.4.1",
|
||||
"isomorphic-git": "^1.27.1",
|
||||
"ora": "^8.1.0",
|
||||
"picocolors": "^1.1.1",
|
||||
"yaml": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('CLI Commands', () => {
|
||||
describe('exports', () => {
|
||||
it('should export all commands', async () => {
|
||||
const commands = await import('../commands/index.js');
|
||||
|
||||
expect(commands.ListCommand).toBeDefined();
|
||||
expect(commands.ReadCommand).toBeDefined();
|
||||
expect(commands.SyncCommand).toBeDefined();
|
||||
expect(commands.InitCommand).toBeDefined();
|
||||
expect(commands.EnableCommand).toBeDefined();
|
||||
expect(commands.DisableCommand).toBeDefined();
|
||||
expect(commands.RemoveCommand).toBeDefined();
|
||||
expect(commands.InstallCommand).toBeDefined();
|
||||
expect(commands.UpdateCommand).toBeDefined();
|
||||
expect(commands.ValidateCommand).toBeDefined();
|
||||
expect(commands.CreateCommand).toBeDefined();
|
||||
expect(commands.UICommand).toBeDefined();
|
||||
expect(commands.TranslateCommand).toBeDefined();
|
||||
expect(commands.ContextCommand).toBeDefined();
|
||||
expect(commands.RecommendCommand).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user