mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-19 02:13:58 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79656339c9 | ||
|
|
03d6610e7c | ||
|
|
c22e1b3caf | ||
|
|
dd3bd07296 | ||
|
|
d6b76f3abd | ||
|
|
28c2c0a936 | ||
|
|
0a59bcf314 | ||
|
|
3f03d0690d | ||
|
|
96f83fdc2e |
@@ -14,6 +14,7 @@ import {
|
||||
RemoveCommand,
|
||||
InitCommand,
|
||||
ValidateCommand,
|
||||
FixCommand,
|
||||
CreateCommand,
|
||||
UICommand,
|
||||
TranslateCommand,
|
||||
@@ -83,6 +84,7 @@ cli.register(UpdateCommand);
|
||||
cli.register(RemoveCommand);
|
||||
cli.register(InitCommand);
|
||||
cli.register(ValidateCommand);
|
||||
cli.register(FixCommand);
|
||||
cli.register(CreateCommand);
|
||||
cli.register(UICommand);
|
||||
cli.register(TranslateCommand);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Footer } from './components/Footer';
|
||||
import { SkillGenerator } from './components/SkillGenerator';
|
||||
import { SkillSubmitForm } from './components/SkillSubmitForm';
|
||||
import { Commands } from './components/Commands';
|
||||
import { Documentation } from './components/Documentation';
|
||||
|
||||
const GITHUB_ICON = (
|
||||
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
|
||||
@@ -35,6 +36,12 @@ export default function App(): React.ReactElement {
|
||||
<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="#docs"
|
||||
className="text-zinc-400 hover:text-white transition-colors text-sm font-mono hidden sm:block"
|
||||
>
|
||||
Docs
|
||||
</a>
|
||||
<a
|
||||
href="https://www.npmjs.com/package/skillkit"
|
||||
target="_blank"
|
||||
@@ -64,6 +71,10 @@ export default function App(): React.ReactElement {
|
||||
<Features />
|
||||
<Commands />
|
||||
|
||||
<section id="docs" className="py-12 border-b border-zinc-800 bg-surface">
|
||||
<Documentation />
|
||||
</section>
|
||||
|
||||
<section id="skills" className="py-12 border-b border-zinc-800">
|
||||
<SkillGenerator />
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,479 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
interface DocSection {
|
||||
id: string;
|
||||
title: string;
|
||||
content: React.ReactNode;
|
||||
}
|
||||
|
||||
const CodeBlock = ({ children, language = 'bash' }: { children: string; language?: string }) => (
|
||||
<pre className="bg-zinc-900 border border-zinc-800 rounded-lg p-4 overflow-x-auto text-sm font-mono">
|
||||
<code className="text-zinc-300">{children}</code>
|
||||
</pre>
|
||||
);
|
||||
|
||||
const Table = ({ headers, rows }: { headers: string[]; rows: string[][] }) => (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm border-collapse">
|
||||
<thead>
|
||||
<tr className="border-b border-zinc-700">
|
||||
{headers.map((h, i) => (
|
||||
<th key={i} className="text-left py-2 px-3 text-zinc-300 font-mono font-semibold">{h}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row, i) => (
|
||||
<tr key={i} className="border-b border-zinc-800 hover:bg-zinc-900/50">
|
||||
{row.map((cell, j) => (
|
||||
<td key={j} className="py-2 px-3 text-zinc-400 font-mono">{cell}</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
|
||||
const sections: DocSection[] = [
|
||||
{
|
||||
id: 'overview',
|
||||
title: 'Overview',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<p className="text-zinc-300">
|
||||
SkillKit is a universal command-line interface (CLI) and programmatic toolkit for managing AI agent skills across 17+ AI coding platforms. It solves the fragmentation problem where each AI agent uses different skill formats and directory structures.
|
||||
</p>
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Core Capabilities</h3>
|
||||
<ul className="list-disc list-inside space-y-2 text-zinc-400">
|
||||
<li><span className="text-white">Skill Discovery</span> - Browse 15,000+ skills from marketplace with AI-powered recommendations</li>
|
||||
<li><span className="text-white">Cross-Agent Translation</span> - Automatically convert skills between 17 agent-specific formats</li>
|
||||
<li><span className="text-white">Team Collaboration</span> - Share skills via .skills manifest files and publish to marketplace</li>
|
||||
</ul>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'installation',
|
||||
title: 'Installation',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold text-white">Quick Start</h3>
|
||||
<CodeBlock>{`# Install globally via npm
|
||||
npm install -g skillkit
|
||||
|
||||
# Or use npx directly
|
||||
npx skillkit --help
|
||||
|
||||
# Or install via pnpm
|
||||
pnpm add -g skillkit`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Verify Installation</h3>
|
||||
<CodeBlock>{`skillkit --version
|
||||
skillkit --help`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">First Steps</h3>
|
||||
<CodeBlock>{`# Initialize SkillKit in your project
|
||||
skillkit init
|
||||
|
||||
# Browse available skills
|
||||
skillkit marketplace
|
||||
|
||||
# Get AI-powered recommendations
|
||||
skillkit recommend
|
||||
|
||||
# Install skills from a source
|
||||
skillkit install anthropics/skills`}</CodeBlock>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'architecture',
|
||||
title: 'Architecture',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<p className="text-zinc-300">
|
||||
SkillKit employs a three-tier design with clean separation of concerns:
|
||||
</p>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">System Tiers</h3>
|
||||
<ul className="list-disc list-inside space-y-2 text-zinc-400">
|
||||
<li><span className="text-white">UI Tier</span> - CLI commands, Terminal UI (OpenTUI-based), and documentation website</li>
|
||||
<li><span className="text-white">Core Logic Tier</span> - @skillkit/core for business logic; @skillkit/agents for adapter implementations</li>
|
||||
<li><span className="text-white">Integration Tier</span> - File systems, Git repositories, marketplace APIs, and 17+ AI agents</li>
|
||||
</ul>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Monorepo Structure</h3>
|
||||
<CodeBlock language="text">{`skillkit-monorepo (pnpm workspace + Turbo)
|
||||
├── apps/skillkit/ → Main CLI application (bin: skillkit, sk)
|
||||
├── packages/core/ → Core business logic (no internal dependencies)
|
||||
├── packages/agents/ → Agent adapters (depends on core)
|
||||
├── packages/cli/ → Command implementations (depends on core, agents, tui)
|
||||
├── packages/tui/ → Terminal UI (depends on core, agents)
|
||||
└── docs/skillkit/ → Documentation website`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Dependency Hierarchy</h3>
|
||||
<ul className="list-disc list-inside space-y-2 text-zinc-400">
|
||||
<li><code className="text-emerald-400">@skillkit/core</code> → Foundation (no SkillKit dependencies)</li>
|
||||
<li><code className="text-emerald-400">@skillkit/agents</code> → Adapters (depends on core)</li>
|
||||
<li><code className="text-emerald-400">@skillkit/cli</code>, <code className="text-emerald-400">@skillkit/tui</code> → UIs (depend on core and agents)</li>
|
||||
<li><code className="text-emerald-400">skillkit</code> app → Orchestrates all packages</li>
|
||||
</ul>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'agents',
|
||||
title: 'Supported Agents',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<p className="text-zinc-300">
|
||||
SkillKit supports 17+ AI coding agents with automatic format translation:
|
||||
</p>
|
||||
|
||||
<Table
|
||||
headers={['Agent', 'Directory', 'Format']}
|
||||
rows={[
|
||||
['Claude Code', '.claude/skills/', 'SKILL.md'],
|
||||
['Cursor', '.cursor/skills/', '.mdc'],
|
||||
['GitHub Copilot', '.github/skills/', 'Markdown'],
|
||||
['Gemini CLI', '.gemini/skills/', 'SKILL.md'],
|
||||
['Windsurf', '.windsurf/skills/', 'Markdown'],
|
||||
['Codex', '.codex/skills/', 'SKILL.md'],
|
||||
['OpenCode', '.opencode/skills/', 'SKILL.md'],
|
||||
['Antigravity', '.antigravity/skills/', 'SKILL.md'],
|
||||
['Amp', '.amp/skills/', 'SKILL.md'],
|
||||
['Clawdbot', '.clawdbot/skills/', 'SKILL.md'],
|
||||
['Droid', '.droid/skills/', 'SKILL.md'],
|
||||
['Goose', '.goose/skills/', 'SKILL.md'],
|
||||
['Kilo', '.kilo/skills/', 'SKILL.md'],
|
||||
['Kiro CLI', '.kiro/skills/', 'SKILL.md'],
|
||||
['Roo', '.roo/skills/', 'SKILL.md'],
|
||||
['Trae', '.trae/skills/', 'SKILL.md'],
|
||||
['Universal', 'skills/', 'SKILL.md'],
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'commands',
|
||||
title: 'CLI Commands',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold text-white">Skill Management</h3>
|
||||
<CodeBlock>{`skillkit install <source> # Install skills from source
|
||||
skillkit remove <skill> # Remove installed skill
|
||||
skillkit update [skill] # Update skills
|
||||
skillkit list # List installed skills
|
||||
skillkit sync # Sync skills across agents
|
||||
skillkit enable <skill> # Enable a skill
|
||||
skillkit disable <skill> # Disable a skill`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Discovery</h3>
|
||||
<CodeBlock>{`skillkit recommend # AI-powered skill recommendations
|
||||
skillkit marketplace # Browse marketplace skills
|
||||
skillkit find <query> # Search for skills
|
||||
skillkit search <term> # Search skill content`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Translation</h3>
|
||||
<CodeBlock>{`skillkit translate --from claude --to cursor <skill>
|
||||
skillkit agent translate <skill> --target cursor
|
||||
skillkit context sync # Sync context across agents`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Team Collaboration</h3>
|
||||
<CodeBlock>{`skillkit manifest init # Initialize .skills manifest
|
||||
skillkit manifest add <source> # Add source to manifest
|
||||
skillkit manifest install # Install from manifest
|
||||
skillkit publish # Publish skill to marketplace
|
||||
skillkit cicd init # Setup CI/CD integration`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Advanced</h3>
|
||||
<CodeBlock>{`skillkit ui # Launch Terminal UI
|
||||
skillkit workflow # Manage workflows
|
||||
skillkit memory compress # Compress memory
|
||||
skillkit memory export # Export memory
|
||||
skillkit test # Run skill tests
|
||||
skillkit validate # Validate skill format & quality`}</CodeBlock>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'configuration',
|
||||
title: 'Configuration',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold text-white">Project Configuration (skillkit.yaml)</h3>
|
||||
<CodeBlock language="yaml">{`version: 1
|
||||
agent: cursor
|
||||
autoSync: true
|
||||
enabledSkills:
|
||||
- pdf
|
||||
- xlsx
|
||||
disabledSkills:
|
||||
- deprecated-skill`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Team Manifest (.skills)</h3>
|
||||
<CodeBlock>{`# Team-wide skill sources
|
||||
anthropics/skills
|
||||
vercel-labs/agent-skills
|
||||
./local-skills
|
||||
owner/repo@v1.2.3`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">User Preferences (~/.skillkit/preferences.json)</h3>
|
||||
<CodeBlock language="json">{`{
|
||||
"lastSelectedAgents": ["claude", "cursor"],
|
||||
"autoSync": true,
|
||||
"marketplace": {
|
||||
"lastRefresh": "2024-01-01T00:00:00Z"
|
||||
}
|
||||
}`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">File System Layout</h3>
|
||||
<CodeBlock language="text">{`project/
|
||||
├── .skillkit/ # Project config & memory
|
||||
├── .claude/skills/ # Claude Code skills
|
||||
├── .cursor/skills/ # Cursor AI skills
|
||||
├── .github/skills/ # GitHub Copilot skills
|
||||
├── skills/ # Universal format
|
||||
└── .skills # Team manifest file
|
||||
|
||||
~/.skillkit/ # Global user config
|
||||
├── preferences.json
|
||||
├── memory/
|
||||
└── cache/`}</CodeBlock>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'api',
|
||||
title: 'API Reference',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold text-white">Package Exports</h3>
|
||||
<p className="text-zinc-300">@skillkit/core provides multiple entry points for programmatic use:</p>
|
||||
|
||||
<CodeBlock language="typescript">{`import { findAllSkills, findSkill } from '@skillkit/core/discovery';
|
||||
import { parseSkillFile } from '@skillkit/core/parser';
|
||||
import { translateSkill } from '@skillkit/core/translator';
|
||||
import { syncContext } from '@skillkit/core/context';
|
||||
import { getRecommendations } from '@skillkit/core/recommend';
|
||||
import { evaluateSkillContent, getQualityGrade } from '@skillkit/core/quality';`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Core Functions</h3>
|
||||
<CodeBlock language="typescript">{`// Discovery
|
||||
findAllSkills(searchDirs: string[]): SkillInfo[]
|
||||
findSkill(name: string, searchDirs: string[]): SkillInfo | null
|
||||
|
||||
// Parsing
|
||||
parseSkillFile(filePath: string): ParsedSkill
|
||||
parseSkillContent(content: string): ParsedSkill
|
||||
|
||||
// Translation
|
||||
translateSkill(skill: ParsedSkill, targetAgent: AgentType): string
|
||||
getAgentAdapter(agent: AgentType): AgentAdapter
|
||||
|
||||
// Quality Evaluation
|
||||
evaluateSkillContent(content: string): QualityScore
|
||||
evaluateSkillFile(filePath: string): QualityScore
|
||||
getQualityGrade(score: number): 'A' | 'B' | 'C' | 'D' | 'F'
|
||||
isHighQuality(score: QualityScore): boolean
|
||||
|
||||
// Recommendations
|
||||
getRecommendations(context: ProjectContext): Recommendation[]`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Type Definitions</h3>
|
||||
<CodeBlock language="typescript">{`interface SkillInfo {
|
||||
name: string;
|
||||
path: string;
|
||||
agent: AgentType;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
interface ParsedSkill {
|
||||
name: string;
|
||||
description?: string;
|
||||
globs?: string[];
|
||||
triggers?: string[];
|
||||
content: string;
|
||||
frontmatter: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface QualityScore {
|
||||
overall: number;
|
||||
structure: StructureScore;
|
||||
clarity: ClarityScore;
|
||||
specificity: SpecificityScore;
|
||||
advanced: AdvancedScore;
|
||||
warnings: string[];
|
||||
suggestions: string[];
|
||||
}
|
||||
|
||||
type AgentType =
|
||||
| 'claude-code' | 'cursor' | 'codex' | 'gemini-cli'
|
||||
| 'opencode' | 'antigravity' | 'amp' | 'clawdbot'
|
||||
| 'droid' | 'github-copilot' | 'goose' | 'kilo'
|
||||
| 'kiro-cli' | 'roo' | 'trae' | 'windsurf' | 'universal';`}</CodeBlock>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'skill-format',
|
||||
title: 'Skill Format',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold text-white">SKILL.md Structure</h3>
|
||||
<p className="text-zinc-300">Skills use YAML frontmatter followed by markdown content:</p>
|
||||
|
||||
<CodeBlock language="markdown">{`---
|
||||
name: my-skill
|
||||
description: A helpful skill for coding tasks
|
||||
globs:
|
||||
- "**/*.ts"
|
||||
- "**/*.tsx"
|
||||
triggers:
|
||||
- "when working with TypeScript"
|
||||
- "when creating React components"
|
||||
---
|
||||
|
||||
# My Skill
|
||||
|
||||
## When to Use
|
||||
|
||||
Use this skill when:
|
||||
- Working with TypeScript files
|
||||
- Creating React components
|
||||
|
||||
## Instructions
|
||||
|
||||
Follow these guidelines:
|
||||
|
||||
1. Always use TypeScript strict mode
|
||||
2. Prefer functional components
|
||||
|
||||
\`\`\`typescript
|
||||
function Example(): JSX.Element {
|
||||
return <div>Hello</div>;
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## Boundaries
|
||||
|
||||
This skill should NOT:
|
||||
- Modify configuration files without asking
|
||||
- Delete existing code without confirmation`}</CodeBlock>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Quality Scoring</h3>
|
||||
<p className="text-zinc-300">Skills are evaluated on four dimensions:</p>
|
||||
<Table
|
||||
headers={['Dimension', 'Weight', 'Criteria']}
|
||||
rows={[
|
||||
['Structure', '35%', 'Metadata, description, triggers, examples, boundaries'],
|
||||
['Clarity', '25%', 'Line count, token count, headers, readability'],
|
||||
['Specificity', '25%', 'Concrete commands, file patterns, code examples'],
|
||||
['Advanced', '15%', 'No deprecated patterns, security issues, completeness'],
|
||||
]}
|
||||
/>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Grade Scale</h3>
|
||||
<Table
|
||||
headers={['Grade', 'Score Range', 'Description']}
|
||||
rows={[
|
||||
['A', '90-100', 'Excellent - Production ready'],
|
||||
['B', '80-89', 'Good - Minor improvements possible'],
|
||||
['C', '70-79', 'Acceptable - Some issues to address'],
|
||||
['D', '60-69', 'Poor - Significant improvements needed'],
|
||||
['F', '0-59', 'Failing - Major revision required'],
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'tech-stack',
|
||||
title: 'Technology Stack',
|
||||
content: (
|
||||
<div className="space-y-4">
|
||||
<Table
|
||||
headers={['Layer', 'Technology']}
|
||||
rows={[
|
||||
['CLI Framework', 'Clipanion v4'],
|
||||
['TUI Framework', '@opentui/react v0.1.75'],
|
||||
['Validation', 'Zod v3.24'],
|
||||
['YAML Parsing', 'yaml v2.6'],
|
||||
['Git Operations', 'isomorphic-git v1.27'],
|
||||
['HTTP Client', 'got v14.4'],
|
||||
['Build System', 'Turbo v2.3, tsup v8.3, pnpm v9.0'],
|
||||
['Testing', 'Vitest v2.1'],
|
||||
['Runtime', 'Node.js 18+, Bun 1.2+ (for TUI)'],
|
||||
]}
|
||||
/>
|
||||
|
||||
<h3 className="text-lg font-semibold text-white mt-6">Build Commands</h3>
|
||||
<CodeBlock>{`pnpm build # Build all packages via Turbo
|
||||
pnpm dev # Watch mode development
|
||||
pnpm test # Unit tests via Vitest
|
||||
pnpm test:e2e # End-to-end tests
|
||||
pnpm typecheck # Type checking
|
||||
pnpm clean # Remove build artifacts`}</CodeBlock>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export function Documentation(): React.ReactElement {
|
||||
const [activeSection, setActiveSection] = useState('overview');
|
||||
|
||||
const currentSection = sections.find(s => s.id === activeSection) || sections[0];
|
||||
|
||||
return (
|
||||
<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">Documentation</h2>
|
||||
<p className="text-zinc-400 font-mono text-sm">
|
||||
Complete guide to using SkillKit
|
||||
</p>
|
||||
<a
|
||||
href="https://deepwiki.com/rohitg00/skillkit"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-2 mt-2 text-xs text-zinc-500 hover:text-zinc-300 transition-colors"
|
||||
>
|
||||
<span>Powered by DeepWiki</span>
|
||||
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<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="flex flex-col lg:flex-row gap-8">
|
||||
<nav className="lg:w-48 flex-shrink-0">
|
||||
<div className="sticky top-20 space-y-1">
|
||||
{sections.map(section => (
|
||||
<button
|
||||
key={section.id}
|
||||
onClick={() => setActiveSection(section.id)}
|
||||
className={`w-full text-left px-3 py-2 text-sm font-mono rounded transition-colors ${
|
||||
activeSection === section.id
|
||||
? 'bg-white text-black'
|
||||
: 'text-zinc-400 hover:text-white hover:bg-zinc-800'
|
||||
}`}
|
||||
>
|
||||
{section.title}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="bg-surface border border-zinc-800 rounded-lg p-6">
|
||||
<h2 className="text-xl font-bold text-white mb-6 font-mono">{currentSection.title}</h2>
|
||||
<div className="prose prose-invert prose-zinc max-w-none">
|
||||
{currentSection.content}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -92,6 +92,12 @@
|
||||
]
|
||||
},
|
||||
"description": "Compatible AI agents (omit for universal compatibility)"
|
||||
},
|
||||
"quality": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 100,
|
||||
"description": "Pre-computed quality score (0-100). Verified sources default to 85."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join, resolve, basename } from 'node:path';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import {
|
||||
evaluateSkillFile,
|
||||
findAllSkills,
|
||||
type QualityScore,
|
||||
} from '@skillkit/core';
|
||||
import { getSearchDirs } from '../helpers.js';
|
||||
import {
|
||||
colors,
|
||||
symbols,
|
||||
success,
|
||||
warn,
|
||||
error,
|
||||
header,
|
||||
confirm,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
interface FixSuggestion {
|
||||
type: 'add' | 'replace' | 'format';
|
||||
description: string;
|
||||
original?: string;
|
||||
replacement: string;
|
||||
line?: number;
|
||||
automatic: boolean;
|
||||
}
|
||||
|
||||
const FRONTMATTER_TEMPLATE = `---
|
||||
name: {{NAME}}
|
||||
description: {{DESCRIPTION}}
|
||||
globs:
|
||||
- "**/*"
|
||||
---
|
||||
|
||||
`;
|
||||
|
||||
const WHEN_TO_USE_TEMPLATE = `
|
||||
## When to Use
|
||||
|
||||
Use this skill when:
|
||||
- [Add specific trigger conditions]
|
||||
- [Add relevant patterns to detect]
|
||||
|
||||
`;
|
||||
|
||||
const BOUNDARIES_TEMPLATE = `
|
||||
## Boundaries
|
||||
|
||||
This skill should NOT:
|
||||
- [Add constraints and limitations]
|
||||
- [Specify what the agent should never do]
|
||||
|
||||
`;
|
||||
|
||||
const VAGUE_TERM_REPLACEMENTS: Record<string, string> = {
|
||||
'be helpful': 'follow the specific instructions below',
|
||||
'assist the user': 'complete the requested task',
|
||||
'help with': 'handle',
|
||||
'try to': '',
|
||||
'attempt to': '',
|
||||
'do your best': 'follow these guidelines',
|
||||
'as needed': 'when the following conditions are met',
|
||||
'when appropriate': 'when',
|
||||
'if necessary': 'when required',
|
||||
'general purpose': 'designed for',
|
||||
'various tasks': 'the following tasks',
|
||||
'many things': 'the following',
|
||||
'etc.': '',
|
||||
'and so on': '',
|
||||
'stuff like that': '',
|
||||
};
|
||||
|
||||
function generateFixes(content: string, quality: QualityScore, skillName: string): FixSuggestion[] {
|
||||
const fixes: FixSuggestion[] = [];
|
||||
|
||||
if (!quality.structure.hasMetadata) {
|
||||
const template = FRONTMATTER_TEMPLATE
|
||||
.replace('{{NAME}}', skillName)
|
||||
.replace('{{DESCRIPTION}}', 'Add a description for this skill');
|
||||
fixes.push({
|
||||
type: 'add',
|
||||
description: 'Add YAML frontmatter template',
|
||||
replacement: template,
|
||||
automatic: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (!quality.structure.hasTriggers && !quality.structure.hasWhenToUse) {
|
||||
fixes.push({
|
||||
type: 'add',
|
||||
description: 'Add "When to Use" section scaffold',
|
||||
replacement: WHEN_TO_USE_TEMPLATE,
|
||||
automatic: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (!quality.structure.hasBoundaries) {
|
||||
fixes.push({
|
||||
type: 'add',
|
||||
description: 'Add "Boundaries" section scaffold',
|
||||
replacement: BOUNDARIES_TEMPLATE,
|
||||
automatic: true,
|
||||
});
|
||||
}
|
||||
|
||||
for (const [vague, replacement] of Object.entries(VAGUE_TERM_REPLACEMENTS)) {
|
||||
const escaped = vague.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const regex = new RegExp(escaped, 'gi');
|
||||
if (regex.test(content)) {
|
||||
fixes.push({
|
||||
type: 'replace',
|
||||
description: `Replace vague term "${vague}"`,
|
||||
original: vague,
|
||||
replacement: replacement || '[be specific]',
|
||||
automatic: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const codeBlockPattern = /```(\s*\n[\s\S]*?```)/g;
|
||||
let match;
|
||||
while ((match = codeBlockPattern.exec(content)) !== null) {
|
||||
if (match[1].startsWith('\n') && !content.slice(match.index, match.index + 10).match(/```\w/)) {
|
||||
fixes.push({
|
||||
type: 'format',
|
||||
description: 'Add language tag to code block',
|
||||
original: '```',
|
||||
replacement: '```typescript',
|
||||
automatic: false,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fixes;
|
||||
}
|
||||
|
||||
function applyFixes(content: string, fixes: FixSuggestion[]): string {
|
||||
let result = content;
|
||||
|
||||
const hasFrontmatter = /^---\s*\n/.test(content);
|
||||
|
||||
for (const fix of fixes) {
|
||||
if (fix.type === 'add') {
|
||||
if (fix.description.includes('frontmatter') && !hasFrontmatter) {
|
||||
result = fix.replacement + result;
|
||||
} else if (fix.description.includes('When to Use') || fix.description.includes('Boundaries')) {
|
||||
result = result.trimEnd() + '\n' + fix.replacement;
|
||||
}
|
||||
} else if (fix.type === 'replace' && fix.original && fix.automatic) {
|
||||
const escaped = fix.original.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const regex = new RegExp(escaped, 'gi');
|
||||
result = result.replace(regex, fix.replacement);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export class FixCommand extends Command {
|
||||
static override paths = [['fix']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Automatically fix common skill quality issues',
|
||||
details: `
|
||||
The fix command analyzes skills and applies automatic fixes for common quality issues.
|
||||
|
||||
Fixes that can be automated:
|
||||
- Add missing YAML frontmatter template
|
||||
- Add "When to Use" section scaffold
|
||||
- Add "Boundaries" section scaffold
|
||||
- Format code blocks with language tags
|
||||
|
||||
Interactive mode prompts before each fix.
|
||||
`,
|
||||
examples: [
|
||||
['Fix a specific skill', '$0 fix my-skill'],
|
||||
['Fix skill file', '$0 fix ./path/to/SKILL.md'],
|
||||
['Preview fixes without applying', '$0 fix my-skill --dry-run'],
|
||||
['Apply all fixes without prompts', '$0 fix my-skill --yes'],
|
||||
],
|
||||
});
|
||||
|
||||
targets = Option.Rest();
|
||||
|
||||
dryRun = Option.Boolean('--dry-run,-d', false, {
|
||||
description: 'Show proposed changes without applying',
|
||||
});
|
||||
|
||||
yes = Option.Boolean('--yes,-y', false, {
|
||||
description: 'Apply all automatic fixes without prompting',
|
||||
});
|
||||
|
||||
interactive = Option.Boolean('--interactive,-i', {
|
||||
description: 'Prompt for each fix (default when not using --yes)',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const isInteractive = this.interactive !== false && !this.yes && !this.dryRun && process.stdin.isTTY;
|
||||
|
||||
if (this.targets.length === 0) {
|
||||
error('Please specify a skill to fix');
|
||||
console.log(colors.muted('Usage: skillkit fix <skill-name> or skillkit fix ./path/to/SKILL.md'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
header('Skill Quality Fixer');
|
||||
|
||||
let totalFixes = 0;
|
||||
let filesFixed = 0;
|
||||
|
||||
for (const target of this.targets) {
|
||||
const resolved = resolve(target);
|
||||
let filePath: string | null = null;
|
||||
let skillName = basename(target);
|
||||
|
||||
if (existsSync(resolved)) {
|
||||
if (resolved.endsWith('.md') || resolved.endsWith('.mdc')) {
|
||||
filePath = resolved;
|
||||
const fileName = basename(resolved);
|
||||
if (fileName.endsWith('.mdc')) {
|
||||
skillName = fileName.slice(0, -4);
|
||||
} else if (fileName.endsWith('.md')) {
|
||||
skillName = fileName.slice(0, -3);
|
||||
} else {
|
||||
skillName = fileName;
|
||||
}
|
||||
} else {
|
||||
const skillMd = join(resolved, 'SKILL.md');
|
||||
const indexMdc = join(resolved, 'index.mdc');
|
||||
if (existsSync(skillMd)) {
|
||||
filePath = skillMd;
|
||||
} else if (existsSync(indexMdc)) {
|
||||
filePath = indexMdc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const searchDirs = getSearchDirs();
|
||||
const skills = findAllSkills(searchDirs);
|
||||
const found = skills.find(s => s.name === target);
|
||||
if (found) {
|
||||
const skillMd = join(found.path, 'SKILL.md');
|
||||
const indexMdc = join(found.path, 'index.mdc');
|
||||
if (existsSync(skillMd)) {
|
||||
filePath = skillMd;
|
||||
} else if (existsSync(indexMdc)) {
|
||||
filePath = indexMdc;
|
||||
}
|
||||
skillName = found.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!filePath || !existsSync(filePath)) {
|
||||
warn(`Skill not found: ${target}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const content = readFileSync(filePath, 'utf-8');
|
||||
const quality = evaluateSkillFile(filePath);
|
||||
|
||||
if (!quality) {
|
||||
warn(`Could not evaluate: ${target}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log(colors.bold(skillName));
|
||||
console.log(colors.muted(`Score: ${quality.overall}/100`));
|
||||
|
||||
const fixes = generateFixes(content, quality, skillName);
|
||||
const automaticFixes = fixes.filter(f => f.automatic);
|
||||
const manualFixes = fixes.filter(f => !f.automatic);
|
||||
|
||||
if (fixes.length === 0) {
|
||||
console.log(colors.success(`${symbols.success} No automatic fixes needed`));
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log(colors.muted(`Found ${fixes.length} potential fix(es):`));
|
||||
|
||||
for (const fix of automaticFixes) {
|
||||
console.log(` ${colors.success(symbols.success)} ${fix.description} ${colors.muted('(automatic)')}`);
|
||||
}
|
||||
|
||||
for (const fix of manualFixes) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${fix.description} ${colors.muted('(manual review)')}`);
|
||||
}
|
||||
|
||||
if (this.dryRun) {
|
||||
console.log('');
|
||||
console.log(colors.muted('Dry run - no changes applied'));
|
||||
|
||||
if (automaticFixes.length > 0) {
|
||||
console.log('');
|
||||
console.log(colors.muted('Preview of automatic fixes:'));
|
||||
const preview = applyFixes(content, automaticFixes);
|
||||
const diff = generateDiff(content, preview);
|
||||
console.log(diff);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (automaticFixes.length > 0) {
|
||||
let shouldApply = this.yes;
|
||||
|
||||
if (isInteractive && !this.yes) {
|
||||
console.log('');
|
||||
const confirmResult = await confirm({
|
||||
message: `Apply ${automaticFixes.length} automatic fix(es)?`,
|
||||
initialValue: true,
|
||||
});
|
||||
shouldApply = confirmResult === true;
|
||||
}
|
||||
|
||||
if (shouldApply) {
|
||||
const fixed = applyFixes(content, automaticFixes);
|
||||
writeFileSync(filePath, fixed, 'utf-8');
|
||||
totalFixes += automaticFixes.length;
|
||||
filesFixed++;
|
||||
console.log(colors.success(`${symbols.success} Applied ${automaticFixes.length} fix(es)`));
|
||||
} else {
|
||||
console.log(colors.muted('Skipped'));
|
||||
}
|
||||
}
|
||||
|
||||
if (manualFixes.length > 0) {
|
||||
console.log('');
|
||||
console.log(colors.muted('Manual fixes required:'));
|
||||
for (const fix of manualFixes) {
|
||||
if (fix.original) {
|
||||
console.log(` ${colors.warning(symbols.bullet)} Replace "${fix.original}" with "${fix.replacement}"`);
|
||||
} else {
|
||||
console.log(` ${colors.warning(symbols.bullet)} ${fix.description}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
if (totalFixes > 0) {
|
||||
success(`Fixed ${totalFixes} issue(s) in ${filesFixed} file(s)`);
|
||||
console.log(colors.muted('Run "skillkit validate" to verify improvements'));
|
||||
} else if (!this.dryRun) {
|
||||
console.log(colors.muted('No fixes applied'));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function generateDiff(original: string, modified: string): string {
|
||||
const originalLines = original.split('\n');
|
||||
const modifiedLines = modified.split('\n');
|
||||
|
||||
const originalSet = new Set(originalLines);
|
||||
const modifiedSet = new Set(modifiedLines);
|
||||
|
||||
const added = modifiedLines.filter(line => !originalSet.has(line));
|
||||
const removed = originalLines.filter(line => !modifiedSet.has(line));
|
||||
|
||||
const diff: string[] = [];
|
||||
|
||||
for (const line of removed.slice(0, 5)) {
|
||||
diff.push(colors.error(`- ${line}`));
|
||||
}
|
||||
if (removed.length > 5) {
|
||||
diff.push(colors.muted(` ... and ${removed.length - 5} more removed`));
|
||||
}
|
||||
|
||||
for (const line of added.slice(0, 10)) {
|
||||
diff.push(colors.success(`+ ${line}`));
|
||||
}
|
||||
if (added.length > 10) {
|
||||
diff.push(colors.muted(` ... and ${added.length - 10} more added`));
|
||||
}
|
||||
|
||||
if (diff.length === 0) {
|
||||
diff.push(colors.muted(' (no visible changes)'));
|
||||
}
|
||||
|
||||
return diff.join('\n');
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export { RemoveCommand } from './remove.js';
|
||||
export { InstallCommand } from './install.js';
|
||||
export { UpdateCommand } from './update.js';
|
||||
export { ValidateCommand } from './validate.js';
|
||||
export { FixCommand } from './fix.js';
|
||||
export { CreateCommand } from './create.js';
|
||||
export { UICommand } from './ui.js';
|
||||
export { TranslateCommand } from './translate.js';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { existsSync, mkdirSync, cpSync, rmSync, symlinkSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { detectProvider, isLocalPath, getProvider } from '@skillkit/core';
|
||||
import { detectProvider, isLocalPath, getProvider, evaluateSkillDirectory } from '@skillkit/core';
|
||||
import type { SkillMetadata, GitProvider, AgentType } from '@skillkit/core';
|
||||
import { isPathInside } from '@skillkit/core';
|
||||
import { getAdapter, detectAgent, getAllAdapters } from '@skillkit/agents';
|
||||
@@ -28,6 +28,8 @@ import {
|
||||
showNextSteps,
|
||||
saveLastAgents,
|
||||
getLastAgents,
|
||||
formatQualityBadge,
|
||||
getQualityGradeFromScore,
|
||||
type InstallResult,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
@@ -135,7 +137,9 @@ export class InstallCommand extends Command {
|
||||
console.log(colors.bold('Available skills:'));
|
||||
console.log('');
|
||||
for (const skill of discoveredSkills) {
|
||||
console.log(` ${colors.success(symbols.stepActive)} ${colors.primary(skill.name)}`);
|
||||
const quality = evaluateSkillDirectory(skill.path);
|
||||
const qualityBadge = quality ? ` ${formatQualityBadge(quality.overall)}` : '';
|
||||
console.log(` ${colors.success(symbols.stepActive)} ${colors.primary(skill.name)}${qualityBadge}`);
|
||||
}
|
||||
console.log('');
|
||||
console.log(colors.muted(`Total: ${discoveredSkills.length} skill(s)`));
|
||||
@@ -237,9 +241,34 @@ export class InstallCommand extends Command {
|
||||
installMethod = methodResult as 'symlink' | 'copy';
|
||||
}
|
||||
|
||||
// Check for low-quality skills and warn
|
||||
const lowQualitySkills: Array<{ name: string; score: number; warnings: string[] }> = [];
|
||||
for (const skill of skillsToInstall) {
|
||||
const quality = evaluateSkillDirectory(skill.path);
|
||||
if (quality && quality.overall < 60) {
|
||||
lowQualitySkills.push({
|
||||
name: skill.name,
|
||||
score: quality.overall,
|
||||
warnings: quality.warnings.slice(0, 2),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm installation
|
||||
if (isInteractive && !this.yes) {
|
||||
console.log('');
|
||||
|
||||
// Show low-quality warning if any
|
||||
if (lowQualitySkills.length > 0) {
|
||||
console.log(colors.warning(`${symbols.warning} Warning: ${lowQualitySkills.length} skill(s) have low quality scores (< 60)`));
|
||||
for (const lq of lowQualitySkills) {
|
||||
const grade = getQualityGradeFromScore(lq.score);
|
||||
const warningText = lq.warnings.length > 0 ? ` - ${lq.warnings.join(', ')}` : '';
|
||||
console.log(colors.muted(` - ${lq.name} [${grade}]${warningText}`));
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
const agentDisplay = targetAgents.length <= 3
|
||||
? targetAgents.map(formatAgent).join(', ')
|
||||
: `${targetAgents.slice(0, 2).map(formatAgent).join(', ')} +${targetAgents.length - 2} more`;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import chalk from 'chalk';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { findAllSkills } from '@skillkit/core';
|
||||
import { findAllSkills, evaluateSkillDirectory } from '@skillkit/core';
|
||||
import { getSearchDirs } from '../helpers.js';
|
||||
import { formatQualityBadge, colors } from '../onboarding/index.js';
|
||||
|
||||
export class ListCommand extends Command {
|
||||
static override paths = [['list'], ['ls'], ['l']];
|
||||
@@ -23,6 +24,10 @@ export class ListCommand extends Command {
|
||||
description: 'Show only disabled skills',
|
||||
});
|
||||
|
||||
quality = Option.Boolean('--quality,-q', false, {
|
||||
description: 'Show quality scores and grades',
|
||||
});
|
||||
|
||||
json = Option.Boolean('--json,-j', false, {
|
||||
description: 'Output as JSON',
|
||||
});
|
||||
@@ -44,8 +49,18 @@ export class ListCommand extends Command {
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
const skillsWithQuality = this.quality || this.json
|
||||
? skills.map(s => {
|
||||
const quality = evaluateSkillDirectory(s.path);
|
||||
return {
|
||||
...s,
|
||||
quality: quality?.overall ?? null,
|
||||
};
|
||||
})
|
||||
: skills.map(s => ({ ...s, quality: null as number | null }));
|
||||
|
||||
if (this.json) {
|
||||
console.log(JSON.stringify(skills, null, 2));
|
||||
console.log(JSON.stringify(skillsWithQuality, null, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -57,13 +72,13 @@ export class ListCommand extends Command {
|
||||
|
||||
console.log(chalk.cyan(`Installed skills (${skills.length}):\n`));
|
||||
|
||||
const projectSkills = skills.filter(s => s.location === 'project');
|
||||
const globalSkills = skills.filter(s => s.location === 'global');
|
||||
const projectSkills = skillsWithQuality.filter(s => s.location === 'project');
|
||||
const globalSkills = skillsWithQuality.filter(s => s.location === 'global');
|
||||
|
||||
if (projectSkills.length > 0) {
|
||||
console.log(chalk.blue('Project skills:'));
|
||||
for (const skill of projectSkills) {
|
||||
printSkill(skill);
|
||||
printSkill(skill, this.quality);
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
@@ -71,7 +86,7 @@ export class ListCommand extends Command {
|
||||
if (globalSkills.length > 0) {
|
||||
console.log(chalk.dim('Global skills:'));
|
||||
for (const skill of globalSkills) {
|
||||
printSkill(skill);
|
||||
printSkill(skill, this.quality);
|
||||
}
|
||||
console.log();
|
||||
}
|
||||
@@ -86,16 +101,28 @@ export class ListCommand extends Command {
|
||||
)
|
||||
);
|
||||
|
||||
if (this.quality) {
|
||||
const qualityScores = skillsWithQuality.filter(s => s.quality !== null).map(s => s.quality!);
|
||||
if (qualityScores.length > 0) {
|
||||
const avgQuality = Math.round(qualityScores.reduce((a, b) => a + b, 0) / qualityScores.length);
|
||||
console.log(colors.muted(`Average quality: ${avgQuality}/100`));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function printSkill(skill: { name: string; description: string; enabled: boolean; location: string }) {
|
||||
function printSkill(
|
||||
skill: { name: string; description: string; enabled: boolean; location: string; quality: number | null },
|
||||
showQuality = false
|
||||
) {
|
||||
const status = skill.enabled ? chalk.green('✓') : chalk.red('○');
|
||||
const name = skill.enabled ? skill.name : chalk.dim(skill.name);
|
||||
const desc = chalk.dim(truncate(skill.description, 50));
|
||||
const qualityBadge = showQuality && skill.quality !== null ? ` ${formatQualityBadge(skill.quality)}` : '';
|
||||
|
||||
console.log(` ${status} ${name}`);
|
||||
console.log(` ${status} ${name}${qualityBadge}`);
|
||||
if (skill.description) {
|
||||
console.log(` ${desc}`);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
warn,
|
||||
showProjectSummary,
|
||||
progressBar,
|
||||
formatQualityBadge,
|
||||
getQualityGradeFromScore,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
export class RecommendCommand extends Command {
|
||||
@@ -236,8 +238,12 @@ export class RecommendCommand extends Command {
|
||||
scoreColor = colors.muted;
|
||||
}
|
||||
const scoreBar = progressBar(rec.score, 100, 10);
|
||||
const qualityScore = rec.skill.quality ?? null;
|
||||
const qualityDisplay = qualityScore !== null && qualityScore !== undefined
|
||||
? ` ${formatQualityBadge(qualityScore)}`
|
||||
: '';
|
||||
|
||||
console.log(` ${scoreColor(`${rec.score}%`)} ${colors.dim(scoreBar)} ${colors.bold(rec.skill.name)}`);
|
||||
console.log(` ${scoreColor(`${rec.score}%`)} ${colors.dim(scoreBar)} ${colors.bold(rec.skill.name)}${qualityDisplay}`);
|
||||
|
||||
if (rec.skill.description) {
|
||||
console.log(` ${colors.muted(truncate(rec.skill.description, 70))}`);
|
||||
@@ -252,6 +258,10 @@ export class RecommendCommand extends Command {
|
||||
for (const reason of rec.reasons.filter(r => r.weight > 0)) {
|
||||
console.log(` ${colors.muted(symbols.stepActive)} ${reason.description} (+${reason.weight})`);
|
||||
}
|
||||
if (qualityScore !== null && qualityScore !== undefined) {
|
||||
const grade = getQualityGradeFromScore(qualityScore);
|
||||
console.log(` ${colors.muted(symbols.stepActive)} Quality: ${qualityScore}/100 (${grade})`);
|
||||
}
|
||||
}
|
||||
|
||||
if (rec.warnings.length > 0) {
|
||||
|
||||
@@ -1,87 +1,441 @@
|
||||
import { existsSync, readdirSync } from 'node:fs';
|
||||
import { join, basename } from 'node:path';
|
||||
import chalk from 'chalk';
|
||||
import { existsSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join, basename, resolve, dirname } from 'node:path';
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { validateSkill } from '@skillkit/core';
|
||||
import {
|
||||
validateSkill,
|
||||
evaluateSkillFile,
|
||||
evaluateSkillDirectory,
|
||||
getQualityGrade,
|
||||
isHighQuality,
|
||||
findAllSkills,
|
||||
benchmarkSkill,
|
||||
type QualityScore,
|
||||
type BenchmarkResult,
|
||||
} from '@skillkit/core';
|
||||
import { getSearchDirs } from '../helpers.js';
|
||||
import {
|
||||
colors,
|
||||
symbols,
|
||||
spinner,
|
||||
success,
|
||||
warn,
|
||||
error,
|
||||
header,
|
||||
} from '../onboarding/index.js';
|
||||
|
||||
function formatScore(score: number): string {
|
||||
if (score >= 80) return colors.success(`${score}`);
|
||||
if (score >= 60) return colors.warning(`${score}`);
|
||||
return colors.error(`${score}`);
|
||||
}
|
||||
|
||||
function formatGrade(grade: string): string {
|
||||
switch (grade) {
|
||||
case 'A':
|
||||
case 'B':
|
||||
return colors.success(grade);
|
||||
case 'C':
|
||||
case 'D':
|
||||
return colors.warning(grade);
|
||||
default:
|
||||
return colors.error(grade);
|
||||
}
|
||||
}
|
||||
|
||||
function printQualityReport(name: string, quality: QualityScore, verbose: boolean): void {
|
||||
const grade = getQualityGrade(quality.overall);
|
||||
const gradeDisplay = formatGrade(grade);
|
||||
const scoreDisplay = formatScore(quality.overall);
|
||||
|
||||
console.log(`\n${colors.primary(name)}`);
|
||||
console.log(` Grade: ${gradeDisplay} Score: ${scoreDisplay}/100`);
|
||||
|
||||
if (verbose) {
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('Structure:')} ${formatScore(quality.structure.score)}/100`);
|
||||
console.log(` ${quality.structure.hasMetadata ? colors.success(symbols.success) : colors.error(symbols.error)} Metadata`);
|
||||
console.log(` ${quality.structure.hasDescription ? colors.success(symbols.success) : colors.error(symbols.error)} Description`);
|
||||
console.log(` ${quality.structure.hasTriggers ? colors.success(symbols.success) : colors.error(symbols.error)} Trigger conditions`);
|
||||
console.log(` ${quality.structure.hasExamples ? colors.success(symbols.success) : colors.error(symbols.error)} Code examples`);
|
||||
console.log(` ${quality.structure.hasBoundaries ? colors.success(symbols.success) : colors.error(symbols.error)} Boundaries defined`);
|
||||
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('Clarity:')} ${formatScore(quality.clarity.score)}/100`);
|
||||
console.log(` Lines: ${quality.clarity.lineCount}${quality.clarity.lineCount > 300 ? colors.warning(' (consider splitting)') : ''}`);
|
||||
console.log(` Tokens: ${quality.clarity.tokenCount}${quality.clarity.tokenCount > 2000 ? colors.warning(' (high)') : ''}`);
|
||||
console.log(` ${quality.clarity.hasHeaders ? colors.success(symbols.success) : colors.error(symbols.error)} Uses headers`);
|
||||
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('Specificity:')} ${formatScore(quality.specificity.score)}/100`);
|
||||
console.log(` ${quality.specificity.hasConcreteCommands ? colors.success(symbols.success) : colors.error(symbols.error)} Concrete commands`);
|
||||
console.log(` ${quality.specificity.hasFilePatterns ? colors.success(symbols.success) : colors.error(symbols.error)} File patterns`);
|
||||
console.log(` ${quality.specificity.hasCodeExamples ? colors.success(symbols.success) : colors.error(symbols.error)} Multiple code examples`);
|
||||
if (quality.specificity.vagueTermCount > 0) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${quality.specificity.vagueTermCount} vague term(s)`);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('Advanced:')} ${formatScore(quality.advanced.score)}/100`);
|
||||
if (quality.advanced.deprecatedPatterns.length > 0) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${quality.advanced.deprecatedPatterns.length} deprecated pattern(s)`);
|
||||
for (const pattern of quality.advanced.deprecatedPatterns) {
|
||||
console.log(` ${colors.muted(symbols.bullet)} ${pattern}`);
|
||||
}
|
||||
}
|
||||
if (quality.advanced.securityIssues.length > 0) {
|
||||
console.log(` ${colors.error(symbols.error)} ${quality.advanced.securityIssues.length} security issue(s)`);
|
||||
for (const issue of quality.advanced.securityIssues) {
|
||||
console.log(` ${colors.muted(symbols.bullet)} ${issue}`);
|
||||
}
|
||||
}
|
||||
if (quality.advanced.conflictingInstructions.length > 0) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${quality.advanced.conflictingInstructions.length} conflicting instruction(s)`);
|
||||
}
|
||||
console.log(` Completeness: ${quality.advanced.completeness.score}/100`);
|
||||
console.log(` Example coverage: ${quality.advanced.completeness.exampleCoverage}%`);
|
||||
if (quality.advanced.completeness.hasTodos) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${quality.advanced.completeness.todoCount} TODO/FIXME comment(s)`);
|
||||
}
|
||||
}
|
||||
|
||||
if (quality.warnings.length > 0) {
|
||||
console.log('');
|
||||
console.log(` ${colors.warning('Warnings:')}`);
|
||||
for (const w of quality.warnings) {
|
||||
console.log(` ${colors.warning(symbols.warning)} ${w}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (quality.suggestions.length > 0 && verbose) {
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('Suggestions:')}`);
|
||||
for (const s of quality.suggestions) {
|
||||
console.log(` ${colors.muted(symbols.bullet)} ${s}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function printBenchmarkReport(benchmark: BenchmarkResult): void {
|
||||
console.log('');
|
||||
console.log(colors.bold('Benchmark Comparison'));
|
||||
console.log('');
|
||||
|
||||
console.log(` ${colors.muted('Your Score:')} ${formatScore(benchmark.score)}/100 ${formatGrade(benchmark.grade)}`);
|
||||
console.log(` ${colors.muted('Category Average:')} ${benchmark.categoryAvg}/100`);
|
||||
console.log(` ${colors.muted('Top Skill Score:')} ${benchmark.topSkillScore}/100`);
|
||||
console.log(` ${colors.muted('Percentile:')} ${benchmark.percentile}${getOrdinal(benchmark.percentile)}`);
|
||||
|
||||
if (benchmark.comparisonNotes.length > 0) {
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('Comparison:')}`);
|
||||
for (const note of benchmark.comparisonNotes) {
|
||||
console.log(` ${colors.muted(symbols.bullet)} ${note}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (benchmark.recommendations.length > 0) {
|
||||
console.log('');
|
||||
console.log(` ${colors.muted('To Improve:')}`);
|
||||
for (const rec of benchmark.recommendations) {
|
||||
console.log(` ${colors.info(symbols.info)} ${rec}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getOrdinal(n: number): string {
|
||||
const s = ['th', 'st', 'nd', 'rd'];
|
||||
const v = n % 100;
|
||||
return s[(v - 20) % 10] || s[v] || s[0];
|
||||
}
|
||||
|
||||
export class ValidateCommand extends Command {
|
||||
static override paths = [['validate'], ['v']];
|
||||
static override paths = [['validate']];
|
||||
|
||||
static override usage = Command.Usage({
|
||||
description: 'Validate skill(s) against the Agent Skills specification (agentskills.io)',
|
||||
description: 'Validate skill format and quality',
|
||||
details: `
|
||||
Validates skills against the specification and evaluates quality.
|
||||
Quality scores are based on structure, clarity, and specificity.
|
||||
`,
|
||||
examples: [
|
||||
['Validate a skill directory', '$0 validate ./my-skill'],
|
||||
['Validate all skills in a directory', '$0 validate ./skills --all'],
|
||||
['Validate all installed skills', '$0 validate'],
|
||||
['Validate specific skill', '$0 validate my-skill'],
|
||||
['Validate skill file', '$0 validate ./path/to/SKILL.md'],
|
||||
['Detailed quality report', '$0 validate --verbose'],
|
||||
['Only show issues', '$0 validate --issues'],
|
||||
['Quality check only', '$0 validate --quality'],
|
||||
['JSON output', '$0 validate --json'],
|
||||
],
|
||||
});
|
||||
|
||||
skillPath = Option.String({ required: true });
|
||||
targets = Option.Rest();
|
||||
|
||||
verbose = Option.Boolean('--verbose,-v', false, {
|
||||
description: 'Show detailed quality breakdown',
|
||||
});
|
||||
|
||||
quality = Option.Boolean('--quality,-q', false, {
|
||||
description: 'Only check quality (skip format validation)',
|
||||
});
|
||||
|
||||
issues = Option.Boolean('--issues,-i', false, {
|
||||
description: 'Only show skills with issues',
|
||||
});
|
||||
|
||||
minScore = Option.String('--min-score,-m', {
|
||||
description: 'Minimum acceptable score (default: 60)',
|
||||
});
|
||||
|
||||
json = Option.Boolean('--json', false, {
|
||||
description: 'Output as JSON',
|
||||
});
|
||||
|
||||
all = Option.Boolean('--all,-a', false, {
|
||||
description: 'Validate all skills in the directory',
|
||||
description: 'Validate all skills in directory',
|
||||
});
|
||||
|
||||
benchmark = Option.Boolean('--benchmark,-b', false, {
|
||||
description: 'Compare skill against category leaders',
|
||||
});
|
||||
|
||||
fix = Option.Boolean('--fix', false, {
|
||||
description: 'Automatically fix common quality issues (runs fix command)',
|
||||
});
|
||||
|
||||
async execute(): Promise<number> {
|
||||
const targetPath = this.skillPath;
|
||||
|
||||
if (!existsSync(targetPath)) {
|
||||
console.error(chalk.red(`Path does not exist: ${targetPath}`));
|
||||
return 1;
|
||||
if (this.fix) {
|
||||
if (this.targets.length === 0) {
|
||||
error('--fix requires at least one target');
|
||||
console.log(colors.muted('Usage: skillkit validate --fix <skill-name>'));
|
||||
return 1;
|
||||
}
|
||||
const { FixCommand } = await import('./fix.js');
|
||||
const fixCmd = new FixCommand();
|
||||
fixCmd.targets = this.targets;
|
||||
fixCmd.yes = false;
|
||||
return fixCmd.execute();
|
||||
}
|
||||
|
||||
const skillPaths: string[] = [];
|
||||
let minScore = 60;
|
||||
if (this.minScore) {
|
||||
const parsed = parseInt(this.minScore, 10);
|
||||
if (Number.isNaN(parsed) || parsed < 0 || parsed > 100) {
|
||||
if (!this.json) {
|
||||
warn(`Invalid --min-score value "${this.minScore}", using default: 60`);
|
||||
}
|
||||
} else {
|
||||
minScore = parsed;
|
||||
}
|
||||
}
|
||||
const results: Array<{ name: string; quality: QualityScore | null; formatValid: boolean; formatErrors: string[]; path?: string }> = [];
|
||||
|
||||
if (this.all) {
|
||||
const entries = readdirSync(targetPath, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isDirectory()) {
|
||||
const skillPath = join(targetPath, entry.name);
|
||||
if (existsSync(join(skillPath, 'SKILL.md'))) {
|
||||
skillPaths.push(skillPath);
|
||||
if (this.targets.length > 0) {
|
||||
for (const target of this.targets) {
|
||||
const resolved = resolve(target);
|
||||
|
||||
if (existsSync(resolved)) {
|
||||
const isDirectory = statSync(resolved).isDirectory();
|
||||
if (this.all) {
|
||||
if (!isDirectory) {
|
||||
if (!this.json) {
|
||||
warn(`--all requires a directory, but "${target}" is a file`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const entries = readdirSync(resolved, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isDirectory()) {
|
||||
const skillPath = join(resolved, entry.name);
|
||||
const hasSkillMd = existsSync(join(skillPath, 'SKILL.md'));
|
||||
const hasIndexMdc = existsSync(join(skillPath, 'index.mdc'));
|
||||
const hasNamedMdc = existsSync(join(skillPath, `${entry.name}.mdc`));
|
||||
if (hasSkillMd || hasIndexMdc || hasNamedMdc) {
|
||||
const formatResult = this.quality ? { valid: true, errors: [] } : validateSkill(skillPath);
|
||||
const quality = evaluateSkillDirectory(skillPath);
|
||||
results.push({
|
||||
name: entry.name,
|
||||
quality,
|
||||
formatValid: formatResult.valid,
|
||||
formatErrors: formatResult.errors || [],
|
||||
path: skillPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const isFile = resolved.endsWith('.md') || resolved.endsWith('.mdc');
|
||||
const skillDir = isFile ? dirname(resolved) : resolved;
|
||||
const formatResult = this.quality ? { valid: true, errors: [] } : validateSkill(skillDir);
|
||||
const quality = isFile ? evaluateSkillFile(resolved) : evaluateSkillDirectory(resolved);
|
||||
results.push({
|
||||
name: basename(target),
|
||||
quality,
|
||||
formatValid: formatResult.valid,
|
||||
formatErrors: formatResult.errors || [],
|
||||
path: resolved,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const searchDirs = getSearchDirs();
|
||||
const skills = findAllSkills(searchDirs);
|
||||
const found = skills.find(s => s.name === target);
|
||||
|
||||
if (found) {
|
||||
const formatResult = this.quality ? { valid: true, errors: [] } : validateSkill(found.path);
|
||||
const quality = evaluateSkillDirectory(found.path);
|
||||
results.push({
|
||||
name: found.name,
|
||||
quality,
|
||||
formatValid: formatResult.valid,
|
||||
formatErrors: formatResult.errors || [],
|
||||
path: found.path,
|
||||
});
|
||||
} else {
|
||||
if (!this.json) {
|
||||
warn(`Skill not found: ${target}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (skillPaths.length === 0) {
|
||||
console.error(chalk.yellow('No skills found in directory'));
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
skillPaths.push(targetPath);
|
||||
}
|
||||
const searchDirs = getSearchDirs();
|
||||
const skills = findAllSkills(searchDirs);
|
||||
|
||||
let hasErrors = false;
|
||||
|
||||
for (const skillPath of skillPaths) {
|
||||
const skillName = basename(skillPath);
|
||||
const result = validateSkill(skillPath);
|
||||
|
||||
if (result.valid) {
|
||||
console.log(chalk.green(`✓ ${skillName}`));
|
||||
|
||||
if (result.warnings && result.warnings.length > 0) {
|
||||
result.warnings.forEach(w => {
|
||||
console.log(chalk.yellow(` ⚠ ${w}`));
|
||||
});
|
||||
if (skills.length === 0) {
|
||||
if (!this.json) {
|
||||
warn('No installed skills found');
|
||||
}
|
||||
} else {
|
||||
console.log(chalk.red(`✗ ${skillName}`));
|
||||
result.errors.forEach(e => {
|
||||
console.log(chalk.red(` • ${e}`));
|
||||
return 0;
|
||||
}
|
||||
|
||||
const s = spinner();
|
||||
if (!this.json) {
|
||||
s.start(`Evaluating ${skills.length} skill(s)...`);
|
||||
}
|
||||
|
||||
for (const skill of skills) {
|
||||
const formatResult = this.quality ? { valid: true, errors: [] } : validateSkill(skill.path);
|
||||
const quality = evaluateSkillDirectory(skill.path);
|
||||
results.push({
|
||||
name: skill.name,
|
||||
quality,
|
||||
formatValid: formatResult.valid,
|
||||
formatErrors: formatResult.errors || [],
|
||||
path: skill.path,
|
||||
});
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
if (!this.json) {
|
||||
s.stop(`Evaluated ${results.length} skill(s)`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log();
|
||||
|
||||
if (hasErrors) {
|
||||
console.log(chalk.red('Validation failed'));
|
||||
console.log(chalk.dim('See https://agentskills.io/specification for the complete format'));
|
||||
if (results.length === 0) {
|
||||
if (!this.json) {
|
||||
error('No skills to validate');
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.log(chalk.green(`Validated ${skillPaths.length} skill(s) successfully`));
|
||||
if (this.json) {
|
||||
const output = results.map(r => {
|
||||
const result: Record<string, unknown> = {
|
||||
name: r.name,
|
||||
path: r.path,
|
||||
formatValid: r.formatValid,
|
||||
formatErrors: r.formatErrors,
|
||||
score: r.quality?.overall ?? null,
|
||||
grade: r.quality ? getQualityGrade(r.quality.overall) : null,
|
||||
highQuality: r.quality ? isHighQuality(r.quality) : false,
|
||||
structure: r.quality?.structure ?? null,
|
||||
clarity: r.quality?.clarity ?? null,
|
||||
specificity: r.quality?.specificity ?? null,
|
||||
advanced: r.quality?.advanced ?? null,
|
||||
warnings: r.quality?.warnings ?? [],
|
||||
suggestions: r.quality?.suggestions ?? [],
|
||||
};
|
||||
if (this.benchmark && r.quality) {
|
||||
result.benchmark = benchmarkSkill(r.name, r.quality);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
console.log(JSON.stringify(output, null, 2));
|
||||
const hasFormatFailures = results.some(r => !r.formatValid);
|
||||
const hasBelowThreshold = results.some(r => r.quality && r.quality.overall < minScore);
|
||||
return hasFormatFailures || hasBelowThreshold ? 1 : 0;
|
||||
}
|
||||
|
||||
header('Skill Validation Report');
|
||||
|
||||
let filteredResults = results;
|
||||
if (this.issues) {
|
||||
filteredResults = results.filter(r =>
|
||||
!r.formatValid ||
|
||||
(r.quality && r.quality.overall < minScore) ||
|
||||
(r.quality && r.quality.warnings.length > 0)
|
||||
);
|
||||
}
|
||||
|
||||
filteredResults.sort((a, b) => (b.quality?.overall ?? 0) - (a.quality?.overall ?? 0));
|
||||
|
||||
for (const { name, quality, formatValid, formatErrors } of filteredResults) {
|
||||
if (!formatValid) {
|
||||
console.log(`\n${colors.error(symbols.error)} ${colors.primary(name)}`);
|
||||
console.log(` ${colors.error('Format validation failed:')}`);
|
||||
for (const err of formatErrors) {
|
||||
console.log(` ${colors.error(symbols.bullet)} ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (quality) {
|
||||
printQualityReport(name, quality, this.verbose);
|
||||
|
||||
if (this.benchmark) {
|
||||
const benchmark = benchmarkSkill(name, quality);
|
||||
printBenchmarkReport(benchmark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
const formatFailed = results.filter(r => !r.formatValid).length;
|
||||
const withQuality = results.filter(r => r.quality !== null);
|
||||
const highQuality = withQuality.filter(r => r.quality!.overall >= 80).length;
|
||||
const passing = withQuality.filter(r => r.quality!.overall >= minScore).length;
|
||||
const failing = withQuality.filter(r => r.quality!.overall < minScore).length;
|
||||
|
||||
console.log(colors.muted('Summary:'));
|
||||
|
||||
if (!this.quality) {
|
||||
console.log(` ${formatFailed === 0 ? colors.success(symbols.success) : colors.error(symbols.error)} Format valid: ${results.length - formatFailed}/${results.length}`);
|
||||
}
|
||||
|
||||
console.log(` ${colors.success(symbols.success)} High quality (80+): ${highQuality}`);
|
||||
console.log(` ${colors.primary(symbols.bullet)} Passing (${minScore}+): ${passing}`);
|
||||
|
||||
if (failing > 0) {
|
||||
console.log(` ${colors.error(symbols.error)} Below threshold: ${failing}`);
|
||||
}
|
||||
|
||||
if (withQuality.length > 0) {
|
||||
const avgScore = Math.round(withQuality.reduce((sum, r) => sum + r.quality!.overall, 0) / withQuality.length);
|
||||
console.log(` ${colors.muted('Average score:')} ${formatScore(avgScore)}/100`);
|
||||
}
|
||||
|
||||
if (formatFailed > 0 || failing > 0) {
|
||||
console.log('');
|
||||
if (formatFailed > 0) {
|
||||
warn(`${formatFailed} skill(s) failed format validation`);
|
||||
}
|
||||
if (failing > 0) {
|
||||
warn(`${failing} skill(s) below quality threshold`);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.log('');
|
||||
success('All skills validated successfully');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ export {
|
||||
formatAgentIconsInline,
|
||||
progressBar,
|
||||
formatScore,
|
||||
formatQualityBadge,
|
||||
formatQualityBadgeCompact,
|
||||
getQualityGradeFromScore,
|
||||
} from './theme.js';
|
||||
|
||||
export {
|
||||
|
||||
@@ -132,3 +132,25 @@ export function formatScore(score: number): string {
|
||||
}
|
||||
return `${scoreColor(`${score}%`)} ${colors.dim(bar)}`;
|
||||
}
|
||||
|
||||
export function getQualityGradeFromScore(score: number): string {
|
||||
if (score >= 90) return 'A';
|
||||
if (score >= 80) return 'B';
|
||||
if (score >= 70) return 'C';
|
||||
if (score >= 60) return 'D';
|
||||
return 'F';
|
||||
}
|
||||
|
||||
export function formatQualityBadge(score: number): string {
|
||||
const grade = getQualityGradeFromScore(score);
|
||||
if (score >= 80) return colors.success(`[${grade}]`);
|
||||
if (score >= 60) return colors.warning(`[${grade}]`);
|
||||
return colors.error(`[${grade}]`);
|
||||
}
|
||||
|
||||
export function formatQualityBadgeCompact(score: number): string {
|
||||
const grade = getQualityGradeFromScore(score);
|
||||
if (score >= 80) return colors.success(grade);
|
||||
if (score >= 60) return colors.warning(grade);
|
||||
return colors.error(grade);
|
||||
}
|
||||
|
||||
@@ -75,3 +75,5 @@ export * from './agents/index.js';
|
||||
|
||||
export * from './skill-translator.js';
|
||||
export * from './manifest/index.js';
|
||||
|
||||
export * from './quality/index.js';
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
evaluateSkillContent,
|
||||
getQualityGrade,
|
||||
isHighQuality,
|
||||
} from '../index.js';
|
||||
|
||||
describe('Quality Evaluation', () => {
|
||||
describe('evaluateSkillContent', () => {
|
||||
it('should score a well-structured skill highly', () => {
|
||||
const content = `---
|
||||
name: test-skill
|
||||
description: A test skill for validation
|
||||
globs: ["**/*.ts"]
|
||||
---
|
||||
|
||||
# Test Skill
|
||||
|
||||
## When to Use
|
||||
|
||||
Use this skill when working with TypeScript files.
|
||||
|
||||
## Instructions
|
||||
|
||||
Always follow these patterns:
|
||||
|
||||
\`\`\`typescript
|
||||
function example(): void {
|
||||
console.log('example');
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
## Commands
|
||||
|
||||
Run tests with:
|
||||
|
||||
\`\`\`bash
|
||||
npm test
|
||||
\`\`\`
|
||||
|
||||
## Boundaries
|
||||
|
||||
Never commit secrets to the repository.
|
||||
Always run linting before commits.
|
||||
`;
|
||||
|
||||
const result = evaluateSkillContent(content);
|
||||
expect(result.overall).toBeGreaterThanOrEqual(70);
|
||||
expect(result.structure.hasMetadata).toBe(true);
|
||||
expect(result.structure.hasTriggers).toBe(true);
|
||||
expect(result.structure.hasExamples).toBe(true);
|
||||
expect(result.structure.hasBoundaries).toBe(true);
|
||||
expect(result.clarity.hasHeaders).toBe(true);
|
||||
expect(result.specificity.hasConcreteCommands).toBe(true);
|
||||
});
|
||||
|
||||
it('should score a minimal skill lower', () => {
|
||||
const content = `# My Skill
|
||||
|
||||
Be helpful and assist the user with various tasks.
|
||||
Try to do your best.
|
||||
`;
|
||||
|
||||
const result = evaluateSkillContent(content);
|
||||
expect(result.overall).toBeLessThan(50);
|
||||
expect(result.structure.hasMetadata).toBe(false);
|
||||
expect(result.structure.hasTriggers).toBe(false);
|
||||
expect(result.specificity.vagueTermCount).toBeGreaterThan(0);
|
||||
expect(result.warnings.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should penalize overly long skills', () => {
|
||||
const longContent = '# Skill\n' + 'Some content.\n'.repeat(600);
|
||||
const result = evaluateSkillContent(longContent);
|
||||
expect(result.clarity.lineCount).toBeGreaterThan(500);
|
||||
expect(result.clarity.score).toBeLessThan(70);
|
||||
});
|
||||
|
||||
it('should detect vague terms', () => {
|
||||
const content = `# Skill
|
||||
|
||||
Be helpful and assist the user.
|
||||
Try to do your best when appropriate.
|
||||
Help with various tasks as needed.
|
||||
`;
|
||||
|
||||
const result = evaluateSkillContent(content);
|
||||
expect(result.specificity.vagueTermCount).toBeGreaterThan(3);
|
||||
});
|
||||
|
||||
it('should detect code examples', () => {
|
||||
const content = `# Skill
|
||||
|
||||
\`\`\`typescript
|
||||
const x = 1;
|
||||
\`\`\`
|
||||
|
||||
\`\`\`javascript
|
||||
const y = 2;
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
const result = evaluateSkillContent(content);
|
||||
expect(result.structure.hasExamples).toBe(true);
|
||||
expect(result.specificity.hasCodeExamples).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect boundary patterns', () => {
|
||||
const content = `# Skill
|
||||
|
||||
## Boundaries
|
||||
|
||||
- Never commit secrets
|
||||
- Always run tests
|
||||
- Don't modify node_modules
|
||||
- Avoid using deprecated APIs
|
||||
`;
|
||||
|
||||
const result = evaluateSkillContent(content);
|
||||
expect(result.structure.hasBoundaries).toBe(true);
|
||||
});
|
||||
|
||||
it('should detect trigger conditions', () => {
|
||||
const content = `# Skill
|
||||
|
||||
## When to Use
|
||||
|
||||
Use this skill when:
|
||||
- Working with React components
|
||||
- Building forms
|
||||
`;
|
||||
|
||||
const result = evaluateSkillContent(content);
|
||||
expect(result.structure.hasTriggers).toBe(true);
|
||||
expect(result.structure.hasWhenToUse).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getQualityGrade', () => {
|
||||
it('should return A for scores >= 90', () => {
|
||||
expect(getQualityGrade(90)).toBe('A');
|
||||
expect(getQualityGrade(100)).toBe('A');
|
||||
});
|
||||
|
||||
it('should return B for scores >= 80', () => {
|
||||
expect(getQualityGrade(80)).toBe('B');
|
||||
expect(getQualityGrade(89)).toBe('B');
|
||||
});
|
||||
|
||||
it('should return C for scores >= 70', () => {
|
||||
expect(getQualityGrade(70)).toBe('C');
|
||||
expect(getQualityGrade(79)).toBe('C');
|
||||
});
|
||||
|
||||
it('should return D for scores >= 60', () => {
|
||||
expect(getQualityGrade(60)).toBe('D');
|
||||
expect(getQualityGrade(69)).toBe('D');
|
||||
});
|
||||
|
||||
it('should return F for scores < 60', () => {
|
||||
expect(getQualityGrade(59)).toBe('F');
|
||||
expect(getQualityGrade(0)).toBe('F');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isHighQuality', () => {
|
||||
const defaultAdvanced = {
|
||||
score: 100,
|
||||
deprecatedPatterns: [],
|
||||
conflictingInstructions: [],
|
||||
securityIssues: [],
|
||||
completeness: { score: 100, hasTodos: false, todoCount: 0, emptySections: [], exampleCoverage: 100 },
|
||||
};
|
||||
|
||||
it('should return true for high scoring skills with few warnings', () => {
|
||||
const score = {
|
||||
overall: 80,
|
||||
structure: { score: 80, hasMetadata: true, hasDescription: true, hasTriggers: true, hasExamples: true, hasBoundaries: true, hasWhenToUse: true },
|
||||
clarity: { score: 80, lineCount: 100, tokenCount: 500, avgSentenceLength: 15, hasHeaders: true },
|
||||
specificity: { score: 80, hasConcreteCommands: true, hasFilePatterns: true, hasCodeExamples: true, vagueTermCount: 0 },
|
||||
advanced: defaultAdvanced,
|
||||
warnings: [],
|
||||
suggestions: [],
|
||||
};
|
||||
expect(isHighQuality(score)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for low scoring skills', () => {
|
||||
const score = {
|
||||
overall: 50,
|
||||
structure: { score: 50, hasMetadata: false, hasDescription: false, hasTriggers: false, hasExamples: false, hasBoundaries: false, hasWhenToUse: false },
|
||||
clarity: { score: 50, lineCount: 100, tokenCount: 500, avgSentenceLength: 15, hasHeaders: true },
|
||||
specificity: { score: 50, hasConcreteCommands: false, hasFilePatterns: false, hasCodeExamples: false, vagueTermCount: 5 },
|
||||
advanced: { ...defaultAdvanced, score: 50 },
|
||||
warnings: ['Missing triggers', 'No examples'],
|
||||
suggestions: [],
|
||||
};
|
||||
expect(isHighQuality(score)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for skills with many warnings', () => {
|
||||
const score = {
|
||||
overall: 75,
|
||||
structure: { score: 75, hasMetadata: true, hasDescription: true, hasTriggers: false, hasExamples: false, hasBoundaries: false, hasWhenToUse: false },
|
||||
clarity: { score: 75, lineCount: 100, tokenCount: 500, avgSentenceLength: 15, hasHeaders: true },
|
||||
specificity: { score: 75, hasConcreteCommands: true, hasFilePatterns: true, hasCodeExamples: false, vagueTermCount: 0 },
|
||||
advanced: { ...defaultAdvanced, score: 75 },
|
||||
warnings: ['Warning 1', 'Warning 2', 'Warning 3'],
|
||||
suggestions: [],
|
||||
};
|
||||
expect(isHighQuality(score)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* Benchmark quality scores against category leaders
|
||||
*/
|
||||
|
||||
import type { QualityScore } from './index.js';
|
||||
|
||||
export interface BenchmarkResult {
|
||||
skill: string;
|
||||
score: number;
|
||||
grade: string;
|
||||
categoryAvg: number;
|
||||
topSkillScore: number;
|
||||
percentile: number;
|
||||
comparisonNotes: string[];
|
||||
recommendations: string[];
|
||||
}
|
||||
|
||||
export interface CategoryStats {
|
||||
category: string;
|
||||
avgScore: number;
|
||||
topScore: number;
|
||||
topSkills: string[];
|
||||
count: number;
|
||||
distribution: {
|
||||
A: number;
|
||||
B: number;
|
||||
C: number;
|
||||
D: number;
|
||||
F: number;
|
||||
};
|
||||
}
|
||||
|
||||
const CATEGORY_BENCHMARKS: Record<string, CategoryStats> = {
|
||||
react: {
|
||||
category: 'react',
|
||||
avgScore: 78,
|
||||
topScore: 95,
|
||||
topSkills: ['react-patterns', 'react-hooks-best-practices'],
|
||||
count: 150,
|
||||
distribution: { A: 15, B: 35, C: 30, D: 15, F: 5 },
|
||||
},
|
||||
typescript: {
|
||||
category: 'typescript',
|
||||
avgScore: 75,
|
||||
topScore: 92,
|
||||
topSkills: ['typescript-strict', 'type-safety-patterns'],
|
||||
count: 120,
|
||||
distribution: { A: 12, B: 30, C: 35, D: 18, F: 5 },
|
||||
},
|
||||
testing: {
|
||||
category: 'testing',
|
||||
avgScore: 72,
|
||||
topScore: 90,
|
||||
topSkills: ['tdd-workflow', 'testing-best-practices'],
|
||||
count: 80,
|
||||
distribution: { A: 10, B: 28, C: 38, D: 19, F: 5 },
|
||||
},
|
||||
git: {
|
||||
category: 'git',
|
||||
avgScore: 80,
|
||||
topScore: 94,
|
||||
topSkills: ['git-workflow', 'conventional-commits'],
|
||||
count: 60,
|
||||
distribution: { A: 18, B: 40, C: 28, D: 12, F: 2 },
|
||||
},
|
||||
security: {
|
||||
category: 'security',
|
||||
avgScore: 76,
|
||||
topScore: 93,
|
||||
topSkills: ['security-review', 'owasp-patterns'],
|
||||
count: 45,
|
||||
distribution: { A: 14, B: 32, C: 34, D: 16, F: 4 },
|
||||
},
|
||||
api: {
|
||||
category: 'api',
|
||||
avgScore: 74,
|
||||
topScore: 91,
|
||||
topSkills: ['api-design', 'rest-best-practices'],
|
||||
count: 55,
|
||||
distribution: { A: 11, B: 30, C: 36, D: 18, F: 5 },
|
||||
},
|
||||
general: {
|
||||
category: 'general',
|
||||
avgScore: 70,
|
||||
topScore: 88,
|
||||
topSkills: ['code-review', 'best-practices'],
|
||||
count: 200,
|
||||
distribution: { A: 8, B: 25, C: 40, D: 22, F: 5 },
|
||||
},
|
||||
};
|
||||
|
||||
export function getGrade(score: number): string {
|
||||
if (score >= 90) return 'A';
|
||||
if (score >= 80) return 'B';
|
||||
if (score >= 70) return 'C';
|
||||
if (score >= 60) return 'D';
|
||||
return 'F';
|
||||
}
|
||||
|
||||
export function detectCategory(skillName: string, tags: string[] = []): string {
|
||||
const lowerName = skillName.toLowerCase();
|
||||
const lowerTags = tags.map(t => t.toLowerCase());
|
||||
const searchTerms = [lowerName, ...lowerTags];
|
||||
|
||||
const categoryKeywords: Record<string, string[]> = {
|
||||
react: ['react', 'hooks', 'jsx', 'tsx', 'component', 'nextjs', 'remix'],
|
||||
typescript: ['typescript', 'type', 'types', 'ts', 'strict'],
|
||||
testing: ['test', 'testing', 'tdd', 'jest', 'vitest', 'playwright', 'e2e'],
|
||||
git: ['git', 'commit', 'branch', 'merge', 'workflow', 'conventional'],
|
||||
security: ['security', 'auth', 'owasp', 'vulnerability', 'safe'],
|
||||
api: ['api', 'rest', 'graphql', 'endpoint', 'http'],
|
||||
};
|
||||
|
||||
for (const [category, keywords] of Object.entries(categoryKeywords)) {
|
||||
for (const term of searchTerms) {
|
||||
if (keywords.some(kw => term.includes(kw))) {
|
||||
return category;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'general';
|
||||
}
|
||||
|
||||
export function calculatePercentile(score: number, categoryStats: CategoryStats): number {
|
||||
const { distribution } = categoryStats;
|
||||
const totalSkills = distribution.A + distribution.B + distribution.C + distribution.D + distribution.F;
|
||||
|
||||
let percentBelow = 0;
|
||||
|
||||
if (score < 60) {
|
||||
percentBelow = (score / 60) * (distribution.F / totalSkills) * 100;
|
||||
} else if (score < 70) {
|
||||
percentBelow = (distribution.F / totalSkills) * 100;
|
||||
percentBelow += ((score - 60) / 10) * (distribution.D / totalSkills) * 100;
|
||||
} else if (score < 80) {
|
||||
percentBelow = ((distribution.F + distribution.D) / totalSkills) * 100;
|
||||
percentBelow += ((score - 70) / 10) * (distribution.C / totalSkills) * 100;
|
||||
} else if (score < 90) {
|
||||
percentBelow = ((distribution.F + distribution.D + distribution.C) / totalSkills) * 100;
|
||||
percentBelow += ((score - 80) / 10) * (distribution.B / totalSkills) * 100;
|
||||
} else {
|
||||
percentBelow = ((distribution.F + distribution.D + distribution.C + distribution.B) / totalSkills) * 100;
|
||||
percentBelow += ((score - 90) / 10) * (distribution.A / totalSkills) * 100;
|
||||
}
|
||||
|
||||
return Math.round(Math.min(99, Math.max(1, percentBelow)));
|
||||
}
|
||||
|
||||
export function generateComparisonNotes(
|
||||
quality: QualityScore,
|
||||
categoryStats: CategoryStats
|
||||
): string[] {
|
||||
const notes: string[] = [];
|
||||
const topScore = categoryStats.topScore;
|
||||
const avgScore = categoryStats.avgScore;
|
||||
|
||||
if (quality.overall >= topScore) {
|
||||
notes.push('Your skill is among the top performers in this category');
|
||||
} else if (quality.overall >= avgScore) {
|
||||
notes.push(`Your skill is above the category average (${avgScore})`);
|
||||
} else {
|
||||
notes.push(`Your skill is ${avgScore - quality.overall} points below the category average`);
|
||||
}
|
||||
|
||||
if (!quality.structure.hasExamples) {
|
||||
notes.push('Missing code examples (present in 95% of top skills)');
|
||||
}
|
||||
|
||||
if (!quality.structure.hasTriggers) {
|
||||
notes.push('Missing trigger conditions (present in 80% of top skills)');
|
||||
}
|
||||
|
||||
if (!quality.structure.hasBoundaries) {
|
||||
notes.push('Missing "When Not to Use" section (present in 80% of top skills)');
|
||||
}
|
||||
|
||||
if (quality.specificity.vagueTermCount > 3) {
|
||||
notes.push('Trigger conditions are less specific than category average');
|
||||
}
|
||||
|
||||
if (quality.clarity.lineCount > 300) {
|
||||
notes.push('Skill is longer than recommended (top skills average 150-250 lines)');
|
||||
}
|
||||
|
||||
if (quality.advanced.deprecatedPatterns.length > 0) {
|
||||
notes.push('Contains deprecated patterns not found in top skills');
|
||||
}
|
||||
|
||||
return notes;
|
||||
}
|
||||
|
||||
export function generateRecommendations(
|
||||
quality: QualityScore,
|
||||
categoryStats: CategoryStats
|
||||
): string[] {
|
||||
const recommendations: string[] = [];
|
||||
const gap = categoryStats.topScore - quality.overall;
|
||||
|
||||
if (gap > 20) {
|
||||
recommendations.push('Consider studying top skills in this category for patterns');
|
||||
}
|
||||
|
||||
if (!quality.structure.hasExamples) {
|
||||
recommendations.push(`Add ${quality.specificity.hasCodeExamples ? 'more' : ''} code examples showing input/output`);
|
||||
}
|
||||
|
||||
if (!quality.structure.hasTriggers) {
|
||||
recommendations.push('Add explicit trigger conditions with patterns like "Triggers when:"');
|
||||
}
|
||||
|
||||
if (!quality.structure.hasBoundaries) {
|
||||
recommendations.push('Add a "Boundaries" or "Limitations" section');
|
||||
}
|
||||
|
||||
if (quality.clarity.lineCount > 400) {
|
||||
recommendations.push('Split into multiple focused skills (top skills are 150-250 lines)');
|
||||
}
|
||||
|
||||
if (quality.specificity.vagueTermCount > 0) {
|
||||
recommendations.push(`Replace ${quality.specificity.vagueTermCount} vague term(s) with specific instructions`);
|
||||
}
|
||||
|
||||
if (quality.advanced.completeness.hasTodos) {
|
||||
recommendations.push('Complete TODO items before publishing');
|
||||
}
|
||||
|
||||
return recommendations;
|
||||
}
|
||||
|
||||
export function benchmarkSkill(
|
||||
skillName: string,
|
||||
quality: QualityScore,
|
||||
tags: string[] = [],
|
||||
customCategoryStats?: CategoryStats
|
||||
): BenchmarkResult {
|
||||
const category = detectCategory(skillName, tags);
|
||||
const categoryStats = customCategoryStats || CATEGORY_BENCHMARKS[category] || CATEGORY_BENCHMARKS.general;
|
||||
|
||||
const percentile = calculatePercentile(quality.overall, categoryStats);
|
||||
const comparisonNotes = generateComparisonNotes(quality, categoryStats);
|
||||
const recommendations = generateRecommendations(quality, categoryStats);
|
||||
|
||||
return {
|
||||
skill: skillName,
|
||||
score: quality.overall,
|
||||
grade: getGrade(quality.overall),
|
||||
categoryAvg: categoryStats.avgScore,
|
||||
topSkillScore: categoryStats.topScore,
|
||||
percentile,
|
||||
comparisonNotes,
|
||||
recommendations,
|
||||
};
|
||||
}
|
||||
|
||||
export function getCategoryStats(category: string): CategoryStats | null {
|
||||
return CATEGORY_BENCHMARKS[category] || null;
|
||||
}
|
||||
|
||||
export function getAllCategories(): string[] {
|
||||
return Object.keys(CATEGORY_BENCHMARKS);
|
||||
}
|
||||
@@ -0,0 +1,589 @@
|
||||
import { readFileSync, existsSync } from 'node:fs';
|
||||
import { join, basename } from 'node:path';
|
||||
|
||||
export * from './benchmark.js';
|
||||
|
||||
export interface QualityScore {
|
||||
overall: number;
|
||||
structure: StructureScore;
|
||||
clarity: ClarityScore;
|
||||
specificity: SpecificityScore;
|
||||
advanced: AdvancedScore;
|
||||
warnings: string[];
|
||||
suggestions: string[];
|
||||
}
|
||||
|
||||
export interface AdvancedScore {
|
||||
score: number;
|
||||
deprecatedPatterns: string[];
|
||||
conflictingInstructions: string[];
|
||||
securityIssues: string[];
|
||||
completeness: CompletenessResult;
|
||||
}
|
||||
|
||||
export interface CompletenessResult {
|
||||
score: number;
|
||||
hasTodos: boolean;
|
||||
todoCount: number;
|
||||
emptySections: string[];
|
||||
exampleCoverage: number;
|
||||
}
|
||||
|
||||
export interface StructureScore {
|
||||
score: number;
|
||||
hasMetadata: boolean;
|
||||
hasDescription: boolean;
|
||||
hasTriggers: boolean;
|
||||
hasExamples: boolean;
|
||||
hasBoundaries: boolean;
|
||||
hasWhenToUse: boolean;
|
||||
}
|
||||
|
||||
export interface ClarityScore {
|
||||
score: number;
|
||||
lineCount: number;
|
||||
tokenCount: number;
|
||||
avgSentenceLength: number;
|
||||
hasHeaders: boolean;
|
||||
}
|
||||
|
||||
export interface SpecificityScore {
|
||||
score: number;
|
||||
hasConcreteCommands: boolean;
|
||||
hasFilePatterns: boolean;
|
||||
hasCodeExamples: boolean;
|
||||
vagueTermCount: number;
|
||||
}
|
||||
|
||||
const VAGUE_TERMS = [
|
||||
'be helpful',
|
||||
'assist the user',
|
||||
'help with',
|
||||
'try to',
|
||||
'attempt to',
|
||||
'do your best',
|
||||
'as needed',
|
||||
'when appropriate',
|
||||
'if necessary',
|
||||
'general purpose',
|
||||
'various tasks',
|
||||
'many things',
|
||||
'etc.',
|
||||
'and so on',
|
||||
'stuff like that',
|
||||
];
|
||||
|
||||
const BOUNDARY_PATTERNS = [
|
||||
/never\s+(?:do|use|commit|push|delete|remove)/i,
|
||||
/always\s+(?:do|use|check|verify|ensure)/i,
|
||||
/don'?t\s+(?:do|use|commit|push|delete)/i,
|
||||
/avoid\s+(?:using|doing|committing)/i,
|
||||
/must\s+(?:not|always|never)/i,
|
||||
/forbidden/i,
|
||||
/prohibited/i,
|
||||
/required/i,
|
||||
];
|
||||
|
||||
const TRIGGER_PATTERNS = [
|
||||
/when\s+to\s+use/i,
|
||||
/use\s+this\s+(?:skill|when)/i,
|
||||
/triggers?\s*(?:when|:)/i,
|
||||
/activated?\s+(?:when|by)/i,
|
||||
/applies?\s+(?:when|to)/i,
|
||||
/invoke\s+(?:when|this)/i,
|
||||
];
|
||||
|
||||
const COMMAND_PATTERNS = [
|
||||
/```(?:bash|sh|shell|zsh)[\s\S]*?```/g,
|
||||
/`(?:npm|pnpm|yarn|bun|npx|git|docker|kubectl)\s+[^`]+`/g,
|
||||
/\$\s*\w+/g,
|
||||
];
|
||||
|
||||
const CODE_EXAMPLE_PATTERNS = [
|
||||
/```(?:typescript|javascript|tsx|jsx|python|go|rust|java)[\s\S]*?```/g,
|
||||
/```[\s\S]{50,}?```/g,
|
||||
];
|
||||
|
||||
const FILE_PATTERN_PATTERNS = [
|
||||
/\*\*\/\*\.\w+/,
|
||||
/\.\w+$/m,
|
||||
/glob[s]?\s*[:=]/i,
|
||||
/include[s]?\s*[:=]/i,
|
||||
/pattern[s]?\s*[:=]/i,
|
||||
];
|
||||
|
||||
const DEPRECATED_PATTERNS = [
|
||||
{ pattern: /require\s*\(['"][^'"]+['"]\)/g, message: 'Uses CommonJS require() instead of ES modules' },
|
||||
{ pattern: /React\.Component/g, message: 'Uses class components instead of functional' },
|
||||
{ pattern: /componentDidMount|componentWillUnmount|componentDidUpdate/g, message: 'Uses lifecycle methods instead of hooks' },
|
||||
{ pattern: /\bvar\s+\w+\s*=/g, message: 'Uses var instead of const/let' },
|
||||
{ pattern: /\.then\s*\([^)]*\)\.catch/g, message: 'Uses .then().catch() instead of async/await' },
|
||||
{ pattern: /new\s+Promise\s*\(/g, message: 'Consider using async/await instead of new Promise()' },
|
||||
];
|
||||
|
||||
const SECURITY_PATTERNS = [
|
||||
{ pattern: /password\s*[:=]\s*['"][^'"]+['"]/gi, message: 'Potential hardcoded password' },
|
||||
{ pattern: /api[_-]?key\s*[:=]\s*['"][^'"]+['"]/gi, message: 'Potential hardcoded API key' },
|
||||
{ pattern: /secret\s*[:=]\s*['"][^'"]+['"]/gi, message: 'Potential hardcoded secret' },
|
||||
{ pattern: /token\s*[:=]\s*['"][A-Za-z0-9_-]{20,}['"]/gi, message: 'Potential hardcoded token' },
|
||||
{ pattern: /\$\{[^}]*\}/g, message: 'Template literal - ensure proper sanitization in shell commands' },
|
||||
{ pattern: /eval\s*\(/g, message: 'Uses eval() - potential code injection risk' },
|
||||
{ pattern: /innerHTML\s*=/g, message: 'Uses innerHTML - potential XSS risk' },
|
||||
{ pattern: /dangerouslySetInnerHTML/g, message: 'Uses dangerouslySetInnerHTML - potential XSS risk' },
|
||||
];
|
||||
|
||||
|
||||
function extractFrontmatter(content: string): Record<string, unknown> | null {
|
||||
const normalizedContent = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
const match = normalizedContent.match(/^---\s*\n([\s\S]*?)\n---/);
|
||||
if (!match) return null;
|
||||
|
||||
const frontmatter: Record<string, unknown> = {};
|
||||
const lines = match[1].split('\n');
|
||||
|
||||
for (const line of lines) {
|
||||
const colonIndex = line.indexOf(':');
|
||||
if (colonIndex > 0) {
|
||||
const key = line.slice(0, colonIndex).trim();
|
||||
const value = line.slice(colonIndex + 1).trim();
|
||||
frontmatter[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(frontmatter).length > 0 ? frontmatter : null;
|
||||
}
|
||||
|
||||
function countTokens(text: string): number {
|
||||
return Math.ceil(text.length / 4);
|
||||
}
|
||||
|
||||
function countVagueTerms(content: string): number {
|
||||
const lowerContent = content.toLowerCase();
|
||||
let count = 0;
|
||||
for (const term of VAGUE_TERMS) {
|
||||
const regex = new RegExp(term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi');
|
||||
const matches = lowerContent.match(regex);
|
||||
if (matches) count += matches.length;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
function hasPattern(content: string, patterns: RegExp[]): boolean {
|
||||
return patterns.some(p => p.test(content));
|
||||
}
|
||||
|
||||
function countMatches(content: string, patterns: RegExp[]): number {
|
||||
let count = 0;
|
||||
for (const pattern of patterns) {
|
||||
const matches = content.match(pattern);
|
||||
if (matches) count += matches.length;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
function calculateAvgSentenceLength(content: string): number {
|
||||
const contentWithoutCode = content.replace(/```[\s\S]*?```/g, '');
|
||||
const sentences = contentWithoutCode.split(/[.!?]+/).filter(s => s.trim().length > 0);
|
||||
if (sentences.length === 0) return 0;
|
||||
const totalWords = sentences.reduce((sum, s) => sum + s.trim().split(/\s+/).length, 0);
|
||||
return Math.round(totalWords / sentences.length);
|
||||
}
|
||||
|
||||
function evaluateStructure(content: string): StructureScore {
|
||||
const frontmatter = extractFrontmatter(content);
|
||||
const hasMetadata = frontmatter !== null && Object.keys(frontmatter).length > 0;
|
||||
const hasDescription = !!(frontmatter?.description) || /^#+\s*description/im.test(content);
|
||||
const hasTriggers = hasPattern(content, TRIGGER_PATTERNS);
|
||||
const hasExamples = countMatches(content, CODE_EXAMPLE_PATTERNS) > 0;
|
||||
const hasBoundaries = hasPattern(content, BOUNDARY_PATTERNS);
|
||||
const hasWhenToUse = /when\s+to\s+use|use\s+case|scenario/i.test(content);
|
||||
|
||||
let score = 0;
|
||||
if (hasMetadata) score += 15;
|
||||
if (hasDescription) score += 10;
|
||||
if (hasTriggers) score += 20;
|
||||
if (hasExamples) score += 20;
|
||||
if (hasBoundaries) score += 20;
|
||||
if (hasWhenToUse) score += 15;
|
||||
|
||||
return {
|
||||
score: Math.min(100, score),
|
||||
hasMetadata,
|
||||
hasDescription,
|
||||
hasTriggers,
|
||||
hasExamples,
|
||||
hasBoundaries,
|
||||
hasWhenToUse,
|
||||
};
|
||||
}
|
||||
|
||||
function evaluateClarity(content: string): ClarityScore {
|
||||
const lines = content.split('\n');
|
||||
const lineCount = lines.length;
|
||||
const tokenCount = countTokens(content);
|
||||
const avgSentenceLength = calculateAvgSentenceLength(content);
|
||||
const hasHeaders = /^#+\s+/m.test(content);
|
||||
|
||||
let score = 100;
|
||||
|
||||
if (lineCount > 500) score -= 30;
|
||||
else if (lineCount > 300) score -= 15;
|
||||
else if (lineCount > 150) score -= 5;
|
||||
|
||||
if (tokenCount > 4000) score -= 30;
|
||||
else if (tokenCount > 2000) score -= 15;
|
||||
else if (tokenCount > 1000) score -= 5;
|
||||
|
||||
if (avgSentenceLength > 30) score -= 20;
|
||||
else if (avgSentenceLength > 20) score -= 10;
|
||||
|
||||
if (!hasHeaders) score -= 15;
|
||||
|
||||
return {
|
||||
score: Math.max(0, score),
|
||||
lineCount,
|
||||
tokenCount,
|
||||
avgSentenceLength,
|
||||
hasHeaders,
|
||||
};
|
||||
}
|
||||
|
||||
function countCodeBlocks(content: string): number {
|
||||
const fencedBlocks = content.match(/```[\s\S]*?```/g) || [];
|
||||
return fencedBlocks.length;
|
||||
}
|
||||
|
||||
function detectDeprecatedPatterns(content: string): string[] {
|
||||
const codeBlocks = content.match(/```[\s\S]*?```/g) || [];
|
||||
const codeContent = codeBlocks.join('\n');
|
||||
const issues: string[] = [];
|
||||
|
||||
for (const { pattern, message } of DEPRECATED_PATTERNS) {
|
||||
const regex = new RegExp(pattern.source, pattern.flags);
|
||||
if (regex.test(codeContent)) {
|
||||
issues.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
return [...new Set(issues)];
|
||||
}
|
||||
|
||||
function detectSecurityPatterns(content: string): string[] {
|
||||
const issues: string[] = [];
|
||||
|
||||
for (const { pattern, message } of SECURITY_PATTERNS) {
|
||||
const regex = new RegExp(pattern.source, pattern.flags);
|
||||
if (regex.test(content)) {
|
||||
if (!message.includes('Template literal') || content.includes('bash') || content.includes('shell')) {
|
||||
issues.push(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [...new Set(issues)];
|
||||
}
|
||||
|
||||
function detectConflictingInstructions(content: string): string[] {
|
||||
const issues: string[] = [];
|
||||
const lowerContent = content.toLowerCase();
|
||||
|
||||
const alwaysMatches = lowerContent.match(/always\s+(?:use|do|include|add)\s+(\w+)/gi) || [];
|
||||
const neverMatches = lowerContent.match(/never\s+(?:use|do|include|add)\s+(\w+)/gi) || [];
|
||||
|
||||
for (const always of alwaysMatches) {
|
||||
const term = always.replace(/always\s+(?:use|do|include|add)\s+/i, '').toLowerCase();
|
||||
for (const never of neverMatches) {
|
||||
const neverTerm = never.replace(/never\s+(?:use|do|include|add)\s+/i, '').toLowerCase();
|
||||
if (term === neverTerm) {
|
||||
issues.push(`Conflicting instructions: "always" and "never" used with "${term}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const mustMatches = lowerContent.match(/must\s+(\w+)/gi) || [];
|
||||
const mustNotMatches = lowerContent.match(/must\s+not\s+(\w+)/gi) || [];
|
||||
|
||||
for (const must of mustMatches) {
|
||||
const term = must.replace(/must\s+/i, '').toLowerCase();
|
||||
for (const mustNot of mustNotMatches) {
|
||||
const notTerm = mustNot.replace(/must\s+not\s+/i, '').toLowerCase();
|
||||
if (term === notTerm) {
|
||||
issues.push(`Conflicting instructions: "must" and "must not" used with "${term}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [...new Set(issues)];
|
||||
}
|
||||
|
||||
function assessCompleteness(content: string): CompletenessResult {
|
||||
const todoMatches = content.match(/TODO|FIXME|XXX|HACK/gi) || [];
|
||||
const todoCount = todoMatches.length;
|
||||
|
||||
const headerPositions: Array<{ header: string; index: number }> = [];
|
||||
const lines = content.split('\n');
|
||||
let inFence = false;
|
||||
let offset = 0;
|
||||
|
||||
for (const line of lines) {
|
||||
if (/^```|^~~~/.test(line)) {
|
||||
inFence = !inFence;
|
||||
} else if (!inFence && /^#+\s+.+$/.test(line)) {
|
||||
headerPositions.push({ header: line, index: offset });
|
||||
}
|
||||
offset += line.length + 1;
|
||||
}
|
||||
|
||||
const emptySections: string[] = [];
|
||||
|
||||
for (let i = 0; i < headerPositions.length - 1; i++) {
|
||||
const current = headerPositions[i];
|
||||
const next = headerPositions[i + 1];
|
||||
const sectionContent = content.slice(current.index + current.header.length, next.index).trim();
|
||||
|
||||
if (sectionContent.length < 20) {
|
||||
const sectionName = current.header.replace(/^#+\s+/, '');
|
||||
emptySections.push(sectionName);
|
||||
}
|
||||
}
|
||||
|
||||
if (headerPositions.length > 0) {
|
||||
const last = headerPositions[headerPositions.length - 1];
|
||||
const tailContent = content.slice(last.index + last.header.length).trim();
|
||||
if (tailContent.length < 20) {
|
||||
const sectionName = last.header.replace(/^#+\s+/, '');
|
||||
emptySections.push(sectionName);
|
||||
}
|
||||
}
|
||||
|
||||
const codeBlocks = countCodeBlocks(content);
|
||||
const exampleCoverage = Math.min(100, codeBlocks * 25);
|
||||
|
||||
let score = 100;
|
||||
if (todoCount > 0) score -= Math.min(30, todoCount * 10);
|
||||
if (emptySections.length > 0) score -= Math.min(30, emptySections.length * 10);
|
||||
if (codeBlocks < 2) score -= 20;
|
||||
else if (codeBlocks < 4) score -= 10;
|
||||
|
||||
return {
|
||||
score: Math.max(0, score),
|
||||
hasTodos: todoCount > 0,
|
||||
todoCount,
|
||||
emptySections,
|
||||
exampleCoverage,
|
||||
};
|
||||
}
|
||||
|
||||
function evaluateAdvanced(content: string): AdvancedScore {
|
||||
const deprecatedPatterns = detectDeprecatedPatterns(content);
|
||||
const conflictingInstructions = detectConflictingInstructions(content);
|
||||
const securityIssues = detectSecurityPatterns(content);
|
||||
const completeness = assessCompleteness(content);
|
||||
|
||||
let score = 100;
|
||||
score -= Math.min(30, deprecatedPatterns.length * 10);
|
||||
score -= Math.min(30, conflictingInstructions.length * 15);
|
||||
score -= Math.min(25, securityIssues.length * 10);
|
||||
score -= Math.round((100 - completeness.score) * 0.15);
|
||||
|
||||
return {
|
||||
score: Math.max(0, score),
|
||||
deprecatedPatterns,
|
||||
conflictingInstructions,
|
||||
securityIssues,
|
||||
completeness,
|
||||
};
|
||||
}
|
||||
|
||||
function evaluateSpecificity(content: string): SpecificityScore {
|
||||
const hasConcreteCommands = countMatches(content, COMMAND_PATTERNS) > 0;
|
||||
const hasFilePatterns = hasPattern(content, FILE_PATTERN_PATTERNS);
|
||||
const codeBlockCount = countCodeBlocks(content);
|
||||
const hasCodeExamples = codeBlockCount >= 2;
|
||||
const vagueTermCount = countVagueTerms(content);
|
||||
|
||||
let score = 0;
|
||||
|
||||
if (hasConcreteCommands) score += 30;
|
||||
if (hasFilePatterns) score += 25;
|
||||
if (hasCodeExamples) score += 30;
|
||||
|
||||
if (vagueTermCount === 0) score += 15;
|
||||
else if (vagueTermCount <= 2) score += 10;
|
||||
else if (vagueTermCount <= 5) score += 5;
|
||||
|
||||
return {
|
||||
score: Math.min(100, score),
|
||||
hasConcreteCommands,
|
||||
hasFilePatterns,
|
||||
hasCodeExamples,
|
||||
vagueTermCount,
|
||||
};
|
||||
}
|
||||
|
||||
function generateWarnings(
|
||||
structure: StructureScore,
|
||||
clarity: ClarityScore,
|
||||
specificity: SpecificityScore,
|
||||
advanced: AdvancedScore
|
||||
): string[] {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (!structure.hasMetadata) {
|
||||
warnings.push('Missing frontmatter metadata');
|
||||
}
|
||||
if (!structure.hasTriggers) {
|
||||
warnings.push('No trigger conditions defined');
|
||||
}
|
||||
if (!structure.hasBoundaries) {
|
||||
warnings.push('No boundaries or constraints specified');
|
||||
}
|
||||
if (clarity.lineCount > 500) {
|
||||
warnings.push(`Skill is too long (${clarity.lineCount} lines)`);
|
||||
}
|
||||
if (clarity.tokenCount > 4000) {
|
||||
warnings.push(`High token usage (${clarity.tokenCount} tokens)`);
|
||||
}
|
||||
if (specificity.vagueTermCount > 5) {
|
||||
warnings.push(`Contains ${specificity.vagueTermCount} vague terms`);
|
||||
}
|
||||
if (!structure.hasExamples) {
|
||||
warnings.push('No code examples provided');
|
||||
} else if (!specificity.hasCodeExamples) {
|
||||
warnings.push('Only one code example provided');
|
||||
}
|
||||
|
||||
for (const issue of advanced.securityIssues) {
|
||||
warnings.push(`Security: ${issue}`);
|
||||
}
|
||||
for (const conflict of advanced.conflictingInstructions) {
|
||||
warnings.push(conflict);
|
||||
}
|
||||
if (advanced.completeness.hasTodos) {
|
||||
warnings.push(`Contains ${advanced.completeness.todoCount} TODO/FIXME comment(s)`);
|
||||
}
|
||||
if (advanced.completeness.emptySections.length > 0) {
|
||||
warnings.push(`Empty sections: ${advanced.completeness.emptySections.join(', ')}`);
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
function generateSuggestions(
|
||||
structure: StructureScore,
|
||||
clarity: ClarityScore,
|
||||
specificity: SpecificityScore,
|
||||
advanced: AdvancedScore
|
||||
): string[] {
|
||||
const suggestions: string[] = [];
|
||||
|
||||
if (!structure.hasMetadata) {
|
||||
suggestions.push('Add YAML frontmatter with name, description, and globs');
|
||||
}
|
||||
if (!structure.hasTriggers) {
|
||||
suggestions.push('Add a "When to Use" section with specific trigger conditions');
|
||||
}
|
||||
if (!structure.hasExamples) {
|
||||
suggestions.push('Include code examples showing expected output');
|
||||
}
|
||||
if (!structure.hasBoundaries) {
|
||||
suggestions.push('Define boundaries: what the agent should never do');
|
||||
}
|
||||
if (clarity.lineCount > 300) {
|
||||
suggestions.push('Consider splitting into multiple focused skills');
|
||||
}
|
||||
if (!clarity.hasHeaders) {
|
||||
suggestions.push('Use markdown headers to organize content');
|
||||
}
|
||||
if (specificity.vagueTermCount > 0) {
|
||||
suggestions.push('Replace vague terms with specific instructions');
|
||||
}
|
||||
if (!specificity.hasConcreteCommands) {
|
||||
suggestions.push('Add concrete executable commands with flags');
|
||||
}
|
||||
|
||||
if (advanced.deprecatedPatterns.length > 0) {
|
||||
suggestions.push('Update code examples to use modern patterns (ES modules, hooks, async/await)');
|
||||
}
|
||||
if (advanced.securityIssues.length > 0) {
|
||||
suggestions.push('Review and remove potential security risks from examples');
|
||||
}
|
||||
if (advanced.completeness.hasTodos) {
|
||||
suggestions.push('Complete or remove TODO/FIXME comments');
|
||||
}
|
||||
if (advanced.completeness.emptySections.length > 0) {
|
||||
suggestions.push('Add content to empty sections or remove them');
|
||||
}
|
||||
if (advanced.completeness.exampleCoverage < 50) {
|
||||
suggestions.push('Add more code examples to improve coverage');
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
export function evaluateSkillContent(content: string): QualityScore {
|
||||
const structure = evaluateStructure(content);
|
||||
const clarity = evaluateClarity(content);
|
||||
const specificity = evaluateSpecificity(content);
|
||||
const advanced = evaluateAdvanced(content);
|
||||
|
||||
const overall = Math.round(
|
||||
structure.score * 0.35 +
|
||||
clarity.score * 0.25 +
|
||||
specificity.score * 0.25 +
|
||||
advanced.score * 0.15
|
||||
);
|
||||
|
||||
const warnings = generateWarnings(structure, clarity, specificity, advanced);
|
||||
const suggestions = generateSuggestions(structure, clarity, specificity, advanced);
|
||||
|
||||
return {
|
||||
overall,
|
||||
structure,
|
||||
clarity,
|
||||
specificity,
|
||||
advanced,
|
||||
warnings,
|
||||
suggestions,
|
||||
};
|
||||
}
|
||||
|
||||
export function evaluateSkillFile(filePath: string): QualityScore | null {
|
||||
if (!existsSync(filePath)) return null;
|
||||
|
||||
try {
|
||||
const content = readFileSync(filePath, 'utf-8');
|
||||
return evaluateSkillContent(content);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function evaluateSkillDirectory(dirPath: string): QualityScore | null {
|
||||
const skillMdPath = join(dirPath, 'SKILL.md');
|
||||
if (existsSync(skillMdPath)) {
|
||||
return evaluateSkillFile(skillMdPath);
|
||||
}
|
||||
|
||||
const mdcFiles = ['index.mdc', `${basename(dirPath)}.mdc`];
|
||||
for (const file of mdcFiles) {
|
||||
const mdcPath = join(dirPath, file);
|
||||
if (existsSync(mdcPath)) {
|
||||
return evaluateSkillFile(mdcPath);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getQualityGrade(score: number): string {
|
||||
if (score >= 90) return 'A';
|
||||
if (score >= 80) return 'B';
|
||||
if (score >= 70) return 'C';
|
||||
if (score >= 60) return 'D';
|
||||
return 'F';
|
||||
}
|
||||
|
||||
export function isHighQuality(score: QualityScore): boolean {
|
||||
return score.overall >= 80 && score.warnings.length <= 2;
|
||||
}
|
||||
@@ -188,10 +188,14 @@ export function Installed({ onNavigate, cols = 80, rows = 24 }: InstalledProps)
|
||||
const selected = actualIdx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = skill.enabled !== false ? '●' : '○';
|
||||
// Use single text element to avoid rendering overlap
|
||||
const line = `${indicator}${statusIcon} ${skill.name}`;
|
||||
const qualityBadge = skill.grade ? ` [${skill.grade}]` : '';
|
||||
const warningIndicator = skill.warnings && skill.warnings > 2 ? ' ⚠' : '';
|
||||
const line = `${indicator}${statusIcon} ${skill.name}${qualityBadge}${warningIndicator}`;
|
||||
const badgeColor = skill.quality !== undefined
|
||||
? (skill.quality >= 80 ? terminalColors.success : skill.quality >= 60 ? terminalColors.warning : terminalColors.error)
|
||||
: terminalColors.text;
|
||||
return (
|
||||
<text key={skill.name} fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
<text key={skill.name} fg={selected ? terminalColors.accent : badgeColor}>
|
||||
{line}
|
||||
</text>
|
||||
);
|
||||
|
||||
@@ -50,14 +50,14 @@ export function Recommend({ onNavigate, cols = 80, rows = 24 }: RecommendProps)
|
||||
return () => clearInterval(interval);
|
||||
}, [analyzing]);
|
||||
|
||||
// Recommendations data
|
||||
// Recommendations data (with quality scores)
|
||||
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 },
|
||||
{ name: 'tdd-workflow', reason: 'Based on your test files and coverage patterns', confidence: 95, quality: 92, grade: 'A' },
|
||||
{ name: 'react-patterns', reason: 'Detected React in package.json with hooks usage', confidence: 88, quality: 85, grade: 'B' },
|
||||
{ name: 'typescript-strict', reason: 'tsconfig.json found with strict mode disabled', confidence: 82, quality: 78, grade: 'C' },
|
||||
{ name: 'git-workflow', reason: '.git directory with complex branching detected', confidence: 75, quality: 82, grade: 'B' },
|
||||
{ name: 'api-design', reason: 'REST endpoints found in your codebase', confidence: 68, quality: 71, grade: 'C' },
|
||||
{ name: 'docker-compose', reason: 'docker-compose.yml detected for orchestration', confidence: 62, quality: 65, grade: 'D' },
|
||||
], []);
|
||||
|
||||
const maxVisible = Math.max(3, Math.floor((rows - 10) / 2));
|
||||
@@ -163,6 +163,7 @@ export function Recommend({ onNavigate, cols = 80, rows = 24 }: RecommendProps)
|
||||
{visibleRecs.map((rec, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const qualityColor = rec.quality >= 80 ? terminalColors.success : rec.quality >= 60 ? terminalColors.warning : terminalColors.error;
|
||||
return (
|
||||
<box key={rec.name} flexDirection="column">
|
||||
<box flexDirection="row">
|
||||
@@ -171,6 +172,7 @@ export function Recommend({ onNavigate, cols = 80, rows = 24 }: RecommendProps)
|
||||
{rec.name}
|
||||
</text>
|
||||
<text fg={getConfColor(rec.confidence)}> {rec.confidence}%</text>
|
||||
<text fg={qualityColor}> [{rec.grade}]</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> {rec.reason}</text>
|
||||
<text> </text>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Skills state management for SkillKit TUI
|
||||
*/
|
||||
import { findAllSkills } from '@skillkit/core';
|
||||
import { findAllSkills, evaluateSkillDirectory, getQualityGrade } from '@skillkit/core';
|
||||
import { rmSync } from 'node:fs';
|
||||
import { resolve, normalize } from 'node:path';
|
||||
import { getSearchDirs } from '../utils/helpers.js';
|
||||
@@ -38,12 +38,18 @@ export function loadSkills(agentType?: AgentType): SkillsState {
|
||||
const searchDirs = getSearchDirs(agentType);
|
||||
const foundSkills = findAllSkills(searchDirs);
|
||||
|
||||
const skillItems: SkillItem[] = foundSkills.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
source: s.metadata?.source,
|
||||
enabled: s.enabled,
|
||||
}));
|
||||
const skillItems: SkillItem[] = foundSkills.map((s) => {
|
||||
const quality = evaluateSkillDirectory(s.path);
|
||||
return {
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
source: s.metadata?.source,
|
||||
enabled: s.enabled,
|
||||
quality: quality?.overall,
|
||||
grade: quality ? getQualityGrade(quality.overall) : undefined,
|
||||
warnings: quality?.warnings.length,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
skills: skillItems,
|
||||
|
||||
@@ -4,6 +4,9 @@ export interface SkillItem {
|
||||
source?: string;
|
||||
installs?: number;
|
||||
enabled?: boolean;
|
||||
quality?: number;
|
||||
grade?: string;
|
||||
warnings?: number;
|
||||
}
|
||||
|
||||
export interface RepoInfo {
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Compute quality scores for marketplace skills
|
||||
*
|
||||
* This script assigns default quality scores to skills based on source verification.
|
||||
* For detailed quality evaluation, skills would need to be fetched and analyzed individually.
|
||||
*
|
||||
* Usage:
|
||||
* npx tsx scripts/compute-quality.ts
|
||||
* pnpm tsx scripts/compute-quality.ts
|
||||
*/
|
||||
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
interface Skill {
|
||||
id: string;
|
||||
name: string;
|
||||
source: string;
|
||||
description?: string;
|
||||
tags: string[];
|
||||
author?: string;
|
||||
version?: string;
|
||||
agents?: string[];
|
||||
quality?: number;
|
||||
}
|
||||
|
||||
interface SkillsIndex {
|
||||
version: number;
|
||||
updatedAt: string;
|
||||
skills: Skill[];
|
||||
}
|
||||
|
||||
const VERIFIED_SOURCES = [
|
||||
'anthropics/',
|
||||
'vercel/',
|
||||
'vercel-labs/',
|
||||
'modelcontextprotocol/',
|
||||
'cursor/',
|
||||
'google/',
|
||||
'microsoft/',
|
||||
'openai/',
|
||||
];
|
||||
|
||||
const TRUSTED_AUTHORS = [
|
||||
'anthropic',
|
||||
'vercel',
|
||||
'google',
|
||||
'microsoft',
|
||||
'openai',
|
||||
];
|
||||
|
||||
function computeDefaultQuality(skill: Skill): number {
|
||||
let score = 70;
|
||||
|
||||
for (const verified of VERIFIED_SOURCES) {
|
||||
if (skill.source.startsWith(verified)) {
|
||||
score = 85;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skill.author) {
|
||||
for (const trusted of TRUSTED_AUTHORS) {
|
||||
if (skill.author.toLowerCase().includes(trusted)) {
|
||||
score = Math.max(score, 85);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (skill.description && skill.description.length > 50) {
|
||||
score += 3;
|
||||
}
|
||||
|
||||
if (skill.tags && skill.tags.length >= 3) {
|
||||
score += 2;
|
||||
}
|
||||
|
||||
if (skill.version) {
|
||||
score += 2;
|
||||
}
|
||||
|
||||
if (skill.agents && skill.agents.length >= 2) {
|
||||
score += 3;
|
||||
}
|
||||
|
||||
return Math.min(100, score);
|
||||
}
|
||||
|
||||
function main(): void {
|
||||
const skillsPath = join(__dirname, '../marketplace/skills.json');
|
||||
|
||||
console.log('Reading skills.json...');
|
||||
|
||||
let data: SkillsIndex;
|
||||
try {
|
||||
const content = readFileSync(skillsPath, 'utf-8');
|
||||
data = JSON.parse(content) as SkillsIndex;
|
||||
} catch (err) {
|
||||
console.error(`Failed to read or parse skills.json: ${err instanceof Error ? err.message : String(err)}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!data.skills || data.skills.length === 0) {
|
||||
console.log('No skills found in skills.json');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Processing ${data.skills.length} skills...`);
|
||||
|
||||
let updated = 0;
|
||||
let verified = 0;
|
||||
|
||||
for (const skill of data.skills) {
|
||||
const quality = computeDefaultQuality(skill);
|
||||
if (skill.quality !== quality) {
|
||||
skill.quality = quality;
|
||||
updated++;
|
||||
}
|
||||
if (quality >= 85) {
|
||||
verified++;
|
||||
}
|
||||
}
|
||||
|
||||
data.updatedAt = new Date().toISOString().split('T')[0];
|
||||
|
||||
console.log(`Updated ${updated} skills with quality scores`);
|
||||
console.log(`Verified sources: ${verified} skills (quality >= 85)`);
|
||||
|
||||
const averageQuality = Math.round(
|
||||
data.skills.reduce((sum, s) => sum + (s.quality ?? 70), 0) / data.skills.length
|
||||
);
|
||||
console.log(`Average quality: ${averageQuality}`);
|
||||
|
||||
try {
|
||||
writeFileSync(skillsPath, JSON.stringify(data, null, 2) + '\n');
|
||||
console.log('Saved skills.json');
|
||||
} catch (err) {
|
||||
console.error(`Failed to write skills.json: ${err instanceof Error ? err.message : String(err)}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user