Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: skill store add skills tab (#13568)

Rdmclin2e364b9a51631
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 1f0937dabec..b6b6e88f2b1 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -705,6 +705,8 @@
"skillStore.tabs.community": "Community",
"skillStore.tabs.custom": "Custom",
"skillStore.tabs.lobehub": "LobeHub",
+ "skillStore.tabs.mcp": "MCP",
+ "skillStore.tabs.skills": "Skills",
"skillStore.title": "Skill Store",
"skillStore.wantMore.action": "Submit a request →",
"skillStore.wantMore.feedback.message": "## Skill Name\n[Please fill in]\n\n## Use Case\nWhen I am ___, I need ___\n\n## Expected Features\n1.\n2.\n3.\n\n## Reference Examples\n(Optional) Are there any similar tools or features for reference?\n\n---\n💡 Tip: The more specific your description, the better we can meet your needs",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index ee3798abe4d..913d83dd579 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -705,6 +705,8 @@
"skillStore.tabs.community": "社区",
"skillStore.tabs.custom": "自定义",
"skillStore.tabs.lobehub": "LobeHub",
+ "skillStore.tabs.mcp": "MCP",
+ "skillStore.tabs.skills": "技能",
"skillStore.title": "技能商店",
"skillStore.wantMore.action": "提交申请 →",
"skillStore.wantMore.feedback.message": "## 技能名称\n[请填写]\n\n## 使用场景\n当我在___时,我需要___\n\n## 期望功能\n1.\n2.\n3.\n\n## 参考示例\n(可选)是否有类似的工具或功能可供参考?\n\n---\n💡 提示:描述越具体,我们就越能满足您的需求",
diff --git a/packages/builtin-skills/src/task/index.ts b/packages/builtin-skills/src/task/index.ts
index 877d1355a28..c3c49bdf8cd 100644
--- a/packages/builtin-skills/src/task/index.ts
+++ b/packages/builtin-skills/src/task/index.ts
@@ -7,6 +7,7 @@ import content from './SKILL.md';
export const TaskIdentifier = 'task';
export const TaskSkill: BuiltinSkill = {
+ avatar: '📋',
content,
description: 'Task management and execution — create, track, review, and complete tasks via CLI.',
identifier: TaskIdentifier,
diff --git a/src/features/SkillStore/Search/index.tsx b/src/features/SkillStore/Search/index.tsx
index f3f13c6c90d..0a7467c89d3 100644
--- a/src/features/SkillStore/Search/index.tsx
+++ b/src/features/SkillStore/Search/index.tsx
@@ -11,15 +11,14 @@ import { SkillStoreTab } from '../SkillStoreContent';
interface SearchProps {
activeTab: SkillStoreTab;
onLobeHubSearch: (keywords: string) => void;
+ onSkillSearch: (keywords: string) => void;
}
-export const Search = memo<SearchProps>(({ activeTab, onLobeHubSearch }) => {
+export const Search = memo<SearchProps>(({ activeTab, onLobeHubSearch, onSkillSearch }) => {
const { t } = useTranslation('setting');
const mcpKeywords = useToolStore((s) => s.mcpSearchKeywords);
- const isCustomTab = activeTab === SkillStoreTab.Custom;
-
- const keywords = activeTab === SkillStoreTab.Community ? mcpKeywords : '';
+ const keywords = activeTab === SkillStoreTab.MCP ? mcpKeywords : '';
return (
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
@@ -30,9 +29,11 @@ export const Search = memo<SearchProps>(({ activeTab, onLobeHubSearch }) => {
placeholder={t('skillStore.search')}
variant="outlined"
onSearch={(keywords: string) => {
- if (activeTab === SkillStoreTab.Community) {
+ if (activeTab === SkillStoreTab.MCP) {
useToolStore.setState({ mcpSearchKeywords: keywords, searchLoading: true });
- } else if (isCustomTab) {
+ } else if (activeTab === SkillStoreTab.Skills) {
+ onSkillSearch(keywords);
+ } else if (activeTab === SkillStoreTab.Custom) {
useToolStore.setState({ customPluginSearchKeywords: keywords });
} else {
onLobeHubSearch(keywords);
diff --git a/src/features/SkillStore/SkillList/Community/MarketSkillItem.tsx b/src/features/SkillStore/SkillList/Community/MarketSkillItem.tsx
new file mode 100644
index 00000000000..03380602273
--- /dev/null
+++ b/src/features/SkillStore/SkillList/Community/MarketSkillItem.tsx
@@ -0,0 +1,173 @@
+'use client';
+
+import { ActionIcon, Avatar, Block, DropdownMenu, Flexbox, Icon, Modal, Tag } from '@lobehub/ui';
+import { SkillsIcon } from '@lobehub/ui/icons';
+import { App } from 'antd';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { DownloadIcon, Loader2, MoreVerticalIcon, Plus, Trash2 } from 'lucide-react';
+import { lazy, memo, Suspense, useCallback, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { agentSkillService } from '@/services/skill';
+import { useToolStore } from '@/store/tool';
+import { agentSkillsSelectors } from '@/store/tool/selectors';
+import { type DiscoverSkillItem } from '@/types/discover';
+import { downloadFile } from '@/utils/client/downloadFile';
+
+import { itemStyles } from '../style';
+
+const MarketSkillDetail = lazy(() => import('../MarketSkills/MarketSkillDetail'));
+
+const styles = createStaticStyles(({ css }) => ({
+ title: css`
+ cursor: pointer;
+
+ overflow: hidden;
+
+ font-size: 14px;
+ font-weight: 500;
+ color: ${cssVar.colorText};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ &:hover {
+ color: ${cssVar.colorPrimary};
+ }
+ `,
+}));
+
+const MarketSkillItem = memo<DiscoverSkillItem>(({ name, icon, description, identifier }) => {
+ const { t } = useTranslation('plugin');
+ const { t: tc } = useTranslation('common');
+ const [detailOpen, setDetailOpen] = useState(false);
+ const [installing, setInstalling] = useState(false);
+ const [loading, setLoading] = useState(false);
+ const { modal } = App.useApp();
+
+ const installed = useToolStore(agentSkillsSelectors.isAgentSkill(identifier));
+ const installedSkill = useToolStore(agentSkillsSelectors.getAgentSkillByIdentifier(identifier));
+ const [refreshAgentSkills, deleteAgentSkill] = useToolStore((s) => [
+ s.refreshAgentSkills,
+ s.deleteAgentSkill,
+ ]);
+
+ const handleInstall = useCallback(async () => {
+ if (installing || installed) return;
+ setInstalling(true);
+ try {
+ await agentSkillService.importFromMarket(identifier);
+ await refreshAgentSkills();
+ } catch {
+ // silently fail
+ } finally {
+ setInstalling(false);
+ }
+ }, [identifier, installing, installed, refreshAgentSkills]);
+
+ const handleUninstall = useCallback(() => {
+ if (!installedSkill) return;
+ modal.confirm({
+ centered: true,
+ okButtonProps: { danger: true },
+ onOk: async () => {
+ await deleteAgentSkill(installedSkill.id);
+ },
+ title: t('store.actions.confirmUninstall'),
+ type: 'error',
+ });
+ }, [installedSkill, deleteAgentSkill, modal, t]);
+
+ const handleDownload = useCallback(async () => {
+ if (!installedSkill?.zipFileHash) return;
+ setLoading(true);
+ try {
+ const result = await agentSkillService.getZipUrl(installedSkill.id);
+ if (result.url) {
+ await downloadFile(result.url, `${result.name || name}.zip`);
+ }
+ } finally {
+ setLoading(false);
+ }
+ }, [installedSkill, name]);
+
+ const renderAction = () => {
+ if (installed) {
+ return (
+ <DropdownMenu
+ nativeButton={false}
+ placement="bottomRight"
+ items={[
+ ...(installedSkill?.zipFileHash
+ ? [
+ {
+ icon: <Icon icon={DownloadIcon} />,
+ key: 'download',
+ label: tc('download'),
+ onClick: handleDownload,
+ },
+ { type: 'divider' as const },
+ ]
+ : []),
+ {
+ danger: true,
+ icon: <Icon icon={Trash2} />,
+ key: 'uninstall',
+ label: t('store.actions.uninstall'),
+ onClick: handleUninstall,
+ },
+ ]}
+ >
+ <ActionIcon icon={MoreVerticalIcon} loading={loading} />
+ </DropdownMenu>
+ );
+ }
+
+ if (installing) return <ActionIcon loading icon={Loader2} />;
+
+ return <ActionIcon icon={Plus} title={t('store.actions.install')} onClick={handleInstall} />;
+ };
+
+ return (
+ <>
+ <Flexbox className={itemStyles.container} gap={0}>
+ <Block
+ horizontal
+ align={'center'}
+ gap={12}
+ paddingBlock={12}
+ paddingInline={12}
+ variant={'outlined'}
+ >
+ <Avatar avatar={icon || name} shape={'square'} size={40} style={{ flex: 'none' }} />
+ <Flexbox flex={1} gap={4} style={{ minWidth: 0, overflow: 'hidden' }}>
+ <Flexbox horizontal align="center" gap={8}>
+ <span className={styles.title} onClick={() => setDetailOpen(true)}>
+ {name}
+ </span>
+ <Tag icon={<Icon icon={SkillsIcon} />} size={'small'} />
+ </Flexbox>
+ {description && <span className={itemStyles.description}>{description}</span>}
+ </Flexbox>
+ {renderAction()}
+ </Block>
+ </Flexbox>
+ <Modal
+ destroyOnHidden
+ footer={null}
+ open={detailOpen}
+ styles={{ body: { height: 'calc(100dvh - 200px)', overflow: 'hidden', padding: 0 } }}
+ title={t('dev.title.skillDetails')}
+ width={960}
+ onCancel={() => setDetailOpen(false)}
+ >
+ <Suspense fallback={<div style={{ height: '100%' }} />}>
+ <MarketSkillDetail identifier={identifier} />
+ </Suspense>
+ </Modal>
+ </>
+ );
+});
+
+MarketSkillItem.displayName = 'MarketSkillItem';
+
+export default MarketSkillItem;
diff --git a/src/features/SkillStore/SkillList/MCP/index.tsx b/src/features/SkillStore/SkillList/MCP/index.tsx
new file mode 100644
index 00000000000..0519e5ff5c9
--- /dev/null
+++ b/src/features/SkillStore/SkillList/MCP/index.tsx
@@ -0,0 +1,98 @@
+'use client';
+
+import { Center, Icon, Text } from '@lobehub/ui';
+import { ServerCrash } from 'lucide-react';
+import { memo, useEffect, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
+import { VirtuosoGrid } from 'react-virtuoso';
+
+import { useToolStore } from '@/store/tool';
+
+import Item from '../Community/Item';
+import Empty from '../Empty';
+import Loading from '../Loading';
+import { virtuosoGridStyles } from '../style';
+import VirtuosoLoading from '../VirtuosoLoading';
+import WantMoreSkills from '../WantMoreSkills';
+
+export const MCPList = memo(() => {
+ const { t } = useTranslation('setting');
+
+ const [
+ keywords,
+ isMcpListInit,
+ allItems,
+ currentPage,
+ totalPages,
+ searchLoading,
+ useFetchMCPPluginList,
+ loadMoreMCPPlugins,
+ resetMCPPluginList,
+ ] = useToolStore((s) => [
+ s.mcpSearchKeywords,
+ s.isMcpListInit,
+ s.mcpPluginItems,
+ s.currentPage,
+ s.totalPages,
+ s.searchLoading,
+ s.useFetchMCPPluginList,
+ s.loadMoreMCPPlugins,
+ s.resetMCPPluginList,
+ ]);
+
+ const prevKeywordsRef = useRef(keywords);
+
+ useEffect(() => {
+ if (prevKeywordsRef.current !== keywords) {
+ prevKeywordsRef.current = keywords;
+ resetMCPPluginList(keywords);
+ }
+ }, [keywords, resetMCPPluginList]);
+
+ const { isLoading, error } = useFetchMCPPluginList({
+ page: currentPage,
+ pageSize: 20,
+ q: keywords,
+ });
+
+ const hasSearchKeywords = Boolean(keywords && keywords.trim());
+
+ if (searchLoading || !isMcpListInit || (isLoading && allItems.length === 0)) return <Loading />;
+
+ if (error) {
+ return (
+ <Center gap={12} padding={40}>
+ <Icon icon={ServerCrash} size={80} />
+ <Text type={'secondary'}>{t('skillStore.networkError')}</Text>
+ </Center>
+ );
+ }
+
+ if (allItems.length === 0) return <Empty search={hasSearchKeywords} />;
+
+ const hasReachedEnd = totalPages !== undefined && currentPage >= totalPages;
+
+ const renderFooter = () => {
+ if (isLoading) return <VirtuosoLoading />;
+ if (hasReachedEnd) return <WantMoreSkills />;
+ return <div style={{ height: 16 }} />;
+ };
+
+ return (
+ <VirtuosoGrid
+ components={{ Footer: renderFooter }}
+ data={allItems}
+ endReached={loadMoreMCPPlugins}
+ increaseViewportBy={typeof window !== 'undefined' ? window.innerHeight : 0}
+ itemClassName={virtuosoGridStyles.item}
+ itemContent={(_, item) => <Item {...item} />}
+ listClassName={virtuosoGridStyles.list}
+ overscan={24}
+ style={{ height: '60vh', width: '100%' }}
+ />
+ );
+});
+
+MCPList.displayName = 'MCPList';
+
+export default MCPList;
diff --git a/src/features/SkillStore/SkillList/MarketSkills/MarketSkillDetail.tsx b/src/features/SkillStore/SkillList/MarketSkills/MarketSkillDetail.tsx
new file mode 100644
index 00000000000..ad5671e2536
--- /dev/null
+++ b/src/features/SkillStore/SkillList/MarketSkills/MarketSkillDetail.tsx
@@ -0,0 +1,260 @@
+'use client';
+
+import { type SkillResourceTreeNode } from '@lobechat/types';
+import { Github } from '@lobehub/icons';
+import { ActionIcon, Avatar, Flexbox, Icon } from '@lobehub/ui';
+import { Skeleton } from 'antd';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { unzip } from 'fflate';
+import { DotIcon, ExternalLinkIcon } from 'lucide-react';
+import { memo, useEffect, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import PublishedTime from '@/components/PublishedTime';
+import { marketApiService } from '@/services/marketApi';
+import { useDiscoverStore } from '@/store/discover';
+import { useToolStore } from '@/store/tool';
+import { agentSkillsSelectors } from '@/store/tool/selectors';
+import { type DiscoverSkillDetail as DiscoverSkillDetailType } from '@/types/discover';
+
+import ContentViewer from '../../../AgentSkillDetail/ContentViewer';
+import FileTree from '../../../AgentSkillDetail/FileTree';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ description: css`
+ overflow: hidden;
+
+ margin: 0;
+
+ font-size: 13px;
+ line-height: 1.5;
+ color: ${cssVar.colorTextSecondary};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ divider: css`
+ flex-shrink: 0;
+ width: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ left: css`
+ overflow-y: auto;
+ flex-shrink: 0;
+ width: 240px;
+ padding: 8px;
+ `,
+ meta: css`
+ flex-shrink: 0;
+ padding: 16px;
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+ name: css`
+ font-size: 16px;
+ font-weight: 500;
+ line-height: 1.4;
+ color: ${cssVar.colorText};
+ `,
+ right: css`
+ container-type: size;
+ overflow: auto;
+ flex: 1;
+ `,
+}));
+
+interface MarketSkillDetailProps {
+ identifier: string;
+}
+
+const buildContentMap = (nodes: SkillResourceTreeNode[]): Record<string, string> => {
+ const map: Record<string, string> = {};
+ const walk = (items: SkillResourceTreeNode[]) => {
+ for (const node of items) {
+ if (node.type === 'file' && node.content !== undefined) {
+ map[node.path] = node.content;
+ } else if (node.children) {
+ walk(node.children);
+ }
+ }
+ };
+ walk(nodes);
+ return map;
+};
+
+const buildMarketResourceTree = (
+ resources?: DiscoverSkillDetailType['resources'],
+): { name: string; path: string; type: 'file' }[] => {
+ if (!resources) return [];
+ return Object.keys(resources)
+ .sort()
+ .map((path) => ({
+ name: path.split('/').pop() || path,
+ path,
+ type: 'file' as const,
+ }));
+};
+
+/**
+ * Fetch zip from downloadUrl and extract text file contents
+ */
+const fetchZipContents = async (
+ url: string,
+): Promise<{ contentMap: Record<string, string>; tree: SkillResourceTreeNode[] }> => {
+ const res = await fetch(url);
+ const buf = await res.arrayBuffer();
+
+ return new Promise((resolve, reject) => {
+ unzip(new Uint8Array(buf), (err, files) => {
+ if (err) return reject(err);
+
+ const contentMap: Record<string, string> = {};
+ const tree: SkillResourceTreeNode[] = [];
+ const decoder = new TextDecoder();
+
+ for (const [rawPath, data] of Object.entries(files)) {
+ if (rawPath.endsWith('/') || rawPath.includes('__MACOSX')) continue;
+
+ // Strip the top-level directory prefix (e.g. "skill-name/")
+ const slashIdx = rawPath.indexOf('/');
+ const path = slashIdx >= 0 ? rawPath.slice(slashIdx + 1) : rawPath;
+ if (!path || path === 'SKILL.md') continue;
+
+ const content = decoder.decode(data);
+ contentMap[path] = content;
+ tree.push({
+ content,
+ name: path.split('/').pop() || path,
+ path,
+ type: 'file',
+ });
+ }
+
+ tree.sort((a, b) => a.path.localeCompare(b.path));
+ resolve({ contentMap, tree });
+ });
+ });
+};
+
+const MarketSkillDetail = memo<MarketSkillDetailProps>(({ identifier }) => {
+ const { t } = useTranslation('setting');
+ const [selectedFile, setSelectedFile] = useState('SKILL.md');
+
+ // Market data (always fetched for header info + icon)
+ const useFetchSkillDetail = useDiscoverStore((s) => s.useFetchSkillDetail);
+ const { data, isLoading } = useFetchSkillDetail({ identifier });
+
+ // Installed skill data (for full file content)
+ const installedSkill = useToolStore(agentSkillsSelectors.getAgentSkillByIdentifier(identifier));
+ const { data: installedData } = useToolStore((s) => s.useFetchAgentSkillDetail)(
+ installedSkill?.id,
+ );
+
+ // Zip-based content for uninstalled skills
+ const [zipContentMap, setZipContentMap] = useState<Record<string, string>>({});
+ const [zipTree, setZipTree] = useState<SkillResourceTreeNode[]>([]);
+
+ const downloadUrl = marketApiService.getSkillDownloadUrl(encodeURIComponent(identifier));
+
+ useEffect(() => {
+ if (installedSkill) return;
+
+ fetchZipContents(downloadUrl)
+ .then(({ contentMap, tree }) => {
+ setZipContentMap(contentMap);
+ setZipTree(tree);
+ })
+ .catch(() => {
+ // fall back to metadata-only view
+ });
+ }, [downloadUrl, installedSkill]);
+
+ const installedResourceTree = useMemo(
+ () => installedData?.resourceTree ?? [],
+ [installedData?.resourceTree],
+ );
+ const installedContentMap = useMemo(
+ () => buildContentMap(installedResourceTree),
+ [installedResourceTree],
+ );
+
+ // Pick the best content source: installed > zip > market metadata
+ const contentMap = installedResourceTree.length > 0 ? installedContentMap : zipContentMap;
+ const resourceTree = useMemo(() => {
+ if (installedResourceTree.length > 0) return installedResourceTree;
+ if (zipTree.length > 0) return zipTree;
+ return buildMarketResourceTree(data?.resources);
+ }, [installedResourceTree, zipTree, data?.resources]);
+
+ if (isLoading || !data) {
+ return <Skeleton active paragraph={{ rows: 8 }} style={{ padding: 16 }} />;
+ }
+
+ const { name, icon, version, description, homepage, github } = data;
+
+ const skillDetailForViewer = {
+ content: installedData?.skillDetail?.content || data.content,
+ } as any;
+
+ return (
+ <Flexbox style={{ height: '100%', overflow: 'hidden' }}>
+ <div className={styles.meta}>
+ <Flexbox horizontal align={'center'} gap={12}>
+ <Avatar avatar={icon || name} shape={'square'} size={40} style={{ flex: 'none' }} />
+ <Flexbox flex={1} gap={4} style={{ overflow: 'hidden' }}>
+ <Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
+ <Flexbox horizontal align={'center'} className={styles.description} gap={4}>
+ <span className={styles.name}>{name}</span>
+ {version && (
+ <>
+ <Icon icon={DotIcon} />
+ <span>v{version}</span>
+ </>
+ )}
+ <Icon icon={DotIcon} />
+ {t('agentSkillDetail.updatedAt')}{' '}
+ <PublishedTime date={data.updatedAt} template={'MMM DD, YYYY'} />
+ </Flexbox>
+ <Flexbox horizontal align={'center'} gap={2} style={{ flexShrink: 0 }}>
+ {github?.url && (
+ <a href={github.url} rel="noreferrer" target={'_blank'}>
+ <ActionIcon
+ fill={cssVar.colorTextDescription}
+ icon={Github}
+ title={t('agentSkillDetail.repository')}
+ />
+ </a>
+ )}
+ {homepage && (
+ <a href={homepage} rel="noreferrer" target={'_blank'}>
+ <ActionIcon icon={ExternalLinkIcon} title={t('agentSkillDetail.sourceUrl')} />
+ </a>
+ )}
+ </Flexbox>
+ </Flexbox>
+ {description && <p className={styles.description}>{description}</p>}
+ </Flexbox>
+ </Flexbox>
+ </div>
+ <Flexbox horizontal style={{ flex: 1, overflow: 'hidden' }}>
+ <div className={styles.left}>
+ <FileTree
+ resourceTree={resourceTree}
+ selectedFile={selectedFile}
+ onSelectFile={setSelectedFile}
+ />
+ </div>
+ <div className={styles.divider} />
+ <div className={styles.right} key={selectedFile}>
+ <ContentViewer
+ contentMap={contentMap}
+ selectedFile={selectedFile}
+ skillDetail={skillDetailForViewer}
+ />
+ </div>
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+MarketSkillDetail.displayName = 'MarketSkillDetail';
+
+export default MarketSkillDetail;
diff --git a/src/features/SkillStore/SkillList/MarketSkills/index.tsx b/src/features/SkillStore/SkillList/MarketSkills/index.tsx
new file mode 100644
index 00000000000..ef8a384377e
--- /dev/null
+++ b/src/features/SkillStore/SkillList/MarketSkills/index.tsx
@@ -0,0 +1,119 @@
+'use client';
+
+import { Center, Icon, Text } from '@lobehub/ui';
+import { uniqBy } from 'es-toolkit/compat';
+import { ServerCrash } from 'lucide-react';
+import { memo, useCallback, useEffect, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { VirtuosoGrid } from 'react-virtuoso';
+
+import { useClientDataSWR } from '@/libs/swr';
+import { discoverService } from '@/services/discover';
+import { globalHelpers } from '@/store/global/helpers';
+import { useToolStore } from '@/store/tool';
+import { type DiscoverSkillItem, SkillSorts } from '@/types/discover';
+
+import MarketSkillItem from '../Community/MarketSkillItem';
+import Empty from '../Empty';
+import Loading from '../Loading';
+import { virtuosoGridStyles } from '../style';
+import VirtuosoLoading from '../VirtuosoLoading';
+import WantMoreSkills from '../WantMoreSkills';
+
+interface MarketSkillListProps {
+ keywords?: string;
+}
+
+const MarketSkillList = memo<MarketSkillListProps>(({ keywords }) => {
+ const { t } = useTranslation('setting');
+
+ // Ensure agent skills are fetched so install status is available
+ const useFetchAgentSkills = useToolStore((s) => s.useFetchAgentSkills);
+ useFetchAgentSkills(true);
+
+ // Market skills pagination state
+ const [page, setPage] = useState(1);
+ const [items, setItems] = useState<DiscoverSkillItem[]>([]);
+ const [totalPages, setTotalPages] = useState<number>();
+
+ const locale = globalHelpers.getCurrentLanguage();
+ const { data, isLoading, error } = useClientDataSWR(
+ ['skill-store-market-skills', locale, keywords || '', page].filter(Boolean).join('-'),
+ () =>
+ discoverService.getSkillList({
+ page,
+ pageSize: 20,
+ q: keywords || undefined,
+ sort: SkillSorts.InstallCount,
+ }),
+ { revalidateOnFocus: false },
+ );
+
+ // Accumulate items across pages
+ useEffect(() => {
+ if (!data) return;
+ setTotalPages(data.totalPages);
+
+ if (page === 1) {
+ setItems(data.items);
+ } else {
+ setItems((prev) => uniqBy([...prev, ...data.items], (i) => i.identifier));
+ }
+ }, [data, page]);
+
+ // Reset on keyword change
+ const prevKeywordsRef = useRef(keywords);
+ useEffect(() => {
+ if (prevKeywordsRef.current !== keywords) {
+ prevKeywordsRef.current = keywords;
+ setPage(1);
+ setItems([]);
+ setTotalPages(undefined);
+ }
+ }, [keywords]);
+
+ const loadMore = useCallback(() => {
+ if (totalPages === undefined || page < totalPages) {
+ setPage((p) => p + 1);
+ }
+ }, [page, totalPages]);
+
+ if (isLoading && items.length === 0) return <Loading />;
+
+ if (error) {
+ return (
+ <Center gap={12} padding={40}>
+ <Icon icon={ServerCrash} size={80} />
+ <Text type={'secondary'}>{t('skillStore.networkError')}</Text>
+ </Center>
+ );
+ }
+
+ if (items.length === 0) return <Empty search={Boolean(keywords?.trim())} />;
+
+ const hasReachedEnd = totalPages !== undefined && page >= totalPages;
+
+ const renderFooter = () => {
+ if (isLoading) return <VirtuosoLoading />;
+ if (hasReachedEnd) return <WantMoreSkills />;
+ return <div style={{ height: 16 }} />;
+ };
+
+ return (
+ <VirtuosoGrid
+ components={{ Footer: renderFooter }}
+ data={items}
+ endReached={loadMore}
+ increaseViewportBy={typeof window !== 'undefined' ? window.innerHeight : 0}
+ itemClassName={virtuosoGridStyles.item}
+ itemContent={(_, item) => <MarketSkillItem {...item} />}
+ listClassName={virtuosoGridStyles.list}
+ overscan={24}
+ style={{ height: '60vh', width: '100%' }}
+ />
+ );
+});
+
+MarketSkillList.displayName = 'MarketSkillList';
+
+export default MarketSkillList;
diff --git a/src/features/SkillStore/SkillStoreContent.tsx b/src/features/SkillStore/SkillStoreContent.tsx
index 8c6b480515a..76715f04c76 100644
--- a/src/features/SkillStore/SkillStoreContent.tsx
+++ b/src/features/SkillStore/SkillStoreContent.tsx
@@ -7,29 +7,34 @@ import { useTranslation } from 'react-i18next';
import Search from './Search';
import AddSkillButton from './SkillList/AddSkillButton';
-import CommunityList from './SkillList/Community';
import CustomList from './SkillList/Custom';
import LobeHubList from './SkillList/LobeHub';
+import MarketSkillList from './SkillList/MarketSkills';
+import MCPList from './SkillList/MCP';
export enum SkillStoreTab {
- Community = 'community',
Custom = 'custom',
LobeHub = 'lobehub',
+ MCP = 'mcp',
+ Skills = 'skills',
}
export const SkillStoreContent = () => {
const { t } = useTranslation('setting');
const [activeTab, setActiveTab] = useState<SkillStoreTab>(SkillStoreTab.LobeHub);
const [lobehubKeywords, setLobehubKeywords] = useState('');
+ const [skillKeywords, setSkillKeywords] = useState('');
const options: SegmentedOptions = [
{ label: t('skillStore.tabs.lobehub'), value: SkillStoreTab.LobeHub },
- { label: t('skillStore.tabs.community'), value: SkillStoreTab.Community },
+ { label: 'Skills', value: SkillStoreTab.Skills },
+ { label: t('skillStore.tabs.mcp'), value: SkillStoreTab.MCP },
{ label: t('skillStore.tabs.custom'), value: SkillStoreTab.Custom },
];
const isLobeHub = activeTab === SkillStoreTab.LobeHub;
- const isCommunity = activeTab === SkillStoreTab.Community;
+ const isSkills = activeTab === SkillStoreTab.Skills;
+ const isMCP = activeTab === SkillStoreTab.MCP;
const isCustom = activeTab === SkillStoreTab.Custom;
return (
@@ -46,14 +51,21 @@ export const SkillStoreContent = () => {
/>
<AddSkillButton />
</Flexbox>
- <Search activeTab={activeTab} onLobeHubSearch={setLobehubKeywords} />
+ <Search
+ activeTab={activeTab}
+ onLobeHubSearch={setLobehubKeywords}
+ onSkillSearch={setSkillKeywords}
+ />
</Flexbox>
<Flexbox height={496}>
<Flexbox flex={1} style={{ display: isLobeHub ? 'flex' : 'none', overflow: 'auto' }}>
<LobeHubList keywords={lobehubKeywords} />
</Flexbox>
- <Flexbox flex={1} style={{ display: isCommunity ? 'flex' : 'none', overflow: 'auto' }}>
- <CommunityList />
+ <Flexbox flex={1} style={{ display: isSkills ? 'flex' : 'none', overflow: 'auto' }}>
+ <MarketSkillList keywords={skillKeywords} />
+ </Flexbox>
+ <Flexbox flex={1} style={{ display: isMCP ? 'flex' : 'none', overflow: 'auto' }}>
+ <MCPList />
</Flexbox>
<Flexbox flex={1} style={{ display: isCustom ? 'flex' : 'none', overflow: 'auto' }}>
<CustomList />
diff --git a/src/locales/default/setting.ts b/src/locales/default/setting.ts
index c2ed93a9db1..9ea080f7d41 100644
--- a/src/locales/default/setting.ts
+++ b/src/locales/default/setting.ts
@@ -796,6 +796,8 @@ export default {
'skillStore.tabs.community': 'Community',
'skillStore.tabs.custom': 'Custom',
'skillStore.tabs.lobehub': 'LobeHub',
+ 'skillStore.tabs.mcp': 'MCP',
+ 'skillStore.tabs.skills': 'Skills',
'skillStore.title': 'Skill Store',
'skillStore.wantMore.action': 'Submit a request →',
'skillStore.wantMore.feedback.message': `## Skill Name