mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-19 02:13:58 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -0,0 +1,89 @@
|
||||
name: Skill Submission
|
||||
description: Submit a new skill to the SkillKit marketplace
|
||||
title: "[Skill Submission] "
|
||||
labels: ["skill-submission"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Submit Your Skill to SkillKit Marketplace
|
||||
|
||||
Thanks for contributing! Please fill out the details below.
|
||||
|
||||
**Tip:** You can also use our [web form](https://rohitg00.github.io/skillkit/) to submit skills.
|
||||
|
||||
- type: input
|
||||
id: skill-name
|
||||
attributes:
|
||||
label: Skill Name
|
||||
description: A descriptive name for your skill
|
||||
placeholder: e.g., React Best Practices
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: What does this skill teach AI agents?
|
||||
placeholder: A brief description of your skill...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: repo-owner
|
||||
attributes:
|
||||
label: GitHub Owner
|
||||
description: The owner of the repository (username or organization)
|
||||
placeholder: e.g., your-username
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: repo-name
|
||||
attributes:
|
||||
label: Repository Name
|
||||
description: The name of the repository containing the skill
|
||||
placeholder: e.g., my-agent-skills
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: skill-path
|
||||
attributes:
|
||||
label: Skill Path
|
||||
description: Path to SKILL.md in the repository
|
||||
placeholder: skills/my-skill/SKILL.md
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: tags
|
||||
attributes:
|
||||
label: Tags
|
||||
description: Comma-separated tags for categorization
|
||||
placeholder: react, typescript, frontend
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: author-github
|
||||
attributes:
|
||||
label: Author GitHub Username
|
||||
description: Your GitHub username
|
||||
placeholder: your-username
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
description: Please confirm the following
|
||||
options:
|
||||
- label: Repository is public
|
||||
required: true
|
||||
- label: SKILL.md follows the agentskills.io standard format
|
||||
required: true
|
||||
- label: Skill has been tested with at least one AI agent
|
||||
required: false
|
||||
@@ -0,0 +1,180 @@
|
||||
name: Process Skill Submission
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: process-submission-${{ github.event.issue.number }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
process-submission:
|
||||
if: github.event.label.name == 'approved'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Parse Issue and Update skills.json
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
|
||||
const issue = context.payload.issue;
|
||||
const body = issue.body;
|
||||
|
||||
// Parse issue body for skill details
|
||||
const parseField = (label) => {
|
||||
const regex = new RegExp(`\\*\\*${label}:\\*\\*\\s*(.+?)(?:\\n|$)`, 'i');
|
||||
const match = body.match(regex);
|
||||
return match ? match[1].trim() : '';
|
||||
};
|
||||
|
||||
const parseCheckbox = (text) => {
|
||||
const regex = new RegExp(`- \\[(x|X)\\]\\s*${text}`, 'i');
|
||||
return regex.test(body);
|
||||
};
|
||||
|
||||
// Extract fields from form-based issue
|
||||
let skillName, description, repoOwner, repoName, skillPath, tags, authorGithub;
|
||||
|
||||
if (body.includes('### Skill Name')) {
|
||||
// YAML form format
|
||||
const sections = body.split('###').filter(s => s.trim());
|
||||
for (const section of sections) {
|
||||
const lines = section.trim().split('\n');
|
||||
const header = lines[0].trim().toLowerCase();
|
||||
const value = lines.slice(1).join('\n').trim();
|
||||
|
||||
if (header.includes('skill name')) skillName = value;
|
||||
if (header.includes('description')) description = value;
|
||||
if (header.includes('github owner')) repoOwner = value;
|
||||
if (header.includes('repository name')) repoName = value;
|
||||
if (header.includes('skill path')) skillPath = value;
|
||||
if (header.includes('tags')) tags = value;
|
||||
if (header.includes('author github')) authorGithub = value;
|
||||
}
|
||||
} else {
|
||||
// Markdown format from web form
|
||||
skillName = parseField('Name');
|
||||
description = parseField('Description');
|
||||
repoOwner = parseField('Owner');
|
||||
repoName = parseField('Repo');
|
||||
skillPath = parseField('Skill Path');
|
||||
tags = parseField('Tags');
|
||||
const authorField = parseField('Author') || '';
|
||||
authorGithub = authorField.replace(/^@/, '').trim();
|
||||
}
|
||||
|
||||
if (!skillName || !repoOwner || !repoName) {
|
||||
console.log('Missing required fields');
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: '❌ Could not parse skill details. Missing required fields (name, owner, or repo).'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate skill ID
|
||||
const skillSlug = skillName.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
||||
const skillId = `${repoOwner}/${repoName}/${skillSlug}`;
|
||||
|
||||
// Read current skills.json
|
||||
const skillsPath = 'marketplace/skills.json';
|
||||
const skillsData = JSON.parse(fs.readFileSync(skillsPath, 'utf-8'));
|
||||
|
||||
// Check for duplicates
|
||||
if (skillsData.skills.some(s => s.id === skillId)) {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: `⚠️ Skill with ID \`${skillId}\` already exists in the marketplace.`
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse and validate tags
|
||||
const filteredTags = tags
|
||||
? tags.split(',').map(t => t.trim().toLowerCase()).filter(t => t.length > 0)
|
||||
: [];
|
||||
|
||||
if (filteredTags.length === 0) {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: '❌ At least one tag is required. Please add tags to your submission.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Add new skill
|
||||
const newSkill = {
|
||||
id: skillId,
|
||||
name: skillName,
|
||||
description: description || '',
|
||||
source: `${repoOwner}/${repoName}`,
|
||||
tags: filteredTags,
|
||||
author: authorGithub
|
||||
};
|
||||
|
||||
skillsData.skills.push(newSkill);
|
||||
skillsData.updatedAt = new Date().toISOString().split('T')[0];
|
||||
|
||||
// Write updated skills.json
|
||||
fs.writeFileSync(skillsPath, JSON.stringify(skillsData, null, 2) + '\n');
|
||||
|
||||
// Also update docs copy
|
||||
const docsCopyPath = 'docs/skillkit/data/skills.json';
|
||||
fs.writeFileSync(docsCopyPath, JSON.stringify(skillsData, null, 2) + '\n');
|
||||
|
||||
// Also update core copy
|
||||
const coreCopyPath = 'packages/core/src/marketplace/data/skills.json';
|
||||
fs.writeFileSync(coreCopyPath, JSON.stringify(skillsData, null, 2) + '\n');
|
||||
|
||||
console.log(`Added skill: ${skillId}`);
|
||||
|
||||
// Set output for commit
|
||||
core.setOutput('skill_name', skillName);
|
||||
core.setOutput('skill_id', skillId);
|
||||
|
||||
- name: Commit Changes
|
||||
run: |
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add marketplace/skills.json docs/skillkit/data/skills.json packages/core/src/marketplace/data/skills.json
|
||||
git commit -m "feat(marketplace): add skill from #${{ github.event.issue.number }}"
|
||||
git push
|
||||
|
||||
- name: Close Issue with Comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.issue.number,
|
||||
body: `✅ **Skill added to marketplace!**\n\nYour skill has been added and will be available in the next release.\n\nThank you for contributing to SkillKit! 🎉`
|
||||
});
|
||||
|
||||
await github.rest.issues.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.issue.number,
|
||||
state: 'closed'
|
||||
});
|
||||
@@ -1,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:
|
||||
@@ -44,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 }}
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
# 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://rohitg00.github.io/skillkit/)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
## Supercharge Every AI Coding Agent
|
||||
@@ -51,16 +60,6 @@ skillkit recommend
|
||||
| **Session Memory** | Knowledge dies with each session | Persistent learning across agents |
|
||||
| **Skill Testing** | Hope it works | Test framework with assertions |
|
||||
|
||||
## What's New in v1.6
|
||||
|
||||
- **Recursive Agent Translation**: Batch translate entire directories of agents with `--recursive` flag
|
||||
- **Custom AI Sub-Agents**: Create, translate, sync, and validate custom AI sub-agents across 17 coding agents
|
||||
- **Methodology Framework**: 5 ready-to-use frameworks (Agile, TDD, DevOps, Security-First, Documentation-First)
|
||||
- **Hooks System**: Event-driven skill triggers - auto-activate on commits, file changes, builds
|
||||
- **Agent Orchestration**: Multi-agent team coordination with leader/teammate roles
|
||||
- **Plan System**: Parse, validate, and execute structured development plans
|
||||
- **Slash Commands**: Generate agent-native `/commands` from natural language
|
||||
|
||||
## 5-Minute Quick Start
|
||||
|
||||
```bash
|
||||
@@ -426,6 +425,9 @@ 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
|
||||
@@ -456,3 +458,4 @@ Contributions welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md
|
||||
- [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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "skillkit",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.2",
|
||||
"description": "Supercharge AI coding agents with portable skills. Install, translate, and share skills across Claude Code, Cursor, Codex, Copilot & 13 more",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
CommandCmd,
|
||||
AICommand,
|
||||
AuditCommand,
|
||||
PublishCommand,
|
||||
AgentCommand,
|
||||
AgentListCommand,
|
||||
AgentShowCommand,
|
||||
@@ -98,6 +99,7 @@ cli.register(PlanCommand);
|
||||
cli.register(CommandCmd);
|
||||
cli.register(AICommand);
|
||||
cli.register(AuditCommand);
|
||||
cli.register(PublishCommand);
|
||||
cli.register(AgentCommand);
|
||||
cli.register(AgentListCommand);
|
||||
cli.register(AgentShowCommand);
|
||||
|
||||
@@ -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,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
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "skillkit-monorepo",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "skillkit-monorepo",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.2",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
|
||||
+4
-2
@@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "skillkit-monorepo",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.2",
|
||||
"private": true,
|
||||
"description": "Universal skills loader for AI coding agents - Monorepo",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "turbo run build",
|
||||
"dev": "turbo run dev",
|
||||
"ui": "pnpm --filter skillkit exec bun skillkit ui",
|
||||
"test": "turbo run test",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
@@ -53,5 +54,6 @@
|
||||
"turbo": "^2.3.4",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
}
|
||||
},
|
||||
"pnpm": {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/agents",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.1",
|
||||
"description": "Agent adapters for SkillKit - supports 17+ AI coding agents",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/cli",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.1",
|
||||
"description": "CLI commands for SkillKit",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -31,6 +31,7 @@ export { PlanCommand } from './plan.js';
|
||||
export { CommandCmd } from './command.js';
|
||||
export { AICommand } from './ai.js';
|
||||
export { AuditCommand } from './audit.js';
|
||||
export { PublishCommand } from './publish.js';
|
||||
export {
|
||||
AgentCommand,
|
||||
AgentListCommand,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { createInterface } from 'node:readline';
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
@@ -69,6 +72,9 @@ export class InitCommand extends Command {
|
||||
console.log(chalk.dim(' 2. Sync config: skillkit sync'));
|
||||
console.log(chalk.dim(' 3. Use skills: skillkit read <skill-name>'));
|
||||
|
||||
// Check if SKILL.md exists and offer to publish
|
||||
await this.checkAndPromptPublish();
|
||||
|
||||
return 0;
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Initialization failed'));
|
||||
@@ -76,4 +82,47 @@ export class InitCommand extends Command {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private async checkAndPromptPublish(): Promise<void> {
|
||||
// Skip in non-interactive environments (CI, piped input, etc.)
|
||||
if (!process.stdin.isTTY) return;
|
||||
|
||||
const skillMdLocations = [
|
||||
join(process.cwd(), 'SKILL.md'),
|
||||
join(process.cwd(), 'skills', 'SKILL.md'),
|
||||
join(process.cwd(), '.claude', 'skills', 'SKILL.md'),
|
||||
join(process.cwd(), '.cursor', 'skills', 'SKILL.md'),
|
||||
];
|
||||
|
||||
const foundSkillMd = skillMdLocations.find(loc => existsSync(loc));
|
||||
if (!foundSkillMd) return;
|
||||
|
||||
console.log();
|
||||
console.log(chalk.yellow('Found SKILL.md in your project!'));
|
||||
console.log(chalk.dim('Would you like to publish it to the SkillKit marketplace?'));
|
||||
console.log();
|
||||
|
||||
const answer = await this.prompt('Publish skill? [y/N]: ');
|
||||
|
||||
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
||||
console.log();
|
||||
console.log(chalk.cyan('To publish your skill, run:'));
|
||||
console.log(chalk.white(` skillkit publish ${foundSkillMd}`));
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
|
||||
private prompt(question: string): Promise<string> {
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
rl.question(question, answer => {
|
||||
rl.close();
|
||||
resolve(answer.trim());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join, basename, dirname } from 'node:path';
|
||||
import { execSync } from 'node:child_process';
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
|
||||
interface SkillFrontmatter {
|
||||
name?: string;
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export class PublishCommand extends Command {
|
||||
static override paths = [['publish']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Publish your skill to the SkillKit marketplace',
|
||||
examples: [
|
||||
['Publish skill from current directory', '$0 publish'],
|
||||
['Publish skill from specific path', '$0 publish ./my-skill'],
|
||||
['Publish with custom name', '$0 publish --name my-awesome-skill'],
|
||||
],
|
||||
});
|
||||
|
||||
skillPath = Option.String({ required: false, name: 'path' });
|
||||
|
||||
name = Option.String('--name,-n', {
|
||||
description: 'Custom skill name (default: parsed from SKILL.md)',
|
||||
});
|
||||
|
||||
dryRun = Option.Boolean('--dry-run', false, {
|
||||
description: 'Show what would be published without actually publishing',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const skillPath = this.skillPath || process.cwd();
|
||||
const skillMdPath = this.findSkillMd(skillPath);
|
||||
|
||||
if (!skillMdPath) {
|
||||
console.error(chalk.red('No SKILL.md found'));
|
||||
console.error(chalk.dim('Run this command from a directory containing SKILL.md'));
|
||||
console.error(chalk.dim('Or specify the path: skillkit publish ./path/to/skill'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.log(chalk.cyan('Publishing skill to SkillKit marketplace...\n'));
|
||||
|
||||
// Parse SKILL.md
|
||||
const content = readFileSync(skillMdPath, 'utf-8');
|
||||
const frontmatter = this.parseFrontmatter(content);
|
||||
const skillName = this.name || frontmatter.name || basename(dirname(skillMdPath));
|
||||
|
||||
// Get git repo info
|
||||
const repoInfo = this.getRepoInfo(dirname(skillMdPath));
|
||||
if (!repoInfo) {
|
||||
console.error(chalk.red('Not a git repository or no remote configured'));
|
||||
console.error(chalk.dim('Your skill must be in a git repository with a GitHub remote'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Build skill entry
|
||||
const skillSlug = this.slugify(skillName);
|
||||
if (!skillSlug) {
|
||||
console.error(chalk.red('Skill name produces an empty slug.'));
|
||||
console.error(chalk.dim('Please pass --name with letters or numbers.'));
|
||||
return 1;
|
||||
}
|
||||
const skillEntry = {
|
||||
id: `${repoInfo.owner}/${repoInfo.repo}/${skillSlug}`,
|
||||
name: this.formatName(skillName),
|
||||
description: frontmatter.description || `Best practices and patterns for ${this.formatName(skillName)}`,
|
||||
source: `${repoInfo.owner}/${repoInfo.repo}`,
|
||||
tags: frontmatter.tags || this.inferTags(skillName, frontmatter.description || ''),
|
||||
};
|
||||
|
||||
console.log(chalk.white('Skill details:'));
|
||||
console.log(chalk.dim(` ID: ${skillEntry.id}`));
|
||||
console.log(chalk.dim(` Name: ${skillEntry.name}`));
|
||||
console.log(chalk.dim(` Description: ${skillEntry.description}`));
|
||||
console.log(chalk.dim(` Source: ${skillEntry.source}`));
|
||||
console.log(chalk.dim(` Tags: ${skillEntry.tags.join(', ')}`));
|
||||
console.log();
|
||||
|
||||
if (this.dryRun) {
|
||||
console.log(chalk.yellow('Dry run - not publishing'));
|
||||
console.log(chalk.dim('JSON entry that would be added:'));
|
||||
console.log(JSON.stringify(skillEntry, null, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create GitHub issue to add skill
|
||||
const issueBody = this.createIssueBody(skillEntry);
|
||||
const issueTitle = encodeURIComponent(`[Publish] ${skillEntry.name}`);
|
||||
const issueBodyEncoded = encodeURIComponent(issueBody);
|
||||
const issueUrl = `https://github.com/rohitg00/skillkit/issues/new?title=${issueTitle}&body=${issueBodyEncoded}&labels=skill-submission,publish`;
|
||||
|
||||
console.log(chalk.green('Opening GitHub to submit your skill...\n'));
|
||||
|
||||
try {
|
||||
// Try to open the URL
|
||||
const openCmd =
|
||||
process.platform === 'darwin'
|
||||
? `open "${issueUrl}"`
|
||||
: process.platform === 'win32'
|
||||
? `cmd /c start "" "${issueUrl}"`
|
||||
: `xdg-open "${issueUrl}"`;
|
||||
execSync(openCmd, { stdio: 'ignore' });
|
||||
|
||||
console.log(chalk.green('GitHub issue page opened!'));
|
||||
console.log(chalk.dim('Review and submit the issue to publish your skill.'));
|
||||
} catch {
|
||||
console.log(chalk.yellow('Could not open browser automatically.'));
|
||||
console.log(chalk.dim('Please open this URL manually:\n'));
|
||||
console.log(chalk.cyan(issueUrl));
|
||||
}
|
||||
|
||||
console.log();
|
||||
console.log(chalk.cyan('Next steps:'));
|
||||
console.log(chalk.dim(' 1. Review the skill details in the GitHub issue'));
|
||||
console.log(chalk.dim(' 2. Submit the issue'));
|
||||
console.log(chalk.dim(' 3. A maintainer will review and add your skill'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private findSkillMd(basePath: string): string | null {
|
||||
// Check if path is directly to SKILL.md
|
||||
if (basePath.endsWith('SKILL.md') && existsSync(basePath)) {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
// Check if SKILL.md exists in the directory
|
||||
const direct = join(basePath, 'SKILL.md');
|
||||
if (existsSync(direct)) {
|
||||
return direct;
|
||||
}
|
||||
|
||||
// Check common skill locations
|
||||
const locations = [
|
||||
join(basePath, 'skills', 'SKILL.md'),
|
||||
join(basePath, '.claude', 'skills', 'SKILL.md'),
|
||||
join(basePath, '.cursor', 'skills', 'SKILL.md'),
|
||||
];
|
||||
|
||||
for (const loc of locations) {
|
||||
if (existsSync(loc)) {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private parseFrontmatter(content: string): SkillFrontmatter {
|
||||
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
||||
if (!match) return {};
|
||||
|
||||
const frontmatter: SkillFrontmatter = {};
|
||||
const lines = match[1].split(/\r?\n/);
|
||||
let inTagsList = false;
|
||||
|
||||
for (const line of lines) {
|
||||
// Handle multiline tags list
|
||||
if (inTagsList) {
|
||||
const tagMatch = line.match(/^\s*-\s*(.+)$/);
|
||||
if (tagMatch) {
|
||||
frontmatter.tags ??= [];
|
||||
frontmatter.tags.push(tagMatch[1].trim().replace(/^["']|["']$/g, ''));
|
||||
continue;
|
||||
}
|
||||
if (line.trim() === '') continue;
|
||||
inTagsList = false;
|
||||
}
|
||||
|
||||
const colonIdx = line.indexOf(':');
|
||||
if (colonIdx === -1) continue;
|
||||
|
||||
const key = line.slice(0, colonIdx).trim();
|
||||
const value = line.slice(colonIdx + 1).trim();
|
||||
|
||||
switch (key) {
|
||||
case 'name':
|
||||
frontmatter.name = value.replace(/^["']|["']$/g, '');
|
||||
break;
|
||||
case 'description':
|
||||
frontmatter.description = value.replace(/^["']|["']$/g, '');
|
||||
break;
|
||||
case 'version':
|
||||
frontmatter.version = value.replace(/^["']|["']$/g, '');
|
||||
break;
|
||||
case 'tags':
|
||||
// Parse YAML array: [tag1, tag2] or multiline list
|
||||
if (value.startsWith('[')) {
|
||||
frontmatter.tags = value
|
||||
.slice(1, -1)
|
||||
.split(',')
|
||||
.map(t => t.trim().replace(/^["']|["']$/g, ''))
|
||||
.filter(t => t.length > 0);
|
||||
} else if (value === '') {
|
||||
inTagsList = true;
|
||||
frontmatter.tags = [];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return frontmatter;
|
||||
}
|
||||
|
||||
private slugify(name: string): string {
|
||||
return name
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '');
|
||||
}
|
||||
|
||||
private getRepoInfo(dir: string): { owner: string; repo: string } | null {
|
||||
try {
|
||||
const remote = execSync('git remote get-url origin', {
|
||||
cwd: dir,
|
||||
encoding: 'utf-8',
|
||||
stdio: ['pipe', 'pipe', 'ignore'],
|
||||
}).trim();
|
||||
|
||||
// Parse GitHub URL: git@github.com:owner/repo.git or https://github.com/owner/repo.git
|
||||
const match = remote.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?$/);
|
||||
if (match) {
|
||||
return { owner: match[1], repo: match[2] };
|
||||
}
|
||||
} catch {
|
||||
// Not a git repo or no remote
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private formatName(name: string): string {
|
||||
return name
|
||||
.split(/[-_]/)
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
private inferTags(name: string, description: string): string[] {
|
||||
const tags: string[] = [];
|
||||
const text = `${name} ${description}`.toLowerCase();
|
||||
|
||||
const tagMap: Record<string, string[]> = {
|
||||
react: ['react', 'jsx', 'tsx'],
|
||||
typescript: ['typescript', 'ts'],
|
||||
nextjs: ['next', 'nextjs'],
|
||||
testing: ['test', 'jest', 'vitest'],
|
||||
mobile: ['mobile', 'react-native', 'expo'],
|
||||
backend: ['backend', 'api', 'server'],
|
||||
database: ['database', 'postgres', 'mysql', 'supabase'],
|
||||
frontend: ['frontend', 'ui', 'design'],
|
||||
devops: ['devops', 'ci', 'cd', 'docker'],
|
||||
};
|
||||
|
||||
for (const [tag, keywords] of Object.entries(tagMap)) {
|
||||
if (keywords.some(k => text.includes(k))) {
|
||||
tags.push(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return tags.length > 0 ? tags : ['general'];
|
||||
}
|
||||
|
||||
private createIssueBody(
|
||||
skill: { id: string; name: string; description: string; source: string; tags: string[] }
|
||||
): string {
|
||||
return `## Publish Skill Request
|
||||
|
||||
### Skill Details
|
||||
- **ID:** \`${skill.id}\`
|
||||
- **Name:** ${skill.name}
|
||||
- **Description:** ${skill.description}
|
||||
- **Source:** [${skill.source}](https://github.com/${skill.source})
|
||||
- **Tags:** ${skill.tags.map(t => `\`${t}\``).join(', ')}
|
||||
|
||||
### JSON Entry
|
||||
\`\`\`json
|
||||
${JSON.stringify(skill, null, 2)}
|
||||
\`\`\`
|
||||
|
||||
### Checklist
|
||||
- [ ] SKILL.md follows the standard format
|
||||
- [ ] Skill is publicly accessible on GitHub
|
||||
- [ ] Description accurately describes the skill
|
||||
- [ ] Tags are appropriate
|
||||
|
||||
---
|
||||
Submitted via \`skillkit publish\``;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,26 @@
|
||||
import { Command } from 'clipanion';
|
||||
|
||||
/**
|
||||
* UI Command - Launch the SkillKit TUI
|
||||
* Uses the unified OpenTUI-based interface
|
||||
*/
|
||||
export class UICommand extends Command {
|
||||
static override paths = [['ui'], ['tui']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Launch the interactive TUI (Terminal User Interface)',
|
||||
details: `
|
||||
Launches the SkillKit TUI with a beautiful monochromatic design.
|
||||
|
||||
Features:
|
||||
- Browse and discover skills from the marketplace
|
||||
- Manage installed skills across 17+ AI coding agents
|
||||
- Sync skills between agents
|
||||
- AI-powered recommendations
|
||||
- Team collaboration
|
||||
|
||||
Requires Bun runtime (>=1.2.0) for optimal performance.
|
||||
`,
|
||||
examples: [
|
||||
['Open interactive TUI', '$0 ui'],
|
||||
['Alias for TUI', '$0 tui'],
|
||||
@@ -12,8 +28,20 @@ export class UICommand extends Command {
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const { startTUI } = await import('@skillkit/tui');
|
||||
await startTUI();
|
||||
return 0;
|
||||
try {
|
||||
const { startTUI } = await import('@skillkit/tui');
|
||||
await startTUI();
|
||||
return 0;
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
console.error('Error launching TUI:', err.message);
|
||||
console.error('');
|
||||
console.error('Make sure you are running with Bun (>=1.2.0):');
|
||||
console.error(' bun skillkit ui');
|
||||
console.error('');
|
||||
console.error('Install Bun from: https://bun.sh');
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/core",
|
||||
"version": "1.6.4",
|
||||
"version": "1.7.1",
|
||||
"description": "Core functionality for SkillKit - skill discovery, parsing, and translation",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "SkillKit Marketplace",
|
||||
"description": "Schema for SkillKit marketplace skills index",
|
||||
"type": "object",
|
||||
"required": ["version", "skills"],
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "Schema version number"
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date",
|
||||
"description": "Last update date (YYYY-MM-DD)"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"description": "List of skills in the marketplace",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Skill"
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Skill": {
|
||||
"type": "object",
|
||||
"required": ["id", "name", "source", "tags"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_-]+$",
|
||||
"description": "Unique identifier: owner/repo/skill-name"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100,
|
||||
"description": "Human-readable skill name"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"maxLength": 500,
|
||||
"description": "Brief description of the skill"
|
||||
},
|
||||
"source": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9_.-]+$",
|
||||
"description": "GitHub repository: owner/repo"
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$"
|
||||
},
|
||||
"minItems": 1,
|
||||
"maxItems": 10,
|
||||
"description": "Tags for categorization (lowercase, hyphenated)"
|
||||
},
|
||||
"author": {
|
||||
"type": "string",
|
||||
"description": "Skill author name or GitHub username"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
||||
"description": "Semantic version (e.g., 1.0.0)"
|
||||
},
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"claude-code",
|
||||
"cursor",
|
||||
"codex",
|
||||
"gemini-cli",
|
||||
"opencode",
|
||||
"antigravity",
|
||||
"amp",
|
||||
"clawdbot",
|
||||
"droid",
|
||||
"github-copilot",
|
||||
"goose",
|
||||
"kilo",
|
||||
"kiro-cli",
|
||||
"roo",
|
||||
"trae",
|
||||
"windsurf",
|
||||
"universal"
|
||||
]
|
||||
},
|
||||
"description": "Compatible AI agents (omit for universal compatibility)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,26 +121,23 @@ export interface MarketplaceConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default skill sources
|
||||
* Default skill sources - loaded from marketplace/sources.json (single source of truth)
|
||||
*/
|
||||
export const DEFAULT_SKILL_SOURCES: SkillSource[] = [
|
||||
{
|
||||
owner: 'composioHQ',
|
||||
repo: 'awesome-claude-code-skills',
|
||||
name: 'Composio Curated',
|
||||
description: 'Curated collection of Claude Code skills',
|
||||
official: false,
|
||||
branch: 'main',
|
||||
},
|
||||
{
|
||||
owner: 'anthropics',
|
||||
repo: 'courses',
|
||||
name: 'Anthropic Official',
|
||||
description: 'Official Anthropic courses and skills',
|
||||
official: true,
|
||||
branch: 'master',
|
||||
},
|
||||
];
|
||||
import sourcesData from '../../../../marketplace/sources.json' with { type: 'json' };
|
||||
|
||||
export const DEFAULT_SKILL_SOURCES: SkillSource[] = sourcesData.sources.map(
|
||||
(s: { source: string; name: string; official?: boolean }) => {
|
||||
const [owner, repo] = s.source.split('/');
|
||||
return {
|
||||
owner,
|
||||
repo,
|
||||
name: s.name,
|
||||
description: `Skills from ${s.name}`,
|
||||
official: s.official || false,
|
||||
branch: 'main',
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Cache file name
|
||||
|
||||
+78
-163
@@ -5,216 +5,131 @@
|
||||
|
||||
**Interactive terminal UI for SkillKit** - browse, install, translate, and manage skills visually in your terminal.
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Bun runtime** (>=1.2.0) - Required for OpenTUI rendering
|
||||
- Terminal with 80x24 minimum (120x40 recommended)
|
||||
|
||||
Install Bun: https://bun.sh
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @skillkit/tui
|
||||
# or
|
||||
npm install -g skillkit # includes TUI
|
||||
npm install -g skillkit
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
skillkit ui
|
||||
# or just
|
||||
skillkit
|
||||
# Launch TUI with Bun
|
||||
bun skillkit ui
|
||||
|
||||
# Or via pnpm in monorepo
|
||||
pnpm ui
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- **Browse Skills**: Explore 33+ skill repositories with search and filtering
|
||||
- **Smart Recommendations**: See project-aware skill suggestions with match scores
|
||||
- **Cross-Agent Translation**: Convert skills between any of 17 agent formats
|
||||
- **Context Management**: View detected stack and sync to all agents
|
||||
- **Multi-Agent Install**: Install skills to multiple agents at once
|
||||
- **Responsive Design**: Adapts to any terminal size
|
||||
|
||||
## Screens
|
||||
|
||||
### Home (h)
|
||||
Overview of your project and quick actions. Shows detected agents, installed skills count, and navigation hints.
|
||||
|
||||
### Marketplace (m)
|
||||
Browse curated skill marketplace:
|
||||
- Search across 33+ repositories
|
||||
- Filter by tags and categories
|
||||
- View popularity metrics
|
||||
- Install with one key
|
||||
|
||||
### Browse (b)
|
||||
Explore available skills from curated repositories:
|
||||
- Search skills with `/`
|
||||
- Filter by tags
|
||||
- View skill details
|
||||
- One-key installation
|
||||
|
||||
### Workflow (w)
|
||||
Manage and execute workflows:
|
||||
- List available workflows
|
||||
- View workflow steps
|
||||
- Execute workflows
|
||||
- Monitor progress
|
||||
|
||||
### Execute (x)
|
||||
Execute skills with checkpoints:
|
||||
- Task-based execution
|
||||
- Decision and review checkpoints
|
||||
- Dry-run mode
|
||||
- Git integration
|
||||
|
||||
### Team (a)
|
||||
Team collaboration management:
|
||||
- Create and share skill bundles
|
||||
- Import team bundles
|
||||
- Sync with remote registry
|
||||
- Manage team members
|
||||
|
||||
### Plugins (p)
|
||||
Plugin system management:
|
||||
- List installed plugins
|
||||
- Install new plugins
|
||||
- Enable/disable plugins
|
||||
- View plugin details
|
||||
|
||||
### Methodology (o)
|
||||
Development methodologies:
|
||||
- Browse 5 methodologies (Agile, TDD, DevOps, Design Thinking, Feature Flags)
|
||||
- View methodology skills
|
||||
- Apply to project
|
||||
- Track adoption
|
||||
|
||||
### Plan (n)
|
||||
Structured plan system:
|
||||
- Parse plan files
|
||||
- Validate plan structure
|
||||
- Execute plans step-by-step
|
||||
- Track progress
|
||||
|
||||
### Recommend (r)
|
||||
AI-powered skill suggestions based on your project:
|
||||
- Analyzes your package.json, configs, and file structure
|
||||
- Shows match percentage for each skill
|
||||
- Explains why skills are recommended
|
||||
- Filter by minimum score
|
||||
|
||||
### Translate (t)
|
||||
Convert skills between agent formats:
|
||||
- Select source skill
|
||||
- Choose target agent(s)
|
||||
- Preview translation
|
||||
- Apply with confirmation
|
||||
|
||||
### Context (c)
|
||||
View and manage project context:
|
||||
- Detected languages and frameworks
|
||||
- Found testing tools and databases
|
||||
- Installed agents
|
||||
- Sync context to all agents
|
||||
|
||||
### Memory (e)
|
||||
Session memory system:
|
||||
- View learnings
|
||||
- Search past sessions
|
||||
- Compress observations
|
||||
- Export as skills
|
||||
|
||||
### Installed (i)
|
||||
Manage your installed skills:
|
||||
- View all installed skills
|
||||
- Enable/disable skills
|
||||
- Remove skills
|
||||
- Update from source
|
||||
|
||||
### Sync (s)
|
||||
Sync skills across agents:
|
||||
- Select target agents
|
||||
- Preview changes
|
||||
- Apply sync
|
||||
|
||||
### Settings (,)
|
||||
Configure SkillKit:
|
||||
- Default agent
|
||||
- Auto-sync settings
|
||||
- Skill directories
|
||||
- **Monochromatic Design** - Clean B&W theme with colored accents
|
||||
- **Animated UI** - Smooth entrance animations and transitions
|
||||
- **Browse Skills** - Explore skill repositories with search and filtering
|
||||
- **Smart Recommendations** - AI-powered skill suggestions with match scores
|
||||
- **Cross-Agent Translation** - Convert skills between 17+ agent formats
|
||||
- **Team Collaboration** - Share and sync skills across teams
|
||||
- **Responsive Design** - Adapts to any terminal size
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
| Key | Action |
|
||||
### Navigation
|
||||
| Key | Screen |
|
||||
|-----|--------|
|
||||
| `h` | Home screen |
|
||||
| `m` | Marketplace |
|
||||
| `h` | Home |
|
||||
| `b` | Browse skills |
|
||||
| `m` | Marketplace |
|
||||
| `r` | Recommendations |
|
||||
| `i` | Installed skills |
|
||||
| `s` | Sync settings |
|
||||
|
||||
### Actions
|
||||
| Key | Screen |
|
||||
|-----|--------|
|
||||
| `t` | Translate skills |
|
||||
| `w` | Workflows |
|
||||
| `x` | Execute |
|
||||
| `a` | Team collaboration |
|
||||
| `n` | Plan |
|
||||
| `y` | History |
|
||||
|
||||
### Team & Config
|
||||
| Key | Screen |
|
||||
|-----|--------|
|
||||
| `a` | Team |
|
||||
| `c` | Context |
|
||||
| `e` | Memory |
|
||||
| `p` | Plugins |
|
||||
| `o` | Methodology |
|
||||
| `n` | Plan system |
|
||||
| `r` | Recommendations |
|
||||
| `t` | Translate skills |
|
||||
| `c` | Context management |
|
||||
| `e` | Memory/Learnings |
|
||||
| `i` | Installed skills |
|
||||
| `s` | Sync skills |
|
||||
| `,` | Settings |
|
||||
| `↑/↓` | Navigate lists |
|
||||
| `Enter` | Select / Confirm |
|
||||
| `/` | Search |
|
||||
| `Tab` | Switch focus |
|
||||
| `Esc` | Go back |
|
||||
| `?` | Help |
|
||||
|
||||
### Global
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `/` | Help screen |
|
||||
| `esc` | Go back / Home |
|
||||
| `q` | Quit |
|
||||
| `j/k` | Navigate lists |
|
||||
| `enter` | Select item |
|
||||
|
||||
## Screens Overview
|
||||
|
||||
- **Home** - Dashboard with stats, detected agents, and features
|
||||
- **Browse** - Search and explore skill repositories
|
||||
- **Marketplace** - Curated skill marketplace with popularity metrics
|
||||
- **Recommend** - AI-powered suggestions based on your project
|
||||
- **Installed** - Manage installed skills (enable/disable/remove)
|
||||
- **Sync** - Sync skills across multiple agents
|
||||
- **Translate** - Convert skills between agent formats
|
||||
- **Workflow** - Manage and execute automation workflows
|
||||
- **Execute** - Run skills with checkpoints
|
||||
- **Plan** - Structured plan creation and execution
|
||||
- **Team** - Share skills and bundles with team members
|
||||
- **Context** - View detected stack and project context
|
||||
- **Memory** - Session memory and learnings
|
||||
- **Plugins** - Plugin management
|
||||
- **Methodology** - Development methodology frameworks
|
||||
- **Settings** - Configure SkillKit preferences
|
||||
|
||||
## Programmatic Usage
|
||||
|
||||
```typescript
|
||||
import { startTUI, TUIOptions } from '@skillkit/tui';
|
||||
import { startTUI } from '@skillkit/tui';
|
||||
|
||||
// Launch with defaults
|
||||
await startTUI();
|
||||
|
||||
// Launch with options
|
||||
await startTUI({
|
||||
projectPath: './my-project',
|
||||
initialScreen: 'browse',
|
||||
theme: 'dark',
|
||||
});
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
Built with:
|
||||
- **Ink** - React for CLIs
|
||||
- **OpenTUI** - High-performance terminal UI framework
|
||||
- **React** - Component architecture
|
||||
- **@skillkit/core** - Core functionality
|
||||
|
||||
```
|
||||
src/
|
||||
├── app.tsx # Main app component
|
||||
├── index.tsx # Entry point and startTUI
|
||||
├── App.tsx # Main app component
|
||||
├── screens/ # Screen components
|
||||
│ ├── Home.tsx
|
||||
│ ├── Browse.tsx
|
||||
│ ├── Recommend.tsx
|
||||
│ ├── Translate.tsx
|
||||
│ ├── Context.tsx
|
||||
│ ├── Help.tsx
|
||||
│ └── ...
|
||||
├── components/ # Reusable UI components
|
||||
│ ├── SkillCard.tsx
|
||||
│ ├── AgentSelector.tsx
|
||||
│ ├── Sidebar.tsx
|
||||
│ ├── Splash.tsx
|
||||
│ └── ...
|
||||
└── hooks/ # React hooks
|
||||
├── useSkills.ts
|
||||
├── useContext.ts
|
||||
└── ...
|
||||
├── state/ # State types and navigation
|
||||
├── theme/ # Colors and symbols
|
||||
└── utils/ # Helper functions
|
||||
```
|
||||
|
||||
## Terminal Requirements
|
||||
|
||||
- Minimum: 80x24 characters
|
||||
- Recommended: 120x40 characters
|
||||
- Supports: True Color, 256 colors, basic ANSI
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation: https://github.com/rohitg00/skillkit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@skillkit/tui",
|
||||
"version": "1.6.4",
|
||||
"description": "Terminal UI for SkillKit",
|
||||
"version": "2.0.0",
|
||||
"description": "Unified Terminal UI for SkillKit - Built on OpenTUI",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -23,22 +23,19 @@
|
||||
"dependencies": {
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"chalk": "^5.3.0",
|
||||
"ink": "^5.0.1",
|
||||
"ink-select-input": "^6.0.0",
|
||||
"ink-spinner": "^5.0.0",
|
||||
"ink-text-input": "^6.0.0",
|
||||
"react": "^18.3.1"
|
||||
"@opentui/core": "^0.1.75",
|
||||
"@opentui/react": "^0.1.75",
|
||||
"react": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react": "^19.0.0",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
"bun": ">=1.2.0"
|
||||
},
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
||||
+87
-81
@@ -1,105 +1,111 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, Text, useInput, useApp, useStdout } from 'ink';
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, NAV_KEYS } from './state/types.js';
|
||||
import { Sidebar } from './components/Sidebar.js';
|
||||
import { Home } from './screens/Home.js';
|
||||
import { Browse } from './screens/Browse.js';
|
||||
import { Installed } from './screens/Installed.js';
|
||||
import { Sync } from './screens/Sync.js';
|
||||
import { Settings } from './screens/Settings.js';
|
||||
import { Recommend } from './screens/Recommend.js';
|
||||
import { Translate } from './screens/Translate.js';
|
||||
import { Context } from './screens/Context.js';
|
||||
import { Workflow } from './screens/Workflow.js';
|
||||
import { Execute } from './screens/Execute.js';
|
||||
import { History } from './screens/History.js';
|
||||
import { Marketplace } from './screens/Marketplace.js';
|
||||
import { Memory } from './screens/Memory.js';
|
||||
import { Team } from './screens/Team.js';
|
||||
import { Plugins } from './screens/Plugins.js';
|
||||
import { Methodology } from './screens/Methodology.js';
|
||||
import { Plan } from './screens/Plan.js';
|
||||
import { Splash } from './components/Splash.js';
|
||||
import {
|
||||
Home, Browse, Installed, Marketplace, Settings, Recommend,
|
||||
Translate, Context, Memory, Team, Plugins, Methodology,
|
||||
Plan, Workflow, Execute, History, Sync, Help,
|
||||
} from './screens/index.js';
|
||||
|
||||
export type Screen = 'home' | 'browse' | 'installed' | 'sync' | 'settings' | 'recommend' | 'translate' | 'context' | 'workflow' | 'execute' | 'history' | 'marketplace' | 'memory' | 'team' | 'plugins' | 'methodology' | 'plan';
|
||||
interface AppProps {
|
||||
onExit?: (code?: number) => void;
|
||||
}
|
||||
|
||||
export function App() {
|
||||
export function App({ onExit }: AppProps = {}) {
|
||||
const [showSplash, setShowSplash] = useState(true);
|
||||
const [screen, setScreen] = useState<Screen>('home');
|
||||
const { exit } = useApp();
|
||||
const { stdout } = useStdout();
|
||||
const [dimensions, setDimensions] = useState({
|
||||
cols: process.stdout.columns || 80,
|
||||
rows: process.stdout.rows || 24,
|
||||
});
|
||||
|
||||
const cols = stdout?.columns || 80;
|
||||
const rows = stdout?.rows || 24;
|
||||
const showSidebar = cols >= 70;
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setDimensions({
|
||||
cols: process.stdout.columns || 80,
|
||||
rows: process.stdout.rows || 24,
|
||||
});
|
||||
};
|
||||
process.stdout.on('resize', handleResize);
|
||||
return () => { process.stdout.off('resize', handleResize); };
|
||||
}, []);
|
||||
|
||||
const NAV_KEYS: Record<string, Screen> = {
|
||||
h: 'home',
|
||||
m: 'marketplace',
|
||||
b: 'browse',
|
||||
w: 'workflow',
|
||||
x: 'execute',
|
||||
y: 'history',
|
||||
r: 'recommend',
|
||||
t: 'translate',
|
||||
c: 'context',
|
||||
e: 'memory',
|
||||
i: 'installed',
|
||||
s: 'sync',
|
||||
a: 'team',
|
||||
p: 'plugins',
|
||||
o: 'methodology',
|
||||
n: 'plan',
|
||||
',': 'settings',
|
||||
};
|
||||
const { cols, rows } = dimensions;
|
||||
const showSidebar = cols >= 60;
|
||||
|
||||
useInput((input, key) => {
|
||||
if (input === 'q') {
|
||||
exit();
|
||||
const handleNavigate = useCallback((newScreen: Screen) => {
|
||||
setScreen(newScreen);
|
||||
}, []);
|
||||
|
||||
const handleSplashComplete = useCallback(() => {
|
||||
setShowSplash(false);
|
||||
}, []);
|
||||
|
||||
useKeyboard((key: { name?: string; ctrl?: boolean }) => {
|
||||
if (showSplash) {
|
||||
setShowSplash(false);
|
||||
return;
|
||||
}
|
||||
if (key.escape) {
|
||||
setScreen('home');
|
||||
|
||||
if (key.name === 'q' || (key.ctrl && key.name === 'c')) {
|
||||
onExit ? onExit(0) : process.exit(0);
|
||||
return;
|
||||
}
|
||||
const targetScreen = NAV_KEYS[input];
|
||||
|
||||
const targetScreen = NAV_KEYS[key.name || ''];
|
||||
if (targetScreen) {
|
||||
setScreen(targetScreen);
|
||||
}
|
||||
|
||||
if (key.name === 'escape' && screen !== 'home') {
|
||||
setScreen('home');
|
||||
}
|
||||
});
|
||||
|
||||
if (showSplash) {
|
||||
return <Splash onComplete={handleSplashComplete} duration={3000} />;
|
||||
}
|
||||
|
||||
const screenProps = {
|
||||
onNavigate: handleNavigate,
|
||||
cols: cols - (showSidebar ? 20 : 0),
|
||||
rows,
|
||||
};
|
||||
|
||||
const renderScreen = () => {
|
||||
switch (screen) {
|
||||
case 'home': return <Home onNavigate={setScreen} cols={cols} rows={rows} />;
|
||||
case 'browse': return <Browse cols={cols} rows={rows} />;
|
||||
case 'installed': return <Installed cols={cols} rows={rows} />;
|
||||
case 'sync': return <Sync cols={cols} rows={rows} />;
|
||||
case 'settings': return <Settings cols={cols} rows={rows} />;
|
||||
case 'recommend': return <Recommend cols={cols} rows={rows} />;
|
||||
case 'translate': return <Translate cols={cols} rows={rows} />;
|
||||
case 'context': return <Context cols={cols} rows={rows} />;
|
||||
case 'workflow': return <Workflow cols={cols} rows={rows} />;
|
||||
case 'execute': return <Execute cols={cols} rows={rows} />;
|
||||
case 'history': return <History cols={cols} rows={rows} />;
|
||||
case 'marketplace': return <Marketplace cols={cols} rows={rows} />;
|
||||
case 'memory': return <Memory cols={cols} rows={rows} />;
|
||||
case 'team': return <Team cols={cols} rows={rows} />;
|
||||
case 'plugins': return <Plugins cols={cols} rows={rows} />;
|
||||
case 'methodology': return <Methodology cols={cols} rows={rows} />;
|
||||
case 'plan': return <Plan cols={cols} rows={rows} />;
|
||||
case 'home': return <Home {...screenProps} />;
|
||||
case 'browse': return <Browse {...screenProps} />;
|
||||
case 'installed': return <Installed {...screenProps} />;
|
||||
case 'marketplace': return <Marketplace {...screenProps} />;
|
||||
case 'settings': return <Settings {...screenProps} />;
|
||||
case 'recommend': return <Recommend {...screenProps} />;
|
||||
case 'translate': return <Translate {...screenProps} />;
|
||||
case 'context': return <Context {...screenProps} />;
|
||||
case 'memory': return <Memory {...screenProps} />;
|
||||
case 'team': return <Team {...screenProps} />;
|
||||
case 'plugins': return <Plugins {...screenProps} />;
|
||||
case 'methodology': return <Methodology {...screenProps} />;
|
||||
case 'plan': return <Plan {...screenProps} />;
|
||||
case 'workflow': return <Workflow {...screenProps} />;
|
||||
case 'execute': return <Execute {...screenProps} />;
|
||||
case 'history': return <History {...screenProps} />;
|
||||
case 'sync': return <Sync {...screenProps} />;
|
||||
case 'help': return <Help {...screenProps} />;
|
||||
default: return <Home {...screenProps} />;
|
||||
}
|
||||
};
|
||||
|
||||
const contentHeight = rows - 2;
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" height={rows}>
|
||||
<Box flexDirection="row" height={contentHeight}>
|
||||
{showSidebar && <Sidebar screen={screen} onNavigate={setScreen} />}
|
||||
<Box flexDirection="column" flexGrow={1} marginLeft={1}>
|
||||
{renderScreen()}
|
||||
</Box>
|
||||
</Box>
|
||||
<Box>
|
||||
<Text dimColor>h Home m Market b Browse w Wflow x Exec a Team p Plug o Meth n Plan r Rec t Trans c Ctx e Mem i Inst s Sync q Quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<box flexDirection="row" height={rows}>
|
||||
{showSidebar && <Sidebar screen={screen} onNavigate={handleNavigate} />}
|
||||
<box flexDirection="column" flexGrow={1} marginLeft={showSidebar ? 1 : 0} paddingRight={1}>
|
||||
{renderScreen()}
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export { type Screen };
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('TUI Components', () => {
|
||||
describe('exports', () => {
|
||||
it('should export App component', async () => {
|
||||
const { App } = await import('../App.js');
|
||||
expect(App).toBeDefined();
|
||||
expect(typeof App).toBe('function');
|
||||
});
|
||||
|
||||
it('should export theme configuration', async () => {
|
||||
const { colors, symbols } = await import('../theme.js');
|
||||
expect(colors).toBeDefined();
|
||||
expect(symbols).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export all screens', async () => {
|
||||
const screens = await import('../screens/index.js');
|
||||
expect(screens.Home).toBeDefined();
|
||||
expect(screens.Browse).toBeDefined();
|
||||
expect(screens.Installed).toBeDefined();
|
||||
expect(screens.Sync).toBeDefined();
|
||||
expect(screens.Settings).toBeDefined();
|
||||
expect(screens.Recommend).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export all hooks', async () => {
|
||||
const hooks = await import('../hooks/index.js');
|
||||
expect(hooks.useSkills).toBeDefined();
|
||||
expect(hooks.useMarketplace).toBeDefined();
|
||||
expect(hooks.useKeyboard).toBeDefined();
|
||||
expect(hooks.useRecommend).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
NAV_KEYS,
|
||||
SIDEBAR_NAV,
|
||||
STATUS_BAR_SHORTCUTS,
|
||||
type Screen,
|
||||
type SkillItem,
|
||||
} from '../state/types.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols, AGENT_LOGOS } from '../theme/symbols.js';
|
||||
import { getVersion, getSearchDirs, getInstallDir } from '../utils/helpers.js';
|
||||
|
||||
describe('@skillkit/tui', () => {
|
||||
describe('state/types', () => {
|
||||
it('should export NAV_KEYS with all screens', () => {
|
||||
expect(NAV_KEYS).toBeDefined();
|
||||
expect(NAV_KEYS.h).toBe('home');
|
||||
expect(NAV_KEYS.b).toBe('browse');
|
||||
expect(NAV_KEYS.m).toBe('marketplace');
|
||||
expect(NAV_KEYS['/']).toBe('help');
|
||||
expect(NAV_KEYS.q).toBeUndefined(); // q is quit, not a screen
|
||||
});
|
||||
|
||||
it('should export SIDEBAR_NAV with sections', () => {
|
||||
expect(SIDEBAR_NAV).toBeDefined();
|
||||
expect(Array.isArray(SIDEBAR_NAV)).toBe(true);
|
||||
expect(SIDEBAR_NAV.length).toBeGreaterThan(0);
|
||||
|
||||
const sections = SIDEBAR_NAV.map(s => s.section);
|
||||
expect(sections).toContain('Discover');
|
||||
expect(sections).toContain('Manage');
|
||||
expect(sections).toContain('Execute');
|
||||
});
|
||||
|
||||
it('should export STATUS_BAR_SHORTCUTS', () => {
|
||||
expect(STATUS_BAR_SHORTCUTS).toBeDefined();
|
||||
expect(STATUS_BAR_SHORTCUTS).toContain('browse');
|
||||
expect(STATUS_BAR_SHORTCUTS).toContain('help');
|
||||
expect(STATUS_BAR_SHORTCUTS).toContain('quit');
|
||||
});
|
||||
});
|
||||
|
||||
describe('theme/colors', () => {
|
||||
it('should export terminalColors', () => {
|
||||
expect(terminalColors).toBeDefined();
|
||||
expect(terminalColors.text).toBeDefined();
|
||||
expect(terminalColors.textMuted).toBeDefined();
|
||||
expect(terminalColors.accent).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('theme/symbols', () => {
|
||||
it('should export symbols', () => {
|
||||
expect(symbols).toBeDefined();
|
||||
expect(symbols.brandIcon).toBeDefined();
|
||||
expect(symbols.pointer).toBeDefined();
|
||||
expect(symbols.horizontalLine).toBeDefined();
|
||||
});
|
||||
|
||||
it('should export AGENT_LOGOS', () => {
|
||||
expect(AGENT_LOGOS).toBeDefined();
|
||||
expect(AGENT_LOGOS['claude-code']).toBeDefined();
|
||||
expect(AGENT_LOGOS['claude-code'].name).toBe('Claude Code');
|
||||
});
|
||||
});
|
||||
|
||||
describe('utils/helpers', () => {
|
||||
it('should return version string', () => {
|
||||
const version = getVersion();
|
||||
expect(typeof version).toBe('string');
|
||||
expect(version.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should return search directories', () => {
|
||||
const dirs = getSearchDirs();
|
||||
expect(Array.isArray(dirs)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return install directory', () => {
|
||||
const dir = getInstallDir();
|
||||
expect(typeof dir).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* AgentGrid Component
|
||||
* Displays monochromatic agent logos in a grid layout
|
||||
*/
|
||||
import { AGENT_LOGOS, type AgentLogo } from '../theme/symbols.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface AgentGridProps {
|
||||
/** Maximum number of agents to display */
|
||||
maxVisible?: number;
|
||||
/** Show status indicators for detected agents */
|
||||
showStatus?: boolean;
|
||||
/** Agent types that are detected/active */
|
||||
detectedAgents?: string[];
|
||||
/** Number of columns in the grid */
|
||||
columns?: number;
|
||||
}
|
||||
|
||||
export function AgentGrid({
|
||||
maxVisible = 12,
|
||||
showStatus = true,
|
||||
detectedAgents = [],
|
||||
columns = 4,
|
||||
}: AgentGridProps) {
|
||||
const safeColumns = Math.max(1, columns);
|
||||
const allAgents = Object.entries(AGENT_LOGOS);
|
||||
const visibleAgents = allAgents.slice(0, maxVisible);
|
||||
const hiddenCount = allAgents.length - maxVisible;
|
||||
|
||||
const rows: [string, AgentLogo][][] = [];
|
||||
for (let i = 0; i < visibleAgents.length; i += safeColumns) {
|
||||
rows.push(visibleAgents.slice(i, i + safeColumns));
|
||||
}
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Works with</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
{rows.map((row, rowIndex) => (
|
||||
<box key={`row-${rowIndex}`} flexDirection="row">
|
||||
{row.map(([agentType, agent]) => {
|
||||
const isDetected = detectedAgents.includes(agentType);
|
||||
const statusIcon = showStatus ? (isDetected ? '●' : '○') : '';
|
||||
const fg = isDetected ? terminalColors.accent : terminalColors.text;
|
||||
|
||||
return (
|
||||
<box key={agentType} width={18}>
|
||||
<text fg={fg}>
|
||||
{agent.icon} {agent.name}
|
||||
{showStatus && (
|
||||
<span fg={isDetected ? terminalColors.success : terminalColors.textMuted}>
|
||||
{' '}{statusIcon}
|
||||
</span>
|
||||
)}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
{hiddenCount > 0 && (
|
||||
<text fg={terminalColors.textMuted}>+{hiddenCount} more agents</text>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* FeatureList Component
|
||||
* Colored feature keywords with descriptions
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface Feature {
|
||||
key: string;
|
||||
label: string;
|
||||
description: string;
|
||||
color: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
const FEATURES: Feature[] = [
|
||||
{ key: 'sync', label: 'Sync', color: 'sync', description: 'share skills across all your coding agents' },
|
||||
{ key: 'browse', label: 'Browse', color: 'browse', description: 'discover skills from the marketplace' },
|
||||
{ key: 'recommend', label: 'Recommend', color: 'recommend', description: 'AI-powered skill suggestions for your project' },
|
||||
{ key: 'translate', label: 'Translate', color: 'translate', description: 'convert skills between agent formats' },
|
||||
{ key: 'workflow', label: 'Workflow', color: 'workflow', description: 'automate skill execution chains' },
|
||||
{ key: 'team', label: 'Team', color: 'team', description: 'collaborate with your development team' },
|
||||
];
|
||||
|
||||
interface FeatureListProps {
|
||||
features?: Feature[];
|
||||
}
|
||||
|
||||
export function FeatureList({ features = FEATURES }: FeatureListProps) {
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}><b>Features</b></text>
|
||||
<text> </text>
|
||||
{features.map((feat) => (
|
||||
<box key={feat.key} flexDirection="row">
|
||||
<text fg={terminalColors[feat.color]}>
|
||||
<b>{' '}{feat.label.padEnd(12)}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.description}</text>
|
||||
</box>
|
||||
))}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export { FEATURES, type Feature };
|
||||
@@ -1,30 +1,35 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
/**
|
||||
* Header Component
|
||||
* Screen header with title and optional badge/count
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface HeaderProps {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
count?: number;
|
||||
badge?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export function Header({ title, subtitle, count }: HeaderProps) {
|
||||
export function Header({ title, subtitle, count, badge, icon }: HeaderProps) {
|
||||
return (
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
<Box justifyContent="space-between">
|
||||
<Text color={colors.primary} bold>
|
||||
{title.toUpperCase()}
|
||||
</Text>
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row" gap={2}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{icon && `${icon} `}{title}</b>
|
||||
</text>
|
||||
{count !== undefined && (
|
||||
<Text color={colors.secondaryDim}>
|
||||
{symbols.star} {count}
|
||||
</Text>
|
||||
<text fg={terminalColors.textMuted}>({count})</text>
|
||||
)}
|
||||
</Box>
|
||||
{badge && (
|
||||
<text fg={terminalColors.accent}>[{badge}]</text>
|
||||
)}
|
||||
</box>
|
||||
{subtitle && (
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
{subtitle}
|
||||
</Text>
|
||||
<text fg={terminalColors.textSecondary}>{subtitle}</text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* ProgressBar Component
|
||||
* Animated progress bar display
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface ProgressBarProps {
|
||||
progress: number; // 0-100
|
||||
width?: number;
|
||||
showPercentage?: boolean;
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
export function ProgressBar({
|
||||
progress,
|
||||
width = 20,
|
||||
showPercentage = true,
|
||||
color = 'accent',
|
||||
}: ProgressBarProps) {
|
||||
const clampedProgress = Math.max(0, Math.min(100, progress));
|
||||
const filledWidth = Math.round((clampedProgress / 100) * width);
|
||||
const emptyWidth = width - filledWidth;
|
||||
|
||||
const filled = symbols.progressFilled.repeat(filledWidth);
|
||||
const empty = symbols.progressEmpty.repeat(emptyWidth);
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text>
|
||||
<span fg={terminalColors[color]}>{filled}</span>
|
||||
<span fg={terminalColors.textMuted}>{empty}</span>
|
||||
</text>
|
||||
{showPercentage && (
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{Math.round(clampedProgress)}%
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,40 +1,29 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import TextInput from 'ink-text-input';
|
||||
import { colors } from '../theme.js';
|
||||
/**
|
||||
* SearchInput Component
|
||||
* Rounded search input with icon
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface SearchInputProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
placeholder?: string;
|
||||
isFocused?: boolean;
|
||||
focused?: boolean;
|
||||
onChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export function SearchInput({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = 'Search skills...',
|
||||
isFocused = false,
|
||||
placeholder = 'Search...',
|
||||
focused = false,
|
||||
}: SearchInputProps) {
|
||||
const display = value || placeholder;
|
||||
const textColor = value ? terminalColors.text : terminalColors.textMuted;
|
||||
|
||||
return (
|
||||
<Box
|
||||
borderStyle="single"
|
||||
borderColor={isFocused ? colors.primary : colors.borderDim}
|
||||
paddingX={1}
|
||||
>
|
||||
<Text color={colors.secondaryDim}>/ </Text>
|
||||
{isFocused ? (
|
||||
<TextInput
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
) : (
|
||||
<Text color={value ? colors.secondary : colors.secondaryDim}>
|
||||
{value || placeholder}
|
||||
</Text>
|
||||
)}
|
||||
<Box flexGrow={1} />
|
||||
<Text color={colors.secondaryDim}>/</Text>
|
||||
</Box>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>⌕ </text>
|
||||
<text fg={textColor}>{display}</text>
|
||||
{focused && <text fg={terminalColors.accent}>▏</text>}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,100 +1,44 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import type { Screen } from '../App.js';
|
||||
import { type Screen, SIDEBAR_NAV } from '../state/types.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
interface SidebarProps {
|
||||
screen: Screen;
|
||||
onNavigate: (screen: Screen) => void;
|
||||
isCompact?: boolean;
|
||||
}
|
||||
|
||||
const NAV: { id: Screen; label: string; key: string }[] = [
|
||||
// Discovery
|
||||
{ id: 'home', label: 'Home', key: 'h' },
|
||||
{ id: 'marketplace', label: 'Marketplace', key: 'm' },
|
||||
{ id: 'browse', label: 'Browse', key: 'b' },
|
||||
// Execution
|
||||
{ id: 'workflow', label: 'Workflows', key: 'w' },
|
||||
{ id: 'execute', label: 'Execute', key: 'x' },
|
||||
{ id: 'history', label: 'History', key: 'y' },
|
||||
// Collaboration
|
||||
{ id: 'team', label: 'Team', key: 'a' },
|
||||
{ id: 'plugins', label: 'Plugins', key: 'p' },
|
||||
// Methodology
|
||||
{ id: 'methodology', label: 'Methodology', key: 'o' },
|
||||
{ id: 'plan', label: 'Plans', key: 'n' },
|
||||
// Tools
|
||||
{ id: 'recommend', label: 'Recommend', key: 'r' },
|
||||
{ id: 'translate', label: 'Translate', key: 't' },
|
||||
{ id: 'context', label: 'Context', key: 'c' },
|
||||
{ id: 'memory', label: 'Memory', key: 'e' },
|
||||
// Management
|
||||
{ id: 'installed', label: 'Installed', key: 'i' },
|
||||
{ id: 'sync', label: 'Sync', key: 's' },
|
||||
{ id: 'settings', label: 'Config', key: ',' },
|
||||
];
|
||||
|
||||
export function Sidebar({ screen }: SidebarProps) {
|
||||
const version = getVersion();
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" width={14} borderStyle="single" paddingX={1}>
|
||||
<Text bold color={colors.primary}>SkillKit</Text>
|
||||
<box flexDirection="column" width={18} paddingRight={1}>
|
||||
<text fg={terminalColors.accent}>
|
||||
<b>{symbols.brandIcon} skillkit</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>v{version}</text>
|
||||
<text> </text>
|
||||
|
||||
{/* Discovery (0-2) */}
|
||||
{NAV.slice(0, 3).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
{SIDEBAR_NAV.map(({ section, items }, idx) => (
|
||||
<box key={section} flexDirection="column">
|
||||
{idx > 0 && <text> </text>}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<i>{section}</i>
|
||||
</text>
|
||||
{items.map((item) => {
|
||||
const active = screen === item.screen;
|
||||
return (
|
||||
<text key={item.key} fg={active ? terminalColors.accent : terminalColors.text}>
|
||||
{active ? <b>{symbols.pointer} {item.label}</b> : <>{symbols.pointerInactive} {item.label}</>}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Execution (3-5) */}
|
||||
{NAV.slice(3, 6).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Collaboration (6-7) */}
|
||||
{NAV.slice(6, 8).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Methodology (8-9) */}
|
||||
{NAV.slice(8, 10).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Tools (10-13) */}
|
||||
{NAV.slice(10, 14).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Management (14-16) */}
|
||||
{NAV.slice(14).map((item) => (
|
||||
<Text key={item.id} inverse={screen === item.id}>
|
||||
{screen === item.id ? symbols.bullet : ' '}{item.label}
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Box flexGrow={1} />
|
||||
|
||||
<Text dimColor>? Help</Text>
|
||||
<Text dimColor>q Quit</Text>
|
||||
</Box>
|
||||
<box flexGrow={1} />
|
||||
<text fg={terminalColors.textMuted}>{symbols.horizontalLine.repeat(14)}</text>
|
||||
<text fg={terminalColors.textMuted}>/ help q quit</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,103 +1,78 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
|
||||
export interface SkillItem {
|
||||
name: string;
|
||||
description?: string;
|
||||
source?: string;
|
||||
installs?: number;
|
||||
enabled?: boolean;
|
||||
}
|
||||
/**
|
||||
* SkillList Component
|
||||
* Paginated list of skills with selection
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
import { calculatePagination, type PaginationResult } from '../utils/list.js';
|
||||
import type { SkillItem } from '../state/types.js';
|
||||
|
||||
interface SkillListProps {
|
||||
skills: SkillItem[];
|
||||
selectedIndex: number;
|
||||
showInstalls?: boolean;
|
||||
showRank?: boolean;
|
||||
showSource?: boolean;
|
||||
maxVisible?: number;
|
||||
}
|
||||
|
||||
function formatInstalls(count: number): string {
|
||||
if (count >= 1000) {
|
||||
return `${(count / 1000).toFixed(1)}K`;
|
||||
}
|
||||
return String(count);
|
||||
onSelect?: (skill: SkillItem) => void;
|
||||
}
|
||||
|
||||
export function SkillList({
|
||||
skills,
|
||||
selectedIndex,
|
||||
showInstalls = false,
|
||||
showRank = false,
|
||||
showSource = true,
|
||||
maxVisible = 10,
|
||||
onSelect,
|
||||
}: SkillListProps) {
|
||||
if (skills.length === 0) {
|
||||
return (
|
||||
<Box>
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
No skills found
|
||||
</Text>
|
||||
</Box>
|
||||
<text fg={terminalColors.textMuted}>No skills found</text>
|
||||
);
|
||||
}
|
||||
|
||||
const startIndex = Math.max(0, selectedIndex - Math.floor(maxVisible / 2));
|
||||
const visibleSkills = skills.slice(startIndex, startIndex + maxVisible);
|
||||
const actualStartIndex = startIndex;
|
||||
const pagination = calculatePagination(skills.length, selectedIndex, maxVisible);
|
||||
const visibleSkills = skills.slice(pagination.start, pagination.end);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{showRank && (
|
||||
<Box marginBottom={1}>
|
||||
<Text color={colors.secondaryDim}>
|
||||
{' # SKILL'}
|
||||
{showSource && ' SOURCE'}
|
||||
{showInstalls && ' INSTALLS'}
|
||||
</Text>
|
||||
</Box>
|
||||
<box flexDirection="column">
|
||||
{/* Items above indicator */}
|
||||
{pagination.itemsAbove > 0 && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowUp} {pagination.itemsAbove} more above
|
||||
</text>
|
||||
)}
|
||||
|
||||
{/* Skill list */}
|
||||
{visibleSkills.map((skill, idx) => {
|
||||
const realIndex = actualStartIndex + idx;
|
||||
const isSelected = realIndex === selectedIndex;
|
||||
const skillName = skill.name.padEnd(28).slice(0, 28);
|
||||
const sourceName = skill.source ? skill.source.slice(0, 25) : '';
|
||||
const actualIndex = pagination.start + idx;
|
||||
const isSelected = actualIndex === selectedIndex;
|
||||
const pointer = isSelected ? symbols.pointer : symbols.pointerInactive;
|
||||
const fg = isSelected ? terminalColors.accent : terminalColors.text;
|
||||
const statusIcon = skill.enabled ? symbols.active : symbols.pending;
|
||||
const statusColor = skill.enabled
|
||||
? terminalColors.success
|
||||
: terminalColors.textMuted;
|
||||
|
||||
return (
|
||||
<Box key={`${skill.source}-${skill.name}`}>
|
||||
<Text
|
||||
color={isSelected ? colors.primary : colors.secondary}
|
||||
bold={isSelected}
|
||||
inverse={isSelected}
|
||||
>
|
||||
{isSelected ? symbols.pointer : ' '}
|
||||
{showRank ? String(realIndex + 1).padStart(2, ' ') : ''}
|
||||
{' '}
|
||||
{skillName}
|
||||
</Text>
|
||||
{showSource && (
|
||||
<Text color={colors.secondaryDim} dimColor={!isSelected}>
|
||||
{' '}{sourceName}
|
||||
</Text>
|
||||
<box key={skill.name} flexDirection="row">
|
||||
<text fg={fg}>
|
||||
{isSelected ? <b>{pointer} {skill.name}</b> : <>{pointer} {skill.name}</>}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{statusIcon}
|
||||
</text>
|
||||
{skill.description && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}- {skill.description.slice(0, 40)}
|
||||
{skill.description.length > 40 ? '...' : ''}
|
||||
</text>
|
||||
)}
|
||||
{showInstalls && skill.installs !== undefined && (
|
||||
<Text color={colors.secondaryDim}>
|
||||
{formatInstalls(skill.installs).padStart(8)}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
|
||||
{skills.length > maxVisible && (
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
Showing {startIndex + 1}-{Math.min(startIndex + maxVisible, skills.length)} of {skills.length}
|
||||
</Text>
|
||||
</Box>
|
||||
{/* Items below indicator */}
|
||||
{pagination.itemsBelow > 0 && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowDown} {pagination.itemsBelow} more below
|
||||
</text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Spinner Component
|
||||
* Loading indicator with animated frames
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface SpinnerProps {
|
||||
label?: string;
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
export function Spinner({ label, color = 'accent' }: SpinnerProps) {
|
||||
const [frame, setFrame] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setFrame((f) => (f + 1) % symbols.spinner.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text fg={terminalColors[color]}>{symbols.spinner[frame]}</text>
|
||||
{label && <text fg={terminalColors.text}>{label}</text>}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* Splash Component
|
||||
* Cinematic ASCII art intro with elegant animations
|
||||
* Premium terminal experience
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
// Premium ASCII art logo - clean geometric design
|
||||
const LOGO_FRAMES = [
|
||||
// Frame 1 - Dots appear
|
||||
[
|
||||
' ',
|
||||
' · · · · · · · · · · · · · · · ',
|
||||
' ',
|
||||
],
|
||||
// Frame 2 - Lines form
|
||||
[
|
||||
' ',
|
||||
' ━━━ ━ ━ ━ ━ ━ ━ ━ ━━━ ',
|
||||
' ',
|
||||
],
|
||||
// Frame 3 - Structure emerges
|
||||
[
|
||||
' ┌──┐ ┬ ┌─ ┬ ┬ ┬ ┬ ┌─ ┬ ┌─┐ ',
|
||||
' └──┐ │ │ │ │ │ │ │ │ │ ',
|
||||
' └──┘ ┴ └─ ┴ ┴─┘ ┴─┘ ┴ └─ ┴ ┴ ',
|
||||
],
|
||||
// Frame 4 - Bold letters
|
||||
[
|
||||
' ╔═╗ ╦╔═ ╦ ╦ ╦ ╦╔═ ╦╔╦╗ ',
|
||||
' ╚═╗ ╠╩╗ ║ ║ ║ ╠╩╗ ║ ║ ',
|
||||
' ╚═╝ ╩ ╩ ╩ ╩═╝ ╩═╝ ╩ ╩ ╩ ╩ ',
|
||||
],
|
||||
// Frame 5 - Final premium logo
|
||||
[
|
||||
' ███████╗██╗ ██╗██╗██╗ ██╗ ██╗ ██╗██╗████████╗',
|
||||
' ██╔════╝██║ ██╔╝██║██║ ██║ ██║ ██╔╝██║╚══██╔══╝',
|
||||
' ███████╗█████╔╝ ██║██║ ██║ █████╔╝ ██║ ██║ ',
|
||||
' ╚════██║██╔═██╗ ██║██║ ██║ ██╔═██╗ ██║ ██║ ',
|
||||
' ███████║██║ ██╗██║███████╗███████╗██║ ██╗██║ ██║ ',
|
||||
' ╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ',
|
||||
],
|
||||
];
|
||||
|
||||
// Compact logo for smaller terminals
|
||||
const LOGO_SMALL = [
|
||||
' ╔═╗╦╔═╦╦ ╦ ╦╔═╦╔╦╗ ',
|
||||
' ╚═╗╠╩╗║║ ║ ╠╩╗║ ║ ',
|
||||
' ╚═╝╩ ╩╩╩═╝╩═╝╩ ╩╩ ╩ ',
|
||||
];
|
||||
|
||||
// Elegant spinner frames
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
// Progress bar characters
|
||||
const PROGRESS = {
|
||||
empty: '░',
|
||||
filled: '█',
|
||||
head: '▓',
|
||||
};
|
||||
|
||||
// Loading phases with elegant messaging
|
||||
const PHASES = [
|
||||
{ message: 'Initializing', detail: 'skill engine' },
|
||||
{ message: 'Connecting', detail: 'agent network' },
|
||||
{ message: 'Loading', detail: 'skill manifests' },
|
||||
{ message: 'Syncing', detail: 'configurations' },
|
||||
{ message: 'Ready', detail: '' },
|
||||
];
|
||||
|
||||
interface SplashProps {
|
||||
onComplete: () => void;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export function Splash({ onComplete, duration = 3500 }: SplashProps) {
|
||||
const [frame, setFrame] = useState(0);
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [phase, setPhase] = useState(0);
|
||||
const [fadeIn, setFadeIn] = useState(0);
|
||||
const [particles, setParticles] = useState<string[]>([]);
|
||||
|
||||
// Cache version to avoid repeated sync file I/O on every render
|
||||
const version = useMemo(() => getVersion(), []);
|
||||
const cols = process.stdout.columns || 80;
|
||||
const rows = process.stdout.rows || 24;
|
||||
const useSmallLogo = cols < 70;
|
||||
const currentLogo = useSmallLogo ? LOGO_SMALL : (LOGO_FRAMES[Math.min(frame, 4)] || LOGO_FRAMES[4]);
|
||||
const maxWidth = Math.max(...currentLogo.map(l => l.length));
|
||||
|
||||
// Generate ambient particles - returns fresh randomized string each call
|
||||
const generateParticles = useCallback(() => {
|
||||
const chars = ['·', '∙', '•', '○', '◦', '◌', '◍', '◎'];
|
||||
return Array(cols).fill(0).map(() =>
|
||||
Math.random() > 0.97 ? chars[Math.floor(Math.random() * chars.length)] : ' '
|
||||
).join('');
|
||||
}, [cols]);
|
||||
|
||||
// Logo reveal animation
|
||||
useEffect(() => {
|
||||
if (frame >= 4) return;
|
||||
const timer = setTimeout(() => setFrame(f => f + 1), 200);
|
||||
return () => clearTimeout(timer);
|
||||
}, [frame]);
|
||||
|
||||
// Fade in effect
|
||||
useEffect(() => {
|
||||
if (fadeIn >= 10) return;
|
||||
const timer = setTimeout(() => setFadeIn(f => f + 1), 50);
|
||||
return () => clearTimeout(timer);
|
||||
}, [fadeIn]);
|
||||
|
||||
// Progress animation
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setProgress(p => {
|
||||
const newProgress = p + (Math.random() * 3 + 1);
|
||||
if (newProgress >= 100) {
|
||||
clearInterval(interval);
|
||||
return 100;
|
||||
}
|
||||
return newProgress;
|
||||
});
|
||||
}, 50);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
// Phase progression
|
||||
useEffect(() => {
|
||||
const phaseProgress = progress / 20;
|
||||
setPhase(Math.min(Math.floor(phaseProgress), PHASES.length - 1));
|
||||
}, [progress]);
|
||||
|
||||
// Spinner animation
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
// Particle animation
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setParticles(prev => {
|
||||
const newParticles = [...prev];
|
||||
if (newParticles.length > 3) newParticles.shift();
|
||||
newParticles.push(generateParticles());
|
||||
return newParticles;
|
||||
});
|
||||
}, 150);
|
||||
return () => clearInterval(interval);
|
||||
}, [generateParticles]);
|
||||
|
||||
// Auto-complete
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(onComplete, duration);
|
||||
return () => clearTimeout(timer);
|
||||
}, [onComplete, duration]);
|
||||
|
||||
const pad = ' '.repeat(Math.max(0, Math.floor((cols - maxWidth) / 2)));
|
||||
const progressWidth = Math.max(1, Math.min(40, cols - 20));
|
||||
const progressPad = ' '.repeat(Math.max(0, Math.floor((cols - progressWidth) / 2)));
|
||||
|
||||
const filledWidth = Math.min(Math.floor((progress / 100) * progressWidth), progressWidth);
|
||||
const emptyWidth = Math.max(0, progressWidth - filledWidth - 1);
|
||||
const progressBar = PROGRESS.filled.repeat(filledWidth) +
|
||||
(filledWidth < progressWidth ? PROGRESS.head : '') +
|
||||
PROGRESS.empty.repeat(emptyWidth);
|
||||
|
||||
const currentPhase = PHASES[phase];
|
||||
|
||||
return (
|
||||
<box flexDirection="column" height={rows}>
|
||||
{/* Top ambient particles */}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{particles[0] || ''}
|
||||
</text>
|
||||
|
||||
{/* Spacer */}
|
||||
<box flexGrow={1} />
|
||||
|
||||
{/* Logo */}
|
||||
<box flexDirection="column" alignItems="center">
|
||||
{currentLogo.map((line, idx) => (
|
||||
<text key={idx} fg={frame >= 4 ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{frame >= 4 ? <b>{pad}{line}</b> : <>{pad}{line}</>}
|
||||
</text>
|
||||
))}
|
||||
</box>
|
||||
|
||||
{/* Tagline with fade-in */}
|
||||
<text> </text>
|
||||
{fadeIn > 3 && (
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{pad}{' '}universal skills for ai coding agents
|
||||
</text>
|
||||
)}
|
||||
|
||||
{/* Version badge */}
|
||||
{fadeIn > 5 && (
|
||||
<>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{pad}{' '}v{version}
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Spacer */}
|
||||
<text> </text>
|
||||
<text> </text>
|
||||
|
||||
{/* Progress section */}
|
||||
{fadeIn > 7 && (
|
||||
<box flexDirection="column" alignItems="center">
|
||||
{/* Status line */}
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>
|
||||
{progressPad}{SPINNER[spinnerFrame]}{' '}
|
||||
</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{currentPhase.message}</b>
|
||||
</text>
|
||||
{currentPhase.detail && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{currentPhase.detail}
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
|
||||
{/* Progress bar */}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>{progressPad}[</text>
|
||||
<text fg={terminalColors.accent}>{progressBar}</text>
|
||||
<text fg={terminalColors.textMuted}>]</text>
|
||||
<text fg={terminalColors.textSecondary}>{' '}{Math.floor(progress)}%</text>
|
||||
</box>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Spacer */}
|
||||
<box flexGrow={1} />
|
||||
|
||||
{/* Bottom hint */}
|
||||
<box flexDirection="column" alignItems="center">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{progressPad}{' '}press any key to skip
|
||||
</text>
|
||||
<text> </text>
|
||||
{/* Bottom particles */}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{particles[1] || ''}
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* StatsCard Component
|
||||
* OpenSync-style stats display with optional animations
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { animations } from '../theme/animations.js';
|
||||
|
||||
interface StatItem {
|
||||
label: string;
|
||||
value: number;
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
interface StatsCardProps {
|
||||
items: StatItem[];
|
||||
animated?: boolean;
|
||||
}
|
||||
|
||||
export function StatsCard({ items, animated = true }: StatsCardProps) {
|
||||
const [displayValues, setDisplayValues] = useState<number[]>(() =>
|
||||
animated ? items.map(() => 0) : items.map((item) => item.value)
|
||||
);
|
||||
const [animComplete, setAnimComplete] = useState(!animated);
|
||||
const [prevItemsLength, setPrevItemsLength] = useState(items.length);
|
||||
|
||||
useEffect(() => {
|
||||
if (items.length !== prevItemsLength) {
|
||||
setPrevItemsLength(items.length);
|
||||
setDisplayValues(animated ? items.map(() => 0) : items.map((item) => item.value));
|
||||
setAnimComplete(!animated);
|
||||
}
|
||||
}, [items, prevItemsLength, animated]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!animated || animComplete) return;
|
||||
|
||||
const duration = animations.countUp.duration;
|
||||
const startTime = Date.now();
|
||||
const targetValues = items.map((item) => item.value);
|
||||
const frameInterval = 16;
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
const elapsed = Date.now() - startTime;
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const eased = 1 - Math.pow(1 - progress, 4);
|
||||
|
||||
const newValues = targetValues.map((target) =>
|
||||
Math.round(target * eased)
|
||||
);
|
||||
|
||||
setDisplayValues(newValues);
|
||||
|
||||
if (progress >= 1) {
|
||||
clearInterval(intervalId);
|
||||
setAnimComplete(true);
|
||||
}
|
||||
}, frameInterval);
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
}, [animated, animComplete, items]);
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={2}>
|
||||
{items.map((item, index) => {
|
||||
const fg = item.color
|
||||
? terminalColors[item.color]
|
||||
: terminalColors.text;
|
||||
|
||||
return (
|
||||
<box
|
||||
key={item.label}
|
||||
flexDirection="column"
|
||||
alignItems="center"
|
||||
padding={2}
|
||||
borderStyle="single"
|
||||
borderColor={terminalColors.border}
|
||||
>
|
||||
<text fg={fg}>
|
||||
<b>{String(displayValues[index])}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{item.label}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,44 +1,38 @@
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
|
||||
interface Shortcut {
|
||||
key: string;
|
||||
label: string;
|
||||
}
|
||||
/**
|
||||
* StatusBar Component
|
||||
* Bottom status bar with keyboard shortcuts
|
||||
*/
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { STATUS_BAR_SHORTCUTS } from '../state/types.js';
|
||||
|
||||
interface StatusBarProps {
|
||||
shortcuts: Shortcut[];
|
||||
message?: string;
|
||||
messageType?: 'info' | 'success' | 'error' | 'warning';
|
||||
shortcuts?: string;
|
||||
}
|
||||
|
||||
export function StatusBar({ shortcuts, message }: StatusBarProps) {
|
||||
return (
|
||||
<Box
|
||||
borderStyle="single"
|
||||
borderColor={colors.borderDim}
|
||||
borderTop
|
||||
borderBottom={false}
|
||||
borderLeft={false}
|
||||
borderRight={false}
|
||||
paddingX={1}
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<Box gap={2}>
|
||||
{shortcuts.map((shortcut, idx) => (
|
||||
<Box key={idx} gap={1}>
|
||||
<Text color={colors.primary} bold>
|
||||
{shortcut.key}
|
||||
</Text>
|
||||
<Text color={colors.secondaryDim}>{shortcut.label}</Text>
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
export function StatusBar({
|
||||
message,
|
||||
messageType = 'info',
|
||||
shortcuts = STATUS_BAR_SHORTCUTS,
|
||||
}: StatusBarProps) {
|
||||
const messageColors = {
|
||||
info: terminalColors.info,
|
||||
success: terminalColors.success,
|
||||
error: terminalColors.error,
|
||||
warning: terminalColors.warning,
|
||||
};
|
||||
|
||||
{message && (
|
||||
<Text color={colors.success}>
|
||||
{symbols.check} {message}
|
||||
</Text>
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\u2500'.repeat(70)}
|
||||
</text>
|
||||
{message ? (
|
||||
<text fg={messageColors[messageType]}>{message}</text>
|
||||
) : (
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
)}
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
export { Sidebar } from './Sidebar.js';
|
||||
/**
|
||||
* Components module for SkillKit TUI
|
||||
*/
|
||||
|
||||
export { AgentGrid } from './AgentGrid.js';
|
||||
export { StatsCard } from './StatsCard.js';
|
||||
export { Header } from './Header.js';
|
||||
export { SkillList, type SkillItem } from './SkillList.js';
|
||||
export { Sidebar } from './Sidebar.js';
|
||||
export { StatusBar } from './StatusBar.js';
|
||||
export { SkillList } from './SkillList.js';
|
||||
export { SearchInput } from './SearchInput.js';
|
||||
export { Spinner } from './Spinner.js';
|
||||
export { ProgressBar } from './ProgressBar.js';
|
||||
export { FeatureList, FEATURES, type Feature } from './FeatureList.js';
|
||||
export { Splash } from './Splash.js';
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Re-export commonly used functions with proper adapters
|
||||
import {
|
||||
loadConfig,
|
||||
getSearchDirs as coreGetSearchDirs,
|
||||
getInstallDir as coreGetInstallDir,
|
||||
saveSkillMetadata as coreSaveSkillMetadata,
|
||||
} from '@skillkit/core';
|
||||
import { getAdapter } from '@skillkit/agents';
|
||||
import type { AgentType, AgentAdapterInfo } from '@skillkit/core';
|
||||
|
||||
// Re-export for direct use
|
||||
export { coreSaveSkillMetadata as saveSkillMetadata };
|
||||
|
||||
export function getSearchDirs(agentType?: AgentType): string[] {
|
||||
const type = agentType || loadConfig().agent;
|
||||
const adapter = getAdapter(type);
|
||||
const adapterInfo: AgentAdapterInfo = {
|
||||
type: adapter.type,
|
||||
name: adapter.name,
|
||||
skillsDir: adapter.skillsDir,
|
||||
configFile: adapter.configFile,
|
||||
};
|
||||
return coreGetSearchDirs(adapterInfo);
|
||||
}
|
||||
|
||||
export function getInstallDir(global = false, agentType?: AgentType): string {
|
||||
const type = agentType || loadConfig().agent;
|
||||
const adapter = getAdapter(type);
|
||||
const adapterInfo: AgentAdapterInfo = {
|
||||
type: adapter.type,
|
||||
name: adapter.name,
|
||||
skillsDir: adapter.skillsDir,
|
||||
configFile: adapter.configFile,
|
||||
};
|
||||
return coreGetInstallDir(adapterInfo, global);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export { useSkills } from './useSkills.js';
|
||||
export { useMarketplace } from './useMarketplace.js';
|
||||
export { useKeyboard, useListNavigation } from './useKeyboard.js';
|
||||
export { useRecommend } from './useRecommend.js';
|
||||
export { useMemory } from './useMemory.js';
|
||||
@@ -1,93 +0,0 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useInput, useApp } from 'ink';
|
||||
import type { Screen } from '../App.js';
|
||||
|
||||
interface UseKeyboardOptions {
|
||||
onNavigate?: (screen: Screen) => void;
|
||||
onSelect?: () => void;
|
||||
onSearch?: () => void;
|
||||
onInstall?: () => void;
|
||||
onBack?: () => void;
|
||||
onUp?: () => void;
|
||||
onDown?: () => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function useKeyboard(options: UseKeyboardOptions = {}) {
|
||||
const { exit } = useApp();
|
||||
|
||||
useInput((input, key) => {
|
||||
if (options.disabled) return;
|
||||
|
||||
if (input === 'q' || (key.ctrl && input === 'c')) {
|
||||
exit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.escape && options.onBack) {
|
||||
options.onBack();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.return && options.onSelect) {
|
||||
options.onSelect();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.upArrow && options.onUp) {
|
||||
options.onUp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.downArrow && options.onDown) {
|
||||
options.onDown();
|
||||
return;
|
||||
}
|
||||
|
||||
if (input === '/' && options.onSearch) {
|
||||
options.onSearch();
|
||||
return;
|
||||
}
|
||||
|
||||
if (input === 'i' && options.onInstall) {
|
||||
options.onInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
if (input === 'h' && options.onNavigate) {
|
||||
options.onNavigate('home');
|
||||
} else if (input === 'b' && options.onNavigate) {
|
||||
options.onNavigate('browse');
|
||||
} else if (input === 'l' && options.onNavigate) {
|
||||
options.onNavigate('installed');
|
||||
} else if (input === 's' && options.onNavigate) {
|
||||
options.onNavigate('sync');
|
||||
} else if (input === ',' && options.onNavigate) {
|
||||
options.onNavigate('settings');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function useListNavigation(listLength: number, initialIndex = 0) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(initialIndex);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedIndex >= listLength && listLength > 0) {
|
||||
setSelectedIndex(listLength - 1);
|
||||
}
|
||||
}, [listLength, selectedIndex]);
|
||||
|
||||
const moveUp = useCallback(() => {
|
||||
setSelectedIndex((prev) => Math.max(0, prev - 1));
|
||||
}, []);
|
||||
|
||||
const moveDown = useCallback(() => {
|
||||
setSelectedIndex((prev) => Math.min(listLength - 1, prev + 1));
|
||||
}, [listLength]);
|
||||
|
||||
const reset = useCallback(() => {
|
||||
setSelectedIndex(0);
|
||||
}, []);
|
||||
|
||||
return { selectedIndex, setSelectedIndex, moveUp, moveDown, reset };
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { detectProvider, loadConfig, extractFrontmatter } from '@skillkit/core';
|
||||
import { readFileSync, existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import type { SkillItem } from '../components/SkillList.js';
|
||||
|
||||
export interface RepoInfo {
|
||||
source: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
// Default popular repos - can be extended via config.marketplaceSources
|
||||
const DEFAULT_REPOS: RepoInfo[] = [
|
||||
{ source: 'anthropics/skills', name: 'Anthropic Official' },
|
||||
{ source: 'vercel-labs/agent-skills', name: 'Vercel Labs' },
|
||||
{ source: 'expo/skills', name: 'Expo / React Native' },
|
||||
{ source: 'remotion-dev/skills', name: 'Remotion Video' },
|
||||
{ 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: 'stripe/ai', name: 'Stripe Payments' },
|
||||
{ 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' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Get marketplace repos from config or use defaults
|
||||
*/
|
||||
function getMarketplaceRepos(): RepoInfo[] {
|
||||
try {
|
||||
const config = loadConfig();
|
||||
if (config.marketplaceSources?.length) {
|
||||
// Merge config sources with defaults, config takes priority
|
||||
const configRepos: RepoInfo[] = config.marketplaceSources.map(source => ({
|
||||
source,
|
||||
name: source.split('/').pop() || source,
|
||||
}));
|
||||
// Add defaults that aren't in config
|
||||
const existingSources = new Set(configRepos.map(r => r.source));
|
||||
for (const repo of DEFAULT_REPOS) {
|
||||
if (!existingSources.has(repo.source)) {
|
||||
configRepos.push(repo);
|
||||
}
|
||||
}
|
||||
return configRepos;
|
||||
}
|
||||
} catch {
|
||||
// Config load failed, use defaults
|
||||
}
|
||||
return DEFAULT_REPOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to read skill description from frontmatter
|
||||
*/
|
||||
function readSkillDescription(skillPath: string): string | undefined {
|
||||
const skillMdPath = join(skillPath, 'SKILL.md');
|
||||
if (!existsSync(skillMdPath)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const content = readFileSync(skillMdPath, 'utf-8');
|
||||
const frontmatter = extractFrontmatter(content);
|
||||
if (frontmatter && typeof frontmatter.description === 'string') {
|
||||
return frontmatter.description;
|
||||
}
|
||||
} catch {
|
||||
// Failed to read, return undefined
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
interface FetchedSkill {
|
||||
name: string;
|
||||
source: string;
|
||||
repoName: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface UseMarketplaceResult {
|
||||
skills: SkillItem[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
totalCount: number;
|
||||
repos: RepoInfo[];
|
||||
currentRepo: string | null;
|
||||
failedRepos: string[];
|
||||
refresh: () => void;
|
||||
search: (query: string) => void;
|
||||
fetchRepo: (source: string) => Promise<void>;
|
||||
fetchAllRepos: () => Promise<void>;
|
||||
}
|
||||
|
||||
export function useMarketplace(): UseMarketplaceResult {
|
||||
const [allSkills, setAllSkills] = useState<FetchedSkill[]>([]);
|
||||
const [filteredSkills, setFilteredSkills] = useState<FetchedSkill[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [currentRepo, setCurrentRepo] = useState<string | null>(null);
|
||||
const [fetchedRepos, setFetchedRepos] = useState<Set<string>>(new Set());
|
||||
const [failedRepos, setFailedRepos] = useState<string[]>([]);
|
||||
const [repos] = useState<RepoInfo[]>(() => getMarketplaceRepos());
|
||||
|
||||
const fetchRepo = useCallback(async (source: string) => {
|
||||
if (fetchedRepos.has(source)) return;
|
||||
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setCurrentRepo(source);
|
||||
|
||||
try {
|
||||
const provider = detectProvider(source);
|
||||
if (!provider) {
|
||||
throw new Error(`Could not detect provider for: ${source}`);
|
||||
}
|
||||
|
||||
const result = await provider.clone(source, '', { depth: 1 });
|
||||
|
||||
if (!result.success || !result.discoveredSkills) {
|
||||
throw new Error(result.error || 'Failed to fetch skills');
|
||||
}
|
||||
|
||||
const repoName = repos.find(r => r.source === source)?.name || source;
|
||||
const newSkills: FetchedSkill[] = result.discoveredSkills.map(skill => ({
|
||||
name: skill.name,
|
||||
source: source,
|
||||
repoName: repoName,
|
||||
// Try to read description from skill frontmatter
|
||||
description: readSkillDescription(skill.path),
|
||||
}));
|
||||
|
||||
setAllSkills(prev => {
|
||||
const updated = [...prev, ...newSkills];
|
||||
return updated.sort((a, b) => a.name.localeCompare(b.name));
|
||||
});
|
||||
|
||||
setFetchedRepos(prev => new Set([...prev, source]));
|
||||
|
||||
if (result.tempRoot) {
|
||||
const { rmSync } = await import('node:fs');
|
||||
rmSync(result.tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
} catch (err) {
|
||||
const errorMsg = err instanceof Error ? err.message : 'Failed to fetch repository';
|
||||
setError(errorMsg);
|
||||
// Track failed repos for display
|
||||
setFailedRepos(prev => prev.includes(source) ? prev : [...prev, source]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setCurrentRepo(null);
|
||||
}
|
||||
}, [fetchedRepos, repos]);
|
||||
|
||||
const fetchAllRepos = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
const failures: string[] = [];
|
||||
|
||||
for (const repo of repos) {
|
||||
if (!fetchedRepos.has(repo.source)) {
|
||||
setCurrentRepo(repo.source);
|
||||
try {
|
||||
await fetchRepo(repo.source);
|
||||
} catch (err) {
|
||||
// Track which repos failed
|
||||
failures.push(repo.source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update failed repos list
|
||||
if (failures.length > 0) {
|
||||
setFailedRepos(prev => {
|
||||
const combined = [...prev, ...failures];
|
||||
return [...new Set(combined)]; // deduplicate
|
||||
});
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
setCurrentRepo(null);
|
||||
}, [fetchRepo, fetchedRepos, repos]);
|
||||
|
||||
const search = useCallback((query: string) => {
|
||||
if (!query.trim()) {
|
||||
setFilteredSkills(allSkills);
|
||||
} else {
|
||||
const lowerQuery = query.toLowerCase();
|
||||
setFilteredSkills(
|
||||
allSkills.filter(
|
||||
(s) =>
|
||||
s.name.toLowerCase().includes(lowerQuery) ||
|
||||
s.source.toLowerCase().includes(lowerQuery) ||
|
||||
s.repoName.toLowerCase().includes(lowerQuery) ||
|
||||
s.description?.toLowerCase().includes(lowerQuery)
|
||||
)
|
||||
);
|
||||
}
|
||||
}, [allSkills]);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
setFetchedRepos(new Set());
|
||||
setAllSkills([]);
|
||||
setFilteredSkills([]);
|
||||
setFailedRepos([]);
|
||||
setError(null);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setFilteredSkills(allSkills);
|
||||
}, [allSkills]);
|
||||
|
||||
const skills: SkillItem[] = filteredSkills.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description || s.repoName,
|
||||
source: s.source,
|
||||
}));
|
||||
|
||||
return {
|
||||
skills,
|
||||
loading,
|
||||
error,
|
||||
totalCount: allSkills.length,
|
||||
repos,
|
||||
currentRepo,
|
||||
failedRepos,
|
||||
refresh,
|
||||
search,
|
||||
fetchRepo,
|
||||
fetchAllRepos,
|
||||
};
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import {
|
||||
LearningStore,
|
||||
ObservationStore,
|
||||
getMemoryStatus,
|
||||
createMemoryInjector,
|
||||
type Learning,
|
||||
type Observation,
|
||||
type MemoryStatus,
|
||||
} from '@skillkit/core';
|
||||
|
||||
interface UseMemoryResult {
|
||||
learnings: Learning[];
|
||||
observations: Observation[];
|
||||
status: MemoryStatus | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
isGlobal: boolean;
|
||||
setIsGlobal: (isGlobal: boolean) => void;
|
||||
refresh: () => void;
|
||||
search: (query: string) => Learning[];
|
||||
deleteLearning: (id: string) => boolean;
|
||||
deleteObservation: (id: string) => boolean;
|
||||
}
|
||||
|
||||
export function useMemory(): UseMemoryResult {
|
||||
const [learnings, setLearnings] = useState<Learning[]>([]);
|
||||
const [observations, setObservations] = useState<Observation[]>([]);
|
||||
const [status, setStatus] = useState<MemoryStatus | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isGlobal, setIsGlobal] = useState(false);
|
||||
|
||||
const projectPath = process.cwd();
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Get memory status
|
||||
const memStatus = getMemoryStatus(projectPath);
|
||||
setStatus(memStatus);
|
||||
|
||||
// Load learnings
|
||||
const learningStore = new LearningStore(
|
||||
isGlobal ? 'global' : 'project',
|
||||
isGlobal ? undefined : projectPath
|
||||
);
|
||||
setLearnings(learningStore.getAll());
|
||||
|
||||
// Load observations (project only)
|
||||
if (memStatus.hasObservations) {
|
||||
const obsStore = new ObservationStore(projectPath);
|
||||
setObservations(obsStore.getAll());
|
||||
} else {
|
||||
setObservations([]);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load memory');
|
||||
setLearnings([]);
|
||||
setObservations([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [projectPath, isGlobal]);
|
||||
|
||||
const search = useCallback(
|
||||
(query: string): Learning[] => {
|
||||
if (!query.trim()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const injector = createMemoryInjector(projectPath);
|
||||
const results = injector.search(query, {
|
||||
includeGlobal: true,
|
||||
maxLearnings: 50,
|
||||
minRelevance: 0,
|
||||
});
|
||||
return results.map((r) => r.learning);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
[projectPath]
|
||||
);
|
||||
|
||||
const deleteLearning = useCallback(
|
||||
(id: string): boolean => {
|
||||
try {
|
||||
const store = new LearningStore(
|
||||
isGlobal ? 'global' : 'project',
|
||||
isGlobal ? undefined : projectPath
|
||||
);
|
||||
const result = store.delete(id);
|
||||
if (result) {
|
||||
refresh();
|
||||
}
|
||||
return result;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[projectPath, isGlobal, refresh]
|
||||
);
|
||||
|
||||
const deleteObservation = useCallback(
|
||||
(id: string): boolean => {
|
||||
try {
|
||||
const store = new ObservationStore(projectPath);
|
||||
const result = store.delete(id);
|
||||
if (result) {
|
||||
refresh();
|
||||
}
|
||||
return result;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[projectPath, refresh]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
refresh();
|
||||
}, [refresh]);
|
||||
|
||||
return {
|
||||
learnings,
|
||||
observations,
|
||||
status,
|
||||
loading,
|
||||
error,
|
||||
isGlobal,
|
||||
setIsGlobal,
|
||||
refresh,
|
||||
search,
|
||||
deleteLearning,
|
||||
deleteObservation,
|
||||
};
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import {
|
||||
RecommendationEngine,
|
||||
ContextManager,
|
||||
type ScoredSkill,
|
||||
type ProjectProfile,
|
||||
loadIndex as loadIndexFromCache,
|
||||
saveIndex,
|
||||
buildSkillIndex,
|
||||
isIndexStale,
|
||||
KNOWN_SKILL_REPOS,
|
||||
} from '@skillkit/core';
|
||||
|
||||
interface UseRecommendResult {
|
||||
recommendations: ScoredSkill[];
|
||||
profile: ProjectProfile | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
totalScanned: number;
|
||||
indexStatus: 'missing' | 'stale' | 'fresh';
|
||||
refresh: () => void;
|
||||
updateIndex: () => void;
|
||||
search: (query: string) => void;
|
||||
searchResults: ScoredSkill[];
|
||||
}
|
||||
|
||||
export function useRecommend(projectPath: string = process.cwd()): UseRecommendResult {
|
||||
const [recommendations, setRecommendations] = useState<ScoredSkill[]>([]);
|
||||
const [searchResults, setSearchResults] = useState<ScoredSkill[]>([]);
|
||||
const [profile, setProfile] = useState<ProjectProfile | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [totalScanned, setTotalScanned] = useState(0);
|
||||
const [indexStatus, setIndexStatus] = useState<'missing' | 'stale' | 'fresh'>('missing');
|
||||
const [engine] = useState(() => new RecommendationEngine());
|
||||
|
||||
const loadIndex = useCallback(() => {
|
||||
const index = loadIndexFromCache();
|
||||
|
||||
if (!index) {
|
||||
setIndexStatus('missing');
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if index is stale
|
||||
if (isIndexStale(index)) {
|
||||
setIndexStatus('stale');
|
||||
} else {
|
||||
setIndexStatus('fresh');
|
||||
}
|
||||
|
||||
return index;
|
||||
}, []);
|
||||
|
||||
const getProjectProfile = useCallback((): ProjectProfile | null => {
|
||||
try {
|
||||
const manager = new ContextManager(projectPath);
|
||||
let context = manager.get();
|
||||
|
||||
if (!context) {
|
||||
context = manager.init();
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
name: context.project.name,
|
||||
type: context.project.type,
|
||||
stack: context.stack,
|
||||
patterns: context.patterns,
|
||||
installedSkills: context.skills?.installed || [],
|
||||
excludedSkills: context.skills?.excluded || [],
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}, [projectPath]);
|
||||
|
||||
const loadRecommendations = useCallback(() => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Load project profile
|
||||
const projectProfile = getProjectProfile();
|
||||
if (!projectProfile) {
|
||||
setError('Failed to analyze project');
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
setProfile(projectProfile);
|
||||
|
||||
// Load skill index
|
||||
const index = loadIndex();
|
||||
if (!index || index.skills.length === 0) {
|
||||
setRecommendations([]);
|
||||
setTotalScanned(0);
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
engine.loadIndex(index);
|
||||
|
||||
// Get recommendations
|
||||
const result = engine.recommend(projectProfile, {
|
||||
limit: 20,
|
||||
minScore: 20,
|
||||
excludeInstalled: true,
|
||||
includeReasons: true,
|
||||
});
|
||||
|
||||
setRecommendations(result.recommendations);
|
||||
setTotalScanned(result.totalSkillsScanned);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to get recommendations');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [engine, getProjectProfile, loadIndex]);
|
||||
|
||||
const updateIndex = useCallback(() => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
// Fetch skills from known GitHub repositories
|
||||
buildSkillIndex(KNOWN_SKILL_REPOS)
|
||||
.then(({ index, errors }) => {
|
||||
if (errors.length > 0) {
|
||||
console.warn('Index update warnings:', errors);
|
||||
}
|
||||
|
||||
// Save the fetched index
|
||||
saveIndex(index);
|
||||
setIndexStatus('fresh');
|
||||
|
||||
// Reload recommendations with new index
|
||||
loadRecommendations();
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(err instanceof Error ? err.message : 'Failed to update index');
|
||||
setLoading(false);
|
||||
});
|
||||
}, [loadRecommendations]);
|
||||
|
||||
const search = useCallback((query: string) => {
|
||||
if (!query.trim()) {
|
||||
setSearchResults([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const results = engine.search({
|
||||
query,
|
||||
limit: 10,
|
||||
semantic: true,
|
||||
});
|
||||
|
||||
// Convert SearchResult to ScoredSkill for consistency
|
||||
const scoredResults: ScoredSkill[] = results.map(r => ({
|
||||
skill: r.skill,
|
||||
score: r.relevance,
|
||||
reasons: r.matchedTerms.map(term => ({
|
||||
category: 'tag' as const,
|
||||
description: `Matched: ${term}`,
|
||||
weight: 0,
|
||||
matched: [term],
|
||||
})),
|
||||
warnings: [],
|
||||
}));
|
||||
|
||||
setSearchResults(scoredResults);
|
||||
}, [engine]);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
loadRecommendations();
|
||||
}, [loadRecommendations]);
|
||||
|
||||
// Initial load
|
||||
useEffect(() => {
|
||||
loadRecommendations();
|
||||
}, [loadRecommendations]);
|
||||
|
||||
return {
|
||||
recommendations,
|
||||
profile,
|
||||
loading,
|
||||
error,
|
||||
totalScanned,
|
||||
indexStatus,
|
||||
refresh,
|
||||
updateIndex,
|
||||
search,
|
||||
searchResults,
|
||||
};
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { findAllSkills } from '@skillkit/core';
|
||||
import { getSearchDirs } from '../helpers.js';
|
||||
import type { SkillItem } from '../components/SkillList.js';
|
||||
|
||||
interface UseSkillsResult {
|
||||
skills: SkillItem[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
refresh: () => void;
|
||||
remove: (name: string) => Promise<void>;
|
||||
}
|
||||
|
||||
export function useSkills(): UseSkillsResult {
|
||||
const [skills, setSkills] = useState<SkillItem[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const refresh = () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const searchDirs = getSearchDirs();
|
||||
const foundSkills = findAllSkills(searchDirs);
|
||||
|
||||
const skillItems: SkillItem[] = foundSkills.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
source: s.metadata?.source,
|
||||
enabled: s.enabled,
|
||||
}));
|
||||
|
||||
setSkills(skillItems);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load skills');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const remove = async (name: string) => {
|
||||
const { rmSync } = await import('node:fs');
|
||||
const foundSkill = skills.find(s => s.name === name);
|
||||
if (foundSkill) {
|
||||
const searchDirs = getSearchDirs();
|
||||
const allSkills = findAllSkills(searchDirs);
|
||||
const skill = allSkills.find(s => s.name === name);
|
||||
if (skill) {
|
||||
rmSync(skill.path, { recursive: true, force: true });
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
refresh();
|
||||
}, []);
|
||||
|
||||
return { skills, loading, error, refresh, remove };
|
||||
}
|
||||
+20
-15
@@ -1,22 +1,27 @@
|
||||
import { render } from 'ink';
|
||||
import { createCliRenderer } from '@opentui/core';
|
||||
import { createRoot } from '@opentui/react';
|
||||
import { App } from './App.js';
|
||||
|
||||
export function startTUI(): Promise<void> {
|
||||
process.stdout.write('\x1B[2J\x1B[0f');
|
||||
|
||||
const { waitUntilExit, clear } = render(<App />, {
|
||||
exitOnCtrlC: true,
|
||||
});
|
||||
|
||||
return waitUntilExit().then(() => {
|
||||
clear();
|
||||
});
|
||||
export function exitTUI(code = 0): void {
|
||||
try {
|
||||
process.stdout.write('\x1b[?1049l\x1b[?25h\x1b[0m');
|
||||
} catch {
|
||||
// Ignore write errors
|
||||
}
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
// Re-export types and components for external use
|
||||
export type { Screen } from './App.js';
|
||||
export async function startTUI(): Promise<never> {
|
||||
const renderer = await createCliRenderer({ exitOnCtrlC: true });
|
||||
const root = createRoot(renderer);
|
||||
root.render(<App onExit={exitTUI} />);
|
||||
return new Promise(() => {});
|
||||
}
|
||||
|
||||
export { type Screen } from './state/types.js';
|
||||
export { App } from './App.js';
|
||||
export * from './theme/index.js';
|
||||
export * from './state/index.js';
|
||||
export * from './utils/index.js';
|
||||
export * from './components/index.js';
|
||||
export * from './screens/index.js';
|
||||
export * from './hooks/index.js';
|
||||
export * from './theme.js';
|
||||
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Type declarations for OpenTUI React JSX elements
|
||||
* Overrides React's JSX namespace to include OpenTUI elements
|
||||
*/
|
||||
import * as React from 'react';
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
box: React.PropsWithChildren<{
|
||||
flexDirection?: 'row' | 'column';
|
||||
flexGrow?: number;
|
||||
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch';
|
||||
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
padding?: number;
|
||||
paddingLeft?: number;
|
||||
paddingRight?: number;
|
||||
paddingTop?: number;
|
||||
paddingBottom?: number;
|
||||
paddingX?: number;
|
||||
paddingY?: number;
|
||||
margin?: number;
|
||||
marginLeft?: number;
|
||||
marginRight?: number;
|
||||
marginTop?: number;
|
||||
marginBottom?: number;
|
||||
marginX?: number;
|
||||
marginY?: number;
|
||||
gap?: number;
|
||||
border?: boolean;
|
||||
borderStyle?: 'single' | 'double' | 'rounded';
|
||||
borderColor?: string;
|
||||
backgroundColor?: string;
|
||||
color?: string;
|
||||
bold?: boolean;
|
||||
dim?: boolean;
|
||||
title?: string;
|
||||
style?: Record<string, unknown>;
|
||||
key?: React.Key;
|
||||
}>;
|
||||
text: React.PropsWithChildren<{
|
||||
color?: string;
|
||||
bold?: boolean;
|
||||
dim?: boolean;
|
||||
attributes?: number;
|
||||
width?: number;
|
||||
key?: React.Key;
|
||||
}>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
+161
-201
@@ -1,222 +1,182 @@
|
||||
import { useState } from 'react';
|
||||
import { existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { useMarketplace } from '../hooks/useMarketplace.js';
|
||||
import { detectProvider, type AgentType, type SkillMetadata } from '@skillkit/core';
|
||||
import { detectAgent, getAdapter, getAllAdapters } from '@skillkit/agents';
|
||||
import { getInstallDir, saveSkillMetadata } from '../helpers.js';
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, DEFAULT_REPOS } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
type View = 'repos' | 'skills' | 'agents';
|
||||
|
||||
interface Props {
|
||||
interface BrowseProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Browse({ rows = 24 }: Props) {
|
||||
const { repos, skills, loading, currentRepo, fetchRepo, fetchAllRepos } = useMarketplace();
|
||||
const [view, setView] = useState<View>('repos');
|
||||
const [sel, setSel] = useState(0);
|
||||
const [installing, setInstalling] = useState<string | null>(null);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
const [selectedSkill, setSelectedSkill] = useState<{ name: string; source: string } | null>(null);
|
||||
const [agents, setAgents] = useState<{ type: AgentType; name: string; detected: boolean }[]>([]);
|
||||
export function Browse({ onNavigate, cols = 80, rows = 24 }: BrowseProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchMode, setSearchMode] = useState(false);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
|
||||
const items = view === 'repos' ? repos : view === 'skills' ? skills : agents;
|
||||
const maxVisible = Math.max(5, rows - 8);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), items.length - maxVisible));
|
||||
const visible = items.slice(start, start + maxVisible);
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
const showAgentSelection = async (skillName: string, source: string) => {
|
||||
setSelectedSkill({ name: skillName, source });
|
||||
const adapters = getAllAdapters();
|
||||
const agentList: typeof agents = [];
|
||||
for (const a of adapters) {
|
||||
agentList.push({
|
||||
type: a.type as AgentType,
|
||||
name: a.name,
|
||||
detected: await a.isDetected(),
|
||||
});
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
const repos = useMemo(() =>
|
||||
DEFAULT_REPOS.map((r) => ({
|
||||
name: r.name,
|
||||
source: r.source,
|
||||
})),
|
||||
[]
|
||||
);
|
||||
|
||||
const filteredRepos = useMemo(() =>
|
||||
searchQuery
|
||||
? repos.filter(
|
||||
(r) =>
|
||||
r.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
r.source.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
)
|
||||
: repos,
|
||||
[repos, searchQuery]
|
||||
);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, filteredRepos.length - 1)));
|
||||
}, [filteredRepos.length]);
|
||||
|
||||
useKeyboard((key: { name?: string; sequence?: string }) => {
|
||||
if (searchMode) {
|
||||
if (key.name === 'escape') {
|
||||
setSearchMode(false);
|
||||
} else if (key.name === 'backspace') {
|
||||
setSearchQuery(prev => prev.slice(0, -1));
|
||||
} else if (key.name === 'return') {
|
||||
setSearchMode(false);
|
||||
} else if (key.sequence && key.sequence.length === 1 && /[a-zA-Z0-9\-_.]/.test(key.sequence)) {
|
||||
setSearchQuery(prev => prev + key.sequence);
|
||||
setSelectedIndex(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
setAgents(agentList);
|
||||
setView('agents');
|
||||
setSel(0);
|
||||
};
|
||||
|
||||
const installSkill = async (skillName: string, source: string, agentType?: AgentType) => {
|
||||
setInstalling(skillName);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
const provider = detectProvider(source);
|
||||
if (!provider) {
|
||||
setMessage(`Error: Unknown provider for ${source}`);
|
||||
setInstalling(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await provider.clone(source, '', { depth: 1 });
|
||||
|
||||
if (!result.success || !result.discoveredSkills) {
|
||||
setMessage(`Error: ${result.error || 'Failed to fetch'}`);
|
||||
setInstalling(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const skill = result.discoveredSkills.find(s => s.name === skillName);
|
||||
if (!skill) {
|
||||
setMessage(`Error: Skill ${skillName} not found`);
|
||||
setInstalling(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const targetAgentType = agentType || await detectAgent();
|
||||
const adapter = getAdapter(targetAgentType);
|
||||
const installDir = getInstallDir(false, targetAgentType);
|
||||
|
||||
if (!existsSync(installDir)) {
|
||||
mkdirSync(installDir, { recursive: true });
|
||||
}
|
||||
|
||||
const targetPath = join(installDir, skillName);
|
||||
|
||||
if (existsSync(targetPath)) {
|
||||
rmSync(targetPath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
cpSync(skill.path, targetPath, { recursive: true, dereference: true });
|
||||
|
||||
const metadata: SkillMetadata = {
|
||||
name: skillName,
|
||||
description: '',
|
||||
source: source,
|
||||
sourceType: provider.type,
|
||||
subpath: skillName,
|
||||
installedAt: new Date().toISOString(),
|
||||
enabled: true,
|
||||
};
|
||||
saveSkillMetadata(targetPath, metadata);
|
||||
|
||||
if (result.tempRoot) {
|
||||
rmSync(result.tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
setMessage(`✓ Installed ${skillName} to ${adapter.name}`);
|
||||
if (!agentType) {
|
||||
setView('skills');
|
||||
}
|
||||
} catch (err) {
|
||||
setMessage(`Error: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
||||
} finally {
|
||||
setInstalling(null);
|
||||
if (agentType) {
|
||||
setSelectedSkill(null);
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.sequence === '/') setSearchMode(true);
|
||||
else if (key.name === 'return') {
|
||||
const repo = filteredRepos[selectedIndex];
|
||||
if (repo) {
|
||||
// Open/view the selected repo (navigate to installed to see skills from this repo)
|
||||
onNavigate('installed');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || installing) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(items.length - 1, i + 1));
|
||||
else if (key.return) {
|
||||
if (view === 'repos' && repos[sel]) {
|
||||
fetchRepo(repos[sel].source);
|
||||
setView('skills');
|
||||
setSel(0);
|
||||
setMessage(null);
|
||||
} else if (view === 'skills' && skills[sel]?.source) {
|
||||
installSkill(skills[sel].name, skills[sel].source);
|
||||
} else if (view === 'agents' && agents[sel]) {
|
||||
installSkill(selectedSkill!.name, selectedSkill!.source, agents[sel].type);
|
||||
}
|
||||
}
|
||||
else if (input === 'm' && view === 'skills' && skills[sel]?.source) {
|
||||
showAgentSelection(skills[sel].name, skills[sel].source!);
|
||||
}
|
||||
else if (input === 'r') {
|
||||
if (view === 'skills') {
|
||||
setView('repos');
|
||||
setSel(0);
|
||||
setMessage(null);
|
||||
} else if (view === 'agents') {
|
||||
setView('skills');
|
||||
setSel(0);
|
||||
}
|
||||
}
|
||||
else if (input === 'a' && view === 'repos') {
|
||||
fetchAllRepos();
|
||||
setView('skills');
|
||||
setSel(0);
|
||||
}
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
});
|
||||
|
||||
if (view === 'agents') {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SELECT AGENT</Text>
|
||||
<Text dimColor>Install "{selectedSkill?.name}" to which agent?</Text>
|
||||
<Text dimColor>(All agents supported - directory created if needed)</Text>
|
||||
useEffect(() => {
|
||||
if (selectedIndex >= filteredRepos.length && filteredRepos.length > 0) {
|
||||
setSelectedIndex(filteredRepos.length - 1);
|
||||
}
|
||||
}, [filteredRepos.length, selectedIndex]);
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{visible.map((agent, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
const a = agent as typeof agents[0];
|
||||
const status = a.detected ? '(ready)' : '(will create)';
|
||||
return (
|
||||
<Text key={a.type} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {a.name.padEnd(20)} <Text color={colors.secondaryDim}>{status}</Text>
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
// Calculate visible repos
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const startIdx = Math.max(0, Math.min(selectedIndex - Math.floor(maxVisible / 2), filteredRepos.length - maxVisible));
|
||||
const visibleRepos = filteredRepos.slice(startIdx, startIdx + maxVisible);
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=install to selected agent r=back q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter open / search esc back'
|
||||
: 'j/k navigate enter open / search esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>{view === 'repos' ? 'REPOSITORIES' : 'SKILLS'}</Text>
|
||||
{loading && <Text dimColor>Loading {currentRepo}...</Text>}
|
||||
{installing && <Text>Installing {installing}...</Text>}
|
||||
{message && <Text dimColor>{message}</Text>}
|
||||
<Text dimColor>{items.length} items</Text>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.browse}>⌕ Browse</text>
|
||||
<text fg={terminalColors.textMuted}>{filteredRepos.length} repos</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>explore skill repositories</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((item, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
const name = view === 'repos'
|
||||
? (item as typeof repos[0]).name
|
||||
: (item as typeof skills[0]).name;
|
||||
const src = view === 'repos'
|
||||
? (item as typeof repos[0]).source
|
||||
: (item as typeof skills[0]).source || '';
|
||||
return (
|
||||
<Text key={src + name} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '}{name.padEnd(25)} <Text color={colors.secondaryDim}>{src}</Text>
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < items.length && <Text dimColor> ↓ {items.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
{/* Search */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>/ </text>
|
||||
<text fg={searchQuery ? terminalColors.text : terminalColors.textMuted}>
|
||||
{searchQuery || 'type to filter...'}
|
||||
</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>
|
||||
{view === 'repos'
|
||||
? 'Enter=fetch a=all q=quit'
|
||||
: 'Enter=quick install m=choose agent r=back q=quit'}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{/* Repository list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Repositories</text>
|
||||
<text> </text>
|
||||
|
||||
{filteredRepos.length === 0 ? (
|
||||
<text fg={terminalColors.textMuted}>No repositories match your search</text>
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
{visibleRepos.map((repo, idx) => {
|
||||
const actualIdx = startIdx + idx;
|
||||
const selected = actualIdx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
// Truncate source if needed - clamp to avoid negative slicing
|
||||
const available = Math.max(0, contentWidth - repo.name.length - 6);
|
||||
const safeSlice = Math.max(0, available - 3);
|
||||
const displaySource = available > 0 && repo.source.length > available
|
||||
? repo.source.slice(0, safeSlice) + '...'
|
||||
: repo.source;
|
||||
return (
|
||||
<box key={repo.source} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{repo.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}> · {displaySource}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Scroll indicator */}
|
||||
{filteredRepos.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}showing {startIdx + 1}-{Math.min(startIdx + maxVisible, filteredRepos.length)} of {filteredRepos.length}
|
||||
</text>
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,276 +1,56 @@
|
||||
/**
|
||||
* Context Screen
|
||||
* Project context analysis
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import {
|
||||
loadContext,
|
||||
initContext,
|
||||
syncToAgent,
|
||||
type ProjectContext,
|
||||
type AgentType,
|
||||
} from '@skillkit/core';
|
||||
import { getAllAdapters } from '@skillkit/agents';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
|
||||
type View = 'overview' | 'sync';
|
||||
|
||||
interface AgentItem {
|
||||
type: AgentType;
|
||||
name: string;
|
||||
detected: boolean;
|
||||
synced?: boolean;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
interface ContextProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Context({ rows = 24 }: Props) {
|
||||
const [view, setView] = useState<View>('overview');
|
||||
const [context, setContext] = useState<ProjectContext | null>(null);
|
||||
export function Context({ onNavigate, cols = 80, rows = 24 }: ContextProps) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [initializing, setInitializing] = useState(false);
|
||||
const [syncing, setSyncing] = useState(false);
|
||||
const [agents, setAgents] = useState<AgentItem[]>([]);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const projectPath = process.cwd();
|
||||
|
||||
useEffect(() => {
|
||||
const load = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const ctx = loadContext(projectPath);
|
||||
setContext(ctx);
|
||||
const timer = setTimeout(() => setLoading(false), 500);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const adapters = getAllAdapters();
|
||||
const agentList: AgentItem[] = [];
|
||||
for (const a of adapters) {
|
||||
const detected = await a.isDetected();
|
||||
agentList.push({
|
||||
type: a.type as AgentType,
|
||||
name: a.name,
|
||||
detected,
|
||||
synced: ctx?.agents?.synced?.includes(a.type),
|
||||
});
|
||||
}
|
||||
setAgents(agentList);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load context');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
load();
|
||||
}, [projectPath]);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 14);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), agents.length - maxVisible));
|
||||
const visible = agents.slice(start, start + maxVisible);
|
||||
|
||||
const handleInit = () => {
|
||||
setInitializing(true);
|
||||
setMessage(null);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const newContext = initContext(projectPath);
|
||||
setContext(newContext);
|
||||
setMessage('Context initialized successfully');
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to initialize context');
|
||||
} finally {
|
||||
setInitializing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSync = async (agentType: AgentType) => {
|
||||
setSyncing(true);
|
||||
setMessage(null);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
await syncToAgent(agentType, projectPath);
|
||||
|
||||
setAgents(prev =>
|
||||
prev.map(a =>
|
||||
a.type === agentType ? { ...a, synced: true } : a
|
||||
)
|
||||
);
|
||||
|
||||
setMessage(`Synced to ${agentType} successfully`);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Sync failed');
|
||||
} finally {
|
||||
setSyncing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSyncAll = async () => {
|
||||
setSyncing(true);
|
||||
setMessage(null);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const detectedAgents = agents.filter(a => a.detected);
|
||||
for (const agent of detectedAgents) {
|
||||
await syncToAgent(agent.type, projectPath);
|
||||
}
|
||||
|
||||
setAgents(prev =>
|
||||
prev.map(a =>
|
||||
a.detected ? { ...a, synced: true } : a
|
||||
)
|
||||
);
|
||||
|
||||
setMessage(`Synced to ${detectedAgents.length} agents`);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Sync failed');
|
||||
} finally {
|
||||
setSyncing(false);
|
||||
}
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || initializing || syncing) return;
|
||||
|
||||
if (view === 'sync') {
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(agents.length - 1, i + 1));
|
||||
else if (key.return && agents[sel]) {
|
||||
handleSync(agents[sel].type);
|
||||
}
|
||||
else if (key.escape) {
|
||||
setView('overview');
|
||||
setSel(0);
|
||||
}
|
||||
else if (input === 'a') {
|
||||
handleSyncAll();
|
||||
}
|
||||
} else if (view === 'overview') {
|
||||
if (input === 'i') handleInit();
|
||||
else if (input === 's') {
|
||||
setView('sync');
|
||||
setSel(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>PROJECT CONTEXT</Text>
|
||||
<Text dimColor>Loading...</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (view === 'sync') {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SYNC TO AGENTS</Text>
|
||||
<Text dimColor>Select an agent to sync your project context</Text>
|
||||
|
||||
{message && <Text color="green">{'✓'} {message}</Text>}
|
||||
{error && <Text color="red">{'✗'} {error}</Text>}
|
||||
{syncing && <Text dimColor>Syncing...</Text>}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((agent, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
const status = agent.synced
|
||||
? '(synced)'
|
||||
: agent.detected
|
||||
? '(ready)'
|
||||
: '(not detected)';
|
||||
const statusColor = agent.synced ? 'green' : agent.detected ? 'yellow' : 'gray';
|
||||
|
||||
return (
|
||||
<Text key={agent.type} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {agent.name.padEnd(20)}
|
||||
<Text color={statusColor}>{status}</Text>
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < agents.length && (
|
||||
<Text dimColor> ↓ {agents.length - start - maxVisible} more</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=sync to agent a=sync all detected Esc=back q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
const stack = context?.stack;
|
||||
const detectedCount = agents.filter(a => a.detected).length;
|
||||
const syncedCount = agents.filter(a => a.synced).length;
|
||||
const contextInfo = [
|
||||
{ label: 'Working Directory', value: process.cwd() },
|
||||
{ label: 'Node Version', value: process.version },
|
||||
{ label: 'Platform', value: process.platform },
|
||||
{ label: 'Architecture', value: process.arch },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>PROJECT CONTEXT</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Project Context"
|
||||
subtitle="Analyze your project environment"
|
||||
icon="◉"
|
||||
/>
|
||||
|
||||
{message && <Text color="green">{'✓'} {message}</Text>}
|
||||
{error && <Text color="red">{'✗'} {error}</Text>}
|
||||
{initializing && <Text dimColor>Initializing...</Text>}
|
||||
|
||||
{!context && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color="yellow">No context found.</Text>
|
||||
<Text dimColor>Press 'i' to initialize and analyze your project.</Text>
|
||||
</Box>
|
||||
{loading ? (
|
||||
<Spinner label="Analyzing project context..." />
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
{contextInfo.map((info) => (
|
||||
<box key={info.label} flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={20}>
|
||||
{info.label}:
|
||||
</text>
|
||||
<text fg={terminalColors.text}>{info.value}</text>
|
||||
</box>
|
||||
))}
|
||||
</box>
|
||||
)}
|
||||
|
||||
{context && (
|
||||
<>
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold>Project:</Text>
|
||||
<Text> Name: {context.project?.name || 'Unknown'}</Text>
|
||||
<Text> Type: {context.project?.type || 'Not detected'}</Text>
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold>Stack:</Text>
|
||||
{stack?.languages && stack.languages.length > 0 && (
|
||||
<Text> Languages: {stack.languages.map(l => l.name).join(', ')}</Text>
|
||||
)}
|
||||
{stack?.frameworks && stack.frameworks.length > 0 && (
|
||||
<Text> Frameworks: {stack.frameworks.map(f => f.name).join(', ')}</Text>
|
||||
)}
|
||||
{stack?.libraries && stack.libraries.length > 0 && (
|
||||
<Text> Libraries: {stack.libraries.slice(0, 5).map(l => l.name).join(', ')}{stack.libraries.length > 5 ? '...' : ''}</Text>
|
||||
)}
|
||||
{(!stack?.languages?.length && !stack?.frameworks?.length) && (
|
||||
<Text dimColor> No stack detected. Press 'i' to re-analyze.</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold>Agents:</Text>
|
||||
<Text> Detected: {detectedCount} agents</Text>
|
||||
<Text> Synced: {syncedCount} agents</Text>
|
||||
{detectedCount > 0 && (
|
||||
<Text dimColor> ({agents.filter(a => a.detected).map(a => a.name).join(', ')})</Text>
|
||||
)}
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold>Actions:</Text>
|
||||
<Text dimColor> [i] Initialize/refresh context</Text>
|
||||
<Text dimColor> [s] Sync to agents</Text>
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>i=init context s=sync to agents q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,131 +1,53 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { createSessionManager, type SessionState, type CurrentExecution } from '@skillkit/core';
|
||||
/**
|
||||
* Execute Screen
|
||||
* Live skill execution
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { ProgressBar } from '../components/ProgressBar.js';
|
||||
|
||||
interface Props {
|
||||
interface ExecuteProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Execute({ rows = 24 }: Props) {
|
||||
const [session, setSession] = useState<SessionState | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
|
||||
useEffect(() => {
|
||||
loadSession();
|
||||
// Poll for updates
|
||||
const interval = setInterval(loadSession, 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
const loadSession = () => {
|
||||
try {
|
||||
const manager = createSessionManager(process.cwd());
|
||||
const state = manager.get();
|
||||
setSession(state);
|
||||
} catch {
|
||||
setSession(null);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useInput((input, _key) => {
|
||||
if (input === 'r') loadSession();
|
||||
else if (input === 'p' && session?.currentExecution?.status === 'running') {
|
||||
const manager = createSessionManager(process.cwd());
|
||||
manager.pause();
|
||||
loadSession();
|
||||
}
|
||||
else if (input === 'c' && session?.currentExecution?.status === 'paused') {
|
||||
const manager = createSessionManager(process.cwd());
|
||||
manager.resume();
|
||||
loadSession();
|
||||
}
|
||||
});
|
||||
|
||||
const renderExecution = (exec: CurrentExecution) => {
|
||||
const completedTasks = exec.tasks.filter(t => t.status === 'completed').length;
|
||||
const failedTasks = exec.tasks.filter(t => t.status === 'failed').length;
|
||||
const progress = exec.totalSteps > 0 ? Math.round((completedTasks / exec.totalSteps) * 100) : 0;
|
||||
|
||||
const statusColor = exec.status === 'running' ? 'yellow' :
|
||||
exec.status === 'completed' ? 'green' :
|
||||
exec.status === 'paused' ? 'blue' :
|
||||
exec.status === 'failed' ? 'red' : 'white';
|
||||
|
||||
const visibleTasks = exec.tasks.slice(0, maxVisible);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" marginTop={1}>
|
||||
<Text bold>{exec.skillName}</Text>
|
||||
<Text>Source: <Text dimColor>{exec.skillSource}</Text></Text>
|
||||
<Text>Status: <Text color={statusColor}>{exec.status.toUpperCase()}</Text></Text>
|
||||
<Text>Progress: {completedTasks}/{exec.totalSteps} ({progress}%)</Text>
|
||||
|
||||
{/* Progress bar */}
|
||||
<Box marginY={1}>
|
||||
<Text>[</Text>
|
||||
<Text color="green">{'█'.repeat(Math.floor(progress / 5))}</Text>
|
||||
<Text dimColor>{'░'.repeat(20 - Math.floor(progress / 5))}</Text>
|
||||
<Text>]</Text>
|
||||
</Box>
|
||||
|
||||
{/* Task list */}
|
||||
<Text bold>Tasks:</Text>
|
||||
{visibleTasks.map((task, i) => {
|
||||
const icon = task.status === 'completed' ? symbols.success :
|
||||
task.status === 'failed' ? symbols.error :
|
||||
task.status === 'in_progress' ? symbols.warning :
|
||||
task.status === 'paused' ? symbols.info :
|
||||
symbols.bullet;
|
||||
const color = task.status === 'completed' ? 'green' :
|
||||
task.status === 'failed' ? 'red' :
|
||||
task.status === 'in_progress' ? 'yellow' :
|
||||
task.status === 'paused' ? 'blue' : 'white';
|
||||
return (
|
||||
<Text key={task.id || i} color={color}>
|
||||
{icon} {task.name} {task.error && <Text dimColor>({task.error})</Text>}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{exec.tasks.length > maxVisible && (
|
||||
<Text dimColor> ... and {exec.tasks.length - maxVisible} more</Text>
|
||||
)}
|
||||
|
||||
{failedTasks > 0 && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="red">{failedTasks} task(s) failed</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export function Execute({ onNavigate, cols = 80, rows = 24 }: ExecuteProps) {
|
||||
const [executing, setExecuting] = useState(false);
|
||||
const [progress, setProgress] = useState(0);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>EXECUTION MONITOR</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Execute"
|
||||
subtitle="Run skills in real-time"
|
||||
icon="▶"
|
||||
/>
|
||||
|
||||
{loading && <Text>Loading session...</Text>}
|
||||
|
||||
{!loading && !session?.currentExecution && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text dimColor>No active execution.</Text>
|
||||
<Text dimColor>Run a skill with: skillkit run {'<skill>'}</Text>
|
||||
</Box>
|
||||
{executing ? (
|
||||
<box flexDirection="column">
|
||||
<Spinner label="Executing skill..." />
|
||||
<text> </text>
|
||||
<ProgressBar progress={progress} width={40} />
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>Press Esc to cancel</text>
|
||||
</box>
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Select a skill to execute:</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
No skills available. Install skills first using 'b' (browse) or 'm' (marketplace).
|
||||
</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to execute, 'i' to view installed skills
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{!loading && session?.currentExecution && renderExecution(session.currentExecution)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>
|
||||
{session?.currentExecution?.status === 'running' ? 'p=pause ' : ''}
|
||||
{session?.currentExecution?.status === 'paused' ? 'c=continue ' : ''}
|
||||
r=refresh q=quit
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
interface HelpProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
const SHORTCUTS = [
|
||||
{ section: 'Navigation', items: [
|
||||
{ key: 'h', desc: 'Home screen' },
|
||||
{ key: 'b', desc: 'Browse skills' },
|
||||
{ key: 'm', desc: 'Marketplace' },
|
||||
{ key: 'r', desc: 'Recommendations' },
|
||||
{ key: 'i', desc: 'Installed skills' },
|
||||
{ key: 's', desc: 'Sync settings' },
|
||||
]},
|
||||
{ section: 'Actions', items: [
|
||||
{ key: 't', desc: 'Translate skills' },
|
||||
{ key: 'w', desc: 'Workflows' },
|
||||
{ key: 'x', desc: 'Execute' },
|
||||
{ key: 'n', desc: 'Plan' },
|
||||
{ key: 'y', desc: 'History' },
|
||||
]},
|
||||
{ section: 'Team & Config', items: [
|
||||
{ key: 'a', desc: 'Team settings' },
|
||||
{ key: 'c', desc: 'Context' },
|
||||
{ key: 'e', desc: 'Memory' },
|
||||
{ key: 'p', desc: 'Plugins' },
|
||||
{ key: 'o', desc: 'Methodology' },
|
||||
{ key: ',', desc: 'Settings' },
|
||||
]},
|
||||
{ section: 'Global', items: [
|
||||
{ key: '/', desc: 'This help screen' },
|
||||
{ key: 'esc', desc: 'Go back / Home' },
|
||||
{ key: 'q', desc: 'Quit application' },
|
||||
{ key: 'j/k', desc: 'Navigate lists' },
|
||||
{ key: 'enter', desc: 'Select item' },
|
||||
]},
|
||||
];
|
||||
|
||||
function ShortcutSection({ section, items, isLast }: { section: string; items: { key: string; desc: string }[]; isLast: boolean }) {
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>{section}</text>
|
||||
{items.map((item) => (
|
||||
<box key={item.key} flexDirection="row">
|
||||
<text fg={terminalColors.accent} width={8}> {item.key}</text>
|
||||
<text fg={terminalColors.textMuted}>{item.desc}</text>
|
||||
</box>
|
||||
))}
|
||||
{!isLast && <text> </text>}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export function Help({ cols = 80 }: HelpProps) {
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const isCompact = cols < 60;
|
||||
const rawWidth = cols - 4;
|
||||
const contentWidth = Math.max(1, Math.min(rawWidth, 60));
|
||||
const version = getVersion();
|
||||
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.text}>/ Help</text>
|
||||
<text fg={terminalColors.textMuted}>skillkit v{version}</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>keyboard shortcuts and navigation</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
{isCompact ? (
|
||||
SHORTCUTS.map((s, idx) => (
|
||||
<ShortcutSection key={s.section} section={s.section} items={s.items} isLast={idx === SHORTCUTS.length - 1} />
|
||||
))
|
||||
) : (
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" width={Math.floor(contentWidth / 2)}>
|
||||
{SHORTCUTS.slice(0, 2).map((s, idx) => (
|
||||
<ShortcutSection key={s.section} section={s.section} items={s.items} isLast={idx === 1} />
|
||||
))}
|
||||
</box>
|
||||
<box flexDirection="column" width={Math.floor(contentWidth / 2)}>
|
||||
{SHORTCUTS.slice(2).map((s, idx) => (
|
||||
<ShortcutSection key={s.section} section={s.section} items={s.items} isLast={idx === 1} />
|
||||
))}
|
||||
</box>
|
||||
</box>
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>esc back h home q quit</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,127 +1,59 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { createSessionManager, type ExecutionHistory } from '@skillkit/core';
|
||||
/**
|
||||
* History Screen
|
||||
* Execution history
|
||||
*/
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
|
||||
interface Props {
|
||||
interface HistoryProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function History({ rows = 24 }: Props) {
|
||||
const [history, setHistory] = useState<ExecutionHistory[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 8);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), history.length - maxVisible));
|
||||
const visible = history.slice(start, start + maxVisible);
|
||||
|
||||
useEffect(() => {
|
||||
loadHistory();
|
||||
}, []);
|
||||
|
||||
const loadHistory = () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const manager = createSessionManager(process.cwd());
|
||||
const h = manager.getHistory(50);
|
||||
setHistory(h);
|
||||
} catch {
|
||||
setHistory([]);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading) return;
|
||||
|
||||
if (key.upArrow) {
|
||||
setSel(i => Math.max(0, i - 1));
|
||||
setExpanded(false);
|
||||
}
|
||||
else if (key.downArrow) {
|
||||
setSel(i => Math.min(history.length - 1, i + 1));
|
||||
setExpanded(false);
|
||||
}
|
||||
else if (input === 'r') loadHistory();
|
||||
else if (key.return) setExpanded(e => !e);
|
||||
});
|
||||
|
||||
const formatDuration = (ms: number): string => {
|
||||
if (ms < 1000) return `${ms}ms`;
|
||||
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
||||
return `${(ms / 60000).toFixed(1)}m`;
|
||||
};
|
||||
|
||||
const formatDate = (iso: string): string => {
|
||||
const d = new Date(iso);
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - d.getTime();
|
||||
|
||||
if (diff < 60000) return 'Just now';
|
||||
if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;
|
||||
if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`;
|
||||
return d.toLocaleDateString();
|
||||
};
|
||||
export function History({ onNavigate, cols = 80, rows = 24 }: HistoryProps) {
|
||||
const history = [
|
||||
{ skill: 'tdd-workflow', time: '10:32 AM', duration: '2.3s', status: 'success' },
|
||||
{ skill: 'code-review', time: '10:15 AM', duration: '5.1s', status: 'success' },
|
||||
{ skill: 'deploy-check', time: '09:45 AM', duration: '8.7s', status: 'failed' },
|
||||
{ skill: 'lint-fix', time: '09:30 AM', duration: '1.2s', status: 'success' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>EXECUTION HISTORY</Text>
|
||||
<Text dimColor>{history.length} execution(s)</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="History"
|
||||
subtitle="View execution history"
|
||||
count={history.length}
|
||||
icon="◷"
|
||||
/>
|
||||
|
||||
{loading && <Text>Loading history...</Text>}
|
||||
<text fg={terminalColors.text}><b>Recent Executions</b></text>
|
||||
<text> </text>
|
||||
|
||||
{!loading && history.length === 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text dimColor>No execution history.</Text>
|
||||
<Text dimColor>Run a skill with: skillkit run {'<skill>'}</Text>
|
||||
</Box>
|
||||
)}
|
||||
{history.map((item, idx) => (
|
||||
<box key={`${item.skill}-${item.time}`} flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={18}
|
||||
>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{item.skill}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>{item.time}</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>{item.duration}</text>
|
||||
<text
|
||||
fg={item.status === 'success' ? terminalColors.success : terminalColors.error}
|
||||
>
|
||||
{item.status === 'success' ? '\u2713 success' : '\u2717 failed'}
|
||||
</text>
|
||||
</box>
|
||||
))}
|
||||
|
||||
{!loading && history.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((entry, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
const icon = entry.status === 'completed' ? symbols.success :
|
||||
entry.status === 'failed' ? symbols.error :
|
||||
symbols.warning;
|
||||
const color = entry.status === 'completed' ? 'green' :
|
||||
entry.status === 'failed' ? 'red' : 'yellow';
|
||||
|
||||
return (
|
||||
<Box key={idx} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '}<Text color={color}>{icon}</Text> {entry.skillName.padEnd(25)} {formatDate(entry.completedAt).padEnd(12)} {formatDuration(entry.durationMs)}
|
||||
</Text>
|
||||
{isSel && expanded && (
|
||||
<Box flexDirection="column" marginLeft={3}>
|
||||
<Text dimColor>Source: {entry.skillSource}</Text>
|
||||
<Text dimColor>Status: {entry.status}</Text>
|
||||
{entry.commits.length > 0 && (
|
||||
<Text dimColor>Commits: {entry.commits.join(', ')}</Text>
|
||||
)}
|
||||
{entry.filesModified.length > 0 && (
|
||||
<Text dimColor>Files: {entry.filesModified.length} modified</Text>
|
||||
)}
|
||||
{entry.error && (
|
||||
<Text color="red">Error: {entry.error}</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < history.length && <Text dimColor> ↓ {history.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=expand r=refresh q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to view details, 'r' to re-run, 'c' to clear
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, logo } from '../theme.js';
|
||||
import type { Screen } from '../App.js';
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { type Screen, loadSkills, TOTAL_AGENTS } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols, AGENT_LOGOS } from '../theme/symbols.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
interface HomeProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -12,89 +10,146 @@ interface HomeProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
const CHARS = '01█▓▒░╔╗╚╝║═';
|
||||
const FEATURES = [
|
||||
{ key: 'Sync', color: terminalColors.sync, desc: 'share across agents' },
|
||||
{ key: 'Browse', color: terminalColors.browse, desc: 'discover skills' },
|
||||
{ key: 'Recommend', color: terminalColors.recommend, desc: 'AI suggestions' },
|
||||
{ key: 'Translate', color: terminalColors.translate, desc: 'convert formats' },
|
||||
{ key: 'Workflow', color: terminalColors.workflow, desc: 'automate chains' },
|
||||
{ key: 'Team', color: terminalColors.text, desc: 'collaborate' },
|
||||
];
|
||||
|
||||
const logoSmall = `
|
||||
╔═╗╦╔═╦╦ ╦ ╦╔═╦╔╦╗
|
||||
╚═╗╠╩╗║║ ║ ╠╩╗║ ║
|
||||
╚═╝╩ ╩╩╩═╝╩═╝╩ ╩╩ ╩
|
||||
`.trim();
|
||||
export function Home({ cols = 80 }: HomeProps) {
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const [stats, setStats] = useState({ skills: 0, agents: TOTAL_AGENTS, synced: 0 });
|
||||
const [detectedAgents, setDetectedAgents] = useState<string[]>([]);
|
||||
|
||||
function getVersion(): string {
|
||||
try {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const packageJsonPath = join(__dirname, '../../../package.json');
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
||||
return packageJson.version || '1.2.0';
|
||||
} catch {
|
||||
return '1.2.0';
|
||||
}
|
||||
}
|
||||
|
||||
function scramble(target: string, progress: number): string {
|
||||
return target.split('\n').map(line => {
|
||||
return line.split('').map((char, i) => {
|
||||
if (char === ' ') return char;
|
||||
if (progress > (i / line.length) * 100) return char;
|
||||
return CHARS[Math.floor(Math.random() * CHARS.length)];
|
||||
}).join('');
|
||||
}).join('\n');
|
||||
}
|
||||
|
||||
export function Home({ cols = 80, rows = 24 }: HomeProps) {
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [display, setDisplay] = useState('');
|
||||
const version = getVersion();
|
||||
|
||||
const useLogo = cols < 80 ? logoSmall : logo;
|
||||
const isCompact = cols < 70;
|
||||
const isNarrow = cols < 50;
|
||||
const contentWidth = Math.min(cols - 4, 55);
|
||||
const line = '─'.repeat(contentWidth);
|
||||
|
||||
useEffect(() => {
|
||||
if (progress >= 100) {
|
||||
setDisplay(useLogo);
|
||||
return;
|
||||
}
|
||||
const t = setInterval(() => {
|
||||
setProgress(p => {
|
||||
const next = p + 12;
|
||||
setDisplay(scramble(useLogo, next));
|
||||
return next;
|
||||
});
|
||||
}, 35);
|
||||
return () => clearInterval(t);
|
||||
}, [progress, useLogo]);
|
||||
if (animPhase >= 5) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
useEffect(() => {
|
||||
const skillsData = loadSkills();
|
||||
setStats({
|
||||
skills: skillsData.skills.length,
|
||||
agents: TOTAL_AGENTS,
|
||||
synced: Math.min(skillsData.skills.length, 3),
|
||||
});
|
||||
setDetectedAgents(['claude-code', 'cursor', 'github-copilot']);
|
||||
}, []);
|
||||
|
||||
const visibleAgents = useMemo(() => {
|
||||
const allAgents = Object.entries(AGENT_LOGOS);
|
||||
const perRow = isNarrow || isCompact ? 2 : 3;
|
||||
const maxAgents = isNarrow ? 4 : isCompact ? 6 : 9;
|
||||
return {
|
||||
agents: allAgents.slice(0, maxAgents),
|
||||
perRow,
|
||||
remaining: allAgents.length - maxAgents,
|
||||
};
|
||||
}, [isCompact, isNarrow]);
|
||||
|
||||
const getAgentWidth = () => {
|
||||
if (isNarrow) return 22;
|
||||
if (isCompact) return 26;
|
||||
return 18;
|
||||
};
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text color={colors.primary}>{display || useLogo}</Text>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text>Manage AI agent skills from your terminal.</Text>
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold>Quick Actions:</Text>
|
||||
<Text dimColor> [b] Browse skills marketplace</Text>
|
||||
<Text dimColor> [r] Get smart recommendations</Text>
|
||||
<Text dimColor> [t] Translate skills between agents</Text>
|
||||
<Text dimColor> [c] Manage project context</Text>
|
||||
<Text dimColor> [l] View installed skills</Text>
|
||||
<Text dimColor> [s] Sync skills across agents</Text>
|
||||
</Box>
|
||||
|
||||
{rows >= 18 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text bold>Navigation:</Text>
|
||||
<Text dimColor> ↑↓ Navigate lists</Text>
|
||||
<Text dimColor> Enter Select / Confirm</Text>
|
||||
<Text dimColor> Esc Go back / Home</Text>
|
||||
<Text dimColor> q Quit</Text>
|
||||
</Box>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.text}>{symbols.brandIcon} skillkit</text>
|
||||
<text fg={terminalColors.textMuted}> v{version}</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>universal skills for ai coding agents</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>v{version} - Works with 17 AI agents</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<box width={14}><text fg={terminalColors.accent}>{stats.skills}</text></box>
|
||||
<box width={14}><text fg={terminalColors.text}>{stats.agents}</text></box>
|
||||
<box width={14}><text fg={terminalColors.text}>{stats.synced}</text></box>
|
||||
</box>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted} width={14}>skills</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>agents</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>synced</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Works with</text>
|
||||
<text> </text>
|
||||
{Array(Math.ceil(visibleAgents.agents.length / visibleAgents.perRow))
|
||||
.fill(0)
|
||||
.map((_, rowIdx) => (
|
||||
<box key={rowIdx} flexDirection="row">
|
||||
{visibleAgents.agents
|
||||
.slice(rowIdx * visibleAgents.perRow, (rowIdx + 1) * visibleAgents.perRow)
|
||||
.map(([type, agent]) => {
|
||||
const isDetected = detectedAgents.includes(type);
|
||||
return (
|
||||
<box key={type} width={getAgentWidth()} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{agent.icon} {agent.name} </text>
|
||||
<text fg={isDetected ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{isDetected ? '●' : '○'}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
{visibleAgents.remaining > 0 && (
|
||||
<text fg={terminalColors.textMuted}>+{visibleAgents.remaining} more</text>
|
||||
)}
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{animPhase >= 4 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Features</text>
|
||||
<text> </text>
|
||||
{FEATURES.map((feat) => (
|
||||
<box key={feat.key} flexDirection="row">
|
||||
<text fg={feat.color} width={12}> {feat.key}</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.desc}</text>
|
||||
</box>
|
||||
))}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{animPhase >= 5 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{isCompact ? 'b browse m market / help q quit' : 'b browse m market i installed / help q quit'}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,59 +1,224 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { useSkills } from '../hooks/useSkills.js';
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, loadSkills, filterSkills } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface Props {
|
||||
interface InstalledProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Installed({ rows = 24 }: Props) {
|
||||
const { skills, loading, refresh, remove } = useSkills();
|
||||
const [sel, setSel] = useState(0);
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
const maxVisible = Math.max(5, rows - 6);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), skills.length - maxVisible));
|
||||
const visible = skills.slice(start, start + maxVisible);
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading) return;
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(skills.length - 1, i + 1));
|
||||
else if (input === 'r') refresh();
|
||||
else if (input === 'd' && skills[sel]) remove(skills[sel].name);
|
||||
export function Installed({ onNavigate, cols = 80, rows = 24 }: InstalledProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchMode, setSearchMode] = useState(false);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [skills, setSkills] = useState<ReturnType<typeof loadSkills>>({
|
||||
skills: [],
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
// Loading spinner
|
||||
useEffect(() => {
|
||||
if (!skills.loading) return;
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, [skills.loading]);
|
||||
|
||||
// Load skills
|
||||
useEffect(() => {
|
||||
const data = loadSkills();
|
||||
setSkills(data);
|
||||
}, []);
|
||||
|
||||
const filteredSkills = useMemo(() =>
|
||||
filterSkills(skills.skills, searchQuery),
|
||||
[skills.skills, searchQuery]
|
||||
);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, filteredSkills.length - 1)));
|
||||
}, [filteredSkills.length]);
|
||||
|
||||
const handleToggle = useCallback(() => {
|
||||
if (filteredSkills.length === 0) return;
|
||||
const skill = filteredSkills[selectedIndex];
|
||||
if (skill) {
|
||||
setSkills(prev => ({
|
||||
...prev,
|
||||
skills: prev.skills.map(s =>
|
||||
s.name === skill.name ? { ...s, enabled: s.enabled === false } : s
|
||||
),
|
||||
}));
|
||||
}
|
||||
}, [filteredSkills, selectedIndex]);
|
||||
|
||||
const handleKeyboard = useCallback((key: { name?: string; sequence?: string }) => {
|
||||
if (searchMode) {
|
||||
if (key.name === 'escape') {
|
||||
setSearchMode(false);
|
||||
} else if (key.name === 'backspace') {
|
||||
setSearchQuery(prev => prev.slice(0, -1));
|
||||
} else if (key.name === 'return') {
|
||||
setSearchMode(false);
|
||||
} else if (key.sequence && key.sequence.length === 1 && /[a-zA-Z0-9\-_.]/.test(key.sequence)) {
|
||||
setSearchQuery(prev => prev + key.sequence);
|
||||
setSelectedIndex(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.sequence === '/') setSearchMode(true);
|
||||
else if (key.name === 'return') handleToggle();
|
||||
else if (key.name === 'd') handleToggle();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
}, [searchMode, handleKeyNav, handleToggle, onNavigate]);
|
||||
|
||||
useKeyboard(handleKeyboard);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedIndex >= filteredSkills.length && filteredSkills.length > 0) {
|
||||
setSelectedIndex(filteredSkills.length - 1);
|
||||
}
|
||||
}, [filteredSkills.length, selectedIndex]);
|
||||
|
||||
// Calculate visible items
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const startIdx = Math.max(0, Math.min(selectedIndex - Math.floor(maxVisible / 2), filteredSkills.length - maxVisible));
|
||||
const visibleSkills = filteredSkills.slice(startIdx, startIdx + maxVisible);
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
// Stats
|
||||
const enabledCount = skills.skills.filter(s => s.enabled !== false).length;
|
||||
const totalCount = skills.skills.length;
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter toggle d disable esc back'
|
||||
: 'j/k navigate enter toggle d disable esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>INSTALLED SKILLS</Text>
|
||||
<Text dimColor>{skills.length} skills</Text>
|
||||
|
||||
{loading && <Text>Loading...</Text>}
|
||||
|
||||
{!loading && skills.length === 0 && (
|
||||
<Text dimColor>No skills installed. Press b to browse.</Text>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.success}>✓ Installed</text>
|
||||
<text fg={terminalColors.textMuted}>{enabledCount}/{totalCount} active</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>manage your skills</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{!loading && skills.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((skill, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
return (
|
||||
<Text key={skill.name} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '}{skill.name.padEnd(30)} {skill.source && <Text color={colors.secondaryDim}>{skill.source}</Text>}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < skills.length && <Text dimColor> ↓ {skills.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
{/* Search */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>/ </text>
|
||||
<text fg={searchQuery ? terminalColors.text : terminalColors.textMuted}>
|
||||
{searchQuery || 'type to filter...'}
|
||||
</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>r=refresh d=delete q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{/* Skills list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{skills.loading ? (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame]} </text>
|
||||
<text fg={terminalColors.text}>Loading skills...</text>
|
||||
</box>
|
||||
) : skills.error ? (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.error}>✗ Error loading skills</text>
|
||||
<text fg={terminalColors.textMuted}>{skills.error}</text>
|
||||
</box>
|
||||
) : filteredSkills.length === 0 ? (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{skills.skills.length === 0
|
||||
? 'No skills installed yet'
|
||||
: 'No skills match your search'}
|
||||
</text>
|
||||
{skills.skills.length === 0 && (
|
||||
<>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press 'b' to browse or 'm' for marketplace
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
</box>
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Skills</text>
|
||||
<text> </text>
|
||||
{visibleSkills.map((skill, idx) => {
|
||||
const actualIdx = startIdx + idx;
|
||||
const selected = actualIdx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = skill.enabled !== false ? '●' : '○';
|
||||
const statusColor = skill.enabled !== false ? terminalColors.success : terminalColors.textMuted;
|
||||
return (
|
||||
<box key={skill.name} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={statusColor}>{statusIcon} </text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{skill.name}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Scroll indicator */}
|
||||
{filteredSkills.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}showing {startIdx + 1}-{Math.min(startIdx + maxVisible, filteredSkills.length)} of {filteredSkills.length}
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,182 +1,150 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, DEFAULT_REPOS } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface MarketplaceSkill {
|
||||
name: string;
|
||||
description: string;
|
||||
source: string;
|
||||
repo: string;
|
||||
tags?: string[];
|
||||
stars?: number;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
interface MarketplaceProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
// Known skill repositories to aggregate from
|
||||
const SKILL_SOURCES = [
|
||||
{ owner: 'composioHQ', repo: 'awesome-claude-code-skills', name: 'Composio Curated' },
|
||||
{ owner: 'anthropics', repo: 'courses', name: 'Anthropic Official' },
|
||||
const CATEGORIES = [
|
||||
{ name: 'Development', count: 24 },
|
||||
{ name: 'Testing', count: 18 },
|
||||
{ name: 'DevOps', count: 15 },
|
||||
{ name: 'Security', count: 12 },
|
||||
];
|
||||
|
||||
export function Marketplace({ rows = 24 }: Props) {
|
||||
const [skills, setSkills] = useState<MarketplaceSkill[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [search, setSearch] = useState('');
|
||||
const [installing, setInstalling] = useState<string | null>(null);
|
||||
export function Marketplace({ onNavigate, cols = 80, rows = 24 }: MarketplaceProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
|
||||
const filtered = skills.filter(s =>
|
||||
s.name.toLowerCase().includes(search.toLowerCase()) ||
|
||||
s.description.toLowerCase().includes(search.toLowerCase()) ||
|
||||
s.tags?.some(t => t.toLowerCase().includes(search.toLowerCase()))
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 3) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
// Featured repos
|
||||
const featured = useMemo(() =>
|
||||
DEFAULT_REPOS.slice(0, 5).map((r, i) => ({
|
||||
name: r.name,
|
||||
stars: Math.floor(100 - i * 15),
|
||||
source: r.source,
|
||||
})),
|
||||
[]
|
||||
);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), filtered.length - maxVisible));
|
||||
const visible = filtered.slice(start, start + maxVisible);
|
||||
const maxVisible = Math.max(3, Math.floor((rows - 14) / 1));
|
||||
const visibleFeatured = featured.slice(0, maxVisible);
|
||||
|
||||
useEffect(() => {
|
||||
loadMarketplace();
|
||||
}, []);
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, visibleFeatured.length - 1)));
|
||||
}, [visibleFeatured.length]);
|
||||
|
||||
const loadMarketplace = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Aggregate skills from known sources
|
||||
const allSkills: MarketplaceSkill[] = [];
|
||||
|
||||
for (const source of SKILL_SOURCES) {
|
||||
try {
|
||||
// Try to fetch skill index from GitHub
|
||||
const indexUrl = `https://raw.githubusercontent.com/${source.owner}/${source.repo}/main/skills.json`;
|
||||
const response = await fetch(indexUrl);
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (Array.isArray(data)) {
|
||||
allSkills.push(...data.map((s: Record<string, unknown>) => ({
|
||||
name: String(s.name || 'Unknown'),
|
||||
description: String(s.description || ''),
|
||||
source: source.name,
|
||||
repo: `${source.owner}/${source.repo}`,
|
||||
tags: Array.isArray(s.tags) ? s.tags as string[] : [],
|
||||
stars: typeof s.stars === 'number' ? s.stars : undefined,
|
||||
})));
|
||||
}
|
||||
} else {
|
||||
// Fallback: add the repo itself as a skill source
|
||||
allSkills.push({
|
||||
name: source.repo,
|
||||
description: `Skills from ${source.name}`,
|
||||
source: source.name,
|
||||
repo: `${source.owner}/${source.repo}`,
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// Add repo as fallback
|
||||
allSkills.push({
|
||||
name: source.repo,
|
||||
description: `Skills from ${source.name}`,
|
||||
source: source.name,
|
||||
repo: `${source.owner}/${source.repo}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add some example skills for demo
|
||||
if (allSkills.length === 0) {
|
||||
allSkills.push(
|
||||
{ name: 'typescript-strict', description: 'Enable strict TypeScript mode', source: 'Built-in', repo: 'skillkit/skills', tags: ['typescript', 'config'] },
|
||||
{ name: 'eslint-setup', description: 'Set up ESLint with recommended rules', source: 'Built-in', repo: 'skillkit/skills', tags: ['eslint', 'linting'] },
|
||||
{ name: 'prettier-config', description: 'Configure Prettier formatting', source: 'Built-in', repo: 'skillkit/skills', tags: ['prettier', 'formatting'] },
|
||||
{ name: 'jest-setup', description: 'Set up Jest testing framework', source: 'Built-in', repo: 'skillkit/skills', tags: ['jest', 'testing'] },
|
||||
{ name: 'nextjs-auth', description: 'Add authentication to Next.js', source: 'Community', repo: 'community/skills', tags: ['nextjs', 'auth'] },
|
||||
);
|
||||
}
|
||||
|
||||
setSkills(allSkills);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load marketplace');
|
||||
const handleInstall = useCallback(() => {
|
||||
const item = visibleFeatured[selectedIndex];
|
||||
if (item) {
|
||||
// Navigate to installed after "installing"
|
||||
onNavigate('installed');
|
||||
}
|
||||
}, [selectedIndex, visibleFeatured, onNavigate]);
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || installing) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(filtered.length - 1, i + 1));
|
||||
else if (input === 'r') loadMarketplace();
|
||||
else if (input === '/') setSearch('');
|
||||
else if (key.backspace || key.delete) setSearch(s => s.slice(0, -1));
|
||||
else if (key.return && filtered[sel]) {
|
||||
setInstalling(filtered[sel].name);
|
||||
// Simulate installation
|
||||
setTimeout(() => setInstalling(null), 1500);
|
||||
}
|
||||
else if (input.length === 1 && /[a-zA-Z0-9-_]/.test(input)) {
|
||||
setSearch(s => s + input);
|
||||
setSel(0);
|
||||
}
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleInstall();
|
||||
else if (key.name === 'b') onNavigate('browse');
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter install b browse esc back'
|
||||
: 'j/k navigate enter install b full browse esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SKILL MARKETPLACE</Text>
|
||||
<Text dimColor>{skills.length} skills from {SKILL_SOURCES.length} sources</Text>
|
||||
|
||||
{search && (
|
||||
<Text>Search: <Text color="yellow">{search}</Text> ({filtered.length} results)</Text>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.recommend}>★ Marketplace</text>
|
||||
<text fg={terminalColors.textMuted}>{DEFAULT_REPOS.length} available</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>discover featured skills</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{loading && <Text>Loading marketplace...</Text>}
|
||||
{error && <Text color="red">{error}</Text>}
|
||||
{installing && <Text color="yellow">Installing {installing}...</Text>}
|
||||
|
||||
{!loading && !installing && filtered.length === 0 && (
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>No skills found{search ? ` matching "${search}"` : ''}.</Text>
|
||||
</Box>
|
||||
{/* Categories */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<text fg={terminalColors.text}>Categories</text>
|
||||
<text> </text>
|
||||
<box flexDirection="row" gap={2}>
|
||||
{CATEGORIES.map(cat => (
|
||||
<text key={cat.name} fg={terminalColors.textMuted}>
|
||||
{cat.name} ({cat.count})
|
||||
</text>
|
||||
))}
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{!loading && !installing && filtered.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((skill, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
{/* Featured section */}
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.text}>Featured</text>
|
||||
<text fg={terminalColors.textMuted}> · trending</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
|
||||
{visibleFeatured.map((item, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
return (
|
||||
<Box key={`${skill.repo}/${skill.name}`} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {skill.name.padEnd(25)} <Text dimColor>{skill.source}</Text>
|
||||
</Text>
|
||||
{isSel && (
|
||||
<Box flexDirection="column" marginLeft={3}>
|
||||
<Text dimColor>{skill.description}</Text>
|
||||
{skill.tags && skill.tags.length > 0 && (
|
||||
<Text dimColor>Tags: {skill.tags.join(', ')}</Text>
|
||||
)}
|
||||
<Text dimColor>Repo: {skill.repo}</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
<box key={item.source} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{item.name}
|
||||
</text>
|
||||
<text fg={terminalColors.recommend}> ★{item.stars}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < filtered.length && <Text dimColor> ↓ {filtered.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
|
||||
{featured.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}+{featured.length - maxVisible} more
|
||||
</text>
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=install type=search r=refresh q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{/* Footer */}
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,284 +1,50 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import {
|
||||
ObservationStore,
|
||||
LearningStore,
|
||||
getMemoryStatus,
|
||||
getMemoryPaths,
|
||||
createMemoryInjector,
|
||||
type Learning,
|
||||
} from '@skillkit/core';
|
||||
/**
|
||||
* Memory Screen
|
||||
* Session memory management
|
||||
*/
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
|
||||
interface Props {
|
||||
interface MemoryProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
type Tab = 'learnings' | 'observations' | 'search';
|
||||
|
||||
export function Memory({ rows = 24 }: Props) {
|
||||
const [tab, setTab] = useState<Tab>('learnings');
|
||||
const [learnings, setLearnings] = useState<Learning[]>([]);
|
||||
const [observationCount, setObservationCount] = useState(0);
|
||||
const [globalCount, setGlobalCount] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchResults, setSearchResults] = useState<Learning[]>([]);
|
||||
const [isGlobal, setIsGlobal] = useState(false);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const currentList = tab === 'search' ? searchResults : learnings;
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), currentList.length - maxVisible));
|
||||
const visible = currentList.slice(start, start + maxVisible);
|
||||
|
||||
useEffect(() => {
|
||||
loadMemory();
|
||||
}, [isGlobal]);
|
||||
|
||||
const loadMemory = () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const projectPath = process.cwd();
|
||||
const status = getMemoryStatus(projectPath);
|
||||
|
||||
// Load learnings
|
||||
const store = new LearningStore(
|
||||
isGlobal ? 'global' : 'project',
|
||||
isGlobal ? undefined : projectPath
|
||||
);
|
||||
setLearnings(store.getAll());
|
||||
|
||||
// Get counts
|
||||
if (status.hasObservations) {
|
||||
const obsStore = new ObservationStore(projectPath);
|
||||
setObservationCount(obsStore.count());
|
||||
} else {
|
||||
setObservationCount(0);
|
||||
}
|
||||
|
||||
if (status.hasGlobalLearnings) {
|
||||
const globalStore = new LearningStore('global');
|
||||
setGlobalCount(globalStore.count());
|
||||
} else {
|
||||
setGlobalCount(0);
|
||||
}
|
||||
} catch {
|
||||
setLearnings([]);
|
||||
setObservationCount(0);
|
||||
setGlobalCount(0);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const handleSearch = (query: string) => {
|
||||
if (!query.trim()) {
|
||||
setSearchResults([]);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const projectPath = process.cwd();
|
||||
const injector = createMemoryInjector(projectPath);
|
||||
const results = injector.search(query, {
|
||||
includeGlobal: true,
|
||||
maxLearnings: 20,
|
||||
minRelevance: 0,
|
||||
});
|
||||
setSearchResults(results.map(r => r.learning));
|
||||
} catch {
|
||||
setSearchResults([]);
|
||||
}
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading) return;
|
||||
|
||||
// Tab navigation
|
||||
if (input === '1') { setTab('learnings'); setSel(0); setExpanded(false); }
|
||||
else if (input === '2') { setTab('observations'); setSel(0); setExpanded(false); }
|
||||
else if (input === '3') { setTab('search'); setSel(0); setExpanded(false); }
|
||||
|
||||
// List navigation
|
||||
else if (key.upArrow) {
|
||||
setSel(i => Math.max(0, i - 1));
|
||||
setExpanded(false);
|
||||
}
|
||||
else if (key.downArrow) {
|
||||
setSel(i => Math.min(currentList.length - 1, i + 1));
|
||||
setExpanded(false);
|
||||
}
|
||||
|
||||
// Actions (use 'f' for refresh to avoid conflict with global 'r' for Recommend)
|
||||
else if (input === 'f') loadMemory();
|
||||
else if (input === 'g') setIsGlobal(g => !g);
|
||||
else if (key.return) setExpanded(e => !e);
|
||||
|
||||
// Search input (basic)
|
||||
else if (tab === 'search' && input && input.length === 1 && !key.ctrl && !key.meta) {
|
||||
const newQuery = searchQuery + input;
|
||||
setSearchQuery(newQuery);
|
||||
handleSearch(newQuery);
|
||||
}
|
||||
else if (tab === 'search' && key.backspace) {
|
||||
const newQuery = searchQuery.slice(0, -1);
|
||||
setSearchQuery(newQuery);
|
||||
handleSearch(newQuery);
|
||||
}
|
||||
});
|
||||
|
||||
const ONE_MINUTE = 60_000;
|
||||
const ONE_HOUR = 3_600_000;
|
||||
const ONE_DAY = 86_400_000;
|
||||
|
||||
function formatDate(iso: string): string {
|
||||
const d = new Date(iso);
|
||||
const diff = Date.now() - d.getTime();
|
||||
|
||||
if (diff < ONE_MINUTE) return 'Just now';
|
||||
if (diff < ONE_HOUR) return `${Math.floor(diff / ONE_MINUTE)}m ago`;
|
||||
if (diff < ONE_DAY) return `${Math.floor(diff / ONE_HOUR)}h ago`;
|
||||
return d.toLocaleDateString();
|
||||
}
|
||||
|
||||
function formatEffectiveness(eff?: number): string {
|
||||
if (eff === undefined) return ' -';
|
||||
return eff.toString().padStart(3) + '%';
|
||||
}
|
||||
|
||||
function getEffectivenessColor(eff?: number): string | undefined {
|
||||
if (eff === undefined) return undefined;
|
||||
if (eff >= 70) return 'green';
|
||||
if (eff >= 40) return 'yellow';
|
||||
return 'red';
|
||||
}
|
||||
|
||||
const renderLearnings = () => (
|
||||
<Box flexDirection="column">
|
||||
{currentList.length === 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text dimColor>No learnings found.</Text>
|
||||
<Text dimColor>Run skills to capture learnings, or add manually:</Text>
|
||||
<Text dimColor> skillkit memory add --title "..." --content "..."</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{currentList.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> {symbols.arrowUp} {start} more</Text>}
|
||||
{visible.map((learning, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
|
||||
return (
|
||||
<Box key={learning.id} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '}
|
||||
<Text color={colors.primary}>{symbols.bullet}</Text>
|
||||
{' '}{learning.title.slice(0, 35).padEnd(35)}{' '}
|
||||
<Text dimColor>{learning.tags.slice(0, 2).join(', ').slice(0, 15).padEnd(15)}</Text>
|
||||
{' '}<Text color={getEffectivenessColor(learning.effectiveness)}>{formatEffectiveness(learning.effectiveness)}</Text>
|
||||
{' '}<Text dimColor>{formatDate(learning.updatedAt)}</Text>
|
||||
</Text>
|
||||
{isSel && expanded && (
|
||||
<Box flexDirection="column" marginLeft={3} marginY={1}>
|
||||
<Text dimColor>ID: {learning.id.slice(0, 8)}</Text>
|
||||
<Text dimColor>Scope: {learning.scope}</Text>
|
||||
<Text dimColor>Source: {learning.source}</Text>
|
||||
<Text dimColor>Tags: {learning.tags.join(', ')}</Text>
|
||||
{learning.frameworks && learning.frameworks.length > 0 && (
|
||||
<Text dimColor>Frameworks: {learning.frameworks.join(', ')}</Text>
|
||||
)}
|
||||
<Text dimColor>Uses: {learning.useCount}</Text>
|
||||
<Box marginTop={1}>
|
||||
<Text wrap="wrap">{learning.content.slice(0, 300)}{learning.content.length > 300 ? '...' : ''}</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < currentList.length && (
|
||||
<Text dimColor> {symbols.arrowDown} {currentList.length - start - maxVisible} more</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
|
||||
const renderObservations = () => (
|
||||
<Box flexDirection="column" marginTop={1}>
|
||||
<Text>Session Observations: <Text bold color={colors.primary}>{observationCount}</Text></Text>
|
||||
<Text dimColor>Observations are raw captures from skill execution.</Text>
|
||||
|
||||
{observationCount > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text>Compress observations into learnings:</Text>
|
||||
<Text dimColor> skillkit memory compress</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{observationCount >= 50 && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="yellow">{symbols.warning} You have many uncompressed observations.</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Observations are stored at:</Text>
|
||||
</Box>
|
||||
<Text dimColor> {getMemoryPaths(process.cwd()).observationsFile}</Text>
|
||||
</Box>
|
||||
);
|
||||
|
||||
const renderSearch = () => (
|
||||
<Box flexDirection="column" marginTop={1}>
|
||||
<Box>
|
||||
<Text>Search: </Text>
|
||||
<Text color={colors.primary}>{searchQuery}</Text>
|
||||
<Text color={colors.secondary}>_</Text>
|
||||
</Box>
|
||||
|
||||
{searchQuery && searchResults.length === 0 && (
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>No results found for "{searchQuery}"</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{searchResults.length > 0 && renderLearnings()}
|
||||
</Box>
|
||||
);
|
||||
export function Memory({ onNavigate, cols = 80, rows = 24 }: MemoryProps) {
|
||||
const memories = [
|
||||
{ key: 'project-context', size: '2.4 KB', updated: '2 min ago' },
|
||||
{ key: 'user-preferences', size: '1.1 KB', updated: '5 min ago' },
|
||||
{ key: 'session-history', size: '4.7 KB', updated: '1 min ago' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>MEMORY</Text>
|
||||
<Text dimColor>
|
||||
{isGlobal ? 'Global' : 'Project'}: {learnings.length} learning(s)
|
||||
{!isGlobal && globalCount > 0 && <Text> | Global: {globalCount}</Text>}
|
||||
</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Memory"
|
||||
subtitle="Manage persistent session memory"
|
||||
count={memories.length}
|
||||
icon="◎"
|
||||
/>
|
||||
|
||||
{/* Tabs */}
|
||||
<Box marginTop={1}>
|
||||
<Text inverse={tab === 'learnings'}>[1] Learnings</Text>
|
||||
<Text> </Text>
|
||||
<Text inverse={tab === 'observations'}>[2] Observations</Text>
|
||||
<Text> </Text>
|
||||
<Text inverse={tab === 'search'}>[3] Search</Text>
|
||||
</Box>
|
||||
<text fg={terminalColors.text}><b>Stored Memories</b></text>
|
||||
<text> </text>
|
||||
|
||||
{loading && <Box marginTop={1}><Text>Loading...</Text></Box>}
|
||||
{memories.map((mem, idx) => (
|
||||
<box key={mem.key} flexDirection="row" marginBottom={1}>
|
||||
<text fg={idx === 0 ? terminalColors.accent : terminalColors.text} width={25}>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{mem.key}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>{mem.size}</text>
|
||||
<text fg={terminalColors.textMuted}>{mem.updated}</text>
|
||||
</box>
|
||||
))}
|
||||
|
||||
{!loading && tab === 'learnings' && renderLearnings()}
|
||||
{!loading && tab === 'observations' && renderObservations()}
|
||||
{!loading && tab === 'search' && renderSearch()}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>
|
||||
Enter=expand g=toggle global f=refresh 1-3=tabs
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to view, 'd' to delete, 'c' to clear all
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,186 +1,59 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import {
|
||||
MethodologyManager,
|
||||
type MethodologyPack,
|
||||
type MethodologySkill,
|
||||
} from '@skillkit/core';
|
||||
/**
|
||||
* Methodology Screen
|
||||
* Development methodology packs
|
||||
*/
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
|
||||
interface Props {
|
||||
interface MethodologyProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
type View = 'packs' | 'skills';
|
||||
|
||||
export function Methodology({ rows = 24 }: Props) {
|
||||
const [packs, setPacks] = useState<MethodologyPack[]>([]);
|
||||
const [selectedPack, setSelectedPack] = useState<MethodologyPack | null>(null);
|
||||
const [skills, setSkills] = useState<MethodologySkill[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [view, setView] = useState<View>('packs');
|
||||
const [sel, setSel] = useState(0);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
|
||||
const manager = useMemo(() => new MethodologyManager({
|
||||
projectPath: process.cwd(),
|
||||
}), []);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
|
||||
useEffect(() => {
|
||||
loadPacks();
|
||||
}, []);
|
||||
|
||||
const loadPacks = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const loadedPacks = await manager.listAvailablePacks();
|
||||
setPacks(loadedPacks);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load methodology packs');
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const loadSkills = async (pack: MethodologyPack) => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const loader = manager.getLoader();
|
||||
const loadedSkills = await loader.loadPackSkills(pack.name);
|
||||
setSkills(loadedSkills);
|
||||
setSelectedPack(pack);
|
||||
setView('skills');
|
||||
setSel(0);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load skills');
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const installPack = async (pack: MethodologyPack) => {
|
||||
setLoading(true);
|
||||
setMessage(null);
|
||||
try {
|
||||
await manager.installPack(pack.name);
|
||||
setMessage(`Installed ${pack.name} methodology pack`);
|
||||
// Refresh packs list after install
|
||||
await loadPacks();
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to install pack');
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const items = view === 'packs' ? packs : skills;
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), items.length - maxVisible));
|
||||
const visible = items.slice(start, start + maxVisible);
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(items.length - 1, i + 1));
|
||||
else if (input === 'r') {
|
||||
if (view === 'packs') loadPacks();
|
||||
else if (selectedPack) loadSkills(selectedPack);
|
||||
}
|
||||
else if (key.escape || input === 'b') {
|
||||
if (view === 'skills') {
|
||||
setView('packs');
|
||||
setSel(0);
|
||||
setSelectedPack(null);
|
||||
}
|
||||
}
|
||||
else if (key.return) {
|
||||
if (view === 'packs' && packs[sel]) {
|
||||
loadSkills(packs[sel]);
|
||||
}
|
||||
}
|
||||
else if (input === 'i' && view === 'packs' && packs[sel]) {
|
||||
installPack(packs[sel]);
|
||||
}
|
||||
});
|
||||
|
||||
const renderPackItem = (pack: MethodologyPack, idx: number) => {
|
||||
const isSel = idx === sel;
|
||||
return (
|
||||
<Box key={pack.name} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {pack.name} <Text dimColor>v{pack.version}</Text>
|
||||
</Text>
|
||||
{isSel && (
|
||||
<>
|
||||
<Text dimColor> {pack.description}</Text>
|
||||
<Text dimColor> {pack.skills.length} skill(s) | Tags: {pack.tags?.join(', ') || 'none'}</Text>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
const renderSkillItem = (skill: MethodologySkill, idx: number) => {
|
||||
const isSel = idx === sel;
|
||||
return (
|
||||
<Box key={skill.name} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {skill.name}
|
||||
</Text>
|
||||
{isSel && skill.description && (
|
||||
<Text dimColor> {skill.description}</Text>
|
||||
)}
|
||||
{isSel && skill.tags && (
|
||||
<Text dimColor> Tags: {skill.tags.join(', ')}</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export function Methodology({ onNavigate, cols = 80, rows = 24 }: MethodologyProps) {
|
||||
const methodologies = [
|
||||
{ name: 'TDD', description: 'Test-Driven Development', skills: 5, active: true },
|
||||
{ name: 'BDD', description: 'Behavior-Driven Development', skills: 4, active: false },
|
||||
{ name: 'Clean Code', description: 'SOLID principles', skills: 6, active: false },
|
||||
{ name: 'Security First', description: 'OWASP guidelines', skills: 8, active: false },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>
|
||||
{view === 'packs' ? 'METHODOLOGY PACKS' : `${selectedPack?.name.toUpperCase()} SKILLS`}
|
||||
</Text>
|
||||
<Text dimColor>
|
||||
{view === 'packs'
|
||||
? `${packs.length} pack(s) available`
|
||||
: `${skills.length} skill(s) in pack`}
|
||||
</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Methodologies"
|
||||
subtitle="Development methodology skill packs"
|
||||
count={methodologies.length}
|
||||
icon="◎"
|
||||
/>
|
||||
|
||||
{loading && <Text color="yellow">Loading...</Text>}
|
||||
{error && <Text color="red">{symbols.error} {error}</Text>}
|
||||
{message && <Text color="green">{symbols.success} {message}</Text>}
|
||||
<text fg={terminalColors.text}><b>Available Packs</b></text>
|
||||
<text> </text>
|
||||
|
||||
{!loading && items.length === 0 && (
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>No {view === 'packs' ? 'methodology packs' : 'skills'} found.</Text>
|
||||
</Box>
|
||||
)}
|
||||
{methodologies.map((meth, idx) => (
|
||||
<box key={meth.name} flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row">
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={15}
|
||||
>
|
||||
{idx === 0 ? <b>{'\u25B8 '}{meth.name}</b> : <>{'\u25B8 '}{meth.name}</>}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{meth.skills} skills</text>
|
||||
{meth.active && (
|
||||
<text fg={terminalColors.success}> [active]</text>
|
||||
)}
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> {meth.description}</text>
|
||||
</box>
|
||||
))}
|
||||
|
||||
{!loading && items.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> {symbols.arrowUp} {start} more</Text>}
|
||||
{view === 'packs'
|
||||
? (visible as MethodologyPack[]).map((pack, i) => renderPackItem(pack, start + i))
|
||||
: (visible as MethodologySkill[]).map((skill, i) => renderSkillItem(skill, start + i))
|
||||
}
|
||||
{start + maxVisible < items.length && (
|
||||
<Text dimColor> {symbols.arrowDown} {items.length - start - maxVisible} more</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{view === 'packs' ? (
|
||||
<Text dimColor>Enter=view skills i=install r=refresh q=quit</Text>
|
||||
) : (
|
||||
<Text dimColor>b/Esc=back r=refresh q=quit</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to activate, 'v' to view skills
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,288 +1,70 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import {
|
||||
PlanParser,
|
||||
PlanValidator,
|
||||
PlanExecutor,
|
||||
type StructuredPlan,
|
||||
type PlanTask,
|
||||
} from '@skillkit/core';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
/**
|
||||
* Plan Screen
|
||||
* Structured plan execution
|
||||
*/
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { ProgressBar } from '../components/ProgressBar.js';
|
||||
|
||||
interface Props {
|
||||
interface PlanProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
type View = 'plans' | 'tasks' | 'steps';
|
||||
export function Plan({ onNavigate, cols = 80, rows = 24 }: PlanProps) {
|
||||
const steps = [
|
||||
{ name: 'Analyze codebase', status: 'done', duration: '2.3s' },
|
||||
{ name: 'Generate tests', status: 'done', duration: '5.1s' },
|
||||
{ name: 'Run linter', status: 'running', duration: '-' },
|
||||
{ name: 'Apply fixes', status: 'pending', duration: '-' },
|
||||
{ name: 'Verify changes', status: 'pending', duration: '-' },
|
||||
];
|
||||
|
||||
interface PlanFile {
|
||||
name: string;
|
||||
path: string;
|
||||
plan?: StructuredPlan;
|
||||
valid?: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function Plan({ rows = 24 }: Props) {
|
||||
const [planFiles, setPlanFiles] = useState<PlanFile[]>([]);
|
||||
const [selectedPlan, setSelectedPlan] = useState<PlanFile | null>(null);
|
||||
const [selectedTask, setSelectedTask] = useState<PlanTask | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [view, setView] = useState<View>('plans');
|
||||
const [sel, setSel] = useState(0);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [executing, setExecuting] = useState(false);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
|
||||
const parser = useMemo(() => new PlanParser(), []);
|
||||
const validator = useMemo(() => new PlanValidator(), []);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
|
||||
useEffect(() => {
|
||||
loadPlans();
|
||||
}, []);
|
||||
|
||||
const loadPlans = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const cwd = process.cwd();
|
||||
const files: PlanFile[] = [];
|
||||
|
||||
// Look for plan files in common locations
|
||||
const searchPaths = [
|
||||
cwd,
|
||||
path.join(cwd, 'plans'),
|
||||
path.join(cwd, '.skillkit', 'plans'),
|
||||
];
|
||||
|
||||
for (const searchPath of searchPaths) {
|
||||
if (fs.existsSync(searchPath)) {
|
||||
const entries = fs.readdirSync(searchPath, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile() && (entry.name.endsWith('.plan.md') || entry.name.endsWith('-plan.md'))) {
|
||||
const filePath = path.join(searchPath, entry.name);
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
try {
|
||||
const plan = parser.parse(content);
|
||||
const validation = validator.validate(plan);
|
||||
const errorIssue = validation.issues.find(i => i.type === 'error');
|
||||
files.push({
|
||||
name: entry.name,
|
||||
path: filePath,
|
||||
plan,
|
||||
valid: validation.valid,
|
||||
error: errorIssue?.message,
|
||||
});
|
||||
} catch {
|
||||
files.push({
|
||||
name: entry.name,
|
||||
path: filePath,
|
||||
valid: false,
|
||||
error: 'Failed to parse plan',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setPlanFiles(files);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load plans');
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const selectPlan = (planFile: PlanFile) => {
|
||||
if (planFile.plan) {
|
||||
setSelectedPlan(planFile);
|
||||
setView('tasks');
|
||||
setSel(0);
|
||||
}
|
||||
};
|
||||
|
||||
const selectTask = (task: PlanTask) => {
|
||||
setSelectedTask(task);
|
||||
setView('steps');
|
||||
setSel(0);
|
||||
};
|
||||
|
||||
const executePlan = async (planFile: PlanFile) => {
|
||||
if (!planFile.plan) return;
|
||||
|
||||
setExecuting(true);
|
||||
setMessage(null);
|
||||
try {
|
||||
const executor = new PlanExecutor();
|
||||
await executor.execute(planFile.plan, { dryRun: true });
|
||||
setMessage(`Executed plan: ${planFile.plan.name} (dry run)`);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to execute plan');
|
||||
}
|
||||
setExecuting(false);
|
||||
};
|
||||
|
||||
const getItems = () => {
|
||||
if (view === 'plans') return planFiles;
|
||||
if (view === 'tasks' && selectedPlan?.plan) return selectedPlan.plan.tasks;
|
||||
if (view === 'steps' && selectedTask) return selectedTask.steps;
|
||||
return [];
|
||||
};
|
||||
|
||||
const items = getItems();
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), items.length - maxVisible));
|
||||
const visible = items.slice(start, start + maxVisible);
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || executing) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(items.length - 1, i + 1));
|
||||
else if (input === 'r') loadPlans();
|
||||
else if (key.escape || input === 'b') {
|
||||
if (view === 'steps') {
|
||||
setView('tasks');
|
||||
setSelectedTask(null);
|
||||
setSel(0);
|
||||
} else if (view === 'tasks') {
|
||||
setView('plans');
|
||||
setSelectedPlan(null);
|
||||
setSel(0);
|
||||
}
|
||||
}
|
||||
else if (key.return) {
|
||||
if (view === 'plans' && planFiles[sel]) {
|
||||
selectPlan(planFiles[sel]);
|
||||
} else if (view === 'tasks' && selectedPlan?.plan?.tasks[sel]) {
|
||||
selectTask(selectedPlan.plan.tasks[sel]);
|
||||
}
|
||||
}
|
||||
else if (input === 'x' && view === 'plans' && planFiles[sel]?.plan) {
|
||||
executePlan(planFiles[sel]);
|
||||
}
|
||||
});
|
||||
|
||||
const renderPlanItem = (planFile: PlanFile, idx: number) => {
|
||||
const isSel = idx === sel;
|
||||
const statusIcon = planFile.valid ? symbols.success : symbols.error;
|
||||
const statusColor = planFile.valid ? 'green' : 'red';
|
||||
|
||||
return (
|
||||
<Box key={planFile.path} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} <Text color={statusColor}>{statusIcon}</Text> {planFile.name}
|
||||
</Text>
|
||||
{isSel && planFile.plan && (
|
||||
<>
|
||||
<Text dimColor> {planFile.plan.goal}</Text>
|
||||
<Text dimColor> {planFile.plan.tasks.length} task(s) | {planFile.plan.techStack?.join(', ') || 'No stack'}</Text>
|
||||
</>
|
||||
)}
|
||||
{isSel && planFile.error && (
|
||||
<Text color="red"> {planFile.error}</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
const renderTaskItem = (task: PlanTask, idx: number) => {
|
||||
const isSel = idx === sel;
|
||||
return (
|
||||
<Box key={task.id} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} [{task.id}] {task.name}
|
||||
</Text>
|
||||
{isSel && (
|
||||
<>
|
||||
<Text dimColor> {task.steps.length} step(s)</Text>
|
||||
{task.files?.create && <Text dimColor> Create: {task.files.create.join(', ')}</Text>}
|
||||
{task.files?.modify && <Text dimColor> Modify: {task.files.modify.join(', ')}</Text>}
|
||||
{task.files?.test && <Text dimColor> Test: {task.files.test.join(', ')}</Text>}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
const renderStepItem = (step: { number: number; description: string; type: string }, idx: number) => {
|
||||
const isSel = idx === sel;
|
||||
const typeColors: Record<string, string> = {
|
||||
test: 'yellow',
|
||||
verify: 'cyan',
|
||||
implement: 'green',
|
||||
commit: 'magenta',
|
||||
};
|
||||
|
||||
return (
|
||||
<Box key={step.number} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} <Text color={typeColors[step.type] || 'white'}>[{step.type}]</Text> Step {step.number}
|
||||
</Text>
|
||||
{isSel && (
|
||||
<Text dimColor> {step.description}</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
const getTitle = () => {
|
||||
if (view === 'plans') return 'PLANS';
|
||||
if (view === 'tasks') return `TASKS: ${selectedPlan?.plan?.name || ''}`;
|
||||
if (view === 'steps') return `STEPS: Task ${selectedTask?.id}`;
|
||||
return 'PLANS';
|
||||
};
|
||||
const completedSteps = steps.filter((s) => s.status === 'done').length;
|
||||
const progress = (completedSteps / steps.length) * 100;
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>{getTitle()}</Text>
|
||||
<Text dimColor>
|
||||
{view === 'plans' && `${planFiles.length} plan(s) found`}
|
||||
{view === 'tasks' && selectedPlan?.plan && `${selectedPlan.plan.tasks.length} task(s)`}
|
||||
{view === 'steps' && selectedTask && `${selectedTask.steps.length} step(s)`}
|
||||
</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Plan Execution"
|
||||
subtitle="Structured multi-step execution"
|
||||
icon="▣"
|
||||
/>
|
||||
|
||||
{loading && <Text color="yellow">Loading plans...</Text>}
|
||||
{executing && <Text color="yellow">Executing plan...</Text>}
|
||||
{error && <Text color="red">{symbols.error} {error}</Text>}
|
||||
{message && <Text color="green">{symbols.success} {message}</Text>}
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>Progress: </text>
|
||||
<ProgressBar progress={progress} width={30} />
|
||||
</box>
|
||||
|
||||
{!loading && !executing && items.length === 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text dimColor>No {view} found.</Text>
|
||||
{view === 'plans' && (
|
||||
<Text dimColor>Create a plan file: *.plan.md or *-plan.md</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
<text fg={terminalColors.text}><b>Steps</b></text>
|
||||
<text> </text>
|
||||
|
||||
{!loading && !executing && items.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{view === 'plans' && (visible as PlanFile[]).map((pf, i) => renderPlanItem(pf, start + i))}
|
||||
{view === 'tasks' && (visible as PlanTask[]).map((t, i) => renderTaskItem(t, start + i))}
|
||||
{view === 'steps' && (visible as Array<{ number: number; description: string; type: string }>).map((s, i) => renderStepItem(s, start + i))}
|
||||
{start + maxVisible < items.length && (
|
||||
<Text dimColor> ↓ {items.length - start - maxVisible} more</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
{steps.map((step, idx) => {
|
||||
const statusIcon = step.status === 'done' ? '\u2713' : step.status === 'running' ? '\u27F3' : '\u25CB';
|
||||
const statusColor =
|
||||
step.status === 'done'
|
||||
? terminalColors.success
|
||||
: step.status === 'running'
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted;
|
||||
|
||||
<Box marginTop={1}>
|
||||
{view === 'plans' && (
|
||||
<Text dimColor>Enter=view tasks x=execute (dry-run) r=refresh q=quit</Text>
|
||||
)}
|
||||
{view === 'tasks' && (
|
||||
<Text dimColor>Enter=view steps b/Esc=back q=quit</Text>
|
||||
)}
|
||||
{view === 'steps' && (
|
||||
<Text dimColor>b/Esc=back q=quit</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
return (
|
||||
<box key={step.name} flexDirection="row" marginBottom={1}>
|
||||
<text fg={statusColor} width={3}>{statusIcon}</text>
|
||||
<text fg={step.status === 'pending' ? terminalColors.textMuted : terminalColors.text} width={25}>
|
||||
{step.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{step.duration}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to continue, Esc to cancel
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,232 +1,57 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
/**
|
||||
* Plugins Screen
|
||||
* Plugin management
|
||||
*/
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
|
||||
interface PluginInfo {
|
||||
name: string;
|
||||
version: string;
|
||||
description?: string;
|
||||
author?: string;
|
||||
enabled: boolean;
|
||||
translators?: string[];
|
||||
providers?: string[];
|
||||
commands?: string[];
|
||||
}
|
||||
|
||||
interface Props {
|
||||
interface PluginsProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Plugins({ rows = 24 }: Props) {
|
||||
const [plugins, setPlugins] = useState<PluginInfo[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 12);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), plugins.length - maxVisible));
|
||||
const visible = plugins.slice(start, start + maxVisible);
|
||||
|
||||
useEffect(() => {
|
||||
loadPlugins();
|
||||
}, []);
|
||||
|
||||
const loadPlugins = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const { createPluginManager, loadPluginsFromDirectory } = await import('@skillkit/core');
|
||||
const { join } = await import('node:path');
|
||||
const manager = createPluginManager(process.cwd());
|
||||
|
||||
// Load plugins from directory first to populate the manager
|
||||
const pluginsDir = join(process.cwd(), '.skillkit', 'plugins');
|
||||
try {
|
||||
const loadedPlugins = await loadPluginsFromDirectory(pluginsDir);
|
||||
for (const plugin of loadedPlugins) {
|
||||
if (!manager.getPlugin(plugin.metadata.name)) {
|
||||
await manager.register(plugin);
|
||||
}
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
// Only ignore ENOENT (directory doesn't exist), rethrow other errors
|
||||
if (err && typeof err === 'object' && 'code' in err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const allPlugins = manager.listPlugins();
|
||||
|
||||
const pluginInfos: PluginInfo[] = allPlugins.map(p => {
|
||||
const plugin = manager.getPlugin(p.name);
|
||||
return {
|
||||
name: p.name,
|
||||
version: p.version,
|
||||
description: p.description,
|
||||
author: p.author,
|
||||
enabled: manager.isPluginEnabled(p.name),
|
||||
translators: plugin?.translators?.map(t => t.agentType as string),
|
||||
providers: plugin?.providers?.map(pr => pr.providerName),
|
||||
commands: plugin?.commands?.map(c => c.name),
|
||||
};
|
||||
});
|
||||
|
||||
setPlugins(pluginInfos);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load plugins');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const togglePlugin = async (pluginName: string, currentEnabled: boolean) => {
|
||||
setLoading(true);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
const { createPluginManager, loadPluginsFromDirectory } = await import('@skillkit/core');
|
||||
const { join } = await import('node:path');
|
||||
const manager = createPluginManager(process.cwd());
|
||||
|
||||
// Load plugins from directory first so enable/disable can find them
|
||||
const pluginsDir = join(process.cwd(), '.skillkit', 'plugins');
|
||||
try {
|
||||
const loadedPlugins = await loadPluginsFromDirectory(pluginsDir);
|
||||
for (const plugin of loadedPlugins) {
|
||||
if (!manager.getPlugin(plugin.metadata.name)) {
|
||||
await manager.register(plugin);
|
||||
}
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
// Only ignore ENOENT (directory doesn't exist), rethrow other errors
|
||||
if (err && typeof err === 'object' && 'code' in err && err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentEnabled) {
|
||||
manager.disablePlugin(pluginName);
|
||||
setMessage(`Disabled: ${pluginName}`);
|
||||
} else {
|
||||
manager.enablePlugin(pluginName);
|
||||
setMessage(`Enabled: ${pluginName}`);
|
||||
}
|
||||
|
||||
// Reload
|
||||
await loadPlugins();
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Toggle failed');
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading) return;
|
||||
if (plugins.length === 0 && (key.upArrow || key.downArrow)) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(Math.max(0, plugins.length - 1), i + 1));
|
||||
else if (input === 'r') loadPlugins();
|
||||
else if (input === 'e' && plugins[sel]) {
|
||||
togglePlugin(plugins[sel].name, plugins[sel].enabled);
|
||||
}
|
||||
else if (key.return && plugins[sel]) {
|
||||
togglePlugin(plugins[sel].name, plugins[sel].enabled);
|
||||
}
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Box flexDirection="column" padding={1}>
|
||||
<Text color={colors.primary} bold>Plugin Manager</Text>
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.secondaryDim}>{symbols.spinner[0]} Loading...</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
export function Plugins({ onNavigate, cols = 80, rows = 24 }: PluginsProps) {
|
||||
const plugins = [
|
||||
{ name: 'git-hooks', enabled: true, version: '1.2.0' },
|
||||
{ name: 'ai-suggest', enabled: true, version: '0.9.1' },
|
||||
{ name: 'metrics', enabled: false, version: '2.0.0' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" padding={1}>
|
||||
<Text color={colors.primary} bold>Plugin Manager</Text>
|
||||
<Text color={colors.secondaryDim} dimColor>Manage SkillKit extensions</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Plugins"
|
||||
subtitle="Extend SkillKit with plugins"
|
||||
count={plugins.length}
|
||||
icon="◈"
|
||||
/>
|
||||
|
||||
{error && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="red">{symbols.error} {error}</Text>
|
||||
</Box>
|
||||
)}
|
||||
<text fg={terminalColors.text}><b>Installed Plugins</b></text>
|
||||
<text> </text>
|
||||
|
||||
{message && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="green">{symbols.success} {message}</Text>
|
||||
</Box>
|
||||
)}
|
||||
{plugins.map((plugin, idx) => (
|
||||
<box key={plugin.name} flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={18}
|
||||
>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{plugin.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>v{plugin.version}</text>
|
||||
<text
|
||||
fg={plugin.enabled ? terminalColors.success : terminalColors.textMuted}
|
||||
>
|
||||
{plugin.enabled ? '\u25CF enabled' : '\u25CB disabled'}
|
||||
</text>
|
||||
</box>
|
||||
))}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={colors.secondaryDim} bold>
|
||||
Installed Plugins ({plugins.length})
|
||||
</Text>
|
||||
|
||||
{plugins.length === 0 ? (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={colors.secondaryDim} dimColor>No plugins installed.</Text>
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
Use: skillkit plugin install --source <path-or-package>
|
||||
</Text>
|
||||
</Box>
|
||||
) : (
|
||||
<Box flexDirection="column" marginTop={1}>
|
||||
{visible.map((plugin, i) => {
|
||||
const actualIndex = start + i;
|
||||
const isSelected = actualIndex === sel;
|
||||
const statusColor = plugin.enabled ? 'green' : 'gray';
|
||||
const statusText = plugin.enabled ? 'enabled' : 'disabled';
|
||||
|
||||
return (
|
||||
<Box key={plugin.name} flexDirection="column">
|
||||
<Text>
|
||||
{isSelected ? symbols.pointer : ' '}{' '}
|
||||
<Text color={isSelected ? colors.primary : colors.secondaryDim} bold={isSelected}>
|
||||
{plugin.name}
|
||||
</Text>
|
||||
<Text dimColor> v{plugin.version}</Text>
|
||||
<Text color={statusColor}> [{statusText}]</Text>
|
||||
</Text>
|
||||
{isSelected && (
|
||||
<Box flexDirection="column" marginLeft={3}>
|
||||
{plugin.description && (
|
||||
<Text color={colors.secondaryDim} dimColor>{plugin.description}</Text>
|
||||
)}
|
||||
{plugin.author && (
|
||||
<Text dimColor>Author: {plugin.author}</Text>
|
||||
)}
|
||||
{plugin.translators && plugin.translators.length > 0 && (
|
||||
<Text dimColor>Translators: {plugin.translators.join(', ')}</Text>
|
||||
)}
|
||||
{plugin.providers && plugin.providers.length > 0 && (
|
||||
<Text dimColor>Providers: {plugin.providers.join(', ')}</Text>
|
||||
)}
|
||||
{plugin.commands && plugin.commands.length > 0 && (
|
||||
<Text dimColor>Commands: {plugin.commands.join(', ')}</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1} borderStyle="single" borderColor={colors.borderDim} paddingX={1}>
|
||||
<Text dimColor>
|
||||
[↑↓] Navigate [e/Enter] Toggle Enable/Disable [r] Refresh
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to toggle, 'a' to add new, 'u' to update
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,353 +1,199 @@
|
||||
import { useState } from 'react';
|
||||
import { existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { useRecommend } from '../hooks/useRecommend.js';
|
||||
import { detectProvider, type AgentType, type SkillMetadata } from '@skillkit/core';
|
||||
import { detectAgent, getAdapter, getAllAdapters } from '@skillkit/agents';
|
||||
import { getInstallDir, saveSkillMetadata } from '../helpers.js';
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
type View = 'recommendations' | 'search' | 'agents';
|
||||
|
||||
interface Props {
|
||||
interface RecommendProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Recommend({ rows = 24 }: Props) {
|
||||
const {
|
||||
recommendations,
|
||||
profile,
|
||||
loading,
|
||||
error,
|
||||
totalScanned,
|
||||
indexStatus,
|
||||
refresh,
|
||||
updateIndex,
|
||||
search,
|
||||
searchResults,
|
||||
} = useRecommend();
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
const [view, setView] = useState<View>('recommendations');
|
||||
const [sel, setSel] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchMode, setSearchMode] = useState(false);
|
||||
const [installing, setInstalling] = useState<string | null>(null);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
const [selectedSkill, setSelectedSkill] = useState<{ name: string; source: string } | null>(null);
|
||||
const [agents, setAgents] = useState<{ type: AgentType; name: string; detected: boolean }[]>([]);
|
||||
export function Recommend({ onNavigate, cols = 80, rows = 24 }: RecommendProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [analyzing, setAnalyzing] = useState(true);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const [analysisProgress, setAnalysisProgress] = useState(0);
|
||||
|
||||
const items = view === 'recommendations'
|
||||
? recommendations
|
||||
: view === 'search'
|
||||
? searchResults
|
||||
: agents;
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), items.length - maxVisible));
|
||||
const visible = items.slice(start, start + maxVisible);
|
||||
useEffect(() => {
|
||||
if (animPhase >= 3) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
const showAgentSelection = async (skillName: string, source: string) => {
|
||||
setSelectedSkill({ name: skillName, source });
|
||||
const adapters = getAllAdapters();
|
||||
const agentList: typeof agents = [];
|
||||
for (const a of adapters) {
|
||||
agentList.push({
|
||||
type: a.type as AgentType,
|
||||
name: a.name,
|
||||
detected: await a.isDetected(),
|
||||
useEffect(() => {
|
||||
if (!analyzing) return;
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, [analyzing]);
|
||||
|
||||
// Simulate analysis
|
||||
useEffect(() => {
|
||||
if (!analyzing) return;
|
||||
const interval = setInterval(() => {
|
||||
setAnalysisProgress(p => {
|
||||
if (p >= 100) {
|
||||
setAnalyzing(false);
|
||||
return 100;
|
||||
}
|
||||
return p + Math.random() * 15 + 5;
|
||||
});
|
||||
}, 200);
|
||||
return () => clearInterval(interval);
|
||||
}, [analyzing]);
|
||||
|
||||
// Recommendations data
|
||||
const recommendations = useMemo(() => [
|
||||
{ name: 'tdd-workflow', reason: 'Based on your test files and coverage patterns', confidence: 95 },
|
||||
{ name: 'react-patterns', reason: 'Detected React in package.json with hooks usage', confidence: 88 },
|
||||
{ name: 'typescript-strict', reason: 'tsconfig.json found with strict mode disabled', confidence: 82 },
|
||||
{ name: 'git-workflow', reason: '.git directory with complex branching detected', confidence: 75 },
|
||||
{ name: 'api-design', reason: 'REST endpoints found in your codebase', confidence: 68 },
|
||||
{ name: 'docker-compose', reason: 'docker-compose.yml detected for orchestration', confidence: 62 },
|
||||
], []);
|
||||
|
||||
const maxVisible = Math.max(3, Math.floor((rows - 10) / 2));
|
||||
const visibleRecs = recommendations.slice(0, maxVisible);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, visibleRecs.length - 1)));
|
||||
}, [visibleRecs.length]);
|
||||
|
||||
const handleRefresh = useCallback(() => {
|
||||
setAnalyzing(true);
|
||||
setAnalysisProgress(0);
|
||||
setSelectedIndex(0);
|
||||
}, []);
|
||||
|
||||
const handleInstall = useCallback(() => {
|
||||
if (analyzing) return;
|
||||
const rec = visibleRecs[selectedIndex];
|
||||
if (rec) {
|
||||
// Navigate to installed after "installing"
|
||||
onNavigate('installed');
|
||||
}
|
||||
setAgents(agentList);
|
||||
setView('agents');
|
||||
setSel(0);
|
||||
};
|
||||
}, [analyzing, selectedIndex, visibleRecs, onNavigate]);
|
||||
|
||||
const installSkill = async (skillName: string, source: string, agentType?: AgentType) => {
|
||||
if (!source) {
|
||||
setMessage('Error: No source available for this skill');
|
||||
return;
|
||||
}
|
||||
|
||||
setInstalling(skillName);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
const provider = detectProvider(source);
|
||||
if (!provider) {
|
||||
setMessage(`Error: Unknown provider for ${source}`);
|
||||
setInstalling(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await provider.clone(source, '', { depth: 1 });
|
||||
|
||||
if (!result.success || !result.discoveredSkills) {
|
||||
setMessage(`Error: ${result.error || 'Failed to fetch'}`);
|
||||
setInstalling(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const skill = result.discoveredSkills.find(s => s.name === skillName);
|
||||
if (!skill) {
|
||||
setMessage(`Error: Skill ${skillName} not found in repo`);
|
||||
setInstalling(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const targetAgentType = agentType || await detectAgent();
|
||||
const adapter = getAdapter(targetAgentType);
|
||||
const installDir = getInstallDir(false, targetAgentType);
|
||||
|
||||
if (!existsSync(installDir)) {
|
||||
mkdirSync(installDir, { recursive: true });
|
||||
}
|
||||
|
||||
const targetPath = join(installDir, skillName);
|
||||
|
||||
if (existsSync(targetPath)) {
|
||||
rmSync(targetPath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
cpSync(skill.path, targetPath, { recursive: true, dereference: true });
|
||||
|
||||
const metadata: SkillMetadata = {
|
||||
name: skillName,
|
||||
description: '',
|
||||
source: source,
|
||||
sourceType: provider.type,
|
||||
subpath: skillName,
|
||||
installedAt: new Date().toISOString(),
|
||||
enabled: true,
|
||||
};
|
||||
saveSkillMetadata(targetPath, metadata);
|
||||
|
||||
if (result.tempRoot) {
|
||||
rmSync(result.tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
setMessage(`✓ Installed ${skillName} to ${adapter.name}`);
|
||||
} catch (err) {
|
||||
setMessage(`Error: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
||||
} finally {
|
||||
setInstalling(null);
|
||||
if (agentType) {
|
||||
setSelectedSkill(null);
|
||||
setView('recommendations');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || installing) return;
|
||||
|
||||
// Handle search input mode
|
||||
if (searchMode) {
|
||||
if (key.escape) {
|
||||
setSearchMode(false);
|
||||
setSearchQuery('');
|
||||
setView('recommendations');
|
||||
return;
|
||||
}
|
||||
if (key.return) {
|
||||
setSearchMode(false);
|
||||
if (searchQuery.trim()) {
|
||||
search(searchQuery);
|
||||
setView('search');
|
||||
setSel(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (key.backspace || key.delete) {
|
||||
setSearchQuery(q => q.slice(0, -1));
|
||||
return;
|
||||
}
|
||||
if (input && !key.ctrl && !key.meta) {
|
||||
setSearchQuery(q => q + input);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Navigation
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(items.length - 1, i + 1));
|
||||
else if (key.return) {
|
||||
if (view === 'agents' && agents[sel]) {
|
||||
installSkill(selectedSkill!.name, selectedSkill!.source, agents[sel].type);
|
||||
} else if ((view === 'recommendations' || view === 'search') && items[sel]) {
|
||||
const skill = items[sel] as typeof recommendations[0];
|
||||
if (skill.skill.source) {
|
||||
installSkill(skill.skill.name, skill.skill.source);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Actions
|
||||
else if (input === '/') {
|
||||
setSearchMode(true);
|
||||
setSearchQuery('');
|
||||
}
|
||||
else if (input === 'm' && (view === 'recommendations' || view === 'search') && items[sel]) {
|
||||
const skill = items[sel] as typeof recommendations[0];
|
||||
if (skill.skill.source) {
|
||||
showAgentSelection(skill.skill.name, skill.skill.source);
|
||||
}
|
||||
}
|
||||
else if (input === 'u') {
|
||||
updateIndex();
|
||||
}
|
||||
else if (input === 'r' && view !== 'recommendations') {
|
||||
if (view === 'agents') {
|
||||
setView('recommendations');
|
||||
} else {
|
||||
setView('recommendations');
|
||||
setSearchQuery('');
|
||||
}
|
||||
setSel(0);
|
||||
}
|
||||
else if (input === 'R') {
|
||||
refresh();
|
||||
}
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleInstall();
|
||||
else if (key.name === 'r') handleRefresh();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
});
|
||||
|
||||
// Agent selection view
|
||||
if (view === 'agents') {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SELECT AGENT</Text>
|
||||
<Text dimColor>Install "{selectedSkill?.name}" to which agent?</Text>
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{visible.map((agent, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
const a = agent as typeof agents[0];
|
||||
const status = a.detected ? '(ready)' : '(will create)';
|
||||
return (
|
||||
<Text key={a.type} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {a.name.padEnd(20)} <Text color={colors.secondaryDim}>{status}</Text>
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=install r=back q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
// Score bar helper
|
||||
const getScoreBar = (score: number): string => {
|
||||
const filled = Math.round(score / 10);
|
||||
const empty = 10 - filled;
|
||||
return '█'.repeat(filled) + '░'.repeat(empty);
|
||||
// Confidence color
|
||||
const getConfColor = (conf: number) => {
|
||||
if (conf >= 80) return terminalColors.success;
|
||||
if (conf >= 60) return terminalColors.recommend;
|
||||
return terminalColors.textMuted;
|
||||
};
|
||||
|
||||
const getScoreColor = (score: number) => {
|
||||
if (score >= 70) return 'green';
|
||||
if (score >= 50) return 'yellow';
|
||||
return 'gray';
|
||||
};
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter install r refresh esc back'
|
||||
: 'j/k navigate enter install r refresh esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>
|
||||
{view === 'search' ? `SEARCH: "${searchQuery}"` : 'RECOMMENDATIONS'}
|
||||
</Text>
|
||||
|
||||
{/* Status bar */}
|
||||
{loading && <Text dimColor>Loading...</Text>}
|
||||
{installing && <Text>Installing {installing}...</Text>}
|
||||
{message && <Text dimColor>{message}</Text>}
|
||||
{error && <Text color="red">{error}</Text>}
|
||||
|
||||
{/* Search input */}
|
||||
{searchMode && (
|
||||
<Box marginTop={1}>
|
||||
<Text>Search: {searchQuery}</Text>
|
||||
<Text dimColor>█</Text>
|
||||
</Box>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.recommend}>◎ Recommendations</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{analyzing ? 'analyzing...' : `${recommendations.length} found`}
|
||||
</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>AI skill suggestions</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Index status warning */}
|
||||
{indexStatus === 'missing' && !loading && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color="yellow">No skill index found.</Text>
|
||||
<Text dimColor>Press 'u' to update index from known sources.</Text>
|
||||
</Box>
|
||||
{/* Analysis progress */}
|
||||
{animPhase >= 2 && analyzing && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame]} </text>
|
||||
<text fg={terminalColors.text}>Analyzing</text>
|
||||
<text fg={terminalColors.textMuted}> your project...</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{indexStatus === 'stale' && !loading && (
|
||||
<Text dimColor>Index may be outdated. Press 'u' to update.</Text>
|
||||
{/* Results summary */}
|
||||
{animPhase >= 2 && !analyzing && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.success}>✓ </text>
|
||||
<text fg={terminalColors.text}>Analysis complete</text>
|
||||
<text fg={terminalColors.textMuted}> · found {recommendations.length} matching skills</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Profile info */}
|
||||
{profile && !searchMode && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text dimColor>
|
||||
Project: {profile.name}
|
||||
{profile.type ? ` (${profile.type})` : ''}
|
||||
</Text>
|
||||
{profile.stack.languages.length > 0 && (
|
||||
<Text dimColor>
|
||||
Stack: {profile.stack.languages.map(l => l.name).join(', ')}
|
||||
{profile.stack.frameworks.length > 0 && `, ${profile.stack.frameworks.map(f => f.name).join(', ')}`}
|
||||
</Text>
|
||||
{/* Recommendations list */}
|
||||
{animPhase >= 3 && !analyzing && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Suggested Skills</text>
|
||||
<text> </text>
|
||||
|
||||
{visibleRecs.map((rec, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
return (
|
||||
<box key={rec.name} flexDirection="column">
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{rec.name}
|
||||
</text>
|
||||
<text fg={getConfColor(rec.confidence)}> {rec.confidence}%</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> {rec.reason}</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
|
||||
{recommendations.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
+{recommendations.length - maxVisible} more
|
||||
</text>
|
||||
)}
|
||||
</Box>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Item count */}
|
||||
{!searchMode && (
|
||||
<Text dimColor>
|
||||
{view === 'search'
|
||||
? `${searchResults.length} results`
|
||||
: `${recommendations.length} of ${totalScanned} skills matched`}
|
||||
</Text>
|
||||
{/* Footer */}
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* List */}
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((item, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
const skill = (item as typeof recommendations[0]).skill;
|
||||
const score = (item as typeof recommendations[0]).score;
|
||||
|
||||
return (
|
||||
<Box key={skill.name} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '}
|
||||
<Text color={getScoreColor(score)}>{score.toString().padStart(3)}%</Text>
|
||||
{' '}
|
||||
<Text color={getScoreColor(score)}>{getScoreBar(score)}</Text>
|
||||
{' '}
|
||||
<Text bold>{skill.name}</Text>
|
||||
</Text>
|
||||
{isSel && skill.description && (
|
||||
<Text dimColor> {skill.description.slice(0, 60)}{skill.description.length > 60 ? '...' : ''}</Text>
|
||||
)}
|
||||
{isSel && skill.source && (
|
||||
<Text dimColor> Source: {skill.source}</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < items.length && <Text dimColor> ↓ {items.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
|
||||
{/* Help bar */}
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>
|
||||
{view === 'search'
|
||||
? 'Enter=install m=choose agent /=search r=back u=update q=quit'
|
||||
: 'Enter=install m=choose agent /=search u=update R=refresh q=quit'}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,193 +1,140 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import TextInput from 'ink-text-input';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { loadConfig, saveConfig, AgentType as AgentTypeSchema, type SkillkitConfig, type AgentType } from '@skillkit/core';
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface Props {
|
||||
interface SettingsProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
interface Setting {
|
||||
id: keyof SkillkitConfig | 'agent' | 'autoSync' | 'cacheDir';
|
||||
interface SettingItem {
|
||||
key: string;
|
||||
label: string;
|
||||
type: 'select' | 'toggle' | 'text';
|
||||
options?: string[];
|
||||
value: string;
|
||||
type: 'select' | 'path' | 'toggle';
|
||||
}
|
||||
|
||||
// Get all valid agent types from the Zod schema
|
||||
const ALL_AGENTS: AgentType[] = AgentTypeSchema.options;
|
||||
|
||||
const SETTINGS: Setting[] = [
|
||||
{ id: 'agent', label: 'Default Agent', type: 'select', options: ['auto-detect', ...ALL_AGENTS] },
|
||||
{ id: 'autoSync', label: 'Auto Sync', type: 'toggle' },
|
||||
{ id: 'cacheDir', label: 'Cache Dir', type: 'text' },
|
||||
const DEFAULT_SETTINGS: SettingItem[] = [
|
||||
{ key: 'defaultAgent', label: 'Default Agent', value: 'claude-code', type: 'select' },
|
||||
{ key: 'skillsDir', label: 'Skills Directory', value: '.claude/skills', type: 'path' },
|
||||
{ key: 'autoSync', label: 'Auto Sync', value: 'enabled', type: 'toggle' },
|
||||
{ key: 'theme', label: 'Theme', value: 'dark', type: 'select' },
|
||||
{ key: 'telemetry', label: 'Telemetry', value: 'disabled', type: 'toggle' },
|
||||
];
|
||||
|
||||
export function Settings(_props: Props) {
|
||||
const [config, setConfig] = useState<SkillkitConfig | null>(null);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [editValue, setEditValue] = useState('');
|
||||
const [saved, setSaved] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
export function Settings({ onNavigate, cols = 80 }: SettingsProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [settings, setSettings] = useState<SettingItem[]>(DEFAULT_SETTINGS);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
// Load config on mount
|
||||
useEffect(() => {
|
||||
try {
|
||||
const loaded = loadConfig();
|
||||
setConfig(loaded);
|
||||
} catch (err) {
|
||||
setError(`Failed to load config: ${err}`);
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, settings.length - 1)));
|
||||
}, [settings.length]);
|
||||
|
||||
const handleToggle = useCallback(() => {
|
||||
const setting = settings[selectedIndex];
|
||||
if (setting?.type === 'toggle') {
|
||||
setSettings(prev => prev.map((s, i) =>
|
||||
i === selectedIndex ? { ...s, value: s.value === 'enabled' ? 'disabled' : 'enabled' } : s
|
||||
));
|
||||
}
|
||||
}, [selectedIndex, settings]);
|
||||
|
||||
const handleReset = useCallback(() => {
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
}, []);
|
||||
|
||||
const getCurrentValue = (setting: Setting): string => {
|
||||
if (!config) return '';
|
||||
const handleKeyboard = useCallback((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleToggle();
|
||||
else if (key.name === 'r') handleReset();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
}, [handleKeyNav, handleToggle, handleReset, onNavigate]);
|
||||
|
||||
switch (setting.id) {
|
||||
case 'agent':
|
||||
// Map 'universal' back to 'auto-detect' for display consistency
|
||||
return config.agent === 'universal' ? 'auto-detect' : (config.agent || 'auto-detect');
|
||||
case 'autoSync':
|
||||
return config.autoSync ? 'enabled' : 'disabled';
|
||||
case 'cacheDir':
|
||||
return config.cacheDir || '~/.skillkit/cache';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
useKeyboard(handleKeyboard);
|
||||
|
||||
const handleSave = (setting: Setting, value: string) => {
|
||||
if (!config) return;
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
const newConfig = { ...config };
|
||||
|
||||
switch (setting.id) {
|
||||
case 'agent':
|
||||
if (value === 'auto-detect') {
|
||||
newConfig.agent = 'universal';
|
||||
} else {
|
||||
newConfig.agent = value as AgentType;
|
||||
}
|
||||
break;
|
||||
case 'autoSync':
|
||||
newConfig.autoSync = value === 'enabled';
|
||||
break;
|
||||
case 'cacheDir':
|
||||
newConfig.cacheDir = value || undefined;
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
saveConfig(newConfig, false);
|
||||
setConfig(newConfig);
|
||||
setSaved(true);
|
||||
setTimeout(() => setSaved(false), 2000);
|
||||
} catch (err) {
|
||||
setError(`Failed to save: ${err}`);
|
||||
setTimeout(() => setError(null), 3000);
|
||||
}
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (editing) {
|
||||
if (key.return) {
|
||||
handleSave(SETTINGS[sel], editValue);
|
||||
setEditing(false);
|
||||
} else if (key.escape) {
|
||||
setEditing(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.upArrow) {
|
||||
setSel(i => Math.max(0, i - 1));
|
||||
} else if (key.downArrow) {
|
||||
setSel(i => Math.min(SETTINGS.length - 1, i + 1));
|
||||
} else if (key.return || input === ' ') {
|
||||
const setting = SETTINGS[sel];
|
||||
|
||||
if (setting.type === 'toggle') {
|
||||
const current = getCurrentValue(setting);
|
||||
const newValue = current === 'enabled' ? 'disabled' : 'enabled';
|
||||
handleSave(setting, newValue);
|
||||
} else if (setting.type === 'select' && setting.options) {
|
||||
const current = getCurrentValue(setting);
|
||||
const idx = setting.options.indexOf(current);
|
||||
const nextIdx = (idx + 1) % setting.options.length;
|
||||
handleSave(setting, setting.options[nextIdx]);
|
||||
} else if (setting.type === 'text') {
|
||||
setEditValue(getCurrentValue(setting));
|
||||
setEditing(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!config) {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SETTINGS</Text>
|
||||
{error ? (
|
||||
<Text color={colors.danger}>{symbols.error} {error}</Text>
|
||||
) : (
|
||||
<Text dimColor>Loading...</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter toggle r reset esc back'
|
||||
: 'j/k navigate enter toggle r reset defaults esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SETTINGS</Text>
|
||||
<Text dimColor>Configure SkillKit (changes save automatically)</Text>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.text}>⚙ Settings</text>
|
||||
<text fg={terminalColors.textMuted}>{settings.length} options</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>configure skillkit</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{SETTINGS.map((s, i) => {
|
||||
const isSel = i === sel;
|
||||
const value = getCurrentValue(s);
|
||||
const isEditing = editing && isSel;
|
||||
{/* Settings list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<text fg={terminalColors.text}>Configuration</text>
|
||||
<text> </text>
|
||||
|
||||
return (
|
||||
<Box key={s.id}>
|
||||
<Text inverse={isSel && !isEditing}>
|
||||
{isSel ? symbols.pointer : ' '}{s.label.padEnd(16)}
|
||||
</Text>
|
||||
{isEditing ? (
|
||||
<Box marginLeft={1}>
|
||||
<TextInput
|
||||
value={editValue}
|
||||
onChange={setEditValue}
|
||||
onSubmit={() => {
|
||||
handleSave(s, editValue);
|
||||
setEditing(false);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<Text color={colors.secondaryDim}> {value}</Text>
|
||||
)}
|
||||
{s.type === 'toggle' && isSel && !isEditing && (
|
||||
<Text dimColor> (space to toggle)</Text>
|
||||
)}
|
||||
{s.type === 'select' && isSel && !isEditing && (
|
||||
<Text dimColor> (enter to cycle)</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
{settings.map((setting, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const valueColor = setting.type === 'toggle'
|
||||
? (setting.value === 'enabled' ? terminalColors.success : terminalColors.textMuted)
|
||||
: terminalColors.textMuted;
|
||||
const toggleIcon = setting.type === 'toggle'
|
||||
? (setting.value === 'enabled' ? '● ' : '○ ')
|
||||
: '';
|
||||
return (
|
||||
<box key={setting.key} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text} width={18}>
|
||||
{setting.label}
|
||||
</text>
|
||||
<text fg={valueColor}>{toggleIcon}{setting.value}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
{saved && <Text color={colors.success}>{symbols.check} Settings saved</Text>}
|
||||
{error && <Text color={colors.danger}>{symbols.error} {error}</Text>}
|
||||
{!saved && !error && (
|
||||
<Text dimColor>
|
||||
{editing ? 'Enter=save Esc=cancel' : 'Enter/Space=edit q=quit'}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
{/* Config location */}
|
||||
{animPhase >= 2 && !isCompact && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>config: ~/.config/skillkit/config.json</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,78 +1,185 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { getAllAdapters } from '@skillkit/agents';
|
||||
/**
|
||||
* Sync Screen - Cross-Agent Synchronization
|
||||
* Clean monochromatic design
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { AGENT_LOGOS } from '../theme/symbols.js';
|
||||
|
||||
interface AgentStatus {
|
||||
name: string;
|
||||
type: string;
|
||||
detected: boolean;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
interface SyncProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Sync({ rows = 24 }: Props) {
|
||||
const [agents, setAgents] = useState<AgentStatus[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [syncing, setSyncing] = useState(false);
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
const maxVisible = Math.max(5, rows - 6);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), agents.length - maxVisible));
|
||||
const visible = agents.slice(start, start + maxVisible);
|
||||
export function Sync({ onNavigate, cols = 80, rows = 24 }: SyncProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [syncStatus, setSyncStatus] = useState<'idle' | 'syncing' | 'done'>('idle');
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const syncTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
// Cleanup timeout on unmount
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const adapters = getAllAdapters();
|
||||
const s: AgentStatus[] = [];
|
||||
for (const a of adapters) {
|
||||
s.push({ name: a.name, type: a.type, detected: await a.isDetected() });
|
||||
return () => {
|
||||
if (syncTimeoutRef.current) {
|
||||
clearTimeout(syncTimeoutRef.current);
|
||||
}
|
||||
setAgents(s);
|
||||
setLoading(false);
|
||||
})();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || syncing) return;
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(agents.length - 1, i + 1));
|
||||
else if (input === 'a') { setSyncing(true); setTimeout(() => setSyncing(false), 500); }
|
||||
else if (key.return && agents[sel]?.detected) { setSyncing(true); setTimeout(() => setSyncing(false), 300); }
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
// Spinner animation
|
||||
useEffect(() => {
|
||||
if (syncStatus !== 'syncing') return;
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, [syncStatus]);
|
||||
|
||||
// Agents with sync data
|
||||
const agents = useMemo(() => {
|
||||
const agentTypes = ['claude-code', 'cursor', 'github-copilot', 'codex', 'gemini-cli', 'windsurf'];
|
||||
return agentTypes.slice(0, isCompact ? 4 : 6).map((type) => ({
|
||||
type,
|
||||
...(AGENT_LOGOS[type] || { name: type, icon: '◇' }),
|
||||
synced: type === 'claude-code' || type === 'cursor',
|
||||
skillCount: type === 'claude-code' ? 12 : type === 'cursor' ? 8 : 0,
|
||||
}));
|
||||
}, [isCompact]);
|
||||
|
||||
const syncedCount = agents.filter(a => a.synced).length;
|
||||
const totalSkills = agents.reduce((sum, a) => sum + a.skillCount, 0);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, agents.length - 1)));
|
||||
}, [agents.length]);
|
||||
|
||||
const handleSync = useCallback(() => {
|
||||
if (syncStatus === 'syncing') return;
|
||||
if (syncTimeoutRef.current) clearTimeout(syncTimeoutRef.current);
|
||||
setSyncStatus('syncing');
|
||||
syncTimeoutRef.current = setTimeout(() => setSyncStatus('done'), 1500);
|
||||
}, [syncStatus]);
|
||||
|
||||
const handleSyncAll = useCallback(() => {
|
||||
if (syncStatus === 'syncing') return;
|
||||
if (syncTimeoutRef.current) clearTimeout(syncTimeoutRef.current);
|
||||
setSyncStatus('syncing');
|
||||
syncTimeoutRef.current = setTimeout(() => setSyncStatus('done'), 2000);
|
||||
}, [syncStatus]);
|
||||
|
||||
// Clamp selectedIndex when agents list shrinks
|
||||
useEffect(() => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev, agents.length - 1)));
|
||||
}, [agents.length]);
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleSync();
|
||||
else if (key.name === 'a') handleSyncAll();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
});
|
||||
|
||||
const detected = agents.filter(a => a.detected).length;
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter sync a sync all esc back'
|
||||
: 'j/k navigate enter sync selected a sync all esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>SYNC SKILLS</Text>
|
||||
<Text dimColor>{detected}/{agents.length} agents detected</Text>
|
||||
|
||||
{loading && <Text>Detecting agents...</Text>}
|
||||
{syncing && <Text>Syncing...</Text>}
|
||||
|
||||
{!loading && !syncing && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((agent, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
return (
|
||||
<Text key={agent.type} inverse={isSel} dimColor={!agent.detected}>
|
||||
{isSel ? symbols.pointer : ' '}{agent.detected ? symbols.checkboxOn : symbols.checkboxOff} {agent.name.padEnd(20)} {agent.detected ? 'Ready' : 'N/A'}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < agents.length && <Text dimColor> ↓ {agents.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.sync}>⇄ Sync</text>
|
||||
<text fg={terminalColors.textMuted}>{syncedCount}/{agents.length} synced</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>share skills across agents</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=sync a=all q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{/* Status */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
{syncStatus === 'syncing' ? (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame]} </text>
|
||||
<text fg={terminalColors.text}>Syncing skills...</text>
|
||||
</box>
|
||||
) : syncStatus === 'done' ? (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.success}>✓ </text>
|
||||
<text fg={terminalColors.text}>Sync complete</text>
|
||||
<text fg={terminalColors.textMuted}> · {totalSkills} skills synced</text>
|
||||
</box>
|
||||
) : (
|
||||
<box flexDirection="row" gap={3}>
|
||||
<text fg={terminalColors.success}>● {syncedCount} synced</text>
|
||||
<text fg={terminalColors.textMuted}>○ {agents.length - syncedCount} pending</text>
|
||||
</box>
|
||||
)}
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Agents list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Agents</text>
|
||||
<text> </text>
|
||||
|
||||
{agents.map((agent, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = agent.synced ? '●' : '○';
|
||||
const statusColor = agent.synced ? terminalColors.success : terminalColors.textMuted;
|
||||
return (
|
||||
<box key={agent.type} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{agent.icon} {agent.name}
|
||||
</text>
|
||||
<text fg={statusColor}> {statusIcon}</text>
|
||||
<text fg={terminalColors.textMuted}> {agent.skillCount} skills</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,221 +1,59 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
/**
|
||||
* Team Screen
|
||||
* Team collaboration
|
||||
*/
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
|
||||
interface SharedSkill {
|
||||
name: string;
|
||||
version: string;
|
||||
description?: string;
|
||||
author: string;
|
||||
downloads?: number;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
interface TeamConfig {
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
registryUrl: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
interface TeamProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Team({ rows = 24 }: Props) {
|
||||
const [config, setConfig] = useState<TeamConfig | null>(null);
|
||||
const [skills, setSkills] = useState<SharedSkill[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
|
||||
const maxVisible = Math.max(5, rows - 12);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), skills.length - maxVisible));
|
||||
const visible = skills.slice(start, start + maxVisible);
|
||||
|
||||
useEffect(() => {
|
||||
loadTeam();
|
||||
}, []);
|
||||
|
||||
const loadTeam = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const { createTeamManager } = await import('@skillkit/core');
|
||||
const manager = createTeamManager(process.cwd());
|
||||
const teamConfig = manager.load();
|
||||
|
||||
if (!teamConfig) {
|
||||
setConfig(null);
|
||||
setSkills([]);
|
||||
setError('Team not initialized. Run `skillkit team init` first.');
|
||||
} else {
|
||||
setConfig(teamConfig);
|
||||
const sharedSkills = manager.listSharedSkills();
|
||||
setSkills(sharedSkills);
|
||||
setSel(s => Math.min(s, Math.max(0, sharedSkills.length - 1)));
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load team');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const syncTeam = async () => {
|
||||
if (!config) return;
|
||||
setLoading(true);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
const { createTeamManager } = await import('@skillkit/core');
|
||||
const manager = createTeamManager(process.cwd());
|
||||
manager.load(); // Load config before sync
|
||||
const result = await manager.sync();
|
||||
|
||||
const changes = [...result.added, ...result.updated];
|
||||
if (changes.length > 0) {
|
||||
setMessage(`Synced: ${changes.join(', ')}`);
|
||||
} else {
|
||||
setMessage('Already up to date');
|
||||
}
|
||||
|
||||
// Reload skills
|
||||
const sharedSkills = manager.listSharedSkills();
|
||||
setSkills(sharedSkills);
|
||||
setSel(s => Math.min(s, Math.max(0, sharedSkills.length - 1)));
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Sync failed');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const importSkill = async (skillName: string) => {
|
||||
if (!config) return;
|
||||
setLoading(true);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
const { createTeamManager } = await import('@skillkit/core');
|
||||
const manager = createTeamManager(process.cwd());
|
||||
manager.load(); // Load config before import
|
||||
const result = await manager.importSkill(skillName, { overwrite: false });
|
||||
|
||||
if (result.success) {
|
||||
setMessage(`Imported: ${skillName}`);
|
||||
} else {
|
||||
setError(result.error || 'Import failed');
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Import failed');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading) return;
|
||||
if (skills.length === 0 && (key.upArrow || key.downArrow)) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(Math.max(0, skills.length - 1), i + 1));
|
||||
else if (input === 'r') loadTeam();
|
||||
else if (input === 's') syncTeam();
|
||||
else if (key.return && skills[sel]) {
|
||||
importSkill(skills[sel].name);
|
||||
}
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Box flexDirection="column" padding={1}>
|
||||
<Text color={colors.primary} bold>Team Collaboration</Text>
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.secondaryDim}>{symbols.spinner[0]} Loading...</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
return (
|
||||
<Box flexDirection="column" padding={1}>
|
||||
<Text color={colors.primary} bold>Team Collaboration</Text>
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={colors.secondaryDim}>{symbols.warning} Team not initialized</Text>
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
Run: skillkit team init --name "Team Name" --registry <url>
|
||||
</Text>
|
||||
</Box>
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>[r] Refresh</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
export function Team({ onNavigate, cols = 80, rows = 24 }: TeamProps) {
|
||||
const members = [
|
||||
{ name: 'You', role: 'Owner', status: 'online', skills: 12 },
|
||||
{ name: 'Alice', role: 'Admin', status: 'online', skills: 8 },
|
||||
{ name: 'Bob', role: 'Member', status: 'offline', skills: 5 },
|
||||
];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" padding={1}>
|
||||
<Text color={colors.primary} bold>Team: {config.teamName}</Text>
|
||||
<Text color={colors.secondaryDim} dimColor>Registry: {config.registryUrl}</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Team"
|
||||
subtitle="Collaborate with your development team"
|
||||
count={members.length}
|
||||
icon="◉"
|
||||
/>
|
||||
|
||||
{error && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="red">{symbols.error} {error}</Text>
|
||||
</Box>
|
||||
)}
|
||||
<text fg={terminalColors.text}><b>Team Members</b></text>
|
||||
<text> </text>
|
||||
|
||||
{message && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="green">{symbols.success} {message}</Text>
|
||||
</Box>
|
||||
)}
|
||||
{members.map((member, idx) => (
|
||||
<box key={member.name} flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={15}
|
||||
>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{member.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>{member.role}</text>
|
||||
<text
|
||||
fg={member.status === 'online' ? terminalColors.success : terminalColors.textMuted}
|
||||
width={10}
|
||||
>
|
||||
{member.status === 'online' ? '\u25CF online' : '\u25CB offline'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{member.skills} skills</text>
|
||||
</box>
|
||||
))}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={colors.secondaryDim} bold>
|
||||
Shared Skills ({skills.length})
|
||||
</Text>
|
||||
|
||||
{skills.length === 0 ? (
|
||||
<Text color={colors.secondaryDim} dimColor>
|
||||
No shared skills. Use `skillkit team share --name <skill>` to share.
|
||||
</Text>
|
||||
) : (
|
||||
<Box flexDirection="column" marginTop={1}>
|
||||
{visible.map((skill, i) => {
|
||||
const actualIndex = start + i;
|
||||
const isSelected = actualIndex === sel;
|
||||
return (
|
||||
<Box key={skill.name} flexDirection="column">
|
||||
<Text>
|
||||
{isSelected ? symbols.pointer : ' '}{' '}
|
||||
<Text color={isSelected ? colors.primary : colors.secondaryDim} bold={isSelected}>
|
||||
{skill.name}
|
||||
</Text>
|
||||
<Text dimColor> v{skill.version}</Text>
|
||||
<Text dimColor> by {skill.author}</Text>
|
||||
{skill.downloads !== undefined && (
|
||||
<Text dimColor> | {skill.downloads} downloads</Text>
|
||||
)}
|
||||
</Text>
|
||||
{skill.description && isSelected && (
|
||||
<Text color={colors.secondaryDim} dimColor> {skill.description}</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1} borderStyle="single" borderColor={colors.borderDim} paddingX={1}>
|
||||
<Text dimColor>
|
||||
[↑↓] Navigate [Enter] Import [s] Sync [r] Refresh
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press 'i' to invite, 's' to share skills
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,286 +1,64 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import {
|
||||
translateSkill,
|
||||
getSupportedTranslationAgents,
|
||||
type AgentType,
|
||||
} from '@skillkit/core';
|
||||
import { getAllAdapters, getAdapter } from '@skillkit/agents';
|
||||
import { getInstallDir } from '../helpers.js';
|
||||
/**
|
||||
* Translate Screen
|
||||
* Skill format conversion with diff view
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { AGENT_LOGOS } from '../theme/symbols.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
|
||||
type View = 'skills' | 'agents' | 'preview' | 'result';
|
||||
|
||||
interface InstalledSkill {
|
||||
name: string;
|
||||
path: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
interface TranslateProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Translate({ rows = 24 }: Props) {
|
||||
const [view, setView] = useState<View>('skills');
|
||||
const [skills, setSkills] = useState<InstalledSkill[]>([]);
|
||||
const [agents, setAgents] = useState<{ type: AgentType; name: string }[]>([]);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [selectedSkill, setSelectedSkill] = useState<InstalledSkill | null>(null);
|
||||
const [selectedAgent, setSelectedAgent] = useState<{ type: AgentType; name: string } | null>(null);
|
||||
const [preview, setPreview] = useState<string>('');
|
||||
const [result, setResult] = useState<{ success: boolean; message: string; path?: string } | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
export function Translate(_props: TranslateProps) {
|
||||
const [sourceAgent] = useState('claude-code');
|
||||
const [targetAgent] = useState('cursor');
|
||||
|
||||
useEffect(() => {
|
||||
const loadSkills = () => {
|
||||
const installDir = getInstallDir(false);
|
||||
const foundSkills: InstalledSkill[] = [];
|
||||
|
||||
if (existsSync(installDir)) {
|
||||
const dirs = readdirSync(installDir, { withFileTypes: true })
|
||||
.filter(d => d.isDirectory())
|
||||
.map(d => d.name);
|
||||
|
||||
for (const dir of dirs) {
|
||||
const skillPath = join(installDir, dir);
|
||||
const skillMdPath = join(skillPath, 'SKILL.md');
|
||||
|
||||
if (existsSync(skillMdPath)) {
|
||||
const content = readFileSync(skillMdPath, 'utf-8');
|
||||
foundSkills.push({
|
||||
name: dir,
|
||||
path: skillPath,
|
||||
content,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSkills(foundSkills);
|
||||
};
|
||||
|
||||
loadSkills();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const adapters = getAllAdapters();
|
||||
const supportedAgents = getSupportedTranslationAgents();
|
||||
const agentList = adapters
|
||||
.filter(a => supportedAgents.includes(a.type as AgentType))
|
||||
.map(a => ({
|
||||
type: a.type as AgentType,
|
||||
name: a.name,
|
||||
}));
|
||||
setAgents(agentList);
|
||||
}, []);
|
||||
|
||||
const currentItems = view === 'skills' ? skills : agents;
|
||||
const maxVisible = Math.max(5, rows - 12);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), currentItems.length - maxVisible));
|
||||
const visible = currentItems.slice(start, start + maxVisible);
|
||||
|
||||
const generatePreview = (skill: InstalledSkill, agent: { type: AgentType; name: string }) => {
|
||||
try {
|
||||
const result = translateSkill(skill.content, agent.type, { sourceFilename: 'SKILL.md' });
|
||||
return result.content;
|
||||
} catch (err) {
|
||||
return `Error: ${err instanceof Error ? err.message : 'Translation failed'}`;
|
||||
}
|
||||
};
|
||||
|
||||
const executeTranslation = () => {
|
||||
if (!selectedSkill || !selectedAgent) return;
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const translationResult = translateSkill(selectedSkill.content, selectedAgent.type, {
|
||||
sourceFilename: 'SKILL.md',
|
||||
});
|
||||
|
||||
if (!translationResult.success) {
|
||||
setResult({
|
||||
success: false,
|
||||
message: `Translation failed: ${translationResult.warnings.join(', ')}`,
|
||||
});
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const adapter = getAdapter(selectedAgent.type);
|
||||
const targetDir = adapter?.skillsDir
|
||||
? join(process.cwd(), adapter.skillsDir)
|
||||
: join(process.cwd(), `.${selectedAgent.type}/skills/`);
|
||||
|
||||
if (!existsSync(targetDir)) {
|
||||
mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
|
||||
const filename = translationResult.filename || `${selectedSkill.name}.md`;
|
||||
const targetPath = join(targetDir, filename);
|
||||
|
||||
writeFileSync(targetPath, translationResult.content, 'utf-8');
|
||||
|
||||
setResult({
|
||||
success: true,
|
||||
message: `Translated ${selectedSkill.name} to ${selectedAgent.name} format`,
|
||||
path: targetPath,
|
||||
});
|
||||
} catch (err) {
|
||||
setResult({
|
||||
success: false,
|
||||
message: `Error: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setView('result');
|
||||
}
|
||||
};
|
||||
|
||||
useInput((_input, key) => {
|
||||
if (loading) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(currentItems.length - 1, i + 1));
|
||||
else if (key.escape) {
|
||||
if (view === 'result') {
|
||||
setView('skills');
|
||||
setSelectedSkill(null);
|
||||
setSelectedAgent(null);
|
||||
setResult(null);
|
||||
setSel(0);
|
||||
} else if (view === 'preview') {
|
||||
setView('agents');
|
||||
} else if (view === 'agents') {
|
||||
setView('skills');
|
||||
setSelectedSkill(null);
|
||||
}
|
||||
}
|
||||
else if (key.return) {
|
||||
if (view === 'skills' && skills[sel]) {
|
||||
setSelectedSkill(skills[sel]);
|
||||
setView('agents');
|
||||
setSel(0);
|
||||
} else if (view === 'agents' && agents[sel]) {
|
||||
setSelectedAgent(agents[sel]);
|
||||
const previewContent = generatePreview(selectedSkill!, agents[sel]);
|
||||
setPreview(previewContent);
|
||||
setView('preview');
|
||||
} else if (view === 'preview') {
|
||||
executeTranslation();
|
||||
} else if (view === 'result') {
|
||||
setView('skills');
|
||||
setSelectedSkill(null);
|
||||
setSelectedAgent(null);
|
||||
setResult(null);
|
||||
setSel(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (view === 'result' && result) {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>TRANSLATION {result.success ? 'COMPLETE' : 'FAILED'}</Text>
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={result.success ? 'green' : 'red'}>
|
||||
{result.success ? '✓' : '✗'} {result.message}
|
||||
</Text>
|
||||
{result.path && (
|
||||
<Text dimColor>Saved to: {result.path}</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={2}>
|
||||
<Text dimColor>Press Enter or Esc to continue</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (view === 'preview') {
|
||||
const previewLines = preview.split('\n').slice(0, maxVisible);
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>TRANSLATION PREVIEW</Text>
|
||||
<Text dimColor>
|
||||
{selectedSkill?.name} → {selectedAgent?.name}
|
||||
</Text>
|
||||
|
||||
<Box marginTop={1} flexDirection="column" borderStyle="single" paddingX={1}>
|
||||
{previewLines.map((line, i) => (
|
||||
<Text key={i} dimColor>{line.slice(0, 70)}</Text>
|
||||
))}
|
||||
{preview.split('\n').length > maxVisible && (
|
||||
<Text dimColor>... ({preview.split('\n').length - maxVisible} more lines)</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=confirm translation Esc=back</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
const sourceInfo = AGENT_LOGOS[sourceAgent];
|
||||
const targetInfo = AGENT_LOGOS[targetAgent];
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>
|
||||
{view === 'skills' ? 'TRANSLATE SKILL' : 'SELECT TARGET AGENT'}
|
||||
</Text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Translate Skills"
|
||||
subtitle="Convert skills between agent formats"
|
||||
icon="⇄"
|
||||
/>
|
||||
|
||||
{view === 'skills' && (
|
||||
<Text dimColor>Select a skill to translate to another agent format</Text>
|
||||
)}
|
||||
<box flexDirection="row" marginTop={1} marginBottom={1}>
|
||||
<box flexDirection="column" width={25}>
|
||||
<text fg={terminalColors.textMuted}>Source Agent</text>
|
||||
<text fg={terminalColors.accent}>
|
||||
<b>{sourceInfo?.icon} {sourceInfo?.name}</b>
|
||||
</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> → </text>
|
||||
<box flexDirection="column" width={25}>
|
||||
<text fg={terminalColors.textMuted}>Target Agent</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{targetInfo?.icon} {targetInfo?.name}</b>
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
{view === 'agents' && selectedSkill && (
|
||||
<Text dimColor>Translate "{selectedSkill.name}" to which agent format?</Text>
|
||||
)}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\u2500'.repeat(50)}
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
{skills.length === 0 && view === 'skills' && (
|
||||
<Box marginTop={1}>
|
||||
<Text color="yellow">No skills installed. Install some skills first with 'skillkit install'</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((item, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
|
||||
if (view === 'skills') {
|
||||
const skill = item as InstalledSkill;
|
||||
return (
|
||||
<Text key={skill.name} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {skill.name}
|
||||
</Text>
|
||||
);
|
||||
} else {
|
||||
const agent = item as { type: AgentType; name: string };
|
||||
return (
|
||||
<Text key={agent.type} inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {agent.name.padEnd(20)} <Text dimColor>({agent.type})</Text>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
})}
|
||||
{start + maxVisible < currentItems.length && (
|
||||
<Text dimColor> ↓ {currentItems.length - start - maxVisible} more</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>
|
||||
{view === 'skills'
|
||||
? 'Enter=select skill q=quit'
|
||||
: 'Enter=select agent Esc=back q=quit'}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<text fg={terminalColors.text}><b>Select a skill to translate:</b></text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
No skills selected. Press 'i' to view installed skills.
|
||||
</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Use Tab to switch agents, Enter to translate
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,96 +1,133 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Text, useInput } from 'ink';
|
||||
import { colors, symbols } from '../theme.js';
|
||||
import { listWorkflows, type Workflow as WorkflowType } from '@skillkit/core';
|
||||
/**
|
||||
* Workflow Screen - Automation Builder
|
||||
* Clean monochromatic design
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface Props {
|
||||
interface WorkflowProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Workflow({ rows = 24 }: Props) {
|
||||
const [workflows, setWorkflows] = useState<WorkflowType[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [sel, setSel] = useState(0);
|
||||
const [running, setRunning] = useState<string | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const WORKFLOWS = [
|
||||
{ name: 'test-and-commit', steps: 3, lastRun: '1 hour ago', status: 'success' as const },
|
||||
{ name: 'deploy-preview', steps: 5, lastRun: '2 hours ago', status: 'success' as const },
|
||||
{ name: 'full-ci', steps: 8, lastRun: '1 day ago', status: 'failed' as const },
|
||||
{ name: 'quick-fix', steps: 2, lastRun: '3 days ago', status: 'pending' as const },
|
||||
];
|
||||
|
||||
const maxVisible = Math.max(5, rows - 8);
|
||||
const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), workflows.length - maxVisible));
|
||||
const visible = workflows.slice(start, start + maxVisible);
|
||||
export function Workflow({ onNavigate, cols = 80, rows = 24 }: WorkflowProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
loadWorkflows();
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
|
||||
const successCount = WORKFLOWS.filter(w => w.status === 'success').length;
|
||||
const failedCount = WORKFLOWS.filter(w => w.status === 'failed').length;
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, WORKFLOWS.length - 1)));
|
||||
}, []);
|
||||
|
||||
const loadWorkflows = () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const wfs = listWorkflows(process.cwd());
|
||||
setWorkflows(wfs);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load workflows');
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useInput((input, key) => {
|
||||
if (loading || running) return;
|
||||
|
||||
if (key.upArrow) setSel(i => Math.max(0, i - 1));
|
||||
else if (key.downArrow) setSel(i => Math.min(workflows.length - 1, i + 1));
|
||||
else if (input === 'r') loadWorkflows();
|
||||
else if (key.return && workflows[sel]) {
|
||||
// Simulate running workflow
|
||||
setRunning(workflows[sel].name);
|
||||
setTimeout(() => setRunning(null), 2000);
|
||||
}
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav esc back'
|
||||
: 'j/k navigate esc back';
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text bold color={colors.primary}>WORKFLOWS</Text>
|
||||
<Text dimColor>{workflows.length} workflow(s) found</Text>
|
||||
|
||||
{loading && <Text>Loading workflows...</Text>}
|
||||
{error && <Text color="red">{error}</Text>}
|
||||
{running && <Text color="yellow">Running: {running}...</Text>}
|
||||
|
||||
{!loading && !running && workflows.length === 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text dimColor>No workflows found.</Text>
|
||||
<Text dimColor>Create one with: skillkit workflow create</Text>
|
||||
</Box>
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.workflow}>⟳ Workflows</text>
|
||||
<text fg={terminalColors.textMuted}>{WORKFLOWS.length} workflows</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>automate skill chains</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{!loading && !running && workflows.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
{start > 0 && <Text dimColor> ↑ {start} more</Text>}
|
||||
{visible.map((wf, i) => {
|
||||
const idx = start + i;
|
||||
const isSel = idx === sel;
|
||||
return (
|
||||
<Box key={wf.name} flexDirection="column">
|
||||
<Text inverse={isSel}>
|
||||
{isSel ? symbols.pointer : ' '} {wf.name}
|
||||
</Text>
|
||||
{isSel && wf.description && (
|
||||
<Text dimColor> {wf.description}</Text>
|
||||
)}
|
||||
{isSel && (
|
||||
<Text dimColor> {wf.waves.length} wave(s), {wf.waves.reduce((acc, w) => acc + w.skills.length, 0)} skill(s)</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
{start + maxVisible < workflows.length && <Text dimColor> ↓ {workflows.length - start - maxVisible} more</Text>}
|
||||
</Box>
|
||||
{/* Stats */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row" gap={3}>
|
||||
<text fg={terminalColors.success}>✓ {successCount} passed</text>
|
||||
{failedCount > 0 && (
|
||||
<text fg={terminalColors.error}>✗ {failedCount} failed</text>
|
||||
)}
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Enter=run r=refresh q=quit</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{/* Workflows list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Workflows</text>
|
||||
<text> </text>
|
||||
|
||||
{WORKFLOWS.length === 0 ? (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>No workflows yet</text>
|
||||
</box>
|
||||
) : (
|
||||
WORKFLOWS.map((wf, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = wf.status === 'success' ? '✓'
|
||||
: wf.status === 'failed' ? '✗' : '○';
|
||||
const statusColor = wf.status === 'success' ? terminalColors.success
|
||||
: wf.status === 'failed' ? terminalColors.error : terminalColors.textMuted;
|
||||
return (
|
||||
<box key={wf.name} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text} width={18}>
|
||||
{wf.name}
|
||||
</text>
|
||||
<text fg={statusColor}>{statusIcon} </text>
|
||||
<text fg={terminalColors.textMuted}>{wf.steps}s · {wf.lastRun}</text>
|
||||
</box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
/**
|
||||
* Screens module for SkillKit TUI
|
||||
*/
|
||||
|
||||
export { Home } from './Home.js';
|
||||
export { Browse } from './Browse.js';
|
||||
export { Installed } from './Installed.js';
|
||||
export { Sync } from './Sync.js';
|
||||
export { Settings } from './Settings.js';
|
||||
export { Marketplace } from './Marketplace.js';
|
||||
export { Recommend } from './Recommend.js';
|
||||
export { Translate } from './Translate.js';
|
||||
export { Context } from './Context.js';
|
||||
export { Sync } from './Sync.js';
|
||||
export { Memory } from './Memory.js';
|
||||
export { Workflow } from './Workflow.js';
|
||||
export { Execute } from './Execute.js';
|
||||
export { History } from './History.js';
|
||||
export { Marketplace } from './Marketplace.js';
|
||||
export { Team } from './Team.js';
|
||||
export { Plugins } from './Plugins.js';
|
||||
export { Methodology } from './Methodology.js';
|
||||
export { Plan } from './Plan.js';
|
||||
export { Settings } from './Settings.js';
|
||||
export { Help } from './Help.js';
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Agent state management for SkillKit TUI
|
||||
*/
|
||||
import { loadConfig } from '@skillkit/core';
|
||||
import { detectAgent, getAdapter, getAllAdapters } from '@skillkit/agents';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
|
||||
/**
|
||||
* Agent status information
|
||||
*/
|
||||
export interface AgentStatus {
|
||||
type: AgentType;
|
||||
name: string;
|
||||
detected: boolean;
|
||||
configured: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Agents state
|
||||
*/
|
||||
export interface AgentsState {
|
||||
agents: AgentStatus[];
|
||||
currentAgent: AgentType;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create initial agents state
|
||||
*/
|
||||
export function createAgentsState(): AgentsState {
|
||||
return {
|
||||
agents: [],
|
||||
currentAgent: 'universal',
|
||||
loading: true,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all agents with their detection status
|
||||
*/
|
||||
export async function loadAgents(): Promise<AgentsState> {
|
||||
try {
|
||||
const config = loadConfig();
|
||||
const currentAgent = config.agent || 'universal';
|
||||
const detectedAgent = await detectAgent();
|
||||
const allAdapters = getAllAdapters();
|
||||
|
||||
const agents: AgentStatus[] = allAdapters.map((adapter) => ({
|
||||
type: adapter.type,
|
||||
name: adapter.name,
|
||||
detected: adapter.type === detectedAgent,
|
||||
configured: adapter.type === currentAgent,
|
||||
}));
|
||||
|
||||
return {
|
||||
agents,
|
||||
currentAgent,
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
agents: [],
|
||||
currentAgent: 'universal',
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load agents',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count of detected agents
|
||||
*/
|
||||
export function getDetectedAgentCount(state: AgentsState): number {
|
||||
return state.agents.filter((a) => a.detected).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of detected agents
|
||||
*/
|
||||
export function getDetectedAgents(state: AgentsState): AgentStatus[] {
|
||||
return state.agents.filter((a) => a.detected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent adapter by type
|
||||
*/
|
||||
export function getAgentAdapter(type: AgentType) {
|
||||
return getAdapter(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Total number of supported agents
|
||||
*/
|
||||
export const TOTAL_AGENTS = 17;
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* State management module for SkillKit TUI
|
||||
*/
|
||||
|
||||
// Types
|
||||
export {
|
||||
type SkillItem,
|
||||
type RepoInfo,
|
||||
type FetchedSkill,
|
||||
type Screen,
|
||||
NAV_KEYS,
|
||||
STATUS_BAR_SHORTCUTS,
|
||||
type ScreenMeta,
|
||||
type SidebarSection,
|
||||
SIDEBAR_NAV,
|
||||
} from './types.js';
|
||||
|
||||
// Navigation
|
||||
export {
|
||||
type NavigationState,
|
||||
createNavigationState,
|
||||
navigateTo,
|
||||
goBack,
|
||||
getScreenFromKey,
|
||||
isNavKey,
|
||||
} from './navigation.js';
|
||||
|
||||
// Skills
|
||||
export {
|
||||
type SkillsState,
|
||||
createSkillsState,
|
||||
loadSkills,
|
||||
removeSkill,
|
||||
filterSkills,
|
||||
} from './skills.js';
|
||||
|
||||
// Agents
|
||||
export {
|
||||
type AgentStatus,
|
||||
type AgentsState,
|
||||
createAgentsState,
|
||||
loadAgents,
|
||||
getDetectedAgentCount,
|
||||
getDetectedAgents,
|
||||
getAgentAdapter,
|
||||
TOTAL_AGENTS,
|
||||
} from './agents.js';
|
||||
|
||||
// Marketplace
|
||||
export {
|
||||
type MarketplaceState,
|
||||
DEFAULT_REPOS,
|
||||
getMarketplaceRepos,
|
||||
createMarketplaceState,
|
||||
readSkillDescription,
|
||||
fetchRepoSkills,
|
||||
cleanupTempRoot,
|
||||
filterMarketplaceSkills,
|
||||
toSkillItems,
|
||||
sortSkillsByName,
|
||||
} from './marketplace.js';
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* Marketplace state management for SkillKit TUI
|
||||
*/
|
||||
import { detectProvider, loadConfig, extractFrontmatter } from '@skillkit/core';
|
||||
import { readFileSync, existsSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import type { SkillItem, RepoInfo, FetchedSkill } from './types.js';
|
||||
|
||||
/**
|
||||
* Default repos loaded from marketplace/sources.json (single source of truth)
|
||||
* Import at runtime to allow updates without code changes
|
||||
*/
|
||||
import sourcesData from '../../../../marketplace/sources.json' with { type: 'json' };
|
||||
|
||||
export const DEFAULT_REPOS: RepoInfo[] = sourcesData.sources.map((s: { source: string; name: string }) => ({
|
||||
source: s.source,
|
||||
name: s.name,
|
||||
}));
|
||||
|
||||
/**
|
||||
* Marketplace state
|
||||
*/
|
||||
export interface MarketplaceState {
|
||||
allSkills: FetchedSkill[];
|
||||
filteredSkills: FetchedSkill[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
currentRepo: string | null;
|
||||
fetchedRepos: Set<string>;
|
||||
failedRepos: string[];
|
||||
repos: RepoInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get marketplace repos from config or use defaults
|
||||
*/
|
||||
export function getMarketplaceRepos(): RepoInfo[] {
|
||||
try {
|
||||
const config = loadConfig();
|
||||
if (config.marketplaceSources?.length) {
|
||||
const configRepos: RepoInfo[] = config.marketplaceSources.map((source) => ({
|
||||
source,
|
||||
name: source.split('/').pop() || source,
|
||||
}));
|
||||
const existingSources = new Set(configRepos.map((r) => r.source));
|
||||
for (const repo of DEFAULT_REPOS) {
|
||||
if (!existingSources.has(repo.source)) {
|
||||
configRepos.push(repo);
|
||||
}
|
||||
}
|
||||
return configRepos;
|
||||
}
|
||||
} catch {
|
||||
// Config load failed, use defaults
|
||||
}
|
||||
return DEFAULT_REPOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create initial marketplace state
|
||||
*/
|
||||
export function createMarketplaceState(): MarketplaceState {
|
||||
return {
|
||||
allSkills: [],
|
||||
filteredSkills: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
currentRepo: null,
|
||||
fetchedRepos: new Set(),
|
||||
failedRepos: [],
|
||||
repos: getMarketplaceRepos(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to read skill description from frontmatter
|
||||
*/
|
||||
export function readSkillDescription(skillPath: string): string | undefined {
|
||||
const skillMdPath = join(skillPath, 'SKILL.md');
|
||||
if (!existsSync(skillMdPath)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const content = readFileSync(skillMdPath, 'utf-8');
|
||||
const frontmatter = extractFrontmatter(content);
|
||||
if (frontmatter && typeof frontmatter.description === 'string') {
|
||||
return frontmatter.description;
|
||||
}
|
||||
} catch {
|
||||
// Failed to read, return undefined
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch skills from a single repository
|
||||
*/
|
||||
export async function fetchRepoSkills(
|
||||
source: string,
|
||||
repos: RepoInfo[]
|
||||
): Promise<{
|
||||
skills: FetchedSkill[];
|
||||
tempRoot?: string;
|
||||
error?: string;
|
||||
}> {
|
||||
try {
|
||||
const provider = detectProvider(source);
|
||||
if (!provider) {
|
||||
return { skills: [], error: `Could not detect provider for: ${source}` };
|
||||
}
|
||||
|
||||
const result = await provider.clone(source, '', { depth: 1 });
|
||||
|
||||
if (!result.success || !result.discoveredSkills) {
|
||||
return { skills: [], error: result.error || 'Failed to fetch skills' };
|
||||
}
|
||||
|
||||
const repoName = repos.find((r) => r.source === source)?.name || source;
|
||||
const skills: FetchedSkill[] = result.discoveredSkills.map((skill) => ({
|
||||
name: skill.name,
|
||||
source: source,
|
||||
repoName: repoName,
|
||||
description: readSkillDescription(skill.path),
|
||||
}));
|
||||
|
||||
return { skills, tempRoot: result.tempRoot };
|
||||
} catch (err) {
|
||||
return {
|
||||
skills: [],
|
||||
error: err instanceof Error ? err.message : 'Failed to fetch repository',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up temp directory from fetch
|
||||
*/
|
||||
export function cleanupTempRoot(tempRoot: string): void {
|
||||
try {
|
||||
rmSync(tempRoot, { recursive: true, force: true });
|
||||
} catch {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter skills by search query
|
||||
*/
|
||||
export function filterMarketplaceSkills(
|
||||
skills: FetchedSkill[],
|
||||
query: string
|
||||
): FetchedSkill[] {
|
||||
if (!query.trim()) return skills;
|
||||
|
||||
const lowerQuery = query.toLowerCase();
|
||||
return skills.filter(
|
||||
(s) =>
|
||||
s.name.toLowerCase().includes(lowerQuery) ||
|
||||
s.source.toLowerCase().includes(lowerQuery) ||
|
||||
s.repoName.toLowerCase().includes(lowerQuery) ||
|
||||
s.description?.toLowerCase().includes(lowerQuery)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert fetched skills to skill items for display
|
||||
*/
|
||||
export function toSkillItems(skills: FetchedSkill[]): SkillItem[] {
|
||||
return skills.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description || s.repoName,
|
||||
source: s.source,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort skills alphabetically by name
|
||||
*/
|
||||
export function sortSkillsByName(skills: FetchedSkill[]): FetchedSkill[] {
|
||||
return [...skills].sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Navigation state management for SkillKit TUI
|
||||
*/
|
||||
import type { Screen } from './types.js';
|
||||
import { NAV_KEYS } from './types.js';
|
||||
|
||||
/**
|
||||
* Navigation state
|
||||
*/
|
||||
export interface NavigationState {
|
||||
currentScreen: Screen;
|
||||
previousScreen: Screen | null;
|
||||
history: Screen[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create initial navigation state
|
||||
*/
|
||||
export function createNavigationState(): NavigationState {
|
||||
return {
|
||||
currentScreen: 'home',
|
||||
previousScreen: null,
|
||||
history: ['home'],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to a new screen
|
||||
*/
|
||||
export function navigateTo(state: NavigationState, screen: Screen): NavigationState {
|
||||
if (state.currentScreen === screen) return state;
|
||||
|
||||
return {
|
||||
currentScreen: screen,
|
||||
previousScreen: state.currentScreen,
|
||||
history: [...state.history, screen],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Go back to previous screen (or home)
|
||||
*/
|
||||
export function goBack(state: NavigationState): NavigationState {
|
||||
const previousScreen = state.previousScreen || 'home';
|
||||
return {
|
||||
currentScreen: previousScreen,
|
||||
previousScreen: state.history[state.history.length - 3] || null,
|
||||
history: state.history.slice(0, -1),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get screen from key press
|
||||
*/
|
||||
export function getScreenFromKey(key: string): Screen | undefined {
|
||||
return NAV_KEYS[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a key is a navigation key
|
||||
*/
|
||||
export function isNavKey(key: string): boolean {
|
||||
return key in NAV_KEYS;
|
||||
}
|
||||
|
||||
export { NAV_KEYS };
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user