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:
airano
2026-03-14 05:05:37 +03:30
parent 4212b5ba47
commit 3e22d2e238
34 changed files with 929 additions and 194 deletions

View File

@@ -38,12 +38,16 @@ async function getSkills(params: {
const limit = 20;
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({
q: params.q,
category: params.category,
platform: params.platform && params.platform !== 'all' ? params.platform : undefined,
format: params.format || 'skill.md',
sort: params.sort || 'lastDownloaded',
sort: effectiveSort,
page,
});
@@ -54,12 +58,14 @@ async function getSkills(params: {
const db = createDb();
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',
'downloads': 'downloads',
'recent': 'updated',
'rating': 'rating',
'lastDownloaded': 'lastDownloaded',
'aiScore': 'aiScore',
'recommended': 'recommended',
};
const filterOptions = {
@@ -67,7 +73,7 @@ async function getSkills(params: {
category: params.category,
platform: params.platform && params.platform !== 'all' ? params.platform : undefined,
sourceFormat: params.format || 'skill.md',
sortBy: sortMap[params.sort || 'lastDownloaded'] || 'lastDownloaded',
sortBy: sortMap[effectiveSort] || defaultSort,
sortOrder: 'desc' as const,
limit,
offset,
@@ -117,11 +123,13 @@ export default async function BrowsePage({ params, searchParams }: BrowsePagePro
const tCommon = await getTranslations('common');
const sortOptions = [
{ id: 'recommended', name: t('filters.sortOptions.recommended') },
{ id: 'lastDownloaded', name: t('filters.sortOptions.lastDownloaded') },
{ 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: 'rating', name: t('filters.sortOptions.rating') },
{ id: 'stars', name: t('filters.sortOptions.stars') },
];
// 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
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 hasActiveFilters = !!(searchParamsResolved.q || currentCategory || (currentSort && currentSort !== 'lastDownloaded') || currentFormat);
const hasActiveFilters = !!(searchParamsResolved.q || currentCategory || (currentSort && currentSort !== defaultSort) || currentFormat);
// Find category name from hierarchical categories
let categoryName = '';

View File

@@ -61,7 +61,7 @@ export default async function ApiDocsPage({
{ 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: '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: 'limit', type: 'number', required: false, description: t('api.params.limit'), default: '20' },
],
@@ -79,7 +79,9 @@ export default async function ApiDocsPage({
"rating": 4.5,
"ratingCount": 23,
"isVerified": true,
"compatibility": { "platforms": ["claude", "cursor"] }
"compatibility": { "platforms": ["claude", "cursor"] },
"reviewStatus": "ai-reviewed",
"aiScore": 85
}
],
"pagination": {
@@ -88,7 +90,7 @@ export default async function ApiDocsPage({
"total": 150,
"totalPages": 8
},
"searchEngine": "meilisearch"
"searchEngine": "postgresql"
}`,
notes: t('api.notes.searchFallback'),
},
@@ -115,7 +117,17 @@ export default async function ApiDocsPage({
"isVerified": true,
"compatibility": { "platforms": ["claude"] },
"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'),
},

View File

@@ -122,6 +122,9 @@ export default async function CliDocsPage({
<code className="block text-sm font-mono">
<span className="text-text-muted">$</span> npx skillhub search &quot;code review&quot; --sort stars --limit 5
</code>
<code className="block text-sm font-mono text-text-muted mt-1">
# Sort options: recommended (default), aiScore, downloads, stars, rating, recent
</code>
</div>
{/* Update all */}
<div>

View File

@@ -44,6 +44,7 @@ npx skillhub uninstall <skill-name> # when done
Rules:
- 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
- Search during planning phase for best results`,
@@ -55,9 +56,9 @@ npx skillhub install <skill-id> --project
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.`,
};
}

View File

@@ -5,7 +5,7 @@ import { Header } from '@/components/Header';
import { Footer } from '@/components/Footer';
import { HeroSearch } from '@/components/HeroSearch';
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 { getPageAlternates } from '@/lib/seo';
import { getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
@@ -24,7 +24,7 @@ async function getStats() {
const browseReady = sql`${skills.isDuplicate} = false AND ${skills.isStale} = false`;
// 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)
db.select({ count: sql<number>`count(*)::int` })
.from(skills)
@@ -32,8 +32,6 @@ async function getStats() {
// Get total downloads (ALL skills — downloads are real user actions)
db.select({ sum: sql<number>`coalesce(sum(${skills.downloadCount}), 0)::int` })
.from(skills),
// Get total categories
categoryQueries.getAll(db),
// Get unique contributors (browse-ready skills only)
db.select({ count: sql<number>`count(distinct ${skills.githubOwner})::int` })
.from(skills)
@@ -42,14 +40,18 @@ async function getStats() {
db.select({ count: sql<number>`count(*)::int` })
.from(skills)
.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 {
totalSkills: skillsResult[0]?.count ?? 0,
totalDownloads: downloadsResult[0]?.sum ?? 0,
totalCategories: categories.length,
totalContributors: contributorsResult[0]?.count ?? 0,
totalIndexed: totalIndexedResult[0]?.count ?? 0,
totalReviewed: reviewedResult[0]?.count ?? 0,
platforms: 5,
};
});
@@ -110,10 +112,10 @@ export default async function HomePage({
]);
const stats = [
{ value: statsData ? formatCompactNumber(statsData.totalSkills, locale) : '۰', label: t('stats.skills'), icon: Layers },
{ value: statsData ? formatCompactNumber(statsData.totalDownloads, locale) : '۰', label: t('stats.downloads'), icon: Download },
{ value: statsData ? formatCompactNumber(statsData.totalContributors, locale) : '۰', label: t('stats.contributors'), icon: Users },
{ value: statsData ? formatCompactNumber(statsData.totalCategories || 8, locale) : '۸', label: t('stats.categories'), icon: Sparkles },
{ 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, href: `/${locale}/browse?sort=downloads` },
{ value: statsData ? formatCompactNumber(statsData.totalContributors, locale) : '۰', label: t('stats.contributors'), icon: Users, href: `/${locale}/attribution` },
{ value: statsData ? formatCompactNumber(statsData.totalReviewed ?? 0, locale) : '۰', label: t('stats.reviewed'), icon: Sparkles, href: `/${locale}/reviewed` },
];
const steps = [
@@ -189,17 +191,17 @@ export default async function HomePage({
<div className="container-main">
<div className="grid grid-cols-2 md:grid-cols-4 gap-8">
{stats.map((stat, index) => (
<div key={index} className="text-center">
<div className="inline-flex items-center justify-center w-12 h-12 rounded-xl bg-primary-50 text-primary-600 mb-3">
<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 group-hover:bg-primary-100 transition-colors">
<stat.icon className="w-6 h-6" />
</div>
<div className="text-3xl font-bold text-text-primary ltr-nums mb-1">
{stat.value}
</div>
<div className="text-text-secondary">
<div className="text-text-secondary group-hover:text-primary-600 transition-colors">
{stat.label}
</div>
</div>
</Link>
))}
</div>
<p className="text-center text-text-muted text-sm mt-6">

View 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>
);
}

View File

@@ -4,7 +4,7 @@ import { notFound } from 'next/navigation';
import { headers } from 'next/headers';
import {
Star, Download, Shield, CheckCircle, Copy,
ExternalLink, Github, Calendar, User, Tag, ChevronRight, Eye
ExternalLink, Github, Calendar, User, Tag, ChevronRight, Eye, Sparkles
} from 'lucide-react';
import { Header } from '@/components/Header';
import { Footer } from '@/components/Footer';
@@ -12,8 +12,8 @@ import { FavoriteButton } from '@/components/FavoriteButton';
import { RatingStars } from '@/components/RatingStars';
import { InstallSection } from '@/components/InstallSection';
import { ShareButton } from '@/components/ShareButton';
import { createDb, skillQueries } from '@skillhub/db';
import { FORMAT_LABELS } from 'skillhub-core';
import { createDb, skillQueries, skillReviewQueries } from '@skillhub/db';
import { FORMAT_LABELS, parseReviewNotes } from 'skillhub-core';
import { formatCompactNumber } from '@/lib/format-number';
import { shouldCountView, getOrSetCache, cacheKeys, cacheTTL } from '@/lib/cache';
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) {
const { locale, id } = await params;
setRequestLocale(locale);
@@ -68,8 +98,11 @@ export default async function SkillPage({ params }: SkillPageProps) {
const skillId = id.join('/');
const isRTL = locale === 'fa';
// Get skill from database
const dbSkill = await getSkill(skillId);
// Get skill and review data from database (in parallel)
const [dbSkill, review] = await Promise.all([
getSkill(skillId),
getSkillReview(skillId),
]);
if (!dbSkill) {
notFound();
@@ -124,6 +157,10 @@ export default async function SkillPage({ params }: SkillPageProps) {
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)
const getContentTitle = (format: string) => {
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>
{/* 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
href={`https://github.com/${skill.author}`}
target="_blank"
rel="noopener noreferrer"
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">
<User className="w-4 h-4" />
@@ -268,47 +306,66 @@ export default async function SkillPage({ params }: SkillPageProps) {
<span className="font-medium">@{skill.author}</span>
</a>
{skill.version && (
<>
<span className="text-text-muted"></span>
<span className="flex items-center gap-1.5 text-text-muted">
<Tag className="w-4 h-4" />
<span className="ltr-nums">v{skill.version}</span>
</span>
</>
<span className="flex items-center gap-1.5 text-text-muted bg-surface-subtle px-2 py-0.5 rounded">
<Tag className="w-3.5 h-3.5" />
<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">
{skill.license}
</span>
<span className="text-text-muted"></span>
<span className="flex items-center gap-1.5 text-text-muted">
<Calendar className="w-4 h-4" />
<span className="flex items-center gap-1.5 text-text-muted bg-surface-subtle px-2 py-0.5 rounded">
<Calendar className="w-3.5 h-3.5" />
<span className="ltr-nums">{skill.updatedAt}</span>
</span>
</div>
</div>
{/* Right: Actions */}
<div className="flex items-center gap-3">
<FavoriteButton skillId={skill.id} size="lg" showLabel={true} />
<ShareButton
title={skill.name}
path={`/${locale}/skill/${skill.id}`}
translations={{
share: t('share.button'),
copied: t('share.copied'),
copyLink: t('share.copyLink'),
}}
/>
<a
href={skill.repository}
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"
title="GitHub"
>
<Github className="w-5 h-5" />
</a>
{/* Right: Actions + AI Score Summary */}
<div className="flex flex-col items-start lg:items-end gap-4">
<div className="flex items-center gap-2">
<FavoriteButton skillId={skill.id} size="lg" showLabel={false} />
<ShareButton
title={skill.name}
path={`/${locale}/skill/${skill.id}`}
translations={{
share: t('share.button'),
copied: t('share.copied'),
copyLink: t('share.copyLink'),
}}
/>
<a
href={skill.repository}
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="GitHub repository"
>
<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>
@@ -369,8 +426,8 @@ export default async function SkillPage({ params }: SkillPageProps) {
{/* Stats Bar */}
<div className="bg-surface-elevated border-b border-border">
<div className="container-main">
<div className="flex items-center gap-6 lg:gap-10 py-4 overflow-x-auto">
<div className="flex items-center gap-2 min-w-fit">
<div className="flex flex-wrap items-center gap-4 lg:gap-8 py-4">
<div className="flex items-center gap-2">
<RatingStars
skillId={skill.id}
averageRating={skill.rating}
@@ -378,29 +435,29 @@ export default async function SkillPage({ params }: SkillPageProps) {
size="sm"
/>
</div>
<div className="h-6 w-px bg-border" />
<div className="flex items-center gap-2 min-w-fit">
<Star className="w-5 h-5 text-gold" />
<div className="hidden sm:block h-5 w-px bg-border" />
<div className="flex items-center gap-2">
<Star className="w-4 h-4 lg:w-5 lg:h-5 text-gold" />
<span className="font-semibold text-text-primary ltr-nums">
{formatCompactNumber(skill.stars, locale)}
</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 className="h-6 w-px bg-border" />
<div className="flex items-center gap-2 min-w-fit">
<Download className="w-5 h-5 text-primary-500" />
<div className="hidden sm:block h-5 w-px bg-border" />
<div className="flex items-center gap-2">
<Download className="w-4 h-4 lg:w-5 lg:h-5 text-primary-500" />
<span className="font-semibold text-text-primary ltr-nums">
{formatCompactNumber(skill.downloads, locale)}
</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 className="h-6 w-px bg-border" />
<div className="flex items-center gap-2 min-w-fit">
<Eye className="w-5 h-5 text-text-muted" />
<div className="hidden sm:block h-5 w-px bg-border" />
<div className="flex items-center gap-2">
<Eye className="w-4 h-4 lg:w-5 lg:h-5 text-text-muted" />
<span className="font-semibold text-text-primary ltr-nums">
{formatCompactNumber(skill.views, locale)}
</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>
@@ -445,6 +502,27 @@ export default async function SkillPage({ params }: SkillPageProps) {
/>
</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 */}
<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">
@@ -455,58 +533,87 @@ export default async function SkillPage({ params }: SkillPageProps) {
</div>
<div className="p-6">
<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>
</pre>
</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>
{/* Right: Sidebar (Desktop) */}
<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">
{/* 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 */}
<InstallSection
skillId={skill.id}
@@ -538,25 +645,6 @@ export default async function SkillPage({ params }: SkillPageProps) {
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>