sync: AI review scores, reviewed page, search improvements, score filter
- Surface AI review scores across skill pages, browse, and search - Add dedicated /reviewed page with score filtering - Add recommended sort using Meilisearch relevance + AI scores - Fix search sort defaulting to stars instead of recommended - Fix CLI TypeScript null check for aiScore in search command - Adjust cache TTL for reviewed content Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "skillhub",
|
"name": "skillhub",
|
||||||
"version": "0.2.5",
|
"version": "0.2.9",
|
||||||
"description": "CLI tool for managing AI Agent skills - search, install, and update skills for Claude, Codex, Copilot, and more",
|
"description": "CLI tool for managing AI Agent skills - search, install, and update skills for Claude, Codex, Copilot, and more",
|
||||||
"author": "SkillHub Contributors",
|
"author": "SkillHub Contributors",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -39,7 +39,12 @@ export async function install(skillId: string, options: InstallOptions): Promise
|
|||||||
try {
|
try {
|
||||||
skillInfo = await getSkill(skillId);
|
skillInfo = await getSkill(skillId);
|
||||||
if (skillInfo) {
|
if (skillInfo) {
|
||||||
spinner.succeed(`Found in registry: ${skillInfo.name}`);
|
const reviewBadge = skillInfo.aiScore && skillInfo.reviewStatus === 'ai-reviewed'
|
||||||
|
? chalk.dim(` | AI: ${skillInfo.aiScore}/100`)
|
||||||
|
: skillInfo.reviewStatus === 'verified'
|
||||||
|
? chalk.green(` | AI: ${skillInfo.aiScore}/100 ✓`)
|
||||||
|
: '';
|
||||||
|
spinner.succeed(`Found in registry: ${skillInfo.name}${reviewBadge}`);
|
||||||
spinner.start('Preparing installation...');
|
spinner.start('Preparing installation...');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export async function search(query: string, options: SearchOptions): Promise<voi
|
|||||||
try {
|
try {
|
||||||
const limit = parseInt(options.limit || '10');
|
const limit = parseInt(options.limit || '10');
|
||||||
const page = parseInt(options.page || '1');
|
const page = parseInt(options.page || '1');
|
||||||
const sort = options.sort || 'downloads';
|
const sort = options.sort || 'recommended';
|
||||||
const result = await searchSkills(query, {
|
const result = await searchSkills(query, {
|
||||||
platform: options.platform,
|
platform: options.platform,
|
||||||
limit,
|
limit,
|
||||||
@@ -34,7 +34,7 @@ export async function search(query: string, options: SearchOptions): Promise<voi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortLabel = { downloads: 'downloads', stars: 'GitHub stars', rating: 'rating', recent: 'recently updated' }[sort] || sort;
|
const sortLabel = { recommended: 'recommended', downloads: 'downloads', stars: 'GitHub stars', rating: 'rating', recent: 'recently updated', aiScore: 'AI score' }[sort] || sort;
|
||||||
console.log(chalk.bold(`Found ${result.pagination.total} skills (sorted by ${sortLabel}):\n`));
|
console.log(chalk.bold(`Found ${result.pagination.total} skills (sorted by ${sortLabel}):\n`));
|
||||||
|
|
||||||
// Print results as a table
|
// Print results as a table
|
||||||
@@ -57,9 +57,14 @@ export async function search(query: string, options: SearchOptions): Promise<voi
|
|||||||
`${num} ${verified} ${chalk.cyan(skill.id.padEnd(38))} ${security}`
|
`${num} ${verified} ${chalk.cyan(skill.id.padEnd(38))} ${security}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Second line: downloads, stars, description
|
// Second line: AI score (if reviewed) + downloads + stars + description
|
||||||
|
const aiScore = skill.aiScore;
|
||||||
|
const hasAiScore = aiScore != null && aiScore > 0 && skill.reviewStatus && skill.reviewStatus !== 'unreviewed' && skill.reviewStatus !== 'auto-scored';
|
||||||
|
const aiPrefix = hasAiScore
|
||||||
|
? `${chalk.magenta('AI')} ${(aiScore >= 75 ? chalk.green : aiScore >= 50 ? chalk.yellow : chalk.dim)(String(aiScore))} `
|
||||||
|
: '';
|
||||||
console.log(
|
console.log(
|
||||||
` ⬇ ${formatNumber(skill.downloadCount).padStart(6)} ⭐ ${formatNumber(skill.githubStars).padStart(6)} ${chalk.dim(skill.description.slice(0, 55))}${skill.description.length > 55 ? '...' : ''}`
|
` ${aiPrefix}⬇ ${formatNumber(skill.downloadCount).padStart(6)} ⭐ ${formatNumber(skill.githubStars).padStart(6)} ${chalk.dim(skill.description.slice(0, hasAiScore ? 45 : 55))}${skill.description.length > (hasAiScore ? 45 : 55) ? '...' : ''}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Third line: Rating (only if ratingCount >= 3)
|
// Third line: Rating (only if ratingCount >= 3)
|
||||||
@@ -83,8 +88,8 @@ export async function search(query: string, options: SearchOptions): Promise<voi
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort === 'downloads') {
|
if (sort === 'recommended') {
|
||||||
console.log(chalk.dim(`Sort options: ${chalk.white('--sort stars|rating|recent')}`));
|
console.log(chalk.dim(`Sort options: ${chalk.white('--sort aiScore|downloads|stars|rating|recent')}`));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
spinner.fail('Search failed');
|
spinner.fail('Search failed');
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ program
|
|||||||
.command('search <query>')
|
.command('search <query>')
|
||||||
.description('Search for skills in the registry')
|
.description('Search for skills in the registry')
|
||||||
.option('-p, --platform <platform>', 'Filter by platform')
|
.option('-p, --platform <platform>', 'Filter by platform')
|
||||||
.option('-s, --sort <sort>', 'Sort by: downloads, stars, rating, recent', 'downloads')
|
.option('-s, --sort <sort>', 'Sort by: recommended, aiScore, downloads, stars, rating, recent', 'recommended')
|
||||||
.option('-l, --limit <number>', 'Number of results', '10')
|
.option('-l, --limit <number>', 'Number of results', '10')
|
||||||
.option('--page <number>', 'Page number', '1')
|
.option('--page <number>', 'Page number', '1')
|
||||||
.action(async (query: string, options) => {
|
.action(async (query: string, options) => {
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ export interface SkillInfo {
|
|||||||
sourceFormat?: string;
|
sourceFormat?: string;
|
||||||
rating?: number | null;
|
rating?: number | null;
|
||||||
ratingCount?: number | null;
|
ratingCount?: number | null;
|
||||||
|
reviewStatus?: string | null;
|
||||||
|
aiScore?: number | null;
|
||||||
isVerified: boolean;
|
isVerified: boolean;
|
||||||
compatibility: {
|
compatibility: {
|
||||||
platforms: string[];
|
platforms: string[];
|
||||||
|
|||||||
@@ -38,12 +38,16 @@ async function getSkills(params: {
|
|||||||
const limit = 20;
|
const limit = 20;
|
||||||
const page = parseInt(params.page || '1');
|
const page = parseInt(params.page || '1');
|
||||||
|
|
||||||
|
// Default sort: lastDownloaded for browsing, recommended when searching
|
||||||
|
const defaultSort = params.q ? 'recommended' : 'lastDownloaded';
|
||||||
|
const effectiveSort = params.sort || defaultSort;
|
||||||
|
|
||||||
const hash = hashSearchParams({
|
const hash = hashSearchParams({
|
||||||
q: params.q,
|
q: params.q,
|
||||||
category: params.category,
|
category: params.category,
|
||||||
platform: params.platform && params.platform !== 'all' ? params.platform : undefined,
|
platform: params.platform && params.platform !== 'all' ? params.platform : undefined,
|
||||||
format: params.format || 'skill.md',
|
format: params.format || 'skill.md',
|
||||||
sort: params.sort || 'lastDownloaded',
|
sort: effectiveSort,
|
||||||
page,
|
page,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,12 +58,14 @@ async function getSkills(params: {
|
|||||||
const db = createDb();
|
const db = createDb();
|
||||||
const offset = (page - 1) * limit;
|
const offset = (page - 1) * limit;
|
||||||
|
|
||||||
const sortMap: Record<string, 'stars' | 'downloads' | 'rating' | 'updated' | 'lastDownloaded'> = {
|
const sortMap: Record<string, 'stars' | 'downloads' | 'rating' | 'updated' | 'lastDownloaded' | 'aiScore' | 'recommended'> = {
|
||||||
'stars': 'stars',
|
'stars': 'stars',
|
||||||
'downloads': 'downloads',
|
'downloads': 'downloads',
|
||||||
'recent': 'updated',
|
'recent': 'updated',
|
||||||
'rating': 'rating',
|
'rating': 'rating',
|
||||||
'lastDownloaded': 'lastDownloaded',
|
'lastDownloaded': 'lastDownloaded',
|
||||||
|
'aiScore': 'aiScore',
|
||||||
|
'recommended': 'recommended',
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterOptions = {
|
const filterOptions = {
|
||||||
@@ -67,7 +73,7 @@ async function getSkills(params: {
|
|||||||
category: params.category,
|
category: params.category,
|
||||||
platform: params.platform && params.platform !== 'all' ? params.platform : undefined,
|
platform: params.platform && params.platform !== 'all' ? params.platform : undefined,
|
||||||
sourceFormat: params.format || 'skill.md',
|
sourceFormat: params.format || 'skill.md',
|
||||||
sortBy: sortMap[params.sort || 'lastDownloaded'] || 'lastDownloaded',
|
sortBy: sortMap[effectiveSort] || defaultSort,
|
||||||
sortOrder: 'desc' as const,
|
sortOrder: 'desc' as const,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
@@ -117,11 +123,13 @@ export default async function BrowsePage({ params, searchParams }: BrowsePagePro
|
|||||||
const tCommon = await getTranslations('common');
|
const tCommon = await getTranslations('common');
|
||||||
|
|
||||||
const sortOptions = [
|
const sortOptions = [
|
||||||
|
{ id: 'recommended', name: t('filters.sortOptions.recommended') },
|
||||||
{ id: 'lastDownloaded', name: t('filters.sortOptions.lastDownloaded') },
|
{ id: 'lastDownloaded', name: t('filters.sortOptions.lastDownloaded') },
|
||||||
{ id: 'downloads', name: t('filters.sortOptions.downloads') },
|
{ id: 'downloads', name: t('filters.sortOptions.downloads') },
|
||||||
{ id: 'stars', name: t('filters.sortOptions.stars') },
|
{ id: 'aiScore', name: t('filters.sortOptions.aiScore') },
|
||||||
{ id: 'recent', name: t('filters.sortOptions.recent') },
|
{ id: 'recent', name: t('filters.sortOptions.recent') },
|
||||||
{ id: 'rating', name: t('filters.sortOptions.rating') },
|
{ id: 'rating', name: t('filters.sortOptions.rating') },
|
||||||
|
{ id: 'stars', name: t('filters.sortOptions.stars') },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Fetch categories hierarchically for filter dropdown with translations (cached 12h)
|
// Fetch categories hierarchically for filter dropdown with translations (cached 12h)
|
||||||
@@ -202,9 +210,10 @@ export default async function BrowsePage({ params, searchParams }: BrowsePagePro
|
|||||||
|
|
||||||
// Get category name for active filters display
|
// Get category name for active filters display
|
||||||
const currentCategory = searchParamsResolved.category;
|
const currentCategory = searchParamsResolved.category;
|
||||||
const currentSort = searchParamsResolved.sort || 'lastDownloaded';
|
const defaultSort = searchParamsResolved.q ? 'recommended' : 'lastDownloaded';
|
||||||
|
const currentSort = searchParamsResolved.sort || defaultSort;
|
||||||
const currentFormat = searchParamsResolved.format || '';
|
const currentFormat = searchParamsResolved.format || '';
|
||||||
const hasActiveFilters = !!(searchParamsResolved.q || currentCategory || (currentSort && currentSort !== 'lastDownloaded') || currentFormat);
|
const hasActiveFilters = !!(searchParamsResolved.q || currentCategory || (currentSort && currentSort !== defaultSort) || currentFormat);
|
||||||
|
|
||||||
// Find category name from hierarchical categories
|
// Find category name from hierarchical categories
|
||||||
let categoryName = '';
|
let categoryName = '';
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export default async function ApiDocsPage({
|
|||||||
{ name: 'format', type: 'string', required: false, description: t('api.params.format'), default: 'skill.md' },
|
{ name: 'format', type: 'string', required: false, description: t('api.params.format'), default: 'skill.md' },
|
||||||
{ name: 'verified', type: 'boolean', required: false, description: t('api.params.verified') },
|
{ name: 'verified', type: 'boolean', required: false, description: t('api.params.verified') },
|
||||||
{ name: 'minStars', type: 'number', required: false, description: t('api.params.minStars') },
|
{ name: 'minStars', type: 'number', required: false, description: t('api.params.minStars') },
|
||||||
{ name: 'sort', type: 'string', required: false, description: t('api.params.sort') + ' (stars, downloads, rating, recent)', default: 'downloads' },
|
{ name: 'sort', type: 'string', required: false, description: t('api.params.sort') + ' (recommended, aiScore, downloads, stars, rating, recent)', default: 'recommended' },
|
||||||
{ name: 'page', type: 'number', required: false, description: t('api.params.page'), default: '1' },
|
{ name: 'page', type: 'number', required: false, description: t('api.params.page'), default: '1' },
|
||||||
{ name: 'limit', type: 'number', required: false, description: t('api.params.limit'), default: '20' },
|
{ name: 'limit', type: 'number', required: false, description: t('api.params.limit'), default: '20' },
|
||||||
],
|
],
|
||||||
@@ -79,7 +79,9 @@ export default async function ApiDocsPage({
|
|||||||
"rating": 4.5,
|
"rating": 4.5,
|
||||||
"ratingCount": 23,
|
"ratingCount": 23,
|
||||||
"isVerified": true,
|
"isVerified": true,
|
||||||
"compatibility": { "platforms": ["claude", "cursor"] }
|
"compatibility": { "platforms": ["claude", "cursor"] },
|
||||||
|
"reviewStatus": "ai-reviewed",
|
||||||
|
"aiScore": 85
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"pagination": {
|
"pagination": {
|
||||||
@@ -88,7 +90,7 @@ export default async function ApiDocsPage({
|
|||||||
"total": 150,
|
"total": 150,
|
||||||
"totalPages": 8
|
"totalPages": 8
|
||||||
},
|
},
|
||||||
"searchEngine": "meilisearch"
|
"searchEngine": "postgresql"
|
||||||
}`,
|
}`,
|
||||||
notes: t('api.notes.searchFallback'),
|
notes: t('api.notes.searchFallback'),
|
||||||
},
|
},
|
||||||
@@ -115,7 +117,17 @@ export default async function ApiDocsPage({
|
|||||||
"isVerified": true,
|
"isVerified": true,
|
||||||
"compatibility": { "platforms": ["claude"] },
|
"compatibility": { "platforms": ["claude"] },
|
||||||
"rawContent": "# Code Review\\n...",
|
"rawContent": "# Code Review\\n...",
|
||||||
"sourceFormat": "skill.md"
|
"sourceFormat": "skill.md",
|
||||||
|
"reviewStatus": "ai-reviewed",
|
||||||
|
"aiScore": 85,
|
||||||
|
"review": {
|
||||||
|
"ai_score": 85,
|
||||||
|
"instruction_quality": 90,
|
||||||
|
"description_precision": 80,
|
||||||
|
"usefulness": 85,
|
||||||
|
"technical_soundness": 85,
|
||||||
|
"review_notes": "RATIONALE: ..."
|
||||||
|
}
|
||||||
}`,
|
}`,
|
||||||
notes: t('api.notes.viewCount'),
|
notes: t('api.notes.viewCount'),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ export default async function CliDocsPage({
|
|||||||
<code className="block text-sm font-mono">
|
<code className="block text-sm font-mono">
|
||||||
<span className="text-text-muted">$</span> npx skillhub search "code review" --sort stars --limit 5
|
<span className="text-text-muted">$</span> npx skillhub search "code review" --sort stars --limit 5
|
||||||
</code>
|
</code>
|
||||||
|
<code className="block text-sm font-mono text-text-muted mt-1">
|
||||||
|
# Sort options: recommended (default), aiScore, downloads, stars, rating, recent
|
||||||
|
</code>
|
||||||
</div>
|
</div>
|
||||||
{/* Update all */}
|
{/* Update all */}
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ npx skillhub uninstall <skill-name> # when done
|
|||||||
|
|
||||||
Rules:
|
Rules:
|
||||||
- Only install skills with security status "Pass"
|
- Only install skills with security status "Pass"
|
||||||
|
- Prefer skills with AI review scores (shown as "AI 75+" in results)
|
||||||
- After installing, read the SKILL.md and follow its instructions
|
- After installing, read the SKILL.md and follow its instructions
|
||||||
- Search during planning phase for best results`,
|
- Search during planning phase for best results`,
|
||||||
|
|
||||||
@@ -55,9 +56,9 @@ npx skillhub install <skill-id> --project
|
|||||||
npx skillhub uninstall <skill-name>
|
npx skillhub uninstall <skill-name>
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
Search for unfamiliar tech or complex tasks. Only install "Pass" security status. Read SKILL.md after install.`,
|
Search for unfamiliar tech or complex tasks. Only install "Pass" security. Prefer "AI 75+" reviewed skills. Read SKILL.md after install.`,
|
||||||
|
|
||||||
oneshot: `You have access to SkillHub (${count} AI agent skills, ${siteUrl}). For unfamiliar or complex tasks: \`npx skillhub search "<query>" --limit 5\` then \`npx skillhub install <id> --project\`. Only "Pass" security. Read SKILL.md after install. Uninstall when done.`,
|
oneshot: `You have access to SkillHub (${count} AI agent skills, ${siteUrl}). For unfamiliar or complex tasks: \`npx skillhub search "<query>" --limit 5\` then \`npx skillhub install <id> --project\`. Only "Pass" security, prefer "AI 75+" reviewed. Read SKILL.md after install. Uninstall when done.`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Header } from '@/components/Header';
|
|||||||
import { Footer } from '@/components/Footer';
|
import { Footer } from '@/components/Footer';
|
||||||
import { HeroSearch } from '@/components/HeroSearch';
|
import { HeroSearch } from '@/components/HeroSearch';
|
||||||
import { SkillCard } from '@/components/SkillCard';
|
import { SkillCard } from '@/components/SkillCard';
|
||||||
import { createDb, categoryQueries, skillQueries, skills, sql } from '@skillhub/db';
|
import { createDb, skillQueries, skills, sql } from '@skillhub/db';
|
||||||
import { formatCompactNumber } from '@/lib/format-number';
|
import { formatCompactNumber } from '@/lib/format-number';
|
||||||
import { getPageAlternates } from '@/lib/seo';
|
import { getPageAlternates } from '@/lib/seo';
|
||||||
import { getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
import { getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
||||||
@@ -24,7 +24,7 @@ async function getStats() {
|
|||||||
const browseReady = sql`${skills.isDuplicate} = false AND ${skills.isStale} = false`;
|
const browseReady = sql`${skills.isDuplicate} = false AND ${skills.isStale} = false`;
|
||||||
|
|
||||||
// Run all independent count queries in parallel
|
// Run all independent count queries in parallel
|
||||||
const [skillsResult, downloadsResult, categories, contributorsResult, totalIndexedResult] = await Promise.all([
|
const [skillsResult, downloadsResult, contributorsResult, totalIndexedResult, reviewedResult] = await Promise.all([
|
||||||
// Get total skills count (browse-ready, SKILL.md only)
|
// Get total skills count (browse-ready, SKILL.md only)
|
||||||
db.select({ count: sql<number>`count(*)::int` })
|
db.select({ count: sql<number>`count(*)::int` })
|
||||||
.from(skills)
|
.from(skills)
|
||||||
@@ -32,8 +32,6 @@ async function getStats() {
|
|||||||
// Get total downloads (ALL skills — downloads are real user actions)
|
// Get total downloads (ALL skills — downloads are real user actions)
|
||||||
db.select({ sum: sql<number>`coalesce(sum(${skills.downloadCount}), 0)::int` })
|
db.select({ sum: sql<number>`coalesce(sum(${skills.downloadCount}), 0)::int` })
|
||||||
.from(skills),
|
.from(skills),
|
||||||
// Get total categories
|
|
||||||
categoryQueries.getAll(db),
|
|
||||||
// Get unique contributors (browse-ready skills only)
|
// Get unique contributors (browse-ready skills only)
|
||||||
db.select({ count: sql<number>`count(distinct ${skills.githubOwner})::int` })
|
db.select({ count: sql<number>`count(distinct ${skills.githubOwner})::int` })
|
||||||
.from(skills)
|
.from(skills)
|
||||||
@@ -42,14 +40,18 @@ async function getStats() {
|
|||||||
db.select({ count: sql<number>`count(*)::int` })
|
db.select({ count: sql<number>`count(*)::int` })
|
||||||
.from(skills)
|
.from(skills)
|
||||||
.where(sql`${skills.isBlocked} = false`),
|
.where(sql`${skills.isBlocked} = false`),
|
||||||
|
// Get AI-reviewed skills count
|
||||||
|
db.select({ count: sql<number>`count(*)::int` })
|
||||||
|
.from(skills)
|
||||||
|
.where(sql`${skills.sourceFormat} = 'skill.md' AND ${skills.isBlocked} = false AND ${browseReady} AND ${skills.reviewStatus} IN ('ai-reviewed', 'verified')`),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalSkills: skillsResult[0]?.count ?? 0,
|
totalSkills: skillsResult[0]?.count ?? 0,
|
||||||
totalDownloads: downloadsResult[0]?.sum ?? 0,
|
totalDownloads: downloadsResult[0]?.sum ?? 0,
|
||||||
totalCategories: categories.length,
|
|
||||||
totalContributors: contributorsResult[0]?.count ?? 0,
|
totalContributors: contributorsResult[0]?.count ?? 0,
|
||||||
totalIndexed: totalIndexedResult[0]?.count ?? 0,
|
totalIndexed: totalIndexedResult[0]?.count ?? 0,
|
||||||
|
totalReviewed: reviewedResult[0]?.count ?? 0,
|
||||||
platforms: 5,
|
platforms: 5,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -110,10 +112,10 @@ export default async function HomePage({
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const stats = [
|
const stats = [
|
||||||
{ value: statsData ? formatCompactNumber(statsData.totalSkills, locale) : '۰', label: t('stats.skills'), icon: Layers },
|
{ value: statsData ? formatCompactNumber(statsData.totalSkills, locale) : '۰', label: t('stats.skills'), icon: Layers, href: `/${locale}/browse` },
|
||||||
{ value: statsData ? formatCompactNumber(statsData.totalDownloads, locale) : '۰', label: t('stats.downloads'), icon: Download },
|
{ value: statsData ? formatCompactNumber(statsData.totalDownloads, locale) : '۰', label: t('stats.downloads'), icon: Download, href: `/${locale}/browse?sort=downloads` },
|
||||||
{ value: statsData ? formatCompactNumber(statsData.totalContributors, locale) : '۰', label: t('stats.contributors'), icon: Users },
|
{ value: statsData ? formatCompactNumber(statsData.totalContributors, locale) : '۰', label: t('stats.contributors'), icon: Users, href: `/${locale}/attribution` },
|
||||||
{ value: statsData ? formatCompactNumber(statsData.totalCategories || 8, locale) : '۸', label: t('stats.categories'), icon: Sparkles },
|
{ value: statsData ? formatCompactNumber(statsData.totalReviewed ?? 0, locale) : '۰', label: t('stats.reviewed'), icon: Sparkles, href: `/${locale}/reviewed` },
|
||||||
];
|
];
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
@@ -189,17 +191,17 @@ export default async function HomePage({
|
|||||||
<div className="container-main">
|
<div className="container-main">
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-8">
|
<div className="grid grid-cols-2 md:grid-cols-4 gap-8">
|
||||||
{stats.map((stat, index) => (
|
{stats.map((stat, index) => (
|
||||||
<div key={index} className="text-center">
|
<Link key={index} href={stat.href} className="text-center group">
|
||||||
<div className="inline-flex items-center justify-center w-12 h-12 rounded-xl bg-primary-50 text-primary-600 mb-3">
|
<div className="inline-flex items-center justify-center w-12 h-12 rounded-xl bg-primary-50 text-primary-600 mb-3 group-hover:bg-primary-100 transition-colors">
|
||||||
<stat.icon className="w-6 h-6" />
|
<stat.icon className="w-6 h-6" />
|
||||||
</div>
|
</div>
|
||||||
<div className="text-3xl font-bold text-text-primary ltr-nums mb-1">
|
<div className="text-3xl font-bold text-text-primary ltr-nums mb-1">
|
||||||
{stat.value}
|
{stat.value}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-text-secondary">
|
<div className="text-text-secondary group-hover:text-primary-600 transition-colors">
|
||||||
{stat.label}
|
{stat.label}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-center text-text-muted text-sm mt-6">
|
<p className="text-center text-text-muted text-sm mt-6">
|
||||||
|
|||||||
152
apps/web/app/[locale]/reviewed/page.tsx
Normal file
152
apps/web/app/[locale]/reviewed/page.tsx
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import { getTranslations, setRequestLocale } from 'next-intl/server';
|
||||||
|
import { Header } from '@/components/Header';
|
||||||
|
import { Footer } from '@/components/Footer';
|
||||||
|
import { createDb, skillQueries } from '@skillhub/db';
|
||||||
|
import { toPersianNumber } from '@/lib/format-number';
|
||||||
|
import { Pagination } from '@/components/BrowseFilters';
|
||||||
|
import { SkillCard } from '@/components/SkillCard';
|
||||||
|
import { ReviewedSortSelector } from '@/components/ReviewedSortSelector';
|
||||||
|
import { getPageAlternates } from '@/lib/seo';
|
||||||
|
import { getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
||||||
|
import { Sparkles } from 'lucide-react';
|
||||||
|
|
||||||
|
|
||||||
|
// Force dynamic rendering to fetch fresh data from database
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
|
interface ReviewedPageProps {
|
||||||
|
params: Promise<{ locale: string }>;
|
||||||
|
searchParams: Promise<{ page?: string; sort?: string; score?: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getReviewedSkillsData(sort: string, page: number, limit: number, minScore: number) {
|
||||||
|
const validSort = (sort === 'aiScore' ? 'aiScore' : 'reviewDate') as 'reviewDate' | 'aiScore';
|
||||||
|
try {
|
||||||
|
return await getOrSetCache(cacheKeys.reviewedPage(validSort, page, minScore), cacheTTL.reviewed, async () => {
|
||||||
|
const db = createDb();
|
||||||
|
const offset = (page - 1) * limit;
|
||||||
|
const [skills, total] = await Promise.all([
|
||||||
|
skillQueries.getReviewedSkills(db, validSort, limit, offset, minScore),
|
||||||
|
skillQueries.countReviewedSkills(db, minScore),
|
||||||
|
]);
|
||||||
|
return { skills, total };
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching reviewed skills:', error);
|
||||||
|
return { skills: [], total: 0 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ locale: string }>;
|
||||||
|
}) {
|
||||||
|
const { locale } = await params;
|
||||||
|
return {
|
||||||
|
alternates: getPageAlternates(locale, '/reviewed'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function ReviewedPage({
|
||||||
|
params,
|
||||||
|
searchParams,
|
||||||
|
}: ReviewedPageProps) {
|
||||||
|
const { locale } = await params;
|
||||||
|
const searchParamsResolved = await searchParams;
|
||||||
|
setRequestLocale(locale);
|
||||||
|
const t = await getTranslations('reviewed');
|
||||||
|
const tBrowse = await getTranslations('browse');
|
||||||
|
|
||||||
|
const limit = 12;
|
||||||
|
const page = parseInt(searchParamsResolved.page || '1');
|
||||||
|
const sort = searchParamsResolved.sort || 'reviewDate';
|
||||||
|
const minScore = searchParamsResolved.score === '0' ? 0 : 50;
|
||||||
|
const { skills: reviewedSkills, total } = await getReviewedSkillsData(sort, page, limit, minScore);
|
||||||
|
const totalPages = Math.ceil(total / limit);
|
||||||
|
|
||||||
|
const startItem = (page - 1) * limit + 1;
|
||||||
|
const endItem = Math.min(page * limit, total);
|
||||||
|
|
||||||
|
const paginationTranslations = {
|
||||||
|
previous: tBrowse('pagination.previous'),
|
||||||
|
next: tBrowse('pagination.next'),
|
||||||
|
page: tBrowse('pagination.page'),
|
||||||
|
of: tBrowse('pagination.of'),
|
||||||
|
};
|
||||||
|
|
||||||
|
const sortTranslations = {
|
||||||
|
sortBy: t('sortBy'),
|
||||||
|
reviewDate: t('sortOptions.reviewDate'),
|
||||||
|
aiScore: t('sortOptions.aiScore'),
|
||||||
|
scoreFilter: t('scoreFilter'),
|
||||||
|
scoreAbove50: t('scoreOptions.above50'),
|
||||||
|
scoreAll: t('scoreOptions.all'),
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen flex flex-col">
|
||||||
|
<Header />
|
||||||
|
<main className="flex-1">
|
||||||
|
<section className="section-header bg-gradient-subtle">
|
||||||
|
<div className="container-main text-center">
|
||||||
|
<div className="inline-flex items-center justify-center w-14 h-14 rounded-2xl bg-primary-50 text-primary-600 mb-4">
|
||||||
|
<Sparkles className="w-7 h-7" />
|
||||||
|
</div>
|
||||||
|
<h1 className="hero-title mb-4">{t('title')}</h1>
|
||||||
|
<p className="hero-subtitle max-w-2xl mx-auto mb-6">{t('subtitle')}</p>
|
||||||
|
<p className="text-text-secondary text-sm max-w-3xl mx-auto leading-relaxed">
|
||||||
|
{t('explanation')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="section bg-surface">
|
||||||
|
<div className="container-main">
|
||||||
|
{/* Sort and results info */}
|
||||||
|
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6">
|
||||||
|
{total > 0 && (
|
||||||
|
<p className="text-text-secondary text-sm">
|
||||||
|
{tBrowse('resultsRange', {
|
||||||
|
start: locale === 'fa' ? toPersianNumber(startItem) : startItem,
|
||||||
|
end: locale === 'fa' ? toPersianNumber(endItem) : endItem,
|
||||||
|
total: locale === 'fa' ? toPersianNumber(total) : total
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<ReviewedSortSelector
|
||||||
|
locale={locale}
|
||||||
|
translations={sortTranslations}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
|
{reviewedSkills.map((skill) => (
|
||||||
|
<SkillCard
|
||||||
|
key={skill.id}
|
||||||
|
skill={skill}
|
||||||
|
locale={locale}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{total === 0 && (
|
||||||
|
<p className="text-center text-text-muted py-12">
|
||||||
|
{locale === 'fa' ? 'هنوز مهارتی بررسی نشده است.' : 'No reviewed skills yet.'}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Pagination */}
|
||||||
|
<Pagination
|
||||||
|
currentPage={page}
|
||||||
|
totalPages={totalPages}
|
||||||
|
locale={locale}
|
||||||
|
translations={paginationTranslations}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
<Footer />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { notFound } from 'next/navigation';
|
|||||||
import { headers } from 'next/headers';
|
import { headers } from 'next/headers';
|
||||||
import {
|
import {
|
||||||
Star, Download, Shield, CheckCircle, Copy,
|
Star, Download, Shield, CheckCircle, Copy,
|
||||||
ExternalLink, Github, Calendar, User, Tag, ChevronRight, Eye
|
ExternalLink, Github, Calendar, User, Tag, ChevronRight, Eye, Sparkles
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { Header } from '@/components/Header';
|
import { Header } from '@/components/Header';
|
||||||
import { Footer } from '@/components/Footer';
|
import { Footer } from '@/components/Footer';
|
||||||
@@ -12,8 +12,8 @@ import { FavoriteButton } from '@/components/FavoriteButton';
|
|||||||
import { RatingStars } from '@/components/RatingStars';
|
import { RatingStars } from '@/components/RatingStars';
|
||||||
import { InstallSection } from '@/components/InstallSection';
|
import { InstallSection } from '@/components/InstallSection';
|
||||||
import { ShareButton } from '@/components/ShareButton';
|
import { ShareButton } from '@/components/ShareButton';
|
||||||
import { createDb, skillQueries } from '@skillhub/db';
|
import { createDb, skillQueries, skillReviewQueries } from '@skillhub/db';
|
||||||
import { FORMAT_LABELS } from 'skillhub-core';
|
import { FORMAT_LABELS, parseReviewNotes } from 'skillhub-core';
|
||||||
import { formatCompactNumber } from '@/lib/format-number';
|
import { formatCompactNumber } from '@/lib/format-number';
|
||||||
import { shouldCountView, getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
import { shouldCountView, getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
||||||
import type { Metadata } from 'next';
|
import type { Metadata } from 'next';
|
||||||
@@ -59,6 +59,36 @@ async function getSkill(skillId: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get skill review with Redis caching (1 hour TTL)
|
||||||
|
async function getSkillReview(skillId: string) {
|
||||||
|
try {
|
||||||
|
return await getOrSetCache(cacheKeys.skillReview(skillId), cacheTTL.skill, async () => {
|
||||||
|
const db = createDb();
|
||||||
|
return await skillReviewQueries.getLatestBySkillId(db, skillId);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Score bar component for the review section
|
||||||
|
function ScoreBar({ label, score }: { label: string; score: number | null | undefined }) {
|
||||||
|
if (score === null || score === undefined) return null;
|
||||||
|
const percentage = Math.min(score, 100);
|
||||||
|
const color = score >= 75 ? 'bg-success' : score >= 50 ? 'bg-gold' : 'bg-text-muted';
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="flex justify-between text-xs mb-1">
|
||||||
|
<span className="text-text-muted">{label}</span>
|
||||||
|
<span className="text-text-primary font-medium ltr-nums">{score}</span>
|
||||||
|
</div>
|
||||||
|
<div className="h-1.5 bg-surface-subtle rounded-full">
|
||||||
|
<div className={`h-full rounded-full ${color}`} style={{ width: `${percentage}%` }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default async function SkillPage({ params }: SkillPageProps) {
|
export default async function SkillPage({ params }: SkillPageProps) {
|
||||||
const { locale, id } = await params;
|
const { locale, id } = await params;
|
||||||
setRequestLocale(locale);
|
setRequestLocale(locale);
|
||||||
@@ -68,8 +98,11 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
const skillId = id.join('/');
|
const skillId = id.join('/');
|
||||||
const isRTL = locale === 'fa';
|
const isRTL = locale === 'fa';
|
||||||
|
|
||||||
// Get skill from database
|
// Get skill and review data from database (in parallel)
|
||||||
const dbSkill = await getSkill(skillId);
|
const [dbSkill, review] = await Promise.all([
|
||||||
|
getSkill(skillId),
|
||||||
|
getSkillReview(skillId),
|
||||||
|
]);
|
||||||
|
|
||||||
if (!dbSkill) {
|
if (!dbSkill) {
|
||||||
notFound();
|
notFound();
|
||||||
@@ -124,6 +157,10 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
sourceFormat: dbSkill.sourceFormat || 'skill.md',
|
sourceFormat: dbSkill.sourceFormat || 'skill.md',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Parse review notes for structured display
|
||||||
|
const parsedNotes = review?.reviewNotes ? parseReviewNotes(review.reviewNotes) : null;
|
||||||
|
const hasReview = review && review.aiScore && (dbSkill.reviewStatus === 'ai-reviewed' || dbSkill.reviewStatus === 'verified');
|
||||||
|
|
||||||
// Content section title based on source format (uses FORMAT_LABELS from skillhub-core)
|
// Content section title based on source format (uses FORMAT_LABELS from skillhub-core)
|
||||||
const getContentTitle = (format: string) => {
|
const getContentTitle = (format: string) => {
|
||||||
const label = FORMAT_LABELS[format as keyof typeof FORMAT_LABELS] || FORMAT_LABELS['skill.md'];
|
const label = FORMAT_LABELS[format as keyof typeof FORMAT_LABELS] || FORMAT_LABELS['skill.md'];
|
||||||
@@ -255,12 +292,13 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Author, Version, License & Last Update */}
|
{/* Author, Version, License & Last Update */}
|
||||||
<div className="flex flex-wrap items-center gap-4 text-sm">
|
<div className="flex flex-wrap items-center gap-3 text-sm">
|
||||||
<a
|
<a
|
||||||
href={`https://github.com/${skill.author}`}
|
href={`https://github.com/${skill.author}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-2 text-text-secondary hover:text-primary-600 transition-colors"
|
className="flex items-center gap-2 text-text-secondary hover:text-primary-600 transition-colors"
|
||||||
|
aria-label={`GitHub profile: ${skill.author}`}
|
||||||
>
|
>
|
||||||
<div className="w-6 h-6 rounded-full bg-surface-subtle flex items-center justify-center">
|
<div className="w-6 h-6 rounded-full bg-surface-subtle flex items-center justify-center">
|
||||||
<User className="w-4 h-4" />
|
<User className="w-4 h-4" />
|
||||||
@@ -268,47 +306,66 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
<span className="font-medium">@{skill.author}</span>
|
<span className="font-medium">@{skill.author}</span>
|
||||||
</a>
|
</a>
|
||||||
{skill.version && (
|
{skill.version && (
|
||||||
<>
|
<span className="flex items-center gap-1.5 text-text-muted bg-surface-subtle px-2 py-0.5 rounded">
|
||||||
<span className="text-text-muted">•</span>
|
<Tag className="w-3.5 h-3.5" />
|
||||||
<span className="flex items-center gap-1.5 text-text-muted">
|
<span className="ltr-nums">v{skill.version}</span>
|
||||||
<Tag className="w-4 h-4" />
|
</span>
|
||||||
<span className="ltr-nums">v{skill.version}</span>
|
|
||||||
</span>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
<span className="text-text-muted">•</span>
|
|
||||||
<span className="text-text-muted bg-surface-subtle px-2 py-0.5 rounded">
|
<span className="text-text-muted bg-surface-subtle px-2 py-0.5 rounded">
|
||||||
{skill.license}
|
{skill.license}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-text-muted">•</span>
|
<span className="flex items-center gap-1.5 text-text-muted bg-surface-subtle px-2 py-0.5 rounded">
|
||||||
<span className="flex items-center gap-1.5 text-text-muted">
|
<Calendar className="w-3.5 h-3.5" />
|
||||||
<Calendar className="w-4 h-4" />
|
|
||||||
<span className="ltr-nums">{skill.updatedAt}</span>
|
<span className="ltr-nums">{skill.updatedAt}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right: Actions */}
|
{/* Right: Actions + AI Score Summary */}
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex flex-col items-start lg:items-end gap-4">
|
||||||
<FavoriteButton skillId={skill.id} size="lg" showLabel={true} />
|
<div className="flex items-center gap-2">
|
||||||
<ShareButton
|
<FavoriteButton skillId={skill.id} size="lg" showLabel={false} />
|
||||||
title={skill.name}
|
<ShareButton
|
||||||
path={`/${locale}/skill/${skill.id}`}
|
title={skill.name}
|
||||||
translations={{
|
path={`/${locale}/skill/${skill.id}`}
|
||||||
share: t('share.button'),
|
translations={{
|
||||||
copied: t('share.copied'),
|
share: t('share.button'),
|
||||||
copyLink: t('share.copyLink'),
|
copied: t('share.copied'),
|
||||||
}}
|
copyLink: t('share.copyLink'),
|
||||||
/>
|
}}
|
||||||
<a
|
/>
|
||||||
href={skill.repository}
|
<a
|
||||||
target="_blank"
|
href={skill.repository}
|
||||||
rel="noopener noreferrer"
|
target="_blank"
|
||||||
className="p-3 rounded-xl bg-surface-elevated hover:bg-surface-subtle border border-border text-text-secondary hover:text-text-primary transition-colors"
|
rel="noopener noreferrer"
|
||||||
title="GitHub"
|
className="p-3 rounded-xl bg-surface-elevated hover:bg-surface-subtle border border-border text-text-secondary hover:text-text-primary transition-colors"
|
||||||
>
|
aria-label="GitHub repository"
|
||||||
<Github className="w-5 h-5" />
|
>
|
||||||
</a>
|
<Github className="w-5 h-5" />
|
||||||
|
</a>
|
||||||
|
{skill.homepage && (
|
||||||
|
<a
|
||||||
|
href={skill.homepage}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="p-3 rounded-xl bg-surface-elevated hover:bg-surface-subtle border border-border text-text-secondary hover:text-text-primary transition-colors"
|
||||||
|
aria-label={isRTL ? 'وبسایت' : 'Homepage'}
|
||||||
|
>
|
||||||
|
<ExternalLink className="w-5 h-5" />
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Compact AI Review Score */}
|
||||||
|
{hasReview && (
|
||||||
|
<div className="flex items-center gap-3 px-4 py-3 bg-surface-elevated rounded-xl border border-border">
|
||||||
|
<Sparkles className={`w-5 h-5 ${review.aiScore! >= 75 ? 'text-success' : 'text-gold'}`} />
|
||||||
|
<span className={`text-2xl font-bold ltr-nums ${review.aiScore! >= 75 ? 'text-success' : review.aiScore! >= 50 ? 'text-gold' : 'text-text-primary'}`}>
|
||||||
|
{review.aiScore}
|
||||||
|
</span>
|
||||||
|
<span className="text-sm text-text-muted">{t('review.outOf100')}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -369,8 +426,8 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
{/* Stats Bar */}
|
{/* Stats Bar */}
|
||||||
<div className="bg-surface-elevated border-b border-border">
|
<div className="bg-surface-elevated border-b border-border">
|
||||||
<div className="container-main">
|
<div className="container-main">
|
||||||
<div className="flex items-center gap-6 lg:gap-10 py-4 overflow-x-auto">
|
<div className="flex flex-wrap items-center gap-4 lg:gap-8 py-4">
|
||||||
<div className="flex items-center gap-2 min-w-fit">
|
<div className="flex items-center gap-2">
|
||||||
<RatingStars
|
<RatingStars
|
||||||
skillId={skill.id}
|
skillId={skill.id}
|
||||||
averageRating={skill.rating}
|
averageRating={skill.rating}
|
||||||
@@ -378,29 +435,29 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
size="sm"
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="h-6 w-px bg-border" />
|
<div className="hidden sm:block h-5 w-px bg-border" />
|
||||||
<div className="flex items-center gap-2 min-w-fit">
|
<div className="flex items-center gap-2">
|
||||||
<Star className="w-5 h-5 text-gold" />
|
<Star className="w-4 h-4 lg:w-5 lg:h-5 text-gold" />
|
||||||
<span className="font-semibold text-text-primary ltr-nums">
|
<span className="font-semibold text-text-primary ltr-nums">
|
||||||
{formatCompactNumber(skill.stars, locale)}
|
{formatCompactNumber(skill.stars, locale)}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-text-muted text-sm">{tCommon('stars')}</span>
|
<span className="text-text-muted text-sm hidden sm:inline">{tCommon('stars')}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="h-6 w-px bg-border" />
|
<div className="hidden sm:block h-5 w-px bg-border" />
|
||||||
<div className="flex items-center gap-2 min-w-fit">
|
<div className="flex items-center gap-2">
|
||||||
<Download className="w-5 h-5 text-primary-500" />
|
<Download className="w-4 h-4 lg:w-5 lg:h-5 text-primary-500" />
|
||||||
<span className="font-semibold text-text-primary ltr-nums">
|
<span className="font-semibold text-text-primary ltr-nums">
|
||||||
{formatCompactNumber(skill.downloads, locale)}
|
{formatCompactNumber(skill.downloads, locale)}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-text-muted text-sm">{tCommon('downloads')}</span>
|
<span className="text-text-muted text-sm hidden sm:inline">{tCommon('downloads')}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="h-6 w-px bg-border" />
|
<div className="hidden sm:block h-5 w-px bg-border" />
|
||||||
<div className="flex items-center gap-2 min-w-fit">
|
<div className="flex items-center gap-2">
|
||||||
<Eye className="w-5 h-5 text-text-muted" />
|
<Eye className="w-4 h-4 lg:w-5 lg:h-5 text-text-muted" />
|
||||||
<span className="font-semibold text-text-primary ltr-nums">
|
<span className="font-semibold text-text-primary ltr-nums">
|
||||||
{formatCompactNumber(skill.views, locale)}
|
{formatCompactNumber(skill.views, locale)}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-text-muted text-sm">{tCommon('views')}</span>
|
<span className="text-text-muted text-sm hidden sm:inline">{tCommon('views')}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -445,6 +502,27 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* AI Review Card (Mobile) */}
|
||||||
|
{hasReview && (
|
||||||
|
<div className="lg:hidden bg-surface-elevated rounded-2xl border border-border p-6">
|
||||||
|
<h3 className="font-semibold text-text-primary mb-4 flex items-center gap-2">
|
||||||
|
<Sparkles className="w-4 h-4 text-primary-500" />
|
||||||
|
{t('review.title')}
|
||||||
|
</h3>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="space-y-3">
|
||||||
|
<ScoreBar label={t('review.instructionQuality')} score={review.instructionQuality} />
|
||||||
|
<ScoreBar label={t('review.descriptionPrecision')} score={review.descriptionPrecision} />
|
||||||
|
<ScoreBar label={t('review.usefulness')} score={review.usefulness} />
|
||||||
|
<ScoreBar label={t('review.technicalSoundness')} score={review.technicalSoundness} />
|
||||||
|
</div>
|
||||||
|
{parsedNotes?.rationale && (
|
||||||
|
<p className="text-sm text-text-secondary pt-3 border-t border-border" dir="auto">{parsedNotes.rationale}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* README Section */}
|
{/* README Section */}
|
||||||
<div className="bg-surface-elevated rounded-2xl border border-border overflow-hidden">
|
<div className="bg-surface-elevated rounded-2xl border border-border overflow-hidden">
|
||||||
<div className="px-6 py-4 border-b border-border bg-surface-subtle/50">
|
<div className="px-6 py-4 border-b border-border bg-surface-subtle/50">
|
||||||
@@ -455,58 +533,87 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<div className="prose prose-slate dark:prose-invert max-w-none" dir="auto">
|
<div className="prose prose-slate dark:prose-invert max-w-none" dir="auto">
|
||||||
<pre className="whitespace-pre-wrap text-sm leading-relaxed bg-surface-subtle rounded-xl p-4 overflow-x-auto text-start border border-border">
|
<pre className="whitespace-pre-wrap break-words text-sm leading-relaxed bg-surface-subtle rounded-xl p-4 overflow-x-auto text-start border border-border">
|
||||||
<code>{skill.longDescription}</code>
|
<code>{skill.longDescription}</code>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Source Links (Mobile) */}
|
|
||||||
<div className="lg:hidden bg-surface-elevated rounded-2xl border border-border p-6">
|
|
||||||
<h3 className="font-semibold text-text-primary mb-4">
|
|
||||||
{isRTL ? 'لینکها' : 'Links'}
|
|
||||||
</h3>
|
|
||||||
<div className="space-y-3">
|
|
||||||
<a
|
|
||||||
href={skill.repository}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="flex items-center justify-between p-3 rounded-xl bg-surface-subtle hover:bg-surface-muted transition-colors group"
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<Github className="w-5 h-5 text-text-muted" />
|
|
||||||
<div>
|
|
||||||
<div className="font-medium text-text-primary">{t('meta.repository')}</div>
|
|
||||||
<div className="text-sm text-text-muted">{skill.author}/{skill.repo}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ExternalLink className="w-4 h-4 text-text-muted group-hover:text-primary-600 transition-colors" />
|
|
||||||
</a>
|
|
||||||
{skill.homepage && (
|
|
||||||
<a
|
|
||||||
href={skill.homepage}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="flex items-center justify-between p-3 rounded-xl bg-surface-subtle hover:bg-surface-muted transition-colors group"
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<ExternalLink className="w-5 h-5 text-text-muted" />
|
|
||||||
<div>
|
|
||||||
<div className="font-medium text-text-primary">{t('meta.homepage')}</div>
|
|
||||||
<div className="text-sm text-text-muted truncate max-w-[200px]">{skill.homepage}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ExternalLink className="w-4 h-4 text-text-muted group-hover:text-primary-600 transition-colors" />
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right: Sidebar (Desktop) */}
|
{/* Right: Sidebar (Desktop) */}
|
||||||
<div className="hidden lg:block space-y-6">
|
<div className="hidden lg:block space-y-6">
|
||||||
<div className="sticky top-24 max-h-[calc(100vh-7rem)] overflow-y-auto space-y-6 scrollbar-thin">
|
<div className="sticky top-24 max-h-[calc(100vh-7rem)] overflow-y-auto space-y-6 scrollbar-thin">
|
||||||
|
{/* AI Review Card (Desktop) — above Install for visibility */}
|
||||||
|
{hasReview && (
|
||||||
|
<div className="bg-surface-elevated rounded-2xl border border-border p-6">
|
||||||
|
<h3 className="font-semibold text-text-primary mb-4 flex items-center gap-2">
|
||||||
|
<Sparkles className="w-4 h-4 text-primary-500" />
|
||||||
|
{t('review.title')}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
{/* Overall Score */}
|
||||||
|
<div className="text-center mb-4">
|
||||||
|
<div className={`text-4xl font-bold ${review.aiScore! >= 75 ? 'text-success' : review.aiScore! >= 50 ? 'text-gold' : 'text-text-primary'}`}>
|
||||||
|
{review.aiScore}
|
||||||
|
</div>
|
||||||
|
<div className="text-sm text-text-muted">{t('review.outOf100')}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 4-axis score bars */}
|
||||||
|
<div className="space-y-3">
|
||||||
|
<ScoreBar label={t('review.instructionQuality')} score={review.instructionQuality} />
|
||||||
|
<ScoreBar label={t('review.descriptionPrecision')} score={review.descriptionPrecision} />
|
||||||
|
<ScoreBar label={t('review.usefulness')} score={review.usefulness} />
|
||||||
|
<ScoreBar label={t('review.technicalSoundness')} score={review.technicalSoundness} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Rationale */}
|
||||||
|
{parsedNotes?.rationale && (
|
||||||
|
<div className="mt-4 pt-4 border-t border-border">
|
||||||
|
<p className="text-sm text-text-secondary" dir="auto">{parsedNotes.rationale}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Tags: Audience, Maturity, Complexity, Use Cases */}
|
||||||
|
{(parsedNotes?.maturity || parsedNotes?.complexity || (parsedNotes?.audience && parsedNotes.audience.length > 0) || (parsedNotes?.useCases && parsedNotes.useCases.length > 0)) && (
|
||||||
|
<div className="mt-4 pt-4 border-t border-border">
|
||||||
|
<div className="flex flex-wrap gap-1.5">
|
||||||
|
{parsedNotes?.maturity && (
|
||||||
|
<span className="px-2 py-0.5 text-xs rounded bg-surface-subtle text-text-muted border border-border">
|
||||||
|
{parsedNotes.maturity}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{parsedNotes?.complexity && (
|
||||||
|
<span className="px-2 py-0.5 text-xs rounded bg-surface-subtle text-text-muted border border-border">
|
||||||
|
{parsedNotes.complexity}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{parsedNotes?.audience?.map((a: string) => (
|
||||||
|
<span key={a} className="px-2 py-0.5 text-xs rounded bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-400">
|
||||||
|
{a.trim()}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
{parsedNotes?.useCases?.map((uc: string) => (
|
||||||
|
<span key={uc} className="px-2 py-0.5 text-xs rounded bg-success/10 text-success">
|
||||||
|
{uc.trim()}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Reviewer info */}
|
||||||
|
<div className="mt-3 text-xs text-text-muted">
|
||||||
|
{t('review.reviewedBy', { reviewer: review.reviewer || 'AI' })}
|
||||||
|
{review.reviewedAt && (
|
||||||
|
<> {t('review.reviewedOn', { date: new Date(review.reviewedAt).toLocaleDateString(locale === 'fa' ? 'fa-IR' : 'en-US') })}</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Install Section */}
|
{/* Install Section */}
|
||||||
<InstallSection
|
<InstallSection
|
||||||
skillId={skill.id}
|
skillId={skill.id}
|
||||||
@@ -538,25 +645,6 @@ export default async function SkillPage({ params }: SkillPageProps) {
|
|||||||
folderNoteSuffix: t('install.folderNoteSuffix') || '" will be created',
|
folderNoteSuffix: t('install.folderNoteSuffix') || '" will be created',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Links Card (Desktop) */}
|
|
||||||
{skill.homepage && (
|
|
||||||
<div className="bg-surface-elevated rounded-2xl border border-border p-6">
|
|
||||||
<h3 className="font-semibold text-text-primary mb-4">
|
|
||||||
{isRTL ? 'لینکها' : 'Links'}
|
|
||||||
</h3>
|
|
||||||
<a
|
|
||||||
href={skill.homepage}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="flex items-center gap-2 text-sm text-text-secondary hover:text-primary-600 transition-colors py-2"
|
|
||||||
>
|
|
||||||
<ExternalLink className="w-4 h-4" />
|
|
||||||
<span className="flex-1">{t('meta.homepage')}</span>
|
|
||||||
<ExternalLink className="w-3 h-3" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const newStatus = r.set_verified ? 'verified' : 'ai-reviewed';
|
const newStatus = r.set_verified ? 'verified' : 'ai-reviewed';
|
||||||
if (r.set_verified) verifiedCount++;
|
if (r.set_verified) verifiedCount++;
|
||||||
|
|
||||||
await skillReviewQueries.updateSkillReviewStatus(db, r.skill_id, newStatus);
|
await skillReviewQueries.updateSkillReviewStatus(db, r.skill_id, newStatus, r.ai_score, new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NextResponse, type NextRequest } from 'next/server';
|
import { NextResponse, type NextRequest } from 'next/server';
|
||||||
import { createDb, skillQueries } from '@skillhub/db';
|
import { createDb, skillQueries, skillReviewQueries } from '@skillhub/db';
|
||||||
import { shouldCountView, getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
import { shouldCountView, getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
|
||||||
|
|
||||||
// Create database connection
|
// Create database connection
|
||||||
@@ -35,12 +35,19 @@ export async function GET(
|
|||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
const skillId = id.join('/');
|
const skillId = id.join('/');
|
||||||
|
|
||||||
// Get skill from database (cached 1h)
|
// Get skill and latest review from database (cached 1h)
|
||||||
const skill = await getOrSetCache(
|
const [skill, review] = await Promise.all([
|
||||||
cacheKeys.skill(skillId),
|
getOrSetCache(
|
||||||
cacheTTL.skill,
|
cacheKeys.skill(skillId),
|
||||||
() => skillQueries.getById(db, skillId)
|
cacheTTL.skill,
|
||||||
);
|
() => skillQueries.getById(db, skillId)
|
||||||
|
),
|
||||||
|
getOrSetCache(
|
||||||
|
cacheKeys.skillReview(skillId),
|
||||||
|
cacheTTL.skill,
|
||||||
|
() => skillReviewQueries.getLatestBySkillId(db, skillId)
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
if (!skill) {
|
if (!skill) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -83,9 +90,21 @@ export async function GET(
|
|||||||
triggers: skill.triggers,
|
triggers: skill.triggers,
|
||||||
rawContent: skill.rawContent,
|
rawContent: skill.rawContent,
|
||||||
sourceFormat: skill.sourceFormat || 'skill.md',
|
sourceFormat: skill.sourceFormat || 'skill.md',
|
||||||
|
reviewStatus: skill.reviewStatus,
|
||||||
|
aiScore: skill.latestAiScore,
|
||||||
createdAt: skill.createdAt,
|
createdAt: skill.createdAt,
|
||||||
updatedAt: skill.updatedAt,
|
updatedAt: skill.updatedAt,
|
||||||
indexedAt: skill.indexedAt,
|
indexedAt: skill.indexedAt,
|
||||||
|
review: review ? {
|
||||||
|
aiScore: review.aiScore,
|
||||||
|
instructionQuality: review.instructionQuality,
|
||||||
|
descriptionPrecision: review.descriptionPrecision,
|
||||||
|
usefulness: review.usefulness,
|
||||||
|
technicalSoundness: review.technicalSoundness,
|
||||||
|
reviewNotes: review.reviewNotes,
|
||||||
|
reviewer: review.reviewer,
|
||||||
|
reviewedAt: review.reviewedAt,
|
||||||
|
} : null,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching skill:', error);
|
console.error('Error fetching skill:', error);
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ export async function GET(request: NextRequest) {
|
|||||||
securityStatus: skill.securityStatus,
|
securityStatus: skill.securityStatus,
|
||||||
isVerified: skill.isVerified,
|
isVerified: skill.isVerified,
|
||||||
compatibility: skill.compatibility,
|
compatibility: skill.compatibility,
|
||||||
|
reviewStatus: skill.reviewStatus,
|
||||||
|
aiScore: skill.latestAiScore,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -97,8 +97,14 @@ export async function GET(request: NextRequest) {
|
|||||||
const useMeilisearch = await isMeilisearchHealthy();
|
const useMeilisearch = await isMeilisearchHealthy();
|
||||||
|
|
||||||
if (useMeilisearch) {
|
if (useMeilisearch) {
|
||||||
// Use Meilisearch for full-text search with relevance ranking
|
// For 'recommended' sort, fetch more results from Meilisearch (by relevance),
|
||||||
// Note: category filter not supported in Meilisearch, handled in PostgreSQL fallback
|
// then post-process to boost ai-reviewed skills to the top
|
||||||
|
const isRecommended = sort === 'recommended';
|
||||||
|
const meiliSort = isRecommended ? undefined : sort as 'stars' | 'downloads' | 'rating' | 'recent';
|
||||||
|
// Fetch extra results for recommended so we have enough after re-ranking
|
||||||
|
const meiliLimit = isRecommended ? Math.min(limit * 3, 60) : limit;
|
||||||
|
const meiliOffset = isRecommended ? 0 : offset;
|
||||||
|
|
||||||
const meiliResult = await meilisearchSearch({
|
const meiliResult = await meilisearchSearch({
|
||||||
query,
|
query,
|
||||||
filters: {
|
filters: {
|
||||||
@@ -106,13 +112,13 @@ export async function GET(request: NextRequest) {
|
|||||||
minStars: minStars > 0 ? minStars : undefined,
|
minStars: minStars > 0 ? minStars : undefined,
|
||||||
verified: verified ? true : undefined,
|
verified: verified ? true : undefined,
|
||||||
},
|
},
|
||||||
sort: sort as 'stars' | 'downloads' | 'rating' | 'recent',
|
sort: meiliSort,
|
||||||
limit,
|
limit: meiliLimit,
|
||||||
offset,
|
offset: meiliOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (meiliResult) {
|
if (meiliResult) {
|
||||||
const skills = meiliResult.hits.map((hit) => ({
|
let skills = meiliResult.hits.map((hit) => ({
|
||||||
id: restoreIdFromMeili(hit.id),
|
id: restoreIdFromMeili(hit.id),
|
||||||
name: hit.name,
|
name: hit.name,
|
||||||
description: hit.description,
|
description: hit.description,
|
||||||
@@ -121,13 +127,31 @@ export async function GET(request: NextRequest) {
|
|||||||
githubStars: hit.githubStars,
|
githubStars: hit.githubStars,
|
||||||
downloadCount: hit.downloadCount,
|
downloadCount: hit.downloadCount,
|
||||||
securityScore: hit.securityScore,
|
securityScore: hit.securityScore,
|
||||||
securityStatus: null, // Not available in Meilisearch yet
|
securityStatus: hit.securityStatus || null,
|
||||||
rating: hit.rating,
|
rating: hit.rating,
|
||||||
ratingCount: null, // Not available in Meilisearch yet
|
ratingCount: null, // Not available in Meilisearch yet
|
||||||
isVerified: hit.isVerified,
|
isVerified: hit.isVerified,
|
||||||
compatibility: { platforms: hit.platforms },
|
compatibility: { platforms: hit.platforms },
|
||||||
|
reviewStatus: hit.reviewStatus || null,
|
||||||
|
aiScore: hit.aiScore || null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// For recommended sort: boost ai-reviewed skills with score >= 75 to top,
|
||||||
|
// preserving Meilisearch relevance order within each group
|
||||||
|
if (isRecommended) {
|
||||||
|
const reviewed = skills.filter(s =>
|
||||||
|
s.aiScore && s.aiScore >= 75 &&
|
||||||
|
(s.reviewStatus === 'ai-reviewed' || s.reviewStatus === 'verified')
|
||||||
|
);
|
||||||
|
const rest = skills.filter(s =>
|
||||||
|
!(s.aiScore && s.aiScore >= 75 &&
|
||||||
|
(s.reviewStatus === 'ai-reviewed' || s.reviewStatus === 'verified'))
|
||||||
|
);
|
||||||
|
// Sort reviewed by score desc (relevance already handled by position)
|
||||||
|
reviewed.sort((a, b) => (b.aiScore || 0) - (a.aiScore || 0));
|
||||||
|
skills = [...reviewed, ...rest].slice(offset, offset + limit);
|
||||||
|
}
|
||||||
|
|
||||||
// Cache the result (5 minutes TTL)
|
// Cache the result (5 minutes TTL)
|
||||||
await setCache(
|
await setCache(
|
||||||
cacheKey,
|
cacheKey,
|
||||||
@@ -159,12 +183,14 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
// Fall back to PostgreSQL search
|
// Fall back to PostgreSQL search
|
||||||
// Map sort parameter to database column
|
// Map sort parameter to database column
|
||||||
const sortByMap: Record<string, 'stars' | 'downloads' | 'rating' | 'updated' | 'lastDownloaded'> = {
|
const sortByMap: Record<string, 'stars' | 'downloads' | 'rating' | 'updated' | 'lastDownloaded' | 'aiScore' | 'recommended'> = {
|
||||||
stars: 'stars',
|
stars: 'stars',
|
||||||
downloads: 'downloads',
|
downloads: 'downloads',
|
||||||
rating: 'rating',
|
rating: 'rating',
|
||||||
recent: 'updated',
|
recent: 'updated',
|
||||||
lastDownloaded: 'lastDownloaded',
|
lastDownloaded: 'lastDownloaded',
|
||||||
|
aiScore: 'aiScore',
|
||||||
|
recommended: 'recommended',
|
||||||
security: 'stars', // Use stars as fallback
|
security: 'stars', // Use stars as fallback
|
||||||
};
|
};
|
||||||
const sortBy = sortByMap[sort] || 'downloads';
|
const sortBy = sortByMap[sort] || 'downloads';
|
||||||
@@ -209,6 +235,8 @@ export async function GET(request: NextRequest) {
|
|||||||
isVerified: skill.isVerified,
|
isVerified: skill.isVerified,
|
||||||
compatibility: skill.compatibility,
|
compatibility: skill.compatibility,
|
||||||
updatedAt: skill.updatedAt,
|
updatedAt: skill.updatedAt,
|
||||||
|
reviewStatus: skill.reviewStatus,
|
||||||
|
aiScore: skill.latestAiScore,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Cache the result (5 minutes TTL)
|
// Cache the result (5 minutes TTL)
|
||||||
|
|||||||
@@ -261,6 +261,22 @@
|
|||||||
@apply bg-surface-subtle text-text-primary;
|
@apply bg-surface-subtle text-text-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Thin scrollbar */
|
||||||
|
.scrollbar-thin {
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: var(--color-border) transparent;
|
||||||
|
}
|
||||||
|
.scrollbar-thin::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
.scrollbar-thin::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.scrollbar-thin::-webkit-scrollbar-thumb {
|
||||||
|
background: var(--color-border);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Card */
|
/* Card */
|
||||||
.card {
|
.card {
|
||||||
@apply bg-surface-elevated rounded-2xl;
|
@apply bg-surface-elevated rounded-2xl;
|
||||||
|
|||||||
@@ -58,13 +58,15 @@ export function BrowseFilters({
|
|||||||
|
|
||||||
// Get current values from URL
|
// Get current values from URL
|
||||||
const currentCategory = searchParams.get('category') || '';
|
const currentCategory = searchParams.get('category') || '';
|
||||||
const currentSort = searchParams.get('sort') || 'lastDownloaded';
|
const hasQuery = !!searchParams.get('q');
|
||||||
|
const defaultSort = hasQuery ? 'recommended' : 'lastDownloaded';
|
||||||
|
const currentSort = searchParams.get('sort') || defaultSort;
|
||||||
const currentFormat = searchParams.get('format') || '';
|
const currentFormat = searchParams.get('format') || '';
|
||||||
|
|
||||||
// Count active filters for mobile badge
|
// Count active filters for mobile badge
|
||||||
const activeFilterCount = [
|
const activeFilterCount = [
|
||||||
currentCategory ? 1 : 0,
|
currentCategory ? 1 : 0,
|
||||||
currentSort !== 'lastDownloaded' ? 1 : 0,
|
currentSort !== defaultSort ? 1 : 0,
|
||||||
currentFormat ? 1 : 0,
|
currentFormat ? 1 : 0,
|
||||||
].reduce((a, b) => a + b, 0);
|
].reduce((a, b) => a + b, 0);
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ export function BrowseFilters({
|
|||||||
|
|
||||||
// Handle sort change
|
// Handle sort change
|
||||||
const handleSortChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
const handleSortChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
updateParams({ sort: e.target.value === 'lastDownloaded' ? null : e.target.value });
|
updateParams({ sort: e.target.value === defaultSort ? null : e.target.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle format change
|
// Handle format change
|
||||||
@@ -272,9 +274,9 @@ export function SearchBar({ placeholder, defaultValue = '' }: SearchBarProps) {
|
|||||||
|
|
||||||
if (searchQuery) {
|
if (searchQuery) {
|
||||||
params.set('q', searchQuery);
|
params.set('q', searchQuery);
|
||||||
// Default to sorting by stars when searching
|
// Remove sort param so server-side defaults to 'recommended' for searches
|
||||||
if (!params.get('sort')) {
|
if (!params.get('sort') || params.get('sort') === 'lastDownloaded') {
|
||||||
params.set('sort', 'stars');
|
params.delete('sort');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
params.delete('q');
|
params.delete('q');
|
||||||
@@ -361,7 +363,8 @@ export function ActiveFilters({
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
|
|
||||||
const hasFilters = query || categoryId || (sortBy && sortBy !== 'lastDownloaded');
|
const defaultSort = query ? 'recommended' : 'lastDownloaded';
|
||||||
|
const hasFilters = query || categoryId || (sortBy && sortBy !== defaultSort);
|
||||||
|
|
||||||
if (!hasFilters) return null;
|
if (!hasFilters) return null;
|
||||||
|
|
||||||
@@ -410,7 +413,7 @@ export function ActiveFilters({
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{sortBy && sortBy !== 'lastDownloaded' && sortName && (
|
{sortBy && sortBy !== defaultSort && sortName && (
|
||||||
<span className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-surface-subtle text-text-secondary text-sm rounded-full">
|
<span className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-surface-subtle text-text-secondary text-sm rounded-full">
|
||||||
<SlidersHorizontal className="w-3 h-3" />
|
<SlidersHorizontal className="w-3 h-3" />
|
||||||
<span>{sortName}</span>
|
<span>{sortName}</span>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export function Footer() {
|
|||||||
{ name: t('links.categories'), href: `/${locale}/categories` },
|
{ name: t('links.categories'), href: `/${locale}/categories` },
|
||||||
{ name: t('links.featured'), href: `/${locale}/featured` },
|
{ name: t('links.featured'), href: `/${locale}/featured` },
|
||||||
{ name: t('links.newSkills'), href: `/${locale}/new` },
|
{ name: t('links.newSkills'), href: `/${locale}/new` },
|
||||||
|
{ name: t('links.reviewedSkills'), href: `/${locale}/reviewed` },
|
||||||
],
|
],
|
||||||
resources: [
|
resources: [
|
||||||
{ name: t('links.documentation'), href: `/${locale}/docs` },
|
{ name: t('links.documentation'), href: `/${locale}/docs` },
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function HeroSearch({ placeholder, locale }: HeroSearchProps) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.dispatchEvent(new Event('progressbar:start'));
|
window.dispatchEvent(new Event('progressbar:start'));
|
||||||
if (query.trim()) {
|
if (query.trim()) {
|
||||||
router.push(`/${locale}/browse?q=${encodeURIComponent(query.trim())}&sort=stars`);
|
router.push(`/${locale}/browse?q=${encodeURIComponent(query.trim())}`);
|
||||||
} else {
|
} else {
|
||||||
router.push(`/${locale}/browse`);
|
router.push(`/${locale}/browse`);
|
||||||
}
|
}
|
||||||
|
|||||||
70
apps/web/components/ReviewedSortSelector.tsx
Normal file
70
apps/web/components/ReviewedSortSelector.tsx
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
import { useTransition } from 'react';
|
||||||
|
|
||||||
|
interface ReviewedSortSelectorProps {
|
||||||
|
locale: string;
|
||||||
|
translations: {
|
||||||
|
sortBy: string;
|
||||||
|
reviewDate: string;
|
||||||
|
aiScore: string;
|
||||||
|
scoreFilter: string;
|
||||||
|
scoreAbove50: string;
|
||||||
|
scoreAll: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ReviewedSortSelector({ locale, translations }: ReviewedSortSelectorProps) {
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const [isPending, startTransition] = useTransition();
|
||||||
|
const currentSort = searchParams.get('sort') || 'reviewDate';
|
||||||
|
const currentScore = searchParams.get('score') || '50';
|
||||||
|
|
||||||
|
const navigate = (updates: Record<string, string>) => {
|
||||||
|
const params = new URLSearchParams(searchParams.toString());
|
||||||
|
for (const [key, value] of Object.entries(updates)) {
|
||||||
|
params.set(key, value);
|
||||||
|
}
|
||||||
|
params.delete('page');
|
||||||
|
startTransition(() => {
|
||||||
|
router.push(`/${locale}/reviewed?${params.toString()}`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-4 flex-wrap">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<label htmlFor="sort-select" className="text-sm text-text-secondary whitespace-nowrap">
|
||||||
|
{translations.sortBy}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="sort-select"
|
||||||
|
value={currentSort}
|
||||||
|
onChange={(e) => navigate({ sort: e.target.value })}
|
||||||
|
disabled={isPending}
|
||||||
|
className="text-sm border border-border rounded-lg px-3 py-1.5 bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<option value="reviewDate">{translations.reviewDate}</option>
|
||||||
|
<option value="aiScore">{translations.aiScore}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<label htmlFor="score-filter" className="text-sm text-text-secondary whitespace-nowrap">
|
||||||
|
{translations.scoreFilter}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="score-filter"
|
||||||
|
value={currentScore}
|
||||||
|
onChange={(e) => navigate({ score: e.target.value })}
|
||||||
|
disabled={isPending}
|
||||||
|
className="text-sm border border-border rounded-lg px-3 py-1.5 bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<option value="50">{translations.scoreAbove50}</option>
|
||||||
|
<option value="0">{translations.scoreAll}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Star, Download, Shield, CheckCircle, Clock, RefreshCw } from 'lucide-react';
|
import { Star, Download, Shield, CheckCircle, Clock, RefreshCw, Sparkles } from 'lucide-react';
|
||||||
import { formatCompactNumber } from '@/lib/format-number';
|
import { formatCompactNumber } from '@/lib/format-number';
|
||||||
|
|
||||||
const FORMAT_BADGE_LABELS: Record<string, string> = {
|
const FORMAT_BADGE_LABELS: Record<string, string> = {
|
||||||
@@ -21,6 +21,9 @@ interface SkillCardProps {
|
|||||||
ratingCount: number | null;
|
ratingCount: number | null;
|
||||||
securityStatus: string | null;
|
securityStatus: string | null;
|
||||||
isVerified: boolean | null;
|
isVerified: boolean | null;
|
||||||
|
reviewStatus?: string | null;
|
||||||
|
aiScore?: number | null;
|
||||||
|
latestAiScore?: number | null;
|
||||||
sourceFormat?: string | null;
|
sourceFormat?: string | null;
|
||||||
createdAt?: Date | string | null;
|
createdAt?: Date | string | null;
|
||||||
updatedAt?: Date | string | null;
|
updatedAt?: Date | string | null;
|
||||||
@@ -53,6 +56,19 @@ export function SkillCard({ skill, locale, showTimeBadge, formatTimeAgo }: Skill
|
|||||||
|
|
||||||
const showRating = (skill.ratingCount ?? 0) >= 3;
|
const showRating = (skill.ratingCount ?? 0) >= 3;
|
||||||
|
|
||||||
|
// AI review score badge (only for reviewed skills with score >= 50)
|
||||||
|
const getAiScoreBadge = () => {
|
||||||
|
const rs = skill.reviewStatus;
|
||||||
|
if (!rs || rs === 'unreviewed' || rs === 'auto-scored') return null;
|
||||||
|
const score = skill.aiScore ?? skill.latestAiScore;
|
||||||
|
if (!score || score < 50) return null;
|
||||||
|
const color = score >= 75
|
||||||
|
? 'text-success bg-success/10 border-success/20'
|
||||||
|
: 'text-gold bg-gold/10 border-gold/20';
|
||||||
|
return { score, color };
|
||||||
|
};
|
||||||
|
const aiScoreBadge = getAiScoreBadge();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
href={`/${locale}/skill/${skill.id}`}
|
href={`/${locale}/skill/${skill.id}`}
|
||||||
@@ -101,8 +117,14 @@ export function SkillCard({ skill, locale, showTimeBadge, formatTimeAgo }: Skill
|
|||||||
{skill.description}
|
{skill.description}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Metadata Row: Stars + Downloads + Rating */}
|
{/* Metadata Row: AI Score + Stars + Downloads + Rating */}
|
||||||
<div className="flex flex-wrap items-center gap-4 text-sm text-text-muted mb-2">
|
<div className="flex flex-wrap items-center gap-4 text-sm text-text-muted mb-2">
|
||||||
|
{aiScoreBadge && (
|
||||||
|
<span className={`flex items-center gap-1 px-1.5 py-0.5 text-xs font-medium rounded border ${aiScoreBadge.color}`}>
|
||||||
|
<Sparkles className="w-3 h-3" />
|
||||||
|
<span className="ltr-nums">{aiScoreBadge.score}</span>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<span className="flex items-center gap-1">
|
<span className="flex items-center gap-1">
|
||||||
<Star className="w-4 h-4" />
|
<Star className="w-4 h-4" />
|
||||||
<span className="ltr-nums">{formatCompactNumber(skill.githubStars || 0, locale)}</span>
|
<span className="ltr-nums">{formatCompactNumber(skill.githubStars || 0, locale)}</span>
|
||||||
|
|||||||
@@ -168,7 +168,9 @@ export const cacheKeys = {
|
|||||||
skill: (id: string) => `skill:${id.replace(/\//g, ':')}`,
|
skill: (id: string) => `skill:${id.replace(/\//g, ':')}`,
|
||||||
skillView: (skillId: string, ip: string) => `view:${skillId.replace(/\//g, ':')}:${ip}`,
|
skillView: (skillId: string, ip: string) => `view:${skillId.replace(/\//g, ':')}:${ip}`,
|
||||||
skillDownload: (skillId: string, ip: string) => `download:${skillId.replace(/\//g, ':')}:${ip}`,
|
skillDownload: (skillId: string, ip: string) => `download:${skillId.replace(/\//g, ':')}:${ip}`,
|
||||||
|
skillReview: (id: string) => `review:skill:${id.replace(/\//g, ':')}`,
|
||||||
reviewStats: () => 'review:stats',
|
reviewStats: () => 'review:stats',
|
||||||
|
reviewedPage: (sort: string, page: number, minScore = 50) => `page:reviewed:${sort}:s${minScore}:${page}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TTL values in seconds
|
// TTL values in seconds
|
||||||
@@ -186,6 +188,7 @@ export const cacheTTL = {
|
|||||||
view: 60 * 60, // 1 hour - same IP can only count as 1 view per hour
|
view: 60 * 60, // 1 hour - same IP can only count as 1 view per hour
|
||||||
download: 5 * 60, // 5 minutes - same IP can only count as 1 download per 5 min
|
download: 5 * 60, // 5 minutes - same IP can only count as 1 download per 5 min
|
||||||
reviewStats: 60, // 1 minute - admin review stats
|
reviewStats: 60, // 1 minute - admin review stats
|
||||||
|
reviewed: 60 * 60, // 1 hour - reviewed skills page
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
"skills": "Curated Skills",
|
"skills": "Curated Skills",
|
||||||
"downloads": "Downloads",
|
"downloads": "Downloads",
|
||||||
"contributors": "Contributors",
|
"contributors": "Contributors",
|
||||||
"categories": "Categories",
|
"reviewed": "AI Reviewed",
|
||||||
"curationNote": "Every skill is deduplicated and quality-filtered from {totalIndexed}+ indexed repositories"
|
"curationNote": "Every skill is deduplicated and quality-filtered from {totalIndexed}+ indexed repositories"
|
||||||
},
|
},
|
||||||
"featured": {
|
"featured": {
|
||||||
@@ -87,11 +87,13 @@
|
|||||||
"allCategories": "All Categories",
|
"allCategories": "All Categories",
|
||||||
"sort": "Sort by",
|
"sort": "Sort by",
|
||||||
"sortOptions": {
|
"sortOptions": {
|
||||||
|
"recommended": "Recommended",
|
||||||
"lastDownloaded": "Recently downloaded",
|
"lastDownloaded": "Recently downloaded",
|
||||||
"stars": "Most stars",
|
"stars": "Most stars",
|
||||||
"downloads": "Most downloads",
|
"downloads": "Most downloads",
|
||||||
"recent": "Recently updated",
|
"recent": "Recently updated",
|
||||||
"rating": "Highest rated"
|
"rating": "Highest rated",
|
||||||
|
"aiScore": "AI Review Score"
|
||||||
},
|
},
|
||||||
"minStars": "Min stars",
|
"minStars": "Min stars",
|
||||||
"minSecurity": "Min security score",
|
"minSecurity": "Min security score",
|
||||||
@@ -178,6 +180,21 @@
|
|||||||
"homepage": "Homepage",
|
"homepage": "Homepage",
|
||||||
"lastUpdate": "Last updated",
|
"lastUpdate": "Last updated",
|
||||||
"createdAt": "Created"
|
"createdAt": "Created"
|
||||||
|
},
|
||||||
|
"review": {
|
||||||
|
"title": "AI Review",
|
||||||
|
"aiScore": "AI Score",
|
||||||
|
"outOf100": "out of 100",
|
||||||
|
"instructionQuality": "Instruction Quality",
|
||||||
|
"descriptionPrecision": "Description Precision",
|
||||||
|
"usefulness": "Usefulness",
|
||||||
|
"technicalSoundness": "Technical Soundness",
|
||||||
|
"audience": "Audience",
|
||||||
|
"maturity": "Maturity",
|
||||||
|
"complexity": "Complexity",
|
||||||
|
"useCases": "Use Cases",
|
||||||
|
"reviewedBy": "Reviewed by {reviewer}",
|
||||||
|
"reviewedOn": "on {date}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"footer": {
|
"footer": {
|
||||||
@@ -202,7 +219,8 @@
|
|||||||
"privacyPolicy": "Privacy Policy",
|
"privacyPolicy": "Privacy Policy",
|
||||||
"termsOfService": "Terms of Service",
|
"termsOfService": "Terms of Service",
|
||||||
"attribution": "Attribution",
|
"attribution": "Attribution",
|
||||||
"manageSkills": "Manage Skills"
|
"manageSkills": "Manage Skills",
|
||||||
|
"reviewedSkills": "Reviewed Skills"
|
||||||
},
|
},
|
||||||
"sourceCode": "Source Code",
|
"sourceCode": "Source Code",
|
||||||
"copyright": "© {year} SkillHub. Open source under MIT license."
|
"copyright": "© {year} SkillHub. Open source under MIT license."
|
||||||
@@ -538,6 +556,21 @@
|
|||||||
"title": "Featured Skills",
|
"title": "Featured Skills",
|
||||||
"subtitle": "Top skills by popularity and community engagement"
|
"subtitle": "Top skills by popularity and community engagement"
|
||||||
},
|
},
|
||||||
|
"reviewed": {
|
||||||
|
"title": "AI Reviewed Skills",
|
||||||
|
"subtitle": "Skills evaluated and scored by AI for quality and usefulness",
|
||||||
|
"explanation": "Each skill has been evaluated by an AI reviewer on a structured rubric: instruction quality, usefulness, technical soundness, and description precision. Scores range from 0 to 100 — skills scoring 75+ (green badge) are high quality, 50–74 (gold badge) are solid with targeted value.",
|
||||||
|
"sortBy": "Sort by",
|
||||||
|
"sortOptions": {
|
||||||
|
"reviewDate": "Recently reviewed",
|
||||||
|
"aiScore": "Highest score"
|
||||||
|
},
|
||||||
|
"scoreFilter": "Score",
|
||||||
|
"scoreOptions": {
|
||||||
|
"above50": "50+ only",
|
||||||
|
"all": "All scores"
|
||||||
|
}
|
||||||
|
},
|
||||||
"owner": {
|
"owner": {
|
||||||
"title": "@{username}'s Skills",
|
"title": "@{username}'s Skills",
|
||||||
"notFound": "Owner not found",
|
"notFound": "Owner not found",
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
"skills": "مهارت برگزیده",
|
"skills": "مهارت برگزیده",
|
||||||
"downloads": "دانلود",
|
"downloads": "دانلود",
|
||||||
"contributors": "مشارکتکننده",
|
"contributors": "مشارکتکننده",
|
||||||
"categories": "دستهبندی",
|
"reviewed": "بررسیشده با هوش مصنوعی",
|
||||||
"curationNote": "هر مهارت از میان {totalIndexed}+ مخزن ایندکسشده، حذف تکراری و فیلتر کیفیت شده است"
|
"curationNote": "هر مهارت از میان {totalIndexed}+ مخزن ایندکسشده، حذف تکراری و فیلتر کیفیت شده است"
|
||||||
},
|
},
|
||||||
"featured": {
|
"featured": {
|
||||||
@@ -87,11 +87,13 @@
|
|||||||
"allCategories": "همه دستهبندیها",
|
"allCategories": "همه دستهبندیها",
|
||||||
"sort": "مرتبسازی",
|
"sort": "مرتبسازی",
|
||||||
"sortOptions": {
|
"sortOptions": {
|
||||||
|
"recommended": "پیشنهادی",
|
||||||
"lastDownloaded": "اخیراً دانلود شده",
|
"lastDownloaded": "اخیراً دانلود شده",
|
||||||
"stars": "بیشترین ستاره",
|
"stars": "بیشترین ستاره",
|
||||||
"downloads": "بیشترین دانلود",
|
"downloads": "بیشترین دانلود",
|
||||||
"recent": "جدیدترین",
|
"recent": "جدیدترین",
|
||||||
"rating": "بالاترین امتیاز"
|
"rating": "بالاترین امتیاز",
|
||||||
|
"aiScore": "امتیاز بررسی هوش مصنوعی"
|
||||||
},
|
},
|
||||||
"minStars": "حداقل ستاره",
|
"minStars": "حداقل ستاره",
|
||||||
"minSecurity": "حداقل امتیاز امنیتی",
|
"minSecurity": "حداقل امتیاز امنیتی",
|
||||||
@@ -178,6 +180,21 @@
|
|||||||
"homepage": "وبسایت",
|
"homepage": "وبسایت",
|
||||||
"lastUpdate": "آخرین بهروزرسانی",
|
"lastUpdate": "آخرین بهروزرسانی",
|
||||||
"createdAt": "تاریخ ایجاد"
|
"createdAt": "تاریخ ایجاد"
|
||||||
|
},
|
||||||
|
"review": {
|
||||||
|
"title": "بررسی هوش مصنوعی",
|
||||||
|
"aiScore": "امتیاز AI",
|
||||||
|
"outOf100": "از ۱۰۰",
|
||||||
|
"instructionQuality": "کیفیت دستورالعمل",
|
||||||
|
"descriptionPrecision": "دقت توضیحات",
|
||||||
|
"usefulness": "کاربردی بودن",
|
||||||
|
"technicalSoundness": "صحت فنی",
|
||||||
|
"audience": "مخاطبان",
|
||||||
|
"maturity": "بلوغ",
|
||||||
|
"complexity": "پیچیدگی",
|
||||||
|
"useCases": "موارد استفاده",
|
||||||
|
"reviewedBy": "بررسی توسط {reviewer}",
|
||||||
|
"reviewedOn": "در {date}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"footer": {
|
"footer": {
|
||||||
@@ -202,7 +219,8 @@
|
|||||||
"privacyPolicy": "حریم خصوصی",
|
"privacyPolicy": "حریم خصوصی",
|
||||||
"termsOfService": "شرایط استفاده",
|
"termsOfService": "شرایط استفاده",
|
||||||
"attribution": "تقدیر و تشکر",
|
"attribution": "تقدیر و تشکر",
|
||||||
"manageSkills": "مدیریت مهارتها"
|
"manageSkills": "مدیریت مهارتها",
|
||||||
|
"reviewedSkills": "مهارتهای بررسیشده"
|
||||||
},
|
},
|
||||||
"sourceCode": "کد منبع",
|
"sourceCode": "کد منبع",
|
||||||
"copyright": "© {year} SkillHub. کد متنباز تحت مجوز MIT."
|
"copyright": "© {year} SkillHub. کد متنباز تحت مجوز MIT."
|
||||||
@@ -538,6 +556,21 @@
|
|||||||
"title": "مهارتهای ویژه",
|
"title": "مهارتهای ویژه",
|
||||||
"subtitle": "برترین مهارتها بر اساس محبوبیت و مشارکت جامعه"
|
"subtitle": "برترین مهارتها بر اساس محبوبیت و مشارکت جامعه"
|
||||||
},
|
},
|
||||||
|
"reviewed": {
|
||||||
|
"title": "مهارتهای بررسیشده توسط هوش مصنوعی",
|
||||||
|
"subtitle": "مهارتهایی که توسط هوش مصنوعی ارزیابی و امتیازدهی شدهاند",
|
||||||
|
"explanation": "هر مهارت در این فهرست توسط یک ارزیاب هوش مصنوعی بر اساس معیارهای ساختاریافته شامل کیفیت دستورالعمل، کاربرد، درستی فنی و دقت توضیحات بررسی شده است. امتیازها از ۰ تا ۱۰۰ هستند — مهارتهای با امتیاز ۷۵+ (نشان سبز) باکیفیت بالا، ۵۰ تا ۷۴ (نشان طلایی) مستحکم با ارزش هدفمند هستند.",
|
||||||
|
"sortBy": "مرتبسازی",
|
||||||
|
"sortOptions": {
|
||||||
|
"reviewDate": "آخرین بررسیشده",
|
||||||
|
"aiScore": "بالاترین امتیاز"
|
||||||
|
},
|
||||||
|
"scoreFilter": "امتیاز",
|
||||||
|
"scoreOptions": {
|
||||||
|
"above50": "فقط ۵۰+",
|
||||||
|
"all": "همه امتیازها"
|
||||||
|
}
|
||||||
|
},
|
||||||
"owner": {
|
"owner": {
|
||||||
"title": "مهارتهای @{username}",
|
"title": "مهارتهای @{username}",
|
||||||
"notFound": "مالک یافت نشد",
|
"notFound": "مالک یافت نشد",
|
||||||
|
|||||||
@@ -121,14 +121,8 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
name: skillhub-public_postgres_data
|
|
||||||
external: true
|
|
||||||
redis_data:
|
redis_data:
|
||||||
name: skillhub-public_redis_data
|
|
||||||
external: true
|
|
||||||
meilisearch_data:
|
meilisearch_data:
|
||||||
name: skillhub-public_meilisearch_data
|
|
||||||
external: true
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ export {
|
|||||||
// Validator
|
// Validator
|
||||||
export { validateSkill, isValidSkill, formatValidationSummary } from './validator.js';
|
export { validateSkill, isValidSkill, formatValidationSummary } from './validator.js';
|
||||||
|
|
||||||
|
// Review Notes Parser
|
||||||
|
export type { ParsedReviewNotes } from './review-notes-parser.js';
|
||||||
|
export { parseReviewNotes } from './review-notes-parser.js';
|
||||||
|
|
||||||
// Security Scanner
|
// Security Scanner
|
||||||
export {
|
export {
|
||||||
scanSecurity,
|
scanSecurity,
|
||||||
|
|||||||
141
packages/core/src/review-notes-parser.ts
Normal file
141
packages/core/src/review-notes-parser.ts
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/**
|
||||||
|
* Parser for structured review_notes from the AI review pipeline.
|
||||||
|
*
|
||||||
|
* Review notes use tagged sections like:
|
||||||
|
* RATIONALE: ...
|
||||||
|
* USE-CASES: csv-cleaning, pdf-generation
|
||||||
|
* AUDIENCE: data-analysts
|
||||||
|
* MATURITY: production
|
||||||
|
* COMPLEXITY: complex
|
||||||
|
* DEPENDENCIES: node, bash
|
||||||
|
* PLATFORM: cross-platform
|
||||||
|
* COMPLEMENTS: context-manager
|
||||||
|
* SEO-EN: One-line summary
|
||||||
|
* BUNDLE-FIT: productivity
|
||||||
|
* FRAMEWORK-LOCK: none
|
||||||
|
* CONTRIBUTING-REPO: none
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface ParsedReviewNotes {
|
||||||
|
/** Free-text summary before the first structured tag */
|
||||||
|
summary: string;
|
||||||
|
rationale: string | null;
|
||||||
|
useCases: string[];
|
||||||
|
audience: string[];
|
||||||
|
complements: string[];
|
||||||
|
seoEn: string | null;
|
||||||
|
bundleFit: string | null;
|
||||||
|
frameworkLock: string | null;
|
||||||
|
contributingRepo: string | null;
|
||||||
|
maturity: 'prototype' | 'beta' | 'production' | null;
|
||||||
|
complexity: 'simple' | 'moderate' | 'complex' | null;
|
||||||
|
dependencies: string[];
|
||||||
|
platform: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TAG_KEYS = [
|
||||||
|
'RATIONALE',
|
||||||
|
'USE-CASES',
|
||||||
|
'AUDIENCE',
|
||||||
|
'COMPLEMENTS',
|
||||||
|
'SEO-EN',
|
||||||
|
'BUNDLE-FIT',
|
||||||
|
'FRAMEWORK-LOCK',
|
||||||
|
'CONTRIBUTING-REPO',
|
||||||
|
'MATURITY',
|
||||||
|
'COMPLEXITY',
|
||||||
|
'DEPENDENCIES',
|
||||||
|
'PLATFORM',
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
// Build regex that matches any tag at the start of a segment
|
||||||
|
const TAG_REGEX = new RegExp(`(${TAG_KEYS.join('|')}):\\s*`, 'g');
|
||||||
|
|
||||||
|
function splitComma(val: string): string[] {
|
||||||
|
return val
|
||||||
|
.split(',')
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeNone(val: string): string | null {
|
||||||
|
const lower = val.trim().toLowerCase();
|
||||||
|
return lower === 'none' || lower === 'n/a' || lower === '' ? null : val.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseReviewNotes(notes: string | null | undefined): ParsedReviewNotes {
|
||||||
|
const empty: ParsedReviewNotes = {
|
||||||
|
summary: '',
|
||||||
|
rationale: null,
|
||||||
|
useCases: [],
|
||||||
|
audience: [],
|
||||||
|
complements: [],
|
||||||
|
seoEn: null,
|
||||||
|
bundleFit: null,
|
||||||
|
frameworkLock: null,
|
||||||
|
contributingRepo: null,
|
||||||
|
maturity: null,
|
||||||
|
complexity: null,
|
||||||
|
dependencies: [],
|
||||||
|
platform: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!notes) return empty;
|
||||||
|
|
||||||
|
// Normalize escaped newlines to real newlines
|
||||||
|
const normalized = notes.replace(/\\n/g, '\n');
|
||||||
|
|
||||||
|
// Extract tags and their values
|
||||||
|
const tags: Record<string, string> = {};
|
||||||
|
let summary = '';
|
||||||
|
|
||||||
|
// Find the first tag position
|
||||||
|
TAG_REGEX.lastIndex = 0;
|
||||||
|
const firstMatch = TAG_REGEX.exec(normalized);
|
||||||
|
const firstTagPos = firstMatch ? firstMatch.index : normalized.length;
|
||||||
|
|
||||||
|
// Everything before the first tag is the summary
|
||||||
|
summary = normalized.slice(0, firstTagPos).trim();
|
||||||
|
|
||||||
|
// Parse all tag: value pairs
|
||||||
|
const tagMatches: Array<{ tag: string; start: number; valueStart: number }> = [];
|
||||||
|
TAG_REGEX.lastIndex = 0;
|
||||||
|
let match;
|
||||||
|
while ((match = TAG_REGEX.exec(normalized)) !== null) {
|
||||||
|
tagMatches.push({
|
||||||
|
tag: match[1],
|
||||||
|
start: match.index,
|
||||||
|
valueStart: match.index + match[0].length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < tagMatches.length; i++) {
|
||||||
|
const current = tagMatches[i];
|
||||||
|
const nextStart = i + 1 < tagMatches.length ? tagMatches[i + 1].start : normalized.length;
|
||||||
|
const value = normalized.slice(current.valueStart, nextStart).trim();
|
||||||
|
tags[current.tag] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const maturityVal = tags['MATURITY']?.trim().toLowerCase();
|
||||||
|
const complexityVal = tags['COMPLEXITY']?.trim().toLowerCase();
|
||||||
|
|
||||||
|
return {
|
||||||
|
summary,
|
||||||
|
rationale: tags['RATIONALE']?.trim() || null,
|
||||||
|
useCases: tags['USE-CASES'] ? splitComma(tags['USE-CASES']) : [],
|
||||||
|
audience: tags['AUDIENCE'] ? splitComma(tags['AUDIENCE']) : [],
|
||||||
|
complements: tags['COMPLEMENTS'] ? splitComma(tags['COMPLEMENTS']) : [],
|
||||||
|
seoEn: normalizeNone(tags['SEO-EN'] || ''),
|
||||||
|
bundleFit: normalizeNone(tags['BUNDLE-FIT'] || ''),
|
||||||
|
frameworkLock: normalizeNone(tags['FRAMEWORK-LOCK'] || ''),
|
||||||
|
contributingRepo: normalizeNone(tags['CONTRIBUTING-REPO'] || ''),
|
||||||
|
maturity: maturityVal === 'prototype' || maturityVal === 'beta' || maturityVal === 'production'
|
||||||
|
? maturityVal
|
||||||
|
: null,
|
||||||
|
complexity: complexityVal === 'simple' || complexityVal === 'moderate' || complexityVal === 'complex'
|
||||||
|
? complexityVal
|
||||||
|
: null,
|
||||||
|
dependencies: tags['DEPENDENCIES'] ? splitComma(tags['DEPENDENCIES']) : [],
|
||||||
|
platform: normalizeNone(tags['PLATFORM'] || ''),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -28,6 +28,8 @@ export interface MeiliSkillDocument {
|
|||||||
securityStatus: 'pass' | 'warning' | 'fail' | null;
|
securityStatus: 'pass' | 'warning' | 'fail' | null;
|
||||||
isFeatured: boolean;
|
isFeatured: boolean;
|
||||||
isVerified: boolean;
|
isVerified: boolean;
|
||||||
|
reviewStatus: string | null;
|
||||||
|
aiScore: number;
|
||||||
indexedAt: string;
|
indexedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ export interface MeiliSearchOptions {
|
|||||||
verified?: boolean;
|
verified?: boolean;
|
||||||
featured?: boolean;
|
featured?: boolean;
|
||||||
};
|
};
|
||||||
sort?: 'stars' | 'downloads' | 'rating' | 'recent';
|
sort?: 'stars' | 'downloads' | 'rating' | 'recent' | 'aiScore';
|
||||||
limit?: number;
|
limit?: number;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
}
|
}
|
||||||
@@ -154,6 +156,8 @@ export async function initializeSkillsIndex(): Promise<void> {
|
|||||||
'isFeatured',
|
'isFeatured',
|
||||||
'securityScore',
|
'securityScore',
|
||||||
'githubStars',
|
'githubStars',
|
||||||
|
'reviewStatus',
|
||||||
|
'aiScore',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Configure sortable attributes
|
// Configure sortable attributes
|
||||||
@@ -162,6 +166,7 @@ export async function initializeSkillsIndex(): Promise<void> {
|
|||||||
'downloadCount',
|
'downloadCount',
|
||||||
'rating',
|
'rating',
|
||||||
'indexedAt',
|
'indexedAt',
|
||||||
|
'aiScore',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Configure ranking rules (relevance + custom)
|
// Configure ranking rules (relevance + custom)
|
||||||
@@ -279,6 +284,9 @@ export async function searchSkills(options: MeiliSearchOptions): Promise<MeiliSe
|
|||||||
case 'recent':
|
case 'recent':
|
||||||
sort.push('indexedAt:desc');
|
sort.push('indexedAt:desc');
|
||||||
break;
|
break;
|
||||||
|
case 'aiScore':
|
||||||
|
sort.push('aiScore:desc');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchResult: SearchResponse<MeiliSkillDocument> = await index.search(options.query, {
|
const searchResult: SearchResponse<MeiliSkillDocument> = await index.search(options.query, {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export const skillQueries = {
|
|||||||
verified?: boolean;
|
verified?: boolean;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
sortBy?: 'stars' | 'downloads' | 'rating' | 'updated' | 'lastDownloaded';
|
sortBy?: 'stars' | 'downloads' | 'rating' | 'updated' | 'lastDownloaded' | 'aiScore' | 'recommended';
|
||||||
sortOrder?: 'asc' | 'desc';
|
sortOrder?: 'asc' | 'desc';
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
@@ -167,6 +167,8 @@ export const skillQueries = {
|
|||||||
rating: skills.rating,
|
rating: skills.rating,
|
||||||
updated: skills.updatedAt,
|
updated: skills.updatedAt,
|
||||||
lastDownloaded: skills.lastDownloadedAt,
|
lastDownloaded: skills.lastDownloadedAt,
|
||||||
|
aiScore: skills.latestAiScore,
|
||||||
|
recommended: skills.downloadCount, // fallback column, actual ordering uses custom SQL
|
||||||
}[sortBy];
|
}[sortBy];
|
||||||
|
|
||||||
// Secondary sort: when primary values are tied/zero, fall back to another metric
|
// Secondary sort: when primary values are tied/zero, fall back to another metric
|
||||||
@@ -176,14 +178,21 @@ export const skillQueries = {
|
|||||||
rating: skills.githubStars,
|
rating: skills.githubStars,
|
||||||
updated: skills.githubStars,
|
updated: skills.githubStars,
|
||||||
lastDownloaded: skills.downloadCount,
|
lastDownloaded: skills.downloadCount,
|
||||||
|
aiScore: skills.downloadCount,
|
||||||
|
recommended: skills.githubStars,
|
||||||
}[sortBy];
|
}[sortBy];
|
||||||
|
|
||||||
const orderFn = sortOrder === 'asc' ? asc : desc;
|
const orderFn = sortOrder === 'asc' ? asc : desc;
|
||||||
|
|
||||||
// For lastDownloaded sort, use NULLS LAST so never-downloaded skills
|
// For lastDownloaded and aiScore sorts, use NULLS LAST so null-valued skills
|
||||||
// don't dominate the first pages (PostgreSQL puts NULLs first in DESC by default)
|
// don't dominate the first pages (PostgreSQL puts NULLs first in DESC by default)
|
||||||
const primaryOrder = sortBy === 'lastDownloaded'
|
// 'recommended' sort: ai-reviewed skills with score >= 75 first (by score desc), then rest by downloads
|
||||||
|
const primaryOrder = sortBy === 'recommended'
|
||||||
|
? sql`CASE WHEN ${skills.reviewStatus} IN ('ai-reviewed', 'verified') AND ${skills.latestAiScore} >= 75 THEN 0 ELSE 1 END ASC, CASE WHEN ${skills.reviewStatus} IN ('ai-reviewed', 'verified') AND ${skills.latestAiScore} >= 75 THEN ${skills.latestAiScore} ELSE 0 END DESC, ${skills.downloadCount} DESC`
|
||||||
|
: sortBy === 'lastDownloaded'
|
||||||
? sql`${skills.lastDownloadedAt} DESC NULLS LAST`
|
? sql`${skills.lastDownloadedAt} DESC NULLS LAST`
|
||||||
|
: sortBy === 'aiScore'
|
||||||
|
? sql`${skills.latestAiScore} DESC NULLS LAST`
|
||||||
: orderFn(orderByColumn);
|
: orderFn(orderByColumn);
|
||||||
|
|
||||||
// If filtering by category, use JOIN with skillCategories
|
// If filtering by category, use JOIN with skillCategories
|
||||||
@@ -458,6 +467,49 @@ export const skillQueries = {
|
|||||||
return result[0]?.count ?? 0;
|
return result[0]?.count ?? 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get AI-reviewed skills with pagination
|
||||||
|
*/
|
||||||
|
getReviewedSkills: async (db: DB, sortBy: 'reviewDate' | 'aiScore' = 'reviewDate', limit = 12, offset = 0, minScore = 50) => {
|
||||||
|
const order = sortBy === 'aiScore'
|
||||||
|
? sql`${skills.latestAiScore} DESC NULLS LAST, ${skills.latestReviewDate} DESC NULLS LAST`
|
||||||
|
: sql`${skills.latestReviewDate} DESC NULLS LAST, ${skills.latestAiScore} DESC NULLS LAST`;
|
||||||
|
const conditions = [
|
||||||
|
eq(skills.isBlocked, false),
|
||||||
|
eq(skills.sourceFormat, 'skill.md'),
|
||||||
|
browseReadyFilter,
|
||||||
|
inArray(skills.reviewStatus, ['ai-reviewed', 'verified']),
|
||||||
|
];
|
||||||
|
if (minScore > 0) {
|
||||||
|
conditions.push(sql`${skills.latestAiScore} >= ${minScore}`);
|
||||||
|
}
|
||||||
|
return db.select().from(skills)
|
||||||
|
.where(and(...conditions))
|
||||||
|
.orderBy(order)
|
||||||
|
.limit(limit)
|
||||||
|
.offset(offset);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count AI-reviewed skills
|
||||||
|
*/
|
||||||
|
countReviewedSkills: async (db: DB, minScore = 50) => {
|
||||||
|
const conditions = [
|
||||||
|
eq(skills.isBlocked, false),
|
||||||
|
eq(skills.sourceFormat, 'skill.md'),
|
||||||
|
browseReadyFilter,
|
||||||
|
inArray(skills.reviewStatus, ['ai-reviewed', 'verified']),
|
||||||
|
];
|
||||||
|
if (minScore > 0) {
|
||||||
|
conditions.push(sql`${skills.latestAiScore} >= ${minScore}`);
|
||||||
|
}
|
||||||
|
const result = await db
|
||||||
|
.select({ count: sql<number>`cast(count(*) as int)` })
|
||||||
|
.from(skills)
|
||||||
|
.where(and(...conditions));
|
||||||
|
return result[0]?.count ?? 0;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all skills for sitemap generation (lightweight: id, updatedAt, githubOwner only)
|
* Get all skills for sitemap generation (lightweight: id, updatedAt, githubOwner only)
|
||||||
*/
|
*/
|
||||||
@@ -530,12 +582,14 @@ export const skillQueries = {
|
|||||||
.orderBy(
|
.orderBy(
|
||||||
desc(
|
desc(
|
||||||
sql`(
|
sql`(
|
||||||
-- Quality Score (0-60 points)
|
-- Quality Score (0-80 points: base 60 + review bonus 20)
|
||||||
(
|
(
|
||||||
CASE WHEN LENGTH(COALESCE(${skills.description}, '')) > 200 THEN 30
|
CASE WHEN LENGTH(COALESCE(${skills.description}, '')) > 200 THEN 30
|
||||||
ELSE LENGTH(COALESCE(${skills.description}, '')) / 10 END +
|
ELSE LENGTH(COALESCE(${skills.description}, '')) / 10 END +
|
||||||
CASE WHEN ${skills.securityStatus} = 'pass' THEN 20 ELSE 0 END +
|
CASE WHEN ${skills.securityStatus} = 'pass' THEN 20 ELSE 0 END +
|
||||||
CASE WHEN ${skills.rawContent} IS NOT NULL THEN 10 ELSE 0 END
|
CASE WHEN ${skills.rawContent} IS NOT NULL THEN 10 ELSE 0 END +
|
||||||
|
CASE WHEN ${skills.latestAiScore} IS NOT NULL AND ${skills.reviewStatus} IN ('ai-reviewed', 'verified')
|
||||||
|
THEN LEAST(${skills.latestAiScore} / 5, 20) ELSE 0 END
|
||||||
) * ${wQuality} +
|
) * ${wQuality} +
|
||||||
|
|
||||||
-- Freshness Score (0-50 points)
|
-- Freshness Score (0-50 points)
|
||||||
@@ -2782,11 +2836,17 @@ export const skillReviewQueries = {
|
|||||||
updateSkillReviewStatus: async (
|
updateSkillReviewStatus: async (
|
||||||
db: DB,
|
db: DB,
|
||||||
skillId: string,
|
skillId: string,
|
||||||
reviewStatus: string
|
reviewStatus: string,
|
||||||
|
aiScore?: number,
|
||||||
|
reviewDate?: Date
|
||||||
) => {
|
) => {
|
||||||
return db
|
return db
|
||||||
.update(skills)
|
.update(skills)
|
||||||
.set({ reviewStatus })
|
.set({
|
||||||
|
reviewStatus,
|
||||||
|
...(aiScore !== undefined ? { latestAiScore: aiScore } : {}),
|
||||||
|
...(reviewDate ? { latestReviewDate: reviewDate } : {}),
|
||||||
|
})
|
||||||
.where(eq(skills.id, skillId));
|
.where(eq(skills.id, skillId));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ export const skills = pgTable(
|
|||||||
canonicalSkillId: text('canonical_skill_id'), // points to the "original" if this is a duplicate
|
canonicalSkillId: text('canonical_skill_id'), // points to the "original" if this is a duplicate
|
||||||
repoSkillCount: integer('repo_skill_count'), // cached count of skills in same repo
|
repoSkillCount: integer('repo_skill_count'), // cached count of skills in same repo
|
||||||
reviewStatus: text('review_status').default('unreviewed'), // unreviewed → auto-scored → ai-reviewed → verified (or needs-re-review)
|
reviewStatus: text('review_status').default('unreviewed'), // unreviewed → auto-scored → ai-reviewed → verified (or needs-re-review)
|
||||||
|
latestAiScore: integer('latest_ai_score'), // Denormalized from skill_reviews for efficient sorting
|
||||||
|
latestReviewDate: timestamp('latest_review_date', { withTimezone: true }), // When last AI-reviewed
|
||||||
|
|
||||||
// Content (cached)
|
// Content (cached)
|
||||||
contentHash: text('content_hash'),
|
contentHash: text('content_hash'),
|
||||||
@@ -129,6 +131,7 @@ export const skills = pgTable(
|
|||||||
duplicateIdx: index('idx_skills_duplicate').on(table.isDuplicate),
|
duplicateIdx: index('idx_skills_duplicate').on(table.isDuplicate),
|
||||||
contentHashIdx: index('idx_skills_content_hash').on(table.contentHash),
|
contentHashIdx: index('idx_skills_content_hash').on(table.contentHash),
|
||||||
staleIdx: index('idx_skills_stale').on(table.isStale),
|
staleIdx: index('idx_skills_stale').on(table.isStale),
|
||||||
|
aiScoreIdx: index('idx_skills_ai_score').on(table.latestAiScore),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -568,6 +568,11 @@ ALTER TABLE skills ADD COLUMN IF NOT EXISTS stale_since TIMESTAMP WITH TIME ZONE
|
|||||||
ALTER TABLE skills ADD COLUMN IF NOT EXISTS stale_check_count INTEGER DEFAULT 0;
|
ALTER TABLE skills ADD COLUMN IF NOT EXISTS stale_check_count INTEGER DEFAULT 0;
|
||||||
CREATE INDEX IF NOT EXISTS idx_skills_stale ON skills(is_stale) WHERE is_stale = TRUE;
|
CREATE INDEX IF NOT EXISTS idx_skills_stale ON skills(is_stale) WHERE is_stale = TRUE;
|
||||||
|
|
||||||
|
-- Denormalized AI review scores (March 2026)
|
||||||
|
ALTER TABLE skills ADD COLUMN IF NOT EXISTS latest_ai_score INTEGER;
|
||||||
|
ALTER TABLE skills ADD COLUMN IF NOT EXISTS latest_review_date TIMESTAMPTZ;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_skills_ai_score ON skills(latest_ai_score) WHERE latest_ai_score IS NOT NULL;
|
||||||
|
|
||||||
-- Grant permissions
|
-- Grant permissions
|
||||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
|
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
|
||||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO postgres;
|
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO postgres;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { INSTRUCTION_FILE_PATTERNS, type SourceFormat } from 'skillhub-core';
|
import { INSTRUCTION_FILE_PATTERNS, type SourceFormat } from 'skillhub-core';
|
||||||
import { scheduleFullCrawl, scheduleIncrementalCrawl, getQueueStats, getQueue } from './queue.js';
|
import { scheduleFullCrawl, scheduleIncrementalCrawl, getQueueStats, getQueue } from './queue.js';
|
||||||
import { syncAllSkillsToMeilisearch, checkMeilisearchHealth } from './meilisearch-sync.js';
|
import { syncAllSkillsToMeilisearch, checkMeilisearchHealth } from './meilisearch-sync.js';
|
||||||
import { createDb, skillQueries, categoryQueries, discoveredRepoQueries, awesomeListQueries, addRequestQueries, userQueries, skills, sql } from '@skillhub/db';
|
import { createDb, skillQueries, categoryQueries, discoveredRepoQueries, awesomeListQueries, addRequestQueries, userQueries, sql } from '@skillhub/db';
|
||||||
import { createStrategyOrchestrator, createDeepScanCrawler, createAwesomeListCrawler, createPopularReposCrawler, createCommitsSearchCrawler } from './strategies/index.js';
|
import { createStrategyOrchestrator, createDeepScanCrawler, createAwesomeListCrawler, createPopularReposCrawler, createCommitsSearchCrawler } from './strategies/index.js';
|
||||||
import { createCrawler } from './crawler.js';
|
import { createCrawler } from './crawler.js';
|
||||||
import { indexSkill } from './skill-indexer.js';
|
import { indexSkill } from './skill-indexer.js';
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ async function initializeIndex(): Promise<void> {
|
|||||||
'isFeatured',
|
'isFeatured',
|
||||||
'securityScore',
|
'securityScore',
|
||||||
'githubStars',
|
'githubStars',
|
||||||
|
'reviewStatus',
|
||||||
|
'aiScore',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Configure sortable attributes
|
// Configure sortable attributes
|
||||||
@@ -100,6 +102,7 @@ async function initializeIndex(): Promise<void> {
|
|||||||
'downloadCount',
|
'downloadCount',
|
||||||
'rating',
|
'rating',
|
||||||
'indexedAt',
|
'indexedAt',
|
||||||
|
'aiScore',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Configure ranking rules
|
// Configure ranking rules
|
||||||
@@ -144,6 +147,8 @@ export async function syncSkillToMeilisearch(skill: {
|
|||||||
securityStatus?: 'pass' | 'warning' | 'fail' | null;
|
securityStatus?: 'pass' | 'warning' | 'fail' | null;
|
||||||
isFeatured?: boolean | null;
|
isFeatured?: boolean | null;
|
||||||
isVerified?: boolean | null;
|
isVerified?: boolean | null;
|
||||||
|
reviewStatus?: string | null;
|
||||||
|
latestAiScore?: number | null;
|
||||||
indexedAt?: Date | null;
|
indexedAt?: Date | null;
|
||||||
}): Promise<boolean> {
|
}): Promise<boolean> {
|
||||||
const meili = getMeilisearchClient();
|
const meili = getMeilisearchClient();
|
||||||
@@ -171,6 +176,8 @@ export async function syncSkillToMeilisearch(skill: {
|
|||||||
securityStatus: skill.securityStatus || null,
|
securityStatus: skill.securityStatus || null,
|
||||||
isFeatured: skill.isFeatured || false,
|
isFeatured: skill.isFeatured || false,
|
||||||
isVerified: skill.isVerified || false,
|
isVerified: skill.isVerified || false,
|
||||||
|
reviewStatus: skill.reviewStatus || null,
|
||||||
|
aiScore: skill.latestAiScore || 0,
|
||||||
indexedAt: skill.indexedAt?.toISOString() || new Date().toISOString(),
|
indexedAt: skill.indexedAt?.toISOString() || new Date().toISOString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -254,6 +261,8 @@ export async function syncAllSkillsToMeilisearch(
|
|||||||
securityStatus?: 'pass' | 'warning' | 'fail' | null;
|
securityStatus?: 'pass' | 'warning' | 'fail' | null;
|
||||||
isFeatured?: boolean | null;
|
isFeatured?: boolean | null;
|
||||||
isVerified?: boolean | null;
|
isVerified?: boolean | null;
|
||||||
|
reviewStatus?: string | null;
|
||||||
|
latestAiScore?: number | null;
|
||||||
indexedAt?: Date | null;
|
indexedAt?: Date | null;
|
||||||
}>
|
}>
|
||||||
): Promise<{ success: number; failed: number }> {
|
): Promise<{ success: number; failed: number }> {
|
||||||
@@ -284,6 +293,8 @@ export async function syncAllSkillsToMeilisearch(
|
|||||||
securityStatus: skill.securityStatus || null,
|
securityStatus: skill.securityStatus || null,
|
||||||
isFeatured: skill.isFeatured || false,
|
isFeatured: skill.isFeatured || false,
|
||||||
isVerified: skill.isVerified || false,
|
isVerified: skill.isVerified || false,
|
||||||
|
reviewStatus: skill.reviewStatus || null,
|
||||||
|
aiScore: skill.latestAiScore || 0,
|
||||||
indexedAt: skill.indexedAt?.toISOString() || new Date().toISOString(),
|
indexedAt: skill.indexedAt?.toISOString() || new Date().toISOString(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user